1.解决mysql index关键字
2.增加通讯脚本相关接口
This commit is contained in:
@@ -514,7 +514,7 @@ public class DetectionServiceImpl {
|
||||
DictDataEnum dataRule,
|
||||
String code) {
|
||||
List<PqScriptCheckData> checkData = pqScriptCheckDataService.list(new MPJLambdaWrapper<PqScriptCheckData>()
|
||||
.eq(PqScriptCheckData::getIndex, sourceIssue.getIndex())
|
||||
.eq(PqScriptCheckData::getScriptIndex, sourceIssue.getIndex())
|
||||
.eq(PqScriptCheckData::getScriptId, sourceIssue.getScriptId())
|
||||
);
|
||||
Map<String, List<Double>> map = devListMap(dev, dataRule, code);
|
||||
@@ -802,7 +802,7 @@ public class DetectionServiceImpl {
|
||||
Map<Double, Double> issueHarmMap;
|
||||
if (P.equals(type)) {
|
||||
List<PqScriptCheckData> checkData = pqScriptCheckDataService.list(new MPJLambdaWrapper<PqScriptCheckData>()
|
||||
.eq(PqScriptCheckData::getIndex, sourceIssue.getIndex())
|
||||
.eq(PqScriptCheckData::getScriptIndex, sourceIssue.getIndex())
|
||||
.eq(PqScriptCheckData::getPhase, phase)
|
||||
.eq(PqScriptCheckData::getScriptId, sourceIssue.getScriptId())
|
||||
);
|
||||
|
||||
@@ -354,7 +354,7 @@ public class AdPlanServiceImpl extends ServiceImpl<AdPlanMapper, AdPlan> impleme
|
||||
List<PqScriptDtls> scriptDtlsList = pqScriptDtlsService.listPqScriptDtlByScriptId(scriptId);
|
||||
|
||||
Map<String, List<PqScriptDtls>> collect = scriptDtlsList.stream()
|
||||
.sorted(Comparator.comparing(PqScriptDtls::getIndex))
|
||||
.sorted(Comparator.comparing(PqScriptDtls::getScriptIndex))
|
||||
.collect(Collectors.groupingBy(PqScriptDtls::getScriptType, LinkedHashMap::new, Collectors.toList()));
|
||||
|
||||
collect.forEach((key, value) -> {
|
||||
|
||||
@@ -488,7 +488,7 @@ public class ReportServiceImpl implements IReportService {
|
||||
queryWrapper.eq(PqScriptCheckData::getScriptId, scriptId)
|
||||
.eq(PqScriptCheckData::getEnable, DataStateEnum.ENABLE.getCode())
|
||||
.in(PqScriptCheckData::getPhase, phase)
|
||||
.eq(PqScriptCheckData::getIndex, index);
|
||||
.eq(PqScriptCheckData::getScriptIndex, index);
|
||||
List<PqScriptCheckData> list = pqScriptCheckDataService.list(queryWrapper);
|
||||
if (CollectionUtil.isNotEmpty(list)) {
|
||||
return list.get(0).getValueType();
|
||||
@@ -537,7 +537,7 @@ public class ReportServiceImpl implements IReportService {
|
||||
.eq(PqScriptDtls::getValue, value);
|
||||
List<PqScriptDtls> pqScriptDtls = pqScriptDtlsService.list(queryWrapper);
|
||||
if (CollectionUtil.isNotEmpty(pqScriptDtls)) {
|
||||
return pqScriptDtls.get(0).getIndex();
|
||||
return pqScriptDtls.get(0).getScriptIndex();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -126,8 +126,8 @@ public class ResultServiceImpl implements IResultService {
|
||||
.selectAll(PqScriptDtls.class)
|
||||
.eq(StrUtil.isNotBlank(param.getScriptId()), PqScriptDtls::getScriptId, param.getScriptId())
|
||||
.eq(StrUtil.isNotBlank(param.getScriptType()), PqScriptDtls::getScriptType, param.getScriptType())
|
||||
.ne(PqScriptDtls::getIndex, -1)
|
||||
.eq(PqScriptDtls::getEnable, DataStateEnum.ENABLE.getCode())
|
||||
.ne(PqScriptDtls::getScriptIndex, -1)
|
||||
.eq(StrUtil.isNotBlank(param.getDevId()),PqScriptDtls::getEnable, DataStateEnum.ENABLE.getCode())
|
||||
);
|
||||
Map<Integer, Set<Integer>> resultMap = new HashMap<>(5);
|
||||
if(StrUtil.isNotBlank(param.getDevId())){
|
||||
@@ -144,7 +144,7 @@ public class ResultServiceImpl implements IResultService {
|
||||
}
|
||||
|
||||
Map<String, List<PqScriptDtls>> dtlsSortMap = dtlsList.stream()
|
||||
.sorted(Comparator.comparing(PqScriptDtls::getIndex))
|
||||
.sorted(Comparator.comparing(PqScriptDtls::getScriptIndex))
|
||||
.collect(Collectors.groupingBy(PqScriptDtls::getScriptType, LinkedHashMap::new, Collectors.toList()));
|
||||
List<DictTree> dictTreeById = dictTreeService.getDictTreeById(new ArrayList<>(dtlsSortMap.keySet()));
|
||||
|
||||
@@ -170,7 +170,7 @@ public class ResultServiceImpl implements IResultService {
|
||||
infoVO.setScriptTypeCode(dictTree.getId());
|
||||
//额定条件下频率准确度测试
|
||||
LinkedHashMap<String, List<PqScriptDtls>> subTypeMap = value.stream()
|
||||
.sorted(Comparator.comparing(PqScriptDtls::getIndex))
|
||||
.sorted(Comparator.comparing(PqScriptDtls::getScriptIndex))
|
||||
.filter(x -> "Base".equals(x.getScriptSubType()))
|
||||
.collect(Collectors.groupingBy(PqScriptDtls::getScriptSubType, LinkedHashMap::new, Collectors.toList()));
|
||||
subTypeMap.forEach((subKey, subValue) -> {
|
||||
@@ -179,8 +179,8 @@ public class ResultServiceImpl implements IResultService {
|
||||
subType.setScriptTypeName(subName.get(subKey).replace("XX", dictTree.getName()));
|
||||
subType.setScriptTypeCode(subKey);
|
||||
LinkedHashMap<Integer, List<PqScriptDtls>> indexMap = subValue.stream()
|
||||
.sorted(Comparator.comparing(PqScriptDtls::getIndex))
|
||||
.collect(Collectors.groupingBy(PqScriptDtls::getIndex, LinkedHashMap::new, Collectors.toList()));
|
||||
.sorted(Comparator.comparing(PqScriptDtls::getScriptIndex))
|
||||
.collect(Collectors.groupingBy(PqScriptDtls::getScriptIndex, LinkedHashMap::new, Collectors.toList()));
|
||||
List<TreeDataVO> subTypeList = new ArrayList<>();
|
||||
indexMap.forEach((index, scriptDtlIndexList) -> {
|
||||
TreeDataVO dtlType = new TreeDataVO();
|
||||
@@ -208,7 +208,7 @@ public class ResultServiceImpl implements IResultService {
|
||||
|
||||
//单影响量下频率准确度测试
|
||||
LinkedHashMap<String, List<PqScriptDtls>> subSingleTypeMap = value.stream()
|
||||
.sorted(Comparator.comparing(PqScriptDtls::getIndex))
|
||||
.sorted(Comparator.comparing(PqScriptDtls::getScriptIndex))
|
||||
.filter(x -> !"Base".equals(x.getScriptSubType()))
|
||||
.collect(Collectors.groupingBy(PqScriptDtls::getScriptSubType, LinkedHashMap::new, Collectors.toList()));
|
||||
if (CollUtil.isNotEmpty(subSingleTypeMap)) {
|
||||
@@ -224,8 +224,8 @@ public class ResultServiceImpl implements IResultService {
|
||||
List<TreeDataVO> subTypeList = new ArrayList<>();
|
||||
|
||||
LinkedHashMap<Integer, List<PqScriptDtls>> indexMap = subValue.stream()
|
||||
.sorted(Comparator.comparing(PqScriptDtls::getIndex))
|
||||
.collect(Collectors.groupingBy(PqScriptDtls::getIndex, LinkedHashMap::new, Collectors.toList()));
|
||||
.sorted(Comparator.comparing(PqScriptDtls::getScriptIndex))
|
||||
.collect(Collectors.groupingBy(PqScriptDtls::getScriptIndex, LinkedHashMap::new, Collectors.toList()));
|
||||
indexMap.forEach((index, scriptDtlIndexList) -> {
|
||||
TreeDataVO dtlType = new TreeDataVO();
|
||||
dtlType.setIndex(index);
|
||||
@@ -268,21 +268,21 @@ public class ResultServiceImpl implements IResultService {
|
||||
List<PqScriptDtls> dip = subValue.stream()
|
||||
.filter(x -> "Dip".equals(x.getValueType()) && "A".equals(x.getPhase()))
|
||||
.filter(x -> x.getTransValue() >= start && x.getTransValue() <= end)
|
||||
.sorted(Comparator.comparing(PqScriptDtls::getIndex))
|
||||
.sorted(Comparator.comparing(PqScriptDtls::getScriptIndex))
|
||||
.collect(Collectors.toList());
|
||||
TreeDataVO vo = new TreeDataVO();
|
||||
vo.setScriptTypeName(name);
|
||||
TreeDataVO dlt;
|
||||
for (PqScriptDtls dtls : dip) {
|
||||
dlt = new TreeDataVO();
|
||||
List<PqScriptDtls> scriptDtlIndexList = subValue.stream().filter(x -> dtls.getIndex().equals(x.getIndex())).collect(Collectors.toList());
|
||||
List<PqScriptDtls> scriptDtlIndexList = subValue.stream().filter(x -> dtls.getScriptIndex().equals(x.getScriptIndex())).collect(Collectors.toList());
|
||||
//特征幅值=20%Un,持续时间=1周波
|
||||
dlt.setScriptTypeName("特征幅值=" + dtls.getTransValue() + "%Un,持续时间=" + dtls.getRetainTime().intValue() + "周波");
|
||||
dlt.setIndex(dtls.getIndex());
|
||||
dlt.setIndex(dtls.getScriptIndex());
|
||||
dlt.setScriptType(scriptDtlIndexList.get(0).getScriptType());
|
||||
dlt.setSourceDesc(ScriptDtlsDesc.getStringBuffer(scriptDtlIndexList, isValueType).toString());
|
||||
if (finalResultMap.containsKey(dtls.getIndex())) {
|
||||
dlt.setFly(conform(finalResultMap.get(dtls.getIndex())));
|
||||
if (finalResultMap.containsKey(dtls.getScriptIndex())) {
|
||||
dlt.setFly(conform(finalResultMap.get(dtls.getScriptIndex())));
|
||||
}
|
||||
info.add(dlt);
|
||||
|
||||
@@ -398,7 +398,7 @@ public class ResultServiceImpl implements IResultService {
|
||||
case IMBV:
|
||||
List<PqScriptCheckData> list = pqScriptCheckDataService.list(new MPJLambdaWrapper<PqScriptCheckData>()
|
||||
.eq(PqScriptCheckData::getScriptId, scriptDtlIndexList.get(0).getScriptId())
|
||||
.eq(PqScriptCheckData::getIndex, scriptDtlIndexList.get(0).getIndex())
|
||||
.eq(PqScriptCheckData::getScriptIndex, scriptDtlIndexList.get(0).getScriptIndex())
|
||||
);
|
||||
//三相负序电压不平衡度=0%
|
||||
dtlType.setScriptTypeName(dictTree.getName() + "=" + list.get(0).getValue() + ResultUnitEnum.IMBV.getUnit());
|
||||
@@ -409,7 +409,7 @@ public class ResultServiceImpl implements IResultService {
|
||||
case IMBA:
|
||||
List<PqScriptCheckData> imba = pqScriptCheckDataService.list(new MPJLambdaWrapper<PqScriptCheckData>()
|
||||
.eq(PqScriptCheckData::getScriptId, scriptDtlIndexList.get(0).getScriptId())
|
||||
.eq(PqScriptCheckData::getIndex, scriptDtlIndexList.get(0).getIndex())
|
||||
.eq(PqScriptCheckData::getScriptIndex, scriptDtlIndexList.get(0).getScriptIndex())
|
||||
);
|
||||
//三相负序电流不平衡度=0%
|
||||
dtlType.setScriptTypeName(dictTree.getName() + "=" + imba.get(0).getValue() + ResultUnitEnum.IMBV.getUnit());
|
||||
@@ -767,7 +767,7 @@ public class ResultServiceImpl implements IResultService {
|
||||
.select(PqScriptCheckData::getHarmNum)
|
||||
.eq(PqScriptCheckData::getScriptId, param.getScriptId())
|
||||
.isNotNull(PqScriptCheckData::getHarmNum)
|
||||
.eq(PqScriptCheckData::getIndex, param.getIndex())
|
||||
.eq(PqScriptCheckData::getScriptIndex, param.getIndex())
|
||||
);
|
||||
harmNum = list.stream().sorted(Comparator.comparing(PqScriptCheckData::getHarmNum))
|
||||
.map(PqScriptCheckData::getHarmNum).distinct().collect(Collectors.toList());
|
||||
@@ -800,7 +800,7 @@ public class ResultServiceImpl implements IResultService {
|
||||
.select(PqScriptCheckData::getHarmNum)
|
||||
.eq(PqScriptCheckData::getScriptId, param.getScriptId())
|
||||
.isNotNull(PqScriptCheckData::getHarmNum)
|
||||
.eq(PqScriptCheckData::getIndex, param.getIndex())
|
||||
.eq(PqScriptCheckData::getScriptIndex, param.getIndex())
|
||||
);
|
||||
harmNum = list.stream().sorted(Comparator.comparing(PqScriptCheckData::getHarmNum))
|
||||
.map(PqScriptCheckData::getHarmNum).distinct().collect(Collectors.toList());
|
||||
|
||||
@@ -10,7 +10,9 @@ import com.njcn.common.utils.LogUtil;
|
||||
import com.njcn.gather.script.pojo.param.PqScriptDtlsParam;
|
||||
import com.njcn.gather.script.pojo.param.PqScriptIssueParam;
|
||||
import com.njcn.gather.script.pojo.param.PqScriptParam;
|
||||
import com.njcn.gather.script.pojo.param.ScriptParam;
|
||||
import com.njcn.gather.script.pojo.po.PqScript;
|
||||
import com.njcn.gather.script.pojo.po.PqScriptCheckData;
|
||||
import com.njcn.gather.script.pojo.po.PqScriptDtls;
|
||||
import com.njcn.gather.script.pojo.po.SourceIssue;
|
||||
import com.njcn.gather.script.service.IPqScriptDtlsService;
|
||||
@@ -130,7 +132,7 @@ public class PqScriptController extends BaseController {
|
||||
@ApiOperation("获取指定模式下的所有检测脚本")
|
||||
@ApiImplicitParam(name = "patternId", value = "模式Id", required = true)
|
||||
public HttpResult<List<Map<String, Object>>> getAllPqScript(@RequestParam("patternId") String patternId) {
|
||||
String methodDescribe = getMethodDescribe("getAll");
|
||||
String methodDescribe = getMethodDescribe("getAllPqScript");
|
||||
LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, patternId);
|
||||
List<Map<String, Object>> result = pqScriptService.listAllPqScript(patternId);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
@@ -140,8 +142,8 @@ public class PqScriptController extends BaseController {
|
||||
@OperateInfo
|
||||
@PostMapping("/dlsDetails")
|
||||
@ApiOperation("根据脚本id查询检测脚本详情")
|
||||
@ApiImplicitParam(name = "id", value = "检测脚本id", required = true)
|
||||
public HttpResult<List<SourceIssue>> dls(@RequestBody PqScriptIssueParam param) {
|
||||
@ApiImplicitParam(name = "param", value = "检测脚本", required = true)
|
||||
public HttpResult<List<SourceIssue>> dlsDetails(@RequestBody PqScriptIssueParam param) {
|
||||
String methodDescribe = getMethodDescribe("dlsDetails");
|
||||
LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, param);
|
||||
List<SourceIssue> sourceIssues = pqScriptDtlsService.listSourceIssue(param);
|
||||
@@ -152,12 +154,59 @@ public class PqScriptController extends BaseController {
|
||||
@OperateInfo
|
||||
@PostMapping("/addScriptDtls")
|
||||
@ApiOperation("添加检测脚本")
|
||||
@ApiImplicitParam(name = "id", value = "检测脚本id", required = true)
|
||||
@ApiImplicitParam(name = "sourceIssue", value = "检测脚本", required = true)
|
||||
public HttpResult<Boolean> addScriptDtls(@RequestBody PqScriptDtlsParam sourceIssue) {
|
||||
String methodDescribe = getMethodDescribe("addScriptDtls");
|
||||
LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, sourceIssue);
|
||||
Boolean b = pqScriptDtlsService.saveScriptDtls(sourceIssue);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, b , methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo
|
||||
@PostMapping("/scriptDtlsCheckDataList")
|
||||
@ApiOperation("根据通讯参数生成装置下发原始数据公式")
|
||||
@ApiImplicitParam(name = "sourceIssue", value = "检测脚本", required = true)
|
||||
public HttpResult<List<PqScriptDtlsParam.CheckData>> scriptDtlsCheckDataList(@RequestBody PqScriptDtlsParam sourceIssue) {
|
||||
String methodDescribe = getMethodDescribe("scriptDtlsCheckDataList");
|
||||
LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, sourceIssue);
|
||||
List<PqScriptDtlsParam.CheckData> checkData = pqScriptDtlsService.scriptDtlsCheckDataList(sourceIssue);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, checkData , methodDescribe);
|
||||
}
|
||||
|
||||
|
||||
@OperateInfo
|
||||
@PostMapping("/deleteDtls")
|
||||
@ApiOperation("删除脚本")
|
||||
@ApiImplicitParam(name = "sourceIssue", value = "检测脚本", required = true)
|
||||
public HttpResult<Boolean> deleteDtls(@RequestBody @Validated ScriptParam sourceIssue) {
|
||||
String methodDescribe = getMethodDescribe("deleteDtls");
|
||||
LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, sourceIssue);
|
||||
Boolean b = pqScriptDtlsService.deleteDtls(sourceIssue);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, b , methodDescribe);
|
||||
}
|
||||
|
||||
|
||||
@OperateInfo
|
||||
@PostMapping("/updateDtls")
|
||||
@ApiOperation("启用关闭脚本")
|
||||
@ApiImplicitParam(name = "sourceIssue", value = "检测脚本", required = true)
|
||||
public HttpResult<Boolean> updateDtls(@RequestBody @Validated ScriptParam sourceIssue) {
|
||||
String methodDescribe = getMethodDescribe("updateDtls");
|
||||
LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, sourceIssue);
|
||||
Boolean b = pqScriptDtlsService.updateDtls(sourceIssue);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, b , methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo
|
||||
@PostMapping("/checkDataList")
|
||||
@ApiOperation("通讯脚本回显")
|
||||
@ApiImplicitParam(name = "sourceIssue", value = "检测脚本", required = true)
|
||||
public HttpResult<List<PqScriptCheckData>> checkDataList(@RequestBody @Validated ScriptParam sourceIssue) {
|
||||
String methodDescribe = getMethodDescribe("checkDataList");
|
||||
LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, sourceIssue);
|
||||
List<PqScriptCheckData> checkData = pqScriptDtlsService.checkDataList(sourceIssue);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, checkData, methodDescribe);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<select id="selectMaxIndex" resultType="java.lang.Integer">
|
||||
|
||||
SELECT
|
||||
IFNULL( max( t.INDEX ), -1 ) AS num
|
||||
IFNULL( max( t.Script_Index ), -1 ) AS num
|
||||
FROM
|
||||
pq_script_dtls t
|
||||
WHERE
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.njcn.gather.script.pojo.param;
|
||||
|
||||
import com.njcn.gather.device.pojo.constant.DevValidMessage;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @data 2024/11/18
|
||||
*/
|
||||
@Data
|
||||
public class ScriptParam {
|
||||
|
||||
@ApiModelProperty("检测脚本id")
|
||||
@NotBlank(message = DevValidMessage.ID_FORMAT_ERROR)
|
||||
private String scriptId;
|
||||
|
||||
@ApiModelProperty("检测脚本类型")
|
||||
@NotBlank(message = DevValidMessage.ID_FORMAT_ERROR)
|
||||
private String scriptType;
|
||||
|
||||
@ApiModelProperty("检测脚本序号")
|
||||
private Integer index;
|
||||
|
||||
@ApiModelProperty("是否启用脚本(状态:0-不启用 1-启用)")
|
||||
private Integer enable;
|
||||
}
|
||||
@@ -28,7 +28,8 @@ public class PqScriptCheckData implements Serializable {
|
||||
/**
|
||||
* 总检测脚本中的测试项序号
|
||||
*/
|
||||
private Integer index;
|
||||
@TableField("Script_Index")
|
||||
private Integer scriptIndex;
|
||||
|
||||
/**
|
||||
* 检测指标类型,与数据字典关联(例如电压有效值、谐波电压含有率等)
|
||||
|
||||
@@ -32,8 +32,8 @@ public class PqScriptDtls implements Serializable {
|
||||
/**
|
||||
* 总检测脚本中的测试项序号
|
||||
*/
|
||||
@TableField("`index`")
|
||||
private Integer index;
|
||||
@TableField("Script_Index")
|
||||
private Integer scriptIndex;
|
||||
|
||||
/**
|
||||
* 检测脚本类型
|
||||
|
||||
@@ -18,8 +18,14 @@ public class SourceIssue {
|
||||
/**
|
||||
* 检测小项dtls Id
|
||||
*/
|
||||
@JSONField(serialize = false)
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 是否启用
|
||||
*/
|
||||
@JSONField(serialize = false)
|
||||
private Integer enable;
|
||||
/**
|
||||
* 源ID
|
||||
*/
|
||||
|
||||
@@ -3,6 +3,8 @@ package com.njcn.gather.script.service;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.njcn.gather.script.pojo.param.PqScriptDtlsParam;
|
||||
import com.njcn.gather.script.pojo.param.PqScriptIssueParam;
|
||||
import com.njcn.gather.script.pojo.param.ScriptParam;
|
||||
import com.njcn.gather.script.pojo.po.PqScriptCheckData;
|
||||
import com.njcn.gather.script.pojo.po.PqScriptDtls;
|
||||
import com.njcn.gather.script.pojo.po.SourceIssue;
|
||||
|
||||
@@ -79,10 +81,30 @@ public interface IPqScriptDtlsService extends IService<PqScriptDtls> {
|
||||
Boolean saveScriptDtls(PqScriptDtlsParam sourceIssue);
|
||||
|
||||
/**
|
||||
* 查询当前检测小项的信息
|
||||
* 根据通讯参数生成装置下发原始数据公式
|
||||
* @return
|
||||
*/
|
||||
List<PqScriptDtlsParam.CheckData> scriptDtlsList(PqScriptDtlsParam sourceIssue);
|
||||
List<PqScriptDtlsParam.CheckData> scriptDtlsCheckDataList(PqScriptDtlsParam sourceIssue);
|
||||
|
||||
/**
|
||||
* 删除脚本
|
||||
* @param param
|
||||
* @return
|
||||
*/
|
||||
Boolean deleteDtls(ScriptParam param);
|
||||
|
||||
/**
|
||||
* 启用关闭脚本
|
||||
* @param param
|
||||
* @return
|
||||
*/
|
||||
Boolean updateDtls(ScriptParam param);
|
||||
|
||||
/**
|
||||
* 通讯脚本回显
|
||||
* @param param
|
||||
* @return
|
||||
*/
|
||||
List<PqScriptCheckData> checkDataList(ScriptParam param);
|
||||
|
||||
Boolean saveCheck();
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ public class PqScriptCheckDataServiceImpl extends ServiceImpl<PqScriptCheckDataM
|
||||
queryWrapper.selectAll(PqScriptCheckData.class)
|
||||
.leftJoin(DictTree.class, DictTree::getId, PqScriptCheckData::getValueType)
|
||||
.eq(PqScriptCheckData::getScriptId, param.getScriptId())
|
||||
.eq(ObjectUtil.isNotNull(param.getIndex()),PqScriptCheckData::getIndex, param.getIndex())
|
||||
.eq(ObjectUtil.isNotNull(param.getIndex()),PqScriptCheckData::getScriptIndex, param.getIndex())
|
||||
.eq(PqScriptCheckData::getEnable, DataStateEnum.ENABLE.getCode());
|
||||
if (param.getIsValueTypeName()) {
|
||||
queryWrapper.selectAs(DictTree::getCode, PqScriptCheckData::getValueType);
|
||||
@@ -101,7 +101,7 @@ public class PqScriptCheckDataServiceImpl extends ServiceImpl<PqScriptCheckDataM
|
||||
.leftJoin(DictTree.class, DictTree::getId, PqScriptCheckData::getValueType)
|
||||
.selectAs(DictTree::getCode, PqScriptCheckData::getValueTypeCode)
|
||||
.eq(PqScriptCheckData::getScriptId, param.getScriptId())
|
||||
.eq(PqScriptCheckData::getIndex, param.getIndex())
|
||||
.eq(PqScriptCheckData::getScriptIndex, param.getIndex())
|
||||
.eq(PqScriptCheckData::getEnable, DataStateEnum.ENABLE.getCode());
|
||||
return this.getBaseMapper().selectJoinList(PqScriptCheckData.class, queryWrapper);
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import cn.hutool.core.util.NumberUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
||||
import com.njcn.common.pojo.enums.common.DataStateEnum;
|
||||
@@ -12,11 +13,13 @@ import com.njcn.gather.detection.pojo.enums.DetectionCodeEnum;
|
||||
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;
|
||||
import com.njcn.gather.script.pojo.param.PqScriptCheckDataParam;
|
||||
import com.njcn.gather.script.pojo.param.PqScriptDtlsParam;
|
||||
import com.njcn.gather.script.pojo.param.PqScriptIssueParam;
|
||||
import com.njcn.gather.script.pojo.param.ScriptParam;
|
||||
import com.njcn.gather.script.pojo.po.PqScript;
|
||||
import com.njcn.gather.script.pojo.po.PqScriptCheckData;
|
||||
import com.njcn.gather.script.pojo.po.PqScriptDtls;
|
||||
@@ -37,6 +40,7 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
@@ -76,6 +80,7 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl<PqScriptDtlsMapper, PqS
|
||||
private final IPqDevService pqDevService;
|
||||
private final PqScriptMapper pqScriptMapper;
|
||||
private final IPqScriptCheckDataService pqScriptCheckDataService;
|
||||
private final PqScriptCheckDataMapper pqScriptCheckDataMapper;
|
||||
private final IDevTypeService devTypeService;
|
||||
private final IDictTreeService dictTreeService;
|
||||
|
||||
@@ -155,8 +160,8 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl<PqScriptDtlsMapper, PqS
|
||||
* 3.组装所有检测格式
|
||||
*/
|
||||
Map<Integer, List<PqScriptDtls>> scriptDtlsMap = pqScriptDtls.stream()
|
||||
.sorted(Comparator.comparing(PqScriptDtls::getIndex))
|
||||
.collect(Collectors.groupingBy(PqScriptDtls::getIndex, LinkedHashMap::new, Collectors.toList()));
|
||||
.sorted(Comparator.comparing(PqScriptDtls::getScriptIndex))
|
||||
.collect(Collectors.groupingBy(PqScriptDtls::getScriptIndex, LinkedHashMap::new, Collectors.toList()));
|
||||
scriptDtlsMap.forEach((key, value) -> {
|
||||
/**
|
||||
* 分组获取有多少小类
|
||||
@@ -169,14 +174,15 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl<PqScriptDtlsMapper, PqS
|
||||
PqScriptDtls freqDtls = freq.get(0);
|
||||
SourceIssue issue = new SourceIssue();
|
||||
issue.setId(freqDtls.getId());
|
||||
issue.setEnable(freqDtls.getEnable());
|
||||
issue.setSourceId(param.getSourceId());
|
||||
issue.setType(freqDtls.getScriptCode());
|
||||
issue.setIndex(freqDtls.getIndex());
|
||||
issue.setIndex(freqDtls.getScriptIndex());
|
||||
String scriptSubType = freqDtls.getScriptSubType();
|
||||
issue.setSubType(StrUtil.isBlank(scriptSubType)&&CollUtil.isNotEmpty(param.getDevIds()) ? scriptSubType : scriptSubType.replace("Base", "NULL"));
|
||||
issue.setSubType(CollUtil.isEmpty(param.getDevIds()) || StrUtil.isBlank(scriptSubType) ? scriptSubType : scriptSubType.replace("Base", "NULL"));
|
||||
PqScriptCheckDataParam checkDataParam = new PqScriptCheckDataParam();
|
||||
checkDataParam.setScriptId(freqDtls.getScriptId());
|
||||
checkDataParam.setIndex(freqDtls.getIndex());
|
||||
checkDataParam.setIndex(freqDtls.getScriptIndex());
|
||||
checkDataParam.setIsValueTypeName(true);
|
||||
issue.setDevValueTypeList(pqScriptCheckDataService.getValueType(checkDataParam));
|
||||
issue.setDesc(ScriptDtlsDesc.getStringBuffer(value, isValueType).toString());
|
||||
@@ -227,11 +233,11 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl<PqScriptDtlsMapper, PqS
|
||||
@Override
|
||||
public List<Integer> getIndexList(String scriptType, String scriptId) {
|
||||
MPJLambdaWrapper<PqScriptDtls> wrapper = new MPJLambdaWrapper<>();
|
||||
wrapper.select(PqScriptDtls::getIndex)
|
||||
wrapper.select(PqScriptDtls::getScriptIndex)
|
||||
.distinct()
|
||||
.eq(PqScriptDtls::getScriptType, scriptType)
|
||||
.eq(PqScriptDtls::getScriptId, scriptId);
|
||||
return this.getBaseMapper().selectJoinList(PqScriptDtls.class, wrapper).stream().map(PqScriptDtls::getIndex).collect(Collectors.toList());
|
||||
return this.getBaseMapper().selectJoinList(PqScriptDtls.class, wrapper).stream().map(PqScriptDtls::getScriptIndex).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -241,13 +247,13 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl<PqScriptDtlsMapper, PqS
|
||||
List<PqScriptCheckData> checkList = new ArrayList<>();
|
||||
Integer i = sourceIssue.getIndex();
|
||||
if (ObjectUtil.isNotNull(sourceIssue.getIndex())) {
|
||||
this.remove(new MPJLambdaWrapper<PqScriptDtls>()
|
||||
this.remove(new LambdaQueryWrapper<PqScriptDtls>()
|
||||
.eq(PqScriptDtls::getScriptId, sourceIssue.getScriptId())
|
||||
.eq(PqScriptDtls::getIndex, sourceIssue.getIndex())
|
||||
.eq(PqScriptDtls::getScriptIndex, sourceIssue.getIndex())
|
||||
);
|
||||
pqScriptCheckDataService.remove(new MPJLambdaWrapper<PqScriptCheckData>()
|
||||
pqScriptCheckDataService.remove(new LambdaQueryWrapper<PqScriptCheckData>()
|
||||
.eq(PqScriptCheckData::getScriptId, sourceIssue.getScriptId())
|
||||
.eq(PqScriptCheckData::getIndex, sourceIssue.getIndex())
|
||||
.eq(PqScriptCheckData::getScriptIndex, sourceIssue.getIndex())
|
||||
);
|
||||
} else {
|
||||
i = this.baseMapper.selectMaxIndex(sourceIssue.getScriptId()) + 1;
|
||||
@@ -258,7 +264,7 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl<PqScriptDtlsMapper, PqS
|
||||
for (PqScriptDtlsParam.CheckData checkData : checkDataList) {
|
||||
data = new PqScriptCheckData();
|
||||
data.setScriptId(sourceIssue.getScriptId());
|
||||
data.setIndex(i);
|
||||
data.setScriptIndex(i);
|
||||
data.setValueType(checkData.getValueType());
|
||||
data.setDataType(checkData.getDataType());
|
||||
data.setPhase(checkData.getPhase());
|
||||
@@ -298,6 +304,7 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl<PqScriptDtlsMapper, PqS
|
||||
//谐波值
|
||||
if (channelListDTO.getHarmFlag()) {
|
||||
List<PqScriptDtlsParam.ChannelListDTO.HarmModel> harmList = channelListDTO.getHarmList();
|
||||
if (CollUtil.isNotEmpty(harmList)) {
|
||||
for (PqScriptDtlsParam.ChannelListDTO.HarmModel harmModel : harmList) {
|
||||
PqScriptDtls harm = setScriptDtls(sourceIssue, i);
|
||||
if (channelListDTO.getChannelType().contains("U")) {
|
||||
@@ -313,9 +320,11 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl<PqScriptDtlsMapper, PqS
|
||||
info.add(harm);
|
||||
}
|
||||
}
|
||||
}
|
||||
//间谐波
|
||||
if (channelListDTO.getInHarmFlag()) {
|
||||
List<PqScriptDtlsParam.ChannelListDTO.InharmModel> inharmList = channelListDTO.getInharmList();
|
||||
if (CollUtil.isNotEmpty(inharmList)) {
|
||||
for (PqScriptDtlsParam.ChannelListDTO.InharmModel inharmModel : inharmList) {
|
||||
PqScriptDtls inHarm = setScriptDtls(sourceIssue, i);
|
||||
if (channelListDTO.getChannelType().contains("U")) {
|
||||
@@ -331,6 +340,7 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl<PqScriptDtlsMapper, PqS
|
||||
info.add(inHarm);
|
||||
}
|
||||
}
|
||||
}
|
||||
//暂态
|
||||
if (channelListDTO.getDipFlag()) {
|
||||
PqScriptDtlsParam.ChannelListDTO.DipDataDTO dipData = channelListDTO.getDipData();
|
||||
@@ -364,7 +374,7 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl<PqScriptDtlsMapper, PqS
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PqScriptDtlsParam.CheckData> scriptDtlsList(PqScriptDtlsParam sourceIssue) {
|
||||
public List<PqScriptDtlsParam.CheckData> scriptDtlsCheckDataList(PqScriptDtlsParam sourceIssue) {
|
||||
List<PqScriptDtlsParam.CheckData> info = new ArrayList<>();
|
||||
//获取所有下拉值情况
|
||||
List<PqScriptDtlsParam.CheckData> checkDataList = sourceIssue.getCheckDataList();
|
||||
@@ -440,6 +450,39 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl<PqScriptDtlsMapper, PqS
|
||||
}
|
||||
break;
|
||||
case P2_50:
|
||||
List<PqScriptDtlsParam.ChannelListDTO> channelU = channelList.stream().filter(x -> x.getChannelType().contains("U")).collect(Collectors.toList());
|
||||
if (CollUtil.isNotEmpty(channelU)) {
|
||||
for (PqScriptDtlsParam.ChannelListDTO listDTO : channelU) {
|
||||
//获取电流通道
|
||||
List<PqScriptDtlsParam.ChannelListDTO> channelI = channelList.stream()
|
||||
.filter(x -> x.getChannelType().contains("I" + listDTO.getChannelType().substring(1, 2)))
|
||||
.collect(Collectors.toList());
|
||||
if (CollUtil.isNotEmpty(channelI)) {
|
||||
List<PqScriptDtlsParam.ChannelListDTO.HarmModel> harmI = channelI.stream()
|
||||
.flatMap(x -> x.getHarmList().stream()).collect(Collectors.toList());
|
||||
Map<Double, PqScriptDtlsParam.ChannelListDTO.HarmModel> harmIMap = harmI.stream()
|
||||
.collect(Collectors.toMap(PqScriptDtlsParam.ChannelListDTO.HarmModel::getHarm, Function.identity()));
|
||||
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());
|
||||
if (harmIMap.containsKey(harmModel.getHarm())) {
|
||||
PqScriptDtlsParam.ChannelListDTO.HarmModel i = harmIMap.get(harmModel.getHarm());
|
||||
//电压*电流*cos(电压角度-电流角度)
|
||||
checkData.setValue(i.getFAmp() * harmModel.getFAmp() * Math.cos(harmModel.getFPhase() - i.getFPhase()));
|
||||
}
|
||||
checkData.setPhase(listDTO.getChannelType().substring(1, 2));
|
||||
checkData.setDataType(channelListDTO.getDataType());
|
||||
checkData.setValueType(channelListDTO.getValueType());
|
||||
info.add(checkData);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case SV_1_49:
|
||||
if (CollUtil.isNotEmpty(channelList)) {
|
||||
@@ -497,6 +540,10 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl<PqScriptDtlsMapper, PqS
|
||||
case PST:
|
||||
break;
|
||||
|
||||
case I1:
|
||||
break;
|
||||
case UNKNOWN_ERROR:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -506,6 +553,46 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl<PqScriptDtlsMapper, PqS
|
||||
return info;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean deleteDtls(ScriptParam param) {
|
||||
this.remove(new LambdaQueryWrapper<PqScriptDtls>()
|
||||
.eq(PqScriptDtls::getScriptId, param.getScriptId())
|
||||
.eq(PqScriptDtls::getScriptIndex, param.getIndex())
|
||||
);
|
||||
return pqScriptCheckDataService.remove(new LambdaQueryWrapper<PqScriptCheckData>()
|
||||
.eq(PqScriptCheckData::getScriptId, param.getScriptId())
|
||||
.eq(PqScriptCheckData::getScriptIndex, param.getIndex())
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean updateDtls(ScriptParam param) {
|
||||
return this.update(new LambdaUpdateWrapper<PqScriptDtls>()
|
||||
.set(PqScriptDtls::getEnable, param.getEnable())
|
||||
.eq(PqScriptDtls::getScriptId, param.getScriptId())
|
||||
.eq(PqScriptDtls::getScriptIndex, param.getIndex())
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PqScriptCheckData> checkDataList(ScriptParam param) {
|
||||
List<PqScriptDtls> list = this.list(new LambdaQueryWrapper<PqScriptDtls>()
|
||||
.eq(PqScriptDtls::getScriptId, param.getScriptId())
|
||||
.eq(PqScriptDtls::getScriptType, param.getScriptType())
|
||||
);
|
||||
List<Integer> indexList = list.stream().map(PqScriptDtls::getScriptIndex).distinct().collect(Collectors.toList());
|
||||
if(CollUtil.isNotEmpty(indexList)){
|
||||
return pqScriptCheckDataMapper.selectJoinList(PqScriptCheckData.class,new MPJLambdaWrapper<PqScriptCheckData>()
|
||||
.select(PqScriptCheckData::getValueType, PqScriptCheckData::getEnable, PqScriptCheckData::getErrorFlag)
|
||||
.distinct()
|
||||
.eq(PqScriptCheckData::getScriptId, param.getScriptId())
|
||||
.eq(PqScriptCheckData::getScriptId, indexList)
|
||||
);
|
||||
|
||||
}
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
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)) {
|
||||
@@ -578,15 +665,10 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl<PqScriptDtlsMapper, PqS
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Boolean saveCheck() {
|
||||
return null;
|
||||
}
|
||||
|
||||
private PqScriptDtls setScriptDtls(PqScriptDtlsParam sourceIssue, Integer i) {
|
||||
PqScriptDtls dtls = new PqScriptDtls();
|
||||
dtls.setScriptId(sourceIssue.getScriptId());
|
||||
dtls.setIndex(i);
|
||||
dtls.setScriptIndex(i);
|
||||
dtls.setScriptType(sourceIssue.getScriptType());
|
||||
dtls.setScriptSubType(sourceIssue.getSubType());
|
||||
dtls.setEnable(DataStateEnum.ENABLE.getCode());
|
||||
@@ -605,17 +687,17 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl<PqScriptDtlsMapper, PqS
|
||||
// .le(PqScriptDtls::getIndex, 30)
|
||||
// .in(PqScriptDtls::getIndex, Arrays.asList(1,7))
|
||||
|
||||
.eq(PqScriptCheckData::getEnable, DataStateEnum.ENABLE.getCode())
|
||||
.orderByAsc(PqScriptCheckData::getIndex)
|
||||
.eq(CollUtil.isNotEmpty(param.getDevIds()), PqScriptCheckData::getEnable, DataStateEnum.ENABLE.getCode())
|
||||
.orderByAsc(PqScriptCheckData::getScriptIndex)
|
||||
;
|
||||
if (param.getIsPhaseSequence().equals(CommonEnum.PHASE_TEST.getValue())) {
|
||||
//相序
|
||||
queryWrapper.eq(PqScriptDtls::getIndex, -1)
|
||||
queryWrapper.eq(PqScriptDtls::getScriptIndex, -1)
|
||||
.eq(PqScriptDtls::getEnable, 1);
|
||||
pqScriptDtls = this.list(queryWrapper);
|
||||
} else if (param.getIsPhaseSequence().equals(CommonEnum.COEFFICIENT_TEST.getValue())) {
|
||||
//系数
|
||||
queryWrapper.in(PqScriptDtls::getIndex, param.getIndexList())
|
||||
queryWrapper.in(PqScriptDtls::getScriptIndex, param.getIndexList())
|
||||
.eq(PqScriptDtls::getEnable, 1);
|
||||
pqScriptDtls = this.list(queryWrapper);
|
||||
} else {
|
||||
|
||||
@@ -79,7 +79,7 @@ public class ScriptDtlsDesc {
|
||||
buffer.append(name + " ");
|
||||
for (PqScriptDtls dtls : list) {
|
||||
buffer.append(dtls.getPhase() + "相(暂态深度=" + dtls.getTransValue() + ResultUnitEnum.VOLTAGE_DUR_UNIT.getUnit()
|
||||
+ ",暂态持续时间=" + dtls.getRetainTime().intValue() + ResultUnitEnum.VOLTAGE_MAG_UNIT.getUnit() + ") ");
|
||||
+ ",暂态持续时间=" + (ObjectUtil.isNull(dtls.getRetainTime()) ? dtls.getRetainTime() : dtls.getRetainTime().intValue()) + ResultUnitEnum.VOLTAGE_MAG_UNIT.getUnit() + ") ");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user