| | |
| | | |
| | | 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.CodeSerialValue; |
| | | import com.vci.ubcs.code.entity.CodeWupin; |
| | | 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.lifecycle.CodeAllCodeLC; |
| | | 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; |
| | | import com.vci.ubcs.code.vo.pagemodel.CodeClassifyTemplateVO; |
| | | import com.vci.ubcs.code.vo.pagemodel.CodeClassifyVO; |
| | | import com.vci.ubcs.code.vo.pagemodel.CodeRuleVO; |
| | | import com.vci.ubcs.starter.exception.VciBaseException; |
| | | import com.vci.ubcs.starter.revision.model.BaseModel; |
| | | import com.vci.ubcs.starter.util.DefaultAttrAssimtUtil; |
| | | import com.vci.ubcs.starter.web.constant.QueryOptionConstant; |
| | | import com.vci.ubcs.starter.web.constant.RegExpConstant; |
| | | 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 org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.context.annotation.Lazy; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | |
| | | */ |
| | | @Resource |
| | | private ICodeWupinService iCodeWupinService; |
| | | /** |
| | | * 所有的编码的内容 |
| | | */ |
| | | @Resource |
| | | @Lazy |
| | | private MdmEngineService mdmEngineService; |
| | | |
| | | /** |
| | | * 公式的服务 |
| | | */ |
| | | @Autowired |
| | | private FormulaServiceImpl formulaService; |
| | | |
| | | @Override |
| | | public List<String> productCodeAndSaveData(CodeClassifyFullInfoBO classifyFullInfoBO, CodeClassifyTemplateVO templateVO, CodeRuleVO ruleVO, List<CodeOrderSecDTO> secDTOList, List<CodeWupin> dataCBOList) { |
| | | 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()); |
| | | dataCBOList = dataCBOList.stream().sorted(((o1, o2) -> o1.getCreateTime().compareTo(o2.getCreateTime()))).collect(Collectors.toList()); |
| | | // batchCBO.getCreateCbos().addAll(dataCBOList); |
| | | List<String> codeList = new ArrayList<>(); |
| | | |
| | |
| | | // VciBaseUtil.setCurrentUserSessionInfo(sessionInfo); |
| | | String code = cbo.getId(); |
| | | List<String> serialUnitList = new ArrayList<>(); |
| | | String[] secLengths = cbo.getCodeSecLengthField().split("#"); |
| | | String[] secLengths = cbo.getData().get(CODE_SEC_LENGTH_FIELD).split("#"); |
| | | List<CodeBasicSecVO> secVOList = ruleVO.getSecVOList().stream().sorted(((o1, o2) -> o1.getOrderNum().compareTo(o2.getOrderNum()))).collect(Collectors.toList()); |
| | | Map<String/**码段的主键**/,String/**码段的值**/> serialValueMap = new HashMap<>(); |
| | | Map<String, CodeBasicSecVO> secVOMap = secVOList.stream().collect(Collectors.toMap(s -> s.getOid(), t -> t)); |
| | |
| | | Map<String/**码段的主键**/, Map<String, CodeSerialValue>> maxSerialValueMap = new HashMap<>(); |
| | | |
| | | for (int i = 0; i < dataCBOList.size(); i++) { |
| | | CodeWupin cbo = dataCBOList.get(i); |
| | | BaseModel cbo = dataCBOList.get(i); |
| | | List<String> thisSecValueList = new LinkedList<>(); |
| | | for (int j = 0; j < secValueList.size(); j++) { |
| | | thisSecValueList.add(secValueList.get(j)); |
| | |
| | | Map<String, String> statusMap = allCodeDOList.stream().collect(Collectors.toMap(s -> s.getOid(), s -> s.getLcStatus())); |
| | | allCodeDOList.stream().filter(s -> StringUtils.equalsIgnoreCase("codeallcode",s.getBtmname())).forEach(s -> { |
| | | s.setLcStatus(statusMap.get(s.getOid())); |
| | | |
| | | }); |
| | | |
| | | |
| | | allCodeDOList.stream().forEach( |
| | | allCode -> {DefaultAttrAssimtUtil.addDefaultAttrAssimt(allCode,"codeallcode");allCode.setLctid("codeAllCodeLC");} |
| | | ); |
| | | |
| | | codeAllCodeService.saveBatch(allCodeDOList); |
| | | iCodeWupinService.saveBatch(dataCBOList); |
| | | // iCodeWupinService.saveBatch(dataCBOList); |
| | | mdmEngineService.insertBatchByType(dataCBOList.get(0).getBtmname(),dataCBOList); |
| | | |
| | | // batchCBO.getCreateCbos().stream().filter(s -> StringUtils.equalsIgnoreCase("codeallcode",s.getBtmName())).forEach(s -> { |
| | | // s.setLcStatus(statusMap.get(s.getOid())); |
| | | // try { |
| | |
| | | * @param serialUnitList 流水依据的内容 |
| | | * 还需要后续的一个移植将会涉及到其他的服务 |
| | | */ |
| | | private void switchAttrSecValue(List<CodeBasicSecVO> attrSecVOList, CodeWupin cbo, |
| | | private void switchAttrSecValue(List<CodeBasicSecVO> attrSecVOList, BaseModel cbo, |
| | | List<String> thisSecValueList, boolean attrSevIsSerialDepend, |
| | | List<String> serialUnitList){ |
| | | if (!CollectionUtils.isEmpty(attrSecVOList)) { |
| | |
| | | String value = ""; |
| | | if (StringUtils.isNotBlank(attrSevVO.getGetValueClass())) { |
| | | //使用组合规则来处理的 |
| | | // value = getValueByFormulaForCBO(cbo, attrSevVO.getGetValueClass()); |
| | | value = getValueByFormulaForCBO(cbo, attrSevVO.getGetValueClass()); |
| | | } else { |
| | | // value = cbo.getAttributeValue(attrSevVO.getReferAttributeId()); |
| | | value = cbo.getData().get(attrSevVO.getReferAttributeId()); |
| | | } |
| | | if (value == null) { |
| | | value = ""; |
| | |
| | | * @param allCodeDOList 所有的码值的对象列表 |
| | | */ |
| | | private void wrapperAllCode(CodeClassifyFullInfoBO classifyFullInfoBO, CodeRuleVO ruleVO, |
| | | CodeWupin cbo, CodeClassifyTemplateVO templateVO, |
| | | BaseModel cbo, CodeClassifyTemplateVO templateVO, |
| | | List<CodeAllCode> allCodeDOList, String serialUnitString, String serialValueString){ |
| | | CodeAllCode allCodeDO = new CodeAllCode(); |
| | | allCodeDO.setCodeClassifyOid(classifyFullInfoBO.getCurrentClassifyVO().getOid()); |
| | |
| | | // WebUtil.setPersistence(oldPersistence); |
| | | return updateFlag.get(); |
| | | } |
| | | |
| | | /** |
| | | * 使用CBO处理组合规则的内容 |
| | | * @param cbo 数据的内容 |
| | | * @param rule 规则的内容 |
| | | * @return 转换后的 |
| | | */ |
| | | private String getValueByFormulaForCBO(BaseModel cbo,String rule){ |
| | | Map<String, Object> dataMap = BeanUtils.beanToMap(cbo); |
| | | Map<String, String> map = new HashMap<String, String>(); |
| | | for (String i : dataMap.keySet()) { |
| | | map.put(i, String.valueOf(dataMap.get(i))); |
| | | } |
| | | // WebUtil.copyValueToMapFromCbos(cbo,dataMap); |
| | | return formulaService.getValueByFormula(map,rule); |
| | | } |
| | | } |