From 2a64b537e8e3bce9ce030585a3da17d48379c0ad Mon Sep 17 00:00:00 2001 From: sfd <sun.sunshine@163.com> Date: 星期一, 26 五月 2025 15:04:45 +0800 Subject: [PATCH] 修改json类型转换错误 --- aps-modules/aps-core/src/main/java/com/aps/core/service/impl/ApsPlate/ApsPlateProcessShopStatServiceImpl.java | 438 ++++++++++++++++++++++------------------------------- 1 files changed, 183 insertions(+), 255 deletions(-) diff --git a/aps-modules/aps-core/src/main/java/com/aps/core/service/impl/ApsPlate/ApsPlateProcessShopStatServiceImpl.java b/aps-modules/aps-core/src/main/java/com/aps/core/service/impl/ApsPlate/ApsPlateProcessShopStatServiceImpl.java index 6da9ad7..b492865 100644 --- a/aps-modules/aps-core/src/main/java/com/aps/core/service/impl/ApsPlate/ApsPlateProcessShopStatServiceImpl.java +++ b/aps-modules/aps-core/src/main/java/com/aps/core/service/impl/ApsPlate/ApsPlateProcessShopStatServiceImpl.java @@ -2,11 +2,15 @@ import java.text.SimpleDateFormat; import java.util.*; +import java.util.concurrent.atomic.AtomicInteger; import java.util.stream.Collectors; +import cn.hutool.core.collection.ListUtil; +import cn.hutool.core.util.IdUtil; import com.alibaba.fastjson.JSONObject; +import com.alibaba.fastjson2.JSON; +import com.alibaba.nacos.common.utils.JacksonUtils; import com.aps.common.core.utils.DateUtils; -import com.aps.common.core.utils.bean.BeanUtils; import com.aps.common.core.web.domain.AjaxResult; import com.aps.common.security.utils.DictUtils; import com.aps.common.security.utils.SecurityUtils; @@ -16,9 +20,14 @@ import com.aps.core.domain.ApsPlate.ApsPlateProcessShopStat; import com.aps.core.domain.ApsPlate.ApsPlateProcessStat; import com.aps.core.mapper.*; +import com.aps.core.service.ApsPlate.IApsPlateProcessStatService; import com.aps.system.api.domain.SysDictData; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.node.ObjectNode; import jakarta.annotation.Resource; import jakarta.servlet.http.HttpServletResponse; +import lombok.AllArgsConstructor; +import lombok.Data; import lombok.extern.slf4j.Slf4j; import org.apache.poi.ss.usermodel.*; import org.apache.poi.util.IOUtils; @@ -53,6 +62,9 @@ @Resource private ApsPlatePlanMapper apsPlatePlanMapper; + @Autowired + private IApsPlateProcessStatService apsPlateProcessStatService; + /** @@ -126,61 +138,73 @@ /** * 淇濆瓨閽i噾杞﹂棿缁熻 */ - @Transactional + @Transactional( rollbackFor =Exception.class) @Override public void saveShopStat() { - try { - // 寮�濮嬩箣鍓嶅厛鍒犻櫎鎵�鏈夊巻鍙叉暟鎹� + // 瀹氫箟璇ュ姛鑳戒娇鐢ㄦ暟鎹簮涓哄崡閫氱殑宸ュ巶 + final String plant = "FORTUNA"; + final String major="BJ"; + // 鏌ヨ鐩稿叧鏁版嵁 + ApsPlatePlan platePlan = new ApsPlatePlan(); + platePlan.setPlant(plant); + log.info("寮�濮嬫墽琛岄挘閲戣鍒掑ぇ琛�"); + List<ApsPlatePlan> planList = apsPlatePlanMapper.selectApsPlatePlanList(platePlan); + + ApsShop apsShop = new ApsShop(); + apsShop.setPlantCode(plant); + List<ApsShop> shopList = shopMapper.selectApsShopList(apsShop); + + ApsStandardProcess process = new ApsStandardProcess(); + process.setPlant(plant); + process.setMajor(major); + + List<ApsStandardProcess> shopProcesses = standardProcessMapper.selectApsStandardProcessList(process); + + if (!planList.isEmpty() && !shopList.isEmpty() && !shopProcesses.isEmpty()) { + + log.info("閽i噾璁″垝澶ц〃锛氬垹闄ゆ墍鏈夊巻鍙叉暟鎹�"); + apsPlateProcessStatMapper.deleteAll(); apsPlateProcessShopStatMapper.deleteAll(); - - // 瀹氫箟璇ュ姛鑳戒娇鐢ㄦ暟鎹簮涓哄崡閫氱殑宸ュ巶 - final String plant = "FORTUNA"; - final String major="閽i噾"; - // 鏌ヨ鐩稿叧鏁版嵁 - ApsPlatePlan platePlan = new ApsPlatePlan(); - platePlan.setPlant(plant); - List<ApsPlatePlan> planList = apsPlatePlanMapper.selectApsPlatePlanList(platePlan); - - List<ApsPlateProcessStat> statList = apsPlateProcessStatMapper.selectApsPlateProcessStatList(new ApsPlateProcessStat()); - - ApsShop apsShop = new ApsShop(); - apsShop.setPlantCode(plant); - List<ApsShop> shopList = shopMapper.selectApsShopList(apsShop); - - ApsStandardProcess process = new ApsStandardProcess(); - process.setPlant(plant); - process.setMajor(major); - List<ApsStandardProcess> shopProcesses = standardProcessMapper.selectApsStandardProcessList(process); - if (planList.isEmpty() || shopList.isEmpty() || shopProcesses.isEmpty()) { - log.warn("璁″垝鍒楄〃銆佽溅闂村垪琛ㄦ垨宸ュ簭鍒楄〃涓虹┖锛屾棤娉曠敓鎴愮粺璁′俊鎭�"); - return; - } - // 鏋勫缓杞﹂棿鍚嶇О鍒板伐搴忓悕绉扮殑鏄犲皠 - Map<String, List<String>> shopToProcessNames = shopProcesses.stream() + log.info("閽i噾璁″垝澶ц〃锛氭帹绠楀�掓帓閽i噾宸ュ簭璁″垝瀹屽伐鏃ユ湡鍜岃鍒掑紑宸ユ椂闂�"); + List<ApsPlateProcessStat> statList =apsPlateProcessStatService.computePlateProcessStat(); + // 鏋勫缓杞﹂棿鍚嶇О鍒板伐搴忓悕绉扮殑鏄犲皠 + Map<String, List<String>> shopToProcessNames = shopProcesses.stream().filter(x -> null!=x.getWorkShop()) .collect(Collectors.groupingBy(ApsStandardProcess::getWorkShop, Collectors.mapping(ApsStandardProcess::getProcessName, Collectors.toList()) )); // 鎵归噺鎻掑叆缁熻鏁版嵁 + log.info("閽i噾璁″垝澶ц〃锛氳绠楁瘡涓伐鍗曚腑姣忎釜杞﹂棿鐨勫紑濮嬨�佺粨鏉熸椂闂�"); List<ApsPlateProcessShopStat> statsToInsert = new ArrayList<>(); - for (ApsPlatePlan plan : planList) { - for (ApsShop shop : shopList) { + log.info("閽i噾璁″垝澶ц〃V1锛氬紑濮嬭绠楁瘡涓伐鍗曡溅闂村伐鏃�"); + planList.stream().parallel().forEach(plan -> { + shopList.stream().parallel().forEach(shop -> { ApsPlateProcessShopStat stat = createShopStat(plan, shop, shopToProcessNames, statList); statsToInsert.add(stat); - } + }); + }); + log.info("閽i噾璁″垝澶ц〃锛氭壒閲忎繚瀛樺伐搴忓紑宸ュ拰瀹屽伐鏃堕棿"); + List<List<ApsPlateProcessStat>> processStatBatchList = ListUtil.split(statList, 1000); + processStatBatchList.stream().parallel().forEach(batch -> apsPlateProcessStatMapper.batchInsertPlateStat(batch)); + + + log.info("閽i噾璁″垝澶ц〃锛氭壒閲忎繚瀛樺伐鍗�-杞﹂棿鏃堕棿淇℃伅"); + List<List<ApsPlateProcessShopStat>> shopStatBatchList = ListUtil.split(statsToInsert, 1000); + shopStatBatchList.stream().parallel().forEach(batch -> apsPlateProcessShopStatMapper.batchInsert(batch)); + }else { + if(shopProcesses.isEmpty()){ + log.error("閽i噾璁″垝澶ц〃锛氭湭鎵惧埌鏍囧噯宸ュ簭鏁版嵁锛�"); + throw new RuntimeException("鏈壘鍒版爣鍑嗗伐搴忔暟鎹紒"); } - // 鎵归噺鎻掑叆浠ユ彁楂樻�ц兘 - if (!statsToInsert.isEmpty()) { - int batchSize = 1000; - for (int i = 0; i < statsToInsert.size(); i += batchSize) { - int end = Math.min(i + batchSize, statsToInsert.size()); - List<ApsPlateProcessShopStat> batch = statsToInsert.subList(i, end); - apsPlateProcessShopStatMapper.batchInsert(batch); - } + if(shopList.isEmpty()){ + log.error("閽i噾璁″垝澶ц〃锛氭湭鎵惧埌杞﹂棿鏁版嵁锛�"); + throw new RuntimeException("鏈壘鍒拌溅闂存暟鎹紒"); } - } catch (Exception e) { - log.error("淇濆瓨閽i噾杞﹂棿缁熻鏃跺彂鐢熷紓甯�", e); - throw new RuntimeException("淇濆瓨閽i噾杞﹂棿缁熻澶辫触", e); + if(planList.isEmpty()){ + log.error("閽i噾璁″垝澶ц〃锛氭湭鎵惧埌宸ュ崟鏁版嵁锛�"); + throw new RuntimeException("鏈壘鍒板伐鍗曟暟鎹紒"); + } } + log.info("閽i噾璁″垝澶ц〃锛氬畬鎴�"); } /** @@ -199,7 +223,6 @@ stat.setWorkCenter(plan.getWorkCenter()); stat.setProcessNumber(plan.getProcessNumber()); try { - List<String> processNames = shopToProcessNames.getOrDefault(shopName, Collections.emptyList()); if (!processNames.isEmpty()) { @@ -241,7 +264,8 @@ } } } catch (Exception e) { - log.error("computer error:"+ JSONObject.toJSONString(stat)); + log.error("閽i噾璁″垝澶ц〃 error:"+ JSONObject.toJSONString(stat)); + throw new RuntimeException("璁$畻杞﹂棿缁熻鏁版嵁寮傚父锛�"); } return stat; } @@ -257,7 +281,7 @@ ApsShop apsShop = new ApsShop(); apsShop.setPlantCode(PLANT_CODE); - + apsShop.setStatus("1"); // 鑾峰彇杞﹂棿鍒楄〃骞跺鐞嗙┖鍊� List<String> shopList = Optional.ofNullable(shopMapper.selectApsShopList(apsShop)) .orElse(Collections.emptyList()) @@ -266,8 +290,7 @@ .toList(); // 鑾峰彇璁″垝鍒楄〃鍜岀姸鎬佸垪琛� - List<ApsPlatePlan> planList = Optional.ofNullable(apsPlatePlanMapper.selectApsPlatePlanList(platePlan)) - .orElse(Collections.emptyList()); + List<ApsPlateProcessShopPlanStat> planList = apsPlateProcessShopStatMapper.selectPlatePlanBaseTable(); List<ApsPlateProcessShopStat> shopStates = Optional.ofNullable(apsPlateProcessShopStatMapper.selectApsPlateProcessShopStatList(new ApsPlateProcessShopStat())) .orElse(Collections.emptyList()); @@ -281,26 +304,22 @@ List<SysDictData> documentStatusDic = DictUtils.getDictCache("aps_document_status"); // 鏋勫缓缁撴灉鍒楄〃 - List<ApsPlateProcessShopPlanStat> shopPlanStats = planList.stream() - .map(plan -> { - ApsPlateProcessShopPlanStat shopPlanStat = new ApsPlateProcessShopPlanStat(); - BeanUtils.copyProperties(plan, shopPlanStat); // 纭繚鐩爣瀵硅薄鏄悎娉曠殑鍗曚釜瀵硅薄瀹炰緥 - + planList.stream().parallel().forEach( + plan -> { // 鏍规嵁 docNo 鑾峰彇瀵瑰簲鐨� shopStatList List<ApsPlateProcessShopStat> shopStatList = shopStatesByDocNo.getOrDefault(plan.getDocumentNumber(), Collections.emptyList()); - shopPlanStat.setDeptPlans(shopStatList); + plan.setDeptPlans(shopStatList); if (businessTypeDic != null) { businessTypeDic.stream().filter(x -> x.getDictValue().equals(plan.getBusinessType())).findFirst() - .ifPresent(sysDictData -> shopPlanStat.setBusinessType(sysDictData.getDictLabel())); + .ifPresent(sysDictData -> plan.setBusinessType(sysDictData.getDictLabel())); } if (documentStatusDic != null) { documentStatusDic.stream().filter(x->x.getDictValue().equals(plan.getDocumentStatus())) - .findFirst().ifPresent(sysDictData -> shopPlanStat.setDocumentStatus(sysDictData.getDictLabel())); + .findFirst().ifPresent(sysDictData -> plan.setDocumentStatus(sysDictData.getDictLabel())); } - return shopPlanStat; - }).toList(); + }); // 鏋勫缓杩斿洖缁撴灉 - AjaxResult success = AjaxResult.success(shopPlanStats); + AjaxResult success = AjaxResult.success(planList); success.put("shopNames", shopList); return success; } @@ -314,7 +333,7 @@ response.setCharacterEncoding("utf-8"); Map<String, CellStyle> styles = createStyles(wb); - CellStyle title = styles.get("title"); + CellStyle titleStyle = styles.get("title"); try { @@ -324,222 +343,58 @@ SXSSFSheet sheet = wb.getSheetAt(0); /*濉啓鏃ユ湡鍒� 鍜� 宸ユ椂鍒�*/ SXSSFRow rowTitle = sheet.createRow(0); - SXSSFCell mainPartNumberTitle = rowTitle.createCell(0); - mainPartNumberTitle.setCellValue("涓讳欢鏂欏彿"); - mainPartNumberTitle.setCellStyle(title); - SXSSFCell businessTypeTitle = rowTitle.createCell(1); - businessTypeTitle.setCellValue("涓氬姟绫诲瀷"); - businessTypeTitle.setCellStyle(title); - - SXSSFCell documentNumberTitle = rowTitle.createCell(2); - documentNumberTitle.setCellValue("鍗曟嵁鍙�"); - documentNumberTitle.setCellStyle(title); - - SXSSFCell requirementTypeTitle = rowTitle.createCell(3); - requirementTypeTitle.setCellValue("闇�姹傚垎绫�"); - requirementTypeTitle.setCellStyle(title); - - SXSSFCell documentStatusTitle = rowTitle.createCell(4); - documentStatusTitle.setCellValue("鍗曟嵁鐘舵��"); - documentStatusTitle.setCellStyle(title); - - SXSSFCell approveDateTitle = rowTitle.createCell(5); - approveDateTitle.setCellValue("瀹℃牳鏃堕棿"); - approveDateTitle.setCellStyle(title); - - SXSSFCell workCenterTitle = rowTitle.createCell(6); - workCenterTitle.setCellValue("褰撳墠宸ュ簭"); - workCenterTitle.setCellStyle(title); - - SXSSFCell departmentTitle = rowTitle.createCell(7); - departmentTitle.setCellValue("褰撳墠宸ュ簭璐熻矗浜�"); - departmentTitle.setCellStyle(title); - - SXSSFCell crtPcsStsTitle = rowTitle.createCell(8); - crtPcsStsTitle.setCellValue("褰撳墠宸ュ簭鐘舵��"); - crtPcsStsTitle.setCellStyle(title); - - SXSSFCell nextProcessTitle = rowTitle.createCell(9); - nextProcessTitle.setCellValue("涓嬩竴宸ュ簭"); - nextProcessTitle.setCellStyle(title); + Map<Integer, String> FrontTitleMap = initFrontTitle(shopNames); + FrontTitleMap.forEach((index, titleName) -> { + createCell(rowTitle, index, titleName, titleStyle); + }); - SXSSFCell nextProcessDeparmentTitle = rowTitle.createCell(10); - nextProcessDeparmentTitle.setCellValue("涓嬩竴宸ュ簭璐熻矗浜�"); - nextProcessDeparmentTitle.setCellStyle(title); - - SXSSFCell itemNumberTitle = rowTitle.createCell(11); - itemNumberTitle.setCellValue("鏂欏彿"); - itemNumberTitle.setCellStyle(title); - - SXSSFCell drawingNoTitle = rowTitle.createCell(12); - drawingNoTitle.setCellValue("鍥惧彿"); - drawingNoTitle.setCellStyle(title); - - SXSSFCell versionNumberTitle = rowTitle.createCell(13); - versionNumberTitle.setCellValue("鐗堟湰鍙�"); - versionNumberTitle.setCellStyle(title); - - SXSSFCell lowNumTitle = rowTitle.createCell(14); - lowNumTitle.setCellValue("浣庨樁鐮�"); - lowNumTitle.setCellStyle(title); - - - SXSSFCell productionQuantityTitle = rowTitle.createCell(15); - productionQuantityTitle.setCellValue("鐢熶骇鏁伴噺"); - productionQuantityTitle.setCellStyle(title); - - SXSSFCell planSendDateTitle = rowTitle.createCell(16); - planSendDateTitle.setCellValue("宸ュ崟璁″垝涓嬪彂鏃堕棿"); - planSendDateTitle.setCellStyle(title); - - - - SXSSFCell planEndDayTitle = rowTitle.createCell(17); - planEndDayTitle.setCellValue("绯荤粺瀹屽伐鏃堕棿"); - planEndDayTitle.setCellStyle(title); - - - - - - String firstShopName = shopNames.get(0); - SXSSFCell firstShopBeginDateTitle = rowTitle.createCell(18); - firstShopBeginDateTitle.setCellValue(firstShopName+"寮�宸ユ椂闂�"); - firstShopBeginDateTitle.setCellStyle(title); - SXSSFCell firstShopEndDateTitle = rowTitle.createCell(19); - firstShopEndDateTitle.setCellValue(firstShopName+"瀹屽伐鏃堕棿"); - firstShopEndDateTitle.setCellStyle(title); - - /*鐒婃帴浠堕綈濂�*/ - SXSSFCell hanJieQiTaoTitle= rowTitle.createCell(20); - hanJieQiTaoTitle.setCellValue("鐒婃帴浠堕綈濂楀紑濮嬫椂闂�"); - hanJieQiTaoTitle.setCellStyle(title); - - int i1 = 19; - - for (int i = 1; i < shopNames.size(); i++) { - String shopName = shopNames.get(i); - SXSSFCell beginDateCell = rowTitle.createCell(i * 2 + i1); - SXSSFCell endDateCell = rowTitle.createCell(i * 2 + i1+1); - beginDateCell.setCellValue(shopName+"寮�宸ユ椂闂�"); - endDateCell.setCellValue(shopName+"瀹屽伐鏃堕棿"); - beginDateCell.setCellStyle(title); - endDateCell.setCellStyle(title); - } SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); for (int i = 0; i < table.size(); i++) { ApsPlateProcessShopPlanStat plan = table.get(i); - + //JSONObject jsonObject = (JSONObject) JSONObject.toJSON(plan); + ObjectMapper mapper = new ObjectMapper(); + ObjectNode node = mapper.valueToTree(plan); SXSSFRow dataRow = sheet.createRow(i+1); - //涓讳欢鏂欏彿 - SXSSFCell mainPartNumberCell = dataRow.createCell(0); - mainPartNumberCell.setCellValue(plan.getMainPartNumber()); - //涓氬姟绫诲瀷; - SXSSFCell businessTypeCell= dataRow.createCell(1); - businessTypeCell.setCellValue(plan.getBusinessType()); + LinkedHashMap<String,String> frontTitles= frontTitleName(); + ArrayList<Map.Entry<String, String>> frontTitlesList = new ArrayList<Map.Entry<String, String>>( + frontTitles.entrySet()); - //鍗曟嵁鍙�; - SXSSFCell documentNumberCell = dataRow.createCell(2); - documentNumberCell.setCellValue(plan.getDocumentNumber()); + for (int i1 = 0; i1 < frontTitlesList.size(); i1++) { - //闇�姹傚垎绫�; - SXSSFCell requirementTypeCell = dataRow.createCell(3); - requirementTypeCell.setCellValue(plan.getRequirementType()); + Map.Entry<String, String> entry = frontTitlesList.get(i1); + String filedKey = entry.getKey(); + String fieldValue= node.get(filedKey).textValue(); + createCell(dataRow, i1,fieldValue , null); + } - // 鍗曟嵁鐘舵�� - SXSSFCell documentStatusCell = dataRow.createCell(4); - documentStatusCell.setCellValue(plan.getDocumentStatus()); - - - // 瀹℃牳鏃堕棿 - SXSSFCell approveDateCell = dataRow.createCell(5); - approveDateCell.setCellValue(""); - - //褰撳墠宸ュ簭 - SXSSFCell workCenterCell = dataRow.createCell(6); - workCenterCell.setCellValue(plan.getWorkCenter()); - - //褰撳墠宸ュ簭璐熻矗浜�; - SXSSFCell departmentCell = dataRow.createCell(7); - departmentCell.setCellValue(plan.getDepartment()); - - /*褰撳墠宸ュ簭鐘舵��*/ - SXSSFCell crtPcsStsCell = dataRow.createCell(8); - crtPcsStsCell.setCellValue(plan.getOpStatus()); - - - //涓嬩竴宸ュ簭 - SXSSFCell nextProcessCell = dataRow.createCell(9); - nextProcessCell.setCellValue(plan.getNextOpName()); - - //涓嬩竴宸ュ簭宸ュ簭璐熻矗浜� - SXSSFCell nextProcessDeparmentCell = dataRow.createCell(10); - nextProcessDeparmentCell.setCellValue(plan.getNextProcessDeparment()); - - //鏂欏彿 - SXSSFCell itemNumberCell = dataRow.createCell(11); - itemNumberCell.setCellValue(plan.getItemNumber()); - - // 鍥惧彿 - SXSSFCell drawingNoCell = dataRow.createCell(12); - drawingNoCell.setCellValue(plan.getDrawingNo()); - - //鐗堟湰鍙� - SXSSFCell versionNumberCell = dataRow.createCell(13); - versionNumberCell.setCellValue(plan.getVersionNumber()); - - //浣庨樁鐮� - SXSSFCell lowNumCell = dataRow.createCell(14); - lowNumCell.setCellValue(""); - - //鐢熶骇鏁伴噺 - SXSSFCell productionQuantityCell = dataRow.createCell(15); - productionQuantityCell.setCellValue(plan.getProductionQuantity().toString()); - - //宸ュ崟璁″垝涓嬪彂鏃堕棿 - SXSSFCell planSendDateCell = dataRow.createCell(16); - planSendDateCell.setCellValue(""); - - //绯荤粺瀹屽伐鏃堕棿 - SXSSFCell planEndDayCell = dataRow.createCell(17); - planEndDayCell.setCellValue(dateFormat.format(plan.getPlanEndDay())); - - - - - SXSSFCell firstShopBeginDateCell = dataRow.createCell(18); - SXSSFCell firstShopEndDateCell = dataRow.createCell(19); - - plan.getDeptPlans().stream().filter(x->x.getShopName().equals(firstShopName)).findFirst().ifPresent(x->{ - firstShopBeginDateCell.setCellValue(x.getPlanStartDate()); - firstShopEndDateCell.setCellValue(x.getPlanEndDate()); - }); - /*鐒婃帴浠堕綈濂�*/ - SXSSFCell hanJieQiTaoCell = dataRow.createCell(20); - hanJieQiTaoCell.setCellValue(""); - - - for (int j = 1; j< shopNames.size(); j++) { - String shopName = shopNames.get(j); - SXSSFCell beginDateCell = dataRow.createCell(j * 2 + i1); - SXSSFCell endDateCell = dataRow.createCell(j * 2 + i1+1); + int shopBeginIndex = frontTitlesList.size(); + for (int j = 0; j< shopNames.size(); j++) { + String shopName = shopNames.get(0); + SXSSFCell beginDateCell = dataRow.createCell(j * 2 + shopBeginIndex); + SXSSFCell endDateCell = dataRow.createCell(j * 2 + shopBeginIndex+1); plan.getDeptPlans().stream().filter(x->x.getShopName().equals(shopName)).findFirst().ifPresent(x->{ beginDateCell.setCellValue(x.getPlanStartDate()); endDateCell.setCellValue(x.getPlanEndDate()); }); } + LinkedHashMap<String,String> backTitles= backTitleName(); + ArrayList<Map.Entry<String, String>> backTitlesList = new ArrayList<Map.Entry<String, String>>( + backTitles.entrySet()); - + int backBeginIndex = shopBeginIndex+shopNames.size()*2; + for (int i1 = 0; i1 < backTitlesList.size(); i1++) { + Map.Entry<String, String> entry = backTitlesList.get(i1); + String filedKey = entry.getKey(); + String fieldValue= node.get(filedKey).textValue(); + createCell(dataRow, i1+backBeginIndex,fieldValue , null); + } } - for (int i = 0; i < rowTitle.getLastCellNum(); i++) { - sheet.setColumnWidth(i, 20 * 256); } - wb.write(response.getOutputStream()); } catch (Exception e) @@ -552,6 +407,79 @@ } } + + private LinkedHashMap<String,String> frontTitleName(){ + + LinkedHashMap<String,String> map = new LinkedHashMap<>(); + map.put("mainPartNumber","涓讳欢鏂欏彿"); + map.put("customer","涓讳欢瀹㈡埛"); + map.put("requireTrackId","寤烘爲琛�"); + map.put("businessType","涓氬姟绫诲瀷"); + map.put("documentNumber","鍗曟嵁鍙�"); + map.put("itemNumber","鏂欏彿"); + map.put("drawingNo","鍥惧彿"); + map.put("versionNumber","鐗堟湰鍙�"); + map.put("lowOrderCode","浣庨樁鐮�"); + map.put("productionQuantity","鐢熶骇鏁伴噺"); + map.put("requirementType","闇�姹傚垎绫�"); + map.put("documentStatus","鍗曟嵁鐘舵��"); + map.put("approveOn","瀹℃牳鏃堕棿"); + map.put("processNumber","宸ュ簭鍙�"); + map.put("workCenter","褰撳墠宸ュ簭"); + map.put("department","褰撳墠宸ュ簭璐d换浜�"); + map.put("opStatus","鐘舵��"); + map.put("nextOpName","涓嬩竴閬撳伐搴�"); + map.put("planEndDay","绯荤粺瀹屽伐鏃堕棿"); + + return map; + } + private LinkedHashMap<String,String> backTitleName(){ + LinkedHashMap<String,String> map = new LinkedHashMap<>(); + + map.put("orderCreateTime","宸ュ崟鍒涘缓鏃堕棿"); + map.put("startWorkDate","宸ュ崟寮�宸ユ椂闂�"); + map.put("remainedProcess","鍓╀綑宸ュ簭"); + + return map; + } + + private Map<Integer,String> initFrontTitle(List<String> shopNames) { + Map<Integer,String> map = new HashMap<>(); + Map<String,String> frontTitles= frontTitleName(); + AtomicInteger index= new AtomicInteger(); + + frontTitles.forEach((key,value)->{ + map.put(index.get(), value); + index.getAndIncrement(); + }); + + + for (int i = 0; i < shopNames.size(); i++) { + map.put(i * 2 + index.get(),shopNames.get(i) + "寮�濮嬫椂闂�"); + map.put(i * 2 + index.get()+1,shopNames.get(i) + "缁撴潫鏃堕棿"); + } + + Map<String,String> backTitles= backTitleName(); + + AtomicInteger begBackIndex= new AtomicInteger(frontTitles.size() + shopNames.size() * 2); + + backTitles.forEach((key,value)->{ + map.put(begBackIndex.get(),value); + begBackIndex.getAndIncrement(); + }); + + return map; + } + + + private static void createCell(SXSSFRow rowTitle, int column, String titleName, CellStyle cellStyle) { + SXSSFCell cell = rowTitle.createCell(column); + cell.setCellValue(titleName); + if(null!=cellStyle){ + cell.setCellStyle(cellStyle); + } + } + private Map<String,CellStyle> createStyles(SXSSFWorkbook wb) { Map<String,CellStyle> styles=new HashMap<>(); -- Gitblit v1.9.3