Commit cdaef6c2 by Wyh

1、報表時間問題 、銷售外送報表沒顯示數據問題

parent 13ff529e
......@@ -49,6 +49,7 @@ import com.qmuiteam.qmui.alpha.QMUIAlphaButton;
import java.text.ParseException;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
......@@ -212,9 +213,12 @@ public class BusinessReportFragment extends BaseFragment<BusinessReportPresenter
String[] xData = new String[manyDay];
Calendar cal = Calendar.getInstance();
//設置默認時間為當前的起止時間
//設置默認時間為當前的起止時間-1天,因為要把起始時間算進去
try {
cal.setTime(TimeUtils.DATE_FORMAT_DATE.parse(startTime));
Date parse = TimeUtils.DATE_FORMAT_DATE.parse(TimeUtils.getDatebyDate(startTime, -1));
if (parse != null) {
cal.setTime(parse);
}
} catch (ParseException e) {
e.printStackTrace();
}
......@@ -249,7 +253,7 @@ public class BusinessReportFragment extends BaseFragment<BusinessReportPresenter
//配置線形圖
AAChartModel aaChartModel = configureColorfulGradientSplineChart(xData, chartData, (int) (yAxisTickInterval / 6));
//如果這幾天的數據都為0,設置默認最大數為18000,間隔為3000
if (yAxisTickInterval == 0) {
if (yAxisTickInterval < 1) {
aaChartModel.yAxisMax(18000f);
aaChartModel.yAxisTickInterval(3000);
} else {
......
......@@ -3,18 +3,18 @@ package com.gingersoft.gsa.cloud.main.mvp.ui.fragment;
import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.os.Message;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.gingersoft.gsa.cloud.common.core.restaurant.RestaurantInfoManager;
import com.gingersoft.gsa.cloud.common.utils.MoneyUtil;
import com.gingersoft.gsa.cloud.common.utils.time.TimeUtils;
......@@ -109,6 +109,7 @@ public class SalesFragment extends BaseFragment<SalesPresenter> implements Sales
@BindView(R2.id.pc_report_delivery)
AAChartView mDeliveryLineChart;
public static SalesFragment newInstance() {
SalesFragment fragment = new SalesFragment();
return fragment;
......@@ -376,6 +377,7 @@ public class SalesFragment extends BaseFragment<SalesPresenter> implements Sales
chart.highlightValues(null);
chart.invalidate();
}
//查詢多少天的數據
private int manyDay = 7;
......@@ -407,7 +409,7 @@ public class SalesFragment extends BaseFragment<SalesPresenter> implements Sales
}
//y軸 數據間隔
double yAxisTickInterval = 0;
int yAxisTickInterval = 0;
//第一條線
for (int i = 0; i < manyDay; i++) {
//通過今年年份+月份+日期,獲取對應的對象
......@@ -420,7 +422,8 @@ public class SalesFragment extends BaseFragment<SalesPresenter> implements Sales
}
}
//配置線形圖
AAChartModel aaChartModel = configureColorfulGradientSplineChart(xData, chartData, (int) (yAxisTickInterval / 6));
yAxisTickInterval = yAxisTickInterval / 6;
AAChartModel aaChartModel = configureColorfulGradientSplineChart(xData, chartData, yAxisTickInterval);
//如果這幾天的數據都為0,設置默認最大數為18000,間隔為3000
if (yAxisTickInterval == 0) {
aaChartModel.yAxisMax(18000f);
......@@ -532,7 +535,7 @@ public class SalesFragment extends BaseFragment<SalesPresenter> implements Sales
mPresenter.getSalesReportInfo(RestaurantInfoManager.newInstance().getRestaurantId() + "", startTime, endTime);
}
private void getDeliveryReport(){
private void getDeliveryReport() {
String startTime = TimeUtils.getDatebyDate(startEndTimePickerView.getStartTime(), 0);
String endTime = TimeUtils.getDatebyDate(startEndTimePickerView.getEndTime(), 1);
mPresenter.getDeliveryOrderCurveInfo(RestaurantInfoManager.newInstance().getRestaurantId() + "", startTime, endTime);
......
......@@ -25,10 +25,10 @@ public class TimeUtils {
/**
* SimpleDateFormat.format把date转成String
* SimpleDateFormat.parse把String转成date。
*
* <p>
* SimpleDateFormat.parse的时候,经常会有ParseException原因是输入的字符串格式跟SimpleDateFormat定义的格式不一致。
* 这时候,可以先通过SimpleDateFormat.format把参数转成符合格式的字符串,然后再调用SimpleDateFormat.parse
*
* <p>
* G 年代标志符
* y 年
* M 月
......@@ -90,7 +90,7 @@ public class TimeUtils {
public static final SimpleDateFormat DATE_FORMAT_DATE_HM = new SimpleDateFormat("HH:mm");
public static final SimpleDateFormat DATE_FORMAT_DATE_H = new SimpleDateFormat("HH");
public static final SimpleDateFormat DATE_FORMAT_HMS= new SimpleDateFormat("HH:mm:ss");
public static final SimpleDateFormat DATE_FORMAT_HMS = new SimpleDateFormat("HH:mm:ss");
public static final SimpleDateFormat DEFAULT_DATE_MDHM = new SimpleDateFormat("MM-dd HH:mm");//, Locale.CHINESE
public static final SimpleDateFormat DEFAULT_DATE_MD = new SimpleDateFormat("MM-dd");
......@@ -369,6 +369,7 @@ public class TimeUtils {
}
return curDateTime;
}
//获取当前系统前后第几小时
public static String getNextHour(int i) {
String curDateTime = null;
......@@ -1569,9 +1570,6 @@ public class TimeUtils {
* @return
*/
public static String getDatebyDate(String date, int day) {
if (day == 0) {
return "";
}
try {
Date date1 = TimeUtils.DATE_FORMAT_DATE.parse(date);
Calendar cal = Calendar.getInstance();
......
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