|
|
|
@ -3,7 +3,9 @@ |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
package org.springblade.desk.quality.controller; |
|
|
|
package org.springblade.desk.quality.controller; |
|
|
|
|
|
|
|
|
|
|
|
import ch.qos.logback.core.joran.util.beans.BeanUtil; |
|
|
|
import cn.hutool.core.bean.BeanUtil; |
|
|
|
|
|
|
|
import cn.hutool.core.date.DateTime; |
|
|
|
|
|
|
|
import cn.hutool.core.util.StrUtil; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
@ -19,6 +21,7 @@ import lombok.AllArgsConstructor; |
|
|
|
import lombok.Data; |
|
|
|
import lombok.Data; |
|
|
|
import lombok.EqualsAndHashCode; |
|
|
|
import lombok.EqualsAndHashCode; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
|
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.springblade.core.boot.ctrl.BladeController; |
|
|
|
import org.springblade.core.boot.ctrl.BladeController; |
|
|
|
import org.springblade.core.excel.util.ExcelUtil; |
|
|
|
import org.springblade.core.excel.util.ExcelUtil; |
|
|
|
import org.springblade.core.log.annotation.ApiLog; |
|
|
|
import org.springblade.core.log.annotation.ApiLog; |
|
|
|
@ -34,6 +37,11 @@ import org.springblade.desk.basic.constant.BaseCol; |
|
|
|
import org.springblade.desk.basic.constant.BaseRequest; |
|
|
|
import org.springblade.desk.basic.constant.BaseRequest; |
|
|
|
import org.springblade.desk.basic.util.ExcelExtUtil; |
|
|
|
import org.springblade.desk.basic.util.ExcelExtUtil; |
|
|
|
import org.springblade.desk.basic.util.RequestUtil; |
|
|
|
import org.springblade.desk.basic.util.RequestUtil; |
|
|
|
|
|
|
|
import org.springblade.desk.common.constant.BizTypeConstant; |
|
|
|
|
|
|
|
import org.springblade.desk.common.feign.IMesNotifyMessageClient; |
|
|
|
|
|
|
|
import org.springblade.desk.common.feign.MesNotifyMessageClient; |
|
|
|
|
|
|
|
import org.springblade.desk.common.pojo.entity.MesNotifyMessageEntity; |
|
|
|
|
|
|
|
import org.springblade.desk.energy.pojo.entity.BsTowerReportEntity; |
|
|
|
import org.springblade.desk.quality.constant.QAModuleConst; |
|
|
|
import org.springblade.desk.quality.constant.QAModuleConst; |
|
|
|
import org.springblade.desk.quality.excel.LiquidTankWaveExcel; |
|
|
|
import org.springblade.desk.quality.excel.LiquidTankWaveExcel; |
|
|
|
import org.springblade.desk.quality.excel.RaiseHandExcel; |
|
|
|
import org.springblade.desk.quality.excel.RaiseHandExcel; |
|
|
|
@ -55,6 +63,8 @@ import org.springframework.web.bind.annotation.*; |
|
|
|
import org.springframework.web.multipart.MultipartFile; |
|
|
|
import org.springframework.web.multipart.MultipartFile; |
|
|
|
|
|
|
|
|
|
|
|
import java.time.LocalDate; |
|
|
|
import java.time.LocalDate; |
|
|
|
|
|
|
|
import java.time.LocalDateTime; |
|
|
|
|
|
|
|
import java.time.ZoneId; |
|
|
|
import java.time.format.DateTimeFormatter; |
|
|
|
import java.time.format.DateTimeFormatter; |
|
|
|
import java.time.format.DateTimeParseException; |
|
|
|
import java.time.format.DateTimeParseException; |
|
|
|
import java.util.*; |
|
|
|
import java.util.*; |
|
|
|
@ -86,6 +96,8 @@ public class RaiseHandController extends BladeController { |
|
|
|
private IUserClient userClient; |
|
|
|
private IUserClient userClient; |
|
|
|
@Resource |
|
|
|
@Resource |
|
|
|
IRaiseHandRecordService recordService; |
|
|
|
IRaiseHandRecordService recordService; |
|
|
|
|
|
|
|
@Resource |
|
|
|
|
|
|
|
IMesNotifyMessageClient mesNotifyMessageClient; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
@ -268,18 +280,139 @@ public class RaiseHandController extends BladeController { |
|
|
|
} |
|
|
|
} |
|
|
|
service.updateById(one); |
|
|
|
service.updateById(one); |
|
|
|
|
|
|
|
|
|
|
|
RaiseHandRecord record = new RaiseHandRecord(); |
|
|
|
//创建当前节点记录
|
|
|
|
|
|
|
|
// TODO: 2026/4/28 当前节点已经存在
|
|
|
|
|
|
|
|
RaiseHandRecord record = recordService.getOne(Wrappers.lambdaQuery(RaiseHandRecord.class) |
|
|
|
|
|
|
|
.eq(RaiseHandRecord::getHandId, one.getId()) |
|
|
|
|
|
|
|
.eq(RaiseHandRecord::getCurrentStatus, status) |
|
|
|
|
|
|
|
.eq(RaiseHandRecord::getIsDeleted, 0), false); |
|
|
|
|
|
|
|
// 如果记录不存在,创建新记录
|
|
|
|
|
|
|
|
if (BeanUtil.isEmpty( record)) { |
|
|
|
|
|
|
|
record = new RaiseHandRecord(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
Date now = new Date(); |
|
|
|
record.setHandId(one.getId()); |
|
|
|
record.setHandId(one.getId()); |
|
|
|
record.setNotes(addOne.getNotes()); |
|
|
|
record.setNotes(addOne.getNotes()); |
|
|
|
record.setIsSuccess(addOne.getIsSuccess()); |
|
|
|
record.setIsSuccess(addOne.getIsSuccess()); |
|
|
|
record.setCurrentStatus(status); |
|
|
|
record.setCurrentStatus(status); |
|
|
|
record.setCreateTime(new Date()); |
|
|
|
record.setCreateTime(now); |
|
|
|
|
|
|
|
record.setReviewTime(now); |
|
|
|
record.setReviewUserId(AuthUtil.getUser().getUserId()); |
|
|
|
record.setReviewUserId(AuthUtil.getUser().getUserId()); |
|
|
|
record.setReviewUserName(AuthUtil.getUser().getNickName()); |
|
|
|
record.setReviewUserName(AuthUtil.getUser().getNickName()); |
|
|
|
recordService.save(record); |
|
|
|
recordService.saveOrUpdate(record); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 当下审批节点固定,大于 1 需要手动选择审批人 创建下一节点记录
|
|
|
|
|
|
|
|
if (one.getStatus() > 1 && one.getStatus() < 4) { |
|
|
|
|
|
|
|
createNextNodeRecord(one, addOne.getNextUserId()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return R.status(true); |
|
|
|
return R.status(true); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void createNextNodeRecord(RaiseHand raiseHand, String nextUserId) { |
|
|
|
|
|
|
|
// 校验下一节点审批人
|
|
|
|
|
|
|
|
if (StrUtil.isEmpty(nextUserId)) { |
|
|
|
|
|
|
|
throw new RuntimeException("请选择下一节点审批人"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 获取下一节点审批人信息
|
|
|
|
|
|
|
|
User nextApprover; |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
nextApprover = userClient.userInfoById(Long.parseLong(nextUserId)).getData(); |
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
|
|
log.error("获取下一节点审批人失败", e); |
|
|
|
|
|
|
|
throw new RuntimeException("下一节点审批人获取失败"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (BeanUtil.isEmpty(nextApprover)) { |
|
|
|
|
|
|
|
throw new RuntimeException("下一节点审批人获取失败"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 创建下一节点记录
|
|
|
|
|
|
|
|
RaiseHandRecord nextNode = new RaiseHandRecord(); |
|
|
|
|
|
|
|
nextNode.setHandId(raiseHand.getId()); |
|
|
|
|
|
|
|
nextNode.setCurrentStatus(raiseHand.getStatus()); |
|
|
|
|
|
|
|
nextNode.setNextUserId(nextApprover.getId().toString()); |
|
|
|
|
|
|
|
nextNode.setNextUserName(nextApprover.getRealName()); |
|
|
|
|
|
|
|
nextNode.setCreateTime(new Date()); |
|
|
|
|
|
|
|
recordService.save(nextNode); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 给下一个节点审批人推送消息
|
|
|
|
|
|
|
|
pushNotificationToNextApprover(raiseHand, nextApprover); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void pushNotificationToNextApprover(RaiseHand raiseHand, User nextApprover) { |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
// 构建审批节点名称
|
|
|
|
|
|
|
|
String nodeName = getApprovalNodeName(raiseHand.getStatus() + 1); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 构建通知标题
|
|
|
|
|
|
|
|
String title = String.format("举手免责审批提醒 - %s", |
|
|
|
|
|
|
|
StringUtils.isNotBlank(raiseHand.getNotes()) ? raiseHand.getNotes() : "待审批"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 构建通知内容
|
|
|
|
|
|
|
|
String content = String.format( |
|
|
|
|
|
|
|
"您有一条新的举手免责审批待处理:\n" + |
|
|
|
|
|
|
|
"- 问题描述:%s\n" + |
|
|
|
|
|
|
|
"- 申请人:%s\n" + |
|
|
|
|
|
|
|
"- 岗位:%s\n" + |
|
|
|
|
|
|
|
"- 当前节点:%s\n" + |
|
|
|
|
|
|
|
"- 申请时间:%s\n" + |
|
|
|
|
|
|
|
"请及时登录系统进行处理。", |
|
|
|
|
|
|
|
StringUtils.defaultIfBlank(raiseHand.getNotes(), "无"), |
|
|
|
|
|
|
|
StringUtils.defaultIfBlank(raiseHand.getReportUserName(), "未知"), |
|
|
|
|
|
|
|
StringUtils.defaultIfBlank(raiseHand.getPostName(), "未知"), |
|
|
|
|
|
|
|
nodeName, |
|
|
|
|
|
|
|
raiseHand.getCreateTime() != null ? DateUtil.format(raiseHand.getCreateTime(), "yyyy-MM-dd HH:mm:ss") : "未知" |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 创建通知消息实体
|
|
|
|
|
|
|
|
MesNotifyMessageEntity notifyMessage = MesNotifyMessageEntity.builder() |
|
|
|
|
|
|
|
.title(title) |
|
|
|
|
|
|
|
.content(content) |
|
|
|
|
|
|
|
.receiveUserId(nextApprover.getId()) |
|
|
|
|
|
|
|
.bizType(BizTypeConstant.CRAFT_TASK_REDEPLOY) |
|
|
|
|
|
|
|
.build(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 调用Feign客户端保存通知消息
|
|
|
|
|
|
|
|
R result = mesNotifyMessageClient.save(notifyMessage); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (result != null && result.isSuccess()) { |
|
|
|
|
|
|
|
log.info("成功发送举手免责审批提醒,审批人: {}, 审批人姓名: {}, 举手ID: {}", |
|
|
|
|
|
|
|
nextApprover.getId(), nextApprover.getRealName(), raiseHand.getId()); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
log.error("发送举手免责审批提醒失败,审批人: {}, 错误信息: {}", |
|
|
|
|
|
|
|
nextApprover.getId(), result != null ? result.getMsg() : "返回结果为空"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
|
|
log.error("处理举手免责审批提醒时发生异常,举手ID: {}", raiseHand.getId(), e); |
|
|
|
|
|
|
|
throw new RuntimeException("发送举手免责审批提醒失败"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 根据状态获取审批节点名称 |
|
|
|
|
|
|
|
* @param status 审批状态 |
|
|
|
|
|
|
|
* @return 节点名称 |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private String getApprovalNodeName(Integer status) { |
|
|
|
|
|
|
|
if (status == null) { |
|
|
|
|
|
|
|
return "未知节点"; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
switch (status) { |
|
|
|
|
|
|
|
case 1: |
|
|
|
|
|
|
|
return "工艺管理员审批"; |
|
|
|
|
|
|
|
case 2: |
|
|
|
|
|
|
|
return "质量管理员审批"; |
|
|
|
|
|
|
|
case 3: |
|
|
|
|
|
|
|
return "主管业务领导审批"; |
|
|
|
|
|
|
|
case 4: |
|
|
|
|
|
|
|
return "审批完成"; |
|
|
|
|
|
|
|
default: |
|
|
|
|
|
|
|
return "未知节点"; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@PostMapping("/save") |
|
|
|
@PostMapping("/save") |
|
|
|
@ApiOperationSupport(order = 30) |
|
|
|
@ApiOperationSupport(order = 30) |
|
|
|
@ -288,20 +421,21 @@ public class RaiseHandController extends BladeController { |
|
|
|
@Transactional |
|
|
|
@Transactional |
|
|
|
public R save(@Valid @RequestBody RaiseHand addOne) { |
|
|
|
public R save(@Valid @RequestBody RaiseHand addOne) { |
|
|
|
|
|
|
|
|
|
|
|
addOne.setId(null); |
|
|
|
addOne.setId(null); |
|
|
|
service.save(addOne); |
|
|
|
service.save(addOne); |
|
|
|
if(1 == addOne.getStatus()){ |
|
|
|
// TODO: 2026/4/29 前端未传该字段,框架自动填充
|
|
|
|
RaiseHandRecord record = new RaiseHandRecord(); |
|
|
|
//if(1 == addOne.getStatus()){
|
|
|
|
record.setHandId(addOne.getId()); |
|
|
|
RaiseHandRecord record = new RaiseHandRecord(); |
|
|
|
record.setNotes(""); |
|
|
|
record.setHandId(addOne.getId()); |
|
|
|
record.setIsSuccess("1"); |
|
|
|
record.setNotes(""); |
|
|
|
record.setCurrentStatus(0); |
|
|
|
record.setIsSuccess("1"); |
|
|
|
record.setCreateTime(new Date()); |
|
|
|
record.setCurrentStatus(0); |
|
|
|
record.setReviewUserId(AuthUtil.getUser().getUserId()); |
|
|
|
record.setCreateTime(new Date()); |
|
|
|
record.setReviewUserName(AuthUtil.getUser().getNickName()); |
|
|
|
record.setReviewUserId(AuthUtil.getUser().getUserId()); |
|
|
|
recordService.save(record); |
|
|
|
record.setReviewUserName(AuthUtil.getUser().getNickName()); |
|
|
|
} |
|
|
|
recordService.save(record); |
|
|
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
createNextNodeRecord(addOne, addOne.getProcessUserId().toString()); |
|
|
|
|
|
|
|
|
|
|
|
return R.status(true); |
|
|
|
return R.status(true); |
|
|
|
} |
|
|
|
} |
|
|
|
|