| | |
| | | package com.zy.asrs.controller; |
| | | |
| | | import HslCommunication.Profinet.Siemens.SiemensS7Net; |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.baomidou.mybatisplus.plugins.Page; |
| | | import com.core.annotations.ManagerAuth; |
| | |
| | | import com.zy.asrs.service.WrkMastService; |
| | | import com.zy.asrs.service.impl.MainServiceImpl; |
| | | import com.zy.asrs.utils.VersionUtils; |
| | | import com.zy.common.utils.HttpHandler; |
| | | 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; |
| | |
| | | @Slf4j |
| | | @RestController |
| | | public class CrnController { |
| | | |
| | | @Value("${wms.url}") |
| | | private String wmsUrl; |
| | | @Value("${wms.movePath}") |
| | | private String movePath; |
| | | |
| | | |
| | | |
| | | @Autowired |
| | | private SlaveProperties slaveProperties; |
| | |
| | | return R.error(); |
| | | } |
| | | |
| | | @ManagerAuth(memo = "切换联机模式") |
| | | @PostMapping("/crn/operator/auto") |
| | | public R crnAuto(CrnOperatorParam param){ |
| | | short[] array = new short[9]; |
| | | CrnCommand command = new CrnCommand(); |
| | | command.setCrnNo(param.getCrnNo()); // 堆垛机编号 |
| | | command.setTaskNo((short) 0); // 工作号 |
| | | command.setAuto((short)1); |
| | | |
| | | return crnControl2(command)?R.ok():R.error(); |
| | | } |
| | | @ManagerAuth(memo = "切换半手动模式") |
| | | @PostMapping("/crn/operator/semiAutomatic") |
| | | public R crnsemiAutomatic(CrnOperatorParam param){ |
| | | short[] array = new short[9]; |
| | | CrnCommand command = new CrnCommand(); |
| | | command.setCrnNo(param.getCrnNo()); // 堆垛机编号 |
| | | command.setTaskNo((short) 0); // 工作号 |
| | | command.setAuto((short)2); |
| | | |
| | | return crnControl2(command)?R.ok():R.error(); |
| | | } |
| | | @ManagerAuth(memo = "切换手动模式") |
| | | @PostMapping("/crn/operator/hand") |
| | | public R onlineWrk1(CrnOperatorParam param){ |
| | | short[] array = new short[9]; |
| | | CrnCommand command = new CrnCommand(); |
| | | command.setCrnNo(param.getCrnNo()); // 堆垛机编号 |
| | | command.setTaskNo((short) 0); // 工作号 |
| | | command.setAuto((short)3); |
| | | |
| | | return crnControl2(command)?R.ok():R.error(); |
| | | } |
| | | @ManagerAuth(memo = "申请完成任务") |
| | | @PostMapping("/crn/operator/onlineWrk1") |
| | | public R onlineWrk2(CrnOperatorParam param){ |
| | | short[] array = new short[9]; |
| | | CrnCommand command = new CrnCommand(); |
| | | command.setCrnNo(param.getCrnNo()); // 堆垛机编号 |
| | | command.setTaskNo((short) 0); // 工作号 |
| | | command.setOnlineWrk1((short)1); |
| | | |
| | | return crnControl2(command)?R.ok():R.error(); |
| | | } |
| | | @ManagerAuth(memo = "申请取消任务") |
| | | @PostMapping("/crn/operator/onlineWrk2") |
| | | public R onlineWrk3(CrnOperatorParam param){ |
| | | short[] array = new short[9]; |
| | | CrnCommand command = new CrnCommand(); |
| | | command.setCrnNo(param.getCrnNo()); // 堆垛机编号 |
| | | command.setTaskNo((short) 0); // 工作号 |
| | | command.setOnlineWrk2((short)1); |
| | | |
| | | return crnControl2(command)?R.ok():R.error(); |
| | | } |
| | | @ManagerAuth(memo = "清除联机任务") |
| | | @PostMapping("/crn/operator/onlineWrk3") |
| | | public R onlineWrk4(CrnOperatorParam param){ |
| | | short[] array = new short[9]; |
| | | CrnCommand command = new CrnCommand(); |
| | | command.setCrnNo(param.getCrnNo()); // 堆垛机编号 |
| | | command.setTaskNo((short) 0); // 工作号 |
| | | command.setOnlineWrk3((short)1); |
| | | |
| | | return crnControl2(command)?R.ok():R.error(); |
| | | } |
| | | @ManagerAuth(memo = "恢复联机任务") |
| | | @PostMapping("/crn/operator/onlineWrk4") |
| | | public R crnHand(CrnOperatorParam param){ |
| | | short[] array = new short[9]; |
| | | CrnCommand command = new CrnCommand(); |
| | | command.setCrnNo(param.getCrnNo()); // 堆垛机编号 |
| | | command.setTaskNo((short) 0); // 工作号 |
| | | command.setOnlineWrk4((short)1); |
| | | |
| | | return crnControl2(command)?R.ok():R.error(); |
| | | } |
| | | |
| | | |
| | | |
| | | private boolean crnControl2(CrnCommand command){ |
| | | if (command.getCrnNo() == null) { |
| | | throw new CoolException("请选择堆垛机"); |
| | | } |
| | | for (CrnSlave crn : slaveProperties.getCrn()) { |
| | | // 获取堆垛机信息 |
| | | if (command.getCrnNo().equals(crn.getId())) { |
| | | CrnThread crnThread = (CrnThread) SlaveConnection.get(SlaveType.Crn, crn.getId()); |
| | | if (crnThread == null) { |
| | | throw new CoolException("堆垛机不在线"); |
| | | } |
| | | CrnProtocol crnProtocol = crnThread.getCrnProtocol(); |
| | | if (crnProtocol == null) { |
| | | throw new CoolException("堆垛机不在线"); |
| | | } |
| | | // 空闲判断 |
| | | // if (crnProtocol.getStatusType().equals(com.zy.core.enums.CrnStatusType.IDLE) && crnProtocol.getTaskNo() == 0) { |
| | | if (MessageQueue.offer(SlaveType.Crn, crn.getId(), new Task(4, command))) { |
| | | return true; |
| | | } else { |
| | | throw new CoolException("命令下发失败"); |
| | | } |
| | | // } else { |
| | | // throw new CoolException("堆垛机不在空闲状态"); |
| | | // } |
| | | } |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | private boolean crnControl(CrnCommand command){ |
| | | if (command.getCrnNo() == null) { |
| | | throw new CoolException("请选择堆垛机"); |