From 67a5f2c9689d38b5b1533888829b7f9bbf0c3ba8 Mon Sep 17 00:00:00 2001
From: cjl <909710561@qq.com>
Date: Thu, 18 Apr 2024 14:01:43 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/cjl' into dev
---
screen-api/src/main/java/com/moral/api/controller/CruiserController.java | 277 ++++++++++++++++++++++++++++++++++++++-----------------
1 files changed, 190 insertions(+), 87 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 e550ddc..6f71385 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
@@ -164,6 +164,9 @@
public void loadDaily( @RequestBody Map<String,Object> params,HttpServletResponse response) throws IOException {
List<Integer> ids = (List<Integer>) params.get("ids");
List<DailyVo> dailyVos = specialDeviceService.loadDaily(ids);
+ if (ObjectUtils.isEmpty(dailyVos)){
+ throw new BusinessException("���������������������");
+ }
dailyDocx(dailyVos,response);
}
@@ -402,12 +405,15 @@
//������jar���������������
ApplicationHome applicationHome = new ApplicationHome(getClass());
//���jar������������������������������upload������������������������������������
- String path = applicationHome.getSource().getParentFile().toString() + "/static/img";
+ String path = applicationHome.getSource().getParentFile().toString() + "\\static\\img";
+
+ String name1 = dailyVos.size()>1?"word/���������������������������.docx":"word/���������������������������2.docx";
+
try {
//InputStream inputStream = WordUtil.class.getClassLoader().getResourceAsStream("word/���������������������.docx");
- InputStream stream = WordUtil.class.getClassLoader().getResourceAsStream("word/���������������������������.docx");
+ InputStream stream = WordUtil.class.getClassLoader().getResourceAsStream(name1);
//������������������
- File file = new File("word/���������������������������.docx");
+ File file = new File(name1);
//���������������������������������������������������������������������������������������������
FileUtils.copyInputStreamToFile(stream, file);
//��������������������������������������������� ������������������������
@@ -446,25 +452,36 @@
// picMap.put("urlImg1", Pictures.ofUrl("G:\\home\\3d423e3cb05d7edc35c38e3173af2a0d.jpg", PictureType.JPEG).size(500, 500).create());
int i =1;
for (DailyVo dailyVo : dailyVos) {
- Map picMap = new HashMap();
+ Map picMap1 = new HashMap();
+ Map picMap2 = new HashMap();
+ Map picMap3 = new HashMap();
+ Map picMap4 = new HashMap();
+ Map picMap5 = new HashMap();
+ Map picMap6 = new HashMap();
+ Map picMap7 = new HashMap();
+ Map picMap8 = new HashMap();
List<String> images = dailyVo.getImages();
if (!ObjectUtils.isEmpty(images)){
- picMap.put("urlImg"+i,new PictureRenderData(500, 500, path+"\\"+images.get(0)));
- pic1.add(picMap);
- picMap.put("urlImg"+i,new PictureRenderData(500, 500, path+"\\"+images.get(1)));
- pic2.add(picMap);
- picMap.put("urlImg"+i,new PictureRenderData(500, 500, path+"\\"+images.get(2)));
- pic3.add(picMap);
- picMap.put("urlImg"+i,new PictureRenderData(500, 500, path+"\\"+images.get(3)));
- pic4.add(picMap);
- picMap.put("urlImg"+i,new PictureRenderData(500, 500, path+"\\"+images.get(4)));
- pic5.add(picMap);
- picMap.put("urlImg"+i,new PictureRenderData(500, 500, path+"\\"+images.get(5)));
- pic6.add(picMap);
- picMap.put("urlImg"+i,new PictureRenderData(500, 500, path+"\\"+images.get(6)));
- pic7.add(picMap);
- picMap.put("urlImg"+i,new PictureRenderData(500, 500, path+"\\"+images.get(7)));
- pic8.add(picMap);
+
+ picMap1.put("urlImg"+i,new PictureRenderData(500, 500, path+"\\"+images.get(0)));
+// picMap1.put("urlImg"+i,new PictureRenderData(500, 500, path+"\\0a4ab467-304d-4871-948f-55aa7e820975.png"));
+ pic1.add(picMap1);
+ picMap2.put("urlImg"+i,new PictureRenderData(500, 500, path+"\\"+images.get(1)));
+// picMap2.put("urlImg"+i,new PictureRenderData(500, 500, path+"\\0a4ab467-304d-4871-948f-55aa7e820975.png"));
+ pic2.add(picMap2);
+ picMap3.put("urlImg"+i,new PictureRenderData(500, 500, path+"\\"+images.get(2)));
+ pic3.add(picMap3);
+ picMap4.put("urlImg"+i,new PictureRenderData(500, 500, path+"\\"+images.get(3)));
+ pic4.add(picMap4);
+ picMap5.put("urlImg"+i,new PictureRenderData(500, 500, path+"\\"+images.get(4)));
+ pic5.add(picMap5);
+ picMap6.put("urlImg"+i,new PictureRenderData(500, 500, path+"\\"+images.get(5)));
+ pic6.add(picMap6);
+ picMap7.put("urlImg"+i,new PictureRenderData(500, 500, path+"\\"+images.get(6)));
+ pic7.add(picMap7);
+ picMap8.put("urlImg"+i,new PictureRenderData(500, 500, path+"\\"+images.get(7)));
+ pic8.add(picMap8);
+ i++;
}
detailList1.add(dailyVo.getCode());
detailList2.add(dailyVo.getCode());
@@ -474,80 +491,166 @@
detailList6.add(dailyVo.getCode());
detailList7.add(dailyVo.getCode());
detailList8.add(dailyVo.getCode());
- builder.append("("+dailyVo.getCode().get("mac")+")������������������������������������������������������������������������������������������7���������������������PM2.5���������������"+dailyVo.getCode().get("avgPm25")+"ug/m3���PM10���������������"+dailyVo.getCode().get("avgPm10")+"ug/m3���NO2���������������"
- +dailyVo.getCode().get("avgNO2")+"ug/m3���CO���������������"+dailyVo.getCode().get("avgCO")+"mg/m3���SO2���������������"+dailyVo.getCode().get("avgSO2")+"ug/m3���O3���������������"+dailyVo.getCode().get("avgO3")+"ug/m3���VOCs������������"+dailyVo.getCode().get("avgVOC")+"mg/m3���"+"\n"+" ");
+
+
+ builder.append("("+dailyVo.getCode().get("mac")+")������������������������������������������������������������������������������������������7���������������������PM\u2082.\u2085���������������"+dailyVo.getCode().get("avgPm25")+"ug/m\u00b3���PM\u2081\u2080���������������"+dailyVo.getCode().get("avgPm10")+"ug/m\u00b3���NO\u2082���������������"
+ +dailyVo.getCode().get("avgNO2")+"ug/m\u00b3���CO���������������"+dailyVo.getCode().get("avgCO")+"mg/m\u00b3���SO\u2082���������������"+dailyVo.getCode().get("avgSO2")+"ug/m\u00b3���O\u2083���������������"+dailyVo.getCode().get("avgO3")+"ug/m\u00b3���VOCs������������"+dailyVo.getCode().get("avgVOC")+"mg/m\u00b3���"+"\n"+" ");
}
-/* for (HashMap<String, Object> list : lists) {
- detailList1.add(list);
- detailList2.add(list);
- detailList3.add(list);
- detailList4.add(list);
- detailList5.add(list);
- detailList6.add(list);
- detailList7.add(list);
- detailList8.add(list);
- builder.append("("+list.get("mac")+")������������������������������������������������������������������������������������������7���������������������PM2.5���������������"+list.get("avgPm25")+"ug/m3���PM10���������������"+list.get("avgPm10")+"ug/m3���NO2���������������"
- +list.get("avgNO2")+"ug/m3���CO���������������"+list.get("avgCO")+"mg/m3���SO2���������������"+list.get("avgSO2")+"ug/m3���O3���������������"+list.get("avgO3")+"ug/m3���VOCs������������"+list.get("avgVOC")+"mg/m3���"+"\n"+" ");
- }*/
-/* List<Map> pic = new ArrayList<>();
- for (MultipartFile multipartFile : files) {
- Map picMap = new HashMap();
- InputStream inputStream = multipartFile.getInputStream();
- picMap.put("urlImg", Pictures.ofStream(inputStream, PictureType.JPEG).size(500, 500).create());
- pic.add(picMap);
- }*/
+
+ if (dailyVos.size()>1){
+ String name = dailyVos.get(0).getName();
+ String type = dailyVos.get(0).getType();
+ map.put("code",builder);
+ map.put("time1",DateUtils.getCurCNDate());
+ map.put("name",name);
+ map.put("type",type);
+ map.put("mac",dailyVos.get(0).getCode().get("mac"));
+ map.put("pm25",dailyVos.get(0).getCode().get("avgPm25"));
+ map.put("pm10",dailyVos.get(0).getCode().get("avgPm10"));
+ map.put("no2",dailyVos.get(0).getCode().get("avgNO2"));
+ map.put("co",dailyVos.get(0).getCode().get("avgCO"));
+ map.put("so2",dailyVos.get(0).getCode().get("avgSO2"));
+ map.put("o3",dailyVos.get(0).getCode().get("avgO3"));
+ map.put("VOCs",dailyVos.get(0).getCode().get("avgVOC"));
+ map.put("mac2",dailyVos.get(1).getCode().get("mac"));
+ map.put("2pm25",dailyVos.get(1).getCode().get("avgPm25"));
+ map.put("2pm10",dailyVos.get(1).getCode().get("avgPm10"));
+ map.put("2no2",dailyVos.get(1).getCode().get("avgNO2"));
+ map.put("2co",dailyVos.get(1).getCode().get("avgCO"));
+ map.put("2so2",dailyVos.get(1).getCode().get("avgSO2"));
+ map.put("2o3",dailyVos.get(1).getCode().get("avgO3"));
+ map.put("2VOCs",dailyVos.get(1).getCode().get("avgVOC"));
-
- map.put("code",builder);
- map.put("time1",DateUtils.getCurCNDate());
-// map.put("pho",new PictureRenderData(100, 100, "G:\\home\\3d423e3cb05d7edc35c38e3173af2a0d.jpg"));
-// Pictures.ofLocal(null);
-// map.put("pho1",new PictureRenderData(100, 100, path+"\\0a4ab467-304d-4871-948f-55aa7e820975.png"));
-
- HackLoopTableRenderPolicy policy = new HackLoopTableRenderPolicy();
- Configure config = Configure.newBuilder().bind("detailList1", policy).bind("detailList2", policy).bind("detailList3", policy).bind("detailList4", policy)
- .bind("detailList5", policy).bind("detailList6", policy).bind("detailList7", policy).bind("detailList8", policy).build();
- XWPFTemplate compile = XWPFTemplate.compile(filePath,config).render(new HashMap<String, Object>(){{
- put("code",map.get("code"));
- put("time1",map.get("time1"));
+ HackLoopTableRenderPolicy policy = new HackLoopTableRenderPolicy();
+ Configure config = Configure.newBuilder().bind("detailList1", policy).bind("detailList2", policy).bind("detailList3", policy).bind("detailList4", policy)
+ .bind("detailList5", policy).bind("detailList6", policy).bind("detailList7", policy).bind("detailList8", policy).build();
+ XWPFTemplate compile = XWPFTemplate.compile(filePath,config).render(new HashMap<String, Object>(){{
+ put("code",map.get("code"));
+ put("time1",map.get("time1"));
+ put("mac",map.get("mac"));
+ put("pm25",map.get("pm25"));
+ put("pm10",map.get("pm10"));
+ put("no2",map.get("no2"));
+ put("co",map.get("co"));
+ put("so2",map.get("so2"));
+ put("o3",map.get("o3"));
+ put("VOCs",map.get("VOCs"));
+ put("2pm25",map.get("2pm25"));
+ put("2pm10",map.get("2pm10"));
+ put("2no2",map.get("2no2"));
+ put("2co",map.get("2co"));
+ put("2so2",map.get("2so2"));
+ put("2o3",map.get("2o3"));
+ put("2VOCs",map.get("2VOCs"));
+ put("mac2",map.get("mac2"));
// put("pho", map.get("pho"));
// put("pho1", map.get("pho1"));
- put("detailList1", detailList1);
- put("detailList2", detailList2);
- put("detailList3", detailList3);
- put("detailList4", detailList4);
- put("detailList5", detailList5);
- put("detailList6", detailList6);
- put("detailList7", detailList7);
- put("detailList8", detailList8);
- put("picList1", pic1);
- put("picList2", pic2);
- put("picList3", pic3);
- put("picList4", pic4);
- put("picList5", pic5);
- put("picList6", pic6);
- put("picList7", pic7);
- put("picList8", pic8);
- }});
+ put("name",map.get("name"));
+ put("type",map.get("type"));
+ put("detailList1", detailList1);
+ put("detailList2", detailList2);
+ put("detailList3", detailList3);
+ put("detailList4", detailList4);
+ put("detailList5", detailList5);
+ put("detailList6", detailList6);
+ put("detailList7", detailList7);
+ put("detailList8", detailList8);
+ put("picList1", pic1);
+ put("picList2", pic2);
+ put("picList3", pic3);
+ put("picList4", pic4);
+ put("picList5", pic5);
+ put("picList6", pic6);
+ put("picList7", pic7);
+ put("picList8", pic8);
+ }});
+ response.setContentType("multipart/form-data");
+ // ���������������
+ response.addHeader("Content-Disposition", "attachment;fileName=ce.docx" );
+// response.setHeader("Content-Disposition", "attachment; filename=\"" + name+type+"������������" + "\"");
+ response.setCharacterEncoding("UTF-8");
+ //���������������
+/* File file1 = new File("G:\\test\\test2.docx");
+ FileOutputStream out = new FileOutputStream(file1);
+ compile.write(out);*/
+ //���������������
+ OutputStream out = response.getOutputStream();
+ compile.write(out);
+ out.flush();
+ out.close();
+ compile.close();
+
+ }else {
+ String name = dailyVos.get(0).getName();
+ String type = dailyVos.get(0).getType();
+ map.put("code",builder);
+ map.put("time1",DateUtils.getCurCNDate());
+ map.put("name",name);
+ map.put("type",type);
+ map.put("mac",dailyVos.get(0).getCode().get("mac"));
+ map.put("pm25",dailyVos.get(0).getCode().get("avgPm25"));
+ map.put("pm10",dailyVos.get(0).getCode().get("avgPm10"));
+ map.put("no2",dailyVos.get(0).getCode().get("avgNO2"));
+ map.put("co",dailyVos.get(0).getCode().get("avgCO"));
+ map.put("so2",dailyVos.get(0).getCode().get("avgSO2"));
+ map.put("o3",dailyVos.get(0).getCode().get("avgO3"));
+ map.put("VOCs",dailyVos.get(0).getCode().get("avgVOC"));
+
+ HackLoopTableRenderPolicy policy = new HackLoopTableRenderPolicy();
+ Configure config = Configure.newBuilder().bind("detailList1", policy).bind("detailList2", policy).bind("detailList3", policy).bind("detailList4", policy)
+ .bind("detailList5", policy).bind("detailList6", policy).bind("detailList7", policy).bind("detailList8", policy).build();
+ XWPFTemplate compile = XWPFTemplate.compile(filePath,config).render(new HashMap<String, Object>(){{
+ put("code",map.get("code"));
+ put("time1",map.get("time1"));
+ put("mac",map.get("mac"));
+ put("pm25",map.get("pm25"));
+ put("pm10",map.get("pm10"));
+ put("no2",map.get("no2"));
+ put("co",map.get("co"));
+ put("so2",map.get("so2"));
+ put("o3",map.get("o3"));
+ put("VOCs",map.get("VOCs"));
+// put("pho", map.get("pho"));
+// put("pho1", map.get("pho1"));
+ put("name",map.get("name"));
+ put("type",map.get("type"));
+ put("detailList1", detailList1);
+ put("detailList2", detailList2);
+ put("detailList3", detailList3);
+ put("detailList4", detailList4);
+ put("detailList5", detailList5);
+ put("detailList6", detailList6);
+ put("detailList7", detailList7);
+ put("detailList8", detailList8);
+ put("picList1", pic1);
+ put("picList2", pic2);
+ put("picList3", pic3);
+ put("picList4", pic4);
+ put("picList5", pic5);
+ put("picList6", pic6);
+ put("picList7", pic7);
+ put("picList8", pic8);
+ }});
+ response.setContentType("multipart/form-data");
+ // ���������������
+ response.addHeader("Content-Disposition", "attachment;fileName=ce.docx" );
+// response.setHeader("Content-Disposition", "attachment; filename=\"" + name+type+"������������" + "\"");
+ response.setCharacterEncoding("UTF-8");
+ //���������������
+/* File file1 = new File("G:\\test\\test2.docx");
+ FileOutputStream out = new FileOutputStream(file1);
+ compile.write(out);*/
+ //���������������
+ OutputStream out = response.getOutputStream();
+ compile.write(out);
+ out.flush();
+ out.close();
+ compile.close();
+
+ }
-
-
- response.setContentType("multipart/form-data");
- // ���������������
- response.addHeader("Content-Disposition", "attachment;fileName=ce.docx" );
- response.setCharacterEncoding("UTF-8");
- //���������������
-// File file1 = new File("G:\\test\\test2.docx");
-// FileOutputStream out = new FileOutputStream(file1);
-// compile.write(out);
- //���������������
- OutputStream out = response.getOutputStream();
- compile.write(out);
- out.flush();
- out.close();
- compile.close();
} catch (IOException e) {
log.error ("������������������������������������������", e);
} catch (Exception e) {
--
Gitblit v1.8.0