Jelajahi Sumber

Changes 增加消息提醒规则

cyan 1 bulan lalu
induk
melakukan
0e8fbb9504

+ 5 - 0
jeecg-boot/jeecg-boot-base-core/pom.xml

@@ -280,6 +280,11 @@
 			<artifactId>jsoup</artifactId>
 			<version>1.15.4</version>
 		</dependency>
+		<dependency>
+			<groupId>cn.bigmodel.openapi</groupId>
+			<artifactId>oapi-java-sdk</artifactId>
+			<version>release-V4-2.3.0</version>
+		</dependency>
 	</dependencies>
 
 </project>

+ 80 - 0
jeecg-boot/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/okki/site/controller/ShopApiController.java

@@ -1,5 +1,9 @@
 package org.jeecg.modules.okki.site.controller;
 
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.zhipu.oapi.ClientV4;
+import com.zhipu.oapi.Constants;
+import com.zhipu.oapi.service.v4.model.*;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.http.HttpHeaders;
@@ -16,6 +20,11 @@ import org.jeecg.modules.okki.site.service.IOkkiSiteService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.concurrent.TimeUnit;
+
 /**
  * @Description: 站点
  * @Author: Jack
@@ -170,4 +179,75 @@ public class ShopApiController {
         feiShuSheetService.createFeiShuSeoShowlistBitable(recordSheetDto);
         return Result.ok();
     }
+
+    @RequestMapping("/test")
+    public Result<?> test() throws JsonProcessingException {
+        List<ChatMessage> messages = new ArrayList<>();
+        ChatMessage systemChatMessage = new ChatMessage(ChatMessageRole.SYSTEM.value(), "#角色 你是一位情感、心理学和社会学领域的专家,专注于情感分析。通过对话中的语言和情感线索,你能够深入洞察对话者的心理活动,捕捉他们的情感波动、内在需求和潜在动机。不仅如此,你还可以分析对话中的社会互动模式,揭示人际关系中的权力动态、依赖性或冲突源。无论是提供情感支持、改善人际沟通,还是帮助理解复杂的心理状态,你都能通过精准的情感解读,为我提供全面的分析与建议。");
+        messages.add(systemChatMessage);
+
+        String promot = "Mick(SEM优化专员) 9-13 11:18:29\n" +
+                "@Anne☆英   您好,这边给您准备了一份广告部署表,里面帮您整理了产品列表,每日预算以及投放地区的内容,麻烦您看一下是否符合我们推广的预期。如果有问题也欢迎与我们沟通修改。\n" +
+                "\n" +
+                "Mick(SEM优化专员) 9-13 11:18:42\n" +
+                "[文件:2-Google ads部署表.xls]\n" +
+                "\n" +
+                "Anne☆英@微信@微信联系人 9-13 11:21:08\n" +
+                "好的,我们先看看\n" +
+                "\n" +
+                "Anne☆英@微信@微信联系人 9-13 11:26:51\n" +
+                "@王佳恒 你好,就是这一组吗?\n" +
+                "\n" +
+                "Mick(SEM优化专员) 9-13 11:27:47\n" +
+                "嗯嗯对的\n" +
+                "\n" +
+                "Mick(SEM优化专员) 9-13 11:27:58\n" +
+                "目前给您整理了一个广告大类的内容\n" +
+                "\n" +
+                "Anne☆英@微信@微信联系人 9-13 11:33:52\n" +
+                "不行哦,这几个Google图片搜出来的,几乎100%与我们要做的产品不相关\n" +
+                "\n" +
+                "Anne☆英@微信@微信联系人 9-13 11:41:30\n" +
+                "standup pouch 也不行,这个词零售属性更强,不符合我们定位的B端客户\n" +
+                "\n" +
+                "Anne☆英@微信@微信联系人 9-13 11:43:21\n" +
+                "@王佳恒  你有没有keywords everywhere?\n" +
+                "\n" +
+                "Anne☆英@微信@微信联系人 9-13 11:44:19\n" +
+                "如果有,帮忙查一下: eight side-sealed bag 和quad seal bag 的 volume(搜索量)和CPC (点击花费)\n" +
+                "\n" +
+                "Anne☆英@微信@微信联系人 9-13 11:50:26\n" +
+                "另外,你直接拿我们网站上这个作为这个广告组的着陆页,也不合适吧?着陆页觉得客户是否询盘,不是应该好好设计一下吗?";
+        ChatMessage userChatMessage = new ChatMessage(ChatMessageRole.USER.value(), promot);
+        messages.add(userChatMessage);
+
+        log.info("messages:{}", FastJsonUtil.toJSONString(messages));
+
+        HashMap<String, Object> extraJson = new HashMap<>();
+        extraJson.put("temperature", 0.5);
+        extraJson.put("max_tokens", 3);
+
+        ChatCompletionRequest chatCompletionRequest = ChatCompletionRequest.builder()
+                .model(Constants.ModelChatGLM4)
+                .stream(Boolean.FALSE)
+                .invokeMethod(Constants.invokeMethod)
+                .messages(messages)
+                .build();
+
+        ClientV4 client = new ClientV4.Builder("3e1dc0e5cee1a8f0cc7b1fd01e5276c0.ueEh44nuymbAbUle")
+                .networkConfig(300, 100, 100, 100, TimeUnit.SECONDS)
+                .connectionPool(new okhttp3.ConnectionPool(8, 1, TimeUnit.SECONDS))
+                .build();
+
+        ModelApiResponse invokeModelApiResp = client.invokeModelApi(chatCompletionRequest);
+        log.info("model output: {}", FastJsonUtil.toJSONString(invokeModelApiResp));
+
+        String text = "";
+        if (invokeModelApiResp.isSuccess()) {
+            List<Choice> choices = invokeModelApiResp.getData().getChoices();
+            text = choices.get(0).getMessage().getContent().toString();
+        }
+        return Result.OK("OK", text);
+    }
+
 }

+ 6 - 5
jeecg-boot/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/okki/site/service/IFeiShuCommonService.java

@@ -742,11 +742,12 @@ public class IFeiShuCommonService {
         Client client = Client.newBuilder(configEnum.getAppId(), configEnum.getAppSecret()).build();
 
         Map<String, Object> map = new HashMap<>();
-        if ("remindCustomerMsg".equals(msgType)) {
-            map.put("text", msgText);
-        } else {
-            map.put("text", "<at user_id=\"" + userId + "\"></at> \n" + msgText);
-        }
+//        if ("remindCustomerMsg".equals(msgType)) {
+//            map.put("text", msgText);
+//        } else {
+//            map.put("text", "<at user_id=\"" + userId + "\"></at> \n" + msgText);
+//        }
+        map.put("text", msgText);
 
         // 创建请求对象
         CreateMessageReq req = CreateMessageReq.newBuilder()

+ 3 - 0
jeecg-boot/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/okki/wechatgroup/entity/OkkiShopWechatGroupMsg.java

@@ -96,4 +96,7 @@ public class OkkiShopWechatGroupMsg implements Serializable {
     @TableField(exist = false)
     private String from;
     /**消息接收方列表,可能是多个,同一个企业内容为userid,非相同企业为external_userid*/
+
+    @TableField(exist = false)
+    private String tcName;
 }

+ 14 - 6
jeecg-boot/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/okki/wechatgroup/mapper/xml/OkkiShopWechatGroupMsgMapper.xml

@@ -20,12 +20,16 @@
         SELECT
         t1.site_id,
         t1.from_id,
+        t1.content,
+        t1.client_id,
         t1.seq,
-        t1.msg_time
+        t1.msg_type,
+        t1.msg_time,
+        t3.tc_name
         FROM
         `okki_shop_wechat_group_msg` t1
-        INNER JOIN ( SELECT site_id, MAX( seq ) AS seq FROM `okki_shop_wechat_group_msg` GROUP BY site_id ) t2 ON t1.site_id = t2.site_id
-        AND t1.seq = t2.seq
+        INNER JOIN ( SELECT site_id, MAX( seq ) AS seq FROM `okki_shop_wechat_group_msg` GROUP BY site_id ) t2 ON t1.site_id = t2.site_id AND t1.seq = t2.seq
+        INNER JOIN ( SELECT site_id,tc_name FROM `okki_site` ) t3 ON t1.site_id = t3.site_id
         WHERE
         <if test="siteId != null and siteId != ''">
             t1.site_id = #{siteId} and
@@ -39,16 +43,20 @@
         SELECT
         t1.site_id,
         t1.from_id,
+        t1.content,
+        t1.client_id,
         t1.seq,
-        t1.msg_time
+        t1.msg_type,
+        t1.msg_time,
+        t3.tc_name
         FROM
         `okki_shop_wechat_group_msg` t1
         INNER JOIN (
         SELECT site_id, MAX(seq) AS seq
         FROM `okki_shop_wechat_group_msg`
         GROUP BY site_id
-        ) t2 ON t1.site_id = t2.site_id
-        AND t1.seq = t2.seq
+        ) t2 ON t1.site_id = t2.site_id AND t1.seq = t2.seq
+        INNER JOIN ( SELECT site_id,tc_name FROM `okki_site` ) t3 ON t1.site_id = t3.site_id
         WHERE
         <if test="days != null">
             <![CDATA[ t1.msg_time < NOW() - INTERVAL #{days} DAY ]]>

+ 27 - 2
jeecg-boot/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/okki/wechatgroup/service/impl/OkkiShopWechatGroupMsgServiceImpl.java

@@ -343,9 +343,11 @@ public class OkkiShopWechatGroupMsgServiceImpl extends ServiceImpl<OkkiShopWecha
                         finalI + 1, currentSiteId, companyName, zhName, feiShuGroupId);
 
                 String msgType = "remindCustomerMsg";
+                String exceptionMsg = "";
                 String msgText = "";
                 if (days != null) {
-                    msgText = "我们注意到【" + companyName + "】的企业微信群已连续" + days + "天没有消息更新。最后一条消息的记录时间为" + DateUtil.format(okkiShopWechatGroupMsg.getMsgTime(), DatePattern.CHINESE_DATE_TIME_FORMATTER) + "。为了确保我们服务的高效性,请大家保持微信群内消息的畅通。特别是当收到客户提问或寻求帮助时,请务必及时回应,以提升我们的服务质量和效率。感谢配合!";
+//                    msgText = "我们注意到【" + companyName + "】的企业微信群已连续" + days + "天没有消息更新。最后一条消息的记录时间为" + DateUtil.format(okkiShopWechatGroupMsg.getMsgTime(), DatePattern.CHINESE_DATE_TIME_FORMATTER) + "。为了确保我们服务的高效性,请大家保持微信群内消息的畅通。特别是当收到客户提问或寻求帮助时,请务必及时回应,以提升我们的服务质量和效率。感谢配合!";
+                    exceptionMsg = "已连续" + days + "天没有消息更新";
                 }
 
                 if (hours != null) {
@@ -353,9 +355,32 @@ public class OkkiShopWechatGroupMsgServiceImpl extends ServiceImpl<OkkiShopWecha
                     if (hours == 0.5) {
                         hourStr = "30分钟";
                     }
-                    msgText = "我们注意到【" + companyName + "】的企业微信群中,客户发送的消息已超过" + hourStr + "未得到回复。最后一条消息的记录时间为" + DateUtil.format(okkiShopWechatGroupMsg.getMsgTime(), DatePattern.CHINESE_DATE_TIME_FORMATTER) + "。请及时回复客户消息,以确保服务的及时性和质量!";
+//                    msgText = "我们注意到【" + companyName + "】的企业微信群中,客户发送的消息已超过" + hourStr + "未得到回复。最后一条消息的记录时间为" + DateUtil.format(okkiShopWechatGroupMsg.getMsgTime(), DatePattern.CHINESE_DATE_TIME_FORMATTER) + "。请及时回复客户消息,以确保服务的及时性和质量!";
+                    exceptionMsg = "未回复客户消息超过" + hourStr;
                 }
 
+                StringBuilder sb = new StringBuilder();
+                sb.append("<b>Production:###OKKI建站企微群异常通知</b> ");
+                sb.append("\n");
+                sb.append("<b>企业名称:</b> ").append(companyName);
+                sb.append("\n");
+                sb.append("<b>Client Id:</b> ").append(okkiShopWechatGroupMsg.getClientId());
+                sb.append("\n");
+                sb.append("<b>异常类型:</b> ").append(exceptionMsg);
+                sb.append("\n");
+                sb.append("<b>商家套餐:</b> ").append(okkiShopWechatGroupMsg.getTcName());
+                sb.append("\n");
+                sb.append("<b>服务顾问:</b> ").append(zhName);
+                sb.append("\n");
+
+                String content = "请看企微群消息";
+                if ("text".equals(okkiShopWechatGroupMsg.getMsgType())) {
+                    content = okkiShopWechatGroupMsg.getContent();
+                }
+                sb.append("<b>最后一条消息:</b> ").append(content);
+                msgText = sb.toString();
+                log.info("msgText:{}", msgText);
+
                 // todo 测试使用
 //                feiShuGroupId = "oc_184b7dbca30579372652f5cef04ae645";
                 if (StringUtils.isNotBlank(feiShuGroupId)) {

+ 1 - 1
jeecg-boot/pom.xml

@@ -64,7 +64,7 @@
 		<aliyun.oss.version>3.11.2</aliyun.oss.version>
 		<!-- shiro -->
 		<shiro.version>1.12.0</shiro.version>
-		<java-jwt.version>3.11.0</java-jwt.version>
+		<java-jwt.version>4.4.0</java-jwt.version>
 		<shiro-redis.version>3.2.2</shiro-redis.version>
 		<codegenerate.version>1.4.7</codegenerate.version>
 		<autopoi-web.version>1.4.7</autopoi-web.version>