| | |
| | | import com.vci.ubcs.starter.web.util.VciDateUtil; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springblade.core.log.exception.ServiceException; |
| | | import org.springblade.core.secure.utils.AuthUtil; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.context.annotation.Lazy; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | |
| | | /***** |
| | | * 保证并发的时候,最大流水号都对的,但是这种加锁有弊端 |
| | | * |
| | | */ |
| | | |
| | | if(dataCBOList.stream().anyMatch(cbo-> StringUtils.isNotBlank(cbo.getId())) |
| | | // && StringUtils.isNotBlank(cbo.getAttributeValue(CODE_SEC_LENGTH_FIELD)) |
| | | ){ |
| | | // && StringUtils.isNotBlank(cbo.getAttributeValue(CODE_SEC_LENGTH_FIELD)) |
| | | ){ |
| | | //是历史数据导入 |
| | | //历史数据执行的时候,这个系统会很卡 |
| | | //主要是为了录入最大流水号和allcode |
| | | // SessionInfo sessionInfo = VciBaseUtil.getCurrentUserSessionInfo(); |
| | | //SessionInfo sessionInfo = VciBaseUtil.getCurrentUserSessionInfo(); |
| | | List<CodeAllCode> allCodeDOList = new ArrayList<>(); |
| | | Map<String/**流水依据**/, Map<String/**码段的主键**/,Double/**最大流水号**/>> maxSerialMap = new HashMap<>(); |
| | | // TODO 多线程流引发的问题已修改 |
| | | dataCBOList.parallelStream().forEach(cbo->{ |
| | | log.info("code:----->"+cbo.getId()); |
| | | // VciBaseUtil.setCurrentUserSessionInfo(sessionInfo); |
| | | //VciBaseUtil.setCurrentUserSessionInfo(sessionInfo); |
| | | String code = cbo.getId(); |
| | | List<String> serialUnitList = new ArrayList<>(); |
| | | String seclenghStr=cbo.getData().get(CODE_SEC_LENGTH_FIELD); |
| | |
| | | QueryWrapper<CodeAllCode> wrapper = new QueryWrapper<>(); |
| | | wrapper.eq("CREATECODEBTM",addCodeDOs.get(0).getCreateCodeBtm()); |
| | | wrapper.in("ID",addCodeDOs.stream().map(CodeAllCode::getId).collect(Collectors.toList())); |
| | | if(codeAllCodeService.count(wrapper)>0){ |
| | | List<CodeAllCode> codeAllCodes = codeAllCodeService.selectByWrapper(wrapper); |
| | | List<CodeAllCode> takeBack = codeAllCodes.stream().filter(e -> e.getLcStatus().equals("TakeBack")).collect(Collectors.toList()); |
| | | if(codeAllCodes.size()>takeBack.size()){ |
| | | throw new ServiceException("生成编码数据ID已有历史记录,请确认如下生成的ID数据:"+ addCodeDOs.stream().map(CodeAllCode::getId).collect(Collectors.toList())); |
| | | } |
| | | for (CodeAllCode codeAllCode : takeBack) { |
| | | codeAllCode.setTs(new Date()); |
| | | codeAllCode.setLastModifyTime(new Date()); |
| | | codeAllCode.setLastModifier(AuthUtil.getUserId().toString()); |
| | | Iterator<CodeAllCode> iterator = addCodeDOs.iterator(); |
| | | while (iterator.hasNext()){ |
| | | CodeAllCode next = iterator.next(); |
| | | if(codeAllCode.getId().equals(next.getId())){ |
| | | codeAllCode.setCreateCodeOid(next.getCreateCodeOid()); |
| | | codeAllCode.setLcStatus(next.getLcStatus()); |
| | | iterator.remove(); |
| | | } |
| | | } |
| | | } |
| | | if(takeBack.size()>0){ |
| | | codeAllCodeService.updateBatchById(takeBack); |
| | | } |
| | | codeAllCodeService.saveBatch(addCodeDOs); |
| | | } |
| | |
| | | QueryWrapper<CodeAllCode> wrapper = new QueryWrapper<>(); |
| | | wrapper.eq("CREATECODEBTM",allCodeDOList.get(0).getCreateCodeBtm()); |
| | | wrapper.in("ID",allCodeDOList.stream().map(CodeAllCode::getId).collect(Collectors.toList())); |
| | | if(codeAllCodeService.count(wrapper)>0){ |
| | | List<CodeAllCode> codeAllCodes = codeAllCodeService.selectByWrapper(wrapper); |
| | | List<CodeAllCode> takeBack = codeAllCodes.stream().filter(e -> e.getLcStatus().equals("TakeBack")).collect(Collectors.toList()); |
| | | if(codeAllCodes.size()>takeBack.size()){ |
| | | throw new ServiceException("生成编码数据ID已有历史记录,请确认如下生成的ID数据:"+ allCodeDOList.stream().map(CodeAllCode::getId).collect(Collectors.toList())); |
| | | } |
| | | |
| | | for (CodeAllCode codeAllCode : takeBack) { |
| | | codeAllCode.setTs(new Date()); |
| | | codeAllCode.setLastModifyTime(new Date()); |
| | | codeAllCode.setLastModifier(AuthUtil.getUserId().toString()); |
| | | Iterator<CodeAllCode> iterator = allCodeDOList.iterator(); |
| | | while (iterator.hasNext()){ |
| | | CodeAllCode next = iterator.next(); |
| | | if(codeAllCode.getId().equals(next.getId())){ |
| | | codeAllCode.setCreateCodeOid(next.getCreateCodeOid()); |
| | | codeAllCode.setLcStatus(next.getLcStatus()); |
| | | iterator.remove(); |
| | | } |
| | | } |
| | | } |
| | | if(takeBack.size()>0){ |
| | | codeAllCodeService.updateBatchById(takeBack); |
| | | } |
| | | codeAllCodeService.saveBatch(allCodeDOList); |
| | | // iCodeWupinService.saveBatch(dataCBOList); |
| | |
| | | // } |
| | | // }); |
| | | } |
| | | // WebUtil.setPersistence(true); |
| | | // boService.persistenceBatch(batchCBO); |
| | | // WebUtil.setPersistence(true); |
| | | // boService.persistenceBatch(batchCBO); |
| | | return codeList; |
| | | } |
| | | |
| | | /** |
| | | * 转换属性码段的值 |
| | | * @param attrSecVOList 属性码段的显示对象 |
| | |
| | | }); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 转换流水码段的值 |
| | |
| | | allCodeDOList.add(allCodeDO); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | /** |
| | | * 保存流水的信息 |
| | | * @param ruleVO 规则的显示对象 |
| | |
| | | // WebUtil.copyValueToMapFromCbos(cbo,dataMap); |
| | | return formulaService.getValueByFormula(map,rule); |
| | | } |
| | | |
| | | } |