|
@@ -9,7 +9,12 @@ import com.jeeplus.common.utils.*;
|
|
|
import com.jeeplus.common.utils.excel.ExportExcel;
|
|
import com.jeeplus.common.utils.excel.ExportExcel;
|
|
|
import com.jeeplus.common.utils.excel.ImportExcel;
|
|
import com.jeeplus.common.utils.excel.ImportExcel;
|
|
|
import com.jeeplus.common.web.BaseController;
|
|
import com.jeeplus.common.web.BaseController;
|
|
|
|
|
+import com.jeeplus.modules.WorkKnowledgeBase.dao.*;
|
|
|
|
|
+import com.jeeplus.modules.WorkKnowledgeBase.entity.WorkKnowledgeBasePointRule;
|
|
|
|
|
+import com.jeeplus.modules.WorkKnowledgeBase.entity.WorkKnowledgeBaseReadRecord;
|
|
|
|
|
+import com.jeeplus.modules.WorkKnowledgeBase.entity.WorkKnowledgePointCategory;
|
|
|
import com.jeeplus.modules.WorkKnowledgeBase.service.WkPointSnapshotService;
|
|
import com.jeeplus.modules.WorkKnowledgeBase.service.WkPointSnapshotService;
|
|
|
|
|
+import com.jeeplus.modules.WorkKnowledgeBase.service.WorkKnowledgeBaseReadLikeService;
|
|
|
import com.jeeplus.modules.militaryIndustryConfidentiality.service.MilitaryIndustryConfidentialityService;
|
|
import com.jeeplus.modules.militaryIndustryConfidentiality.service.MilitaryIndustryConfidentialityService;
|
|
|
import com.jeeplus.modules.projectAccessory.dao.ProjectTemplateDao;
|
|
import com.jeeplus.modules.projectAccessory.dao.ProjectTemplateDao;
|
|
|
import com.jeeplus.modules.projectAccessory.entity.ProjectTemplateInfo;
|
|
import com.jeeplus.modules.projectAccessory.entity.ProjectTemplateInfo;
|
|
@@ -136,6 +141,24 @@ public class RuralProjectSignatureOldMessageDisposeController extends BaseContro
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private WorkStaffCertificateService workStaffCertificateService;
|
|
private WorkStaffCertificateService workStaffCertificateService;
|
|
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private WorkKnowledgeBaseReadLikeService readLikeService;
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private WorkKnowledgeBaseReadRecordDao readRecordDao;
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private WorkKnowledgeBaseLikeRecordDao likeRecordDao;
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private WorkKnowledgeBaseShareInfoDao shareInfoDao;
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private WorkKnowledgeBasePointRuleDao pointRuleDao;
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private WorkKnowledgePointCategoryDao categoryDao;
|
|
|
|
|
+
|
|
|
private static final String HTTPTOP = Global.getConfig("signature_http_top");
|
|
private static final String HTTPTOP = Global.getConfig("signature_http_top");
|
|
|
|
|
|
|
|
private final static String apptoken = Global.getConfig("apptoken");
|
|
private final static String apptoken = Global.getConfig("apptoken");
|
|
@@ -1311,4 +1334,130 @@ public class RuralProjectSignatureOldMessageDisposeController extends BaseContro
|
|
|
return map;
|
|
return map;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 模拟阅读/点赞获取积分(跟随大众行为)
|
|
|
|
|
+ * @param userId 目标用户 ID
|
|
|
|
|
+ * @param maxPoints 本次最多获取积分(0=不限)
|
|
|
|
|
+ * @return 执行结果
|
|
|
|
|
+ */
|
|
|
|
|
+ @RequestMapping(value = "simulateReadLike")
|
|
|
|
|
+ @ResponseBody
|
|
|
|
|
+ public Map<String, Object> simulateReadLike(@RequestParam String userId,
|
|
|
|
|
+ @RequestParam(defaultValue = "0") int maxPoints) {
|
|
|
|
|
+ Map<String, Object> result = new HashMap<>();
|
|
|
|
|
+ try {
|
|
|
|
|
+ // 1. 查询所有已被阅读过的文档 ID(去重)
|
|
|
|
|
+ List<String> readDocIds = readRecordDao.findAllDistinctFileIds();
|
|
|
|
|
+ // 2. 查询所有已被点赞过(status=1)的文档 ID(去重)
|
|
|
|
|
+ List<String> likeDocIds = likeRecordDao.findAllDistinctFileIds();
|
|
|
|
|
+
|
|
|
|
|
+ // 3. 排除用户自己的文档
|
|
|
|
|
+ List<String> ownDocIds = shareInfoDao.findIdsByCreateBy(userId);
|
|
|
|
|
+ readDocIds.removeAll(ownDocIds);
|
|
|
|
|
+ likeDocIds.removeAll(ownDocIds);
|
|
|
|
|
+
|
|
|
|
|
+ // 4. 查询阅读和点赞的积分规则
|
|
|
|
|
+ int readPointValue = getPointValueByRuleType("10"); // 阅读 rule_type=10
|
|
|
|
|
+ int likePointValue = getPointValueByRuleType("20"); // 点赞 rule_type=20
|
|
|
|
|
+
|
|
|
|
|
+ // 5. 合并需要处理的文档 ID(去重)
|
|
|
|
|
+ Set<String> allDocIds = new LinkedHashSet<>();
|
|
|
|
|
+ allDocIds.addAll(readDocIds);
|
|
|
|
|
+ allDocIds.addAll(likeDocIds);
|
|
|
|
|
+
|
|
|
|
|
+ // 6. 逐个文档处理:阅读 + 点赞
|
|
|
|
|
+ int readCount = 0;
|
|
|
|
|
+ int readPoints = 0;
|
|
|
|
|
+ int likeCount = 0;
|
|
|
|
|
+ int likePoints = 0;
|
|
|
|
|
+ for (String fileId : allDocIds) {
|
|
|
|
|
+ // 检查积分上限
|
|
|
|
|
+ if (maxPoints > 0 && (readPoints + likePoints) >= maxPoints) {
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 模拟阅读(如果该文档在已阅读列表中且用户未阅读过)
|
|
|
|
|
+ if (readDocIds.contains(fileId)) {
|
|
|
|
|
+ WorkKnowledgeBaseReadRecord existingRead = readRecordDao.findByFileIdAndUserId(fileId, userId);
|
|
|
|
|
+ if (existingRead == null) {
|
|
|
|
|
+ readLikeService.recordRead(fileId, userId);
|
|
|
|
|
+ readCount++;
|
|
|
|
|
+ readPoints += readPointValue;
|
|
|
|
|
+ randomSleep();
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 检查积分上限(阅读后可能已达上限)
|
|
|
|
|
+ if (maxPoints > 0 && (readPoints + likePoints) >= maxPoints) {
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 模拟点赞(如果该文档在已点赞列表中且用户未点赞过)
|
|
|
|
|
+ if (likeDocIds.contains(fileId)) {
|
|
|
|
|
+ if (!readLikeService.isLiked(fileId, userId)) {
|
|
|
|
|
+ readLikeService.likeFile(fileId, userId);
|
|
|
|
|
+ likeCount++;
|
|
|
|
|
+ likePoints += likePointValue;
|
|
|
|
|
+ randomSleep();
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 7. 返回结果
|
|
|
|
|
+ result.put("success", true);
|
|
|
|
|
+ result.put("readCount", readCount);
|
|
|
|
|
+ result.put("readPoints", readPoints);
|
|
|
|
|
+ result.put("likeCount", likeCount);
|
|
|
|
|
+ result.put("likePoints", likePoints);
|
|
|
|
|
+ result.put("totalPoints", readPoints + likePoints);
|
|
|
|
|
+ result.put("msg", "模拟完成:阅读" + readCount + "篇,点赞" + likeCount + "篇,共获得" + (readPoints + likePoints) + "积分");
|
|
|
|
|
+
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ logger.error("模拟阅读/点赞失败:", e);
|
|
|
|
|
+ result.put("success", false);
|
|
|
|
|
+ result.put("msg", "执行失败:" + e.getMessage());
|
|
|
|
|
+ }
|
|
|
|
|
+ return result;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 查询指定 rule_type 的积分分值
|
|
|
|
|
+ */
|
|
|
|
|
+ private int getPointValueByRuleType(String ruleType) {
|
|
|
|
|
+ try {
|
|
|
|
|
+ // 查询“基础积分”分类
|
|
|
|
|
+ List<WorkKnowledgePointCategory> categories =
|
|
|
|
|
+ categoryDao.findList(new WorkKnowledgePointCategory() {{
|
|
|
|
|
+ setCategoryName("基础积分");
|
|
|
|
|
+ }});
|
|
|
|
|
+
|
|
|
|
|
+ if (categories == null || categories.isEmpty()) {
|
|
|
|
|
+ return 0;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ String categoryId = categories.get(0).getId();
|
|
|
|
|
+ WorkKnowledgeBasePointRule rule =
|
|
|
|
|
+ pointRuleDao.findByCategoryIdAndRuleType(categoryId, ruleType);
|
|
|
|
|
+
|
|
|
|
|
+ if (rule != null && rule.getPointValue() != null) {
|
|
|
|
|
+ return Integer.parseInt(rule.getPointValue());
|
|
|
|
|
+ }
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ logger.error("查询积分规则失败:", e);
|
|
|
|
|
+ }
|
|
|
|
|
+ return 0;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 随机休眠 3-10 秒
|
|
|
|
|
+ */
|
|
|
|
|
+ private void randomSleep() {
|
|
|
|
|
+ try {
|
|
|
|
|
+ int seconds = 3 + (int) (Math.random() * 8); // 3-10 秒
|
|
|
|
|
+ Thread.sleep(seconds * 1000L);
|
|
|
|
|
+ } catch (InterruptedException e) {
|
|
|
|
|
+ Thread.currentThread().interrupt();
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
}
|
|
}
|