diff --git a/src/main/java/com/cm/bigdata/controller/apis/kpi/KpiKhxzController.java b/src/main/java/com/cm/bigdata/controller/apis/kpi/KpiKhxzController.java index 5223280..d28045e 100644 --- a/src/main/java/com/cm/bigdata/controller/apis/kpi/KpiKhxzController.java +++ b/src/main/java/com/cm/bigdata/controller/apis/kpi/KpiKhxzController.java @@ -4,6 +4,7 @@ import com.cm.bigdata.monitor.KpiUpdateMonitor; import com.cm.bigdata.pojo.dtos.kpi.*; import com.cm.bigdata.pojo.vos.kpi.KpiUpdateVO; import com.cm.bigdata.service.kpi.IKpiKhxzService; +import com.cm.bigdata.task.BigDataTask; import com.cm.common.base.AbstractController; import com.cm.common.constants.ISystemConstant; import com.cm.common.exception.UpdateException; @@ -191,4 +192,13 @@ public class KpiKhxzController extends AbstractController { kpiKhxzService.updateWgzTask(year, month); } + + @Autowired + private BigDataTask bigDataTask; + + @GetMapping("ddy-day-work") + public void ddyDayWorkTask() throws Exception { + bigDataTask.ddyDayWorkTask(); + } + } diff --git a/src/main/java/com/cm/bigdata/dao/kpi/IKpiDao.java b/src/main/java/com/cm/bigdata/dao/kpi/IKpiDao.java index 90e4a24..3dec7b6 100644 --- a/src/main/java/com/cm/bigdata/dao/kpi/IKpiDao.java +++ b/src/main/java/com/cm/bigdata/dao/kpi/IKpiDao.java @@ -1,5 +1,6 @@ package com.cm.bigdata.dao.kpi; +import com.cm.bigdata.pojo.pos.kpi.CaseAssignPO; import com.cm.bigdata.pojo.pos.kpi.CasePO; import com.cm.bigdata.pojo.pos.kpi.CommunityBossDayCountPO; import com.cm.bigdata.pojo.pos.kpi.NPersonDayCountPO; @@ -11,6 +12,20 @@ import java.util.Map; @Repository public interface IKpiDao { + void saveCaseAssign(Map params); + + void removeCaseAssign(Map deleteMap); + + + void updateCaseAssign(Map params); + + CaseAssignPO getCaseAssignPO(Map queryMap); + + List listCaseAssignPO(Map params); + + Integer countCaseAssign(Map caseAssignMap); + + void saveCommunityBossDayCount(Map params); void deleteCommunityBossDayCount(Map params); @@ -39,4 +54,6 @@ public interface IKpiDao { Integer sumLeaveTimelong(Map sumLeaveMap); + + } diff --git a/src/main/java/com/cm/bigdata/pojo/dtos/kpi/KpiKhxzDdyDTO.java b/src/main/java/com/cm/bigdata/pojo/dtos/kpi/KpiKhxzDdyDTO.java index 79f2097..4effdf4 100644 --- a/src/main/java/com/cm/bigdata/pojo/dtos/kpi/KpiKhxzDdyDTO.java +++ b/src/main/java/com/cm/bigdata/pojo/dtos/kpi/KpiKhxzDdyDTO.java @@ -87,22 +87,29 @@ public class KpiKhxzDdyDTO implements Serializable { /** * 案件调度数量 */ - @ApiModelProperty("案件调度数量") - @ExcelProperty(value = {"网格案件调度情况", "案件调度", "数量"}, index = 5) + @ApiModelProperty("案件及时调度数量") + @ExcelProperty(value = {"网格案件调度情况", "案件及时调度", "数量"}, index = 5) + @JsonProperty("timelyCount") + private Integer timelyCount; + /** + * 案件调度数量 + */ + @ApiModelProperty("案件未及时调度数量") + @ExcelProperty(value = {"网格案件调度情况", "案件未及时调度", "数量"}, index = 6) @JsonProperty("E") private Integer e; /** * 案件调度扣分 */ @ApiModelProperty("案件调度扣分") - @ExcelProperty(value = {"网格案件调度情况", "案件调度", "扣分"}, index = 6) + @ExcelProperty(value = {"网格案件调度情况", "案件调度", "扣分"}, index = 7) @JsonProperty("F") private Double f; /** * 应调度却未及时调度 */ @ApiModelProperty("应调度却未及时调度") - @ExcelProperty(value = {"网格案件调度情况", "案件调度过程质量", "应调度却未及时调度"}, index = 7) + @ExcelProperty(value = {"网格案件调度情况", "案件调度过程质量", "应调度却未及时调度"}, index = 8) @JsonProperty("G") private Double g; /** @@ -117,7 +124,7 @@ public class KpiKhxzDdyDTO implements Serializable { * 未及时调度案件造成严重影响 */ @ApiModelProperty("未及时调度案件造成严重影响") - @ExcelProperty(value = {"网格案件调度情况", "案件调度过程质量", "未及时调度案件造成严重影响"}, index = 8) + @ExcelProperty(value = {"网格案件调度情况", "案件调度过程质量", "未及时调度案件造成严重影响"}, index = 9) @JsonProperty("H") private Double h; /** @@ -132,7 +139,7 @@ public class KpiKhxzDdyDTO implements Serializable { * 其它情况 */ @ApiModelProperty("其它情况") - @ExcelProperty(value = {"网格案件调度情况", "案件调度过程质量", "其它情况"}, index = 9) + @ExcelProperty(value = {"网格案件调度情况", "案件调度过程质量", "其它情况"}, index = 10) @JsonProperty("I") private Double i; /** @@ -147,7 +154,7 @@ public class KpiKhxzDdyDTO implements Serializable { * 组织评价 */ @ApiModelProperty("组织评价") - @ExcelProperty(value = {"其他工作考核", "组织评价"}, index = 10) + @ExcelProperty(value = {"其他工作考核", "组织评价"}, index = 11) @JsonProperty("J") private Double j; /** @@ -162,21 +169,21 @@ public class KpiKhxzDdyDTO implements Serializable { * 总得分 */ @ApiModelProperty("总得分") - @ExcelProperty(value = {"总得分"}, index = 11) + @ExcelProperty(value = {"总得分"}, index = 12) @JsonProperty("K") private Double k; /** * 应发绩效工资 */ @ApiModelProperty("应发绩效工资") - @ExcelProperty(value = {"应发绩效工资"}, index = 12) + @ExcelProperty(value = {"应发绩效工资"}, index = 13) @JsonProperty("L") private Double l; /** * 实发绩效工资 */ @ApiModelProperty("实发绩效工资") - @ExcelProperty(value = {"实发绩效工资"}, index = 13) + @ExcelProperty(value = {"实发绩效工资"}, index = 14) @JsonProperty("M") private Double m; /** diff --git a/src/main/java/com/cm/bigdata/pojo/pos/kpi/CaseAssignPO.java b/src/main/java/com/cm/bigdata/pojo/pos/kpi/CaseAssignPO.java new file mode 100644 index 0000000..f975152 --- /dev/null +++ b/src/main/java/com/cm/bigdata/pojo/pos/kpi/CaseAssignPO.java @@ -0,0 +1,88 @@ +package com.cm.bigdata.pojo.pos.kpi; + +import io.swagger.models.auth.In; + +public class CaseAssignPO { + + private Long id; + private String caseAssignId; + private String caseId; + private String gmtCreate; + private String gmtModified; + private Integer isTimeout; + private String gmtComplete; + private Integer isComplete; + private Integer isDelete; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getCaseAssignId() { + return caseAssignId; + } + + public void setCaseAssignId(String caseAssignId) { + this.caseAssignId = caseAssignId; + } + + public String getCaseId() { + return caseId; + } + + public void setCaseId(String caseId) { + this.caseId = caseId; + } + + public String getGmtCreate() { + return gmtCreate; + } + + public void setGmtCreate(String gmtCreate) { + this.gmtCreate = gmtCreate; + } + + public String getGmtModified() { + return gmtModified; + } + + public void setGmtModified(String gmtModified) { + this.gmtModified = gmtModified; + } + + public Integer getIsTimeout() { + return isTimeout; + } + + public void setIsTimeout(Integer isTimeout) { + this.isTimeout = isTimeout; + } + + public String getGmtComplete() { + return gmtComplete; + } + + public void setGmtComplete(String gmtComplete) { + this.gmtComplete = gmtComplete; + } + + public Integer getIsComplete() { + return isComplete; + } + + public void setIsComplete(Integer isComplete) { + this.isComplete = isComplete; + } + + public Integer getIsDelete() { + return isDelete; + } + + public void setIsDelete(Integer isDelete) { + this.isDelete = isDelete; + } +} diff --git a/src/main/java/com/cm/bigdata/pojo/pos/kpi/CasePO.java b/src/main/java/com/cm/bigdata/pojo/pos/kpi/CasePO.java index 867f2a8..9748601 100644 --- a/src/main/java/com/cm/bigdata/pojo/pos/kpi/CasePO.java +++ b/src/main/java/com/cm/bigdata/pojo/pos/kpi/CasePO.java @@ -34,6 +34,7 @@ public class CasePO { private Integer isAssign; private Integer isHandle; private Integer isInspect; + private Integer assignTimeoutCount; public String getCaseId() { return caseId; @@ -290,4 +291,12 @@ public class CasePO { public void setIsInspect(Integer isInspect) { this.isInspect = isInspect; } + + public Integer getAssignTimeoutCount() { + return assignTimeoutCount; + } + + public void setAssignTimeoutCount(Integer assignTimeoutCount) { + this.assignTimeoutCount = assignTimeoutCount; + } } diff --git a/src/main/java/com/cm/bigdata/service/kpi/impl/KpiServiceImpl.java b/src/main/java/com/cm/bigdata/service/kpi/impl/KpiServiceImpl.java index 017eb6a..c93afa9 100644 --- a/src/main/java/com/cm/bigdata/service/kpi/impl/KpiServiceImpl.java +++ b/src/main/java/com/cm/bigdata/service/kpi/impl/KpiServiceImpl.java @@ -330,12 +330,13 @@ public class KpiServiceImpl implements IKpiService { LocalDateTime assignDateTime = LocalDateTime.parse(reportCaseAssignPO.getGmtCreate().substring(0, 19), DATE_TIME_FORMATTER); String handleEndTime = assignDateTime.plusHours((int) (reportCaseAssignPO.getHandleTime() * 24)).toString(DATE_TIME_FORMATTER); params.put("handleEndTime", handleEndTime); - // 如果是自处理,处理人为上报人 -// if (StringUtils.equals(reportCasePO.getIsSelf(), "1")) { -// params.put("handleUserId", reportCasePO.getCreator()); -// } else { -// params.put("handleUserId", reportCaseAssignPO.getHandleUserId()); -// } + // 下派超时 + Map caseAssignMap = new HashMap<>(); + caseAssignMap.put("caseId", reportCasePO.getReportCaseId()); + caseAssignMap.put("isTimeout", 1); + Integer count = kpiDao.countCaseAssign(caseAssignMap); + count = count == null ? 0 : count; + params.put("assignTimeoutCount", count); break; } } diff --git a/src/main/java/com/cm/bigdata/service/kpi/task/sub/KpiKhxzDdyEFNRunnable.java b/src/main/java/com/cm/bigdata/service/kpi/task/sub/KpiKhxzDdyEFNRunnable.java index b5eaf19..74158ac 100644 --- a/src/main/java/com/cm/bigdata/service/kpi/task/sub/KpiKhxzDdyEFNRunnable.java +++ b/src/main/java/com/cm/bigdata/service/kpi/task/sub/KpiKhxzDdyEFNRunnable.java @@ -47,19 +47,17 @@ public class KpiKhxzDdyEFNRunnable implements Runnable { updateParams.put("khYear", khYear); updateParams.put("khMonth", khMonth); updateParams.put("userId", userId); - // 超时转派扣分 int assignIn24HoursCount = 0; + // 超时转派扣分 int notAssignIn24HoursCount = 0; for (CasePO casePO : casePOS) { - LocalDateTime reportDateTime = LocalDateTime.parse(casePO.getGmtReport().substring(0, 18), DateTimeFormat.forPattern(ISystemConstant.DATE_FORMATTER_YYYY_MM_DD_HH_MM_SS)); - LocalDateTime assignDateTime = LocalDateTime.parse(casePO.getGmtAssign().substring(0, 18), DateTimeFormat.forPattern(ISystemConstant.DATE_FORMATTER_YYYY_MM_DD_HH_MM_SS)); - int hours = Hours.hoursBetween(reportDateTime, assignDateTime).getHours(); - if (hours > 24) { - notAssignIn24HoursCount++; - } else { + if (casePO.getAssignTimeoutCount() == 0) { assignIn24HoursCount++; + } else { + notAssignIn24HoursCount += casePO.getAssignTimeoutCount(); } } + updateParams.put("timelyCount", assignIn24HoursCount); updateParams.put("E", notAssignIn24HoursCount); updateParams.put("F", notAssignIn24HoursCount * 10); updateParams.put("N", handleCasePOS.size()); diff --git a/src/main/java/com/cm/bigdata/task/BigDataTask.java b/src/main/java/com/cm/bigdata/task/BigDataTask.java new file mode 100644 index 0000000..a37fb4e --- /dev/null +++ b/src/main/java/com/cm/bigdata/task/BigDataTask.java @@ -0,0 +1,129 @@ +package com.cm.bigdata.task; + +import com.cm.bigdata.dao.kpi.IKpiDao; +import com.cm.bigdata.pojo.pos.kpi.CaseAssignPO; +import com.cm.bigdata.pojo.pos.kpi.ReportCasePO; +import com.cm.bigdata.service.kpi.IReportCaseService; +import com.cm.common.utils.DateUtil; +import com.cm.common.utils.HashMapUtil; +import com.cm.common.utils.UUIDUtil; +import org.joda.time.Hours; +import org.joda.time.LocalDateTime; +import org.joda.time.format.DateTimeFormat; +import org.joda.time.format.DateTimeFormatter; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Configuration; +import org.springframework.scheduling.annotation.EnableScheduling; +import org.springframework.scheduling.annotation.Scheduled; +import org.springframework.stereotype.Service; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +@Configuration +@EnableScheduling +@Service +public class BigDataTask { + + private static final Logger LOG = LoggerFactory.getLogger(BigDataTask.class); + @Autowired + private IKpiDao kpiDao; + @Autowired + private IReportCaseService reportCaseService; + + + // 每10分钟执行一次 + @Scheduled(cron = "0 0/10 * * * ?") + public void ddyDayWorkTask() throws Exception { + DateTimeFormatter dateTimeFormatter = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss"); + LocalDateTime nowDateTime = LocalDateTime.now(); + LOG.debug("day work task, {}", nowDateTime.toString(dateTimeFormatter)); + // 统计过去24小时内没有转派的案件 + Map params = new HashMap<>(); + params.put("caseStatus", 2); + // 为下派的案件 + List reportCasePOS = reportCaseService.listPO(params); + Map reportCasePOMap = new HashMap<>(); + reportCasePOS.forEach(reportCasePO -> { + reportCasePOMap.put(reportCasePO.getReportCaseId(), reportCasePO); + }); + params.clear(); + params.put("isComplete", 0); + // 已经保存未完成的调度记录 + List caseAssignPOS = kpiDao.listCaseAssignPO(params); + Map caseAssignPOMap = new HashMap<>(); + caseAssignPOS.forEach(caseAssignPO -> { + caseAssignPOMap.put(caseAssignPO.getCaseId(), caseAssignPO); + }); + // 原先不存在,需要新增的 + List saves = new ArrayList<>(); + // 原先存在,现在不存在,判断为已处理且未超时 + List assigneds = new ArrayList<>(); + // 原先存在,现在依然存在,标记未未处理且已超时 + List updates = new ArrayList<>(); + // 已经删除的数据 + List deleteCaseIds = new ArrayList<>(); + reportCasePOS.forEach(reportCasePO -> { + if (reportCasePO.getIsDelete() == 1) { + deleteCaseIds.add(reportCasePO.getReportCaseId()); + } + CaseAssignPO caseAssignPO = new CaseAssignPO(); + caseAssignPO.setCaseAssignId(UUIDUtil.getUUID()); + caseAssignPO.setCaseId(reportCasePO.getReportCaseId()); + caseAssignPO.setIsDelete(0); + // 获得最后一条未完成的数据 + Map queryMap = new HashMap<>(); + queryMap.put("caseId", reportCasePO.getReportCaseId()); + queryMap.put("isComplete", 0); + CaseAssignPO existCaseAssignPO = kpiDao.getCaseAssignPO(queryMap); + if (existCaseAssignPO == null) { + // 需要新增 + caseAssignPO.setGmtCreate(DateUtil.getTime()); + caseAssignPO.setIsTimeout(0); + caseAssignPO.setIsComplete(0); + saves.add(caseAssignPO); + return; + } + // 判断是否超过24小时 + LocalDateTime gmtCreateDateTime = LocalDateTime.parse(existCaseAssignPO.getGmtCreate().substring(0, 18), dateTimeFormatter); + if (Hours.hoursBetween(gmtCreateDateTime, nowDateTime).getHours() >= 24) { + // 超过24小时标记为已超时 + caseAssignPO.setGmtModified(DateUtil.getTime()); + caseAssignPO.setIsTimeout(1); + updates.add(caseAssignPO); + } + }); + caseAssignPOS.forEach(caseAssignPO -> { + ReportCasePO reportCasePO = reportCasePOMap.get(caseAssignPO.getCaseId()); + if (reportCasePO == null) { + caseAssignPO.setGmtModified(DateUtil.getTime()); + // 原先存在,现在不存在,说明已经转派,标记为完成 + caseAssignPO.setGmtComplete(DateUtil.getTime()); + caseAssignPO.setIsComplete(1); + assigneds.add(caseAssignPO); + } + }); + for (CaseAssignPO caseAssignPO : saves) { + Map map = HashMapUtil.beanToMap(caseAssignPO); + kpiDao.saveCaseAssign(map); + } + for (CaseAssignPO caseAssignPO : updates) { + Map map = HashMapUtil.beanToMap(caseAssignPO); + kpiDao.updateCaseAssign(map); + } + for (CaseAssignPO caseAssignPO : assigneds) { + Map map = HashMapUtil.beanToMap(caseAssignPO); + kpiDao.updateCaseAssign(map); + } + if (!deleteCaseIds.isEmpty()) { + Map deleteMap = new HashMap<>(); + deleteMap.put("caseIds", deleteCaseIds); + kpiDao.removeCaseAssign(deleteMap); + } + } + +} diff --git a/src/main/resources/mybatis/db2-mapper/kpi/report-case-mapper.xml b/src/main/resources/mybatis/db2-mapper/kpi/report-case-mapper.xml index 15528e4..c8ea8ab 100644 --- a/src/main/resources/mybatis/db2-mapper/kpi/report-case-mapper.xml +++ b/src/main/resources/mybatis/db2-mapper/kpi/report-case-mapper.xml @@ -105,6 +105,12 @@ case_source FROM city_report_case + + + AND + case_status = #{caseStatus} + + + SELECT + id, + case_assign_id, + case_id, + gmt_create, + gmt_modified, + gmt_complete, + is_timeout, + is_complete, + is_delete + FROM + kpi_case_assign + WHERE + case_id = #{caseId} + AND + is_complete = #{isComplete} + + + + + + INSERT INTO kpi_community_boss_${level}_day_count( @@ -254,6 +376,7 @@ is_accept, gmt_assign, is_assign, + assign_timeout_count, handle_end_time_long, handle_end_time, gmt_handle, @@ -287,6 +410,7 @@ #{isAccept}, #{gmtAssign}, #{isAssign}, + #{assignTimeoutCount}, #{handleEndTimeLong}, #{handleEndTime}, #{gmtHandle}, @@ -342,7 +466,8 @@ is_accept = #{isAccept}, is_assign = #{isAssign}, is_handle = #{isHandle}, - is_inspect = #{isInspect} + is_inspect = #{isInspect}, + assign_timeout_count = #{assignTimeoutCount} WHERE case_id = #{caseId} @@ -381,7 +506,8 @@ is_accept, is_assign, is_handle, - is_inspect + is_inspect, + assign_timeout_count FROM kpi_case WHERE @@ -472,7 +598,8 @@ is_accept, is_assign, is_handle, - is_inspect + is_inspect, + assign_timeout_count FROM kpi_case @@ -535,7 +662,7 @@ - SELECT SUM(leave_timelong_in_day) FROM