浏览代码

Merge branch 'f-xiaogu' into dev

gushoubang 9 月之前
父节点
当前提交
2cd4227b67

+ 33 - 28
onemap-modules/onemap-analyse/src/main/java/com/onemap/analyse/controller/FzssController.java

@@ -1,10 +1,13 @@
 package com.onemap.analyse.controller;
 
 import com.fasterxml.jackson.core.JsonProcessingException;
+import com.onemap.analyse.domain.FzxzReport;
 import com.onemap.analyse.domain.calculation.FzxzCalc;
+import com.onemap.analyse.domain.vo.DkReportVo;
 import com.onemap.analyse.domain.vo.SelectPilotVo;
 import com.onemap.analyse.service.IFzssService;
 import com.onemap.analyse.domain.HgxfxEntityDTO;
+import com.onemap.analyse.service.IReportService;
 import com.onemap.analyse.utils.UnitsUtil;
 import com.onemap.common.core.utils.file.FileUtils;
 import com.onemap.common.core.web.controller.BaseController;
@@ -13,12 +16,14 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.web.bind.annotation.*;
 
+import javax.annotation.Resource;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import java.io.IOException;
 import java.text.SimpleDateFormat;
 import java.util.ArrayList;
 import java.util.Date;
+import java.util.HashMap;
 import java.util.Map;
 
 @RestController
@@ -31,6 +36,11 @@ public class FzssController extends BaseController {
     @Value("${Hgxfx.tempLinux}")
     public String tempLinux;
 
+
+    // 报告服务
+    @Resource
+    private IReportService iReportService;
+
     /**
      * 新建辅助选址
      *
@@ -96,39 +106,34 @@ public class FzssController extends BaseController {
      *
      * @return
      */
-    @PostMapping("/SaveWordFile")
-    public RequestResult SaveWordFile(@RequestBody Map params) {
-        String bsm = (String) params.get("bsm");
-        ArrayList xzbsm = (ArrayList) params.get("xzbsm");
-        // RequestResult res = fzssService.saveWordFile(bsm, xzbsm);
-        return null;
+    @PostMapping("/DownloadLandReport")
+    public RequestResult SaveWordFile(@RequestBody DkReportVo dkReportVo) {
+        FzxzReport fzxzReport = iReportService.createReport(dkReportVo.getBsm(), dkReportVo.getDkIds());
+        Map<String, String> resMap = new HashMap<>();
+        resMap.put("fxbg", fzxzReport.getReportfile());
+        return RequestResult.success("查询成功!", resMap);
     }
 
     @GetMapping("/DownloadReport")
-    public void fileDownload(String filePath, HttpServletResponse response, HttpServletRequest request) {
-        try {
-            String path = tempWin;
-            // windows 使用 tempWin, linux 使用 tempLinux
-            System.out.println("####获取操作系统名称####");
-            System.out.println("os.name: " + System.getProperty("os.name").toLowerCase());
-            if (System.getProperty("os.name").toLowerCase().contains("linux")) {
-                path = tempLinux;
-            }
-
-            String realFileName = path + filePath;
-            response.setCharacterEncoding("utf-8");
-            response.setContentType("multipart/form-data");
-            response.setContentType("application/vnd.openxmlformats-officedocument.wordprocessingml.document");
+    public void fileDownload(String filePath, HttpServletResponse response) throws IOException {
+        String path = tempWin;
+        // windows 使用 tempWin, linux 使用 tempLinux
+        System.out.println("####获取操作系统名称####");
+        System.out.println("os.name: " + System.getProperty("os.name").toLowerCase());
+        if (System.getProperty("os.name").toLowerCase().contains("linux")) {
+            path = tempLinux;
+        }
 
-            String fileType = filePath.substring(filePath.lastIndexOf(".") + 1);
-            String time = new SimpleDateFormat("yyyyMMddHHmmss").format(new Date());
-            String downloadName = time + "." + fileType;
+        String realFileName = path + filePath;
+        response.setCharacterEncoding("utf-8");
+        response.setContentType("multipart/form-data");
+        response.setContentType("application/vnd.openxmlformats-officedocument.wordprocessingml.document");
 
-            response.setHeader("Content-Disposition", "attachment;fileName=\"" + downloadName + "\"");
-            FileUtils.writeBytes(realFileName, response.getOutputStream());
+        String fileType = filePath.substring(filePath.lastIndexOf(".") + 1);
+        String time = new SimpleDateFormat("yyyyMMddHHmmss").format(new Date());
+        String downloadName = time + "." + fileType;
 
-        } catch (Exception e) {
-            // log.error("下载文件失败", e);
-        }
+        response.setHeader("Content-Disposition", "attachment;fileName=\"" + downloadName + "\"");
+        FileUtils.writeBytes(realFileName, response.getOutputStream());
     }
 }

+ 13 - 0
onemap-modules/onemap-analyse/src/main/java/com/onemap/analyse/domain/vo/DkReportVo.java

@@ -0,0 +1,13 @@
+package com.onemap.analyse.domain.vo;
+
+import lombok.Data;
+
+import javax.validation.constraints.NotNull;
+import java.util.List;
+
+@Data
+public class DkReportVo {
+    private String bsm;
+    @NotNull
+    private List<String> dkIds;
+}

+ 0 - 4
onemap-modules/onemap-analyse/src/main/java/com/onemap/analyse/service/IFzssService.java

@@ -8,8 +8,6 @@ import com.onemap.common.core.web.domain.RequestResult;
 import java.util.Map;
 
 public interface IFzssService {
-    // RequestResult AddHgxfx(HgxfxEntityDTO hgxfxEntityDTO) throws IOException;
-
     FzxzCalc saveScheduleParam(SelectPilotVo selectPilotVo) throws JsonProcessingException;
 
     RequestResult startSchedule(FzxzCalc fzxzCalc);
@@ -21,6 +19,4 @@ public interface IFzssService {
     RequestResult GetXzResList(String startTime, String endTime, String name, Integer pageNum, Integer pageSize);
 
     RequestResult DelXzRes(String bsm);
-
-    // RequestResult saveWordFile(String bsm, ArrayList xzbsm);
 }

+ 1 - 2
onemap-modules/onemap-analyse/src/main/java/com/onemap/analyse/service/IReportService.java

@@ -1,10 +1,9 @@
 package com.onemap.analyse.service;
 
 import com.onemap.analyse.domain.FzxzReport;
-import com.onemap.analyse.domain.res.GeomRes;
 
 import java.util.List;
 
 public interface IReportService {
-    FzxzReport createReport(String bsm, List<String> xzbsmList);
+    FzxzReport createReport(String bsm, List<String> dkIds);
 }

+ 5 - 6
onemap-modules/onemap-analyse/src/main/java/com/onemap/analyse/service/impl/ReportServiceImpl.java

@@ -60,7 +60,7 @@ public class ReportServiceImpl implements IReportService {
     GhdkaMapper ghdkaMapper;
 
     // 根据选址任务生成报告
-    public FzxzReport createReport(String bsm, List<String> xzbsmList) {
+    public FzxzReport createReport(String bsm, List<String> dkIds) {
         String temp = tempWin;
         // windows 使用 tempWin, linux 使用 tempLinux
         if (System.getProperty("os.name").toLowerCase().contains("linux")) {
@@ -85,7 +85,7 @@ public class ReportServiceImpl implements IReportService {
             }
             String reportPath = res.getXmmc() + "(选址报告)_" + timeStamp + ".docx";
             // ###选址报告###
-            createReport(res, allPath + "/" + reportPath, xzbsmList);
+            createReport(res, allPath + "/" + reportPath, dkIds);
             // 生成返回结果
             fzxzReport.setReportfile(filePath + "/" + reportPath);
             fzxzReport.setBsm(bsm);
@@ -110,7 +110,7 @@ public class ReportServiceImpl implements IReportService {
      * @param reportPath
      * @param xzbsmList  没有导出全部地块
      */
-    private void createReport(FzxzEntityDTO res, String reportPath, List<String> xzbsmList) {
+    private void createReport(FzxzEntityDTO res, String reportPath, List<String> dkIds) {
         GeomRes geomRes = shpFileMapper.getOne(res.getGeomId());
 
         // List<String> imgList = ReportImg(res, xzbsmList);
@@ -244,9 +244,8 @@ public class ReportServiceImpl implements IReportService {
             QueryWrapper<SelectionResDTO> giswrapper = new QueryWrapper<>();
             giswrapper.eq("rwbsm", res.getBsm());
             // 筛选方案,根据传参或者预选方案
-//            giswrapper.ne("yxfa", "0");
-            if (xzbsmList != null) {
-                giswrapper.in("bsm", xzbsmList);
+            if (dkIds != null && dkIds.size() > 0) {
+                giswrapper.in("bsm", dkIds);
             }
             List<SelectionResDTO> fzxzJgGisDTOList = fzxzResMapper.selectList(giswrapper);
             NpoiHelper.catalog(document, "三、选址分析", pos++);