From 01bec5540f87a68ae881295f9fe06283e00f1ed2 Mon Sep 17 00:00:00 2001
From: zhanghl <253316343@qq.com>
Date: 星期日, 27 四月 2025 10:31:51 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/dev' into dev

---
 aps-modules/aps-core/src/main/java/com/aps/core/service/impl/ApsGasPipingRouteStatServiceImpl.java |  430 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 430 insertions(+), 0 deletions(-)

diff --git a/aps-modules/aps-core/src/main/java/com/aps/core/service/impl/ApsGasPipingRouteStatServiceImpl.java b/aps-modules/aps-core/src/main/java/com/aps/core/service/impl/ApsGasPipingRouteStatServiceImpl.java
new file mode 100644
index 0000000..cd38d02
--- /dev/null
+++ b/aps-modules/aps-core/src/main/java/com/aps/core/service/impl/ApsGasPipingRouteStatServiceImpl.java
@@ -0,0 +1,430 @@
+package com.aps.core.service.impl;
+
+import com.alibaba.fastjson2.JSONArray;
+import com.alibaba.fastjson2.JSONObject;
+import com.aps.common.core.utils.DateUtils;
+import com.aps.common.core.utils.uuid.IdUtils;
+import com.aps.common.security.utils.SecurityUtils;
+import com.aps.core.domain.*;
+import com.aps.core.mapper.ApsGasPipelineCapacityPlanMapper;
+import com.aps.core.mapper.ApsGasPipingPlanMapper;
+import com.aps.core.mapper.ApsGasPipingRouteStatMapper;
+import com.aps.core.service.IApsGasMaterialUsageService;
+import com.aps.core.service.IApsGasPipingRouteStatService;
+import jakarta.servlet.http.HttpServletResponse;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.poi.ss.usermodel.*;
+import org.apache.poi.ss.util.CellRangeAddress;
+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 java.math.BigDecimal;
+import java.sql.Timestamp;
+import java.text.SimpleDateFormat;
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+import java.time.YearMonth;
+import java.time.ZoneId;
+import java.time.format.DateTimeFormatter;
+import java.util.*;
+
+/**
+ * 姘斾綋绠¤矾浜ц兘璐熻浇缁熻Service涓氬姟灞傚鐞�
+ * 
+ * @author hjy
+ * @date 2025-04-24
+ */
+@Slf4j
+@Service
+public class ApsGasPipingRouteStatServiceImpl implements IApsGasPipingRouteStatService 
+{
+    @Autowired
+    private ApsGasPipingRouteStatMapper apsGasPipingRouteStatMapper;
+
+    @Autowired
+    private ApsGasPipingPlanMapper apsGasPipingPlanMapper;
+
+    @Autowired
+    private ApsGasPipelineCapacityPlanMapper apsGasPipelineCapacityPlanMapper;
+
+    @Autowired
+    private IApsGasMaterialUsageService apsGasMaterialUsageService;
+
+    /**
+     * 鏌ヨ姘斾綋绠¤矾浜ц兘璐熻浇缁熻
+     * 
+     * @param id 姘斾綋绠¤矾浜ц兘璐熻浇缁熻涓婚敭
+     * @return 姘斾綋绠¤矾浜ц兘璐熻浇缁熻
+     */
+    @Override
+    public ApsGasPipingRouteStat selectApsGasPipingRouteStatById(String id)
+    {
+        return apsGasPipingRouteStatMapper.selectApsGasPipingRouteStatById(id);
+    }
+
+    /**
+     * 鏌ヨ姘斾綋绠¤矾浜ц兘璐熻浇缁熻鍒楄〃
+     * 
+     * @param apsGasPipingRouteStat 姘斾綋绠¤矾浜ц兘璐熻浇缁熻
+     * @return 姘斾綋绠¤矾浜ц兘璐熻浇缁熻
+     */
+    @Override
+    public List<ApsGasPipingRouteStat> selectApsGasPipingRouteStatList(ApsGasPipingRouteStat apsGasPipingRouteStat)
+    {
+        return apsGasPipingRouteStatMapper.selectApsGasPipingRouteStatList(apsGasPipingRouteStat);
+    }
+
+    /**
+     * 鏂板姘斾綋绠¤矾浜ц兘璐熻浇缁熻
+     * 
+     * @param apsGasPipingRouteStat 姘斾綋绠¤矾浜ц兘璐熻浇缁熻
+     * @return 缁撴灉
+     */
+    @Override
+    public int insertApsGasPipingRouteStat(ApsGasPipingRouteStat apsGasPipingRouteStat)
+    {
+        apsGasPipingRouteStat.setCreateTime(DateUtils.getNowDate());
+        apsGasPipingRouteStat.setCreateBy(SecurityUtils.getUsername());
+        return apsGasPipingRouteStatMapper.insertApsGasPipingRouteStat(apsGasPipingRouteStat);
+    }
+
+    /**
+     * 淇敼姘斾綋绠¤矾浜ц兘璐熻浇缁熻
+     * 
+     * @param apsGasPipingRouteStat 姘斾綋绠¤矾浜ц兘璐熻浇缁熻
+     * @return 缁撴灉
+     */
+    @Override
+    public int updateApsGasPipingRouteStat(ApsGasPipingRouteStat apsGasPipingRouteStat)
+    {
+        apsGasPipingRouteStat.setUpdateBy(SecurityUtils.getUsername());
+        apsGasPipingRouteStat.setUpdateTime(DateUtils.getNowDate());
+        return apsGasPipingRouteStatMapper.updateApsGasPipingRouteStat(apsGasPipingRouteStat);
+    }
+
+    /**
+     * 鎵归噺鍒犻櫎姘斾綋绠¤矾浜ц兘璐熻浇缁熻
+     * 
+     * @param ids 闇�瑕佸垹闄ょ殑姘斾綋绠¤矾浜ц兘璐熻浇缁熻涓婚敭
+     * @return 缁撴灉
+     */
+    @Override
+    public int deleteApsGasPipingRouteStatByIds(String[] ids)
+    {
+        return apsGasPipingRouteStatMapper.deleteApsGasPipingRouteStatByIds(ids);
+    }
+
+    /**
+     * 鍒犻櫎姘斾綋绠¤矾浜ц兘璐熻浇缁熻淇℃伅
+     * 
+     * @param id 姘斾綋绠¤矾浜ц兘璐熻浇缁熻涓婚敭
+     * @return 缁撴灉
+     */
+    @Override
+    public int deleteApsGasPipingRouteStatById(String id)
+    {
+        return apsGasPipingRouteStatMapper.deleteApsGasPipingRouteStatById(id);
+    }
+
+    @Override
+    public boolean computeCapacity() {
+//        PageHelper.startPage(1, 500);
+        List<ApsGasPipingPlan> apsGasPipingPlans = apsGasPipingPlanMapper.selectApsGasPipingPlanWithProcess(new ApsGasPipingPlan());
+        List<ApsGasPipingRouteStat> apsGasPipingRouteStatList = new ArrayList<>();
+        /*鏈璁$畻鎵规鍙�*/
+        String batchNum = IdUtils.fastSimpleUUID();
+        try {
+            apsGasPipingPlans.forEach(apsGasPipingPlan -> {
+                List<ApsProcessRoute> apsProcessRoutes = apsGasPipingPlan.getApsProcessRoutes();
+                //鎸夌収宸ュ簭搴忓彿鍗囧簭鎺掑簭
+                apsProcessRoutes.sort((a, b)->a.getProcessNumber().compareTo(b.getProcessNumber()));
+                //鏄惁鎵惧埌褰撳墠宸ュ簭
+                boolean isFind = false;
+                for (int i=0;i<apsProcessRoutes.size();i++){
+                    ApsProcessRoute apsProcessRoute = apsProcessRoutes.get(i);
+                    ApsGasPipingRouteStat apsGasPipingRouteStat = new ApsGasPipingRouteStat();
+                    //宸ュ崟鍙�
+                    apsGasPipingRouteStat.setWorkOrderNo(apsGasPipingPlan.getDocumentNumber());
+                    //鏂欏彿
+                    apsGasPipingRouteStat.setItemNumber(apsGasPipingPlan.getItemNumber());
+                    //褰撳墠宸ュ簭鍙�
+                    apsGasPipingRouteStat.setCurrentProcessNumber(apsGasPipingPlan.getProcessNumber());
+                    //鐢熶骇鏁伴噺
+                    apsGasPipingRouteStat.setProductionQuantity(apsGasPipingPlan.getProductionQuantity());
+                    //宸ュ簭鍚嶇О
+                    apsGasPipingRouteStat.setProcessName(apsProcessRoute.getProcessName());
+                    //宸ュ簭鍙�
+                    apsGasPipingRouteStat.setRoadProcessNumber(apsProcessRoute.getProcessNumber());
+                    //鏍囧噯宸ユ椂
+                    apsGasPipingRouteStat.setStandardTime(apsProcessRoute.getStandardTime());
+                    //涓撲笟
+                    apsGasPipingRouteStat.setMajor(apsGasPipingPlan.getPlanType());
+                    //宸ュ簭鎬诲伐鏃� 绛変簬 鏍囧噯宸ユ椂*鐢熶骇鏁伴噺
+                    apsGasPipingRouteStat.setProcessTotalTime(apsProcessRoute.getStandardTime().multiply(apsGasPipingPlan.getProductionQuantity()));
+                    //璁″垝寮�宸ユ棩
+                    if(apsGasPipingRouteStat.getCurrentProcessNumber().equals(apsGasPipingRouteStat.getRoadProcessNumber())) {
+                        /* 瀵� stat.getProcessPlanStartDay() 鍜屽綋鍓嶆棩鏈� 杩涜瀵规瘮锛屽彧瀵规瘮鍒版棩锛屼笉鐢ㄧ鍗佸垎绉�*/
+                        LocalDate startLocalDate = LocalDate.ofInstant(apsProcessRoute.getProcessPlanStartDay().toInstant(), ZoneId.systemDefault());
+                        LocalDate nowLocalDate = LocalDate.now();
+                        if (startLocalDate.isBefore(nowLocalDate)) {
+                            apsGasPipingRouteStat.setProcessPlanStartDay(new Date());
+                        }else{
+                            apsGasPipingRouteStat.setProcessPlanStartDay(apsProcessRoute.getProcessPlanStartDay());
+                        }
+                        isFind = true;
+                    }
+                    if(!isFind){
+                        continue;
+                    }
+                    // 涓婁竴閬撳伐搴忕殑缁撴潫鏃堕棿 = 涓婁竴閬撳伐搴忕殑寮�濮嬫椂闂� + 涓婁竴閬撳伐搴忕殑鎬诲伐鏃�
+                    if(apsGasPipingRouteStat.getProcessPlanStartDay()==null){
+                        LocalDateTime previousProcessPlanStartDay = apsProcessRoutes.get(i - 1).getProcessPlanStartDay().toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime();
+                        long previousProcessTotalTime = apsGasPipingRouteStatList.get(i - 1).getProcessTotalTime().longValue();
+                        LocalDateTime currentProcessPlanStartDay = previousProcessPlanStartDay.plusHours(previousProcessTotalTime);
+                        apsGasPipingRouteStat.setProcessPlanStartDay(Date.from(Timestamp.valueOf(currentProcessPlanStartDay.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))).toInstant()));
+                    }
+                    //鎻掑叆 骞� 鏈� 鏃�
+                    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+                    String formattedDate = sdf.format(apsGasPipingRouteStat.getProcessPlanStartDay());
+                    String[] dateParts = formattedDate.split("-");
+                    apsGasPipingRouteStat.setPlanStartYear(String.valueOf(Integer.parseInt(dateParts[0])));
+                    apsGasPipingRouteStat.setPlanStartMonth(String.valueOf(Integer.parseInt(dateParts[1])));
+                    apsGasPipingRouteStat.setPlanStartDay(String.valueOf(Integer.parseInt(dateParts[2])));
+                    //鏍囧噯鐢ㄩ噺 鏌ヨ鐗╂枡鐢ㄩ噺琛�
+//                    ApsGasMaterialUsage apsGasMaterialUsage = new ApsGasMaterialUsage();
+//                    apsGasMaterialUsage.setItemNumber(apsGasPipingPlan.getItemNumber());
+//                    apsGasMaterialUsage.setProcessName(apsProcessRoute.getProcessName());
+//                    List<ApsGasMaterialUsage> apsGasMaterialUsageList = apsGasMaterialUsageService.selectApsGasMaterialUsageList(apsGasMaterialUsage);
+                    apsGasPipingRouteStat.setStandardDosage(apsProcessRoute.getStandardTime().multiply(apsGasPipingPlan.getProductionQuantity()));
+                    //宸ュ簭鎬荤敤閲� = 鏍囧噯鐢ㄩ噺*鐢熶骇鏁伴噺
+                    apsGasPipingRouteStat.setProcessTotalDosage(apsGasPipingRouteStat.getStandardDosage().multiply(apsGasPipingPlan.getProductionQuantity()));
+                    apsGasPipingRouteStat.setCreateTime(DateUtils.getNowDate());
+                    apsGasPipingRouteStat.setCreateBy("auto");
+                    apsGasPipingRouteStat.setBatchNumber(batchNum);
+                    apsGasPipingRouteStat.setId(IdUtils.fastSimpleUUID());
+                    apsGasPipingRouteStatList.add(apsGasPipingRouteStat);
+                }
+            });
+            List<ApsGasPipingRouteStat> tempInsertList = new ArrayList<>();
+            for (int i = 0; i < apsGasPipingRouteStatList.size(); i++) {
+                tempInsertList.add(apsGasPipingRouteStatList.get(i));
+                if(tempInsertList.size()==500){
+                    apsGasPipingRouteStatMapper.insertApsGasPipingRouteStatBatch(tempInsertList);
+                    tempInsertList = new ArrayList<>();
+                }else if(i==apsGasPipingRouteStatList.size()-1){
+                    apsGasPipingRouteStatMapper.insertApsGasPipingRouteStatBatch(tempInsertList);
+                }
+            }
+            apsGasPipingRouteStatMapper.deleteApsGasPipingRouteStatByBatchNum(batchNum);
+        } catch (Exception e) {
+            e.printStackTrace();
+            return false;
+        }
+        return true;
+    }
+
+    @Override
+    public JSONObject getCapacityPlanData(ApsGasPipingRouteStat apsGasPipingRouteStat) {
+        JSONObject result = new JSONObject();
+        HashSet<String> startPlanTimeSet = new HashSet<>();
+        JSONArray processData = new JSONArray();
+        try {
+            //鑾峰彇宸ュ簭璁″垝浜ц兘鏁版嵁
+            HashMap<String, ApsGasPipelineCapacityPlan> apsGasPipingPlanMap = new HashMap<>();
+            List<ApsGasPipelineCapacityPlan> apsGasPipelineCapacityPlanList = apsGasPipelineCapacityPlanMapper.selectApsGasPipelineCapacityPlanList(new ApsGasPipelineCapacityPlan());
+            apsGasPipelineCapacityPlanList.forEach(apsGasPipelineCapacityPlan -> {
+                apsGasPipingPlanMap.put(apsGasPipelineCapacityPlan.getProcessName(),apsGasPipelineCapacityPlan);
+            });
+            //璁$畻鏃ヤ骇鑳芥暟鎹�
+            DateTimeFormatter formatter = null;
+            List<ApsGasPipingRouteStat> apsGasPipingRouteStats;
+            SimpleDateFormat simpleDateFormat = null;
+            YearMonth yearMonth = YearMonth.parse(apsGasPipingRouteStat.getSearchEndDate());
+            int daysInMonth = yearMonth.lengthOfMonth();
+            apsGasPipingRouteStat.setSearchStartDate(apsGasPipingRouteStat.getSearchStartDate()+"-01 00:00:00");
+            apsGasPipingRouteStat.setSearchEndDate(apsGasPipingRouteStat.getSearchEndDate()+"-"+ daysInMonth +" 23:59:59");
+            if("day".equals(apsGasPipingRouteStat.getSearchType())){
+                formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
+                simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
+            }else if("month".equals(apsGasPipingRouteStat.getSearchType())){
+                formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
+                simpleDateFormat = new SimpleDateFormat("yyyy-MM");
+            }
+            apsGasPipingRouteStats = apsGasPipingRouteStatMapper.selectApsGasPipingRouteStatList(apsGasPipingRouteStat);
+            //鏍规嵁寮�宸ユ棩杩涜鍗囧簭鎺掑簭
+            apsGasPipingRouteStats.sort((a, b)->a.getProcessPlanStartDay().compareTo(b.getProcessPlanStartDay()));
+            //宸ュ簭鍒嗙粍缁熻
+            HashMap<String, List<ApsResourceDateStat>> processMap = new HashMap<>();
+            List<HashMap<String, List<ApsResourceDateStat>>> processList = new ArrayList<>();
+            //宸ュ簭寮�宸ユ棩鏈�
+            String planStartDate = "";
+            //缁熻鎵�鏈夊伐搴忓搴旂殑寮�宸ユ椂闂�
+            for (ApsGasPipingRouteStat apsGasPipingRouteStatTemp : apsGasPipingRouteStats) {
+                planStartDate = simpleDateFormat.format(apsGasPipingRouteStatTemp.getProcessPlanStartDay());
+                if("month".equals(apsGasPipingRouteStat.getSearchType())){
+                    planStartDate = planStartDate+"-01";
+                }
+                ApsResourceDateStat apsResourceDateStat = new ApsResourceDateStat();
+                apsResourceDateStat.setPlanDay(LocalDate.parse(planStartDate, formatter));
+                apsResourceDateStat.setResourceName(apsGasPipingRouteStatTemp.getProcessName());
+                //鏌ヨ姘旀煖绠¤矾浜ц兘瑙勫垝琛�
+                apsResourceDateStat.setDesignTimes(apsGasPipingPlanMap.get(apsGasPipingRouteStatTemp.getProcessName())!=null?apsGasPipingPlanMap.get(apsGasPipingRouteStatTemp.getProcessName()).getDayProduceAllNum().intValue():0);
+                //鏌ヨ鏂欏彿宸ュ簭浜ц兘琛�
+                apsResourceDateStat.setRequireTimes(apsGasPipingRouteStatTemp.getProcessTotalTime().intValue());
+                if(apsResourceDateStat.getDesignTimes()!=0){
+                    apsResourceDateStat.setCapacityLoad(BigDecimal.valueOf(apsResourceDateStat.getRequireTimes()/apsResourceDateStat.getDesignTimes()* 100L));
+                }else{
+                    apsResourceDateStat.setCapacityLoad(BigDecimal.valueOf(0));
+                }
+                List<ApsResourceDateStat> apsResourceDateStatList = new ArrayList<>();
+                if(processMap.containsKey(apsGasPipingRouteStatTemp.getProcessName())){
+                    apsResourceDateStatList = processMap.get(apsGasPipingRouteStatTemp.getProcessName());
+                }
+                apsResourceDateStatList.add(apsResourceDateStat);
+                processMap.put(apsGasPipingRouteStatTemp.getProcessName(), apsResourceDateStatList);
+            }
+            //鑱氬悎姣忛亾宸ュ簭鐨勫紑宸ユ椂闂村拰浜ц兘
+            processMap.forEach((processName, apsResourceDateStatList) -> {
+                LinkedHashMap<String, ApsResourceDateStat> dayMap = new LinkedHashMap<>();
+                apsResourceDateStatList.forEach(apsResourceDateStat -> {
+                    startPlanTimeSet.add(apsResourceDateStat.getPlanDay().toString());
+                    if(dayMap.containsKey(apsResourceDateStat.getPlanDay().toString())){
+                        ApsResourceDateStat apsResourceDateStatTemp = dayMap.get(apsResourceDateStat.getPlanDay().toString());
+                        apsResourceDateStatTemp.setDesignTimes(apsGasPipingPlanMap.get(processName)!=null?apsGasPipingPlanMap.get(processName).getMonthProduceAllNum().intValue():0);
+                        apsResourceDateStatTemp.setRequireTimes(apsResourceDateStatTemp.getRequireTimes()+apsResourceDateStat.getRequireTimes());
+                        if(apsResourceDateStatTemp.getDesignTimes()!=0){
+                            apsResourceDateStatTemp.setCapacityLoad(BigDecimal.valueOf(apsResourceDateStatTemp.getRequireTimes()/apsResourceDateStatTemp.getDesignTimes()* 100L));
+                        }else{
+                            apsResourceDateStatTemp.setCapacityLoad(BigDecimal.valueOf(0));
+                        }
+                        apsResourceDateStatTemp.setResourceGroupName(processName);
+                        apsResourceDateStatTemp.setPlanDay(apsResourceDateStat.getPlanDay());
+                        dayMap.put(apsResourceDateStat.getPlanDay().toString(), apsResourceDateStatTemp);
+                    }else{
+                        dayMap.put(apsResourceDateStat.getPlanDay().toString(), apsResourceDateStat);
+                    }
+                });
+                List<ApsResourceDateStat> tempList = new ArrayList<>();
+                dayMap.forEach((key, value) -> {
+                    tempList.add(value);
+                });
+//                processMap.put(processName, tempList);
+                HashMap<String, List<ApsResourceDateStat>> temp = new HashMap<>();
+                temp.put(processName, tempList);
+                processList.add(temp);
+            });
+//            for (String key : processMap.keySet()) {
+//                HashMap<String, List<ApsResourceDateStat>> temp = new HashMap<>();
+//                temp.put(key, processMap.get(key));
+//                processList.add(temp);
+//            }
+            //鎺掑簭鏃堕棿鏍囬
+            List<String> sortedStartPlanTimeList = new ArrayList<>(startPlanTimeSet);
+            Collections.sort(sortedStartPlanTimeList);
+            result.put("planTable", processList);
+            result.put("planTitle", sortedStartPlanTimeList);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return result;
+    }
+
+    @Override
+    public void exportExcel(HttpServletResponse response, ApsGasPipingRouteStat apsGasPipingRouteStat) {
+        SXSSFWorkbook wb = new SXSSFWorkbook(500);
+        wb.createSheet();
+        wb.setSheetName(0, "姘旀煖绠¤矾浜ц兘璐熻浇缁熻琛�");
+        response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
+        response.setCharacterEncoding("utf-8");
+
+        Map<String, CellStyle> styles = createStyles(wb);
+        CellStyle title = styles.get("title");
+        try
+        {
+            JSONObject stat = getCapacityPlanData(apsGasPipingRouteStat);
+            List<String> days = (List<String>) stat.get("planTitle");
+            List<HashMap<String, List<ApsResourceDateStat>>> table= (List<HashMap<String, List<ApsResourceDateStat>>>) stat.get("planTable");
+            SXSSFSheet sheet = wb.getSheetAt(0);
+            /*濉啓鏃ユ湡鍒� 鍜� 宸ユ椂鍒�*/
+            SXSSFRow rowDay = sheet.createRow(0);
+            SXSSFRow rowTitle = sheet.createRow(1);
+
+            SXSSFCell daytitle = rowDay.createCell(0);
+            daytitle.setCellValue("鏃ユ湡");
+            daytitle.setCellStyle(title);
+            SXSSFCell titleCell = rowTitle.createCell(0);
+            titleCell.setCellValue("宸ュ簭");
+            titleCell.setCellStyle(title);
+
+            for (int i = 0; i < days.size(); i++) {
+                SXSSFCell dateCell = rowDay.createCell(i * 3 + 1);
+                SXSSFCell designHoursCell = rowTitle.createCell(i * 3 + 1);
+                SXSSFCell requireHoursCell = rowTitle.createCell(i * 3 + 2);
+                SXSSFCell loadCell = rowTitle.createCell(i * 3 + 3);
+                dateCell.setCellValue(days.get(i));
+                designHoursCell.setCellValue("璁捐宸ユ椂");
+                requireHoursCell.setCellValue("闇�姹傚伐鏃�");
+                loadCell.setCellValue("浜ц兘璐熻嵎");
+                /*set cell style*/
+                dateCell.setCellStyle(title);
+                designHoursCell.setCellStyle(title);
+                requireHoursCell.setCellStyle(title);
+                loadCell.setCellStyle(title);
+
+                /*鍚堝苟鏃ユ湡鍗曞厓鏍�*/
+                sheet.addMergedRegion( new CellRangeAddress(0, 0, i*3+1, i*3+3));
+            }
+            for (int i = 0; i < table.size(); i++) {
+                Map<String, List<ApsResourceDateStat>> resourceList = table.get(i);
+                /*鍒涘缓鏁版嵁琛�*/
+                SXSSFRow dataRow  = sheet.createRow(i+2);
+                for( Map.Entry<String, List<ApsResourceDateStat>> entry : resourceList.entrySet()){
+                    String resourceName = entry.getKey();
+                    List<ApsResourceDateStat> resourceDateStats = entry.getValue();
+                    dataRow.createCell(0).setCellValue(resourceName);
+                    for (int j = 0; j < resourceDateStats.size(); j++) {
+                        ApsResourceDateStat apsResourceDateStat = resourceDateStats.get(j);
+                        dataRow.createCell(j*3+1).setCellValue(apsResourceDateStat.getDesignTimes());
+                        dataRow.createCell(j*3+2).setCellValue(apsResourceDateStat.getRequireTimes());
+                        if(apsResourceDateStat.getCapacityLoad()!=null){
+                            dataRow.createCell(j*3+3).setCellValue(apsResourceDateStat.getCapacityLoad().doubleValue()+"%");
+                        }else{
+                            dataRow.createCell(j*3+3).setCellValue("%");
+                        }
+                    }
+                }
+
+            }
+            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