| | |
| | | import com.zy.asrs.mapper.ReportQueryMapper; |
| | | import com.zy.common.service.CommonService; |
| | | import com.zy.core.CrnThread; |
| | | import com.zy.core.cache.MessageQueue; |
| | | import com.zy.core.cache.SlaveConnection; |
| | | import com.zy.core.enums.SlaveType; |
| | | import com.zy.core.model.LedSlave; |
| | | import com.zy.core.model.Task; |
| | | import com.zy.core.model.command.LedCommand; |
| | | import com.zy.core.model.protocol.CrnProtocol; |
| | | import com.zy.core.properties.SlaveProperties; |
| | | import com.zy.core.thread.LedThread; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RequestParam; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * Created by vincent on 2020/11/16 |
| | |
| | | |
| | | @Autowired |
| | | private ReportQueryMapper reportQueryMapper; |
| | | @Autowired |
| | | private SlaveProperties slaveProperties; |
| | | |
| | | ArrayList<Object> programs = new ArrayList<>(); |
| | | HashMap<Integer,String> lcd = new HashMap<>(); |
| | | |
| | | /** |
| | | * 获取当前时间 |
| | |
| | | |
| | | // 获取输送线plc线程 |
| | | LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, ledId); |
| | | String ledContent = ledThread.getWorkNos().toString(); |
| | | String ledContent = Cools.isEmpty(ledThread) ? "" : ledThread.getWorkNos().toString(); |
| | | // ledContent = "ask的模块萨满大算了萨满大了\n 是窘境到埃及嗲家嗲\n 萨达姆打开萨满大凯撒麦当劳萨满大老师"; |
| | | |
| | | return R.ok( |
| | |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取其他信息 |
| | | */ |
| | | @GetMapping("/led") |
| | | public R monitorLed(@RequestParam("ledId") Integer ledId) { |
| | | String ledContent = ""; |
| | | List<LedCommand> commandList = null; |
| | | for (LedSlave slave : slaveProperties.getLed()) { |
| | | if (slave.getStaArr().contains(ledId)) { |
| | | LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, slave.getId()); |
| | | if (null != ledThread) { |
| | | ledContent = ledThread.getStringBuffer().toString(); |
| | | commandList = ledThread.getCommandList(); |
| | | } |
| | | } |
| | | } |
| | | return R.ok().add(commandList); |
| | | } |
| | | |
| | | /** |
| | | * 异常通知 |
| | | */ |
| | | @GetMapping("/led/error") |
| | | public R monitorLedError(@RequestParam("ledId") Integer ledId) { |
| | | String errorMsg = ""; |
| | | for (LedSlave slave : slaveProperties.getLed()) { |
| | | if (slave.getStaArr().contains(ledId)) { |
| | | LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, slave.getId()); |
| | | if (null != ledThread) { |
| | | errorMsg = ledThread.getErrorMsg().toString(); |
| | | } |
| | | } |
| | | } |
| | | return R.ok().add(errorMsg); |
| | | } |
| | | |
| | | /** |
| | | * 节目 |
| | | */ |
| | | @GetMapping("/led/program") |
| | | public R monitorProgramShow(@RequestParam("ledId") Integer ledId) { |
| | | String program = ""; |
| | | for (Object object : programs) { |
| | | program = lcd.get(ledId); |
| | | |
| | | } |
| | | return R.ok().add(program); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 显示节目 |
| | | */ |
| | | @RequestMapping("/led/add/program") |
| | | public R addProgram(Integer ledId, String msg) { |
| | | lcd.put(ledId,msg); |
| | | for (int i = 0; i < programs.size(); i++) { |
| | | Object o = programs.get(i); |
| | | System.out.println(o); |
| | | } |
| | | programs.add(lcd); |
| | | Iterator<Object> iterator = programs.iterator(); |
| | | while (iterator.hasNext()) { |
| | | // 获取循环的值 |
| | | Object next = iterator.next(); |
| | | // 如果存在两个相同的值 |
| | | if (programs.indexOf(next) != programs.lastIndexOf(next)) { |
| | | // 移除最后那个相同的值 |
| | | iterator.remove(); |
| | | } |
| | | } |
| | | System.out.println(programs); |
| | | return R.ok(); |
| | | } |
| | | |
| | | /** |
| | | * 移除节目 |
| | | */ |
| | | @RequestMapping("/led/remove/program") |
| | | public R removeProgram(Integer ledId, String msg) { |
| | | |
| | | return R.ok(); |
| | | } |
| | | |
| | | |
| | | |