From ccbf509ba5d9028741eff7d7267e8c7f5b7d9fcc Mon Sep 17 00:00:00 2001
From: huangjiayang <5265313@qq.com>
Date: 星期四, 24 四月 2025 15:51:44 +0800
Subject: [PATCH] 【UPDATE】修改标准工序实体,增加专业字段
---
aps-modules/aps-core/src/main/java/com/aps/core/service/impl/ApsPlateProcessShopStatServiceImpl.java | 210 +++++++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 204 insertions(+), 6 deletions(-)
diff --git a/aps-modules/aps-core/src/main/java/com/aps/core/service/impl/ApsPlateProcessShopStatServiceImpl.java b/aps-modules/aps-core/src/main/java/com/aps/core/service/impl/ApsPlateProcessShopStatServiceImpl.java
index dcaec74..9af3fbc 100644
--- a/aps-modules/aps-core/src/main/java/com/aps/core/service/impl/ApsPlateProcessShopStatServiceImpl.java
+++ b/aps-modules/aps-core/src/main/java/com/aps/core/service/impl/ApsPlateProcessShopStatServiceImpl.java
@@ -1,5 +1,6 @@
package com.aps.core.service.impl;
+import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;
@@ -7,11 +8,20 @@
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;
import com.aps.core.domain.*;
import com.aps.core.mapper.*;
+import com.aps.system.api.domain.SysDictData;
import jakarta.annotation.Resource;
+import jakarta.servlet.http.HttpServletResponse;
import lombok.extern.slf4j.Slf4j;
+import org.apache.poi.ss.usermodel.*;
+import org.apache.poi.util.IOUtils;
+import org.apache.poi.xssf.streaming.SXSSFCell;
+import org.apache.poi.xssf.streaming.SXSSFRow;
+import org.apache.poi.xssf.streaming.SXSSFSheet;
+import org.apache.poi.xssf.streaming.SXSSFWorkbook;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.aps.core.service.IApsPlateProcessShopStatService;
@@ -189,8 +199,9 @@
if (!processNames.isEmpty()) {
// 鏍规嵁宸ュ簭鍚嶇О锛屾煡璇㈣宸ュ崟涓嬫墍鏈夌殑宸ュ簭淇℃伅
List<ApsPlateProcessStat> processStats = statList.stream()
- .filter(x -> processNames.contains(x.getProcessName()) && x.getWorkOrderNo().equals(plan.getDocumentNumber()))
- .toList();
+ .filter(x -> processNames.contains(x.getProcessName()) && x.getWorkOrderNo().equals(plan.getDocumentNumber())
+ &&x.getProcessPlanStartDay()!=null&&x.getProcessPlanEndDay()!=null
+ ).toList();
if (!processStats.isEmpty()) {
// 鍙栧嚭宸ュ崟涓嬪伐搴忕殑鏈�灏忓紑濮嬫椂闂村拰鏈�澶х粨鏉熸椂闂�
List<Date> startDayList = processStats.stream().map(ApsPlateProcessStat::getProcessPlanStartDay).filter(Objects::nonNull).toList();
@@ -259,6 +270,10 @@
Map<String, List<ApsPlateProcessShopStat>> shopStatesByDocNo = shopStates.stream()
.collect(Collectors.groupingBy(ApsPlateProcessShopStat::getDocNo));
+
+ List<SysDictData> businessTypeDic = DictUtils.getDictCache("aps_business_type");
+ List<SysDictData> documentStatusDic = DictUtils.getDictCache("aps_document_status");
+
// 鏋勫缓缁撴灉鍒楄〃
List<ApsPlateProcessShopPlanStat> shopPlanStats = planList.stream()
.map(plan -> {
@@ -268,16 +283,199 @@
// 鏍规嵁 docNo 鑾峰彇瀵瑰簲鐨� shopStatList
List<ApsPlateProcessShopStat> shopStatList = shopStatesByDocNo.getOrDefault(plan.getDocumentNumber(), Collections.emptyList());
shopPlanStat.setDeptPlans(shopStatList);
-
+ if (businessTypeDic != null) {
+ businessTypeDic.stream().filter(x -> x.getDictValue().equals(plan.getBusinessType())).findFirst()
+ .ifPresent(sysDictData -> shopPlanStat.setBusinessType(sysDictData.getDictLabel()));
+ }
+ if (documentStatusDic != null) {
+ documentStatusDic.stream().filter(x->x.getDictValue().equals(plan.getDocumentStatus()))
+ .findFirst().ifPresent(sysDictData -> shopPlanStat.setDocumentStatus(sysDictData.getDictLabel()));
+ }
return shopPlanStat;
- })
- .toList();
-
+ }).toList();
// 鏋勫缓杩斿洖缁撴灉
AjaxResult success = AjaxResult.success(shopPlanStats);
success.put("shopNames", shopList);
return success;
}
+ @Override
+ public void exportExcel(HttpServletResponse response) {
+ SXSSFWorkbook wb = new SXSSFWorkbook(500);
+ wb.createSheet();
+ wb.setSheetName(0, "閽i噾璁″垝琛�");
+ response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
+ response.setCharacterEncoding("utf-8");
+
+ Map<String, CellStyle> styles = createStyles(wb);
+ CellStyle title = styles.get("title");
+ try
+ {
+
+ AjaxResult stat = getShopPlanStat();
+ List<String> shopNames = (List<String>) stat.get("shopNames");
+ List<ApsPlateProcessShopPlanStat> table= (List<ApsPlateProcessShopPlanStat>)stat.get("data");
+ 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 workCenterTitle = rowTitle.createCell(5);
+ workCenterTitle.setCellValue("褰撳墠宸ュ簭");
+ workCenterTitle.setCellStyle(title);
+
+ SXSSFCell itemNumberTitle = rowTitle.createCell(6);
+ itemNumberTitle.setCellValue("鏂欏彿");
+ itemNumberTitle.setCellStyle(title);
+
+ SXSSFCell drawingNoTitle = rowTitle.createCell(7);
+ drawingNoTitle.setCellValue("鍥惧彿");
+ drawingNoTitle.setCellStyle(title);
+
+ SXSSFCell versionNumberTitle = rowTitle.createCell(8);
+ versionNumberTitle.setCellValue("鐗堟湰鍙�");
+ versionNumberTitle.setCellStyle(title);
+
+ SXSSFCell productionQuantityTitle = rowTitle.createCell(9);
+ productionQuantityTitle.setCellValue("鐢熶骇鏁伴噺");
+ productionQuantityTitle.setCellStyle(title);
+
+ SXSSFCell planEndDayTitle = rowTitle.createCell(10);
+ planEndDayTitle.setCellValue("璁″垝瀹屽伐鏃�");
+ planEndDayTitle.setCellStyle(title);
+
+
+
+
+ for (int i = 0; i < shopNames.size(); i++) {
+ String shopName = shopNames.get(i);
+ SXSSFCell beginDateCell = rowTitle.createCell(i * 2 + 11);
+ SXSSFCell endDateCell = rowTitle.createCell(i * 2 + 12);
+ 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);
+
+ SXSSFRow dataRow = sheet.createRow(i+1);
+
+ SXSSFCell mainPartNumberCell = dataRow.createCell(0);
+ mainPartNumberCell.setCellValue(plan.getMainPartNumber());
+
+ //mainPartNumberCell.setCellStyle(title);
+
+ SXSSFCell businessTypeCell= dataRow.createCell(1);
+ businessTypeCell.setCellValue(plan.getBusinessType());
+ //businessTypeCell.setCellStyle(title);
+
+ SXSSFCell documentNumberCell = dataRow.createCell(2);
+ documentNumberCell.setCellValue(plan.getDocumentNumber());
+ // documentNumberCell.setCellStyle(title);
+
+ SXSSFCell requirementTypeCell = dataRow.createCell(3);
+ requirementTypeCell.setCellValue(plan.getRequirementType());
+ // requirementTypeCell.setCellStyle(title);
+
+ SXSSFCell documentStatusCell = dataRow.createCell(4);
+ documentStatusCell.setCellValue(plan.getDocumentStatus());
+ // documentStatusCell.setCellStyle(title);
+
+ SXSSFCell workCenterCell = dataRow.createCell(5);
+ workCenterCell.setCellValue(plan.getWorkCenter());
+ // workCenterCell.setCellStyle(title);
+
+ SXSSFCell itemNumberCell = dataRow.createCell(6);
+ itemNumberCell.setCellValue(plan.getItemNumber());
+ // itemNumberCell.setCellStyle(title);
+
+ SXSSFCell drawingNoCell = dataRow.createCell(7);
+ drawingNoCell.setCellValue(plan.getDrawingNo());
+ // drawingNoCell.setCellStyle(title);
+
+ SXSSFCell versionNumberCell = dataRow.createCell(8);
+ versionNumberCell.setCellValue(plan.getVersionNumber());
+ // versionNumberCell.setCellStyle(title);
+
+ SXSSFCell productionQuantityCell = dataRow.createCell(9);
+ productionQuantityCell.setCellValue(plan.getProductionQuantity().toString());
+ // productionQuantityCell.setCellStyle(title);
+
+ SXSSFCell planEndDayCell = dataRow.createCell(10);
+ planEndDayCell.setCellValue(dateFormat.format(plan.getPlanEndDay()));
+ // planEndDayCell.setCellStyle(title);
+
+ for (int j = 0; j< shopNames.size(); j++) {
+ String shopName = shopNames.get(j);
+ SXSSFCell beginDateCell = dataRow.createCell(j * 2 + 11);
+ SXSSFCell endDateCell = dataRow.createCell(j * 2 + 12);
+ plan.getDeptPlans().stream().filter(x->x.getShopName().equals(shopName)).findFirst().ifPresent(x->{
+ beginDateCell.setCellValue(x.getPlanStartDate());
+ endDateCell.setCellValue(x.getPlanEndDate());
+ });
+ }
+
+
+ }
+
+ for (int i = 0; i < 24; i++) {
+
+ sheet.setColumnWidth(i, 20 * 256);
+ }
+
+ wb.write(response.getOutputStream());
+ }
+ catch (Exception e)
+ {
+ log.error("瀵煎嚭Excel寮傚父{}", e.getMessage());
+ }
+ finally
+ {
+ IOUtils.closeQuietly(wb);
+ }
+
+ }
+ private Map<String,CellStyle> createStyles(SXSSFWorkbook wb)
+ {
+ Map<String,CellStyle> styles=new HashMap<>();
+ CellStyle style = wb.createCellStyle();
+ style.setAlignment(HorizontalAlignment.CENTER);
+ style.setVerticalAlignment(VerticalAlignment.CENTER);
+ Font titleFont = wb.createFont();
+ titleFont.setFontName("Arial");
+ titleFont.setFontHeightInPoints((short) 12);
+ titleFont.setBold(true);
+ style.setFont(titleFont);
+ DataFormat dataFormat = wb.createDataFormat();
+ style.setDataFormat(dataFormat.getFormat("@"));
+
+
+
+
+ styles.put("title", style);
+ return styles;
+ }
+
}
--
Gitblit v1.9.3