| | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.context.annotation.Lazy; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.TransactionStatus; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.transaction.support.DefaultTransactionDefinition; |
| | | import org.springframework.transaction.support.TransactionTemplate; |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | import javax.annotation.Resource; |
| | |
| | | @Autowired |
| | | private FormulaServiceImpl formulaService; |
| | | |
| | | // 注入事务管理器 |
| | | // @Autowired |
| | | // private TransactionTemplate transactionTemplate; |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public List<String> productCodeAndSaveData(CodeClassifyFullInfoBO classifyFullInfoBO, CodeClassifyTemplateVO templateVO, CodeRuleVO ruleVO, List<CodeOrderSecDTO> secDTOList, List<BaseModel> dataCBOList) throws Exception { |
| | |
| | | log.info("code:----->"+cbo.getId()); |
| | | //VciBaseUtil.setCurrentUserSessionInfo(sessionInfo); |
| | | String code = cbo.getId(); |
| | | List<String> serialUnitList = new ArrayList<>(); |
| | | List<String> serialUnitList = new CopyOnWriteArrayList<>(); |
| | | String seclenghStr=cbo.getData().get(CODE_SEC_LENGTH_FIELD); |
| | | String[] secLengths = cbo.getData().get(CODE_SEC_LENGTH_FIELD).split("#"); |
| | | cbo.getData().remove(CODE_SEC_LENGTH_FIELD);//将此key除去 |
| | |
| | | // TODO 历史数据导入的时候这儿偶尔会触发空指针异常 |
| | | Map<String,List<CodeAllCode>> ruleGroup = allCodeDOList.stream().collect(Collectors.groupingBy(s -> s.getCodeRuleOid())); |
| | | Map<String, CodeAllCode> codeDOMap = allCodeDOList.stream().collect(Collectors.toMap(s -> s.getCodeRuleOid() + "${SEP}" + s.getId(), t -> t)); |
| | | List<CodeAllCode> addCodeDOs = new ArrayList<>(); |
| | | List<CodeAllCode> editCodeDOs = new ArrayList<>(); |
| | | List<CodeAllCode> addCodeDOs = new CopyOnWriteArrayList<>(); |
| | | List<CodeAllCode> editCodeDOs = new CopyOnWriteArrayList<>(); |
| | | ruleGroup.forEach((ruleOid,allCodeDOS)->{ |
| | | VciBaseUtil.switchCollectionForOracleIn(allCodeDOS).stream().forEach(codeDOs->{ |
| | | QueryWrapper<CodeAllCode> allCodeWrapper = new QueryWrapper<>(); |
| | |
| | | if(!CollectionUtils.isEmpty(editCodeDOs)){ |
| | | codeAllCodeService.updateBatchById(editCodeDOs); |
| | | } |
| | | // 获取事务定义 |
| | | //DefaultTransactionDefinition def = new DefaultTransactionDefinition(); |
| | | // 开始事务 |
| | | //TransactionStatus status = transactionTemplate.getTransactionManager().getTransaction(def); |
| | | if(!CollectionUtils.isEmpty(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 -> { |
| | |
| | | .collectingAndThen( |
| | | Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(CodeAllCode::getId))), |
| | | ArrayList::new)); |
| | | if( distinctCodeAllCOdes.size() != addCodeDOs.size() ){ |
| | | if(distinctCodeAllCOdes.size() != addCodeDOs.size() ){ |
| | | throw new VciBaseException("编码数据重复,无法保存,请注意!"); |
| | | } |
| | | QueryWrapper<CodeAllCode> wrapper = new QueryWrapper<>(); |
| | |
| | | if(codeAllCode.getId().equals(next.getId())){ |
| | | codeAllCode.setCreateCodeOid(next.getCreateCodeOid()); |
| | | codeAllCode.setLcStatus(next.getLcStatus()); |
| | | iterator.remove(); |
| | | // TODO: 这儿先暂时注释掉,没看懂这儿为什么要这样做,导致报错 |
| | | //iterator.remove(); |
| | | } |
| | | } |
| | | } |
| | | if(takeBack.size()>0){ |
| | | codeAllCodeService.updateBatchById(takeBack); |
| | | } |
| | | |
| | | codeAllCodeService.saveBatch(addCodeDOs); |
| | | } |
| | | |
| | | mdmEngineService.insertBatchByType(dataCBOList.get(0).getBtmname(),dataCBOList); |
| | | } |
| | | return codeList; |
| | |
| | | allCode -> {DefaultAttrAssimtUtil.addDefaultAttrAssimt(allCode,"codeallcode");allCode.setLctid("codeAllCodeLC");} |
| | | ); |
| | | |
| | | |
| | | Map<String, String> statusMap = allCodeDOList.stream().collect(Collectors.toMap(s -> s.getOid(), s -> s.getLcStatus())); |
| | | allCodeDOList.stream().filter(s -> StringUtils.equalsIgnoreCase("codeallcode",s.getBtmname())).forEach(s -> { |
| | | s.setLcStatus(statusMap.get(s.getOid())); |
| | | }); |
| | | |
| | | |
| | | //通过ID来进行去重 |
| | | List<CodeAllCode> distinctCodeAllCOdes = allCodeDOList.stream().collect(Collectors |