Commit a9dd1b57 by 龙于生

新增审批节点并序审批功能

parent 096ad6bf
......@@ -726,7 +726,6 @@ public class SpmkController {
@ApiOperationSupport(order = 19)
@Log(title = "审批-审批详情", businessType = BusinessType.OTHER)
public Result<Object> selectAd(@PathVariable(required = true) Integer id) {
SpmkApproveDetailDto adD = spmkService.selectApproveDetailByAsId(id);
System.out.println(ResultUtil.data(adD));
return ResultUtil.data(adD);
......@@ -778,7 +777,10 @@ public class SpmkController {
redisUtil.set(asId.toString(),0,500);
return ResultUtil.error("您已审批过!");
}
Integer integer = spmkExecutorMapper.selectCount(new QueryWrapper<SpmkExecutor>().lambda()
.eq(SpmkExecutor::getId, approvingDto.getExecutorId())
.eq(SpmkExecutor::getEmpNum, userBean.getEmpNum())
.eq(SpmkExecutor::getSts, ExecutorSts.IN_EXECUTION.ordinal()));
if ( spmkExecutorMapper.selectCount(new QueryWrapper<SpmkExecutor>().lambda()
.eq(SpmkExecutor::getId, approvingDto.getExecutorId())
.eq(SpmkExecutor::getEmpNum, userBean.getEmpNum())
......@@ -808,11 +810,13 @@ public class SpmkController {
approvingDto.getOpinion(),
approvingDto.getSts(),
approvingDto.getUser(),
approvingDto.getSignatureImg()
approvingDto.getSignatureImg(),
userBean.getEmpNum()
);
// 更新 flowChildren
SpmkApproveDetailSummary.builder().id(ad.getId()).flowChildren(JSONArray.fromObject(listFlowChildren).toString()).build().updateById();
//最后一条数据
FlowChildren fc = CollUtil.getLast(listFlowChildren);
if (fc.getExecute() == "2") {
// 查询 SpmkApproveSummary 状态
......
......@@ -92,7 +92,9 @@ public class SpmkServiceImpl implements SpmkService{
public SpmkApproveDetailDto selectApproveDetailByAsId(Integer asId) {
// TODO Auto-generated method stub
//SpmkApproveDetail ad = spmkApproveDetailMapper.selectOne(new QueryWrapper<SpmkApproveDetail>().lambda().eq(SpmkApproveDetail::getApproveSummaryId, asId));
//审批详情
SpmkApproveDetailSummary ad = spmkApproveDetailSummaryMapper.selectOne(new QueryWrapper<SpmkApproveDetailSummary>().lambda().eq(SpmkApproveDetailSummary::getApproveSummaryId, asId));
//审批汇总
SpmkApproveSummary sum = null;
if(ad != null) {
sum = SpmkApproveSummary.builder().build().selectOne(new QueryWrapper<SpmkApproveSummary>().lambda().select(SpmkApproveSummary::getId,SpmkApproveSummary::getEmpNum,SpmkApproveSummary::getSts,SpmkApproveSummary::getCreateTime)
......@@ -103,6 +105,7 @@ public class SpmkServiceImpl implements SpmkService{
if (ad == null) {
return null;
}
//审批操作记录
List<SpmkApproveExecuteRecord> listAer = spmkApproveExecuteRecordMapper.selectListByAsId(asId);
BeanUtil.copyProperties(ad, adD, "requestData","froms","router","flowChildren","spmkApproveExecuteRecord");
if(ad.getRequestData() !=null) {
......
......@@ -52,5 +52,10 @@ public class Relation implements Serializable{
* 主管是否手签 1是 0否
*/
private Integer signature;
/**
* 同级审批次序 0依次 1同时
*/
private String approvalOrder;
}
......@@ -463,37 +463,71 @@ public class RouterUtils {
.insert();
break;
case AUDIT:
SpmkApproveExecuteRecord aer2 = SpmkApproveExecuteRecord
.builder()
.approveSummaryId(asId)
.name(ParticipatorType.APPROVER.getName())
.type(ParticipatorType.APPROVER.ordinal())
.sts(ExecuteRecordSts.IN_EXECUTION.ordinal())
.build();
// 新增 审批执行记录
aer2.insert();
// 新增 执行人
List<User> listUser = listFlowChildren.get(i).getRelation().get(0).getUsers();
for (User user2 : listUser) {
SpmkExecutor executor = SpmkExecutor.builder()
.approveExecuteRecordId(aer2.getId())
.empNum(Integer.parseInt(user2.getId()))
.operatorHeaderUrl(user2.getHeadUrl())
.executorName(user2.getName())
.build();
switch (user2.getExecute()) {
case EXECUTING:
executor.setSts(ExecutorSts.IN_EXECUTION.ordinal());
executor.insert();
break for_insert;
case EXECUTED:
executor.setSts(ExecutorSts.AGREE.ordinal());
executor.insert();
break;
Relation relation1 =listFlowChildren.get(i).getRelation().get(0);
if("1".equals(relation1.getApprovalOrder())){
for (User user2 : listUser) {
SpmkApproveExecuteRecord aer2 = SpmkApproveExecuteRecord
.builder()
.approveSummaryId(asId)
.name(ParticipatorType.APPROVER.getName())
.type(ParticipatorType.APPROVER.ordinal())
.sts(ExecuteRecordSts.IN_EXECUTION.ordinal())
.build();
// 新增 审批执行记录
aer2.insert();
SpmkExecutor executor = SpmkExecutor.builder()
.approveExecuteRecordId(aer2.getId())
.empNum(Integer.parseInt(user2.getId()))
.operatorHeaderUrl(user2.getHeadUrl())
.executorName(user2.getName())
.build();
user2.setExecute("1");
switch (user2.getExecute()) {
case EXECUTING:
executor.setSts(ExecutorSts.IN_EXECUTION.ordinal());
executor.insert();
break;
case EXECUTED:
executor.setSts(ExecutorSts.AGREE.ordinal());
executor.insert();
break;
}
}
}else{
SpmkApproveExecuteRecord aer2 = SpmkApproveExecuteRecord
.builder()
.approveSummaryId(asId)
.name(ParticipatorType.APPROVER.getName())
.type(ParticipatorType.APPROVER.ordinal())
.sts(ExecuteRecordSts.IN_EXECUTION.ordinal())
.build();
// 新增 审批执行记录
aer2.insert();
for (User user2 : listUser) {
SpmkExecutor executor = SpmkExecutor.builder()
.approveExecuteRecordId(aer2.getId())
.empNum(Integer.parseInt(user2.getId()))
.operatorHeaderUrl(user2.getHeadUrl())
.executorName(user2.getName())
.build();
switch (user2.getExecute()) {
case EXECUTING:
executor.setSts(ExecutorSts.IN_EXECUTION.ordinal());
executor.insert();
break for_insert;
case EXECUTED:
executor.setSts(ExecutorSts.AGREE.ordinal());
executor.insert();
break;
}
}
}
break;
case COPY:
SpmkApproveExecuteRecord aer3 = SpmkApproveExecuteRecord
......@@ -536,19 +570,37 @@ public class RouterUtils {
* @param opinion 意见
* @param sts 状态 1执行中 2通过 3拒绝
*/
public static void approving(List<FlowChildren> listFlowChildren,Integer asId,Integer executeRecordId, Integer executorId, String opinion,Integer sts,User redeployUser,String signatureImg ) throws Exception {
public static void approving(List<FlowChildren> listFlowChildren,Integer asId,Integer executeRecordId, Integer executorId, String opinion,Integer sts,User redeployUser,String signatureImg,Integer empNum ) throws Exception {
boolean hasNextApprover = false;
int es=0;
for (int i = 0,n = listFlowChildren.size(); i < n; i++) {
// 新增 执行人
List<User> listUser = CollUtil.toList();
List<Relation> listR = listFlowChildren.get(i).getRelation();
if (CollectionUtil.isNotEmpty(listR)) {
listUser = listR.get(0).getUsers();
if("1".equals(listR.get(0).getApprovalOrder())){
for (User user:listR.get(0).getUsers()
) {
if ("1".equals(user.getExecute())){
es++;
}
}
/*for (int j = 0; j < listR.get(0).getUsers().size(); j++) {
String execute = listR.get(0).getUsers().get(j).getExecute();
if("1".equals(execute)){
es++;
}
}*/
}
}
if (EXECUTING.equals(listFlowChildren.get(i).getExecute())) {
......@@ -556,17 +608,21 @@ public class RouterUtils {
if (EXECUTED.equals(listUser.get(i_user).getExecute())) {
}else if (EXECUTING.equals(listUser.get(i_user).getExecute())) {
SpmkExecutor.builder()
.id(executorId)
.opinion(opinion)
.empNum(Integer.parseInt(listUser.get(i_user).getId()))
.executorName(listUser.get(i_user).getName())
.operatorHeaderUrl(listUser.get(i_user).getHeadUrl())
.sts(sts)
.signatureImg(signatureImg)
.build()
.updateById();
listUser.get(i_user).setExecute(EXECUTED);
if (Integer.parseInt(listUser.get(i_user).getId()) == empNum){
SpmkExecutor.builder()
.id(executorId)
.opinion(opinion)
.empNum(Integer.parseInt(listUser.get(i_user).getId()))
.executorName(listUser.get(i_user).getName())
.operatorHeaderUrl(listUser.get(i_user).getHeadUrl())
.sts(sts)
.signatureImg(signatureImg)
.build()
.updateById();
listUser.get(i_user).setExecute(EXECUTED);
}
// 历史审批人
SpmkApproveSummary.builder()
......@@ -574,6 +630,7 @@ public class RouterUtils {
.historyApprover(listUser.get(i_user).getName())
.build()
.updateById();
//拒绝处理
// 0未执行 1执行中 2同意 3拒绝 4 转派
if (sts == ExecutorSts.REFUSE.ordinal()) {
// 更新 审批汇总 状态
......@@ -629,11 +686,16 @@ public class RouterUtils {
.build();
// 更新 审批执行记录
aer.updateById();
listFlowChildren.get(i).setExecute(EXECUTED);
if(es<=1){
listFlowChildren.get(i).setExecute(EXECUTED);
}
}
}else if (UNEXECUTED.equals(listFlowChildren.get(i).getExecute())) {
if (!hasNextApprover) {
if (!hasNextApprover && es<=1) {
switch (listFlowChildren.get(i).getClassName()) {
case CREATOR:
SpmkApproveExecuteRecord aer = SpmkApproveExecuteRecord
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment