|
@@ -12,6 +12,10 @@ import com.kingdee.bos.metadata.entity.FilterItemInfo;
|
|
|
import com.kingdee.bos.metadata.entity.SelectorItemInfo;
|
|
|
import com.kingdee.bos.metadata.query.util.CompareType;
|
|
|
import com.kingdee.eas.base.permission.UserInfo;
|
|
|
+import com.kingdee.eas.basedata.person.IPerson;
|
|
|
+import com.kingdee.eas.basedata.person.PersonCollection;
|
|
|
+import com.kingdee.eas.basedata.person.PersonFactory;
|
|
|
+import com.kingdee.eas.basedata.person.PersonInfo;
|
|
|
import com.kingdee.eas.common.EASBizException;
|
|
|
import com.kingdee.eas.custom.log.ISyncLog;
|
|
|
import com.kingdee.eas.custom.log.SyncLogFactory;
|
|
@@ -20,23 +24,18 @@ import com.kingdee.eas.custom.log.app.DataDirectionEnum;
|
|
|
import com.kingdee.eas.custom.log.app.DockingSystemEnum;
|
|
|
import com.kingdee.eas.custom.log.app.SyncEntityNameEnum;
|
|
|
import com.kingdee.eas.custom.log.app.SyncStatusEnum;
|
|
|
-import com.kingdee.eas.custom.sso.ExpiringMapCache;
|
|
|
import com.kingdee.eas.custom.synctask.utils.HRTimeWebUtils;
|
|
|
import com.kingdee.eas.framework.CoreBaseCollection;
|
|
|
import com.kingdee.eas.hr.ats.*;
|
|
|
import com.kingdee.eas.utils.EncryptUtils;
|
|
|
+import com.kingdee.eas.utils.ExpiringMapCache;
|
|
|
import com.kingdee.util.StringUtils;
|
|
|
import okhttp3.*;
|
|
|
import org.apache.log4j.Logger;
|
|
|
-import org.springframework.ui.ModelMap;
|
|
|
-
|
|
|
-import javax.servlet.http.HttpServletRequest;
|
|
|
-import javax.servlet.http.HttpServletResponse;
|
|
|
import java.io.FileInputStream;
|
|
|
import java.io.IOException;
|
|
|
import java.sql.*;
|
|
|
import java.sql.Connection;
|
|
|
-import java.text.ParseException;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.*;
|
|
|
import java.util.Date;
|
|
@@ -58,6 +57,7 @@ public class SyncTranForMJFacadeControllerBean extends AbstractSyncTranForMJFaca
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
/**
|
|
|
* 同步门禁打卡记录
|
|
|
*
|
|
@@ -68,6 +68,7 @@ public class SyncTranForMJFacadeControllerBean extends AbstractSyncTranForMJFaca
|
|
|
*/
|
|
|
@Override
|
|
|
protected void _syncAccessRecord(Context ctx, String startDate, String endDate) throws BOSException {
|
|
|
+ logger.error("_syncAccessRecord------");
|
|
|
Properties properties = new Properties();
|
|
|
properties.put("version", propt.getProperty("version"));
|
|
|
properties.put("tenantCode", propt.getProperty("tenantCode"));//租户编号,平台提供
|
|
@@ -76,18 +77,22 @@ public class SyncTranForMJFacadeControllerBean extends AbstractSyncTranForMJFaca
|
|
|
properties.put("account", propt.getProperty("account"));//接口账号
|
|
|
properties.put("password", propt.getProperty("password"));//接口账号密码
|
|
|
properties.put("getTokenPath", propt.getProperty("getTokenPath"));//获取token接口地址
|
|
|
-
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
|
|
|
try {
|
|
|
JSONObject params = new JSONObject();
|
|
|
params.put("count", "100");
|
|
|
- SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
//获取前三天数据
|
|
|
Calendar calendar = Calendar.getInstance();
|
|
|
calendar.add(Calendar.DAY_OF_YEAR, -3);
|
|
|
Date threeDaysAgoDate = calendar.getTime();
|
|
|
- //Date parse = sdf.parse("2022-01-01");
|
|
|
- params.put("rowTimeStamp", threeDaysAgoDate.getTime());
|
|
|
+ if(StringUtils.isEmpty(startDate)){
|
|
|
+ //Date parse = sdf.parse("2022-01-01");
|
|
|
+ params.put("rowTimeStamp", threeDaysAgoDate.getTime());
|
|
|
+ }else{
|
|
|
+ Date parse = sdf.parse(startDate);
|
|
|
+ params.put("rowTimeStamp", parse.getTime());
|
|
|
+ }
|
|
|
String payload = params.toJSONString();
|
|
|
Map<String, String> headers = getHeader(payload, false);
|
|
|
|
|
@@ -103,18 +108,31 @@ public class SyncTranForMJFacadeControllerBean extends AbstractSyncTranForMJFaca
|
|
|
requestBuilder.header(header.getKey(), header.getValue());
|
|
|
}
|
|
|
Response response = client.newCall(requestBuilder.build()).execute();
|
|
|
+ logger.error("response----" + response.isSuccessful());
|
|
|
if (response.isSuccessful()) {
|
|
|
//重置token,每次调用接口后刷新token
|
|
|
resetToken();
|
|
|
ObjectMapper mapper = new ObjectMapper();
|
|
|
- Map<String, Object> result = mapper.readValue(response.body().string(), Map.class);
|
|
|
- if (result.get("code").equals("0")) {
|
|
|
- JSONArray jsonArray = JSONArray.parseArray(result.get("data").toString());
|
|
|
+ String resultBody = response.body().string();
|
|
|
+ logger.error("resultBody----" + resultBody);
|
|
|
+ JSONObject result = JSONObject.parseObject(resultBody);
|
|
|
+ logger.error("respMap----" + result);
|
|
|
+ if (result.get("code").equals("0") || Integer.parseInt(result.get("code").toString()) == 0) {
|
|
|
+ String data = result.get("data").toString();
|
|
|
+ JSONArray jsonArray = JSONArray.parseArray(data);
|
|
|
logger.error("jsonArray---" + jsonArray.toString());
|
|
|
+ logger.error("jsonArray---" + jsonArray.size());
|
|
|
+ IPerson iPerson = PersonFactory.getLocalInstance(ctx);
|
|
|
+ PersonCollection personCollection = iPerson.getPersonCollection("select number ");
|
|
|
+ Set set = new HashSet();
|
|
|
+ for (int i = 0; i < personCollection.size(); i++) {
|
|
|
+ PersonInfo personInfo = personCollection.get(i);
|
|
|
+ set.add(personInfo.getNumber().toString());
|
|
|
+ }
|
|
|
for (int i = 0; i < jsonArray.size(); i++) {
|
|
|
JSONObject resultData = jsonArray.getJSONObject(i);
|
|
|
//保存门禁打卡记录
|
|
|
- saveMJPunchCardData(ctx, resultData);
|
|
|
+ saveMJPunchCardData(ctx, resultData, set);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -130,8 +148,10 @@ public class SyncTranForMJFacadeControllerBean extends AbstractSyncTranForMJFaca
|
|
|
* @param ctx
|
|
|
* @param resultData
|
|
|
*/
|
|
|
- public void saveMJPunchCardData(Context ctx, JSONObject resultData) {
|
|
|
+ public void saveMJPunchCardData(Context ctx, JSONObject resultData, Set set) {
|
|
|
+ logger.error("saveMJPunchCardData----");
|
|
|
try {
|
|
|
+
|
|
|
int success = 0;
|
|
|
int error = 0;
|
|
|
Set<String> setCardId = new HashSet();
|
|
@@ -155,8 +175,12 @@ public class SyncTranForMJFacadeControllerBean extends AbstractSyncTranForMJFaca
|
|
|
//String EquNo = resultSet.getString("EquNo"); //考勤机编码
|
|
|
//String exceptionType = resultSet.getString("EquNo"); // 打卡/异常类型
|
|
|
//Date punchDate = HRTimeWebUtils.stringToShortDate(RecDate, true);
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssXXX");
|
|
|
+ SimpleDateFormat sdfymd = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
+ Date date = sdf.parse(punchCardDate);
|
|
|
+ String format = sdfymd.format(date);
|
|
|
Date punchDate = com.kingdee.eas.custom.synctask.utils.HRTimeWebUtils.stringToShortDate(RecDate, true);
|
|
|
- Timestamp punchCardTime = com.kingdee.eas.custom.synctask.utils.HRTimeWebUtils.stringToTimestamp(punchCardDate, true);
|
|
|
+ Timestamp punchCardTime = com.kingdee.eas.custom.synctask.utils.HRTimeWebUtils.stringToTimestamp(format ,true);
|
|
|
// 处理数据
|
|
|
if (punchCardDate != null && punchCardTime != null) {
|
|
|
PunchCardRecordInfo cardInfo = new PunchCardRecordInfo();
|
|
@@ -183,10 +207,13 @@ public class SyncTranForMJFacadeControllerBean extends AbstractSyncTranForMJFaca
|
|
|
////简称
|
|
|
//cardInfo.setSimpleName(exceptionType);
|
|
|
//描述
|
|
|
- //cardInfo.setDescription(exceptionType);
|
|
|
+ cardInfo.setDescription("门禁打卡机");
|
|
|
|
|
|
EquNoSet.add("001");
|
|
|
if (!StringUtils.isEmpty(personNumber)) {
|
|
|
+ if (!set.contains(personNumber)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
setCardId.add(personNumber);
|
|
|
cardColl.add(cardInfo);
|
|
|
}
|
|
@@ -208,6 +235,7 @@ public class SyncTranForMJFacadeControllerBean extends AbstractSyncTranForMJFaca
|
|
|
// 考勤档案
|
|
|
Map<String, AttendanceFileInfo> attendanceFileMap = AttendanceFileFactory.getLocalInstance(ctx).getPersonByAttendanceNum(setCardId);
|
|
|
logger.error("attendanceFileMap-----" + attendanceFileMap);
|
|
|
+ logger.error("setCardId-----" + setCardId);
|
|
|
//相同的数据
|
|
|
PunchCardRecordCollection existColl = this.getExistedPunchCardRecordCollection(ctx, minDateTime, maxDateTime, setCardId);
|
|
|
logger.error("existColl-----" + existColl.size());
|
|
@@ -266,7 +294,6 @@ public class SyncTranForMJFacadeControllerBean extends AbstractSyncTranForMJFaca
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
/**
|
|
|
* 重置token,每次调用接口后刷新token
|
|
|
*/
|
|
@@ -511,7 +538,7 @@ public class SyncTranForMJFacadeControllerBean extends AbstractSyncTranForMJFaca
|
|
|
////简称
|
|
|
//cardInfo.setSimpleName(exceptionType);
|
|
|
//描述
|
|
|
- //cardInfo.setDescription(exceptionType);
|
|
|
+ cardInfo.setDescription("数据库数据");
|
|
|
|
|
|
EquNoSet.add("001");
|
|
|
if (!StringUtils.isEmpty(personNumber)) {
|