diff --git a/mallinkAdmin/src/main/java/com/iformall/controller/invest/InvestOperateRecordController.java b/mallinkAdmin/src/main/java/com/iformall/controller/invest/InvestOperateRecordController.java index 492c329ad..ac43fdb52 100755 --- a/mallinkAdmin/src/main/java/com/iformall/controller/invest/InvestOperateRecordController.java +++ b/mallinkAdmin/src/main/java/com/iformall/controller/invest/InvestOperateRecordController.java @@ -3,8 +3,11 @@ package com.iformall.controller.invest; import com.iformall.annotation.SystemServiceLog; import com.iformall.common.InvestResultData; import com.iformall.domain.po.invest.InvestOperateRecordEntity; +import com.iformall.domain.vo.invest.InvestOperateRecordQuery; +import com.iformall.domain.vo.invest.InvestOperateRecordVo; import com.iformall.domain.vo.invest.InvestPageQuery; import com.iformall.domain.vo.invest.InvestPageResult; +import com.iformall.service.invest.InvestBizService; import com.iformall.service.invest.InvestOperateRecordService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; @@ -30,6 +33,8 @@ import java.util.Arrays; public class InvestOperateRecordController extends InvestBaseController { @Autowired private InvestOperateRecordService investOperateRecordService; + @Autowired + private InvestBizService bizService; /** * 分页列表 @@ -37,8 +42,8 @@ public class InvestOperateRecordController extends InvestBaseController { @SystemServiceLog @ApiOperation("分页列表接口") @GetMapping("/list") - public InvestResultData> list(InvestPageQuery params) { - return execute(params, p -> investOperateRecordService.queryPage(p)); + public InvestResultData> list(InvestOperateRecordQuery params) { + return execute(params, p -> bizService.queryPageOperateRecord(p)); } @@ -47,7 +52,7 @@ public class InvestOperateRecordController extends InvestBaseController { */ //@GetMapping("/info/{id}") public InvestResultData info(@PathVariable("id") Long id){ - return execute(id, p -> investOperateRecordService.getById(p)); + return execute(id, p -> investOperateRecordService.getByIdNotNull(p)); } /** diff --git a/mallinkService/src/main/java/com/iformall/domain/po/invest/InvestOperateRecordEntity.java b/mallinkService/src/main/java/com/iformall/domain/po/invest/InvestOperateRecordEntity.java index 163b57ae8..16bbdb734 100755 --- a/mallinkService/src/main/java/com/iformall/domain/po/invest/InvestOperateRecordEntity.java +++ b/mallinkService/src/main/java/com/iformall/domain/po/invest/InvestOperateRecordEntity.java @@ -6,7 +6,6 @@ import com.baomidou.mybatisplus.annotation.TableName; import java.util.Date; import com.fasterxml.jackson.annotation.JsonIgnore; -import com.iformall.domain.po.invest.InvestBaseEntity; import com.iformall.enums.EnumTableOperateType; import lombok.Data; import lombok.EqualsAndHashCode; @@ -23,6 +22,10 @@ import lombok.EqualsAndHashCode; @EqualsAndHashCode(callSuper = true) public class InvestOperateRecordEntity extends InvestBaseEntity { + public static final String TLB_CUSTOMER = "invest_customer" ; + public static final String TLB_DEMAND = "invest_demand" ; + public static final String TLB_TASK = "invest_task" ; + /** * 表名称 */ diff --git a/mallinkService/src/main/java/com/iformall/domain/vo/invest/InvestOperateRecordQuery.java b/mallinkService/src/main/java/com/iformall/domain/vo/invest/InvestOperateRecordQuery.java new file mode 100644 index 000000000..29d69508d --- /dev/null +++ b/mallinkService/src/main/java/com/iformall/domain/vo/invest/InvestOperateRecordQuery.java @@ -0,0 +1,21 @@ +package com.iformall.domain.vo.invest; + +import com.iformall.enums.EnumFollowType; +import lombok.Data; + +@Data +public class InvestOperateRecordQuery extends InvestPageQuery { + + /** + * 跟踪类型:0-招商任务;1-客户需求 + */ + @io.swagger.annotations.ApiModelProperty(value = "跟踪类型:0-招商任务;1-客户需求", name = "reocrdType") + private EnumFollowType reocrdType; + + /** + * 跟踪类型的主键ID + */ + @io.swagger.annotations.ApiModelProperty(value = "跟踪类型的主键ID", name = "followId") + private Long tid; + +} diff --git a/mallinkService/src/main/java/com/iformall/domain/vo/invest/InvestOperateRecordVo.java b/mallinkService/src/main/java/com/iformall/domain/vo/invest/InvestOperateRecordVo.java new file mode 100644 index 000000000..6c078520c --- /dev/null +++ b/mallinkService/src/main/java/com/iformall/domain/vo/invest/InvestOperateRecordVo.java @@ -0,0 +1,32 @@ +package com.iformall.domain.vo.invest; + +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 lombok.Data; +import lombok.EqualsAndHashCode; + +import java.util.Collection; +import java.util.List; + +@Data +@EqualsAndHashCode(callSuper = true) +public class InvestOperateRecordVo extends InvestOperateRecordEntity { + + /** + * 表名称 + */ + @JsonIgnore + private String tbl; + + /** + * 更新内容 + */ + @JsonIgnore + private String content; + + private Collection record; +} diff --git a/mallinkService/src/main/java/com/iformall/service/invest/InvestBizService.java b/mallinkService/src/main/java/com/iformall/service/invest/InvestBizService.java index ff22fbc6f..33def32ef 100644 --- a/mallinkService/src/main/java/com/iformall/service/invest/InvestBizService.java +++ b/mallinkService/src/main/java/com/iformall/service/invest/InvestBizService.java @@ -16,6 +16,8 @@ public interface InvestBizService { InvestPageResult queryPageRemind(InvestPageQuery params); + InvestPageResult queryPageOperateRecord(InvestOperateRecordQuery params); + List queryUserList() ; boolean saveCustomerAndDemand(InvestDemandDto customerDemandDto) ; @@ -28,6 +30,8 @@ public interface InvestBizService { InvestRemindVo findRemindById(Long id) ; + InvestOperateRecordVo findOperateById(InvestOperateRecordQuery params) ; + InvestFollowRecordVo findFollowRecordById(Long id) ; } diff --git a/mallinkService/src/main/java/com/iformall/service/invest/InvestOperateRecordService.java b/mallinkService/src/main/java/com/iformall/service/invest/InvestOperateRecordService.java index 17816d877..1cfc2038d 100755 --- a/mallinkService/src/main/java/com/iformall/service/invest/InvestOperateRecordService.java +++ b/mallinkService/src/main/java/com/iformall/service/invest/InvestOperateRecordService.java @@ -12,7 +12,7 @@ import com.iformall.domain.vo.invest.InvestPageResult; * @email * @date 2019-09-23 18:40:43 */ -public interface InvestOperateRecordService extends IService { +public interface InvestOperateRecordService extends IService,InvestBaseService { InvestPageResult queryPage(InvestPageQuery params); } diff --git a/mallinkService/src/main/java/com/iformall/service/invest/impl/InvestBizServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/invest/impl/InvestBizServiceImpl.java index 0b8a7b9e4..201c88b56 100644 --- a/mallinkService/src/main/java/com/iformall/service/invest/impl/InvestBizServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/invest/impl/InvestBizServiceImpl.java @@ -4,11 +4,14 @@ 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.*; import com.iformall.domain.po.invest.*; import com.iformall.domain.vo.invest.*; +import com.iformall.enums.EnumFollowType; import com.iformall.enums.EnumNegotiationType; import com.iformall.service.MallUserInfoService; import com.iformall.service.WxBrandService; @@ -19,6 +22,7 @@ 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; @@ -38,6 +42,8 @@ public class InvestBizServiceImpl implements InvestBizService { @Autowired private InvestFollowRecordService followRecordService; @Autowired + private InvestOperateRecordService operateRecordService; + @Autowired private InvestRemindService remindService; @Autowired private WxShopService shopService; @@ -105,19 +111,18 @@ public class InvestBizServiceImpl implements InvestBizService { shopParams = queryParams.getShop(); taskParams = queryParams.getTask(); } - LambdaQueryWrapper taskQueryWrapper = null; + LambdaQueryWrapper taskQueryWrapper = new LambdaQueryWrapper<>(); InvestPageResult investPage = new InvestPageResult<>(); if (Objects.nonNull(shopParams)) { Collection shops = shopService.selectList(new QueryWrapper<>(shopParams)); if (CollectionUtils.isEmpty(shops)) { return investPage; } - taskQueryWrapper = new LambdaQueryWrapper<>(); taskQueryWrapper.in(InvestTaskEntity::getTargetId, getIds(shops, WxShop::getId)); } - if (Objects.nonNull(taskQueryWrapper) && Objects.nonNull(taskParams)) { - taskQueryWrapper.eq(InvestTaskEntity::getOwner, taskParams.getOwner()); - taskQueryWrapper.apply(StringUtils.isNoneEmpty(taskParams.getOwner()), "`owner` REGEXP {0}", taskParams.getOwner()); + if (Objects.nonNull(taskParams)) { + taskQueryWrapper.apply(StringUtils.isNotEmpty(taskParams.getOwner()), "`owner` REGEXP {0}", taskParams.getOwner()); + taskParams.setOwner(null); } InvestPageResult taskPage = taskService.queryPage(buildPageQuery(params, taskParams), taskQueryWrapper); @@ -234,14 +239,63 @@ public class InvestBizServiceImpl implements InvestBizService { remindVo.setOwnerInfo(usersMap.get(remindVo.getOwner())); } - BeanUtils.copyProperties(recordPage, investPage); investPage.setRecords(resultList); - investPage.setTotal(recordPage.getTotal()); return investPage; } + @Override + public InvestPageResult queryPageOperateRecord(InvestOperateRecordQuery params) { + InvestHelper.notNull(params, params.getReocrdType(), params.getTid()); + LambdaQueryWrapper recordQueryWrapper = new LambdaQueryWrapper<>(); + InvestDemandEntity demandEntity = null; + if (Objects.equals(params.getReocrdType(), EnumFollowType.DEMAND)) { + InvestCustomerEntity customerEntity = customerService.getByIdNotNull(params.getTid()); + demandEntity = demandService.getOne(new LambdaQueryWrapper().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 demandRecord = null; + if (Objects.nonNull(demandEntity)) { + LambdaQueryWrapper demandQueryWrapper = new LambdaQueryWrapper<>(); + buildQueryWrapper(demandQueryWrapper, InvestOperateRecordEntity.TLB_DEMAND, demandEntity.getId()); + demandRecord = operateRecordService.list(demandQueryWrapper); + } + + ImmutableListMultimap demandRecordMap = getMultiMap(demandRecord); + + InvestPageResult recordPage = operateRecordService.queryPage(buildPageQuery(params, null), recordQueryWrapper); + InvestPageResult investPage = new InvestPageResult<>(); + if (CollectionUtils.isNotEmpty(recordPage.getRecords())) { + return investPage; + } + + Collection resultList = new ArrayList<>(); + Collection primaryRecord = recordPage.getRecords(); + for (InvestOperateRecordEntity recordEntity : primaryRecord) { + InvestOperateRecordVo itemVo = new InvestOperateRecordVo(); + BeanUtils.copyProperties(recordEntity, itemVo); + List record = JSONArray.parseArray(recordEntity.getContent(), TableTriple.class); + //List innerRecord = demandRecordMap.get(recordEntity.get) ; + itemVo.setRecord(record); + resultList.add(itemVo) ; + } + + BeanUtils.copyProperties(recordPage, investPage); + investPage.setRecords(resultList); + return investPage; + } + + private void buildQueryWrapper(LambdaQueryWrapper wrapper, String tbl, Long tId) { + if (ObjectUtils.allNotNull(tbl, tId)) { + wrapper.eq(InvestOperateRecordEntity::getTbl, tbl); + wrapper.eq(InvestOperateRecordEntity::getTid, tId); + } + } + private List getMallUserInfos(Map usersMap, InvestFollowRecordEntity item) { List ownerInfo = null; Map contentMap = JSON.parseObject(item.getContent(), Map.class); @@ -318,6 +372,12 @@ public class InvestBizServiceImpl implements InvestBizService { return remindVo; } + @Override + public InvestOperateRecordVo findOperateById(InvestOperateRecordQuery params) { + + return null; + } + @Override public InvestFollowRecordVo findFollowRecordById(Long id) { InvestFollowRecordEntity followRecordEntity = followRecordService.getByIdNotNull(id); @@ -430,6 +490,19 @@ public class InvestBizServiceImpl implements InvestBizService { return function.apply(params); } + private ImmutableListMultimap getMultiMap(Collection dataList) { + return Multimaps.index(dataList, new com.google.common.base.Function() { + @Nullable + @Override + public R apply(@Nullable T input) { + if (input instanceof InvestBaseEntity) { + return (R) ((InvestBaseEntity) input).getId(); + } + return null; + } + }); + } + private Map getMap(Collection dataList, Function keyMapper) { return dataList.parallelStream().collect(Collectors.toMap(keyMapper, entity -> entity)); }