From acd8bc764569dcd6a89df4186537e210ffafb283 Mon Sep 17 00:00:00 2001 From: jinpengyong <jpy123456> Date: Fri, 08 Sep 2023 15:21:34 +0800 Subject: [PATCH] chore:测试提交 --- screen-api/src/main/java/com/moral/api/controller/CruiserController.java | 32 +++++++++++++++++++++++++------- 1 files changed, 25 insertions(+), 7 deletions(-) diff --git a/screen-api/src/main/java/com/moral/api/controller/CruiserController.java b/screen-api/src/main/java/com/moral/api/controller/CruiserController.java index 6d20e73..d9a2e78 100644 --- a/screen-api/src/main/java/com/moral/api/controller/CruiserController.java +++ b/screen-api/src/main/java/com/moral/api/controller/CruiserController.java @@ -6,12 +6,14 @@ import com.deepoove.poi.data.TextRenderData; import com.moral.api.pojo.dto.historySecondCruiser.HistorySecondCruiserResultDTO; +import cn.afterturn.easypoi.exception.word.WordExportException; import cn.afterturn.easypoi.word.WordExportUtil; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiOperation; import lombok.extern.slf4j.Slf4j; +import org.apache.poi.ss.formula.functions.Rows; import org.apache.poi.xwpf.usermodel.XWPFDocument; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.util.ObjectUtils; @@ -19,6 +21,7 @@ import org.springframework.web.bind.annotation.CrossOrigin; 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.RequestMapping; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.multipart.MultipartFile; @@ -36,6 +39,7 @@ import java.util.List; import java.util.Map; +import javax.servlet.ServletOutputStream; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -240,17 +244,20 @@ * @return */ @PostMapping("dailyDustlds") - public ResultMessage dailyDustlds(HttpServletRequest request) throws IOException { -// List<MultipartFile> files = ((MultipartHttpServletRequest) request).getFiles("files"); - Map<String, Object> params = WebUtils.getParametersStartingWith(request, null); + public ResultMessage dailyDustlds(@RequestBody Map<String,Object> params, HttpServletResponse response) throws IOException { +// Map<String, Object> params = WebUtils.getParametersStartingWith(request, null); + if (!params.containsKey("mac") || !params.containsKey("startTime") || !params.containsKey("endTime")){ + return ResultMessage.fail(ResponseCodeEnum.PARAMETERS_IS_MISSING.getCode(), ResponseCodeEnum.PARAMETERS_IS_MISSING.getMsg()); + } Map<String, Object> map = dustldService.dailyDustlds(null,params); - test(map); + test(map,response); if (ObjectUtils.isEmpty(map)){ return ResultMessage.fail(ResponseCodeEnum.TARGET_IS_NULL.getCode(), ResponseCodeEnum.TARGET_IS_NULL.getMsg()); } - return new ResultMessage(ResponseCodeEnum.SUCCESS.getCode(),ResponseCodeEnum.SUCCESS.getMsg(),map); +// return new ResultMessage(ResponseCodeEnum.SUCCESS.getCode(),ResponseCodeEnum.SUCCESS.getMsg(),map); + return ResultMessage.ok(); } @@ -313,7 +320,7 @@ } - public void test( Map<String, Object> params) throws IOException { + public void test( Map<String, Object> params,HttpServletResponse response) throws IOException { // String path="D:\\���������������������.docx"; String path = getPath("���������������������.docx"); //��������������������������� @@ -348,9 +355,20 @@ map.put("table2", new MiniTableRenderData(header2, rsList2)); map.put("data",params.get("data").toString()); map.put("time",params.get("time").toString()); + + compile.render(map); - compile.writeToFile("G:\\home\\mon1\\" + "���������������������"+params.get("time").toString()+".docx"); +// response.setCharacterEncoding("utf-8"); +// response.setContentType("multipart/form-data"); +// response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode("���������������������" + params.get("time").toString() + ".docx", "utf-8")); +// FileOutputStream fileOutputStream = new FileOutputStream("���������������������" + params.get("time").toString() + ".docx"); +// compile.write(fileOutputStream); +// compile.writeToFile("G:\\hme\\mon1\\" + "���������������������"+params.get("time").toString()+".docx"); + +// FileOutputStream out = new FileOutputStream("���������������������" + params.get("time").toString() + ".docx"); + compile.write(response.getOutputStream()); compile.close(); +// return compile; } -- Gitblit v1.8.0