| @@ -12,6 +12,7 @@ import org.springframework.web.bind.annotation.PostMapping; | |||||
| import org.springframework.web.bind.annotation.RequestMapping; | import org.springframework.web.bind.annotation.RequestMapping; | ||||
| import org.springframework.web.bind.annotation.RestController; | import org.springframework.web.bind.annotation.RestController; | ||||
| import java.util.Collection; | |||||
| import java.util.List; | import java.util.List; | ||||
| @@ -30,7 +31,7 @@ public class InvestController extends InvestBaseController { | |||||
| @ApiOperation("用户列表") | @ApiOperation("用户列表") | ||||
| @SystemControllerLog(description = "用户列表") | @SystemControllerLog(description = "用户列表") | ||||
| @PostMapping("/users") | @PostMapping("/users") | ||||
| public InvestResultData<List<MallUserInfo>> userList() { | |||||
| public InvestResultData<Collection<MallUserInfo>> userList() { | |||||
| return execute(null, p -> bizService.queryUserList()); | return execute(null, p -> bizService.queryUserList()); | ||||
| } | } | ||||
| @@ -42,17 +42,17 @@ public class InvestOperateRecordController extends InvestBaseController { | |||||
| @SystemServiceLog | @SystemServiceLog | ||||
| @ApiOperation("分页列表接口") | @ApiOperation("分页列表接口") | ||||
| @GetMapping("/list") | @GetMapping("/list") | ||||
| public InvestResultData<InvestPageResult<InvestOperateRecordVo>> list(InvestOperateRecordQuery params) { | |||||
| return execute(params, p -> bizService.queryPageOperateRecord(p)); | |||||
| public InvestResultData<InvestPageResult<InvestOperateRecordEntity>> list(InvestPageQuery<InvestOperateRecordEntity> params) { | |||||
| return execute(params, p -> investOperateRecordService.queryPage(p)); | |||||
| } | } | ||||
| /** | /** | ||||
| * 信息 | * 信息 | ||||
| */ | */ | ||||
| //@GetMapping("/info/{id}") | |||||
| public InvestResultData info(@PathVariable("id") Long id){ | |||||
| return execute(id, p -> investOperateRecordService.getByIdNotNull(p)); | |||||
| @GetMapping("/info") | |||||
| public InvestResultData info(InvestOperateRecordQuery params) { | |||||
| return execute(params, p -> bizService.findOperateById(p)); | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -162,7 +162,7 @@ public class TableOperateAspect { | |||||
| if (innerBefore instanceof Map) { | if (innerBefore instanceof Map) { | ||||
| diffRows.addAll(getContent((Map<String, Object>) innerBefore, (Map<String, Object>) innerAfter)); | diffRows.addAll(getContent((Map<String, Object>) innerBefore, (Map<String, Object>) innerAfter)); | ||||
| } else { | } else { | ||||
| diffRows.add(TableTriple.of(s, innerBefore, innerAfter)); | |||||
| diffRows.add(new TableTriple(s, innerBefore, innerAfter)); | |||||
| } | } | ||||
| } | } | ||||
| return diffRows; | return diffRows; | ||||
| @@ -177,14 +177,14 @@ public class TableOperateAspect { | |||||
| if (innerAfter instanceof Map) { | if (innerAfter instanceof Map) { | ||||
| list.addAll(mapToList(null, (Map<String, Object>) innerAfter)); | list.addAll(mapToList(null, (Map<String, Object>) innerAfter)); | ||||
| } else { | } else { | ||||
| list.add(TableTriple.of(key, "", innerAfter)); | |||||
| list.add(new TableTriple(key, "", innerAfter)); | |||||
| } | } | ||||
| } else { | } else { | ||||
| Object innerBefore = before.get(key); | Object innerBefore = before.get(key); | ||||
| if (innerBefore instanceof Map) { | if (innerBefore instanceof Map) { | ||||
| list.addAll(mapToList((Map<String, Object>) innerBefore, null)); | list.addAll(mapToList((Map<String, Object>) innerBefore, null)); | ||||
| } else { | } else { | ||||
| list.add(TableTriple.of(key, innerBefore, "")); | |||||
| list.add(new TableTriple(key, innerBefore, "")); | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -55,5 +55,4 @@ public class InvestOperateRecordEntity extends InvestBaseEntity { | |||||
| @JsonIgnore | @JsonIgnore | ||||
| @TableField(exist = false) | @TableField(exist = false) | ||||
| private Date updateDate; | private Date updateDate; | ||||
| } | } | ||||
| @@ -9,13 +9,13 @@ public class InvestOperateRecordQuery extends InvestPageQuery { | |||||
| /** | /** | ||||
| * 跟踪类型:0-招商任务;1-客户需求 | * 跟踪类型:0-招商任务;1-客户需求 | ||||
| */ | */ | ||||
| @io.swagger.annotations.ApiModelProperty(value = "跟踪类型:0-招商任务;1-客户需求", name = "reocrdType") | |||||
| private EnumFollowType reocrdType; | |||||
| @io.swagger.annotations.ApiModelProperty(value = "跟踪类型:0-招商任务;1-客户需求", name = "recordType") | |||||
| private EnumFollowType recordType; | |||||
| /** | /** | ||||
| * 跟踪类型的主键ID | * 跟踪类型的主键ID | ||||
| */ | */ | ||||
| @io.swagger.annotations.ApiModelProperty(value = "跟踪类型的主键ID", name = "followId") | |||||
| @io.swagger.annotations.ApiModelProperty(value = "跟踪类型的主键ID", name = "tid") | |||||
| private Long tid; | private Long tid; | ||||
| } | } | ||||
| @@ -1,16 +1,10 @@ | |||||
| package com.iformall.domain.vo.invest; | package com.iformall.domain.vo.invest; | ||||
| import com.fasterxml.jackson.annotation.JsonIgnore; | import com.fasterxml.jackson.annotation.JsonIgnore; | ||||
| import com.iformall.domain.po.MallUserInfo; | |||||
| import com.iformall.domain.po.WxBrand; | |||||
| import com.iformall.domain.po.invest.InvestCustomerEntity; | |||||
| import com.iformall.domain.po.invest.InvestFollowRecordEntity; | |||||
| import com.iformall.domain.po.invest.InvestOperateRecordEntity; | import com.iformall.domain.po.invest.InvestOperateRecordEntity; | ||||
| import lombok.Data; | import lombok.Data; | ||||
| import lombok.EqualsAndHashCode; | import lombok.EqualsAndHashCode; | ||||
| import java.util.Collection; | |||||
| import java.util.List; | |||||
| @Data | @Data | ||||
| @EqualsAndHashCode(callSuper = true) | @EqualsAndHashCode(callSuper = true) | ||||
| @@ -28,5 +22,11 @@ public class InvestOperateRecordVo extends InvestOperateRecordEntity { | |||||
| @JsonIgnore | @JsonIgnore | ||||
| private String content; | private String content; | ||||
| private Collection<TableTriple> record; | |||||
| /** | |||||
| * 操作人:0-系统;其它 | |||||
| */ | |||||
| @io.swagger.annotations.ApiModelProperty(value = "操作人:0-系统;其它", name = "operatorName") | |||||
| private String operatorName; | |||||
| private TableTriple record; | |||||
| } | } | ||||
| @@ -1,5 +1,6 @@ | |||||
| package com.iformall.domain.vo.invest; | package com.iformall.domain.vo.invest; | ||||
| import lombok.AllArgsConstructor; | |||||
| import lombok.Data; | import lombok.Data; | ||||
| import lombok.EqualsAndHashCode; | import lombok.EqualsAndHashCode; | ||||
| import org.apache.commons.lang3.builder.CompareToBuilder; | import org.apache.commons.lang3.builder.CompareToBuilder; | ||||
| @@ -7,13 +8,12 @@ import org.apache.commons.lang3.builder.CompareToBuilder; | |||||
| import java.io.Serializable; | import java.io.Serializable; | ||||
| @EqualsAndHashCode | @EqualsAndHashCode | ||||
| @Data(staticConstructor = "of") | |||||
| @Data | |||||
| @AllArgsConstructor | |||||
| public class TableTriple<K,L,R> implements Comparable<TableTriple<K,L,R>>, Serializable { | public class TableTriple<K,L,R> implements Comparable<TableTriple<K,L,R>>, Serializable { | ||||
| private final K column; | |||||
| private final L before ; | |||||
| private final R after ; | |||||
| private K column; | |||||
| private L before ; | |||||
| private R after ; | |||||
| @Override | @Override | ||||
| public int compareTo(TableTriple<K, L, R> other) { | public int compareTo(TableTriple<K, L, R> other) { | ||||
| @@ -1,6 +1,7 @@ | |||||
| package com.iformall.enums; | package com.iformall.enums; | ||||
| import com.baomidou.mybatisplus.annotation.EnumValue; | import com.baomidou.mybatisplus.annotation.EnumValue; | ||||
| import com.fasterxml.jackson.annotation.JsonValue; | |||||
| /** | /** | ||||
| * 操作类型:0-添加;1-更新;2-删除 | * 操作类型:0-添加;1-更新;2-删除 | ||||
| @@ -29,6 +30,7 @@ public enum EnumTableOperateType { | |||||
| this.info = info; | this.info = info; | ||||
| } | } | ||||
| @JsonValue | |||||
| public Integer getCode() { | public Integer getCode() { | ||||
| return code; | return code; | ||||
| } | } | ||||
| @@ -4,7 +4,8 @@ import com.iformall.domain.dto.InvestDemandDto; | |||||
| import com.iformall.domain.po.MallUserInfo; | import com.iformall.domain.po.MallUserInfo; | ||||
| import com.iformall.domain.po.invest.InvestRemindEntity; | import com.iformall.domain.po.invest.InvestRemindEntity; | ||||
| import com.iformall.domain.vo.invest.*; | import com.iformall.domain.vo.invest.*; | ||||
| import java.util.List; | |||||
| import java.util.Collection; | |||||
| public interface InvestBizService { | public interface InvestBizService { | ||||
| @@ -16,9 +17,7 @@ public interface InvestBizService { | |||||
| InvestPageResult<InvestRemindVo> queryPageRemind(InvestPageQuery<InvestRemindEntity> params); | InvestPageResult<InvestRemindVo> queryPageRemind(InvestPageQuery<InvestRemindEntity> params); | ||||
| InvestPageResult<InvestOperateRecordVo> queryPageOperateRecord(InvestOperateRecordQuery params); | |||||
| List<MallUserInfo> queryUserList() ; | |||||
| Collection<MallUserInfo> queryUserList() ; | |||||
| boolean saveCustomerAndDemand(InvestDemandDto customerDemandDto) ; | boolean saveCustomerAndDemand(InvestDemandDto customerDemandDto) ; | ||||
| @@ -30,7 +29,7 @@ public interface InvestBizService { | |||||
| InvestRemindVo findRemindById(Long id) ; | InvestRemindVo findRemindById(Long id) ; | ||||
| InvestOperateRecordVo findOperateById(InvestOperateRecordQuery params) ; | |||||
| Collection<InvestOperateRecordVo> findOperateById(InvestOperateRecordQuery params) ; | |||||
| InvestFollowRecordVo findFollowRecordById(Long id) ; | InvestFollowRecordVo findFollowRecordById(Long id) ; | ||||
| @@ -2,14 +2,19 @@ package com.iformall.service.invest; | |||||
| import com.baomidou.mybatisplus.core.toolkit.StringUtils; | import com.baomidou.mybatisplus.core.toolkit.StringUtils; | ||||
| import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | ||||
| import com.google.common.collect.ImmutableListMultimap; | |||||
| import com.google.common.collect.Multimaps; | |||||
| import com.iformall.common.ErrorCode; | import com.iformall.common.ErrorCode; | ||||
| import com.iformall.domain.po.invest.InvestBaseEntity; | |||||
| import com.iformall.domain.vo.invest.InvestPageQuery; | import com.iformall.domain.vo.invest.InvestPageQuery; | ||||
| import com.iformall.exception.MallinkException; | import com.iformall.exception.MallinkException; | ||||
| import org.apache.commons.compress.utils.Lists; | import org.apache.commons.compress.utils.Lists; | ||||
| import org.checkerframework.checker.nullness.qual.Nullable; | |||||
| import org.springframework.util.CollectionUtils; | import org.springframework.util.CollectionUtils; | ||||
| import java.lang.reflect.Method; | import java.lang.reflect.Method; | ||||
| import java.text.MessageFormat; | import java.text.MessageFormat; | ||||
| import java.util.Collection; | |||||
| import java.util.List; | import java.util.List; | ||||
| import java.util.Objects; | import java.util.Objects; | ||||
| @@ -135,4 +140,17 @@ public class InvestHelper { | |||||
| public static <T extends Enum<T>> T valueOf(Class<T> enumType, String name) { | public static <T extends Enum<T>> T valueOf(Class<T> enumType, String name) { | ||||
| return T.valueOf(enumType, name); | return T.valueOf(enumType, name); | ||||
| } | } | ||||
| 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; | |||||
| } | |||||
| }); | |||||
| } | |||||
| } | } | ||||
| @@ -4,8 +4,6 @@ import com.alibaba.fastjson.JSON; | |||||
| import com.alibaba.fastjson.JSONArray; | import com.alibaba.fastjson.JSONArray; | ||||
| import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | ||||
| import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | 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.InvestDemandDto; | ||||
| import com.iformall.domain.dto.InvestTaskDto; | import com.iformall.domain.dto.InvestTaskDto; | ||||
| import com.iformall.domain.po.*; | 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.compress.utils.Lists; | ||||
| import org.apache.commons.lang3.ObjectUtils; | import org.apache.commons.lang3.ObjectUtils; | ||||
| import org.apache.commons.lang3.StringUtils; | import org.apache.commons.lang3.StringUtils; | ||||
| import org.checkerframework.checker.nullness.qual.Nullable; | |||||
| import org.springframework.beans.BeanUtils; | import org.springframework.beans.BeanUtils; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | import org.springframework.beans.factory.annotation.Autowired; | ||||
| import org.springframework.stereotype.Service; | import org.springframework.stereotype.Service; | ||||
| @@ -245,50 +242,6 @@ public class InvestBizServiceImpl implements InvestBizService { | |||||
| return investPage; | 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) { | private void buildQueryWrapper(LambdaQueryWrapper<InvestOperateRecordEntity> wrapper, String tbl, Long tId) { | ||||
| if (ObjectUtils.allNotNull(tbl, tId)) { | if (ObjectUtils.allNotNull(tbl, tId)) { | ||||
| wrapper.eq(InvestOperateRecordEntity::getTbl, tbl); | wrapper.eq(InvestOperateRecordEntity::getTbl, tbl); | ||||
| @@ -373,9 +326,66 @@ public class InvestBizServiceImpl implements InvestBizService { | |||||
| } | } | ||||
| @Override | @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 | @Override | ||||
| @@ -406,7 +416,9 @@ public class InvestBizServiceImpl implements InvestBizService { | |||||
| resultItemVo.setCustomer(customer); | resultItemVo.setCustomer(customer); | ||||
| resultItemVo.setTargetInfo(shop); | resultItemVo.setTargetInfo(shop); | ||||
| if (Objects.nonNull(item)) { | 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); | BeanUtils.copyProperties(item, resultItemVo); | ||||
| } | } | ||||
| return resultItemVo; | return resultItemVo; | ||||
| @@ -490,19 +502,6 @@ public class InvestBizServiceImpl implements InvestBizService { | |||||
| return function.apply(params); | 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) { | private <T, R> Map<R, T> getMap(Collection<T> dataList, Function<T, R> keyMapper) { | ||||
| return dataList.parallelStream().collect(Collectors.toMap(keyMapper, entity -> entity)); | return dataList.parallelStream().collect(Collectors.toMap(keyMapper, entity -> entity)); | ||||
| } | } | ||||