Commit a9dd1b57 by 龙于生

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

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