|
@@ -1,16 +1,20 @@
|
|
|
package com.ruoyi.web.v2.v1.controller;
|
|
package com.ruoyi.web.v2.v1.controller;
|
|
|
|
|
|
|
|
-
|
|
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.ruoyi.app.model.Pigpen;
|
|
import com.ruoyi.app.model.Pigpen;
|
|
|
import com.ruoyi.app.mapper.PigpenMapper;
|
|
import com.ruoyi.app.mapper.PigpenMapper;
|
|
|
import com.ruoyi.common.core.domain.AjaxResult;
|
|
import com.ruoyi.common.core.domain.AjaxResult;
|
|
|
|
|
+import com.ruoyi.web.v2.v1.mapper.JsDivideCircleMapper;
|
|
|
|
|
+import com.ruoyi.web.v2.v1.model.JsDivideCircle;
|
|
|
import com.ruoyi.web.v2.v1.model.JsReport;
|
|
import com.ruoyi.web.v2.v1.model.JsReport;
|
|
|
import com.ruoyi.web.v2.v1.service.IJsReportService;
|
|
import com.ruoyi.web.v2.v1.service.IJsReportService;
|
|
|
import io.swagger.annotations.Api;
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
+import org.springframework.util.ObjectUtils;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
|
|
import java.util.Date;
|
|
import java.util.Date;
|
|
@@ -35,6 +39,8 @@ public class JsReportController {
|
|
|
private IJsReportService reportService;
|
|
private IJsReportService reportService;
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private PigpenMapper pigpenMapper;
|
|
private PigpenMapper pigpenMapper;
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private JsDivideCircleMapper jsDivideCircleMapper;
|
|
|
|
|
|
|
|
@ApiOperation("完工报告添加")
|
|
@ApiOperation("完工报告添加")
|
|
|
@PostMapping("/add")
|
|
@PostMapping("/add")
|
|
@@ -65,4 +71,41 @@ public class JsReportController {
|
|
|
Page<JsReport> page = new Page<>(pageNum, pageSize);
|
|
Page<JsReport> page = new Page<>(pageNum, pageSize);
|
|
|
return success(reportService.page(page,queryWrapper));
|
|
return success(reportService.page(page,queryWrapper));
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ @ApiOperation("完工登记")
|
|
|
|
|
+ @PostMapping("/register")
|
|
|
|
|
+ public AjaxResult register(@RequestBody List<JsDivideCircle> circles) {
|
|
|
|
|
+ //根据提交的分圈登记,计算每个批次的剩余存栏量(每个猪圈的存栏量为0后视为该批次完结),然后决定猪圈状态和待宰栏中的该批次数据状态
|
|
|
|
|
+ for (JsDivideCircle circle : circles) {
|
|
|
|
|
+ if (!ObjectUtils.isEmpty(circle.getEntranceBatchId()) && !ObjectUtils.isEmpty(circle.getSeriesNo())) {
|
|
|
|
|
+ //先检索出同批次、同栏的历史记录,针对数量进行逻辑完整性校验,数量的变化过程,不能小于0,小于0就归零
|
|
|
|
|
+ List<JsDivideCircle> records = jsDivideCircleMapper.selectList(new LambdaQueryWrapper<JsDivideCircle>()
|
|
|
|
|
+ .eq(JsDivideCircle::getSeriesNo, circle.getSeriesNo()).orderByAsc(JsDivideCircle::getId)
|
|
|
|
|
+ .eq(JsDivideCircle::getStatusFlag, "opened"));
|
|
|
|
|
+ if (!ObjectUtils.isEmpty(records)) {
|
|
|
|
|
+ if (circle.getAmount() > 0) {
|
|
|
|
|
+ circle.setStatusFlag("opened");
|
|
|
|
|
+ circle.setId(null);
|
|
|
|
|
+ jsDivideCircleMapper.insert(circle);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ circle.setId(null);
|
|
|
|
|
+ jsDivideCircleMapper.insert(circle);
|
|
|
|
|
+ jsDivideCircleMapper.update(null, new LambdaUpdateWrapper<JsDivideCircle>()
|
|
|
|
|
+ .eq(JsDivideCircle::getSeriesNo, circle.getSeriesNo())
|
|
|
|
|
+ .eq(JsDivideCircle::getStatusFlag, "opened")
|
|
|
|
|
+ .set(JsDivideCircle::getStatusFlag, "closed"));
|
|
|
|
|
+ Pigpen pigpen = new Pigpen();
|
|
|
|
|
+ pigpen.setId(circle.getPigpenId().longValue());
|
|
|
|
|
+ pigpen.setIsUse(0);
|
|
|
|
|
+ pigpenMapper.updatePigpen(pigpen);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ //保存完工报告记录
|
|
|
|
|
+ JsReport jsReport = new JsReport();
|
|
|
|
|
+ jsReport.setCreateTime(new Date());
|
|
|
|
|
+ return success(reportService.save(jsReport));
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|