From fb1a3d76131a0ff72605535d75466ca3223cb1cc Mon Sep 17 00:00:00 2001 From: TS-QD1 Date: Tue, 17 Oct 2023 12:57:17 +0800 Subject: [PATCH] =?UTF-8?q?=E6=A1=88=E4=BB=B6=E5=A4=84=E7=90=86=E3=80=81?= =?UTF-8?q?=E8=B0=83=E5=BA=A6=E5=91=98=E8=B0=83=E5=BA=A624=E5=B0=8F?= =?UTF-8?q?=E6=97=B6=E6=8E=92=E9=99=A4=E8=8A=82=E5=81=87=E6=97=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cm/bigdata/dao/kpi/IKpiHolidayDao.java | 2 ++ .../service/kpi/impl/KpiKhxzServiceImpl.java | 4 +++ .../task/sub/KpiKhxzWgyEGIKRTRunnable.java | 9 ++--- .../sub/KpiKhxzWgyEGIKRTUserRunnable.java | 8 ++--- .../java/com/cm/bigdata/task/BigDataTask.java | 23 +++++++++++++ .../java/com/cm/bigdata/utils/KpiUtil.java | 28 +++++++++++++--- .../mybatis/mapper/kpi/kpi-holiday-mapper.xml | 33 +++++++++++++++++++ 7 files changed, 95 insertions(+), 12 deletions(-) diff --git a/src/main/java/com/cm/bigdata/dao/kpi/IKpiHolidayDao.java b/src/main/java/com/cm/bigdata/dao/kpi/IKpiHolidayDao.java index 5e59ec1..9bde794 100644 --- a/src/main/java/com/cm/bigdata/dao/kpi/IKpiHolidayDao.java +++ b/src/main/java/com/cm/bigdata/dao/kpi/IKpiHolidayDao.java @@ -11,4 +11,6 @@ public interface IKpiHolidayDao { List list(Map params); + Integer count(Map params); + } diff --git a/src/main/java/com/cm/bigdata/service/kpi/impl/KpiKhxzServiceImpl.java b/src/main/java/com/cm/bigdata/service/kpi/impl/KpiKhxzServiceImpl.java index 84fac83..d997c1d 100644 --- a/src/main/java/com/cm/bigdata/service/kpi/impl/KpiKhxzServiceImpl.java +++ b/src/main/java/com/cm/bigdata/service/kpi/impl/KpiKhxzServiceImpl.java @@ -193,6 +193,10 @@ public class KpiKhxzServiceImpl extends AbstractService implements IKpiKhxzServi Double score = kpiKhxzWgyDTO.getaE(); if (score <= 100 && score >= 85) { kpiKhxzWgyDTO.setaF(333 * kpiKhxzWgyDTO.getGridCount() + "(" + 500 * kpiKhxzWgyDTO.getGridCount() + ")"); + } else if (score >= 75) { + kpiKhxzWgyDTO.setaF(333 * kpiKhxzWgyDTO.getGridCount() + "(" + 333 * kpiKhxzWgyDTO.getGridCount() + ")"); + } else if (score >= 60) { + kpiKhxzWgyDTO.setaF(333 * kpiKhxzWgyDTO.getGridCount() + "(" + 233 * kpiKhxzWgyDTO.getGridCount() + ")"); } else { kpiKhxzWgyDTO.setaF(333 * kpiKhxzWgyDTO.getGridCount() + "(0)"); } diff --git a/src/main/java/com/cm/bigdata/service/kpi/task/sub/KpiKhxzWgyEGIKRTRunnable.java b/src/main/java/com/cm/bigdata/service/kpi/task/sub/KpiKhxzWgyEGIKRTRunnable.java index 401f937..49be3f2 100644 --- a/src/main/java/com/cm/bigdata/service/kpi/task/sub/KpiKhxzWgyEGIKRTRunnable.java +++ b/src/main/java/com/cm/bigdata/service/kpi/task/sub/KpiKhxzWgyEGIKRTRunnable.java @@ -42,7 +42,7 @@ public class KpiKhxzWgyEGIKRTRunnable implements Runnable { List holidayPOS = listHoliday(); List> dayWeeks = KpiUtil.listDayWeekOfMonth(year, month); List>[] reportDayWeeks = listShouldReportDayWeek(holidayPOS, dayWeeks); - updateEGIKRT(userIds, reportDayWeeks[0], reportDayWeeks[1]); + updateEGIKRT(userIds, reportDayWeeks[0], reportDayWeeks[1], holidayPOS); KpiUpdateMonitor.getInstance().complete(); } @@ -83,7 +83,7 @@ public class KpiKhxzWgyEGIKRTRunnable implements Runnable { return new List[]{shouldReportDayWeeks, unShouldReportDayWeeks}; } - private void updateEGIKRT(List userIds, List> shouldReportDayWeeks, List> unShouldReportDayWeeks) { + private void updateEGIKRT(List userIds, List> shouldReportDayWeeks, List> unShouldReportDayWeeks, List holidayPOS) { userIds.forEach(userId -> { try { int shouldCount = shouldReportDayWeeks.size(); @@ -128,7 +128,8 @@ public class KpiKhxzWgyEGIKRTRunnable implements Runnable { continue; } // 处理时间和检查时间超过24小时 - if (!KpiUtil.isdateTimeIn24Hours(gmtHandle, gmtInspect)) { + // 排除期间的假期 + if (!KpiUtil.isdateTimeIn24HoursNoHoliday(gmtHandle, gmtInspect, holidayPOS)) { inspectTimeoutCount++; } exceedCount++; @@ -164,7 +165,7 @@ public class KpiKhxzWgyEGIKRTRunnable implements Runnable { continue; } // 处理时间和检查时间超过24小时 - if (!KpiUtil.isdateTimeIn24Hours(gmtHandle, gmtInspect)) { + if (!KpiUtil.isdateTimeIn24HoursNoHoliday(gmtHandle, gmtInspect, holidayPOS)) { inspectTimeoutCount++; } realityCount++; diff --git a/src/main/java/com/cm/bigdata/service/kpi/task/sub/KpiKhxzWgyEGIKRTUserRunnable.java b/src/main/java/com/cm/bigdata/service/kpi/task/sub/KpiKhxzWgyEGIKRTUserRunnable.java index a46f593..6c13e30 100644 --- a/src/main/java/com/cm/bigdata/service/kpi/task/sub/KpiKhxzWgyEGIKRTUserRunnable.java +++ b/src/main/java/com/cm/bigdata/service/kpi/task/sub/KpiKhxzWgyEGIKRTUserRunnable.java @@ -42,7 +42,7 @@ public class KpiKhxzWgyEGIKRTUserRunnable implements Runnable { List holidayPOS = listHoliday(); List> dayWeeks = KpiUtil.listDayWeekOfMonth(year, month); List>[] reportDayWeeks = listShouldReportDayWeek(holidayPOS, dayWeeks); - updateEGIKRT(userId, reportDayWeeks[0], reportDayWeeks[1]); + updateEGIKRT(userId, reportDayWeeks[0], reportDayWeeks[1], holidayPOS); KpiUpdateMonitor.getInstance().complete(); } @@ -83,7 +83,7 @@ public class KpiKhxzWgyEGIKRTUserRunnable implements Runnable { return new List[]{shouldReportDayWeeks, unShouldReportDayWeeks}; } - private void updateEGIKRT(String userId, List> shouldReportDayWeeks, List> unShouldReportDayWeeks) { + private void updateEGIKRT(String userId, List> shouldReportDayWeeks, List> unShouldReportDayWeeks, List holidayPOS) { int shouldCount = shouldReportDayWeeks.size(); // 网格数量 Integer gridCount = userGridService.countUserGrid(userId); @@ -126,7 +126,7 @@ public class KpiKhxzWgyEGIKRTUserRunnable implements Runnable { continue; } // 处理时间和检查时间超过24小时 - if (!KpiUtil.isdateTimeIn24Hours(gmtHandle, gmtInspect)) { + if (!KpiUtil.isdateTimeIn24HoursNoHoliday(gmtHandle, gmtInspect, holidayPOS)) { inspectTimeoutCount++; } // 检查时间复合规定 @@ -163,7 +163,7 @@ public class KpiKhxzWgyEGIKRTUserRunnable implements Runnable { continue; } // 处理时间和检查时间超过24小时 - if (!KpiUtil.isdateTimeIn24Hours(gmtHandle, gmtInspect)) { + if (!KpiUtil.isdateTimeIn24HoursNoHoliday(gmtHandle, gmtInspect, holidayPOS)) { inspectTimeoutCount++; } realityCount++; diff --git a/src/main/java/com/cm/bigdata/task/BigDataTask.java b/src/main/java/com/cm/bigdata/task/BigDataTask.java index a37fb4e..40f9dc0 100644 --- a/src/main/java/com/cm/bigdata/task/BigDataTask.java +++ b/src/main/java/com/cm/bigdata/task/BigDataTask.java @@ -1,7 +1,9 @@ package com.cm.bigdata.task; import com.cm.bigdata.dao.kpi.IKpiDao; +import com.cm.bigdata.dao.kpi.IKpiHolidayDao; import com.cm.bigdata.pojo.pos.kpi.CaseAssignPO; +import com.cm.bigdata.pojo.pos.kpi.HolidayPO; import com.cm.bigdata.pojo.pos.kpi.ReportCasePO; import com.cm.bigdata.service.kpi.IReportCaseService; import com.cm.common.utils.DateUtil; @@ -34,6 +36,8 @@ public class BigDataTask { private IKpiDao kpiDao; @Autowired private IReportCaseService reportCaseService; + @Autowired + private IKpiHolidayDao kpiHolidayDao; // 每10分钟执行一次 @@ -67,6 +71,8 @@ public class BigDataTask { List updates = new ArrayList<>(); // 已经删除的数据 List deleteCaseIds = new ArrayList<>(); + // 是否是假期 + boolean isHoliday = isHoliday(nowDateTime); reportCasePOS.forEach(reportCasePO -> { if (reportCasePO.getIsDelete() == 1) { deleteCaseIds.add(reportCasePO.getReportCaseId()); @@ -91,6 +97,10 @@ public class BigDataTask { // 判断是否超过24小时 LocalDateTime gmtCreateDateTime = LocalDateTime.parse(existCaseAssignPO.getGmtCreate().substring(0, 18), dateTimeFormatter); if (Hours.hoursBetween(gmtCreateDateTime, nowDateTime).getHours() >= 24) { + // 如果当天是假期,不记录 + if (isHoliday) { + return; + } // 超过24小时标记为已超时 caseAssignPO.setGmtModified(DateUtil.getTime()); caseAssignPO.setIsTimeout(1); @@ -126,4 +136,17 @@ public class BigDataTask { } } + private boolean isHoliday(LocalDateTime nowDateTime) { + Map params = new HashMap<>(); + params.put("holidayYear", nowDateTime.getYear()); + params.put("holidayMonth", nowDateTime.getMonthOfYear()); + List holidayPOS = kpiHolidayDao.list(params); + for (HolidayPO holidayPO : holidayPOS) { + if (holidayPO.getHolidayDay() == nowDateTime.getDayOfMonth()) { + return true; + } + } + return false; + } + } diff --git a/src/main/java/com/cm/bigdata/utils/KpiUtil.java b/src/main/java/com/cm/bigdata/utils/KpiUtil.java index 450753a..e7db00d 100644 --- a/src/main/java/com/cm/bigdata/utils/KpiUtil.java +++ b/src/main/java/com/cm/bigdata/utils/KpiUtil.java @@ -1,5 +1,6 @@ package com.cm.bigdata.utils; +import com.cm.bigdata.dao.kpi.IKpiHolidayDao; import com.cm.bigdata.dao2.kpi.IUserGridDao; import com.cm.bigdata.pojo.pos.kpi.*; import com.cm.bigdata.service.kpi.*; @@ -9,6 +10,8 @@ import com.cm.common.utils.point.PointUtil; import org.apache.commons.lang3.StringUtils; import org.joda.time.DateTime; import org.joda.time.Hours; +import org.joda.time.LocalDate; +import org.joda.time.LocalDateTime; import org.joda.time.format.DateTimeFormat; import java.util.*; @@ -20,20 +23,37 @@ public class KpiUtil { public static String ZF_DEPARTMENT_ID = "1d74dfc8-f3a3-4517-87fe-7acf7891bab4"; public static String GA_DEPARTMENT_ID = "2da5c4db-209b-4c28-bf35-153535fdfc78"; - public static boolean isdateTimeIn24Hours(String date1, DateTime date2) { + public static boolean isdateTimeIn24Hours(String date1, LocalDateTime date2) { date1 = date1.split("\\.")[0]; - DateTime date1DateTime = DateTime.parse(date1, DateTimeFormat.forPattern(ISystemConstant.DATE_FORMATTER_YYYY_MM_DD_HH_MM_SS)); + LocalDateTime date1DateTime = LocalDateTime.parse(date1, DateTimeFormat.forPattern(ISystemConstant.DATE_FORMATTER_YYYY_MM_DD_HH_MM_SS)); return Hours.hoursBetween(date1DateTime, date2).getHours() < 24; } public static boolean isdateTimeIn24Hours(String date1, String date2) { date1 = date1.split("\\.")[0]; date2 = date2.split("\\.")[0]; - DateTime date1DateTime = DateTime.parse(date1, DateTimeFormat.forPattern(ISystemConstant.DATE_FORMATTER_YYYY_MM_DD_HH_MM_SS)); - DateTime date2DateTime = DateTime.parse(date2, DateTimeFormat.forPattern(ISystemConstant.DATE_FORMATTER_YYYY_MM_DD_HH_MM_SS)); + LocalDateTime date1DateTime = LocalDateTime.parse(date1, DateTimeFormat.forPattern(ISystemConstant.DATE_FORMATTER_YYYY_MM_DD_HH_MM_SS)); + LocalDateTime date2DateTime = LocalDateTime.parse(date2, DateTimeFormat.forPattern(ISystemConstant.DATE_FORMATTER_YYYY_MM_DD_HH_MM_SS)); return Hours.hoursBetween(date1DateTime, date2DateTime).getHours() < 24; } + public static boolean isdateTimeIn24HoursNoHoliday(String date1, String date2, List holidayPOS) { + date1 = date1.split("\\.")[0]; + date2 = date2.split("\\.")[0]; + LocalDateTime date1DateTime = LocalDateTime.parse(date1, DateTimeFormat.forPattern(ISystemConstant.DATE_FORMATTER_YYYY_MM_DD_HH_MM_SS)); + LocalDateTime date2DateTime = LocalDateTime.parse(date2, DateTimeFormat.forPattern(ISystemConstant.DATE_FORMATTER_YYYY_MM_DD_HH_MM_SS)); + LocalDateTime now = LocalDateTime.now(); + int holidayCount = 0; + for (HolidayPO holidayPO : holidayPOS) { + String holiday = String.format("%04d-%02d-%02d %02d:%02d:%02d", holidayPO.getHolidayYear(), holidayPO.getHolidayMonth(), holidayPO.getHolidayDay(), now.hourOfDay().get(), now.minuteOfHour().get(), now.secondOfMinute().get()); + LocalDateTime holidayDateTime = LocalDateTime.parse(holiday, DateTimeFormat.forPattern(ISystemConstant.DATE_FORMATTER_YYYY_MM_DD_HH_MM_SS)); + if (date1DateTime.isBefore(holidayDateTime) && date2DateTime.isAfter(holidayDateTime)) { + holidayCount++; + } + } + return Hours.hoursBetween(date1DateTime, date2DateTime).getHours() - holidayCount * 24 < 24; + } + public static boolean isDateBetween(String date, String startDate, String endDate) { if (StringUtils.isBlank(date)) { return false; diff --git a/src/main/resources/mybatis/mapper/kpi/kpi-holiday-mapper.xml b/src/main/resources/mybatis/mapper/kpi/kpi-holiday-mapper.xml index 3834c56..debef4e 100644 --- a/src/main/resources/mybatis/mapper/kpi/kpi-holiday-mapper.xml +++ b/src/main/resources/mybatis/mapper/kpi/kpi-holiday-mapper.xml @@ -33,4 +33,37 @@ + + + + \ No newline at end of file