| | |
| | | |
| | | import cn.hutool.json.JSONObject; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.github.xingshuangs.iot.protocol.s7.enums.EPlcType; |
| | | import com.github.yulichang.wrapper.MPJLambdaWrapper; |
| | | import com.mes.common.S7objectFlipSlice; |
| | | import com.mes.common.S7objectMachine; |
| | | import com.mes.common.S7objectMarking; |
| | | import com.mes.device.PlcParameterInfo; |
| | | import com.mes.device.PlcParameterObject; |
| | | import com.mes.md.entity.*; |
| | | import com.mes.md.mapper.GlassInfoMapper; |
| | | import com.mes.md.mapper.MachineMapper; |
| | | import com.mes.md.mapper.TaskingMapper; |
| | | import com.mes.md.service.*; |
| | | import com.mes.tools.WebSocketServer; |
| | | import com.mes.websocket.WebSocketServer; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.scheduling.annotation.Scheduled; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | |
| | | KBBTJPDrawingBPService kBBTJPDrawingBPService; |
| | | @Autowired |
| | | LineConfigurationService lineConfigurationService; |
| | | @Resource |
| | | WebSocketServer webSocketServer; |
| | | @Autowired |
| | | private GlassInfoMapper glassInfoMapper; |
| | | public List<Map> sendRecords = new ArrayList<>(); |
| | |
| | | this.webSocketServer(jsonObject); |
| | | } |
| | | |
| | | |
| | | public void webSocketServer(JSONObject jsonObject) { |
| | | try { |
| | | String sessionMapName=jsonObject.getJSONArray("sessionMapName").get(0).toString(); |
| | | ArrayList<WebSocketServer> sendwServer = WebSocketServer.sessionMap.get(sessionMapName); |
| | | if (sendwServer != null) { |
| | | for (WebSocketServer webserver : sendwServer) { |
| | | if (webserver != null) { |
| | | try { |
| | | webserver.sendMessage(jsonObject.toString()); |
| | | List<String> messages = webserver.getMessages(); |
| | | if (!messages.isEmpty()) { |
| | | // // 将最后一个消息转换为整数类型的列表 |
| | | webserver.clearMessages(); |
| | | } |
| | | }catch (Exception e) { |
| | | |
| | | } |
| | | } else { |
| | | log.info("Home is closed"); |
| | | } |
| | | } |
| | | } |
| | | }catch (Exception e) { |
| | | |
| | | webSocketServer.sendToWeb(sessionMapName, jsonObject.toString()); |
| | | } catch (Exception ex) { |
| | | log.info("{}发送数据失败:{}", "rawGlassStorage", ex.getMessage()); |
| | | } |
| | | |
| | | } |
| | | // public void webSocketServer(JSONObject jsonObject) { |
| | | // try { |
| | | // String sessionMapName=jsonObject.getJSONArray("sessionMapName").get(0).toString(); |
| | | // ArrayList<WebSocketServer> sendwServer = WebSocketServer.sessionMap.get(sessionMapName); |
| | | // if (sendwServer != null) { |
| | | // for (WebSocketServer webserver : sendwServer) { |
| | | // try { |
| | | // webserver.sendMessage(jsonObject.toString()); |
| | | // List<String> messages = webserver.getMessages(); |
| | | // if (!messages.isEmpty()) { |
| | | // // // 将最后一个消息转换为整数类型的列表 |
| | | // webserver.clearMessages(); |
| | | // } |
| | | // }catch (Exception e) { |
| | | // if (webserver != null) { |
| | | // |
| | | // } else { |
| | | // log.info("Home is closed"); |
| | | // } |
| | | // } |
| | | // |
| | | // } |
| | | // } |
| | | // }catch (Exception e) { |
| | | // |
| | | // } |
| | | // |
| | | // } |
| | | |
| | | } |