WIP: страницы для правил #62
@ -29,7 +29,8 @@ public class AssessmentController {
|
|||||||
public String getAssessments(Model model, @RequestParam Optional<Integer> branchId) {
|
public String getAssessments(Model model, @RequestParam Optional<Integer> branchId) {
|
||||||
model.addAttribute("branches", branchService.findAllValid());
|
model.addAttribute("branches", branchService.findAllValid());
|
||||||
if (branchId.isPresent()) {
|
if (branchId.isPresent()) {
|
||||||
model.addAttribute("assessments", assessmentService.getAssessmentsByForecastTendencies(branchId.get()));
|
model.addAttribute("assessments", assessmentService.getAssessments(branchId.get()));
|
||||||
|
model.addAttribute("singleAssessment", assessmentService.getSingleAssessment(branchId.get()));
|
||||||
model.addAttribute("filterBranchForm", new FilterBranchForm(branchId.get()));
|
model.addAttribute("filterBranchForm", new FilterBranchForm(branchId.get()));
|
||||||
} else {
|
} else {
|
||||||
model.addAttribute("filterBranchForm", new FilterBranchForm());
|
model.addAttribute("filterBranchForm", new FilterBranchForm());
|
||||||
|
@ -34,24 +34,24 @@ public class AssessmentService {
|
|||||||
this.fuzzyInferenceService = fuzzyInferenceService;
|
this.fuzzyInferenceService = fuzzyInferenceService;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Assessment> getAssessmentsByForecastTendencies(Integer branchId) {
|
public List<Assessment> getAssessments(Integer branchId) {
|
||||||
List<TimeSeries> timeSeries = timeSeriesService.getByBranch(branchId);
|
List<TimeSeries> timeSeries = timeSeriesService.getByBranch(branchId);
|
||||||
List<DbRule> dbRules = ruleService.getList();
|
List<DbRule> dbRules = ruleService.getList();
|
||||||
try {
|
try {
|
||||||
return getAssessmentsByTimeSeriesTendencies(dbRules, timeSeries);
|
return getAssessments(dbRules, timeSeries);
|
||||||
} catch (AssessmentException ex) {
|
} catch (AssessmentException ex) {
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
return new ArrayList<>();
|
return new ArrayList<>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Assessment> getAssessmentsByLastValues(Integer branchId) {
|
public List<Assessment> getSingleAssessment(Integer branchId) throws AssessmentException {
|
||||||
List<TimeSeries> timeSeries = timeSeriesService.getByBranch(branchId);
|
List<TimeSeries> timeSeries = timeSeriesService.getByBranch(branchId);
|
||||||
List<DbRule> dbRules = ruleService.getList();
|
List<DbRule> dbRules = ruleService.getList();
|
||||||
return getAssessmentsByLastValues(dbRules, timeSeries);
|
return getSingleAssessment(dbRules, timeSeries);
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<Assessment> getSingleAssessmentByTimeSeriesTendencies(List<DbRule> dbRules, List<TimeSeries> timeSeries) throws AssessmentException {
|
private List<Assessment> getSingleAssessment(List<DbRule> dbRules, List<TimeSeries> timeSeries) throws AssessmentException {
|
||||||
Map<String, Double> variableValues = new HashMap<>();
|
Map<String, Double> variableValues = new HashMap<>();
|
||||||
timeSeries.forEach(ts -> variableValues.put(ts.getTimeSeriesType().name(), timeSeriesService.getLastTimeSeriesTendency(ts)));
|
timeSeries.forEach(ts -> variableValues.put(ts.getTimeSeriesType().name(), timeSeriesService.getLastTimeSeriesTendency(ts)));
|
||||||
return fuzzyInferenceService.getFuzzyInference(dbRules,
|
return fuzzyInferenceService.getFuzzyInference(dbRules,
|
||||||
@ -59,7 +59,7 @@ public class AssessmentService {
|
|||||||
variableValues);
|
variableValues);
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<Assessment> getAssessmentsByTimeSeriesTendencies(List<DbRule> dbRules, List<TimeSeries> timeSeries) {
|
private List<Assessment> getAssessments(List<DbRule> dbRules, List<TimeSeries> timeSeries) {
|
||||||
return dbRules
|
return dbRules
|
||||||
.stream()
|
.stream()
|
||||||
.flatMap(dbRule -> {
|
.flatMap(dbRule -> {
|
||||||
@ -77,12 +77,4 @@ public class AssessmentService {
|
|||||||
.sorted(Comparator.comparing(Assessment::getDegree))
|
.sorted(Comparator.comparing(Assessment::getDegree))
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<Assessment> getAssessmentsByLastValues(List<DbRule> dbRules, List<TimeSeries> timeSeries) {
|
|
||||||
Map<String, Double> variableValues = new HashMap<>();
|
|
||||||
timeSeries.forEach(ts -> variableValues.put(ts.getTimeSeriesType().name(), ts.getValues().get(ts.getValues().size() - 1).getValue()));
|
|
||||||
return fuzzyInferenceService.getFuzzyInference(dbRules,
|
|
||||||
antecedentValueService.getList(),
|
|
||||||
variableValues);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -33,7 +33,7 @@
|
|||||||
<div th:if="*{branchId == null}">Выбрерите ветку для получения оценки репозитория</div>
|
<div th:if="*{branchId == null}">Выбрерите ветку для получения оценки репозитория</div>
|
||||||
</form>
|
</form>
|
||||||
<div th:if="${assessments != null && #lists.size(assessments) > 0}">
|
<div th:if="${assessments != null && #lists.size(assessments) > 0}">
|
||||||
<h5>Состояние репозитория описывается следующими выражениями:</h5>
|
<h5>Состояние репозитория по нескольким правилам описывается следующими выражениями:</h5>
|
||||||
<div th:each="assessment: ${assessments}">
|
<div th:each="assessment: ${assessments}">
|
||||||
<span th:text="${assessment.consequent}"></span>
|
<span th:text="${assessment.consequent}"></span>
|
||||||
вследствие тенденции '<span th:text="${assessment.firstAntecedentTendency}"></span>' показателя '<span
|
вследствие тенденции '<span th:text="${assessment.firstAntecedentTendency}"></span>' показателя '<span
|
||||||
@ -46,5 +46,22 @@
|
|||||||
<div th:if="${assessments != null && #lists.size(assessments) == 0}">
|
<div th:if="${assessments != null && #lists.size(assessments) == 0}">
|
||||||
<h5>Нет результатов</h5>
|
<h5>Нет результатов</h5>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<hr/>
|
||||||
|
|
||||||
|
<div th:if="${singleAssessment != null && #lists.size(assessments) > 0}">
|
||||||
|
<h5>Состояние репозитория по лидирующему правилу описывается следующими выражениями:</h5>
|
||||||
|
<div th:each="assessment: ${singleAssessment}">
|
||||||
|
<span th:text="${assessment.consequent}"></span>
|
||||||
|
вследствие тенденции '<span th:text="${assessment.firstAntecedentTendency}"></span>' показателя '<span
|
||||||
|
th:text="${assessment.firstAntecedent.description}"></span>'
|
||||||
|
и тенденции '<span th:text="${assessment.secondAntecedentTendency}"></span>' показателя '<span
|
||||||
|
th:text="${assessment.secondAntecedent.description}"></span>';
|
||||||
|
<span class="badge badge-warning" th:text="${assessment.degree}"></span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div th:if="${singleAssessment != null && #lists.size(singleAssessment) == 0}">
|
||||||
|
<h5>Нет результатов</h5>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</html>
|
</html>
|
||||||
|
Loading…
Reference in New Issue
Block a user