Commit d94d480c by hzc

对标运算加try捕获未知异常

parent 82229af3
......@@ -10,6 +10,7 @@ import com.keymobile.indicators.constant.Constants;
import com.keymobile.indicators.model.entity.indicators.CompareUnitCalLog;
import com.keymobile.indicators.service.hytobacco.CompareUnitCalLogService;
import com.keymobile.indicators.utils.LogManager;
import com.netflix.discovery.converters.jackson.EurekaXmlJacksonCodec;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......@@ -51,6 +52,7 @@ public class BeforeCompareUnitCalActor extends AbstractActor{
@Override
public Receive createReceive() {
try {
return receiveBuilder()
.match(StartCompareUnitCalMsg.class,beforeCompareUnitCalMsg -> {
List<CompareUnitDef> compareUnitDefs = beforeCompareUnitCalMsg.getCompareInitDefs();
......@@ -88,7 +90,7 @@ public class BeforeCompareUnitCalActor extends AbstractActor{
}
if(!currentCompareUnitDef.isEmpty()) {
currentDate = currentCompareUnitDef.get(0).getDate();
if("0".equals(isTest)) {
logger.info("进行date:"+currentDate+" 的对标单元试运行计算.....");
}else {
......@@ -108,10 +110,10 @@ public class BeforeCompareUnitCalActor extends AbstractActor{
if("1".equals(isTest)) {//正式对标单元运算才进行报表数据生成
Map<String,String> compareObjMap = new HashMap<>();
logger.info("进行date:"+currentDate+" 指标本期同期报表数据和考核指标报表数据2数据整合");
//整合考核指标报表数据2
for(CompareUnitDef unitDef : currentCompareUnitDef) {
if(StringUtils.isNotBlank(unitDef.getIndIds()) &&
if(StringUtils.isNotBlank(unitDef.getIndIds()) &&
StringUtils.isNotBlank(unitDef.getCompareObjs())) {
//用map整合对标机构
List<String> compareObjsList =Arrays
......@@ -122,31 +124,31 @@ public class BeforeCompareUnitCalActor extends AbstractActor{
//整合指标本期同期报表数据
indicatorsReportService.dealReportOne(
unitDef.getCompareId(), Arrays.asList(unitDef.getIndIds().split(",")),
Arrays.asList(unitDef.getCompareObjs().split(",")),
Arrays.asList(unitDef.getCompareObjs().split(",")),
unitDef.getDate(), code);
//整合考核指标报表数据2
indicatorsReportService.dealDriveIndReportTwoData(
unitDef.getCompareId(), Arrays.asList(unitDef.getIndIds().split(",")),
Arrays.asList(unitDef.getCompareObjs().split(",")), unitDef.getDate(),code);
}
}
//整合基础项本期同期报表数据
logger.info("进行date:"+currentDate+" 基础项本期同期报表数据整合");
if(!compareObjMap.isEmpty()) {
List<String> compareObjs = new ArrayList<String>(compareObjMap.keySet());
indicatorsReportService.dealBaseIndReportOneData(currentDate, compareObjs, code);
}
//整合考核指标报表数据3
logger.info("进行date:"+currentDate+" 指标报表3数据整合");
//删除历史数据
indicatorsReportService.deleteReportThreeDataByParam(currentDate,
indicatorsReportService.deleteReportThreeDataByParam(currentDate,
new ArrayList<String>(compareObjMap.keySet()),code);
for(CompareUnitDef unitDef : currentCompareUnitDef) {
indicatorsReportService.dealDriveIndReportThreeData(
unitDef.getCompareId(), Arrays.asList(unitDef.getIndIds().split(",")),
unitDef.getCompareId(), Arrays.asList(unitDef.getIndIds().split(",")),
unitDef.getDate(),code);
}
}
......@@ -156,6 +158,12 @@ public class BeforeCompareUnitCalActor extends AbstractActor{
if(compCalLog!=null) {
compCalLog.setEndTime(System.currentTimeMillis()+"");
compCalLog.setRunStatus("1");
String logInfo = compCalLog.getLogInfo();
if(StringUtils.isBlank(logInfo)){
logInfo = "没异常";
}
logInfo = "整体试运算成功-运算过程:"+logInfo;
compCalLog.setLogInfo(logInfo);
compareUnitCalLogService.saveOrUndate(compCalLog);
}
LogManager.logInfo(Constants.LOG_INDICATOR_UNIT_CAL_API,"完成对标单元id:{},日期:{} 的试运行计算",compCalLogId,currentDate );
......@@ -164,18 +172,34 @@ public class BeforeCompareUnitCalActor extends AbstractActor{
if(compCalLog!=null) {
compCalLog.setEndTime(System.currentTimeMillis()+"");
compCalLog.setRunStatus("1");
if(compCalLog.getStatus()==1){
compCalLog.setLogInfo("运算成功");
String logInfo = compCalLog.getLogInfo();
if(StringUtils.isBlank(logInfo)){
logInfo = "没异常";
}
logInfo = "整体运算成功-运算过程:"+logInfo;
compCalLog.setLogInfo(logInfo);
compareUnitCalLogService.saveOrUndate(compCalLog);
}
LogManager.logInfo(Constants.LOG_INDICATOR_UNIT_CAL_API,"完成对标单元id:{},日期:{} 的运行计算",compCalLogId,currentDate );
LogManager.logInfo(Constants.LOG_INDICATOR_UNIT_CAL_API,"完成对标单元id:{},日期:{} 的正式运行计算",compCalLogId,currentDate );
logger.info("本期同期对标单元计算完成");
}
}
}
})
.build();
}catch (Exception e){
e.printStackTrace();
CompareUnitCalLog compCalLog = compareUnitCalLogService.findById(compCalLogId);
if(compCalLog!=null){
compCalLog.setEndTime(System.currentTimeMillis()+"");
compCalLog.setRunStatus("1");
compCalLog.setStatus(0);
compCalLog.setLogInfo("运算失败");
compareUnitCalLogService.saveOrUndate(compCalLog);
}
}
return null;
}
}
......@@ -65,6 +65,8 @@ public class CompareUnitCalActor extends AbstractActor{
@Override
public Receive createReceive() {
try {
return receiveBuilder()
.match(CompareUnitCalMsg.class,compareUnitCalMsg -> {
CompareUnitDef compareUnitDef = compareUnitCalMsg.getCompareUnitDef();
......@@ -75,7 +77,7 @@ public class CompareUnitCalActor extends AbstractActor{
objScoreRuleId = compareUnitDef.getObjScoreRuleId();
code = compareUnitCalMsg.getCode();
isTest = compareUnitCalMsg.getIsTest();
compCalLogId = compareUnitCalMsg.getCompCalLogId();
// //新增运行日志记录
// CompareUnitCalLog compCalLog = new CompareUnitCalLog(compareId,date,
// System.currentTimeMillis()+"","0");
......@@ -85,7 +87,7 @@ public class CompareUnitCalActor extends AbstractActor{
// compCalLog.setType(isTest);
//保存
// Integer compCalLogId = compareUnitCalLogService.saveOrUndate(compCalLog);
compCalLogId = compareUnitCalMsg.getCompCalLogId();
//获取对标对象
String compareObjsString = compareUnitDef.getCompareObjs();
//获取对标指标
......@@ -161,5 +163,18 @@ public class CompareUnitCalActor extends AbstractActor{
}
})
.build();
}catch (Exception e){
e.printStackTrace();
CompareUnitCalLog compCalLog = compareUnitCalLogService.findById(compCalLogId);
if(compCalLog!=null){
compCalLog.setEndTime(System.currentTimeMillis()+"");
compCalLog.setRunStatus("1");
compCalLog.setStatus(0);
compCalLog.setLogInfo("运算失败");
compareUnitCalLogService.saveOrUndate(compCalLog);
}
}
return null;
}
}
......@@ -4,6 +4,8 @@ import java.util.Map;
import com.keymobile.indicators.akka.message.indicators.BaseIndValueMsg;
import com.keymobile.indicators.akka.message.indicators.GetBaseIndValueMsg;
import com.keymobile.indicators.model.entity.indicators.CompareUnitCalLog;
import com.keymobile.indicators.service.hytobacco.CompareUnitCalLogService;
import com.keymobile.indicators.service.hytobacco.IndicatorsValueService;
import com.keymobile.indicators.utils.SpringUtil;
......@@ -13,37 +15,60 @@ public class GetBaseIndValueActor extends AbstractActor{
private IndicatorsValueService indicatorsValueService = SpringUtil.getBean(IndicatorsValueService.class);
private CompareUnitCalLogService compareUnitCalLogService = SpringUtil.getBean(CompareUnitCalLogService.class);
private Integer compCalLogId = null;
@Override
public Receive createReceive() {
return receiveBuilder()
.match(GetBaseIndValueMsg.class,getBaseIndValueMsg -> {
//根据维度值和基础指标id获取指标值
Map<String,Object> indValueMap = indicatorsValueService.getIndicatorsValue(
getBaseIndValueMsg.getIndId(), getBaseIndValueMsg.getDimValue(),
getBaseIndValueMsg.getCode());
if(indValueMap!=null) {
if(indValueMap.get("value")==null) {//如果指标值为空,返回失败结果
Receive receive = null;
try {
receive= receiveBuilder()
.match(GetBaseIndValueMsg.class, getBaseIndValueMsg -> {
//根据维度值和基础指标id获取指标值
compCalLogId = getBaseIndValueMsg.getCompCalLogId();
Map<String, Object> indValueMap = indicatorsValueService.getIndicatorsValue(
getBaseIndValueMsg.getIndId(), getBaseIndValueMsg.getDimValue(),
getBaseIndValueMsg.getCode());
if (indValueMap != null) {
if (indValueMap.get("value") == null) {//如果指标值为空,返回失败结果
//返回指标值结果
getSender().tell(new BaseIndValueMsg(getBaseIndValueMsg.getIndId()
, null, indValueMap.get("compareObjDesc").toString(), 0,
"获取指标id:" +
getBaseIndValueMsg.getIndId() + ";维度:" +
getBaseIndValueMsg.getDimValue().get(0).getDimvalue() + "," +
getBaseIndValueMsg.getDimValue().get(1).getDimvalue() + " 的指标值为空;"), getSelf());
} else {
getSender().tell(new BaseIndValueMsg(getBaseIndValueMsg.getIndId()
, indValueMap.get("value").toString(),
indValueMap.get("compareObjDesc").toString(), 1, ""), getSelf());
}
} else {
//返回指标值结果
getSender().tell(new BaseIndValueMsg(getBaseIndValueMsg.getIndId()
,null,indValueMap.get("compareObjDesc").toString(),0,
"获取指标id:"+
getBaseIndValueMsg.getIndId()+";维度:"+
getBaseIndValueMsg.getDimValue().get(0).getDimvalue()+","+
getBaseIndValueMsg.getDimValue().get(1).getDimvalue()+" 的指标值为空;"),getSelf());
}else {
getSender().tell(new BaseIndValueMsg(getBaseIndValueMsg.getIndId()
,indValueMap.get("value").toString(),
indValueMap.get("compareObjDesc").toString(),1,""),getSelf());
getSender().tell(new BaseIndValueMsg(getBaseIndValueMsg.getIndId(), null, null,
0, "无法获取指标id:" +
getBaseIndValueMsg.getIndId() + ";维度:" +
getBaseIndValueMsg.getDimValue().get(0).getDimvalue() + "," +
getBaseIndValueMsg.getDimValue().get(1).getDimvalue() + " 的指标值;"), getSelf());
}
}else {
//返回指标值结果
getSender().tell(new BaseIndValueMsg(getBaseIndValueMsg.getIndId(),null,null,
0,"无法获取指标id:"+
getBaseIndValueMsg.getIndId()+";维度:"+
getBaseIndValueMsg.getDimValue().get(0).getDimvalue()+","+
getBaseIndValueMsg.getDimValue().get(1).getDimvalue()+" 的指标值;"),getSelf());
}
})
.build();
})
.build();
}catch (Exception e){
e.printStackTrace();
CompareUnitCalLog compCalLog = compareUnitCalLogService.findById(compCalLogId);
if(compCalLog!=null){
compCalLog.setEndTime(System.currentTimeMillis()+"");
compCalLog.setRunStatus("1");
compCalLog.setStatus(0);
compCalLog.setLogInfo("运算失败");
compareUnitCalLogService.saveOrUndate(compCalLog);
}
}
return receive;
}
}
......@@ -17,13 +17,23 @@ public class GetBaseIndValueMsg implements Serializable{
private List<DimValue> dimValue = new ArrayList<>();//维度值
private String code;
private Integer compCalLogId;
public GetBaseIndValueMsg(String indId,List<DimValue> dimValue,String code) {
this.indId = indId;
this.dimValue.addAll(dimValue);
this.code = code;
}
public Integer getCompCalLogId() {
return compCalLogId;
}
public void setCompCalLogId(Integer compCalLogId) {
this.compCalLogId = compCalLogId;
}
public List<DimValue> getDimValue() {
return dimValue;
}
......
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