Kaynağa Gözat

v3项目-修改0901

wwh 2 ay önce
ebeveyn
işleme
76e583c11a

+ 6 - 0
app-admin/src/main/java/com/ruoyi/web/v2/v1/controller/JsDivideCircleController.java

@@ -72,4 +72,10 @@ public class JsDivideCircleController {
         String id = paramsMap.get("id");
         return success(divideCircleService.getById(id));
     }
+
+    @ApiOperation("存栏数据核查")
+    @GetMapping("/review")
+    public AjaxResult review() {
+        return success(divideCircleService.review());
+    }
 }

+ 3 - 2
app-admin/src/main/java/com/ruoyi/web/v2/v1/controller/JsInStockController.java

@@ -62,9 +62,10 @@ public class JsInStockController {
             , @RequestParam(value = "endTime", required = false) String endTime
             , @RequestParam(value = "materialBatch", required = false) String materialBatch
             , @RequestParam(value = "materialName", required = false) String materialName
-            , @RequestParam(value = "materialType", required = false) Integer materialType) {
+            , @RequestParam(value = "materialType", required = false) Integer materialType
+            , @RequestParam(value = "needAllFlag", required = false) Boolean needAllFlag) {
 
-        return inStockService.page(pageNum, pageSize, startTime, endTime, materialBatch,materialName,materialType);
+        return inStockService.page(pageNum, pageSize, startTime, endTime, materialBatch,materialName,materialType,needAllFlag);
     }
 
     @ApiOperation("物料入库详情")

+ 3 - 2
app-admin/src/main/java/com/ruoyi/web/v2/v1/controller/JsOutStockController.java

@@ -61,9 +61,10 @@ public class JsOutStockController {
             , @RequestParam(value = "endTime", required = false) String endTime
             , @RequestParam(value = "materialBatch", required = false) String materialBatch
             , @RequestParam(value = "materialName", required = false) String materialName
-            , @RequestParam(value = "materialType", required = false) Integer materialType) {
+            , @RequestParam(value = "materialType", required = false) Integer materialType
+            , @RequestParam(value = "needAllFlag", required = false) Boolean needAllFlag) {
 
-        return outStockService.page(pageNum, pageSize, startTime, endTime, materialBatch,materialName,materialType);
+        return outStockService.page(pageNum, pageSize, startTime, endTime, materialBatch,materialName,materialType,needAllFlag);
     }
 
     @ApiOperation("物料领用详情")

+ 44 - 1
app-admin/src/main/java/com/ruoyi/web/v2/v1/controller/JsReportController.java

@@ -1,16 +1,20 @@
 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.update.LambdaUpdateWrapper;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.ruoyi.app.model.Pigpen;
 import com.ruoyi.app.mapper.PigpenMapper;
 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.service.IJsReportService;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.util.ObjectUtils;
 import org.springframework.web.bind.annotation.*;
 
 import java.util.Date;
@@ -35,6 +39,8 @@ public class JsReportController {
     private IJsReportService reportService;
     @Autowired
     private PigpenMapper pigpenMapper;
+    @Autowired
+    private JsDivideCircleMapper jsDivideCircleMapper;
 
     @ApiOperation("完工报告添加")
     @PostMapping("/add")
@@ -65,4 +71,41 @@ public class JsReportController {
         Page<JsReport> page = new Page<>(pageNum, pageSize);
         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));
+    }
 }

+ 2 - 1
app-admin/src/main/java/com/ruoyi/web/v2/v1/model/JsDivideCircle.java

@@ -71,5 +71,6 @@ public class JsDivideCircle implements Serializable {
     @ApiModelProperty(value = "批次序列号")
     private String seriesNo;
 
-
+    @ApiModelProperty(value = "是否闭环标记:opened表示未闭环,closed表示已闭环")
+    private String statusFlag;
 }

+ 2 - 0
app-admin/src/main/java/com/ruoyi/web/v2/v1/service/IJsDivideCircleService.java

@@ -23,4 +23,6 @@ public interface IJsDivideCircleService extends IService<JsDivideCircle> {
     AjaxResult page(Integer pageNum, Integer pageSize, String startTime, String endTime, String pigpenName);
 
     AjaxResult listAll(String startTime);
+
+    AjaxResult review();
 }

+ 2 - 1
app-admin/src/main/java/com/ruoyi/web/v2/v1/service/IJsInStockService.java

@@ -20,7 +20,8 @@ public interface IJsInStockService extends IService<JsInStock> {
 
     AjaxResult delete(String ids);
 
-    AjaxResult page(Integer pageNum, Integer pageSize, String startTime, String endTime, String materialBatch, String materialName, Integer materialType);
+    AjaxResult page(Integer pageNum, Integer pageSize, String startTime, String endTime, String materialBatch,
+                    String materialName, Integer materialType,  Boolean needAllFlag);
 
     AjaxResult listAll(String materialBatch);
 

+ 2 - 1
app-admin/src/main/java/com/ruoyi/web/v2/v1/service/IJsOutStockService.java

@@ -20,7 +20,8 @@ public interface IJsOutStockService extends IService<JsOutStock> {
 
     AjaxResult delete(String ids);
 
-    AjaxResult page(Integer pageNum, Integer pageSize, String startTime, String endTime, String materialBatch, String materialName, Integer materialType);
+    AjaxResult page(Integer pageNum, Integer pageSize, String startTime, String endTime, String materialBatch,
+                    String materialName, Integer materialType,  Boolean needAllFlag);
 
     AjaxResult listAll();
 }

+ 34 - 0
app-admin/src/main/java/com/ruoyi/web/v2/v1/service/impl/JsDivideCircleServiceImpl.java

@@ -1,6 +1,7 @@
 package com.ruoyi.web.v2.v1.service.impl;
 
 import cn.hutool.core.util.ObjectUtil;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.ruoyi.app.model.EntranceBatch;
@@ -18,9 +19,11 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
+import org.springframework.util.ObjectUtils;
 
 import java.text.SimpleDateFormat;
 import java.time.ZoneId;
+import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
 
@@ -83,6 +86,8 @@ public class JsDivideCircleServiceImpl extends ServiceImpl<JsDivideCircleMapper,
         divideCircle.setCreateTime(new Date());
         divideCircle.setSeriesNo(
                 generateSeriesNo(animalCertNo, pigpen.getPigpenName(), Date.from(entranceBatch.getEntranceTime().atZone(ZoneId.systemDefault()).toInstant())));
+        //分圈添加时的数据,状态都是未闭环的状态
+        divideCircle.setStatusFlag("opened");
         jsDivideCircleMapper.insert(divideCircle);
         pigpen.setIsUse(1);
         pigpenMapper.updatePigpen(pigpen);
@@ -179,4 +184,33 @@ public class JsDivideCircleServiceImpl extends ServiceImpl<JsDivideCircleMapper,
         return success(jsDivideCircleMapper.selectList(queryWrapper));
     }
 
+    /**
+     * 分圈数据核查
+     * 用于查询出所有猪圈的当前有效分圈数据,以便完工报告进行数据更新闭环
+     * @return
+     */
+    @Override
+    public AjaxResult review() {
+        List<Pigpen> pigpenList = pigpenMapper.selectPigpenList(new Pigpen());
+        List<JsDivideCircle> circles = new ArrayList<>();
+        for(Pigpen pigpen : pigpenList) {
+            //根据猪圈号,检索有效的分圈数据记录(未闭环的数据)
+            List<JsDivideCircle> circleList = jsDivideCircleMapper.selectList(new LambdaQueryWrapper<JsDivideCircle>()
+                    .eq(JsDivideCircle::getPigpenName, pigpen.getPigpenName())
+                    .eq(JsDivideCircle::getStatusFlag, "opened")
+                    .orderByDesc(JsDivideCircle::getId).last("limit 1"));
+            if(!ObjectUtils.isEmpty(circleList)) {
+                circles.add(circleList.get(0));
+            }else {
+                JsDivideCircle dummyCircle = new JsDivideCircle();
+                dummyCircle.setPigpenId(pigpen.getId().intValue());
+                dummyCircle.setPigpenName(pigpen.getPigpenName());
+                dummyCircle.setAmount(0);
+                dummyCircle.setStatusFlag("closed");
+                circles.add(dummyCircle);
+            }
+        }
+        return success(circles);
+    }
+
 }

+ 6 - 1
app-admin/src/main/java/com/ruoyi/web/v2/v1/service/impl/JsInStockServiceImpl.java

@@ -15,6 +15,7 @@ import com.ruoyi.web.v2.v1.service.IJsInStockService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+import org.springframework.util.ObjectUtils;
 
 import java.text.SimpleDateFormat;
 import java.util.Date;
@@ -109,7 +110,8 @@ public class JsInStockServiceImpl extends ServiceImpl<JsInStockMapper, JsInStock
     }
 
     @Override
-    public AjaxResult page(Integer pageNum, Integer pageSize, String startTime, String endTime, String materialBatch, String materialName, Integer materialType) {
+    public AjaxResult page(Integer pageNum, Integer pageSize, String startTime, String endTime, String materialBatch,
+                           String materialName, Integer materialType,  Boolean needAllFlag) {
         Page<JsInStock> page = new Page<>(pageNum, pageSize);
         QueryWrapper<JsInStock> queryWrapper = new QueryWrapper<>();
         if ("".equals(startTime) || null == startTime) {
@@ -121,6 +123,9 @@ public class JsInStockServiceImpl extends ServiceImpl<JsInStockMapper, JsInStock
                 .or().like(StringUtils.isNotEmpty(materialName), "material_name", materialName);
         if (null != materialType) {
             queryWrapper.eq("material_type", materialType);
+        }else if(ObjectUtils.isEmpty(needAllFlag) || needAllFlag.equals(Boolean.FALSE)) {
+            //material_type=3表示该种物料是危险品,查询时默认排除危险品
+            queryWrapper.ne("material_type", 3);
         }
         queryWrapper.orderByDesc("id");
         return success(inStockMapper.selectPage(page, queryWrapper));

+ 3 - 4
app-admin/src/main/java/com/ruoyi/web/v2/v1/service/impl/JsMaterialServiceImpl.java

@@ -88,12 +88,11 @@ public class JsMaterialServiceImpl extends ServiceImpl<JsMaterialMapper, JsMater
     public AjaxResult page(Integer pageNum, Integer pageSize, String materialName, Integer materialType, Boolean needAllFlag) {
         QueryWrapper<JsMaterial> queryWrapper = new QueryWrapper<>();
         Page<JsMaterial> page = new Page<>(pageNum, pageSize);
-        if(ObjectUtils.isEmpty(needAllFlag) || needAllFlag.equals(Boolean.FALSE)) {
-            //material_type=3表示该种物料是危险品,查询时默认排除危险品
-            queryWrapper.ne("material_type", 3);
-        }
         if (null != materialType) {
             queryWrapper.eq("material_type", materialType);
+        }else if(ObjectUtils.isEmpty(needAllFlag) || needAllFlag.equals(Boolean.FALSE)) {
+            //material_type=3表示该种物料是危险品,查询时默认排除危险品
+            queryWrapper.ne("material_type", 3);
         }
         queryWrapper.like(StringUtils.isNotEmpty(materialName), "material_name", materialName);
         return success(materialMapper.selectPage(page, queryWrapper));

+ 6 - 1
app-admin/src/main/java/com/ruoyi/web/v2/v1/service/impl/JsOutStockServiceImpl.java

@@ -13,6 +13,7 @@ import com.ruoyi.web.v2.v1.service.IJsOutStockService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+import org.springframework.util.ObjectUtils;
 
 import java.util.Date;
 
@@ -86,7 +87,8 @@ public class JsOutStockServiceImpl extends ServiceImpl<JsOutStockMapper, JsOutSt
     }
 
     @Override
-    public AjaxResult page(Integer pageNum, Integer pageSize, String startTime, String endTime, String materialBatch, String materialName, Integer materialType) {
+    public AjaxResult page(Integer pageNum, Integer pageSize, String startTime, String endTime, String materialBatch,
+                           String materialName, Integer materialType,  Boolean needAllFlag) {
         Page<JsOutStock> page = new Page<>(pageNum, pageSize);
         QueryWrapper<JsOutStock> queryWrapper = new QueryWrapper<>();
         if ("".equals(startTime) || null == startTime) {
@@ -98,6 +100,9 @@ public class JsOutStockServiceImpl extends ServiceImpl<JsOutStockMapper, JsOutSt
                 .or().like(StringUtils.isNotEmpty(materialName), "material_name", materialName);
         if (null != materialType) {
             queryWrapper.eq("material_type", materialType);
+        }else if(ObjectUtils.isEmpty(needAllFlag) || needAllFlag.equals(Boolean.FALSE)) {
+            //material_type=3表示该种物料是危险品,查询时默认排除危险品
+            queryWrapper.ne("material_type", 3);
         }
         queryWrapper.orderByDesc("out_time");
         return success(jsOutStockMapper.selectPage(page, queryWrapper));

+ 13 - 4
app-admin/src/main/java/com/ruoyi/web/v3/service/impl/HbRiskCheckDailyServiceImpl.java

@@ -13,6 +13,8 @@ import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.ObjectUtils;
 
+import java.time.LocalDate;
+import java.time.format.DateTimeFormatter;
 import java.util.Arrays;
 
 import static com.ruoyi.common.core.domain.AjaxResult.error;
@@ -35,10 +37,17 @@ public class HbRiskCheckDailyServiceImpl extends ServiceImpl<HbRiskCheckDailyMap
             return error("请输入【排查结果】!");
         }
         //防重检测,
-        Integer count = lambdaQuery().eq(HbRiskCheckDailyEntity::getCheckDate, request.getCheckDate()).count();
-        if (count != 0) {
-            return error("请勿重复添加!");
-        }
+//        Integer count = lambdaQuery().eq(HbRiskCheckDailyEntity::getCheckDate, request.getCheckDate()).count();
+//        if (count != 0) {
+//            return error("请勿重复添加!");
+//        }
+        //根据排查日期,以及该日期下的记录数确认编号
+        LocalDate checkDate = request.getCheckDate().toLocalDate();
+        Integer countNum = lambdaQuery()
+                .ge(HbRiskCheckDailyEntity::getCheckDate, checkDate.atStartOfDay())
+                .lt(HbRiskCheckDailyEntity::getCheckDate, checkDate.plusDays(1).atStartOfDay())
+                .count();
+        request.setRecordNo(checkDate.format(DateTimeFormatter.ofPattern("yyyyMMdd")) + countNum);
         return success("添加成功", baseMapper.insert(request));
     }
 

+ 12 - 4
app-admin/src/main/java/com/ruoyi/web/v3/service/impl/HbRiskCheckMonthlyServiceImpl.java

@@ -13,6 +13,8 @@ import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.ObjectUtils;
 
+import java.time.LocalDate;
+import java.time.format.DateTimeFormatter;
 import java.util.Arrays;
 
 import static com.ruoyi.common.core.domain.AjaxResult.error;
@@ -35,10 +37,16 @@ public class HbRiskCheckMonthlyServiceImpl extends ServiceImpl<HbRiskCheckMonthl
             return error("请输入【排查结果】!");
         }
         //防重检测,
-        Integer count = lambdaQuery().eq(HbRiskCheckMonthlyEntity::getCheckDate, request.getCheckDate()).count();
-        if (count != 0) {
-            return error("请勿重复添加!");
-        }
+//        Integer count = lambdaQuery().eq(HbRiskCheckMonthlyEntity::getCheckDate, request.getCheckDate()).count();
+//        if (count != 0) {
+//            return error("请勿重复添加!");
+//        }
+        LocalDate checkDate = request.getCheckDate().toLocalDate();
+        Integer countNum = lambdaQuery()
+                .ge(HbRiskCheckMonthlyEntity::getCheckDate, checkDate.atStartOfDay())
+                .lt(HbRiskCheckMonthlyEntity::getCheckDate, checkDate.plusDays(1).atStartOfDay())
+                .count();
+        request.setRecordNo(checkDate.format(DateTimeFormatter.ofPattern("yyyyMMdd")) + countNum);
         return success("添加成功", baseMapper.insert(request));
     }
 

+ 4 - 0
sql/v3_biz_20250814.sql

@@ -534,3 +534,7 @@ insert into `hb_risk_strategy_dictionary` (risk_position, risk, strategy, remark
 insert into `hb_risk_strategy_dictionary` (risk_position, risk, strategy, remarks, is_deleted, create_by, create_time, update_by) VALUES (null,'地面有积水','及时清理积水',null, 0, 'admin', NOW(), NULL);
 insert into `hb_risk_strategy_dictionary` (risk_position, risk, strategy, remarks, is_deleted, create_by, create_time, update_by) VALUES (null,'脚手架未拆卸','及时拆卸入库',null, 0, 'admin', NOW(), NULL);
 insert into `hb_risk_strategy_dictionary` (risk_position, risk, strategy, remarks, is_deleted, create_by, create_time, update_by) VALUES (null,'物品杂乱堆放','物品及时放入仓库',null, 0, 'admin', NOW(), NULL);
+
+
+-- 分圈登记 增加一个状态字段status(opened-表示该批次的圈养猪存栏数未闭环,closed-表示存栏量已闭环)
+ALTER TABLE `js_divide_circle` ADD COLUMN status_flag VARCHAR(20) COMMENT '是否闭环标记:opened-表示该批次的圈养猪存栏数未闭环,closed-表示存栏量已闭环';