statistic workload change
| | |
| | | |
| | | int updateByPrimaryKey(OthStatisticWorkload record); |
| | | |
| | | Date selectMaxDate(); |
| | | String selectMaxDate(); |
| | | |
| | | void insertBatch(@Param("startDt")Date startDt, @Param("endDt") Date endDt); |
| | | } |
| | |
| | | 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_device), |
| | | (SELECT DATE_FORMAT(MIN(out_line_time),'%Y-%m-%d') FROM sta_device_last where status =2 and out_line_time is not null), |
| | | DATE_FORMAT(NOW() ,'%Y-%m-%d') -- 如果两个表都没有数据,返回当前时间 |
| | | ) AS max_date; |
| | | </select> |
| | | |
| | | <delete id="deleteByPrimaryKey" parameterType="java.lang.Long"> |
| | |
| | | </insert> |
| | | <insert id="insertBatch"> |
| | | INSERT INTO oth_statistic_workload |
| | | (id,statistic_date,user_id |
| | | (statistic_date,user_id |
| | | ,user_name,type,node_content |
| | | ,number) |
| | | WITH total as (select |
| | |
| | | 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 null AS id, 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 |
| | | 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 null AS id, 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) |
| | | 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 null AS id, 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 ='') |
| | | 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; |
| | | </insert> |
| | | <update id="updateByPrimaryKeySelective" parameterType="com.dy.pmsGlobal.pojoOth.OthStatisticWorkload"> |
| | |
| | | log.info("启动统计人员工作量任务"); |
| | | OthStatisticWorkloadMapper workloadMapper = SpringContextUtil.getBean(OthStatisticWorkloadMapper.class); |
| | | //找到最大一条日期记录 |
| | | Date maxDate = workloadMapper.selectMaxDate(); |
| | | DateTimeFormatter formatter = DateTimeFormatter.ISO_DATE; |
| | | LocalDate maxLocalDate = LocalDate.parse(workloadMapper.selectMaxDate(), formatter); |
| | | //往后循环天数汇总 //循环统计 |
| | | LocalDate maxLocalDate = null; |
| | | /* LocalDate maxLocalDate = null; |
| | | if (maxDate == null) { |
| | | maxLocalDate = LocalDate.now().minusDays(2); |
| | | } else { |
| | | maxLocalDate = maxDate.toInstant().atZone(ZoneId.systemDefault()).toLocalDate(); |
| | | } |
| | | }*/ |
| | | |
| | | LocalDate today = LocalDate.now(); |
| | | LocalDate statisticDate = maxLocalDate.plusDays(1); |