BaseDuckInfoController.java 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. package com.huimv.guowei.admin.controller;
  2. import cn.hutool.core.util.ObjectUtil;
  3. import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
  4. import com.huimv.guowei.admin.common.utils.PdfUtil;
  5. import com.huimv.guowei.admin.common.utils.Result;
  6. import com.huimv.guowei.admin.common.utils.ResultCode;
  7. import com.huimv.guowei.admin.common.utils.UploadImage;
  8. import com.huimv.guowei.admin.entity.BaseDuckBreedImg;
  9. import com.huimv.guowei.admin.entity.BaseDuckInfo;
  10. import com.huimv.guowei.admin.service.IBaseDuckBreedImgService;
  11. import com.huimv.guowei.admin.service.IBaseDuckInfoService;
  12. import org.springframework.beans.factory.annotation.Autowired;
  13. import org.springframework.web.bind.annotation.*;
  14. import org.springframework.web.multipart.MultipartFile;
  15. import javax.servlet.http.HttpServletRequest;
  16. import javax.servlet.http.HttpServletResponse;
  17. import java.util.HashMap;
  18. import java.util.Map;
  19. /**
  20. * <p>
  21. * 前端控制器
  22. * </p>
  23. *
  24. * @author author
  25. * @since 2023-06-01
  26. */
  27. @RestController
  28. @RequestMapping("/base-duck-info")
  29. @CrossOrigin
  30. public class BaseDuckInfoController {
  31. @Autowired
  32. private IBaseDuckInfoService duckInfoService;
  33. @RequestMapping("/listDuck")
  34. public Result listDuck(HttpServletRequest httpServletRequest, @RequestBody Map<String, String> paramsMap) {
  35. return duckInfoService.listDuck(httpServletRequest, paramsMap);
  36. }
  37. @RequestMapping("/listAppDuck")
  38. public Result listAppDuck(HttpServletRequest httpServletRequest, @RequestBody Map<String, String> paramsMap) {
  39. return duckInfoService.listAppDuck(httpServletRequest, paramsMap);
  40. }
  41. @RequestMapping("/deleteDuck")
  42. public Result deleteDuck(HttpServletRequest httpServletRequest, @RequestBody Map<String, String> paramsMap) {
  43. duckInfoService.removeById(paramsMap.get("id"));
  44. return new Result(10000, "删除成功!", true);
  45. }
  46. @PostMapping("/addDuck")
  47. public Result addDuck(HttpServletRequest httpServletRequest, @RequestParam(name = "imgUrl", required = false) MultipartFile imgUrl,
  48. @RequestParam(name = "farmId") String farmId,
  49. @RequestParam(name = "unitList") String unitList,
  50. @RequestParam(name = "unitName") String unitName,
  51. @RequestParam(name = "duckBreed") String duckBreed,
  52. @RequestParam(name = "duckSex") String duckSex,
  53. @RequestParam(name = "duckBirthPlace") String duckBirthPlace,
  54. @RequestParam(name = "duckBirthDay") String duckBirthDay,
  55. @RequestParam(name = "genotype") String genotype,
  56. @RequestParam(name = "nowWeight") String nowWeight,
  57. @RequestParam(name = "unitId") String unitId,
  58. @RequestParam(name = "breedEnv") String breedEnv,
  59. @RequestParam(name = "hatchRate", required = false) String hatchRate,
  60. @RequestParam(name = "fatherNum", required = false) String fatherNum,
  61. @RequestParam(name = "motherNum", required = false) String motherNum,
  62. @RequestParam(name = "fatherGenotype") String fatherGenotype,
  63. @RequestParam(name = "motherGenotype") String motherGenotype,
  64. @RequestParam(name = "specialNeeds") String specialNeeds,
  65. @RequestParam(name = "batchNum") String batchNum,
  66. @RequestParam(name = "chiNum") String chiNum,
  67. @RequestParam(name = "jiaoNum") String jiaoNum,
  68. @RequestParam(name = "fatherChiNum",required = false) String fatherChiNum,
  69. @RequestParam(name = "fatherJiaoNum",required = false) String fatherJiaoNum,
  70. @RequestParam(name = "motherChiNum",required = false) String motherChiNum,
  71. @RequestParam(name = "motherJiaoNum",required = false) String motherJiaoNum) throws Exception {
  72. httpServletRequest.setCharacterEncoding("UTF-8");
  73. Map<String, String> map = new HashMap<>();
  74. map.put("unitList", unitList);
  75. map.put("unitName", unitName);
  76. map.put("farmId", farmId);
  77. map.put("duckBreed", duckBreed);
  78. map.put("duckSex", duckSex);
  79. map.put("duckBirthPlace", duckBirthPlace);
  80. map.put("duckBirthDay", duckBirthDay);
  81. map.put("genotype", genotype);
  82. map.put("nowWeight", nowWeight);
  83. map.put("unitId", unitId);
  84. map.put("breedEnv", breedEnv);
  85. map.put("hatchRate", hatchRate);
  86. map.put("fatherNum", fatherNum);
  87. map.put("motherNum", motherNum);
  88. map.put("fatherGenotype", fatherGenotype);
  89. map.put("motherGenotype", motherGenotype);
  90. map.put("specialNeeds", specialNeeds);
  91. map.put("batchNum", batchNum);
  92. map.put("chiNum", chiNum);
  93. map.put("jiaoNum", jiaoNum);
  94. map.put("fatherChiNum", fatherChiNum);
  95. map.put("fatherJiaoNum", fatherJiaoNum);
  96. map.put("motherChiNum", motherChiNum);
  97. map.put("motherJiaoNum", motherJiaoNum);
  98. return duckInfoService.addDuck(httpServletRequest, map, imgUrl);
  99. }
  100. @RequestMapping("/editDuck")
  101. public Result editDuck(HttpServletRequest httpServletRequest, @RequestBody BaseDuckInfo baseDuckInfo) {
  102. return duckInfoService.editDuck(httpServletRequest, baseDuckInfo);
  103. }
  104. @RequestMapping("/listDuckById")
  105. public Result listDuckById(HttpServletRequest httpServletRequest, @RequestBody Map<String, String> paramsMap) {
  106. return duckInfoService.listDuckById(httpServletRequest, paramsMap);
  107. }
  108. @PostMapping("/getLocationById")
  109. public Result getLocationById(@RequestBody Map<String, String> paramsMap) {
  110. String duckNum = paramsMap.get("duckNum");
  111. BaseDuckInfo baseDuckInfo = duckInfoService.getOne(new QueryWrapper<BaseDuckInfo>().eq("duck_num", duckNum));
  112. if (ObjectUtil.isEmpty(baseDuckInfo)) {
  113. return new Result(10001, "鸭只不存在", false);
  114. }
  115. Map resultMap = new HashMap();
  116. resultMap.put("unitName", baseDuckInfo.getUnitName());
  117. resultMap.put("unitId", baseDuckInfo.getUnitId());
  118. return new Result(ResultCode.SUCCESS, resultMap);
  119. }
  120. @PostMapping("/getDuckNumByUnitId")
  121. public Result getDuckNumByUnitId(@RequestBody Map<String, String> paramsMap) {
  122. String unitId = paramsMap.get("unitId");
  123. String farmId = paramsMap.get("farmId");
  124. BaseDuckInfo baseDuckInfo = duckInfoService.getOne(new QueryWrapper<BaseDuckInfo>().eq("farm_id", farmId).eq("unit_id", unitId).eq("is_cage", 0));
  125. if (ObjectUtil.isEmpty(baseDuckInfo)) {
  126. return new Result(10001, "该笼位无鸭只", false);
  127. }
  128. Map resultMap = new HashMap();
  129. resultMap.put("chiNum", baseDuckInfo.getChiNum());
  130. resultMap.put("jiaoNum", baseDuckInfo.getJiaoNum());
  131. resultMap.put("batchNum", baseDuckInfo.getBatchNum());
  132. resultMap.put("unitName", baseDuckInfo.getUnitName());
  133. resultMap.put("duckNum", baseDuckInfo.getDuckNum());
  134. return new Result(ResultCode.SUCCESS, resultMap);
  135. }
  136. @GetMapping("/printDuck")
  137. public void printDuck(HttpServletResponse response, @RequestParam(name = "duckCode") String duckCode) throws Exception {
  138. Map<String, String> map = new HashMap<>();
  139. map.put("duckCode", duckCode);
  140. duckInfoService.printDuck(response, map);
  141. String path = "/opt/guowei/duck.xls";
  142. PdfUtil.returnPdfStream3(response, path, "鸭只档案列表");
  143. }
  144. @GetMapping("/printChi")
  145. public void printChi(HttpServletResponse response, @RequestParam(name = "farmId") String farmId) throws Exception {
  146. Map<String, String> map = new HashMap<>();
  147. map.put("farmId", farmId);
  148. duckInfoService.printChi(response, map);
  149. String path = "/opt/guowei/chi.xls";
  150. PdfUtil.returnPdfStream3(response, path, "最新笼位列表");
  151. }
  152. //excel导入
  153. @PostMapping("/importData")
  154. public Result importData(HttpServletRequest httpServletRequest, @RequestParam(name = "file") MultipartFile file,
  155. @RequestParam(name = "farmId") String farmId) throws Exception {
  156. Map<String, String> map = new HashMap<>();
  157. map.put("farmId", farmId);
  158. return duckInfoService.importData(httpServletRequest, map, file);
  159. }
  160. //大屏
  161. @RequestMapping("/listDuckByScreen")
  162. public Result listDuckByScreen(HttpServletRequest httpServletRequest, @RequestBody Map<String, String> paramsMap) {
  163. return duckInfoService.listDuckByScreen(httpServletRequest, paramsMap);
  164. }
  165. @RequestMapping("/listDuckByScreen2")
  166. public Result listDuckByScreen2(HttpServletRequest httpServletRequest, @RequestBody Map<String, String> paramsMap) {
  167. return duckInfoService.listDuckByScreen2(httpServletRequest, paramsMap);
  168. }
  169. }