| | |
| | | import com.vci.ubcs.starter.revision.model.BaseModel; |
| | | import com.vci.ubcs.starter.util.DefaultAttrAssimtUtil; |
| | | import com.vci.ubcs.starter.util.LocalFileUtil; |
| | | import com.vci.ubcs.starter.util.UBCSSqlKeyword; |
| | | import com.vci.ubcs.starter.web.constant.QueryOptionConstant; |
| | | import com.vci.ubcs.starter.web.enumpck.BooleanEnum; |
| | | import com.vci.ubcs.starter.web.enumpck.UserSecretEnum; |
| | |
| | | //参照的自行输入名称 |
| | | //分类注入的不用,都是导入后自动处理的 |
| | | //编码,状态等字段不导入 |
| | | 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(); |
| | |
| | | CodeClassifyTemplateVO templateVO = engineService.getUsedTemplateByClassifyOid(exportAttrDTO.getCodeClassifyOid()); |
| | | //先查询数据 |
| | | String btmTypeId = classifyFullInfo.getTopClassifyVO().getBtmTypeId(); |
| | | Map<String, Object> conditionMap = exportAttrDTO.getConditionMap(); |
| | | Map<String, String> conditionMap = exportAttrDTO.getConditionMap(); |
| | | if(conditionMap == null){ |
| | | conditionMap = new HashMap<>(); |
| | | } |
| | |
| | | conditionMap.put("codeclsfpath","*" + exportAttrDTO.getCodeClassifyOid() + "*"); |
| | | conditionMap.put("lastr", "1"); |
| | | conditionMap.put("lastv", "1"); |
| | | UBCSSqlKeyword.buildSqlwhere(conditionMap); |
| | | |
| | | String countSql = "select count(*) from " + VciBaseUtil.getTableName(btmTypeId) +" where 1=1" + |
| | | " and lastr = '1'" + |
| | | " and lastv='1'" + |
| | | " and codeclsfpath like '%" + exportAttrDTO.getCodeClassifyOid() + "%'"; |
| | | |
| | | //先查询总数 |
| | | int total = 0; |
| | | if(exportAttrDTO.getEndPage()!=null && exportAttrDTO.getEndPage()>0 |
| | |
| | | thisPage.setOrder(exportAttrDTO.getOrder()); |
| | | thisPage.addDefaultDesc("createTime"); |
| | | |
| | | total += boService.queryCount(btmTypeId, conditionMap); |
| | | total += commonsMapper.queryCountBySql(countSql); |
| | | } |
| | | }else{ |
| | | |
| | | total=boService.queryCount(btmTypeId, conditionMap); |
| | | total = commonsMapper.queryCountBySql(countSql); |
| | | } |
| | | List<String> selectFieldList = new ArrayList<>(); |
| | | if(!CollectionUtils.isEmpty(exportAttrDTO.getAttrIdIndexMap())){ |
| | |
| | | LocalFileUtil.deleteTempFile(file,true); |
| | | return zipFileName; |
| | | } |
| | | |
| | | private |
| | | |
| | | |
| | | /** |
| | | * 查询数据并导出到excel |
| | |
| | | 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(); |