From d8b7de110ce5e16b95f87f79aec65c13b7f475f2 Mon Sep 17 00:00:00 2001
From: zjj <3272660260@qq.com>
Date: 星期六, 20 四月 2024 17:44:50 +0800
Subject: [PATCH] #演示
---
src/main/java/com/zy/asrs/controller/OpenController.java | 189 +++++++++++++++++++++++++++++++++++++---------
1 files changed, 151 insertions(+), 38 deletions(-)
diff --git a/src/main/java/com/zy/asrs/controller/OpenController.java b/src/main/java/com/zy/asrs/controller/OpenController.java
index 6f30d10..27594da 100644
--- a/src/main/java/com/zy/asrs/controller/OpenController.java
+++ b/src/main/java/com/zy/asrs/controller/OpenController.java
@@ -8,6 +8,7 @@
import com.core.common.Cools;
import com.core.common.R;
import com.core.exception.CoolException;
+import com.zy.asrs.domain.vo.CrnStateTableVo;
import com.zy.asrs.entity.*;
import com.zy.asrs.entity.param.TaskOverParam;
import com.zy.asrs.entity.param.WMSAndAGVInterfaceParam;
@@ -15,6 +16,10 @@
import com.zy.asrs.service.*;
import com.zy.common.utils.HttpHandler;
import com.zy.common.web.BaseController;
+import com.zy.core.CrnThread;
+import com.zy.core.cache.SlaveConnection;
+import com.zy.core.enums.SlaveType;
+import com.zy.core.model.protocol.CrnProtocol;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
@@ -48,6 +53,8 @@
@Autowired
private StaDescService staDescService;
+ @Autowired
+ private BasCrnpService basCrnpService;
@Value("${wms.url}")
private String wmsUrl;
@@ -73,8 +80,16 @@
if (Cools.isEmpty(param.getStatus())){
return R.error("瀹屾垚鏍囪[status]涓嶈兘涓虹┖");
}
- openService.getAgvTaskOver(param);
- return R.ok();
+ R agvTaskOver = openService.getAgvTaskOver(param);
+ apiLogService.save("AGV璇锋眰浠诲姟瀹屾垚"
+ ,request.getRemoteAddr()+request.getRequestURI()
+ ,appkey
+ ,request.getRemoteAddr()
+ ,JSON.toJSONString(param)
+ ,agvTaskOver.toString()
+ ,true
+ );
+ return agvTaskOver;
}
//鍒涘缓浠诲姟
@@ -154,9 +169,10 @@
return R.error("鎵樼洏缂栫爜涓虹┖锛�");
} else if (Cools.isEmpty(param.getWharfSource())){
return R.error("婧愮爜澶翠负绌猴紒");
- } else if (Cools.isEmpty(param.getFreeWharfs()) || param.getFreeWharfs().size()==0){
- return R.error("绌洪棽鐨勫叆搴撶爜澶达紙AGV锛変负绌猴紒");
}
+// else if (Cools.isEmpty(param.getFreeWharfs()) || param.getFreeWharfs().size()==0){
+// return R.error("绌洪棽鐨勫叆搴撶爜澶达紙AGV锛変负绌猴紒");
+// }
R r = openService.AgvToWCSToWms(param);
apiLogService.save("AGV璇锋眰鍏ュ簱鐮佸ご鎺ュ彛"
,request.getRemoteAddr()+request.getRequestURI()
@@ -185,20 +201,26 @@
}
Map<String,Integer> map = new HashMap<>();
- map.put("J-1101",102);map.put("J-1102",101);
- map.put("J-1103",106);map.put("J-1104",105);
- map.put("J-1105",110);map.put("J-1106",109);
- map.put("J-1107",114);map.put("J-1108",113);
- map.put("J-1109",118);map.put("J-1110",117);
- map.put("J-1111",122);map.put("J-1112",121);
-
- StaDesc staDesc = staDescService.selectOne(new EntityWrapper<StaDesc>().eq("stn_desc", param.getWharfCode()));
-
- if (Cools.isEmpty(staDesc)){
- return R.error("绋嬪簭鎶ラ敊锛屾湭鏌ヨ鍒扮珯鐐�");
+ map.put("J-1102",102);map.put("J-1101",101);
+ map.put("J-1103",105);map.put("J-1104",106);
+ map.put("J-1105",109);map.put("J-1106",110);
+ map.put("J-1107",113);map.put("J-1108",114);
+ map.put("J-1109",117);map.put("J-1110",118);
+ map.put("J-1111",121);map.put("J-1112",122);
+ map.put("H-1102",300);map.put("H-1101",305);
+ map.put("G-1102",400);map.put("G-1101",405);
+// StaDesc staDesc = staDescService.selectOne(new EntityWrapper<StaDesc>()
+// .eq("stn_desc", param.getWharfCode()));
+//
+// if (Cools.isEmpty(staDesc)){
+// return R.error("绋嬪簭鎶ラ敊锛屾湭鏌ヨ鍒扮珯鐐�");
+// }
+ if (Cools.isEmpty(map.get(param.getWharfCode()))){
+ return R.error("鏈煡璇㈠埌绔欑偣");
}
BasDevp basDevp = basDevpService.selectById(map.get(param.getWharfCode()));
- if (basDevp.getAutoing().equals("Y")){
+// BasDevp basDevp = basDevpService.selectById(staDesc.getStnNo());
+ if (basDevp.getAutoing().equals("Y") && (basDevp.getInEnable().equals("Y") || basDevp.getOutEnable().equals("Y"))){
apiLogService.save("AGV璇锋眰鍏ュ簱鐮佸ご鎺ュ彛"
,request.getRemoteAddr()+request.getRequestURI()
,appkey
@@ -207,7 +229,7 @@
,R.ok().toString()
,true
);
- return R.ok();
+ return R.ok("鍙叆");
}else {
apiLogService.save("AGV璇锋眰鍏ュ簱鐮佸ご鎺ュ彛"
,request.getRemoteAddr()+request.getRequestURI()
@@ -217,7 +239,7 @@
,R.error("绔欑偣鐘舵�佷笉鍙叆").toString()
,true
);
- return R.error("绔欑偣鐘舵�佷笉鍙叆");
+ return R.error("绔欑偣鐘舵�佷笉鍙叆,鑷姩淇″彿:"+basDevp.getAutoing()+";鍙叆淇″彿:"+basDevp.getInEnable()+";鍙嚭淇″彿:"+basDevp.getOutEnable());
}
@@ -235,7 +257,7 @@
auth(appkey, params, request);
List<WMSAndAGVInterfaceParam> params1 =new ArrayList<>();
for (WMSAndAGVInterfaceParam param:params){
- try {
+
if (Cools.isEmpty(param)){
return R.error("鍙傛暟涓虹┖锛�");
} else if (Cools.isEmpty(param.getTaskNo())){
@@ -254,29 +276,49 @@
if (Cools.isEmpty(param.getEmptyContainer())){
return R.error("鏄惁绌烘墭鐩樹俊鍙蜂负绌猴紒");
}
-// if (Cools.isEmpty(param.getTaskTunnel())){
-// return R.error("浠诲姟宸烽亾涓虹┖锛�");
-// }
-// if (Cools.isEmpty(param.getGroupNo())){
-// return R.error("浠诲姟缁勪负绌猴紒");
-// }
-// if (Cools.isEmpty(param.getTaskSerialNo())){
-// return R.error("浠诲姟鎵ц椤哄簭涓虹┖锛�");
-// }
- if (Cools.isEmpty(param.getTargetWharf())){
- return R.error("鐩爣鐮佸ご鍖哄煙涓虹┖锛�");//G寮�澶�=7杞﹂棿锛孒寮�澶�=8灞傦紝J寮�澶�=9杞﹂棿
+ if (!param.getTaskType().equals("YK")){
+ if (Cools.isEmpty(param.getTargetWharf())){
+ return R.error("鐩爣鐮佸ご鍖哄煙涓虹┖锛�");//G寮�澶�=7杞﹂棿锛孒寮�澶�=8灞傦紝J寮�澶�=9杞﹂棿
+ }
}
- openService.taskCreate(new taskCreateParam(param));
+ StaDesc staDesc = new StaDesc();
+ if (param.getTaskType().equals("CK") && param.getTargetWharf().contains("J")){
+ staDesc = staDescService.selectOne(new EntityWrapper<StaDesc>()
+ .eq("crn_no",param.getTaskTunnel())
+ .eq("type_no",2)
+ .lt("stn_no",200));
+ }else if (param.getTaskType().equals("CK") && param.getTargetWharf().contains("H")){
+ staDesc = staDescService.selectOne(new EntityWrapper<StaDesc>()
+ .eq("crn_no",param.getTaskTunnel())
+ .eq("type_no",2)
+ .lt("stn_no",400)
+ .gt("stn_no",200));
+ }else {
+ staDesc = staDescService.selectOne(new EntityWrapper<StaDesc>()
+ .eq("crn_no",param.getTaskTunnel())
+ .eq("type_no",2)
+ .lt("stn_no",500)
+ .ge("stn_no",400));
+ }
+ param.setTargetLocationCode(staDesc.getStnNo().toString());
- params1.add(param);
-// return R.ok(param);
- }catch (Exception e){
- String errorMsg = Cools.isEmpty(e.getLocalizedMessage()) ? "" : e.getLocalizedMessage();
- return R.error("鐢熸垚浠诲姟澶辫触锛岃鑱旂郴绠$悊鍛�!"+ errorMsg);
- }
+
+ R r = openService.taskCreate(new taskCreateParam(param));
+
+ apiLogService.save("Wms浠诲姟涓嬪彂鎺ュ彛"
+ ,request.getRemoteAddr()+request.getRequestURI()
+ ,appkey
+ ,request.getRemoteAddr()
+ ,JSON.toJSONString(param)
+ ,r.toString()
+ ,true
+ );
+
+
}
- return R.ok(params1);
+
+ return R.ok();
}
//浠诲姟鍙栨秷鎺ュ彛
@@ -338,7 +380,78 @@
return R.error();
}
}
+ @PostMapping("/getCrnStatus")
+ public R getCrnStatus(HttpServletRequest request){
+ List<Integer> crnStatusDtos = new ArrayList<>();
+ List<BasCrnp> crnps = basCrnpService.selectList(new EntityWrapper<BasCrnp>().orderBy("crn_no"));
+ for (BasCrnp basCrnp : crnps) {
+ // 琛ㄦ牸琛�
+ CrnStateTableVo vo = new CrnStateTableVo();
+ vo.setCrnNo(basCrnp.getCrnNo()); // 鍫嗗灈鏈哄彿
+ // 鑾峰彇鍫嗗灈鏈轰俊鎭�
+ CrnThread crnThread = (CrnThread) SlaveConnection.get(SlaveType.Crn, basCrnp.getCrnNo());
+ if (crnThread == null) {
+ continue;
+ }
+ CrnProtocol crnProtocol = crnThread.getCrnProtocol();
+ if (crnProtocol == null) {
+ continue;
+ }
+ if (basCrnp.getOutEnable().equals("N")){
+ continue;
+ }
+ if (crnProtocol.getAlarm() != 0){
+ continue;
+ }
+ if (crnProtocol.getMode() != 3){
+ continue;
+ }
+
+ crnStatusDtos.add(basCrnp.getCrnNo());
+
+ }
+ return R.ok(crnStatusDtos);
+ }
+
+// @PostMapping("/getCrnStatus")
+// public R getCrnStatus(HttpServletRequest request) {
+// List<BasCrnp> basCrnps = basCrnpService.selectList(new EntityWrapper<BasCrnp>());
+// if (Cools.isEmpty(basCrnps)){
+// return R.error("鏁版嵁搴撳紓甯革紝鍫嗗灈鏈哄垪琛ㄤ负绌�");
+// }
+// List<CrnStatusDto> crnStatusDtos = new ArrayList<>();
+// for (BasCrnp basCrnp : basCrnps){
+// CrnStatusDto crnStatusDto = new CrnStatusDto();
+// crnStatusDto.setCrnNo(basCrnp.getCrnNo());
+// if (basCrnp.getOutEnable().equals("N")){
+// crnStatusDto.setCrnStatus(500);
+// crnStatusDto.setCrnErrMsg("鍫嗗灈鏈哄嚭搴撹绂佺敤");
+// crnStatusDtos.add(crnStatusDto);
+// continue;
+// }
+// if (basCrnp.getCrnErr() != 0){
+// crnStatusDto.setCrnStatus(500);
+// crnStatusDto.setCrnErrMsg("鍫嗗灈鏈哄浜庢姤璀︾姸鎬�");
+// crnStatusDtos.add(crnStatusDto);
+// continue;
+// }
+// if (basCrnp.getCrnSts() != 3){
+// crnStatusDto.setCrnStatus(500);
+// crnStatusDto.setCrnErrMsg("鍫嗗灈鏈哄浜庨潪鑷姩鐘舵��");
+// crnStatusDtos.add(crnStatusDto);
+// continue;
+// }
+//
+// crnStatusDto.setCrnStatus(200);
+// crnStatusDto.setCrnErrMsg("");
+// crnStatusDtos.add(crnStatusDto);
+//
+//
+// }
+//
+// return R.ok(crnStatusDtos);
+// }
}
--
Gitblit v1.9.1