完成统计

This commit is contained in:
itgaojian 2023-07-05 17:57:26 +08:00
parent 54606027cd
commit c9e7ae240d
24 changed files with 330 additions and 212 deletions

View File

@ -20,13 +20,13 @@ public class BaseUrlApi {
public static final String SYS_VISITS = "visits/";/*信访系统*/
public static final String BASE_MAIN_IP = IP + SYS_USERCENTER;
// public static final String BASE_CASE_IP = IP + SYS_CASE;
public static final String BASE_CASE_IP = "http://192.168.0.120:9000/" + SYS_CASE;
public static final String BASE_CASE_IP = IP + SYS_CASE;
// public static final String BASE_CASE_IP = "http://192.168.0.120:9000/" + SYS_CASE;
public static final String BASE_CASE_LOCAL_IP = "http://49.233.36.36:58099/case/";
public static final String BASE_LIBRARY_IP = IP + SYS_LIBRARY;
public static final String BASE_TASK_IP = IP + SYS_TASK;
// public static final String BASE_PERSON_IP = IP + SYS_POPULATION;
public static final String BASE_PERSON_IP = "http://192.168.0.115:8080/" + SYS_POPULATION;
public static final String BASE_PERSON_IP = IP + SYS_POPULATION;
// public static final String BASE_PERSON_IP = "http://192.168.0.115:8080/" + SYS_POPULATION;
public static final String BASE_HOUSE_IP = IP + SYS_HOUSE;
public static final String BASE_SECURITY_IP = IP + SYS_SECURITY;
public static final String BASE_VISITS_IP = IP + SYS_VISITS;

View File

@ -61,7 +61,8 @@ public class CustomDialog extends ProgressDialog {
window.setWindowAnimations(R.style.Dialog_ChoseFile);
WindowManager.LayoutParams params = window.getAttributes();
params.dimAmount = 0.3f;
params.width = (int) (width * 0.5);
params.width = (int) (width * 0.4);
// params.width = WindowManager.LayoutParams.WRAP_CONTENT;
params.height = WindowManager.LayoutParams.WRAP_CONTENT;
window.setAttributes(params);
window.setBackgroundDrawable(new ColorDrawable());

View File

@ -53,4 +53,5 @@ public class ViewPageWhiteNavigatorAdapter extends CommonNavigatorAdapter {
indicator.setColors(Color.WHITE);
return indicator;
}
}

View File

@ -66,7 +66,13 @@ public class BallView extends View {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
mWidth = resolveSize(mWidth, widthMeasureSpec);
mHeight = resolveSize(mHeight, heightMeasureSpec);
setMeasuredDimension(mWidth, mHeight);
setMeasuredDimension(
Math.max(getSuggestedMinimumWidth(),
resolveSize(mWidth,
widthMeasureSpec)),
Math.max(getSuggestedMinimumHeight(),
resolveSize(mHeight,
heightMeasureSpec)));
}
@ -104,7 +110,7 @@ public class BallView extends View {
emptyPaint.setColor(Color.parseColor("#FFA900"));
emptyPaint.setStyle(Paint.Style.FILL);
emptyPaint.setTextSize(ConvertUtils.sp2px(14f));
canvas.drawText("暂无数据", canvas.getHeight() / 2, canvas.getWidth() / 2, emptyPaint);
canvas.drawText("暂无数据", mWidth / 2, mHeight / 2, emptyPaint);
}
}

View File

@ -36,9 +36,9 @@ public class CircleChartView extends View {
private Paint mTextPaint;
private Bitmap mBitmap;
private Paint mPaint;
private int mSmallCirRadius = 25; //圆环上小圆的半径
private int mSmallCirRadius = 20; //圆环上小圆的半径
private int mPadding = 25;//圆环距离视图的距离
private int mDisCircle = 35;//中心圆与圆环的间距
private int mDisCircle = 25;//中心圆与圆环的间距
private double mStartAngle = 0;//开始角度
private double mSweepAngle = 0;//角度
private double mSurplusAngle = 360;//
@ -68,6 +68,7 @@ public class CircleChartView extends View {
* 初始化
*/
private void init() {
setLayerType(LAYER_TYPE_SOFTWARE, null);//禁用硬件加速
//初始化画笔
mColorPaint = new Paint();
mColorPaint.setColor(Color.parseColor("#FFA800"));
@ -96,7 +97,7 @@ public class CircleChartView extends View {
mCirclePaint.setColor(Color.parseColor("#E7E7E7"));
mCirclePaint.setStyle(Paint.Style.FILL);
mCirclePaint.setAntiAlias(true);
mCirclePaint.setShadowLayer(3, 4, 4, Color.parseColor("#E5E5E5"));
mCirclePaint.setShadowLayer(2, 4, 4, Color.parseColor("#E9E9E9"));
mBitmap = BitmapFactory.decodeResource(getContext().getResources(), R.drawable.ic_statistics_count_percent_icon);
mPaint = new Paint();
@ -165,10 +166,10 @@ public class CircleChartView extends View {
int bitMapCenterX = mCenterX;
int bitmapCenterY = mCenterY - 20;
Rect dstRect = new Rect();
int l = bitMapCenterX - 40;
int t = bitmapCenterY - 40;
int r = bitMapCenterX + 40;
int b = bitmapCenterY + 40;
int l = bitMapCenterX - 32;
int t = bitmapCenterY - 36;
int r = bitMapCenterX + 32;
int b = bitmapCenterY + 36;
dstRect.set(l, t, r, b);
canvas.drawBitmap(mBitmap, null, dstRect, mTextPaint);
//计算文字的宽度

View File

@ -65,6 +65,8 @@ public class ConditionAllAreaPopup extends BasePopupWindow {
mCurrentAreaStr = currentArea;
mUserLevel = userLevel;
mTvCurrentArea = view.findViewById(R.id.tv_current_area);
// FrameLayout flContent = view.findViewById(R.id.fl_content);
// flContent.setOnClickListener(v -> this.dismiss());
mTvCurrentArea.setText(mCurrentAreaStr);
mRlvArea1 = view.findViewById(R.id.rlv_area_1);
mRlvArea2 = view.findViewById(R.id.rlv_area_2);
@ -173,12 +175,15 @@ public class ConditionAllAreaPopup extends BasePopupWindow {
break;
}
setContentView(view);
setBackgroundColor(Color.parseColor("#11000000"));
setBackgroundColor(Color.parseColor("#67000000"));
setPopupGravity(Gravity.CENTER | Gravity.BOTTOM);
DisplayMetrics displayMetrics = context.getResources().getDisplayMetrics();
int height = (int) (displayMetrics.heightPixels * 0.3);
setHeight(height);
// setHeight(displayMetrics.heightPixels);
setWidth(displayMetrics.widthPixels);
setAlignBackground(true);
setAlignBackgroundGravity(Gravity.TOP);
}

View File

@ -1,6 +1,31 @@
package com.tenlionsoft.baselib.utils;
import android.text.SpannableString;
import android.text.TextUtils;
import android.text.style.RelativeSizeSpan;
import java.text.DecimalFormat;
public final class StringUtils {
/**
* 中文数字
*/
private static final String[] CN_NUM = {"", "", "", "", "", "", "", "", "", ""};
/**
* 中文数字单位
*/
private static final String[] CN_UNIT = {"", "", "", "", "", "", "", "", "亿", "", "", ""};
/**
* 特殊字符
*/
private static final String CN_NEGATIVE = "";
/**
* 特殊字符
*/
private static final String CN_POINT = "";
private StringUtils() {
throw new UnsupportedOperationException("u can't instantiate me...");
@ -182,4 +207,63 @@ public final class StringUtils {
}
return new String(chars);
}
/**
* int 中文数字
* 支持到int最大值
*
* @param intNum 要转换的整型数
* @return 中文数字
*/
public static String int2chineseNum(int intNum) {
StringBuffer sb = new StringBuffer();
boolean isNegative = false;
if (intNum < 0) {
isNegative = true;
intNum *= -1;
}
int count = 0;
while (intNum > 0) {
sb.insert(0, CN_NUM[intNum % 10] + CN_UNIT[count]);
intNum = intNum / 10;
count++;
}
if (isNegative)
sb.insert(0, CN_NEGATIVE);
return sb.toString().replaceAll("零[千百十]", "").replaceAll("零+万", "")
.replaceAll("零+亿", "亿").replaceAll("亿万", "亿零")
.replaceAll("零+", "").replaceAll("零$", "");
}
public static CharSequence numAddUnit(int num) {
if (num > 9999) {
//
DecimalFormat df2 = new DecimalFormat("0.00");
String format = df2.format((float) num / 10000);
String content = format + "";
SpannableString s = new SpannableString(content);
s.setSpan(new RelativeSizeSpan(0.6f), content.indexOf(""), content.length(),
0);
return s;
} else {
DecimalFormat mFormat = new DecimalFormat("###,###,###,###");
String format = mFormat.format(num);
return format;
}
}
public static CharSequence numAddUnit(String num) {
if (TextUtils.isEmpty(num)) return "0";
try {
int i = Integer.parseInt(num);
DecimalFormat mFormat = new DecimalFormat("###,###,###,###");
String format = mFormat.format(i);
return format;
} catch (Exception e) {
return "0";
}
}
}

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="@color/white" />
<corners android:bottomRightRadius="3dp" android:bottomLeftRadius="3dp" />
</shape>

View File

@ -16,8 +16,8 @@
<ProgressBar
android:id="@+id/pb_load"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_centerInParent="true"
android:indeterminateBehavior="repeat"
android:indeterminateDrawable="@drawable/anim_loading" />
@ -35,7 +35,7 @@
android:maxEms="10"
android:maxLines="1"
android:textColor="@color/white"
android:textSize="15sp"
tools:text="加载中加载中加载中加载中加载中...." />
android:textSize="15dp"
tools:text="加载中...." />
</LinearLayout>

View File

@ -3,10 +3,10 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:background="@drawable/shp_rectangle_white"
android:background="@drawable/shp_rectangle_white_ra_bottom"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
@ -82,9 +82,6 @@
android:scrollbarSize="3dp"
android:scrollbarThumbVertical="@color/gray"
android:scrollbars="vertical" />
</LinearLayout>
</LinearLayout>

View File

@ -111,6 +111,7 @@
<color name="file_len_text_color">#686767</color>
<color name="diyishuji_text_color">#535353</color>
<color name="transparent">#00000000</color>
<color name="transparent_3">#67000000</color>
<color name="titleBar">#1189FF</color>
<color name="titleBarDeep">#9F1512</color>
<!--我的页面灰色背景-->

View File

@ -17,11 +17,11 @@ import com.tengshisoft.commonmodule.R2;
import com.tenlionsoft.baselib.constant.PathConfig;
import com.tenlionsoft.baselib.core.widget.base.BaseActivity;
import com.tenlionsoft.baselib.core.widget.base.BaseFragment;
import com.tenlionsoft.baselib.core.widget.base.ViewPageNavigatorAdapter;
import com.tenlionsoft.baselib.core.widget.base.ViewPageWhiteNavigatorAdapter;
import com.tenlionsoft.baselib.utils.UIUtil;
import net.lucode.hackware.magicindicator.MagicIndicator;
import net.lucode.hackware.magicindicator.abs.IPagerNavigator;
import net.lucode.hackware.magicindicator.buildins.commonnavigator.CommonNavigator;
import java.util.ArrayList;
@ -42,9 +42,9 @@ import butterknife.Unbinder;
public class StatisticsCommandActivity extends BaseActivity {
@BindView(R2.id.mi_tabs)
public MagicIndicator mMiTabs;
MagicIndicator mMiTabs;
@BindView(R2.id.vp_content)
public ViewPager2 mVpContent;
ViewPager2 mVpContent;
@BindView(R2.id.iv_back)
ImageView mIvBack;
@ -90,7 +90,10 @@ public class StatisticsCommandActivity extends BaseActivity {
commonNavigator.setAdjustMode(false);
mMiTabs.setNavigator(commonNavigator);
mVpContent.setUserInputEnabled(false);
UIUtil.bindViewPager2(mMiTabs, mVpContent, null);
UIUtil.bindViewPager2(mMiTabs, mVpContent, pos -> {
IPagerNavigator navigator = mMiTabs.getNavigator();
});
mVpContent.setOffscreenPageLimit(1);
}

View File

@ -9,6 +9,7 @@ import com.tengshisoft.commonmodule.R;
import com.tengshisoft.commonmodule.beans.AreaPopulaceBean;
import com.tengshisoft.commonmodule.holders.PopulaceItemHolder;
import com.tenlionsoft.baselib.core.widget.base.BaseRecyclerAdapter;
import com.tenlionsoft.baselib.utils.StringUtils;
import java.util.List;
@ -34,7 +35,8 @@ public class PopulaceCountAdapter extends BaseRecyclerAdapter<AreaPopulaceBean.I
public void bindHolder(PopulaceItemHolder h, int i) {
AreaPopulaceBean.ItemBean bean = mData.get(i);
h.mTvName.setText(bean.getName());
h.mTvCount.setText(bean.getCount());
CharSequence count= StringUtils.numAddUnit(bean.getCount());
h.mTvCount.setText(count);
}
}

View File

@ -37,7 +37,8 @@ import com.tenlionsoft.baselib.core.retrofit_net.RetrofitManager;
import com.tenlionsoft.baselib.core.widget.base.BaseFragment;
import com.tenlionsoft.baselib.core.widget.views.CircleChartView;
import com.tenlionsoft.baselib.core.widget.views.ConditionAllAreaPopup;
import com.tenlionsoft.baselib.utils.TimeUtils;
import com.tenlionsoft.baselib.utils.ExceptionHandler;
import com.tenlionsoft.baselib.utils.LogUtils;
import com.tenlionsoft.baselib.utils.UIUtil;
import com.tenlionsoft.baselib.utils.UserLgUtils;
@ -50,6 +51,7 @@ import butterknife.ButterKnife;
import butterknife.Unbinder;
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers;
import io.reactivex.rxjava3.annotations.NonNull;
import io.reactivex.rxjava3.core.Observable;
import io.reactivex.rxjava3.core.Observer;
import io.reactivex.rxjava3.disposables.Disposable;
import io.reactivex.rxjava3.schedulers.Schedulers;
@ -98,35 +100,75 @@ public class GridLeaderStatisticsFragment extends BaseFragment {
mBind = ButterKnife.bind(this, dataView);
setStateView(STATE_SUCCESS);
mSrlView.setEnableLoadMore(false);
mSrlView.setEnableRefresh(false);
mSrlView.setEnableRefresh(true);
initViews();
getData();
mSrlView.autoRefresh();
}
/**
* 获取数据
*/
private void getData() {
RetrofitManager.getInstance()
//TOP7
Observable<List<IncidentTop7Bean>> areaReportTop7 = RetrofitManager.getInstance()
.create(CenterApis.class)
.getAreaReportTop7(mCurrentAreaCode, UserLgUtils.getToken())
.getAreaReportTop7(mCurrentAreaCode, UserLgUtils.getToken());
//网格员上报事件
Observable<AreaIncidentPercentBean> areaGridPercent = RetrofitManager.getInstance()
.create(CenterApis.class)
.getAreaGridPercent(mCurrentAreaCode, UserLgUtils.getToken());
//辖区内网格员
Observable<AreaGridCountBean> areaGrid = RetrofitManager.getInstance()
.create(CenterApis.class)
.getAreaGrid(mCurrentAreaCode, UserLgUtils.getToken());
//辖区下级网格员人数
Observable<AreaGridLowCountBean> areaLowerGrid = RetrofitManager.getInstance()
.create(CenterApis.class)
.getAreaLowerGrid(mCurrentAreaCode, UserLgUtils.getToken());
Observable<Object>[] observables1 = new Observable[]{areaReportTop7, areaGridPercent, areaGrid, areaLowerGrid};
Observable.mergeArrayDelayError(observables1)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Observer<List<IncidentTop7Bean>>() {
.observeOn(AndroidSchedulers.mainThread(), true)
.subscribe(new Observer<Object>() {
@Override
public void onSubscribe(@NonNull Disposable d) {
}
@Override
public void onNext(@NonNull List<IncidentTop7Bean> areaIncidentCategoryBeans) {
public void onNext(Object o) {
if (mDialog != null && mDialog.isShowing()) {
mDialog.dismiss();
}
areaIncidentCategoryBeans.add(0, new IncidentTop7Bean());
mTop7BeanList = areaIncidentCategoryBeans;
mTop7Adapter.setData(mTop7BeanList);
mSrlView.finishRefresh();
LogUtils.e("TOP7" + o.getClass().getSimpleName());
if (o instanceof ArrayList) {
//TOP7
ArrayList<IncidentTop7Bean> areaIncidentCategoryBeans = (ArrayList<IncidentTop7Bean>) o;
areaIncidentCategoryBeans.add(0, new IncidentTop7Bean());
mTop7BeanList = areaIncidentCategoryBeans;
mTop7Adapter.setData(mTop7BeanList);
} else if (o instanceof AreaIncidentPercentBean) {
//网格员上报事件占比
AreaIncidentPercentBean b = (AreaIncidentPercentBean) o;
setAreaIncidentPercent(b);
} else if (o instanceof AreaGridCountBean) {
//网格员占比
AreaGridCountBean b = (AreaGridCountBean) o;
setGridCount(b);
} else if (o instanceof AreaGridLowCountBean) {
//下级网格人数
AreaGridLowCountBean b = (AreaGridLowCountBean) o;
if (b.getData() != null && b.getData().size() > 0) {
mRlvGridCount.setVisibility(View.VISIBLE);
mTvGridCountHint.setVisibility(View.GONE);
mLowCountDatas = b.getData();
mGridCountAdapter.setData(mLowCountDatas);
} else {
mRlvGridCount.setVisibility(View.GONE);
mTvGridCountHint.setVisibility(View.VISIBLE);
}
}
}
@Override
@ -134,6 +176,8 @@ public class GridLeaderStatisticsFragment extends BaseFragment {
if (mDialog != null && mDialog.isShowing()) {
mDialog.dismiss();
}
mSrlView.finishRefresh();
ExceptionHandler.handleException(e);
}
@Override
@ -141,101 +185,6 @@ public class GridLeaderStatisticsFragment extends BaseFragment {
}
});
RetrofitManager.getInstance()
.create(CenterApis.class)
.getAreaGridPercent(mCurrentAreaCode, UserLgUtils.getToken())
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Observer<AreaIncidentPercentBean>() {
@Override
public void onSubscribe(@NonNull Disposable d) {
}
@Override
public void onNext(@NonNull AreaIncidentPercentBean areaIncidentCategoryBeans) {
if (mDialog != null && mDialog.isShowing()) {
mDialog.dismiss();
}
setAreaIncidentPercent(areaIncidentCategoryBeans);
}
@Override
public void onError(@NonNull Throwable e) {
if (mDialog != null && mDialog.isShowing()) {
mDialog.dismiss();
}
}
@Override
public void onComplete() {
}
});
//获取辖区内网格员
RetrofitManager.getInstance()
.create(CenterApis.class)
.getAreaGrid(mCurrentAreaCode, UserLgUtils.getToken())
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Observer<AreaGridCountBean>() {
@Override
public void onSubscribe(@NonNull Disposable d) {
}
@Override
public void onNext(@NonNull AreaGridCountBean areaPopulaceBean) {
setGridCount(areaPopulaceBean);
}
@Override
public void onError(@NonNull Throwable e) {
}
@Override
public void onComplete() {
}
});
//获取辖区下级网格员
RetrofitManager.getInstance()
.create(CenterApis.class)
.getAreaLowerGrid(mCurrentAreaCode, UserLgUtils.getToken())
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Observer<AreaGridLowCountBean>() {
@Override
public void onSubscribe(@NonNull Disposable d) {
}
@Override
public void onNext(@NonNull AreaGridLowCountBean areaPopulaceBeans) {
if (areaPopulaceBeans.getData() != null && areaPopulaceBeans.getData().size() > 0) {
mRlvGridCount.setVisibility(View.VISIBLE);
mTvGridCountHint.setVisibility(View.GONE);
mLowCountDatas = areaPopulaceBeans.getData();
mGridCountAdapter.setData(mLowCountDatas);
} else {
mRlvGridCount.setVisibility(View.GONE);
mTvGridCountHint.setVisibility(View.VISIBLE);
}
}
@Override
public void onError(@NonNull Throwable e) {
}
@Override
public void onComplete() {
}
});
}
/**
@ -249,6 +198,7 @@ public class GridLeaderStatisticsFragment extends BaseFragment {
double percent = ((double) bean.getData().getCount() / bean.getData().getTotal()) * 100;
DecimalFormat format = new DecimalFormat("#0.00");
String percentStr = format.format(percent);
LogUtils.e("网格人数:" + bean.getData().getCount() + "\n总人数:" + bean.getData().getTotal() + "占比:" + percentStr);
//计算占用比例
mCcvPercent.setData(Double.parseDouble(percentStr));
String countStr = bean.getData().getCount() + "";
@ -266,22 +216,18 @@ public class GridLeaderStatisticsFragment extends BaseFragment {
*/
private void initViews() {
mTop7BeanList = new ArrayList<>();
mTvCurrentTime.setText("数据更新时间:" + TimeUtils.getCurrentTimeHHMM());
mCurrentAreaCode = UserLgUtils.getUserAreaCode();
mTvArea.setText(UserLgUtils.getUserFullAreaName());
mRlvGridIncident.setLayoutManager(new LinearLayoutManager(mActivity));
mTop7Adapter = new IncidentStatisticsAdapter(mActivity, mTop7BeanList);
mRlvGridIncident.setAdapter(mTop7Adapter);
mLowCountDatas = new ArrayList<>();
mGridCountAdapter = new GridPersonCountAdapter(mActivity, mLowCountDatas);
mRlvGridCount.setLayoutManager(new GridLayoutManager(mActivity, 1, GridLayoutManager.HORIZONTAL, false));
mRlvGridCount.setAdapter(mGridCountAdapter);
mCurrentAreaCode = UserLgUtils.getUserAreaCode();
initPieChart();
mLlArea.setOnClickListener(v -> onShowArea());
mTvArea.setText(UserLgUtils.getUserFullAreaName());
mDialog = UIUtil.initDialog(mActivity, "加载中...");
mDialog.show();
}
/**
@ -323,7 +269,7 @@ public class GridLeaderStatisticsFragment extends BaseFragment {
getData();
areaPopup.dismiss();
});
areaPopup.setOffsetY(10);
areaPopup.setOffsetY(20);
areaPopup.showPopupWindow(mTvArea);
}
@ -334,7 +280,7 @@ public class GridLeaderStatisticsFragment extends BaseFragment {
*/
private void setAreaIncidentPercent(AreaIncidentPercentBean bean) {
ArrayList<PieEntry> entries = new ArrayList<>();
mTvCurrentTime.setText("数据更新时间:" + bean.getData().getDataTime());
mPieChart.clear();
if (bean.getData() == null) return;
if (bean.getData().getNowAreaReportNum() == 0 && bean.getData().getOtherAreaReportNum() == 0) return;
@ -398,7 +344,7 @@ public class GridLeaderStatisticsFragment extends BaseFragment {
@Override
protected void refreshView() {
getData();
}
@Override

View File

@ -4,6 +4,7 @@ import android.app.ProgressDialog;
import android.graphics.Color;
import android.graphics.Typeface;
import android.text.SpannableString;
import android.text.TextUtils;
import android.text.style.ForegroundColorSpan;
import android.text.style.RelativeSizeSpan;
import android.text.style.StyleSpan;
@ -42,26 +43,28 @@ import com.tengshisoft.commonmodule.utils.PiePercentFormater;
import com.tengshisoft.commonmodule.views.MyIncidentMarkerView;
import com.tenlionsoft.baselib.constant.PathConfig;
import com.tenlionsoft.baselib.core.retrofit_net.RetrofitManager;
import com.tenlionsoft.baselib.core.retrofit_net.conver.RxTransformer;
import com.tenlionsoft.baselib.core.widget.base.BaseFragment;
import com.tenlionsoft.baselib.core.widget.views.ConditionAllAreaPopup;
import com.tenlionsoft.baselib.utils.ExceptionHandler;
import com.tenlionsoft.baselib.utils.LogUtils;
import com.tenlionsoft.baselib.utils.StringUtils;
import com.tenlionsoft.baselib.utils.TimeUtils;
import com.tenlionsoft.baselib.utils.UIUtil;
import com.tenlionsoft.baselib.utils.UserLgUtils;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Random;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.Unbinder;
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers;
import io.reactivex.rxjava3.annotations.NonNull;
import io.reactivex.rxjava3.core.Observable;
import io.reactivex.rxjava3.core.Observer;
import io.reactivex.rxjava3.disposables.Disposable;
import io.reactivex.rxjava3.schedulers.Schedulers;
/**
* 作者: adam
@ -91,29 +94,32 @@ public class IncidentLeaderStatisticsFragment extends BaseFragment {
TextView mTvHotType2;
@BindView(R2.id.tv_hot_detail)
TextView mTvHotDetail;
@BindView(R2.id.tv_hot_detail_scale)
TextView mTvHotDetailScale;
@BindView(R2.id.tv_refresh_time)
TextView mTvRefreshTime;
private Unbinder mBind;
private LabelAdapter mLabelAdapter;
private List<LabelBean> mLabelBeanList;
private List<LabelBean> labelHint = null;
private String mCurrentAreaCode;
private ProgressDialog mDialog;
private Random mColorRandom;
@Override
protected void setDataToView(View dataView) {
mBind = ButterKnife.bind(this, dataView);
setStateView(STATE_SUCCESS);
mSrlView.setEnableLoadMore(false);
mSrlView.setEnableRefresh(false);
mSrlView.setEnableRefresh(true);
initViews();
getData();
mSrlView.autoRefresh();
}
/**
* 获取数据
*/
private void getData() {
//获取事件分类占比
Observable<AreaIncidentScaleBean> areaTypeScale = RetrofitManager.getInstance()
.create(CenterApis.class)
@ -127,7 +133,8 @@ public class IncidentLeaderStatisticsFragment extends BaseFragment {
.create(CenterApis.class)
.getAreaIncidentCategory(mCurrentAreaCode, UserLgUtils.getToken());
Observable.mergeDelayError(areaTypeScale, areaHot, areaIncidentCategory)
.compose(RxTransformer.getTransformer())
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread(), true)
.subscribe(new Observer<Object>() {
@Override
public void onSubscribe(@NonNull Disposable d) {
@ -136,6 +143,10 @@ public class IncidentLeaderStatisticsFragment extends BaseFragment {
@Override
public void onNext(@NonNull Object o) {
mSrlView.finishRefresh();
if (mDialog != null && mDialog.isShowing()) {
mDialog.dismiss();
}
if (o instanceof AreaIncidentScaleBean) {
AreaIncidentScaleBean b = (AreaIncidentScaleBean) o;
if (b.getReportTypeList() != null && b.getReportTypeList().size() > 0) {
@ -152,21 +163,25 @@ public class IncidentLeaderStatisticsFragment extends BaseFragment {
}
mLabelAdapter.setData(mLabelBeanList);
setInfoToView(b, mLabelBeanList);
} else {
mPieChart.clear();
mPieChart.invalidate();
}
} else if (o instanceof AreaIncidentHotBean) {
AreaIncidentHotBean b = (AreaIncidentHotBean) o;
setHotDataToView(b);
} else if (o instanceof List) {
List<AreaIncidentCategoryBean> b = (List<AreaIncidentCategoryBean>) o;
} else if (o instanceof ArrayList) {
ArrayList<AreaIncidentCategoryBean> b = (ArrayList<AreaIncidentCategoryBean>) o;
setIncidentCategory(b);
}
if (mDialog != null && mDialog.isShowing()) {
mDialog.dismiss();
}
}
@Override
public void onError(@NonNull Throwable e) {
if (mDialog != null && mDialog.isShowing()) {
mDialog.dismiss();
}
if (mDialog != null && mDialog.isShowing()) {
mDialog.dismiss();
}
@ -184,20 +199,25 @@ public class IncidentLeaderStatisticsFragment extends BaseFragment {
* 显示热门事件数据
*/
private void setHotDataToView(AreaIncidentHotBean hotBean) {
mTvHotType1.setText(hotBean.getTypeName1());
mTvHotType2.setText(hotBean.getTypeName2());
mTvHotDetail.setText(generateHotTxt("共计上报" + hotBean.getReportNum() + "\n占比" + hotBean.getReportScale() + "%"));
mTvHotType1.setText(TextUtils.isEmpty(hotBean.getTypeName1()) ? "" : hotBean.getTypeName1());
mTvHotType2.setText(TextUtils.isEmpty(hotBean.getTypeName2()) ? "" : hotBean.getTypeName2());
mTvHotDetail.setText(generateHotTxt("共计上报" + StringUtils.numAddUnit(hotBean.getReportNum()) + ""));
String scale = TextUtils.isEmpty(hotBean.getReportScale()) ? "0" : hotBean.getReportScale();
mTvHotDetailScale.setText(generateHotScale("占比" + scale + "%"));
}
private SpannableString generateHotTxt(String content) {
SpannableString s = new SpannableString(content);
s.setSpan(new RelativeSizeSpan(1.4f), content.lastIndexOf("") + 1, content.indexOf(""), 0);
s.setSpan(new UnderlineSpan(), content.lastIndexOf(""), content.indexOf(""), 0);
s.setSpan(new UnderlineSpan(), content.lastIndexOf("") + 1, content.indexOf(""), 0);
s.setSpan(new StyleSpan(Typeface.BOLD), content.lastIndexOf("") + 1, content.indexOf(""), 0);
return s;
}
private SpannableString generateHotScale(String content) {
SpannableString s = new SpannableString(content);
s.setSpan(new RelativeSizeSpan(1.4f), content.indexOf("") + 1, content.length() - 1, 0);
s.setSpan(new UnderlineSpan(), content.lastIndexOf("") + 1, content.length() - 1, 0);
s.setSpan(new StyleSpan(Typeface.BOLD), content.lastIndexOf("") + 1, content.indexOf(""), 0);
s.setSpan(new StyleSpan(Typeface.BOLD), content.lastIndexOf("") + 1, content.length() - 1, 0);
return s;
}
@ -207,9 +227,9 @@ public class IncidentLeaderStatisticsFragment extends BaseFragment {
*/
private void setInfoToView(AreaIncidentScaleBean b, List<LabelBean> list) {
//设置文字数据
mTvDoIncident.setText(generateDisTxt("上报事件已处理\n" + b.getOverNum() + ""));
mTvUndoIncident.setText(generateDisTxt("上报事件未处理\n" + b.getNoOverNum() + ""));
mPieChart.clear();
mTvDoIncident.setText(generateDisTxt("上报事件已处理\n" + StringUtils.numAddUnit(b.getOverNum()) + ""));
mTvUndoIncident.setText(generateDisTxt("上报事件未处理\n" + StringUtils.numAddUnit(b.getNoOverNum()) + ""));
ArrayList<PieEntry> entries = new ArrayList<>();
if (list == null || list.size() == 0) return;
@ -257,7 +277,7 @@ public class IncidentLeaderStatisticsFragment extends BaseFragment {
mLlArea.setOnClickListener(v -> onShowArea());
mTvArea.setText(UserLgUtils.getUserFullAreaName());
mDialog = UIUtil.initDialog(mActivity, "加载中...");
mDialog.show();
mTvRefreshTime.setText("数据更新时间:" + TimeUtils.getCurrentDate());
}
private void onShowArea() {
@ -275,7 +295,7 @@ public class IncidentLeaderStatisticsFragment extends BaseFragment {
getData();
areaPopup.dismiss();
});
areaPopup.setOffsetY(10);
areaPopup.setOffsetY(20);
areaPopup.showPopupWindow(mTvArea);
}
@ -311,7 +331,7 @@ public class IncidentLeaderStatisticsFragment extends BaseFragment {
* 构建事件分类占比图中心展示的文字
*/
private SpannableString generateCenterSpannableText(int total) {
String content = "上报事件总数\n" + total + "";
String content = "上报事件总数\n" + StringUtils.numAddUnit(total) + "";
SpannableString s = new SpannableString(content);
s.setSpan(new RelativeSizeSpan(0.8f), 0, content.indexOf("") + 1, 0);
s.setSpan(new RelativeSizeSpan(0.8f), content.lastIndexOf(""), content.length(), 0);
@ -380,6 +400,7 @@ public class IncidentLeaderStatisticsFragment extends BaseFragment {
* 显示事件分类
*/
private void setIncidentCategory(List<AreaIncidentCategoryBean> datas) {
mHbcChart.clear();
if (datas != null && datas.size() > 0) {
setAxis(datas);
float maxiNum = getMaxNum(datas);
@ -411,7 +432,6 @@ public class IncidentLeaderStatisticsFragment extends BaseFragment {
mHbcChart.setMarker(mv); // Set the marker to the chart
} else {
mHbcChart.clear();
mHbcChart.setNoDataText("当前区域内无数据");
}
mHbcChart.invalidate();
@ -437,14 +457,29 @@ public class IncidentLeaderStatisticsFragment extends BaseFragment {
* 获取随机颜色值
*/
private int getRandomColor() {
Random rnd = new Random();
int color = Color.argb(255, rnd.nextInt(256), rnd.nextInt(256), rnd.nextInt(256));
return color;
if (mColorRandom == null) {
mColorRandom = new Random();
}
int r = 0;
int g = 0;
int b = 0;
for (int i = 0; i < 2; i++) {
int temp = mColorRandom.nextInt(16);
r = r * 16 + temp;
temp = mColorRandom.nextInt(16);
g = g * 16 + temp;
temp = mColorRandom.nextInt(16);
b = b * 16 + temp;
}
return Color.rgb(r, g, b);
// Random rnd = new Random();
// int color = Color.argb(255, rnd.nextInt(256), rnd.nextInt(256), rnd.nextInt(256));
// return color;
}
@Override
protected void refreshView() {
getData();
}
@Override

View File

@ -33,6 +33,8 @@ import com.tenlionsoft.baselib.core.widget.views.ConditionAllAreaPopup;
import com.tenlionsoft.baselib.core.widget.views.TypeBoldTextView;
import com.tenlionsoft.baselib.utils.ExceptionHandler;
import com.tenlionsoft.baselib.utils.LogUtils;
import com.tenlionsoft.baselib.utils.StringUtils;
import com.tenlionsoft.baselib.utils.UIUtil;
import com.tenlionsoft.baselib.utils.UserLgUtils;
import java.util.ArrayList;
@ -79,6 +81,8 @@ public class PopulaceLeaderStatisticsFragment extends BaseFragment {
BallView mBvType;
@BindView(R2.id.tv_refresh_time)
TextView mTvRefreshTime;
@BindView(R2.id.tv_gird_or_community)
TextView mTvGirdOrCommunity;
private Unbinder mBind;
private String mCurrentAreaCode;
private ProgressDialog mDialog;
@ -90,9 +94,9 @@ public class PopulaceLeaderStatisticsFragment extends BaseFragment {
mBind = ButterKnife.bind(this, dataView);
setStateView(STATE_SUCCESS);
mSrlView.setEnableLoadMore(false);
mSrlView.setEnableRefresh(false);
mSrlView.setEnableRefresh(true);
initViews();
getData();
mSrlView.autoRefresh();
}
/**
@ -116,6 +120,7 @@ public class PopulaceLeaderStatisticsFragment extends BaseFragment {
if (mDialog != null && mDialog.isShowing()) {
mDialog.dismiss();
}
mSrlView.finishRefresh();
setInfoToView(bean);
}
@ -124,6 +129,7 @@ public class PopulaceLeaderStatisticsFragment extends BaseFragment {
if (mDialog != null && mDialog.isShowing()) {
mDialog.dismiss();
}
mSrlView.finishRefresh();
ExceptionHandler.handleException(e);
}
@ -141,11 +147,11 @@ public class PopulaceLeaderStatisticsFragment extends BaseFragment {
*/
private void setInfoToView(AreaPopulaceBean bean) {
mTvRefreshTime.setText("数据更新时间 : " + bean.getFreshTime());
mTvTotalPopulace.setText(bean.getZongShu() + "");//总人口
mTvTotalPopulace.setText(StringUtils.numAddUnit(bean.getZongShu() + ""));//总人口
mTvPopulacePercent.setText(bean.getZhanQuanShi() + "%");//占全市
mTvPopulaceIncidentPercent.setText(bean.getShiJianLv() + "%");
mTvPopulaceCommunity.setText(bean.getSheQuCun() + "");
mTvPopulaceCommunity.setText(StringUtils.numAddUnit(bean.getSheQuCun() + ""));
mTvGirdOrCommunity.setText(bean.isGrid() ? "辖区网格" : "辖区社区/村");
mCountDatas.clear();
mPopulaceCountAdapter.setData(mCountDatas);
@ -299,8 +305,7 @@ public class PopulaceLeaderStatisticsFragment extends BaseFragment {
mRlvCategoryPercent.setAdapter(mPopulaceCountAdapter);
mLlArea.setOnClickListener(v -> onShowArea());
mTvArea.setText(UserLgUtils.getUserFullAreaName());
// mDialog = UIUtil.initDialog(mActivity, "加载中...");
// mDialog.show();
mDialog = UIUtil.initDialog(mActivity, "加载中...");
}
@ -316,13 +321,13 @@ public class PopulaceLeaderStatisticsFragment extends BaseFragment {
mTvArea.setText(areaNames);
//刷新数据
mCurrentAreaCode = areaCode;
// if (mDialog != null) {
// mDialog.show();
// }
if (mDialog != null) {
mDialog.show();
}
getData();
areaPopup.dismiss();
});
areaPopup.setOffsetY(10);
areaPopup.setOffsetY(20);
areaPopup.showPopupWindow(mTvArea);
}
@ -385,7 +390,7 @@ public class PopulaceLeaderStatisticsFragment extends BaseFragment {
@Override
protected void refreshView() {
getData();
}
@Override

View File

@ -8,13 +8,13 @@
tools:background="@color/gray">
<LinearLayout
android:id="@+id/ll_area"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/shp_rectangle_white_5"
android:padding="10dp">
<LinearLayout
android:id="@+id/ll_area"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1">

View File

@ -8,13 +8,13 @@
tools:background="@color/gray">
<LinearLayout
android:id="@+id/ll_area"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/shp_rectangle_white_5"
android:padding="10dp">
<LinearLayout
android:id="@+id/ll_area"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1">
@ -72,12 +72,21 @@
android:src="@drawable/ic_statistics_title_icon" />
<com.tenlionsoft.baselib.core.widget.views.TypeBoldTextView
android:layout_width="wrap_content"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_weight="1"
android:text="事件分类占比"
android:textColor="@color/black"
android:textSize="@dimen/text_14" />
<TextView
android:id="@+id/tv_refresh_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/gray_text_8A"
android:textSize="@dimen/text_10"
tools:text="数据刷新时间:2023-22-22 11:11" />
</LinearLayout>
<LinearLayout
@ -268,14 +277,29 @@
android:id="@+id/tv_hot_detail"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginTop="10dp"
android:ellipsize="end"
android:maxLines="2"
android:minLines="2"
android:padding="15dp"
android:maxLines="1"
android:minLines="1"
android:text="无"
android:textColor="@color/white"
android:textSize="@dimen/text_12"
tools:text="" />
tools:text="共计上报100.00万件" />
<TextView
android:id="@+id/tv_hot_detail_scale"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/tv_hot_detail"
android:layout_alignLeft="@id/tv_hot_detail"
android:ellipsize="end"
android:maxLines="1"
android:minLines="1"
android:text="无"
android:textColor="@color/white"
android:textSize="@dimen/text_12"
tools:text="占比100.00%" />
<ImageView
android:layout_width="wrap_content"

View File

@ -8,13 +8,14 @@
tools:background="@color/gray">
<LinearLayout
android:id="@+id/ll_area"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/shp_rectangle_white_5"
android:padding="10dp">
<LinearLayout
android:id="@+id/ll_area"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1">
@ -68,9 +69,9 @@
android:layout_height="wrap_content"
android:background="@drawable/shp_rectangle_top_left_bottom"
android:paddingLeft="10dp"
android:paddingTop="10dp"
android:paddingTop="6dp"
android:paddingRight="50dp"
android:paddingBottom="10dp">
android:paddingBottom="6dp">
<ImageView
android:layout_width="20dp"
@ -82,7 +83,8 @@
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:text="辖区总人口"
android:textColor="@color/white" />
android:textColor="@color/white"
android:textSize="@dimen/text_14" />
</LinearLayout>
<TextView
@ -121,9 +123,9 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="3dp"
android:text="0"
android:textColor="@color/black"
android:textSize="@dimen/text_16"
tools:text="0" />
android:textSize="@dimen/text_16" />
</LinearLayout>
<LinearLayout
@ -144,9 +146,9 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="3dp"
android:text="0"
android:textColor="#26BE34"
android:textSize="@dimen/text_16"
tools:text="0" />
android:textSize="@dimen/text_16" />
</LinearLayout>
<LinearLayout
@ -167,9 +169,9 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="3dp"
android:text="0"
android:textColor="#F59814"
android:textSize="@dimen/text_16"
tools:text="0" />
android:textSize="@dimen/text_16" />
</LinearLayout>
<LinearLayout
@ -180,6 +182,7 @@
android:orientation="vertical">
<TextView
android:id="@+id/tv_gird_or_community"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="辖内社区/村"
@ -190,9 +193,9 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="3dp"
android:text="0"
android:textColor="#E25A5A"
android:textSize="@dimen/text_16"
tools:text="0" />
android:textSize="@dimen/text_16" />
</LinearLayout>
</LinearLayout>

View File

@ -17,7 +17,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableLeft="@drawable/ic_point_blue_text_title"
android:text="处理:"
android:text="处理:"
android:textColor="#FF8300"
android:textSize="@dimen/text_12" />
@ -40,7 +40,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableLeft="@drawable/ic_point_yellow_text_title"
android:text="处理:"
android:text="处理:"
android:textColor="#2F5CFB"
android:textSize="@dimen/text_12" />

View File

@ -98,7 +98,6 @@ public class LeaderMainFragment extends BaseFragment {
"督办消息",
"归档事件",
"已办事件",
"事件处理",
"通讯录",
"事件追踪",
"辖区人口",
@ -109,12 +108,11 @@ public class LeaderMainFragment extends BaseFragment {
R.drawable.ic_early_icon,
R.drawable.ic_supervise_icon,
R.drawable.ic_file_icon,
R.drawable.ic_incident_accept_icon,
R.drawable.ic_case_dispose,
R.drawable.ic_list_contact,
R.drawable.ic_journal_list,
R.drawable.ic_populace_list_icon,
R.drawable.ic_journal_list};
R.drawable.ic_incident_track_icon,
R.drawable.ic_populace_popedom_icon,
R.drawable.ic_statistics_data_icon};
private FunctionTitleNumAdapter mNumAdapter;
private Disposable mDisposable;
private List mDatas;

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB