|
|
@@ -27,6 +27,7 @@ public class YongHService {
|
|
|
|
|
|
public Map<String, Object> syncEmployee() throws Exception {
|
|
|
Map<String, Object> modelMap = new HashMap<String, Object>();
|
|
|
+ StringBuffer errorMsg = new StringBuffer();
|
|
|
//获取token
|
|
|
String token=getToken();
|
|
|
int add_count_success=0;
|
|
|
@@ -36,24 +37,27 @@ public class YongHService {
|
|
|
if(StringUtil.hasText(token)){
|
|
|
List<Employee> employeeDel = uasSyncService.getYongHDelUserList();
|
|
|
for (Employee employee : employeeDel) {
|
|
|
- boolean bool1=delYongHAccount(token,employee);
|
|
|
- if(bool1){
|
|
|
+ Map<String, Object> map = delYongHAccount(token,employee);
|
|
|
+ if(String.valueOf(map.get("success")).equals("true")){
|
|
|
del_count_success++;
|
|
|
}else{
|
|
|
del_count_failed++;
|
|
|
+ errorMsg.append(map.get("info").toString() +" | ");
|
|
|
}
|
|
|
}
|
|
|
List<Employee> employeeAdd = uasSyncService.getYongHAddUserList();
|
|
|
for (Employee employee : employeeAdd) {
|
|
|
- boolean bool2=addYongHAccount(token,employee);
|
|
|
- if(bool2){
|
|
|
+ Map<String, Object> map = addYongHAccount(token,employee);
|
|
|
+ if(String.valueOf(map.get("success")).equals("true")){
|
|
|
add_count_success++;
|
|
|
}else{
|
|
|
add_count_failed++;
|
|
|
+ errorMsg.append(map.get("info").toString() +" | ");
|
|
|
}
|
|
|
}
|
|
|
String message="添加成功:"+add_count_success+",添加失败:"+add_count_failed+",删除成功:"+del_count_success+",删除失败:"+del_count_failed;
|
|
|
modelMap.put("message", message);
|
|
|
+ modelMap.put("err", errorMsg.toString());
|
|
|
modelMap.put("success", true);
|
|
|
logout(token);
|
|
|
}else{
|
|
|
@@ -62,7 +66,8 @@ public class YongHService {
|
|
|
}
|
|
|
return modelMap;
|
|
|
}
|
|
|
- private boolean delYongHAccount(String token,Employee employee) throws Exception {
|
|
|
+ private Map<String, Object> delYongHAccount(String token,Employee employee) throws Exception {
|
|
|
+ Map<String, Object> map = new HashMap<String, Object>();
|
|
|
String action="http://172.16.0.207:8081/bi/api?action=delNode&token="+token;
|
|
|
Map<String,Object> xmlData = new HashMap<>();
|
|
|
Map<String,Object> user = new HashMap<>();
|
|
|
@@ -77,17 +82,21 @@ public class YongHService {
|
|
|
YongHResp resp= FlexJsonUtil.fromJson(res, YongHResp.class);
|
|
|
if("1".equals(resp.getResults().getResult().getLevel())){
|
|
|
baseDao.updateByCondition("employee","em_yonghongsynced=0,em_isyonghong=0,EM_YONGHONGID=''","em_code='"+employee.getEm_code()+"'");
|
|
|
- return true;
|
|
|
+ map.put("success",true);
|
|
|
}else{
|
|
|
logger.info("yonghong删除用户失败,token:{},message:{}",token,resp.getResults().getResult().getMessage());
|
|
|
- return false;
|
|
|
+ map.put("success",false);
|
|
|
+ map.put("info",employee.getEm_code()+":"+resp.getResults().getResult().getMessage());
|
|
|
}
|
|
|
}else{
|
|
|
logger.info("yonghong删除用户请求失败:{}",response.getResponseText());
|
|
|
- return false;
|
|
|
+ map.put("success",false);
|
|
|
+ map.put("info",employee.getEm_code()+":删除永洪账户请求失败!");
|
|
|
}
|
|
|
+ return map;
|
|
|
}
|
|
|
- private boolean addYongHAccount(String token,Employee employee) throws Exception {
|
|
|
+ private Map<String, Object> addYongHAccount(String token,Employee employee) throws Exception {
|
|
|
+ Map<String, Object> map = new HashMap<String, Object>();
|
|
|
String action="http://172.16.0.207:8081/bi/api?action=saveNode&type=user&token="+token;
|
|
|
Map<String,Object> xmlData = new HashMap<>();
|
|
|
Map<String,Object> info = new HashMap<>();
|
|
|
@@ -125,15 +134,18 @@ public class YongHService {
|
|
|
"初始密码:"+initPWD+"\n" +
|
|
|
"您也可以通过UAS系统首页-->右上角 永洪 进行SSO免密登录。',em_qywx" +
|
|
|
" from employee where em_code='"+employee.getEm_code()+"' and em_qywx is not null");
|
|
|
- return true;
|
|
|
+ map.put("success",true);
|
|
|
}else{
|
|
|
logger.info("yonghong添加用户失败,token:{},message:{}",token,resp.getResults().getResult().getMessage());
|
|
|
- return false;
|
|
|
+ map.put("success",false);
|
|
|
+ map.put("info",employee.getEm_code()+":"+resp.getResults().getResult().getMessage());
|
|
|
}
|
|
|
}else{
|
|
|
logger.info("yonghong添加用户请求失败:{}",response.getResponseText());
|
|
|
- return false;
|
|
|
+ map.put("success",false);
|
|
|
+ map.put("info",employee.getEm_code()+":开通永洪账户请求失败!");
|
|
|
}
|
|
|
+ return map;
|
|
|
}
|
|
|
|
|
|
private String getToken() throws Exception {
|