案件处理、调度员调度24小时排除节假日

This commit is contained in:
TS-QD1 2023-10-17 12:57:17 +08:00
parent 610aad4f88
commit fb1a3d7613
7 changed files with 95 additions and 12 deletions

View File

@ -11,4 +11,6 @@ public interface IKpiHolidayDao {
List<HolidayPO> list(Map<String, Object> params); List<HolidayPO> list(Map<String, Object> params);
Integer count(Map<String, Object> params);
} }

View File

@ -193,6 +193,10 @@ public class KpiKhxzServiceImpl extends AbstractService implements IKpiKhxzServi
Double score = kpiKhxzWgyDTO.getaE(); Double score = kpiKhxzWgyDTO.getaE();
if (score <= 100 && score >= 85) { if (score <= 100 && score >= 85) {
kpiKhxzWgyDTO.setaF(333 * kpiKhxzWgyDTO.getGridCount() + "(" + 500 * kpiKhxzWgyDTO.getGridCount() + ")"); 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 { } else {
kpiKhxzWgyDTO.setaF(333 * kpiKhxzWgyDTO.getGridCount() + "(0)"); kpiKhxzWgyDTO.setaF(333 * kpiKhxzWgyDTO.getGridCount() + "(0)");
} }

View File

@ -42,7 +42,7 @@ public class KpiKhxzWgyEGIKRTRunnable implements Runnable {
List<HolidayPO> holidayPOS = listHoliday(); List<HolidayPO> holidayPOS = listHoliday();
List<List<KpiUtil.DayWeek>> dayWeeks = KpiUtil.listDayWeekOfMonth(year, month); List<List<KpiUtil.DayWeek>> dayWeeks = KpiUtil.listDayWeekOfMonth(year, month);
List<List<KpiUtil.DayWeek>>[] reportDayWeeks = listShouldReportDayWeek(holidayPOS, dayWeeks); List<List<KpiUtil.DayWeek>>[] reportDayWeeks = listShouldReportDayWeek(holidayPOS, dayWeeks);
updateEGIKRT(userIds, reportDayWeeks[0], reportDayWeeks[1]); updateEGIKRT(userIds, reportDayWeeks[0], reportDayWeeks[1], holidayPOS);
KpiUpdateMonitor.getInstance().complete(); KpiUpdateMonitor.getInstance().complete();
} }
@ -83,7 +83,7 @@ public class KpiKhxzWgyEGIKRTRunnable implements Runnable {
return new List[]{shouldReportDayWeeks, unShouldReportDayWeeks}; return new List[]{shouldReportDayWeeks, unShouldReportDayWeeks};
} }
private void updateEGIKRT(List<String> userIds, List<List<KpiUtil.DayWeek>> shouldReportDayWeeks, List<List<KpiUtil.DayWeek>> unShouldReportDayWeeks) { private void updateEGIKRT(List<String> userIds, List<List<KpiUtil.DayWeek>> shouldReportDayWeeks, List<List<KpiUtil.DayWeek>> unShouldReportDayWeeks, List<HolidayPO> holidayPOS) {
userIds.forEach(userId -> { userIds.forEach(userId -> {
try { try {
int shouldCount = shouldReportDayWeeks.size(); int shouldCount = shouldReportDayWeeks.size();
@ -128,7 +128,8 @@ public class KpiKhxzWgyEGIKRTRunnable implements Runnable {
continue; continue;
} }
// 处理时间和检查时间超过24小时 // 处理时间和检查时间超过24小时
if (!KpiUtil.isdateTimeIn24Hours(gmtHandle, gmtInspect)) { // 排除期间的假期
if (!KpiUtil.isdateTimeIn24HoursNoHoliday(gmtHandle, gmtInspect, holidayPOS)) {
inspectTimeoutCount++; inspectTimeoutCount++;
} }
exceedCount++; exceedCount++;
@ -164,7 +165,7 @@ public class KpiKhxzWgyEGIKRTRunnable implements Runnable {
continue; continue;
} }
// 处理时间和检查时间超过24小时 // 处理时间和检查时间超过24小时
if (!KpiUtil.isdateTimeIn24Hours(gmtHandle, gmtInspect)) { if (!KpiUtil.isdateTimeIn24HoursNoHoliday(gmtHandle, gmtInspect, holidayPOS)) {
inspectTimeoutCount++; inspectTimeoutCount++;
} }
realityCount++; realityCount++;

View File

@ -42,7 +42,7 @@ public class KpiKhxzWgyEGIKRTUserRunnable implements Runnable {
List<HolidayPO> holidayPOS = listHoliday(); List<HolidayPO> holidayPOS = listHoliday();
List<List<KpiUtil.DayWeek>> dayWeeks = KpiUtil.listDayWeekOfMonth(year, month); List<List<KpiUtil.DayWeek>> dayWeeks = KpiUtil.listDayWeekOfMonth(year, month);
List<List<KpiUtil.DayWeek>>[] reportDayWeeks = listShouldReportDayWeek(holidayPOS, dayWeeks); List<List<KpiUtil.DayWeek>>[] reportDayWeeks = listShouldReportDayWeek(holidayPOS, dayWeeks);
updateEGIKRT(userId, reportDayWeeks[0], reportDayWeeks[1]); updateEGIKRT(userId, reportDayWeeks[0], reportDayWeeks[1], holidayPOS);
KpiUpdateMonitor.getInstance().complete(); KpiUpdateMonitor.getInstance().complete();
} }
@ -83,7 +83,7 @@ public class KpiKhxzWgyEGIKRTUserRunnable implements Runnable {
return new List[]{shouldReportDayWeeks, unShouldReportDayWeeks}; return new List[]{shouldReportDayWeeks, unShouldReportDayWeeks};
} }
private void updateEGIKRT(String userId, List<List<KpiUtil.DayWeek>> shouldReportDayWeeks, List<List<KpiUtil.DayWeek>> unShouldReportDayWeeks) { private void updateEGIKRT(String userId, List<List<KpiUtil.DayWeek>> shouldReportDayWeeks, List<List<KpiUtil.DayWeek>> unShouldReportDayWeeks, List<HolidayPO> holidayPOS) {
int shouldCount = shouldReportDayWeeks.size(); int shouldCount = shouldReportDayWeeks.size();
// 网格数量 // 网格数量
Integer gridCount = userGridService.countUserGrid(userId); Integer gridCount = userGridService.countUserGrid(userId);
@ -126,7 +126,7 @@ public class KpiKhxzWgyEGIKRTUserRunnable implements Runnable {
continue; continue;
} }
// 处理时间和检查时间超过24小时 // 处理时间和检查时间超过24小时
if (!KpiUtil.isdateTimeIn24Hours(gmtHandle, gmtInspect)) { if (!KpiUtil.isdateTimeIn24HoursNoHoliday(gmtHandle, gmtInspect, holidayPOS)) {
inspectTimeoutCount++; inspectTimeoutCount++;
} }
// 检查时间复合规定 // 检查时间复合规定
@ -163,7 +163,7 @@ public class KpiKhxzWgyEGIKRTUserRunnable implements Runnable {
continue; continue;
} }
// 处理时间和检查时间超过24小时 // 处理时间和检查时间超过24小时
if (!KpiUtil.isdateTimeIn24Hours(gmtHandle, gmtInspect)) { if (!KpiUtil.isdateTimeIn24HoursNoHoliday(gmtHandle, gmtInspect, holidayPOS)) {
inspectTimeoutCount++; inspectTimeoutCount++;
} }
realityCount++; realityCount++;

View File

@ -1,7 +1,9 @@
package com.cm.bigdata.task; package com.cm.bigdata.task;
import com.cm.bigdata.dao.kpi.IKpiDao; 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.CaseAssignPO;
import com.cm.bigdata.pojo.pos.kpi.HolidayPO;
import com.cm.bigdata.pojo.pos.kpi.ReportCasePO; import com.cm.bigdata.pojo.pos.kpi.ReportCasePO;
import com.cm.bigdata.service.kpi.IReportCaseService; import com.cm.bigdata.service.kpi.IReportCaseService;
import com.cm.common.utils.DateUtil; import com.cm.common.utils.DateUtil;
@ -34,6 +36,8 @@ public class BigDataTask {
private IKpiDao kpiDao; private IKpiDao kpiDao;
@Autowired @Autowired
private IReportCaseService reportCaseService; private IReportCaseService reportCaseService;
@Autowired
private IKpiHolidayDao kpiHolidayDao;
// 每10分钟执行一次 // 每10分钟执行一次
@ -67,6 +71,8 @@ public class BigDataTask {
List<CaseAssignPO> updates = new ArrayList<>(); List<CaseAssignPO> updates = new ArrayList<>();
// 已经删除的数据 // 已经删除的数据
List<String> deleteCaseIds = new ArrayList<>(); List<String> deleteCaseIds = new ArrayList<>();
// 是否是假期
boolean isHoliday = isHoliday(nowDateTime);
reportCasePOS.forEach(reportCasePO -> { reportCasePOS.forEach(reportCasePO -> {
if (reportCasePO.getIsDelete() == 1) { if (reportCasePO.getIsDelete() == 1) {
deleteCaseIds.add(reportCasePO.getReportCaseId()); deleteCaseIds.add(reportCasePO.getReportCaseId());
@ -91,6 +97,10 @@ public class BigDataTask {
// 判断是否超过24小时 // 判断是否超过24小时
LocalDateTime gmtCreateDateTime = LocalDateTime.parse(existCaseAssignPO.getGmtCreate().substring(0, 18), dateTimeFormatter); LocalDateTime gmtCreateDateTime = LocalDateTime.parse(existCaseAssignPO.getGmtCreate().substring(0, 18), dateTimeFormatter);
if (Hours.hoursBetween(gmtCreateDateTime, nowDateTime).getHours() >= 24) { if (Hours.hoursBetween(gmtCreateDateTime, nowDateTime).getHours() >= 24) {
// 如果当天是假期不记录
if (isHoliday) {
return;
}
// 超过24小时标记为已超时 // 超过24小时标记为已超时
caseAssignPO.setGmtModified(DateUtil.getTime()); caseAssignPO.setGmtModified(DateUtil.getTime());
caseAssignPO.setIsTimeout(1); caseAssignPO.setIsTimeout(1);
@ -126,4 +136,17 @@ public class BigDataTask {
} }
} }
private boolean isHoliday(LocalDateTime nowDateTime) {
Map<String, Object> params = new HashMap<>();
params.put("holidayYear", nowDateTime.getYear());
params.put("holidayMonth", nowDateTime.getMonthOfYear());
List<HolidayPO> holidayPOS = kpiHolidayDao.list(params);
for (HolidayPO holidayPO : holidayPOS) {
if (holidayPO.getHolidayDay() == nowDateTime.getDayOfMonth()) {
return true;
}
}
return false;
}
} }

View File

@ -1,5 +1,6 @@
package com.cm.bigdata.utils; package com.cm.bigdata.utils;
import com.cm.bigdata.dao.kpi.IKpiHolidayDao;
import com.cm.bigdata.dao2.kpi.IUserGridDao; import com.cm.bigdata.dao2.kpi.IUserGridDao;
import com.cm.bigdata.pojo.pos.kpi.*; import com.cm.bigdata.pojo.pos.kpi.*;
import com.cm.bigdata.service.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.apache.commons.lang3.StringUtils;
import org.joda.time.DateTime; import org.joda.time.DateTime;
import org.joda.time.Hours; import org.joda.time.Hours;
import org.joda.time.LocalDate;
import org.joda.time.LocalDateTime;
import org.joda.time.format.DateTimeFormat; import org.joda.time.format.DateTimeFormat;
import java.util.*; import java.util.*;
@ -20,20 +23,37 @@ public class KpiUtil {
public static String ZF_DEPARTMENT_ID = "1d74dfc8-f3a3-4517-87fe-7acf7891bab4"; public static String ZF_DEPARTMENT_ID = "1d74dfc8-f3a3-4517-87fe-7acf7891bab4";
public static String GA_DEPARTMENT_ID = "2da5c4db-209b-4c28-bf35-153535fdfc78"; 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]; 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; return Hours.hoursBetween(date1DateTime, date2).getHours() < 24;
} }
public static boolean isdateTimeIn24Hours(String date1, String date2) { public static boolean isdateTimeIn24Hours(String date1, String date2) {
date1 = date1.split("\\.")[0]; date1 = date1.split("\\.")[0];
date2 = date2.split("\\.")[0]; date2 = date2.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));
DateTime date2DateTime = DateTime.parse(date2, 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; return Hours.hoursBetween(date1DateTime, date2DateTime).getHours() < 24;
} }
public static boolean isdateTimeIn24HoursNoHoliday(String date1, String date2, List<HolidayPO> 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) { public static boolean isDateBetween(String date, String startDate, String endDate) {
if (StringUtils.isBlank(date)) { if (StringUtils.isBlank(date)) {
return false; return false;

View File

@ -33,4 +33,37 @@
</where> </where>
</select> </select>
<select id="count" parameterType="map" resultType="java.lang.Integer">
SELECT
COUNT(*)
FROM
kpi_holiday
<where>
<if test="holidayYears != null and holidayYears.size > 0">
holiday_year IN
<foreach collection="holidayYears" index="index" open="(" separator="," close=")">
#{holidayYears[${index}]}
</foreach>
</if>
<if test="holidayYear != null">
AND
holiday_year = #{holidayYear}
</if>
<if test="holidayMonth != null">
AND
holiday_month = #{holidayMonth}
</if>
<if test="startYear != null and startMonth != null">
AND
holiday_year <![CDATA[>=]]> #{startYear} AND holiday_month <![CDATA[>=]]> #{startMonth}
</if>
<if test="endYear != null and endMonth != null">
AND
holiday_year <![CDATA[<=]]> #{endYear} AND holiday_month <![CDATA[<=]]> #{endMonth}
</if>
</where>
</select>
</mapper> </mapper>