|
@@ -8,29 +8,20 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.usky.common.core.bean.CommonPage;
|
|
import com.usky.common.core.bean.CommonPage;
|
|
import com.usky.common.core.exception.BusinessException;
|
|
import com.usky.common.core.exception.BusinessException;
|
|
import com.usky.common.security.utils.SecurityUtils;
|
|
import com.usky.common.security.utils.SecurityUtils;
|
|
-import com.usky.oa.domain.OaApproval;
|
|
|
|
-import com.usky.oa.domain.OaDocument;
|
|
|
|
-import com.usky.oa.domain.OaFormDefinition;
|
|
|
|
-import com.usky.oa.mapper.OaApprovalMapper;
|
|
|
|
-import com.usky.oa.mapper.OaDocumentMapper;
|
|
|
|
-import com.usky.oa.mapper.OaFormDefinitionMapper;
|
|
|
|
|
|
+import com.usky.oa.domain.*;
|
|
|
|
+import com.usky.oa.mapper.*;
|
|
import com.usky.oa.service.OaApprovalService;
|
|
import com.usky.oa.service.OaApprovalService;
|
|
import com.usky.common.mybatis.core.AbstractCrudService;
|
|
import com.usky.common.mybatis.core.AbstractCrudService;
|
|
-import com.usky.oa.service.utils.OaProcessAnalysis;
|
|
|
|
|
|
+// import com.usky.oa.service.utils.OaProcessAnalysis;
|
|
import com.usky.oa.service.utils.OaSendMessageCenter;
|
|
import com.usky.oa.service.utils.OaSendMessageCenter;
|
|
import com.usky.oa.service.vo.OaApprovalCountVO;
|
|
import com.usky.oa.service.vo.OaApprovalCountVO;
|
|
import com.usky.system.domain.SysUser;
|
|
import com.usky.system.domain.SysUser;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
-import org.hibernate.validator.internal.constraintvalidators.bv.time.futureorpresent.FutureOrPresentValidatorForReadableInstant;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.time.LocalDateTime;
|
|
import java.time.LocalDateTime;
|
|
-import java.time.format.DateTimeFormatter;
|
|
|
|
-import java.util.ArrayList;
|
|
|
|
-import java.util.Collections;
|
|
|
|
-import java.util.List;
|
|
|
|
-import java.util.Map;
|
|
|
|
|
|
+import java.util.*;
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Stream;
|
|
import java.util.stream.Stream;
|
|
|
|
|
|
@@ -55,7 +46,16 @@ public class OaApprovalServiceImpl extends AbstractCrudService<OaApprovalMapper,
|
|
private OaSendMessageCenter oaSendMessageCenter;
|
|
private OaSendMessageCenter oaSendMessageCenter;
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
- private OaProcessAnalysis oaProcessAnalysis;
|
|
|
|
|
|
+ private SysUserMapper sysUserMapper;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private OaNodeMapper oaNodeMapper;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private SysUserPostMapper sysUserPostMapper;
|
|
|
|
+
|
|
|
|
+/* @Autowired
|
|
|
|
+ private OaProcessAnalysis oaProcessAnalysis;*/
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
private OaFormDefinitionMapper oaFormDefinitionMapper;
|
|
private OaFormDefinitionMapper oaFormDefinitionMapper;
|
|
@@ -96,33 +96,54 @@ public class OaApprovalServiceImpl extends AbstractCrudService<OaApprovalMapper,
|
|
|
|
|
|
LambdaQueryWrapper<OaApproval> queryWrapper = Wrappers.lambdaQuery();
|
|
LambdaQueryWrapper<OaApproval> queryWrapper = Wrappers.lambdaQuery();
|
|
queryWrapper.eq(OaApproval::getTenantId, tenantId)
|
|
queryWrapper.eq(OaApproval::getTenantId, tenantId)
|
|
- .eq(OaApproval::getApprovalUid, userId).orderByDesc(OaApproval::getApprovalDate);
|
|
|
|
|
|
+ .eq(OaApproval::getApprovalUid, userId);
|
|
|
|
|
|
switch (queryType) {
|
|
switch (queryType) {
|
|
case 1:
|
|
case 1:
|
|
queryWrapper.eq(OaApproval::getApprovalStatus, 1)
|
|
queryWrapper.eq(OaApproval::getApprovalStatus, 1)
|
|
.like(StringUtils.isNotBlank(docNo), OaApproval::getDocNo, docNo)
|
|
.like(StringUtils.isNotBlank(docNo), OaApproval::getDocNo, docNo)
|
|
.like(StringUtils.isNotBlank(formSign), OaApproval::getDocNo, formSign)
|
|
.like(StringUtils.isNotBlank(formSign), OaApproval::getDocNo, formSign)
|
|
- .between(StringUtils.isNotBlank(startTime) && StringUtils.isNotBlank(endTime), OaApproval::getSubmitDate, startTime, endTime);
|
|
|
|
|
|
+ .between(StringUtils.isNotBlank(startTime) && StringUtils.isNotBlank(endTime), OaApproval::getSubmitDate, startTime, endTime)
|
|
|
|
+ .orderByDesc(OaApproval::getSubmitDate);
|
|
break;
|
|
break;
|
|
case 2:
|
|
case 2:
|
|
queryWrapper.like(StringUtils.isNotBlank(docNo), OaApproval::getDocNo, docNo)
|
|
queryWrapper.like(StringUtils.isNotBlank(docNo), OaApproval::getDocNo, docNo)
|
|
.like(StringUtils.isNotBlank(formSign), OaApproval::getDocNo, formSign)
|
|
.like(StringUtils.isNotBlank(formSign), OaApproval::getDocNo, formSign)
|
|
.eq(approvalStatus != null && approvalStatus > 1 && approvalStatus < 4, OaApproval::getApprovalStatus, approvalStatus)
|
|
.eq(approvalStatus != null && approvalStatus > 1 && approvalStatus < 4, OaApproval::getApprovalStatus, approvalStatus)
|
|
.in(OaApproval::getApprovalStatus, processed)
|
|
.in(OaApproval::getApprovalStatus, processed)
|
|
- .between(StringUtils.isNotBlank(startTime) && StringUtils.isNotBlank(endTime), OaApproval::getSubmitDate, startTime, endTime);
|
|
|
|
|
|
+ .between(StringUtils.isNotBlank(startTime) && StringUtils.isNotBlank(endTime), OaApproval::getSubmitDate, startTime, endTime)
|
|
|
|
+ .orderByDesc(OaApproval::getApprovalDate);
|
|
break;
|
|
break;
|
|
case 3:
|
|
case 3:
|
|
queryWrapper.like(StringUtils.isNotBlank(docNo), OaApproval::getDocNo, docNo)
|
|
queryWrapper.like(StringUtils.isNotBlank(docNo), OaApproval::getDocNo, docNo)
|
|
.like(StringUtils.isNotBlank(formSign), OaApproval::getDocNo, formSign)
|
|
.like(StringUtils.isNotBlank(formSign), OaApproval::getDocNo, formSign)
|
|
- .eq(OaApproval::getType, 1)
|
|
|
|
|
|
+ .eq(OaApproval::getType, 2)
|
|
.eq(approvalStatus != null && approvalStatus > 0 && approvalStatus < 4, OaApproval::getApprovalStatus, approvalStatus)
|
|
.eq(approvalStatus != null && approvalStatus > 0 && approvalStatus < 4, OaApproval::getApprovalStatus, approvalStatus)
|
|
- .between(StringUtils.isNotBlank(startTime) && StringUtils.isNotBlank(endTime), OaApproval::getSubmitDate, startTime, endTime);
|
|
|
|
|
|
+ .between(StringUtils.isNotBlank(startTime) && StringUtils.isNotBlank(endTime), OaApproval::getSubmitDate, startTime, endTime)
|
|
|
|
+ .orderByDesc(OaApproval::getSubmitDate);
|
|
break;
|
|
break;
|
|
default:
|
|
default:
|
|
throw new RuntimeException("查询类型参数错误");
|
|
throw new RuntimeException("查询类型参数错误");
|
|
}
|
|
}
|
|
- return ToCommonPage(oaApprovalMapper.selectPage(page, queryWrapper));
|
|
|
|
|
|
+
|
|
|
|
+ IPage<OaApproval> resultPage = oaApprovalMapper.selectPage(page, queryWrapper);
|
|
|
|
+
|
|
|
|
+ // 获取真实姓名
|
|
|
|
+ List<Long> userIds = resultPage.getRecords().stream()
|
|
|
|
+ .map(oaApproval -> ((long) oaApproval.getProposer()))
|
|
|
|
+ .distinct()
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
+ if (!userIds.isEmpty()) {
|
|
|
|
+ LambdaQueryWrapper<SysUser> userQueryWrapper = Wrappers.lambdaQuery();
|
|
|
|
+ userQueryWrapper.in(SysUser::getUserId, userIds).select(SysUser::getUserId, SysUser::getNickName);
|
|
|
|
+ Map<Long, String> userNicknameMap = sysUserMapper.selectList(userQueryWrapper).stream()
|
|
|
|
+ .collect(Collectors.toMap(SysUser::getUserId, SysUser::getNickName));
|
|
|
|
+ for (OaApproval oaApproval : resultPage.getRecords()) {
|
|
|
|
+ oaApproval.setCreateBy(userNicknameMap.get(oaApproval.getProposer().longValue()));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return ToCommonPage(resultPage);
|
|
}
|
|
}
|
|
|
|
|
|
// 审批
|
|
// 审批
|
|
@@ -154,22 +175,128 @@ public class OaApprovalServiceImpl extends AbstractCrudService<OaApprovalMapper,
|
|
oaApproval.setUpdateTime(now);
|
|
oaApproval.setUpdateTime(now);
|
|
oaApprovalMapper.updateById(oaApproval);
|
|
oaApprovalMapper.updateById(oaApproval);
|
|
|
|
|
|
- int isPass = 1;
|
|
|
|
- if (approvalStatus == 3) {
|
|
|
|
- isPass = 0;
|
|
|
|
|
|
+ boolean isPass = approvalStatus != 3;
|
|
|
|
+ Long proposerId = Long.valueOf(oaApproval.getProposer());
|
|
|
|
+ List<Long> receivers = Collections.singletonList(proposerId);
|
|
|
|
+ oaSendMessageCenter.sendAsyncMessage(oaApproval.getCreateBy(), proposerId, oaApproval.getId(), receivers, isPass ? 1 : 0);
|
|
|
|
+
|
|
|
|
+ if (approvalStatus == 2) {
|
|
|
|
+ LambdaQueryWrapper<OaApproval> approvalLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
|
+ approvalLambdaQueryWrapper.eq(OaApproval::getDocNo, oaApproval.getDocNo())
|
|
|
|
+ .eq(OaApproval::getApprovalStatus, 1);
|
|
|
|
+ List<OaApproval> oaApprovals = oaApprovalMapper.selectList(approvalLambdaQueryWrapper);
|
|
|
|
+
|
|
|
|
+ if (oaApprovals.isEmpty()) {
|
|
|
|
+ LambdaQueryWrapper<OaNode> nodeQuery = new LambdaQueryWrapper<>();
|
|
|
|
+ nodeQuery.eq(OaNode::getParentId, oaApproval.getNodeId())
|
|
|
|
+ .orderByAsc(OaNode::getId);
|
|
|
|
+ List<OaNode> oaNodes = oaNodeMapper.selectList(nodeQuery);
|
|
|
|
+
|
|
|
|
+ Integer tenantId = SecurityUtils.getTenantId();
|
|
|
|
+ Long deptId = SecurityUtils.getLoginUser().getSysUser().getDeptId();
|
|
|
|
+ for (OaNode oaNode : oaNodes) {
|
|
|
|
+ List<Long> userIds = new ArrayList<>();
|
|
|
|
+ switch (oaNode.getNodeScope()) {
|
|
|
|
+ case 0:
|
|
|
|
+ case 1:
|
|
|
|
+ case 2:
|
|
|
|
+ userIds = Arrays.stream(oaNode.getProposer().split(",")).map(Long::parseLong).collect(Collectors.toList());
|
|
|
|
+ break;
|
|
|
|
+ case 3:
|
|
|
|
+ LambdaQueryWrapper<SysUser> userQuery = new LambdaQueryWrapper<>();
|
|
|
|
+ userQuery.select(SysUser::getUserId)
|
|
|
|
+ .eq(SysUser::getTenantId, tenantId)
|
|
|
|
+ .eq(SysUser::getDelFlag, 0)
|
|
|
|
+ .eq(SysUser::getStatus, 0)
|
|
|
|
+ .eq(SysUser::getDeptId, oaNode.getDeptId());
|
|
|
|
+ userIds = sysUserMapper.selectList(userQuery).stream().map(SysUser::getUserId).collect(Collectors.toList());
|
|
|
|
+ break;
|
|
|
|
+ case 4:
|
|
|
|
+ LambdaQueryWrapper<SysUserPost> userRoleQuery = new LambdaQueryWrapper<>();
|
|
|
|
+ userRoleQuery.eq(SysUserPost::getPostId, oaNode.getJobId());
|
|
|
|
+ userIds = sysUserPostMapper.selectList(userRoleQuery).stream().map(SysUserPost::getUserId).collect(Collectors.toList());
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ for (Long userId1 : userIds) {
|
|
|
|
+ OaApproval approval = new OaApproval();
|
|
|
|
+ approval.setDocNo(oaApproval.getDocNo());
|
|
|
|
+ approval.setProposer(Math.toIntExact(userId1));
|
|
|
|
+ approval.setType(oaNode.getNodeType());
|
|
|
|
+ approval.setApprovalStatus(1);
|
|
|
|
+ approval.setCreateTime(now);
|
|
|
|
+ approval.setCreateBy(username);
|
|
|
|
+ approval.setDeptId(deptId);
|
|
|
|
+ approval.setTenantId(tenantId);
|
|
|
|
+ approval.setNodeId(oaNode.getId());
|
|
|
|
+ oaApprovalMapper.insert(approval);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ for (OaApproval approval : oaApprovals) {
|
|
|
|
+ approval.setApprovalStatus(2);
|
|
|
|
+ oaApprovalMapper.updateById(approval);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ LambdaQueryWrapper<OaNode> nodeQuery = new LambdaQueryWrapper<>();
|
|
|
|
+ nodeQuery.eq(OaNode::getParentId, oaApproval.getNodeId())
|
|
|
|
+ .orderByAsc(OaNode::getId);
|
|
|
|
+ List<OaNode> oaNodes = oaNodeMapper.selectList(nodeQuery);
|
|
|
|
+
|
|
|
|
+ Integer tenantId = SecurityUtils.getTenantId();
|
|
|
|
+ Long deptId = SecurityUtils.getLoginUser().getSysUser().getDeptId();
|
|
|
|
+ for (OaNode oaNode : oaNodes) {
|
|
|
|
+ List<Long> userIds = new ArrayList<>();
|
|
|
|
+ switch (oaNode.getNodeScope()) {
|
|
|
|
+ case 0:
|
|
|
|
+ case 1:
|
|
|
|
+ case 2:
|
|
|
|
+ userIds = Arrays.stream(oaNode.getProposer().split(",")).map(Long::parseLong).collect(Collectors.toList());
|
|
|
|
+ break;
|
|
|
|
+ case 3:
|
|
|
|
+ LambdaQueryWrapper<SysUser> userQuery = new LambdaQueryWrapper<>();
|
|
|
|
+ userQuery.select(SysUser::getUserId)
|
|
|
|
+ .eq(SysUser::getTenantId, tenantId)
|
|
|
|
+ .eq(SysUser::getDelFlag, 0)
|
|
|
|
+ .eq(SysUser::getStatus, 0)
|
|
|
|
+ .eq(SysUser::getDeptId, oaNode.getDeptId());
|
|
|
|
+ userIds = sysUserMapper.selectList(userQuery).stream().map(SysUser::getUserId).collect(Collectors.toList());
|
|
|
|
+ break;
|
|
|
|
+ case 4:
|
|
|
|
+ LambdaQueryWrapper<SysUserPost> userRoleQuery = new LambdaQueryWrapper<>();
|
|
|
|
+ userRoleQuery.eq(SysUserPost::getPostId, oaNode.getJobId());
|
|
|
|
+ userIds = sysUserPostMapper.selectList(userRoleQuery).stream().map(SysUserPost::getUserId).collect(Collectors.toList());
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ for (Long userId1 : userIds) {
|
|
|
|
+ OaApproval approval = new OaApproval();
|
|
|
|
+ approval.setDocNo(oaApproval.getDocNo());
|
|
|
|
+ approval.setProposer(Math.toIntExact(userId1));
|
|
|
|
+ approval.setType(oaNode.getNodeType());
|
|
|
|
+ approval.setApprovalStatus(1);
|
|
|
|
+ approval.setCreateTime(now);
|
|
|
|
+ approval.setCreateBy(username);
|
|
|
|
+ approval.setDeptId(deptId);
|
|
|
|
+ approval.setTenantId(tenantId);
|
|
|
|
+ approval.setNodeId(oaNode.getId());
|
|
|
|
+ oaApprovalMapper.insert(approval);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ } else if (oaApproval.getApprovalStatus() == 3) {
|
|
}
|
|
}
|
|
|
|
|
|
- List<Long> receivers = Collections.singletonList(Long.valueOf(oaApproval.getProposer()));
|
|
|
|
- oaSendMessageCenter.sendAsyncMessage(oaApproval.getCreateBy(), Long.valueOf(oaApproval.getProposer()), oaApproval.getId(), receivers, isPass);
|
|
|
|
}
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
|
|
|
+ // xml 流程解析测试
|
|
|
|
+/* @Override
|
|
public void analysisTest(Integer id) {
|
|
public void analysisTest(Integer id) {
|
|
LambdaQueryWrapper<OaFormDefinition> queryWrapper = Wrappers.lambdaQuery();
|
|
LambdaQueryWrapper<OaFormDefinition> queryWrapper = Wrappers.lambdaQuery();
|
|
queryWrapper.eq(OaFormDefinition::getId, id);
|
|
queryWrapper.eq(OaFormDefinition::getId, id);
|
|
String flowInfo = oaFormDefinitionMapper.selectOne(queryWrapper).getFlowInfo();
|
|
String flowInfo = oaFormDefinitionMapper.selectOne(queryWrapper).getFlowInfo();
|
|
oaProcessAnalysis.processAnalysis(flowInfo);
|
|
oaProcessAnalysis.processAnalysis(flowInfo);
|
|
- }
|
|
|
|
|
|
+ }*/
|
|
|
|
|
|
// 待处理
|
|
// 待处理
|
|
private List<OaApproval> getPendingSum(Integer tenantId, Long userId, LocalDateTime oneYearAgo, LocalDateTime now) {
|
|
private List<OaApproval> getPendingSum(Integer tenantId, Long userId, LocalDateTime oneYearAgo, LocalDateTime now) {
|
|
@@ -227,7 +354,7 @@ public class OaApprovalServiceImpl extends AbstractCrudService<OaApprovalMapper,
|
|
LambdaQueryWrapper<OaApproval> queryWrapper = Wrappers.lambdaQuery();
|
|
LambdaQueryWrapper<OaApproval> queryWrapper = Wrappers.lambdaQuery();
|
|
queryWrapper.eq(OaApproval::getTenantId, tenantId)
|
|
queryWrapper.eq(OaApproval::getTenantId, tenantId)
|
|
.eq(OaApproval::getApprovalUid, userId)
|
|
.eq(OaApproval::getApprovalUid, userId)
|
|
- .eq(OaApproval::getType, 1)
|
|
|
|
|
|
+ .eq(OaApproval::getType, 2)
|
|
.between(OaApproval::getSubmitDate, oneYearAgo, now);
|
|
.between(OaApproval::getSubmitDate, oneYearAgo, now);
|
|
List<OaApproval> oaApprovals = oaApprovalMapper.selectList(queryWrapper);
|
|
List<OaApproval> oaApprovals = oaApprovalMapper.selectList(queryWrapper);
|
|
return oaApprovals == null ? Collections.emptyList() : oaApprovals;
|
|
return oaApprovals == null ? Collections.emptyList() : oaApprovals;
|