浏览代码

Merge remote-tracking branch 'origin/V1' into V1

zhengqiang 5 年之前
父节点
当前提交
c1c1b06d96

+ 86 - 0
common/src/main/java/com/jpsoft/smart/modules/common/utils/WeixinUtil.java

@@ -3,6 +3,7 @@ package com.jpsoft.smart.modules.common.utils;
 import cn.hutool.core.date.DateTime;
 import com.jpsoft.smart.modules.wechat.entity.AccessToken;
 import com.jpsoft.smart.modules.wechat.vo.UserInfo;
+import net.sf.json.JSONArray;
 import net.sf.json.JSONException;
 import net.sf.json.JSONObject;
 import org.slf4j.Logger;
@@ -237,4 +238,89 @@ public class WeixinUtil {
 		}
 	}
 
+	public static void replyArticlesMessage(HttpServletResponse response, String fromUserName, String toUserName, String title,String description,String picurl,String url){
+		StringBuilder sb = new StringBuilder();
+		sb.append("<xml>");
+		sb.append("<ToUserName><![CDATA[" + toUserName + "]]></ToUserName>");
+		sb.append("<FromUserName><![CDATA["+ fromUserName + "]]></FromUserName>");
+		sb.append("<CreateTime>" + DateTime.now().getTime() + "</CreateTime>");
+		sb.append("<MsgType><![CDATA[news]]></MsgType>");
+		sb.append("<ArticleCount>" + 1 + "</ArticleCount>");
+		sb.append("<Articles>");
+		sb.append("<item>");
+		sb.append("<Title><![CDATA["+title+"]]></Title> ");
+		sb.append("<Description><![CDATA["+description+"]]></Description>");
+		sb.append("<PicUrl><![CDATA["+picurl+"]]></PicUrl>");
+		sb.append("<Url><![CDATA["+url+"]]></Url>");
+		sb.append("</item>");
+		sb.append("</Articles>");
+		sb.append("</xml>");
+
+		try {
+			response.getWriter().print(sb.toString());
+			response.getWriter().close();
+		} catch (IOException e) {
+			e.printStackTrace();
+		}
+	}
+
+
+	public static String createMenu(String appid,String appSecret){
+		AccessToken token = WeixinUtil.getAccessToken(appid, appSecret);
+
+		System.out.println(token.getToken());
+
+		JSONObject data = new JSONObject();
+		JSONArray buttonArray = new JSONArray();
+
+		JSONObject button1 = new JSONObject();
+		button1.put("type", "view");
+		button1.put("name", "疫情监管");
+		button1.put("url", "http://wisdomhousewechat.sudaonline.net/prevention/");
+		buttonArray.add(button1);
+
+		JSONObject button2 = new JSONObject();
+		button2.put("type","view");
+		button2.put("name","智慧物业");
+		button2.put("url","http://wisdomhousewechat.sudaonline.net/#/home/?id=1");
+		buttonArray.add(button2);
+
+		JSONObject button3 = new JSONObject();
+		button3.put("type","click");
+		button3.put("name","关于系统");
+		button3.put("key","文章");
+		buttonArray.add(button3);
+
+
+
+
+		data.put("button", buttonArray);
+		data.put("action_name", "QR_LIMIT_STR_SCENE");
+
+		JSONObject actionInfo = new JSONObject();
+		JSONObject scene = new JSONObject();
+
+		scene.put("scene_str", "6");
+
+		actionInfo.put("scene", scene);
+
+		data.put("action_info", actionInfo);
+		System.out.println(data.toString());
+		//创建菜单
+		String result = HttpConnectionUtil.getHttpContentByPost(" https://api.weixin.qq.com/cgi-bin/menu/create?access_token=" + token.getToken(), "utf-8", data.toString());
+
+
+
+		return result;
+
+	}
+
+	public static void main(String[] args){
+
+		String result = createMenu("wxb935babc7dd147b8","9cb08ae433a8ad88d77ff921f9175577");
+		System.out.println(result);
+	}
+
+
+
 }

+ 3 - 2
common/src/main/resources/mapper/base/MessageNotice.xml

@@ -95,8 +95,9 @@ id_,title_,content_,sender_id,recipient_id,status_,del_flag,create_by,create_tim
 			select * from base_message_notice
 		]]>
 		<where>
-			<if test="searchParams.id != null">
-				and ID_ like #{searchParams.id}
+			and del_flag = false
+			<if test="searchParams.title != null">
+				and title_ like #{searchParams.title}
 			</if>
 		</where>
 		<foreach item="sort" collection="sortList"  open="order by" separator=",">

+ 3 - 2
common/src/main/resources/mapper/base/MessageReport.xml

@@ -95,8 +95,9 @@ id_,title_,content_,sender_id,recipient_id,status_,del_flag,create_by,create_tim
 			select * from base_message_report
 		]]>
 		<where>
-			<if test="searchParams.id != null">
-				and ID_ like #{searchParams.id}
+			and del_flag = false
+			<if test="searchParams.title != null">
+				and title_ like #{searchParams.title}
 			</if>
 		</where>
 		<foreach item="sort" collection="sortList"  open="order by" separator=",">

+ 4 - 4
web/src/main/java/com/jpsoft/smart/modules/base/controller/MessageNoticeController.java

@@ -196,7 +196,7 @@ public class MessageNoticeController {
     @ApiOperation(value="列表")
     @RequestMapping(value = "pageList",method = RequestMethod.POST)
     public MessageResult<Map> pageList(
-            String id,
+            String title,
             @RequestParam(value="pageIndex",defaultValue="1") int pageIndex,
             @RequestParam(value="pageSize",defaultValue="20") int pageSize,
             @RequestAttribute String subject){
@@ -209,10 +209,10 @@ public class MessageNoticeController {
         Map<String,Object> searchParams = new HashMap<>();
 
         List<Sort> sortList = new ArrayList<>();
-        sortList.add(new Sort("id_","asc"));
+        sortList.add(new Sort("create_time","desc"));
 
-        if (StringUtils.isNotEmpty(id)) {
-            searchParams.put("id","%" + id + "%");
+        if (StringUtils.isNotEmpty(title)) {
+            searchParams.put("title","%" + title + "%");
         }
 
         Page<MessageNotice> page = messageNoticeService.pageSearch(searchParams,pageIndex,pageSize,true,sortList);

+ 4 - 4
web/src/main/java/com/jpsoft/smart/modules/base/controller/MessageReportController.java

@@ -196,7 +196,7 @@ public class MessageReportController {
     @ApiOperation(value="列表")
     @RequestMapping(value = "pageList",method = RequestMethod.POST)
     public MessageResult<Map> pageList(
-            String id,
+            String title,
             @RequestParam(value="pageIndex",defaultValue="1") int pageIndex,
             @RequestParam(value="pageSize",defaultValue="20") int pageSize,
             @RequestAttribute String subject){
@@ -209,10 +209,10 @@ public class MessageReportController {
         Map<String,Object> searchParams = new HashMap<>();
 
         List<Sort> sortList = new ArrayList<>();
-        sortList.add(new Sort("id_","asc"));
+        sortList.add(new Sort("create_time","desc"));
 
-        if (StringUtils.isNotEmpty(id)) {
-            searchParams.put("id","%" + id + "%");
+        if (StringUtils.isNotEmpty(title)) {
+            searchParams.put("title","%" + title + "%");
         }
 
         Page<MessageReport> page = messageReportService.pageSearch(searchParams,pageIndex,pageSize,true,sortList);

+ 11 - 0
web/src/main/java/com/jpsoft/smart/modules/wechat/controller/WxController.java

@@ -840,9 +840,11 @@ public class WxController {
                 String eventCode = keys[0];
                 String id = keys[1];
 
+
                 ReplyMessage replyMessage = replyMessageService.findByEvent(eventCode);
 
                 if (replyMessage != null) {
+
                     WarningPusher warningPusher = warningPusherService.get(id);
                     if (warningPusher == null){
                         WeixinUtil.replyTextMessage(response, wechatId, openId,"绑定信息不存在,请联系管理员");
@@ -861,6 +863,15 @@ public class WxController {
                     processed = true;
                 }
             }
+            else if ("文章".equals(eventKey)){
+
+                WeixinUtil.replyArticlesMessage(response,wechatId,openId,"复工复学疫情防控监管平台","即日起接受预定,货源紧张,先订先得。\n预定电话:13972127999 市企业联合会蔡秘书长;\n19971390396 刘经理;15607217777 付经理。","http://wisdomhousewechat.sudaonline.net/1111.jpg","https://mp.weixin.qq.com/s/nXYp0m8OOYdWBRu-80SnmQ");
+            }
+            else {
+                WeixinUtil.replyTextMessage(response, wechatId, openId,"您好,欢迎关注荆鹏云管家。\n" +
+                        "\n" +
+                        "疫情监管产品介绍:<a href=\"https://mp.weixin.qq.com/s/nXYp0m8OOYdWBRu-80SnmQ\">点击查看详情</a>");
+            }
             //开发者在5秒内未回复任何内容
 //                for (EventCallback callback : callbackList) {
 //                    if (StringUtils.isNotEmpty(eventKey) && eventKey.startsWith(callback.getCode())) {