|
@@ -14,6 +14,8 @@ import org.apache.http.client.methods.HttpGet;
|
|
|
import org.apache.http.impl.client.CloseableHttpClient;
|
|
|
import org.apache.http.impl.client.HttpClients;
|
|
|
import org.apache.http.util.EntityUtils;
|
|
|
+import org.slf4j.Logger;
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.scheduling.annotation.Scheduled;
|
|
|
import org.springframework.stereotype.Service;
|
|
@@ -29,6 +31,7 @@ import java.util.*;
|
|
|
*/
|
|
|
@Service
|
|
|
public class SsoSyncService {
|
|
|
+ private static final Logger logger = LoggerFactory.getLogger(SsoSyncService.class);
|
|
|
|
|
|
@Autowired
|
|
|
private SysDeptService sysDeptService;
|
|
@@ -54,30 +57,40 @@ public class SsoSyncService {
|
|
|
if (StringUtils.isNotEmpty(ssoDeptDto.getPARENT_ID())){//有父节点
|
|
|
Dept parenDept = sysDeptService.findDeptByOrgId(ssoDeptDto.getPARENT_ID());
|
|
|
if (Objects.nonNull(parenDept)){//父节点在系统不为空,无父节点不同步,等下一批次
|
|
|
- if (ssoDeptDto.getPARENT_ID().equals("515959718506717184")&&ssoDeptDto.getORG_ID().equals("515959718884204544")){//应急局下,只增加直属单位
|
|
|
- if (Objects.isNull(dept)){//部门不存在,部门存在不做处理
|
|
|
- newDept.setDeptId(orgId);
|
|
|
- newDept.setDeptIndex(3);
|
|
|
- newDept.setDeptName(ssoDeptDto.getORG_NAME());
|
|
|
- newDept.setParent(parenDept);
|
|
|
- newDept.setUpdateTime(new Date(ssoDeptDto.getUPDATE_TIME()));
|
|
|
- newDept.setPdeptids(parenDept.getPdeptids()+","+orgId);
|
|
|
- newDept.setOrgId(orgId);
|
|
|
- sysDeptService.saveAndUpdateDeptInfo(newDept);
|
|
|
- }
|
|
|
+ if (Objects.isNull(dept)){//部门不存在,部门存在不做处理
|
|
|
+ newDept.setDeptId(orgId);
|
|
|
+ newDept.setDeptIndex(3);
|
|
|
+ newDept.setDeptName(ssoDeptDto.getORG_NAME());
|
|
|
+ newDept.setParent(parenDept);
|
|
|
+ newDept.setUpdateTime(new Date(ssoDeptDto.getUPDATE_TIME()));
|
|
|
+ newDept.setPdeptids(parenDept.getPdeptids()+","+orgId);
|
|
|
+ newDept.setOrgId(orgId);
|
|
|
+ sysDeptService.saveAndUpdateDeptInfo(newDept);
|
|
|
}
|
|
|
- if (!ssoDeptDto.getPARENT_ID().equals("515959718506717184")){
|
|
|
- if (Objects.isNull(dept)){//部门不存在,部门存在不做处理
|
|
|
- newDept.setDeptId(orgId);
|
|
|
- newDept.setDeptIndex(3);
|
|
|
- newDept.setDeptName(ssoDeptDto.getORG_NAME());
|
|
|
- newDept.setParent(parenDept);
|
|
|
- newDept.setUpdateTime(new Date(ssoDeptDto.getUPDATE_TIME()));
|
|
|
- newDept.setPdeptids(parenDept.getPdeptids()+","+orgId);
|
|
|
- newDept.setOrgId(orgId);
|
|
|
+// if (ssoDeptDto.getPARENT_ID().equals("515959718506717184")&&ssoDeptDto.getORG_ID().equals("515959718884204544")){//应急局下,只增加直属单位
|
|
|
+// if (Objects.isNull(dept)){//部门不存在,部门存在不做处理
|
|
|
+// newDept.setDeptId(orgId);
|
|
|
+// newDept.setDeptIndex(3);
|
|
|
+// newDept.setDeptName(ssoDeptDto.getORG_NAME());
|
|
|
+// newDept.setParent(parenDept);
|
|
|
+// newDept.setUpdateTime(new Date(ssoDeptDto.getUPDATE_TIME()));
|
|
|
+// newDept.setPdeptids(parenDept.getPdeptids()+","+orgId);
|
|
|
+// newDept.setOrgId(orgId);
|
|
|
sysDeptService.saveAndUpdateDeptInfo(newDept);
|
|
|
- }
|
|
|
- }
|
|
|
+// }
|
|
|
+// }
|
|
|
+// if (!ssoDeptDto.getPARENT_ID().equals("515959718506717184")){
|
|
|
+// if (Objects.isNull(dept)){//部门不存在,部门存在不做处理
|
|
|
+// newDept.setDeptId(orgId);
|
|
|
+// newDept.setDeptIndex(3);
|
|
|
+// newDept.setDeptName(ssoDeptDto.getORG_NAME());
|
|
|
+// newDept.setParent(parenDept);
|
|
|
+// newDept.setUpdateTime(new Date(ssoDeptDto.getUPDATE_TIME()));
|
|
|
+// newDept.setPdeptids(parenDept.getPdeptids()+","+orgId);
|
|
|
+// newDept.setOrgId(orgId);
|
|
|
+// sysDeptService.saveAndUpdateDeptInfo(newDept);
|
|
|
+// }
|
|
|
+// }
|
|
|
|
|
|
|
|
|
}
|
|
@@ -123,16 +136,18 @@ public class SsoSyncService {
|
|
|
dbdcUserService.insertRoleUser(roleUserPK);
|
|
|
dbdcUserService.saveDeptUser(dept.getDeptId(),ssoUserDto.getUSER_ID());
|
|
|
}
|
|
|
- }else {
|
|
|
- if (Objects.nonNull(dept)){
|
|
|
- userDto.setDeptid(dept.getDeptId());
|
|
|
- userDto.setPdeptids(dept.getPdeptids());
|
|
|
- dbdcUserService.updateUser(userDto);
|
|
|
- dbdcUserService.saveDeptUser(dept.getDeptId(),ssoUserDto.getUSER_ID());
|
|
|
- }
|
|
|
}
|
|
|
+// else {
|
|
|
+// if (Objects.nonNull(dept)){
|
|
|
+// userDto.setDeptid(dept.getDeptId());
|
|
|
+// userDto.setPdeptids(dept.getPdeptids());
|
|
|
+// dbdcUserService.updateUser(userDto);
|
|
|
+// dbdcUserService.saveDeptUser(dept.getDeptId(),ssoUserDto.getUSER_ID());
|
|
|
+// }
|
|
|
+// }
|
|
|
}
|
|
|
}
|
|
|
+ logger.info("用户同步完毕");
|
|
|
}
|
|
|
|
|
|
public List<SsoDeptDto> getSsoDept(){
|
|
@@ -184,7 +199,7 @@ public class SsoSyncService {
|
|
|
|
|
|
public static void main(String args[]){
|
|
|
SsoSyncService ssoSyncService= new SsoSyncService();
|
|
|
- ssoSyncService.syncUser();
|
|
|
+ ssoSyncService.syncDept();
|
|
|
}
|
|
|
|
|
|
|