123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140 |
- package com.huimv.management.controller;
- import java.util.Arrays;
- import java.util.Date;
- import java.util.HashMap;
- import java.util.Map;
- import io.swagger.annotations.Api;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.web.bind.annotation.PathVariable;
- import org.springframework.web.bind.annotation.RequestBody;
- import org.springframework.web.bind.annotation.RequestMapping;
- import org.springframework.web.bind.annotation.RequestParam;
- import org.springframework.web.bind.annotation.RestController;
- import com.huimv.management.entity.YearPigBaseEntity;
- import com.huimv.management.service.YearPigBaseService;
- import com.huimv.common.utils.PageUtils;
- import com.huimv.common.utils.R;
- /**
- * 年猪基本
- *
- * @author yinhao
- * @email yinhao@163.com
- * @date 2021-05-07 15:32:42
- */
- @Api(tags = "年猪基本")
- @RestController
- @RequestMapping("management/yearpigbase")
- public class YearPigBaseController {
- @Autowired
- private YearPigBaseService yearPigBaseService;
- /**
- * 列表
- */
- @RequestMapping("/list")
- public R list(@RequestParam Map<String, Object> params){
- PageUtils page = yearPigBaseService.queryPage(params);
- return R.ok().put("page", page);
- }
- /**
- * 信息
- */
- @RequestMapping("/info/{id}")
- public R info(@PathVariable("id") Integer id){
- YearPigBaseEntity yearPigBase = yearPigBaseService.getById(id);
- return R.ok().put("yearPigBase", yearPigBase);
- }
- /**
- * 保存
- */
- @RequestMapping("/save")
- public R save(@RequestBody YearPigBaseEntity yearPigBase){
- yearPigBaseService.save(yearPigBase);
- return R.ok();
- }
- /**
- * 修改
- */
- @RequestMapping("/update")
- public R update(@RequestBody YearPigBaseEntity yearPigBase){
- yearPigBaseService.updateById(yearPigBase);
- return R.ok();
- }
- /**
- * 删除
- */
- @RequestMapping("/delete")
- public R delete(@RequestBody Integer[] ids){
- yearPigBaseService.removeByIds(Arrays.asList(ids));
- return R.ok();
- }
- /*@RequestMapping("/batchLairage")
- public R batchLairage(@RequestBody Map<String, Object> map){
- String eartags = (String)map.get("eartags");
- Integer periodId = (Integer)map.get("periodId");
- String[] split = eartags.split(",");
- yearPigBaseService.batchLairage(split,periodId);
- return R.ok();
- } */
- //批量入栏
- @RequestMapping("/batchLairage")
- public R batchLairage(@RequestBody YearPigBaseEntity yearPigBase){
- for (String eartage : yearPigBase.getEartag().split(",")) {
- yearPigBase.setEartag(eartage);
- yearPigBaseService.save(yearPigBase);
- }
- return R.ok();
- }
- //批量出栏
- @RequestMapping("/such")
- public R such(@RequestParam Integer[] ids){
- // YearPigBaseEntity yearPigBaseEntity = new YearPigBaseEntity();
- // yearPigBaseEntity.setOutFenceStatus(1);
- // yearPigBaseEntity.setOutFenceTime(new Date());
- //
- //
- // for (Integer id : ids) {
- // yearPigBaseEntity.setId(id);
- // yearPigBaseService.updateById(yearPigBaseEntity);
- // }
- yearPigBaseService.such(ids);
- return R.ok();
- }
- //出栏入栏比例
- @RequestMapping("/outAndInProportion")
- public R outAndInProportion(Integer farmId){
- //出栏
- Integer outFenct = yearPigBaseService.findByoutFenceStatus(1,farmId);
- //育肥
- Integer inFenct = yearPigBaseService.findByoutFenceStatus(0,farmId);
- Map<String,Integer> resultMap = new HashMap<String,Integer>();
- resultMap.put("outFenct",outFenct);
- resultMap.put("inFenct",inFenct);
- return R.ok().put("data",resultMap);
- }
- }
|