From 16170b1d8429f7c31bb1a323b93c2de5137f2c6f Mon Sep 17 00:00:00 2001
From: 严智鑫 <test>
Date: 星期一, 22 九月 2025 08:49:21 +0800
Subject: [PATCH] Merge branch 'master' of http://10.153.19.25:10105/r/JiuMuMES
---
JiuMuMesParent/moduleService/DeviceInteractionModule/src/main/java/com/mes/md/service/impl/TaskingLogServiceImpl.java | 150 ++++++++++++++++++++++++++++++++++++++++++++++++--
1 files changed, 144 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..db5d4fe 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
@@ -3,9 +3,11 @@
import cn.smallbun.screw.core.util.CollectionUtils;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.yulichang.base.MPJBaseServiceImpl;
+import com.mes.md.entity.BPjingpianKC;
import com.mes.md.entity.KBBTJPDrawingBP;
import com.mes.md.entity.KBBTProgramsOperationLogBP;
import com.mes.md.entity.TaskingLog;
+import com.mes.md.mapper.BPjingpianKCMapper;
import com.mes.md.mapper.KBBTJPDrawingBPMapper;
import com.mes.md.mapper.KBBTProgramsOperationLogBPMapper;
import com.mes.md.mapper.TaskingLogMapper;
@@ -34,6 +36,8 @@
KBBTProgramsOperationLogBPMapper kBBTProgramsOperationLogBPMapper;
@Autowired
KBBTJPDrawingBPMapper kBBTJPDrawingBPMapper;
+ @Autowired
+ BPjingpianKCMapper bPjingpianKCMapper;
@Override
public List<Map> selectMechanicalReport(int dayCount, Date startDate, Date endDate, String taskType, String operationRecord, String lineType) {
@@ -74,10 +78,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 +124,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 +131,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 +280,136 @@
}
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());
+ }
+ }
+
+ /**
+ * 鏌ヨ搴撲綅鏁版嵁
+ * 鎸夊簱浣嶇粺璁★細
+ * 鏌ヨ BPjingpianKC 琛ㄧ殑搴撲綅鏁版嵁
+ */
+ @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<BPjingpianKC> queryWrapper = new QueryWrapper<>();
+ queryWrapper.select(
+ "RecordDate as date",
+ "LGORTOT as warehouse",
+ "TotalLensStock as count"
+ )
+ .ge("RecordDate", startDate)
+ .orderByAsc("RecordDate", "LGORTOT");
+
+ return bPjingpianKCMapper.selectMaps(queryWrapper);
+
+ } catch (Exception e) {
+ log.error("鏌ヨ搴撲綅鏁版嵁澶辫触", e);
+ throw new RuntimeException("鏌ヨ搴撲綅鏁版嵁澶辫触: " + e.getMessage());
+ }
+ }
}
--
Gitblit v1.8.0