Skip to content

Commit

Permalink
add new feature
Browse files Browse the repository at this point in the history
  • Loading branch information
Tangjiafeng committed Jun 27, 2024
1 parent bf82530 commit af809c0
Show file tree
Hide file tree
Showing 574 changed files with 35,910 additions and 5,439 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,20 @@

package com.webank.wedatasphere.qualitis.dao;

import com.webank.wedatasphere.qualitis.entity.AuthList;
import com.webank.wedatasphere.qualitis.entity.AuthList;
import com.webank.wedatasphere.qualitis.entity.FieldsAnalyse;

import java.util.List;

/**
* @author howeye
* @author v_wenxuanzhang
*/
public interface AuthListDao {
public interface FieldsAnalyseDao {

/**
* Find auth list by appId
* @param appId
* Find all by application ID list
* @param ruleIdList
* @param dataDateList
* @return
*/
AuthList findByAppId(String appId);

List< FieldsAnalyse > findByRuleIdInAndDataDateIn(List< Long > ruleIdList, List< Integer > dataDateList);
}
Original file line number Diff line number Diff line change
Expand Up @@ -152,4 +152,11 @@ public interface TaskResultDao {
* @return
*/
List<TaskResult> findByApplicationId(String applicationId);

/**
* Find all by application ID list
* @param applicationIdList
* @return
*/
List< TaskResult> findByApplicationIdIn(List< String> applicationIdList);
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,25 @@

package com.webank.wedatasphere.qualitis.dao.impl;

import com.webank.wedatasphere.qualitis.dao.AuthListDao;
import com.webank.wedatasphere.qualitis.dao.repository.AuthListRepository;
import com.webank.wedatasphere.qualitis.entity.AuthList;
import com.webank.wedatasphere.qualitis.dao.FieldsAnalyseDao;
import com.webank.wedatasphere.qualitis.dao.repository.FieldsAnalyseRepository;
import com.webank.wedatasphere.qualitis.entity.FieldsAnalyse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
* @author howeye
* @author v_wenxuanzhang
*/
@Repository
public class AuthListDaoImpl implements AuthListDao {
public class FieldsAnalyseDaoImpl implements FieldsAnalyseDao {

@Autowired
private AuthListRepository authListRepository;
private FieldsAnalyseRepository fieldsAnalyseRepository;

@Override
public AuthList findByAppId(String appId) {
return authListRepository.findByAppId(appId);
public List< FieldsAnalyse > findByRuleIdInAndDataDateIn(List< Long > ruleIdList, List< Integer > dataDateList) {
return fieldsAnalyseRepository.findByRuleIdInAndDataDateIn(ruleIdList, dataDateList);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -110,4 +110,8 @@ public List<TaskResult> findByApplicationId(String applicationId) {
return resultRepository.findByApplicationId(applicationId);
}

@Override
public List<TaskResult> findByApplicationIdIn(List< String> applicationIdList) {
return resultRepository.findByApplicationIdIn(applicationIdList);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,21 @@

package com.webank.wedatasphere.qualitis.dao.repository;

import com.webank.wedatasphere.qualitis.entity.AuthList;
import com.webank.wedatasphere.qualitis.entity.AuthList;
import com.webank.wedatasphere.qualitis.entity.FieldsAnalyse;
import org.springframework.data.jpa.repository.JpaRepository;

import java.util.List;

/**
* @author howeye
* @author v_wenxuanzhang
*/
public interface AuthListRepository extends JpaRepository<AuthList, String> {
public interface FieldsAnalyseRepository extends JpaRepository< FieldsAnalyse, Long > {

/**
* Find auth list by appId
* @param appId
* Find all by application ID list
* @param ruleIdList
* @param dataDateList
* @return
*/
AuthList findByAppId(String appId);

List< FieldsAnalyse > findByRuleIdInAndDataDateIn(List< Long > ruleIdList, List< Integer > dataDateList);
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public interface TaskResultRepository extends JpaRepository<TaskResult, Long> {
* @param applicationId
* @return
*/
@Query("select avg(value) from TaskResult t where (t.createTime between ?1 and ?2) and t.ruleId = ?3 and (t.ruleMetricId = ?4) and t.applicationId != ?5 and t.saveResult = 1")
@Query("select avg(value) from TaskResult t where (t.createTime between ?1 and ?2) and t.ruleId = ?3 and (?4 IS NULL OR t.ruleMetricId = ?4) and t.applicationId != ?5 and t.saveResult = 1")
Double findAvgByCreateTimeBetweenAndRuleAndMetricAndApplication(String begin, String end, Long ruleId, Long ruleMetricId, String applicationId);


Expand All @@ -65,7 +65,7 @@ public interface TaskResultRepository extends JpaRepository<TaskResult, Long> {
* @param applicationId
* @return
*/
@Query("select count(t.id) from TaskResult t where (t.createTime between ?1 and ?2) and t.ruleId = ?3 and (t.ruleMetricId = ?4) and t.applicationId != ?5 and t.saveResult = 1")
@Query("select count(t.id) from TaskResult t where (t.createTime between ?1 and ?2) and t.ruleId = ?3 and (?4 IS NULL OR t.ruleMetricId = ?4) and t.applicationId != ?5 and t.saveResult = 1")
long countByCreateTimeBetweenAndRuleAndMetricAndApplication(String begin, String end, Long ruleId, Long ruleMetricId, String applicationId);

/**
Expand All @@ -76,7 +76,7 @@ public interface TaskResultRepository extends JpaRepository<TaskResult, Long> {
* @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) and t.saveResult = 1")
@Query("select avg(value) from TaskResult t where (t.createTime between ?1 and ?2) and t.ruleId = ?3 and (?4 IS NULL OR t.ruleMetricId = ?4) and t.saveResult = 1")
Double findAvgByCreateTimeBetweenAndRuleAndRuleMetric(String begin, String end, Long ruleId, Long ruleMetricId);

/**
Expand All @@ -88,7 +88,7 @@ public interface TaskResultRepository extends JpaRepository<TaskResult, Long> {
* @param applicationId
* @return
*/
@Query("select count(value) from TaskResult t where (t.createTime between ?1 and ?2) and t.ruleId = ?3 and (t.ruleMetricId = ?4) and t.applicationId != ?5 and t.saveResult = 1")
@Query("select count(value) from TaskResult t where (t.createTime between ?1 and ?2) and t.ruleId = ?3 and (?4 IS NULL OR t.ruleMetricId = ?4) and t.applicationId != ?5 and t.saveResult = 1")
long countByCreateTimeBetweenAndRuleAndRuleMetric(String start, String end, Long ruleId, Long ruleMetricId, String applicationId);

/**
Expand Down Expand Up @@ -138,7 +138,7 @@ public interface TaskResultRepository extends JpaRepository<TaskResult, Long> {
* @param ruleMetricId
* @return
*/
@Query(value = "SELECT tr from TaskResult tr where tr.applicationId = ?1 and tr.ruleId = ?2 and tr.ruleMetricId = ?3")
@Query(value = "SELECT tr from TaskResult tr where tr.applicationId = ?1 and tr.ruleId = ?2 and (?3 IS NULL OR tr.ruleMetricId = ?3)")
TaskResult findValue(String applicationId, Long ruleId, Long ruleMetricId);

/**
Expand All @@ -158,4 +158,11 @@ public interface TaskResultRepository extends JpaRepository<TaskResult, Long> {
*/
@Query(value = "SELECT tr from TaskResult tr where tr.applicationId = ?1")
List<TaskResult> findByApplicationId(String applicationId);

/**
* Find all by application ID list
* @param applicationIdList
* @return
*/
List<TaskResult> findByApplicationIdIn(List<String> applicationIdList);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,180 @@
/*
* Copyright 2019 WeBank
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.webank.wedatasphere.qualitis.entity;

import javax.persistence.*;
import java.math.BigDecimal;
import java.util.Date;

/**
* @author v_wenxuanzhang
*/
@Entity
@Table(name = "qualitis_imsmetric_fields_analyse")
@IdClass(FieldsAnalysePrimaryKey.class)
public class FieldsAnalyse {

@Id
@Column(name = "rule_id")
private Long ruleId;

@Id
@Column(name = "data_date")
private Integer dataDate;

@Column(name = "analyse_type", columnDefinition = "TINYINT(5)")
private Integer analyseType;

@Column(name = "datasource_type", columnDefinition = "TINYINT(5)")
private Integer datasourceType;

@Column(name = "database_name")
private String databaseName;

@Column(name = "table_name")
private String tableName;

@Column(name = "field_name")
private String fieldName;

@Column(name = "value")
private BigDecimal value;

@Column(name = "partition_attrs")
private String partitionAttrs;

@Column(name = "create_time")
private Date createTime;

@Column(name = "update_time")
private Date updateTime;

@Column(name = "datasource_user")
private String datasourceUser;

@Column(name = "remark")
private String remark;


public FieldsAnalyse() {
// Default Constructor
}

public Long getRuleId() {
return ruleId;
}

public void setRuleId(Long ruleId) {
this.ruleId = ruleId;
}

public Integer getDataDate() {
return dataDate;
}

public void setDataDate(Integer dataDate) {
this.dataDate = dataDate;
}

public Integer getAnalyseType() {
return analyseType;
}

public void setAnalyseType(Integer analyseType) {
this.analyseType = analyseType;
}

public Integer getDatasourceType() {
return datasourceType;
}

public void setDatasourceType(Integer datasourceType) {
this.datasourceType = datasourceType;
}

public String getDatabaseName() {
return databaseName;
}

public void setDatabaseName(String databaseName) {
this.databaseName = databaseName;
}

public String getTableName() {
return tableName;
}

public void setTableName(String tableName) {
this.tableName = tableName;
}

public String getFieldName() {
return fieldName;
}

public void setFieldName(String fieldName) {
this.fieldName = fieldName;
}

public BigDecimal getValue() {
return value;
}

public void setValue(BigDecimal value) {
this.value = value;
}

public String getPartitionAttrs() {
return partitionAttrs;
}

public void setPartitionAttrs(String partitionAttrs) {
this.partitionAttrs = partitionAttrs;
}

public Date getCreateTime() {
return createTime;
}

public void setCreateTime(Date createTime) {
this.createTime = createTime;
}

public Date getUpdateTime() {
return updateTime;
}

public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}

public String getDatasourceUser() {
return datasourceUser;
}

public void setDatasourceUser(String datasourceUser) {
this.datasourceUser = datasourceUser;
}

public String getRemark() {
return remark;
}

public void setRemark(String remark) {
this.remark = remark;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package com.webank.wedatasphere.qualitis.entity;

import java.io.Serializable;
import java.util.Objects;

/**
* @author v_wenxuanzhang
*/
public class FieldsAnalysePrimaryKey implements Serializable {
private Long ruleId;
private Integer dataDate;

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
FieldsAnalysePrimaryKey that = (FieldsAnalysePrimaryKey) o;
return ruleId.equals(that.ruleId) &&
dataDate.equals(that.dataDate);
}

@Override
public int hashCode() {
return Objects.hash(ruleId, dataDate);
}

public Long getMetricId() {
return ruleId;
}

public void setMetricId(Long metricId) {
this.ruleId = metricId;
}

public Integer getDs() {
return dataDate;
}

public void setDs(Integer ds) {
this.dataDate = ds;
}
}
Loading

0 comments on commit af809c0

Please sign in to comment.