tjx
2 天以前 4cb1c6b66795468cbe361b66ae261159b7d9aedd
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
package com.hk.NumericalCollection;
 
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import com.hk.NumericalCollection.config.DataAcquisitionConfiguration;
import com.hk.NumericalCollection.dto.NumbericalDto;
import com.hk.NumericalCollection.entity.DevMacBycl;
import com.hk.NumericalCollection.entity.DevMachine;
import com.hk.NumericalCollection.service.*;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
 
import java.io.IOException;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.List;
 
@SpringBootTest
class DeviceReceivingApplicationTests {
 
    @Autowired
    private ApiService apiService;
    @Autowired
    private INumericalService numericalService;
    @Autowired
    private DeviceMetricsService deviceMetricsService;
    @Autowired
    private MesNumericalService mesNumericalServicen;
    @Autowired
    private MesOrderSelectService orderSelectService;
    @Autowired
    private DevMachineService devMachineService;
    @Autowired
    private DevMacByclService devMacByclService;
    @Autowired
    private MesNumericalService mesNumericalService;
 
    @Autowired
    private WomdaaService womdaaService;
 
    @Autowired
    private INumericalNoOrderService numericalNoOrderService;
 
    @Test
    void contextLoads() {
        //FFFFFFFE
        long decimal = Long.parseLong("FFFFFFFE", 16);  // 将16进制字符串转换为long类型的10进制数
        BigDecimal a = new BigDecimal(String.valueOf((int) decimal));
        BigDecimal b = new BigDecimal("1000");
        BigDecimal c = a.divide(b, 3, RoundingMode.HALF_UP);
        System.out.println(c);
    }
 
    @Test
    void getDeviceDayCount() throws IOException {
//        DateTime oneWeekAgo = DateUtil.offsetDay(DateUtil.date(), -1);
//        String format = DateUtil.format(oneWeekAgo, "yyyy-MM-dd");
//        try {
//            List<DevMachine> list = devMachineService.list();
//            for (DevMachine s : list) {
//                numericalService.getDeviceDayCount(s.getDevNo(), format);
//            }
//        } catch (IOException e) {
//            throw new RuntimeException(e);
//        }
        //
       //numericalService.getDeviceDayCount("862858070704174_1", "2025-04-22");
    }
 
    @Test
    void getMesNumerical() throws IOException {
        DateTime oneWeekAgo = DateUtil.offsetDay(DateUtil.date(), -7);
        String format = DateUtil.format(oneWeekAgo, "yyyy-MM-dd");
        System.out.println(format);
    }
 
    @Test
    public void getDeviceRealTimeData() throws Exception {
//        List<DevMachine> list = devMachineService.list();
//        list.forEach(s -> {
//            try {
//                numericalService.getDeviceRealTimeData(s.getDevNo());
//            } catch (Exception e) {
//                throw new RuntimeException(e);
//            }
//        });
 
//        numericalService.getDeviceRealTimeData("868371072149251_1");
 
 
//        numericalService.getDeviceRealTimeDataBycl("866042075016340");
//        List<DevMachine> list = devMachineService.list();
//        list.forEach(s -> {
//            try {
//                numericalNoOrderService.getDeviceRealTimeData(s.getDevNo());
//            } catch (Exception e) {
//                throw new RuntimeException(e);
//            }
//        });
    }
 
    //@Test
    public void SoDeviceList() {
        try {
            boolean b = numericalService.SoDeviceList();
            if (b) {
                System.out.println("设备基础信息获取成功");
            } else {
                System.out.println("设备基础信息获取失败");
            }
        } catch (IOException e) {
            // Handle the exception
            e.printStackTrace();
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
 
    /**
     * 测试批量获取所有设备的故障列表
     */
    //@Test
    public void testGetAllDeviceErrorList() throws Exception {
        DateTime yesterday = DateUtil.yesterday();
        DateTime startDateTime = DateUtil.parse(DateUtil.format(yesterday, "yyyy-MM-dd") + " 07:30:00");
        DateTime endDateTime = DateUtil.parse(DateUtil.format(DateUtil.date(), "yyyy-MM-dd") + " 07:30:00");
 
        String startDate = DateUtil.format(startDateTime, "yyyy-MM-dd HH:mm:ss");
        String endDate = DateUtil.format(endDateTime, "yyyy-MM-dd HH:mm:ss");
 
        try {
            List<DevMachine> list = devMachineService.list();
            for (DevMachine machine : list) {
                numericalNoOrderService.getDeviceErrorList(machine.getDevNo(), startDate, endDate);
                System.out.println("设备 " + machine.getDevNo() + " 故障列表获取成功");
            }
        } catch (Exception e) {
            System.err.println("批量获取设备故障列表失败: " + e.getMessage());
            throw e;
        }
    }
 
    @Test
    public void tt(){
        System.out.println(String.format(DataAcquisitionConfiguration.ASK_DATA_URL, DataAcquisitionConfiguration.APP_ID));
    }
}