Explorar o código

知识库积分部分功能提交,积分查询功能调整

徐滕 hai 4 semanas
pai
achega
ca8247977d

+ 11 - 4
src/main/java/com/jeeplus/modules/WorkKnowledgeBase/dao/WorkKnowledgeBasePointDetailDao.java

@@ -5,6 +5,7 @@ import com.jeeplus.common.persistence.annotation.MyBatisDao;
 import com.jeeplus.modules.WorkKnowledgeBase.entity.UserPointDetail;
 import com.jeeplus.modules.WorkKnowledgeBase.entity.WorkKnowledgeBasePoint;
 import com.jeeplus.modules.WorkKnowledgeBase.entity.WorkKnowledgeBasePointDetail;
+import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
 
@@ -27,7 +28,13 @@ public interface WorkKnowledgeBasePointDetailDao extends CrudDao<WorkKnowledgeBa
 
     /** 某用户积分明细总数 */
     int findUserPointDetailCount(UserPointDetail userPointDetail);
-    
+
+    /** 根据用户ID和分类ID(含子节点)统计积分总和 */
+    int sumUserPointByColumnId(
+        @Param("userId") String userId,
+        @Param("columnId") String columnId
+    );
+
     /**
      * 物理删除指定条件的积分记录(用于取消点赞时删除)
      * @param userId 用户ID(积分接收人)
@@ -35,8 +42,8 @@ public interface WorkKnowledgeBasePointDetailDao extends CrudDao<WorkKnowledgeBa
      * @param changeType 变动类型(4=点赞积分)
      */
     void deleteByUserIdAndShareIdAndChangeType(
-        @org.apache.ibatis.annotations.Param("userId") String userId,
-        @org.apache.ibatis.annotations.Param("shareId") String shareId,
-        @org.apache.ibatis.annotations.Param("changeType") Integer changeType
+        @Param("userId") String userId,
+        @Param("shareId") String shareId,
+        @Param("changeType") Integer changeType
     );
 }

+ 9 - 0
src/main/java/com/jeeplus/modules/WorkKnowledgeBase/entity/UserPointDetail.java

@@ -52,6 +52,7 @@ public class UserPointDetail extends DataEntity<UserPointDetail> {
     private Date beginDate;
     private Date endDate;
     private String userName;
+    private String columnId;
 
     public String getId() {
         return id;
@@ -172,4 +173,12 @@ public class UserPointDetail extends DataEntity<UserPointDetail> {
     public void setUserName(String userName) {
         this.userName = userName;
     }
+
+    public String getColumnId() {
+        return columnId;
+    }
+
+    public void setColumnId(String columnId) {
+        this.columnId = columnId;
+    }
 }

+ 10 - 0
src/main/java/com/jeeplus/modules/WorkKnowledgeBase/service/WorkKnowledgeBasePointDetailService.java

@@ -90,4 +90,14 @@ public class WorkKnowledgeBasePointDetailService extends CrudService<WorkKnowled
         }*/
         return page;
     }
+
+    /**
+     * 根据用户ID和分类ID(含子节点)统计积分总和
+     * @param userId 用户ID
+     * @param columnId 分类ID(对应 work_knowledge_point_category.id)
+     * @return 积分总和
+     */
+    public int sumUserPointByColumnId(String userId, String columnId) {
+        return pointDetailDao.sumUserPointByColumnId(userId, columnId);
+    }
 }

+ 6 - 0
src/main/java/com/jeeplus/modules/WorkKnowledgeBase/web/WorkKnowledgeBasePointController.java

@@ -154,9 +154,15 @@ public class WorkKnowledgeBasePointController extends BaseController {
         if (StringUtils.isBlank(userPointDetail.getUserId())) {
             model.addAttribute("message", "用户ID不能为空");
         }
+        if (StringUtils.isBlank(userPointDetail.getColumnId())) {
+            userPointDetail.setColumnId("2");
+        }
         Page<UserPointDetail> page = workKnowledgeBasePointDetailService.findUserPointDetailPage(new Page<>(request, response), userPointDetail);
+        // 查询该用户在当前分类(含子节点)下的积分总和
+        int totalPoint = workKnowledgeBasePointDetailService.sumUserPointByColumnId(userPointDetail.getUserId(), userPointDetail.getColumnId());
         model.addAttribute("page", page);
         model.addAttribute("userPointDetail", userPointDetail);
+        model.addAttribute("totalPoint", totalPoint);
         return "modules/WorkKnowledgeBase/workKnowledgeBasePointUserDetail";
     }
 

+ 22 - 0
src/main/resources/mappings/modules/WorkKnowledgeBase/WorkKnowledgeBasePointDetailDao.xml

@@ -230,6 +230,10 @@
             <if test="ruleType != null">
                 AND r.rule_type = #{ruleType}
             </if>
+            <!-- 按积分分类节点及其所有子节点筛选 -->
+            <if test="columnId != null and columnId != ''">
+                AND (d.category_id = #{columnId} OR c.parent_ids LIKE CONCAT('%,', #{columnId}, ',%'))
+            </if>
             <!-- 正确日期查询:使用 DATE() 函数 + 直接传 Date 类型 -->
             <if test="beginDate != null">
                 AND d.create_date &gt;= #{beginDate}
@@ -266,6 +270,10 @@
             <if test="ruleType != null">
                 AND r.rule_type = #{ruleType}
             </if>
+            <!-- 按积分分类节点及其所有子节点筛选 -->
+            <if test="columnId != null and columnId != ''">
+                AND (d.category_id = #{columnId} OR c.parent_ids LIKE CONCAT('%,', #{columnId}, ',%'))
+            </if>
             <!-- 正确日期查询:使用 DATE() 函数 + 直接传 Date 类型 -->
             <if test="beginDate != null">
                 AND d.create_date &gt;= #{beginDate}
@@ -276,6 +284,20 @@
         </where>
     </select>
     
+    <!-- 根据用户ID和分类ID(含子节点)统计积分总和 -->
+    <select id="sumUserPointByColumnId" resultType="java.lang.Integer">
+        SELECT COALESCE(SUM(d.point), 0)
+        FROM work_knowledge_base_point_detail d
+        LEFT JOIN work_knowledge_point_category c ON c.id = d.category_id AND c.del_flag = '0'
+        <where>
+            d.del_flag = '0'
+            AND d.user_id = #{userId}
+            <if test="columnId != null and columnId != ''">
+                AND (d.category_id = #{columnId} OR c.parent_ids LIKE CONCAT('%,', #{columnId}, ',%'))
+            </if>
+        </where>
+    </select>
+
     <!-- 物理删除指定条件的积分记录(用于取消点赞时删除) -->
     <delete id="deleteByUserIdAndShareIdAndChangeType">
         DELETE FROM work_knowledge_base_point_detail

+ 204 - 177
src/main/webapp/webpage/modules/WorkKnowledgeBase/workKnowledgeBasePointUserDetail.jsp

@@ -1,189 +1,216 @@
 <%@ page contentType="text/html;charset=UTF-8" %>
 <%@ include file="/webpage/include/taglib.jsp"%>
 <html>
-<body>
-<div class="wrapper wrapper-content">
-    <sys:message content="${message}"/>
-    <div class="layui-row">
-        <!-- 查询条件 -->
-        <div class="full-width fl">
-            <div class="contentShadow layui-row" id="queryDiv">
-                <form id="searchForm" action="${ctx}/workKnowledgeBase/point/userDetail" method="post" class="form-inline">
-                    <input type="hidden" name="userId" value="${userPointDetail.userId}"/>
-                    <input type="hidden" name="userName" value="${userPointDetail.userName}"/>
-                    <input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
-                    <input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
-                    <div class="commonQuery lw7">
-                        <div class="layui-item query athird" style="width: 25%">
-                            <label class="layui-form-label">文档名称:</label>
-                            <div class="layui-input-block with-icon">
-                                <input type="text" name="shareName" value="${userPointDetail.shareName}"
-                                       placeholder="文档名模糊查询" class="form-control layui-input"/>
-                            </div>
-                        </div>
-                        <%--<div class="layui-item query athird" style="width: 25%">
-                            <label class="layui-form-label">积分来源:</label>
-                            <div class="layui-input-block">
-                                <input type="text" name="categoryName" value="${userPointDetail.categoryName}"
-                                       placeholder="分类名称模糊查询" class="form-control layui-input"/>
-                            </div>
-                        </div>--%>
-                        <div class="layui-item query athird" style="width: 25%">
-                            <label class="layui-form-label">获取方式:</label>
-                            <div class="layui-input-block">
-                                <select name="ruleType" class="form-control layui-input">
-                                    <option value="">全部</option>
-                                    <option value="1" ${userPointDetail.ruleType == 1 ? 'selected' : ''}>创建</option>
-                                    <option value="2" ${userPointDetail.ruleType == 2 ? 'selected' : ''}>审核</option>
-                                    <option value="10" ${userPointDetail.ruleType == 10 ? 'selected' : ''}>阅读</option>
-                                    <option value="20" ${userPointDetail.ruleType == 20 ? 'selected' : ''}>点赞</option>
-                                </select>
-                            </div>
-                        </div>
-
-                        <div class="layui-item query athird " style="width: 25%">
-                            <label class="layui-form-label">获取时间:</label>
-                            <div class="layui-input-block">
-                                <input id="beginDate" name="beginDate" placeholder="开始时间" type="text" readonly="readonly" maxlength="20" class="laydate-icondate form-control layer-date layui-input laydate-icon query-group"
-                                       value="<fmt:formatDate value="${userPointDetail.beginDate}" pattern="yyyy-MM-dd"/>"/>
-                                </input>
-                                <span class="group-sep">-</span>
-                                <input id="endDate" name="endDate" placeholder="结束时间" type="text" readonly="readonly" maxlength="20" class="laydate-icondate form-control layer-date layui-input laydate-icon query-group"
-                                       value="<fmt:formatDate value="${userPointDetail.endDate}" pattern="yyyy-MM-dd"/>"/>
-                                </input>
-                            </div>
-                        </div>
-
+<head>
+	<title>积分明细</title>
+	<meta name="decorator" content="default"/>
+	<script type="text/javascript" src="${ctxStatic}/ckeditor/ckeditor.js"></script>
+	<script type="text/javascript">
+		$(document).ready(function() {
+			var columnId = $("#columnId").val();
+			$(".list-tabs li").each(function(){
+				$(this).removeAttr("class","active");
+				var id='#'+$(this).find("span").html();
+				$(id).attr("class","hide");
+				if($(this).val() == columnId){
+					$(this).attr("class","active");
+					var id='#'+$(this).find("span").html();
+					$(id).removeAttr("class","hide");
+				}
+				$("#columnId").val(columnId)
+			})
 
-                        <div class="layui-item athird" style="width: 25%">
-                            <div class="input-group">
-                                <div class="layui-btn-group search-spacing">
-                                    <button id="searchQuery" class="layui-btn layui-btn-sm layui-bg-blue" onclick="return search()">查询</button>
-                                    <button id="searchReset" type="button" class="layui-btn layui-btn-sm" onclick="resetSearch()">重置</button>
-                                </div>
-                            </div>
-                        </div>
-                        <div style="clear:both;"></div>
-                    </div>
-                </form>
-            </div>
-        </div>
+			$(".list-tabs li").click(function(){
+				$(".list-tabs li").each(function(){
+					$(this).removeAttr("class","active");
+					var id='#'+$(this).find("span").html();
+					$(id).attr("class","hide");
+				})
+				$(this).attr("class","active");
+				var id='#'+$(this).find("span").html();
+				$(id).removeAttr("class","hide");
 
-        <!-- 表格 + 分页 -->
-        <div class="full-width fl">
-            <div class="contentShadow layui-form contentDetails">
-                <table class="oa-table layui-table" id="contentTable"></table>
-                <table:page page="${page}"></table:page>
-                <div style="clear:both;"></div>
-            </div>
-        </div>
-    </div>
-</div>
-</body>
-<head>
-    <title>积分明细</title>
-    <meta name="decorator" content="default"/>
-    <script type="text/javascript" src="${ctxStatic}/layer-v2.3/layui/layui.all.js" charset="utf-8"></script>
-    <script type="text/javascript">
-        $(document).ready(function() {
-            // 日期选择器
-            layui.use('laydate', function() {
-                var laydate = layui.laydate;
-                laydate.render({elem: '#beginDate', event: 'focus', type: 'date', format: 'yyyy-MM-dd', trigger: 'click'});
-                laydate.render({elem: '#endDate', event: 'focus', type: 'date', format: 'yyyy-MM-dd', trigger: 'click'});
-            });
+				$("#columnId").val($(this).val())
+				$("#searchForm").submit();
+			})
 
-            // 表格渲染
-            layui.use('table', function() {
-                layui.table.render({
-                    limit: ${page.pageSize},
-                    id: 'pointDetailTable',
-                    elem: '#contentTable',
-                    page: false,
-                    cols: [[
-                        {field: 'index', align: 'center', width: 60, title: '序号'},
-                        {field: 'shareName', align: 'center', title: '文档名称', minWidth: 240, templet: function(d) {
-                            var nm = d.shareName || '';
-                            var sid = d.shareId || '';
-                            // 文档已被删除(物理或逻辑)
-                            if (!sid) {
-                                return '<span style="color:#999;">(无关联文档)</span>';
-                            }
-                            if (d.shareDelFlag === '1' || !nm) {
-                                return '<span style="color:#999;">' + (nm || '(已删除文档)') + '</span>';
-                            }
-                            return '<a href="javascript:void(0)" class="attention-info" onclick="openShareDetail(\'' + sid + '\',\'' + (d.treeNodeId || '') + '\')">' + nm + '</a>';
-                        }},
-                        {field: 'categoryName', align: 'center', title: '来源', width: 140, templet: function(d) {
-                            return d.categoryName || '-';
-                        }},
-                        {field: 'ruleType', align: 'center', title: '获取方式', width: 110, templet: function(d) {
-                            var rt = parseInt(d.ruleType);
-                            if (rt === 1) return '<span class="layui-badge layui-bg-blue">创建</span>';
-                            if (rt === 2) return '<span class="layui-badge layui-bg-green">审核</span>';
-                            if (rt === 10) return '<span class="layui-badge layui-bg-orange">阅读</span>';
-                            if (rt === 20) return '<span class="layui-badge layui-bg-red">点赞</span>';
-                            return '-';
-                        }},
-                        {field: 'point', align: 'center', title: '积分额度', width: 100, templet: function(d) {
-                            return '<span style="color:#1aa094;font-weight:bold;">+' + (d.point || 0) + '</span>';
-                        }},
-                        {field: 'createDate', align: 'center', title: '时间', width: 170}
-                    ]],
-                    data: [
-                        <c:choose>
-                            <c:when test="${not empty page.list}">
-                                <c:forEach items="${page.list}" var="row" varStatus="st">
-                                    <c:if test="${st.index != 0}">,</c:if>
-                                    {
-                                        "index": "${st.index + 1 + (page.pageNo - 1) * page.pageSize}"
-                                        ,"id": "${row.id}"
-                                        ,"shareId": "${row.shareId}"
-                                        ,"shareName": "<c:out value='${row.shareName}'/>"
-                                        ,"treeNodeId": "${row.treeNodeId}"
-                                        ,"shareDelFlag": "${row.shareDelFlag}"
-                                        ,"categoryId": "${row.categoryId}"
-                                        ,"ruleId": "${row.ruleId}"
-                                        ,"categoryName": "<c:out value='${row.categoryName}'/>"
-                                        ,"ruleType": "${row.ruleType}"
-                                        ,"point": "${row.point}"
-                                        ,"createDate": "<fmt:formatDate value="${row.createDate}" pattern="yyyy-MM-dd"/>"
-                                    }
-                                </c:forEach>
-                            </c:when>
-                            <c:otherwise></c:otherwise>
-                        </c:choose>
-                    ]
-                });
-            });
-        });
 
-        /** 跳转到文档详情 */
-        function openShareDetail(shareId, treeNodeId) {
-            top.layer.open({
-                type: 2,
-                area: ['80%', '80%'],
-                title: '文件详情',
-                maxmin: true,
-                content: '${ctx}/workKnowledgeBase/share/detail?id=' + shareId + (treeNodeId ? '&treeNodeId=' + treeNodeId : ''),
-                btn: ['关闭'],
-                btn1: function(index) { top.layer.close(index); }
-            });
-        }
+			// 初始化创建时间 laydate 日期选择器
+			layui.use('laydate', function() {
+				var laydate = layui.laydate;
+				laydate.render({
+					elem: '#beginDate',
+					event: 'focus',
+					type: 'date',
+					format: 'yyyy-MM-dd',
+					trigger: 'click'
+				});
+				laydate.render({
+					elem: '#endDate',
+					event: 'focus',
+					type: 'date',
+					format: 'yyyy-MM-dd',
+					trigger: 'click'
+				});
+			});
+		});
 
-        function search() { $('#searchForm').submit(); return false; }
-        function resetSearch() {
-            $('#searchForm input[type=text]').val('');
-            $('#searchForm select').val('');
-            $('#searchForm').submit();
-        }
+		/** 跳转到文档详情 */
+		function openShareDetail(shareId, treeNodeId) {
+			top.layer.open({
+				type: 2,
+				area: ['80%', '80%'],
+				title: '文件详情',
+				maxmin: true,
+				content: '${ctx}/workKnowledgeBase/share/detail?id=' + shareId + (treeNodeId ? '&treeNodeId=' + treeNodeId : ''),
+				btn: ['关闭'],
+				btn1: function(index) { top.layer.close(index); }
+			});
+		}
 
-        resizeListWindow1 = function() {
-            var height = $(window).height() - 10;
-            $('body').css('min-height', height + 'px');
-        };
-        $(window).resize(function() { resizeListWindow1(); });
-    </script>
+		function search() { $('#searchForm').submit(); return false; }
+		function resetSearch() {
+			$('#searchForm input[type=text]').val('');
+			$('#searchForm select').val('');
+			$('#searchForm').submit();
+		}
+	</script>
 </head>
+<body>
+<div class="wrapper wrapper-content">
+	<sys:message content="${message}"/>
+	<div class="list-form-tab contentShadow shadowLTR" id="tabDiv">
+		<ul class="list-tabs" >
+			<li value="2"><a>贡献积分</a></li>
+			<li value="1"><a>基础积分</a></li>
+		</ul>
+	</div>
+	<div class="layui-row">
+		<div class="full-width fl">
+			<div class="contentShadow layui-row" id="queryDiv">
+				<form id="searchForm" action="${ctx}/workKnowledgeBase/point/userDetail" method="post" class="form-inline">
+					<input type="hidden" name="userId" value="${userPointDetail.userId}"/>
+					<input type="hidden" name="userName" value="${userPointDetail.userName}"/>
+					<input id="columnId" name="columnId" type="hidden" value="${userPointDetail.columnId}"/>
+					<input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
+					<input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
+					<div class="commonQuery">
+						<div class="layui-item query athird">
+							<label class="layui-form-label">文档名称:</label>
+							<div class="layui-input-block with-icon">
+								<input type="text" name="shareName" value="${userPointDetail.shareName}"
+								       placeholder="文档名模糊查询" class="form-control layui-input"/>
+							</div>
+						</div>
+						<div class="layui-item query athird">
+							<label class="layui-form-label">获取时间:</label>
+							<div class="layui-input-block">
+								<input id="beginDate" name="beginDate" placeholder="开始时间" type="text" readonly="readonly" maxlength="20" class="laydate-icondate form-control layer-date layui-input laydate-icon query-group"
+								       value="<fmt:formatDate value="${userPointDetail.beginDate}" pattern="yyyy-MM-dd"/>"/>
+								<span class="group-sep">-</span>
+								<input id="endDate" name="endDate" placeholder="结束时间" type="text" readonly="readonly" maxlength="20" class="laydate-icondate form-control layer-date layui-input laydate-icon query-group"
+								       value="<fmt:formatDate value="${userPointDetail.endDate}" pattern="yyyy-MM-dd"/>"/>
+							</div>
+						</div>
+						<div class="layui-item athird">
+							<div class="input-group">
+								<div class="layui-btn-group search-spacing">
+									<button id="searchQuery" class="layui-btn layui-btn-sm layui-bg-blue" onclick="return search()">查询</button>
+									<button id="searchReset" type="button" class="layui-btn layui-btn-sm" onclick="resetSearch()">重置</button>
+								</div>
+							</div>
+						</div>
+						<div style="clear:both;"></div>
+					</div>
+				</form>
+			</div>
+		</div>
+		<div class="full-width fl">
+			<div class="contentShadow layui-form contentDetails">
+				<div class="nav-btns">
+					<span style="float:right;font-size:14px;color:#333;font-weight:bold;line-height:30px;">积分总和:<span style="color:#1aa094;font-size:16px;">${totalPoint}</span> 分</span>
+				</div>
+				<table class="oa-table layui-table" id="contentTable"></table>
+				<table:page page="${page}"></table:page>
+				<div style="clear: both;"></div>
+			</div>
+		</div>
+	</div>
+	<div id="changewidth"></div>
+</div>
+<script src="${ctxStatic}/layer-v2.3/layui/layui.all.js" charset="utf-8"></script>
+<script>
+	layui.use('table', function(){
+		layui.table.render({
+			limit:${ page.pageSize }
+			,id:"pointDetailTable"
+			,elem: '#contentTable'
+			,page: false
+			,cols: [[
+				{field:'index',align:'center', width:60,title: '序号'}
+				,{field:'shareName',align:'center', title: '文档名称', minWidth:240,templet:function(d){
+					var nm = d.shareName || '';
+					var sid = d.shareId || '';
+					// 文档已被删除(物理或逻辑)
+					if (!sid) {
+						return '<span style="color:#999;">(无关联文档)</span>';
+					}
+					if (d.shareDelFlag === '1' || !nm) {
+						return '<span style="color:#999;">' + (nm || '(已删除文档)') + '</span>';
+					}
+					var xml = '<a class="attention-info" href="javascript:void(0)" onclick="openShareDetail(\'' + sid + '\',\'' + (d.treeNodeId || '') + '\')">' + nm + '</a>';
+					return xml;
+				}}
+				,{field:'categoryName',align:'center', title: '来源', width:140,templet:function(d){
+					return d.categoryName || '-';
+				}}
+				,{field:'ruleType',align:'center', title: '获取方式', width:110,templet:function(d){
+					var rt = parseInt(d.ruleType);
+					if (rt === 1) return '<span class="layui-badge layui-bg-blue">创建</span>';
+					if (rt === 2) return '<span class="layui-badge layui-bg-green">审核</span>';
+					if (rt === 10) return '<span class="layui-badge layui-bg-orange">阅读</span>';
+					if (rt === 20) return '<span class="layui-badge layui-bg-red">点赞</span>';
+					return '-';
+				}}
+				,{field:'point',align:'center', title: '积分额度', width:100,templet:function(d){
+					return '<span style="color:#1aa094;font-weight:bold;">+' + (d.point || 0) + '</span>';
+				}}
+				,{field:'createDate',align:'center', title: '时间', width:170}
+			]]
+			,data: [
+				<c:choose>
+					<c:when test="${not empty page.list}">
+						<c:forEach items="${page.list}" var="row" varStatus="st">
+							<c:if test="${st.index != 0}">,</c:if>
+							{
+								"index": "${st.index + 1 + (page.pageNo - 1) * page.pageSize}"
+								,"id": "${row.id}"
+								,"shareId": "${row.shareId}"
+								,"shareName": "<c:out value='${row.shareName}'/>"
+								,"treeNodeId": "${row.treeNodeId}"
+								,"shareDelFlag": "${row.shareDelFlag}"
+								,"categoryId": "${row.categoryId}"
+								,"ruleId": "${row.ruleId}"
+								,"categoryName": "<c:out value='${row.categoryName}'/>"
+								,"ruleType": "${row.ruleType}"
+								,"point": "${row.point}"
+								,"createDate": "<fmt:formatDate value="${row.createDate}" pattern="yyyy-MM-dd"/>"
+							}
+						</c:forEach>
+					</c:when>
+					<c:otherwise></c:otherwise>
+				</c:choose>
+			]
+		});
+	});
 
+	resizeListWindow1();
+</script>
+<script>
+	resizeListWindow1();
+	$(window).resize(function () {
+		resizeListWindow1();
+	});
+</script>
+</body>
 </html>