123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139 |
- 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;
- 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.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
- @RequestMapping("/fzss")
- public class FzssController extends BaseController {
- @Autowired
- private IFzssService fzssService;
- @Value("${Hgxfx.tempWin}")
- public String tempWin;
- @Value("${Hgxfx.tempLinux}")
- public String tempLinux;
- // 报告服务
- @Resource
- private IReportService iReportService;
- /**
- * 新建辅助选址
- *
- * @param
- * @return
- */
- @PostMapping("/AddFzxz")
- public RequestResult AddFzxz(@RequestBody SelectPilotVo selectPilotVo) throws JsonProcessingException {
- // TODO xmlx:项目类型
- if (selectPilotVo.getYdmjbegin() != null) {
- selectPilotVo.setYdmjbegin((float) (UnitsUtil.muToM2(selectPilotVo.getYdmjbegin())));
- }
- if (selectPilotVo.getYdmjend() != null) {
- selectPilotVo.setYdmjend((float) (UnitsUtil.muToM2(selectPilotVo.getYdmjend())));
- }
- // 存储规划参数
- FzxzCalc fzxzCalc = fzssService.saveScheduleParam(selectPilotVo);
- // 开始规划任务
- RequestResult res = fzssService.startSchedule(fzxzCalc);
- return res;
- }
- /**
- * 获取选址结果
- *
- * @param bsm
- * @return
- */
- @GetMapping("/GetXzjg")
- public RequestResult GetXzjg(String bsm) {
- RequestResult res = fzssService.GetXzjg(bsm);
- return res;
- }
- /**
- * 获取选址结果列表
- *
- * @param startTime
- * @param endTime
- * @param name
- * @return
- */
- @GetMapping("/GetXzResList")
- public RequestResult GetXzResList(String startTime, String endTime, String name, Integer pageNum, Integer pageSize) {
- RequestResult res = fzssService.GetXzResList(startTime, endTime, name, pageNum, pageSize);
- return res;
- }
- /**
- * 删除选址结果
- *
- * @return
- */
- @DeleteMapping("/DelXzRes")
- public RequestResult DelXzRes(String bsm) {
- RequestResult res = fzssService.DelXzRes(bsm);
- return res;
- }
- /**
- * 通过选择的方案生成报告
- *
- * @return
- */
- @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) 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 realFileName = path + filePath;
- response.setCharacterEncoding("utf-8");
- response.setContentType("multipart/form-data");
- response.setContentType("application/vnd.openxmlformats-officedocument.wordprocessingml.document");
- String fileType = filePath.substring(filePath.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());
- }
- }
|