瀏覽代碼

网站考评计分规则修改

gt 3 年之前
父節點
當前提交
40d459803a

+ 19 - 2
nngkxxdp/src/main/java/com/example/nngkxxdp/dao/HlwInterfaceDao.java

@@ -22,19 +22,36 @@ public interface HlwInterfaceDao {
     Integer countColumnRelationByChnlid(@Param("chnlid") String chnlid);
 
     /**
-     * 获取栏目
+     * 获取栏目更新及其他信息
      * @param date
      * @return
      */
     List<Map<String, Object>> getAllColumn(@Param("date") String date);
 
     /**
-     * 统计各栏目文章数量大于1
+     * 统计各栏目文章数量大于1栏目ID及发文数量
      * @return
      */
     List<Map<String, Object>> countArticle(@Param("date") String date);
 
     /**
+     * 根据chnlid获取一段时间内的文章
+     * @param chnlid
+     * @param startDate
+     * @param endDate
+     * @return
+     */
+    List<Map<String, Object>> getArticleByChnlidAndDate(@Param("chnlid") String chnlid,
+                                                        @Param("startDate") String startDate,
+                                                        @Param("endDate") String endDate);
+
+    /**
+     * 根据栏目ID获取栏目名称
+     * @param chnlid
+     * @return
+     */
+    String getChnlNameByChnlid(@Param("chnlid") String chnlid);
+    /**
      * 更新column_relation的last_update字段
      * @return
      */

+ 160 - 94
nngkxxdp/src/main/java/com/example/nngkxxdp/util/WzkpRecordUtil.java

@@ -2,6 +2,7 @@ package com.example.nngkxxdp.util;
 
 import cn.hutool.core.convert.Convert;
 import cn.hutool.core.date.DateField;
+import cn.hutool.core.date.DateTime;
 import cn.hutool.core.date.DateUtil;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
@@ -23,10 +24,11 @@ public class WzkpRecordUtil {
     private HlwInterfaceDao hlwInterfaceDao;
 
     public void generateRecord(String date) {
+        if (date == null) {
+            date = DateUtil.format(new Date(), "yyyy-MM-dd");
+        }
         // 初始化部门分值
         List<Map<String, Object>> deptList = initDeptScore();
-        // 获取部门其他栏目
-        Map<String, String> deptOtherColumn = getDeptOtherColumn(deptList);
         // 获取事项规则
         List<Map<String, Object>> eventList = initEvent();
         // 获取事项规则组
@@ -58,32 +60,45 @@ public class WzkpRecordUtil {
                 }
                 // 获取超期标识
                 String isExceed = columnInfo.get(deptName + "-" + chnlid).toString();
-                // todo 两周内发文间隔大于14扣分,小于不扣分,拿需要2周内更新的规则专门匹配
                 // 超过更新时间
                 if ("1".equals(isExceed)) {
-                    // todo 区分基础栏目和其他栏目,其他栏目单独处理
                     // 循环加扣分规则
                     for (int k = 0; k < eventList.size(); k++) {
                         Map<String, Object> eventItem = eventList.get(k);
+                        String pId = eventItem.get("pId").toString();
                         if (!Convert.toBool(eventItem.get("type"))) {
                             continue;
                         }
+                        // 确定是哪一项规则扣分
                         List<String> list = Convert.toList(String.class, Convert.toStr(eventItem.get("chnlid").toString().split(","), ""));
                         if (list.contains(chnlid)) {
+                            // 是两周更新的规则
+                            if ("6".equals(pId)) {
+                                // 上个月的最后一天
+                                DateTime dateTime = DateUtil.offsetDay(DateUtil.parseDate(date).toJdkDate(), -1);
+                                String startDate = dateTime.toString("yyyy-MM") + "-01";
+                                Map<String, Object> map = getTwoWeekUpdateRecord(startDate, date, chnlid, pId, deptItem.get("deptid").toString(), eventItem, "sub");
+                                if (!map.isEmpty()) {
+                                    record.add(map);
+                                }
+                                continue;
+                            }
+
                             Map<String, Object> param = new HashMap<>();
-                            param.put("pId", eventItem.get("pId"));
+                            param.put("pId", pId);
 
                             param.put("type", eventItem.get("type"));
                             param.put("cloumnName", eventItem.get("target"));
                             param.put("deptId", deptItem.get("deptid"));
                             param.put("score", eventItem.get("score"));
                             param.put("date", Blank.isEmpty(date) ? cn.hutool.core.date.DateUtil.now() : cn.hutool.core.date.DateUtil.parse(date, "yyyy-MM-dd").offset(DateField.DAY_OF_MONTH, -1).toString("yyyy-MM-dd"));
-//							param.put("chnlid", chnlid);
+                            param.put("chnlid", chnlid);
 
                             record.add(param);
                         }
                     }
                 } else {
+                    // 加分
                     for (int k = 0; k < eventList.size(); k++) {
                         Map<String, Object> eventItem = eventList.get(k);
                         if (Convert.toBool(eventItem.get("type"))) {
@@ -100,18 +115,20 @@ public class WzkpRecordUtil {
                             Double maxScore = Convert.toDouble(eventItem.get("targetScore"));
                             String pId = Convert.toStr(eventItem.get("pId"));
                             // 动态要闻
-                            if ("26".equals(pId)) {
-                                if (addCount > 2) {
-                                    double scoreS = (addCount - 2) * score;
-                                    if (scoreS > 0) {
-                                        if (maxScore > scoreS) {
-                                            param.put("score", scoreS);
-                                        } else {
-                                            param.put("score", maxScore);
-                                        }
-                                    }
-                                }
-                            } else {
+                            if ("25".equals(pId)) {
+                                DateTime dateTime = DateUtil.offsetDay(DateUtil.parseDate(date).toJdkDate(), -1);
+                                String startDate = dateTime.toString("yyyy-MM") + "-01";
+                                Map<String, Object> map = getTwoWeekUpdateRecord(startDate, date, chnlid, pId, deptItem.get("deptid").toString(), eventItem, "add");
+                                record.add(map);
+                                continue;
+                            } else if ("28".equals(pId)) {
+                                // 政策文件
+                                DateTime dateTime = DateUtil.offsetMonth(DateUtil.parseDate(date).toJdkDate(), -3);
+                                String startDate = dateTime.toString("yyyy-MM") + "-01";
+                                Map<String, Object> map = getTwoWeekUpdateRecord(startDate, date, chnlid, pId, deptItem.get("deptid").toString(), eventItem, "add");
+                                record.add(map);
+                                continue;
+                            }else {
                                 // 区分加分和减分时间(政策文件加分3个月,减分6个月)
                                 if (addCount > 1) {
                                     double scoreS = (addCount - 1) * score;
@@ -131,81 +148,7 @@ public class WzkpRecordUtil {
                             param.put("cloumnName", eventItem.get("target"));
                             param.put("deptId", deptItem.get("deptid"));
                             param.put("date", Blank.isEmpty(date) ? cn.hutool.core.date.DateUtil.now() : cn.hutool.core.date.DateUtil.parse(date, "yyyy-MM-dd").offset(DateField.DAY_OF_MONTH, -1).toString("yyyy-MM-dd"));
-//							param.put("chnlid", chnlid);
-
-                            record.add(param);
-                        }
-                    }
-                }
-            }
-
-            // 其他栏目
-            if (Blank.isEmpty(deptOtherColumn.get(deptName))) {
-                continue;
-            }
-            // 获取部门下的其他栏目
-            String[] otherChnlids = deptOtherColumn.get(deptName).split(",");
-            for (int j = 0; j < otherChnlids.length; j++) {
-                String chnlid = otherChnlids[j];
-                if (Blank.isEmpty(columnInfo.get(deptName + "-" + chnlid))) {
-                    System.out.println(deptName + "-" + chnlid);
-                    continue;
-                }
-                String isExceed = columnInfo.get(deptName + "-" + chnlid).toString();
-                if ("1".equals(isExceed)) {
-                    for (int k = 0; k < eventList.size(); k++) {
-                        Map<String, Object> eventItem = eventList.get(k);
-                        String pId = eventItem.get("pId").toString();
-                        // todo t_partition、t_dept加上其他栏目chnlid
-                        if ("9".equals(pId)) {
-                            Map<String, Object> param = new HashMap<>();
-
-                            param.put("pId", eventItem.get("pId"));
-                            param.put("type", eventItem.get("type"));
-                            param.put("cloumnName", eventItem.get("target"));
-                            param.put("deptId", deptItem.get("deptid"));
-                            param.put("date", Blank.isEmpty(date) ? cn.hutool.core.date.DateUtil.now() : cn.hutool.core.date.DateUtil.parse(date, "yyyy-MM-dd").offset(DateField.DAY_OF_MONTH, -1).toString("yyyy-MM-dd"));
-                            record.add(param);
-                            break;
-                        }
-                    }
-                } else {
-                    // todo 其他栏目不加分,删除这部分内容
-                    // 在规定时间内发文
-                    double scoreS = 0;
-                    for (int k = 0; k < eventList.size(); k++) {
-                        Map<String, Object> eventItem = eventList.get(k);
-                        if (Convert.toBool(eventItem.get("type"))) {
-                            continue;
-                        }
-                        List<String> list = Convert.toList(String.class, Convert.toStr(eventItem.get("chnlid").toString().split(","), ""));
-                        if (list.contains(chnlid)) {
-                            Map<String, Object> param = new HashMap<>();
-                            Integer addCount = addScoreColumn.get(chnlid);
-                            if (Blank.isEmpty(addCount)){
-                                continue;
-                            }
-                            Double score = Convert.toDouble(eventItem.get("score"));
-                            Double maxScore = Convert.toDouble(eventItem.get("targetScore"));
-                            String pId = Convert.toStr(eventItem.get("pId"));
-                            if ("28".equals(pId)) {
-                                if (addCount > 1) {
-                                    scoreS = (addCount - 1) * score;
-                                    if (scoreS > 0) {
-                                        if (maxScore > scoreS) {
-                                            param.put("score", scoreS);
-                                        } else {
-                                            param.put("score", maxScore);
-                                        }
-                                    }
-                                }
-                            }
-
-                            param.put("pId", eventItem.get("pId"));
-                            param.put("type", eventItem.get("type"));
-                            param.put("cloumnName", eventItem.get("target"));
-                            param.put("deptId", deptItem.get("deptid"));
-                            param.put("date", Blank.isEmpty(date) ? cn.hutool.core.date.DateUtil.now() : cn.hutool.core.date.DateUtil.parse(date, "yyyy-MM-dd").offset(DateField.DAY_OF_MONTH, -1).toString("yyyy-MM-dd"));
+							param.put("chnlid", chnlid);
 
                             record.add(param);
                         }
@@ -216,6 +159,13 @@ public class WzkpRecordUtil {
         tjDao.saveOnceRecord(filterRecord(record, eventList, eventGroup));
     }
 
+    /**
+     * 过滤多余记录,并设置分值上限
+     * @param records
+     * @param events
+     * @param eventGroup
+     * @return
+     */
     private List<Map<String, Object>> filterRecord(List<Map<String, Object>> records, List<Map<String, Object>> events, List<Map<String, Object>> eventGroup) {
         List<Map<String, Object>> list = new ArrayList<>();
         JSONObject deptGroup = new JSONObject();
@@ -253,9 +203,13 @@ public class WzkpRecordUtil {
                         continue;
                     }
                     Double score = 0.00;
+                    StringBuilder chnlid = new StringBuilder();
+                    StringJoiner chnName = new StringJoiner(",");
                     for (int k = 0; k < recordArr.size(); k++) {
                         JSONObject record = recordArr.getJSONObject(k);
                         score += Convert.toDouble(record.getDouble("score"), 0.00);
+                        chnlid.append(record.getString("chnlid")).append(",");
+                        chnName.add(hlwInterfaceDao.getChnlNameByChnlid(record.getString("chnlid")));
                     }
 
                     if (maxScore > 0) {
@@ -268,6 +222,8 @@ public class WzkpRecordUtil {
                     }
                     JSONObject record = recordArr.getJSONObject(0);
                     record.put("score", score);
+                    record.put("chnlid", chnlid.toString());
+                    record.put("cloumnName", record.getString("cloumnName") + "-" + chnName.toString());
                     list.add(Convert.toMap(String.class, Object.class, record));
                 }
 
@@ -277,6 +233,82 @@ public class WzkpRecordUtil {
         return list;
     }
 
+    /**
+     * 处理两周内加减分
+     * @param date
+     * @param chnlid
+     * @param pId
+     * @param deptId
+     * @param eventItem
+     * @param flag
+     * @return
+     */
+    private Map<String, Object> getTwoWeekUpdateRecord(String startDate, String date, String chnlid, String pId, String deptId, Map<String, Object> eventItem, String flag) {
+        List<Map<String, Object>> articleRecord = hlwInterfaceDao.getArticleByChnlidAndDate(chnlid, startDate, date);
+        Map<String, Object> param = new HashMap<>();
+
+        if ("sub".equals(flag)) {
+            if (articleRecord.isEmpty()) {
+                // 在上个月未发送过文章时扣2次分
+                param.put("pId", pId);
+                param.put("type", eventItem.get("type"));
+                param.put("cloumnName", eventItem.get("target"));
+                param.put("deptId", deptId);
+                param.put("score", Convert.toDouble(eventItem.get("score"), 0.00) * 2);
+                param.put("date", Blank.isEmpty(date) ? cn.hutool.core.date.DateUtil.now() : cn.hutool.core.date.DateUtil.parse(date, "yyyy-MM-dd").offset(DateField.DAY_OF_MONTH, -1).toString("yyyy-MM-dd"));
+                param.put("chnlid", chnlid);
+            } else if (articleRecord.size() > 1){
+                // 超过14天未发文的情况
+                for (int l = 0; l < articleRecord.size() - 1; l++) {
+                    Map<String, Object> map1 = articleRecord.get(l);
+                    Map<String, Object> map2 = articleRecord.get(l + 1);
+                    int day1 = DateUtil.parse(map1.get("docreltime").toString()).getField(DateField.DAY_OF_MONTH);
+                    int day2 = DateUtil.parse(map2.get("docreltime").toString()).getField(DateField.DAY_OF_MONTH);
+                    if ((day2 - day1) > 14) {
+                        param.put("pId", pId);
+                        param.put("type", eventItem.get("type"));
+                        param.put("cloumnName", eventItem.get("target"));
+                        param.put("deptId", deptId);
+                        param.put("score", Convert.toDouble(eventItem.get("score"), 0.00));
+                        param.put("date", Blank.isEmpty(date) ? cn.hutool.core.date.DateUtil.now() : cn.hutool.core.date.DateUtil.parse(date, "yyyy-MM-dd").offset(DateField.DAY_OF_MONTH, -1).toString("yyyy-MM-dd"));
+                        param.put("chnlid", chnlid);
+                    }
+                }
+            } else {
+                // 只发文一次
+                param.put("pId", pId);
+                param.put("type", eventItem.get("type"));
+                param.put("cloumnName", eventItem.get("target"));
+                param.put("deptId", deptId);
+                param.put("score", Convert.toDouble(eventItem.get("score"), 0.00));
+                param.put("date", Blank.isEmpty(date) ? cn.hutool.core.date.DateUtil.now() : cn.hutool.core.date.DateUtil.parse(date, "yyyy-MM-dd").offset(DateField.DAY_OF_MONTH, -1).toString("yyyy-MM-dd"));
+                param.put("chnlid", chnlid);
+            }
+        }
+
+        if ("add".equals(flag)) {
+            int count = 0;
+            for (int l = 0; l < articleRecord.size() - 1; l++) {
+                Map<String, Object> map1 = articleRecord.get(l);
+                Map<String, Object> map2 = articleRecord.get(l + 1);
+                int day1 = DateUtil.parse(map1.get("docreltime").toString()).getField(DateField.DAY_OF_MONTH);
+                int day2 = DateUtil.parse(map2.get("docreltime").toString()).getField(DateField.DAY_OF_MONTH);
+                if ((day2 - day1) < 14) {
+                    count += 1;
+                }
+            }
+
+            param.put("pId", pId);
+            param.put("type", eventItem.get("type"));
+            param.put("cloumnName", eventItem.get("target"));
+            param.put("deptId", deptId);
+            param.put("score", Convert.toDouble(eventItem.get("score"), 0.00) * count);
+            param.put("date", Blank.isEmpty(date) ? cn.hutool.core.date.DateUtil.now() : cn.hutool.core.date.DateUtil.parse(date, "yyyy-MM-dd").offset(DateField.DAY_OF_MONTH, -1).toString("yyyy-MM-dd"));
+            param.put("chnlid", chnlid);
+        }
+        return param;
+    }
+
     private Map<String, String> getDeptOtherColumn(List<Map<String, Object>> list) {
         Map<String, String> res = new HashMap<>();
         for (int i = 0; i < list.size(); i++) {
@@ -290,6 +322,11 @@ public class WzkpRecordUtil {
         return res;
     }
 
+    /**
+     * 获取多次更新的栏目及次数
+     * @param date
+     * @return
+     */
     private Map<String, Integer> getAddScoreColumn(String date) {
         List<Map<String, Object>> list = hlwInterfaceDao.countArticle(date);
         Map<String, Integer> res = new HashMap<>();
@@ -301,12 +338,31 @@ public class WzkpRecordUtil {
         return res;
     }
 
+    /**
+     * 获取部门下的栏目是否更新
+     * @param list
+     * @param date
+     * @return
+     */
     private Map<String, Object> getColumnLastUpdate(List<Map<String, Object>> list, String date) {
         List<Map<String, Object>> columnInfo = hlwInterfaceDao.getAllColumn(date);
         Map<String, Object> res = new HashMap<>();
         for (int i = 0; i < columnInfo.size(); i++) {
             Map<String, Object> map = columnInfo.get(i);
-            String key = getRealDeptName(map.get("unit").toString(), list) + "-" + map.get("chnlid").toString();
+            Integer publicColumn = Convert.toInt(map.get("publicColumn"), 0);
+            String unit = map.get("unit").toString();
+
+            // 多个栏目共用同一个栏目时
+            if (publicColumn == 1) {
+                String[] units = unit.split(",");
+                for (int j = 0; j < units.length; j++) {
+                    String key = getRealDeptName(units[j], list) + "-" + map.get("chnlid").toString();
+                    String value = Convert.toStr(map.get("isExceed"), "-1");
+                    res.put(key, value);
+                }
+                continue;
+            }
+            String key = getRealDeptName(unit, list) + "-" + map.get("chnlid").toString();
             String value = Convert.toStr(map.get("isExceed"), "-1");
             res.put(key, value);
         }
@@ -314,6 +370,12 @@ public class WzkpRecordUtil {
         return res;
     }
 
+    /**
+     * 获取部门名字
+     * @param userName
+     * @param list
+     * @return
+     */
     private String getRealDeptName(String userName, List<Map<String, Object>> list) {
         for (int i = 0; i < list.size(); i++) {
             Map<String, Object> map = list.get(i);
@@ -325,6 +387,10 @@ public class WzkpRecordUtil {
         return "";
     }
 
+    /**
+     * 获取规则组
+     * @return
+     */
     private List<Map<String, Object>> getEventGroup() {
         return tjDao.getPartitionGroup();
     }

+ 29 - 8
nngkxxdp/src/main/resources/mapper/HlwInterfaceDao.xml

@@ -33,10 +33,12 @@
 		from
 			column_relation
 	</select>-->
+	<!-- 获取栏目更新及其他信息 -->
 	<select id="getAllColumn" resultType="hashmap">
 		SELECT
 			b.CHNLID,
 			c.unit,
+		    c.public_column,
 			c.frequency,
 			b.DOCRELTIME,
 			TIMESTAMPDIFF(
@@ -54,23 +56,17 @@
 			(
 			SELECT
 				a.CHNLID,
-				GREATEST( a.OPERTIME, a.CRTIME, a.DOCPUBTIME, a.DOCRELTIME ) DOCRELTIME
+				DOCRELTIME
 			FROM
 				(
 					SELECT
 						CHNLID,
-						DOCRELTIME,
-						CRTIME,
-						OPERTIME,
-						DOCPUBTIME
+						MAX(DOCRELTIME) AS DOCRELTIME
 					FROM
 						save_hlw_interface_data
 						<if test="date != null and date != ''">
 							WHERE
 							DOCRELTIME &lt; #{date}
-							AND OPERTIME &lt; #{date}
-							AND CRTIME &lt; #{date}
-							AND DOCPUBTIME &lt; #{date}
 						</if>
 					GROUP BY
 						CHNLID DESC
@@ -83,6 +79,7 @@
 			c.frequency &gt; 0
 	</select>
 
+	<!-- 统计时间段内各个栏目的发文数量 -->
 	<select id="countArticle" resultType="hashmap">
 		SELECT
 			b.CHNLID,
@@ -112,6 +109,30 @@
 			COUNT(*) > 1
 	</select>
 
+	<!-- 根据chnlid获取一段时间内的文章 -->
+	<select id="getArticleByChnlidAndDate" resultType="map">
+		SELECT
+			*
+		FROM
+			save_hlw_interface_data a
+		WHERE
+			a.CHNLID = #{chnlid}
+		  AND DATE_FORMAT(a.DOCRELTIME, '%Y-%m-%d') BETWEEN DATE_FORMAT(#{startDate}, '%Y-%m-%d') AND DATE_FORMAT(#{endDate}, '%Y-%m-%d')
+		ORDER BY
+			a.DOCRELTIME DESC
+	</select>
+
+	<!-- 根据栏目ID获取栏目名称 -->
+	<select id="getChnlNameByChnlid" resultType="string" >
+		SELECT
+			CHANNELNAME
+		FROM
+			save_hlw_interface_data
+		WHERE
+			chnlid = #{chnlid}
+		LIMIT 1
+	</select>
+
 	<update id="updateLastUpdateTime">
 		UPDATE column_relation b,
 			(

+ 2 - 1
nngkxxdp/src/main/resources/mapper/TjDao.xml

@@ -192,7 +192,8 @@
 	<!-- 查询扣分详情 -->
 	<select id="getEventByDeptId" resultType="java.util.Map">
 		SELECT
-			tp.target,
+# 			tp.target,
+		    tr.cloumn_name target,
 			tp.target_score,
 			tp.target_requirement,
 			tp.target_deduct,

+ 10 - 8
nngkxxdp/src/main/resources/static/page/js/base/wzkp.item.js

@@ -118,7 +118,7 @@ function initBarChartData(data, deptId, hasDept, type, dBasic) {
 			}
 		} else if ((basicTemp + addTemp) < 80) {
 			// 显示不合格
-			data.yData[i] = data.yData[i] + '(不合格)';
+			data.yData[i] = data.yData[i] + '';
 		}
 	}
 
@@ -350,13 +350,15 @@ function iniatWzkpDetailTable(data, dBasic) {
 			_html += '<td>' + (temp.targetRequirement ? temp.targetRequirement : '-') + '</td>';
 			_html += '<td>' + (temp.event ? temp.event : '-') + '</td>';
 			_html += '<td>' + (temp.targetDeduct ? temp.targetDeduct : temp.zdyEvent) + '</td>';
-			if (temp.type) {
-				_html += '<td>-' + (temp.score ? temp.score : temp.addscore) + '</td>';
-//				_html += '<td>' + temp.finalscore + '</td>';
-			} else {
-//				_html += '<td>-</td>';
-				_html += '<td>' + temp.addscore + '</td>';
-			}
+// 			if (temp.type) {
+// 				_html += '<td>-' + (temp.score ? temp.score : temp.addscore) + '</td>';
+// //				_html += '<td>' + temp.finalscore + '</td>';
+// 			} else {
+// //				_html += '<td>-</td>';
+// 				_html += '<td>' + temp.addscore + '</td>';
+// 			}
+			_html += '<td>' + (temp.type ? '-' + temp.addscore : temp.addscore) + '</td>';
+
 			_html += '</tr>';
 		}
 	}