From d00c7e51d1af52bd4bb1fdf7dbd8b36b903848ce Mon Sep 17 00:00:00 2001 From: Burce Date: Tue, 22 Oct 2019 15:28:38 +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 --- .../invest/InvestBaseController.java | 11 ++ .../invest/InvestCustomerController.java | 10 +- .../po/invest/InvestCustomerEntity.java | 5 +- .../domain/po/invest/InvestDemandEntity.java | 3 + .../domain/vo/invest/InvestCustomerVo.java | 15 +++ .../service/invest/InvestBizService.java | 4 + .../iformall/service/invest/InvestHelper.java | 1 + .../invest/impl/InvestBaseServiceImpl.java | 26 ++--- .../invest/impl/InvestBizServiceImpl.java | 106 ++++++++++++++++-- .../impl/InvestCustomerServiceImpl.java | 1 - .../invest/impl/InvestDemandServiceImpl.java | 1 - .../invest/impl/InvestTaskServiceImpl.java | 1 - 12 files changed, 155 insertions(+), 29 deletions(-) diff --git a/mallinkAdmin/src/main/java/com/iformall/controller/invest/InvestBaseController.java b/mallinkAdmin/src/main/java/com/iformall/controller/invest/InvestBaseController.java index 3a9d4b6fa..296b1a0d7 100644 --- a/mallinkAdmin/src/main/java/com/iformall/controller/invest/InvestBaseController.java +++ b/mallinkAdmin/src/main/java/com/iformall/controller/invest/InvestBaseController.java @@ -14,6 +14,7 @@ import org.springframework.web.bind.annotation.InitBinder; import java.beans.PropertyEditor; import java.beans.PropertyEditorSupport; +import java.util.function.BiConsumer; import java.util.function.Function; @@ -52,6 +53,16 @@ public class InvestBaseController extends BaseController { } } + public void export(T t, U u, BiConsumer action) { + try { + log.debug("[" + getIpAddr() + "] request , params : {}", JSON.toJSONString(t)); + InvestUserContext.setUser(getUser()); + action.accept(t, u); + } finally { + InvestUserContext.remove(); + } + } + private void setUserRule() { EnumInvestUserType investUserType = EnumInvestUserType.getEnum(getUser().getInvestRule()) ; InvestUserContext.setInvestUserType(investUserType); diff --git a/mallinkAdmin/src/main/java/com/iformall/controller/invest/InvestCustomerController.java b/mallinkAdmin/src/main/java/com/iformall/controller/invest/InvestCustomerController.java index 9acce2b80..02c72a0cd 100755 --- a/mallinkAdmin/src/main/java/com/iformall/controller/invest/InvestCustomerController.java +++ b/mallinkAdmin/src/main/java/com/iformall/controller/invest/InvestCustomerController.java @@ -5,10 +5,8 @@ import com.iformall.annotation.SystemControllerLog; import com.iformall.annotation.SystemServiceLog; import com.iformall.common.InvestResultData; import com.iformall.domain.dto.InvestDemandDto; -import com.iformall.domain.po.invest.InvestCustomerEntity; import com.iformall.domain.vo.invest.InvestDemandQuery; import com.iformall.domain.vo.invest.InvestDemandVo; -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.InvestCustomerService; @@ -18,6 +16,7 @@ import lombok.extern.slf4j.Slf4j; import org.springframework.web.bind.annotation.*; import org.springframework.beans.factory.annotation.Autowired; +import javax.servlet.http.HttpServletResponse; import java.util.List; @@ -87,4 +86,11 @@ public class InvestCustomerController extends InvestBaseController{ return execute(customerDto, p -> investBizService.updateCustomerAndDemand(p)); } + @ApiOperation("导出客户信息") + @GetMapping("/exportCustomer") + @SystemControllerLog(description = "招商管理-导出客户信息") + public void exportCustomer(InvestDemandQuery params, HttpServletResponse response) { + export(params, response, (p, u) -> investBizService.exportCustomer(p, u)); + } + } diff --git a/mallinkService/src/main/java/com/iformall/domain/po/invest/InvestCustomerEntity.java b/mallinkService/src/main/java/com/iformall/domain/po/invest/InvestCustomerEntity.java index 68efdd102..acfd0cc43 100755 --- a/mallinkService/src/main/java/com/iformall/domain/po/invest/InvestCustomerEntity.java +++ b/mallinkService/src/main/java/com/iformall/domain/po/invest/InvestCustomerEntity.java @@ -1,5 +1,6 @@ package com.iformall.domain.po.invest; +import cn.afterturn.easypoi.excel.annotation.Excel; import com.baomidou.mybatisplus.annotation.TableName; @@ -30,13 +31,15 @@ public class InvestCustomerEntity extends InvestBaseEntity { * 客户名称 */ @LogColumn - @io.swagger.annotations.ApiModelProperty(value = "客户名称", name = "name") + @io.swagger.annotations.ApiModelProperty(value = "品牌负责人", name = "name") + @Excel(name = "品牌负责人", width = 20, orderNum = "2") private String name; /** * 电话 */ @LogColumn @io.swagger.annotations.ApiModelProperty(value = "电话", name = "phone") + @Excel(name = "负责人电话", width = 20, orderNum = "3") private String phone; /** * 经营业态 diff --git a/mallinkService/src/main/java/com/iformall/domain/po/invest/InvestDemandEntity.java b/mallinkService/src/main/java/com/iformall/domain/po/invest/InvestDemandEntity.java index 68580c1cb..cda0ec9f3 100755 --- a/mallinkService/src/main/java/com/iformall/domain/po/invest/InvestDemandEntity.java +++ b/mallinkService/src/main/java/com/iformall/domain/po/invest/InvestDemandEntity.java @@ -24,6 +24,9 @@ import java.util.Date; @EqualsAndHashCode(callSuper = true) public class InvestDemandEntity extends InvestBaseEntity { + public static final String KEY_RENT_AREA = "rent_area" ; + public static final String KEY_OPENING_TIME = "opening_time" ; + /** * 负责人 */ diff --git a/mallinkService/src/main/java/com/iformall/domain/vo/invest/InvestCustomerVo.java b/mallinkService/src/main/java/com/iformall/domain/vo/invest/InvestCustomerVo.java index 300887205..2f8136d0b 100644 --- a/mallinkService/src/main/java/com/iformall/domain/vo/invest/InvestCustomerVo.java +++ b/mallinkService/src/main/java/com/iformall/domain/vo/invest/InvestCustomerVo.java @@ -1,5 +1,6 @@ package com.iformall.domain.vo.invest; +import cn.afterturn.easypoi.excel.annotation.Excel; import com.iformall.domain.po.invest.InvestCustomerEntity; import lombok.Data; import lombok.EqualsAndHashCode; @@ -16,4 +17,18 @@ public class InvestCustomerVo extends InvestCustomerEntity { @io.swagger.annotations.ApiModelProperty(value = "客户需求负责人", name = "demandOwner") private Long demandOwner; + + @Excel(name = "品牌", width = 30, orderNum = "1") + private String brandName; + @Excel(name = "经营业态", width = 20, orderNum = "3") + private String business; + + @Excel(name = "意向租赁面积", width = 20, orderNum = "5") + private String rentArea; + + @Excel(name = "预计开业时间", width = 20, orderNum = "6") + private String openingTime; + + @Excel(name = "意向铺位", width = 20, orderNum = "4") + private String shopNumber; } 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 f61664680..a49831d0b 100644 --- a/mallinkService/src/main/java/com/iformall/service/invest/InvestBizService.java +++ b/mallinkService/src/main/java/com/iformall/service/invest/InvestBizService.java @@ -6,12 +6,16 @@ import com.iformall.domain.po.invest.InvestMessageEntity; import com.iformall.domain.po.invest.InvestTaskEntity; import com.iformall.domain.vo.invest.*; +import javax.servlet.http.HttpServletResponse; import java.util.Collection; import java.util.List; public interface InvestBizService { InvestPageResult queryPageDemand(InvestDemandQuery params); + + void exportCustomer(InvestDemandQuery params, HttpServletResponse response); + List queryCustomer(); InvestPageResult queryPageTask(InvestTaskQuery params); 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 23205df5d..8c9884955 100644 --- a/mallinkService/src/main/java/com/iformall/service/invest/InvestHelper.java +++ b/mallinkService/src/main/java/com/iformall/service/invest/InvestHelper.java @@ -1,5 +1,6 @@ package com.iformall.service.invest; +import com.alibaba.fastjson.JSON; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.google.common.collect.ImmutableListMultimap; import com.google.common.collect.Multimaps; diff --git a/mallinkService/src/main/java/com/iformall/service/invest/impl/InvestBaseServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/invest/impl/InvestBaseServiceImpl.java index 4bf2ea573..d234f5020 100644 --- a/mallinkService/src/main/java/com/iformall/service/invest/impl/InvestBaseServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/invest/impl/InvestBaseServiceImpl.java @@ -68,37 +68,37 @@ public class InvestBaseServiceImpl, T> extends ServiceIm @Override public T getByIdNotNull(Serializable id) { - InvestHelper.checkResult(id,"id=null"); + InvestHelper.checkResult(id, "id=null"); T t = super.getById(id); - InvestHelper.checkResult(t,"id=null"); + InvestHelper.checkResult(t, "id=null"); return t; } boolean saveAction(T entity, Consumer consumer) { - checkUserAndTenant(entity,consumer); + checkUserAndTenant(entity, consumer); return super.save(entity); } boolean updateActon(T entity, Wrapper updateWrapper, Consumer consumer) { - checkUserAndTenant(entity,consumer); + checkUserAndTenant(entity, consumer); return super.update(entity, updateWrapper); } boolean saveOrUpdateAction(T entity, Consumer consumer) { - checkUserAndTenant(entity,consumer); + checkUserAndTenant(entity, consumer); return super.saveOrUpdate(entity); } boolean updateByIdAction(T entity, Consumer consumer) { - checkUserAndTenant(entity,consumer); + checkUserAndTenant(entity, consumer); return super.updateById(entity); } - void checkUserAndTenant(T input,Consumer consumer) { + void checkUserAndTenant(T input, Consumer consumer) { InvestHelper.notNull(input, "参数"); InvestHelper.notNull(InvestUserContext.getUser(), ErrorCode.USER_IS_EMPTY); ((InvestBaseEntity) input).setTenantId(InvestUserContext.getUser().getTenantId()); - if(consumer!=null) { + if (consumer != null) { consumer.accept(input); } } @@ -111,13 +111,13 @@ public class InvestBaseServiceImpl, T> extends ServiceIm LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); queryWrapper.eq(InvestMessageEntity::getType, type); queryWrapper.eq(InvestMessageEntity::getTid, tid); - queryWrapper.eq(InvestMessageEntity::getTag,tag) ; + queryWrapper.eq(InvestMessageEntity::getTag, tag); queryWrapper.in(InvestMessageEntity::getOwner, ownerArray); List before = messageService.list(queryWrapper); - Map map = InvestHelper.getMap(before,InvestMessageEntity::getOwner) ; + Map map = InvestHelper.getMap(before, InvestMessageEntity::getOwner); List messageEntityList = new ArrayList<>(); for (Long aLong : ownerArray) { - if(Objects.nonNull(map.get(aLong))) { + if (Objects.nonNull(map.get(aLong))) { continue; } InvestMessageEntity messageEntity = new InvestMessageEntity(); @@ -198,7 +198,7 @@ public class InvestBaseServiceImpl, T> extends ServiceIm } void checkBusiness(WxBusinessService businessService, Integer businessId) { - WxBusiness business = businessService.getById(businessId) ; + WxBusiness business = businessService.getById(businessId); InvestHelper.notNull(business, ErrorCode.BUSINESS_NOT_FOUND); } @@ -208,7 +208,7 @@ public class InvestBaseServiceImpl, T> extends ServiceIm } protected Page buildQueryPage(InvestPageQuery pageQuery) { - return InvestHelper.buildQueryPage(pageQuery) ; + return InvestHelper.buildQueryPage(pageQuery); } 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 27691e590..b84616bcc 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 @@ -10,10 +10,7 @@ import com.iformall.domain.po.*; import com.iformall.domain.po.invest.*; import com.iformall.domain.vo.invest.*; import com.iformall.enums.*; -import com.iformall.service.MallUserInfoService; -import com.iformall.service.WxBrandService; -import com.iformall.service.WxRentContractService; -import com.iformall.service.WxShopService; +import com.iformall.service.*; import com.iformall.service.invest.*; import com.iformall.utils.DateUtils; import org.apache.commons.collections.CollectionUtils; @@ -26,6 +23,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import javax.servlet.http.HttpServletResponse; import java.util.*; import java.util.function.Function; import java.util.stream.Collectors; @@ -54,10 +52,15 @@ public class InvestBizServiceImpl implements InvestBizService { @Autowired private MallUserInfoService userInfoService; @Autowired + private WxBusinessService businessService; + @Autowired private WxRentContractService rentContractService; + @Autowired + private ExcelService excelService; @Override public InvestPageResult queryPageDemand(InvestDemandQuery params) { + InvestPageResult investPage = new InvestPageResult<>(); InvestDemandDto queryParams = convert(params, this::doConvertDemand); InvestCustomerEntity customerParams = null; InvestDemandEntity demandParams = null; @@ -65,10 +68,8 @@ public class InvestBizServiceImpl implements InvestBizService { customerParams = queryParams.getCustomer(); demandParams = queryParams.getDemand(); } - InvestPageResult investPage = new InvestPageResult<>(); List demandList = demandService.list(new LambdaQueryWrapper<>(demandParams)); LambdaQueryWrapper queryWrapperCustomer = new LambdaQueryWrapper<>(customerParams); - InvestPageResult customers; if (Objects.isNull(InvestUserContext.getDataUser())) { queryWrapperCustomer.in(ObjectUtils.allNotNull(params.getDemandOwner()), InvestCustomerEntity::getId, getIds(demandList, InvestDemandEntity::getCustomerId)); @@ -79,7 +80,8 @@ public class InvestBizServiceImpl implements InvestBizService { queryWrapperCustomer.in(InvestCustomerEntity::getId, getIds(demandList, InvestDemandEntity::getCustomerId)); } } - customers = customerService.queryPage(buildPageQuery(params, null), queryWrapperCustomer); + queryWrapperCustomer.orderByDesc(InvestCustomerEntity::getCreateDate); + InvestPageResult customers = customerService.queryPage(buildPageQuery(params, null), queryWrapperCustomer); List resultList = getTargeInfoList(demandList, customers.getRecords()); BeanUtils.copyProperties(customers, investPage); investPage.setRecords(resultList); @@ -90,6 +92,35 @@ public class InvestBizServiceImpl implements InvestBizService { return investPage; } + @Override + public void exportCustomer(InvestDemandQuery params, HttpServletResponse response) { + InvestDemandDto queryParams = convert(params, this::doConvertDemand); + InvestCustomerEntity customerParams = null; + InvestDemandEntity demandParams = null; + if (Objects.nonNull(queryParams)) { + customerParams = queryParams.getCustomer(); + demandParams = queryParams.getDemand(); + } + List demandList = demandService.list(new LambdaQueryWrapper<>(demandParams)); + LambdaQueryWrapper queryWrapperCustomer = new LambdaQueryWrapper<>(customerParams); + if (Objects.isNull(InvestUserContext.getDataUser())) { + queryWrapperCustomer.in(ObjectUtils.allNotNull(params.getDemandOwner()), + InvestCustomerEntity::getId, getIds(demandList, InvestDemandEntity::getCustomerId)); + } else { + if (CollectionUtils.isNotEmpty(demandList)) { + return; + } else { + queryWrapperCustomer.in(InvestCustomerEntity::getId, getIds(demandList, InvestDemandEntity::getCustomerId)); + } + } + queryWrapperCustomer.orderByDesc(InvestCustomerEntity::getCreateDate); + Collection customers = customerService.list(queryWrapperCustomer); + if (CollectionUtils.isNotEmpty(customers)) { + List resultList = getCustomerVOList(demandList, customers); + excelService.exportExcel(resultList, null, "客户信息", InvestCustomerVo.class, "客户信息.xlsx", response, false); + } + } + @Override public List queryCustomer() { List customerEntities = customerService.list(); @@ -140,7 +171,7 @@ public class InvestBizServiceImpl implements InvestBizService { } taskQueryWrapper.in(InvestTaskEntity::getTargetId, getIds(shops, WxShop::getId)); } - + taskQueryWrapper.orderByDesc(InvestTaskEntity::getCreateDate); InvestPageResult taskPage = taskService.queryPage(buildPageQuery(params, null), taskQueryWrapper); if (CollectionUtils.isEmpty(taskPage.getRecords())) { return investPage; @@ -220,7 +251,6 @@ public class InvestBizServiceImpl implements InvestBizService { followRecordEntity.setFollowId(params.getFollowId()); followRecordEntity.setType(params.getType()); InvestPageQuery pageQuery = buildPageQuery(params, followRecordEntity); - InvestPageResult recordPage = followRecordService.queryPage(pageQuery); InvestPageResult investPage = new InvestPageResult<>(); @@ -270,6 +300,7 @@ public class InvestBizServiceImpl implements InvestBizService { LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); queryWrapper.ge(Objects.nonNull(params.getRemindDate()), InvestRemindEntity::getBeginDate, getDayStart(params.getRemindDate())); queryWrapper.le(Objects.nonNull(params.getRemindDate()), InvestRemindEntity::getEndDate, getDayEnd(params.getRemindDate())); + queryWrapper.orderByDesc(InvestRemindEntity::getCreateDate); InvestPageResult recordPage = remindService.queryPage(remindPageQuery, queryWrapper); if (CollectionUtils.isEmpty(recordPage.getRecords())) { return investPage; @@ -320,6 +351,8 @@ public class InvestBizServiceImpl implements InvestBizService { InvestMessageEntity messageEntity = new InvestMessageEntity(); messageEntity.setOwner(InvestUserContext.getUserId()); query.setQueryData(messageEntity); + query.setSortColumn("createDate"); + query.setSortOrder("desc"); return messageService.queryPage(query); } @@ -327,6 +360,7 @@ public class InvestBizServiceImpl implements InvestBizService { if (ObjectUtils.allNotNull(tbl, tId)) { wrapper.eq(InvestOperateRecordEntity::getTbl, tbl); wrapper.eq(InvestOperateRecordEntity::getTid, tId); + wrapper.orderByDesc(InvestOperateRecordEntity::getCreateDate); } } @@ -538,6 +572,31 @@ public class InvestBizServiceImpl implements InvestBizService { return resultItemVo; } + private InvestCustomerVo buildCustomerItem(InvestDemandEntity item, InvestCustomerEntity customer, WxBrand brand, + WxShop shop, WxBusiness business) { + InvestCustomerVo resultItemVo = new InvestCustomerVo(); + BeanUtils.copyProperties(customer, resultItemVo); + if (Objects.nonNull(brand)) { + resultItemVo.setBrandName(brand.getName()); + } + if (Objects.nonNull(shop)) { + resultItemVo.setShopNumber(shop.getShopNumber()); + } + if (Objects.nonNull(business)) { + resultItemVo.setBusiness(business.getTitle()); + } + if (Objects.nonNull(item)) { + resultItemVo.setDemandOwner(item.getOwner()); + if (StringUtils.isNotBlank(item.getIntent())) { + Map intentMap = JSON.parseObject(item.getIntent(), Map.class); + resultItemVo.setRentArea(String.valueOf(intentMap.get(InvestDemandEntity.KEY_RENT_AREA))); + resultItemVo.setOpeningTime(String.valueOf(intentMap.get(InvestDemandEntity.KEY_OPENING_TIME))); + } + } + //resultItemVo.setBusiness(usersMap.get(item.getOwner())); + return resultItemVo; + } + private InvestTaskVo buildTaskItem(InvestTaskEntity item, WxShop shop, Map usersMap) { List ownerInfo = getMallUserInfos(item.getOwner(), usersMap); InvestTaskVo resultItemVo = new InvestTaskVo(); @@ -574,13 +633,40 @@ public class InvestBizServiceImpl implements InvestBizService { if (userId instanceof Long) { ownerInfo.add(usersMap.get(userId)); } else { - ownerInfo.add(usersMap.get(Long.parseLong((String) userId))); + String uId = (String) userId; + if (StringUtils.isNotBlank(uId)) { + ownerInfo.add(usersMap.get(Long.parseLong(uId))); + } } } } return ownerInfo; } + private List getCustomerVOList(List demandList, Collection customers) { + Map demindsMap = getMap(demandList, InvestDemandEntity::getCustomerId); + + //3、目标信息 + Collection shops = shopService.getByIds(getIds(demandList, InvestDemandEntity::getTargetId)); + Map shopsMap = getMap(shops, WxShop::getId); + + //4、品牌 + Map brandMap = getMap(brandService.getByIds(getIds(customers, InvestCustomerEntity::getBrandId)), WxBrand::getId); + //5、用户 + Map bussinessMap = getMap(businessService.getByIds(getIds(customers, InvestCustomerEntity::getBusinessId)), WxBusiness::getId); + List resultList = new ArrayList<>(); + for (InvestCustomerEntity costomerItem : customers) { + InvestDemandEntity demandItem = demindsMap.get(costomerItem.getId()); + WxShop shop = null; + if (Objects.nonNull(demandItem)) { + shop = shopsMap.get(demandItem.getTargetId()); + } + WxBrand brand = brandMap.get(costomerItem.getBrandId()); + resultList.add(buildCustomerItem(demandItem, costomerItem, brand, shop, bussinessMap.get(costomerItem.getBusinessId()))); + } + return resultList; + } + private List getTargeInfoList(List demandList, Collection customers) { Map demindsMap = getMap(demandList, InvestDemandEntity::getCustomerId); diff --git a/mallinkService/src/main/java/com/iformall/service/invest/impl/InvestCustomerServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/invest/impl/InvestCustomerServiceImpl.java index 2ff9af5ac..a84af1d59 100755 --- a/mallinkService/src/main/java/com/iformall/service/invest/impl/InvestCustomerServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/invest/impl/InvestCustomerServiceImpl.java @@ -33,7 +33,6 @@ public class InvestCustomerServiceImpl extends InvestBaseServiceImpl updateWrapper) { return super.updateActon(entity, updateWrapper, this::checkBeforeSaveOrUpdate); diff --git a/mallinkService/src/main/java/com/iformall/service/invest/impl/InvestDemandServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/invest/impl/InvestDemandServiceImpl.java index 6d18448fa..a30509947 100755 --- a/mallinkService/src/main/java/com/iformall/service/invest/impl/InvestDemandServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/invest/impl/InvestDemandServiceImpl.java @@ -30,7 +30,6 @@ public class InvestDemandServiceImpl extends InvestBaseServiceImpl