|
@@ -17,6 +17,7 @@
|
|
|
package org.springblade.check.service.impl;
|
|
package org.springblade.check.service.impl;
|
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
|
|
import org.springblade.client.entity.Message;
|
|
import org.springblade.client.entity.Message;
|
|
|
import org.springblade.client.feign.IMessageClient;
|
|
import org.springblade.client.feign.IMessageClient;
|
|
|
import org.springblade.core.tool.api.R;
|
|
import org.springblade.core.tool.api.R;
|
|
@@ -37,8 +38,11 @@ import org.springframework.stereotype.Service;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
|
|
|
+import java.util.Collections;
|
|
|
|
|
+import java.util.Comparator;
|
|
|
import java.util.Date;
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 审批流记录 服务实现类
|
|
* 审批流记录 服务实现类
|
|
@@ -66,8 +70,26 @@ public class AuditProecessServiceImpl extends ServiceImpl<AuditProecessMapper, A
|
|
|
@Transactional
|
|
@Transactional
|
|
|
public void createFinanceProcess(AuditProecessDTO auditProecessDTO)
|
|
public void createFinanceProcess(AuditProecessDTO auditProecessDTO)
|
|
|
{
|
|
{
|
|
|
|
|
+ //查询最大批次号
|
|
|
|
|
+ int current=0;
|
|
|
|
|
+ LambdaQueryWrapper<AuditProecess> auditProecessLambdaQueryWrapper=new LambdaQueryWrapper<>();
|
|
|
|
|
+ auditProecessLambdaQueryWrapper.eq(AuditProecess::getSrcBillId,auditProecessDTO.getSrcBillId());
|
|
|
|
|
+ List<AuditProecess> auditProecesses = baseMapper.selectList(auditProecessLambdaQueryWrapper);
|
|
|
|
|
+ if(CollectionUtils.isNotEmpty(auditProecesses))
|
|
|
|
|
+ {
|
|
|
|
|
+ int max = auditProecesses.stream().max(Comparator.comparing(AuditProecess::getBatchNo)).get().getBatchNo();
|
|
|
|
|
+ current=max+1;
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ else
|
|
|
|
|
+ {
|
|
|
|
|
+ current=1;
|
|
|
|
|
+ }
|
|
|
|
|
+ int finalCurrent = current;
|
|
|
|
|
+
|
|
|
List<AuditPathsLevels> pathsLevelsList = auditProecessDTO.getPathsLevelsList();
|
|
List<AuditPathsLevels> pathsLevelsList = auditProecessDTO.getPathsLevelsList();
|
|
|
//根据审批级次 生成 有多少调就生成多条审批流
|
|
//根据审批级次 生成 有多少调就生成多条审批流
|
|
|
|
|
+
|
|
|
pathsLevelsList.forEach(e->{
|
|
pathsLevelsList.forEach(e->{
|
|
|
AuditProecess auditProecess=new AuditProecess();
|
|
AuditProecess auditProecess=new AuditProecess();
|
|
|
auditProecess.setActId(auditProecessDTO.getActId());
|
|
auditProecess.setActId(auditProecessDTO.getActId());
|
|
@@ -86,7 +108,7 @@ public class AuditProecessServiceImpl extends ServiceImpl<AuditProecessMapper, A
|
|
|
auditProecess.setIffinalItem(e.getIffinalItem());
|
|
auditProecess.setIffinalItem(e.getIffinalItem());
|
|
|
auditProecess.setProcessType(auditProecessDTO.getProcessType());
|
|
auditProecess.setProcessType(auditProecessDTO.getProcessType());
|
|
|
auditProecess.setUrl(auditProecessDTO.getUrl());
|
|
auditProecess.setUrl(auditProecessDTO.getUrl());
|
|
|
-
|
|
|
|
|
|
|
+ auditProecess.setBatchNo(finalCurrent);
|
|
|
//除了第一级是待审,其他都N
|
|
//除了第一级是待审,其他都N
|
|
|
if(e.getLevelId()==1)
|
|
if(e.getLevelId()==1)
|
|
|
{
|
|
{
|
|
@@ -247,4 +269,49 @@ public class AuditProecessServiceImpl extends ServiceImpl<AuditProecessMapper, A
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
|
+ @Transactional
|
|
|
|
|
+ @GlobalTransactional
|
|
|
|
|
+ public void cancelCheck(Long srcBillId)
|
|
|
|
|
+ {
|
|
|
|
|
+ //查询最大批次号
|
|
|
|
|
+ LambdaQueryWrapper<AuditProecess> countMaxWrapper=new LambdaQueryWrapper<>();
|
|
|
|
|
+ countMaxWrapper
|
|
|
|
|
+ .eq(AuditProecess::getSrcBillId,srcBillId)
|
|
|
|
|
+ .eq(AuditProecess::getIsDelete,0)
|
|
|
|
|
+ .eq(AuditProecess::getTenantId,AuthUtil.getTenantId());
|
|
|
|
|
+ List<AuditProecess> proecessList = baseMapper.selectList(countMaxWrapper);
|
|
|
|
|
+ if(CollectionUtils.isEmpty(proecessList))
|
|
|
|
|
+ {
|
|
|
|
|
+ throw new SecurityException("无审批记录,禁止撤回");
|
|
|
|
|
+ }
|
|
|
|
|
+ //获取此申请表下的最大批次号
|
|
|
|
|
+ int max = proecessList.stream().max(Comparator.comparing(AuditProecess::getBatchNo)).get().getBatchNo();
|
|
|
|
|
+ //获取最新的审批记录
|
|
|
|
|
+ List<AuditProecess> auditProecessList = proecessList.stream().filter(e -> e.getBatchNo() == max).collect(Collectors.toList());
|
|
|
|
|
+ //如果最新审批记录 第一级已经操作,就禁止撤回
|
|
|
|
|
+ long count = auditProecessList.stream().filter(
|
|
|
|
|
+ e -> e.getBatchNo() == max &&
|
|
|
|
|
+ e.getLevelId() == 1 &&
|
|
|
|
|
+ (e.getAuditStatus().equals("A") || e.getAuditStatus().equals("B")))
|
|
|
|
|
+ .count();
|
|
|
|
|
+ if(count>0)
|
|
|
|
|
+ {
|
|
|
|
|
+ throw new SecurityException("第一级审批已经开始,禁止撤回");
|
|
|
|
|
+ }
|
|
|
|
|
+ //撤回开始,删除审批记录
|
|
|
|
|
+ auditProecessList.forEach(e->{
|
|
|
|
|
+ e.setIsDelete(1);
|
|
|
|
|
+ baseMapper.updateById(e);
|
|
|
|
|
+ });
|
|
|
|
|
+ // 修改原申请表状态
|
|
|
|
|
+ R r = financeClient.passCancel(srcBillId);
|
|
|
|
|
+ if(!r.isSuccess())
|
|
|
|
|
+ {
|
|
|
|
|
+ throw new SecurityException("撤回失败,修改原申请表出错");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
}
|
|
}
|