增加季度考核统计功能

This commit is contained in:
TS-QD1 2023-05-10 18:15:25 +08:00
parent 0c63fd773d
commit b97e0deb6a
38 changed files with 1044 additions and 13 deletions

View File

@ -41,7 +41,7 @@ public class AuthClientSecurityConfig extends WebSecurityConfigurerAdapter {
.and() .and()
.logout().logoutSuccessUrl(authServer.getOauthLogout()) .logout().logoutSuccessUrl(authServer.getOauthLogout())
.and() .and()
.authorizeRequests().antMatchers("/app/**", "/route/file/**", "/assets/**").permitAll() .authorizeRequests().antMatchers("/app/**", "/route/file/**", "/assets/**", "/api/kpi/khxz/**").permitAll()
.and() .and()
.authorizeRequests() .authorizeRequests()
.anyRequest() .anyRequest()

View File

@ -13,6 +13,8 @@ import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -92,6 +94,15 @@ public class KpiController extends AbstractController {
return kpiService.listCommunityCaseCount(areaId, communityId, startTime, endTime); 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") @GetMapping("list-community-boss-case-count")
public List<CommunityBossCaseCountDTO> listCommunityBossCaseCount(@RequestParam(name = "areaId", required = false) String areaId, public List<CommunityBossCaseCountDTO> listCommunityBossCaseCount(@RequestParam(name = "areaId", required = false) String areaId,
@RequestParam(name = "communityId", required = false) String communityId, @RequestParam(name = "communityId", required = false) String communityId,
@ -101,6 +112,16 @@ public class KpiController extends AbstractController {
return kpiService.listCommunityBossCaseCount(areaId, communityId, startTime, endTime, communityBossLevel); 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") @GetMapping("list-n-person-count")
public List<NPersonCaseCountDTO> listNPersonCaseCount(@RequestParam(name = "departmentId", required = false) String departmentId, public List<NPersonCaseCountDTO> listNPersonCaseCount(@RequestParam(name = "departmentId", required = false) String departmentId,
@RequestParam(name = "startTime", required = false) String startTime, @RequestParam(name = "startTime", required = false) String startTime,
@ -108,6 +129,14 @@ public class KpiController extends AbstractController {
return kpiService.listNPersonCaseCount(departmentId, startTime, endTime); 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") @GetMapping("list-community-boss-case-day-count")
public List<CommunityBossCaseDayCountDTO> listCommunityBossCaseDayCount(@RequestParam(name = "areaId", required = false) String areaId, public List<CommunityBossCaseDayCountDTO> listCommunityBossCaseDayCount(@RequestParam(name = "areaId", required = false) String areaId,
@RequestParam(name = "communityId", required = false) String communityId, @RequestParam(name = "communityId", required = false) String communityId,
@ -117,6 +146,16 @@ public class KpiController extends AbstractController {
return kpiService.listCommunityBossCaseDayCount(areaId, communityId, startTime, endTime, communityBossLevel); 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") @GetMapping("list-n-person-day-count")
public List<NPersonCaseDayCountDTO> listNPersonCaseDayCount(@RequestParam(name = "departmentId", required = false) String departmentId, public List<NPersonCaseDayCountDTO> listNPersonCaseDayCount(@RequestParam(name = "departmentId", required = false) String departmentId,
@RequestParam(name = "startTime", required = false) String startTime, @RequestParam(name = "startTime", required = false) String startTime,
@ -124,6 +163,14 @@ public class KpiController extends AbstractController {
return kpiService.listNPersonCaseDayCount(departmentId, startTime, endTime); 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}") @GetMapping("listpage-user-signin/user-id/{userId}")
public SuccessResultList<List<UserSigninDTO>> listUserSignin(@PathVariable("userId") String userId, public SuccessResultList<List<UserSigninDTO>> listUserSignin(@PathVariable("userId") String userId,
@RequestParam(name = "startTime", required = false) String startTime, @RequestParam(name = "startTime", required = false) String startTime,

View File

@ -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<Map<String, Object>> listWgy() {
Map<String, Object> queryMap = requestParams();
return kpiKhxzService.listWgy(queryMap);
}
}

View File

@ -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<HolidayPO> list(Map<String, Object> params);
}

View File

@ -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<Map<String, Object>> listWgy(Map<String, Object> queryMap);
}

View File

@ -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<String, Object> params);
void delete(Map<String, Object> params);
@MapKey("id")
List<Map<String, Object>> listWgy(Map<String, Object> params);
void updateC(Map<String, Object> updateParams);
List<String> listUserId(Map<String, Object> params);
}

View File

@ -1,16 +1,29 @@
package com.cm.bigdata.pojo.dtos.kpi; package com.cm.bigdata.pojo.dtos.kpi;
import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty;
public class CommunityBossCaseCountDTO implements Comparable<CommunityBossCaseCountDTO> { public class CommunityBossCaseCountDTO implements Comparable<CommunityBossCaseCountDTO> {
@ExcelIgnore
private String areaId; private String areaId;
@ExcelProperty(value = "地区", index = 0)
private String areaName; private String areaName;
@ExcelIgnore
private String communityId; private String communityId;
@ExcelProperty(value = "社区", index = 1)
private String communityName; private String communityName;
@ExcelIgnore
private String userId; private String userId;
@ExcelProperty(value = "姓名", index = 2)
private String userName; private String userName;
@ExcelProperty(value = "案件总数", index = 3)
private Integer caseTotal; private Integer caseTotal;
@ExcelProperty(value = "已处理案件", index = 4)
private Integer caseHandleTotal; private Integer caseHandleTotal;
@ExcelProperty(value = "已检查案件", index = 5)
private Integer caseInspectTotal; private Integer caseInspectTotal;
@ExcelProperty(value = "已归档案件", index = 6)
private Integer caseOnfileTotal; private Integer caseOnfileTotal;
public String getAreaId() { public String getAreaId() {

View File

@ -1,23 +1,43 @@
package com.cm.bigdata.pojo.dtos.kpi; package com.cm.bigdata.pojo.dtos.kpi;
import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty;
public class CommunityBossCaseDayCountDTO implements Comparable<CommunityBossCaseDayCountDTO> { public class CommunityBossCaseDayCountDTO implements Comparable<CommunityBossCaseDayCountDTO> {
@ExcelIgnore
private String areaId; private String areaId;
@ExcelProperty(value = "地区", index = 0)
private String areaName; private String areaName;
@ExcelIgnore
private String communityId; private String communityId;
@ExcelProperty(value = "社区", index = 1)
private String communityName; private String communityName;
@ExcelIgnore
private String userId; private String userId;
@ExcelProperty(value = "姓名", index = 2)
private String userName; private String userName;
@ExcelProperty(value = "签到次数", index = 3)
private Integer isSigninTotal; private Integer isSigninTotal;
@ExcelProperty(value = "迟到次数", index = 4)
private Integer isSigninLateTotal; private Integer isSigninLateTotal;
@ExcelProperty(value = "签退次数", index = 5)
private Integer isSignoutTotal; private Integer isSignoutTotal;
@ExcelProperty(value = "早退次数", index = 6)
private Integer isSignoutEarlyTotal; private Integer isSignoutEarlyTotal;
@ExcelProperty(value = "移动距离", index = 7)
private Double workDistanceTotal; private Double workDistanceTotal;
@ExcelProperty(value = "新增人口", index = 8)
private Integer savePopulationCountTotal; private Integer savePopulationCountTotal;
@ExcelProperty(value = "维护人口", index = 9)
private Integer updatePopulationCountTotal; private Integer updatePopulationCountTotal;
@ExcelProperty(value = "案件总数", index = 10)
private Integer caseTotal; private Integer caseTotal;
@ExcelProperty(value = "已处理案件", index = 11)
private Integer caseHandleTotal; private Integer caseHandleTotal;
@ExcelProperty(value = "已检查案件", index = 12)
private Integer caseInspectTotal; private Integer caseInspectTotal;
@ExcelProperty(value = "已归档案件", index = 13)
private Integer caseOnfileTotal; private Integer caseOnfileTotal;
public String getAreaId() { public String getAreaId() {

View File

@ -1,15 +1,27 @@
package com.cm.bigdata.pojo.dtos.kpi; package com.cm.bigdata.pojo.dtos.kpi;
import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty;
public class CommunityCaseCountDTO implements Comparable<CommunityCaseCountDTO> { public class CommunityCaseCountDTO implements Comparable<CommunityCaseCountDTO> {
@ExcelIgnore
private String areaId; private String areaId;
@ExcelProperty(value = "地区", index = 0)
private String areaName; private String areaName;
@ExcelIgnore
private String communityId; private String communityId;
@ExcelProperty(value = "社区", index = 1)
private String communityName; private String communityName;
@ExcelProperty(value = "案件总数", index = 2)
private Integer caseTotal; private Integer caseTotal;
@ExcelProperty(value = "已受理案件", index = 3)
private Integer caseAcceptTotal; private Integer caseAcceptTotal;
@ExcelProperty(value = "已处理案件", index = 4)
private Integer caseHandleTotal; private Integer caseHandleTotal;
@ExcelProperty(value = "已检查案件", index = 5)
private Integer caseInspectTotal; private Integer caseInspectTotal;
@ExcelProperty(value = "已归档案件", index = 6)
private Integer caseOnfileTotal; private Integer caseOnfileTotal;
public String getAreaId() { public String getAreaId() {

View File

@ -1,12 +1,21 @@
package com.cm.bigdata.pojo.dtos.kpi; package com.cm.bigdata.pojo.dtos.kpi;
import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty;
public class NPersonCaseCountDTO implements Comparable<NPersonCaseCountDTO> { public class NPersonCaseCountDTO implements Comparable<NPersonCaseCountDTO> {
@ExcelIgnore
private String departmentId; private String departmentId;
@ExcelProperty(value = "职能部门", index = 0)
private String departmentName; private String departmentName;
@ExcelIgnore
private String userId; private String userId;
@ExcelProperty(value = "姓名", index = 1)
private String userName; private String userName;
@ExcelProperty(value = "上报案件总数", index = 2)
private Integer caseReportTotal; private Integer caseReportTotal;
@ExcelProperty(value = "处理案件总数", index = 3)
private Integer caseHandleTotal; private Integer caseHandleTotal;
public String getDepartmentId() { public String getDepartmentId() {

View File

@ -1,16 +1,29 @@
package com.cm.bigdata.pojo.dtos.kpi; package com.cm.bigdata.pojo.dtos.kpi;
import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty;
public class NPersonCaseDayCountDTO implements Comparable<NPersonCaseDayCountDTO> { public class NPersonCaseDayCountDTO implements Comparable<NPersonCaseDayCountDTO> {
@ExcelIgnore
private String departmentId; private String departmentId;
@ExcelProperty(value = "职能部门", index = 0)
private String departmentName; private String departmentName;
@ExcelIgnore
private String userId; private String userId;
@ExcelProperty(value = "姓名", index = 1)
private String userName; private String userName;
@ExcelProperty(value = "签到次数", index = 2)
private Integer isSigninTotal; private Integer isSigninTotal;
@ExcelProperty(value = "迟到次数", index = 3)
private Integer isSigninLateTotal; private Integer isSigninLateTotal;
@ExcelProperty(value = "签退次数", index = 4)
private Integer isSignoutTotal; private Integer isSignoutTotal;
@ExcelProperty(value = "早退次数", index = 5)
private Integer isSignoutEarlyTotal; private Integer isSignoutEarlyTotal;
@ExcelProperty(value = "上报案件总数", index = 6)
private Integer caseReportTotal; private Integer caseReportTotal;
@ExcelProperty(value = "处理案件总数", index = 7)
private Integer caseHandleTotal; private Integer caseHandleTotal;
public String getDepartmentId() { public String getDepartmentId() {

View File

@ -15,6 +15,8 @@ public class CommunityBossDayCountPO {
private Double workDistance; private Double workDistance;
private Integer savePopulationCount; private Integer savePopulationCount;
private Integer updatePopulationCount; private Integer updatePopulationCount;
private Integer isHoliday;
private Double dayScore;
public Long getId() { public Long getId() {
return id; return id;
@ -95,4 +97,20 @@ public class CommunityBossDayCountPO {
public void setUpdatePopulationCount(Integer updatePopulationCount) { public void setUpdatePopulationCount(Integer updatePopulationCount) {
this.updatePopulationCount = 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;
}
} }

View File

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

View File

@ -9,6 +9,8 @@ public class NPersonDayCountPO {
private Integer isSigninLate; private Integer isSigninLate;
private Integer isSignout; private Integer isSignout;
private Integer isSignoutEarly; private Integer isSignoutEarly;
private Integer isHoliday;
private Double dayScore;
public Long getId() { public Long getId() {
return id; return id;
@ -65,4 +67,20 @@ public class NPersonDayCountPO {
public void setIsSignoutEarly(Integer isSignoutEarly) { public void setIsSignoutEarly(Integer isSignoutEarly) {
this.isSignoutEarly = 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;
}
} }

View File

@ -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<Map<String, Object>> listWgy(Map<String, Object> queryMap);
}

View File

@ -2,6 +2,8 @@ package com.cm.bigdata.service.kpi;
import com.cm.bigdata.pojo.dtos.kpi.*; import com.cm.bigdata.pojo.dtos.kpi.*;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List; 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(String areaId, String communityId, String startTime, String endTime, int level);
void updateCommunityBossDayCount(int year, int month, int level);
/** /**
* 更新N员 * 更新N员
* 更新N员 * 更新N员
@ -41,12 +45,23 @@ public interface IKpiService {
*/ */
List<CommunityCaseCountDTO> listCommunityCaseCount(String areaId, String communityId, String startTime, String endTime); List<CommunityCaseCountDTO> listCommunityCaseCount(String areaId, String communityId, String startTime, String endTime);
void exportCommunityCaseCount(HttpServletResponse httpServletResponse, String areaId, String communityId, String startTime, String endTime) throws IOException;
List<CommunityBossCaseCountDTO> listCommunityBossCaseCount(String areaId, String communityId, String startTime, String endTime, Integer communityBossLevel); List<CommunityBossCaseCountDTO> 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<NPersonCaseCountDTO> listNPersonCaseCount(String departmentId, String startTime, String endTime); List<NPersonCaseCountDTO> listNPersonCaseCount(String departmentId, String startTime, String endTime);
void exportNPersonCaseCount(HttpServletResponse httpServletResponse, String departmentId, String startTime, String endTime) throws IOException;
List<CommunityBossCaseDayCountDTO> listCommunityBossCaseDayCount(String areaId, String communityId, String startTime, String endTime, Integer communityBossLevel); List<CommunityBossCaseDayCountDTO> 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<NPersonCaseDayCountDTO> listNPersonCaseDayCount(String departmentId, String startTime, String endTime); List<NPersonCaseDayCountDTO> listNPersonCaseDayCount(String departmentId, String startTime, String endTime);
void exportNPersonCaseDayCount(HttpServletResponse httpServletResponse, String departmentId, String startTime, String endTime) throws IOException;
} }

View File

@ -8,6 +8,8 @@ import java.util.Map;
public interface IUserService { public interface IUserService {
List<UserPO> listPOByRoleId(String roleId); List<UserPO> listPOByRoleId(String roleId);
List<UserPO> listPO(List<String> userIds);
List<UserPO> listPO(Map<String, Object> params); List<UserPO> listPO(Map<String, Object> params);
} }

View File

@ -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<HolidayPO> list(int year) {
Map<String, Object> params = new HashMap<>();
params.put("holidayYear", year);
return kpiHolidayDao.list(params);
}
public List<HolidayPO> list(List<Integer> years) {
Map<String, Object> params = new HashMap<>();
params.put("holidayYears", years);
return kpiHolidayDao.list(params);
}
public List<HolidayPO> list(int year, int month) {
Map<String, Object> params = new HashMap<>();
params.put("holidayYear", year);
params.put("holidayMonth", month);
return kpiHolidayDao.list(params);
}
public List<String> listFormat(int year) {
List<HolidayPO> pos = list(year);
return listFormatByPOs(pos);
}
public List<String> listFormat(List<Integer> years) {
List<HolidayPO> pos = list(years);
return listFormatByPOs(pos);
}
public List<String> listFormat(int year, int month) {
List<HolidayPO> pos = list(year, month);
List<String> list = new ArrayList<>();
pos.forEach(holidayPO -> {
list.add(String.format("%04d-%02d-%02d", holidayPO.getHolidayYear(), holidayPO.getHolidayMonth(), holidayPO.getHolidayDay()));
});
return list;
}
public List<String> listFormatByPOs(List<HolidayPO> pos) {
List<String> list = new ArrayList<>();
pos.forEach(holidayPO -> {
list.add(String.format("%04d-%02d-%02d", holidayPO.getHolidayYear(), holidayPO.getHolidayMonth(), holidayPO.getHolidayDay()));
});
return list;
}
}

View File

@ -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<Map<String, Object>> listWgy(Map<String, Object> queryMap) {
return kpiKhxzDao.listWgy(queryMap);
}
}

View File

@ -1,9 +1,12 @@
package com.cm.bigdata.service.kpi.impl; package com.cm.bigdata.service.kpi.impl;
import com.cm.bigdata.dao.kpi.IKpiDao; 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.dtos.kpi.*;
import com.cm.bigdata.pojo.pos.kpi.*; import com.cm.bigdata.pojo.pos.kpi.*;
import com.cm.bigdata.service.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.bigdata.utils.KpiUtil;
import com.cm.common.constants.ISystemConstant; import com.cm.common.constants.ISystemConstant;
import org.apache.commons.lang3.StringUtils; 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.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -40,6 +45,8 @@ public class KpiServiceImpl implements IKpiService {
private ICommunityService communityService; private ICommunityService communityService;
@Autowired @Autowired
private IDepartmentService departmentService; 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); 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<CommunityBossDTO> communityBossDTOList = communityBossService.list(params); List<CommunityBossDTO> communityBossDTOList = communityBossService.list(params);
List<String> userIds = communityBossDTOList.stream().map(CommunityBossDTO::getCommunityBossUserId).filter(StringUtils::isNotBlank).collect(Collectors.toList()); List<String> userIds = communityBossDTOList.stream().map(CommunityBossDTO::getCommunityBossUserId).filter(StringUtils::isNotBlank).collect(Collectors.toList());
List<String> dates = listDate(startTime, endTime); List<String> dates = listDate(startTime, endTime);
List<String> holidays = kpiHolidayService.listFormat(KpiUtil.years(dates));
dates.forEach(date -> { dates.forEach(date -> {
int isHoliday = KpiUtil.hasValueInList(holidays, date) ? 1 : 0;
Map<String, List<UserSigninPO>> userSigninMap = KpiUtil.mapSignin(userSignService, userIds, date); Map<String, List<UserSigninPO>> userSigninMap = KpiUtil.mapSignin(userSignService, userIds, date);
Map<String, List<UserSignoutPO>> userSignoutMap = KpiUtil.mapSignout(userSignService, userIds, date); Map<String, List<UserSignoutPO>> userSignoutMap = KpiUtil.mapSignout(userSignService, userIds, date);
Map<String, Integer> populationCountMap = KpiUtil.mapPopulationCount(basePopulationInfoService, userIds); Map<String, Integer> populationCountMap = KpiUtil.mapPopulationCount(basePopulationInfoService, userIds);
@ -86,12 +95,22 @@ public class KpiServiceImpl implements IKpiService {
queryParams.put("populationCount", populationCount); queryParams.put("populationCount", populationCount);
queryParams.put("savePopulationCount", savePopulationCount); queryParams.put("savePopulationCount", savePopulationCount);
queryParams.put("updatePopulationCount", updatePopulationCount); queryParams.put("updatePopulationCount", updatePopulationCount);
queryParams.put("isHoliday", isHoliday);
queryParams.put("dayScore", KpiScoreUtil.getWgyDayScore(isSignin, isSigninLate, isSignout, isSignoutEarly, workDistance, isHoliday));
queryParams.put("level", communityBossLevel); queryParams.put("level", communityBossLevel);
kpiDao.saveCommunityBossDayCount(queryParams); 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 @Override
public void updateNPersonDayCount(String departmentId, String startTime, String endTime) { public void updateNPersonDayCount(String departmentId, String startTime, String endTime) {
Map<String, Object> params = new HashMap<>(); Map<String, Object> params = new HashMap<>();
@ -104,7 +123,9 @@ public class KpiServiceImpl implements IKpiService {
} }
List<String> userIds = userPOS.stream().map(UserPO::getUserId).filter(StringUtils::isNotBlank).collect(Collectors.toList()); List<String> userIds = userPOS.stream().map(UserPO::getUserId).filter(StringUtils::isNotBlank).collect(Collectors.toList());
List<String> dates = listDate(startTime, endTime); List<String> dates = listDate(startTime, endTime);
List<String> holidays = kpiHolidayService.listFormat(KpiUtil.years(dates));
dates.forEach(date -> { dates.forEach(date -> {
int isHoliday = KpiUtil.hasValueInList(holidays, date) ? 1 : 0;
Map<String, List<UserSigninPO>> userSigninMap = KpiUtil.mapSignin(userSignService, userIds, date); Map<String, List<UserSigninPO>> userSigninMap = KpiUtil.mapSignin(userSignService, userIds, date);
Map<String, List<UserSignoutPO>> userSignoutMap = KpiUtil.mapSignout(userSignService, userIds, date); Map<String, List<UserSignoutPO>> userSignoutMap = KpiUtil.mapSignout(userSignService, userIds, date);
// 删除当日数据 // 删除当日数据
@ -127,7 +148,7 @@ public class KpiServiceImpl implements IKpiService {
queryParams.put("isSignout", isSignout); queryParams.put("isSignout", isSignout);
queryParams.put("isSignoutEarly", isSignoutEarly); queryParams.put("isSignoutEarly", isSignoutEarly);
queryParams.put("workDistance", workDistance); queryParams.put("workDistance", workDistance);
queryParams.put("isHoliday", isHoliday);
kpiDao.saveNPersonDayCount(queryParams); kpiDao.saveNPersonDayCount(queryParams);
}); });
}); });
@ -294,7 +315,13 @@ public class KpiServiceImpl implements IKpiService {
communityCaseCountDTO.setCaseInspectTotal(inspectTotal); communityCaseCountDTO.setCaseInspectTotal(inspectTotal);
communityCaseCountDTO.setCaseOnfileTotal(inspectTotal); communityCaseCountDTO.setCaseOnfileTotal(inspectTotal);
return communityCaseCountDTO; 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<CommunityCaseCountDTO> communityCaseCountDTOS = listCommunityCaseCount(areaId, communityId, startTime, endTime);
ExcelExportUtil.simple(httpServletResponse, "街镇案件情况", communityCaseCountDTOS, CommunityCaseCountDTO.class);
} }
@Override @Override
@ -331,6 +358,12 @@ public class KpiServiceImpl implements IKpiService {
}).sorted(CommunityBossCaseCountDTO::compareTo).collect(Collectors.toList()); }).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<CommunityBossCaseCountDTO> communityBossCaseCountDTOS = listCommunityBossCaseCount(areaId, communityId, startTime, endTime, communityBossLevel);
ExcelExportUtil.simple(httpServletResponse, "网格员案件情况", communityBossCaseCountDTOS, CommunityBossCaseCountDTO.class);
}
@Override @Override
public List<NPersonCaseCountDTO> listNPersonCaseCount(String departmentId, String startTime, String endTime) { public List<NPersonCaseCountDTO> listNPersonCaseCount(String departmentId, String startTime, String endTime) {
Map<String, Object> params = new HashMap<>(); Map<String, Object> params = new HashMap<>();
@ -355,6 +388,12 @@ public class KpiServiceImpl implements IKpiService {
}).sorted(NPersonCaseCountDTO::compareTo).collect(Collectors.toList()); }).sorted(NPersonCaseCountDTO::compareTo).collect(Collectors.toList());
} }
@Override
public void exportNPersonCaseCount(HttpServletResponse httpServletResponse, String departmentId, String startTime, String endTime) throws IOException {
List<NPersonCaseCountDTO> nPersonCaseCountDTOS = listNPersonCaseCount(departmentId, startTime, endTime);
ExcelExportUtil.simple(httpServletResponse, "专管员案件情况", nPersonCaseCountDTOS, NPersonCaseCountDTO.class);
}
@Override @Override
public List<CommunityBossCaseDayCountDTO> listCommunityBossCaseDayCount(String areaId, String communityId, String startTime, String endTime, Integer communityBossLevel) { public List<CommunityBossCaseDayCountDTO> listCommunityBossCaseDayCount(String areaId, String communityId, String startTime, String endTime, Integer communityBossLevel) {
Map<String, Object> params = new HashMap<>(); Map<String, Object> params = new HashMap<>();
@ -416,6 +455,12 @@ public class KpiServiceImpl implements IKpiService {
}).sorted(CommunityBossCaseDayCountDTO::compareTo).collect(Collectors.toList()); }).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<CommunityBossCaseDayCountDTO> communityBossCaseDayCountDTOS = listCommunityBossCaseDayCount(areaId, communityId, startTime, endTime, communityBossLevel);
ExcelExportUtil.simple(httpServletResponse, "网格员考勤", communityBossCaseDayCountDTOS, CommunityBossCaseDayCountDTO.class);
}
@Override @Override
public List<NPersonCaseDayCountDTO> listNPersonCaseDayCount(String departmentId, String startTime, String endTime) { public List<NPersonCaseDayCountDTO> listNPersonCaseDayCount(String departmentId, String startTime, String endTime) {
Map<String, Object> params = new HashMap<>(); Map<String, Object> params = new HashMap<>();
@ -458,6 +503,12 @@ public class KpiServiceImpl implements IKpiService {
}).sorted(NPersonCaseDayCountDTO::compareTo).collect(Collectors.toList()); }).sorted(NPersonCaseDayCountDTO::compareTo).collect(Collectors.toList());
} }
@Override
public void exportNPersonCaseDayCount(HttpServletResponse httpServletResponse, String departmentId, String startTime, String endTime) throws IOException {
List<NPersonCaseDayCountDTO> nPersonCaseDayCountDTOS = listNPersonCaseDayCount(departmentId, startTime, endTime);
ExcelExportUtil.simple(httpServletResponse, "专管员考勤", nPersonCaseDayCountDTOS, NPersonCaseDayCountDTO.class);
}
private Integer countCase(Map<String, Object> params) { private Integer countCase(Map<String, Object> params) {
return kpiDao.countCase(params); return kpiDao.countCase(params);
} }

View File

@ -23,6 +23,13 @@ public class UserServiceImpl implements IUserService {
return userDao.listPO(params); return userDao.listPO(params);
} }
@Override
public List<UserPO> listPO(List<String> userIds) {
Map<String, Object> params = new HashMap<>();
params.put("userIds", userIds);
return userDao.listPO(params);
}
@Override @Override
public List<UserPO> listPO(Map<String, Object> params) { public List<UserPO> listPO(Map<String, Object> params) {
return userDao.listPO(params); return userDao.listPO(params);

View File

@ -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<String> userIds = listUserIds(khYear, khMonth, wgyLevel);
if (userIds.isEmpty()) {
return;
}
executorService.execute(new KpiKhxzWgyCRunnable(kpiKhxzWgyDao, kpiDao, khYear, khMonth, wgyLevel, userIds));
}
private List<String> listUserIds(int khYear, int khMonth, int wgyLevel) {
Map<String, Object> 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<String, Object> 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<String, Object> params = new HashMap<>();
params.put("communityBossLevel", wgyLevel);
// 删除
params.put("wgyLevel", wgyLevel);
params.put("khYear", khYear);
params.put("khMonth", khMonth);
List<CommunityBossDTO> communityBossDTOS = communityBossService.list(params);
if (communityBossDTOS.isEmpty()) {
return;
}
List<String> userIds = communityBossDTOS.stream().map(CommunityBossDTO::getCommunityBossUserId).filter(StringUtils::isNotBlank).collect(Collectors.toList());
List<UserPO> 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<String, Object> 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);
});
}
}

View File

@ -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<String> userIds;
public KpiKhxzWgyCRunnable(IKpiKhxzWgyDao kpiKhxzWgyDao, IKpiDao kpiDao, Integer year, Integer month, Integer level, List<String> userIds) {
this.kpiKhxzWgyDao = kpiKhxzWgyDao;
this.kpiDao = kpiDao;
this.year = year;
this.month = month;
this.level = level;
this.userIds = userIds;
}
@Override
public void run() {
List<String> dates = KpiUtil.listDate(year, month);
dates.forEach(date -> {
Map<String, Object> params = new HashMap<>();
params.put("level", level);
userIds.forEach(userId -> {
params.put("userId", userId);
params.put("dayDate", date);
List<CommunityBossDayCountPO> 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<String, Object> 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);
});
});
}
}

View File

@ -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<HolidayPO> holidayPOS = listHoliday();
List<List<DayWeek>> dayWeeks = listDayWeekOfMonth(year, month);
int shouldReportCount = 0;
for (List<DayWeek> 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<HolidayPO> listHoliday() {
Map<String, Object> params = new HashMap<>();
params.put("holidayYear", year);
params.put("holidayMonth", month);
return kpiHolidayDao.list(params);
}
private List<List<DayWeek>> 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<List<DayWeek>> dayWeeks = new ArrayList<>();
int weekOfMonth = 1;
List<DayWeek> 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 +
'}';
}
}
}

View File

@ -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 <T> void simple(HttpServletResponse response, String fileName, List<T> dataList, Class<T> 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);
}
}

View File

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

View File

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

View File

@ -1,5 +1,6 @@
package com.cm.bigdata.utils; 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.BasePopulationInfoCountPO;
import com.cm.bigdata.pojo.pos.kpi.UserLocationPO; import com.cm.bigdata.pojo.pos.kpi.UserLocationPO;
import com.cm.bigdata.pojo.pos.kpi.UserSigninPO; 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.IBasePopulationInfoService;
import com.cm.bigdata.service.kpi.IUserLocationService; import com.cm.bigdata.service.kpi.IUserLocationService;
import com.cm.bigdata.service.kpi.IUserSignService; 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.Point;
import com.cm.common.utils.point.PointUtil; import com.cm.common.utils.point.PointUtil;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.joda.time.DateTime;
import org.joda.time.format.DateTimeFormat;
import java.util.ArrayList; import java.util.*;
import java.util.HashMap; import java.util.stream.Collectors;
import java.util.List;
import java.util.Map;
public class KpiUtil { public class KpiUtil {
public static boolean hasValueInList(List<String> values, String checkValue) {
for (String value : values) {
if (StringUtils.equals(value, checkValue)) {
return true;
}
}
return false;
}
public static List<Integer> years(List<String> dates) {
Set<Integer> years = new LinkedHashSet<>();
dates.forEach(date -> {
int year = Integer.parseInt(date.split("-")[0]);
years.add(year);
});
return new ArrayList<>(years);
}
public static List<String> 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<String> dates = new ArrayList<>();
for (int day = 1; day <= maxDateValue; day++) {
dates.add(String.format("%04d-%02d-%02d", year, month, day));
}
return dates;
}
/** /**
* 签到map * 签到map
* *

View File

@ -17,6 +17,13 @@
sys_user su sys_user su
WHERE WHERE
is_delete = 0 is_delete = 0
<if test="userIds != null and userIds.size > 0">
AND
user_id IN
<foreach collection="userIds" index="index" open="(" separator="," close=")">
#{userIds[${index}]}
</foreach>
</if>
<if test="departmentId != null and departmentId != ''"> <if test="departmentId != null and departmentId != ''">
AND AND
EXISTS ( EXISTS (

View File

@ -0,0 +1,36 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.cm.bigdata.dao.kpi.IKpiHolidayDao">
<resultMap id="holidayPO" type="com.cm.bigdata.pojo.pos.kpi.HolidayPO">
<result column="holiday_year" property="holidayYear"/>
<result column="holiday_month" property="holidayMonth"/>
<result column="holiday_day" property="holidayDay"/>
</resultMap>
<select id="list" parameterType="map" resultMap="holidayPO">
SELECT
holiday_year,
holiday_month,
holiday_day
FROM
kpi_holiday
<where>
<if test="holidayYears != null and holidayYears.size > 0">
holiday_year IN
<foreach collection="holidayYears" index="index" open="(" separator="," close=")">
#{holidayYears[${index}]}
</foreach>
</if>
<if test="holidayYear != null">
AND
holiday_year = #{holidayYear}
</if>
<if test="holidayMonth != null">
AND
holiday_month = #{holidayMonth}
</if>
</where>
</select>
</mapper>

View File

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.cm.bigdata.dao.kpi.IKpiKhxzDao">
<select id="listWgy" parameterType="map" resultType="map">
SELECT
*
FROM
kpi_khxz_wgy_${wgyLevel}
WHERE
kh_year = #{khYear}
AND
kh_month = #{khMonth}
</select>
</mapper>

View File

@ -0,0 +1,67 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.cm.bigdata.dao.kpi.IKpiKhxzWgyDao">
<insert id="save" parameterType="map">
INSERT INTO kpi_khxz_wgy_${wgyLevel}(
area_id,
community_id,
user_id,
kh_year,
kh_month,
B
) VALUES (
#{areaId},
#{communityId},
#{userId},
#{khYear},
#{khMonth},
#{B}
)
</insert>
<delete id="delete" parameterType="map">
DELETE FROM
kpi_khxz_wgy_${wgyLevel}
WHERE
kh_year = #{khYear}
AND
kh_month = #{khMonth}
</delete>
<select id="listWgy" parameterType="map" resultType="map">
SELECT
*
FROM
kpi_khxz_wgy_${wgyLevel}
WHERE
kh_year = #{khYear}
AND
kh_month = #{khMonth}
</select>
<update id="updateC" parameterType="map">
UPDATE
kpi_khxz_wgy_${wgyLevel}
SET
C = #{C}
WHERE
kh_year = #{khYear}
AND
kh_month = #{khMonth}
AND
user_id = #{userId}
</update>
<select id="listUserId" parameterType="map" resultType="java.lang.String">
SELECT
user_id
FROM
kpi_khxz_wgy_${wgyLevel}
WHERE
kh_year = #{khYear}
AND
kh_month = #{khMonth}
</select>
</mapper>

View File

@ -13,6 +13,8 @@
<result column="work_distance" property="workDistance"/> <result column="work_distance" property="workDistance"/>
<result column="save_population_count" property="savePopulationCount"/> <result column="save_population_count" property="savePopulationCount"/>
<result column="update_population_count" property="updatePopulationCount"/> <result column="update_population_count" property="updatePopulationCount"/>
<result column="is_holiday" property="isHoliday"/>
<result column="day_score" property="dayScore"/>
</resultMap> </resultMap>
<resultMap id="nPersonDayCountPO" type="com.cm.bigdata.pojo.pos.kpi.NPersonDayCountPO"> <resultMap id="nPersonDayCountPO" type="com.cm.bigdata.pojo.pos.kpi.NPersonDayCountPO">
@ -23,6 +25,8 @@
<result column="is_signin_late" property="isSigninLate"/> <result column="is_signin_late" property="isSigninLate"/>
<result column="is_signout" property="isSignout"/> <result column="is_signout" property="isSignout"/>
<result column="is_signout_early" property="isSignoutEarly"/> <result column="is_signout_early" property="isSignoutEarly"/>
<result column="is_holiday" property="isHoliday"/>
<result column="day_score" property="dayScore"/>
</resultMap> </resultMap>
<resultMap id="casePO" type="com.cm.bigdata.pojo.pos.kpi.CasePO"> <resultMap id="casePO" type="com.cm.bigdata.pojo.pos.kpi.CasePO">
@ -65,7 +69,9 @@
work_distance, work_distance,
population_count, population_count,
save_population_count, save_population_count,
update_population_count update_population_count,
is_holiday,
day_score
) VALUES ( ) VALUES (
#{userId}, #{userId},
#{dayDate}, #{dayDate},
@ -76,7 +82,9 @@
#{workDistance}, #{workDistance},
#{populationCount}, #{populationCount},
#{savePopulationCount}, #{savePopulationCount},
#{updatePopulationCount} #{updatePopulationCount},
#{isHoliday},
#{dayScore}
) )
</insert> </insert>
@ -99,7 +107,9 @@
is_signout_early = #{isSignoutEarly}, is_signout_early = #{isSignoutEarly},
work_distance = #{workDistance}, work_distance = #{workDistance},
save_population_count = #{savePopulationCount}, save_population_count = #{savePopulationCount},
update_population_count = #{updatePopulationCount} update_population_count = #{updatePopulationCount},
is_holiday = #{isHoliday},
day_score = #{dayScore}
WHERE WHERE
user_id = #{userId} user_id = #{userId}
AND AND
@ -118,7 +128,9 @@
is_signout_early, is_signout_early,
work_distance, work_distance,
save_population_count, save_population_count,
update_population_count update_population_count,
is_holiday,
day_score
FROM FROM
kpi_community_boss_${level}_day_count kpi_community_boss_${level}_day_count
WHERE WHERE
@ -289,14 +301,18 @@
is_signin, is_signin,
is_signin_late, is_signin_late,
is_signout, is_signout,
is_signout_early is_signout_early,
is_holiday,
day_score
) VALUES ( ) VALUES (
#{userId}, #{userId},
#{dayDate}, #{dayDate},
#{isSignin}, #{isSignin},
#{isSigninLate}, #{isSigninLate},
#{isSignout}, #{isSignout},
#{isSignoutEarly} #{isSignoutEarly},
#{isHoliday},
#{dayScore}
) )
</insert> </insert>
@ -355,6 +371,10 @@
<if test="userId != null and userId != ''"> <if test="userId != null and userId != ''">
AND AND
user_id = #{userId} user_id = #{userId}
<if test="dayDate != null and dayDate != ''">
AND
day_date = #{dayDate}
</if>
</if> </if>
<if test="startTime != null and startTime != ''"> <if test="startTime != null and startTime != ''">
AND AND

View File

@ -56,6 +56,9 @@
<button type="button" id="search" class="layui-btn layui-btn-sm"> <button type="button" id="search" class="layui-btn layui-btn-sm">
<i class="fa fa-lg fa-search"></i> 搜索 <i class="fa fa-lg fa-search"></i> 搜索
</button> </button>
<button type="button" id="exportData" class="layui-btn layui-btn-sm layui-btn-normal">
<i class="fa fa-lg fa-download"></i> 导出
</button>
</div> </div>
<table class="layui-hide" id="dataTable" lay-filter="dataTable"></table> <table class="layui-hide" id="dataTable" lay-filter="dataTable"></table>
@ -257,6 +260,10 @@
reloadTable(1); 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()]))
});
}) })
</script> </script>
</body> </body>

View File

@ -59,6 +59,9 @@
<button type="button" id="refreshData" class="layui-btn layui-btn-sm"> <button type="button" id="refreshData" class="layui-btn layui-btn-sm">
<i class="fa fa-lg fa-refresh"></i> 更新数据 <i class="fa fa-lg fa-refresh"></i> 更新数据
</button> </button>
<button type="button" id="exportData" class="layui-btn layui-btn-sm layui-btn-normal">
<i class="fa fa-lg fa-download"></i> 导出
</button>
</div> </div>
<table class="layui-hide" id="dataTable" lay-filter="dataTable"></table> <table class="layui-hide" id="dataTable" lay-filter="dataTable"></table>
@ -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()]))
});
}) })
</script> </script>
</body> </body>

View File

@ -53,6 +53,9 @@
<button type="button" id="refreshData" class="layui-btn layui-btn-sm"> <button type="button" id="refreshData" class="layui-btn layui-btn-sm">
<i class="fa fa-lg fa-refresh"></i> 更新案件情况 <i class="fa fa-lg fa-refresh"></i> 更新案件情况
</button> </button>
<button type="button" id="exportData" class="layui-btn layui-btn-sm layui-btn-normal">
<i class="fa fa-lg fa-download"></i> 导出
</button>
</div> </div>
<table class="layui-hide" id="dataTable" lay-filter="dataTable"></table> <table class="layui-hide" id="dataTable" lay-filter="dataTable"></table>
@ -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()]))
});
}) })
</script> </script>
</body> </body>

View File

@ -41,6 +41,9 @@
<button type="button" id="search" class="layui-btn layui-btn-sm"> <button type="button" id="search" class="layui-btn layui-btn-sm">
<i class="fa fa-lg fa-search"></i> 搜索 <i class="fa fa-lg fa-search"></i> 搜索
</button> </button>
<button type="button" id="exportData" class="layui-btn layui-btn-sm layui-btn-normal">
<i class="fa fa-lg fa-download"></i> 导出
</button>
</div> </div>
<table class="layui-hide" id="dataTable" lay-filter="dataTable"></table> <table class="layui-hide" id="dataTable" lay-filter="dataTable"></table>
@ -186,6 +189,10 @@
reloadTable(1); 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()]))
});
}) })
</script> </script>
</body> </body>

View File

@ -44,6 +44,9 @@
<button type="button" id="refreshData" class="layui-btn layui-btn-sm"> <button type="button" id="refreshData" class="layui-btn layui-btn-sm">
<i class="fa fa-lg fa-refresh"></i> 更新数据 <i class="fa fa-lg fa-refresh"></i> 更新数据
</button> </button>
<button type="button" id="exportData" class="layui-btn layui-btn-sm layui-btn-normal">
<i class="fa fa-lg fa-download"></i> 导出
</button>
</div> </div>
<table class="layui-hide" id="dataTable" lay-filter="dataTable"></table> <table class="layui-hide" id="dataTable" lay-filter="dataTable"></table>
@ -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()]))
});
}) })
</script> </script>
</body> </body>