New file |
| | |
| | | package com.zy.asrs.controller; |
| | | |
| | | import com.core.common.R; |
| | | import com.zy.asrs.domain.param.ToOutStaParam; |
| | | import com.zy.core.cache.MessageQueue; |
| | | import com.zy.core.cache.SlaveConnection; |
| | | import com.zy.core.enums.SlaveType; |
| | | import com.zy.core.model.Task; |
| | | import com.zy.core.model.protocol.StaProtocol; |
| | | import com.zy.core.thread.SiemensDevpThread; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | @Slf4j |
| | | @RestController |
| | | public class OpenController { |
| | | |
| | | @RequestMapping("/open/toOutSta") |
| | | public R toOutSta(@RequestBody ToOutStaParam param) { |
| | | Integer sourceStaNo = param.getSourceStaNo(); |
| | | SiemensDevpThread siemensDevpThread = (SiemensDevpThread) SlaveConnection.get(SlaveType.Devp, 1); |
| | | if(siemensDevpThread == null) { |
| | | return R.error("线程不存在"); |
| | | } |
| | | |
| | | StaProtocol staProtocol = siemensDevpThread.getStation().get(sourceStaNo).clone(); |
| | | if(staProtocol == null) { |
| | | return R.error("站点不存在"); |
| | | } |
| | | |
| | | if (staProtocol.getWorkNo().intValue() != param.getWrkNo()) { |
| | | return R.error("工作号不一致"); |
| | | } |
| | | |
| | | if (!staProtocol.isLoading()) { |
| | | return R.error("站点无物"); |
| | | } |
| | | |
| | | staProtocol.setWorkNo(param.getWrkNo().shortValue()); |
| | | staProtocol.setStaNo(param.getStaNo().shortValue()); |
| | | boolean result = MessageQueue.offer(SlaveType.Devp, 1, new Task(2, staProtocol)); |
| | | return R.ok().add(result); |
| | | } |
| | | |
| | | } |