Browse Source

导出修改

hjc 5 months ago
parent
commit
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
 import com.unis.equipmentOnlineRateAssessment.modular.monitorCamera.vo.*;
19
 import com.unis.equipmentOnlineRateAssessment.modular.monitorCamera.vo.*;
20
 import io.swagger.annotations.Api;
20
 import io.swagger.annotations.Api;
21
 import io.swagger.annotations.ApiOperation;
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
 import org.springframework.validation.annotation.Validated;
25
 import org.springframework.validation.annotation.Validated;
23
 import org.springframework.web.bind.annotation.GetMapping;
26
 import org.springframework.web.bind.annotation.GetMapping;
24
 import org.springframework.web.bind.annotation.PostMapping;
27
 import org.springframework.web.bind.annotation.PostMapping;
@@ -28,6 +31,7 @@ import com.unis.equipmentOnlineRateAssessment.modular.monitorCamera.entity.Monit
28
 import com.unis.equipmentOnlineRateAssessment.modular.monitorCamera.service.MonitorCameraService;
31
 import com.unis.equipmentOnlineRateAssessment.modular.monitorCamera.service.MonitorCameraService;
29
 
32
 
30
 import javax.annotation.Resource;
33
 import javax.annotation.Resource;
34
+import javax.servlet.http.HttpServletRequest;
31
 import javax.servlet.http.HttpServletResponse;
35
 import javax.servlet.http.HttpServletResponse;
32
 import javax.validation.Valid;
36
 import javax.validation.Valid;
33
 
37
 
@@ -46,6 +50,8 @@ public class MonitorCameraController {
46
     @Resource
50
     @Resource
47
     private MonitorCameraService monitorCameraService;
51
     private MonitorCameraService monitorCameraService;
48
 
52
 
53
+
54
+
49
     /**
55
     /**
50
      * 设备接入管理-分页
56
      * 设备接入管理-分页
51
      *
57
      *
@@ -137,19 +143,19 @@ public class MonitorCameraController {
137
         return CommonResult.data(monitorCameraService.statisticalAnalysisPage(pageParam));
143
         return CommonResult.data(monitorCameraService.statisticalAnalysisPage(pageParam));
138
     }
144
     }
139
 
145
 
140
-    /**
146
+   /* *//**
141
      * 在线统计分析-导出
147
      * 在线统计分析-导出
142
      *
148
      *
143
      * @author hjc
149
      * @author hjc
144
      * @date 2024/06/21 10:07
150
      * @date 2024/06/21 10:07
145
-     */
151
+     *//*
146
     @ApiOperationSupport(order = 4)
152
     @ApiOperationSupport(order = 4)
147
     @ApiOperation("在线统计分析-导出")
153
     @ApiOperation("在线统计分析-导出")
148
     //@SaCheckPermission("/equipmentOnlineRateAssessment/monitorCamera/page")
154
     //@SaCheckPermission("/equipmentOnlineRateAssessment/monitorCamera/page")
149
     @GetMapping("/equipmentOnlineRateAssessment/monitorCamera/statisticalAnalysisExport")
155
     @GetMapping("/equipmentOnlineRateAssessment/monitorCamera/statisticalAnalysisExport")
150
     public void statisticalAnalysisExport(String fileName, HttpServletResponse response) {
156
     public void statisticalAnalysisExport(String fileName, HttpServletResponse response) {
151
         monitorCameraService.statisticalAnalysisExport(fileName,response);
157
         monitorCameraService.statisticalAnalysisExport(fileName,response);
152
-    }
158
+    }*/
153
 
159
 
154
     /**
160
     /**
155
      * 在线巡检-分页
161
      * 在线巡检-分页
@@ -205,8 +211,8 @@ public class MonitorCameraController {
205
     @ApiOperation("自动考核-导出")
211
     @ApiOperation("自动考核-导出")
206
     //@SaCheckPermission("/equipmentOnlineRateAssessment/monitorCamera/page")
212
     //@SaCheckPermission("/equipmentOnlineRateAssessment/monitorCamera/page")
207
     @GetMapping("/equipmentOnlineRateAssessment/monitorCamera/AutomatedAssessmentsExport")
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
 package com.unis.equipmentOnlineRateAssessment.modular.monitorCamera.param;
1
 package com.unis.equipmentOnlineRateAssessment.modular.monitorCamera.param;
2
 
2
 
3
+import io.swagger.annotations.ApiModelProperty;
4
+import lombok.AllArgsConstructor;
3
 import lombok.Data;
5
 import lombok.Data;
6
+import lombok.NoArgsConstructor;
4
 import org.springframework.web.bind.annotation.ModelAttribute;
7
 import org.springframework.web.bind.annotation.ModelAttribute;
5
 
8
 
6
 import javax.servlet.http.HttpServlet;
9
 import javax.servlet.http.HttpServlet;
7
 import javax.servlet.http.HttpServletRequest;
10
 import javax.servlet.http.HttpServletRequest;
8
 import javax.servlet.http.HttpServletResponse;
11
 import javax.servlet.http.HttpServletResponse;
12
+import java.math.BigDecimal;
9
 
13
 
10
 /**
14
 /**
11
  * @author hjc
15
  * @author hjc
12
  * @date 2024/6/24 17:07
16
  * @date 2024/6/24 17:07
13
  */
17
  */
14
 @Data
18
 @Data
15
-public class AutomatedAssessmentsExportParam{
19
+@NoArgsConstructor
20
+@AllArgsConstructor
21
+public class AutomatedAssessmentsExportParam {
16
 
22
 
23
+    /** 文件名 */
24
+    @ApiModelProperty(value = "文件名", position = 1)
17
     private String fileName;
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
 import com.unis.equipmentOnlineRateAssessment.modular.monitorCamera.param.*;
18
 import com.unis.equipmentOnlineRateAssessment.modular.monitorCamera.param.*;
19
 import com.unis.equipmentOnlineRateAssessment.modular.monitorCamera.vo.*;
19
 import com.unis.equipmentOnlineRateAssessment.modular.monitorCamera.vo.*;
20
 
20
 
21
+import javax.servlet.http.HttpServletRequest;
21
 import javax.servlet.http.HttpServletResponse;
22
 import javax.servlet.http.HttpServletResponse;
22
 import java.util.List;
23
 import java.util.List;
23
 
24
 
@@ -125,6 +126,6 @@ public interface MonitorCameraService extends IService<MonitorCamera> {
125
      * @author hjc
126
      * @author hjc
126
      * @date 2024/06/21 10:07
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
 import cn.hutool.core.bean.BeanUtil;
15
 import cn.hutool.core.bean.BeanUtil;
16
 import cn.hutool.core.collection.CollStreamUtil;
16
 import cn.hutool.core.collection.CollStreamUtil;
17
 import cn.hutool.core.collection.CollectionUtil;
17
 import cn.hutool.core.collection.CollectionUtil;
18
-import cn.hutool.core.date.DateUnit;
19
-import cn.hutool.core.date.DateUtil;
20
 import cn.hutool.core.util.ObjectUtil;
18
 import cn.hutool.core.util.ObjectUtil;
21
 import com.alibaba.excel.EasyExcel;
19
 import com.alibaba.excel.EasyExcel;
22
 import com.alibaba.excel.support.ExcelTypeEnum;
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
 import com.baomidou.mybatisplus.core.toolkit.StringUtils;
21
 import com.baomidou.mybatisplus.core.toolkit.StringUtils;
28
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
22
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
29
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
23
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
30
 import com.unis.basic.info.modular.orgInfo.entity.OrgInfo;
24
 import com.unis.basic.info.modular.orgInfo.entity.OrgInfo;
31
 import com.unis.basic.info.modular.orgInfo.mapper.OrgInfoMapper;
25
 import com.unis.basic.info.modular.orgInfo.mapper.OrgInfoMapper;
32
-import com.unis.common.page.CommonPageRequest;
33
 import com.unis.equipmentOnlineRateAssessment.modular.monitorCamera.param.*;
26
 import com.unis.equipmentOnlineRateAssessment.modular.monitorCamera.param.*;
34
 import com.unis.equipmentOnlineRateAssessment.modular.monitorCamera.vo.*;
27
 import com.unis.equipmentOnlineRateAssessment.modular.monitorCamera.vo.*;
35
 import com.unis.equipmentOnlineRateAssessment.modular.monitorNvr.entity.MonitorNvr;
28
 import com.unis.equipmentOnlineRateAssessment.modular.monitorNvr.entity.MonitorNvr;
36
 import com.unis.equipmentOnlineRateAssessment.modular.monitorNvr.mapper.MonitorNvrMapper;
29
 import com.unis.equipmentOnlineRateAssessment.modular.monitorNvr.mapper.MonitorNvrMapper;
37
-import com.unis.statisticalReport.info.modular.grainTempCheck.entity.GrainTempExcel;
38
 import org.springframework.beans.factory.annotation.Autowired;
30
 import org.springframework.beans.factory.annotation.Autowired;
39
 import org.springframework.stereotype.Service;
31
 import org.springframework.stereotype.Service;
40
 import org.springframework.transaction.annotation.Transactional;
32
 import org.springframework.transaction.annotation.Transactional;
@@ -43,19 +35,15 @@ import com.unis.equipmentOnlineRateAssessment.modular.monitorCamera.entity.Monit
43
 import com.unis.equipmentOnlineRateAssessment.modular.monitorCamera.mapper.MonitorCameraMapper;
35
 import com.unis.equipmentOnlineRateAssessment.modular.monitorCamera.mapper.MonitorCameraMapper;
44
 import com.unis.equipmentOnlineRateAssessment.modular.monitorCamera.service.MonitorCameraService;
36
 import com.unis.equipmentOnlineRateAssessment.modular.monitorCamera.service.MonitorCameraService;
45
 
37
 
38
+import javax.servlet.http.HttpServletRequest;
46
 import javax.servlet.http.HttpServletResponse;
39
 import javax.servlet.http.HttpServletResponse;
47
-import javax.xml.crypto.Data;
48
-import java.io.File;
49
 import java.io.IOException;
40
 import java.io.IOException;
50
 import java.math.BigDecimal;
41
 import java.math.BigDecimal;
51
 import java.net.URLEncoder;
42
 import java.net.URLEncoder;
52
-import java.text.DecimalFormat;
53
-import java.text.SimpleDateFormat;
54
 import java.time.*;
43
 import java.time.*;
55
 import java.util.ArrayList;
44
 import java.util.ArrayList;
56
 import java.util.Date;
45
 import java.util.Date;
57
 import java.util.List;
46
 import java.util.List;
58
-import java.util.stream.Collectors;
59
 
47
 
60
 /**
48
 /**
61
  * 摄像头基本信息表Service接口实现类
49
  * 摄像头基本信息表Service接口实现类
@@ -75,6 +63,7 @@ public class MonitorCameraServiceImpl extends ServiceImpl<MonitorCameraMapper, M
75
     @Autowired
63
     @Autowired
76
     private MonitorNvrMapper monitorNvrMapper;
64
     private MonitorNvrMapper monitorNvrMapper;
77
 
65
 
66
+
78
     @Override
67
     @Override
79
     public Page<CameraAndNvrVO> page(MonitorCameraPageParam pageParam) {
68
     public Page<CameraAndNvrVO> page(MonitorCameraPageParam pageParam) {
80
 
69
 
@@ -350,21 +339,22 @@ public class MonitorCameraServiceImpl extends ServiceImpl<MonitorCameraMapper, M
350
      * @date 2024/06/21 10:07
339
      * @date 2024/06/21 10:07
351
      */
340
      */
352
     @Override
341
     @Override
353
-    public void AutomatedAssessmentsExport(String fileName, HttpServletResponse response) {
354
-
342
+    public void AutomatedAssessmentsExport(AutomatedAssessmentsExportParam param , HttpServletRequest request, HttpServletResponse response) {
355
         try {
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
             fileName = URLEncoder.encode(fileName, "UTF-8");
347
             fileName = URLEncoder.encode(fileName, "UTF-8");
359
             // 设置响应信息,让浏览器下载文件
348
             // 设置响应信息,让浏览器下载文件
360
-            response.setContentType("application/vnd.ms-excel");
349
+            response.setContentType("application/xml");
361
             response.setCharacterEncoding("utf-8");
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
             EasyExcel.write(response.getOutputStream()) // 或, GrainTempExcel.class
353
             EasyExcel.write(response.getOutputStream()) // 或, GrainTempExcel.class
364
                     .head(AutomatedAssessmentsExportVO.class) // write 中, GrainTempExcel.class 二选一
354
                     .head(AutomatedAssessmentsExportVO.class) // write 中, GrainTempExcel.class 二选一
365
                     .excelType(ExcelTypeEnum.XLSX)
355
                     .excelType(ExcelTypeEnum.XLSX)
366
                     .sheet(fileName)
356
                     .sheet(fileName)
367
-                    .doWrite(this::data);
357
+                    .doWrite(this.getData(param));
368
 
358
 
369
         } catch (IOException e) {
359
         } catch (IOException e) {
370
             log.error("自动考核导出异常:{}", e);
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
         AutomatedAssessmentsExportVO vo = new AutomatedAssessmentsExportVO();
378
         AutomatedAssessmentsExportVO vo = new AutomatedAssessmentsExportVO();
378
         //获取摄像头总数量
379
         //获取摄像头总数量
379
         Integer cameraAllNum = monitorCameraMapper.selectAll(null);
380
         Integer cameraAllNum = monitorCameraMapper.selectAll(null);
@@ -409,6 +410,6 @@ public class MonitorCameraServiceImpl extends ServiceImpl<MonitorCameraMapper, M
409
         list.add(vo);
410
         list.add(vo);
410
 
411
 
411
         return list;
412
         return list;
412
-    }
413
+    }*/
413
 
414
 
414
 }
415
 }