ソースを参照

整改清单报表导出

zhuang 1 年間 前
コミット
5367f55d00

+ 7 - 0
business-common/src/main/java/com/rongwei/bscommon/sys/feign/LuckySheetService.java

@@ -1,10 +1,13 @@
 package com.rongwei.bscommon.sys.feign;
 
 import com.alibaba.fastjson.JSONObject;
+import com.rongwei.bscommon.sys.config.api.ResponseVO;
 import com.rongwei.bsentity.dto.project.ProjectSummaryParamExcelDto;
 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.RequestBody;
+import org.springframework.web.bind.annotation.RequestParam;
 
 @FeignClient(name = "luckySheetService", url = "${luckysheet-provider.url}")
 public interface LuckySheetService {
@@ -17,4 +20,8 @@ public interface LuckySheetService {
      */
     @PostMapping("luckysheet/api/genLuckysheetExcel")
     JSONObject genLuckysheetExcel(@RequestBody ProjectSummaryParamExcelDto excelDto);
+
+    @GetMapping("luckysheet/test/get/LuckySheetJson")
+    ResponseVO getLuckySheetJson(@RequestParam("listId") String listId);
+
 }

+ 28 - 7
business-common/src/main/java/com/rongwei/bscommon/sys/service/impl/ZhcxProjectManageServiceImpl.java

@@ -9,8 +9,11 @@ import com.aspose.cells.*;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.rongwei.bscommon.sys.config.api.ResponseVO;
 import com.rongwei.bscommon.sys.dao.LuckysheetDao;
+import com.rongwei.bscommon.sys.feign.LuckySheetService;
 import com.rongwei.bscommon.sys.service.*;
+import com.rongwei.bscommon.sys.utils.JsonUtil;
 import com.rongwei.bscommon.sys.utils.LuckySheet4SummaryHelp;
 import com.rongwei.bscommon.sys.utils.ProjectSummaryExcelHelp;
 import com.rongwei.bscommon.sys.utils.XlsSheetUtil;
@@ -81,6 +84,8 @@ public class ZhcxProjectManageServiceImpl extends ServiceImpl<ZhcxProjectManageD
     private ExcelUtils excelUtils;
     @Autowired
     private ZhcxProjectManageDao zhcxProjectManageDao;
+    @Autowired
+    private LuckySheetService luckySheetFeignService;
 
     /**
      * 生成汇总文件
@@ -332,17 +337,33 @@ public class ZhcxProjectManageServiceImpl extends ServiceImpl<ZhcxProjectManageD
     @Override
     public int exportRectifyReportData(Map<String, Object> map, HttpServletResponse response) {
 
-        if(!excelUtils.GetLicense()) {
+//        if(!excelUtils.GetLicense()) {
+//            return 0;
+//        }
+//
+//        Workbook workbook = new Workbook();
+//        WorksheetCollection worksheets = workbook.getWorksheets();
+//        Worksheet worksheet = worksheets.get(0);
+//
+//        return exportRectifyReportDataBySheet(workbook, worksheet, map, response);
+        Object summaryfiles = map.get("summaryfiles");
+        Object projectIdobj = map.get("projectId");
+        if (ObjectUtil.isEmpty(summaryfiles) || ObjectUtil.isEmpty(projectIdobj)) {
             return 0;
         }
-
-        Workbook workbook = new Workbook();
-        WorksheetCollection worksheets = workbook.getWorksheets();
-        Worksheet worksheet = worksheets.get(0);
-
-        return exportRectifyReportDataBySheet(workbook, worksheet, map, response);
+        String listId = (String) summaryfiles;
+        String projectId = (String) projectIdobj;
+        ResponseVO responseVO = luckySheetFeignService.getLuckySheetJson(listId);
+        List<JSONObject> jsonObjects = JsonUtil.convertToJsonObjectList(responseVO.getData());
+        ExportProjectSummaryDto dto = new ExportProjectSummaryDto();
+        dto.setSheetList(jsonObjects);
+        dto.setProjectId(projectId);
+        dto.setFileName("整改清单");
+        this.exportRectifyReportDataInSummary(dto, response);
+        return 1;
     }
 
+
     /**
      * 在整改页导出报表
      *

+ 26 - 0
business-common/src/main/java/com/rongwei/bscommon/sys/utils/JsonUtil.java

@@ -1,9 +1,12 @@
 package com.rongwei.bscommon.sys.utils;
 
+import com.alibaba.fastjson.JSONObject;
 import com.google.gson.Gson;
 import com.google.gson.GsonBuilder;
 
+import java.util.ArrayList;
 import java.util.Date;
+import java.util.List;
 import java.util.Map;
 
 /**
@@ -36,5 +39,28 @@ public class JsonUtil {
 
     }
 
+    public static List<JSONObject> convertToJsonObjectList(Object obj) {
+        // 检查对象是否为List类型
+        if (obj instanceof List) {
+            List<?> rawList = (List<?>) obj;
 
+            // 创建一个新的List以存储JSONObject
+            List<JSONObject> jsonObjectList = new ArrayList<>();
+
+            for (Object element : rawList) {
+                // 检查每个元素是否为JSONObject
+                if (element instanceof JSONObject) {
+                    jsonObjectList.add((JSONObject) element);
+                } else {
+                    // 如果元素不是JSONObject,可以进行其他处理或抛出异常
+                    System.out.println("Element is not a JSONObject: " + element);
+                    return null;
+                }
+            }
+            return jsonObjectList;
+        } else {
+            System.out.println("Provided object is not a List.");
+            return null;
+        }
+    }
 }

+ 3 - 0
business-server/src/main/java/com/rongwei/bsserver/controller/ZhcxProjectManageController.java

@@ -1,6 +1,9 @@
 package com.rongwei.bsserver.controller;
 
 
+import cn.hutool.core.util.ObjectUtil;
+import com.rongwei.bscommon.sys.config.api.ResponseVO;
+import com.rongwei.bscommon.sys.feign.LuckySheetService;
 import com.rongwei.bscommon.sys.service.LuckysheetService;
 import com.rongwei.bscommon.sys.service.ZhcxProjectManageService;
 import com.rongwei.bsentity.domain.ZhcxProjectManageDo;