feat(report): 新增DMS设备相关分析报表功能
- 新增设备故障分析报表实体类DeviceFaultAnalysisReport,包含设备编码、名称、故障类型等属性 - 新增设备OEE分析报表实体类DeviceOeeReport,支持计算计划运行时间、停机时间、可用率等指标 - 新增维修工时统计报表实体类RepairHoursReport,统计执行人工单数量及工时 - 实现DmsReportMapper接口,定义设备故障分析、维修工时统计及设备OEE分析的数据库查询方法 - 编写对应的MyBatis映射文件DmsReportMapper.xml,支持动态查询参数和数据聚合 - 实现IDmsReportService接口及其实现类DmsReportServiceImpl,封装业务逻辑及OEE指标计算 - 新增DmsReportController,提供设备故障分析、维修工时统计、设备OEE分析的REST接口及Excel导出功能 - 支持传入时间等参数过滤报表数据,保证数据准确性和灵活性master
parent
5e1a856d05
commit
86fa02175b
@ -0,0 +1,102 @@
|
||||
package com.aucma.report.controller;
|
||||
|
||||
import com.aucma.common.core.controller.BaseController;
|
||||
import com.aucma.common.core.domain.AjaxResult;
|
||||
import com.aucma.common.utils.poi.ExcelUtil;
|
||||
import com.aucma.report.domain.DeviceFaultAnalysisReport;
|
||||
import com.aucma.report.domain.DeviceOeeReport;
|
||||
import com.aucma.report.domain.RepairHoursReport;
|
||||
import com.aucma.report.service.IDmsReportService;
|
||||
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.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* DMS 设备报表 Controller
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/report/dmsReport")
|
||||
public class DmsReportController extends BaseController {
|
||||
|
||||
@Autowired
|
||||
private IDmsReportService dmsReportService;
|
||||
|
||||
/**
|
||||
* 设备故障分析
|
||||
*/
|
||||
@GetMapping("/deviceFaultAnalysis")
|
||||
public AjaxResult deviceFaultAnalysis(@RequestParam(required = false) Map<String, Object> params) {
|
||||
List<DeviceFaultAnalysisReport> list = dmsReportService.deviceFaultAnalysisList(params);
|
||||
return success(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设备故障分析导出
|
||||
*/
|
||||
@PostMapping("/deviceFaultAnalysis/export")
|
||||
public void deviceFaultAnalysisExport(HttpServletResponse response,
|
||||
@RequestParam(required = false) Map<String, Object> params) {
|
||||
if (params != null) {
|
||||
params.put("pageNum", null);
|
||||
params.put("pageSize", null);
|
||||
}
|
||||
List<DeviceFaultAnalysisReport> list = dmsReportService.deviceFaultAnalysisList(params);
|
||||
ExcelUtil<DeviceFaultAnalysisReport> util = new ExcelUtil<>(DeviceFaultAnalysisReport.class);
|
||||
util.exportExcel(response, list, "设备故障分析");
|
||||
}
|
||||
|
||||
/**
|
||||
* 维修工时统计
|
||||
*/
|
||||
@GetMapping("/repairHoursStat")
|
||||
public AjaxResult repairHoursStat(@RequestParam(required = false) Map<String, Object> params) {
|
||||
List<RepairHoursReport> list = dmsReportService.repairHoursReportList(params);
|
||||
return success(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 维修工时统计导出
|
||||
*/
|
||||
@PostMapping("/repairHoursStat/export")
|
||||
public void repairHoursStatExport(HttpServletResponse response,
|
||||
@RequestParam(required = false) Map<String, Object> params) {
|
||||
if (params != null) {
|
||||
params.put("pageNum", null);
|
||||
params.put("pageSize", null);
|
||||
}
|
||||
List<RepairHoursReport> list = dmsReportService.repairHoursReportList(params);
|
||||
ExcelUtil<RepairHoursReport> util = new ExcelUtil<>(RepairHoursReport.class);
|
||||
util.exportExcel(response, list, "维修工时统计");
|
||||
}
|
||||
|
||||
/**
|
||||
* 设备 OEE 分析
|
||||
*/
|
||||
@GetMapping("/deviceOeeAnalysis")
|
||||
public AjaxResult deviceOeeAnalysis(@RequestParam(required = false) Map<String, Object> params) {
|
||||
List<DeviceOeeReport> list = dmsReportService.deviceOeeReportList(params);
|
||||
return success(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设备 OEE 分析导出
|
||||
*/
|
||||
@PostMapping("/deviceOeeAnalysis/export")
|
||||
public void deviceOeeAnalysisExport(HttpServletResponse response,
|
||||
@RequestParam(required = false) Map<String, Object> params) {
|
||||
if (params != null) {
|
||||
params.put("pageNum", null);
|
||||
params.put("pageSize", null);
|
||||
}
|
||||
List<DeviceOeeReport> list = dmsReportService.deviceOeeReportList(params);
|
||||
ExcelUtil<DeviceOeeReport> util = new ExcelUtil<>(DeviceOeeReport.class);
|
||||
util.exportExcel(response, list, "设备OEE分析");
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,29 @@
|
||||
package com.aucma.report.service;
|
||||
|
||||
import com.aucma.report.domain.DeviceFaultAnalysisReport;
|
||||
import com.aucma.report.domain.RepairHoursReport;
|
||||
import com.aucma.report.domain.DeviceOeeReport;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* DMS 设备报表 Service 接口
|
||||
*/
|
||||
public interface IDmsReportService {
|
||||
|
||||
/**
|
||||
* 设备故障分析
|
||||
*/
|
||||
List<DeviceFaultAnalysisReport> deviceFaultAnalysisList(Map<String, Object> params);
|
||||
|
||||
/**
|
||||
* 维修工时统计
|
||||
*/
|
||||
List<RepairHoursReport> repairHoursReportList(Map<String, Object> params);
|
||||
|
||||
/**
|
||||
* 设备 OEE 分析
|
||||
*/
|
||||
List<DeviceOeeReport> deviceOeeReportList(Map<String, Object> params);
|
||||
}
|
||||
@ -0,0 +1,106 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.aucma.report.mapper.DmsReportMapper">
|
||||
|
||||
<!-- 设备故障分析 -->
|
||||
<select id="deviceFaultAnalysisList"
|
||||
resultType="com.aucma.report.domain.DeviceFaultAnalysisReport"
|
||||
parameterType="java.util.HashMap">
|
||||
SELECT
|
||||
dl.device_code AS DEVICE_CODE,
|
||||
dl.device_name AS DEVICE_NAME,
|
||||
fa.fault_type AS FAULT_TYPE,
|
||||
COUNT(1) AS FAULT_COUNT,
|
||||
NVL(SUM(
|
||||
CASE
|
||||
WHEN fi.real_begin_time IS NOT NULL AND fi.real_end_time IS NOT NULL
|
||||
THEN (fi.real_end_time - fi.real_begin_time) * 24 * 60
|
||||
ELSE 0
|
||||
END
|
||||
), 0) AS FAULT_DURATION_MINUTES
|
||||
FROM dms_bills_fault_instance fi
|
||||
LEFT JOIN base_deviceledger dl ON fi.device_id = dl.OBJ_ID
|
||||
LEFT JOIN dms_fault_instance_activity fa ON fi.repair_instance_id = fa.repair_instance_id
|
||||
AND fa.process_step_order = 1
|
||||
<where>
|
||||
fi.is_flag = '1'
|
||||
<if test="deviceCode != null and deviceCode != ''">
|
||||
AND dl.device_code = #{deviceCode}
|
||||
</if>
|
||||
<if test="faultType != null and faultType != ''">
|
||||
AND fa.fault_type = #{faultType}
|
||||
</if>
|
||||
<if test="beginTime != null and beginTime != ''">
|
||||
AND fi.apply_time >= TO_DATE(#{beginTime}, 'yyyy-mm-dd')
|
||||
</if>
|
||||
<if test="endTime != null and endTime != ''">
|
||||
AND fi.apply_time <= TO_DATE(#{endTime}, 'yyyy-mm-dd')
|
||||
</if>
|
||||
</where>
|
||||
GROUP BY dl.device_code, dl.device_name, fa.fault_type
|
||||
ORDER BY FAULT_COUNT DESC
|
||||
</select>
|
||||
|
||||
<!-- 维修工时统计:按执行人汇总 -->
|
||||
<select id="repairHoursReportList"
|
||||
resultType="com.aucma.report.domain.RepairHoursReport"
|
||||
parameterType="java.util.HashMap">
|
||||
SELECT
|
||||
rwo.executor_id AS EXECUTOR_ID,
|
||||
rwo.executor_name AS EXECUTOR_NAME,
|
||||
COUNT(1) AS ORDER_COUNT,
|
||||
NVL(SUM(rwo.repair_hours), 0) AS TOTAL_HOURS,
|
||||
CASE WHEN COUNT(1) = 0 THEN 0
|
||||
ELSE ROUND(NVL(SUM(rwo.repair_hours), 0) / COUNT(1), 2)
|
||||
END AS AVG_HOURS
|
||||
FROM dms_repair_work_order rwo
|
||||
<where>
|
||||
rwo.is_flag = '1'
|
||||
AND rwo.order_status = '3'
|
||||
<if test="executorId != null">
|
||||
AND rwo.executor_id = #{executorId}
|
||||
</if>
|
||||
<if test="executorName != null and executorName != ''">
|
||||
AND rwo.executor_name LIKE '%' || #{executorName} || '%'
|
||||
</if>
|
||||
<if test="beginTime != null and beginTime != ''">
|
||||
AND rwo.actual_start_time >= TO_DATE(#{beginTime}, 'yyyy-mm-dd')
|
||||
</if>
|
||||
<if test="endTime != null and endTime != ''">
|
||||
AND rwo.actual_start_time <= TO_DATE(#{endTime}, 'yyyy-mm-dd')
|
||||
</if>
|
||||
</where>
|
||||
GROUP BY rwo.executor_id, rwo.executor_name
|
||||
ORDER BY TOTAL_HOURS DESC
|
||||
</select>
|
||||
|
||||
<!-- 设备 OEE 分析基础数据:按设备统计停机时长(分钟) -->
|
||||
<select id="deviceOeeReportList"
|
||||
resultType="com.aucma.report.domain.DeviceOeeReport"
|
||||
parameterType="java.util.HashMap">
|
||||
SELECT
|
||||
dl.device_code AS DEVICE_CODE,
|
||||
dl.device_name AS DEVICE_NAME,
|
||||
NVL(SUM(rwo.shutdown_duration), 0) AS DOWNTIME_MINUTES
|
||||
FROM dms_repair_work_order rwo
|
||||
LEFT JOIN base_deviceledger dl ON rwo.device_id = dl.OBJ_ID
|
||||
<where>
|
||||
rwo.is_flag = '1'
|
||||
AND rwo.need_shutdown = '1'
|
||||
<if test="deviceCode != null and deviceCode != ''">
|
||||
AND dl.device_code = #{deviceCode}
|
||||
</if>
|
||||
<if test="beginTime != null and beginTime != ''">
|
||||
AND rwo.actual_start_time >= TO_DATE(#{beginTime}, 'yyyy-mm-dd')
|
||||
</if>
|
||||
<if test="endTime != null and endTime != ''">
|
||||
AND rwo.actual_start_time <= TO_DATE(#{endTime}, 'yyyy-mm-dd')
|
||||
</if>
|
||||
</where>
|
||||
GROUP BY dl.device_code, dl.device_name
|
||||
ORDER BY dl.device_code
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
Loading…
Reference in New Issue