[go: nahoru, domu]

Skip to content

Commit

Permalink
Merge pull request #83 from WeBankFinTech/branch-0.9.0
Browse files Browse the repository at this point in the history
Branch 0.9.0
  • Loading branch information
Tangjiafeng committed Mar 2, 2022
2 parents 60cc625 + 1fdde9d commit ee94b3f
Show file tree
Hide file tree
Showing 572 changed files with 42,954 additions and 5,464 deletions.
36 changes: 22 additions & 14 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ buildscript {
url "http://maven.aliyun.com/nexus/content/groups/public/"
}
}

dependencies {
classpath 'net.sf.proguard:proguard-gradle:6.2.0'
classpath 'org.springframework.boot:spring-boot-gradle-plugin:1.5.15.RELEASE'
}
}

dependencies {
Expand Down Expand Up @@ -91,7 +96,7 @@ distributions {
fileMode = 0755
}
into { "doc" } {
from "web/app/src/main/doc"
from "docs"
dirMode = 0755
fileMode = 0644
}
Expand Down Expand Up @@ -130,20 +135,23 @@ subprojects {

configurations.all {
resolutionStrategy {
force 'org.springframework:spring-aop:5.1.15.RELEASE'
force 'org.springframework:spring-aspects:5.1.15.RELEASE'
force 'org.springframework:spring-beans:5.1.15.RELEASE'
force 'org.springframework:spring-context:5.1.15.RELEASE'
force 'org.springframework:spring-core:5.1.15.RELEASE'
force 'org.springframework:spring-expressions:5.1.15.RELEASE'
force 'org.springframework:spring-jcl:5.1.15.RELEASE'
force 'org.springframework:spring-jdbc:5.1.15.RELEASE'
force 'org.springframework:spring-orm:5.1.15.RELEASE'
force 'org.springframework:spring-test:5.1.15.RELEASE'
force 'org.springframework:spring-tx:5.1.15.RELEASE'
force 'org.springframework:spring-web:5.1.15.RELEASE'
force 'org.springframework:spring-webmvc:5.1.15.RELEASE'
force 'org.springframework:spring-aop:5.1.18.RELEASE'
force 'org.springframework:spring-aspects:5.1.18.RELEASE'
force 'org.springframework:spring-beans:5.1.18.RELEASE'
force 'org.springframework:spring-context:5.1.18.RELEASE'
force 'org.springframework:spring-core:5.1.18.RELEASE'
force 'org.springframework:spring-expressions:5.1.18.RELEASE'
force 'org.springframework:spring-jcl:5.1.18.RELEASE'
force 'org.springframework:spring-jdbc:5.1.18.RELEASE'
force 'org.springframework:spring-orm:5.1.18.RELEASE'
force 'org.springframework:spring-test:5.1.18.RELEASE'
force 'org.springframework:spring-tx:5.1.18.RELEASE'
force 'org.springframework:spring-web:5.1.18.RELEASE'
force 'org.springframework:spring-webmvc:5.1.18.RELEASE'
force 'org.apache.logging.log4j:log4j-slf4j-impl:2.16.0'
}
exclude group: 'log4j', module: 'log4j'
exclude group: 'org.codehaus.jackson', module: 'jackson-mapper-asl'
}

apply from: "profile.gradle"
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,13 @@
* @author howeye
*/
public interface TaskResultDao {

/**
* Find task result by application id and rule id
* @param applicationId
* @param ruleId
* @return
*/
TaskResult findByApplicationIdAndRuleId(String applicationId, Long ruleId);
List<TaskResult> findByApplicationAndRule(String applicationId, Long ruleId);

/**
* Find avg value between create time and rule id
Expand All @@ -40,14 +39,80 @@ public interface TaskResultDao {
* @param ruleId
* @return
*/
Double findAvgByCreateTimeBetweenAndRuleId(String begin, String end, Long ruleId);
Double findAvgByCreateTimeBetweenAndRule(String begin, String end, Long ruleId);

/**
* Find task result by application and rule id in
* @param applicationId
* @param ruleIds
* @return
*/
List<TaskResult> findByApplicationIdAndRuleIdIn(String applicationId, List<Long> ruleIds);
List<TaskResult> findByApplicationIdAndRuleIn(String applicationId, List<Long> ruleIds);

/**
* Save file task result.
* @param taskResult
* @return
*/
TaskResult saveTaskResult(TaskResult taskResult);

/**
* Find rule IDs by rule metric ID.
* @param id
* @param page
* @param size
* @return
*/
List<Long> findRuleByRuleMetric(Long id, int page, int size);

/**
* Find values by rule ID and rule metric ID.
* @param ruleMetricId
* @param page
* @param size
* @return
*/
List<TaskResult> findValuesByRuleMetric(long ruleMetricId, int page, int size);

/**
* Find avg value by rule ID and rule metric ID.
* @param start
* @param end
* @param ruleId
* @param ruleMetricId
* @return
*/
Double findAvgByCreateTimeBetweenAndRuleAndRuleMetric(String start, String end, Long ruleId, Long ruleMetricId);

/**
* Find value.
* @param applicationId
* @param ruleId
* @param ruleMetricId
* @return
*/
TaskResult find(String applicationId, Long ruleId, Long ruleMetricId);

/**
* Find value.
* @param runDate
* @param ruleId
* @param ruleMetricId
* @return
*/
TaskResult find(Long runDate, Long ruleId, Long ruleMetricId);

/**
* Count values.
* @param ruleMetricId
* @return
*/
int countValuesByRuleMetric(long ruleMetricId);

/**
* Count rules.
* @param ruleMetricId
* @return
*/
int countRuleByRuleMetric(Long ruleMetricId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@
import com.webank.wedatasphere.qualitis.dao.TaskResultDao;
import com.webank.wedatasphere.qualitis.dao.repository.TaskResultRepository;
import com.webank.wedatasphere.qualitis.entity.TaskResult;
import com.webank.wedatasphere.qualitis.dao.TaskResultDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Repository;

import java.util.List;
Expand All @@ -30,22 +32,65 @@
*/
@Repository
public class TaskResultDaoImpl implements TaskResultDao {

@Autowired
private TaskResultRepository resultRepository;

@Override
public TaskResult findByApplicationIdAndRuleId(String applicationId, Long ruleId) {
public List<TaskResult> findByApplicationAndRule(String applicationId, Long ruleId) {
return resultRepository.findByApplicationIdAndRuleId(applicationId, ruleId);
}

@Override
public Double findAvgByCreateTimeBetweenAndRuleId(String begin, String end, Long ruleId) {
return resultRepository.findAvgByCreateTimeBetweenAndRuleId(begin, end, ruleId);
public Double findAvgByCreateTimeBetweenAndRule(String begin, String end, Long ruleId) {
return resultRepository.findAvgByCreateTimeBetween(begin, end, ruleId);
}

@Override
public List<TaskResult> findByApplicationIdAndRuleIdIn(String applicationId, List<Long> ruleIds) {
public List<TaskResult> findByApplicationIdAndRuleIn(String applicationId, List<Long> ruleIds) {
return resultRepository.findByApplicationIdAndRuleIdIn(applicationId, ruleIds);
}

@Override
public TaskResult saveTaskResult(TaskResult taskResult) {
return resultRepository.save(taskResult);
}

@Override
public List<Long> findRuleByRuleMetric(Long ruleMetricId, int page, int size) {
Sort sort = new Sort(Sort.Direction.ASC, "id");
Pageable pageable = PageRequest.of(page, size, sort);
return resultRepository.findRuleByRuleMetricId(ruleMetricId, pageable).getContent();
}

@Override
public List<TaskResult> findValuesByRuleMetric(long ruleMetricId, int page, int size) {
Sort sort = new Sort(Sort.Direction.DESC, "id");
Pageable pageable = PageRequest.of(page, size, sort);
return resultRepository.findValuesByRuleAndRuleMetric(ruleMetricId, pageable).getContent();
}

@Override
public Double findAvgByCreateTimeBetweenAndRuleAndRuleMetric(String start, String end, Long ruleId, Long ruleMetricId) {
return resultRepository.findAvgByCreateTimeBetween(start, end, ruleId, ruleMetricId);
}

@Override
public TaskResult find(String applicationId, Long ruleId, Long ruleMetricId) {
return resultRepository.findValue(applicationId, ruleId, ruleMetricId);
}

@Override
public TaskResult find(Long runDate, Long ruleId, Long ruleMetricId) {
return resultRepository.findWithRunDate(runDate, ruleId, ruleMetricId);
}

@Override
public int countValuesByRuleMetric(long ruleMetricId) {
return resultRepository.countValuesByRuleMetric(ruleMetricId);
}

@Override
public int countRuleByRuleMetric(Long ruleMetricId) {
return resultRepository.countRulesByRuleMetric(ruleMetricId);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,23 @@
package com.webank.wedatasphere.qualitis.dao.repository;

import com.webank.wedatasphere.qualitis.entity.TaskResult;
import com.webank.wedatasphere.qualitis.entity.TaskResult;
import java.util.List;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

/**
* @author howeye
*/
public interface TaskResultRepository extends JpaRepository<TaskResult, Long> {

/**
* Find task result by application and ruls
* @param applicationId
* @param ruleId
* @return
*/
TaskResult findByApplicationIdAndRuleId(String applicationId, Long ruleId);
List<TaskResult> findByApplicationIdAndRuleId(String applicationId, Long ruleId);

/**
* Find value avg from begin time and end time
Expand All @@ -44,7 +43,19 @@ public interface TaskResultRepository extends JpaRepository<TaskResult, Long> {
* @return
*/
@Query("select avg(value) from TaskResult t where (t.createTime between ?1 and ?2) and t.ruleId = ?3")
Double findAvgByCreateTimeBetweenAndRuleId(String begin, String end, Long ruleId);
Double findAvgByCreateTimeBetween(String begin, String end, Long ruleId);


/**
* Find avg value by rule ID and rule metric ID.
* @param begin
* @param end
* @param ruleId
* @param ruleMetricId
* @return
*/
@Query("select avg(value) from TaskResult t where (t.createTime between ?1 and ?2) and t.ruleId = ?3 and (t.ruleMetricId = ?4)")
Double findAvgByCreateTimeBetween(String begin, String end, Long ruleId, Long ruleMetricId);

/**
* Find task result by application and rule id
Expand All @@ -53,4 +64,58 @@ public interface TaskResultRepository extends JpaRepository<TaskResult, Long> {
* @return
*/
List<TaskResult> findByApplicationIdAndRuleIdIn(String applicationId, List<Long> ruleIds);

/**
* Find rule IDs by rule metric ID.
* @param id
* @param pageable
* @return
*/
@Query(value = "SELECT tr.ruleId from TaskResult tr where tr.ruleMetricId = ?1")
Page<Long> findRuleByRuleMetricId(Long id, Pageable pageable);

/**
* Find values by rule ID and rule metric ID.
* @param ruleMetricId
* @param pageable
* @return
*/
@Query(value = "SELECT tr from TaskResult tr where tr.ruleMetricId = ?1")
Page<TaskResult> findValuesByRuleAndRuleMetric(long ruleMetricId, Pageable pageable);

/**
* Find value.
* @param applicationId
* @param ruleId
* @param ruleMetricId
* @return
*/
@Query(value = "SELECT tr from TaskResult tr where tr.applicationId = ?1 and tr.ruleId = ?2 and tr.ruleMetricId = ?3")
TaskResult findValue(String applicationId, Long ruleId, Long ruleMetricId);

/**
* Find value with run date.
* @param runDate
* @param ruleId
* @param ruleMetricId
* @return
*/
@Query(value = "SELECT tr from TaskResult tr where tr.runDate = ?1 and tr.ruleId = ?2 and tr.ruleMetricId = ?3")
TaskResult findWithRunDate(Long runDate, Long ruleId, Long ruleMetricId);

/**
* Count values.
* @param ruleMetricId
* @return
*/
@Query(value = "SELECT count(tr.id) from TaskResult tr where tr.ruleMetricId = ?1")
int countValuesByRuleMetric(long ruleMetricId);

/**
* Count rules.
* @param ruleMetricId
* @return
*/
@Query(value = "SELECT count(tr.ruleId) from TaskResult tr where tr.ruleMetricId = ?1")
int countRulesByRuleMetric(Long ruleMetricId);
}
Loading

0 comments on commit ee94b3f

Please sign in to comment.