From e49b4ed39fa32266ca89e3eaeeeec1f78c42d4b3 Mon Sep 17 00:00:00 2001 From: zhubaomin <zhubaomin> Date: 星期一, 11 十一月 2024 14:27:05 +0800 Subject: [PATCH] 工单任务类型自动初始化 --- pipIrr-platform/pipIrr-global/src/main/resources/mapper/RmCommandHistoryMapper.xml | 95 +++++++++++++++++++---------------------------- 1 files changed, 39 insertions(+), 56 deletions(-) diff --git a/pipIrr-platform/pipIrr-global/src/main/resources/mapper/RmCommandHistoryMapper.xml b/pipIrr-platform/pipIrr-global/src/main/resources/mapper/RmCommandHistoryMapper.xml index 7888144..9925f62 100644 --- a/pipIrr-platform/pipIrr-global/src/main/resources/mapper/RmCommandHistoryMapper.xml +++ b/pipIrr-platform/pipIrr-global/src/main/resources/mapper/RmCommandHistoryMapper.xml @@ -197,55 +197,30 @@ <!--鏍规嵁鎿嶄綔鍛業D鑾峰彇鏈叧闃�璁板綍锛堝寘鍚湪绾挎儏鍐碉級--> <select id="getUnclosedValves" resultType="com.dy.pipIrrGlobal.voRm.VoUnclosedValve"> - SELECT inta.name AS intakeNum, - rtus.isOnLine, - com.rtu_addr AS rtuAddr, - com.param ->> '$.icCardNo' AS vcNum, - (SELECT param ->> '$.orderNo' AS orderNo + SELECT + inta.name AS intakeNum, +<!-- rtus.isOnLine,--> + IFNULL(rtus.isOnLine,'鏈煡') AS isOnLine, + com.rtu_addr AS rtuAddr, + com.param ->> '$.icCardNo' AS vcNum, + ( + SELECT param ->> '$.orderNo' AS orderNo FROM rm_command_history WHERE rtu_addr = com.rtu_addr ORDER BY send_time desc - LIMIT 0,1) AS orderNo, - 'toClose' AS state + LIMIT 0,1 + ) AS orderNo, + 'toClose' AS state, + CASE + WHEN com.command_code = 'A1' OR com.command_code = 'A2' THEN 0 + ELSE 0 + END AS planned, + com.send_time AS sendTime FROM rm_command_history com INNER JOIN pr_controller con ON com.rtu_addr = con.rtuAddr INNER JOIN pr_intake inta ON con.intakeId = inta.id - INNER JOIN JSON_TABLE( - <!--'[{"rtuAddr":"37142501020100215","isOnLine":true},{"rtuAddr":"4000004","isOnLine":true},{"rtuAddr":"dy20240325","isOnLine":false}]',--> - #{onLineMap}, - '$[*]' COLUMNS ( - rtuAddr VARCHAR(20) PATH '$.rtuAddr', - isOnLine BOOLEAN PATH '$.isOnLine' - ) - ) rtus ON com.rtu_addr = rtus.rtuAddr - <where> - AND (com.command_code = '92' OR com.command_code = 'A2' OR com.command_code = '97') - AND com.operator = #{operator} - AND NOT EXISTS( - SELECT * - FROM rm_command_history - WHERE (result IS NULL OR result = 1) - AND (command_code = '93' OR command_code = 'A3' OR command_code = '98') - AND param ->> '$.orderNo' = com.param ->> '$.orderNo' - ) - </where> - GROUP BY inta.name, rtus.isOnLine, com.rtu_addr, com.param ->> '$.icCardNo' - - UNION ALL - - SELECT inta.name AS intakeNum, - rtus.isOnLine, - com.rtu_addr AS rtuAddr, - com.param ->> '$.icCardNo' AS vcNum, - (SELECT param ->> '$.orderNo' AS orderNo - FROM rm_command_history - WHERE rtu_addr = com.rtu_addr - ORDER BY send_time desc - LIMIT 0,1) AS orderNo, - 'toCancel' AS state - FROM rm_command_history com - INNER JOIN pr_intake inta ON inta.id = com.intake_id - INNER JOIN JSON_TABLE( + LEFT JOIN JSON_TABLE( +<!-- '[{"rtuAddr":"620201000030","isOnLine":true}]',--> #{onLineMap}, '$[*]' COLUMNS ( rtuAddr VARCHAR(20) PATH '$.rtuAddr', @@ -253,14 +228,24 @@ ) ) rtus ON com.rtu_addr = rtus.rtuAddr <where> - AND (command_code = 'A1' OR command_code = 'A2') AND com.operator = #{operator} - AND DATE_FORMAT( - CONCAT(com.param ->> '$.year', '-', com.param ->> '$.month', '-', com.param ->> '$.day', - ' ', - com.param ->> '$.hour', ':', com.param ->> '$.minute', ':', '0'), - '%Y-%m-%d %H:%i:%S') > NOW() + AND ((com.protocol = 'p206V1' OR com.protocol = 'p206V2') AND (com.command_code = '92' OR com.command_code = '97' OR com.command_code = '99' OR com.command_code = 'A0' OR com.command_code = 'A1' OR com.command_code = 'A2')) + AND ( + SELECT op_dt FROM rm_open_close_valve_last + WHERE rtu_addr = com.rtu_addr AND op_ic_card_no = com.param ->> '$.icCardNo' + ORDER BY op_dt DESC + LIMIT 1 + ) IS NOT NULL + AND ( + SELECT cl_dt FROM rm_open_close_valve_last + WHERE rtu_addr = com.rtu_addr AND op_ic_card_no = com.param ->> '$.icCardNo' + ORDER BY op_dt DESC + LIMIT 1 + ) IS NULL </where> + GROUP BY inta.name, rtus.isOnLine, com.rtu_addr, com.param ->> '$.icCardNo', com.command_code, com.send_time + ORDER BY com.send_time DESC + LIMIT 1 </select> <!--鏍规嵁鍙栨按鍙D鑾峰彇璇ュ彇姘村彛鏈叧闃�鍙傛暟--> @@ -297,8 +282,6 @@ SELECT COUNT(*) AS recordCount FROM rm_command_history his INNER JOIN pr_intake inta ON inta.id = his.intake_id - LEFT JOIN se_client cli ON cli.id = his.operator - LEFT JOIN ba_user user ON user.id = his.operator <where> <if test="intakeId != null"> AND his.intake_id = #{intakeId} @@ -318,17 +301,17 @@ <!--鏍规嵁鎸囧畾鏉′欢鑾峰彇鍛戒护鏃ュ織鍘嗗彶璁板綍--> <select id="getCommandHistories" resultType="com.dy.pipIrrGlobal.voRm.VoCommand"> SELECT his.com_id AS comId, - his.command_name AS commandName, + CONCAT(his.command_name, '(', his.command_code, ')') AS commandName, inta.name AS intakeName, his.rtu_addr AS rtuAddr, - his.protocol, + his.protocol AS protocol, his.send_time AS sendTime, his.result_time AS resultTime, (CASE WHEN his.result = 1 THEN '鎴愬姛' ELSE '澶辫触' - END) AS result, - his.result_text, + END) AS state, + his.result_text AS result, IFNULL(cli.name, user.name) AS userName FROM rm_command_history his INNER JOIN pr_intake inta ON inta.id = his.intake_id @@ -349,7 +332,7 @@ AND his.send_time BETWEEN #{timeStart} AND #{timeStop} </if> </where> - ORDER BY his.send_time DESC + ORDER BY his.com_id DESC <trim prefix="limit "> <if test="start != null and count != null"> #{start,javaType=Integer,jdbcType=INTEGER}, #{count,javaType=Integer,jdbcType=INTEGER} -- Gitblit v1.8.0