| | |
| | | import com.mes.downworkstation.entity.DownWorkstation;
|
| | | import com.mes.downworkstation.service.DownWorkstationService;
|
| | | import com.mes.tools.DateUtil;
|
| | | import com.mes.tools.SocketUtil;
|
| | | import com.mes.tools.WebSocketServer;
|
| | | import lombok.extern.slf4j.Slf4j;
|
| | | import org.apache.commons.lang.StringUtils;
|
| | |
| | | private DownGlassInfoService downGlassInfoService;
|
| | | @Autowired
|
| | | private DownGlassTaskService downGlassTaskService;
|
| | |
|
| | |
|
| | | @Autowired
|
| | | SocketUtil socketUtil;
|
| | | @Autowired
|
| | | private RedisUtil redisUtil;
|
| | |
|
| | |
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | @Scheduled(fixedDelay = Long.MAX_VALUE)
|
| | | public void scanCodeTask() {
|
| | | while (true) {
|
| | | try {
|
| | | if (socketUtil.openSocket()) {
|
| | | String data = socketUtil.receiveData();
|
| | | if (StringUtils.isNotBlank(data)) {
|
| | | log.info("扫描数据:" + data);
|
| | | //发送扫描数据
|
| | | //todo:按照玻璃id获取玻璃信息返回给前端界面,具体需要哪些数据待确认
|
| | | ArrayList<WebSocketServer> sendwServer = WebSocketServer.sessionMap.get("scanCode");
|
| | | if (sendwServer != null) {
|
| | | for (WebSocketServer webserver : sendwServer) {
|
| | | if (webserver != null && webserver.session.isOpen()) {
|
| | | webserver.sendMessage(data);
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | | } else {
|
| | | log.info("socket连接失败");
|
| | | }
|
| | | } catch (Exception e) {
|
| | | log.info("socke执行过程中发生异常");
|
| | | }
|
| | | }
|
| | |
|
| | | }
|
| | | }
|