From 4a6f48adcf51b22e40d94605ed44751e962fd0ea Mon Sep 17 00:00:00 2001
From: skyouc <creaycat@gmail.com>
Date: 星期四, 15 一月 2026 11:08:27 +0800
Subject: [PATCH] 堆垛机任务执行回写
---
src/main/java/com/zy/api/service/impl/WcsApiServiceImpl.java | 129 ++++++++++++++++++++++++++++++++++--------
1 files changed, 103 insertions(+), 26 deletions(-)
diff --git a/src/main/java/com/zy/api/service/impl/WcsApiServiceImpl.java b/src/main/java/com/zy/api/service/impl/WcsApiServiceImpl.java
index 0186fd0..5c3e6b7 100644
--- a/src/main/java/com/zy/api/service/impl/WcsApiServiceImpl.java
+++ b/src/main/java/com/zy/api/service/impl/WcsApiServiceImpl.java
@@ -11,10 +11,7 @@
import com.zy.asrs.entity.BasDevice;
import com.zy.asrs.entity.LocAroundBind;
import com.zy.asrs.entity.WrkMast;
-import com.zy.asrs.service.BasDeviceService;
-import com.zy.asrs.service.LocAroundBindService;
-import com.zy.asrs.service.LocMastService;
-import com.zy.asrs.service.WrkMastService;
+import com.zy.asrs.service.*;
import com.zy.common.constant.MesConstant;
import com.zy.common.utils.HttpHandler;
import org.springframework.beans.factory.annotation.Autowired;
@@ -38,6 +35,8 @@
private LocMastService locMastService;
@Autowired
private WrkMastService wrkMastService;
+ @Autowired
+ private WorkService workService;
/**
* 閫氱煡WCS閿佸畾搴撲綅锛屽強绂佹褰撳墠搴撲綅鐨勪竴鍒囨搷浣�
@@ -59,9 +58,9 @@
if (Objects.isNull(binds) || binds.isEmpty()) {
throw new CoolException("鏈哄彴鏈粦瀹氬伐浣滅珯鍙帮紒锛�");
}
- Set<String> locs = binds.stream().map(LocAroundBind::getBLocNo).collect(Collectors.toSet());
+ Set<String> locs = binds.stream().map(LocAroundBind::getBlocNo).collect(Collectors.toSet());
- reportLockLocs(locs);
+ reportLockLocs(locs, "lock");
return R.ok("涓婃姤鎴愬姛锛侊紒");
}
@@ -76,26 +75,28 @@
@Override
@Transactional(rollbackFor = Exception.class)
public R backLocs(WorkTaskParams params) {
- if (Objects.isNull(params.getTaskNo())) {
+ if (Objects.isNull(params.getWrkNo())) {
throw new CoolException("宸ヤ綔鍙蜂笉鑳戒负绌猴紒锛�");
}
- String wrkCode = params.getTaskNo();
- if (wrkCode.contains("-1")) {
- throw new CoolException("閰嶅浠诲姟缂栫爜閿欒锛岃妫�鏌ュ悗閲嶆柊涓婁紶锛侊紒");
- }
-
- WrkMast mast = wrkMastService.selectOne(new EntityWrapper<WrkMast>().eq("wrk_code", params.getTaskNo()));
-
+// String wrkCode = params.getTaskNo();
+// if (wrkCode.contains("-1")) {
+// throw new CoolException("閰嶅浠诲姟缂栫爜閿欒锛岃妫�鏌ュ悗閲嶆柊涓婁紶锛侊紒");
+// }
+ WrkMast mast = wrkMastService.selectOne(new EntityWrapper<WrkMast>().eq("wrk_no", params.getWrkNo()));
if (Objects.isNull(mast)) {
throw new CoolException("浠诲姟涓嶅瓨鍦紒锛�");
}
- if (!mast.getWrkSts().equals(103L)) {
- throw new CoolException("褰撳墠浠诲姟骞堕潪浣欐枡鍑哄簱浠诲姟锛侊紒");
- }
- mast.setWrkSts(53L);
- if (!wrkMastService.updateById(mast)) {
- throw new CoolException("浠诲姟鐘舵�佹洿鏂板け璐ワ紒锛�");
- }
+// if (!mast.getWrkSts().equals(103L)) {
+// throw new CoolException("褰撳墠浠诲姟骞堕潪浣欐枡鍑哄簱浠诲姟锛侊紒");
+// }
+// if (params.getIsSuplus() == 1) {
+// mast.setIsSuplus(1);
+// }
+//
+// if (!wrkMastService.updateById(mast)) {
+// throw new CoolException("浠诲姟鐘舵�佹洿鏂板け璐ワ紒锛�");
+// }
+ workService.backLocOperation(mast.getWrkNo() + "", mast.getAppeUser());
return R.ok("鎺ユ敹鎴愬姛锛屾墽琛屽洖搴撲腑...");
}
@@ -109,26 +110,59 @@
*/
@Override
public R pubWrkToWcs(WorkTaskParams params) {
+ if (Objects.isNull(params.getTaskNo())) {
+ return R.error("浠诲姟鍙蜂笉鑳戒负绌猴紒锛�");
+ }
+ if (Objects.isNull(params.getBarcode())) {
+ return R.error("鎵樼洏鐮佷笉鑳戒负绌猴紒锛�");
+ }
+ if (Objects.isNull(params.getLocNo())) {
+ return R.error("鐩爣搴撲綅涓嶈兘涓虹┖锛侊紒");
+ }
+ String url = MesConstant.PUB_TASK_IN;
+ if (Objects.isNull(params.getType()) && params.getType().equals("out")) {
+ url = MesConstant.PUB_TASK_OUT;
+ }
+ String response;
+ try {
+ response = new HttpHandler.Builder()
+ .setUri(MesConstant.URL)
+ .setPath(url)
+ .setJson(JSON.toJSONString(params))
+ .build()
+ .doPost();
+ R result = JSON.parseObject(response, R.class);
-
-
+ if (result.get("code").equals("200")) {
+ //TODO 涓婃姤鏄惁鎴愬姛
+ }
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
return null;
}
/**
- * 涓婃姤閿佸畾搴撲綅淇℃伅
+ * 涓婃姤閿佸畾/閲婃斁搴撲綅淇℃伅
* @author Ryan
* @date 2026/1/10 12:50
* @param locs
*/
+ @Override
@Transactional(rollbackFor = Exception.class)
- public void reportLockLocs(Set<String> locs) {
+ public void reportLockLocs(Set<String> locs, String type) {
+ String url = MesConstant.LOCK_LOCS_URL;
+ if (!Objects.isNull(type)) {
+ if (type.equals("release")) {
+ url = MesConstant.RELEASE_LOCS_URL;
+ }
+ }
String response;
try {
response = new HttpHandler.Builder()
.setUri(MesConstant.URL)
- .setPath(MesConstant.LOCK_LOCS_URL)
+ .setPath(url)
.setJson(JSON.toJSONString(locs))
.build()
.doPost();
@@ -142,4 +176,47 @@
}
}
+
+ /**
+ * 鍫嗗灈鏈烘墽琛岀姸鎬佷笂鎶�
+ * @author Ryan
+ * @date 2026/1/10 16:30
+ * @param params
+ * @return com.core.common.R
+ */
+ @Override
+ @Transactional(rollbackFor = Exception.class)
+ public R receviceTaskFromWcs(ReceviceTaskParams params) {
+ if (Objects.isNull(params.getDevice())) {
+ throw new CoolException("璁惧鍙蜂笉鑳戒负绌猴紒锛�");
+ }
+ if (Objects.isNull(params.getSuperTaskNo())) {
+ throw new CoolException("WMS浠诲姟鍙蜂笉鑳戒负绌猴紒锛�");
+ }
+ if (Objects.isNull(params.getMsgType())) {
+ throw new CoolException("鍔ㄤ綔绫诲瀷涓嶈兘涓虹┖锛侊紒");
+ }
+ WrkMast mast = wrkMastService.selectOne(new EntityWrapper<WrkMast>().eq("wrk_no", params.getSuperTaskNo()));
+ if (Objects.isNull(mast)) {
+ throw new CoolException("浠诲姟妗d笉瀛樺湪锛侊紒");
+ }
+ if (!Objects.isNull(params.getMsgType()) && params.getMsgType().equals("task")) {
+ throw new CoolException("娑堟伅涓嶈兘涓虹┖锛侊紒");
+ }
+
+ if (params.getMsgType().equals("task_complete")) {
+ mast.setWrkSts(4L);
+ if (!wrkMastService.updateById(mast)) {
+ throw new CoolException("浠诲姟鐘舵�佷慨鏀瑰け璐ワ紒锛�");
+ }
+ } else if (params.getMsgType().equals("task_cancel")){
+
+ }
+
+// if (!wrkMastService.updateById(mast)) {
+// throw new CoolException("浠诲姟鐘舵�佷慨鏀瑰け璐ワ紒锛�");
+// }
+
+ return R.ok();
+ }
}
--
Gitblit v1.9.1