严智鑫
2024-12-03 def1eb8623e1444164ae4bce9179d011a89b8c5e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package com.mes.job;
 
import cn.hutool.json.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.mes.md.entity.*;
import com.mes.md.mapper.MachineMapper;
import com.mes.md.mapper.TaskingMapper;
import com.mes.md.service.*;
import com.mes.service.ModbusTcp;
import com.mes.service.PlcAgreement;
import com.mes.service.PlcParameter;
import com.mes.tools.WebSocketServer;
import com.mes.utils.HexUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
 
import java.text.SimpleDateFormat;
import java.util.*;
 
/**
 * @author SNG-010
 */
@Component
@Slf4j
public class AddTask {
 
    @Autowired
    ProjectService projectService;
 
    @Autowired
    KBBTJPDrawingBPService kBBTJPDrawingBPService;
 
    //@Scheduled(fixedDelay = 30000)
    public void AddTasks() {
        projectService.insertProjectStandard();
 
    }
    //@Scheduled(fixedDelay = 1000)
    public void notReceive() {
        JSONObject jsonObject = new JSONObject();
        List<KBBTJPDrawingBP> list =kBBTJPDrawingBPService.notReceiveKBBTJPDrawingBP();
        jsonObject.append("content", list);
        ArrayList<WebSocketServer> sendwServer = WebSocketServer.sessionMap.get("notReceiveTask");
        if (sendwServer != null) {
            for (WebSocketServer webserver : sendwServer) {
                if (webserver != null) {
                    webserver.sendMessage(jsonObject.toString());
                    List<String> messages = webserver.getMessages();
                    if (!messages.isEmpty()) {
                        // // 将最后一个消息转换为整数类型的列表
                        webserver.clearMessages();
                    }
                } else {
                    log.info("Home is closed");
                }
            }
        }
    }
}