|
@@ -1,15 +1,41 @@
|
|
|
package com.kingdee.eas.custom.synctask.handler;
|
|
|
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
import com.kingdee.bos.BOSException;
|
|
|
import com.kingdee.bos.Context;
|
|
|
+import com.kingdee.bos.dao.IObjectPK;
|
|
|
+import com.kingdee.bos.metadata.entity.EntityViewInfo;
|
|
|
+import com.kingdee.bos.metadata.entity.FilterInfo;
|
|
|
+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.custom.sso.ExpiringMapCache;
|
|
|
import com.kingdee.eas.custom.synctask.SyncTranForMJFacadeFactory;
|
|
|
+import com.kingdee.eas.custom.synctask.utils.HRTimeWebUtils;
|
|
|
+import com.kingdee.eas.framework.CoreBaseCollection;
|
|
|
+import com.kingdee.eas.hr.ats.*;
|
|
|
import com.kingdee.shr.ats.web.handler.PunchCardRecordListHandler;
|
|
|
import com.kingdee.shr.base.syssetting.context.SHRContext;
|
|
|
+import com.kingdee.shr.base.syssetting.exception.ShrWebBizException;
|
|
|
+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.Timestamp;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
+import java.util.*;
|
|
|
|
|
|
/**
|
|
|
* @Description TODO
|
|
@@ -19,11 +45,425 @@ import javax.servlet.http.HttpServletResponse;
|
|
|
public class PunchCardRecordListHandlerEx extends PunchCardRecordListHandler {
|
|
|
Logger logger = Logger.getLogger(PunchCardRecordListHandlerEx.class);
|
|
|
private Context ctx = SHRContext.getInstance().getContext();
|
|
|
+ private Properties propt = new Properties();
|
|
|
|
|
|
+ private static ExpiringMapCache<String, String> cache = new ExpiringMapCache();
|
|
|
+ private long durationInMillis = 84600000;
|
|
|
+
|
|
|
+ public PunchCardRecordListHandlerEx() throws BOSException {
|
|
|
+ String syncOAConfigPath = System.getProperty("EAS_HOME") + "/server/properties/scy/syncMJConfig.properties";
|
|
|
+ try {
|
|
|
+ propt.load(new FileInputStream(syncOAConfigPath));
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ String errorMsg = "获取配置文件报错,请检查配置:" + syncOAConfigPath + " " + e.getMessage();
|
|
|
+ throw new BOSException(errorMsg);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取数据库打卡记录
|
|
|
+ *
|
|
|
+ * @param request
|
|
|
+ * @param response
|
|
|
+ * @param modelMap
|
|
|
+ * @throws BOSException
|
|
|
+ */
|
|
|
public void syncZKPunchCardDataAction(HttpServletRequest request, HttpServletResponse response, ModelMap modelMap) throws BOSException {
|
|
|
SyncTranForMJFacadeFactory.getLocalInstance(ctx).syncPunchRecordFromMJ(null, null);
|
|
|
//syncZKPunchCardData(request, response, modelMap);
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取门禁打卡记录
|
|
|
+ *
|
|
|
+ * @param request
|
|
|
+ * @param response
|
|
|
+ * @param modelMap
|
|
|
+ * @throws BOSException
|
|
|
+ */
|
|
|
+ public void syncPunchRecordFromMJAction(HttpServletRequest request, HttpServletResponse response, ModelMap modelMap) throws BOSException, ShrWebBizException {
|
|
|
+ //SyncTranForMJFacadeFactory.getLocalInstance(ctx).syncAccessRecord(null, null);
|
|
|
+ //syncZKPunchCardData(request, response, modelMap);
|
|
|
+ _syncAccessRecord(ctx, null, null);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 同步门禁打卡记录
|
|
|
+ *
|
|
|
+ * @param ctx
|
|
|
+ * @param startDate
|
|
|
+ * @param endDate
|
|
|
+ * @throws BOSException
|
|
|
+ */
|
|
|
+ protected void _syncAccessRecord(Context ctx, String startDate, String endDate) throws ShrWebBizException {
|
|
|
+ logger.error("_syncAccessRecord------");
|
|
|
+ Properties properties = new Properties();
|
|
|
+ properties.put("version", propt.getProperty("version"));
|
|
|
+ properties.put("tenantCode", propt.getProperty("tenantCode"));//租户编号,平台提供
|
|
|
+ properties.put("language", propt.getProperty("language"));//语言
|
|
|
+ properties.put("tenantSecret", propt.getProperty("tenantSecret"));//密钥
|
|
|
+ properties.put("account", propt.getProperty("account"));//接口账号
|
|
|
+ properties.put("password", propt.getProperty("password"));//接口账号密码
|
|
|
+ properties.put("getTokenPath", propt.getProperty("getTokenPath"));//获取token接口地址
|
|
|
+
|
|
|
+
|
|
|
+ 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());
|
|
|
+ String payload = params.toJSONString();
|
|
|
+ Map<String, String> headers = getHeader(payload, false);
|
|
|
+
|
|
|
+ OkHttpClient client = new OkHttpClient.Builder().build();
|
|
|
+ MediaType mediaType = MediaType.parse("application/json");
|
|
|
+ RequestBody body = RequestBody.create(mediaType, payload);
|
|
|
+ Request.Builder requestBuilder = new Request.Builder()
|
|
|
+ .url(propt.getProperty("getMJPath"))
|
|
|
+ .method("POST", body)
|
|
|
+ .addHeader("Content-Type", "application/json");
|
|
|
+ // 批量添加请求头
|
|
|
+ for (Map.Entry<String, String> header : headers.entrySet()) {
|
|
|
+ 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();
|
|
|
+ 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(result.get("data").toString());
|
|
|
+ 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, set);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ throw new ShrWebBizException(e.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 保存门禁打卡记录
|
|
|
+ *
|
|
|
+ * @param ctx
|
|
|
+ * @param 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();
|
|
|
+ Set<String> EquNoSet = new HashSet();
|
|
|
+ Timestamp minDateTime = null;
|
|
|
+ Timestamp maxDateTime = null;
|
|
|
+ CoreBaseCollection cardCollFinally = new CoreBaseCollection();
|
|
|
+ CoreBaseCollection cardColl = new CoreBaseCollection();
|
|
|
+ JSONArray formatErrorRecords = new JSONArray();
|
|
|
+ //存储相同的数据
|
|
|
+ JSONArray duplicateRecords = new JSONArray();
|
|
|
+ //存储考勤日期为空的数据
|
|
|
+ JSONArray notExistRecords = new JSONArray();
|
|
|
+ JSONArray seccussArray = new JSONArray();
|
|
|
+ ++success;
|
|
|
+ String personNumber = resultData.getString("empCode");//员工编码
|
|
|
+ String punchCardDate = resultData.getString("checkTime"); //打卡时间
|
|
|
+ String RecDate = punchCardDate.substring(0, 10);// 考勤日期
|
|
|
+ String RecTime = punchCardDate.substring(11, 19);// 考勤时间
|
|
|
+ //String locationDetail = resultSet.getString("name"); //打卡地点
|
|
|
+ //String EquNo = resultSet.getString("EquNo"); //考勤机编码
|
|
|
+ //String exceptionType = resultSet.getString("EquNo"); // 打卡/异常类型
|
|
|
+ //Date punchDate = HRTimeWebUtils.stringToShortDate(RecDate, true);
|
|
|
+ Date punchDate = com.kingdee.eas.custom.synctask.utils.HRTimeWebUtils.stringToShortDate(RecDate, true);
|
|
|
+ Timestamp punchCardTime = com.kingdee.eas.custom.synctask.utils.HRTimeWebUtils.stringToTimestamp(punchCardDate, true);
|
|
|
+ // 处理数据
|
|
|
+ if (punchCardDate != null && punchCardTime != null) {
|
|
|
+ PunchCardRecordInfo cardInfo = new PunchCardRecordInfo();
|
|
|
+ //考勤机编码
|
|
|
+ cardInfo.setEquipmentNum("001");
|
|
|
+ //考勤编码
|
|
|
+ cardInfo.setAttendanceNum(personNumber);
|
|
|
+ //打卡日期
|
|
|
+ cardInfo.setPunchCardDate(punchDate);
|
|
|
+ //打卡时间
|
|
|
+ cardInfo.setPunchCardTime(punchCardTime);
|
|
|
+ // 打卡来源
|
|
|
+ cardInfo.setPunchCardSource(PunchCardSourceEnum.attenceMachine);
|
|
|
+ // 打卡位置
|
|
|
+ cardInfo.setPunchCardPlace((String) resultData.get("checkLocation"));
|
|
|
+ // 有效
|
|
|
+ PunchCardStateEnum punchCardStateEnum;
|
|
|
+ if ((boolean) resultData.get("isActive")) {
|
|
|
+ punchCardStateEnum = PunchCardStateEnum.normal;
|
|
|
+ } else {
|
|
|
+ punchCardStateEnum = PunchCardStateEnum.cancelled;
|
|
|
+ }
|
|
|
+ cardInfo.setPunchCardState(punchCardStateEnum);
|
|
|
+ ////简称
|
|
|
+ //cardInfo.setSimpleName(exceptionType);
|
|
|
+ //描述
|
|
|
+ //cardInfo.setDescription(exceptionType);
|
|
|
+
|
|
|
+ EquNoSet.add("001");
|
|
|
+ if (!StringUtils.isEmpty(personNumber)) {
|
|
|
+ if (!set.contains(personNumber)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ setCardId.add(personNumber);
|
|
|
+ cardColl.add(cardInfo);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (minDateTime != null && maxDateTime != null) {
|
|
|
+ if (punchCardTime.getTime() < minDateTime.getTime()) {
|
|
|
+ minDateTime = punchCardTime;
|
|
|
+ } else if (punchCardTime.getTime() > maxDateTime.getTime()) {
|
|
|
+ maxDateTime = punchCardTime;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ minDateTime = punchCardTime;
|
|
|
+ maxDateTime = punchCardTime;
|
|
|
+ }
|
|
|
+
|
|
|
+ } else {
|
|
|
+ formatErrorRecords.add(resultData);
|
|
|
+ }
|
|
|
+ // 考勤档案
|
|
|
+ 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());
|
|
|
+ for (int i = 0; i < cardColl.size(); ++i) {
|
|
|
+ Map map = new HashMap();
|
|
|
+ // 原始打卡记录实体
|
|
|
+ PunchCardRecordInfo cardInfo = (PunchCardRecordInfo) cardColl.get(i);
|
|
|
+ JSONObject jsObject = new JSONObject();
|
|
|
+ jsObject.put("deviceid", cardInfo.getEquipmentNum()); // deviceid --EquNo
|
|
|
+ jsObject.put("userid", cardInfo.getAttendanceNum()); // userid --CardId
|
|
|
+ jsObject.put("RecDate", com.kingdee.eas.custom.synctask.utils.HRTimeWebUtils.dateShortToString(cardInfo.getPunchCardDate())); //checkin_time --RecDate
|
|
|
+ jsObject.put("RecTime", com.kingdee.eas.custom.synctask.utils.HRTimeWebUtils.timestampToString(cardInfo.getPunchCardTime()).substring(11)); //checkin_time --RecDate
|
|
|
+ map.put("userid", cardInfo.getAttendanceNum());
|
|
|
+ map.put("RecDate", com.kingdee.eas.custom.synctask.utils.HRTimeWebUtils.dateShortToString(cardInfo.getPunchCardDate()));
|
|
|
+ map.put("RecTime", HRTimeWebUtils.timestampToString(cardInfo.getPunchCardTime()).substring(11));
|
|
|
+ //员工是否有考勤档案
|
|
|
+ if (attendanceFileMap.containsKey(cardInfo.getAttendanceNum())) {
|
|
|
+ if (existColl.contains(cardInfo)) {
|
|
|
+ duplicateRecords.add(jsObject);
|
|
|
+ } else {
|
|
|
+ // 打卡位置 ,考勤机 的地址
|
|
|
+ cardInfo.setPunchCardPlace(cardInfo.getPunchCardPlace());
|
|
|
+ //打卡来源
|
|
|
+ cardInfo.setPunchCardSource(PunchCardSourceEnum.attenceMachine);
|
|
|
+ // 考勤实体
|
|
|
+ AttendanceFileInfo attendanceFileInfo = (AttendanceFileInfo) attendanceFileMap.get(cardInfo.getAttendanceNum());
|
|
|
+ // 姓名
|
|
|
+ cardInfo.setProposer(attendanceFileInfo.getProposer());
|
|
|
+ // HR 组织
|
|
|
+ cardInfo.setHrOrgUnit(attendanceFileInfo.getHrOrgUnit());
|
|
|
+ //行政组织
|
|
|
+ cardInfo.setAdminOrgUnit(attendanceFileInfo.getAdminOrgUnit());
|
|
|
+ cardInfo.setCreator((UserInfo) ctx.get("UserInfo"));
|
|
|
+ cardInfo.setLastUpdateUser((UserInfo) ctx.get("UserInfo"));
|
|
|
+ cardInfo.setCreateTime(new Timestamp((new Date()).getTime()));
|
|
|
+ cardInfo.setLastUpdateTime(new Timestamp((new Date()).getTime()));
|
|
|
+ cardCollFinally.add(cardInfo);
|
|
|
+ }
|
|
|
+ seccussArray.add(map);
|
|
|
+ } else {
|
|
|
+ ++error;
|
|
|
+ notExistRecords.add(jsObject);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ logger.error("cardCollFinally-----" + cardCollFinally.size());
|
|
|
+ logger.error("success-----" + success);
|
|
|
+ logger.error("error-----" + error);
|
|
|
+ logger.error("notExistRecords--list---" + notExistRecords);
|
|
|
+ logger.error("notExistRecords-----" + notExistRecords.size());
|
|
|
+ logger.error("seccussArray--Size-----" + seccussArray.size());
|
|
|
+ logger.error("seccussArray-----" + seccussArray);
|
|
|
+ IObjectPK[] iObjectPKS = PunchCardRecordFactory.getLocalInstance(ctx).saveBatchData(cardCollFinally);
|
|
|
+ logger.error("iObjectPKS----" + iObjectPKS.length);
|
|
|
+ } catch (
|
|
|
+ Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 重置token,每次调用接口后刷新token
|
|
|
+ */
|
|
|
+ private void resetToken() {
|
|
|
+ String token = cache.get("token");
|
|
|
+ if (org.apache.commons.lang3.StringUtils.isBlank(token)) {
|
|
|
+ getTokenByRemote();
|
|
|
+ } else {
|
|
|
+ cache.put("token", token, durationInMillis);//23.5小时
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取请求头
|
|
|
+ *
|
|
|
+ * @param payload body的json字符串
|
|
|
+ * @param isGetToken 是否获取token请求
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private Map<String, String> getHeader(String payload, boolean isGetToken) {
|
|
|
+ Map<String, String> signParams = new HashMap<>();
|
|
|
+ signParams.put("version", propt.getProperty("version"));
|
|
|
+ signParams.put("transId", UUID.randomUUID().toString());
|
|
|
+ signParams.put("timestamp", String.valueOf(System.currentTimeMillis() / 1000));
|
|
|
+ signParams.put("tenantCode", propt.getProperty("tenantCode"));//租户编号,平台提供
|
|
|
+ signParams.put("language", propt.getProperty("language"));//语言支持
|
|
|
+ if (!isGetToken) {
|
|
|
+ signParams.put("token", getToken());
|
|
|
+ }
|
|
|
+ signParams.put("payload", payload);//发起请求时 body 的 json 字符串
|
|
|
+ //密钥必须放在生成签名代码之前
|
|
|
+ signParams.put("tenantSecret", propt.getProperty("tenantSecret"));
|
|
|
+ signParams.put("sign", createSign(signParams));
|
|
|
+ return signParams;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取token
|
|
|
+ *
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private String getToken() {
|
|
|
+ String token = cache.get("token");
|
|
|
+ if (org.apache.commons.lang3.StringUtils.isBlank(token)) {
|
|
|
+ token = getTokenByRemote();
|
|
|
+ }
|
|
|
+ return token;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 远程获取token
|
|
|
+ *
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private String getTokenByRemote() {
|
|
|
+ try {
|
|
|
+ com.alibaba.fastjson.JSONObject params = new com.alibaba.fastjson.JSONObject();
|
|
|
+ params.put("account", propt.getProperty("account"));
|
|
|
+ String password = propt.getProperty("password");
|
|
|
+ params.put("password", EncryptUtils.sha256(password, false));
|
|
|
+ String payload = params.toJSONString();
|
|
|
+ String getTokenPath = propt.getProperty("getTokenPath");
|
|
|
+
|
|
|
+ Map<String, String> headers = getHeader(payload, true);
|
|
|
+ OkHttpClient client = new OkHttpClient.Builder().build();
|
|
|
+ MediaType mediaType = MediaType.parse("application/json");
|
|
|
+ RequestBody body = RequestBody.create(mediaType, payload);
|
|
|
+ Request.Builder requestBuilder = new Request.Builder()
|
|
|
+ .url(getTokenPath)
|
|
|
+ .method("POST", body)
|
|
|
+ .addHeader("Content-Type", "application/json");
|
|
|
+ // 批量添加请求头
|
|
|
+ for (Map.Entry<String, String> header : headers.entrySet()) {
|
|
|
+ requestBuilder.header(header.getKey(), header.getValue());
|
|
|
+ }
|
|
|
+ Response response = client.newCall(requestBuilder.build()).execute();
|
|
|
+ ObjectMapper mapper = new ObjectMapper();
|
|
|
+ if (response.isSuccessful()) {
|
|
|
+ Map<String, Object> result = mapper.readValue(response.body().string(), Map.class);
|
|
|
+ if ("success".equals(result.get("msg"))) {
|
|
|
+ String token = (String) result.get("data");
|
|
|
+ cache.put("token", token, 84600000);//23.5小时
|
|
|
+ return token;
|
|
|
+ } else {
|
|
|
+ throw new RuntimeException("远程获取token报错: ");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ throw new RuntimeException("远程获取token报错: ");
|
|
|
+ }
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ throw new RuntimeException("远程获取token报错: " + e.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 生成签名
|
|
|
+ *
|
|
|
+ * @param signParams 参与签名的参数
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private String createSign(Map<String, String> signParams) {
|
|
|
+ String tenantSecret = signParams.get("tenantSecret");
|
|
|
+ signParams.remove("tenantSecret");
|
|
|
+ String linkStr = createLinkStr(signParams, "&");
|
|
|
+ linkStr = linkStr + "&tenantSecret=" + tenantSecret;
|
|
|
+ return EncryptUtils.sha256(linkStr, true);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 创建链接字符串
|
|
|
+ *
|
|
|
+ * @param params 参数
|
|
|
+ * @param linkStr 连接字符
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private static String createLinkStr(Map<String, String> params, String linkStr) {
|
|
|
+ List<String> keys = new ArrayList<String>(params.keySet());
|
|
|
+ Collections.sort(keys);
|
|
|
+ StringBuilder content = new StringBuilder();
|
|
|
+ for (int i = 0; i < keys.size(); i++) {
|
|
|
+ String key = keys.get(i);
|
|
|
+ String value = params.get(key);
|
|
|
+ if (i == keys.size() - 1) {
|
|
|
+ content.append(key).append("=").append(value);
|
|
|
+ } else {
|
|
|
+ content.append(key).append("=").append(value).append(linkStr);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return content.toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ private PunchCardRecordCollection getExistedPunchCardRecordCollection(Context ctx, Timestamp minDateTime, Timestamp maxDateTime, Set<String> setCardId) throws BOSException {
|
|
|
+ EntityViewInfo evi = new EntityViewInfo();
|
|
|
+ FilterInfo fi = new FilterInfo();
|
|
|
+ evi.setFilter(fi);
|
|
|
+ evi.getSelector().add(new SelectorItemInfo("punchCardDate"));
|
|
|
+ evi.getSelector().add(new SelectorItemInfo("punchCardTime"));
|
|
|
+ evi.getSelector().add(new SelectorItemInfo("punchCardSource"));
|
|
|
+ evi.getSelector().add(new SelectorItemInfo("equipmentNum"));
|
|
|
+ evi.getSelector().add(new SelectorItemInfo("attendanceNum"));
|
|
|
+ fi.getFilterItems().add(new FilterItemInfo("attendanceNum", setCardId, CompareType.INCLUDE));
|
|
|
+ fi.getFilterItems().add(new FilterItemInfo("punchCardTime", maxDateTime, CompareType.LESS_EQUALS));
|
|
|
+ fi.getFilterItems().add(new FilterItemInfo("punchCardTime", minDateTime, CompareType.GREATER_EQUALS));
|
|
|
+ PunchCardRecordCollection existColl = PunchCardRecordFactory.getLocalInstance(ctx).getPunchCardRecordCollection(evi);
|
|
|
+ return existColl;
|
|
|
+
|
|
|
+ }
|
|
|
//
|
|
|
//public void syncZKPunchCardData(HttpServletRequest request, HttpServletResponse response, ModelMap modelMap) {
|
|
|
// //String url = "jdbc:sqlserver://10.0.3.23:1433;databaseName=kaoqin";
|