|
@@ -6,6 +6,7 @@ import cn.hutool.core.collection.CollUtil;
|
|
import cn.hutool.core.collection.CollectionUtil;
|
|
import cn.hutool.core.collection.CollectionUtil;
|
|
import cn.hutool.core.util.ArrayUtil;
|
|
import cn.hutool.core.util.ArrayUtil;
|
|
import cn.hutool.core.util.StrUtil;
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
|
+import cn.hutool.crypto.digest.DigestUtil;
|
|
import cn.hutool.json.JSONArray;
|
|
import cn.hutool.json.JSONArray;
|
|
import cn.hutool.json.JSONUtil;
|
|
import cn.hutool.json.JSONUtil;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
@@ -58,6 +59,7 @@ import lombok.AllArgsConstructor;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import org.apache.commons.collections4.CollectionUtils;
|
|
import org.apache.commons.collections4.CollectionUtils;
|
|
import org.springframework.context.ApplicationEventPublisher;
|
|
import org.springframework.context.ApplicationEventPublisher;
|
|
|
|
+import org.springframework.data.redis.core.RedisTemplate;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
@@ -72,6 +74,7 @@ import java.util.HashMap;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
import java.util.Optional;
|
|
import java.util.Optional;
|
|
|
|
+import java.util.concurrent.TimeUnit;
|
|
import java.util.function.Function;
|
|
import java.util.function.Function;
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
@@ -103,6 +106,7 @@ public class WmTaskContentServiceImpl extends ServiceImpl<WmTaskContentMapper, W
|
|
private final ApplicationEventPublisher applicationEventPublisher;
|
|
private final ApplicationEventPublisher applicationEventPublisher;
|
|
private final WmPackageTaskTypeQtyService packageTaskTypeQtyService;
|
|
private final WmPackageTaskTypeQtyService packageTaskTypeQtyService;
|
|
private final Sequence taskSequence;
|
|
private final Sequence taskSequence;
|
|
|
|
+ private final RedisTemplate redisTemplate;
|
|
|
|
|
|
private static final DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm");
|
|
private static final DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm");
|
|
|
|
|
|
@@ -1109,4 +1113,119 @@ public class WmTaskContentServiceImpl extends ServiceImpl<WmTaskContentMapper, W
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 检查任务参数是否重复
|
|
|
|
+ *
|
|
|
|
+ * @param taskTypeId 任务类型 ID
|
|
|
|
+ * @param packageId 积分包ID
|
|
|
|
+ * @param username 用户名
|
|
|
|
+ * @param taskContent 任务content
|
|
|
|
+ * @return boolean 是否重复
|
|
|
|
+ */
|
|
|
|
+ @Override
|
|
|
|
+ public boolean checkDuplicate(String taskTypeId, String packageId, String username, WmTaskContent taskContent) {
|
|
|
|
+ String toCheckParams = null;
|
|
|
|
+ switch (taskTypeId) {
|
|
|
|
+ case "53":
|
|
|
|
+ // 基础拜访
|
|
|
|
+ // 唯一值(用于判定是否为“重复任务”): 拜访日期+拜访类型+拜访总结 (这里写死了, 就不从taskContentConfig查了)
|
|
|
|
+ toCheckParams = String.format("%s_%s_%s", taskContent.getTemp25(), taskContent.getTemp26(),
|
|
|
|
+ taskContent.getTemp23());
|
|
|
|
+ break;
|
|
|
|
+ case "51":
|
|
|
|
+ // 专业拜访
|
|
|
|
+ // 拜访日期+拜访类型+拜访主题
|
|
|
|
+ toCheckParams =
|
|
|
|
+ String.format("%s_%s_%s", taskContent.getTemp25(), taskContent.getTemp3(), taskContent.getTemp23());
|
|
|
|
+ break;
|
|
|
|
+ case "52":
|
|
|
|
+ // 专项拜访
|
|
|
|
+ // 拜访日期+拜访类型+拜访主题
|
|
|
|
+ toCheckParams =
|
|
|
|
+ String.format("%s_%s_%s", taskContent.getTemp25(), taskContent.getTemp3(), taskContent.getTemp23());
|
|
|
|
+ break;
|
|
|
|
+ case "1":
|
|
|
|
+ // POV科室会
|
|
|
|
+ // 会议类型+会议主题+会议时间
|
|
|
|
+ toCheckParams =
|
|
|
|
+ String.format("%s_%s_%s", taskContent.getTemp12(), taskContent.getTemp2(), taskContent.getTemp4());
|
|
|
|
+ break;
|
|
|
|
+ case "5":
|
|
|
|
+ // 沙龙会
|
|
|
|
+ // 会议类型+会议主题+会议时间
|
|
|
|
+ toCheckParams =
|
|
|
|
+ String.format("%s_%s_%s", taskContent.getTemp12(), taskContent.getTemp2(), taskContent.getTemp4());
|
|
|
|
+ break;
|
|
|
|
+ case "2":
|
|
|
|
+ // 区县学术会议
|
|
|
|
+ // 会议类型+会议主题+会议时间
|
|
|
|
+ toCheckParams =
|
|
|
|
+ String.format("%s_%s_%s", taskContent.getTemp12(), taskContent.getTemp2(), taskContent.getTemp4());
|
|
|
|
+ break;
|
|
|
|
+ case "3":
|
|
|
|
+ // 市级学术会议
|
|
|
|
+ // 会议类型+会议主题+会议时间
|
|
|
|
+ toCheckParams =
|
|
|
|
+ String.format("%s_%s_%s", taskContent.getTemp12(), taskContent.getTemp2(), taskContent.getTemp4());
|
|
|
|
+ break;
|
|
|
|
+ case "4":
|
|
|
|
+ // 省级学术会议
|
|
|
|
+ // 会议类型+会议主题+会议时间
|
|
|
|
+ toCheckParams =
|
|
|
|
+ String.format("%s_%s_%s", taskContent.getTemp8(), taskContent.getTemp2(), taskContent.getTemp4());
|
|
|
|
+ break;
|
|
|
|
+ case "64":
|
|
|
|
+ // 线上学术会议
|
|
|
|
+ // 会议类型+会议主题+会议时间
|
|
|
|
+ toCheckParams =
|
|
|
|
+ String.format("%s_%s_%s", taskContent.getTemp12(), taskContent.getTemp2(), taskContent.getTemp4());
|
|
|
|
+ break;
|
|
|
|
+ case "19":
|
|
|
|
+ // 健康教育课题 or 健康教育课堂?
|
|
|
|
+ // 培训类型+培训主题+培训时间
|
|
|
|
+ toCheckParams =
|
|
|
|
+ String.format("%s_%s_%s", taskContent.getTemp13(), taskContent.getTemp2(), taskContent.getTemp4());
|
|
|
|
+ break;
|
|
|
|
+ case "14":
|
|
|
|
+ // 数据信息收集
|
|
|
|
+ // 调查类别+标题+调研时间
|
|
|
|
+ toCheckParams =
|
|
|
|
+ String.format("%s_%s_%s", taskContent.getTemp23(), taskContent.getTemp2(), taskContent.getTemp4());
|
|
|
|
+ break;
|
|
|
|
+ case "17":
|
|
|
|
+ // 医学警戒信息收集
|
|
|
|
+ // 调查类别+标题+调研时间
|
|
|
|
+ toCheckParams =
|
|
|
|
+ String.format("%s_%s_%s", taskContent.getTemp3(), taskContent.getTemp2(), taskContent.getTemp4());
|
|
|
|
+ break;
|
|
|
|
+ case "12":
|
|
|
|
+ // 产品展示
|
|
|
|
+ // 展示类型+展示主题+展示场地+展示开始时间
|
|
|
|
+ toCheckParams = String.format("%s_%s_%s_%s", taskContent.getTemp3(), taskContent.getTemp2(),
|
|
|
|
+ taskContent.getTemp5(), taskContent.getTemp9());
|
|
|
|
+ break;
|
|
|
|
+ case "13":
|
|
|
|
+ // 业务宣传服务
|
|
|
|
+ // 平台名称+宣传主题+发布时间
|
|
|
|
+ toCheckParams =
|
|
|
|
+ String.format("%s_%s_%s", taskContent.getTemp2(), taskContent.getTemp13(), taskContent.getTemp4());
|
|
|
|
+ break;
|
|
|
|
+ default:
|
|
|
|
+ // 其他任务类型不做重复检查
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 计算参数md5
|
|
|
|
+ String paramMd5 = DigestUtil.md5Hex(toCheckParams);
|
|
|
|
+
|
|
|
|
+ String cacheKey1 = "save:task:content:ide:key:" + packageId + ":" + username + ":" + paramMd5;
|
|
|
|
+
|
|
|
|
+ if (Boolean.FALSE.equals(redisTemplate.opsForValue().setIfAbsent(cacheKey1, toCheckParams, 90, TimeUnit.DAYS))) {
|
|
|
|
+ // 存在重复任务,则返回true
|
|
|
|
+ return true;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
}
|
|
}
|