Commit dff24ee6 by 徐高华

好办延时调用

parent cfcce7c1
...@@ -8,7 +8,7 @@ public class CommonMQDTO implements Serializable { ...@@ -8,7 +8,7 @@ public class CommonMQDTO implements Serializable {
* @Fields serialVersionUID : TODO(用一句话描述这个变量表示什么) * @Fields serialVersionUID : TODO(用一句话描述这个变量表示什么)
*/ */
private static final long serialVersionUID = -5681421708810402425L; private static final long serialVersionUID = -5681421708810402425L;
// 1删除日报定时 2无部门成员修复
private int type; private int type;
private Object params; private Object params;
......
...@@ -14,6 +14,8 @@ public interface HaobanCommonMQApiService { ...@@ -14,6 +14,8 @@ public interface HaobanCommonMQApiService {
public void putCommonMessage(CommonMQDTO dto); public void putCommonMessage(CommonMQDTO dto);
public void putCommonDelayMessage(CommonMQDTO dto , int delay);
public void commonHandler(String message); public void commonHandler(String message);
} }
...@@ -44,6 +44,6 @@ public interface StaffDepartmentRelatedService { ...@@ -44,6 +44,6 @@ public interface StaffDepartmentRelatedService {
*/ */
public void repairAllStaffDepart(String params) ; public void repairAllStaffDepart(String params) ;
public void repairStaffDepart(String staffId) ; public void repairStaffDepart(String staffId) ;
public void staffDepartChange(TabHaobanStaff staff, String wxEnterpriseId, Integer[] departmentIds) ; public void staffDepartChange(TabHaobanStaff staff, String wxEnterpriseId, Integer[] departmentIds, boolean retryFlag) ;
} }
...@@ -21,11 +21,13 @@ import com.gic.commons.util.DateUtil; ...@@ -21,11 +21,13 @@ import com.gic.commons.util.DateUtil;
import com.gic.commons.util.EntityUtil; import com.gic.commons.util.EntityUtil;
import com.gic.haoban.common.utils.DingUtils; import com.gic.haoban.common.utils.DingUtils;
import com.gic.haoban.common.utils.StringUtil; import com.gic.haoban.common.utils.StringUtil;
import com.gic.haoban.manage.api.dto.CommonMQDTO;
import com.gic.haoban.manage.api.dto.DepartmentDTO; import com.gic.haoban.manage.api.dto.DepartmentDTO;
import com.gic.haoban.manage.api.dto.SecretSettingDTO; import com.gic.haoban.manage.api.dto.SecretSettingDTO;
import com.gic.haoban.manage.api.dto.StaffDepartmentRelatedDTO; import com.gic.haoban.manage.api.dto.StaffDepartmentRelatedDTO;
import com.gic.haoban.manage.api.dto.WxEnterpriseQwDTO; import com.gic.haoban.manage.api.dto.WxEnterpriseQwDTO;
import com.gic.haoban.manage.api.enums.SecretTypeEnum; import com.gic.haoban.manage.api.enums.SecretTypeEnum;
import com.gic.haoban.manage.api.service.HaobanCommonMQApiService;
import com.gic.haoban.manage.service.dao.mapper.StaffDepartmentRelatedMapper; import com.gic.haoban.manage.service.dao.mapper.StaffDepartmentRelatedMapper;
import com.gic.haoban.manage.service.dao.mapper.StaffMapper; import com.gic.haoban.manage.service.dao.mapper.StaffMapper;
import com.gic.haoban.manage.service.entity.TabHaobanStaff; import com.gic.haoban.manage.service.entity.TabHaobanStaff;
...@@ -54,6 +56,8 @@ public class StaffDepartmentRelatedServiceImpl implements StaffDepartmentRelated ...@@ -54,6 +56,8 @@ public class StaffDepartmentRelatedServiceImpl implements StaffDepartmentRelated
private QywxUserApiService qywxUserApiService ; private QywxUserApiService qywxUserApiService ;
@Autowired @Autowired
private DepartmentService departmentService ; private DepartmentService departmentService ;
@Autowired
private HaobanCommonMQApiService haobanCommonMQApiService ;
@Override @Override
public List<TabHaobanStaffDepartmentRelated> listByDepartmentId(String departmentId) { public List<TabHaobanStaffDepartmentRelated> listByDepartmentId(String departmentId) {
...@@ -156,22 +160,32 @@ public class StaffDepartmentRelatedServiceImpl implements StaffDepartmentRelated ...@@ -156,22 +160,32 @@ public class StaffDepartmentRelatedServiceImpl implements StaffDepartmentRelated
UserDTO user = qywxUserApiService.getSelfWorkWxUser(qwDTO.getDkCorpid(), secretSetting.getSecretVal(), wxUserId); UserDTO user = qywxUserApiService.getSelfWorkWxUser(qwDTO.getDkCorpid(), secretSetting.getSecretVal(), wxUserId);
logger.info("成员详情(代开)={}",JSON.toJSONString(user)) ; logger.info("成员详情(代开)={}",JSON.toJSONString(user)) ;
if(null != user.getDepartment()) { if(null != user.getDepartment()) {
this.staffDepartChange(staff, wxEnterpriseId, user.getDepartment()); ; this.staffDepartChange(staff, wxEnterpriseId, user.getDepartment(),false); ;
} }
} }
} }
public void staffDepartChange(TabHaobanStaff staff, String wxEnterpriseId, Integer[] departmentIds) { public void staffDepartChange(TabHaobanStaff staff, String wxEnterpriseId, Integer[] departmentIds , boolean retryFlag) {
//更新部门 //更新部门
List<String> wxDepartIds = new ArrayList<>(); List<String> wxDepartIds = new ArrayList<>();
for (Integer wDId : departmentIds) { for (Integer wDId : departmentIds) {
wxDepartIds.add(wDId.toString()); wxDepartIds.add(wDId.toString());
} }
if(CollectionUtils.isEmpty(wxDepartIds)) {
return ;
}
//关联部门 //关联部门
List<DepartmentDTO> departmentDTOList = departmentService.listDepartmentByWxDepartIds(wxEnterpriseId, wxDepartIds); List<DepartmentDTO> departmentDTOList = departmentService.listDepartmentByWxDepartIds(wxEnterpriseId, wxDepartIds);
if (CollectionUtils.isEmpty(departmentDTOList)) { if (CollectionUtils.isEmpty(departmentDTOList)) {
logger.info("部门没有更新或同步:{}", wxEnterpriseId); logger.info("部门没有更新或同步:{}", wxEnterpriseId);
if(retryFlag) {
Map<String,Object> map = new HashMap<>() ;
map.put("staffId", staff.getStaffId()) ;
CommonMQDTO dto = new CommonMQDTO();
dto.setType(2);
dto.setParams(map);
this.haobanCommonMQApiService.putCommonDelayMessage(dto, 60);
}
return; return;
} }
...@@ -226,5 +240,4 @@ public class StaffDepartmentRelatedServiceImpl implements StaffDepartmentRelated ...@@ -226,5 +240,4 @@ public class StaffDepartmentRelatedServiceImpl implements StaffDepartmentRelated
} }
} }
} }
} }
...@@ -13,6 +13,7 @@ import com.alibaba.fastjson.JSONObject; ...@@ -13,6 +13,7 @@ import com.alibaba.fastjson.JSONObject;
import com.gic.commons.util.GICMQClientUtil; import com.gic.commons.util.GICMQClientUtil;
import com.gic.haoban.manage.api.dto.CommonMQDTO; import com.gic.haoban.manage.api.dto.CommonMQDTO;
import com.gic.haoban.manage.api.service.HaobanCommonMQApiService; import com.gic.haoban.manage.api.service.HaobanCommonMQApiService;
import com.gic.haoban.manage.service.service.StaffDepartmentRelatedService;
import com.gic.mq.sdk.GicMQClient; import com.gic.mq.sdk.GicMQClient;
import com.gic.quartz.api.dto.QuartzTaskDTO; import com.gic.quartz.api.dto.QuartzTaskDTO;
import com.gic.quartz.api.service.QuartzService; import com.gic.quartz.api.service.QuartzService;
...@@ -26,6 +27,8 @@ public class HaobanCommonMQApiServiceImpl implements HaobanCommonMQApiService { ...@@ -26,6 +27,8 @@ public class HaobanCommonMQApiServiceImpl implements HaobanCommonMQApiService {
@Autowired @Autowired
private QuartzService quartzService ; private QuartzService quartzService ;
@Autowired
private StaffDepartmentRelatedService staffDepartmentRelatedService ;
@Override @Override
public void putCommonMessage(CommonMQDTO dto) { public void putCommonMessage(CommonMQDTO dto) {
...@@ -41,14 +44,35 @@ public class HaobanCommonMQApiServiceImpl implements HaobanCommonMQApiService { ...@@ -41,14 +44,35 @@ public class HaobanCommonMQApiServiceImpl implements HaobanCommonMQApiService {
} }
@Override @Override
public void putCommonDelayMessage(CommonMQDTO dto , int delay) {
String message = JSONObject.toJSONString(dto);
log.info("加入好办延时通用队列params={}",message);
try {
mqClient.sendMessage("haobanDelayMQ", message, delay);
} catch (Exception e) {
log.error("发送MQ异常");
e.printStackTrace();
}
}
@Override
public void commonHandler(String message) { public void commonHandler(String message) {
log.info("接收好办通用队列params={}",message); log.info("接收好办通用队列params={}",message);
CommonMQDTO dto = JSON.parseObject(message, CommonMQDTO.class); CommonMQDTO dto = JSON.parseObject(message, CommonMQDTO.class);
// 好办停用,删除定时 // 好办停用,删除定时
if(dto.getType()==1) {
Map<String,String> map = (Map<String, String>) dto.getParams() ; Map<String,String> map = (Map<String, String>) dto.getParams() ;
switch (dto.getType()) {
case 1:
String enterpriseId = map.get("enterpriseId") ; String enterpriseId = map.get("enterpriseId") ;
this.deleteQuartz(enterpriseId); this.deleteQuartz(enterpriseId);
break;
case 2:
String staffId = map.get("staffId") ;
if(StringUtils.isNotBlank(staffId)) {
this.staffDepartmentRelatedService.repairStaffDepart(staffId);
}
default:
break;
} }
} }
......
package com.gic.haoban.manage.service.service.out.impl; package com.gic.haoban.manage.service.service.out.impl;
import cn.hutool.core.convert.Convert; import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.function.Function;
import java.util.stream.Collectors;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.gic.clerk.api.dto.ClerkQwDTO; import com.gic.clerk.api.dto.ClerkQwDTO;
import com.gic.clerk.api.service.ClerkService; import com.gic.clerk.api.service.ClerkService;
import com.gic.commons.util.*; import com.gic.commons.util.EntityUtil;
import com.gic.commons.util.GICMQClientUtil;
import com.gic.commons.util.GlobalInfo;
import com.gic.commons.util.GlobalVar;
import com.gic.commons.util.ImageUtil;
import com.gic.haoban.app.customer.service.api.service.InnerApiService; import com.gic.haoban.app.customer.service.api.service.InnerApiService;
import com.gic.haoban.base.api.common.Constant; import com.gic.haoban.base.api.common.Constant;
import com.gic.haoban.base.api.common.ServiceResponse; import com.gic.haoban.base.api.common.ServiceResponse;
import com.gic.haoban.manage.api.dto.*; import com.gic.haoban.manage.api.dto.CommonMQDTO;
import com.gic.haoban.manage.api.enums.*; import com.gic.haoban.manage.api.dto.DepartmentDTO;
import com.gic.haoban.manage.api.dto.QywxCallBackDTO;
import com.gic.haoban.manage.api.dto.SecretSettingDTO;
import com.gic.haoban.manage.api.dto.StaffClerkRelationDTO;
import com.gic.haoban.manage.api.dto.StaffDTO;
import com.gic.haoban.manage.api.dto.WxEnterpriseDTO;
import com.gic.haoban.manage.api.dto.WxEnterpriseQwDTO;
import com.gic.haoban.manage.api.enums.AppPageType;
import com.gic.haoban.manage.api.enums.ChannelCodeEnum;
import com.gic.haoban.manage.api.enums.NoticeMessageTypeEnum;
import com.gic.haoban.manage.api.enums.SecretTypeEnum;
import com.gic.haoban.manage.api.enums.WxEditType;
import com.gic.haoban.manage.api.service.HaobanCommonMQApiService;
import com.gic.haoban.manage.api.service.MessageApiService; import com.gic.haoban.manage.api.service.MessageApiService;
import com.gic.haoban.manage.api.service.StaffApiService; import com.gic.haoban.manage.api.service.StaffApiService;
import com.gic.haoban.manage.api.service.StaffClerkRelationApiService; import com.gic.haoban.manage.api.service.StaffClerkRelationApiService;
import com.gic.haoban.manage.api.service.StaffDepartmentRelatedApiService; import com.gic.haoban.manage.api.service.StaffDepartmentRelatedApiService;
import com.gic.haoban.manage.api.util.notify.NoticeMessageUtil; import com.gic.haoban.manage.api.util.notify.NoticeMessageUtil;
import com.gic.haoban.manage.service.config.Config; import com.gic.haoban.manage.service.config.Config;
import com.gic.haoban.manage.service.entity.*; import com.gic.haoban.manage.service.entity.TabHaobanDepartment;
import com.gic.haoban.manage.service.service.*; import com.gic.haoban.manage.service.entity.TabHaobanStaff;
import com.gic.haoban.manage.service.entity.TabHaobanStaffDepartmentRelated;
import com.gic.haoban.manage.service.entity.TabHaobanWxApplication;
import com.gic.haoban.manage.service.entity.TabHaobanWxEnterpriseRelated;
import com.gic.haoban.manage.service.service.DepartmentService;
import com.gic.haoban.manage.service.service.SecretSettingService;
import com.gic.haoban.manage.service.service.StaffDepartmentRelatedService;
import com.gic.haoban.manage.service.service.StaffService;
import com.gic.haoban.manage.service.service.WxApplicationService;
import com.gic.haoban.manage.service.service.WxEnterpriseRelatedService;
import com.gic.haoban.manage.service.service.WxEnterpriseService;
import com.gic.mq.sdk.GicMQClient; import com.gic.mq.sdk.GicMQClient;
import com.gic.redis.data.util.RedisUtil; import com.gic.redis.data.util.RedisUtil;
import com.gic.thirdparty.api.dto.PicUploadResDTO; import com.gic.thirdparty.api.dto.PicUploadResDTO;
...@@ -30,16 +71,8 @@ import com.gic.wechat.api.service.qywx.QywxDepartmentApiService; ...@@ -30,16 +71,8 @@ import com.gic.wechat.api.service.qywx.QywxDepartmentApiService;
import com.gic.wechat.api.service.qywx.QywxSuiteApiService; import com.gic.wechat.api.service.qywx.QywxSuiteApiService;
import com.gic.wechat.api.service.qywx.QywxUserApiService; import com.gic.wechat.api.service.qywx.QywxUserApiService;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.*; import cn.hutool.core.convert.Convert;
import java.util.function.Function;
import java.util.stream.Collectors;
/** /**
* 接收企业微信或者gic推送消息进行处理 * 接收企业微信或者gic推送消息进行处理
...@@ -86,6 +119,8 @@ public class MessageApiServiceImpl implements MessageApiService { ...@@ -86,6 +119,8 @@ public class MessageApiServiceImpl implements MessageApiService {
private WxApplicationService wxApplicationService; private WxApplicationService wxApplicationService;
@Autowired @Autowired
private QywxUserApiService qywxUserApiService; private QywxUserApiService qywxUserApiService;
@Autowired
private HaobanCommonMQApiService haobanCommonMQApiService ;
@Override @Override
public void wxMessageReceive(QywxCallBackDTO qywxCallBackDTO) { public void wxMessageReceive(QywxCallBackDTO qywxCallBackDTO) {
...@@ -244,6 +279,12 @@ public class MessageApiServiceImpl implements MessageApiService { ...@@ -244,6 +279,12 @@ public class MessageApiServiceImpl implements MessageApiService {
TabHaobanDepartment department = this.departmentService.getByWxId(s, wxEnterpriseId); TabHaobanDepartment department = this.departmentService.getByWxId(s, wxEnterpriseId);
if (department == null) { if (department == null) {
log.info("成员同步,部门不存在"); log.info("成员同步,部门不存在");
Map<String,Object> map = new HashMap<>() ;
map.put("staffId", staff.getStaffId()) ;
CommonMQDTO dto = new CommonMQDTO();
dto.setType(2);
dto.setParams(map);
this.haobanCommonMQApiService.putCommonDelayMessage(dto, 60);
continue; continue;
} }
departmentIds.append(department.getDepartmentId()).append(","); departmentIds.append(department.getDepartmentId()).append(",");
......
...@@ -266,7 +266,7 @@ public class StaffApiServiceImpl implements StaffApiService { ...@@ -266,7 +266,7 @@ public class StaffApiServiceImpl implements StaffApiService {
staffService.updateByPrimaryKey(staff); staffService.updateByPrimaryKey(staff);
} }
logger.info("staff变更保存:{}", JSONObject.toJSONString(user)); logger.info("staff变更保存:{}", JSONObject.toJSONString(user));
this.staffDepartmentRelatedService.staffDepartChange(staff, wxEnterpriseId, user.getDepartment()); this.staffDepartmentRelatedService.staffDepartChange(staff, wxEnterpriseId, user.getDepartment(),true);
// 返回结果带上员工姓名 // 返回结果带上员工姓名
res.setResult(staff.getStaffName()); res.setResult(staff.getStaffName());
return res; return res;
......
...@@ -52,13 +52,6 @@ public class QywxStaffSyncOperation implements BaseSyncOperation { ...@@ -52,13 +52,6 @@ public class QywxStaffSyncOperation implements BaseSyncOperation {
private StaffApiService staffApiService; private StaffApiService staffApiService;
@Autowired @Autowired
private DealSyncOperationApiService dealSyncOperationApiService; private DealSyncOperationApiService dealSyncOperationApiService;
@Autowired
private QywxUserApiService qywxUserApiService;
@Autowired
private WxEnterpriseApiService wxEnterpriseApiService;
@Autowired
private Config config;
@Override @Override
public void dealSingleByMq(DealParamMqDTO dealParamMqDTO, TabHaobanPreDealLog dataPre) { public void dealSingleByMq(DealParamMqDTO dealParamMqDTO, TabHaobanPreDealLog dataPre) {
logger.info("企微通讯录成员同步处理:{}", JSONObject.toJSONString(dealParamMqDTO)); logger.info("企微通讯录成员同步处理:{}", JSONObject.toJSONString(dealParamMqDTO));
......
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