|  |  |  | 
|---|
|  |  |  | import com.zy.core.cache.MessageQueue; | 
|---|
|  |  |  | import com.zy.core.cache.OutputQueue; | 
|---|
|  |  |  | import com.zy.core.cache.SlaveConnection; | 
|---|
|  |  |  | import com.zy.core.enums.CrnLiftPosType; | 
|---|
|  |  |  | import com.zy.core.enums.CrnModeType; | 
|---|
|  |  |  | import com.zy.core.enums.CrnTaskModeType; | 
|---|
|  |  |  | import com.zy.core.enums.SlaveType; | 
|---|
|  |  |  | 
|---|
|  |  |  | import com.zy.core.model.protocol.CrnProtocol; | 
|---|
|  |  |  | import com.zy.core.properties.SlaveProperties; | 
|---|
|  |  |  | import com.zy.core.properties.SystemProperties; | 
|---|
|  |  |  | import com.zy.core.thread.RgvThread; | 
|---|
|  |  |  | import lombok.extern.slf4j.Slf4j; | 
|---|
|  |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
|---|
|  |  |  | import org.springframework.web.bind.annotation.GetMapping; | 
|---|
|  |  |  | 
|---|
|  |  |  | continue; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | vo.setWorkNo(crnProtocol.getTaskNo());  //  任务号 | 
|---|
|  |  |  | //            if (crnProtocol.getTaskNo()>0) { | 
|---|
|  |  |  | //                WrkMast wrkMast = wrkMastService.selectById(crnProtocol.getTaskNo()); | 
|---|
|  |  |  | //                if (wrkMast != null) { | 
|---|
|  |  |  | //                    vo.setStatusType(CrnStatusType.process(wrkMast.getIoType()).getDesc());   //  模式状态 | 
|---|
|  |  |  | //                } | 
|---|
|  |  |  | //            } else { | 
|---|
|  |  |  | // | 
|---|
|  |  |  | //            } | 
|---|
|  |  |  | vo.setStatusType(crnProtocol.modeType.desc);   //  模式状态 | 
|---|
|  |  |  | if (crnProtocol.getTaskFinish() == 1) { | 
|---|
|  |  |  | vo.setStatus("等待确认"); | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | vo.setStatus(crnProtocol.getStatusType().desc);     //  状态 | 
|---|
|  |  |  | if (crnProtocol.getStatusType().equals(com.zy.core.enums.CrnStatusType.PUT_COMPLETE)) { | 
|---|
|  |  |  | vo.setStatus("正在作业"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | vo.setStatus(crnProtocol.getStatusType().desc);     //  状态 | 
|---|
|  |  |  | vo.setLoading(crnProtocol.getLoaded()==1?"有物":"无物");  //  有物 | 
|---|
|  |  |  | vo.setBay(crnProtocol.getBay());    //  列 | 
|---|
|  |  |  | vo.setLev(crnProtocol.getLevel());  //  层 | 
|---|
|  |  |  | vo.setLiftPos(crnProtocol.getLiftPosType().desc); | 
|---|
|  |  |  | if (crnProtocol.getPlatformHigh()) { | 
|---|
|  |  |  | vo.setSitePos("站台高位"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (crnProtocol.getPlatformLow()) { | 
|---|
|  |  |  | vo.setSitePos("站台高位"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | vo.setForkOffset(crnProtocol.getForkPosType().desc);    // 货叉位置 | 
|---|
|  |  |  | vo.setXLocation(crnProtocol.getWalkPos() == 1?"是":"否");      // 走行定位 | 
|---|
|  |  |  | vo.setYLocation(crnProtocol.getLiftPosType().equals(CrnLiftPosType.NONE)?"否":"是");      // 升降定位 | 
|---|
|  |  |  | if (crnProtocol.getAlarm1() > 0) { | 
|---|
|  |  |  | BasCrnError crnError = basCrnErrorMapper.selectById(crnProtocol.getAlarm1()); | 
|---|
|  |  |  | vo.setAlarm1(crnError==null?"未知异常":crnError.getErrName()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (crnProtocol.getAlarm2() > 0) { | 
|---|
|  |  |  | BasCrnError crnError = basCrnErrorMapper.selectById(crnProtocol.getAlarm2()); | 
|---|
|  |  |  | vo.setAlarm2(crnError==null?"未知异常":crnError.getErrName()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (crnProtocol.getAlarm3() > 0) { | 
|---|
|  |  |  | BasCrnError crnError = basCrnErrorMapper.selectById(crnProtocol.getAlarm3()); | 
|---|
|  |  |  | vo.setAlarm3(crnError==null?"未知异常":crnError.getErrName()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (crnProtocol.getAlarm4() > 0) { | 
|---|
|  |  |  | BasCrnError crnError = basCrnErrorMapper.selectById(crnProtocol.getAlarm4()); | 
|---|
|  |  |  | vo.setAlarm4(crnError==null?"未知异常":crnError.getErrName()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //            vo.setAlarm1(String.valueOf(crnProtocol.getAlarm1())); | 
|---|
|  |  |  | //            vo.setAlarm2(String.valueOf(crnProtocol.getAlarm2())); | 
|---|
|  |  |  | //            vo.setAlarm3(String.valueOf(crnProtocol.getAlarm3())); | 
|---|
|  |  |  | //            vo.setAlarm4(String.valueOf(crnProtocol.getAlarm4())); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | vo.setForkOffset(crnProtocol.getForkPosType().desc);    // 货叉位置 | 
|---|
|  |  |  | vo.setLiftPos(crnProtocol.getLiftPosType().desc); | 
|---|
|  |  |  | vo.setWalkPos(crnProtocol.getWalkPos()==1?"不在定位":"在定位"); | 
|---|
|  |  |  | vo.setWarnCode(String.valueOf(crnProtocol.getAlarm())); | 
|---|
|  |  |  | if (crnProtocol.getAlarm() > 0) { | 
|---|
|  |  |  | BasCrnError crnError = basCrnErrorMapper.selectById(crnProtocol.getAlarm()); | 
|---|
|  |  |  | vo.setAlarm(crnError==null?"未知异常":crnError.getErrName()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return R.ok().add(list); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | command.setDestinationPosX(param.getRow());     // 目标库位排 | 
|---|
|  |  |  | command.setDestinationPosY(param.getBay());     // 目标库位列 | 
|---|
|  |  |  | command.setDestinationPosZ(param.getLev());     // 目标库位层 | 
|---|
|  |  |  | boolean locSts = isLocSts(param.getRow().toString(), param.getBay().toString(), param.getLev().toString()); | 
|---|
|  |  |  | command.setTraySize(locSts); | 
|---|
|  |  |  | return crnControl(command)?R.ok():R.error(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | command.setDestinationPosX(param.getRow());     // 目标库位排 | 
|---|
|  |  |  | command.setDestinationPosY(param.getBay());     // 目标库位列 | 
|---|
|  |  |  | command.setDestinationPosZ(param.getLev());     // 目标库位层 | 
|---|
|  |  |  | boolean locSts = isLocSts(param.getSourceRow().toString(), param.getSourceBay().toString(), param.getSourceLev().toString()); | 
|---|
|  |  |  | command.setTraySize(locSts); | 
|---|
|  |  |  | return crnControl(command)?R.ok():R.error(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | .eq("bay1", command.getSourcePosY()).eq("lev1", command.getSourcePosZ())); | 
|---|
|  |  |  | LocMast loc = locMastService.selectOne(new EntityWrapper<LocMast>().eq("row1", command.getDestinationPosX()) | 
|---|
|  |  |  | .eq("bay1", command.getDestinationPosY()).eq("lev1", command.getDestinationPosZ())); | 
|---|
|  |  |  | VersionUtils.locMoveCheckLocType(sourceLoc, loc); | 
|---|
|  |  |  | if (sourceLoc.getLocType1() != loc.getLocType1()){ | 
|---|
|  |  |  | return R.error("库位类型不一致"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | command.setTraySize(loc.getLocType1() == 2); | 
|---|
|  |  |  | //        VersionUtils.locMoveCheckLocType(sourceLoc, loc); | 
|---|
|  |  |  | return crnControl(command)?R.ok():R.error(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | command.setCrnNo(param.getCrnNo()); // 堆垛机编号 | 
|---|
|  |  |  | command.setTaskNo((short) 0); // 工作号 | 
|---|
|  |  |  | command.setAckFinish((short) 0);  // 任务完成确认位 | 
|---|
|  |  |  | command.setTaskMode(CrnTaskModeType.SITE_MOVE); // 任务模式 | 
|---|
|  |  |  | command.setTaskMode(CrnTaskModeType.LOC_MOVE); // 任务模式 | 
|---|
|  |  |  | command.setSourcePosX(param.getSourceStaNo());     // 源库位排 | 
|---|
|  |  |  | command.setSourcePosY((short) 0);     // 源库位列 | 
|---|
|  |  |  | command.setSourcePosZ((short) 1);     // 源库位层 | 
|---|
|  |  |  | 
|---|
|  |  |  | return crnControl(command)?R.ok():R.error(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //    @ManagerAuth(memo = "暂停") | 
|---|
|  |  |  | //    @PostMapping("/operator/pause") | 
|---|
|  |  |  | //    public R crnPause(CrnOperatorParam param){ | 
|---|
|  |  |  | 
|---|
|  |  |  | if (param.getCrnNo() == null) { | 
|---|
|  |  |  | throw new CoolException("请选择堆垛机"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | MessageQueue.clear(SlaveType.Crn, param.getCrnNo()); | 
|---|
|  |  |  | return R.ok("清除命令成功"); | 
|---|
|  |  |  | CrnCommand command = new CrnCommand(); | 
|---|
|  |  |  | command.setCrnNo(param.getCrnNo()); // 堆垛机编号 | 
|---|
|  |  |  | command.setTaskNo((short) 0); // 工作号 | 
|---|
|  |  |  | command.setAckFinish((short) 0);  // 任务完成确认位 | 
|---|
|  |  |  | command.setTaskMode(CrnTaskModeType.NONE); // 任务模式 | 
|---|
|  |  |  | command.setSourcePosX((short) 0);     // 源库位排 | 
|---|
|  |  |  | command.setSourcePosY((short) 0);     // 源库位列 | 
|---|
|  |  |  | command.setSourcePosZ((short) 0);     // 源库位层 | 
|---|
|  |  |  | command.setDestinationPosX((short) 0);     // 目标库位排 | 
|---|
|  |  |  | command.setDestinationPosY((short) 0);     // 目标库位列 | 
|---|
|  |  |  | command.setDestinationPosZ((short) 0);     // 目标库位层 | 
|---|
|  |  |  | return crnControl(command)?R.ok():R.error(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @ManagerAuth(memo = "手动复位") | 
|---|
|  |  |  | 
|---|
|  |  |  | crnCommand.setCrnNo(crn.getId()); // 堆垛机编号 | 
|---|
|  |  |  | crnCommand.setTaskMode(CrnTaskModeType.CLEAR); | 
|---|
|  |  |  | crnCommand.setAckFinish((short) 0);  // 任务完成确认位 | 
|---|
|  |  |  | crnCommand.setCommand((short) 0);  // 任务完成确认位 | 
|---|
|  |  |  | // 延时发送 | 
|---|
|  |  |  | Thread.sleep(1000L); | 
|---|
|  |  |  | if (MessageQueue.offer(SlaveType.Crn, crn.getId(), new Task(2, crnCommand))) { | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private boolean isLocSts(String row,String bay,String lev){ | 
|---|
|  |  |  | String loc = String.format("%2d",row)+String.format("%3d",bay)+String.format("%2d",lev); | 
|---|
|  |  |  | LocMast locMast = locMastService.selectOne(new EntityWrapper<LocMast>().eq("loc_no", loc)); | 
|---|
|  |  |  | if (Cools.isEmpty(locMast)){ | 
|---|
|  |  |  | return false; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (locMast.getLocType1() == 2){ | 
|---|
|  |  |  | return true; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return false; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|