瀏覽代碼

运行记录调整优化

lipenghui 1 周之前
父節點
當前提交
2a90950683
共有 1 個文件被更改,包括 203 次插入195 次删除
  1. 203 195
      yudao-module-pms/yudao-module-pms-biz/src/main/resources/mapper/static/IotOpeationFillMapper.xml

+ 203 - 195
yudao-module-pms/yudao-module-pms-biz/src/main/resources/mapper/static/IotOpeationFillMapper.xml

@@ -7,32 +7,32 @@
             resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO">
 
         select
-            distinct
-            c.id,
-            c.dept_id,
-            c.device_code,
-            c.device_name,
-            b.device_category_id,
-            d.person_id user_id
+        distinct
+        c.id,
+        c.dept_id,
+        c.device_code,
+        c.device_name,
+        b.device_category_id,
+        d.person_id user_id
         from
-            rq_iot_model_template a,
-            rq_iot_model_template_attrs b,
-            rq_iot_device c,
-            rq_iot_device_person d
+        rq_iot_model_template a,
+        rq_iot_model_template_attrs b,
+        rq_iot_device c,
+        rq_iot_device_person d
         where
-            a.device_category_id = b.device_category_id
-          and
-            a.device_category_id = c.asset_class
-          and
-            c.id = d.device_id
-          and
-            c.device_status in ('sg','dm')
-          and
-            a.deleted = 0
-          and
-            c.deleted = 0
-          and
-            d.deleted = 0
+        a.device_category_id = b.device_category_id
+        and
+        a.device_category_id = c.asset_class
+        and
+        c.id = d.device_id
+        and
+        c.device_status in ('sg','dm')
+        and
+        a.deleted = 0
+        and
+        c.deleted = 0
+        and
+        d.deleted = 0
         <if test="deviceIds != null and !deviceIds.isEmpty()">
             and c.id  in
             <foreach collection="deviceIds" item="id" open="(" separator="," close=")">
@@ -50,25 +50,25 @@
     <select id="getFillDevices1"
             resultType="cn.iocoder.yudao.module.pms.controller.admin.vo.IotDeviceRespVO">
         select
-            distinct
-            c.id,
-            c.dept_id,
-            c.device_code,
-            c.device_name,
-            b.device_category_id,
-            d.person_id user_id,
-            e.name dept_name,
-            f.nickname,
-            g.name,
-            c.device_status
+        distinct
+        c.id,
+        c.dept_id,
+        c.device_code,
+        c.device_name,
+        b.device_category_id,
+        d.person_id user_id,
+        e.name dept_name,
+        f.nickname,
+        g.name,
+        c.device_status
         from
-            rq_iot_model_template a,
-            rq_iot_model_template_attrs b,
-            rq_iot_device c,
-            rq_iot_device_person d,
-            system_dept e,
-            system_users f,
-            rq_iot_product_classify g
+        rq_iot_model_template a,
+        rq_iot_model_template_attrs b,
+        rq_iot_device c,
+        rq_iot_device_person d,
+        system_dept e,
+        system_users f,
+        rq_iot_product_classify g
         where
         a.device_category_id = b.device_category_id
         and
@@ -154,31 +154,31 @@
 
 
     <insert id="insertFill"
-    parameterType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO">
-       insert into rq_iot_opeation_fill(device_id,device_code,device_name,device_category_id,create_time,dept_id,order_id,is_report)
-           values
+            parameterType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO">
+        insert into rq_iot_opeation_fill(device_id,device_code,device_name,device_category_id,create_time,dept_id,order_id,is_report)
+        values
         <foreach collection="list" item="item" separator=",">
             (#{item.deviceId},#{item.deviceCode},#{item.deviceName},
             #{item.deviceCategoryId},#{item.createTime},#{item.deptId},#{item.orderId},#{item.isReport})
         </foreach>
     </insert>
 
-   <!-- <insert id="insertFillOrder"
-            parameterType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO">
-        insert into rq_iot_opeation_fill_order(dept_id,order_name,
-        order_status,create_time,order_type,user_name,user_id)
-        values
-        <foreach collection="list" item="item" separator=",">
-            (#{item.deptId},#{item.orderName},#{item.orderStatus},
-            #{item.createTime},#{item.orderType},#{item.userName},#{item.userId})
-        </foreach>
+    <!-- <insert id="insertFillOrder"
+             parameterType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO">
+         insert into rq_iot_opeation_fill_order(dept_id,order_name,
+         order_status,create_time,order_type,user_name,user_id)
+         values
+         <foreach collection="list" item="item" separator=",">
+             (#{item.deptId},#{item.orderName},#{item.orderStatus},
+             #{item.createTime},#{item.orderType},#{item.userName},#{item.userId})
+         </foreach>
 
-    </insert>-->
+     </insert>-->
 
     <insert id="insertLog"
             parameterType="cn.iocoder.yudao.module.pms.dal.dataobject.iotdevicerunlog.IotDeviceRunLogDO">
         insert into rq_iot_device_run_log
-            (dept_id,device_id,device_code,point_code,fill_content,create_time,point_name,total_run_time,is_sum)
+        (dept_id,device_id,device_code,point_code,fill_content,create_time,point_name,total_run_time,is_sum)
         values
         <foreach collection="list" item="item" separator=",">
             (#{item.deptId},#{item.deviceId},#{item.deviceCode},
@@ -192,22 +192,22 @@
         insert into rq_iot_device_run_log
         (dept_id, device_id, device_code, point_code, fill_content, create_time, point_name, total_run_time,is_sum)
         values
-        (#{deptId}, #{deviceId}, #{deviceCode},
-         #{pointCode}, #{fillContent}, #{createTime}, #{pointName}, #{totalRunTime},#{isSum})
+            (#{deptId}, #{deviceId}, #{deviceCode},
+             #{pointCode}, #{fillContent}, #{createTime}, #{pointName}, #{totalRunTime},#{isSum})
     </insert>
 
     <update id="updateLog" parameterType="cn.iocoder.yudao.module.pms.dal.dataobject.iotdevicerunlog.IotDeviceRunLogDO">
         update rq_iot_device_run_log
         set
-        fill_content = #{fillContent}
+            fill_content = #{fillContent}
         where
-            device_code = #{deviceCode}
-        and
+            device_id = #{deviceId}
+          and
             point_name = #{pointName}
-        and
+          and
             DATE(create_time) = #{createTime}
-        and
-           is_sum = 0
+          and
+            is_sum = 0
     </update>
 
     <update id="updateSumLog" parameterType="cn.iocoder.yudao.module.pms.dal.dataobject.iotdevicerunlog.IotDeviceRunLogDO">
@@ -215,7 +215,7 @@
         set
             total_run_time = #{totalRunTime}
         where
-            device_code = #{deviceCode}
+            device_id = #{deviceId}
           and
             point_name = #{pointName}
           and
@@ -224,20 +224,20 @@
             is_sum = 1
     </update>
 
-   <!-- <select id="fillList" parameterType="cn.iocoder.yudao.module.pms.controller.admin.iotopeationfill.vo.IotOpeationFillRespVO"
-    resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO">
-        SELECT * FROM
-            rq_iot_opeation_fill
-        WHERE DATE(create_time) = CURDATE()
-        <if test="deptId != null  and deptId != ''">
-        and dept_id in (SELECT d1.id
-            FROM system_dept d1
-            JOIN system_dept d2 ON d2.id = d1.parent_id
-            WHERE d2.parent_id = #{deptId}
-            union
-            select id from system_dept where id = #{deptId})
-        </if>
-    </select>-->
+    <!-- <select id="fillList" parameterType="cn.iocoder.yudao.module.pms.controller.admin.iotopeationfill.vo.IotOpeationFillRespVO"
+     resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO">
+         SELECT * FROM
+             rq_iot_opeation_fill
+         WHERE DATE(create_time) = CURDATE()
+         <if test="deptId != null  and deptId != ''">
+         and dept_id in (SELECT d1.id
+             FROM system_dept d1
+             JOIN system_dept d2 ON d2.id = d1.parent_id
+             WHERE d2.parent_id = #{deptId}
+             union
+             select id from system_dept where id = #{deptId})
+         </if>
+     </select>-->
     <select id="fillList" parameterType="cn.iocoder.yudao.module.pms.controller.admin.iotopeationfill.vo.IotOpeationFillRespVO"
             resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO">
         SELECT * FROM
@@ -276,9 +276,9 @@
     <update id="upFill1" parameterType="cn.iocoder.yudao.module.pms.controller.admin.iotopeationfill.vo.IotOpeationFillSaveReqVO">
         update rq_iot_opeation_fill_order
         set order_status = '3',
-        reason = #{reason}
+            reason = #{reason}
         where
-        id = #{id}
+            id = #{id}
     </update>
 
 
@@ -321,7 +321,7 @@
         AND -->(
         1=1
         <if test="orderId != null and orderId != ''">
-           and  a.order_id = #{orderId}
+            and  a.order_id = #{orderId}
         </if>
         <!--<if test="orgName != null and orgName != ''">
             (
@@ -343,18 +343,18 @@
     <select id="getOrderIds" parameterType="cn.iocoder.yudao.module.pms.controller.admin.iotopeationfill.vo.IotOpeationFillRespVO"
             resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO">
         select
-            distinct a.order_id
+        distinct a.order_id
         from
         rq_iot_opeation_fill a,
         rq_iot_opeation_fill_order b
         where
-            a.order_id = b.id
+        a.order_id = b.id
         and
-            a.deleted = 0
+        a.deleted = 0
         and
-            b.deleted = 0
+        b.deleted = 0
         and
-            a.order_id is not null
+        a.order_id is not null
         and(
         <if test="orgName != null and orgName != ''">
             (
@@ -402,7 +402,7 @@
             rq_iot_opeation_fill
         WHERE
             order_id = #{orderId}
-        and
+          and
             dept_id IN (
                 SELECT id FROM (
                                    SELECT d1.id FROM system_dept d1 WHERE d1.id = #{deptId}
@@ -414,7 +414,7 @@
                                    SELECT d4.id FROM system_dept d1 JOIN system_dept d2 ON d2.parent_id = d1.id JOIN system_dept d3 ON d3.parent_id = d2.id JOIN system_dept d4 ON d4.parent_id = d3.id WHERE d1.id = #{deptId}
                                ) AS dept_hierarchy
             )
-        and device_name != '日报填报'
+          and device_name != '日报填报'
     </select>
 
     <!--  -->
@@ -532,22 +532,22 @@
 
     <select id="pdList" resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO">
         select
-            distinct
-            b.id user_id,
-            b.nickname user_name,
-            c.id dept_id,
-            b.mobile,
-            c.name orgName
+        distinct
+        b.id user_id,
+        b.nickname user_name,
+        c.id dept_id,
+        b.mobile,
+        c.name orgName
         from
-            rq_iot_device_person a
-                left join
-            system_users b
-            on
-                a.person_id = b.id
-                left join
-            system_dept c
-            on
-                b.dept_id = c.id
+        rq_iot_device_person a
+        left join
+        system_users b
+        on
+        a.person_id = b.id
+        left join
+        system_dept c
+        on
+        b.dept_id = c.id
         where b.id is not null
         <if test="deviceIds != null and !deviceIds.isEmpty()">
             and a.device_id  in
@@ -588,70 +588,70 @@
     <select id="allOrder" resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillOrderDO">
         select distinct user_name
         from
-            rq_iot_opeation_fill_order
+        rq_iot_opeation_fill_order
         where
-            DATE(create_time) = DATE(#{localDateTime})
-            <if test="userNames != null and !userNames.isEmpty()">
-                and user_name  in
-                <foreach collection="userNames" item="userName" open="(" separator="," close=")">
-                    #{userName}
-                </foreach>
-            </if>
+        DATE(create_time) = DATE(#{localDateTime})
+        <if test="userNames != null and !userNames.isEmpty()">
+            and user_name  in
+            <foreach collection="userNames" item="userName" open="(" separator="," close=")">
+                #{userName}
+            </foreach>
+        </if>
     </select>
 
     <select id="pdList2" resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO">
         select
-            distinct
-            b.id user_id,
-            b.nickname user_name,
-            c.id dept_id,
-            b.mobile,
-            c.name orgName
+        distinct
+        b.id user_id,
+        b.nickname user_name,
+        c.id dept_id,
+        b.mobile,
+        c.name orgName
         from
-            rq_iot_device_person a
-                left join
-            system_users b
-            on
-                a.person_id = b.id
-                left join
-            system_dept c
-            on
-                b.dept_id = c.id
+        rq_iot_device_person a
+        left join
+        system_users b
+        on
+        a.person_id = b.id
+        left join
+        system_dept c
+        on
+        b.dept_id = c.id
         where
-            b.id is not null
-          and
-            c.id is not null
+        b.id is not null
+        and
+        c.id is not null
         <if test="deviceIds != null and !deviceIds.isEmpty()">
             and c.id  in
             <foreach collection="deviceIds" item="id" open="(" separator="," close=")">
                 #{id}
             </foreach>
         </if>
-          and
-            a.person_id
-            not in
-              (select
-                   distinct
-                   d.person_id
-               from
-                   rq_iot_model_template a,
-                   rq_iot_model_template_attrs b,
-                   rq_iot_device c,
-                   rq_iot_device_person d
-               where
-                   a.device_category_id = b.device_category_id
-                 and
-                   a.device_category_id = c.asset_class
-                 and
-                   c.id = d.device_id
-                 and
-                   c.device_status in ('sg','dm')
-                 and
-                   a.deleted = 0
-                 and
-                   c.deleted = 0
-                 and
-                   d.deleted = 0)
+        and
+        a.person_id
+        not in
+        (select
+        distinct
+        d.person_id
+        from
+        rq_iot_model_template a,
+        rq_iot_model_template_attrs b,
+        rq_iot_device c,
+        rq_iot_device_person d
+        where
+        a.device_category_id = b.device_category_id
+        and
+        a.device_category_id = c.asset_class
+        and
+        c.id = d.device_id
+        and
+        c.device_status in ('sg','dm')
+        and
+        a.deleted = 0
+        and
+        c.deleted = 0
+        and
+        d.deleted = 0)
     </select>
 
     <select id="fillList1" parameterType="cn.iocoder.yudao.module.pms.controller.admin.iotopeationfill.vo.IotOpeationFillRespVO"
@@ -666,7 +666,7 @@
 
 
     <select id="getAttrsById" parameterType="cn.iocoder.yudao.module.pms.controller.admin.vo.IotDeviceRespVO"
-    resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotmodeltemplateattrs.IotModelTemplateAttrsDO">
+            resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotmodeltemplateattrs.IotModelTemplateAttrsDO">
         select
             id,
             name,
@@ -685,16 +685,16 @@
 
     <update id="updateFill"  parameterType="cn.iocoder.yudao.module.pms.controller.admin.vo.IotOpeationModelPageReqVO">
         update  rq_iot_opeation_fill
-         set is_fill = '1'
+        set is_fill = '1'
         where device_id = #{deviceId}
-        and DATE(create_time) = DATE(#{createTime})
+          and DATE(create_time) = DATE(#{createTime})
     </update>
 
     <select id="getFillList" parameterType="cn.iocoder.yudao.module.pms.controller.admin.iotopeationfill.vo.IotOpeationFillRespVO"
             resultType="cn.iocoder.yudao.module.pms.controller.admin.iotopeationfill.vo.IotOpeationFillRespVO">
         select distinct b.* from
-            rq_iot_opeation_fill b,
-            rq_iot_opeation_fill_order c
+                                rq_iot_opeation_fill b,
+                                rq_iot_opeation_fill_order c
         where
             c.id = #{orderId}
           and
@@ -708,7 +708,7 @@
 
 
     <select id="getDeivceFillInfo" parameterType="cn.iocoder.yudao.module.pms.dal.dataobject.iotdevicerunlog.IotDeviceRunLogDO"
-    resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotdevicerunlog.IotDeviceRunLogDO">
+            resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotdevicerunlog.IotDeviceRunLogDO">
         <!--SELECT * FROM rq_iot_device_run_log
         WHERE
             device_id = #{deviceId}
@@ -770,17 +770,17 @@
 
 
     <select id="devList" parameterType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO"
-    resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO">
+            resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO">
         select device_id from rq_iot_opeation_fill where order_id = #{orderId}
     </select>
 
     <select id="orderList" parameterType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO"
             resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO">
         select distinct order_id
-         from
-             rq_iot_opeation_fill
+        from
+            rq_iot_opeation_fill
         where
-             device_id = #{deviceId}
+            device_id = #{deviceId}
           and DATE(create_time) = #{creDate}
           and order_id != #{orderId}
     </select>
@@ -823,14 +823,14 @@
     <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
+        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
@@ -884,7 +884,7 @@
 
 
     <select id="countList" parameterType="cn.iocoder.yudao.module.pms.dal.dataobject.iotcountdata.IotCountDataDO"
-    resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotcountdata.IotCountDataDO">
+            resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotcountdata.IotCountDataDO">
         -- 统计指定部门及其子部门的工单状态
         SELECT
         dept_id,
@@ -1040,22 +1040,30 @@
 
 
     <select id="childList" parameterType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillOrderDO"
-    resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillOrderDO">
+            resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillOrderDO">
         SELECT id dept_id
         FROM system_dept
         WHERE parent_id = #{deptId}
           AND deleted = 0
     </select>
 
+    <select id="devStatus" parameterType="cn.iocoder.yudao.module.pms.dal.dataobject.IotDeviceDO"
+            resultType="cn.iocoder.yudao.module.pms.dal.dataobject.IotDeviceDO">
+        SELECT order_status
+        FROM rq_iot_device
+        WHERE dept_id = #{deptId}
+          AND asset_class in (159,160)
+    </select>
+
     <select id="isReport" parameterType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO"
-    resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO">
+            resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO">
         select * from
             rq_iot_opeation_fill
         where
             device_id = #{deviceId}
-        and
+          and
             DATE(create_time) = DATE(#{createTime})
-        LIMIT 1
+            LIMIT 1
     </select>
 
     <select id="orderDO" parameterType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO"
@@ -1066,7 +1074,7 @@
             rq_iot_opeation_fill
         where
             device_id = #{deviceId}
-        and
+          and
             DATE(create_time) = #{createTime}
     </select>
 
@@ -1080,34 +1088,34 @@
             b.name AS org_name
         FROM
             rq_iot_opeation_fill a
-        INNER JOIN
+                INNER JOIN
             rq_iot_model_template_attrs b
-        ON
-            a.device_category_id = b.device_category_id
+            ON
+                a.device_category_id = b.device_category_id
         WHERE
             a.order_id = #{orderId}
-        AND (
-        -- 第一个查询的条件
+          AND (
+            -- 第一个查询的条件
             (a.is_report = 1 AND b.daily_report = 0
-            AND b.name NOT IN (
+                AND b.name NOT IN (
                     SELECT
                         DISTINCT
                         b2.name
                     FROM
                         rq_iot_opeation_fill a2
-                    INNER JOIN
+                            INNER JOIN
                         rq_iot_model_template_attrs b2
-                    ON
-                        a2.device_category_id = b2.device_category_id
+                        ON
+                            a2.device_category_id = b2.device_category_id
                     WHERE
-                       a2.order_id =  #{orderId}
-                    AND
-                       a2.is_report = 0
-                    AND
-                       b2.daily_report = 1
+                        a2.order_id =  #{orderId}
+                      AND
+                        a2.is_report = 0
+                      AND
+                        b2.daily_report = 1
                 ))
-            -- 第二个查询的条件(通过OR代替UNION)
-             OR (a.is_report is null AND b.daily_report = 1)
+                -- 第二个查询的条件(通过OR代替UNION)
+                OR (a.is_report is null AND b.daily_report = 1)
             )
           and a.device_code != ''
     </select>