检测脚本增加额定电压和电流(取消装置层获取)
This commit is contained in:
@@ -9,6 +9,7 @@ import lombok.Getter;
|
|||||||
@Getter
|
@Getter
|
||||||
public enum DetectionResponseEnum {
|
public enum DetectionResponseEnum {
|
||||||
PLAN_PATTERN_NOT("A020001", "计划模式查询为空"),
|
PLAN_PATTERN_NOT("A020001", "计划模式查询为空"),
|
||||||
|
SCRIPT_PATTERN_NOT("A020001", "检测脚本查询为空"),
|
||||||
SOURCE_INFO_NOT("A020002", "源表信息不存在"),
|
SOURCE_INFO_NOT("A020002", "源表信息不存在"),
|
||||||
PLAN_AND_SOURCE_NOT("A020003", "计划和源关系不存在"),
|
PLAN_AND_SOURCE_NOT("A020003", "计划和源关系不存在"),
|
||||||
ITEM_TEST_NOT("A020004", "检测项为空"),
|
ITEM_TEST_NOT("A020004", "检测项为空"),
|
||||||
|
|||||||
@@ -53,6 +53,26 @@ public class PqScriptParam {
|
|||||||
@DateTimeStrValid(format = "yyyy", message = DevValidMessage.STANDARD_TIME_FORMAT_ERROR)
|
@DateTimeStrValid(format = "yyyy", message = DevValidMessage.STANDARD_TIME_FORMAT_ERROR)
|
||||||
private String standardTime;
|
private String standardTime;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 额定电压
|
||||||
|
*/
|
||||||
|
@ApiModelProperty("额定电压")
|
||||||
|
@NotNull(message = DevValidMessage.SCRIPT_TYPE_NOT_BLANK)
|
||||||
|
@Min(value = 0, message = DevValidMessage.SCRIPT_TYPE_FORMAT_ERROR)
|
||||||
|
@Max(value = 380, message = DevValidMessage.SCRIPT_TYPE_FORMAT_ERROR)
|
||||||
|
private Double ratedVolt;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 额定电流
|
||||||
|
*/
|
||||||
|
@ApiModelProperty("额定电流")
|
||||||
|
@NotNull(message = DevValidMessage.SCRIPT_TYPE_NOT_BLANK)
|
||||||
|
@Min(value = 0, message = DevValidMessage.SCRIPT_TYPE_FORMAT_ERROR)
|
||||||
|
@Max(value = 20, message = DevValidMessage.SCRIPT_TYPE_FORMAT_ERROR)
|
||||||
|
private Double ratedCurr;
|
||||||
|
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
public static class QueryParam extends BaseParam {
|
public static class QueryParam extends BaseParam {
|
||||||
|
|||||||
@@ -63,6 +63,16 @@ public class PqScript extends BaseEntity implements Serializable {
|
|||||||
@JsonSerialize(using = LocalDateSerializer.class)
|
@JsonSerialize(using = LocalDateSerializer.class)
|
||||||
private LocalDate standardTime;
|
private LocalDate standardTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 额定电压
|
||||||
|
*/
|
||||||
|
private Double ratedVolt;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 额定电流
|
||||||
|
*/
|
||||||
|
private Double ratedCurr;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 状态:0-删除 1-正常
|
* 状态:0-删除 1-正常
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -9,7 +9,9 @@ import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|||||||
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.common.pojo.enums.common.DataStateEnum;
|
import com.njcn.common.pojo.enums.common.DataStateEnum;
|
||||||
|
import com.njcn.common.pojo.exception.BusinessException;
|
||||||
import com.njcn.gather.detection.pojo.enums.DetectionCodeEnum;
|
import com.njcn.gather.detection.pojo.enums.DetectionCodeEnum;
|
||||||
|
import com.njcn.gather.detection.pojo.enums.DetectionResponseEnum;
|
||||||
import com.njcn.gather.device.pojo.enums.CommonEnum;
|
import com.njcn.gather.device.pojo.enums.CommonEnum;
|
||||||
import com.njcn.gather.device.pojo.po.PqDev;
|
import com.njcn.gather.device.pojo.po.PqDev;
|
||||||
import com.njcn.gather.device.service.IPqDevService;
|
import com.njcn.gather.device.service.IPqDevService;
|
||||||
@@ -131,17 +133,15 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl<PqScriptDtlsMapper, PqS
|
|||||||
boolean devFly = CollUtil.isNotEmpty(param.getDevIds());
|
boolean devFly = CollUtil.isNotEmpty(param.getDevIds());
|
||||||
if (devFly) {
|
if (devFly) {
|
||||||
//校验终端额定电压电流是否相同
|
//校验终端额定电压电流是否相同
|
||||||
List<PqDev> list = pqDevService.list(new LambdaQueryWrapper<PqDev>()
|
PqScript pqScript = pqScriptMapper.selectOne(new LambdaQueryWrapper<PqScript>()
|
||||||
.eq(StrUtil.isNotBlank(param.getPlanId()), PqDev::getPlanId, param.getPlanId())
|
.eq(PqScript::getId, param.getScriptId()));
|
||||||
.in(PqDev::getId, param.getDevIds())
|
if(ObjectUtil.isNull(pqScript)){
|
||||||
.eq(PqDev::getState, DataStateEnum.ENABLE.getCode())
|
throw new BusinessException(DetectionResponseEnum.SCRIPT_PATTERN_NOT);
|
||||||
);
|
}
|
||||||
Set<String> devTypeSet = list.stream().map(PqDev::getDevType).collect(Collectors.toSet());
|
|
||||||
List<DevType> devTypes = devTypeService.listByIds(devTypeSet);
|
|
||||||
//额定电压信息
|
//额定电压信息
|
||||||
voltSet = devTypes.stream().map(DevType::getDevVolt).collect(Collectors.toSet());
|
voltSet.add(pqScript.getRatedVolt());
|
||||||
//额定电流信息
|
//额定电流信息
|
||||||
currSet = devTypes.stream().map(DevType::getDevCurr).collect(Collectors.toSet());
|
currSet.add(pqScript.getRatedCurr());
|
||||||
} else {
|
} else {
|
||||||
if (param.getType() == 0) {
|
if (param.getType() == 0) {
|
||||||
voltSet.add(1.0);
|
voltSet.add(1.0);
|
||||||
@@ -154,7 +154,6 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl<PqScriptDtlsMapper, PqS
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (voltSet.size() == 1 && currSet.size() == 1) {
|
if (voltSet.size() == 1 && currSet.size() == 1) {
|
||||||
Double volt = voltSet.stream().collect(Collectors.toList()).stream().findFirst().get();
|
Double volt = voltSet.stream().collect(Collectors.toList()).stream().findFirst().get();
|
||||||
Double curr = currSet.stream().collect(Collectors.toList()).stream().findFirst().get();
|
Double curr = currSet.stream().collect(Collectors.toList()).stream().findFirst().get();
|
||||||
|
|||||||
Reference in New Issue
Block a user