Parcourir la source

知识分享同步至dify的文件状态调整,添加手动同步按钮

huangguoce il y a 1 mois
Parent
commit
c98e1cd39a

+ 22 - 0
src/main/java/com/jeeplus/modules/knowledgeSharing/service/KnowledgeSharingDetailsService.java

@@ -333,6 +333,28 @@ public class KnowledgeSharingDetailsService extends CrudService<KnowledgeSharing
     }
 
     /**
+     * 将附件同步至dify
+     *
+     * @param knowledgeSharingInfo
+     */
+    @Transactional(readOnly = false)
+    @Async
+    public void changeSyncStatus(KnowledgeSharingInfo knowledgeSharingInfo) {
+        try {
+            //更新
+            KnowledgeSharingInfo dbInfo = get(knowledgeSharingInfo.getId());
+            MyBeanUtils.copyBeanNotNull2Bean(knowledgeSharingInfo, dbInfo);
+            knowledgeSharingInfo.setOffice(UserUtils.getSelectOffice());
+            knowledgeSharingInfo.setCompany(UserUtils.getSelectCompany());
+            knowledgeSharingInfo.setModerator("系统管理员");
+            knowledgeSharingInfo.setIsSync("1");
+            super.save(knowledgeSharingInfo);
+        } catch (Exception e) {
+            throw new RuntimeException("操作失败");
+        }
+    }
+
+    /**
      * 添加附件信息
      *
      * @param knowledgeSharingInfo

+ 20 - 0
src/main/java/com/jeeplus/modules/knowledgeSharing/web/KnowledgeSharingDetailsController.java

@@ -145,6 +145,26 @@ public class KnowledgeSharingDetailsController extends BaseController {
     }
 
     /**
+     * 只同步状态,不操作其他
+     *
+     * @param info
+     * @param model
+     * @return
+     * @throws Exception
+     */
+    @RequestMapping(value = "changeSyncStatus")
+    @ResponseBody
+    public Object changeSyncStatus(KnowledgeSharingInfo info, Model model) {
+        try{
+            service.changeSyncStatus(info);
+            model.addAttribute("success", true);
+        }catch(Exception e){
+            model.addAttribute("success", false);
+        }
+        return "redirect:" + Global.getAdminPath() + "/knowledgeSharingDetails/knowledgeSharingDetails/?repage";
+    }
+
+    /**
      * 查看页面
      */
     @RequiresPermissions(value = {"knowledgeSharing:knowledgeSharing:view"}, logical = Logical.OR)

+ 0 - 2
src/main/webapp/webpage/modules/knowledgeSharing/knowledgeSharingDetailsForm.jsp

@@ -144,9 +144,7 @@
                                 <th>文件预览</th>
                                 <th>上传人</th>
                                 <th>上传时间</th>
-                                <c:if test="${not empty knowledgeSharingInfo.id}">
                                     <th>同步状态</th>
-                                </c:if>
                                 <th width="200px">操作</th>
                             </tr>
                             </thead>

+ 71 - 19
src/main/webapp/webpage/modules/knowledgeSharing/knowledgeSharingDetailsList.jsp

@@ -142,6 +142,35 @@
 			});
 		}
 
+		function changeSyncStatus(title,id) {
+			layer.open({
+				title: title,
+				maxmin: true, //开启最大化最小化按钮
+				content: '确认手动操作同步状态?',
+				skin: 'two-btns',
+				btn: ['确定', '取消'],
+				btn1: function(index, layero){
+					$.ajax({
+						type: "post",
+						url: "${ctx}/knowledgeSharingDetails/knowledgeSharingDetails/changeSyncStatus?id=" + id,
+						success: function (res) {
+							parent.layer.msg('操作成功', { icon: 1 });
+							setTimeout(function () {
+								layer.close(index);
+								document.getElementById("refreshBtn").click();
+							}, 200);
+						},
+						error: function () {
+							parent.layer.msg('操作失败', { icon: 2 });
+						}
+					});
+				},
+				btn2: function (index) {
+				}
+			});
+		}
+
+
 
 		//打开对话框(查看)
 		function openDialogListView(title,url,width,height){
@@ -280,8 +309,10 @@
 				,{align:'center',title:"操作",width:150,templet:function(d){
 						////对操作进行初始化
 						var xml = "<div class=\"layui-btn-group\">";
-						if(  d.isAdmin == "1" && d.isSync == "0")
+						if(  (d.cansync != undefined && d.cansync == "1") && d.isSync == "0")
 							xml += "<a href=\"javascript:void(0)\" onclick=\"syncToDify('同步',  '"+d.id+"')\"   class=\"layui-btn layui-btn-xs layui-bg-blue\"> 同步</a>";
+						if(  (d.cansync != undefined && d.cansync == "1") && d.isSync == "0")
+							xml += "<a href=\"javascript:void(0)\" onclick=\"changeSyncStatus('手动同步',  '"+d.id+"')\"   class=\"layui-btn layui-btn-xs layui-bg-blue\"> 手动同步</a>";
 						if(d.canedit != undefined && d.canedit == "1")
 							xml += "<a href=\"javascript:void(0)\" onclick=\"openDialog('修改发帖信息', '${ctx}/knowledgeSharingDetails/knowledgeSharingDetails/form?id="+ d.id +"','95%', '95%')\"   class=\"layui-btn layui-btn-xs  layui-bg-green\"> 编辑</a>";
 						if((d.candelete != undefined && d.candelete == "1") || d.isAdmin == "1")
@@ -296,23 +327,44 @@
 				<c:forEach items="${page.list}" var="knowledgeSharingInfo" varStatus="index">
 				<c:if test="${index.index != 0}">,</c:if>
 				{
-					"index":"${index.index+1}"
-					,"id":"${knowledgeSharingInfo.id}"
-					,"columnId":"${knowledgeSharingInfo.columnId}"
-					,"subject":"${knowledgeSharingInfo.subject}"
-					,"columnName":"${fns:getMainDictLabel(knowledgeSharingInfo.columnId, 'column_name', '')}"
-					,"invitationCount":"${knowledgeSharingInfo.invitationCount}"
-					,"createBy":"${knowledgeSharingInfo.createBy.name}"
-					,"createDate":"<fmt:formatDate value="${knowledgeSharingInfo.createDate}" pattern="yyyy-MM-dd HH:mm:ss"/>"
-					,"moderator":"${knowledgeSharingInfo.moderator}"
-					,"lastPublish":"${knowledgeSharingInfo.lastPublish}"
-					,"readCount":"${knowledgeSharingInfo.readCount}"
-					,"replyCount":"${knowledgeSharingInfo.replyCount}"
-                    ,"isSync": "${knowledgeSharingInfo.isSync}"
-                    ,"isSyncText": "${knowledgeSharingInfo.isSync == '1' ? '<span class=\'layui-badge layui-bg-green\'>已同步</span>' : '<span class=\'layui-badge\'>未同步</span>'}"
-					,"isAdmin":"${knowledgeSharingInfo.isAdmin}"
-					<shiro:hasPermission name="knowledgeSharing:knowledgeSharing:edit">,"canedit":<c:choose><c:when test="${fns:getUser().id == knowledgeSharingInfo.createBy.id}">"1"</c:when><c:otherwise>"0"</c:otherwise></c:choose></shiro:hasPermission>
-					<shiro:hasPermission name="knowledgeSharing:knowledgeSharing:del">,"candelete":<c:choose><c:when test="${fns:getUser().id == knowledgeSharingInfo.createBy.id}">"1"</c:when><c:otherwise>"0"</c:otherwise></c:choose></shiro:hasPermission>
+					"index": "${index.index+1}"
+					,
+					"id": "${knowledgeSharingInfo.id}"
+					,
+					"columnId": "${knowledgeSharingInfo.columnId}"
+					,
+					"subject": "${knowledgeSharingInfo.subject}"
+					,
+					"columnName": "${fns:getMainDictLabel(knowledgeSharingInfo.columnId, 'column_name', '')}"
+					,
+					"invitationCount": "${knowledgeSharingInfo.invitationCount}"
+					,
+					"createBy": "${knowledgeSharingInfo.createBy.name}"
+					,
+					"createDate": "<fmt:formatDate value="${knowledgeSharingInfo.createDate}" pattern="yyyy-MM-dd HH:mm:ss"/>"
+					,
+					"moderator": "${knowledgeSharingInfo.moderator}"
+					,
+					"lastPublish": "${knowledgeSharingInfo.lastPublish}"
+					,
+					"readCount": "${knowledgeSharingInfo.readCount}"
+					,
+					"replyCount": "${knowledgeSharingInfo.replyCount}"
+					,
+					"isSync": "${knowledgeSharingInfo.isSync}"
+					,
+					"isSyncText": "${knowledgeSharingInfo.isSync == '1' ? '<span class=\'layui-badge layui-bg-green\'>已同步</span>' : '<span class=\'layui-badge\'>未同步</span>'}"
+					,
+					"isAdmin": "${knowledgeSharingInfo.isAdmin}"
+					<shiro:hasPermission name="knowledgeSharing:knowledgeSharing:edit">,
+					"canedit": <c:choose><c:when test="${fns:getUser().id == knowledgeSharingInfo.createBy.id}">"1"
+					</c:when><c:otherwise>"0"</c:otherwise></c:choose></shiro:hasPermission>
+					<shiro:hasPermission name="knowledgeSharing:knowledgeSharing:del">,
+					"candelete": <c:choose><c:when test="${fns:getUser().id == knowledgeSharingInfo.createBy.id}">"1"
+					</c:when><c:otherwise>"0"</c:otherwise></c:choose></shiro:hasPermission>
+					<shiro:hasPermission name="knowledgeSharing:knowledgeSharing:sync">,
+					"cansync": "1"</shiro:hasPermission>
+
 				}
 				</c:forEach>
 				</c:if>
@@ -327,7 +379,7 @@
 </script>
 <script>
 	resizeListWindow1();
-	$(window).resize(function(){
+	$(window).resize(function () {
 		resizeListWindow1();
 	});
 </script>