瀏覽代碼

移动端AI对话界面开发

huangguoce 2 天之前
父節點
當前提交
c14ffd1e85

+ 2 - 1
src/main/java/com/jeeplus/common/security/shiro/session/SessionManager.java

@@ -80,7 +80,8 @@ public class SessionManager extends DefaultWebSessionManager {
     		return super.getStartTimestamp(key);
     	}catch (InvalidSessionException e) {
     		// 获取不到SESSION不抛出异常
-        	return null;
+        	//return null;
+			return new Date();
 		}
     }
 

+ 1 - 1
src/main/java/com/jeeplus/modules/knowledgeSharing/dify/DifyApiClient.java

@@ -40,7 +40,7 @@ public class DifyApiClient {
 
     //开发
     private static final String API_KEY = "dataset-TinelGDdnlrXJPyFe38iA0Zh";
-    private static final String API_URL = "http://3081089em4.wicp.vip:20667/v1/datasets";
+    private static final String API_URL = "http://3081089em4.wicp.vip:28499/v1/datasets";
 
 
 

+ 65 - 3
src/main/java/com/jeeplus/modules/knowledgeSharing/web/KnowledgeBaseController.java

@@ -4,10 +4,9 @@ import com.fasterxml.jackson.databind.ObjectMapper;
 import com.jeeplus.common.persistence.Page;
 import com.jeeplus.common.utils.StringUtils;
 import com.jeeplus.modules.knowledgeSharing.dify.DifyApiClient;
-import com.jeeplus.modules.knowledgeSharing.entity.KnowledgeBase;
-import com.jeeplus.modules.knowledgeSharing.entity.KnowledgeBaseDoc;
-import com.jeeplus.modules.knowledgeSharing.entity.KnowledgeBaseDocContent;
+import com.jeeplus.modules.knowledgeSharing.entity.*;
 import com.jeeplus.modules.knowledgeSharing.service.KnowledgeBaseService;
+import com.jeeplus.modules.knowledgeSharing.service.KnowledgeSharingTypeService;
 import com.jeeplus.modules.sys.utils.UserUtils;
 import org.apache.commons.fileupload.servlet.ServletFileUpload;
 import org.apache.shiro.authz.annotation.Logical;
@@ -41,6 +40,9 @@ public class KnowledgeBaseController {
     @Autowired
     private KnowledgeBaseService service;
 
+    @Autowired
+    private KnowledgeSharingTypeService typeService;
+
     /**
      * 知识库列表
      */
@@ -52,6 +54,66 @@ public class KnowledgeBaseController {
         return "modules/knowledgeSharing/knowledgeBaseList";
     }
 
+    /**
+     * Ai移动端展示列表
+     * @param knowledgeSharingInfo
+     * @param request
+     * @param model
+     * @return
+     */
+    @RequestMapping(value = {"mobileList"})
+    public String mobileList(KnowledgeSharingInfo knowledgeSharingInfo, HttpServletRequest request, Model model) {
+        List<KnowledgeSharingTypeInfo> typeInfoList = typeService.findList(new KnowledgeSharingTypeInfo());
+        model.addAttribute("typeInfoList", typeInfoList);
+        return "modules/knowledgeSharing/knowledgeBaseMobile";
+    }
+
+
+    /**
+     * 打开对应的ai页面
+     * @param knowledgeSharingInfo
+     * @param request
+     * @param response
+     * @param model
+     * @return
+     * @throws Exception
+     */
+    @RequestMapping(value = {"openChatPage"})
+    public String openChatPage(KnowledgeSharingInfo knowledgeSharingInfo, HttpServletRequest request, HttpServletResponse response, Model model) throws Exception {
+
+        String difySrc = "http://3081089em4.wicp.vip:28499/chatbot/";
+
+        model.addAttribute("columnId", knowledgeSharingInfo.getColumnId());
+        model.addAttribute("difySrc", difySrc + "LlXD0YzBLGPKBlqb");
+        //根据不同的栏目id 跳转不同的dify聊天窗口
+        if (StringUtils.isNotBlank(knowledgeSharingInfo.getColumnId())) {
+            switch (knowledgeSharingInfo.getColumnId()){
+                case "1":   //学习园地
+                    model.addAttribute("difySrc", difySrc + "6A7qteLy6CtDSHVf");
+                    break;
+                case "9":   //国家标准及规范
+                    model.addAttribute("difySrc", difySrc + "2NV1GQvNY9IxM1lA");
+                    break;
+                case "7":   //行业标准及规范
+                    model.addAttribute("difySrc", difySrc + "vKk88XwbCBfgaiQH");
+                    break;
+                case "8":   //公司内部发文和通知
+                    model.addAttribute("difySrc", difySrc + "V7fLUXpZ4w73ftgG");
+                    break;
+                case "2":   //请教专家
+                    model.addAttribute("difySrc", difySrc + "jpxMOy6u9zXQ5Uuz");
+                    break;
+                case "6":   //案例讨论
+                    model.addAttribute("difySrc", difySrc + "LzY2NuohCsayFwmG");
+                    break;
+                default:
+                    model.addAttribute("difySrc", difySrc + "LlXD0YzBLGPKBlqb");
+                    break;
+            }
+        }
+        return "modules/knowledgeSharing/knowledgeBaseMobileDify";
+    }
+
 
     /**
      * 查看知识库数据

+ 5 - 0
src/main/resources/spring-context-shiro.xml

@@ -17,6 +17,8 @@
                 /static/** = anon
                 /userfiles/** = anon
                 ${adminPath}/redis/** = anon
+                ${adminPath}/knowledgeBase/knowledgeBase/mobileList = anon
+                ${adminPath}/knowledgeBase/knowledgeBase/openChatPage = anon
                 ${adminPath}/clockInRecordController/** = anon
                 ${adminPath}/hrUserController/** = anon
                 ${adminPath}/ccpmList/ccpmList/** = anon
@@ -58,6 +60,7 @@
                 ${adminPath}/login = authc
                 ${adminPath}/logout = anon
                 ${adminPath}/** = user
+
                 ${frontPath}/login = authcMobile
                 ${frontPath}/logout = anon
                 ${frontPath}/registerUser = anon
@@ -71,6 +74,8 @@
                 /act/rest/service/model/** = perms[act:model:edit]
                 /act/rest/service/** = user
                 /ReportServer/** = user
+
+
             </value>
         </constructor-arg>
     </bean>

+ 130 - 0
src/main/webapp/webpage/modules/knowledgeSharing/knowledgeBaseMobile.jsp

@@ -0,0 +1,130 @@
+<%@ page contentType="text/html;charset=UTF-8" %>
+<%@ include file="/webpage/include/taglib.jsp" %>
+<html>
+<head>
+    <title>知识库分类</title>
+    <meta name="decorator" content="default"/>
+    <script type="text/javascript" src="${ctxStatic}/ckeditor/ckeditor.js"></script>
+    <style>
+        html {
+            font-size: 16px;
+            background: #f5f5f5;
+        }
+        body{
+            background: #f5f5f5;
+
+        }
+
+        .dify-box {
+            width: 100%;
+            min-height: 10rem;
+            display: flex;
+            justify-content: center;
+            align-items: center;
+            padding: 6px 10px;
+            box-sizing: border-box;
+        }
+
+        .dify-item {
+            width: 100%;
+            min-height: 10rem;
+            height: 10rem;
+            background-color: #fff;
+            font-size: 2rem;
+            display: flex;
+            justify-content: center;
+            align-items: center;
+            border-radius: 6px;
+            user-select: none;
+            display: flex;
+            justify-content: space-between;
+            padding: 30px 30px;
+            box-sizing: border-box;
+        }
+
+        .dify-icon-left {
+            display: flex;
+            justify-content: center;
+            align-items: center;
+            height: 100%;
+            margin-right: 20px;
+        }
+
+
+
+        .dify-center {
+            height: 100%;
+            flex: 1;
+            display: flex;
+            align-items: center;
+            justify-content: flex-start;
+            background-color: #fff;
+        }
+
+        .dify-icon-right {
+            height: 100%;
+            display: flex;
+            justify-content: center;
+            align-items: center;
+        }
+
+        /* 当屏幕宽度小于600px时 */
+        @media screen and (max-width: 599px) {
+            html {
+                font-size: 14px;
+            }
+        }
+
+        /* 当屏幕宽度大于等于600px且小于1024px时 */
+        @media screen and (min-width: 600px) and (max-width: 1023px) {
+            html {
+                font-size: 16px;
+            }
+        }
+
+        /* 当屏幕宽度大于等于1024px时 */
+        @media screen and (min-width: 1024px) {
+            html {
+                font-size: 18px;
+            }
+        }
+    </style>
+</head>
+<body>
+<div class="wrapper wrapper-content" style="">
+    <form:form id="searchForm" modelAttribute="knowledgeSharingInfo" action="${ctx}/knowledgeBase/knowledgeBase/openChatPage"
+               method="post" class="form-inline">
+        <input id="columnId" name="columnId" type="hidden" value="${knowledgeSharingInfo.columnId}"/>
+        <div class="layui-row">
+            <div class="full-width fl">
+                <div class="layui-row">
+                    <c:forEach var="item" items="${typeInfoList}" varStatus="status">
+                        <div class="layui-col-xs12 layui-col-sm12 layui-col-md4">
+                            <div class="dify-box">
+                                <div class="dify-item" onclick="handleClick('${item.key}')">
+                                    <div class="dify-icon-left">
+                                        <i class="layui-icon" style="font-size: 54px; color: #1E9FFF;">&#xe63a;</i>
+                                    </div>
+                                    <div class="dify-center">${item.value}</div>
+                                    <div class="dify-icon-right">
+                                        <i class="layui-icon" style="font-size: 40px; color: #1E9FFF;">&#xe602;</i>
+                                    </div>
+                                </div>
+                            </div>
+                        </div>
+                    </c:forEach>
+                </div>
+            </div>
+        </div>
+    </form:form>
+</div>
+<script src="${ctxStatic}/layer-v2.3/layui/layui.all.js" charset="utf-8"></script>
+<script type="text/javascript">
+    // 打开ai聊天
+    function handleClick(columnId) {
+        document.getElementById("columnId").value = columnId;
+        document.getElementById("searchForm").submit();
+    }
+</script>
+</body>
+</html>

+ 21 - 0
src/main/webapp/webpage/modules/knowledgeSharing/knowledgeBaseMobileDify.jsp

@@ -0,0 +1,21 @@
+<%@ page contentType="text/html;charset=UTF-8" %>
+<%@ include file="/webpage/include/taglib.jsp" %>
+<html>
+<head>
+    <title>问答助手</title>
+    <meta name="decorator" content="default"/>
+    <script type="text/javascript" src="${ctxStatic}/ckeditor/ckeditor.js"></script>
+	<script  type="text/javascript">
+		window.onload = function () {
+			var difySrc = '${difySrc}';  // EL表达式输出成字符串
+			console.log(difySrc);
+			window.location.href = difySrc;
+		};
+	</script>
+</head>
+<body>
+<div class="wrapper wrapper-content">
+</div>
+<script src="${ctxStatic}/layer-v2.3/layui/layui.all.js" charset="utf-8"></script>
+</body>
+</html>