| | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.alibaba.nacos.common.utils.StringUtils; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.google.protobuf.ServiceException; |
| | | import com.vci.ubcs.code.applyjtcodeservice.feign.IMdmInterJtClient; |
| | | import com.vci.ubcs.code.bo.AttributeValue; |
| | | import com.vci.ubcs.code.bo.CodeClassifyFullInfoBO; |
| | |
| | | |
| | | @Value("${batchadd.redis.time:6000000}") |
| | | public int BATCHADD_REDIS_TIME; |
| | | |
| | | @Value("${batchadd.import_data_limit:5001}") |
| | | private Integer IMPORT_DATA_LIMIT; |
| | | |
| | | /** |
| | | * 主题库分类的服务 |
| | | */ |
| | |
| | | LinkedList<WriteExcelData> excelDataList = new LinkedList<>(); |
| | | Workbook workbook = new HSSFWorkbook(); |
| | | if(isHistory){ |
| | | excelDataList.add(new WriteExcelData(0,0,"分类路径")); |
| | | excelDataList.add(new WriteExcelData(0,1,"码段宽度")); |
| | | excelDataList.add(new WriteExcelData(0,2,!CollectionUtils.isEmpty(idAttrVOList)?idAttrVOList.get(0).getName():"企业编码")); |
| | | excelDataList.add(new WriteExcelData(0,0,"分类路径","")); |
| | | excelDataList.add(new WriteExcelData(0,1,"码段宽度","")); |
| | | excelDataList.add(new WriteExcelData(0,2,!CollectionUtils.isEmpty(idAttrVOList)?idAttrVOList.get(0).getName():"企业编码",idAttrVOList.get(0).getId())); |
| | | } |
| | | for (int i = 0; i < templateAttrVOS.size(); i++) { |
| | | CodeClassifyTemplateAttrVO attrVO = templateAttrVOS.get(i); |
| | |
| | | Object text = attrVO.getName(); |
| | | text = exportKeyAndRequired(workbook,attrVO,text); |
| | | int colIndex = (isHistory?3:0) + i; |
| | | WriteExcelData excelData = new WriteExcelData(0, colIndex, text); |
| | | WriteExcelData excelData = new WriteExcelData(0, colIndex, text,attrVO.getId()); |
| | | if(StringUtils.isNotBlank(attrVO.getCodeDateFormat()) |
| | | || VciFieldTypeEnum.VTDateTime.name().equalsIgnoreCase(attrVO.getAttributeDataType()) |
| | | || VciFieldTypeEnum.VTDate.name().equalsIgnoreCase(attrVO.getAttributeDataType()) |
| | |
| | | || sheetDataSetList.get(i).getRowData().size() < 1) { |
| | | continue; |
| | | } |
| | | // 单次导入数量限制 |
| | | if(sheetDataSetList.get(i).getRowData().size() > IMPORT_DATA_LIMIT){ |
| | | throw new ServiceException("为了保证系统的稳定性,请一次不要导入超过"+IMPORT_DATA_LIMIT+"条的数据"); |
| | | } |
| | | //历史导入的时候不处理编码 |
| | | //----逻辑内容---- |
| | | //1. 分类的路径可以在页面上选择是分类编号还是分类的名称 |
| | |
| | | if (CollectionUtils.isEmpty(ruleOidMap.values())) { |
| | | throw new VciBaseException("导入的数据所选择的分类都没有设置编码规则"); |
| | | } |
| | | Map<String, CodeRuleVO> ruleVOMap = ruleService.listCodeRuleByIds(ruleOidMap.values(), true).stream().collect(Collectors.toMap(s -> s.getOid(), t -> t)); |
| | | // TODO: 改用oid查询规则的,别用id |
| | | Map<String, CodeRuleVO> ruleVOMap = ruleService.listCodeRuleByOids(ruleOidMap.values()).stream().collect(Collectors.toMap(s -> s.getOid(), t -> t)); |
| | | //校验编码规则和码段是否正确 |
| | | Map<String, List<String>> ruleRowIndexMap = new ConcurrentHashMap<>(); |
| | | checkSecLengthInHistory(cboList, classifyVOMap, ruleVOMap, ruleOidMap, errorMap, ruleRowIndexMap); |
| | |
| | | //VciBaseUtil.setCurrentUserSessionInfo(sessionInfo); |
| | | List<String> rowIndexList = ruleRowIndexMap.get(ruleOid); |
| | | List<ClientBusinessObject> thisCbos = finalNeedSaveCboList.stream().filter(cbo -> rowIndexList.contains(cbo.getAttributeValue(IMPORT_ROW_INDEX)) && !errorMap.containsKey(cbo.getAttributeValue(IMPORT_ROW_INDEX))).collect(Collectors.toList()); |
| | | List<BaseModel> dataCBOList=new ArrayList<>(); |
| | | List<BaseModel> dataCBOList=new CopyOnWriteArrayList<>(); |
| | | thisCbos.stream().forEach(clientBusinessObject -> { |
| | | BaseModel baseModel=new BaseModel(); |
| | | BeanUtil.convert(clientBusinessObject,baseModel); |
| | |
| | | log.error("批量产生编码的时候出错了", e); |
| | | thisCbos.stream().forEach(cbo -> { |
| | | String rowIndex = cbo.getAttributeValue(IMPORT_ROW_INDEX); |
| | | errorMap.put(rowIndex, errorMap.getOrDefault(rowIndex, "") + ";系统错误,存储数据的时候出错了"); |
| | | errorMap.put(rowIndex, errorMap.getOrDefault(rowIndex, "") + ";系统错误,存储数据的时候出错了:"+e.getMessage()); |
| | | }); |
| | | |
| | | } |
| | |
| | | * @param currentTemplateVO |
| | | * @param templateColumnVOMap |
| | | */ |
| | | |
| | | private void createTemplate(CodeClassifyTemplateVO currentTemplateVO,Map<String,List<ColumnVO>>templateColumnVOMap){ |
| | | |
| | | List<CodeClassifyTemplateAttrVO> templateAttrVOS = currentTemplateVO.getAttributes().stream().filter(s -> |
| | |
| | | Map<String/**分类主键**/, String/**规则主键**/> ruleOidMap = new ConcurrentHashMap<String, String>(); |
| | | List<String> unExistRuleClassifyOidList = new CopyOnWriteArrayList<>(); |
| | | checkRuleOidInHistory(classifyVOMap, ruleOidMap, unExistRuleClassifyOidList); |
| | | ruleVOMap = ruleService.listCodeRuleByIds(ruleOidMap.values(), true).stream().collect(Collectors.toMap(s -> s.getOid(), t -> t)); |
| | | // TODO 改用oid查询的,这儿不该用id |
| | | ruleVOMap = ruleService.listCodeRuleByOids(ruleOidMap.values()).stream().collect(Collectors.toMap(s -> s.getOid(), t -> t)); |
| | | |
| | | checkSecLengthInHistory(cboList, classifyVOMap, ruleVOMap, ruleOidMap, errorMap, ruleRowIndexMap); |
| | | } |
| | |
| | | // if (lifeCycleVO != null) { |
| | | // cbo.setLcStatus(lifeCycleVO.getStartStatus()); |
| | | // } else { |
| | | cbo.setLcStatus(CodeDefaultLC.EDITING.getValue()); |
| | | cbo.setLcStatus(CodeDefaultLC.RELEASED.getValue()); |
| | | // } |
| | | } else { |
| | | cbo.setLcStatus(CodeDefaultLC.EDITING.getValue()); |
| | | cbo.setLcStatus(CodeDefaultLC.RELEASED.getValue()); |
| | | } |
| | | |
| | | } |
| | |
| | | for (int j = 0; j < ruleVO.getSecVOList().size(); j++) { |
| | | CodeBasicSecVO secVO = ruleVO.getSecVOList().get(j); |
| | | String length= secValues[j]; |
| | | if(StringUtils.isNotBlank(secVO.getCodeSecLength())&&VciBaseUtil.getInt(length)>VciBaseUtil.getInt(secVO.getCodeSecLength())){ |
| | | if(StringUtils.isNotBlank(secVO.getCodeSecLength())&&VciBaseUtil.getInt(length)>(VciBaseUtil.getInt(secVO.getCodeSecLength())+((secVO.getPrefixCode()+secVO.getSuffixCode()).length()))){ |
| | | errorMap.put(rowIndex,errorMap.getOrDefault(rowIndex,"") + ";码段宽度与系统中的编码规则不同" ); |
| | | fined = true; |
| | | break; |
| | |
| | | Integer userSecret = VciBaseUtil.getCurrentUserSecret(); |
| | | cbo.setAttributeValue(SECRET_FIELD,String.valueOf((userSecret==null || userSecret ==0)? UserSecretEnum.NONE.getValue():userSecret)); |
| | | } |
| | | cbo.setLcStatus(CodeDefaultLC.EDITING.getValue()); |
| | | cbo.setLcStatus(CodeDefaultLC.RELEASED.getValue()); |
| | | }else{ |
| | | //此时还没有转换路径 |
| | | //cbo.setAttributeValue(CODE_FULL_PATH_FILED, childOidPathMap.getOrDefault(rowData.getData().getOrDefault(CODE_CLASSIFY_OID_FIELD,""),fullPath)); |
| | |
| | | Integer userSecret = VciBaseUtil.getCurrentUserSecret(); |
| | | cbo.setAttributeValue(SECRET_FIELD,String.valueOf((userSecret==null || userSecret ==0)? UserSecretEnum.NONE.getValue():userSecret)); |
| | | } |
| | | cbo.setLcStatus(CodeDefaultLC.EDITING.getValue()); |
| | | cbo.setLcStatus(CodeDefaultLC.RELEASED.getValue()); |
| | | }else{ |
| | | //此时还没有转换路径 |
| | | //cbo.setAttributeValue(CODE_FULL_PATH_FILED, childOidPathMap.getOrDefault(rowData.getData().getOrDefault(CODE_CLASSIFY_OID_FIELD,""),fullPath)); |
| | |
| | | //2.判断关键属性在系统里是否重复 |
| | | //因为数据量很大,所以得想办法并行 |
| | | //SessionInfo sessionInfo = VciBaseUtil.getCurrentUserSessionInfo(); |
| | | Map<String,List<BaseModel>> indexTODataMap=new HashMap<>(); |
| | | Map<String,List<BaseModel>> indexTODataMap=new ConcurrentHashMap<>(); |
| | | List<ClientBusinessObject> repeatDataMap = cboList.parallelStream().filter(cbo -> { |
| | | //每行都得查询.如果其中出现了错误,我们就直接抛出异常,其余的显示 |
| | | //VciBaseUtil.setCurrentUserSessionInfo(sessionInfo); |