xiejun
2023-10-16 a85cb705274d8fbd9f5fba86ff1c39c13ac66de0
Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/MdmProductCodeServiceImpl.java
@@ -30,6 +30,7 @@
import com.vci.ubcs.starter.web.util.VciBaseUtil;
import com.vci.ubcs.starter.web.util.VciDateUtil;
import lombok.extern.slf4j.Slf4j;
import org.springblade.core.log.exception.ServiceException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
@@ -150,13 +151,14 @@
                        OsCodeFillTypeEnum.LEFT.getValue().equalsIgnoreCase(secVO.getCodeFillType()))));
                  }
                  Map<String, Double> thisUnitMaxMap = maxSerialMap.getOrDefault(serialUnitString, new HashMap<>());
                  Double maxValue=serialDb;
                  if(thisUnitMaxMap.containsKey(secOid)){
                     Double maxValue=  thisUnitMaxMap.getOrDefault(secOid,new Double(-1));
                     if(maxValue>serialDb){
                        serialDb=maxValue;
                     maxValue=  thisUnitMaxMap.getOrDefault(secOid,new Double(-1));
                     if(maxValue<serialDb){
                        maxValue=serialDb;
                     }
                  }
                  thisUnitMaxMap.put(secOid,serialDb);
                  thisUnitMaxMap.put(secOid,maxValue);
                  maxSerialMap.put(serialUnitString,thisUnitMaxMap);
                  serialUnFileStringList.add(String.valueOf(serialDb));
               });
@@ -170,7 +172,8 @@
            allCodeDO.setCreateCodeBtm(cbo.getBtmname());
            allCodeDO.setCreateCodeOid(cbo.getOid());
            allCodeDO.setSerialUnit(serialUnitString);
            allCodeDO.setUnFillSerial(serialUnFileStringList.stream().collect(Collectors.joining(SERIAL_VALUE_SPACE)));
            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());
            allCodeDOList.add(allCodeDO);
         });
@@ -272,6 +275,12 @@
               if( distinctCodeAllCOdes.size() != addCodeDOs.size() ){
                  throw new VciBaseException("编码数据重复,无法保存,请注意!");
               }
               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){
                  throw new ServiceException("生成编码数据ID已有历史记录,请确认如下生成的ID数据:"+ addCodeDOs.stream().map(CodeAllCode::getId).collect(Collectors.toList()));
               }
               codeAllCodeService.saveBatch(addCodeDOs);
            }
            mdmEngineService.insertBatchByType(dataCBOList.get(0).getBtmname(),dataCBOList);
@@ -351,7 +360,13 @@
               Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(CodeAllCode::getId))),
               ArrayList::new));
         if( distinctCodeAllCOdes.size() != allCodeDOList.size() ){
            throw new VciBaseException("编码数据重复,无法保存,请注意!");
            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()));
         if(codeAllCodeService.count(wrapper)>0){
            throw new ServiceException("生成编码数据ID已有历史记录,请确认如下生成的ID数据:"+ allCodeDOList.stream().map(CodeAllCode::getId).collect(Collectors.toList()));
         }
         codeAllCodeService.saveBatch(allCodeDOList);
//         iCodeWupinService.saveBatch(dataCBOList);
@@ -737,12 +752,14 @@
   private String killFillChar(String s, String fillString,boolean left){
      Integer index = 0;
      String value = s;
      if(left){
         for (int i = 0; i < s.length(); i++) {
            char c = s.charAt(i);
            if((new String(new char[]{c})).equalsIgnoreCase(fillString)){
               index = i;
            if(!(new String(new char[]{c})).equalsIgnoreCase(fillString)){
               break;
            }
            index = i;
         }
         if(index >0){
            value = value.substring(index);
@@ -751,9 +768,10 @@
         //从右往左找
         for (int i = s.length()-1; i >=0; i++) {
            char c = s.charAt(i);
            if((new String(new char[]{c})).equalsIgnoreCase(fillString)){
               index = i;
            if(!(new String(new char[]{c})).equalsIgnoreCase(fillString)){
               break;
            }
            index = i;
         }
         if(index >0){
            value = value.substring(0,index);