From 8ec7046779aa7ae510cbb584fbaa87cc45cfc49b Mon Sep 17 00:00:00 2001
From: jinpengyong <jpy123456>
Date: Tue, 05 Sep 2023 08:40:34 +0800
Subject: [PATCH] chore:测试提交
---
screen-common/src/main/java/com/moral/util/DateUtils.java | 16 +++++++
screen-manage/src/main/java/com/moral/api/service/impl/ManageCoordinateDetailServiceImpl.java | 2
screen-manage/src/main/java/com/moral/api/controller/ManageCoordinateDetailController.java | 2
screen-api/src/main/java/com/moral/api/controller/CruiserController.java | 85 +++++++++++++++++++++++++++++++++++++++++-
4 files changed, 100 insertions(+), 5 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 31f57f0..6d20e73 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
@@ -1,14 +1,21 @@
package com.moral.api.controller;
+import com.deepoove.poi.XWPFTemplate;
+import com.deepoove.poi.data.MiniTableRenderData;
+import com.deepoove.poi.data.RowRenderData;
+import com.deepoove.poi.data.TextRenderData;
import com.moral.api.pojo.dto.historySecondCruiser.HistorySecondCruiserResultDTO;
+
+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.xwpf.usermodel.XWPFDocument;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.util.CollectionUtils;
import org.springframework.util.ObjectUtils;
+import org.springframework.util.ResourceUtils;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
@@ -17,22 +24,32 @@
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.net.URLEncoder;
import java.text.ParseException;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
import com.moral.api.entity.Dustld;
import com.moral.api.pojo.bo.ExcelBO;
+import com.moral.api.pojo.dust.DustForm;
import com.moral.api.pojo.vo.excel.DailyVo;
import com.moral.api.service.DustldService;
import com.moral.api.service.SpecialDeviceService;
import com.moral.constant.ResponseCodeEnum;
import com.moral.constant.ResultMessage;
import com.moral.util.WebUtils;
+
+import static com.moral.api.controller.SysTestController.getPath;
@Slf4j
@Api(tags = {"���������"})
@@ -223,12 +240,13 @@
* @return
*/
@PostMapping("dailyDustlds")
- public ResultMessage dailyDustlds(HttpServletRequest request){
+ public ResultMessage dailyDustlds(HttpServletRequest request) throws IOException {
// List<MultipartFile> files = ((MultipartHttpServletRequest) request).getFiles("files");
Map<String, Object> params = WebUtils.getParametersStartingWith(request, null);
Map<String, Object> map = dustldService.dailyDustlds(null,params);
+ test(map);
if (ObjectUtils.isEmpty(map)){
return ResultMessage.fail(ResponseCodeEnum.TARGET_IS_NULL.getCode(), ResponseCodeEnum.TARGET_IS_NULL.getMsg());
}
@@ -273,4 +291,67 @@
}
+
+ public static void downloadWord(String fileName, Map<String, Object> params, HttpServletResponse response, String newFileName) {
+ String path = getPath(fileName);//��������� resources������
+ try {
+ //������������������
+ OutputStream out = new FileOutputStream("G:\\home\\mon1\\" + newFileName);
+ File rootFile = new File(ResourceUtils.getURL("classpath:").getPath());
+ File file= new File(rootFile, path);
+ XWPFDocument word = WordExportUtil.exportWord07(file.getPath(), params);
+ response.setCharacterEncoding("utf-8");
+ response.setContentType("multipart/form-data");
+ response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(newFileName, "utf-8"));
+ //OutputStream out = response.getOutputStream();
+ word.write(out);
+ out.flush();
+ out.close();
+ } catch (Exception e) {
+ log.error ("������������������������������������������", e);
+ }
+ }
+
+
+ public void test( Map<String, Object> params) throws IOException {
+// String path="D:\\���������������������.docx";
+ String path = getPath("���������������������.docx");
+ //���������������������������
+ File rootFile = new File(ResourceUtils.getURL("classpath:").getPath());
+ File file= new File(rootFile, path);
+ //������������������������
+ XWPFTemplate compile = XWPFTemplate.compile(file.getPath());
+ //������������������������������������������������������{{}}������������������������,map������������key������������������������������������������
+ HashMap<String, Object> map = new HashMap<>();
+ //������������������������
+ RowRenderData header1 = RowRenderData.build(new TextRenderData("6495ED", "������"), new TextRenderData("6495ED", "������"),new TextRenderData("6495ED", "���������������������/������������"));
+ RowRenderData header2 = RowRenderData.build(new TextRenderData("6495ED", "������"), new TextRenderData("6495ED", "������"),new TextRenderData("6495ED", "���������������������/������������"));
+
+ //���������������������������������������������������������list������������������������������foreach������������������
+ List<DustForm> list1 = (List<DustForm>) params.get("list1");
+ List<DustForm> list2 = (List<DustForm>) params.get("list2");
+ ArrayList<RowRenderData> rsList1 = new ArrayList<>();
+ ArrayList<RowRenderData> rsList2 = new ArrayList<>();
+
+ for (int i = 0; i < list1.size(); i++) {
+ DustForm dustForm = list1.get(i);
+ RowRenderData row0 = RowRenderData.build(i+1+"",dustForm.getRoad(), dustForm.getValue()+"");
+ rsList1.add(row0);
+ }
+ for (int i = 0; i < list2.size(); i++) {
+ DustForm dustForm = list2.get(i);
+ RowRenderData row0 = RowRenderData.build(i+1+"",dustForm.getRoad(), dustForm.getValue()+"");
+ rsList2.add(row0);
+ }
+
+ map.put("table1", new MiniTableRenderData(header1, rsList1));
+ 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");
+ compile.close();
+ }
+
+
}
diff --git a/screen-common/src/main/java/com/moral/util/DateUtils.java b/screen-common/src/main/java/com/moral/util/DateUtils.java
index e725576..5a51ae9 100644
--- a/screen-common/src/main/java/com/moral/util/DateUtils.java
+++ b/screen-common/src/main/java/com/moral/util/DateUtils.java
@@ -442,7 +442,7 @@
}
/**
- * ������������"yyyy-MM-dd HH:mm:ss"������������������������������������������,time2-time1
+ * ������������"yyyy-MM-dd"������������������������������������������,time2-time1
*
* @param time1
* @param time2
@@ -455,6 +455,20 @@
}
/**
+ * ������������"yyyy-MM-dd HH:mm:ss"������������������������������������������,time2-time1
+ *
+ * @param time1
+ * @param time2
+ * @return
+ */
+ public static long compareDateStrDay(String time1, String time2) {
+ Date d1 = getDate(time1,DateUtils.yyyy_MM_dd_HH_mm_ss_EN);
+ Date d2 = getDate(time2,DateUtils.yyyy_MM_dd_HH_mm_ss_EN);
+ return d2.getTime() - d1.getTime();
+ }
+
+
+ /**
* ���������������������������������������
*
* @param time1
diff --git a/screen-manage/src/main/java/com/moral/api/controller/ManageCoordinateDetailController.java b/screen-manage/src/main/java/com/moral/api/controller/ManageCoordinateDetailController.java
index dcd38d9..38955aa 100644
--- a/screen-manage/src/main/java/com/moral/api/controller/ManageCoordinateDetailController.java
+++ b/screen-manage/src/main/java/com/moral/api/controller/ManageCoordinateDetailController.java
@@ -71,7 +71,7 @@
if (integer!=200){
return ResultMessage.ok("������������");
}
- return ResultMessage.ok();
+ return ResultMessage.ok(integer);
}
/**
diff --git a/screen-manage/src/main/java/com/moral/api/service/impl/ManageCoordinateDetailServiceImpl.java b/screen-manage/src/main/java/com/moral/api/service/impl/ManageCoordinateDetailServiceImpl.java
index 5b9b086..d7c7333 100644
--- a/screen-manage/src/main/java/com/moral/api/service/impl/ManageCoordinateDetailServiceImpl.java
+++ b/screen-manage/src/main/java/com/moral/api/service/impl/ManageCoordinateDetailServiceImpl.java
@@ -205,7 +205,7 @@
queryWrapper.eq("coordinate_id",coordinateId);
String time1 = params.remove("time1").toString();
String time2 = params.remove("time2").toString();
- long l = DateUtils.compareDateStr(time1, time2);
+ long l = DateUtils.compareDateStrDay(time1, time2);
if (l>0){
params.put("time1",time1);
params.put("time2",time2);
--
Gitblit v1.8.0