|  |  |  | 
|---|
|  |  |  | package com.zy.asrs.controller; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import com.alibaba.excel.EasyExcel; | 
|---|
|  |  |  | import com.alibaba.fastjson.JSON; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.mapper.EntityWrapper; | 
|---|
|  |  |  | import com.core.annotations.ManagerAuth; | 
|---|
|  |  |  | 
|---|
|  |  |  | import com.zy.asrs.domain.vo.CrnMsgTableVo; | 
|---|
|  |  |  | import com.zy.asrs.domain.vo.CrnStateTableVo; | 
|---|
|  |  |  | import com.zy.asrs.entity.*; | 
|---|
|  |  |  | import com.zy.asrs.importexcle.ImportCrnErrDto; | 
|---|
|  |  |  | import com.zy.asrs.importexcle.ImportCrnErrListener; | 
|---|
|  |  |  | import com.zy.asrs.mapper.BasCrnErrorMapper; | 
|---|
|  |  |  | import com.zy.asrs.mapper.TaskWrkMapper; | 
|---|
|  |  |  | import com.zy.asrs.service.BasCrnErrorService; | 
|---|
|  |  |  | 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.utils.CommandUtils; | 
|---|
|  |  |  | import com.zy.asrs.utils.VersionUtils; | 
|---|
|  |  |  | import com.zy.core.CrnThread; | 
|---|
|  |  |  | import com.zy.core.cache.MessageQueue; | 
|---|
|  |  |  | 
|---|
|  |  |  | 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.transaction.annotation.Transactional; | 
|---|
|  |  |  | import org.springframework.web.bind.annotation.*; | 
|---|
|  |  |  | import org.springframework.web.multipart.MultipartFile; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import javax.annotation.Resource; | 
|---|
|  |  |  | import java.io.IOException; | 
|---|
|  |  |  | import java.util.ArrayList; | 
|---|
|  |  |  | import java.util.HashMap; | 
|---|
|  |  |  | 
|---|
|  |  |  | @RestController | 
|---|
|  |  |  | public class CrnController { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Value("${wms.url}") | 
|---|
|  |  |  | private String wmsUrl; | 
|---|
|  |  |  | @Value("${wms.movePath}") | 
|---|
|  |  |  | private String movePath; | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private SlaveProperties slaveProperties; | 
|---|
|  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private BasCrnpService basCrnpService; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private MainServiceImpl mainService; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private LocMastService locMastService; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Resource | 
|---|
|  |  |  | private TaskWrkMapper taskWrkMapper; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Resource | 
|---|
|  |  |  | private BasCrnErrorService basCrnErrorService; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @PostMapping("/importCrnErr") | 
|---|
|  |  |  | @ManagerAuth(memo = "导入堆垛机异常表") | 
|---|
|  |  |  | public R importCrnErr(@RequestParam("file") MultipartFile multipartFile) { | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | importCrnErrExec(multipartFile); | 
|---|
|  |  |  | } catch (Exception e) { | 
|---|
|  |  |  | e.printStackTrace(); | 
|---|
|  |  |  | return R.error(e.getMessage()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return R.ok("导入成功"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Transactional(rollbackFor = Exception.class) | 
|---|
|  |  |  | public void importCrnErrExec(MultipartFile multipartFile) throws IOException { | 
|---|
|  |  |  | EasyExcel.read(multipartFile.getInputStream(), ImportCrnErrDto.class, | 
|---|
|  |  |  | new ImportCrnErrListener(basCrnErrorService)).sheet().doReadSync(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @ManagerAuth(memo = "进行中的命令") | 
|---|
|  |  |  | @PostMapping("/crn/command/ongoing") | 
|---|
|  |  |  | public R ongoingCommand(){ | 
|---|
|  |  |  | public R ongoingCommand() { | 
|---|
|  |  |  | List<CommandLogVo> list = new ArrayList<>(); | 
|---|
|  |  |  | for (CrnSlave crn : slaveProperties.getCrn()) { | 
|---|
|  |  |  | CommandLogVo vo = new CommandLogVo(); | 
|---|
|  |  |  | 
|---|
|  |  |  | vo.setStatus(1);    //  状态 | 
|---|
|  |  |  | Task task = MessageQueue.peek(SlaveType.Crn, crn.getId()); | 
|---|
|  |  |  | if (task != null) { | 
|---|
|  |  |  | vo.setCommand(JSON.toJSONString((CrnCommand)task.getData())); | 
|---|
|  |  |  | vo.setCommand(JSON.toJSONString((CrnCommand) task.getData())); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return R.ok().add(list); | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @PostMapping("/crn/table/crn/state") | 
|---|
|  |  |  | @ManagerAuth(memo = "堆垛机信息表") | 
|---|
|  |  |  | public R crnStateTable(){ | 
|---|
|  |  |  | public R crnStateTable() { | 
|---|
|  |  |  | List<CrnStateTableVo> list = new ArrayList<>(); | 
|---|
|  |  |  | List<BasCrnp> crnps = basCrnpService.selectList(new EntityWrapper<BasCrnp>().orderBy("crn_no")); | 
|---|
|  |  |  | for (BasCrnp basCrnp : crnps) { | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | vo.setForkOffset(crnProtocol.getForkPosType().desc);    // 货叉位置 | 
|---|
|  |  |  | vo.setLiftPos(crnProtocol.getLiftPosType().desc); | 
|---|
|  |  |  | vo.setWalkPos(crnProtocol.getWalkPos()==1?"不在定位":"在定位"); | 
|---|
|  |  |  | vo.setWalkPos(crnProtocol.getWalkPos() == 1 ? "不在定位" : "在定位"); | 
|---|
|  |  |  | vo.setWarnCode(String.valueOf(crnProtocol.getAlarm1())); | 
|---|
|  |  |  | if (crnProtocol.getAlarm() > 0) { | 
|---|
|  |  |  | BasCrnError crnError = basCrnErrorMapper.selectById(crnProtocol.getAlarm()); | 
|---|
|  |  |  | vo.setAlarm(crnError==null?"未知异常":crnError.getErrName()); | 
|---|
|  |  |  | vo.setAlarm(crnError == null ? "未知异常" : crnError.getErrName()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return R.ok().add(list); | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @PostMapping("/crn/table/crn/{id}/state") | 
|---|
|  |  |  | @ManagerAuth(memo = "堆垛机信息表") | 
|---|
|  |  |  | public R crnStateTable(@PathVariable("id") Integer id){ | 
|---|
|  |  |  | public R crnStateTable(@PathVariable("id") Integer id) { | 
|---|
|  |  |  | BasCrnp basCrnp = basCrnpService.selectOne(new EntityWrapper<BasCrnp>().eq("crn_no", id).orderBy("crn_no")); | 
|---|
|  |  |  | // 表格行 | 
|---|
|  |  |  | CrnStateTableVo vo = new CrnStateTableVo(); | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | vo.setForkOffset(crnProtocol.getForkPosType().desc);    // 货叉位置 | 
|---|
|  |  |  | vo.setLiftPos(crnProtocol.getLiftPosType().desc); | 
|---|
|  |  |  | vo.setWalkPos(crnProtocol.getWalkPos()==1?"不在定位":"在定位"); | 
|---|
|  |  |  | vo.setWalkPos(crnProtocol.getWalkPos() == 1 ? "不在定位" : "在定位"); | 
|---|
|  |  |  | vo.setWarnCode(String.valueOf(crnProtocol.getAlarm1())); | 
|---|
|  |  |  | if (crnProtocol.getAlarm1() > 0) { | 
|---|
|  |  |  | BasCrnError crnError = basCrnErrorMapper.selectById(crnProtocol.getAlarm1()); | 
|---|
|  |  |  | vo.setAlarm(crnError==null?"未知异常":crnError.getErrName()); | 
|---|
|  |  |  | vo.setAlarm(crnError == null ? "未知异常" : crnError.getErrName()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return R.ok().add(vo); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @PostMapping("/crn/table/crn/msg") | 
|---|
|  |  |  | @ManagerAuth(memo = "堆垛机数据表") | 
|---|
|  |  |  | public R crnMsgTable(){ | 
|---|
|  |  |  | public R crnMsgTable() { | 
|---|
|  |  |  | List<CrnMsgTableVo> list = new ArrayList<>(); | 
|---|
|  |  |  | List<BasCrnp> crnps = basCrnpService.selectList(new EntityWrapper<BasCrnp>().orderBy("crn_no")); | 
|---|
|  |  |  | for (BasCrnp basCrnp : crnps) { | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 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());    //  目标库位 | 
|---|
|  |  |  | if (crnProtocol.getTaskNo() > 0) { | 
|---|
|  |  |  | //                WrkMast wrkMast = wrkMastService.selectById(crnProtocol.getTaskNo()); | 
|---|
|  |  |  | TaskWrk taskWrk = taskWrkMapper.selectByWrkNo(Integer.valueOf(crnProtocol.getTaskNo())); | 
|---|
|  |  |  | if (taskWrk != null) { | 
|---|
|  |  |  | vo.setStatus(CrnStatusType.process(taskWrk.getIoType()).getDesc());   //  模式状态 | 
|---|
|  |  |  | vo.setSourceStaNo(taskWrk.getStartPoint());    //  源站 | 
|---|
|  |  |  | vo.setStaNo(taskWrk.getTargetPoint());   //  目标站 | 
|---|
|  |  |  | 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.setStatus(crnProtocol.modeType.equals(CrnModeType.AUTO) ? CrnStatusType.MACHINE_AUTO.getDesc() : CrnStatusType.MACHINE_UN_AUTO.getDesc());   //  模式状态 | 
|---|
|  |  |  | } | 
|---|
|  |  |  | vo.setXspeed(crnProtocol.getXSpeed());  //  走行速度(m/min) | 
|---|
|  |  |  | vo.setYspeed(crnProtocol.getYSpeed());  //  升降速度(m/min) | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @PostMapping("/crn/table/crn/{id}/msg") | 
|---|
|  |  |  | @ManagerAuth(memo = "堆垛机数据表") | 
|---|
|  |  |  | public R crnMsgTable(@PathVariable("id") Integer id){ | 
|---|
|  |  |  | public R crnMsgTable(@PathVariable("id") Integer id) { | 
|---|
|  |  |  | BasCrnp basCrnp = basCrnpService.selectOne(new EntityWrapper<BasCrnp>().eq("crn_no", id).orderBy("crn_no")); | 
|---|
|  |  |  | // 表格行 | 
|---|
|  |  |  | CrnMsgTableVo vo = new CrnMsgTableVo(); | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | vo.setWorkNo(crnProtocol.getTaskNo());  //  任务号 | 
|---|
|  |  |  | if (crnProtocol.getTaskNo()>0) { | 
|---|
|  |  |  | if (crnProtocol.getTaskNo() > 0) { | 
|---|
|  |  |  | WrkMast wrkMast = wrkMastService.selectById(crnProtocol.getTaskNo()); | 
|---|
|  |  |  | if (wrkMast != null) { | 
|---|
|  |  |  | vo.setStatus(CrnStatusType.process(wrkMast.getIoType()).getDesc());   //  模式状态 | 
|---|
|  |  |  | 
|---|
|  |  |  | vo.setLocNo(wrkMast.getLocNo());    //  目标库位 | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | vo.setStatus(crnProtocol.modeType.equals(CrnModeType.AUTO)? CrnStatusType.MACHINE_AUTO.getDesc(): CrnStatusType.MACHINE_UN_AUTO.getDesc());   //  模式状态 | 
|---|
|  |  |  | vo.setStatus(crnProtocol.modeType.equals(CrnModeType.AUTO) ? CrnStatusType.MACHINE_AUTO.getDesc() : CrnStatusType.MACHINE_UN_AUTO.getDesc());   //  模式状态 | 
|---|
|  |  |  | } | 
|---|
|  |  |  | vo.setXspeed(crnProtocol.getXSpeed());  //  走行速度(m/min) | 
|---|
|  |  |  | vo.setYspeed(crnProtocol.getYSpeed());  //  升降速度(m/min) | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @GetMapping("/crn/list/auth") | 
|---|
|  |  |  | @ManagerAuth(memo = "堆垛机数据表") | 
|---|
|  |  |  | public R crnList(){ | 
|---|
|  |  |  | public R crnList() { | 
|---|
|  |  |  | List<CrnListVo> list = new ArrayList<>(); | 
|---|
|  |  |  | List<BasCrnp> crnps = basCrnpService.selectList(new EntityWrapper<BasCrnp>().orderBy("crn_no")); | 
|---|
|  |  |  | for (BasCrnp basCrnp : crnps) { | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | vo.setWorkNo(crnProtocol.getTaskNo());  //  任务号 | 
|---|
|  |  |  | if (crnProtocol.getTaskNo()>0) { | 
|---|
|  |  |  | if (crnProtocol.getTaskNo() > 0) { | 
|---|
|  |  |  | WrkMast wrkMast = wrkMastService.selectById(crnProtocol.getTaskNo()); | 
|---|
|  |  |  | if (wrkMast != null) { | 
|---|
|  |  |  | vo.setDeviceStatus(CrnStatusType.process(wrkMast.getIoType()).getDesc());   //  模式状态 | 
|---|
|  |  |  | 
|---|
|  |  |  | vo.setLocNo(wrkMast.getLocNo());    //  目标库位 | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | vo.setDeviceStatus(crnProtocol.modeType.equals(CrnModeType.AUTO)? CrnStatusType.MACHINE_AUTO.getDesc(): CrnStatusType.MACHINE_UN_AUTO.getDesc());   //  模式状态 | 
|---|
|  |  |  | vo.setDeviceStatus(crnProtocol.modeType.equals(CrnModeType.AUTO) ? CrnStatusType.MACHINE_AUTO.getDesc() : CrnStatusType.MACHINE_UN_AUTO.getDesc());   //  模式状态 | 
|---|
|  |  |  | } | 
|---|
|  |  |  | vo.setXspeed(crnProtocol.getXSpeed());  //  走行速度(m/min) | 
|---|
|  |  |  | vo.setYspeed(crnProtocol.getYSpeed());  //  升降速度(m/min) | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | vo.setForkOffset(crnProtocol.getForkPosType().desc);    // 货叉位置 | 
|---|
|  |  |  | vo.setLiftPos(crnProtocol.getLiftPosType().desc); | 
|---|
|  |  |  | vo.setWalkPos(crnProtocol.getWalkPos()==1?"不在定位":"在定位"); | 
|---|
|  |  |  | vo.setWalkPos(crnProtocol.getWalkPos() == 1 ? "不在定位" : "在定位"); | 
|---|
|  |  |  | vo.setWarnCode(String.valueOf(crnProtocol.getAlarm1())); | 
|---|
|  |  |  | if (crnProtocol.getAlarm1() > 0) { | 
|---|
|  |  |  | BasCrnError crnError = basCrnErrorMapper.selectById(crnProtocol.getAlarm1()); | 
|---|
|  |  |  | vo.setAlarm(crnError==null?"未知异常":crnError.getErrName()); | 
|---|
|  |  |  | vo.setAlarm(crnError == null ? "未知异常" : crnError.getErrName()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | vo.setInEnable(basCrnp.getInEnable()); | 
|---|
|  |  |  | vo.setOutEnable(basCrnp.getOutEnable()); | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @PostMapping("/crn/output/site") | 
|---|
|  |  |  | @ManagerAuth(memo = "堆垛机报文日志输出") | 
|---|
|  |  |  | public R crnOutput(){ | 
|---|
|  |  |  | public R crnOutput() { | 
|---|
|  |  |  | StringBuilder str = new StringBuilder(); | 
|---|
|  |  |  | String s; | 
|---|
|  |  |  | int i = 0; | 
|---|
|  |  |  | while((s = OutputQueue.CRN.poll()) != null && i <=10) { | 
|---|
|  |  |  | while ((s = OutputQueue.CRN.poll()) != null && i <= 10) { | 
|---|
|  |  |  | str.append("\n").append(s); | 
|---|
|  |  |  | i++; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @GetMapping("/crn/demo/status") | 
|---|
|  |  |  | public R demoStatus(){ | 
|---|
|  |  |  | public R demoStatus() { | 
|---|
|  |  |  | List<Map<String, Object>> res = new ArrayList<>(); | 
|---|
|  |  |  | for (CrnSlave crnSlave : slaveProperties.getCrn()) { | 
|---|
|  |  |  | Map<String, Object> map = new HashMap<>(); | 
|---|
|  |  |  | 
|---|
|  |  |  | @PostMapping("/crn/demo/switch") | 
|---|
|  |  |  | @ManagerAuth(memo = "堆垛机演示") | 
|---|
|  |  |  | public R crnDemo(CrnDemoParam param) throws InterruptedException { | 
|---|
|  |  |  | if (Cools.isEmpty(param.getCrnId())){ | 
|---|
|  |  |  | if (Cools.isEmpty(param.getCrnId())) { | 
|---|
|  |  |  | return R.error(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (Cools.isEmpty(param.getPassword())){ | 
|---|
|  |  |  | if (Cools.isEmpty(param.getPassword())) { | 
|---|
|  |  |  | return R.error("请输入口令"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (!param.getPassword().equals(SystemProperties.WCS_PASSWORD)){ | 
|---|
|  |  |  | if (!param.getPassword().equals(SystemProperties.WCS_PASSWORD)) { | 
|---|
|  |  |  | return R.error("口令错误"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | Thread.sleep(200L); | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /****************************************************************/ | 
|---|
|  |  |  | /************************** 手动操作 ******************************/ | 
|---|
|  |  |  | /****************************************************************/ | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @ManagerAuth(memo = "入库") | 
|---|
|  |  |  | @PostMapping("/crn/operator/put") | 
|---|
|  |  |  | public R crnPut(CrnOperatorParam param){ | 
|---|
|  |  |  | // 系统运行状态判断 | 
|---|
|  |  |  | if (SystemProperties.WCS_RUNNING_STATUS.get()) { | 
|---|
|  |  |  | return R.error("wcs系统状态为开启"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | public R crnPut(CrnOperatorParam param) { | 
|---|
|  |  |  | //        // 系统运行状态判断 | 
|---|
|  |  |  | //        if (SystemProperties.WCS_RUNNING_STATUS.get()) { | 
|---|
|  |  |  | //            return R.error("wcs系统状态为开启"); | 
|---|
|  |  |  | //        } | 
|---|
|  |  |  | CrnCommand command = new CrnCommand(); | 
|---|
|  |  |  | command.setCrnNo(param.getCrnNo()); // 堆垛机编号 | 
|---|
|  |  |  | command.setTaskNo((short) 0); // 工作号 | 
|---|
|  |  |  | command.setAckFinish((short) 0);  // 任务完成确认位 | 
|---|
|  |  |  | command.setTaskMode(CrnTaskModeType.PAKIN); // 任务模式 | 
|---|
|  |  |  | command.setSourcePosZ(param.getSourceRow());     // 源库位排 | 
|---|
|  |  |  | command.setSourcePosX(param.getSourceBay());     // 源库位列 | 
|---|
|  |  |  | command.setSourcePosY(param.getSourceLev());     // 源库位层 | 
|---|
|  |  |  | command.setDestinationPosZ(param.getRow());     // 目标库位排 | 
|---|
|  |  |  | command.setDestinationPosX(param.getBay());     // 目标库位列 | 
|---|
|  |  |  | command.setDestinationPosY(param.getLev());     // 目标库位层 | 
|---|
|  |  |  | command.setCommand((short)1); | 
|---|
|  |  |  | return crnControl(command)?R.ok():R.error(); | 
|---|
|  |  |  | command.setSourcePosX(param.getSourceRow());     // 源库位排 | 
|---|
|  |  |  | command.setSourcePosY(param.getSourceBay());     // 源库位列 | 
|---|
|  |  |  | command.setSourcePosZ(param.getSourceLev());     // 源库位层 | 
|---|
|  |  |  | command.setDestinationPosX(param.getRow());     // 目标库位排 | 
|---|
|  |  |  | command.setDestinationPosY(param.getBay());     // 目标库位列 | 
|---|
|  |  |  | command.setDestinationPosZ(param.getLev());     // 目标库位层 | 
|---|
|  |  |  | command.setCommand((short) 1); | 
|---|
|  |  |  | return crnControl(command) ? R.ok() : R.error(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @ManagerAuth(memo = "出库") | 
|---|
|  |  |  | @PostMapping("/crn/operator/take") | 
|---|
|  |  |  | public R crnTake(CrnOperatorParam param){ | 
|---|
|  |  |  | public R crnTake(CrnOperatorParam param) { | 
|---|
|  |  |  | // 系统运行状态判断 | 
|---|
|  |  |  | if (SystemProperties.WCS_RUNNING_STATUS.get()) { | 
|---|
|  |  |  | return R.error("wcs系统状态为开启"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //        if (SystemProperties.WCS_RUNNING_STATUS.get()) { | 
|---|
|  |  |  | //            return R.error("wcs系统状态为开启"); | 
|---|
|  |  |  | //        } | 
|---|
|  |  |  | CrnCommand command = new CrnCommand(); | 
|---|
|  |  |  | command.setCrnNo(param.getCrnNo()); // 堆垛机编号 | 
|---|
|  |  |  | command.setTaskNo((short) 0); // 工作号 | 
|---|
|  |  |  | command.setAckFinish((short) 0);  // 任务完成确认位 | 
|---|
|  |  |  | command.setTaskMode(CrnTaskModeType.PAKOUT); // 任务模式 | 
|---|
|  |  |  | command.setSourcePosZ(param.getSourceRow());     // 源库位排 | 
|---|
|  |  |  | command.setSourcePosX(param.getSourceBay());     // 源库位列 | 
|---|
|  |  |  | command.setSourcePosY(param.getSourceLev());     // 源库位层 | 
|---|
|  |  |  | command.setDestinationPosZ(param.getRow());     // 目标库位排 | 
|---|
|  |  |  | command.setDestinationPosX(param.getBay());     // 目标库位列 | 
|---|
|  |  |  | command.setDestinationPosY(param.getLev());     // 目标库位层 | 
|---|
|  |  |  | return crnControl(command)?R.ok():R.error(); | 
|---|
|  |  |  | 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());     // 目标库位层 | 
|---|
|  |  |  | command.setCommand((short) 1); | 
|---|
|  |  |  | return crnControl(command) ? R.ok() : R.error(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @ManagerAuth(memo = "库位转移") | 
|---|
|  |  |  | @PostMapping("/crn/operator/stockMove") | 
|---|
|  |  |  | public R crnStockMove(CrnOperatorParam param){ | 
|---|
|  |  |  | public R crnStockMove(CrnOperatorParam param) { | 
|---|
|  |  |  | // 系统运行状态判断 | 
|---|
|  |  |  | if (SystemProperties.WCS_RUNNING_STATUS.get()) { | 
|---|
|  |  |  | return R.error("wcs系统状态为开启"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //        if (SystemProperties.WCS_RUNNING_STATUS.get()) { | 
|---|
|  |  |  | //            return R.error("wcs系统状态为开启"); | 
|---|
|  |  |  | //        } | 
|---|
|  |  |  | CrnCommand command = new CrnCommand(); | 
|---|
|  |  |  | command.setCrnNo(param.getCrnNo()); // 堆垛机编号 | 
|---|
|  |  |  | command.setTaskNo((short) 0); // 工作号 | 
|---|
|  |  |  | 
|---|
|  |  |  | command.setDestinationPosZ(param.getRow());     // 目标库位排 | 
|---|
|  |  |  | command.setDestinationPosX(param.getBay());     // 目标库位列 | 
|---|
|  |  |  | command.setDestinationPosY(param.getLev());     // 目标库位层 | 
|---|
|  |  |  | command.setCommand((short)1); | 
|---|
|  |  |  | command.setCommand((short) 1); | 
|---|
|  |  |  | 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(); | 
|---|
|  |  |  | return crnControl(command) ? R.ok() : R.error(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @ManagerAuth(memo = "站到站") | 
|---|
|  |  |  | @PostMapping("/crn/operator/siteMove") | 
|---|
|  |  |  | public R crnSiteMove(CrnOperatorParam param){ | 
|---|
|  |  |  | public R crnSiteMove(CrnOperatorParam param) { | 
|---|
|  |  |  | // 系统运行状态判断 | 
|---|
|  |  |  | if (SystemProperties.WCS_RUNNING_STATUS.get()) { | 
|---|
|  |  |  | return R.error("wcs系统状态为开启"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //        if (SystemProperties.WCS_RUNNING_STATUS.get()) { | 
|---|
|  |  |  | //            return R.error("wcs系统状态为开启"); | 
|---|
|  |  |  | //        } | 
|---|
|  |  |  | CrnCommand command = new CrnCommand(); | 
|---|
|  |  |  | command.setCrnNo(param.getCrnNo()); // 堆垛机编号 | 
|---|
|  |  |  | command.setTaskNo((short) 0); // 工作号 | 
|---|
|  |  |  | 
|---|
|  |  |  | command.setDestinationPosX(param.getStaNo());     // 目标库位排 | 
|---|
|  |  |  | command.setDestinationPosY((short) 0);     // 目标库位列 | 
|---|
|  |  |  | command.setDestinationPosZ((short) 1);     // 目标库位层 | 
|---|
|  |  |  | return crnControl(command)?R.ok():R.error(); | 
|---|
|  |  |  | return crnControl(command) ? R.ok() : R.error(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @ManagerAuth(memo = "回原点") | 
|---|
|  |  |  | @PostMapping("/crn/operator/bacOrigin") | 
|---|
|  |  |  | public R crnBacOrigin(CrnOperatorParam param){ | 
|---|
|  |  |  | public R crnBacOrigin(CrnOperatorParam param) { | 
|---|
|  |  |  | // 系统运行状态判断 | 
|---|
|  |  |  | if (SystemProperties.WCS_RUNNING_STATUS.get()) { | 
|---|
|  |  |  | return R.error("wcs系统状态为开启"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //        if (SystemProperties.WCS_RUNNING_STATUS.get()) { | 
|---|
|  |  |  | //            return R.error("wcs系统状态为开启"); | 
|---|
|  |  |  | //        } | 
|---|
|  |  |  | CrnCommand command = new CrnCommand(); | 
|---|
|  |  |  | command.setCrnNo(param.getCrnNo()); // 堆垛机编号 | 
|---|
|  |  |  | command.setTaskNo((short) 0); // 工作号 | 
|---|
|  |  |  | 
|---|
|  |  |  | command.setDestinationPosX((short) 0);     // 目标库位排 | 
|---|
|  |  |  | command.setDestinationPosY((short) 0);     // 目标库位列 | 
|---|
|  |  |  | command.setDestinationPosZ((short) 0);     // 目标库位层 | 
|---|
|  |  |  | return crnControl(command)?R.ok():R.error(); | 
|---|
|  |  |  | return crnControl(command) ? R.ok() : R.error(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @ManagerAuth(memo = "反原点") | 
|---|
|  |  |  | @PostMapping("/crn/operator/reverseOrigin") | 
|---|
|  |  |  | public R reverseOrigin(CrnOperatorParam param){ | 
|---|
|  |  |  | public R reverseOrigin(CrnOperatorParam param) { | 
|---|
|  |  |  | // 系统运行状态判断 | 
|---|
|  |  |  | if (SystemProperties.WCS_RUNNING_STATUS.get()) { | 
|---|
|  |  |  | return R.error("wcs系统状态为开启"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //        if (SystemProperties.WCS_RUNNING_STATUS.get()) { | 
|---|
|  |  |  | //            return R.error("wcs系统状态为开启"); | 
|---|
|  |  |  | //        } | 
|---|
|  |  |  | CrnCommand command = new CrnCommand(); | 
|---|
|  |  |  | command.setCrnNo(param.getCrnNo()); // 堆垛机编号 | 
|---|
|  |  |  | command.setTaskNo((short) 0); // 工作号 | 
|---|
|  |  |  | 
|---|
|  |  |  | command.setDestinationPosX((short) 0);     // 目标库位排 | 
|---|
|  |  |  | command.setDestinationPosY((short) 22);     // 目标库位列 | 
|---|
|  |  |  | command.setDestinationPosZ((short) 1);     // 目标库位层 | 
|---|
|  |  |  | return crnControl(command)?R.ok():R.error(); | 
|---|
|  |  |  | return crnControl(command) ? R.ok() : R.error(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //    @ManagerAuth(memo = "坐标移动") | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @ManagerAuth(memo = "任务完成") | 
|---|
|  |  |  | @PostMapping("/crn/operator/taskComplete") | 
|---|
|  |  |  | public R crnTaskComplete(CrnOperatorParam param){ | 
|---|
|  |  |  | public R crnTaskComplete(CrnOperatorParam param) { | 
|---|
|  |  |  | // 系统运行状态判断 | 
|---|
|  |  |  | if (SystemProperties.WCS_RUNNING_STATUS.get()) { | 
|---|
|  |  |  | return R.error("wcs系统状态为开启"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //        if (SystemProperties.WCS_RUNNING_STATUS.get()) { | 
|---|
|  |  |  | //            return R.error("wcs系统状态为开启"); | 
|---|
|  |  |  | //        } | 
|---|
|  |  |  | CrnCommand command = new CrnCommand(); | 
|---|
|  |  |  | command.setCrnNo(param.getCrnNo()); // 堆垛机编号 | 
|---|
|  |  |  | command.setTaskNo((short) 0); // 工作号 | 
|---|
|  |  |  | 
|---|
|  |  |  | command.setDestinationPosX((short) 0);     // 目标库位排 | 
|---|
|  |  |  | command.setDestinationPosY((short) 0);     // 目标库位列 | 
|---|
|  |  |  | command.setDestinationPosZ((short) 0);     // 目标库位层 | 
|---|
|  |  |  | return crnControl(command)?R.ok():R.error(); | 
|---|
|  |  |  | command.setCommand((short) 0); | 
|---|
|  |  |  | return crnControl(command) ? R.ok() : R.error(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //    @ManagerAuth(memo = "暂停") | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @ManagerAuth(memo = "清除命令") | 
|---|
|  |  |  | @PostMapping("/crn/operator/clearCommand") | 
|---|
|  |  |  | public R crnClearCommand(CrnOperatorParam param){ | 
|---|
|  |  |  | public R crnClearCommand(CrnOperatorParam param) { | 
|---|
|  |  |  | // 系统运行状态判断 | 
|---|
|  |  |  | if (SystemProperties.WCS_RUNNING_STATUS.get()) { | 
|---|
|  |  |  | return R.error("wcs系统状态为开启"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //        if (SystemProperties.WCS_RUNNING_STATUS.get()) { | 
|---|
|  |  |  | //            return R.error("wcs系统状态为开启"); | 
|---|
|  |  |  | //        } | 
|---|
|  |  |  | if (param.getCrnNo() == null) { | 
|---|
|  |  |  | throw new CoolException("请选择堆垛机"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | command.setDestinationPosX((short) 0);     // 目标库位排 | 
|---|
|  |  |  | command.setDestinationPosY((short) 0);     // 目标库位列 | 
|---|
|  |  |  | command.setDestinationPosZ((short) 0);     // 目标库位层 | 
|---|
|  |  |  | return crnControl(command)?R.ok():R.error(); | 
|---|
|  |  |  | return crnControl(command) ? 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 (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 (MessageQueue.offer(SlaveType.Crn, crn.getId(), new Task(5, crnCommand))) { | 
|---|
|  |  |  | return R.ok(); | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | throw new CoolException("命令下发失败"); | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @ManagerAuth(memo = "切换联机模式") | 
|---|
|  |  |  | @PostMapping("/crn/operator/auto") | 
|---|
|  |  |  | public R crnAuto(CrnOperatorParam param){ | 
|---|
|  |  |  | public R crnAuto(CrnOperatorParam param) { | 
|---|
|  |  |  | // 系统运行状态判断 | 
|---|
|  |  |  | if (SystemProperties.WCS_RUNNING_STATUS.get()) { | 
|---|
|  |  |  | return R.error("wcs系统状态为开启"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //        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.setAuto((short)1); | 
|---|
|  |  |  | command.setAuto((short) 1); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return crnControl2(command)?R.ok():R.error(); | 
|---|
|  |  |  | return crnControl2(command) ? R.ok() : R.error(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @ManagerAuth(memo = "切换半手动模式") | 
|---|
|  |  |  | @PostMapping("/crn/operator/semiAutomatic") | 
|---|
|  |  |  | public R crnsemiAutomatic(CrnOperatorParam param){ | 
|---|
|  |  |  | public R crnsemiAutomatic(CrnOperatorParam param) { | 
|---|
|  |  |  | // 系统运行状态判断 | 
|---|
|  |  |  | if (SystemProperties.WCS_RUNNING_STATUS.get()) { | 
|---|
|  |  |  | return R.error("wcs系统状态为开启"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //        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.setAuto((short)2); | 
|---|
|  |  |  | command.setAuto((short) 2); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return crnControl2(command)?R.ok():R.error(); | 
|---|
|  |  |  | return crnControl2(command) ? R.ok() : R.error(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @ManagerAuth(memo = "切换手动模式") | 
|---|
|  |  |  | @PostMapping("/crn/operator/hand") | 
|---|
|  |  |  | public R onlineWrk1(CrnOperatorParam param){ | 
|---|
|  |  |  | public R onlineWrk1(CrnOperatorParam param) { | 
|---|
|  |  |  | // 系统运行状态判断 | 
|---|
|  |  |  | if (SystemProperties.WCS_RUNNING_STATUS.get()) { | 
|---|
|  |  |  | return R.error("wcs系统状态为开启"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //        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.setAuto((short)3); | 
|---|
|  |  |  | command.setAuto((short) 3); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return crnControl2(command)?R.ok():R.error(); | 
|---|
|  |  |  | return crnControl2(command) ? R.ok() : R.error(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @ManagerAuth(memo = "申请完成任务") | 
|---|
|  |  |  | @PostMapping("/crn/operator/onlineWrk1") | 
|---|
|  |  |  | public R onlineWrk2(CrnOperatorParam param){ | 
|---|
|  |  |  | public R onlineWrk2(CrnOperatorParam param) { | 
|---|
|  |  |  | // 系统运行状态判断 | 
|---|
|  |  |  | if (SystemProperties.WCS_RUNNING_STATUS.get()) { | 
|---|
|  |  |  | return R.error("wcs系统状态为开启"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //        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.setOnlineWrk1((short)1); | 
|---|
|  |  |  | command.setOnlineWrk1((short) 1); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return crnControl2(command)?R.ok():R.error(); | 
|---|
|  |  |  | return crnControl2(command) ? R.ok() : R.error(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @ManagerAuth(memo = "申请取消任务") | 
|---|
|  |  |  | @PostMapping("/crn/operator/onlineWrk2") | 
|---|
|  |  |  | public R onlineWrk3(CrnOperatorParam param){ | 
|---|
|  |  |  | public R onlineWrk3(CrnOperatorParam param) { | 
|---|
|  |  |  | // 系统运行状态判断 | 
|---|
|  |  |  | if (SystemProperties.WCS_RUNNING_STATUS.get()) { | 
|---|
|  |  |  | return R.error("wcs系统状态为开启"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //        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.setOnlineWrk2((short)1); | 
|---|
|  |  |  | command.setOnlineWrk2((short) 1); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return crnControl2(command)?R.ok():R.error(); | 
|---|
|  |  |  | return crnControl2(command) ? R.ok() : R.error(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @ManagerAuth(memo = "清除联机任务") | 
|---|
|  |  |  | @PostMapping("/crn/operator/onlineWrk3") | 
|---|
|  |  |  | public R onlineWrk4(CrnOperatorParam param){ | 
|---|
|  |  |  | public R onlineWrk4(CrnOperatorParam param) { | 
|---|
|  |  |  | // 系统运行状态判断 | 
|---|
|  |  |  | if (SystemProperties.WCS_RUNNING_STATUS.get()) { | 
|---|
|  |  |  | return R.error("wcs系统状态为开启"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //        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.setOnlineWrk3((short)1); | 
|---|
|  |  |  | command.setOnlineWrk3((short) 1); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return crnControl2(command)?R.ok():R.error(); | 
|---|
|  |  |  | return crnControl2(command) ? R.ok() : R.error(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @ManagerAuth(memo = "恢复联机任务") | 
|---|
|  |  |  | @PostMapping("/crn/operator/onlineWrk4") | 
|---|
|  |  |  | public R crnHand(CrnOperatorParam param){ | 
|---|
|  |  |  | public R crnHand(CrnOperatorParam param) { | 
|---|
|  |  |  | // 系统运行状态判断 | 
|---|
|  |  |  | if (SystemProperties.WCS_RUNNING_STATUS.get()) { | 
|---|
|  |  |  | return R.error("wcs系统状态为开启"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //        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.setOnlineWrk4((short)1); | 
|---|
|  |  |  | command.setOnlineWrk4((short) 1); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return crnControl2(command)?R.ok():R.error(); | 
|---|
|  |  |  | return crnControl2(command) ? R.ok() : R.error(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @ManagerAuth(memo = "复位") | 
|---|
|  |  |  | @PostMapping("/crn/operator/reset") | 
|---|
|  |  |  | public R crnReset(CrnOperatorParam param){ | 
|---|
|  |  |  | public R crnReset(CrnOperatorParam param) { | 
|---|
|  |  |  | // 系统运行状态判断 | 
|---|
|  |  |  | if (SystemProperties.WCS_RUNNING_STATUS.get()) { | 
|---|
|  |  |  | return R.error("wcs系统状态为开启"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //        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); | 
|---|
|  |  |  | command.setReset((short) 1); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return crnControl2(command)?R.ok():R.error(); | 
|---|
|  |  |  | return crnControl2(command) ? R.ok() : R.error(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private boolean crnControl2(CrnCommand command){ | 
|---|
|  |  |  | private boolean crnControl2(CrnCommand command) { | 
|---|
|  |  |  | if (command.getCrnNo() == null) { | 
|---|
|  |  |  | throw new CoolException("请选择堆垛机"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | // 空闲判断 | 
|---|
|  |  |  | //                if (crnProtocol.getStatusType().equals(com.zy.core.enums.CrnStatusType.IDLE) && crnProtocol.getTaskNo() == 0) { | 
|---|
|  |  |  | if (CommandUtils.offer(SlaveType.Crn, crn.getId(), new Task(4, command), false)) { | 
|---|
|  |  |  | if (MessageQueue.offer(SlaveType.Crn, crn.getId(), new Task(4, command))) { | 
|---|
|  |  |  | return true; | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | throw new CoolException("命令下发失败"); | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private boolean crnControl(CrnCommand command){ | 
|---|
|  |  |  | private boolean crnControl(CrnCommand command) { | 
|---|
|  |  |  | if (command.getCrnNo() == null) { | 
|---|
|  |  |  | throw new CoolException("请选择堆垛机"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | // 空闲判断 | 
|---|
|  |  |  | //                if (crnProtocol.getStatusType().equals(com.zy.core.enums.CrnStatusType.IDLE) && crnProtocol.getTaskNo() == 0) { | 
|---|
|  |  |  | if (CommandUtils.offer(SlaveType.Crn, crn.getId(), new Task(2, command), false)) { | 
|---|
|  |  |  | if (MessageQueue.offer(SlaveType.Crn, crn.getId(), new Task(2, command))) { | 
|---|
|  |  |  | return true; | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | throw new CoolException("命令下发失败"); | 
|---|
|  |  |  | 
|---|
|  |  |  | return false; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private void staNoProcess(CrnOperatorParam param, CrnCommand command){ | 
|---|
|  |  |  | if (param.getSourceStaNo()!=null) { | 
|---|
|  |  |  | private void staNoProcess(CrnOperatorParam param, CrnCommand command) { | 
|---|
|  |  |  | if (param.getSourceStaNo() != null) { | 
|---|
|  |  |  | if (param.getSourceStaNo() == 5) { | 
|---|
|  |  |  | command.setSourcePosX((short) 2);     // 源库位排 | 
|---|
|  |  |  | command.setSourcePosY((short) 0);     // 源库位列 | 
|---|
|  |  |  | 
|---|
|  |  |  | command.setSourcePosZ((short) 1);     // 源库位层 | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (param.getStaNo()!=null) { | 
|---|
|  |  |  | if (param.getStaNo() != null) { | 
|---|
|  |  |  | if (param.getStaNo() == 5) { | 
|---|
|  |  |  | command.setDestinationPosX((short) 2);     // 目标库位排 | 
|---|
|  |  |  | command.setDestinationPosY((short) 0);     // 目标库位列 | 
|---|
|  |  |  | 
|---|
|  |  |  | // /crn/list/auth | 
|---|
|  |  |  | @RequestMapping(value = "/crnListQuery/auth") | 
|---|
|  |  |  | @ManagerAuth | 
|---|
|  |  |  | public R listQuery(String condition){ | 
|---|
|  |  |  | public R listQuery(String condition) { | 
|---|
|  |  |  | ArrayList<HashMap<String, Object>> list = new ArrayList<>(); | 
|---|
|  |  |  | for (CrnSlave crn : slaveProperties.getCrn()) { | 
|---|
|  |  |  | // 获取堆垛机信息 | 
|---|