|
@@ -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();
|
|
|
}
|