| | |
| | | |
| | | import com.alibaba.nacos.common.utils.StringUtils; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.vci.ubcs.code.algorithm.CustomSerialEnum; |
| | | import com.vci.ubcs.code.bo.CodeClassifyFullInfoBO; |
| | | import com.vci.ubcs.code.dto.CodeCustomSerialDTO; |
| | | import com.vci.ubcs.code.dto.CodeOrderSecDTO; |
| | | import com.vci.ubcs.code.entity.CodeAllCode; |
| | | import com.vci.ubcs.code.entity.CodeClassifyValue; |
| | |
| | | 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; |
| | | import java.lang.reflect.InvocationTargetException; |
| | | import java.lang.reflect.Method; |
| | | import java.util.*; |
| | | import java.util.concurrent.ConcurrentHashMap; |
| | | import java.util.concurrent.CopyOnWriteArrayList; |
| | | import java.util.concurrent.atomic.AtomicInteger; |
| | | import java.util.concurrent.atomic.AtomicReference; |
| | | import java.util.stream.Collectors; |
| | | |
| | |
| | | //ä¸»è¦æ¯ä¸ºäºå½å
¥æå¤§æµæ°´å·åallcode |
| | | //SessionInfo sessionInfo = VciBaseUtil.getCurrentUserSessionInfo(); |
| | | List<CodeAllCode> allCodeDOList = new CopyOnWriteArrayList<>(); |
| | | Map<String/**æµæ°´ä¾æ®**/, Map<String/**ç æ®µç主é®**/,Double/**æå¤§æµæ°´å·**/>> maxSerialMap = new HashMap<>(); |
| | | Map<String/**æµæ°´ä¾æ®**/, ConcurrentHashMap<String/**ç æ®µç主é®**/,String/**æå¤§æµæ°´å·**/>> maxSerialMap = new ConcurrentHashMap<>(); |
| | | // TODO å¤çº¿ç¨æµå¼åçé®é¢å·²ä¿®æ¹ |
| | | dataCBOList.parallelStream().forEach(cbo->{ |
| | | log.info("code:----->"+cbo.getId()); |
| | |
| | | List<CodeBasicSecVO> secVOList = finalRuleVO.getSecVOList().stream().sorted(((o1, o2) -> o1.getOrderNum().compareTo(o2.getOrderNum()))).collect(Collectors.toList()); |
| | | Map<String/**ç æ®µç主é®**/,String/**ç æ®µçå¼**/> serialValueMap = new HashMap<>(); |
| | | Map<String, CodeBasicSecVO> secVOMap = secVOList.stream().collect(Collectors.toMap(s -> s.getOid(), t -> t)); |
| | | Map<String,Integer> serialSecOidIndexMap=new HashMap<>(); |
| | | for (int i = 0; i < secLengths.length; i++) { |
| | | CodeBasicSecVO secVO = secVOList.get(i); |
| | | String thisSecValue = ""; |
| | |
| | | // } |
| | | if(VciBaseUtil.getBoolean(secVO.getSerialDependFlag())){ |
| | | serialUnitList.add(thisSecValue); |
| | | serialSecOidIndexMap.put(secVO.getOid(),i); |
| | | } |
| | | if(CodeSecTypeEnum.CODE_SERIAL_SEC.getValue().equalsIgnoreCase(secVO.getSecType())){ |
| | | serialValueMap.put(secVO.getOid(),thisSecValue); |
| | | } |
| | | } |
| | | String serialUnitString = serialUnitList.size() == 0 ? EMPTY_SERIAL_UNIT : serialUnitList.stream().collect(Collectors.joining(SERIAL_UNIT_SPACE)); |
| | | List<String> serialUnFileStringList = new ArrayList<>(); |
| | | AtomicReference<String> newSerialUnitString = new AtomicReference<>(""); |
| | | if(!CollectionUtils.isEmpty(serialValueMap)){ |
| | | AtomicInteger index= new AtomicInteger(); |
| | | serialValueMap.forEach((secOid,secValue)->{ |
| | | //è¦çæ¯ä¸æ¯è¡¥ä½ç |
| | | CodeBasicSecVO secVO = secVOMap.get(secOid); |
| | | Double serialDb = null; |
| | | List<String >newSerialUnitList=new ArrayList<>(); |
| | | newSerialUnitList.addAll(serialUnitList); |
| | | if(index.get() ==0){ |
| | | if(serialSecOidIndexMap.containsKey(secOid)) { |
| | | int num = serialSecOidIndexMap.get(secOid); |
| | | newSerialUnitList.set(num, ""); |
| | | } |
| | | } |
| | | String serialUnitString = newSerialUnitList.size() == 0 ? EMPTY_SERIAL_UNIT : newSerialUnitList.stream().collect(Collectors.joining(SERIAL_UNIT_SPACE)); |
| | | newSerialUnitString.set(serialUnitString); |
| | | index.getAndIncrement(); |
| | | String serialDb = ""; |
| | | // æªåæååç¼ä¹åçç æ®µ |
| | | String subSecValue = killPriffixSuffix(secValue, secVO.getPrefixCode(), secVO.getSuffixCode()); |
| | | if(OsCodeFillTypeEnum.NONE.getValue().equalsIgnoreCase(secVO.getCodeFillType())){ |
| | | //ä¸è¡¥ç |
| | | //æææä¸æ¯æ°åç廿ï¼å 为å¯è½ä¼æ¯èæ°æ®ï¼æ°è§å |
| | | serialDb = VciBaseUtil.getDouble(killUnNumberChar(subSecValue)); |
| | | // serialDb = VciBaseUtil.getDouble(killUnNumberChar(subSecValue)); |
| | | //serialDb = killUnNumberChar(subSecValue); |
| | | serialDb=subSecValue; |
| | | }else { |
| | | //å·¦å³å¡«å
çï¼æä»¬éè¦ |
| | | serialDb = VciBaseUtil.getDouble(killUnNumberChar(killFillChar(subSecValue,secVO.getCodeFillSeparator(), |
| | | OsCodeFillTypeEnum.LEFT.getValue().equalsIgnoreCase(secVO.getCodeFillType())))); |
| | | /*serialDb = VciBaseUtil.getDouble(killUnNumberChar(killFillChar(subSecValue,secVO.getCodeFillSeparator(), |
| | | OsCodeFillTypeEnum.LEFT.getValue().equalsIgnoreCase(secVO.getCodeFillType()))));*/ |
| | | serialDb = killFillChar(subSecValue,secVO.getCodeFillSeparator(), |
| | | OsCodeFillTypeEnum.LEFT.getValue().equalsIgnoreCase(secVO.getCodeFillType())); |
| | | } |
| | | Map<String, Double> thisUnitMaxMap = maxSerialMap.getOrDefault(serialUnitString, new HashMap<>()); |
| | | Double maxValue=serialDb; |
| | | Double newSerialDb= CustomSerialEnum.getDoubleCustomSerialValue(secValue,secVO.getCustomCodeSerialType()); |
| | | ConcurrentHashMap<String, String> thisUnitMaxMap = maxSerialMap.getOrDefault(serialUnitString, new ConcurrentHashMap<>()); |
| | | Double maxValue=newSerialDb; |
| | | if(thisUnitMaxMap.containsKey(secOid)){ |
| | | maxValue= thisUnitMaxMap.getOrDefault(secOid,new Double(-1)); |
| | | if(maxValue<serialDb){ |
| | | maxValue=serialDb; |
| | | String newMaxValue= thisUnitMaxMap.getOrDefault(secOid,""); |
| | | maxValue=StringUtils.isBlank(newMaxValue)?-1:VciBaseUtil.getDouble(newMaxValue); |
| | | if(maxValue<newSerialDb){ |
| | | maxValue=newSerialDb; |
| | | } |
| | | } |
| | | thisUnitMaxMap.put(secOid,maxValue); |
| | | String newMaxValue=CustomSerialEnum.getStringCustomSerialValue(maxValue,secVO.getCustomCodeSerialType()); |
| | | serialDb=CustomSerialEnum.getStringCustomSerialValue(newSerialDb,secVO.getCustomCodeSerialType()); |
| | | thisUnitMaxMap.put(secOid,newMaxValue); |
| | | maxSerialMap.put(serialUnitString,thisUnitMaxMap); |
| | | serialUnFileStringList.add(String.valueOf(serialDb)); |
| | | }); |
| | |
| | | allCodeDO.setCodeClassifyTemplateOid(templateVO.getOid()); |
| | | allCodeDO.setCreateCodeBtm(cbo.getBtmname()); |
| | | allCodeDO.setCreateCodeOid(cbo.getOid()); |
| | | allCodeDO.setSerialUnit(serialUnitString); |
| | | allCodeDO.setSerialUnit(newSerialUnitString.get()); |
| | | String unFillSerial =serialUnFileStringList.size()==1?serialUnFileStringList.get(0)+ SERIAL_VALUE_SPACE:serialUnFileStringList.stream().collect(Collectors.joining(SERIAL_VALUE_SPACE)); |
| | | allCodeDO.setUnFillSerial(unFillSerial); |
| | | allCodeDO.setLcStatus(cbo.getLcStatus()); |
| | |
| | | if (!CollectionUtils.isEmpty(serialValueDOS)) { |
| | | CodeSerialValue serialValueDO = serialValueDOS.get(0); |
| | | log.info("oldmaxSerial--->"+serialValueDO.getMaxSerial()+"---- newmaxSerial---->"+maxSerial); |
| | | if(VciBaseUtil.getDouble(serialValueDO.getMaxSerial())<maxSerial){ |
| | | if(VciBaseUtil.getDouble(serialValueDO.getMaxSerial())<VciBaseUtil.getDouble(maxSerial)){ |
| | | serialValueDO.setMaxSerial(String.valueOf(maxSerial)); |
| | | DefaultAttrAssimtUtil.updateDefaultAttrAssimt(serialValueDO); |
| | | editSerialValueList.add(serialValueDO); |
| | |
| | | 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())); |
| | | throw new ServiceException("çæç¼ç æ°æ®IDå·²æåå²è®°å½,请确认å¦ä¸çæçIDæ°æ®ï¼"+ codeAllCodes.stream().map(CodeAllCode::getId).collect(Collectors.toList())); |
| | | } |
| | | for (CodeAllCode codeAllCode : takeBack) { |
| | | codeAllCode.setTs(new Date()); |
| | |
| | | |
| | | // try { |
| | | mdmEngineService.insertBatchByType(dataCBOList.get(0).getBtmname(),dataCBOList); |
| | | // æäº¤äºå¡ |
| | | //transactionTemplate.getTransactionManager().commit(status); |
| | | // }catch (Exception e){ |
| | | // // åºç°å¼å¸¸æ¶åæ»äºå¡ |
| | | // transactionTemplate.getTransactionManager().rollback(status); |
| | | // } |
| | | |
| | | } |
| | | return codeList; |
| | | }else { |
| | |
| | | switchSecValue(secVO, secValueMap, classifyFullInfoBO, serialSecVOList, attrSecVOList, serialUnitList, secValueList); |
| | | } |
| | | //å¤ç屿§ç æ®µåæµæ°´ç æ®µ |
| | | Map<String/**æµæ°´ç 段ç主é®**/, Map<String/**æµæ°´ä¾æ®**/, Double>> lastMaxSerialValueMap = new HashMap<>(); |
| | | Map<String/**æµæ°´ç 段ç主é®**/, Map<String/**æµæ°´ä¾æ®**/, String>> lastMaxSerialValueMap = new HashMap<>(); |
| | | List<CodeAllCode> allCodeDOList = new ArrayList<>(); |
| | | |
| | | //å·²ç»åå¨çæå¤§æµæ°´å·çå
容 |
| | |
| | | switchAttrSecValue(attrSecVOList, cbo, thisSecValueList, attrSevIsSerialDepend, thisSerialUnitList); |
| | | |
| | | String serialUnitString = thisSerialUnitList.size() == 0 ? EMPTY_SERIAL_UNIT : thisSerialUnitList.stream().collect(Collectors.joining(SERIAL_UNIT_SPACE)); |
| | | switchSerialSecValue(serialSecVOList, attrSevIsSerialDepend, finalRuleVO, serialUnitString, maxSerialValueMap, thisSecValueList, lastMaxSerialValueMap, i == 0); |
| | | switchSerialSecValue(cbo,serialSecVOList, attrSevIsSerialDepend, finalRuleVO, serialUnitString, maxSerialValueMap, thisSecValueList, lastMaxSerialValueMap, i == 0); |
| | | |
| | | //ç»è£
ç¼ç çå¼ |
| | | cbo.setId(thisSecValueList.stream().collect(Collectors.joining())); |
| | |
| | | //æç 段éé¢é½æ¾ä¸ä¸æµæ°´å· |
| | | for (int j = 0; j < serialSecVOList.size(); j++) { |
| | | CodeBasicSecVO secVO = serialSecVOList.get(j); |
| | | Double serialValue = lastMaxSerialValueMap.getOrDefault(secVO.getOid(), new HashMap<>()).getOrDefault(serialUnitString, 0d); |
| | | String serialValue = lastMaxSerialValueMap.getOrDefault(secVO.getOid(), new HashMap<>()).getOrDefault(serialUnitString, ""); |
| | | if (serialValue != null) { |
| | | sb.append(String.valueOf(serialValue.longValue())).append(SERIAL_VALUE_SPACE); |
| | | sb.append(serialValue).append(SERIAL_VALUE_SPACE); |
| | | } |
| | | } |
| | | //è¦å卿åçå
¨é¨allcode |
| | |
| | | //å¤çæå¤§æµæ°´ |
| | | saveSerialValue( finalRuleVO, lastMaxSerialValueMap, maxSerialValueMap); |
| | | |
| | | allCodeDOList.stream().forEach( |
| | | 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 -> { |
| | | allCodeDOList.stream().forEach( |
| | | 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 |
| | | .collectingAndThen( |
| | | Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(CodeAllCode::getId))), |
| | | ArrayList::new)); |
| | | if( distinctCodeAllCOdes.size() != allCodeDOList.size() ){ |
| | | throw new ServiceException("ç¼ç æ°æ®éå¤ï¼æ æ³ä¿åï¼è¯·æ³¨æï¼"); |
| | | } |
| | | QueryWrapper<CodeAllCode> wrapper = new QueryWrapper<>(); |
| | | wrapper.eq("CREATECODEBTM",allCodeDOList.get(0).getCreateCodeBtm()); |
| | | wrapper.in("ID",allCodeDOList.stream().map(CodeAllCode::getId).collect(Collectors.toList())); |
| | | 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æ°æ®ï¼"+ codeAllCodes.stream().map(CodeAllCode::getId).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 ServiceException("ç¼ç æ°æ®éå¤ï¼æ æ³ä¿åï¼è¯·æ³¨æï¼"); |
| | | } |
| | | QueryWrapper<CodeAllCode> wrapper = new QueryWrapper<>(); |
| | | wrapper.eq("CREATECODEBTM",allCodeDOList.get(0).getCreateCodeBtm()); |
| | | wrapper.in("ID",allCodeDOList.stream().map(CodeAllCode::getId).collect(Collectors.toList())); |
| | | 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(); |
| | | 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); |
| | | mdmEngineService.insertBatchByType(dataCBOList.get(0).getBtmname(),dataCBOList); |
| | | mdmEngineService.insertBatchByType(dataCBOList.get(0).getBtmname(), dataCBOList); |
| | | if(takeBack.size()>0){ |
| | | codeAllCodeService.updateBatchById(takeBack); |
| | | } |
| | | codeAllCodeService.saveBatch(allCodeDOList); |
| | | // iCodeWupinService.saveBatch(dataCBOList); |
| | | // æäº¤äºå¡ |
| | | // transactionTemplate.getTransactionManager().commit(status); |
| | | //}catch (Exception e){ |
| | | // åºç°å¼å¸¸æ¶åæ»äºå¡ |
| | | // transactionTemplate.getTransactionManager().rollback(status); |
| | | // throw e; |
| | | //} |
| | | // batchCBO.getCreateCbos().stream().filter(s -> StringUtils.equalsIgnoreCase("codeallcode",s.getBtmName())).forEach(s -> { |
| | | // s.setLcStatus(statusMap.get(s.getOid())); |
| | | // try { |
| | |
| | | * @param lastMaxSerialValueMap å°è£
å |
| | | * @param firstData æ¯å¦ä¸ºç¬¬ä¸æ¡æ°æ® |
| | | */ |
| | | private void switchSerialSecValue(List<CodeBasicSecVO> serialSecVOList,boolean attrSevIsSerialDepend, |
| | | private void switchSerialSecValue(BaseModel cbo, List<CodeBasicSecVO> serialSecVOList,boolean attrSevIsSerialDepend, |
| | | CodeRuleVO ruleVO,String serialUnitString, |
| | | Map<String/**ç æ®µç主é®**/,Map<String/**æµæ°´ä¾æ®**/,CodeSerialValue>> maxSerialValueMap,List<String> thisSecValueList, |
| | | Map<String/**ç æ®µç主é®**/,Map<String/**æµæ°´ä¾æ®**/, Double>> lastMaxSerialValueMap,boolean firstData){ |
| | | Map<String/**ç æ®µç主é®**/,Map<String/**æµæ°´ä¾æ®**/, String>> lastMaxSerialValueMap,boolean firstData){ |
| | | |
| | | if (!CollectionUtils.isEmpty(serialSecVOList)) { |
| | | Map<String,String> secIdserialValueMap=new LinkedHashMap<>(); |
| | | for (int j = 0; j < serialSecVOList.size(); j++) { |
| | | CodeBasicSecVO secVO = serialSecVOList.get(j); |
| | | String secVOValue=""; |
| | | AtomicReference<String> newSerialUnitString= new AtomicReference<>(serialUnitString); |
| | | if(j==0){ |
| | | secVOValue=""; |
| | | newSerialUnitString.set(serialUnitString.replace("${" + secVO.getOid() + "}", secVOValue)); |
| | | }else{ |
| | | CodeBasicSecVO upSecVO =serialSecVOList.get(j-1); |
| | | secIdserialValueMap.forEach((key,vaule)->{ |
| | | newSerialUnitString.set(serialUnitString.replace("${"+key+"}", vaule)); |
| | | }); |
| | | } |
| | | |
| | | if (attrSevIsSerialDepend || firstData) { |
| | | //妿屿§ç æ®µä¹æ¯ä¾èµï¼åæ¯æ¬¡é½è¦æ¥è¯¢ï¼å¦æå±æ§ç æ®µä¸æ¯ä¾èµï¼ååªæ¥è¯¢ä¸æ¬¡ |
| | | // Map<String, String> conditionMap = new HashMap<>(); |
| | |
| | | // //è¿ä¸ªå段æ¯ä¸ºäºè§£å³å¤ä¸ªæµæ°´çé®é¢ |
| | | // conditionMap.put("codeSecOid", secVO.getOid()); |
| | | QueryWrapper<CodeSerialValue> codeSerialWrapper = new QueryWrapper<>(); |
| | | |
| | | codeSerialWrapper.eq("codeRuleOid", ruleVO.getOid()); |
| | | codeSerialWrapper.eq("serialUnit", serialUnitString); |
| | | codeSerialWrapper.eq("serialUnit", newSerialUnitString.get()); |
| | | codeSerialWrapper.eq("codeSecOid", secVO.getOid()); |
| | | List<CodeSerialValue> serialValueDOS = serialValueMapper.selectList(codeSerialWrapper); |
| | | if (!CollectionUtils.isEmpty(serialValueDOS)) { |
| | |
| | | maxSerialValueMap.put(secVO.getOid(), unitSerialMap); |
| | | } |
| | | } |
| | | Double startValue = null; |
| | | if(maxSerialValueMap.containsKey(secVO.getOid()) && maxSerialValueMap.get(secVO.getOid()).containsKey(serialUnitString)){ |
| | | startValue = VciBaseUtil.getDouble(maxSerialValueMap.get(secVO.getOid()).get(serialUnitString).getMaxSerial()); |
| | | String serialString=""; |
| | | String thisSerialValue = ""; |
| | | String startValue = null; |
| | | if (maxSerialValueMap.containsKey(secVO.getOid()) && maxSerialValueMap.get(secVO.getOid()).containsKey(newSerialUnitString.get())) { |
| | | startValue = maxSerialValueMap.get(secVO.getOid()).get(newSerialUnitString.get()).getMaxSerial(); |
| | | } |
| | | if(lastMaxSerialValueMap.containsKey(secVO.getOid()) && lastMaxSerialValueMap.get(secVO.getOid()).containsKey(serialUnitString)){ |
| | | if (lastMaxSerialValueMap.containsKey(secVO.getOid()) && lastMaxSerialValueMap.get(secVO.getOid()).containsKey(newSerialUnitString.get())) { |
| | | //说æå¤ä¸ªç³è¯·ï¼ä¹åå·²ç»å äºæµæ°´å·äº |
| | | startValue = lastMaxSerialValueMap.get(secVO.getOid()).get(serialUnitString); |
| | | startValue = lastMaxSerialValueMap.get(secVO.getOid()).get(newSerialUnitString.get()); |
| | | } |
| | | Double thisSerialValue = 0d; |
| | | if (startValue == null) { |
| | | //第ä¸ä¸ªç¼ç |
| | | thisSerialValue = VciBaseUtil.getDouble(secVO.getSerialStart()); |
| | | } else { |
| | | //æµæ°´å·è¯å®æ¯æ°å |
| | | thisSerialValue = startValue + (j + 1) * secVO.getSerialStep(); |
| | | } |
| | | //è¦çæ¯å¦è¶
è¿æå¤§çæµæ°´å¼ |
| | | if (thisSerialValue >= secVO.getCodeFillLimit()) { |
| | | throw new VciBaseException("æµæ°´å·å·²ç»è¶
è¿å
许çæå¤§æµæ°´å¼{0}",new String[]{secVO.getCodeFillLimit().toString()}); |
| | | if(StringUtils.isNotBlank(secVO.getCustomCodeSerialClass())){//èªå®ä¹æµæ°´å¤ç |
| | | String currentFlowValue=startValue; |
| | | CodeCustomSerialDTO codeCustomSerialDTO=new CodeCustomSerialDTO(); |
| | | codeCustomSerialDTO.setSerialUnitString(newSerialUnitString.get()); |
| | | codeCustomSerialDTO.setSerialCodeCodeBasicSec(secVO); |
| | | codeCustomSerialDTO.setCurrentFlowValue(startValue); |
| | | codeCustomSerialDTO.setCodeBasicSecVOList(ruleVO.getSecVOList()); |
| | | codeCustomSerialDTO.setCodeRuleOid(ruleVO.getOid()); |
| | | codeCustomSerialDTO.setBaseModel(cbo); |
| | | thisSerialValue=customCodeSerial(secVO.getCustomCodeSerialClass(),codeCustomSerialDTO); |
| | | log.info(secVO.getCustomCodeSerialClassText()+"---->"+thisSerialValue); |
| | | }else { |
| | | Double newThisSerialValue = 0d; |
| | | if (startValue == null) { |
| | | //第ä¸ä¸ªç¼ç |
| | | newThisSerialValue = VciBaseUtil.getDouble(secVO.getSerialStart()); |
| | | } else { |
| | | //æµæ°´å·è¯å®æ¯æ°å |
| | | newThisSerialValue = Double.parseDouble(startValue) + (j + 1) * secVO.getSerialStep(); |
| | | } |
| | | //è¦çæ¯å¦è¶
è¿æå¤§çæµæ°´å¼ |
| | | if (newThisSerialValue >= secVO.getCodeFillLimit()) { |
| | | throw new VciBaseException("æµæ°´å·å·²ç»è¶
è¿å
许çæå¤§æµæ°´å¼{0}", new String[]{secVO.getCodeFillLimit().toString()}); |
| | | } |
| | | thisSerialValue=String.valueOf(newThisSerialValue.intValue()); |
| | | } |
| | | //è¦çè¡¥ä½çå
容 |
| | | Integer fillLength = VciBaseUtil.getInt(secVO.getCodeFillLength()); |
| | |
| | | //鲿¢å¨æ·»å çå°æ¹æ²¡ææ§å¶æ£ç¡® |
| | | fillLength = VciBaseUtil.getInt(secVO.getCodeSecLength()); |
| | | } |
| | | String serialString = String.valueOf(thisSerialValue.longValue()); |
| | | serialString = thisSerialValue; |
| | | serialString = fillString(fillLength, OsCodeFillTypeEnum.forValue(secVO.getCodeFillType()), serialString, secVO.getCodeFillSeparator()); |
| | | |
| | | for (int z = 0; z < thisSecValueList.size(); z++) { |
| | | String secValue = thisSecValueList.get(z); |
| | | if (secValue.equalsIgnoreCase("${" + secVO.getOid() + "}")) { |
| | |
| | | thisSecValueList.set(z, joinPreffixAndSuffix(secVO, serialString)); |
| | | } |
| | | } |
| | | Map<String, Double> unitSerialMap = lastMaxSerialValueMap.getOrDefault(secVO.getOid(), new HashMap<>()); |
| | | unitSerialMap.put(serialUnitString, thisSerialValue); |
| | | secIdserialValueMap.put(secVO.getOid(),thisSerialValue);//è®°å½æµæ°´ç 段å½åçå¼ |
| | | Map<String, String> unitSerialMap = lastMaxSerialValueMap.getOrDefault(secVO.getOid(), new HashMap<>()); |
| | | unitSerialMap.put(newSerialUnitString.get(), String.valueOf(thisSerialValue)); |
| | | lastMaxSerialValueMap.put(secVO.getOid(),unitSerialMap); |
| | | } |
| | | } |
| | | } |
| | | |
| | | private String customCodeSerial(String className, CodeCustomSerialDTO codeCustomSerialDTO){ |
| | | String result = ""; |
| | | try { |
| | | Class classInstance=Class.forName(className); |
| | | Object obj =classInstance.newInstance(); |
| | | Method method= classInstance.getMethod("serialGenerate",CodeCustomSerialDTO.class); |
| | | method.setAccessible(Boolean.TRUE); |
| | | //method.invoke(obj); |
| | | Object o= method.invoke(obj,codeCustomSerialDTO); |
| | | result= Func.isEmpty(o) ?"":o.toString(); |
| | | } catch (ClassNotFoundException e) { |
| | | throw new VciBaseException("æªæ¾å°èªå®ä¹æµæ°´ç®æ³ç±»æä»¶"); |
| | | } catch (InvocationTargetException e) { |
| | | throw new VciBaseException("æ§è¡èªå®ä¹æµæ°´ç®æ³å¤çæ¹æ³åºç°å¼å¸¸"); |
| | | } catch (NoSuchMethodException e) { |
| | | throw new VciBaseException("æªæ¾å°èªå®ä¹æµæ°´ç®æ³å¤çæ¹æ³"); |
| | | } catch (IllegalAccessException e) { |
| | | throw new VciBaseException("æ§è¡èªå®ä¹æµæ°´ç®æ³å¤çæ¹æ³åºç°å¼å¸¸"); |
| | | } catch (InstantiationException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return result; |
| | | } |
| | | /** |
| | | * 转æ¢ç å¼çå
容 |
| | | * @param secVO ç æ®µçå
容 |
| | |
| | | * @param maxSerialValueMap 便®åå¨çæå¤§æµæ°´çå
容 |
| | | */ |
| | | private void saveSerialValue(CodeRuleVO ruleVO, |
| | | Map<String/**ç æ®µç主é®**/,Map<String, Double>> lastMaxSerialValueMap, |
| | | Map<String/**ç æ®µç主é®**/,Map<String, String>> lastMaxSerialValueMap, |
| | | Map<String/**ç æ®µç主é®**/,Map<String, CodeSerialValue>> maxSerialValueMap){ |
| | | List<CodeSerialValue> editSerialValueDOList = new ArrayList<>(); |
| | | List<CodeSerialValue> addSerialValueDOList = new ArrayList<>(); |