diff --git a/mallinkAdmin/src/main/java/com/iformall/controller/invest/InvestDemandController.java b/mallinkAdmin/src/main/java/com/iformall/controller/invest/InvestDemandController.java index 2e37b58fb..c19635b8d 100755 --- a/mallinkAdmin/src/main/java/com/iformall/controller/invest/InvestDemandController.java +++ b/mallinkAdmin/src/main/java/com/iformall/controller/invest/InvestDemandController.java @@ -11,6 +11,7 @@ import com.iformall.service.invest.InvestDemandService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.extern.slf4j.Slf4j; +import org.apache.shiro.authz.annotation.RequiresPermissions; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; @@ -39,6 +40,7 @@ public class InvestDemandController extends InvestBaseController { /** * 分页列表 */ + @RequiresPermissions("investTaskEdit") @SystemServiceLog @ApiOperation(value = "分页列表接口") @GetMapping("/list") diff --git a/mallinkAdmin/src/main/java/com/iformall/controller/invest/InvestFollowRecordController.java b/mallinkAdmin/src/main/java/com/iformall/controller/invest/InvestFollowRecordController.java index 4d41cca35..f7b3c5e0d 100755 --- a/mallinkAdmin/src/main/java/com/iformall/controller/invest/InvestFollowRecordController.java +++ b/mallinkAdmin/src/main/java/com/iformall/controller/invest/InvestFollowRecordController.java @@ -4,6 +4,7 @@ import com.iformall.common.InvestResultData; import com.iformall.domain.po.InvestFollowRecordEntity; 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.InvestFollowRecordService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; @@ -29,6 +30,8 @@ import java.util.Arrays; public class InvestFollowRecordController extends InvestBaseController { @Autowired private InvestFollowRecordService investFollowRecordService; + @Autowired + private InvestBizService bizService ; /** * 分页列表 diff --git a/mallinkAdmin/src/main/java/com/iformall/controller/invest/InvestRemindController.java b/mallinkAdmin/src/main/java/com/iformall/controller/invest/InvestRemindController.java index 037cabc8b..fa75db9b7 100755 --- a/mallinkAdmin/src/main/java/com/iformall/controller/invest/InvestRemindController.java +++ b/mallinkAdmin/src/main/java/com/iformall/controller/invest/InvestRemindController.java @@ -8,6 +8,7 @@ import com.iformall.service.invest.InvestRemindService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.extern.slf4j.Slf4j; +import org.apache.shiro.authz.annotation.RequiresPermissions; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; @@ -52,6 +53,7 @@ public class InvestRemindController extends InvestBaseController { /** * 保存 */ + @RequiresPermissions("investFollowRecordEdit") @PostMapping("/save") public InvestResultData save(@RequestBody InvestRemindEntity investRemind) { return execute(investRemind, p -> investRemindService.save(p)); diff --git a/mallinkAdmin/src/main/java/com/iformall/controller/invest/InvestTaskController.java b/mallinkAdmin/src/main/java/com/iformall/controller/invest/InvestTaskController.java index c73a667e7..b449fd23e 100755 --- a/mallinkAdmin/src/main/java/com/iformall/controller/invest/InvestTaskController.java +++ b/mallinkAdmin/src/main/java/com/iformall/controller/invest/InvestTaskController.java @@ -11,6 +11,7 @@ import com.iformall.service.invest.InvestTaskService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.extern.slf4j.Slf4j; +import org.apache.shiro.authz.annotation.RequiresPermissions; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; @@ -57,6 +58,7 @@ public class InvestTaskController extends InvestBaseController { /** * 保存 */ + @RequiresPermissions("investTaskEdit") @SystemServiceLog @PostMapping("/save") public InvestResultData save(@RequestBody InvestTaskEntity investTask) { diff --git a/mallinkService/src/main/java/com/iformall/domain/po/InvestFollowRecordEntity.java b/mallinkService/src/main/java/com/iformall/domain/po/InvestFollowRecordEntity.java index 0155e45da..6eea09391 100755 --- a/mallinkService/src/main/java/com/iformall/domain/po/InvestFollowRecordEntity.java +++ b/mallinkService/src/main/java/com/iformall/domain/po/InvestFollowRecordEntity.java @@ -30,7 +30,14 @@ public class InvestFollowRecordEntity extends InvestBaseEntity { /** * 洽谈内容 */ - @io.swagger.annotations.ApiModelProperty(value = "洽谈内容", name = "content") + @io.swagger.annotations.ApiModelProperty(value = "洽谈内容", name = "content",example = "{\n" + + " \"date\": \"2019-09-10 20:12:20\",\n" + + " \"address\": \"北京三里屯\",\n" + + " \"text\": \"今天约了王老板,目标要签订框架协议\",\n" + + " \"document\": [\"url1\",\"url2\"],\n" + + " \"member\": [id1,id2,id3],\n" + + " \"negotiationType\": 1\n" + + "}") private String content; /** * 跟踪类型:0-招商任务;1-客户需求 @@ -44,4 +51,9 @@ public class InvestFollowRecordEntity extends InvestBaseEntity { @io.swagger.annotations.ApiModelProperty(value = "跟踪类型的主键ID", name = "followId") private Long followId; + /** + * 操作人 + */ + @io.swagger.annotations.ApiModelProperty(value = "操作人", name = "followId") + private Long operator; } diff --git a/mallinkService/src/main/java/com/iformall/domain/po/InvestTaskEntity.java b/mallinkService/src/main/java/com/iformall/domain/po/InvestTaskEntity.java index 9a2bd0a21..44b666850 100755 --- a/mallinkService/src/main/java/com/iformall/domain/po/InvestTaskEntity.java +++ b/mallinkService/src/main/java/com/iformall/domain/po/InvestTaskEntity.java @@ -45,7 +45,10 @@ public class InvestTaskEntity extends InvestBaseEntity { /** * 任务设定条件 */ - @io.swagger.annotations.ApiModelProperty(value = "任务设定条件", name = "content") + @io.swagger.annotations.ApiModelProperty(value = "任务设定条件", name = "content",example = "{\n" + + " \"business\": 1,\n" + + " \"lastDate\": \"2018-10-01 12:18:48\"\n" + + "}") private String content; /** diff --git a/mallinkService/src/main/java/com/iformall/domain/vo/invest/InvestDemandVo.java b/mallinkService/src/main/java/com/iformall/domain/vo/invest/InvestDemandVo.java index cd157bd98..8b52db119 100644 --- a/mallinkService/src/main/java/com/iformall/domain/vo/invest/InvestDemandVo.java +++ b/mallinkService/src/main/java/com/iformall/domain/vo/invest/InvestDemandVo.java @@ -2,6 +2,7 @@ package com.iformall.domain.vo.invest; import com.iformall.domain.po.InvestCustomerEntity; import com.iformall.domain.po.InvestDemandEntity; +import com.iformall.domain.po.MallUserInfo; import com.iformall.domain.po.WxBrand; import lombok.Builder; import lombok.Data; @@ -14,5 +15,7 @@ public class InvestDemandVo extends InvestDemandEntity { private WxBrand brand; + private MallUserInfo ownerInfo; + private T targetInfo; } 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 8b4715ee5..080acfd03 100644 --- a/mallinkService/src/main/java/com/iformall/service/invest/InvestBizService.java +++ b/mallinkService/src/main/java/com/iformall/service/invest/InvestBizService.java @@ -1,12 +1,10 @@ package com.iformall.service.invest; import com.iformall.domain.po.InvestDemandEntity; +import com.iformall.domain.po.InvestFollowRecordEntity; import com.iformall.domain.po.InvestTaskEntity; import com.iformall.domain.po.MallUserInfo; -import com.iformall.domain.vo.invest.InvestDemandVo; -import com.iformall.domain.vo.invest.InvestPageQuery; -import com.iformall.domain.vo.invest.InvestPageResult; -import com.iformall.domain.vo.invest.InvestTaskVo; +import com.iformall.domain.vo.invest.*; import java.util.List; @@ -16,6 +14,8 @@ public interface InvestBizService { InvestPageResult queryPageTask(InvestPageQuery params); + InvestPageResult queryPageFollowRecord(InvestPageQuery params); + List queryUserList() ; boolean saveCustomerAndDemand(InvestDemandVo customerDemandVo) ; 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 0bdaa46ec..bb3519953 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 @@ -1,14 +1,8 @@ package com.iformall.service.invest.impl; import com.alibaba.fastjson.JSON; -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.baomidou.mybatisplus.core.metadata.IPage; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.iformall.domain.po.*; -import com.iformall.domain.vo.invest.InvestDemandVo; -import com.iformall.domain.vo.invest.InvestPageQuery; -import com.iformall.domain.vo.invest.InvestPageResult; -import com.iformall.domain.vo.invest.InvestTaskVo; +import com.iformall.domain.vo.invest.*; import com.iformall.service.MallUserInfoService; import com.iformall.service.WxBrandService; import com.iformall.service.WxShopService; @@ -20,8 +14,10 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import java.io.Serializable; import java.util.*; import java.util.stream.Collectors; +import java.util.stream.Stream; @Service public class InvestBizServiceImpl implements InvestBizService { @@ -31,6 +27,8 @@ public class InvestBizServiceImpl implements InvestBizService { @Autowired private InvestTaskService taskService; @Autowired + private InvestFollowRecordService followRecordService; + @Autowired private WxShopService shopService; @Autowired private InvestCustomerService customerService; @@ -41,19 +39,12 @@ public class InvestBizServiceImpl implements InvestBizService { @Override public InvestPageResult queryPageDemand(InvestPageQuery params) { - InvestHelper.allNotNull(params); - Page page = InvestHelper.buildQueryPage(params); + InvestPageResult demandPage = demandService.queryPage(params); InvestPageResult investPage = new InvestPageResult<>(); - //1、客户需求 - InvestDemandEntity queryTask = params.getQueryData(); - LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(queryTask); - IPage demandPage = demandService.page(page, queryWrapper); if (CollectionUtils.isEmpty(demandPage.getRecords())) { return investPage; } - - List resultList = getITargeInfoList(demandPage); - + List resultList = getTargeInfoList(demandPage); BeanUtils.copyProperties(demandPage, investPage); investPage.setRecords(resultList); return investPage; @@ -70,25 +61,64 @@ public class InvestBizServiceImpl implements InvestBizService { } List taskList = taskPage.getRecords(); - //2、目标信息 Collection shops = shopService.getByIds(taskList.stream().map(InvestTaskEntity::getTargetId).collect(Collectors.toList())); Map shopsMap = shops.stream().collect(Collectors.toMap(WxShop::getId, shop -> shop)); //3、用户信息 Map usersMap = getUserInfoMap(); - List resultList = new ArrayList<>(); for (InvestTaskEntity item : taskList) { WxShop shop = shopsMap.get(item.getTargetId()); - resultList.add(buildResultItem(item, shop, usersMap)); + resultList.add(buildTaskItem(item, shop, usersMap)); } - BeanUtils.copyProperties(taskPage, investPage); investPage.setRecords(resultList); investPage.setTotal(taskPage.getTotal()); return investPage; } + @Override + public InvestPageResult queryPageFollowRecord(InvestPageQuery params) { + InvestPageResult recordPage = followRecordService.queryPage(params); + + InvestPageResult investPage = new InvestPageResult<>(); + if (CollectionUtils.isEmpty(recordPage.getRecords())) { + return investPage; + } + + List recordList = recordPage.getRecords(); + + //2、用户信息 + Map usersMap = getUserInfoMap(); + + //3、客户 + Collection customers = getCustomers(recordList.stream().map(InvestFollowRecordEntity::getCustomerId)); + Map customerMap = getCustomerMap(customers); + //4、 品牌 + Map brandMap = getBrandMap(customers.stream().map(InvestCustomerEntity::getBrandId).collect(Collectors.toList())); + + List resultList = new ArrayList<>(); + for (InvestFollowRecordEntity item : recordList) { + InvestCustomerEntity customerEntity = customerMap.get(item.getCustomerId()); + WxBrand brand = brandMap.get(customerEntity.getBrandId()); + Map followContent = (Map) JSON.parseObject(item.getContent(), Map.class); + String followMember = (String) followContent.get("member"); + List ownerInfo = getMallUserInfos(followMember, usersMap); + InvestFollowRecordVo followRecordVo = InvestFollowRecordVo.builder() + .customer(customerEntity) + .memberInfo(ownerInfo) + .brand(brand).build(); + followRecordVo.setOwnerInfo(usersMap.get(item.getOwner())); + BeanUtils.copyProperties(item, followRecordVo); + resultList.add(followRecordVo); + } + + BeanUtils.copyProperties(recordPage, investPage); + investPage.setRecords(resultList); + investPage.setTotal(recordPage.getTotal()); + return investPage; + } + @Override public List queryUserList() { MallUserInfo query = new MallUserInfo(); @@ -126,7 +156,8 @@ public class InvestBizServiceImpl implements InvestBizService { InvestCustomerEntity customerEntity = customerService.getByIdNotNull(demandEntity.getCustomerId()); WxBrand brand = brandService.getById(customerEntity.getBrandId()); WxShop shop = shopService.getById(demandEntity.getTargetId()); - return buildResultItem(demandEntity, customerEntity, brand, shop); + Map usersMap = getUserInfoMap(); + return buildDemindItem(demandEntity, customerEntity, brand, shop,usersMap); } @Override @@ -134,14 +165,15 @@ public class InvestBizServiceImpl implements InvestBizService { InvestTaskEntity taskEntity = taskService.getByIdNotNull(id); WxShop shop = shopService.getById(taskEntity.getTargetId()); Map usersMap = getUserInfoMap(); - return buildResultItem(taskEntity, shop, usersMap); + return buildTaskItem(taskEntity, shop, usersMap); } - private InvestDemandVo buildResultItem(InvestDemandEntity item, InvestCustomerEntity customer, WxBrand brand, WxShop shop) { + private InvestDemandVo buildDemindItem(InvestDemandEntity item, InvestCustomerEntity customer, WxBrand brand, WxShop shop, Map usersMap) { InvestDemandVo resultItemVo = InvestDemandVo.builder() .brand(brand) .customer(customer) .targetInfo(shop) + .ownerInfo(usersMap.get(item.getOwner())) .build(); BeanUtils.copyProperties(item, resultItemVo); return resultItemVo; @@ -152,14 +184,8 @@ public class InvestBizServiceImpl implements InvestBizService { return users.parallelStream().collect(Collectors.toMap(MallUserInfo::getId, MallUserInfo -> MallUserInfo)); } - private InvestTaskVo buildResultItem(InvestTaskEntity item, WxShop shop, Map usersMap) { - List ownerInfo = Lists.newArrayList(); - List ownerList = JSON.parseArray(item.getOwner(), Long.class); - if (CollectionUtils.isNotEmpty(ownerList)) { - for (Long userId : ownerList) { - ownerInfo.add(usersMap.get(userId)); - } - } + private InvestTaskVo buildTaskItem(InvestTaskEntity item, WxShop shop, Map usersMap) { + List ownerInfo = getMallUserInfos(item.getOwner(), usersMap); InvestTaskVo resultItemVo = InvestTaskVo.builder() .targetInfo(shop) .ownerInfo(ownerInfo) @@ -168,20 +194,31 @@ public class InvestBizServiceImpl implements InvestBizService { return resultItemVo; } - private List getITargeInfoList(IPage demandPage) { + private List getMallUserInfos(String userJson, Map usersMap) { + List ownerInfo = Lists.newArrayList(); + List ownerList = JSON.parseArray(userJson, Long.class); + if (CollectionUtils.isNotEmpty(ownerList)) { + for (Long userId : ownerList) { + ownerInfo.add(usersMap.get(userId)); + } + } + return ownerInfo; + } + + private List getTargeInfoList(InvestPageResult demandPage) { List demandList = demandPage.getRecords(); //2、客户信息 - Collection customers = customerService.listByIds(demandList - .stream().map(InvestDemandEntity::getCustomerId).collect(Collectors.toList())); - Map customersMap = customers.stream().collect(Collectors.toMap(InvestCustomerEntity::getId, customer -> customer)); + Collection customers = getCustomers(demandList.stream().map(InvestDemandEntity::getCustomerId)); + Map customersMap = getCustomerMap(customers); //3、目标信息 Collection shops = shopService.getByIds(demandList.stream().map(InvestDemandEntity::getTargetId).collect(Collectors.toList())); Map shopsMap = shops.stream().collect(Collectors.toMap(WxShop::getId, shop -> shop)); - //4 品牌 - Collection brands = brandService.getByIds(customers.stream().map(InvestCustomerEntity::getBrandId).collect(Collectors.toList())); - Map brandMap = brands.stream().collect(Collectors.toMap(WxBrand::getId, brand -> brand)); + //4、品牌 + Map brandMap = getBrandMap(customers.stream().map(InvestCustomerEntity::getBrandId).collect(Collectors.toList())); + //5、用户 + Map usersMap = getUserInfoMap(); List resultList = new ArrayList<>(); for (InvestDemandEntity item : demandList) { @@ -191,8 +228,22 @@ public class InvestBizServiceImpl implements InvestBizService { if (Objects.nonNull(customer)) { brand = brandMap.get(customer.getBrandId()); } - resultList.add(buildResultItem(item, customer, brand, shop)); + resultList.add(buildDemindItem(item, customer, brand, shop, usersMap)); } return resultList; } + + private Map getBrandMap(Collection ids) { + Collection brands = brandService.getByIds(ids); + return brands.stream().collect(Collectors.toMap(WxBrand::getId, brand -> brand)); + } + + + private Map getCustomerMap(Collection customers) { + return customers.stream().collect(Collectors.toMap(InvestCustomerEntity::getId, customer -> customer)); + } + + private Collection getCustomers(Stream longStream) { + return customerService.listByIds(longStream.collect(Collectors.toList())); + } } diff --git a/mallinkService/src/main/java/com/iformall/service/invest/impl/InvestFollowRecordServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/invest/impl/InvestFollowRecordServiceImpl.java index 8db3cdb44..10626d0d9 100755 --- a/mallinkService/src/main/java/com/iformall/service/invest/impl/InvestFollowRecordServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/invest/impl/InvestFollowRecordServiceImpl.java @@ -3,6 +3,7 @@ package com.iformall.service.invest.impl; import com.baomidou.mybatisplus.core.conditions.Wrapper; import com.iformall.common.ErrorCode; import com.iformall.domain.po.InvestFollowRecordEntity; +import com.iformall.domain.vo.invest.InvestUserContext; import com.iformall.enums.EnumFollowType; import com.iformall.mapper.InvestFollowRecordDao; import com.iformall.service.invest.InvestDemandService; @@ -24,6 +25,7 @@ public class InvestFollowRecordServiceImpl extends InvestBaseServiceImpl