|
@@ -490,6 +490,67 @@
|
|
|
update rq_iot_device set location= #{location} where device_code = #{deviceCode}
|
|
|
</update>
|
|
|
|
|
|
+ <select id="deviceCountList" parameterType="cn.iocoder.yudao.module.pms.dal.dataobject.iotdevicecountdata.IotDeviceCountData"
|
|
|
+ resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotdevicecountdata.IotDeviceCountData">
|
|
|
+ select
|
|
|
+ distinct
|
|
|
+ a.device_code,
|
|
|
+ a.device_name,
|
|
|
+ a.create_time,
|
|
|
+ b.name dept_name,
|
|
|
+ a.is_fill,
|
|
|
+ d.nickname,
|
|
|
+ e.order_name
|
|
|
+ FROM rq_iot_opeation_fill a
|
|
|
+ LEFT JOIN system_dept b
|
|
|
+ ON a.dept_id = b.id
|
|
|
+ AND b.deleted = 0 -- 将删除检查移至JOIN条件
|
|
|
+ LEFT JOIN rq_iot_device_person c
|
|
|
+ ON a.device_id = c.device_id
|
|
|
+ AND c.deleted = 0 -- 将删除检查移至JOIN条件
|
|
|
+ LEFT JOIN system_users d
|
|
|
+ ON c.person_id = d.id
|
|
|
+ AND d.deleted = 0 -- 将删除检查移至JOIN条件
|
|
|
+ LEFT JOIN rq_iot_opeation_fill_order e
|
|
|
+ ON a.order_id = e.id
|
|
|
+ and e.deleted = 0
|
|
|
+ WHERE a.deleted = 0
|
|
|
+ and e.order_name is not null
|
|
|
+ AND b.id IN (
|
|
|
+ SELECT id FROM system_dept WHERE id = #{deptId}
|
|
|
+ UNION ALL
|
|
|
+ SELECT id FROM system_dept WHERE parent_id = #{deptId}
|
|
|
+ UNION ALL
|
|
|
+ SELECT id FROM system_dept WHERE parent_id IN (SELECT id FROM system_dept WHERE parent_id = #{deptId})
|
|
|
+ UNION ALL
|
|
|
+ SELECT id FROM system_dept WHERE parent_id IN (SELECT id FROM system_dept WHERE parent_id IN (SELECT id FROM system_dept WHERE parent_id = #{deptId}))
|
|
|
+ UNION ALL
|
|
|
+ SELECT id FROM system_dept WHERE parent_id IN (SELECT id FROM system_dept WHERE parent_id IN (SELECT id FROM system_dept WHERE parent_id IN (SELECT id FROM system_dept WHERE parent_id = #{deptId})))
|
|
|
+ )
|
|
|
+ <if test="isFill != null">
|
|
|
+ and a.is_fill = #{isFill}
|
|
|
+ </if>
|
|
|
+ <if test="createTime != null and createTime.length > 0">
|
|
|
+ <choose>
|
|
|
+ <when test="createTime.length == 1">
|
|
|
+ AND a.create_time = #{createTime[0],typeHandler=org.apache.ibatis.type.LocalDateTimeTypeHandler}
|
|
|
+ </when>
|
|
|
+ <otherwise>
|
|
|
+ AND a.create_time BETWEEN #{createTime[0],typeHandler=org.apache.ibatis.type.LocalDateTimeTypeHandler} AND #{createTime[1],typeHandler=org.apache.ibatis.type.LocalDateTimeTypeHandler}
|
|
|
+ </otherwise>
|
|
|
+ </choose>
|
|
|
+ </if>
|
|
|
+ <if test="orderName != null and orderName != ''">
|
|
|
+ AND (e.order_name LIKE CONCAT('%', #{orderName}, '%')
|
|
|
+ OR a.device_code LIKE CONCAT('%', #{orderName}, '%')
|
|
|
+ OR a.device_name LIKE CONCAT('%', #{orderName}, '%')
|
|
|
+ OR d.nickname LIKE CONCAT('%', #{orderName}, '%'))
|
|
|
+ </if>
|
|
|
+ order by a.create_time desc,a.is_fill asc,b.name asc
|
|
|
+ </select>
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
<select id="countList" parameterType="cn.iocoder.yudao.module.pms.dal.dataobject.iotcountdata.IotCountDataDO"
|
|
|
resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotcountdata.IotCountDataDO">
|
|
@@ -579,4 +640,44 @@
|
|
|
|
|
|
</select>
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+ <select id="countDeviceList" parameterType="cn.iocoder.yudao.module.pms.dal.dataobject.iotcountdata.IotCountDataDO"
|
|
|
+ resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotcountdata.IotCountDataDO">
|
|
|
+ -- 统计指定部门及其子部门的工单状态
|
|
|
+ -- 第一行:汇总数据
|
|
|
+ SELECT
|
|
|
+ COUNT(a.id) AS total_count,
|
|
|
+ SUM(CASE WHEN a.is_fill = 1 THEN 1 ELSE 0 END) AS filled_count,
|
|
|
+ COUNT(a.id) - SUM(CASE WHEN a.is_fill = 1 THEN 1 ELSE 0 END) AS unfilled_count
|
|
|
+ FROM rq_iot_opeation_fill a
|
|
|
+ WHERE a.deleted = 0
|
|
|
+ AND EXISTS (
|
|
|
+ SELECT 1 FROM system_dept b
|
|
|
+ WHERE a.dept_id = b.id
|
|
|
+ AND b.deleted = 0
|
|
|
+ AND (b.id = #{deptId} OR b.parent_id = #{deptId}
|
|
|
+ OR b.parent_id IN (SELECT id FROM system_dept WHERE parent_id = #{deptId})
|
|
|
+ OR b.parent_id IN (SELECT id FROM system_dept WHERE parent_id IN (SELECT id FROM system_dept WHERE parent_id = #{deptId}))
|
|
|
+ OR b.parent_id IN (SELECT id FROM system_dept WHERE parent_id IN (SELECT id FROM system_dept WHERE parent_id IN (SELECT id FROM system_dept WHERE parent_id = #{deptId})))
|
|
|
+ )
|
|
|
+ )
|
|
|
+ AND EXISTS (
|
|
|
+ SELECT 1 FROM rq_iot_opeation_fill_order e
|
|
|
+ WHERE a.order_id = e.id
|
|
|
+ AND e.deleted = 0
|
|
|
+ AND e.order_name IS NOT NULL
|
|
|
+ )
|
|
|
+ <if test="createTime != null and createTime.length > 0">
|
|
|
+ <choose>
|
|
|
+ <when test="createTime.length == 1">
|
|
|
+ AND a.create_time = #{createTime[0],typeHandler=org.apache.ibatis.type.LocalDateTimeTypeHandler}
|
|
|
+ </when>
|
|
|
+ <otherwise>
|
|
|
+ AND a.create_time BETWEEN #{createTime[0],typeHandler=org.apache.ibatis.type.LocalDateTimeTypeHandler} AND #{createTime[1],typeHandler=org.apache.ibatis.type.LocalDateTimeTypeHandler}
|
|
|
+ </otherwise>
|
|
|
+ </choose>
|
|
|
+ </if>
|
|
|
+ </select>
|
|
|
+
|
|
|
</mapper>
|