Commit ce2811a4 by fudahua

Merge branch 'feature-2024-09-23' into 'master'

Feature 2024 09 23

See merge request !2160
parents 76561474 9e20fcec
...@@ -545,46 +545,90 @@ public class DealSyncOperationApiServiceImpl implements DealSyncOperationApiServ ...@@ -545,46 +545,90 @@ public class DealSyncOperationApiServiceImpl implements DealSyncOperationApiServ
unlockTask(wxEnterpriseId); unlockTask(wxEnterpriseId);
return "没有配置secret"; return "没有配置secret";
} }
Map<String,Integer> map = CustomSwitcher.haoban_department_id ; Map<String,String> map = CustomSwitcher.haoban_department_id ;
int id = 1 ; int syncId = 1 ;
List<Integer> ids=new ArrayList<>();
if(null != map && null != map.get(wxEnterpriseId)) { if(null != map && null != map.get(wxEnterpriseId)) {
id = map.get(wxEnterpriseId) ; String rootIdsStr = map.get(wxEnterpriseId);
List<Integer> rootIds = Arrays.stream(rootIdsStr.split(",")).filter(mid -> mid != null).map(mid -> Integer.valueOf(mid)).collect(Collectors.toList());
if (CollectionUtils.isEmpty(rootIds)) {
logger.info("apollo部门配置异常");
return "同步部门配置异常";
}
ids.addAll(rootIds);
}else{
ids.add(syncId);
} }
logger.info("id={}",id); List<TabHaobanPreDealLog> dealLogList=new ArrayList<>();
List<com.gic.wechat.api.dto.qywx.DepartmentDTO> list = qywxDepartmentApiService.listSelfDepartment(qwDTO.getDkCorpid(), secretSetting.getSecretVal(), id,qwDTO.getUrlHost()); String rootPid="0";
if (CollectionUtils.isEmpty(list)) { if (ids.size()>1) {
logger.info("企微部门数量0,退出同步"); rootPid="-999";
syncTaskService.updateTaskStatus(taskId, SyncTaskStatusEnum.exception_close.getVal()); syncId=Integer.valueOf(rootPid);
unlockTask(wxEnterpriseId); TabHaobanPreDealLog dealLog = getRootDept(wxEnterpriseId,rootPid,taskId);
return "没有数据同步或权限没设置全部"; dealLogList.add(dealLog);
} }
logger.info("企微部门数={}",list.size()); for (Integer id: ids) {
final int _id = id ; logger.info("id={}",id);
syncTaskService.updateTaskStatus(taskId, SyncTaskStatusEnum.group_sync.getVal()); List<com.gic.wechat.api.dto.qywx.DepartmentDTO> list = qywxDepartmentApiService.listSelfDepartment(qwDTO.getDkCorpid(), secretSetting.getSecretVal(), id,qwDTO.getUrlHost());
List<TabHaobanPreDealLog> dealLogList = list.stream().map(dto -> { if (CollectionUtils.isEmpty(list)) {
TabHaobanPreDealLog dealLog = new TabHaobanPreDealLog(); logger.info("企微部门数量0,退出同步");
dealLog.setDataId(dto.getId().toString()); syncTaskService.updateTaskStatus(taskId, SyncTaskStatusEnum.exception_close.getVal());
if(dto.getId().toString().equals(_id+"")) { unlockTask(wxEnterpriseId);
dealLog.setpDataId("0"); return "没有数据同步或权限没设置全部";
dto.setParentid(0);
}else {
dealLog.setpDataId(dto.getParentid().toString());
} }
dealLog.setDataType(0); logger.info("企微部门数={}",list.size());
dealLog.setStatusFlag(0); final int _id = id ;
dealLog.setTaskId(taskId); syncTaskService.updateTaskStatus(taskId, SyncTaskStatusEnum.group_sync.getVal());
dealLog.setDataContent(JSONObject.toJSONString(dto)); String finalRootPid = rootPid;
dealLog.setWxEnterpriseId(wxEnterpriseId); List<TabHaobanPreDealLog> dealLogListMid = list.stream().map(dto -> {
return dealLog; TabHaobanPreDealLog dealLog = new TabHaobanPreDealLog();
}).collect(Collectors.toList()); dealLog.setDataId(dto.getId().toString());
if(dto.getId().toString().equals(_id+"")) {
dealLog.setpDataId(finalRootPid);
dto.setParentid(Integer.valueOf(finalRootPid));
}else {
dealLog.setpDataId(dto.getParentid().toString());
}
dealLog.setDataType(0);
dealLog.setStatusFlag(0);
dealLog.setTaskId(taskId);
dealLog.setDataContent(JSONObject.toJSONString(dto));
dealLog.setWxEnterpriseId(wxEnterpriseId);
return dealLog;
}).collect(Collectors.toList());
dealLogList.addAll(dealLogListMid);
}
// 保存部门数据 // 保存部门数据
preDealService.insert(dealLogList); preDealService.insert(dealLogList);
HashSet<String> hashSet = new HashSet<>(); HashSet<String> hashSet = new HashSet<>();
hashSet.add(""+id); hashSet.add(""+syncId);
sendToMq(taskId, hashSet, SyncTaskStatusEnum.group_sync,"departmentSyncDealMq2"); sendToMq(taskId, hashSet, SyncTaskStatusEnum.group_sync,"departmentSyncDealMq2");
return null; return null;
} }
private TabHaobanPreDealLog getRootDept(String wxEnterpriseId,String rootPid,String taskId) {
WxEnterpriseDTO wxEnterpriseDTO = this.wxEnterpriseService.selectById(wxEnterpriseId);
com.gic.wechat.api.dto.qywx.DepartmentDTO departmentDTO = new com.gic.wechat.api.dto.qywx.DepartmentDTO();
departmentDTO.setName(wxEnterpriseDTO.getCorpName());
departmentDTO.setParentid(0);
departmentDTO.setOrder(0L);
departmentDTO.setId(Integer.valueOf(rootPid));
departmentDTO.setCorpid("");
TabHaobanPreDealLog dealLog = new TabHaobanPreDealLog();
dealLog.setDataId(rootPid);
dealLog.setpDataId("0");
dealLog.setDataType(0);
dealLog.setStatusFlag(0);
dealLog.setTaskId(taskId);
dealLog.setDataContent(JSONObject.toJSONString(departmentDTO));
dealLog.setWxEnterpriseId(wxEnterpriseId);
return dealLog;
}
@Override @Override
public void cleanDiffrence(String wxEnterpriseId, String taskId) { public void cleanDiffrence(String wxEnterpriseId, String taskId) {
......
package com.gic.haoban.manage.service.task; package com.gic.haoban.manage.service.task;
import java.util.List; import java.util.*;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import com.gic.haoban.manage.api.service.DealSyncOperationApiService; import com.gic.haoban.manage.api.service.DealSyncOperationApiService;
...@@ -179,11 +177,12 @@ public class QywxDeptSyncOperation implements BaseSyncOperation { ...@@ -179,11 +177,12 @@ public class QywxDeptSyncOperation implements BaseSyncOperation {
private String getStaff(String taskId, String dataId, String enterpriseId, String wxEnterpriseId,SecretSettingDTO secretSetting,WxEnterpriseQwDTO qwDTO) { private String getStaff(String taskId, String dataId, String enterpriseId, String wxEnterpriseId,SecretSettingDTO secretSetting,WxEnterpriseQwDTO qwDTO) {
logger.info("getstaff={}",dataId); logger.info("getstaff={}",dataId);
String id = "1" ; String id = "1" ;
Map<String,Integer> map = CustomSwitcher.haoban_department_id ; Map<String,String> map = CustomSwitcher.haoban_department_id ;
if(null != map && null != map.get(wxEnterpriseId)) { if(null != map && null != map.get(wxEnterpriseId)) {
id = map.get(wxEnterpriseId) +"" ; id = map.get(wxEnterpriseId) ;
} }
if(id.equals(dataId)) { List<String> ids = Arrays.stream(id.split(",")).collect(Collectors.toList());
if(ids.contains(dataId)) {
List<UserDTO> list = null ; List<UserDTO> list = null ;
if(qwDTO.getWxSecurityType()==4) { if(qwDTO.getWxSecurityType()==4) {
list = this.qywxUserApiService.listDepartmentUser(qwDTO.getThirdCorpid(), config.getWxSuiteid(), dataId, 1) ; list = this.qywxUserApiService.listDepartmentUser(qwDTO.getThirdCorpid(), config.getWxSuiteid(), dataId, 1) ;
......
...@@ -21,6 +21,6 @@ public class CustomSwitcher { ...@@ -21,6 +21,6 @@ public class CustomSwitcher {
public static String haoban_one_bind_many ; public static String haoban_one_bind_many ;
@Switcher @Switcher
public static Map<String,Integer> haoban_department_id ; public static Map<String,String> haoban_department_id ;
} }
\ 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