Browse Source

新建档案修改

wwh 2 years ago
parent
commit
5c849e7c64

+ 2 - 2
huimv-admin/src/main/java/com/huimv/guowei/admin/controller/BaseDuckInfoController.java

@@ -63,8 +63,8 @@ public class BaseDuckInfoController {
                           @RequestParam(name = "unitId") String unitId,
                           @RequestParam(name = "breedEnv") String breedEnv,
                           @RequestParam(name = "hatchRate", required = false) String hatchRate,
-                          @RequestParam(name = "fatherNum") String fatherNum,
-                          @RequestParam(name = "motherNum") String motherNum,
+                          @RequestParam(name = "fatherNum",required = false) String fatherNum,
+                          @RequestParam(name = "motherNum",required = false) String motherNum,
                           @RequestParam(name = "fatherGenotype") String fatherGenotype,
                           @RequestParam(name = "motherGenotype") String motherGenotype,
                           @RequestParam(name = "specialNeeds") String specialNeeds) throws Exception {

+ 45 - 6
huimv-admin/src/main/java/com/huimv/guowei/admin/service/impl/BaseDuckInfoServiceImpl.java

@@ -114,13 +114,49 @@ public class BaseDuckInfoServiceImpl extends ServiceImpl<BaseDuckInfoMapper, Bas
             BigDecimal rate = new BigDecimal(paramsMap.get("hatchRate"));
             baseDuckInfo.setHatchRate(rate);
         }
-        if (paramsMap.get("fatherNum").equals(paramsMap.get("motherNum")) ||
-                paramsMap.get("motherNum").equals(paramsMap.get("duckCode")) ||
-                paramsMap.get("fatherNum").equals(paramsMap.get("duckCode"))) {
-            return new Result(10001, "鸭只编号、父亲编号、母亲编号三者的编号不能相同!", false);
+        String fatherNum = paramsMap.get("fatherNum");
+        String motherNum = paramsMap.get("motherNum");
+        String duckCode = paramsMap.get("duckCode");
+        if (StringUtils.isNotBlank(fatherNum) && StringUtils.isNotBlank(motherNum)) {
+            if (fatherNum.equals(motherNum) ||
+                    motherNum.equals(duckCode) ||
+                    fatherNum.equals(duckCode)) {
+                return new Result(10001, "鸭只编号、父亲编号、母亲编号三者的编号不能相同!", false);
+            }
+            QueryWrapper<BaseDuckInfo> duckInfoQueryWrapper = new QueryWrapper<>();
+            duckInfoQueryWrapper.eq("farm_id", paramsMap.get("farmId")).eq("duck_num", fatherNum).eq("is_cage",0);
+            BaseDuckInfo father = duckInfoMapper.selectOne(duckInfoQueryWrapper);//父亲编号
+
+            if (ObjectUtil.isEmpty(father)) {
+                return new Result(10001, "父亲编号不存在,请重新输入!", false);
+            } else {
+
+                if (father.getDayAge() < 100) {
+                    return new Result(10001, "该鸭只日龄小于100天,暂不能作为种鸭!", false);
+                } else {
+                    QueryWrapper<BaseDuckInfo> duckInfoQueryWrapper1 = new QueryWrapper<>();
+                    duckInfoQueryWrapper1.eq("farm_id", paramsMap.get("farmId")).eq("duck_num", motherNum).eq("is_cage",0);
+                    BaseDuckInfo mother = duckInfoMapper.selectOne(duckInfoQueryWrapper1);//母亲编号
+                    if (ObjectUtil.isEmpty(mother)) {
+                        return new Result(10001, "母亲编号不存在,请重新输入!", false);
+                    } else {
+                        if (mother.getDayAge() < 100) {
+                            return new Result(10001, "该鸭只日龄小于100天,暂不能作为种鸭!", false);
+                        } else {
+                            baseDuckInfo.setFatherNum(paramsMap.get("fatherNum"));
+                            baseDuckInfo.setMotherNum(paramsMap.get("motherNum"));
+                        }
+                    }
+                }
+            }
+        }
+
+        if (StringUtils.isBlank(fatherNum) && StringUtils.isNotBlank(motherNum)) {
+            return new Result(10001, "母亲编号已填写,请输入父亲编号!", false);
+        }
+        if (StringUtils.isBlank(motherNum) && StringUtils.isNotBlank(fatherNum)) {
+            return new Result(10001, "父亲编号已填写,请输入母亲编号!", false);
         }
-        baseDuckInfo.setFatherNum(paramsMap.get("fatherNum"));
-        baseDuckInfo.setMotherNum(paramsMap.get("motherNum"));
         baseDuckInfo.setFatherGenotype(paramsMap.get("fatherGenotype"));
         baseDuckInfo.setMotherGenotype(paramsMap.get("motherGenotype"));
         baseDuckInfo.setSpecialNeeds(paramsMap.get("specialNeeds"));
@@ -157,8 +193,10 @@ public class BaseDuckInfoServiceImpl extends ServiceImpl<BaseDuckInfoMapper, Bas
         }
 
     }
+
     /**
      * 获取两个日期间的天数,精确到年月日
+     *
      * @param start
      * @param end
      * @return
@@ -176,6 +214,7 @@ public class BaseDuckInfoServiceImpl extends ServiceImpl<BaseDuckInfoMapper, Bas
         long betweenDays = (endTime - startTime) / (1000 * 3600 * 24);
         return Integer.parseInt(String.valueOf(betweenDays));
     }
+
     @Override
     public Result editDuck(HttpServletRequest httpServletRequest, BaseDuckInfo baseDuckInfo) {
         QueryWrapper<BaseDuckInfo> queryWrapper = new QueryWrapper<>();