|
@@ -0,0 +1,403 @@
|
|
|
+package com.winhc.repal.task;
|
|
|
+
|
|
|
+import cn.hutool.core.collection.CollUtil;
|
|
|
+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;
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import com.winhc.common.model.base.VOPage;
|
|
|
+import com.winhc.repal.cloud.dto.QueryESFinanceDynamicDTO;
|
|
|
+import com.winhc.repal.cloud.dto.QueryV8DynamicDTO;
|
|
|
+import com.winhc.repal.cloud.vo.FinanceDynamicVO;
|
|
|
+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.enums.*;
|
|
|
+import com.winhc.repal.service.*;
|
|
|
+import com.xxl.job.core.handler.annotation.XxlJob;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Component;
|
|
|
+
|
|
|
+import javax.annotation.PostConstruct;
|
|
|
+import java.time.LocalDate;
|
|
|
+import java.time.LocalDateTime;
|
|
|
+import java.time.ZoneOffset;
|
|
|
+import java.time.format.DateTimeFormatter;
|
|
|
+import java.time.temporal.ChronoUnit;
|
|
|
+import java.util.*;
|
|
|
+import java.util.concurrent.TimeUnit;
|
|
|
+import java.util.concurrent.atomic.AtomicReference;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @author Aaron
|
|
|
+ * @date 2020/12/17 10:59
|
|
|
+ * @description 智能提醒定时调度
|
|
|
+ */
|
|
|
+@Component
|
|
|
+@Slf4j
|
|
|
+public class SmartRemindTask {
|
|
|
+ private static final int PAGE_SIZE = 100;
|
|
|
+ private static final String MESSAGE_PRIFIX = "msg_prifix_";
|
|
|
+ @Autowired
|
|
|
+ private RepalBillService accountBillService;
|
|
|
+ @Autowired
|
|
|
+ private RepalRemindDefinitionService accountRemindDefinitionService;
|
|
|
+ @Autowired
|
|
|
+ private RepalRemindHistoryService accountRemindHistoryService;
|
|
|
+ @Autowired
|
|
|
+ private CompanyService companyService;
|
|
|
+ @Autowired
|
|
|
+ private RepalBillDiagnosisService diagnosisService;
|
|
|
+// @Autowired
|
|
|
+// private MessageNoticeService messageNoticeService;
|
|
|
+// @Autowired
|
|
|
+// private RedisUtil redisUtil;
|
|
|
+// @Autowired
|
|
|
+// private AccountRemindSettingService accountRemindSettingService;
|
|
|
+
|
|
|
+ private static final HashMap<String,String> RISK_MAP = new HashMap<>(32);
|
|
|
+
|
|
|
+ private static final DateTimeFormatter DATE_TIME_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
|
+
|
|
|
+ private static final DateTimeFormatter DATE_TIME_FINANCE = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 初始化风险预警map,填入需要预警的动态类型
|
|
|
+ */
|
|
|
+ @PostConstruct
|
|
|
+ private void initRiskMap(){
|
|
|
+ RISK_MAP.put(DynamicEnum.失信被执行人.getTn(),DynamicEnum.失信被执行人.name());
|
|
|
+ RISK_MAP.put(DynamicEnum.被执行人.getTn(),DynamicEnum.被执行人.name());
|
|
|
+ RISK_MAP.put(DynamicEnum.司法拍卖.getTn(),DynamicEnum.司法拍卖.name());
|
|
|
+ RISK_MAP.put(DynamicEnum.简易注销.getTn(),DynamicEnum.简易注销.name());
|
|
|
+ RISK_MAP.put(DynamicEnum.严重违法.getTn(),DynamicEnum.严重违法.name());
|
|
|
+ RISK_MAP.put(DynamicEnum.裁判文书.getTn(),DynamicEnum.裁判文书.name());
|
|
|
+ RISK_MAP.put(DynamicEnum.法院公告.getTn(),DynamicEnum.法院公告.name());
|
|
|
+ RISK_MAP.put(DynamicEnum.开庭公告.getTn(),DynamicEnum.开庭公告.name());
|
|
|
+ RISK_MAP.put(DynamicEnum.土地抵押.getTn(),DynamicEnum.土地抵押.name());
|
|
|
+ RISK_MAP.put(DynamicEnum.动产抵押.getTn(),DynamicEnum.动产抵押.name());
|
|
|
+ RISK_MAP.put(DynamicEnum.土地转让.getTn(),DynamicEnum.土地转让.name());
|
|
|
+ RISK_MAP.put(DynamicEnum.股权出质.getTn(),DynamicEnum.股权出质.name());
|
|
|
+ RISK_MAP.put(DynamicEnum.欠税公告.getTn(),DynamicEnum.欠税公告.name());
|
|
|
+ RISK_MAP.put(DynamicEnum.税收违法.getTn(),DynamicEnum.税收违法.name());
|
|
|
+ RISK_MAP.put(DynamicEnum.经营异常.getTn(),DynamicEnum.经营异常.name());
|
|
|
+ RISK_MAP.put(DynamicEnum.股东变更.getTn(), DynamicEnum.股东变更.name());
|
|
|
+ RISK_MAP.put(DynamicEnum.立案信息.getTn(),DynamicEnum.立案信息.name());
|
|
|
+ RISK_MAP.put(DynamicEnum.破产信息.getTn(),DynamicEnum.破产信息.name());
|
|
|
+ RISK_MAP.put(DynamicEnum.终本案件.getTn(),DynamicEnum.终本案件.name());
|
|
|
+ RISK_MAP.put(DynamicEnum.限制高消费.getTn(),DynamicEnum.限制高消费.name());
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 每日早上10点跑动态(涉及到发短信和push,不能放在半夜)
|
|
|
+ * 更新逾期状态
|
|
|
+ * 检查账款公司是否有新的动态,若有,自动刷新评级
|
|
|
+ * 新动态时间为今天-2(入库时间为昨天,动态时间为前天)
|
|
|
+ */
|
|
|
+ //@Scheduled(cron = "0 0 10 * * ?")
|
|
|
+ @XxlJob("checkTrend")
|
|
|
+ public void checkTrend(){
|
|
|
+ LocalDate now = LocalDate.now();
|
|
|
+ LambdaQueryWrapper<RepalBill> qw = Wrappers.lambdaQuery(RepalBill.class);
|
|
|
+ qw.ne(RepalBill::getRepalBillStatus,RepalBillStatusEnum.SUCCESS.getCode());
|
|
|
+ qw.ne(RepalBill::getUserId,0);
|
|
|
+ qw.eq(RepalBill::getDeleted,Dict.DeletedStatusEnunm.否.getCode());
|
|
|
+ IPage<RepalBill> countAccountBill =accountBillService.page(new Page<>(1,1),qw);
|
|
|
+ long pageNum = (countAccountBill.getTotal()+PAGE_SIZE-1) / PAGE_SIZE;
|
|
|
+ for(long i = 1;i<= pageNum ; i++){
|
|
|
+ IPage<RepalBill> result = accountBillService.page(new Page<>(i,PAGE_SIZE),qw);
|
|
|
+ List<RepalBill> billList = result.getRecords();
|
|
|
+ //更新逾期状态
|
|
|
+ billList.forEach(e->{
|
|
|
+ //todo 过滤没开通标准版和高级版的账款
|
|
|
+// AccountRemindSettingVO accountRemindSetting = accountRemindSettingService.find(e.getUserId());
|
|
|
+ AtomicReference<Boolean> needRefreshGrade = new AtomicReference<>(Boolean.FALSE);
|
|
|
+ AtomicReference<RepalRemindHistory> lastestRemind = new AtomicReference<>(null);
|
|
|
+ LocalDate endDate = e.getEndDate();
|
|
|
+ //顺带更新逾期状态
|
|
|
+ if((endDate !=null && endDate.isBefore(now) || endDate !=null && endDate.isEqual(now))
|
|
|
+ && RepalBillStatusEnum.PROGRESSING.getCode().equals(e.getRepalBillStatus())){
|
|
|
+ e.setRepalBillStatus(RepalBillStatusEnum.OVERDUE.getCode());
|
|
|
+ accountBillService.updateById(e);
|
|
|
+ }
|
|
|
+ //更新逾期提醒
|
|
|
+ OverdueEnum overdueEnum = getDaysBetween(endDate);
|
|
|
+ try {
|
|
|
+ if (!OverdueEnum.其他.equals(overdueEnum)) {
|
|
|
+ LambdaQueryWrapper<RepalRemindDefinition> definitionQueryWrapper = Wrappers.lambdaQuery(RepalRemindDefinition.class);
|
|
|
+ definitionQueryWrapper.eq(RepalRemindDefinition::getRemindType, RemindEnum.逾期提醒.name());
|
|
|
+ definitionQueryWrapper.eq(RepalRemindDefinition::getOpportunity, overdueEnum.getCode());
|
|
|
+ definitionQueryWrapper.eq(RepalRemindDefinition::getRepalBillStatus, e.getRepalBillStatus());
|
|
|
+ definitionQueryWrapper.eq(RepalRemindDefinition::getRepalBillStage, e.getRepalBillStage() == null ? 1 : e.getRepalBillStage());
|
|
|
+ RepalRemindDefinition accountRemindDefinition = accountRemindDefinitionService.getOne(definitionQueryWrapper, false);
|
|
|
+ if (accountRemindDefinition != null) {
|
|
|
+ //检查是否已经有相应的逾期提醒了
|
|
|
+ LambdaQueryWrapper<RepalRemindHistory> remindHistoryQueryWrapper = Wrappers.lambdaQuery(RepalRemindHistory.class);
|
|
|
+ remindHistoryQueryWrapper.eq(RepalRemindHistory::getRemindTitle, overdueEnum.name());
|
|
|
+ remindHistoryQueryWrapper.eq(RepalRemindHistory::getRepalBillId, e.getId());
|
|
|
+ RepalRemindHistory accountRemindHistory = accountRemindHistoryService.getOne(remindHistoryQueryWrapper, false);
|
|
|
+ if (accountRemindHistory == null) {
|
|
|
+ RepalRemindHistory newRemind = new RepalRemindHistory();
|
|
|
+ newRemind.setUserId(e.getUserId());
|
|
|
+ newRemind.setRepalBookId(e.getRepalBookId());
|
|
|
+ newRemind.setRepalBillId(e.getId());
|
|
|
+ newRemind.setTrendId(e.getDiagnosisId() == null ? "" : e.getDiagnosisId() + "");
|
|
|
+ newRemind.setTrendContent(e.getEndDate().atStartOfDay().toInstant(ZoneOffset.ofHours(8)).toEpochMilli() + "");
|
|
|
+ newRemind.setRemindTime(LocalDateTime.now());
|
|
|
+ newRemind.setCompanyName(e.getCustomerName());
|
|
|
+ newRemind.setRemindTitle(overdueEnum.name());
|
|
|
+ newRemind.setRemindContent(accountRemindDefinition.getRemindContent());
|
|
|
+ newRemind.setFunctionList(accountRemindDefinition.getFunctionList());
|
|
|
+ newRemind.setRemindType(RemindEnum.逾期提醒.name());
|
|
|
+ newRemind.setReadStatus(ReadStatusEnum.未读.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);
|
|
|
+// }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }catch (Exception ee){
|
|
|
+ log.error("逾期提醒出错",ee);
|
|
|
+ }
|
|
|
+ //财产线索
|
|
|
+ Arrays.stream(FinanceDynamicTypeEnum.values()).forEach(financeDynamicTypeEnum -> {
|
|
|
+ try{
|
|
|
+ //匹配提醒措施,匹配到再去查动态
|
|
|
+ LambdaQueryWrapper<RepalRemindDefinition> financeQw = Wrappers.lambdaQuery(RepalRemindDefinition.class);
|
|
|
+ financeQw.eq(RepalRemindDefinition::getRemindType, RemindEnum.财产线索.name());
|
|
|
+ financeQw.eq(RepalRemindDefinition::getOpportunity, financeDynamicTypeEnum.getCode());
|
|
|
+ financeQw.eq(RepalRemindDefinition::getRepalBillStatus, e.getRepalBillStatus());
|
|
|
+ financeQw.eq(RepalRemindDefinition::getRepalBillStatus, e.getRepalBillStage() == null ? 1 :e.getRepalBillStage());
|
|
|
+ RepalRemindDefinition accountRemindDefinition = accountRemindDefinitionService.getOne(financeQw, false);
|
|
|
+ if (accountRemindDefinition != null) {
|
|
|
+ //取前一天入库的一周内的动态
|
|
|
+ QueryESFinanceDynamicDTO requestDto = new QueryESFinanceDynamicDTO();
|
|
|
+ requestDto.setPageNum("1");
|
|
|
+ requestDto.setPageSize("20");
|
|
|
+ requestDto.setKeyWords(Collections.singletonList(e.getCustomerName()))
|
|
|
+ .setType(financeDynamicTypeEnum.getCode())
|
|
|
+ .setCreateDateFrom(now.minusDays(1).atTime(0,0,0).format(DATE_TIME_FINANCE))
|
|
|
+ .setCreateDateEnd(now.minusDays(1).atTime(23,59,59).format(DATE_TIME_FINANCE))
|
|
|
+ .setDateFrom(now.minusDays(30).atTime(0,0,0).format(DATE_TIME_FINANCE))
|
|
|
+ .setDateEnd(now.minusDays(1).atTime(23,59,59).format(DATE_TIME_FINANCE));
|
|
|
+ VOPage<FinanceDynamicVO> dynamics = companyService.pageFinanceDynamic(requestDto);
|
|
|
+ if(dynamics!=null && CollUtil.isNotEmpty(dynamics.getDataList())){
|
|
|
+ dynamics.getDataList().forEach(financeDynamicVO -> {
|
|
|
+ //新增动态提醒
|
|
|
+ RepalRemindHistory accountRemindHistory = new RepalRemindHistory();
|
|
|
+ accountRemindHistory.setUserId(e.getUserId())
|
|
|
+ .setRepalBookId(e.getRepalBookId())
|
|
|
+ .setRepalBillId(e.getId())
|
|
|
+ .setTrendId(financeDynamicVO.getId())
|
|
|
+ .setTrendContent(JSON.toJSONString(financeDynamicVO.getDetail()))
|
|
|
+ .setTrentType(financeDynamicTypeEnum.getCode())
|
|
|
+ .setRemindTime(LocalDateTime.now())
|
|
|
+ .setCompanyName(e.getCustomerName())
|
|
|
+ .setRemindTitle(financeDynamicTypeEnum.getDesc())
|
|
|
+ .setRemindContent(StrUtil.format(accountRemindDefinition.getRemindContent(),
|
|
|
+ e.getCustomerName()))
|
|
|
+ .setFunctionList(accountRemindDefinition.getFunctionList())
|
|
|
+ .setRemindType(RemindEnum.财产线索.name())
|
|
|
+ .setReadStatus(ReadStatusEnum.未读.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);
|
|
|
+// }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }catch (Exception ee){
|
|
|
+ log.error("财产线索提醒出错",ee);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ //风险预警
|
|
|
+ RISK_MAP.keySet().forEach(type -> {
|
|
|
+ try {
|
|
|
+ //匹配提醒措施,匹配到再去查动态
|
|
|
+ LambdaQueryWrapper<RepalRemindDefinition> definitionQw = Wrappers.lambdaQuery(RepalRemindDefinition.class);
|
|
|
+ definitionQw.eq(RepalRemindDefinition::getRemindType, RemindEnum.风险预警.name());
|
|
|
+ definitionQw.eq(RepalRemindDefinition::getOpportunity, DynamicEnum.getOpportunityByTn(type));
|
|
|
+ definitionQw.eq(RepalRemindDefinition::getRepalBillStatus, e.getRepalBillStatus());
|
|
|
+ definitionQw.eq(RepalRemindDefinition::getRepalBillStage, e.getRepalBillStage() == null ? 1 : e.getRepalBillStage());
|
|
|
+ RepalRemindDefinition accountRemindDefinition = accountRemindDefinitionService.getOne(definitionQw, false);
|
|
|
+ if (accountRemindDefinition != null) {
|
|
|
+ QueryV8DynamicDTO dynamicDto = new QueryV8DynamicDTO();
|
|
|
+ dynamicDto.setEntityNames(Collections.singletonList(e.getCustomerName()));
|
|
|
+ dynamicDto.setUpdateTime(now.minusDays(1).format(DATE_TIME_FORMATTER));
|
|
|
+ dynamicDto.setStartDate(now.minusDays(30).format(DATE_TIME_FORMATTER));
|
|
|
+ dynamicDto.setEndDate(now.minusDays(1).format(DATE_TIME_FORMATTER));
|
|
|
+ dynamicDto.setInfoTypes(Collections.singletonList(DynamicEnum.getInfoTypeByTn(type)));
|
|
|
+ if (type.equals(DynamicEnum.裁判文书.getTn())
|
|
|
+ || type.equals(DynamicEnum.法院公告.getTn())
|
|
|
+ || type.equals(DynamicEnum.开庭公告.getTn())
|
|
|
+ || type.equals(DynamicEnum.土地抵押.getTn())
|
|
|
+ || type.equals(DynamicEnum.动产抵押.getTn())
|
|
|
+ || type.equals(DynamicEnum.土地转让.getTn())
|
|
|
+ || type.equals(DynamicEnum.股权出质.getTn())) {
|
|
|
+ dynamicDto.setRiskLevel("3");
|
|
|
+ }
|
|
|
+ VOPage<V8DynamicVO> esDynamics = companyService.queryDynamic(dynamicDto,1,10);
|
|
|
+ if (esDynamics != null && CollUtil.isNotEmpty(esDynamics.getDataList())) {
|
|
|
+ esDynamics.getDataList().forEach(esDynamic -> {
|
|
|
+ //新增动态提醒
|
|
|
+ String titleString = RISK_MAP.get(type);
|
|
|
+ RepalRemindHistory accountRemindHistory = new RepalRemindHistory();
|
|
|
+ accountRemindHistory.setUserId(e.getUserId())
|
|
|
+ .setRepalBookId(e.getRepalBookId())
|
|
|
+ .setRepalBillId(e.getId())
|
|
|
+ .setTrendId(esDynamic.getId())
|
|
|
+ .setTrendContent(esDynamic.getDynamicInfo())
|
|
|
+ .setTrentType(esDynamic.getTn())
|
|
|
+ .setRemindTime(LocalDateTime.now())
|
|
|
+ .setCompanyName(e.getCustomerName())
|
|
|
+ .setRemindTitle(titleString)
|
|
|
+ .setRemindContent(StrUtil.format(accountRemindDefinition.getRemindContent(),
|
|
|
+ e.getCustomerName()))
|
|
|
+ .setFunctionList(accountRemindDefinition.getFunctionList())
|
|
|
+ .setRemindType(RemindEnum.风险预警.name())
|
|
|
+ .setReadStatus(ReadStatusEnum.未读.getCode())
|
|
|
+ .setBizId(esDynamic.getRowkey())
|
|
|
+ .setInfoType(esDynamic.getInfoType())
|
|
|
+ .setDynamicId(esDynamic.getId())
|
|
|
+ .setIsNew(1)
|
|
|
+ .setNewTrendContent(JSON.toJSONString(esDynamic.getDynamicJSON()));
|
|
|
+ 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);
|
|
|
+// }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }catch (Exception ee){
|
|
|
+ log.error("风险提醒出错",ee);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ //更新账款的最新动态信息
|
|
|
+ if(ObjectUtil.isNotNull(lastestRemind.get())){
|
|
|
+ RepalRemindHistory latest = lastestRemind.get();
|
|
|
+ //掐头去尾压进accountbill.remindInfo中
|
|
|
+ Map<String,Object> remindMap = new HashMap<>();
|
|
|
+ remindMap.put("remindType",latest.getRemindType());
|
|
|
+ remindMap.put("remindTitle",latest.getRemindTitle());
|
|
|
+ remindMap.put("id",latest.getId().toString());
|
|
|
+ remindMap.put("remindTime",latest.getRemindTime());
|
|
|
+ String remindContent = latest.getRemindContent();
|
|
|
+ if(remindContent.length() > 100){
|
|
|
+ remindContent = remindContent.substring(0,100);
|
|
|
+ }
|
|
|
+ remindMap.put("remindContent",remindContent);
|
|
|
+ e.setRemindInfo(JSON.toJSONString(remindMap));
|
|
|
+ accountBillService.updateById(e);
|
|
|
+ }
|
|
|
+ //有新动态则自动刷新评级
|
|
|
+ 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)){
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ log.info("完成每日智能提醒调度");
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 正常时间流逝的逾期提醒
|
|
|
+ * @param endDate
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private OverdueEnum getDaysBetween(LocalDate endDate){
|
|
|
+ if(endDate == null){
|
|
|
+ return OverdueEnum.其他;
|
|
|
+ }
|
|
|
+ long delta = LocalDate.now().toEpochDay() - endDate.toEpochDay();
|
|
|
+ OverdueEnum overdueEnum = OverdueEnum.其他;
|
|
|
+ if(delta <= 0 && delta >=-7){
|
|
|
+ overdueEnum = OverdueEnum.即将逾期;
|
|
|
+ }else if(delta > 0 && delta <90){
|
|
|
+ overdueEnum = OverdueEnum.已逾期;
|
|
|
+ }else if(delta >=90 && delta<180){
|
|
|
+ overdueEnum = OverdueEnum.已逾期三个月;
|
|
|
+ }else if(delta >=180 && delta<365){
|
|
|
+ overdueEnum = OverdueEnum.已逾期半年;
|
|
|
+ }else if(delta >=365 && delta<365*3){
|
|
|
+ overdueEnum = OverdueEnum.已逾期一年;
|
|
|
+ }else if(delta >= 365*3){
|
|
|
+ overdueEnum = OverdueEnum.已逾期三年;
|
|
|
+ }
|
|
|
+ return overdueEnum;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 计算当天剩余的毫秒时间
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private Long calTTL(){
|
|
|
+ LocalDateTime midnight = LocalDateTime.now().plusDays(1).withHour(0).withMinute(0).withSecond(0).withNano(0);
|
|
|
+ return ChronoUnit.MILLIS.between(LocalDateTime.now(),midnight);
|
|
|
+ }
|
|
|
+
|
|
|
+ @XxlJob("updateAccountBillStatus")
|
|
|
+ public void updateAccountBillStatus() {
|
|
|
+ log.info("updateAccountBillStatus");
|
|
|
+ LambdaUpdateWrapper<RepalBill> updateWrapper = Wrappers.lambdaUpdate(RepalBill.class)
|
|
|
+ .eq(RepalBill::getRepalBillStatus, RepalBillStatusEnum.PROGRESSING.getCode())
|
|
|
+ .eq(RepalBill::getDeleted, Dict.DeletedStatusEnunm.否.getCode())
|
|
|
+ .le(RepalBill::getEndDate, LocalDate.now()).set(RepalBill::getRepalBillStatus, RepalBillStatusEnum.OVERDUE.getCode());
|
|
|
+ accountBillService.update(updateWrapper);
|
|
|
+ log.info("update is ok");
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+}
|