ws 3 年之前
父節點
當前提交
7131a67a71

+ 110 - 0
nngkxxdp/src/main/java/com/example/nngkxxdp/util/WebsiteSmsUtil.java

@@ -0,0 +1,110 @@
+package com.example.nngkxxdp.util;
+
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+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.crypto.SecureUtil;
+import cn.hutool.http.HttpRequest;
+import cn.hutool.log.StaticLog;
+
+/**
+* @ClassName: WebsiteSmsUtil 
+* @Description: 网站考评每月短信定时任务
+* @author wangs  
+* @date 2022年1月4日 下午2:10:16 
+*
+ */
+@Configuration      
+@EnableScheduling 
+public class WebsiteSmsUtil {
+	
+	@Autowired
+	private TjService tjService;
+	
+	@Value("${sms.custom}")
+	private String custom;
+	
+	private static String UP_SMS = "${name},您好,${year}年${month}月区政务公开考评结果已经更新。贵单位得分${branch}分,位列${ranking}名,同比上月上升${ringRatio}名,感谢您的努力工作。点击查看详细考评数据。》》${url}";
+	private static String DOWN_SMS = "${name},您好,上月网站考核结果已经更新。贵单位得分${branch}分,位列${ranking}名,同比上月下降${ringRatio}名。点击查看详细考评数据。》》${url}";
+	
+	/**
+	* @Title: task 
+	* @Description: 每月定时任务
+	* @param      
+	* @return void   
+	* @throws
+	 */
+	@Scheduled(cron = "0 0 08 10 * ?")
+	public void task() {
+		StaticLog.info("==============================================================");
+		StaticLog.info("开始执行每月网站考评短信发送任务");
+		Map<String, Object> map = tjService.sendSms();
+		StaticLog.info("获取网站考核,data:{}", map);
+		if (Blank.isEmpty(map)) {
+			return;
+		}
+		JSONObject upObj ;
+		JSONArray up = JSONArray.parseArray(String.valueOf(map.get("up")));
+		if (!up.isEmpty()) {
+			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);
+				
+				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");
+				
+				sendSms(phone, content);
+			}
+		}
+		JSONArray down = JSONArray.parseArray(String.valueOf(map.get("down")));
+		if (!down.isEmpty()) {
+			String downMsg = DOWN_SMS;
+			for (int i = 0; i < down.size(); i++) {
+				upObj = down.getJSONObject(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");
+				
+				sendSms(phone, content);
+			}
+		}
+	}
+	
+	public void sendSms(String phone, String content) {
+		long time = new Date().getTime();
+		Map<String, Object> map = new HashMap<>();
+		map.put("phoneNumber", phone);
+		map.put("content", content);
+		String result = HttpRequest.post(custom)
+			    .header("_t", String.valueOf(time))
+			    .header("_yz", SecureUtil.md5(phone + "," + content + "," + time))
+			    .form(map)
+			    .execute().body();
+		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));
+	}
+
+}

+ 1 - 1
nngkxxdp/src/main/resources/static/page/js/base/fbtx.item.js

@@ -654,7 +654,7 @@ function reloadSmsTable() {
 				return d.sendTime ? d.sendTime : '未提醒';
 			}},
 			{title: '操作', templet: function(d) {
-				return '<a style="color:#1276ff;cursor: pointer;" onclick="initSmsTableDetail(\''+ (d.wType + '-' + d.wName) +'\',\''+ d.id +'\')">详情</a>';
+				return '<a style="color:#1276ff;cursor: pointer;" onclick="initSmsTableDetail(\''+ d.staffName +'\',\''+ d.leadName +'\',\''+ (d.wType + '-' + d.wName) +'\',\''+ d.id +'\')">详情</a>';
 			}}
 	    ]]
 	});