diff --git a/inspect-main/inspect-main-statistics/pom.xml b/inspect-main/inspect-main-statistics/pom.xml
index 00e7e18..3823500 100644
--- a/inspect-main/inspect-main-statistics/pom.xml
+++ b/inspect-main/inspect-main-statistics/pom.xml
@@ -39,5 +39,11 @@
com.inspect
inspect-base-swagger
+
+ com.inspect
+ inspect-main-task
+
+
+
\ No newline at end of file
diff --git a/inspect-main/inspect-main-statistics/src/main/java/com/inspect/statistics/controller/PatrolStatisticsController.java b/inspect-main/inspect-main-statistics/src/main/java/com/inspect/statistics/controller/PatrolStatisticsController.java
index ab6cfc2..ceff8ce 100644
--- a/inspect-main/inspect-main-statistics/src/main/java/com/inspect/statistics/controller/PatrolStatisticsController.java
+++ b/inspect-main/inspect-main-statistics/src/main/java/com/inspect/statistics/controller/PatrolStatisticsController.java
@@ -1,5 +1,6 @@
package com.inspect.statistics.controller;
+import cn.hutool.poi.excel.ExcelWriter;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.inspect.base.core.exception.ServiceException;
@@ -10,11 +11,13 @@ import com.inspect.base.core.web.domain.AjaxResult;
import com.inspect.base.core.web.page.TableDataInfo;
import com.inspect.common.log.annotation.Log;
import com.inspect.common.log.enums.BizType;
+import com.inspect.message.MessageUtils;
import com.inspect.statistics.domain.StatisticsPatrolResult;
import com.inspect.statistics.service.PatrolStatisticsService;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
+import java.net.URLEncoder;
import java.util.HashMap;
import java.util.List;
import javax.annotation.Resource;
@@ -22,6 +25,7 @@ import javax.servlet.http.HttpServletResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
@@ -35,6 +39,9 @@ public class PatrolStatisticsController extends BaseController {
@Resource
PatrolStatisticsService statisticsService;
+ @Autowired
+ MessageUtils messageUtils;
+
@GetMapping({"/list"})
public TableDataInfo queryPatrolResult(StatisticsPatrolResult result) {
this.statisticsService.verifyParam(result);
@@ -107,11 +114,30 @@ public class PatrolStatisticsController extends BaseController {
businessType = BizType.EXPORT
)
@GetMapping({"/export"})
- public void exportExcel(StatisticsPatrolResult result, HttpServletResponse response) throws UnsupportedEncodingException {
+ public void exportExcel(StatisticsPatrolResult result, HttpServletResponse response) throws IOException {
this.statisticsService.verifyParam(result);
List patrolResults = this.statisticsService.queryPatrolResultMulti(result);
- ExcelUtil util = new ExcelUtil<>(StatisticsPatrolResult.class);
- util.exportExcelWithFileName(response, patrolResults, "巡视结果", "数据对比分析");
+// ExcelUtil util = new ExcelUtil<>(StatisticsPatrolResult.class);
+// util.exportExcelWithFileName(response, patrolResults, "巡视结果", "数据对比分析");
+ ExcelWriter writer = new ExcelWriter();
+ String[] configColArr = new String[]{"deviceName", "time", "value", "patrolStatus", "checkResult"};
+ HashMap colMap = this.statisticsService.colMap();
+ for (String col : configColArr) {
+ if (StringUtils.isNotBlank(colMap.get(col))) {
+ writer.addHeaderAlias(col, colMap.get(col));
+ }
+ }
+
+ long now = System.currentTimeMillis();
+ String filename = messageUtils.get("巡视结果") + "_" + messageUtils.get("数据对比分析") + "_" + now;
+ filename = URLEncoder.encode(filename, "utf8");
+ response.setContentType("application/vnd.ms-excel;charset=utf-8");
+ response.setHeader("Content-Disposition", "attachment;filename=" + filename + ".xls");
+ response.setCharacterEncoding("utf-8");
+ writer.setOnlyAlias(true);
+ writer.write(patrolResults, true);
+ writer.flush(response.getOutputStream());
+ writer.close();
}
@Log(
@@ -120,9 +146,90 @@ public class PatrolStatisticsController extends BaseController {
)
@GetMapping({"/configExport"})
public void configExport(StatisticsPatrolResult result, HttpServletResponse response) throws IOException {
+ logger.info("----------自定义字段导出,result:{}", result);
this.statisticsService.verifyParam(result);
List patrolResults = this.statisticsService.queryPatrolResultMultiExport(result);
+ for (StatisticsPatrolResult patrolResult : patrolResults) {
+ String dataType = patrolResult.getDataType();
+ if ("1".equals(dataType)) {
+ patrolResult.setDataType(messageUtils.get("摄像机"));
+ } else if ("2".equals(dataType)) {
+ patrolResult.setDataType(messageUtils.get("机器人"));
+ } else if ("3".equals(dataType)) {
+ patrolResult.setDataType(messageUtils.get("无人机"));
+ } else if ("4".equals(dataType)) {
+ patrolResult.setDataType(messageUtils.get("声纹"));
+ } else if ("5".equals(dataType)) {
+ patrolResult.setDataType(messageUtils.get("在线监测"));
+ }
+
+ String recognitionType = patrolResult.getRecognitionType();
+ if (StringUtils.isNotEmpty(recognitionType)) {
+ if ("1".equals(recognitionType)) {
+ patrolResult.setRecognitionType(messageUtils.get("表计读取"));
+ } else if ("2".equals(recognitionType)) {
+ patrolResult.setRecognitionType(messageUtils.get("位置状态识别"));
+ } else if ("4".equals(recognitionType)) {
+ patrolResult.setRecognitionType(messageUtils.get("红外测温"));
+ } else if ("52".equals(recognitionType)) {
+ patrolResult.setRecognitionType(messageUtils.get("仪表读数"));
+ } else if ("118".equals(recognitionType)) {
+ patrolResult.setRecognitionType(messageUtils.get("形变"));
+ } else if ("119".equals(recognitionType)) {
+ patrolResult.setRecognitionType(messageUtils.get("红外1800"));
+ } else if ("120".equals(recognitionType)) {
+ patrolResult.setRecognitionType(messageUtils.get("无人机红外"));
+ } else if ("121".equals(recognitionType)) {
+ patrolResult.setRecognitionType(messageUtils.get("摄像头红外"));
+ } else if ("122".equals(recognitionType)) {
+ patrolResult.setRecognitionType(messageUtils.get("摄像头红外灰度反算"));
+ }
+ }
+
+ Integer patrolStatus = patrolResult.getPatrolStatus();
+ if (patrolStatus != null) {
+ if (patrolStatus == 0) {
+ patrolResult.setPatrolStatusName(messageUtils.get("未审核"));
+ } else if (patrolStatus == 1) {
+ patrolResult.setPatrolStatusName(messageUtils.get("已审核"));
+ }
+ }
+
+ String fileType = patrolResult.getFileType();
+ if (StringUtils.isNotEmpty(fileType)) {
+ StringBuilder stringBuilder = new StringBuilder();
+ String[] fileTypeArr = fileType.split(",");
+ for (String s : fileTypeArr) {
+ if ("1".equals(s)) {
+ stringBuilder.append(messageUtils.get("红外图谱")).append(",");
+ } else if ("2".equals(s)) {
+ stringBuilder.append(messageUtils.get("可见光照片")).append(",");
+ } else if ("3".equals(s)) {
+ stringBuilder.append(messageUtils.get("音频")).append(",");
+ } else if ("4".equals(s)) {
+ stringBuilder.append(messageUtils.get("视频")).append(",");
+ }
+ }
+ String fileTypeStr = stringBuilder.toString();
+ if (fileTypeStr.endsWith(",")) {
+ fileTypeStr = fileTypeStr.substring(0, fileTypeStr.length() - 1);
+ }
+ patrolResult.setFileType(fileTypeStr);
+ }
+
+ String valid = patrolResult.getValid();
+ if (StringUtils.isNotEmpty(valid)) {
+ if ("0".equals(valid)) {
+ patrolResult.setValid(messageUtils.get("失败"));
+ } else if ("2".equals(valid)) {
+ patrolResult.setValid(messageUtils.get("成功"));
+ } else {
+ patrolResult.setValid(messageUtils.get("判别异常"));
+ }
+ }
+ }
this.statisticsService.configExport(patrolResults, result, response);
+
}
@GetMapping({"/colMap"})
diff --git a/inspect-main/inspect-main-statistics/src/main/java/com/inspect/statistics/service/impl/PatrolStatisticsServiceImpl.java b/inspect-main/inspect-main-statistics/src/main/java/com/inspect/statistics/service/impl/PatrolStatisticsServiceImpl.java
index b0114af..c6370fa 100644
--- a/inspect-main/inspect-main-statistics/src/main/java/com/inspect/statistics/service/impl/PatrolStatisticsServiceImpl.java
+++ b/inspect-main/inspect-main-statistics/src/main/java/com/inspect/statistics/service/impl/PatrolStatisticsServiceImpl.java
@@ -25,7 +25,9 @@ import javax.servlet.http.HttpServletResponse;
import org.apache.commons.lang3.ArrayUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
+import com.inspect.message.MessageUtils;
@Service
public class PatrolStatisticsServiceImpl implements PatrolStatisticsService {
@@ -33,6 +35,9 @@ public class PatrolStatisticsServiceImpl implements PatrolStatisticsService {
@Resource
StatisticsPatrolResultMapper resultMapper;
+ @Autowired
+ private MessageUtils messageUtils;
+
public List queryPatrolResult(StatisticsPatrolResult result) {
return this.resultMapper.queryPatrolResult(result);
}
@@ -175,7 +180,7 @@ public class PatrolStatisticsServiceImpl implements PatrolStatisticsService {
}
long now = System.currentTimeMillis();
- String filename = "巡视结果表格_" + now;
+ String filename = messageUtils.get("巡视结果") + now;
filename = URLEncoder.encode(filename, "utf8");
response.setContentType("application/vnd.ms-excel;charset=utf-8");
response.setHeader("Content-Disposition", "attachment;filename=" + filename + ".xls");
@@ -189,23 +194,23 @@ public class PatrolStatisticsServiceImpl implements PatrolStatisticsService {
public HashMap colMap() {
HashMap colMap = new HashMap<>();
- colMap.put("lineId", "巡视结果ID");
- colMap.put("patrolDeviceName", "巡视设备名称");
- colMap.put("patrolDeviceCode", "巡视设备编码");
- colMap.put("taskName", "任务名称");
- colMap.put("taskCode", "任务编码");
- colMap.put("deviceName", "设备点位");
- colMap.put("deviceId", "设备点位ID");
- colMap.put("value", "识别结果");
- colMap.put("value_unit", "识别结果带单位");
- colMap.put("time", "巡视时间");
- colMap.put("recognitionType", "识别类型");
- colMap.put("fileType", "识别结果");
- colMap.put("taskPatrolledId", "巡视任务执行ID");
- colMap.put("valid", "结论");
- colMap.put("patrolStatusName", "审核状态");
- colMap.put("checkResult", "审核结果");
- colMap.put("dataType", "巡视结果数据来源");
+ colMap.put("lineId", messageUtils.get("线路名称"));
+ colMap.put("patrolDeviceName", messageUtils.get("巡视设备名称"));
+ colMap.put("patrolDeviceCode", messageUtils.get("巡视设备编码"));
+ colMap.put("taskName", messageUtils.get("任务名称"));
+ colMap.put("taskCode", messageUtils.get("任务编码"));
+ colMap.put("deviceName", messageUtils.get("设备点位"));
+ colMap.put("deviceId", messageUtils.get("设备点位ID"));
+ colMap.put("value", messageUtils.get("识别结果"));
+ colMap.put("valueUnit", messageUtils.get("识别结果带单位"));
+ colMap.put("time", messageUtils.get("巡视时间"));
+ colMap.put("recognitionType", messageUtils.get("识别类型"));
+ colMap.put("fileType", messageUtils.get("文件类型"));
+ colMap.put("taskPatrolledId", messageUtils.get("巡视任务执行ID"));
+ colMap.put("valid", messageUtils.get("结论"));
+ colMap.put("patrolStatusName", messageUtils.get("归档状态"));
+ colMap.put("checkResult", messageUtils.get("审核结果"));
+ colMap.put("dataType", messageUtils.get("巡视结果数据来源"));
return colMap;
}
}
diff --git a/inspect-main/inspect-main-statistics/src/main/resources/mapper/PatrolResultMapper.xml b/inspect-main/inspect-main-statistics/src/main/resources/mapper/PatrolResultMapper.xml
index 6e1a32c..8ef2572 100644
--- a/inspect-main/inspect-main-statistics/src/main/resources/mapper/PatrolResultMapper.xml
+++ b/inspect-main/inspect-main-statistics/src/main/resources/mapper/PatrolResultMapper.xml
@@ -44,19 +44,38 @@
-
- select result.line_id,result.patrol_device_name,result.patrol_device_code,result.task_name,result.task_code,result.device_name,result.device_id,result.value_type,result.material_id,result.data_type,
+
+ select result.line_id,result.patrol_device_name,result.patrol_device_code,result.task_name,result.task_code,result.device_name,result.device_id,result.value_type,result.material_id,
+ case result.data_type when 1 then '摄像机' when 2 then '机器人' when 3 then '无人机' when 4 then '声纹' when 5 then '在线监测'else data_type end data_type,
result.value,result.value_unit,result.unit,result.time,result.check_result,
case result.recognition_type when 1 then '表计读取' when 2 then '位置状态识别' when 4 then '红外测温' end recognition_type,
- result.file_type,result.file_path,result.rectangle,result.task_patrolled_id,
+ case result.file_type when 1 then '红外图谱' when 2 then ' 可见光照片' when 3 then '音频' when 4 then '视频' else file_type end file_type,
+ result.file_path,result.rectangle,result.task_patrolled_id,
case result.valid when 0 then '失败' when 1 then '成功' when 2 then '判别异常' end valid,
- case result.patrol_status when 0 then '未审核' when 1 then '已审核' end patrolStatusName
+ case result.patrol_status when 0 then '未审核' when 1 then '已审核' end patrolStatusName,
+ result.patrol_status patrol_status
from basedata_patrolpoint point
left join patrol_result result
on point.patrol_point_id = result.device_id
+
+ select result.line_id,result.patrol_device_name,result.patrol_device_code,result.task_name,result.task_code,result.device_name,result.device_id,result.value_type,result.material_id,
+ result.data_type data_type,
+ result.value,result.value_unit,result.unit,result.time,result.check_result,
+ result.recognition_type recognition_type,
+ result.file_type file_type,
+ result.file_path,result.rectangle,result.task_patrolled_id,
+ result.valid valid,
+ result.patrol_status patrolStatusName,
+ result.patrol_status patrol_status
+ from basedata_patrolpoint point
+ left join patrol_result result
+ on point.patrol_point_id = result.device_id
+
+
+