| | |
| | | package com.zy.asrs.service.impl; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.core.common.Cools; |
| | | import com.zy.asrs.domain.enums.NotifyMsgType; |
| | |
| | | import com.zy.asrs.utils.NotifyUtils; |
| | | import com.zy.asrs.utils.Utils; |
| | | import com.zy.common.model.MapNode; |
| | | import com.zy.common.model.SearchLocParam; |
| | | import com.zy.common.model.StartupDto; |
| | | import com.zy.common.model.enums.NavigationMapType; |
| | | import com.zy.common.service.CommonService; |
| | | import com.zy.common.utils.*; |
| | |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | |
| | | /** |
| | |
| | | @Autowired |
| | | private NoLiftOutServiceImpl noLiftOutService; |
| | | |
| | | |
| | | public static List<Integer> staNosIn = new ArrayList<Integer>() {{ |
| | | add(1015); |
| | | add(1026); |
| | | }}; |
| | | |
| | | private boolean isInEnable(DevpThread devpThread, Integer staNo) { |
| | | if (staNo == null) { |
| | |
| | | continue; |
| | | } |
| | | // 判断是否满足入库条件 |
| | | if (staProtocol.isAutoing() && staProtocol.isLoading() |
| | | && isInEnable(devpThread, inSta.getStaNo()) |
| | | && !staProtocol.isEmptyMk() && (workNo == 0 || (workNo >= 9990 && workNo <= 9999)) |
| | | && staProtocol.isPakMk() |
| | | ) { |
| | | if (staProtocol.isAutoing() && staProtocol.isLoading() && isInEnable(devpThread, inSta.getStaNo()) && !staProtocol.isEmptyMk() && (workNo == 0 || (workNo >= 9990 && workNo <= 9999)) && staProtocol.isPakMk()) { |
| | | String barcode = staProtocol.getBarcode(); |
| | | if (!Cools.isEmpty(barcode)) { |
| | | News.info("条码扫描器检测条码信息:{}", barcode); |
| | | } |
| | | // 判断重复工作档 |
| | | WrkMast wrkMast = wrkMastService.selectOne(new EntityWrapper<WrkMast>() |
| | | .eq("source_sta_no", inSta.getStaNo()) |
| | | .eq("wrk_sts", WrkStsType.NEW_INBOUND) |
| | | .eq("barcode", barcode)); |
| | | WrkMast wrkMast = wrkMastService.selectOne(new EntityWrapper<WrkMast>().eq("source_sta_no", inSta.getStaNo()).eq("wrk_sts", WrkStsType.NEW_INBOUND).eq("barcode", barcode)); |
| | | if (wrkMast != null) { |
| | | News.error("工作档已存在,工作号={}", wrkMast.getWrkNo()); |
| | | if (staProtocol.getWorkNo().intValue() != wrkMast.getWrkNo()) { |
| | | MessageQueue.offer(SlaveType.Devp, devpSlave.getId(), new Task(2, staProtocol)); |
| | | devpThread.setPakMk(staProtocol.getSiteId(), false); |
| | | News.info("输送线入库命令下发,任务数据={}", JSON.toJSON(wrkMast)); |
| | | //判断时提升机侧,还是无提升机测 |
| | | if (inSta.getStaNo() == 1014 || inSta.getStaNo() == 1025) { |
| | | staProtocol.setWorkNo(Short.parseShort(String.valueOf(wrkMast.getWrkNo()))); |
| | | staProtocol.setStaNo(Short.parseShort(String.valueOf(wrkMast.getStaNo()))); |
| | | MessageQueue.offer(SlaveType.Devp, devpSlave.getId(), new Task(2, staProtocol)); |
| | | News.info("输送线入库命令下发,任务数据={}", JSON.toJSON(wrkMast)); |
| | | wrkMast.setWrkSts(WrkStsType.INBOUND_DEVICE_RUN.sts); |
| | | wrkMast.setModiTime(new Date()); |
| | | wrkMastService.updateById(wrkMast); |
| | | } else { |
| | | |
| | | } |
| | | } |
| | | continue; |
| | | } |
| | | |
| | | try { |
| | | String wmsUrl = "127.0.0.1:8080/fyxcwms"; |
| | | /*String wmsUrl = "127.0.0.1:8080/fyxcwms"; |
| | | SearchLocParam param = new SearchLocParam(); |
| | | param.setBarcode(barcode); |
| | | param.setIoType(1); |
| | |
| | | JSONObject jsonObject = JSON.parseObject(response); |
| | | Integer code = jsonObject.getInteger("code"); |
| | | if (code.equals(200)) { |
| | | MessageQueue.offer(SlaveType.Devp, devpSlave.getId(), new Task(2, staProtocol)); |
| | | devpThread.setPakMk(staProtocol.getSiteId(), false); |
| | | News.info("输送线入库命令下发,任务数据={}", JSON.toJSON(wrkMast)); |
| | | |
| | | StartupDto dto = jsonObject.getObject("data", StartupDto.class); |
| | | |
| | | // String wmsLocNo = dto.getLocNo(); |
| | |
| | | .build() |
| | | .doPost(); |
| | | News.error("入库申请失败,任务数据={},请求响应={}", JSON.toJSON(param), JSON.toJSON(jsonObject)); |
| | | } |
| | | }*/ |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | public synchronized void generateInboundWrk2() { |
| | | DevpSlave devpSlave = slaveProperties.getDevp().get(0); |
| | | // 遍历堆垛机出库站 |
| | | for (DevpSlave.Sta inSta : devpSlave.getInSta()) { |
| | | DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, 1); |
| | | StaProtocol staProtocol = devpThread.getStation().get(inSta); |
| | | if (staProtocol == null) { |
| | | return; |
| | | } else { |
| | | staProtocol = staProtocol.clone(); |
| | | } |
| | | Short finishWorkNo = staProtocol.getFinishWorkNo(); |
| | | WrkMast wrkMast = wrkMastService.selectByWorkNo(Integer.valueOf(finishWorkNo)); |
| | | if (wrkMast != null) { |
| | | if (wrkMast.getSourceStaNo() == 1015 || wrkMast.getSourceStaNo() == 1026) { |
| | | |
| | | //调度车辆 |
| | | // boolean dispatchShuttle = shuttleDispatchUtils.dispatchShuttle(null, staProtocol.getLocNo(), wrkMast.getLocNo(), param.getShuttleNo(), "TRANSPORT_DEVP"); |
| | | // if (!dispatchShuttle) { |
| | | // News.taskInfo(wrkMast.getWrkNo(), "{}任务,{}小车,调度至取货点失败", wrkMast.getWrkNo(), shuttleProtocol.getShuttleNo()); |
| | | // return; |
| | | // } |
| | | } else { |
| | | //判断提升机 |
| | | |
| | | |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 出库到出库口 |
| | |
| | | public synchronized void stnToOutStn() { |
| | | DevpSlave devpSlave = slaveProperties.getDevp().get(0); |
| | | // 遍历堆垛机出库站 |
| | | for (DevpSlave.Sta outSta : devpSlave.getOutSta()) { |
| | | // 获取堆垛机出库站信息 |
| | | DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, devpSlave.getId()); |
| | | StaProtocol staProtocol = devpThread.getStation().get(outSta.getStaNo()); |
| | | if (staProtocol == null) { |
| | | continue; |
| | | } else { |
| | | staProtocol = staProtocol.clone(); |
| | | } |
| | | if (staProtocol.isAutoing() && staProtocol.isLoading() && (staProtocol.getWorkNo() == 0 || staProtocol.getStaNo() == null)) { |
| | | // 查询工作档 |
| | | // WrkMast wrkMast = wrkMastMapper.selectPakOutStep2(staProtocol.getSiteId()); |
| | | // if (wrkMast == null) { |
| | | // continue; |
| | | // } |
| | | // // 判断工作档条件 |
| | | // if (wrkMast.getIoType() < 100 || wrkMast.getStaNo() == null || wrkMast.getSourceStaNo() == null) { |
| | | // |
| | | // } |
| | | for (DevpSlave.Sta inSta : devpSlave.getInSta()) { |
| | | if (inSta.getStaNo() == 1014 || inSta.getStaNo() == 1025) { |
| | | DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, devpSlave.getId()); |
| | | List<WrkMast> wrkSts = wrkMastService.selectList(new EntityWrapper<WrkMast>().eq("wrk_sts", WrkStsType.OUTBOUND_LIFT_RUN_COMPLETE.sts)); |
| | | for (WrkMast wrkMast : wrkSts) { |
| | | StaProtocol staProtocol = devpThread.getStation().get(inSta.getStaNo()); |
| | | if (staProtocol == null) { |
| | | continue; |
| | | } else { |
| | | staProtocol = staProtocol.clone(); |
| | | } |
| | | if (staProtocol.isAutoing() && !staProtocol.isLoading() && (staProtocol.getWorkNo() == 0 || staProtocol.getStaNo() == null)) { |
| | | // 查询工作档 |
| | | if (wrkMast == null) { |
| | | continue; |
| | | } |
| | | staProtocol.setWorkNo(Short.parseShort(String.valueOf(wrkMast.getWrkNo()))); |
| | | staProtocol.setStaNo(Short.parseShort(String.valueOf(wrkMast.getStaNo()))); |
| | | MessageQueue.offer(SlaveType.Devp, devpSlave.getId(), new Task(2, staProtocol)); |
| | | News.info("输送线入库命令下发,任务数据={}", JSON.toJSON(wrkMast)); |
| | | wrkMast.setWrkSts(WrkStsType.COMPLETE_OUTBOUND.sts); |
| | | wrkMast.setModiTime(new Date()); |
| | | wrkMastService.updateById(wrkMast); |
| | | |
| | | // 判断输送线和小车状态状态等待确认 |
| | | // if (crnProtocol.modeType == CrnModeType.AUTO && crnProtocol.getTaskNo().equals(wrkMast.getWrkNo().shortValue()) |
| | | // && crnProtocol.statusType == CrnStatusType.WAITING |
| | | // && crnProtocol.forkPosType == CrnForkPosType.HOME) { |
| | | // log.info("堆垛机出库完成 - 开始执行"); |
| | | // |
| | | // // 命令下发区 -------------------------------------------------------------------------- |
| | | // |
| | | // // 下发站点信息 |
| | | // staProtocol.setWorkNo(wrkMast.getWrkNo()); |
| | | // staProtocol.setStaNo(RouteUtils.CrnStaEnd(wrkMast.getStaNo(), wrkMast.getSourceStaNo())); |
| | | // if (!MessageQueue.offer(SlaveType.Devp, crnStn.getDevpPlcId(), new Task(2, staProtocol))) { |
| | | // log.info(staProtocol.getWorkNo() + "," + staProtocol.getStaNo() + "输送线出库命令下发失败"); |
| | | // continue; |
| | | // } else { |
| | | // log.info(staProtocol.getWorkNo() + "," + staProtocol.getStaNo() + "输送线出库命令下发成功"); |
| | | // } |
| | | // |
| | | // // 更新工作档状态为14失败 |
| | | // wrkMast.setWrkSts(14L); |
| | | // wrkMast.setCrnEndTime(new Date()); |
| | | // if (wrkMastMapper.updateById(wrkMast) != 0) { |
| | | // // 复位堆垛机 |
| | | // log.error("出库任务完成下发堆垛机复位,{}", wrkMast.getWrkNo()); |
| | | // crnThread.setResetFlag(true); |
| | | // } else { |
| | | // News.error("" + mark + " - 1" + " - 更新工作档的工作状态为14失败!!! [工作号:{}]", wrkMast.getWrkNo()); |
| | | // } |
| | | // |
| | | // } else { |
| | | // News.errorNoLog("" + mark + " - 6" + " - 堆垛机信息不符合入库条件!!!" |
| | | // + " 堆垛机状态:" + crnProtocol.modeType + "==自动AUTO:" + CrnModeType.AUTO |
| | | // + "、堆垛机任务号:" + crnProtocol.getTaskNo() + "==工作档任务号:" + wrkMast.getWrkNo().shortValue() |
| | | // + "、状态枚举:" + crnProtocol.statusType + "==WAITING:90 //任务完成等待WCS确认):" + CrnStatusType.WAITING |
| | | // + "、货叉位置:" + crnProtocol.forkPosType + "==HOME:0 // 货叉原位:" + CrnForkPosType.HOME); |
| | | // } |
| | | } |
| | | } |
| | | } else { |
| | | |
| | | } |
| | | } |
| | |
| | | */ |
| | | public synchronized void shuttleInExecute() { |
| | | try { |
| | | List<WrkMast> wrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>() |
| | | .in("wrk_sts" |
| | | , WrkStsType.INBOUND_LIFT_RUN_COMPLETE.sts |
| | | )); |
| | | List<WrkMast> wrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>().in("wrk_sts", WrkStsType.INBOUND_LIFT_RUN_COMPLETE.sts)); |
| | | for (WrkMast wrkMast : wrkMasts) { |
| | | boolean step1 = this.shuttleInExecuteStep1(wrkMast);//小车搬入库中 |
| | | if (!step1) { |
| | |
| | | */ |
| | | public synchronized void shuttleOutExecute() { |
| | | try { |
| | | List<WrkMast> wrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>() |
| | | .in("wrk_sts" |
| | | , WrkStsType.NEW_OUTBOUND.sts |
| | | )); |
| | | List<WrkMast> wrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>().in("wrk_sts", WrkStsType.NEW_OUTBOUND.sts)); |
| | | for (WrkMast wrkMast : wrkMasts) { |
| | | boolean step1 = this.shuttleOutExecuteStep1(wrkMast);//小车搬出库中 |
| | | if (!step1) { |
| | |
| | | |
| | | //四向穿梭车状态为等待确认、小车处于空闲状态 |
| | | if (shuttleProtocol.getProtocolStatus() == ShuttleProtocolStatusType.WAITING.id //任务完成等待确认 |
| | | && shuttleProtocol.getTaskNo() != 0 |
| | | ) { |
| | | && shuttleProtocol.getTaskNo() != 0) { |
| | | //将任务档标记为完成 |
| | | WrkMast wrkMast = wrkMastService.selectByWorkNo(shuttleProtocol.getTaskNo()); |
| | | if (wrkMast != null) { |
| | |
| | | wrkMast.setWrkSts(WrkStsType.MOVE_IN_NO_LIFT_14.sts); |
| | | shuttleThread.setSyncTaskNo(0); |
| | | notifyUtils.notify(String.valueOf(SlaveType.Shuttle), shuttleProtocol.getShuttleNo(), String.valueOf(wrkMast.getWrkNo()), wrkMast.getWmsWrkNo(), NotifyMsgType.SHUTTLE_POWER_COMPLETE);//触发通知 |
| | | } else if (wrkMast.getWrkSts() == WrkStsType.MOVE_OUT_NO_LIFT_12.sts) { |
| | | } else if (wrkMast.getWrkSts() == WrkStsType.MOVE_OUT_NO_LIFT_12.sts) { |
| | | wrkMast.setWrkSts(WrkStsType.MOVE_OUT_NO_LIFT_13.sts); |
| | | shuttleThread.setSyncTaskNo(0); |
| | | notifyUtils.notify(String.valueOf(SlaveType.Shuttle), shuttleProtocol.getShuttleNo(), String.valueOf(wrkMast.getWrkNo()), wrkMast.getWmsWrkNo(), NotifyMsgType.SHUTTLE_POWER_COMPLETE);//触发通知 |
| | | }else if (wrkMast.getWrkSts() == WrkStsType.MOVE_OUT_NO_LIFT_10.sts) { |
| | | } else if (wrkMast.getWrkSts() == WrkStsType.MOVE_OUT_NO_LIFT_10.sts) { |
| | | wrkMast.setWrkSts(WrkStsType.MOVE_OUT_NO_LIFT_11.sts); |
| | | shuttleThread.setSyncTaskNo(0); |
| | | notifyUtils.notify(String.valueOf(SlaveType.Shuttle), shuttleProtocol.getShuttleNo(), String.valueOf(wrkMast.getWrkNo()), wrkMast.getWmsWrkNo(), NotifyMsgType.SHUTTLE_POWER_COMPLETE);//触发通知 |
| | | }else if (wrkMast.getWrkSts() == WrkStsType.MOVE_OUT_NO_LIFT_8.sts) { |
| | | } else if (wrkMast.getWrkSts() == WrkStsType.MOVE_OUT_NO_LIFT_8.sts) { |
| | | wrkMast.setWrkSts(WrkStsType.MOVE_OUT_NO_LIFT_9.sts); |
| | | shuttleThread.setSyncTaskNo(0); |
| | | notifyUtils.notify(String.valueOf(SlaveType.Shuttle), shuttleProtocol.getShuttleNo(), String.valueOf(wrkMast.getWrkNo()), wrkMast.getWmsWrkNo(), NotifyMsgType.SHUTTLE_POWER_COMPLETE);//触发通知 |
| | | }else if (wrkMast.getWrkSts() == WrkStsType.MOVE_OUT_NO_LIFT_6.sts) { |
| | | } else if (wrkMast.getWrkSts() == WrkStsType.MOVE_OUT_NO_LIFT_6.sts) { |
| | | wrkMast.setWrkSts(WrkStsType.MOVE_OUT_NO_LIFT_7.sts); |
| | | shuttleThread.setSyncTaskNo(0); |
| | | notifyUtils.notify(String.valueOf(SlaveType.Shuttle), shuttleProtocol.getShuttleNo(), String.valueOf(wrkMast.getWrkNo()), wrkMast.getWmsWrkNo(), NotifyMsgType.SHUTTLE_POWER_COMPLETE);//触发通知 |
| | | }else if (wrkMast.getWrkSts() == WrkStsType.MOVE_OUT_NO_LIFT_4.sts) { |
| | | } else if (wrkMast.getWrkSts() == WrkStsType.MOVE_OUT_NO_LIFT_4.sts) { |
| | | wrkMast.setWrkSts(WrkStsType.MOVE_OUT_NO_LIFT_5.sts); |
| | | shuttleThread.setSyncTaskNo(0); |
| | | notifyUtils.notify(String.valueOf(SlaveType.Shuttle), shuttleProtocol.getShuttleNo(), String.valueOf(wrkMast.getWrkNo()), wrkMast.getWmsWrkNo(), NotifyMsgType.SHUTTLE_POWER_COMPLETE);//触发通知 |
| | | }else if (wrkMast.getWrkSts() == WrkStsType.MOVE_OUT_NO_LIFT_2.sts) { |
| | | } else if (wrkMast.getWrkSts() == WrkStsType.MOVE_OUT_NO_LIFT_2.sts) { |
| | | wrkMast.setWrkSts(WrkStsType.MOVE_OUT_NO_LIFT_3.sts); |
| | | shuttleThread.setSyncTaskNo(0); |
| | | notifyUtils.notify(String.valueOf(SlaveType.Shuttle), shuttleProtocol.getShuttleNo(), String.valueOf(wrkMast.getWrkNo()), wrkMast.getWmsWrkNo(), NotifyMsgType.SHUTTLE_POWER_COMPLETE);//触发通知 |
| | | } |
| | | |
| | | |
| | | |
| | | else { |
| | | } else { |
| | | continue; |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | //提升机为等待确认且空闲 |
| | | if (liftProtocol.getProtocolStatus() == LiftProtocolStatusType.WAITING.id |
| | | && liftProtocol.getTaskNo() != 0 |
| | | ) { |
| | | if (liftProtocol.getProtocolStatus() == LiftProtocolStatusType.WAITING.id && liftProtocol.getTaskNo() != 0) { |
| | | //将任务档标记为完成 |
| | | WrkMast wrkMast = wrkMastService.selectByWorkNo(liftProtocol.getTaskNo()); |
| | | if (wrkMast != null) { |
| | |
| | | } else if (wrkMast.getWrkSts() == WrkStsType.MOVE_IN_NO_LIFT_9.sts) { |
| | | //提升机至小车层 ==> 提升机至小车层完成 |
| | | wrkMast.setWrkSts(WrkStsType.MOVE_IN_NO_LIFT_10.sts); |
| | | }else if (wrkMast.getWrkSts() == WrkStsType.MOVE_OUT_NO_LIFT_8.sts) { |
| | | } else if (wrkMast.getWrkSts() == WrkStsType.MOVE_OUT_NO_LIFT_8.sts) { |
| | | //提升机至小车层 ==> 提升机至小车层完成 |
| | | wrkMast.setWrkSts(WrkStsType.MOVE_OUT_NO_LIFT_9.sts); |
| | | }else if (wrkMast.getWrkSts() == WrkStsType.MOVE_OUT_NO_LIFT_4.sts) { |
| | | } else if (wrkMast.getWrkSts() == WrkStsType.MOVE_OUT_NO_LIFT_4.sts) { |
| | | //提升机至小车层 ==> 提升机至小车层完成 |
| | | wrkMast.setWrkSts(WrkStsType.MOVE_OUT_NO_LIFT_5.sts); |
| | | } |
| | |
| | | int errorCode = Integer.parseInt(shuttleProtocol.getErrorCode()); |
| | | BasShuttleErr basShuttleErr = basShuttleErrService.queryByCode(errorCode); |
| | | String errName = basShuttleErr == null ? "未知异常" : basShuttleErr.getErrName(); |
| | | BasShuttleErrLog basShuttleErrLog = new BasShuttleErrLog( |
| | | null, // 编号 |
| | | BasShuttleErrLog basShuttleErrLog = new BasShuttleErrLog(null, // 编号 |
| | | wrkMast.getWrkNo(), // 工作号 |
| | | now, // 发生时间 |
| | | null, // 结束时间 |
| | |
| | | BasLiftErr basLiftErr = basLiftErrService.queryByCode(Integer.parseInt(liftProtocol.getErrorCode())); |
| | | String errName = basLiftErr == null ? "未知异常" : basLiftErr.getErrName(); |
| | | |
| | | BasLiftErrLog basLiftErrLog = new BasLiftErrLog( |
| | | null, // 编号 |
| | | BasLiftErrLog basLiftErrLog = new BasLiftErrLog(null, // 编号 |
| | | wrkMast.getWrkNo(), // 工作号 |
| | | now, // 发生时间 |
| | | null, // 结束时间 |