|
|
|
|
@ -4,6 +4,7 @@ |
|
|
|
|
package org.springblade.desk.quality.service.impl; |
|
|
|
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil; |
|
|
|
|
import cn.hutool.core.util.StrUtil; |
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.Wrapper; |
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
|
|
|
|
@ -18,6 +19,7 @@ import org.apache.commons.lang3.StringUtils; |
|
|
|
|
import org.springblade.common.exception.BusinessException; |
|
|
|
|
import org.springblade.core.secure.utils.AuthUtil; |
|
|
|
|
import org.springblade.core.tool.api.R; |
|
|
|
|
import org.springblade.core.tool.utils.DateUtil; |
|
|
|
|
import org.springblade.desk.basic.pojo.entity.WorkCenter; |
|
|
|
|
import org.springblade.desk.basic.service.IWorkCenterService; |
|
|
|
|
import org.springblade.desk.basic.service.en.impl.EnBaseServiceImpl; |
|
|
|
|
@ -34,6 +36,7 @@ import org.springblade.desk.quality.pojo.request.ProReTemplateAuditRequest; |
|
|
|
|
import org.springblade.desk.quality.pojo.vo.ProReTemplateAuditHistoryVO; |
|
|
|
|
import org.springblade.desk.quality.pojo.vo.ProReTemplateDetailVO; |
|
|
|
|
import org.springblade.desk.quality.pojo.vo.ProReTemplateTankVO; |
|
|
|
|
import org.springblade.desk.quality.pojo.vo.ProReTemplateTimelineVO; |
|
|
|
|
import org.springblade.desk.quality.pojo.vo.ProReTemplateVO; |
|
|
|
|
import org.springblade.desk.quality.service.IProReTemplateDetailService; |
|
|
|
|
import org.springblade.desk.quality.service.IProReTemplateService; |
|
|
|
|
@ -43,6 +46,7 @@ import org.springblade.desk.basic.util.RoleUtil; |
|
|
|
|
import org.springblade.system.feign.IDictClient; |
|
|
|
|
import org.springblade.system.feign.ISysClient; |
|
|
|
|
import org.springblade.system.feign.IUserClient; |
|
|
|
|
import org.springblade.system.pojo.entity.User; |
|
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
|
|
@ -155,7 +159,7 @@ public class ProReTemplateServiceImpl extends EnBaseServiceImpl<ProReTemplateMap |
|
|
|
|
ProReTemplate copy = new ProReTemplate(); |
|
|
|
|
BeanUtil.copyProperties(find, copy, true); |
|
|
|
|
copy.setStatus(ProReTemplateConst.STATUS_NEW); |
|
|
|
|
copy.setAuditStatus(ProReTemplateConst.AUDIT_STATUS_PENDING); // 设置初始审核状态
|
|
|
|
|
copy.setAuditStatus(ProReTemplateConst.AUDIT_STATUS_NEW); // 设置初始审核状态为新建
|
|
|
|
|
copy.setApprovalStatus(ProReTemplateConst.APPROVAL_STATUS_1); |
|
|
|
|
copy.setId(null); |
|
|
|
|
return R.status(save(copy)); |
|
|
|
|
@ -194,14 +198,15 @@ public class ProReTemplateServiceImpl extends EnBaseServiceImpl<ProReTemplateMap |
|
|
|
|
return R.fail("只有新建状态的模板才能发布"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 更新状态为待审核
|
|
|
|
|
// 更新状态为待审核(status和auditStatus保持一致)
|
|
|
|
|
template.setStatus(ProReTemplateConst.STATUS_PENDING); |
|
|
|
|
template.setAuditStatus(ProReTemplateConst.AUDIT_STATUS_PENDING); |
|
|
|
|
updateById(template); |
|
|
|
|
|
|
|
|
|
// 发送消息通知给一级审核人
|
|
|
|
|
sendNotificationToLevel1(template); |
|
|
|
|
|
|
|
|
|
return R.success(); |
|
|
|
|
return R.success("发布成功,等待一级审核"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
@ -226,7 +231,7 @@ public class ProReTemplateServiceImpl extends EnBaseServiceImpl<ProReTemplateMap |
|
|
|
|
// 根据当前状态判断是一级还是二级审核
|
|
|
|
|
Integer auditStatus = template.getAuditStatus(); |
|
|
|
|
|
|
|
|
|
if (ProReTemplateConst.AUDIT_STATUS_PENDING.equals(auditStatus)) { |
|
|
|
|
if (ProReTemplateConst.AUDIT_STATUS_PENDING.equals(auditStatus) || ProReTemplateConst.AUDIT_STATUS_REJECTED.equals(auditStatus)) { |
|
|
|
|
// 一级审核
|
|
|
|
|
return processLevel1Audit(template, request); |
|
|
|
|
} else if (ProReTemplateConst.AUDIT_STATUS_AUDITING.equals(auditStatus)) { |
|
|
|
|
@ -250,24 +255,27 @@ public class ProReTemplateServiceImpl extends EnBaseServiceImpl<ProReTemplateMap |
|
|
|
|
String currentUserName = AuthUtil.getUserName(); |
|
|
|
|
Date now = new Date(); |
|
|
|
|
|
|
|
|
|
if (request.isPass()) { |
|
|
|
|
// 审核通过
|
|
|
|
|
template.setAuditor1Id(currentUserId); |
|
|
|
|
template.setAuditor1Name(currentUserName); |
|
|
|
|
template.setAuditTime1(now); |
|
|
|
|
|
|
|
|
|
if (request.isPass()) { |
|
|
|
|
// 一级审核通过,状态更新为审核中(等待二级审核)
|
|
|
|
|
template.setStatus(ProReTemplateConst.STATUS_AUDITING); // 审核中
|
|
|
|
|
template.setAuditStatus(ProReTemplateConst.AUDIT_STATUS_AUDITING); |
|
|
|
|
template.setAuditRemark(null); |
|
|
|
|
|
|
|
|
|
// 发送消息通知给二级审核人
|
|
|
|
|
sendNotificationToLevel2(template); |
|
|
|
|
updateById(template); |
|
|
|
|
return R.success(); |
|
|
|
|
return R.success("一级审核通过,等待二级审核"); |
|
|
|
|
} else { |
|
|
|
|
// 审核不通过
|
|
|
|
|
// 一级审核不通过
|
|
|
|
|
template.setStatus(ProReTemplateConst.STATUS_REJECTED); |
|
|
|
|
template.setAuditStatus(ProReTemplateConst.AUDIT_STATUS_REJECTED); |
|
|
|
|
template.setAuditRemark(request.getRemark()); |
|
|
|
|
|
|
|
|
|
updateById(template); |
|
|
|
|
return R.success(); |
|
|
|
|
return R.success("一级审核不通过"); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -284,51 +292,92 @@ public class ProReTemplateServiceImpl extends EnBaseServiceImpl<ProReTemplateMap |
|
|
|
|
String currentUserName = AuthUtil.getUserName(); |
|
|
|
|
Date now = new Date(); |
|
|
|
|
|
|
|
|
|
if (request.isPass()) { |
|
|
|
|
// 审核通过
|
|
|
|
|
template.setAuditor2Id(currentUserId); |
|
|
|
|
template.setAuditor2Name(currentUserName); |
|
|
|
|
template.setAuditTime2(now); |
|
|
|
|
if (request.isPass()) { |
|
|
|
|
// 二级审核通过,状态更新为使用中
|
|
|
|
|
template.setStatus(ProReTemplateConst.STATUS_OK); // 使用中
|
|
|
|
|
template.setAuditStatus(ProReTemplateConst.AUDIT_STATUS_APPROVED); |
|
|
|
|
|
|
|
|
|
// 将同一作业中心-工序-类型的其他模板改为废弃
|
|
|
|
|
disableOtherTemplates(template.getWcId(), template.getPpsId(), template.getLine(), template.getId()); |
|
|
|
|
|
|
|
|
|
// 更新当前模板为使用中
|
|
|
|
|
template.setStatus(ProReTemplateConst.STATUS_OK); |
|
|
|
|
template.setAuditRemark(null); |
|
|
|
|
updateById(template); |
|
|
|
|
return R.success("二级审核通过,模板已生效"); |
|
|
|
|
} else { |
|
|
|
|
// 审核不通过
|
|
|
|
|
// 二级审核不通过
|
|
|
|
|
template.setStatus(ProReTemplateConst.STATUS_REJECTED); |
|
|
|
|
template.setAuditStatus(ProReTemplateConst.AUDIT_STATUS_REJECTED); |
|
|
|
|
template.setAuditRemark(request.getRemark()); |
|
|
|
|
|
|
|
|
|
updateById(template); |
|
|
|
|
return R.success("二级审核不通过"); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public ProReTemplateAuditHistoryVO getAuditHistory(Long id) { |
|
|
|
|
public List<ProReTemplateTimelineVO> getAuditTimeline(Long id) { |
|
|
|
|
ProReTemplate template = getById(id); |
|
|
|
|
|
|
|
|
|
if (template == null) { |
|
|
|
|
return null; |
|
|
|
|
return new ArrayList<>(); |
|
|
|
|
} |
|
|
|
|
User user = userClient.userInfoById(template.getCreateUser()).getData(); |
|
|
|
|
|
|
|
|
|
List<ProReTemplateTimelineVO> timelineList = new ArrayList<>(); |
|
|
|
|
|
|
|
|
|
// 1. 添加提交记录(从创建人信息)
|
|
|
|
|
ProReTemplateTimelineVO submitNode = new ProReTemplateTimelineVO(); |
|
|
|
|
submitNode.setType("submit"); |
|
|
|
|
submitNode.setLabel("提交人:"); |
|
|
|
|
submitNode.setValue(BeanUtil.isNotEmpty(user) && StrUtil.isNotEmpty(user.getName()) ? user.getName() : "-"); |
|
|
|
|
submitNode.setTime(template.getCreateTime() != null ? DateUtil.format(template.getCreateTime(), "yyyy-MM-dd HH:mm:ss") : ""); |
|
|
|
|
submitNode.setStatus("success"); // 提交总是已完成
|
|
|
|
|
timelineList.add(submitNode); |
|
|
|
|
|
|
|
|
|
// 2. 添加一级审核记录
|
|
|
|
|
if (template.getAuditor1Name() != null) { |
|
|
|
|
ProReTemplateTimelineVO audit1Node = new ProReTemplateTimelineVO(); |
|
|
|
|
audit1Node.setType("audit"); |
|
|
|
|
audit1Node.setLabel("审核人:"); |
|
|
|
|
audit1Node.setValue(template.getAuditor1Name()); |
|
|
|
|
audit1Node.setTime(template.getAuditTime1() != null ? DateUtil.format(template.getAuditTime1(), "yyyy-MM-dd HH:mm:ss") : ""); |
|
|
|
|
audit1Node.setRemark(template.getAuditRemark()); |
|
|
|
|
// 判断一级审核状态
|
|
|
|
|
if (template.getAuditStatus() >= ProReTemplateConst.AUDIT_STATUS_AUDITING && !ProReTemplateConst.AUDIT_STATUS_REJECTED.equals(template.getAuditStatus())) { |
|
|
|
|
audit1Node.setStatus("success"); // 一级审核已完成
|
|
|
|
|
} else { |
|
|
|
|
audit1Node.setStatus("false"); // 一级审核待处理
|
|
|
|
|
} |
|
|
|
|
timelineList.add(audit1Node); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 3. 添加二级审核记录
|
|
|
|
|
if (template.getAuditor2Name() != null) { |
|
|
|
|
ProReTemplateTimelineVO audit2Node = new ProReTemplateTimelineVO(); |
|
|
|
|
audit2Node.setType("audit"); |
|
|
|
|
audit2Node.setLabel("审核人:"); |
|
|
|
|
audit2Node.setValue(template.getAuditor2Name()); |
|
|
|
|
audit2Node.setTime(template.getAuditTime2() != null ? DateUtil.format(template.getAuditTime2(), "yyyy-MM-dd HH:mm:ss") : ""); |
|
|
|
|
audit2Node.setRemark(template.getAuditRemark()); |
|
|
|
|
// 判断二级审核状态
|
|
|
|
|
if (template.getAuditStatus() >= ProReTemplateConst.AUDIT_STATUS_APPROVED && !ProReTemplateConst.AUDIT_STATUS_REJECTED.equals(template.getAuditStatus())) { |
|
|
|
|
audit2Node.setStatus("success"); // 二级审核已完成
|
|
|
|
|
} else { |
|
|
|
|
audit2Node.setStatus("false"); // 二级审核待处理
|
|
|
|
|
} |
|
|
|
|
timelineList.add(audit2Node); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
ProReTemplateAuditHistoryVO history = new ProReTemplateAuditHistoryVO(); |
|
|
|
|
history.setId(template.getId()); |
|
|
|
|
history.setName(template.getName()); |
|
|
|
|
history.setAuditStatus(template.getAuditStatus()); |
|
|
|
|
history.setAuditStatusName(getAuditStatusName(template.getAuditStatus())); |
|
|
|
|
history.setAuditor1Id(template.getAuditor1Id()); |
|
|
|
|
history.setAuditor1Name(template.getAuditor1Name()); |
|
|
|
|
history.setAuditTime1(template.getAuditTime1()); |
|
|
|
|
history.setAuditor2Id(template.getAuditor2Id()); |
|
|
|
|
history.setAuditor2Name(template.getAuditor2Name()); |
|
|
|
|
history.setAuditTime2(template.getAuditTime2()); |
|
|
|
|
history.setAuditRemark(template.getAuditRemark()); |
|
|
|
|
// 按时间倒序排列(最新的在前面)
|
|
|
|
|
timelineList.sort((a, b) -> { |
|
|
|
|
if (a.getTime() == null || b.getTime() == null) { |
|
|
|
|
return 0; |
|
|
|
|
} |
|
|
|
|
return b.getTime().compareTo(a.getTime()); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
return history; |
|
|
|
|
return timelineList; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
@ -343,12 +392,16 @@ public class ProReTemplateServiceImpl extends EnBaseServiceImpl<ProReTemplateMap |
|
|
|
|
} |
|
|
|
|
switch (auditStatus) { |
|
|
|
|
case 0: |
|
|
|
|
return "待审核"; |
|
|
|
|
return "新建"; |
|
|
|
|
case 1: |
|
|
|
|
return "审核中"; |
|
|
|
|
return "待审核"; |
|
|
|
|
case 2: |
|
|
|
|
return "审核通过"; |
|
|
|
|
return "审核中"; |
|
|
|
|
case 3: |
|
|
|
|
return "使用中"; |
|
|
|
|
case 4: |
|
|
|
|
return "废弃"; |
|
|
|
|
case 5: |
|
|
|
|
return "审核不通过"; |
|
|
|
|
default: |
|
|
|
|
return "未知"; |
|
|
|
|
|