|
@@ -2,6 +2,7 @@ package com.example.nngkxxdp.util;
|
|
|
|
|
|
import java.util.Date;
|
|
|
import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
import java.util.Map;
|
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -10,10 +11,9 @@ import org.springframework.context.annotation.Configuration;
|
|
|
import org.springframework.scheduling.annotation.EnableScheduling;
|
|
|
import org.springframework.scheduling.annotation.Scheduled;
|
|
|
|
|
|
-import com.alibaba.fastjson.JSONArray;
|
|
|
-import com.alibaba.fastjson.JSONObject;
|
|
|
import com.example.nngkxxdp.service.TjService;
|
|
|
|
|
|
+import cn.hutool.core.convert.Convert;
|
|
|
import cn.hutool.crypto.SecureUtil;
|
|
|
import cn.hutool.http.HttpRequest;
|
|
|
import cn.hutool.log.StaticLog;
|
|
@@ -54,34 +54,34 @@ public class WebsiteSmsUtil {
|
|
|
if (Blank.isEmpty(map)) {
|
|
|
return;
|
|
|
}
|
|
|
- JSONObject upObj ;
|
|
|
- JSONArray up = JSONArray.parseArray(String.valueOf(map.get("up")));
|
|
|
- if (!up.isEmpty()) {
|
|
|
+ Map<String, Object> upObj ;
|
|
|
+ List<?> up = Convert.toList(map.get("up"));
|
|
|
+ if (Blank.notBlank(up)) {
|
|
|
String upMsg = UP_SMS;
|
|
|
Date date = new Date();
|
|
|
date = cn.hutool.core.date.DateUtil.offsetMonth(date, -1);
|
|
|
for (int i = 0; i < up.size(); i++) {
|
|
|
- upObj = up.getJSONObject(i);
|
|
|
+ upObj = Convert.toMap(String.class, Object.class, up.get(i));
|
|
|
|
|
|
- String content = upMsg.replace("${name}", upObj.getString("name")).replace("${year}", String.valueOf(cn.hutool.core.date.DateUtil.year(date)))
|
|
|
- .replace("${month}", String.valueOf(cn.hutool.core.date.DateUtil.month(date) + 1)).replace("${branch}", upObj.getString("score"))
|
|
|
- .replace("${ranking}", upObj.getString("ranking")).replace("${ringRatio}", upObj.getString("ringRatio"))
|
|
|
- .replace("${url}", upObj.getString("url"));
|
|
|
- String phone = upObj.getString("phone");
|
|
|
+ String content = upMsg.replace("${name}", String.valueOf(upObj.get("name"))).replace("${year}", String.valueOf(cn.hutool.core.date.DateUtil.year(date)))
|
|
|
+ .replace("${month}", String.valueOf(cn.hutool.core.date.DateUtil.month(date) + 1)).replace("${branch}", String.valueOf(upObj.get("score")))
|
|
|
+ .replace("${ranking}", String.valueOf(upObj.get("ranking"))).replace("${ringRatio}", String.valueOf(upObj.get("ringRatio")))
|
|
|
+ .replace("${url}", String.valueOf(upObj.get("url")));
|
|
|
+ String phone = String.valueOf(upObj.get("phone"));
|
|
|
|
|
|
sendSms(phone, content);
|
|
|
}
|
|
|
}
|
|
|
- JSONArray down = JSONArray.parseArray(String.valueOf(map.get("down")));
|
|
|
- if (!down.isEmpty()) {
|
|
|
+ List<?> down = Convert.toList(map.get("down"));
|
|
|
+ if (Blank.notBlank(down)) {
|
|
|
String downMsg = DOWN_SMS;
|
|
|
for (int i = 0; i < down.size(); i++) {
|
|
|
- upObj = down.getJSONObject(i);
|
|
|
+ upObj = Convert.toMap(String.class, Object.class, down.get(i));
|
|
|
|
|
|
- String content = downMsg.replace("${name}", upObj.getString("name")).replace("${ranking}", upObj.getString("ranking"))
|
|
|
- .replace("${branch}", upObj.getString("score")).replace("${ringRatio}", upObj.getString("ringRatio"))
|
|
|
- .replace("${url}", upObj.getString("url"));
|
|
|
- String phone = upObj.getString("phone");
|
|
|
+ String content = downMsg.replace("${name}", String.valueOf(upObj.get("name"))).replace("${ranking}", String.valueOf(upObj.get("ranking")))
|
|
|
+ .replace("${branch}", String.valueOf(upObj.get("score"))).replace("${ringRatio}", String.valueOf(upObj.get("ringRatio")))
|
|
|
+ .replace("${url}", String.valueOf(upObj.get("url")));
|
|
|
+ String phone = String.valueOf(upObj.get("phone"));
|
|
|
|
|
|
sendSms(phone, content);
|
|
|
}
|
|
@@ -101,10 +101,5 @@ public class WebsiteSmsUtil {
|
|
|
System.err.println("body==========:"+result);
|
|
|
}
|
|
|
|
|
|
- public static void main(String[] args) {
|
|
|
- Date date = new Date();
|
|
|
- date = cn.hutool.core.date.DateUtil.offsetMonth(date, -1);
|
|
|
- System.err.println(cn.hutool.core.date.DateUtil.year(date));
|
|
|
- }
|
|
|
|
|
|
}
|