Commit 556f52c4781b3d54358a50ae19ecf57bb0412176
1 parent
f41edf2d
酒测推送异常数据
Showing
3 changed files
with
29 additions
and
28 deletions
Bsth-admin/src/main/java/com/ruoyi/service/SignatureUtils.java
| 1 | package com.ruoyi.service; | 1 | package com.ruoyi.service; |
| 2 | 2 | ||
| 3 | -import org.slf4j.Logger; | ||
| 4 | -import org.slf4j.LoggerFactory; | ||
| 5 | -import org.springframework.util.DigestUtils; | ||
| 6 | - | ||
| 7 | import java.security.MessageDigest; | 3 | import java.security.MessageDigest; |
| 8 | import java.security.NoSuchAlgorithmException; | 4 | import java.security.NoSuchAlgorithmException; |
| 9 | import java.util.Map; | 5 | import java.util.Map; |
| 10 | import java.util.TreeMap; | 6 | import java.util.TreeMap; |
| 11 | 7 | ||
| 12 | public class SignatureUtils { | 8 | public class SignatureUtils { |
| 13 | - private final static Logger logger = LoggerFactory.getLogger(SignatureUtils.class); | ||
| 14 | - | ||
| 15 | // 生成签名 | 9 | // 生成签名 |
| 16 | - public static String generateSignature(Map<String, Object> params, String secretKey) { | ||
| 17 | - TreeMap<String, Object> sortedParams = new TreeMap<>(params); | 10 | + public static String generateSignature(Map<String, String> params, String secretKey) { |
| 11 | + TreeMap<String, String> sortedParams = new TreeMap<>(params); | ||
| 18 | StringBuilder sb = new StringBuilder(); | 12 | StringBuilder sb = new StringBuilder(); |
| 19 | 13 | ||
| 20 | - for (Map.Entry<String, Object> entry : sortedParams.entrySet()) { | 14 | + for (Map.Entry<String, String> entry : sortedParams.entrySet()) { |
| 21 | sb.append(entry.getKey()).append("=").append(entry.getValue()).append("&"); | 15 | sb.append(entry.getKey()).append("=").append(entry.getValue()).append("&"); |
| 22 | } | 16 | } |
| 23 | sb.append("secretKey=").append(secretKey); | 17 | sb.append("secretKey=").append(secretKey); |
| @@ -25,19 +19,21 @@ public class SignatureUtils { | @@ -25,19 +19,21 @@ public class SignatureUtils { | ||
| 25 | return md5(sb.toString()); | 19 | return md5(sb.toString()); |
| 26 | } | 20 | } |
| 27 | 21 | ||
| 22 | + // MD5加密 | ||
| 28 | private static String md5(String input) { | 23 | private static String md5(String input) { |
| 29 | try { | 24 | try { |
| 30 | - logger.info("MD5加密之前内容: {}", input); | ||
| 31 | - if (input == null || "".equals(input.trim())) { | ||
| 32 | - return null; | 25 | + MessageDigest md = MessageDigest.getInstance("MD5"); |
| 26 | + byte[] messageDigest = md.digest(input.getBytes()); | ||
| 27 | + StringBuilder hexString = new StringBuilder(); | ||
| 28 | + | ||
| 29 | + for (byte b : messageDigest) { | ||
| 30 | + hexString.append(String.format("%02x", b)); | ||
| 33 | } | 31 | } |
| 34 | - String md5 = DigestUtils.md5DigestAsHex(input.getBytes()); | ||
| 35 | - logger.info("MD5加密之后内容: {}", md5); | ||
| 36 | - return md5; | ||
| 37 | - } catch (Exception e) { | ||
| 38 | - logger.error("MD5加密异常:", e); | 32 | + |
| 33 | + return hexString.toString(); | ||
| 34 | + } catch (NoSuchAlgorithmException e) { | ||
| 39 | e.printStackTrace(); | 35 | e.printStackTrace(); |
| 36 | + return null; | ||
| 40 | } | 37 | } |
| 41 | - return null; | ||
| 42 | } | 38 | } |
| 43 | } | 39 | } |
Bsth-admin/src/main/java/com/ruoyi/service/ThreadJobService.java
| @@ -5,6 +5,7 @@ import cn.hutool.core.collection.CollectionUtil; | @@ -5,6 +5,7 @@ import cn.hutool.core.collection.CollectionUtil; | ||
| 5 | import cn.hutool.core.convert.Convert; | 5 | import cn.hutool.core.convert.Convert; |
| 6 | import cn.hutool.http.HttpUtil; | 6 | import cn.hutool.http.HttpUtil; |
| 7 | import cn.hutool.json.JSONUtil; | 7 | import cn.hutool.json.JSONUtil; |
| 8 | +import com.alibaba.fastjson2.JSON; | ||
| 8 | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | 9 | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| 9 | import com.ruoyi.common.cache.NowSchedulingCache; | 10 | import com.ruoyi.common.cache.NowSchedulingCache; |
| 10 | import com.ruoyi.common.cache.TempCache; | 11 | import com.ruoyi.common.cache.TempCache; |
| @@ -45,7 +46,6 @@ import com.ruoyi.system.domain.SysNotice; | @@ -45,7 +46,6 @@ import com.ruoyi.system.domain.SysNotice; | ||
| 45 | import com.ruoyi.system.service.ISysNoticeService; | 46 | import com.ruoyi.system.service.ISysNoticeService; |
| 46 | import com.ruoyi.utils.ConstDateUtil; | 47 | import com.ruoyi.utils.ConstDateUtil; |
| 47 | import com.ruoyi.utils.DateUtil; | 48 | import com.ruoyi.utils.DateUtil; |
| 48 | -import com.ruoyi.utils.HttpClientUtil; | ||
| 49 | import lombok.extern.slf4j.Slf4j; | 49 | import lombok.extern.slf4j.Slf4j; |
| 50 | import org.apache.commons.collections4.CollectionUtils; | 50 | import org.apache.commons.collections4.CollectionUtils; |
| 51 | import org.springframework.beans.BeanUtils; | 51 | import org.springframework.beans.BeanUtils; |
| @@ -370,7 +370,7 @@ public class ThreadJobService { | @@ -370,7 +370,7 @@ public class ThreadJobService { | ||
| 370 | 370 | ||
| 371 | if (CollectionUtils.isNotEmpty(newDrivers)) { | 371 | if (CollectionUtils.isNotEmpty(newDrivers)) { |
| 372 | for (NewDriver newDriver : newDrivers) { | 372 | for (NewDriver newDriver : newDrivers) { |
| 373 | - Map<String, Object> map = new HashMap<>(); | 373 | + Map<String, String> map = new HashMap<>(); |
| 374 | map.put("noticeIssuer", "运控中心"); | 374 | map.put("noticeIssuer", "运控中心"); |
| 375 | map.put("noticeRecipient", "05-" + newDriver.getJobCode()); | 375 | map.put("noticeRecipient", "05-" + newDriver.getJobCode()); |
| 376 | map.put("noticeTitle", "异常通知"); | 376 | map.put("noticeTitle", "异常通知"); |
| @@ -386,14 +386,14 @@ public class ThreadJobService { | @@ -386,14 +386,14 @@ public class ThreadJobService { | ||
| 386 | 386 | ||
| 387 | map.put("noticeContent", builder.toString()); | 387 | map.put("noticeContent", builder.toString()); |
| 388 | map.put("phone", newDriver.getTelphone()); | 388 | map.put("phone", newDriver.getTelphone()); |
| 389 | - map.put("smscontent", builder.toString()); | 389 | + map.put("smsContent", builder.toString()); |
| 390 | map.put("noticeType", "岗前检查"); | 390 | map.put("noticeType", "岗前检查"); |
| 391 | 391 | ||
| 392 | String key = SignatureUtils.generateSignature(map, "your_secret_key_here"); | 392 | String key = SignatureUtils.generateSignature(map, "your_secret_key_here"); |
| 393 | map.put("signature", key); | 393 | map.put("signature", key); |
| 394 | String result = null; | 394 | String result = null; |
| 395 | try { | 395 | try { |
| 396 | - result = HttpUtil.get(processSignExceptionURL, map, 10000); | 396 | + result = HttpUtil.get(processSignExceptionURL, (Map<String, Object>) JSON.toJSON((map)), 10000); |
| 397 | log.info("processSignExceptionURL:[{}],paramMap:[{}],result:[{}]", processSignExceptionURL, JSONUtil.toJsonStr(map), result); | 397 | log.info("processSignExceptionURL:[{}],paramMap:[{}],result:[{}]", processSignExceptionURL, JSONUtil.toJsonStr(map), result); |
| 398 | } catch (Exception e) { | 398 | } catch (Exception e) { |
| 399 | log.error("processSignExceptionURL:[{}],paramMap:[{}],result:[{}]", processSignExceptionURL, JSONUtil.toJsonStr(map), result, e); | 399 | log.error("processSignExceptionURL:[{}],paramMap:[{}],result:[{}]", processSignExceptionURL, JSONUtil.toJsonStr(map), result, e); |
| @@ -406,19 +406,24 @@ public class ThreadJobService { | @@ -406,19 +406,24 @@ public class ThreadJobService { | ||
| 406 | } | 406 | } |
| 407 | 407 | ||
| 408 | public static void main(String[] args) { | 408 | public static void main(String[] args) { |
| 409 | - Map<String, Object> map = new HashMap<>(); | 409 | + Map<String, String> map = new HashMap<>(); |
| 410 | map.put("noticeIssuer", "运控中心"); | 410 | map.put("noticeIssuer", "运控中心"); |
| 411 | map.put("noticeRecipient", "05-006154"); | 411 | map.put("noticeRecipient", "05-006154"); |
| 412 | map.put("noticeTitle", "异常通知"); | 412 | map.put("noticeTitle", "异常通知"); |
| 413 | - | ||
| 414 | - | ||
| 415 | map.put("noticeContent", "工号:1700003,姓名:测试,工种:驾驶员,排班:有排班,打卡时间:2025-01-07 03:29:20,酒精测试超标,当前测试值达到50mg/100ml。属于饮酒后驾驶机动车"); | 413 | map.put("noticeContent", "工号:1700003,姓名:测试,工种:驾驶员,排班:有排班,打卡时间:2025-01-07 03:29:20,酒精测试超标,当前测试值达到50mg/100ml。属于饮酒后驾驶机动车"); |
| 416 | map.put("phone", "13681905733"); | 414 | map.put("phone", "13681905733"); |
| 417 | - map.put("smscontent", "工号:1700003,姓名:测试,工种:驾驶员,排班:有排班,打卡时间:2025-01-07 03:29:20,酒精测试超标,当前测试值达到50mg/100ml。属于饮酒后驾驶机动车"); | 415 | + map.put("smsContent", "工号:1700003,姓名:测试,工种:驾驶员,排班:有排班,打卡时间:2025-01-07 03:29:20,酒精测试超标,当前测试值达到50mg/100ml。属于饮酒后驾驶机动车"); |
| 418 | map.put("noticeType", "岗前检查"); | 416 | map.put("noticeType", "岗前检查"); |
| 419 | 417 | ||
| 420 | String key = SignatureUtils.generateSignature(map, "your_secret_key_here"); | 418 | String key = SignatureUtils.generateSignature(map, "your_secret_key_here"); |
| 421 | - System.out.println(key); | 419 | + map.put("signature", key); |
| 420 | + String result = null; | ||
| 421 | + try { | ||
| 422 | + result = HttpUtil.get("http://10.10.200.142:9103/commonOpenDataApi/sendAppAndSmsNotice", (Map<String, Object>) JSON.toJSON((map)), 10000); | ||
| 423 | + System.out.println(result); | ||
| 424 | + } catch (Exception e) { | ||
| 425 | + e.printStackTrace(); | ||
| 426 | + } | ||
| 422 | } | 427 | } |
| 423 | 428 | ||
| 424 | private static String[] comStrs(String str) { | 429 | private static String[] comStrs(String str) { |
Bsth-admin/src/main/resources/application-druid-lingangPrd.yml
| @@ -239,6 +239,6 @@ bsth: | @@ -239,6 +239,6 @@ bsth: | ||
| 239 | url: http://222.76.217.238:8880/fcgi-bin/entry.fcgi/system | 239 | url: http://222.76.217.238:8880/fcgi-bin/entry.fcgi/system |
| 240 | process: | 240 | process: |
| 241 | sign: | 241 | sign: |
| 242 | - url: http://10.10.200.171:9103/commonOpenDataApi/sendAppAndSmsNotice | 242 | + url: http://10.10.200.142:9103/commonOpenDataApi/sendAppAndSmsNotice |
| 243 | audit-jobs: | 243 | audit-jobs: |
| 244 | 244 |