田源
2024-09-29 d8f51c40544ae278095e991ed00ec297842d4332
Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/MdmProductCodeServiceImpl.java
@@ -51,6 +51,7 @@
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;
@@ -117,7 +118,7 @@
            //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除去
@@ -184,6 +185,8 @@
                        OsCodeFillTypeEnum.LEFT.getValue().equalsIgnoreCase(secVO.getCodeFillType()));
                  }
                  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)){
@@ -198,6 +201,7 @@
                  thisUnitMaxMap.put(secOid,newMaxValue);
                  maxSerialMap.put(serialUnitString,thisUnitMaxMap);
                  serialUnFileStringList.add(String.valueOf(serialDb));
                  }
               });
            }
            CodeAllCode allCodeDO = new CodeAllCode();
@@ -273,7 +277,6 @@
                  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->{