Commit 3c73feb2 by 陶光胜

Merge branch 'developer' of http://115.159.76.241/haoban3.0/haoban-manage3.0 into developer

parents 92969199 4a0ff118
......@@ -9,11 +9,14 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.gic.commons.util.EntityUtil;
import com.gic.enterprise.api.dto.GicTreeDTO;
import com.gic.enterprise.api.service.StoreGroupService;
import com.gic.haoban.common.utils.UuidUtil;
import com.gic.haoban.manage.api.dto.EnterpriseDetailDTO;
import com.gic.haoban.manage.api.service.WxEnterpriseRelatedApiService;
import com.gic.haoban.manage.service.dao.mapper.WxEnterpriseRelatedMapper;
import com.gic.haoban.manage.service.entity.TabHaobanWxEnterpriseRelated;
import com.gic.haoban.manage.service.service.DepartmentService;
import com.gic.haoban.manage.service.service.WxEnterpriseRelatedService;
@Service
......@@ -23,15 +26,56 @@ public class WxEnterpriseRelatedApiServiceImpl implements WxEnterpriseRelatedApi
private WxEnterpriseRelatedMapper wxEnterpriseRelatedMapper;
@Autowired
private WxEnterpriseRelatedService wxEnterpriseRelatedService;
@Autowired
private StoreGroupService storeGroupService;
@Autowired
private DepartmentService departmentService;
@Override
public List<EnterpriseDetailDTO> listEnterpriseByWxEnterpriseId(
String wxEnterpriseId) {
List<TabHaobanWxEnterpriseRelated> relatedList = wxEnterpriseRelatedMapper.listByWxenterpriseId(wxEnterpriseId);
List<EnterpriseDetailDTO> result = EntityUtil.changeEntityListByJSON(EnterpriseDetailDTO.class, relatedList);
//TODO 调熊大接口,获取nodeCount
for (EnterpriseDetailDTO enterpriseDetailDTO : result) {
String enterpriseId = enterpriseDetailDTO.getEnterpriseId();
int nodeCount = 0;
List<GicTreeDTO> departmentList = storeGroupService.listGicTree(enterpriseId,1, null);
for (GicTreeDTO gicTreeDTO : departmentList) {
if(departmentService.getByRelatedId(gicTreeDTO.getId()) == null) {
nodeCount ++;
}
nodeCount += getNodeCount(enterpriseId,gicTreeDTO.getId(),gicTreeDTO.getType());
}
List<GicTreeDTO> departmentList2 = storeGroupService.listGicTree(enterpriseId,2, null);
for (GicTreeDTO gicTreeDTO : departmentList2) {
if(departmentService.getByRelatedId(gicTreeDTO.getId()) == null) {
nodeCount ++;
}
nodeCount += getNodeCount(enterpriseId,gicTreeDTO.getId(),gicTreeDTO.getType());
}
enterpriseDetailDTO.setNodeCount(nodeCount);
}
return result;
}
public int getNodeCount(String enterpriseId,String parentId,int type) {
int nodeCount = 0;
List<GicTreeDTO> departmentList = storeGroupService.listGicTree(enterpriseId,type, parentId);
for (GicTreeDTO gicTreeDTO : departmentList) {
if(departmentService.getByRelatedId(gicTreeDTO.getId()) == null) {
nodeCount ++;
}
}
while(departmentList.isEmpty()) {
for (GicTreeDTO gicTreeDTO : departmentList) {
nodeCount += getNodeCount(enterpriseId,gicTreeDTO.getId(),gicTreeDTO.getType());
}
}
return nodeCount;
}
@Override
public int wxEnterpriseBind(String enterpriseId, String wxEnterpriseId,
String version) {
......
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