|
@@ -1,5 +1,6 @@
|
|
|
package com.kingdee.eas.custom.task;
|
|
|
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
import com.gemdale.gdgateway.util.MD5Utils;
|
|
@@ -7,7 +8,6 @@ import com.kingdee.eas.base.permission.UserCollection;
|
|
|
import com.kingdee.eas.base.permission.UserFactory;
|
|
|
import com.kingdee.eas.base.permission.UserInfo;
|
|
|
import com.kingdee.eas.basedata.person.PersonInfo;
|
|
|
-import com.kingdee.eas.custom.task.vo.EmpInfo;
|
|
|
import com.kingdee.eas.util.app.DbUtil;
|
|
|
import com.kingdee.util.DateTimeUtils;
|
|
|
import com.kingdee.util.StringUtils;
|
|
@@ -25,7 +25,7 @@ import java.util.*;
|
|
|
|
|
|
public class SyncZYEmpFacadeControllerBean extends AbstractSyncZYEmpFacadeControllerBean {
|
|
|
private static String propertiesUrl = System.getProperty("EAS_HOME") + "/server/properties/Api/propertie.properties";
|
|
|
- private List<EmpInfo> empInfoList = new ArrayList<>();
|
|
|
+ private List empInfoList = new ArrayList<>();
|
|
|
private static Logger logger = Logger.getLogger(SyncZYEmpFacadeControllerBean.class);
|
|
|
private int pageSize = 100;
|
|
|
|
|
@@ -61,7 +61,7 @@ public class SyncZYEmpFacadeControllerBean extends AbstractSyncZYEmpFacadeContro
|
|
|
private void updateUserInfo(Context ctx) throws BOSException {
|
|
|
try {
|
|
|
ObjectMapper objectMapper = new ObjectMapper();
|
|
|
- UserCollection userCollection = UserFactory.getLocalInstance(ctx).getUserCollection("select id,person.*");
|
|
|
+ UserCollection userCollection = UserFactory.getLocalInstance(ctx).getUserCollection("select id,person.* where person is not null");
|
|
|
Map<String, String> idCardNoMap = new HashMap<>();
|
|
|
Map<String, String> passportNoMap = new HashMap<>();
|
|
|
Map<String, String> emailMap = new HashMap<>();
|
|
@@ -88,15 +88,15 @@ public class SyncZYEmpFacadeControllerBean extends AbstractSyncZYEmpFacadeContro
|
|
|
List<Object[]> updateParams = new ArrayList<>();
|
|
|
for (int i = 0; i < empInfoList.size(); i++) {
|
|
|
//首先匹配身份证或护照号,再匹配邮箱
|
|
|
- EmpInfo empInfo = empInfoList.get(i);
|
|
|
+ Map<String, Object> empInfo = (Map<String, Object>) empInfoList.get(i);
|
|
|
//账号
|
|
|
- String username = empInfo.getUsername();
|
|
|
- String email = empInfo.getEmail();
|
|
|
- String cardType = empInfo.getCardType();
|
|
|
- String cardNum = empInfo.getCardNum();
|
|
|
+ String username = (String) empInfo.get("username");
|
|
|
+ String email = (String) empInfo.get("email");
|
|
|
+ String cardType = (String) empInfo.get("cardType");
|
|
|
+ String cardNum = (String) empInfo.get("cardNum");
|
|
|
String userId = null;
|
|
|
- if (!StringUtils.isEmpty(cardNum)) {
|
|
|
- if ("大陆地区身份证".equals(cardType)) {
|
|
|
+ if (!StringUtils.isEmpty(cardNum) && "null".equals(cardNum)) {
|
|
|
+ if (!StringUtils.isEmpty(cardType) && cardType.contains("身份证")) {
|
|
|
userId = idCardNoMap.get(cardNum);
|
|
|
} else {
|
|
|
userId = passportNoMap.get(cardNum);
|
|
@@ -307,9 +307,9 @@ public class SyncZYEmpFacadeControllerBean extends AbstractSyncZYEmpFacadeContro
|
|
|
Boolean success = (Boolean) result.get("success");
|
|
|
logger.error("查询用户数据: " + resultStr);
|
|
|
if (success) {
|
|
|
- String data = (String) result.get("data");
|
|
|
- EmpInfo empInfo = objectMapper.readValue(data, EmpInfo.class);
|
|
|
- empInfoList.add(empInfo);
|
|
|
+ List data = (List) result.get("data");
|
|
|
+ //EmpInfo empInfo = objectMapper.readValue(data, EmpInfo.class);
|
|
|
+ empInfoList.addAll(data);
|
|
|
} else {
|
|
|
String msg = (String) result.get("msg");
|
|
|
throw new BOSException(msg);
|
|
@@ -325,4 +325,107 @@ public class SyncZYEmpFacadeControllerBean extends AbstractSyncZYEmpFacadeContro
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+//
|
|
|
+// public static void main(String[] args) throws IOException, BOSException {
|
|
|
+// OkHttpClient client = new OkHttpClient();
|
|
|
+// ObjectMapper objectMapper = new ObjectMapper();
|
|
|
+// Map<String, String> idCardNoMap = new HashMap<>();
|
|
|
+// idCardNoMap.put("2342", "111");
|
|
|
+// Map<String, String> passportNoMap = new HashMap<>();
|
|
|
+// passportNoMap.put("234123", "111");
|
|
|
+// Map<String, String> emailMap = new HashMap<>();
|
|
|
+// emailMap.put("liucanyu1@gemdale.com", "111");
|
|
|
+//
|
|
|
+//
|
|
|
+// int total = 0;
|
|
|
+// JSONObject content = new JSONObject();
|
|
|
+// content.put("containslnvalid", false);//是否包含失效用户
|
|
|
+// String contentStr = content.toJSONString();
|
|
|
+// RequestBody body = RequestBody.create(MediaType.parse("application/json"), contentStr);
|
|
|
+//
|
|
|
+// Request request = new Request.Builder()
|
|
|
+// .url("https://api-test.gemdale.com/openApi/organization-center/emp/getEmpCount")
|
|
|
+// .post(body)
|
|
|
+// .addHeader("x-ca-key", "1838882415880818690")
|
|
|
+// .addHeader("x-ca-signature", "+fCDx073OeZDGPalliiigQ==")
|
|
|
+// .addHeader("x-ca-signature-method", "MD5")
|
|
|
+// .addHeader("content-type", "application/json")
|
|
|
+// .build();
|
|
|
+// Response response = client.newCall(request).execute();
|
|
|
+// if (response.isSuccessful()) {
|
|
|
+// Map result = objectMapper.readValue(response.body().string(), Map.class);
|
|
|
+// Boolean success = (Boolean) result.get("success");
|
|
|
+// if (success) {
|
|
|
+// total = (int) result.get("total");
|
|
|
+// } else {
|
|
|
+// String msg = (String) result.get("msg");
|
|
|
+// throw new BOSException(msg);
|
|
|
+// }
|
|
|
+// } else {
|
|
|
+// throw new BOSException("请求失败");
|
|
|
+// }
|
|
|
+// System.out.println("total: " + total);
|
|
|
+// boolean flag = true;
|
|
|
+// int pageCount = total % 100 == 0 ? total / 100 : total / 100 + 1;
|
|
|
+// for (int page = 1; page <= pageCount && flag; page++) {
|
|
|
+// content = new JSONObject();
|
|
|
+// content.put("containslnvalid", false);//是否包含失效用户
|
|
|
+// content.put("pageSize", 100);
|
|
|
+// content.put("pageNum", page);
|
|
|
+// body = RequestBody.create(MediaType.parse("application/json"), content.toJSONString());
|
|
|
+// System.out.println("page: " + page);
|
|
|
+//
|
|
|
+// request = new Request.Builder()
|
|
|
+// .url("https://api-test.gemdale.com/openApi/organization-center/emp/getEmp")
|
|
|
+// .post(body)
|
|
|
+// .addHeader("x-ca-key", "1838882415880818690")
|
|
|
+// .addHeader("x-ca-signature", "KvB3twvz5cYyffJlvZQo8Q==")
|
|
|
+// .addHeader("x-ca-signature-method", "MD5")
|
|
|
+// .addHeader("content-type", "application/json")
|
|
|
+// .build();
|
|
|
+// response = client.newCall(request).execute();
|
|
|
+// if (response.isSuccessful()) {
|
|
|
+// String resultStr = response.body().string();
|
|
|
+// Map result = objectMapper.readValue(resultStr, Map.class);
|
|
|
+// Boolean success = (Boolean) result.get("success");
|
|
|
+// logger.error("查询用户数据: " + resultStr);
|
|
|
+// if (success) {
|
|
|
+// List data = (List) result.get("data");
|
|
|
+// for (int i = 0; i < data.size() && flag; i++) {
|
|
|
+// Map<String, Object> map = (Map<String, Object>) data.get(i);
|
|
|
+// String username = (String) map.get("username");
|
|
|
+// if ("liucanyu1".equals(username)) {
|
|
|
+// System.out.println("username: " + username);
|
|
|
+// String cardType = (String) map.get("cardType");
|
|
|
+// System.out.println("cardType: " + cardType);
|
|
|
+// String cardNum = (String) map.get("cardNum");
|
|
|
+// System.out.println("cardNum: " + cardNum);
|
|
|
+// if (!StringUtils.isEmpty(cardNum)) {
|
|
|
+// System.out.println("cardNum: " + cardNum);
|
|
|
+// }
|
|
|
+// String email = (String) map.get("email");
|
|
|
+// System.out.println("email: " + email);
|
|
|
+// String userId = null;
|
|
|
+// if (!StringUtils.isEmpty(cardNum)) {
|
|
|
+// if (!StringUtils.isEmpty(cardType) && cardType.contains("身份证")) {
|
|
|
+// userId = idCardNoMap.get(cardNum);
|
|
|
+// } else {
|
|
|
+// userId = passportNoMap.get(cardNum);
|
|
|
+// }
|
|
|
+// } else {
|
|
|
+// userId = emailMap.get(email);
|
|
|
+// }
|
|
|
+// System.out.println("userId: " + userId);
|
|
|
+// flag = false;
|
|
|
+// }
|
|
|
+// }
|
|
|
+// } else {
|
|
|
+// String msg = (String) result.get("msg");
|
|
|
+// throw new BOSException(msg);
|
|
|
+// }
|
|
|
+// } else {
|
|
|
+// throw new BOSException("请求失败");
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
}
|