|
@@ -1,14 +1,25 @@
|
|
|
package com.winhc.repal.service.impl;
|
|
|
|
|
|
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.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import com.module.login.usersession.UserBean;
|
|
|
+import com.winhc.common.enums.CodeMsg;
|
|
|
+import com.winhc.common.exception.CommonException;
|
|
|
+import com.winhc.common.model.base.VOPage;
|
|
|
+import com.winhc.repal.cloud.dto.QueryV8DynamicDTO;
|
|
|
+import com.winhc.repal.cloud.vo.V8DynamicVO;
|
|
|
import com.winhc.repal.entity.*;
|
|
|
import com.winhc.repal.enums.*;
|
|
|
-import com.winhc.repal.model.vo.RemindTypeUnReadCountVO;
|
|
|
-import com.winhc.repal.model.vo.RepalBillRemindUnReadVO;
|
|
|
+import com.winhc.repal.model.cvt.RepalRemindHistoryConvert;
|
|
|
+import com.winhc.repal.model.dto.RepalRemindHistoryDTO;
|
|
|
+import com.winhc.repal.model.vo.*;
|
|
|
import com.winhc.repal.repository.RepalRemindHistoryMapper;
|
|
|
import com.winhc.repal.service.*;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
@@ -19,11 +30,12 @@ import org.springframework.stereotype.Service;
|
|
|
import java.math.BigDecimal;
|
|
|
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.HashMap;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
+import java.util.*;
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
+import java.util.function.Function;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
@@ -46,6 +58,16 @@ public class RepalRemindHistoryServiceImpl extends ServiceImpl<RepalRemindHistor
|
|
|
private RepalRemindReadInfoService repalRemindReadInfoService;
|
|
|
@Autowired
|
|
|
private RepalRemindHistoryMapper repalRemindHistoryMapper;
|
|
|
+ @Autowired
|
|
|
+ private RepalBillService repalBillService;
|
|
|
+ @Autowired
|
|
|
+ private RepalBillDiagnosisService repalBillDiagnosisService;
|
|
|
+ @Autowired
|
|
|
+ private CompanyService companyService;
|
|
|
+ @Autowired
|
|
|
+ private RepalCustomerService repalCustomerService;
|
|
|
+ @Autowired
|
|
|
+ private RepalBookService repalBookService;
|
|
|
|
|
|
@Override
|
|
|
public RepalBillRemindUnReadVO getRemindUnReadVO(List<RepalBill> repalBills,Long userId) {
|
|
@@ -142,6 +164,314 @@ public class RepalRemindHistoryServiceImpl extends ServiceImpl<RepalRemindHistor
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public RepalRemindHistoryVO getDetailById(Long id, UserBean userBean) {
|
|
|
+
|
|
|
+ RepalRemindHistory bean = getById(id);
|
|
|
+ RepalRemindHistoryVO remindHistoryVO = RepalRemindHistoryConvert.EntityToVO(bean);
|
|
|
+ RepalBill accountBill = repalBillService.getById(remindHistoryVO.getRepalBillId());
|
|
|
+
|
|
|
+ //评级提醒返回本次评分 上次评分,以及动态监测
|
|
|
+ if (RemindEnum.账款评级.getCode().equals(remindHistoryVO.getRemindType())) {
|
|
|
+ RepalBillDiagnosis accountBillDiagnosis = repalBillDiagnosisService.getById(remindHistoryVO.getTrendId());
|
|
|
+ if (ObjectUtil.isNotNull(accountBillDiagnosis)) {
|
|
|
+ QueryV8DynamicDTO dynamicDto = new QueryV8DynamicDTO();
|
|
|
+ remindHistoryVO.setDiagnosisGrade(accountBillDiagnosis.getDiagnosisGrade())
|
|
|
+ .setDiagnosisScore(accountBillDiagnosis.getDiagnosisScore())
|
|
|
+ .setDiagnosisDatetime(accountBillDiagnosis.getDiagnosisDatetime())
|
|
|
+ .setDiagnosisRecordId(accountBillDiagnosis.getBizId());
|
|
|
+ dynamicDto.setEndDate(accountBillDiagnosis.getDiagnosisDatetime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd")));
|
|
|
+
|
|
|
+ if (StrUtil.isNotEmpty(remindHistoryVO.getTrendContent())) {
|
|
|
+ RepalBillDiagnosis preAccountDiagnosis = repalBillDiagnosisService.getById(remindHistoryVO.getTrendContent());
|
|
|
+ if (ObjectUtil.isNotNull(preAccountDiagnosis)) {
|
|
|
+ remindHistoryVO.setPreDiagnosisGrade(preAccountDiagnosis.getDiagnosisGrade())
|
|
|
+ .setPreDiagnosisScore(preAccountDiagnosis.getDiagnosisScore())
|
|
|
+ .setPreDiagnosisDatetime(preAccountDiagnosis.getDiagnosisDatetime());
|
|
|
+ dynamicDto.setStartDate(preAccountDiagnosis.getDiagnosisDatetime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd")));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ dynamicDto.setEntityNames(Collections.singletonList(accountBill.getCustomerName()));
|
|
|
+ VOPage<V8DynamicVO> resultPage = companyService.queryDynamic(dynamicDto, 1, 10);
|
|
|
+ if (ObjectUtil.isNull(resultPage) || ObjectUtil.isNull(resultPage.getDataList()) || CollUtil.isEmpty(resultPage.getDataList())) {
|
|
|
+ DiagnosisDynamicVO dynamicVO = new DiagnosisDynamicVO();
|
|
|
+ dynamicVO.setRtaDesc("该账款信息发生变动(欠款企业、金额有所调整)");
|
|
|
+ dynamicVO.setCreateTime(accountBill.getTimeModified().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
|
|
|
+ remindHistoryVO.setEsDynamics(Collections.singletonList(dynamicVO));
|
|
|
+ }
|
|
|
+ remindHistoryVO.setEsDynamics(resultPage.getDataList().stream().map(entity -> {
|
|
|
+ DiagnosisDynamicVO diagnosisDynamicVO = new DiagnosisDynamicVO();
|
|
|
+ diagnosisDynamicVO.setNewDynamicId(entity.getId());
|
|
|
+ diagnosisDynamicVO.setRowKey(entity.getRowkey());
|
|
|
+ diagnosisDynamicVO.setCreateTime(entity.getDynamicTime());
|
|
|
+
|
|
|
+ String rtaDesc = DynamicEnum.getDescByTn(entity.getTn());
|
|
|
+ diagnosisDynamicVO.setRtaDesc(rtaDesc);
|
|
|
+ diagnosisDynamicVO.setTn(entity.getTn());
|
|
|
+ diagnosisDynamicVO.setInfoType(entity.getInfoType());
|
|
|
+ diagnosisDynamicVO.setNewRemindContent(JSON.toJSONString(entity.getDynamicJSON()));
|
|
|
+ diagnosisDynamicVO.setRouting(DynamicEnum.getRoutingByTn(entity.getTn()));
|
|
|
+ return diagnosisDynamicVO;
|
|
|
+ }).collect(Collectors.toList()));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //逾期提醒返回本次评分以及应收账款日期
|
|
|
+ else if (RemindEnum.逾期提醒.getCode().equals(remindHistoryVO.getRemindType())) {
|
|
|
+ RepalBillDiagnosis accountBillDiagnosis = repalBillDiagnosisService.getById(remindHistoryVO.getTrendId());
|
|
|
+ if (ObjectUtil.isNotNull(accountBillDiagnosis)) {
|
|
|
+ remindHistoryVO.setDiagnosisGrade(accountBillDiagnosis.getDiagnosisGrade())
|
|
|
+ .setDiagnosisScore(accountBillDiagnosis.getDiagnosisScore())
|
|
|
+ .setDiagnosisDatetime(accountBillDiagnosis.getDiagnosisDatetime());
|
|
|
+ }
|
|
|
+ remindHistoryVO.setEndDate(LocalDateTime.ofEpochSecond(Long.parseLong(remindHistoryVO.getTrendContent()) / 1000, 0, ZoneOffset.ofHours(8)));
|
|
|
+ }
|
|
|
+ RepalCustomer repalCustomer = repalCustomerService.getById(accountBill.getCustomerId());
|
|
|
+ if(ObjectUtil.isNotNull(repalCustomer)) {
|
|
|
+ remindHistoryVO.setCompanyId(repalCustomer.getCompanyId());
|
|
|
+ }
|
|
|
+ //更新已读状态,感觉用不到,还是加上吧
|
|
|
+ repalRemindReadInfoService.updateReadInfoByUserId(userBean.getUserId(),bean.getRemindType(),accountBill.getId(),accountBill.getRepalBookId());
|
|
|
+ return remindHistoryVO;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public RepalRemindCountVO queryRemidCount(RepalRemindHistoryDTO dto, UserBean userBean) {
|
|
|
+ //参数校验
|
|
|
+ if(ObjectUtil.isNull(dto.getQueryType())){
|
|
|
+ throw new CommonException(CodeMsg.VALIDATE_PARAMETER);
|
|
|
+ }
|
|
|
+ LocalDateTime localDateTime = LocalDateTime.now().withYear(2019);
|
|
|
+ //添加查询时间的条件
|
|
|
+ if (StrUtil.isBlank(dto.getTimeSlot()) || Dict.TIME_SLOT_ENUM.近30天.getCode().equals(dto.getTimeSlot())) {
|
|
|
+ localDateTime = LocalDateTime.now().minusDays(30).withHour(0).withMinute(0).withSecond(0);
|
|
|
+ }
|
|
|
+ RepalRemindCountVO result = new RepalRemindCountVO(0,0,0,0,0,0,0,0,0,0);
|
|
|
+ if(Dict.COUNT_QUERY_ENUM.账款.getCode().equals(dto.getQueryType())){
|
|
|
+ if(ObjectUtil.isNull(dto.getRepalBillId())){
|
|
|
+ throw new CommonException(CodeMsg.VALIDATE_PARAMETER);
|
|
|
+ }
|
|
|
+ RepalBill repalBill = repalBillService.getById(dto.getRepalBillId());
|
|
|
+ RepalRemindReadInfo repalRemindReadInfo = repalRemindReadInfoService.getReadInfoByUserId(userBean.getUserId(), dto.getRepalBillId(), repalBill.getRepalBookId());
|
|
|
+ result = repalRemindHistoryMapper.remindCount(repalBill.getId(),localDateTime,repalRemindReadInfo.getRiskRemindId(),repalRemindReadInfo.getRankRemindId(),repalRemindReadInfo.getOverdueRemindId(),repalRemindReadInfo.getFinanceRemindId());
|
|
|
+ result.setUnreadTotalCount(result.getUnreadRankCount()+result.getUnreadRiskCount()+result.getUnreadOverdueCount()+result.getUnreadFinanceCount());
|
|
|
+ }else if(Dict.COUNT_QUERY_ENUM.客户.getCode().equals(dto.getQueryType())){
|
|
|
+ if(ObjectUtil.isNull(dto.getCustId())){
|
|
|
+ throw new CommonException(CodeMsg.VALIDATE_PARAMETER);
|
|
|
+ }
|
|
|
+ //客户维度多账款
|
|
|
+ List<RepalBill> repalBills = repalBillService.list(Wrappers.lambdaQuery(RepalBill.class).eq(RepalBill::getCustomerId,dto.getCustId()).eq(RepalBill::getDeleted, Dict.DeletedStatusEnunm.否.getCode()));
|
|
|
+ for(RepalBill repalBill:repalBills){
|
|
|
+ RepalRemindReadInfo repalRemindReadInfo = repalRemindReadInfoService.getReadInfoByUserId(userBean.getUserId(), dto.getRepalBillId(), repalBill.getRepalBookId());
|
|
|
+ RepalRemindCountVO tmp = repalRemindHistoryMapper.remindCount(repalBill.getId(),localDateTime,repalRemindReadInfo.getRiskRemindId(),repalRemindReadInfo.getRankRemindId(),repalRemindReadInfo.getOverdueRemindId(),repalRemindReadInfo.getFinanceRemindId());
|
|
|
+ result.setFinanceCount(result.getFinanceCount()+tmp.getFinanceCount());
|
|
|
+ result.setRankCount(result.getRankCount()+tmp.getRankCount());
|
|
|
+ result.setOverdueCount(result.getOverdueCount()+tmp.getOverdueCount());
|
|
|
+ result.setRiskCount(result.getRiskCount()+tmp.getRiskCount());
|
|
|
+ result.setUnreadRiskCount(result.getUnreadRiskCount()+tmp.getUnreadRiskCount());
|
|
|
+ result.setUnreadRankCount(result.getUnreadRankCount()+tmp.getUnreadRankCount());
|
|
|
+ result.setUnreadFinanceCount(result.getUnreadFinanceCount()+tmp.getUnreadFinanceCount());
|
|
|
+ result.setUnreadOverdueCount(result.getUnreadOverdueCount()+tmp.getUnreadOverdueCount());
|
|
|
+ result.setTotalCount(result.getTotalCount()+tmp.getTotalCount());
|
|
|
+ result.setUnreadTotalCount(result.getUnreadTotalCount()+tmp.getUnreadTotalCount());
|
|
|
+ }
|
|
|
+ }else if(Dict.COUNT_QUERY_ENUM.用户.getCode().equals(dto.getQueryType())){
|
|
|
+ //用户->组织->客户s->账款s
|
|
|
+ ThirdPartyAccount thirdPartyAccount = thirdPartyAccountService.getOne(Wrappers.lambdaQuery(ThirdPartyAccount.class).eq(ThirdPartyAccount::getUserId,userBean.getUserId()).eq(ThirdPartyAccount::getAppId,0).eq(ThirdPartyAccount::getDeleted, Dict.DeletedStatusEnunm.否.getCode()),false);
|
|
|
+ if(thirdPartyAccount!=null){
|
|
|
+ List<RepalCustomer> repalCustomers = repalCustomerService.list(Wrappers.lambdaQuery(RepalCustomer.class).eq(RepalCustomer::getRepalGroupId,thirdPartyAccount.getGroupId()).eq(RepalCustomer::getDeleted,Dict.DeletedStatusEnunm.否.getCode()));
|
|
|
+ List<RepalBill> repalBills = repalBillService.list(Wrappers.lambdaQuery(RepalBill.class).in(RepalBill::getCustomerId,repalCustomers.stream().map(RepalCustomer::getCustId).collect(Collectors.toList())).eq(RepalBill::getDeleted, Dict.DeletedStatusEnunm.否.getCode()));
|
|
|
+ for(RepalBill repalBill:repalBills){
|
|
|
+ RepalRemindReadInfo repalRemindReadInfo = repalRemindReadInfoService.getReadInfoByUserId(userBean.getUserId(), dto.getRepalBillId(), repalBill.getRepalBookId());
|
|
|
+ RepalRemindCountVO tmp = repalRemindHistoryMapper.remindCount(repalBill.getId(),localDateTime,repalRemindReadInfo.getRiskRemindId(),repalRemindReadInfo.getRankRemindId(),repalRemindReadInfo.getOverdueRemindId(),repalRemindReadInfo.getFinanceRemindId());
|
|
|
+ result.setFinanceCount(result.getFinanceCount()+tmp.getFinanceCount());
|
|
|
+ result.setRankCount(result.getRankCount()+tmp.getRankCount());
|
|
|
+ result.setOverdueCount(result.getOverdueCount()+tmp.getOverdueCount());
|
|
|
+ result.setRiskCount(result.getRiskCount()+tmp.getRiskCount());
|
|
|
+ result.setUnreadRiskCount(result.getUnreadRiskCount()+tmp.getUnreadRiskCount());
|
|
|
+ result.setUnreadRankCount(result.getUnreadRankCount()+tmp.getUnreadRankCount());
|
|
|
+ result.setUnreadFinanceCount(result.getUnreadFinanceCount()+tmp.getUnreadFinanceCount());
|
|
|
+ result.setUnreadOverdueCount(result.getUnreadOverdueCount()+tmp.getUnreadOverdueCount());
|
|
|
+ result.setTotalCount(result.getTotalCount()+tmp.getTotalCount());
|
|
|
+ result.setUnreadTotalCount(result.getUnreadTotalCount()+tmp.getUnreadTotalCount());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public VOPage<RepalRemindHistoryVO> find(RepalRemindHistoryDTO dto, Integer pageNum, Integer pageSize, UserBean userBean) {
|
|
|
+ //参数校验
|
|
|
+ if(ObjectUtil.isNull(dto.getQueryType())){
|
|
|
+ throw new CommonException(CodeMsg.VALIDATE_PARAMETER);
|
|
|
+ }
|
|
|
+ LocalDateTime localDateTime = LocalDateTime.now().withYear(2019);
|
|
|
+ //添加查询时间的条件
|
|
|
+ if (StrUtil.isBlank(dto.getTimeSlot()) || Dict.TIME_SLOT_ENUM.近30天.getCode().equals(dto.getTimeSlot())) {
|
|
|
+ localDateTime = LocalDateTime.now().minusDays(30).withHour(0).withMinute(0).withSecond(0);
|
|
|
+ }
|
|
|
+ VOPage<RepalRemindHistoryVO> result = new VOPage<>(pageNum,pageSize,0L,new ArrayList<>());
|
|
|
+ LambdaQueryWrapper<RepalRemindHistory> qw = Wrappers.lambdaQuery(RepalRemindHistory.class);
|
|
|
+ if (StrUtil.isNotBlank(dto.getRemindType())) {
|
|
|
+ if (RemindEnum.财产线索.getCode().equals(dto.getRemindType())
|
|
|
+ || RemindEnum.逾期提醒.getCode().equals(dto.getRemindType())
|
|
|
+ || RemindEnum.账款评级.getCode().equals(dto.getRemindType())
|
|
|
+ || RemindEnum.风险预警.getCode().equals(dto.getRemindType())) {
|
|
|
+ qw.eq(RepalRemindHistory::getRemindType, dto.getRemindType());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ qw.ge(RepalRemindHistory::getRemindTime,localDateTime).orderByDesc(RepalRemindHistory::getId);
|
|
|
+ if(Dict.COUNT_QUERY_ENUM.账款.getCode().equals(dto.getQueryType())){
|
|
|
+ if(ObjectUtil.isNull(dto.getRepalBillId())){
|
|
|
+ throw new CommonException(CodeMsg.VALIDATE_PARAMETER);
|
|
|
+ }
|
|
|
+ qw.eq(RepalRemindHistory::getRepalBillId,dto.getRepalBillId());
|
|
|
+ IPage<RepalRemindHistory> pageAccountRemindHistory = page(new Page<>(pageNum, pageSize), qw);
|
|
|
+ if(CollUtil.isNotEmpty(pageAccountRemindHistory.getRecords())){
|
|
|
+ result = new VOPage<>(pageNum, pageSize, pageAccountRemindHistory.getTotal(), pageAccountRemindHistory.getRecords().stream()
|
|
|
+ .map(RepalRemindHistoryConvert::EntityToVO).collect(Collectors.toList()));
|
|
|
+ //更新已读未读状态
|
|
|
+ RepalBill repalBill = repalBillService.getById(dto.getRepalBillId());
|
|
|
+ RepalCustomer repalCustomer = repalCustomerService.getById(repalBill.getCustomerId());
|
|
|
+ RepalRemindReadInfo repalRemindReadInfo = repalRemindReadInfoService.getReadInfoByUserId(userBean.getUserId(), dto.getRepalBillId(), repalBill.getRepalBookId());
|
|
|
+ for(RepalRemindHistoryVO vo:result.getDataList()){
|
|
|
+ vo.setCompanyId(repalCustomer.getCompanyId());
|
|
|
+ vo.setReadStatus(Dict.ReadStatusEnum.已读.getCode());
|
|
|
+ if(RemindEnum.逾期提醒.getCode().equals(vo.getRemindType()) && vo.getId() > repalRemindReadInfo.getOverdueRemindId()){
|
|
|
+ vo.setReadStatus(Dict.ReadStatusEnum.未读.getCode());
|
|
|
+ }else if(RemindEnum.财产线索.getCode().equals(vo.getRemindType()) && vo.getId() > repalRemindReadInfo.getFinanceRemindId()){
|
|
|
+ vo.setReadStatus(Dict.ReadStatusEnum.未读.getCode());
|
|
|
+ }else if(RemindEnum.风险预警.getCode().equals(vo.getRemindType()) && vo.getId() > repalRemindReadInfo.getRiskRemindId()){
|
|
|
+ vo.setReadStatus(Dict.ReadStatusEnum.未读.getCode());
|
|
|
+ }else if(RemindEnum.账款评级.getCode().equals(vo.getRemindType()) && vo.getId() > repalRemindReadInfo.getRankRemindId()){
|
|
|
+ vo.setReadStatus(Dict.ReadStatusEnum.未读.getCode());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //查询详细分类时更新已读id
|
|
|
+ if(StrUtil.isNotBlank(dto.getRemindType())){
|
|
|
+ repalRemindReadInfoService.updateReadInfoByUserId(userBean.getUserId(), dto.getRemindType(),dto.getRepalBillId(), repalBill.getRepalBookId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }else if(Dict.COUNT_QUERY_ENUM.客户.getCode().equals(dto.getQueryType())){
|
|
|
+ if(ObjectUtil.isNull(dto.getCustId())){
|
|
|
+ throw new CommonException(CodeMsg.VALIDATE_PARAMETER);
|
|
|
+ }
|
|
|
+ //客户维度多账款
|
|
|
+ List<RepalBill> repalBills = repalBillService.list(Wrappers.lambdaQuery(RepalBill.class).eq(RepalBill::getCustomerId,dto.getCustId()).eq(RepalBill::getDeleted, Dict.DeletedStatusEnunm.否.getCode()));
|
|
|
+ qw.in(RepalRemindHistory::getRepalBillId,repalBills.stream().map(RepalBill::getId).collect(Collectors.toList()));
|
|
|
+ Map<String,RepalCustomer> repalCustomerMap = repalCustomerService.list(Wrappers.lambdaQuery(RepalCustomer.class).in(RepalCustomer::getCustId,repalBills.stream().map(RepalBill::getCustomerId).collect(Collectors.toList()))).stream().collect(Collectors.toMap(RepalCustomer::getCustName, Function.identity()));
|
|
|
+ IPage<RepalRemindHistory> pageAccountRemindHistory = page(new Page<>(pageNum, pageSize), qw);
|
|
|
+ if(CollUtil.isNotEmpty(pageAccountRemindHistory.getRecords())){
|
|
|
+ result = new VOPage<>(pageNum, pageSize, pageAccountRemindHistory.getTotal(), pageAccountRemindHistory.getRecords().stream()
|
|
|
+ .map(RepalRemindHistoryConvert::EntityToVO).collect(Collectors.toList()));
|
|
|
+ Map<Long,RepalRemindReadInfo> readInfoMap = new HashMap<>();
|
|
|
+ for(RepalRemindHistoryVO vo:result.getDataList()){
|
|
|
+ if(repalCustomerMap.containsKey(vo.getCompanyName())){
|
|
|
+ vo.setCompanyId(repalCustomerMap.get(vo.getCompanyName()).getCompanyId());
|
|
|
+ }
|
|
|
+ vo.setReadStatus(Dict.ReadStatusEnum.已读.getCode());
|
|
|
+ RepalRemindReadInfo repalRemindReadInfo;
|
|
|
+ if(readInfoMap.containsKey(vo.getRepalBillId())){
|
|
|
+ repalRemindReadInfo = readInfoMap.get(vo.getRepalBillId());
|
|
|
+ }else {
|
|
|
+ repalRemindReadInfo = repalRemindReadInfoService.getReadInfoByUserId(userBean.getUserId(), vo.getRepalBillId(), vo.getRepalBookId());
|
|
|
+ readInfoMap.put(vo.getRepalBillId(),repalRemindReadInfo);
|
|
|
+ }
|
|
|
+ if(RemindEnum.逾期提醒.getCode().equals(vo.getRemindType()) && vo.getId() > repalRemindReadInfo.getOverdueRemindId()){
|
|
|
+ vo.setReadStatus(Dict.ReadStatusEnum.未读.getCode());
|
|
|
+ }else if(RemindEnum.财产线索.getCode().equals(vo.getRemindType()) && vo.getId() > repalRemindReadInfo.getFinanceRemindId()){
|
|
|
+ vo.setReadStatus(Dict.ReadStatusEnum.未读.getCode());
|
|
|
+ }else if(RemindEnum.风险预警.getCode().equals(vo.getRemindType()) && vo.getId() > repalRemindReadInfo.getRiskRemindId()){
|
|
|
+ vo.setReadStatus(Dict.ReadStatusEnum.未读.getCode());
|
|
|
+ }else if(RemindEnum.账款评级.getCode().equals(vo.getRemindType()) && vo.getId() > repalRemindReadInfo.getRankRemindId()){
|
|
|
+ vo.setReadStatus(Dict.ReadStatusEnum.未读.getCode());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //查询详细分类时更新已读id
|
|
|
+ if(StrUtil.isNotBlank(dto.getRemindType()) && CollUtil.isNotEmpty(readInfoMap)){
|
|
|
+ for(RepalRemindReadInfo repalRemindReadInfo:readInfoMap.values()){
|
|
|
+ repalRemindReadInfoService.updateReadInfoByUserId(userBean.getUserId(), dto.getRemindType(),repalRemindReadInfo.getRepalBillId(), repalRemindReadInfo.getRepalBookId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }else if(Dict.COUNT_QUERY_ENUM.用户.getCode().equals(dto.getQueryType())){
|
|
|
+ //用户->组织->客户s->账款s
|
|
|
+ ThirdPartyAccount thirdPartyAccount = thirdPartyAccountService.getOne(Wrappers.lambdaQuery(ThirdPartyAccount.class).eq(ThirdPartyAccount::getUserId,userBean.getUserId()).eq(ThirdPartyAccount::getAppId,0).eq(ThirdPartyAccount::getDeleted, Dict.DeletedStatusEnunm.否.getCode()),false);
|
|
|
+ if(thirdPartyAccount!=null){
|
|
|
+ List<RepalCustomer> repalCustomers = repalCustomerService.list(Wrappers.lambdaQuery(RepalCustomer.class).eq(RepalCustomer::getRepalGroupId,thirdPartyAccount.getGroupId()).eq(RepalCustomer::getDeleted,Dict.DeletedStatusEnunm.否.getCode()));
|
|
|
+ List<RepalBill> repalBills = repalBillService.list(Wrappers.lambdaQuery(RepalBill.class).in(RepalBill::getCustomerId,repalCustomers.stream().map(RepalCustomer::getCustId).collect(Collectors.toList())).eq(RepalBill::getDeleted, Dict.DeletedStatusEnunm.否.getCode()));
|
|
|
+ Map<String,RepalCustomer> repalCustomerMap = repalCustomerService.list(Wrappers.lambdaQuery(RepalCustomer.class).in(RepalCustomer::getCustId,repalBills.stream().map(RepalBill::getCustomerId).collect(Collectors.toList()))).stream().collect(Collectors.toMap(RepalCustomer::getCustName, Function.identity()));
|
|
|
+ qw.in(RepalRemindHistory::getRepalBillId,repalBills.stream().map(RepalBill::getId).collect(Collectors.toList()));
|
|
|
+ IPage<RepalRemindHistory> pageAccountRemindHistory = page(new Page<>(pageNum, pageSize), qw);
|
|
|
+ if(CollUtil.isNotEmpty(pageAccountRemindHistory.getRecords())){
|
|
|
+ result = new VOPage<>(pageNum, pageSize, pageAccountRemindHistory.getTotal(), pageAccountRemindHistory.getRecords().stream()
|
|
|
+ .map(RepalRemindHistoryConvert::EntityToVO).collect(Collectors.toList()));
|
|
|
+ Map<Long,RepalRemindReadInfo> readInfoMap = new HashMap<>();
|
|
|
+ for(RepalRemindHistoryVO vo:result.getDataList()){
|
|
|
+ vo.setReadStatus(Dict.ReadStatusEnum.已读.getCode());
|
|
|
+ if(repalCustomerMap.containsKey(vo.getCompanyName())){
|
|
|
+ vo.setCompanyId(repalCustomerMap.get(vo.getCompanyName()).getCompanyId());
|
|
|
+ }
|
|
|
+ RepalRemindReadInfo repalRemindReadInfo;
|
|
|
+ if(readInfoMap.containsKey(vo.getRepalBillId())){
|
|
|
+ repalRemindReadInfo = readInfoMap.get(vo.getRepalBillId());
|
|
|
+ }else {
|
|
|
+ repalRemindReadInfo = repalRemindReadInfoService.getReadInfoByUserId(userBean.getUserId(), vo.getRepalBillId(), vo.getRepalBookId());
|
|
|
+ readInfoMap.put(vo.getRepalBillId(),repalRemindReadInfo);
|
|
|
+ }
|
|
|
+ if(RemindEnum.逾期提醒.getCode().equals(vo.getRemindType()) && vo.getId() > repalRemindReadInfo.getOverdueRemindId()){
|
|
|
+ vo.setReadStatus(Dict.ReadStatusEnum.未读.getCode());
|
|
|
+ }else if(RemindEnum.财产线索.getCode().equals(vo.getRemindType()) && vo.getId() > repalRemindReadInfo.getFinanceRemindId()){
|
|
|
+ vo.setReadStatus(Dict.ReadStatusEnum.未读.getCode());
|
|
|
+ }else if(RemindEnum.风险预警.getCode().equals(vo.getRemindType()) && vo.getId() > repalRemindReadInfo.getRiskRemindId()){
|
|
|
+ vo.setReadStatus(Dict.ReadStatusEnum.未读.getCode());
|
|
|
+ }else if(RemindEnum.账款评级.getCode().equals(vo.getRemindType()) && vo.getId() > repalRemindReadInfo.getRankRemindId()){
|
|
|
+ vo.setReadStatus(Dict.ReadStatusEnum.未读.getCode());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //查询详细分类时更新已读id
|
|
|
+ if(StrUtil.isNotBlank(dto.getRemindType()) && CollUtil.isNotEmpty(readInfoMap)){
|
|
|
+ for(RepalRemindReadInfo repalRemindReadInfo:readInfoMap.values()){
|
|
|
+ repalRemindReadInfoService.updateReadInfoByUserId(userBean.getUserId(), dto.getRemindType(),repalRemindReadInfo.getRepalBillId(), repalRemindReadInfo.getRepalBookId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (CollUtil.isNotEmpty(result.getDataList())) {
|
|
|
+ result.getDataList().forEach(e -> {
|
|
|
+ //逾期提醒返回本次评分以及应收账款日期
|
|
|
+ if (RemindEnum.逾期提醒.getCode().equals(e.getRemindType())) {
|
|
|
+ RepalBillDiagnosis accountBillDiagnosis = repalBillDiagnosisService.getById(e.getTrendId());
|
|
|
+ if (ObjectUtil.isNotNull(accountBillDiagnosis)) {
|
|
|
+ e.setDiagnosisGrade(accountBillDiagnosis.getDiagnosisGrade())
|
|
|
+ .setDiagnosisScore(accountBillDiagnosis.getDiagnosisScore())
|
|
|
+ .setDiagnosisDatetime(accountBillDiagnosis.getDiagnosisDatetime());
|
|
|
+ }
|
|
|
+ e.setEndDate(LocalDateTime.ofEpochSecond(Long.parseLong(e.getTrendContent()) / 1000, 0, ZoneOffset.ofHours(8)));
|
|
|
+ }
|
|
|
+ if (RemindEnum.账款评级.getCode().equals(e.getRemindType())) {
|
|
|
+ RepalBillDiagnosis accountBillDiagnosis = repalBillDiagnosisService.getById(e.getTrendId());
|
|
|
+ if (ObjectUtil.isNotNull(accountBillDiagnosis)) {
|
|
|
+ e.setDiagnosisGrade(accountBillDiagnosis.getDiagnosisGrade())
|
|
|
+ .setDiagnosisScore(accountBillDiagnosis.getDiagnosisScore())
|
|
|
+ .setDiagnosisDatetime(accountBillDiagnosis.getDiagnosisDatetime())
|
|
|
+ .setDiagnosisRecordId(accountBillDiagnosis.getBizId());
|
|
|
+ if (StrUtil.isNotEmpty(e.getTrendContent())) {
|
|
|
+ RepalBillDiagnosis preAccountDiagnosis = repalBillDiagnosisService.getById(e.getTrendContent());
|
|
|
+ if (ObjectUtil.isNotNull(preAccountDiagnosis)) {
|
|
|
+ e.setPreDiagnosisGrade(preAccountDiagnosis.getDiagnosisGrade())
|
|
|
+ .setPreDiagnosisScore(preAccountDiagnosis.getDiagnosisScore())
|
|
|
+ .setPreDiagnosisDatetime(preAccountDiagnosis.getDiagnosisDatetime());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
private OverdueEnum getDaysBetween(LocalDate endDate) {
|
|
|
long delta = LocalDate.now().toEpochDay() - endDate.toEpochDay();
|
|
|
OverdueEnum overdueEnum = OverdueEnum.其他;
|