|
|
@@ -55,8 +55,25 @@
|
|
|
|
|
|
<select id="getCost" parameterType="cn.iocoder.yudao.module.pms.controller.admin.maintain.vo.IotMaintainPageReqVO"
|
|
|
resultType="cn.iocoder.yudao.module.pms.controller.admin.stat.vo.ReportCost">
|
|
|
- select CAST(create_time AS CHAR) as date, '维修'as type, device_code as deviceCode, device_name as deviceName, maintain_fee as cost from rq_iot_maintain a
|
|
|
+ select * from (select CAST(create_time AS CHAR) as date, '内部维修'as type, device_code as deviceCode, device_name as deviceName, maintain_fee as cost from rq_iot_maintain a
|
|
|
<where>
|
|
|
+ a.deleted=0 and a.type!='out'
|
|
|
+ <if test="reqVO.createTime[0] != null">
|
|
|
+ AND a.create_time >= #{reqVO.createTime[0]}
|
|
|
+ </if>
|
|
|
+ <if test="reqVO.createTime.length > 1 and reqVO.createTime[1] != null">
|
|
|
+ AND a.create_time <= #{reqVO.createTime[1]}
|
|
|
+ </if>
|
|
|
+ <if test="reqVO.deptIds != null and reqVO.deptIds.size > 0">
|
|
|
+ AND a.dept_id IN
|
|
|
+ <foreach collection="reqVO.deptIds" index="index" item="key" open="(" separator="," close=")">
|
|
|
+ #{key}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ </where>
|
|
|
+ select CAST(create_time AS CHAR) as date, '委外维修'as type, device_code as deviceCode, device_name as deviceName, maintain_fee as cost from rq_iot_maintain a
|
|
|
+ <where>
|
|
|
+ a.deleted=0 and a.type='out'
|
|
|
<if test="reqVO.createTime[0] != null">
|
|
|
AND a.create_time >= #{reqVO.createTime[0]}
|
|
|
</if>
|
|
|
@@ -96,7 +113,12 @@
|
|
|
#{key}
|
|
|
</foreach>
|
|
|
</if>
|
|
|
- GROUP BY wo.id, wob.device_id
|
|
|
+ GROUP BY wo.id, wob.device_id) fin
|
|
|
+ <where>
|
|
|
+ <if test="reqVO.type != null">
|
|
|
+ AND fin.type = #{reqVO.type}
|
|
|
+ </if>
|
|
|
+ </where>
|
|
|
</select>
|
|
|
|
|
|
<select id="selectStatusNumber" parameterType="cn.iocoder.yudao.module.pms.controller.admin.maintain.vo.IotMaintainPageReqVO"
|
|
|
@@ -223,14 +245,21 @@ select * from (
|
|
|
|
|
|
UNION ALL
|
|
|
|
|
|
- select b.id,'保养工单' as type,
|
|
|
- '' as taskId,
|
|
|
- b.create_time as createTime,
|
|
|
+ SELECT
|
|
|
+ c.id,
|
|
|
+ '' AS taskId,
|
|
|
+ '运行记录' AS type,
|
|
|
+ c.create_time AS createTime,
|
|
|
+ -- 核心优化:status 数值转中文描述
|
|
|
CASE
|
|
|
- WHEN b.result = 1 THEN '未完成'
|
|
|
- WHEN b.result = 2 THEN '已完成'
|
|
|
+ WHEN c.order_status = 0 THEN '未完成'
|
|
|
+ WHEN c.order_status = 1 THEN '已完成'
|
|
|
+ WHEN c.order_status = 2 THEN '填写中'
|
|
|
ELSE '' -- 兼容其他未知状态值
|
|
|
- END AS status, '' as device,b.dept_id as deptId,
|
|
|
+ END AS status,
|
|
|
+ '' AS device,
|
|
|
+ c.dept_id AS deptId,
|
|
|
+ -- 按type规则填充company字段
|
|
|
CASE
|
|
|
WHEN d.type = 1 THEN COALESCE(d.`name`, '')
|
|
|
WHEN d.type = 2 THEN COALESCE(p1.`name`, '')
|
|
|
@@ -248,37 +277,36 @@ select * from (
|
|
|
WHEN d.type = 3 THEN COALESCE(d.`name`, '')
|
|
|
ELSE ''
|
|
|
END AS deptName
|
|
|
- from rq_iot_main_work_order b
|
|
|
+ FROM rq_iot_opeation_fill_order c
|
|
|
-- 左关联当前部门(避免主表数据丢失)
|
|
|
- LEFT JOIN system_dept d ON b.dept_id = d.id
|
|
|
+ LEFT JOIN system_dept d ON c.dept_id = d.id
|
|
|
-- 左关联父级部门(type=2/3时用)
|
|
|
LEFT JOIN system_dept p1 ON d.parent_id = p1.id
|
|
|
-- 左关联祖父级部门(type=3时用)
|
|
|
LEFT JOIN system_dept p2 ON p1.parent_id = p2.id
|
|
|
<where>
|
|
|
- b.deleted = 0
|
|
|
+ c.deleted=0
|
|
|
<if test="reqVO.createTime[0] != null">
|
|
|
- AND b.create_time >= #{reqVO.createTime[0]}
|
|
|
+ AND c.create_time >= #{reqVO.createTime[0]}
|
|
|
</if>
|
|
|
<if test="reqVO.createTime.length > 1 and reqVO.createTime[1] != null">
|
|
|
- AND b.create_time <= #{reqVO.createTime[1]}
|
|
|
+ AND c.create_time <= #{reqVO.createTime[1]}
|
|
|
</if>
|
|
|
<if test="reqVO.deptIds != null and reqVO.deptIds.size > 0">
|
|
|
- AND b.dept_id IN
|
|
|
+ AND c.dept_id IN
|
|
|
<foreach collection="reqVO.deptIds" index="index" item="key" open="(" separator="," close=")">
|
|
|
#{key}
|
|
|
</foreach>
|
|
|
</if>
|
|
|
</where>
|
|
|
+ union all
|
|
|
|
|
|
- UNION ALL
|
|
|
-
|
|
|
- select b.id,'瑞恒日报' as type,
|
|
|
- b.task_id as taskId,
|
|
|
- b.create_time as createTime,
|
|
|
+ select b.id,'保养工单' as type,
|
|
|
+ '' as taskId,
|
|
|
+ b.create_time as createTime,
|
|
|
CASE
|
|
|
- WHEN b.status = 0 THEN '未完成'
|
|
|
- WHEN b.status = 1 THEN '已完成'
|
|
|
+ WHEN b.result = 1 THEN '未完成'
|
|
|
+ WHEN b.result = 2 THEN '已完成'
|
|
|
ELSE '' -- 兼容其他未知状态值
|
|
|
END AS status, '' as device,b.dept_id as deptId,
|
|
|
CASE
|
|
|
@@ -298,7 +326,7 @@ select * from (
|
|
|
WHEN d.type = 3 THEN COALESCE(d.`name`, '')
|
|
|
ELSE ''
|
|
|
END AS deptName
|
|
|
- from rq_iot_rh_daily_report b
|
|
|
+ from rq_iot_main_work_order b
|
|
|
-- 左关联当前部门(避免主表数据丢失)
|
|
|
LEFT JOIN system_dept d ON b.dept_id = d.id
|
|
|
-- 左关联父级部门(type=2/3时用)
|
|
|
@@ -323,8 +351,8 @@ select * from (
|
|
|
|
|
|
UNION ALL
|
|
|
|
|
|
- select b.id,'瑞鹰日报' as type,
|
|
|
- b.task_id taskId,
|
|
|
+ select b.id,'瑞恒日报' as type,
|
|
|
+ b.task_id as taskId,
|
|
|
b.create_time as createTime,
|
|
|
CASE
|
|
|
WHEN b.status = 0 THEN '未完成'
|
|
|
@@ -348,7 +376,7 @@ select * from (
|
|
|
WHEN d.type = 3 THEN COALESCE(d.`name`, '')
|
|
|
ELSE ''
|
|
|
END AS deptName
|
|
|
- from rq_iot_ry_daily_report b
|
|
|
+ from rq_iot_rh_daily_report b
|
|
|
-- 左关联当前部门(避免主表数据丢失)
|
|
|
LEFT JOIN system_dept d ON b.dept_id = d.id
|
|
|
-- 左关联父级部门(type=2/3时用)
|
|
|
@@ -373,8 +401,8 @@ select * from (
|
|
|
|
|
|
UNION ALL
|
|
|
|
|
|
- select b.id,'瑞都日报' as type,
|
|
|
- b.task_id as taskId,
|
|
|
+ select b.id,'瑞鹰日报' as type,
|
|
|
+ b.task_id taskId,
|
|
|
b.create_time as createTime,
|
|
|
CASE
|
|
|
WHEN b.status = 0 THEN '未完成'
|
|
|
@@ -398,7 +426,7 @@ select * from (
|
|
|
WHEN d.type = 3 THEN COALESCE(d.`name`, '')
|
|
|
ELSE ''
|
|
|
END AS deptName
|
|
|
- from rq_iot_rd_daily_report b
|
|
|
+ from rq_iot_ry_daily_report b
|
|
|
-- 左关联当前部门(避免主表数据丢失)
|
|
|
LEFT JOIN system_dept d ON b.dept_id = d.id
|
|
|
-- 左关联父级部门(type=2/3时用)
|
|
|
@@ -423,21 +451,14 @@ select * from (
|
|
|
|
|
|
UNION ALL
|
|
|
|
|
|
- SELECT
|
|
|
- c.id,
|
|
|
- '' AS taskId,
|
|
|
- '运行记录' AS type,
|
|
|
- c.create_time AS createTime,
|
|
|
- -- 核心优化:status 数值转中文描述
|
|
|
+ select b.id,'瑞都日报' as type,
|
|
|
+ b.task_id as taskId,
|
|
|
+ b.create_time as createTime,
|
|
|
CASE
|
|
|
- WHEN c.order_status = 0 THEN '未完成'
|
|
|
- WHEN c.order_status = 1 THEN '已完成'
|
|
|
- WHEN c.order_status = 2 THEN '填写中'
|
|
|
+ WHEN b.status = 0 THEN '未完成'
|
|
|
+ WHEN b.status = 1 THEN '已完成'
|
|
|
ELSE '' -- 兼容其他未知状态值
|
|
|
- END AS status,
|
|
|
- '' AS device,
|
|
|
- c.dept_id AS deptId,
|
|
|
- -- 按type规则填充company字段
|
|
|
+ END AS status, '' as device,b.dept_id as deptId,
|
|
|
CASE
|
|
|
WHEN d.type = 1 THEN COALESCE(d.`name`, '')
|
|
|
WHEN d.type = 2 THEN COALESCE(p1.`name`, '')
|
|
|
@@ -455,13 +476,38 @@ select * from (
|
|
|
WHEN d.type = 3 THEN COALESCE(d.`name`, '')
|
|
|
ELSE ''
|
|
|
END AS deptName
|
|
|
- FROM rq_iot_opeation_fill_order c
|
|
|
+ from rq_iot_rd_daily_report b
|
|
|
-- 左关联当前部门(避免主表数据丢失)
|
|
|
- LEFT JOIN system_dept d ON c.dept_id = d.id
|
|
|
+ LEFT JOIN system_dept d ON b.dept_id = d.id
|
|
|
-- 左关联父级部门(type=2/3时用)
|
|
|
LEFT JOIN system_dept p1 ON d.parent_id = p1.id
|
|
|
-- 左关联祖父级部门(type=3时用)
|
|
|
LEFT JOIN system_dept p2 ON p1.parent_id = p2.id
|
|
|
+ <where>
|
|
|
+ b.deleted = 0
|
|
|
+ <if test="reqVO.createTime[0] != null">
|
|
|
+ AND b.create_time >= #{reqVO.createTime[0]}
|
|
|
+ </if>
|
|
|
+ <if test="reqVO.createTime.length > 1 and reqVO.createTime[1] != null">
|
|
|
+ AND b.create_time <= #{reqVO.createTime[1]}
|
|
|
+ </if>
|
|
|
+ <if test="reqVO.deptIds != null and reqVO.deptIds.size > 0">
|
|
|
+ AND b.dept_id IN
|
|
|
+ <foreach collection="reqVO.deptIds" index="index" item="key" open="(" separator="," close=")">
|
|
|
+ #{key}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ </where>
|
|
|
+
|
|
|
+ ) fin
|
|
|
+ <where>
|
|
|
+ <if test="reqVO.type != null">
|
|
|
+ AND fin.type LIKE concat("%",#{reqVO.type},"%")
|
|
|
+ </if>
|
|
|
+ </where>
|
|
|
+ </select>
|
|
|
+ <select id="getMaintainFee" resultType="java.math.BigDecimal" >
|
|
|
+ select sum(maintain_fee) from rq_iot_maintain c
|
|
|
<where>
|
|
|
c.deleted=0
|
|
|
<if test="reqVO.createTime[0] != null">
|
|
|
@@ -476,11 +522,32 @@ select * from (
|
|
|
#{key}
|
|
|
</foreach>
|
|
|
</if>
|
|
|
- </where>) fin
|
|
|
+ <if test="reqVO.type != null">
|
|
|
+ AND c.type = #{reqVO.type}
|
|
|
+ </if>
|
|
|
+ </where>
|
|
|
+
|
|
|
+ </select>
|
|
|
+ <select id="getMaintainFeeIn" resultType="java.math.BigDecimal" >
|
|
|
+ select sum(maintain_fee) from rq_iot_maintain c
|
|
|
<where>
|
|
|
+ c.deleted=0 and c.type !='out'
|
|
|
+ <if test="reqVO.createTime[0] != null">
|
|
|
+ AND c.create_time >= #{reqVO.createTime[0]}
|
|
|
+ </if>
|
|
|
+ <if test="reqVO.createTime.length > 1 and reqVO.createTime[1] != null">
|
|
|
+ AND c.create_time <= #{reqVO.createTime[1]}
|
|
|
+ </if>
|
|
|
+ <if test="reqVO.deptIds != null and reqVO.deptIds.size > 0">
|
|
|
+ AND c.dept_id IN
|
|
|
+ <foreach collection="reqVO.deptIds" index="index" item="key" open="(" separator="," close=")">
|
|
|
+ #{key}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
<if test="reqVO.type != null">
|
|
|
- AND fin.type= #{reqVO.type}
|
|
|
+ AND c.type = #{reqVO.type}
|
|
|
</if>
|
|
|
</where>
|
|
|
+
|
|
|
</select>
|
|
|
</mapper>
|