新增检测脚本,调整检测脚本返回值

This commit is contained in:
wr
2025-02-17 16:32:07 +08:00
parent a5472781de
commit 76ec26dca0
8 changed files with 149 additions and 9 deletions

View File

@@ -59,12 +59,12 @@ public class PqScriptController extends BaseController {
@PostMapping("/add") @PostMapping("/add")
@ApiOperation("新增检测脚本") @ApiOperation("新增检测脚本")
@ApiImplicitParam(name = "pqDevParam", value = "检测脚本", required = true) @ApiImplicitParam(name = "pqDevParam", value = "检测脚本", required = true)
public HttpResult<Object> add(@RequestBody @Validated PqScriptParam param) { public HttpResult<String> add(@RequestBody @Validated PqScriptParam param) {
String methodDescribe = getMethodDescribe("add"); String methodDescribe = getMethodDescribe("add");
LogUtil.njcnDebug(log, "{},新增数据为:{}", methodDescribe, param); LogUtil.njcnDebug(log, "{},新增数据为:{}", methodDescribe, param);
boolean result = pqScriptService.addPqScript(param); String result = pqScriptService.addPqScript(param);
if (result) { if (StrUtil.isNotBlank(result)) {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
} else { } else {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, null, methodDescribe); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, null, methodDescribe);
} }
@@ -150,7 +150,7 @@ public class PqScriptController extends BaseController {
String jsonString = JSON.toJSONString(sourceIssue,SerializerFeature.WriteNullStringAsEmpty); String jsonString = JSON.toJSONString(sourceIssue,SerializerFeature.WriteNullStringAsEmpty);
System.out.println(); System.out.println();
} }
String jsonString =sourceIssues.get(0).toString(); String jsonString =JSON.toJSONString(sourceIssues);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, sourceIssues, methodDescribe); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, sourceIssues, methodDescribe);
} }
} }

View File

@@ -2,6 +2,7 @@ package com.njcn.gather.script.mapper;
import com.github.yulichang.base.MPJBaseMapper; import com.github.yulichang.base.MPJBaseMapper;
import com.njcn.gather.script.pojo.po.PqScriptDtls; import com.njcn.gather.script.pojo.po.PqScriptDtls;
import org.apache.ibatis.annotations.Param;
/** /**
* @author caozehui * @author caozehui
@@ -9,5 +10,11 @@ import com.njcn.gather.script.pojo.po.PqScriptDtls;
*/ */
public interface PqScriptDtlsMapper extends MPJBaseMapper<PqScriptDtls> { public interface PqScriptDtlsMapper extends MPJBaseMapper<PqScriptDtls> {
/**
* 获取当前检测脚本最大index值
* @param scriptId
* @return
*/
Integer selectMaxIndex(@Param("scriptId") String scriptId);
} }

View File

@@ -3,5 +3,15 @@
<mapper namespace="com.njcn.gather.script.mapper.PqScriptDtlsMapper"> <mapper namespace="com.njcn.gather.script.mapper.PqScriptDtlsMapper">
<select id="selectMaxIndex" resultType="java.lang.Integer">
SELECT
max( t.INDEX )
FROM
pq_script_dtls t
WHERE
Script_Id = ${scriptId}
</select>
</mapper> </mapper>

View File

@@ -1,6 +1,8 @@
package com.njcn.gather.script.pojo.po; package com.njcn.gather.script.pojo.po;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data; import lombok.Data;
@@ -18,6 +20,7 @@ public class PqScriptDtls implements Serializable {
/** /**
* 检测脚本子表ID * 检测脚本子表ID
*/ */
@TableId(value = "Id", type = IdType.ASSIGN_UUID)
private String id; private String id;
/** /**

View File

@@ -69,4 +69,13 @@ public interface IPqScriptDtlsService extends IService<PqScriptDtls> {
* @return index列表 * @return index列表
*/ */
List<Integer> getIndexList(String scriptType, String scriptId); List<Integer> getIndexList(String scriptType, String scriptId);
/**
* 检测脚本单次小项数据新增
* @param sourceIssue
* @return
*/
Boolean saveScriptDtls(SourceIssue sourceIssue);
Boolean saveCheck();
} }

View File

@@ -36,7 +36,7 @@ public interface IPqScriptService extends IService<PqScript> {
* @param param 检测脚本 * @param param 检测脚本
* @return 成功返回true, 失败返回false * @return 成功返回true, 失败返回false
*/ */
boolean addPqScript(PqScriptParam param); String addPqScript(PqScriptParam param);
/** /**
* 删除检测脚本 * 删除检测脚本

View File

@@ -220,6 +220,114 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl<PqScriptDtlsMapper, PqS
return this.getBaseMapper().selectJoinList(PqScriptDtls.class, wrapper).stream().map(PqScriptDtls::getIndex).collect(Collectors.toList()); return this.getBaseMapper().selectJoinList(PqScriptDtls.class, wrapper).stream().map(PqScriptDtls::getIndex).collect(Collectors.toList());
} }
@Override
@Transactional(rollbackFor = {Exception.class})
public Boolean saveScriptDtls(SourceIssue sourceIssue) {
List<PqScriptDtls> info = new ArrayList<>();
Integer i = this.baseMapper.selectMaxIndex(sourceIssue.getScriptId());
//频率赋值
PqScriptDtls dtls = setScriptDtls(sourceIssue, i);
dtls.setValueType(FREQ);
dtls.setPhase("T");
dtls.setValue(sourceIssue.getFFreq());
dtls.setAngle(0.0);
info.add(dtls);
//开始遍历通道信息
for (SourceIssue.ChannelListDTO channelListDTO : sourceIssue.getChannelList()) {
String phase = channelListDTO.getChannelType().substring(0, 1);
//电压或者电流
if (channelListDTO.getChannelFlag()) {
PqScriptDtls uOri = setScriptDtls(sourceIssue, i);
uOri.setPhase(phase);
if (channelListDTO.getChannelType().contains("U")) {
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")) {
harm.setValueType(HARM_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.getInHarmFlag()) {
List<SourceIssue.ChannelListDTO.InharmModel> inharmList = channelListDTO.getInharmList();
for (SourceIssue.ChannelListDTO.InharmModel inharmModel : inharmList) {
PqScriptDtls inHarm = setScriptDtls(sourceIssue, i);
if (channelListDTO.getChannelType().contains("U")) {
inHarm.setValueType(INHARM_V);
}
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.getDipFlag()) {
SourceIssue.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()) {
SourceIssue.ChannelListDTO.FlickerDataDTO flickerData = channelListDTO.getFlickerData();
PqScriptDtls dip = setScriptDtls(sourceIssue, i);
dip.setValueType(DIP);
dip.setPhase(phase);
dip.setChagFre(flickerData.getFChagFre());
dip.setChagValue(flickerData.getFChagValue());
info.add(dip);
}
}
if (CollUtil.isNotEmpty(info)) {
this.saveBatch(info);
}
return false;
}
@Override
public Boolean saveCheck() {
return null;
}
private PqScriptDtls setScriptDtls(SourceIssue sourceIssue, Integer i) {
PqScriptDtls dtls = new PqScriptDtls();
dtls.setScriptId(sourceIssue.getScriptId());
dtls.setIndex(i);
dtls.setScriptType(sourceIssue.getScriptId());
dtls.setScriptSubType(sourceIssue.getScriptId());
dtls.setEnable(DataStateEnum.ENABLE.getCode());
return dtls;
}
public List<PqScriptDtls> pqScriptDtls(String scriptId, String isPhaseSequence, Double volt, Double curr, List<Integer> indexList) { public List<PqScriptDtls> pqScriptDtls(String scriptId, String isPhaseSequence, Double volt, Double curr, List<Integer> indexList) {
List<PqScriptDtls> pqScriptDtls; List<PqScriptDtls> pqScriptDtls;
MPJLambdaWrapper<PqScriptDtls> queryWrapper = new MPJLambdaWrapper<>(); MPJLambdaWrapper<PqScriptDtls> queryWrapper = new MPJLambdaWrapper<>();
@@ -230,7 +338,9 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl<PqScriptDtlsMapper, PqS
// .le(PqScriptDtls::getIndex, 30) // .le(PqScriptDtls::getIndex, 30)
// .in(PqScriptDtls::getIndex, Arrays.asList(1,7)) // .in(PqScriptDtls::getIndex, Arrays.asList(1,7))
.eq(PqScriptCheckData::getEnable, DataStateEnum.ENABLE.getCode()); .eq(PqScriptCheckData::getEnable, DataStateEnum.ENABLE.getCode())
.orderByAsc(PqScriptCheckData::getIndex)
;
if (isPhaseSequence.equals(CommonEnum.PHASE_TEST.getValue())) { if (isPhaseSequence.equals(CommonEnum.PHASE_TEST.getValue())) {
//相序 //相序
queryWrapper.eq(PqScriptDtls::getIndex, -1) queryWrapper.eq(PqScriptDtls::getIndex, -1)

View File

@@ -56,12 +56,13 @@ public class PqScriptServiceImpl extends ServiceImpl<PqScriptMapper, PqScript> i
@Override @Override
@Transactional(rollbackFor = {Exception.class}) @Transactional(rollbackFor = {Exception.class})
public boolean addPqScript(PqScriptParam param) { public String addPqScript(PqScriptParam param) {
PqScript pqScript = new PqScript(); PqScript pqScript = new PqScript();
BeanUtils.copyProperties(param, pqScript); BeanUtils.copyProperties(param, pqScript);
pqScript.setStandardTime(LocalDate.of(Integer.parseInt(param.getStandardTime()), 1, 1)); pqScript.setStandardTime(LocalDate.of(Integer.parseInt(param.getStandardTime()), 1, 1));
pqScript.setState(DataStateEnum.ENABLE.getCode()); pqScript.setState(DataStateEnum.ENABLE.getCode());
return this.save(pqScript); this.save(pqScript);
return pqScript.getId();
} }
@Override @Override