pdi功能修改
This commit is contained in:
parent
d9c01921f7
commit
69dd1c665b
|
|
@ -45,16 +45,21 @@ public class QmsPdiDeliveryItemControllerService {
|
||||||
*/
|
*/
|
||||||
@Transactional
|
@Transactional
|
||||||
public void add(QmsPdiDeliveryItemAddQO request) {
|
public void add(QmsPdiDeliveryItemAddQO request) {
|
||||||
// 如果传入了sort,校验同一检测规则ID下sort是否已存在
|
// 查询同一检测规则ID下的最大sort值
|
||||||
if (request.getSort() != null) {
|
Integer maxSort = deliveryItemService.lambdaQuery()
|
||||||
long count = deliveryItemService.lambdaQuery()
|
|
||||||
.eq(QmsPdiDetectionRulesDeliveryItem::getDetectionRulesId, request.getDetectionRulesId())
|
.eq(QmsPdiDetectionRulesDeliveryItem::getDetectionRulesId, request.getDetectionRulesId())
|
||||||
.eq(QmsPdiDetectionRulesDeliveryItem::getSort, request.getSort())
|
.orderByDesc(QmsPdiDetectionRulesDeliveryItem::getSort)
|
||||||
.count();
|
.last("LIMIT 1")
|
||||||
if (count > 0) {
|
.oneOpt()
|
||||||
throw new NflgException(STATE.BusinessError,
|
.map(QmsPdiDetectionRulesDeliveryItem::getSort)
|
||||||
"该检测规则下排序值" + request.getSort() + "已存在,不允许新增");
|
.orElse(0);
|
||||||
}
|
|
||||||
|
// 将已有数据的sort全部+1
|
||||||
|
if (maxSort > 0) {
|
||||||
|
deliveryItemService.lambdaUpdate()
|
||||||
|
.eq(QmsPdiDetectionRulesDeliveryItem::getDetectionRulesId, request.getDetectionRulesId())
|
||||||
|
.setSql("sort = sort + 1")
|
||||||
|
.update();
|
||||||
}
|
}
|
||||||
|
|
||||||
String operator = UserUtil.getUserName();
|
String operator = UserUtil.getUserName();
|
||||||
|
|
@ -62,7 +67,7 @@ public class QmsPdiDeliveryItemControllerService {
|
||||||
QmsPdiDetectionRulesDeliveryItem entity = new QmsPdiDetectionRulesDeliveryItem()
|
QmsPdiDetectionRulesDeliveryItem entity = new QmsPdiDetectionRulesDeliveryItem()
|
||||||
.setDetectionRulesId(request.getDetectionRulesId())
|
.setDetectionRulesId(request.getDetectionRulesId())
|
||||||
.setChecklist(request.getChecklist())
|
.setChecklist(request.getChecklist())
|
||||||
.setSort(request.getSort())
|
.setSort(1) // 新数据sort=1
|
||||||
.setCreateBy(operator)
|
.setCreateBy(operator)
|
||||||
.setCreateTime(now);
|
.setCreateTime(now);
|
||||||
deliveryItemService.save(entity);
|
deliveryItemService.save(entity);
|
||||||
|
|
|
||||||
|
|
@ -53,17 +53,23 @@ public class QmsPdiStatusItemControllerService {
|
||||||
throw new NflgException(STATE.BusinessError, "静态/动态检测项的部件描述不能为空");
|
throw new NflgException(STATE.BusinessError, "静态/动态检测项的部件描述不能为空");
|
||||||
}
|
}
|
||||||
|
|
||||||
// 如果传入了sort,校验同一检测规则ID+同一状态下sort是否已存在
|
// 查询同一检测规则ID+同一状态下的最大sort值
|
||||||
if (request.getSort() != null) {
|
Integer maxSort = statusItemService.lambdaQuery()
|
||||||
long count = statusItemService.lambdaQuery()
|
|
||||||
.eq(QmsPdiDetectionRulesStatusItem::getDetectionRulesId, request.getDetectionRulesId())
|
.eq(QmsPdiDetectionRulesStatusItem::getDetectionRulesId, request.getDetectionRulesId())
|
||||||
.eq(QmsPdiDetectionRulesStatusItem::getStatus, request.getStatus())
|
.eq(QmsPdiDetectionRulesStatusItem::getStatus, request.getStatus())
|
||||||
.eq(QmsPdiDetectionRulesStatusItem::getSort, request.getSort())
|
.orderByDesc(QmsPdiDetectionRulesStatusItem::getSort)
|
||||||
.count();
|
.last("LIMIT 1")
|
||||||
if (count > 0) {
|
.oneOpt()
|
||||||
throw new NflgException(STATE.BusinessError,
|
.map(QmsPdiDetectionRulesStatusItem::getSort)
|
||||||
"该检测规则下状态" + request.getStatus() + "的排序值" + request.getSort() + "已存在,不允许新增");
|
.orElse(0);
|
||||||
}
|
|
||||||
|
// 将已有数据的sort全部+1
|
||||||
|
if (maxSort > 0) {
|
||||||
|
statusItemService.lambdaUpdate()
|
||||||
|
.eq(QmsPdiDetectionRulesStatusItem::getDetectionRulesId, request.getDetectionRulesId())
|
||||||
|
.eq(QmsPdiDetectionRulesStatusItem::getStatus, request.getStatus())
|
||||||
|
.setSql("sort = sort + 1")
|
||||||
|
.update();
|
||||||
}
|
}
|
||||||
|
|
||||||
String operator = UserUtil.getUserName();
|
String operator = UserUtil.getUserName();
|
||||||
|
|
@ -74,7 +80,7 @@ public class QmsPdiStatusItemControllerService {
|
||||||
.setInspectionContent(request.getInspectionContent())
|
.setInspectionContent(request.getInspectionContent())
|
||||||
.setInspectionImage(request.getInspectionImage())
|
.setInspectionImage(request.getInspectionImage())
|
||||||
.setStatus(request.getStatus())
|
.setStatus(request.getStatus())
|
||||||
.setSort(request.getSort())
|
.setSort(1) // 新数据sort=1
|
||||||
.setSetBy(operator)
|
.setSetBy(operator)
|
||||||
.setSetTime(now);
|
.setSetTime(now);
|
||||||
statusItemService.save(entity);
|
statusItemService.save(entity);
|
||||||
|
|
|
||||||
|
|
@ -21,9 +21,4 @@ public class QmsPdiDeliveryItemAddQO {
|
||||||
*/
|
*/
|
||||||
@NotBlank(message = "检查项不能为空")
|
@NotBlank(message = "检查项不能为空")
|
||||||
private String checklist;
|
private String checklist;
|
||||||
|
|
||||||
/**
|
|
||||||
* 排序
|
|
||||||
*/
|
|
||||||
private Integer sort;
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -38,9 +38,4 @@ public class QmsPdiStatusItemAddQO {
|
||||||
*/
|
*/
|
||||||
@NotNull(message = "状态不能为空")
|
@NotNull(message = "状态不能为空")
|
||||||
private Integer status;
|
private Integer status;
|
||||||
|
|
||||||
/**
|
|
||||||
* 排序
|
|
||||||
*/
|
|
||||||
private Integer sort;
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue