Commit 2948b419 by zhangkb

添加指标报表运算逻辑到对标单元计算中

parent ebec0a80
...@@ -65,6 +65,8 @@ public class DriveIndCalculateActor extends AbstractActor{ ...@@ -65,6 +65,8 @@ public class DriveIndCalculateActor extends AbstractActor{
private String indType;//正向,反向 private String indType;//正向,反向
private String code;//编码标识
private final ActorRef driveIndCalculateRegionActor;//定义schemaActor,用于返回给schemaActor确认信息 private final ActorRef driveIndCalculateRegionActor;//定义schemaActor,用于返回给schemaActor确认信息
static public Props props(ActorRef driveIndCalculateRegionActor) { static public Props props(ActorRef driveIndCalculateRegionActor) {
...@@ -90,6 +92,7 @@ public class DriveIndCalculateActor extends AbstractActor{ ...@@ -90,6 +92,7 @@ public class DriveIndCalculateActor extends AbstractActor{
unit = driveIndDef.getIndUnit();//指标单位 unit = driveIndDef.getIndUnit();//指标单位
indType = driveIndDef.getIndType();//指标类型:正向 反向 indType = driveIndDef.getIndType();//指标类型:正向 反向
markType = driveIndDef.getIndCalScoreRule();//指标评分规则 markType = driveIndDef.getIndCalScoreRule();//指标评分规则
code = driveIndDef.getCode();
//获取考核指标的公式 //获取考核指标的公式
driveIndFormula = driveIndDef.getIndFormat(); driveIndFormula = driveIndDef.getIndFormat();
...@@ -153,7 +156,8 @@ public class DriveIndCalculateActor extends AbstractActor{ ...@@ -153,7 +156,8 @@ public class DriveIndCalculateActor extends AbstractActor{
findCalResultDataIsExist(compareId, compareObj, driveIndId, date); findCalResultDataIsExist(compareId, compareObj, driveIndId, date);
if(driveIndCalResult==null) { if(driveIndCalResult==null) {
driveIndCalResult = new DriveIndCalResultDef(compareId, driveIndCalResult = new DriveIndCalResultDef(compareId,
driveIndId,compareObj,date,driveIndValue,unit,"1","1","admin"); driveIndId,compareObj,date,driveIndValue,unit,
"1","1","admin",code);
}else { }else {
driveIndCalResult.setValue(driveIndValue); driveIndCalResult.setValue(driveIndValue);
} }
...@@ -172,7 +176,8 @@ public class DriveIndCalculateActor extends AbstractActor{ ...@@ -172,7 +176,8 @@ public class DriveIndCalculateActor extends AbstractActor{
findCalResultDataIsExist(compareId, compareObj, driveIndId, date); findCalResultDataIsExist(compareId, compareObj, driveIndId, date);
if(driveIndCalResult==null) { if(driveIndCalResult==null) {
driveIndCalResult = new DriveIndCalResultDef(compareId, driveIndCalResult = new DriveIndCalResultDef(compareId,
driveIndId,compareObj,date,"NaN",unit,"1","0","admin"); driveIndId,compareObj,date,"NaN",unit,
"1","0","admin",code);
}else { }else {
driveIndCalResult.setValue("NaN"); driveIndCalResult.setValue("NaN");
} }
......
...@@ -19,6 +19,7 @@ import com.keymobile.indicators.model.entity.indicators.DriveIndCalResultDef; ...@@ -19,6 +19,7 @@ import com.keymobile.indicators.model.entity.indicators.DriveIndCalResultDef;
import com.keymobile.indicators.service.hytobacco.DriveIndCalResultService; import com.keymobile.indicators.service.hytobacco.DriveIndCalResultService;
import com.keymobile.indicators.service.hytobacco.DriveIndDefService; import com.keymobile.indicators.service.hytobacco.DriveIndDefService;
import com.keymobile.indicators.service.hytobacco.IndScorecardService; import com.keymobile.indicators.service.hytobacco.IndScorecardService;
import com.keymobile.indicators.service.report.IndicatorsReportService;
import com.keymobile.indicators.utils.CalculateUtils; import com.keymobile.indicators.utils.CalculateUtils;
import com.keymobile.indicators.utils.SpringUtil; import com.keymobile.indicators.utils.SpringUtil;
...@@ -35,6 +36,8 @@ public class DriveIndIdCalActor extends AbstractActor{ ...@@ -35,6 +36,8 @@ public class DriveIndIdCalActor extends AbstractActor{
private DriveIndDefService driveIndDefService = SpringUtil.getBean(DriveIndDefService.class); private DriveIndDefService driveIndDefService = SpringUtil.getBean(DriveIndDefService.class);
private IndicatorsReportService indiReportService = SpringUtil.getBean(IndicatorsReportService.class);
private int numberOfConfirm = 0;//定义返回确认消息的子actor private int numberOfConfirm = 0;//定义返回确认消息的子actor
private int compareObjSize = 0;//对标对象个数 private int compareObjSize = 0;//对标对象个数
...@@ -147,6 +150,8 @@ public class DriveIndIdCalActor extends AbstractActor{ ...@@ -147,6 +150,8 @@ public class DriveIndIdCalActor extends AbstractActor{
driveIndCalResult.setScore(scoreMap.get("score")); driveIndCalResult.setScore(scoreMap.get("score"));
driveIndCalResult.setImproveScore(scoreMap.get("improveScore")); driveIndCalResult.setImproveScore(scoreMap.get("improveScore"));
driveIndCalResultService.saveOrUpdate(driveIndCalResult); driveIndCalResultService.saveOrUpdate(driveIndCalResult);
//整合本期同期报表数据
indiReportService.dealSingleReportOneData(driveIndCalResult);
} }
} }
//发送确认信息给父actor //发送确认信息给父actor
......
...@@ -63,6 +63,8 @@ public class DriveIndIdObjCalActor extends AbstractActor{ ...@@ -63,6 +63,8 @@ public class DriveIndIdObjCalActor extends AbstractActor{
private int indIdSize = 0;//考核指标内包含的基础指标id的个数 private int indIdSize = 0;//考核指标内包含的基础指标id的个数
private String code;//编码标识
private Map<String, Object> env = Maps.newHashMap(); private Map<String, Object> env = Maps.newHashMap();
//定义线程安全的收集反馈确认消息list //定义线程安全的收集反馈确认消息list
...@@ -97,6 +99,7 @@ public class DriveIndIdObjCalActor extends AbstractActor{ ...@@ -97,6 +99,7 @@ public class DriveIndIdObjCalActor extends AbstractActor{
unit = driveIndDef.getIndUnit();//指标单位 unit = driveIndDef.getIndUnit();//指标单位
indType = driveIndDef.getIndType();//指标类型:正向 反向 indType = driveIndDef.getIndType();//指标类型:正向 反向
scoreCardId = driveIndDef.getIndCalScoreRule();//指标评分规则 scoreCardId = driveIndDef.getIndCalScoreRule();//指标评分规则
code = driveIndDef.getCode();
//获取考核指标的公式 //获取考核指标的公式
driveIndFormula = driveIndDef.getIndFormat(); driveIndFormula = driveIndDef.getIndFormat();
...@@ -183,8 +186,10 @@ public class DriveIndIdObjCalActor extends AbstractActor{ ...@@ -183,8 +186,10 @@ public class DriveIndIdObjCalActor extends AbstractActor{
findCalResultDataIsExist(compareId, compareObj, driveIndId, date); findCalResultDataIsExist(compareId, compareObj, driveIndId, date);
if(driveIndCalResult==null) { if(driveIndCalResult==null) {
driveIndCalResult = new DriveIndCalResultDef(compareId, driveIndCalResult = new DriveIndCalResultDef(compareId,
driveIndId,compareObj,date,driveIndValue,unit,"1","1","admin"); driveIndId,compareObj,date,driveIndValue,unit,
"1","1","admin",code);
}else { }else {
driveIndCalResult.setCode(code);
driveIndCalResult.setUnit(unit); driveIndCalResult.setUnit(unit);
driveIndCalResult.setValue(driveIndValue); driveIndCalResult.setValue(driveIndValue);
driveIndCalResult.setLastUpdateTime(DateUtils.formatDate(new Date(), "yyyy-MM-dd HH:mm:ss")); driveIndCalResult.setLastUpdateTime(DateUtils.formatDate(new Date(), "yyyy-MM-dd HH:mm:ss"));
...@@ -204,10 +209,13 @@ public class DriveIndIdObjCalActor extends AbstractActor{ ...@@ -204,10 +209,13 @@ public class DriveIndIdObjCalActor extends AbstractActor{
findCalResultDataIsExist(compareId, compareObj, driveIndId, date); findCalResultDataIsExist(compareId, compareObj, driveIndId, date);
if(driveIndCalResult==null) { if(driveIndCalResult==null) {
driveIndCalResult = new DriveIndCalResultDef(compareId, driveIndCalResult = new DriveIndCalResultDef(compareId,
driveIndId,compareObj,date,"NaN",unit,"1","0","admin"); driveIndId,compareObj,date,"NaN",unit,
"1","0","admin",code);
}else { }else {
driveIndCalResult.setCode(code);
driveIndCalResult.setUnit(unit); driveIndCalResult.setUnit(unit);
driveIndCalResult.setValue("NaN"); driveIndCalResult.setValue("NaN");
driveIndCalResult.setLastUpdateTime(DateUtils.formatDate(new Date(), "yyyy-MM-dd HH:mm:ss"));
} }
driveIndCalResultService.saveOrUpdate(driveIndCalResult); driveIndCalResultService.saveOrUpdate(driveIndCalResult);
......
package com.keymobile.indicators.api.report;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.keymobile.indicators.service.report.IndicatorsReportService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@Api(tags={"指标分析-指标分析接口"})
@RestController
@RequestMapping(value = "/indReport")
public class IndicatorReportCtrl {
@Autowired
private IndicatorsReportService indicatorsReportService;
@ApiOperation(value = "整合指标本期同期报表数据", notes = "整合指标本期同期报表数据")
@PostMapping(value = "/dealReportOne")
public String dealReportOne() {
return indicatorsReportService.dealReportOne();
}
}
...@@ -36,13 +36,14 @@ public class DriveIndCalResultDef { ...@@ -36,13 +36,14 @@ public class DriveIndCalResultDef {
private String score;//指标评分分数 private String score;//指标评分分数
private String improveScore;//改善提升得分 private String improveScore;//改善提升得分
private String actualAverage;//实际平均数:用于省对市的操作,如果有全省的基础项数据,直接拿全省的基础项数据算考核指标做为其实际平均值 private String actualAverage;//实际平均数:用于省对市的操作,如果有全省的基础项数据,直接拿全省的基础项数据算考核指标做为其实际平均值
private String code;//编码标识
public DriveIndCalResultDef() { public DriveIndCalResultDef() {
super(); super();
} }
public DriveIndCalResultDef(String compareId,String indId,String compareObj,int date,String value, public DriveIndCalResultDef(String compareId,String indId,String compareObj,int date,String value,
String unit,String type,String isRight,String lastUpdater) { String unit,String type,String isRight,String lastUpdater,String code) {
this.compareId = compareId; this.compareId = compareId;
this.indId = indId; this.indId = indId;
this.compareObj = compareObj; this.compareObj = compareObj;
...@@ -52,5 +53,6 @@ public class DriveIndCalResultDef { ...@@ -52,5 +53,6 @@ public class DriveIndCalResultDef {
this.type = type; this.type = type;
this.isRight = isRight; this.isRight = isRight;
this.lastUpdater = lastUpdater; this.lastUpdater = lastUpdater;
this.code = code;
} }
} }
package com.keymobile.indicators.model.entity.report;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import lombok.Data;
/**
*author:zhangkb time:2020-7-13 desc:对标报表1
*/
@Data
@Table(name ="indicators_report_one")
public class IndicatorsReportOne {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
private String indId;//指标编号
private String indName;//指标名称
private String compareObj;//对标对象编号
private String compareObjDesc;//对标对象描述
private Integer compareDate;//对标日期
private String compareType;//对标类型: 1:日 2:月 3:季 4:年
private String unit;//指标单位
private String currentValue;//本期值
private String lastSameValue;// 同期值
private String valueRate;//同比
private String currentRank;//本期排名
private String lastSameRank;//同期排名
private String currentScore;//本期综合评分
private String currentImprove;//本期改善提升评分
private String lastSameScore;//同期综合评分
private String lastSameImprove;//同期改善提升评分
private String code;//编码标识
}
...@@ -52,4 +52,6 @@ public interface DriveIndCalResultDefMapper extends BaseMapper<DriveIndCalResult ...@@ -52,4 +52,6 @@ public interface DriveIndCalResultDefMapper extends BaseMapper<DriveIndCalResult
public List<DriveIndCalResultDef> findByCompareIdAndDate(@Param("compareId")String compareId, public List<DriveIndCalResultDef> findByCompareIdAndDate(@Param("compareId")String compareId,
@Param("date")Integer date); @Param("date")Integer date);
public List<DriveIndCalResultDef> findReportData();
} }
package com.keymobile.indicators.model.mapper.report;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import com.keymobile.indicators.model.entity.report.IndicatorsReportOne;
import tk.mybatis.mapper.common.BaseMapper;
@Mapper
public interface ReportOneMapper extends BaseMapper<IndicatorsReportOne>{
public IndicatorsReportOne getByParam(@Param("indId")String indId,
@Param("compareObj")String compareObj,@Param("date")Integer date,
@Param("type")String type);
}
package com.keymobile.indicators.service.report;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.keymobile.indicators.model.entity.indicators.DriveIndCalResultDef;
import com.keymobile.indicators.model.entity.indicators.DriveIndDef;
import com.keymobile.indicators.model.entity.report.IndicatorsReportOne;
import com.keymobile.indicators.model.mapper.indicators.DriveIndDefMapper;
import com.keymobile.indicators.model.mapper.indmapper.DriveIndCalResultDefMapper;
import com.keymobile.indicators.model.mapper.report.ReportOneMapper;
import com.keymobile.indicators.utils.CalculateUtils;
@Service
public class IndicatorsReportService {
@Autowired
private ReportOneMapper reportOneMapper;
@Autowired
private DriveIndCalResultDefMapper driveIndCalResultDefMapper;
@Autowired
private DriveIndDefMapper driveIndDefMapper;
public Integer saveOrUpdate(IndicatorsReportOne reportData) {
if(reportData.getId()==null) {
reportOneMapper.insert(reportData);
}else {
reportOneMapper.updateByPrimaryKey(reportData);
}
return reportData.getId();
}
//处理单挑指标结果报表数据
public void dealSingleReportOneData(DriveIndCalResultDef calData) {
//判断是否存在
String type = this.getCompareType(calData.getDate());
IndicatorsReportOne indReportData = reportOneMapper.getByParam(
calData.getIndId(), calData.getCompareObj(), calData.getDate(), type);
if(indReportData==null) {
indReportData = new IndicatorsReportOne();
}
indReportData.setCode(calData.getCode());
indReportData.setCompareType(type);
indReportData.setUnit(calData.getUnit());
indReportData = this.fillReportOneData(calData, indReportData);
this.saveOrUpdate(indReportData);
}
//整合指标本期同期报表数据
public String dealReportOne() {
//获取所有考核指标结果
List<DriveIndCalResultDef> calDatas = driveIndCalResultDefMapper.findReportData();
for(DriveIndCalResultDef calData : calDatas) {
//判断是否存在
String type = this.getCompareType(calData.getDate());
IndicatorsReportOne indReportData = reportOneMapper.getByParam(
calData.getIndId(), calData.getCompareObj(), calData.getDate(), type);
if(indReportData==null) {
indReportData = new IndicatorsReportOne();
}
indReportData.setCode(calData.getCode());
indReportData.setCompareType(type);
indReportData.setUnit(calData.getUnit());
indReportData = this.fillReportOneData(calData, indReportData);
this.saveOrUpdate(indReportData);
}
return "deal indicators report one success";
}
public IndicatorsReportOne fillReportOneData(DriveIndCalResultDef calData,
IndicatorsReportOne indReportData) {
indReportData.setIndId(calData.getIndId());
//根据指标id获取指标信息
DriveIndDef driveIndDef = driveIndDefMapper.selectByPrimaryKey(calData.getIndId());
if(driveIndDef!=null) {
indReportData.setIndName(driveIndDef.getIndName());
}
indReportData.setCompareObj(calData.getCompareObj());//对标对象
indReportData.setCompareObjDesc(calData.getCompareObj());//对标对象描述
indReportData.setCompareDate(calData.getDate());
indReportData.setCurrentValue(calData.getValue());
indReportData.setCurrentRank(calData.getRank().toString());
indReportData.setCurrentScore(calData.getScore());
indReportData.setCurrentImprove(calData.getImproveScore());
//查找同期结果
DriveIndCalResultDef sameCalData = driveIndCalResultDefMapper.findByIndIdAndDateAndCompareObj(
calData.getIndId(), (calData.getDate()-100), calData.getCompareObj());
if(sameCalData!=null) {
indReportData.setLastSameValue(sameCalData.getValue());
indReportData.setLastSameRank(sameCalData.getRank().toString());
indReportData.setLastSameScore(sameCalData.getScore());
indReportData.setLastSameImprove(sameCalData.getImproveScore());
//算同比
String calGowth = CalculateUtils.calGowth(calData.getValue(), sameCalData.getValue(),
driveIndDef.getGrowCalType());
indReportData.setValueRate(calGowth);
}
return indReportData;
}
public String getCompareType(Integer date) {
if(date!=null) {
if(date.toString().length()>6) {
return "1";
}else {
if(date.toString().length()==6) {
Integer type = date%100;
if(type==3 || type==6 || type==9) {
return "3";
}else if(type==12) {
return "4";
}else {
return "2";
}
}
}
}
return null;
}
}
...@@ -137,4 +137,12 @@ ...@@ -137,4 +137,12 @@
compare_id = #{compareId} and compare_id = #{compareId} and
date = #{date} date = #{date}
</select> </select>
<select id="findReportData" resultType="com.keymobile.indicators.model.entity.indicators.DriveIndCalResultDef" >
select *
from drive_ind_cal_result_def
where
score is not null
order by date desc
</select>
</mapper> </mapper>
\ No newline at end of file
<?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.ReportOneMapper">
<select id="getByParam" resultType="com.keymobile.indicators.model.entity.report.IndicatorsReportOne" >
select *
from indicators_report_one
where
ind_id = #{indId} and
compare_obj = #{compareObj} and
compare_date = #{date} and
compare_type = #{type}
</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