From 5bd56f3ebf96aa9a71e4a452cd2402df59d17384 Mon Sep 17 00:00:00 2001
From: 严智鑫 <test>
Date: 星期四, 04 九月 2025 09:28:27 +0800
Subject: [PATCH] 1.全部页面增加线下数据查询 2.增加一键删除线下玻璃按钮
---
JiuMuMesParent/moduleService/DeviceInteractionModule/src/main/java/com/mes/md/service/impl/TaskingLogServiceImpl.java | 160 +++++++++++++++++++++++++++++++++++++++++++++++++++--
1 files changed, 154 insertions(+), 6 deletions(-)
diff --git a/JiuMuMesParent/moduleService/DeviceInteractionModule/src/main/java/com/mes/md/service/impl/TaskingLogServiceImpl.java b/JiuMuMesParent/moduleService/DeviceInteractionModule/src/main/java/com/mes/md/service/impl/TaskingLogServiceImpl.java
index 242a9f5..6a8b100 100644
--- a/JiuMuMesParent/moduleService/DeviceInteractionModule/src/main/java/com/mes/md/service/impl/TaskingLogServiceImpl.java
+++ b/JiuMuMesParent/moduleService/DeviceInteractionModule/src/main/java/com/mes/md/service/impl/TaskingLogServiceImpl.java
@@ -74,10 +74,14 @@
if (lineType != null && !lineType.isEmpty()) {
taskingWrapper.apply("operation_record REGEXP '.*[^0-9]" + lineType + "$'");
}
-
- // 鎸夋椂闂存帓搴�
- taskingWrapper.orderByDesc("operation_record_time");
-
+
+ // 鎸夋椂闂存帓搴忥紙闄嶅簭)
+ //taskingWrapper.orderByDesc("operation_record_time");
+ //(鍗囧簭)
+ taskingWrapper.orderByAsc("operation_record_time");
+ // 鍏堟寜sortOrder鎺掑簭锛屽啀鎸夋椂闂存帓搴�
+ //taskingWrapper.orderByAsc("sort_order", "operation_record_time");
+
// 鎵ц鏌ヨ
List<Map<String, Object>> taskingList = baseMapper.selectMaps(taskingWrapper);
@@ -116,7 +120,6 @@
List<Map<String, Object>> listTasking1 = baseMapper.selectMaps(new QueryWrapper<TaskingLog>()
.select("task_type, operation_record, operation_mode, DATE_FORMAT(operation_record_time, '%Y-%m-%d') as operation_record_time, count(*) as count")
- .eq("task_type", "瀹氬埗")
.eq("operation_record", "鏃嬭浆1")
.eq("operation_mode", "缁撴潫")
.gt("operation_record_time", startDate)
@@ -124,7 +127,6 @@
.orderByAsc("DATE_FORMAT(operation_record_time, '%Y-%m-%d')"));
List<Map<String, Object>> listTasking2 = baseMapper.selectMaps(new QueryWrapper<TaskingLog>()
.select("task_type,operation_record,operation_mode,DATE_FORMAT(operation_record_time, '%Y-%m-%d') as operation_record_time,count(1) as count")
- .eq("task_type", "瀹氬埗")
.eq("operation_record", "鏃嬭浆2")
.eq("operation_mode", "缁撴潫")
.gt("operation_record_time", startDate)
@@ -274,4 +276,150 @@
}
return 0;
}
+
+
+ /**
+ * 鏌ヨ鍗曞皬鏃朵骇閲�
+ * @param dayCount 鏌ヨ澶╂暟
+ * @return Map 鍖呭惈姣忓ぉ涓ゆ潯绾跨殑骞冲潎灏忔椂浜ч噺
+ */
+ @Override
+ public Map<String, Object> findHourlyOutput(int dayCount) {
+ try {
+ // 璁$畻寮�濮嬫椂闂�
+ Calendar cal = Calendar.getInstance();
+ cal.setTime(new Date());
+ cal.set(Calendar.HOUR_OF_DAY, 0);
+ cal.set(Calendar.MINUTE, 0);
+ cal.set(Calendar.SECOND, 0);
+ cal.set(Calendar.MILLISECOND, 0);
+ cal.add(Calendar.DATE, -dayCount + 1);
+ Date startDate = cal.getTime();
+
+ // 鏌ヨ涓�绾挎暟鎹紝鎸夊ぉ鍒嗙粍缁熻鎬讳骇閲忓拰宸ヤ綔灏忔椂鏁�
+ QueryWrapper<TaskingLog> line1Query = new QueryWrapper<>();
+ line1Query.select(
+ "DATE_FORMAT(operation_record_time, '%Y-%m-%d') as date",
+ "COUNT(*) as total_count",
+ "COUNT(DISTINCT DATE_FORMAT(operation_record_time, '%H')) as working_hours"
+ )
+ .eq("operation_record", "鏃嬭浆1")
+ .eq("operation_mode", "缁撴潫")
+ .ge("operation_record_time", startDate)
+ .groupBy("DATE_FORMAT(operation_record_time, '%Y-%m-%d')")
+ .orderByAsc("date");
+ List<Map<String, Object>> line1Results = baseMapper.selectMaps(line1Query);
+
+ // 鏌ヨ浜岀嚎鏁版嵁锛屾寜澶╁垎缁勭粺璁℃�讳骇閲忓拰宸ヤ綔灏忔椂鏁�
+ QueryWrapper<TaskingLog> line2Query = new QueryWrapper<>();
+ line2Query.select(
+ "DATE_FORMAT(operation_record_time, '%Y-%m-%d') as date",
+ "COUNT(*) as total_count",
+ "COUNT(DISTINCT DATE_FORMAT(operation_record_time, '%H')) as working_hours"
+ )
+ .eq("operation_record", "鏃嬭浆2")
+ .eq("operation_mode", "缁撴潫")
+ .ge("operation_record_time", startDate)
+ .groupBy("DATE_FORMAT(operation_record_time, '%Y-%m-%d')")
+ .orderByAsc("date");
+ List<Map<String, Object>> line2Results = baseMapper.selectMaps(line2Query);
+
+ // 鍚堝苟缁撴灉
+ Map<String, Object> result = new HashMap<>();
+ Map<String, Map<String, Object>> dailyStats = new HashMap<>();
+
+ // 澶勭悊涓�绾挎暟鎹�
+ for (Map<String, Object> line1Data : line1Results) {
+ String date = (String) line1Data.get("date");
+ int totalCount = ((Number) line1Data.get("total_count")).intValue();
+ int workingHours = ((Number) line1Data.get("working_hours")).intValue();
+
+ Map<String, Object> dailyData = new HashMap<>();
+ dailyData.put("date", date);
+ dailyData.put("line1Count", totalCount);
+ dailyData.put("line1Hours", workingHours);
+ dailyData.put("line1HourlyAvg", workingHours > 0 ? totalCount / workingHours : 0);
+
+ dailyStats.put(date, dailyData);
+ }
+
+ // 澶勭悊浜岀嚎鏁版嵁
+ for (Map<String, Object> line2Data : line2Results) {
+ String date = (String) line2Data.get("date");
+ int totalCount = ((Number) line2Data.get("total_count")).intValue();
+ int workingHours = ((Number) line2Data.get("working_hours")).intValue();
+
+ Map<String, Object> dailyData = dailyStats.computeIfAbsent(date, k -> {
+ Map<String, Object> newData = new HashMap<>();
+ newData.put("date", date);
+ return newData;
+ });
+
+ dailyData.put("line2Count", totalCount);
+ dailyData.put("line2Hours", workingHours);
+ dailyData.put("line2HourlyAvg", workingHours > 0 ? totalCount / workingHours : 0);
+ }
+
+ // 杞崲涓烘渶缁堢殑杩斿洖鏍煎紡
+ List<Map<String, Object>> finalStats = new ArrayList<>(dailyStats.values());
+
+ // 鎸夋棩鏈熸帓搴�
+ finalStats.sort((a, b) -> ((String)a.get("date")).compareTo((String)b.get("date")));
+
+ result.put("dailyStats", finalStats);
+ return result;
+ } catch (Exception e) {
+ log.error("璁$畻鍗曞皬鏃朵骇閲忓け璐�", e);
+ throw new RuntimeException("璁$畻鍗曞皬鏃朵骇閲忓け璐�: " + e.getMessage());
+ }
+ }
+
+ /**
+ * 鏌ヨ搴撲綅鏁版嵁
+ * 鎸夊簱浣嶇粺璁★細
+ * - 鏍囧噯宸ヨ壓锛氱粺璁′笂鐗�1鍜屼笂鐗�2鐨勮褰�
+ * - 瀹氬埗宸ヨ壓锛氱粺璁℃棆杞�1鍜屾棆杞�2鐨勮褰�
+ */
+ @Override
+ public List<Map<String, Object>> selectWareHouse(int dayCount) {
+ try {
+ // 璁$畻寮�濮嬫椂闂�
+ Calendar cal = Calendar.getInstance();
+ cal.setTime(new Date());
+ cal.set(Calendar.HOUR_OF_DAY, 0);
+ cal.set(Calendar.MINUTE, 0);
+ cal.set(Calendar.SECOND, 0);
+ cal.set(Calendar.MILLISECOND, 0);
+ cal.add(Calendar.DATE, -dayCount + 1);
+ Date startDate = cal.getTime();
+
+ // 浣跨敤QueryWrapper鏋勫缓鏌ヨ
+ QueryWrapper<TaskingLog> queryWrapper = new QueryWrapper<>();
+ queryWrapper.select(
+ "DATE_FORMAT(operation_record_time, '%Y-%m-%d') as date",
+ "warehouse",
+ "COUNT(*) as count"
+ )
+ .and(wrapper -> wrapper
+ .and(w -> w
+ .eq("task_type", "鏍囧噯")
+ .in("operation_record", "涓婄墖1", "涓婄墖2")
+ )
+ .or(w -> w
+ .eq("task_type", "瀹氬埗")
+ .in("operation_record", "鏃嬭浆1", "鏃嬭浆2")
+ )
+ )
+ .eq("operation_mode", "缁撴潫")
+ .ge("operation_record_time", startDate)
+ .groupBy("DATE_FORMAT(operation_record_time, '%Y-%m-%d')", "warehouse")
+ .orderByAsc("date", "warehouse");
+
+ return baseMapper.selectMaps(queryWrapper);
+
+ } catch (Exception e) {
+ log.error("鏌ヨ搴撲綅鏁版嵁澶辫触", e);
+ throw new RuntimeException("鏌ヨ搴撲綅鏁版嵁澶辫触: " + e.getMessage());
+ }
+ }
}
--
Gitblit v1.8.0