1. 修复自定义 sql 中大写表名无法匹配到 mybatis 中的缓存表信息,导致表被忽略租户的问题

2. 新增 iwork feign api 调用
This commit is contained in:
chenbowen
2025-11-28 11:05:09 +08:00
parent 03ebe21670
commit 542466270a
22 changed files with 580 additions and 30 deletions

View File

@@ -0,0 +1,111 @@
package com.zt.plat.module.system.api.iwork;
import com.zt.plat.framework.common.pojo.CommonResult;
import com.zt.plat.framework.common.util.object.BeanUtils;
import com.zt.plat.module.system.api.iwork.dto.*;
import com.zt.plat.module.system.controller.admin.integration.iwork.vo.*;
import com.zt.plat.module.system.service.integration.iwork.IWorkIntegrationService;
import com.zt.plat.module.system.service.integration.iwork.IWorkOrgRestService;
import com.zt.plat.module.system.service.integration.iwork.IWorkSyncService;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RestController;
import static com.zt.plat.framework.common.pojo.CommonResult.success;
/**
* iWork 集成 Feign API 实现类。
* <p>
* 将 system-api 模块中的 DTO 与现有 Controller VO 进行简单转换,
* 再委托给 Service 层完成实际业务逻辑,供其他模块通过 Feign 统一调用。
*/
@RestController
@Validated
public class IWorkIntegrationApiImpl implements IWorkIntegrationApi {
@Resource
private IWorkIntegrationService integrationService;
@Resource
private IWorkOrgRestService orgRestService;
@Resource
private IWorkSyncService syncService;
// ----------------- 认证 / 会话 -----------------
@Override
public CommonResult<IWorkAuthRegisterRespDTO> register(IWorkAuthRegisterReqDTO reqDTO) {
IWorkAuthRegisterReqVO reqVO = BeanUtils.toBean(reqDTO, IWorkAuthRegisterReqVO.class);
IWorkAuthRegisterRespVO respVO = integrationService.registerSession(reqVO);
IWorkAuthRegisterRespDTO respDTO = BeanUtils.toBean(respVO, IWorkAuthRegisterRespDTO.class);
return success(respDTO);
}
@Override
public CommonResult<IWorkAuthTokenRespDTO> acquireToken(IWorkAuthTokenReqDTO reqDTO) {
IWorkAuthTokenReqVO reqVO = BeanUtils.toBean(reqDTO, IWorkAuthTokenReqVO.class);
IWorkAuthTokenRespVO respVO = integrationService.acquireToken(reqVO);
IWorkAuthTokenRespDTO respDTO = BeanUtils.toBean(respVO, IWorkAuthTokenRespDTO.class);
return success(respDTO);
}
// ----------------- 流程类能力 -----------------
@Override
public CommonResult<IWorkUserInfoRespDTO> resolveUser(IWorkUserInfoReqDTO reqDTO) {
IWorkUserInfoReqVO reqVO = BeanUtils.toBean(reqDTO, IWorkUserInfoReqVO.class);
IWorkUserInfoRespVO respVO = integrationService.resolveUserId(reqVO);
IWorkUserInfoRespDTO respDTO = BeanUtils.toBean(respVO, IWorkUserInfoRespDTO.class);
return success(respDTO);
}
@Override
public CommonResult<IWorkOperationRespDTO> createWorkflow(IWorkWorkflowCreateReqDTO reqDTO) {
IWorkWorkflowCreateReqVO reqVO = BeanUtils.toBean(reqDTO, IWorkWorkflowCreateReqVO.class);
IWorkOperationRespVO respVO = integrationService.createWorkflow(reqVO);
IWorkOperationRespDTO respDTO = BeanUtils.toBean(respVO, IWorkOperationRespDTO.class);
return success(respDTO);
}
@Override
public CommonResult<IWorkOperationRespDTO> voidWorkflow(IWorkWorkflowVoidReqDTO reqDTO) {
IWorkWorkflowVoidReqVO reqVO = BeanUtils.toBean(reqDTO, IWorkWorkflowVoidReqVO.class);
IWorkOperationRespVO respVO = integrationService.voidWorkflow(reqVO);
IWorkOperationRespDTO respDTO = BeanUtils.toBean(respVO, IWorkOperationRespDTO.class);
return success(respDTO);
}
// ----------------- 人力组织分页接口 -----------------
@Override
public CommonResult<IWorkHrSubcompanyPageRespDTO> listSubcompanies(IWorkOrgPageReqDTO reqDTO) {
IWorkSubcompanyQueryReqVO reqVO = BeanUtils.toBean(reqDTO, IWorkSubcompanyQueryReqVO.class);
IWorkHrSubcompanyPageRespVO respVO = orgRestService.listSubcompanies(reqVO);
IWorkHrSubcompanyPageRespDTO respDTO = BeanUtils.toBean(respVO, IWorkHrSubcompanyPageRespDTO.class);
return success(respDTO);
}
@Override
public CommonResult<IWorkHrDepartmentPageRespDTO> listDepartments(IWorkOrgPageReqDTO reqDTO) {
IWorkDepartmentQueryReqVO reqVO = BeanUtils.toBean(reqDTO, IWorkDepartmentQueryReqVO.class);
IWorkHrDepartmentPageRespVO respVO = orgRestService.listDepartments(reqVO);
IWorkHrDepartmentPageRespDTO respDTO = BeanUtils.toBean(respVO, IWorkHrDepartmentPageRespDTO.class);
return success(respDTO);
}
@Override
public CommonResult<IWorkHrJobTitlePageRespDTO> listJobTitles(IWorkOrgPageReqDTO reqDTO) {
IWorkJobTitleQueryReqVO reqVO = BeanUtils.toBean(reqDTO, IWorkJobTitleQueryReqVO.class);
IWorkHrJobTitlePageRespVO respVO = orgRestService.listJobTitles(reqVO);
IWorkHrJobTitlePageRespDTO respDTO = BeanUtils.toBean(respVO, IWorkHrJobTitlePageRespDTO.class);
return success(respDTO);
}
@Override
public CommonResult<IWorkHrUserPageRespDTO> listUsers(IWorkOrgPageReqDTO reqDTO) {
IWorkUserQueryReqVO reqVO = BeanUtils.toBean(reqDTO, IWorkUserQueryReqVO.class);
IWorkHrUserPageRespVO respVO = orgRestService.listUsers(reqVO);
IWorkHrUserPageRespDTO respDTO = BeanUtils.toBean(respVO, IWorkHrUserPageRespDTO.class);
return success(respDTO);
}
}

View File

@@ -1,15 +0,0 @@
package com.zt.plat.module.system.controller.admin.integration.iwork.vo;
import io.swagger.v3.oas.annotations.media.Schema;
/**
* @deprecated 请改用强类型的 IWorkHr*RespVO避免再引用该占位类。
*/
@Deprecated(forRemoval = true)
@Schema(description = "已废弃,占位用")
public final class IWorkOrgRespVO {
private IWorkOrgRespVO() {
throw new UnsupportedOperationException("Use IWorkHr*RespVO instead");
}
}

View File

@@ -34,13 +34,13 @@ public class IWorkWorkflowCreateReqVO extends IWorkBaseReqVO {
@Schema(description = "用印材料附件 URL必填")
private String xyywjUrl;
@Schema(description = "用印材料附件文件名(必填)")
private String xyywjFileName;
@Schema(description = "用印事项")
private String yysx;
@Schema(description = "业务系统单据编号(用于派生流程标题)", example = "DJ-2025-0001")
private String ywxtdjbh;
@Schema(description = "流程模板编号(必填)", example = "54")
private String workflowId;
}

View File

@@ -34,11 +34,6 @@ public class IWorkProperties {
*/
private String clientPublicKey;
/**
* 当调用方未指定流程编号时使用的默认流程模板编号。
*/
private Long workflowId;
/**
* 当请求未指定操作人时使用的默认用户编号。
*/
@@ -53,6 +48,8 @@ public class IWorkProperties {
private final Client client = new Client();
@Valid
private final OrgRest org = new OrgRest();
@Valid
private final Workflow workflow = new Workflow();
@Data
public static class Paths {
@@ -142,4 +139,13 @@ public class IWorkProperties {
private String syncJobTitle;
private String syncUser;
}
@Data
public static class Workflow {
/**
* 用印流程对应的 iWork 模板编号。
*/
@NotBlank(message = "iWork 用印流程模板编号不能为空")
private String sealWorkflowId;
}
}

View File

@@ -416,7 +416,8 @@ public class IWorkIntegrationServiceImpl implements IWorkIntegrationService {
addField(main, "yyqx", fields.yyqx());
addField(main, "yyfk", fields.yyfkUrl());
addField(main, "yysy", fields.yysy());
addField(main, "xyywj", fields.xyywjUrl());
// xyywj 需要是一个数组结构 [{fileName,filePath}, ...]
addJsonField(main, "xyywj", buildSealAttachmentValue(fields.xyywjUrl()));
addField(main, "yysx", fields.yysx());
addField(main, "lclx", SealRequestFields.DEFAULT_FLOW_TYPE);
addField(main, "qsdz", SealRequestFields.DEFAULT_SIGN_ACTION);
@@ -434,6 +435,49 @@ public class IWorkIntegrationServiceImpl implements IWorkIntegrationService {
target.add(map);
}
private void addJsonField(List<Map<String, Object>> target, String name, Object value) {
if (value == null) {
return;
}
Map<String, Object> map = new HashMap<>(2);
map.put("fieldName", name);
map.put("fieldValue", value);
target.add(map);
}
/**
* 将单个附件 URL 封装成 iWork 需要的数组结构:
* [ {"fileName": "xxx", "filePath": "url"} ]
*/
private List<Map<String, Object>> buildSealAttachmentValue(String xyywjUrl) {
String url = trimToNull(xyywjUrl);
if (url == null) {
return null;
}
Map<String, Object> file = new LinkedHashMap<>(2);
// 这里简单从 URL 截取文件名,调用方也可以直接传入已经带文件名的 URL
String fileName = extractFileNameFromUrl(url);
file.put("fileName", fileName);
file.put("filePath", url);
List<Map<String, Object>> list = new ArrayList<>(1);
list.add(file);
return list;
}
private String extractFileNameFromUrl(String url) {
String trimmed = trimToNull(url);
if (trimmed == null) {
return null;
}
int queryIndex = trimmed.indexOf('?');
String pathPart = queryIndex >= 0 ? trimmed.substring(0, queryIndex) : trimmed;
int slashIndex = pathPart.lastIndexOf('/');
if (slashIndex >= 0 && slashIndex < pathPart.length() - 1) {
return pathPart.substring(slashIndex + 1);
}
return pathPart;
}
private SealRequestFields resolveSealFields(IWorkWorkflowCreateReqVO reqVO) {
String jbr = requireSealField(reqVO.getJbr(), "jbr");
String yybm = requireSealField(reqVO.getYybm(), "yybm");
@@ -443,9 +487,9 @@ public class IWorkIntegrationServiceImpl implements IWorkIntegrationService {
String xyywjUrl = requireSealField(reqVO.getXyywjUrl(), "xyywjUrl");
String yysx = requireSealField(reqVO.getYysx(), "yysx");
String billNo = requireSealField(reqVO.getYwxtdjbh(), "ywxtdjbh");
String workflowId = requireSealField(reqVO.getWorkflowId(), "workflowId");
String yyfkUrl = trimToNull(reqVO.getYyfkUrl());
String yysy = trimToNull(reqVO.getYysy());
String workflowId = requireSealField(properties.getWorkflow().getSealWorkflowId(), "workflowId");
return new SealRequestFields(jbr, yybm, fb, sqsj, yyqx, yyfkUrl, yysy, xyywjUrl, yysx, billNo, workflowId);
}

View File

@@ -110,7 +110,6 @@ iwork:
# app-id: f47ac10b-58cc-4372-a567-0e02b2c3d479
app-id: f47ac10b-58cc-4372-a567-0e02b2c3d479
user-id: 9869
workflow-id: 1753
paths:
register: /api/ec/dev/auth/regist
apply-token: /api/ec/dev/auth/applytoken
@@ -134,6 +133,8 @@ iwork:
sync-department: /api/hrm/resful/synDepartment
sync-job-title: /api/hrm/resful/synJobtitle
sync-user: /api/hrm/resful/synHrmresource
workflow:
seal-workflow-id: "1753"
--- #################### RPC 远程调用相关配置 ####################