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));
|
}
|
}
|