| | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.core.exception.CoolException; |
| | | import com.zy.asrs.domain.enums.NotifyMsgType; |
| | | import com.zy.asrs.entity.*; |
| | | import com.zy.asrs.service.*; |
| | | import com.zy.asrs.utils.NotifyUtils; |
| | | import com.zy.common.entity.FindCrnNoResult; |
| | | import com.zy.common.model.StartupDto; |
| | | import com.zy.common.service.CommonService; |
| | |
| | | import com.zy.core.model.StationObjModel; |
| | | import com.zy.core.model.Task; |
| | | import com.zy.core.model.command.StationCommand; |
| | | import com.zy.core.model.protocol.CrnProtocol; |
| | | import com.zy.core.model.protocol.StationProtocol; |
| | | import com.zy.core.thread.CrnThread; |
| | | import com.zy.core.thread.StationThread; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | |
| | | private LocMastService locMastService; |
| | | @Autowired |
| | | private WmsOperateUtils wmsOperateUtils; |
| | | @Autowired |
| | | private NotifyUtils notifyUtils; |
| | | |
| | | //执行输送站点入库任务 |
| | | public synchronized void stationInExecute() { |
| | |
| | | News.info("输送站点出库命令下发成功,站点号={},工作号={},命令数据={}", stationProtocol.getStationId(), wrkMast.getWrkNo(), JSON.toJSONString(command)); |
| | | redisUtil.set(RedisKeyType.STATION_OUT_EXECUTE_LIMIT.key + stationProtocol.getStationId(), "lock", 5); |
| | | redisUtil.set(RedisKeyType.STATION_OUT_EXECUTE_COMPLETE_LIMIT.key + wrkMast.getWrkNo(), "lock", 60 * 5); |
| | | redisUtil.set(RedisKeyType.STATION_OUT_EXECUTE_DESTINATION_LIMIT.key + wrkMast.getWrkNo(), "lock", 60 * 5); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | //检测出库任务到达目的地 |
| | | public synchronized void arriveAtTheDestination() { |
| | | List<WrkMast> wrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>().eq("wrk_sts", WrkStsType.STATION_RUN.sts)); |
| | | for (WrkMast wrkMast : wrkMasts) { |
| | | Integer wrkNo = wrkMast.getWrkNo(); |
| | | |
| | | // Object lock = redisUtil.get(RedisKeyType.STATION_OUT_EXECUTE_DESTINATION_LIMIT.key + wrkNo); |
| | | // if (lock != null) { |
| | | // continue; |
| | | // } |
| | | |
| | | boolean complete = false; |
| | | |
| | | StationThread stationThread = (StationThread) SlaveConnection.get(SlaveType.Devp, 1); |
| | | if (stationThread == null) { |
| | | continue; |
| | | } |
| | | List<StationProtocol> list = stationThread.getStatus(); |
| | | for (StationProtocol stationProtocol : list) { |
| | | if (stationProtocol.getTaskNo().equals(wrkNo)&&stationProtocol.getStationId().equals(wrkMast.getStaNo())) { |
| | | complete = true; |
| | | } |
| | | } |
| | | if (complete) { |
| | | //上报--到达目的地上报wms |
| | | notifyUtils.notify("task", 1, String.valueOf(wrkMast.getWrkNo()), wrkMast.getWmsWrkNo(), NotifyMsgType.ARRIVE_AT_THE_DESTINATION, JSON.toJSONString(wrkMast)); |
| | | wrkMast.setWrkSts(WrkStsType.ARRIVE_AT_THE_DESTINATION.sts); |
| | | wrkMast.setIoTime(new Date()); |
| | | wrkMastService.updateById(wrkMast); |
| | | } |
| | | } |
| | | } |
| | | |
| | | //检测库位橙色按钮信号 1:员工确认(常亮) 2 :上位机确认(闪烁)0 :熄灭 |
| | | public synchronized void locNo() { |
| | | List<BasCrnp> basCrnps = basCrnpService.selectList(null); |
| | | for (BasCrnp basCrnp : basCrnps) { |
| | | CrnThread crnThread = (CrnThread) SlaveConnection.get(SlaveType.Crn, basCrnp.getCrnNo()); |
| | | if(crnThread == null){ |
| | | continue; |
| | | } |
| | | |
| | | CrnProtocol crnProtocol = crnThread.getStatus(); |
| | | if(crnProtocol == null){ |
| | | continue; |
| | | } |
| | | |
| | | |
| | | } |
| | | // List<WrkMast> wrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>().eq("wrk_sts", WrkStsType.ARRIVE_AT_THE_DESTINATION.sts)); |
| | | // for (WrkMast wrkMast : wrkMasts) { |
| | | // Integer wrkNo = wrkMast.getWrkNo(); |
| | | // |
| | | // Object lock = redisUtil.get(RedisKeyType.STATION_OUT_EXECUTE_COMPLETE_LIMIT.key + wrkNo); |
| | | // if (lock != null) { |
| | | // continue; |
| | | // } |
| | | // |
| | | // boolean complete = false; |
| | | // |
| | | // StationThread stationThread = (StationThread) SlaveConnection.get(SlaveType.Devp, wrkMast.getStaNo()); |
| | | // if (stationThread == null) { |
| | | // continue; |
| | | // } |
| | | // List<StationProtocol> list = stationThread.getStatus(); |
| | | // for (StationProtocol stationProtocol : list) { |
| | | // if (stationProtocol.getTaskNo().equals(wrkNo)) { |
| | | // complete = true; |
| | | // } |
| | | // } |
| | | // if (complete) { |
| | | // //上报--到达目的地上报wms |
| | | // notifyUtils.notify("task", 1, String.valueOf(wrkMast.getWrkNo()), wrkMast.getWmsWrkNo(), NotifyMsgType.ARRIVE_AT_THE_DESTINATION, JSON.toJSONString(wrkMast)); |
| | | // wrkMast.setWrkSts(WrkStsType.ARRIVE_AT_THE_DESTINATION.sts); |
| | | // wrkMast.setIoTime(new Date()); |
| | | // wrkMastService.updateById(wrkMast); |
| | | // } |
| | | // } |
| | | } |
| | | |
| | | //检测输送站点出库任务执行完成 |
| | | public synchronized void stationOutExecuteFinish() { |
| | | List<WrkMast> wrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>().eq("wrk_sts", WrkStsType.STATION_RUN.sts)); |
| | | List<WrkMast> wrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>().eq("wrk_sts", WrkStsType.ARRIVE_AT_THE_DESTINATION.sts)); |
| | | for (WrkMast wrkMast : wrkMasts) { |
| | | Integer wrkNo = wrkMast.getWrkNo(); |
| | | |