21 changed files with 285 additions and 243 deletions
@ -0,0 +1,37 @@ |
|||
package io.sc.algorithm.weka.initializer; |
|||
|
|||
import io.sc.platform.core.initializer.ApplicationInitializer; |
|||
import io.sc.platform.core.initializer.ApplicationInitializerExecuteException; |
|||
import org.slf4j.Logger; |
|||
import org.slf4j.LoggerFactory; |
|||
import org.springframework.context.ApplicationContext; |
|||
import weka.core.WekaPackageManager; |
|||
|
|||
public class WekaInitializer implements ApplicationInitializer { |
|||
private static final Logger log = LoggerFactory.getLogger(WekaInitializer.class); |
|||
private Boolean isInitialized =null; |
|||
|
|||
@Override |
|||
public void init(ApplicationContext applicationContext) { |
|||
} |
|||
|
|||
@Override |
|||
public int getOrder() { |
|||
return 1400; |
|||
} |
|||
|
|||
@Override |
|||
public synchronized boolean isInitialized() { |
|||
if(isInitialized!=null) { |
|||
return isInitialized; |
|||
} |
|||
isInitialized =false; |
|||
return isInitialized; |
|||
} |
|||
|
|||
@Override |
|||
public void execute() throws ApplicationInitializerExecuteException { |
|||
//WekaPackageManager.loadPackages(true);
|
|||
isInitialized =true; |
|||
} |
|||
} |
@ -0,0 +1,125 @@ |
|||
<template> |
|||
<div style="height: 100%"> |
|||
<w-grid |
|||
ref="gridRef" |
|||
:title="$t('engine.st.testResult.grid.title')" |
|||
dense |
|||
:checkbox-selection="false" |
|||
:fetch-data-url="Environment.apiContextPath('/api/st/testResult?testCase=' + factorDefine.id)" |
|||
:pageable="false" |
|||
:sort-by="['year', 'quarter', 'month']" |
|||
:query-form-cols-num="4" |
|||
:query-form-fields="[]" |
|||
:toolbar-actions="['refresh', 'separator', 'view', 'separator', 'export']" |
|||
:columns="[ |
|||
{ width: 60, name: 'year', label: t('year'), align: 'right' }, |
|||
{ width: 60, name: 'quarter', label: t('quarter'), align: 'right' }, |
|||
{ width: 60, name: 'month', label: t('month'), align: 'right' }, |
|||
{ width: 100, name: 'valueLow', label: t('engine.st.scenario.scenarioFactor.grid.entity.valueLow') }, |
|||
{ width: 100, name: 'valueMid', label: t('engine.st.scenario.scenarioFactor.grid.entity.valueMid') }, |
|||
{ width: 100, name: 'valueHigh', label: t('engine.st.scenario.scenarioFactor.grid.entity.valueHigh') }, |
|||
]" |
|||
:viewer="{ |
|||
panel: { |
|||
columnNum: 1, |
|||
fields: [ |
|||
{ name: 'id', label: $t('id') }, |
|||
{ name: 'testCase', label: $t('engine.st.indepFactorDefine.grid.entity.factorDefine') }, |
|||
{ name: 'year', label: $t('year') }, |
|||
{ name: 'quarter', label: $t('quarter') }, |
|||
{ name: 'month', label: $t('month') }, |
|||
{ name: 'value', label: $t('value') }, |
|||
{ name: 'dataComeFrom', label: $t('dataComeFrom') }, |
|||
{ name: 'creator', label: $t('creator') }, |
|||
{ name: 'createDate', label: $t('createDate') }, |
|||
{ name: 'lastModifier', label: $t('lastModifier') }, |
|||
{ name: 'lastModifyDate', label: $t('lastModifyDate'), format: Formater.none() }, |
|||
{ name: 'corporationCode', label: $t('corporationCode') }, |
|||
], |
|||
}, |
|||
}" |
|||
@after-request-data=" |
|||
() => { |
|||
const rows = gridRef.getRows(); |
|||
const xAxisData = []; |
|||
const seriesData = []; |
|||
for (const row of rows) { |
|||
xAxisData.push(row.year + (row.month ? '-' + row.month : '')); |
|||
seriesData.push(row.valueLow); |
|||
} |
|||
echartsOptionRef = { |
|||
title: { |
|||
text: factorDefine.name, |
|||
left: 'center', |
|||
}, |
|||
xAxis: { |
|||
type: 'category', |
|||
name: $t('period'), |
|||
data: xAxisData, |
|||
}, |
|||
yAxis: { |
|||
type: 'value', |
|||
name: $t('value'), |
|||
}, |
|||
series: [ |
|||
{ |
|||
data: seriesData, |
|||
type: 'line', |
|||
smooth: true, |
|||
}, |
|||
], |
|||
}; |
|||
} |
|||
" |
|||
></w-grid> |
|||
</div> |
|||
</template> |
|||
<script setup lang="ts"> |
|||
import { ref, computed, onUpdated } from 'vue'; |
|||
import { useI18n } from 'vue-i18n'; |
|||
import { axios, Environment, Formater } from 'platform-core'; |
|||
|
|||
const props = defineProps({ |
|||
factorDefine: { |
|||
type: Object, |
|||
default: () => { |
|||
return {}; |
|||
}, |
|||
}, |
|||
}); |
|||
|
|||
const { t } = useI18n(); |
|||
const gridRef = ref(); |
|||
const echartsOptionRef = ref(); |
|||
const dialogRef = ref(); |
|||
|
|||
const getFactorColumns = computed(() => { |
|||
let result = [{ width: 60, name: 'year', label: t('year'), align: 'right' }]; |
|||
result.push({ width: 60, name: 'month', label: t('month'), align: 'right' }); |
|||
result.push({ width: 100, name: 'valueLow', label: t('engine.st.scenario.scenarioFactor.grid.entity.valueLow') }); |
|||
result.push({ width: 100, name: 'valueMid', label: t('engine.st.scenario.scenarioFactor.grid.entity.valueMid') }); |
|||
result.push({ width: 100, name: 'valueHigh', label: t('engine.st.scenario.scenarioFactor.grid.entity.valueHigh') }); |
|||
return result; |
|||
}); |
|||
|
|||
const fillWithPercentile = (settings) => { |
|||
axios |
|||
.post(Environment.apiContextPath('/api/st/scenarioFactor/fillWithPercentile?scenarioFactorId=' + gridRef.value.getSelectedRow().id), settings) |
|||
.then(() => { |
|||
refresh(); |
|||
dialogRef.value.close(); |
|||
}); |
|||
}; |
|||
|
|||
const refresh = () => { |
|||
gridRef.value.refresh(); |
|||
}; |
|||
|
|||
onUpdated(() => { |
|||
gridRef.value.refresh(); |
|||
}); |
|||
|
|||
defineExpose({ |
|||
refresh, |
|||
}); |
|||
</script> |
@ -1,20 +0,0 @@ |
|||
package io.sc.engine.st.controller; |
|||
|
|||
import io.sc.engine.st.jpa.entity.TestScenarioEntity; |
|||
import io.sc.engine.st.jpa.repository.TestScenarioRepository; |
|||
import io.sc.engine.st.service.TestScenarioService; |
|||
import io.sc.engine.st.vo.TestScenarioVo; |
|||
import io.sc.platform.mvc.controller.support.RestCrudController; |
|||
import org.springframework.web.bind.annotation.GetMapping; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RequestParam; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
|
|||
import java.util.ArrayList; |
|||
import java.util.Locale; |
|||
|
|||
@RestController("io.sc.engine.st.controller.TestScenarioWebController") |
|||
@RequestMapping("/api/st/testScenario") |
|||
public class TestScenarioWebController extends RestCrudController<TestScenarioVo, TestScenarioEntity,String, TestScenarioRepository, TestScenarioService> { |
|||
|
|||
} |
@ -1,10 +1,55 @@ |
|||
package io.sc.engine.st.enums; |
|||
|
|||
import io.sc.platform.core.util.DateUtil; |
|||
import org.springframework.util.StringUtils; |
|||
|
|||
import java.text.ParseException; |
|||
import java.util.Date; |
|||
|
|||
/** |
|||
* 值类型枚举 |
|||
*/ |
|||
public enum ValueType { |
|||
NUMBER, //数字
|
|||
NUMERIC, //数字
|
|||
STRING, //字符串
|
|||
DATE; //日期
|
|||
|
|||
/** |
|||
* 获取值类型对应的 Java 类 |
|||
* @return 值类型对应的 Java 类 |
|||
*/ |
|||
public Class<?> getJavaType(){ |
|||
switch (this){ |
|||
case NUMERIC: |
|||
return Double.class; |
|||
case STRING: |
|||
return String.class; |
|||
case DATE: |
|||
return Date.class; |
|||
default: |
|||
return null; |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* 获取值 |
|||
* @param value 值的字符串 |
|||
* @return 值对象 |
|||
* @throws ParseException 解析错误 |
|||
*/ |
|||
public Object getValue(String value) throws ParseException { |
|||
if(!StringUtils.hasText(value)){ |
|||
return null; |
|||
} |
|||
switch (this){ |
|||
case NUMERIC: |
|||
return Double.parseDouble(value); |
|||
case STRING: |
|||
return value; |
|||
case DATE: |
|||
return DateUtil.tryParseDate(value); |
|||
default: |
|||
return null; |
|||
} |
|||
} |
|||
} |
|||
|
@ -1,107 +0,0 @@ |
|||
package io.sc.engine.st.jpa.entity; |
|||
|
|||
import io.sc.engine.st.enums.StatisticalPeriodType; |
|||
import io.sc.engine.st.vo.TestScenarioVo; |
|||
import io.sc.platform.orm.entity.CorporationAuditorEntity; |
|||
import org.hibernate.annotations.GenericGenerator; |
|||
|
|||
import javax.persistence.*; |
|||
import javax.validation.constraints.NotBlank; |
|||
import javax.validation.constraints.Size; |
|||
import java.util.Date; |
|||
|
|||
@Entity(name="io.sc.engine.st.jpa.entity.TestScenarioEntity") |
|||
@Table(name="ST_TEST_SCENARIO") |
|||
public class TestScenarioEntity extends CorporationAuditorEntity<TestScenarioVo> { |
|||
@Id |
|||
@GeneratedValue(generator = "system-uuid") |
|||
@GenericGenerator(name = "system-uuid", strategy = "uuid2") |
|||
@Column(name="ID_", length=36) |
|||
@Size(max=36) |
|||
protected String id; |
|||
|
|||
@Column(name="INDICATOR_", length=255) |
|||
@NotBlank |
|||
@Size(max=255) |
|||
protected String indicator; |
|||
|
|||
@Column(name="LOW_GRADE_") |
|||
protected Double lowGrade; |
|||
|
|||
@Column(name="MID_GRADE_") |
|||
protected Double midGrade; |
|||
|
|||
@Column(name="HIGH_GRADE_") |
|||
protected Double highGrade; |
|||
|
|||
@ManyToOne(fetch=FetchType.LAZY) |
|||
@JoinColumn(name="TEST_CASE_ID_") |
|||
protected TestCaseEntity testCase; |
|||
|
|||
@Override |
|||
public TestScenarioVo toVo() { |
|||
TestScenarioVo vo =new TestScenarioVo(); |
|||
super.toVo(vo); |
|||
vo.setId(this.getId()); |
|||
vo.setIndicator(this.getIndicator()); |
|||
vo.setLowGrade(this.getLowGrade()); |
|||
vo.setMidGrade(this.getMidGrade()); |
|||
vo.setHighGrade(this.getHighGrade()); |
|||
vo.setTestCase(this.getTestCase()==null?null:this.getTestCase().getId()); |
|||
return vo; |
|||
} |
|||
|
|||
public TestScenarioEntity(){} |
|||
|
|||
public TestScenarioEntity(String id) { |
|||
this.id = id; |
|||
} |
|||
|
|||
public String getId() { |
|||
return id; |
|||
} |
|||
|
|||
public void setId(String id) { |
|||
this.id = id; |
|||
} |
|||
|
|||
public String getIndicator() { |
|||
return indicator; |
|||
} |
|||
|
|||
public void setIndicator(String indicator) { |
|||
this.indicator = indicator; |
|||
} |
|||
|
|||
public Double getLowGrade() { |
|||
return lowGrade; |
|||
} |
|||
|
|||
public void setLowGrade(Double lowGrade) { |
|||
this.lowGrade = lowGrade; |
|||
} |
|||
|
|||
public Double getMidGrade() { |
|||
return midGrade; |
|||
} |
|||
|
|||
public void setMidGrade(Double midGrade) { |
|||
this.midGrade = midGrade; |
|||
} |
|||
|
|||
public Double getHighGrade() { |
|||
return highGrade; |
|||
} |
|||
|
|||
public void setHighGrade(Double highGrade) { |
|||
this.highGrade = highGrade; |
|||
} |
|||
|
|||
public TestCaseEntity getTestCase() { |
|||
return testCase; |
|||
} |
|||
|
|||
public void setTestCase(TestCaseEntity testCase) { |
|||
this.testCase = testCase; |
|||
} |
|||
} |
@ -1,10 +0,0 @@ |
|||
package io.sc.engine.st.jpa.repository; |
|||
|
|||
import io.sc.engine.st.jpa.entity.TestScenarioEntity; |
|||
import io.sc.platform.orm.repository.DaoRepository; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
@Service("io.sc.engine.st.jpa.repository.TestScenarioRepository") |
|||
public interface TestScenarioRepository extends DaoRepository<TestScenarioEntity,String>{ |
|||
|
|||
} |
@ -1,8 +0,0 @@ |
|||
package io.sc.engine.st.service; |
|||
|
|||
import io.sc.engine.st.jpa.entity.TestScenarioEntity; |
|||
import io.sc.engine.st.jpa.repository.TestScenarioRepository; |
|||
import io.sc.platform.orm.service.DaoService; |
|||
|
|||
public interface TestScenarioService extends DaoService<TestScenarioEntity, String, TestScenarioRepository>{ |
|||
} |
@ -1,12 +0,0 @@ |
|||
package io.sc.engine.st.service.impl; |
|||
|
|||
import io.sc.engine.st.jpa.entity.TestScenarioEntity; |
|||
import io.sc.engine.st.jpa.repository.TestScenarioRepository; |
|||
import io.sc.engine.st.service.TestScenarioService; |
|||
import io.sc.platform.orm.service.impl.DaoServiceImpl; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
@Service("io.sc.engine.st.service.impl.TestScenarioServiceImpl") |
|||
public class TestScenarioServiceImpl extends DaoServiceImpl<TestScenarioEntity, String, TestScenarioRepository> implements TestScenarioService { |
|||
|
|||
} |
@ -1,70 +0,0 @@ |
|||
package io.sc.engine.st.vo; |
|||
|
|||
import io.sc.engine.st.enums.StatisticalPeriodType; |
|||
import io.sc.engine.st.jpa.entity.TestScenarioEntity; |
|||
import io.sc.platform.orm.api.vo.CorporationAuditorVo; |
|||
|
|||
import javax.persistence.Column; |
|||
import javax.persistence.FetchType; |
|||
import javax.persistence.JoinColumn; |
|||
import javax.persistence.ManyToOne; |
|||
import javax.validation.constraints.NotBlank; |
|||
import javax.validation.constraints.Size; |
|||
import java.util.Date; |
|||
|
|||
public class TestScenarioVo extends CorporationAuditorVo { |
|||
protected String id; |
|||
protected String indicator; |
|||
protected Double lowGrade; |
|||
protected Double midGrade; |
|||
protected Double highGrade; |
|||
protected String testCase; |
|||
|
|||
public String getId() { |
|||
return id; |
|||
} |
|||
|
|||
public void setId(String id) { |
|||
this.id = id; |
|||
} |
|||
|
|||
public String getIndicator() { |
|||
return indicator; |
|||
} |
|||
|
|||
public void setIndicator(String indicator) { |
|||
this.indicator = indicator; |
|||
} |
|||
|
|||
public Double getLowGrade() { |
|||
return lowGrade; |
|||
} |
|||
|
|||
public void setLowGrade(Double lowGrade) { |
|||
this.lowGrade = lowGrade; |
|||
} |
|||
|
|||
public Double getMidGrade() { |
|||
return midGrade; |
|||
} |
|||
|
|||
public void setMidGrade(Double midGrade) { |
|||
this.midGrade = midGrade; |
|||
} |
|||
|
|||
public Double getHighGrade() { |
|||
return highGrade; |
|||
} |
|||
|
|||
public void setHighGrade(Double highGrade) { |
|||
this.highGrade = highGrade; |
|||
} |
|||
|
|||
public String getTestCase() { |
|||
return testCase; |
|||
} |
|||
|
|||
public void setTestCase(String testCase) { |
|||
this.testCase = testCase; |
|||
} |
|||
} |
@ -0,0 +1,5 @@ |
|||
package io.sc.platform.orm.api.validator; |
|||
|
|||
public class ValidatorMessage { |
|||
public static final String ID ="{io.sc.platform.orm.api.validator.ValidatorMessage.ID}"; |
|||
} |
@ -0,0 +1,8 @@ |
|||
package io.sc.platform.orm.api.validator; |
|||
|
|||
public class ValidatorRegExp { |
|||
/** |
|||
* 合法 ID 正则表达式 |
|||
*/ |
|||
public static final String ID ="^[a-zA-Z][a-zA-Z0-9_]*"; |
|||
} |
@ -0,0 +1 @@ |
|||
io.sc.platform.orm.api.validator.ValidatorMessage.ID=It can only consist of letters, numbers, or underscores, and must begin with a letter! |
@ -0,0 +1 @@ |
|||
io.sc.platform.orm.api.validator.ValidatorMessage.ID=\u53EA\u80FD\u7531\u5B57\u6BCD\u3001\u6578\u5B57\u6216\u4E0B\u5283\u7DDA\u7D44\u6210,\u4E14\u5FC5\u9808\u4EE5\u5B57\u6BCD\u958B\u982D! |
@ -0,0 +1 @@ |
|||
io.sc.platform.orm.api.validator.ValidatorMessage.ID=\u53EA\u80FD\u7531\u5B57\u6BCD\u3001\u6570\u5B57\u6216\u4E0B\u5212\u7EBF\u7EC4\u6210,\u4E14\u5FC5\u987B\u4EE5\u5B57\u6BCD\u5F00\u5934! |
Loading…
Reference in new issue