装置下发参数公式接口编写

This commit is contained in:
wr
2025-02-19 16:51:13 +08:00
parent c062e2a47f
commit b746a6445f
11 changed files with 530 additions and 130 deletions

View File

@@ -1,5 +1,6 @@
package com.njcn.gather.detection.pojo.enums; package com.njcn.gather.detection.pojo.enums;
import cn.hutool.core.util.ObjectUtil;
import lombok.Getter; import lombok.Getter;
/** /**
@@ -10,15 +11,31 @@ import lombok.Getter;
@Getter @Getter
public enum DetectionCodeEnum { public enum DetectionCodeEnum {
FREQ("FREQ", "频率"),
VRMS("VRMS", "相电压有效值"),
DELTA_V("DELTA_V", "电压偏差"),
VA("VA", "电压相角"),
U1("U1", "基波电压"), U1("U1", "基波电压"),
V2_50("V2-50", "谐波电压"), V2_50("V2-50", "谐波电压"),
SV_1_49("SV_1-49", "间谐波电压"),
I1("I1", "基波电流"),
I2_50("I2-50", "谐波电流"), I2_50("I2-50", "谐波电流"),
SI_1_49("SI_1-49", "间谐波电压"),
P2_50("P2-50", "谐波有功功率"), P2_50("P2-50", "谐波有功功率"),
SV_1_49("SV_1-49", "间谐波电压"),
SI_1_49("SI_1-49", "间谐波电压"),
MAG("MAG", "电压幅值"),
DUR("DUR", "持续时间"),
IRMS("IRMS", "电流有效值"),
IA("IA", "电流相角"),
V_UNBAN("V_UNBAN", "三相电压负序不平衡度"),
I_UNBAN("I_UNBAN", "三相电流负序不平衡度"),
PST("PST", "短时间闪变"),
I1("I1", "基波电流"),
UNKNOWN_ERROR("-1", "未知异常"),
; ;
@@ -29,4 +46,12 @@ public enum DetectionCodeEnum {
this.code = code; this.code = code;
this.message = message; this.message = message;
} }
public static DetectionCodeEnum getDetectionCodeByCode(String code) {
for (DetectionCodeEnum detectionCodeEnum : DetectionCodeEnum.values()) {
if (ObjectUtil.equals(code, detectionCodeEnum.getCode())) {
return detectionCodeEnum;
}
}
return UNKNOWN_ERROR;
}
} }

View File

@@ -303,6 +303,7 @@ public class DetectionServiceImpl {
if (CollUtil.isNotEmpty(dtlsCheckData)) { if (CollUtil.isNotEmpty(dtlsCheckData)) {
harmonicResult.setAdType(dtlsCheckData.get(0).getValueType()); harmonicResult.setAdType(dtlsCheckData.get(0).getValueType());
} }
//电压下百分比给百分比直接算 电流是是下百分比给的是幅值要转换算
List<DetectionData> integerBooleanA = harmRangeComparison(new ArrayList<>(), type, TYPE_A, sourceIssue, dataRule, devHarmMap.get(TYPE_A), fData, num); List<DetectionData> integerBooleanA = harmRangeComparison(new ArrayList<>(), type, TYPE_A, sourceIssue, dataRule, devHarmMap.get(TYPE_A), fData, num);
List<DetectionData> integerBooleanB = harmRangeComparison(new ArrayList<>(), type, TYPE_B, sourceIssue, dataRule, devHarmMap.get(TYPE_B), fData, num); List<DetectionData> integerBooleanB = harmRangeComparison(new ArrayList<>(), type, TYPE_B, sourceIssue, dataRule, devHarmMap.get(TYPE_B), fData, num);
List<DetectionData> integerBooleanC = harmRangeComparison(new ArrayList<>(), type, TYPE_C, sourceIssue, dataRule, devHarmMap.get(TYPE_C), fData, num); List<DetectionData> integerBooleanC = harmRangeComparison(new ArrayList<>(), type, TYPE_C, sourceIssue, dataRule, devHarmMap.get(TYPE_C), fData, num);
@@ -809,8 +810,10 @@ public class DetectionServiceImpl {
} else { } else {
Double percent; Double percent;
if (I.equals(type)) { if (I.equals(type)) {
//电流是百分比转换成赋值算的
percent = fData * 0.01; percent = fData * 0.01;
} else { } else {
//电压是百分比算的
percent = 1.0; percent = 1.0;
} }
if (1 == num) { if (1 == num) {

View File

@@ -17,6 +17,11 @@ public class TreeDataVO {
*/ */
private String scriptTypeName; private String scriptTypeName;
/**
* code
*/
private String scriptTypeCode;
/** /**
* 源下发的描述 * 源下发的描述
*/ */

View File

@@ -167,6 +167,7 @@ public class ResultServiceImpl implements IResultService {
//大相检测信息 //大相检测信息
TreeDataVO infoVO = new TreeDataVO(); TreeDataVO infoVO = new TreeDataVO();
infoVO.setScriptTypeName(dictTree.getName()); infoVO.setScriptTypeName(dictTree.getName());
infoVO.setScriptTypeCode(dictTree.getId());
//额定条件下频率准确度测试 //额定条件下频率准确度测试
LinkedHashMap<String, List<PqScriptDtls>> subTypeMap = value.stream() LinkedHashMap<String, List<PqScriptDtls>> subTypeMap = value.stream()
.sorted(Comparator.comparing(PqScriptDtls::getIndex)) .sorted(Comparator.comparing(PqScriptDtls::getIndex))
@@ -176,6 +177,7 @@ public class ResultServiceImpl implements IResultService {
if (!"VOLTAGE".equals(dictTree.getCode())) { if (!"VOLTAGE".equals(dictTree.getCode())) {
TreeDataVO subType = new TreeDataVO(); TreeDataVO subType = new TreeDataVO();
subType.setScriptTypeName(subName.get(subKey).replace("XX", dictTree.getName())); subType.setScriptTypeName(subName.get(subKey).replace("XX", dictTree.getName()));
subType.setScriptTypeCode(subKey);
LinkedHashMap<Integer, List<PqScriptDtls>> indexMap = subValue.stream() LinkedHashMap<Integer, List<PqScriptDtls>> indexMap = subValue.stream()
.sorted(Comparator.comparing(PqScriptDtls::getIndex)) .sorted(Comparator.comparing(PqScriptDtls::getIndex))
.collect(Collectors.groupingBy(PqScriptDtls::getIndex, LinkedHashMap::new, Collectors.toList())); .collect(Collectors.groupingBy(PqScriptDtls::getIndex, LinkedHashMap::new, Collectors.toList()));
@@ -212,11 +214,13 @@ public class ResultServiceImpl implements IResultService {
if (CollUtil.isNotEmpty(subSingleTypeMap)) { if (CollUtil.isNotEmpty(subSingleTypeMap)) {
TreeDataVO subType = new TreeDataVO(); TreeDataVO subType = new TreeDataVO();
subType.setScriptTypeName(subName.get("Single").replace("XX", dictTree.getName())); subType.setScriptTypeName(subName.get("Single").replace("XX", dictTree.getName()));
subType.setScriptTypeCode(dictTree.getCode());
//单影响量下频率准测量集合 //单影响量下频率准测量集合
List<TreeDataVO> subSingleList = new ArrayList<>(); List<TreeDataVO> subSingleList = new ArrayList<>();
subSingleTypeMap.forEach((subKey, subValue) -> { subSingleTypeMap.forEach((subKey, subValue) -> {
TreeDataVO treeDataVO = new TreeDataVO(); TreeDataVO treeDataVO = new TreeDataVO();
treeDataVO.setScriptTypeName(subName.get(subKey).replace("XX", dictTree.getName())); treeDataVO.setScriptTypeName(subName.get(subKey).replace("XX", dictTree.getName()));
treeDataVO.setScriptTypeCode(subKey);
List<TreeDataVO> subTypeList = new ArrayList<>(); List<TreeDataVO> subTypeList = new ArrayList<>();
LinkedHashMap<Integer, List<PqScriptDtls>> indexMap = subValue.stream() LinkedHashMap<Integer, List<PqScriptDtls>> indexMap = subValue.stream()

View File

@@ -130,7 +130,7 @@ public class PqScriptController extends BaseController {
@ApiOperation("获取指定模式下的所有检测脚本") @ApiOperation("获取指定模式下的所有检测脚本")
@ApiImplicitParam(name = "patternId", value = "模式Id", required = true) @ApiImplicitParam(name = "patternId", value = "模式Id", required = true)
public HttpResult<List<Map<String, Object>>> getAllPqScript(@RequestParam("patternId") String patternId) { public HttpResult<List<Map<String, Object>>> getAllPqScript(@RequestParam("patternId") String patternId) {
String methodDescribe = getMethodDescribe("getAllPqScript"); String methodDescribe = getMethodDescribe("getAll");
LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, patternId); LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, patternId);
List<Map<String, Object>> result = pqScriptService.listAllPqScript(patternId); List<Map<String, Object>> result = pqScriptService.listAllPqScript(patternId);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
@@ -142,7 +142,7 @@ public class PqScriptController extends BaseController {
@ApiOperation("根据脚本id查询检测脚本详情") @ApiOperation("根据脚本id查询检测脚本详情")
@ApiImplicitParam(name = "id", value = "检测脚本id", required = true) @ApiImplicitParam(name = "id", value = "检测脚本id", required = true)
public HttpResult<List<SourceIssue>> dls(@RequestBody PqScriptIssueParam param) { public HttpResult<List<SourceIssue>> dls(@RequestBody PqScriptIssueParam param) {
String methodDescribe = getMethodDescribe("list"); String methodDescribe = getMethodDescribe("dlsDetails");
LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, param); LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, param);
List<SourceIssue> sourceIssues = pqScriptDtlsService.listSourceIssue(param); List<SourceIssue> sourceIssues = pqScriptDtlsService.listSourceIssue(param);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, sourceIssues, methodDescribe); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, sourceIssues, methodDescribe);
@@ -154,10 +154,10 @@ public class PqScriptController extends BaseController {
@ApiOperation("添加检测脚本") @ApiOperation("添加检测脚本")
@ApiImplicitParam(name = "id", value = "检测脚本id", required = true) @ApiImplicitParam(name = "id", value = "检测脚本id", required = true)
public HttpResult<Boolean> addScriptDtls(@RequestBody PqScriptDtlsParam sourceIssue) { public HttpResult<Boolean> addScriptDtls(@RequestBody PqScriptDtlsParam sourceIssue) {
String methodDescribe = getMethodDescribe("list"); String methodDescribe = getMethodDescribe("addScriptDtls");
LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, sourceIssue); LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, sourceIssue);
Boolean b = pqScriptDtlsService.saveScriptDtls(sourceIssue); Boolean b = pqScriptDtlsService.saveScriptDtls(sourceIssue);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, b, methodDescribe); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, b , methodDescribe);
} }
} }

View File

@@ -6,11 +6,11 @@
<select id="selectMaxIndex" resultType="java.lang.Integer"> <select id="selectMaxIndex" resultType="java.lang.Integer">
SELECT SELECT
max( t.INDEX ) IFNULL( max( t.INDEX ), -1 ) AS num
FROM FROM
pq_script_dtls t pq_script_dtls t
WHERE WHERE
Script_Id = ${scriptId} Script_Id = #{scriptId}
</select> </select>
</mapper> </mapper>

View File

@@ -1,9 +1,7 @@
package com.njcn.gather.script.pojo.param; package com.njcn.gather.script.pojo.param;
import com.alibaba.fastjson.annotation.JSONField; import com.alibaba.fastjson.annotation.JSONField;
import com.njcn.gather.script.pojo.po.SourceIssue;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List; import java.util.List;
@@ -60,7 +58,7 @@ public class PqScriptDtlsParam {
private Double fFreq; private Double fFreq;
/** /**
* * 装置下发参数
*/ */
@JSONField(name = "channelList", ordinal = 7) @JSONField(name = "channelList", ordinal = 7)
private List<CheckData> checkDataList; private List<CheckData> checkDataList;
@@ -69,10 +67,8 @@ public class PqScriptDtlsParam {
* 通道信息 * 通道信息
*/ */
@JSONField(name = "channelList", ordinal = 8) @JSONField(name = "channelList", ordinal = 8)
private List<SourceIssue.ChannelListDTO> channelList; private List<ChannelListDTO> channelList;
@NoArgsConstructor
@Data @Data
public static class CheckData { public static class CheckData {
@@ -110,9 +106,10 @@ public class PqScriptDtlsParam {
* 是否参与误差比较0-不参与 1-参与 * 是否参与误差比较0-不参与 1-参与
*/ */
private Integer errorFlag; private Integer errorFlag;
} }
@NoArgsConstructor
@Data @Data
public static class ChannelListDTO { public static class ChannelListDTO {
@@ -168,31 +165,30 @@ public class PqScriptDtlsParam {
* 谐波叠加列表 * 谐波叠加列表
*/ */
@JSONField(name = "harmList", ordinal = 9) @JSONField(name = "harmList", ordinal = 9)
private List<SourceIssue.ChannelListDTO.HarmModel> harmList; private List<HarmModel> harmList;
/** /**
* 间谐波叠加列表 * 间谐波叠加列表
*/ */
@JSONField(name = "inharmList", ordinal = 10) @JSONField(name = "inharmList", ordinal = 10)
private List<SourceIssue.ChannelListDTO.InharmModel> inharmList; private List<InharmModel> inharmList;
/** /**
* 暂态数据 * 暂态数据
*/ */
@JSONField(name = "dipData", ordinal = 11) @JSONField(name = "dipData", ordinal = 11)
private SourceIssue.ChannelListDTO.DipDataDTO dipData; private DipDataDTO dipData;
/** /**
* 闪变数据 * 闪变数据
*/ */
@JSONField(name = "flickerData", ordinal = 12) @JSONField(name = "flickerData", ordinal = 12)
private SourceIssue.ChannelListDTO.FlickerDataDTO flickerData; private FlickerDataDTO flickerData;
/** /**
* 谐波叠加列表 * 谐波叠加列表
*/ */
@NoArgsConstructor
@Data @Data
public static class HarmModel { public static class HarmModel {
@@ -219,7 +215,6 @@ public class PqScriptDtlsParam {
/** /**
* 间谐波叠加列表 * 间谐波叠加列表
*/ */
@NoArgsConstructor
@Data @Data
public static class InharmModel { public static class InharmModel {
@@ -247,7 +242,6 @@ public class PqScriptDtlsParam {
/** /**
* 暂态数据 * 暂态数据
*/ */
@NoArgsConstructor
@Data @Data
public static class DipDataDTO { public static class DipDataDTO {
@@ -294,7 +288,6 @@ public class PqScriptDtlsParam {
/** /**
* 闪变数据 * 闪变数据
*/ */
@NoArgsConstructor
@Data @Data
public static class FlickerDataDTO { public static class FlickerDataDTO {

View File

@@ -32,7 +32,7 @@ public class PqScriptDtls implements Serializable {
/** /**
* 总检测脚本中的测试项序号 * 总检测脚本中的测试项序号
*/ */
@TableField("Index") @TableField("`index`")
private Integer index; private Integer index;
/** /**

View File

@@ -5,7 +5,6 @@ import com.njcn.gather.script.pojo.param.PqScriptDtlsParam;
import com.njcn.gather.script.pojo.param.PqScriptIssueParam; import com.njcn.gather.script.pojo.param.PqScriptIssueParam;
import com.njcn.gather.script.pojo.po.PqScriptDtls; import com.njcn.gather.script.pojo.po.PqScriptDtls;
import com.njcn.gather.script.pojo.po.SourceIssue; import com.njcn.gather.script.pojo.po.SourceIssue;
import com.njcn.gather.script.pojo.vo.PqScriptDtlDataVO;
import java.util.List; import java.util.List;
@@ -83,7 +82,7 @@ public interface IPqScriptDtlsService extends IService<PqScriptDtls> {
* 查询当前检测小项的信息 * 查询当前检测小项的信息
* @return * @return
*/ */
List<PqScriptDtlDataVO> scriptDtlsList(); List<PqScriptDtlsParam.CheckData> scriptDtlsList(PqScriptDtlsParam sourceIssue);
Boolean saveCheck(); Boolean saveCheck();
} }

View File

@@ -8,6 +8,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.yulichang.wrapper.MPJLambdaWrapper; import com.github.yulichang.wrapper.MPJLambdaWrapper;
import com.njcn.common.pojo.enums.common.DataStateEnum; import com.njcn.common.pojo.enums.common.DataStateEnum;
import com.njcn.gather.detection.pojo.enums.DetectionCodeEnum;
import com.njcn.gather.device.pojo.po.PqDev; import com.njcn.gather.device.pojo.po.PqDev;
import com.njcn.gather.device.service.IPqDevService; import com.njcn.gather.device.service.IPqDevService;
import com.njcn.gather.device.pojo.enums.CommonEnum; import com.njcn.gather.device.pojo.enums.CommonEnum;
@@ -20,11 +21,12 @@ import com.njcn.gather.script.pojo.po.PqScript;
import com.njcn.gather.script.pojo.po.PqScriptCheckData; import com.njcn.gather.script.pojo.po.PqScriptCheckData;
import com.njcn.gather.script.pojo.po.PqScriptDtls; import com.njcn.gather.script.pojo.po.PqScriptDtls;
import com.njcn.gather.script.pojo.po.SourceIssue; import com.njcn.gather.script.pojo.po.SourceIssue;
import com.njcn.gather.script.pojo.vo.PqScriptDtlDataVO;
import com.njcn.gather.script.service.IPqScriptCheckDataService; import com.njcn.gather.script.service.IPqScriptCheckDataService;
import com.njcn.gather.script.service.IPqScriptDtlsService; import com.njcn.gather.script.service.IPqScriptDtlsService;
import com.njcn.gather.script.util.ScriptDtlsDesc; import com.njcn.gather.script.util.ScriptDtlsDesc;
import com.njcn.gather.script.util.UnbanUtil;
import com.njcn.gather.system.dictionary.pojo.po.DictTree; import com.njcn.gather.system.dictionary.pojo.po.DictTree;
import com.njcn.gather.system.dictionary.service.IDictTreeService;
import com.njcn.gather.type.pojo.po.DevType; import com.njcn.gather.type.pojo.po.DevType;
import com.njcn.gather.type.service.IDevTypeService; import com.njcn.gather.type.service.IDevTypeService;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
@@ -75,6 +77,7 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl<PqScriptDtlsMapper, PqS
private final PqScriptMapper pqScriptMapper; private final PqScriptMapper pqScriptMapper;
private final IPqScriptCheckDataService pqScriptCheckDataService; private final IPqScriptCheckDataService pqScriptCheckDataService;
private final IDevTypeService devTypeService; private final IDevTypeService devTypeService;
private final IDictTreeService dictTreeService;
@Override @Override
@Transactional(rollbackFor = {Exception.class}) @Transactional(rollbackFor = {Exception.class})
@@ -117,19 +120,27 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl<PqScriptDtlsMapper, PqS
@Override @Override
public List<SourceIssue> listSourceIssue(PqScriptIssueParam param) { public List<SourceIssue> listSourceIssue(PqScriptIssueParam param) {
List<SourceIssue> sourceIssues = new ArrayList<>(); List<SourceIssue> sourceIssues = new ArrayList<>();
//校验终端额定电压电流是否相同 Set<Double> voltSet =new HashSet<>(1);
List<PqDev> list = pqDevService.list(new LambdaQueryWrapper<PqDev>() Set<Double> currSet =new HashSet<>(1);
.eq(PqDev::getPlanId, param.getPlanId()) if(CollUtil.isNotEmpty(param.getDevIds())){
.in(PqDev::getId, param.getDevIds()) //校验终端额定电压电流是否相同
.eq(PqDev::getState, DataStateEnum.ENABLE.getCode()) List<PqDev> list = pqDevService.list(new LambdaQueryWrapper<PqDev>()
); .eq(PqDev::getPlanId, param.getPlanId())
Set<String> devTypeSet = list.stream().map(PqDev::getDevType).collect(Collectors.toSet()); .in(PqDev::getId, param.getDevIds())
List<DevType> devTypes = devTypeService.listByIds(devTypeSet); .eq(PqDev::getState, DataStateEnum.ENABLE.getCode())
);
Set<String> devTypeSet = list.stream().map(PqDev::getDevType).collect(Collectors.toSet());
List<DevType> devTypes = devTypeService.listByIds(devTypeSet);
//额定电压信息
voltSet = devTypes.stream().map(DevType::getDevVolt).collect(Collectors.toSet());
//额定电流信息
currSet = devTypes.stream().map(DevType::getDevCurr).collect(Collectors.toSet());
}else{
voltSet.add(1.0);
currSet.add(1.0);
param.setIsPhaseSequence("-1");
}
//额定电压信息
Set<Double> voltSet = devTypes.stream().map(DevType::getDevVolt).collect(Collectors.toSet());
//额定电流信息
Set<Double> currSet = devTypes.stream().map(DevType::getDevCurr).collect(Collectors.toSet());
if (voltSet.size() == 1 && currSet.size() == 1) { if (voltSet.size() == 1 && currSet.size() == 1) {
Double volt = voltSet.stream().collect(Collectors.toList()).stream().findFirst().get(); Double volt = voltSet.stream().collect(Collectors.toList()).stream().findFirst().get();
@@ -162,7 +173,7 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl<PqScriptDtlsMapper, PqS
issue.setType(freqDtls.getScriptCode()); issue.setType(freqDtls.getScriptCode());
issue.setIndex(freqDtls.getIndex()); issue.setIndex(freqDtls.getIndex());
String scriptSubType = freqDtls.getScriptSubType(); String scriptSubType = freqDtls.getScriptSubType();
issue.setSubType(StrUtil.isBlank(scriptSubType) ? scriptSubType : scriptSubType.replace("Base", "NULL")); issue.setSubType(StrUtil.isBlank(scriptSubType)&&CollUtil.isNotEmpty(param.getDevIds()) ? scriptSubType : scriptSubType.replace("Base", "NULL"));
PqScriptCheckDataParam checkDataParam = new PqScriptCheckDataParam(); PqScriptCheckDataParam checkDataParam = new PqScriptCheckDataParam();
checkDataParam.setScriptId(freqDtls.getScriptId()); checkDataParam.setScriptId(freqDtls.getScriptId());
checkDataParam.setIndex(freqDtls.getIndex()); checkDataParam.setIndex(freqDtls.getIndex());
@@ -228,34 +239,37 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl<PqScriptDtlsMapper, PqS
public Boolean saveScriptDtls(PqScriptDtlsParam sourceIssue) { public Boolean saveScriptDtls(PqScriptDtlsParam sourceIssue) {
List<PqScriptDtls> info = new ArrayList<>(); List<PqScriptDtls> info = new ArrayList<>();
List<PqScriptCheckData> checkList = new ArrayList<>(); List<PqScriptCheckData> checkList = new ArrayList<>();
Integer i=sourceIssue.getIndex(); Integer i = sourceIssue.getIndex();
if(ObjectUtil.isNotNull(sourceIssue.getIndex())){ if (ObjectUtil.isNotNull(sourceIssue.getIndex())) {
this.remove(new MPJLambdaWrapper<PqScriptDtls>() this.remove(new MPJLambdaWrapper<PqScriptDtls>()
.eq(PqScriptDtls::getScriptId,sourceIssue.getScriptId()) .eq(PqScriptDtls::getScriptId, sourceIssue.getScriptId())
.eq(PqScriptDtls::getIndex,sourceIssue.getIndex()) .eq(PqScriptDtls::getIndex, sourceIssue.getIndex())
); );
pqScriptCheckDataService.remove(new MPJLambdaWrapper<PqScriptCheckData>() pqScriptCheckDataService.remove(new MPJLambdaWrapper<PqScriptCheckData>()
.eq(PqScriptCheckData::getScriptId,sourceIssue.getScriptId()) .eq(PqScriptCheckData::getScriptId, sourceIssue.getScriptId())
.eq(PqScriptCheckData::getIndex,sourceIssue.getIndex()) .eq(PqScriptCheckData::getIndex, sourceIssue.getIndex())
); );
}else{ } else {
i = this.baseMapper.selectMaxIndex(sourceIssue.getScriptId()); i = this.baseMapper.selectMaxIndex(sourceIssue.getScriptId()) + 1;
} }
List<PqScriptDtlsParam.CheckData> checkDataList = sourceIssue.getCheckDataList(); List<PqScriptDtlsParam.CheckData> checkDataList = sourceIssue.getCheckDataList();
PqScriptCheckData data; PqScriptCheckData data;
for (PqScriptDtlsParam.CheckData checkData : checkDataList) { if (CollUtil.isNotEmpty(checkDataList)) {
data=new PqScriptCheckData(); for (PqScriptDtlsParam.CheckData checkData : checkDataList) {
data.setScriptId(sourceIssue.getScriptId()); data = new PqScriptCheckData();
data.setIndex(i); data.setScriptId(sourceIssue.getScriptId());
data.setValueType(checkData.getValueType()); data.setIndex(i);
data.setDataType(checkData.getDataType()); data.setValueType(checkData.getValueType());
data.setPhase(checkData.getPhase()); data.setDataType(checkData.getDataType());
data.setValue(checkData.getValue()); data.setPhase(checkData.getPhase());
data.setHarmNum(checkData.getHarmNum()); data.setValue(checkData.getValue());
data.setEnable(checkData.getEnable()); data.setHarmNum(checkData.getHarmNum());
data.setErrorFlag(checkData.getErrorFlag()); data.setEnable(checkData.getEnable());
checkList.add(data); data.setErrorFlag(checkData.getErrorFlag());
checkList.add(data);
}
} }
//频率赋值 //频率赋值
PqScriptDtls dtls = setScriptDtls(sourceIssue, i); PqScriptDtls dtls = setScriptDtls(sourceIssue, i);
dtls.setValueType(FREQ); dtls.setValueType(FREQ);
@@ -263,95 +277,307 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl<PqScriptDtlsMapper, PqS
dtls.setValue(sourceIssue.getFFreq()); dtls.setValue(sourceIssue.getFFreq());
dtls.setAngle(0.0); dtls.setAngle(0.0);
info.add(dtls); info.add(dtls);
//开始遍历通道信息 if (CollUtil.isNotEmpty(sourceIssue.getChannelList())) {
for (SourceIssue.ChannelListDTO channelListDTO : sourceIssue.getChannelList()) { //开始遍历通道信息
String phase = channelListDTO.getChannelType().substring(0, 1); for (PqScriptDtlsParam.ChannelListDTO channelListDTO : sourceIssue.getChannelList()) {
//电压或者电流 String phase = channelListDTO.getChannelType().substring(1, 2).toUpperCase();
if (channelListDTO.getChannelFlag()) { //电压或者电流
PqScriptDtls uOri = setScriptDtls(sourceIssue, i); if (channelListDTO.getChannelFlag()) {
uOri.setPhase(phase); PqScriptDtls uOri = setScriptDtls(sourceIssue, i);
if (channelListDTO.getChannelType().contains("U")) { uOri.setPhase(phase);
uOri.setValueType(VOL);
}
if (channelListDTO.getChannelType().contains("I")) {
uOri.setValueType(CUR);
}
uOri.setValue(channelListDTO.getFAmp());
uOri.setAngle(channelListDTO.getFPhase());
info.add(uOri);
}
//谐波值
if (channelListDTO.getHarmFlag()) {
List<SourceIssue.ChannelListDTO.HarmModel> harmList = channelListDTO.getHarmList();
for (SourceIssue.ChannelListDTO.HarmModel harmModel : harmList) {
PqScriptDtls harm = setScriptDtls(sourceIssue, i);
if (channelListDTO.getChannelType().contains("U")) { if (channelListDTO.getChannelType().contains("U")) {
harm.setValueType(HARM_V); uOri.setValueType(VOL);
} }
if (channelListDTO.getChannelType().contains("I")) { if (channelListDTO.getChannelType().contains("I")) {
harm.setValueType(HARM_I); uOri.setValueType(CUR);
} }
harm.setPhase(phase); uOri.setValue(channelListDTO.getFAmp());
harm.setHarmNum(harmModel.getHarm()); uOri.setAngle(channelListDTO.getFPhase());
harm.setValue(harmModel.getFAmp()); info.add(uOri);
harm.setAngle(harmModel.getFPhase());
info.add(harm);
} }
} //谐波值
//间谐波 if (channelListDTO.getHarmFlag()) {
if (channelListDTO.getInHarmFlag()) { List<PqScriptDtlsParam.ChannelListDTO.HarmModel> harmList = channelListDTO.getHarmList();
List<SourceIssue.ChannelListDTO.InharmModel> inharmList = channelListDTO.getInharmList(); for (PqScriptDtlsParam.ChannelListDTO.HarmModel harmModel : harmList) {
for (SourceIssue.ChannelListDTO.InharmModel inharmModel : inharmList) { PqScriptDtls harm = setScriptDtls(sourceIssue, i);
PqScriptDtls inHarm = setScriptDtls(sourceIssue, i); if (channelListDTO.getChannelType().contains("U")) {
if (channelListDTO.getChannelType().contains("U")) { harm.setValueType(HARM_V);
inHarm.setValueType(INHARM_V); }
if (channelListDTO.getChannelType().contains("I")) {
harm.setValueType(HARM_I);
}
harm.setPhase(phase);
harm.setHarmNum(harmModel.getHarm());
harm.setValue(harmModel.getFAmp());
harm.setAngle(harmModel.getFPhase());
info.add(harm);
} }
if (channelListDTO.getChannelType().contains("I")) {
inHarm.setValueType(INHARM_I);
}
inHarm.setPhase(phase);
inHarm.setHarmNum(inharmModel.getInharm());
inHarm.setValue(inharmModel.getFAmp());
inHarm.setAngle(inharmModel.getFPhase());
info.add(inHarm);
} }
} //间谐波
//暂态 if (channelListDTO.getInHarmFlag()) {
if (channelListDTO.getDipFlag()) { List<PqScriptDtlsParam.ChannelListDTO.InharmModel> inharmList = channelListDTO.getInharmList();
SourceIssue.ChannelListDTO.DipDataDTO dipData = channelListDTO.getDipData(); for (PqScriptDtlsParam.ChannelListDTO.InharmModel inharmModel : inharmList) {
PqScriptDtls dip = setScriptDtls(sourceIssue, i); PqScriptDtls inHarm = setScriptDtls(sourceIssue, i);
dip.setValueType(DIP); if (channelListDTO.getChannelType().contains("U")) {
dip.setPhase(phase); inHarm.setValueType(INHARM_V);
dip.setTransValue(dipData.getFTransValue()); }
dip.setRetainTime(dipData.getRetainTime()); if (channelListDTO.getChannelType().contains("I")) {
info.add(dip); inHarm.setValueType(INHARM_I);
}
inHarm.setPhase(phase);
inHarm.setHarmNum(inharmModel.getInharm());
inHarm.setValue(inharmModel.getFAmp());
inHarm.setAngle(inharmModel.getFPhase());
info.add(inHarm);
}
}
//暂态
if (channelListDTO.getDipFlag()) {
PqScriptDtlsParam.ChannelListDTO.DipDataDTO dipData = channelListDTO.getDipData();
PqScriptDtls dip = setScriptDtls(sourceIssue, i);
dip.setValueType(DIP);
dip.setPhase(phase);
dip.setTransValue(dipData.getFTransValue());
dip.setRetainTime(dipData.getRetainTime());
info.add(dip);
} }
//闪变 //闪变
if (channelListDTO.getFlickerFlag()) { if (channelListDTO.getFlickerFlag()) {
SourceIssue.ChannelListDTO.FlickerDataDTO flickerData = channelListDTO.getFlickerData(); PqScriptDtlsParam.ChannelListDTO.FlickerDataDTO flickerData = channelListDTO.getFlickerData();
PqScriptDtls dip = setScriptDtls(sourceIssue, i); PqScriptDtls dip = setScriptDtls(sourceIssue, i);
dip.setValueType(DIP); dip.setValueType(FLICKER);
dip.setPhase(phase); dip.setPhase(phase);
dip.setChagFre(flickerData.getFChagFre()); dip.setChagFre(flickerData.getFChagFre());
dip.setChagValue(flickerData.getFChagValue()); dip.setChagValue(flickerData.getFChagValue());
info.add(dip); info.add(dip);
}
} }
} }
if (CollUtil.isNotEmpty(info)) { if (CollUtil.isNotEmpty(info)) {
this.saveBatch(info); this.saveBatch(info);
} }
if(CollUtil.isNotEmpty(checkList)){ if (CollUtil.isNotEmpty(checkList)) {
pqScriptCheckDataService.saveBatch(checkList); pqScriptCheckDataService.saveBatch(checkList);
} }
return true; return true;
} }
@Override @Override
public List<PqScriptDtlDataVO> scriptDtlsList() { public List<PqScriptDtlsParam.CheckData> scriptDtlsList(PqScriptDtlsParam sourceIssue) {
return Collections.emptyList(); List<PqScriptDtlsParam.CheckData> info=new ArrayList<>();
//获取所有下拉值情况
List<PqScriptDtlsParam.CheckData> checkDataList = sourceIssue.getCheckDataList();
if(CollUtil.isNotEmpty(checkDataList)){
List<String> ids = checkDataList.stream().map(PqScriptDtlsParam.CheckData::getValueType).collect(Collectors.toList());
List<DictTree> dictTreeById = dictTreeService.getDictTreeById(ids);
Map<String, String> dicTreeMap = dictTreeById.stream().collect(Collectors.toMap(DictTree::getId, DictTree::getCode));
PqScriptDtlsParam.CheckData checkData;
for (PqScriptDtlsParam.CheckData channelListDTO : checkDataList) {
if(dicTreeMap.containsKey(channelListDTO.getValueType())){
String code = dicTreeMap.get(channelListDTO.getValueType());
DetectionCodeEnum codeEnum = DetectionCodeEnum.getDetectionCodeByCode(code);
List<PqScriptDtlsParam.ChannelListDTO> channelList = sourceIssue.getChannelList();
List<PqScriptDtlsParam.ChannelListDTO> list;
switch (codeEnum){
case FREQ:
checkData=new PqScriptDtlsParam.CheckData();
checkData.setErrorFlag(channelListDTO.getErrorFlag());
checkData.setEnable(channelListDTO.getEnable());
checkData.setValue(sourceIssue.getFFreq());
checkData.setPhase("T");
checkData.setDataType(channelListDTO.getDataType());
checkData.setValueType(channelListDTO.getValueType());
info.add(checkData);
break;
case U1:
case VRMS:
if(CollUtil.isNotEmpty(channelList)){
list = channelList.stream().filter(x -> x.getChannelType().contains("U")).collect(Collectors.toList());
rmsCheck(info, channelListDTO, list);
}
break;
case DELTA_V:
if(CollUtil.isNotEmpty(channelList)){
list = channelList.stream().filter(x -> x.getChannelType().contains("U")).collect(Collectors.toList());
for (PqScriptDtlsParam.ChannelListDTO listDTO : list) {
checkData=new PqScriptDtlsParam.CheckData();
checkData.setErrorFlag(channelListDTO.getErrorFlag());
checkData.setEnable(channelListDTO.getEnable());
checkData.setValue(0.0);
checkData.setPhase(listDTO.getChannelType().substring(1,2));
checkData.setDataType(channelListDTO.getDataType());
checkData.setValueType(channelListDTO.getValueType());
info.add(checkData);
}
}
break;
case VA:
if(CollUtil.isNotEmpty(channelList)){
list = channelList.stream().filter(x -> x.getChannelType().contains("U")).collect(Collectors.toList());
for (PqScriptDtlsParam.ChannelListDTO listDTO : list) {
checkData=new PqScriptDtlsParam.CheckData();
checkData.setErrorFlag(channelListDTO.getErrorFlag());
checkData.setEnable(channelListDTO.getEnable());
checkData.setValue(listDTO.getFPhase());
checkData.setPhase(listDTO.getChannelType().substring(1,2));
checkData.setDataType(channelListDTO.getDataType());
checkData.setValueType(channelListDTO.getValueType());
info.add(checkData);
}
}
break;
case V2_50:
if(CollUtil.isNotEmpty(channelList)){
list = channelList.stream().filter(x -> x.getChannelType().contains("U")).collect(Collectors.toList());
harmCheck(info, channelListDTO, list);
}
break;
case I2_50:
if(CollUtil.isNotEmpty(channelList)){
list = channelList.stream().filter(x -> x.getChannelType().contains("I")).collect(Collectors.toList());
harmCheck(info, channelListDTO, list);
}
break;
case P2_50:
break;
case SV_1_49:
if(CollUtil.isNotEmpty(channelList)){
list = channelList.stream().filter(x -> x.getChannelType().contains("U")).collect(Collectors.toList());
inHarmCheck(info, channelListDTO, list);
}
break;
case SI_1_49:
if(CollUtil.isNotEmpty(channelList)){
list= channelList.stream().filter(x -> x.getChannelType().contains("I")).collect(Collectors.toList());
inHarmCheck(info, channelListDTO, list);
}
break;
case MAG:
list= channelList.stream().filter(x -> x.getChannelType().contains("U")).collect(Collectors.toList());
for (PqScriptDtlsParam.ChannelListDTO listDTO : list) {
checkData=new PqScriptDtlsParam.CheckData();
checkData.setErrorFlag(channelListDTO.getErrorFlag());
checkData.setEnable(channelListDTO.getEnable());
checkData.setValue(listDTO.getDipData().getFTransValue());
checkData.setPhase(listDTO.getChannelType().substring(1,2));
checkData.setDataType(channelListDTO.getDataType());
checkData.setValueType(channelListDTO.getValueType());
info.add(checkData);
}
break;
case DUR:
list = channelList.stream().filter(x -> x.getChannelType().contains("U")).collect(Collectors.toList());
for (PqScriptDtlsParam.ChannelListDTO listDTO : list) {
checkData=new PqScriptDtlsParam.CheckData();
checkData.setErrorFlag(channelListDTO.getErrorFlag());
checkData.setEnable(channelListDTO.getEnable());
checkData.setValue(listDTO.getDipData().getRetainTime());
checkData.setPhase(listDTO.getChannelType().substring(1,2));
checkData.setDataType(channelListDTO.getDataType());
checkData.setValueType(channelListDTO.getValueType());
info.add(checkData);
}
break;
case IRMS:
case IA:
if(CollUtil.isNotEmpty(channelList)){
list = channelList.stream().filter(x -> x.getChannelType().contains("I")).collect(Collectors.toList());
rmsCheck(info, channelListDTO, list);
}
break;
case V_UNBAN:
list = channelList.stream().filter(x -> x.getChannelType().contains("U")).collect(Collectors.toList());
unbanCheck(info, channelListDTO, channelList, list);
break;
case I_UNBAN:
list = channelList.stream().filter(x -> x.getChannelType().contains("I")).collect(Collectors.toList());
unbanCheck(info, channelListDTO, channelList, list);
break;
case PST:
break;
default:
break;
}
}
}
}
return info;
} }
private void unbanCheck(List<PqScriptDtlsParam.CheckData> info, PqScriptDtlsParam.CheckData channelListDTO, List<PqScriptDtlsParam.ChannelListDTO> channelList, List<PqScriptDtlsParam.ChannelListDTO> list) {
PqScriptDtlsParam.CheckData checkData;
if(CollUtil.isNotEmpty(list)){
PqScriptDtlsParam.ChannelListDTO a = channelList.stream().filter(x -> x.getChannelType().contains("a")).findFirst().get();
PqScriptDtlsParam.ChannelListDTO b = channelList.stream().filter(x -> x.getChannelType().contains("b")).findFirst().get();
PqScriptDtlsParam.ChannelListDTO c = channelList.stream().filter(x -> x.getChannelType().contains("c")).findFirst().get();
checkData=new PqScriptDtlsParam.CheckData();
checkData.setErrorFlag(channelListDTO.getErrorFlag());
checkData.setEnable(channelListDTO.getEnable());
checkData.setValue(UnbanUtil.calculateUnbalance(a.getFAmp(),a.getFPhase(),b.getFAmp(),b.getFPhase(),c.getFAmp(),c.getFPhase()));
checkData.setPhase("T");
checkData.setDataType(channelListDTO.getDataType());
checkData.setValueType(channelListDTO.getValueType());
info.add(checkData);
}
}
private void rmsCheck(List<PqScriptDtlsParam.CheckData> info, PqScriptDtlsParam.CheckData channelListDTO, List<PqScriptDtlsParam.ChannelListDTO> list) {
PqScriptDtlsParam.CheckData checkData;
for (PqScriptDtlsParam.ChannelListDTO listDTO : list) {
checkData=new PqScriptDtlsParam.CheckData();
checkData.setErrorFlag(channelListDTO.getErrorFlag());
checkData.setEnable(channelListDTO.getEnable());
checkData.setValue(listDTO.getFAmp());
checkData.setPhase(listDTO.getChannelType().substring(1,2));
checkData.setDataType(channelListDTO.getDataType());
checkData.setValueType(channelListDTO.getValueType());
info.add(checkData);
}
}
private void inHarmCheck(List<PqScriptDtlsParam.CheckData> info, PqScriptDtlsParam.CheckData channelListDTO, List<PqScriptDtlsParam.ChannelListDTO> uList) {
PqScriptDtlsParam.CheckData checkData;
for (PqScriptDtlsParam.ChannelListDTO listDTO : uList) {
List<PqScriptDtlsParam.ChannelListDTO.InharmModel> inharmList = listDTO.getInharmList();
if(CollUtil.isNotEmpty(inharmList)){
for (PqScriptDtlsParam.ChannelListDTO.InharmModel inharmModel : inharmList) {
checkData=new PqScriptDtlsParam.CheckData();
checkData.setErrorFlag(channelListDTO.getErrorFlag());
checkData.setEnable(channelListDTO.getEnable());
checkData.setValue(inharmModel.getFAmp());
checkData.setPhase(listDTO.getChannelType().substring(1,2));
checkData.setHarmNum(inharmModel.getInharm());
checkData.setDataType(channelListDTO.getDataType());
checkData.setValueType(channelListDTO.getValueType());
info.add(checkData);
}
}
}
}
private void harmCheck(List<PqScriptDtlsParam.CheckData> info, PqScriptDtlsParam.CheckData channelListDTO, List<PqScriptDtlsParam.ChannelListDTO> uList) {
PqScriptDtlsParam.CheckData checkData;
for (PqScriptDtlsParam.ChannelListDTO listDTO : uList) {
List<PqScriptDtlsParam.ChannelListDTO.HarmModel> harmList = listDTO.getHarmList();
if(CollUtil.isNotEmpty(harmList)){
for (PqScriptDtlsParam.ChannelListDTO.HarmModel harmModel : harmList) {
checkData=new PqScriptDtlsParam.CheckData();
checkData.setErrorFlag(channelListDTO.getErrorFlag());
checkData.setEnable(channelListDTO.getEnable());
checkData.setValue(harmModel.getFAmp());
checkData.setPhase(listDTO.getChannelType().substring(1,2));
checkData.setHarmNum(harmModel.getHarm());
checkData.setDataType(channelListDTO.getDataType());
checkData.setValueType(channelListDTO.getValueType());
info.add(checkData);
}
}
}
}
@Override @Override
public Boolean saveCheck() { public Boolean saveCheck() {
return null; return null;
@@ -373,7 +599,7 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl<PqScriptDtlsMapper, PqS
queryWrapper.selectAll(PqScriptDtls.class) queryWrapper.selectAll(PqScriptDtls.class)
.selectAs(DictTree::getCode, PqScriptDtls::getScriptCode) .selectAs(DictTree::getCode, PqScriptDtls::getScriptCode)
.leftJoin(DictTree.class, DictTree::getId, PqScriptDtls::getScriptType) .leftJoin(DictTree.class, DictTree::getId, PqScriptDtls::getScriptType)
.eq(StrUtil.isNotBlank(param.getScriptType()), PqScriptDtls::getScriptType, param.getScriptSubType()) .eq(StrUtil.isNotBlank(param.getScriptType()), PqScriptDtls::getScriptType, param.getScriptType())
.eq(StrUtil.isNotBlank(param.getScriptSubType()), PqScriptDtls::getScriptSubType, param.getScriptSubType()) .eq(StrUtil.isNotBlank(param.getScriptSubType()), PqScriptDtls::getScriptSubType, param.getScriptSubType())
// .eq(PqScriptDtls::getIndex, 1) // .eq(PqScriptDtls::getIndex, 1)
// .le(PqScriptDtls::getIndex, 30) // .le(PqScriptDtls::getIndex, 30)

View File

@@ -0,0 +1,145 @@
package com.njcn.gather.script.util;
import cn.hutool.core.util.NumberUtil;
/**
* @author wr
* @description
* @date 2025/2/19 14:00
*/
public class UnbanUtil {
static class Complex {
double real;
double imag;
Complex(double real, double imag) {
this.real = real;
this.imag = imag;
}
Complex add(Complex other) {
return new Complex(this.real + other.real, this.imag + other.imag);
}
Complex multiply(Complex other) {
double newReal = this.real * other.real - this.imag * other.imag;
double newImag = this.real * other.imag + this.imag * other.real;
return new Complex(newReal, newImag);
}
Complex divideBy3() {
return new Complex(this.real / 3.0, this.imag / 3.0);
}
double magnitude() {
return Math.sqrt(real * real + imag * imag);
}
// 定义旋转因子
static final Complex J120 = new Complex(-0.5, Math.sqrt(3) / 2);
static final Complex J_MINUS_120 = new Complex(-0.5, -Math.sqrt(3) / 2);
}
public static Complex[] calculateSequenceComponents(Complex Ua, Complex Ub, Complex Uc) {
// 计算正序分量
Complex temp1 = Ua.add(Ub.multiply(Complex.J_MINUS_120).add(Uc.multiply(Complex.J120)));
Complex U1 = temp1.divideBy3();
// 计算负序分量
Complex temp2 = Ua.add(Ub.multiply(Complex.J120).add(Uc.multiply(Complex.J_MINUS_120)));
Complex U2 = temp2.divideBy3();
// 计算零序分量
Complex temp0 = Ua.add(Ub).add(Uc);
Complex U0 = temp0.divideBy3();
return new Complex[]{U1, U2, U0};
}
public static double calculateNegativeSequenceImbalance(Complex U1, Complex U2) {
double U1Mag = U1.magnitude();
double U2Mag = U2.magnitude();
return (U2Mag / U1Mag) * 100.0;
}
public static double calculateZeroSequenceImbalance(Complex U1, Complex U0) {
double U1Mag = U1.magnitude();
double U0Mag = U0.magnitude();
return (U0Mag / U1Mag) * 100.0;
}
public static void main(String[] args) {
// 输入三相电压的幅值和相角
double Ua0 = 220.0, thetaA = 0.0; // A相
double Ub0 = 220.0, thetaB = -120.0; // B相
double Uc0 = 220.0, thetaC = 120.0; // C相
// 转换为复数形式
Complex Ua = new Complex(
Ua0 * Math.cos(thetaA * Math.PI / 180.0),
Ua0 * Math.sin(thetaA * Math.PI / 180.0)
);
Complex Ub = new Complex(
Ub0 * Math.cos(thetaB * Math.PI / 180.0),
Ub0 * Math.sin(thetaB * Math.PI / 180.0)
);
Complex Uc = new Complex(
Uc0 * Math.cos(thetaC * Math.PI / 180.0),
Uc0 * Math.sin(thetaC * Math.PI / 180.0)
);
// 计算序分量
Complex[] components = calculateSequenceComponents(Ua, Ub, Uc);
Complex U1 = components[0];
Complex U2 = components[1];
Complex U0 = components[2];
// 输出结果
System.out.printf("正序分量 U1: %.2f + j%.2f%n", U1.real, U1.imag);
System.out.printf("负序分量 U2: %.2f + j%.2f%n", U2.real, U2.imag);
System.out.printf("零序分量 U0: %.2f + j%.2f%n", U0.real, U0.imag);
// 计算不平衡度
double negativeImbalance = calculateNegativeSequenceImbalance(U1, U2);
double zeroImbalance = calculateZeroSequenceImbalance(U1, U0);
System.out.printf("负序不平衡度: %.2f%%%n", negativeImbalance);
System.out.printf("零序不平衡度: %.2f%%%n", zeroImbalance);
}
// 输入三相电压的幅值和相角
public static double calculateUnbalance(double Ua0, double thetaA,
double Ub0, double thetaB,
double Uc0, double thetaC) {
// 转换为复数形式
Complex Ua = new Complex(
Ua0 * Math.cos(thetaA * Math.PI / 180.0),
Ua0 * Math.sin(thetaA * Math.PI / 180.0)
);
Complex Ub = new Complex(
Ub0 * Math.cos(thetaB * Math.PI / 180.0),
Ub0 * Math.sin(thetaB * Math.PI / 180.0)
);
Complex Uc = new Complex(
Uc0 * Math.cos(thetaC * Math.PI / 180.0),
Uc0 * Math.sin(thetaC * Math.PI / 180.0)
);
// 计算序分量
Complex[] components = calculateSequenceComponents(Ua, Ub, Uc);
Complex U1 = components[0];
Complex U2 = components[1];
Complex U0 = components[2];
// 输出结果
System.out.printf("正序分量 U1: %.2f + j%.2f%n", U1.real, U1.imag);
System.out.printf("负序分量 U2: %.2f + j%.2f%n", U2.real, U2.imag);
System.out.printf("零序分量 U0: %.2f + j%.2f%n", U0.real, U0.imag);
// 计算不平衡度
return NumberUtil.round(calculateNegativeSequenceImbalance(U1, U2), 2).doubleValue();
}
}