PDI部件
This commit is contained in:
parent
d9da88e351
commit
ded51f12f1
|
|
@ -71,23 +71,17 @@ public class QmsPdiStatusItemControllerService {
|
|||
throw new NflgException(STATE.BusinessError, "静态/动态检测项的部件描述不能为空");
|
||||
}
|
||||
|
||||
// 状态为0或1时,部件状态不能为空
|
||||
if ((Objects.equals(request.getStatus(), 0) || Objects.equals(request.getStatus(), 1))
|
||||
&& request.getComponentStatus() == null) {
|
||||
throw new NflgException(STATE.BusinessError, "静态/动态检测项的部件状态不能为空");
|
||||
}
|
||||
|
||||
String operator = UserUtil.getUserName();
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
Long componentsId = null;
|
||||
|
||||
// 处理部件
|
||||
// 处理部件(部件状态复用检测项的status)
|
||||
if (StrUtil.isNotBlank(request.getComponentsDes())) {
|
||||
// 检查部件是否已存在(按检测规则ID + 名称 + 状态查询)
|
||||
QmsPdiComponentAnagement existingComponent = componentAnagementService.lambdaQuery()
|
||||
.eq(QmsPdiComponentAnagement::getComponentName, request.getComponentsDes())
|
||||
.eq(QmsPdiComponentAnagement::getDetectionRulesId, request.getDetectionRulesId())
|
||||
.eq(QmsPdiComponentAnagement::getStatus, request.getComponentStatus())
|
||||
.eq(QmsPdiComponentAnagement::getStatus, request.getStatus())
|
||||
.one();
|
||||
|
||||
if (existingComponent != null) {
|
||||
|
|
@ -97,7 +91,7 @@ public class QmsPdiStatusItemControllerService {
|
|||
// 新部件,插入到部件表(sort按检测规则ID + 状态独立计算)
|
||||
Integer maxComponentSort = componentAnagementService.lambdaQuery()
|
||||
.eq(QmsPdiComponentAnagement::getDetectionRulesId, request.getDetectionRulesId())
|
||||
.eq(QmsPdiComponentAnagement::getStatus, request.getComponentStatus())
|
||||
.eq(QmsPdiComponentAnagement::getStatus, request.getStatus())
|
||||
.orderByDesc(QmsPdiComponentAnagement::getSort)
|
||||
.last("LIMIT 1")
|
||||
.oneOpt()
|
||||
|
|
@ -107,7 +101,7 @@ public class QmsPdiStatusItemControllerService {
|
|||
QmsPdiComponentAnagement component = new QmsPdiComponentAnagement();
|
||||
component.setComponentName(request.getComponentsDes());
|
||||
component.setDetectionRulesId(request.getDetectionRulesId());
|
||||
component.setStatus(request.getComponentStatus());
|
||||
component.setStatus(request.getStatus() != null ? request.getStatus().shortValue() : null);
|
||||
component.setSort(maxComponentSort + 1);
|
||||
component.setCreateBy(operator);
|
||||
component.setCreateTime(now);
|
||||
|
|
|
|||
|
|
@ -244,9 +244,9 @@ public class QmsPdiTaskRecordControllerService {
|
|||
return vo;
|
||||
}).collect(Collectors.toList());
|
||||
|
||||
// 按部件分组(componentsDes 相同的放一组,null 为特殊类型无部件)
|
||||
// 按部件分组(componentsId 相同的放一组,null 为特殊类型无部件)
|
||||
Map<String, List<QmsPdiTaskRecordDetailVO.StatusItemVO>> groupedByComponent = new LinkedHashMap<>();
|
||||
Map<String, Long> componentNameToId = new HashMap<>();
|
||||
Map<String, Long> groupKeyToComponentId = new HashMap<>();
|
||||
|
||||
for (int i = 0; i < allRecords.size(); i++) {
|
||||
QmsPdiInspectionResults r = allRecords.get(i);
|
||||
|
|
@ -254,14 +254,14 @@ public class QmsPdiTaskRecordControllerService {
|
|||
QmsPdiDetectionRulesStatusItem si = finalStatusMap.get(r.getInspectionItemId());
|
||||
|
||||
Long compId = (si != null) ? si.getComponentsId() : null;
|
||||
String compName = vo.getComponentsDes(); // 可能是 null
|
||||
|
||||
// 用部件ID作为分组 key(null 表示无部件)
|
||||
String groupKey = compId != null ? String.valueOf(compId) : "__null__";
|
||||
|
||||
groupedByComponent.computeIfAbsent(groupKey, k -> new ArrayList<>()).add(vo);
|
||||
if (compId != null && compName != null) {
|
||||
componentNameToId.putIfAbsent(groupKey, compId);
|
||||
// 记录分组的部件ID(不管部件名称是否为空)
|
||||
if (compId != null) {
|
||||
groupKeyToComponentId.putIfAbsent(groupKey, compId);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -271,7 +271,7 @@ public class QmsPdiTaskRecordControllerService {
|
|||
QmsPdiTaskRecordStatusItemGroupVO groupVO = new QmsPdiTaskRecordStatusItemGroupVO();
|
||||
String key = entry.getKey();
|
||||
if (!"__null__".equals(key)) {
|
||||
Long compId = componentNameToId.get(key);
|
||||
Long compId = groupKeyToComponentId.get(key);
|
||||
groupVO.setComponentsId(compId);
|
||||
QmsPdiComponentAnagement comp = finalComponentMap.get(compId);
|
||||
groupVO.setComponentName(comp != null ? comp.getComponentName() : null);
|
||||
|
|
|
|||
|
|
@ -21,11 +21,6 @@ public class QmsPdiStatusItemAddQO {
|
|||
*/
|
||||
private String componentsDes;
|
||||
|
||||
/**
|
||||
* 部件状态:0为静态,1为动态(当status为0或1时需要传)
|
||||
*/
|
||||
private Short componentStatus;
|
||||
|
||||
/**
|
||||
* 检查核实内容(必传)
|
||||
*/
|
||||
|
|
|
|||
Loading…
Reference in New Issue