From 437faf8e56bfc30d00473e65ece48be504a57fe7 Mon Sep 17 00:00:00 2001
From: zyh <zyh@123>
Date: 星期六, 28 三月 2026 10:47:34 +0800
Subject: [PATCH] CTU预调度功能,更新为正式部署许可证,修改前端导出功能,打开Redis,数字孪生增加接口

---
 src/main/java/com/zy/asrs/service/impl/DigitalTwinServiceImpl.java |  143 ++++++++++++++++++++++++++++++++++-------------
 1 files changed, 102 insertions(+), 41 deletions(-)

diff --git a/src/main/java/com/zy/asrs/service/impl/DigitalTwinServiceImpl.java b/src/main/java/com/zy/asrs/service/impl/DigitalTwinServiceImpl.java
index dd7afc2..2ce70fa 100644
--- a/src/main/java/com/zy/asrs/service/impl/DigitalTwinServiceImpl.java
+++ b/src/main/java/com/zy/asrs/service/impl/DigitalTwinServiceImpl.java
@@ -11,21 +11,20 @@
 import com.zy.asrs.entity.mes.StockDetl;
 import com.zy.asrs.mapper.DigitalTwinMapper;
 import com.zy.asrs.mapper.LocCountMapper;
+import com.zy.asrs.mapper.LocDetlMapper;
 import com.zy.asrs.service.BasCrnpService;
 import com.zy.asrs.service.DigitalTwinService;
 import com.zy.asrs.service.LocDetlService;
 import com.zy.asrs.service.LocMastService;
 import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
 import javax.annotation.Resource;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.List;
+import java.util.*;
 import java.util.stream.Collectors;
 
 @Service
@@ -35,33 +34,8 @@
     private DigitalTwinMapper digitalTwinMapper;
     @Resource
     private LocCountMapper locCountMapper;
-
-    @Override
-    public R getAllLocations() {
-        List<AllLocationsVo> allLocationsVos = new ArrayList<>();
-        List<LocMast> locMastList = locMastService.selectList(new EntityWrapper<>());
-        locMastList.forEach(locMast -> {
-            AllLocationsVo allLocationsVo = new AllLocationsVo();
-            allLocationsVo.setLocNo(locMast.getLocNo());
-            String locSts = locMast.getLocSts();
-            allLocationsVo.setLocSts(locSts);
-            // 鏈夊簱瀛�
-            if (locSts.equals("F") || locSts.equals("P") || locSts.equals("Q") || locSts.equals("R")) {
-                List<LocDetl> locDetls = locDetlService.selectList(new EntityWrapper<LocDetl>().eq("loc_no", locMast.getLocNo()));
-                if (!locDetls.isEmpty()) {
-                    List<AllLocationsVo.LocDetl> locDetlList = locDetls.stream().map(locDetl -> {
-                                AllLocationsVo.LocDetl locDetl1 = new AllLocationsVo.LocDetl();
-                                BeanUtils.copyProperties(locDetl, locDetl1);
-                                return locDetl1;
-                            }
-                    ).collect(Collectors.toList());
-                    allLocationsVo.setLocDetls(locDetlList);
-                }
-            }
-            allLocationsVos.add(allLocationsVo);
-        });
-        return R.ok(allLocationsVos);
-    }
+    @Autowired
+    private LocDetlMapper locDetlMapper;
 
     /**
      * 鎬昏锛氭�诲簱浣嶃�佸凡鐢ㄥ簱浣嶃�佸墿浣欏簱浣嶃�佷粖鏃ュ嚭搴撱�佷粖鏃ュ叆搴撱�佸墿浣欏簱浣�
@@ -106,14 +80,36 @@
             endTime = now;
 
         } else {
-            SimpleDateFormat sdf =
-                    new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
-
+            SimpleDateFormat sdf;
             try {
-                startTime  = sdf.parse(startDate);
-                endTime = sdf.parse(endDate);
+                // 灏濊瘯瑙f瀽yyyyMMdd鏍煎紡
+                if (startDate.length() == 8 && endDate.length() == 8) {
+                    sdf = new SimpleDateFormat("yyyyMMdd");
+                    startTime = sdf.parse(startDate);
+                    endTime = sdf.parse(endDate);
+                    // 璁剧疆缁撴潫鏃堕棿涓哄綋澶╃殑23:59:59.999
+                    Calendar calendar = Calendar.getInstance();
+                    calendar.setTime(endTime);
+                    calendar.set(Calendar.HOUR_OF_DAY, 23);
+                    calendar.set(Calendar.MINUTE, 59);
+                    calendar.set(Calendar.SECOND, 59);
+                    calendar.set(Calendar.MILLISECOND, 999);
+                    endTime = calendar.getTime();
+                } else {
+                    // 灏濊瘯瑙f瀽yyyy-MM-dd HH:mm:ss.SSS鏍煎紡
+                    sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
+                    startTime = sdf.parse(startDate);
+                    endTime = sdf.parse(endDate);
+                }
             } catch (ParseException e) {
                 e.printStackTrace();
+                // 瑙f瀽澶辫触鏃朵娇鐢ㄩ粯璁ょ殑7澶╂椂闂磋寖鍥�
+                Date now = new Date();
+                Calendar calendar = Calendar.getInstance();
+                calendar.setTime(now);
+                calendar.add(Calendar.DAY_OF_MONTH, -7);
+                startTime = calendar.getTime();
+                endTime = now;
             }
         }
         List<DtOrderVo> dbOrder = digitalTwinMapper.recentOrder(startTime, endTime);
@@ -146,14 +142,36 @@
             endTime = now;
 
         } else {
-            SimpleDateFormat sdf =
-                    new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
-
+            SimpleDateFormat sdf;
             try {
-                startTime  = sdf.parse(startDate);
-                endTime = sdf.parse(endDate);
+                // 灏濊瘯瑙f瀽yyyyMMdd鏍煎紡
+                if (startDate.length() == 8 && endDate.length() == 8) {
+                    sdf = new SimpleDateFormat("yyyyMMdd");
+                    startTime = sdf.parse(startDate);
+                    endTime = sdf.parse(endDate);
+                    // 璁剧疆缁撴潫鏃堕棿涓哄綋澶╃殑23:59:59.999
+                    Calendar calendar = Calendar.getInstance();
+                    calendar.setTime(endTime);
+                    calendar.set(Calendar.HOUR_OF_DAY, 23);
+                    calendar.set(Calendar.MINUTE, 59);
+                    calendar.set(Calendar.SECOND, 59);
+                    calendar.set(Calendar.MILLISECOND, 999);
+                    endTime = calendar.getTime();
+                } else {
+                    // 灏濊瘯瑙f瀽yyyy-MM-dd HH:mm:ss.SSS鏍煎紡
+                    sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
+                    startTime = sdf.parse(startDate);
+                    endTime = sdf.parse(endDate);
+                }
             } catch (ParseException e) {
                 e.printStackTrace();
+                // 瑙f瀽澶辫触鏃朵娇鐢ㄩ粯璁ょ殑7澶╂椂闂磋寖鍥�
+                Date now = new Date();
+                Calendar calendar = Calendar.getInstance();
+                calendar.setTime(now);
+                calendar.add(Calendar.DAY_OF_MONTH, -7);
+                startTime = calendar.getTime();
+                endTime = now;
             }
         }
 
@@ -371,4 +389,47 @@
 
     // endregion
 
+    @Override
+    public R getAllLocations() {
+        List<AllLocationsVo> allLocationsVos = new ArrayList<>();
+        List<LocMast> locMastList = locMastService.selectList(new EntityWrapper<>());
+        locMastList.forEach(locMast -> {
+            AllLocationsVo allLocationsVo = new AllLocationsVo();
+            allLocationsVo.setLocNo(locMast.getLocNo());
+            String locSts = locMast.getLocSts();
+            allLocationsVo.setLocSts(locSts);
+            // 鏈夊簱瀛�
+            if (locSts.equals("F") || locSts.equals("P") || locSts.equals("Q") || locSts.equals("R")) {
+                List<LocDetl> locDetls = locDetlService.selectList(new EntityWrapper<LocDetl>().eq("loc_no", locMast.getLocNo()));
+                if (!locDetls.isEmpty()) {
+                    List<AllLocationsVo.LocDetl> locDetlList = locDetls.stream().map(locDetl -> {
+                                AllLocationsVo.LocDetl locDetl1 = new AllLocationsVo.LocDetl();
+                                BeanUtils.copyProperties(locDetl, locDetl1);
+                                return locDetl1;
+                            }
+                    ).collect(Collectors.toList());
+                    allLocationsVo.setLocDetls(locDetlList);
+                }
+            }
+            allLocationsVos.add(allLocationsVo);
+        });
+        return R.ok(allLocationsVos);
+    }
+
+
+    public List<Map<String, Object>> getLocalDetal() {
+        List<LocDetl> locDetls = locDetlMapper.selectList(new EntityWrapper<>());
+        List<Map<String, Object>> result = new ArrayList<>();
+
+        for (LocDetl locDetl : locDetls) {
+            Map<String, Object> item = new HashMap<>();
+            item.put("zpallet", locDetl.getZpallet());
+            item.put("anfme", locDetl.getAnfme());
+            item.put("matnr", locDetl.getMatnr());
+            item.put("maktx", locDetl.getMaktx());
+            result.add(item);
+        }
+
+        return result;
+    }
 }

--
Gitblit v1.9.1