微调
This commit is contained in:
@@ -34,6 +34,7 @@ import com.njcn.gather.script.pojo.param.PqScriptIssueParam;
|
||||
import com.njcn.gather.script.pojo.po.SourceIssue;
|
||||
import com.njcn.gather.script.service.IPqScriptCheckDataService;
|
||||
import com.njcn.gather.script.service.IPqScriptDtlsService;
|
||||
import com.njcn.gather.source.pojo.po.PqSource;
|
||||
import com.njcn.gather.source.service.IPqSourceService;
|
||||
import com.njcn.gather.storage.pojo.param.StorageParam;
|
||||
import com.njcn.gather.storage.pojo.po.SimAndDigHarmonicResult;
|
||||
@@ -1802,6 +1803,94 @@ public class SocketDevResponseService {
|
||||
if (param.getTestItemList().get(1)) {
|
||||
initXiManager(param);
|
||||
}
|
||||
|
||||
FormalTestManager.overload = getOverloadResult(param);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取过载测试结果
|
||||
*
|
||||
* @return 如果检测到电压过载,overload=1;如果检测到电流过载,overload=2;如果检测到电压&&电流过载,overload=3;反之,overload=4
|
||||
*/
|
||||
private int getOverloadResult(PreDetectionParam param) {
|
||||
PqSource pqSource = pqSourceService.getPqSourceById(param.getSourceId());
|
||||
BigDecimal maxVoltage = pqSource.getMaxVoltage();
|
||||
BigDecimal maxCurrent = pqSource.getMaxCurrent();
|
||||
|
||||
PqScriptIssueParam issueParam = new PqScriptIssueParam();
|
||||
issueParam.setSourceId(pqSource.getName());
|
||||
issueParam.setPlanId(param.getPlanId());
|
||||
issueParam.setDevIds(param.getDevIds());
|
||||
issueParam.setScriptId(param.getScriptId());
|
||||
issueParam.setIsPhaseSequence(CommonEnum.FORMAL_TEST.getValue());
|
||||
List<SourceIssue> sourceIssues = pqScriptDtlsService.listSourceIssue(issueParam);
|
||||
|
||||
for (int i = 0; i < sourceIssues.size(); i++) {
|
||||
SourceIssue sourceIssue = sourceIssues.get(i);
|
||||
List<SourceIssue.ChannelListDTO> channelList = sourceIssue.getChannelList();
|
||||
for (int j = 0; j < channelList.size(); j++) {
|
||||
SourceIssue.ChannelListDTO channelListDTO = channelList.get(j);
|
||||
Double fAmp = channelListDTO.getFAmp();
|
||||
String channelType = channelListDTO.getChannelType();
|
||||
|
||||
if (ObjectUtil.isNotNull(fAmp)) {
|
||||
if (channelType.contains("U")) {
|
||||
// 电压判断
|
||||
if (maxVoltage.compareTo(BigDecimal.valueOf(fAmp)) < 0) {
|
||||
return 1;
|
||||
}
|
||||
} else {
|
||||
// 电流判断
|
||||
if (maxCurrent.compareTo(BigDecimal.valueOf(fAmp)) < 0) {
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
// 暂态判断
|
||||
if (channelListDTO.getDipFlag()) {
|
||||
SourceIssue.ChannelListDTO.DipDataDTO dipData = channelListDTO.getDipData();
|
||||
if (ObjectUtil.isNotNull(dipData)) {
|
||||
Double fTransValue = dipData.getFTransValue();
|
||||
if (ObjectUtil.isNotNull(fTransValue) && ObjectUtil.isNotNull(fAmp)) {
|
||||
if (maxVoltage.compareTo(BigDecimal.valueOf(fTransValue).max(BigDecimal.valueOf(fAmp))) < 0) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// 谐波判断
|
||||
if (channelListDTO.getHarmFlag()) {
|
||||
List<SourceIssue.ChannelListDTO.HarmModel> harmList = channelListDTO.getHarmList();
|
||||
double sum = harmList.stream().map(harmModel -> harmModel.getFAmp() * harmModel.getFAmp()).mapToDouble(x -> x).sum();
|
||||
if (channelType.contains("U")) {
|
||||
if (maxVoltage.compareTo(BigDecimal.valueOf(Math.sqrt(1 + sum) * fAmp)) < 0) {
|
||||
return 1;
|
||||
}
|
||||
} else {
|
||||
if (maxCurrent.compareTo(BigDecimal.valueOf(Math.sqrt(1 + sum) * fAmp)) < 0) {
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
// 间谐波判断
|
||||
if (channelListDTO.getInHarmFlag()) {
|
||||
List<SourceIssue.ChannelListDTO.InharmModel> inharmList = channelListDTO.getInharmList();
|
||||
double sum = inharmList.stream().map(harmModel -> harmModel.getFAmp() * harmModel.getFAmp()).mapToDouble(x -> x).sum();
|
||||
if (channelType.contains("U")) {
|
||||
if (maxVoltage.compareTo(BigDecimal.valueOf(Math.sqrt(1 + sum) * fAmp)) < 0) {
|
||||
return 1;
|
||||
}
|
||||
} else {
|
||||
if (maxCurrent.compareTo(BigDecimal.valueOf(Math.sqrt(1 + sum) * fAmp)) < 0) {
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 4;
|
||||
}
|
||||
|
||||
//初始化系数校验参数
|
||||
|
||||
@@ -384,6 +384,12 @@ public class SocketSourceResponseService {
|
||||
socketMsg.setRequestId(SourceOperateCodeEnum.FORMAL_REAL.getValue() + CnSocketUtil.STEP_TAG + type);
|
||||
SocketManager.sendMsg(param.getUserPageId() + CnSocketUtil.SOURCE_TAG, JSON.toJSONString(socketMsg));
|
||||
} else {
|
||||
// 推送过载测试结果
|
||||
SocketDataMsg overloadSocketDataMsg = new SocketDataMsg();
|
||||
overloadSocketDataMsg.setRequestId("overloadTest");
|
||||
overloadSocketDataMsg.setCode(FormalTestManager.overload);
|
||||
sendWebSocketMessage(param.getUserPageId(), overloadSocketDataMsg);
|
||||
|
||||
//todo 前端推送收到的消息暂未处理好
|
||||
sendWebSocketMessage(param.getUserPageId(), socketDataMsg);
|
||||
//开始设备通讯检测(发送设备初始化)
|
||||
|
||||
@@ -208,4 +208,9 @@ public class FormalTestManager {
|
||||
* 是否进行相序校验
|
||||
*/
|
||||
public static boolean isXu;
|
||||
|
||||
/**
|
||||
* 过载信息,如果检测到电压过载,overload=1;如果检测到电流过载,overload=2;如果检测到电压&&电流过载,overload=3;反之,overload=4
|
||||
*/
|
||||
public static int overload;
|
||||
}
|
||||
|
||||
@@ -7,8 +7,10 @@ import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import javax.validation.constraints.DecimalMin;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.Pattern;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
@@ -51,6 +53,14 @@ public class PqSourceParam {
|
||||
@ApiModelProperty("源参数")
|
||||
private String parameter;
|
||||
|
||||
@ApiModelProperty("最大电压")
|
||||
@DecimalMin("0")
|
||||
private BigDecimal maxVoltage;
|
||||
|
||||
@ApiModelProperty("最大电流")
|
||||
@DecimalMin("0")
|
||||
private BigDecimal maxCurrent;
|
||||
|
||||
|
||||
@Data
|
||||
public static class QueryParam extends BaseParam {
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
package com.njcn.gather.source.pojo.po;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.njcn.db.mybatisplus.bo.BaseEntity;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
@@ -46,6 +48,12 @@ public class PqSource extends BaseEntity implements Serializable {
|
||||
*/
|
||||
private String parameter;
|
||||
|
||||
@TableField("Max_Voltage")
|
||||
private BigDecimal maxVoltage;
|
||||
|
||||
@TableField("Max_Current")
|
||||
private BigDecimal maxCurrent;
|
||||
|
||||
/**
|
||||
* 状态:0-删除 1-正常
|
||||
*/
|
||||
|
||||
@@ -1,33 +0,0 @@
|
||||
package com.njcn.gather.plan.pojo.vo;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
public class PlanStatisticsVOTest {
|
||||
|
||||
@Test
|
||||
public void shouldExposeQualifiedDeviceCount() {
|
||||
PlanStatisticsVO statistics = new PlanStatisticsVO();
|
||||
|
||||
statistics.setQualifiedDeviceCount(6);
|
||||
|
||||
Assert.assertEquals(Integer.valueOf(6), statistics.getQualifiedDeviceCount());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldExposeLinkedFilterOptions() {
|
||||
PlanStatisticsVO statistics = new PlanStatisticsVO();
|
||||
PlanStatisticsOptionVO manufacturer = new PlanStatisticsOptionVO("manufacturer-1", "厂家A");
|
||||
PlanStatisticsOptionVO devType = new PlanStatisticsOptionVO("dev-type-1", "PQS-882A");
|
||||
|
||||
statistics.setManufacturerOptions(Collections.singletonList(manufacturer));
|
||||
statistics.setDevTypeOptions(Collections.singletonList(devType));
|
||||
|
||||
Assert.assertEquals("manufacturer-1", statistics.getManufacturerOptions().get(0).getId());
|
||||
Assert.assertEquals("厂家A", statistics.getManufacturerOptions().get(0).getName());
|
||||
Assert.assertEquals("dev-type-1", statistics.getDevTypeOptions().get(0).getId());
|
||||
Assert.assertEquals("PQS-882A", statistics.getDevTypeOptions().get(0).getName());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
package com.njcn.gather.source.pojo;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.njcn.gather.source.pojo.param.PqSourceParam;
|
||||
import com.njcn.gather.source.pojo.po.PqSource;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import javax.validation.Validation;
|
||||
import javax.validation.Validator;
|
||||
import javax.validation.constraints.DecimalMin;
|
||||
import java.lang.reflect.Field;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
public class PqSourceCapacityFieldsTest {
|
||||
|
||||
private final Validator validator = Validation.buildDefaultValidatorFactory().getValidator();
|
||||
|
||||
@Test
|
||||
public void shouldExposeExplicitCapacityColumnMappings() throws Exception {
|
||||
Field maxVoltage = PqSource.class.getDeclaredField("maxVoltage");
|
||||
Field maxCurrent = PqSource.class.getDeclaredField("maxCurrent");
|
||||
|
||||
Assert.assertEquals("Max_Voltage", maxVoltage.getAnnotation(TableField.class).value());
|
||||
Assert.assertEquals("Max_Current", maxCurrent.getAnnotation(TableField.class).value());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldExposeNonNegativeCapacityValidation() throws Exception {
|
||||
Field maxVoltage = PqSourceParam.class.getDeclaredField("maxVoltage");
|
||||
Field maxCurrent = PqSourceParam.class.getDeclaredField("maxCurrent");
|
||||
|
||||
Assert.assertEquals("0", maxVoltage.getAnnotation(DecimalMin.class).value());
|
||||
Assert.assertEquals("0", maxCurrent.getAnnotation(DecimalMin.class).value());
|
||||
|
||||
PqSourceParam.UpdateParam param = new PqSourceParam.UpdateParam();
|
||||
param.setId("12345678901234567890123456789012");
|
||||
param.setPattern("12345678901234567890123456789012");
|
||||
param.setType("12345678901234567890123456789012");
|
||||
param.setDevType("12345678901234567890123456789012");
|
||||
param.setMaxVoltage(new BigDecimal("-1"));
|
||||
|
||||
Assert.assertFalse(validator.validate(param).isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldCopyCapacityFieldsFromRequestToEntity() {
|
||||
PqSourceParam.UpdateParam param = new PqSourceParam.UpdateParam();
|
||||
param.setMaxVoltage(new BigDecimal("220.00"));
|
||||
param.setMaxCurrent(new BigDecimal("5.00"));
|
||||
|
||||
PqSource source = new PqSource();
|
||||
BeanUtil.copyProperties(param, source);
|
||||
|
||||
Assert.assertEquals(new BigDecimal("220.00"), source.getMaxVoltage());
|
||||
Assert.assertEquals(new BigDecimal("5.00"), source.getMaxCurrent());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user