1、增加ALLCODE数据保存时通过ID判断是否有重复数据如果有重复数据则报错。
已修改1个文件
39 ■■■■■ 文件已修改
Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/MdmProductCodeServiceImpl.java 39 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/MdmProductCodeServiceImpl.java
@@ -86,10 +86,7 @@
    @Override
    @Transactional(rollbackFor = VciBaseException.class)
    public List<String> productCodeAndSaveData(CodeClassifyFullInfoBO classifyFullInfoBO, CodeClassifyTemplateVO templateVO, CodeRuleVO ruleVO, List<CodeOrderSecDTO> secDTOList, List<BaseModel> dataCBOList) throws Exception {
//        BatchCBO batchCBO = new BatchCBO();
//        WebUtil.setPersistence(false);
        dataCBOList = dataCBOList.stream().sorted(((o1, o2) -> o1.getCreateTime().compareTo(o2.getCreateTime()))).collect(Collectors.toList());
//        batchCBO.getCreateCbos().addAll(dataCBOList);
        List<String> codeList = new ArrayList<>();
        /*****
@@ -179,18 +176,13 @@
            List<CodeSerialValue> editSerialValueList = new ArrayList<>();
            maxSerialMap.forEach((serialUnit,secOidMaxMap)->{
                secOidMaxMap.forEach((secOid,maxSerial)->{
//                    Map<String, String> conditionMap = new HashMap<>();
//                    conditionMap.put("codeRuleOid", ruleVO.getOid());
//                    conditionMap.put("serialUnit", serialUnit);
//                    //这个字段是为了解决多个流水的问题
//                    conditionMap.put("codeSecOid", secOid);
                    QueryWrapper<CodeSerialValue> queryWrapper = new QueryWrapper<>();
                    queryWrapper.eq("codeRuleOid", ruleVO.getOid());
                    queryWrapper.eq("serialUnit", serialUnit);
                    //这个字段是为了解决多个流水的问题
                    queryWrapper.eq("codeSecOid", secOid);
                    List<CodeSerialValue> serialValueDOS = serialValueMapper.selectList(queryWrapper);
//                    .selectByCondition(conditionMap, new PageHelper(-1));
                    if (!CollectionUtils.isEmpty(serialValueDOS)) {
                        CodeSerialValue serialValueDO = serialValueDOS.get(0);
                        if(VciBaseUtil.getDouble(serialValueDO.getMaxSerial())<maxSerial){
@@ -209,19 +201,14 @@
                });
            });
            if(!CollectionUtils.isEmpty(addSerialValueList)){
//                batchCBO.copyFromOther(serialValueMapper.batchInsert(addSerialValueList));
                for (CodeSerialValue codeSerialValue : addSerialValueList) {
                    serialValueMapper.insert(codeSerialValue);
                }
//                serialValueMapper.ba
            }
            if(!CollectionUtils.isEmpty(editSerialValueList)){
                for (CodeSerialValue codeSerialValue : editSerialValueList) {
                    serialValueMapper.updateById(codeSerialValue);
                }
//                batchCBO.copyFromOther(serialValueMapper.batchUpdate(editSerialValueList));
            }
            //处理allCode
            if(!CollectionUtils.isEmpty(allCodeDOList)){
@@ -231,9 +218,6 @@
                List<CodeAllCode> editCodeDOs = new ArrayList<>();
                ruleGroup.forEach((ruleOid,allCodeDOS)->{
                    VciBaseUtil.switchCollectionForOracleIn(allCodeDOS).stream().forEach(codeDOs->{
//                        Map<String,String> conditionMap = new HashMap<>();
//                        conditionMap.put("coderuleoid",ruleOid);
//                        conditionMap.put("id",QueryOptionConstant.IN + "(" + VciBaseUtil.toInSql(codeDOs.stream().map(s->s.getId()).collect(Collectors.toList()).toArray(new String[0])) + ")");
                        QueryWrapper<CodeAllCode> allCodeWrapper = new QueryWrapper<>();
                        allCodeWrapper.eq("coderuleoid",ruleOid);
                        allCodeWrapper.in("id", QueryOptionConstant.IN + "(" +
@@ -264,21 +248,25 @@
                    addCodeDOs = allCodeDOList;
                }
                if(!CollectionUtils.isEmpty(editCodeDOs)){
//                    batchCBO.copyFromOther(allCodeMapper.batchUpdate(editCodeDOs));
                    codeAllCodeService.updateBatchById(editCodeDOs);
                }
                if(!CollectionUtils.isEmpty(addCodeDOs)){
                    //batchCBO.copyFromOther(allCodeMapper.batchInsert(addCodeDOs));
                    Map<String, String> statusMap = addCodeDOs.stream().collect(Collectors.toMap(s -> s.getOid(), s -> s.getLcStatus()));
                    addCodeDOs.stream().filter(s -> StringUtils.equalsIgnoreCase("codeallcode",s.getBtmname())).forEach(s -> {
                        s.setLcStatus(statusMap.get(s.getOid()));
                    });
                    //通过ID来进行去重
                    List<CodeAllCode> distinctCodeAllCOdes = addCodeDOs.stream().collect(Collectors
                        .collectingAndThen(
                            Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(CodeAllCode::getId))),
                            ArrayList::new));
                    if( distinctCodeAllCOdes.size() != addCodeDOs.size() ){
                        throw new VciBaseException("编码数据重复,无法保存,请注意!");
                    }
                    codeAllCodeService.saveBatch(addCodeDOs);
                }
                mdmEngineService.insertBatchByType(dataCBOList.get(0).getBtmname(),dataCBOList);
            }
//            WebUtil.setPersistence(true);
//            boService.persistenceBatch(batchCBO);
            return codeList;
        }else {
            List<CodeBasicSecVO> secVOList = ruleVO.getSecVOList().stream().sorted(((o1, o2) -> o1.getOrderNum().compareTo(o2.getOrderNum()))).collect(Collectors.toList());
@@ -347,7 +335,14 @@
            });
            //通过ID来进行去重
            List<CodeAllCode> distinctCodeAllCOdes = allCodeDOList.stream().collect(Collectors
                .collectingAndThen(
                    Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(CodeAllCode::getId))),
                    ArrayList::new));
            if( distinctCodeAllCOdes.size() != allCodeDOList.size() ){
                throw new VciBaseException("编码数据重复,无法保存,请注意!");
            }
            codeAllCodeService.saveBatch(allCodeDOList);
//            iCodeWupinService.saveBatch(dataCBOList);
            mdmEngineService.insertBatchByType(dataCBOList.get(0).getBtmname(),dataCBOList);