|
@@ -19,10 +19,12 @@ import cn.hutool.core.date.DateUnit;
|
19
|
19
|
import cn.hutool.core.date.DateUtil;
|
20
|
20
|
import cn.hutool.core.util.ObjectUtil;
|
21
|
21
|
import com.alibaba.excel.EasyExcel;
|
|
22
|
+import com.alibaba.excel.support.ExcelTypeEnum;
|
22
|
23
|
import com.alibaba.excel.write.style.column.SimpleColumnWidthStyleStrategy;
|
23
|
24
|
import com.alibaba.excel.write.style.row.SimpleRowHeightStyleStrategy;
|
24
|
25
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
25
|
26
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
27
|
+import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
26
|
28
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
27
|
29
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
28
|
30
|
import com.unis.basic.info.modular.orgInfo.entity.OrgInfo;
|
|
@@ -32,6 +34,7 @@ import com.unis.equipmentOnlineRateAssessment.modular.monitorCamera.param.*;
|
32
|
34
|
import com.unis.equipmentOnlineRateAssessment.modular.monitorCamera.vo.*;
|
33
|
35
|
import com.unis.equipmentOnlineRateAssessment.modular.monitorNvr.entity.MonitorNvr;
|
34
|
36
|
import com.unis.equipmentOnlineRateAssessment.modular.monitorNvr.mapper.MonitorNvrMapper;
|
|
37
|
+import com.unis.statisticalReport.info.modular.grainTempCheck.entity.GrainTempExcel;
|
35
|
38
|
import org.springframework.beans.factory.annotation.Autowired;
|
36
|
39
|
import org.springframework.stereotype.Service;
|
37
|
40
|
import org.springframework.transaction.annotation.Transactional;
|
|
@@ -40,15 +43,15 @@ import com.unis.equipmentOnlineRateAssessment.modular.monitorCamera.entity.Monit
|
40
|
43
|
import com.unis.equipmentOnlineRateAssessment.modular.monitorCamera.mapper.MonitorCameraMapper;
|
41
|
44
|
import com.unis.equipmentOnlineRateAssessment.modular.monitorCamera.service.MonitorCameraService;
|
42
|
45
|
|
|
46
|
+import javax.servlet.http.HttpServletResponse;
|
43
|
47
|
import javax.xml.crypto.Data;
|
44
|
48
|
import java.io.File;
|
|
49
|
+import java.io.IOException;
|
45
|
50
|
import java.math.BigDecimal;
|
|
51
|
+import java.net.URLEncoder;
|
46
|
52
|
import java.text.DecimalFormat;
|
47
|
53
|
import java.text.SimpleDateFormat;
|
48
|
|
-import java.time.Instant;
|
49
|
|
-import java.time.LocalDateTime;
|
50
|
|
-import java.time.LocalTime;
|
51
|
|
-import java.time.ZoneId;
|
|
54
|
+import java.time.*;
|
52
|
55
|
import java.util.ArrayList;
|
53
|
56
|
import java.util.Date;
|
54
|
57
|
import java.util.List;
|
|
@@ -215,22 +218,25 @@ public class MonitorCameraServiceImpl extends ServiceImpl<MonitorCameraMapper, M
|
215
|
218
|
* @date 2024/06/21 10:07
|
216
|
219
|
*/
|
217
|
220
|
@Override
|
218
|
|
- public void statisticalAnalysisExport() {
|
219
|
|
- //TODO 路径改变
|
220
|
|
- String path = "D://";
|
221
|
|
- File folder = new File(path);
|
222
|
|
- if (!folder.isDirectory()) {
|
223
|
|
- folder.mkdirs();
|
|
221
|
+ public void statisticalAnalysisExport(String fileName, HttpServletResponse response) {
|
|
222
|
+
|
|
223
|
+ try {
|
|
224
|
+ if (StringUtils.isEmpty(fileName))
|
|
225
|
+ fileName = LocalDate.now()+"在线统计分析表";
|
|
226
|
+ fileName = URLEncoder.encode(fileName, "UTF-8");
|
|
227
|
+ // 设置响应信息,让浏览器下载文件
|
|
228
|
+ response.setContentType("application/vnd.ms-excel");
|
|
229
|
+ response.setCharacterEncoding("utf-8");
|
|
230
|
+ response.setHeader("Content-disposition", "attachment;filename=" + fileName + ExcelTypeEnum.XLSX.getValue());
|
|
231
|
+ EasyExcel.write(response.getOutputStream()) // 或, GrainTempExcel.class
|
|
232
|
+ .head(StatisticalAnalysisVO.class) // write 中, GrainTempExcel.class 二选一
|
|
233
|
+ .excelType(ExcelTypeEnum.XLSX)
|
|
234
|
+ .sheet(fileName)
|
|
235
|
+ .doWrite(orgInfoMapper.statisticalAnalysis());
|
|
236
|
+ } catch (IOException e) {
|
|
237
|
+ log.error("在线统计分析导出异常:{}",e);
|
|
238
|
+ throw new RuntimeException(e);
|
224
|
239
|
}
|
225
|
|
-
|
226
|
|
- SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd");
|
227
|
|
- String dateStr = format.format(new Date());
|
228
|
|
- String fileName = path + dateStr + "设备在线率考核统计分析" + ".xlsx";
|
229
|
|
-
|
230
|
|
- EasyExcel.write(fileName, StatisticalAnalysisVO.class)
|
231
|
|
- .sheet("设备在线率考核统计分析表")
|
232
|
|
- .doWrite(orgInfoMapper.statisticalAnalysis());
|
233
|
|
-
|
234
|
240
|
}
|
235
|
241
|
|
236
|
242
|
/**
|
|
@@ -344,19 +350,26 @@ public class MonitorCameraServiceImpl extends ServiceImpl<MonitorCameraMapper, M
|
344
|
350
|
* @date 2024/06/21 10:07
|
345
|
351
|
*/
|
346
|
352
|
@Override
|
347
|
|
- public void AutomatedAssessmentsExport() {
|
348
|
|
- String path = "D://";
|
349
|
|
- File folder = new File(path);
|
350
|
|
- if (!folder.isDirectory()) {
|
351
|
|
- folder.mkdirs();
|
|
353
|
+ public void AutomatedAssessmentsExport(String fileName, HttpServletResponse response) {
|
|
354
|
+
|
|
355
|
+ try {
|
|
356
|
+ if (StringUtils.isEmpty(fileName))
|
|
357
|
+ fileName = LocalDate.now()+ "自动考核数据表";
|
|
358
|
+ fileName = URLEncoder.encode(fileName, "UTF-8");
|
|
359
|
+ // 设置响应信息,让浏览器下载文件
|
|
360
|
+ response.setContentType("application/vnd.ms-excel");
|
|
361
|
+ response.setCharacterEncoding("utf-8");
|
|
362
|
+ response.setHeader("Content-disposition", "attachment;filename=" + fileName + ExcelTypeEnum.XLSX.getValue());
|
|
363
|
+ EasyExcel.write(response.getOutputStream()) // 或, GrainTempExcel.class
|
|
364
|
+ .head(AutomatedAssessmentsExportVO.class) // write 中, GrainTempExcel.class 二选一
|
|
365
|
+ .excelType(ExcelTypeEnum.XLSX)
|
|
366
|
+ .sheet(fileName)
|
|
367
|
+ .doWrite(this::data);
|
|
368
|
+ } catch (IOException e) {
|
|
369
|
+ log.error("自动考核导出异常:{}",e);
|
|
370
|
+ throw new RuntimeException(e);
|
352
|
371
|
}
|
353
|
|
- SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd");
|
354
|
|
- String dateStr = format.format(new Date());
|
355
|
|
- String fileName = path + dateStr + "自动考核数据表" + ".xlsx";
|
356
|
372
|
|
357
|
|
- EasyExcel.write(fileName, AutomatedAssessmentsExportVO.class)
|
358
|
|
- .sheet("自动考核数据表")
|
359
|
|
- .doWrite(this::data);
|
360
|
373
|
}
|
361
|
374
|
|
362
|
375
|
private List<AutomatedAssessmentsExportVO> data() {
|