From abcbc1657792026dbb9db86689141544e8d86b77 Mon Sep 17 00:00:00 2001
From: zyx <zyx123456>
Date: 星期四, 19 十月 2023 11:42:48 +0800
Subject: [PATCH] 补货单流程更新
---
src/main/java/com/zy/asrs/service/impl/AgvWrkMastServiceImp.java | 157 ++++++++++++++++++++++++++++++++++++++--------------
1 files changed, 115 insertions(+), 42 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 ad0cdbd..db9685d 100644
--- a/src/main/java/com/zy/asrs/service/impl/AgvWrkMastServiceImp.java
+++ b/src/main/java/com/zy/asrs/service/impl/AgvWrkMastServiceImp.java
@@ -2,6 +2,7 @@
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.core.exception.CoolException;
import com.zy.asrs.entity.AgvWrkMast;
@@ -9,10 +10,14 @@
import com.zy.asrs.entity.param.AgvTaskParam;
import com.zy.asrs.entity.param.AgvTaskkDescribeParam;
import com.zy.asrs.mapper.AgvWrkMastMapper;
+import com.zy.asrs.service.AgvLocMastService;
+import com.zy.asrs.service.AgvWrkDetlService;
import com.zy.asrs.service.AgvWrkMastService;
import com.zy.asrs.service.ApiLogService;
import com.zy.common.utils.HttpHandler;
+import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.io.IOException;
@@ -23,45 +28,121 @@
import java.util.stream.Collectors;
@Service
+@Slf4j
public class AgvWrkMastServiceImp extends ServiceImpl<AgvWrkMastMapper, AgvWrkMast> implements AgvWrkMastService {
+ @Value("${agv.url}")
private String url;
- private String path;
+ @Value("${agv.taskCreatePath}")
+ private String taskCreatePath;
+
+ @Value("${agv.containerMoveInPath}")
+ private String containerMoveInPath;
+
+ @Value("${agv.containerMoveOutPath}")
+ private String containerMoveOutPath;
@Autowired
AgvWrkMastMapper agvWrkMastMapper;
+ @Autowired
+ AgvWrkDetlService agvWrkDetlService;
+ @Autowired
+ AgvLocMastService agvLocMastService;
@Autowired
ApiLogService apiLogService;
public void updateWrkStsByWrkNo(int wrkNo, long wrkSts) {
AgvWrkMast agvWrkMast = this.selectById(wrkNo);
+ //鍒ゆ柇瑕佷慨鏀圭殑宸ヤ綔妗g姸鎬佹槸鍚﹀悎鐞嗭紝濡傛灉涓嶅悎鐞嗗垯鎶涘嚭寮傚父
+ checkWrkSts(agvWrkMast,wrkSts);
agvWrkMast.setWrkSts(wrkSts);
this.updateById(agvWrkMast);
}
- public Map<String,List<Map<String,String>>> startWrk(List<AgvWrkMast> agvWrkMastList) throws IOException {
+ // TODO 鍒ゆ柇瑙勫垯
+ private boolean checkWrkSts(AgvWrkMast agvWrkMast,long wrkSts){
+
+
+
+ return true;
+ }
+
+ public int startWrk(List<AgvWrkMast> agvWrkMastList, String taskType) throws IOException {
AgvTaskCreateParam agvTaskCreateParam = new AgvTaskCreateParam();
- agvTaskCreateParam.setTaskType("putaway");
+ agvTaskCreateParam.setTaskType(taskType);
+// //璋冪敤瀹瑰櫒鍏ュ満鏃舵墍闇�瑕佸弬鏁�
+// Map<String,List<Map<String,String>>> containerMoveParam = new HashMap<>();
+// List<Map<String,String>> positionCodeMapList = new ArrayList<>();
+// containerMoveParam.put("containerMoveIns",positionCodeMapList);
+
+ getRequestParam(agvTaskCreateParam,agvWrkMastList);
+
+ return doHttpRequest(agvTaskCreateParam,"鎼繍浠诲姟涓嬪彂",url, taskCreatePath,null,"127.0.0.1");
+
+ //return containerMoveParam;
+ }
+
+ //瀹瑰櫒鍏ュ満
+ public int containerMove(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);
+ getContainerMoveParam(agvWrkMastList,positionCodeMapList);
+ 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());
+ positionCodeMapList.add(positionCodeMap);
+ }
+ return doHttpRequest(containerMoveParam,"瀹瑰櫒绂诲満浠诲姟涓嬪彂",url, containerMoveOutPath,null,"127.0.0.1");
+ }
+
+ public boolean insertByIncrease(AgvWrkMast agvWrkMast) {
+ int index = this.baseMapper.insertByIncrease(agvWrkMast);
+
+ return index > 0;
+ }
+
+ @Override
+ public boolean deleteByWrkNo(int wrkNo) {
+ return this.delete(new EntityWrapper<AgvWrkMast>().eq("wrk_no", wrkNo));
+ }
+
+ private void getContainerMoveParam(List<AgvWrkMast> agvWrkMastList,List<Map<String,String>> positionCodeMapList){
+ //寰�瀹瑰櫒鍏ュ満鍙傛暟涓斁鍏ユ簮绔欑偣浣嶇疆
+ for(AgvWrkMast agvWrkMast : agvWrkMastList){
+ Map<String,String> positionCodeMap = new HashMap<>();
+ positionCodeMap.put("positionCode",agvWrkMast.getSourceLocNo());
+ positionCodeMapList.add(positionCodeMap);
+ }
+ }
+
+ private void getRequestParam(AgvTaskCreateParam agvTaskCreateParam,List<AgvWrkMast> agvWrkMastList){
List<AgvTaskParam> agvTaskParamList = agvWrkMastList.stream().map(agvWrkMast -> {
AgvTaskParam agvTaskParam = new AgvTaskParam();
AgvTaskkDescribeParam agvTaskkDescribeParam = new AgvTaskkDescribeParam();
agvTaskParam.setTaskDescribe(agvTaskkDescribeParam);
//AgvTaskParam
- agvTaskParam.setTaskCode(agvWrkMast.getWrkNo().toString());
- agvTaskParam.setTaskPriority(agvWrkMast.getIoPri().intValue());
+ if(agvWrkMast.getIoType() == 53 || agvWrkMast.getIoType() == 57){
+ agvTaskParam.setTaskCode(-agvWrkMast.getWrkNo() + "");
+ }else{
+ agvTaskParam.setTaskCode(agvWrkMast.getWrkNo() + "");
+ }
- //寰�瀹瑰櫒鍏ュ満鍙傛暟涓斁鍏ユ簮绔欑偣浣嶇疆
- Map<String,String> positionCodeMap = new HashMap<>();
- positionCodeMap.put("positionCode",agvWrkMast.getSourceLocNo());
- positionCodeMapList.add(positionCodeMap);
+ agvTaskParam.setTaskPriority(agvWrkMast.getIoPri().intValue());
//AgvTaskkDescribeParam
agvTaskkDescribeParam.setFromLocationCode(agvWrkMast.getSourceLocNo());
@@ -71,50 +152,42 @@
}).collect(Collectors.toList());
agvTaskCreateParam.setTasks(agvTaskParamList);
+ }
+ 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("localhost:8080")
- .setPath("test/task/create")
- .setJson(JSONObject.toJSONString(agvTaskCreateParam))
+ .setUri(url)
+ .setPath(path)
+ .setJson(JSONObject.toJSONString(requestParam))
.build()
.doPost();
+ JSONObject jsonObject = JSON.parseObject(response);
+
+ int code = (int) jsonObject.get("code");
+ if(code != 0){
+ throw new CoolException("璋冪敤AGV鍝嶅簲閿欒");
+ }
+ success = true;
+ return code;
}catch (Exception e){
-
+ log.error(e.getMessage());
+ throw new CoolException("璋冪敤AGV鍝嶅簲閿欒");
}finally {
-// apiLogService.save(
-// "涓婃灦浠诲姟涓嬪彂",
-// url + path,
-// null,
-// "127.0.0.1",
-// JSON.toJSONString(requestMap),
-// response,
-// success
-// );
+ apiLogService.save(
+ namespace,
+ url + path,
+ appkey,
+ ip,
+ JSON.toJSONString(JSONObject.toJSONString(requestParam)),
+ response,
+ success
+ );
}
- JSONObject jsonObject = JSON.parseObject(response);
- //save log api
- int code = (int) jsonObject.get("code");
- if(code != 0){
- throw new CoolException("璋冪敤AGV鎺ュ彛澶辫触");
- }
-
- return containerMoveParam;
- }
-
- public int containerMove(Map<String, List<Map<String, String>>> containerMoveParam) throws IOException {
- String response = new HttpHandler.Builder()
- .setUri("localhost:8080")
- .setPath("test/container/moveIn")
- .setJson(JSONObject.toJSONString(containerMoveParam))
- .build()
- .doPost();
-
- JSONObject jsonObject = JSON.parseObject(response);
- return (int) jsonObject.get("code");
}
}
--
Gitblit v1.9.1