diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/extensions/Long.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/extensions/Long.kt index d321829..11db041 100644 --- a/app/src/main/java/com/casic/app/smartwell/sanxi/extensions/Long.kt +++ b/app/src/main/java/com/casic/app/smartwell/sanxi/extensions/Long.kt @@ -26,6 +26,14 @@ val dateFormat = SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.CHINA) val calendar = Calendar.getInstance() calendar.time = Date(this) - calendar.set(Calendar.DAY_OF_YEAR, calendar.get(Calendar.DAY_OF_YEAR) - 6) + calendar.set(Calendar.DAY_OF_YEAR, calendar.get(Calendar.DAY_OF_YEAR) - 7) + return dateFormat.format(calendar.time) +} + +fun Long.timestampToLastMonthTime(): String { + val dateFormat = SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.CHINA) + val calendar = Calendar.getInstance() + calendar.time = Date(this) + calendar.set(Calendar.DAY_OF_YEAR, calendar.get(Calendar.DAY_OF_YEAR) - 30) return dateFormat.format(calendar.time) } \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/extensions/Long.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/extensions/Long.kt index d321829..11db041 100644 --- a/app/src/main/java/com/casic/app/smartwell/sanxi/extensions/Long.kt +++ b/app/src/main/java/com/casic/app/smartwell/sanxi/extensions/Long.kt @@ -26,6 +26,14 @@ val dateFormat = SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.CHINA) val calendar = Calendar.getInstance() calendar.time = Date(this) - calendar.set(Calendar.DAY_OF_YEAR, calendar.get(Calendar.DAY_OF_YEAR) - 6) + calendar.set(Calendar.DAY_OF_YEAR, calendar.get(Calendar.DAY_OF_YEAR) - 7) + return dateFormat.format(calendar.time) +} + +fun Long.timestampToLastMonthTime(): String { + val dateFormat = SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.CHINA) + val calendar = Calendar.getInstance() + calendar.time = Date(this) + calendar.set(Calendar.DAY_OF_YEAR, calendar.get(Calendar.DAY_OF_YEAR) - 30) return dateFormat.format(calendar.time) } \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/extensions/String.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/extensions/String.kt index c41c867..e094b53 100644 --- a/app/src/main/java/com/casic/app/smartwell/sanxi/extensions/String.kt +++ b/app/src/main/java/com/casic/app/smartwell/sanxi/extensions/String.kt @@ -20,6 +20,8 @@ import java.io.FileOutputStream import java.io.IOException import java.io.InputStream +import java.text.SimpleDateFormat +import java.util.* /** * String扩展方法 @@ -120,6 +122,21 @@ } } +fun String.toMonthDay(): String { + if (this.isBlank()) { + return "" + } + try { + val dateFormat = SimpleDateFormat("yyyy年MM月dd日", Locale.CHINA) + val date = dateFormat.parse(this) ?: return "" + val monthDayFormat = SimpleDateFormat("MM/dd", Locale.CHINA) + return monthDayFormat.format(date) + } catch (e: Exception) { + e.printStackTrace() + return "" + } +} + fun String.separateResponseCode(): Int { if (this.isBlank()) { return 404 diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/extensions/Long.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/extensions/Long.kt index d321829..11db041 100644 --- a/app/src/main/java/com/casic/app/smartwell/sanxi/extensions/Long.kt +++ b/app/src/main/java/com/casic/app/smartwell/sanxi/extensions/Long.kt @@ -26,6 +26,14 @@ val dateFormat = SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.CHINA) val calendar = Calendar.getInstance() calendar.time = Date(this) - calendar.set(Calendar.DAY_OF_YEAR, calendar.get(Calendar.DAY_OF_YEAR) - 6) + calendar.set(Calendar.DAY_OF_YEAR, calendar.get(Calendar.DAY_OF_YEAR) - 7) + return dateFormat.format(calendar.time) +} + +fun Long.timestampToLastMonthTime(): String { + val dateFormat = SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.CHINA) + val calendar = Calendar.getInstance() + calendar.time = Date(this) + calendar.set(Calendar.DAY_OF_YEAR, calendar.get(Calendar.DAY_OF_YEAR) - 30) return dateFormat.format(calendar.time) } \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/extensions/String.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/extensions/String.kt index c41c867..e094b53 100644 --- a/app/src/main/java/com/casic/app/smartwell/sanxi/extensions/String.kt +++ b/app/src/main/java/com/casic/app/smartwell/sanxi/extensions/String.kt @@ -20,6 +20,8 @@ import java.io.FileOutputStream import java.io.IOException import java.io.InputStream +import java.text.SimpleDateFormat +import java.util.* /** * String扩展方法 @@ -120,6 +122,21 @@ } } +fun String.toMonthDay(): String { + if (this.isBlank()) { + return "" + } + try { + val dateFormat = SimpleDateFormat("yyyy年MM月dd日", Locale.CHINA) + val date = dateFormat.parse(this) ?: return "" + val monthDayFormat = SimpleDateFormat("MM/dd", Locale.CHINA) + return monthDayFormat.format(date) + } catch (e: Exception) { + e.printStackTrace() + return "" + } +} + fun String.separateResponseCode(): Int { if (this.isBlank()) { return 404 diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/fragment/HomePageFragment.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/fragment/HomePageFragment.kt index e68e7c1..7d544d7 100644 --- a/app/src/main/java/com/casic/app/smartwell/sanxi/fragment/HomePageFragment.kt +++ b/app/src/main/java/com/casic/app/smartwell/sanxi/fragment/HomePageFragment.kt @@ -36,6 +36,8 @@ import kotlinx.android.synthetic.main.include_home_data_overview.view.* import kotlinx.android.synthetic.main.include_home_device_chart.* import kotlinx.android.synthetic.main.include_home_device_type_chart.* +import kotlinx.android.synthetic.main.include_home_device_type_chart.deviceTypeChart +import kotlinx.android.synthetic.main.include_home_order_chart.* import kotlinx.android.synthetic.main.include_home_well_chart.* import kotlinx.android.synthetic.main.include_home_well_type_chart.* @@ -246,8 +248,7 @@ if (it.code == 200) { val dataModel = it.data!! dataModel.forEach { dateModel -> - val split = dateModel.date.toString().split("年") - xAxisDate.add(split[1]) + xAxisDate.add(dateModel.date.toString().toMonthDay()) } val lines = 2 @@ -279,6 +280,37 @@ ChartViewHelper.setLineChartData(alarmLineChart, xAxisDate, entryModels) } }) + + //近30天工单统计 + workOrderViewModel.obtainMonthOrder( + currentTimeMillis.timestampToLastMonthTime(), + currentTimeMillis.timestampToTime() + ) + workOrderViewModel.monthOrderModel.observe(viewLifecycleOwner, { + if (it.code == 200) { + val xAxisLabel: MutableList = ArrayList() + val barEntries: MutableList = ArrayList() + it.data?.forEachIndexed { index, dataBean -> + xAxisLabel.add(dataBean.deptName.toString()) + val dataValue = if (dataBean.beforeGet.toString().isBlank()) { + 0f + } else { + dataBean.beforeGet.toFloat() + } + val completedValue = if (dataBean.over.toString().isBlank()) { + 0f + } else { + dataBean.over.toFloat() + } + //柱状图 +// barEntries.add(BarEntry(index.toFloat(), dataValue)) + barEntries.add(BarEntry(index.toFloat(), completedValue)) + } + ChartViewHelper.setBarChartData( + orderBarChart, xAxisLabel, barEntries, "monthOrderData" + ) + } + }) return homeView } diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/extensions/Long.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/extensions/Long.kt index d321829..11db041 100644 --- a/app/src/main/java/com/casic/app/smartwell/sanxi/extensions/Long.kt +++ b/app/src/main/java/com/casic/app/smartwell/sanxi/extensions/Long.kt @@ -26,6 +26,14 @@ val dateFormat = SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.CHINA) val calendar = Calendar.getInstance() calendar.time = Date(this) - calendar.set(Calendar.DAY_OF_YEAR, calendar.get(Calendar.DAY_OF_YEAR) - 6) + calendar.set(Calendar.DAY_OF_YEAR, calendar.get(Calendar.DAY_OF_YEAR) - 7) + return dateFormat.format(calendar.time) +} + +fun Long.timestampToLastMonthTime(): String { + val dateFormat = SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.CHINA) + val calendar = Calendar.getInstance() + calendar.time = Date(this) + calendar.set(Calendar.DAY_OF_YEAR, calendar.get(Calendar.DAY_OF_YEAR) - 30) return dateFormat.format(calendar.time) } \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/extensions/String.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/extensions/String.kt index c41c867..e094b53 100644 --- a/app/src/main/java/com/casic/app/smartwell/sanxi/extensions/String.kt +++ b/app/src/main/java/com/casic/app/smartwell/sanxi/extensions/String.kt @@ -20,6 +20,8 @@ import java.io.FileOutputStream import java.io.IOException import java.io.InputStream +import java.text.SimpleDateFormat +import java.util.* /** * String扩展方法 @@ -120,6 +122,21 @@ } } +fun String.toMonthDay(): String { + if (this.isBlank()) { + return "" + } + try { + val dateFormat = SimpleDateFormat("yyyy年MM月dd日", Locale.CHINA) + val date = dateFormat.parse(this) ?: return "" + val monthDayFormat = SimpleDateFormat("MM/dd", Locale.CHINA) + return monthDayFormat.format(date) + } catch (e: Exception) { + e.printStackTrace() + return "" + } +} + fun String.separateResponseCode(): Int { if (this.isBlank()) { return 404 diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/fragment/HomePageFragment.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/fragment/HomePageFragment.kt index e68e7c1..7d544d7 100644 --- a/app/src/main/java/com/casic/app/smartwell/sanxi/fragment/HomePageFragment.kt +++ b/app/src/main/java/com/casic/app/smartwell/sanxi/fragment/HomePageFragment.kt @@ -36,6 +36,8 @@ import kotlinx.android.synthetic.main.include_home_data_overview.view.* import kotlinx.android.synthetic.main.include_home_device_chart.* import kotlinx.android.synthetic.main.include_home_device_type_chart.* +import kotlinx.android.synthetic.main.include_home_device_type_chart.deviceTypeChart +import kotlinx.android.synthetic.main.include_home_order_chart.* import kotlinx.android.synthetic.main.include_home_well_chart.* import kotlinx.android.synthetic.main.include_home_well_type_chart.* @@ -246,8 +248,7 @@ if (it.code == 200) { val dataModel = it.data!! dataModel.forEach { dateModel -> - val split = dateModel.date.toString().split("年") - xAxisDate.add(split[1]) + xAxisDate.add(dateModel.date.toString().toMonthDay()) } val lines = 2 @@ -279,6 +280,37 @@ ChartViewHelper.setLineChartData(alarmLineChart, xAxisDate, entryModels) } }) + + //近30天工单统计 + workOrderViewModel.obtainMonthOrder( + currentTimeMillis.timestampToLastMonthTime(), + currentTimeMillis.timestampToTime() + ) + workOrderViewModel.monthOrderModel.observe(viewLifecycleOwner, { + if (it.code == 200) { + val xAxisLabel: MutableList = ArrayList() + val barEntries: MutableList = ArrayList() + it.data?.forEachIndexed { index, dataBean -> + xAxisLabel.add(dataBean.deptName.toString()) + val dataValue = if (dataBean.beforeGet.toString().isBlank()) { + 0f + } else { + dataBean.beforeGet.toFloat() + } + val completedValue = if (dataBean.over.toString().isBlank()) { + 0f + } else { + dataBean.over.toFloat() + } + //柱状图 +// barEntries.add(BarEntry(index.toFloat(), dataValue)) + barEntries.add(BarEntry(index.toFloat(), completedValue)) + } + ChartViewHelper.setBarChartData( + orderBarChart, xAxisLabel, barEntries, "monthOrderData" + ) + } + }) return homeView } diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/model/MonthOrderModel.java b/app/src/main/java/com/casic/app/smartwell/sanxi/model/MonthOrderModel.java new file mode 100644 index 0000000..e895ffd --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/sanxi/model/MonthOrderModel.java @@ -0,0 +1,109 @@ +package com.casic.app.smartwell.sanxi.model; + +import java.util.List; + +public class MonthOrderModel { + + private int code; + private List data; + private String message; + private boolean success; + + public int getCode() { + return code; + } + + public void setCode(int code) { + this.code = code; + } + + public List getData() { + return data; + } + + public void setData(List data) { + this.data = data; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + + public boolean isSuccess() { + return success; + } + + public void setSuccess(boolean success) { + this.success = success; + } + + public static class DataDTO { + private int over; + private int cancel; + private String deptName; + private int beforeGet; + private String deptId; + private int inHandle; + private int beforeConfirm; + + public int getOver() { + return over; + } + + public void setOver(int over) { + this.over = over; + } + + public int getCancel() { + return cancel; + } + + public void setCancel(int cancel) { + this.cancel = cancel; + } + + public String getDeptName() { + return deptName; + } + + public void setDeptName(String deptName) { + this.deptName = deptName; + } + + public int getBeforeGet() { + return beforeGet; + } + + public void setBeforeGet(int beforeGet) { + this.beforeGet = beforeGet; + } + + public String getDeptId() { + return deptId; + } + + public void setDeptId(String deptId) { + this.deptId = deptId; + } + + public int getInHandle() { + return inHandle; + } + + public void setInHandle(int inHandle) { + this.inHandle = inHandle; + } + + public int getBeforeConfirm() { + return beforeConfirm; + } + + public void setBeforeConfirm(int beforeConfirm) { + this.beforeConfirm = beforeConfirm; + } + } +} diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/extensions/Long.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/extensions/Long.kt index d321829..11db041 100644 --- a/app/src/main/java/com/casic/app/smartwell/sanxi/extensions/Long.kt +++ b/app/src/main/java/com/casic/app/smartwell/sanxi/extensions/Long.kt @@ -26,6 +26,14 @@ val dateFormat = SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.CHINA) val calendar = Calendar.getInstance() calendar.time = Date(this) - calendar.set(Calendar.DAY_OF_YEAR, calendar.get(Calendar.DAY_OF_YEAR) - 6) + calendar.set(Calendar.DAY_OF_YEAR, calendar.get(Calendar.DAY_OF_YEAR) - 7) + return dateFormat.format(calendar.time) +} + +fun Long.timestampToLastMonthTime(): String { + val dateFormat = SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.CHINA) + val calendar = Calendar.getInstance() + calendar.time = Date(this) + calendar.set(Calendar.DAY_OF_YEAR, calendar.get(Calendar.DAY_OF_YEAR) - 30) return dateFormat.format(calendar.time) } \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/extensions/String.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/extensions/String.kt index c41c867..e094b53 100644 --- a/app/src/main/java/com/casic/app/smartwell/sanxi/extensions/String.kt +++ b/app/src/main/java/com/casic/app/smartwell/sanxi/extensions/String.kt @@ -20,6 +20,8 @@ import java.io.FileOutputStream import java.io.IOException import java.io.InputStream +import java.text.SimpleDateFormat +import java.util.* /** * String扩展方法 @@ -120,6 +122,21 @@ } } +fun String.toMonthDay(): String { + if (this.isBlank()) { + return "" + } + try { + val dateFormat = SimpleDateFormat("yyyy年MM月dd日", Locale.CHINA) + val date = dateFormat.parse(this) ?: return "" + val monthDayFormat = SimpleDateFormat("MM/dd", Locale.CHINA) + return monthDayFormat.format(date) + } catch (e: Exception) { + e.printStackTrace() + return "" + } +} + fun String.separateResponseCode(): Int { if (this.isBlank()) { return 404 diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/fragment/HomePageFragment.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/fragment/HomePageFragment.kt index e68e7c1..7d544d7 100644 --- a/app/src/main/java/com/casic/app/smartwell/sanxi/fragment/HomePageFragment.kt +++ b/app/src/main/java/com/casic/app/smartwell/sanxi/fragment/HomePageFragment.kt @@ -36,6 +36,8 @@ import kotlinx.android.synthetic.main.include_home_data_overview.view.* import kotlinx.android.synthetic.main.include_home_device_chart.* import kotlinx.android.synthetic.main.include_home_device_type_chart.* +import kotlinx.android.synthetic.main.include_home_device_type_chart.deviceTypeChart +import kotlinx.android.synthetic.main.include_home_order_chart.* import kotlinx.android.synthetic.main.include_home_well_chart.* import kotlinx.android.synthetic.main.include_home_well_type_chart.* @@ -246,8 +248,7 @@ if (it.code == 200) { val dataModel = it.data!! dataModel.forEach { dateModel -> - val split = dateModel.date.toString().split("年") - xAxisDate.add(split[1]) + xAxisDate.add(dateModel.date.toString().toMonthDay()) } val lines = 2 @@ -279,6 +280,37 @@ ChartViewHelper.setLineChartData(alarmLineChart, xAxisDate, entryModels) } }) + + //近30天工单统计 + workOrderViewModel.obtainMonthOrder( + currentTimeMillis.timestampToLastMonthTime(), + currentTimeMillis.timestampToTime() + ) + workOrderViewModel.monthOrderModel.observe(viewLifecycleOwner, { + if (it.code == 200) { + val xAxisLabel: MutableList = ArrayList() + val barEntries: MutableList = ArrayList() + it.data?.forEachIndexed { index, dataBean -> + xAxisLabel.add(dataBean.deptName.toString()) + val dataValue = if (dataBean.beforeGet.toString().isBlank()) { + 0f + } else { + dataBean.beforeGet.toFloat() + } + val completedValue = if (dataBean.over.toString().isBlank()) { + 0f + } else { + dataBean.over.toFloat() + } + //柱状图 +// barEntries.add(BarEntry(index.toFloat(), dataValue)) + barEntries.add(BarEntry(index.toFloat(), completedValue)) + } + ChartViewHelper.setBarChartData( + orderBarChart, xAxisLabel, barEntries, "monthOrderData" + ) + } + }) return homeView } diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/model/MonthOrderModel.java b/app/src/main/java/com/casic/app/smartwell/sanxi/model/MonthOrderModel.java new file mode 100644 index 0000000..e895ffd --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/sanxi/model/MonthOrderModel.java @@ -0,0 +1,109 @@ +package com.casic.app.smartwell.sanxi.model; + +import java.util.List; + +public class MonthOrderModel { + + private int code; + private List data; + private String message; + private boolean success; + + public int getCode() { + return code; + } + + public void setCode(int code) { + this.code = code; + } + + public List getData() { + return data; + } + + public void setData(List data) { + this.data = data; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + + public boolean isSuccess() { + return success; + } + + public void setSuccess(boolean success) { + this.success = success; + } + + public static class DataDTO { + private int over; + private int cancel; + private String deptName; + private int beforeGet; + private String deptId; + private int inHandle; + private int beforeConfirm; + + public int getOver() { + return over; + } + + public void setOver(int over) { + this.over = over; + } + + public int getCancel() { + return cancel; + } + + public void setCancel(int cancel) { + this.cancel = cancel; + } + + public String getDeptName() { + return deptName; + } + + public void setDeptName(String deptName) { + this.deptName = deptName; + } + + public int getBeforeGet() { + return beforeGet; + } + + public void setBeforeGet(int beforeGet) { + this.beforeGet = beforeGet; + } + + public String getDeptId() { + return deptId; + } + + public void setDeptId(String deptId) { + this.deptId = deptId; + } + + public int getInHandle() { + return inHandle; + } + + public void setInHandle(int inHandle) { + this.inHandle = inHandle; + } + + public int getBeforeConfirm() { + return beforeConfirm; + } + + public void setBeforeConfirm(int beforeConfirm) { + this.beforeConfirm = beforeConfirm; + } + } +} diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/utils/ChartViewHelper.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/utils/ChartViewHelper.kt index 91dc43c..a1b4784 100644 --- a/app/src/main/java/com/casic/app/smartwell/sanxi/utils/ChartViewHelper.kt +++ b/app/src/main/java/com/casic/app/smartwell/sanxi/utils/ChartViewHelper.kt @@ -69,7 +69,7 @@ val barDataSets: MutableList = ArrayList() //绑定数据 val dataSet = BarDataSet(entries, "") - dataSet.color = R.color.color_6.convertColor(context) + dataSet.color = R.color.color_8.convertColor(context) barDataSets.add(dataSet) val barData = BarData(barDataSets) barData.barWidth = 0.75f @@ -103,8 +103,8 @@ dataSet.color = it.lineColor //圆点颜色 dataSet.setCircleColor(it.lineColor) - dataSet.setDrawFilled(true) - dataSet.fillColor = it.lineColor +// dataSet.setDrawFilled(true) +// dataSet.fillColor = it.lineColor dataSet.mode = LineDataSet.Mode.CUBIC_BEZIER lineDataSets.add(dataSet) } diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/extensions/Long.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/extensions/Long.kt index d321829..11db041 100644 --- a/app/src/main/java/com/casic/app/smartwell/sanxi/extensions/Long.kt +++ b/app/src/main/java/com/casic/app/smartwell/sanxi/extensions/Long.kt @@ -26,6 +26,14 @@ val dateFormat = SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.CHINA) val calendar = Calendar.getInstance() calendar.time = Date(this) - calendar.set(Calendar.DAY_OF_YEAR, calendar.get(Calendar.DAY_OF_YEAR) - 6) + calendar.set(Calendar.DAY_OF_YEAR, calendar.get(Calendar.DAY_OF_YEAR) - 7) + return dateFormat.format(calendar.time) +} + +fun Long.timestampToLastMonthTime(): String { + val dateFormat = SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.CHINA) + val calendar = Calendar.getInstance() + calendar.time = Date(this) + calendar.set(Calendar.DAY_OF_YEAR, calendar.get(Calendar.DAY_OF_YEAR) - 30) return dateFormat.format(calendar.time) } \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/extensions/String.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/extensions/String.kt index c41c867..e094b53 100644 --- a/app/src/main/java/com/casic/app/smartwell/sanxi/extensions/String.kt +++ b/app/src/main/java/com/casic/app/smartwell/sanxi/extensions/String.kt @@ -20,6 +20,8 @@ import java.io.FileOutputStream import java.io.IOException import java.io.InputStream +import java.text.SimpleDateFormat +import java.util.* /** * String扩展方法 @@ -120,6 +122,21 @@ } } +fun String.toMonthDay(): String { + if (this.isBlank()) { + return "" + } + try { + val dateFormat = SimpleDateFormat("yyyy年MM月dd日", Locale.CHINA) + val date = dateFormat.parse(this) ?: return "" + val monthDayFormat = SimpleDateFormat("MM/dd", Locale.CHINA) + return monthDayFormat.format(date) + } catch (e: Exception) { + e.printStackTrace() + return "" + } +} + fun String.separateResponseCode(): Int { if (this.isBlank()) { return 404 diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/fragment/HomePageFragment.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/fragment/HomePageFragment.kt index e68e7c1..7d544d7 100644 --- a/app/src/main/java/com/casic/app/smartwell/sanxi/fragment/HomePageFragment.kt +++ b/app/src/main/java/com/casic/app/smartwell/sanxi/fragment/HomePageFragment.kt @@ -36,6 +36,8 @@ import kotlinx.android.synthetic.main.include_home_data_overview.view.* import kotlinx.android.synthetic.main.include_home_device_chart.* import kotlinx.android.synthetic.main.include_home_device_type_chart.* +import kotlinx.android.synthetic.main.include_home_device_type_chart.deviceTypeChart +import kotlinx.android.synthetic.main.include_home_order_chart.* import kotlinx.android.synthetic.main.include_home_well_chart.* import kotlinx.android.synthetic.main.include_home_well_type_chart.* @@ -246,8 +248,7 @@ if (it.code == 200) { val dataModel = it.data!! dataModel.forEach { dateModel -> - val split = dateModel.date.toString().split("年") - xAxisDate.add(split[1]) + xAxisDate.add(dateModel.date.toString().toMonthDay()) } val lines = 2 @@ -279,6 +280,37 @@ ChartViewHelper.setLineChartData(alarmLineChart, xAxisDate, entryModels) } }) + + //近30天工单统计 + workOrderViewModel.obtainMonthOrder( + currentTimeMillis.timestampToLastMonthTime(), + currentTimeMillis.timestampToTime() + ) + workOrderViewModel.monthOrderModel.observe(viewLifecycleOwner, { + if (it.code == 200) { + val xAxisLabel: MutableList = ArrayList() + val barEntries: MutableList = ArrayList() + it.data?.forEachIndexed { index, dataBean -> + xAxisLabel.add(dataBean.deptName.toString()) + val dataValue = if (dataBean.beforeGet.toString().isBlank()) { + 0f + } else { + dataBean.beforeGet.toFloat() + } + val completedValue = if (dataBean.over.toString().isBlank()) { + 0f + } else { + dataBean.over.toFloat() + } + //柱状图 +// barEntries.add(BarEntry(index.toFloat(), dataValue)) + barEntries.add(BarEntry(index.toFloat(), completedValue)) + } + ChartViewHelper.setBarChartData( + orderBarChart, xAxisLabel, barEntries, "monthOrderData" + ) + } + }) return homeView } diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/model/MonthOrderModel.java b/app/src/main/java/com/casic/app/smartwell/sanxi/model/MonthOrderModel.java new file mode 100644 index 0000000..e895ffd --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/sanxi/model/MonthOrderModel.java @@ -0,0 +1,109 @@ +package com.casic.app.smartwell.sanxi.model; + +import java.util.List; + +public class MonthOrderModel { + + private int code; + private List data; + private String message; + private boolean success; + + public int getCode() { + return code; + } + + public void setCode(int code) { + this.code = code; + } + + public List getData() { + return data; + } + + public void setData(List data) { + this.data = data; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + + public boolean isSuccess() { + return success; + } + + public void setSuccess(boolean success) { + this.success = success; + } + + public static class DataDTO { + private int over; + private int cancel; + private String deptName; + private int beforeGet; + private String deptId; + private int inHandle; + private int beforeConfirm; + + public int getOver() { + return over; + } + + public void setOver(int over) { + this.over = over; + } + + public int getCancel() { + return cancel; + } + + public void setCancel(int cancel) { + this.cancel = cancel; + } + + public String getDeptName() { + return deptName; + } + + public void setDeptName(String deptName) { + this.deptName = deptName; + } + + public int getBeforeGet() { + return beforeGet; + } + + public void setBeforeGet(int beforeGet) { + this.beforeGet = beforeGet; + } + + public String getDeptId() { + return deptId; + } + + public void setDeptId(String deptId) { + this.deptId = deptId; + } + + public int getInHandle() { + return inHandle; + } + + public void setInHandle(int inHandle) { + this.inHandle = inHandle; + } + + public int getBeforeConfirm() { + return beforeConfirm; + } + + public void setBeforeConfirm(int beforeConfirm) { + this.beforeConfirm = beforeConfirm; + } + } +} diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/utils/ChartViewHelper.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/utils/ChartViewHelper.kt index 91dc43c..a1b4784 100644 --- a/app/src/main/java/com/casic/app/smartwell/sanxi/utils/ChartViewHelper.kt +++ b/app/src/main/java/com/casic/app/smartwell/sanxi/utils/ChartViewHelper.kt @@ -69,7 +69,7 @@ val barDataSets: MutableList = ArrayList() //绑定数据 val dataSet = BarDataSet(entries, "") - dataSet.color = R.color.color_6.convertColor(context) + dataSet.color = R.color.color_8.convertColor(context) barDataSets.add(dataSet) val barData = BarData(barDataSets) barData.barWidth = 0.75f @@ -103,8 +103,8 @@ dataSet.color = it.lineColor //圆点颜色 dataSet.setCircleColor(it.lineColor) - dataSet.setDrawFilled(true) - dataSet.fillColor = it.lineColor +// dataSet.setDrawFilled(true) +// dataSet.fillColor = it.lineColor dataSet.mode = LineDataSet.Mode.CUBIC_BEZIER lineDataSets.add(dataSet) } diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitService.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitService.kt index 2314a33..d02db3f 100644 --- a/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitService.kt +++ b/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitService.kt @@ -206,6 +206,16 @@ ): String /** + * 获取最近30天工单 + */ + @GET("/statics/jobsByDept") + suspend fun obtainMonthOrder( + @Header("token") token: String, + @Query("beginTime") beginTime: String, + @Query("endTime") endTime: String + ): String + + /** * 获取获取闸井列表 * * @param keywords 关键字 diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/extensions/Long.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/extensions/Long.kt index d321829..11db041 100644 --- a/app/src/main/java/com/casic/app/smartwell/sanxi/extensions/Long.kt +++ b/app/src/main/java/com/casic/app/smartwell/sanxi/extensions/Long.kt @@ -26,6 +26,14 @@ val dateFormat = SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.CHINA) val calendar = Calendar.getInstance() calendar.time = Date(this) - calendar.set(Calendar.DAY_OF_YEAR, calendar.get(Calendar.DAY_OF_YEAR) - 6) + calendar.set(Calendar.DAY_OF_YEAR, calendar.get(Calendar.DAY_OF_YEAR) - 7) + return dateFormat.format(calendar.time) +} + +fun Long.timestampToLastMonthTime(): String { + val dateFormat = SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.CHINA) + val calendar = Calendar.getInstance() + calendar.time = Date(this) + calendar.set(Calendar.DAY_OF_YEAR, calendar.get(Calendar.DAY_OF_YEAR) - 30) return dateFormat.format(calendar.time) } \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/extensions/String.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/extensions/String.kt index c41c867..e094b53 100644 --- a/app/src/main/java/com/casic/app/smartwell/sanxi/extensions/String.kt +++ b/app/src/main/java/com/casic/app/smartwell/sanxi/extensions/String.kt @@ -20,6 +20,8 @@ import java.io.FileOutputStream import java.io.IOException import java.io.InputStream +import java.text.SimpleDateFormat +import java.util.* /** * String扩展方法 @@ -120,6 +122,21 @@ } } +fun String.toMonthDay(): String { + if (this.isBlank()) { + return "" + } + try { + val dateFormat = SimpleDateFormat("yyyy年MM月dd日", Locale.CHINA) + val date = dateFormat.parse(this) ?: return "" + val monthDayFormat = SimpleDateFormat("MM/dd", Locale.CHINA) + return monthDayFormat.format(date) + } catch (e: Exception) { + e.printStackTrace() + return "" + } +} + fun String.separateResponseCode(): Int { if (this.isBlank()) { return 404 diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/fragment/HomePageFragment.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/fragment/HomePageFragment.kt index e68e7c1..7d544d7 100644 --- a/app/src/main/java/com/casic/app/smartwell/sanxi/fragment/HomePageFragment.kt +++ b/app/src/main/java/com/casic/app/smartwell/sanxi/fragment/HomePageFragment.kt @@ -36,6 +36,8 @@ import kotlinx.android.synthetic.main.include_home_data_overview.view.* import kotlinx.android.synthetic.main.include_home_device_chart.* import kotlinx.android.synthetic.main.include_home_device_type_chart.* +import kotlinx.android.synthetic.main.include_home_device_type_chart.deviceTypeChart +import kotlinx.android.synthetic.main.include_home_order_chart.* import kotlinx.android.synthetic.main.include_home_well_chart.* import kotlinx.android.synthetic.main.include_home_well_type_chart.* @@ -246,8 +248,7 @@ if (it.code == 200) { val dataModel = it.data!! dataModel.forEach { dateModel -> - val split = dateModel.date.toString().split("年") - xAxisDate.add(split[1]) + xAxisDate.add(dateModel.date.toString().toMonthDay()) } val lines = 2 @@ -279,6 +280,37 @@ ChartViewHelper.setLineChartData(alarmLineChart, xAxisDate, entryModels) } }) + + //近30天工单统计 + workOrderViewModel.obtainMonthOrder( + currentTimeMillis.timestampToLastMonthTime(), + currentTimeMillis.timestampToTime() + ) + workOrderViewModel.monthOrderModel.observe(viewLifecycleOwner, { + if (it.code == 200) { + val xAxisLabel: MutableList = ArrayList() + val barEntries: MutableList = ArrayList() + it.data?.forEachIndexed { index, dataBean -> + xAxisLabel.add(dataBean.deptName.toString()) + val dataValue = if (dataBean.beforeGet.toString().isBlank()) { + 0f + } else { + dataBean.beforeGet.toFloat() + } + val completedValue = if (dataBean.over.toString().isBlank()) { + 0f + } else { + dataBean.over.toFloat() + } + //柱状图 +// barEntries.add(BarEntry(index.toFloat(), dataValue)) + barEntries.add(BarEntry(index.toFloat(), completedValue)) + } + ChartViewHelper.setBarChartData( + orderBarChart, xAxisLabel, barEntries, "monthOrderData" + ) + } + }) return homeView } diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/model/MonthOrderModel.java b/app/src/main/java/com/casic/app/smartwell/sanxi/model/MonthOrderModel.java new file mode 100644 index 0000000..e895ffd --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/sanxi/model/MonthOrderModel.java @@ -0,0 +1,109 @@ +package com.casic.app.smartwell.sanxi.model; + +import java.util.List; + +public class MonthOrderModel { + + private int code; + private List data; + private String message; + private boolean success; + + public int getCode() { + return code; + } + + public void setCode(int code) { + this.code = code; + } + + public List getData() { + return data; + } + + public void setData(List data) { + this.data = data; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + + public boolean isSuccess() { + return success; + } + + public void setSuccess(boolean success) { + this.success = success; + } + + public static class DataDTO { + private int over; + private int cancel; + private String deptName; + private int beforeGet; + private String deptId; + private int inHandle; + private int beforeConfirm; + + public int getOver() { + return over; + } + + public void setOver(int over) { + this.over = over; + } + + public int getCancel() { + return cancel; + } + + public void setCancel(int cancel) { + this.cancel = cancel; + } + + public String getDeptName() { + return deptName; + } + + public void setDeptName(String deptName) { + this.deptName = deptName; + } + + public int getBeforeGet() { + return beforeGet; + } + + public void setBeforeGet(int beforeGet) { + this.beforeGet = beforeGet; + } + + public String getDeptId() { + return deptId; + } + + public void setDeptId(String deptId) { + this.deptId = deptId; + } + + public int getInHandle() { + return inHandle; + } + + public void setInHandle(int inHandle) { + this.inHandle = inHandle; + } + + public int getBeforeConfirm() { + return beforeConfirm; + } + + public void setBeforeConfirm(int beforeConfirm) { + this.beforeConfirm = beforeConfirm; + } + } +} diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/utils/ChartViewHelper.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/utils/ChartViewHelper.kt index 91dc43c..a1b4784 100644 --- a/app/src/main/java/com/casic/app/smartwell/sanxi/utils/ChartViewHelper.kt +++ b/app/src/main/java/com/casic/app/smartwell/sanxi/utils/ChartViewHelper.kt @@ -69,7 +69,7 @@ val barDataSets: MutableList = ArrayList() //绑定数据 val dataSet = BarDataSet(entries, "") - dataSet.color = R.color.color_6.convertColor(context) + dataSet.color = R.color.color_8.convertColor(context) barDataSets.add(dataSet) val barData = BarData(barDataSets) barData.barWidth = 0.75f @@ -103,8 +103,8 @@ dataSet.color = it.lineColor //圆点颜色 dataSet.setCircleColor(it.lineColor) - dataSet.setDrawFilled(true) - dataSet.fillColor = it.lineColor +// dataSet.setDrawFilled(true) +// dataSet.fillColor = it.lineColor dataSet.mode = LineDataSet.Mode.CUBIC_BEZIER lineDataSets.add(dataSet) } diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitService.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitService.kt index 2314a33..d02db3f 100644 --- a/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitService.kt +++ b/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitService.kt @@ -206,6 +206,16 @@ ): String /** + * 获取最近30天工单 + */ + @GET("/statics/jobsByDept") + suspend fun obtainMonthOrder( + @Header("token") token: String, + @Query("beginTime") beginTime: String, + @Query("endTime") endTime: String + ): String + + /** * 获取获取闸井列表 * * @param keywords 关键字 diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitServiceManager.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitServiceManager.kt index b6d6134..c958f57 100644 --- a/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitServiceManager.kt +++ b/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitServiceManager.kt @@ -208,6 +208,13 @@ return api.obtainDayAlarm(AuthenticationHelper.token!!, deviceType, startDate, endDate) } + /** + * 获取最近30天工单 + */ + suspend fun obtainMonthOrder(startDate: String, endDate: String): String { + return api.obtainMonthOrder(AuthenticationHelper.token!!, startDate, endDate) + } + // /** // * 获取获取闸井列表 // */ diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/extensions/Long.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/extensions/Long.kt index d321829..11db041 100644 --- a/app/src/main/java/com/casic/app/smartwell/sanxi/extensions/Long.kt +++ b/app/src/main/java/com/casic/app/smartwell/sanxi/extensions/Long.kt @@ -26,6 +26,14 @@ val dateFormat = SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.CHINA) val calendar = Calendar.getInstance() calendar.time = Date(this) - calendar.set(Calendar.DAY_OF_YEAR, calendar.get(Calendar.DAY_OF_YEAR) - 6) + calendar.set(Calendar.DAY_OF_YEAR, calendar.get(Calendar.DAY_OF_YEAR) - 7) + return dateFormat.format(calendar.time) +} + +fun Long.timestampToLastMonthTime(): String { + val dateFormat = SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.CHINA) + val calendar = Calendar.getInstance() + calendar.time = Date(this) + calendar.set(Calendar.DAY_OF_YEAR, calendar.get(Calendar.DAY_OF_YEAR) - 30) return dateFormat.format(calendar.time) } \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/extensions/String.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/extensions/String.kt index c41c867..e094b53 100644 --- a/app/src/main/java/com/casic/app/smartwell/sanxi/extensions/String.kt +++ b/app/src/main/java/com/casic/app/smartwell/sanxi/extensions/String.kt @@ -20,6 +20,8 @@ import java.io.FileOutputStream import java.io.IOException import java.io.InputStream +import java.text.SimpleDateFormat +import java.util.* /** * String扩展方法 @@ -120,6 +122,21 @@ } } +fun String.toMonthDay(): String { + if (this.isBlank()) { + return "" + } + try { + val dateFormat = SimpleDateFormat("yyyy年MM月dd日", Locale.CHINA) + val date = dateFormat.parse(this) ?: return "" + val monthDayFormat = SimpleDateFormat("MM/dd", Locale.CHINA) + return monthDayFormat.format(date) + } catch (e: Exception) { + e.printStackTrace() + return "" + } +} + fun String.separateResponseCode(): Int { if (this.isBlank()) { return 404 diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/fragment/HomePageFragment.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/fragment/HomePageFragment.kt index e68e7c1..7d544d7 100644 --- a/app/src/main/java/com/casic/app/smartwell/sanxi/fragment/HomePageFragment.kt +++ b/app/src/main/java/com/casic/app/smartwell/sanxi/fragment/HomePageFragment.kt @@ -36,6 +36,8 @@ import kotlinx.android.synthetic.main.include_home_data_overview.view.* import kotlinx.android.synthetic.main.include_home_device_chart.* import kotlinx.android.synthetic.main.include_home_device_type_chart.* +import kotlinx.android.synthetic.main.include_home_device_type_chart.deviceTypeChart +import kotlinx.android.synthetic.main.include_home_order_chart.* import kotlinx.android.synthetic.main.include_home_well_chart.* import kotlinx.android.synthetic.main.include_home_well_type_chart.* @@ -246,8 +248,7 @@ if (it.code == 200) { val dataModel = it.data!! dataModel.forEach { dateModel -> - val split = dateModel.date.toString().split("年") - xAxisDate.add(split[1]) + xAxisDate.add(dateModel.date.toString().toMonthDay()) } val lines = 2 @@ -279,6 +280,37 @@ ChartViewHelper.setLineChartData(alarmLineChart, xAxisDate, entryModels) } }) + + //近30天工单统计 + workOrderViewModel.obtainMonthOrder( + currentTimeMillis.timestampToLastMonthTime(), + currentTimeMillis.timestampToTime() + ) + workOrderViewModel.monthOrderModel.observe(viewLifecycleOwner, { + if (it.code == 200) { + val xAxisLabel: MutableList = ArrayList() + val barEntries: MutableList = ArrayList() + it.data?.forEachIndexed { index, dataBean -> + xAxisLabel.add(dataBean.deptName.toString()) + val dataValue = if (dataBean.beforeGet.toString().isBlank()) { + 0f + } else { + dataBean.beforeGet.toFloat() + } + val completedValue = if (dataBean.over.toString().isBlank()) { + 0f + } else { + dataBean.over.toFloat() + } + //柱状图 +// barEntries.add(BarEntry(index.toFloat(), dataValue)) + barEntries.add(BarEntry(index.toFloat(), completedValue)) + } + ChartViewHelper.setBarChartData( + orderBarChart, xAxisLabel, barEntries, "monthOrderData" + ) + } + }) return homeView } diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/model/MonthOrderModel.java b/app/src/main/java/com/casic/app/smartwell/sanxi/model/MonthOrderModel.java new file mode 100644 index 0000000..e895ffd --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/sanxi/model/MonthOrderModel.java @@ -0,0 +1,109 @@ +package com.casic.app.smartwell.sanxi.model; + +import java.util.List; + +public class MonthOrderModel { + + private int code; + private List data; + private String message; + private boolean success; + + public int getCode() { + return code; + } + + public void setCode(int code) { + this.code = code; + } + + public List getData() { + return data; + } + + public void setData(List data) { + this.data = data; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + + public boolean isSuccess() { + return success; + } + + public void setSuccess(boolean success) { + this.success = success; + } + + public static class DataDTO { + private int over; + private int cancel; + private String deptName; + private int beforeGet; + private String deptId; + private int inHandle; + private int beforeConfirm; + + public int getOver() { + return over; + } + + public void setOver(int over) { + this.over = over; + } + + public int getCancel() { + return cancel; + } + + public void setCancel(int cancel) { + this.cancel = cancel; + } + + public String getDeptName() { + return deptName; + } + + public void setDeptName(String deptName) { + this.deptName = deptName; + } + + public int getBeforeGet() { + return beforeGet; + } + + public void setBeforeGet(int beforeGet) { + this.beforeGet = beforeGet; + } + + public String getDeptId() { + return deptId; + } + + public void setDeptId(String deptId) { + this.deptId = deptId; + } + + public int getInHandle() { + return inHandle; + } + + public void setInHandle(int inHandle) { + this.inHandle = inHandle; + } + + public int getBeforeConfirm() { + return beforeConfirm; + } + + public void setBeforeConfirm(int beforeConfirm) { + this.beforeConfirm = beforeConfirm; + } + } +} diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/utils/ChartViewHelper.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/utils/ChartViewHelper.kt index 91dc43c..a1b4784 100644 --- a/app/src/main/java/com/casic/app/smartwell/sanxi/utils/ChartViewHelper.kt +++ b/app/src/main/java/com/casic/app/smartwell/sanxi/utils/ChartViewHelper.kt @@ -69,7 +69,7 @@ val barDataSets: MutableList = ArrayList() //绑定数据 val dataSet = BarDataSet(entries, "") - dataSet.color = R.color.color_6.convertColor(context) + dataSet.color = R.color.color_8.convertColor(context) barDataSets.add(dataSet) val barData = BarData(barDataSets) barData.barWidth = 0.75f @@ -103,8 +103,8 @@ dataSet.color = it.lineColor //圆点颜色 dataSet.setCircleColor(it.lineColor) - dataSet.setDrawFilled(true) - dataSet.fillColor = it.lineColor +// dataSet.setDrawFilled(true) +// dataSet.fillColor = it.lineColor dataSet.mode = LineDataSet.Mode.CUBIC_BEZIER lineDataSets.add(dataSet) } diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitService.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitService.kt index 2314a33..d02db3f 100644 --- a/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitService.kt +++ b/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitService.kt @@ -206,6 +206,16 @@ ): String /** + * 获取最近30天工单 + */ + @GET("/statics/jobsByDept") + suspend fun obtainMonthOrder( + @Header("token") token: String, + @Query("beginTime") beginTime: String, + @Query("endTime") endTime: String + ): String + + /** * 获取获取闸井列表 * * @param keywords 关键字 diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitServiceManager.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitServiceManager.kt index b6d6134..c958f57 100644 --- a/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitServiceManager.kt +++ b/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitServiceManager.kt @@ -208,6 +208,13 @@ return api.obtainDayAlarm(AuthenticationHelper.token!!, deviceType, startDate, endDate) } + /** + * 获取最近30天工单 + */ + suspend fun obtainMonthOrder(startDate: String, endDate: String): String { + return api.obtainMonthOrder(AuthenticationHelper.token!!, startDate, endDate) + } + // /** // * 获取获取闸井列表 // */ diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/vm/WorkOrderViewModel.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/vm/WorkOrderViewModel.kt index 2d2f78c..2eee546 100644 --- a/app/src/main/java/com/casic/app/smartwell/sanxi/vm/WorkOrderViewModel.kt +++ b/app/src/main/java/com/casic/app/smartwell/sanxi/vm/WorkOrderViewModel.kt @@ -6,6 +6,7 @@ import com.casic.app.smartwell.sanxi.extensions.separateResponseCode import com.casic.app.smartwell.sanxi.extensions.show import com.casic.app.smartwell.sanxi.extensions.toErrorMessage +import com.casic.app.smartwell.sanxi.model.MonthOrderModel import com.casic.app.smartwell.sanxi.model.OrderStatusModel import com.casic.app.smartwell.sanxi.model.WorkOrderListModel import com.casic.app.smartwell.sanxi.utils.retrofit.RetrofitServiceManager @@ -19,6 +20,7 @@ val orderListModel = MutableLiveData() val orderStatusModel = MutableLiveData() val orderCountModel = MutableLiveData>() + val monthOrderModel = MutableLiveData() fun obtainWorkOrderListByState( keywords: String, alarmType: String, alarmContentType: String, jobStatus: String, page: Int @@ -72,4 +74,18 @@ }, { it.printStackTrace() }) + + fun obtainMonthOrder(startDate: String, endDate: String) = launch({ + val response = RetrofitServiceManager.obtainMonthOrder(startDate, endDate) + val responseCode = response.separateResponseCode() + if (responseCode == 200) { + monthOrderModel.value = gson.fromJson( + response, object : TypeToken() {}.type + ) + } else { + response.toErrorMessage().show() + } + }, { + it.printStackTrace() + }) } \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/extensions/Long.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/extensions/Long.kt index d321829..11db041 100644 --- a/app/src/main/java/com/casic/app/smartwell/sanxi/extensions/Long.kt +++ b/app/src/main/java/com/casic/app/smartwell/sanxi/extensions/Long.kt @@ -26,6 +26,14 @@ val dateFormat = SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.CHINA) val calendar = Calendar.getInstance() calendar.time = Date(this) - calendar.set(Calendar.DAY_OF_YEAR, calendar.get(Calendar.DAY_OF_YEAR) - 6) + calendar.set(Calendar.DAY_OF_YEAR, calendar.get(Calendar.DAY_OF_YEAR) - 7) + return dateFormat.format(calendar.time) +} + +fun Long.timestampToLastMonthTime(): String { + val dateFormat = SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.CHINA) + val calendar = Calendar.getInstance() + calendar.time = Date(this) + calendar.set(Calendar.DAY_OF_YEAR, calendar.get(Calendar.DAY_OF_YEAR) - 30) return dateFormat.format(calendar.time) } \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/extensions/String.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/extensions/String.kt index c41c867..e094b53 100644 --- a/app/src/main/java/com/casic/app/smartwell/sanxi/extensions/String.kt +++ b/app/src/main/java/com/casic/app/smartwell/sanxi/extensions/String.kt @@ -20,6 +20,8 @@ import java.io.FileOutputStream import java.io.IOException import java.io.InputStream +import java.text.SimpleDateFormat +import java.util.* /** * String扩展方法 @@ -120,6 +122,21 @@ } } +fun String.toMonthDay(): String { + if (this.isBlank()) { + return "" + } + try { + val dateFormat = SimpleDateFormat("yyyy年MM月dd日", Locale.CHINA) + val date = dateFormat.parse(this) ?: return "" + val monthDayFormat = SimpleDateFormat("MM/dd", Locale.CHINA) + return monthDayFormat.format(date) + } catch (e: Exception) { + e.printStackTrace() + return "" + } +} + fun String.separateResponseCode(): Int { if (this.isBlank()) { return 404 diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/fragment/HomePageFragment.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/fragment/HomePageFragment.kt index e68e7c1..7d544d7 100644 --- a/app/src/main/java/com/casic/app/smartwell/sanxi/fragment/HomePageFragment.kt +++ b/app/src/main/java/com/casic/app/smartwell/sanxi/fragment/HomePageFragment.kt @@ -36,6 +36,8 @@ import kotlinx.android.synthetic.main.include_home_data_overview.view.* import kotlinx.android.synthetic.main.include_home_device_chart.* import kotlinx.android.synthetic.main.include_home_device_type_chart.* +import kotlinx.android.synthetic.main.include_home_device_type_chart.deviceTypeChart +import kotlinx.android.synthetic.main.include_home_order_chart.* import kotlinx.android.synthetic.main.include_home_well_chart.* import kotlinx.android.synthetic.main.include_home_well_type_chart.* @@ -246,8 +248,7 @@ if (it.code == 200) { val dataModel = it.data!! dataModel.forEach { dateModel -> - val split = dateModel.date.toString().split("年") - xAxisDate.add(split[1]) + xAxisDate.add(dateModel.date.toString().toMonthDay()) } val lines = 2 @@ -279,6 +280,37 @@ ChartViewHelper.setLineChartData(alarmLineChart, xAxisDate, entryModels) } }) + + //近30天工单统计 + workOrderViewModel.obtainMonthOrder( + currentTimeMillis.timestampToLastMonthTime(), + currentTimeMillis.timestampToTime() + ) + workOrderViewModel.monthOrderModel.observe(viewLifecycleOwner, { + if (it.code == 200) { + val xAxisLabel: MutableList = ArrayList() + val barEntries: MutableList = ArrayList() + it.data?.forEachIndexed { index, dataBean -> + xAxisLabel.add(dataBean.deptName.toString()) + val dataValue = if (dataBean.beforeGet.toString().isBlank()) { + 0f + } else { + dataBean.beforeGet.toFloat() + } + val completedValue = if (dataBean.over.toString().isBlank()) { + 0f + } else { + dataBean.over.toFloat() + } + //柱状图 +// barEntries.add(BarEntry(index.toFloat(), dataValue)) + barEntries.add(BarEntry(index.toFloat(), completedValue)) + } + ChartViewHelper.setBarChartData( + orderBarChart, xAxisLabel, barEntries, "monthOrderData" + ) + } + }) return homeView } diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/model/MonthOrderModel.java b/app/src/main/java/com/casic/app/smartwell/sanxi/model/MonthOrderModel.java new file mode 100644 index 0000000..e895ffd --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/sanxi/model/MonthOrderModel.java @@ -0,0 +1,109 @@ +package com.casic.app.smartwell.sanxi.model; + +import java.util.List; + +public class MonthOrderModel { + + private int code; + private List data; + private String message; + private boolean success; + + public int getCode() { + return code; + } + + public void setCode(int code) { + this.code = code; + } + + public List getData() { + return data; + } + + public void setData(List data) { + this.data = data; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + + public boolean isSuccess() { + return success; + } + + public void setSuccess(boolean success) { + this.success = success; + } + + public static class DataDTO { + private int over; + private int cancel; + private String deptName; + private int beforeGet; + private String deptId; + private int inHandle; + private int beforeConfirm; + + public int getOver() { + return over; + } + + public void setOver(int over) { + this.over = over; + } + + public int getCancel() { + return cancel; + } + + public void setCancel(int cancel) { + this.cancel = cancel; + } + + public String getDeptName() { + return deptName; + } + + public void setDeptName(String deptName) { + this.deptName = deptName; + } + + public int getBeforeGet() { + return beforeGet; + } + + public void setBeforeGet(int beforeGet) { + this.beforeGet = beforeGet; + } + + public String getDeptId() { + return deptId; + } + + public void setDeptId(String deptId) { + this.deptId = deptId; + } + + public int getInHandle() { + return inHandle; + } + + public void setInHandle(int inHandle) { + this.inHandle = inHandle; + } + + public int getBeforeConfirm() { + return beforeConfirm; + } + + public void setBeforeConfirm(int beforeConfirm) { + this.beforeConfirm = beforeConfirm; + } + } +} diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/utils/ChartViewHelper.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/utils/ChartViewHelper.kt index 91dc43c..a1b4784 100644 --- a/app/src/main/java/com/casic/app/smartwell/sanxi/utils/ChartViewHelper.kt +++ b/app/src/main/java/com/casic/app/smartwell/sanxi/utils/ChartViewHelper.kt @@ -69,7 +69,7 @@ val barDataSets: MutableList = ArrayList() //绑定数据 val dataSet = BarDataSet(entries, "") - dataSet.color = R.color.color_6.convertColor(context) + dataSet.color = R.color.color_8.convertColor(context) barDataSets.add(dataSet) val barData = BarData(barDataSets) barData.barWidth = 0.75f @@ -103,8 +103,8 @@ dataSet.color = it.lineColor //圆点颜色 dataSet.setCircleColor(it.lineColor) - dataSet.setDrawFilled(true) - dataSet.fillColor = it.lineColor +// dataSet.setDrawFilled(true) +// dataSet.fillColor = it.lineColor dataSet.mode = LineDataSet.Mode.CUBIC_BEZIER lineDataSets.add(dataSet) } diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitService.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitService.kt index 2314a33..d02db3f 100644 --- a/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitService.kt +++ b/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitService.kt @@ -206,6 +206,16 @@ ): String /** + * 获取最近30天工单 + */ + @GET("/statics/jobsByDept") + suspend fun obtainMonthOrder( + @Header("token") token: String, + @Query("beginTime") beginTime: String, + @Query("endTime") endTime: String + ): String + + /** * 获取获取闸井列表 * * @param keywords 关键字 diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitServiceManager.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitServiceManager.kt index b6d6134..c958f57 100644 --- a/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitServiceManager.kt +++ b/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitServiceManager.kt @@ -208,6 +208,13 @@ return api.obtainDayAlarm(AuthenticationHelper.token!!, deviceType, startDate, endDate) } + /** + * 获取最近30天工单 + */ + suspend fun obtainMonthOrder(startDate: String, endDate: String): String { + return api.obtainMonthOrder(AuthenticationHelper.token!!, startDate, endDate) + } + // /** // * 获取获取闸井列表 // */ diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/vm/WorkOrderViewModel.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/vm/WorkOrderViewModel.kt index 2d2f78c..2eee546 100644 --- a/app/src/main/java/com/casic/app/smartwell/sanxi/vm/WorkOrderViewModel.kt +++ b/app/src/main/java/com/casic/app/smartwell/sanxi/vm/WorkOrderViewModel.kt @@ -6,6 +6,7 @@ import com.casic.app.smartwell.sanxi.extensions.separateResponseCode import com.casic.app.smartwell.sanxi.extensions.show import com.casic.app.smartwell.sanxi.extensions.toErrorMessage +import com.casic.app.smartwell.sanxi.model.MonthOrderModel import com.casic.app.smartwell.sanxi.model.OrderStatusModel import com.casic.app.smartwell.sanxi.model.WorkOrderListModel import com.casic.app.smartwell.sanxi.utils.retrofit.RetrofitServiceManager @@ -19,6 +20,7 @@ val orderListModel = MutableLiveData() val orderStatusModel = MutableLiveData() val orderCountModel = MutableLiveData>() + val monthOrderModel = MutableLiveData() fun obtainWorkOrderListByState( keywords: String, alarmType: String, alarmContentType: String, jobStatus: String, page: Int @@ -72,4 +74,18 @@ }, { it.printStackTrace() }) + + fun obtainMonthOrder(startDate: String, endDate: String) = launch({ + val response = RetrofitServiceManager.obtainMonthOrder(startDate, endDate) + val responseCode = response.separateResponseCode() + if (responseCode == 200) { + monthOrderModel.value = gson.fromJson( + response, object : TypeToken() {}.type + ) + } else { + response.toErrorMessage().show() + } + }, { + it.printStackTrace() + }) } \ No newline at end of file diff --git a/app/src/main/res/layout/include_home_order_chart.xml b/app/src/main/res/layout/include_home_order_chart.xml index 952b01f..be17e3e 100644 --- a/app/src/main/res/layout/include_home_order_chart.xml +++ b/app/src/main/res/layout/include_home_order_chart.xml @@ -2,8 +2,8 @@ - \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/extensions/Long.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/extensions/Long.kt index d321829..11db041 100644 --- a/app/src/main/java/com/casic/app/smartwell/sanxi/extensions/Long.kt +++ b/app/src/main/java/com/casic/app/smartwell/sanxi/extensions/Long.kt @@ -26,6 +26,14 @@ val dateFormat = SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.CHINA) val calendar = Calendar.getInstance() calendar.time = Date(this) - calendar.set(Calendar.DAY_OF_YEAR, calendar.get(Calendar.DAY_OF_YEAR) - 6) + calendar.set(Calendar.DAY_OF_YEAR, calendar.get(Calendar.DAY_OF_YEAR) - 7) + return dateFormat.format(calendar.time) +} + +fun Long.timestampToLastMonthTime(): String { + val dateFormat = SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.CHINA) + val calendar = Calendar.getInstance() + calendar.time = Date(this) + calendar.set(Calendar.DAY_OF_YEAR, calendar.get(Calendar.DAY_OF_YEAR) - 30) return dateFormat.format(calendar.time) } \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/extensions/String.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/extensions/String.kt index c41c867..e094b53 100644 --- a/app/src/main/java/com/casic/app/smartwell/sanxi/extensions/String.kt +++ b/app/src/main/java/com/casic/app/smartwell/sanxi/extensions/String.kt @@ -20,6 +20,8 @@ import java.io.FileOutputStream import java.io.IOException import java.io.InputStream +import java.text.SimpleDateFormat +import java.util.* /** * String扩展方法 @@ -120,6 +122,21 @@ } } +fun String.toMonthDay(): String { + if (this.isBlank()) { + return "" + } + try { + val dateFormat = SimpleDateFormat("yyyy年MM月dd日", Locale.CHINA) + val date = dateFormat.parse(this) ?: return "" + val monthDayFormat = SimpleDateFormat("MM/dd", Locale.CHINA) + return monthDayFormat.format(date) + } catch (e: Exception) { + e.printStackTrace() + return "" + } +} + fun String.separateResponseCode(): Int { if (this.isBlank()) { return 404 diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/fragment/HomePageFragment.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/fragment/HomePageFragment.kt index e68e7c1..7d544d7 100644 --- a/app/src/main/java/com/casic/app/smartwell/sanxi/fragment/HomePageFragment.kt +++ b/app/src/main/java/com/casic/app/smartwell/sanxi/fragment/HomePageFragment.kt @@ -36,6 +36,8 @@ import kotlinx.android.synthetic.main.include_home_data_overview.view.* import kotlinx.android.synthetic.main.include_home_device_chart.* import kotlinx.android.synthetic.main.include_home_device_type_chart.* +import kotlinx.android.synthetic.main.include_home_device_type_chart.deviceTypeChart +import kotlinx.android.synthetic.main.include_home_order_chart.* import kotlinx.android.synthetic.main.include_home_well_chart.* import kotlinx.android.synthetic.main.include_home_well_type_chart.* @@ -246,8 +248,7 @@ if (it.code == 200) { val dataModel = it.data!! dataModel.forEach { dateModel -> - val split = dateModel.date.toString().split("年") - xAxisDate.add(split[1]) + xAxisDate.add(dateModel.date.toString().toMonthDay()) } val lines = 2 @@ -279,6 +280,37 @@ ChartViewHelper.setLineChartData(alarmLineChart, xAxisDate, entryModels) } }) + + //近30天工单统计 + workOrderViewModel.obtainMonthOrder( + currentTimeMillis.timestampToLastMonthTime(), + currentTimeMillis.timestampToTime() + ) + workOrderViewModel.monthOrderModel.observe(viewLifecycleOwner, { + if (it.code == 200) { + val xAxisLabel: MutableList = ArrayList() + val barEntries: MutableList = ArrayList() + it.data?.forEachIndexed { index, dataBean -> + xAxisLabel.add(dataBean.deptName.toString()) + val dataValue = if (dataBean.beforeGet.toString().isBlank()) { + 0f + } else { + dataBean.beforeGet.toFloat() + } + val completedValue = if (dataBean.over.toString().isBlank()) { + 0f + } else { + dataBean.over.toFloat() + } + //柱状图 +// barEntries.add(BarEntry(index.toFloat(), dataValue)) + barEntries.add(BarEntry(index.toFloat(), completedValue)) + } + ChartViewHelper.setBarChartData( + orderBarChart, xAxisLabel, barEntries, "monthOrderData" + ) + } + }) return homeView } diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/model/MonthOrderModel.java b/app/src/main/java/com/casic/app/smartwell/sanxi/model/MonthOrderModel.java new file mode 100644 index 0000000..e895ffd --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/sanxi/model/MonthOrderModel.java @@ -0,0 +1,109 @@ +package com.casic.app.smartwell.sanxi.model; + +import java.util.List; + +public class MonthOrderModel { + + private int code; + private List data; + private String message; + private boolean success; + + public int getCode() { + return code; + } + + public void setCode(int code) { + this.code = code; + } + + public List getData() { + return data; + } + + public void setData(List data) { + this.data = data; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + + public boolean isSuccess() { + return success; + } + + public void setSuccess(boolean success) { + this.success = success; + } + + public static class DataDTO { + private int over; + private int cancel; + private String deptName; + private int beforeGet; + private String deptId; + private int inHandle; + private int beforeConfirm; + + public int getOver() { + return over; + } + + public void setOver(int over) { + this.over = over; + } + + public int getCancel() { + return cancel; + } + + public void setCancel(int cancel) { + this.cancel = cancel; + } + + public String getDeptName() { + return deptName; + } + + public void setDeptName(String deptName) { + this.deptName = deptName; + } + + public int getBeforeGet() { + return beforeGet; + } + + public void setBeforeGet(int beforeGet) { + this.beforeGet = beforeGet; + } + + public String getDeptId() { + return deptId; + } + + public void setDeptId(String deptId) { + this.deptId = deptId; + } + + public int getInHandle() { + return inHandle; + } + + public void setInHandle(int inHandle) { + this.inHandle = inHandle; + } + + public int getBeforeConfirm() { + return beforeConfirm; + } + + public void setBeforeConfirm(int beforeConfirm) { + this.beforeConfirm = beforeConfirm; + } + } +} diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/utils/ChartViewHelper.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/utils/ChartViewHelper.kt index 91dc43c..a1b4784 100644 --- a/app/src/main/java/com/casic/app/smartwell/sanxi/utils/ChartViewHelper.kt +++ b/app/src/main/java/com/casic/app/smartwell/sanxi/utils/ChartViewHelper.kt @@ -69,7 +69,7 @@ val barDataSets: MutableList = ArrayList() //绑定数据 val dataSet = BarDataSet(entries, "") - dataSet.color = R.color.color_6.convertColor(context) + dataSet.color = R.color.color_8.convertColor(context) barDataSets.add(dataSet) val barData = BarData(barDataSets) barData.barWidth = 0.75f @@ -103,8 +103,8 @@ dataSet.color = it.lineColor //圆点颜色 dataSet.setCircleColor(it.lineColor) - dataSet.setDrawFilled(true) - dataSet.fillColor = it.lineColor +// dataSet.setDrawFilled(true) +// dataSet.fillColor = it.lineColor dataSet.mode = LineDataSet.Mode.CUBIC_BEZIER lineDataSets.add(dataSet) } diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitService.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitService.kt index 2314a33..d02db3f 100644 --- a/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitService.kt +++ b/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitService.kt @@ -206,6 +206,16 @@ ): String /** + * 获取最近30天工单 + */ + @GET("/statics/jobsByDept") + suspend fun obtainMonthOrder( + @Header("token") token: String, + @Query("beginTime") beginTime: String, + @Query("endTime") endTime: String + ): String + + /** * 获取获取闸井列表 * * @param keywords 关键字 diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitServiceManager.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitServiceManager.kt index b6d6134..c958f57 100644 --- a/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitServiceManager.kt +++ b/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitServiceManager.kt @@ -208,6 +208,13 @@ return api.obtainDayAlarm(AuthenticationHelper.token!!, deviceType, startDate, endDate) } + /** + * 获取最近30天工单 + */ + suspend fun obtainMonthOrder(startDate: String, endDate: String): String { + return api.obtainMonthOrder(AuthenticationHelper.token!!, startDate, endDate) + } + // /** // * 获取获取闸井列表 // */ diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/vm/WorkOrderViewModel.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/vm/WorkOrderViewModel.kt index 2d2f78c..2eee546 100644 --- a/app/src/main/java/com/casic/app/smartwell/sanxi/vm/WorkOrderViewModel.kt +++ b/app/src/main/java/com/casic/app/smartwell/sanxi/vm/WorkOrderViewModel.kt @@ -6,6 +6,7 @@ import com.casic.app.smartwell.sanxi.extensions.separateResponseCode import com.casic.app.smartwell.sanxi.extensions.show import com.casic.app.smartwell.sanxi.extensions.toErrorMessage +import com.casic.app.smartwell.sanxi.model.MonthOrderModel import com.casic.app.smartwell.sanxi.model.OrderStatusModel import com.casic.app.smartwell.sanxi.model.WorkOrderListModel import com.casic.app.smartwell.sanxi.utils.retrofit.RetrofitServiceManager @@ -19,6 +20,7 @@ val orderListModel = MutableLiveData() val orderStatusModel = MutableLiveData() val orderCountModel = MutableLiveData>() + val monthOrderModel = MutableLiveData() fun obtainWorkOrderListByState( keywords: String, alarmType: String, alarmContentType: String, jobStatus: String, page: Int @@ -72,4 +74,18 @@ }, { it.printStackTrace() }) + + fun obtainMonthOrder(startDate: String, endDate: String) = launch({ + val response = RetrofitServiceManager.obtainMonthOrder(startDate, endDate) + val responseCode = response.separateResponseCode() + if (responseCode == 200) { + monthOrderModel.value = gson.fromJson( + response, object : TypeToken() {}.type + ) + } else { + response.toErrorMessage().show() + } + }, { + it.printStackTrace() + }) } \ No newline at end of file diff --git a/app/src/main/res/layout/include_home_order_chart.xml b/app/src/main/res/layout/include_home_order_chart.xml index 952b01f..be17e3e 100644 --- a/app/src/main/res/layout/include_home_order_chart.xml +++ b/app/src/main/res/layout/include_home_order_chart.xml @@ -2,8 +2,8 @@ - \ No newline at end of file diff --git a/app/src/main/res/layout/popu_bar_chart_marker.xml b/app/src/main/res/layout/popu_bar_chart_marker.xml index ba27061..3effc96 100644 --- a/app/src/main/res/layout/popu_bar_chart_marker.xml +++ b/app/src/main/res/layout/popu_bar_chart_marker.xml @@ -21,7 +21,7 @@