#
Junjie
1 天以前 707f8db2227a6031f230e35895ea1c5f7ff03bd6
src/main/java/com/zy/core/utils/StationOperateProcessUtils.java
@@ -5,14 +5,8 @@
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.core.common.Cools;
import com.zy.asrs.domain.param.CreateInTaskParam;
import com.zy.asrs.entity.BasCrnp;
import com.zy.asrs.entity.BasDevp;
import com.zy.asrs.entity.HttpRequestLog;
import com.zy.asrs.entity.WrkMast;
import com.zy.asrs.service.BasCrnpService;
import com.zy.asrs.service.BasDevpService;
import com.zy.asrs.service.HttpRequestLogService;
import com.zy.asrs.service.WrkMastService;
import com.zy.asrs.entity.*;
import com.zy.asrs.service.*;
import com.zy.asrs.utils.Utils;
import com.zy.common.model.StartupDto;
import com.zy.common.service.CommonService;
@@ -53,6 +47,8 @@
    private ConfigService configService;
    @Autowired
    private HttpRequestLogService httpRequestLogService;
    @Autowired
    private LocMastService locMastService;
    //执行输送站点入库任务
    public synchronized void stationInExecute() {
@@ -253,6 +249,11 @@
                continue;
            }
            List<Integer> runBlockReassignLocStationList = new ArrayList<>();
            for (StationObjModel stationObjModel : basDevp.getRunBlockReassignLocStationList$()) {
                runBlockReassignLocStationList.add(stationObjModel.getStationId());
            }
            List<StationProtocol> list = stationThread.getStatus();
            for (StationProtocol stationProtocol : list) {
                if(stationProtocol.isAutoing()
@@ -260,7 +261,6 @@
                    && stationProtocol.getTaskNo() > 0
                    && stationProtocol.isRunBlock()
                ) {
                    //运行堵塞,重新申请任务
                    WrkMast wrkMast = wrkMastService.selectByWorkNo(stationProtocol.getTaskNo());
                    if (wrkMast == null) {
                        News.info("输送站点号={} 运行阻塞,但无法找到对应任务,工作号={}", stationProtocol.getStationId(), stationProtocol.getTaskNo());
@@ -271,61 +271,112 @@
                    if (lock != null) {
                        continue;
                    }
                    redisUtil.set(RedisKeyType.CHECK_STATION_RUN_BLOCK_LIMIT_.key + stationProtocol.getTaskNo(), "lock", 15);
                    HashMap<String, Object> requestParam = new HashMap<>();
                    String response = null;
                    try {
                        requestParam.put("taskNo", wrkMast.getWmsWrkNo());
                        requestParam.put("row", Utils.getInTaskEnableRow(new ArrayList<>(basDevp.getDevpNo())));
                    if (runBlockReassignLocStationList.contains(stationProtocol.getStationId())) {
                        //站点处于重新分配库位区域
                        //运行堵塞,重新申请任务
                        response = new HttpHandler.Builder()
                                .setUri(wmsUrl)
                                .setPath(wmsSystemReassignInTaskUrl)
                                .setJson(JSON.toJSONString(requestParam))
                                .build()
                                .doPost();
                        JSONObject jsonObject = JSON.parseObject(response);
                        if (jsonObject.getInteger("code").equals(200)) {
                            StartupDto dto = jsonObject.getObject("data", StartupDto.class);
                        HashMap<String, Object> requestParam = new HashMap<>();
                        String response = null;
                        try {
                            requestParam.put("taskNo", wrkMast.getWmsWrkNo());
                            requestParam.put("row", Utils.getInTaskEnableRow(new ArrayList<>(basDevp.getDevpNo())));
                            String locNo = dto.getLocNo();
                            //更新数据
                            wrkMast.setLocNo(locNo);
                            wrkMastService.updateById(wrkMast);
                            response = new HttpHandler.Builder()
                                    .setUri(wmsUrl)
                                    .setPath(wmsSystemReassignInTaskUrl)
                                    .setJson(JSON.toJSONString(requestParam))
                                    .build()
                                    .doPost();
                            JSONObject jsonObject = JSON.parseObject(response);
                            if (jsonObject.getInteger("code").equals(200)) {
                                StartupDto dto = jsonObject.getObject("data", StartupDto.class);
                            Integer crnNo = commonService.findCrnNoByLocNo(locNo);
                            if (crnNo == null) {
                                News.taskInfo(wrkMast.getWrkNo(), "未匹配到堆垛机");
                                continue;
                                String sourceLocNo = wrkMast.getLocNo();
                                String locNo = dto.getLocNo();
                                LocMast sourceLocMast = locMastService.queryByLoc(sourceLocNo);
                                if (sourceLocMast == null) {
                                    News.taskInfo(wrkMast.getWrkNo(), "库位号:{} 源库位信息不存在", sourceLocNo);
                                    continue;
                                }
                                if (!sourceLocMast.getLocSts().equals("S")) {
                                    News.taskInfo(wrkMast.getWrkNo(), "库位号:{} 源库位状态不处于入库预约", sourceLocNo);
                                    continue;
                                }
                                LocMast locMast = locMastService.queryByLoc(locNo);
                                if (locMast == null) {
                                    News.taskInfo(wrkMast.getWrkNo(), "库位号:{} 目标库位信息不存在", locNo);
                                    continue;
                                }
                                if (!locMast.getLocSts().equals("O")) {
                                    News.taskInfo(wrkMast.getWrkNo(), "库位号:{} 目标库位状态不处于空库位", locNo);
                                    continue;
                                }
                                Integer crnNo = commonService.findCrnNoByLocNo(locNo);
                                if (crnNo == null) {
                                    News.taskInfo(wrkMast.getWrkNo(), "未匹配到堆垛机");
                                    continue;
                                }
                                Integer targetStationId = commonService.findInStationId(crnNo, stationProtocol.getStationId());
                                if (targetStationId == null) {
                                    News.taskInfo(wrkMast.getWrkNo(), "搜索入库站点失败");
                                    continue;
                                }
                                StationCommand command = stationThread.getMoveCommand(wrkMast.getWrkNo(), stationProtocol.getStationId(), targetStationId, 0);
                                if(command == null){
                                    News.taskInfo(wrkMast.getWrkNo(), "获取输送线命令失败");
                                    continue;
                                }
                                //更新源库位
                                sourceLocMast.setLocSts("O");
                                sourceLocMast.setModiTime(new Date());
                                locMastService.updateById(sourceLocMast);
                                //更新目标库位
                                locMast.setLocSts("S");
                                locMast.setModiTime(new Date());
                                locMastService.updateById(locMast);
                                //更新工作档数据
                                wrkMast.setLocNo(locNo);
                                wrkMast.setCrnNo(crnNo);
                                wrkMast.setStaNo(targetStationId);
                                if (wrkMastService.updateById(wrkMast)) {
                                    MessageQueue.offer(SlaveType.Devp, basDevp.getDevpNo(), new Task(2, command));
                                }
                                News.info("请求WMS接口成功!!!url:{};request:{};response:{}", wmsUrl + wmsSystemReassignInTaskUrl, JSON.toJSONString(requestParam), response);
                            } else {
                                News.error("请求WMS接口失败!!!url:{};request:{};response:{}", wmsUrl + wmsSystemReassignInTaskUrl, JSON.toJSONString(requestParam), response);
                            }
                            Integer targetStationId = commonService.findInStationId(crnNo, stationProtocol.getStationId());
                            if (targetStationId == null) {
                                News.taskInfo(wrkMast.getWrkNo(), "搜索入库站点失败");
                                continue;
                            }
                            StationCommand command = stationThread.getMoveCommand(wrkMast.getWrkNo(), stationProtocol.getStationId(), targetStationId, 0);
                            if(command == null){
                                News.taskInfo(wrkMast.getWrkNo(), "获取输送线命令失败");
                                continue;
                            }
                            MessageQueue.offer(SlaveType.Devp, basDevp.getDevpNo(), new Task(2, command));
                            News.info("请求WMS接口成功!!!url:{};request:{};response:{}", wmsUrl + wmsSystemReassignInTaskUrl, JSON.toJSONString(requestParam), response);
                        } else {
                            News.error("请求WMS接口失败!!!url:{};request:{};response:{}", wmsUrl + wmsSystemReassignInTaskUrl, JSON.toJSONString(requestParam), response);
                        } catch (Exception e) {
                            News.error("请求WMS接口异常!!!url:{};request:{}; response:{}", wmsUrl + wmsSystemReassignInTaskUrl, JSON.toJSONString(requestParam), response, e);
                        } finally {
                            HttpRequestLog httpRequestLog = new HttpRequestLog();
                            httpRequestLog.setName(wmsUrl + wmsSystemReassignInTaskUrl);
                            httpRequestLog.setRequest(JSON.toJSONString(requestParam));
                            httpRequestLog.setResponse(response);
                            httpRequestLog.setCreateTime(new Date());
                            httpRequestLogService.insert(httpRequestLog);
                        }
                    } catch (Exception e) {
                        News.error("请求WMS接口异常!!!url:{};request:{}; response:{}", wmsUrl + wmsSystemReassignInTaskUrl, JSON.toJSONString(requestParam), response, e);
                    } finally {
                        HttpRequestLog httpRequestLog = new HttpRequestLog();
                        httpRequestLog.setName(wmsUrl + wmsSystemReassignInTaskUrl);
                        httpRequestLog.setRequest(JSON.toJSONString(requestParam));
                        httpRequestLog.setResponse(response);
                        httpRequestLog.setCreateTime(new Date());
                        httpRequestLogService.insert(httpRequestLog);
                    }else {
                        //运行堵塞,重新计算路线
                        StationCommand command = stationThread.getMoveCommand(wrkMast.getWrkNo(), stationProtocol.getStationId(), wrkMast.getStaNo(), 0);
                        if(command == null){
                            News.taskInfo(wrkMast.getWrkNo(), "获取输送线命令失败");
                            continue;
                        }
                        MessageQueue.offer(SlaveType.Devp, basDevp.getDevpNo(), new Task(2, command));
                        News.info("输送站点堵塞后重新计算路径命令下发成功,站点号={},工作号={},命令数据={}", stationProtocol.getStationId(), wrkMast.getWrkNo(), JSON.toJSONString(command));
                    }
                }
            }