From c135b2adb55f470ca20b434ed71ae48d8874d6b0 Mon Sep 17 00:00:00 2001 From: zyx <zyx123456> Date: 星期日, 07 四月 2024 11:05:06 +0800 Subject: [PATCH] 订单系统bug --- src/main/java/com/zy/asrs/service/impl/AgvWrkMastServiceImp.java | 110 +++++++++++++++++++++++++++++++++++-------------------- 1 files changed, 70 insertions(+), 40 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 8d90d1d..5a25ca3 100644 --- a/src/main/java/com/zy/asrs/service/impl/AgvWrkMastServiceImp.java +++ b/src/main/java/com/zy/asrs/service/impl/AgvWrkMastServiceImp.java @@ -2,17 +2,16 @@ import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; +import com.baomidou.mybatisplus.mapper.EntityWrapper; +import com.baomidou.mybatisplus.mapper.Wrapper; import com.baomidou.mybatisplus.service.impl.ServiceImpl; +import com.core.common.Cools; import com.core.exception.CoolException; import com.zy.asrs.entity.AgvWrkMast; import com.zy.asrs.entity.param.AgvTaskCreateParam; 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.asrs.service.*; import com.zy.common.utils.HttpHandler; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; @@ -20,11 +19,7 @@ import org.springframework.stereotype.Service; import java.io.IOException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; +import java.util.*; @Service @Slf4j @@ -42,6 +37,9 @@ @Value("${agv.containerMoveOutPath}") private String containerMoveOutPath; + @Value("${agv.containerArrivedPath}") + private String containerArrivedPath; + @Autowired AgvWrkMastMapper agvWrkMastMapper; @Autowired @@ -50,6 +48,8 @@ AgvLocMastService agvLocMastService; @Autowired ApiLogService apiLogService; + @Autowired + AgvBasDevpService agvBasDevpService; public void updateWrkStsByWrkNo(int wrkNo, long wrkSts) { AgvWrkMast agvWrkMast = this.selectById(wrkNo); @@ -67,31 +67,30 @@ return true; } - public int startWrk(List<AgvWrkMast> agvWrkMastList, String taskType) throws IOException { + public int startWrk(AgvWrkMast agvWrkMast) throws IOException { AgvTaskCreateParam agvTaskCreateParam = new AgvTaskCreateParam(); - agvTaskCreateParam.setTaskType(taskType); + //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,agvWrkMast); - getRequestParam(agvTaskCreateParam,agvWrkMastList); - - return doHttpRequest(agvTaskCreateParam,"涓婃灦浠诲姟涓嬪彂",url, taskCreatePath,null,"127.0.0.1"); + return doHttpRequest(agvTaskCreateParam,"鎼繍浠诲姟涓嬪彂",url, taskCreatePath,null,"127.0.0.1"); //return containerMoveParam; } //瀹瑰櫒鍏ュ満 - public int containerMove(List<AgvWrkMast> agvWrkMastList) throws IOException { + 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); getContainerMoveParam(agvWrkMastList,positionCodeMapList); + + if(Cools.isEmpty(positionCodeMapList)){ + return 0; + } return doHttpRequest(containerMoveParam,"瀹瑰櫒鍏ュ満浠诲姟涓嬪彂",url, containerMoveInPath,null,"127.0.0.1"); } @@ -115,37 +114,68 @@ return index > 0; } + @Override + public boolean deleteByWrkNo(int wrkNo) { + return this.delete(new EntityWrapper<AgvWrkMast>().eq("wrk_no", wrkNo)); + } + + //瀹瑰櫒鍒拌揪閫氱煡 + public int containerArrived(AgvWrkMast agvWrkMast) { + + 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"); + } + + @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); + return this.selectList(wrapper); + //return this.baseMapper.selectReadyAgvWrkMast(); + } + + @Override + public AgvWrkMast selectByContainerCode(String containerCode) { + return this.selectOne(new EntityWrapper<AgvWrkMast>().eq("barcode",containerCode)); + } + private void getContainerMoveParam(List<AgvWrkMast> agvWrkMastList,List<Map<String,String>> positionCodeMapList){ //寰�瀹瑰櫒鍏ュ満鍙傛暟涓斁鍏ユ簮绔欑偣浣嶇疆 for(AgvWrkMast agvWrkMast : agvWrkMastList){ + //鍒ゆ柇鏄惁涓鸿緭閫佺嚎鍏ュ簱锛屾槸鍒欎笉闇�瑕佸鍣ㄨ繘鍦鸿姹� + if("Y".equals(agvWrkMast.getMk())){ + continue; + } 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 - if(agvWrkMast.getIoType() == 53 || agvWrkMast.getIoType() == 57){ - agvTaskParam.setTaskCode(-agvWrkMast.getWrkNo() + ""); - }else{ - agvTaskParam.setTaskCode(agvWrkMast.getWrkNo() + ""); - } + private void getRequestParam(AgvTaskCreateParam agvTaskCreateParam,AgvWrkMast agvWrkMast){ - agvTaskParam.setTaskPriority(agvWrkMast.getIoPri().intValue()); + List<AgvTaskParam> agvTaskParamList = Arrays.asList( + //璧峰浣� + new AgvTaskParam(agvWrkMast.getSourceLocNo()), + //鐩爣浣� + new AgvTaskParam(agvWrkMast.getLocNo())); - //AgvTaskkDescribeParam - agvTaskkDescribeParam.setFromLocationCode(agvWrkMast.getSourceLocNo()); - agvTaskkDescribeParam.setToLocationCode(agvWrkMast.getLocNo()); - agvTaskkDescribeParam.setContainerCode(agvWrkMast.getBarcode()); - return agvTaskParam; - }).collect(Collectors.toList()); +// //璧峰浣� +// agvTaskParamList.add(new AgvTaskParam(agvWrkMast.getSourceLocNo())); +// //鐩爣浣� +// agvTaskParamList.add(new AgvTaskParam(agvWrkMast.getLocNo())); - agvTaskCreateParam.setTasks(agvTaskParamList); + if(agvWrkMast.getIoType() == 53 || agvWrkMast.getIoType() == 57 ){ + agvWrkMast.setWrkNo(-agvWrkMast.getWrkNo()); + } + agvTaskCreateParam.setTaskCode(agvWrkMast.getWrkNo().toString()); + agvTaskCreateParam.setTaskTyp("F01"); + agvTaskCreateParam.setPositionCodePath(agvTaskParamList); + } private int doHttpRequest(Object requestParam, String namespace, String url, String path, String appkey, String ip){ @@ -161,7 +191,7 @@ .doPost(); JSONObject jsonObject = JSON.parseObject(response); - int code = (int) jsonObject.get("code"); + int code = Integer.parseInt(jsonObject.get("code").toString()); if(code != 0){ throw new CoolException("璋冪敤AGV鍝嶅簲閿欒"); } -- Gitblit v1.9.1