浏览代码

导出修改

hjc 5 月之前
父节点
当前提交
db0a6da83a

+ 11 - 5
unis-plugin/unis-plugin-biz/src/main/java/com/unis/equipmentOnlineRateAssessment/modular/monitorCamera/controller/MonitorCameraController.java

@@ -19,6 +19,9 @@ import com.unis.equipmentOnlineRateAssessment.modular.monitorCamera.param.*;
19 19
 import com.unis.equipmentOnlineRateAssessment.modular.monitorCamera.vo.*;
20 20
 import io.swagger.annotations.Api;
21 21
 import io.swagger.annotations.ApiOperation;
22
+import org.hibernate.validator.constraints.URL;
23
+import org.mapstruct.Context;
24
+import org.springframework.beans.factory.annotation.Autowired;
22 25
 import org.springframework.validation.annotation.Validated;
23 26
 import org.springframework.web.bind.annotation.GetMapping;
24 27
 import org.springframework.web.bind.annotation.PostMapping;
@@ -28,6 +31,7 @@ import com.unis.equipmentOnlineRateAssessment.modular.monitorCamera.entity.Monit
28 31
 import com.unis.equipmentOnlineRateAssessment.modular.monitorCamera.service.MonitorCameraService;
29 32
 
30 33
 import javax.annotation.Resource;
34
+import javax.servlet.http.HttpServletRequest;
31 35
 import javax.servlet.http.HttpServletResponse;
32 36
 import javax.validation.Valid;
33 37
 
@@ -46,6 +50,8 @@ public class MonitorCameraController {
46 50
     @Resource
47 51
     private MonitorCameraService monitorCameraService;
48 52
 
53
+
54
+
49 55
     /**
50 56
      * 设备接入管理-分页
51 57
      *
@@ -137,19 +143,19 @@ public class MonitorCameraController {
137 143
         return CommonResult.data(monitorCameraService.statisticalAnalysisPage(pageParam));
138 144
     }
139 145
 
140
-    /**
146
+   /* *//**
141 147
      * 在线统计分析-导出
142 148
      *
143 149
      * @author hjc
144 150
      * @date 2024/06/21 10:07
145
-     */
151
+     *//*
146 152
     @ApiOperationSupport(order = 4)
147 153
     @ApiOperation("在线统计分析-导出")
148 154
     //@SaCheckPermission("/equipmentOnlineRateAssessment/monitorCamera/page")
149 155
     @GetMapping("/equipmentOnlineRateAssessment/monitorCamera/statisticalAnalysisExport")
150 156
     public void statisticalAnalysisExport(String fileName, HttpServletResponse response) {
151 157
         monitorCameraService.statisticalAnalysisExport(fileName,response);
152
-    }
158
+    }*/
153 159
 
154 160
     /**
155 161
      * 在线巡检-分页
@@ -205,8 +211,8 @@ public class MonitorCameraController {
205 211
     @ApiOperation("自动考核-导出")
206 212
     //@SaCheckPermission("/equipmentOnlineRateAssessment/monitorCamera/page")
207 213
     @GetMapping("/equipmentOnlineRateAssessment/monitorCamera/AutomatedAssessmentsExport")
208
-    public void AutomatedAssessmentsExport(AutomatedAssessmentsExportParam param) {
209
-        monitorCameraService.AutomatedAssessmentsExport(param.getFileName(), param.getResponse());
214
+    public void AutomatedAssessmentsExport(AutomatedAssessmentsExportParam param ,HttpServletRequest request,HttpServletResponse response) {
215
+        monitorCameraService.AutomatedAssessmentsExport(param,request,response);
210 216
 
211 217
     }
212 218
 

+ 33 - 2
unis-plugin/unis-plugin-biz/src/main/java/com/unis/equipmentOnlineRateAssessment/modular/monitorCamera/param/AutomatedAssessmentsExportParam.java

@@ -1,21 +1,52 @@
1 1
 package com.unis.equipmentOnlineRateAssessment.modular.monitorCamera.param;
2 2
 
3
+import io.swagger.annotations.ApiModelProperty;
4
+import lombok.AllArgsConstructor;
3 5
 import lombok.Data;
6
+import lombok.NoArgsConstructor;
4 7
 import org.springframework.web.bind.annotation.ModelAttribute;
5 8
 
6 9
 import javax.servlet.http.HttpServlet;
7 10
 import javax.servlet.http.HttpServletRequest;
8 11
 import javax.servlet.http.HttpServletResponse;
12
+import java.math.BigDecimal;
9 13
 
10 14
 /**
11 15
  * @author hjc
12 16
  * @date 2024/6/24 17:07
13 17
  */
14 18
 @Data
15
-public class AutomatedAssessmentsExportParam{
19
+@NoArgsConstructor
20
+@AllArgsConstructor
21
+public class AutomatedAssessmentsExportParam {
16 22
 
23
+    /** 文件名 */
24
+    @ApiModelProperty(value = "文件名", position = 1)
17 25
     private String fileName;
18 26
 
19
-    private HttpServletResponse response;
27
+    /** 摄像头总数量 */
28
+    @ApiModelProperty(value = "摄像头总数量", position = 1)
29
+    private Integer cameraAllNum;
30
+
31
+    /** 摄像头在线数量 */
32
+    @ApiModelProperty(value = "摄像头在线数量", position = 2)
33
+    private Integer cameraOnlineNum;
34
+
35
+    /** 摄像头离线数量 */
36
+    @ApiModelProperty(value = "摄像头离线数量", position = 3)
37
+    private Integer cameraOfflineNum;
38
+
39
+    /** 摄像头在线率 */
40
+    @ApiModelProperty(value = "摄像头在线率(%)", position = 4)
41
+    private BigDecimal cameraOnlineRate;
42
+
43
+    /** 摄像头在线率 */
44
+    @ApiModelProperty(value = "摄像头离线率(%)", position = 5)
45
+    private BigDecimal cameraOfflineRate;
46
+
47
+    /** NVR总数量 */
48
+    @ApiModelProperty(value = "NVR总数量", position = 6)
49
+    private Integer nvrAllNum;
50
+
20 51
 
21 52
 }

+ 2 - 1
unis-plugin/unis-plugin-biz/src/main/java/com/unis/equipmentOnlineRateAssessment/modular/monitorCamera/service/MonitorCameraService.java

@@ -18,6 +18,7 @@ import com.unis.equipmentOnlineRateAssessment.modular.monitorCamera.entity.Monit
18 18
 import com.unis.equipmentOnlineRateAssessment.modular.monitorCamera.param.*;
19 19
 import com.unis.equipmentOnlineRateAssessment.modular.monitorCamera.vo.*;
20 20
 
21
+import javax.servlet.http.HttpServletRequest;
21 22
 import javax.servlet.http.HttpServletResponse;
22 23
 import java.util.List;
23 24
 
@@ -125,6 +126,6 @@ public interface MonitorCameraService extends IService<MonitorCamera> {
125 126
      * @author hjc
126 127
      * @date 2024/06/21 10:07
127 128
      */
128
-    void AutomatedAssessmentsExport(String fileName, HttpServletResponse response);
129
+    void AutomatedAssessmentsExport(AutomatedAssessmentsExportParam param , HttpServletRequest request , HttpServletResponse response);
129 130
 
130 131
 }

+ 23 - 22
unis-plugin/unis-plugin-biz/src/main/java/com/unis/equipmentOnlineRateAssessment/modular/monitorCamera/service/impl/MonitorCameraServiceImpl.java

@@ -15,26 +15,18 @@ package com.unis.equipmentOnlineRateAssessment.modular.monitorCamera.service.imp
15 15
 import cn.hutool.core.bean.BeanUtil;
16 16
 import cn.hutool.core.collection.CollStreamUtil;
17 17
 import cn.hutool.core.collection.CollectionUtil;
18
-import cn.hutool.core.date.DateUnit;
19
-import cn.hutool.core.date.DateUtil;
20 18
 import cn.hutool.core.util.ObjectUtil;
21 19
 import com.alibaba.excel.EasyExcel;
22 20
 import com.alibaba.excel.support.ExcelTypeEnum;
23
-import com.alibaba.excel.write.style.column.SimpleColumnWidthStyleStrategy;
24
-import com.alibaba.excel.write.style.row.SimpleRowHeightStyleStrategy;
25
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
26
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
27 21
 import com.baomidou.mybatisplus.core.toolkit.StringUtils;
28 22
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
29 23
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
30 24
 import com.unis.basic.info.modular.orgInfo.entity.OrgInfo;
31 25
 import com.unis.basic.info.modular.orgInfo.mapper.OrgInfoMapper;
32
-import com.unis.common.page.CommonPageRequest;
33 26
 import com.unis.equipmentOnlineRateAssessment.modular.monitorCamera.param.*;
34 27
 import com.unis.equipmentOnlineRateAssessment.modular.monitorCamera.vo.*;
35 28
 import com.unis.equipmentOnlineRateAssessment.modular.monitorNvr.entity.MonitorNvr;
36 29
 import com.unis.equipmentOnlineRateAssessment.modular.monitorNvr.mapper.MonitorNvrMapper;
37
-import com.unis.statisticalReport.info.modular.grainTempCheck.entity.GrainTempExcel;
38 30
 import org.springframework.beans.factory.annotation.Autowired;
39 31
 import org.springframework.stereotype.Service;
40 32
 import org.springframework.transaction.annotation.Transactional;
@@ -43,19 +35,15 @@ import com.unis.equipmentOnlineRateAssessment.modular.monitorCamera.entity.Monit
43 35
 import com.unis.equipmentOnlineRateAssessment.modular.monitorCamera.mapper.MonitorCameraMapper;
44 36
 import com.unis.equipmentOnlineRateAssessment.modular.monitorCamera.service.MonitorCameraService;
45 37
 
38
+import javax.servlet.http.HttpServletRequest;
46 39
 import javax.servlet.http.HttpServletResponse;
47
-import javax.xml.crypto.Data;
48
-import java.io.File;
49 40
 import java.io.IOException;
50 41
 import java.math.BigDecimal;
51 42
 import java.net.URLEncoder;
52
-import java.text.DecimalFormat;
53
-import java.text.SimpleDateFormat;
54 43
 import java.time.*;
55 44
 import java.util.ArrayList;
56 45
 import java.util.Date;
57 46
 import java.util.List;
58
-import java.util.stream.Collectors;
59 47
 
60 48
 /**
61 49
  * 摄像头基本信息表Service接口实现类
@@ -75,6 +63,7 @@ public class MonitorCameraServiceImpl extends ServiceImpl<MonitorCameraMapper, M
75 63
     @Autowired
76 64
     private MonitorNvrMapper monitorNvrMapper;
77 65
 
66
+
78 67
     @Override
79 68
     public Page<CameraAndNvrVO> page(MonitorCameraPageParam pageParam) {
80 69
 
@@ -350,21 +339,22 @@ public class MonitorCameraServiceImpl extends ServiceImpl<MonitorCameraMapper, M
350 339
      * @date 2024/06/21 10:07
351 340
      */
352 341
     @Override
353
-    public void AutomatedAssessmentsExport(String fileName, HttpServletResponse response) {
354
-
342
+    public void AutomatedAssessmentsExport(AutomatedAssessmentsExportParam param , HttpServletRequest request, HttpServletResponse response) {
355 343
         try {
356
-            if (StringUtils.isEmpty(fileName))
357
-                fileName = LocalDate.now().toString();
344
+            String fileName = param.getFileName();
345
+            if (StringUtils.isEmpty(fileName));
346
+            fileName = LocalDate.now().toString();
358 347
             fileName = URLEncoder.encode(fileName, "UTF-8");
359 348
             // 设置响应信息,让浏览器下载文件
360
-            response.setContentType("application/vnd.ms-excel");
349
+            response.setContentType("application/xml");
361 350
             response.setCharacterEncoding("utf-8");
362
-            response.setHeader("Content-disposition", "attachment;filename=" + fileName + ExcelTypeEnum.XLSX.getValue());
351
+            response.setHeader("Content-Disposition", "attachment;filename=" + fileName + ExcelTypeEnum.XLSX.getValue());
352
+
363 353
             EasyExcel.write(response.getOutputStream()) // 或, GrainTempExcel.class
364 354
                     .head(AutomatedAssessmentsExportVO.class) // write 中, GrainTempExcel.class 二选一
365 355
                     .excelType(ExcelTypeEnum.XLSX)
366 356
                     .sheet(fileName)
367
-                    .doWrite(this::data);
357
+                    .doWrite(this.getData(param));
368 358
 
369 359
         } catch (IOException e) {
370 360
             log.error("自动考核导出异常:{}", e);
@@ -373,7 +363,18 @@ public class MonitorCameraServiceImpl extends ServiceImpl<MonitorCameraMapper, M
373 363
 
374 364
     }
375 365
 
376
-    private List<AutomatedAssessmentsExportVO> data() {
366
+
367
+    private List<AutomatedAssessmentsExportVO> getData(AutomatedAssessmentsExportParam param){
368
+        AutomatedAssessmentsExportVO vo = new AutomatedAssessmentsExportVO();
369
+        List<AutomatedAssessmentsExportVO> list = new ArrayList<>();
370
+        BeanUtil.copyProperties(param,vo);
371
+        list.add(vo);
372
+
373
+        return list;
374
+    }
375
+
376
+
377
+/*    private List<AutomatedAssessmentsExportVO> data() {
377 378
         AutomatedAssessmentsExportVO vo = new AutomatedAssessmentsExportVO();
378 379
         //获取摄像头总数量
379 380
         Integer cameraAllNum = monitorCameraMapper.selectAll(null);
@@ -409,6 +410,6 @@ public class MonitorCameraServiceImpl extends ServiceImpl<MonitorCameraMapper, M
409 410
         list.add(vo);
410 411
 
411 412
         return list;
412
-    }
413
+    }*/
413 414
 
414 415
 }