| | |
| | | package com.zy.asrs.controller; |
| | | |
| | | import com.core.common.R; |
| | | import com.zy.asrs.domain.param.AskStaParam; |
| | | import com.zy.asrs.domain.param.TaskReportParam; |
| | | import com.zy.asrs.service.LocMastService; |
| | | import com.zy.asrs.service.impl.CtuMainServiceImpl; |
| | | import com.zy.common.web.BaseController; |
| | | import com.zy.core.DevpThread; |
| | | 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.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Map; |
| | | import java.util.Random; |
| | | |
| | | /** |
| | | * Created by vincent on 2022/4/8 |
| | |
| | | if (param == null || param.getSeqNum() == null || param.getQrCode() == null) { |
| | | return R.error("参数为空"); |
| | | } |
| | | if (param.getQrCode().equals("1547")) { |
| | | if ((param.getQrCode().equals("00001547") || param.getQrCode().equals("1001")) && param.getTaskSts() == 15) { |
| | | log.info("1001任务状态上报接收:{}", param); |
| | | ctuMainService.setFlag1001(true); |
| | | } else if (param.getQrCode().equals("1612")) { |
| | | DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, 1); |
| | | Map<Integer, StaProtocol> station = devpThread.getStation(); |
| | | StaProtocol staProtocol = station.get(1001); |
| | | if (staProtocol == null) { |
| | | return R.error("未找到站点"); |
| | | } else { |
| | | staProtocol = staProtocol.clone(); |
| | | } |
| | | Random rand = new Random(); |
| | | staProtocol.setWorkNo(rand.nextInt(1000)); |
| | | staProtocol.setStaNo((short) 1004); |
| | | boolean result = MessageQueue.offer(SlaveType.Devp, 1, new Task(2, staProtocol)); |
| | | if (result) { |
| | | log.info("下发成功:{},{}", staProtocol.getWorkNo(), 1004); |
| | | } |
| | | } else if (param.getQrCode().equals("00001612") && param.getTaskSts() == 5) { |
| | | log.info("1007任务状态上报接收:{}", param); |
| | | ctuMainService.setFlag1007(true); |
| | | |
| | | } |
| | | return R.ok(); |
| | | } |
| | | |
| | | /** |
| | | * 任务状态上报接收 |
| | | */ |
| | | @RequestMapping("/sta/ask/v1") |
| | | public R taskSync(@RequestBody AskStaParam param) { |
| | | log.info("状态询问:{}", param); |
| | | if (param == null || param.getAskSta() == null || param.getAskType() == null) { |
| | | return R.error("参数为空"); |
| | | } |
| | | SiemensDevpThread devpThread = (SiemensDevpThread) SlaveConnection.get(SlaveType.Devp, 1); |
| | | StaProtocol staProtocol = devpThread.getStation().get(param.getAskSta()); |
| | | if (staProtocol != null) { |
| | | if (param.getAskType() == 1) { |
| | | if (staProtocol.isLoading() && staProtocol.isAutoing() && staProtocol.isOutEnable()) { |
| | | return R.ok(); |
| | | } |
| | | } else if (param.getAskType() == 2) { |
| | | if (!staProtocol.isLoading() && staProtocol.isAutoing() && staProtocol.isInEnable()) { |
| | | return R.ok(); |
| | | } |
| | | } |
| | | } |
| | | return R.error("状态不对"); |
| | | } |
| | | |
| | | |
| | | } |