| | |
| | | DATE_FORMAT(DATE_SUB(NOW(), INTERVAL 1 DAY),'%Y-%m-%d') -- 如果两个表都没有数据,返回前一天时间 无用 |
| | | ) AS max_date; |
| | | </select> |
| | | |
| | | <select id="queryStatisticWork" resultType="cn.hutool.json.JSONObject"> |
| | | WITH total as (select |
| | | 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 DISTINCT device_no,plan_id,station_id,curr_node,node_content,number,updated_by from sta_device_production_log_past |
| | | where out_time BETWEEN #{startDt} AND #{endDt} |
| | | union |
| | | 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), |
| | | 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 user_name, MAX(CASE record.type WHEN '计划任务' THEN record.number ELSE 0 END) plan, |
| | | MAX(CASE record.type WHEN '临时任务' THEN record.number ELSE 0 END) unplan_device, |
| | | MAX(CASE record.type WHEN '临时任务(无设备码)' THEN record.number ELSE 0 END) unplan, |
| | | MAX(CASE record.type WHEN '辅助工作' THEN record.number ELSE 0 END) assistant |
| | | FROM ( |
| | | select user_name,'计划任务' AS type,sum(number) as number from total where curr_node IS NOT NULL GROUP BY user_name |
| | | UNION |
| | | select user_name,'临时任务' AS type, sum(number) as number from total where curr_node IS NULL AND (device_no !='' AND device_no IS NOT NULL) GROUP BY user_name |
| | | UNION |
| | | select user_name,'临时任务(无设备码)' AS type, sum(number) as number from total where curr_node IS NULL AND (device_no IS NULL OR device_no ='') GROUP BY user_name |
| | | UNION |
| | | select user_name,'辅助工作' AS type , sum(number) as number from assistants_total GROUP BY user_name ) record GROUP BY record.user_name; |
| | | </select> |
| | | <delete id="deleteByPrimaryKey" parameterType="java.lang.Long"> |
| | | delete from oth_statistic_workload |
| | | where id = #{id,jdbcType=BIGINT} |
| | | </delete> |
| | | <insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.dy.pmsGlobal.pojoOth.OthStatisticWorkload" useGeneratedKeys="true"> |
| | | <insert id="insert" parameterType="com.dy.pmsGlobal.pojoOth.OthStatisticWorkload"> |
| | | insert into oth_statistic_workload |
| | | ( id,statistic_date,user_id |
| | | ,user_name,type,node_content |
| | |
| | | ,#{userName,jdbcType=VARCHAR},#{type,jdbcType=VARCHAR},#{nodeContent,jdbcType=VARCHAR} |
| | | ,#{number,jdbcType=INTEGER}) |
| | | </insert> |
| | | <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.dy.pmsGlobal.pojoOth.OthStatisticWorkload" useGeneratedKeys="true"> |
| | | <insert id="insertSelective" parameterType="com.dy.pmsGlobal.pojoOth.OthStatisticWorkload"> |
| | | insert into oth_statistic_workload |
| | | <trim prefix="(" suffix=")" suffixOverrides=","> |
| | | <if test="id != null">id,</if> |