From 064ea74646ce340d5fd2dadee64be17173dd3017 Mon Sep 17 00:00:00 2001 From: Burce Date: Tue, 15 Oct 2019 18:26:19 +0800 Subject: [PATCH] =?UTF-8?q?[=E6=8B=9B=E5=95=86]adjust?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/invest/InvestController.java | 3 +- .../invest/InvestOperateRecordController.java | 10 +- .../com/iformall/log/TableOperateAspect.java | 6 +- .../po/invest/InvestOperateRecordEntity.java | 1 - .../vo/invest/InvestOperateRecordQuery.java | 6 +- .../vo/invest/InvestOperateRecordVo.java | 14 +- .../domain/vo/invest/TableTriple.java | 12 +- .../iformall/enums/EnumTableOperateType.java | 2 + .../service/invest/InvestBizService.java | 9 +- .../iformall/service/invest/InvestHelper.java | 18 +++ .../invest/impl/InvestBizServiceImpl.java | 125 +++++++++--------- 11 files changed, 112 insertions(+), 94 deletions(-) diff --git a/mallinkAdmin/src/main/java/com/iformall/controller/invest/InvestController.java b/mallinkAdmin/src/main/java/com/iformall/controller/invest/InvestController.java index d8625c4a6..a09c361b6 100644 --- a/mallinkAdmin/src/main/java/com/iformall/controller/invest/InvestController.java +++ b/mallinkAdmin/src/main/java/com/iformall/controller/invest/InvestController.java @@ -12,6 +12,7 @@ import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import java.util.Collection; import java.util.List; @@ -30,7 +31,7 @@ public class InvestController extends InvestBaseController { @ApiOperation("用户列表") @SystemControllerLog(description = "用户列表") @PostMapping("/users") - public InvestResultData> userList() { + public InvestResultData> userList() { return execute(null, p -> bizService.queryUserList()); } 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 ac43fdb52..7d9233bc7 100755 --- a/mallinkAdmin/src/main/java/com/iformall/controller/invest/InvestOperateRecordController.java +++ b/mallinkAdmin/src/main/java/com/iformall/controller/invest/InvestOperateRecordController.java @@ -42,17 +42,17 @@ public class InvestOperateRecordController extends InvestBaseController { @SystemServiceLog @ApiOperation("分页列表接口") @GetMapping("/list") - public InvestResultData> list(InvestOperateRecordQuery params) { - return execute(params, p -> bizService.queryPageOperateRecord(p)); + public InvestResultData> list(InvestPageQuery 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)); } /** diff --git a/mallinkAdmin/src/main/java/com/iformall/log/TableOperateAspect.java b/mallinkAdmin/src/main/java/com/iformall/log/TableOperateAspect.java index caae3a0a2..9d865df7e 100644 --- a/mallinkAdmin/src/main/java/com/iformall/log/TableOperateAspect.java +++ b/mallinkAdmin/src/main/java/com/iformall/log/TableOperateAspect.java @@ -162,7 +162,7 @@ public class TableOperateAspect { if (innerBefore instanceof Map) { diffRows.addAll(getContent((Map) innerBefore, (Map) innerAfter)); } else { - diffRows.add(TableTriple.of(s, innerBefore, innerAfter)); + diffRows.add(new TableTriple(s, innerBefore, innerAfter)); } } return diffRows; @@ -177,14 +177,14 @@ public class TableOperateAspect { if (innerAfter instanceof Map) { list.addAll(mapToList(null, (Map) innerAfter)); } else { - list.add(TableTriple.of(key, "", innerAfter)); + list.add(new TableTriple(key, "", innerAfter)); } } else { Object innerBefore = before.get(key); if (innerBefore instanceof Map) { list.addAll(mapToList((Map) innerBefore, null)); } else { - list.add(TableTriple.of(key, innerBefore, "")); + list.add(new TableTriple(key, innerBefore, "")); } } } 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 16bbdb734..0bab14c6b 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 @@ -55,5 +55,4 @@ public class InvestOperateRecordEntity extends InvestBaseEntity { @JsonIgnore @TableField(exist = false) private Date updateDate; - } 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 index 29d69508d..b0de0b110 100644 --- a/mallinkService/src/main/java/com/iformall/domain/vo/invest/InvestOperateRecordQuery.java +++ b/mallinkService/src/main/java/com/iformall/domain/vo/invest/InvestOperateRecordQuery.java @@ -9,13 +9,13 @@ public class InvestOperateRecordQuery extends InvestPageQuery { /** * 跟踪类型: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 */ - @io.swagger.annotations.ApiModelProperty(value = "跟踪类型的主键ID", name = "followId") + @io.swagger.annotations.ApiModelProperty(value = "跟踪类型的主键ID", name = "tid") 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 index 6c078520c..3b7788bdc 100644 --- a/mallinkService/src/main/java/com/iformall/domain/vo/invest/InvestOperateRecordVo.java +++ b/mallinkService/src/main/java/com/iformall/domain/vo/invest/InvestOperateRecordVo.java @@ -1,16 +1,10 @@ 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) @@ -28,5 +22,11 @@ public class InvestOperateRecordVo extends InvestOperateRecordEntity { @JsonIgnore private String content; - private Collection record; + /** + * 操作人:0-系统;其它 + */ + @io.swagger.annotations.ApiModelProperty(value = "操作人:0-系统;其它", name = "operatorName") + private String operatorName; + + private TableTriple record; } diff --git a/mallinkService/src/main/java/com/iformall/domain/vo/invest/TableTriple.java b/mallinkService/src/main/java/com/iformall/domain/vo/invest/TableTriple.java index b0518a4f0..ceeb36c88 100644 --- a/mallinkService/src/main/java/com/iformall/domain/vo/invest/TableTriple.java +++ b/mallinkService/src/main/java/com/iformall/domain/vo/invest/TableTriple.java @@ -1,5 +1,6 @@ package com.iformall.domain.vo.invest; +import lombok.AllArgsConstructor; import lombok.Data; import lombok.EqualsAndHashCode; import org.apache.commons.lang3.builder.CompareToBuilder; @@ -7,13 +8,12 @@ import org.apache.commons.lang3.builder.CompareToBuilder; import java.io.Serializable; @EqualsAndHashCode -@Data(staticConstructor = "of") +@Data +@AllArgsConstructor public class TableTriple implements Comparable>, Serializable { - private final K column; - private final L before ; - private final R after ; - - + private K column; + private L before ; + private R after ; @Override public int compareTo(TableTriple other) { diff --git a/mallinkService/src/main/java/com/iformall/enums/EnumTableOperateType.java b/mallinkService/src/main/java/com/iformall/enums/EnumTableOperateType.java index f0ca3995e..bc4b7dd66 100644 --- a/mallinkService/src/main/java/com/iformall/enums/EnumTableOperateType.java +++ b/mallinkService/src/main/java/com/iformall/enums/EnumTableOperateType.java @@ -1,6 +1,7 @@ package com.iformall.enums; import com.baomidou.mybatisplus.annotation.EnumValue; +import com.fasterxml.jackson.annotation.JsonValue; /** * 操作类型:0-添加;1-更新;2-删除 @@ -29,6 +30,7 @@ public enum EnumTableOperateType { this.info = info; } + @JsonValue public Integer getCode() { return code; } 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 33def32ef..8bebe9e95 100644 --- a/mallinkService/src/main/java/com/iformall/service/invest/InvestBizService.java +++ b/mallinkService/src/main/java/com/iformall/service/invest/InvestBizService.java @@ -4,7 +4,8 @@ import com.iformall.domain.dto.InvestDemandDto; import com.iformall.domain.po.MallUserInfo; import com.iformall.domain.po.invest.InvestRemindEntity; import com.iformall.domain.vo.invest.*; -import java.util.List; + +import java.util.Collection; public interface InvestBizService { @@ -16,9 +17,7 @@ public interface InvestBizService { InvestPageResult queryPageRemind(InvestPageQuery params); - InvestPageResult queryPageOperateRecord(InvestOperateRecordQuery params); - - List queryUserList() ; + Collection queryUserList() ; boolean saveCustomerAndDemand(InvestDemandDto customerDemandDto) ; @@ -30,7 +29,7 @@ public interface InvestBizService { InvestRemindVo findRemindById(Long id) ; - InvestOperateRecordVo findOperateById(InvestOperateRecordQuery params) ; + Collection findOperateById(InvestOperateRecordQuery params) ; InvestFollowRecordVo findFollowRecordById(Long id) ; diff --git a/mallinkService/src/main/java/com/iformall/service/invest/InvestHelper.java b/mallinkService/src/main/java/com/iformall/service/invest/InvestHelper.java index 7e6accb13..98f87c0bc 100644 --- a/mallinkService/src/main/java/com/iformall/service/invest/InvestHelper.java +++ b/mallinkService/src/main/java/com/iformall/service/invest/InvestHelper.java @@ -2,14 +2,19 @@ package com.iformall.service.invest; import com.baomidou.mybatisplus.core.toolkit.StringUtils; 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.domain.po.invest.InvestBaseEntity; import com.iformall.domain.vo.invest.InvestPageQuery; import com.iformall.exception.MallinkException; import org.apache.commons.compress.utils.Lists; +import org.checkerframework.checker.nullness.qual.Nullable; import org.springframework.util.CollectionUtils; import java.lang.reflect.Method; import java.text.MessageFormat; +import java.util.Collection; import java.util.List; import java.util.Objects; @@ -135,4 +140,17 @@ public class InvestHelper { public static > T valueOf(Class enumType, String name) { return T.valueOf(enumType, name); } + + 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; + } + }); + } } 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 201c88b56..a05b88264 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,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 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); @@ -373,9 +326,66 @@ public class InvestBizServiceImpl implements InvestBizService { } @Override - public InvestOperateRecordVo findOperateById(InvestOperateRecordQuery params) { + public Collection findOperateById(InvestOperateRecordQuery params) { + InvestHelper.notNull(params, params.getRecordType(), params.getTid()); + LambdaQueryWrapper recordQueryWrapper = new LambdaQueryWrapper<>(); + InvestDemandEntity demandEntity = null; + if (Objects.equals(params.getRecordType(), 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.getRecordType(), EnumFollowType.TASK)) { + buildQueryWrapper(recordQueryWrapper, InvestOperateRecordEntity.TLB_TASK, params.getTid()); + } + + Collection resultList = new ArrayList<>(); + List recordPage = operateRecordService.list(recordQueryWrapper); + if (CollectionUtils.isEmpty(recordPage)) { + return resultList; + } - return null; + List demandRecord = new ArrayList<>(); + if (Objects.nonNull(demandEntity)) { + LambdaQueryWrapper demandQueryWrapper = new LambdaQueryWrapper<>(); + buildQueryWrapper(demandQueryWrapper, InvestOperateRecordEntity.TLB_DEMAND, demandEntity.getId()); + demandRecord.addAll(operateRecordService.list(demandQueryWrapper)); + } + + recordPage.addAll(demandRecord); + List 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 usersMap = getMap(userInfoService.getByIds(getIds(mixRecordPage, InvestOperateRecordEntity::getOperator)), MallUserInfo::getId); + for (InvestOperateRecordEntity recordEntity : mixRecordPage) { + List record = JSONArray.parseArray(recordEntity.getContent(), TableTriple.class); + resultList.addAll(getRecordList(recordEntity, record, usersMap.get(recordEntity.getOperator()))); + } + return resultList; + } + + private List getRecordList(InvestOperateRecordEntity recordEntity, Collection contentList, MallUserInfo userInfo) { + List 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 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)); }