|
|
|
@@ -4,8 +4,6 @@ import com.alibaba.fastjson.JSON; |
|
|
|
import com.alibaba.fastjson.JSONArray; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
import com.google.common.collect.ImmutableListMultimap; |
|
|
|
import com.google.common.collect.Multimaps; |
|
|
|
import com.iformall.domain.dto.InvestDemandDto; |
|
|
|
import com.iformall.domain.dto.InvestTaskDto; |
|
|
|
import com.iformall.domain.po.*; |
|
|
|
@@ -22,7 +20,6 @@ import org.apache.commons.collections.MapUtils; |
|
|
|
import org.apache.commons.compress.utils.Lists; |
|
|
|
import org.apache.commons.lang3.ObjectUtils; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.checkerframework.checker.nullness.qual.Nullable; |
|
|
|
import org.springframework.beans.BeanUtils; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
@@ -245,50 +242,6 @@ public class InvestBizServiceImpl implements InvestBizService { |
|
|
|
return investPage; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public InvestPageResult<InvestOperateRecordVo> queryPageOperateRecord(InvestOperateRecordQuery params) { |
|
|
|
InvestHelper.notNull(params, params.getReocrdType(), params.getTid()); |
|
|
|
LambdaQueryWrapper<InvestOperateRecordEntity> recordQueryWrapper = new LambdaQueryWrapper<>(); |
|
|
|
InvestDemandEntity demandEntity = null; |
|
|
|
if (Objects.equals(params.getReocrdType(), EnumFollowType.DEMAND)) { |
|
|
|
InvestCustomerEntity customerEntity = customerService.getByIdNotNull(params.getTid()); |
|
|
|
demandEntity = demandService.getOne(new LambdaQueryWrapper<InvestDemandEntity>().eq(InvestDemandEntity::getCustomerId, customerEntity.getId())); |
|
|
|
buildQueryWrapper(recordQueryWrapper, InvestOperateRecordEntity.TLB_CUSTOMER, customerEntity.getId()); |
|
|
|
} else if (Objects.equals(params.getReocrdType(), EnumFollowType.TASK)) { |
|
|
|
buildQueryWrapper(recordQueryWrapper, InvestOperateRecordEntity.TLB_TASK, params.getTid()); |
|
|
|
} |
|
|
|
|
|
|
|
List<InvestOperateRecordEntity> demandRecord = null; |
|
|
|
if (Objects.nonNull(demandEntity)) { |
|
|
|
LambdaQueryWrapper<InvestOperateRecordEntity> demandQueryWrapper = new LambdaQueryWrapper<>(); |
|
|
|
buildQueryWrapper(demandQueryWrapper, InvestOperateRecordEntity.TLB_DEMAND, demandEntity.getId()); |
|
|
|
demandRecord = operateRecordService.list(demandQueryWrapper); |
|
|
|
} |
|
|
|
|
|
|
|
ImmutableListMultimap<Long, InvestOperateRecordEntity> demandRecordMap = getMultiMap(demandRecord); |
|
|
|
|
|
|
|
InvestPageResult<InvestOperateRecordEntity> recordPage = operateRecordService.queryPage(buildPageQuery(params, null), recordQueryWrapper); |
|
|
|
InvestPageResult<InvestOperateRecordVo> investPage = new InvestPageResult<>(); |
|
|
|
if (CollectionUtils.isNotEmpty(recordPage.getRecords())) { |
|
|
|
return investPage; |
|
|
|
} |
|
|
|
|
|
|
|
Collection<InvestOperateRecordVo> resultList = new ArrayList<>(); |
|
|
|
Collection<InvestOperateRecordEntity> primaryRecord = recordPage.getRecords(); |
|
|
|
for (InvestOperateRecordEntity recordEntity : primaryRecord) { |
|
|
|
InvestOperateRecordVo itemVo = new InvestOperateRecordVo(); |
|
|
|
BeanUtils.copyProperties(recordEntity, itemVo); |
|
|
|
List<TableTriple> record = JSONArray.parseArray(recordEntity.getContent(), TableTriple.class); |
|
|
|
//List<InvestOperateRecordEntity> innerRecord = demandRecordMap.get(recordEntity.get) ; |
|
|
|
itemVo.setRecord(record); |
|
|
|
resultList.add(itemVo) ; |
|
|
|
} |
|
|
|
|
|
|
|
BeanUtils.copyProperties(recordPage, investPage); |
|
|
|
investPage.setRecords(resultList); |
|
|
|
return investPage; |
|
|
|
} |
|
|
|
|
|
|
|
private void buildQueryWrapper(LambdaQueryWrapper<InvestOperateRecordEntity> wrapper, String tbl, Long tId) { |
|
|
|
if (ObjectUtils.allNotNull(tbl, tId)) { |
|
|
|
wrapper.eq(InvestOperateRecordEntity::getTbl, tbl); |
|
|
|
@@ -373,9 +326,66 @@ public class InvestBizServiceImpl implements InvestBizService { |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public InvestOperateRecordVo findOperateById(InvestOperateRecordQuery params) { |
|
|
|
public Collection<InvestOperateRecordVo> findOperateById(InvestOperateRecordQuery params) { |
|
|
|
InvestHelper.notNull(params, params.getRecordType(), params.getTid()); |
|
|
|
LambdaQueryWrapper<InvestOperateRecordEntity> recordQueryWrapper = new LambdaQueryWrapper<>(); |
|
|
|
InvestDemandEntity demandEntity = null; |
|
|
|
if (Objects.equals(params.getRecordType(), EnumFollowType.DEMAND)) { |
|
|
|
InvestCustomerEntity customerEntity = customerService.getByIdNotNull(params.getTid()); |
|
|
|
demandEntity = demandService.getOne(new LambdaQueryWrapper<InvestDemandEntity>().eq(InvestDemandEntity::getCustomerId, customerEntity.getId())); |
|
|
|
buildQueryWrapper(recordQueryWrapper, InvestOperateRecordEntity.TLB_CUSTOMER, customerEntity.getId()); |
|
|
|
} else if (Objects.equals(params.getRecordType(), EnumFollowType.TASK)) { |
|
|
|
buildQueryWrapper(recordQueryWrapper, InvestOperateRecordEntity.TLB_TASK, params.getTid()); |
|
|
|
} |
|
|
|
|
|
|
|
Collection<InvestOperateRecordVo> resultList = new ArrayList<>(); |
|
|
|
List<InvestOperateRecordEntity> recordPage = operateRecordService.list(recordQueryWrapper); |
|
|
|
if (CollectionUtils.isEmpty(recordPage)) { |
|
|
|
return resultList; |
|
|
|
} |
|
|
|
|
|
|
|
return null; |
|
|
|
List<InvestOperateRecordEntity> demandRecord = new ArrayList<>(); |
|
|
|
if (Objects.nonNull(demandEntity)) { |
|
|
|
LambdaQueryWrapper<InvestOperateRecordEntity> demandQueryWrapper = new LambdaQueryWrapper<>(); |
|
|
|
buildQueryWrapper(demandQueryWrapper, InvestOperateRecordEntity.TLB_DEMAND, demandEntity.getId()); |
|
|
|
demandRecord.addAll(operateRecordService.list(demandQueryWrapper)); |
|
|
|
} |
|
|
|
|
|
|
|
recordPage.addAll(demandRecord); |
|
|
|
List<InvestOperateRecordEntity> mixRecordPage = recordPage.parallelStream().sorted((o1, o2) -> { |
|
|
|
if (Objects.equals(o1.getCreateDate(), o2.getCreateDate())) { |
|
|
|
return 0; |
|
|
|
} else if (o1.getCreateDate().after(o2.getCreateDate())) { |
|
|
|
return 1; |
|
|
|
} else { |
|
|
|
return -1; |
|
|
|
} |
|
|
|
}).collect(Collectors.toList()); |
|
|
|
|
|
|
|
Map<Long, MallUserInfo> usersMap = getMap(userInfoService.getByIds(getIds(mixRecordPage, InvestOperateRecordEntity::getOperator)), MallUserInfo::getId); |
|
|
|
for (InvestOperateRecordEntity recordEntity : mixRecordPage) { |
|
|
|
List<TableTriple> record = JSONArray.parseArray(recordEntity.getContent(), TableTriple.class); |
|
|
|
resultList.addAll(getRecordList(recordEntity, record, usersMap.get(recordEntity.getOperator()))); |
|
|
|
} |
|
|
|
return resultList; |
|
|
|
} |
|
|
|
|
|
|
|
private List<InvestOperateRecordVo> getRecordList(InvestOperateRecordEntity recordEntity, Collection<TableTriple> contentList, MallUserInfo userInfo) { |
|
|
|
List<InvestOperateRecordVo> recordVo = new ArrayList<>(); |
|
|
|
if (CollectionUtils.isEmpty(contentList)) { |
|
|
|
return recordVo; |
|
|
|
} |
|
|
|
|
|
|
|
for (TableTriple record : contentList) { |
|
|
|
InvestOperateRecordVo itemVo = new InvestOperateRecordVo(); |
|
|
|
BeanUtils.copyProperties(recordEntity, itemVo); |
|
|
|
if (Objects.nonNull(userInfo)) { |
|
|
|
itemVo.setOperatorName(userInfo.getName()); |
|
|
|
} |
|
|
|
itemVo.setRecord(record); |
|
|
|
recordVo.add(itemVo); |
|
|
|
} |
|
|
|
return recordVo; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
@@ -406,7 +416,9 @@ public class InvestBizServiceImpl implements InvestBizService { |
|
|
|
resultItemVo.setCustomer(customer); |
|
|
|
resultItemVo.setTargetInfo(shop); |
|
|
|
if (Objects.nonNull(item)) { |
|
|
|
resultItemVo.setOwnerInfo(usersMap.get(item.getOwner())); |
|
|
|
if (Objects.nonNull(usersMap.get(item.getOwner()))) { |
|
|
|
resultItemVo.setOwnerInfo(usersMap.get(item.getOwner())); |
|
|
|
} |
|
|
|
BeanUtils.copyProperties(item, resultItemVo); |
|
|
|
} |
|
|
|
return resultItemVo; |
|
|
|
@@ -490,19 +502,6 @@ public class InvestBizServiceImpl implements InvestBizService { |
|
|
|
return function.apply(params); |
|
|
|
} |
|
|
|
|
|
|
|
private <T, R> ImmutableListMultimap<R, T> getMultiMap(Collection<T> dataList) { |
|
|
|
return Multimaps.index(dataList, new com.google.common.base.Function<T, R>() { |
|
|
|
@Nullable |
|
|
|
@Override |
|
|
|
public R apply(@Nullable T input) { |
|
|
|
if (input instanceof InvestBaseEntity) { |
|
|
|
return (R) ((InvestBaseEntity) input).getId(); |
|
|
|
} |
|
|
|
return null; |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
private <T, R> Map<R, T> getMap(Collection<T> dataList, Function<T, R> keyMapper) { |
|
|
|
return dataList.parallelStream().collect(Collectors.toMap(keyMapper, entity -> entity)); |
|
|
|
} |
|
|
|
|