From 55f9daa3863e1fdf54c78dfcddeffeeba3e22a73 Mon Sep 17 00:00:00 2001 From: Burce Date: Wed, 9 Oct 2019 13:51:35 +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 | 12 +- .../invest/InvestDemandController.java | 2 +- .../invest/InvestTaskController.java | 91 +++++++------- .../service/invest/InvestBizService.java | 9 +- .../invest/impl/InvestBizServiceImpl.java | 113 ++++++++++-------- 5 files changed, 125 insertions(+), 102 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 7025cf5c6..b86b1ee3a 100644 --- a/mallinkAdmin/src/main/java/com/iformall/controller/invest/InvestController.java +++ b/mallinkAdmin/src/main/java/com/iformall/controller/invest/InvestController.java @@ -3,7 +3,7 @@ package com.iformall.controller.invest; import com.iformall.annotation.SystemControllerLog; import com.iformall.common.InvestResultData; import com.iformall.domain.po.MallUserInfo; -import com.iformall.service.MallUserInfoService; +import com.iformall.service.invest.InvestBizService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.extern.slf4j.Slf4j; @@ -12,6 +12,8 @@ import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import java.util.List; + @Slf4j @RestController @@ -20,7 +22,7 @@ import org.springframework.web.bind.annotation.RestController; public class InvestController extends InvestBaseController { @Autowired - private MallUserInfoService userInfoService ; + private InvestBizService bizService ; /** * 用户列表 @@ -28,10 +30,8 @@ public class InvestController extends InvestBaseController { @ApiOperation("用户列表") @SystemControllerLog(description = "用户列表") @PostMapping("/users") - public InvestResultData userList() { - MallUserInfo query = new MallUserInfo() ; - query.setIsAdmin(0); - return execute(query, p -> userInfoService.findList(query)); + public InvestResultData> userList() { + return execute(null, p -> bizService.queryUserList()); } } 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 270e27c5e..2e37b58fb 100755 --- a/mallinkAdmin/src/main/java/com/iformall/controller/invest/InvestDemandController.java +++ b/mallinkAdmin/src/main/java/com/iformall/controller/invest/InvestDemandController.java @@ -53,7 +53,7 @@ public class InvestDemandController extends InvestBaseController { @SystemServiceLog @GetMapping("/info/{id}") public InvestResultData info(@PathVariable("id") Long id) { - return execute(id, p -> investBizService.findById(p)); + return execute(id, p -> investBizService.findDemandById(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 bf8589e0b..c73a667e7 100755 --- a/mallinkAdmin/src/main/java/com/iformall/controller/invest/InvestTaskController.java +++ b/mallinkAdmin/src/main/java/com/iformall/controller/invest/InvestTaskController.java @@ -17,7 +17,6 @@ import org.springframework.web.bind.annotation.*; import java.util.Arrays; - /** * 招商任务 * @@ -30,56 +29,56 @@ import java.util.Arrays; @RequestMapping("invest/task") @Api(tags = "招商任务") public class InvestTaskController extends InvestBaseController { - @Autowired - private InvestTaskService investTaskService; - @Autowired - private InvestBizService bizService; + @Autowired + private InvestTaskService investTaskService; + @Autowired + private InvestBizService bizService; - /** - * 分页列表 - */ - @SystemServiceLog - @ApiOperation("分页列表接口") - @GetMapping("/list") - public InvestResultData> list(InvestPageQuery params){ - return execute(params, p -> bizService.queryPageTask(p)); - } + /** + * 分页列表 + */ + @SystemServiceLog + @ApiOperation("分页列表接口") + @GetMapping("/list") + public InvestResultData> list(InvestPageQuery params) { + return execute(params, p -> bizService.queryPageTask(p)); + } - /** - * 信息 - */ - @SystemServiceLog - @GetMapping("/info/{id}") - public InvestResultData info(@PathVariable("id") Long id){ - return execute(id, p -> investTaskService.getByIdNotNull(id)); - } + /** + * 信息 + */ + @SystemServiceLog + @GetMapping("/info/{id}") + public InvestResultData info(@PathVariable("id") Long id) { + return execute(id, p -> bizService.findTaskById(id)); + } - /** - * 保存 - */ - @SystemServiceLog - @PostMapping("/save") - public InvestResultData save(@RequestBody InvestTaskEntity investTask){ - return execute(investTask, p -> investTaskService.save(p)); - } + /** + * 保存 + */ + @SystemServiceLog + @PostMapping("/save") + public InvestResultData save(@RequestBody InvestTaskEntity investTask) { + return execute(investTask, p -> investTaskService.save(p)); + } - /** - * 修改 - */ - @SystemServiceLog - @PostMapping("/update") - public InvestResultData update(@RequestBody InvestTaskEntity investTask){ - return execute(investTask, p -> investTaskService.updateById(p)); - } + /** + * 修改 + */ + @SystemServiceLog + @PostMapping("/update") + public InvestResultData update(@RequestBody InvestTaskEntity investTask) { + return execute(investTask, p -> investTaskService.updateById(p)); + } - /** - * 删除 - */ - @SystemServiceLog - @PostMapping("/delete") - public InvestResultData delete(@RequestBody Long[] ids){ - return execute(ids, p -> investTaskService.removeByIds(Arrays.asList(p))); - } + /** + * 删除 + */ + @SystemServiceLog + @PostMapping("/delete") + public InvestResultData delete(@RequestBody Long[] ids) { + return execute(ids, p -> investTaskService.removeByIds(Arrays.asList(p))); + } } 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 8d94b559d..8b4715ee5 100644 --- a/mallinkService/src/main/java/com/iformall/service/invest/InvestBizService.java +++ b/mallinkService/src/main/java/com/iformall/service/invest/InvestBizService.java @@ -2,20 +2,27 @@ package com.iformall.service.invest; import com.iformall.domain.po.InvestDemandEntity; 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 java.util.List; + public interface InvestBizService { InvestPageResult queryPageDemand(InvestPageQuery params); InvestPageResult queryPageTask(InvestPageQuery params); + List queryUserList() ; + boolean saveCustomerAndDemand(InvestDemandVo customerDemandVo) ; boolean updateCustomerAndDemand(InvestDemandVo customerDemandVo) ; - InvestDemandVo findById(Long id) ; + InvestDemandVo findDemandById(Long id) ; + + InvestTaskVo findTaskById(Long id) ; } 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 600f884df..0bdaa46ec 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 @@ -64,7 +64,6 @@ public class InvestBizServiceImpl implements InvestBizService { public InvestPageResult queryPageTask(InvestPageQuery params) { InvestPageResult taskPage = taskService.queryPage(params); - InvestPageResult investPage = new InvestPageResult<>(); if (CollectionUtils.isEmpty(taskPage.getRecords())) { return investPage; @@ -75,10 +74,9 @@ public class InvestBizServiceImpl implements InvestBizService { //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、用户信息 - Collection users = userInfoService.findList(null); - Map usersMap = users.parallelStream().collect(Collectors.toMap(MallUserInfo::getId, MallUserInfo -> MallUserInfo)); + Map usersMap = getUserInfoMap(); + List resultList = new ArrayList<>(); for (InvestTaskEntity item : taskList) { WxShop shop = shopsMap.get(item.getTargetId()); @@ -91,48 +89,11 @@ public class InvestBizServiceImpl implements InvestBizService { return investPage; } - 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)); - } - } - InvestTaskVo resultItemVo = InvestTaskVo.builder() - .targetInfo(shop) - .ownerInfo(ownerInfo) - .build(); - BeanUtils.copyProperties(item, resultItemVo); - return resultItemVo; - } - - private List getITargeInfoList(IPage 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)); - - //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)); - - List resultList = new ArrayList<>(); - for (InvestDemandEntity item : demandList) { - InvestCustomerEntity customer = customersMap.get(item.getCustomerId()); - WxShop shop = shopsMap.get(item.getTargetId()); - WxBrand brand = null; - if (Objects.nonNull(customer)) { - brand = brandMap.get(customer.getBrandId()); - } - resultList.add(buildResultItem(item, customer, brand, shop)); - } - return resultList; + @Override + public List queryUserList() { + MallUserInfo query = new MallUserInfo(); + query.setIsAdmin(0); + return userInfoService.findList(query); } @Transactional(rollbackFor = Exception.class) @@ -160,8 +121,7 @@ public class InvestBizServiceImpl implements InvestBizService { } @Override - public InvestDemandVo findById(Long id) { - InvestHelper.allNotNull(id); + public InvestDemandVo findDemandById(Long id) { InvestDemandEntity demandEntity = demandService.getByIdNotNull(id); InvestCustomerEntity customerEntity = customerService.getByIdNotNull(demandEntity.getCustomerId()); WxBrand brand = brandService.getById(customerEntity.getBrandId()); @@ -169,6 +129,14 @@ public class InvestBizServiceImpl implements InvestBizService { return buildResultItem(demandEntity, customerEntity, brand, shop); } + @Override + public InvestTaskVo findTaskById(Long id) { + InvestTaskEntity taskEntity = taskService.getByIdNotNull(id); + WxShop shop = shopService.getById(taskEntity.getTargetId()); + Map usersMap = getUserInfoMap(); + return buildResultItem(taskEntity, shop, usersMap); + } + private InvestDemandVo buildResultItem(InvestDemandEntity item, InvestCustomerEntity customer, WxBrand brand, WxShop shop) { InvestDemandVo resultItemVo = InvestDemandVo.builder() .brand(brand) @@ -178,4 +146,53 @@ public class InvestBizServiceImpl implements InvestBizService { BeanUtils.copyProperties(item, resultItemVo); return resultItemVo; } + + private Map getUserInfoMap() { + Collection users = userInfoService.findList(null); + 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)); + } + } + InvestTaskVo resultItemVo = InvestTaskVo.builder() + .targetInfo(shop) + .ownerInfo(ownerInfo) + .build(); + BeanUtils.copyProperties(item, resultItemVo); + return resultItemVo; + } + + private List getITargeInfoList(IPage 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)); + + //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)); + + List resultList = new ArrayList<>(); + for (InvestDemandEntity item : demandList) { + InvestCustomerEntity customer = customersMap.get(item.getCustomerId()); + WxShop shop = shopsMap.get(item.getTargetId()); + WxBrand brand = null; + if (Objects.nonNull(customer)) { + brand = brandMap.get(customer.getBrandId()); + } + resultList.add(buildResultItem(item, customer, brand, shop)); + } + return resultList; + } }