From e9a28062b899087b341514702efe370b3c6df3d4 Mon Sep 17 00:00:00 2001
From: Fancy <Fancy.fx@outlook.com>
Date: 星期三, 16 十月 2024 17:22:02 +0800
Subject: [PATCH] statistic workload change
---
pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/daoOth/OthStatisticWorkloadMapper.java | 2 +-
pms-parent/pms-global/src/main/resources/mapper/OthStatisticWorkloadMapper.xml | 17 +++++++++++------
pms-parent/pms-web-other/src/main/java/com/dy/pmsOther/task/WorkloadTask.java | 7 ++++---
3 files changed, 16 insertions(+), 10 deletions(-)
diff --git a/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/daoOth/OthStatisticWorkloadMapper.java b/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/daoOth/OthStatisticWorkloadMapper.java
index 0cc8409..3d14aff 100644
--- a/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/daoOth/OthStatisticWorkloadMapper.java
+++ b/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/daoOth/OthStatisticWorkloadMapper.java
@@ -28,7 +28,7 @@
int updateByPrimaryKey(OthStatisticWorkload record);
- Date selectMaxDate();
+ String selectMaxDate();
void insertBatch(@Param("startDt")Date startDt, @Param("endDt") Date endDt);
}
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 6e49e54..0d42749 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_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">
@@ -66,7 +71,7 @@
</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
@@ -81,12 +86,12 @@
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">
diff --git a/pms-parent/pms-web-other/src/main/java/com/dy/pmsOther/task/WorkloadTask.java b/pms-parent/pms-web-other/src/main/java/com/dy/pmsOther/task/WorkloadTask.java
index e39742c..2ad3c44 100644
--- a/pms-parent/pms-web-other/src/main/java/com/dy/pmsOther/task/WorkloadTask.java
+++ b/pms-parent/pms-web-other/src/main/java/com/dy/pmsOther/task/WorkloadTask.java
@@ -28,14 +28,15 @@
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);
--
Gitblit v1.8.0