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 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 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 resultMap = new HashMap(); resultMap.put("outFenct",outFenct); resultMap.put("inFenct",inFenct); return R.ok().put("data",resultMap); } }