工单详情查询修改
This commit is contained in:
parent
8d45b6beb5
commit
e0c16e2c54
|
|
@ -1628,6 +1628,54 @@ public class QmsIssueTicketControllerService {
|
|||
Map<String, QmsPdiTicketMyDetailVO.SignatureInfo> signatures = buildSignatures(processes);
|
||||
vo.setSignatures(signatures);
|
||||
|
||||
// === 权限判断:isReview / isDispatch ===
|
||||
if (isCreator) {
|
||||
// 创建人:isReview = false,isDispatch = 是否有未分派/被驳回的不合格项
|
||||
vo.setIsReview(false);
|
||||
|
||||
// 获取该工单全部处理记录(创建人场景下 processes 已经是全量)
|
||||
Set<Long> effectivelyDispatched = new HashSet<>();
|
||||
Set<Long> rejectedResultIds = new HashSet<>();
|
||||
for (QmsIssueTicketProcess p : processes) {
|
||||
if (StrUtil.isBlank(p.getTaskResultIds())) continue;
|
||||
List<Long> ids = Arrays.stream(p.getTaskResultIds().split(","))
|
||||
.filter(StrUtil::isNotBlank).map(String::trim).map(Long::valueOf)
|
||||
.collect(Collectors.toList());
|
||||
if (p.getApprovalStatus() != null && p.getApprovalStatus() == 1) {
|
||||
// 被驳回的记录,其中的不合格项视为未分派
|
||||
rejectedResultIds.addAll(ids);
|
||||
} else {
|
||||
// 有效分派(pending 或已通过)
|
||||
effectivelyDispatched.addAll(ids);
|
||||
}
|
||||
}
|
||||
// 被驳回且未被重新分派的项
|
||||
rejectedResultIds.removeAll(effectivelyDispatched);
|
||||
// 没有任何处理记录 或 存在被驳回未重新分派的项 → isDispatch = true
|
||||
vo.setIsDispatch(processes.isEmpty() || !rejectedResultIds.isEmpty());
|
||||
} else {
|
||||
// 非创建人:isDispatch = false
|
||||
vo.setIsDispatch(false);
|
||||
|
||||
// 判断是否为上级领导
|
||||
List<QmsIssueTicketProcess> allProcesses = issueTicketProcessService.lambdaQuery()
|
||||
.eq(QmsIssueTicketProcess::getIssueTicketId, id)
|
||||
.list();
|
||||
boolean isLeader = allProcesses.stream()
|
||||
.anyMatch(p -> currentUserId.equals(p.getLeaderUserId()));
|
||||
|
||||
if (isLeader) {
|
||||
// 上级领导:isReview = true
|
||||
vo.setIsReview(true);
|
||||
} else {
|
||||
// 处理人/审批人:检查是否有未审批的处理记录
|
||||
boolean hasUnapproved = allProcesses.stream()
|
||||
.filter(p -> currentUserId.equals(p.getHandlerUserId()) || currentUserId.equals(p.getApprovalUserId()))
|
||||
.anyMatch(p -> p.getApprovalStatus() == null);
|
||||
vo.setIsReview(hasUnapproved);
|
||||
}
|
||||
}
|
||||
|
||||
return vo;
|
||||
}
|
||||
|
||||
|
|
@ -1905,6 +1953,30 @@ public class QmsIssueTicketControllerService {
|
|||
vo.setPermanentMeasures(List.of());
|
||||
}
|
||||
|
||||
// === 权限判断:isReview / isDispatch ===
|
||||
Long currentUserId = UserUtil.getUserId();
|
||||
// 获取该工单全部处理记录
|
||||
List<QmsIssueTicketProcess> allProcesses = issueTicketProcessService.lambdaQuery()
|
||||
.eq(QmsIssueTicketProcess::getIssueTicketId, id)
|
||||
.list();
|
||||
|
||||
if (currentUserId.equals(ticket.getCreateUserId()) || currentUserId.equals(ticket.getApprovalUserId())) {
|
||||
// 情况1/2:创建人 或 工单表审批人 → isReview=false,isDispatch看是否有未分派/被驳回
|
||||
vo.setIsReview(false);
|
||||
// 无处理记录 或 存在被驳回的处理记录 → isDispatch=true
|
||||
boolean hasRejected = allProcesses.stream()
|
||||
.anyMatch(p -> p.getApprovalStatus() != null && p.getApprovalStatus() == 1);
|
||||
vo.setIsDispatch(allProcesses.isEmpty() || hasRejected);
|
||||
} else if (allProcesses.stream().anyMatch(p -> currentUserId.equals(p.getLeaderUserId()))) {
|
||||
// 情况4:上级领导 → isReview=true,isDispatch=false
|
||||
vo.setIsReview(true);
|
||||
vo.setIsDispatch(false);
|
||||
} else {
|
||||
// 情况3:处理人/审批人(工单处理表) → isReview=false,isDispatch=false
|
||||
vo.setIsReview(false);
|
||||
vo.setIsDispatch(false);
|
||||
}
|
||||
|
||||
return vo;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -17,6 +17,16 @@ public class QmsInspectionTicketDetailVO {
|
|||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 是否有审批权限
|
||||
*/
|
||||
private Boolean isReview;
|
||||
|
||||
/**
|
||||
* 是否有分派权限
|
||||
*/
|
||||
private Boolean isDispatch;
|
||||
|
||||
/**
|
||||
* 工单标题
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package com.nflg.wms.common.pojo.vo;
|
|||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 质量问题工单 列表视图对象
|
||||
|
|
@ -52,6 +53,26 @@ public class QmsIssueTicketVO {
|
|||
*/
|
||||
private Integer unqualifiedQty;
|
||||
|
||||
/**
|
||||
* 影响数量
|
||||
*/
|
||||
private String impactQuantity;
|
||||
|
||||
/**
|
||||
* 事件描述
|
||||
*/
|
||||
private String incidentDescription;
|
||||
|
||||
/**
|
||||
* 事件原因
|
||||
*/
|
||||
private String incidentReason;
|
||||
|
||||
/**
|
||||
* 事件后果
|
||||
*/
|
||||
private String incidentConsequence;
|
||||
|
||||
/**
|
||||
* 事件地点
|
||||
*/
|
||||
|
|
@ -101,4 +122,20 @@ public class QmsIssueTicketVO {
|
|||
* 完成时间
|
||||
*/
|
||||
private LocalDateTime completeTime;
|
||||
|
||||
/**
|
||||
* 图片列表
|
||||
*/
|
||||
private List<ImageVO> images;
|
||||
|
||||
/**
|
||||
* 图片信息
|
||||
*/
|
||||
@Data
|
||||
public static class ImageVO {
|
||||
private Long id;
|
||||
private String fileName;
|
||||
private String fileType;
|
||||
private String url;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,6 +17,16 @@ public class QmsPdiTicketMyDetailVO {
|
|||
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 是否有审批权限
|
||||
*/
|
||||
private Boolean isReview;
|
||||
|
||||
/**
|
||||
* 是否有分派权限
|
||||
*/
|
||||
private Boolean isDispatch;
|
||||
|
||||
/**
|
||||
* 来源类型:0=IQC检测任务,1=PDI检测任务,2=巡检
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package com.nflg.wms.repository.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
|
|
@ -8,24 +9,29 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|||
import com.nflg.wms.common.pojo.PageData;
|
||||
import com.nflg.wms.common.pojo.qo.QmsIssueTicketSearchQO;
|
||||
import com.nflg.wms.common.pojo.vo.QmsIssueTicketVO;
|
||||
import com.nflg.wms.repository.entity.FileUploadRecord;
|
||||
import com.nflg.wms.repository.entity.QmsIssueTicket;
|
||||
import com.nflg.wms.repository.mapper.QmsIssueTicketMapper;
|
||||
import com.nflg.wms.repository.service.IFileUploadRecordService;
|
||||
import com.nflg.wms.repository.service.IQmsIssueTicketService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalTime;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 质量问题工单 ServiceImpl
|
||||
*/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class QmsIssueTicketServiceImpl
|
||||
extends ServiceImpl<QmsIssueTicketMapper, QmsIssueTicket>
|
||||
implements IQmsIssueTicketService {
|
||||
|
||||
private final IFileUploadRecordService fileUploadRecordService;
|
||||
|
||||
@Override
|
||||
public PageData<QmsIssueTicketVO> search(QmsIssueTicketSearchQO request) {
|
||||
Page<QmsIssueTicket> page = new Page<>(request.getPage(), request.getPageSize());
|
||||
|
|
@ -51,8 +57,55 @@ public class QmsIssueTicketServiceImpl
|
|||
|
||||
IPage<QmsIssueTicket> result = query.page(page);
|
||||
|
||||
// 收集所有图片ID,批量查询
|
||||
Set<Long> allImageIds = new HashSet<>();
|
||||
for (QmsIssueTicket entity : result.getRecords()) {
|
||||
if (StrUtil.isNotBlank(entity.getImageIds())) {
|
||||
Arrays.stream(entity.getImageIds().split(","))
|
||||
.filter(StrUtil::isNotBlank)
|
||||
.map(String::trim)
|
||||
.map(Long::valueOf)
|
||||
.forEach(allImageIds::add);
|
||||
}
|
||||
}
|
||||
|
||||
// 批量查询文件记录
|
||||
Map<Long, FileUploadRecord> fileMap = new HashMap<>();
|
||||
if (CollectionUtil.isNotEmpty(allImageIds)) {
|
||||
List<FileUploadRecord> records = fileUploadRecordService.lambdaQuery()
|
||||
.in(FileUploadRecord::getId, allImageIds)
|
||||
.list();
|
||||
for (FileUploadRecord record : records) {
|
||||
fileMap.put(record.getId(), record);
|
||||
}
|
||||
}
|
||||
|
||||
List<QmsIssueTicketVO> voList = result.getRecords().stream()
|
||||
.map(entity -> BeanUtil.copyProperties(entity, QmsIssueTicketVO.class))
|
||||
.map(entity -> {
|
||||
QmsIssueTicketVO vo = BeanUtil.copyProperties(entity, QmsIssueTicketVO.class);
|
||||
// 组装图片列表
|
||||
if (StrUtil.isNotBlank(entity.getImageIds())) {
|
||||
List<QmsIssueTicketVO.ImageVO> images = Arrays.stream(entity.getImageIds().split(","))
|
||||
.filter(StrUtil::isNotBlank)
|
||||
.map(String::trim)
|
||||
.map(Long::valueOf)
|
||||
.map(fileMap::get)
|
||||
.filter(Objects::nonNull)
|
||||
.map(record -> {
|
||||
QmsIssueTicketVO.ImageVO imageVO = new QmsIssueTicketVO.ImageVO();
|
||||
imageVO.setId(record.getId());
|
||||
imageVO.setFileName(record.getFileName());
|
||||
imageVO.setFileType(record.getFileType());
|
||||
imageVO.setUrl(record.getUrl());
|
||||
return imageVO;
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
vo.setImages(images);
|
||||
} else {
|
||||
vo.setImages(List.of());
|
||||
}
|
||||
return vo;
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
|
||||
PageData<QmsIssueTicketVO> pageData = new PageData<>();
|
||||
|
|
|
|||
Loading…
Reference in New Issue