✨ feat: 报告生成-厂界在线前后端,部分功能
This commit is contained in:
parent
490bd84309
commit
31a9707d0a
|
@ -0,0 +1,62 @@
|
|||
package com.ruoyi.project.oil.controller;
|
||||
|
||||
import com.ruoyi.framework.web.controller.BaseController;
|
||||
import com.ruoyi.framework.web.domain.AjaxResult;
|
||||
import com.ruoyi.project.oil.service.IOilThDeviceDealService;
|
||||
import com.ruoyi.project.oil.service.IOilThDeviceService;
|
||||
import com.ruoyi.project.oil.service.impl.OilThDeviceReportService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/report")
|
||||
public class OilReportController extends BaseController {
|
||||
|
||||
@Autowired
|
||||
IOilThDeviceService oilThDeviceService;
|
||||
|
||||
@Autowired
|
||||
IOilThDeviceDealService oilThDeviceDealService;
|
||||
@Autowired
|
||||
private OilThDeviceReportService oilThDeviceReportService;
|
||||
|
||||
private int getDeviceCount(Long deptId, String year, Integer status) {
|
||||
Map<String, Object> deviceCountMap = new HashMap<>();
|
||||
deviceCountMap.put("deptId", deptId);
|
||||
deviceCountMap.put("year", year);
|
||||
if (status != null) {
|
||||
deviceCountMap.put("status", status);
|
||||
}
|
||||
return oilThDeviceService.countDevice(deviceCountMap);
|
||||
}
|
||||
|
||||
@GetMapping("/getBoundDashboardData")
|
||||
public AjaxResult getBoundDashboardData(Long deptId, String year) {
|
||||
Map<String, Object> resultMap = new HashMap<>();
|
||||
// 设备总数
|
||||
int deviceCount = getDeviceCount(deptId, year, null);
|
||||
// 正常设备数
|
||||
int normalDeviceCount = getDeviceCount(deptId, year, 1);
|
||||
// 异常设备数
|
||||
int abnormalDeviceCount = getDeviceCount(deptId, year, 0);
|
||||
// 全年解决报警次数
|
||||
// int alarmSolveCountYear = oilThDeviceDealService.countThDeviceDealByYear(year);
|
||||
resultMap.put("deviceCount", deviceCount);
|
||||
resultMap.put("normalDeviceCount", normalDeviceCount);
|
||||
resultMap.put("abnormalDeviceCount", abnormalDeviceCount);
|
||||
// resultMap.put("alarmSolveCountYear", alarmSolveCountYear);
|
||||
return AjaxResult.success(resultMap);
|
||||
}
|
||||
|
||||
@GetMapping("/getBoundTableData")
|
||||
public AjaxResult getBoundTableData(Long deptId, String year) {
|
||||
List<Map<String, Object>> result = oilThDeviceReportService.selectOverLimitCountByYearAndDeptId(deptId, year);
|
||||
return AjaxResult.success(result);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,136 @@
|
|||
package com.ruoyi.project.oil.domain.monitor;
|
||||
|
||||
import com.ruoyi.framework.web.domain.BaseEntity;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
|
||||
public class ThDeviceDeal extends BaseEntity {
|
||||
private static final long serialVersionUID = 1L;
|
||||
/** 表id */
|
||||
private Long id;
|
||||
|
||||
/** 报警id */
|
||||
private Long reportId;
|
||||
|
||||
/** 处理人id */
|
||||
private String dealUser;
|
||||
|
||||
/** 处理方式 */
|
||||
private String dealWay;
|
||||
|
||||
/** 处理时间 */
|
||||
private Date dealTime;
|
||||
|
||||
/** 创建者 */
|
||||
private String createBy;
|
||||
|
||||
/** 创建时间 */
|
||||
private Date createTime;
|
||||
|
||||
/** 报警原因 */
|
||||
private String reason;
|
||||
|
||||
/** 图片地址 */
|
||||
private String fileUrl;
|
||||
|
||||
/** 1:正在处理 2:处理完成 */
|
||||
private Integer status;
|
||||
|
||||
/** 备注 */
|
||||
private String remark;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Long getReportId() {
|
||||
return reportId;
|
||||
}
|
||||
|
||||
public void setReportId(Long reportId) {
|
||||
this.reportId = reportId;
|
||||
}
|
||||
|
||||
public String getDealUser() {
|
||||
return dealUser;
|
||||
}
|
||||
|
||||
public void setDealUser(String dealUser) {
|
||||
this.dealUser = dealUser;
|
||||
}
|
||||
|
||||
public String getDealWay() {
|
||||
return dealWay;
|
||||
}
|
||||
|
||||
public void setDealWay(String dealWay) {
|
||||
this.dealWay = dealWay;
|
||||
}
|
||||
|
||||
public Date getDealTime() {
|
||||
return dealTime;
|
||||
}
|
||||
|
||||
public void setDealTime(Date dealTime) {
|
||||
this.dealTime = dealTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCreateBy() {
|
||||
return createBy;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCreateBy(String createBy) {
|
||||
this.createBy = createBy;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Date getCreateTime() {
|
||||
return createTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCreateTime(Date createTime) {
|
||||
this.createTime = createTime;
|
||||
}
|
||||
|
||||
public String getReason() {
|
||||
return reason;
|
||||
}
|
||||
|
||||
public void setReason(String reason) {
|
||||
this.reason = reason;
|
||||
}
|
||||
|
||||
public String getFileUrl() {
|
||||
return fileUrl;
|
||||
}
|
||||
|
||||
public void setFileUrl(String fileUrl) {
|
||||
this.fileUrl = fileUrl;
|
||||
}
|
||||
|
||||
public Integer getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(Integer status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRemark() {
|
||||
return remark;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRemark(String remark) {
|
||||
this.remark = remark;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
package com.ruoyi.project.oil.mapper;
|
||||
|
||||
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author Lenovo
|
||||
* @description 针对表【th_device_deal】的数据库操作Mapper
|
||||
* @createDate 2024-10-29 15:40:41
|
||||
* @Entity com.ruoyi.oil.domain.monitor.ThDeviceDeal
|
||||
*/
|
||||
public interface ThDeviceDealMapper {
|
||||
int countThDeviceDealByYear(@Param("year") String year);
|
||||
}
|
|
@ -3,6 +3,7 @@ package com.ruoyi.project.oil.mapper;
|
|||
import com.ruoyi.project.oil.domain.monitor.ThDevice;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author Lenovo
|
||||
|
@ -28,6 +29,12 @@ public interface ThDeviceMapper {
|
|||
*/
|
||||
List<ThDevice> selectDeviceList(ThDevice thDevice);
|
||||
|
||||
/**
|
||||
* 设备统计
|
||||
* @return 设备统计
|
||||
*/
|
||||
int countDevice(Map<String, Object> params);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -78,4 +78,6 @@ public interface ThDeviceReportMapper {
|
|||
@MapKey("sn")
|
||||
List<Map<String, Object>> selectAlarmCountByDeptIdAndDateRangeDesc(@Param("deptId") Long deptId, @Param("beginDate") String beginDate, @Param("endDate") String endDate);
|
||||
|
||||
@MapKey("sn")
|
||||
List<Map<String, Object>> selectOverLimitCountByYearAndDeptId(@Param("deptId") Long deptId, @Param("year") String year);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
package com.ruoyi.project.oil.service;
|
||||
|
||||
public interface IOilThDeviceDealService {
|
||||
|
||||
/**
|
||||
* 根据年份查询设备处理数量
|
||||
*/
|
||||
int countThDeviceDealByYear(String year);
|
||||
}
|
|
@ -13,4 +13,6 @@ public interface IOilThDeviceReportService {
|
|||
List<Map<String, Object>> selectAlarmCountByDeptIdAndDateRange(Long deptId, String beginDate, String endDate);
|
||||
|
||||
List<Map<String, Object>> selectAlarmCountByDeptIdAndDateRangeDesc(Long deptId, String beginDate, String endDate);
|
||||
|
||||
List<Map<String, Object>> selectOverLimitCountByYearAndDeptId(Long deptId, String year);
|
||||
}
|
||||
|
|
|
@ -56,4 +56,7 @@ public interface IOilThDeviceService {
|
|||
* @return 按月度统计的ds平均值
|
||||
*/
|
||||
List<Map<String, Object>> selectAllAvgByMonth(Long deptId, String month);
|
||||
|
||||
|
||||
int countDevice(Map<String, Object> params);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
package com.ruoyi.project.oil.service.impl;
|
||||
|
||||
import com.ruoyi.project.oil.mapper.ThDeviceDealMapper;
|
||||
import com.ruoyi.project.oil.service.IOilThDeviceDealService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class OilThDeviceDealServiceImpl implements IOilThDeviceDealService {
|
||||
|
||||
@Autowired
|
||||
private ThDeviceDealMapper thDeviceDealMapper;
|
||||
|
||||
@Override
|
||||
public int countThDeviceDealByYear(String year) {
|
||||
return thDeviceDealMapper.countThDeviceDealByYear(year);
|
||||
}
|
||||
}
|
|
@ -41,4 +41,9 @@ public class OilThDeviceReportService implements IOilThDeviceReportService {
|
|||
return camelCaseMapListKey(thDeviceReportMapper.selectAlarmCountByDeptIdAndDateRangeDesc(deptId, beginDate, endDate));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Map<String, Object>> selectOverLimitCountByYearAndDeptId(Long deptId, String year) {
|
||||
return camelCaseMapListKey(thDeviceReportMapper.selectOverLimitCountByYearAndDeptId(deptId, year));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -91,4 +91,10 @@ public class OilThDeviceServiceImpl implements IOilThDeviceService {
|
|||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int countDevice(Map<String, Object> params) {
|
||||
return thDeviceMapper.countDevice(params);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,41 @@
|
|||
<?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.ruoyi.project.oil.mapper.ThDeviceDealMapper">
|
||||
<parameterMap id="BaseParameterMap" type="com.ruoyi.project.oil.domain.monitor.ThDeviceDeal">
|
||||
<parameter property="id" jdbcType="BIGINT" />
|
||||
<parameter property="reportId" jdbcType="BIGINT" />
|
||||
<parameter property="dealUser" jdbcType="VARCHAR" />
|
||||
<parameter property="dealWay" jdbcType="VARCHAR" />
|
||||
<parameter property="dealTime" jdbcType="TIMESTAMP" />
|
||||
<parameter property="createBy" jdbcType="VARCHAR" />
|
||||
<parameter property="createTime" jdbcType="TIMESTAMP" />
|
||||
<parameter property="reason" jdbcType="VARCHAR" />
|
||||
<parameter property="fileUrl" jdbcType="VARCHAR" />
|
||||
<parameter property="status" jdbcType="INTEGER" />
|
||||
<parameter property="remark" jdbcType="VARCHAR" />
|
||||
</parameterMap>
|
||||
<resultMap id="ThDeviceDealResultMap" type="com.ruoyi.project.oil.domain.monitor.ThDeviceDeal">
|
||||
<id property="id" column="ID" jdbcType="BIGINT" />
|
||||
<result property="reportId" column="REPORT_ID" jdbcType="BIGINT" />
|
||||
<result property="dealUser" column="DEAL_USER" jdbcType="VARCHAR" />
|
||||
<result property="dealWay" column="DEAL_WAY" jdbcType="VARCHAR" />
|
||||
<result property="dealTime" column="DEAL_TIME" jdbcType="TIMESTAMP" />
|
||||
<result property="createBy" column="CREATE_BY" jdbcType="VARCHAR" />
|
||||
<result property="createTime" column="CREATE_TIME" jdbcType="TIMESTAMP" />
|
||||
<result property="reason" column="REASON" jdbcType="VARCHAR" />
|
||||
<result property="fileUrl" column="FILE_URL" jdbcType="VARCHAR" />
|
||||
<result property="status" column="STATUS" jdbcType="INTEGER" />
|
||||
<result property="remark" column="REMARK" jdbcType="VARCHAR" />
|
||||
</resultMap>
|
||||
|
||||
|
||||
<select id="countThDeviceDealByYear" parameterType="map" resultType="int">
|
||||
SELECT COUNT(1) FROM th_device_deal
|
||||
WHERE to_char(create_time, 'yyyy') = #{year}
|
||||
</select>
|
||||
|
||||
|
||||
</mapper>
|
|
@ -120,4 +120,21 @@
|
|||
#{deptId}
|
||||
</foreach>
|
||||
</select>
|
||||
|
||||
<select id="countDevice" parameterType="map" resultType="int">
|
||||
select count(1) from th_device d
|
||||
<where>
|
||||
<if test="deptId != null and deptId != ''">
|
||||
AND d.dept_id IN (SELECT dept_id
|
||||
FROM sys_dept START WITH dept_id = #{deptId}
|
||||
CONNECT BY PRIOR dept_id = parent_id)
|
||||
</if>
|
||||
<if test="year != null and year != ''">
|
||||
AND to_char(d.create_time, 'yyyy') = #{year}
|
||||
</if>
|
||||
<if test="status != null">
|
||||
AND d.status = #{status}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
</mapper>
|
||||
|
|
|
@ -210,4 +210,40 @@
|
|||
GROUP BY d.sn, p.dept_name, pp.dept_name, ppp.dept_name, td.address, td.name, d.zt
|
||||
ORDER BY count DESC
|
||||
</select>
|
||||
|
||||
|
||||
<!-- 选择 某年year,每个deptId下的所有设备的每个月的超限次数(ds不在dbz和gbz范围内的行) -->
|
||||
<select id="selectOverLimitCountByYearAndDeptId" parameterType="map" resultType="map">
|
||||
SELECT d.sn,
|
||||
td.address,
|
||||
p.dept_name as "p",
|
||||
pp.dept_name as "pp",
|
||||
ppp.dept_name as "ppp",
|
||||
SUM(CASE WHEN TO_CHAR(d.report_time, 'MM') = '01' AND (TO_NUMBER(d.ds) > TO_NUMBER(d.gbz) OR TO_NUMBER(d.ds) < TO_NUMBER(d.dbz)) THEN 1 ELSE 0 END) AS month1,
|
||||
SUM(CASE WHEN TO_CHAR(d.report_time, 'MM') = '02' AND (TO_NUMBER(d.ds) > TO_NUMBER(d.gbz) OR TO_NUMBER(d.ds) < TO_NUMBER(d.dbz)) THEN 1 ELSE 0 END) AS month2,
|
||||
SUM(CASE WHEN TO_CHAR(d.report_time, 'MM') = '03' AND (TO_NUMBER(d.ds) > TO_NUMBER(d.gbz) OR TO_NUMBER(d.ds) < TO_NUMBER(d.dbz)) THEN 1 ELSE 0 END) AS month3,
|
||||
SUM(CASE WHEN TO_CHAR(d.report_time, 'MM') = '04' AND (TO_NUMBER(d.ds) > TO_NUMBER(d.gbz) OR TO_NUMBER(d.ds) < TO_NUMBER(d.dbz)) THEN 1 ELSE 0 END) AS month4,
|
||||
SUM(CASE WHEN TO_CHAR(d.report_time, 'MM') = '05' AND (TO_NUMBER(d.ds) > TO_NUMBER(d.gbz) OR TO_NUMBER(d.ds) < TO_NUMBER(d.dbz)) THEN 1 ELSE 0 END) AS month5,
|
||||
SUM(CASE WHEN TO_CHAR(d.report_time, 'MM') = '06' AND (TO_NUMBER(d.ds) > TO_NUMBER(d.gbz) OR TO_NUMBER(d.ds) < TO_NUMBER(d.dbz)) THEN 1 ELSE 0 END) AS month6,
|
||||
SUM(CASE WHEN TO_CHAR(d.report_time, 'MM') = '07' AND (TO_NUMBER(d.ds) > TO_NUMBER(d.gbz) OR TO_NUMBER(d.ds) < TO_NUMBER(d.dbz)) THEN 1 ELSE 0 END) AS month7,
|
||||
SUM(CASE WHEN TO_CHAR(d.report_time, 'MM') = '08' AND (TO_NUMBER(d.ds) > TO_NUMBER(d.gbz) OR TO_NUMBER(d.ds) < TO_NUMBER(d.dbz)) THEN 1 ELSE 0 END) AS month8,
|
||||
SUM(CASE WHEN TO_CHAR(d.report_time, 'MM') = '09' AND (TO_NUMBER(d.ds) > TO_NUMBER(d.gbz) OR TO_NUMBER(d.ds) < TO_NUMBER(d.dbz)) THEN 1 ELSE 0 END) AS month9,
|
||||
SUM(CASE WHEN TO_CHAR(d.report_time, 'MM') = '10' AND (TO_NUMBER(d.ds) > TO_NUMBER(d.gbz) OR TO_NUMBER(d.ds) < TO_NUMBER(d.dbz)) THEN 1 ELSE 0 END) AS month10,
|
||||
SUM(CASE WHEN TO_CHAR(d.report_time, 'MM') = '11' AND (TO_NUMBER(d.ds) > TO_NUMBER(d.gbz) OR TO_NUMBER(d.ds) < TO_NUMBER(d.dbz)) THEN 1 ELSE 0 END) AS month11,
|
||||
SUM(CASE WHEN TO_CHAR(d.report_time, 'MM') = '12' AND (TO_NUMBER(d.ds) > TO_NUMBER(d.gbz) OR TO_NUMBER(d.ds) < TO_NUMBER(d.dbz)) THEN 1 ELSE 0 END) AS month12
|
||||
FROM th_device_report d
|
||||
LEFT JOIN th_device td ON d.sn = td.sn
|
||||
LEFT JOIN sys_dept p ON td.dept_id = p.dept_id
|
||||
LEFT JOIN sys_dept pp ON p.parent_id = pp.dept_id
|
||||
LEFT JOIN sys_dept ppp ON pp.parent_id = ppp.dept_id
|
||||
WHERE d.sn IN (SELECT d.sn
|
||||
FROM th_device d
|
||||
LEFT JOIN sys_dept p ON d.dept_id = p.dept_id
|
||||
WHERE d.dept_id IN (SELECT dept_id
|
||||
FROM sys_dept START WITH dept_id = #{deptId}
|
||||
CONNECT BY PRIOR dept_id = parent_id))
|
||||
AND TO_CHAR(d.report_time, 'YYYY') = #{year}
|
||||
GROUP BY d.sn, td.address, p.dept_name, pp.dept_name, ppp.dept_name
|
||||
ORDER BY p.dept_name, pp.dept_name, ppp.dept_name, d.sn
|
||||
</select>
|
||||
</mapper>
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
import request from '@/utils/request'
|
||||
|
||||
export function getBoundTableData(params) {
|
||||
return request({
|
||||
url: '/report/getBoundTableData',
|
||||
params: params,
|
||||
method: 'get',
|
||||
})
|
||||
}
|
||||
|
||||
export function getBoundDashboardData(params) {
|
||||
return request({
|
||||
url: '/report/getBoundDashboardData',
|
||||
params: params,
|
||||
method: 'get',
|
||||
})
|
||||
}
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue