Browse Source

打卡同步

“luojun” 7 months ago
parent
commit
74026f38f6

+ 264 - 2
src/com/kingdee/eas/custom/synctask/SyncTranForMJFacadeControllerBean.java

@@ -2,13 +2,55 @@ package com.kingdee.eas.custom.synctask;
 
 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.common.EASBizException;
+import com.kingdee.eas.custom.log.ISyncLog;
+import com.kingdee.eas.custom.log.SyncLogFactory;
+import com.kingdee.eas.custom.log.SyncLogInfo;
+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.synctask.utils.HRTimeWebUtils;
+import com.kingdee.eas.framework.CoreBaseCollection;
+import com.kingdee.eas.hr.ats.*;
+import com.kingdee.shr.base.syssetting.web.json.JSONUtils;
+import com.kingdee.util.StringUtils;
+import net.sf.json.JSONArray;
+import net.sf.json.JSONObject;
 import org.apache.log4j.Logger;
 
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.sql.*;
+import java.text.SimpleDateFormat;
+import java.util.*;
+import java.util.Date;
+
 public class SyncTranForMJFacadeControllerBean extends AbstractSyncTranForMJFacadeControllerBean {
     private static Logger logger = Logger.getLogger(SyncTranForMJFacadeControllerBean.class);
+    private Properties propt = new Properties();
+
+    public SyncTranForMJFacadeControllerBean() 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 ctx
      * @param beginDate
      * @param endDate
@@ -16,6 +58,226 @@ public class SyncTranForMJFacadeControllerBean extends AbstractSyncTranForMJFaca
      */
     @Override
     protected void _syncPunchRecordFromMJ(Context ctx, String beginDate, String endDate) throws BOSException {
-        super._syncPunchRecordFromMJ(ctx, beginDate, endDate);
+        String url = propt.getProperty("jdbc");
+        String username = propt.getProperty("user");
+        String password = propt.getProperty("password");
+        ISyncLog iSyncLog = SyncLogFactory.getLocalInstance(ctx);
+        SyncLogInfo syncLogInfo = new SyncLogInfo();
+        syncLogInfo.setEntityName(SyncEntityNameEnum.cardRecord);
+        syncLogInfo.setDataDirection(DataDirectionEnum.flowInto);
+        syncLogInfo.setDockingSystem(DockingSystemEnum.accessControl);
+        int success = 0;
+        int error = 0;
+        try {
+            // 加载SQL Server JDBC驱动程序
+            //Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
+            // 建立连接
+            Connection connection = DriverManager.getConnection(url, username, password);
+            // 创建Statement对象
+            Statement statement = connection.createStatement();
+            String oneMOnthDate = null;
+            String nowDate = null;
+            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+
+            //获取当前时间以及一个月前的时间
+            if (StringUtils.isEmpty(beginDate) && StringUtils.isEmpty(endDate)) {
+                // 获取当前日期
+                Date now = new Date();
+                Calendar calendar = Calendar.getInstance();
+                calendar.setTime(now);
+                // 将月份减1(这里只是简单的月份减1,没有考虑日期边界等复杂情况)
+                calendar.add(Calendar.MONTH, -1);
+                Date one_month_ago = calendar.getTime();
+                oneMOnthDate = sdf.format(one_month_ago);
+                nowDate = sdf.format(now);
+                logger.error("PunchCardRecordEx----oneMOnthDate--" + oneMOnthDate);
+                logger.error("PunchCardRecordEx----nowDate--" + nowDate);
+            } else {
+                oneMOnthDate = beginDate;
+                nowDate = endDate;
+            }
+            // 执行查询语句
+            String query = "select \n" +
+                    "userinfo.SSN as personNumber ,\n" +
+                    "checkin.CHECKTIME as checkTime\n" +
+                    "from  checkinout as checkin\n" +
+                    "left join USERINFO as userinfo on userinfo.USERID = checkin.USERID\n" +
+                    "where checkin.CHECKTIME >='" + oneMOnthDate + "' and checkin.CHECKTIME <='" + nowDate + "'\n";
+            //String query = "\n" +
+            //        " \n" +
+            //        "select \n" +
+            //        "userinfo.SSN as personNumber ,\n" +
+            //        "checkin.CHECKTIME as checkTime\n" +
+            //        "from  checkinout as checkin\n" +
+            //        "left join USERINFO as userinfo on userinfo.USERID = checkin.USERID\n" +
+            //        "where checkin.CHECKTIME >='2024-10-29' and checkin.CHECKTIME <='2024-10-30'\n" +
+            //        " ";
+            ResultSet resultSet = statement.executeQuery(query);
+            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();
+
+            // 处理查询结果
+            while (resultSet.next()) {
+                ++success;
+                String personNumber = resultSet.getString("personNumber");//员工编码
+                String punchCardDate = resultSet.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 = HRTimeWebUtils.stringToShortDate(RecDate, true);
+                Timestamp punchCardTime = 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.mobileRegistration);
+                    // 打卡位置
+                    cardInfo.setPunchCardPlace("考勤机打卡");
+                    // 有效
+                    cardInfo.setPunchCardState(PunchCardStateEnum.normal);
+                    ////简称
+                    //cardInfo.setSimpleName(exceptionType);
+                    //描述
+                    //cardInfo.setDescription(exceptionType);
+
+                    EquNoSet.add("001");
+                    if (!StringUtils.isEmpty(personNumber)) {
+                        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(resultSet);
+                }
+            }
+            // 考勤档案
+            Map<String, AttendanceFileInfo> attendanceFileMap = AttendanceFileFactory.getLocalInstance(ctx).getPersonByAttendanceNum(setCardId);
+            logger.error("attendanceFileMap-----" + attendanceFileMap);
+            //相同的数据
+            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", HRTimeWebUtils.dateShortToString(cardInfo.getPunchCardDate())); //checkin_time --RecDate
+                jsObject.put("RecTime", HRTimeWebUtils.timestampToString(cardInfo.getPunchCardTime()).substring(11)); //checkin_time --RecDate
+                map.put("userid", cardInfo.getAttendanceNum());
+                map.put("RecDate", 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.mobileRegistration);
+                        // 考勤实体
+                        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);
+            if(iObjectPKS.length>0){
+                logger.error("iObjectPKS----" + iObjectPKS.length);
+                syncLogInfo.setSyncStatus(SyncStatusEnum.SUCCESS);
+                syncLogInfo.setSyncResult(iObjectPKS.toString());
+                syncLogInfo.setSyncCount(success);
+                syncLogInfo.setSuccessNum(cardCollFinally.size());
+                syncLogInfo.setFailNum(error);
+                iSyncLog.save(syncLogInfo);
+            }
+            // 关闭连接
+            resultSet.close();
+            statement.close();
+            connection.close();
+
+        } catch (Exception e) {
+            syncLogInfo.setSyncStatus(SyncStatusEnum.ERROR);
+            syncLogInfo.setSyncResult(e.getMessage());
+            try {
+                iSyncLog.save(syncLogInfo);
+            } catch (EASBizException ex) {
+                throw new RuntimeException(ex);
+            }
+            e.printStackTrace();
+        }
+    }
+
+    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;
+
     }
 }

+ 771 - 0
src/com/kingdee/eas/custom/synctask/utils/HRTimeWebUtils.java

@@ -0,0 +1,771 @@
+package com.kingdee.eas.custom.synctask.utils;
+
+import com.kingdee.bos.BOSException;
+import com.kingdee.bos.Context;
+import com.kingdee.eas.common.EASBizException;
+import com.kingdee.eas.hr.ats.util.AtsDateUtils;
+import com.kingdee.eas.hr.ats.util.common.AtsCommonUtile;
+import org.apache.commons.lang3.StringUtils;
+
+import java.math.BigDecimal;
+import java.sql.Time;
+import java.sql.Timestamp;
+import java.text.DateFormat;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.*;
+
+/**
+ * @author qingwu
+ * @date 2024/10/30
+ * @apiNote
+ */
+public class HRTimeWebUtils {
+    public static String timestampToString(Timestamp timestamp) {
+        String tsStr = "";
+        DateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+
+        try {
+            tsStr = sdf.format(timestamp);
+        } catch (Exception var4) {
+            AtsCommonUtile.logFirstStack(var4);
+        }
+
+        return tsStr;
+    }
+
+    public static String timestampToString2(Timestamp timestamp) {
+        String tsStr = "";
+        DateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
+
+        try {
+            tsStr = sdf.format(timestamp);
+        } catch (Exception var4) {
+            AtsCommonUtile.logFirstStack(var4);
+        }
+
+        return tsStr;
+    }
+
+    public static Timestamp string2Timestamp(String tsStr) {
+        Timestamp ts = new Timestamp(System.currentTimeMillis());
+        SimpleDateFormat c = new SimpleDateFormat("yyyy-MM-dd HH:mm");
+
+        try {
+            Date d = c.parse(tsStr);
+            ts = new Timestamp(d.getTime());
+        } catch (Exception var4) {
+            AtsCommonUtile.logFirstStack(var4);
+        }
+
+        return ts;
+    }
+
+    public static Timestamp stringToTimestamp(String tsStr) {
+        Timestamp ts = new Timestamp(System.currentTimeMillis());
+
+        try {
+            ts = Timestamp.valueOf(tsStr);
+        } catch (Exception var3) {
+            AtsCommonUtile.logFirstStack(var3);
+        }
+
+        return ts;
+    }
+
+    public static Timestamp stringShortToTimestamp(String tsStr) {
+        DateFormat format = new SimpleDateFormat("yyyy-MM-dd");
+        format.setLenient(false);
+        Timestamp ts = new Timestamp(System.currentTimeMillis());
+
+        try {
+            ts = new Timestamp(format.parse(tsStr).getTime());
+        } catch (ParseException var4) {
+            AtsCommonUtile.logFirstStack(var4);
+        }
+
+        return ts;
+    }
+
+    public static Date stringToLongDate(String str) {
+        Date date = new Date();
+        if (str.indexOf("/") != -1) {
+            str = str.replaceAll("/", "-");
+        }
+
+        DateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+
+        try {
+            date = sdf.parse(str);
+        } catch (Exception var4) {
+            AtsCommonUtile.logFirstStack(var4);
+        }
+
+        return date;
+    }
+
+    public static Date stringToShortDate(String str) {
+        Date date = new Date();
+        if (str.indexOf("/") != -1) {
+            str = str.replaceAll("/", "-");
+        }
+
+        DateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+
+        try {
+            date = sdf.parse(str);
+        } catch (Exception var4) {
+            AtsCommonUtile.logFirstStack(var4);
+        }
+
+        return date;
+    }
+
+    public static String dateLongToString(Date date) {
+        String dateStr = "";
+        DateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+
+        try {
+            dateStr = sdf.format(date);
+        } catch (Exception var4) {
+            AtsCommonUtile.logFirstStack(var4);
+        }
+
+        return dateStr;
+    }
+
+    public static String dateToString(Date date, String parameter) {
+        String dateStr = "";
+        if (StringUtils.isEmpty(parameter)) {
+            parameter = "yyyy-MM-dd HH:mm:ss";
+        }
+
+        DateFormat sdf = new SimpleDateFormat(parameter);
+
+        try {
+            dateStr = sdf.format(date);
+        } catch (Exception var5) {
+            AtsCommonUtile.logFirstStack(var5);
+        }
+
+        return dateStr;
+    }
+
+    public static String dateShortToString(Date date) {
+        String dateStr = "";
+        DateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+
+        try {
+            dateStr = sdf.format(date);
+        } catch (Exception var4) {
+            AtsCommonUtile.logFirstStack(var4);
+        }
+
+        return dateStr;
+    }
+
+    public static Timestamp dateToTimestamp(Date date) {
+        Timestamp ts = new Timestamp(date.getTime());
+        return ts;
+    }
+
+    public static Date timestampToDate(Timestamp temTimestamp) {
+        Date date = new Date();
+
+        try {
+            date = temTimestamp;
+        } catch (Exception var3) {
+            AtsCommonUtile.logFirstStack(var3);
+        }
+
+        return (Date)date;
+    }
+
+    public static Map<String, String> getFirstDayLastDay(int year, int month) {
+        SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd");
+        Calendar cal = Calendar.getInstance();
+        if (year >= 1900 && year <= 9999) {
+            cal.set(1, year);
+        }
+
+        cal.set(2, month);
+        cal.set(5, 1);
+        cal.add(5, -1);
+        Date lastDate = cal.getTime();
+        cal.set(5, 1);
+        Date firstDate = cal.getTime();
+        Map<String, String> map = new HashMap();
+        map.put("firstDate", sf.format(firstDate));
+        map.put("lastDate", sf.format(lastDate));
+        return map;
+    }
+
+    public static long getDaysBetweenTwoDate(Date date2, Date date1) {
+        new SimpleDateFormat("yyyy-MM-dd");
+        long days = 0L;
+
+        try {
+            long diff = date2.getTime() - date1.getTime();
+            if (diff < 0L) {
+                days = 0L;
+            } else {
+                days = diff / 86400000L;
+            }
+        } catch (Exception var7) {
+        }
+
+        return days;
+    }
+
+    public static int getMonthsBetweenTwoDate(Date date2, Date date1) {
+        int month = (date2.getYear() - date1.getYear()) * 12 + date2.getMonth() - date1.getMonth() + 1;
+        return month;
+    }
+
+    public static int getQuarterBetweenTwoDate(Date date2, Date date1) {
+        int quarter = (date2.getYear() - date1.getYear()) * 4 + date2.getMonth() / 3 - date1.getMonth() / 3 + 1;
+        return quarter;
+    }
+
+    public static String getBeforeDay(String someDay) {
+        Calendar c = Calendar.getInstance();
+        Date date = null;
+
+        try {
+            date = (new SimpleDateFormat("yyyy-MM-dd")).parse(someDay);
+        } catch (ParseException var5) {
+            AtsCommonUtile.logFirstStack(var5);
+        }
+
+        c.setTime(date);
+        int day = c.get(5);
+        c.set(5, day - 1);
+        String dayBefore = (new SimpleDateFormat("yyyy-MM-dd")).format(c.getTime());
+        return dayBefore;
+    }
+
+    public static Date getAfterOneDayTime(String curTime) {
+        Calendar c = Calendar.getInstance();
+        Date date = null;
+
+        try {
+            date = (new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")).parse(curTime);
+        } catch (ParseException var4) {
+            AtsCommonUtile.logFirstStack(var4);
+        }
+
+        c.setTime(date);
+        int day = c.get(5);
+        c.set(5, day + 1);
+        return c.getTime();
+    }
+
+    public static Date getAfterOneHourTime(Date curTime, int val) {
+        Calendar c = Calendar.getInstance();
+        c.setTime(curTime);
+        c.add(11, val);
+        return c.getTime();
+    }
+
+    public static Date getAfterOneHourTime(Date curTime, BigDecimal val) {
+        int diff = val.multiply(new BigDecimal(3600000)).intValue();
+        Calendar c = Calendar.getInstance();
+        c.setTime(curTime);
+        c.add(14, diff);
+        return c.getTime();
+    }
+
+    public static String getAfterDay(String someDay) {
+        Calendar c = Calendar.getInstance();
+        Date date = null;
+
+        try {
+            date = (new SimpleDateFormat("yyyy-MM-dd")).parse(someDay);
+        } catch (ParseException var5) {
+            AtsCommonUtile.logFirstStack(var5);
+        }
+
+        c.setTime(date);
+        int day = c.get(5);
+        c.set(5, day + 1);
+        String dayAfter = (new SimpleDateFormat("yyyy-MM-dd")).format(c.getTime());
+        return dayAfter;
+    }
+
+    public static String getAfterDay(String someDay, int n) {
+        Calendar c = Calendar.getInstance();
+        Date date = null;
+
+        try {
+            date = (new SimpleDateFormat("yyyy-MM-dd")).parse(someDay);
+        } catch (ParseException var6) {
+            AtsCommonUtile.logFirstStack(var6);
+        }
+
+        c.setTime(date);
+        int day = c.get(5);
+        c.set(5, day + n);
+        String dayAfter = (new SimpleDateFormat("yyyy-MM-dd")).format(c.getTime());
+        return dayAfter;
+    }
+
+    public static Date getAfterDay(Date someDay, int n) {
+        Calendar c = Calendar.getInstance();
+        c.setTime(someDay);
+        int day = c.get(5);
+        c.set(5, day + n);
+        return c.getTime();
+    }
+
+    public static Date getNextYearDate(Date date) {
+        Calendar c = Calendar.getInstance();
+        c.setTime(date);
+        int year = c.get(1);
+        c.set(1, year + 1);
+        return c.getTime();
+    }
+
+    public static String getDateOfWeek(String sDate) {
+        try {
+            String formater = "yyyy-MM-dd";
+            SimpleDateFormat format = new SimpleDateFormat(formater);
+            Date date = format.parse(sDate);
+            format.applyPattern("E");
+            return format.format(date);
+        } catch (Exception var4) {
+            System.out.println("HRTimeWebUtils  getDateOfWeek  " + var4.getMessage());
+            return "";
+        }
+    }
+
+    public static int getDateOfWeekForNum(Context ctx, String sDate) {
+        try {
+            String formater = "yyyy-MM-dd";
+            SimpleDateFormat sdf = new SimpleDateFormat(formater, Locale.CHINA);
+            Date date = sdf.parse(sDate);
+            Calendar calendar = Calendar.getInstance();
+            calendar.setTime(date);
+            int dayOfWeek = calendar.get(7) % 7;
+            return dayOfWeek == 0 ? 6 : dayOfWeek - 1;
+        } catch (Exception var7) {
+            System.out.println("HRTimeWebUtils  getDateOfWeek  " + var7.getMessage());
+            return 0;
+        }
+    }
+
+    public static String getFullDateWeekTime(String sDate) {
+        try {
+            String formater = "yyyy-MM-dd HH:mm:ss";
+            SimpleDateFormat format = new SimpleDateFormat(formater);
+            Date date = format.parse(sDate);
+            format.applyPattern("yyyy-MM-dd E HH:mm:ss");
+            return format.format(date);
+        } catch (Exception var4) {
+            System.out.println("HRTimeWebUtils  getFullDateWeekTime " + var4.getMessage());
+            return "";
+        }
+    }
+
+    public static String getCurentShortStringDate() {
+        try {
+            Date cudate = new Date();
+            String formater = "yyyy-MM-dd";
+            SimpleDateFormat sdf = new SimpleDateFormat(formater);
+            String dateTemp = sdf.format(cudate);
+            return dateTemp;
+        } catch (Exception var4) {
+            System.out.println("HRTimeWebUtils  getCurentShortStringDate " + var4.getMessage());
+            return "";
+        }
+    }
+
+    public static String getCurentLongStringDate() {
+        try {
+            Date cudate = new Date();
+            String formater = "yyyy-MM-dd HH:mm:ss";
+            SimpleDateFormat sdf = new SimpleDateFormat(formater);
+            String dateTemp = sdf.format(cudate);
+            return dateTemp;
+        } catch (Exception var4) {
+            System.out.println("HRTimeWebUtils  getCurentLongStringDate " + var4.getMessage());
+            return "";
+        }
+    }
+
+    public static String getTimeCoincidence(Date beginTime1, Date endTime1, Date beginTime2, Date endTime2) {
+        long b1 = beginTime1 != null ? beginTime1.getTime() : 0L;
+        long e1 = endTime1 != null ? endTime1.getTime() : 0L;
+        long b2 = beginTime2 != null ? beginTime2.getTime() : 0L;
+        long e2 = endTime2 != null ? endTime2.getTime() : 0L;
+        String coincidenceTime;
+        if (b1 <= b2 && e1 >= e2) {
+            coincidenceTime = getTimeDifference(endTime2, beginTime2);
+        } else if (b1 >= b2 && e1 <= e2) {
+            coincidenceTime = getTimeDifference(endTime1, beginTime1);
+        } else if (b1 >= b2 && b1 < e2 && e2 <= e1) {
+            coincidenceTime = getTimeDifference(endTime2, beginTime1);
+        } else if (b1 <= b2 && e1 <= e2 && e1 > b2) {
+            coincidenceTime = getTimeDifference(endTime1, beginTime2);
+        } else if (e1 > b2 && b1 < e2) {
+            coincidenceTime = "-1";
+            System.out.println("Unexpected date combination,Could not calculate coincidence.");
+        } else {
+            coincidenceTime = "0";
+        }
+
+        return coincidenceTime;
+    }
+
+    public static String getTimeCoincidence2(Date beginTime1, Date endTime1, Date beginTime2, Date endTime2) {
+        long b1 = beginTime1 != null ? beginTime1.getTime() : 0L;
+        long e1 = endTime1 != null ? endTime1.getTime() : 0L;
+        long b2 = beginTime2 != null ? beginTime2.getTime() : 0L;
+        long e2 = endTime2 != null ? endTime2.getTime() : 0L;
+        String coincidenceTime;
+        if (b1 <= b2 && e1 >= e2) {
+            coincidenceTime = getTimeDifference2(endTime2, beginTime2);
+        } else if (b1 >= b2 && e1 <= e2) {
+            coincidenceTime = getTimeDifference2(endTime1, beginTime1);
+        } else if (b1 >= b2 && b1 < e2 && e2 <= e1) {
+            coincidenceTime = getTimeDifference2(endTime2, beginTime1);
+        } else if (b1 <= b2 && e1 <= e2 && e1 > b2) {
+            coincidenceTime = getTimeDifference2(endTime1, beginTime2);
+        } else if (e1 > b2 && b1 < e2) {
+            coincidenceTime = "-1";
+            System.out.println("Unexpected date combination,Could not calculate coincidence.");
+        } else {
+            coincidenceTime = "0";
+        }
+
+        return coincidenceTime;
+    }
+
+    public static String getTimeCoincidence3(Date beginTime1, Date endTime1, Date beginTime2, Date endTime2) {
+        long b1 = beginTime1 != null ? beginTime1.getTime() : 0L;
+        long e1 = endTime1 != null ? endTime1.getTime() : 0L;
+        long b2 = beginTime2 != null ? beginTime2.getTime() : 0L;
+        long e2 = endTime2 != null ? endTime2.getTime() : 0L;
+        String coincidenceTime;
+        if (b1 <= b2 && e1 >= e2) {
+            coincidenceTime = getTimeDifference2(endTime2, beginTime2);
+        } else if (b1 >= b2 && e1 <= e2) {
+            coincidenceTime = getTimeDifference2(endTime1, beginTime1);
+        } else if (b1 >= b2 && b1 < e2 && e2 <= e1) {
+            coincidenceTime = getTimeDifference2(endTime2, beginTime1);
+        } else if (b1 <= b2 && e1 <= e2 && e1 > b2) {
+            coincidenceTime = getTimeDifference2(endTime1, beginTime2);
+        } else if (e1 >= b2 && b1 <= e2) {
+            if (e1 != b2 && b1 != e2) {
+                coincidenceTime = "-1";
+                System.out.println("Unexpected date combination,Could not calculate coincidence.");
+            } else {
+                coincidenceTime = "1";
+            }
+        } else {
+            coincidenceTime = "0";
+        }
+
+        return coincidenceTime;
+    }
+
+    public static String getTimeDifference(Date date1, Date date2) {
+        StringBuffer df = new StringBuffer();
+        if (null != date1 && null != date2) {
+            try {
+                double num = (double)(date1.getTime() - date2.getTime()) / 60000.0;
+                num = BigDecimal.valueOf(num).setScale(2, 4).doubleValue();
+                if (num > 0.0) {
+                    df.append(num);
+                } else if (num == 0.0) {
+                    df.append(0);
+                } else {
+                    df.append(-1);
+                }
+            } catch (Exception var5) {
+                AtsCommonUtile.logFirstStack(var5);
+            }
+
+            return df.toString();
+        } else {
+            df.append(-1);
+            return df.toString();
+        }
+    }
+
+    public static String getTimeDifference2(Date date1, Date date2) {
+        StringBuffer df = new StringBuffer();
+        if (null != date1 && null != date2) {
+            try {
+                long num = (date1.getTime() - date2.getTime()) / 60000L;
+                if (num > 0L) {
+                    df.append(num);
+                } else if (num == 0L) {
+                    df.append(0);
+                } else {
+                    df.append(-1);
+                }
+            } catch (Exception var5) {
+                AtsCommonUtile.logFirstStack(var5);
+            }
+
+            return df.toString();
+        } else {
+            df.append(-1);
+            return df.toString();
+        }
+    }
+
+    public static long getTimeCoincidence(long b1, long e1, long b2, long e2) {
+        long coincidenceTime = 0L;
+        if (b1 <= b2 && e1 >= e2) {
+            System.out.println("1 include 2");
+            coincidenceTime = getTimeDifference(e2, b2);
+        } else if (b1 >= b2 && e1 <= e2) {
+            System.out.println("2 include 1");
+            coincidenceTime = getTimeDifference(e1, b1);
+        } else if (b1 >= b2 && b1 <= e2 && e2 <= e1) {
+            System.out.println("intersect 1");
+            coincidenceTime = getTimeDifference(e2, b1);
+        } else if (b1 <= b2 && e1 <= e2 && e1 > b2) {
+            System.out.println("intersect 2");
+            coincidenceTime = getTimeDifference(e1, b2);
+        } else if (e1 > b2 && b1 < e2) {
+            coincidenceTime = 0L;
+            System.out.println("illegal date combine£¡");
+        } else {
+            coincidenceTime = 0L;
+        }
+
+        System.out.println("intersect count is [" + coincidenceTime + "]min¡£");
+        return coincidenceTime;
+    }
+
+    public static long getTimeDifference(long time1, long time2) {
+        return time1 - time2;
+    }
+
+    public static void main(String[] args) {
+        Calendar cal = Calendar.getInstance();
+        System.out.println(cal.get(1) + "-" + (cal.get(2) + 1) + "-01");
+    }
+
+    public static Timestamp stringToTimestamp(String tsStr, boolean errorToNull) {
+        Timestamp ts = new Timestamp(System.currentTimeMillis());
+        if (errorToNull) {
+            ts = null;
+        }
+
+        try {
+            ts = Timestamp.valueOf(tsStr);
+        } catch (Exception var4) {
+            AtsCommonUtile.logFirstStack(var4);
+        }
+
+        return ts;
+    }
+
+    public static Timestamp stringShortToTimestamp(String tsStr, boolean errorToNull) {
+        DateFormat format = new SimpleDateFormat("yyyy-MM-dd");
+        format.setLenient(false);
+        Timestamp ts = new Timestamp(System.currentTimeMillis());
+        if (errorToNull) {
+            ts = null;
+        }
+
+        try {
+            ts = new Timestamp(format.parse(tsStr).getTime());
+        } catch (ParseException var5) {
+            AtsCommonUtile.logFirstStack(var5);
+        }
+
+        return ts;
+    }
+
+    public static Date stringToLongDate(String str, boolean errorToNull) {
+        Date date = new Date();
+        if (errorToNull) {
+            date = null;
+        }
+
+        DateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+
+        try {
+            date = sdf.parse(str);
+        } catch (Exception var5) {
+            AtsCommonUtile.logFirstStack(var5);
+        }
+
+        return date;
+    }
+
+    public static Date stringToShortDate(String str, boolean errorToNull) {
+        Date date = new Date();
+        if (errorToNull) {
+            date = null;
+        }
+
+        DateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+
+        try {
+            date = sdf.parse(str);
+        } catch (Exception var5) {
+            AtsCommonUtile.logFirstStack(var5);
+        }
+
+        return date;
+    }
+
+    public static List getLeaveDateColl(Date beginTime, Date endTime) throws EASBizException, BOSException {
+        List<Date> dateList = new ArrayList();
+        beginTime = stringToShortDate(dateLongToString(beginTime));
+        endTime = stringToShortDate(dateLongToString(endTime));
+        Calendar beginCal = Calendar.getInstance();
+        beginCal.setTime(beginTime);
+        Calendar endCal = Calendar.getInstance();
+        endCal.setTime(endTime);
+        int temp = (int)((endTime.getTime() - beginTime.getTime()) / 86400000L + 1L);
+
+        for(int i = 0; i < temp; ++i) {
+            int year = beginCal.get(1);
+            int month = beginCal.get(2);
+            int day = beginCal.get(5);
+            Date tempDate = new Date(year - 1900, month, day);
+            dateList.add(tempDate);
+            beginCal.add(5, 1);
+        }
+
+        return dateList;
+    }
+
+    public static Date getMonthFirstDay(Date date) {
+        Calendar cal = Calendar.getInstance();
+        cal.setTime(date);
+        cal.set(5, 1);
+        Date firstDate = cal.getTime();
+        return firstDate;
+    }
+
+    public static Date getMonthLastDay(Date date) {
+        Calendar cal = Calendar.getInstance();
+        cal.setTime(date);
+        cal.add(2, 1);
+        cal.set(5, 1);
+        cal.add(5, -1);
+        Date lastDate = cal.getTime();
+        return lastDate;
+    }
+
+    public static Date addMonth(Date date, int months) {
+        Calendar cal = Calendar.getInstance();
+        cal.setTime(date);
+        cal.add(2, months);
+        Date lastDate = cal.getTime();
+        return lastDate;
+    }
+
+    public static String getStringFromObject(Object value) {
+        if (value == null) {
+            return "";
+        } else if (value instanceof Date) {
+            return dateLongToString((Date)value);
+        } else {
+            return value instanceof String ? (String)value : "";
+        }
+    }
+
+    public static Date getLongDateFromObject(Object value) {
+        if (value == null) {
+            return null;
+        } else if (value instanceof String) {
+            return stringToLongDate(value.toString());
+        } else {
+            return value instanceof Date ? (Date)value : null;
+        }
+    }
+
+    public static Date getShortDateFromObject(Object value) {
+        if (value == null) {
+            return null;
+        } else if (value instanceof String) {
+            return stringToShortDate(value.toString());
+        } else {
+            return value instanceof Date ? (Date)value : null;
+        }
+    }
+
+    public static List getLeaveBeforeAndAfterDateColl(Date beginTime, Date endTime) throws EASBizException, BOSException {
+        List<Date> dateList = new ArrayList();
+        beginTime = AtsDateUtils.getPreDay(beginTime);
+        endTime = AtsDateUtils.getNextDay(endTime);
+        beginTime = stringToShortDate(dateLongToString(beginTime));
+        endTime = stringToShortDate(dateLongToString(endTime));
+        Calendar beginCal = Calendar.getInstance();
+        beginCal.setTime(beginTime);
+        Calendar endCal = Calendar.getInstance();
+        endCal.setTime(endTime);
+        int temp = (int)((endTime.getTime() - beginTime.getTime()) / 86400000L + 1L);
+
+        for(int i = 0; i < temp; ++i) {
+            int year = beginCal.get(1);
+            int month = beginCal.get(2);
+            int day = beginCal.get(5);
+            Date tempDate = new Date(year - 1900, month, day);
+            dateList.add(tempDate);
+            beginCal.add(5, 1);
+        }
+
+        return dateList;
+    }
+
+    public static Date getLastMonthFirstDay() {
+        Calendar cal = Calendar.getInstance();
+        cal.add(2, -1);
+        cal.set(5, 1);
+        return cal.getTime();
+    }
+
+    public static Date getLastMonthLastDay() {
+        Calendar calendar = Calendar.getInstance();
+        calendar.set(5, 1);
+        calendar.add(5, -1);
+        return calendar.getTime();
+    }
+
+    public static boolean compareTime(String timeStr, String timeStr1) {
+        int timeHour = Integer.parseInt(timeStr.split(":")[0]);
+        int timeMin = Integer.parseInt(timeStr.split(":")[1]);
+        int timeHour1 = Integer.parseInt(timeStr1.split(":")[0]);
+        int timeMin1 = Integer.parseInt(timeStr1.split(":")[1]);
+        Time time = new Time(timeHour, timeMin, 0);
+        Time time1 = new Time(timeHour1, timeMin1, 0);
+        int i = time.compareTo(time1);
+        return i >= 0;
+    }
+
+    public static List<String> getMonthBetween(String minDate, String maxDate) throws ParseException {
+        ArrayList<String> result = new ArrayList();
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMM");
+        Calendar min = Calendar.getInstance();
+        Calendar max = Calendar.getInstance();
+        min.setTime(sdf.parse(minDate));
+        min.set(min.get(1), min.get(2), 1);
+        max.setTime(sdf.parse(maxDate));
+        max.set(max.get(1), max.get(2), 2);
+        Calendar curr = min;
+
+        while(curr.before(max)) {
+            result.add(sdf.format(curr.getTime()));
+            curr.add(2, 1);
+        }
+
+        return result;
+    }
+
+    public static Date addYear(Date date, int years) {
+        Calendar cal = Calendar.getInstance();
+        cal.setTime(date);
+        cal.add(1, years);
+        Date lastDate = cal.getTime();
+        return lastDate;
+    }
+}

+ 251 - 0
websrc/com/kingdee/eas/custom/synctask/handler/websrc/com/kingdee/eas/custom/synctask/handler/PunchCardRecordListHandlerEx.java

@@ -0,0 +1,251 @@
+package com.kingdee.eas.custom.synctask.handler;
+
+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.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.web.json.JSONUtils;
+import com.kingdee.util.StringUtils;
+import net.sf.json.JSONArray;
+import net.sf.json.JSONObject;
+import org.apache.log4j.Logger;
+import org.springframework.ui.ModelMap;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.sql.*;
+import java.text.SimpleDateFormat;
+import java.util.*;
+import java.util.Date;
+
+/**
+ * @Description TODO
+ * @Date 2024/10/29 17:51
+ * @Created by 30489
+ */
+public class PunchCardRecordListHandlerEx extends PunchCardRecordListHandler {
+    Logger logger = Logger.getLogger(PunchCardRecordListHandlerEx.class);
+    private Context ctx = SHRContext.getInstance().getContext();
+
+    public void syncZKPunchCardDataAction(HttpServletRequest request, HttpServletResponse response, ModelMap modelMap) throws BOSException {
+        SyncTranForMJFacadeFactory.getLocalInstance(ctx).syncPunchRecordFromMJ(null, null);
+        //syncZKPunchCardData(request, response, modelMap);
+    }
+    //
+    //public void syncZKPunchCardData(HttpServletRequest request, HttpServletResponse response, ModelMap modelMap) {
+    //    //String url = "jdbc:sqlserver://10.0.3.23:1433;databaseName=kaoqin";
+    //    String url = "jdbc:sqlserver://10.0.3.23:1433;databaseName=kaoqin;encrypt=true;trustServerCertificate=true;";
+    //    String username = "zhongkong";
+    //    String password = "6554+oijhh@";
+    //    try {
+    //        // 加载SQL Server JDBC驱动程序
+    //        //Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
+    //        // 建立连接
+    //        Connection connection = DriverManager.getConnection(url, username, password);
+    //        // 创建Statement对象
+    //        Statement statement = connection.createStatement();
+    //        //获取当前时间以及一个月前的时间
+    //        // 获取当前日期
+    //        Date now = new Date();
+    //        Calendar calendar = Calendar.getInstance();
+    //        calendar.setTime(now);
+    //        // 将月份减1(这里只是简单的月份减1,没有考虑日期边界等复杂情况)
+    //        calendar.add(Calendar.MONTH, -1);
+    //        Date one_month_ago = calendar.getTime();
+    //        // 获取当前日期
+    //        Date currentDate = new Date();
+    //        // 使用Calendar类来操作日期
+    //        Calendar calendarNewDate = Calendar.getInstance();
+    //        calendarNewDate.setTime(currentDate);
+    //        // 在当前日期基础上加1天
+    //        calendarNewDate.add(Calendar.DAY_OF_MONTH, 1);
+    //        Date newDate = calendarNewDate.getTime();
+    //        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+    //        String oneMOnthDate = sdf.format(one_month_ago);
+    //        String nowDate = sdf.format(newDate);
+    //        logger.error("PunchCardRecordEx----oneMOnthDate--" + oneMOnthDate);
+    //        logger.error("PunchCardRecordEx----nowDate--" + nowDate);
+    //        int success = 0;
+    //        int error = 0;
+    //        // 执行查询语句
+    //        //String query = "select \n" +
+    //        //        "userinfo.SSN as personNumber ,\n" +
+    //        //        "checkin.CHECKTIME as checkTime\n" +
+    //        //        "from  checkinout as checkin\n" +
+    //        //        "left join USERINFO as userinfo on userinfo.USERID = checkin.USERID\n" +
+    //        //        "where checkin.CHECKTIME >='" + oneMOnthDate + "' and checkin.CHECKTIME <='" + nowDate + "'\n";
+    //        String query = "\n" +
+    //                " \n" +
+    //                "select \n" +
+    //                "userinfo.SSN as personNumber ,\n" +
+    //                "checkin.CHECKTIME as checkTime\n" +
+    //                "from  checkinout as checkin\n" +
+    //                "left join USERINFO as userinfo on userinfo.USERID = checkin.USERID\n" +
+    //                "where checkin.CHECKTIME >='2024-10-30' and checkin.CHECKTIME <='2024-10-31'\n" +
+    //                " ";
+    //        ResultSet resultSet = statement.executeQuery(query);
+    //        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();
+    //
+    //        // 处理查询结果
+    //        while (resultSet.next()) {
+    //            ++success;
+    //            String personNumber = resultSet.getString("personNumber");//员工编码
+    //            String punchCardDate = resultSet.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.mobileRegistration);
+    //                // 打卡位置
+    //                cardInfo.setPunchCardPlace("考勤机打卡");
+    //                // 有效
+    //                cardInfo.setPunchCardState(PunchCardStateEnum.normal);
+    //                ////简称
+    //                //cardInfo.setSimpleName(exceptionType);
+    //                //描述
+    //                //cardInfo.setDescription(exceptionType);
+    //
+    //                EquNoSet.add("001");
+    //                if (!StringUtils.isEmpty(personNumber)) {
+    //                    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(resultSet);
+    //            }
+    //        }
+    //        // 考勤档案
+    //        Map<String, AttendanceFileInfo> attendanceFileMap = AttendanceFileFactory.getLocalInstance(ctx).getPersonByAttendanceNum(setCardId);
+    //        logger.error("attendanceFileMap-----" + attendanceFileMap);
+    //        //相同的数据
+    //        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.mobileRegistration);
+    //                    // 考勤实体
+    //                    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);
+    //        JSONUtils.SUCCESS(iObjectPKS);
+    //        // 关闭连接
+    //        resultSet.close();
+    //        statement.close();
+    //        connection.close();
+    //
+    //    } catch (Exception e) {
+    //        e.printStackTrace();
+    //    }
+    //}
+    //
+    //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;
+    //
+    //}
+
+}