From bfc9774d9dce6d97477c1dc1f475850a9fdf05fd Mon Sep 17 00:00:00 2001 From: Burce Date: Tue, 15 Oct 2019 11:08:51 +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 | 4 +- .../domain/vo/invest/InvestFollowQuery.java | 1 - .../com/iformall/enums/EnumFollowType.java | 2 + .../service/invest/event/InvestListener.java | 4 +- .../invest/impl/InvestBizServiceImpl.java | 39 +++++++++---------- 5 files changed, 24 insertions(+), 26 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 1ab166601..6022b4af4 100644 --- a/mallinkAdmin/src/main/java/com/iformall/controller/invest/InvestBaseController.java +++ b/mallinkAdmin/src/main/java/com/iformall/controller/invest/InvestBaseController.java @@ -29,7 +29,7 @@ public class InvestBaseController extends BaseController { registerEnumEditor(dataBinder, EnumCustomerType.class, "customerType") ; registerEnumEditor(dataBinder, EnumCustomerRatingType.class, "customerRatingType") ; registerEnumEditor(dataBinder, EnumTaskStatus.class, "taskStatus") ; - registerEnumEditor(dataBinder, EnumFollowType.class, "followType") ; + registerEnumEditor(dataBinder, EnumFollowType.class, "type") ; } public InvestResultData execute(T params, Function function) { @@ -43,7 +43,7 @@ public class InvestBaseController extends BaseController { return new InvestResultData(e.getErrorCode(), e.getMessage()); } catch (NullPointerException e) { ErrorCode errorCode = ErrorCode.SYS_NULLPOINTER_ERROR ; - log.error("execute error", errorCode.getMessage()); + log.error("execute error {}", errorCode.getMessage()); return new InvestResultData(errorCode); } catch (Exception e) { log.error("execute error", e); diff --git a/mallinkService/src/main/java/com/iformall/domain/vo/invest/InvestFollowQuery.java b/mallinkService/src/main/java/com/iformall/domain/vo/invest/InvestFollowQuery.java index d9fcce846..6d830a63f 100644 --- a/mallinkService/src/main/java/com/iformall/domain/vo/invest/InvestFollowQuery.java +++ b/mallinkService/src/main/java/com/iformall/domain/vo/invest/InvestFollowQuery.java @@ -1,7 +1,6 @@ package com.iformall.domain.vo.invest; import com.iformall.enums.EnumFollowType; -import com.iformall.enums.EnumTaskStatus; import lombok.Data; @Data diff --git a/mallinkService/src/main/java/com/iformall/enums/EnumFollowType.java b/mallinkService/src/main/java/com/iformall/enums/EnumFollowType.java index 7133722aa..9cf70fb71 100644 --- a/mallinkService/src/main/java/com/iformall/enums/EnumFollowType.java +++ b/mallinkService/src/main/java/com/iformall/enums/EnumFollowType.java @@ -1,6 +1,7 @@ package com.iformall.enums; import com.baomidou.mybatisplus.annotation.EnumValue; +import com.fasterxml.jackson.annotation.JsonValue; /** * 跟踪类型:0-招商任务;1-客户需求 @@ -28,6 +29,7 @@ public enum EnumFollowType { this.info = info; } + @JsonValue public Integer getCode() { return code; } diff --git a/mallinkService/src/main/java/com/iformall/service/invest/event/InvestListener.java b/mallinkService/src/main/java/com/iformall/service/invest/event/InvestListener.java index d7801630c..b7f80ee9e 100644 --- a/mallinkService/src/main/java/com/iformall/service/invest/event/InvestListener.java +++ b/mallinkService/src/main/java/com/iformall/service/invest/event/InvestListener.java @@ -7,7 +7,6 @@ import com.iformall.domain.vo.RentEventInfo; import com.iformall.enums.EnumInvestType; import com.iformall.enums.EnumRentContractStatus; import com.iformall.enums.EnumTaskStatus; -import com.iformall.service.invest.InvestHelper; import com.iformall.service.invest.InvestTaskService; import com.iformall.utils.JsonUtil; import lombok.extern.slf4j.Slf4j; @@ -16,7 +15,6 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationListener; import org.springframework.stereotype.Component; -import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Objects; @@ -55,7 +53,7 @@ public class InvestListener implements ApplicationListener { for (InvestTaskEntity task : tasks) { task.setStatus(status); String content = task.getContent(); - HashMap contentMap = JSON.parseObject(content, HashMap.class); + Map contentMap = JSON.parseObject(content, Map.class); contentMap.put(InvestTaskEntity.KEY_CONTRACTID, rentEventInfo.getRentId()); task.setContent(JsonUtil.obj2Json(contentMap)); } 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 7358a595a..0b8a7b9e4 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 @@ -128,9 +128,9 @@ public class InvestBizServiceImpl implements InvestBizService { Collection taskList = taskPage.getRecords(); //2、目标信息 Collection shops = shopService.getByIds(getIds(taskList, InvestTaskEntity::getTargetId)); - HashMap shopsMap = getMap(shops, WxShop::getId); + Map shopsMap = getMap(shops, WxShop::getId); //3、用户信息 - HashMap usersMap = getMap(userInfoService.findList(null), MallUserInfo::getId); + Map usersMap = getMap(userInfoService.findList(null), MallUserInfo::getId); List resultList = new ArrayList<>(); for (InvestTaskEntity item : taskList) { WxShop shop = shopsMap.get(item.getTargetId()); @@ -182,13 +182,13 @@ public class InvestBizServiceImpl implements InvestBizService { Collection recordList = recordPage.getRecords(); //2、用户信息 - HashMap usersMap = getMap(userInfoService.findList(null), MallUserInfo::getId); + Map usersMap = getMap(userInfoService.findList(null), MallUserInfo::getId); //3、客户 Collection customers = customerService.listByIds(getIds(recordList, InvestFollowRecordEntity::getCustomerId)); - HashMap customerMap = getMap(customers, InvestCustomerEntity::getId); + Map customerMap = getMap(customers, InvestCustomerEntity::getId); //4、 品牌 - HashMap brandMap = getMap(brandService.getByIds(getIds(customers, InvestCustomerEntity::getBrandId)), WxBrand::getId); + Map brandMap = getMap(brandService.getByIds(getIds(customers, InvestCustomerEntity::getBrandId)), WxBrand::getId); List resultList = new ArrayList<>(); for (InvestFollowRecordEntity item : recordList) { @@ -217,13 +217,13 @@ public class InvestBizServiceImpl implements InvestBizService { } //2、用户信息 - HashMap usersMap = getMap(userInfoService.getByIds(getIds(recordList, InvestRemindEntity::getOwner)), MallUserInfo::getId); + Map usersMap = getMap(userInfoService.getByIds(getIds(recordList, InvestRemindEntity::getOwner)), MallUserInfo::getId); //3、客户 Collection customers = customerService.listByIds(getIds(resultList, InvestRemindVo::getCustomerId)); - HashMap customerMap = getMap(customers, InvestCustomerEntity::getId); + Map customerMap = getMap(customers, InvestCustomerEntity::getId); //4、 品牌 - HashMap brandMap = getMap(brandService.getByIds(getIds(customers, InvestCustomerEntity::getBrandId)), WxBrand::getId); + Map brandMap = getMap(brandService.getByIds(getIds(customers, InvestCustomerEntity::getBrandId)), WxBrand::getId); for (InvestRemindVo remindVo : resultList) { InvestCustomerEntity customerEntity = customerMap.get(remindVo.getCustomerId()); @@ -244,7 +244,7 @@ public class InvestBizServiceImpl implements InvestBizService { private List getMallUserInfos(Map usersMap, InvestFollowRecordEntity item) { List ownerInfo = null; - HashMap contentMap = JSON.parseObject(item.getContent(), HashMap.class); + Map contentMap = JSON.parseObject(item.getContent(), Map.class); if (MapUtils.isNotEmpty(contentMap)) { Object followMember = contentMap.get(InvestFollowRecordEntity.KEY_MEMBER); ownerInfo = getMallUserInfos(followMember, usersMap); @@ -291,7 +291,7 @@ public class InvestBizServiceImpl implements InvestBizService { InvestCustomerEntity customerEntity = customerService.getByIdNotNull(demandEntity.getCustomerId()); WxBrand brand = brandService.getById(customerEntity.getBrandId()); WxShop shop = shopService.getById(demandEntity.getTargetId()); - HashMap usersMap = getMap(userInfoService.findList(null), MallUserInfo::getId); + Map usersMap = getMap(userInfoService.findList(null), MallUserInfo::getId); return buildDemindItem(demandEntity, customerEntity, brand, shop, usersMap); } @@ -299,7 +299,7 @@ public class InvestBizServiceImpl implements InvestBizService { public InvestTaskVo findTaskById(Long id) { InvestTaskEntity taskEntity = taskService.getByIdNotNull(id); WxShop shop = shopService.getById(taskEntity.getTargetId()); - HashMap usersMap = getMap(userInfoService.findList(null), MallUserInfo::getId); + Map usersMap = getMap(userInfoService.findList(null), MallUserInfo::getId); return buildTaskItem(taskEntity, shop, usersMap); } @@ -321,7 +321,7 @@ public class InvestBizServiceImpl implements InvestBizService { @Override public InvestFollowRecordVo findFollowRecordById(Long id) { InvestFollowRecordEntity followRecordEntity = followRecordService.getByIdNotNull(id); - HashMap usersMap = getMap(userInfoService.findList(null), MallUserInfo::getId); + Map usersMap = getMap(userInfoService.findList(null), MallUserInfo::getId); InvestCustomerEntity customerEntity = customerService.getByIdNotNull(followRecordEntity.getCustomerId()); WxBrand brand = brandService.getById(customerEntity.getBrandId()); return buildFollowRecordItem(usersMap, followRecordEntity, customerEntity, brand); @@ -365,7 +365,7 @@ public class InvestBizServiceImpl implements InvestBizService { private InvestRemindVo buildRemindItem(InvestRemindEntity remindEntity) { InvestRemindVo remindVo = new InvestRemindVo(); BeanUtils.copyProperties(remindEntity, remindVo); - HashMap contentMap = JSON.parseObject(remindEntity.getContent(), HashMap.class); + Map contentMap = JSON.parseObject(remindEntity.getContent(), Map.class); if (MapUtils.isNotEmpty(contentMap)) { Object customerId = contentMap.get(InvestRemindEntity.KEY_CUSTOMER); remindVo.setCustomerId(Objects.isNull(customerId) ? null : Long.parseLong((String) customerId)); @@ -392,16 +392,16 @@ public class InvestBizServiceImpl implements InvestBizService { } private List getTargeInfoList(List demandList, Collection customers) { - HashMap demindsMap = getMap(demandList, InvestDemandEntity::getCustomerId); + Map demindsMap = getMap(demandList, InvestDemandEntity::getCustomerId); //3、目标信息 Collection shops = shopService.getByIds(getIds(demandList, InvestDemandEntity::getTargetId)); - HashMap shopsMap = getMap(shops, WxShop::getId); + Map shopsMap = getMap(shops, WxShop::getId); //4、品牌 - HashMap brandMap = getMap(brandService.getByIds(getIds(customers, InvestCustomerEntity::getBrandId)), WxBrand::getId); + Map brandMap = getMap(brandService.getByIds(getIds(customers, InvestCustomerEntity::getBrandId)), WxBrand::getId); //5、用户 - HashMap usersMap = getMap(userInfoService.findList(null), MallUserInfo::getId); + Map usersMap = getMap(userInfoService.findList(null), MallUserInfo::getId); List resultList = new ArrayList<>(); for (InvestCustomerEntity costomerItem : customers) { @@ -430,9 +430,8 @@ public class InvestBizServiceImpl implements InvestBizService { return function.apply(params); } - private HashMap getMap(Collection dataList, Function keyMapper) { - Map map = dataList.parallelStream().collect(Collectors.toMap(keyMapper, entity -> entity)); - return new HashMap<>(map); + private Map getMap(Collection dataList, Function keyMapper) { + return dataList.parallelStream().collect(Collectors.toMap(keyMapper, entity -> entity)); } private Collection getIds(Collection dataList, Function mapper) {