| | |
| | | private DownGlassTaskService downGlassTaskService;
|
| | | @Autowired
|
| | | private GlassInfoService glassInfoService;
|
| | | private final ExecutorService scanCodeThreadPool = new ThreadPoolExecutor(
|
| | | 10, // core pool size
|
| | | 20, // maximum pool size
|
| | | 60L, TimeUnit.SECONDS,
|
| | | new LinkedBlockingQueue<>()
|
| | | );
|
| | | private final ExecutorService isRunThreadPool = Executors.newFixedThreadPool(5);
|
| | |
|
| | | @Value("${mes.scan.ip}")
|
| | | private String scanIp;
|
| | |
| | | );
|
| | | jsonObject4.append("takeGlass", takeGlass);
|
| | |
|
| | |
|
| | | ArrayList<WebSocketServer> sendwServer4 = WebSocketServer.sessionMap.get("unloadglass");
|
| | | if (sendwServer4 != null) {
|
| | | for (WebSocketServer webserver : sendwServer4) {
|
| | |
| | |
|
| | | @Scheduled(fixedDelay = 1000)
|
| | | public void isRun() {
|
| | | isRunThreadPool.execute(() -> {
|
| | | JSONObject jsonObject = new JSONObject();
|
| | | //正在进行的任务
|
| | | List<DownWorkstation> downWorkstation = downWorkstationService.getoneDownWorkstations(1, 6);
|
| | |
| | | }
|
| | | }
|
| | | }
|
| | | });
|
| | |
|
| | | }
|
| | |
|
| | | @Async
|
| | | @Scheduled(fixedDelay = Long.MAX_VALUE)
|
| | | public void scanCodeTask() {
|
| | | JSONObject jsonObject = new JSONObject();
|
| | |
| | | try (Socket socket = new Socket(scanIp, scanPort);
|
| | | BufferedReader in = new BufferedReader(new InputStreamReader(socket.getInputStream()))) {
|
| | | // 接收服务器响应
|
| | | // socket.setSoTimeout(1000);
|
| | | log.info("等待扫码中......");
|
| | | String glassId = in.readLine();
|
| | | log.info("扫描到的玻璃id:{}", glassId);
|
| | |
| | | if (null == glassInfo) {
|
| | | log.info("按照玻璃id:{},无法找到玻璃信息", glassId);
|
| | | } else {
|
| | | for (WebSocketServer webserver : sendwServer) {
|
| | | jsonObject.append("scanGlass",glassInfo);
|
| | | sendwServer.get(0).sendMessage(jsonObject.toString());
|
| | | webserver.sendMessage(jsonObject.toString());
|
| | | }
|
| | | }
|
| | | }
|
| | | } catch (Exception exception) {
|
| | | log.info("读取异常,原因为{}", exception.getMessage());
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | @Scheduled(fixedDelay = Long.MAX_VALUE)
|
| | | public void scanCodeTaskCopy()
|
| | | {
|
| | | log.info("扫描任务已启动");
|
| | | try {
|
| | | BarcodeReadThread brt=new BarcodeReadThread(scanIp,scanPort,this);
|
| | | brt.start();
|
| | |
|
| | | }catch (Exception exception) {
|
| | | log.info("扫描任务启动异常,原因为{}", exception.getMessage());
|
| | | }
|
| | |
|
| | | }
|
| | | //socket读取到消息后会调用这个函数
|
| | | public void barcodeCheckin(String response)
|
| | | {
|
| | | log.info("扫描到的玻璃id:{}", response);
|
| | | List<WebSocketServer> sendwServer = WebSocketServer.sessionMap.get("scanCode");
|
| | | if (CollectionUtils.isNotEmpty(sendwServer)) {
|
| | | //按照玻璃id获取玻璃信息返回给前端界面,具体需要哪些数据待确认
|
| | | GlassInfo glassInfo = glassInfoService.getOne(new LambdaQueryWrapper<GlassInfo>()
|
| | | .eq(GlassInfo::getGlassId, response).last("limit 1"));
|
| | | if (null == glassInfo) {
|
| | | log.info("按照玻璃id:{},无法找到玻璃信息", response);
|
| | | } else {
|
| | | sendwServer.get(0).sendMessage(glassInfo.toString());
|
| | | }
|
| | | }
|
| | | }
|