处理绩效考核的新问题

This commit is contained in:
TS-QD1 2023-07-14 16:17:48 +08:00
parent d79632274f
commit 9596a2b851
9 changed files with 220 additions and 35 deletions

View File

@ -136,4 +136,59 @@ public class KpiKhxzController extends AbstractController {
return new SuccessResult();
}
@GetMapping("sync-case")
public void syncCase() throws IOException {
kpiKhxzService.updateCase();
}
@GetMapping("sync-wgy3/{year}/{month}")
public void syncWgy3(@PathVariable("year") Integer year, @PathVariable("month") Integer month) throws IOException {
kpiKhxzService.updateWgy3(year, month);
}
@GetMapping("sync-wgy4/{year}/{month}")
public void syncWgy4(@PathVariable("year") Integer year, @PathVariable("month") Integer month) throws IOException {
kpiKhxzService.updateWgy4(year, month);
}
@GetMapping("sync-ddy/{year}/{month}")
public void syncDdy(@PathVariable("year") Integer year, @PathVariable("month") Integer month) throws IOException {
kpiKhxzService.updateDdy(year, month);
}
@GetMapping("sync-zgy/{year}/{month}")
public void syncZgy(@PathVariable("year") Integer year, @PathVariable("month") Integer month) throws IOException {
kpiKhxzService.updateZgy(year, month);
}
@GetMapping("sync-wgy3-task/{year}/{month}")
public void syncWgy3Task(@PathVariable("year") Integer year, @PathVariable("month") Integer month) throws IOException {
kpiKhxzService.updateWgy3Task(year, month);
}
@GetMapping("sync-wgy4-task/{year}/{month}")
public void syncWgy4Task(@PathVariable("year") Integer year, @PathVariable("month") Integer month) throws IOException {
kpiKhxzService.updateWgy4Task(year, month);
}
@GetMapping("sync-ddy-task/{year}/{month}")
public void syncDdyTask(@PathVariable("year") Integer year, @PathVariable("month") Integer month) throws IOException {
kpiKhxzService.updateDdyTask(year, month);
}
@GetMapping("sync-zf-ga-task/{year}/{month}")
public void syncZfGaTask(@PathVariable("year") Integer year, @PathVariable("month") Integer month) throws IOException {
kpiKhxzService.updateZfGaTask(year, month);
}
@GetMapping("sync-znbm-task/{year}/{month}")
public void syncZnbmTask(@PathVariable("year") Integer year, @PathVariable("month") Integer month) throws IOException {
kpiKhxzService.updateZnbmTask(year, month);
}
@GetMapping("sync-wgz-tazk/{year}/{month}")
public void syncWgzTask(@PathVariable("year") Integer year, @PathVariable("month") Integer month) throws IOException {
kpiKhxzService.updateWgzTask(year, month);
}
}

View File

@ -12,6 +12,27 @@ public interface IKpiKhxzService {
void update(Integer khYear, Integer khMonth);
void updateCase();
void updateWgy3(Integer khYear, Integer khMonth);
void updateWgy4(Integer khYear, Integer khMonth);
void updateDdy(Integer khYear, Integer khMonth);
void updateZgy(Integer khYear, Integer khMonth);
void updateWgy3Task(Integer khYear, Integer khMonth);
void updateWgy4Task(Integer khYear, Integer khMonth);
void updateDdyTask(Integer khYear, Integer khMonth);
void updateZfGaTask(Integer khYear, Integer khMonth);
void updateZnbmTask(Integer khYear, Integer khMonth);
void updateWgzTask(Integer khYear, Integer khMonth);
List<KpiKhxzWgyDTO> listWgy(Map<String, Object> queryMap);
@ -43,4 +64,5 @@ public interface IKpiKhxzService {
void exportZnbm(HttpServletResponse httpServletResponse, Map<String, Object> queryMap) throws IOException;
void updateZnbm(KpiUpdateVO kpiUpdateVO);
}

View File

@ -54,52 +54,47 @@ public class KpiKhxzServiceImpl extends AbstractService implements IKpiKhxzServi
// 开始更新
Executors.newSingleThreadExecutor().execute(() -> {
// 更新案件1任务
kpiService.updateCaseCount();
KpiUpdateMonitor.getInstance().complete();
updateCase();
// 更新4级网格员日统计1任务
kpiService.updateCommunityBossDayCount(khYear, khMonth, 3);
KpiUpdateMonitor.getInstance().complete();
updateWgy3(khYear, khMonth);
// 更新5级网格员日统计1任务
kpiService.updateCommunityBossDayCount(khYear, khMonth, 4);
KpiUpdateMonitor.getInstance().complete();
updateWgy4(khYear, khMonth);
// 更新调度员日统计1任务
kpiService.updateNPersonDayCount(KpiUtil.DDY_ROLE_ID, khYear, khMonth);
KpiUpdateMonitor.getInstance().complete();
updateDdy(khYear, khMonth);
// 更新专管员1任务
kpiService.updateNPersonDayCount(KpiUtil.ZGY_ROLE_ID, khYear, khMonth);
KpiUpdateMonitor.getInstance().complete();
updateZgy(khYear, khMonth);
executorService.execute(() -> {
// 更新4级网格员4任务
kpiKhxzWgyTask.update(khYear, khMonth, 3);
updateWgy3Task(khYear, khMonth);
});
executorService.execute(() -> {
// 更新5级网格员4个任务
kpiKhxzWgyTask.update(khYear, khMonth, 4);
updateWgy4Task(khYear, khMonth);
});
executorService.execute(() -> {
// 调度员4任务
kpiKhxzDdyTask.update(khYear, khMonth);
updateDdyTask(khYear, khMonth);
});
executorService.execute(() -> {
// 执法公安5任务
khKhxzZfGaTask.update(khYear, khMonth);
updateZfGaTask(khYear, khMonth);
});
executorService.execute(() -> {
// 职能部门4任务
kpiKhxzZnbmTask.update(khYear, khMonth);
updateZnbmTask(khYear, khMonth);
});
executorService.execute(() -> {
while(KpiUpdateMonitor.getInstance().getCompleteCount() < 26) {
while (KpiUpdateMonitor.getInstance().getCompleteCount() < 26) {
try {
Thread.sleep(3000);
LOG.debug("等待其他任务执行完成");
@ -108,9 +103,69 @@ public class KpiKhxzServiceImpl extends AbstractService implements IKpiKhxzServi
}
}
// 网格长3任务
updateWgzTask(khYear, khMonth);
});
});
}
@Override
public void updateCase() {
kpiService.updateCaseCount();
KpiUpdateMonitor.getInstance().complete();
}
@Override
public void updateWgy3(Integer khYear, Integer khMonth) {
kpiService.updateCommunityBossDayCount(khYear, khMonth, 3);
KpiUpdateMonitor.getInstance().complete();
}
@Override
public void updateWgy4(Integer khYear, Integer khMonth) {
kpiService.updateCommunityBossDayCount(khYear, khMonth, 4);
KpiUpdateMonitor.getInstance().complete();
}
@Override
public void updateDdy(Integer khYear, Integer khMonth) {
kpiService.updateNPersonDayCount(KpiUtil.DDY_ROLE_ID, khYear, khMonth);
KpiUpdateMonitor.getInstance().complete();
}
@Override
public void updateZgy(Integer khYear, Integer khMonth) {
kpiService.updateNPersonDayCount(KpiUtil.ZGY_ROLE_ID, khYear, khMonth);
KpiUpdateMonitor.getInstance().complete();
}
@Override
public void updateWgy3Task(Integer khYear, Integer khMonth) {
kpiKhxzWgyTask.update(khYear, khMonth, 3);
}
@Override
public void updateWgy4Task(Integer khYear, Integer khMonth) {
kpiKhxzWgyTask.update(khYear, khMonth, 4);
}
@Override
public void updateDdyTask(Integer khYear, Integer khMonth) {
kpiKhxzDdyTask.update(khYear, khMonth);
}
@Override
public void updateZfGaTask(Integer khYear, Integer khMonth) {
khKhxzZfGaTask.update(khYear, khMonth);
}
@Override
public void updateZnbmTask(Integer khYear, Integer khMonth) {
kpiKhxzZnbmTask.update(khYear, khMonth);
}
@Override
public void updateWgzTask(Integer khYear, Integer khMonth) {
kpiKhxzWgzTask.update(khYear, khMonth);
});
});
}
@Override

View File

@ -51,7 +51,7 @@ public class KpiKhxzWgyTask {
return;
}
executorService.execute(new KpiKhxzWgyCRunnable(kpiKhxzWgyDao, kpiDao, khYear, khMonth, wgyLevel, userIds));
executorService.execute(new KpiKhxzWgyEGIKRTRunnable(kpiKhxzWgyDao, kpiHolidayDao, kpiDao, khYear, khMonth, wgyLevel, userIds));
executorService.execute(new KpiKhxzWgyEGIKRTRunnable(userGridService, kpiKhxzWgyDao, kpiHolidayDao, kpiDao, khYear, khMonth, wgyLevel, userIds));
}
private void deleteBaseWgy(int khYear, int khMonth, int wgyLevel) {

View File

@ -38,7 +38,7 @@ public class KpiKhxzWgzTask {
KpiUpdateMonitor.getInstance().complete();
return;
}
executorService.execute(new KpiKhxzWgzCDEFGHRunnable(kpiKhxzWgzDao, kpiKhxzWgyDao, khYear, khMonth, kpiKhxzWgzDTOS));
executorService.execute(new KpiKhxzWgzCDEFGHRunnable(communityBossService, kpiKhxzWgzDao, kpiKhxzWgyDao, khYear, khMonth, kpiKhxzWgzDTOS));
}
private void deleteBase(int khYear, int khMonth) {

View File

@ -6,6 +6,7 @@ import com.cm.bigdata.dao.kpi.IKpiKhxzWgyDao;
import com.cm.bigdata.monitor.KpiUpdateMonitor;
import com.cm.bigdata.pojo.pos.kpi.CasePO;
import com.cm.bigdata.pojo.pos.kpi.HolidayPO;
import com.cm.bigdata.service.kpi.IUserGridService;
import com.cm.bigdata.utils.KpiUtil;
import org.apache.commons.lang3.StringUtils;
@ -16,6 +17,7 @@ import java.util.Map;
public class KpiKhxzWgyEGIKRTRunnable implements Runnable {
private IUserGridService userGridService;
private IKpiKhxzWgyDao kpiKhxzWgyDao;
private IKpiHolidayDao kpiHolidayDao;
private IKpiDao kpiDao;
@ -24,7 +26,8 @@ public class KpiKhxzWgyEGIKRTRunnable implements Runnable {
private int level;
private List<String> userIds;
public KpiKhxzWgyEGIKRTRunnable(IKpiKhxzWgyDao kpiKhxzWgyDao, IKpiHolidayDao kpiHolidayDao, IKpiDao kpiDao, int year, int month, int level, List<String> userIds) {
public KpiKhxzWgyEGIKRTRunnable(IUserGridService userGridService, IKpiKhxzWgyDao kpiKhxzWgyDao, IKpiHolidayDao kpiHolidayDao, IKpiDao kpiDao, int year, int month, int level, List<String> userIds) {
this.userGridService = userGridService;
this.kpiKhxzWgyDao = kpiKhxzWgyDao;
this.kpiHolidayDao = kpiHolidayDao;
this.kpiDao = kpiDao;
@ -80,6 +83,9 @@ public class KpiKhxzWgyEGIKRTRunnable implements Runnable {
private void updateEGIKRT(List<String> userIds, List<List<KpiUtil.DayWeek>> shouldReportDayWeeks) {
int shouldCount = shouldReportDayWeeks.size();
userIds.forEach(userId -> {
// 网格数量
Integer gridCount = userGridService.countUserGrid(userId);
int totalShouldCount = shouldCount * gridCount;
// 每周上报
int weekReportCount = 0;
// 实报
@ -100,6 +106,7 @@ public class KpiKhxzWgyEGIKRTRunnable implements Runnable {
params.put("startTime", startTime);
params.put("endTime", endTime);
List<CasePO> casePOS = kpiDao.listCase(params);
// 本周是否有上报数据
boolean isWeekReport = false;
for (CasePO casePO : casePOS) {
urgeCount += casePO.getTotalUrge();
@ -130,12 +137,13 @@ public class KpiKhxzWgyEGIKRTRunnable implements Runnable {
isWeekReport = true;
}
}
weekReportCount += isWeekReport ? 1 : 0;
lackCount = Math.max(shouldCount - weekReportCount, 0);
exceedCount = Math.max(realityCount - shouldCount, 0);
// 每周上报数量由网格数量决定
weekReportCount += isWeekReport ? gridCount : 0;
lackCount = Math.max(totalShouldCount - weekReportCount, 0);
exceedCount = Math.max(realityCount - totalShouldCount, 0);
}
Map<String, Object> updateParams = new HashMap<>();
updateParams.put("E", shouldCount);
updateParams.put("E", totalShouldCount);
updateParams.put("G", weekReportCount);
updateParams.put("I", lackCount);
updateParams.put("K", exceedCount);

View File

@ -5,21 +5,27 @@ import com.cm.bigdata.dao.kpi.IKpiKhxzWgzDao;
import com.cm.bigdata.monitor.KpiUpdateMonitor;
import com.cm.bigdata.pojo.dtos.kpi.KpiKhxzWgyDTO;
import com.cm.bigdata.pojo.dtos.kpi.KpiKhxzWgzDTO;
import com.cm.bigdata.pojo.pos.kpi.CommunityBossPO;
import com.cm.bigdata.service.kpi.ICommunityBossService;
import org.apache.commons.collections4.ListUtils;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
public class KpiKhxzWgzCDEFGHRunnable implements Runnable {
private ICommunityBossService communityBossService;
private IKpiKhxzWgzDao kpiKhxzWgzDao;
private IKpiKhxzWgyDao kpiKhxzWgyDao;
private int khYear;
private int khMonth;
private List<KpiKhxzWgzDTO> kpiKhxzWgzDTOS;
public KpiKhxzWgzCDEFGHRunnable(IKpiKhxzWgzDao kpiKhxzWgzDao, IKpiKhxzWgyDao kpiKhxzWgyDao, int khYear, int khMonth, List<KpiKhxzWgzDTO> kpiKhxzWgzDTOS) {
public KpiKhxzWgzCDEFGHRunnable(ICommunityBossService communityBossService, IKpiKhxzWgzDao kpiKhxzWgzDao, IKpiKhxzWgyDao kpiKhxzWgyDao, int khYear, int khMonth, List<KpiKhxzWgzDTO> kpiKhxzWgzDTOS) {
this.communityBossService = communityBossService;
this.kpiKhxzWgzDao = kpiKhxzWgzDao;
this.kpiKhxzWgyDao = kpiKhxzWgyDao;
this.khYear = khYear;
@ -30,14 +36,34 @@ public class KpiKhxzWgzCDEFGHRunnable implements Runnable {
@Override
public void run() {
kpiKhxzWgzDTOS.forEach(kpiKhxzWgzDTO -> {
Map<String, Object> communityBossMap = new HashMap<>();
communityBossMap.put("communityBossParentUserId", kpiKhxzWgzDTO.getUserId());
// 直属下级网格员
List<CommunityBossPO> communityBossPOS = communityBossService.listPO(communityBossMap);
List<String> communityBossUserIds = communityBossPOS.stream().map(CommunityBossPO::getCommunityBossUserId).collect(Collectors.toList());
List<KpiKhxzWgyDTO> kpiKhxzWgyDTOS = new ArrayList<>();
if (!communityBossUserIds.isEmpty()) {
// 下级的直属下级
communityBossMap.clear();
communityBossMap.put("communityBossParentUserIds", communityBossUserIds);
List<CommunityBossPO> communityBossPOS1 = communityBossService.listPO(communityBossMap);
List<String> communityBossUserIds1 = communityBossPOS1.stream().map(CommunityBossPO::getCommunityBossUserId).collect(Collectors.toList());
// 合并用户ID
communityBossUserIds.addAll(communityBossUserIds1);
List<String> userIds = communityBossUserIds;
Map<String, Object> wgyParams = new HashMap<>();
wgyParams.put("areaId", kpiKhxzWgzDTO.getAreaId());
wgyParams.put("communityId", kpiKhxzWgzDTO.getCommunityId());
wgyParams.put("khYear", khYear);
wgyParams.put("khMonth", khMonth);
wgyParams.put("userIds", userIds);
wgyParams.put("wgyLevel", 3);
List<KpiKhxzWgyDTO> kpiKhxzWgyDTOS = kpiKhxzWgyDao.listWgy(wgyParams);
kpiKhxzWgyDTOS.addAll(kpiKhxzWgyDao.listWgy(wgyParams));
wgyParams.put("wgyLevel", 4);
List<KpiKhxzWgyDTO> kpiKhxzWgyDTOS1 = kpiKhxzWgyDao.listWgy(wgyParams);
kpiKhxzWgyDTOS.addAll(kpiKhxzWgyDTOS1);
}
int unPassCount = 0;
int unReportCompleteCount = 0;
for (KpiKhxzWgyDTO kpiKhxzWgyDTO : kpiKhxzWgyDTOS) {
@ -58,10 +84,10 @@ public class KpiKhxzWgzCDEFGHRunnable implements Runnable {
updateParams.put("userId", kpiKhxzWgzDTO.getUserId());
updateParams.put("C", defaultC);
updateParams.put("D", unPassCount);
updateParams.put("E", unPassCount * 10);
updateParams.put("E", Math.min(defaultC, unPassCount * 10));
updateParams.put("F", defaultF);
updateParams.put("G", unReportCompleteCount);
updateParams.put("H", unReportCompleteCount * 10);
updateParams.put("H", Math.min(defaultF, unReportCompleteCount * 10));
kpiKhxzWgzDao.updateCDEFGH(updateParams);
});
KpiUpdateMonitor.getInstance().complete();

View File

@ -55,6 +55,17 @@
AND
community_boss_level = #{communityBossLevel}
</if>
<if test="communityBossParentUserId != null and communityBossParentUserId != ''">
AND
community_boss_parent_user_id = #{communityBossParentUserId};
</if>
<if test="communityBossParentUserIds != null and communityBossParentUserIds.size > 0">
AND
community_boss_parent_user_id IN
<foreach collection="communityBossParentUserIds" index="index" open="(" separator="," close=")">
#{communityBossParentUserIds[${index}]}
</foreach>
</if>
</select>
<select id="list" parameterType="map" resultMap="communityBossDTO">

View File

@ -100,7 +100,15 @@
FROM
kpi_khxz_wgy_${wgyLevel}
<where>
<if test="userIds != null and userIds.size > 0">
AND
user_id IN
<foreach collection="userIds" index="index" open="(" separator="," close=")">
#{userIds[${index}]}
</foreach>
</if>
<if test="areaId != null and areaId != ''">
AND
area_id = #{areaId}
</if>
<if test="communityId != null and communityId != ''">