From 071b6b6eb7add4aa6e067b87259697101bff4119 Mon Sep 17 00:00:00 2001
From: zhou zhou <3272660260@qq.com>
Date: 星期一, 01 十二月 2025 17:00:46 +0800
Subject: [PATCH] #AGV
---
src/main/java/com/zy/asrs/service/impl/MobileServiceImpl.java | 91 +++++++++++++++++++++++++++++++++++++++++++--
1 files changed, 86 insertions(+), 5 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 716a7ed..5587732 100644
--- a/src/main/java/com/zy/asrs/service/impl/MobileServiceImpl.java
+++ b/src/main/java/com/zy/asrs/service/impl/MobileServiceImpl.java
@@ -8,13 +8,16 @@
import com.core.exception.CoolException;
import com.zy.asrs.entity.*;
import com.zy.asrs.entity.param.*;
-import com.zy.asrs.enums.CommonEnum;
+import com.zy.asrs.entity.result.ForwardAGVTaskDTO;
+import com.zy.asrs.entity.result.HIKApiDTO;
+import com.zy.asrs.entity.result.HIKResultDTO;
import com.zy.asrs.enums.LocStsType;
import com.zy.asrs.mapper.LocMastMapper;
import com.zy.asrs.mapper.ManLocDetlMapper;
import com.zy.asrs.service.*;
import com.zy.asrs.utils.MatUtils;
import com.zy.asrs.utils.OrderInAndOutUtil;
+import com.zy.common.constant.HIKApiConstant;
import com.zy.common.constant.MesConstant;
import com.zy.common.entity.Parameter;
import com.zy.common.model.DetlDto;
@@ -683,17 +686,16 @@
if (Cools.isEmpty(mat)) {
throw new CoolException(detlDto.getMatnr() + "鍟嗗搧妗f涓嶅瓨鍦�");
}
-
//鏈�澶氬彲鏀炬暟閲�
Double singleMax = mat.getUpQty() * suplus;
if (singleMax.compareTo(detlDto.getAnfme()) < 0) {
- throw new CoolException("鍗曟鏈�澶х粍鎵樹笂闄愪负锛�" + singleMax);
+ throw new CoolException("鐗╂枡锛�" + detlDto.getMatnr() + "鍗曟缁勬墭涓婇檺涓猴細" + mat.getUpQty() + ",褰撳墠鎬婚噺瓒呭嚭鎵樼洏瑁呰浇涓婇檺!!");
}
BigDecimal decimal = new BigDecimal(detlDto.getAnfme() / mat.getUpQty());
//褰撳墠鐗╂枡闇�瑕佸崰鐢ㄦ枡绠辨牸鏁�
Integer curr = decimal.setScale(0, RoundingMode.CEILING).intValue();
suplus = suplus - curr;
- if (suplus == 0 || suplus < 0) {
+ if (suplus < 0) {
throw new CoolException("鐗╂枡锛�" + detlDto.getMatnr() + ", 瓒呭嚭褰撳墠鎵樼洏瑁呰浇涓婇檺锛侊紒");
}
@@ -1273,6 +1275,31 @@
return R.ok();
}
+ @Override
+ public R callEmptyCar(AgvCallParams params) {
+
+ List<LocCache> locSts = locCacheService.selectList(new EntityWrapper<LocCache>().eq("loc_sts", LocStsType.LOC_STS_TYPE_D.type));
+ if (locSts.isEmpty()){
+ throw new CoolException("鏆傛棤绌烘澘搴撲綅");
+ }
+
+ HIKApiDTO hikApiDTO =new HIKApiDTO()
+ .setOrg(locSts.get(0).getLocNo())
+ .setOrgType("05")
+ .setTar(params.getTarSite())
+ .setTarType("05")
+ .setTaskType("GT5")
+ .setPriority("1")
+ .setCtnrType("2")
+ ;
+ HIKResultDTO hikResultDTO = sendAgvTask(hikApiDTO, HIKApiConstant.AGV_CALL_IN_PATH);
+ if (!hikResultDTO.isSuccess()){
+ return R.error(hikResultDTO.getMessage());
+ }
+
+ return R.ok();
+ }
+
/**
* @author Ryan
* @date 2025/9/25
@@ -1375,7 +1402,7 @@
task.setWrkNo(workNo)
.setIoTime(new Date())
.setWrkSts(1L) // 宸ヤ綔鐘舵�侊細11.鐢熸垚鍑哄簱ID
- .setIoType(11) // 鍏ュ嚭搴撶姸鎬侊細 11.搴撴牸绉昏浇
+ .setIoType(1) // 鍏ュ嚭搴撶姸鎬侊細 11.搴撴牸绉昏浇
.setTaskType("agv")
.setIoPri(10D)
.setLocNo(loc.getLocNo()) // 鐩爣搴撲綅
@@ -1430,4 +1457,58 @@
throw new CoolException("绉昏浆澶辫触锛岀洰鏍囧簱浣嶇姸鎬侊細" + loc.getLocSts$());
}
}
+
+
+ public HIKResultDTO sendAgvTask(HIKApiDTO haiKangApiDTO,String path){
+ HIKResultDTO result = new HIKResultDTO();
+
+ ForwardAGVTaskDTO forwardAGVTaskParam = new ForwardAGVTaskDTO();
+ forwardAGVTaskParam.setReqCode(UUID.randomUUID().toString().replace("-", ""));
+ forwardAGVTaskParam.setClientCode("IWMS");
+ forwardAGVTaskParam.setTaskTyp(haiKangApiDTO.getTaskType());
+ forwardAGVTaskParam.setCtnrTyp(haiKangApiDTO.getCtnrType());
+ forwardAGVTaskParam.setPriority(haiKangApiDTO.getPriority());
+ List<ForwardAGVTaskDTO.PositionCodePaths> positionCodePathsList = new ArrayList<>();
+ positionCodePathsList.add(new ForwardAGVTaskDTO.PositionCodePaths(haiKangApiDTO.getOrg(), haiKangApiDTO.getOrgType()));
+ positionCodePathsList.add(new ForwardAGVTaskDTO.PositionCodePaths(haiKangApiDTO.getTar(), haiKangApiDTO.getTarType()));
+ forwardAGVTaskParam.setPositionCodePath(positionCodePathsList);
+
+ String body = JSON.toJSONString(forwardAGVTaskParam);
+ String response = "";
+ try {
+ response = new HttpHandler.Builder()
+ .setUri(HIKApiConstant.AGV_IP)
+ .setPath(path)
+ .setJson(body)
+ .build()
+ .doPost();
+ JSONObject jsonObject = JSON.parseObject(response);
+ if (jsonObject.getInteger("code").equals(0)) {
+ result.setSuccess(true);
+ } else {
+ result.setMessage(jsonObject.getString("message"));
+ log.error("鍙戦�乤gv浠诲姟澶辫触锛侊紒锛乽rl锛歿}锛況equest锛歿}锛況esponse锛歿}", HIKApiConstant.AGV_IP + path, body, response);
+ }
+// {"code":"1","data":"","interrupt":false,"message":"閲嶅鎻愪氦","msgErrCode":"0x3a80D012","reqCode":"fa92b49481a44627ae4d80c1400f28f6"}
+ } catch (Exception e) {
+ result.setMessage(e.getMessage());
+ log.error("鍙戦�乤gv浠诲姟寮傚父", e);
+ } finally {
+ try {
+ // 淇濆瓨鎺ュ彛鏃ュ織
+ apiLogService.save(
+ "鍙戦�乤gv浠诲姟",
+ HIKApiConstant.AGV_IP + path,
+ null,
+ "127.0.0.1",
+ body,
+ response,
+ result.isSuccess()
+ );
+ } catch (Exception e) {
+ log.error("", e);
+ }
+ }
+ return result;
+ }
}
--
Gitblit v1.9.1