wangfei
2024-11-08 3c7d672fb7d6c34742fb7da6f66616ccf3be2c9a
hangzhoumesParent/moduleService/UnLoadGlassModule/src/main/java/com/mes/job/Downpush.java
@@ -5,7 +5,6 @@
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.mes.common.config.Const;
import com.mes.common.utils.RedisUtil;
import com.mes.downglassinfo.entity.DownGlassInfo;
import com.mes.downglassinfo.entity.DownGlassTask;
import com.mes.downglassinfo.entity.request.DownGlassInfoRequest;
@@ -18,6 +17,7 @@
import com.mes.glassinfo.service.GlassInfoService;
import com.mes.tools.DateUtil;
import com.mes.tools.WebSocketServer;
import com.mes.utils.RedisUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
@@ -154,7 +154,7 @@
        jsonObject4.append("downGlassInfos", downGlassInfos);
        jsonObject4.append("engineerIdList", engineerIdList);
        //钢化开关
        //打印开关
        boolean autoPrint = false;
        if (redisUtil.getCacheObject("autoPrint") == null) {
            redisUtil.setCacheObject("autoPrint", false);
@@ -167,11 +167,12 @@
                new QueryWrapper<DownGlassTask>()
                        .select("Top 1 *")
                        .eq("end_cell", Const.G13_WORK_STATION)
                        .orderByDesc("id")
                        .lt("task_status", Const.UNLOAD_GLASS_DOWN)
                        .orderByAsc("id")
        );
        jsonObject4.append("takeGlass", takeGlass);
        if(takeGlass!=null){
            jsonObject4.append("takeGlass", takeGlass);
        }
        ArrayList<WebSocketServer> sendwServer4 = WebSocketServer.sessionMap.get("unloadglass");
        if (sendwServer4 != null) {
@@ -205,21 +206,26 @@
    @Scheduled(fixedDelay = Long.MAX_VALUE)
    public void scanCodeTask() {
        log.info("扫描任务已启动");
        while (true) {
            JSONObject jsonObject = new JSONObject();
            try (Socket socket = new Socket(scanIp, scanPort);
                 BufferedReader in = new BufferedReader(new InputStreamReader(socket.getInputStream()))) {
                // 接收服务器响应
                String response;
                while ((response = in.readLine()) != null) {
                    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());
                log.info("等待扫码中......");
                String glassId = in.readLine();
                log.info("扫描到的玻璃id:{}", glassId);
                List<WebSocketServer> sendwServer = WebSocketServer.sessionMap.get("unloadglass");
                if (CollectionUtils.isNotEmpty(sendwServer)) {
                    //按照玻璃id获取玻璃信息返回给前端界面,具体需要哪些数据待确认
                    GlassInfo glassInfo = glassInfoService.getOne(new LambdaQueryWrapper<GlassInfo>()
                            .eq(GlassInfo::getGlassId, glassId).last("limit 1"));
                    if (null == glassInfo) {
                        log.info("按照玻璃id:{},无法找到玻璃信息", glassId);
                    } else {
                        for (WebSocketServer webserver : sendwServer) {
                                jsonObject.append("scanGlass", glassInfo);
                                webserver.sendMessage(jsonObject.toString());
                        }
                    }
                }