From 977b4b2f4b0ce0af4d259a113f076e93053a5d96 Mon Sep 17 00:00:00 2001 From: xiejun <xj@2023> Date: 星期一, 04 十二月 2023 01:28:00 +0800 Subject: [PATCH] 集团码导出模板功能添加 --- Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/code/vo/webserviceModel/attrmap/标准系列修订(跨年).json | 0 Source/UBCS/ubcs-service/ubcs-applyjtcodeservice/src/main/java/com/vci/ubcs/code/applyjtcodeservice/service/impl/DockingPreAttrMappingServiceImpl.java | 3 Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/code/dto/ExecGroupCodePortDataDTO.java | 32 ++++ Source/UBCS/ubcs-service/ubcs-applyjtcodeservice/src/main/java/com/vci/ubcs/code/applyjtcodeservice/service/IDockingPreAttrMappingService.java | 9 + Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/MdmIOServiceImpl.java | 264 +++++++++++++++++++++----------- Source/UBCS/ubcs-service-api/ubcs-applyjtcodeservice-api/src/main/java/com/vci/ubcs/code/applyjtcodeservice/feign/IMdmInterJtClient.java | 11 + Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/code/dto/CodeAndGroupCodeAttrRnageDTO.java | 30 +++ Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/code/vo/webserviceModel/attrmap/标准系列申请.json | 0 Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/code/dto/CodeAndGroupCodeAttrMappingDTO.java | 50 ++++++ Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/controller/MdmEngineController.java | 4 Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/code/vo/webserviceModel/attrmap/标准修订(跨年).json | 0 Source/UBCS/ubcs-service/ubcs-applyjtcodeservice/src/main/java/com/vci/ubcs/code/applyjtcodeservice/feigh/MdmInterJtClient.java | 22 ++ 12 files changed, 327 insertions(+), 98 deletions(-) diff --git a/Source/UBCS/ubcs-service-api/ubcs-applyjtcodeservice-api/src/main/java/com/vci/ubcs/code/applyjtcodeservice/feign/IMdmInterJtClient.java b/Source/UBCS/ubcs-service-api/ubcs-applyjtcodeservice-api/src/main/java/com/vci/ubcs/code/applyjtcodeservice/feign/IMdmInterJtClient.java index 42920c9..ddf5d0c 100644 --- a/Source/UBCS/ubcs-service-api/ubcs-applyjtcodeservice-api/src/main/java/com/vci/ubcs/code/applyjtcodeservice/feign/IMdmInterJtClient.java +++ b/Source/UBCS/ubcs-service-api/ubcs-applyjtcodeservice-api/src/main/java/com/vci/ubcs/code/applyjtcodeservice/feign/IMdmInterJtClient.java @@ -2,12 +2,15 @@ import com.vci.ubcs.code.applyjtcodeservice.vo.DockingClassifyModelAttrVO; +import com.vci.ubcs.code.applyjtcodeservice.vo.DockingPreAttrMappingVO; import com.vci.ubcs.code.applyjtcodeservice.vo.DockingReturnStoreVO; import org.springblade.core.tool.api.R; import org.springframework.cloud.openfeign.FeignClient; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestParam; + +import java.util.List; /**** @@ -24,6 +27,7 @@ String RETURNGROUPCODE = API_PREFIX + "/getApplyGroupCode"; String PUBMDMMODEL = API_PREFIX + "/pubMdmModel"; String RECEIVE_EDITAPPLY =API_PREFIX + "/receiveEditApply"; + String LIST_MAPPING=API_PREFIX + "/listMapping"; /*** * 灏嗛泦鍥㈢敵璇锋垚鍔熺殑缂栫爜瀛樺叆鐩稿叧鏁版嵁涔嬩腑 @@ -34,6 +38,13 @@ @GetMapping(APPLYGROUPCODE) public R applyGroupCode(@RequestParam("oids")String oids,@RequestParam("btmName")String btmName); + /*** + * + * @param codeClassifyOid + * @return + */ + @GetMapping(LIST_MAPPING) + public R<List<DockingPreAttrMappingVO>> list_mapping(@RequestParam("codeClassifyOid")String codeClassifyOid); /*** * 闆嗗洟缂栫爜鏁版嵁淇敼 diff --git a/Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/code/dto/CodeAndGroupCodeAttrMappingDTO.java b/Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/code/dto/CodeAndGroupCodeAttrMappingDTO.java new file mode 100644 index 0000000..cc86306 --- /dev/null +++ b/Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/code/dto/CodeAndGroupCodeAttrMappingDTO.java @@ -0,0 +1,50 @@ +package com.vci.ubcs.code.dto; + +import lombok.Data; + +import java.util.ArrayList; +import java.util.List; + +/*** + * 闆嗗洟鍩熷睘鎬ф槧灏勫叧绯� + */ +@Data +public class CodeAndGroupCodeAttrMappingDTO { + + /*** + * 榛樿鍊� + */ + private String defaultValue; + /*** + *灞炴�d + */ + private String metaListId; + + /*** + * 婧愬睘鎬у唴閮ㄥ悕绉� + */ + private String sourceAttrKey; + + /*** + * 婧愬睘鎬у悕绉� + */ + private String sourceAttrName; + + /** + * 鐩爣灞炴�id + */ + private String targetAttrId; + + /*** + * 鐩爣灞炴�у唴閮ㄥ悕绉� + */ + private String targetAttrKey; + + /*** + * 鐩爣灞炴�у悕绉� + */ + private String targetAttrName; + + List<CodeAndGroupCodeAttrRnageDTO> codeAndGroupCodeAttrRnageDTOList; + +} diff --git a/Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/code/dto/CodeAndGroupCodeAttrRnageDTO.java b/Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/code/dto/CodeAndGroupCodeAttrRnageDTO.java new file mode 100644 index 0000000..f1818c2 --- /dev/null +++ b/Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/code/dto/CodeAndGroupCodeAttrRnageDTO.java @@ -0,0 +1,30 @@ +package com.vci.ubcs.code.dto; + +import lombok.Data; + +@Data +public class CodeAndGroupCodeAttrRnageDTO { + + /*** + *灞炴�d + */ + private String metaListId; + + /** + * 灞炴�ф灇涓炬樉绀哄悕绉� + */ + private String numText; + /** + * 灞炴�ф灇涓惧唴閮ㄥ悕绉� + */ + private String numTextValue; + + /** + * 婧愬睘鎬ф灇涓炬樉绀哄悕绉� + */ + private String targetNumText; + /** + * 婧愬睘鎬ф灇涓惧唴閮ㄥ悕绉� + */ + private String targetNumTextValue; +} diff --git a/Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/code/dto/ExecGroupCodePortDataDTO.java b/Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/code/dto/ExecGroupCodePortDataDTO.java new file mode 100644 index 0000000..451b70f --- /dev/null +++ b/Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/code/dto/ExecGroupCodePortDataDTO.java @@ -0,0 +1,32 @@ +package com.vci.ubcs.code.dto; + +import lombok.Data; + +import java.util.ArrayList; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; + +@Data +public class ExecGroupCodePortDataDTO { + /*** + * sheet鍚嶇О + */ + private String sheetName; + /*** + * 鍘熷瀛楁 + */ + private LinkedList<String> fieldList=new LinkedList<>(); + /** + * 鏁版嵁闆嗘垚 + */ + private List<Map<String,String>> dataList=new ArrayList<>(); + /*** + * 鍒楀悕 + */ + private LinkedList<String> colName=new LinkedList<>(); + /*** + * 闆嗗洟灞炴�т笌缂栫爜灞炴�ф槧灏勫叧绯� + */ + private List<CodeAndGroupCodeAttrMappingDTO> codeAttrMapGroupAttrDTOS=new ArrayList<>(); +} diff --git "a/Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/code/vo/webserviceModel/attrmap/\346\240\207\345\207\206\344\277\256\350\256\242\346\234\210\344\273\275\345\244\247\344\272\2161\347\232\204.json" "b/Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/code/vo/webserviceModel/attrmap/\346\240\207\345\207\206\344\277\256\350\256\242\050\350\267\250\345\271\264\051.json" similarity index 100% rename from "Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/code/vo/webserviceModel/attrmap/\346\240\207\345\207\206\344\277\256\350\256\242\346\234\210\344\273\275\345\244\247\344\272\2161\347\232\204.json" rename to "Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/code/vo/webserviceModel/attrmap/\346\240\207\345\207\206\344\277\256\350\256\242\050\350\267\250\345\271\264\051.json" diff --git "a/Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/code/vo/webserviceModel/attrmap/\347\263\273\345\210\227\346\265\201\346\260\264\347\224\263\350\257\267\345\244\247\344\272\2161.json" "b/Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/code/vo/webserviceModel/attrmap/\346\240\207\345\207\206\347\263\273\345\210\227\344\277\256\350\256\242\357\274\210\350\267\250\345\271\264\357\274\211.json" similarity index 100% rename from "Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/code/vo/webserviceModel/attrmap/\347\263\273\345\210\227\346\265\201\346\260\264\347\224\263\350\257\267\345\244\247\344\272\2161.json" rename to "Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/code/vo/webserviceModel/attrmap/\346\240\207\345\207\206\347\263\273\345\210\227\344\277\256\350\256\242\357\274\210\350\267\250\345\271\264\357\274\211.json" diff --git "a/Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/code/vo/webserviceModel/attrmap/\347\263\273\345\210\227\346\265\201\346\260\264.json" "b/Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/code/vo/webserviceModel/attrmap/\346\240\207\345\207\206\347\263\273\345\210\227\347\224\263\350\257\267.json" similarity index 100% rename from "Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/code/vo/webserviceModel/attrmap/\347\263\273\345\210\227\346\265\201\346\260\264.json" rename to "Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/code/vo/webserviceModel/attrmap/\346\240\207\345\207\206\347\263\273\345\210\227\347\224\263\350\257\267.json" diff --git a/Source/UBCS/ubcs-service/ubcs-applyjtcodeservice/src/main/java/com/vci/ubcs/code/applyjtcodeservice/feigh/MdmInterJtClient.java b/Source/UBCS/ubcs-service/ubcs-applyjtcodeservice/src/main/java/com/vci/ubcs/code/applyjtcodeservice/feigh/MdmInterJtClient.java index 0924909..42e4177 100644 --- a/Source/UBCS/ubcs-service/ubcs-applyjtcodeservice/src/main/java/com/vci/ubcs/code/applyjtcodeservice/feigh/MdmInterJtClient.java +++ b/Source/UBCS/ubcs-service/ubcs-applyjtcodeservice/src/main/java/com/vci/ubcs/code/applyjtcodeservice/feigh/MdmInterJtClient.java @@ -56,8 +56,10 @@ * 闆嗗洟鍒嗙被鐢宠鍗曟湇鍔� */ private final IDockingPreClassifyService dockingPreClassifyService; - - + /*** + * 灞炴�ф槧灏勬湇鍔� + */ + private final IDockingPreAttrMappingService dockingPreAttrMappingService; /** * 闆嗗洟鍙栧�艰寖鍥寸敵璇峰崟鏈嶅姟 */ @@ -81,6 +83,22 @@ return R.fail("闆嗗洟鐮佺敵璇峰け璐ワ細"+e.getMessage()); } } + + /*** + * 鏌ヨ闆嗗洟灞炴�ф槧灏� + * @param codeClassifyOid:缂栫爜鍒嗙被oid + * @return + */ + @Override + public R<List<DockingPreAttrMappingVO>> list_mapping(String codeClassifyOid) { + List<DockingPreAttrMapping> dockingPreAttrMappings= dockingPreAttrMappingService.selectByWrapper(Wrappers.<DockingPreAttrMapping>query().lambda().eq(DockingPreAttrMapping::getTargetClassifyId,codeClassifyOid)); + List<DockingPreAttrMappingVO> dockingPreAttrMappingVOList=new ArrayList<>(); + if(!CollectionUtils.isEmpty(dockingPreAttrMappings)){ + dockingPreAttrMappingVOList=dockingPreAttrMappingService.dockingPreAttrMappingDO2VOS(dockingPreAttrMappings,true); + } + return R.data(dockingPreAttrMappingVOList); + } + /*** * 鐢宠闆嗗洟缂栫爜鏁版嵁缁存姢 * @return diff --git a/Source/UBCS/ubcs-service/ubcs-applyjtcodeservice/src/main/java/com/vci/ubcs/code/applyjtcodeservice/service/IDockingPreAttrMappingService.java b/Source/UBCS/ubcs-service/ubcs-applyjtcodeservice/src/main/java/com/vci/ubcs/code/applyjtcodeservice/service/IDockingPreAttrMappingService.java index 28a6f73..b28d66d 100644 --- a/Source/UBCS/ubcs-service/ubcs-applyjtcodeservice/src/main/java/com/vci/ubcs/code/applyjtcodeservice/service/IDockingPreAttrMappingService.java +++ b/Source/UBCS/ubcs-service/ubcs-applyjtcodeservice/src/main/java/com/vci/ubcs/code/applyjtcodeservice/service/IDockingPreAttrMappingService.java @@ -8,6 +8,7 @@ import com.vci.ubcs.starter.exception.VciBaseException; import org.springblade.core.tool.api.R; +import java.util.Collection; import java.util.List; /** @@ -51,4 +52,12 @@ * @return */ public R search(DokingAttributeSerchVO dokingAttributeSerchVO); + + /*** + * 杞崲闆嗗洟灞炴�ф槧灏勯厤缃� + * @param dockingPreAttrMappings + * @param contain 鏄惁鏌ュ巻鍙叉暟鎹� + * @return + */ + List<DockingPreAttrMappingVO> dockingPreAttrMappingDO2VOS(Collection<DockingPreAttrMapping> dockingPreAttrMappings, boolean contain); } diff --git a/Source/UBCS/ubcs-service/ubcs-applyjtcodeservice/src/main/java/com/vci/ubcs/code/applyjtcodeservice/service/impl/DockingPreAttrMappingServiceImpl.java b/Source/UBCS/ubcs-service/ubcs-applyjtcodeservice/src/main/java/com/vci/ubcs/code/applyjtcodeservice/service/impl/DockingPreAttrMappingServiceImpl.java index 86a2b9b..0711970 100644 --- a/Source/UBCS/ubcs-service/ubcs-applyjtcodeservice/src/main/java/com/vci/ubcs/code/applyjtcodeservice/service/impl/DockingPreAttrMappingServiceImpl.java +++ b/Source/UBCS/ubcs-service/ubcs-applyjtcodeservice/src/main/java/com/vci/ubcs/code/applyjtcodeservice/service/impl/DockingPreAttrMappingServiceImpl.java @@ -242,7 +242,8 @@ * @param dockingPreAttrMappings * @return */ - private List<DockingPreAttrMappingVO> dockingPreAttrMappingDO2VOS(Collection<DockingPreAttrMapping> dockingPreAttrMappings,boolean contain) { + @Override + public List<DockingPreAttrMappingVO> dockingPreAttrMappingDO2VOS(Collection<DockingPreAttrMapping> dockingPreAttrMappings,boolean contain) { List<DockingPreAttrMappingVO> dockingPreAttrMappingVOList=new ArrayList<>(); dockingPreAttrMappingVOList=DockingPreAttrMappingWrapper.build().entityVOs(dockingPreAttrMappings); if(CollectionUtils.isEmpty(dockingPreAttrMappingVOList)){ diff --git a/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/controller/MdmEngineController.java b/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/controller/MdmEngineController.java index db787cb..2dac4c4 100644 --- a/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/controller/MdmEngineController.java +++ b/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/controller/MdmEngineController.java @@ -779,9 +779,9 @@ @GetMapping("/exportGroupCodeExcel") @VciBusinessLog(operateName = "瀵煎嚭闆嗗洟鐮�") public void exportGroupCodeExcel(String codeClassifyOid, HttpServletResponse response) throws IOException{ - String excelName = mdmIOService.exportGroupCodeExcel(codeClassifyOid); + try { - ControllerUtil.writeFileToResponse(response,excelName); + String excelName = mdmIOService.exportGroupCodeExcel(codeClassifyOid); } catch (Throwable e) { //濡傛灉鍑洪敊,鎶婇敊璇俊鎭啓鍒皌ext String msg = LangBaseUtil.getErrorMsg(e); diff --git a/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/MdmIOServiceImpl.java b/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/MdmIOServiceImpl.java index 96383b7..e19dc23 100644 --- a/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/MdmIOServiceImpl.java +++ b/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/MdmIOServiceImpl.java @@ -5,12 +5,14 @@ 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.entity.DockingPreAttrMapping; import com.vci.ubcs.code.applyjtcodeservice.feign.IMdmInterJtClient; +import com.vci.ubcs.code.applyjtcodeservice.vo.DockingPreAttrMappingVO; import com.vci.ubcs.code.bo.AttributeValue; import com.vci.ubcs.code.bo.CodeClassifyFullInfoBO; import com.vci.ubcs.code.bo.CodeTemplateAttrSqlBO; -import com.vci.ubcs.code.dto.CodeExportAttrDTO; -import com.vci.ubcs.code.dto.CodeOrderDTO; +import com.vci.ubcs.code.constant.MdmEngineConstant; +import com.vci.ubcs.code.dto.*; import com.vci.ubcs.code.entity.CodeAllCode; import com.vci.ubcs.code.enumpack.CodeDefaultLC; import com.vci.ubcs.code.enumpack.CodeLevelTypeEnum; @@ -4611,106 +4613,182 @@ */ @Override public String exportGroupCodeExcel(String codeClassifyOid) { - List<CodeClassifyTemplateVO> templateVOList=new ArrayList<>(); - VciBaseUtil.alertNotNull("瀵煎嚭妯℃澘","瀵煎嚭鐨勯厤缃�",codeClassifyOid,"涓婚搴撳垎绫荤殑涓婚敭"); - CodeClassifyVO codeClassifyVO = classifyService.getObjectByOid(codeClassifyOid); - //鎵炬ā鏉� + VciBaseUtil.alertNotNull(codeClassifyOid,"涓婚搴撳垎绫荤殑涓婚敭"); + CodeClassifyFullInfoBO classifyFullInfo = classifyService.getClassifyFullInfo(codeClassifyOid); + CodeClassifyVO codeClassifyVO= classifyFullInfo.getCurrentClassifyVO(); + //鑾峰彇鏈�鏂扮殑妯℃澘 CodeClassifyTemplateVO templateVO = engineService.getUsedTemplateByClassifyOid(codeClassifyOid); - templateVOList.add(templateVO); - WriteExcelOption eo = new WriteExcelOption(); - eo.setAppend(true); + LinkedList<String> colName=new LinkedList<>();//鍒楀ご + LinkedList<String> fieldList=new LinkedList<>();//鍒楀瓧娈� + + ExecGroupCodePortDataDTO execGroupCodePortDataDTO=new ExecGroupCodePortDataDTO(); + createExportGroupCodeMapConfig(templateVO,execGroupCodePortDataDTO);//缁勭粐鏁版嵁 + fieldList=execGroupCodePortDataDTO.getFieldList(); + List<Map<String,String>>dataList=new ArrayList<>(); + getDatas(classifyFullInfo,templateVO,fieldList,dataList); + execGroupCodePortDataDTO.setDataList(dataList);//鏀炬暟鎹� + execGroupCodePortDataDTO.setSheetName(codeClassifyVO.getName()+"闆嗗洟鐮佸鍏ユā鏉�"); + String tempFolder = LocalFileUtil.getDefaultTempFolder(); + String excelName = tempFolder + File.separator + + classifyFullInfo.getCurrentClassifyVO().getId() + "_" + classifyFullInfo.getCurrentClassifyVO().getName() + "_闆嗗洟鐮佸鍑烘ā鏉�.xls"; + try { + new File(excelName).createNewFile(); + } catch (Throwable e) { + throw new VciBaseException(LangBaseUtil.getErrorMsg(e), new String[]{excelName}, e); + } + LinkedList<String> finalFieldList = fieldList; + Map<String, CodeClassifyTemplateAttrVO> attrVOMap = templateVO.getAttributes().stream().filter(s-> finalFieldList.contains(s.getId().toLowerCase(Locale.ROOT))).collect(Collectors.toMap(s -> s.getId().toLowerCase(Locale.ROOT), t -> t)); + List<WriteExcelData> excelDataList = new ArrayList<>(); + Workbook workbook = new HSSFWorkbook(); + List<CodeAndGroupCodeAttrMappingDTO> codeAndGroupCodeAttrMappingDTOList= execGroupCodePortDataDTO.getCodeAttrMapGroupAttrDTOS(); + + Map<String, CodeAndGroupCodeAttrMappingDTO> jAttrVOMap = codeAndGroupCodeAttrMappingDTOList.stream().filter(s-> finalFieldList.contains(s.getTargetAttrKey().toLowerCase(Locale.ROOT))).collect(Collectors.toMap(s -> s.getTargetAttrKey().toLowerCase(Locale.ROOT), t -> t)); + + WriteExcelData codeExcelData = new WriteExcelData(0, 0, "浼佷笟缂栫爜"); + WriteExcelData groupExcelData = new WriteExcelData(0, 1, "闆嗗洟鐮�"); + excelDataList.add(codeExcelData); + excelDataList.add(groupExcelData); + for (int i = 0; i < fieldList.size(); i++) { + String attrId=fieldList.get(i); + if(attrId.equals(CODE_FIELD)||attrId.equals(CODE_GROUP_FIELD)){ + continue; + } + if (attrVOMap.containsKey(attrId)) { + CodeClassifyTemplateAttrVO attrVO = attrVOMap.get(attrId); + //Object text = attrVO.getName(); + CodeAndGroupCodeAttrMappingDTO codeAttrMappingDTO = jAttrVOMap.get(attrId); + Object text = codeAttrMappingDTO.getSourceAttrName(); + text = exportKeyAndRequired(workbook, attrVO, text); + WriteExcelData excelData = new WriteExcelData(0, i, text); + if (text instanceof RichTextString) { + excelData.setFontColor(String.valueOf(HSSFColor.HSSFColorPredefined.RED.getIndex())); + } + excelDataList.add(excelData); + } + } + final Integer[] rowIndex = {0}; + dataList.stream().forEach(data -> { + rowIndex[0]++; + String id=data.getOrDefault("id", ""); + excelDataList.add(new WriteExcelData(rowIndex[0], 0, id)); + String groupCode=data.getOrDefault("groupcode", ""); + excelDataList.add(new WriteExcelData(rowIndex[0], 1, groupCode)); + List<String> newFieldList = finalFieldList.stream().filter(e -> !e.equals("id") &&!e.equals("groupcode")).collect(Collectors.toList()); + + for (int i = 0; i < newFieldList.size(); i++) { + String attrId = newFieldList.get(i).toLowerCase(Locale.ROOT); + if(attrId.equals("id")){ + + }else if(attrId.equals("groupcode")){ + + }else{ + if (attrVOMap.containsKey(attrId)) { + CodeClassifyTemplateAttrVO attrVO = attrVOMap.get(attrId); + if (StringUtils.isNotBlank(attrVO.getEnumId()) || StringUtils.isNotBlank(attrVO.getEnumString())) { + attrId = attrId + "Text"; + } + if (StringUtils.isNotBlank(attrVO.getReferBtmId()) || StringUtils.isNotBlank(attrVO.getReferConfig())) { + attrId = attrId + "name"; + } + if (VciQueryWrapperForDO.LC_STATUS_FIELD.equalsIgnoreCase(attrId)) { + attrId = VciQueryWrapperForDO.LC_STATUS_FIELD_TEXT.toLowerCase(Locale.ROOT); + } + excelDataList.add(new WriteExcelData(rowIndex[0], i+2, data.getOrDefault(attrId, ""))); + } + } + } + }); + WriteExcelOption excelOption = new WriteExcelOption(); + excelOption.addSheetDataList(execGroupCodePortDataDTO.getSheetName(),excelDataList); + //澧炲姞妯℃澘鐨勪俊鎭鍏� LinkedList<WriteExcelData> tempEDList = new LinkedList<>(); tempEDList.add(new WriteExcelData(0,0,"妯℃澘涓婚敭")); tempEDList.add(new WriteExcelData(0,1,"妯℃澘浠e彿")); tempEDList.add(new WriteExcelData(0,2,"妯℃澘鍚嶇О")); - CodeClassifyTemplateVO codeClassifyTemplateVO = new CodeClassifyTemplateVO(); - BeanUtils.copyProperties(templateVO,codeClassifyTemplateVO); - //缁勫悎鏍煎紡鐨勪笉瀵煎叆锛� - // 鏋氫妇鐨勬彁渚涘簭鍒楃殑閫夋嫨 - //鏃堕棿鍏ㄩ儴缁熶竴涓簓yyy-MM-dd HH:mm:ss - //鍙傜収鐨勮嚜琛岃緭鍏ュ悕绉� - //鍒嗙被娉ㄥ叆鐨勪笉鐢紝閮芥槸瀵煎叆鍚庤嚜鍔ㄥ鐞嗙殑 - //缂栫爜锛岀姸鎬佺瓑瀛楁涓嶅鍏� - List<CodeClassifyTemplateAttrVO> codeClassifyTemplateAttrVOList=codeClassifyTemplateVO.getAttributes(); - if(!CollectionUtils.isEmpty(codeClassifyTemplateAttrVOList)) { - if (CollectionUtils.isEmpty(codeClassifyTemplateAttrVOList)) { - throw new VciBaseException("妯℃澘娌℃湁閰嶇疆灞炴��"); - } - } - List<CodeClassifyTemplateAttrVO> templateAttrVOS = codeClassifyTemplateAttrVOList.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("妯℃澘娌℃湁閰嶇疆浠讳綍銆愯〃鍗曟樉绀恒�戜负銆愭槸銆戠殑灞炴��"); - } - List<CodeClassifyTemplateAttrVO> idAttrVOList = codeClassifyTemplateVO.getAttributes().stream().filter(s -> s.getId().equalsIgnoreCase(CODE_FIELD)).collect(Collectors.toList()); - LinkedList<WriteExcelData> excelDataList = new LinkedList<>(); - Workbook workbook = new HSSFWorkbook(); - excelDataList.add(new WriteExcelData(0,0,!CollectionUtils.isEmpty(idAttrVOList)?idAttrVOList.get(0).getName():"浼佷笟缂栫爜",idAttrVOList.get(0).getId())); - excelDataList.add(new WriteExcelData(0,1,"闆嗗洟鐮�","")); - for (int i = 0; i < templateAttrVOS.size(); i++) { - CodeClassifyTemplateAttrVO attrVO = templateAttrVOS.get(i); - - Object text = attrVO.getName(); - text = exportKeyAndRequired(workbook, attrVO, text); - int colIndex = 2 + i; - 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()) - || VciFieldTypeEnum.VTTime.name().equalsIgnoreCase(attrVO.getAttributeDataType())) { - excelData.setDateFormat(VciDateUtil.DateTimeFormat); - } - if (text instanceof RichTextString) { - excelData.setFontColor(String.valueOf(HSSFColor.HSSFColorPredefined.RED.getIndex())); - } - excelDataList.add(excelData); - if (StringUtils.isNotBlank(attrVO.getEnumString()) || StringUtils.isNotBlank(attrVO.getEnumId())) { - //娣诲姞鏁版嵁鏈夋晥鎬� - List<String> enumValueList = new ArrayList<>(); - enumValueList.add(""); - List<KeyValue> valueList = engineService.listComboboxItems(attrVO); - if (!CollectionUtils.isEmpty(valueList)) { - valueList.stream().forEach(kv -> { - enumValueList.add(kv.getValue()); - }); - } - //榛樿鍔�1涓囨潯 - WriteExcelData ed = new WriteExcelData(1, colIndex, ""); - ed.setRowTo(100); - ed.setColTo(colIndex); - ed.setValidation(true); - ed.setValidationDataList(enumValueList); - ed.setValidationErrorMsg("璇峰湪搴忓垪涓�夋嫨姝g‘鐨勫��"); - excelDataList.add(ed); - } - if (VciFieldTypeEnum.VTBoolean.name().equalsIgnoreCase(attrVO.getAttributeDataType())) { - List<String> booleanList = new ArrayList<>(); - - booleanList.add("鏄�"); - booleanList.add("鍚�"); - //榛樿鍔�1涓囨潯 - WriteExcelData ed = new WriteExcelData(1, colIndex, ""); - ed.setRowTo(100); - ed.setColTo(colIndex); - ed.setValidation(true); - ed.setValidationDataList(booleanList); - ed.setValidationErrorMsg("璇峰湪搴忓垪涓�夋嫨姝g‘鐨勫��"); - excelDataList.add(ed); - } - } - eo.addSheetDataList(templateVO.getName(),excelDataList); tempEDList.add(new WriteExcelData(1,0,templateVO.getOid())); tempEDList.add(new WriteExcelData(1,1,templateVO.getId())); tempEDList.add(new WriteExcelData(1,2,templateVO.getName())); - String excelName = LocalFileUtil.getDefaultTempFolder() + File.separator + codeClassifyVO.getName() + "闆嗗洟鐮乢瀵煎叆妯℃澘.xls"; - eo.addSheetDataList(templateVOList.size()+"妯℃澘淇℃伅銆愯鍕垮垹闄ゆ垨绉诲姩銆�",tempEDList); - ExcelUtil.writeDataToFile(excelName,eo); + excelOption.addSheetDataList("妯℃澘淇℃伅銆愯鍕垮垹闄ゆ垨绉诲姩銆�",tempEDList); + ExcelUtil.writeDataToFile(excelName, excelOption); + log.info("鏂囦欢璺緞"+excelName); return excelName; } + /*** + * + */ + private void createExportGroupCodeMapConfig(CodeClassifyTemplateVO templateVO,ExecGroupCodePortDataDTO execGroupCodePortDataDTO){ + String classOid=templateVO.getCodeclassifyoid(); + String templateOid=templateVO.getOid(); + R r=mdmInterJtClient.list_mapping(classOid); + if(r.isSuccess()){ + List<DockingPreAttrMappingVO>dockingPreAttrMappingVOList= (List<DockingPreAttrMappingVO>) r.getData(); + List<CodeAndGroupCodeAttrMappingDTO> codeAttrMapGroupAttrDTOS=new ArrayList<>(); + LinkedList<String> fieldList=new LinkedList<>(); + LinkedList<String> colNameList=new LinkedList<>(); + dockingPreAttrMappingVOList.stream().forEach(dockingPreAttrMappingVO -> { + CodeAndGroupCodeAttrMappingDTO codeAndGroupCodeAttrMappingDTO=new CodeAndGroupCodeAttrMappingDTO(); + if(StringUtils.isNotBlank(dockingPreAttrMappingVO.getTargetAttrId())){ + codeAndGroupCodeAttrMappingDTO.setDefaultValue(dockingPreAttrMappingVO.getDefaultValue()); + codeAndGroupCodeAttrMappingDTO.setMetaListId(dockingPreAttrMappingVO.getMetaListId()); + codeAndGroupCodeAttrMappingDTO.setSourceAttrKey(dockingPreAttrMappingVO.getSourceAttrKey()); + codeAndGroupCodeAttrMappingDTO.setSourceAttrName(dockingPreAttrMappingVO.getSourceAttrName()); + codeAndGroupCodeAttrMappingDTO.setTargetAttrId(dockingPreAttrMappingVO.getTargetAttrId()); + codeAndGroupCodeAttrMappingDTO.setTargetAttrKey(dockingPreAttrMappingVO.getTargetAttrKey()); + codeAndGroupCodeAttrMappingDTO.setTargetAttrName(dockingPreAttrMappingVO.getTargetAttrName()); + fieldList.add(dockingPreAttrMappingVO.getTargetAttrKey()); + colNameList.add(dockingPreAttrMappingVO.getSourceAttrName()); + } + codeAttrMapGroupAttrDTOS.add(codeAndGroupCodeAttrMappingDTO); + }); + execGroupCodePortDataDTO.setCodeAttrMapGroupAttrDTOS(codeAttrMapGroupAttrDTOS); + execGroupCodePortDataDTO.setFieldList(fieldList); + execGroupCodePortDataDTO.setColName(colNameList); + } + } + /*** + * 鏌ヨ鏁版嵁 + * @param classifyFullInfo + * @param templateVO + */ + private void getDatas(CodeClassifyFullInfoBO classifyFullInfo,CodeClassifyTemplateVO templateVO,LinkedList<String> selectFieldList,List<Map<String,String>>dataList){ + + //鍏堟煡璇㈡暟鎹� + String btmTypeId = classifyFullInfo.getTopClassifyVO().getBtmTypeId(); + String codeClassifyOid=classifyFullInfo.getCurrentClassifyVO().getOid(); + Map<String, String> conditionMap = new HashMap<>(); + if(conditionMap == null){ + conditionMap = new HashMap<>(); + } + if(conditionMap.containsKey(VciQueryWrapperForDO.OID_FIELD)){ + conditionMap.put(VciQueryWrapperForDO.OID_FIELD,QueryOptionConstant.IN + "(" + VciBaseUtil.toInSql(conditionMap.get(VciQueryWrapperForDO.OID_FIELD)) + ")"); + } + conditionMap.put("codeclsfpath","*" + codeClassifyOid + "*"); + conditionMap.put("groupcode_null", "null"); + 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); + } + PageHelper pageHelper = new PageHelper(); + pageHelper.setLimit(1000000); + pageHelper.setPage(1); + pageHelper.addDefaultDesc("createTime"); + DataGrid<Map<String, String>> dataGrid = engineService.queryGrid(btmTypeId, templateVO, conditionMap, pageHelper); + //杞崲鏁版嵁 + if(!CollectionUtils.isEmpty(dataGrid.getData())){ + dataList.addAll(dataGrid.getData()); + } + //灏佽鏌ヨ鍑烘潵鐨勬暟鎹� + engineService.wrapperData(dataList, templateVO, selectFieldList,false); + //modify by weidy@2022-09-27 + //鍥犱负鍦ㄥ垪琛ㄥ拰琛ㄥ崟鐨勬樉绀虹殑鏃跺�欙紝鎴戜滑鐨勫紑鍏崇被鍨嬮〉闈細澶勭悊锛屼絾鏄湪瀵煎嚭鐨勬椂鍊欙紝鎴戜滑闇�瑕佸皢true鍜宖alse閮芥浛鎹㈡垚涓枃 + engineService.wrapperBoolean(dataList,templateVO); + log.info("瀵煎嚭妯℃澘鐨勬暟鎹潯鐩暟:"+dataList.size()); + } } -- Gitblit v1.9.3