首页 > 编程语言 >牧场系统设计与实现-计算机毕业设计源码+LW文档

牧场系统设计与实现-计算机毕业设计源码+LW文档

时间:2022-11-19 21:02:13浏览次数:42  
标签:yaopinrukuInfo LW 源码 Result 毕业设计 new put import row

关键代码

package com.example.controller;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.io.IoUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.crypto.SecureUtil;
import cn.hutool.json.JSONObject;
import cn.hutool.poi.excel.ExcelUtil;
import cn.hutool.poi.excel.ExcelWriter;
import com.example.common.Result;
import com.example.common.ResultCode;
import com.example.entity.YaopinrukuInfo;
import com.example.dao.YaopinrukuInfoDao;
import com.example.service.YaopinrukuInfoService;
import com.example.exception.CustomException;
import com.example.common.ResultCode;
import com.example.vo.EchartsData;
import com.example.vo.YaopinrukuInfoVo;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.example.service.*;
import org.springframework.web.bind.annotation.*;
import org.springframework.beans.factory.annotation.Value;
import cn.hutool.core.util.StrUtil;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.*;
import java.util.stream.Collectors;

@RestController
@RequestMapping(value = "/yaopinrukuInfo")
public class YaopinrukuInfoController {

    @Resource
    private YaopinrukuInfoService yaopinrukuInfoService;
@Resource
    private YaopinrukuInfoDao yaopinrukuInfoDao;

    @PostMapping
    public Result<YaopinrukuInfo> add(@RequestBody YaopinrukuInfoVo yaopinrukuInfo) {
        
//mixmajixami
yaopinrukuInfoService.add(yaopinrukuInfo);
        return Result.success(yaopinrukuInfo);
    }

//youtixing1
    //youtixing2

    @DeleteMapping("/{id}")
    public Result delete(@PathVariable Long id) {
        yaopinrukuInfoService.delete(id);
        return Result.success();
    }

    @PutMapping
    public Result update(@RequestBody YaopinrukuInfoVo yaopinrukuInfo) {
        yaopinrukuInfoService.update(yaopinrukuInfo);
        return Result.success();
    }
    //@PutMapping("/update2")
//    public Result update2(@RequestBody YaopinrukuInfoVo yaopinrukuInfo) {
//        yaopinrukuInfoService.update2(yaopinrukuInfo);
//        return Result.success();
//    }
    @GetMapping("/{id}")
    public Result<YaopinrukuInfo> detail(@PathVariable Long id) {
        YaopinrukuInfo yaopinrukuInfo = yaopinrukuInfoService.findById(id);
        return Result.success(yaopinrukuInfo);
    }
    @GetMapping("/changeStatus/{id}")
    public Result<YaopinrukuInfo> changeStatus(@PathVariable Long id) {
        yaopinrukuInfoService.changeStatus(id);
        return Result.success();
    }


    @GetMapping
    public Result<List<YaopinrukuInfoVo>> all() {
        return Result.success(yaopinrukuInfoService.findAll());
    }

    @GetMapping("/page/{name}")
    public Result<PageInfo<YaopinrukuInfoVo>> page(@PathVariable String name,
                                                @RequestParam(defaultValue = "1") Integer pageNum,
                                                @RequestParam(defaultValue = "5") Integer pageSize,
                                                HttpServletRequest request) {
        return Result.success(yaopinrukuInfoService.findPage(name, pageNum, pageSize, request));
    }

@GetMapping("/pageqt/{name}")
    public Result<PageInfo<YaopinrukuInfoVo>> pageqt(@PathVariable String name,
                                                @RequestParam(defaultValue = "1") Integer pageNum,
                                                @RequestParam(defaultValue = "8") Integer pageSize,
                                                HttpServletRequest request) {
        return Result.success(yaopinrukuInfoService.findPageqt(name, pageNum, pageSize, request));
    }

   // @PostMapping("/register")
//    public Result<YaopinrukuInfo> register(@RequestBody YaopinrukuInfo yaopinrukuInfo) {
//        if (StrUtil.isBlank(yaopinrukuInfo.getName()) || StrUtil.isBlank(yaopinrukuInfo.getPassword())) {
//            throw new CustomException(ResultCode.PARAM_ERROR);
//        }
//        return Result.success(yaopinrukuInfoService.add(yaopinrukuInfo));
//    }

    /**
    * 批量通过excel添加信息
    * @param file excel文件
    * @throws IOException
    */
    @PostMapping("/upload")
    public Result upload(MultipartFile file) throws IOException {

        List<YaopinrukuInfo> infoList = ExcelUtil.getReader(file.getInputStream()).readAll(YaopinrukuInfo.class);
        if (!CollectionUtil.isEmpty(infoList)) {
            // 处理一下空数据
            List<YaopinrukuInfo> resultList = infoList.stream().filter(x -> ObjectUtil.isNotEmpty(x.getYaopinmingcheng())).collect(Collectors.toList());
            for (YaopinrukuInfo info : resultList) {
                yaopinrukuInfoService.add(info);
            }
        }
        return Result.success();
    }
//yoxutonxgjitu
    @GetMapping("/getExcelModel")
    public void getExcelModel(HttpServletResponse response) throws IOException {
        // 1. 生成excel
        Map<String, Object> row = new LinkedHashMap<>();
row.put("yaopinbianhao", "A药品编号");
row.put("yaopinmingcheng", "A药品名称");
row.put("kucun", "A库存");
row.put("rukushuliang", "A入库数量");
row.put("rukushijian", "A入库时间");
row.put("beizhu", "A备注");
row.put("caozuoren", "A操作人"); row.put("status", "是");
row.put("level", "yaopinruku");

        List<Map<String, Object>> list = CollUtil.newArrayList(row);

        // 2. 写excel
        ExcelWriter writer = ExcelUtil.getWriter(true);
        writer.write(list, true);

        response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8");
        response.setHeader("Content-Disposition","attachment;filename=yaopinrukuInfoModel.xlsx");

        ServletOutputStream out = response.getOutputStream();
        writer.flush(out, true);
        writer.close();
        IoUtil.close(System.out);
    }
@GetMapping("/getExcel")
    public void getExcel(HttpServletResponse response) throws IOException {
        // 1. 生成excel
        Map<String, Object> row = new LinkedHashMap<>();
        row.put("yaopinbianhao", "A药品编号");
row.put("yaopinmingcheng", "A药品名称");
row.put("kucun", "A库存");
row.put("rukushuliang", "A入库数量");
row.put("rukushijian", "A入库时间");
row.put("beizhu", "A备注");
row.put("caozuoren", "A操作人"); 
        row.put("status", "是");
        row.put("level", "权限");
        List<Map<String, Object>> list = CollUtil.newArrayList(row);
        List<Map<String, Object>> daochuexcellist = yaopinrukuInfoDao.daochuexcel();
        Map<String, Double> typeMap = new HashMap<>();
        for (Map<String, Object> map : daochuexcellist) {
            list.add(map);
        }
        // 2. 写excel
        ExcelWriter writer = ExcelUtil.getWriter(true);
        writer.write(list, true);

        response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8");
        response.setHeader("Content-Disposition","attachment;filename=yaopinrukuInfo.xlsx");

        ServletOutputStream out = response.getOutputStream();
        writer.flush(out, true);
        writer.close();
        IoUtil.close(System.out);
    }
private void getPieData(String name, List<EchartsData> pieList, Map<String, Double> dataMap) {
        EchartsData pieData = new EchartsData();
        EchartsData.Series series = new EchartsData.Series();

        Map<String, String> titleMap = new HashMap<>(2);
        titleMap.put("text", name);
        pieData.setTitle(titleMap);

        series.setName(name + "比例");
        series.setType("pie");
        series.setRadius("55%");

        List<Object> objects = new ArrayList<>();
        List<Object> legendList = new ArrayList<>();
        for (String key : dataMap.keySet()) {
            Double value = dataMap.get(key);
            objects.add(new JSONObject().putOpt("name", key).putOpt("value", value));
            legendList.add(key);
        }
        series.setData(objects);

        pieData.setSeries(Collections.singletonList(series));
        Map<String, Boolean> map = new HashMap<>();
        map.put("show", true);
        pieData.setTooltip(map);

        Map<String, Object> legendMap = new HashMap<>(4);
        legendMap.put("orient", "vertical");
        legendMap.put("x", "left");
        legendMap.put("y", "center");
        legendMap.put("data", legendList);
        pieData.setLegend(legendMap);

        pieList.add(pieData);
    }

    private void getBarData(String name, List<EchartsData> barList, Map<String, Double> dataMap) {
        EchartsData barData = new EchartsData();
        EchartsData.Series series = new EchartsData.Series();

        List<Object> seriesObjs = new ArrayList<>();
        List<Object> xAxisObjs = new ArrayList<>();
        for (String key : dataMap.keySet()) {
            Double value = dataMap.get(key);
            xAxisObjs.add(key);
            seriesObjs.add(value);
        }

        series.setType("bar");
        series.setName(name);
        series.setData(seriesObjs);
        barData.setSeries(Collections.singletonList(series));

        Map<String, Object> xAxisMap = new HashMap<>(1);
        xAxisMap.put("data", xAxisObjs);
        barData.setxAxis(xAxisMap);

        barData.setyAxis(new HashMap<>());

        Map<String, Object> legendMap = new HashMap<>(1);
        legendMap.put("data", Collections.singletonList(name));
        barData.setLegend(legendMap);

        Map<String, Boolean> map = new HashMap<>(1);
        map.put("show", true);
        barData.setTooltip(map);

        Map<String, String> titleMap = new HashMap<>(1);
        titleMap.put("text", name);
        barData.setTitle(titleMap);

        barList.add(barData);
    }
}

牧场系统设计与实现-计算机毕业设计源码+LW文档_java

牧场系统设计与实现-计算机毕业设计源码+LW文档_java_02

牧场系统设计与实现-计算机毕业设计源码+LW文档_java_03

牧场系统设计与实现-计算机毕业设计源码+LW文档_spring_04

标签:yaopinrukuInfo,LW,源码,Result,毕业设计,new,put,import,row
From: https://blog.51cto.com/u_15745565/5870639

相关文章

  • 养老服务系统设计与实现-计算机毕业设计源码+LW文档
    基于SSM的养老服务系统设计与实现摘 要本养老服务系统就是建立在充分利用现在完善科技技术这个理念基础之上,并使用IT技术进行对养老服务的管理,从而保证系统得到充分利用......
  • Odoo学习笔记(一) odoo的源码安装
    一、安装环境操作系统:Ubuntu22.04系统环境准备运行库的安装,不然安装psycopg2和python-ldap会失败#pg的运行库apt-getinstalllibpq-dev#ldap的运行库apt-getin......
  • 2022最新wifi大师,wifi分销小程序源码,亲测可用
     话不多说,直接上干货 微信搜索,wifi鑫速连,就可以获得免费源码,免费搭建源码:链接  ​......
  • JAVA仓库管理系统(附源码+调试)
    JAVA仓库管理系统——三只松鼠仓库管理系统功能描述(1)登录模块:登录信息等存储在数据库中(2)基本档案管理模块:供货商管理,销售商管理,货品档案管理,仓库管理(3)采购订货模块:用户可以......
  • C++学习------cinttypes头文件的源码学习02---函数定义
    函数定义257__BEGIN_DECLS258intmax_timaxabs(intmax_t__i)__attribute_const____INTRODUCED_IN(19);259imaxdiv_timaxdiv(intmax_t__numerator,intmax_t__de......
  • settings配置文件和源码
    BASE_DIR:用来在项目中构建路径SECRET_KEY:项目生成时候用的秘钥DEBUG:调试模式,在写代码的时候打开,投入使用了就不用了ALLOWED_HOSTS=['']:运行那些ip来进行访问......
  • MySQL 源码解读之-语法解析(四)
    MySQL源码解读之-语法解析(四)在上篇文章中,我们分析了一条sql语句select*frombank;警告bison语法解析器(MYSQLparser函数)生成的AST树的结构,如下图所示:mysql需......
  • 微前端之四 • Single SPA 的源码实现
    深入了解一个库最好的办法是直接去看源代码,学习作者的设计模式、运行原理、代码风格等。并且动手跑起来,碰到不懂的地方打断点或者打印关键信息,一步一步去琢磨。很多流行库......
  • mybatis源码解析1
    一、mybatis的简单使用根据mybatis官网提供的例子,需要这么几个步骤1、获取mybatis配置文件的输入流对象2、创建SqlSessionFactoryBuilder对象3、调用SqlSessionFactor......
  • 数据库处理封装 GotDotNet.ApplicationBlocks.Data AdoHelper Dao 源码
    数据库处理封装GotDotNet.ApplicationBlocks.DataAdoHelperDao源码在GotDotNet.ApplicationBlocks.DataAdoHelper源码的基础上进行封装处理使调用更方便。支持所有常......