| | |
| | | |
| | | 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.CodeWupinEntity; |
| | | 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.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; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.*; |
| | | import java.util.concurrent.atomic.AtomicReference; |
| | | import java.util.stream.Collectors; |
| | | |
| | | import static com.vci.ubcs.code.constant.MdmEngineConstant.*; |
| | |
| | | */ |
| | | @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<CodeWupinEntity> 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++) { |
| | | CodeWupinEntity 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,CodeWupinEntity cbo, |
| | | List<String> thisSecValueList,boolean attrSevIsSerialDepend, |
| | | List<String> serialUnitList){ |
| | | private void switchAttrSecValue(List<CodeBasicSecVO> attrSecVOList, BaseModel cbo, |
| | | List<String> thisSecValueList, boolean attrSevIsSerialDepend, |
| | | List<String> serialUnitList){ |
| | | if (!CollectionUtils.isEmpty(attrSecVOList)) { |
| | | attrSecVOList.stream().forEach(attrSevVO -> { |
| | | 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 templateVO 模板的信息 |
| | | * @param allCodeDOList 所有的码值的对象列表 |
| | | */ |
| | | private void wrapperAllCode(CodeClassifyFullInfoBO classifyFullInfoBO,CodeRuleVO ruleVO, |
| | | CodeWupinEntity cbo,CodeClassifyTemplateVO templateVO, |
| | | List<CodeAllCode> allCodeDOList,String serialUnitString,String serialValueString){ |
| | | private void wrapperAllCode(CodeClassifyFullInfoBO classifyFullInfoBO, CodeRuleVO ruleVO, |
| | | BaseModel cbo, CodeClassifyTemplateVO templateVO, |
| | | List<CodeAllCode> allCodeDOList, String serialUnitString, String serialValueString){ |
| | | CodeAllCode allCodeDO = new CodeAllCode(); |
| | | allCodeDO.setCodeClassifyOid(classifyFullInfoBO.getCurrentClassifyVO().getOid()); |
| | | allCodeDO.setCodeRuleOid(ruleVO.getOid()); |
| | |
| | | return value; |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 回收码值 |
| | | * |
| | | * @param btmId 业务数据的业务类型 |
| | | * @param businessOidCollection 业务数据的主键 |
| | | * @return 是否更新成功 |
| | | */ |
| | | @Override |
| | | public Boolean recycleCode(String btmId, Collection<String> businessOidCollection) { |
| | | // boolean oldPersistence = WebUtil.isPersistence(); |
| | | // WebUtil.setPersistence(false); |
| | | // BatchCBO batchCBO = new BatchCBO(); |
| | | AtomicReference<Boolean> updateFlag = new AtomicReference<>(false); |
| | | VciBaseUtil.switchCollectionForOracleIn(businessOidCollection).stream().forEach(oids-> { |
| | | // Map<String, String> conditionMap = new HashMap<>(); |
| | | // //编码要记录为回收的状态 |
| | | // conditionMap.put("createcodeoid", QueryOptionConstant.IN + "(" + VciBaseUtil.toInSql(oids.toArray(new String[0])) + ")"); |
| | | // conditionMap.put("createcodebtm", btmId); |
| | | |
| | | QueryWrapper<CodeAllCode> wrapper = new QueryWrapper<>(); |
| | | wrapper.in("createcodeoid",QueryOptionConstant.IN + "(" + VciBaseUtil.toInSql(oids.toArray(new String[0])) + ")"); |
| | | wrapper.eq("createcodebtm", btmId); |
| | | |
| | | |
| | | List<CodeAllCode> allCodeDOS = codeAllCodeService.selectByWrapper(wrapper); |
| | | // allCodeMapper.selectByCondition(conditionMap, new PageHelper(-1)); |
| | | if (!CollectionUtils.isEmpty(allCodeDOS)) { |
| | | allCodeDOS.stream().forEach(codeDO->{ |
| | | codeDO.setLcStatus(CodeAllCodeLC.TASK_BACK.getValue()); |
| | | }); |
| | | updateFlag.set(codeAllCodeService.updateBatchById(allCodeDOS)); |
| | | // batchCBO.copyFromOther(allCodeMapper.batchUpdate(allCodeDOS)); |
| | | } |
| | | }); |
| | | // 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); |
| | | } |
| | | } |