This commit is contained in:
caozehui
2025-03-08 16:49:54 +08:00
parent efccaae69e
commit 189ffad11d
5 changed files with 47 additions and 19 deletions

View File

@@ -1,6 +1,7 @@
package com.njcn.gather.detection.pojo.param;
import com.njcn.gather.source.pojo.constant.PqSourceValidMessage;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotBlank;
@@ -36,5 +37,8 @@ public class SimulateDetectionParam {
@NotBlank(message = PqSourceValidMessage.ID_NOT_BLANK)
private String sourceId;
/**
* 脚本值类型 1绝对值脚本、2相对值脚本
*/
private int valueType;
}

View File

@@ -246,21 +246,25 @@ public class PreDetectionServiceImpl implements PreDetectionService {
@Override
public void sendScript(SimulateDetectionParam param) {
Channel channel = SocketManager.getChannelByUserId(param.getUserPageId() + source);
if (Objects.isNull(channel) || !channel.isActive()) {
// 进行源通信连接
PreDetectionParam preDetectionParam = new PreDetectionParam();
preDetectionParam.setSourceId(param.getSourceId());
preDetectionParam.setUserPageId(param.getUserPageId());
preDetectionParam.setSendWebMsg(false);
this.sendYtxSocketSimulate(preDetectionParam);
}
// if (Objects.isNull(channel) || !channel.isActive()) {
// // 进行源通信连接
// PreDetectionParam preDetectionParam = new PreDetectionParam();
// preDetectionParam.setSourceId(param.getSourceId());
// preDetectionParam.setUserPageId(param.getUserPageId());
// preDetectionParam.setSendWebMsg(false);
// this.sendYtxSocketSimulate(preDetectionParam);
// }
//组装源控制脚本
PqScriptIssueParam issueParam = new PqScriptIssueParam();
//issueParam.setPlanId(param.getPlanId());
issueParam.setSourceId(param.getSourceId());
//issueParam.setDevIds(param.getDevIds());
issueParam.setScriptId(param.getScriptId());
issueParam.setType(1);
issueParam.setValueType(param.getValueType()); // 设置脚本类型
issueParam.setIsPhaseSequence(SourceOperateCodeEnum.SIMULATE_TEST.getValue());
List<SourceIssue> sourceIssues = pqScriptDtlsService.listSourceIssue(issueParam);
sourceIssues = sourceIssues.stream()
.filter(s -> s.getIndex().equals(param.getScriptIndex()))

View File

@@ -36,4 +36,11 @@ public class PqScriptIssueParam {
@ApiModelProperty("表明指标类型例如Freq频率下的影响、Base额定下的影响、VOL电压下的影响")
private String scriptSubType;
@ApiModelProperty("脚本下发类型")
private int type;
@ApiModelProperty("脚本值类型")
private int valueType;
}

View File

@@ -64,6 +64,7 @@ public interface IPqScriptDtlsService extends IService<PqScriptDtls> {
*/
List<SourceIssue> listSourceIssue(PqScriptIssueParam param);
/**
* 根据脚本类型、脚本id获取index列表
*

View File

@@ -10,9 +10,9 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
import com.njcn.common.pojo.enums.common.DataStateEnum;
import com.njcn.gather.detection.pojo.enums.DetectionCodeEnum;
import com.njcn.gather.device.pojo.enums.CommonEnum;
import com.njcn.gather.device.pojo.po.PqDev;
import com.njcn.gather.device.service.IPqDevService;
import com.njcn.gather.device.pojo.enums.CommonEnum;
import com.njcn.gather.script.mapper.PqScriptCheckDataMapper;
import com.njcn.gather.script.mapper.PqScriptDtlsMapper;
import com.njcn.gather.script.mapper.PqScriptMapper;
@@ -34,7 +34,6 @@ import com.njcn.gather.type.pojo.po.DevType;
import com.njcn.gather.type.service.IDevTypeService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.hamcrest.core.Is;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -144,9 +143,17 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl<PqScriptDtlsMapper, PqS
//额定电流信息
currSet = devTypes.stream().map(DevType::getDevCurr).collect(Collectors.toSet());
} else {
voltSet.add(1.0);
currSet.add(1.0);
param.setIsPhaseSequence("-1");
if (ObjectUtil.isNull(param.getType())) {
voltSet.add(1.0);
currSet.add(1.0);
param.setIsPhaseSequence("-1");
}else {
if (param.getType() == 1) {
voltSet.add(57.74);
currSet.add(5.0);
param.setIsPhaseSequence("-1");
}
}
}
@@ -207,7 +214,7 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl<PqScriptDtlsMapper, PqS
)
.sorted(Comparator.comparing(PqScriptDtls::getPhase))
.collect(Collectors.toList());
issueAdd(volList, dtlsVList, HARM_V, INHARM_V, freqDtls.getValue(), "U", channelListDTOS, checkDataParam,devFly, isValueType);
issueAdd(volList, dtlsVList, HARM_V, INHARM_V, freqDtls.getValue(), "U", channelListDTOS, checkDataParam, devFly, isValueType);
//2.通道电流(ABC)
List<PqScriptDtls> curList = value.stream().filter(x -> CUR.equals(x.getValueType()))
@@ -219,7 +226,7 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl<PqScriptDtlsMapper, PqS
)
.sorted(Comparator.comparing(PqScriptDtls::getPhase))
.collect(Collectors.toList());
issueAdd(curList, dtlsIList, HARM_I, INHARM_I, freqDtls.getValue(), "I", channelListDTOS, checkDataParam,devFly, isValueType);
issueAdd(curList, dtlsIList, HARM_I, INHARM_I, freqDtls.getValue(), "I", channelListDTOS, checkDataParam, devFly, isValueType);
issue.setChannelList(channelListDTOS);
sourceIssues.add(issue);
@@ -824,8 +831,13 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl<PqScriptDtlsMapper, PqS
//先获取检测脚本类型是否相对值 true相对值 false绝对值相对值要乘额定值,绝对值不需要处理)
queryWrapper.eq(PqScriptDtls::getScriptId, param.getScriptId());
pqScriptDtls = this.getBaseMapper().selectJoinList(PqScriptDtls.class, queryWrapper);
if (CollUtil.isNotEmpty(param.getDevIds())) {
Boolean isValueType = pqScriptMapper.selectScriptIsValueType(param.getScriptId());
if (CollUtil.isNotEmpty(param.getDevIds()) || (ObjectUtil.isNotNull(param.getType())&&param.getType()==1)) {
Boolean isValueType;
if (ObjectUtil.isNotNull(param.getValueType()) && param.getValueType() == 2) {
isValueType = true; //相对值脚本
}else {
isValueType = pqScriptMapper.selectScriptIsValueType(param.getScriptId());
}
if (isValueType) {
for (PqScriptDtls pqScriptDtl : pqScriptDtls) {
if (VOL.equals(pqScriptDtl.getValueType())) {
@@ -942,7 +954,7 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl<PqScriptDtlsMapper, PqS
if (CollUtil.isNotEmpty(dipList)) {
PqScriptDtls dip = dipList.get(0);
dipDataDTO.setFTransValue(dip.getTransValue());
if(devFly){
if (devFly) {
if (isValueType) {
dipDataDTO.setFTransValue(dip.getTransValue() * dtls.getValue() * 0.01);
} else {