| | |
| | | @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<>(); |
| | | |
| | | /***** |
| | |
| | | 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){ |
| | |
| | | }); |
| | | }); |
| | | 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)){ |
| | |
| | | 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 + "(" + |
| | |
| | | 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()); |
| | |
| | | }); |
| | | |
| | | |
| | | |
| | | //通过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); |