diff --git a/src/main/java/com/cm/bigdata/config/AuthClientSecurityConfig.java b/src/main/java/com/cm/bigdata/config/AuthClientSecurityConfig.java index 2f78076..54db111 100644 --- a/src/main/java/com/cm/bigdata/config/AuthClientSecurityConfig.java +++ b/src/main/java/com/cm/bigdata/config/AuthClientSecurityConfig.java @@ -41,7 +41,7 @@ public class AuthClientSecurityConfig extends WebSecurityConfigurerAdapter { .and() .logout().logoutSuccessUrl(authServer.getOauthLogout()) .and() - .authorizeRequests().antMatchers("/app/**", "/route/file/**", "/assets/**").permitAll() + .authorizeRequests().antMatchers("/app/**", "/route/file/**", "/assets/**", "/api/kpi/khxz/**").permitAll() .and() .authorizeRequests() .anyRequest() diff --git a/src/main/java/com/cm/bigdata/controller/apis/kpi/KpiController.java b/src/main/java/com/cm/bigdata/controller/apis/kpi/KpiController.java index 398f117..ccfdaa3 100644 --- a/src/main/java/com/cm/bigdata/controller/apis/kpi/KpiController.java +++ b/src/main/java/com/cm/bigdata/controller/apis/kpi/KpiController.java @@ -13,6 +13,8 @@ import io.swagger.annotations.Api; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -92,6 +94,15 @@ public class KpiController extends AbstractController { return kpiService.listCommunityCaseCount(areaId, communityId, startTime, endTime); } + @GetMapping("export-community-case-count") + public void exportCommunityCaseCount(HttpServletResponse httpServletResponse, + @RequestParam(name = "areaId", required = false) String areaId, + @RequestParam(name = "communityId", required = false) String communityId, + @RequestParam(name = "startTime", required = false) String startTime, + @RequestParam(name = "endTime", required = false) String endTime) throws IOException { + kpiService.exportCommunityCaseCount(httpServletResponse, areaId, communityId, startTime, endTime); + } + @GetMapping("list-community-boss-case-count") public List listCommunityBossCaseCount(@RequestParam(name = "areaId", required = false) String areaId, @RequestParam(name = "communityId", required = false) String communityId, @@ -101,6 +112,16 @@ public class KpiController extends AbstractController { return kpiService.listCommunityBossCaseCount(areaId, communityId, startTime, endTime, communityBossLevel); } + @GetMapping("export-community-boss-case-count") + public void exportCommunityBossCaseCount(HttpServletResponse httpServletResponse, + @RequestParam(name = "areaId", required = false) String areaId, + @RequestParam(name = "communityId", required = false) String communityId, + @RequestParam(name = "startTime", required = false) String startTime, + @RequestParam(name = "endTime", required = false) String endTime, + @RequestParam(name = "communityBossLevel") Integer communityBossLevel) throws IOException { + kpiService.exportCommunityBossCaseCount(httpServletResponse, areaId, communityId, startTime, endTime, communityBossLevel); + } + @GetMapping("list-n-person-count") public List listNPersonCaseCount(@RequestParam(name = "departmentId", required = false) String departmentId, @RequestParam(name = "startTime", required = false) String startTime, @@ -108,6 +129,14 @@ public class KpiController extends AbstractController { return kpiService.listNPersonCaseCount(departmentId, startTime, endTime); } + @GetMapping("export-n-person-count") + public void exportNPersonCaseCount(HttpServletResponse httpServletResponse, + @RequestParam(name = "departmentId", required = false) String departmentId, + @RequestParam(name = "startTime", required = false) String startTime, + @RequestParam(name = "endTime", required = false) String endTime) throws IOException { + kpiService.exportNPersonCaseCount(httpServletResponse, departmentId, startTime, endTime); + } + @GetMapping("list-community-boss-case-day-count") public List listCommunityBossCaseDayCount(@RequestParam(name = "areaId", required = false) String areaId, @RequestParam(name = "communityId", required = false) String communityId, @@ -117,6 +146,16 @@ public class KpiController extends AbstractController { return kpiService.listCommunityBossCaseDayCount(areaId, communityId, startTime, endTime, communityBossLevel); } + @GetMapping("export-community-boss-case-day-count") + public void exportCommunityBossCaseDayCount(HttpServletResponse httpServletResponse, + @RequestParam(name = "areaId", required = false) String areaId, + @RequestParam(name = "communityId", required = false) String communityId, + @RequestParam(name = "startTime", required = false) String startTime, + @RequestParam(name = "endTime", required = false) String endTime, + @RequestParam(name = "communityBossLevel") Integer communityBossLevel) throws IOException { + kpiService.exportCommunityBossCaseDayCount(httpServletResponse, areaId, communityId, startTime, endTime, communityBossLevel); + } + @GetMapping("list-n-person-day-count") public List listNPersonCaseDayCount(@RequestParam(name = "departmentId", required = false) String departmentId, @RequestParam(name = "startTime", required = false) String startTime, @@ -124,6 +163,14 @@ public class KpiController extends AbstractController { return kpiService.listNPersonCaseDayCount(departmentId, startTime, endTime); } + @GetMapping("export-n-person-day-count") + public void exportNPersonCaseDayCount(HttpServletResponse httpServletResponse, + @RequestParam(name = "departmentId", required = false) String departmentId, + @RequestParam(name = "startTime", required = false) String startTime, + @RequestParam(name = "endTime", required = false) String endTime) throws IOException { + kpiService.exportNPersonCaseDayCount(httpServletResponse, departmentId, startTime, endTime); + } + @GetMapping("listpage-user-signin/user-id/{userId}") public SuccessResultList> listUserSignin(@PathVariable("userId") String userId, @RequestParam(name = "startTime", required = false) String startTime, 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 new file mode 100644 index 0000000..19011d7 --- /dev/null +++ b/src/main/java/com/cm/bigdata/controller/apis/kpi/KpiKhxzController.java @@ -0,0 +1,34 @@ +package com.cm.bigdata.controller.apis.kpi; + +import com.cm.bigdata.service.kpi.IKpiKhxzService; +import com.cm.common.base.AbstractController; +import com.cm.common.constants.ISystemConstant; +import com.cm.common.result.SuccessResult; +import io.swagger.annotations.Api; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.util.List; +import java.util.Map; + +@Api(tags = ISystemConstant.API_TAGS_SYSTEM_PREFIX + "KPI接口") +@RestController +@RequestMapping(ISystemConstant.API_PREFIX + "/kpi/khxz") +public class KpiKhxzController extends AbstractController { + + @Autowired + private IKpiKhxzService kpiKhxzService; + + @PutMapping("update-wgy/kh-year/{khYear}/kh-month/{khMonth}/wgy-level/{wgyLevel}") + public synchronized SuccessResult updateWgy(@PathVariable("khYear") Integer khYear, @PathVariable("khMonth") Integer khMonth, @PathVariable("wgyLevel") Integer wgyLevel) { + kpiKhxzService.updateWgy(khYear, khMonth, wgyLevel); + return new SuccessResult(); + } + + @GetMapping("list-wgy") + public List> listWgy() { + Map queryMap = requestParams(); + return kpiKhxzService.listWgy(queryMap); + } + +} diff --git a/src/main/java/com/cm/bigdata/dao/kpi/IKpiHolidayDao.java b/src/main/java/com/cm/bigdata/dao/kpi/IKpiHolidayDao.java new file mode 100644 index 0000000..5e59ec1 --- /dev/null +++ b/src/main/java/com/cm/bigdata/dao/kpi/IKpiHolidayDao.java @@ -0,0 +1,14 @@ +package com.cm.bigdata.dao.kpi; + +import com.cm.bigdata.pojo.pos.kpi.HolidayPO; +import org.springframework.stereotype.Repository; + +import java.util.List; +import java.util.Map; + +@Repository +public interface IKpiHolidayDao { + + List list(Map params); + +} diff --git a/src/main/java/com/cm/bigdata/dao/kpi/IKpiKhxzDao.java b/src/main/java/com/cm/bigdata/dao/kpi/IKpiKhxzDao.java new file mode 100644 index 0000000..2b4b9d8 --- /dev/null +++ b/src/main/java/com/cm/bigdata/dao/kpi/IKpiKhxzDao.java @@ -0,0 +1,13 @@ +package com.cm.bigdata.dao.kpi; + +import org.springframework.stereotype.Repository; + +import java.util.List; +import java.util.Map; + +@Repository +public interface IKpiKhxzDao { + + List> listWgy(Map queryMap); + +} diff --git a/src/main/java/com/cm/bigdata/dao/kpi/IKpiKhxzWgyDao.java b/src/main/java/com/cm/bigdata/dao/kpi/IKpiKhxzWgyDao.java new file mode 100644 index 0000000..1e85e7d --- /dev/null +++ b/src/main/java/com/cm/bigdata/dao/kpi/IKpiKhxzWgyDao.java @@ -0,0 +1,22 @@ +package com.cm.bigdata.dao.kpi; + +import org.apache.ibatis.annotations.MapKey; +import org.springframework.stereotype.Repository; + +import java.util.List; +import java.util.Map; + +@Repository +public interface IKpiKhxzWgyDao { + + void save(Map params); + + void delete(Map params); + + @MapKey("id") + List> listWgy(Map params); + + void updateC(Map updateParams); + + List listUserId(Map params); +} diff --git a/src/main/java/com/cm/bigdata/pojo/dtos/kpi/CommunityBossCaseCountDTO.java b/src/main/java/com/cm/bigdata/pojo/dtos/kpi/CommunityBossCaseCountDTO.java index d838f6a..2433006 100644 --- a/src/main/java/com/cm/bigdata/pojo/dtos/kpi/CommunityBossCaseCountDTO.java +++ b/src/main/java/com/cm/bigdata/pojo/dtos/kpi/CommunityBossCaseCountDTO.java @@ -1,16 +1,29 @@ package com.cm.bigdata.pojo.dtos.kpi; +import com.alibaba.excel.annotation.ExcelIgnore; +import com.alibaba.excel.annotation.ExcelProperty; + public class CommunityBossCaseCountDTO implements Comparable { + @ExcelIgnore private String areaId; + @ExcelProperty(value = "地区", index = 0) private String areaName; + @ExcelIgnore private String communityId; + @ExcelProperty(value = "社区", index = 1) private String communityName; + @ExcelIgnore private String userId; + @ExcelProperty(value = "姓名", index = 2) private String userName; + @ExcelProperty(value = "案件总数", index = 3) private Integer caseTotal; + @ExcelProperty(value = "已处理案件", index = 4) private Integer caseHandleTotal; + @ExcelProperty(value = "已检查案件", index = 5) private Integer caseInspectTotal; + @ExcelProperty(value = "已归档案件", index = 6) private Integer caseOnfileTotal; public String getAreaId() { diff --git a/src/main/java/com/cm/bigdata/pojo/dtos/kpi/CommunityBossCaseDayCountDTO.java b/src/main/java/com/cm/bigdata/pojo/dtos/kpi/CommunityBossCaseDayCountDTO.java index fd27fcb..8636cc0 100644 --- a/src/main/java/com/cm/bigdata/pojo/dtos/kpi/CommunityBossCaseDayCountDTO.java +++ b/src/main/java/com/cm/bigdata/pojo/dtos/kpi/CommunityBossCaseDayCountDTO.java @@ -1,23 +1,43 @@ package com.cm.bigdata.pojo.dtos.kpi; +import com.alibaba.excel.annotation.ExcelIgnore; +import com.alibaba.excel.annotation.ExcelProperty; + public class CommunityBossCaseDayCountDTO implements Comparable { + @ExcelIgnore private String areaId; + @ExcelProperty(value = "地区", index = 0) private String areaName; + @ExcelIgnore private String communityId; + @ExcelProperty(value = "社区", index = 1) private String communityName; + @ExcelIgnore private String userId; + @ExcelProperty(value = "姓名", index = 2) private String userName; + @ExcelProperty(value = "签到次数", index = 3) private Integer isSigninTotal; + @ExcelProperty(value = "迟到次数", index = 4) private Integer isSigninLateTotal; + @ExcelProperty(value = "签退次数", index = 5) private Integer isSignoutTotal; + @ExcelProperty(value = "早退次数", index = 6) private Integer isSignoutEarlyTotal; + @ExcelProperty(value = "移动距离", index = 7) private Double workDistanceTotal; + @ExcelProperty(value = "新增人口", index = 8) private Integer savePopulationCountTotal; + @ExcelProperty(value = "维护人口", index = 9) private Integer updatePopulationCountTotal; + @ExcelProperty(value = "案件总数", index = 10) private Integer caseTotal; + @ExcelProperty(value = "已处理案件", index = 11) private Integer caseHandleTotal; + @ExcelProperty(value = "已检查案件", index = 12) private Integer caseInspectTotal; + @ExcelProperty(value = "已归档案件", index = 13) private Integer caseOnfileTotal; public String getAreaId() { diff --git a/src/main/java/com/cm/bigdata/pojo/dtos/kpi/CommunityCaseCountDTO.java b/src/main/java/com/cm/bigdata/pojo/dtos/kpi/CommunityCaseCountDTO.java index 89b2d74..568929a 100644 --- a/src/main/java/com/cm/bigdata/pojo/dtos/kpi/CommunityCaseCountDTO.java +++ b/src/main/java/com/cm/bigdata/pojo/dtos/kpi/CommunityCaseCountDTO.java @@ -1,15 +1,27 @@ package com.cm.bigdata.pojo.dtos.kpi; +import com.alibaba.excel.annotation.ExcelIgnore; +import com.alibaba.excel.annotation.ExcelProperty; + public class CommunityCaseCountDTO implements Comparable { + @ExcelIgnore private String areaId; + @ExcelProperty(value = "地区", index = 0) private String areaName; + @ExcelIgnore private String communityId; + @ExcelProperty(value = "社区", index = 1) private String communityName; + @ExcelProperty(value = "案件总数", index = 2) private Integer caseTotal; + @ExcelProperty(value = "已受理案件", index = 3) private Integer caseAcceptTotal; + @ExcelProperty(value = "已处理案件", index = 4) private Integer caseHandleTotal; + @ExcelProperty(value = "已检查案件", index = 5) private Integer caseInspectTotal; + @ExcelProperty(value = "已归档案件", index = 6) private Integer caseOnfileTotal; public String getAreaId() { diff --git a/src/main/java/com/cm/bigdata/pojo/dtos/kpi/NPersonCaseCountDTO.java b/src/main/java/com/cm/bigdata/pojo/dtos/kpi/NPersonCaseCountDTO.java index 11192b2..c7d2e3b 100644 --- a/src/main/java/com/cm/bigdata/pojo/dtos/kpi/NPersonCaseCountDTO.java +++ b/src/main/java/com/cm/bigdata/pojo/dtos/kpi/NPersonCaseCountDTO.java @@ -1,12 +1,21 @@ package com.cm.bigdata.pojo.dtos.kpi; +import com.alibaba.excel.annotation.ExcelIgnore; +import com.alibaba.excel.annotation.ExcelProperty; + public class NPersonCaseCountDTO implements Comparable { + @ExcelIgnore private String departmentId; + @ExcelProperty(value = "职能部门", index = 0) private String departmentName; + @ExcelIgnore private String userId; + @ExcelProperty(value = "姓名", index = 1) private String userName; + @ExcelProperty(value = "上报案件总数", index = 2) private Integer caseReportTotal; + @ExcelProperty(value = "处理案件总数", index = 3) private Integer caseHandleTotal; public String getDepartmentId() { diff --git a/src/main/java/com/cm/bigdata/pojo/dtos/kpi/NPersonCaseDayCountDTO.java b/src/main/java/com/cm/bigdata/pojo/dtos/kpi/NPersonCaseDayCountDTO.java index 8be09e5..04bded2 100644 --- a/src/main/java/com/cm/bigdata/pojo/dtos/kpi/NPersonCaseDayCountDTO.java +++ b/src/main/java/com/cm/bigdata/pojo/dtos/kpi/NPersonCaseDayCountDTO.java @@ -1,16 +1,29 @@ package com.cm.bigdata.pojo.dtos.kpi; +import com.alibaba.excel.annotation.ExcelIgnore; +import com.alibaba.excel.annotation.ExcelProperty; + public class NPersonCaseDayCountDTO implements Comparable { + @ExcelIgnore private String departmentId; + @ExcelProperty(value = "职能部门", index = 0) private String departmentName; + @ExcelIgnore private String userId; + @ExcelProperty(value = "姓名", index = 1) private String userName; + @ExcelProperty(value = "签到次数", index = 2) private Integer isSigninTotal; + @ExcelProperty(value = "迟到次数", index = 3) private Integer isSigninLateTotal; + @ExcelProperty(value = "签退次数", index = 4) private Integer isSignoutTotal; + @ExcelProperty(value = "早退次数", index = 5) private Integer isSignoutEarlyTotal; + @ExcelProperty(value = "上报案件总数", index = 6) private Integer caseReportTotal; + @ExcelProperty(value = "处理案件总数", index = 7) private Integer caseHandleTotal; public String getDepartmentId() { diff --git a/src/main/java/com/cm/bigdata/pojo/pos/kpi/CommunityBossDayCountPO.java b/src/main/java/com/cm/bigdata/pojo/pos/kpi/CommunityBossDayCountPO.java index 44bc8b5..1146d81 100644 --- a/src/main/java/com/cm/bigdata/pojo/pos/kpi/CommunityBossDayCountPO.java +++ b/src/main/java/com/cm/bigdata/pojo/pos/kpi/CommunityBossDayCountPO.java @@ -15,6 +15,8 @@ public class CommunityBossDayCountPO { private Double workDistance; private Integer savePopulationCount; private Integer updatePopulationCount; + private Integer isHoliday; + private Double dayScore; public Long getId() { return id; @@ -95,4 +97,20 @@ public class CommunityBossDayCountPO { public void setUpdatePopulationCount(Integer updatePopulationCount) { this.updatePopulationCount = updatePopulationCount; } + + public Integer getIsHoliday() { + return isHoliday; + } + + public void setIsHoliday(Integer isHoliday) { + this.isHoliday = isHoliday; + } + + public Double getDayScore() { + return dayScore; + } + + public void setDayScore(Double dayScore) { + this.dayScore = dayScore; + } } diff --git a/src/main/java/com/cm/bigdata/pojo/pos/kpi/HolidayPO.java b/src/main/java/com/cm/bigdata/pojo/pos/kpi/HolidayPO.java new file mode 100644 index 0000000..b18607a --- /dev/null +++ b/src/main/java/com/cm/bigdata/pojo/pos/kpi/HolidayPO.java @@ -0,0 +1,32 @@ +package com.cm.bigdata.pojo.pos.kpi; + +public class HolidayPO { + + private Integer holidayYear; + private Integer holidayMonth; + private Integer holidayDay; + + public Integer getHolidayYear() { + return holidayYear; + } + + public void setHolidayYear(Integer holidayYear) { + this.holidayYear = holidayYear; + } + + public Integer getHolidayMonth() { + return holidayMonth; + } + + public void setHolidayMonth(Integer holidayMonth) { + this.holidayMonth = holidayMonth; + } + + public Integer getHolidayDay() { + return holidayDay; + } + + public void setHolidayDay(Integer holidayDay) { + this.holidayDay = holidayDay; + } +} diff --git a/src/main/java/com/cm/bigdata/pojo/pos/kpi/NPersonDayCountPO.java b/src/main/java/com/cm/bigdata/pojo/pos/kpi/NPersonDayCountPO.java index 08bdb08..524253f 100644 --- a/src/main/java/com/cm/bigdata/pojo/pos/kpi/NPersonDayCountPO.java +++ b/src/main/java/com/cm/bigdata/pojo/pos/kpi/NPersonDayCountPO.java @@ -9,6 +9,8 @@ public class NPersonDayCountPO { private Integer isSigninLate; private Integer isSignout; private Integer isSignoutEarly; + private Integer isHoliday; + private Double dayScore; public Long getId() { return id; @@ -65,4 +67,20 @@ public class NPersonDayCountPO { public void setIsSignoutEarly(Integer isSignoutEarly) { this.isSignoutEarly = isSignoutEarly; } + + public Integer getIsHoliday() { + return isHoliday; + } + + public void setIsHoliday(Integer isHoliday) { + this.isHoliday = isHoliday; + } + + public Double getDayScore() { + return dayScore; + } + + public void setDayScore(Double dayScore) { + this.dayScore = dayScore; + } } diff --git a/src/main/java/com/cm/bigdata/service/kpi/IKpiKhxzService.java b/src/main/java/com/cm/bigdata/service/kpi/IKpiKhxzService.java new file mode 100644 index 0000000..c8bfb92 --- /dev/null +++ b/src/main/java/com/cm/bigdata/service/kpi/IKpiKhxzService.java @@ -0,0 +1,14 @@ +package com.cm.bigdata.service.kpi; + +import java.util.List; +import java.util.Map; + +public interface IKpiKhxzService { + + void updateWgy(Integer khYear, Integer khMonth, Integer wgyLevel); + + + List> listWgy(Map queryMap); + + +} 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 7452b96..970ace4 100644 --- a/src/main/java/com/cm/bigdata/service/kpi/IKpiService.java +++ b/src/main/java/com/cm/bigdata/service/kpi/IKpiService.java @@ -2,6 +2,8 @@ package com.cm.bigdata.service.kpi; import com.cm.bigdata.pojo.dtos.kpi.*; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; import java.util.List; /** @@ -16,6 +18,8 @@ public interface IKpiService { */ void updateCommunityBossDayCount(String areaId, String communityId, String startTime, String endTime, int level); + void updateCommunityBossDayCount(int year, int month, int level); + /** * 更新N员 * 更新N员 @@ -41,12 +45,23 @@ public interface IKpiService { */ List listCommunityCaseCount(String areaId, String communityId, String startTime, String endTime); + void exportCommunityCaseCount(HttpServletResponse httpServletResponse, String areaId, String communityId, String startTime, String endTime) throws IOException; + List listCommunityBossCaseCount(String areaId, String communityId, String startTime, String endTime, Integer communityBossLevel); + void exportCommunityBossCaseCount(HttpServletResponse httpServletResponse, String areaId, String communityId, String startTime, String endTime, Integer communityBossLevel) throws IOException; + + List listNPersonCaseCount(String departmentId, String startTime, String endTime); + void exportNPersonCaseCount(HttpServletResponse httpServletResponse, String departmentId, String startTime, String endTime) throws IOException; + List listCommunityBossCaseDayCount(String areaId, String communityId, String startTime, String endTime, Integer communityBossLevel); + void exportCommunityBossCaseDayCount(HttpServletResponse httpServletResponse, String areaId, String communityId, String startTime, String endTime, Integer communityBossLevel) throws IOException; + List listNPersonCaseDayCount(String departmentId, String startTime, String endTime); + void exportNPersonCaseDayCount(HttpServletResponse httpServletResponse, String departmentId, String startTime, String endTime) throws IOException; + } diff --git a/src/main/java/com/cm/bigdata/service/kpi/IUserService.java b/src/main/java/com/cm/bigdata/service/kpi/IUserService.java index 0cecd8d..51843ff 100644 --- a/src/main/java/com/cm/bigdata/service/kpi/IUserService.java +++ b/src/main/java/com/cm/bigdata/service/kpi/IUserService.java @@ -8,6 +8,8 @@ import java.util.Map; public interface IUserService { List listPOByRoleId(String roleId); + List listPO(List userIds); + List listPO(Map params); } diff --git a/src/main/java/com/cm/bigdata/service/kpi/KpiHolidayService.java b/src/main/java/com/cm/bigdata/service/kpi/KpiHolidayService.java new file mode 100644 index 0000000..eb1a756 --- /dev/null +++ b/src/main/java/com/cm/bigdata/service/kpi/KpiHolidayService.java @@ -0,0 +1,65 @@ +package com.cm.bigdata.service.kpi; + +import com.cm.bigdata.dao.kpi.IKpiHolidayDao; +import com.cm.bigdata.pojo.pos.kpi.HolidayPO; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +@Service +public class KpiHolidayService { + + @Autowired + private IKpiHolidayDao kpiHolidayDao; + + public List list(int year) { + Map params = new HashMap<>(); + params.put("holidayYear", year); + return kpiHolidayDao.list(params); + } + + public List list(List years) { + Map params = new HashMap<>(); + params.put("holidayYears", years); + return kpiHolidayDao.list(params); + } + + public List list(int year, int month) { + Map params = new HashMap<>(); + params.put("holidayYear", year); + params.put("holidayMonth", month); + return kpiHolidayDao.list(params); + } + + public List listFormat(int year) { + List pos = list(year); + return listFormatByPOs(pos); + } + + public List listFormat(List years) { + List pos = list(years); + return listFormatByPOs(pos); + } + + public List listFormat(int year, int month) { + List pos = list(year, month); + List list = new ArrayList<>(); + pos.forEach(holidayPO -> { + list.add(String.format("%04d-%02d-%02d", holidayPO.getHolidayYear(), holidayPO.getHolidayMonth(), holidayPO.getHolidayDay())); + }); + return list; + } + + public List listFormatByPOs(List pos) { + List list = new ArrayList<>(); + pos.forEach(holidayPO -> { + list.add(String.format("%04d-%02d-%02d", holidayPO.getHolidayYear(), holidayPO.getHolidayMonth(), holidayPO.getHolidayDay())); + }); + return list; + } + +} 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 new file mode 100644 index 0000000..25abf45 --- /dev/null +++ b/src/main/java/com/cm/bigdata/service/kpi/impl/KpiKhxzServiceImpl.java @@ -0,0 +1,30 @@ +package com.cm.bigdata.service.kpi.impl; + +import com.cm.bigdata.dao.kpi.IKpiKhxzDao; +import com.cm.bigdata.service.kpi.IKpiKhxzService; +import com.cm.bigdata.service.kpi.task.KpiKhxzWgyTask; +import com.cm.common.base.AbstractService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; +import java.util.Map; + +@Service +public class KpiKhxzServiceImpl extends AbstractService implements IKpiKhxzService { + + @Autowired + private IKpiKhxzDao kpiKhxzDao; + @Autowired + private KpiKhxzWgyTask kpiKhxzWgyTask; + + @Override + public void updateWgy(Integer khYear, Integer khMonth, Integer wgyLevel) { + kpiKhxzWgyTask.update(khYear, khMonth, wgyLevel); + } + + @Override + public List> listWgy(Map queryMap) { + return kpiKhxzDao.listWgy(queryMap); + } +} 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 81b5beb..9928ce9 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 @@ -1,9 +1,12 @@ package com.cm.bigdata.service.kpi.impl; import com.cm.bigdata.dao.kpi.IKpiDao; +import com.cm.bigdata.dao.kpi.IKpiHolidayDao; import com.cm.bigdata.pojo.dtos.kpi.*; import com.cm.bigdata.pojo.pos.kpi.*; import com.cm.bigdata.service.kpi.*; +import com.cm.bigdata.utils.ExcelExportUtil; +import com.cm.bigdata.utils.KpiScoreUtil; import com.cm.bigdata.utils.KpiUtil; import com.cm.common.constants.ISystemConstant; import org.apache.commons.lang3.StringUtils; @@ -16,6 +19,8 @@ import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; import java.util.*; import java.util.stream.Collectors; @@ -40,6 +45,8 @@ public class KpiServiceImpl implements IKpiService { private ICommunityService communityService; @Autowired private IDepartmentService departmentService; + @Autowired + private KpiHolidayService kpiHolidayService; private static final DateTimeFormatter DATE_TIME_FORMATTER = DateTimeFormat.forPattern(ISystemConstant.DATE_FORMATTER_YYYY_MM_DD_HH_MM_SS); @@ -54,7 +61,9 @@ public class KpiServiceImpl implements IKpiService { List communityBossDTOList = communityBossService.list(params); List userIds = communityBossDTOList.stream().map(CommunityBossDTO::getCommunityBossUserId).filter(StringUtils::isNotBlank).collect(Collectors.toList()); List dates = listDate(startTime, endTime); + List holidays = kpiHolidayService.listFormat(KpiUtil.years(dates)); dates.forEach(date -> { + int isHoliday = KpiUtil.hasValueInList(holidays, date) ? 1 : 0; Map> userSigninMap = KpiUtil.mapSignin(userSignService, userIds, date); Map> userSignoutMap = KpiUtil.mapSignout(userSignService, userIds, date); Map populationCountMap = KpiUtil.mapPopulationCount(basePopulationInfoService, userIds); @@ -86,12 +95,22 @@ public class KpiServiceImpl implements IKpiService { queryParams.put("populationCount", populationCount); queryParams.put("savePopulationCount", savePopulationCount); queryParams.put("updatePopulationCount", updatePopulationCount); + queryParams.put("isHoliday", isHoliday); + queryParams.put("dayScore", KpiScoreUtil.getWgyDayScore(isSignin, isSigninLate, isSignout, isSignoutEarly, workDistance, 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")); + 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); + } + @Override public void updateNPersonDayCount(String departmentId, String startTime, String endTime) { Map params = new HashMap<>(); @@ -104,7 +123,9 @@ public class KpiServiceImpl implements IKpiService { } List userIds = userPOS.stream().map(UserPO::getUserId).filter(StringUtils::isNotBlank).collect(Collectors.toList()); List dates = listDate(startTime, endTime); + List holidays = kpiHolidayService.listFormat(KpiUtil.years(dates)); dates.forEach(date -> { + int isHoliday = KpiUtil.hasValueInList(holidays, date) ? 1 : 0; Map> userSigninMap = KpiUtil.mapSignin(userSignService, userIds, date); Map> userSignoutMap = KpiUtil.mapSignout(userSignService, userIds, date); // 删除当日数据 @@ -127,7 +148,7 @@ public class KpiServiceImpl implements IKpiService { queryParams.put("isSignout", isSignout); queryParams.put("isSignoutEarly", isSignoutEarly); queryParams.put("workDistance", workDistance); - + queryParams.put("isHoliday", isHoliday); kpiDao.saveNPersonDayCount(queryParams); }); }); @@ -294,7 +315,13 @@ public class KpiServiceImpl implements IKpiService { communityCaseCountDTO.setCaseInspectTotal(inspectTotal); communityCaseCountDTO.setCaseOnfileTotal(inspectTotal); return communityCaseCountDTO; - }).sorted(CommunityCaseCountDTO::compareTo).collect(Collectors.toList()); + }).filter(communityCaseCountDTO -> !StringUtils.equals("e64a0a05-45ca-4452-a869-a4dcbff74593", communityCaseCountDTO.getAreaId())).sorted(CommunityCaseCountDTO::compareTo).collect(Collectors.toList()); + } + + @Override + public void exportCommunityCaseCount(HttpServletResponse httpServletResponse, String areaId, String communityId, String startTime, String endTime) throws IOException { + List communityCaseCountDTOS = listCommunityCaseCount(areaId, communityId, startTime, endTime); + ExcelExportUtil.simple(httpServletResponse, "街镇案件情况", communityCaseCountDTOS, CommunityCaseCountDTO.class); } @Override @@ -331,6 +358,12 @@ public class KpiServiceImpl implements IKpiService { }).sorted(CommunityBossCaseCountDTO::compareTo).collect(Collectors.toList()); } + @Override + public void exportCommunityBossCaseCount(HttpServletResponse httpServletResponse, String areaId, String communityId, String startTime, String endTime, Integer communityBossLevel) throws IOException { + List communityBossCaseCountDTOS = listCommunityBossCaseCount(areaId, communityId, startTime, endTime, communityBossLevel); + ExcelExportUtil.simple(httpServletResponse, "网格员案件情况", communityBossCaseCountDTOS, CommunityBossCaseCountDTO.class); + } + @Override public List listNPersonCaseCount(String departmentId, String startTime, String endTime) { Map params = new HashMap<>(); @@ -355,6 +388,12 @@ public class KpiServiceImpl implements IKpiService { }).sorted(NPersonCaseCountDTO::compareTo).collect(Collectors.toList()); } + @Override + public void exportNPersonCaseCount(HttpServletResponse httpServletResponse, String departmentId, String startTime, String endTime) throws IOException { + List nPersonCaseCountDTOS = listNPersonCaseCount(departmentId, startTime, endTime); + ExcelExportUtil.simple(httpServletResponse, "专管员案件情况", nPersonCaseCountDTOS, NPersonCaseCountDTO.class); + } + @Override public List listCommunityBossCaseDayCount(String areaId, String communityId, String startTime, String endTime, Integer communityBossLevel) { Map params = new HashMap<>(); @@ -416,6 +455,12 @@ public class KpiServiceImpl implements IKpiService { }).sorted(CommunityBossCaseDayCountDTO::compareTo).collect(Collectors.toList()); } + @Override + public void exportCommunityBossCaseDayCount(HttpServletResponse httpServletResponse, String areaId, String communityId, String startTime, String endTime, Integer communityBossLevel) throws IOException { + List communityBossCaseDayCountDTOS = listCommunityBossCaseDayCount(areaId, communityId, startTime, endTime, communityBossLevel); + ExcelExportUtil.simple(httpServletResponse, "网格员考勤", communityBossCaseDayCountDTOS, CommunityBossCaseDayCountDTO.class); + } + @Override public List listNPersonCaseDayCount(String departmentId, String startTime, String endTime) { Map params = new HashMap<>(); @@ -458,6 +503,12 @@ public class KpiServiceImpl implements IKpiService { }).sorted(NPersonCaseDayCountDTO::compareTo).collect(Collectors.toList()); } + @Override + public void exportNPersonCaseDayCount(HttpServletResponse httpServletResponse, String departmentId, String startTime, String endTime) throws IOException { + List nPersonCaseDayCountDTOS = listNPersonCaseDayCount(departmentId, startTime, endTime); + ExcelExportUtil.simple(httpServletResponse, "专管员考勤", nPersonCaseDayCountDTOS, NPersonCaseDayCountDTO.class); + } + private Integer countCase(Map params) { return kpiDao.countCase(params); } diff --git a/src/main/java/com/cm/bigdata/service/kpi/impl/UserServiceImpl.java b/src/main/java/com/cm/bigdata/service/kpi/impl/UserServiceImpl.java index b2b8739..12b393b 100644 --- a/src/main/java/com/cm/bigdata/service/kpi/impl/UserServiceImpl.java +++ b/src/main/java/com/cm/bigdata/service/kpi/impl/UserServiceImpl.java @@ -23,6 +23,13 @@ public class UserServiceImpl implements IUserService { return userDao.listPO(params); } + @Override + public List listPO(List userIds) { + Map params = new HashMap<>(); + params.put("userIds", userIds); + return userDao.listPO(params); + } + @Override public List listPO(Map params) { return userDao.listPO(params); 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 new file mode 100644 index 0000000..bb1c0aa --- /dev/null +++ b/src/main/java/com/cm/bigdata/service/kpi/task/KpiKhxzWgyTask.java @@ -0,0 +1,103 @@ +package com.cm.bigdata.service.kpi.task; + +import com.cm.bigdata.dao.kpi.IKpiDao; +import com.cm.bigdata.dao.kpi.IKpiKhxzWgyDao; +import com.cm.bigdata.pojo.dtos.kpi.CommunityBossDTO; +import com.cm.bigdata.pojo.pos.kpi.UserPO; +import com.cm.bigdata.service.kpi.ICommunityBossService; +import com.cm.bigdata.service.kpi.IKpiService; +import com.cm.bigdata.service.kpi.IUserService; +import com.cm.bigdata.service.kpi.task.sub.KpiKhxzWgyCRunnable; +import org.apache.commons.lang3.StringUtils; +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; +import java.util.concurrent.ScheduledExecutorService; +import java.util.stream.Collectors; + +@Service +public class KpiKhxzWgyTask { + + @Autowired + private IKpiKhxzWgyDao kpiKhxzWgyDao; + @Autowired + private IKpiDao kpiDao; + @Autowired + private IUserService userService; + @Autowired + private ICommunityBossService communityBossService; + @Autowired + private IKpiService kpiService; + private ExecutorService executorService = Executors.newFixedThreadPool(10); + + public void update(int khYear, int khMonth, int wgyLevel) { + kpiService.updateCommunityBossDayCount(khYear, khMonth, wgyLevel); + deleteBase(khYear, khMonth, wgyLevel); + updateBase(khYear, khMonth, wgyLevel); + List userIds = listUserIds(khYear, khMonth, wgyLevel); + if (userIds.isEmpty()) { + return; + } + executorService.execute(new KpiKhxzWgyCRunnable(kpiKhxzWgyDao, kpiDao, khYear, khMonth, wgyLevel, userIds)); + } + + private List listUserIds(int khYear, int khMonth, int wgyLevel) { + Map params = new HashMap<>(); + params.put("khYear", khYear); + params.put("khMonth", khMonth); + params.put("wgyLevel", wgyLevel); + return kpiKhxzWgyDao.listUserId(params); + } + + private void deleteBase(int khYear, int khMonth, int wgyLevel) { + Map params = new HashMap<>(); + params.put("khYear", khYear); + params.put("khMonth", khMonth); + params.put("wgyLevel", wgyLevel); + kpiKhxzWgyDao.delete(params); + } + + private void updateBase(int khYear, int khMonth, int wgyLevel) { + Map params = new HashMap<>(); + params.put("communityBossLevel", wgyLevel); + // 删除 + params.put("wgyLevel", wgyLevel); + params.put("khYear", khYear); + params.put("khMonth", khMonth); + 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; + } + Map saveParams = new HashMap<>(); + saveParams.put("areaId", areaId); + saveParams.put("communityId", communityId); + saveParams.put("userId", userPO.getUserId()); + saveParams.put("B", userPO.getUserName()); + saveParams.put("khYear", khYear); + saveParams.put("khMonth", khMonth); + saveParams.put("wgyLevel", wgyLevel); + kpiKhxzWgyDao.save(saveParams); + }); + } + +} diff --git a/src/main/java/com/cm/bigdata/service/kpi/task/sub/KpiKhxzWgyCRunnable.java b/src/main/java/com/cm/bigdata/service/kpi/task/sub/KpiKhxzWgyCRunnable.java new file mode 100644 index 0000000..53c20e7 --- /dev/null +++ b/src/main/java/com/cm/bigdata/service/kpi/task/sub/KpiKhxzWgyCRunnable.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.pojo.pos.kpi.CommunityBossDayCountPO; +import com.cm.bigdata.utils.KpiUtil; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class KpiKhxzWgyCRunnable implements Runnable { + + private IKpiKhxzWgyDao kpiKhxzWgyDao; + private IKpiDao kpiDao; + private Integer year; + private Integer month; + private Integer level; + private List userIds; + + public KpiKhxzWgyCRunnable(IKpiKhxzWgyDao kpiKhxzWgyDao, IKpiDao kpiDao, Integer year, Integer month, Integer level, List userIds) { + this.kpiKhxzWgyDao = kpiKhxzWgyDao; + this.kpiDao = kpiDao; + this.year = year; + this.month = month; + this.level = level; + this.userIds = userIds; + } + + @Override + public void run() { + List dates = KpiUtil.listDate(year, month); + dates.forEach(date -> { + Map params = new HashMap<>(); + params.put("level", level); + userIds.forEach(userId -> { + params.put("userId", userId); + params.put("dayDate", date); + List communityBossDayCountPOS = kpiDao.listCommunityBossDayCountPO(params); + int workDay = 0; + double totalDayScore = 0D; + for (CommunityBossDayCountPO communityBossDayCountPO : communityBossDayCountPOS) { + int isHoliday = communityBossDayCountPO.getIsHoliday(); + if (isHoliday == 1) { + continue; + } + workDay++; + totalDayScore += communityBossDayCountPO.getDayScore(); + } + 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/KpiKhxzWgyDRunnable.java b/src/main/java/com/cm/bigdata/service/kpi/task/sub/KpiKhxzWgyDRunnable.java new file mode 100644 index 0000000..63cb1c5 --- /dev/null +++ b/src/main/java/com/cm/bigdata/service/kpi/task/sub/KpiKhxzWgyDRunnable.java @@ -0,0 +1,136 @@ +package com.cm.bigdata.service.kpi.task.sub; + +import com.cm.bigdata.dao.kpi.IKpiHolidayDao; +import com.cm.bigdata.dao.kpi.IKpiKhxzWgyDao; +import com.cm.bigdata.pojo.pos.kpi.HolidayPO; +import com.cm.bigdata.utils.KpiUtil; +import com.cm.common.constants.ISystemConstant; +import javafx.scene.effect.InnerShadow; +import org.apache.commons.lang3.StringUtils; +import org.joda.time.DateTime; +import org.joda.time.format.DateTimeFormat; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class KpiKhxzWgyDRunnable implements Runnable { + + private IKpiKhxzWgyDao kpiKhxzWgyDao; + private IKpiHolidayDao kpiHolidayDao; + private int year; + private int month; + private int level; + + @Override + public void run() { + List holidayPOS = listHoliday(); + List> dayWeeks = listDayWeekOfMonth(year, month); + int shouldReportCount = 0; + for (List dws : dayWeeks) { + int holidayCount = 0; + for (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)) { + isHoliday = true; + break; + } + } + if (isHoliday) { + holidayCount++; + } + } + // 如果假期小于4天,就应该上报一条 + if (holidayCount > 4) { + shouldReportCount++; + } + } + } + + private List listHoliday() { + Map params = new HashMap<>(); + params.put("holidayYear", year); + params.put("holidayMonth", month); + return kpiHolidayDao.list(params); + } + + private 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(); + DateTime monthEndDateTime = dayOfMonth.withMaximumValue(); + int monthEndDay = monthEndDateTime.getDayOfMonth(); + List> dayWeeks = new ArrayList<>(); + int weekOfMonth = 1; + List currentWeekDays = new ArrayList<>(); + for (int i = 1; i <= monthEndDay; i++) { + DateTime dayDateTime = dateTime.withDayOfMonth(i); + 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)) { + dayWeeks.add(currentWeekDays); + weekOfMonth++; + currentWeekDays = new ArrayList<>(); + } + } + return dayWeeks; + } + + public static class DayWeek { + private String date; + private int year; + private int month; + private int day; + private int weekOfMonth; + private int dayOfWeek; + + public DayWeek(String date, int weekOfMonth, int dayOfWeek) { + this.date = date; + this.weekOfMonth = weekOfMonth; + this.dayOfWeek = dayOfWeek; + String[] dateArray = date.split("-"); + this.year = Integer.parseInt(dateArray[0]); + this.month = Integer.parseInt(dateArray[1]); + this.day = Integer.parseInt(dateArray[2]); + } + + public String getDate() { + return date; + } + + public int getYear() { + return year; + } + + public int getMonth() { + return month; + } + + public int getDay() { + return day; + } + + public int getWeekOfMonth() { + return weekOfMonth; + } + + public int getDayOfWeek() { + return dayOfWeek; + } + + @Override + public String toString() { + return "DayWeek{" + + "date='" + date + '\'' + + ", year=" + year + + ", month=" + month + + ", day=" + day + + ", weekOfMonth=" + weekOfMonth + + ", dayOfWeek=" + dayOfWeek + + '}'; + } + } +} diff --git a/src/main/java/com/cm/bigdata/utils/ExcelExportUtil.java b/src/main/java/com/cm/bigdata/utils/ExcelExportUtil.java new file mode 100644 index 0000000..83d7aa6 --- /dev/null +++ b/src/main/java/com/cm/bigdata/utils/ExcelExportUtil.java @@ -0,0 +1,20 @@ +package com.cm.bigdata.utils; + +import com.alibaba.excel.EasyExcel; + +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.net.URLEncoder; +import java.util.List; + +public class ExcelExportUtil { + + public static void simple(HttpServletResponse response, String fileName, List dataList, Class clazz) throws IOException { + response.setContentType("application/vnd.ms-excel"); + response.setCharacterEncoding("utf-8"); + String exportName = URLEncoder.encode(fileName, "utf-8"); + response.setHeader("Content-disposition", "attachment;filename=" + exportName + ".xlsx"); + EasyExcel.write(response.getOutputStream(), clazz).sheet("sheet1").doWrite(dataList); + } + +} diff --git a/src/main/java/com/cm/bigdata/utils/KpiScoreUtil.java b/src/main/java/com/cm/bigdata/utils/KpiScoreUtil.java new file mode 100644 index 0000000..de2f8ba --- /dev/null +++ b/src/main/java/com/cm/bigdata/utils/KpiScoreUtil.java @@ -0,0 +1,29 @@ +package com.cm.bigdata.utils; + +public class KpiScoreUtil { + + private static double WGY_SIGNIN_SCORE = 10D; + private static double WGY_SIGNOUT_SCORE = 10D; + private static double WGY_DISTANCE_SCORE = 20D; + + public static double getWgyDayScore(int isSignin, int isSigninLate, int isSignout, int isSignoutEarly, double workDistance, int isHoliday) { + if (isHoliday == 1) { + return 0; + } + double signinScore = 0D; + double signoutScore = 0D; + double distanceScore = 0D; + if (isSignin == 1) { + signinScore += isSigninLate == 1 ? WGY_SIGNIN_SCORE / 2 : WGY_SIGNIN_SCORE; + } + if (isSignout == 1) { + signoutScore += isSignoutEarly == 1 ? WGY_SIGNOUT_SCORE / 2 : WGY_SIGNOUT_SCORE; + } + if (workDistance > 0) { + distanceScore = WGY_DISTANCE_SCORE; + } + return signinScore + signoutScore + distanceScore; + } + + +} diff --git a/src/main/java/com/cm/bigdata/utils/KpiTaskManager.java b/src/main/java/com/cm/bigdata/utils/KpiTaskManager.java new file mode 100644 index 0000000..3a50722 --- /dev/null +++ b/src/main/java/com/cm/bigdata/utils/KpiTaskManager.java @@ -0,0 +1,19 @@ +package com.cm.bigdata.utils; + +public class KpiTaskManager { + public static KpiTaskManager kpiTaskManager = KpiTaskManagerBuilder.KPI_TASK_MANAGER; + + private KpiTaskManager() { + + } + + public static KpiTaskManager getInstance() { + return kpiTaskManager; + } + + + private static class KpiTaskManagerBuilder { + public static final KpiTaskManager KPI_TASK_MANAGER = new KpiTaskManager(); + } + +} diff --git a/src/main/java/com/cm/bigdata/utils/KpiUtil.java b/src/main/java/com/cm/bigdata/utils/KpiUtil.java index 3c389f0..51839f4 100644 --- a/src/main/java/com/cm/bigdata/utils/KpiUtil.java +++ b/src/main/java/com/cm/bigdata/utils/KpiUtil.java @@ -1,5 +1,6 @@ package com.cm.bigdata.utils; +import com.cm.bigdata.dao.kpi.IKpiKhxzWgyDao; import com.cm.bigdata.pojo.pos.kpi.BasePopulationInfoCountPO; import com.cm.bigdata.pojo.pos.kpi.UserLocationPO; import com.cm.bigdata.pojo.pos.kpi.UserSigninPO; @@ -7,17 +8,47 @@ import com.cm.bigdata.pojo.pos.kpi.UserSignoutPO; import com.cm.bigdata.service.kpi.IBasePopulationInfoService; import com.cm.bigdata.service.kpi.IUserLocationService; import com.cm.bigdata.service.kpi.IUserSignService; +import com.cm.common.constants.ISystemConstant; import com.cm.common.utils.point.Point; import com.cm.common.utils.point.PointUtil; import org.apache.commons.lang3.StringUtils; +import org.joda.time.DateTime; +import org.joda.time.format.DateTimeFormat; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; +import java.util.stream.Collectors; public class KpiUtil { + public static boolean hasValueInList(List values, String checkValue) { + for (String value : values) { + if (StringUtils.equals(value, checkValue)) { + return true; + } + } + return false; + } + + public static List years(List dates) { + Set years = new LinkedHashSet<>(); + dates.forEach(date -> { + int year = Integer.parseInt(date.split("-")[0]); + years.add(year); + }); + return new ArrayList<>(years); + } + + public static List listDate(int year, int month) { + DateTime dateTime = DateTime.parse(String.format("%04d-%02d", year, month), DateTimeFormat.forPattern("yyyy-MM")); + DateTime maxValueDateTime = dateTime.dayOfMonth().withMaximumValue(); + int maxDateValue = maxValueDateTime.getDayOfMonth(); + List dates = new ArrayList<>(); + for (int day = 1; day <= maxDateValue; day++) { + dates.add(String.format("%04d-%02d-%02d", year, month, day)); + } + return dates; + } + /** * 签到map * diff --git a/src/main/resources/mybatis/db2-mapper/kpi/user-mapper.xml b/src/main/resources/mybatis/db2-mapper/kpi/user-mapper.xml index 5f36b97..83b3b87 100644 --- a/src/main/resources/mybatis/db2-mapper/kpi/user-mapper.xml +++ b/src/main/resources/mybatis/db2-mapper/kpi/user-mapper.xml @@ -17,6 +17,13 @@ sys_user su WHERE is_delete = 0 + + AND + user_id IN + + #{userIds[${index}]} + + AND EXISTS ( diff --git a/src/main/resources/mybatis/mapper/kpi/kpi-holiday-mapper.xml b/src/main/resources/mybatis/mapper/kpi/kpi-holiday-mapper.xml new file mode 100644 index 0000000..3834c56 --- /dev/null +++ b/src/main/resources/mybatis/mapper/kpi/kpi-holiday-mapper.xml @@ -0,0 +1,36 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/mybatis/mapper/kpi/kpi-khxz-mapper.xml b/src/main/resources/mybatis/mapper/kpi/kpi-khxz-mapper.xml new file mode 100644 index 0000000..deffb36 --- /dev/null +++ b/src/main/resources/mybatis/mapper/kpi/kpi-khxz-mapper.xml @@ -0,0 +1,16 @@ + + + + + + + \ No newline at end of file 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 new file mode 100644 index 0000000..cd579c6 --- /dev/null +++ b/src/main/resources/mybatis/mapper/kpi/kpi-khxz-wgy-mapper.xml @@ -0,0 +1,67 @@ + + + + + + INSERT INTO kpi_khxz_wgy_${wgyLevel}( + area_id, + community_id, + user_id, + kh_year, + kh_month, + B + ) VALUES ( + #{areaId}, + #{communityId}, + #{userId}, + #{khYear}, + #{khMonth}, + #{B} + ) + + + + DELETE FROM + kpi_khxz_wgy_${wgyLevel} + WHERE + kh_year = #{khYear} + AND + kh_month = #{khMonth} + + + + + + UPDATE + kpi_khxz_wgy_${wgyLevel} + SET + C = #{C} + 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 29551d9..029118d 100644 --- a/src/main/resources/mybatis/mapper/kpi/kpi-mapper.xml +++ b/src/main/resources/mybatis/mapper/kpi/kpi-mapper.xml @@ -13,6 +13,8 @@ + + @@ -23,6 +25,8 @@ + + @@ -65,7 +69,9 @@ work_distance, population_count, save_population_count, - update_population_count + update_population_count, + is_holiday, + day_score ) VALUES ( #{userId}, #{dayDate}, @@ -76,7 +82,9 @@ #{workDistance}, #{populationCount}, #{savePopulationCount}, - #{updatePopulationCount} + #{updatePopulationCount}, + #{isHoliday}, + #{dayScore} ) @@ -99,7 +107,9 @@ is_signout_early = #{isSignoutEarly}, work_distance = #{workDistance}, save_population_count = #{savePopulationCount}, - update_population_count = #{updatePopulationCount} + update_population_count = #{updatePopulationCount}, + is_holiday = #{isHoliday}, + day_score = #{dayScore} WHERE user_id = #{userId} AND @@ -118,7 +128,9 @@ is_signout_early, work_distance, save_population_count, - update_population_count + update_population_count, + is_holiday, + day_score FROM kpi_community_boss_${level}_day_count WHERE @@ -289,14 +301,18 @@ is_signin, is_signin_late, is_signout, - is_signout_early + is_signout_early, + is_holiday, + day_score ) VALUES ( #{userId}, #{dayDate}, #{isSignin}, #{isSigninLate}, #{isSignout}, - #{isSignoutEarly} + #{isSignoutEarly}, + #{isHoliday}, + #{dayScore} ) @@ -355,6 +371,10 @@ AND user_id = #{userId} + + AND + day_date = #{dayDate} + AND diff --git a/src/main/resources/static/route/kpi/community-boss-count.html b/src/main/resources/static/route/kpi/community-boss-count.html index 7069335..96c02a2 100644 --- a/src/main/resources/static/route/kpi/community-boss-count.html +++ b/src/main/resources/static/route/kpi/community-boss-count.html @@ -56,6 +56,9 @@ +
@@ -257,6 +260,10 @@ reloadTable(1); }); + $(document).on('click', '#exportData', function() { + window.open(top.restAjax.path('api/kpi/export-community-boss-case-count?areaId={areaId}&communityId={communityId}&startTime={startTime}&endTime={endTime}&communityBossLevel={communityBossLevel}', [$('#areaId').val(), $('#communityId').val(), $('#startTime').val(), $('#endTime').val(), $('#communityBossLevel').val()])) + }); + }) diff --git a/src/main/resources/static/route/kpi/community-boss-day-count.html b/src/main/resources/static/route/kpi/community-boss-day-count.html index e3b6ba9..d22cded 100644 --- a/src/main/resources/static/route/kpi/community-boss-day-count.html +++ b/src/main/resources/static/route/kpi/community-boss-day-count.html @@ -59,6 +59,9 @@ +
@@ -365,6 +368,10 @@ }); }); }); + + $(document).on('click', '#exportData', function() { + window.open(top.restAjax.path('api/kpi/export-community-boss-case-day-count?areaId={areaId}&communityId={communityId}&startTime={startTime}&endTime={endTime}&communityBossLevel={communityBossLevel}', [$('#areaId').val(), $('#communityId').val(), $('#startTime').val(), $('#endTime').val(), $('#communityBossLevel').val()])) + }); }) diff --git a/src/main/resources/static/route/kpi/community-count.html b/src/main/resources/static/route/kpi/community-count.html index b64ccd2..7ad6a5e 100644 --- a/src/main/resources/static/route/kpi/community-count.html +++ b/src/main/resources/static/route/kpi/community-count.html @@ -53,6 +53,9 @@ +
@@ -274,6 +277,10 @@ }); }); }); + + $(document).on('click', '#exportData', function() { + window.open(top.restAjax.path('api/kpi/export-community-case-count?areaId={areaId}&communityId={communityId}&startTime={startTime}&endTime={endTime}', [$('#areaId').val(), $('#communityId').val(), $('#startTime').val(), $('#endTime').val()])) + }); }) diff --git a/src/main/resources/static/route/kpi/n-person-count.html b/src/main/resources/static/route/kpi/n-person-count.html index de57044..f0c1c83 100644 --- a/src/main/resources/static/route/kpi/n-person-count.html +++ b/src/main/resources/static/route/kpi/n-person-count.html @@ -41,6 +41,9 @@ +
@@ -186,6 +189,10 @@ reloadTable(1); }); + $(document).on('click', '#exportData', function() { + window.open(top.restAjax.path('api/kpi/export-n-person-count?departmentId={departmentId}&startTime={startTime}&endTime={endTime}', [$('#departmentId').val(), $('#startTime').val(), $('#endTime').val()])) + }); + }) diff --git a/src/main/resources/static/route/kpi/n-person-day-count.html b/src/main/resources/static/route/kpi/n-person-day-count.html index d7663bb..772ec62 100644 --- a/src/main/resources/static/route/kpi/n-person-day-count.html +++ b/src/main/resources/static/route/kpi/n-person-day-count.html @@ -44,6 +44,9 @@ +
@@ -265,6 +268,10 @@ }); }); + $(document).on('click', '#exportData', function() { + window.open(top.restAjax.path('api/kpi/export-n-person-day-count?departmentId={departmentId}&startTime={startTime}&endTime={endTime}', [$('#departmentId').val(), $('#startTime').val(), $('#endTime').val()])) + }); + })