|
|
@@ -14,46 +14,123 @@ package com.unis.equipmentOnlineRateAssessment.modular.monitorCamera.service.imp
|
|
14
|
14
|
|
|
15
|
15
|
import cn.hutool.core.bean.BeanUtil;
|
|
16
|
16
|
import cn.hutool.core.collection.CollStreamUtil;
|
|
|
17
|
+import cn.hutool.core.collection.CollectionUtil;
|
|
17
|
18
|
import cn.hutool.core.util.ObjectUtil;
|
|
18
|
|
-import cn.hutool.core.util.StrUtil;
|
|
|
19
|
+import com.alibaba.excel.EasyExcel;
|
|
|
20
|
+import com.alibaba.excel.write.style.column.SimpleColumnWidthStyleStrategy;
|
|
|
21
|
+import com.alibaba.excel.write.style.row.SimpleRowHeightStyleStrategy;
|
|
|
22
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
19
|
23
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
20
|
24
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
21
|
25
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
26
|
+import com.unis.basic.info.modular.orgInfo.mapper.OrgInfoMapper;
|
|
|
27
|
+import com.unis.common.page.CommonPageRequest;
|
|
|
28
|
+import com.unis.equipmentOnlineRateAssessment.modular.monitorCamera.param.*;
|
|
|
29
|
+import com.unis.equipmentOnlineRateAssessment.modular.monitorCamera.vo.CameraAndNvrDetailVO;
|
|
|
30
|
+import com.unis.equipmentOnlineRateAssessment.modular.monitorCamera.vo.StatisticalAnalysisPageVO;
|
|
|
31
|
+import com.unis.equipmentOnlineRateAssessment.modular.monitorCamera.vo.StatisticalAnalysisVO;
|
|
|
32
|
+import com.unis.equipmentOnlineRateAssessment.modular.monitorCamera.vo.CameraAndNvrVO;
|
|
|
33
|
+import com.unis.equipmentOnlineRateAssessment.modular.monitorNvr.entity.MonitorNvr;
|
|
|
34
|
+import com.unis.equipmentOnlineRateAssessment.modular.monitorNvr.mapper.MonitorNvrMapper;
|
|
|
35
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
22
|
36
|
import org.springframework.stereotype.Service;
|
|
23
|
37
|
import org.springframework.transaction.annotation.Transactional;
|
|
24
|
|
-import com.unis.common.enums.CommonSortOrderEnum;
|
|
25
|
38
|
import com.unis.common.exception.CommonException;
|
|
26
|
|
-import com.unis.common.page.CommonPageRequest;
|
|
27
|
39
|
import com.unis.equipmentOnlineRateAssessment.modular.monitorCamera.entity.MonitorCamera;
|
|
28
|
40
|
import com.unis.equipmentOnlineRateAssessment.modular.monitorCamera.mapper.MonitorCameraMapper;
|
|
29
|
|
-import com.unis.equipmentOnlineRateAssessment.modular.monitorCamera.param.MonitorCameraAddParam;
|
|
30
|
|
-import com.unis.equipmentOnlineRateAssessment.modular.monitorCamera.param.MonitorCameraEditParam;
|
|
31
|
|
-import com.unis.equipmentOnlineRateAssessment.modular.monitorCamera.param.MonitorCameraIdParam;
|
|
32
|
|
-import com.unis.equipmentOnlineRateAssessment.modular.monitorCamera.param.MonitorCameraPageParam;
|
|
33
|
41
|
import com.unis.equipmentOnlineRateAssessment.modular.monitorCamera.service.MonitorCameraService;
|
|
34
|
42
|
|
|
|
43
|
+import javax.xml.crypto.Data;
|
|
|
44
|
+import java.io.File;
|
|
|
45
|
+import java.text.SimpleDateFormat;
|
|
|
46
|
+import java.util.ArrayList;
|
|
|
47
|
+import java.util.Date;
|
|
35
|
48
|
import java.util.List;
|
|
|
49
|
+import java.util.stream.Collectors;
|
|
36
|
50
|
|
|
37
|
51
|
/**
|
|
38
|
52
|
* 摄像头基本信息表Service接口实现类
|
|
39
|
53
|
*
|
|
40
|
54
|
* @author hjc
|
|
41
|
|
- * @date 2024/06/21 10:07
|
|
|
55
|
+ * @date 2024/06/21 10:07
|
|
42
|
56
|
**/
|
|
43
|
57
|
@Service
|
|
44
|
58
|
public class MonitorCameraServiceImpl extends ServiceImpl<MonitorCameraMapper, MonitorCamera> implements MonitorCameraService {
|
|
45
|
59
|
|
|
|
60
|
+ @Autowired
|
|
|
61
|
+ private OrgInfoMapper orgInfoMapper;
|
|
|
62
|
+
|
|
|
63
|
+ @Autowired
|
|
|
64
|
+ private MonitorCameraMapper monitorCameraMapper;
|
|
|
65
|
+
|
|
|
66
|
+ @Autowired
|
|
|
67
|
+ private MonitorNvrMapper monitorNvrMapper;
|
|
|
68
|
+
|
|
46
|
69
|
@Override
|
|
47
|
|
- public Page<MonitorCamera> page(MonitorCameraPageParam monitorCameraPageParam) {
|
|
48
|
|
- QueryWrapper<MonitorCamera> queryWrapper = new QueryWrapper<>();
|
|
49
|
|
- if(ObjectUtil.isAllNotEmpty(monitorCameraPageParam.getSortField(), monitorCameraPageParam.getSortOrder())) {
|
|
50
|
|
- CommonSortOrderEnum.validate(monitorCameraPageParam.getSortOrder());
|
|
51
|
|
- queryWrapper.orderBy(true, monitorCameraPageParam.getSortOrder().equals(CommonSortOrderEnum.ASC.getValue()),
|
|
52
|
|
- StrUtil.toUnderlineCase(monitorCameraPageParam.getSortField()));
|
|
53
|
|
- } else {
|
|
54
|
|
- queryWrapper.lambda().orderByAsc(MonitorCamera::getId);
|
|
|
70
|
+ public Page<CameraAndNvrVO> page(MonitorCameraPageParam pageParam) {
|
|
|
71
|
+
|
|
|
72
|
+ Page<CameraAndNvrVO> page = new Page<>(pageParam.getCurrent(), pageParam.getSize());
|
|
|
73
|
+
|
|
|
74
|
+ switch (pageParam.getVariety() == null ? 3 : pageParam.getVariety()) {
|
|
|
75
|
+ case 1:
|
|
|
76
|
+ page = findCamera(page, pageParam);
|
|
|
77
|
+ break;
|
|
|
78
|
+ case 2:
|
|
|
79
|
+ page = findNvr(pageParam, page);
|
|
|
80
|
+ break;
|
|
|
81
|
+ default:
|
|
|
82
|
+ page = findAll(pageParam, page);
|
|
|
83
|
+
|
|
55
|
84
|
}
|
|
56
|
|
- return this.page(CommonPageRequest.defaultPage(), queryWrapper);
|
|
|
85
|
+ return page;
|
|
|
86
|
+
|
|
|
87
|
+ }
|
|
|
88
|
+
|
|
|
89
|
+ private Page<CameraAndNvrVO> findAll(MonitorCameraPageParam pageParam, Page<CameraAndNvrVO> page) {
|
|
|
90
|
+ List<MonitorCamera> monitorCameras = monitorCameraMapper.selectList(null);
|
|
|
91
|
+ List<MonitorNvr> monitorNvrs = monitorNvrMapper.selectList(null);
|
|
|
92
|
+ List<CameraAndNvrVO> cameraAndNvrVOS = new ArrayList<>();
|
|
|
93
|
+
|
|
|
94
|
+ for (MonitorCamera monitorCamera : monitorCameras) {
|
|
|
95
|
+ CameraAndNvrVO vo = new CameraAndNvrVO();
|
|
|
96
|
+ BeanUtil.copyProperties(monitorCamera, vo);
|
|
|
97
|
+ vo.setVariety(1);
|
|
|
98
|
+ cameraAndNvrVOS.add(vo);
|
|
|
99
|
+ }
|
|
|
100
|
+ for (MonitorNvr monitorNvr : monitorNvrs) {
|
|
|
101
|
+ CameraAndNvrVO vo = new CameraAndNvrVO();
|
|
|
102
|
+ BeanUtil.copyProperties(monitorNvr, vo);
|
|
|
103
|
+ vo.setVariety(2);
|
|
|
104
|
+ cameraAndNvrVOS.add(vo);
|
|
|
105
|
+ }
|
|
|
106
|
+ page.setRecords(cameraAndNvrVOS.subList(Math.min((pageParam.getCurrent() - 1) * pageParam.getSize(), cameraAndNvrVOS.size())
|
|
|
107
|
+ , Math.min(pageParam.getCurrent() * pageParam.getSize(), cameraAndNvrVOS.size())));
|
|
|
108
|
+ page.setTotal(cameraAndNvrVOS.size());
|
|
|
109
|
+ return page;
|
|
|
110
|
+ }
|
|
|
111
|
+
|
|
|
112
|
+ private Page<CameraAndNvrVO> findNvr(MonitorCameraPageParam pageParam, Page<CameraAndNvrVO> list) {
|
|
|
113
|
+ list = monitorNvrMapper.findNvr(list, pageParam.getName());
|
|
|
114
|
+ List<CameraAndNvrVO> records = list.getRecords();
|
|
|
115
|
+ if (CollectionUtil.isNotEmpty(records)) {
|
|
|
116
|
+ for (CameraAndNvrVO CameraAndNvrVO : records) {
|
|
|
117
|
+ CameraAndNvrVO.setVariety(2);
|
|
|
118
|
+ }
|
|
|
119
|
+ }
|
|
|
120
|
+
|
|
|
121
|
+ return list;
|
|
|
122
|
+ }
|
|
|
123
|
+
|
|
|
124
|
+
|
|
|
125
|
+ private Page<CameraAndNvrVO> findCamera(Page<CameraAndNvrVO> list, MonitorCameraPageParam pageParam) {
|
|
|
126
|
+ list = monitorCameraMapper.findcamera(list, pageParam.getName());
|
|
|
127
|
+ List<CameraAndNvrVO> records = list.getRecords();
|
|
|
128
|
+ if (CollectionUtil.isNotEmpty(records)) {
|
|
|
129
|
+ for (CameraAndNvrVO monitorCamera : records) {
|
|
|
130
|
+ monitorCamera.setVariety(1);
|
|
|
131
|
+ }
|
|
|
132
|
+ }
|
|
|
133
|
+ return list;
|
|
57
|
134
|
}
|
|
58
|
135
|
|
|
59
|
136
|
@Transactional(rollbackFor = Exception.class)
|
|
|
@@ -79,16 +156,75 @@ public class MonitorCameraServiceImpl extends ServiceImpl<MonitorCameraMapper, M
|
|
79
|
156
|
}
|
|
80
|
157
|
|
|
81
|
158
|
@Override
|
|
82
|
|
- public MonitorCamera detail(MonitorCameraIdParam monitorCameraIdParam) {
|
|
83
|
|
- return this.queryEntity(monitorCameraIdParam.getId());
|
|
|
159
|
+ public CameraAndNvrDetailVO detail(MonitorCameraDetailParam detailParam) {
|
|
|
160
|
+
|
|
|
161
|
+ CameraAndNvrDetailVO vo = new CameraAndNvrDetailVO();
|
|
|
162
|
+ if (detailParam.getVariety() == 1) {
|
|
|
163
|
+ //摄像头
|
|
|
164
|
+ MonitorCamera monitorCamera = this.queryEntity(detailParam.getId());
|
|
|
165
|
+ BeanUtil.copyProperties(monitorCamera, vo);
|
|
|
166
|
+ vo.setVariety(1);
|
|
|
167
|
+
|
|
|
168
|
+ } else if (detailParam.getVariety() == 2) {
|
|
|
169
|
+ //NVR
|
|
|
170
|
+ MonitorNvr monitorNvr = monitorNvrMapper.selectById(detailParam.getId());
|
|
|
171
|
+ BeanUtil.copyProperties(monitorNvr, vo);
|
|
|
172
|
+ vo.setModelNumber(monitorNvr.getModelNum());
|
|
|
173
|
+ vo.setSubnetmask(monitorNvr.getSubnetMask());
|
|
|
174
|
+ vo.setVariety(2);
|
|
|
175
|
+ }
|
|
|
176
|
+
|
|
|
177
|
+ return vo;
|
|
84
|
178
|
}
|
|
85
|
179
|
|
|
86
|
180
|
@Override
|
|
87
|
181
|
public MonitorCamera queryEntity(Integer id) {
|
|
88
|
182
|
MonitorCamera monitorCamera = this.getById(id);
|
|
89
|
|
- if(ObjectUtil.isEmpty(monitorCamera)) {
|
|
|
183
|
+ if (ObjectUtil.isEmpty(monitorCamera)) {
|
|
90
|
184
|
throw new CommonException("摄像头基本信息表不存在,id值为:{}", id);
|
|
91
|
185
|
}
|
|
92
|
186
|
return monitorCamera;
|
|
93
|
187
|
}
|
|
|
188
|
+
|
|
|
189
|
+
|
|
|
190
|
+ /**
|
|
|
191
|
+ * 在线统计分析-分页
|
|
|
192
|
+ *
|
|
|
193
|
+ * @author hjc
|
|
|
194
|
+ * @date 2024/06/21 10:07
|
|
|
195
|
+ */
|
|
|
196
|
+ @Override
|
|
|
197
|
+ public Page<StatisticalAnalysisPageVO> statisticalAnalysisPage(StatisticalAnalysisPageParam pageParam) {
|
|
|
198
|
+
|
|
|
199
|
+ Page<StatisticalAnalysisPageVO> page = new Page<>(pageParam.getCurrent(), pageParam.getSize());
|
|
|
200
|
+ return orgInfoMapper.statisticalAnalysisPage(page, pageParam.getZcdzCityName());
|
|
|
201
|
+
|
|
|
202
|
+ }
|
|
|
203
|
+
|
|
|
204
|
+
|
|
|
205
|
+ /**
|
|
|
206
|
+ * 在线统计分析-导出
|
|
|
207
|
+ *
|
|
|
208
|
+ * @author hjc
|
|
|
209
|
+ * @date 2024/06/21 10:07
|
|
|
210
|
+ */
|
|
|
211
|
+ @Override
|
|
|
212
|
+ public void statisticalAnalysisExport() {
|
|
|
213
|
+ //TODO 路径改变
|
|
|
214
|
+ String path = "D://";
|
|
|
215
|
+ File folder = new File(path);
|
|
|
216
|
+ if (!folder.isDirectory()) {
|
|
|
217
|
+ folder.mkdirs();
|
|
|
218
|
+ }
|
|
|
219
|
+
|
|
|
220
|
+ SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd");
|
|
|
221
|
+ String dateStr = format.format(new Date());
|
|
|
222
|
+ String fileName = path + dateStr + "设备在线率考核统计分析" + ".xlsx";
|
|
|
223
|
+
|
|
|
224
|
+ EasyExcel.write(fileName, StatisticalAnalysisVO.class)
|
|
|
225
|
+ .sheet("设备在线率考核统计分析表")
|
|
|
226
|
+ .doWrite(orgInfoMapper.statisticalAnalysis());
|
|
|
227
|
+
|
|
|
228
|
+ }
|
|
|
229
|
+
|
|
94
|
230
|
}
|