Browse Source

[招商][消息提醒]

release_toaliyun_real
Burce 6 years ago
parent
commit
b8d4ab54e3
4 changed files with 20 additions and 23 deletions
  1. +14
    -16
      mallinkSchedule/src/main/java/com/iformall/schedule/InvestSchedule.java
  2. +1
    -1
      mallinkService/src/main/java/com/iformall/service/invest/impl/InvestFollowRecordServiceImpl.java
  3. +1
    -1
      mallinkService/src/main/java/com/iformall/service/invest/impl/InvestMessageServiceImpl.java
  4. +4
    -5
      mallinkService/src/main/resources/mapper/InvestCustomerMapper.xml

+ 14
- 16
mallinkSchedule/src/main/java/com/iformall/schedule/InvestSchedule.java View File

@@ -40,18 +40,18 @@ public class InvestSchedule {
@Autowired
Environment environment;

private static final String PREFIX = "招商定时任务";
private static final String SCHEDULE_TAG = "招商定时任务";


//@Scheduled(cron = "0 0 14 * * ?") // 每天下午两点执行定时任务
@Scheduled(cron = "0 */30 * * * *?") // 测试,每5分钟执行
public void messageSchedule() {
log.info("{}: 开始", PREFIX);
log.info("{}: 开始", SCHEDULE_TAG);
//一个月内未完成提醒
taskMonthMessage();
//一周内未跟踪提醒
demandWeekMessage();
log.info("{}: 结束", PREFIX);
log.info("{}: 结束", SCHEDULE_TAG);
}

private void taskMonthMessage() {
@@ -69,14 +69,14 @@ public class InvestSchedule {
}
//查询满足条件
List<InvestTaskEntity> tasks = taskService.listByStatusAndTime(Arrays.asList(EnumTaskStatus.INTENTION, EnumTaskStatus.NEGOTIATING), start.getTime(), end.getTime());
log.info("{}:{} - {} 的任务数 :{}", PREFIX, start, end, tasks.size());
log.info("{}:{} - {} 的任务数 :{}", SCHEDULE_TAG, start, end, tasks.size());
if (tasks.isEmpty()) {
return;
}
for (InvestTaskEntity task : tasks) {
String owner = task.getOwner();
if (StringUtils.isEmpty(owner)) {
log.warn("{}:taskID:{} owner不存在:{}, 跳过", PREFIX, task.getId(), task.getOwner());
log.warn("{}:taskID:{} owner不存在:{}, 跳过", SCHEDULE_TAG, task.getId(), task.getOwner());
continue;
}
List<Long> ownerArray = JSONArray.parseArray(owner, Long.class);
@@ -85,7 +85,7 @@ public class InvestSchedule {
if (CollectionUtils.isNotEmpty(messageList)) {
for (InvestMessageEntity messageEntity : messageList) {
if (messageEntity.getTid().equals(task.getId())) {
log.info("{}:taskID:{} 提醒已存在:{}, 跳过", PREFIX, task.getId(), messageEntity.getId());
log.info("{}:taskID:{} 提醒已存在:{}, 跳过", SCHEDULE_TAG, task.getId(), messageEntity.getId());
continue;
}
addTaskMessage(task, ownerArray);
@@ -100,7 +100,7 @@ public class InvestSchedule {
private void addTaskMessage(InvestTaskEntity task, List<Long> ownerArray) {
String message = String.format(EnumInvestMessageType.TASK_REMIND.getInfo(), task.getId(), DateUtils.format(task.getLastTime()));
messageService.saveBatchMessage(ownerArray, message, EnumInvestMessageTag.TASK_MONTH, EnumFollowType.TASK, task.getId(),task.getTenantId());
log.info("{}:taskID:{} 为用户{}创建消息提醒", PREFIX, task.getId(), task.getOwner());
log.info("{}:taskID:{} 为用户{}创建消息提醒", SCHEDULE_TAG, task.getId(), task.getOwner());
}

private void demandWeekMessage() {
@@ -111,9 +111,9 @@ public class InvestSchedule {
//初始化时间条件
Calendar start = Calendar.getInstance();
if (environment.acceptsProfiles(ENV_STR)) {
start.add(Calendar.DAY_OF_YEAR, 1); //测试
start.add(Calendar.DAY_OF_YEAR, -1); //测试
} else {
start.add(Calendar.DAY_OF_YEAR, 7);
start.add(Calendar.DAY_OF_YEAR, -7);
}

//查询跟踪列表
@@ -122,14 +122,12 @@ public class InvestSchedule {
List<InvestCustomerVo> demands = customerService.listByIds(InvestHelper.getIds(follows, InvestFollowRecordEntity::getFollowId),
Arrays.asList(EnumCustomerType.INTENTIONAL, EnumCustomerType.POTENTIAL));

/**
* 已经已经提醒过的用户
*/
// 已经提醒过的用户
List<String> userDemandFlag = new ArrayList<>();
for (InvestCustomerVo customerVo : demands) {
Long owner = customerVo.getDemandOwner();
if (Objects.isNull(owner)) {
log.warn("{}:customerID:{} owner不存在:{}, 跳过", PREFIX, customerVo.getId(), customerVo.getDemandOwner());
log.warn("{}:customerID:{} owner不存在:{}, 跳过", SCHEDULE_TAG, customerVo.getId(), customerVo.getDemandOwner());
continue;
}
List<InvestMessageEntity> messageList = demandMessageUserIdMap.get(owner);
@@ -138,13 +136,13 @@ public class InvestSchedule {
}
for (InvestMessageEntity messageEntity : messageList) {
if (messageEntity.getTid().equals(messageEntity.getId())) {
log.info("{}:taskID:{} 提醒已存在:{}, 跳过", PREFIX, customerVo.getId(), messageEntity.getId());
log.info("{}:taskID:{} 提醒已存在:{}, 跳过", SCHEDULE_TAG, customerVo.getId(), messageEntity.getId());
continue;
}
String userDemandFlagItem = StringUtils.join(messageEntity.getOwner(), messageEntity.getId());
//已经提醒过的用户不在提醒
if (userDemandFlag.contains(userDemandFlagItem)) {
log.info("{}:taskID:{} 提醒已存在:{}, 跳过", PREFIX, customerVo.getId(), userDemandFlagItem);
log.info("{}:taskID:{} 提醒已存在:{}, 跳过", SCHEDULE_TAG, customerVo.getId(), userDemandFlagItem);
continue;
}
addCustomerMessage(customerVo, owner);
@@ -156,6 +154,6 @@ public class InvestSchedule {
private void addCustomerMessage(InvestCustomerVo customerVo, Long owner) {
String message = String.format(EnumInvestMessageType.COSTOMER_REMIND.getInfo(), customerVo.getId());
messageService.saveBatchMessage(Arrays.asList(owner), message, EnumInvestMessageTag.CUSTOMER_WEEK, EnumFollowType.DEMAND, customerVo.getId(),customerVo.getTenantId());
log.info("{}:customerID:{} 为用户{}创建消息提醒", PREFIX, customerVo.getId(), customerVo.getDemandOwner());
log.info("{}:customerID:{} 为用户{}创建消息提醒", SCHEDULE_TAG, customerVo.getId(), customerVo.getDemandOwner());
}
}

+ 1
- 1
mallinkService/src/main/java/com/iformall/service/invest/impl/InvestFollowRecordServiceImpl.java View File

@@ -41,7 +41,7 @@ public class InvestFollowRecordServiceImpl extends InvestBaseServiceImpl<InvestF
public List<InvestFollowRecordEntity> listByTime(EnumFollowType followType, Date start) {
LambdaUpdateWrapper<InvestFollowRecordEntity> query = new LambdaUpdateWrapper<>() ;
query.eq(InvestFollowRecordEntity::getType,followType) ;
query.ge(InvestFollowRecordEntity::getCreateDate, start);
query.le(InvestFollowRecordEntity::getCreateDate, start);
return list(query);
}



+ 1
- 1
mallinkService/src/main/java/com/iformall/service/invest/impl/InvestMessageServiceImpl.java View File

@@ -66,7 +66,7 @@ public class InvestMessageServiceImpl extends InvestBaseServiceImpl<InvestMessag
public List<InvestMessageEntity> listByTypeAndTag(EnumFollowType type, EnumInvestMessageTag tag) {
LambdaQueryWrapper<InvestMessageEntity> messageQueryWrapper = new LambdaQueryWrapper<>();
messageQueryWrapper.eq(InvestMessageEntity::getType, type);
messageQueryWrapper.ge(InvestMessageEntity::getTag, tag);
messageQueryWrapper.eq(InvestMessageEntity::getTag, tag);
return list(messageQueryWrapper);
}
}

+ 4
- 5
mallinkService/src/main/resources/mapper/InvestCustomerMapper.xml View File

@@ -20,10 +20,9 @@
</resultMap>

<select id="listByIds" resultType="com.iformall.domain.vo.invest.InvestCustomerVo">
select c.*,d.`id` as demandId,d.`owner` as demandOwner
from `invest_follow_record` f
LEFT JOIN `invest_demand` d ON d.id = f.`follow_id`
LEFT JOIN invest_customer c ON d.`customer_id` = c.id
SELECT c.*,d.`id` AS demandId,d.`owner` AS demandOwner FROM `invest_follow_record` f
INNER JOIN `invest_customer` c ON c.id=f.`follow_id`
INNER JOIN `invest_demand` d ON d.`customer_id`=c.id
where 1=1
<if test=" null != type and type.size()>0">
AND c.type in
@@ -32,7 +31,7 @@
</foreach>
</if>
<if test=" null != ids and ids.size()>0">
AND d.id in
AND c.id in
<foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
#{idItem}
</foreach>


Loading…
Cancel
Save