|
@@ -5,7 +5,6 @@ import cn.hutool.core.util.ObjectUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
@@ -18,8 +17,10 @@ import com.winhc.repal.cloud.vo.V8DynamicVO;
|
|
|
import com.winhc.repal.entity.RepalBill;
|
|
|
import com.winhc.repal.entity.RepalRemindDefinition;
|
|
|
import com.winhc.repal.entity.RepalRemindHistory;
|
|
|
+import com.winhc.repal.entity.ThirdPartyAccount;
|
|
|
import com.winhc.repal.enums.*;
|
|
|
import com.winhc.repal.service.*;
|
|
|
+import com.winhc.repal.util.RedisUtil;
|
|
|
import com.xxl.job.core.handler.annotation.XxlJob;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -45,7 +46,7 @@ import java.util.stream.Collectors;
|
|
|
@Slf4j
|
|
|
public class SmartRemindTask {
|
|
|
private static final int PAGE_SIZE = 100;
|
|
|
- private static final String MESSAGE_PRIFIX = "msg_prifix_";
|
|
|
+ private static final String MESSAGE_PRIFIX = "winhc:repal:key_";
|
|
|
@Autowired
|
|
|
private RepalBillService accountBillService;
|
|
|
@Autowired
|
|
@@ -56,12 +57,12 @@ public class SmartRemindTask {
|
|
|
private CompanyService companyService;
|
|
|
@Autowired
|
|
|
private RepalBillDiagnosisService diagnosisService;
|
|
|
-// @Autowired
|
|
|
-// private MessageNoticeService messageNoticeService;
|
|
|
-// @Autowired
|
|
|
-// private RedisUtil redisUtil;
|
|
|
-// @Autowired
|
|
|
-// private AccountRemindSettingService accountRemindSettingService;
|
|
|
+ @Autowired
|
|
|
+ private MessageNoticeService messageNoticeService;
|
|
|
+ @Autowired
|
|
|
+ private RedisUtil redisUtil;
|
|
|
+ @Autowired
|
|
|
+ private ThirdPartyAccountService thirdPartyAccountService;
|
|
|
|
|
|
private static final HashMap<String,String> RISK_MAP = new HashMap<>(32);
|
|
|
|
|
@@ -118,7 +119,15 @@ public class SmartRemindTask {
|
|
|
//更新逾期状态
|
|
|
billList.forEach(e->{
|
|
|
//todo 过滤没开通标准版和高级版的账款
|
|
|
-// AccountRemindSettingVO accountRemindSetting = accountRemindSettingService.find(e.getUserId());
|
|
|
+
|
|
|
+ //查出组织下所有已经授权的成员
|
|
|
+ List<ThirdPartyAccount> accounts = thirdPartyAccountService.list(Wrappers.lambdaQuery(ThirdPartyAccount.class)
|
|
|
+ .eq(ThirdPartyAccount::getGroupId,e.getRepalGroupId())
|
|
|
+ .eq(ThirdPartyAccount::getDeleted,Dict.DeletedStatusEnunm.否.getCode())
|
|
|
+ .eq(ThirdPartyAccount::getAppId,0)
|
|
|
+ .isNotNull(ThirdPartyAccount::getMobileNo));
|
|
|
+ List<String> mobiles = accounts.stream().map(ThirdPartyAccount::getMobileNo).collect(Collectors.toList());
|
|
|
+
|
|
|
AtomicReference<Boolean> needRefreshGrade = new AtomicReference<>(Boolean.FALSE);
|
|
|
AtomicReference<RepalRemindHistory> lastestRemind = new AtomicReference<>(null);
|
|
|
LocalDate endDate = e.getEndDate();
|
|
@@ -156,20 +165,18 @@ public class SmartRemindTask {
|
|
|
newRemind.setRemindTitle(overdueEnum.name());
|
|
|
newRemind.setRemindContent(accountRemindDefinition.getRemindContent());
|
|
|
newRemind.setFunctionList(accountRemindDefinition.getFunctionList());
|
|
|
- newRemind.setRemindType(RemindEnum.逾期提醒.name());
|
|
|
- newRemind.setReadStatus(ReadStatusEnum.未读.getCode());
|
|
|
+ newRemind.setRemindType(RemindEnum.逾期提醒.getCode());
|
|
|
accountRemindHistoryService.save(newRemind);
|
|
|
lastestRemind.set(newRemind);
|
|
|
-// //提醒
|
|
|
-// if(Dict.REMIND_SETTING_ENUM.需要提醒.getCode().equals(accountRemindSetting.getOverdue())) {
|
|
|
-// Map<String, String> paraMap = new HashMap<>();
|
|
|
-// paraMap.put("company", e.getAccountBillTitle());
|
|
|
-// paraMap.put("status", overdueEnum.name());
|
|
|
-// paraMap.put("wizardId", e.getId().toString());
|
|
|
-// paraMap.put("accountBookId",e.getAccountBookId().toString());
|
|
|
-// messageNoticeService.sendPushmsg(e.getUserId(), Dict.MsgNameEnum.逾期APP提醒, paraMap);
|
|
|
-// messageNoticeService.sendSms(e.getUserId(), Dict.MsgNameEnum.逾期短信提醒, paraMap);
|
|
|
-// }
|
|
|
+ //提醒
|
|
|
+ if(CollUtil.isNotEmpty(mobiles)) {
|
|
|
+ for(String mobileNo:mobiles) {
|
|
|
+ Map<String, String> paraMap = new HashMap<>();
|
|
|
+ paraMap.put("company", e.getCustomerName());
|
|
|
+ paraMap.put("status", overdueEnum.name());
|
|
|
+ messageNoticeService.sendSms(mobileNo, MsgNameEnum.逾期短信提醒, paraMap);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -214,26 +221,24 @@ public class SmartRemindTask {
|
|
|
.setRemindContent(StrUtil.format(accountRemindDefinition.getRemindContent(),
|
|
|
e.getCustomerName()))
|
|
|
.setFunctionList(accountRemindDefinition.getFunctionList())
|
|
|
- .setRemindType(RemindEnum.财产线索.name())
|
|
|
- .setReadStatus(ReadStatusEnum.未读.getCode())
|
|
|
+ .setRemindType(RemindEnum.财产线索.getCode())
|
|
|
.setBizId(financeDynamicVO.getBizId())
|
|
|
.setIsNew(1)
|
|
|
.setDimensionType(financeDynamicVO.getDimensionType());
|
|
|
accountRemindHistoryService.save(accountRemindHistory);
|
|
|
needRefreshGrade.set(Boolean.TRUE);
|
|
|
lastestRemind.set(accountRemindHistory);
|
|
|
-// //推送
|
|
|
-// String redisKey = MESSAGE_PRIFIX+e.getUserId()+"_"+financeDynamicTypeEnum.getCode();
|
|
|
-// if(Dict.REMIND_SETTING_ENUM.需要提醒.getCode().equals(accountRemindSetting.getFinance()) && redisUtil.get(redisKey) == null) {
|
|
|
-// Map<String, String> paraMap = new HashMap<>();
|
|
|
-// paraMap.put("company", company);
|
|
|
-// paraMap.put("change", financeDynamicTypeEnum.getDesc());
|
|
|
-// paraMap.put("wizardId", e.getId().toString());
|
|
|
-// paraMap.put("accountBookId",e.getAccountBookId().toString());
|
|
|
-// messageNoticeService.sendPushmsg(e.getUserId(), Dict.MsgNameEnum.财产线索APP提醒, paraMap);
|
|
|
-// messageNoticeService.sendSms(e.getUserId(), Dict.MsgNameEnum.财产线索短信提醒, paraMap);
|
|
|
-// redisUtil.setEx(redisKey, "done", calTTL(), TimeUnit.MILLISECONDS);
|
|
|
-// }
|
|
|
+ //推送
|
|
|
+ String redisKey = MESSAGE_PRIFIX+e.getRepalGroupId()+"_"+financeDynamicTypeEnum.getCode();
|
|
|
+ if(CollUtil.isNotEmpty(mobiles) && redisUtil.get(redisKey) == null) {
|
|
|
+ for(String mobileNo:mobiles) {
|
|
|
+ Map<String, String> paraMap = new HashMap<>();
|
|
|
+ paraMap.put("company", e.getCustomerName());
|
|
|
+ paraMap.put("change", financeDynamicTypeEnum.getDesc());
|
|
|
+ messageNoticeService.sendSms(mobileNo, MsgNameEnum.财产线索短信提醒, paraMap);
|
|
|
+ }
|
|
|
+ redisUtil.setEx(redisKey, "done", calTTL(), TimeUnit.MILLISECONDS);
|
|
|
+ }
|
|
|
});
|
|
|
}
|
|
|
}
|
|
@@ -285,8 +290,7 @@ public class SmartRemindTask {
|
|
|
.setRemindContent(StrUtil.format(accountRemindDefinition.getRemindContent(),
|
|
|
e.getCustomerName()))
|
|
|
.setFunctionList(accountRemindDefinition.getFunctionList())
|
|
|
- .setRemindType(RemindEnum.风险预警.name())
|
|
|
- .setReadStatus(ReadStatusEnum.未读.getCode())
|
|
|
+ .setRemindType(RemindEnum.风险预警.getCode())
|
|
|
.setBizId(esDynamic.getRowkey())
|
|
|
.setInfoType(esDynamic.getInfoType())
|
|
|
.setDynamicId(esDynamic.getId())
|
|
@@ -295,19 +299,17 @@ public class SmartRemindTask {
|
|
|
accountRemindHistoryService.save(accountRemindHistory);
|
|
|
needRefreshGrade.set(Boolean.TRUE);
|
|
|
lastestRemind.set(accountRemindHistory);
|
|
|
-// //推送
|
|
|
-// String redisKey = MESSAGE_PRIFIX + e.getUserId() + "_" + type;
|
|
|
-// if (Dict.REMIND_SETTING_ENUM.需要提醒.getCode().equals(accountRemindSetting.getRisk()) &&
|
|
|
-// redisUtil.get(redisKey) == null) {
|
|
|
-// Map<String, String> paraMap = new HashMap<>();
|
|
|
-// paraMap.put("company", company);
|
|
|
-// paraMap.put("change", "新增"+RISK_MAP.get(type));
|
|
|
-// paraMap.put("wizardId", e.getId().toString());
|
|
|
-// paraMap.put("accountBookId",e.getAccountBookId().toString());
|
|
|
-// messageNoticeService.sendPushmsg(e.getUserId(), Dict.MsgNameEnum.风险提醒APP提醒, paraMap);
|
|
|
-// messageNoticeService.sendSms(e.getUserId(), Dict.MsgNameEnum.风险提醒短信提醒, paraMap);
|
|
|
-// redisUtil.setEx(redisKey, "done", calTTL(), TimeUnit.MILLISECONDS);
|
|
|
-// }
|
|
|
+ //推送
|
|
|
+ String redisKey = MESSAGE_PRIFIX + e.getRepalGroupId() + "_" + type;
|
|
|
+ if (CollUtil.isNotEmpty(mobiles) && redisUtil.get(redisKey) == null) {
|
|
|
+ for(String mobileNo:mobiles) {
|
|
|
+ Map<String, String> paraMap = new HashMap<>();
|
|
|
+ paraMap.put("company", e.getCustomerName());
|
|
|
+ paraMap.put("change", "新增" + RISK_MAP.get(type));
|
|
|
+ messageNoticeService.sendSms(mobileNo, MsgNameEnum.风险提醒短信提醒, paraMap);
|
|
|
+ }
|
|
|
+ redisUtil.setEx(redisKey, "done", calTTL(), TimeUnit.MILLISECONDS);
|
|
|
+ }
|
|
|
});
|
|
|
}
|
|
|
}
|
|
@@ -336,16 +338,9 @@ public class SmartRemindTask {
|
|
|
if(needRefreshGrade.get()){
|
|
|
diagnosisService.addRepalBillDiagnosis(e.getUserId(),e.getId(),e.getReceivable(), Collections.singletonList(e.getCustomerName()));
|
|
|
}
|
|
|
- //一个月无最新变化,刷新评级并推送消息
|
|
|
- if(
|
|
|
-// Dict.REMIND_SETTING_ENUM.需要提醒.getCode().equals(accountRemindSetting.getRank()) &&
|
|
|
- (now.toEpochDay() - e.getDiagnosisDatetime().toLocalDate().toEpochDay() >= 30)){
|
|
|
+ //一个月无最新变化,刷新评级
|
|
|
+ if(now.toEpochDay() - e.getDiagnosisDatetime().toLocalDate().toEpochDay() >= 30){
|
|
|
diagnosisService.addRepalBillDiagnosis(e.getUserId(),e.getId(),e.getReceivable(),Collections.singletonList(e.getCustomerName()));
|
|
|
-// Map<String, String> paraMap = new HashMap<>();
|
|
|
-// paraMap.put("company", e.getAccountBillTitle());
|
|
|
-// paraMap.put("wizardId", e.getId().toString());
|
|
|
-// paraMap.put("accountBookId",e.getAccountBookId().toString());
|
|
|
-// messageNoticeService.sendPushmsg(e.getUserId(), Dict.MsgNameEnum.评级无变动APP提醒, paraMap);
|
|
|
}
|
|
|
});
|
|
|
}
|