|
@@ -0,0 +1,95 @@
|
|
|
|
|
+package nckd.jxccl.base.wtc.helper;
|
|
|
|
|
+
|
|
|
|
|
+import kd.bos.dataentity.entity.DynamicObject;
|
|
|
|
|
+import kd.bos.dataentity.entity.DynamicObjectCollection;
|
|
|
|
|
+import kd.bos.logging.Log;
|
|
|
|
|
+import kd.bos.logging.LogFactory;
|
|
|
|
|
+import kd.bos.orm.query.QCP;
|
|
|
|
|
+import kd.bos.orm.query.QFilter;
|
|
|
|
|
+import kd.hr.hbp.business.servicehelper.HRBaseServiceHelper;
|
|
|
|
|
+import nckd.jxccl.base.common.constant.FormConstant;
|
|
|
|
|
+import nckd.jxccl.base.orm.helper.QFilterCommonHelper;
|
|
|
|
|
+
|
|
|
|
|
+import java.util.Date;
|
|
|
|
|
+import java.util.List;
|
|
|
|
|
+import java.util.Set;
|
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
+
|
|
|
|
|
+/**
|
|
|
|
|
+ * Tyx 2025-11-28
|
|
|
|
|
+ * 考勤帮助类
|
|
|
|
|
+ */
|
|
|
|
|
+public class WTCHelper {
|
|
|
|
|
+
|
|
|
|
|
+ private static final Log logger = LogFactory.getLog(WTCHelper.class);
|
|
|
|
|
+ public static final HRBaseServiceHelper HOLIDAYFOROT_HELPER = new HRBaseServiceHelper("nckd_holidayforot");
|
|
|
|
|
+ public static final HRBaseServiceHelper OTBILL_HELPER = new HRBaseServiceHelper("wtom_overtimeapplybill");
|
|
|
|
|
+ public static final HRBaseServiceHelper OTTYPE_HELPER = new HRBaseServiceHelper("wtbd_ottype");
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 根据组织ID列表获取关键岗位信息
|
|
|
|
|
+ * @param orgIds 组织ID列表
|
|
|
|
|
+ * @return
|
|
|
|
|
+ */
|
|
|
|
|
+ public static List<Long> getKeyPositionByOrg (List<Long> orgIds) {
|
|
|
|
|
+ QFilter filter = new QFilter("nckd_iskeypos", QCP.equals, "1");
|
|
|
|
|
+ filter.and(QFilterCommonHelper.getCurrentVersionFilter());
|
|
|
|
|
+ filter.and("adminorg.id", QCP.in, orgIds);
|
|
|
|
|
+ HRBaseServiceHelper helper = new HRBaseServiceHelper(FormConstant.HBPM_POSITIONHR);
|
|
|
|
|
+ DynamicObjectCollection positions = helper.queryOriginalCollection("id", filter.toArray());
|
|
|
|
|
+ return positions.stream().map(position -> position.getLong("id")).collect(Collectors.toList());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 根据考勤档案ID获取二级单位编码
|
|
|
|
|
+ * @param attFileId
|
|
|
|
|
+ */
|
|
|
|
|
+ public static String getSecondOrgNumberByAttFileId (Long attFileId) {
|
|
|
|
|
+ QFilter filter = new QFilter ("id", QCP.equals, attFileId);
|
|
|
|
|
+ String selectFields = "adminorg.nckd_secondorg.number";
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 根据加班归属日期获取假期
|
|
|
|
|
+ *
|
|
|
|
|
+ * @return
|
|
|
|
|
+ */
|
|
|
|
|
+ public static DynamicObject getHolidayByOtDutyDate (Date otDutyDate) {
|
|
|
|
|
+ QFilter filter = new QFilter("nckd_startdate", QCP.less_equals, otDutyDate);
|
|
|
|
|
+ filter.and("nckd_enddate", QCP.large_equals, otDutyDate);
|
|
|
|
|
+ DynamicObject dyn = HOLIDAYFOROT_HELPER.queryOriginalOne("name, nckd_startdate, nckd_enddate, nckd_holidays", filter.toArray());
|
|
|
|
|
+ return dyn;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 根据起止日期+考勤档案+排除ID获取加班日期的天数
|
|
|
|
|
+ * 如果加班单为yyyy-MM-dd 18:00:00 至 yyyy-MM-dd 19:00:00,不管实际加班小时,计作一天
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param startDate
|
|
|
|
|
+ * @param endDate
|
|
|
|
|
+ * @param attfileId
|
|
|
|
|
+ * @param billId
|
|
|
|
|
+ * @return
|
|
|
|
|
+ */
|
|
|
|
|
+ public static int getOTDays(Date startDate, Date endDate, Long attfileId, Long billId) {
|
|
|
|
|
+ QFilter filter = new QFilter("attfile.id", QCP.equals, attfileId);
|
|
|
|
|
+ filter.and("id", QCP.not_equals, billId);
|
|
|
|
|
+ filter.and("sdentry.otdutydate", QCP.large_equals, startDate);
|
|
|
|
|
+ filter.and("sdentry.otdutydate", QCP.less_equals, endDate);
|
|
|
|
|
+ DynamicObjectCollection cols = OTBILL_HELPER.queryOriginalCollection("id,sdentry.otdutydate", filter.toArray());
|
|
|
|
|
+ Set<Date> dateSet = cols.stream().map(dyn -> dyn.getDate("sdentry.otdutydate")).collect(Collectors.toSet());
|
|
|
|
|
+ return dateSet.size();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 获取加班类型
|
|
|
|
|
+ * @param number 加班类型编码
|
|
|
|
|
+ * @return
|
|
|
|
|
+ */
|
|
|
|
|
+ public static DynamicObject getSdOtType (String number) {
|
|
|
|
|
+ QFilter filter = new QFilter("number", QCP.equals, number);
|
|
|
|
|
+ return OTTYPE_HELPER.loadOne(filter.toArray());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+}
|