Commit 1811333e by hzc

修改驳回消息详情

parent 8567f23c
......@@ -143,8 +143,8 @@ public class BeforeCompareUnitCalActor extends AbstractActor{
indicatorsReportService.dealBaseIndReportOneData(currentDate, compareObjs, code);
}
//整合考核指标报表数据3
logger.info("进行date:"+currentDate+" 指标报表3数据整合");
//整合考核指标报表数据3,和报表四
logger.info("进行date:"+currentDate+" 指标报表3,4数据整合");
//删除历史数据
indicatorsReportService.deleteReportThreeDataByParam(path,currentDate,
new ArrayList<String>(compareObjMap.keySet()),code);
......
package com.keymobile.indicators.model.entity.report;
import javax.persistence.*;
import java.io.Serializable;
import lombok.Data;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
/**
* @Description
* @Author hzc
* @Date 2020-12-18
*/
@Data
@Table ( name ="indicators_report_four" )
public class IndicatorsReportFour implements Serializable {
private static final long serialVersionUID = 3424539524437039425L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id" )
private Integer id;
/**
* 结果表id
*/
@Column(name = "result_id" )
private Integer resultId;
/**
* 对标单元id
*/
@Column(name = "compare_id" )
private Integer compareId;
/**
* 指标id
*/
@Column(name = "ind_id" )
private String indId;
/**
* 指标名称
*/
@Column(name = "ind_name" )
private String indName;
/**
* 对标对象id
*/
@Column(name = "compare_obj" )
private String compareObj;
/**
* 对标对象描述
*/
@Column(name = "compare_obj_desc" )
private String compareObjDesc;
/**
* 指标正负属性:正向指标0 反向指标1
*/
@Column(name = "indRule" )
private String indRule;
/**
* 对标维度
*/
@Column(name = "compare_date" )
private Integer compareDate;
/**
* 指标值
*/
@Column(name = "value" )
private String value;
/**
* 平均值
*/
@Column(name = "average" )
private String average;
/**
* 机构编码
*/
@Column(name = "code" )
private String code;
/**
* 同比趋势 0:趋好 1:趋坏
*/
@Column(name = "trend" )
private Integer trend;
/**
* 排名标识,1,2,3前三
*/
@Column(name = "rank_mark_before" )
private Integer rankMarkBefore;
/**
* 排名标识,1,2,3末三
*/
@Column(name = "rank_mark_after" )
private Integer rankMarkAfter;
/**
* 对比平均数1大于,2等于,3小于
*/
@Column(name = "compare_avg" )
private Integer compareAvg;
/**
* 对标目录
*/
@Column(name = "compare_catalog" )
private String compareCatalog;
}
package com.keymobile.indicators.model.mapper.report;
import com.keymobile.indicators.model.entity.report.IndicatorsReportFour;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import tk.mybatis.mapper.common.BaseMapper;
import java.util.List;
/**
* TODO
*
* @author hzc
* @version 1.0
* @date 2020/12/18
*/
@Mapper
public interface IndicatorsReportFourMapper extends BaseMapper<IndicatorsReportFour> {
void batchInsert(@Param("indicatorsReportFours") List<IndicatorsReportFour> indicatorsReportFours);
void deleteByCompareCatalog(String compareCatalog);
}
......@@ -7,6 +7,8 @@ import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import com.keymobile.indicators.model.entity.report.IndicatorsReportFour;
import com.keymobile.indicators.model.mapper.report.IndicatorsReportFourMapper;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
......@@ -50,6 +52,9 @@ public class IndicatorsReportService {
private BaseIndDefMapper baseIndDefMapper;
@Autowired
private BaseIndDataService baseIndDataService;
@Autowired
private IndicatorsReportFourMapper indicatorsReportFourMapper;
//保存指标本期同期结果
public Integer saveOrUpdateReportTwo(IndicatorsReportTwo reportTwoData) {
......@@ -136,6 +141,9 @@ public class IndicatorsReportService {
paramMap.put("compareObjs", compareObjs);
log.info("开始清除报表三数据:date={},type={},code={},compareObjs={}",date,type,code,compareObjs);
reportThreeMapper.deleteByParam(paramMap);
log.info("开始清除报表四数据:compareCatalog={}",compareCatalog);
indicatorsReportFourMapper.deleteByCompareCatalog(compareCatalog);
}else{
log.info("指标层级为空或对标主体为空-不清除报表三数据");
}
......@@ -145,6 +153,14 @@ public class IndicatorsReportService {
public void dealDriveIndReportThreeData(String compareCatalog,String compareId,List<String> indIds,
Integer date,String code) throws Exception{
String type = this.getCompareType(date);
/**
* key:rankMarkAfterMap 末三 ,rankMarkBeforeMap 前三 ,单位id获取排名
* @Date 2020/12/18 10:48
* @Author hzc
**/
Map<String,Map<String,Integer>> rankMarkMap = new HashMap<>();
//报表四数据
List<IndicatorsReportFour> indicatorsReportFours = new ArrayList<>();
for(String indId : indIds) {
List<IndicatorsReportThree> dataList = new ArrayList<>();
Map<String,String> improveValue = new HashMap<>();//定义存储地区指标增幅,用于排名使用
......@@ -162,6 +178,14 @@ public class IndicatorsReportService {
List<DriveIndCalResultDef> calResults = driveIndCalResultDefMapper.
findByIndIdAndDateAndCompareIdAndSort(indId, date, compareId,code);
if(!calResults.isEmpty()) {
if(StringUtils.isNotBlank(indRule)){
/**
* key:rankMarkAfterMap 末三 ,rankMarkBeforeMap 前三 ,单位id获取排名
**/
rankMarkMap= this.fillRankMarkMap(calResults, indRule);
}
for(DriveIndCalResultDef calResult : calResults) {
//判断是否存在
IndicatorsReportThree indReportData = reportThreeMapper.getByParam(
......@@ -176,9 +200,39 @@ public class IndicatorsReportService {
//设置对标单元目录
indReportData.setCompareCatalog(compareCatalog);
indReportData.setCode(code);
//填充报表四数据
IndicatorsReportFour indicatorsReportFour = new IndicatorsReportFour();
indicatorsReportFour.setResultId(calResult.getId());
indicatorsReportFour.setCompareObj(calResult.getCompareObj());
indicatorsReportFour.setCompareObjDesc(calResult.getCompareObjDesc());
indicatorsReportFour.setCompareDate(date);
indicatorsReportFour.setIndId(driveIndDef.getIndId());
indicatorsReportFour.setIndName(driveIndDef.getIndName());
indicatorsReportFour.setIndRule(indRule);
//设置对标单元目录
indicatorsReportFour.setCompareCatalog(compareCatalog);
indicatorsReportFour.setCode(code);
if(StringUtils.isNotBlank(indRule) && StringUtils.isNotBlank(growCalType)) {
//填充优劣平均数指标个数
indReportData = this.fillAverageCount(indReportData, calResult, indRule);
Map<String, Object> map = this.fillAverageCount(indReportData, calResult, indRule);
//报表四数据============start
String average= (String) map.get("average");
Integer compareAvg= (Integer) map.get("compareAvg");
//key:rankMarkAfterMap 末三 ,rankMarkBeforeMap 前三 ,单位id获取排名
Map<String, Integer> rankMarkAfterMap = rankMarkMap.get("rankMarkAfterMap");
Map<String, Integer> rankMarkBeforeMap = rankMarkMap.get("rankMarkBeforeMap");
indicatorsReportFour.setAverage(average);
//对比平均数
indicatorsReportFour.setCompareAvg(compareAvg);
//末三
indicatorsReportFour.setRankMarkAfter(rankMarkAfterMap.get(calResult.getCompareId()));
//前三
indicatorsReportFour.setRankMarkBefore(rankMarkBeforeMap.get(calResult.getCompareObj()));
//报表四数据===============end
//填充排名前三末三指标个数
indReportData = this.fillRankHeadAndAfterCount(indReportData,calResults, indRule);
......@@ -209,6 +263,8 @@ public class IndicatorsReportService {
if(Double.parseDouble(calResult.getValue())-
Double.parseDouble(sameCalResult.getValue()) > 0) {
if("0".equals(indRule)) {//正向
//报表四记录同比趋向
indicatorsReportFour.setTrend(1);
//填充指标提升个数
if(indReportData.getIndImproveCount()==null) {
indReportData.setIndImproveCount(1);
......@@ -217,6 +273,8 @@ public class IndicatorsReportService {
indReportData.getIndImproveCount()+1);
}
}else {//反向
//报表四记录同比趋向
indicatorsReportFour.setTrend(0);
//填充指标降低个数
if(indReportData.getIndReduceCount()==null) {
indReportData.setIndReduceCount(1);
......@@ -229,6 +287,8 @@ public class IndicatorsReportService {
if(Double.parseDouble(calResult.getValue())-
Double.parseDouble(sameCalResult.getValue()) < 0) {
if("1".equals(indRule)) {//反向
//报表四记录同比趋向
indicatorsReportFour.setTrend(1);
//填充指标提升个数
if(indReportData.getIndImproveCount()==null) {
indReportData.setIndImproveCount(1);
......@@ -237,6 +297,8 @@ public class IndicatorsReportService {
indReportData.getIndImproveCount()+1);
}
}else {//正向
//报表四记录同比趋向
indicatorsReportFour.setTrend(0);
//填充指标降低个数
if(indReportData.getIndReduceCount()==null) {
indReportData.setIndReduceCount(1);
......@@ -253,6 +315,7 @@ public class IndicatorsReportService {
}
//加入list中
dataList.add(indReportData);
indicatorsReportFours.add(indicatorsReportFour);
}
this.batchSaveOrUpdateReportThree(dataList);
}
......@@ -276,8 +339,56 @@ public class IndicatorsReportService {
this.batchSaveOrUpdateReportThree(dataList);
}
}
//保存报表四数据
if(indicatorsReportFours.size()>0){
log.info("保存报表四数据,条数:{}",indicatorsReportFours.size());
indicatorsReportFourMapper.batchInsert(indicatorsReportFours);
}
}
/**
* @Description rankMarkAfterMap 末三 ,rankMarkBeforeMap 前三
* @Param [calResults, indRule]
* @Date 2020/12/18 10:50
* @Author hzc
**/
private Map<String,Map<String,Integer>> fillRankMarkMap(List<DriveIndCalResultDef> calResults, String indRule) {
Map<String,Integer> rankMarkBeforeMap = new HashMap<>();
Map<String,Integer> rankMarkAfterMap = new HashMap<>();
Map<String,Map<String,Integer>> returnValue = new HashMap<>();
Map<String,String> valueMap = new HashMap<>();
//前三
for(DriveIndCalResultDef calResult : calResults) {
if(calResult.getRank()!=null) {
valueMap.put(calResult.getCompareObj(), calResult.getValue());
if(calResult.getRank()==1||calResult.getRank()==2||calResult.getRank()==3) {
rankMarkBeforeMap.put(calResult.getCompareObj(),calResult.getRank());
}
}
}
if(!valueMap.isEmpty()) {
//末三
Map<String,Integer> rankValue = new HashMap<>();
if("0".equals(indRule)) {//正向
rankValue = CalculateUtils.rankValue(valueMap, "1");
}else {//反向
rankValue = CalculateUtils.rankValue(valueMap, "0");
}
if(!rankValue.isEmpty()) {
for(Map.Entry<String, Integer> map : rankValue.entrySet()) {
if(map.getValue()==1||map.getValue()==2||map.getValue()==3) {
rankMarkAfterMap.put(map.getKey(),map.getValue());
}
}
}
}
returnValue.put("rankMarkAfterMap",rankMarkAfterMap);
returnValue.put("rankMarkBeforeMap",rankMarkBeforeMap);
return returnValue;
}
//type:0 前三 1末三
private List<IndicatorsReportThree> fillImproveHeadAndAfterCount(String compareCatalog,
Map<String,Integer> resultRank,List<IndicatorsReportThree> dataList,Integer type,String code){
......@@ -424,7 +535,7 @@ public class IndicatorsReportService {
}
//填充优劣平均数个数
private IndicatorsReportThree fillAverageCount(IndicatorsReportThree indReportData,
private Map<String,Object> fillAverageCount(IndicatorsReportThree indReportData,
DriveIndCalResultDef calResult,String indRule) {
String average = null;
//优于平均水平的指标个数
......@@ -434,11 +545,18 @@ public class IndicatorsReportService {
}else {
average = calResult.getAverage();
}
/**
* compareAvg对比平均数1大于,2等于,3小于
* @Date 2020/12/18 10:36
* @Author hzc
**/
Integer compareAvg=2;
if(StringUtils.isNotBlank(average)
&& StringUtils.isNotBlank(calResult.getValue())) {
//指标值大于平均数
if(Double.parseDouble(calResult.getValue()) > Double.parseDouble(average)) {
if("1".equals(indRule)) {//反向
compareAvg=3;
if(indReportData.getBadAverageIndCount()==null) {
indReportData.setBadAverageIndCount(1);
}else {
......@@ -446,6 +564,7 @@ public class IndicatorsReportService {
indReportData.getBadAverageIndCount()+1);
}
}else {//正向
compareAvg=1;
if(indReportData.getBatterAverageIndCount()==null) {
indReportData.setBatterAverageIndCount(1);
}else {
......@@ -456,6 +575,7 @@ public class IndicatorsReportService {
}
if(Double.parseDouble(calResult.getValue()) < Double.parseDouble(average)){//指标值小于平均数
if("1".equals(indRule)) {//反向
compareAvg=1;
if(indReportData.getBatterAverageIndCount()==null) {
indReportData.setBatterAverageIndCount(1);
}else {
......@@ -463,6 +583,7 @@ public class IndicatorsReportService {
indReportData.getBatterAverageIndCount()+1);
}
}else {//正向
compareAvg=2;
if(indReportData.getBadAverageIndCount()==null) {
indReportData.setBadAverageIndCount(1);
}else {
......@@ -472,7 +593,10 @@ public class IndicatorsReportService {
}
}
}
return indReportData;
Map<String,Object> returnMap = new HashMap<>();
returnMap.put("compareAvg",compareAvg);
returnMap.put("average",average);
return returnMap;
}
@Async
......@@ -492,8 +616,6 @@ public class IndicatorsReportService {
.findByIndIdAndDateAndCompareObjIn(paramMap);
if(!calDatas.isEmpty()) {
//判断是否存在
log.info("查报表二数据参数:indId={},date={}, type={}, code={}, compareCatalog={}",indId,
date, type, code, compareCatalog);
IndicatorsReportTwo indReportData = reportTwoMapper.getDataByParam(indId,
date, type, code, compareCatalog,compareUnitId);
if(indReportData==null) {
......
<?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.keymobile.indicators.model.mapper.report.IndicatorsReportFourMapper">
<insert id="batchInsert" parameterType="java.util.List">
insert into indicators_report_four(
result_id,compare_id,ind_id,ind_name,compare_obj,compare_obj_desc,ind_rule,compare_date,`value`,average,code,
trend,rank_mark_before,rank_mark_after,compare_avg,compare_catalog)
values
<foreach collection="indicatorsReportFours" item="val" separator=",">
(
#{val.resultId},#{val.compareId},#{val.indId},#{val.indName},#{val.compareObj},#{val.compareObjDesc},#{val.indRule},
#{val.compareDate},#{val.value},#{val.average},#{val.code},#{val.trend},#{val.rankMarkBefore},#{val.rankMarkAfter},
#{val.compareAvg},#{val.compareCatalog}
)
</foreach>
</insert>
<delete id="deleteByCompareCatalog">
delete from indicators_report_four where compare_catalog=#{compareCatalog}
</delete>
</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