Commit 8570ad1d by jinxin

定时任务:刷新企业成员外部联系人

parent 27fcc0a3
...@@ -342,4 +342,11 @@ public interface StaffApiService { ...@@ -342,4 +342,11 @@ public interface StaffApiService {
* @return * @return
*/ */
com.gic.api.base.commons.ServiceResponse<List<WxEnterpriseRelatedDTO>> getWxEnterpriseRelatedList(String wxEnterpriseId); com.gic.api.base.commons.ServiceResponse<List<WxEnterpriseRelatedDTO>> getWxEnterpriseRelatedList(String wxEnterpriseId);
/**
* 定时任务
* 刷新企业成员外部联系人
* @param params 企业微信id,多个按”,“隔开
*/
com.gic.api.base.commons.ServiceResponse<Boolean> updateExternalUserId(String params);
} }
...@@ -400,4 +400,12 @@ public interface TabHaobanExternalClerkRelatedMapper { ...@@ -400,4 +400,12 @@ public interface TabHaobanExternalClerkRelatedMapper {
*/ */
List<TabHaobanExternalClerkRelated> queryClerkMemberRelations(@Param("staffId") String staffId, @Param("memberIds") List<String> memberIds); List<TabHaobanExternalClerkRelated> queryClerkMemberRelations(@Param("staffId") String staffId, @Param("memberIds") List<String> memberIds);
/**
* 查询企业微信下面 外部联系人是null的所有成员
* @param wxEnterpriseId
* @param enterpriseIdList
* @return
*/
List<String> listByWxEnterpriseId(@Param("wxEnterpriseId")String wxEnterpriseId, @Param("enterpriseIdList") List<String> enterpriseIdList);
} }
\ No newline at end of file
...@@ -98,4 +98,12 @@ public interface ExternalClerkRelatedService { ...@@ -98,4 +98,12 @@ public interface ExternalClerkRelatedService {
*/ */
List<TabHaobanExternalClerkRelated> queryClerkMemberRelations(String staffId, List<String> memberIds); List<TabHaobanExternalClerkRelated> queryClerkMemberRelations(String staffId, List<String> memberIds);
/**
* 查询企业微信下面,所有外部联系人是null的成员
* @param wxEnterpriseId
* @param enterpriseIdList
* @return
*/
List<String> listByWxEnterpriseId(String wxEnterpriseId,List<String> enterpriseIdList);
} }
...@@ -520,4 +520,9 @@ public class ExternalClerkRelatedServiceImpl implements ExternalClerkRelatedServ ...@@ -520,4 +520,9 @@ public class ExternalClerkRelatedServiceImpl implements ExternalClerkRelatedServ
} }
return this.mapper.queryClerkMemberRelations(staffId, memberIds); return this.mapper.queryClerkMemberRelations(staffId, memberIds);
} }
@Override
public List<String> listByWxEnterpriseId(String wxEnterpriseId, List<String> enterpriseIdList) {
return this.mapper.listByWxEnterpriseId(wxEnterpriseId,enterpriseIdList);
}
} }
...@@ -29,6 +29,8 @@ import com.gic.haoban.manage.api.dto.*; ...@@ -29,6 +29,8 @@ import com.gic.haoban.manage.api.dto.*;
import com.gic.haoban.manage.api.dto.qdto.TransferActiveCodeQDTO; import com.gic.haoban.manage.api.dto.qdto.TransferActiveCodeQDTO;
import com.gic.haoban.manage.api.dto.role.StoreRoleDTO; import com.gic.haoban.manage.api.dto.role.StoreRoleDTO;
import com.gic.haoban.manage.api.enums.SecretTypeEnum; import com.gic.haoban.manage.api.enums.SecretTypeEnum;
import com.gic.haoban.manage.api.enums.SyncTaskTypeEnum;
import com.gic.haoban.manage.api.service.DealSyncOperationApiService;
import com.gic.haoban.manage.api.service.StaffApiService; import com.gic.haoban.manage.api.service.StaffApiService;
import com.gic.haoban.manage.service.config.Config; import com.gic.haoban.manage.service.config.Config;
import com.gic.haoban.manage.service.dao.mapper.StaffDepartmentRelatedMapper; import com.gic.haoban.manage.service.dao.mapper.StaffDepartmentRelatedMapper;
...@@ -112,6 +114,10 @@ public class StaffApiServiceImpl implements StaffApiService { ...@@ -112,6 +114,10 @@ public class StaffApiServiceImpl implements StaffApiService {
private GroupChatService groupChatService; private GroupChatService groupChatService;
@Autowired @Autowired
private WxEnterpriseRelatedService wxEnterpriseRelatedService; private WxEnterpriseRelatedService wxEnterpriseRelatedService;
@Autowired
private DealSyncOperationApiService dealSyncOperationApiService;
@Autowired
private ExternalClerkRelatedService externalClerkRelatedService;
@Override @Override
public StaffDTO selectById(String staffId) { public StaffDTO selectById(String staffId) {
...@@ -1167,4 +1173,35 @@ public class StaffApiServiceImpl implements StaffApiService { ...@@ -1167,4 +1173,35 @@ public class StaffApiServiceImpl implements StaffApiService {
List<TabHaobanWxEnterpriseRelated> list = wxEnterpriseRelatedService.getByWxEnterpriseId(wxEnterpriseId); List<TabHaobanWxEnterpriseRelated> list = wxEnterpriseRelatedService.getByWxEnterpriseId(wxEnterpriseId);
return com.gic.api.base.commons.ServiceResponse.success(com.gic.haoban.common.utils.EntityUtil.changeEntityListByJSON(WxEnterpriseRelatedDTO.class, list)); return com.gic.api.base.commons.ServiceResponse.success(com.gic.haoban.common.utils.EntityUtil.changeEntityListByJSON(WxEnterpriseRelatedDTO.class, list));
} }
@Override
public com.gic.api.base.commons.ServiceResponse<Boolean> updateExternalUserId(String params) {
if(StrUtil.isBlank(params)){
return com.gic.api.base.commons.ServiceResponse.failure("-9999","参数不能为空");
}
logger.info("定时刷新成员外部联系人开始,id参数:{}",params);
List<String> wxEnterpriseIdList = Arrays.asList(params.split(","));
String taskName = "刷新企业微信好友(定时处理)";
for (String wxEnterpriseId: wxEnterpriseIdList){
List<TabHaobanWxEnterpriseRelated> list = wxEnterpriseRelatedService.getByWxEnterpriseId(wxEnterpriseId);
//查询企业微信下面所有的品牌id
List<String> enterpriseIdList = list.stream().map(dto -> dto.getEnterpriseId()).collect(Collectors.toList());
//查询外部联系人id为空的成员id
List<String> staffIdList = externalClerkRelatedService.listByWxEnterpriseId(wxEnterpriseId, enterpriseIdList);
if (CollUtil.isNotEmpty(staffIdList)){
//去重
List<String> collect = staffIdList.stream().distinct().collect(Collectors.toList());
logger.info("需要刷新好友的企业微信id:{},staff成员列表:{}",wxEnterpriseId,JSON.toJSONString(collect));
for (String staffId : staffIdList){
String taskId = dealSyncOperationApiService.createWxFriendTaskSingle(wxEnterpriseId, taskName, staffId,
"刷新企业微信好友(定时任务处理)", SyncTaskTypeEnum.FRIEND_SINGLE.getType());
if (StringUtils.isNotBlank(taskId)) {
dealSyncOperationApiService.dealWxFriendClerkSingle(taskId, staffId, staffId, wxEnterpriseId);
}
}
}
}
logger.info("定时刷新成员外部联系人结束");
return com.gic.api.base.commons.ServiceResponse.success(true);
}
} }
...@@ -795,4 +795,17 @@ ...@@ -795,4 +795,17 @@
AND status_flag = 1 AND status_flag = 1
</select> </select>
<select id="listByWxEnterpriseId" resultType="java.lang.String">
select staff_id
from tab_haoban_external_clerk_related
WHERE
wx_enterprise_id = #{wxEnterpriseId}
AND enterprise_id IN
<foreach collection="enterpriseIdList" item="item" separator="," open="(" close=")">
#{item}
</foreach>
AND status_flag = 1
AND external_user_id IS NULL
</select>
</mapper> </mapper>
\ No newline at end of file
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