Commit cdd316b0 by kangxiaoshan

流量汇总

parent 8a3846bc
package common.model;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
/**
* @author liyin
* @description
* @date
*/
@Entity
public class TkioFlowHistory {
@Id
private Long id;
private String ds;
private String email;
private String contractCode;
private Long flow;
private Long costFlow;
public String getDs() {
return ds;
}
public void setDs(String ds) {
this.ds = ds;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getContractCode() {
return contractCode;
}
public void setContractCode(String contractCode) {
this.contractCode = contractCode;
}
public Long getFlow() {
return flow;
}
public void setFlow(Long flow) {
this.flow = flow;
}
public Long getCostFlow() {
return costFlow;
}
public void setCostFlow(Long costFlow) {
this.costFlow = costFlow;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
}
package common.repository;
import common.model.TkioFlowHistory;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
public interface TkioFlowHistoryRepository extends JpaRepository<TkioFlowHistory, Long> {
@Transactional
@Modifying
@Query(value = " insert into tkio_flow_history select * from tkio_flow where email = ?1 and cost_flow > 0 ", nativeQuery = true)
BigDecimal backDatasByEmail(String email);
}
......@@ -3,10 +3,7 @@ package track.task;
import common.model.CalculationFlow;
import common.model.Contract;
import common.model.TkioFlow;
import common.repository.CalculationFlowRepository;
import common.repository.ContractChangeRepository;
import common.repository.ContractRepository;
import common.repository.TkioFlowRepository;
import common.repository.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -47,6 +44,8 @@ public class TrackingFlowTask {
private ContractChangeRepository contractChangeRepository;
@Autowired
private CalculationFlowRepository calculationFlowRepository;
@Autowired
private TkioFlowHistoryRepository tkioFlowHistoryRepository;
public void syncFlow(){
List<CalculationFlow> calculationFlows = calculationFlowRepository.findByStatus(0);
......@@ -54,6 +53,9 @@ public class TrackingFlowTask {
List<TkioFlow> tkioFlowList = new ArrayList<>();
calculationFlow.setStatus(1);
calculationFlowRepository.save(calculationFlow);
//记录历史数据
tkioFlowHistoryRepository.backDatasByEmail(calculationFlow.getEmail());
tkioFlowRepository.deleteByEmail(calculationFlow.getEmail());
String email = calculationFlow.getEmail();
//查询用户下所有appkey
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment