feat: 提交流程中心后端代码
build / build-push (push) Successful in 28s

Spring Boot 流程引擎服务:流程定义/实例/任务、审批人解析、
回调分发、oapi 接口及单元测试。
保留远程 .gitea/workflows/build.yml 与 docker/Dockerfile,
新增 .gitignore 排除 target/ 构建产物。
This commit is contained in:
chenxing
2026-09-15 10:42:56 +08:00
parent 0296b2b5dd
commit c1103aeb29
65 changed files with 7119 additions and 0 deletions
@@ -0,0 +1,85 @@
package com.yunhai.flowcenter.service;
import com.yunhai.flowcenter.entity.FlwAssigneeMap;
import com.yunhai.flowcenter.repository.FlwAssigneeMapRepository;
import com.yunhai.platform.apistd.BizException;
import com.yunhai.platform.utils.exception.ErrorCode;
import com.yunhai.platform.utils.model.BoaUser;
import com.yunhai.platform.openapi.client.OpenApiUserClient;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
/**
* 办理人映射管理(概览 §4.7/§六):DEPT_KEY → 办理人显式映射,成员检索经
* UserBase /oapi/user/byId 补全姓名快照(检索按 id 精确查;按名检索二期接 UserBase 模糊端点)。
*/
@Service
@RequiredArgsConstructor
public class FlowMapAdminService {
private final FlwAssigneeMapRepository mapRepository;
private final OpenApiUserClient userClient;
public List<FlwAssigneeMap> listByDept(Long schId, String deptKey) {
if (deptKey == null || deptKey.trim().isEmpty()) {
return mapRepository.findEnabledBySchId(schId);
}
return mapRepository.findBySchIdAndDeptKeyOrderByUserIdAsc(schId, deptKey.trim());
}
/** 新增/启用映射(uk: sch+dept+user;已存在则刷新姓名/状态) */
@Transactional
public FlwAssigneeMap save(Long schId, String deptKey, String deptName,
Integer userId, String userName) {
if (deptKey == null || deptKey.trim().isEmpty() || userId == null) {
throw new BizException(ErrorCode.PARAM_ERROR, "deptKey/userId 必填");
}
if (userName == null || userName.trim().isEmpty()) {
userName = fetchName(userId);
}
FlwAssigneeMap map = mapRepository.findBySchIdAndDeptKeyAndUserId(schId, deptKey.trim(), userId);
if (map == null) {
map = new FlwAssigneeMap();
map.setSchId(schId);
map.setDeptKey(deptKey.trim());
map.setUserId(userId);
}
map.setDeptName(deptName);
map.setUserName(userName);
map.setStatus(0);
return mapRepository.save(map);
}
/** 停用映射(保留历史,DEPT_KEY 解析只取 status=0) */
@Transactional
public void disable(Long schId, Long id) {
FlwAssigneeMap map = mapRepository.findById(id)
.orElseThrow(() -> new BizException(ErrorCode.PARAM_ERROR, "映射不存在:" + id));
if (!map.getSchId().equals(schId)) {
throw new BizException(ErrorCode.FORBIDDEN, "映射不属于该学校");
}
map.setStatus(1);
mapRepository.save(map);
}
/** 成员检索:按用户 id 从 UserBase 取姓名快照(管理端录入校验) */
public BoaUser lookupUser(Integer userId) {
try {
return userClient.getUserById(String.valueOf(userId));
} catch (Exception e) {
throw new BizException(ErrorCode.PARAM_ERROR, "UserBase 用户检索失败(服务不可达)");
}
}
private String fetchName(Integer userId) {
try {
BoaUser user = userClient.getUserById(String.valueOf(userId));
return user == null ? "" : (user.getName() == null ? "" : user.getName());
} catch (Exception e) {
return "";
}
}
}