Commit c0f22f71 by qwmqiuwenmin

Merge branch 'contact-4-14' into 'developer'

Contact 4 14

See merge request !44
parents 91ffd3ef 35f158f8
......@@ -158,7 +158,9 @@ public interface DepartmentApiService {
* @return
*/
ServiceResponse<List<DepartmentDTO>> listStoreListByStaffId(String wxUserId);
void initwxDepartmentMQ(String res);
boolean isInitLocked(String wxEnterpriseId);
}
......@@ -47,7 +47,7 @@ public interface StaffApiService {
StaffDepartmentRelatedDTO getDepartmentIdAndCode(String departmentId, String code);
void initWxUser(String corpid, String contactSecret, String wxEnterpriseId, Integer wxDepartmentId);
void initWxUser(String corpid, String contactSecret, String wxEnterpriseId, Integer wxDepartmentId,String taskId);
public List<String> listUnBindClerk(String storeId);
......@@ -60,4 +60,5 @@ public interface StaffApiService {
public List<StaffDTO> listByPhoneNumber(String phoneNumber);
public List<StaffDTO> listByUserIdsAndWxEnterpriseId(List<String> userIds, String wxEnterpriseId);
}
package com.gic.haoban.manage.service.service;
import com.gic.haoban.manage.service.entity.TabHaobanSyncErrorLog;
public interface SyncErrorLogService {
void add(TabHaobanSyncErrorLog tab);
}
package com.gic.haoban.manage.service.service.impl;
import java.util.Date;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.gic.haoban.manage.service.dao.mapper.TabHaobanSyncErrorLogMapper;
import com.gic.haoban.manage.service.entity.TabHaobanSyncErrorLog;
import com.gic.haoban.manage.service.service.SyncErrorLogService;
@Service
public class SyncErrorLogServiceImpl implements SyncErrorLogService {
@Autowired
private TabHaobanSyncErrorLogMapper mapper;
@Override
public void add(TabHaobanSyncErrorLog tab) {
tab.setCreateTime(new Date());
tab.setUpdateTime(new Date());
mapper.insert(tab);
}
}
......@@ -44,7 +44,9 @@ import com.gic.haoban.manage.service.entity.TabHaobanSyncErrorLog;
import com.gic.haoban.manage.service.entity.TabHaobanWxEnterpriseRelated;
import com.gic.haoban.manage.service.service.DepartmentService;
import com.gic.haoban.manage.service.service.StaffDepartmentRelatedService;
import com.gic.haoban.manage.service.service.SyncErrorLogService;
import com.gic.haoban.manage.service.service.WxEnterpriseService;
import com.gic.redis.data.util.RedisUtil;
import com.gic.wechat.api.service.qywx.QywxDepartmentApiService;
import com.github.pagehelper.PageHelper;
......@@ -73,6 +75,8 @@ public class DepartmentApiServiceImpl implements DepartmentApiService {
@Autowired
private StaffDepartmentRelatedApiService staffDepartmentRelatedApiService;
@Autowired
private SyncErrorLogService syncErrorLogService;
@Override
......@@ -499,12 +503,20 @@ public class DepartmentApiServiceImpl implements DepartmentApiService {
//
// DepartmentDTO parent = EntityUtil.changeEntityByJSON(DepartmentDTO.class,departmentService.selectById(parentId));
// this.addSon(subList, wxEnterpriseId, parent,corpid,suiteid);
RedisUtil.lock("init_enterprise_" + wxEnterpriseId,60 * 60L);
String taskId = StringUtil.randomUUID();
List<com.gic.wechat.api.dto.qywx.DepartmentDTO> list = this.qywxDepartmentApiService.listSelfDepartment(corpid, contactSecret, null);
logger.info("企业所有部门数据:{}", JSON.toJSONString(list));
if(CollectionUtils.isNotEmpty(list)){
this.addAllDepartment(list, 0, wxEnterpriseId, corpid, contactSecret,taskId);
}
RedisUtil.unlock("init_enterprise_" + wxEnterpriseId);
}
@Override
public boolean isInitLocked(String wxEnterpriseId){
return RedisUtil.isLocked("init_enterprise_" + wxEnterpriseId);
}
......@@ -551,9 +563,10 @@ public class DepartmentApiServiceImpl implements DepartmentApiService {
tab.setReason(e.getMessage());
tab.setTaskId(taskId);
tab.setWxEnterpriseId(wxEnterpriseId);
syncErrorLogService.add(tab);
}
this.addAllDepartment(list, departmentDTO.getId(), wxEnterpriseId, corpid, contactSecret,taskId);
this.staffApiService.initWxUser(corpid, contactSecret, wxEnterpriseId, departmentDTO.getId());
this.staffApiService.initWxUser(corpid, contactSecret, wxEnterpriseId, departmentDTO.getId(),taskId);
}
}
......@@ -632,7 +645,7 @@ public class DepartmentApiServiceImpl implements DepartmentApiService {
rer.setResult(departmentList);
return rer;
}
@Override
public void initwxDepartmentMQ(String res) {
WxEnterpriseDTO enterpriseDTO = this.wxEnterpriseService.selectById(res);
......
......@@ -47,9 +47,11 @@ import com.gic.haoban.manage.service.dao.mapper.StaffMapper;
import com.gic.haoban.manage.service.entity.TabHaobanDepartment;
import com.gic.haoban.manage.service.entity.TabHaobanStaff;
import com.gic.haoban.manage.service.entity.TabHaobanStaffDepartmentRelated;
import com.gic.haoban.manage.service.entity.TabHaobanSyncErrorLog;
import com.gic.haoban.manage.service.service.DepartmentService;
import com.gic.haoban.manage.service.service.StaffDepartmentRelatedService;
import com.gic.haoban.manage.service.service.StaffService;
import com.gic.haoban.manage.service.service.SyncErrorLogService;
import com.gic.haoban.manage.service.service.UserLoginLogService;
import com.gic.haoban.manage.service.service.WxEnterpriseService;
import com.gic.wechat.api.dto.qywx.UserDTO;
......@@ -87,6 +89,8 @@ public class StaffApiServiceImpl implements StaffApiService {
private UserLoginLogService userLoginLogService;
@Autowired
private WxEnterpriseRelatedApiService wxEnterpriseRelatedApiService;
@Autowired
private SyncErrorLogService syncErrorLogService;
@Override
public StaffDTO selectById(String staffId) {
......@@ -772,11 +776,22 @@ public class StaffApiServiceImpl implements StaffApiService {
}
@Override
public void initWxUser(String corpid, String contactSecret, String wxEnterpriseId, Integer wxDepartmentId) {
public void initWxUser(String corpid, String contactSecret, String wxEnterpriseId, Integer wxDepartmentId,String taskId) {
List<UserDTO> list = this.qywxUserApiService.listSelfDepartmentUser(corpid, contactSecret, wxDepartmentId.toString(), 0);
if(CollectionUtils.isNotEmpty(list)){
for(UserDTO dto : list){
this.wxGetAdd(dto.getUserid(), wxEnterpriseId);
try {
this.wxGetAdd(dto.getUserid(), wxEnterpriseId);
} catch (Exception e) {
TabHaobanSyncErrorLog tab = new TabHaobanSyncErrorLog();
tab.setDataId(dto.getUserid());
tab.setDataType(0);
tab.setLogType(0);
tab.setReason(e.getMessage());
tab.setTaskId(taskId);
tab.setWxEnterpriseId(wxEnterpriseId);
syncErrorLogService.add(tab);
}
}
}
}
......
......@@ -109,9 +109,14 @@ public class ApplicationController extends WebBaseController{
WxEnterpriseDTO enterpriseDTO = this.wxEnterpriseApiService.getOne(wxEnterpriseId);
if(enterpriseDTO != null){
if(StringUtils.isNotBlank(enterpriseDTO.getContactSecret()) && enterpriseDTO.getContactFlag() != null && enterpriseDTO.getContactFlag() == 0){
this.departmentApiService.initwxDepartment(enterpriseDTO.getCorpid(), enterpriseDTO.getContactSecret(), enterpriseDTO.getWxEnterpriseId());
enterpriseDTO.setContactFlag(1);
wxEnterpriseApiService.update(enterpriseDTO);
log.info("【初始化部门调用】{},{},{}",RouterConstant.INIT_WX_DEPARTMENT_SERVICENAME,RouterConstant.INIT_WX_DEPARTMENT_METHODNAME,wxEnterpriseId);
try {
GICMQClientUtil.getClientInstance().sendCommonMessage(RouterConstant.ROUTERTYPE, wxEnterpriseId,
RouterConstant.INIT_WX_DEPARTMENT_SERVICENAME, RouterConstant.INIT_WX_DEPARTMENT_METHODNAME);
} catch (Exception e) {
log.info(e.getMessage(),e);
}
}
}
......@@ -180,6 +185,28 @@ public class ApplicationController extends WebBaseController{
e.printStackTrace();
}
}
@RequestMapping("init-wx-department")
public HaobanResponse initWxDepartment(){
LoginVO login = (LoginVO) AuthRequestUtil.getLoginUser();
String wxEnterpriseId = login.getWxEnterpriseId();
WxEnterpriseDTO enterpriseDTO = this.wxEnterpriseApiService.getOne(wxEnterpriseId);
if(enterpriseDTO != null){
if(StringUtils.isNotBlank(enterpriseDTO.getContactSecret()) && enterpriseDTO.getContactFlag() != null && enterpriseDTO.getContactFlag() == 0){
log.info("【初始化部门调用】{},{},{}",RouterConstant.INIT_WX_DEPARTMENT_SERVICENAME,RouterConstant.INIT_WX_DEPARTMENT_METHODNAME,wxEnterpriseId);
try {
GICMQClientUtil.getClientInstance().sendCommonMessage(RouterConstant.ROUTERTYPE, wxEnterpriseId,
RouterConstant.INIT_WX_DEPARTMENT_SERVICENAME, RouterConstant.INIT_WX_DEPARTMENT_METHODNAME);
} catch (Exception e) {
log.info(e.getMessage(),e);
}
}
}
return resultResponse(HaoBanErrCode.ERR_1, true);
}
@RequestMapping("cancal-suite")
@IgnoreLogin
......
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