1.解决相对值脚本电压电流问题

This commit is contained in:
wr
2025-02-27 10:26:51 +08:00
parent bf94ed37d9
commit 19e99fda9e
3 changed files with 30 additions and 3 deletions

View File

@@ -76,6 +76,14 @@ public class PqErrSysParam {
@ApiModelProperty("所属检测脚本")
private String scriptId;
@ApiModelProperty("电压")
private Double un;
@ApiModelProperty("电流")
private Double in;
}
}

View File

@@ -4,12 +4,14 @@ import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
import com.njcn.gather.detection.pojo.enums.DetectionCodeEnum;
import com.njcn.gather.err.mapper.PqErrSysDtlsMapper;
import com.njcn.gather.err.pojo.param.PqErrSysDtlsParam;
import com.njcn.gather.err.pojo.param.PqErrSysParam;
import com.njcn.gather.err.pojo.po.PqErrSysDtls;
import com.njcn.gather.err.pojo.vo.ErrDtlsCheckDataVO;
import com.njcn.gather.err.service.IPqErrSysDtlsService;
import com.njcn.gather.script.mapper.PqScriptMapper;
import com.njcn.gather.script.pojo.param.PqScriptCheckDataParam;
import com.njcn.gather.script.pojo.po.PqScriptCheckData;
import com.njcn.gather.script.service.IPqScriptCheckDataService;
@@ -20,6 +22,7 @@ import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
import java.util.*;
import java.util.stream.Collectors;
@@ -33,7 +36,7 @@ import java.util.stream.Collectors;
public class PqErrSysDtlsServiceImpl extends ServiceImpl<PqErrSysDtlsMapper, PqErrSysDtls> implements IPqErrSysDtlsService {
private final IPqScriptCheckDataService pqScriptCheckDataService;
private final PqScriptMapper pqScriptMapper;
@Override
public List<PqErrSysDtls> listPqErrSysDtlsByPqErrSysId(String pqErrSysId) {
@@ -96,6 +99,7 @@ public class PqErrSysDtlsServiceImpl extends ServiceImpl<PqErrSysDtlsMapper, PqE
checkDataParam.setScriptId(param.getScriptId());
checkDataParam.setIndex(param.getIndex());
List<PqScriptCheckData> list = pqScriptCheckDataService.listCheckDataCode(checkDataParam);
Boolean isValueType = pqScriptMapper.selectScriptIsValueType(param.getScriptId());
List<String> valueType = list.stream().filter(x->x.getErrorFlag()!=0).map(PqScriptCheckData::getValueType).collect(Collectors.toList());
Map<String, List<PqErrSysDtls>> errMap =new HashMap<>(3);
@@ -117,6 +121,21 @@ public class PqErrSysDtlsServiceImpl extends ServiceImpl<PqErrSysDtlsMapper, PqE
dataVO.setValueType(script.getValueType());
dataVO.setValue(script.getValue());
dataVO.setPhase(script.getPhase());
if(isValueType){
if (DetectionCodeEnum.VRMS.getCode().equals(script.getValueTypeCode())) {
BigDecimal volValue = new BigDecimal(script.getValue());
BigDecimal result = volValue.multiply(new BigDecimal(param.getUn().toString()))
.divide(new BigDecimal(100), 4, BigDecimal.ROUND_HALF_UP);
dataVO.setValue(result.doubleValue());
}
if (DetectionCodeEnum.IRMS.getCode().equals(script.getValueTypeCode())) {
BigDecimal volValue = new BigDecimal(script.getValue());
BigDecimal result = volValue.multiply(new BigDecimal(param.getIn().toString()))
.divide(new BigDecimal(100), 4, BigDecimal.ROUND_HALF_UP);
dataVO.setValue(result.doubleValue());
}
}
if(errMap.containsKey(script.getValueType())){
dataVO.setErrSysDtls(errMap.get(script.getValueType()));
}

View File

@@ -823,13 +823,13 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl<PqScriptDtlsMapper, PqS
if (VOL.equals(pqScriptDtl.getValueType())) {
BigDecimal volValue = new BigDecimal(pqScriptDtl.getValue());
BigDecimal result = volValue.multiply(new BigDecimal(volt.toString()))
.divide(new BigDecimal(100), 2, BigDecimal.ROUND_HALF_UP);
.divide(new BigDecimal(100), 4, BigDecimal.ROUND_HALF_UP);
pqScriptDtl.setValue(result.doubleValue());
}
if (CUR.equals(pqScriptDtl.getValueType())) {
BigDecimal volValue = new BigDecimal(pqScriptDtl.getValue());
BigDecimal result = volValue.multiply(new BigDecimal(curr.toString()))
.divide(new BigDecimal(100), 2, BigDecimal.ROUND_HALF_UP);
.divide(new BigDecimal(100), 4, BigDecimal.ROUND_HALF_UP);
pqScriptDtl.setValue(result.doubleValue());
}
}