| | |
| | | import com.vci.ubcs.starter.web.enumpck.OsCodeFillTypeEnum; |
| | | import com.vci.ubcs.starter.web.util.VciBaseUtil; |
| | | import com.vci.ubcs.starter.web.util.VciDateUtil; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.context.annotation.Lazy; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | |
| | | import static com.vci.ubcs.code.constant.MdmEngineConstant.*; |
| | | @Service |
| | | @Slf4j |
| | | public class MdmProductCodeServiceImpl implements MdmProductCodeService { |
| | | |
| | | /** |
| | |
| | | Map<String/**流水依据**/, Map<String/**码段的主键**/,Double/**最大流水号**/>> maxSerialMap = new HashMap<>(); |
| | | // TODO 多线程流引发的问题已修改 |
| | | dataCBOList.parallelStream().forEach(cbo->{ |
| | | log.info("code:----->"+cbo.getId()); |
| | | // VciBaseUtil.setCurrentUserSessionInfo(sessionInfo); |
| | | String code = cbo.getId(); |
| | | List<String> serialUnitList = new ArrayList<>(); |
| | | 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除去 |
| | |
| | | for (int i = 0; i < secLengths.length; i++) { |
| | | CodeBasicSecVO secVO = secVOList.get(i); |
| | | String thisSecValue = ""; |
| | | if(i == 0){ |
| | | thisSecValue = code.contains("#")?code.substring(0,code.indexOf("#")):code; |
| | | /*if(i == 0){ |
| | | thisSecValue = seclenghStr.contains("#")?code.substring(0,VciBaseUtil.getInt(secLengths[i])):code; |
| | | } else if(i == secLengths.length-1){ |
| | | //最后 |
| | | thisSecValue = code.contains("#")?code.substring(code.lastIndexOf("#")):code; |
| | | }else { |
| | | 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]) + 1; |
| | | start += VciBaseUtil.getInt(secLengths[j]); |
| | | } |
| | | thisSecValue = code.substring(start,start+VciBaseUtil.getInt(secLengths[1])); |
| | | } |
| | | thisSecValue = code.substring(start,start+VciBaseUtil.getInt(secLengths[i])); |
| | | // } |
| | | if(VciBaseUtil.getBoolean(secVO.getSerialDependFlag())){ |
| | | serialUnitList.add(thisSecValue); |
| | | } |
| | |
| | | OsCodeFillTypeEnum.LEFT.getValue().equalsIgnoreCase(secVO.getCodeFillType())))); |
| | | } |
| | | Map<String, Double> thisUnitMaxMap = maxSerialMap.getOrDefault(serialUnitString, new HashMap<>()); |
| | | if(thisUnitMaxMap.containsKey(secOid)){ |
| | | Double maxValue= thisUnitMaxMap.getOrDefault(secOid,new Double(-1)); |
| | | if(maxValue>serialDb){ |
| | | serialDb=maxValue; |
| | | } |
| | | } |
| | | thisUnitMaxMap.put(secOid,serialDb); |
| | | maxSerialMap.put(serialUnitString,thisUnitMaxMap); |
| | | serialUnFileStringList.add(String.valueOf(serialDb)); |
| | |
| | | //处理最大的流水号 |
| | | List<CodeSerialValue> addSerialValueList = new ArrayList<>(); |
| | | List<CodeSerialValue> editSerialValueList = new ArrayList<>(); |
| | | log.info("maxSerialMap:----->"+maxSerialMap.size()); |
| | | maxSerialMap.forEach((serialUnit,secOidMaxMap)->{ |
| | | secOidMaxMap.forEach((secOid,maxSerial)->{ |
| | | QueryWrapper<CodeSerialValue> queryWrapper = new QueryWrapper<>(); |
| | |
| | | queryWrapper.eq("codeSecOid", secOid); |
| | | |
| | | List<CodeSerialValue> serialValueDOS = serialValueMapper.selectList(queryWrapper); |
| | | log.info("serialValueDOS--->"+serialValueDOS.size()); |
| | | if (!CollectionUtils.isEmpty(serialValueDOS)) { |
| | | CodeSerialValue serialValueDO = serialValueDOS.get(0); |
| | | log.info("oldmaxSerial--->"+serialValueDO.getMaxSerial()+"---- newmaxSerial---->"+maxSerial); |
| | | if(VciBaseUtil.getDouble(serialValueDO.getMaxSerial())<maxSerial){ |
| | | serialValueDO.setMaxSerial(String.valueOf(maxSerial)); |
| | | DefaultAttrAssimtUtil.updateDefaultAttrAssimt(serialValueDO); |