Selaa lähdekoodia

Merge branch 'f-xiaogu' into dev

gushoubang 9 kuukautta sitten
vanhempi
commit
7d49da8a1d

+ 36 - 13
onemap-modules/onemap-analyse/src/main/java/com/onemap/analyse/controller/FzssController.java

@@ -6,33 +6,30 @@ import com.onemap.analyse.domain.vo.SelectPilotVo;
 import com.onemap.analyse.service.IFzssService;
 import com.onemap.analyse.domain.HgxfxEntityDTO;
 import com.onemap.analyse.utils.UnitsUtil;
+import com.onemap.common.core.utils.file.FileUtils;
 import com.onemap.common.core.web.controller.BaseController;
 import com.onemap.common.core.web.domain.RequestResult;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.web.bind.annotation.*;
 
+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.Map;
 
 @RestController
 @RequestMapping("/fzss")
 public class FzssController extends BaseController {
-
     @Autowired
     private IFzssService fzssService;
-
-    // /**
-    //  * 新建合规性分析
-    //  *
-    //  * @param hgxfxEntityDTO
-    //  * @return
-    //  */
-    // @PostMapping("/AddHgxfx")
-    // public RequestResult AddHgxfx(@RequestBody HgxfxEntityDTO hgxfxEntityDTO) throws IOException {
-    //     RequestResult res = fzssService.AddHgxfx(hgxfxEntityDTO);
-    //     return res;
-    // }
+    @Value("${Hgxfx.tempWin}")
+    public String tempWin;
+    @Value("${Hgxfx.tempLinux}")
+    public String tempLinux;
 
     /**
      * 新建辅助选址
@@ -106,4 +103,30 @@ public class FzssController extends BaseController {
         // RequestResult res = fzssService.saveWordFile(bsm, xzbsm);
         return null;
     }
+
+    @GetMapping("/DownloadReport")
+    public void fileDownload(String fileName, HttpServletResponse response, HttpServletRequest request) {
+        try {
+            String path = tempWin;
+            // windows 使用 tempWin, linux 使用 tempLinux
+            if (System.getProperty("os.name").toLowerCase().contains("linux")) {
+                path = tempLinux;
+            }
+
+            String realFileName = path + fileName;
+            response.setCharacterEncoding("utf-8");
+            response.setContentType("multipart/form-data");
+            response.setContentType("application/vnd.openxmlformats-officedocument.wordprocessingml.document");
+
+            String fileType = fileName.substring(fileName.lastIndexOf(".") + 1);
+            String time = new SimpleDateFormat("yyyyMMddHHmmss").format(new Date());
+            String downloadName = time + "." + fileType;
+
+            response.setHeader("Content-Disposition", "attachment;fileName=\"" + downloadName + "\"");
+            FileUtils.writeBytes(realFileName, response.getOutputStream());
+
+        } catch (Exception e) {
+            // log.error("下载文件失败", e);
+        }
+    }
 }

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

@@ -53,7 +53,7 @@ public class ReportServiceImpl implements IReportService {
 
     @Value("${Hgxfx.tempWin}")
     private String tempWin;
-    @Value("${Hgxfx.tempLinux}")
+    @Value("${Hgxfx.temp}")
     private String tempLinux;
 
     @Resource
@@ -61,7 +61,11 @@ public class ReportServiceImpl implements IReportService {
 
     // 根据选址任务生成报告
     public FzxzReport createReport(String bsm, List<String> xzbsmList) {
-        String temp = tempLinux;
+        String temp = tempWin;
+        // windows 使用 tempWin, linux 使用 tempLinux
+        if (System.getProperty("os.name").toLowerCase().contains("linux")) {
+            temp = tempLinux;
+        }
 
         // 保存生成报告日志
         iLogService.saveLog(bsm, "智能选址", "开始生成选址报告", "info");