yuanzhi_kuang 4 miesięcy temu
rodzic
commit
63700ea7af

+ 27 - 8
src/com/kingdee/eas/custom/synctask/SyncTranForAtsFacadeControllerBean.java

@@ -79,7 +79,7 @@ public class SyncTranForAtsFacadeControllerBean extends AbstractSyncTranForAtsFa
         if(!StringUtils.isEmpty(beginDate) ){
             //开始日期字定义,结束日期都是今天
             start = LocalDate.parse(beginDate, dateFormatter);
-        } 
+        }
         if(!StringUtils.isEmpty(endDate)){
             //开始日期,结束日期都是今天
             end = LocalDate.parse(endDate, dateFormatter);
@@ -123,7 +123,7 @@ public class SyncTranForAtsFacadeControllerBean extends AbstractSyncTranForAtsFa
                         logger.error("日期 " + dayStr + " 打卡同步接口,接口共传输记录数: " + items.size()+"条数据");
                         saveMJPunchCardData(ctx, items);
                     }else {
-                    	System.out.print("打卡,考勤,接口获取错误!");
+                        System.out.print("打卡,考勤,接口获取错误!");
                     }
                 }
             } catch (Exception e) {
@@ -186,7 +186,7 @@ public class SyncTranForAtsFacadeControllerBean extends AbstractSyncTranForAtsFa
 
             //获取员工编码
             IPerson iPerson = PersonFactory.getLocalInstance(ctx);
-            PersonCollection personCollection = iPerson.getPersonCollection("select number ");
+            PersonCollection personCollection = iPerson.getPersonCollection("select number ,id ");
             Set<String> persNoSet = new HashSet();
             HashMap<String,PersonInfo> persInfoMap = new HashMap();
             for (int i = 0; i < personCollection.size(); i++) {
@@ -235,6 +235,10 @@ public class SyncTranForAtsFacadeControllerBean extends AbstractSyncTranForAtsFa
                 // 处理数据
                 if (punchDate != null && punchCardTime != null) {
                     PunchCardRecordInfo cardInfo = new PunchCardRecordInfo();
+                    PunchCardRecordCollection punchCardRecordCollection = PunchCardRecordFactory.getLocalInstance(ctx).getPunchCardRecordCollection("where number = '"+attId+"'");
+                    if(punchCardRecordCollection.size()>0) {
+                        cardInfo = punchCardRecordCollection.get(0);
+                    }
                     cardInfo.setNumber(attId);
                     //考勤机编码
                     cardInfo.setEquipmentNum(EquNo);
@@ -265,11 +269,13 @@ public class SyncTranForAtsFacadeControllerBean extends AbstractSyncTranForAtsFa
                         //shr系统存在的人员才添加;
                         if (!persNoSet.contains(personNumber)) {
                             logger.error("打卡同步:personNumber not exist in shr system, personNumber=" + personNumber);
+                            System.out.print("打卡同步:personNumber not exist in shr system, personNumber=" + personNumber);
                             continue;
                         }
                         // 姓名
-                        cardInfo.setProposer(persInfoMap.get(personNumber));
-                        setCardId.add(personNumber);
+                        PersonInfo personInfo = persInfoMap.get(personNumber);
+                        cardInfo.setProposer(personInfo);
+                        setCardId.add(personInfo.getId().toString());
                         cardColl.add(cardInfo);
                     }
                 }
@@ -288,7 +294,19 @@ public class SyncTranForAtsFacadeControllerBean extends AbstractSyncTranForAtsFa
 
     private void syncAttendanceRecords(Set<String> setCardId, CoreBaseCollection  cardColl, Context ctx) throws BOSException, EASBizException {
         // 获取考勤档案
-        Map<String, AttendanceFileInfo> attendanceFileMap = AttendanceFileFactory.getLocalInstance(ctx).getPersonByAttendanceNum(setCardId);
+        Map<String, AttendanceFileInfo> attendanceFileMap = new HashMap();
+        StringBuffer oqlb = new StringBuffer();
+        oqlb.append("select  proposer.number  , id ,attendanceNum,proposer.id,adminOrgUnit.id,adminOrgUnit.name,hrOrgUnit.id,hrOrgUnit.name,attAdminOrgUnit.id,attAdminOrgUnit.name  where proposer.id  in ( ");
+        oqlb.append(AtsUtil.convertSetToString(setCardId));
+        oqlb.append(")");
+        AttendanceFileCollection coll = AttendanceFileFactory.getLocalInstance(ctx) .getAttendanceFileCollection(oqlb.toString());
+        for (int i = 0; i < coll.size(); ++i) {
+            PersonInfo proposer = coll.get(i).getProposer();
+            if(null != proposer ) {
+                attendanceFileMap.put(proposer.getId().toString(), coll.get(i));
+            }
+        }
+//      Map<String, AttendanceFileInfo> attendanceFileMap = AttendanceFileFactory.getLocalInstance(ctx).getPersonByAttendanceNum(setCardId);
         logger.error("attendanceFileMap-----" + attendanceFileMap);
         logger.error("setCardId-----" + setCardId);
         IPerson personIns = PersonFactory.getLocalInstance(ctx);
@@ -311,14 +329,14 @@ public class SyncTranForAtsFacadeControllerBean extends AbstractSyncTranForAtsFa
             map.put("RecTime", HRTimeWebUtils.timestampToString(cardInfo.getPunchCardTime()).substring(11));
 
             // 员工是否有考勤档案
-            if (attendanceFileMap.containsKey(cardInfo.getAttendanceNum())) {
+            if (attendanceFileMap.containsKey(cardInfo.getProposer().getId().toString())) {
                 ++success;
                 // 打卡位置 ,考勤机 的地址
                 cardInfo.setPunchCardPlace(cardInfo.getPunchCardPlace());
                 // 打卡来源
                 cardInfo.setPunchCardSource(PunchCardSourceEnum.attenceMachine);
                 // 考勤实体
-                AttendanceFileInfo attendanceFileInfo = attendanceFileMap.get(cardInfo.getAttendanceNum());
+                AttendanceFileInfo attendanceFileInfo = attendanceFileMap.get(cardInfo.getProposer().getId().toString());
                 // HR 组织
                 cardInfo.setHrOrgUnit(attendanceFileInfo.getHrOrgUnit());
                 // 行政组织
@@ -337,6 +355,7 @@ public class SyncTranForAtsFacadeControllerBean extends AbstractSyncTranForAtsFa
         logger.error("打卡同步保存到hr数量-----" + cardCollFinally.size());
         logger.error("打卡同步符合条件的写入数量-----" + success);
         logger.error("打卡同步时不存在考勤档案---" + notExistRecords);
+        System.out.print("打卡同步时不存在考勤档案---" + notExistRecords);
         logger.error("打卡同步时不存在考勤档案数量-----" + notExistRecords.size());
         logger.error("seccussArray--Size-----" + seccussArray.size());
 //        logger.error("seccussArray-----" + seccussArray);