소스 검색

考勤异常代码提交

Heyuan 1 개월 전
부모
커밋
e7ba47c47b

+ 7 - 2
src/com/kingdee/eas/custom/attendanceexception/app/AttendanceExceptionLogControllerBean.java

@@ -8,7 +8,7 @@ import com.kingdee.eas.common.EASBizException;
 import com.kingdee.eas.custom.attendanceexception.AttendanceExceptionLogInfo;
 import org.apache.log4j.Logger;
 
-import java.util.Date;
+import java.util.Calendar;
 
 public class AttendanceExceptionLogControllerBean extends AbstractAttendanceExceptionLogControllerBean {
     private static Logger logger = Logger.getLogger(AttendanceExceptionLogControllerBean.class);
@@ -17,7 +17,12 @@ public class AttendanceExceptionLogControllerBean extends AbstractAttendanceExce
     @Override
     protected IObjectPK _addnew(Context ctx, IObjectValue model) throws BOSException, EASBizException {
         AttendanceExceptionLogInfo info = (AttendanceExceptionLogInfo) model;
-        info.setBizDate(new Date());
+        Calendar calendar = Calendar.getInstance();
+        calendar.set(Calendar.HOUR_OF_DAY, 0);
+        calendar.set(Calendar.MINUTE, 0);
+        calendar.set(Calendar.SECOND, 0);
+        calendar.set(Calendar.MILLISECOND, 0);
+        info.setBizDate(calendar.getTime());
         return super._addnew(ctx, model);
     }
 }

+ 0 - 90
src/com/kingdee/eas/custom/attendanceexception/bean/DingMsgBean.java

@@ -1,90 +0,0 @@
-package com.kingdee.eas.custom.attendanceexception.bean;
-
-import java.util.UUID;
-
-/**
- * @Description TODO
- * @Date 2025/4/17 9:51
- * @Created by Heyuan
- */
-public class DingMsgBean {
-    //消息 id
-    private String msgId;
-    //
-    private String title;
-    private String content;
-    private Boolean toAllUser;
-    private String alertUser;
-    //提醒方式类型,1:工作通知,2:应用消息,3:群消息
-    private Integer alertType;
-
-
-    public DingMsgBean(String msgId, String title, String content, String alertUser) {
-        this.msgId = UUID.randomUUID().toString();
-        this.title = title;
-        this.content = content;
-        this.toAllUser = false;
-        this.alertUser = alertUser;
-        this.alertType = 2;
-    }
-
-    public String getMsgId() {
-        return msgId;
-    }
-
-    public String getTitle() {
-        return title;
-    }
-
-    public String getContent() {
-        return content;
-    }
-
-    public Boolean getToAllUser() {
-        return toAllUser;
-    }
-
-    public String getAlertUser() {
-        return alertUser;
-    }
-
-    public Integer getAlertType() {
-        return alertType;
-    }
-
-    public void setMsgId(String msgId) {
-        this.msgId = msgId;
-    }
-
-    public void setTitle(String title) {
-        this.title = title;
-    }
-
-    public void setContent(String content) {
-        this.content = content;
-    }
-
-    public void setToAllUser(Boolean toAllUser) {
-        this.toAllUser = toAllUser;
-    }
-
-    public void setAlertUser(String alertUser) {
-        this.alertUser = alertUser;
-    }
-
-    public void setAlertType(Integer alertType) {
-        this.alertType = alertType;
-    }
-
-    @Override
-    public String toString() {
-        return "DingMsgBean{" +
-                "msgId='" + msgId + '\'' +
-                ", title='" + title + '\'' +
-                ", content='" + content + '\'' +
-                ", toAllUser=" + toAllUser +
-                ", alertUser='" + alertUser + '\'' +
-                ", alertType=" + alertType +
-                '}';
-    }
-}

+ 34 - 44
src/com/kingdee/eas/custom/attendanceexception/task/AttendanceExceptionFacadeControllerBean.java

@@ -34,26 +34,13 @@ import java.io.IOException;
 import java.lang.String;
 import java.math.BigDecimal;
 import java.sql.SQLException;
-import java.text.MessageFormat;
 import java.text.SimpleDateFormat;
 import java.util.*;
+import java.util.concurrent.TimeUnit;
 
 public class AttendanceExceptionFacadeControllerBean extends AbstractAttendanceExceptionFacadeControllerBean {
     private static Logger logger = Logger.getLogger(AttendanceExceptionFacadeControllerBean.class);
     private Properties propt = new Properties();
-    //通知员工个人消息模板
-    //private static final String NOTIFYEMPLOYEEMSGTEMPLATE = "##### <font color=#6192f2>HR系统</font>\\n#### 考勤异常提醒:\\n您在{0}出现考勤异常,请及时处理! \\n###### (如有审批中的假勤单据,请及时催办)";
-    //通知员工个人消息标题
-    //private static final String NOTIFYEMPLOYEEMSGTITLE = "【考勤异常提醒】";
-    //通知员工个人消息模板
-    //private static final String NOTIFYEMPLOYEECUMULATIVEMSGTEMPLATE = "##### <font color=#6192f2>HR系统</font>\\n#### 员工考勤提醒:\\n您在{0}考勤异常次数已经达到{1}次,请您注意本月考勤 \\n###### (如有审批中的假勤单据,请及时催办)";
-    //通知员工个人消息标题
-    //private static final String NOTIFYEMPLOYEECUMULATIVEMSGTITLE = "【员工考勤提醒】";
-    //通知提醒中心负责人异常消息模板
-    //private static final String NOTIFYALERTLEADEREXCEPTIONMSGTEMPLATE = "##### <font color=#6192f2>HR系统</font>\\n#### 中心考勤异常周报:\\n#####时间:{0}-{1}\\n#####内容:{2}考勤人数{3}人,考勤异常人数{4}人,迟到{5}人,早退{6}人,旷工{7}人 \\n###### (如有审批中的假勤单据,请及时催办)";
-    //通知提醒中心负责人异常消息标题
-    //private static final String NOTIFYALERTLEADEREXCEPTIONMSGTITLE = "【考勤异常周报】";
-
     //来源标识
     private static final String SOURCE = "EHR";
 
@@ -170,7 +157,7 @@ public class AttendanceExceptionFacadeControllerBean extends AbstractAttendanceE
         Date preDay = AtsDateUtils.getPreDay(today);
         logger.error("_notifyEmployeeCumulativeException preDay: " + sdf.format(preDay));
         //查询异常数据
-        Map<String, List<SyncAttendanceDataBean>> exceptionData = getAttendanceExceptionData(ctx, currentFirstDay, preDay, pushTypeEnum, 0);
+        Map<String, List<SyncAttendanceDataBean>> exceptionData = getAttendanceExceptionData(ctx, currentFirstDay, preDay, pushTypeEnum, limit);
         String yearMonth = DateTimeUtils.format(today, "yyyy年MM月");
         for (String personNumber : exceptionData.keySet()) {
             String msgId = UUID.randomUUID().toString();
@@ -362,35 +349,33 @@ public class AttendanceExceptionFacadeControllerBean extends AbstractAttendanceE
             IRowSet iRowSet = DBUtil.executeQuery(ctx, sql);
             Map<String, List<SyncAttendanceDataBean>> result = new HashMap<>();
             Map<String, Integer> personExceptionTimes = new HashMap<>();
-            if (!PushTypeEnum.CENTERLEADERREMINDER.equals(pushType)) {
-                //非中心负责人提醒
-                while (iRowSet.next()) {
-                    //设置考勤结果和次数
-                    SyncAttendanceDataBean data = setAttendanceResult(iRowSet, sdf);
-                    int times = data.getTimes();
-                    String personNumber = data.getEmployeeId();
-                    //累计员工期间总异常次数
-                    if (personExceptionTimes.containsKey(personNumber)) {
-                        Integer i = personExceptionTimes.get(personNumber);
-                        personExceptionTimes.put(personNumber, i + times);
-                    } else {
-                        personExceptionTimes.put(personNumber, times);
-                    }
-                    if (!result.containsKey(personNumber)) {
-                        result.put(personNumber, new ArrayList<>());
-                    }
-                    result.get(personNumber).add(data);
+            //非中心负责人提醒
+            while (iRowSet.next()) {
+                //设置考勤结果和次数
+                SyncAttendanceDataBean data = setAttendanceResult(iRowSet, sdf);
+                int times = data.getTimes();
+                String personNumber = data.getEmployeeId();
+                //累计员工期间总异常次数
+                if (personExceptionTimes.containsKey(personNumber)) {
+                    Integer i = personExceptionTimes.get(personNumber);
+                    personExceptionTimes.put(personNumber, i + times);
+                } else {
+                    personExceptionTimes.put(personNumber, times);
                 }
-                if (PushTypeEnum.EMPLOYEEEXCEPTIONALERT.equals(pushType)) {
-                    String yearMonth = DateTimeUtils.format(startDate, "yyyy年MM月");
-                    //获取提醒记录
-                    Set<String> remindRecord = getRemindRecord(ctx, yearMonth);
-                    //员工累计异常提醒
-                    for (Map.Entry<String, Integer> entry : personExceptionTimes.entrySet()) {
-                        if (entry.getValue() < limit || remindRecord.contains(entry.getKey())) {
-                            //移除没有达到预警上限的数据,获取已经提醒过的人员
-                            result.remove(entry.getKey());
-                        }
+                if (!result.containsKey(personNumber)) {
+                    result.put(personNumber, new ArrayList<>());
+                }
+                result.get(personNumber).add(data);
+            }
+            if (PushTypeEnum.EMPLOYEEEXCEPTIONALERT.equals(pushType)) {
+                String yearMonth = DateTimeUtils.format(startDate, "yyyy年MM月");
+                //获取提醒记录
+                Set<String> remindRecord = getRemindRecord(ctx, yearMonth);
+                //员工累计异常提醒
+                for (Map.Entry<String, Integer> entry : personExceptionTimes.entrySet()) {
+                    if (entry.getValue() < limit || remindRecord.contains(entry.getKey())) {
+                        //移除没有达到预警上限的数据,获取已经提醒过的人员
+                        result.remove(entry.getKey());
                     }
                 }
             }
@@ -683,7 +668,11 @@ public class AttendanceExceptionFacadeControllerBean extends AbstractAttendanceE
             }
             String params = JSON.toJSONString(list);
             logInfo.setDataPushRequest(params);
-            OkHttpClient client = new OkHttpClient();
+            OkHttpClient client = new OkHttpClient.Builder()
+                    .connectTimeout(120, TimeUnit.SECONDS)
+                    .writeTimeout(120, TimeUnit.SECONDS)
+                    .readTimeout(120, TimeUnit.SECONDS)
+                    .build();
             MediaType mediaType = MediaType.parse("application/json");
             RequestBody body = RequestBody.create(mediaType, params);
             Request request = new Request.Builder()
@@ -696,6 +685,7 @@ public class AttendanceExceptionFacadeControllerBean extends AbstractAttendanceE
                     .addHeader("Content-Type", "application/json")
                     .build();
             Response response = client.newCall(request).execute();
+            logger.error("pushAttendanceExceptionData response----" + response.isSuccessful());
             if (response.isSuccessful()) {
                 String resultBody = response.body().string();
                 logInfo.setDataPushResponse(resultBody);