新增城市管理

This commit is contained in:
2026-04-20 14:14:08 +08:00
parent 1584d7e06d
commit f73a002f0f
15 changed files with 483 additions and 15 deletions

View File

@@ -56,6 +56,16 @@ public class HrmFlowTaskController extends BaseController {
}
/**
* 详情页使用:按 bizType + bizId 查询审批概要、当前待办和历史记录
*/
@GetMapping("/detailByBiz")
public R<?> detailByBiz(@RequestParam @NotNull String bizType,
@RequestParam @NotNull Long bizId,
@RequestParam(required = false) Long assigneeUserId) {
return R.ok(service.queryDetailByBiz(bizType, bizId, assigneeUserId));
}
@GetMapping("/{taskId}")
public R<HrmFlowTaskVo> getInfo(@PathVariable @NotNull Long taskId) {
return R.ok(service.queryById(taskId));

View File

@@ -7,12 +7,11 @@ import com.ruoyi.common.core.domain.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.io.Serializable;
@Data
@EqualsAndHashCode(callSuper = true)
@TableName("hrm_flow_action")
public class HrmFlowAction extends BaseEntity implements Serializable {
public class HrmFlowAction extends BaseEntity {
private static final long serialVersionUID = 1L;
@TableId

View File

@@ -0,0 +1,28 @@
package com.ruoyi.hrm.domain.vo;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
@Data
public class HrmFlowActionTimelineVo implements Serializable {
private static final long serialVersionUID = 1L;
private Long actionId;
private Long taskId;
private Long instId;
private Long actionUserId;
private String actionUserName;
private Long assigneeUserId;
private String assigneeUserName;
private String action;
private String actionText;
private String remark;
private String bizType;
private Long bizId;
private Long nodeId;
private String nodeName;
private String taskStatus;
private Date createTime;
}

View File

@@ -0,0 +1,32 @@
package com.ruoyi.hrm.domain.vo;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
@Data
public class HrmFlowTaskDetailVo implements Serializable {
private static final long serialVersionUID = 1L;
/** 当前业务对应的待办任务 */
private HrmFlowTaskVo currentTask;
/** 当前业务对应的全部任务历史 */
private List<HrmFlowTaskVo> taskHistory;
/** 当前流程实例状态 */
private String flowStatus;
/** 当前节点ID */
private Long currentNodeId;
/** 当前节点名称 */
private String currentNodeName;
/** 审批是否通过 */
private Boolean approved;
/** 流程动作历史(更细粒度) */
private List<HrmFlowActionTimelineVo> actionTimeline;
}

View File

@@ -2,8 +2,8 @@ package com.ruoyi.hrm.service;
import com.ruoyi.common.core.domain.PageQuery;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.hrm.domain.HrmFlowTask;
import com.ruoyi.hrm.domain.bo.HrmFlowTaskBo;
import com.ruoyi.hrm.domain.vo.HrmFlowTaskDetailVo;
import com.ruoyi.hrm.domain.vo.HrmFlowTaskVo;
import java.util.Collection;
@@ -51,4 +51,9 @@ public interface IHrmFlowTaskService {
* 根据业务类型 + 业务ID 查询当前待办任务pending用于详情页自动带出 currentTaskId
*/
HrmFlowTaskVo queryTodoByBiz(String bizType, Long bizId, Long assigneeUserId);
/**
* 按业务查询详情:当前待办、状态和历史审批记录
*/
HrmFlowTaskDetailVo queryDetailByBiz(String bizType, Long bizId, Long assigneeUserId);
}

View File

@@ -75,6 +75,7 @@ public class HrmFlowInstanceServiceImpl implements IHrmFlowInstanceService {
task.setNodeId(0L);
task.setAssigneeUserId(bo.getManualAssigneeUserId());
task.setStatus("pending");
task.setRemark("自选审批人一次性审批");
// 关键:写入业务关联字段,便于审批中心联查业务数据
task.setBizType(bo.getBizType());
task.setBizId(bo.getBizId());
@@ -121,6 +122,7 @@ public class HrmFlowInstanceServiceImpl implements IHrmFlowInstanceService {
task.setNodeId(firstNode.getNodeId());
task.setAssigneeUserId(assignees.get(0));
task.setStatus("pending");
task.setRemark(firstNode.getRemark());
// 关键:写入业务关联字段,便于审批中心联查业务数据
task.setBizType(bo.getBizType());
task.setBizId(bo.getBizId());

View File

@@ -12,6 +12,8 @@ import com.ruoyi.common.helper.LoginHelper;
import com.ruoyi.hrm.domain.*;
import com.ruoyi.hrm.domain.bo.HrmFlowTaskBo;
import com.ruoyi.hrm.domain.bo.HrmSealStampBo;
import com.ruoyi.hrm.domain.vo.HrmFlowActionTimelineVo;
import com.ruoyi.hrm.domain.vo.HrmFlowTaskDetailVo;
import com.ruoyi.hrm.domain.vo.HrmFlowTaskVo;
import com.ruoyi.hrm.domain.vo.HrmEmployeeVo;
import com.ruoyi.hrm.mapper.*;
@@ -40,7 +42,6 @@ public class HrmFlowTaskServiceImpl implements IHrmFlowTaskService {
private final FlowAssigneeHelper assigneeHelper;
private final BizStatusSyncHelper bizStatusSyncHelper;
private final HrmFlowTaskMapper hrmFlowTaskMapper;
// 注入五个业务Mapper
private final HrmLeaveReqMapper leaveReqMapper;
private final HrmTravelReqMapper travelReqMapper;
@@ -185,12 +186,13 @@ private void fillBizData(List<HrmFlowTaskVo> tasks) {
if (inst == null) {
return false;
}
Long operatorUserId = actionUserId != null ? actionUserId : LoginHelper.getUserId();
// 无模板一次性审批tplId=0 或 nodeId=0直接结束流程
if (inst.getTplId() != null && inst.getTplId() == 0L) {
// 记录动作
saveAction(taskId, inst.getInstId(), "approve", remark, actionUserId,task.getBizType(), task.getBizId());
saveAction(taskId, inst.getInstId(), task.getBizType(), task.getBizId(), task.getAssigneeUserId(), "approve", remark, operatorUserId);
if (stampBo != null) {
saveAction(taskId, inst.getInstId(), "stamp", "盖章", actionUserId,task.getBizType(), task.getBizId());
saveAction(taskId, inst.getInstId(), task.getBizType(), task.getBizId(), task.getAssigneeUserId(), "stamp", "盖章", operatorUserId);
}
task.setStatus("approved");
baseMapper.updateById(task);
@@ -202,7 +204,7 @@ private void fillBizData(List<HrmFlowTaskVo> tasks) {
sealReqService.updateStatus(inst.getBizId(), "approved");
if (stampBo != null) {
// 盖章动作也写入流转历史
saveAction(taskId, inst.getInstId(), "stamp", "盖章", actionUserId,task.getBizType(), task.getBizId());
saveAction(taskId, inst.getInstId(), task.getBizType(), task.getBizId(), task.getAssigneeUserId(), "stamp", "盖章", operatorUserId);
sealReqService.stampWithJava(inst.getBizId(), stampBo);
}
}
@@ -215,7 +217,7 @@ private void fillBizData(List<HrmFlowTaskVo> tasks) {
return false;
}
// 记录动作
saveAction(taskId, inst.getInstId(), "approve", remark, actionUserId,task.getBizType(),task.getBizId());
saveAction(taskId, inst.getInstId(), task.getBizType(), task.getBizId(), task.getAssigneeUserId(), "approve", remark, operatorUserId);
// 完成当前任务
task.setStatus("approved");
baseMapper.updateById(task);
@@ -299,7 +301,8 @@ private void fillBizData(List<HrmFlowTaskVo> tasks) {
if (inst == null) {
return false;
}
saveAction(taskId, inst.getInstId(), "reject", remark, actionUserId,task.getBizType(),task.getBizId());
Long operatorUserId = actionUserId != null ? actionUserId : LoginHelper.getUserId();
saveAction(taskId, inst.getInstId(), task.getBizType(), task.getBizId(), task.getAssigneeUserId(), "reject", remark, operatorUserId);
task.setStatus("rejected");
baseMapper.updateById(task);
inst.setStatus("rejected");
@@ -323,7 +326,8 @@ private void fillBizData(List<HrmFlowTaskVo> tasks) {
if (inst == null) {
return false;
}
saveAction(taskId, inst.getInstId(), "withdraw", remark, actionUserId, task.getBizType(), task.getBizId());
Long operatorUserId = actionUserId != null ? actionUserId : LoginHelper.getUserId();
saveAction(taskId, inst.getInstId(), task.getBizType(), task.getBizId(), task.getAssigneeUserId(), "withdraw", remark, operatorUserId);
task.setStatus("withdraw");
baseMapper.updateById(task);
// 无模板一次性审批:撤回后业务回到 pending并重新生成一个待办仍然只允许一次审批
@@ -360,13 +364,13 @@ private void fillBizData(List<HrmFlowTaskVo> tasks) {
return true;
}
private void saveAction(Long taskId, Long instId, String action, String remark, Long userId, String bizType, Long bizId) {
private void saveAction(Long taskId, Long instId, String bizType, Long bizId, Long assigneeUserId, String action, String remark, Long actionUserId) {
HrmFlowAction log = new HrmFlowAction();
log.setTaskId(taskId);
log.setInstId(instId);
log.setAction(action);
log.setRemark(remark);
log.setActionUserId(userId);
log.setActionUserId(actionUserId);
log.setCreateTime(new Date());
log.setBizType(bizType);
log.setBizId(bizId);
@@ -388,7 +392,8 @@ private void fillBizData(List<HrmFlowTaskVo> tasks) {
return false;
}
// 记录动作
saveAction(taskId, inst.getInstId(), "transfer", remark, actionUserId, task.getBizType(), task.getBizId());
Long operatorUserId = actionUserId != null ? actionUserId : LoginHelper.getUserId();
saveAction(taskId, inst.getInstId(), task.getBizType(), task.getBizId(), newAssigneeUserId, "transfer", remark, operatorUserId);
// 更新办理人
HrmFlowTask u = new HrmFlowTask();
@@ -399,7 +404,6 @@ private void fillBizData(List<HrmFlowTaskVo> tasks) {
@Override
public HrmFlowTaskVo queryTodoByBiz(String bizType, Long bizId, Long assigneeUserId) {
// 只取"待办 pending"的一条(理论上同一 biz 同一时刻最多一条待办)
LambdaQueryWrapper<HrmFlowTask> lqw = Wrappers.<HrmFlowTask>lambdaQuery()
.eq(bizType != null, HrmFlowTask::getBizType, bizType)
.eq(bizId != null, HrmFlowTask::getBizId, bizId)
@@ -408,12 +412,118 @@ private void fillBizData(List<HrmFlowTaskVo> tasks) {
.orderByDesc(HrmFlowTask::getTaskId)
.last("limit 1");
HrmFlowTaskVo hrmFlowTaskVo = baseMapper.selectVoOne(lqw);
if (hrmFlowTaskVo != null) {
if (hrmFlowTaskVo != null && hrmFlowTaskVo.getAssigneeUserId() != null) {
hrmFlowTaskVo.setAssigneeNickName(userService.selectNickNameById(hrmFlowTaskVo.getAssigneeUserId()));
}
return hrmFlowTaskVo;
}
@Override
public HrmFlowTaskDetailVo queryDetailByBiz(String bizType, Long bizId, Long assigneeUserId) {
HrmFlowTaskDetailVo result = new HrmFlowTaskDetailVo();
HrmFlowTaskVo currentTask = queryTodoByBiz(bizType, bizId, assigneeUserId);
result.setCurrentTask(currentTask);
LambdaQueryWrapper<HrmFlowTask> historyQ = Wrappers.<HrmFlowTask>lambdaQuery()
.eq(bizType != null, HrmFlowTask::getBizType, bizType)
.eq(bizId != null, HrmFlowTask::getBizId, bizId)
.orderByAsc(HrmFlowTask::getCreateTime);
List<HrmFlowTaskVo> histories = baseMapper.selectVoList(historyQ);
if (histories != null) {
histories.forEach(task -> {
if (task.getAssigneeUserId() != null) {
task.setAssigneeNickName(userService.selectNickNameById(task.getAssigneeUserId()));
}
});
}
result.setTaskHistory(histories == null ? Collections.emptyList() : histories);
HrmFlowInstance inst = instanceMapper.selectOne(Wrappers.<HrmFlowInstance>lambdaQuery()
.eq(bizType != null, HrmFlowInstance::getBizType, bizType)
.eq(bizId != null, HrmFlowInstance::getBizId, bizId)
.orderByDesc(HrmFlowInstance::getInstId)
.last("limit 1"));
if (inst != null) {
result.setFlowStatus(inst.getStatus());
result.setCurrentNodeId(inst.getCurrentNodeId());
HrmFlowNode node = inst.getCurrentNodeId() == null ? null : nodeMapper.selectById(inst.getCurrentNodeId());
if (node != null) {
result.setCurrentNodeName(node.getRemark());
}
result.setApproved(Boolean.valueOf("approved".equalsIgnoreCase(inst.getStatus())));
}
result.setActionTimeline(buildActionTimeline(bizType, bizId));
return result;
}
private List<HrmFlowActionTimelineVo> buildActionTimeline(String bizType, Long bizId) {
LambdaQueryWrapper<HrmFlowAction> actionQ = Wrappers.<HrmFlowAction>lambdaQuery()
.eq(bizType != null, HrmFlowAction::getBizType, bizType)
.eq(bizId != null, HrmFlowAction::getBizId, bizId)
.orderByAsc(HrmFlowAction::getCreateTime);
List<HrmFlowAction> actions = actionMapper.selectList(actionQ);
if (actions == null || actions.isEmpty()) {
return Collections.emptyList();
}
Map<Long, HrmFlowTask> taskMap = new HashMap<>();
List<Long> taskIds = actions.stream().map(HrmFlowAction::getTaskId).filter(Objects::nonNull).distinct().collect(Collectors.toList());
if (!taskIds.isEmpty()) {
baseMapper.selectBatchIds(taskIds).forEach(task -> taskMap.put(task.getTaskId(), task));
}
List<HrmFlowActionTimelineVo> timelines = new ArrayList<HrmFlowActionTimelineVo>();
for (HrmFlowAction action : actions) {
HrmFlowActionTimelineVo vo = new HrmFlowActionTimelineVo();
vo.setActionId(action.getActionId());
vo.setTaskId(action.getTaskId());
vo.setInstId(action.getInstId());
vo.setActionUserId(action.getActionUserId());
vo.setActionUserName(action.getActionUserId() == null ? null : userService.selectNickNameById(action.getActionUserId()));
vo.setAction(action.getAction());
vo.setActionText(actionText(action.getAction()));
vo.setRemark(action.getRemark());
vo.setBizType(action.getBizType());
vo.setBizId(action.getBizId());
HrmFlowTask task = taskMap.get(action.getTaskId());
if (task != null) {
vo.setNodeId(task.getNodeId());
vo.setTaskStatus(task.getStatus());
HrmFlowNode node = task.getNodeId() == null ? null : nodeMapper.selectById(task.getNodeId());
if (node != null) {
vo.setNodeName(node.getRemark());
}
}
vo.setCreateTime(action.getCreateTime());
timelines.add(vo);
}
return timelines;
}
private String actionText(String action) {
if (action == null) {
return "-";
}
String lower = action.toLowerCase();
if ("approve".equals(lower)) {
return "通过";
}
if ("reject".equals(lower)) {
return "驳回";
}
if ("withdraw".equals(lower)) {
return "撤回";
}
if ("transfer".equals(lower)) {
return "转办";
}
if ("stamp".equals(lower)) {
return "盖章";
}
return action;
}
private LambdaQueryWrapper<HrmFlowTask> buildQueryWrapper(HrmFlowTaskBo bo) {
LambdaQueryWrapper<HrmFlowTask> lqw = Wrappers.lambdaQuery();
lqw.eq(bo.getTaskId() != null, HrmFlowTask::getTaskId, bo.getTaskId());