Merge branch 'dev-klw' into test
* dev-klw: 清理与ztcloud中重复的代码,改为 jar 包方式引用 ztcloud # Conflicts: # zt-module-system/zt-module-system-api/src/main/java/com/zt/plat/module/system/api/sms/dto/send/SmsSendSingleToUserReqDTO.java # zt-module-system/zt-module-system-server/src/main/java/com/zt/plat/module/system/controller/admin/sms/SmsCallbackController.java # zt-module-system/zt-module-system-server/src/main/java/com/zt/plat/module/system/mq/message/sms/SmsSendMessage.java
This commit is contained in:
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,93 @@
|
||||
package com.zt.plat.module.system.framework.sms.core.client.impl;
|
||||
|
||||
import com.zt.plat.module.system.framework.sms.core.client.SmsClient;
|
||||
import com.zt.plat.module.system.framework.sms.core.client.SmsClientFactory;
|
||||
import com.zt.plat.module.system.framework.sms.core.enums.SmsChannelEnum;
|
||||
import com.zt.plat.module.system.framework.sms.core.property.SmsChannelProperties;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
|
||||
/**
|
||||
* 短信客户端工厂接口
|
||||
*
|
||||
* @author zzf
|
||||
*/
|
||||
@Validated
|
||||
@Slf4j
|
||||
public class SmsClientFactoryImpl implements SmsClientFactory {
|
||||
|
||||
/**
|
||||
* 短信客户端 Map
|
||||
* key:渠道编号,使用 {@link SmsChannelProperties#getId()}
|
||||
*/
|
||||
private final ConcurrentMap<Long, AbstractSmsClient> channelIdClients = new ConcurrentHashMap<>();
|
||||
|
||||
/**
|
||||
* 短信客户端 Map
|
||||
* key:渠道编码,使用 {@link SmsChannelProperties#getCode()} ()}
|
||||
*
|
||||
* 注意,一些场景下,需要获得某个渠道类型的客户端,所以需要使用它。
|
||||
* 例如说,解析短信接收结果,是相对通用的,不需要使用某个渠道编号的 {@link #channelIdClients}
|
||||
*/
|
||||
private final ConcurrentMap<String, AbstractSmsClient> channelCodeClients = new ConcurrentHashMap<>();
|
||||
|
||||
public SmsClientFactoryImpl() {
|
||||
// 初始化 channelCodeClients 集合
|
||||
Arrays.stream(SmsChannelEnum.values()).forEach(channel -> {
|
||||
// 创建一个空的 SmsChannelProperties 对象
|
||||
SmsChannelProperties properties = new SmsChannelProperties().setCode(channel.getCode())
|
||||
.setApiKey("default default").setApiSecret("default");
|
||||
// 创建 Sms 客户端
|
||||
AbstractSmsClient smsClient = createSmsClient(properties);
|
||||
channelCodeClients.put(channel.getCode(), smsClient);
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public SmsClient getSmsClient(Long channelId) {
|
||||
return channelIdClients.get(channelId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SmsClient getSmsClient(String channelCode) {
|
||||
return channelCodeClients.get(channelCode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SmsClient createOrUpdateSmsClient(SmsChannelProperties properties) {
|
||||
AbstractSmsClient client = channelIdClients.get(properties.getId());
|
||||
if (client == null) {
|
||||
client = this.createSmsClient(properties);
|
||||
client.init();
|
||||
channelIdClients.put(client.getId(), client);
|
||||
} else {
|
||||
client.refresh(properties);
|
||||
}
|
||||
return client;
|
||||
}
|
||||
|
||||
private AbstractSmsClient createSmsClient(SmsChannelProperties properties) {
|
||||
SmsChannelEnum channelEnum = SmsChannelEnum.getByCode(properties.getCode());
|
||||
Assert.notNull(channelEnum, String.format("渠道类型(%s) 为空", channelEnum));
|
||||
// 创建客户端
|
||||
switch (channelEnum) {
|
||||
case ALIYUN: return new AliyunSmsClient(properties);
|
||||
case DEBUG_DING_TALK: return new DebugDingTalkSmsClient(properties);
|
||||
case TENCENT: return new TencentSmsClient(properties);
|
||||
case HUAWEI: return new HuaweiSmsClient(properties);
|
||||
case QINIU: return new QiniuSmsClient(properties);
|
||||
// case CMCC_MAS: return new CmccMasSmsClient(properties);
|
||||
case HL95: return new Hl95SmsClient(properties);
|
||||
case ZLE: return new ZleSmsClient(properties);
|
||||
}
|
||||
// 创建失败,错误日志 + 抛出异常
|
||||
log.error("[createSmsClient][配置({}) 找不到合适的客户端实现]", properties);
|
||||
throw new IllegalArgumentException(String.format("配置(%s) 找不到合适的客户端实现", properties));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package com.zt.plat.module.system.framework.sms.core.enums;
|
||||
|
||||
import cn.hutool.core.util.ArrayUtil;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 短信渠道枚举
|
||||
*
|
||||
* @author zzf
|
||||
* @since 2021/1/25 10:56
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum SmsChannelEnum {
|
||||
|
||||
DEBUG_DING_TALK("DEBUG_DING_TALK", "调试(钉钉)"),
|
||||
ALIYUN("ALIYUN", "阿里云"),
|
||||
TENCENT("TENCENT", "腾讯云"),
|
||||
HUAWEI("HUAWEI", "华为云"),
|
||||
QINIU("QINIU", "七牛云"),
|
||||
HL95("HL95", "鸿联九五"),
|
||||
// CMCC_MAS("CMCC_MAS", "中国移动云MAS"),
|
||||
ZLE("ZLE", "中铝e办"),
|
||||
;
|
||||
|
||||
/**
|
||||
* 编码
|
||||
*/
|
||||
private final String code;
|
||||
/**
|
||||
* 名字
|
||||
*/
|
||||
private final String name;
|
||||
|
||||
public static SmsChannelEnum getByCode(String code) {
|
||||
return ArrayUtil.firstMatch(o -> o.getCode().equals(code), values());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
package com.zt.plat.module.system.job.sync;
|
||||
|
||||
import com.xxl.job.core.handler.annotation.XxlJob;
|
||||
import com.zt.plat.framework.tenant.core.job.TenantJob;
|
||||
import com.zt.plat.module.system.service.sync.SyncIWorkOrgChangeService;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* 用于定时同步 iWork 当日变更的组织数据
|
||||
* 同步时间:每日23:00
|
||||
*/
|
||||
@Component
|
||||
@Slf4j
|
||||
public class SyncIWorkOrgChangeJob {
|
||||
|
||||
@Resource
|
||||
private SyncIWorkOrgChangeService syncIWorkOrgChangeService;
|
||||
|
||||
/**
|
||||
* 执行定时任务
|
||||
* 配置执行频率:每日23:00时执行一次
|
||||
* cron表达式:0 0 23 * * ?
|
||||
*/
|
||||
@XxlJob("syncIWorkOrgChangeJob")
|
||||
@TenantJob
|
||||
public void execute() {
|
||||
log.info("[syncIWorkOrgChangeJob][开始执行同步 iWork 当日变更组织任务]");
|
||||
try {
|
||||
int processedCount = syncIWorkOrgChangeService.process();
|
||||
if (processedCount > 0) {
|
||||
log.info("[syncIWorkOrgChangeJob][同步任务执行完成,处理了 {} 条记录]", processedCount);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("[syncIWorkOrgChangeJob][同步任务执行失败]", e);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
package com.zt.plat.module.system.service.portal;
|
||||
|
||||
import com.zt.plat.framework.common.pojo.PageResult;
|
||||
import com.zt.plat.module.system.controller.admin.portal.vo.PortalPageReqVO;
|
||||
import com.zt.plat.module.system.controller.admin.portal.vo.PortalSaveReqVO;
|
||||
import com.zt.plat.module.system.dal.dataobject.portal.PortalDO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 门户网站 Service 接口
|
||||
*
|
||||
* @author 中铜数字供应链平台
|
||||
*/
|
||||
public interface PortalService {
|
||||
|
||||
/**
|
||||
* 创建门户
|
||||
*
|
||||
* @param createReqVO 创建信息
|
||||
* @return 编号
|
||||
*/
|
||||
Long createPortal(PortalSaveReqVO createReqVO);
|
||||
|
||||
/**
|
||||
* 更新门户
|
||||
*
|
||||
* @param updateReqVO 更新信息
|
||||
*/
|
||||
void updatePortal(PortalSaveReqVO updateReqVO);
|
||||
|
||||
/**
|
||||
* 删除门户
|
||||
*
|
||||
* @param id 编号
|
||||
*/
|
||||
void deletePortal(Long id);
|
||||
|
||||
/**
|
||||
* 获得门户
|
||||
*
|
||||
* @param id 编号
|
||||
* @return 门户
|
||||
*/
|
||||
PortalDO getPortal(Long id);
|
||||
|
||||
/**
|
||||
* 获得门户分页
|
||||
*
|
||||
* @param pageReqVO 分页查询
|
||||
* @return 门户分页
|
||||
*/
|
||||
PageResult<PortalDO> getPortalPage(PortalPageReqVO pageReqVO);
|
||||
|
||||
/**
|
||||
* 获得用户有权限访问的门户列表
|
||||
*
|
||||
* @param userId 用户ID
|
||||
* @return 门户列表
|
||||
*/
|
||||
List<PortalDO> getPortalListByUserId(Long userId);
|
||||
|
||||
/**
|
||||
* 获得公开门户列表(无需登录)
|
||||
*
|
||||
* @return 门户列表
|
||||
*/
|
||||
List<PortalDO> getPublicPortalList();
|
||||
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,13 @@
|
||||
package com.zt.plat.module.system.service.sync;
|
||||
|
||||
/**
|
||||
* 定时同步 iWork 组织变更服务
|
||||
*/
|
||||
public interface SyncIWorkOrgChangeService {
|
||||
|
||||
/**
|
||||
* 执行同步
|
||||
* @return 拉取记录数量
|
||||
*/
|
||||
int process();
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package com.zt.plat.module.system.service.sync;
|
||||
|
||||
import com.zt.plat.module.system.controller.admin.integration.iwork.vo.IWorkFullSyncReqVO;
|
||||
import com.zt.plat.module.system.controller.admin.integration.iwork.vo.IWorkFullSyncRespVO;
|
||||
import com.zt.plat.module.system.service.integration.iwork.IWorkSyncService;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.ZoneId;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
|
||||
@Service
|
||||
public class SyncIWorkOrgChangeServiceImpl implements SyncIWorkOrgChangeService {
|
||||
|
||||
@Resource
|
||||
private IWorkSyncService iWorkSyncService;
|
||||
|
||||
@Override
|
||||
public int process() {
|
||||
IWorkFullSyncReqVO reqVO = new IWorkFullSyncReqVO();
|
||||
reqVO.setPageSize(10);
|
||||
ZoneId zone = ZoneId.of("Asia/Shanghai");
|
||||
String startOfToday = LocalDate.now(zone)
|
||||
.atStartOfDay(zone)
|
||||
.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
|
||||
reqVO.setModified(startOfToday);
|
||||
IWorkFullSyncRespVO subcompanyResp = iWorkSyncService.fullSyncSubcompanies(reqVO);
|
||||
IWorkFullSyncRespVO departmentResp = iWorkSyncService.fullSyncDepartments(reqVO);
|
||||
return countPulled(subcompanyResp) + countPulled(departmentResp);
|
||||
}
|
||||
|
||||
private int countPulled(IWorkFullSyncRespVO respVO) {
|
||||
if (respVO == null || respVO.getBatches() == null) {
|
||||
return 0;
|
||||
}
|
||||
return respVO.getBatches().stream()
|
||||
.mapToInt(batch -> batch.getPulled() == null ? 0 : batch.getPulled())
|
||||
.sum();
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user