From eaa10dce48521e297ec4c06d46b92407fb6f04c7 Mon Sep 17 00:00:00 2001
From: pang.jiabao <pang_jiabao@163.com>
Date: 星期四, 28 十一月 2024 10:08:25 +0800
Subject: [PATCH] agv站点修改
---
src/main/java/com/zy/asrs/service/impl/MobileServiceImpl.java | 289 ++++++++++++++++++++++++++++++++++++++++++++++++++++++---
1 files changed, 271 insertions(+), 18 deletions(-)
diff --git a/src/main/java/com/zy/asrs/service/impl/MobileServiceImpl.java b/src/main/java/com/zy/asrs/service/impl/MobileServiceImpl.java
index 26be866..b8f8d62 100644
--- a/src/main/java/com/zy/asrs/service/impl/MobileServiceImpl.java
+++ b/src/main/java/com/zy/asrs/service/impl/MobileServiceImpl.java
@@ -7,14 +7,13 @@
import com.core.common.*;
import com.core.exception.CoolException;
import com.zy.asrs.entity.*;
-import com.zy.asrs.entity.param.CombParam;
-import com.zy.asrs.entity.param.MobileAdjustParam;
-import com.zy.asrs.entity.param.OffSaleParam;
-import com.zy.asrs.entity.param.OpenOrderPakinParam;
+import com.zy.asrs.entity.param.*;
+import com.zy.asrs.mapper.BasDevpMapper;
import com.zy.asrs.mapper.ManLocDetlMapper;
import com.zy.asrs.service.*;
import com.zy.asrs.utils.MatUtils;
-import com.zy.common.CodeRes;
+import com.zy.common.constant.AgvSiteConstant;
+import com.zy.common.constant.ApiInterfaceConstant;
import com.zy.common.constant.MesConstant;
import com.zy.common.entity.Parameter;
import com.zy.common.model.DetlDto;
@@ -26,6 +25,7 @@
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
+import javax.annotation.Resource;
import java.util.*;
/**
@@ -75,6 +75,183 @@
@Autowired
private ManLocDetlMapper manLocDetlMapper;
+ @Resource
+ private BasDevpMapper basDevpMapper;
+
+ @Override
+ public R inLocCallAgv(String sta, String inSta) {
+
+ BasDevp basDevp = basDevpMapper.selectById(inSta);
+ // 0.鍑哄簱妯″紡锛�1.agv鍏ュ簱涓紝2.鐢熸垚鍏ュ簱浠诲姟
+ if (basDevp.getDevMk().equals("0")) { // 鏄嚭搴�
+ // 鍒ゆ柇鏄惁鏈夊嚭搴撲换鍔�
+ int count = wrkMastService.selectCount(new EntityWrapper<WrkMast>()
+ .eq("sta_no", inSta).lt("wrk_sts",14).in("io_type",101,103,107,110));
+ if (count == 0) {
+ // 娌℃湁鍑哄簱浠诲姟锛屾洿鏀逛负鍏ュ簱妯″紡
+ basDevp.setDevMk("1");
+ basDevpMapper.updateById(basDevp);
+ } else {
+ return R.parse(inSta + "绔欑偣瀛樺湪鍑哄簱浠诲姟");
+ }
+ }
+
+ // 鍏堢粦瀹�
+// boolean flag = bindPodAndBerth(sta);
+// if (!flag) {
+// return R.parse(inSta + "缁戝畾澶辫触");
+// }
+
+ ForwardAGVTaskParam forwardAGVTaskParam = new ForwardAGVTaskParam();
+ forwardAGVTaskParam.setReqCode(UUID.randomUUID().toString().replace("-", ""));
+ forwardAGVTaskParam.setClientCode("IWMS");
+ forwardAGVTaskParam.setTaskTyp("GT3");
+ forwardAGVTaskParam.setCtnrTyp("2");
+ forwardAGVTaskParam.setPriority("1");
+ List<ForwardAGVTaskParam.PositionCodePaths> positionCodePathsList = new ArrayList<>();
+ positionCodePathsList.add(new ForwardAGVTaskParam.PositionCodePaths(sta, "05"));
+ positionCodePathsList.add(new ForwardAGVTaskParam.PositionCodePaths(inSta, "05"));
+ forwardAGVTaskParam.setPositionCodePath(positionCodePathsList);
+
+ String body = JSON.toJSONString(forwardAGVTaskParam);
+ String response = "";
+ String message = "";
+ boolean success = false;
+ try {
+ response = new HttpHandler.Builder()
+ .setUri(ApiInterfaceConstant.AGV_IP)
+ .setPath(ApiInterfaceConstant.AGV_CALL_IN_PATH)
+ .setJson(body)
+ .build()
+ .doPost();
+ JSONObject jsonObject = JSON.parseObject(response);
+ jsonObject.getString("message");
+ if (jsonObject.getInteger("code").equals(0)) {
+ success = true;
+ } else {
+ log.error("鍏ュ簱鍛煎彨agv澶辫触锛侊紒锛乽rl锛歿}锛況equest锛歿}锛況esponse锛歿}", ApiInterfaceConstant.AGV_IP + ApiInterfaceConstant.AGV_CALL_IN_PATH, body, response);
+ }
+ } catch (Exception e) {
+ log.error("鍏ュ簱鍛煎彨agv寮傚父", e);
+ } finally {
+ try {
+ // 淇濆瓨鎺ュ彛鏃ュ織
+ apiLogService.save(
+ "鍏ュ簱鍛煎彨agv",
+ ApiInterfaceConstant.AGV_IP + ApiInterfaceConstant.AGV_CALL_IN_PATH,
+ null,
+ "127.0.0.1",
+ body,
+ response,
+ success
+ );
+ } catch (Exception e) {
+ log.error("", e);
+ }
+ }
+
+ return success ? R.ok("鍛煎彨agv鎴愬姛") : R.parse(message);
+ }
+
+ @Override
+ public R unbind(String site) {
+ String staMap = AgvSiteConstant.SiteMap.get(site);
+ if (staMap == null) {
+ return R.parse("娌℃湁鎵惧埌璇ョ珯鐐圭殑鍏ュ簱鏄犲皠锛�" + site);
+ }
+ JSONObject jsonObject = new JSONObject();
+ jsonObject.put("reqCode",UUID.randomUUID().toString().replace("-", "")); // 璇锋眰鍞竴鍊�
+ jsonObject.put("ctnrTyp","2"); // 瀹瑰櫒绫诲瀷2
+ jsonObject.put("stgBinCode",staMap); // 浠撲綅缂栧彿锛屾牴鎹浠撶紪鍙疯浆鎹�
+ jsonObject.put("indBind","0"); // 1缁戝畾锛�0瑙g粦
+
+ String body = jsonObject.toJSONString();
+ String response = "";
+ String message = "";
+ boolean success = false;
+ try {
+ response = new HttpHandler.Builder()
+ .setUri(ApiInterfaceConstant.AGV_IP)
+ .setPath(ApiInterfaceConstant.AGV_BIND_PATH)
+ .setJson(body)
+ .build()
+ .doPost();
+ JSONObject res = JSON.parseObject(response);
+ message = jsonObject.getString("message");
+ if (res.getInteger("code").equals(0)) {
+ success = true;
+ } else {
+ log.error("璋冪敤agv瑙g粦鏆傚瓨浣嶅け璐ワ紒锛侊紒url锛歿}锛況equest锛歿}锛況esponse锛歿}", ApiInterfaceConstant.AGV_IP + ApiInterfaceConstant.AGV_BIND_PATH, body, response);
+ }
+ } catch (Exception e) {
+ log.error("璋冪敤agv瑙g粦鏆傚瓨浣嶅紓甯�", e);
+ } finally {
+ try {
+ // 淇濆瓨鎺ュ彛鏃ュ織
+ apiLogService.save(
+ "璋冪敤agv瑙g粦鏆傚瓨浣�",
+ ApiInterfaceConstant.AGV_IP + ApiInterfaceConstant.AGV_BIND_PATH,
+ null,
+ "127.0.0.1",
+ body,
+ response,
+ success
+ );
+ } catch (Exception e) {
+ log.error("", e);
+ }
+ }
+ return success ? R.ok("瑙g粦鎴愬姛") : R.parse(message);
+ }
+
+ private boolean bindPodAndBerth(String sta) {
+ String staMap = AgvSiteConstant.SiteMap.get(sta);
+ if (staMap == null) {
+ log.error("娌℃湁鎵惧埌璇ョ珯鐐圭殑鍏ュ簱鏄犲皠:{}",sta);
+ return false;
+ }
+ JSONObject jsonObject = new JSONObject();
+ jsonObject.put("reqCode",UUID.randomUUID().toString().replace("-", "")); // 璇锋眰鍞竴鍊�
+ jsonObject.put("ctnrTyp","2"); // 瀹瑰櫒绫诲瀷2
+ jsonObject.put("stgBinCode",staMap); // 浠撲綅缂栧彿锛屾牴鎹浠撶紪鍙疯浆鎹�
+ jsonObject.put("indBind","1"); // 1缁戝畾锛�0瑙g粦
+
+ String body = jsonObject.toJSONString();
+ String response = "";
+ boolean success = false;
+ try {
+ response = new HttpHandler.Builder()
+ .setUri(ApiInterfaceConstant.AGV_IP)
+ .setPath(ApiInterfaceConstant.AGV_BIND_PATH)
+ .setJson(body)
+ .build()
+ .doPost();
+ JSONObject res = JSON.parseObject(response);
+ if (res.getInteger("code").equals(0)) {
+ success = true;
+ } else {
+ log.error("璋冪敤agv缁戝畾浠撲綅澶辫触锛侊紒锛乽rl锛歿}锛況equest锛歿}锛況esponse锛歿}", ApiInterfaceConstant.AGV_IP + ApiInterfaceConstant.AGV_BIND_PATH, body, response);
+ }
+ } catch (Exception e) {
+ log.error("璋冪敤agv缁戝畾浠撲綅寮傚父", e);
+ } finally {
+ try {
+ // 淇濆瓨鎺ュ彛鏃ュ織
+ apiLogService.save(
+ "璋冪敤agv缁戝畾浠撲綅",
+ ApiInterfaceConstant.AGV_IP + ApiInterfaceConstant.AGV_BIND_PATH,
+ null,
+ "127.0.0.1",
+ body,
+ response,
+ success
+ );
+ } catch (Exception e) {
+ log.error("", e);
+ }
+ }
+ return success;
+ }
@Override
@Transactional
@@ -86,23 +263,20 @@
throw new CoolException("璇锋彁鍙栦竴涓晢鍝侊紝鎴栬�呭埛鏂伴噸鏂扮粍鎵橈紒");
}
// 鍒ゆ柇鏄惁鏈夌浉鍚屾潯鐮佺殑鏁版嵁
- if (waitPakinService.selectCount(new EntityWrapper<WaitPakin>().
- eq("zpallet", param.getBarcode()).eq("io_status", "N")) > 0) {
- throw new CoolException(param.getBarcode() + "鏁版嵁姝e湪杩涜鍏ュ簱");
- }
+// if (waitPakinService.selectCount(new EntityWrapper<WaitPakin>().
+// eq("zpallet", param.getBarcode()).eq("io_status", "N")) > 0) {
+// throw new CoolException(param.getBarcode() + "鏁版嵁姝e湪杩涜鍏ュ簱");
+// }
- if(param.getBarcode().length()!=8){
- throw new CoolException("鏉$爜闀垮害涓嶆槸8浣�===>>" + param.getBarcode());
- }
- if (param.getCombMats().size()>1){
- throw new CoolException("涓嶅厑璁告贩鏂�===>>" + param.getBarcode());
+ if(param.getBarcode().length()!=9){
+ throw new CoolException("鏉$爜闀垮害涓嶆槸9浣�===>>" + param.getBarcode());
}
int countLoc = locDetlService.selectCount(new EntityWrapper<LocDetl>().eq("zpallet",param.getBarcode()));
int countWrk = wrkDetlService.selectCount(new EntityWrapper<WrkDetl>().eq("zpallet",param.getBarcode()));
- int countwait = waitPakinService.selectCount(new EntityWrapper<WaitPakin>().eq("zpallet",param.getBarcode()));
- if (countLoc > 0 || countWrk > 0 || countwait > 0) {
- throw new CoolException("缁勬墭妗�/宸ヤ綔妗�/搴撳瓨鏉$爜鏁版嵁宸插瓨鍦�===>>" + param.getBarcode());
+// int countwait = waitPakinService.selectCount(new EntityWrapper<WaitPakin>().eq("zpallet",param.getBarcode()));
+ if (countLoc > 0 || countWrk > 0) {
+ throw new CoolException("宸ヤ綔妗�/搴撳瓨鏉$爜鏁版嵁宸插瓨鍦�===>>" + param.getBarcode());
}
Date now = new Date();
@@ -171,7 +345,7 @@
throw new CoolException("淇敼鍗曟嵁浣滀笟鏁伴噺澶辫触");
}
- DetlDto detlDto = new DetlDto(elem.getMatnr(), elem.getBatch(), elem.getAnfme());
+ DetlDto detlDto = new DetlDto(elem.getMatnr(), elem.getBatch(), elem.getAnfme(),orderDetl.getManu());
if (DetlDto.has(detlDtos, detlDto)) {
DetlDto one = DetlDto.find(detlDtos, detlDto.getMatnr(), detlDto.getBatch());
assert one != null;
@@ -198,12 +372,84 @@
waitPakin.setAppeTime(now);
waitPakin.setModiUser(userId);
waitPakin.setModiTime(now);
+ waitPakin.setManu(detlDto.getMark());
if (!waitPakinService.insert(waitPakin)) {
throw new CoolException("淇濆瓨鍏ュ簱閫氱煡妗eけ璐�");
}
}
orderService.updateSettle(order.getId(), 2L, userId);
}
+
+ }
+
+ @Override
+ @Transactional
+ public void mergeComb(CombParam param, Long userId) {
+
+ if (Cools.isEmpty(param.getBarcode(), param.getCombMats())) {
+ throw new CoolException(BaseRes.PARAM);
+ }
+ if(param.getCombMats().stream().anyMatch(obj -> obj.getAnfme() == null)){
+ throw new CoolException("鍏ュ簱鐗╂枡鏁伴噺涓嶈兘涓虹┖");
+ }
+ Order order = orderService.selectByNo(param.getOrderNo());
+ if (Cools.isEmpty(order) || order.getSettle() > 2) {
+ throw new CoolException("鍗曟嵁缂栧彿宸茶繃鏈�");
+ }
+
+ // 鍒ゆ柇鏄惁鏈夌浉鍚屾潯鐮佺殑鏁版嵁
+ if (waitPakinService.selectCount(new EntityWrapper<WaitPakin>().
+ eq("zpallet", param.getBarcode()).eq("io_status", "N")) > 0) {
+ throw new CoolException(param.getBarcode() + "鏁版嵁姝e湪杩涜鍏ュ簱");
+ }
+
+ int countLoc = locDetlService.selectCount(new EntityWrapper<LocDetl>().eq("zpallet",param.getBarcode()));
+ WrkMast wrkMast = wrkMastService.selectByBarcode(param.getBarcode());
+ if (wrkMast.getWrkSts() != 14 && wrkMast.getIoType() != 104){
+ throw new CoolException(param.getBarcode() + "璇ユ潯鐮佹暟鎹笉涓哄苟鏉垮嚭搴�");
+ }
+
+ //璁剧疆闈瀗ull鎵瑰彿锛�
+ for (CombParam.CombMat combMat : param.getCombMats()) {
+ if (combMat.getBatch() == null){
+ combMat.setBatch("");
+ }
+ }
+
+ Date now = new Date();
+ for (CombParam.CombMat combMat : param.getCombMats()) {
+ // 璁㈠崟鏄庣粏鏁伴噺鏍¢獙
+ OrderDetl orderDetl = orderDetlService.selectItem(order.getId(), combMat.getMatnr(), combMat.getBatch());
+ if (Cools.isEmpty(orderDetl)) {
+ throw new CoolException("璇ュ崟鎹腑鏈壘鍒板搴旂墿鏂欐槑缁�");
+ }
+ if (combMat.getAnfme() > orderDetl.getEnableQty()) {
+ throw new CoolException(orderDetl.getMatnr() + "鍏ュ簱鏁伴噺涓嶅悎娉�");
+ }
+ // 淇敼璁㈠崟浣滀笟鏁伴噺
+ if (!orderDetlService.increaseWorkQty(order.getId(), combMat.getMatnr(), combMat.getBatch(), combMat.getAnfme())) {
+ throw new CoolException("淇敼鍗曟嵁浣滀笟鏁伴噺澶辫触");
+ }
+
+ Mat mat = matService.selectByMatnr(combMat.getMatnr());
+ WrkDetl wrkDetl = new WrkDetl();
+ wrkDetl.sync(mat);
+ wrkDetl.setBatch(combMat.getBatch());
+ wrkDetl.setWrkNo(wrkMast.getWrkNo());
+ wrkDetl.setOrderNo(param.getOrderNo());
+ wrkDetl.setZpallet(param.getBarcode());
+ wrkDetl.setAnfme(combMat.getAnfme());
+ wrkDetl.setAppeTime(now);
+ wrkDetl.setAppeUser(userId);
+ wrkDetl.setModiTime(now);
+ wrkDetl.setModiUser(userId);
+ wrkDetl.setManu(orderDetl.getManu());
+ wrkDetlService.insert(wrkDetl);
+ }
+
+
+
+
}
@@ -570,6 +816,13 @@
public void leftoversOut(Map<String, Object> map,Long userId) {
String barcode = map.get("barcode").toString();
String barcode2 = map.get("barcode2").toString();
+
+ int countLoc = locDetlService.selectCount(new EntityWrapper<LocDetl>().eq("zpallet",barcode2));
+ int countWrk = wrkMastService.selectCount(new EntityWrapper<WrkMast>().eq("barcode",barcode2).ne("io_type",200));
+ int countwait = waitPakinService.selectCount(new EntityWrapper<WaitPakin>().eq("zpallet",barcode2));
+ if (countLoc > 0 || countWrk > 0 || countwait > 0) {
+ throw new CoolException("璇ユ潯鐮佸凡琚娇鐢�===>>" + barcode2);
+ }
WrkMast wrkMast = wrkMastService.selectOne(new EntityWrapper<WrkMast>().eq("barcode", barcode).eq("io_type", 103));
if (Cools.isEmpty(wrkMast)) {
throw new CoolException("鏈煡璇㈠埌鎷f枡浠诲姟");
--
Gitblit v1.9.1