|
|
|
@ -2,64 +2,102 @@ package com.mh.user;
|
|
|
|
|
|
|
|
|
|
import com.mh.user.entity.DeviceManageEntity; |
|
|
|
|
import com.mh.user.entity.GaugeEntity; |
|
|
|
|
import com.mh.user.service.chillers.DealDataService; |
|
|
|
|
import com.mh.user.service.chillers.DeviceManageService; |
|
|
|
|
import com.mh.user.service.chillers.GaugeService; |
|
|
|
|
import com.mh.user.utils.AnalysisReceiveOrder485; |
|
|
|
|
import com.mh.user.utils.GetReadOrder485; |
|
|
|
|
import com.mh.user.utils.PasswordEncoder; |
|
|
|
|
import com.mh.user.utils.PasswordUtils; |
|
|
|
|
import com.mh.user.utils.*; |
|
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
|
import org.junit.jupiter.api.Test; |
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
|
import org.springframework.boot.test.context.SpringBootTest; |
|
|
|
|
|
|
|
|
|
import java.util.List; |
|
|
|
|
import java.util.concurrent.CountDownLatch; |
|
|
|
|
|
|
|
|
|
@Slf4j |
|
|
|
|
@SpringBootTest |
|
|
|
|
class UserServiceApplicationTests { |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
void contextLoads() { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void encode() { |
|
|
|
|
String s = PasswordUtils.encode("123456", "87e03afa1f0122531f729c9a7453f475"); |
|
|
|
|
System.out.println(s); |
|
|
|
|
System.out.println(new PasswordEncoder("87e03afa1f0122531f729c9a7453f475").matches(s, "123456")); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
private GaugeService gaugeService; |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void getGaugeData() { |
|
|
|
|
GaugeEntity gaugeEntity = gaugeService.getGaugeData("0", "1号冷水机"); |
|
|
|
|
System.out.println(gaugeEntity.toString()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
DeviceManageService deviceManageService; |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void queryDevices() { |
|
|
|
|
List<DeviceManageEntity> deviceManageEntities = deviceManageService.queryDevicesByType(null); |
|
|
|
|
for (DeviceManageEntity device : |
|
|
|
|
deviceManageEntities) { |
|
|
|
|
System.out.println(device.toString()); |
|
|
|
|
@Test |
|
|
|
|
void contextLoads() { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void AnalysisTest() { |
|
|
|
|
AnalysisReceiveOrder485 analysis=new AnalysisReceiveOrder485(); |
|
|
|
|
GetReadOrder485 getReadOrder485=new GetReadOrder485(); |
|
|
|
|
@Autowired |
|
|
|
|
private DealDataService dealDataService; |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void testDealData() { |
|
|
|
|
try { |
|
|
|
|
// 记录开始时间
|
|
|
|
|
long startTime = System.currentTimeMillis(); |
|
|
|
|
|
|
|
|
|
// 通过多线程进行处理
|
|
|
|
|
String curDate = ExchangeStringUtil.dateTime(1, ""); |
|
|
|
|
List<String> list = dealDataService.queryProjectId("1"); |
|
|
|
|
if (!list.isEmpty()) { |
|
|
|
|
CountDownLatch latch = new CountDownLatch(list.size()); |
|
|
|
|
for (String projectId : list) { |
|
|
|
|
new Thread(() -> { |
|
|
|
|
try { |
|
|
|
|
dealDataService.proDataResult(curDate, projectId); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
log.error("能效监测定时汇总异常", e); |
|
|
|
|
} finally { |
|
|
|
|
latch.countDown(); |
|
|
|
|
} |
|
|
|
|
}).start(); |
|
|
|
|
} |
|
|
|
|
latch.await(); // 等待所有子线程执行完毕
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 记录结束时间并计算运行时长
|
|
|
|
|
long endTime = System.currentTimeMillis(); |
|
|
|
|
long duration = endTime - startTime; |
|
|
|
|
|
|
|
|
|
log.info("---------能效监测定时汇总,每一分钟!{},耗时: {} 毫秒", curDate, duration); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
log.error("能效监测定时汇总异常", e); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void encode() { |
|
|
|
|
String s = PasswordUtils.encode("123456", "87e03afa1f0122531f729c9a7453f475"); |
|
|
|
|
System.out.println(s); |
|
|
|
|
System.out.println(new PasswordEncoder("87e03afa1f0122531f729c9a7453f475").matches(s, "123456")); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
private GaugeService gaugeService; |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void getGaugeData() { |
|
|
|
|
GaugeEntity gaugeEntity = gaugeService.getGaugeData("0", "1号冷水机"); |
|
|
|
|
System.out.println(gaugeEntity.toString()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
DeviceManageService deviceManageService; |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void queryDevices() { |
|
|
|
|
List<DeviceManageEntity> deviceManageEntities = deviceManageService.queryDevicesByType(null); |
|
|
|
|
for (DeviceManageEntity device : |
|
|
|
|
deviceManageEntities) { |
|
|
|
|
System.out.println(device.toString()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void AnalysisTest() { |
|
|
|
|
AnalysisReceiveOrder485 analysis = new AnalysisReceiveOrder485(); |
|
|
|
|
GetReadOrder485 getReadOrder485 = new GetReadOrder485(); |
|
|
|
|
// analysis.analysisWtMeterOrder485("FEFEFE6810398710810000008116901F00006502002C006502002C0000000000000000FF3416");
|
|
|
|
|
//0203020008FD82
|
|
|
|
|
//0203020008FD82
|
|
|
|
|
// analysis.analysisPumpOrder485("0203020008FD82","0641");
|
|
|
|
|
// getReadOrder485.createOrderParam();
|
|
|
|
|
// analysis.analysisRelayOrder485("220611000000013A220611000000023B220611000000033C220611000000043D220611000000053E220611000000063F22061100000007402206110000000841","0017","中凯");
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|