| | |
| | | import org.apache.poi.ss.usermodel.Workbook; |
| | | import org.springblade.core.redis.cache.BladeRedis; |
| | | import org.springblade.core.tool.api.R; |
| | | import org.springblade.core.tool.utils.Func; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | |
| | | //参照的自行输入名称 |
| | | //分类注入的不用,都是导入后自动处理的 |
| | | //编码,状态等字段不导入 |
| | | List<CodeClassifyTemplateAttrVO> templateAttrVOS = templateVO.getAttributes().stream().filter(s -> |
| | | !DEFAULT_ATTR_LIST.contains(s.getId()) |
| | | && StringUtils.isBlank(s.getComponentRule()) |
| | | && StringUtils.isBlank(s.getClassifyInvokeAttr()) |
| | | && (VciBaseUtil.getBoolean(s.getFormDisplayFlag())) |
| | | ).collect(Collectors.toList()); |
| | | if(CollectionUtils.isEmpty(templateAttrVOS)){ |
| | | throw new VciBaseException("模板没有配置任何【表单显示】为【是】的属性"); |
| | | } |
| | | templateAttrVOS.stream().forEach(codetemplateAttr ->{ |
| | | String field=codetemplateAttr.getId(); |
| | | String name=codetemplateAttr.getName(); |
| | | CodeClassifyTemplateAttrVO codeBaseAttributeDTO=new CodeClassifyTemplateAttrVO(); |
| | | boolean res=(StringUtils.isNotBlank(codetemplateAttr.getAttributeGroup())&& codetemplateAttr.getAttributeGroup().equals(BATCHADD_EXCEPORT_ATTR_TYPE))//基本属性字段显示 |
| | | ||(StringUtils.isNotBlank(codetemplateAttr.getKeyAttrFlag())&&Boolean.parseBoolean(codetemplateAttr.getKeyAttrFlag()))//关键属性的存入 |
| | | ||(StringUtils.isNotBlank(codetemplateAttr.getSameRepeatAttrFlag())&&Boolean.parseBoolean(codetemplateAttr.getSameRepeatAttrFlag())) //相似属性的存入 |
| | | ||(StringUtils.isNotBlank(codetemplateAttr.getRequireFlag())&&Boolean.parseBoolean(codetemplateAttr.getRequireFlag())); |
| | | if(allFieldToOutNameMap.containsKey(name)){//如果存在的话则需要根据具体的去赋值 |
| | | codeBaseAttributeDTO= allFieldToOutNameMap.get(name); |
| | | if(StringUtils.isNotBlank(codetemplateAttr.getKeyAttrFlag())&&Boolean.parseBoolean(codetemplateAttr.getKeyAttrFlag())){ |
| | | codeBaseAttributeDTO.setKeyAttrFlag(codetemplateAttr.getKeyAttrFlag());//属性关键属性 |
| | | } |
| | | if(StringUtils.isNotBlank(codetemplateAttr.getRequireFlag())&&Boolean.parseBoolean(codetemplateAttr.getRequireFlag())){ |
| | | codeBaseAttributeDTO.setRequireFlag(codetemplateAttr.getRequireFlag());//属性必填项 |
| | | } |
| | | if(StringUtils.isNotBlank(codetemplateAttr.getSameRepeatAttrFlag())&&Boolean.parseBoolean(codetemplateAttr.getSameRepeatAttrFlag())){ |
| | | codeBaseAttributeDTO.setSameRepeatAttrFlag(codetemplateAttr.getSameRepeatAttrFlag());//属性相似属性 |
| | | } |
| | | }else if(res){ |
| | | allFieldToOutNameMap.put(name,codetemplateAttr); |
| | | if(!CollectionUtils.isEmpty(templateVO.getAttributes())) { |
| | | List<CodeClassifyTemplateAttrVO> templateAttrVOS = templateVO.getAttributes().stream().filter(s -> |
| | | !DEFAULT_ATTR_LIST.contains(s.getId()) |
| | | && StringUtils.isBlank(s.getComponentRule()) |
| | | && StringUtils.isBlank(s.getClassifyInvokeAttr()) |
| | | && (VciBaseUtil.getBoolean(s.getFormDisplayFlag())) |
| | | ).collect(Collectors.toList()); |
| | | if(CollectionUtils.isEmpty(templateAttrVOS)){ |
| | | throw new VciBaseException("模板没有配置任何【表单显示】为【是】的属性"); |
| | | } |
| | | }); |
| | | templateAttrVOS.stream().forEach(codetemplateAttr -> { |
| | | String field = codetemplateAttr.getId(); |
| | | String name = codetemplateAttr.getName(); |
| | | CodeClassifyTemplateAttrVO codeBaseAttributeDTO = new CodeClassifyTemplateAttrVO(); |
| | | boolean res = (StringUtils.isNotBlank(codetemplateAttr.getAttributeGroup()) && codetemplateAttr.getAttributeGroup().equals(BATCHADD_EXCEPORT_ATTR_TYPE))//基本属性字段显示 |
| | | || (StringUtils.isNotBlank(codetemplateAttr.getKeyAttrFlag()) && Boolean.parseBoolean(codetemplateAttr.getKeyAttrFlag()))//关键属性的存入 |
| | | || (StringUtils.isNotBlank(codetemplateAttr.getSameRepeatAttrFlag()) && Boolean.parseBoolean(codetemplateAttr.getSameRepeatAttrFlag())) //相似属性的存入 |
| | | || (StringUtils.isNotBlank(codetemplateAttr.getRequireFlag()) && Boolean.parseBoolean(codetemplateAttr.getRequireFlag())); |
| | | if (allFieldToOutNameMap.containsKey(name)) {//如果存在的话则需要根据具体的去赋值 |
| | | codeBaseAttributeDTO = allFieldToOutNameMap.get(name); |
| | | if (StringUtils.isNotBlank(codetemplateAttr.getKeyAttrFlag()) && Boolean.parseBoolean(codetemplateAttr.getKeyAttrFlag())) { |
| | | codeBaseAttributeDTO.setKeyAttrFlag(codetemplateAttr.getKeyAttrFlag());//属性关键属性 |
| | | } |
| | | if (StringUtils.isNotBlank(codetemplateAttr.getRequireFlag()) && Boolean.parseBoolean(codetemplateAttr.getRequireFlag())) { |
| | | codeBaseAttributeDTO.setRequireFlag(codetemplateAttr.getRequireFlag());//属性必填项 |
| | | } |
| | | if (StringUtils.isNotBlank(codetemplateAttr.getSameRepeatAttrFlag()) && Boolean.parseBoolean(codetemplateAttr.getSameRepeatAttrFlag())) { |
| | | codeBaseAttributeDTO.setSameRepeatAttrFlag(codetemplateAttr.getSameRepeatAttrFlag());//属性相似属性 |
| | | } |
| | | } else if (res) { |
| | | allFieldToOutNameMap.put(name, codetemplateAttr); |
| | | } |
| | | }); |
| | | } |
| | | }); |
| | | //整理好所有模板需要写入execl的属性信息 |
| | | Workbook workbook = new HSSFWorkbook(); |
| | |
| | | conditionMap.put("lastr", "1"); |
| | | conditionMap.put("lastv", "1"); |
| | | |
| | | // 查询出表名 |
| | | R<List<BtmTypeVO>> listR = btmTypeClient.selectByIdCollection(Arrays.asList(btmTypeId)); |
| | | String tableName = ""; |
| | | if(listR.isSuccess() && !listR.getData().isEmpty()){ |
| | | tableName = Func.isNotBlank(listR.getData().get(0).getTableName()) ? listR.getData().get(0).getTableName():VciBaseUtil.getTableName(btmTypeId); |
| | | }else{ |
| | | tableName = VciBaseUtil.getTableName(btmTypeId); |
| | | } |
| | | |
| | | |
| | | String countSql = "select count(*) from " + VciBaseUtil.getTableName(btmTypeId) +" where 1=1" + |
| | | String countSql = "select count(*) from " + tableName +" where 1=1" + |
| | | " and lastr = '1'" + |
| | | " and lastv='1'" + |
| | | " and codeclsfpath like '%" + exportAttrDTO.getCodeClassifyOid() + "%'"; |
| | |
| | | * @return 有错误信息的excel |
| | | */ |
| | | @Override |
| | | public void batchSyncApplyCode(CodeOrderDTO orderDTO, DataObjectVO dataObjectVO, LinkedList<XMLResultDataObjectDetailDO> resultDataObjectDetailDOs) { |
| | | public void batchSyncApplyCode(CodeOrderDTO orderDTO, DataObjectVO dataObjectVO, LinkedList<XMLResultDataObjectDetailDO> resultDataObjectDetailDOs,boolean isCodeOrGroupCode) { |
| | | Map<String,String> errorMap=new HashMap<>(); |
| | | VciBaseUtil.alertNotNull(orderDTO,"编码申请相关的数据",orderDTO.getCodeClassifyOid(),"主题库分类主键"); |
| | | CodeClassifyFullInfoBO classifyFullInfo = classifyService.getClassifyFullInfo(orderDTO.getCodeClassifyOid()); |
| | |
| | | sourceOid=codeOidToSystemOidMap.get(oid); |
| | | } |
| | | String code=""; |
| | | String groupCode=""; |
| | | String errorid="103"; |
| | | String mes=errorMap.get(rowIndex); |
| | | XMLResultDataObjectDetailDO resultDataObjectDetailDO=new XMLResultDataObjectDetailDO(); |
| | | resultDataObjectDetailDO.setCode(code); |
| | | if(isCodeOrGroupCode){ |
| | | resultDataObjectDetailDO.setCode(groupCode); |
| | | }else{ |
| | | resultDataObjectDetailDO.setCode(code); |
| | | } |
| | | resultDataObjectDetailDO.setId(sourceOid); |
| | | resultDataObjectDetailDO.setErrorid(errorid); |
| | | resultDataObjectDetailDO.setMsg(mes); |
| | |
| | | String oid = cbo.getOid(); |
| | | String sourceOid = oid; |
| | | String code = ""; |
| | | String groupCode=""; |
| | | String errorid = "201"; |
| | | if(codeOidToSystemOidMap.containsKey(oid)){ |
| | | sourceOid=codeOidToSystemOidMap.get(oid); |
| | |
| | | String lcstatus =newCbo.getLcStatus(); |
| | | String newOid =newCbo.getOid(); |
| | | Date ts =newCbo.getTs(); |
| | | groupCode=newCbo.getData().get("GROUPCODE"); |
| | | code=newCbo.getId(); |
| | | String lastmodifier=newCbo.getLastModifier(); |
| | | if (!lcstatus.equals(CodeDefaultLC.RELEASED.getValue())) { |
| | | if (lcstatus!=null&&!lcstatus.equals(CodeDefaultLC.RELEASED.getValue())) { |
| | | newCbo.setOid(newOid); |
| | | newCbo.setLastModifier(lastmodifier); |
| | | newCbo.setId(code); |
| | | /*if(isCodeOrGroupCode) { |
| | | newCbo.setId(code); |
| | | }else{ |
| | | newCbo.getData().put("groupcode",groupCode); |
| | | }*/ |
| | | newCbo.setTs(ts); |
| | | cbo.setLastModifier(cbo.getLastModifier()); |
| | | editBoList.add(newCbo); |
| | | } |
| | | String mes = errorKeyMap.get(rowIndex); |
| | | XMLResultDataObjectDetailDO resultDataObjectDetailDO = new XMLResultDataObjectDetailDO(); |
| | | resultDataObjectDetailDO.setCode(code); |
| | | if(isCodeOrGroupCode) { |
| | | if(StringUtils.isBlank(groupCode)){ |
| | | mes+=";申请的编码类型为集团码,等待集团编码赋值"; |
| | | } |
| | | resultDataObjectDetailDO.setCode(groupCode); |
| | | }else{ |
| | | resultDataObjectDetailDO.setCode(code); |
| | | } |
| | | resultDataObjectDetailDO.setId(sourceOid); |
| | | resultDataObjectDetailDO.setErrorid(errorid); |
| | | resultDataObjectDetailDO.setMsg(mes); |
| | | |
| | | resultDataObjectDetailDOs.add(resultDataObjectDetailDO); |
| | | } |
| | | } |
| | |
| | | // if(!isProcess){ |
| | | dataCBOList.stream().forEach(needSaveCbo->{ |
| | | XMLResultDataObjectDetailDO resultDataObjectDetailDO=new XMLResultDataObjectDetailDO(); |
| | | resultDataObjectDetailDO.setCode(needSaveCbo.getId()); |
| | | String code=needSaveCbo.getId(); |
| | | String groupCode=needSaveCbo.getData().getOrDefault("GROUPCODE",""); |
| | | //resultDataObjectDetailDO.setCode(needSaveCbo.getId()); |
| | | String msg="申请编码成功"; |
| | | String oid=needSaveCbo.getOid(); |
| | | String sourceOid=oid; |
| | | if(codeOidToSystemOidMap.containsKey(oid)){ |
| | | sourceOid=codeOidToSystemOidMap.get(oid); |
| | | } |
| | | if(isCodeOrGroupCode) { |
| | | if(StringUtils.isBlank(groupCode)){ |
| | | msg="申请的编码类型为集团码,等待集团编码赋值"; |
| | | } |
| | | resultDataObjectDetailDO.setCode(groupCode); |
| | | }else{ |
| | | resultDataObjectDetailDO.setCode(code); |
| | | } |
| | | resultDataObjectDetailDO.setId(sourceOid); |
| | | resultDataObjectDetailDO.setErrorid("0"); |
| | | resultDataObjectDetailDO.setMsg("申请编码成功"); |
| | | resultDataObjectDetailDO.setMsg(msg); |
| | | resultDataObjectDetailDOs.add(resultDataObjectDetailDO); |
| | | }); |
| | | /* }else{ |
| | |
| | | String tableName =""; |
| | | try { |
| | | R<BtmTypeVO> r = btmTypeClient.getAllAttributeByBtmId(templateVO.getBtmTypeId()); |
| | | if(r.getCode()!=200) { |
| | | if(!r.isSuccess()) { |
| | | throw new Throwable(r.getMsg()); |
| | | } |
| | | BtmTypeVO btmTypeVO = r.getData(); |
| | |
| | | String tableName =""; |
| | | try { |
| | | R<BtmTypeVO> r = btmTypeClient.getAllAttributeByBtmId(templateVO.getBtmTypeId()); |
| | | if(r.getCode()!=200) { |
| | | if(!r.isSuccess()) { |
| | | throw new Throwable(r.getMsg()); |
| | | } |
| | | BtmTypeVO btmTypeVO = r.getData(); |
| | |
| | | CodeImportResultVO resultVO = new CodeImportResultVO(); |
| | | resultVO.setKeyAttrRuleInfo(String.format(keyRuleVO ==null?"":"查询规则:去除空格--{0},忽略大小写--{1},忽略全半角--{2},忽略全部空格--{3}", |
| | | new String[]{trim?"是":"否",ignoreCase?"是":"否",ignoreWidth?"是":"否",trimAll?"是":"否"})); |
| | | resultVO.setSelfRepeatRowIndexList(getSelfRepeatRowIndex(ketAttrMap,cboList,keyRuleVO)); |
| | | //resultVO.setSelfRepeatRowIndexList(getSelfRepeatRowIndex(ketAttrMap,cboList,keyRuleVO)); |
| | | getSelfRepeatRowIndex(ketAttrMap,cboList,keyRuleVO,resultVO); |
| | | if(!CollectionUtils.isEmpty(resultVO.getSelfRepeatRowIndexList())){ |
| | | //我们移除本身重复的数据 |
| | | cboList = cboList.stream().filter(s->!resultVO.getSelfRepeatRowIndexList().contains(s.getAttributeValue(IMPORT_ROW_INDEX))).collect(Collectors.toList()); |
| | |
| | | * @param keyRuleVO 关键属性控制规则 |
| | | * @return 重复的行号 |
| | | */ |
| | | private Set<String> getSelfRepeatRowIndex(Map<String/**属性的编号**/, CodeClassifyTemplateAttrVO> ketAttrMap, |
| | | List<ClientBusinessObject> dataList,CodeKeyAttrRepeatVO keyRuleVO){ |
| | | private void getSelfRepeatRowIndex(Map<String/**属性的编号**/, CodeClassifyTemplateAttrVO> ketAttrMap, |
| | | List<ClientBusinessObject> dataList,CodeKeyAttrRepeatVO keyRuleVO,CodeImportResultVO resultVO){ |
| | | Set<String> selfRepeatRowIndexList = new CopyOnWriteArraySet<>(); |
| | | Map<String,List<String>> keyAttrOkOidTORepeatOidMap=new HashMap<>(); |
| | | boolean trimAll =keyRuleVO ==null?false: VciBaseUtil.getBoolean(keyRuleVO.getIgnoreallspaceflag()); |
| | | //全部去空的优先级大于去空 |
| | | boolean trim =keyRuleVO ==null?false: VciBaseUtil.getBoolean(keyRuleVO.getIgnorespaceflag()); |
| | |
| | | } |
| | | }); |
| | | //因为只是关键属性重复,所以我们不能重复的多条选一条来报错 |
| | | return selfRepeatRowIndexList; |
| | | resultVO.setKeyAttrRepeatRowIndexList(selfRepeatRowIndexList); |
| | | resultVO.setKeyAttrOkOidTORepeatOidMap(keyAttrOkOidTORepeatOidMap); |
| | | } |
| | | /** |
| | | * excel的标题上获取字段所在的位置 |