65 changed files with 34759 additions and 111 deletions
@ -0,0 +1,5 @@ |
|||||
|
package io.sc.engine.mv.sample.service; |
||||
|
|
||||
|
public interface DaiKuanImporterService { |
||||
|
public void load() throws Exception; |
||||
|
} |
@ -0,0 +1,5 @@ |
|||||
|
package io.sc.engine.mv.sample.service; |
||||
|
|
||||
|
public interface TestCaseImporterService { |
||||
|
public void load() throws Exception; |
||||
|
} |
@ -0,0 +1,189 @@ |
|||||
|
package io.sc.engine.mv.sample.service.impl; |
||||
|
|
||||
|
import com.opencsv.CSVReader; |
||||
|
import com.opencsv.CSVReaderBuilder; |
||||
|
import io.sc.engine.mv.sample.service.CardGongXinImporterService; |
||||
|
import io.sc.engine.mv.sample.service.DaiKuanImporterService; |
||||
|
import io.sc.platform.core.util.DateUtil; |
||||
|
import io.sc.platform.jdbc.sql.builder.InsertIntoSqlBuilder; |
||||
|
import io.sc.platform.jdbc.util.SqlBatcher; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.core.io.DefaultResourceLoader; |
||||
|
import org.springframework.core.io.Resource; |
||||
|
import org.springframework.jdbc.core.JdbcTemplate; |
||||
|
import org.springframework.stereotype.Service; |
||||
|
|
||||
|
import java.io.BufferedReader; |
||||
|
import java.io.IOException; |
||||
|
import java.io.InputStreamReader; |
||||
|
import java.util.Date; |
||||
|
import java.util.Iterator; |
||||
|
import java.util.UUID; |
||||
|
|
||||
|
@Service |
||||
|
public class DaiKuanImporterServiceImpl implements DaiKuanImporterService { |
||||
|
private static final String URL ="classpath:/io/sc/engine/mv/sample/贷款模型.csv"; |
||||
|
private static final String MODEL_ID ="DAIKUAN"; |
||||
|
private static final String MODEL_NAME ="贷款"; |
||||
|
@Autowired |
||||
|
private JdbcTemplate jdbcTemplate; |
||||
|
|
||||
|
@Override |
||||
|
public void load() throws Exception { |
||||
|
//删除违约记录表的数据
|
||||
|
deleteDefaultRecord(); |
||||
|
//删除评分记录表的数据
|
||||
|
deleteScoreRecord(); |
||||
|
//更新模型配置表的数据
|
||||
|
updateModelConfigure(); |
||||
|
//更新咨询建模时的客户分布配置表的数据
|
||||
|
updateDistributionConfigure(); |
||||
|
//更新标尺表的数据
|
||||
|
updateScaleConfigure(); |
||||
|
//导入测试用例评分记录和违约记录
|
||||
|
importData(); |
||||
|
} |
||||
|
|
||||
|
private void deleteDefaultRecord(){ |
||||
|
jdbcTemplate.update("delete from MV_DEFAULT_RECORD where FD_CUSTOM_ID in (select distinct FD_CUSTOM_ID from MV_SCORE_RECORD where FD_MODEL_ID=?)",MODEL_ID); |
||||
|
} |
||||
|
|
||||
|
private void deleteScoreRecord(){ |
||||
|
jdbcTemplate.update("delete from MV_SCORE_RECORD where FD_MODEL_ID=?",MODEL_ID); |
||||
|
} |
||||
|
|
||||
|
private void updateModelConfigure(){ |
||||
|
jdbcTemplate.update("delete from MV_CFG_MODEL where FD_MODEL_ID=?",MODEL_ID); |
||||
|
InsertIntoSqlBuilder builder =new InsertIntoSqlBuilder(); |
||||
|
builder.table("MV_CFG_MODEL") |
||||
|
.field("FD_ID",MODEL_ID) |
||||
|
.field("FD_MODEL_ID",MODEL_ID) |
||||
|
.field("FD_MODEL_NAME",MODEL_NAME) |
||||
|
.field("FD_TYPE","IMPORT_FROM_SCORE_RECORD") |
||||
|
.field("DATA_COME_FROM_","IMPORT") |
||||
|
.field("CREATOR_","system") |
||||
|
.field("CREATE_DATE_",new Date()) |
||||
|
.field("LAST_MODIFIER_","system") |
||||
|
.field("LAST_MODIFYDATE_",new Date()) |
||||
|
.insert(jdbcTemplate); |
||||
|
|
||||
|
|
||||
|
} |
||||
|
|
||||
|
private void updateDistributionConfigure(){ |
||||
|
jdbcTemplate.update("delete from MV_CFG_DISTRIBUTION where FD_MODEL_ID=?",MODEL_ID); |
||||
|
insertDistributionConfigure( 1,10,0); |
||||
|
insertDistributionConfigure(11,20,0); |
||||
|
insertDistributionConfigure(21,30,0); |
||||
|
insertDistributionConfigure(31,40,30); |
||||
|
insertDistributionConfigure(41,50,30); |
||||
|
insertDistributionConfigure(51,60,2000); |
||||
|
insertDistributionConfigure(61,70,1000); |
||||
|
insertDistributionConfigure(71,80,600); |
||||
|
insertDistributionConfigure(81,90,600); |
||||
|
insertDistributionConfigure(91,100,1500); |
||||
|
} |
||||
|
|
||||
|
private void insertDistributionConfigure(int start,int end,int count){ |
||||
|
new InsertIntoSqlBuilder().table("MV_CFG_DISTRIBUTION") |
||||
|
.field("FD_ID",UUID.randomUUID().toString()) |
||||
|
.field("FD_MODEL_ID",MODEL_ID) |
||||
|
.field("FD_MODEL_NAME",MODEL_NAME) |
||||
|
.field("FD_SCORE_SEG_START",start) |
||||
|
.field("FD_SCORE_SEG_END",end) |
||||
|
.field("FD_COUNT",count) |
||||
|
.field("CREATOR_","system") |
||||
|
.field("CREATE_DATE_",new Date()) |
||||
|
.field("LAST_MODIFIER_","system") |
||||
|
.field("LAST_MODIFYDATE_",new Date()) |
||||
|
.insert(jdbcTemplate); |
||||
|
} |
||||
|
|
||||
|
private void updateScaleConfigure(){ |
||||
|
jdbcTemplate.update("delete from MV_CFG_SCALE where FD_MODEL_ID is null"); |
||||
|
insertScaleConfigure( 1,0.0); |
||||
|
insertScaleConfigure(2,0.0015); |
||||
|
insertScaleConfigure(3,0.0033); |
||||
|
insertScaleConfigure(4,0.0060); |
||||
|
insertScaleConfigure(5,0.0088); |
||||
|
insertScaleConfigure(6,0.0189); |
||||
|
insertScaleConfigure(7,0.03); |
||||
|
insertScaleConfigure(8,0.0486); |
||||
|
insertScaleConfigure(9,0.0685); |
||||
|
insertScaleConfigure(10,0.1054); |
||||
|
insertScaleConfigure(11,0.2869); |
||||
|
insertScaleConfigure(12,0.5128); |
||||
|
} |
||||
|
|
||||
|
private void insertScaleConfigure(int order,double pd){ |
||||
|
new InsertIntoSqlBuilder().table("MV_CFG_SCALE") |
||||
|
.field("FD_ID", UUID.randomUUID().toString()) |
||||
|
.field("FD_LEVEL",order) |
||||
|
.field("FD_PD",pd) |
||||
|
.field("FD_ORDER",order) |
||||
|
.field("CREATOR_","system") |
||||
|
.field("CREATE_DATE_",new Date()) |
||||
|
.field("LAST_MODIFIER_","system") |
||||
|
.field("LAST_MODIFYDATE_",new Date()) |
||||
|
.insert(jdbcTemplate); |
||||
|
} |
||||
|
|
||||
|
private void importData() throws Exception { |
||||
|
Date scroeBeginDate =DateUtil.parseDate("2014-05-01", DateUtil.yyyy_MM_dd); |
||||
|
Date scroeEndDate =DateUtil.parseDate("2015-05-01", DateUtil.yyyy_MM_dd); |
||||
|
Date defaultConfirmDate =DateUtil.parseDate("2015-01-01", DateUtil.yyyy_MM_dd); |
||||
|
Resource resource =new DefaultResourceLoader().getResource(URL); |
||||
|
if(resource==null|| !resource.exists()){ |
||||
|
throw new IOException("resource '" + URL + "' is not exists"); |
||||
|
} |
||||
|
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(resource.getInputStream())); |
||||
|
CSVReader reader = new CSVReaderBuilder(bufferedReader).withSkipLines(1).build(); |
||||
|
Iterator<String[]> iterator = reader.iterator(); |
||||
|
SqlBatcher scoreRecordBatcher =new SqlBatcher(getScoreRecordInsertSql()); |
||||
|
SqlBatcher defaultRecordBatcher =new SqlBatcher(getDefaultRecordInsertSql()); |
||||
|
long index =1; |
||||
|
while(iterator.hasNext()) { |
||||
|
String[] values = iterator.next(); |
||||
|
scoreRecordBatcher.addArg( |
||||
|
values[0], /* FD_CUSTOM_ID */ |
||||
|
values[0], /* FD_CUSTOM_NAME */ |
||||
|
MODEL_ID, /* FD_MODEL_ID */ |
||||
|
MODEL_NAME, /* FD_MODEL_NAME */ |
||||
|
Double.parseDouble(values[1]), /* FD_SCORE */ |
||||
|
values[2], /* FD_LEVEL */ |
||||
|
scroeBeginDate, /* FD_SCORE_BEGIN_DATE */ |
||||
|
scroeEndDate /* FD_SCORE_END_DATE */ |
||||
|
); |
||||
|
|
||||
|
if("1".equalsIgnoreCase(values[3])){ |
||||
|
defaultRecordBatcher.addArg(values[0],defaultConfirmDate); |
||||
|
} |
||||
|
|
||||
|
if(index%500==0){ |
||||
|
scoreRecordBatcher.execute(jdbcTemplate); |
||||
|
defaultRecordBatcher.execute(jdbcTemplate); |
||||
|
} |
||||
|
index++; |
||||
|
} |
||||
|
scoreRecordBatcher.execute(jdbcTemplate); |
||||
|
defaultRecordBatcher.execute(jdbcTemplate); |
||||
|
} |
||||
|
|
||||
|
private String getScoreRecordInsertSql(){ |
||||
|
return "" |
||||
|
+ "insert into MV_SCORE_RECORD(" |
||||
|
+ " FD_CUSTOM_ID," |
||||
|
+ " FD_CUSTOM_NAME," |
||||
|
+ " FD_MODEL_ID," |
||||
|
+ " FD_MODEL_NAME," |
||||
|
+ " FD_SCORE," |
||||
|
+ " FD_LEVEL," |
||||
|
+ " FD_SCORE_BEGIN_DATE," |
||||
|
+ " FD_SCORE_END_DATE" |
||||
|
+ ") values (?,?,?,?,?,?,?,?)"; |
||||
|
} |
||||
|
|
||||
|
private String getDefaultRecordInsertSql(){ |
||||
|
return "insert into MV_DEFAULT_RECORD(FD_CUSTOM_ID,FD_DEFAULT_CONFIRM_DATE) values (?,?)"; |
||||
|
} |
||||
|
} |
@ -0,0 +1,162 @@ |
|||||
|
package io.sc.engine.mv.sample.service.impl; |
||||
|
|
||||
|
import com.opencsv.CSVReader; |
||||
|
import com.opencsv.CSVReaderBuilder; |
||||
|
import io.sc.engine.mv.sample.service.TestCaseImporterService; |
||||
|
import io.sc.platform.core.util.DateUtil; |
||||
|
import io.sc.platform.core.util.StringUtil; |
||||
|
import io.sc.platform.jdbc.sql.builder.InsertIntoSqlBuilder; |
||||
|
import io.sc.platform.jdbc.util.SqlBatcher; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.core.io.DefaultResourceLoader; |
||||
|
import org.springframework.core.io.Resource; |
||||
|
import org.springframework.jdbc.core.JdbcTemplate; |
||||
|
import org.springframework.stereotype.Service; |
||||
|
import org.springframework.util.StringUtils; |
||||
|
|
||||
|
import java.io.BufferedReader; |
||||
|
import java.io.IOException; |
||||
|
import java.io.InputStreamReader; |
||||
|
import java.util.Date; |
||||
|
import java.util.Iterator; |
||||
|
import java.util.UUID; |
||||
|
|
||||
|
@Service |
||||
|
public class TestCaseImporterServiceImpl implements TestCaseImporterService { |
||||
|
private static final String URL ="classpath:/io/sc/engine/mv/sample/TestCase.csv"; |
||||
|
private static final String MODEL_ID ="M1"; |
||||
|
private static final String MODEL_NAME ="测试用例模型"; |
||||
|
|
||||
|
@Autowired private JdbcTemplate jdbcTemplate; |
||||
|
|
||||
|
@Override |
||||
|
public void load() throws Exception { |
||||
|
//删除违约记录表的数据
|
||||
|
deleteDefaultRecord(); |
||||
|
//删除评分记录表的数据
|
||||
|
deleteScoreRecord(); |
||||
|
//更新模型配置表的数据
|
||||
|
updateModelConfigure(); |
||||
|
//更新咨询建模时的客户分布配置表的数据
|
||||
|
updateDistributionConfigure(); |
||||
|
//导入测试用例评分记录和违约记录
|
||||
|
importData(); |
||||
|
} |
||||
|
|
||||
|
private void deleteDefaultRecord(){ |
||||
|
jdbcTemplate.update("delete from MV_DEFAULT_RECORD where FD_CUSTOM_ID in (select distinct FD_CUSTOM_ID from MV_SCORE_RECORD where FD_MODEL_ID=?)",MODEL_ID); |
||||
|
} |
||||
|
|
||||
|
private void deleteScoreRecord(){ |
||||
|
jdbcTemplate.update("delete from MV_SCORE_RECORD where FD_MODEL_ID=?",MODEL_ID); |
||||
|
} |
||||
|
|
||||
|
private void updateModelConfigure(){ |
||||
|
jdbcTemplate.update("delete from MV_CFG_MODEL where FD_MODEL_ID=?",MODEL_ID); |
||||
|
InsertIntoSqlBuilder builder =new InsertIntoSqlBuilder(); |
||||
|
builder.table("MV_CFG_MODEL") |
||||
|
.field("FD_ID",UUID.randomUUID().toString()) |
||||
|
.field("FD_MODEL_ID",MODEL_ID) |
||||
|
.field("FD_MODEL_NAME",MODEL_NAME) |
||||
|
.field("FD_TYPE","IMPORT_FROM_SCORE_RECORD") |
||||
|
.field("DATA_COME_FROM_","IMPORT") |
||||
|
.field("CREATOR_","system") |
||||
|
.field("CREATE_DATE_",new Date()) |
||||
|
.field("LAST_MODIFIER_","system") |
||||
|
.field("LAST_MODIFYDATE_",new Date()) |
||||
|
.insert(jdbcTemplate); |
||||
|
|
||||
|
|
||||
|
} |
||||
|
|
||||
|
private void updateDistributionConfigure(){ |
||||
|
jdbcTemplate.update("delete from MV_CFG_DISTRIBUTION where FD_MODEL_ID=?",MODEL_ID); |
||||
|
insertDistributionConfigure(1,20,0); |
||||
|
insertDistributionConfigure(21,40,20); |
||||
|
insertDistributionConfigure(41,60,50); |
||||
|
insertDistributionConfigure(61,80,60); |
||||
|
insertDistributionConfigure(81,100,30); |
||||
|
} |
||||
|
|
||||
|
private void insertDistributionConfigure(int start,int end,int count){ |
||||
|
new InsertIntoSqlBuilder().table("MV_CFG_DISTRIBUTION") |
||||
|
.field("FD_ID", UUID.randomUUID().toString()) |
||||
|
.field("FD_MODEL_ID",MODEL_ID) |
||||
|
.field("FD_MODEL_NAME",MODEL_NAME) |
||||
|
.field("FD_SCORE_SEG_START",start) |
||||
|
.field("FD_SCORE_SEG_END",end) |
||||
|
.field("FD_COUNT",count) |
||||
|
.field("CREATOR_","system") |
||||
|
.field("CREATE_DATE_",new Date()) |
||||
|
.field("LAST_MODIFIER_","system") |
||||
|
.field("LAST_MODIFYDATE_",new Date()) |
||||
|
.insert(jdbcTemplate); |
||||
|
} |
||||
|
|
||||
|
private void importData() throws Exception { |
||||
|
Resource resource =new DefaultResourceLoader().getResource(URL); |
||||
|
if(resource==null|| !resource.exists()){ |
||||
|
throw new IOException("resource '" + URL + "' is not exists"); |
||||
|
} |
||||
|
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(resource.getInputStream())); |
||||
|
CSVReader reader = new CSVReaderBuilder(bufferedReader).withSkipLines(3).build(); |
||||
|
Iterator<String[]> iterator = reader.iterator(); |
||||
|
SqlBatcher scoreRecordBatcher =new SqlBatcher(getScoreRecordInsertSql()); |
||||
|
SqlBatcher defaultRecordBatcher =new SqlBatcher(getDefaultRecordInsertSql()); |
||||
|
long index =1; |
||||
|
while(iterator.hasNext()) { |
||||
|
String[] values = iterator.next(); |
||||
|
if(values!=null && values.length>0){ |
||||
|
for(int i=0;i<values.length;i++){ |
||||
|
values[i] =values[i]==null?null:values[i].trim(); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
scoreRecordBatcher.addArg( |
||||
|
values[0], /* FD_CUSTOM_ID */ |
||||
|
values[1], /* FD_CUSTOM_NAME */ |
||||
|
values[2], /* FD_MODEL_ID */ |
||||
|
values[3], /* FD_MODEL_NAME */ |
||||
|
Double.parseDouble(values[4]), /* FD_PD */ |
||||
|
Double.parseDouble(values[5]), /* FD_SCORE */ |
||||
|
Double.parseDouble(values[6]), /* FD_SCORE_QUANTITATIVE */ |
||||
|
Double.parseDouble(values[7]), /* FD_SCORE_QUALITATIVE */ |
||||
|
values[8], /* FD_LEVEL */ |
||||
|
DateUtil.parseDate(values[9], DateUtil.yyyy_MM_dd), /* FD_SCORE_BEGIN_DATE */ |
||||
|
DateUtil.parseDate(values[10], DateUtil.yyyy_MM_dd) /* FD_SCORE_END_DATE */ |
||||
|
); |
||||
|
|
||||
|
if(StringUtils.hasText(values[11])){ |
||||
|
defaultRecordBatcher.addArg(values[0],DateUtil.parseDate(values[11], DateUtil.yyyy_MM_dd)); |
||||
|
} |
||||
|
|
||||
|
if(index%500==0){ |
||||
|
scoreRecordBatcher.execute(jdbcTemplate); |
||||
|
defaultRecordBatcher.execute(jdbcTemplate); |
||||
|
} |
||||
|
index++; |
||||
|
} |
||||
|
scoreRecordBatcher.execute(jdbcTemplate); |
||||
|
defaultRecordBatcher.execute(jdbcTemplate); |
||||
|
} |
||||
|
|
||||
|
private String getScoreRecordInsertSql(){ |
||||
|
return "insert into MV_SCORE_RECORD(" |
||||
|
+ " FD_CUSTOM_ID," |
||||
|
+ " FD_CUSTOM_NAME," |
||||
|
+ " FD_MODEL_ID," |
||||
|
+ " FD_MODEL_NAME," |
||||
|
+ " FD_PD," |
||||
|
+ " FD_SCORE," |
||||
|
+ " FD_SCORE_QUANTITATIVE," |
||||
|
+ " FD_SCORE_QUALITATIVE," |
||||
|
+ " FD_LEVEL," |
||||
|
+ " FD_SCORE_BEGIN_DATE," |
||||
|
+ " FD_SCORE_END_DATE" |
||||
|
+ ") values (?,?,?,?,?,?,?,?,?,?,?)"; |
||||
|
} |
||||
|
|
||||
|
private String getDefaultRecordInsertSql(){ |
||||
|
return "insert into MV_DEFAULT_RECORD(FD_CUSTOM_ID,FD_DEFAULT_CONFIRM_DATE) values (?,?)"; |
||||
|
} |
||||
|
} |
File diff suppressed because it is too large
File diff suppressed because it is too large
File diff suppressed because it is too large
@ -0,0 +1,11 @@ |
|||||
|
package io.sc.engine.mv; |
||||
|
|
||||
|
/** |
||||
|
* 估值准确性检验结果枚举值 |
||||
|
* @author wangshaoping |
||||
|
* |
||||
|
*/ |
||||
|
public enum CoeResult { |
||||
|
PASS, //验证通过
|
||||
|
NOT_PASS; //验证未通过
|
||||
|
} |
@ -0,0 +1,14 @@ |
|||||
|
package io.sc.engine.mv; |
||||
|
|
||||
|
/** |
||||
|
* 模型验证源数据抽取器 |
||||
|
* @author wangshaoping |
||||
|
* |
||||
|
*/ |
||||
|
public interface DataExtractor extends ProgressTracker{ |
||||
|
/** |
||||
|
* 抽取源数据 |
||||
|
* @param runtimeContext 模型验证执行上下文对象 |
||||
|
*/ |
||||
|
public void extract(RuntimeContext runtimeContext); |
||||
|
} |
@ -0,0 +1,106 @@ |
|||||
|
package io.sc.engine.mv; |
||||
|
|
||||
|
import io.sc.engine.mv.jpa.entity.CfgDataExtractor; |
||||
|
import io.sc.engine.mv.jpa.repository.CfgDataExtractorRepository; |
||||
|
import io.sc.platform.core.support.ProgressInfo; |
||||
|
import io.sc.platform.groovy.GroovyScriptExecutor; |
||||
|
import io.sc.platform.jdbc.service.DatasourceService; |
||||
|
import org.slf4j.Logger; |
||||
|
import org.slf4j.LoggerFactory; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.context.ApplicationContext; |
||||
|
import org.springframework.stereotype.Component; |
||||
|
import org.springframework.util.StringUtils; |
||||
|
|
||||
|
import java.util.HashMap; |
||||
|
import java.util.List; |
||||
|
import java.util.Map; |
||||
|
|
||||
|
/** |
||||
|
* 数据抽取器接口管理器 |
||||
|
* @author wangshaoping |
||||
|
* |
||||
|
*/ |
||||
|
@Component("mvDataExtractorManager") |
||||
|
public class DataExtractorManager { |
||||
|
private static final Logger log =LoggerFactory.getLogger(DataExtractorManager.class); |
||||
|
@Autowired private CfgDataExtractorRepository repository; |
||||
|
@Autowired private ApplicationContext applicationContext; |
||||
|
@Autowired private DatasourceService datasourceService; |
||||
|
|
||||
|
/** |
||||
|
* 获取所有可用的数据抽取器的预计执行时间权重之和 |
||||
|
* @param runtimeContext 执行上下文 |
||||
|
* @return 所有可用的数据抽取器的预计执行时间权重之和 |
||||
|
*/ |
||||
|
public int getTotalWeight(RuntimeContext runtimeContext){ |
||||
|
int totalWeight =0; |
||||
|
List<CfgDataExtractor> dataExtractors =repository.findByEnableOrderByOrder(true); |
||||
|
if(dataExtractors!=null && dataExtractors.size()>0){ |
||||
|
for(CfgDataExtractor dataExtractor : dataExtractors){ |
||||
|
totalWeight +=dataExtractor.getExecuteTimeWeight(); |
||||
|
} |
||||
|
} |
||||
|
return totalWeight; |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 执行所有可用的数据抽取器 |
||||
|
* @param runtimeContext 执行上下文 |
||||
|
* @param progressInfo 执行进度信息 |
||||
|
* @throws Exception 违例 |
||||
|
*/ |
||||
|
public void execute(RuntimeContext runtimeContext, ProgressInfo progressInfo) throws Exception{ |
||||
|
List<CfgDataExtractor> dataExtractors =repository.findByEnableOrderByOrder(true); |
||||
|
if(dataExtractors!=null && dataExtractors.size()>0){ |
||||
|
for(CfgDataExtractor dataExtractor : dataExtractors){ |
||||
|
execute(dataExtractor,runtimeContext,progressInfo); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 执行数据抽取器 |
||||
|
* @param dataExtractor 数据抽取器 |
||||
|
* @param runtimeContext 执行上下文 |
||||
|
* @param progressInfo 执行进度信息 |
||||
|
* @throws Exception 违例 |
||||
|
*/ |
||||
|
public void execute(CfgDataExtractor dataExtractor,RuntimeContext runtimeContext,ProgressInfo progressInfo) throws Exception{ |
||||
|
String name =dataExtractor.getName(); |
||||
|
String message ="开始执行数据抽取器[" + name + "]..."; |
||||
|
log.info(message); |
||||
|
progressInfo.setMessageKey(message); |
||||
|
try { |
||||
|
executeGroovyScript(dataExtractor,runtimeContext); |
||||
|
} catch (Exception e) { |
||||
|
message ="执行数据抽取器[" + name + "]时,发生错误."; |
||||
|
progressInfo.setMessageKey(message); |
||||
|
throw new Exception(message,e); |
||||
|
} |
||||
|
|
||||
|
message ="结束执行数据抽取器[" + name + "]"; |
||||
|
log.info(message); |
||||
|
progressInfo.setMessageKey(message); |
||||
|
|
||||
|
progressInfo.addWeight(dataExtractor.getExecuteTimeWeight()); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 执行数据抽取器(Groovy 脚本) |
||||
|
* @param dataExtractor 数据抽取器 |
||||
|
* @param runtimeContext 执行上下文 |
||||
|
* @throws Exception 违例 |
||||
|
*/ |
||||
|
private void executeGroovyScript(CfgDataExtractor dataExtractor,RuntimeContext runtimeContext) throws Exception{ |
||||
|
if(StringUtils.hasText(dataExtractor.getGroovyScript())){ |
||||
|
Map<String,Object> context =new HashMap<String,Object>(); |
||||
|
context.put("dataExtractor", dataExtractor); |
||||
|
context.put("runtimeContext", runtimeContext); |
||||
|
context.put("applicationContext", applicationContext); |
||||
|
context.put("defaultDataSource", datasourceService.getDefaultDatasource()); |
||||
|
context.put("dataSource", datasourceService.getDatasource(dataExtractor.getDatasourceName())); |
||||
|
GroovyScriptExecutor.getInstance().eval(dataExtractor.getGroovyScript(), context); |
||||
|
} |
||||
|
} |
||||
|
} |
@ -0,0 +1,8 @@ |
|||||
|
package io.sc.engine.mv; |
||||
|
|
||||
|
public enum DataExtractorType { |
||||
|
SQL, //SQL 语句
|
||||
|
JAVA_CLASS, //Java 类
|
||||
|
GROOVY_SCRIPT, //groovy 脚本
|
||||
|
SPRING_BEAN_NAME; //spring bean 名称
|
||||
|
} |
@ -0,0 +1,62 @@ |
|||||
|
package io.sc.engine.mv; |
||||
|
|
||||
|
import java.util.Date; |
||||
|
import java.util.Locale; |
||||
|
|
||||
|
import io.sc.platform.core.support.ProgressInfo; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.stereotype.Component; |
||||
|
|
||||
|
/** |
||||
|
* 模型验证器,作为模型验证的执行入口 |
||||
|
* @author wangshaoping |
||||
|
* |
||||
|
*/ |
||||
|
@Component("mvValidator") |
||||
|
public class Validator { |
||||
|
//数据抽取器接口管理器
|
||||
|
@Autowired private DataExtractorManager dataExtractorManager; |
||||
|
//模型验证执行器管理器
|
||||
|
@Autowired private ExecutorManager executorManager; |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 执行模型验证 |
||||
|
* @param runtimeContext 模型验证运行时上下文对象 |
||||
|
* @throws Exception 违例 |
||||
|
*/ |
||||
|
public void validate(RuntimeContext runtimeContext) throws Exception{ |
||||
|
validate(runtimeContext,new ProgressInfo(),Locale.getDefault()); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 执行模型验证 |
||||
|
* @param runtimeContext 模型验证运行时上下文对象 |
||||
|
* @param progressInfo 执行进度跟踪器对象 |
||||
|
* @throws Exception 违例 |
||||
|
*/ |
||||
|
public void validate(RuntimeContext runtimeContext,ProgressInfo progressInfo) throws Exception{ |
||||
|
validate(runtimeContext,progressInfo,Locale.getDefault()); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 执行模型验证 |
||||
|
* @param runtimeContext 模型验证运行时上下文对象 |
||||
|
* @param progressInfo 执行进度跟踪器对象 |
||||
|
* @param locale 区域对象 |
||||
|
* @throws Exception 违例 |
||||
|
*/ |
||||
|
public void validate(RuntimeContext runtimeContext,ProgressInfo progressInfo,Locale locale) throws Exception{ |
||||
|
progressInfo.setStartDatetime(new Date()); |
||||
|
progressInfo.setTotalWeight(dataExtractorManager.getTotalWeight(runtimeContext) + executorManager.getTotalWeight()); |
||||
|
|
||||
|
//执行源数据抽取
|
||||
|
dataExtractorManager.execute(runtimeContext,progressInfo); |
||||
|
//执行模型验证计算
|
||||
|
executorManager.execute(runtimeContext, progressInfo,locale); |
||||
|
|
||||
|
//执行完毕
|
||||
|
progressInfo.setCompletedDatetime(new Date()); |
||||
|
progressInfo.setCurrentWeight(progressInfo.getTotalWeight()); |
||||
|
} |
||||
|
} |
@ -0,0 +1,47 @@ |
|||||
|
package io.sc.engine.mv.controller; |
||||
|
|
||||
|
import io.sc.engine.mv.jpa.entity.GeneralResultHistory; |
||||
|
import io.sc.engine.mv.jpa.entity.id.GeneralResultHistoryId; |
||||
|
import io.sc.engine.mv.jpa.repository.GeneralResultHistoryRepository; |
||||
|
import io.sc.engine.mv.jpa.repository.RuntimeParameterRepository; |
||||
|
import io.sc.engine.mv.service.result.GeneralResultHistoryService; |
||||
|
import io.sc.engine.mv.vo.GeneralResultHistoryVo; |
||||
|
import io.sc.platform.core.util.CollectionUtil; |
||||
|
import io.sc.platform.mvc.controller.support.RestCrudController; |
||||
|
import io.sc.platform.orm.service.support.QueryParameter; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.data.domain.Page; |
||||
|
import org.springframework.stereotype.Controller; |
||||
|
import org.springframework.web.bind.annotation.RequestMapping; |
||||
|
import org.springframework.web.bind.annotation.RestController; |
||||
|
import org.springframework.web.servlet.ModelAndView; |
||||
|
|
||||
|
import javax.servlet.http.HttpServletRequest; |
||||
|
import javax.servlet.http.HttpServletResponse; |
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* 查询模型验证结果控制器 |
||||
|
* @author wangshaoping |
||||
|
* |
||||
|
*/ |
||||
|
@RestController |
||||
|
@RequestMapping("/api/mv/result") |
||||
|
public class ShowResultWebController extends RestCrudController<GeneralResultHistoryVo,GeneralResultHistory, GeneralResultHistoryId, GeneralResultHistoryRepository, GeneralResultHistoryService> { |
||||
|
@Autowired private GeneralResultHistoryRepository generalResultHistoryRepository; |
||||
|
@Autowired private RuntimeParameterRepository runtimeParameterRepository; |
||||
|
|
||||
|
@Override |
||||
|
protected Page<GeneralResultHistoryVo> query(HttpServletRequest request, HttpServletResponse response, QueryParameter queryParameter) throws Exception { |
||||
|
Page<GeneralResultHistoryVo> page =super.query(request, response, queryParameter); |
||||
|
if(page!=null && page.getContent()!=null && !page.getContent().isEmpty()){ |
||||
|
List<GeneralResultHistoryVo> content =page.getContent(); |
||||
|
if(content!=null && !content.isEmpty()) { |
||||
|
for (GeneralResultHistoryVo vo : content) { |
||||
|
vo.setRuntimeParameters(runtimeParameterRepository.findByValidateDateOrderBySno(vo.getValidateDate())); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
return page; |
||||
|
} |
||||
|
} |
@ -0,0 +1,44 @@ |
|||||
|
package io.sc.engine.mv.controller; |
||||
|
|
||||
|
import io.sc.engine.mv.jpa.entity.GeneralSampleHistory; |
||||
|
import io.sc.engine.mv.jpa.entity.id.GeneralSampleHistoryId; |
||||
|
import io.sc.engine.mv.jpa.repository.GeneralSampleHistoryRepository; |
||||
|
import io.sc.engine.mv.service.result.GeneralSampleHistoryService; |
||||
|
import io.sc.engine.mv.vo.GeneralSampleHistoryVo; |
||||
|
import io.sc.platform.core.util.CollectionUtil; |
||||
|
import io.sc.platform.mvc.controller.support.RestCrudController; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.stereotype.Controller; |
||||
|
import org.springframework.web.bind.annotation.RequestMapping; |
||||
|
import org.springframework.web.bind.annotation.RequestParam; |
||||
|
import org.springframework.web.servlet.ModelAndView; |
||||
|
|
||||
|
/** |
||||
|
* 查询模型验证样本数据控制器 |
||||
|
* @author wangshaoping |
||||
|
* |
||||
|
*/ |
||||
|
@Controller |
||||
|
@RequestMapping("/mv/sample") |
||||
|
public class ShowSampleWebController extends RestCrudController<GeneralSampleHistoryVo,GeneralSampleHistory, GeneralSampleHistoryId, GeneralSampleHistoryRepository, GeneralSampleHistoryService> { |
||||
|
@Autowired private GeneralSampleHistoryRepository generalSampleHistoryRepository; |
||||
|
|
||||
|
/** |
||||
|
* 模型验证样本页面 |
||||
|
* @param modelId 模型ID |
||||
|
* @param validateDate 验证日期 |
||||
|
* @return 模型视图对象 |
||||
|
*/ |
||||
|
@RequestMapping("sampleDataView") |
||||
|
public ModelAndView sampleView( |
||||
|
@RequestParam(name="modelId",required=false) String modelId, |
||||
|
@RequestParam(name="validateDate",required=false) String validateDate |
||||
|
){ |
||||
|
ModelAndView mv =new ModelAndView("org/wsp/model/validator/view/sampleDataView.html"); |
||||
|
mv.addObject("removeNavbar", true); |
||||
|
mv.addObject("modelId", modelId); |
||||
|
mv.addObject("validateDate", validateDate); |
||||
|
mv.addObject("distinctModelIdAndNames", CollectionUtil.arrayList2Map(generalSampleHistoryRepository.findDistinctModelIdAndNames())); |
||||
|
return mv; |
||||
|
} |
||||
|
} |
@ -0,0 +1,35 @@ |
|||||
|
package io.sc.engine.mv.controller.configuration; |
||||
|
|
||||
|
import io.sc.engine.mv.jpa.entity.CfgDataExtractor; |
||||
|
import io.sc.engine.mv.jpa.repository.CfgDataExtractorRepository; |
||||
|
import io.sc.engine.mv.service.configuration.CfgDataExtractorService; |
||||
|
import io.sc.engine.mv.vo.CfgDataExtractorVo; |
||||
|
import io.sc.platform.mvc.controller.support.RestCrudController; |
||||
|
import io.sc.platform.system.ds.jpa.repository.DsRepository; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.stereotype.Controller; |
||||
|
import org.springframework.web.bind.annotation.*; |
||||
|
import org.springframework.web.servlet.ModelAndView; |
||||
|
|
||||
|
/** |
||||
|
* 数据抽取器接口配置控制器 |
||||
|
* @author wangshaoping |
||||
|
* |
||||
|
*/ |
||||
|
@RestController |
||||
|
@RequestMapping("/api/mv/config/dataExtractor") |
||||
|
public class DataExtractorWebController extends RestCrudController<CfgDataExtractorVo, CfgDataExtractor, String, CfgDataExtractorRepository, CfgDataExtractorService> { |
||||
|
@Autowired private DsRepository dsRepository; |
||||
|
|
||||
|
@RequestMapping(value="test",method=RequestMethod.POST) |
||||
|
@ResponseBody |
||||
|
public void test(@RequestBody CfgDataExtractor object) throws Exception{ |
||||
|
service.test(object); |
||||
|
} |
||||
|
|
||||
|
@RequestMapping(value="generateSample",method=RequestMethod.POST) |
||||
|
@ResponseBody |
||||
|
public void generateSample() throws Exception{ |
||||
|
service.generateSample(); |
||||
|
} |
||||
|
} |
@ -0,0 +1,38 @@ |
|||||
|
package io.sc.engine.mv.controller.core; |
||||
|
|
||||
|
import io.sc.engine.mv.jpa.entity.CoeChiSquareHistory; |
||||
|
import io.sc.engine.mv.jpa.repository.CoeChiSquareHistoryRepository; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.data.domain.Example; |
||||
|
import org.springframework.data.domain.ExampleMatcher; |
||||
|
import org.springframework.data.domain.ExampleMatcher.StringMatcher; |
||||
|
import org.springframework.stereotype.Controller; |
||||
|
import org.springframework.web.bind.annotation.RequestMapping; |
||||
|
import org.springframework.web.bind.annotation.RequestMethod; |
||||
|
import org.springframework.web.bind.annotation.ResponseBody; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
@Controller |
||||
|
@RequestMapping("/mv/coe/chiSquare") |
||||
|
public class ChiSquareWebController { |
||||
|
@Autowired private CoeChiSquareHistoryRepository coeChiSquareHistoryRepository; |
||||
|
|
||||
|
@RequestMapping(value="isc/fetch",method=RequestMethod.GET) |
||||
|
@ResponseBody |
||||
|
public List<CoeChiSquareHistory> iscFetch(CoeChiSquareHistory psiHistory){ |
||||
|
return fetch(psiHistory); |
||||
|
} |
||||
|
|
||||
|
@RequestMapping(value="fetch",method=RequestMethod.GET) |
||||
|
@ResponseBody |
||||
|
public List<CoeChiSquareHistory> fetch(CoeChiSquareHistory history){ |
||||
|
ExampleMatcher matcher = ExampleMatcher.matching() |
||||
|
.withIgnoreNullValues() |
||||
|
.withIgnoreCase() |
||||
|
.withStringMatcher(StringMatcher.CONTAINING); |
||||
|
Example<CoeChiSquareHistory> example = Example.of(history, matcher); |
||||
|
List<CoeChiSquareHistory> result =coeChiSquareHistoryRepository.findAll(example); |
||||
|
return result; |
||||
|
} |
||||
|
} |
@ -0,0 +1,15 @@ |
|||||
|
package io.sc.engine.mv.controller.st; |
||||
|
|
||||
|
import org.springframework.stereotype.Controller; |
||||
|
import org.springframework.web.bind.annotation.RequestMapping; |
||||
|
|
||||
|
@Controller |
||||
|
@RequestMapping("/mv/st") |
||||
|
public class SvdWebController { |
||||
|
/* |
||||
|
@Autowired private GeneralResultHistoryRepository generalResultHistoryRepository; |
||||
|
@Autowired private StPsiHistoryRepository stPsiHistoryRepository; |
||||
|
@Autowired private JdbcTemplate jdbcTemplate; |
||||
|
*/ |
||||
|
|
||||
|
} |
@ -0,0 +1,68 @@ |
|||||
|
package io.sc.engine.mv.controller.st.support; |
||||
|
|
||||
|
import io.sc.engine.mv.jpa.entity.CfgThreshold; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
|
||||
|
public class Threshold2SmartClientJavascript { |
||||
|
public static String getScript(String var,List<CfgThreshold> thresholds){ |
||||
|
return getScript("range",var,thresholds); |
||||
|
} |
||||
|
|
||||
|
public static String getScript(String type,String var,List<CfgThreshold> thresholds){ |
||||
|
StringBuilder sb =new StringBuilder(); |
||||
|
for(int i=0;i<thresholds.size();i++){ |
||||
|
if(i==0){ |
||||
|
sb.append("if("); |
||||
|
}else{ |
||||
|
sb.append("else if("); |
||||
|
} |
||||
|
if("range".equalsIgnoreCase(type)){ |
||||
|
sb.append(parseRangeCondition(var,thresholds.get(i).getRange())); |
||||
|
}else if("quantitativeRange".equalsIgnoreCase(type)){ |
||||
|
sb.append(parseRangeCondition(var,thresholds.get(i).getQuantitativeRange())); |
||||
|
}else if("qualitativeRange".equalsIgnoreCase(type)){ |
||||
|
sb.append(parseRangeCondition(var,thresholds.get(i).getQualitativeRange())); |
||||
|
} |
||||
|
sb.append("){").append("\n"); |
||||
|
sb.append("\treturn 'color:" + thresholds.get(i).getColor()).append(";';\n"); |
||||
|
sb.append("}"); |
||||
|
} |
||||
|
return sb.toString(); |
||||
|
} |
||||
|
|
||||
|
private static String parseRangeCondition(String var,String condition){ |
||||
|
StringBuilder sb =new StringBuilder(); |
||||
|
char left =condition.charAt(0); |
||||
|
char right =condition.charAt(condition.length()-1); |
||||
|
String mid =condition.substring(1,condition.length()-1); |
||||
|
String[] split =mid.split(","); |
||||
|
String leftValue =split[0]; |
||||
|
String rightValue =split[1]; |
||||
|
|
||||
|
if("-".equals(leftValue)){ |
||||
|
|
||||
|
}else{ |
||||
|
if('('==left){ |
||||
|
sb.append(var + ">" + leftValue); |
||||
|
}else if('['==left){ |
||||
|
sb.append(var + ">=" + leftValue); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
if("-".equals(rightValue)){ |
||||
|
|
||||
|
}else{ |
||||
|
if(!"-".equals(leftValue)){ |
||||
|
sb.append(" && "); |
||||
|
} |
||||
|
if(')'==right){ |
||||
|
sb.append(var + "<" + rightValue); |
||||
|
}else if(']'==right){ |
||||
|
sb.append(var + "<=" + rightValue); |
||||
|
} |
||||
|
} |
||||
|
return sb.toString(); |
||||
|
} |
||||
|
} |
@ -0,0 +1,204 @@ |
|||||
|
package io.sc.engine.mv.executor; |
||||
|
|
||||
|
import java.sql.PreparedStatement; |
||||
|
import java.sql.ResultSet; |
||||
|
import java.sql.SQLException; |
||||
|
|
||||
|
import io.sc.engine.mv.CoeResult; |
||||
|
import io.sc.engine.mv.RuntimeContext; |
||||
|
import io.sc.engine.mv.jpa.entity.CfgBinomial; |
||||
|
import io.sc.engine.mv.jpa.repository.CfgBinomialRepository; |
||||
|
import io.sc.platform.core.support.ProgressInfo; |
||||
|
import io.sc.platform.core.util.DateUtil; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.dao.DataAccessException; |
||||
|
import org.springframework.jdbc.core.PreparedStatementSetter; |
||||
|
import org.springframework.jdbc.core.ResultSetExtractor; |
||||
|
import org.springframework.jdbc.core.RowCallbackHandler; |
||||
|
import org.springframework.stereotype.Component; |
||||
|
|
||||
|
@Component |
||||
|
public class CoeBinomialExecutor extends AbstractExecutor{ |
||||
|
private static final int ORDER =3000; |
||||
|
@Autowired private CfgBinomialRepository cfgBinomialRepository; |
||||
|
|
||||
|
@Override |
||||
|
public int getOrder() { |
||||
|
return ORDER; |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public int getExecuteTimeWeight() { |
||||
|
return 10; |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public void execute(RuntimeContext runtimeContext, ProgressInfo progressInfo) { |
||||
|
//初始化合格样本表及合格样本临时表
|
||||
|
initKpi(runtimeContext,progressInfo); |
||||
|
//生成合格样本表
|
||||
|
generateKpi(runtimeContext,progressInfo); |
||||
|
//将合格样本数据保存到历史表
|
||||
|
saveToHistory(runtimeContext,progressInfo); |
||||
|
} |
||||
|
|
||||
|
protected void initKpi(final RuntimeContext runtimeContext,ProgressInfo progressInfo){ |
||||
|
log.info("开始执行初始化指标表..."); |
||||
|
jdbcTemplate.execute("delete from MV_COE_BINOMIAL"); |
||||
|
log.info("完成执行初始化指标表"); |
||||
|
} |
||||
|
|
||||
|
protected void generateKpi(final RuntimeContext runtimeContext,ProgressInfo progressInfo){ |
||||
|
doGenerateKpi(runtimeContext,progressInfo); |
||||
|
} |
||||
|
|
||||
|
private void doGenerateKpi(final RuntimeContext runtimeContext,ProgressInfo progressInfo){ |
||||
|
CfgBinomial cfgBinomial =cfgBinomialRepository.findBySignificanceLevel(runtimeContext.getBinomialSignificanceLevel()); |
||||
|
String sql ="" |
||||
|
+ " insert into MV_COE_BINOMIAL(" |
||||
|
+ " FD_MODEL_ID," |
||||
|
+ " FD_MODEL_NAME," |
||||
|
+ " FD_LEVEL," |
||||
|
+ " FD_PD," |
||||
|
+ " FD_COUNT," |
||||
|
+ " FD_DEFAULT_COUNT," |
||||
|
+ " FD_SL," |
||||
|
+ " FD_CL," |
||||
|
+ " FD_Z_UPPER," |
||||
|
+ " FD_Z_LOWER" |
||||
|
+ " )" |
||||
|
+ " select " |
||||
|
+ " FD_MODEL_ID," |
||||
|
+ " FD_MODEL_NAME," |
||||
|
+ " FD_LEVEL," |
||||
|
+ " FD_PD," |
||||
|
+ " FD_COUNT," |
||||
|
+ " FD_DEFAULT_COUNT," |
||||
|
+ " " + cfgBinomial.getSignificanceLevel() + "," |
||||
|
+ " " + cfgBinomial.getConfidenceLevel() + "," |
||||
|
+ " " + cfgBinomial.getzUpper() + "," |
||||
|
+ " " + cfgBinomial.getzLower() + "" |
||||
|
+ " from MV_COE_CHI_SQUARE"; |
||||
|
jdbcTemplate.execute(sql); |
||||
|
|
||||
|
jdbcTemplate.execute("update MV_COE_BINOMIAL set FD_ND_AVG=FD_PD*FD_COUNT"); |
||||
|
jdbcTemplate.execute("update MV_COE_BINOMIAL set FD_ND_SD=SQRT(FD_PD*FD_COUNT*(1-FD_PD))"); |
||||
|
jdbcTemplate.execute("update MV_COE_BINOMIAL set FD_D_UPPER=FD_Z_UPPER*FD_ND_SD+FD_ND_AVG"); |
||||
|
jdbcTemplate.execute("update MV_COE_BINOMIAL set FD_D_LOWER=FD_Z_LOWER*FD_ND_SD+FD_ND_AVG"); |
||||
|
jdbcTemplate.execute("update MV_COE_BINOMIAL set FD_LE_UPPER=0"); |
||||
|
jdbcTemplate.execute("update MV_COE_BINOMIAL set FD_LE_UPPER=1 where FD_DEFAULT_COUNT<=FD_D_UPPER"); |
||||
|
jdbcTemplate.execute("update MV_COE_BINOMIAL set FD_GE_LOWER=0"); |
||||
|
jdbcTemplate.execute("update MV_COE_BINOMIAL set FD_GE_LOWER=1 where FD_DEFAULT_COUNT>=FD_D_LOWER"); |
||||
|
|
||||
|
//更新模型验证结果表
|
||||
|
sql ="select FD_MODEL_ID,max(FD_MODEL_NAME) FD_MODEL_NAME from MV_COE_BINOMIAL group by FD_MODEL_ID"; |
||||
|
jdbcTemplate.query(sql, new RowCallbackHandler() { |
||||
|
@Override |
||||
|
public void processRow(ResultSet rs) throws SQLException { |
||||
|
String modelId =rs.getString("FD_MODEL_ID"); |
||||
|
String modelName =rs.getString("FD_MODEL_NAME"); |
||||
|
CoeResult result =pass(modelId); |
||||
|
//更新模型验证结果表
|
||||
|
int updated =jdbcTemplate.update("update MV_GENERAL_RESULT set FD_COE_BINOMIAL=? where FD_MODEL_ID=?", result.toString(),modelId); |
||||
|
if(updated==0){ |
||||
|
jdbcTemplate.update("insert into MV_GENERAL_RESULT(FD_MODEL_ID,FD_MODEL_NAME,FD_COE_BINOMIAL) values(?,?,?)", modelId,modelName,result.toString()); |
||||
|
} |
||||
|
} |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
private CoeResult pass(String modelId){ |
||||
|
String sql ="select count(*) FD_COUNT,sum(FD_LE_UPPER) FD_SUM from MV_COE_BINOMIAL where FD_MODEL_ID='" + modelId + "'"; |
||||
|
CoeResult result =jdbcTemplate.query(sql,new ResultSetExtractor<CoeResult>() { |
||||
|
@Override |
||||
|
public CoeResult extractData(ResultSet rs) throws SQLException, DataAccessException { |
||||
|
if(rs.next()){ |
||||
|
long count =rs.getLong("FD_COUNT"); |
||||
|
long sum =rs.getLong("FD_SUM"); |
||||
|
if(count==sum){ |
||||
|
return CoeResult.PASS; |
||||
|
} |
||||
|
} |
||||
|
return CoeResult.NOT_PASS; |
||||
|
} |
||||
|
}); |
||||
|
if(CoeResult.NOT_PASS.equals(result)){ |
||||
|
return result; |
||||
|
}else{ |
||||
|
sql ="select count(*) FD_COUNT,sum(FD_GE_LOWER) FD_SUM from MV_COE_BINOMIAL where FD_MODEL_ID='" + modelId + "'"; |
||||
|
result =jdbcTemplate.query(sql,new ResultSetExtractor<CoeResult>() { |
||||
|
@Override |
||||
|
public CoeResult extractData(ResultSet rs) throws SQLException, DataAccessException { |
||||
|
if(rs.next()){ |
||||
|
long count =rs.getLong("FD_COUNT"); |
||||
|
long sum =rs.getLong("FD_SUM"); |
||||
|
if(count==sum){ |
||||
|
return CoeResult.PASS; |
||||
|
} |
||||
|
} |
||||
|
return CoeResult.NOT_PASS; |
||||
|
} |
||||
|
}); |
||||
|
} |
||||
|
return result; |
||||
|
} |
||||
|
|
||||
|
protected void saveToHistory(final RuntimeContext runtimeContext,ProgressInfo progressInfo){ |
||||
|
log.info("开始将计算并生成指标表数据保存到历史表中..."); |
||||
|
final String runtimeDateString = DateUtil.formatDate(runtimeContext.getValidateDate(), DateUtil.yyyy_MM_dd_HH_mm_ss); |
||||
|
String sql ="delete from MV_COE_BINOMIAL_HIS where FD_VALIDATE_DATE=?"; |
||||
|
jdbcTemplate.update(sql, new PreparedStatementSetter() { |
||||
|
@Override |
||||
|
public void setValues(PreparedStatement pstmt) throws SQLException { |
||||
|
pstmt.setObject(1, runtimeDateString); |
||||
|
} |
||||
|
}); |
||||
|
sql = "" |
||||
|
+ " insert into MV_COE_BINOMIAL_HIS (" |
||||
|
+ " FD_VALIDATE_DATE," |
||||
|
+ " FD_MODEL_ID," |
||||
|
+ " FD_MODEL_NAME," |
||||
|
+ " FD_LEVEL," |
||||
|
+ " FD_PD," |
||||
|
+ " FD_COUNT," |
||||
|
+ " FD_DEFAULT_COUNT," |
||||
|
+ " FD_ND_AVG," |
||||
|
+ " FD_ND_SD," |
||||
|
+ " FD_SL," |
||||
|
+ " FD_CL," |
||||
|
+ " FD_Z_UPPER," |
||||
|
+ " FD_Z_LOWER," |
||||
|
+ " FD_D_UPPER," |
||||
|
+ " FD_D_LOWER," |
||||
|
+ " FD_LE_UPPER," |
||||
|
+ " FD_GE_LOWER" |
||||
|
+ " )" |
||||
|
+ " select " |
||||
|
+ " ?," |
||||
|
+ " FD_MODEL_ID," |
||||
|
+ " FD_MODEL_NAME," |
||||
|
+ " FD_LEVEL," |
||||
|
+ " FD_PD," |
||||
|
+ " FD_COUNT," |
||||
|
+ " FD_DEFAULT_COUNT," |
||||
|
+ " FD_ND_AVG," |
||||
|
+ " FD_ND_SD," |
||||
|
+ " FD_SL," |
||||
|
+ " FD_CL," |
||||
|
+ " FD_Z_UPPER," |
||||
|
+ " FD_Z_LOWER," |
||||
|
+ " FD_D_UPPER," |
||||
|
+ " FD_D_LOWER," |
||||
|
+ " FD_LE_UPPER," |
||||
|
+ " FD_GE_LOWER" |
||||
|
+ " from MV_COE_BINOMIAL"; |
||||
|
|
||||
|
jdbcTemplate.update(sql, new PreparedStatementSetter() { |
||||
|
@Override |
||||
|
public void setValues(PreparedStatement pstmt) throws SQLException { |
||||
|
pstmt.setObject(1, runtimeDateString); |
||||
|
} |
||||
|
}); |
||||
|
log.info("完成将计算并生成指标表数据保存到历史表中"); |
||||
|
} |
||||
|
} |
@ -0,0 +1,253 @@ |
|||||
|
package io.sc.engine.mv.executor; |
||||
|
|
||||
|
import io.sc.engine.mv.CoeResult; |
||||
|
import io.sc.engine.mv.RuntimeContext; |
||||
|
import io.sc.engine.mv.executor.support.ExecutorUtil; |
||||
|
import io.sc.engine.mv.jpa.entity.CfgChiSquare; |
||||
|
import io.sc.engine.mv.jpa.entity.CfgScale; |
||||
|
import io.sc.engine.mv.jpa.repository.CfgChiSquareRepository; |
||||
|
import io.sc.engine.mv.jpa.repository.CfgScaleRepository; |
||||
|
import io.sc.platform.core.support.ProgressInfo; |
||||
|
import io.sc.platform.core.util.DateUtil; |
||||
|
import io.sc.platform.jdbc.util.SqlBatcher; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.dao.DataAccessException; |
||||
|
import org.springframework.jdbc.core.PreparedStatementSetter; |
||||
|
import org.springframework.jdbc.core.ResultSetExtractor; |
||||
|
import org.springframework.jdbc.core.RowCallbackHandler; |
||||
|
import org.springframework.jdbc.core.RowMapper; |
||||
|
import org.springframework.stereotype.Component; |
||||
|
|
||||
|
import java.sql.PreparedStatement; |
||||
|
import java.sql.ResultSet; |
||||
|
import java.sql.SQLException; |
||||
|
import java.util.List; |
||||
|
import java.util.Map; |
||||
|
|
||||
|
@Component |
||||
|
public class CoeChiSquareExecutor extends AbstractExecutor{ |
||||
|
private static final int ORDER =2000; |
||||
|
@Autowired private CfgScaleRepository scaleRepository; |
||||
|
@Autowired private CfgChiSquareRepository chiSquareRepository; |
||||
|
|
||||
|
@Override |
||||
|
public int getOrder() { |
||||
|
return ORDER; |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public int getExecuteTimeWeight() { |
||||
|
return 10; |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public void execute(RuntimeContext runtimeContext, ProgressInfo progressInfo) { |
||||
|
//初始化合格样本表及合格样本临时表
|
||||
|
initKpi(runtimeContext,progressInfo); |
||||
|
//生成合格样本表
|
||||
|
generateKpi(runtimeContext,progressInfo); |
||||
|
//将合格样本数据保存到历史表
|
||||
|
saveToHistory(runtimeContext,progressInfo); |
||||
|
} |
||||
|
|
||||
|
protected void initKpi(final RuntimeContext runtimeContext,ProgressInfo progressInfo){ |
||||
|
log.info("开始执行初始化指标表..."); |
||||
|
jdbcTemplate.execute("delete from MV_COE_CHI_SQUARE"); |
||||
|
log.info("完成执行初始化指标表"); |
||||
|
} |
||||
|
|
||||
|
protected void generateKpi(final RuntimeContext runtimeContext,ProgressInfo progressInfo){ |
||||
|
initScale(runtimeContext,progressInfo); |
||||
|
doGenerateKpi(runtimeContext,progressInfo); |
||||
|
calChiSquare(runtimeContext,progressInfo); |
||||
|
} |
||||
|
|
||||
|
private void initScale(final RuntimeContext runtimeContext,ProgressInfo progressInfo){ |
||||
|
final SqlBatcher sqlBatcher =new SqlBatcher("" |
||||
|
+ " insert into MV_COE_CHI_SQUARE(" |
||||
|
+ " FD_MODEL_ID," |
||||
|
+ " FD_MODEL_NAME," |
||||
|
+ " FD_LEVEL," |
||||
|
+ " FD_PD" |
||||
|
+ " ) values (?,?,?,?)" |
||||
|
); |
||||
|
Map<String,String> models = ExecutorUtil.getAllModels(jdbcTemplate); |
||||
|
if(models!=null && models.size()>0){ |
||||
|
for(String key : models.keySet()){ |
||||
|
String modelId =key; |
||||
|
String modelName =models.get(key); |
||||
|
List<CfgScale> scales =getScaleConfiguration(modelId); |
||||
|
if(scales!=null && scales.size()>0){ |
||||
|
for(CfgScale scale : scales){ |
||||
|
sqlBatcher.addArg(new Object[]{ |
||||
|
modelId, |
||||
|
modelName, |
||||
|
scale.getLevel(), |
||||
|
scale.getPd() |
||||
|
}); |
||||
|
} |
||||
|
sqlBatcher.execute(jdbcTemplate); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
private List<CfgScale> getScaleConfiguration(String modelId){ |
||||
|
List<CfgScale> result =scaleRepository.findByModelIdOrderByOrder(modelId); |
||||
|
if(result==null || result.size()==0){ |
||||
|
result =scaleRepository.findByNullModelIdOrderByOrder(); |
||||
|
} |
||||
|
return result; |
||||
|
} |
||||
|
|
||||
|
private void doGenerateKpi(final RuntimeContext runtimeContext,ProgressInfo progressInfo){ |
||||
|
final SqlBatcher sqlBatcher =new SqlBatcher("" |
||||
|
+ " update MV_COE_CHI_SQUARE" |
||||
|
+ " set" |
||||
|
+ " FD_COUNT=?," |
||||
|
+ " FD_DEFAULT_COUNT=?," |
||||
|
+ " FD_CHI_SQUARE=?" |
||||
|
+ " where" |
||||
|
+ " FD_MODEL_ID=?" |
||||
|
+ " and FD_LEVEL=?" |
||||
|
); |
||||
|
List<CfgScale> scales =getAllScale(); |
||||
|
if(scales!=null && scales.size()>0){ |
||||
|
for(CfgScale scale : scales){ |
||||
|
double e =scale.getPd(); //E
|
||||
|
long f =getCount(scale); //F
|
||||
|
long g =getDefaultCount(scale); //G
|
||||
|
|
||||
|
double chiSquare =0; |
||||
|
if(e!=0 && e!=1 && f!=0){ |
||||
|
chiSquare =(f*e-g)*(f*e-g)/(f*e*(1-e)); |
||||
|
} |
||||
|
sqlBatcher.addArg(new Object[]{getCount(scale),getDefaultCount(scale),chiSquare,scale.getModelId(),scale.getLevel()}); |
||||
|
} |
||||
|
sqlBatcher.execute(jdbcTemplate); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
private List<CfgScale> getAllScale(){ |
||||
|
String sql ="select FD_MODEL_ID,FD_LEVEL,FD_PD from MV_COE_CHI_SQUARE order by FD_MODEL_ID,FD_LEVEL"; |
||||
|
return jdbcTemplate.query(sql, new RowMapper<CfgScale>() { |
||||
|
@Override |
||||
|
public CfgScale mapRow(ResultSet rs, int rowNum) throws SQLException { |
||||
|
CfgScale scale =new CfgScale(); |
||||
|
scale.setModelId(rs.getString("FD_MODEL_ID")); |
||||
|
scale.setLevel(rs.getString("FD_LEVEL")); |
||||
|
scale.setPd(rs.getDouble("FD_PD")); |
||||
|
return scale; |
||||
|
} |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
private Long getCount(final CfgScale scale){ |
||||
|
String sql ="select count(*) from MV_GENERAL_SAMPLE where FD_MODEL_ID=? and FD_LEVEL=?"; |
||||
|
return jdbcTemplate.query(sql,new PreparedStatementSetter() { |
||||
|
@Override |
||||
|
public void setValues(PreparedStatement ps) throws SQLException { |
||||
|
ps.setString(1, scale.getModelId()); |
||||
|
ps.setString(2, scale.getLevel()); |
||||
|
} |
||||
|
},new ResultSetExtractor<Long>() { |
||||
|
@Override |
||||
|
public Long extractData(ResultSet rs) throws SQLException, DataAccessException { |
||||
|
if(rs.next()){ |
||||
|
return rs.getLong(1); |
||||
|
} |
||||
|
return 0L; |
||||
|
} |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
private Long getDefaultCount(final CfgScale scale){ |
||||
|
String sql ="select count(*) from MV_GENERAL_SAMPLE where FD_MODEL_ID=? and FD_LEVEL=? and FD_DEFAULT_STATUS='D'"; |
||||
|
return jdbcTemplate.query(sql,new PreparedStatementSetter() { |
||||
|
@Override |
||||
|
public void setValues(PreparedStatement ps) throws SQLException { |
||||
|
ps.setString(1, scale.getModelId()); |
||||
|
ps.setString(2, scale.getLevel()); |
||||
|
} |
||||
|
},new ResultSetExtractor<Long>() { |
||||
|
@Override |
||||
|
public Long extractData(ResultSet rs) throws SQLException, DataAccessException { |
||||
|
if(rs.next()){ |
||||
|
return rs.getLong(1); |
||||
|
} |
||||
|
return 0L; |
||||
|
} |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
private void calChiSquare(final RuntimeContext runtimeContext,ProgressInfo progressInfo){ |
||||
|
String sql ="select FD_MODEL_ID,max(FD_MODEL_NAME) FD_MODEL_NAME,sum(FD_CHI_SQUARE) FD_CHI_SQUARE from MV_COE_CHI_SQUARE group by FD_MODEL_ID"; |
||||
|
jdbcTemplate.query(sql, new RowCallbackHandler() { |
||||
|
@Override |
||||
|
public void processRow(ResultSet rs) throws SQLException { |
||||
|
String modelId =rs.getString("FD_MODEL_ID"); |
||||
|
String modelName =rs.getString("FD_MODEL_NAME"); |
||||
|
double chiSquare =rs.getDouble("FD_CHI_SQUARE"); |
||||
|
|
||||
|
double criticalValue =0; |
||||
|
List<CfgScale> scales =getScaleConfiguration(modelId); |
||||
|
if(scales!=null && scales.size()>0){ |
||||
|
CfgChiSquare cfg =chiSquareRepository.findByDofAndSignificanceLevel(scales.size(),runtimeContext.getChiSquareSignificanceLevel()); |
||||
|
if(cfg!=null){ |
||||
|
criticalValue =cfg.getCriticalValue(); |
||||
|
} |
||||
|
} |
||||
|
String chiSquareStr = CoeResult.PASS.toString(); |
||||
|
if(chiSquare>criticalValue){ |
||||
|
chiSquareStr =CoeResult.NOT_PASS.toString(); |
||||
|
} |
||||
|
//更新模型验证结果表
|
||||
|
int updated =jdbcTemplate.update("update MV_GENERAL_RESULT set FD_COE_CHI_SQUARE=? where FD_MODEL_ID=?", chiSquareStr,modelId); |
||||
|
if(updated==0){ |
||||
|
jdbcTemplate.update("insert into MV_GENERAL_RESULT(FD_MODEL_ID,FD_MODEL_NAME,FD_COE_CHI_SQUARE) values(?,?,?)", modelId,modelName,chiSquareStr); |
||||
|
} |
||||
|
} |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
protected void saveToHistory(final RuntimeContext runtimeContext,ProgressInfo progressInfo){ |
||||
|
log.info("开始将计算并生成指标表数据保存到历史表中..."); |
||||
|
final String runtimeDateString = DateUtil.formatDate(runtimeContext.getValidateDate(), DateUtil.yyyy_MM_dd_HH_mm_ss); |
||||
|
String sql ="delete from MV_COE_CHI_SQUARE_HIS where FD_VALIDATE_DATE=?"; |
||||
|
jdbcTemplate.update(sql, new PreparedStatementSetter() { |
||||
|
@Override |
||||
|
public void setValues(PreparedStatement pstmt) throws SQLException { |
||||
|
pstmt.setObject(1, runtimeDateString); |
||||
|
} |
||||
|
}); |
||||
|
sql = "" |
||||
|
+ " insert into MV_COE_CHI_SQUARE_HIS (" |
||||
|
+ " FD_VALIDATE_DATE," |
||||
|
+ " FD_MODEL_ID," |
||||
|
+ " FD_MODEL_NAME," |
||||
|
+ " FD_LEVEL," |
||||
|
+ " FD_PD," |
||||
|
+ " FD_COUNT," |
||||
|
+ " FD_DEFAULT_COUNT," |
||||
|
+ " FD_CHI_SQUARE" |
||||
|
+ " )" |
||||
|
+ " select " |
||||
|
+ " ?," |
||||
|
+ " FD_MODEL_ID," |
||||
|
+ " FD_MODEL_NAME," |
||||
|
+ " FD_LEVEL," |
||||
|
+ " FD_PD," |
||||
|
+ " FD_COUNT," |
||||
|
+ " FD_DEFAULT_COUNT," |
||||
|
+ " FD_CHI_SQUARE" |
||||
|
+ " from MV_COE_CHI_SQUARE"; |
||||
|
|
||||
|
jdbcTemplate.update(sql, new PreparedStatementSetter() { |
||||
|
@Override |
||||
|
public void setValues(PreparedStatement pstmt) throws SQLException { |
||||
|
pstmt.setObject(1, runtimeDateString); |
||||
|
} |
||||
|
}); |
||||
|
log.info("完成将计算并生成指标表数据保存到历史表中"); |
||||
|
} |
||||
|
} |
@ -0,0 +1,57 @@ |
|||||
|
package io.sc.engine.mv.executor; |
||||
|
|
||||
|
import java.sql.SQLException; |
||||
|
|
||||
|
import javax.sql.DataSource; |
||||
|
|
||||
|
import io.sc.engine.mv.RuntimeContext; |
||||
|
import io.sc.platform.core.support.ProgressInfo; |
||||
|
import io.sc.platform.jdbc.DatabaseType; |
||||
|
import org.springframework.jdbc.datasource.DataSourceUtils; |
||||
|
import org.springframework.stereotype.Component; |
||||
|
import org.springframework.util.StringUtils; |
||||
|
|
||||
|
/** |
||||
|
* 数据库初始化操作 |
||||
|
* 通常用于优化数据的性能 |
||||
|
* @author wangshaoping |
||||
|
* |
||||
|
*/ |
||||
|
@Component |
||||
|
public class DatabaseInitExecutor extends AbstractExecutor{ |
||||
|
private static final int ORDER =-1000; |
||||
|
|
||||
|
@Override |
||||
|
public int getOrder() { |
||||
|
return ORDER; |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public int getExecuteTimeWeight() { |
||||
|
return 10; |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public void execute(RuntimeContext runtimeContext, ProgressInfo progressInfo) { |
||||
|
log.info("开始执行数据库初始化..."); |
||||
|
//initDatabase();
|
||||
|
log.info("完成执行数据库初始化"); |
||||
|
} |
||||
|
|
||||
|
protected void initDatabase(){ |
||||
|
String databaseType = DatabaseType.getDatabaseType(jdbcTemplate.getDataSource()); |
||||
|
if(databaseType!=null && databaseType.contains("derby")){ |
||||
|
try { |
||||
|
DataSource ds =jdbcTemplate.getDataSource(); |
||||
|
if(ds!=null) { |
||||
|
String schema =DataSourceUtils.getConnection(ds).getSchema(); |
||||
|
if(StringUtils.hasText(schema)) { |
||||
|
jdbcTemplate.execute("call SYSCS_UTIL.SYSCS_UPDATE_STATISTICS('" + schema + "','',null)"); |
||||
|
} |
||||
|
} |
||||
|
} catch (SQLException e) { |
||||
|
log.error("",e); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
@ -0,0 +1,285 @@ |
|||||
|
package io.sc.engine.mv.executor; |
||||
|
|
||||
|
import java.sql.PreparedStatement; |
||||
|
import java.sql.ResultSet; |
||||
|
import java.sql.SQLException; |
||||
|
|
||||
|
import io.sc.engine.mv.RuntimeContext; |
||||
|
import io.sc.platform.core.support.ProgressInfo; |
||||
|
import io.sc.platform.core.util.DateUtil; |
||||
|
import org.springframework.dao.DataAccessException; |
||||
|
import org.springframework.jdbc.core.PreparedStatementSetter; |
||||
|
import org.springframework.jdbc.core.ResultSetExtractor; |
||||
|
import org.springframework.jdbc.core.RowCallbackHandler; |
||||
|
import org.springframework.stereotype.Component; |
||||
|
|
||||
|
/** |
||||
|
* 模型稳定性 PSI 验证执行器 |
||||
|
* @author wangshaoping |
||||
|
* |
||||
|
*/ |
||||
|
@Component |
||||
|
public class StPsiExecutor extends AbstractExecutor{ |
||||
|
protected static final int ORDER =1000; |
||||
|
|
||||
|
@Override |
||||
|
public int getOrder() { |
||||
|
return ORDER; |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public int getExecuteTimeWeight() { |
||||
|
return 10; |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public void execute(RuntimeContext runtimeContext, ProgressInfo progressInfo) { |
||||
|
if(checkDistributionConfiguration()){ |
||||
|
//初始化指标表
|
||||
|
initKpi(runtimeContext); |
||||
|
|
||||
|
//计算并生成指标表数据
|
||||
|
generateKpi(runtimeContext); |
||||
|
|
||||
|
//计算 PSI 值,并更新到模型验证结果表中
|
||||
|
calPsi(runtimeContext); |
||||
|
|
||||
|
//将计算并生成指标表数据保存到历史表中
|
||||
|
saveToHistory(runtimeContext); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 删除指标表历史数据 |
||||
|
* @param runtimeContext 执行上下文 |
||||
|
*/ |
||||
|
protected void initKpi(final RuntimeContext runtimeContext){ |
||||
|
log.info("开始执行初始化指标表..."); |
||||
|
jdbcTemplate.execute("delete from MV_ST_PSI"); |
||||
|
log.info("完成执行初始化指标表"); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 计算并生成指标表 |
||||
|
* @param runtimeContext 执行上下文 |
||||
|
*/ |
||||
|
protected void generateKpi(final RuntimeContext runtimeContext){ |
||||
|
log.info("开始执行计算并生成指标表数据..."); |
||||
|
//根据咨询建模时分数段初始化指标表
|
||||
|
String sql ="" |
||||
|
+ " select " |
||||
|
+ " FD_MODEL_ID," |
||||
|
+ " FD_MODEL_NAME," |
||||
|
+ " FD_SCORE_SEG_START," |
||||
|
+ " FD_SCORE_SEG_END," |
||||
|
+ " FD_COUNT FD_COUNT_DEV" |
||||
|
+ " from MV_CFG_DISTRIBUTION"; |
||||
|
jdbcTemplate.query(sql, new RowCallbackHandler() { |
||||
|
@Override |
||||
|
public void processRow(ResultSet rs) throws SQLException { |
||||
|
String countAppSql ="" |
||||
|
+ " select" |
||||
|
+ " count(*) FD_COUNT_APP" |
||||
|
+ " from MV_GENERAL_SAMPLE" |
||||
|
+ " where" |
||||
|
+ " FD_MODEL_ID='" + rs.getString("FD_MODEL_ID") + "'" |
||||
|
+ " and FD_SCORE>=" + rs.getDouble("FD_SCORE_SEG_START") |
||||
|
+ " and FD_SCORE<=" + rs.getDouble("FD_SCORE_SEG_END"); |
||||
|
Long countApp =jdbcTemplate.query(countAppSql,new ResultSetExtractor<Long>(){ |
||||
|
@Override |
||||
|
public Long extractData(ResultSet rs) throws SQLException, DataAccessException { |
||||
|
if(rs.next()){ |
||||
|
return rs.getLong("FD_COUNT_APP"); |
||||
|
}else{ |
||||
|
return 0L; |
||||
|
} |
||||
|
} |
||||
|
}); |
||||
|
String sqlInsert ="" |
||||
|
+ " insert into MV_ST_PSI(" |
||||
|
+ " FD_MODEL_ID," |
||||
|
+ " FD_MODEL_NAME," |
||||
|
+ " FD_SCORE_SEG_START," |
||||
|
+ " FD_SCORE_SEG_END," |
||||
|
+ " FD_COUNT_DEV," |
||||
|
+ " FD_COUNT_APP" |
||||
|
+ " ) values (" |
||||
|
+ " '" + rs.getString("FD_MODEL_ID") + "'," |
||||
|
+ " '" + rs.getString("FD_MODEL_NAME") + "'," |
||||
|
+ " " + rs.getDouble("FD_SCORE_SEG_START") + "," |
||||
|
+ " " + rs.getDouble("FD_SCORE_SEG_END") + "," |
||||
|
+ " " + rs.getInt("FD_COUNT_DEV") + "," |
||||
|
+ " " + countApp |
||||
|
+ ")"; |
||||
|
jdbcTemplate.update(sqlInsert); |
||||
|
} |
||||
|
}); |
||||
|
|
||||
|
sql ="select FD_MODEL_ID from MV_CFG_DISTRIBUTION group by FD_MODEL_ID"; |
||||
|
jdbcTemplate.query(sql, new RowCallbackHandler() { |
||||
|
@Override |
||||
|
public void processRow(ResultSet rs) throws SQLException { |
||||
|
String modelId =rs.getString("FD_MODEL_ID"); |
||||
|
String totalCountDevSql ="select sum(FD_COUNT_DEV) FD_TOTAL_COUNT_DEV from MV_ST_PSI where FD_MODEL_ID='" + modelId + "'"; |
||||
|
Long totalCountDev =jdbcTemplate.query(totalCountDevSql,new ResultSetExtractor<Long>(){ |
||||
|
@Override |
||||
|
public Long extractData(ResultSet rs) throws SQLException, DataAccessException { |
||||
|
if(rs.next()){ |
||||
|
return rs.getLong("FD_TOTAL_COUNT_DEV"); |
||||
|
}else{ |
||||
|
return 0L; |
||||
|
} |
||||
|
} |
||||
|
}); |
||||
|
String totalCountAppSql ="select sum(FD_COUNT_APP) FD_TOTAL_COUNT_APP from MV_ST_PSI where FD_MODEL_ID='" + modelId + "'"; |
||||
|
Long totalCountApp =jdbcTemplate.query(totalCountAppSql,new ResultSetExtractor<Long>(){ |
||||
|
@Override |
||||
|
public Long extractData(ResultSet rs) throws SQLException, DataAccessException { |
||||
|
if(rs.next()){ |
||||
|
return rs.getLong("FD_TOTAL_COUNT_APP"); |
||||
|
}else{ |
||||
|
return 0L; |
||||
|
} |
||||
|
} |
||||
|
}); |
||||
|
String updateSql ="update MV_ST_PSI set FD_TOTAL_COUNT_DEV=" + totalCountDev + ",FD_TOTAL_COUNT_APP=" + totalCountApp + " where FD_MODEL_ID='" + modelId + "'"; |
||||
|
jdbcTemplate.update(updateSql); |
||||
|
} |
||||
|
}); |
||||
|
//计算分数段内申请人数占群体总人数百分比(咨询建模时)
|
||||
|
jdbcTemplate.update("update MV_ST_PSI set FD_COUNT_DEV=0 where FD_COUNT_DEV is null"); |
||||
|
jdbcTemplate.update("update MV_ST_PSI set FD_TOTAL_COUNT_DEV=0 where FD_TOTAL_COUNT_DEV is null"); |
||||
|
jdbcTemplate.update("update MV_ST_PSI set FD_PERCENT_DEV=0 where FD_TOTAL_COUNT_DEV=0"); |
||||
|
jdbcTemplate.update("update MV_ST_PSI set FD_PERCENT_DEV=(FD_COUNT_DEV*1.000000/FD_TOTAL_COUNT_DEV) where FD_TOTAL_COUNT_DEV<>0"); |
||||
|
|
||||
|
//计算分数段内申请人数占群体总人数百分比(模型应用时)
|
||||
|
jdbcTemplate.update("update MV_ST_PSI set FD_COUNT_APP=0 where FD_COUNT_APP is null"); |
||||
|
jdbcTemplate.update("update MV_ST_PSI set FD_TOTAL_COUNT_APP=0 where FD_TOTAL_COUNT_APP is null"); |
||||
|
jdbcTemplate.update("update MV_ST_PSI set FD_PERCENT_APP=0 where FD_TOTAL_COUNT_APP=0"); |
||||
|
jdbcTemplate.update("update MV_ST_PSI set FD_PERCENT_APP=(FD_COUNT_APP*1.000000/FD_TOTAL_COUNT_APP) where FD_TOTAL_COUNT_APP<>0"); |
||||
|
|
||||
|
//计算百分比变化
|
||||
|
jdbcTemplate.update("update MV_ST_PSI set FD_PERCENT_DIFF=(FD_PERCENT_APP-FD_PERCENT_DEV)"); |
||||
|
//计算百分比相对比例
|
||||
|
jdbcTemplate.update("update MV_ST_PSI set FD_PERCENT_RATE=0 where FD_PERCENT_DEV=0"); |
||||
|
jdbcTemplate.update("update MV_ST_PSI set FD_PERCENT_RATE=(FD_PERCENT_APP*1.000000/FD_PERCENT_DEV) where FD_PERCENT_DEV<>0"); |
||||
|
//计算加权系数
|
||||
|
jdbcTemplate.update("update MV_ST_PSI set FD_WEIGHT=0 where FD_PERCENT_RATE=0"); |
||||
|
jdbcTemplate.update("update MV_ST_PSI set FD_WEIGHT=ln(FD_PERCENT_RATE) where FD_PERCENT_RATE>0"); |
||||
|
//计算稳定性加权
|
||||
|
jdbcTemplate.update("update MV_ST_PSI set FD_ST_WEIGHT=(FD_WEIGHT*FD_PERCENT_DIFF)"); |
||||
|
log.info("完成执行计算并生成指标表数据..."); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 计算 PSI 值,并更新到模型验证结果表中 |
||||
|
* @param runtimeContext 执行上下文 |
||||
|
*/ |
||||
|
protected void calPsi(final RuntimeContext runtimeContext){ |
||||
|
log.info("开始计算 PSI 值,并更新到模型验证结果表中..."); |
||||
|
String sql ="" |
||||
|
+ " select" |
||||
|
+ " FD_MODEL_ID" |
||||
|
+ " ,max(FD_MODEL_NAME) as FD_MODEL_NAME" |
||||
|
+ " ,sum(FD_ST_WEIGHT) as PSI" |
||||
|
+ " from MV_ST_PSI" |
||||
|
+ " group by FD_MODEL_ID"; |
||||
|
jdbcTemplate.query(sql, new RowCallbackHandler() { |
||||
|
@Override |
||||
|
public void processRow(ResultSet rs) throws SQLException { |
||||
|
final String modelId = rs.getString("FD_MODEL_ID"); |
||||
|
final String modelName = rs.getString("FD_MODEL_NAME"); |
||||
|
//更新模型验证结果表
|
||||
|
//更新模型验证结果表
|
||||
|
int updated =jdbcTemplate.update("update MV_GENERAL_RESULT set FD_ST_PSI=? where FD_MODEL_ID=?", rs.getDouble("PSI"),modelId); |
||||
|
if(updated==0){ |
||||
|
jdbcTemplate.update("insert into MV_GENERAL_RESULT(FD_MODEL_ID,FD_MODEL_NAME,FD_ST_PSI) values(?,?,?)", modelId,modelName,rs.getDouble("PSI")); |
||||
|
} |
||||
|
} |
||||
|
}); |
||||
|
log.info("完成计算 PSI 值,并更新到模型验证结果表中..."); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 将计算并生成指标表数据保存到历史表中 |
||||
|
* @param runtimeContext 执行上下文 |
||||
|
*/ |
||||
|
protected void saveToHistory(final RuntimeContext runtimeContext){ |
||||
|
log.info("开始将计算并生成指标表数据保存到历史表中..."); |
||||
|
final String runtimeDateString = DateUtil.formatDate(runtimeContext.getValidateDate(), DateUtil.yyyy_MM_dd_HH_mm_ss); |
||||
|
String sql ="delete from MV_ST_PSI_HIS where FD_VALIDATE_DATE=?"; |
||||
|
jdbcTemplate.update(sql, new PreparedStatementSetter() { |
||||
|
@Override |
||||
|
public void setValues(PreparedStatement pstmt) throws SQLException { |
||||
|
pstmt.setObject(1, runtimeDateString); |
||||
|
} |
||||
|
}); |
||||
|
sql = "" |
||||
|
+ " insert into MV_ST_PSI_HIS (" |
||||
|
+ " FD_VALIDATE_DATE," |
||||
|
+ " FD_MODEL_ID," |
||||
|
+ " FD_MODEL_NAME," |
||||
|
+ " FD_SCORE_SEG_START," |
||||
|
+ " FD_SCORE_SEG_END," |
||||
|
+ " FD_COUNT_DEV," |
||||
|
+ " FD_TOTAL_COUNT_DEV," |
||||
|
+ " FD_PERCENT_DEV," |
||||
|
+ " FD_COUNT_APP," |
||||
|
+ " FD_TOTAL_COUNT_APP," |
||||
|
+ " FD_PERCENT_APP," |
||||
|
+ " FD_PERCENT_DIFF," |
||||
|
+ " FD_PERCENT_RATE," |
||||
|
+ " FD_WEIGHT," |
||||
|
+ " FD_ST_WEIGHT" |
||||
|
+ " )" |
||||
|
+ " select " |
||||
|
+ " ?," |
||||
|
+ " FD_MODEL_ID," |
||||
|
+ " FD_MODEL_NAME," |
||||
|
+ " FD_SCORE_SEG_START," |
||||
|
+ " FD_SCORE_SEG_END," |
||||
|
+ " FD_COUNT_DEV," |
||||
|
+ " FD_TOTAL_COUNT_DEV," |
||||
|
+ " FD_PERCENT_DEV," |
||||
|
+ " FD_COUNT_APP," |
||||
|
+ " FD_TOTAL_COUNT_APP," |
||||
|
+ " FD_PERCENT_APP," |
||||
|
+ " FD_PERCENT_DIFF," |
||||
|
+ " FD_PERCENT_RATE," |
||||
|
+ " FD_WEIGHT," |
||||
|
+ " FD_ST_WEIGHT" |
||||
|
+ " from MV_ST_PSI"; |
||||
|
|
||||
|
jdbcTemplate.update(sql, new PreparedStatementSetter() { |
||||
|
@Override |
||||
|
public void setValues(PreparedStatement pstmt) throws SQLException { |
||||
|
pstmt.setObject(1, runtimeDateString); |
||||
|
} |
||||
|
}); |
||||
|
log.info("完成将计算并生成指标表数据保存到历史表中"); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 检查咨询建模客户分布表是否已经配置 |
||||
|
* @return 是否通过检查 |
||||
|
*/ |
||||
|
private boolean checkDistributionConfiguration(){ |
||||
|
String sql ="select count(*) count from MV_CFG_DISTRIBUTION"; |
||||
|
Long count =jdbcTemplate.query(sql, new ResultSetExtractor<Long>(){ |
||||
|
@Override |
||||
|
public Long extractData(ResultSet rs) throws SQLException, DataAccessException { |
||||
|
if(rs.next()){ |
||||
|
return rs.getLong("count"); |
||||
|
}else{ |
||||
|
return 0L; |
||||
|
} |
||||
|
} |
||||
|
}); |
||||
|
if(count!=null && count>0){ |
||||
|
return true; |
||||
|
}else{ |
||||
|
//throw new RuntimeException("未找到咨询建模时客户分布情况配置信息,请首先对参数[咨询建模时客户分布情况配置]进行配置后,再重试.");
|
||||
|
return false; |
||||
|
} |
||||
|
} |
||||
|
} |
@ -0,0 +1,33 @@ |
|||||
|
package io.sc.engine.mv.executor.support; |
||||
|
|
||||
|
import java.math.BigDecimal; |
||||
|
|
||||
|
import io.sc.engine.mv.jpa.entity.CfgCutOffPoint; |
||||
|
import io.sc.engine.mv.jpa.repository.CfgCutOffPointRepository; |
||||
|
import io.sc.platform.core.support.NumberIterator; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.stereotype.Component; |
||||
|
|
||||
|
@Component |
||||
|
public class CutOffPointFinder{ |
||||
|
@Autowired protected CfgCutOffPointRepository cfgCutPointRepository; |
||||
|
|
||||
|
/** |
||||
|
* 获取截断点配置 |
||||
|
* @param cutOffPointName 截断点名称 |
||||
|
* @return 截断点配置 |
||||
|
*/ |
||||
|
public NumberIterator getCufOffPoint(String cutOffPointName){ |
||||
|
CfgCutOffPoint cutPoint =cfgCutPointRepository.findByName(cutOffPointName); |
||||
|
if(cutPoint!=null){ |
||||
|
NumberIterator result =new NumberIterator(); |
||||
|
result.setFrom(new BigDecimal(cutPoint.getFrom())); |
||||
|
result.setTo(new BigDecimal(cutPoint.getTo())); |
||||
|
result.setStep(new BigDecimal(cutPoint.getStep())); |
||||
|
result.setScale(cutPoint.getScale()); |
||||
|
result.setRoundingMode(cutPoint.getRoundingMode()); |
||||
|
return result; |
||||
|
} |
||||
|
return null; |
||||
|
} |
||||
|
} |
@ -0,0 +1,29 @@ |
|||||
|
package io.sc.engine.mv.extractor; |
||||
|
|
||||
|
import io.sc.engine.mv.DataExtractor; |
||||
|
import io.sc.engine.mv.RuntimeContext; |
||||
|
import org.slf4j.Logger; |
||||
|
import org.slf4j.LoggerFactory; |
||||
|
import org.springframework.stereotype.Component; |
||||
|
|
||||
|
/** |
||||
|
* 违约记录源数据抽取器 |
||||
|
* @author wangshaoping |
||||
|
* |
||||
|
*/ |
||||
|
@Component |
||||
|
public class DefaultRecordDataExtractor implements DataExtractor { |
||||
|
private static final Logger log =LoggerFactory.getLogger(DefaultRecordDataExtractor.class); |
||||
|
|
||||
|
@Override |
||||
|
public void extract(RuntimeContext runtimeContext) { |
||||
|
log.info("开始抽取违约记录数据..."); |
||||
|
|
||||
|
log.info("完成抽取违约记录数据..."); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public int getExecuteTimeWeight() { |
||||
|
return 10; |
||||
|
} |
||||
|
} |
@ -0,0 +1,81 @@ |
|||||
|
package io.sc.engine.mv.initializer; |
||||
|
|
||||
|
import io.sc.engine.mv.service.configuration.*; |
||||
|
import io.sc.platform.core.initializer.ApplicationInitializer; |
||||
|
import io.sc.platform.core.initializer.ApplicationInitializerExecuteException; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.context.ApplicationContext; |
||||
|
|
||||
|
public class ConfigurationInitializer implements ApplicationInitializer { |
||||
|
@Autowired private CfgDataExtractorService cfgDataExtractorService; |
||||
|
@Autowired private CfgBinomialService binomialService; |
||||
|
@Autowired private CfgChiSquareService chiSquareService; |
||||
|
@Autowired private CfgCutOffPointService cutOffPointService; |
||||
|
@Autowired private CfgThresholdService thresholdService; |
||||
|
private Boolean isInitialized =null; |
||||
|
|
||||
|
@Override |
||||
|
public String getId() { |
||||
|
return this.getClass().getName(); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public String getName() { |
||||
|
return "Model Validator Configuration Initializer"; |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public String getDescription() { |
||||
|
return "Model Validator Configuration Initializer"; |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public void init(ApplicationContext applicationContext) { |
||||
|
this.cfgDataExtractorService =applicationContext.getBean(CfgDataExtractorService.class); |
||||
|
this.binomialService =applicationContext.getBean(CfgBinomialService.class); |
||||
|
this.chiSquareService =applicationContext.getBean(CfgChiSquareService.class); |
||||
|
this.cutOffPointService =applicationContext.getBean(CfgCutOffPointService.class); |
||||
|
this.thresholdService =applicationContext.getBean(CfgThresholdService.class); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public int getOrder() { |
||||
|
return 1100; |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public synchronized boolean isInitialized() { |
||||
|
if(isInitialized!=null) { |
||||
|
return isInitialized; |
||||
|
} |
||||
|
isInitialized = ( cfgDataExtractorService.getRepository().count()>0 |
||||
|
|| binomialService.getRepository().count()>0 |
||||
|
|| chiSquareService.getRepository().count()>0 |
||||
|
|| cutOffPointService.getRepository().count()>0 |
||||
|
|| thresholdService.getRepository().count()>0); |
||||
|
return isInitialized; |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public void execute() throws ApplicationInitializerExecuteException { |
||||
|
try { |
||||
|
if(cfgDataExtractorService.getRepository().count()<=0){ |
||||
|
cfgDataExtractorService.generateSample(); |
||||
|
} |
||||
|
if(binomialService.getRepository().count()<=0) { |
||||
|
binomialService.resetDefaultValues(); |
||||
|
} |
||||
|
if(chiSquareService.getRepository().count()<=0) { |
||||
|
chiSquareService.resetDefaultValues(); |
||||
|
} |
||||
|
if(cutOffPointService.getRepository().count()<=0) { |
||||
|
cutOffPointService.resetDefaultValues(); |
||||
|
} |
||||
|
if(thresholdService.getRepository().count()<=0) { |
||||
|
thresholdService.resetDefaultValues(); |
||||
|
} |
||||
|
} catch (Exception e) { |
||||
|
throw new ApplicationInitializerExecuteException(e); |
||||
|
} |
||||
|
} |
||||
|
} |
@ -0,0 +1,243 @@ |
|||||
|
package io.sc.engine.mv.jpa.entity; |
||||
|
|
||||
|
import io.sc.engine.mv.jpa.entity.id.CoeBinomialHistoryId; |
||||
|
import io.sc.engine.mv.vo.CoeBinomialHistoryVo; |
||||
|
import io.sc.platform.orm.entity.BaseEntity; |
||||
|
|
||||
|
import javax.persistence.*; |
||||
|
|
||||
|
|
||||
|
@Entity |
||||
|
@Table(name="MV_COE_BINOMIAL_HIS") |
||||
|
@IdClass(CoeBinomialHistoryId.class) |
||||
|
public class CoeBinomialHistory extends BaseEntity<CoeBinomialHistoryVo> { |
||||
|
//模型验证日期
|
||||
|
@Id |
||||
|
@Column(name="FD_VALIDATE_DATE") |
||||
|
private String validateDate; |
||||
|
|
||||
|
//模型标识
|
||||
|
@Id |
||||
|
@Column(name="FD_MODEL_ID") |
||||
|
private String modelId; |
||||
|
|
||||
|
//模型名称
|
||||
|
@Column(name="FD_MODEL_NAME") |
||||
|
private String modelName; |
||||
|
|
||||
|
//评分等级
|
||||
|
@Id |
||||
|
@Column(name="FD_LEVEL") |
||||
|
private String level; |
||||
|
|
||||
|
//违约概率
|
||||
|
@Column(name="FD_PD") |
||||
|
private Double pd; |
||||
|
|
||||
|
//客户个数
|
||||
|
@Column(name="FD_COUNT") |
||||
|
private Long count; |
||||
|
|
||||
|
//事实违约客户个数
|
||||
|
@Column(name="FD_DEFAULT_COUNT") |
||||
|
private Long defaultCount; |
||||
|
|
||||
|
//正态分布平均数
|
||||
|
@Column(name="FD_ND_AVG") |
||||
|
private Double ndAvg; |
||||
|
|
||||
|
//正态分布标准差
|
||||
|
@Column(name="FD_ND_SD") |
||||
|
private Double ndSd; |
||||
|
|
||||
|
//显著水平
|
||||
|
@Column(name="FD_SL") |
||||
|
private Double sl; |
||||
|
|
||||
|
//置信水平
|
||||
|
@Column(name="FD_CL") |
||||
|
private Double cl; |
||||
|
|
||||
|
//正态分布Z值上界
|
||||
|
@Column(name="FD_Z_UPPER") |
||||
|
private Double zUpper; |
||||
|
|
||||
|
//正态分布Z值下界
|
||||
|
@Column(name="FD_Z_LOWER") |
||||
|
private Double zLower; |
||||
|
|
||||
|
//临界值上界
|
||||
|
@Column(name="FD_D_UPPER") |
||||
|
private Double dUpper; |
||||
|
|
||||
|
//临界值下界
|
||||
|
@Column(name="FD_D_LOWER") |
||||
|
private Double dLower; |
||||
|
|
||||
|
//是否小于等于上界
|
||||
|
@Column(name="FD_LE_UPPER") |
||||
|
private Double leUpper; |
||||
|
|
||||
|
//是否大于等于下界
|
||||
|
@Column(name="FD_GE_LOWER") |
||||
|
private Double geLower; |
||||
|
|
||||
|
@Override |
||||
|
public CoeBinomialHistoryVo toVo() { |
||||
|
CoeBinomialHistoryVo vo =new CoeBinomialHistoryVo(); |
||||
|
vo.setValidateDate(this.getValidateDate()); |
||||
|
vo.setModelId(this.getModelId()); |
||||
|
vo.setModelName(this.getModelName()); |
||||
|
vo.setLevel(this.getLevel()); |
||||
|
vo.setPd(this.getPd()); |
||||
|
vo.setCount(this.getCount()); |
||||
|
vo.setDefaultCount(this.getDefaultCount()); |
||||
|
vo.setNdAvg(this.getNdAvg()); |
||||
|
vo.setNdSd(this.getNdSd()); |
||||
|
vo.setSl(this.getSl()); |
||||
|
vo.setCl(this.getCl()); |
||||
|
vo.setzUpper(this.getzUpper()); |
||||
|
vo.setzLower(this.getzLower()); |
||||
|
vo.setdUpper(this.getdUpper()); |
||||
|
vo.setdLower(this.getdLower()); |
||||
|
vo.setLeUpper(this.getLeUpper()); |
||||
|
vo.setGeLower(this.getGeLower()); |
||||
|
return vo; |
||||
|
} |
||||
|
|
||||
|
public String getValidateDate() { |
||||
|
return validateDate; |
||||
|
} |
||||
|
|
||||
|
public void setValidateDate(String validateDate) { |
||||
|
this.validateDate = validateDate; |
||||
|
} |
||||
|
|
||||
|
public String getModelId() { |
||||
|
return modelId; |
||||
|
} |
||||
|
|
||||
|
public void setModelId(String modelId) { |
||||
|
this.modelId = modelId; |
||||
|
} |
||||
|
|
||||
|
public String getModelName() { |
||||
|
return modelName; |
||||
|
} |
||||
|
|
||||
|
public void setModelName(String modelName) { |
||||
|
this.modelName = modelName; |
||||
|
} |
||||
|
|
||||
|
public String getLevel() { |
||||
|
return level; |
||||
|
} |
||||
|
|
||||
|
public void setLevel(String level) { |
||||
|
this.level = level; |
||||
|
} |
||||
|
|
||||
|
public Double getPd() { |
||||
|
return pd; |
||||
|
} |
||||
|
|
||||
|
public void setPd(Double pd) { |
||||
|
this.pd = pd; |
||||
|
} |
||||
|
|
||||
|
public Long getCount() { |
||||
|
return count; |
||||
|
} |
||||
|
|
||||
|
public void setCount(Long count) { |
||||
|
this.count = count; |
||||
|
} |
||||
|
|
||||
|
public Long getDefaultCount() { |
||||
|
return defaultCount; |
||||
|
} |
||||
|
|
||||
|
public void setDefaultCount(Long defaultCount) { |
||||
|
this.defaultCount = defaultCount; |
||||
|
} |
||||
|
|
||||
|
public Double getNdAvg() { |
||||
|
return ndAvg; |
||||
|
} |
||||
|
|
||||
|
public void setNdAvg(Double ndAvg) { |
||||
|
this.ndAvg = ndAvg; |
||||
|
} |
||||
|
|
||||
|
public Double getNdSd() { |
||||
|
return ndSd; |
||||
|
} |
||||
|
|
||||
|
public void setNdSd(Double ndSd) { |
||||
|
this.ndSd = ndSd; |
||||
|
} |
||||
|
|
||||
|
public Double getSl() { |
||||
|
return sl; |
||||
|
} |
||||
|
|
||||
|
public void setSl(Double sl) { |
||||
|
this.sl = sl; |
||||
|
} |
||||
|
|
||||
|
public Double getCl() { |
||||
|
return cl; |
||||
|
} |
||||
|
|
||||
|
public void setCl(Double cl) { |
||||
|
this.cl = cl; |
||||
|
} |
||||
|
|
||||
|
public Double getzUpper() { |
||||
|
return zUpper; |
||||
|
} |
||||
|
|
||||
|
public void setzUpper(Double zUpper) { |
||||
|
this.zUpper = zUpper; |
||||
|
} |
||||
|
|
||||
|
public Double getzLower() { |
||||
|
return zLower; |
||||
|
} |
||||
|
|
||||
|
public void setzLower(Double zLower) { |
||||
|
this.zLower = zLower; |
||||
|
} |
||||
|
|
||||
|
public Double getdUpper() { |
||||
|
return dUpper; |
||||
|
} |
||||
|
|
||||
|
public void setdUpper(Double dUpper) { |
||||
|
this.dUpper = dUpper; |
||||
|
} |
||||
|
|
||||
|
public Double getdLower() { |
||||
|
return dLower; |
||||
|
} |
||||
|
|
||||
|
public void setdLower(Double dLower) { |
||||
|
this.dLower = dLower; |
||||
|
} |
||||
|
|
||||
|
public Double getLeUpper() { |
||||
|
return leUpper; |
||||
|
} |
||||
|
|
||||
|
public void setLeUpper(Double leUpper) { |
||||
|
this.leUpper = leUpper; |
||||
|
} |
||||
|
|
||||
|
public Double getGeLower() { |
||||
|
return geLower; |
||||
|
} |
||||
|
|
||||
|
public void setGeLower(Double geLower) { |
||||
|
this.geLower = geLower; |
||||
|
} |
||||
|
} |
@ -0,0 +1,125 @@ |
|||||
|
package io.sc.engine.mv.jpa.entity; |
||||
|
|
||||
|
import io.sc.engine.mv.jpa.entity.id.CoeChiSquareHistoryId; |
||||
|
import io.sc.engine.mv.vo.CoeChiSquareHistoryVo; |
||||
|
import io.sc.platform.orm.entity.BaseEntity; |
||||
|
|
||||
|
import javax.persistence.*; |
||||
|
|
||||
|
@Entity |
||||
|
@Table(name="MV_COE_CHI_SQUARE_HIS") |
||||
|
@IdClass(CoeChiSquareHistoryId.class) |
||||
|
public class CoeChiSquareHistory extends BaseEntity<CoeChiSquareHistoryVo> { |
||||
|
//模型验证日期
|
||||
|
@Id |
||||
|
@Column(name="FD_VALIDATE_DATE") |
||||
|
private String validateDate; |
||||
|
|
||||
|
//模型标识
|
||||
|
@Id |
||||
|
@Column(name="FD_MODEL_ID") |
||||
|
private String modelId; |
||||
|
|
||||
|
//模型名称
|
||||
|
@Column(name="FD_MODEL_NAME") |
||||
|
private String modelName; |
||||
|
|
||||
|
//评分等级
|
||||
|
@Id |
||||
|
@Column(name="FD_LEVEL") |
||||
|
private String level; |
||||
|
|
||||
|
//违约概率
|
||||
|
@Column(name="FD_PD") |
||||
|
private Double pd; |
||||
|
|
||||
|
//客户个数
|
||||
|
@Column(name="FD_COUNT") |
||||
|
private Long count; |
||||
|
|
||||
|
//事实违约客户个数
|
||||
|
@Column(name="FD_DEFAULT_COUNT") |
||||
|
private Long defaultCount; |
||||
|
|
||||
|
//卡方值
|
||||
|
@Column(name="FD_CHI_SQUARE") |
||||
|
private Double chiSquare; |
||||
|
|
||||
|
@Override |
||||
|
public CoeChiSquareHistoryVo toVo() { |
||||
|
CoeChiSquareHistoryVo vo =new CoeChiSquareHistoryVo(); |
||||
|
vo.setValidateDate(this.getValidateDate()); |
||||
|
vo.setModelId(this.getModelId()); |
||||
|
vo.setModelName(this.getModelName()); |
||||
|
vo.setLevel(this.getLevel()); |
||||
|
vo.setPd(this.getPd()); |
||||
|
vo.setCount(this.getCount()); |
||||
|
vo.setDefaultCount(this.getDefaultCount()); |
||||
|
vo.setChiSquare(this.getChiSquare()); |
||||
|
return vo; |
||||
|
} |
||||
|
|
||||
|
public String getValidateDate() { |
||||
|
return validateDate; |
||||
|
} |
||||
|
|
||||
|
public void setValidateDate(String validateDate) { |
||||
|
this.validateDate = validateDate; |
||||
|
} |
||||
|
|
||||
|
public String getModelId() { |
||||
|
return modelId; |
||||
|
} |
||||
|
|
||||
|
public void setModelId(String modelId) { |
||||
|
this.modelId = modelId; |
||||
|
} |
||||
|
|
||||
|
public String getModelName() { |
||||
|
return modelName; |
||||
|
} |
||||
|
|
||||
|
public void setModelName(String modelName) { |
||||
|
this.modelName = modelName; |
||||
|
} |
||||
|
|
||||
|
public String getLevel() { |
||||
|
return level; |
||||
|
} |
||||
|
|
||||
|
public void setLevel(String level) { |
||||
|
this.level = level; |
||||
|
} |
||||
|
|
||||
|
public Double getPd() { |
||||
|
return pd; |
||||
|
} |
||||
|
|
||||
|
public void setPd(Double pd) { |
||||
|
this.pd = pd; |
||||
|
} |
||||
|
|
||||
|
public Long getCount() { |
||||
|
return count; |
||||
|
} |
||||
|
|
||||
|
public void setCount(Long count) { |
||||
|
this.count = count; |
||||
|
} |
||||
|
|
||||
|
public Long getDefaultCount() { |
||||
|
return defaultCount; |
||||
|
} |
||||
|
|
||||
|
public void setDefaultCount(Long defaultCount) { |
||||
|
this.defaultCount = defaultCount; |
||||
|
} |
||||
|
|
||||
|
public Double getChiSquare() { |
||||
|
return chiSquare; |
||||
|
} |
||||
|
|
||||
|
public void setChiSquare(Double chiSquare) { |
||||
|
this.chiSquare = chiSquare; |
||||
|
} |
||||
|
} |
@ -0,0 +1,294 @@ |
|||||
|
package io.sc.engine.mv.jpa.entity; |
||||
|
|
||||
|
import io.sc.engine.mv.CoeResult; |
||||
|
import io.sc.engine.mv.ExecuteMode; |
||||
|
import io.sc.engine.mv.jpa.entity.id.GeneralResultHistoryId; |
||||
|
import io.sc.engine.mv.vo.GeneralResultHistoryVo; |
||||
|
import io.sc.platform.orm.entity.BaseEntity; |
||||
|
|
||||
|
import javax.persistence.*; |
||||
|
import java.util.ArrayList; |
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* 验证结果历史实体类 |
||||
|
* @author wangshaoping |
||||
|
* |
||||
|
*/ |
||||
|
@Entity |
||||
|
@Table(name="MV_GENERAL_RESULT_HIS") |
||||
|
@IdClass(GeneralResultHistoryId.class) |
||||
|
public class GeneralResultHistory extends BaseEntity<GeneralResultHistoryVo> { |
||||
|
private static final long serialVersionUID = -6490873659011192600L; |
||||
|
|
||||
|
//验证日期
|
||||
|
@Id |
||||
|
@Column(name="FD_VALIDATE_DATE", nullable=false, length=19) |
||||
|
private String validateDate; |
||||
|
|
||||
|
//模型标识
|
||||
|
@Id |
||||
|
@Column(name="FD_MODEL_ID", nullable=false) |
||||
|
private String modelId; |
||||
|
|
||||
|
//模型名称
|
||||
|
@Column(name="FD_MODEL_NAME") |
||||
|
private String modelName; |
||||
|
|
||||
|
//验证执行模式
|
||||
|
@Id |
||||
|
@Column(name="FD_EXECUTE_MODE", nullable=false) |
||||
|
@Enumerated(EnumType.STRING) |
||||
|
private ExecuteMode executeMode; |
||||
|
|
||||
|
//总样本数
|
||||
|
@Column(name="FD_TOTAL_SAMPLE_COUNT") |
||||
|
private Long totalSampleCount; |
||||
|
|
||||
|
//事实违约样本个数
|
||||
|
@Column(name="FD_DEFAULT_SAMPLE_COUNT") |
||||
|
private Long defaultSampleCount; |
||||
|
|
||||
|
//区分能力 AUC 值(总体)
|
||||
|
@Column(name="FD_SC_AUC") |
||||
|
private Double auc; |
||||
|
|
||||
|
//区分能力 AUC 值(定量)
|
||||
|
@Column(name="FD_SC_AUC_QUANTITATIVE") |
||||
|
private Double aucQuantitative; |
||||
|
|
||||
|
//区分能力 AUC 值(定性)
|
||||
|
@Column(name="FD_SC_AUC_QUALITATIVE") |
||||
|
private Double aucQualitative; |
||||
|
|
||||
|
//区分能力 AR 值(总体)
|
||||
|
@Column(name="FD_SC_AR") |
||||
|
private Double ar; |
||||
|
|
||||
|
//区分能力 AR 值(定量)
|
||||
|
@Column(name="FD_SC_AR_QUANTITATIVE") |
||||
|
private Double arQuantitative; |
||||
|
|
||||
|
//区分能力 AR 值(定性)
|
||||
|
@Column(name="FD_SC_AR_QUALITATIVE") |
||||
|
private Double arQualitative; |
||||
|
|
||||
|
//区分能力 KS 值(总体)
|
||||
|
@Column(name="FD_SC_KS") |
||||
|
private Double ks; |
||||
|
|
||||
|
//区分能力 KS 值(定量)
|
||||
|
@Column(name="FD_SC_KS_QUANTITATIVE") |
||||
|
private Double ksQuantitative; |
||||
|
|
||||
|
//区分能力 KS 值(定性)
|
||||
|
@Column(name="FD_SC_KS_QUALITATIVE") |
||||
|
private Double ksQualitative; |
||||
|
|
||||
|
//稳定性转移矩阵 SVD 值
|
||||
|
@Column(name="FD_ST_SVD") |
||||
|
private Double svd; |
||||
|
|
||||
|
//稳定性群体稳定性 PSI 值
|
||||
|
@Column(name="FD_ST_PSI") |
||||
|
private Double psi; |
||||
|
|
||||
|
//卡方检验结果
|
||||
|
@Column(name="FD_COE_CHI_SQUARE") |
||||
|
@Enumerated(EnumType.STRING) |
||||
|
private CoeResult chiSquare; |
||||
|
|
||||
|
//卡方检验结果
|
||||
|
@Column(name="FD_COE_BINOMIAL") |
||||
|
@Enumerated(EnumType.STRING) |
||||
|
private CoeResult binomial; |
||||
|
|
||||
|
//模型验证执行时参数配置
|
||||
|
@Transient |
||||
|
private List<RuntimeParameter> runtimeParameters =new ArrayList<RuntimeParameter>(); |
||||
|
|
||||
|
@Override |
||||
|
public GeneralResultHistoryVo toVo() { |
||||
|
GeneralResultHistoryVo vo =new GeneralResultHistoryVo(); |
||||
|
vo.setValidateDate(this.getValidateDate()); |
||||
|
vo.setModelId(this.getModelId()); |
||||
|
vo.setModelName(this.getModelName()); |
||||
|
vo.setExecuteMode(this.getExecuteMode()); |
||||
|
vo.setTotalSampleCount(this.getTotalSampleCount()); |
||||
|
vo.setDefaultSampleCount(this.getDefaultSampleCount()); |
||||
|
vo.setAuc(this.getAuc()); |
||||
|
vo.setAucQuantitative(this.getAucQuantitative()); |
||||
|
vo.setAucQualitative(this.getAucQualitative()); |
||||
|
vo.setAr(this.getAr()); |
||||
|
vo.setArQuantitative(this.getArQuantitative()); |
||||
|
vo.setArQualitative(this.getArQualitative()); |
||||
|
vo.setKs(this.getKs()); |
||||
|
vo.setKsQuantitative(this.getKsQuantitative()); |
||||
|
vo.setKsQualitative(this.getKsQualitative()); |
||||
|
vo.setSvd(this.getSvd()); |
||||
|
vo.setPsi(this.getPsi()); |
||||
|
vo.setChiSquare(this.getChiSquare()); |
||||
|
vo.setBinomial(this.getBinomial()); |
||||
|
return vo; |
||||
|
} |
||||
|
|
||||
|
public String getValidateDate() { |
||||
|
return validateDate; |
||||
|
} |
||||
|
|
||||
|
public void setValidateDate(String validateDate) { |
||||
|
this.validateDate = validateDate; |
||||
|
} |
||||
|
|
||||
|
public String getModelId() { |
||||
|
return modelId; |
||||
|
} |
||||
|
|
||||
|
public void setModelId(String modelId) { |
||||
|
this.modelId = modelId; |
||||
|
} |
||||
|
|
||||
|
public String getModelName() { |
||||
|
return modelName; |
||||
|
} |
||||
|
|
||||
|
public void setModelName(String modelName) { |
||||
|
this.modelName = modelName; |
||||
|
} |
||||
|
|
||||
|
public ExecuteMode getExecuteMode() { |
||||
|
return executeMode; |
||||
|
} |
||||
|
|
||||
|
public void setExecuteMode(ExecuteMode executeMode) { |
||||
|
this.executeMode = executeMode; |
||||
|
} |
||||
|
|
||||
|
public Long getTotalSampleCount() { |
||||
|
return totalSampleCount; |
||||
|
} |
||||
|
|
||||
|
public void setTotalSampleCount(Long totalSampleCount) { |
||||
|
this.totalSampleCount = totalSampleCount; |
||||
|
} |
||||
|
|
||||
|
public Long getDefaultSampleCount() { |
||||
|
return defaultSampleCount; |
||||
|
} |
||||
|
|
||||
|
public void setDefaultSampleCount(Long defaultSampleCount) { |
||||
|
this.defaultSampleCount = defaultSampleCount; |
||||
|
} |
||||
|
|
||||
|
public Double getAuc() { |
||||
|
return auc; |
||||
|
} |
||||
|
|
||||
|
public void setAuc(Double auc) { |
||||
|
this.auc = auc; |
||||
|
} |
||||
|
|
||||
|
public Double getAucQuantitative() { |
||||
|
return aucQuantitative; |
||||
|
} |
||||
|
|
||||
|
public void setAucQuantitative(Double aucQuantitative) { |
||||
|
this.aucQuantitative = aucQuantitative; |
||||
|
} |
||||
|
|
||||
|
public Double getAucQualitative() { |
||||
|
return aucQualitative; |
||||
|
} |
||||
|
|
||||
|
public void setAucQualitative(Double aucQualitative) { |
||||
|
this.aucQualitative = aucQualitative; |
||||
|
} |
||||
|
|
||||
|
public Double getAr() { |
||||
|
return ar; |
||||
|
} |
||||
|
|
||||
|
public void setAr(Double ar) { |
||||
|
this.ar = ar; |
||||
|
} |
||||
|
|
||||
|
public Double getArQuantitative() { |
||||
|
return arQuantitative; |
||||
|
} |
||||
|
|
||||
|
public void setArQuantitative(Double arQuantitative) { |
||||
|
this.arQuantitative = arQuantitative; |
||||
|
} |
||||
|
|
||||
|
public Double getArQualitative() { |
||||
|
return arQualitative; |
||||
|
} |
||||
|
|
||||
|
public void setArQualitative(Double arQualitative) { |
||||
|
this.arQualitative = arQualitative; |
||||
|
} |
||||
|
|
||||
|
public Double getKs() { |
||||
|
return ks; |
||||
|
} |
||||
|
|
||||
|
public void setKs(Double ks) { |
||||
|
this.ks = ks; |
||||
|
} |
||||
|
|
||||
|
public Double getKsQuantitative() { |
||||
|
return ksQuantitative; |
||||
|
} |
||||
|
|
||||
|
public void setKsQuantitative(Double ksQuantitative) { |
||||
|
this.ksQuantitative = ksQuantitative; |
||||
|
} |
||||
|
|
||||
|
public Double getKsQualitative() { |
||||
|
return ksQualitative; |
||||
|
} |
||||
|
|
||||
|
public void setKsQualitative(Double ksQualitative) { |
||||
|
this.ksQualitative = ksQualitative; |
||||
|
} |
||||
|
|
||||
|
public Double getSvd() { |
||||
|
return svd; |
||||
|
} |
||||
|
|
||||
|
public void setSvd(Double svd) { |
||||
|
this.svd = svd; |
||||
|
} |
||||
|
|
||||
|
public Double getPsi() { |
||||
|
return psi; |
||||
|
} |
||||
|
|
||||
|
public void setPsi(Double psi) { |
||||
|
this.psi = psi; |
||||
|
} |
||||
|
|
||||
|
public CoeResult getChiSquare() { |
||||
|
return chiSquare; |
||||
|
} |
||||
|
|
||||
|
public void setChiSquare(CoeResult chiSquare) { |
||||
|
this.chiSquare = chiSquare; |
||||
|
} |
||||
|
|
||||
|
public CoeResult getBinomial() { |
||||
|
return binomial; |
||||
|
} |
||||
|
|
||||
|
public void setBinomial(CoeResult binomial) { |
||||
|
this.binomial = binomial; |
||||
|
} |
||||
|
|
||||
|
public List<RuntimeParameter> getRuntimeParameters() { |
||||
|
return runtimeParameters; |
||||
|
} |
||||
|
|
||||
|
public void setRuntimeParameters(List<RuntimeParameter> runtimeParameters) { |
||||
|
this.runtimeParameters = runtimeParameters; |
||||
|
} |
||||
|
} |
@ -0,0 +1,222 @@ |
|||||
|
package io.sc.engine.mv.jpa.entity; |
||||
|
|
||||
|
import io.sc.engine.mv.jpa.entity.id.GeneralSampleHistoryId; |
||||
|
import io.sc.engine.mv.vo.GeneralSampleHistoryVo; |
||||
|
import io.sc.platform.orm.entity.BaseEntity; |
||||
|
|
||||
|
import java.math.BigDecimal; |
||||
|
import java.util.Date; |
||||
|
|
||||
|
import javax.persistence.Column; |
||||
|
import javax.persistence.Entity; |
||||
|
import javax.persistence.Id; |
||||
|
import javax.persistence.IdClass; |
||||
|
import javax.persistence.Table; |
||||
|
import javax.persistence.Temporal; |
||||
|
import javax.persistence.TemporalType; |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 验证样本历史实体类 |
||||
|
* @author wangshaoping |
||||
|
* |
||||
|
*/ |
||||
|
@Entity |
||||
|
@Table(name="MV_GENERAL_SAMPLE_HIS") |
||||
|
@IdClass(GeneralSampleHistoryId.class) |
||||
|
public class GeneralSampleHistory extends BaseEntity<GeneralSampleHistoryVo> { |
||||
|
//验证日期
|
||||
|
@Id |
||||
|
@Column(name="FD_VALIDATE_DATE") |
||||
|
private String validateDate; |
||||
|
|
||||
|
//客户标识
|
||||
|
@Id |
||||
|
@Column(name="FD_CUSTOM_ID") |
||||
|
private String customId; |
||||
|
|
||||
|
//客户名称
|
||||
|
@Column(name="FD_CUSTOM_NAME") |
||||
|
private String customName; |
||||
|
|
||||
|
//模型标识
|
||||
|
@Id |
||||
|
@Column(name="FD_MODEL_ID") |
||||
|
private String modelId; |
||||
|
|
||||
|
//模型名称
|
||||
|
@Column(name="FD_MODEL_NAME") |
||||
|
private String modelName; |
||||
|
|
||||
|
//违约概率
|
||||
|
@Column(name="FD_PD") |
||||
|
private BigDecimal pd; |
||||
|
|
||||
|
//评分
|
||||
|
@Column(name="FD_SCORE") |
||||
|
private BigDecimal score; |
||||
|
|
||||
|
//评分(定量得分)
|
||||
|
@Column(name="FD_SCORE_QUANTITATIVE") |
||||
|
private BigDecimal scoreQuantitative; |
||||
|
|
||||
|
//评分(定性得分)
|
||||
|
@Column(name="FD_SCORE_QUALITATIVE") |
||||
|
private BigDecimal scoreQualitative; |
||||
|
|
||||
|
//评级等级
|
||||
|
@Column(name="FD_LEVEL") |
||||
|
private String level; |
||||
|
|
||||
|
//评级有效期开始日期
|
||||
|
@Id |
||||
|
@Column(name="FD_SCORE_BEGIN_DATE") |
||||
|
@Temporal(TemporalType.TIMESTAMP) |
||||
|
private Date beginDate; |
||||
|
|
||||
|
//评级有效期结束日期
|
||||
|
@Id |
||||
|
@Column(name="FD_SCORE_END_DATE") |
||||
|
@Temporal(TemporalType.TIMESTAMP) |
||||
|
private Date endDate; |
||||
|
|
||||
|
//违约状态
|
||||
|
@Column(name="FD_DEFAULT_STATUS") |
||||
|
private String status; |
||||
|
|
||||
|
//违约认定日期
|
||||
|
@Column(name="FD_DEFAULT_CONFIRM_DATE") |
||||
|
private Date defaultConfirmDate; |
||||
|
|
||||
|
@Override |
||||
|
public GeneralSampleHistoryVo toVo() { |
||||
|
GeneralSampleHistoryVo vo =new GeneralSampleHistoryVo(); |
||||
|
vo.setValidateDate(this.getValidateDate()); |
||||
|
vo.setCustomId(this.getCustomId()); |
||||
|
vo.setCustomName(this.getCustomName()); |
||||
|
vo.setModelId(this.getModelId()); |
||||
|
vo.setModelName(this.getModelName()); |
||||
|
vo.setPd(this.getPd()); |
||||
|
vo.setScore(this.getScore()); |
||||
|
vo.setScoreQuantitative(this.getScoreQuantitative()); |
||||
|
vo.setScoreQualitative(this.getScoreQualitative()); |
||||
|
vo.setLevel(this.getLevel()); |
||||
|
vo.setBeginDate(this.getBeginDate()); |
||||
|
vo.setEndDate(this.getEndDate()); |
||||
|
vo.setStatus(this.getStatus()); |
||||
|
vo.setDefaultConfirmDate(this.getDefaultConfirmDate()); |
||||
|
return vo; |
||||
|
} |
||||
|
|
||||
|
public String getValidateDate() { |
||||
|
return validateDate; |
||||
|
} |
||||
|
|
||||
|
public void setValidateDate(String validateDate) { |
||||
|
this.validateDate = validateDate; |
||||
|
} |
||||
|
|
||||
|
public String getCustomId() { |
||||
|
return customId; |
||||
|
} |
||||
|
|
||||
|
public void setCustomId(String customId) { |
||||
|
this.customId = customId; |
||||
|
} |
||||
|
|
||||
|
public String getCustomName() { |
||||
|
return customName; |
||||
|
} |
||||
|
|
||||
|
public void setCustomName(String customName) { |
||||
|
this.customName = customName; |
||||
|
} |
||||
|
|
||||
|
public String getModelId() { |
||||
|
return modelId; |
||||
|
} |
||||
|
|
||||
|
public void setModelId(String modelId) { |
||||
|
this.modelId = modelId; |
||||
|
} |
||||
|
|
||||
|
public String getModelName() { |
||||
|
return modelName; |
||||
|
} |
||||
|
|
||||
|
public void setModelName(String modelName) { |
||||
|
this.modelName = modelName; |
||||
|
} |
||||
|
|
||||
|
public BigDecimal getPd() { |
||||
|
return pd; |
||||
|
} |
||||
|
|
||||
|
public void setPd(BigDecimal pd) { |
||||
|
this.pd = pd; |
||||
|
} |
||||
|
|
||||
|
public BigDecimal getScore() { |
||||
|
return score; |
||||
|
} |
||||
|
|
||||
|
public void setScore(BigDecimal score) { |
||||
|
this.score = score; |
||||
|
} |
||||
|
|
||||
|
public BigDecimal getScoreQuantitative() { |
||||
|
return scoreQuantitative; |
||||
|
} |
||||
|
|
||||
|
public void setScoreQuantitative(BigDecimal scoreQuantitative) { |
||||
|
this.scoreQuantitative = scoreQuantitative; |
||||
|
} |
||||
|
|
||||
|
public BigDecimal getScoreQualitative() { |
||||
|
return scoreQualitative; |
||||
|
} |
||||
|
|
||||
|
public void setScoreQualitative(BigDecimal scoreQualitative) { |
||||
|
this.scoreQualitative = scoreQualitative; |
||||
|
} |
||||
|
|
||||
|
public String getLevel() { |
||||
|
return level; |
||||
|
} |
||||
|
|
||||
|
public void setLevel(String level) { |
||||
|
this.level = level; |
||||
|
} |
||||
|
|
||||
|
public Date getBeginDate() { |
||||
|
return beginDate; |
||||
|
} |
||||
|
|
||||
|
public void setBeginDate(Date beginDate) { |
||||
|
this.beginDate = beginDate; |
||||
|
} |
||||
|
|
||||
|
public Date getEndDate() { |
||||
|
return endDate; |
||||
|
} |
||||
|
|
||||
|
public void setEndDate(Date endDate) { |
||||
|
this.endDate = endDate; |
||||
|
} |
||||
|
|
||||
|
public String getStatus() { |
||||
|
return status; |
||||
|
} |
||||
|
|
||||
|
public void setStatus(String status) { |
||||
|
this.status = status; |
||||
|
} |
||||
|
|
||||
|
public Date getDefaultConfirmDate() { |
||||
|
return defaultConfirmDate; |
||||
|
} |
||||
|
|
||||
|
public void setDefaultConfirmDate(Date defaultConfirmDate) { |
||||
|
this.defaultConfirmDate = defaultConfirmDate; |
||||
|
} |
||||
|
} |
@ -0,0 +1,223 @@ |
|||||
|
package io.sc.engine.mv.jpa.entity; |
||||
|
|
||||
|
import io.sc.engine.mv.jpa.entity.id.StPsiHistoryId; |
||||
|
import io.sc.engine.mv.vo.StPsiHistoryVo; |
||||
|
import io.sc.platform.orm.entity.BaseEntity; |
||||
|
|
||||
|
import javax.persistence.*; |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 模型稳定性验证 PSI 指标表历史数据实体类 |
||||
|
* @author wangshaoping |
||||
|
* |
||||
|
*/ |
||||
|
@Entity |
||||
|
@Table(name="MV_ST_PSI_HIS") |
||||
|
@IdClass(StPsiHistoryId.class) |
||||
|
public class StPsiHistory extends BaseEntity<StPsiHistoryVo> { |
||||
|
//模型验证日期
|
||||
|
@Id |
||||
|
@Column(name="FD_VALIDATE_DATE") |
||||
|
private String validateDate; |
||||
|
|
||||
|
//模型标识
|
||||
|
@Id |
||||
|
@Column(name="FD_MODEL_ID") |
||||
|
private String modelId; |
||||
|
|
||||
|
//模型名称
|
||||
|
@Column(name="FD_MODEL_NAME") |
||||
|
private String modelName; |
||||
|
|
||||
|
//分数段开始值_含该值
|
||||
|
@Id |
||||
|
@Column(name="FD_SCORE_SEG_START") |
||||
|
private Double scoreSegStart; |
||||
|
|
||||
|
//分数段结束值_含该值
|
||||
|
@Id |
||||
|
@Column(name="FD_SCORE_SEG_END") |
||||
|
private Double scoreSegEnd; |
||||
|
|
||||
|
//分数段内申请人数_咨询建模时
|
||||
|
@Column(name="FD_COUNT_DEV") |
||||
|
private Long countDev; |
||||
|
|
||||
|
//群体总人数_咨询建模时
|
||||
|
@Column(name="FD_TOTAL_COUNT_DEV") |
||||
|
private Long totalCountDev; |
||||
|
|
||||
|
//分数段内申请人数占群体总人数百分比_咨询建模时
|
||||
|
@Column(name="FD_PERCENT_DEV") |
||||
|
private Double percentDev; |
||||
|
|
||||
|
//分数段内申请人数_模型应用时
|
||||
|
@Column(name="FD_COUNT_APP") |
||||
|
private Long countApp; |
||||
|
|
||||
|
//群体总人数_模型应用时
|
||||
|
@Column(name="FD_TOTAL_COUNT_APP") |
||||
|
private Long totalCountApp; |
||||
|
|
||||
|
//分数段内申请人数占群体总人数百分比_模型应用时
|
||||
|
@Column(name="FD_PERCENT_APP") |
||||
|
private Double percentApp; |
||||
|
|
||||
|
//百分比变化
|
||||
|
@Column(name="FD_PERCENT_DIFF") |
||||
|
private Double percentDiff; |
||||
|
|
||||
|
//百分比相对比例
|
||||
|
@Column(name="FD_PERCENT_RATE") |
||||
|
private Double percentRate; |
||||
|
|
||||
|
//加权系数
|
||||
|
@Column(name="FD_WEIGHT") |
||||
|
private Double weight; |
||||
|
|
||||
|
//稳定性加权
|
||||
|
@Column(name="FD_ST_WEIGHT") |
||||
|
private Double stWeight; |
||||
|
|
||||
|
@Override |
||||
|
public StPsiHistoryVo toVo() { |
||||
|
StPsiHistoryVo vo =new StPsiHistoryVo(); |
||||
|
vo.setValidateDate(this.getValidateDate()); |
||||
|
vo.setModelId(this.getModelId()); |
||||
|
vo.setModelName(this.getModelName()); |
||||
|
vo.setScoreSegStart(this.getScoreSegStart()); |
||||
|
vo.setScoreSegEnd(this.getScoreSegEnd()); |
||||
|
vo.setCountDev(this.getCountDev()); |
||||
|
vo.setTotalCountDev(this.getTotalCountDev()); |
||||
|
vo.setPercentDev(this.getPercentDev()); |
||||
|
vo.setCountApp(this.getCountApp()); |
||||
|
vo.setTotalCountApp(this.getTotalCountApp()); |
||||
|
vo.setPercentApp(this.getPercentApp()); |
||||
|
vo.setPercentDiff(this.getPercentDiff()); |
||||
|
vo.setPercentRate(this.getPercentRate()); |
||||
|
vo.setWeight(this.getWeight()); |
||||
|
vo.setStWeight(this.getStWeight()); |
||||
|
return vo; |
||||
|
} |
||||
|
|
||||
|
public String getValidateDate() { |
||||
|
return validateDate; |
||||
|
} |
||||
|
|
||||
|
public void setValidateDate(String validateDate) { |
||||
|
this.validateDate = validateDate; |
||||
|
} |
||||
|
|
||||
|
public String getModelId() { |
||||
|
return modelId; |
||||
|
} |
||||
|
|
||||
|
public void setModelId(String modelId) { |
||||
|
this.modelId = modelId; |
||||
|
} |
||||
|
|
||||
|
public String getModelName() { |
||||
|
return modelName; |
||||
|
} |
||||
|
|
||||
|
public void setModelName(String modelName) { |
||||
|
this.modelName = modelName; |
||||
|
} |
||||
|
|
||||
|
public Double getScoreSegStart() { |
||||
|
return scoreSegStart; |
||||
|
} |
||||
|
|
||||
|
public void setScoreSegStart(Double scoreSegStart) { |
||||
|
this.scoreSegStart = scoreSegStart; |
||||
|
} |
||||
|
|
||||
|
public Double getScoreSegEnd() { |
||||
|
return scoreSegEnd; |
||||
|
} |
||||
|
|
||||
|
public void setScoreSegEnd(Double scoreSegEnd) { |
||||
|
this.scoreSegEnd = scoreSegEnd; |
||||
|
} |
||||
|
|
||||
|
public Long getCountDev() { |
||||
|
return countDev; |
||||
|
} |
||||
|
|
||||
|
public void setCountDev(Long countDev) { |
||||
|
this.countDev = countDev; |
||||
|
} |
||||
|
|
||||
|
public Long getTotalCountDev() { |
||||
|
return totalCountDev; |
||||
|
} |
||||
|
|
||||
|
public void setTotalCountDev(Long totalCountDev) { |
||||
|
this.totalCountDev = totalCountDev; |
||||
|
} |
||||
|
|
||||
|
public Double getPercentDev() { |
||||
|
return percentDev; |
||||
|
} |
||||
|
|
||||
|
public void setPercentDev(Double percentDev) { |
||||
|
this.percentDev = percentDev; |
||||
|
} |
||||
|
|
||||
|
public Long getCountApp() { |
||||
|
return countApp; |
||||
|
} |
||||
|
|
||||
|
public void setCountApp(Long countApp) { |
||||
|
this.countApp = countApp; |
||||
|
} |
||||
|
|
||||
|
public Long getTotalCountApp() { |
||||
|
return totalCountApp; |
||||
|
} |
||||
|
|
||||
|
public void setTotalCountApp(Long totalCountApp) { |
||||
|
this.totalCountApp = totalCountApp; |
||||
|
} |
||||
|
|
||||
|
public Double getPercentApp() { |
||||
|
return percentApp; |
||||
|
} |
||||
|
|
||||
|
public void setPercentApp(Double percentApp) { |
||||
|
this.percentApp = percentApp; |
||||
|
} |
||||
|
|
||||
|
public Double getPercentDiff() { |
||||
|
return percentDiff; |
||||
|
} |
||||
|
|
||||
|
public void setPercentDiff(Double percentDiff) { |
||||
|
this.percentDiff = percentDiff; |
||||
|
} |
||||
|
|
||||
|
public Double getPercentRate() { |
||||
|
return percentRate; |
||||
|
} |
||||
|
|
||||
|
public void setPercentRate(Double percentRate) { |
||||
|
this.percentRate = percentRate; |
||||
|
} |
||||
|
|
||||
|
public Double getWeight() { |
||||
|
return weight; |
||||
|
} |
||||
|
|
||||
|
public void setWeight(Double weight) { |
||||
|
this.weight = weight; |
||||
|
} |
||||
|
|
||||
|
public Double getStWeight() { |
||||
|
return stWeight; |
||||
|
} |
||||
|
|
||||
|
public void setStWeight(Double stWeight) { |
||||
|
this.stWeight = stWeight; |
||||
|
} |
||||
|
} |
@ -0,0 +1,66 @@ |
|||||
|
package io.sc.engine.mv.jpa.entity.id; |
||||
|
|
||||
|
import java.io.Serializable; |
||||
|
|
||||
|
public class CoeBinomialHistoryId implements Serializable{ |
||||
|
private static final long serialVersionUID = 7292907540613138975L; |
||||
|
private String validateDate; |
||||
|
private String modelId; |
||||
|
private String level; |
||||
|
|
||||
|
public String getValidateDate() { |
||||
|
return validateDate; |
||||
|
} |
||||
|
public void setValidateDate(String validateDate) { |
||||
|
this.validateDate = validateDate; |
||||
|
} |
||||
|
public String getModelId() { |
||||
|
return modelId; |
||||
|
} |
||||
|
public void setModelId(String modelId) { |
||||
|
this.modelId = modelId; |
||||
|
} |
||||
|
public String getLevel() { |
||||
|
return level; |
||||
|
} |
||||
|
public void setLevel(String level) { |
||||
|
this.level = level; |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public int hashCode() { |
||||
|
final int prime = 31; |
||||
|
int result = 1; |
||||
|
result = prime * result + ((level == null) ? 0 : level.hashCode()); |
||||
|
result = prime * result + ((modelId == null) ? 0 : modelId.hashCode()); |
||||
|
result = prime * result + ((validateDate == null) ? 0 : validateDate.hashCode()); |
||||
|
return result; |
||||
|
} |
||||
|
@Override |
||||
|
public boolean equals(Object obj) { |
||||
|
if (this == obj) |
||||
|
return true; |
||||
|
if (obj == null) |
||||
|
return false; |
||||
|
if (getClass() != obj.getClass()) |
||||
|
return false; |
||||
|
CoeBinomialHistoryId other = (CoeBinomialHistoryId) obj; |
||||
|
|
||||
|
if (level == null) { |
||||
|
if (other.level != null) |
||||
|
return false; |
||||
|
} else if (!level.equals(other.level)) |
||||
|
return false; |
||||
|
if (modelId == null) { |
||||
|
if (other.modelId != null) |
||||
|
return false; |
||||
|
} else if (!modelId.equals(other.modelId)) |
||||
|
return false; |
||||
|
if (validateDate == null) { |
||||
|
if (other.validateDate != null) |
||||
|
return false; |
||||
|
} else if (!validateDate.equals(other.validateDate)) |
||||
|
return false; |
||||
|
return true; |
||||
|
} |
||||
|
} |
@ -0,0 +1,65 @@ |
|||||
|
package io.sc.engine.mv.jpa.entity.id; |
||||
|
|
||||
|
import java.io.Serializable; |
||||
|
|
||||
|
public class CoeChiSquareHistoryId implements Serializable{ |
||||
|
private static final long serialVersionUID = -3256367575140177940L; |
||||
|
private String validateDate; |
||||
|
private String modelId; |
||||
|
private String level; |
||||
|
|
||||
|
public String getValidateDate() { |
||||
|
return validateDate; |
||||
|
} |
||||
|
public void setValidateDate(String validateDate) { |
||||
|
this.validateDate = validateDate; |
||||
|
} |
||||
|
public String getModelId() { |
||||
|
return modelId; |
||||
|
} |
||||
|
public void setModelId(String modelId) { |
||||
|
this.modelId = modelId; |
||||
|
} |
||||
|
public String getLevel() { |
||||
|
return level; |
||||
|
} |
||||
|
public void setLevel(String level) { |
||||
|
this.level = level; |
||||
|
} |
||||
|
@Override |
||||
|
public int hashCode() { |
||||
|
final int prime = 31; |
||||
|
int result = 1; |
||||
|
result = prime * result + ((level == null) ? 0 : level.hashCode()); |
||||
|
result = prime * result + ((modelId == null) ? 0 : modelId.hashCode()); |
||||
|
result = prime * result + ((validateDate == null) ? 0 : validateDate.hashCode()); |
||||
|
return result; |
||||
|
} |
||||
|
@Override |
||||
|
public boolean equals(Object obj) { |
||||
|
if (this == obj) |
||||
|
return true; |
||||
|
if (obj == null) |
||||
|
return false; |
||||
|
if (getClass() != obj.getClass()) |
||||
|
return false; |
||||
|
CoeChiSquareHistoryId other = (CoeChiSquareHistoryId) obj; |
||||
|
if (level == null) { |
||||
|
if (other.level != null) |
||||
|
return false; |
||||
|
} else if (!level.equals(other.level)) |
||||
|
return false; |
||||
|
if (modelId == null) { |
||||
|
if (other.modelId != null) |
||||
|
return false; |
||||
|
} else if (!modelId.equals(other.modelId)) |
||||
|
return false; |
||||
|
if (validateDate == null) { |
||||
|
if (other.validateDate != null) |
||||
|
return false; |
||||
|
} else if (!validateDate.equals(other.validateDate)) |
||||
|
return false; |
||||
|
return true; |
||||
|
} |
||||
|
|
||||
|
} |
@ -0,0 +1,53 @@ |
|||||
|
package io.sc.engine.mv.jpa.entity.id; |
||||
|
|
||||
|
import java.io.Serializable; |
||||
|
|
||||
|
public class GeneralResultHistoryId implements Serializable{ |
||||
|
private static final long serialVersionUID = -6831606643821339120L; |
||||
|
private String validateDate; |
||||
|
private String modelId; |
||||
|
|
||||
|
public String getValidateDate() { |
||||
|
return validateDate; |
||||
|
} |
||||
|
public void setValidateDate(String validateDate) { |
||||
|
this.validateDate = validateDate; |
||||
|
} |
||||
|
public String getModelId() { |
||||
|
return modelId; |
||||
|
} |
||||
|
public void setModelId(String modelId) { |
||||
|
this.modelId = modelId; |
||||
|
} |
||||
|
@Override |
||||
|
public int hashCode() { |
||||
|
final int prime = 31; |
||||
|
int result = 1; |
||||
|
result = prime * result + ((modelId == null) ? 0 : modelId.hashCode()); |
||||
|
result = prime * result + ((validateDate == null) ? 0 : validateDate.hashCode()); |
||||
|
return result; |
||||
|
} |
||||
|
@Override |
||||
|
public boolean equals(Object obj) { |
||||
|
if (this == obj) |
||||
|
return true; |
||||
|
if (obj == null) |
||||
|
return false; |
||||
|
if (getClass() != obj.getClass()) |
||||
|
return false; |
||||
|
GeneralResultHistoryId other = (GeneralResultHistoryId) obj; |
||||
|
|
||||
|
if (modelId == null) { |
||||
|
if (other.modelId != null) |
||||
|
return false; |
||||
|
} else if (!modelId.equals(other.modelId)) |
||||
|
return false; |
||||
|
if (validateDate == null) { |
||||
|
if (other.validateDate != null) |
||||
|
return false; |
||||
|
} else if (!validateDate.equals(other.validateDate)) |
||||
|
return false; |
||||
|
return true; |
||||
|
} |
||||
|
|
||||
|
} |
@ -0,0 +1,93 @@ |
|||||
|
package io.sc.engine.mv.jpa.entity.id; |
||||
|
|
||||
|
import java.io.Serializable; |
||||
|
import java.util.Date; |
||||
|
|
||||
|
public class GeneralSampleHistoryId implements Serializable{ |
||||
|
private static final long serialVersionUID = -1449379762137544415L; |
||||
|
private String validateDate; |
||||
|
private String customId; |
||||
|
private String modelId; |
||||
|
private Date beginDate; |
||||
|
private Date endDate; |
||||
|
|
||||
|
public String getValidateDate() { |
||||
|
return validateDate; |
||||
|
} |
||||
|
public void setValidateDate(String validateDate) { |
||||
|
this.validateDate = validateDate; |
||||
|
} |
||||
|
public String getCustomId() { |
||||
|
return customId; |
||||
|
} |
||||
|
public void setCustomId(String customId) { |
||||
|
this.customId = customId; |
||||
|
} |
||||
|
public String getModelId() { |
||||
|
return modelId; |
||||
|
} |
||||
|
public void setModelId(String modelId) { |
||||
|
this.modelId = modelId; |
||||
|
} |
||||
|
public Date getBeginDate() { |
||||
|
return beginDate; |
||||
|
} |
||||
|
public void setBeginDate(Date beginDate) { |
||||
|
this.beginDate = beginDate; |
||||
|
} |
||||
|
public Date getEndDate() { |
||||
|
return endDate; |
||||
|
} |
||||
|
public void setEndDate(Date endDate) { |
||||
|
this.endDate = endDate; |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public int hashCode() { |
||||
|
final int prime = 31; |
||||
|
int result = 1; |
||||
|
result = prime * result + ((beginDate == null) ? 0 : beginDate.hashCode()); |
||||
|
result = prime * result + ((customId == null) ? 0 : customId.hashCode()); |
||||
|
result = prime * result + ((endDate == null) ? 0 : endDate.hashCode()); |
||||
|
result = prime * result + ((modelId == null) ? 0 : modelId.hashCode()); |
||||
|
result = prime * result + ((validateDate == null) ? 0 : validateDate.hashCode()); |
||||
|
return result; |
||||
|
} |
||||
|
@Override |
||||
|
public boolean equals(Object obj) { |
||||
|
if (this == obj) |
||||
|
return true; |
||||
|
if (obj == null) |
||||
|
return false; |
||||
|
if (getClass() != obj.getClass()) |
||||
|
return false; |
||||
|
GeneralSampleHistoryId other = (GeneralSampleHistoryId) obj; |
||||
|
if (beginDate == null) { |
||||
|
if (other.beginDate != null) |
||||
|
return false; |
||||
|
} else if (!beginDate.equals(other.beginDate)) |
||||
|
return false; |
||||
|
if (customId == null) { |
||||
|
if (other.customId != null) |
||||
|
return false; |
||||
|
} else if (!customId.equals(other.customId)) |
||||
|
return false; |
||||
|
if (endDate == null) { |
||||
|
if (other.endDate != null) |
||||
|
return false; |
||||
|
} else if (!endDate.equals(other.endDate)) |
||||
|
return false; |
||||
|
if (modelId == null) { |
||||
|
if (other.modelId != null) |
||||
|
return false; |
||||
|
} else if (!modelId.equals(other.modelId)) |
||||
|
return false; |
||||
|
if (validateDate == null) { |
||||
|
if (other.validateDate != null) |
||||
|
return false; |
||||
|
} else if (!validateDate.equals(other.validateDate)) |
||||
|
return false; |
||||
|
return true; |
||||
|
} |
||||
|
|
||||
|
} |
@ -0,0 +1,79 @@ |
|||||
|
package io.sc.engine.mv.jpa.entity.id; |
||||
|
|
||||
|
import java.io.Serializable; |
||||
|
|
||||
|
public class StPsiHistoryId implements Serializable{ |
||||
|
private static final long serialVersionUID = -6358520753599342392L; |
||||
|
private String validateDate; |
||||
|
private String modelId; |
||||
|
private Double scoreSegStart; |
||||
|
private Double scoreSegEnd; |
||||
|
|
||||
|
public String getValidateDate() { |
||||
|
return validateDate; |
||||
|
} |
||||
|
public void setValidateDate(String validateDate) { |
||||
|
this.validateDate = validateDate; |
||||
|
} |
||||
|
public String getModelId() { |
||||
|
return modelId; |
||||
|
} |
||||
|
public void setModelId(String modelId) { |
||||
|
this.modelId = modelId; |
||||
|
} |
||||
|
public Double getScoreSegStart() { |
||||
|
return scoreSegStart; |
||||
|
} |
||||
|
public void setScoreSegStart(Double scoreSegStart) { |
||||
|
this.scoreSegStart = scoreSegStart; |
||||
|
} |
||||
|
public Double getScoreSegEnd() { |
||||
|
return scoreSegEnd; |
||||
|
} |
||||
|
public void setScoreSegEnd(Double scoreSegEnd) { |
||||
|
this.scoreSegEnd = scoreSegEnd; |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public int hashCode() { |
||||
|
final int prime = 31; |
||||
|
int result = 1; |
||||
|
result = prime * result + ((modelId == null) ? 0 : modelId.hashCode()); |
||||
|
result = prime * result + ((scoreSegEnd == null) ? 0 : scoreSegEnd.hashCode()); |
||||
|
result = prime * result + ((scoreSegStart == null) ? 0 : scoreSegStart.hashCode()); |
||||
|
result = prime * result + ((validateDate == null) ? 0 : validateDate.hashCode()); |
||||
|
return result; |
||||
|
} |
||||
|
@Override |
||||
|
public boolean equals(Object obj) { |
||||
|
if (this == obj) |
||||
|
return true; |
||||
|
if (obj == null) |
||||
|
return false; |
||||
|
if (getClass() != obj.getClass()) |
||||
|
return false; |
||||
|
StPsiHistoryId other = (StPsiHistoryId) obj; |
||||
|
if (modelId == null) { |
||||
|
if (other.modelId != null) |
||||
|
return false; |
||||
|
} else if (!modelId.equals(other.modelId)) |
||||
|
return false; |
||||
|
if (scoreSegEnd == null) { |
||||
|
if (other.scoreSegEnd != null) |
||||
|
return false; |
||||
|
} else if (!scoreSegEnd.equals(other.scoreSegEnd)) |
||||
|
return false; |
||||
|
if (scoreSegStart == null) { |
||||
|
if (other.scoreSegStart != null) |
||||
|
return false; |
||||
|
} else if (!scoreSegStart.equals(other.scoreSegStart)) |
||||
|
return false; |
||||
|
if (validateDate == null) { |
||||
|
if (other.validateDate != null) |
||||
|
return false; |
||||
|
} else if (!validateDate.equals(other.validateDate)) |
||||
|
return false; |
||||
|
return true; |
||||
|
} |
||||
|
|
||||
|
} |
@ -0,0 +1,10 @@ |
|||||
|
package io.sc.engine.mv.jpa.repository; |
||||
|
|
||||
|
|
||||
|
import io.sc.engine.mv.jpa.entity.CoeBinomialHistory; |
||||
|
import io.sc.engine.mv.jpa.entity.id.CoeBinomialHistoryId; |
||||
|
import io.sc.platform.orm.repository.DaoRepository; |
||||
|
|
||||
|
public interface CoeBinomialHistoryRepository extends DaoRepository<CoeBinomialHistory, CoeBinomialHistoryId> { |
||||
|
|
||||
|
} |
@ -0,0 +1,10 @@ |
|||||
|
package io.sc.engine.mv.jpa.repository; |
||||
|
|
||||
|
|
||||
|
import io.sc.engine.mv.jpa.entity.CoeChiSquareHistory; |
||||
|
import io.sc.engine.mv.jpa.entity.id.CoeChiSquareHistoryId; |
||||
|
import io.sc.platform.orm.repository.DaoRepository; |
||||
|
|
||||
|
public interface CoeChiSquareHistoryRepository extends DaoRepository<CoeChiSquareHistory, CoeChiSquareHistoryId> { |
||||
|
|
||||
|
} |
@ -0,0 +1,40 @@ |
|||||
|
package io.sc.engine.mv.jpa.repository; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
import io.sc.engine.mv.jpa.entity.GeneralResultHistory; |
||||
|
import io.sc.engine.mv.jpa.entity.id.GeneralResultHistoryId; |
||||
|
import io.sc.platform.orm.repository.DaoRepository; |
||||
|
import org.springframework.data.jpa.repository.Query; |
||||
|
|
||||
|
public interface GeneralResultHistoryRepository extends DaoRepository<GeneralResultHistory, GeneralResultHistoryId> { |
||||
|
|
||||
|
/** |
||||
|
* 根据验证日期查找模型验证结果摘要信息列表 |
||||
|
* @param validateDate 模型验证日期 |
||||
|
* @return 模型验证结果摘要信息列表 |
||||
|
*/ |
||||
|
public List<GeneralResultHistory> findByValidateDate(String validateDate); |
||||
|
|
||||
|
/** |
||||
|
* 获取模型验证结果摘要信息包含的所有验证日期 |
||||
|
* @return 模型验证结果摘要信息包含的所有验证日期 |
||||
|
*/ |
||||
|
@Query("select distinct e.validateDate from GeneralResultHistory e order by e.validateDate desc") |
||||
|
public List<String> findDistinctValidateDates(); |
||||
|
|
||||
|
/** |
||||
|
* 获取模型验证结果摘要信息包含的所有模型标示和名称 |
||||
|
* @return 模型验证结果摘要信息包含的所有模型标示和名称 |
||||
|
*/ |
||||
|
@Query("select e.modelId,max(e.modelName) from GeneralResultHistory e group by e.modelId") |
||||
|
public List<Object[]> findDistinctModelIdAndNames(); |
||||
|
|
||||
|
/** |
||||
|
* 获取模型验证结果 |
||||
|
* @param modelId 模型标识 |
||||
|
* @param validateDate 模型验证日期 |
||||
|
* @return 模型验证结果 |
||||
|
*/ |
||||
|
public GeneralResultHistory findByModelIdAndValidateDate(String modelId,String validateDate); |
||||
|
} |
@ -0,0 +1,20 @@ |
|||||
|
package io.sc.engine.mv.jpa.repository; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
import io.sc.engine.mv.jpa.entity.StPsiHistory; |
||||
|
import io.sc.engine.mv.jpa.entity.id.StPsiHistoryId; |
||||
|
import io.sc.platform.orm.repository.DaoRepository; |
||||
|
import org.springframework.data.domain.Page; |
||||
|
import org.springframework.data.domain.Pageable; |
||||
|
import org.springframework.data.jpa.repository.Query; |
||||
|
|
||||
|
public interface StPsiHistoryRepository extends DaoRepository<StPsiHistory, StPsiHistoryId> { |
||||
|
public Page<StPsiHistory> findAllByValidateDate(String validateDate,Pageable pageable); |
||||
|
|
||||
|
@Query("select distinct e.validateDate from StPsiHistory e order by e.validateDate desc") |
||||
|
public List<String> findDistinctValidateDates(); |
||||
|
|
||||
|
@Query("select e.modelId,max(e.modelName) from StPsiHistory e group by e.modelId") |
||||
|
public List<Object[]> findDistinctModelIdAndNames(); |
||||
|
} |
@ -0,0 +1,89 @@ |
|||||
|
package io.sc.engine.mv.sc.echarts; |
||||
|
|
||||
|
import java.math.BigDecimal; |
||||
|
import java.math.RoundingMode; |
||||
|
import java.util.ArrayList; |
||||
|
import java.util.List; |
||||
|
|
||||
|
import org.springframework.util.StringUtils; |
||||
|
|
||||
|
public class Coordinates { |
||||
|
private List<BigDecimal> xs =new ArrayList<BigDecimal>(); |
||||
|
private List<BigDecimal> y1s =new ArrayList<BigDecimal>(); |
||||
|
private List<BigDecimal> y2s =new ArrayList<BigDecimal>(); |
||||
|
|
||||
|
public void add(BigDecimal x, BigDecimal y1){ |
||||
|
this.xs.add(x==null?new BigDecimal(0):x); |
||||
|
this.y1s.add(y1==null?new BigDecimal(0):y1); |
||||
|
} |
||||
|
|
||||
|
public void add(BigDecimal x, BigDecimal y1, BigDecimal y2){ |
||||
|
this.xs.add(x==null?new BigDecimal(0):x); |
||||
|
this.y1s.add(y1==null?new BigDecimal(0):y1); |
||||
|
this.y2s.add(y2==null?new BigDecimal(0):y2); |
||||
|
} |
||||
|
|
||||
|
public void setScale(int newScale){ |
||||
|
setScale("x",newScale,RoundingMode.HALF_UP); |
||||
|
setScale("y1",newScale,RoundingMode.HALF_UP); |
||||
|
setScale("y2",newScale,RoundingMode.HALF_UP); |
||||
|
} |
||||
|
|
||||
|
public void setScale(int newScale, RoundingMode roundingMode){ |
||||
|
setScale("x",newScale,roundingMode); |
||||
|
setScale("y1",newScale,roundingMode); |
||||
|
setScale("y2",newScale,roundingMode); |
||||
|
} |
||||
|
|
||||
|
public void setScale(String axis,int newScale){ |
||||
|
setScale(axis,newScale,RoundingMode.HALF_UP); |
||||
|
} |
||||
|
|
||||
|
public void setScale(String axis,int newScale, RoundingMode roundingMode){ |
||||
|
if(StringUtils.hasText(axis)){ |
||||
|
if("x".equalsIgnoreCase(axis)){ |
||||
|
List<BigDecimal> _xs =new ArrayList<BigDecimal>(); |
||||
|
for(BigDecimal x : xs){ |
||||
|
_xs.add(x.setScale(newScale, roundingMode)); |
||||
|
} |
||||
|
xs =_xs; |
||||
|
}else if("y".equalsIgnoreCase(axis) || "y1".equalsIgnoreCase(axis)){ |
||||
|
List<BigDecimal> _y1s =new ArrayList<BigDecimal>(); |
||||
|
for(BigDecimal y : y1s){ |
||||
|
_y1s.add(y.setScale(newScale, roundingMode)); |
||||
|
} |
||||
|
y1s =_y1s; |
||||
|
}else if("y2".equalsIgnoreCase(axis)){ |
||||
|
List<BigDecimal> _y2s =new ArrayList<BigDecimal>(); |
||||
|
for(BigDecimal y : y2s){ |
||||
|
_y2s.add(y.setScale(newScale, roundingMode)); |
||||
|
} |
||||
|
y2s =_y2s; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
public List<BigDecimal> getXs() { |
||||
|
return xs; |
||||
|
} |
||||
|
|
||||
|
public void setXs(List<BigDecimal> xs) { |
||||
|
this.xs = xs; |
||||
|
} |
||||
|
|
||||
|
public List<BigDecimal> getY1s() { |
||||
|
return y1s; |
||||
|
} |
||||
|
|
||||
|
public void setY1s(List<BigDecimal> y1s) { |
||||
|
this.y1s = y1s; |
||||
|
} |
||||
|
|
||||
|
public List<BigDecimal> getY2s() { |
||||
|
return y2s; |
||||
|
} |
||||
|
|
||||
|
public void setY2s(List<BigDecimal> y2s) { |
||||
|
this.y2s = y2s; |
||||
|
} |
||||
|
} |
@ -0,0 +1,40 @@ |
|||||
|
package io.sc.engine.mv.sc.echarts; |
||||
|
|
||||
|
import java.util.ArrayList; |
||||
|
import java.util.List; |
||||
|
|
||||
|
public class XyCoordinates<T> { |
||||
|
private List<String> xs =new ArrayList<String>(); |
||||
|
private List<T> y1s =new ArrayList<T>(); |
||||
|
private List<T> y2s =new ArrayList<T>(); |
||||
|
|
||||
|
public void add(String x, T y1, T y2){ |
||||
|
this.xs.add(x==null?"":x); |
||||
|
this.y1s.add(y1); |
||||
|
this.y2s.add(y2); |
||||
|
} |
||||
|
|
||||
|
public List<String> getXs() { |
||||
|
return xs; |
||||
|
} |
||||
|
|
||||
|
public void setXs(List<String> xs) { |
||||
|
this.xs = xs; |
||||
|
} |
||||
|
|
||||
|
public List<T> getY1s() { |
||||
|
return y1s; |
||||
|
} |
||||
|
|
||||
|
public void setY1s(List<T> y1s) { |
||||
|
this.y1s = y1s; |
||||
|
} |
||||
|
|
||||
|
public List<T> getY2s() { |
||||
|
return y2s; |
||||
|
} |
||||
|
|
||||
|
public void setY2s(List<T> y2s) { |
||||
|
this.y2s = y2s; |
||||
|
} |
||||
|
} |
@ -0,0 +1,11 @@ |
|||||
|
package io.sc.engine.mv.service.result; |
||||
|
|
||||
|
|
||||
|
import io.sc.engine.mv.jpa.entity.GeneralResultHistory; |
||||
|
import io.sc.engine.mv.jpa.entity.id.GeneralResultHistoryId; |
||||
|
import io.sc.engine.mv.jpa.repository.GeneralResultHistoryRepository; |
||||
|
import io.sc.platform.orm.service.DaoService; |
||||
|
|
||||
|
public interface GeneralResultHistoryService extends DaoService<GeneralResultHistory, GeneralResultHistoryId, GeneralResultHistoryRepository> { |
||||
|
|
||||
|
} |
@ -0,0 +1,13 @@ |
|||||
|
package io.sc.engine.mv.service.result.impl; |
||||
|
|
||||
|
import io.sc.engine.mv.jpa.entity.GeneralResultHistory; |
||||
|
import io.sc.engine.mv.jpa.entity.id.GeneralResultHistoryId; |
||||
|
import io.sc.engine.mv.jpa.repository.GeneralResultHistoryRepository; |
||||
|
import io.sc.engine.mv.service.result.GeneralResultHistoryService; |
||||
|
import io.sc.platform.orm.service.impl.DaoServiceImpl; |
||||
|
import org.springframework.stereotype.Service; |
||||
|
|
||||
|
@Service |
||||
|
public class GeneralResultHistoryServiceImpl extends DaoServiceImpl<GeneralResultHistory, GeneralResultHistoryId, GeneralResultHistoryRepository> implements GeneralResultHistoryService { |
||||
|
|
||||
|
} |
@ -0,0 +1,11 @@ |
|||||
|
package io.sc.engine.mv.service.st; |
||||
|
|
||||
|
|
||||
|
import io.sc.engine.mv.jpa.entity.StPsiHistory; |
||||
|
import io.sc.engine.mv.jpa.entity.id.StPsiHistoryId; |
||||
|
import io.sc.engine.mv.jpa.repository.StPsiHistoryRepository; |
||||
|
import io.sc.platform.orm.service.DaoService; |
||||
|
|
||||
|
public interface StPsiHistoryService extends DaoService<StPsiHistory, StPsiHistoryId, StPsiHistoryRepository> { |
||||
|
|
||||
|
} |
@ -0,0 +1,5 @@ |
|||||
|
package io.sc.engine.mv.service.st; |
||||
|
|
||||
|
public interface StSvdService { |
||||
|
|
||||
|
} |
@ -0,0 +1,13 @@ |
|||||
|
package io.sc.engine.mv.service.st.impl; |
||||
|
|
||||
|
import io.sc.engine.mv.jpa.entity.StPsiHistory; |
||||
|
import io.sc.engine.mv.jpa.entity.id.StPsiHistoryId; |
||||
|
import io.sc.engine.mv.jpa.repository.StPsiHistoryRepository; |
||||
|
import io.sc.engine.mv.service.st.StPsiHistoryService; |
||||
|
import io.sc.platform.orm.service.impl.DaoServiceImpl; |
||||
|
import org.springframework.stereotype.Service; |
||||
|
|
||||
|
@Service |
||||
|
public class StPsiHistoryServiceImpl extends DaoServiceImpl<StPsiHistory, StPsiHistoryId, StPsiHistoryRepository> implements StPsiHistoryService { |
||||
|
|
||||
|
} |
@ -0,0 +1,8 @@ |
|||||
|
package io.sc.engine.mv.service.st.impl; |
||||
|
|
||||
|
|
||||
|
import io.sc.engine.mv.service.st.StSvdService; |
||||
|
|
||||
|
public class StSvdServiceImpl implements StSvdService { |
||||
|
|
||||
|
} |
@ -0,0 +1,159 @@ |
|||||
|
package io.sc.engine.mv.vo; |
||||
|
|
||||
|
import io.sc.platform.orm.api.vo.BaseVo; |
||||
|
|
||||
|
public class CoeBinomialHistoryVo extends BaseVo { |
||||
|
private String validateDate; |
||||
|
private String modelId; |
||||
|
private String modelName; |
||||
|
private String level; |
||||
|
private Double pd; |
||||
|
private Long count; |
||||
|
private Long defaultCount; |
||||
|
private Double ndAvg; |
||||
|
private Double ndSd; |
||||
|
private Double sl; |
||||
|
private Double cl; |
||||
|
private Double zUpper; |
||||
|
private Double zLower; |
||||
|
private Double dUpper; |
||||
|
private Double dLower; |
||||
|
private Double leUpper; |
||||
|
private Double geLower; |
||||
|
|
||||
|
public String getValidateDate() { |
||||
|
return validateDate; |
||||
|
} |
||||
|
|
||||
|
public void setValidateDate(String validateDate) { |
||||
|
this.validateDate = validateDate; |
||||
|
} |
||||
|
|
||||
|
public String getModelId() { |
||||
|
return modelId; |
||||
|
} |
||||
|
|
||||
|
public void setModelId(String modelId) { |
||||
|
this.modelId = modelId; |
||||
|
} |
||||
|
|
||||
|
public String getModelName() { |
||||
|
return modelName; |
||||
|
} |
||||
|
|
||||
|
public void setModelName(String modelName) { |
||||
|
this.modelName = modelName; |
||||
|
} |
||||
|
|
||||
|
public String getLevel() { |
||||
|
return level; |
||||
|
} |
||||
|
|
||||
|
public void setLevel(String level) { |
||||
|
this.level = level; |
||||
|
} |
||||
|
|
||||
|
public Double getPd() { |
||||
|
return pd; |
||||
|
} |
||||
|
|
||||
|
public void setPd(Double pd) { |
||||
|
this.pd = pd; |
||||
|
} |
||||
|
|
||||
|
public Long getCount() { |
||||
|
return count; |
||||
|
} |
||||
|
|
||||
|
public void setCount(Long count) { |
||||
|
this.count = count; |
||||
|
} |
||||
|
|
||||
|
public Long getDefaultCount() { |
||||
|
return defaultCount; |
||||
|
} |
||||
|
|
||||
|
public void setDefaultCount(Long defaultCount) { |
||||
|
this.defaultCount = defaultCount; |
||||
|
} |
||||
|
|
||||
|
public Double getNdAvg() { |
||||
|
return ndAvg; |
||||
|
} |
||||
|
|
||||
|
public void setNdAvg(Double ndAvg) { |
||||
|
this.ndAvg = ndAvg; |
||||
|
} |
||||
|
|
||||
|
public Double getNdSd() { |
||||
|
return ndSd; |
||||
|
} |
||||
|
|
||||
|
public void setNdSd(Double ndSd) { |
||||
|
this.ndSd = ndSd; |
||||
|
} |
||||
|
|
||||
|
public Double getSl() { |
||||
|
return sl; |
||||
|
} |
||||
|
|
||||
|
public void setSl(Double sl) { |
||||
|
this.sl = sl; |
||||
|
} |
||||
|
|
||||
|
public Double getCl() { |
||||
|
return cl; |
||||
|
} |
||||
|
|
||||
|
public void setCl(Double cl) { |
||||
|
this.cl = cl; |
||||
|
} |
||||
|
|
||||
|
public Double getzUpper() { |
||||
|
return zUpper; |
||||
|
} |
||||
|
|
||||
|
public void setzUpper(Double zUpper) { |
||||
|
this.zUpper = zUpper; |
||||
|
} |
||||
|
|
||||
|
public Double getzLower() { |
||||
|
return zLower; |
||||
|
} |
||||
|
|
||||
|
public void setzLower(Double zLower) { |
||||
|
this.zLower = zLower; |
||||
|
} |
||||
|
|
||||
|
public Double getdUpper() { |
||||
|
return dUpper; |
||||
|
} |
||||
|
|
||||
|
public void setdUpper(Double dUpper) { |
||||
|
this.dUpper = dUpper; |
||||
|
} |
||||
|
|
||||
|
public Double getdLower() { |
||||
|
return dLower; |
||||
|
} |
||||
|
|
||||
|
public void setdLower(Double dLower) { |
||||
|
this.dLower = dLower; |
||||
|
} |
||||
|
|
||||
|
public Double getLeUpper() { |
||||
|
return leUpper; |
||||
|
} |
||||
|
|
||||
|
public void setLeUpper(Double leUpper) { |
||||
|
this.leUpper = leUpper; |
||||
|
} |
||||
|
|
||||
|
public Double getGeLower() { |
||||
|
return geLower; |
||||
|
} |
||||
|
|
||||
|
public void setGeLower(Double geLower) { |
||||
|
this.geLower = geLower; |
||||
|
} |
||||
|
} |
@ -0,0 +1,79 @@ |
|||||
|
package io.sc.engine.mv.vo; |
||||
|
|
||||
|
|
||||
|
import io.sc.platform.orm.api.vo.BaseVo; |
||||
|
|
||||
|
public class CoeChiSquareHistoryVo extends BaseVo { |
||||
|
private String validateDate; |
||||
|
private String modelId; |
||||
|
private String modelName; |
||||
|
private String level; |
||||
|
private Double pd; |
||||
|
private Long count; |
||||
|
private Long defaultCount; |
||||
|
private Double chiSquare; |
||||
|
|
||||
|
public String getValidateDate() { |
||||
|
return validateDate; |
||||
|
} |
||||
|
|
||||
|
public void setValidateDate(String validateDate) { |
||||
|
this.validateDate = validateDate; |
||||
|
} |
||||
|
|
||||
|
public String getModelId() { |
||||
|
return modelId; |
||||
|
} |
||||
|
|
||||
|
public void setModelId(String modelId) { |
||||
|
this.modelId = modelId; |
||||
|
} |
||||
|
|
||||
|
public String getModelName() { |
||||
|
return modelName; |
||||
|
} |
||||
|
|
||||
|
public void setModelName(String modelName) { |
||||
|
this.modelName = modelName; |
||||
|
} |
||||
|
|
||||
|
public String getLevel() { |
||||
|
return level; |
||||
|
} |
||||
|
|
||||
|
public void setLevel(String level) { |
||||
|
this.level = level; |
||||
|
} |
||||
|
|
||||
|
public Double getPd() { |
||||
|
return pd; |
||||
|
} |
||||
|
|
||||
|
public void setPd(Double pd) { |
||||
|
this.pd = pd; |
||||
|
} |
||||
|
|
||||
|
public Long getCount() { |
||||
|
return count; |
||||
|
} |
||||
|
|
||||
|
public void setCount(Long count) { |
||||
|
this.count = count; |
||||
|
} |
||||
|
|
||||
|
public Long getDefaultCount() { |
||||
|
return defaultCount; |
||||
|
} |
||||
|
|
||||
|
public void setDefaultCount(Long defaultCount) { |
||||
|
this.defaultCount = defaultCount; |
||||
|
} |
||||
|
|
||||
|
public Double getChiSquare() { |
||||
|
return chiSquare; |
||||
|
} |
||||
|
|
||||
|
public void setChiSquare(Double chiSquare) { |
||||
|
this.chiSquare = chiSquare; |
||||
|
} |
||||
|
} |
@ -0,0 +1,196 @@ |
|||||
|
package io.sc.engine.mv.vo; |
||||
|
|
||||
|
import io.sc.engine.mv.CoeResult; |
||||
|
import io.sc.engine.mv.ExecuteMode; |
||||
|
import io.sc.engine.mv.jpa.entity.RuntimeParameter; |
||||
|
import io.sc.platform.orm.api.vo.BaseVo; |
||||
|
|
||||
|
import javax.persistence.Transient; |
||||
|
import java.util.ArrayList; |
||||
|
import java.util.List; |
||||
|
|
||||
|
public class GeneralResultHistoryVo extends BaseVo { |
||||
|
private String validateDate; |
||||
|
private String modelId; |
||||
|
private String modelName; |
||||
|
private ExecuteMode executeMode; |
||||
|
private Long totalSampleCount; |
||||
|
private Long defaultSampleCount; |
||||
|
private Double auc; |
||||
|
private Double aucQuantitative; |
||||
|
private Double aucQualitative; |
||||
|
private Double ar; |
||||
|
private Double arQuantitative; |
||||
|
private Double arQualitative; |
||||
|
private Double ks; |
||||
|
private Double ksQuantitative; |
||||
|
private Double ksQualitative; |
||||
|
private Double svd; |
||||
|
private Double psi; |
||||
|
private CoeResult chiSquare; |
||||
|
private CoeResult binomial; |
||||
|
|
||||
|
//模型验证执行时参数配置
|
||||
|
@Transient |
||||
|
private List<RuntimeParameter> runtimeParameters =new ArrayList<RuntimeParameter>(); |
||||
|
|
||||
|
public String getValidateDate() { |
||||
|
return validateDate; |
||||
|
} |
||||
|
|
||||
|
public void setValidateDate(String validateDate) { |
||||
|
this.validateDate = validateDate; |
||||
|
} |
||||
|
|
||||
|
public String getModelId() { |
||||
|
return modelId; |
||||
|
} |
||||
|
|
||||
|
public void setModelId(String modelId) { |
||||
|
this.modelId = modelId; |
||||
|
} |
||||
|
|
||||
|
public String getModelName() { |
||||
|
return modelName; |
||||
|
} |
||||
|
|
||||
|
public void setModelName(String modelName) { |
||||
|
this.modelName = modelName; |
||||
|
} |
||||
|
|
||||
|
public ExecuteMode getExecuteMode() { |
||||
|
return executeMode; |
||||
|
} |
||||
|
|
||||
|
public void setExecuteMode(ExecuteMode executeMode) { |
||||
|
this.executeMode = executeMode; |
||||
|
} |
||||
|
|
||||
|
public Long getTotalSampleCount() { |
||||
|
return totalSampleCount; |
||||
|
} |
||||
|
|
||||
|
public void setTotalSampleCount(Long totalSampleCount) { |
||||
|
this.totalSampleCount = totalSampleCount; |
||||
|
} |
||||
|
|
||||
|
public Long getDefaultSampleCount() { |
||||
|
return defaultSampleCount; |
||||
|
} |
||||
|
|
||||
|
public void setDefaultSampleCount(Long defaultSampleCount) { |
||||
|
this.defaultSampleCount = defaultSampleCount; |
||||
|
} |
||||
|
|
||||
|
public Double getAuc() { |
||||
|
return auc; |
||||
|
} |
||||
|
|
||||
|
public void setAuc(Double auc) { |
||||
|
this.auc = auc; |
||||
|
} |
||||
|
|
||||
|
public Double getAucQuantitative() { |
||||
|
return aucQuantitative; |
||||
|
} |
||||
|
|
||||
|
public void setAucQuantitative(Double aucQuantitative) { |
||||
|
this.aucQuantitative = aucQuantitative; |
||||
|
} |
||||
|
|
||||
|
public Double getAucQualitative() { |
||||
|
return aucQualitative; |
||||
|
} |
||||
|
|
||||
|
public void setAucQualitative(Double aucQualitative) { |
||||
|
this.aucQualitative = aucQualitative; |
||||
|
} |
||||
|
|
||||
|
public Double getAr() { |
||||
|
return ar; |
||||
|
} |
||||
|
|
||||
|
public void setAr(Double ar) { |
||||
|
this.ar = ar; |
||||
|
} |
||||
|
|
||||
|
public Double getArQuantitative() { |
||||
|
return arQuantitative; |
||||
|
} |
||||
|
|
||||
|
public void setArQuantitative(Double arQuantitative) { |
||||
|
this.arQuantitative = arQuantitative; |
||||
|
} |
||||
|
|
||||
|
public Double getArQualitative() { |
||||
|
return arQualitative; |
||||
|
} |
||||
|
|
||||
|
public void setArQualitative(Double arQualitative) { |
||||
|
this.arQualitative = arQualitative; |
||||
|
} |
||||
|
|
||||
|
public Double getKs() { |
||||
|
return ks; |
||||
|
} |
||||
|
|
||||
|
public void setKs(Double ks) { |
||||
|
this.ks = ks; |
||||
|
} |
||||
|
|
||||
|
public Double getKsQuantitative() { |
||||
|
return ksQuantitative; |
||||
|
} |
||||
|
|
||||
|
public void setKsQuantitative(Double ksQuantitative) { |
||||
|
this.ksQuantitative = ksQuantitative; |
||||
|
} |
||||
|
|
||||
|
public Double getKsQualitative() { |
||||
|
return ksQualitative; |
||||
|
} |
||||
|
|
||||
|
public void setKsQualitative(Double ksQualitative) { |
||||
|
this.ksQualitative = ksQualitative; |
||||
|
} |
||||
|
|
||||
|
public Double getSvd() { |
||||
|
return svd; |
||||
|
} |
||||
|
|
||||
|
public void setSvd(Double svd) { |
||||
|
this.svd = svd; |
||||
|
} |
||||
|
|
||||
|
public Double getPsi() { |
||||
|
return psi; |
||||
|
} |
||||
|
|
||||
|
public void setPsi(Double psi) { |
||||
|
this.psi = psi; |
||||
|
} |
||||
|
|
||||
|
public CoeResult getChiSquare() { |
||||
|
return chiSquare; |
||||
|
} |
||||
|
|
||||
|
public void setChiSquare(CoeResult chiSquare) { |
||||
|
this.chiSquare = chiSquare; |
||||
|
} |
||||
|
|
||||
|
public CoeResult getBinomial() { |
||||
|
return binomial; |
||||
|
} |
||||
|
|
||||
|
public void setBinomial(CoeResult binomial) { |
||||
|
this.binomial = binomial; |
||||
|
} |
||||
|
|
||||
|
public List<RuntimeParameter> getRuntimeParameters() { |
||||
|
return runtimeParameters; |
||||
|
} |
||||
|
|
||||
|
public void setRuntimeParameters(List<RuntimeParameter> runtimeParameters) { |
||||
|
this.runtimeParameters = runtimeParameters; |
||||
|
} |
||||
|
} |
@ -0,0 +1,142 @@ |
|||||
|
package io.sc.engine.mv.vo; |
||||
|
|
||||
|
|
||||
|
import io.sc.platform.orm.api.vo.BaseVo; |
||||
|
|
||||
|
public class StPsiHistoryVo extends BaseVo { |
||||
|
private String validateDate; |
||||
|
private String modelId; |
||||
|
private String modelName; |
||||
|
private Double scoreSegStart; |
||||
|
private Double scoreSegEnd; |
||||
|
private Long countDev; |
||||
|
private Long totalCountDev; |
||||
|
private Double percentDev; |
||||
|
private Long countApp; |
||||
|
private Long totalCountApp; |
||||
|
private Double percentApp; |
||||
|
private Double percentDiff; |
||||
|
private Double percentRate; |
||||
|
private Double weight; |
||||
|
private Double stWeight; |
||||
|
|
||||
|
public String getValidateDate() { |
||||
|
return validateDate; |
||||
|
} |
||||
|
|
||||
|
public void setValidateDate(String validateDate) { |
||||
|
this.validateDate = validateDate; |
||||
|
} |
||||
|
|
||||
|
public String getModelId() { |
||||
|
return modelId; |
||||
|
} |
||||
|
|
||||
|
public void setModelId(String modelId) { |
||||
|
this.modelId = modelId; |
||||
|
} |
||||
|
|
||||
|
public String getModelName() { |
||||
|
return modelName; |
||||
|
} |
||||
|
|
||||
|
public void setModelName(String modelName) { |
||||
|
this.modelName = modelName; |
||||
|
} |
||||
|
|
||||
|
public Double getScoreSegStart() { |
||||
|
return scoreSegStart; |
||||
|
} |
||||
|
|
||||
|
public void setScoreSegStart(Double scoreSegStart) { |
||||
|
this.scoreSegStart = scoreSegStart; |
||||
|
} |
||||
|
|
||||
|
public Double getScoreSegEnd() { |
||||
|
return scoreSegEnd; |
||||
|
} |
||||
|
|
||||
|
public void setScoreSegEnd(Double scoreSegEnd) { |
||||
|
this.scoreSegEnd = scoreSegEnd; |
||||
|
} |
||||
|
|
||||
|
public Long getCountDev() { |
||||
|
return countDev; |
||||
|
} |
||||
|
|
||||
|
public void setCountDev(Long countDev) { |
||||
|
this.countDev = countDev; |
||||
|
} |
||||
|
|
||||
|
public Long getTotalCountDev() { |
||||
|
return totalCountDev; |
||||
|
} |
||||
|
|
||||
|
public void setTotalCountDev(Long totalCountDev) { |
||||
|
this.totalCountDev = totalCountDev; |
||||
|
} |
||||
|
|
||||
|
public Double getPercentDev() { |
||||
|
return percentDev; |
||||
|
} |
||||
|
|
||||
|
public void setPercentDev(Double percentDev) { |
||||
|
this.percentDev = percentDev; |
||||
|
} |
||||
|
|
||||
|
public Long getCountApp() { |
||||
|
return countApp; |
||||
|
} |
||||
|
|
||||
|
public void setCountApp(Long countApp) { |
||||
|
this.countApp = countApp; |
||||
|
} |
||||
|
|
||||
|
public Long getTotalCountApp() { |
||||
|
return totalCountApp; |
||||
|
} |
||||
|
|
||||
|
public void setTotalCountApp(Long totalCountApp) { |
||||
|
this.totalCountApp = totalCountApp; |
||||
|
} |
||||
|
|
||||
|
public Double getPercentApp() { |
||||
|
return percentApp; |
||||
|
} |
||||
|
|
||||
|
public void setPercentApp(Double percentApp) { |
||||
|
this.percentApp = percentApp; |
||||
|
} |
||||
|
|
||||
|
public Double getPercentDiff() { |
||||
|
return percentDiff; |
||||
|
} |
||||
|
|
||||
|
public void setPercentDiff(Double percentDiff) { |
||||
|
this.percentDiff = percentDiff; |
||||
|
} |
||||
|
|
||||
|
public Double getPercentRate() { |
||||
|
return percentRate; |
||||
|
} |
||||
|
|
||||
|
public void setPercentRate(Double percentRate) { |
||||
|
this.percentRate = percentRate; |
||||
|
} |
||||
|
|
||||
|
public Double getWeight() { |
||||
|
return weight; |
||||
|
} |
||||
|
|
||||
|
public void setWeight(Double weight) { |
||||
|
this.weight = weight; |
||||
|
} |
||||
|
|
||||
|
public Double getStWeight() { |
||||
|
return stWeight; |
||||
|
} |
||||
|
|
||||
|
public void setStWeight(Double stWeight) { |
||||
|
this.stWeight = stWeight; |
||||
|
} |
||||
|
} |
@ -0,0 +1,13 @@ |
|||||
|
package io.sc.platform.data.csv; |
||||
|
|
||||
|
import io.sc.platform.data.ItemProcessor; |
||||
|
|
||||
|
import java.math.BigDecimal; |
||||
|
|
||||
|
public class CsvItemProcessor implements ItemProcessor<Record, Record> { |
||||
|
@Override |
||||
|
public Record process(Record item) throws Exception { |
||||
|
System.out.println(item.get("CUSTOMER_ID") + "," + item.get("SCORE", BigDecimal.class) + "," + item.get("LEVEL",Integer.class) + "," + item.get("IS_DEFAULT",Boolean.class)); |
||||
|
return item; |
||||
|
} |
||||
|
} |
@ -0,0 +1,99 @@ |
|||||
|
package io.sc.platform.data.csv; |
||||
|
|
||||
|
import com.opencsv.CSVReader; |
||||
|
import com.opencsv.CSVReaderBuilder; |
||||
|
import io.sc.platform.data.ItemReader; |
||||
|
import org.springframework.core.io.DefaultResourceLoader; |
||||
|
import org.springframework.core.io.Resource; |
||||
|
import org.springframework.util.StringUtils; |
||||
|
|
||||
|
import java.io.BufferedReader; |
||||
|
import java.io.IOException; |
||||
|
import java.io.InputStreamReader; |
||||
|
import java.util.Iterator; |
||||
|
|
||||
|
public class CsvItemReader implements ItemReader<Record> { |
||||
|
private String resourceUrl; |
||||
|
private int skipLines; |
||||
|
private String splitChar; |
||||
|
private CSVReader reader; |
||||
|
private Iterator<String[]> iterator; |
||||
|
private RecordMapper mapper; |
||||
|
|
||||
|
public CsvItemReader(RecordMapper mapper){ |
||||
|
this.mapper =mapper; |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public void init() throws IOException { |
||||
|
if(!StringUtils.hasText(resourceUrl)){ |
||||
|
throw new IOException("resourceUrl is not defined"); |
||||
|
} |
||||
|
Resource resource =new DefaultResourceLoader().getResource(resourceUrl); |
||||
|
if(resource==null|| !resource.exists()){ |
||||
|
throw new IOException("resource '" + resourceUrl + "' is not exists"); |
||||
|
} |
||||
|
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(resource.getInputStream())); |
||||
|
reader = new CSVReaderBuilder(bufferedReader) |
||||
|
.withSkipLines(this.skipLines) |
||||
|
.build(); |
||||
|
iterator = reader.iterator(); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public boolean hasNext() throws IOException { |
||||
|
return iterator.hasNext(); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public Record read() throws IOException { |
||||
|
return new Record(mapper,iterator.next()); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public void close() throws IOException { |
||||
|
if(reader!=null) { |
||||
|
reader.close(); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
public String getResourceUrl() { |
||||
|
return resourceUrl; |
||||
|
} |
||||
|
|
||||
|
public void setResourceUrl(String resourceUrl) { |
||||
|
this.resourceUrl = resourceUrl; |
||||
|
} |
||||
|
|
||||
|
public int getSkipLines() { |
||||
|
return skipLines; |
||||
|
} |
||||
|
|
||||
|
public void setSkipLines(int skipLines) { |
||||
|
this.skipLines = skipLines; |
||||
|
} |
||||
|
|
||||
|
public String getSplitChar() { |
||||
|
return splitChar; |
||||
|
} |
||||
|
|
||||
|
public void setSplitChar(String splitChar) { |
||||
|
this.splitChar = splitChar; |
||||
|
} |
||||
|
|
||||
|
public CSVReader getReader() { |
||||
|
return reader; |
||||
|
} |
||||
|
|
||||
|
public void setReader(CSVReader reader) { |
||||
|
this.reader = reader; |
||||
|
} |
||||
|
|
||||
|
public Iterator<String[]> getIterator() { |
||||
|
return iterator; |
||||
|
} |
||||
|
|
||||
|
public void setIterator(Iterator<String[]> iterator) { |
||||
|
this.iterator = iterator; |
||||
|
} |
||||
|
} |
@ -0,0 +1,23 @@ |
|||||
|
package io.sc.platform.data.csv; |
||||
|
|
||||
|
import io.sc.platform.data.ItemWriter; |
||||
|
|
||||
|
import java.io.IOException; |
||||
|
import java.util.List; |
||||
|
|
||||
|
public class CsvItemWriter implements ItemWriter<Record> { |
||||
|
@Override |
||||
|
public void init() throws IOException { |
||||
|
|
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public void write(List<Record> items) throws IOException { |
||||
|
|
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public void close() throws IOException { |
||||
|
|
||||
|
} |
||||
|
} |
@ -0,0 +1,8 @@ |
|||||
|
package io.sc.platform.data.db; |
||||
|
|
||||
|
import io.sc.platform.data.ItemProcessor; |
||||
|
import io.sc.platform.data.csv.Record; |
||||
|
|
||||
|
public abstract class DbItemProcessor<S,T> implements ItemProcessor<S, T> { |
||||
|
|
||||
|
} |
@ -0,0 +1,99 @@ |
|||||
|
package io.sc.platform.data.db; |
||||
|
|
||||
|
import io.sc.platform.data.ItemReader; |
||||
|
|
||||
|
import javax.sql.DataSource; |
||||
|
import java.io.IOException; |
||||
|
import java.sql.Connection; |
||||
|
import java.sql.ResultSet; |
||||
|
import java.sql.SQLException; |
||||
|
import java.sql.Statement; |
||||
|
|
||||
|
public abstract class DbItemReader<S> implements ItemReader<S> { |
||||
|
protected DataSource datasource; |
||||
|
protected String tableName; |
||||
|
protected String sql; |
||||
|
protected int fetchSize; |
||||
|
|
||||
|
protected Connection conn; |
||||
|
protected Statement statement; |
||||
|
protected ResultSet rs; |
||||
|
|
||||
|
@Override |
||||
|
public void init() throws IOException { |
||||
|
try { |
||||
|
statement =conn.createStatement(ResultSet.TYPE_FORWARD_ONLY,ResultSet.CONCUR_READ_ONLY); |
||||
|
statement.setFetchSize(fetchSize); |
||||
|
rs =statement.executeQuery(sql); |
||||
|
}catch (SQLException e){ |
||||
|
throw new IOException(e); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public boolean hasNext() throws IOException { |
||||
|
try { |
||||
|
return rs.next(); |
||||
|
}catch (SQLException e){ |
||||
|
throw new IOException(e); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public void close() throws IOException { |
||||
|
SQLException exceptionRs =null; |
||||
|
SQLException exceptionStatement =null; |
||||
|
SQLException exceptionConnection =null; |
||||
|
try{ |
||||
|
rs.close(); |
||||
|
}catch (SQLException e){ |
||||
|
exceptionRs =e; |
||||
|
} |
||||
|
try{ |
||||
|
statement.close(); |
||||
|
}catch (SQLException e){ |
||||
|
exceptionStatement =e; |
||||
|
} |
||||
|
try { |
||||
|
conn.close(); |
||||
|
} catch (SQLException e) { |
||||
|
exceptionConnection =e; |
||||
|
} |
||||
|
if(exceptionRs!=null || exceptionStatement!=null || exceptionConnection!=null){ |
||||
|
SQLException exception =exceptionRs!=null?exceptionRs:exceptionStatement!=null?exceptionStatement:exceptionConnection!=null?exceptionConnection:null; |
||||
|
throw new IOException(exception); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
public DataSource getDatasource() { |
||||
|
return datasource; |
||||
|
} |
||||
|
|
||||
|
public void setDatasource(DataSource datasource) { |
||||
|
this.datasource = datasource; |
||||
|
} |
||||
|
|
||||
|
public String getTableName() { |
||||
|
return tableName; |
||||
|
} |
||||
|
|
||||
|
public void setTableName(String tableName) { |
||||
|
this.tableName = tableName; |
||||
|
} |
||||
|
|
||||
|
public String getSql() { |
||||
|
return sql; |
||||
|
} |
||||
|
|
||||
|
public void setSql(String sql) { |
||||
|
this.sql = sql; |
||||
|
} |
||||
|
|
||||
|
public int getFetchSize() { |
||||
|
return fetchSize; |
||||
|
} |
||||
|
|
||||
|
public void setFetchSize(int fetchSize) { |
||||
|
this.fetchSize = fetchSize; |
||||
|
} |
||||
|
} |
@ -0,0 +1,43 @@ |
|||||
|
package io.sc.platform.data.db; |
||||
|
|
||||
|
import io.sc.platform.data.ItemWriter; |
||||
|
|
||||
|
import javax.sql.DataSource; |
||||
|
import java.io.IOException; |
||||
|
import java.util.List; |
||||
|
|
||||
|
public abstract class DbItemWriter<T> implements ItemWriter<T> { |
||||
|
protected DataSource datasource; |
||||
|
protected String tableName; |
||||
|
|
||||
|
@Override |
||||
|
public void init() throws IOException { |
||||
|
|
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public void write(List<T> items) throws IOException { |
||||
|
|
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public void close() throws IOException { |
||||
|
|
||||
|
} |
||||
|
|
||||
|
public DataSource getDatasource() { |
||||
|
return datasource; |
||||
|
} |
||||
|
|
||||
|
public void setDatasource(DataSource datasource) { |
||||
|
this.datasource = datasource; |
||||
|
} |
||||
|
|
||||
|
public String getTableName() { |
||||
|
return tableName; |
||||
|
} |
||||
|
|
||||
|
public void setTableName(String tableName) { |
||||
|
this.tableName = tableName; |
||||
|
} |
||||
|
} |
@ -0,0 +1,90 @@ |
|||||
|
package io.sc.platform.developer.controller.springboot; |
||||
|
|
||||
|
import io.sc.platform.developer.wrapper.springboot.AutoConfigurationWrapper; |
||||
|
import io.sc.platform.orm.service.support.QueryParameter; |
||||
|
import io.sc.platform.orm.service.support.QueryResult; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.boot.actuate.autoconfigure.condition.ConditionsReportEndpoint; |
||||
|
import org.springframework.boot.actuate.autoconfigure.condition.ConditionsReportEndpoint.ApplicationConditionEvaluation; |
||||
|
import org.springframework.boot.actuate.autoconfigure.condition.ConditionsReportEndpoint.ContextConditionEvaluation; |
||||
|
import org.springframework.boot.actuate.autoconfigure.condition.ConditionsReportEndpoint.MessageAndCondition; |
||||
|
import org.springframework.boot.actuate.autoconfigure.condition.ConditionsReportEndpoint.MessageAndConditions; |
||||
|
import org.springframework.data.domain.Page; |
||||
|
import org.springframework.stereotype.Controller; |
||||
|
import org.springframework.web.bind.annotation.GetMapping; |
||||
|
import org.springframework.web.bind.annotation.RequestMapping; |
||||
|
import org.springframework.web.bind.annotation.ResponseBody; |
||||
|
|
||||
|
import java.util.ArrayList; |
||||
|
import java.util.List; |
||||
|
import java.util.Map; |
||||
|
|
||||
|
@Controller |
||||
|
@RequestMapping("/api/developer/springboot/autoConfiguration") |
||||
|
public class SpringbootAutoConfigurationWebController { |
||||
|
@Autowired private ConditionsReportEndpoint conditionsReportEndpoint; |
||||
|
|
||||
|
@GetMapping("") |
||||
|
@ResponseBody |
||||
|
public Page<AutoConfigurationWrapper> autoConfiguration(QueryParameter queryParameter){ |
||||
|
List<AutoConfigurationWrapper> result =new ArrayList<AutoConfigurationWrapper>(); |
||||
|
ApplicationConditionEvaluation applicationConditionEvaluation =conditionsReportEndpoint.applicationConditionEvaluation(); |
||||
|
Map<String, ContextConditionEvaluation> contextConditionEvaluationMap =applicationConditionEvaluation.getContexts(); |
||||
|
if(contextConditionEvaluationMap!=null && contextConditionEvaluationMap.size()>0) { |
||||
|
for(String contextName : contextConditionEvaluationMap.keySet()) { |
||||
|
ContextConditionEvaluation contextConditionEvaluation =contextConditionEvaluationMap.get(contextName); |
||||
|
Map<String, List<MessageAndCondition>> positiveMatches =contextConditionEvaluation.getPositiveMatches(); |
||||
|
if(positiveMatches!=null && positiveMatches.size()>0) { |
||||
|
for(String key : positiveMatches.keySet()) { |
||||
|
List<MessageAndCondition> messageAndConditions =positiveMatches.get(key); |
||||
|
if(messageAndConditions!=null && messageAndConditions.size()>0) { |
||||
|
for(MessageAndCondition messageAndCondition : messageAndConditions) { |
||||
|
AutoConfigurationWrapper wrapper =new AutoConfigurationWrapper(); |
||||
|
wrapper.setContext(contextName); |
||||
|
wrapper.setName(key); |
||||
|
wrapper.setPositiveAndNegativeType(AutoConfigurationWrapper.PositiveAndNegativeType.Positive); |
||||
|
wrapper.setCondition(messageAndCondition.getCondition()); |
||||
|
wrapper.setMessage(messageAndCondition.getMessage()); |
||||
|
result.add(wrapper); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
Map<String, MessageAndConditions> negativeMatches =contextConditionEvaluation.getNegativeMatches(); |
||||
|
if(negativeMatches!=null && negativeMatches.size()>0) { |
||||
|
for(String key : negativeMatches.keySet()) { |
||||
|
MessageAndConditions messageAndCondition =negativeMatches.get(key); |
||||
|
List<MessageAndCondition> matcheds =messageAndCondition.getMatched(); |
||||
|
if(matcheds!=null && matcheds.size()>0) { |
||||
|
for(MessageAndCondition matched : matcheds) { |
||||
|
AutoConfigurationWrapper wrapper =new AutoConfigurationWrapper(); |
||||
|
wrapper.setContext(contextName); |
||||
|
wrapper.setName(key); |
||||
|
wrapper.setPositiveAndNegativeType(AutoConfigurationWrapper.PositiveAndNegativeType.Positive); |
||||
|
wrapper.setMatchedAndNotMatchedType(AutoConfigurationWrapper.MatchedAndNotMatchedType.Matched); |
||||
|
wrapper.setCondition(matched.getCondition()); |
||||
|
wrapper.setMessage(matched.getMessage()); |
||||
|
result.add(wrapper); |
||||
|
} |
||||
|
} |
||||
|
List<MessageAndCondition> notMatcheds =messageAndCondition.getNotMatched(); |
||||
|
if(notMatcheds!=null && notMatcheds.size()>0) { |
||||
|
for(MessageAndCondition notMatched : notMatcheds) { |
||||
|
AutoConfigurationWrapper wrapper =new AutoConfigurationWrapper(); |
||||
|
wrapper.setContext(contextName); |
||||
|
wrapper.setName(key); |
||||
|
wrapper.setPositiveAndNegativeType(AutoConfigurationWrapper.PositiveAndNegativeType.Positive); |
||||
|
wrapper.setMatchedAndNotMatchedType(AutoConfigurationWrapper.MatchedAndNotMatchedType.NotMatched); |
||||
|
wrapper.setCondition(notMatched.getCondition()); |
||||
|
wrapper.setMessage(notMatched.getMessage()); |
||||
|
result.add(wrapper); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
return QueryResult.page(result,queryParameter); |
||||
|
} |
||||
|
} |
@ -0,0 +1,57 @@ |
|||||
|
package io.sc.platform.developer.controller.springboot; |
||||
|
|
||||
|
import io.sc.platform.developer.wrapper.springboot.EnvironmentWrapper; |
||||
|
import io.sc.platform.orm.service.support.QueryParameter; |
||||
|
import io.sc.platform.orm.service.support.QueryResult; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.boot.actuate.env.EnvironmentEndpoint; |
||||
|
import org.springframework.boot.actuate.env.EnvironmentEndpoint.EnvironmentDescriptor; |
||||
|
import org.springframework.boot.actuate.env.EnvironmentEndpoint.PropertySourceDescriptor; |
||||
|
import org.springframework.boot.actuate.env.EnvironmentEndpoint.PropertyValueDescriptor; |
||||
|
import org.springframework.data.domain.Page; |
||||
|
import org.springframework.stereotype.Controller; |
||||
|
import org.springframework.web.bind.annotation.GetMapping; |
||||
|
import org.springframework.web.bind.annotation.RequestMapping; |
||||
|
import org.springframework.web.bind.annotation.ResponseBody; |
||||
|
|
||||
|
import java.util.ArrayList; |
||||
|
import java.util.List; |
||||
|
import java.util.Map; |
||||
|
|
||||
|
@Controller |
||||
|
@RequestMapping("/api/developer/springboot/environment") |
||||
|
public class SpringbootEnvironmentWebController { |
||||
|
@Autowired private EnvironmentEndpoint endpoint; |
||||
|
|
||||
|
@GetMapping("") |
||||
|
@ResponseBody |
||||
|
public Page<EnvironmentWrapper> environment(QueryParameter queryParameter){ |
||||
|
List<EnvironmentWrapper> result =new ArrayList<EnvironmentWrapper>(); |
||||
|
EnvironmentDescriptor environmentDescriptor =endpoint.environment("\\w+"); |
||||
|
List<PropertySourceDescriptor> propertySourceDescriptors =environmentDescriptor.getPropertySources(); |
||||
|
if(propertySourceDescriptors!=null && propertySourceDescriptors.size()>0) { |
||||
|
for(PropertySourceDescriptor propertySourceDescriptor : propertySourceDescriptors) { |
||||
|
String propertySourceName =propertySourceDescriptor.getName(); |
||||
|
if(propertySourceName.contains("application.properties")){ |
||||
|
propertySourceName ="application.properties"; |
||||
|
} |
||||
|
Map<String, PropertyValueDescriptor> map =propertySourceDescriptor.getProperties(); |
||||
|
if(map!=null && map.size()>0) { |
||||
|
for(String name : map.keySet()) { |
||||
|
PropertyValueDescriptor propertyValueDescriptor =map.get(name); |
||||
|
String origin =propertyValueDescriptor.getOrigin(); |
||||
|
Object value =propertyValueDescriptor.getValue(); |
||||
|
|
||||
|
EnvironmentWrapper wrapper =new EnvironmentWrapper(); |
||||
|
wrapper.setPropertySourceName(propertySourceName); |
||||
|
wrapper.setPropertyName(name); |
||||
|
wrapper.setOrigin(origin); |
||||
|
wrapper.setValue(value); |
||||
|
result.add(wrapper); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
return QueryResult.page(result,queryParameter); |
||||
|
} |
||||
|
} |
@ -1,44 +0,0 @@ |
|||||
package io.sc.platform.developer.wrapper.springboot; |
|
||||
|
|
||||
import org.springframework.web.bind.annotation.RequestMethod; |
|
||||
|
|
||||
import java.util.Set; |
|
||||
|
|
||||
public class DespatcherServletWrapper { |
|
||||
private String className; |
|
||||
private String methodName; |
|
||||
private Set<RequestMethod> httpMethods; |
|
||||
private Set<String> patterns; |
|
||||
|
|
||||
public String getClassName() { |
|
||||
return className; |
|
||||
} |
|
||||
|
|
||||
public void setClassName(String className) { |
|
||||
this.className = className; |
|
||||
} |
|
||||
|
|
||||
public String getMethodName() { |
|
||||
return methodName; |
|
||||
} |
|
||||
|
|
||||
public void setMethodName(String methodName) { |
|
||||
this.methodName = methodName; |
|
||||
} |
|
||||
|
|
||||
public Set<RequestMethod> getHttpMethods() { |
|
||||
return httpMethods; |
|
||||
} |
|
||||
|
|
||||
public void setHttpMethods(Set<RequestMethod> httpMethods) { |
|
||||
this.httpMethods = httpMethods; |
|
||||
} |
|
||||
|
|
||||
public Set<String> getPatterns() { |
|
||||
return patterns; |
|
||||
} |
|
||||
|
|
||||
public void setPatterns(Set<String> patterns) { |
|
||||
this.patterns = patterns; |
|
||||
} |
|
||||
} |
|
@ -0,0 +1,41 @@ |
|||||
|
package io.sc.platform.developer.wrapper.springboot; |
||||
|
|
||||
|
import io.sc.platform.core.util.StringUtil; |
||||
|
|
||||
|
import java.util.Collection; |
||||
|
|
||||
|
public class ServletWrapper { |
||||
|
private String name; |
||||
|
private String patterns; |
||||
|
private String className; |
||||
|
|
||||
|
public ServletWrapper(String name, Collection<String> patterns, String className) { |
||||
|
this.name = name; |
||||
|
this.patterns = StringUtil.combine(",", patterns); |
||||
|
this.className = className; |
||||
|
} |
||||
|
|
||||
|
public String getName() { |
||||
|
return name; |
||||
|
} |
||||
|
|
||||
|
public void setName(String name) { |
||||
|
this.name = name; |
||||
|
} |
||||
|
|
||||
|
public String getPatterns() { |
||||
|
return patterns; |
||||
|
} |
||||
|
|
||||
|
public void setPatterns(String patterns) { |
||||
|
this.patterns = patterns; |
||||
|
} |
||||
|
|
||||
|
public String getClassName() { |
||||
|
return className; |
||||
|
} |
||||
|
|
||||
|
public void setClassName(String className) { |
||||
|
this.className = className; |
||||
|
} |
||||
|
} |
@ -0,0 +1,68 @@ |
|||||
|
package io.sc.platform.orm.service.support; |
||||
|
|
||||
|
import org.springframework.data.util.DirectFieldAccessFallbackBeanWrapper; |
||||
|
|
||||
|
import java.util.Comparator; |
||||
|
|
||||
|
public class DefaultQueryResultSorter<T> implements QueryResultSorter<T>{ |
||||
|
|
||||
|
@Override |
||||
|
public Comparator<T> getComparator(String propertyName, boolean isAscending) { |
||||
|
return new AscComparator<T>(propertyName,isAscending); |
||||
|
} |
||||
|
|
||||
|
static class AscComparator<T> implements Comparator<T>{ |
||||
|
private String propertyName; |
||||
|
private boolean isAscending; |
||||
|
|
||||
|
|
||||
|
public AscComparator(String propertyName,boolean isAscending){ |
||||
|
this.propertyName =propertyName; |
||||
|
this.isAscending =isAscending; |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public int compare(T o1, T o2) { |
||||
|
int direction =isAscending?1:-1; |
||||
|
if(o1!=null && o2==null){ |
||||
|
return 1*direction; |
||||
|
} |
||||
|
if(o1==null && o2!=null){ |
||||
|
return -1*direction; |
||||
|
} |
||||
|
if(o1==null && o2==null){ |
||||
|
return 0; |
||||
|
} |
||||
|
DirectFieldAccessFallbackBeanWrapper e1 = new DirectFieldAccessFallbackBeanWrapper(o1); |
||||
|
DirectFieldAccessFallbackBeanWrapper e2 = new DirectFieldAccessFallbackBeanWrapper(o2); |
||||
|
Object v1 =e1.getPropertyValue(propertyName); |
||||
|
Object v2 =e2.getPropertyValue(propertyName); |
||||
|
if(v1!=null && v2==null){ |
||||
|
return 1*direction; |
||||
|
} |
||||
|
if(v1==null && v2!=null){ |
||||
|
return -1*direction; |
||||
|
} |
||||
|
if(v1==null && v2==null){ |
||||
|
return 0; |
||||
|
} |
||||
|
Comparable c1 =null; |
||||
|
Comparable c2 =null; |
||||
|
if(Comparable.class.isAssignableFrom(v1.getClass())){ |
||||
|
c1 =(Comparable)v1; |
||||
|
} |
||||
|
if(Comparable.class.isAssignableFrom(v1.getClass())){ |
||||
|
c2 =(Comparable)v2; |
||||
|
} |
||||
|
if(c1!=null && c2!=null){ |
||||
|
if(v1.getClass().equals(v2.getClass())) { |
||||
|
return c1.compareTo(c2) * direction; |
||||
|
}else{ |
||||
|
return v1.toString().compareTo(v2.toString())*direction; |
||||
|
} |
||||
|
}else { |
||||
|
return v1.toString().compareTo(v2.toString())*direction; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
Loading…
Reference in new issue