|
|
@@ -2,6 +2,7 @@ use std::str::FromStr;
|
|
|
use chrono::NaiveDateTime;
|
|
|
use rust_decimal::Decimal;
|
|
|
use rust_decimal_macros::dec;
|
|
|
+use tracing::info;
|
|
|
use crate::export_template::template_columnar;
|
|
|
use crate::utils::utils;
|
|
|
use crate::utils::utils::{ColumnarConfigInfo};
|
|
|
@@ -23,37 +24,68 @@ pub async fn export_columnar(config_info: ColumnarConfigInfo) {
|
|
|
let mut over_list = vec![];
|
|
|
let mut save_value: Vec<String> = vec![];
|
|
|
let mut total = dec!(0);
|
|
|
- for (index, item) in balance_list.iter().enumerate() {
|
|
|
- if index == 0 {
|
|
|
- total = Decimal::from_str(item[4].as_str().unwrap()).unwrap();
|
|
|
+ match config_info.export_mode {
|
|
|
+ 1 => {
|
|
|
+ info!("正在导出余额柱状图!");
|
|
|
+ for (index, item) in balance_list.iter().enumerate() {
|
|
|
+ let time: i64 = item[1].as_str().unwrap().parse().unwrap();
|
|
|
+ let mut new_value: Vec<String> = vec![];
|
|
|
+ if time_list[0] < time {
|
|
|
+ new_value.push(time_list[0].to_string());
|
|
|
+ new_value.push(Decimal::from_str(item[4].as_str().unwrap()).unwrap().to_string());
|
|
|
+ over_list.push(new_value.clone());
|
|
|
+ time_list.remove(0);
|
|
|
+ }
|
|
|
+ save_value = item.as_array().unwrap().iter().map(|value| value.as_str().unwrap().to_string()).collect();
|
|
|
+ if index == balance_list.len() - 1 {
|
|
|
+ if time <= time_list[0] {
|
|
|
+ new_value.push(time_list[0].to_string());
|
|
|
+ new_value.push(Decimal::from_str(item[4].as_str().unwrap()).unwrap().to_string());
|
|
|
+ over_list.push(new_value.clone());
|
|
|
+ time_list.remove(0);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ template_columnar::export_html(config_info, over_list);
|
|
|
}
|
|
|
- if index != 0 && item[5] == "transfer" {
|
|
|
- total = total + (Decimal::from_str(item[4].as_str().unwrap()).unwrap() - Decimal::from_str(balance_list.clone()[index - 1][4].as_str().unwrap()).unwrap());
|
|
|
+ 2 => {
|
|
|
+ info!("正在导出收益柱状图!");
|
|
|
+ for (index, item) in balance_list.iter().enumerate() {
|
|
|
+ if index == 0 {
|
|
|
+ total = Decimal::from_str(item[4].as_str().unwrap()).unwrap();
|
|
|
+ }
|
|
|
+ if index != 0 && item[5] == "transfer" {
|
|
|
+ total = total + (Decimal::from_str(item[4].as_str().unwrap()).unwrap() - Decimal::from_str(balance_list.clone()[index - 1][4].as_str().unwrap()).unwrap());
|
|
|
+ }
|
|
|
+ let time: i64 = item[1].as_str().unwrap().parse().unwrap();
|
|
|
+ let mut new_value: Vec<String> = vec![];
|
|
|
+ if time_list[0] < time {
|
|
|
+ new_value.push(time_list[0].to_string());
|
|
|
+ new_value.push((Decimal::from_str(item[4].as_str().unwrap()).unwrap() - total).to_string());
|
|
|
+ over_list.push(new_value.clone());
|
|
|
+ time_list.remove(0);
|
|
|
+ }
|
|
|
+ save_value = item.as_array().unwrap().iter().map(|value| value.as_str().unwrap().to_string()).collect();
|
|
|
+ if index == balance_list.len() - 1 && time <= time_list[0] {
|
|
|
+ new_value.push(time_list[0].to_string());
|
|
|
+ new_value.push((Decimal::from_str(item[4].as_str().unwrap()).unwrap() - total).to_string());
|
|
|
+ save_value[1] = time_list[0].to_string();
|
|
|
+ over_list.push(new_value.clone());
|
|
|
+ time_list.remove(0);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ let mut over_value_list: Vec<Vec<String>> = vec![];
|
|
|
+ for (index, item) in over_list.iter().enumerate() {
|
|
|
+ if index == 0 {
|
|
|
+ over_value_list.push(vec![item[0].clone(), "0".to_string()]);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ over_value_list.push(vec![item[0].clone(), (Decimal::from_str(&item[1]).unwrap() - Decimal::from_str(&over_list[index - 1][1]).unwrap()).to_string()])
|
|
|
+ }
|
|
|
+ template_columnar::export_html(config_info, over_value_list);
|
|
|
}
|
|
|
- let time: i64 = item[1].as_str().unwrap().parse().unwrap();
|
|
|
- let mut new_value: Vec<String> = vec![];
|
|
|
- if time_list[0] < time {
|
|
|
- new_value.push(time_list[0].to_string());
|
|
|
- new_value.push((Decimal::from_str(item[4].as_str().unwrap()).unwrap() - total).to_string());
|
|
|
- over_list.push(new_value.clone());
|
|
|
- time_list.remove(0);
|
|
|
+ _ => {
|
|
|
+ info!("导出模式错误!");
|
|
|
}
|
|
|
- save_value = item.as_array().unwrap().iter().map(|value| value.as_str().unwrap().to_string()).collect();
|
|
|
- if index == balance_list.len() - 1 && time <= time_list[0] {
|
|
|
- new_value.push(time_list[0].to_string());
|
|
|
- new_value.push((Decimal::from_str(item[4].as_str().unwrap()).unwrap() - total).to_string());
|
|
|
- save_value[1] = time_list[0].to_string();
|
|
|
- over_list.push(new_value.clone());
|
|
|
- time_list.remove(0);
|
|
|
- }
|
|
|
- }
|
|
|
- let mut over_value_list: Vec<Vec<String>> = vec![];
|
|
|
- for (index, item) in over_list.iter().enumerate() {
|
|
|
- if index == 0 {
|
|
|
- over_value_list.push(vec![item[0].clone(), "0".to_string()]);
|
|
|
- continue;
|
|
|
- }
|
|
|
- over_value_list.push(vec![item[0].clone(), (Decimal::from_str(&item[1]).unwrap() - Decimal::from_str(&over_list[index - 1][1]).unwrap()).to_string()])
|
|
|
}
|
|
|
- template_columnar::export_html(config_info, over_value_list);
|
|
|
}
|