Przeglądaj źródła

台风单,台风函数

zqy 5 miesięcy temu
rodzic
commit
d52f0ced18

+ 0 - 111
src/com/kingdee/eas/custom/shengsheng/AbstractTimeSheetOfTyphoonInfo.java

@@ -1,119 +1,8 @@
 package com.kingdee.eas.custom.shengsheng;
 
-import java.io.Serializable;
-import com.kingdee.bos.dao.AbstractObjectValue;
-import java.util.Locale;
-import com.kingdee.util.TypeConversionUtils;
 import com.kingdee.bos.util.BOSObjectType;
 
-
-public class AbstractTimeSheetOfTyphoonInfo extends com.kingdee.eas.hr.base.HRBillBaseInfo implements Serializable 
-{
-    public AbstractTimeSheetOfTyphoonInfo()
-    {
-        this("id");
-    }
-    protected AbstractTimeSheetOfTyphoonInfo(String pkField)
-    {
-        super(pkField);
-        put("entrys", new TimeSheetOfTyphoonEntryCollection());
-    }
-    /**
-     * Object: �U�L�� 's ��¼ property 
-     */
-    public TimeSheetOfTyphoonEntryCollection getEntrys()
-    {
-        return (TimeSheetOfTyphoonEntryCollection)get("entrys");
-    }
-    /**
-     * Object: �U�L�� 's ������ property 
-     */
-    public com.kingdee.eas.basedata.person.PersonInfo getApplier()
-    {
-        return (com.kingdee.eas.basedata.person.PersonInfo)get("applier");
-    }
-    public void setApplier(com.kingdee.eas.basedata.person.PersonInfo item)
-    {
-        put("applier", item);
-    }
-    /**
-     * Object:�U�L��'s ��������property 
-     */
-    public java.util.Date getApplyDate()
-    {
-        return getDate("applyDate");
-    }
-    public void setApplyDate(java.util.Date item)
-    {
-        setDate("applyDate", item);
-    }
-    /**
-     * Object:�U�L��'s ����״̬property 
-     */
-    public int getInnerState()
-    {
-        return getInt("innerState");
-    }
-    public void setInnerState(int item)
-    {
-        setInt("innerState", item);
-    }
-    /**
-     * Object: �U�L�� 's ������֯ property 
-     */
-    public com.kingdee.eas.basedata.org.AdminOrgUnitInfo getAdminOrgUnit()
-    {
-        return (com.kingdee.eas.basedata.org.AdminOrgUnitInfo)get("adminOrgUnit");
-    }
-    public void setAdminOrgUnit(com.kingdee.eas.basedata.org.AdminOrgUnitInfo item)
-    {
-        put("adminOrgUnit", item);
-    }
-    /**
-     * Object:�U�L��'s �U�L���Qproperty 
-     */
-    public String getTyphoonName()
-    {
-        return getString("typhoonName");
-    }
-    public void setTyphoonName(String item)
-    {
-        setString("typhoonName", item);
-    }
-    /**
-     * Object:�U�L��'s �_ʼ�r�gproperty 
-     */
-    public java.util.Date getStartTime()
-    {
-        return getDate("startTime");
-    }
-    public void setStartTime(java.util.Date item)
-    {
-        setDate("startTime", item);
-    }
-    /**
-     * Object:�U�L��'s �Y���r�gproperty 
-     */
-    public java.util.Date getEndTime()
-    {
-        return getDate("endTime");
-    }
-    public void setEndTime(java.util.Date item)
-    {
-        setDate("endTime", item);
-    }
-    public BOSObjectType getBOSType()
-    {
-        return new BOSObjectType("85B34E0B");
-    }
-}
-package com.kingdee.eas.custom.shengsheng;
-
 import java.io.Serializable;
-import com.kingdee.bos.dao.AbstractObjectValue;
-import java.util.Locale;
-import com.kingdee.util.TypeConversionUtils;
-import com.kingdee.bos.util.BOSObjectType;
 
 
 public class AbstractTimeSheetOfTyphoonInfo extends com.kingdee.eas.hr.base.HRBillBaseInfo implements Serializable 

+ 237 - 0
src/com/kingdee/eas/hr/ats/function/TyphoonWorkTimeFunction.java

@@ -0,0 +1,237 @@
+package com.kingdee.eas.hr.ats.function;
+
+import com.google.common.collect.Maps;
+import com.kingdee.bos.BOSException;
+import com.kingdee.bos.Context;
+import com.kingdee.eas.common.EASBizException;
+import com.kingdee.eas.hr.ats.*;
+import com.kingdee.eas.hr.ats.app.formula.calculate.data.Tools;
+import com.kingdee.eas.util.app.DbUtil;
+import com.kingdee.jdbc.rowset.IRowSet;
+import org.apache.commons.lang.StringUtils;
+
+import java.sql.SQLException;
+import java.sql.Timestamp;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * description: TyphoonWorkTimeFunction <br>
+ * date: 2025/8/5 10:57 <br>
+ * author: lhbj <br>
+ * version: 1.0 <br>
+ */
+
+//台风应上班时数= max(0,min(一段班次下班时间,台风结束时间)-max(一段班次上班时间,台风开始时间))
+//       + max(0,min(二段班次下班时间,台风结束时间)-max(二段班次上班时间,台风开始时间))
+//       + max(0,min(三段班次下班时间,台风结束时间)-max(三段班次上班时间,台风开始时间))
+//
+//台风实际上班时数= max(0,min(一段班次下班打卡时间,台风结束时间)-max(一段班次上班打卡时间,台风开始时间))
+//        + max(0,min(二段班次下班打卡时间,台风结束时间)-max(二段班次上班打卡时间,台风开始时间))
+//        + max(0,min(三段班次下班打卡时间,台风结束时间)-max(三段班次上班打卡时间,台风开始时间))
+//台风上班时数= min(台风应上班时数,台风实际上班时数)
+public class TyphoonWorkTimeFunction {
+
+    private SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
+    private SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+
+    public double getTyphoonOtTime(Map paramMap, String workOrOt) throws EASBizException, BOSException {
+
+        String personId = (String) paramMap.get("T_HR_ATS_ATTENDANCERESULT_FPROPOSERID");
+        String currDateStr = (String) paramMap.get("T_HR_ATS_ATTENDANCERESULT_FATTENCEDATE");
+        Map globalMap = (Map) paramMap.get("globalMapKey");
+        System.out.println("personId:" + personId + "currDateStr:" + currDateStr);
+        long TyphoonWordUp = 0;
+        long TyphoonWordDw = 0;
+        double typhoon = 0D;
+        try {
+            Context ctx = Tools.getInstance().getCtx();
+            String sqlTy = "select CFStartTime, CFEndTime from CT_SS_TimeSheetOfTyphoon where to_char(CFEndTime,'yyyy-MM-dd') >= '" + currDateStr + "' and to_char(CFStartTime,'yyyy-MM-dd')<='" + currDateStr + "'";
+            IRowSet rowTy = DbUtil.executeQuery(ctx, sqlTy);
+            Date typhoonStart = null;
+            Date typhoonEnd = null;
+            if (rowTy.next()) {
+                typhoonStart = rowTy.getDate("CFStartTime");
+                typhoonEnd = rowTy.getDate("CFEndTime");
+
+                Map<String,List<PunchCardRecordInfo>> punchCardInfoMap = ((Map<String,List<PunchCardRecordInfo>>) globalMap.get("punchCardInfoMap"));
+
+                System.out.println("punchCardInfoMap.size():" + punchCardInfoMap.size());
+                if (punchCardInfoMap != null && punchCardInfoMap.size() > 0) {
+                    List<PunchCardRecordInfo> punchCardInfoList = punchCardInfoMap.get(personId + "_" + currDateStr);
+                    PunchCardRecordInfo s2Info = punchCardInfoList.get(punchCardInfoList.size()-1);
+                    PunchCardRecordInfo s1Info = punchCardInfoList.get(0);
+                    Timestamp s2 = s2Info.getPunchCardTime();
+                    Timestamp s1 = s1Info.getPunchCardTime();
+                    Map<String, List<AtsOverTimeBillEntryInfo>> atsOverTimeBillObject = (Map) globalMap.get("T_HR_ATS_OverTimeBillEntry");
+                    if (atsOverTimeBillObject != null && atsOverTimeBillObject.size() > 0) {
+                        List<AtsOverTimeBillEntryInfo> list = (List) atsOverTimeBillObject.get(personId + "_" + currDateStr);
+                        AtsOverTimeBillEntryInfo atsBillEntryInfo = null;
+                        int listSize = list != null ? list.size() : 0;
+
+                        for (int i = 0; i < listSize; ++i) {
+                            atsBillEntryInfo = (AtsOverTimeBillEntryInfo) list.get(i);
+                            //计算一段班台风时间
+
+                            //计算一段班台风时间
+                            if (null != s1 && null != s2) {
+
+                                    TyphoonWordDw +=
+                                            Math.max(0, Math.min(Math.min(atsBillEntryInfo.getRealEndTime().getTime(), s2.getTime()), typhoonEnd.getTime())
+                                                    - Math.max(Math.max(atsBillEntryInfo.getRealStartTime().getTime(), s1.getTime()), typhoonStart.getTime()));
+
+                            }
+                            System.out.println("TyphoonWordDw3:" + TyphoonWordDw);
+                        }
+                    }
+                }
+            }
+            typhoon = TyphoonWordDw;
+            System.out.println("typhoon.min:" + typhoon);
+            typhoon = Math.round(typhoon / 60D / 60D) / 1000D;
+            System.out.println("typhoon.toHour:" + typhoon);
+        } catch (Exception e) {
+            throw new RuntimeException(e);
+        }
+        return typhoon;
+    }
+
+    public double getTyphoonWorkTime(Map paramMap, String workOrOt) throws EASBizException, BOSException {
+
+        String personId = (String) paramMap.get("T_HR_ATS_ATTENDANCERESULT_FPROPOSERID");
+        String currDateStr = (String) paramMap.get("T_HR_ATS_ATTENDANCERESULT_FATTENCEDATE");
+        Map globalMap = (Map) paramMap.get("globalMapKey");
+        System.out.println("personId:" + personId + "currDateStr:" + currDateStr);
+        long TyphoonWordUp = 0;
+        long TyphoonWordDw = 0;
+        double typhoon = 0D;
+        try {
+            Context ctx = Tools.getInstance().getCtx();
+            String sqlTy = "select CFStartTime, CFEndTime from CT_SS_TimeSheetOfTyphoon where to_char(CFEndTime,'yyyy-MM-dd') >= '" + currDateStr + "' and to_char(CFStartTime,'yyyy-MM-dd')<='" + currDateStr + "'";
+            IRowSet rowTy = DbUtil.executeQuery(ctx, sqlTy);
+            Date typhoonStart = null;
+            Date typhoonEnd = null;
+            if (rowTy.next()) {
+                typhoonStart = rowTy.getDate("CFStartTime");
+                typhoonEnd = rowTy.getDate("CFEndTime");
+
+
+                Map<String, List<ScheduleShiftInfo>> shiftMap = (Map) globalMap.get("T_HR_ATS_ScheduleShift");
+                List<ScheduleShiftInfo> schedulelList = shiftMap != null && shiftMap.size() > 0 ? (List) shiftMap.get(personId + "_" + currDateStr) : null;
+                Map<String, ScheduleShiftItemInfo> scheduleShiftItemMap = Maps.newHashMap();
+
+                int i = 0;
+                int shiftItemSize = 0;
+                ScheduleShiftInfo scheduleShiftInfo = null;
+                ScheduleShiftItemCollection scheduleShiftItemCollection = null;
+                for (int shiftSize = schedulelList != null ? schedulelList.size() : 0; i < shiftSize; ++i) {
+                    scheduleShiftInfo = (ScheduleShiftInfo) schedulelList.get(i);
+                    if (scheduleShiftInfo != null) {
+                        scheduleShiftItemCollection = scheduleShiftInfo.getItems();
+                        shiftItemSize = scheduleShiftItemCollection.size();
+                        ScheduleShiftItemInfo scheduleShiftItemInfo = null;
+
+                        for (int j = 0; j < shiftItemSize; ++j) {
+                            scheduleShiftItemInfo = scheduleShiftItemCollection.get(j);
+                            if (scheduleShiftItemInfo != null) {
+                                scheduleShiftItemMap.put(scheduleShiftItemInfo.getSegment().getValue(), scheduleShiftItemInfo);
+                                if (null != scheduleShiftItemInfo.getRestNextDateTime() && null != scheduleShiftItemInfo.getRestPreDateTime()) {
+                                    TyphoonWordUp += (Math.max(0, Math.min(scheduleShiftItemInfo.getNextDateTime().getTime(), typhoonEnd.getTime())
+                                            - Math.max(scheduleShiftItemInfo.getRestNextDateTime().getTime(), typhoonStart.getTime())))
+                                            +
+                                            Math.max(0, Math.min(scheduleShiftItemInfo.getRestPreDateTime().getTime(), typhoonEnd.getTime())
+                                                    - Math.max(scheduleShiftItemInfo.getPreDateTime().getTime(), typhoonStart.getTime()));
+                                } else {
+                                    TyphoonWordUp += Math.max(0, Math.min(scheduleShiftItemInfo.getNextDateTime().getTime(), typhoonEnd.getTime()) - Math.max(scheduleShiftItemInfo.getPreDateTime().getTime(), typhoonStart.getTime()));
+                                }
+                            }
+                        }
+                    }
+                }
+                System.out.println("TyphoonWordUp:" + TyphoonWordUp);
+                java.sql.Date sqlDate = new java.sql.Date(this.df.parse(currDateStr).getTime());
+                Object[] params = new Object[]{personId, sqlDate};
+                String sql = "select S1,S2,S3,S4,S5,S6 from t_hr_ats_attendanceresult where fproposerid = ? and fattencedate = ?";
+                IRowSet row = DbUtil.executeQuery(ctx, sql, params);
+                System.out.println("row.size():" + row.size());
+                while (row.next()) {
+                    Timestamp s6 = row.getTimestamp("S6");
+                    Timestamp s5 = row.getTimestamp("S5");
+                    Timestamp s4 = row.getTimestamp("S4");
+                    Timestamp s3 = row.getTimestamp("S3");
+                    Timestamp s2 = row.getTimestamp("S2");
+                    Timestamp s1 = row.getTimestamp("S1");
+                    ScheduleShiftItemInfo scheduleShiftItemInfo = null;
+                    if(scheduleShiftItemMap.size()>0) {
+                        //计算一段班台风时间
+                        if (null != s1 && null != s2) {
+                            scheduleShiftItemInfo = scheduleShiftItemMap.get("1");
+                            if (null != scheduleShiftItemInfo.getRestNextDateTime() && null != scheduleShiftItemInfo.getRestPreDateTime()) {
+                                TyphoonWordDw +=
+                                        (Math.max(0, Math.min(Math.min(scheduleShiftItemInfo.getNextDateTime().getTime(), s2.getTime()), typhoonEnd.getTime())
+                                                - Math.max(scheduleShiftItemInfo.getRestNextDateTime().getTime(), typhoonStart.getTime())))
+                                                +
+                                                Math.max(0, Math.min(scheduleShiftItemInfo.getRestPreDateTime().getTime(), typhoonEnd.getTime())
+                                                        - Math.max(Math.max(scheduleShiftItemInfo.getPreDateTime().getTime(), s1.getTime()), typhoonStart.getTime()));
+                            } else {
+                                TyphoonWordDw +=
+                                        Math.max(0, Math.min(Math.min(scheduleShiftItemInfo.getNextDateTime().getTime(), s2.getTime()), typhoonEnd.getTime())
+                                                - Math.max(Math.max(scheduleShiftItemInfo.getPreDateTime().getTime(), s1.getTime()), typhoonStart.getTime()));
+                            }
+                        }
+                        System.out.println("TyphoonWordDw1:" + TyphoonWordDw);
+                        if (null != s3 && null != s4) {
+                            scheduleShiftItemInfo = scheduleShiftItemMap.get("2");
+                            if (null != scheduleShiftItemInfo.getRestNextDateTime() && null != scheduleShiftItemInfo.getRestPreDateTime()) {
+                                TyphoonWordDw +=
+                                        (Math.max(0, Math.min(Math.min(scheduleShiftItemInfo.getNextDateTime().getTime(), s4.getTime()), typhoonEnd.getTime())
+                                                - Math.max(scheduleShiftItemInfo.getRestNextDateTime().getTime(), typhoonStart.getTime())))
+                                                +
+                                                Math.max(0, Math.min(scheduleShiftItemInfo.getRestPreDateTime().getTime(), typhoonEnd.getTime())
+                                                        - Math.max(Math.max(scheduleShiftItemInfo.getPreDateTime().getTime(), s3.getTime()), typhoonStart.getTime()));
+                            } else {
+                                TyphoonWordDw +=
+                                        Math.max(0, Math.min(Math.min(scheduleShiftItemInfo.getNextDateTime().getTime(), s4.getTime()), typhoonEnd.getTime())
+                                                - Math.max(Math.max(scheduleShiftItemInfo.getPreDateTime().getTime(), s3.getTime()), typhoonStart.getTime()));
+                            }
+                        }
+                        System.out.println("TyphoonWordDw2:" + TyphoonWordDw);
+                        if (null != s5 && null != s6) {
+                            scheduleShiftItemInfo = scheduleShiftItemMap.get("3");
+                            if (null != scheduleShiftItemInfo.getRestNextDateTime() && null != scheduleShiftItemInfo.getRestPreDateTime()) {
+                                TyphoonWordDw +=
+                                        (Math.max(0, Math.min(Math.min(scheduleShiftItemInfo.getNextDateTime().getTime(), s6.getTime()), typhoonEnd.getTime())
+                                                - Math.max(scheduleShiftItemInfo.getRestNextDateTime().getTime(), typhoonStart.getTime())))
+                                                +
+                                                Math.max(0, Math.min(scheduleShiftItemInfo.getRestPreDateTime().getTime(), typhoonEnd.getTime())
+                                                        - Math.max(Math.max(scheduleShiftItemInfo.getPreDateTime().getTime(), s5.getTime()), typhoonStart.getTime()));
+                            } else {
+                                TyphoonWordDw +=
+                                        Math.max(0, Math.min(Math.min(scheduleShiftItemInfo.getNextDateTime().getTime(), s6.getTime()), typhoonEnd.getTime())
+                                                - Math.max(Math.max(scheduleShiftItemInfo.getPreDateTime().getTime(), s5.getTime()), typhoonStart.getTime()));
+                            }
+                        }
+                    }
+                    System.out.println("TyphoonWordDw3:" + TyphoonWordDw);
+                }
+
+                typhoon = Math.min(TyphoonWordDw, TyphoonWordUp);
+                System.out.println("typhoon.min:" + typhoon);
+                typhoon = Math.round(typhoon / 60D / 60D) / 1000D;
+                System.out.println("typhoon.toHour:" + typhoon);
+            }
+        } catch (BOSException var18) {
+            var18.printStackTrace();
+        } catch (SQLException var19) {
+            var19.printStackTrace();
+        } catch (ParseException e) {
+            e.printStackTrace();
+        } finally {
+
+        }
+        return typhoon;
+    }
+}

+ 0 - 68
src/com/kingdee/eas/hr/ats/function/fc/TyphoonWorkTimeFunction.java

@@ -1,68 +0,0 @@
-package com.kingdee.eas.hr.ats.function.fc;
-
-import com.kingdee.bos.BOSException;
-import com.kingdee.bos.Context;
-import com.kingdee.eas.common.EASBizException;
-import com.kingdee.eas.hr.ats.ScheduleShiftInfo;
-import com.kingdee.eas.hr.ats.app.formula.calculate.data.Tools;
-import com.kingdee.eas.hr.ats.function.AtsCalFunctionService;
-import com.kingdee.eas.util.app.DbUtil;
-import com.kingdee.jdbc.rowset.IRowSet;
-
-
-import java.sql.SQLException;
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.List;
-import java.util.Map;
-
-/**
- * description: TyphoonWorkTimeFunction <br>
- * date: 2025/8/5 10:57 <br>
- * author: lhbj <br>
- * version: 1.0 <br>
- */
-public class TyphoonWorkTimeFunction extends AtsCalFunctionService {
-
-    private SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
-
-    public double getTyphoonWorkTime(Map paramMap, String workOrOt) throws EASBizException, BOSException {
-
-        String personId = (String)paramMap.get("T_HR_ATS_ATTENDANCERESULT_FPROPOSERID");
-        String currDateStr = (String)paramMap.get("T_HR_ATS_ATTENDANCERESULT_FATTENCEDATE");
-        Map globalMap = (Map)paramMap.get("globalMapKey");
-
-        try {
-            Context ctx = Tools.getInstance().getCtx();
-            java.sql.Date sqlDate = new java.sql.Date(this.df.parse(currDateStr).getTime());
-            Object[] params = new Object[]{personId, sqlDate};
-            String sql = "select S1,S2,S3,S4,S5,S6 from t_hr_ats_attendanceresult where fproposerid = ? and fattencedate = ?";
-            IRowSet row = DbUtil.executeQuery(ctx, sql, params);
-
-            while(row.next()) {
-                if (row.getTimestamp("S6") != null) {
-                    timestamp = row.getTimestamp("S6");
-                } else if (row.getTimestamp("S5") != null) {
-                    timestamp = row.getTimestamp("S5");
-                } else if (row.getTimestamp("S4") != null) {
-                    timestamp = row.getTimestamp("S4");
-                } else if (row.getTimestamp("S3") != null) {
-                    timestamp = row.getTimestamp("S3");
-                } else if (row.getTimestamp("S2") != null) {
-                    timestamp = row.getTimestamp("S2");
-                } else if (row.getTimestamp("S1") != null) {
-                    timestamp = row.getTimestamp("S1");
-                }
-            }
-            Map<String, List<ScheduleShiftInfo>> shiftMap = (Map)globalMap.get("T_HR_ATS_ScheduleShift");
-            List<ScheduleShiftInfo> schedulelList = shiftMap != null && shiftMap.size() > 0 ? (List)shiftMap.get(personId + "_" + currDateStr) : null;
-        } catch (BOSException var18) {
-            var18.printStackTrace();
-        } catch (SQLException var19) {
-            var19.printStackTrace();
-        } catch (ParseException e) {
-            e.printStackTrace();
-        }
-        return 0D;
-    }
-}