Commit 007f59b4 by fudahua

绑定接口

parent 83a7a273
......@@ -15,6 +15,10 @@ public class StoreRangeInfoDTO implements Serializable {
*
*/
private String wxEnterpriseId;
/**
* 企业名称
*/
private String wxEnterpriseName;
/**
* 关联id 默认0
......@@ -26,6 +30,13 @@ public class StoreRangeInfoDTO implements Serializable {
*/
private Integer relationType;
public String getWxEnterpriseName() {
return wxEnterpriseName;
}
public void setWxEnterpriseName(String wxEnterpriseName) {
this.wxEnterpriseName = wxEnterpriseName;
}
/**
*/
......
package com.gic.haoban.manage.web.controller;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
import com.gic.haoban.auth.api.dto.UserRightDetailDTO;
import com.gic.enterprise.api.dto.PowerStoreGroupDTO;
import com.gic.enterprise.api.service.StoreGroupService;
import com.gic.haoban.common.utils.HaobanResponse;
import com.gic.haoban.manage.api.dto.StoreRangeInfoDTO;
import com.gic.haoban.manage.api.dto.WxEnterpriseRelationDetailDTO;
import com.gic.haoban.manage.api.dto.WxEnterpriseDTO;
import com.gic.haoban.manage.api.service.WxEnterpriseRelatedApiService;
import com.gic.haoban.manage.web.errCode.HaoBanErrCode;
import com.gic.haoban.manage.web.vo.LoginVO;
import com.gic.haoban.manage.web.vo.StoreGroupVo;
import org.apache.commons.collections.CollectionUtils;
......@@ -18,11 +16,11 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.gic.enterprise.api.dto.PowerStoreGroupDTO;
import com.gic.enterprise.api.service.StoreGroupService;
import com.gic.haoban.base.api.common.BasePageInfo;
import com.gic.haoban.common.utils.HaobanResponse;
import com.gic.haoban.manage.web.errCode.HaoBanErrCode;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@RestController
public class GicDepartmentController extends WebBaseController{
......@@ -49,17 +47,28 @@ public class GicDepartmentController extends WebBaseController{
String wxEnterpriseId = loginUser.getWxEnterpriseId();
List<PowerStoreGroupDTO> departmentList = storeGroupService.getStoreGroupList(enterpriseId, keyWord);
List<StoreRangeInfoDTO> rangeInfoDTOList = wxEnterpriseRelatedApiService.listAllBindStoreOrGroup(enterpriseId);
Set<String> groupIds = new HashSet<>();
Map<String, StoreRangeInfoDTO> storeRangeMap = new HashMap<>();
if (CollectionUtils.isNotEmpty(rangeInfoDTOList)) {
groupIds = rangeInfoDTOList.stream().filter(dto -> (!dto.getWxEnterpriseId().equals(wxEnterpriseId)) && dto.getRelationType() == 1)
.map(dto -> dto.getRelationId()).collect(Collectors.toSet());
List<WxEnterpriseDTO> wxEnterpriseDTOS = wxEnterpriseRelatedApiService.listWxEnterpriseByEid(enterpriseId);
Map<String, WxEnterpriseDTO> wxEnterpriseDTOMap = wxEnterpriseDTOS.stream().collect(Collectors.toMap(dto -> dto.getWxEnterpriseId(), dto -> dto));
storeRangeMap = rangeInfoDTOList.stream().filter(dto -> (!dto.getWxEnterpriseId().equals(wxEnterpriseId)) && dto.getRelationType() == 1)
.map(dto -> {
dto.setWxEnterpriseName(wxEnterpriseDTOMap.get(dto.getWxEnterpriseId()).getCorpName());
return dto;
}).collect(Collectors.toMap(dto -> dto.getRelationId(), dto -> dto));
}
Set<String> finalGroupIds = groupIds;
Map<String, StoreRangeInfoDTO> finalStoreRangeMap = storeRangeMap;
List<StoreGroupVo> ret = departmentList.stream().map(dto -> {
StoreRangeInfoDTO mid = finalStoreRangeMap.get(dto.getStoreGroupId());
StoreGroupVo storeGroupVo = new StoreGroupVo();
storeGroupVo.setRelationId(dto.getStoreGroupId());
storeGroupVo.setParentRelationId(dto.getParentGroupId());
storeGroupVo.setIsBind(finalGroupIds.contains(dto.getStoreGroupId()) ? 1 : 0);
if (mid != null) {
storeGroupVo.setIsBind(1);
storeGroupVo.setWxEnterpriseId(mid.getWxEnterpriseId());
storeGroupVo.setWxEnterpriseName(mid.getWxEnterpriseName());
}
storeGroupVo.setRelationType(1);
storeGroupVo.setRelationName(dto.getStoreGroupName());
return storeGroupVo;
......
......@@ -12,8 +12,26 @@ public class StoreGroupVo implements Serializable {
private Integer relationType;
private String relationName;
private int isBind = 0;
private String wxEnterpriseId;
private String wxEnterpriseName;
private String parentRelationId;
public String getWxEnterpriseId() {
return wxEnterpriseId;
}
public void setWxEnterpriseId(String wxEnterpriseId) {
this.wxEnterpriseId = wxEnterpriseId;
}
public String getWxEnterpriseName() {
return wxEnterpriseName;
}
public void setWxEnterpriseName(String wxEnterpriseName) {
this.wxEnterpriseName = wxEnterpriseName;
}
public String getRelationId() {
return relationId;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment