| | |
| | | |
| | | import com.alibaba.nacos.common.utils.StringUtils; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.BeanUtils; |
| | | import com.vci.ubcs.code.bo.CodeClassifyFullInfoBO; |
| | | import com.vci.ubcs.code.dto.CodeOrderSecDTO; |
| | | import com.vci.ubcs.code.entity.CodeAllCode; |
| | | import com.vci.ubcs.code.entity.CodeClassifyValue; |
| | | import com.vci.ubcs.code.entity.CodeSerialValue; |
| | | import com.vci.ubcs.code.enumpack.CodeCutTypeEnum; |
| | | import com.vci.ubcs.code.enumpack.CodeGetValueTypeEnum; |
| | | import com.vci.ubcs.code.enumpack.CodeLevelTypeEnum; |
| | | import com.vci.ubcs.code.enumpack.CodeSecTypeEnum; |
| | | import com.vci.ubcs.code.lifecycle.CodeAllCodeLC; |
| | | import com.vci.ubcs.code.mapper.CodeClassifyValueMapper; |
| | | import com.vci.ubcs.code.mapper.CodeSerialValueMapper; |
| | | import com.vci.ubcs.code.service.ICodeWupinService; |
| | | import com.vci.ubcs.code.service.MdmEngineService; |
| | | import com.vci.ubcs.code.service.MdmProductCodeService; |
| | | import com.vci.ubcs.code.vo.pagemodel.CodeBasicSecVO; |
| | |
| | | private CodeSerialValueMapper serialValueMapper; |
| | | |
| | | /** |
| | | * 所有的编码的内容 |
| | | * 流水号的相关的信息 |
| | | */ |
| | | @Resource |
| | | private CodeAllCodeServiceImpl codeAllCodeService; |
| | | private CodeClassifyValueMapper codeClassifyValueMapper; |
| | | |
| | | /** |
| | | * 所有的编码的内容 |
| | | */ |
| | | @Resource |
| | | private ICodeWupinService iCodeWupinService; |
| | | private CodeAllCodeServiceImpl codeAllCodeService; |
| | | |
| | | /** |
| | | * 所有的编码的内容 |
| | | */ |
| | |
| | | @Override |
| | | @Transactional(rollbackFor = VciBaseException.class) |
| | | public List<String> productCodeAndSaveData(CodeClassifyFullInfoBO classifyFullInfoBO, CodeClassifyTemplateVO templateVO, CodeRuleVO ruleVO, List<CodeOrderSecDTO> secDTOList, List<BaseModel> dataCBOList) throws Exception { |
| | | // BatchCBO batchCBO = new BatchCBO(); |
| | | // WebUtil.setPersistence(false); |
| | | dataCBOList = dataCBOList.stream().sorted(((o1, o2) -> o1.getCreateTime().compareTo(o2.getCreateTime()))).collect(Collectors.toList()); |
| | | // batchCBO.getCreateCbos().addAll(dataCBOList); |
| | | List<String> codeList = new ArrayList<>(); |
| | | |
| | | /***** |
| | |
| | | List<CodeSerialValue> editSerialValueList = new ArrayList<>(); |
| | | maxSerialMap.forEach((serialUnit,secOidMaxMap)->{ |
| | | secOidMaxMap.forEach((secOid,maxSerial)->{ |
| | | // Map<String, String> conditionMap = new HashMap<>(); |
| | | // conditionMap.put("codeRuleOid", ruleVO.getOid()); |
| | | // conditionMap.put("serialUnit", serialUnit); |
| | | // //这个字段是为了解决多个流水的问题 |
| | | // conditionMap.put("codeSecOid", secOid); |
| | | QueryWrapper<CodeSerialValue> queryWrapper = new QueryWrapper<>(); |
| | | queryWrapper.eq("codeRuleOid", ruleVO.getOid()); |
| | | queryWrapper.eq("serialUnit", serialUnit); |
| | | //这个字段是为了解决多个流水的问题 |
| | | queryWrapper.eq("codeSecOid", secOid); |
| | | |
| | | List<CodeSerialValue> serialValueDOS = serialValueMapper.selectList(queryWrapper); |
| | | // .selectByCondition(conditionMap, new PageHelper(-1)); |
| | | if (!CollectionUtils.isEmpty(serialValueDOS)) { |
| | | CodeSerialValue serialValueDO = serialValueDOS.get(0); |
| | | if(VciBaseUtil.getDouble(serialValueDO.getMaxSerial())<maxSerial){ |
| | | serialValueDO.setMaxSerial(String.valueOf(maxSerial)); |
| | | DefaultAttrAssimtUtil.updateDefaultAttrAssimt(serialValueDO); |
| | | editSerialValueList.add(serialValueDO); |
| | | } |
| | | }else{ |
| | | //没有 |
| | | CodeSerialValue serialValueDO = new CodeSerialValue(); |
| | | DefaultAttrAssimtUtil.addDefaultAttrAssimt(serialValueDO, MdmBtmTypeConstant.CODE_SERIAL_VALUE); |
| | | serialValueDO.setCodeRuleOid(ruleVO.getOid()); |
| | | serialValueDO.setSerialUnit(serialUnit); |
| | | serialValueDO.setCodeSecOid(secOid); |
| | |
| | | }); |
| | | }); |
| | | if(!CollectionUtils.isEmpty(addSerialValueList)){ |
| | | // batchCBO.copyFromOther(serialValueMapper.batchInsert(addSerialValueList)); |
| | | for (CodeSerialValue codeSerialValue : addSerialValueList) { |
| | | serialValueMapper.insert(codeSerialValue); |
| | | } |
| | | // serialValueMapper.ba |
| | | |
| | | } |
| | | if(!CollectionUtils.isEmpty(editSerialValueList)){ |
| | | for (CodeSerialValue codeSerialValue : editSerialValueList) { |
| | | serialValueMapper.updateById(codeSerialValue); |
| | | } |
| | | |
| | | // batchCBO.copyFromOther(serialValueMapper.batchUpdate(editSerialValueList)); |
| | | } |
| | | //处理allCode |
| | | if(!CollectionUtils.isEmpty(allCodeDOList)){ |
| | |
| | | List<CodeAllCode> editCodeDOs = new ArrayList<>(); |
| | | ruleGroup.forEach((ruleOid,allCodeDOS)->{ |
| | | VciBaseUtil.switchCollectionForOracleIn(allCodeDOS).stream().forEach(codeDOs->{ |
| | | // Map<String,String> conditionMap = new HashMap<>(); |
| | | // conditionMap.put("coderuleoid",ruleOid); |
| | | // conditionMap.put("id",QueryOptionConstant.IN + "(" + VciBaseUtil.toInSql(codeDOs.stream().map(s->s.getId()).collect(Collectors.toList()).toArray(new String[0])) + ")"); |
| | | QueryWrapper<CodeAllCode> allCodeWrapper = new QueryWrapper<>(); |
| | | allCodeWrapper.eq("coderuleoid",ruleOid); |
| | | allCodeWrapper.in("id", QueryOptionConstant.IN + "(" + |
| | |
| | | addCodeDOs = allCodeDOList; |
| | | } |
| | | if(!CollectionUtils.isEmpty(editCodeDOs)){ |
| | | // batchCBO.copyFromOther(allCodeMapper.batchUpdate(editCodeDOs)); |
| | | codeAllCodeService.updateBatchById(editCodeDOs); |
| | | } |
| | | if(!CollectionUtils.isEmpty(addCodeDOs)){ |
| | | //batchCBO.copyFromOther(allCodeMapper.batchInsert(addCodeDOs)); |
| | | Map<String, String> statusMap = addCodeDOs.stream().collect(Collectors.toMap(s -> s.getOid(), s -> s.getLcStatus())); |
| | | addCodeDOs.stream().filter(s -> StringUtils.equalsIgnoreCase("codeallcode",s.getBtmname())).forEach(s -> { |
| | | s.setLcStatus(statusMap.get(s.getOid())); |
| | | }); |
| | | //通过ID来进行去重 |
| | | List<CodeAllCode> distinctCodeAllCOdes = addCodeDOs.stream().collect(Collectors |
| | | .collectingAndThen( |
| | | Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(CodeAllCode::getId))), |
| | | ArrayList::new)); |
| | | if( distinctCodeAllCOdes.size() != addCodeDOs.size() ){ |
| | | throw new VciBaseException("编码数据重复,无法保存,请注意!"); |
| | | } |
| | | codeAllCodeService.saveBatch(addCodeDOs); |
| | | } |
| | | mdmEngineService.insertBatchByType(dataCBOList.get(0).getBtmname(),dataCBOList); |
| | | } |
| | | // WebUtil.setPersistence(true); |
| | | // boService.persistenceBatch(batchCBO); |
| | | return codeList; |
| | | }else { |
| | | List<CodeBasicSecVO> secVOList = ruleVO.getSecVOList().stream().sorted(((o1, o2) -> o1.getOrderNum().compareTo(o2.getOrderNum()))).collect(Collectors.toList()); |
| | | List<String> serialUnitList = new LinkedList<>(); |
| | | List<String> secValueList = new ArrayList<>(); |
| | | Map<String, String> secValueMap = secDTOList.stream().collect(Collectors.toMap(s -> s.getSecOid(), s -> s.getSecValue())); |
| | | Map<String, String> secValueMap = secDTOList.stream().collect(Collectors.toMap(s -> s.getSecOid(), s -> s.getSecValue()==null?"":s.getSecValue())); |
| | | List<CodeBasicSecVO> serialSecVOList = new ArrayList<>(); |
| | | List<CodeBasicSecVO> attrSecVOList = new ArrayList<>(); |
| | | for (int i = 0; i < secVOList.size(); i++) { |
| | |
| | | }); |
| | | |
| | | |
| | | |
| | | //通过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 VciBaseException("编码数据重复,无法保存,请注意!"); |
| | | } |
| | | codeAllCodeService.saveBatch(allCodeDOList); |
| | | // iCodeWupinService.saveBatch(dataCBOList); |
| | | mdmEngineService.insertBatchByType(dataCBOList.get(0).getBtmname(),dataCBOList); |
| | |
| | | break; |
| | | case CODE_CLASSIFY_SEC: |
| | | //分类码段的,也是从前端选择了码值即可,不论码值的长度是多少 |
| | | CodeClassifyValue codeClassifyValueDO= codeClassifyValueMapper.selectById(secValue); |
| | | if(codeClassifyValueDO!=null) { |
| | | secValue = codeClassifyValueDO.getId(); |
| | | } |
| | | break; |
| | | case CODE_LEVEL_SEC: |
| | | //层级码段,需要从分类上获取相应的信息 |
| | |
| | | BaseModel cbo, CodeClassifyTemplateVO templateVO, |
| | | List<CodeAllCode> allCodeDOList, String serialUnitString, String serialValueString){ |
| | | CodeAllCode allCodeDO = new CodeAllCode(); |
| | | DefaultAttrAssimtUtil.addDefaultAttrAssimt(allCodeDO, MdmBtmTypeConstant.CODE_ALL_CODE); |
| | | allCodeDO.setCodeClassifyOid(classifyFullInfoBO.getCurrentClassifyVO().getOid()); |
| | | allCodeDO.setCodeRuleOid(ruleVO.getOid()); |
| | | allCodeDO.setId(cbo.getId()); |
| | |
| | | //说明有 |
| | | serialValueDO = maxSerialValueMap.get(secOid).get(unit); |
| | | serialValueDO.setMaxSerial(maxSerial.toString()); |
| | | DefaultAttrAssimtUtil.updateDefaultAttrAssimt(serialValueDO); |
| | | editSerialValueDOList.add(serialValueDO); |
| | | }else{ |
| | | serialValueDO = new CodeSerialValue(); |
| | | DefaultAttrAssimtUtil.addDefaultAttrAssimt(serialValueDO, MdmBtmTypeConstant.CODE_SERIAL_VALUE); |
| | | serialValueDO.setCodeRuleOid(ruleVO.getOid()); |
| | | serialValueDO.setSerialUnit(unit); |
| | | serialValueDO.setCodeSecOid(secOid); |