|
|
@@ -1,6 +1,5 @@
|
|
|
package com.uas.eis.serviceImpl;
|
|
|
|
|
|
-import com.alibaba.druid.util.HttpClientUtils;
|
|
|
import com.uas.eis.dao.BaseDao;
|
|
|
import com.uas.eis.dto.YongHResp;
|
|
|
import com.uas.eis.entity.Employee;
|
|
|
@@ -28,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;
|
|
|
@@ -37,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{
|
|
|
- del_count_failed++;
|
|
|
+ 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{
|
|
|
@@ -63,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,25 +81,37 @@ public class YongHService {
|
|
|
System.out.println(res);
|
|
|
YongHResp resp= FlexJsonUtil.fromJson(res, YongHResp.class);
|
|
|
if("1".equals(resp.getResults().getResult().getLevel())){
|
|
|
- baseDao.updateByCondition("employee","em_isyonghong=0,EM_YONGHONGID=''","em_code='"+employee.getEm_code()+"'");
|
|
|
- return true;
|
|
|
+ baseDao.updateByCondition("employee","em_yonghongsynced=0,em_isyonghong=0,EM_YONGHONGID=''","em_code='"+employee.getEm_code()+"'");
|
|
|
+ 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<>();
|
|
|
Map<String,Object> user = new HashMap<>();
|
|
|
- String name=PinyinUtils.getCustomPinyin(employee.getEm_name());
|
|
|
+ String name = PinyinUtils.getCustomPinyin(employee.getEm_name());
|
|
|
+ if(StringUtil.hasText(employee.getEm_yonghongid())){
|
|
|
+ name=employee.getEm_yonghongid();
|
|
|
+ }
|
|
|
user.put("name",name);
|
|
|
- user.put("pass",employee.getEm_password());
|
|
|
+ String initPWD = employee.getEm_password();
|
|
|
+ if(! StringUtil.hasText(initPWD) || initPWD.length() <8 || ! hasThreeCharacterTypes(initPWD)){
|
|
|
+ //初始密码拼音+系统账号+SI
|
|
|
+ initPWD = name+employee.getEm_code()+"SI";
|
|
|
+ }
|
|
|
+ user.put("pass",initPWD);
|
|
|
user.put("email",employee.getEm_email());
|
|
|
user.put("alias",employee.getEm_name());
|
|
|
user.put("parent","");
|
|
|
@@ -111,16 +127,25 @@ public class YongHService {
|
|
|
System.out.println(res);
|
|
|
YongHResp resp= FlexJsonUtil.fromJson(res, YongHResp.class);
|
|
|
if("1".equals(resp.getResults().getResult().getLevel())){
|
|
|
- baseDao.updateByCondition("employee","EM_YONGHONGID='"+name+"'","em_code='"+employee.getEm_code()+"'");
|
|
|
- return true;
|
|
|
+ baseDao.updateByCondition("employee","EM_YONGHONGID='"+name+"',em_yonghongsynced=-1","em_code='"+employee.getEm_code()+"'");
|
|
|
+ baseDao.execute("insert into UAPPROVALMSG(ID_,TYPE_,TITLE_,MSG_,EMS_) " +
|
|
|
+ "select UAPPROVALMSG_SEQ.NEXTVAL,'TEXT','永洪账号开通提醒','"+employee.getEm_name()+" 您的永洪报表平台账号已创建\n" +
|
|
|
+ "账号:"+name+
|
|
|
+ "初始密码:"+initPWD+"\n" +
|
|
|
+ "您也可以通过UAS系统首页-->右上角 永洪 进行SSO免密登录。',em_qywx" +
|
|
|
+ " from employee where em_code='"+employee.getEm_code()+"' and em_qywx is not null");
|
|
|
+ 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 {
|
|
|
@@ -165,6 +190,17 @@ public class YongHService {
|
|
|
}else{
|
|
|
logger.info("yonghong-logout-请求失败:{}",response.getResponseText());
|
|
|
}
|
|
|
-
|
|
|
+ }
|
|
|
+ public boolean hasThreeCharacterTypes(String password) {
|
|
|
+ int typeCount = 0;
|
|
|
+ // 检查是否包含大写字母
|
|
|
+ if (password.matches(".*[A-Z].*")) typeCount++;
|
|
|
+ // 检查是否包含小写字母
|
|
|
+ if (password.matches(".*[a-z].*")) typeCount++;
|
|
|
+ // 检查是否包含数字
|
|
|
+ if (password.matches(".*[0-9].*")) typeCount++;
|
|
|
+ // 检查是否包含特殊符号(非字母数字)
|
|
|
+ if (password.matches(".*[^A-Za-z0-9].*")) typeCount++;
|
|
|
+ return typeCount >= 3;
|
|
|
}
|
|
|
}
|