提交到处修改
This commit is contained in:
5
pom.xml
5
pom.xml
@@ -149,6 +149,11 @@
|
||||
</dependency>
|
||||
|
||||
<!-- excel工具 -->
|
||||
<dependency>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi</artifactId>
|
||||
<version>${poi.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi-ooxml</artifactId>
|
||||
|
||||
@@ -62,6 +62,8 @@ public class DutyController extends BaseController
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, Duty duty)
|
||||
{
|
||||
SysUser user = getLoginUser().getUser();
|
||||
duty.setTenantId(user.getDeptId());
|
||||
List<Duty> list = dutyService.selectDutyList(duty);
|
||||
ExcelUtil<Duty> util = new ExcelUtil<Duty>(Duty.class);
|
||||
util.exportExcel(response, list, "值班管理数据");
|
||||
|
||||
@@ -42,7 +42,7 @@ public class DutyRecordController extends BaseController
|
||||
/**
|
||||
* 查询交班记录列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('itsm:dutyRecord:list')")
|
||||
//@PreAuthorize("@ss.hasPermi('itsm:dutyRecord:list')")
|
||||
@GetMapping("/list")
|
||||
@ApiOperation("查询交班记录列表")
|
||||
public TableDataInfo list(DutyRecord dutyRecord)
|
||||
@@ -62,6 +62,8 @@ public class DutyRecordController extends BaseController
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, DutyRecord dutyRecord)
|
||||
{
|
||||
SysUser user = getLoginUser().getUser();
|
||||
dutyRecord.setTenantId(user.getDeptId());
|
||||
List<DutyRecord> list = dutyRecordService.selectDutyRecordList(dutyRecord);
|
||||
ExcelUtil<DutyRecord> util = new ExcelUtil<DutyRecord>(DutyRecord.class);
|
||||
util.exportExcel(response, list, "交班记录数据");
|
||||
|
||||
@@ -60,6 +60,8 @@ public class ExampleReportController extends BaseController
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, ExampleReport exampleReport)
|
||||
{
|
||||
SysUser user = getLoginUser().getUser();
|
||||
exampleReport.setTenantId(user.getDeptId());
|
||||
List<ExampleReport> list = exampleReportService.selectExampleReportList(exampleReport);
|
||||
ExcelUtil<ExampleReport> util = new ExcelUtil<ExampleReport>(ExampleReport.class);
|
||||
util.exportExcel(response, list, "例报管理数据");
|
||||
|
||||
@@ -62,6 +62,8 @@ public class InspectionPlanController extends BaseController
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, InspectionPlan inspectionPlan)
|
||||
{
|
||||
SysUser user = getLoginUser().getUser();
|
||||
inspectionPlan.setTenantId(user.getDeptId());
|
||||
List<InspectionPlan> list = inspectionPlanService.selectInspectionPlanList(inspectionPlan);
|
||||
ExcelUtil<InspectionPlan> util = new ExcelUtil<InspectionPlan>(InspectionPlan.class);
|
||||
util.exportExcel(response, list, "巡检计划数据");
|
||||
|
||||
@@ -62,6 +62,8 @@ public class InspectionRecordController extends BaseController
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, InspectionRecord inspectionRecord)
|
||||
{
|
||||
SysUser user = getLoginUser().getUser();
|
||||
inspectionRecord.setTenantId(user.getDeptId());
|
||||
List<InspectionRecord> list = inspectionRecordService.selectInspectionRecordList(inspectionRecord);
|
||||
ExcelUtil<InspectionRecord> util = new ExcelUtil<InspectionRecord>(InspectionRecord.class);
|
||||
util.exportExcel(response, list, "巡检记录数据");
|
||||
|
||||
@@ -62,6 +62,8 @@ public class PrePlanController extends BaseController
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, PrePlan prePlan)
|
||||
{
|
||||
SysUser user = getLoginUser().getUser();
|
||||
prePlan.setTenantId(user.getDeptId());
|
||||
List<PrePlan> list = prePlanService.selectPrePlanList(prePlan);
|
||||
ExcelUtil<PrePlan> util = new ExcelUtil<PrePlan>(PrePlan.class);
|
||||
util.exportExcel(response, list, "预案管理数据");
|
||||
|
||||
@@ -62,6 +62,8 @@ public class ProcessInfoController extends BaseController
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, ProcessInfo processInfo)
|
||||
{
|
||||
SysUser user = getLoginUser().getUser();
|
||||
processInfo.setTenantId(user.getDeptId());
|
||||
List<ProcessInfo> list = processInfoService.selectProcessInfoList(processInfo);
|
||||
ExcelUtil<ProcessInfo> util = new ExcelUtil<ProcessInfo>(ProcessInfo.class);
|
||||
util.exportExcel(response, list, "流程管理数据");
|
||||
|
||||
@@ -62,6 +62,8 @@ public class RegulationInfoController extends BaseController
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, RegulationInfo regulationInfo)
|
||||
{
|
||||
SysUser user = getLoginUser().getUser();
|
||||
regulationInfo.setTenantId(user.getDeptId());
|
||||
List<RegulationInfo> list = regulationInfoService.selectRegulationInfoList(regulationInfo);
|
||||
ExcelUtil<RegulationInfo> util = new ExcelUtil<RegulationInfo>(RegulationInfo.class);
|
||||
util.exportExcel(response, list, "制度管理数据");
|
||||
|
||||
@@ -62,6 +62,8 @@ public class RepairOrderController extends BaseController
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, RepairOrder repairOrder)
|
||||
{
|
||||
SysUser user = getLoginUser().getUser();
|
||||
repairOrder.setTenantId(user.getDeptId());
|
||||
List<RepairOrder> list = repairOrderService.selectRepairOrderList(repairOrder);
|
||||
ExcelUtil<RepairOrder> util = new ExcelUtil<RepairOrder>(RepairOrder.class);
|
||||
util.exportExcel(response, list, "维修工单数据");
|
||||
|
||||
@@ -62,6 +62,8 @@ public class ScheduleController extends BaseController
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, Schedule schedule)
|
||||
{
|
||||
SysUser user = getLoginUser().getUser();
|
||||
schedule.setTenantId(user.getDeptId());
|
||||
List<Schedule> list = scheduleService.selectScheduleList(schedule);
|
||||
ExcelUtil<Schedule> util = new ExcelUtil<Schedule>(Schedule.class);
|
||||
util.exportExcel(response, list, "调度计划管理数据");
|
||||
|
||||
@@ -62,6 +62,8 @@ public class StandardInfoController extends BaseController
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, StandardInfo standardInfo)
|
||||
{
|
||||
SysUser user = getLoginUser().getUser();
|
||||
standardInfo.setTenantId(user.getDeptId());
|
||||
List<StandardInfo> list = standardInfoService.selectStandardInfoList(standardInfo);
|
||||
ExcelUtil<StandardInfo> util = new ExcelUtil<StandardInfo>(StandardInfo.class);
|
||||
util.exportExcel(response, list, "作业规范数据");
|
||||
|
||||
@@ -53,6 +53,6 @@ private static final long serialVersionUID = 1L;
|
||||
@ApiModelProperty("替班人员")
|
||||
private String relief;
|
||||
/** 租户id */
|
||||
@Excel(name = "租户id")
|
||||
// @Excel(name = "租户id")
|
||||
private Long tenantId;
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ private static final long serialVersionUID = 1L;
|
||||
private String dutyDate;
|
||||
|
||||
/** 值班人员id */
|
||||
@Excel(name = "值班人员id")
|
||||
// @Excel(name = "值班人员id")
|
||||
@ApiModelProperty("值班人员id")
|
||||
private Long onId;
|
||||
|
||||
@@ -45,7 +45,7 @@ private static final long serialVersionUID = 1L;
|
||||
|
||||
|
||||
/** 替班id */
|
||||
@Excel(name = "替班id")
|
||||
// @Excel(name = "替班id")
|
||||
@ApiModelProperty("替班id")
|
||||
private Long reId;
|
||||
/** 替班人员 */
|
||||
@@ -70,7 +70,7 @@ private static final long serialVersionUID = 1L;
|
||||
private String status;
|
||||
|
||||
/** 机构id */
|
||||
@Excel(name = "机构id")
|
||||
// @Excel(name = "机构id")
|
||||
@ApiModelProperty("机构id")
|
||||
private Long tenantId;
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ private static final long serialVersionUID = 1L;
|
||||
private String pushMethod;
|
||||
|
||||
/** 接收人id */
|
||||
@Excel(name = "接收人id")
|
||||
// @Excel(name = "接收人id")
|
||||
@ApiModelProperty("接收人id")
|
||||
private String userId;
|
||||
|
||||
@@ -67,7 +67,7 @@ private static final long serialVersionUID = 1L;
|
||||
@ApiModelProperty("结束日期")
|
||||
private Date endDate;
|
||||
/** 租户id */
|
||||
@Excel(name = "租户id")
|
||||
// @Excel(name = "租户id")
|
||||
private Long tenantId;
|
||||
|
||||
@Excel(name = "批阅状态", readConverterExp = "0=待批阅,1=已通过,2=未通过")
|
||||
@@ -77,4 +77,7 @@ private static final long serialVersionUID = 1L;
|
||||
@Excel(name = "批阅回复")
|
||||
@ApiModelProperty("批阅回复")
|
||||
private String reviewReply;
|
||||
|
||||
@ApiModelProperty("附件")
|
||||
private String fileUrl;
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ private static final long serialVersionUID = 1L;
|
||||
private String inspectionPerson;
|
||||
private String inspection;
|
||||
/** 巡检人id */
|
||||
@Excel(name = "巡检人id")
|
||||
// @Excel(name = "巡检人id")
|
||||
@ApiModelProperty("巡检人id")
|
||||
private String userId;
|
||||
|
||||
@@ -82,9 +82,9 @@ private static final long serialVersionUID = 1L;
|
||||
@ApiModelProperty("状态")
|
||||
private String status;
|
||||
/** 租户id */
|
||||
@Excel(name = "租户id")
|
||||
// @Excel(name = "租户id")
|
||||
private Long tenantId;
|
||||
|
||||
@ApiModelProperty("图片")
|
||||
// @ApiModelProperty("图片")
|
||||
private String imgUrl;
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ private static final long serialVersionUID = 1L;
|
||||
private Long id;
|
||||
|
||||
/** 计划id */
|
||||
@Excel(name = "计划id")
|
||||
// @Excel(name = "计划id")
|
||||
@ApiModelProperty("计划id")
|
||||
private Long planId;
|
||||
|
||||
@@ -63,7 +63,7 @@ private static final long serialVersionUID = 1L;
|
||||
private String inspectionPerson;
|
||||
|
||||
/** 巡检人id */
|
||||
@Excel(name = "巡检人id")
|
||||
// @Excel(name = "巡检人id")
|
||||
@ApiModelProperty("巡检人id")
|
||||
private String userId;
|
||||
|
||||
@@ -88,7 +88,7 @@ private static final long serialVersionUID = 1L;
|
||||
private String inspectionRemark;
|
||||
|
||||
/** 租户id */
|
||||
@Excel(name = "租户id")
|
||||
// @Excel(name = "租户id")
|
||||
private Long tenantId;
|
||||
@ApiModelProperty("图片")
|
||||
private String imgUrl;
|
||||
|
||||
@@ -58,10 +58,10 @@ private static final long serialVersionUID = 1L;
|
||||
@ApiModelProperty("预案关键词")
|
||||
private String keywords;
|
||||
/** 租户id */
|
||||
@Excel(name = "租户id")
|
||||
// @Excel(name = "租户id")
|
||||
private Long tenantId;
|
||||
/** 预案关键词 */
|
||||
@Excel(name = "docOssId")
|
||||
// @Excel(name = "docOssId")
|
||||
@ApiModelProperty("docOssId")
|
||||
private String docOssId;
|
||||
}
|
||||
|
||||
@@ -51,6 +51,6 @@ private static final long serialVersionUID = 1L;
|
||||
@ApiModelProperty("处理人")
|
||||
private Long handlePerson;
|
||||
/** 租户id */
|
||||
@Excel(name = "租户id")
|
||||
// @Excel(name = "租户id")
|
||||
private Long tenantId;
|
||||
}
|
||||
|
||||
@@ -56,6 +56,6 @@ private static final long serialVersionUID = 1L;
|
||||
@ApiModelProperty("上传时间")
|
||||
private Date uploadTime;
|
||||
/** 租户id */
|
||||
@Excel(name = "租户id")
|
||||
// @Excel(name = "租户id")
|
||||
private Long tenantId;
|
||||
}
|
||||
|
||||
@@ -65,7 +65,7 @@ private static final long serialVersionUID = 1L;
|
||||
private String annex;
|
||||
|
||||
/** 完成人id */
|
||||
@Excel(name = "完成人id")
|
||||
// @Excel(name = "完成人id")
|
||||
@ApiModelProperty("完成人id")
|
||||
private Long userId;
|
||||
|
||||
@@ -79,6 +79,6 @@ private static final long serialVersionUID = 1L;
|
||||
@ApiModelProperty("工单备注")
|
||||
private String orderRemark;
|
||||
/** 租户id */
|
||||
@Excel(name = "租户id")
|
||||
// @Excel(name = "租户id")
|
||||
private Long tenantId;
|
||||
}
|
||||
|
||||
@@ -129,6 +129,6 @@ private static final long serialVersionUID = 1L;
|
||||
@ApiModelProperty("负责人")
|
||||
private String head;
|
||||
/** 租户id */
|
||||
@Excel(name = "租户id")
|
||||
// @Excel(name = "租户id")
|
||||
private Long tenantId;
|
||||
}
|
||||
|
||||
@@ -43,6 +43,6 @@ private static final long serialVersionUID = 1L;
|
||||
@ApiModelProperty("规范文件")
|
||||
private String docOssId;
|
||||
/** 租户id */
|
||||
@Excel(name = "租户id")
|
||||
// @Excel(name = "租户id")
|
||||
private Long tenantId;
|
||||
}
|
||||
|
||||
@@ -77,6 +77,7 @@ public class InspectionPlanServiceImpl implements IInspectionPlanService
|
||||
inspectionRecord.setTenantId(inspectionPlan.getTenantId());
|
||||
inspectionRecord.setCreateTime(DateUtils.getNowDate());
|
||||
inspectionRecord.setCreateBy(loginUser.getUsername());
|
||||
inspectionRecord.setInspectionPerson(inspectionPlan.getInspectionPerson());
|
||||
inspectionRecordMapper.insertInspectionRecord(inspectionRecord);
|
||||
}
|
||||
return num;
|
||||
|
||||
@@ -21,10 +21,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<result property="tenantId" column="tenant_id" />
|
||||
<result property="reviewStatus" column="review_status" />
|
||||
<result property="reviewReply" column="review_reply" />
|
||||
<result property="fileUrl" column="file_url" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectExampleReportVo">
|
||||
select example_report_id, type, cycle, content, push_method, user_id, receiver, create_by, create_time, update_by, update_time, start_date, end_date,review_status,review_reply from example_report
|
||||
select example_report_id, type, cycle, content, push_method, user_id, receiver, create_by, create_time, update_by, update_time, start_date, end_date,review_status,review_reply , file_url from example_report
|
||||
</sql>
|
||||
|
||||
<select id="selectExampleReportList" parameterType="ExampleReport" resultMap="ExampleReportResult">
|
||||
@@ -71,6 +72,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="tenantId != null">tenant_id,</if>
|
||||
<if test="reviewStatus != null">review_status,</if>
|
||||
<if test="reviewReply != null">review_reply,</if>
|
||||
<if test="fileUrl != null and fileUrl != ''">file_url,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="exampleReportId != null">#{exampleReportId},</if>
|
||||
@@ -89,6 +91,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="tenantId != null">#{tenantId},</if>
|
||||
<if test="reviewStatus != null">#{reviewStatus},</if>
|
||||
<if test="reviewReply != null">#{reviewReply},</if>
|
||||
<if test="fileUrl != null and fileUrl != ''">#{fileUrl},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
@@ -109,6 +112,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="endDate != null">end_date = #{endDate},</if>
|
||||
<if test="reviewStatus != null">review_status = #{reviewStatus},</if>
|
||||
<if test="reviewReply != null">review_reply = #{reviewReply},</if>
|
||||
<if test="fileUrl != null and fileUrl != ''">file_url = #{fileUrl},</if>
|
||||
</trim>
|
||||
where example_report_id = #{exampleReportId}
|
||||
</update>
|
||||
|
||||
@@ -19,6 +19,8 @@ import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
|
||||
import org.apache.poi.ss.usermodel.*;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@@ -26,6 +28,10 @@ import javax.annotation.Resource;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.io.PrintWriter;
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@@ -65,21 +71,140 @@ public class DataCenterController {
|
||||
|
||||
@ApiOperation("导出设备的历史数据为Excel")
|
||||
@PostMapping("/deviceHistoryExport")
|
||||
public void deviceHistoryExport(@RequestBody DeviceHistoryParam deviceHistoryParam, HttpServletResponse response) {
|
||||
public void deviceHistoryExport(@RequestBody DeviceHistoryParam deviceHistoryParam, HttpServletResponse response) throws Exception {
|
||||
if (StringUtils.isEmpty(deviceHistoryParam.getSerialNumber())) {
|
||||
try {
|
||||
response.setContentType("application/json");
|
||||
response.getWriter().print(JSON.toJSONString(AjaxResult.error("请选择设备")));
|
||||
} catch (IOException e) {
|
||||
log.error("导出失败", e);
|
||||
}
|
||||
response.sendError(HttpServletResponse.SC_BAD_REQUEST, "请选择设备");
|
||||
return;
|
||||
}
|
||||
dataCenterService.deviceHistoryExport(deviceHistoryParam, response);
|
||||
|
||||
List<JSONObject> dataList = dataCenterService.deviceHistory(deviceHistoryParam);
|
||||
|
||||
// 创建工作簿
|
||||
Workbook workbook = new XSSFWorkbook();
|
||||
Sheet sheet = workbook.createSheet("设备历史数据");
|
||||
|
||||
// 创建表头
|
||||
Row headerRow = sheet.createRow(0);
|
||||
headerRow.createCell(0).setCellValue("时间戳");
|
||||
headerRow.createCell(1).setCellValue("指标名");
|
||||
headerRow.createCell(2).setCellValue("值");
|
||||
|
||||
// 填充数据
|
||||
int rowIndex = 1;
|
||||
|
||||
for (JSONObject data : dataList) {
|
||||
if (data == null || data.isEmpty()) continue;
|
||||
|
||||
// 获取时间戳
|
||||
String timestamp = new ArrayList<>(data.keySet()).get(0);
|
||||
|
||||
// 获取指标数据 - 现在处理 ArrayList 类型
|
||||
Object valueObj = data.get(timestamp);
|
||||
|
||||
if (valueObj instanceof java.util.List) {
|
||||
java.util.List<?> valueList = (java.util.List<?>) valueObj;
|
||||
if (!valueList.isEmpty() && valueList.get(0) instanceof JSONObject) {
|
||||
JSONObject valueData = (JSONObject) valueList.get(0);
|
||||
|
||||
// 为每个指标创建一行
|
||||
for (String identifier : valueData.keySet()) {
|
||||
Row row = sheet.createRow(rowIndex++);
|
||||
row.createCell(0).setCellValue(timestamp);
|
||||
row.createCell(1).setCellValue(identifier);
|
||||
Object value = valueData.get(identifier);
|
||||
if (value != null) {
|
||||
row.createCell(2).setCellValue(value.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// 同时兼容原来的 JSONArray 类型
|
||||
else if (valueObj instanceof com.alibaba.fastjson.JSONArray) {
|
||||
com.alibaba.fastjson.JSONArray valueArray = (com.alibaba.fastjson.JSONArray) valueObj;
|
||||
if (!valueArray.isEmpty() && valueArray.get(0) instanceof JSONObject) {
|
||||
JSONObject valueData = (JSONObject) valueArray.get(0);
|
||||
|
||||
// 为每个指标创建一行
|
||||
for (String identifier : valueData.keySet()) {
|
||||
Row row = sheet.createRow(rowIndex++);
|
||||
row.createCell(0).setCellValue(timestamp);
|
||||
row.createCell(1).setCellValue(identifier);
|
||||
Object value = valueData.get(identifier);
|
||||
if (value != null) {
|
||||
row.createCell(2).setCellValue(value.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// 设置列宽
|
||||
sheet.setColumnWidth(0, 25 * 256); // 时间戳列 - 25个字符宽度
|
||||
sheet.setColumnWidth(1, 20 * 256); // 指标名列 - 20个字符宽度
|
||||
sheet.setColumnWidth(2, 20 * 256); // 值列 - 20个字符宽度
|
||||
|
||||
// 或者使用自动调整列宽(根据内容)
|
||||
// sheet.autoSizeColumn(0);
|
||||
// sheet.autoSizeColumn(1);
|
||||
// sheet.autoSizeColumn(2);
|
||||
// 设置响应头
|
||||
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
|
||||
response.setCharacterEncoding("utf-8");
|
||||
String fileName = URLEncoder.encode("设备历史数据.xlsx", "UTF-8");
|
||||
response.setHeader("Content-Disposition", "attachment; filename=" + fileName);
|
||||
|
||||
// 写入响应流
|
||||
workbook.write(response.getOutputStream());
|
||||
workbook.close();
|
||||
}
|
||||
|
||||
|
||||
|
||||
// public void deviceHistoryExport(@RequestBody DeviceHistoryParam deviceHistoryParam, HttpServletResponse response) {
|
||||
// if (StringUtils.isEmpty(deviceHistoryParam.getSerialNumber())) {
|
||||
// try {
|
||||
// response.getWriter().write(JSON.toJSONString(AjaxResult.error("请选择设备")));
|
||||
// } catch (IOException e) {
|
||||
// log.error("导出设备历史数据错误", e);
|
||||
// }
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// try {
|
||||
// List<JSONObject> jsonObjectList = dataCenterService.deviceHistory(deviceHistoryParam);
|
||||
// List<DeviceHistoryExcel> exportList = new ArrayList<>();
|
||||
//
|
||||
// // 转换数据格式
|
||||
// for (JSONObject jsonObject : jsonObjectList) {
|
||||
// for (String timestamp : jsonObject.keySet()) {
|
||||
// JSONArray values = jsonObject.getJSONArray(timestamp);
|
||||
// for (int i = 0; i < values.size(); i++) {
|
||||
// JSONObject valueObj = values.getJSONObject(i);
|
||||
// for (String key : valueObj.keySet()) {
|
||||
// exportList.add(new DeviceHistoryExcel(
|
||||
// timestamp,
|
||||
// key,
|
||||
// valueObj.getString(key)
|
||||
// ));
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// // 使用ExcelUtil导出
|
||||
// ExcelUtil<DeviceHistoryExcel> util = new ExcelUtil<>(DeviceHistoryExcel.class);
|
||||
// util.exportExcel(response, exportList, "设备历史数据");
|
||||
// } catch (Exception e) {
|
||||
// log.error("导出设备历史数据错误", e);
|
||||
// try {
|
||||
// response.getWriter().write(JSON.toJSONString(AjaxResult.error("导出Excel失败: " + e.getMessage())));
|
||||
// } catch (IOException ex) {
|
||||
// log.error("响应导出错误信息失败", ex);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
|
||||
|
||||
@ApiOperation("查询场景变量历史数据")
|
||||
@PreAuthorize("@ss.hasPermi('dataCenter:history:list')")
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
package com.xinda.data.controller.datacenter;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import com.xinda.common.annotation.Excel;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class DeviceHistoryData {
|
||||
@Excel(name = "时间")
|
||||
private String time;
|
||||
|
||||
@Excel(name = "数据")
|
||||
private String value;
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package com.xinda.data.controller.datacenter;
|
||||
|
||||
|
||||
import com.xinda.common.annotation.Excel;
|
||||
|
||||
// DeviceHistoryExcel.java
|
||||
public class DeviceHistoryExcel {
|
||||
@Excel(name = "时间戳")
|
||||
private String timestamp;
|
||||
|
||||
@Excel(name = "标识符")
|
||||
private String identifier;
|
||||
|
||||
@Excel(name = "值")
|
||||
private String value;
|
||||
|
||||
// 构造函数、getter和setter
|
||||
public DeviceHistoryExcel(String timestamp, String identifier, String value) {
|
||||
this.timestamp = timestamp;
|
||||
this.identifier = identifier;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
// getter和setter方法
|
||||
public String getTimestamp() { return timestamp; }
|
||||
public void setTimestamp(String timestamp) { this.timestamp = timestamp; }
|
||||
public String getIdentifier() { return identifier; }
|
||||
public void setIdentifier(String identifier) { this.identifier = identifier; }
|
||||
public String getValue() { return value; }
|
||||
public void setValue(String value) { this.value = value; }
|
||||
}
|
||||
@@ -73,4 +73,6 @@ public class AlertLog extends BaseEntity
|
||||
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date endTime;
|
||||
private Long respPersonId; //负责人
|
||||
private String procPersonName; //处理人
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ import com.xinda.iot.model.dto.ThingsModelDTO;
|
||||
import com.xinda.iot.model.param.DataCenterParam;
|
||||
import com.xinda.iot.model.scenemodel.SceneHistoryParam;
|
||||
import com.xinda.iot.service.*;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.poi.ss.usermodel.Row;
|
||||
import org.apache.poi.ss.usermodel.Sheet;
|
||||
@@ -38,6 +39,7 @@ import java.util.stream.Collectors;
|
||||
* @description: 数据中心服务类
|
||||
* @date 2024-06-13 15:29
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class DataCenterServiceImpl implements DataCenterService {
|
||||
|
||||
|
||||
@@ -24,6 +24,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<result property="sceneName" column="scene_name"/>
|
||||
<result property="enable" column="enable"/>
|
||||
<result property="orderId" column="order_id"/>
|
||||
<result property="respPersonId" column="resp_person_id"/>
|
||||
<result property="procPersonName" column="proc_person_name"/>
|
||||
</resultMap>
|
||||
|
||||
<resultMap type="com.xinda.iot.model.DeviceAlertCount" id="DeviceAlertCount">
|
||||
@@ -36,11 +38,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectAlertLogVo">
|
||||
select alert_log_id, alert_name, alert_level, status, product_id, detail, serial_number, create_by, create_time, remark, device_name, user_id,enable,order_id from iot_alert_log
|
||||
select alert_log_id, alert_name, alert_level, status, product_id, detail, serial_number, create_by, create_time, remark, device_name, user_id,enable,order_id,resp_person_id,proc_person_name from iot_alert_log
|
||||
</sql>
|
||||
|
||||
<select id="selectAlertLogList" parameterType="com.xinda.iot.domain.AlertLog" resultMap="AlertLogResult">
|
||||
select distinct al.alert_log_id, al.alert_name, al.alert_level, al.status, al.product_id, al.detail, al.serial_number, al.create_time, al.remark, al.device_name, al.user_id,al.enable,al.order_id
|
||||
select distinct al.alert_log_id, al.alert_name, al.alert_level, al.status, al.product_id, al.detail, al.serial_number, al.create_time, al.remark, al.device_name, al.user_id,al.enable,al.order_id,al.resp_person_id,al.proc_person_name
|
||||
from iot_alert_log al
|
||||
<where>
|
||||
<if test="alertName != null and alertName != ''"> and al.alert_name like concat('%', #{alertName}, '%')</if>
|
||||
@@ -51,6 +53,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="userId != null "> and al.user_id = #{userId}</if>
|
||||
<if test="createBy != null "> and al.create_by = #{createBy}</if>
|
||||
<if test="remark != null "> and al.remark = #{remark}</if>
|
||||
<if test="respPersonId != null "> and al.resp_person_id = #{respPersonId}</if>
|
||||
<if test="procPersonName != null "> and al.proc_person_name = #{procPersonName}</if>
|
||||
</where>
|
||||
order by al.create_time desc
|
||||
</select>
|
||||
@@ -191,6 +195,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="remark != null">remark,</if>
|
||||
<if test="userId != null">user_id,</if>
|
||||
<if test="deviceName != null and deviceName != ''">device_name,</if>
|
||||
<if test="respPersonId != null">resp_person_id,</if>
|
||||
<if test="procPersonName != null and procPersonName != ''">proc_person_name,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="alertName != null and alertName != ''">#{alertName},</if>
|
||||
@@ -206,6 +212,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="remark != null">#{remark},</if>
|
||||
<if test="userId != null">#{userId},</if>
|
||||
<if test="deviceName != null and deviceName != ''">#{deviceName},</if>
|
||||
<if test="respPersonId != null">#{respPersonId},</if>
|
||||
<if test="procPersonName != null and procPersonName != ''">#{procPersonName},</if>
|
||||
|
||||
</trim>
|
||||
</insert>
|
||||
@@ -243,6 +251,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="remark != null">remark = #{remark},</if>
|
||||
<if test="enable != null">enable =#{enable},</if>
|
||||
<if test="orderId != null">orderId =#{orderId},</if>
|
||||
<if test="respPersonId != null">resp_person_id =#{respPersonId},</if>
|
||||
<if test="procPersonName != null and procPersonName != ''">proc_person_name,</if>
|
||||
</trim>
|
||||
where alert_log_id = #{alertLogId}
|
||||
</update>
|
||||
|
||||
Reference in New Issue
Block a user