123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189 |
- package com.huimv.guowei.admin.controller;
- import cn.hutool.core.util.ObjectUtil;
- import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
- import com.huimv.guowei.admin.common.utils.PdfUtil;
- import com.huimv.guowei.admin.common.utils.Result;
- import com.huimv.guowei.admin.common.utils.ResultCode;
- import com.huimv.guowei.admin.common.utils.UploadImage;
- import com.huimv.guowei.admin.entity.BaseDuckBreedImg;
- import com.huimv.guowei.admin.entity.BaseDuckInfo;
- import com.huimv.guowei.admin.service.IBaseDuckBreedImgService;
- import com.huimv.guowei.admin.service.IBaseDuckInfoService;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.web.bind.annotation.*;
- import org.springframework.web.multipart.MultipartFile;
- import javax.servlet.http.HttpServletRequest;
- import javax.servlet.http.HttpServletResponse;
- import java.util.HashMap;
- import java.util.Map;
- /**
- * <p>
- * 前端控制器
- * </p>
- *
- * @author author
- * @since 2023-06-01
- */
- @RestController
- @RequestMapping("/base-duck-info")
- @CrossOrigin
- public class BaseDuckInfoController {
- @Autowired
- private IBaseDuckInfoService duckInfoService;
- @RequestMapping("/listDuck")
- public Result listDuck(HttpServletRequest httpServletRequest, @RequestBody Map<String, String> paramsMap) {
- return duckInfoService.listDuck(httpServletRequest, paramsMap);
- }
- @RequestMapping("/listAppDuck")
- public Result listAppDuck(HttpServletRequest httpServletRequest, @RequestBody Map<String, String> paramsMap) {
- return duckInfoService.listAppDuck(httpServletRequest, paramsMap);
- }
- @RequestMapping("/deleteDuck")
- public Result deleteDuck(HttpServletRequest httpServletRequest, @RequestBody Map<String, String> paramsMap) {
- duckInfoService.removeById(paramsMap.get("id"));
- return new Result(10000, "删除成功!", true);
- }
- @PostMapping("/addDuck")
- public Result addDuck(HttpServletRequest httpServletRequest, @RequestParam(name = "imgUrl", required = false) MultipartFile imgUrl,
- @RequestParam(name = "farmId") String farmId,
- @RequestParam(name = "unitList") String unitList,
- @RequestParam(name = "unitName") String unitName,
- @RequestParam(name = "duckBreed") String duckBreed,
- @RequestParam(name = "duckSex") String duckSex,
- @RequestParam(name = "duckBirthPlace") String duckBirthPlace,
- @RequestParam(name = "duckBirthDay") String duckBirthDay,
- @RequestParam(name = "genotype") String genotype,
- @RequestParam(name = "nowWeight") String nowWeight,
- @RequestParam(name = "unitId") String unitId,
- @RequestParam(name = "breedEnv") String breedEnv,
- @RequestParam(name = "hatchRate", required = false) String hatchRate,
- @RequestParam(name = "fatherNum", required = false) String fatherNum,
- @RequestParam(name = "motherNum", required = false) String motherNum,
- @RequestParam(name = "fatherGenotype") String fatherGenotype,
- @RequestParam(name = "motherGenotype") String motherGenotype,
- @RequestParam(name = "specialNeeds") String specialNeeds,
- @RequestParam(name = "batchNum") String batchNum,
- @RequestParam(name = "chiNum") String chiNum,
- @RequestParam(name = "jiaoNum") String jiaoNum,
- @RequestParam(name = "fatherChiNum",required = false) String fatherChiNum,
- @RequestParam(name = "fatherJiaoNum",required = false) String fatherJiaoNum,
- @RequestParam(name = "motherChiNum",required = false) String motherChiNum,
- @RequestParam(name = "motherJiaoNum",required = false) String motherJiaoNum) throws Exception {
- httpServletRequest.setCharacterEncoding("UTF-8");
- Map<String, String> map = new HashMap<>();
- map.put("unitList", unitList);
- map.put("unitName", unitName);
- map.put("farmId", farmId);
- map.put("duckBreed", duckBreed);
- map.put("duckSex", duckSex);
- map.put("duckBirthPlace", duckBirthPlace);
- map.put("duckBirthDay", duckBirthDay);
- map.put("genotype", genotype);
- map.put("nowWeight", nowWeight);
- map.put("unitId", unitId);
- map.put("breedEnv", breedEnv);
- map.put("hatchRate", hatchRate);
- map.put("fatherNum", fatherNum);
- map.put("motherNum", motherNum);
- map.put("fatherGenotype", fatherGenotype);
- map.put("motherGenotype", motherGenotype);
- map.put("specialNeeds", specialNeeds);
- map.put("batchNum", batchNum);
- map.put("chiNum", chiNum);
- map.put("jiaoNum", jiaoNum);
- map.put("fatherChiNum", fatherChiNum);
- map.put("fatherJiaoNum", fatherJiaoNum);
- map.put("motherChiNum", motherChiNum);
- map.put("motherJiaoNum", motherJiaoNum);
- return duckInfoService.addDuck(httpServletRequest, map, imgUrl);
- }
- @RequestMapping("/editDuck")
- public Result editDuck(HttpServletRequest httpServletRequest, @RequestBody BaseDuckInfo baseDuckInfo) {
- return duckInfoService.editDuck(httpServletRequest, baseDuckInfo);
- }
- @RequestMapping("/listDuckById")
- public Result listDuckById(HttpServletRequest httpServletRequest, @RequestBody Map<String, String> paramsMap) {
- return duckInfoService.listDuckById(httpServletRequest, paramsMap);
- }
- @PostMapping("/getLocationById")
- public Result getLocationById(@RequestBody Map<String, String> paramsMap) {
- String duckNum = paramsMap.get("duckNum");
- BaseDuckInfo baseDuckInfo = duckInfoService.getOne(new QueryWrapper<BaseDuckInfo>().eq("duck_num", duckNum));
- if (ObjectUtil.isEmpty(baseDuckInfo)) {
- return new Result(10001, "鸭只不存在", false);
- }
- Map resultMap = new HashMap();
- resultMap.put("unitName", baseDuckInfo.getUnitName());
- resultMap.put("unitId", baseDuckInfo.getUnitId());
- return new Result(ResultCode.SUCCESS, resultMap);
- }
- @PostMapping("/getDuckNumByUnitId")
- public Result getDuckNumByUnitId(@RequestBody Map<String, String> paramsMap) {
- String unitId = paramsMap.get("unitId");
- String farmId = paramsMap.get("farmId");
- BaseDuckInfo baseDuckInfo = duckInfoService.getOne(new QueryWrapper<BaseDuckInfo>().eq("farm_id", farmId).eq("unit_id", unitId).eq("is_cage", 0));
- if (ObjectUtil.isEmpty(baseDuckInfo)) {
- return new Result(10001, "该笼位无鸭只", false);
- }
- Map resultMap = new HashMap();
- resultMap.put("chiNum", baseDuckInfo.getChiNum());
- resultMap.put("jiaoNum", baseDuckInfo.getJiaoNum());
- resultMap.put("batchNum", baseDuckInfo.getBatchNum());
- resultMap.put("unitName", baseDuckInfo.getUnitName());
- resultMap.put("duckNum", baseDuckInfo.getDuckNum());
- return new Result(ResultCode.SUCCESS, resultMap);
- }
- @GetMapping("/printDuck")
- public void printDuck(HttpServletResponse response, @RequestParam(name = "duckCode") String duckCode) throws Exception {
- Map<String, String> map = new HashMap<>();
- map.put("duckCode", duckCode);
- duckInfoService.printDuck(response, map);
- String path = "/opt/guowei/duck.xls";
- PdfUtil.returnPdfStream3(response, path, "鸭只档案列表");
- }
- @GetMapping("/printChi")
- public void printChi(HttpServletResponse response, @RequestParam(name = "farmId") String farmId) throws Exception {
- Map<String, String> map = new HashMap<>();
- map.put("farmId", farmId);
- duckInfoService.printChi(response, map);
- String path = "/opt/guowei/chi.xls";
- PdfUtil.returnPdfStream3(response, path, "最新笼位列表");
- }
- //excel导入
- @PostMapping("/importData")
- public Result importData(HttpServletRequest httpServletRequest, @RequestParam(name = "file") MultipartFile file,
- @RequestParam(name = "farmId") String farmId) throws Exception {
- Map<String, String> map = new HashMap<>();
- map.put("farmId", farmId);
- return duckInfoService.importData(httpServletRequest, map, file);
- }
- //大屏
- @RequestMapping("/listDuckByScreen")
- public Result listDuckByScreen(HttpServletRequest httpServletRequest, @RequestBody Map<String, String> paramsMap) {
- return duckInfoService.listDuckByScreen(httpServletRequest, paramsMap);
- }
- @RequestMapping("/listDuckByScreen2")
- public Result listDuckByScreen2(HttpServletRequest httpServletRequest, @RequestBody Map<String, String> paramsMap) {
- return duckInfoService.listDuckByScreen2(httpServletRequest, paramsMap);
- }
- }
|