Commit c752417d466d9e467890c4f5b0dca903c5c02b97
1 parent
fc32b320
feat(*): 优化项目
- 优化项目
Showing
25 changed files
with
268 additions
and
382 deletions
fw-hermes-common/src/main/java/cn/fw/hermes/common/utils/RobotHelper.java deleted
1 | -package cn.fw.hermes.common.utils; | |
2 | - | |
3 | -import cn.hutool.http.HttpRequest; | |
4 | -import cn.hutool.http.HttpUtil; | |
5 | -import cn.hutool.json.JSONUtil; | |
6 | -import org.apache.commons.codec.binary.Base64; | |
7 | - | |
8 | -import javax.crypto.Mac; | |
9 | -import javax.crypto.spec.SecretKeySpec; | |
10 | -import java.net.URLEncoder; | |
11 | -import java.nio.charset.StandardCharsets; | |
12 | -import java.util.Date; | |
13 | -import java.util.HashMap; | |
14 | -import java.util.Map; | |
15 | - | |
16 | -/** | |
17 | - * 机器人工具 | |
18 | - * | |
19 | - * @author : kurisu | |
20 | - * @version : 2.0 | |
21 | - * @desc : 机器人工具 | |
22 | - * @date : 2023-09-08 14:40 | |
23 | - */ | |
24 | -public class RobotHelper { | |
25 | - private static final String DING_TALK_ROBOT_API = "https://oapi.dingtalk.com/robot/send"; | |
26 | - | |
27 | - public static String sendEarlyWarning(String accessToken, String secret) throws Exception { | |
28 | - Long timestamp = System.currentTimeMillis(); | |
29 | - String sign = createSign(timestamp, secret); | |
30 | - String url = String.format("%s?access_token=%s×tamp=%s&sign=%s", DING_TALK_ROBOT_API, accessToken, timestamp, sign); | |
31 | - | |
32 | - Map<String, String> markdown = new HashMap<>(); | |
33 | - markdown.put("title", "预警信息"); | |
34 | - markdown.put("text", "### MQTT服务断开连接 \n" + | |
35 | - " ##### 重连次数超过10次\n" + | |
36 | - " ###### " + DateUtil.getFormatString(new Date(), "MM月dd日 HH点mm分") + | |
37 | - " 发布 \n"); | |
38 | - | |
39 | - Map<String, Object> params = new HashMap<>(); | |
40 | - params.put("msgtype", "markdown"); | |
41 | - params.put("markdown", markdown); | |
42 | - HttpRequest post = HttpUtil.createPost(url); | |
43 | - post.body(JSONUtil.toJsonStr(params), "application/json"); | |
44 | - | |
45 | - return post.setConnectionTimeout(-1).execute().body(); | |
46 | - } | |
47 | - | |
48 | - public static void main(String[] args) throws Exception { | |
49 | - String res = sendEarlyWarning("31a16df234bc4b78a29c5a4cc35a7421fc90a87cc339dbb545117b6966d2ca32", "SEC509e8cd6d0c3969563acf9e33c177c49cf2a365cd60ddc841d4eb728afcd6940"); | |
50 | - System.out.println(res); | |
51 | - } | |
52 | - | |
53 | - private static String createSign(Long timestamp, String secret) throws Exception { | |
54 | - String stringToSign = timestamp + "\n" + secret; | |
55 | - Mac mac = Mac.getInstance("HmacSHA256"); | |
56 | - mac.init(new SecretKeySpec(secret.getBytes(StandardCharsets.UTF_8), "HmacSHA256")); | |
57 | - byte[] signData = mac.doFinal(stringToSign.getBytes(StandardCharsets.UTF_8)); | |
58 | - return URLEncoder.encode(new String(Base64.encodeBase64(signData)), "UTF-8"); | |
59 | - } | |
60 | -} |
fw-hermes-common/src/main/java/cn/fw/hermes/common/utils/TemplateHelper.java deleted
1 | -package cn.fw.hermes.common.utils; | |
2 | - | |
3 | -import cn.hutool.core.lang.Dict; | |
4 | -import cn.hutool.extra.template.Template; | |
5 | -import cn.hutool.extra.template.TemplateConfig; | |
6 | -import cn.hutool.extra.template.TemplateEngine; | |
7 | -import cn.hutool.extra.template.TemplateUtil; | |
8 | - | |
9 | -import java.util.Objects; | |
10 | - | |
11 | -/** | |
12 | - * 模板字符工具类 | |
13 | - * | |
14 | - * @author : kurisu | |
15 | - * @version : 2.0 | |
16 | - * @desc : 模板字符工具类 | |
17 | - * @date : 2023-06-25 16:15 | |
18 | - */ | |
19 | -public final class TemplateHelper { | |
20 | - private static volatile TemplateHelper INSTANCE; | |
21 | - private final TemplateEngine engine; | |
22 | - | |
23 | - private TemplateHelper() { | |
24 | - this.engine = TemplateUtil.createEngine(new TemplateConfig()); | |
25 | - } | |
26 | - | |
27 | - public static TemplateHelper getInstance() { | |
28 | - if (INSTANCE == null) { | |
29 | - synchronized (ThreadPoolUtil.class) { | |
30 | - if (INSTANCE == null) { | |
31 | - INSTANCE = new TemplateHelper(); | |
32 | - } | |
33 | - } | |
34 | - } | |
35 | - return INSTANCE; | |
36 | - } | |
37 | - | |
38 | - public TemplateEngine getEngine() { | |
39 | - return engine; | |
40 | - } | |
41 | - | |
42 | - /** | |
43 | - * 渲染模板 | |
44 | - * | |
45 | - * @param template 模板字符串 | |
46 | - * @param dict 字典值 | |
47 | - * @return res | |
48 | - */ | |
49 | - public String render(String template, Dict dict) { | |
50 | - try { | |
51 | - if (StringUtils.isEmpty(template) || Objects.isNull(dict)) { | |
52 | - return template; | |
53 | - } | |
54 | - Template engineTemplate = engine.getTemplate(template); | |
55 | - return engineTemplate.render(dict); | |
56 | - } catch (Exception e) { | |
57 | - return null; | |
58 | - } | |
59 | - } | |
60 | - | |
61 | - public static void main(String[] args) { | |
62 | - TemplateHelper helper = getInstance(); | |
63 | - Dict dict = Dict.create(); | |
64 | - dict.set("identifier", "b0123"); | |
65 | - dict.set("platform", "89b3f3ef"); | |
66 | - dict.set("groupId", "89"); | |
67 | - String render = helper.render("platform/${identifier}/${platform}", dict); | |
68 | - System.out.println(render); | |
69 | - } | |
70 | -} |
fw-hermes-common/src/main/java/cn/fw/hermes/common/utils/ThreadPoolUtil.java deleted
1 | -package cn.fw.hermes.common.utils; | |
2 | - | |
3 | -import cn.hutool.core.thread.ExecutorBuilder; | |
4 | -import cn.hutool.core.thread.NamedThreadFactory; | |
5 | - | |
6 | -import java.util.concurrent.ExecutorService; | |
7 | - | |
8 | -/** | |
9 | - * ThreadPoolUtil | |
10 | - * | |
11 | - * @author : kurisu | |
12 | - * @version : 2.0 | |
13 | - * @className : ThreadPoolUtil | |
14 | - * @description : ThreadPoolUtil | |
15 | - * @date : 2023-04-19 17:31 | |
16 | - */ | |
17 | -public class ThreadPoolUtil { | |
18 | - private static volatile ThreadPoolUtil INSTANCE; | |
19 | - private final ExecutorService executor; | |
20 | - | |
21 | - private ThreadPoolUtil() { | |
22 | - this.executor = ExecutorBuilder.create() | |
23 | - .setCorePoolSize(2 << 5) | |
24 | - .setMaxPoolSize(2 << 6) | |
25 | - .setThreadFactory(new NamedThreadFactory("Hermes-Custom-", false)) | |
26 | - .setAllowCoreThreadTimeOut(true) | |
27 | - .useArrayBlockingQueue(2 << 10) | |
28 | - .build(); | |
29 | - } | |
30 | - | |
31 | - public static ThreadPoolUtil getInstance() { | |
32 | - if (INSTANCE == null) { | |
33 | - synchronized (ThreadPoolUtil.class) { | |
34 | - if (INSTANCE == null) { | |
35 | - INSTANCE = new ThreadPoolUtil(); | |
36 | - } | |
37 | - } | |
38 | - } | |
39 | - return INSTANCE; | |
40 | - } | |
41 | - | |
42 | - public ExecutorService getExecutor() { | |
43 | - return executor; | |
44 | - } | |
45 | -} |
fw-hermes-common/src/main/java/cn/fw/hermes/common/utils/UUIDUtils.java deleted
1 | -package cn.fw.hermes.common.utils; | |
2 | - | |
3 | -import java.util.UUID; | |
4 | - | |
5 | - | |
6 | -public final class UUIDUtils { | |
7 | - public static String newRandomUUid(){ | |
8 | - return UUID.randomUUID().toString().replaceAll("-",""); | |
9 | - } | |
10 | - | |
11 | - public static String newStaffIdentifier(Long userId){ | |
12 | - return String.format("b0%s", userId); | |
13 | - } | |
14 | - | |
15 | - public static String newMemberIdentifier(Long userId){ | |
16 | - return String.format("c0%s", userId); | |
17 | - } | |
18 | - | |
19 | -} |
fw-hermes-common/src/main/kotlin/cn/fw/hermes/common/utils/RobotHelper.kt
0 → 100644
1 | +package cn.fw.hermes.common.utils | |
2 | + | |
3 | +import cn.hutool.http.HttpUtil | |
4 | +import cn.hutool.json.JSONUtil | |
5 | +import org.apache.commons.codec.binary.Base64 | |
6 | +import java.net.URLEncoder | |
7 | +import java.nio.charset.StandardCharsets | |
8 | +import java.util.* | |
9 | +import javax.crypto.Mac | |
10 | +import javax.crypto.spec.SecretKeySpec | |
11 | + | |
12 | +/** | |
13 | + * 机器人工具 | |
14 | + * | |
15 | + * @author : kurisu | |
16 | + * @version : 2.0 | |
17 | + * @desc : 机器人工具 | |
18 | + * @date : 2023-09-08 14:40 | |
19 | + */ | |
20 | +object RobotHelper { | |
21 | + private const val DING_TALK_ROBOT_API = "https://oapi.dingtalk.com/robot/send" | |
22 | + | |
23 | + @Throws(Exception::class) | |
24 | + fun sendEarlyWarning(accessToken: String?, secret: String?): String { | |
25 | + val timestamp = System.currentTimeMillis() | |
26 | + val sign = createSign(timestamp, secret ?: "") | |
27 | + val url = String.format("%s?access_token=%s×tamp=%s&sign=%s", DING_TALK_ROBOT_API, accessToken, timestamp, sign) | |
28 | + | |
29 | + val markdown: MutableMap<String, String> = HashMap() | |
30 | + markdown["title"] = "预警信息" | |
31 | + markdown["text"] = """### MQTT服务断开连接 | |
32 | + ##### 重连次数超过10次 | |
33 | + ###### ${DateUtil.getFormatString(Date(), "MM月dd日 HH点mm分")} 发布 | |
34 | +""" | |
35 | + | |
36 | + val params: MutableMap<String, Any> = HashMap() | |
37 | + params["msgtype"] = "markdown" | |
38 | + params["markdown"] = markdown | |
39 | + val post = HttpUtil.createPost(url) | |
40 | + post.body(JSONUtil.toJsonStr(params), "application/json") | |
41 | + | |
42 | + return post.setConnectionTimeout(-1).execute().body() | |
43 | + } | |
44 | + | |
45 | + @Throws(Exception::class) | |
46 | + private fun createSign(timestamp: Long, secret: String): String { | |
47 | + val stringToSign = """ | |
48 | + $timestamp | |
49 | + $secret | |
50 | + """.trimIndent() | |
51 | + val mac = Mac.getInstance("HmacSHA256") | |
52 | + mac.init(SecretKeySpec(secret.toByteArray(StandardCharsets.UTF_8), "HmacSHA256")) | |
53 | + val signData = mac.doFinal(stringToSign.toByteArray(StandardCharsets.UTF_8)) | |
54 | + return URLEncoder.encode(String(Base64.encodeBase64(signData)), "UTF-8") | |
55 | + } | |
56 | +} | ... | ... |
fw-hermes-common/src/main/kotlin/cn/fw/hermes/common/utils/TemplateHelper.kt
0 → 100644
1 | +package cn.fw.hermes.common.utils | |
2 | + | |
3 | +import cn.hutool.core.lang.Dict | |
4 | +import cn.hutool.extra.template.TemplateConfig | |
5 | +import cn.hutool.extra.template.TemplateEngine | |
6 | +import cn.hutool.extra.template.TemplateUtil | |
7 | +import java.util.* | |
8 | + | |
9 | +/** | |
10 | + * 模板字符工具类 | |
11 | + * | |
12 | + * @author : kurisu | |
13 | + * @version : 2.0 | |
14 | + * @desc : 模板字符工具类 | |
15 | + * @date : 2023-06-25 16:15 | |
16 | + */ | |
17 | +object TemplateHelper { | |
18 | + val engine: TemplateEngine = TemplateUtil.createEngine(TemplateConfig()) | |
19 | + | |
20 | + /** | |
21 | + * 渲染模板 | |
22 | + * | |
23 | + * @param template 模板字符串 | |
24 | + * @param dict 字典值 | |
25 | + * @return res | |
26 | + */ | |
27 | + fun render(template: String?, dict: Dict?): String? { | |
28 | + try { | |
29 | + if (StringUtils.isEmpty(template) || Objects.isNull(dict)) { | |
30 | + return template | |
31 | + } | |
32 | + val engineTemplate = engine.getTemplate(template) | |
33 | + return engineTemplate.render(dict) | |
34 | + } catch (e: Exception) { | |
35 | + return null | |
36 | + } | |
37 | + } | |
38 | +} | ... | ... |
fw-hermes-common/src/main/kotlin/cn/fw/hermes/common/utils/ThreadPoolUtil.kt
0 → 100644
1 | +package cn.fw.hermes.common.utils | |
2 | + | |
3 | +import cn.hutool.core.thread.ExecutorBuilder | |
4 | +import cn.hutool.core.thread.NamedThreadFactory | |
5 | +import java.util.concurrent.ExecutorService | |
6 | + | |
7 | +/** | |
8 | + * ThreadPoolUtil | |
9 | + * | |
10 | + * @author : kurisu | |
11 | + * @version : 2.0 | |
12 | + * @className : ThreadPoolUtil | |
13 | + * @description : ThreadPoolUtil | |
14 | + * @date : 2023-04-19 17:31 | |
15 | + */ | |
16 | +object ThreadPoolUtil { | |
17 | + val executor: ExecutorService | |
18 | + get() = ExecutorBuilder.create() | |
19 | + .setCorePoolSize(2 shl 5) | |
20 | + .setMaxPoolSize(2 shl 6) | |
21 | + .setThreadFactory(NamedThreadFactory("Hermes-Custom-", false)) | |
22 | + .setAllowCoreThreadTimeOut(true) | |
23 | + .useArrayBlockingQueue(2 shl 10) | |
24 | + .build() | |
25 | + | |
26 | +} | ... | ... |
fw-hermes-common/src/main/kotlin/cn/fw/hermes/common/utils/UUIDUtils.kt
0 → 100644
1 | +package cn.fw.hermes.common.utils | |
2 | + | |
3 | +import java.util.* | |
4 | + | |
5 | +object UUIDUtils { | |
6 | + fun newRandomUUid(): String { | |
7 | + return UUID.randomUUID().toString().replace("-".toRegex(), "") | |
8 | + } | |
9 | + | |
10 | + fun newStaffIdentifier(userId: Long?): String { | |
11 | + return String.format("b0%s", userId) | |
12 | + } | |
13 | + | |
14 | + fun newMemberIdentifier(userId: Long?): String { | |
15 | + return String.format("c0%s", userId) | |
16 | + } | |
17 | +} | ... | ... |
fw-hermes-common/src/test/java/cn/fw/hermes/common/utils/Tests.kt
0 → 100644
1 | +package cn.fw.hermes.common.utils | |
2 | + | |
3 | +import cn.hutool.core.lang.Dict | |
4 | +import org.junit.Test | |
5 | + | |
6 | +/** | |
7 | + * 测试工具 | |
8 | + * | |
9 | + * @author : kurisu | |
10 | + * @version : 1.0 | |
11 | + * @desc : 测试工具 | |
12 | + * @date : 2024-01-05 16:59 | |
13 | + */ | |
14 | +class Tests { | |
15 | + | |
16 | + @Test | |
17 | + fun testUUID() { | |
18 | + println(UUIDUtils.newRandomUUid()) | |
19 | + } | |
20 | + | |
21 | + @Test | |
22 | + fun testTemplate() { | |
23 | + val dict = Dict.create() | |
24 | + dict["identifier"] = "b0123" | |
25 | + dict["platform"] = "89b3f3ef" | |
26 | + dict["groupId"] = "89" | |
27 | + val render: String? = TemplateHelper.render("platform/\${identifier}/\${platform}", dict) | |
28 | + println(render) | |
29 | + } | |
30 | +} | ... | ... |
fw-hermes-rpc/src/main/java/cn/fw/hermes/rpc/ehr/EhrRpcService.java
... | ... | @@ -49,7 +49,7 @@ public class EhrRpcService { |
49 | 49 | return staffInfoDTO; |
50 | 50 | } |
51 | 51 | } catch (Exception e) { |
52 | - e.printStackTrace(); | |
52 | + log.error("queryStaffInfo 失败", e); | |
53 | 53 | } |
54 | 54 | return null; |
55 | 55 | } |
... | ... | @@ -74,7 +74,7 @@ public class EhrRpcService { |
74 | 74 | return staffInfoDTO; |
75 | 75 | } |
76 | 76 | } catch (Exception e) { |
77 | - e.printStackTrace(); | |
77 | + log.error("queryStaffInfoByMobile 失败", e); | |
78 | 78 | } |
79 | 79 | return null; |
80 | 80 | } | ... | ... |
fw-hermes-rpc/src/main/java/cn/fw/hermes/rpc/member/MemberRpcService.java deleted
1 | -package cn.fw.hermes.rpc.member; | |
2 | - | |
3 | -import cn.fw.common.util.MobileUtil; | |
4 | -import cn.fw.data.base.domain.common.Message; | |
5 | -import cn.fw.hermes.rpc.member.dto.MemberUserDTO; | |
6 | -import cn.fw.member.sdk.api.FunctionApi; | |
7 | -import cn.fw.member.sdk.api.MemberApi; | |
8 | -import cn.fw.member.sdk.vo.MemberInfoVo; | |
9 | -import cn.fw.member.sdk.vo.MobileLocation; | |
10 | -import lombok.extern.slf4j.Slf4j; | |
11 | -import org.apache.commons.lang3.StringUtils; | |
12 | -import org.springframework.beans.BeanUtils; | |
13 | -import org.springframework.beans.factory.annotation.Autowired; | |
14 | -import org.springframework.cache.annotation.Cacheable; | |
15 | -import org.springframework.stereotype.Service; | |
16 | - | |
17 | -import java.util.Objects; | |
18 | - | |
19 | -/** | |
20 | - * 会员服务 | |
21 | - * | |
22 | - * @author kurisu | |
23 | - */ | |
24 | -@Slf4j | |
25 | -@Service | |
26 | -public class MemberRpcService { | |
27 | - /** | |
28 | - * 会员服务 | |
29 | - */ | |
30 | - private final MemberApi memberApi; | |
31 | - private final FunctionApi functionApi; | |
32 | - | |
33 | - /** | |
34 | - * 默认构造器 | |
35 | - */ | |
36 | - @Autowired | |
37 | - public MemberRpcService(final MemberApi memberApi, | |
38 | - final FunctionApi functionApi) { | |
39 | - this.memberApi = memberApi; | |
40 | - this.functionApi = functionApi; | |
41 | - } | |
42 | - | |
43 | - /** | |
44 | - * 根据会员ID获取会员信息 | |
45 | - * | |
46 | - * @param userId 会员ID | |
47 | - * @return 会员信息 | |
48 | - */ | |
49 | - public MemberUserDTO user(final Long userId) { | |
50 | - if (userId == null) { | |
51 | - return null; | |
52 | - } | |
53 | - try { | |
54 | - final Message<MemberInfoVo> msg = memberApi.getMemberById(userId); | |
55 | - if (!msg.isSuccess()) { | |
56 | - log.warn("调用Member[根据会员ID[{}]获取会员信息]系统失败, 原因:{}", userId, msg.getResult()); | |
57 | - return null; | |
58 | - } | |
59 | - final MemberInfoVo user = msg.getData(); | |
60 | - if (user != null) { | |
61 | - final MemberUserDTO userDTO = new MemberUserDTO(); | |
62 | - BeanUtils.copyProperties(user, userDTO); | |
63 | - return userDTO; | |
64 | - } | |
65 | - } catch (Exception e) { | |
66 | - log.error("调用Member[根据会员ID[{}]获取会员信息]系统失败", userId, e); | |
67 | - } | |
68 | - return null; | |
69 | - } | |
70 | - | |
71 | - /** | |
72 | - * 查询手机号归属地 | |
73 | - * | |
74 | - * @param mobile | |
75 | - * @return | |
76 | - */ | |
77 | - @Cacheable(cacheNames = "mobile:attribution", key = "#mobile", unless = "#result.isEmpty()") | |
78 | - public String attribution(final String mobile) { | |
79 | - if (StringUtils.isBlank(mobile)) { | |
80 | - return ""; | |
81 | - } | |
82 | - try { | |
83 | - MobileUtil.Result result = MobileUtil.attribution(mobile); | |
84 | - String att = ""; | |
85 | - if (Objects.nonNull(result)) { | |
86 | - att = result.getProvince().concat(" ").concat(result.getCity()); | |
87 | - } | |
88 | - | |
89 | - if (!StringUtils.isBlank(att.trim())) { | |
90 | - return att.trim(); | |
91 | - } | |
92 | - | |
93 | - Message<MobileLocation> msg = functionApi.queryMobileLocation(mobile); | |
94 | - if (!msg.isSuccess()) { | |
95 | - return ""; | |
96 | - } | |
97 | - MobileLocation data = msg.getData(); | |
98 | - if (data != null) { | |
99 | - String province = data.getProvince(); | |
100 | - String city = data.getCity(); | |
101 | - att = province.concat(" ").concat(city); | |
102 | - } | |
103 | - return att.trim(); | |
104 | - } catch (Exception e) { | |
105 | - log.warn("查询手机号归属地失败:", e); | |
106 | - } | |
107 | - return ""; | |
108 | - } | |
109 | - | |
110 | -} |
fw-hermes-rpc/src/main/java/cn/fw/hermes/rpc/member/dto/MemberUserDTO.java deleted
1 | -package cn.fw.hermes.rpc.member.dto; | |
2 | - | |
3 | -import lombok.Data; | |
4 | - | |
5 | -import java.io.Serializable; | |
6 | -import java.util.Date; | |
7 | - | |
8 | -/** | |
9 | - * 会员信息 | |
10 | - * <p> | |
11 | - * create at 2019-05-09 | |
12 | - * | |
13 | - * @author kurisu | |
14 | - */ | |
15 | -@Data | |
16 | -public class MemberUserDTO implements Serializable { | |
17 | - private Long id; | |
18 | - private Long latestAccountId; | |
19 | - /** | |
20 | - * 真实姓名 | |
21 | - */ | |
22 | - private String realName; | |
23 | - | |
24 | - /** | |
25 | - * 证件类型 | |
26 | - */ | |
27 | - private Integer credentType; | |
28 | - | |
29 | - /** | |
30 | - * 证件号码 | |
31 | - */ | |
32 | - private String credentNo; | |
33 | - | |
34 | - /** | |
35 | - * 生日 | |
36 | - */ | |
37 | - private Date birthday; | |
38 | - | |
39 | - public Long getUserId() { | |
40 | - return id; | |
41 | - } | |
42 | - | |
43 | - public Long getMemberId() { | |
44 | - return id; | |
45 | - } | |
46 | - | |
47 | - public Long getAccountId() { | |
48 | - return id; | |
49 | - } | |
50 | -} |
fw-hermes-rpc/src/main/java/cn/fw/hermes/rpc/member/dto/MemberUserLevelDTO.java deleted
1 | -package cn.fw.hermes.rpc.member.dto; | |
2 | - | |
3 | -import lombok.Data; | |
4 | - | |
5 | -/** | |
6 | - * 客户level | |
7 | - * <p> | |
8 | - * create at 2019-05-16 | |
9 | - * | |
10 | - * @author kurisu | |
11 | - */ | |
12 | -@Data | |
13 | -public class MemberUserLevelDTO { | |
14 | - private Long cusId; | |
15 | - private Integer levelType; | |
16 | - private Integer growth; | |
17 | - private String cusName; | |
18 | - private String phone; | |
19 | -} |
fw-hermes-rpc/src/main/kotlin/cn/fw/hermes/rpc/member/MemberRpcService.kt
0 → 100644
1 | +package cn.fw.hermes.rpc.member | |
2 | + | |
3 | +import cn.fw.common.util.logError | |
4 | +import cn.fw.common.util.logInfo | |
5 | +import cn.fw.hermes.rpc.member.dto.MemberUserDTO | |
6 | +import cn.fw.member.sdk.api.MemberApi | |
7 | +import org.springframework.stereotype.Service | |
8 | + | |
9 | +/** | |
10 | + * 会员服务 | |
11 | + * | |
12 | + * @author kurisu | |
13 | + */ | |
14 | +@Service | |
15 | +class MemberRpcService( | |
16 | + private val memberApi: MemberApi | |
17 | +) { | |
18 | + /** | |
19 | + * 根据会员ID获取会员信息 | |
20 | + * | |
21 | + * @param userId 会员ID | |
22 | + * @return 会员信息 | |
23 | + */ | |
24 | + fun user(userId: Long?): MemberUserDTO? { | |
25 | + try { | |
26 | + userId?.let { | |
27 | + memberApi.getMemberById(userId)?.takeIf { | |
28 | + logInfo("调用Member系统[根据会员ID[{}]获取会员信息] --> res:{} data:{}", userId, it.result, it.data) | |
29 | + it.isSuccess | |
30 | + }?.run { | |
31 | + data?.let { | |
32 | + MemberUserDTO( | |
33 | + latestAccountId = data.latestAccountId, | |
34 | + realName = data.realName, | |
35 | + credentType = data.credentType, | |
36 | + credentNo = data.credentNo, | |
37 | + birthday = data.birthDate, | |
38 | + accountId = data.latestAccountId, | |
39 | + ) | |
40 | + } | |
41 | + } | |
42 | + } | |
43 | + } catch (e: Exception) { | |
44 | + logError("调用Member[根据会员ID[{}]获取会员信息]系统失败", userId, e) | |
45 | + } | |
46 | + return null | |
47 | + } | |
48 | +} | ... | ... |
fw-hermes-rpc/src/main/kotlin/cn/fw/hermes/rpc/member/dto/MemberUserDTO.kt
0 → 100644
1 | +package cn.fw.hermes.rpc.member.dto | |
2 | + | |
3 | +import java.util.* | |
4 | + | |
5 | +/** | |
6 | + * 会员信息 | |
7 | + * | |
8 | + * | |
9 | + * create at 2019-05-09 | |
10 | + * | |
11 | + * @author kurisu | |
12 | + */ | |
13 | +data class MemberUserDTO( | |
14 | + val latestAccountId: Long?, | |
15 | + | |
16 | + /** | |
17 | + * 真实姓名 | |
18 | + */ | |
19 | + val realName: String?, | |
20 | + | |
21 | + /** | |
22 | + * 证件类型 | |
23 | + */ | |
24 | + val credentType: Int?, | |
25 | + | |
26 | + /** | |
27 | + * 证件号码 | |
28 | + */ | |
29 | + val credentNo: String?, | |
30 | + | |
31 | + /** | |
32 | + * 生日 | |
33 | + */ | |
34 | + val birthday: Date?, | |
35 | + /** | |
36 | + * 账号id | |
37 | + */ | |
38 | + val accountId: Long?, | |
39 | +) | ... | ... |
fw-hermes-server/src/main/java/cn/fw/hermes/task/MessageSaveTask.kt
... | ... | @@ -69,7 +69,7 @@ class MessageSaveTask( |
69 | 69 | if (Objects.isNull(dto)) { |
70 | 70 | continue |
71 | 71 | } |
72 | - val executor = ThreadPoolUtil.getInstance().executor | |
72 | + val executor = ThreadPoolUtil.executor | |
73 | 73 | val future = CompletableFuture.runAsync({ |
74 | 74 | try { |
75 | 75 | msgPrepareBizService.saveMsg(dto) | ... | ... |
fw-hermes-server/src/main/java/cn/fw/hermes/HermesServer.kt renamed to fw-hermes-server/src/main/kotlin/cn/fw/hermes/HermesServer.kt
fw-hermes-server/src/main/java/cn/fw/hermes/controller/erp/XinGeDebugController.kt renamed to fw-hermes-server/src/main/kotlin/cn/fw/hermes/controller/common/XinGeDebugController.kt
fw-hermes-service/src/main/java/cn/fw/hermes/service/biz/AccountBizService.java
... | ... | @@ -152,7 +152,7 @@ public class AccountBizService { |
152 | 152 | |
153 | 153 | private Hermes genHermes(Long userId, String userName, AccountTypeEnum accountTypeEnum) { |
154 | 154 | Hermes hermes = new Hermes(); |
155 | - hermes.setIdentifier(UUIDUtils.newStaffIdentifier(userId)); | |
155 | + hermes.setIdentifier(UUIDUtils.INSTANCE.newStaffIdentifier(userId)); | |
156 | 156 | hermes.setUserId(userId); |
157 | 157 | hermes.setNickName(userName); |
158 | 158 | hermes.setAccountType(accountTypeEnum); |
... | ... | @@ -162,7 +162,7 @@ public class AccountBizService { |
162 | 162 | } |
163 | 163 | |
164 | 164 | private void renderTopics(AccountResultVO vo, String platform) { |
165 | - final TemplateHelper helper = TemplateHelper.getInstance(); | |
165 | + final TemplateHelper helper = TemplateHelper.INSTANCE; | |
166 | 166 | final Dict dict = Dict.create(); |
167 | 167 | dict.set("identifier", vo.getIdentifier()); |
168 | 168 | dict.set("platform", platform); | ... | ... |
fw-hermes-service/src/main/java/cn/fw/hermes/service/biz/BeanTransfer.java
... | ... | @@ -282,7 +282,7 @@ public final class BeanTransfer { |
282 | 282 | } |
283 | 283 | |
284 | 284 | public static String renderTopic(String format, String identifier, String platformCode) { |
285 | - final TemplateHelper helper = TemplateHelper.getInstance(); | |
285 | + final TemplateHelper helper = TemplateHelper.INSTANCE; | |
286 | 286 | final Dict dict = Dict.create(); |
287 | 287 | dict.set("identifier", identifier); |
288 | 288 | dict.set("platform", platformCode); | ... | ... |
fw-hermes-service/src/main/java/cn/fw/hermes/service/emqx/MqttService.kt
... | ... | @@ -223,7 +223,7 @@ class MqttService( |
223 | 223 | } catch (ignored: InterruptedException) { |
224 | 224 | } |
225 | 225 | messageHistoryService.sendCallback(id, true, Constant.SUCCESS_MSG) |
226 | - }, ThreadPoolUtil.getInstance().executor) | |
226 | + }, ThreadPoolUtil.executor) | |
227 | 227 | } |
228 | 228 | } |
229 | 229 | |
... | ... | @@ -233,7 +233,7 @@ class MqttService( |
233 | 233 | * @return |
234 | 234 | */ |
235 | 235 | fun sendWarningMsg() { |
236 | - val robot = mqttProperty!!.robot | |
236 | + val robot = mqttProperty.robot | |
237 | 237 | logInfo("机器人配置信息:[{}]", robot) |
238 | 238 | if (Objects.nonNull(robot) && robot!!.enabled) { |
239 | 239 | try { | ... | ... |
fw-hermes-service/src/main/java/cn/fw/hermes/service/biz/XgPushBizService.kt renamed to fw-hermes-service/src/main/kotlin/cn/fw/hermes/service/biz/XgPushBizService.kt
fw-hermes-service/src/main/java/cn/fw/hermes/service/property/MqttProperty.kt renamed to fw-hermes-service/src/main/kotlin/cn/fw/hermes/service/property/MqttProperty.kt
fw-hermes-service/src/main/java/cn/fw/hermes/service/property/XinGeProperty.kt renamed to fw-hermes-service/src/main/kotlin/cn/fw/hermes/service/property/XinGeProperty.kt
pom.xml
... | ... | @@ -212,6 +212,10 @@ |
212 | 212 | <groupId>org.codehaus.mojo</groupId> |
213 | 213 | <artifactId>versions-maven-plugin</artifactId> |
214 | 214 | </plugin> |
215 | + <plugin> | |
216 | + <groupId>org.codehaus.mojo</groupId> | |
217 | + <artifactId>build-helper-maven-plugin</artifactId> | |
218 | + </plugin> | |
215 | 219 | </plugins> |
216 | 220 | </build> |
217 | 221 | ... | ... |