Commit 99abf6a3 authored by 廖旭伟's avatar 廖旭伟

部门绩效总分排行榜,个人绩效总分排行榜

parent 068186e1
package com.mortals.xhx.common.code;
import java.util.LinkedHashMap;
import java.util.Map;
/***
* 绩效排行榜汇总方式
*/
public enum SummaryTopTypeEnum {
(1, "年"),
(2, "月"),
(3, "日"),
;
private Integer value;
private String desc;
SummaryTopTypeEnum(Integer value, String desc) {
this.value = value;
this.desc = desc;
}
public Integer getValue() {
return this.value;
}
public String getDesc() {
return this.desc;
}
public static SummaryTopTypeEnum getByValue(Integer value) {
for (SummaryTopTypeEnum item : SummaryTopTypeEnum.values()) {
if (item.getValue() == value) {
return item;
}
}
return null;
}
/**
* 获取Map集合
*
* @param eItem 不包含项
* @return
*/
public static Map<String, String> getEnumMap(Integer... eItem) {
Map<String, String> resultMap = new LinkedHashMap<>();
for (SummaryTopTypeEnum item : SummaryTopTypeEnum.values()) {
try {
boolean hasE = false;
for (Integer e : eItem) {
if (item.getValue() == e) {
hasE = true;
break;
}
}
if (!hasE) {
resultMap.put(item.getValue() + "", item.getDesc());
}
} catch (Exception ex) {
}
}
return resultMap;
}
}
......@@ -2,6 +2,8 @@ package com.mortals.xhx.module.dept.dao;
import com.mortals.framework.dao.ICRUDDao;
import com.mortals.xhx.module.dept.model.DeptPerformStatEntity;
import com.mortals.xhx.module.dept.model.vo.DeptSummaryTopQuery;
import java.util.List;
/**
* 部门绩效分数统计Dao
......@@ -13,5 +15,22 @@ import java.util.List;
public interface DeptPerformStatDao extends ICRUDDao<DeptPerformStatEntity,Long>{
/**
* 按天top10
* @param query
* @return
*/
List<DeptPerformStatEntity> getDaySummaryList(DeptSummaryTopQuery query);
/**
* 按月top10
* @param query
* @return
*/
List<DeptPerformStatEntity> getMonthSummaryList(DeptSummaryTopQuery query);
/**
* 按年top10
* @param query
* @return
*/
List<DeptPerformStatEntity> getYearSummaryList(DeptSummaryTopQuery query);
}
package com.mortals.xhx.module.dept.dao.ibatis;
import com.mortals.xhx.module.dept.model.vo.DeptSummaryTopQuery;
import org.springframework.stereotype.Repository;
import com.mortals.xhx.module.dept.dao.DeptPerformStatDao;
import com.mortals.xhx.module.dept.model.DeptPerformStatEntity;
......@@ -17,5 +18,18 @@ import java.util.List;
public class DeptPerformStatDaoImpl extends BaseCRUDDaoMybatis<DeptPerformStatEntity,Long> implements DeptPerformStatDao {
@Override
public List<DeptPerformStatEntity> getDaySummaryList(DeptSummaryTopQuery query) {
return this.getSqlSession().selectList(this.getSqlId("getDaySummaryList"), query);
}
@Override
public List<DeptPerformStatEntity> getMonthSummaryList(DeptSummaryTopQuery query) {
return this.getSqlSession().selectList(this.getSqlId("getMonthSummaryList"), query);
}
@Override
public List<DeptPerformStatEntity> getYearSummaryList(DeptSummaryTopQuery query) {
return this.getSqlSession().selectList(this.getSqlId("getYearSummaryList"), query);
}
}
......@@ -7,4 +7,18 @@ import lombok.Data;
*/
@Data
public class DeptSummaryTopQuery {
/** 汇总方式 1按年,2按月,3按天*/
private Integer summaryType;
/**
* 年
*/
private Integer year;
/**
* 月
*/
private Integer month;
/**
* 日
*/
private Integer day;
}
package com.mortals.xhx.module.dept.service;
import com.mortals.framework.exception.AppException;
import com.mortals.framework.service.ICRUDService;
import com.mortals.xhx.module.dept.model.DeptPerformStatEntity;
import com.mortals.xhx.module.dept.dao.DeptPerformStatDao;
import com.mortals.xhx.module.dept.model.vo.DeptSummaryTopQuery;
import java.util.List;
/**
* DeptPerformStatService
*
......@@ -13,4 +18,12 @@ import com.mortals.xhx.module.dept.dao.DeptPerformStatDao;
public interface DeptPerformStatService extends ICRUDService<DeptPerformStatEntity,Long>{
DeptPerformStatDao getDao();
/**
* 获取部门绩效排行榜
* @param query
* @return
*/
List<DeptPerformStatEntity> getSummaryTopList(DeptSummaryTopQuery query) throws AppException;
}
\ No newline at end of file
package com.mortals.xhx.module.dept.service.impl;
import com.mortals.framework.util.DateUtils;
import com.mortals.xhx.common.code.SummaryTopTypeEnum;
import com.mortals.xhx.module.dept.model.vo.DeptSummaryTopQuery;
import org.springframework.stereotype.Service;
import com.mortals.framework.service.impl.AbstractCRUDServiceImpl;
import com.mortals.framework.exception.AppException;
......@@ -7,6 +10,10 @@ import com.mortals.xhx.module.dept.dao.DeptPerformStatDao;
import com.mortals.xhx.module.dept.model.DeptPerformStatEntity;
import com.mortals.xhx.module.dept.service.DeptPerformStatService;
import lombok.extern.slf4j.Slf4j;
import java.time.LocalDate;
import java.util.List;
/**
* DeptPerformStatService
* 部门绩效分数统计 service实现
......@@ -17,5 +24,43 @@ import lombok.extern.slf4j.Slf4j;
@Service("deptPerformStatService")
@Slf4j
public class DeptPerformStatServiceImpl extends AbstractCRUDServiceImpl<DeptPerformStatDao, DeptPerformStatEntity, Long> implements DeptPerformStatService {
@Override
public List<DeptPerformStatEntity> getSummaryTopList(DeptSummaryTopQuery query) throws AppException {
LocalDate now = LocalDate.now();
List<DeptPerformStatEntity> result = null;
if(query == null){
query = new DeptSummaryTopQuery();
query.setSummaryType(SummaryTopTypeEnum..getValue());
}
if(query.getSummaryType() == SummaryTopTypeEnum..getValue()){
if(query.getYear()==null){
query.setYear(now.getYear());
}
result = dao.getYearSummaryList(query);
}
if(query.getSummaryType() == SummaryTopTypeEnum..getValue()){
if(query.getYear()==null){
query.setYear(now.getYear());
}
if(query.getMonth()==null){
query.setMonth(now.getMonthValue());
}
result = dao.getMonthSummaryList(query);
}
if(query.getSummaryType() == SummaryTopTypeEnum..getValue()){
if(query.getYear()==null){
query.setYear(now.getYear());
}
if(query.getMonth()==null){
query.setMonth(now.getMonthValue());
}
if(query.getDay()==null){
query.setDay(now.getDayOfMonth());
}
result = dao.getDaySummaryList(query);
}
return result;
}
}
\ No newline at end of file
package com.mortals.xhx.module.dept.web;
import com.mortals.framework.annotation.UnAuth;
import com.mortals.framework.common.Rest;
import com.mortals.framework.model.PageInfo;
import com.mortals.framework.model.Result;
import com.mortals.framework.web.BaseCRUDJsonBodyMappingController;
import com.mortals.xhx.base.system.param.service.ParamService;
import com.mortals.xhx.module.dept.model.vo.DeptSummaryTopQuery;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
......@@ -47,5 +53,35 @@ public class DeptPerformStatController extends BaseCRUDJsonBodyMappingController
super.init(model, context);
}
/**
* 部门绩效排行榜
* @param query
* @return
*/
@PostMapping({"summary/top"})
@UnAuth
public Rest<Object> getSummaryTopList(@RequestBody DeptSummaryTopQuery query) {
Rest<Object> ret = new Rest();
Map<String, Object> model = new HashMap();
Context context = this.getContext();
String busiDesc = "查询部门绩效排行榜";
int code = 1;
try {
List<DeptPerformStatEntity> result = this.getService().getSummaryTopList(query);
model.put("data", result);
model.put("message_info", busiDesc + "成功");
if (!ObjectUtils.isEmpty(context) && !ObjectUtils.isEmpty(context.getUser())) {
this.recordSysLog(this.request, busiDesc + " 【成功】");
}
} catch (Exception var9) {
code = -1;
this.doException(this.request, busiDesc, model, var9);
}
this.init(model, context);
ret.setCode(code);
ret.setData(model.get("data"));
ret.setMsg(model.get("message_info") == null ? "" : model.remove("message_info").toString());
return ret;
}
}
\ No newline at end of file
......@@ -2,6 +2,8 @@ package com.mortals.xhx.module.staff.dao;
import com.mortals.framework.dao.ICRUDDao;
import com.mortals.xhx.module.staff.model.StaffPerformStatEntity;
import com.mortals.xhx.module.staff.model.vo.StaffSummaryTopQuery;
import java.util.List;
/**
* 员工绩效统计Dao
......@@ -13,5 +15,22 @@ import java.util.List;
public interface StaffPerformStatDao extends ICRUDDao<StaffPerformStatEntity,Long>{
/**
* 按天top10
* @param query
* @return
*/
List<StaffPerformStatEntity> getDaySummaryList(StaffSummaryTopQuery query);
/**
* 按月top10
* @param query
* @return
*/
List<StaffPerformStatEntity> getMonthSummaryList(StaffSummaryTopQuery query);
/**
* 按年top10
* @param query
* @return
*/
List<StaffPerformStatEntity> getYearSummaryList(StaffSummaryTopQuery query);
}
package com.mortals.xhx.module.staff.dao.ibatis;
import com.mortals.xhx.module.staff.model.vo.StaffSummaryTopQuery;
import org.springframework.stereotype.Repository;
import com.mortals.xhx.module.staff.dao.StaffPerformStatDao;
import com.mortals.xhx.module.staff.model.StaffPerformStatEntity;
......@@ -17,5 +18,18 @@ import java.util.List;
public class StaffPerformStatDaoImpl extends BaseCRUDDaoMybatis<StaffPerformStatEntity,Long> implements StaffPerformStatDao {
@Override
public List<StaffPerformStatEntity> getDaySummaryList(StaffSummaryTopQuery query) {
return this.getSqlSession().selectList(this.getSqlId("getDaySummaryList"), query);
}
@Override
public List<StaffPerformStatEntity> getMonthSummaryList(StaffSummaryTopQuery query) {
return this.getSqlSession().selectList(this.getSqlId("getMonthSummaryList"), query);
}
@Override
public List<StaffPerformStatEntity> getYearSummaryList(StaffSummaryTopQuery query) {
return this.getSqlSession().selectList(this.getSqlId("getYearSummaryList"), query);
}
}
package com.mortals.xhx.module.staff.model.vo;
import lombok.Data;
/**
* 个人绩效总分排名统计查询条件
*/
@Data
public class StaffSummaryTopQuery {
/** 汇总方式 1按年,2按月,3按天*/
private Integer summaryType;
/**
* 年
*/
private Integer year;
/**
* 月
*/
private Integer month;
/**
* 日
*/
private Integer day;
}
package com.mortals.xhx.module.staff.service;
import com.mortals.framework.exception.AppException;
import com.mortals.framework.service.ICRUDService;
import com.mortals.xhx.module.staff.model.StaffPerformStatEntity;
import com.mortals.xhx.module.staff.dao.StaffPerformStatDao;
import com.mortals.xhx.module.staff.model.vo.StaffSummaryTopQuery;
import java.util.List;
/**
* StaffPerformStatService
*
......@@ -13,4 +18,11 @@ import com.mortals.xhx.module.staff.dao.StaffPerformStatDao;
public interface StaffPerformStatService extends ICRUDService<StaffPerformStatEntity,Long>{
StaffPerformStatDao getDao();
/**
* 获取部门个人绩效排行榜
* @param query
* @return
*/
List<StaffPerformStatEntity> getSummaryTopList(StaffSummaryTopQuery query) throws AppException;
}
\ No newline at end of file
package com.mortals.xhx.module.staff.service.impl;
import org.springframework.stereotype.Service;
import com.mortals.framework.service.impl.AbstractCRUDServiceImpl;
import com.mortals.framework.exception.AppException;
import com.mortals.framework.model.Context;
import com.mortals.framework.service.impl.AbstractCRUDServiceImpl;
import com.mortals.xhx.common.code.SummaryTopTypeEnum;
import com.mortals.xhx.module.staff.dao.StaffPerformStatDao;
import com.mortals.xhx.module.staff.model.StaffPerformStatEntity;
import com.mortals.xhx.module.staff.model.vo.StaffSummaryTopQuery;
import com.mortals.xhx.module.staff.service.StaffPerformStatService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import java.time.LocalDate;
import java.util.List;
/**
* StaffPerformStatService
* 员工绩效统计 service实现
......@@ -17,5 +23,43 @@ import lombok.extern.slf4j.Slf4j;
@Service("staffPerformStatService")
@Slf4j
public class StaffPerformStatServiceImpl extends AbstractCRUDServiceImpl<StaffPerformStatDao, StaffPerformStatEntity, Long> implements StaffPerformStatService {
@Override
public List<StaffPerformStatEntity> getSummaryTopList(StaffSummaryTopQuery query) throws AppException {
LocalDate now = LocalDate.now();
List<StaffPerformStatEntity> result = null;
if(query == null){
query = new StaffSummaryTopQuery();
query.setSummaryType(SummaryTopTypeEnum..getValue());
}
if(query.getSummaryType() == SummaryTopTypeEnum..getValue()){
if(query.getYear()==null){
query.setYear(now.getYear());
}
result = dao.getYearSummaryList(query);
}
if(query.getSummaryType() == SummaryTopTypeEnum..getValue()){
if(query.getYear()==null){
query.setYear(now.getYear());
}
if(query.getMonth()==null){
query.setMonth(now.getMonthValue());
}
result = dao.getMonthSummaryList(query);
}
if(query.getSummaryType() == SummaryTopTypeEnum..getValue()){
if(query.getYear()==null){
query.setYear(now.getYear());
}
if(query.getMonth()==null){
query.setMonth(now.getMonthValue());
}
if(query.getDay()==null){
query.setDay(now.getDayOfMonth());
}
result = dao.getDaySummaryList(query);
}
return result;
}
}
\ No newline at end of file
package com.mortals.xhx.module.staff.web;
import com.mortals.framework.annotation.UnAuth;
import com.mortals.framework.common.Rest;
import com.mortals.framework.model.Context;
import com.mortals.framework.web.BaseCRUDJsonBodyMappingController;
import com.mortals.xhx.base.system.param.service.ParamService;
import com.mortals.xhx.module.staff.model.StaffPerformStatEntity;
import com.mortals.xhx.module.staff.model.vo.StaffSummaryTopQuery;
import com.mortals.xhx.module.staff.service.StaffPerformStatService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import com.mortals.framework.model.Context;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.mortals.framework.web.BaseCRUDJsonBodyMappingController;
import com.mortals.xhx.module.staff.model.StaffPerformStatEntity;
import com.mortals.xhx.module.staff.service.StaffPerformStatService;
import org.apache.commons.lang3.ArrayUtils;
import com.mortals.framework.util.StringUtils;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import com.alibaba.fastjson.JSONObject;
import java.util.Arrays;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import static com.mortals.framework.ap.SysConstains.*;
/**
*
* 员工绩效统计
......@@ -47,5 +43,35 @@ public class StaffPerformStatController extends BaseCRUDJsonBodyMappingControlle
super.init(model, context);
}
/**
* 部门绩效排行榜
* @param query
* @return
*/
@PostMapping({"summary/top"})
@UnAuth
public Rest<Object> getSummaryTopList(@RequestBody StaffSummaryTopQuery query) {
Rest<Object> ret = new Rest();
Map<String, Object> model = new HashMap();
Context context = this.getContext();
String busiDesc = "查询个人绩效排行榜";
int code = 1;
try {
List<StaffPerformStatEntity> result = this.getService().getSummaryTopList(query);
model.put("data", result);
model.put("message_info", busiDesc + "成功");
if (!ObjectUtils.isEmpty(context) && !ObjectUtils.isEmpty(context.getUser())) {
this.recordSysLog(this.request, busiDesc + " 【成功】");
}
} catch (Exception var9) {
code = -1;
this.doException(this.request, busiDesc, model, var9);
}
this.init(model, context);
ret.setCode(code);
ret.setData(model.get("data"));
ret.setMsg(model.get("message_info") == null ? "" : model.remove("message_info").toString());
return ret;
}
}
\ No newline at end of file
......@@ -3,7 +3,7 @@
"mybatis-3-mapper.dtd">
<mapper namespace="com.mortals.xhx.module.dept.dao.ibatis.DeptPerformStatDaoImpl">
<!-- 按天top10 -->
<select id="getSummaryCheckList" parameterType="com.mortals.xhx.module.dept.model.vo.DeptSummaryTopQuery" resultType="com.mortals.xhx.module.dept.model.DeptPerformStatEntity">
<select id="getDaySummaryList" parameterType="com.mortals.xhx.module.dept.model.vo.DeptSummaryTopQuery" resultType="com.mortals.xhx.module.dept.model.DeptPerformStatEntity">
SELECT * FROM (
SELECT
`year`,
......@@ -31,4 +31,56 @@
`day`
) AS a ORDER BY totalScore DESC LIMIT 10
</select>
<!-- 按月top10 -->
<select id="getMonthSummaryList" parameterType="com.mortals.xhx.module.dept.model.vo.DeptSummaryTopQuery" resultType="com.mortals.xhx.module.dept.model.DeptPerformStatEntity">
SELECT * FROM (
SELECT
`year`,
`month`,
deptId,
deptName,
SUM(totalScore) AS totalScore
FROM
mortals_xhx_dept_perform_stat
WHERE 1=1
<if test="year != null">
AND `year` = #{year}
</if>
<if test="month != null">
AND `month` = #{month}
</if>
GROUP BY
deptId,
`year`,
`month`
) AS a ORDER BY totalScore DESC LIMIT 10
</select>
<!-- 按年top10 -->
<select id="getYearSummaryList" parameterType="com.mortals.xhx.module.dept.model.vo.DeptSummaryTopQuery" resultType="com.mortals.xhx.module.dept.model.DeptPerformStatEntity">
SELECT * FROM (
SELECT
`year`,
deptId,
deptName,
SUM(totalScore) AS totalScore
FROM
mortals_xhx_dept_perform_stat
WHERE 1=1
<if test="year != null">
AND `year` = #{year}
</if>
<if test="month != null">
AND `month` = #{month}
</if>
<if test="day != null">
AND `day` = #{day}
</if>
GROUP BY
deptId,
`year`
) AS a ORDER BY totalScore DESC LIMIT 10
</select>
</mapper>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"mybatis-3-mapper.dtd">
<mapper namespace="com.mortals.xhx.module.staff.dao.ibatis.StaffPerformStatDaoImpl">
<!-- 按天top10 -->
<select id="getDaySummaryList" parameterType="com.mortals.xhx.module.staff.model.vo.StaffSummaryTopQuery" resultType="com.mortals.xhx.module.staff.model.StaffPerformStatEntity">
SELECT * FROM (
SELECT
`year`,
`month`,
`day`,
staffId,
staffName,
SUM(totalScore) AS totalScore
FROM
mortals_xhx_staff_perform_stat
WHERE 1=1
<if test="year != null">
AND `year` = #{year}
</if>
<if test="month != null">
AND `month` = #{month}
</if>
<if test="day != null">
AND `day` = #{day}
</if>
GROUP BY
staffId,
`year`,
`month`,
`day`
) AS a ORDER BY totalScore DESC LIMIT 10
</select>
<!-- 按月top10 -->
<select id="getMonthSummaryList" parameterType="com.mortals.xhx.module.staff.model.vo.StaffSummaryTopQuery" resultType="com.mortals.xhx.module.staff.model.StaffPerformStatEntity">
SELECT * FROM (
SELECT
`year`,
`month`,
staffId,
staffName,
SUM(totalScore) AS totalScore
FROM
mortals_xhx_staff_perform_stat
WHERE 1=1
<if test="year != null">
AND `year` = #{year}
</if>
<if test="month != null">
AND `month` = #{month}
</if>
GROUP BY
staffId,
`year`,
`month`
) AS a ORDER BY totalScore DESC LIMIT 10
</select>
<!-- 按年top10 -->
<select id="getYearSummaryList" parameterType="com.mortals.xhx.module.staff.model.vo.StaffSummaryTopQuery" resultType="com.mortals.xhx.module.staff.model.StaffPerformStatEntity">
SELECT * FROM (
SELECT
`year`,
staffId,
staffName,
SUM(totalScore) AS totalScore
FROM
mortals_xhx_staff_perform_stat
WHERE 1=1
<if test="year != null">
AND `year` = #{year}
</if>
GROUP BY
staffId,
`year`
) AS a ORDER BY totalScore DESC LIMIT 10
</select>
</mapper>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment