Commit 572dd1c9 by 陶光胜

加日志

parent ab8f0b18
......@@ -113,4 +113,6 @@ public interface DepartmentApiService {
*/
List<DepartmentDTO> listByChainId(String chainId,String wxEnterpriseId);
void initwxDepartment(String corpid, String suiteid, String wxEnterpriseId);
}
......@@ -5,6 +5,8 @@ import java.util.Date;
import java.util.List;
import java.util.Map;
import com.gic.haoban.base.api.common.Constant;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......@@ -314,4 +316,41 @@ public class DepartmentApiServiceImpl implements DepartmentApiService {
return EntityUtil.changeEntityListByJSON(DepartmentDTO.class, list);
}
@Override
public void initwxDepartment(String corpid, String suiteid, String wxEnterpriseId) {
List<com.gic.wechat.api.dto.qywx.DepartmentDTO> list = this.qywxDepartmentApiService.listDepartment(corpid, suiteid, null);
logger.info("企业所有部门数据:{}", JSON.toJSONString(list));
if(CollectionUtils.isNotEmpty(list)){
this.addAllDepartment(list, 1, wxEnterpriseId);
}
}
private void addAllDepartment(List<com.gic.wechat.api.dto.qywx.DepartmentDTO> list, Integer parentId, String wxEnterpriseId){
int level = 1;
String chainId = "0";
String chainName = "0";
if(parentId != 1){
TabHaobanDepartment parent = this.departmentService.getByWxId(parentId + "");
if(parent != null){
level = parent.getLevel() + 1;
chainId = parent.getChainId() + Constant.ID_SEPARATOR + parent.getDepartmentId();
chainName = parent.getChainName() + Constant.NAME_SEPARATOR + parent.getChainName();
}
}
for(com.gic.wechat.api.dto.qywx.DepartmentDTO departmentDTO : list){
if(parentId == departmentDTO.getParentid()){
com.gic.haoban.manage.api.dto.DepartmentDTO dto = new com.gic.haoban.manage.api.dto.DepartmentDTO();
dto.setDepartmentName(departmentDTO.getName());
dto.setLevel(level);
dto.setWxEnterpriseId(wxEnterpriseId);
dto.setWxDepartmentId(departmentDTO.getId()+"");
dto.setParentDepartmentId(parentId+"");
dto.setChainId(chainId);
dto.setChainName(chainName);
this.departmentService.add(dto);
this.addAllDepartment(list, departmentDTO.getId(), wxEnterpriseId);
}
}
}
}
......@@ -80,13 +80,6 @@ public class WxEnterpriseApiServiceImpl implements WxEnterpriseApiService {
wxApplicationService.update(tab);
}
log.info("企业微信授权处理完成");
if(dto.getLevel() != null && dto.getLevel() == 3){ //如果是通讯录应用拉取所有部门初始化
List<DepartmentDTO> list = this.qywxDepartmentApiService.listDepartment(dto.getCorpid(), dto.getSuiteId(), null);
log.info("企业所有部门数据:{}", JSON.toJSONString(list));
if(CollectionUtils.isNotEmpty(list)){
this.addAllDepartment(list, 1, wxEnterpriseId);
}
}
}
@Override
......@@ -111,34 +104,4 @@ public class WxEnterpriseApiServiceImpl implements WxEnterpriseApiService {
TabHaobanWxEnterprise enterprise = this.wxEnterpriseService.getEnterpriseBycorpId(corpId);
return EntityUtil.changeEntityByJSON(WxEnterpriseDTO.class, enterprise);
}
private void addAllDepartment(List<DepartmentDTO> list, Integer parentId, String wxEnterpriseId){
int level = 1;
String chainId = "0";
String chainName = "0";
if(parentId != 1){
TabHaobanDepartment parent = this.departmentService.getByWxId(parentId + "");
if(parent != null){
level = parent.getLevel() + 1;
chainId = parent.getChainId() + Constant.ID_SEPARATOR + parent.getDepartmentId();
chainName = parent.getChainName() + Constant.NAME_SEPARATOR + parent.getChainName();
}
}
for(DepartmentDTO departmentDTO : list){
if(parentId == departmentDTO.getParentid()){
com.gic.haoban.manage.api.dto.DepartmentDTO dto = new com.gic.haoban.manage.api.dto.DepartmentDTO();
dto.setDepartmentName(departmentDTO.getName());
dto.setLevel(level);
dto.setWxEnterpriseId(wxEnterpriseId);
dto.setWxDepartmentId(departmentDTO.getId()+"");
dto.setParentDepartmentId(parentId+"");
dto.setChainId(chainId);
dto.setChainName(chainName);
this.departmentService.add(dto);
this.addAllDepartment(list, departmentDTO.getId(), wxEnterpriseId);
}
}
}
}
......@@ -6,6 +6,7 @@ import com.alibaba.fastjson.JSON;
import com.ctrip.framework.apollo.spring.annotation.ApolloConfig;
import com.gic.haoban.common.utils.GlobalVar;
import com.gic.haoban.manage.api.dto.*;
import com.gic.haoban.manage.api.service.DepartmentApiService;
import com.gic.haoban.manage.api.service.WxApplicationApiService;
import com.gic.haoban.manage.api.service.WxEnterpriseApiService;
import com.gic.haoban.manage.web.anno.IgnoreLogin;
......@@ -35,6 +36,8 @@ public class ApplicationController extends WebBaseController{
private WxEnterpriseApiService wxEnterpriseApiService;
@Autowired
private Config config;
@Autowired
private DepartmentApiService departmentApiService;
@RequestMapping("application-list")
public HaobanResponse applicationList() {
......@@ -71,6 +74,7 @@ public class ApplicationController extends WebBaseController{
applicationDTO.setAgentName(dto.getAgentName());
applicationDTO.setSiteId(dto.getSuiteId());
wxApplicationApiService.addSuite(applicationDTO);
this.departmentApiService.initwxDepartment(dto.getCorpid(), suiteId, enterpriseDTO.getWxEnterpriseId());
return resultResponse(HaoBanErrCode.ERR_1, result);
}
return resultResponse(HaoBanErrCode.ERR_0, dto);
......
......@@ -29,7 +29,9 @@
<dubbo:reference interface="com.gic.enterprise.api.service.StoreService" id="storeService"/>
<dubbo:reference interface="com.gic.enterprise.api.service.DepartmentService" id="departmentService"/>
<dubbo:reference interface="com.gic.haoban.manage.api.service.DepartmentApiService" id="departmentApiService"/>
<dubbo:reference interface="com.gic.haoban.manage.api.service.DepartmentApiService" id="departmentApiService">
<dubbo:method name="initwxDepartment" async="true"/>
</dubbo:reference>
<dubbo:reference interface="com.gic.enterprise.api.service.StoreGroupService" id="storeGroupService"/>
<dubbo:reference interface="com.gic.clerk.api.service.ClerkService" id="clerkService"/>
......
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