|
@@ -10,12 +10,18 @@ import com.usky.common.core.exception.BusinessException;
|
|
|
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.service.OaApprovalService;
|
|
|
import com.usky.common.mybatis.core.AbstractCrudService;
|
|
|
+import com.usky.oa.service.utils.OaProcessAnalysis;
|
|
|
+import com.usky.oa.service.utils.OaSendMessageCenter;
|
|
|
import com.usky.oa.service.vo.OaApprovalCountVO;
|
|
|
+import com.usky.system.domain.SysUser;
|
|
|
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.stereotype.Service;
|
|
|
|
|
@@ -24,6 +30,7 @@ import java.time.format.DateTimeFormatter;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Collections;
|
|
|
import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
import java.util.stream.Collectors;
|
|
|
import java.util.stream.Stream;
|
|
|
|
|
@@ -44,22 +51,36 @@ public class OaApprovalServiceImpl extends AbstractCrudService<OaApprovalMapper,
|
|
|
@Autowired
|
|
|
private OaDocumentMapper oaDocumentMapper;
|
|
|
|
|
|
- // 我的申请-待处理、已处理、我发起、我收到-统计
|
|
|
+ @Autowired
|
|
|
+ private OaSendMessageCenter oaSendMessageCenter;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private OaProcessAnalysis oaProcessAnalysis;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private OaFormDefinitionMapper oaFormDefinitionMapper;
|
|
|
+
|
|
|
+
|
|
|
+ // 我的申请-待处理、已处理、我发起、我收到-统计(暂时统计近一年数据)
|
|
|
@Override
|
|
|
public OaApprovalCountVO approvalCount() {
|
|
|
Long userId = SecurityUtils.getUserId();
|
|
|
String username = SecurityUtils.getUsername();
|
|
|
Integer tenantId = SecurityUtils.getTenantId();
|
|
|
|
|
|
+ LocalDateTime now = LocalDateTime.now();
|
|
|
+ // 一年前时间
|
|
|
+ LocalDateTime oneYearAgo = now.minusYears(1);
|
|
|
+
|
|
|
OaApprovalCountVO oaApprovalCountVO = new OaApprovalCountVO();
|
|
|
// 待处理
|
|
|
- oaApprovalCountVO.setPendingSum(getPendingSum(tenantId, userId).size());
|
|
|
+ oaApprovalCountVO.setPendingSum(getPendingSum(tenantId, userId, oneYearAgo, now).size());
|
|
|
// 已处理
|
|
|
- oaApprovalCountVO.setAlreadySum(getAlreadySum(tenantId, userId).size());
|
|
|
+ oaApprovalCountVO.setAlreadySum(getAlreadySum(tenantId, userId, oneYearAgo, now).size());
|
|
|
// 我发起
|
|
|
- oaApprovalCountVO.setMyInitiated(getMyInitiated(tenantId, username).size());
|
|
|
+ oaApprovalCountVO.setMyInitiated(getMyInitiated(tenantId, username, oneYearAgo, now).size());
|
|
|
// 我收到
|
|
|
- oaApprovalCountVO.setMyReceived(getMyReceived(tenantId, userId).size());
|
|
|
+ oaApprovalCountVO.setMyReceived(getMyReceived(tenantId, userId, oneYearAgo, now).size());
|
|
|
|
|
|
return oaApprovalCountVO;
|
|
|
}
|
|
@@ -71,16 +92,11 @@ public class OaApprovalServiceImpl extends AbstractCrudService<OaApprovalMapper,
|
|
|
Integer tenantId = SecurityUtils.getTenantId();
|
|
|
IPage<OaApproval> page = new Page<>(pageNum, pageSize);
|
|
|
|
|
|
- LocalDateTime now = LocalDateTime.now();
|
|
|
- // 一年前时间
|
|
|
- LocalDateTime oneYearAgo = now.minusYears(1);
|
|
|
-
|
|
|
List<Integer> processed = Stream.of(2, 3).collect(Collectors.toList());
|
|
|
|
|
|
LambdaQueryWrapper<OaApproval> queryWrapper = Wrappers.lambdaQuery();
|
|
|
queryWrapper.eq(OaApproval::getTenantId, tenantId)
|
|
|
- .eq(OaApproval::getApprovalUid, userId)
|
|
|
- .between(OaApproval::getCreateTime, oneYearAgo, now);
|
|
|
+ .eq(OaApproval::getApprovalUid, userId).orderByDesc(OaApproval::getApprovalDate);
|
|
|
|
|
|
switch (queryType) {
|
|
|
case 1:
|
|
@@ -127,33 +143,55 @@ public class OaApprovalServiceImpl extends AbstractCrudService<OaApprovalMapper,
|
|
|
throw new BusinessException("审批类型错误,请重试!");
|
|
|
}
|
|
|
|
|
|
+ String username = SecurityUtils.getUsername();
|
|
|
+
|
|
|
+ LocalDateTime now = LocalDateTime.now();
|
|
|
+
|
|
|
oaApproval.setApprovalStatus(approvalStatus);
|
|
|
oaApproval.setOpinion(opinion);
|
|
|
- oaApproval.setApprovalDate(LocalDateTime.now());
|
|
|
- oaApproval.setUpdateBy(SecurityUtils.getUsername());
|
|
|
- oaApproval.setUpdateTime(LocalDateTime.now());
|
|
|
+ oaApproval.setApprovalDate(now);
|
|
|
+ oaApproval.setUpdateBy(username);
|
|
|
+ oaApproval.setUpdateTime(now);
|
|
|
oaApprovalMapper.updateById(oaApproval);
|
|
|
+
|
|
|
+ int isPass = 1;
|
|
|
+ if (approvalStatus == 3) {
|
|
|
+ isPass = 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ List<Long> receivers = Collections.singletonList(Long.valueOf(oaApproval.getProposer()));
|
|
|
+ oaSendMessageCenter.sendAsyncMessage(oaApproval.getCreateBy(), Long.valueOf(oaApproval.getProposer()), oaApproval.getId(), receivers, isPass);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void analysisTest(Integer id) {
|
|
|
+ LambdaQueryWrapper<OaFormDefinition> queryWrapper = Wrappers.lambdaQuery();
|
|
|
+ queryWrapper.eq(OaFormDefinition::getId, id);
|
|
|
+ String flowInfo = oaFormDefinitionMapper.selectOne(queryWrapper).getFlowInfo();
|
|
|
+ oaProcessAnalysis.processAnalysis(flowInfo);
|
|
|
}
|
|
|
|
|
|
// 待处理
|
|
|
- private List<OaApproval> getPendingSum(Integer tenantId, Long userId) {
|
|
|
+ private List<OaApproval> getPendingSum(Integer tenantId, Long userId, LocalDateTime oneYearAgo, LocalDateTime now) {
|
|
|
LambdaQueryWrapper<OaApproval> queryWrapper = Wrappers.lambdaQuery();
|
|
|
queryWrapper.eq(OaApproval::getTenantId, tenantId)
|
|
|
.eq(OaApproval::getApprovalUid, userId)
|
|
|
- .eq(OaApproval::getApprovalStatus, 1);
|
|
|
+ .eq(OaApproval::getApprovalStatus, 1)
|
|
|
+ .between(OaApproval::getSubmitDate, oneYearAgo, now);
|
|
|
List<OaApproval> oaApprovals = oaApprovalMapper.selectList(queryWrapper);
|
|
|
return oaApprovals == null ? Collections.emptyList() : oaApprovals;
|
|
|
}
|
|
|
|
|
|
// 已处理
|
|
|
- private List<OaApproval> getAlreadySum(Integer tenantId, Long userId) {
|
|
|
+ private List<OaApproval> getAlreadySum(Integer tenantId, Long userId, LocalDateTime oneYearAgo, LocalDateTime now) {
|
|
|
LambdaQueryWrapper<OaApproval> queryWrapper = Wrappers.lambdaQuery();
|
|
|
queryWrapper.eq(OaApproval::getTenantId, tenantId)
|
|
|
.eq(OaApproval::getApprovalUid, userId)
|
|
|
.and(wrapper -> wrapper
|
|
|
.eq(OaApproval::getApprovalStatus, 2)
|
|
|
.or()
|
|
|
- .eq(OaApproval::getApprovalStatus, 3));
|
|
|
+ .eq(OaApproval::getApprovalStatus, 3))
|
|
|
+ .between(OaApproval::getSubmitDate, oneYearAgo, now);
|
|
|
List<OaApproval> oaApprovals = oaApprovalMapper.selectList(queryWrapper);
|
|
|
return oaApprovals == null ? Collections.emptyList() : oaApprovals;
|
|
|
}
|
|
@@ -174,20 +212,23 @@ public class OaApprovalServiceImpl extends AbstractCrudService<OaApprovalMapper,
|
|
|
}*/
|
|
|
|
|
|
// 我发起
|
|
|
- private List<OaDocument> getMyInitiated(Integer tenantId, String username) {
|
|
|
+ private List<OaDocument> getMyInitiated(Integer tenantId, String username, LocalDateTime oneYearAgo, LocalDateTime now) {
|
|
|
List<OaDocument> oaDocuments = oaDocumentMapper.selectList(new QueryWrapper<OaDocument>().lambda()
|
|
|
.select(OaDocument::getDocNo)
|
|
|
.eq(OaDocument::getTenantId, tenantId)
|
|
|
- .eq(OaDocument::getCreateBy, username));
|
|
|
+ .eq(OaDocument::getCreateBy, username)
|
|
|
+ .in(OaDocument::getDocStatus, 1, 2, 3)
|
|
|
+ .between(OaDocument::getCreateTime, oneYearAgo, now));
|
|
|
return oaDocuments == null ? Collections.emptyList() : oaDocuments;
|
|
|
}
|
|
|
|
|
|
// 我收到
|
|
|
- private List<OaApproval> getMyReceived(Integer tenantId, Long userId) {
|
|
|
+ private List<OaApproval> getMyReceived(Integer tenantId, Long userId, LocalDateTime oneYearAgo, LocalDateTime now) {
|
|
|
LambdaQueryWrapper<OaApproval> queryWrapper = Wrappers.lambdaQuery();
|
|
|
queryWrapper.eq(OaApproval::getTenantId, tenantId)
|
|
|
.eq(OaApproval::getApprovalUid, userId)
|
|
|
- .eq(OaApproval::getType, 1);
|
|
|
+ .eq(OaApproval::getType, 1)
|
|
|
+ .between(OaApproval::getSubmitDate, oneYearAgo, now);
|
|
|
List<OaApproval> oaApprovals = oaApprovalMapper.selectList(queryWrapper);
|
|
|
return oaApprovals == null ? Collections.emptyList() : oaApprovals;
|
|
|
}
|