This commit is contained in:
caozehui
2024-11-21 10:46:18 +08:00
parent d94c03cba1
commit 614849de64
4 changed files with 17 additions and 13 deletions

View File

@@ -78,7 +78,16 @@ public interface DeviceValidMessage {
String STANDARD_NAME_NOT_BLANK = "参照标准名称不能为空请检查standardName参数";
String STANDARD_NAME_FORMAT_ERROR = "参照标准名称格式错误请检查standardName参数";
String STANDARD_TIME_NOT_BLANK = "标准推行时间不能为空请检查standardTime参数";
String SCRIPT_TYPE_FORMAT_ERROR = "检测脚本类型格式错误请检查scriptType参数";
String DEV_LEVEL_NOT_BLANK = "设备等级不能为空请检查devLevel参数";
String DEV_LEVEL_FORMAT_ERROR = "设备等级格式错误请检查devLevel参数";
String ENABLE_FORMAT_ERROR = "是否启用格式错误请检查enable参数";
}

View File

@@ -22,13 +22,10 @@ public class PqScriptParam {
@NotBlank(message = DeviceValidMessage.NAME_NOT_BLANK)
private String name;
/**
* 检测脚本类型,字典表(脚本还是模板)
*/
@ApiModelProperty("类型")
@NotNull(message = DeviceValidMessage.SCRIPT_TYPE_NOT_BLANK)
@Min(value = 1, message = DeviceValidMessage.SCRIPT_TYPE_FORMAT_ERROR)
@Max(value = 2, message = DeviceValidMessage.SCRIPT_TYPE_FORMAT_ERROR)
@Min(value = 0, message = DeviceValidMessage.SCRIPT_TYPE_FORMAT_ERROR)
@Max(value = 1, message = DeviceValidMessage.SCRIPT_TYPE_FORMAT_ERROR)
private Integer type;
/**
@@ -44,19 +41,15 @@ public class PqScriptParam {
@ApiModelProperty("值类型")
private String valueType;
/**
* 参照标准名称
*/
@ApiModelProperty("参照标准名称")
@NotBlank(message = DeviceValidMessage.STANDARD_NAME_NOT_BLANK)
@Pattern(regexp = PatternRegex.ERR_SYS_NAME, message = DeviceValidMessage.STANDARD_NAME_FORMAT_ERROR)
private String standardName;
/**
* 标准推行时间
*/
@ApiModelProperty("标准推行时间")
@DateTimeStrValid(message = DeviceValidMessage.STANDARD_TIME_FORMAT_ERROR)
@NotBlank(message = DeviceValidMessage.STANDARD_TIME_NOT_BLANK)
@DateTimeStrValid(format = "yyyy", message = DeviceValidMessage.STANDARD_TIME_FORMAT_ERROR)
private String standardTime;
@Data

View File

@@ -58,7 +58,7 @@ public class PqScript extends BaseEntity implements Serializable {
/**
* 标准推行时间
*/
@JsonFormat(pattern = "yyyy-MM-dd")
@JsonFormat(pattern = "yyyy")
@JsonDeserialize(using = LocalDateDeserializer.class)
@JsonSerialize(using = LocalDateSerializer.class)
private LocalDate standardTime;

View File

@@ -19,6 +19,7 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import java.time.LocalDate;
import java.util.List;
/**
@@ -49,6 +50,7 @@ public class PqScriptServiceImpl extends ServiceImpl<PqScriptMapper, PqScript> i
public boolean addPqScript(PqScriptParam param) {
PqScript pqScript = new PqScript();
BeanUtils.copyProperties(param, pqScript);
pqScript.setStandardTime(LocalDate.of(Integer.parseInt(param.getStandardTime()), 1, 1));
pqScript.setState(DataStateEnum.ENABLE.getCode());
return this.save(pqScript);
}