zxz 1 year ago
parent
commit
1e6915ab69

+ 1 - 0
winsea-haixin-plugin-yiliangyiyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/exception/YExceptionEnum.java

@@ -42,6 +42,7 @@ public enum YExceptionEnum {
 	PAYMENT_NOT_DELETED_ERROR("ERROR", "请先删除对应的付款信息!"),
 	PAYMENT_NOT_DELETED_ERROR("ERROR", "请先删除对应的付款信息!"),
 	WEIGHT_NOT_DELETED_ERROR("ERROR", "请先删除对应的检斤信息!"),
 	WEIGHT_NOT_DELETED_ERROR("ERROR", "请先删除对应的检斤信息!"),
 	QUALITY_NO_ERROR("ERROR", "业务编号已存在,不可重复!"),
 	QUALITY_NO_ERROR("ERROR", "业务编号已存在,不可重复!"),
+	GOODSNAME_ERROR("ERROR", "货物种类与类型不符,请确认!"),
 	QUALITY_HAVE_ERROR("ERROR", "业务编号错误,请重新添加!"),
 	QUALITY_HAVE_ERROR("ERROR", "业务编号错误,请重新添加!"),
 	TARE_NULL("ERROR", "皮重不能为空!"),
 	TARE_NULL("ERROR", "皮重不能为空!"),
 	JINZHIFABU_NULL("ERROR", "该用户禁止发布!"),
 	JINZHIFABU_NULL("ERROR", "该用户禁止发布!"),

+ 132 - 123
winsea-haixin-plugin-yiliangyiyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/service/impl/QualityInspectionManagementServiceImpl.java

@@ -418,140 +418,149 @@ public class QualityInspectionManagementServiceImpl extends ServiceImpl<QualityI
 
 
     /**
     /**
      * 添加质检管理信息
      * 添加质检管理信息
+     *
      * @param qualityInspectionManagement
      * @param qualityInspectionManagement
      * @return
      * @return
      */
      */
     @Override
     @Override
     @Transactional(rollbackFor = Exception.class)
     @Transactional(rollbackFor = Exception.class)
     public String addQualityInspection(QualityInspectionManagement qualityInspectionManagement) {
     public String addQualityInspection(QualityInspectionManagement qualityInspectionManagement) {
-        String relationId=IdGenerator.generateUUID();
-        qualityInspectionManagement.setId(IdGenerator.generateUUID());
-        if(qualityInspectionManagement.getCompId() == null || qualityInspectionManagement.getCompId().isEmpty()){
-            qualityInspectionManagement.setCompId(AuthSecurityUtils.getStaffById(AuthSecurityUtils.getCurrentUserId()).getCompId());
-        }
-        //获取当前年月日
-        SimpleDateFormat f = new SimpleDateFormat("yyyyMMdd");//设置日期格式
-        String date = f.format(new Date(System.currentTimeMillis()));
-        //查询质检信息数量包括已删除的集合
-        List<QualityInspectionManagement> qualityInspectionManagementList = this.selectQualityInspectionManagementList(qualityInspectionManagement);//调用Service中的方法
-        //生成业务编号
-        if (qualityInspectionManagementList.size() > 0) {
-            //取第一条数据的编号
-            String n = qualityInspectionManagementList.get(0).getQualityNo();
-            int intNumber = 0;
-            if (n.length() == 20){
-                //截取编号后4位
-                intNumber = Integer.parseInt(n.substring(16));
-            }else {
-                //截取编号后4位
-                intNumber = Integer.parseInt(n.substring(15));
+        if ((qualityInspectionManagement.getGoodsName().contains("潮粮") && qualityInspectionManagement.getType().contains("潮"))
+                || (qualityInspectionManagement.getGoodsName().indexOf("潮粮") == -1 && qualityInspectionManagement.getType().contains("干"))) {
+            String relationId = IdGenerator.generateUUID();
+            qualityInspectionManagement.setId(IdGenerator.generateUUID());
+            if (qualityInspectionManagement.getCompId() == null || qualityInspectionManagement.getCompId().isEmpty()) {
+                qualityInspectionManagement.setCompId(AuthSecurityUtils.getStaffById(AuthSecurityUtils.getCurrentUserId()).getCompId());
+            }
+            //获取当前年月日
+            // 设置日期格式
+            SimpleDateFormat f = new SimpleDateFormat("yyyyMMdd");
+            String date = f.format(new Date(System.currentTimeMillis()));
+            //查询质检信息数量包括已删除的集合
+            //调用Service中的方法
+            List<QualityInspectionManagement> qualityInspectionManagementList = this.selectQualityInspectionManagementList(qualityInspectionManagement);
+            //生成业务编号
+            if (qualityInspectionManagementList.size() > 0) {
+                //取第一条数据的编号
+                String n = qualityInspectionManagementList.get(0).getQualityNo();
+                int intNumber = 0;
+                if (n.length() == 20) {
+                    //截取编号后4位
+                    intNumber = Integer.parseInt(n.substring(16));
+                } else {
+                    //截取编号后4位
+                    intNumber = Integer.parseInt(n.substring(15));
+                }
+                intNumber++;
+                String Number = String.valueOf(intNumber);
+                for (int i = 0; i < 4; i++) {
+                    Number = Number.length() < 4 ? "0" + Number : Number;
+                }
+                //编号自增
+                Number = qualityInspectionManagement.getNumberLetter() + date + qualityInspectionManagement.getWarehouseNo() + Number;
+                qualityInspectionManagement.setQualityNo(Number);
+            } else {
+                //如果当天数据为空,生成第一条数据
+                String Number = qualityInspectionManagement.getNumberLetter() + date + qualityInspectionManagement.getWarehouseNo() + "0001";
+                qualityInspectionManagement.setQualityNo(Number);
+            }
+            if (qualityInspectionManagement.getQualityNo().contains("null")) {
+                throw new YException(YExceptionEnum.QUALITY_HAVE_ERROR);
+            }
+            //判断质检编号是否唯一
+            List<QualityInspectionManagement> qualityInspectionManagements =
+                    this.selectList(new EntityWrapper<QualityInspectionManagement>()
+                            .eq("comp_id", qualityInspectionManagement.getCompId())
+                            .eq("quality_no", qualityInspectionManagement.getQualityNo()));
+            if (qualityInspectionManagements.size() > 0) {
+//            throw new YException(YExceptionEnum.QUALITY_NO_ERROR);
             }
             }
-            intNumber++;
-            String Number = String.valueOf(intNumber);
-            for (int i = 0; i < 4; i++) {
-                Number = Number.length() < 4 ? "0" + Number : Number;
+            qualityInspectionManagement.setRelationId(relationId);
+            qualityInspectionManagement.setManagementType("1");
+            qualityInspectionManagement.setQualityDate(new Date());
+            CommonStaff commonStaff = staffService.getInfo(AuthSecurityUtils.getCurrentUserId());
+            qualityInspectionManagement.setQualityInspector(commonStaff.getStaffName());
+            //钎样员提交,状态为待初检
+            if ("1".equals(qualityInspectionManagement.getBrazer())) {
+                qualityInspectionManagement.setStatus(StatusEnum.TO_BE_INSPECTED.getName());
+                qualityInspectionManagement.setStatusFlag(StatusEnum.TO_BE_INSPECTED.getFlag());
             }
             }
-            //编号自增
-            Number = qualityInspectionManagement.getNumberLetter() + date + qualityInspectionManagement.getWarehouseNo() + Number;
-            qualityInspectionManagement.setQualityNo(Number);
-        } else {
-            //如果当天数据为空,生成第一条数据
-            String Number = qualityInspectionManagement.getNumberLetter() + date + qualityInspectionManagement.getWarehouseNo() + "0001";
-            qualityInspectionManagement.setQualityNo(Number);
-        }
-        if(qualityInspectionManagement.getQualityNo().contains("null")){
-            throw new YException(YExceptionEnum.QUALITY_HAVE_ERROR);
-        }
-        //判断质检编号是否唯一
-        List<QualityInspectionManagement> qualityInspectionManagements =
-                this.selectList(new EntityWrapper<QualityInspectionManagement>()
-                        .eq("comp_id",qualityInspectionManagement.getCompId())
-                        .eq("quality_no", qualityInspectionManagement.getQualityNo()));
-        if (qualityInspectionManagements.size() > 0) {
-//            throw new YException(YExceptionEnum.QUALITY_NO_ERROR);
-        }
-
-        qualityInspectionManagement.setRelationId(relationId);
-        qualityInspectionManagement.setManagementType("1");
-        qualityInspectionManagement.setQualityDate(new Date());
-        CommonStaff commonStaff = staffService.getInfo(AuthSecurityUtils.getCurrentUserId());
-        qualityInspectionManagement.setQualityInspector(commonStaff.getStaffName());
-        //钎样员提交,状态为待初检
-        if ("1".equals(qualityInspectionManagement.getBrazer())) {
-            qualityInspectionManagement.setStatus(StatusEnum.TO_BE_INSPECTED.getName());
-            qualityInspectionManagement.setStatusFlag(StatusEnum.TO_BE_INSPECTED.getFlag());
-        }
-        //质检员或双重身份提交,状态为已初检
-        else {
-            qualityInspectionManagement.setStatus(StatusEnum.FIRST_INSPECTED.getName());
-            qualityInspectionManagement.setStatusFlag(StatusEnum.FIRST_INSPECTED.getFlag());
-        }
-        qualityInspectionManagement.setAgentKey(AuthSecurityUtils.getCurrentUserId());
-        qualityInspectionManagement.setAgent(AuthSecurityUtils.getStaffById(AuthSecurityUtils.getCurrentUserId()).getStaffName());
-        CommonSysParameter commonSysParameter = iCommonSysParameterService.selectOne(new EntityWrapper<CommonSysParameter>().eq("const_id", "CON2").eq("const_value", qualityInspectionManagement.getGoodsName()));
-        qualityInspectionManagement.setGoodsNameKey(commonSysParameter.getConstKey());
-        //生成检斤信息
-        WeighingManagement weighingManagement=new WeighingManagement();
-        weighingManagement.setId(IdGenerator.generateUUID());
-        weighingManagement.setWarehouseInOutId(qualityInspectionManagement.getWarehouseInOutId());
-        weighingManagement.setRelationId(qualityInspectionManagement.getRelationId());
-        weighingManagement.setContractNo(qualityInspectionManagement.getContractNo());
-        weighingManagement.setOutType(qualityInspectionManagement.getOutType());
-        weighingManagement.setNumber(qualityInspectionManagement.getQualityNo());
-        weighingManagement.setCustomer(qualityInspectionManagement.getCustomerName());
-        weighingManagement.setCustomerPhone(qualityInspectionManagement.getCustomerPhone());
-        weighingManagement.setCustomerNumberCard(qualityInspectionManagement.getCustomerNumberCard());
-        weighingManagement.setCarNumber(qualityInspectionManagement.getCarNumber());
-        weighingManagement.setCompId(qualityInspectionManagement.getCompId());
-        weighingManagement.setServiceManagementType(qualityInspectionManagement.getServiceManagementType());
-        weighingManagement.setGoodsNameKey(qualityInspectionManagement.getGoodsNameKey());
-        weighingManagement.setGoodsName(qualityInspectionManagement.getGoodsName());
-        weighingManagement.setBinNumber(qualityInspectionManagement.getBinNumber());
-        weighingManagement.setType(qualityInspectionManagement.getType());
-        weighingManagement.setManagementType("1");
-        weighingManagement.setInOutType(qualityInspectionManagement.getInOutType());
-        weighingManagement.setInOutTypeKey(qualityInspectionManagement.getInOutTypeKey());
-        weighingManagement.setWarehouseName(qualityInspectionManagement.getWarehouseName());
-        //状态为已质检
-        weighingManagement.setStatus(StatusEnum.INSPECTED.getName());
-        weighingManagement.setStatusFlag(StatusEnum.INSPECTED.getFlag());
-        weighingManagement.setStorageNumber(qualityInspectionManagement.getStorageTagNo());
-        //送粮登记的id
-        if(qualityInspectionManagement.getIdentityId()!=null){
-            ShippingInformation shippingInformation=shippingInformationService.selectById(qualityInspectionManagement.getIdentityId());
-            if (shippingInformation!=null){
-                if (shippingInformation.getNotCarNo().contains(qualityInspectionManagement.getCarNumber())) {
-                    String newStr = "";
-                    String[] arr = shippingInformation.getNotCarNo().split(",");
-                    List<String> list = Arrays.asList(arr);
-                    List<String> arrList = new ArrayList<>(list);
-                    arrList.remove(qualityInspectionManagement.getCarNumber());
-                    String[] strings = new String[arrList.size()];
-                    String[] newArray = arrList.toArray(strings);
-                    for (int i = 0; i < newArray.length; i++) {
-                        newStr += newArray[i] + ",";
-                    }
-                    if (!"".equals(newStr)) {
-                        newStr = newStr.substring(0, newStr.length() - 1);
+            //质检员或双重身份提交,状态为已初检
+            else {
+                qualityInspectionManagement.setStatus(StatusEnum.FIRST_INSPECTED.getName());
+                qualityInspectionManagement.setStatusFlag(StatusEnum.FIRST_INSPECTED.getFlag());
+            }
+            qualityInspectionManagement.setAgentKey(AuthSecurityUtils.getCurrentUserId());
+            qualityInspectionManagement.setAgent(AuthSecurityUtils.getStaffById(AuthSecurityUtils.getCurrentUserId()).getStaffName());
+            CommonSysParameter commonSysParameter = iCommonSysParameterService.selectOne(new EntityWrapper<CommonSysParameter>().eq("const_id", "CON2").eq("const_value", qualityInspectionManagement.getGoodsName()));
+            qualityInspectionManagement.setGoodsNameKey(commonSysParameter.getConstKey());
+            //生成检斤信息
+            WeighingManagement weighingManagement = new WeighingManagement();
+            weighingManagement.setId(IdGenerator.generateUUID());
+            weighingManagement.setWarehouseInOutId(qualityInspectionManagement.getWarehouseInOutId());
+            weighingManagement.setRelationId(qualityInspectionManagement.getRelationId());
+            weighingManagement.setContractNo(qualityInspectionManagement.getContractNo());
+            weighingManagement.setOutType(qualityInspectionManagement.getOutType());
+            weighingManagement.setNumber(qualityInspectionManagement.getQualityNo());
+            weighingManagement.setCustomer(qualityInspectionManagement.getCustomerName());
+            weighingManagement.setCustomerPhone(qualityInspectionManagement.getCustomerPhone());
+            weighingManagement.setCustomerNumberCard(qualityInspectionManagement.getCustomerNumberCard());
+            weighingManagement.setCarNumber(qualityInspectionManagement.getCarNumber());
+            weighingManagement.setCompId(qualityInspectionManagement.getCompId());
+            weighingManagement.setServiceManagementType(qualityInspectionManagement.getServiceManagementType());
+            weighingManagement.setGoodsNameKey(qualityInspectionManagement.getGoodsNameKey());
+            weighingManagement.setGoodsName(qualityInspectionManagement.getGoodsName());
+            weighingManagement.setBinNumber(qualityInspectionManagement.getBinNumber());
+            weighingManagement.setType(qualityInspectionManagement.getType());
+            weighingManagement.setManagementType("1");
+            weighingManagement.setInOutType(qualityInspectionManagement.getInOutType());
+            weighingManagement.setInOutTypeKey(qualityInspectionManagement.getInOutTypeKey());
+            weighingManagement.setWarehouseName(qualityInspectionManagement.getWarehouseName());
+            //状态为已质检
+            weighingManagement.setStatus(StatusEnum.INSPECTED.getName());
+            weighingManagement.setStatusFlag(StatusEnum.INSPECTED.getFlag());
+            weighingManagement.setStorageNumber(qualityInspectionManagement.getStorageTagNo());
+            //送粮登记的id
+            if (qualityInspectionManagement.getIdentityId() != null) {
+                ShippingInformation shippingInformation = shippingInformationService.selectById(qualityInspectionManagement.getIdentityId());
+                if (shippingInformation != null) {
+                    if (shippingInformation.getNotCarNo().contains(qualityInspectionManagement.getCarNumber())) {
+                        String newStr = "";
+                        String[] arr = shippingInformation.getNotCarNo().split(",");
+                        List<String> list = Arrays.asList(arr);
+                        List<String> arrList = new ArrayList<>(list);
+                        arrList.remove(qualityInspectionManagement.getCarNumber());
+                        String[] strings = new String[arrList.size()];
+                        String[] newArray = arrList.toArray(strings);
+                        for (int i = 0; i < newArray.length; i++) {
+                            newStr += newArray[i] + ",";
+                        }
+                        if (!"".equals(newStr)) {
+                            newStr = newStr.substring(0, newStr.length() - 1);
+                        }
+                        shippingInformation.setNotCarNo(newStr);
+                        shippingInformationService.updateById(shippingInformation);
                     }
                     }
-                    shippingInformation.setNotCarNo(newStr);
-                    shippingInformationService.updateById(shippingInformation);
                 }
                 }
             }
             }
-        }
-        if(qualityInspectionManagement.getCost() == null){
-            qualityInspectionManagement.setCost(Float.parseFloat((qualityInspectionManagement.getDryGrainPrice()==null?0:qualityInspectionManagement.getDryGrainPrice())*1000 + ""));
-        }
-        boolean two=weighingManagementService.insert(weighingManagement);
-        boolean one=this.insert(qualityInspectionManagement);
+            if (qualityInspectionManagement.getCost() == null) {
+                qualityInspectionManagement.setCost(Float.parseFloat((qualityInspectionManagement.getDryGrainPrice() == null ? 0 : qualityInspectionManagement.getDryGrainPrice()) * 1000 + ""));
+            }
 
 
-        cacheComponent.delPrefixKey(Const.ADMIN_WEIGHINGINFO,qualityInspectionManagement.getCompId());
-        cacheComponent.delPrefixKey(Const.ADMIN_WEIGHINGINFO_NUM,qualityInspectionManagement.getCompId());
-        //成功返回ok
-        if (one &&two ) {
-            return qualityInspectionManagement.getId();
+            boolean two = weighingManagementService.insert(weighingManagement);
+
+            boolean one = this.insert(qualityInspectionManagement);
+
+            cacheComponent.delPrefixKey(Const.ADMIN_WEIGHINGINFO, qualityInspectionManagement.getCompId());
+            cacheComponent.delPrefixKey(Const.ADMIN_WEIGHINGINFO_NUM, qualityInspectionManagement.getCompId());
+            //成功返回ok
+            if (one && two) {
+                return qualityInspectionManagement.getId();
+            } else {
+                return "NG";
+            }
         } else {
         } else {
-            return "NG";
+            throw new YException(YExceptionEnum.GOODSNAME_ERROR);
         }
         }
     }
     }
     /**
     /**
@@ -635,10 +644,10 @@ public class QualityInspectionManagementServiceImpl extends ServiceImpl<QualityI
             qualityInspectionManagement1.setQualityDate(qualityInspectionManagement1.getQualityDate());
             qualityInspectionManagement1.setQualityDate(qualityInspectionManagement1.getQualityDate());
             qualityInspectionManagement1.setManagementType("1");
             qualityInspectionManagement1.setManagementType("1");
             if(qualityInspectionManagement1.getGoodsName()!= null && qualityInspectionManagement1.getGoodsName().contains("潮粮")) {
             if(qualityInspectionManagement1.getGoodsName()!= null && qualityInspectionManagement1.getGoodsName().contains("潮粮")) {
-                qualityInspectionManagement1.setType("粮");
+                qualityInspectionManagement1.setType("粮");
             }
             }
             else{
             else{
-                qualityInspectionManagement1.setType("粮");
+                qualityInspectionManagement1.setType("粮");
             }
             }
             qualityInspectionManagement1.setBuckleWeightRatio(1.3f);
             qualityInspectionManagement1.setBuckleWeightRatio(1.3f);
             qualityInspectionManagement1.setConfirm("1");
             qualityInspectionManagement1.setConfirm("1");