Commit 728a2926 authored by 廖旭伟's avatar 廖旭伟

绩效分值情况(年、月、日)统计

parent 479855a7
......@@ -4,6 +4,8 @@ import com.mortals.framework.model.PageInfo;
import com.mortals.framework.model.Result;
import com.mortals.xhx.module.check.model.CheckAllRecordQuery;
import com.mortals.xhx.module.check.model.vo.CheckAllRecordVo;
import com.mortals.xhx.module.check.model.vo.CheckAllScoreSummaryVo;
import com.mortals.xhx.module.check.model.vo.StaffCheckSummaryQuery;
import java.util.List;
......@@ -12,5 +14,18 @@ import java.util.List;
*/
public interface CheckAllRecordDao {
/**
* 获取全部绩效核查信息列表
* @param query
* @param pageInfo
* @return
*/
Result<CheckAllRecordVo> getAllCheckRecord(CheckAllRecordQuery query, PageInfo pageInfo);
/**
* 绩效核查分数情况汇总
* @param query
* @return
*/
CheckAllScoreSummaryVo getScoreSummary(StaffCheckSummaryQuery query);
}
......@@ -6,6 +6,8 @@ import com.mortals.framework.model.Result;
import com.mortals.xhx.module.check.dao.CheckAllRecordDao;
import com.mortals.xhx.module.check.model.CheckAllRecordQuery;
import com.mortals.xhx.module.check.model.vo.CheckAllRecordVo;
import com.mortals.xhx.module.check.model.vo.CheckAllScoreSummaryVo;
import com.mortals.xhx.module.check.model.vo.StaffCheckSummaryQuery;
import org.apache.ibatis.session.RowBounds;
import org.apache.ibatis.session.SqlSessionFactory;
import org.mybatis.spring.support.SqlSessionDaoSupport;
......@@ -67,7 +69,12 @@ public class CheckAllRecordDaoImpl extends SqlSessionDaoSupport implements Check
return result;
}
public int getCount(CheckAllRecordQuery checkAllRecordQuery) {
private int getCount(CheckAllRecordQuery checkAllRecordQuery) {
return (Integer)this.getSqlSession().selectOne(this.getSqlId("getListCount"), checkAllRecordQuery);
}
@Override
public CheckAllScoreSummaryVo getScoreSummary(StaffCheckSummaryQuery query) {
return this.getSqlSession().selectOne(this.getSqlId("getScoreSummary"), query);
}
}
package com.mortals.xhx.module.check.model.vo;
import lombok.Data;
import java.math.BigDecimal;
/**
* 绩效分值统计
*/
@Data
public class CheckAllScoreSummaryVo {
/**初始扣分*/
private BigDecimal initScore;
/**核查扣分*/
private BigDecimal checkScore;
/**申诉分值*/
private BigDecimal appealScore;
/**累计扣分*/
private BigDecimal total;
}
......@@ -7,7 +7,8 @@ import lombok.Data;
*/
@Data
public class StaffCheckSummaryQuery {
/** 汇总方式 1按年,2按月,3按天*/
private Integer summaryType;
/**员工ID*/
private Long staffId;
/** 开始 核查时间 */
......
......@@ -4,6 +4,8 @@ import com.mortals.framework.model.PageInfo;
import com.mortals.framework.model.Result;
import com.mortals.xhx.module.check.model.CheckAllRecordQuery;
import com.mortals.xhx.module.check.model.vo.CheckAllRecordVo;
import com.mortals.xhx.module.check.model.vo.CheckAllScoreSummaryVo;
import com.mortals.xhx.module.check.model.vo.StaffCheckSummaryQuery;
import java.util.List;
......@@ -12,5 +14,18 @@ import java.util.List;
*/
public interface CheckAllRecordService {
/**
* 获取全部绩效核查信息列表
* @param query
* @param pageInfo
* @return
*/
Result<CheckAllRecordVo> getAllCheckRecord(CheckAllRecordQuery query, PageInfo pageInfo);
/**
* 绩效核查分数情况汇总
* @param query
* @return
*/
CheckAllScoreSummaryVo getScoreSummary(StaffCheckSummaryQuery query);
}
......@@ -2,11 +2,16 @@ package com.mortals.xhx.module.check.service.impl;
import com.mortals.framework.model.PageInfo;
import com.mortals.framework.model.Result;
import com.mortals.framework.util.DateUtils;
import com.mortals.framework.util.StringUtils;
import com.mortals.xhx.common.code.SummaryTopTypeEnum;
import com.mortals.xhx.module.check.dao.CheckAllRecordDao;
import com.mortals.xhx.module.check.model.CheckAllRecordQuery;
import com.mortals.xhx.module.check.model.vo.CheckAllRecordVo;
import com.mortals.xhx.module.check.model.vo.CheckAllScoreSummaryVo;
import com.mortals.xhx.module.check.model.vo.StaffCheckSummaryQuery;
import com.mortals.xhx.module.check.service.CheckAllRecordService;
import com.mortals.xhx.module.dept.model.vo.DeptSummaryTopQuery;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
......@@ -36,4 +41,9 @@ public class CheckAllRecordServiceImpl implements CheckAllRecordService {
}
return checkAllRecordDao.getAllCheckRecord(query,pageInfo);
}
@Override
public CheckAllScoreSummaryVo getScoreSummary(StaffCheckSummaryQuery query) {
return checkAllRecordDao.getScoreSummary(query);
}
}
package com.mortals.xhx.module.check.web;
import com.alibaba.fastjson.JSONObject;
import com.mortals.framework.annotation.UnAuth;
import com.mortals.framework.common.Rest;
import com.mortals.framework.model.Context;
import com.mortals.framework.model.PageInfo;
import com.mortals.framework.model.Result;
import com.mortals.framework.util.DataUtil;
import com.mortals.framework.util.DateUtils;
import com.mortals.framework.web.BaseJsonBodyController;
import com.mortals.xhx.common.code.CheckStatusEnum;
import com.mortals.xhx.common.code.CheckTypeEnum;
import com.mortals.xhx.common.code.SubAddTypeEnum;
import com.mortals.xhx.common.code.SubMethodEnum;
import com.mortals.xhx.common.code.*;
import com.mortals.xhx.module.check.model.CheckAllRecordQuery;
import com.mortals.xhx.module.check.model.vo.CheckAllRecordVo;
import com.mortals.xhx.module.check.model.vo.CheckAllScoreSummaryVo;
import com.mortals.xhx.module.check.model.vo.StaffCheckSummaryQuery;
import com.mortals.xhx.module.check.service.CheckAllRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.ObjectUtils;
......@@ -20,6 +22,12 @@ import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.math.BigDecimal;
import java.text.NumberFormat;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.time.temporal.TemporalAdjusters;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
......@@ -72,4 +80,131 @@ public class CheckAllRecordController extends BaseJsonBodyController {
ret.setMsg(model.get("message_info") == null ? "" : model.remove("message_info").toString());
return ret;
}
/**
* 绩效核查分数情况汇总
* @param query
* @return
*/
@PostMapping({"score/summary"})
@UnAuth
public Rest<Object> getScoreSummary(@RequestBody StaffCheckSummaryQuery query) {
Rest<Object> ret = new Rest();
Map<String, Object> model = new HashMap();
Context context = this.getContext();
String busiDesc = "查询绩效核查分数情况汇总";
int code=1;
try {
StaffCheckSummaryQuery lastQuery = new StaffCheckSummaryQuery();
Date now = new Date();
LocalDate localDate = LocalDate.now();
if (query.getSummaryType() == SummaryTopTypeEnum..getValue()) {
query.setCheckTimeStart(DateUtils.getCurrDateTime("yyyy")+"-01-01");
query.setCheckTimeEnd(DateUtils.getCurrDateTime("yyyy")+"-12-31");
lastQuery.setCheckTimeStart((localDate.getYear()-1)+"-01-01");
lastQuery.setCheckTimeEnd((localDate.getYear()-1)+"-12-31");
}
if (query.getSummaryType() == SummaryTopTypeEnum..getValue()) {
query.setCheckTimeStart(DateUtils.getCurrDateTime("yyyy-MM")+"-01");
query.setCheckTimeEnd(DateUtils.getDateTime(DateUtils.getMonthLastDate(now,"yyyy-MM-dd"),"yyyy-MM-dd"));
lastQuery.setCheckTimeStart(DateUtils.getDateTime(DateUtils.getLastMonthFirstDate(now,"yyyy-MM-dd"),"yyyy-MM-dd"));
lastQuery.setCheckTimeEnd(DateUtils.getDateTime(DateUtils.getLastMonthLastDate(now,"yyyy-MM-dd"),"yyyy-MM-dd"));
}
if (query.getSummaryType() == SummaryTopTypeEnum..getValue()) {
query.setCheckTimeStart(DateUtils.getCurrStrDate());
query.setCheckTimeEnd(DateUtils.getCurrStrDate());
lastQuery.setCheckTimeStart(DateUtils.getDateTime(DateUtils.addDate(now,-1),"yyyy-MM-dd"));
lastQuery.setCheckTimeEnd(DateUtils.getDateTime(DateUtils.addDate(now,-1),"yyyy-MM-dd"));
}
model.put("initScore",0);
model.put("checkScore",0);
model.put("checkPercent","0%");
model.put("appealPercent","0%");
model.put("appealScore",0);
model.put("total",0);
model.put("huanbi","暂无环比");
model.put("tongbi","暂无同比");
CheckAllScoreSummaryVo current = checkAllRecordService.getScoreSummary(query);
NumberFormat numberFormat = NumberFormat.getPercentInstance();
numberFormat.setMaximumFractionDigits(2);
if(current!=null){
model.put("initScore",current.getInitScore());
model.put("checkScore",current.getCheckScore());
model.put("appealScore",current.getAppealScore());
model.put("total",current.getTotal());
BigDecimal checkPercent = current.getCheckScore().divide(current.getInitScore(),6,BigDecimal.ROUND_HALF_UP);
model.put("checkPercent",numberFormat.format(checkPercent));
BigDecimal appealPercent = current.getAppealScore().divide(current.getInitScore(),6,BigDecimal.ROUND_HALF_UP);
model.put("appealPercent",numberFormat.format(appealPercent));
}
CheckAllScoreSummaryVo last = checkAllRecordService.getScoreSummary(lastQuery);
if(last!=null){
BigDecimal huanbi = current.getTotal().subtract(last.getTotal());
huanbi = huanbi.divide(last.getTotal(),6,BigDecimal.ROUND_HALF_UP);
model.put("huanbi",numberFormat.format(huanbi));
//TODO 没有2022年的数据暂时不做同比增长
}
if (query.getSummaryType() == SummaryTopTypeEnum..getValue()) {
if(last!=null){
model.put("tongbi",model.get("huanbi"));
}
}else {
String yyyy = query.getCheckTimeStart().substring(0,4);
int lastyear = DataUtil.converStr2Int(yyyy,0);
lastyear--;
if(query.getCheckTimeStart().substring(4).equals("-02-29")){
lastQuery.setCheckTimeStart(lastyear+"-02-28");
}else {
lastQuery.setCheckTimeStart(lastyear+query.getCheckTimeStart().substring(4));
}
if(query.getCheckTimeEnd().substring(4).equals("-02-29")){
lastQuery.setCheckTimeEnd(lastyear+"-02-28");
}else {
lastQuery.setCheckTimeEnd(lastyear+query.getCheckTimeEnd().substring(4));
}
CheckAllScoreSummaryVo tb = checkAllRecordService.getScoreSummary(lastQuery);
if(tb!=null){
BigDecimal tongbi = current.getTotal().subtract(tb.getTotal());
tongbi = tongbi.divide(last.getTotal(),6,BigDecimal.ROUND_HALF_UP);
model.put("tongbi",numberFormat.format(tongbi));
}
}
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);
}
ret.setCode(code);
ret.setData(model);
ret.setDict(model.get("dict"));
ret.setMsg(model.get("message_info") == null ? "" : model.remove("message_info").toString());
return ret;
}
public static void main(String[] args){
StaffCheckSummaryQuery query = new StaffCheckSummaryQuery();
query.setCheckTimeStart("2023-02-01");
query.setCheckTimeEnd("2023-02-29");
StaffCheckSummaryQuery lastQuery = new StaffCheckSummaryQuery();
String yyyy = query.getCheckTimeStart().substring(0,4);
String mmdd = query.getCheckTimeStart().substring(4);
int lastyear = DataUtil.converStr2Int(yyyy,0);
lastyear--;
if(query.getCheckTimeStart().substring(4).equals("-02-29")){
lastQuery.setCheckTimeStart(lastyear+"-02-28");
}else {
lastQuery.setCheckTimeStart(lastyear+query.getCheckTimeStart().substring(4));
}
if(query.getCheckTimeEnd().substring(4).equals("-02-29")){
lastQuery.setCheckTimeEnd(lastyear+"-02-28");
}else {
lastQuery.setCheckTimeEnd(lastyear+query.getCheckTimeEnd().substring(4));
}
System.out.println(JSONObject.toJSON(lastQuery).toString());
}
}
......@@ -118,4 +118,55 @@
<if test="createUserId != null and createUserId!=''"> AND createUserId = #{createUserId} </if>
) AS a
</select>
<select id="getScoreSummary" parameterType="com.mortals.xhx.module.check.model.vo.StaffCheckSummaryQuery" resultType="com.mortals.xhx.module.check.model.vo.CheckAllScoreSummaryVo">
SELECT sum(0-a.initScore) AS initScore,sum(0-a.checkScore) AS checkScore,sum(a.appealScore) AS appealScore,sum(0-a.checkScore-a.appealScore) AS total FROM (
SELECT sum(CASE subMethod WHEN 4 THEN 0 ELSE (CASE subAddType WHEN 1 THEN score ELSE score*-1 END) END) as initScore,
sum(CASE checkStatus WHEN 2 THEN (CASE subMethod WHEN 4 THEN 0 ELSE (CASE subAddType WHEN 1 THEN score ELSE score*-1 END) END) ELSE 0 END) checkScore,
sum(CASE checkStatus WHEN 2 THEN (CASE subMethod WHEN 4 THEN (CASE subAddType WHEN 1 THEN score ELSE score*-1 END) ELSE 0 END) ELSE 0 END) appealScore
FROM mortals_xhx_check_attend_record WHERE 1=1
<if test="checkTimeStart != null and checkTimeStart!=''"> AND checkTime <![CDATA[ >= ]]> STR_TO_DATE(left(concat(#{checkTimeStart},' 00:00:00'),19),'%Y-%m-%d %k:%i:%s') </if>
<if test="checkTimeEnd != null and checkTimeEnd!=''"> AND checkTime <![CDATA[ <= ]]> STR_TO_DATE(left(concat(#{checkTimeEnd},' 23:59:59'),19),'%Y-%m-%d %k:%i:%s') </if>
UNION
SELECT sum(CASE subMethod WHEN 4 THEN 0 ELSE (CASE subAddType WHEN 1 THEN score ELSE score*-1 END) END) as initScore,
sum(CASE checkStatus WHEN 2 THEN (CASE subMethod WHEN 4 THEN 0 ELSE (CASE subAddType WHEN 1 THEN score ELSE score*-1 END) END) ELSE 0 END) checkScore,
sum(CASE checkStatus WHEN 2 THEN (CASE subMethod WHEN 4 THEN (CASE subAddType WHEN 1 THEN score ELSE score*-1 END) ELSE 0 END) ELSE 0 END) appealScore
FROM mortals_xhx_check_effect_record WHERE 1=1
<if test="checkTimeStart != null and checkTimeStart!=''"> AND checkTime <![CDATA[ >= ]]> STR_TO_DATE(left(concat(#{checkTimeStart},' 00:00:00'),19),'%Y-%m-%d %k:%i:%s') </if>
<if test="checkTimeEnd != null and checkTimeEnd!=''"> AND checkTime <![CDATA[ <= ]]> STR_TO_DATE(left(concat(#{checkTimeEnd},' 23:59:59'),19),'%Y-%m-%d %k:%i:%s') </if>
UNION
SELECT sum(CASE subMethod WHEN 4 THEN 0 ELSE (CASE subAddType WHEN 1 THEN score ELSE score*-1 END) END) as initScore,
sum(CASE checkStatus WHEN 2 THEN (CASE subMethod WHEN 4 THEN 0 ELSE (CASE subAddType WHEN 1 THEN score ELSE score*-1 END) END) ELSE 0 END) checkScore,
sum(CASE checkStatus WHEN 2 THEN (CASE subMethod WHEN 4 THEN (CASE subAddType WHEN 1 THEN score ELSE score*-1 END) ELSE 0 END) ELSE 0 END) appealScore
FROM mortals_xhx_check_complain_record WHERE 1=1
<if test="checkTimeStart != null and checkTimeStart!=''"> AND checkTime <![CDATA[ >= ]]> STR_TO_DATE(left(concat(#{checkTimeStart},' 00:00:00'),19),'%Y-%m-%d %k:%i:%s') </if>
<if test="checkTimeEnd != null and checkTimeEnd!=''"> AND checkTime <![CDATA[ <= ]]> STR_TO_DATE(left(concat(#{checkTimeEnd},' 23:59:59'),19),'%Y-%m-%d %k:%i:%s') </if>
UNION
SELECT sum(CASE subMethod WHEN 4 THEN 0 ELSE (CASE subAddType WHEN 1 THEN score ELSE score*-1 END) END) as initScore,
sum(CASE checkStatus WHEN 2 THEN (CASE subMethod WHEN 4 THEN 0 ELSE (CASE subAddType WHEN 1 THEN score ELSE score*-1 END) END) ELSE 0 END) checkScore,
sum(CASE checkStatus WHEN 2 THEN (CASE subMethod WHEN 4 THEN (CASE subAddType WHEN 1 THEN score ELSE score*-1 END) ELSE 0 END) ELSE 0 END) appealScore
FROM mortals_xhx_check_gowork_record WHERE 1=1
<if test="checkTimeStart != null and checkTimeStart!=''"> AND checkTime <![CDATA[ >= ]]> STR_TO_DATE(left(concat(#{checkTimeStart},' 00:00:00'),19),'%Y-%m-%d %k:%i:%s') </if>
<if test="checkTimeEnd != null and checkTimeEnd!=''"> AND checkTime <![CDATA[ <= ]]> STR_TO_DATE(left(concat(#{checkTimeEnd},' 23:59:59'),19),'%Y-%m-%d %k:%i:%s') </if>
UNION
SELECT sum(CASE subMethod WHEN 4 THEN 0 ELSE (CASE subAddType WHEN 1 THEN score ELSE score*-1 END) END) as initScore,
sum(CASE checkStatus WHEN 2 THEN (CASE subMethod WHEN 4 THEN 0 ELSE (CASE subAddType WHEN 1 THEN score ELSE score*-1 END) END) ELSE 0 END) checkScore,
sum(CASE checkStatus WHEN 2 THEN (CASE subMethod WHEN 4 THEN (CASE subAddType WHEN 1 THEN score ELSE score*-1 END) ELSE 0 END) ELSE 0 END) appealScore
FROM mortals_xhx_check_review_record WHERE 1=1
<if test="checkTimeStart != null and checkTimeStart!=''"> AND checkTime <![CDATA[ >= ]]> STR_TO_DATE(left(concat(#{checkTimeStart},' 00:00:00'),19),'%Y-%m-%d %k:%i:%s') </if>
<if test="checkTimeEnd != null and checkTimeEnd!=''"> AND checkTime <![CDATA[ <= ]]> STR_TO_DATE(left(concat(#{checkTimeEnd},' 23:59:59'),19),'%Y-%m-%d %k:%i:%s') </if>
UNION
SELECT sum(CASE subMethod WHEN 4 THEN 0 ELSE (CASE subAddType WHEN 1 THEN score ELSE score*-1 END) END) as initScore,
sum(CASE checkStatus WHEN 2 THEN (CASE subMethod WHEN 4 THEN 0 ELSE (CASE subAddType WHEN 1 THEN score ELSE score*-1 END) END) ELSE 0 END) checkScore,
sum(CASE checkStatus WHEN 2 THEN (CASE subMethod WHEN 4 THEN (CASE subAddType WHEN 1 THEN score ELSE score*-1 END) ELSE 0 END) ELSE 0 END) appealScore
FROM mortals_xhx_check_other_record WHERE 1=1
<if test="checkTimeStart != null and checkTimeStart!=''"> AND checkTime <![CDATA[ >= ]]> STR_TO_DATE(left(concat(#{checkTimeStart},' 00:00:00'),19),'%Y-%m-%d %k:%i:%s') </if>
<if test="checkTimeEnd != null and checkTimeEnd!=''"> AND checkTime <![CDATA[ <= ]]> STR_TO_DATE(left(concat(#{checkTimeEnd},' 23:59:59'),19),'%Y-%m-%d %k:%i:%s') </if>
) AS a
</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