|
|
|
|
@ -2,8 +2,10 @@ package com.biutag.lan.flow.node;
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.util.StrUtil; |
|
|
|
|
import com.alibaba.fastjson2.JSONObject; |
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
|
import com.biutag.lan.config.AdminThreadLocal; |
|
|
|
|
import com.biutag.lan.domain.*; |
|
|
|
|
import com.biutag.lan.enums.WorkType; |
|
|
|
|
import com.biutag.lan.flow.Flow; |
|
|
|
|
import com.biutag.lan.service.*; |
|
|
|
|
import lombok.RequiredArgsConstructor; |
|
|
|
|
@ -13,6 +15,7 @@ import org.springframework.util.Assert;
|
|
|
|
|
import java.time.LocalDateTime; |
|
|
|
|
import java.util.Comparator; |
|
|
|
|
import java.util.List; |
|
|
|
|
import java.util.Objects; |
|
|
|
|
import java.util.Optional; |
|
|
|
|
|
|
|
|
|
@RequiredArgsConstructor |
|
|
|
|
@ -29,6 +32,8 @@ public class CountersignFlow extends Flow {
|
|
|
|
|
|
|
|
|
|
private final FlowNodeService flowNodeService; |
|
|
|
|
|
|
|
|
|
private final NoticeService noticeService; |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public Flow next(String nextActionKey, String mailId, JSONObject data) { |
|
|
|
|
String comments = data.getString("comments"); |
|
|
|
|
@ -37,7 +42,7 @@ public class CountersignFlow extends Flow {
|
|
|
|
|
LocalDateTime now = LocalDateTime.now(); |
|
|
|
|
List<MailCountersign> list = mailCountersignService.list(mailId); |
|
|
|
|
int count = Long.valueOf(list.stream().filter(item -> StrUtil.isNotBlank(item.getComments())).count()).intValue(); |
|
|
|
|
MailCountersign mailCountersign = list.stream().filter(item -> item.getDeptId().equals(deptId)).findFirst().get(); |
|
|
|
|
MailCountersign mailCountersign = list.stream().filter(item -> Objects.isNull(item.getComments()) && item.getDeptId().equals(deptId)).findFirst().get(); |
|
|
|
|
mailCountersign.setComments(comments); |
|
|
|
|
mailCountersign.setAttachments(Optional.ofNullable(data.getJSONArray("attachments")).map(item -> item.toJSONString()).orElse("[]")); |
|
|
|
|
mailCountersign.setHandlerEmpNo(AdminThreadLocal.getEmpNo()); |
|
|
|
|
@ -49,6 +54,9 @@ public class CountersignFlow extends Flow {
|
|
|
|
|
workService.updateById(work); |
|
|
|
|
Mail mail = mailService.getById(mailId); |
|
|
|
|
mail.setCountersignCompleted(count + 1).setUpdateTime(now); |
|
|
|
|
// 通知发起会签人
|
|
|
|
|
Work initiateCountersignWork = workService.getOne(new LambdaQueryWrapper<Work>().eq(Work::getMailId, mailId).eq(Work::getWorkState, Work.State.todo.name()).eq(Work::getWorkType, WorkType.processing.name()).eq(Work::getMainDeptFlag, true)); |
|
|
|
|
noticeService.sendNoticeDoneByWork(initiateCountersignWork); |
|
|
|
|
if (mail.getCountersignCompleted() < mail.getCountersignTotal()) { |
|
|
|
|
mailService.updateById(mail); |
|
|
|
|
return null; |
|
|
|
|
@ -62,4 +70,5 @@ public class CountersignFlow extends Flow {
|
|
|
|
|
mailService.updateById(mail); |
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|