From f7c6b3779ebc85bb0f097ba56f18a5ab81e5f8f5 Mon Sep 17 00:00:00 2001
From: zyh <zyh@123>
Date: 星期二, 31 三月 2026 08:13:40 +0800
Subject: [PATCH] 修改数字孪生接口,将不同库位状态的数量上报
---
src/main/java/com/zy/asrs/service/impl/DigitalTwinServiceImpl.java | 185 ++++++++++++++++++++++++++++++++++++++++++----
1 files changed, 169 insertions(+), 16 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 935062a..7f88416 100644
--- a/src/main/java/com/zy/asrs/service/impl/DigitalTwinServiceImpl.java
+++ b/src/main/java/com/zy/asrs/service/impl/DigitalTwinServiceImpl.java
@@ -2,26 +2,29 @@
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.core.common.Cools;
+import com.core.common.R;
import com.zy.asrs.entity.BasCrnp;
import com.zy.asrs.entity.LocCount;
import com.zy.asrs.entity.LocDetl;
import com.zy.asrs.entity.LocMast;
import com.zy.asrs.entity.digitaltwin.*;
+import com.zy.asrs.entity.digitaltwin.AllLocationsVo;
import com.zy.asrs.mapper.DigitalTwinMapper;
import com.zy.asrs.mapper.LocCountMapper;
+import com.zy.asrs.mapper.LocDetlMapper;
+import com.zy.asrs.mapper.LocMastMapper;
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 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
@@ -31,6 +34,11 @@
private DigitalTwinMapper digitalTwinMapper;
@Resource
private LocCountMapper locCountMapper;
+ @Autowired
+ private LocDetlMapper locDetlMapper;
+
+ @Autowired
+ private LocMastMapper locMastMapper;
/**
* 鎬昏锛氭�诲簱浣嶃�佸凡鐢ㄥ簱浣嶃�佸墿浣欏簱浣嶃�佷粖鏃ュ嚭搴撱�佷粖鏃ュ叆搴撱�佸墿浣欏簱浣�
@@ -74,15 +82,37 @@
startTime = calendar.getTime();
endTime = now;
- } else {
- SimpleDateFormat sdf =
- new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
-
+ }else {
+ 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);
@@ -114,15 +144,37 @@
startTime = calendar.getTime();
endTime = now;
- } else {
- SimpleDateFormat sdf =
- new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
-
+ } else {
+ 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;
}
}
@@ -301,4 +353,105 @@
// endregion
+ // endregion
+ @Resource
+ private LocDetlService locDetlService;
+
+ @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;
+ }
+
+
+ public Map<String, Object> getLocInfo() {
+ List<LocMast> LocMasts = locMastMapper.selectList(new EntityWrapper<>());
+ Map<String, Object> result = new HashMap<>();
+
+ // 鍒濆鍖栬鏁板櫒
+ int emptyLocCount = 0;
+ int fullZpalletCount = 0;
+ int emptyZpalletCount = 0;
+ int pickOutCount = 0;
+ int pickInCount = 0;
+ int outboundCount = 0;
+ int inboundCount = 0;
+ int disableCount = 0;
+ int mergeCount = 0;
+
+ // 缁熻姣忕鐘舵�佺殑搴撲綅鏁伴噺
+ for (LocMast locMast : LocMasts) {
+ String locSts = locMast.getLocSts();
+ if (locSts.equals("O")) {
+ emptyLocCount++;
+ } else if (locSts.equals("F")) {
+ fullZpalletCount++;
+ } else if (locSts.equals("D")) {
+ emptyZpalletCount++;
+ } else if (locSts.equals("P")) {
+ pickOutCount++;
+ } else if (locSts.equals("Q")) {
+ pickInCount++;
+ } else if (locSts.equals("R")) {
+ outboundCount++;
+ } else if (locSts.equals("S")) {
+ inboundCount++;
+ } else if (locSts.equals("X")) {
+ disableCount++;
+ } else if (locSts.equals("Y")) {
+ mergeCount++;
+ }
+ }
+
+ // 灏嗙粺璁$粨鏋滄斁鍏ap涓�
+ result.put("EmptyLoc", emptyLocCount);
+ result.put("FullZpallet", fullZpalletCount);
+ result.put("EmptyZpallet", emptyZpalletCount);
+ result.put("PickOut", pickOutCount);
+ result.put("PickIn", pickInCount);
+ result.put("Outbound", outboundCount);
+ result.put("Inbound", inboundCount);
+ result.put("Disable", disableCount);
+ result.put("Merge", mergeCount);
+
+ return result;
+ }
}
--
Gitblit v1.9.1