Merge remote-tracking branch 'ztcloud/test' into dev

This commit is contained in:
yangchaojin
2026-01-21 17:33:45 +08:00
20 changed files with 1218 additions and 7 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -59,13 +59,15 @@ public class BusinessDeptHandleUtil {
} }
// 如果有 deptId校验其是否属于该 companyId // 如果有 deptId校验其是否属于该 companyId
if (deptIdHeader != null) { if (deptIdHeader != null) {
boolean valid = companyDeptSetByCompanyId.stream().anyMatch(info -> String.valueOf(info.getDeptId()).equals(deptIdHeader)); Optional<CompanyDeptInfo> matched = companyDeptSetByCompanyId.stream()
if (!valid) { .filter(info -> String.valueOf(info.getDeptId()).equals(deptIdHeader))
.findFirst();
if (matched.isEmpty()) {
return null; return null;
} else {
// 部门存在,放行
return new HashSet<>();
} }
// 部门存在,先设置登录信息再放行
applyAutoSelection(currentLoginUser, request, matched.get());
return Collections.emptySet();
} }
if (companyDeptSetByCompanyId.size() == 1) { if (companyDeptSetByCompanyId.size() == 1) {
CompanyDeptInfo singleCompanyDept = companyDeptSetByCompanyId.iterator().next(); CompanyDeptInfo singleCompanyDept = companyDeptSetByCompanyId.iterator().next();
@@ -183,10 +185,10 @@ public class BusinessDeptHandleUtil {
if (loginUser != null) { if (loginUser != null) {
loginUser.setVisitCompanyId(Long.valueOf(info.getCompanyId())); loginUser.setVisitCompanyId(Long.valueOf(info.getCompanyId()));
loginUser.setVisitCompanyName(info.getCompanyName()); loginUser.setVisitCompanyName(info.getCompanyName());
loginUser.setVisitCompanyCode(info.getCompanyName()); loginUser.setVisitCompanyCode(info.getCompanyCode());
loginUser.setVisitDeptId(Long.valueOf(info.getDeptId())); loginUser.setVisitDeptId(Long.valueOf(info.getDeptId()));
loginUser.setVisitDeptName(info.getDeptName()); loginUser.setVisitDeptName(info.getDeptName());
loginUser.setVisitDeptCode(info.getDeptName()); loginUser.setVisitDeptCode(info.getDeptCode());
} }
request.setAttribute(WebFrameworkUtils.HEADER_VISIT_COMPANY_ID, info.getCompanyId()); request.setAttribute(WebFrameworkUtils.HEADER_VISIT_COMPANY_ID, info.getCompanyId());
if (info.getCompanyName() != null) { if (info.getCompanyName() != null) {

View File

@@ -0,0 +1,39 @@
package com.zt.plat.module.system.api.push;
import com.zt.plat.framework.common.pojo.CommonResult;
import com.zt.plat.module.system.enums.ApiConstants;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
/**
* 外部系统推送配置 Feign API
*
* @author ZT Cloud
*/
@FeignClient(name = ApiConstants.NAME)
@Tag(name = "RPC 服务 - 外部系统推送配置")
public interface ExternalPushConfigApi {
String PREFIX = ApiConstants.PREFIX + "/external-push-config";
/**
* 判断是否允许推送到外部系统
*
* @param companyId 公司编号(可选,为 null 时表示不限制公司)
* @param deptId 部门编号(可选,为 null 时只按公司配置判断)
* @param businessType 业务类型可选PURCHASE/SALE/PRODUCTION为 null 时表示所有业务类型)
* @param externalSystem 外部系统标识可选ERP/IWORK/等,为 null 时表示所有外部系统)
* @return 是否允许推送true=允许false=禁止,默认 true
*/
@GetMapping(PREFIX + "/is-push-enabled")
@Operation(summary = "判断是否允许推送到外部系统")
CommonResult<Boolean> isPushEnabled(
@RequestParam(value = "companyId", required = false) @Parameter(description = "公司编号") Long companyId,
@RequestParam(value = "deptId", required = false) @Parameter(description = "部门编号") Long deptId,
@RequestParam(value = "businessType", required = false) @Parameter(description = "业务类型") String businessType,
@RequestParam(value = "externalSystem", required = false) @Parameter(description = "外部系统标识") String externalSystem);
}

View File

@@ -230,4 +230,11 @@ public interface ErrorCodeConstants {
// ========== 门户网站 1-002-033-000 ========== // ========== 门户网站 1-002-033-000 ==========
ErrorCode PORTAL_NOT_EXISTS = new ErrorCode(1_002_033_000, "门户不存在"); ErrorCode PORTAL_NOT_EXISTS = new ErrorCode(1_002_033_000, "门户不存在");
// ========== 外部系统推送配置 1_002_034_000 ==========
ErrorCode EXTERNAL_PUSH_CONFIG_NOT_EXISTS = new ErrorCode(1_002_034_001, "外部系统推送配置不存在");
ErrorCode EXTERNAL_PUSH_CONFIG_EXISTS = new ErrorCode(1_002_034_002, "该配置已存在");
ErrorCode EXTERNAL_PUSH_CONFIG_COMPANY_INVALID = new ErrorCode(1_002_034_003, "公司编号必须是公司节点is_company=1");
ErrorCode EXTERNAL_PUSH_CONFIG_DEPT_INVALID = new ErrorCode(1_002_034_004, "部门编号必须是部门节点is_company=0");
ErrorCode EXTERNAL_PUSH_CONFIG_BUSINESS_TYPE_INVALID = new ErrorCode(1_002_034_005, "业务类型无效,仅支持 PURCHASE/SALE/PRODUCTION");
} }

View File

@@ -0,0 +1,70 @@
package com.zt.plat.module.system.enums.push;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
* 业务类型枚举
*
* @author ZT Cloud
*/
@AllArgsConstructor
@Getter
public enum BusinessTypeEnum {
PURCHASE(1, "PURCHASE", "采购"),
SALE(2, "SALE", "销售"),
PRODUCTION(3, "PRODUCTION", "生产");
/**
* 类型
*/
private final Integer type;
/**
* 编码
*/
private final String code;
/**
* 名称
*/
private final String name;
/**
* 根据编码获取枚举
*/
public static BusinessTypeEnum valueOfCode(String code) {
if (code == null) {
return null;
}
for (BusinessTypeEnum value : BusinessTypeEnum.values()) {
if (value.getCode().equals(code)) {
return value;
}
}
return null;
}
/**
* 根据类型获取枚举
*/
public static BusinessTypeEnum valueOfType(Integer type) {
if (type == null) {
return null;
}
for (BusinessTypeEnum value : BusinessTypeEnum.values()) {
if (value.getType().equals(type)) {
return value;
}
}
return null;
}
/**
* 验证编码是否有效
*/
public static boolean isValidCode(String code) {
return valueOfCode(code) != null;
}
}

View File

@@ -0,0 +1,28 @@
package com.zt.plat.module.system.api.push;
import com.zt.plat.framework.common.pojo.CommonResult;
import com.zt.plat.module.system.service.push.ExternalPushConfigService;
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;
/**
* 外部系统推送配置 Feign API 实现类
*
* @author ZT Cloud
*/
@RestController
@Validated
public class ExternalPushConfigApiImpl implements ExternalPushConfigApi {
@Resource
private ExternalPushConfigService externalPushConfigService;
@Override
public CommonResult<Boolean> isPushEnabled(Long companyId, Long deptId, String businessType, String externalSystem) {
Boolean result = externalPushConfigService.isPushEnabled(companyId, deptId, businessType, externalSystem);
return success(result);
}
}

View File

@@ -1,5 +1,6 @@
package com.zt.plat.module.system.controller.admin.integration.iwork.vo; package com.zt.plat.module.system.controller.admin.integration.iwork.vo;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.zt.plat.module.system.enums.integration.IWorkSyncEntityTypeEnum; import com.zt.plat.module.system.enums.integration.IWorkSyncEntityTypeEnum;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.Max; import jakarta.validation.constraints.Max;
@@ -42,6 +43,66 @@ public class IWorkFullSyncReqVO {
@Schema(description = "是否允许更新已存在的本地实体", example = "false") @Schema(description = "是否允许更新已存在的本地实体", example = "false")
private Boolean allowUpdate = Boolean.FALSE; private Boolean allowUpdate = Boolean.FALSE;
@JsonProperty("departmentcode")
@Schema(description = "部门编号")
private String departmentCode;
@JsonProperty("departmentname")
@Schema(description = "部门名称")
private String departmentName;
@JsonProperty("subcompanycode")
@Schema(description = "分部编号")
private String subcompanyCode;
@JsonProperty("subcompanyname")
@Schema(description = "分部名称")
private String subcompanyName;
@JsonProperty("subcompanyid1")
@Schema(description = "分部 ID")
private String subcompanyId1;
@JsonProperty("jobtitlename")
@Schema(description = "岗位名称")
private String jobTitleName;
@JsonProperty("workcode")
@Schema(description = "人员编号")
private String workCode;
@JsonProperty("loginid")
@Schema(description = "登录名")
private String loginId;
@JsonProperty("created")
@Schema(description = "创建时间戳(>=")
private String created;
@JsonProperty("modified")
@Schema(description = "修改时间戳(>=")
private String modified;
@JsonProperty("canceled")
@Schema(description = "封存标志默认查询非封存数据。1:封存")
private String canceled;
@JsonProperty("custom_data")
@Schema(description = "自定义字段列表(逗号分隔)")
private String customData;
@JsonProperty("base_custom_data")
@Schema(description = "基本信息自定义字段列表(逗号分隔)")
private String baseCustomData;
@JsonProperty("person_custom_data")
@Schema(description = "个人信息自定义字段列表(逗号分隔)")
private String personCustomData;
@JsonProperty("work_custom_data")
@Schema(description = "工作信息自定义字段列表(逗号分隔)")
private String workCustomData;
public Set<IWorkSyncEntityTypeEnum> resolveScopes() { public Set<IWorkSyncEntityTypeEnum> resolveScopes() {
EnumSet<IWorkSyncEntityTypeEnum> defaults = EnumSet.allOf(IWorkSyncEntityTypeEnum.class); EnumSet<IWorkSyncEntityTypeEnum> defaults = EnumSet.allOf(IWorkSyncEntityTypeEnum.class);
if (scopes == null || scopes.isEmpty()) { if (scopes == null || scopes.isEmpty()) {

View File

@@ -0,0 +1,22 @@
package com.zt.plat.module.system.controller.admin.push.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Schema(description = "管理后台 - 业务类型 Response VO")
@Data
@NoArgsConstructor
@AllArgsConstructor
public class BusinessTypeRespVO {
@Schema(description = "类型", example = "1")
private Integer type;
@Schema(description = "编码", example = "PURCHASE")
private String code;
@Schema(description = "名称", example = "采购")
private String name;
}

View File

@@ -0,0 +1,33 @@
package com.zt.plat.module.system.controller.admin.push.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import lombok.Data;
@Schema(description = "管理后台 - 外部系统推送配置基础信息")
@Data
public class ExternalPushConfigBaseVO {
@Schema(description = "公司编号(为空表示不限制公司)", example = "1024")
private Long companyId;
@Schema(description = "部门编号(为空表示公司级配置)", example = "2048")
private Long deptId;
@Schema(description = "业务类型(为空表示所有业务类型)", example = "PURCHASE")
@Size(max = 32, message = "业务类型长度不能超过 32 个字符")
private String businessType;
@Schema(description = "外部系统标识(为空表示所有外部系统)", example = "ERP")
@Size(max = 64, message = "外部系统标识长度不能超过 64 个字符")
private String externalSystem;
@Schema(description = "是否启用推送", requiredMode = Schema.RequiredMode.REQUIRED, example = "true")
@NotNull(message = "推送开关不能为空")
private Boolean enablePush;
@Schema(description = "备注", example = "ERP 采购单推送配置")
@Size(max = 512, message = "备注长度不能超过 512 个字符")
private String remark;
}

Some files were not shown because too many files have changed in this diff Show More