refactor(QmsInspectionStandard): 修改版本号类型并调整版本逻辑
- 将QmsInspectionStandard实体中version字段类型由Integer改为String - 注释掉自动生成版本号的方法及相关调用,修改为直接使用传入的version值 - QmsInspectionStandardControllerService中设置版本号及启用状态使用编辑请求数据 - QmsInspectionStandardEditQO中新增version和isEnabled字段,增加参数校验 - 将部分流操作由collect(Collectors.toList())替换为toList()方法调用,提高代码简洁性
This commit is contained in:
parent
b31f6dd847
commit
22f880117d
|
|
@ -255,12 +255,12 @@ public class QmsInspectionStandardControllerService {
|
|||
LocalDateTime now = LocalDateTime.now();
|
||||
|
||||
// 自动生成版本号:查询该物料已发布的最大版本号,如果存在则加1,否则默认为1
|
||||
Integer versionNo = generateVersionNo(qo.getMaterialId());
|
||||
// Integer versionNo = generateVersionNo(qo.getMaterialId());
|
||||
|
||||
QmsInspectionStandard standard = new QmsInspectionStandard();
|
||||
standard.setMaterialId(qo.getMaterialId());
|
||||
standard.setDrawingUrl(qo.getDrawingUrl());
|
||||
standard.setVersion(versionNo);
|
||||
// standard.setVersion(versionNo);
|
||||
standard.setPackagingMethodId(qo.getPackagingMethodId());
|
||||
standard.setInspectionCycle(qo.getInspectionCycle());
|
||||
// 默认值
|
||||
|
|
@ -285,34 +285,34 @@ public class QmsInspectionStandardControllerService {
|
|||
return standard.getId();
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成版本号:查询该物料已发布的最大版本号,如果存在则加1,否则默认为1
|
||||
* @param materialId 物料ID
|
||||
* @return 版本号
|
||||
*/
|
||||
private Integer generateVersionNo(Long materialId) {
|
||||
// 查询该物料已发布的检验标准
|
||||
List<QmsInspectionStandard> publishedStandards = inspectionStandardService.lambdaQuery()
|
||||
.eq(QmsInspectionStandard::getMaterialId, materialId)
|
||||
.eq(QmsInspectionStandard::getPublishStatus, 1)
|
||||
.isNotNull(QmsInspectionStandard::getVersion)
|
||||
.list();
|
||||
|
||||
if (publishedStandards == null || publishedStandards.isEmpty()) {
|
||||
// 如果没有已发布的版本,默认版本号为1
|
||||
return 1;
|
||||
}
|
||||
|
||||
// 查找最大版本号
|
||||
int maxVersion = publishedStandards.stream()
|
||||
.map(QmsInspectionStandard::getVersion)
|
||||
.mapToInt(version -> version != null ? version : 0)
|
||||
.max()
|
||||
.orElse(0);
|
||||
|
||||
// 返回最大版本号加1
|
||||
return maxVersion + 1;
|
||||
}
|
||||
// /**
|
||||
// * 生成版本号:查询该物料已发布的最大版本号,如果存在则加1,否则默认为1
|
||||
// * @param materialId 物料ID
|
||||
// * @return 版本号
|
||||
// */
|
||||
// private Integer generateVersionNo(Long materialId) {
|
||||
// // 查询该物料已发布的检验标准
|
||||
// List<QmsInspectionStandard> publishedStandards = inspectionStandardService.lambdaQuery()
|
||||
// .eq(QmsInspectionStandard::getMaterialId, materialId)
|
||||
// .eq(QmsInspectionStandard::getPublishStatus, 1)
|
||||
// .isNotNull(QmsInspectionStandard::getVersion)
|
||||
// .list();
|
||||
//
|
||||
// if (publishedStandards == null || publishedStandards.isEmpty()) {
|
||||
// // 如果没有已发布的版本,默认版本号为1
|
||||
// return 1;
|
||||
// }
|
||||
//
|
||||
// // 查找最大版本号
|
||||
// int maxVersion = publishedStandards.stream()
|
||||
// .map(QmsInspectionStandard::getVersion)
|
||||
// .mapToInt(version -> version != null ? version : 0)
|
||||
// .max()
|
||||
// .orElse(0);
|
||||
//
|
||||
// // 返回最大版本号加1
|
||||
// return maxVersion + 1;
|
||||
// }
|
||||
|
||||
/**
|
||||
* 编辑检验标准(包含检测项列表)
|
||||
|
|
@ -340,6 +340,8 @@ public class QmsInspectionStandardControllerService {
|
|||
standard.setDrawingUrl(qo.getDrawingUrl());
|
||||
standard.setPackagingMethodId(qo.getPackagingMethodId());
|
||||
standard.setInspectionCycle(qo.getInspectionCycle());
|
||||
standard.setVersion(qo.getVersion());
|
||||
standard.setIsEnabled(qo.getIsEnabled());
|
||||
// 审计字段
|
||||
standard.setUpdateUserId(userId);
|
||||
standard.setUpdateUserName(userName);
|
||||
|
|
@ -369,7 +371,7 @@ public class QmsInspectionStandardControllerService {
|
|||
.list()
|
||||
.stream()
|
||||
.map(QmsInspectionStandardItem::getId)
|
||||
.collect(Collectors.toList());
|
||||
.toList();
|
||||
|
||||
// 处理传入的检测项
|
||||
List<Long> newItemIds = new ArrayList<>();
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package com.nflg.wms.common.pojo.qo;
|
||||
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
|
@ -16,4 +17,16 @@ public class QmsInspectionStandardEditQO extends QmsInspectionStandardAddQO {
|
|||
*/
|
||||
@NotNull(message = "检验标准ID不能为空")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 版本号
|
||||
*/
|
||||
@NotBlank
|
||||
private String version;
|
||||
|
||||
/**
|
||||
* 是否启用
|
||||
*/
|
||||
@NotNull
|
||||
private Boolean isEnabled;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ public class QmsInspectionStandard implements Serializable {
|
|||
/**
|
||||
* 版本号
|
||||
*/
|
||||
private Integer version;
|
||||
private String version;
|
||||
|
||||
/**
|
||||
* 是否启用
|
||||
|
|
|
|||
Loading…
Reference in New Issue