| | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | 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; |
| | |
| | | //VciBaseUtil.setCurrentUserSessionInfo(sessionInfo); |
| | | String code = cbo.getId(); |
| | | List<String> serialUnitList = new CopyOnWriteArrayList<>(); |
| | | String seclenghStr=cbo.getData().get(CODE_SEC_LENGTH_FIELD); |
| | | //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除去 |
| | | cbo.getData().remove(IMPORT_ROW_INDEX);//将此key除去 |
| | |
| | | //最后 |
| | | thisSecValue = seclenghStr.contains("#")?code.substring(VciBaseUtil.getInt(secLengths[i-1]),code.length()):code; |
| | | }else {*/ |
| | | int start = 0; |
| | | for (int j = 0; j < i; j++) { |
| | | start += VciBaseUtil.getInt(secLengths[j]); |
| | | } |
| | | thisSecValue = code.substring(start,start+VciBaseUtil.getInt(secLengths[i])); |
| | | int start = 0; |
| | | for (int j = 0; j < i; j++) { |
| | | start += VciBaseUtil.getInt(secLengths[j]); |
| | | } |
| | | thisSecValue = code.substring(start,start+VciBaseUtil.getInt(secLengths[i])); |
| | | // } |
| | | if(VciBaseUtil.getBoolean(secVO.getSerialDependFlag())){ |
| | | serialUnitList.add(thisSecValue); |
| | |
| | | List<String> serialUnFileStringList = new ArrayList<>(); |
| | | AtomicReference<String> newSerialUnitString = new AtomicReference<>(""); |
| | | if(!CollectionUtils.isEmpty(serialValueMap)){ |
| | | AtomicInteger index= new AtomicInteger(); |
| | | AtomicInteger index = new AtomicInteger(); |
| | | serialValueMap.forEach((secOid,secValue)->{ |
| | | //要看是不是补位的 |
| | | CodeBasicSecVO secVO = secVOMap.get(secOid); |
| | |
| | | if(OsCodeFillTypeEnum.NONE.getValue().equalsIgnoreCase(secVO.getCodeFillType())){ |
| | | //不补码 |
| | | //把所有不是数字的去掉,因为可能会是老数据,新规则 |
| | | // serialDb = VciBaseUtil.getDouble(killUnNumberChar(subSecValue)); |
| | | //serialDb = VciBaseUtil.getDouble(killUnNumberChar(subSecValue)); |
| | | //serialDb = killUnNumberChar(subSecValue); |
| | | serialDb=subSecValue; |
| | | }else { |
| | |
| | | serialDb = killFillChar(subSecValue,secVO.getCodeFillSeparator(), |
| | | OsCodeFillTypeEnum.LEFT.getValue().equalsIgnoreCase(secVO.getCodeFillType())); |
| | | } |
| | | Double newSerialDb= CustomSerialEnum.getDoubleCustomSerialValue(serialDb,secVO.getCustomCodeSerialType()); |
| | | HashMap<String, String> thisUnitMaxMap = maxSerialMap.getOrDefault(serialUnitString, new HashMap<>()); |
| | | Double maxValue=newSerialDb; |
| | | if(thisUnitMaxMap.containsKey(secOid)){ |
| | | String newMaxValue= thisUnitMaxMap.getOrDefault(secOid,""); |
| | | maxValue=StringUtils.isBlank(newMaxValue)?-1:VciBaseUtil.getDouble(newMaxValue); |
| | | if(maxValue<newSerialDb){ |
| | | maxValue=newSerialDb; |
| | | Double newSerialDb = CustomSerialEnum.getDoubleCustomSerialValue(serialDb,secVO.getCustomCodeSerialType()); |
| | | //TODO: 20240822需要这块代码是同步性的,maxSerialMap这儿会因为线程受影响,修改后测试多次总数为5000条一次导入耗费时间为3分30秒左右 |
| | | synchronized(this) { |
| | | HashMap<String, String> thisUnitMaxMap = maxSerialMap.getOrDefault(serialUnitString, new HashMap<>()); |
| | | Double maxValue=newSerialDb; |
| | | if(thisUnitMaxMap.containsKey(secOid)){ |
| | | String newMaxValue = thisUnitMaxMap.getOrDefault(secOid,""); |
| | | maxValue = StringUtils.isBlank(newMaxValue)?-1:VciBaseUtil.getDouble(newMaxValue); |
| | | if(maxValue < newSerialDb){ |
| | | maxValue = newSerialDb; |
| | | } |
| | | } |
| | | 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)); |
| | | } |
| | | 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)); |
| | | }); |
| | | } |
| | | CodeAllCode allCodeDO = new CodeAllCode(); |
| | |
| | | allCodeWrapper.in("id", QueryOptionConstant.IN + "(" + |
| | | VciBaseUtil.toInSql(codeDOs.stream().map(s->s.getId()).collect(Collectors.toList()).toArray(new String[0])) + ")"); |
| | | List<CodeAllCode> existCodes = codeAllCodeService.selectByWrapper(allCodeWrapper); |
| | | |
| | | |
| | | if(!CollectionUtils.isEmpty(existCodes)){ |
| | | existCodes.stream().forEach(existCode->{ |