From 4cdcf7b4165fdcbaff1c96f85ec53c5f944fd038 Mon Sep 17 00:00:00 2001
From: zhangchao <zc857179121@qq.com>
Date: 星期五, 22 十一月 2024 10:56:44 +0800
Subject: [PATCH] 1
---
src/main/java/com/zy/asrs/service/impl/AgvWrkMastServiceImp.java | 98 ++++++++++++++++++++++++++----------------------
1 files changed, 53 insertions(+), 45 deletions(-)
diff --git a/src/main/java/com/zy/asrs/service/impl/AgvWrkMastServiceImp.java b/src/main/java/com/zy/asrs/service/impl/AgvWrkMastServiceImp.java
index 51a32a9..d8d63ba 100644
--- a/src/main/java/com/zy/asrs/service/impl/AgvWrkMastServiceImp.java
+++ b/src/main/java/com/zy/asrs/service/impl/AgvWrkMastServiceImp.java
@@ -23,6 +23,7 @@
import java.io.IOException;
import java.util.*;
+import java.util.concurrent.TimeUnit;
@Service
@Slf4j
@@ -65,17 +66,17 @@
public void updateWrkStsByWrkNo(int wrkNo, long wrkSts) {
AgvWrkMast agvWrkMast = this.selectById(wrkNo);
//鍒ゆ柇瑕佷慨鏀圭殑宸ヤ綔妗g姸鎬佹槸鍚﹀悎鐞嗭紝濡傛灉涓嶅悎鐞嗗垯鎶涘嚭寮傚父
- checkWrkSts(agvWrkMast,wrkSts);
+ checkWrkSts(agvWrkMast, wrkSts);
agvWrkMast.setWrkSts(wrkSts);
agvWrkMast.setModiTime(new Date());
this.updateById(agvWrkMast);
}
- public void updateWrkStsByWrkNo(int wrkNo, long wrkSts,String manuType,long userId) {
+ public void updateWrkStsByWrkNo(int wrkNo, long wrkSts, String manuType, long userId) {
Date now = new Date();
AgvWrkMast agvWrkMast = this.selectById(wrkNo);
//鍒ゆ柇瑕佷慨鏀圭殑宸ヤ綔妗g姸鎬佹槸鍚﹀悎鐞嗭紝濡傛灉涓嶅悎鐞嗗垯鎶涘嚭寮傚父
- checkWrkSts(agvWrkMast,wrkSts);
+ checkWrkSts(agvWrkMast, wrkSts);
agvWrkMast.setWrkSts(wrkSts);
agvWrkMast.setManuType(manuType);
agvWrkMast.setModiTime(now);
@@ -84,8 +85,7 @@
}
// TODO 鍒ゆ柇瑙勫垯
- private boolean checkWrkSts(AgvWrkMast agvWrkMast,long wrkSts){
-
+ private boolean checkWrkSts(AgvWrkMast agvWrkMast, long wrkSts) {
return true;
@@ -96,9 +96,9 @@
AgvTaskCreateParam agvTaskCreateParam = new AgvTaskCreateParam();
//agvTaskCreateParam.setTaskType(taskType);
- getRequestParam(agvTaskCreateParam,agvWrkMast);
+ getRequestParam(agvTaskCreateParam, agvWrkMast);
- return doHttpRequest(agvTaskCreateParam,"鎼繍浠诲姟涓嬪彂",url, taskCreatePath,null,"127.0.0.1");
+ return doHttpRequest(agvTaskCreateParam, "鎼繍浠诲姟涓嬪彂", url, taskCreatePath, null, "127.0.0.1");
//return containerMoveParam;
}
@@ -106,7 +106,7 @@
public int startAllcationIn(AgvWrkMast agvWrkMast) throws IOException {
AgvBasDevp basDevp = agvBasDevpService.selectByDevNo(agvWrkMast.getSourceLocNo());
//妫�绱㈠簱浣嶏紝閫夋嫨鍚堥�傜殑搴撲綅
- AgvLocMast locMast = agvCommonService.getLocNo(basDevp.getLocType1(),basDevp.getFloor(),false,true);
+ AgvLocMast locMast = agvCommonService.getLocNo(basDevp.getLocType1(), basDevp.getFloor(), false, true);
agvWrkMast.setLocNo(locMast.getLocNo());
agvWrkMast.setWrkSts(201L);
agvWrkMast.setLogErrMemo("startAllcationIn");
@@ -122,30 +122,30 @@
//璐ф灦鍏ュ満
public int containerMoveIn(List<AgvWrkMast> agvWrkMastList) throws IOException {
//璋冪敤璐ф灦鍏ュ満鏃舵墍闇�瑕佸弬鏁�
- Map<String,List<Map<String,String>>> containerMoveParam = new HashMap<>();
- List<Map<String,String>> positionCodeMapList = new ArrayList<>();
- containerMoveParam.put("containerMoveIns",positionCodeMapList);
+ Map<String, List<Map<String, String>>> containerMoveParam = new HashMap<>();
+ List<Map<String, String>> positionCodeMapList = new ArrayList<>();
+ containerMoveParam.put("containerMoveIns", positionCodeMapList);
- getContainerMoveParam(agvWrkMastList,positionCodeMapList);
+ getContainerMoveParam(agvWrkMastList, positionCodeMapList);
- if(Cools.isEmpty(positionCodeMapList)){
+ if (Cools.isEmpty(positionCodeMapList)) {
return 0;
}
- return doHttpRequest(containerMoveParam,"璐ф灦鍏ュ満浠诲姟涓嬪彂",url, containerMoveInPath,null,"127.0.0.1");
+ return doHttpRequest(containerMoveParam, "璐ф灦鍏ュ満浠诲姟涓嬪彂", url, containerMoveInPath, null, "127.0.0.1");
}
//璐ф灦绂诲満
- public int containerMoveOut(List<AgvWrkMast> agvWrkMastList){
- Map<String,List<Map<String,String>>> containerMoveParam = new HashMap<>();
- List<Map<String,String>> positionCodeMapList = new ArrayList<>();
- containerMoveParam.put("containerMoveOuts",positionCodeMapList);
- for(AgvWrkMast agvWrkMast : agvWrkMastList){
- Map<String,String> positionCodeMap = new HashMap<>();
- positionCodeMap.put("positionCode",agvWrkMast.getLocNo());
+ public int containerMoveOut(List<AgvWrkMast> agvWrkMastList) {
+ Map<String, List<Map<String, String>>> containerMoveParam = new HashMap<>();
+ List<Map<String, String>> positionCodeMapList = new ArrayList<>();
+ containerMoveParam.put("containerMoveOuts", positionCodeMapList);
+ for (AgvWrkMast agvWrkMast : agvWrkMastList) {
+ Map<String, String> positionCodeMap = new HashMap<>();
+ positionCodeMap.put("positionCode", agvWrkMast.getLocNo());
positionCodeMapList.add(positionCodeMap);
}
- return doHttpRequest(containerMoveParam,"璐ф灦绂诲満浠诲姟涓嬪彂",url, containerMoveOutPath,null,"127.0.0.1");
+ return doHttpRequest(containerMoveParam, "璐ф灦绂诲満浠诲姟涓嬪彂", url, containerMoveOutPath, null, "127.0.0.1");
}
public boolean insertByIncrease(AgvWrkMast agvWrkMast) {
@@ -162,25 +162,25 @@
//璐ф灦鍒拌揪閫氱煡
public int containerArrived(AgvWrkMast agvWrkMast) {
- Map<String,String> containerArrivedParam = new HashMap<>();
- containerArrivedParam.put("slotCode",agvWrkMast.getSourceLocNo());
- containerArrivedParam.put("containerCode",agvWrkMast.getBarcode());
+ Map<String, String> containerArrivedParam = new HashMap<>();
+ containerArrivedParam.put("slotCode", agvWrkMast.getSourceLocNo());
+ containerArrivedParam.put("containerCode", agvWrkMast.getBarcode());
- return doHttpRequest(containerArrivedParam,"璐ф灦杈惧埌閫氱煡",url, containerArrivedPath,null,"127.0.0.1");
+ return doHttpRequest(containerArrivedParam, "璐ф灦杈惧埌閫氱煡", url, containerArrivedPath, null, "127.0.0.1");
}
@Override
public List<AgvWrkMast> selectReadyAgvWrkMast() {
List<String> stationCodes = agvBasDevpService.selectAllStationCode();
Wrapper<AgvWrkMast> wrapper = new EntityWrapper<AgvWrkMast>().eq("wrk_sts", 21L).like(false, "loc_no", "@");
- wrapper.in("loc_no",stationCodes);
+ wrapper.in("loc_no", stationCodes);
return this.selectList(wrapper);
//return this.baseMapper.selectReadyAgvWrkMast();
}
@Override
public AgvWrkMast selectByContainerCode(String containerCode) {
- return this.selectOne(new EntityWrapper<AgvWrkMast>().eq("barcode",containerCode));
+ return this.selectOne(new EntityWrapper<AgvWrkMast>().eq("barcode", containerCode));
}
@Override
@@ -189,25 +189,25 @@
AgvTaskCreateParam agvTaskCreateParam = new AgvTaskCreateParam();
agvTaskCreateParam.setTaskCode(wrkNo + "");
- return doHttpRequest(agvTaskCreateParam,"鍙栨秷浠诲姟涓嬪彂",url, taskCancelPath,null,"127.0.0.1");
+ return doHttpRequest(agvTaskCreateParam, "鍙栨秷浠诲姟涓嬪彂", url, taskCancelPath, null, "127.0.0.1");
}
- private void getContainerMoveParam(List<AgvWrkMast> agvWrkMastList,List<Map<String,String>> positionCodeMapList){
+ private void getContainerMoveParam(List<AgvWrkMast> agvWrkMastList, List<Map<String, String>> positionCodeMapList) {
//寰�璐ф灦鍏ュ満鍙傛暟涓斁鍏ユ簮绔欑偣浣嶇疆
- for(AgvWrkMast agvWrkMast : agvWrkMastList){
+ for (AgvWrkMast agvWrkMast : agvWrkMastList) {
//鍒ゆ柇鏄惁涓鸿緭閫佺嚎鍏ュ簱锛屾槸鍒欎笉闇�瑕佽揣鏋惰繘鍦鸿姹�
- if("Y".equals(agvWrkMast.getMk())){
+ if ("Y".equals(agvWrkMast.getMk())) {
continue;
}
- Map<String,String> positionCodeMap = new HashMap<>();
- positionCodeMap.put("positionCode",agvWrkMast.getSourceLocNo());
+ Map<String, String> positionCodeMap = new HashMap<>();
+ positionCodeMap.put("positionCode", agvWrkMast.getSourceLocNo());
positionCodeMapList.add(positionCodeMap);
}
}
- private void getRequestParam(AgvTaskCreateParam agvTaskCreateParam,AgvWrkMast agvWrkMast){
+ private void getRequestParam(AgvTaskCreateParam agvTaskCreateParam, AgvWrkMast agvWrkMast) {
List<AgvTaskParam> agvTaskParamList = Arrays.asList(
//璧峰浣�
@@ -220,7 +220,7 @@
// //鐩爣浣�
// agvTaskParamList.add(new AgvTaskParam(agvWrkMast.getLocNo()));
- if(agvWrkMast.getIoType() == 53 || agvWrkMast.getIoType() == 57 ){
+ if (agvWrkMast.getIoType() == 53 || agvWrkMast.getIoType() == 57) {
agvWrkMast.setWrkNo(-agvWrkMast.getWrkNo());
}
agvTaskCreateParam.setTaskCode(agvWrkMast.getWrkNo().toString());
@@ -270,32 +270,40 @@
}
- private int doHttpRequest(Object requestParam, String namespace, String url, String path, String appkey, String ip){
+ private int doHttpRequest(Object requestParam, String namespace, String url, String path, String appkey, String ip) {
String response = "";
boolean success = false;
try {
response = new HttpHandler.Builder()
.setUri(url)
.setPath(path)
+ .setTimeout(30, TimeUnit.SECONDS)
.setJson(JSONObject.toJSONString(requestParam))
.build()
.doPost();
JSONObject jsonObject = JSON.parseObject(response);
int code = Integer.parseInt(jsonObject.get("code").toString());
- if(code != 0){
- //TODO 寮犺秴
- //throw new CoolException("璋冪敤AGV鍝嶅簲閿欒");
- return code;
+ if (code != 0) {
+ if (code == 6) {
+ log.info("AGV浠诲姟鍗曞彿宸蹭笂鎶�:{}", response);
+ String message = jsonObject.getString("message");
+ if (!Cools.isEmpty(message) && message.contains("宸插瓨鍦ㄤ换鍔″崟澶翠负")) {
+ success = true;
+ return 0;
+ }
+ }
+ throw new CoolException("璋冪敤AGV鍝嶅簲閿欒");
+ //return code;
}
success = true;
return code;
- }catch (Exception e){
+ } catch (Exception e) {
log.error(e.getMessage());
//TODO 寮犺秴
- //throw new CoolException("璋冪敤AGV鍝嶅簲閿欒");
- return 1;
- }finally {
+ throw new CoolException("璋冪敤AGV鍝嶅簲閿欒");
+ //return 1;
+ } finally {
apiLogService.save(
namespace,
url + path,
--
Gitblit v1.9.1