id,statistic_date,user_id,
user_name,type,node_content,
number
delete from oth_statistic_workload
where id = #{id,jdbcType=BIGINT}
insert into oth_statistic_workload
( id,statistic_date,user_id
,user_name,type,node_content
,number)
values (#{id,jdbcType=BIGINT},#{statisticDate,jdbcType=DATE},#{userId,jdbcType=BIGINT}
,#{userName,jdbcType=VARCHAR},#{type,jdbcType=VARCHAR},#{nodeContent,jdbcType=VARCHAR}
,#{number,jdbcType=INTEGER})
insert into oth_statistic_workload
id,statistic_date,user_id,user_name,type,node_content,number,#{id,jdbcType=BIGINT},#{statisticDate,jdbcType=DATE},#{userId,jdbcType=BIGINT},#{userName,jdbcType=VARCHAR},#{type,jdbcType=VARCHAR},#{nodeContent,jdbcType=VARCHAR},#{number,jdbcType=INTEGER},
INSERT INTO oth_statistic_workload
(statistic_date,user_id
,user_name,type,node_content
,number)
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 * from sta_device_production_log_past
where repair_id IS NULL and 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}
) 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
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;
update oth_statistic_workload
statistic_date = #{statisticDate,jdbcType=DATE},
user_id = #{userId,jdbcType=BIGINT},
user_name = #{userName,jdbcType=VARCHAR},
type = #{type,jdbcType=VARCHAR},
node_content = #{nodeContent,jdbcType=VARCHAR},
number = #{number,jdbcType=INTEGER},
where id = #{id,jdbcType=BIGINT}
update oth_statistic_workload
set
statistic_date = #{statisticDate,jdbcType=DATE},
user_id = #{userId,jdbcType=BIGINT},
user_name = #{userName,jdbcType=VARCHAR},
type = #{type,jdbcType=VARCHAR},
node_content = #{nodeContent,jdbcType=VARCHAR},
number = #{number,jdbcType=INTEGER}
where id = #{id,jdbcType=BIGINT}