parent
3e3796ccfb
commit
6759fb6ab5
|
|
@ -22,6 +22,7 @@ import org.springframework.stereotype.Component;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.atomic.AtomicReference;
|
import java.util.concurrent.atomic.AtomicReference;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
@ -610,6 +611,61 @@ public class QmsIssueTicketControllerService {
|
||||||
issueTicketService.save(entity);
|
issueTicketService.save(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改巡检工单(发起前)
|
||||||
|
* 仅允许创建人修改,且工单状态必须为待流转(0)
|
||||||
|
*/
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public void updateInspectionTicket(QmsIssueTicketUpdateQO request) {
|
||||||
|
Long currentUserId = UserUtil.getUserId();
|
||||||
|
String currentUserName = UserUtil.getUserName();
|
||||||
|
LocalDateTime now = LocalDateTime.now();
|
||||||
|
|
||||||
|
// 1. 查询工单
|
||||||
|
QmsIssueTicket ticket = issueTicketService.getById(request.getId());
|
||||||
|
VUtil.trueThrowBusinessError(ticket == null).throwMessage("工单不存在");
|
||||||
|
|
||||||
|
// 2. 权限校验:只有创建人才能修改
|
||||||
|
VUtil.trueThrowBusinessError(!ticket.getCreateUserId().equals(currentUserId))
|
||||||
|
.throwMessage("只有创建人才能修改工单");
|
||||||
|
|
||||||
|
// 3. 状态校验:只有待流转状态才能修改
|
||||||
|
VUtil.trueThrowBusinessError(ticket.getStatus() != 0)
|
||||||
|
.throwMessage("只有待流转状态的工单才能修改");
|
||||||
|
|
||||||
|
// 4. 来源类型校验:只能修改巡检工单
|
||||||
|
VUtil.trueThrowBusinessError(ticket.getSourceType() != 2)
|
||||||
|
.throwMessage("只能修改巡检工单");
|
||||||
|
|
||||||
|
// 5. 校验是否已设置负责人(已发起)
|
||||||
|
VUtil.trueThrowBusinessError(ticket.getApprovalUserId() != null)
|
||||||
|
.throwMessage("工单已发起,不允许修改");
|
||||||
|
|
||||||
|
// 6. 更新工单信息
|
||||||
|
issueTicketService.lambdaUpdate()
|
||||||
|
.eq(QmsIssueTicket::getId, request.getId())
|
||||||
|
.set(QmsIssueTicket::getTicketTitle, request.getTicketTitle())
|
||||||
|
.set(QmsIssueTicket::getProjectNo, request.getProjectNo())
|
||||||
|
.set(QmsIssueTicket::getIncidentType, request.getIncidentType())
|
||||||
|
.set(QmsIssueTicket::getExceptionCode, request.getExceptionCode())
|
||||||
|
.set(QmsIssueTicket::getUnqualifiedQty, request.getUnqualifiedQty())
|
||||||
|
.set(QmsIssueTicket::getImpactQuantity, request.getImpactQuantity())
|
||||||
|
.set(QmsIssueTicket::getIncidentLocation, request.getIncidentLocation())
|
||||||
|
.set(QmsIssueTicket::getIncidentDescription, request.getIncidentDescription())
|
||||||
|
.set(QmsIssueTicket::getIncidentReason, request.getIncidentReason())
|
||||||
|
.set(QmsIssueTicket::getIncidentConsequence, request.getIncidentConsequence())
|
||||||
|
.set(QmsIssueTicket::getImageIds, request.getImages() == null
|
||||||
|
? ""
|
||||||
|
: StrUtil.join(",", request.getImages().stream()
|
||||||
|
.map(com.nflg.wms.common.pojo.vo.FileUploadVO::getId)
|
||||||
|
.toList()))
|
||||||
|
.set(QmsIssueTicket::getRemark, request.getRemark())
|
||||||
|
.set(QmsIssueTicket::getUpdateUserId, currentUserId)
|
||||||
|
.set(QmsIssueTicket::getUpdateUserName, currentUserName)
|
||||||
|
.set(QmsIssueTicket::getUpdateTime, now)
|
||||||
|
.update();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 平板端查询巡检工单列表
|
* 平板端查询巡检工单列表
|
||||||
* 仅查询当前登录人创建的巡检工单(sourceType=2)
|
* 仅查询当前登录人创建的巡检工单(sourceType=2)
|
||||||
|
|
@ -1008,224 +1064,228 @@ public class QmsIssueTicketControllerService {
|
||||||
* 返回工单基本信息及处理记录、措施列表
|
* 返回工单基本信息及处理记录、措施列表
|
||||||
*/
|
*/
|
||||||
public QmsPdiTicketDetailVO getPdiTicketDetail(Long id) {
|
public QmsPdiTicketDetailVO getPdiTicketDetail(Long id) {
|
||||||
// 查询工单基本信息
|
// // 查询工单基本信息
|
||||||
QmsIssueTicket ticket = issueTicketService.getById(id);
|
// QmsIssueTicket ticket = issueTicketService.getById(id);
|
||||||
QmsPdiTicketDetailVO vo = new QmsPdiTicketDetailVO();
|
// QmsPdiTicketDetailVO vo = new QmsPdiTicketDetailVO();
|
||||||
vo.setTicketNo(ticket.getTicketNo());
|
// vo.setTicketNo(ticket.getTicketNo());
|
||||||
vo.setTicketTitle(ticket.getTicketTitle());
|
// vo.setTicketTitle(ticket.getTicketTitle());
|
||||||
vo.setProjectNo(ticket.getProjectNo());
|
// vo.setProjectNo(ticket.getProjectNo());
|
||||||
vo.setIncidentType(ticket.getIncidentType());
|
// vo.setIncidentType(ticket.getIncidentType());
|
||||||
vo.setExceptionCode(ticket.getExceptionCode());
|
// vo.setExceptionCode(ticket.getExceptionCode());
|
||||||
vo.setUnqualifiedQty(ticket.getUnqualifiedQty());
|
// vo.setUnqualifiedQty(ticket.getUnqualifiedQty());
|
||||||
vo.setCreator(ticket.getCreateUserName());
|
// vo.setCreator(ticket.getCreateUserName());
|
||||||
vo.setCreateTime(ticket.getCreateTime());
|
// vo.setCreateTime(ticket.getCreateTime());
|
||||||
vo.setStatus(ticket.getStatus());
|
// vo.setStatus(ticket.getStatus());
|
||||||
vo.setCompleteTime(ticket.getCompleteTime()); // 设置完成时间
|
// vo.setCompleteTime(ticket.getCompleteTime()); // 设置完成时间
|
||||||
|
//
|
||||||
// 查询工单类型:PDI-新机检测 或 PDI-库存检测
|
// // 查询工单类型:PDI-新机检测 或 PDI-库存检测
|
||||||
if (ticket.getSourceId() != null) {
|
// if (ticket.getSourceId() != null) {
|
||||||
QmsPdiTaskRecord taskRecord = pdiTaskRecordService.getById(ticket.getSourceId());
|
// QmsPdiTaskRecord taskRecord = pdiTaskRecordService.getById(ticket.getSourceId());
|
||||||
if (taskRecord != null && taskRecord.getDetectionRulesId() != null) {
|
// if (taskRecord != null && taskRecord.getDetectionRulesId() != null) {
|
||||||
QmsPdiDetectionRules detectionRules = pdiDetectionRulesService.getById(taskRecord.getDetectionRulesId());
|
// QmsPdiDetectionRules detectionRules = pdiDetectionRulesService.getById(taskRecord.getDetectionRulesId());
|
||||||
if (detectionRules != null && detectionRules.getInspectionType() != null) {
|
// if (detectionRules != null && detectionRules.getInspectionType() != null) {
|
||||||
String inspectionTypeStr = detectionRules.getInspectionType() == 0 ? "新机检测" : "库存检测";
|
// String inspectionTypeStr = detectionRules.getInspectionType() == 0 ? "新机检测" : "库存检测";
|
||||||
vo.setTicketType("PDI-" + inspectionTypeStr);
|
// vo.setTicketType("PDI-" + inspectionTypeStr);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
// 查询处理记录列表
|
// // 查询处理记录列表
|
||||||
List<QmsIssueTicketProcess> processes = issueTicketProcessService.lambdaQuery()
|
// List<QmsIssueTicketProcess> processes = issueTicketProcessService.lambdaQuery()
|
||||||
.eq(QmsIssueTicketProcess::getIssueTicketId, id)
|
// .eq(QmsIssueTicketProcess::getIssueTicketId, id)
|
||||||
.list();
|
// .list();
|
||||||
|
//
|
||||||
// 构建不合格检测项列表(每项关联处理信息)
|
// // 构建不合格检测项列表(每项关联处理信息)
|
||||||
List<QmsPdiTicketDetailVO.InspectionItemVO> inspectionItems = new ArrayList<>();
|
// List<QmsPdiTicketDetailVO.InspectionItemVO> inspectionItems = new ArrayList<>();
|
||||||
String rootCause = null;
|
// String rootCause = null;
|
||||||
List<QmsPdiTicketDetailVO.MeasureVO> temporaryMeasures = new ArrayList<>();
|
// List<QmsPdiTicketDetailVO.MeasureVO> temporaryMeasures = new ArrayList<>();
|
||||||
List<QmsPdiTicketDetailVO.MeasureVO> permanentMeasures = new ArrayList<>();
|
// List<QmsPdiTicketDetailVO.MeasureVO> permanentMeasures = new ArrayList<>();
|
||||||
|
//
|
||||||
for (QmsIssueTicketProcess process : processes) {
|
// for (QmsIssueTicketProcess process : processes) {
|
||||||
// 提取根本原因(取第一条)
|
// // 提取根本原因(取第一条)
|
||||||
if (rootCause == null && StrUtil.isNotBlank(process.getRootCause())) {
|
// if (rootCause == null && StrUtil.isNotBlank(process.getRootCause())) {
|
||||||
rootCause = process.getRootCause();
|
// rootCause = process.getRootCause();
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
// 查询该处理记录关联的不合格检测项
|
// // 查询该处理记录关联的不合格检测项
|
||||||
if (StrUtil.isNotBlank(process.getTaskResultIds())) {
|
// if (StrUtil.isNotBlank(process.getTaskResultIds())) {
|
||||||
String[] taskIds = process.getTaskResultIds().split(",");
|
// String[] taskIds = process.getTaskResultIds().split(",");
|
||||||
for (String taskId : taskIds) {
|
// for (String taskId : taskIds) {
|
||||||
if (StrUtil.isNotBlank(taskId)) {
|
// if (StrUtil.isNotBlank(taskId)) {
|
||||||
List<QmsPdiInspectionResults> unqualifiedResults = pdiInspectionResultsService.lambdaQuery()
|
// List<QmsPdiInspectionResults> unqualifiedResults = pdiInspectionResultsService.lambdaQuery()
|
||||||
.eq(QmsPdiInspectionResults::getTaskId, Long.parseLong(taskId.trim()))
|
// .eq(QmsPdiInspectionResults::getTaskId, Long.parseLong(taskId.trim()))
|
||||||
.eq(QmsPdiInspectionResults::getInspectionItemResults, false)
|
// .eq(QmsPdiInspectionResults::getInspectionItemResults, false)
|
||||||
.list();
|
// .list();
|
||||||
|
//
|
||||||
// 收集检测项ID(仅type=0/1/3)
|
// // 收集检测项ID(仅type=0/1/3)
|
||||||
Set<Long> statusItemIds = unqualifiedResults.stream()
|
// Set<Long> statusItemIds = unqualifiedResults.stream()
|
||||||
.filter(r -> r.getInspectionItemType() != null && r.getInspectionItemType() != 2)
|
// .filter(r -> r.getInspectionItemType() != null && r.getInspectionItemType() != 2)
|
||||||
.map(QmsPdiInspectionResults::getInspectionItemId)
|
// .map(QmsPdiInspectionResults::getInspectionItemId)
|
||||||
.filter(Objects::nonNull)
|
// .filter(Objects::nonNull)
|
||||||
.collect(Collectors.toSet());
|
// .collect(Collectors.toSet());
|
||||||
|
//
|
||||||
// 查询检测项信息
|
// // 查询检测项信息
|
||||||
Map<Long, QmsPdiDetectionRulesStatusItem> statusItemMap = new HashMap<>();
|
// Map<Long, QmsPdiDetectionRulesStatusItem> statusItemMap = new HashMap<>();
|
||||||
if (!statusItemIds.isEmpty()) {
|
// if (!statusItemIds.isEmpty()) {
|
||||||
List<QmsPdiDetectionRulesStatusItem> statusItems = pdiStatusItemService.lambdaQuery()
|
// List<QmsPdiDetectionRulesStatusItem> statusItems = pdiStatusItemService.lambdaQuery()
|
||||||
.in(QmsPdiDetectionRulesStatusItem::getId, statusItemIds)
|
// .in(QmsPdiDetectionRulesStatusItem::getId, statusItemIds)
|
||||||
.list();
|
// .list();
|
||||||
statusItemMap = statusItems.stream()
|
// statusItemMap = statusItems.stream()
|
||||||
.collect(Collectors.toMap(QmsPdiDetectionRulesStatusItem::getId, s -> s, (a, b) -> a));
|
// .collect(Collectors.toMap(QmsPdiDetectionRulesStatusItem::getId, s -> s, (a, b) -> a));
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
// 收集示例图ID
|
// // 收集示例图ID
|
||||||
Set<Long> exampleImageIds = statusItemMap.values().stream()
|
// Set<Long> exampleImageIds = statusItemMap.values().stream()
|
||||||
.map(QmsPdiDetectionRulesStatusItem::getInspectionImage)
|
// .map(QmsPdiDetectionRulesStatusItem::getInspectionImage)
|
||||||
.filter(StrUtil::isNotBlank)
|
// .filter(StrUtil::isNotBlank)
|
||||||
.flatMap(imageStr -> Arrays.stream(imageStr.split(",")))
|
// .flatMap(imageStr -> Arrays.stream(imageStr.split(",")))
|
||||||
.filter(StrUtil::isNotBlank)
|
// .filter(StrUtil::isNotBlank)
|
||||||
.map(Long::valueOf)
|
// .map(Long::valueOf)
|
||||||
.collect(Collectors.toSet());
|
// .collect(Collectors.toSet());
|
||||||
|
//
|
||||||
// 查询示例图
|
// // 查询示例图
|
||||||
Map<Long, FileUploadRecord> exampleImageMap = new HashMap<>();
|
// Map<Long, FileUploadRecord> exampleImageMap = new HashMap<>();
|
||||||
if (!exampleImageIds.isEmpty()) {
|
// if (!exampleImageIds.isEmpty()) {
|
||||||
List<FileUploadRecord> records = fileUploadRecordService.lambdaQuery()
|
// List<FileUploadRecord> records = fileUploadRecordService.lambdaQuery()
|
||||||
.in(FileUploadRecord::getId, exampleImageIds)
|
// .in(FileUploadRecord::getId, exampleImageIds)
|
||||||
.list();
|
// .list();
|
||||||
exampleImageMap = records.stream()
|
// exampleImageMap = records.stream()
|
||||||
.collect(Collectors.toMap(FileUploadRecord::getId, r -> r, (a, b) -> a));
|
// .collect(Collectors.toMap(FileUploadRecord::getId, r -> r, (a, b) -> a));
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
// 查询处理人部门信息
|
// // 查询处理人部门信息
|
||||||
Long handlerDeptId = null;
|
// Long handlerDeptId = null;
|
||||||
String handlerDeptName = null;
|
// String handlerDeptName = null;
|
||||||
if (process.getHandlerUserId() != null) {
|
// if (process.getHandlerUserId() != null) {
|
||||||
UserInterior userInterior = userInteriorService.lambdaQuery()
|
// UserInterior userInterior = userInteriorService.lambdaQuery()
|
||||||
.eq(UserInterior::getUserId, process.getHandlerUserId())
|
// .eq(UserInterior::getUserId, process.getHandlerUserId())
|
||||||
.one();
|
// .one();
|
||||||
if (userInterior != null && userInterior.getDeptId() != null) {
|
// if (userInterior != null && userInterior.getDeptId() != null) {
|
||||||
Department department = departmentService.getById(userInterior.getDeptId());
|
// Department department = departmentService.getById(userInterior.getDeptId());
|
||||||
if (department != null) {
|
// if (department != null) {
|
||||||
handlerDeptId = department.getId();
|
// handlerDeptId = department.getId();
|
||||||
handlerDeptName = department.getName();
|
// handlerDeptName = department.getName();
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
final Map<Long, QmsPdiDetectionRulesStatusItem> finalStatusItemMap = statusItemMap;
|
// final Map<Long, QmsPdiDetectionRulesStatusItem> finalStatusItemMap = statusItemMap;
|
||||||
final Map<Long, FileUploadRecord> finalExampleImageMap = exampleImageMap;
|
// final Map<Long, FileUploadRecord> finalExampleImageMap = exampleImageMap;
|
||||||
final Long finalHandlerDeptId = handlerDeptId;
|
// final Long finalHandlerDeptId = handlerDeptId;
|
||||||
final String finalHandlerDeptName = handlerDeptName;
|
// final String finalHandlerDeptName = handlerDeptName;
|
||||||
|
//
|
||||||
for (QmsPdiInspectionResults result : unqualifiedResults) {
|
// for (QmsPdiInspectionResults result : unqualifiedResults) {
|
||||||
QmsPdiTicketDetailVO.InspectionItemVO itemVO = new QmsPdiTicketDetailVO.InspectionItemVO();
|
// QmsPdiTicketDetailVO.InspectionItemVO itemVO = new QmsPdiTicketDetailVO.InspectionItemVO();
|
||||||
itemVO.setId(result.getId());
|
// itemVO.setId(result.getId());
|
||||||
itemVO.setInspectionItemId(result.getInspectionItemId());
|
// itemVO.setInspectionItemId(result.getInspectionItemId());
|
||||||
itemVO.setInspectionItemType(result.getInspectionItemType());
|
// itemVO.setInspectionItemType(result.getInspectionItemType());
|
||||||
itemVO.setInspectionItemImage(parseImageList(result.getInspectionItemImage()));
|
// itemVO.setInspectionItemImage(parseImageList(result.getInspectionItemImage()));
|
||||||
itemVO.setInspectionItemResults(result.getInspectionItemResults());
|
// itemVO.setInspectionItemResults(result.getInspectionItemResults());
|
||||||
itemVO.setRemark(result.getRemark());
|
// itemVO.setRemark(result.getRemark());
|
||||||
itemVO.setInspectorId(result.getInspectorId());
|
// itemVO.setInspectorId(result.getInspectorId());
|
||||||
itemVO.setInspectionTime(result.getInspectionTime());
|
// itemVO.setInspectionTime(result.getInspectionTime());
|
||||||
itemVO.setInspectionBy(result.getInspectionBy());
|
// itemVO.setInspectionBy(result.getInspectionBy());
|
||||||
|
//
|
||||||
// 填充检测项信息(仅type=0/1/3)
|
// // 填充检测项信息(仅type=0/1/3)
|
||||||
if (result.getInspectionItemType() != null && result.getInspectionItemType() != 2) {
|
// if (result.getInspectionItemType() != null && result.getInspectionItemType() != 2) {
|
||||||
QmsPdiDetectionRulesStatusItem statusItem = finalStatusItemMap.get(result.getInspectionItemId());
|
// QmsPdiDetectionRulesStatusItem statusItem = finalStatusItemMap.get(result.getInspectionItemId());
|
||||||
if (statusItem != null) {
|
// if (statusItem != null) {
|
||||||
itemVO.setComponentsDes(statusItem.getComponentsDes());
|
// itemVO.setComponentsDes(statusItem.getComponentsDes());
|
||||||
itemVO.setInspectionContent(statusItem.getInspectionContent());
|
// itemVO.setInspectionContent(statusItem.getInspectionContent());
|
||||||
// 解析示例图URL
|
// // 解析示例图URL
|
||||||
if (StrUtil.isNotBlank(statusItem.getInspectionImage())) {
|
// if (StrUtil.isNotBlank(statusItem.getInspectionImage())) {
|
||||||
String exampleUrl = Arrays.stream(statusItem.getInspectionImage().split(","))
|
// String exampleUrl = Arrays.stream(statusItem.getInspectionImage().split(","))
|
||||||
.filter(StrUtil::isNotBlank)
|
// .filter(StrUtil::isNotBlank)
|
||||||
.map(String::trim)
|
// .map(String::trim)
|
||||||
.map(Long::valueOf)
|
// .map(Long::valueOf)
|
||||||
.map(finalExampleImageMap::get)
|
// .map(finalExampleImageMap::get)
|
||||||
.filter(Objects::nonNull)
|
// .filter(Objects::nonNull)
|
||||||
.map(FileUploadRecord::getUrl)
|
// .map(FileUploadRecord::getUrl)
|
||||||
.findFirst()
|
// .findFirst()
|
||||||
.orElse(null);
|
// .orElse(null);
|
||||||
itemVO.setInspectionExampleImage(exampleUrl);
|
// itemVO.setInspectionExampleImage(exampleUrl);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
// 填充处理信息
|
// // 填充处理信息
|
||||||
itemVO.setHandlerUserId(process.getHandlerUserId());
|
// itemVO.setHandlerUserId(process.getHandlerUserId());
|
||||||
itemVO.setHandlerUserName(process.getHandlerUserName());
|
// itemVO.setHandlerUserName(process.getHandlerUserName());
|
||||||
itemVO.setHandlerDeptId(finalHandlerDeptId);
|
// itemVO.setHandlerDeptId(finalHandlerDeptId);
|
||||||
itemVO.setHandlerDeptName(finalHandlerDeptName);
|
// itemVO.setHandlerDeptName(finalHandlerDeptName);
|
||||||
itemVO.setProcessTime(process.getApprovalTime());
|
// itemVO.setProcessTime(process.getApprovalTime());
|
||||||
itemVO.setProcessStatus(process.getApprovalStatus());
|
// itemVO.setProcessStatus(process.getApprovalStatus());
|
||||||
itemVO.setApprovalUserId(process.getApprovalUserId());
|
// itemVO.setApprovalUserId(process.getApprovalUserId());
|
||||||
itemVO.setApprovalUserName(process.getApprovalUserName());
|
// itemVO.setApprovalUserName(process.getApprovalUserName());
|
||||||
itemVO.setApprovalTime(process.getApprovalTime());
|
// itemVO.setApprovalTime(process.getApprovalTime());
|
||||||
itemVO.setApprovalStatus(process.getApprovalStatus());
|
// itemVO.setApprovalStatus(process.getApprovalStatus());
|
||||||
|
//
|
||||||
inspectionItems.add(itemVO);
|
// inspectionItems.add(itemVO);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
// 查询措施列表,按措施类型区分临时/永久
|
// // 查询措施列表,按措施类型区分临时/永久
|
||||||
List<QmsIssueTicketProcessMeasure> measures = issueTicketProcessMeasureService.lambdaQuery()
|
// List<QmsIssueTicketProcessMeasure> measures = issueTicketProcessMeasureService.lambdaQuery()
|
||||||
.eq(QmsIssueTicketProcessMeasure::getIssueTicketProcessId, process.getId())
|
// .eq(QmsIssueTicketProcessMeasure::getIssueTicketProcessId, process.getId())
|
||||||
.list();
|
// .list();
|
||||||
|
//
|
||||||
// 查询字典项ID
|
// // 查询字典项ID
|
||||||
Long temporaryTypeId = dictionaryItemService.getIdByCode("MeasureType", "TemporaryCorrectiveMeasures");
|
// Long temporaryTypeId = dictionaryItemService.getIdByCode("MeasureType", "TemporaryCorrectiveMeasures");
|
||||||
Long permanentTypeId = dictionaryItemService.getIdByCode("MeasureType", "PermanentCorrectiveMeasures");
|
// Long permanentTypeId = dictionaryItemService.getIdByCode("MeasureType", "PermanentCorrectiveMeasures");
|
||||||
|
//
|
||||||
for (QmsIssueTicketProcessMeasure measure : measures) {
|
// for (QmsIssueTicketProcessMeasure measure : measures) {
|
||||||
QmsPdiTicketDetailVO.MeasureVO measureVO = new QmsPdiTicketDetailVO.MeasureVO();
|
// QmsPdiTicketDetailVO.MeasureVO measureVO = new QmsPdiTicketDetailVO.MeasureVO();
|
||||||
measureVO.setId(measure.getId());
|
// measureVO.setId(measure.getId());
|
||||||
measureVO.setMeasureTypeId(measure.getMeasureTypeId());
|
// measureVO.setMeasureTypeId(measure.getMeasureTypeId());
|
||||||
measureVO.setMeasureContent(measure.getMeasureContent());
|
// measureVO.setMeasureContent(measure.getMeasureContent());
|
||||||
measureVO.setChargeUser(measure.getChargeUser());
|
// measureVO.setChargeUser(measure.getChargeUser());
|
||||||
measureVO.setPlanDate(measure.getPlanDate());
|
// measureVO.setPlanDate(measure.getPlanDate());
|
||||||
measureVO.setConfirmDate(measure.getConfirmDate());
|
// measureVO.setConfirmDate(measure.getConfirmDate());
|
||||||
measureVO.setRemark(measure.getRemark());
|
// measureVO.setRemark(measure.getRemark());
|
||||||
|
//
|
||||||
// 根据measureTypeId区分临时措施和永久措施
|
// // 根据measureTypeId区分临时措施和永久措施
|
||||||
if (measure.getMeasureTypeId() != null) {
|
// if (measure.getMeasureTypeId() != null) {
|
||||||
if (measure.getMeasureTypeId().equals(temporaryTypeId)) {
|
// if (measure.getMeasureTypeId().equals(temporaryTypeId)) {
|
||||||
temporaryMeasures.add(measureVO);
|
// temporaryMeasures.add(measureVO);
|
||||||
} else if (measure.getMeasureTypeId().equals(permanentTypeId)) {
|
// } else if (measure.getMeasureTypeId().equals(permanentTypeId)) {
|
||||||
permanentMeasures.add(measureVO);
|
// permanentMeasures.add(measureVO);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
// 构建处理人信息(按部门分组)
|
// // 构建处理人信息(按部门分组)
|
||||||
Map<String, List<String>> handlers = new HashMap<>();
|
// Map<String, List<String>> handlers = new HashMap<>();
|
||||||
for (QmsIssueTicketProcess process : processes) {
|
// for (QmsIssueTicketProcess process : processes) {
|
||||||
if (process.getHandlerUserId() != null) {
|
// if (process.getHandlerUserId() != null) {
|
||||||
UserInterior userInterior = userInteriorService.lambdaQuery()
|
// UserInterior userInterior = userInteriorService.lambdaQuery()
|
||||||
.eq(UserInterior::getUserId, process.getHandlerUserId())
|
// .eq(UserInterior::getUserId, process.getHandlerUserId())
|
||||||
.one();
|
// .one();
|
||||||
if (userInterior != null && userInterior.getDeptId() != null) {
|
// if (userInterior != null && userInterior.getDeptId() != null) {
|
||||||
Department department = departmentService.getById(userInterior.getDeptId());
|
// Department department = departmentService.getById(userInterior.getDeptId());
|
||||||
if (department != null) {
|
// if (department != null) {
|
||||||
String deptName = department.getName();
|
// String deptName = department.getName();
|
||||||
handlers.computeIfAbsent(deptName, k -> new ArrayList<>())
|
// handlers.computeIfAbsent(deptName, k -> new ArrayList<>())
|
||||||
.add(process.getHandlerUserName());
|
// .add(process.getHandlerUserName());
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
vo.setInspectionItems(inspectionItems);
|
// vo.setInspectionItems(inspectionItems);
|
||||||
vo.setHandlers(handlers);
|
// vo.setHandlers(handlers);
|
||||||
vo.setRootCause(rootCause);
|
// vo.setRootCause(rootCause);
|
||||||
vo.setTemporaryMeasures(temporaryMeasures);
|
// vo.setTemporaryMeasures(temporaryMeasures);
|
||||||
vo.setPermanentMeasures(permanentMeasures);
|
// vo.setPermanentMeasures(permanentMeasures);
|
||||||
vo.setSignatures(new HashMap<>());
|
//
|
||||||
|
// // 构建相关人员签字(按部门,只返回已审批的)
|
||||||
return vo;
|
// Map<String, QmsPdiTicketMyDetailVO.SignatureInfo> signatures = buildSignatures(processes);
|
||||||
|
// vo.setSignatures(signatures);
|
||||||
|
//
|
||||||
|
// return vo;
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -1265,29 +1325,60 @@ public class QmsIssueTicketControllerService {
|
||||||
.list();
|
.list();
|
||||||
}
|
}
|
||||||
|
|
||||||
// 构建返回VO
|
// 构建返回VO - 工单基本信息
|
||||||
QmsPdiTicketMyDetailVO vo = new QmsPdiTicketMyDetailVO();
|
QmsPdiTicketMyDetailVO vo = new QmsPdiTicketMyDetailVO();
|
||||||
|
vo.setId(ticket.getId());
|
||||||
|
vo.setSourceType(ticket.getSourceType());
|
||||||
|
vo.setSourceId(ticket.getSourceId());
|
||||||
vo.setTicketNo(ticket.getTicketNo());
|
vo.setTicketNo(ticket.getTicketNo());
|
||||||
|
vo.setTicketTitle(ticket.getTicketTitle());
|
||||||
vo.setProjectNo(ticket.getTicketNo()); // 工程编号使用工单编号
|
vo.setProjectNo(ticket.getTicketNo()); // 工程编号使用工单编号
|
||||||
vo.setIncidentType(ticket.getIncidentType());
|
vo.setIncidentType(ticket.getIncidentType());
|
||||||
vo.setExceptionCode(ticket.getExceptionCode());
|
vo.setExceptionCode(ticket.getExceptionCode());
|
||||||
vo.setUnqualifiedQty(ticket.getUnqualifiedQty());
|
vo.setUnqualifiedQty(ticket.getUnqualifiedQty());
|
||||||
vo.setRemark(ticket.getRemark());
|
vo.setIncidentLocation(ticket.getIncidentLocation());
|
||||||
vo.setCreator(ticket.getCreateUserName());
|
vo.setIncidentDescription(ticket.getIncidentDescription());
|
||||||
vo.setCreateTime(ticket.getCreateTime());
|
vo.setIncidentReason(ticket.getIncidentReason());
|
||||||
vo.setStatus(ticket.getStatus());
|
vo.setIncidentConsequence(ticket.getIncidentConsequence());
|
||||||
vo.setCompleteTime(ticket.getCompleteTime()); // 设置完成时间
|
|
||||||
vo.setImages(parseImageList(ticket.getImageIds()));
|
vo.setImages(parseImageList(ticket.getImageIds()));
|
||||||
|
vo.setRemark(ticket.getRemark());
|
||||||
|
vo.setStatus(ticket.getStatus());
|
||||||
|
vo.setCompleteTime(ticket.getCompleteTime());
|
||||||
|
vo.setApprovalStatus(ticket.getApprovalStatus());
|
||||||
|
vo.setApprovalOpinion(ticket.getApprovalOpinion());
|
||||||
|
vo.setApprovalUserId(ticket.getApprovalUserId());
|
||||||
|
vo.setApprovalUserName(ticket.getApprovalUserName());
|
||||||
|
vo.setApprovalTime(ticket.getApprovalTime());
|
||||||
|
vo.setCreateUserId(ticket.getCreateUserId());
|
||||||
|
vo.setCreateUserName(ticket.getCreateUserName());
|
||||||
|
vo.setCreateTime(ticket.getCreateTime());
|
||||||
|
vo.setCreator(ticket.getCreateUserName());
|
||||||
|
|
||||||
|
// 工单类型:根据sourceType转换
|
||||||
|
if (ticket.getSourceType() != null) {
|
||||||
|
switch (ticket.getSourceType()) {
|
||||||
|
case 0:
|
||||||
|
vo.setTicketType("IQC检测任务");
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
vo.setTicketType("PDI检测任务");
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
vo.setTicketType("巡检");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
vo.setTicketType("未知");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 生成主题:机型编号+订单编号+出厂检测/库存检测+检测版本号
|
// 生成主题:机型编号+订单编号+新机检测/库存检测+检测版本号(仅PDI工单)
|
||||||
if (ticket.getSourceId() != null) {
|
if (ticket.getSourceType() != null && ticket.getSourceType() == 1 && ticket.getSourceId() != null) {
|
||||||
QmsPdiTaskRecord taskRecord = pdiTaskRecordService.getById(ticket.getSourceId());
|
QmsPdiTaskRecord taskRecord = pdiTaskRecordService.getById(ticket.getSourceId());
|
||||||
if (taskRecord != null && taskRecord.getDetectionRulesId() != null) {
|
if (taskRecord != null && taskRecord.getDetectionRulesId() != null) {
|
||||||
QmsPdiDetectionRules detectionRules = pdiDetectionRulesService.getById(taskRecord.getDetectionRulesId());
|
QmsPdiDetectionRules detectionRules = pdiDetectionRulesService.getById(taskRecord.getDetectionRulesId());
|
||||||
if (detectionRules != null) {
|
if (detectionRules != null) {
|
||||||
String inspectionTypeStr = detectionRules.getInspectionType() != null && detectionRules.getInspectionType() == 0 ? "新机检测" : "库存检测";
|
String inspectionTypeStr = detectionRules.getInspectionType() != null && detectionRules.getInspectionType() == 0 ? "新机检测" : "库存检测";
|
||||||
vo.setTicketTitle(detectionRules.getMachineNo() + "-" + detectionRules.getOrderNo() + "-" + inspectionTypeStr + "-" + detectionRules.getInspectionVersion());
|
vo.setTicketTitle(detectionRules.getMachineNo() + "-" + detectionRules.getOrderNo() + "-" + inspectionTypeStr + "-" + detectionRules.getInspectionVersion());
|
||||||
vo.setTicketType("PDI-" + inspectionTypeStr);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1465,11 +1556,97 @@ public class QmsIssueTicketControllerService {
|
||||||
vo.setRootCause(rootCause);
|
vo.setRootCause(rootCause);
|
||||||
vo.setTemporaryMeasures(temporaryMeasures);
|
vo.setTemporaryMeasures(temporaryMeasures);
|
||||||
vo.setPermanentMeasures(permanentMeasures);
|
vo.setPermanentMeasures(permanentMeasures);
|
||||||
vo.setSignatures(new HashMap<>());
|
|
||||||
|
// 构建相关人员签字(按部门,只返回已审批的)
|
||||||
|
Map<String, QmsPdiTicketMyDetailVO.SignatureInfo> signatures = buildSignatures(processes);
|
||||||
|
vo.setSignatures(signatures);
|
||||||
|
|
||||||
return vo;
|
return vo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 构建相关人员签字(按部门,只返回已审批的)
|
||||||
|
* @param processes 处理记录列表
|
||||||
|
* @return 部门签字信息Map
|
||||||
|
*/
|
||||||
|
private Map<String, QmsPdiTicketMyDetailVO.SignatureInfo> buildSignatures(List<QmsIssueTicketProcess> processes) {
|
||||||
|
Map<String, QmsPdiTicketMyDetailVO.SignatureInfo> signatures = new HashMap<>();
|
||||||
|
|
||||||
|
for (QmsIssueTicketProcess process : processes) {
|
||||||
|
// 只返回已审批的记录(approvalStatus 不为 null)
|
||||||
|
if (process.getApprovalStatus() == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 查询处理人的部门信息
|
||||||
|
if (process.getHandlerUserId() != null) {
|
||||||
|
UserInterior userInterior = userInteriorService.lambdaQuery()
|
||||||
|
.eq(UserInterior::getUserId, process.getHandlerUserId())
|
||||||
|
.one();
|
||||||
|
|
||||||
|
if (userInterior != null && userInterior.getDeptId() != null) {
|
||||||
|
Department department = departmentService.getById(userInterior.getDeptId());
|
||||||
|
if (department != null) {
|
||||||
|
String deptName = department.getName();
|
||||||
|
|
||||||
|
// 查询部门领导
|
||||||
|
Department leaderDept = departmentService.getById(userInterior.getDeptId());
|
||||||
|
String leaderName = null;
|
||||||
|
if (leaderDept != null && leaderDept.getHeadUserId() != null) {
|
||||||
|
User leaderUser = userService.getById(leaderDept.getHeadUserId());
|
||||||
|
if (leaderUser != null) {
|
||||||
|
leaderName = leaderUser.getUserName();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 如果领导未审批,跳过
|
||||||
|
if (StrUtil.isBlank(leaderName)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 构建签名:姓名(状态)
|
||||||
|
String statusText = convertApprovalStatus(process.getApprovalStatus());
|
||||||
|
String signature = leaderName + "(" + statusText + ")";
|
||||||
|
|
||||||
|
// 构建签字信息
|
||||||
|
QmsPdiTicketMyDetailVO.SignatureInfo signatureInfo = new QmsPdiTicketMyDetailVO.SignatureInfo();
|
||||||
|
signatureInfo.setDeptName(deptName);
|
||||||
|
signatureInfo.setApprovalOpinion(process.getApprovalOpinion());
|
||||||
|
signatureInfo.setApprovalTime(process.getApprovalTime() != null
|
||||||
|
? process.getApprovalTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))
|
||||||
|
: null);
|
||||||
|
signatureInfo.setSignature(signature);
|
||||||
|
|
||||||
|
signatures.put(deptName, signatureInfo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return signatures;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 转换审批状态为文本
|
||||||
|
* @param status 审批状态:0=通过,1=驳回,2=重检,3=报废,4=维修,5=挑选使用,6=让渡使用
|
||||||
|
* @return 状态文本
|
||||||
|
*/
|
||||||
|
private String convertApprovalStatus(Short status) {
|
||||||
|
if (status == null) {
|
||||||
|
return "未审批";
|
||||||
|
}
|
||||||
|
switch (status) {
|
||||||
|
case 0: return "通过";
|
||||||
|
case 1: return "驳回";
|
||||||
|
case 2: return "重检";
|
||||||
|
case 3: return "报废";
|
||||||
|
case 4: return "维修";
|
||||||
|
case 5: return "挑选使用";
|
||||||
|
case 6: return "让渡使用";
|
||||||
|
default: return "未知";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询巡检工单详情
|
* 查询巡检工单详情
|
||||||
* 返回工单基本信息、图片列表、处理人信息、纠正措施等
|
* 返回工单基本信息、图片列表、处理人信息、纠正措施等
|
||||||
|
|
|
||||||
|
|
@ -199,23 +199,36 @@ public class QmsPdiStatusItemControllerService {
|
||||||
// 读取 Excel 里的所有图片
|
// 读取 Excel 里的所有图片
|
||||||
List<Drawings.Picture> pictures = new ExcelReader(new java.io.ByteArrayInputStream(fileBytes)).listPictures();
|
List<Drawings.Picture> pictures = new ExcelReader(new java.io.ByteArrayInputStream(fileBytes)).listPictures();
|
||||||
|
|
||||||
// 遍历 DTO,遇到 DISPIMG 就上传图片并替换地址
|
// 遍历 DTO,遇到 DISPIMG 就上传图片并替换为文件ID
|
||||||
for (int i = 0; i < data.size(); i++) {
|
for (int i = 0; i < data.size(); i++) {
|
||||||
QmsPdiStatusItemImportDTO dto = data.get(i);
|
QmsPdiStatusItemImportDTO dto = data.get(i);
|
||||||
String inspectionImage = dto.getInspectionImage();
|
String inspectionImage = dto.getInspectionImage();
|
||||||
|
|
||||||
// 如果是图片公式,就取图片上传,把地址填回去
|
// 如果是图片公式,就取图片上传,把文件ID填回去
|
||||||
if (StrUtil.isNotBlank(inspectionImage) && inspectionImage.startsWith("=DISPIMG(")) {
|
if (StrUtil.isNotBlank(inspectionImage) && inspectionImage.startsWith("=DISPIMG(")) {
|
||||||
if (i < pictures.size()) {
|
if (i < pictures.size()) {
|
||||||
Drawings.Picture pic = pictures.get(i);
|
Drawings.Picture pic = pictures.get(i);
|
||||||
try (FileInputStream fis = new FileInputStream(pic.getLocalPath().toFile())) {
|
try (FileInputStream fis = new FileInputStream(pic.getLocalPath().toFile())) {
|
||||||
// 上传图片 → 获取地址
|
// 1. 上传图片 → 获取URL
|
||||||
String imageUrl = fileUploadService.upload(
|
String imageUrl = fileUploadService.upload(
|
||||||
"image/" + DateTimeUtil.format(LocalDate.now(), "yyyyMMdd") + "/" + IdUtil.fastUUID() + ".png",
|
"image/" + DateTimeUtil.format(LocalDate.now(), "yyyyMMdd") + "/" + IdUtil.fastUUID() + ".png",
|
||||||
fis,
|
fis,
|
||||||
"image/png"
|
"image/png"
|
||||||
);
|
);
|
||||||
dto.setInspectionImage(imageUrl);
|
|
||||||
|
// 2. 保存文件上传记录
|
||||||
|
FileUploadRecord record = new FileUploadRecord();
|
||||||
|
record.setId(IdUtil.getSnowflakeNextId());
|
||||||
|
record.setFileName(pic.getLocalPath().getFileName().toString());
|
||||||
|
record.setFileType("image/png");
|
||||||
|
record.setUrl(imageUrl);
|
||||||
|
record.setFrom("PDI检测项导入");
|
||||||
|
record.setCreateBy(UserUtil.getUserName());
|
||||||
|
record.setCreateTime(LocalDateTime.now());
|
||||||
|
fileUploadRecordService.save(record);
|
||||||
|
|
||||||
|
// 3. 将文件ID填回到DTO
|
||||||
|
dto.setInspectionImage(String.valueOf(record.getId()));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
dto.setInspectionImage(null);
|
dto.setInspectionImage(null);
|
||||||
|
|
|
||||||
|
|
@ -172,7 +172,7 @@ public class QmsPdiTicketMyDetailVO {
|
||||||
/**
|
/**
|
||||||
* 相关人员签字(按部门)
|
* 相关人员签字(按部门)
|
||||||
*/
|
*/
|
||||||
private Map<String, String> signatures;
|
private Map<String, SignatureInfo> signatures;
|
||||||
|
|
||||||
// ===== 旧的处理记录列表(保留兼容) =====
|
// ===== 旧的处理记录列表(保留兼容) =====
|
||||||
|
|
||||||
|
|
@ -416,4 +416,27 @@ public class QmsPdiTicketMyDetailVO {
|
||||||
*/
|
*/
|
||||||
private Long approvalUserId;
|
private Long approvalUserId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public static class SignatureInfo {
|
||||||
|
/**
|
||||||
|
* 部门名称
|
||||||
|
*/
|
||||||
|
private String deptName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 审批意见
|
||||||
|
*/
|
||||||
|
private String approvalOpinion;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 审批时间
|
||||||
|
*/
|
||||||
|
private String approvalTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 签名(格式:姓名(状态))
|
||||||
|
*/
|
||||||
|
private String signature;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue