From 363a8d3f727e26f773ebffdf7dc8e746758bed15 Mon Sep 17 00:00:00 2001 From: TS-QD1 Date: Mon, 7 Aug 2023 16:36:40 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=84=E7=90=86=E7=BB=A9=E6=95=88=E8=80=83?= =?UTF-8?q?=E6=A0=B8=E7=BD=91=E6=A0=BC=E5=91=98=E9=82=A3=E4=BB=B6=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E5=AF=B9=E4=B8=8D=E4=B8=8A=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../apis/kpi/KpiKhxzController.java | 10 + .../kpi/IBasePopulationInfoService.java | 7 + .../bigdata/service/kpi/IKpiKhxzService.java | 5 + .../cm/bigdata/service/kpi/IKpiService.java | 4 + .../cm/bigdata/service/kpi/ILeaveService.java | 1 + .../bigdata/service/kpi/IUserSignService.java | 4 + .../impl/BasePopulationInfoServiceImpl.java | 23 +++ .../service/kpi/impl/KpiKhxzServiceImpl.java | 10 + .../service/kpi/impl/KpiServiceImpl.java | 127 ++++++++++++ .../service/kpi/impl/LeaveServiceImpl.java | 13 ++ .../service/kpi/impl/UserSignServiceImpl.java | 16 ++ .../service/kpi/task/KpiKhxzWgyTask.java | 61 ++++++ .../kpi/task/sub/KpiKhxzWgyCUserRunnable.java | 63 ++++++ .../task/sub/KpiKhxzWgyEGIKRTRunnable.java | 179 +++++++++------- .../sub/KpiKhxzWgyEGIKRTUserRunnable.java | 192 ++++++++++++++++++ .../java/com/cm/bigdata/utils/KpiUtil.java | 85 +++++++- .../db2-mapper/kpi/base-population-mapper.xml | 4 + .../db2-mapper/kpi/community-boss-mapper.xml | 4 + .../mybatis/db2-mapper/kpi/leave-mapper.xml | 4 + .../db2-mapper/kpi/user-sign-mapper.xml | 8 + .../mapper/kpi/kpi-khxz-wgy-mapper.xml | 4 + .../mybatis/mapper/kpi/kpi-mapper.xml | 12 +- 22 files changed, 754 insertions(+), 82 deletions(-) create mode 100644 src/main/java/com/cm/bigdata/service/kpi/task/sub/KpiKhxzWgyCUserRunnable.java create mode 100644 src/main/java/com/cm/bigdata/service/kpi/task/sub/KpiKhxzWgyEGIKRTUserRunnable.java 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 d28045e..62adb1b 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 @@ -152,6 +152,11 @@ public class KpiKhxzController extends AbstractController { kpiKhxzService.updateWgy4(year, month); } + @GetMapping("sync-wgy4/{year}/{month}/{userId}") + public void syncWgy4(@PathVariable("year") Integer year, @PathVariable("month") Integer month, @PathVariable("userId") String userId) { + kpiKhxzService.updateWgy4(year, month, userId); + } + @GetMapping("sync-ddy/{year}/{month}") public void syncDdy(@PathVariable("year") Integer year, @PathVariable("month") Integer month) throws IOException { kpiKhxzService.updateDdy(year, month); @@ -172,6 +177,11 @@ public class KpiKhxzController extends AbstractController { kpiKhxzService.updateWgy4Task(year, month); } + @GetMapping("sync-wgy4-task/{year}/{month}/{userId}") + public void syncWgy4Task(@PathVariable("year") Integer year, @PathVariable("month") Integer month, @PathVariable("userId") String userId) throws IOException { + kpiKhxzService.updateWgy4Task(year, month, userId); + } + @GetMapping("sync-ddy-task/{year}/{month}") public void syncDdyTask(@PathVariable("year") Integer year, @PathVariable("month") Integer month) throws IOException { kpiKhxzService.updateDdyTask(year, month); diff --git a/src/main/java/com/cm/bigdata/service/kpi/IBasePopulationInfoService.java b/src/main/java/com/cm/bigdata/service/kpi/IBasePopulationInfoService.java index 5d6a6ca..6062cc7 100644 --- a/src/main/java/com/cm/bigdata/service/kpi/IBasePopulationInfoService.java +++ b/src/main/java/com/cm/bigdata/service/kpi/IBasePopulationInfoService.java @@ -10,9 +10,16 @@ import java.util.List; public interface IBasePopulationInfoService { List listPopulationSaveCountByUserIds(List userIds); + List listPopulationSaveCountByUserId(String userId); List listPopulationSaveCountByUserIdsAndDay(List userIds, String date); + List listPopulationUpdateCountByUserIdAndDay(String userId, String date); + + + List listPopulationSaveCountByUserIdAndDay(String userId, String date); + + List listPopulationUpdateCountByUserIdsAndDay(List userIds, String date); SuccessResultList> listPagePopulationSaveByUserIdAndStartTimeAndEndTime(String userId, String startTime, String endTime, ListPage page); diff --git a/src/main/java/com/cm/bigdata/service/kpi/IKpiKhxzService.java b/src/main/java/com/cm/bigdata/service/kpi/IKpiKhxzService.java index 732930f..77c9610 100644 --- a/src/main/java/com/cm/bigdata/service/kpi/IKpiKhxzService.java +++ b/src/main/java/com/cm/bigdata/service/kpi/IKpiKhxzService.java @@ -18,6 +18,8 @@ public interface IKpiKhxzService { void updateWgy4(Integer khYear, Integer khMonth); + void updateWgy4(Integer year, Integer month, String userId); + void updateDdy(Integer khYear, Integer khMonth); void updateZgy(Integer khYear, Integer khMonth); @@ -26,6 +28,9 @@ public interface IKpiKhxzService { void updateWgy4Task(Integer khYear, Integer khMonth); + void updateWgy4Task(Integer year, Integer month, String userId); + + void updateDdyTask(Integer khYear, Integer khMonth); void updateZfGaTask(Integer khYear, Integer khMonth); diff --git a/src/main/java/com/cm/bigdata/service/kpi/IKpiService.java b/src/main/java/com/cm/bigdata/service/kpi/IKpiService.java index 13dc9a5..d7f1105 100644 --- a/src/main/java/com/cm/bigdata/service/kpi/IKpiService.java +++ b/src/main/java/com/cm/bigdata/service/kpi/IKpiService.java @@ -18,8 +18,12 @@ public interface IKpiService { */ void updateCommunityBossDayCount(String areaId, String communityId, String startTime, String endTime, int level); + void updateCommunityBossDayCount(String areaId, String communityId, String startTime, String endTime, int level, String userId); + void updateCommunityBossDayCount(int year, int month, int level); + void updateCommunityBossDayCount(int year, int month, int level, String userId); + /** * 更新N员 * 更新N员 diff --git a/src/main/java/com/cm/bigdata/service/kpi/ILeaveService.java b/src/main/java/com/cm/bigdata/service/kpi/ILeaveService.java index a8f0ca9..ed9b06a 100644 --- a/src/main/java/com/cm/bigdata/service/kpi/ILeaveService.java +++ b/src/main/java/com/cm/bigdata/service/kpi/ILeaveService.java @@ -9,4 +9,5 @@ public interface ILeaveService { List listPOByUserIdsAndDay(List userIds, String day); + List listPOByUserIdAndDay(String userId, String day); } diff --git a/src/main/java/com/cm/bigdata/service/kpi/IUserSignService.java b/src/main/java/com/cm/bigdata/service/kpi/IUserSignService.java index 70099ef..bb5f2c4 100644 --- a/src/main/java/com/cm/bigdata/service/kpi/IUserSignService.java +++ b/src/main/java/com/cm/bigdata/service/kpi/IUserSignService.java @@ -12,8 +12,12 @@ import java.util.List; public interface IUserSignService { List listInPOByUserIdsAndDay(List userIds, String day); + List listInPOByUserIdsAndDay(String userId, String day); + List listOutPOByUserIdsAndDay(List userIds, String day); + List listOutPOByUserIdsAndDay(String userId, String day); + SuccessResultList> listInByUserIdAndStartTimeAndEndTimeAndIsLate(String userId, String startTime, String endTime, Integer isLate, ListPage page); SuccessResultList> listOutByUserIdAndStartTimeAndEndTimeAndIsEarly(String userId, String startTime, String endTime, Integer isEarly, ListPage page); diff --git a/src/main/java/com/cm/bigdata/service/kpi/impl/BasePopulationInfoServiceImpl.java b/src/main/java/com/cm/bigdata/service/kpi/impl/BasePopulationInfoServiceImpl.java index 5e3e254..6a5a390 100644 --- a/src/main/java/com/cm/bigdata/service/kpi/impl/BasePopulationInfoServiceImpl.java +++ b/src/main/java/com/cm/bigdata/service/kpi/impl/BasePopulationInfoServiceImpl.java @@ -29,6 +29,13 @@ public class BasePopulationInfoServiceImpl implements IBasePopulationInfoService return basePopulationInfoDao.listPopulationSaveCount(params); } + @Override + public List listPopulationSaveCountByUserId(String userId) { + Map params = new HashMap<>(); + params.put("userId", userId); + return basePopulationInfoDao.listPopulationSaveCount(params); + } + @Override public List listPopulationSaveCountByUserIdsAndDay(List userIds, String date) { Map params = new HashMap<>(); @@ -37,6 +44,22 @@ public class BasePopulationInfoServiceImpl implements IBasePopulationInfoService return basePopulationInfoDao.listPopulationSaveCount(params); } + @Override + public List listPopulationUpdateCountByUserIdAndDay(String userId, String date) { + Map params = new HashMap<>(); + params.put("day", date); + params.put("userId", userId); + return basePopulationInfoDao.listPopulationSaveCount(params); + } + + @Override + public List listPopulationSaveCountByUserIdAndDay(String userId, String date) { + Map params = new HashMap<>(); + params.put("day", date); + params.put("userId", userId); + return basePopulationInfoDao.listPopulationSaveCount(params); + } + @Override public List listPopulationUpdateCountByUserIdsAndDay(List userIds, String date) { Map params = new HashMap<>(); 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 ceb2e2b..84fac83 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 @@ -126,6 +126,11 @@ public class KpiKhxzServiceImpl extends AbstractService implements IKpiKhxzServi KpiUpdateMonitor.getInstance().complete(); } + @Override + public void updateWgy4(Integer year, Integer month, String userId) { + kpiService.updateCommunityBossDayCount(year, month, 4, userId); + } + @Override public void updateDdy(Integer khYear, Integer khMonth) { kpiService.updateNPersonDayCount(KpiUtil.DDY_ROLE_ID, khYear, khMonth); @@ -148,6 +153,11 @@ public class KpiKhxzServiceImpl extends AbstractService implements IKpiKhxzServi kpiKhxzWgyTask.update(khYear, khMonth, 4); } + @Override + public void updateWgy4Task(Integer year, Integer month, String userId) { + kpiKhxzWgyTask.update(year, month, 4, userId); + } + @Override public void updateDdyTask(Integer khYear, Integer khMonth) { kpiKhxzDdyTask.update(khYear, khMonth); 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 c93afa9..7dddbc4 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 @@ -176,6 +176,117 @@ public class KpiServiceImpl implements IKpiService { }); } + @Override + public void updateCommunityBossDayCount(String areaId, String communityId, String startTime, String endTime, int level, String userId) { + // communityBoss表中的level位1-4,对应的是2-5级网格员 + final int communityBossLevel = level; + List dates = listDate(startTime, endTime); + List holidays = kpiHolidayService.listFormat(KpiUtil.years(dates)); + Map userGridCountMap = KpiUtil.mapUserGridCount(userGridService, userId); + // 当前季度的开始时间 + LocalDateTime startLocalDateTime = LocalDateTime.parse(startTime, DateTimeFormat.forPattern(ISystemConstant.DATE_FORMATTER_YYYY_MM_DD)); + LocalDateTime startQuarterLocalDateTime = startLocalDateTime.withMonthOfYear(((startLocalDateTime.getMonthOfYear() - 1) / 3) * 3 + 1); + String startQuarterTime = startQuarterLocalDateTime.toString(DateTimeFormat.forPattern(ISystemConstant.DATE_FORMATTER_YYYY_MM_DD)); + dates.forEach(date -> { + int isHoliday = KpiUtil.hasValueInList(holidays, date) ? 1 : 0; + Map> userSigninMap = KpiUtil.mapSignin(userSignService, userId, date); + Map> userSignoutMap = KpiUtil.mapSignout(userSignService, userId, date); + Map populationCountMap = KpiUtil.mapPopulationCount(basePopulationInfoService, userId); + Map populationSaveCountMap = KpiUtil.mapPopulationSaveCount(basePopulationInfoService, userId, date); + Map populationUpdateCountMap = KpiUtil.mapPopulationUpdateCount(basePopulationInfoService, userId, date); + Map leaveMap = KpiUtil.mapLeave(leaveService, userId, date); + // 删除当日数据 + deleteCommunityBossDayCount(date, communityBossLevel, userId); + List userSigninPO = userSigninMap.get(userId); + int isSignin = userSigninPO == null || userSigninPO.size() == 0 ? 0 : 1; + int isSigninLate = userSigninPO == null || userSigninPO.size() == 0 ? 0 : userSigninPO.get(0).getIsLate(); + List userSignoutPOS = userSignoutMap.get(userId); + int isSignout = userSignoutPOS == null || userSignoutPOS.size() == 0 ? 0 : 1; + int isSignoutEarly = userSignoutPOS == null || userSignoutPOS.size() == 0 ? 0 : userSignoutPOS.get(0).getIsEarly(); + double workDistance = KpiUtil.calculateWorkDistance(userLocationService, userId, date); + int populationCount = populationCountMap.get(userId) == null ? 0 : populationCountMap.get(userId); + int savePopulationCount = populationSaveCountMap.get(userId) == null ? 0 : populationSaveCountMap.get(userId); + int updatePopulationCount = populationUpdateCountMap.get(userId) == null ? 0 : populationUpdateCountMap.get(userId); + // 新增 + Map queryParams = new HashMap<>(); + queryParams.put("userId", userId); + queryParams.put("dayDate", date); + queryParams.put("isSignin", isSignin); + queryParams.put("isSigninLate", isSigninLate); + queryParams.put("isSignout", isSignout); + queryParams.put("isSignoutEarly", isSignoutEarly); + + queryParams.put("workDistance", workDistance); + queryParams.put("populationCount", populationCount); + queryParams.put("savePopulationCount", savePopulationCount); + queryParams.put("updatePopulationCount", updatePopulationCount); + queryParams.put("isHoliday", isHoliday); + // 网格数量 + queryParams.put("gridCount", userGridCountMap.get(userId)); + + // 请假情况 + int isLeave = 0; + int isLeaveSelf = 0; + int isLeaveSelfOverLimitInQuarter = 0; + double leaveTimelongInDay = 0D; + LeavePO leave = leaveMap.get(userId); + if (leave != null) { + isLeave = 1; + isLeaveSelf = leave.getIsSelf(); + + // 请假开始时间 + String leaveTime = leave.getLeaveTime(); + Double leaveTimeLong = Double.valueOf(leave.getLeaveTimeLong()); + if (StringUtils.contains(leaveTime, date)) { + // 开始时间是当天并且小于1天 + if (leaveTimeLong < 1) { + leaveTimelongInDay = leaveTimeLong; + } else { + leaveTimelongInDay = 1; + } + } else { + // 开始时间不是当天 + DateTime leaveTimeDateTime = DateTime.parse(leaveTime, DateTimeFormat.forPattern(ISystemConstant.DATE_FORMATTER_YYYY_MM_DD)); + int leaveDayIndex = 0; + for (int i = 0; i < leaveTimeLong; i++) { + String newDateTime = leaveTimeDateTime.plusDays(i + 1).toString(DateTimeFormat.forPattern(ISystemConstant.DATE_FORMATTER_YYYY_MM_DD)); + if (StringUtils.contains(newDateTime, date)) { + leaveDayIndex = i; + break; + } + } + if (leaveTimeLong - (leaveDayIndex + 1) < 1) { + leaveTimelongInDay = leaveTimeLong; + } else { + leaveTimelongInDay = 1; + } + } + // 获取当前季度的私假请假天数 + Map sumLeaveMap = new HashMap<>(); + sumLeaveMap.put("userId", userId); + sumLeaveMap.put("startDay", startQuarterTime); + sumLeaveMap.put("endDay", date); + sumLeaveMap.put("isLeave", 1); + sumLeaveMap.put("isLeaveSelf", 1); + sumLeaveMap.put("level", level); + Integer leaveTimelongInQuarter = kpiDao.sumLeaveTimelong(sumLeaveMap); + leaveTimelongInQuarter = leaveTimelongInQuarter == null ? 0 : leaveTimelongInQuarter; + // 私假天数大于4天 + if (leaveTimelongInQuarter > 4) { + isLeaveSelfOverLimitInQuarter = 1; + } + } + queryParams.put("isLeave", isLeave); + queryParams.put("isLeaveSelf", isLeaveSelf); + queryParams.put("leaveTimelongInDay", leaveTimelongInDay); + + // 计算当日总分,旷工不算,私假超过4天不算 + queryParams.put("dayScore", KpiScoreUtil.getWgyDayScore(isSignin, isSigninLate, isSignout, isSignoutEarly, workDistance, isLeave, isLeaveSelf, isLeaveSelfOverLimitInQuarter, isHoliday)); + queryParams.put("level", communityBossLevel); + kpiDao.saveCommunityBossDayCount(queryParams); + }); + } + @Override public void updateCommunityBossDayCount(int year, int month, int level) { DateTime dateTime = DateTime.parse(String.format("%04d-%02d", year, month), DateTimeFormat.forPattern("yyyy-MM")); @@ -184,6 +295,14 @@ public class KpiServiceImpl implements IKpiService { updateCommunityBossDayCount(null, null, startTime, endTime, level); } + @Override + public void updateCommunityBossDayCount(int year, int month, int level, String userId) { + DateTime dateTime = DateTime.parse(String.format("%04d-%02d", year, month), DateTimeFormat.forPattern("yyyy-MM")); + String startTime = dateTime.dayOfMonth().withMinimumValue().toString(DateTimeFormat.forPattern(ISystemConstant.DATE_FORMATTER_YYYY_MM_DD)); + String endTime = dateTime.dayOfMonth().withMaximumValue().toString(DateTimeFormat.forPattern(ISystemConstant.DATE_FORMATTER_YYYY_MM_DD)); + updateCommunityBossDayCount(null, null, startTime, endTime, level, userId); + } + @Override public void updateNPersonDayCount(String departmentId, String startTime, String endTime) { updateNPersonDayCount(departmentId, KpiUtil.ZGY_ROLE_ID, startTime, endTime); @@ -375,6 +494,14 @@ public class KpiServiceImpl implements IKpiService { kpiDao.deleteCommunityBossDayCount(params); } + private void deleteCommunityBossDayCount(String date, int level, String userId) { + Map params = new HashMap<>(4); + params.put("dayDate", date); + params.put("level", level); + params.put("userId", userId); + kpiDao.deleteCommunityBossDayCount(params); + } + @Override public List listCommunityCaseCount(String areaId, String communityId, String startTime, String endTime) { Map params = new HashMap<>(); diff --git a/src/main/java/com/cm/bigdata/service/kpi/impl/LeaveServiceImpl.java b/src/main/java/com/cm/bigdata/service/kpi/impl/LeaveServiceImpl.java index a3790b4..8f1bd55 100644 --- a/src/main/java/com/cm/bigdata/service/kpi/impl/LeaveServiceImpl.java +++ b/src/main/java/com/cm/bigdata/service/kpi/impl/LeaveServiceImpl.java @@ -3,6 +3,7 @@ package com.cm.bigdata.service.kpi.impl; import com.cm.bigdata.dao2.kpi.ILeaveDao; import com.cm.bigdata.pojo.pos.kpi.LeavePO; import com.cm.bigdata.service.kpi.ILeaveService; +import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -29,4 +30,16 @@ public class LeaveServiceImpl implements ILeaveService { params.put("leaveState", 1); return leaveDao.listPO(params); } + + @Override + public List listPOByUserIdAndDay(String userId, String day) { + if (StringUtils.isBlank(userId)) { + return new ArrayList<>(); + } + Map params = new HashMap<>(); + params.put("userId", userId); + params.put("day", day); + params.put("leaveState", 1); + return leaveDao.listPO(params); + } } diff --git a/src/main/java/com/cm/bigdata/service/kpi/impl/UserSignServiceImpl.java b/src/main/java/com/cm/bigdata/service/kpi/impl/UserSignServiceImpl.java index 0daa987..6b3a59f 100644 --- a/src/main/java/com/cm/bigdata/service/kpi/impl/UserSignServiceImpl.java +++ b/src/main/java/com/cm/bigdata/service/kpi/impl/UserSignServiceImpl.java @@ -31,6 +31,14 @@ public class UserSignServiceImpl implements IUserSignService { return userSignDao.listInPO(params); } + @Override + public List listInPOByUserIdsAndDay(String userId, String day) { + Map params = new HashMap<>(); + params.put("creator", userId); + params.put("day", day); + return userSignDao.listInPO(params); + } + @Override public List listOutPOByUserIdsAndDay(List userIds, String day) { Map params = new HashMap<>(); @@ -39,6 +47,14 @@ public class UserSignServiceImpl implements IUserSignService { return userSignDao.listOutPO(params); } + @Override + public List listOutPOByUserIdsAndDay(String userId, String day) { + Map params = new HashMap<>(); + params.put("creator", userId); + params.put("day", day); + return userSignDao.listOutPO(params); + } + @Override public SuccessResultList> listInByUserIdAndStartTimeAndEndTimeAndIsLate(String userId, String startTime, String endTime, Integer isLate, ListPage page) { Map params = new HashMap<>(); diff --git a/src/main/java/com/cm/bigdata/service/kpi/task/KpiKhxzWgyTask.java b/src/main/java/com/cm/bigdata/service/kpi/task/KpiKhxzWgyTask.java index b727e94..ba4c154 100644 --- a/src/main/java/com/cm/bigdata/service/kpi/task/KpiKhxzWgyTask.java +++ b/src/main/java/com/cm/bigdata/service/kpi/task/KpiKhxzWgyTask.java @@ -11,7 +11,9 @@ import com.cm.bigdata.service.kpi.IKpiService; import com.cm.bigdata.service.kpi.IUserGridService; import com.cm.bigdata.service.kpi.IUserService; import com.cm.bigdata.service.kpi.task.sub.KpiKhxzWgyCRunnable; +import com.cm.bigdata.service.kpi.task.sub.KpiKhxzWgyCUserRunnable; import com.cm.bigdata.service.kpi.task.sub.KpiKhxzWgyEGIKRTRunnable; +import com.cm.bigdata.service.kpi.task.sub.KpiKhxzWgyEGIKRTUserRunnable; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -54,6 +56,13 @@ public class KpiKhxzWgyTask { executorService.execute(new KpiKhxzWgyEGIKRTRunnable(userGridService, kpiKhxzWgyDao, kpiHolidayDao, kpiDao, khYear, khMonth, wgyLevel, userIds)); } + public void update(int khYear, int khMonth, int wgyLevel, String userId) { + deleteBaseWgy(khYear, khMonth, wgyLevel, userId); + updateBaseWgy(khYear, khMonth, wgyLevel, userId); + executorService.execute(new KpiKhxzWgyCUserRunnable(kpiKhxzWgyDao, kpiDao, khYear, khMonth, wgyLevel, userId)); + executorService.execute(new KpiKhxzWgyEGIKRTUserRunnable(userGridService, kpiKhxzWgyDao, kpiHolidayDao, kpiDao, khYear, khMonth, wgyLevel, userId)); + } + private void deleteBaseWgy(int khYear, int khMonth, int wgyLevel) { Map params = new HashMap<>(); params.put("khYear", khYear); @@ -63,6 +72,15 @@ public class KpiKhxzWgyTask { KpiUpdateMonitor.getInstance().complete(); } + private void deleteBaseWgy(int khYear, int khMonth, int wgyLevel, String userId) { + Map params = new HashMap<>(); + params.put("khYear", khYear); + params.put("khMonth", khMonth); + params.put("wgyLevel", wgyLevel); + params.put("userId", userId); + kpiKhxzWgyDao.delete(params); + } + private void updateBaseWgy(int khYear, int khMonth, int wgyLevel) { Map params = new HashMap<>(); params.put("communityBossLevel", wgyLevel); @@ -106,6 +124,49 @@ public class KpiKhxzWgyTask { KpiUpdateMonitor.getInstance().complete(); } + private void updateBaseWgy(int khYear, int khMonth, int wgyLevel, String userId) { + Map params = new HashMap<>(); + params.put("communityBossLevel", wgyLevel); + // 删除 + params.put("wgyLevel", wgyLevel); + params.put("khYear", khYear); + params.put("khMonth", khMonth); + params.put("communityBossUserId", userId); + List communityBossDTOS = communityBossService.list(params); + if (communityBossDTOS.isEmpty()) { + return; + } + List userIds = communityBossDTOS.stream().map(CommunityBossDTO::getCommunityBossUserId).filter(StringUtils::isNotBlank).collect(Collectors.toList()); + List userPOS = userService.listPO(userIds); + userPOS.forEach(userPO -> { + String areaId = null; + String communityId = null; + for (CommunityBossDTO communityBossDTO : communityBossDTOS) { + if (StringUtils.equals(userPO.getUserId(), communityBossDTO.getCommunityBossUserId())) { + areaId = communityBossDTO.getAreaId(); + communityId = communityBossDTO.getCommunityId(); + break; + } + } + if (StringUtils.isEmpty(areaId)) { + return; + } + // 网格数量 + Integer gridCount = userGridService.countUserGrid(userPO.getUserId()); + Map saveParams = new HashMap<>(); + saveParams.put("areaId", areaId); + saveParams.put("communityId", communityId); + saveParams.put("userId", userPO.getUserId()); + saveParams.put("userUsername", userPO.getUserUsername()); + saveParams.put("B", userPO.getUserName()); + saveParams.put("khYear", khYear); + saveParams.put("khMonth", khMonth); + saveParams.put("wgyLevel", wgyLevel); + saveParams.put("gridCount", gridCount); + kpiKhxzWgyDao.save(saveParams); + }); + } + private List listUserIds(int khYear, int khMonth, int wgyLevel) { Map params = new HashMap<>(); params.put("khYear", khYear); diff --git a/src/main/java/com/cm/bigdata/service/kpi/task/sub/KpiKhxzWgyCUserRunnable.java b/src/main/java/com/cm/bigdata/service/kpi/task/sub/KpiKhxzWgyCUserRunnable.java new file mode 100644 index 0000000..65ee08a --- /dev/null +++ b/src/main/java/com/cm/bigdata/service/kpi/task/sub/KpiKhxzWgyCUserRunnable.java @@ -0,0 +1,63 @@ +package com.cm.bigdata.service.kpi.task.sub; + +import com.cm.bigdata.dao.kpi.IKpiDao; +import com.cm.bigdata.dao.kpi.IKpiKhxzWgyDao; +import com.cm.bigdata.monitor.KpiUpdateMonitor; +import com.cm.bigdata.pojo.pos.kpi.CommunityBossDayCountPO; +import com.cm.bigdata.utils.KpiUtil; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class KpiKhxzWgyCUserRunnable implements Runnable { + + private IKpiKhxzWgyDao kpiKhxzWgyDao; + private IKpiDao kpiDao; + private Integer year; + private Integer month; + private Integer level; + private String userId; + + public KpiKhxzWgyCUserRunnable(IKpiKhxzWgyDao kpiKhxzWgyDao, IKpiDao kpiDao, Integer year, Integer month, Integer level, String userId) { + this.kpiKhxzWgyDao = kpiKhxzWgyDao; + this.kpiDao = kpiDao; + this.year = year; + this.month = month; + this.level = level; + this.userId = userId; + } + + @Override + public void run() { + List dates = KpiUtil.listDate(year, month); + Map params = new HashMap<>(); + params.put("level", level); + params.put("userId", userId); + params.put("startTime", dates.get(0)); + params.put("endTime", dates.get(dates.size() - 1)); + List communityBossDayCountPOS = kpiDao.listCommunityBossDayCountPO(params); + // 实际工作天数,不算矿工 + int workDay = 0; + double totalDayScore = 0D; + for (CommunityBossDayCountPO communityBossDayCountPO : communityBossDayCountPOS) { + // 如果是假期不记录 + int isHoliday = communityBossDayCountPO.getIsHoliday(); + if (isHoliday == 1) { + continue; + } + totalDayScore += communityBossDayCountPO.getDayScore(); + workDay++; + } + double totalScore = workDay == 0 ? 0D : totalDayScore / workDay; + // 保存总分 + Map updateParams = new HashMap<>(); + updateParams.put("khYear", year); + updateParams.put("khMonth", month); + updateParams.put("wgyLevel", level); + updateParams.put("userId", userId); + updateParams.put("C", totalScore); + kpiKhxzWgyDao.updateC(updateParams); + } + +} 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 089716c..b34f7ea 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 @@ -41,8 +41,8 @@ public class KpiKhxzWgyEGIKRTRunnable implements Runnable { public void run() { List holidayPOS = listHoliday(); List> dayWeeks = KpiUtil.listDayWeekOfMonth(year, month); - List> shouldReportDayWeeks = listShouldReportDayWeek(holidayPOS, dayWeeks); - updateEGIKRT(userIds, shouldReportDayWeeks); + List>[] reportDayWeeks = listShouldReportDayWeek(holidayPOS, dayWeeks); + updateEGIKRT(userIds, reportDayWeeks[0], reportDayWeeks[1]); KpiUpdateMonitor.getInstance().complete(); } @@ -53,7 +53,8 @@ public class KpiKhxzWgyEGIKRTRunnable implements Runnable { * @param dayWeeks * @return [应报,实报,少报,多报] */ - public static List> listShouldReportDayWeek(List holidayPOS, List> dayWeeks) { + public static List>[] listShouldReportDayWeek(List holidayPOS, List> dayWeeks) { + List> unShouldReportDayWeeks = new ArrayList<>(); List> shouldReportDayWeeks = new ArrayList<>(); for (List dws : dayWeeks) { int workdayCount = 0; @@ -75,85 +76,115 @@ public class KpiKhxzWgyEGIKRTRunnable implements Runnable { // 工作天数大于三天,需要上报 if (workdayCount > 3) { shouldReportDayWeeks.add(dws); + } else { + unShouldReportDayWeeks.add(dws); } } - return shouldReportDayWeeks; + return new List[]{shouldReportDayWeeks, unShouldReportDayWeeks}; } - private void updateEGIKRT(List userIds, List> shouldReportDayWeeks) { - int shouldCount = shouldReportDayWeeks.size(); + private void updateEGIKRT(List userIds, List> shouldReportDayWeeks, List> unShouldReportDayWeeks) { userIds.forEach(userId -> { - // 网格数量 - Integer gridCount = userGridService.countUserGrid(userId); - int totalShouldCount = shouldCount * gridCount; - // 每周上报 - int weekReportCount = 0; - // 实报 - int realityCount = 0; - // 少报 - int lackCount = 0; - // 多报 - int exceedCount = 0; - // 督办次数 - int urgeCount = 0; - // 超时检查数量 - int inspectTimeoutCount = 0; - for (List shouldReportDayWeek : shouldReportDayWeeks) { - String startTime = shouldReportDayWeek.get(0).getDate(); - String endTime = shouldReportDayWeek.get(shouldReportDayWeek.size() - 1).getDate(); - Map params = new HashMap<>(); - params.put("reportUserId", userId); - params.put("startTime", startTime); - params.put("endTime", endTime); - List casePOS = kpiDao.listCase(params); - // 本周是否有上报数据 - boolean isWeekReport = false; - for (CasePO casePO : casePOS) { - urgeCount += casePO.getTotalUrge(); - // 自处理 - Integer isSelf = casePO.getIsSelf(); - // 不是自处理,上报就算处理 - if (isSelf == 0) { - realityCount++; - isWeekReport = true; - continue; - } - // 处理时间 - String gmtHandle = casePO.getGmtHandle(); - if (StringUtils.isBlank(gmtHandle)) { - continue; - } - // 检查时间 - String gmtInspect = casePO.getGmtInspect(); - if (StringUtils.isBlank(gmtInspect)) { - continue; - } - // 处理时间和检查时间超过24小时 - if (KpiUtil.isdateTimeIn24Hours(gmtHandle, gmtInspect)) { - inspectTimeoutCount++; - } - if (KpiUtil.isDateBetween(gmtInspect, startTime, endTime)) { - realityCount++; - isWeekReport = true; + try { + int shouldCount = shouldReportDayWeeks.size(); + // 网格数量 + Integer gridCount = userGridService.countUserGrid(userId); + int totalShouldCount = shouldCount * gridCount; + // 每周上报 + int weekReportCount = 0; + // 少报 + int lackCount = 0; + // 多报 + int exceedCount = 0; + // 督办次数 + int urgeCount = 0; + // 超时检查数量 + int inspectTimeoutCount = 0; + // 非必须上报周内上报案件算多报 + for (List unShouldReportDayWeek : unShouldReportDayWeeks) { + String startTime = unShouldReportDayWeek.get(0).getDate(); + String endTime = unShouldReportDayWeek.get(unShouldReportDayWeek.size() - 1).getDate(); + Map params = new HashMap<>(); + params.put("reportUserId", userId); + params.put("startTime", startTime); + params.put("endTime", endTime); + List casePOS = kpiDao.listCase(params); + for (CasePO casePO : casePOS) { + // 自处理 + Integer isSelf = casePO.getIsSelf(); + // 不是自处理,上报就算处理 + if (isSelf == 0) { + exceedCount++; + continue; + } + // 检查过了,算多报 + String gmtInspect = casePO.getGmtInspect(); + if (StringUtils.isBlank(gmtInspect)) { + continue; + } + // 检查时间复合规定 + if (KpiUtil.isDateBetween(gmtInspect.substring(0, 10), startTime, endTime)) { + exceedCount++; + } } } - // 每周上报数量由网格数量决定 - weekReportCount += isWeekReport ? gridCount : 0; - lackCount = Math.max(totalShouldCount - weekReportCount, 0); - exceedCount = Math.max(realityCount - totalShouldCount, 0); + for (List shouldReportDayWeek : shouldReportDayWeeks) { + String startTime = shouldReportDayWeek.get(0).getDate(); + String endTime = shouldReportDayWeek.get(shouldReportDayWeek.size() - 1).getDate(); + Map params = new HashMap<>(); + params.put("reportUserId", userId); + params.put("startTime", startTime); + params.put("endTime", endTime); + List casePOS = kpiDao.listCase(params); + // 实报 + int realityCount = 0; + for (CasePO casePO : casePOS) { + urgeCount += casePO.getTotalUrge(); + // 自处理 + Integer isSelf = casePO.getIsSelf(); + // 不是自处理,上报就算处理 + if (isSelf == 0) { + realityCount++; + continue; + } + // 处理时间 + String gmtHandle = casePO.getGmtHandle(); + if (StringUtils.isBlank(gmtHandle)) { + continue; + } + // 检查时间 + String gmtInspect = casePO.getGmtInspect(); + if (StringUtils.isBlank(gmtInspect)) { + continue; + } + // 处理时间和检查时间超过24小时 + if (KpiUtil.isdateTimeIn24Hours(gmtHandle, gmtInspect)) { + inspectTimeoutCount++; + } + if (KpiUtil.isDateBetween(gmtInspect.substring(0, 10), startTime, endTime)) { + realityCount++; + } + } + // 每周上报数量由网格数量决定 + weekReportCount += Math.min(gridCount, realityCount); + lackCount += Math.max(gridCount - realityCount, 0); + exceedCount += Math.max(realityCount - gridCount, 0); + } + Map updateParams = new HashMap<>(); + updateParams.put("E", totalShouldCount); + updateParams.put("G", weekReportCount); + updateParams.put("I", lackCount); + updateParams.put("K", exceedCount); + updateParams.put("R", urgeCount); + updateParams.put("T", inspectTimeoutCount * 0.1); + updateParams.put("khYear", year); + updateParams.put("khMonth", month); + updateParams.put("wgyLevel", level); + updateParams.put("userId", userId); + kpiKhxzWgyDao.updateEGIKRT(updateParams); + } catch (Exception e) { + e.printStackTrace(); } - Map updateParams = new HashMap<>(); - updateParams.put("E", totalShouldCount); - updateParams.put("G", weekReportCount); - updateParams.put("I", lackCount); - updateParams.put("K", exceedCount); - updateParams.put("R", urgeCount); - updateParams.put("T", inspectTimeoutCount * 0.1); - updateParams.put("khYear", year); - updateParams.put("khMonth", month); - updateParams.put("wgyLevel", level); - updateParams.put("userId", userId); - kpiKhxzWgyDao.updateEGIKRT(updateParams); }); } 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 new file mode 100644 index 0000000..58c3e4c --- /dev/null +++ b/src/main/java/com/cm/bigdata/service/kpi/task/sub/KpiKhxzWgyEGIKRTUserRunnable.java @@ -0,0 +1,192 @@ +package com.cm.bigdata.service.kpi.task.sub; + +import com.cm.bigdata.dao.kpi.IKpiDao; +import com.cm.bigdata.dao.kpi.IKpiHolidayDao; +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; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class KpiKhxzWgyEGIKRTUserRunnable implements Runnable { + + private IUserGridService userGridService; + private IKpiKhxzWgyDao kpiKhxzWgyDao; + private IKpiHolidayDao kpiHolidayDao; + private IKpiDao kpiDao; + private int year; + private int month; + private int level; + private String userId; + + public KpiKhxzWgyEGIKRTUserRunnable(IUserGridService userGridService, IKpiKhxzWgyDao kpiKhxzWgyDao, IKpiHolidayDao kpiHolidayDao, IKpiDao kpiDao, int year, int month, int level, String userId) { + this.userGridService = userGridService; + this.kpiKhxzWgyDao = kpiKhxzWgyDao; + this.kpiHolidayDao = kpiHolidayDao; + this.kpiDao = kpiDao; + this.year = year; + this.month = month; + this.level = level; + this.userId = userId; + } + + @Override + public void run() { + List holidayPOS = listHoliday(); + List> dayWeeks = KpiUtil.listDayWeekOfMonth(year, month); + List>[] reportDayWeeks = listShouldReportDayWeek(holidayPOS, dayWeeks); + updateEGIKRT(userId, reportDayWeeks[0], reportDayWeeks[1]); + KpiUpdateMonitor.getInstance().complete(); + } + + /** + * 上报统计数组 + * + * @param holidayPOS + * @param dayWeeks + * @return [应报,实报,少报,多报] + */ + public static List>[] listShouldReportDayWeek(List holidayPOS, List> dayWeeks) { + List> unShouldReportDayWeeks = new ArrayList<>(); + List> shouldReportDayWeeks = new ArrayList<>(); + for (List dws : dayWeeks) { + int workdayCount = 0; + for (KpiUtil.DayWeek dayWeek : dws) { + boolean isHoliday = false; + for (HolidayPO holidayPO : holidayPOS) { + String holiday = String.format("%04d-%02d-%02d", holidayPO.getHolidayYear(), holidayPO.getHolidayMonth(), holidayPO.getHolidayDay()); + if (StringUtils.equals(dayWeek.getDate(), holiday)) { + dayWeek.setHoliday(true); + isHoliday = true; + break; + } + } + if (isHoliday) { + continue; + } + workdayCount++; + } + // 工作天数大于三天,需要上报 + if (workdayCount > 3) { + shouldReportDayWeeks.add(dws); + } else { + unShouldReportDayWeeks.add(dws); + } + } + return new List[]{shouldReportDayWeeks, unShouldReportDayWeeks}; + } + + private void updateEGIKRT(String userId, List> shouldReportDayWeeks, List> unShouldReportDayWeeks) { + int shouldCount = shouldReportDayWeeks.size(); + // 网格数量 + Integer gridCount = userGridService.countUserGrid(userId); + int totalShouldCount = shouldCount * gridCount; + // 每周上报 + int weekReportCount = 0; + // 少报 + int lackCount = 0; + // 多报 + int exceedCount = 0; + // 督办次数 + int urgeCount = 0; + // 超时检查数量 + int inspectTimeoutCount = 0; + // 非必须上报周内上报案件算多报 + for (List unShouldReportDayWeek : unShouldReportDayWeeks) { + String startTime = unShouldReportDayWeek.get(0).getDate(); + String endTime = unShouldReportDayWeek.get(unShouldReportDayWeek.size() - 1).getDate(); + Map params = new HashMap<>(); + params.put("reportUserId", userId); + params.put("startTime", startTime); + params.put("endTime", endTime); + List casePOS = kpiDao.listCase(params); + for (CasePO casePO : casePOS) { + // 自处理 + Integer isSelf = casePO.getIsSelf(); + // 不是自处理,上报就算处理 + if (isSelf == 0) { + exceedCount++; + continue; + } + // 检查过了,算多报 + String gmtInspect = casePO.getGmtInspect(); + if (StringUtils.isBlank(gmtInspect)) { + continue; + } + // 检查时间复合规定 + if (KpiUtil.isDateBetween(gmtInspect.substring(0, 10), startTime, endTime)) { + exceedCount++; + } + } + } + for (List shouldReportDayWeek : shouldReportDayWeeks) { + String startTime = shouldReportDayWeek.get(0).getDate(); + String endTime = shouldReportDayWeek.get(shouldReportDayWeek.size() - 1).getDate(); + Map params = new HashMap<>(); + params.put("reportUserId", userId); + params.put("startTime", startTime); + params.put("endTime", endTime); + List casePOS = kpiDao.listCase(params); + // 实报 + int realityCount = 0; + for (CasePO casePO : casePOS) { + urgeCount += casePO.getTotalUrge(); + // 自处理 + Integer isSelf = casePO.getIsSelf(); + // 不是自处理,上报就算处理 + if (isSelf == 0) { + realityCount++; + continue; + } + // 处理时间 + String gmtHandle = casePO.getGmtHandle(); + if (StringUtils.isBlank(gmtHandle)) { + continue; + } + // 检查时间 + String gmtInspect = casePO.getGmtInspect(); + if (StringUtils.isBlank(gmtInspect)) { + continue; + } + // 处理时间和检查时间超过24小时 + if (KpiUtil.isdateTimeIn24Hours(gmtHandle, gmtInspect)) { + inspectTimeoutCount++; + } + if (KpiUtil.isDateBetween(gmtInspect.substring(0, 10), startTime, endTime)) { + realityCount++; + } + } + // 每周上报数量由网格数量决定 + weekReportCount += Math.min(gridCount, realityCount); + lackCount += Math.max(gridCount - realityCount, 0); + exceedCount += Math.max(realityCount - gridCount, 0); + } + Map updateParams = new HashMap<>(); + updateParams.put("E", totalShouldCount); + updateParams.put("G", weekReportCount); + updateParams.put("I", lackCount); + updateParams.put("K", exceedCount); + updateParams.put("R", urgeCount); + updateParams.put("T", inspectTimeoutCount * 0.1); + updateParams.put("khYear", year); + updateParams.put("khMonth", month); + updateParams.put("wgyLevel", level); + updateParams.put("userId", userId); + kpiKhxzWgyDao.updateEGIKRT(updateParams); + } + + private List listHoliday() { + Map params = new HashMap<>(); + params.put("holidayYear", year); + params.put("holidayMonth", month); + return kpiHolidayDao.list(params); + } + +} diff --git a/src/main/java/com/cm/bigdata/utils/KpiUtil.java b/src/main/java/com/cm/bigdata/utils/KpiUtil.java index c539add..450753a 100644 --- a/src/main/java/com/cm/bigdata/utils/KpiUtil.java +++ b/src/main/java/com/cm/bigdata/utils/KpiUtil.java @@ -38,11 +38,10 @@ public class KpiUtil { if (StringUtils.isBlank(date)) { return false; } - date = date.split("\\.")[0]; - DateTime dateTime = DateTime.parse(date, DateTimeFormat.forPattern(ISystemConstant.DATE_FORMATTER_YYYY_MM_DD_HH_MM_SS)); + DateTime dateTime = DateTime.parse(date, DateTimeFormat.forPattern(ISystemConstant.DATE_FORMATTER_YYYY_MM_DD)); DateTime startDateTime = DateTime.parse(startDate, DateTimeFormat.forPattern(ISystemConstant.DATE_FORMATTER_YYYY_MM_DD)); DateTime endDateTime = DateTime.parse(endDate, DateTimeFormat.forPattern(ISystemConstant.DATE_FORMATTER_YYYY_MM_DD)); - return dateTime.isAfter(startDateTime) && dateTime.isBefore(endDateTime); + return (dateTime.isEqual(startDateTime) || dateTime.isAfter(startDateTime)) && (dateTime.isEqual(endDateTime) || dateTime.isBefore(endDateTime)); } public static boolean hasValueInList(List values, String checkValue) { @@ -83,6 +82,13 @@ public class KpiUtil { return userGridMap; } + public static Map mapUserGridCount(IUserGridService userGridService, String userId) { + Map userGridMap = new HashMap<>(); + Integer count = userGridService.countUserGrid(userId); + userGridMap.put(userId, count); + return userGridMap; + } + public static Map mapLeave(ILeaveService leaveService, List userIds, String day) { List leavePOS = leaveService.listPOByUserIdsAndDay(userIds, day); Map leavePOMap = new HashMap<>(); @@ -92,6 +98,15 @@ public class KpiUtil { return leavePOMap; } + public static Map mapLeave(ILeaveService leaveService, String userId, String day) { + List leavePOS = leaveService.listPOByUserIdAndDay(userId, day); + Map leavePOMap = new HashMap<>(); + leavePOS.forEach(leavePO -> { + leavePOMap.put(leavePO.getGmtCreate(), leavePO); + }); + return leavePOMap; + } + /** * 签到map * @@ -113,6 +128,27 @@ public class KpiUtil { return userSigninMap; } + /** + * 签到map + * + * @param userSigninService + * @param userIds + * @return + */ + public static Map> mapSignin(IUserSignService userSignService, String userId, String day) { + List userSigninDTOS = userSignService.listInPOByUserIdsAndDay(userId, day); + Map> userSigninMap = new HashMap<>(); + userSigninDTOS.forEach(userSigninPO -> { + List userSigninDTOList = userSigninMap.get(userSigninPO.getCreator()); + if (userSigninDTOList == null) { + userSigninDTOList = new ArrayList<>(); + } + userSigninDTOList.add(userSigninPO); + userSigninMap.put(userSigninPO.getCreator(), userSigninDTOList); + }); + return userSigninMap; + } + /** * 签退map * @@ -134,6 +170,20 @@ public class KpiUtil { return userSigninMap; } + public static Map> mapSignout(IUserSignService userSignService, String userId, String day) { + List userSignoutDTOS = userSignService.listOutPOByUserIdsAndDay(userId, day); + Map> userSigninMap = new HashMap<>(); + userSignoutDTOS.forEach(userSignoutPO -> { + List userSignoutDTOList = userSigninMap.get(userSignoutPO.getCreator()); + if (userSignoutDTOList == null) { + userSignoutDTOList = new ArrayList<>(); + } + userSignoutDTOList.add(userSignoutPO); + userSigninMap.put(userSignoutPO.getCreator(), userSignoutDTOList); + }); + return userSigninMap; + } + /** * 计算工作距离 * @@ -171,6 +221,15 @@ public class KpiUtil { return map; } + public static Map mapPopulationCount(IBasePopulationInfoService basePopulationInfoService, String userId) { + List basePopulationInfoCountPOS = basePopulationInfoService.listPopulationSaveCountByUserId(userId); + Map map = new HashMap<>(); + basePopulationInfoCountPOS.forEach(basePopulationInfoCountPO -> { + map.put(basePopulationInfoCountPO.getUserId(), basePopulationInfoCountPO.getTotal()); + }); + return map; + } + public static Map mapPopulationSaveCount(IBasePopulationInfoService basePopulationInfoService, List userIds, String date) { List basePopulationInfoCountPOS = basePopulationInfoService.listPopulationSaveCountByUserIdsAndDay(userIds, date); Map map = new HashMap<>(); @@ -180,6 +239,15 @@ public class KpiUtil { return map; } + public static Map mapPopulationSaveCount(IBasePopulationInfoService basePopulationInfoService, String userId, String date) { + List basePopulationInfoCountPOS = basePopulationInfoService.listPopulationSaveCountByUserIdAndDay(userId, date); + Map map = new HashMap<>(); + basePopulationInfoCountPOS.forEach(basePopulationInfoCountPO -> { + map.put(basePopulationInfoCountPO.getUserId(), basePopulationInfoCountPO.getTotal()); + }); + return map; + } + public static Map mapPopulationUpdateCount(IBasePopulationInfoService basePopulationInfoService, List userIds, String date) { List basePopulationInfoCountPOS = basePopulationInfoService.listPopulationUpdateCountByUserIdsAndDay(userIds, date); Map map = new HashMap<>(); @@ -189,6 +257,15 @@ public class KpiUtil { return map; } + public static Map mapPopulationUpdateCount(IBasePopulationInfoService basePopulationInfoService, String userId, String date) { + List basePopulationInfoCountPOS = basePopulationInfoService.listPopulationUpdateCountByUserIdAndDay(userId, date); + Map map = new HashMap<>(); + basePopulationInfoCountPOS.forEach(basePopulationInfoCountPO -> { + map.put(basePopulationInfoCountPO.getUserId(), basePopulationInfoCountPO.getTotal()); + }); + return map; + } + public static List> listDayWeekOfMonth(int year, int month) { DateTime dateTime = DateTime.parse(String.format("%04d-%02d", year, month), DateTimeFormat.forPattern("yyyy-MM")); DateTime.Property dayOfMonth = dateTime.dayOfMonth(); @@ -202,7 +279,7 @@ public class KpiUtil { String day = dayDateTime.toString(DateTimeFormat.forPattern(ISystemConstant.DATE_FORMATTER_YYYY_MM_DD)); DayWeek dayWeek = new DayWeek(day, weekOfMonth, dayDateTime.dayOfWeek().get()); currentWeekDays.add(dayWeek); - if (dayWeek.getDayOfWeek() == 7 || (i == monthEndDay - 1)) { + if (dayWeek.getDayOfWeek() == 7 || (i == monthEndDay)) { dayWeeks.add(currentWeekDays); weekOfMonth++; currentWeekDays = new ArrayList<>(); diff --git a/src/main/resources/mybatis/db2-mapper/kpi/base-population-mapper.xml b/src/main/resources/mybatis/db2-mapper/kpi/base-population-mapper.xml index 8a8e7af..4b3b840 100644 --- a/src/main/resources/mybatis/db2-mapper/kpi/base-population-mapper.xml +++ b/src/main/resources/mybatis/db2-mapper/kpi/base-population-mapper.xml @@ -62,6 +62,10 @@ AND LEFT(gmt_create, 10) = #{day} + + AND + creator = #{userId} + AND creator IN diff --git a/src/main/resources/mybatis/db2-mapper/kpi/community-boss-mapper.xml b/src/main/resources/mybatis/db2-mapper/kpi/community-boss-mapper.xml index 562f2fd..882d768 100644 --- a/src/main/resources/mybatis/db2-mapper/kpi/community-boss-mapper.xml +++ b/src/main/resources/mybatis/db2-mapper/kpi/community-boss-mapper.xml @@ -112,6 +112,10 @@ ccb.is_delete = 0 AND su.is_delete = 0 + + AND + ccb.community_boss_user_id = #{communityBossUserId} + AND ccb.area_id = #{areaId} diff --git a/src/main/resources/mybatis/db2-mapper/kpi/leave-mapper.xml b/src/main/resources/mybatis/db2-mapper/kpi/leave-mapper.xml index 4b52930..39656a6 100644 --- a/src/main/resources/mybatis/db2-mapper/kpi/leave-mapper.xml +++ b/src/main/resources/mybatis/db2-mapper/kpi/leave-mapper.xml @@ -38,6 +38,10 @@ city_leave WHERE is_delete = 0 + + AND + creator = #{userId} + AND creator IN diff --git a/src/main/resources/mybatis/db2-mapper/kpi/user-sign-mapper.xml b/src/main/resources/mybatis/db2-mapper/kpi/user-sign-mapper.xml index b74645d..5095236 100644 --- a/src/main/resources/mybatis/db2-mapper/kpi/user-sign-mapper.xml +++ b/src/main/resources/mybatis/db2-mapper/kpi/user-sign-mapper.xml @@ -72,6 +72,10 @@ AND LEFT(gmt_create, 10) = #{day} + + AND + creator = #{creator} + AND creator IN @@ -101,6 +105,10 @@ AND LEFT(gmt_create, 10) = #{day} + + AND + creator = #{creator} + AND creator IN diff --git a/src/main/resources/mybatis/mapper/kpi/kpi-khxz-wgy-mapper.xml b/src/main/resources/mybatis/mapper/kpi/kpi-khxz-wgy-mapper.xml index af9b293..5686be1 100644 --- a/src/main/resources/mybatis/mapper/kpi/kpi-khxz-wgy-mapper.xml +++ b/src/main/resources/mybatis/mapper/kpi/kpi-khxz-wgy-mapper.xml @@ -92,6 +92,10 @@ kh_year = #{khYear} AND kh_month = #{khMonth} + + AND + user_id = #{userId} +