增加调度员当日调度案件超时统计表

This commit is contained in:
TS-QD1 2023-07-28 15:57:34 +08:00
parent 188629696d
commit 5649bf07a3
11 changed files with 421 additions and 27 deletions

View File

@ -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();
}
}

View File

@ -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<String, Object> params);
void removeCaseAssign(Map<String, Object> deleteMap);
void updateCaseAssign(Map<String, Object> params);
CaseAssignPO getCaseAssignPO(Map<String, Object> queryMap);
List<CaseAssignPO> listCaseAssignPO(Map<String, Object> params);
Integer countCaseAssign(Map<String, Object> caseAssignMap);
void saveCommunityBossDayCount(Map<String, Object> params);
void deleteCommunityBossDayCount(Map<String, Object> params);
@ -39,4 +54,6 @@ public interface IKpiDao {
Integer sumLeaveTimelong(Map<String, Object> sumLeaveMap);
}

View File

@ -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;
/**

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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<String, Object> 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;
}
}

View File

@ -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());

View File

@ -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<String, Object> params = new HashMap<>();
params.put("caseStatus", 2);
// 为下派的案件
List<ReportCasePO> reportCasePOS = reportCaseService.listPO(params);
Map<String, ReportCasePO> reportCasePOMap = new HashMap<>();
reportCasePOS.forEach(reportCasePO -> {
reportCasePOMap.put(reportCasePO.getReportCaseId(), reportCasePO);
});
params.clear();
params.put("isComplete", 0);
// 已经保存未完成的调度记录
List<CaseAssignPO> caseAssignPOS = kpiDao.listCaseAssignPO(params);
Map<String, CaseAssignPO> caseAssignPOMap = new HashMap<>();
caseAssignPOS.forEach(caseAssignPO -> {
caseAssignPOMap.put(caseAssignPO.getCaseId(), caseAssignPO);
});
// 原先不存在需要新增的
List<CaseAssignPO> saves = new ArrayList<>();
// 原先存在现在不存在判断为已处理且未超时
List<CaseAssignPO> assigneds = new ArrayList<>();
// 原先存在现在依然存在标记未未处理且已超时
List<CaseAssignPO> updates = new ArrayList<>();
// 已经删除的数据
List<String> 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<String, Object> 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<String, Object> map = HashMapUtil.beanToMap(caseAssignPO);
kpiDao.saveCaseAssign(map);
}
for (CaseAssignPO caseAssignPO : updates) {
Map<String, Object> map = HashMapUtil.beanToMap(caseAssignPO);
kpiDao.updateCaseAssign(map);
}
for (CaseAssignPO caseAssignPO : assigneds) {
Map<String, Object> map = HashMapUtil.beanToMap(caseAssignPO);
kpiDao.updateCaseAssign(map);
}
if (!deleteCaseIds.isEmpty()) {
Map<String, Object> deleteMap = new HashMap<>();
deleteMap.put("caseIds", deleteCaseIds);
kpiDao.removeCaseAssign(deleteMap);
}
}
}

View File

@ -105,6 +105,12 @@
case_source
FROM
city_report_case
<where>
<if test="caseStatus != null">
AND
case_status = #{caseStatus}
</if>
</where>
</select>
<select id="listAcceptPO" parameterType="map" resultMap="reportCaseAcceptPO">

View File

@ -7,6 +7,7 @@
<result column="user_id" property="userId"/>
<result column="kh_year" property="khYear"/>
<result column="kh_month" property="khMonth"/>
<result column="timely_count" property="timelyCount"/>
<result column="A" property="a"/>
<result column="B" property="b"/>
<result column="C" property="c"/>
@ -79,6 +80,7 @@
UPDATE
kpi_khxz_ddy
SET
timely_count = #{timelyCount},
E = #{E},
F = #{F},
N = #{N}

View File

@ -61,8 +61,130 @@
<result column="is_assign" property="isAssign"/>
<result column="is_handle" property="isHandle"/>
<result column="is_inspect" property="isInspect"/>
<result column="assign_timeout_count" property="assignTimeoutCount"/>
</resultMap>
<resultMap id="caseAssignPO" type="com.cm.bigdata.pojo.pos.kpi.CaseAssignPO">
<id column="id" property="id"/>
<result column="case_assign_id" property="caseAssignId"/>
<result column="case_id" property="caseId"/>
<result column="gmt_create" property="gmtCreate"/>
<result column="gmt_modified" property="gmtModified"/>
<result column="isTimeout" property="isTimeout"/>
<result column="isDelete" property="isDelete"/>
</resultMap>
<insert id="saveCaseAssign" parameterType="map">
INSERT INTO kpi_case_assign (
id,
case_assign_id,
case_id,
gmt_create,
gmt_modified,
is_timeout,
is_complete,
is_delete
)
VALUES (
#{id},
#{caseAssignId},
#{caseId},
#{gmtCreate},
#{gmtModified},
#{isTimeout},
#{isComplete},
#{isDelete}
)
</insert>
<update id="removeCaseAssign" parameterType="map">
UPDATE
kpi_case_assign
SET
is_delete = 1
WHERE
case_id IN
<foreach collection="caseIds" index="index" open="(" separator="," close=")">
#{caseIds[${index}]}
</foreach>
</update>
<update id="updateCaseAssign" parameterType="map">
UPDATE
kpi_case_assign
<set>
<if test="gmtModified != null and gmtModified != ''">
gmt_modified = #{gmtModified},
</if>
<if test="gmtComplete != null and gmtComplete != ''">
gmt_complete = #{gmtComplete},
</if>
<if test="isTimeout != null">
is_timeout = #{isTimeout},
</if>
<if test="isComplete != null">
is_complete = #{isComplete},
</if>
</set>
WHERE
case_id = #{caseId}
</update>
<select id="getCaseAssignPO" parameterType="map" resultMap="caseAssignPO">
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}
</select>
<select id="listCaseAssignPO" parameterType="map" resultMap="caseAssignPO">
SELECT
id,
case_assign_id,
case_id,
gmt_create,
gmt_modified,
gmt_complete,
is_timeout,
is_complete,
is_delete
FROM
kpi_case_assign
<where>
<if test="isComplete != null">
AND
is_complete = #{isComplete}
</if>
</where>
</select>
<select id="countCaseAssign" parameterType="map" resultType="java.lang.Integer">
SELECT
COUNT(*)
FROM
kpi_case_assign
WHERE
is_delete = 0
AND
case_id = #{caseId}
<if test="isTimeout != null">
AND
is_timeout = #{isTimeout}
</if>
</select>
<!-- 保存网格员日统计 -->
<insert id="saveCommunityBossDayCount" parameterType="map">
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}
</update>
@ -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
<where>
@ -535,7 +662,7 @@
</where>
</select>
<select id="sumLeaveTimelong" parameterType="map" resultType="java.lang.Double">
<select id="sumLeaveTimelong" parameterType="map" resultType="java.lang.Integer">
SELECT
SUM(leave_timelong_in_day)
FROM