1.解决相对值脚本电压电流问题
This commit is contained in:
@@ -76,6 +76,14 @@ public class PqErrSysParam {
|
|||||||
|
|
||||||
@ApiModelProperty("所属检测脚本")
|
@ApiModelProperty("所属检测脚本")
|
||||||
private String scriptId;
|
private String scriptId;
|
||||||
|
|
||||||
|
|
||||||
|
@ApiModelProperty("电压")
|
||||||
|
private Double un;
|
||||||
|
|
||||||
|
@ApiModelProperty("电流")
|
||||||
|
private Double in;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,12 +4,14 @@ import cn.hutool.core.collection.CollUtil;
|
|||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
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.gather.detection.pojo.enums.DetectionCodeEnum;
|
||||||
import com.njcn.gather.err.mapper.PqErrSysDtlsMapper;
|
import com.njcn.gather.err.mapper.PqErrSysDtlsMapper;
|
||||||
import com.njcn.gather.err.pojo.param.PqErrSysDtlsParam;
|
import com.njcn.gather.err.pojo.param.PqErrSysDtlsParam;
|
||||||
import com.njcn.gather.err.pojo.param.PqErrSysParam;
|
import com.njcn.gather.err.pojo.param.PqErrSysParam;
|
||||||
import com.njcn.gather.err.pojo.po.PqErrSysDtls;
|
import com.njcn.gather.err.pojo.po.PqErrSysDtls;
|
||||||
import com.njcn.gather.err.pojo.vo.ErrDtlsCheckDataVO;
|
import com.njcn.gather.err.pojo.vo.ErrDtlsCheckDataVO;
|
||||||
import com.njcn.gather.err.service.IPqErrSysDtlsService;
|
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.param.PqScriptCheckDataParam;
|
||||||
import com.njcn.gather.script.pojo.po.PqScriptCheckData;
|
import com.njcn.gather.script.pojo.po.PqScriptCheckData;
|
||||||
import com.njcn.gather.script.service.IPqScriptCheckDataService;
|
import com.njcn.gather.script.service.IPqScriptCheckDataService;
|
||||||
@@ -20,6 +22,7 @@ import org.springframework.beans.BeanUtils;
|
|||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@@ -33,7 +36,7 @@ import java.util.stream.Collectors;
|
|||||||
public class PqErrSysDtlsServiceImpl extends ServiceImpl<PqErrSysDtlsMapper, PqErrSysDtls> implements IPqErrSysDtlsService {
|
public class PqErrSysDtlsServiceImpl extends ServiceImpl<PqErrSysDtlsMapper, PqErrSysDtls> implements IPqErrSysDtlsService {
|
||||||
|
|
||||||
private final IPqScriptCheckDataService pqScriptCheckDataService;
|
private final IPqScriptCheckDataService pqScriptCheckDataService;
|
||||||
|
private final PqScriptMapper pqScriptMapper;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<PqErrSysDtls> listPqErrSysDtlsByPqErrSysId(String pqErrSysId) {
|
public List<PqErrSysDtls> listPqErrSysDtlsByPqErrSysId(String pqErrSysId) {
|
||||||
@@ -96,6 +99,7 @@ public class PqErrSysDtlsServiceImpl extends ServiceImpl<PqErrSysDtlsMapper, PqE
|
|||||||
checkDataParam.setScriptId(param.getScriptId());
|
checkDataParam.setScriptId(param.getScriptId());
|
||||||
checkDataParam.setIndex(param.getIndex());
|
checkDataParam.setIndex(param.getIndex());
|
||||||
List<PqScriptCheckData> list = pqScriptCheckDataService.listCheckDataCode(checkDataParam);
|
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());
|
List<String> valueType = list.stream().filter(x->x.getErrorFlag()!=0).map(PqScriptCheckData::getValueType).collect(Collectors.toList());
|
||||||
Map<String, List<PqErrSysDtls>> errMap =new HashMap<>(3);
|
Map<String, List<PqErrSysDtls>> errMap =new HashMap<>(3);
|
||||||
@@ -117,6 +121,21 @@ public class PqErrSysDtlsServiceImpl extends ServiceImpl<PqErrSysDtlsMapper, PqE
|
|||||||
dataVO.setValueType(script.getValueType());
|
dataVO.setValueType(script.getValueType());
|
||||||
dataVO.setValue(script.getValue());
|
dataVO.setValue(script.getValue());
|
||||||
dataVO.setPhase(script.getPhase());
|
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())){
|
if(errMap.containsKey(script.getValueType())){
|
||||||
dataVO.setErrSysDtls(errMap.get(script.getValueType()));
|
dataVO.setErrSysDtls(errMap.get(script.getValueType()));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -823,13 +823,13 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl<PqScriptDtlsMapper, PqS
|
|||||||
if (VOL.equals(pqScriptDtl.getValueType())) {
|
if (VOL.equals(pqScriptDtl.getValueType())) {
|
||||||
BigDecimal volValue = new BigDecimal(pqScriptDtl.getValue());
|
BigDecimal volValue = new BigDecimal(pqScriptDtl.getValue());
|
||||||
BigDecimal result = volValue.multiply(new BigDecimal(volt.toString()))
|
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());
|
pqScriptDtl.setValue(result.doubleValue());
|
||||||
}
|
}
|
||||||
if (CUR.equals(pqScriptDtl.getValueType())) {
|
if (CUR.equals(pqScriptDtl.getValueType())) {
|
||||||
BigDecimal volValue = new BigDecimal(pqScriptDtl.getValue());
|
BigDecimal volValue = new BigDecimal(pqScriptDtl.getValue());
|
||||||
BigDecimal result = volValue.multiply(new BigDecimal(curr.toString()))
|
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());
|
pqScriptDtl.setValue(result.doubleValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user