From ff1985b4fbb44739fa68801ef221eb9f6f02f9e0 Mon Sep 17 00:00:00 2001 From: TS-QD1 Date: Sat, 13 May 2023 01:20:34 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E8=80=83=E6=A0=B8=E7=BB=86?= =?UTF-8?q?=E5=88=99=E5=90=8E=E5=8F=B0=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cm/bigdata/dao/kpi/IKpiKhxzWgzDao.java | 21 +++++ .../cm/bigdata/dao/kpi/IKpiKhxzZfGaDao.java | 21 +++++ .../pojo/dtos/kpi/CommunityBossDTO.java | 9 ++ .../bigdata/pojo/dtos/kpi/KpiKhxzWgy3DTO.java | 4 - .../bigdata/pojo/dtos/kpi/KpiKhxzWgzDTO.java | 90 +++++++++++++++++++ .../service/kpi/impl/KpiKhxzServiceImpl.java | 6 +- .../service/kpi/task/KpiKhxzDdyTask.java | 8 +- .../service/kpi/task/KpiKhxzWgyTask.java | 3 +- .../service/kpi/task/KpiKhxzWgzTask.java | 68 ++++++++++++++ .../service/kpi/task/KpiKhxzZfGaTask.java | 76 ++++++++++++++++ ...unnable.java => KpiKhxzDdyEFRunnable.java} | 5 +- .../task/sub/KpiKhxzWgzCDEFGHRunnable.java | 64 +++++++++++++ .../kpi/task/sub/KpiKhxzZfGaCRunnable.java | 60 +++++++++++++ .../kpi/task/sub/KpiKhxzZfGaDEFRunnable.java | 55 ++++++++++++ .../java/com/cm/bigdata/utils/KpiUtil.java | 2 + .../db2-mapper/kpi/community-boss-mapper.xml | 4 +- .../mybatis/mapper/kpi/IKpiKhxzWgzDao.xml | 70 +++++++++++++++ .../mapper/kpi/kpi-khxz-zfga-mapper.xml | 71 +++++++++++++++ .../mybatis/mapper/kpi/kpi-mapper.xml | 8 ++ 19 files changed, 631 insertions(+), 14 deletions(-) create mode 100644 src/main/java/com/cm/bigdata/dao/kpi/IKpiKhxzWgzDao.java create mode 100644 src/main/java/com/cm/bigdata/dao/kpi/IKpiKhxzZfGaDao.java delete mode 100644 src/main/java/com/cm/bigdata/pojo/dtos/kpi/KpiKhxzWgy3DTO.java create mode 100644 src/main/java/com/cm/bigdata/pojo/dtos/kpi/KpiKhxzWgzDTO.java create mode 100644 src/main/java/com/cm/bigdata/service/kpi/task/KpiKhxzWgzTask.java create mode 100644 src/main/java/com/cm/bigdata/service/kpi/task/KpiKhxzZfGaTask.java rename src/main/java/com/cm/bigdata/service/kpi/task/sub/{KpiKhxzDdyERunnable.java => KpiKhxzDdyEFRunnable.java} (82%) create mode 100644 src/main/java/com/cm/bigdata/service/kpi/task/sub/KpiKhxzWgzCDEFGHRunnable.java create mode 100644 src/main/java/com/cm/bigdata/service/kpi/task/sub/KpiKhxzZfGaCRunnable.java create mode 100644 src/main/java/com/cm/bigdata/service/kpi/task/sub/KpiKhxzZfGaDEFRunnable.java create mode 100644 src/main/resources/mybatis/mapper/kpi/IKpiKhxzWgzDao.xml create mode 100644 src/main/resources/mybatis/mapper/kpi/kpi-khxz-zfga-mapper.xml diff --git a/src/main/java/com/cm/bigdata/dao/kpi/IKpiKhxzWgzDao.java b/src/main/java/com/cm/bigdata/dao/kpi/IKpiKhxzWgzDao.java new file mode 100644 index 0000000..4a52340 --- /dev/null +++ b/src/main/java/com/cm/bigdata/dao/kpi/IKpiKhxzWgzDao.java @@ -0,0 +1,21 @@ +package com.cm.bigdata.dao.kpi; + +import com.cm.bigdata.pojo.dtos.kpi.KpiKhxzWgzDTO; +import org.springframework.stereotype.Repository; + +import java.util.List; +import java.util.Map; + +@Repository +public interface IKpiKhxzWgzDao { + + void save(Map params); + + void delete(Map params); + + void updateCDEFGH(Map updateParams); + + List list(Map params); + + +} diff --git a/src/main/java/com/cm/bigdata/dao/kpi/IKpiKhxzZfGaDao.java b/src/main/java/com/cm/bigdata/dao/kpi/IKpiKhxzZfGaDao.java new file mode 100644 index 0000000..bedae7f --- /dev/null +++ b/src/main/java/com/cm/bigdata/dao/kpi/IKpiKhxzZfGaDao.java @@ -0,0 +1,21 @@ +package com.cm.bigdata.dao.kpi; + +import org.springframework.stereotype.Repository; + +import java.util.List; +import java.util.Map; + +@Repository +public interface IKpiKhxzZfGaDao { + + void save(Map params); + + void delete(Map params); + + List listUserId(Map params); + + void updateC(Map updateParams); + + void updateDEF(Map updateParams); + +} diff --git a/src/main/java/com/cm/bigdata/pojo/dtos/kpi/CommunityBossDTO.java b/src/main/java/com/cm/bigdata/pojo/dtos/kpi/CommunityBossDTO.java index 1c01246..69a37c6 100644 --- a/src/main/java/com/cm/bigdata/pojo/dtos/kpi/CommunityBossDTO.java +++ b/src/main/java/com/cm/bigdata/pojo/dtos/kpi/CommunityBossDTO.java @@ -10,6 +10,7 @@ public class CommunityBossDTO { private String communityBossParentUserId; private Integer communityBossLevel; private String userName; + private String userUsername; private String communityId; private String communityName; @@ -77,6 +78,14 @@ public class CommunityBossDTO { this.userName = userName; } + public String getUserUsername() { + return userUsername; + } + + public void setUserUsername(String userUsername) { + this.userUsername = userUsername; + } + public String getCommunityId() { return communityId; } diff --git a/src/main/java/com/cm/bigdata/pojo/dtos/kpi/KpiKhxzWgy3DTO.java b/src/main/java/com/cm/bigdata/pojo/dtos/kpi/KpiKhxzWgy3DTO.java deleted file mode 100644 index 8d96014..0000000 --- a/src/main/java/com/cm/bigdata/pojo/dtos/kpi/KpiKhxzWgy3DTO.java +++ /dev/null @@ -1,4 +0,0 @@ -package com.cm.bigdata.pojo.dtos.kpi; - -public class KpiKhxzWgy3DTO { -} diff --git a/src/main/java/com/cm/bigdata/pojo/dtos/kpi/KpiKhxzWgzDTO.java b/src/main/java/com/cm/bigdata/pojo/dtos/kpi/KpiKhxzWgzDTO.java new file mode 100644 index 0000000..98ae686 --- /dev/null +++ b/src/main/java/com/cm/bigdata/pojo/dtos/kpi/KpiKhxzWgzDTO.java @@ -0,0 +1,90 @@ +package com.cm.bigdata.pojo.dtos.kpi; + +import com.alibaba.excel.annotation.ExcelIgnore; +import com.alibaba.excel.annotation.ExcelProperty; +import com.fasterxml.jackson.annotation.JsonProperty; + +public class KpiKhxzWgzDTO { + + @ExcelIgnore + private Long id; + @ExcelIgnore + private String areaId; + @ExcelIgnore + private String communityId; + @ExcelIgnore + private String userId; + @ExcelIgnore + private String userUsername; + @ExcelIgnore + private Integer khYear; + @ExcelIgnore + private Integer khMonth; + @ExcelProperty(index = 1) + @JsonProperty("B") + private String b; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getAreaId() { + return areaId; + } + + public void setAreaId(String areaId) { + this.areaId = areaId; + } + + public String getCommunityId() { + return communityId; + } + + public void setCommunityId(String communityId) { + this.communityId = communityId; + } + + public String getUserId() { + return userId; + } + + public void setUserId(String userId) { + this.userId = userId; + } + + public String getUserUsername() { + return userUsername; + } + + public void setUserUsername(String userUsername) { + this.userUsername = userUsername; + } + + public Integer getKhYear() { + return khYear; + } + + public void setKhYear(Integer khYear) { + this.khYear = khYear; + } + + public Integer getKhMonth() { + return khMonth; + } + + public void setKhMonth(Integer khMonth) { + this.khMonth = khMonth; + } + + public String getB() { + return b; + } + + public void setB(String b) { + this.b = b; + } +} 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 6e0ca44..fe0c8f0 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 @@ -58,9 +58,9 @@ public class KpiKhxzServiceImpl extends AbstractService implements IKpiKhxzServi // 更新5级网格员,4个任务 kpiKhxzWgyTask.update(khYear, khMonth, 4); - // 更新专管员、调度员日统计,1任务 - kpiService.updateNPersonDayCount("72bff485-69be-4570-9f30-ff65fdbe5251", khYear, khMonth); - KpiUpdateMonitor.getInstance().complete(); +// // 更新专管员、调度员日统计,1任务 +// kpiService.updateNPersonDayCount("72bff485-69be-4570-9f30-ff65fdbe5251", khYear, khMonth); +// KpiUpdateMonitor.getInstance().complete(); }); } diff --git a/src/main/java/com/cm/bigdata/service/kpi/task/KpiKhxzDdyTask.java b/src/main/java/com/cm/bigdata/service/kpi/task/KpiKhxzDdyTask.java index ded752e..57cd22c 100644 --- a/src/main/java/com/cm/bigdata/service/kpi/task/KpiKhxzDdyTask.java +++ b/src/main/java/com/cm/bigdata/service/kpi/task/KpiKhxzDdyTask.java @@ -2,10 +2,11 @@ package com.cm.bigdata.service.kpi.task; import com.cm.bigdata.dao.kpi.IKpiDao; import com.cm.bigdata.dao.kpi.IKpiKhxzDdyDao; +import com.cm.bigdata.monitor.KpiUpdateMonitor; import com.cm.bigdata.pojo.pos.kpi.UserPO; import com.cm.bigdata.service.kpi.IUserService; import com.cm.bigdata.service.kpi.task.sub.KpiKhxzDdyCRunnable; -import com.cm.bigdata.service.kpi.task.sub.KpiKhxzDdyERunnable; +import com.cm.bigdata.service.kpi.task.sub.KpiKhxzDdyEFRunnable; import com.cm.bigdata.utils.KpiUtil; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -26,17 +27,18 @@ public class KpiKhxzDdyTask { @Autowired private IUserService userService; - private ExecutorService executorService = Executors.newFixedThreadPool(10); + private ExecutorService executorService = Executors.newFixedThreadPool(2); public void update(int khYear, int khMonth) { deleteBase(khYear, khMonth); updateBase(khYear, khMonth); List userIds = listUserId(khYear, khMonth); if (userIds.isEmpty()) { + KpiUpdateMonitor.getInstance().complete(); return; } executorService.execute(new KpiKhxzDdyCRunnable(kpiKhxzDdyDao, kpiDao, khYear, khMonth, userIds)); - executorService.execute(new KpiKhxzDdyERunnable(kpiKhxzDdyDao, kpiDao, khYear, khMonth, userIds)); + executorService.execute(new KpiKhxzDdyEFRunnable(kpiKhxzDdyDao, kpiDao, khYear, khMonth, userIds)); } private void deleteBase(int khYear, int khMonth) { 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 9b0f5a4..407c270 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 @@ -36,13 +36,14 @@ public class KpiKhxzWgyTask { @Autowired private ICommunityBossService communityBossService; - private ExecutorService executorService = Executors.newFixedThreadPool(10); + private ExecutorService executorService = Executors.newFixedThreadPool(2); public void update(int khYear, int khMonth, int wgyLevel) { deleteBaseWgy(khYear, khMonth, wgyLevel); updateBaseWgy(khYear, khMonth, wgyLevel); List userIds = listUserIds(khYear, khMonth, wgyLevel); if (userIds.isEmpty()) { + KpiUpdateMonitor.getInstance().complete(); return; } executorService.execute(new KpiKhxzWgyCRunnable(kpiKhxzWgyDao, kpiDao, khYear, khMonth, wgyLevel, userIds)); diff --git a/src/main/java/com/cm/bigdata/service/kpi/task/KpiKhxzWgzTask.java b/src/main/java/com/cm/bigdata/service/kpi/task/KpiKhxzWgzTask.java new file mode 100644 index 0000000..8f12bab --- /dev/null +++ b/src/main/java/com/cm/bigdata/service/kpi/task/KpiKhxzWgzTask.java @@ -0,0 +1,68 @@ +package com.cm.bigdata.service.kpi.task; + +import com.cm.bigdata.dao.kpi.IKpiKhxzWgyDao; +import com.cm.bigdata.dao.kpi.IKpiKhxzWgzDao; +import com.cm.bigdata.monitor.KpiUpdateMonitor; +import com.cm.bigdata.pojo.dtos.kpi.CommunityBossDTO; +import com.cm.bigdata.pojo.dtos.kpi.KpiKhxzWgzDTO; +import com.cm.bigdata.service.kpi.ICommunityBossService; +import com.cm.bigdata.service.kpi.IUserService; +import com.cm.bigdata.service.kpi.task.sub.KpiKhxzWgzCDEFGHRunnable; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; + +@Service +public class KpiKhxzWgzTask { + + @Autowired + private ICommunityBossService communityBossService; + @Autowired + private IUserService userService; + @Autowired + private IKpiKhxzWgzDao kpiKhxzWgzDao; + @Autowired + private IKpiKhxzWgyDao kpiKhxzWgyDao; + private ExecutorService executorService = Executors.newFixedThreadPool(2); + + private void update(int khYear, int khMonth) { + deleteBase(khYear, khMonth); + updateBase(khYear, khMonth); + List kpiKhxzWgzDTOS = kpiKhxzWgzDao.list(new HashMap<>()); + if (kpiKhxzWgzDTOS.isEmpty()) { + KpiUpdateMonitor.getInstance().complete(); + return; + } + executorService.execute(new KpiKhxzWgzCDEFGHRunnable(kpiKhxzWgzDao, kpiKhxzWgyDao, khYear, khMonth, kpiKhxzWgzDTOS)); + } + + private void deleteBase(int khYear, int khMonth) { + Map params = new HashMap<>(); + params.put("khYear", khYear); + params.put("khMonth", khMonth); + kpiKhxzWgzDao.delete(params); + } + + private void updateBase(int khYear, int khMonth) { + Map params = new HashMap<>(); + params.put("communityBossLevel", 2); + List communityBossDTOS = communityBossService.list(params); + communityBossDTOS.forEach(communityBossDTO -> { + Map saveParams = new HashMap<>(); + saveParams.put("areaId", communityBossDTO.getAreaId()); + saveParams.put("communityId", communityBossDTO.getCommunityId()); + saveParams.put("userId", communityBossDTO.getCommunityBossUserId()); + saveParams.put("userUsername", communityBossDTO.getUserUsername()); + saveParams.put("khYear", khYear); + saveParams.put("khMonth", khMonth); + saveParams.put("B", communityBossDTO.getUserName()); + kpiKhxzWgzDao.save(saveParams); + }); + } + +} diff --git a/src/main/java/com/cm/bigdata/service/kpi/task/KpiKhxzZfGaTask.java b/src/main/java/com/cm/bigdata/service/kpi/task/KpiKhxzZfGaTask.java new file mode 100644 index 0000000..264b3b1 --- /dev/null +++ b/src/main/java/com/cm/bigdata/service/kpi/task/KpiKhxzZfGaTask.java @@ -0,0 +1,76 @@ +package com.cm.bigdata.service.kpi.task; + +import com.cm.bigdata.dao.kpi.IKpiDao; +import com.cm.bigdata.dao.kpi.IKpiKhxzZfGaDao; +import com.cm.bigdata.monitor.KpiUpdateMonitor; +import com.cm.bigdata.pojo.pos.kpi.UserPO; +import com.cm.bigdata.service.kpi.IDepartmentService; +import com.cm.bigdata.service.kpi.IUserService; +import com.cm.bigdata.service.kpi.task.sub.KpiKhxzZfGaCRunnable; +import com.cm.bigdata.service.kpi.task.sub.KpiKhxzZfGaDEFRunnable; +import com.cm.bigdata.utils.KpiUtil; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; + +@Service +public class KpiKhxzZfGaTask { + + @Autowired + private IKpiKhxzZfGaDao kpiKhxzZfGaDao; + @Autowired + private IKpiDao kpiDao; + @Autowired + private IUserService userService; + private ExecutorService executorService = Executors.newFixedThreadPool(2); + + public void update(int khYear, int khMonth) { + deleteBase(khYear, khMonth); + updateBase(KpiUtil.GA_DEPARTMENT_ID, khYear, khMonth); + updateBase(KpiUtil.ZF_DEPARTMENT_ID, khYear, khMonth); + List userIds = listUserId(khYear, khMonth); + if (userIds.isEmpty()) { + KpiUpdateMonitor.getInstance().complete(); + return; + } + executorService.execute(new KpiKhxzZfGaCRunnable(kpiKhxzZfGaDao, kpiDao, khYear, khMonth, userIds)); + executorService.execute(new KpiKhxzZfGaDEFRunnable(kpiKhxzZfGaDao, kpiDao, khYear, khMonth, userIds)); + } + + private void deleteBase(int khYear, int khMonth) { + Map params = new HashMap<>(); + params.put("khYear", khYear); + params.put("khMonth", khMonth); + kpiKhxzZfGaDao.delete(params); + } + + private void updateBase(String departmentId, int khYear, int khMonth) { + Map params = new HashMap<>(); + // 执法局 + params.put("departmentId", departmentId); + List userPOS = userService.listPO(params); + userPOS.forEach(userPO -> { + Map saveParams = new HashMap<>(); + saveParams.put("departmentId", departmentId); + saveParams.put("userId", userPO.getUserId()); + saveParams.put("userUsername", userPO.getUserId()); + saveParams.put("B", userPO.getUserName()); + saveParams.put("khYear", khYear); + saveParams.put("khMonth", khMonth); + kpiKhxzZfGaDao.save(saveParams); + }); + } + + private List listUserId(int khYear, int khMonth) { + Map params = new HashMap<>(); + params.put("khYear", khYear); + params.put("khMonth", khMonth); + return kpiKhxzZfGaDao.listUserId(params); + } + +} diff --git a/src/main/java/com/cm/bigdata/service/kpi/task/sub/KpiKhxzDdyERunnable.java b/src/main/java/com/cm/bigdata/service/kpi/task/sub/KpiKhxzDdyEFRunnable.java similarity index 82% rename from src/main/java/com/cm/bigdata/service/kpi/task/sub/KpiKhxzDdyERunnable.java rename to src/main/java/com/cm/bigdata/service/kpi/task/sub/KpiKhxzDdyEFRunnable.java index 008b073..5a88bdc 100644 --- a/src/main/java/com/cm/bigdata/service/kpi/task/sub/KpiKhxzDdyERunnable.java +++ b/src/main/java/com/cm/bigdata/service/kpi/task/sub/KpiKhxzDdyEFRunnable.java @@ -9,7 +9,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -public class KpiKhxzDdyERunnable implements Runnable { +public class KpiKhxzDdyEFRunnable implements Runnable { private IKpiKhxzDdyDao kpiKhxzDdyDao; private IKpiDao kpiDao; @@ -17,7 +17,7 @@ public class KpiKhxzDdyERunnable implements Runnable { private int khMonth; private List userIds; - public KpiKhxzDdyERunnable(IKpiKhxzDdyDao kpiKhxzDdyDao, IKpiDao kpiDao, int khYear, int khMonth, List userIds) { + public KpiKhxzDdyEFRunnable(IKpiKhxzDdyDao kpiKhxzDdyDao, IKpiDao kpiDao, int khYear, int khMonth, List userIds) { this.kpiKhxzDdyDao = kpiKhxzDdyDao; this.kpiDao = kpiDao; this.khYear = khYear; @@ -28,6 +28,7 @@ public class KpiKhxzDdyERunnable implements Runnable { @Override public void run() { Map params = new HashMap<>(); + params.put("assignYearMonth", String.format("%04d-%02d", khYear, khMonth)); userIds.forEach(userId -> { params.put("assignUserId", userId); List casePOS = kpiDao.listCase(params); diff --git a/src/main/java/com/cm/bigdata/service/kpi/task/sub/KpiKhxzWgzCDEFGHRunnable.java b/src/main/java/com/cm/bigdata/service/kpi/task/sub/KpiKhxzWgzCDEFGHRunnable.java new file mode 100644 index 0000000..84609a8 --- /dev/null +++ b/src/main/java/com/cm/bigdata/service/kpi/task/sub/KpiKhxzWgzCDEFGHRunnable.java @@ -0,0 +1,64 @@ +package com.cm.bigdata.service.kpi.task.sub; + +import com.cm.bigdata.dao.kpi.IKpiKhxzWgyDao; +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 java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class KpiKhxzWgzCDEFGHRunnable implements Runnable { + + private IKpiKhxzWgzDao kpiKhxzWgzDao; + private IKpiKhxzWgyDao kpiKhxzWgyDao; + private int khYear; + private int khMonth; + private List kpiKhxzWgzDTOS; + + public KpiKhxzWgzCDEFGHRunnable(IKpiKhxzWgzDao kpiKhxzWgzDao, IKpiKhxzWgyDao kpiKhxzWgyDao, int khYear, int khMonth, List kpiKhxzWgzDTOS) { + this.kpiKhxzWgzDao = kpiKhxzWgzDao; + this.kpiKhxzWgyDao = kpiKhxzWgyDao; + this.khYear = khYear; + this.khMonth = khMonth; + this.kpiKhxzWgzDTOS = kpiKhxzWgzDTOS; + } + + @Override + public void run() { + kpiKhxzWgzDTOS.forEach(kpiKhxzWgzDTO -> { + Map wgyParams = new HashMap<>(); + wgyParams.put("areaId", kpiKhxzWgzDTO.getAreaId()); + wgyParams.put("communityId", kpiKhxzWgzDTO.getCommunityId()); + List kpiKhxzWgyDTOS = kpiKhxzWgyDao.listWgy(wgyParams); + int unPassCount = 0; + int unReportCompleteCount = 0; + for (KpiKhxzWgyDTO kpiKhxzWgyDTO : kpiKhxzWgyDTOS) { + Double c = kpiKhxzWgyDTO.getC(); + if (c < 40 * 0.6) { + unPassCount++; + } + // 有少报案件记录 + if (kpiKhxzWgyDTO.getI() > 0) { + unReportCompleteCount++; + } + } + double defaultC = 20D; + double defaultF = 50D; + Map updateParams = new HashMap<>(); + updateParams.put("khYear", khYear); + updateParams.put("khMonth", khMonth); + updateParams.put("userId", kpiKhxzWgzDTO.getUserId()); + updateParams.put("C", defaultC); + updateParams.put("D", unPassCount); + updateParams.put("E", unPassCount * 10); + updateParams.put("F", defaultF); + updateParams.put("G", unReportCompleteCount); + updateParams.put("H", unReportCompleteCount * 10); + kpiKhxzWgzDao.updateCDEFGH(updateParams); + }); + KpiUpdateMonitor.getInstance().complete(); + } +} diff --git a/src/main/java/com/cm/bigdata/service/kpi/task/sub/KpiKhxzZfGaCRunnable.java b/src/main/java/com/cm/bigdata/service/kpi/task/sub/KpiKhxzZfGaCRunnable.java new file mode 100644 index 0000000..be1eb1a --- /dev/null +++ b/src/main/java/com/cm/bigdata/service/kpi/task/sub/KpiKhxzZfGaCRunnable.java @@ -0,0 +1,60 @@ +package com.cm.bigdata.service.kpi.task.sub; + +import com.cm.bigdata.dao.kpi.IKpiDao; +import com.cm.bigdata.dao.kpi.IKpiKhxzZfGaDao; +import com.cm.bigdata.monitor.KpiUpdateMonitor; +import com.cm.bigdata.pojo.pos.kpi.NPersonDayCountPO; +import com.cm.bigdata.utils.KpiUtil; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class KpiKhxzZfGaCRunnable implements Runnable{ + + private IKpiKhxzZfGaDao kpiKhxzZfGaDao; + private IKpiDao kpiDao; + private int khYear; + private int khMonth; + private List userIds; + + public KpiKhxzZfGaCRunnable(IKpiKhxzZfGaDao kpiKhxzZfGaDao, IKpiDao kpiDao, int khYear, int khMonth, List userIds) { + this.kpiKhxzZfGaDao = kpiKhxzZfGaDao; + this.kpiDao = kpiDao; + this.khYear = khYear; + this.khMonth = khMonth; + this.userIds = userIds; + } + + @Override + public void run() { + List dates = KpiUtil.listDate(khYear, khMonth); + Map params = new HashMap<>(); + userIds.forEach(userId -> { + params.put("userId", userId); + params.put("startTime", dates.get(0)); + params.put("endTime", dates.get(dates.size() - 1)); + List nPersonDayCountPOS = kpiDao.listNPersonDayCountPO(params); + int workDay = 0; + double totalDayScore = 0D; + for (NPersonDayCountPO nPersonDayCountPO : nPersonDayCountPOS) { + totalDayScore += nPersonDayCountPO.getDayScore(); + int isHoliday = nPersonDayCountPO.getIsHoliday(); + if (isHoliday == 1) { + continue; + } + workDay++; + } + double totalScore = workDay == 0 ? 0D : totalDayScore / workDay; + // 保存总分 + Map updateParams = new HashMap<>(); + updateParams.put("khYear", khYear); + updateParams.put("khMonth", khMonth); + updateParams.put("userId", userId); + updateParams.put("C", totalScore); + kpiKhxzZfGaDao.updateC(updateParams); + }); + KpiUpdateMonitor.getInstance().complete(); + } + +} diff --git a/src/main/java/com/cm/bigdata/service/kpi/task/sub/KpiKhxzZfGaDEFRunnable.java b/src/main/java/com/cm/bigdata/service/kpi/task/sub/KpiKhxzZfGaDEFRunnable.java new file mode 100644 index 0000000..9d3f4c7 --- /dev/null +++ b/src/main/java/com/cm/bigdata/service/kpi/task/sub/KpiKhxzZfGaDEFRunnable.java @@ -0,0 +1,55 @@ +package com.cm.bigdata.service.kpi.task.sub; + +import com.cm.bigdata.dao.kpi.IKpiDao; +import com.cm.bigdata.dao.kpi.IKpiKhxzZfGaDao; +import com.cm.bigdata.monitor.KpiUpdateMonitor; +import com.cm.bigdata.pojo.pos.kpi.CasePO; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class KpiKhxzZfGaDEFRunnable implements Runnable { + + private IKpiKhxzZfGaDao kpiKhxzZfGaDao; + private IKpiDao kpiDao; + private int khYear; + private int khMonth; + private List userIds; + + public KpiKhxzZfGaDEFRunnable(IKpiKhxzZfGaDao kpiKhxzZfGaDao, IKpiDao kpiDao, int khYear, int khMonth, List userIds) { + this.kpiKhxzZfGaDao = kpiKhxzZfGaDao; + this.kpiDao = kpiDao; + this.khYear = khYear; + this.khMonth = khMonth; + this.userIds = userIds; + } + + @Override + public void run() { + Map params = new HashMap<>(); + params.put("handleYearMonth", String.format("%04d-%02d", khYear, khMonth)); + userIds.forEach(userId -> { + params.put("handleUserId", userId); + int unInspectCount = 0; + int inspectCount = 0; + List casePOS = kpiDao.listCase(params); + for (CasePO casePO : casePOS) { + if (casePO.getIsInspect() == 0) { + unInspectCount++; + } else { + inspectCount++; + } + } + Map updateParams = new HashMap<>(); + updateParams.put("khYear", khYear); + updateParams.put("khMonth", khMonth); + updateParams.put("userId", userId); + updateParams.put("D", unInspectCount); + updateParams.put("E", inspectCount); + updateParams.put("F", inspectCount * 200 + unInspectCount * 200 * 0.6); + kpiKhxzZfGaDao.updateDEF(updateParams); + }); + KpiUpdateMonitor.getInstance().complete(); + } +} diff --git a/src/main/java/com/cm/bigdata/utils/KpiUtil.java b/src/main/java/com/cm/bigdata/utils/KpiUtil.java index e1b514c..ab935ee 100644 --- a/src/main/java/com/cm/bigdata/utils/KpiUtil.java +++ b/src/main/java/com/cm/bigdata/utils/KpiUtil.java @@ -21,6 +21,8 @@ public class KpiUtil { public static String DDY_ROLE_ID = "72bff485-69be-4570-9f30-ff65fdbe5251"; public static String ZGY_ROLE_ID = "bc405346-8714-4ded-89ac-9cc4d755f66a"; + public static String ZF_DEPARTMENT_ID = "1d74dfc8-f3a3-4517-87fe-7acf7891bab4"; + public static String GA_DEPARTMENT_ID = "2da5c4db-209b-4c28-bf35-153535fdfc78"; public static boolean isdateTimeIn24Hours(String date1, DateTime date2) { date1 = date1.split("\\.")[0]; 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 b62223a..d8e5dfb 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 @@ -27,6 +27,7 @@ + + SELECT + * + FROM + kpi_khxz_wgz + + + \ No newline at end of file diff --git a/src/main/resources/mybatis/mapper/kpi/kpi-khxz-zfga-mapper.xml b/src/main/resources/mybatis/mapper/kpi/kpi-khxz-zfga-mapper.xml new file mode 100644 index 0000000..3cf0f88 --- /dev/null +++ b/src/main/resources/mybatis/mapper/kpi/kpi-khxz-zfga-mapper.xml @@ -0,0 +1,71 @@ + + + + + + INSERT INTO kpi_khxz_zf_ga ( + department_id, + user_id, + user_username, + kh_year, + kh_month, + B + ) VALUES ( + #{departmentId}, + #{userId}, + #{userUsername}, + #{khYear}, + #{khMonth}, + #{B} + ) + + + + DELETE FROM + kpi_khxz_zf_ga + WHERE + kh_year = #{khYear} + AND + kh_month = #{khMonth} + + + + + + UPDATE + kpi_khxz_zf_ga + SET + C = #{C} + WHERE + kh_year = #{khYear} + AND + kh_month = #{khMonth} + AND + user_id = #{userId} + + + + UPDATE + kpi_khxz_zf_ga + SET + D = #{D}, + E = #{E}, + F = #{F} + WHERE + kh_year = #{khYear} + AND + kh_month = #{khMonth} + AND + user_id = #{userId} + + + \ No newline at end of file diff --git a/src/main/resources/mybatis/mapper/kpi/kpi-mapper.xml b/src/main/resources/mybatis/mapper/kpi/kpi-mapper.xml index 989a31f..0c8a723 100644 --- a/src/main/resources/mybatis/mapper/kpi/kpi-mapper.xml +++ b/src/main/resources/mybatis/mapper/kpi/kpi-mapper.xml @@ -471,10 +471,18 @@ #{assignUserIds[${index}]} + + AND + LEFT(gmt_assign, 7) = #{assignYearMonth} + AND handle_user_id = #{handleUserId} + + AND + LEFT(gmt_handle, 7) = #{handleYearMonth} + AND area_id = #{areaId}