From 8000dd179e5a1eef3113cbd75dddb32bbb805d1c Mon Sep 17 00:00:00 2001 From: Fancy <Fancy.fx@outlook.com> Date: 星期二, 07 一月 2025 11:58:12 +0800 Subject: [PATCH] edit --- pms-parent/pms-global/src/main/resources/mapper/OthStatisticWorkloadMapper.xml | 40 +++++++++++++++++++++++++++++++--------- 1 files changed, 31 insertions(+), 9 deletions(-) diff --git a/pms-parent/pms-global/src/main/resources/mapper/OthStatisticWorkloadMapper.xml b/pms-parent/pms-global/src/main/resources/mapper/OthStatisticWorkloadMapper.xml index 88aac97..314b3d2 100644 --- a/pms-parent/pms-global/src/main/resources/mapper/OthStatisticWorkloadMapper.xml +++ b/pms-parent/pms-global/src/main/resources/mapper/OthStatisticWorkloadMapper.xml @@ -26,8 +26,13 @@ from oth_statistic_workload where id = #{id,jdbcType=BIGINT} </select> - <select id="selectMaxDate" resultType="java.util.Date"> - select max(statistic_date) from oth_statistic_workload + + <select id="selectMaxDate" resultType="java.lang.String"> + SELECT COALESCE( + (SELECT DATE_ADD(MAX(statistic_date), INTERVAL 1 DAY) FROM oth_statistic_workload), + (SELECT DATE_FORMAT(MIN(out_time),'%Y-%m-%d') FROM sta_device_last), + DATE_FORMAT(DATE_SUB(NOW(), INTERVAL 1 DAY),'%Y-%m-%d') -- 濡傛灉涓や釜琛ㄩ兘娌℃湁鏁版嵁锛岃繑鍥炲墠涓�澶╂椂闂� 鏃犵敤 + ) AS max_date; </select> <delete id="deleteByPrimaryKey" parameterType="java.lang.Long"> @@ -70,23 +75,40 @@ ,user_name,type,node_content ,number) WITH total as (select - DISTINCT(t.device_no),t.curr_node,t.node_content,t.number,p.pro_name, p.plan_name,u.id user_id,u.`name` user_name + DISTINCT(t.device_no) device_no,t.curr_node,t.node_content,t.number,p.pro_name, p.plan_name,u.id user_id,u.`name` user_name FROM - (select * from sta_device_production_log_past - where repair_id IS NULL and out_time BETWEEN #{startDt} AND #{endDt} + (select DISTINCT device_no,plan_id,station_id,curr_node,node_content,number,updated_by from sta_device_production_log_past + <!-- repair_id IS NULL and --> + where out_time BETWEEN #{startDt} AND #{endDt} union - select * from sta_device_production_log - where repair_id IS NULL and out_time BETWEEN #{startDt} AND #{endDt} + select DISTINCT device_no,plan_id,station_id,curr_node,node_content,number,updated_by from sta_device_production_log + where out_time BETWEEN #{startDt} AND #{endDt} ) t left join (select pap.id,pap.`name` as plan_name,pp.`name` as pro_name from pr_assembly_plan pap, plt_product pp where pap.pro_id = pp.id) p on t.plan_id = p.id - left JOIN ba_user u on u.id=t.updated_by) - select DATE_FORMAT(#{startDt}, '%Y-%m-%d') as statistic_date,user_id, user_name,'璁″垝浠诲姟' AS type, node_content ,sum(number) as number from total where curr_node IS NOT NULL GROUP BY user_id,user_name,node_content + left JOIN ba_user u on u.id=t.updated_by), + WITH assistants_total as (select t.device_no,t.curr_node,t.node_content,t.number,p.pro_name, p.plan_name,u.id user_id,u.`name` user_name + FROM + ( SELECT a.*,SUBSTRING_INDEX( SUBSTRING_INDEX( a.assistants, ',', b.help_topic_id + 1 ), ',', - 1 ) AS assistant FROM + (select DISTINCT device_no,plan_id,station_id,curr_node,node_content,number,updated_by,assistants from sta_device_production_log_past + where assistants IS NOT NULL AND out_time BETWEEN #{startDt} AND #{endDt} + union + select DISTINCT device_no,plan_id,station_id,curr_node,node_content,number,updated_by,assistants from sta_device_production_log + where assistants IS NOT NULL AND out_time BETWEEN #{startDt} AND #{endDt}) a + JOIN mysql.help_topic AS b ON b.help_topic_id <![CDATA[ < ]]> ( LENGTH( a.assistants ) - LENGTH( REPLACE ( a.assistants, ',', '' ) ) + 1 ) + ) t + left join (select pap.id,pap.`name` as plan_name,pp.`name` as pro_name + from pr_assembly_plan pap, plt_product pp where pap.pro_id = pp.id) p on t.plan_id = p.id + left JOIN ba_user u on u.id=t.assistant) + select DATE_FORMAT(#{startDt}, '%Y-%m-%d') as statistic_date,user_id, user_name,'璁″垝浠诲姟' AS type, node_content ,sum(number) as number from total where curr_node IS NOT NULL GROUP BY user_id,user_name,node_content UNION select DATE_FORMAT(#{startDt}, '%Y-%m-%d') as statistic_date, user_id, user_name,'涓存椂浠诲姟' AS type, node_content, sum(number) as number from total where curr_node IS NULL AND (device_no !='' AND device_no IS NOT NULL) GROUP BY user_id,user_name,node_content UNION select DATE_FORMAT(#{startDt}, '%Y-%m-%d') as statistic_date,user_id , user_name,'涓存椂浠诲姟(鏃犺澶囩爜)' AS type,node_content, sum(number) as number from total where curr_node IS NULL AND (device_no IS NULL OR device_no ='') + GROUP BY user_id,user_name,node_content + UNION + select DATE_FORMAT(#{startDt}, '%Y-%m-%d') as statistic_date,user_id , user_name,'杈呭姪宸ヤ綔' AS type,node_content, sum(number) as number from assistants_total GROUP BY user_id,user_name,node_content; </insert> <update id="updateByPrimaryKeySelective" parameterType="com.dy.pmsGlobal.pojoOth.OthStatisticWorkload"> -- Gitblit v1.8.0