|  |  |  | 
|---|
|  |  |  | import com.zy.asrs.entity.*; | 
|---|
|  |  |  | import com.zy.asrs.mapper.BasCrnErrorMapper; | 
|---|
|  |  |  | import com.zy.asrs.service.BasCrnpService; | 
|---|
|  |  |  | import com.zy.asrs.service.LocMastService; | 
|---|
|  |  |  | import com.zy.asrs.service.WrkMastService; | 
|---|
|  |  |  | import com.zy.asrs.service.impl.MainServiceImpl; | 
|---|
|  |  |  | import com.zy.asrs.service.TaskWrkService; | 
|---|
|  |  |  | import com.zy.asrs.utils.CommandUtils; | 
|---|
|  |  |  | import com.zy.asrs.utils.VersionUtils; | 
|---|
|  |  |  | import com.zy.asrs.utils.CrnOperaUtils; | 
|---|
|  |  |  | import com.zy.core.CrnThread; | 
|---|
|  |  |  | import com.zy.core.cache.MessageQueue; | 
|---|
|  |  |  | import com.zy.core.cache.OutputQueue; | 
|---|
|  |  |  | 
|---|
|  |  |  | import com.zy.core.properties.SystemProperties; | 
|---|
|  |  |  | import lombok.extern.slf4j.Slf4j; | 
|---|
|  |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
|---|
|  |  |  | import org.springframework.beans.factory.annotation.Value; | 
|---|
|  |  |  | import org.springframework.web.bind.annotation.*; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import java.io.IOException; | 
|---|
|  |  |  | import java.util.ArrayList; | 
|---|
|  |  |  | import java.util.HashMap; | 
|---|
|  |  |  | import java.util.List; | 
|---|
|  |  |  | 
|---|
|  |  |  | @RestController | 
|---|
|  |  |  | public class CrnController { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Value("${wms.url}") | 
|---|
|  |  |  | private String wmsUrl; | 
|---|
|  |  |  | @Value("${wms.movePath}") | 
|---|
|  |  |  | private String movePath; | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private SlaveProperties slaveProperties; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private WrkMastService wrkMastService; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private BasCrnErrorMapper basCrnErrorMapper; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private BasCrnpService basCrnpService; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private MainServiceImpl mainService; | 
|---|
|  |  |  | private CrnOperaUtils crnOperaUtils; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private LocMastService locMastService; | 
|---|
|  |  |  | private TaskWrkService taskWrkService; | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @ManagerAuth(memo = "进行中的命令") | 
|---|
|  |  |  | 
|---|
|  |  |  | vo.setLiftPos(crnProtocol.getLiftPosType().desc); | 
|---|
|  |  |  | vo.setWalkPos(crnProtocol.getWalkPos()==1?"不在定位":"在定位"); | 
|---|
|  |  |  | vo.setWarnCode(String.valueOf(crnProtocol.getAlarm1())); | 
|---|
|  |  |  | if (crnProtocol.getAlarm1() > 0) { | 
|---|
|  |  |  | BasCrnError crnError = basCrnErrorMapper.selectById(crnProtocol.getAlarm1()); | 
|---|
|  |  |  | if (crnProtocol.getAlarm() > 0) { | 
|---|
|  |  |  | BasCrnError crnError = basCrnErrorMapper.selectById(crnProtocol.getAlarm()); | 
|---|
|  |  |  | vo.setAlarm(crnError==null?"未知异常":crnError.getErrName()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | vo.setWorkNo(crnProtocol.getTaskNo());  //  任务号 | 
|---|
|  |  |  | if (crnProtocol.getTaskNo()>0) { | 
|---|
|  |  |  | WrkMast wrkMast = wrkMastService.selectById(crnProtocol.getTaskNo()); | 
|---|
|  |  |  | if (wrkMast != null) { | 
|---|
|  |  |  | vo.setStatus(CrnStatusType.process(wrkMast.getIoType()).getDesc());   //  模式状态 | 
|---|
|  |  |  | vo.setSourceStaNo(wrkMast.getSourceStaNo$());    //  源站 | 
|---|
|  |  |  | vo.setStaNo(wrkMast.getStaNo$());   //  目标站 | 
|---|
|  |  |  | vo.setSourceLocNo(wrkMast.getSourceLocNo());    //  源库位 | 
|---|
|  |  |  | vo.setLocNo(wrkMast.getLocNo());    //  目标库位 | 
|---|
|  |  |  | TaskWrk taskWrk = taskWrkService.selectByWrkNo(crnProtocol.getTaskNo().intValue()); | 
|---|
|  |  |  | if (taskWrk != null) { | 
|---|
|  |  |  | vo.setStatus(CrnStatusType.process(taskWrk.getIoType()).getDesc());   //  模式状态 | 
|---|
|  |  |  | vo.setSourceStaNo(null);    //  源站 | 
|---|
|  |  |  | vo.setStaNo(null);   //  目标站 | 
|---|
|  |  |  | vo.setSourceLocNo(taskWrk.getStartPoint());    //  源库位 | 
|---|
|  |  |  | vo.setLocNo(taskWrk.getTargetPoint());    //  目标库位 | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | vo.setStatus(crnProtocol.modeType.equals(CrnModeType.AUTO)? CrnStatusType.MACHINE_AUTO.getDesc(): CrnStatusType.MACHINE_UN_AUTO.getDesc());   //  模式状态 | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | vo.setWorkNo(crnProtocol.getTaskNo());  //  任务号 | 
|---|
|  |  |  | if (crnProtocol.getTaskNo()>0) { | 
|---|
|  |  |  | WrkMast wrkMast = wrkMastService.selectById(crnProtocol.getTaskNo()); | 
|---|
|  |  |  | if (wrkMast != null) { | 
|---|
|  |  |  | vo.setStatus(CrnStatusType.process(wrkMast.getIoType()).getDesc());   //  模式状态 | 
|---|
|  |  |  | vo.setSourceStaNo(wrkMast.getSourceStaNo$());    //  源站 | 
|---|
|  |  |  | vo.setStaNo(wrkMast.getStaNo$());   //  目标站 | 
|---|
|  |  |  | vo.setSourceLocNo(wrkMast.getSourceLocNo());    //  源库位 | 
|---|
|  |  |  | vo.setLocNo(wrkMast.getLocNo());    //  目标库位 | 
|---|
|  |  |  | TaskWrk taskWrk = taskWrkService.selectByWrkNo(crnProtocol.getTaskNo().intValue()); | 
|---|
|  |  |  | if (taskWrk != null) { | 
|---|
|  |  |  | vo.setStatus(CrnStatusType.process(taskWrk.getIoType()).getDesc());   //  模式状态 | 
|---|
|  |  |  | vo.setSourceStaNo(null);    //  源站 | 
|---|
|  |  |  | vo.setStaNo(null);   //  目标站 | 
|---|
|  |  |  | vo.setSourceLocNo(taskWrk.getStartPoint());    //  源库位 | 
|---|
|  |  |  | vo.setLocNo(taskWrk.getTargetPoint());    //  目标库位 | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | vo.setStatus(crnProtocol.modeType.equals(CrnModeType.AUTO)? CrnStatusType.MACHINE_AUTO.getDesc(): CrnStatusType.MACHINE_UN_AUTO.getDesc());   //  模式状态 | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | vo.setWorkNo(crnProtocol.getTaskNo());  //  任务号 | 
|---|
|  |  |  | if (crnProtocol.getTaskNo()>0) { | 
|---|
|  |  |  | WrkMast wrkMast = wrkMastService.selectById(crnProtocol.getTaskNo()); | 
|---|
|  |  |  | if (wrkMast != null) { | 
|---|
|  |  |  | vo.setDeviceStatus(CrnStatusType.process(wrkMast.getIoType()).getDesc());   //  模式状态 | 
|---|
|  |  |  | vo.setSourceStaNo(wrkMast.getSourceStaNo$());    //  源站 | 
|---|
|  |  |  | vo.setStaNo(wrkMast.getStaNo$());   //  目标站 | 
|---|
|  |  |  | vo.setSourceLocNo(wrkMast.getSourceLocNo());    //  源库位 | 
|---|
|  |  |  | vo.setLocNo(wrkMast.getLocNo());    //  目标库位 | 
|---|
|  |  |  | TaskWrk taskWrk = taskWrkService.selectByWrkNo(crnProtocol.getTaskNo().intValue()); | 
|---|
|  |  |  | if (taskWrk != null) { | 
|---|
|  |  |  | vo.setDeviceStatus(CrnStatusType.process(taskWrk.getIoType()).getDesc());   //  模式状态 | 
|---|
|  |  |  | vo.setSourceStaNo(null);    //  源站 | 
|---|
|  |  |  | vo.setStaNo(null);   //  目标站 | 
|---|
|  |  |  | vo.setSourceLocNo(taskWrk.getStartPoint());    //  源库位 | 
|---|
|  |  |  | vo.setLocNo(taskWrk.getTargetPoint());    //  目标库位 | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | vo.setDeviceStatus(crnProtocol.modeType.equals(CrnModeType.AUTO)? CrnStatusType.MACHINE_AUTO.getDesc(): CrnStatusType.MACHINE_UN_AUTO.getDesc());   //  模式状态 | 
|---|
|  |  |  | 
|---|
|  |  |  | @ManagerAuth(memo = "入库") | 
|---|
|  |  |  | @PostMapping("/crn/operator/put") | 
|---|
|  |  |  | public R crnPut(CrnOperatorParam param){ | 
|---|
|  |  |  | CrnCommand command = new CrnCommand(); | 
|---|
|  |  |  | command.setCrnNo(param.getCrnNo()); // 堆垛机编号 | 
|---|
|  |  |  | command.setTaskNo((short) 0); // 工作号 | 
|---|
|  |  |  | command.setAckFinish((short) 0);  // 任务完成确认位 | 
|---|
|  |  |  | command.setTaskMode(CrnTaskModeType.PAKIN); // 任务模式 | 
|---|
|  |  |  | command.setSourcePosX(param.getSourceRow());     // 源库位排 | 
|---|
|  |  |  | command.setSourcePosY(param.getSourceBay());     // 源库位列 | 
|---|
|  |  |  | command.setSourcePosZ(param.getSourceLev());     // 源库位层 | 
|---|
|  |  |  | command.setDestinationPosX(param.getRow());     // 目标库位排 | 
|---|
|  |  |  | command.setDestinationPosY(param.getBay());     // 目标库位列 | 
|---|
|  |  |  | command.setDestinationPosZ(param.getLev());     // 目标库位层 | 
|---|
|  |  |  | return crnControl(command)?R.ok():R.error(); | 
|---|
|  |  |  | //        // 系统运行状态判断 | 
|---|
|  |  |  | //        if (SystemProperties.WCS_RUNNING_STATUS.get()) { | 
|---|
|  |  |  | //            return R.error("wcs系统状态为开启"); | 
|---|
|  |  |  | //        } | 
|---|
|  |  |  | //        command.setCommand((short)1); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | boolean result = crnOperaUtils.crnPut(param); | 
|---|
|  |  |  | return result ? R.ok() : R.error(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @ManagerAuth(memo = "出库") | 
|---|
|  |  |  | @PostMapping("/crn/operator/take") | 
|---|
|  |  |  | public R crnTake(CrnOperatorParam param){ | 
|---|
|  |  |  | CrnCommand command = new CrnCommand(); | 
|---|
|  |  |  | command.setCrnNo(param.getCrnNo()); // 堆垛机编号 | 
|---|
|  |  |  | command.setTaskNo((short) 0); // 工作号 | 
|---|
|  |  |  | command.setAckFinish((short) 0);  // 任务完成确认位 | 
|---|
|  |  |  | command.setTaskMode(CrnTaskModeType.PAKOUT); // 任务模式 | 
|---|
|  |  |  | command.setSourcePosX(param.getSourceRow());     // 源库位排 | 
|---|
|  |  |  | command.setSourcePosY(param.getSourceBay());     // 源库位列 | 
|---|
|  |  |  | command.setSourcePosZ(param.getSourceLev());     // 源库位层 | 
|---|
|  |  |  | command.setDestinationPosX(param.getRow());     // 目标库位排 | 
|---|
|  |  |  | command.setDestinationPosY(param.getBay());     // 目标库位列 | 
|---|
|  |  |  | command.setDestinationPosZ(param.getLev());     // 目标库位层 | 
|---|
|  |  |  | return crnControl(command)?R.ok():R.error(); | 
|---|
|  |  |  | // 系统运行状态判断 | 
|---|
|  |  |  | //        if (SystemProperties.WCS_RUNNING_STATUS.get()) { | 
|---|
|  |  |  | //            return R.error("wcs系统状态为开启"); | 
|---|
|  |  |  | //        } | 
|---|
|  |  |  | //        command.setCommand((short)1); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | boolean result = crnOperaUtils.crnTake(param); | 
|---|
|  |  |  | return result ? R.ok() : R.error(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @ManagerAuth(memo = "库位转移") | 
|---|
|  |  |  | @PostMapping("/crn/operator/stockMove") | 
|---|
|  |  |  | public R crnStockMove(CrnOperatorParam param){ | 
|---|
|  |  |  | CrnCommand command = new CrnCommand(); | 
|---|
|  |  |  | command.setCrnNo(param.getCrnNo()); // 堆垛机编号 | 
|---|
|  |  |  | command.setTaskNo((short) 0); // 工作号 | 
|---|
|  |  |  | command.setAckFinish((short) 0);  // 任务完成确认位 | 
|---|
|  |  |  | command.setTaskMode(CrnTaskModeType.LOC_MOVE); // 任务模式 | 
|---|
|  |  |  | command.setSourcePosX(param.getSourceRow());     // 源库位排 | 
|---|
|  |  |  | command.setSourcePosY(param.getSourceBay());     // 源库位列 | 
|---|
|  |  |  | command.setSourcePosZ(param.getSourceLev());     // 源库位层 | 
|---|
|  |  |  | command.setDestinationPosX(param.getRow());     // 目标库位排 | 
|---|
|  |  |  | command.setDestinationPosY(param.getBay());     // 目标库位列 | 
|---|
|  |  |  | command.setDestinationPosZ(param.getLev());     // 目标库位层 | 
|---|
|  |  |  | LocMast sourceLoc = locMastService.selectOne(new EntityWrapper<LocMast>().eq("row1", command.getSourcePosX()) | 
|---|
|  |  |  | .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); | 
|---|
|  |  |  | return crnControl(command)?R.ok():R.error(); | 
|---|
|  |  |  | // 系统运行状态判断 | 
|---|
|  |  |  | //        if (SystemProperties.WCS_RUNNING_STATUS.get()) { | 
|---|
|  |  |  | //            return R.error("wcs系统状态为开启"); | 
|---|
|  |  |  | //        } | 
|---|
|  |  |  | //        command.setCommand((short)1); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | boolean result = crnOperaUtils.crnStockMove(param); | 
|---|
|  |  |  | return result ? R.ok() : R.error(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @ManagerAuth(memo = "站到站") | 
|---|
|  |  |  | @PostMapping("/crn/operator/siteMove") | 
|---|
|  |  |  | public R crnSiteMove(CrnOperatorParam param){ | 
|---|
|  |  |  | CrnCommand command = new CrnCommand(); | 
|---|
|  |  |  | command.setCrnNo(param.getCrnNo()); // 堆垛机编号 | 
|---|
|  |  |  | command.setTaskNo((short) 0); // 工作号 | 
|---|
|  |  |  | command.setAckFinish((short) 0);  // 任务完成确认位 | 
|---|
|  |  |  | command.setTaskMode(CrnTaskModeType.LOC_MOVE); // 任务模式 | 
|---|
|  |  |  | command.setSourcePosX(param.getSourceStaNo());     // 源库位排 | 
|---|
|  |  |  | command.setSourcePosY((short) 0);     // 源库位列 | 
|---|
|  |  |  | command.setSourcePosZ((short) 1);     // 源库位层 | 
|---|
|  |  |  | command.setDestinationPosX(param.getStaNo());     // 目标库位排 | 
|---|
|  |  |  | command.setDestinationPosY((short) 0);     // 目标库位列 | 
|---|
|  |  |  | command.setDestinationPosZ((short) 1);     // 目标库位层 | 
|---|
|  |  |  | return crnControl(command)?R.ok():R.error(); | 
|---|
|  |  |  | // 系统运行状态判断 | 
|---|
|  |  |  | //        if (SystemProperties.WCS_RUNNING_STATUS.get()) { | 
|---|
|  |  |  | //            return R.error("wcs系统状态为开启"); | 
|---|
|  |  |  | //        } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | boolean result = crnOperaUtils.crnSiteMove(param); | 
|---|
|  |  |  | return result ? R.ok() : R.error(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @ManagerAuth(memo = "回原点") | 
|---|
|  |  |  | @PostMapping("/crn/operator/bacOrigin") | 
|---|
|  |  |  | public R crnBacOrigin(CrnOperatorParam param){ | 
|---|
|  |  |  | CrnCommand command = new CrnCommand(); | 
|---|
|  |  |  | command.setCrnNo(param.getCrnNo()); // 堆垛机编号 | 
|---|
|  |  |  | command.setTaskNo((short) 0); // 工作号 | 
|---|
|  |  |  | command.setAckFinish((short) 0);  // 任务完成确认位 | 
|---|
|  |  |  | command.setTaskMode(CrnTaskModeType.GO_ORIGIN); // 任务模式 | 
|---|
|  |  |  | 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(); | 
|---|
|  |  |  | // 系统运行状态判断 | 
|---|
|  |  |  | //        if (SystemProperties.WCS_RUNNING_STATUS.get()) { | 
|---|
|  |  |  | //            return R.error("wcs系统状态为开启"); | 
|---|
|  |  |  | //        } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | boolean result = crnOperaUtils.crnBacOrigin(param); | 
|---|
|  |  |  | return result ? R.ok() : R.error(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @ManagerAuth(memo = "反原点") | 
|---|
|  |  |  | @PostMapping("/crn/operator/reverseOrigin") | 
|---|
|  |  |  | public R reverseOrigin(CrnOperatorParam param){ | 
|---|
|  |  |  | CrnCommand command = new CrnCommand(); | 
|---|
|  |  |  | command.setCrnNo(param.getCrnNo()); // 堆垛机编号 | 
|---|
|  |  |  | command.setTaskNo((short) 0); // 工作号 | 
|---|
|  |  |  | command.setAckFinish((short) 0);  // 任务完成确认位 | 
|---|
|  |  |  | command.setTaskMode(CrnTaskModeType.GO_ORIGIN); // 任务模式 | 
|---|
|  |  |  | command.setSourcePosX((short) 0);     // 源库位排 | 
|---|
|  |  |  | command.setSourcePosY((short) 0);     // 源库位列 | 
|---|
|  |  |  | command.setSourcePosZ((short) 0);     // 源库位层 | 
|---|
|  |  |  | command.setDestinationPosX((short) 0);     // 目标库位排 | 
|---|
|  |  |  | command.setDestinationPosY((short) 34);     // 目标库位列 | 
|---|
|  |  |  | command.setDestinationPosZ((short) 5);     // 目标库位层 | 
|---|
|  |  |  | return crnControl(command)?R.ok():R.error(); | 
|---|
|  |  |  | // 系统运行状态判断 | 
|---|
|  |  |  | //        if (SystemProperties.WCS_RUNNING_STATUS.get()) { | 
|---|
|  |  |  | //            return R.error("wcs系统状态为开启"); | 
|---|
|  |  |  | //        } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | boolean result = crnOperaUtils.reverseOrigin(param); | 
|---|
|  |  |  | return result ? R.ok() : R.error(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //    @ManagerAuth(memo = "坐标移动") | 
|---|
|  |  |  | 
|---|
|  |  |  | @ManagerAuth(memo = "任务完成") | 
|---|
|  |  |  | @PostMapping("/crn/operator/taskComplete") | 
|---|
|  |  |  | public R crnTaskComplete(CrnOperatorParam param){ | 
|---|
|  |  |  | CrnCommand command = new CrnCommand(); | 
|---|
|  |  |  | command.setCrnNo(param.getCrnNo()); // 堆垛机编号 | 
|---|
|  |  |  | command.setTaskNo((short) 0); // 工作号 | 
|---|
|  |  |  | command.setAckFinish((short) 1);  // 任务完成确认位 | 
|---|
|  |  |  | 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(); | 
|---|
|  |  |  | // 系统运行状态判断 | 
|---|
|  |  |  | //        if (SystemProperties.WCS_RUNNING_STATUS.get()) { | 
|---|
|  |  |  | //            return R.error("wcs系统状态为开启"); | 
|---|
|  |  |  | //        } | 
|---|
|  |  |  | boolean result = crnOperaUtils.crnTaskComplete(param.getCrnNo()); | 
|---|
|  |  |  | return result ? R.ok() : R.error(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //    @ManagerAuth(memo = "暂停") | 
|---|
|  |  |  | 
|---|
|  |  |  | @ManagerAuth(memo = "清除命令") | 
|---|
|  |  |  | @PostMapping("/crn/operator/clearCommand") | 
|---|
|  |  |  | public R crnClearCommand(CrnOperatorParam param){ | 
|---|
|  |  |  | // 系统运行状态判断 | 
|---|
|  |  |  | //        if (SystemProperties.WCS_RUNNING_STATUS.get()) { | 
|---|
|  |  |  | //            return R.error("wcs系统状态为开启"); | 
|---|
|  |  |  | //        } | 
|---|
|  |  |  | if (param.getCrnNo() == null) { | 
|---|
|  |  |  | throw new CoolException("请选择堆垛机"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 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(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | boolean result = crnOperaUtils.crnClearCommand(param); | 
|---|
|  |  |  | return result ? R.ok() : R.error(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @ManagerAuth(memo = "手动复位") | 
|---|
|  |  |  | @PostMapping("/crn/operator/handleReset") | 
|---|
|  |  |  | public R handleReset(CrnOperatorParam param) throws Exception { | 
|---|
|  |  |  | // 系统运行状态判断 | 
|---|
|  |  |  | //        if (SystemProperties.WCS_RUNNING_STATUS.get()) { | 
|---|
|  |  |  | //            return R.error("wcs系统状态为开启"); | 
|---|
|  |  |  | //        } | 
|---|
|  |  |  | if (param.getCrnNo() == null) { | 
|---|
|  |  |  | throw new CoolException("请选择堆垛机"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | crnCommand.setCommand((short) 0);  // 任务完成确认位 | 
|---|
|  |  |  | // 延时发送 | 
|---|
|  |  |  | Thread.sleep(1000L); | 
|---|
|  |  |  | if (CommandUtils.offer(SlaveType.Crn, crn.getId(), new Task(2, crnCommand), false)) { | 
|---|
|  |  |  | if (CommandUtils.offer(SlaveType.Crn, crn.getId(), new Task(5, crnCommand), false)) { | 
|---|
|  |  |  | return R.ok(); | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | throw new CoolException("命令下发失败"); | 
|---|
|  |  |  | 
|---|
|  |  |  | @ManagerAuth(memo = "切换联机模式") | 
|---|
|  |  |  | @PostMapping("/crn/operator/auto") | 
|---|
|  |  |  | public R crnAuto(CrnOperatorParam param){ | 
|---|
|  |  |  | // 系统运行状态判断 | 
|---|
|  |  |  | //        if (SystemProperties.WCS_RUNNING_STATUS.get()) { | 
|---|
|  |  |  | //            return R.error("wcs系统状态为开启"); | 
|---|
|  |  |  | //        } | 
|---|
|  |  |  | short[] array = new short[9]; | 
|---|
|  |  |  | CrnCommand command = new CrnCommand(); | 
|---|
|  |  |  | command.setCrnNo(param.getCrnNo()); // 堆垛机编号 | 
|---|
|  |  |  | 
|---|
|  |  |  | @ManagerAuth(memo = "切换半手动模式") | 
|---|
|  |  |  | @PostMapping("/crn/operator/semiAutomatic") | 
|---|
|  |  |  | public R crnsemiAutomatic(CrnOperatorParam param){ | 
|---|
|  |  |  | // 系统运行状态判断 | 
|---|
|  |  |  | //        if (SystemProperties.WCS_RUNNING_STATUS.get()) { | 
|---|
|  |  |  | //            return R.error("wcs系统状态为开启"); | 
|---|
|  |  |  | //        } | 
|---|
|  |  |  | short[] array = new short[9]; | 
|---|
|  |  |  | CrnCommand command = new CrnCommand(); | 
|---|
|  |  |  | command.setCrnNo(param.getCrnNo()); // 堆垛机编号 | 
|---|
|  |  |  | 
|---|
|  |  |  | @ManagerAuth(memo = "切换手动模式") | 
|---|
|  |  |  | @PostMapping("/crn/operator/hand") | 
|---|
|  |  |  | public R onlineWrk1(CrnOperatorParam param){ | 
|---|
|  |  |  | // 系统运行状态判断 | 
|---|
|  |  |  | //        if (SystemProperties.WCS_RUNNING_STATUS.get()) { | 
|---|
|  |  |  | //            return R.error("wcs系统状态为开启"); | 
|---|
|  |  |  | //        } | 
|---|
|  |  |  | short[] array = new short[9]; | 
|---|
|  |  |  | CrnCommand command = new CrnCommand(); | 
|---|
|  |  |  | command.setCrnNo(param.getCrnNo()); // 堆垛机编号 | 
|---|
|  |  |  | 
|---|
|  |  |  | @ManagerAuth(memo = "申请完成任务") | 
|---|
|  |  |  | @PostMapping("/crn/operator/onlineWrk1") | 
|---|
|  |  |  | public R onlineWrk2(CrnOperatorParam param){ | 
|---|
|  |  |  | // 系统运行状态判断 | 
|---|
|  |  |  | //        if (SystemProperties.WCS_RUNNING_STATUS.get()) { | 
|---|
|  |  |  | //            return R.error("wcs系统状态为开启"); | 
|---|
|  |  |  | //        } | 
|---|
|  |  |  | short[] array = new short[9]; | 
|---|
|  |  |  | CrnCommand command = new CrnCommand(); | 
|---|
|  |  |  | command.setCrnNo(param.getCrnNo()); // 堆垛机编号 | 
|---|
|  |  |  | 
|---|
|  |  |  | @ManagerAuth(memo = "申请取消任务") | 
|---|
|  |  |  | @PostMapping("/crn/operator/onlineWrk2") | 
|---|
|  |  |  | public R onlineWrk3(CrnOperatorParam param){ | 
|---|
|  |  |  | // 系统运行状态判断 | 
|---|
|  |  |  | //        if (SystemProperties.WCS_RUNNING_STATUS.get()) { | 
|---|
|  |  |  | //            return R.error("wcs系统状态为开启"); | 
|---|
|  |  |  | //        } | 
|---|
|  |  |  | short[] array = new short[9]; | 
|---|
|  |  |  | CrnCommand command = new CrnCommand(); | 
|---|
|  |  |  | command.setCrnNo(param.getCrnNo()); // 堆垛机编号 | 
|---|
|  |  |  | 
|---|
|  |  |  | @ManagerAuth(memo = "清除联机任务") | 
|---|
|  |  |  | @PostMapping("/crn/operator/onlineWrk3") | 
|---|
|  |  |  | public R onlineWrk4(CrnOperatorParam param){ | 
|---|
|  |  |  | // 系统运行状态判断 | 
|---|
|  |  |  | //        if (SystemProperties.WCS_RUNNING_STATUS.get()) { | 
|---|
|  |  |  | //            return R.error("wcs系统状态为开启"); | 
|---|
|  |  |  | //        } | 
|---|
|  |  |  | short[] array = new short[9]; | 
|---|
|  |  |  | CrnCommand command = new CrnCommand(); | 
|---|
|  |  |  | command.setCrnNo(param.getCrnNo()); // 堆垛机编号 | 
|---|
|  |  |  | 
|---|
|  |  |  | @ManagerAuth(memo = "恢复联机任务") | 
|---|
|  |  |  | @PostMapping("/crn/operator/onlineWrk4") | 
|---|
|  |  |  | public R crnHand(CrnOperatorParam param){ | 
|---|
|  |  |  | // 系统运行状态判断 | 
|---|
|  |  |  | //        if (SystemProperties.WCS_RUNNING_STATUS.get()) { | 
|---|
|  |  |  | //            return R.error("wcs系统状态为开启"); | 
|---|
|  |  |  | //        } | 
|---|
|  |  |  | short[] array = new short[9]; | 
|---|
|  |  |  | CrnCommand command = new CrnCommand(); | 
|---|
|  |  |  | command.setCrnNo(param.getCrnNo()); // 堆垛机编号 | 
|---|
|  |  |  | 
|---|
|  |  |  | return crnControl2(command)?R.ok():R.error(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @ManagerAuth(memo = "复位") | 
|---|
|  |  |  | @PostMapping("/crn/operator/reset") | 
|---|
|  |  |  | public R crnReset(CrnOperatorParam param){ | 
|---|
|  |  |  | // 系统运行状态判断 | 
|---|
|  |  |  | //        if (SystemProperties.WCS_RUNNING_STATUS.get()) { | 
|---|
|  |  |  | //            return R.error("wcs系统状态为开启"); | 
|---|
|  |  |  | //        } | 
|---|
|  |  |  | short[] array = new short[9]; | 
|---|
|  |  |  | CrnCommand command = new CrnCommand(); | 
|---|
|  |  |  | command.setCrnNo(param.getCrnNo()); // 堆垛机编号 | 
|---|
|  |  |  | command.setTaskNo((short) 0); // 工作号 | 
|---|
|  |  |  | command.setReset((short)1); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return crnControl2(command)?R.ok():R.error(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private boolean crnControl2(CrnCommand command){ | 
|---|