YearPigBaseController.java 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. package com.huimv.management.controller;
  2. import java.util.Arrays;
  3. import java.util.Date;
  4. import java.util.HashMap;
  5. import java.util.Map;
  6. import io.swagger.annotations.Api;
  7. import org.springframework.beans.factory.annotation.Autowired;
  8. import org.springframework.web.bind.annotation.PathVariable;
  9. import org.springframework.web.bind.annotation.RequestBody;
  10. import org.springframework.web.bind.annotation.RequestMapping;
  11. import org.springframework.web.bind.annotation.RequestParam;
  12. import org.springframework.web.bind.annotation.RestController;
  13. import com.huimv.management.entity.YearPigBaseEntity;
  14. import com.huimv.management.service.YearPigBaseService;
  15. import com.huimv.common.utils.PageUtils;
  16. import com.huimv.common.utils.R;
  17. /**
  18. * 年猪基本
  19. *
  20. * @author yinhao
  21. * @email yinhao@163.com
  22. * @date 2021-05-07 15:32:42
  23. */
  24. @Api(tags = "年猪基本")
  25. @RestController
  26. @RequestMapping("management/yearpigbase")
  27. public class YearPigBaseController {
  28. @Autowired
  29. private YearPigBaseService yearPigBaseService;
  30. /**
  31. * 列表
  32. */
  33. @RequestMapping("/list")
  34. public R list(@RequestParam Map<String, Object> params){
  35. PageUtils page = yearPigBaseService.queryPage(params);
  36. return R.ok().put("page", page);
  37. }
  38. /**
  39. * 信息
  40. */
  41. @RequestMapping("/info/{id}")
  42. public R info(@PathVariable("id") Integer id){
  43. YearPigBaseEntity yearPigBase = yearPigBaseService.getById(id);
  44. return R.ok().put("yearPigBase", yearPigBase);
  45. }
  46. /**
  47. * 保存
  48. */
  49. @RequestMapping("/save")
  50. public R save(@RequestBody YearPigBaseEntity yearPigBase){
  51. yearPigBaseService.save(yearPigBase);
  52. return R.ok();
  53. }
  54. /**
  55. * 修改
  56. */
  57. @RequestMapping("/update")
  58. public R update(@RequestBody YearPigBaseEntity yearPigBase){
  59. yearPigBaseService.updateById(yearPigBase);
  60. return R.ok();
  61. }
  62. /**
  63. * 删除
  64. */
  65. @RequestMapping("/delete")
  66. public R delete(@RequestBody Integer[] ids){
  67. yearPigBaseService.removeByIds(Arrays.asList(ids));
  68. return R.ok();
  69. }
  70. /*@RequestMapping("/batchLairage")
  71. public R batchLairage(@RequestBody Map<String, Object> map){
  72. String eartags = (String)map.get("eartags");
  73. Integer periodId = (Integer)map.get("periodId");
  74. String[] split = eartags.split(",");
  75. yearPigBaseService.batchLairage(split,periodId);
  76. return R.ok();
  77. } */
  78. //批量入栏
  79. @RequestMapping("/batchLairage")
  80. public R batchLairage(@RequestBody YearPigBaseEntity yearPigBase){
  81. for (String eartage : yearPigBase.getEartag().split(",")) {
  82. yearPigBase.setEartag(eartage);
  83. yearPigBaseService.save(yearPigBase);
  84. }
  85. return R.ok();
  86. }
  87. //批量出栏
  88. @RequestMapping("/such")
  89. public R such(@RequestParam Integer[] ids){
  90. // YearPigBaseEntity yearPigBaseEntity = new YearPigBaseEntity();
  91. // yearPigBaseEntity.setOutFenceStatus(1);
  92. // yearPigBaseEntity.setOutFenceTime(new Date());
  93. //
  94. //
  95. // for (Integer id : ids) {
  96. // yearPigBaseEntity.setId(id);
  97. // yearPigBaseService.updateById(yearPigBaseEntity);
  98. // }
  99. yearPigBaseService.such(ids);
  100. return R.ok();
  101. }
  102. //出栏入栏比例
  103. @RequestMapping("/outAndInProportion")
  104. public R outAndInProportion(Integer farmId){
  105. //出栏
  106. Integer outFenct = yearPigBaseService.findByoutFenceStatus(1,farmId);
  107. //育肥
  108. Integer inFenct = yearPigBaseService.findByoutFenceStatus(0,farmId);
  109. Map<String,Integer> resultMap = new HashMap<String,Integer>();
  110. resultMap.put("outFenct",outFenct);
  111. resultMap.put("inFenct",inFenct);
  112. return R.ok().put("data",resultMap);
  113. }
  114. }