|
@@ -31,6 +31,7 @@ import org.springblade.core.secure.utils.AuthUtil;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.context.annotation.Lazy;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.HashMap;
|
|
@@ -123,6 +124,7 @@ public class ExampleInfoServiceImpl extends ServiceImpl<ExampleInfoMapper, Examp
|
|
|
List<Map<String, Object>> result = exampleDetailsService.listMaps(
|
|
|
Wrappers.<ExampleDetails>query()
|
|
|
.select("example_info_id exampleInfoId",
|
|
|
+ "id exampleDetailsId",
|
|
|
"handle_user_id userId", // 处理人id
|
|
|
"remarks", // 审批意见
|
|
|
"name_type type", // 处理类型
|
|
@@ -134,12 +136,6 @@ public class ExampleInfoServiceImpl extends ServiceImpl<ExampleInfoMapper, Examp
|
|
|
.eq(ExampleDetails::getExampleInfoId, exampleInfo.getId())
|
|
|
.orderByAsc(BaseEntity::getId));
|
|
|
|
|
|
- // 如果最后一个节点处理人是自己,可以撤回
|
|
|
- Map<String, Object> lastNode = result.get(result.size() - 1);
|
|
|
- if (result.size() > 1 && Convert.toLong(lastNode.get("userId")).equals(AuthUtil.getUserId())) {
|
|
|
- lastNode.put("withdrawProcessNodeId", result.get(result.size() - 2).get("nodeId").toString());
|
|
|
- lastNode.put("withdrawExampleInfoId", lastNode.get("exampleInfoId").toString());
|
|
|
- }
|
|
|
|
|
|
// 查询用户名称与岗位
|
|
|
List<Long> userId = result.stream().map(item -> (Long) item.get("userId")).collect(Collectors.toList());
|
|
@@ -176,10 +172,20 @@ public class ExampleInfoServiceImpl extends ServiceImpl<ExampleInfoMapper, Examp
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
+ Map<String, Object> lastNode = result.get(result.size() - 1);
|
|
|
+
|
|
|
+ // 如果最后一个节点处理人是自己,可以撤回
|
|
|
+ if (result.size() > 1 && Convert.toLong(lastNode.get("userId")).equals(AuthUtil.getUserId())) {
|
|
|
+ lastNode.put("withdrawProcessNodeId", result.get(result.size() - 2).get("nodeId").toString());
|
|
|
+ lastNode.put("withdrawExampleInfoId", lastNode.get("exampleInfoId").toString());
|
|
|
+ lastNode.put("withdrawExampleDetailsId", lastNode.get("exampleDetailsId").toString());
|
|
|
+ }
|
|
|
+
|
|
|
// 如果下一个节点是开始节点,发起人是自己,可以撤销
|
|
|
if (FlowConstant.START_CODE.equals(nextNode.getCode()) &&
|
|
|
AuthUtil.getUserId().equals(Convert.toLong(result.get(0).get("createUser")))) {
|
|
|
lastNode.put("revokeExampleInfoId", lastNode.get("exampleInfoId").toString());
|
|
|
+ lastNode.put("revokeExampleDetailsId", lastNode.get("exampleDetailsId").toString());
|
|
|
}
|
|
|
|
|
|
next(result, nextNode, parentProcessNodeMap);
|
|
@@ -286,9 +292,36 @@ public class ExampleInfoServiceImpl extends ServiceImpl<ExampleInfoMapper, Examp
|
|
|
return page;
|
|
|
}
|
|
|
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
@Override
|
|
|
- public void revoke(Long exampleInfoId) {
|
|
|
+ public void withdraw(Long withdrawExampleInfoId, Long withdrawExampleDetailsId) {
|
|
|
+ List<ExampleDetails> list = exampleDetailsService.list(
|
|
|
+ Wrappers.<ExampleDetails>lambdaQuery()
|
|
|
+ .eq(ExampleDetails::getExampleInfoId, withdrawExampleInfoId)
|
|
|
+ .ge(BaseEntity::getId, withdrawExampleDetailsId));
|
|
|
+ Assert.eqOne(list.size(), "下一审批节点已被处理,无法撤回");
|
|
|
+
|
|
|
+ ExampleDetails exampleDetails = list.get(0);
|
|
|
+ ProcessNode processNode = processNodeService.getById(exampleDetails.getProcessNodeId());
|
|
|
+
|
|
|
+ ExampleInfo exampleInfo = new ExampleInfo();
|
|
|
+ exampleInfo.setId(withdrawExampleInfoId);
|
|
|
+ exampleInfo.setProcessNodeId(processNode.getId());
|
|
|
+ exampleInfo.setProcessNodeCode(processNode.getCode());
|
|
|
+ updateById(exampleInfo);
|
|
|
+
|
|
|
+ exampleDetailsService.removeById(exampleDetails.getId());
|
|
|
+ }
|
|
|
|
|
|
+ @Override
|
|
|
+ public void revoke(Long withdrawExampleInfoId) {
|
|
|
+ ExampleInfo exampleInfo = getById(withdrawExampleInfoId);
|
|
|
+ Assert.eqTrue(FlowConstant.START_CODE.equals(exampleInfo.getProcessNodeCode()),
|
|
|
+ "下一节点已被处理,不可撤销");
|
|
|
+
|
|
|
+ exampleInfo.setHandleResult(HandleResultEnum.REVOKE.getType());
|
|
|
+ exampleInfo.setComplete(StatusConstant.YES);
|
|
|
+ updateById(exampleInfo);
|
|
|
}
|
|
|
|
|
|
|