Просмотр исходного кода

1.对接库信息统计图接口
2.修改人员信息UI
3.修改公告页面UI
4.机械通风增加无审批人提示
5.修改选企业逻辑
6.修改头像刷新页面

mq лет назад: 5
Родитель
Сommit
ae101b4968

+ 28 - 0
app/src/main/java/com/unis/sxzcl/ui/aeration/AerationDetailFragment.java

@@ -26,6 +26,7 @@ import com.unis.model.bean.process.ProcessStepBean;
26 26
 import com.unis.model.event.AerationEvent;
27 27
 import com.unis.sxzcl.base.BaseListFragment;
28 28
 import com.unis.sxzcl.databinding.FragmentAerationDetailBinding;
29
+import com.unis.sxzcl.widget.dialog.SystemDialog;
29 30
 import com.xyxsbj.mylibrary.tool.DPTool;
30 31
 import com.xyxsbj.mylibrary.tool.ToastTool;
31 32
 
@@ -311,6 +312,12 @@ public class AerationDetailFragment extends BaseListFragment<FragmentAerationDet
311 312
     }
312 313
 
313 314
     private void onSave() {
315
+        // 没有审批人弹出提示
316
+        if (!isHaveApprove()) {
317
+            showApproveDialog();
318
+            return;
319
+        }
320
+
314 321
         String houseId = HouseModel.get().getSelectHouse().houseCode.toString();
315 322
         String depotId = DepotModel.get().getSelectDepot().depotCode.toString();
316 323
         UserBean user = UserModel.get().getUser();
@@ -379,6 +386,27 @@ public class AerationDetailFragment extends BaseListFragment<FragmentAerationDet
379 386
 
380 387
 
381 388
     /**
389
+     * 审批人是否完整
390
+     */
391
+    public boolean isHaveApprove() {
392
+        List<DetailApproveBean> beans = approveMap.get(mStepAdapter.getData().get(0).id);
393
+        for (DetailApproveBean item : beans) {
394
+            // 每个审批人id不得为空
395
+            if (item.getContent() == null) {
396
+                return false;
397
+            }
398
+        }
399
+        return true;
400
+    }
401
+
402
+    public void showApproveDialog() {
403
+        new SystemDialog(getContext())
404
+                .setHideTitle()
405
+                .setMsg("暂无审批人,请先去电脑上设置审批人管理")
406
+                .setRightButton("确认", null).show();
407
+    }
408
+
409
+    /**
382 410
      * 最高流程的所有选项
383 411
      * 是否已全部选中
384 412
      *

+ 3 - 0
app/src/main/java/com/unis/sxzcl/ui/company/CompanyListFragment.java

@@ -130,6 +130,9 @@ public class CompanyListFragment extends BaseListFragment<FragmentBaseListTitleB
130 130
         BaseMultiBean item = (BaseMultiBean) data;
131 131
         String extra = item.extra;
132 132
         MultiDepotBean bean = getGson().fromJson(extra, MultiDepotBean.class);
133
+        if (bean.depotCode.equals(1)) {
134
+            return;
135
+        }
133 136
         DepotModel.get().saveSelectDepot(bean);
134 137
         EventBus.getDefault().post(new SelectDepotEvent());
135 138
         onBack();

+ 132 - 27
app/src/main/java/com/unis/sxzcl/ui/company/CompanyStatsFragment.java

@@ -1,10 +1,12 @@
1 1
 package com.unis.sxzcl.ui.company;
2 2
 
3
+import android.graphics.Color;
3 4
 import android.view.LayoutInflater;
4 5
 import android.view.ViewGroup;
5 6
 
6 7
 import com.github.mikephil.charting.data.BarEntry;
7 8
 import com.github.mikephil.charting.data.PieEntry;
9
+import com.unis.model.DataCallback;
8 10
 import com.unis.model.DepotModel;
9 11
 import com.unis.model.bean.MultiDepotBean;
10 12
 import com.unis.sxzcl.base.BaseFragment;
@@ -15,6 +17,7 @@ import com.unis.sxzcl.widget.MyPieChart;
15 17
 import java.util.ArrayList;
16 18
 import java.util.Arrays;
17 19
 import java.util.List;
20
+import java.util.Map;
18 21
 
19 22
 /**
20 23
  * 包名: com.unis.sxzcl.ui.company
@@ -32,6 +35,7 @@ public class CompanyStatsFragment extends BaseFragment<FragmentCompanyStatsBindi
32 35
     private MyPieChart mPieChartHouseStatus;
33 36
     private MyBarChart mBarChartFoodType;
34 37
     private MyPieChart mPieChartStorageStatus;
38
+    private Integer mDepotId;
35 39
 
36 40
     @Override
37 41
     protected FragmentCompanyStatsBinding getViewBinding(LayoutInflater inflater, ViewGroup container) {
@@ -41,6 +45,7 @@ public class CompanyStatsFragment extends BaseFragment<FragmentCompanyStatsBindi
41 45
     @Override
42 46
     protected void init() {
43 47
         MultiDepotBean selectDepot = DepotModel.get().getSelectDepot();
48
+        mDepotId = selectDepot.depotCode;
44 49
         mBinding.bar.setTitle(selectDepot.depotName);
45 50
         mBinding.bar.setLeftClickListener(v -> onBack());
46 51
 
@@ -49,46 +54,146 @@ public class CompanyStatsFragment extends BaseFragment<FragmentCompanyStatsBindi
49 54
 
50 55
     @Override
51 56
     protected void onFirstShow() {
57
+
58
+        if (mPieChartHouseStatus == null) {
59
+            mPieChartHouseStatus = new MyPieChart(mBinding.pieHouseStatus);
60
+        }
61
+
62
+        if (mBarChartFoodType == null) {
63
+            mBarChartFoodType = new MyBarChart(mBinding.barFoodType);
64
+        }
65
+
66
+        if (mPieChartStorageStatus == null) {
67
+            mPieChartStorageStatus = new MyPieChart(mBinding.pieStorageStatus);
68
+        }
69
+
70
+        showProgress("正在加载...", false);
52 71
         getHouseStatus();
53 72
         getFoodType();
54 73
         getStorageStatus();
55 74
     }
56 75
 
57 76
 
77
+    /**
78
+     * 仓房状态饼图
79
+     */
58 80
     private void getHouseStatus() {
59
-        if (mPieChartHouseStatus == null)
60
-            mPieChartHouseStatus = new MyPieChart(mBinding.pieHouseStatus);
61
-        // 仓房状态
62
-        List<PieEntry> pieEntries = new ArrayList<>();
63
-        pieEntries.add(new PieEntry(200f, "入库"));
64
-        pieEntries.add(new PieEntry(290f, "出库"));
65
-        pieEntries.add(new PieEntry(240f, "通风"));
66
-        pieEntries.add(new PieEntry(160f, "熏蒸"));
67
-        mPieChartHouseStatus.showChart(pieEntries, "仓房状态");
81
+
82
+        // 请求后台接口
83
+        DepotModel.get().getWarehouseStatus(1, new DataCallback<List<Map<String, Object>>>() {
84
+            @Override
85
+            public void onSuccess(List<Map<String, Object>> data) {
86
+                if (!isActive()) return;
87
+                hideProgress();
88
+
89
+                if (data == null || data.size() == 0) return;
90
+
91
+                // 将数据源 转为 饼图数据
92
+                List<PieEntry> pieEntries = new ArrayList<>();
93
+                for (Map<String, Object> item : data) {
94
+                    String count = (String) item.get("count");
95
+                    String status = (String) item.get("warehouseStatus");
96
+                    if (count == null) count = "0";
97
+                    if (status == null) status = "";
98
+                    pieEntries.add(new PieEntry(Float.parseFloat(count), status));
99
+                }
100
+                List<Integer> list = Arrays.asList(
101
+                        Color.parseColor("#FFA100"),
102
+                        Color.parseColor("#1FA2EB"),
103
+                        Color.parseColor("#F3DE38"),
104
+                        Color.parseColor("#89BF6B"));
105
+                // 显示饼图
106
+                mPieChartHouseStatus.showChart(pieEntries, "仓房状态", list);
107
+            }
108
+
109
+            @Override
110
+            public void onError(String error) {
111
+                super.onError(error);
112
+                if (!isActive()) return;
113
+                hideProgress();
114
+            }
115
+        });
68 116
     }
69 117
 
118
+    /**
119
+     * 粮食品种柱状图
120
+     */
70 121
     private void getFoodType() {
71
-        if (mBarChartFoodType == null)
72
-            mBarChartFoodType = new MyBarChart(mBinding.barFoodType);
73 122
 
74
-        // 粮食品种
75
-        ArrayList<BarEntry> barEntries = new ArrayList<>();
76
-        barEntries.add(new BarEntry(0, 140));
77
-        barEntries.add(new BarEntry(1, 120));
78
-        barEntries.add(new BarEntry(2, 80));
79
-        barEntries.add(new BarEntry(3, 50));
80
-        List<String> workTypeLabels = Arrays.asList("玉米", "小麦", "大豆", "稻谷");
81
-        mBarChartFoodType.showChart(workTypeLabels, barEntries);
123
+        DepotModel.get().getFoodTypeCount(1, new DataCallback<List<Map<String, Object>>>() {
124
+            @Override
125
+            public void onSuccess(List<Map<String, Object>> data) {
126
+                if (!isActive()) return;
127
+                hideProgress();
128
+
129
+                if (data == null || data.size() == 0) return;
130
+
131
+                // 将数据源 转为 饼图数据
132
+                List<String> labelList = new ArrayList<>();
133
+                ArrayList<BarEntry> valueList = new ArrayList<>();
134
+                for (int i = 0; i < data.size(); i++) {
135
+                    Map<String, Object> item = data.get(i);
136
+
137
+                    String label = (String) item.get("grainVarieties");
138
+                    if (label == null) label = "";
139
+                    labelList.add(label);
140
+
141
+                    String count = (String) item.get("count");
142
+                    if (count == null) count = "0";
143
+                    valueList.add(new BarEntry(i, Float.parseFloat(count)));
144
+
145
+                }
146
+                mBarChartFoodType.showChart(labelList, valueList);
147
+            }
148
+
149
+            @Override
150
+            public void onError(String error) {
151
+                super.onError(error);
152
+                if (!isActive()) return;
153
+                hideProgress();
154
+
155
+            }
156
+        });
82 157
     }
83 158
 
159
+    /**
160
+     * 存储状态饼图
161
+     */
84 162
     private void getStorageStatus() {
85
-        if (mPieChartStorageStatus == null)
86
-            mPieChartStorageStatus = new MyPieChart(mBinding.pieStorageStatus);
87
-        // 储存状态
88
-        List<PieEntry> pieEntries = new ArrayList<>();
89
-        pieEntries.add(new PieEntry(200f, "空仓"));
90
-        pieEntries.add(new PieEntry(290f, "满仓"));
91
-        pieEntries.add(new PieEntry(240f, "半仓"));
92
-        mPieChartStorageStatus.showChart(pieEntries, "储存状态");
163
+
164
+        // 请求后台接口
165
+        DepotModel.get().getStorageStatus(1, new DataCallback<List<Map<String, Object>>>() {
166
+            @Override
167
+            public void onSuccess(List<Map<String, Object>> data) {
168
+                if (!isActive()) return;
169
+                hideProgress();
170
+
171
+                if (data == null || data.size() == 0) return;
172
+
173
+                // 将数据源 转为 饼图数据
174
+                List<PieEntry> pieEntries = new ArrayList<>();
175
+                for (Map<String, Object> item : data) {
176
+                    String count = (String) item.get("count");
177
+                    String status = (String) item.get("storageStatus");
178
+                    if (count == null) count = "0";
179
+                    if (status == null) status = "";
180
+                    pieEntries.add(new PieEntry(Float.parseFloat(count), status));
181
+                }
182
+                List<Integer> list = Arrays.asList(
183
+                        Color.parseColor("#057B43"),
184
+                        Color.parseColor("#8ABF6B"),
185
+                        Color.parseColor("#F3DE38"));
186
+                // 显示饼图
187
+                mPieChartStorageStatus.showChart(pieEntries, "储存状态", list);
188
+            }
189
+
190
+            @Override
191
+            public void onError(String error) {
192
+                super.onError(error);
193
+                if (!isActive()) return;
194
+                hideProgress();
195
+
196
+            }
197
+        });
93 198
     }
94 199
 }

+ 211 - 55
app/src/main/java/com/unis/sxzcl/ui/home/HomeFragment.java

@@ -1,6 +1,6 @@
1 1
 package com.unis.sxzcl.ui.home;
2 2
 
3
-import android.os.Bundle;
3
+import android.graphics.Color;
4 4
 import android.view.LayoutInflater;
5 5
 import android.view.View;
6 6
 import android.view.ViewGroup;
@@ -10,6 +10,7 @@ import com.github.mikephil.charting.data.BarEntry;
10 10
 import com.github.mikephil.charting.data.PieEntry;
11 11
 import com.unis.model.AnnounceModel;
12 12
 import com.unis.model.DataCallback;
13
+import com.unis.model.DepotModel;
13 14
 import com.unis.model.NoticeModel;
14 15
 import com.unis.model.ProcessModel;
15 16
 import com.unis.model.UrlPath;
@@ -34,6 +35,7 @@ import org.greenrobot.eventbus.ThreadMode;
34 35
 import java.util.ArrayList;
35 36
 import java.util.Arrays;
36 37
 import java.util.List;
38
+import java.util.Map;
37 39
 
38 40
 /**
39 41
  * 包名: com.unis.sxzcl.ui.home
@@ -76,26 +78,22 @@ public class HomeFragment extends BaseFragment<FragmentHomeBinding> {
76 78
             // 个人信息
77 79
             navigation(R.id.userFragment);
78 80
         });
79
-//        mBinding.layoutCompany.setOnClickListener(v -> {
81
+//        mBinding.tvDepotCount.setOnClickListener(v -> {
80 82
 //            // 库列表
81 83
 //            navigation(R.id.companyListFragment);
82 84
 //        });
83
-        mBinding.tvDepotCount.setOnClickListener(v -> {
84
-            // 库列表
85
-            navigation(R.id.companyListFragment);
86
-        });
87
-        mBinding.tvHouseCount.setOnClickListener(v -> {
88
-            // 仓列表
89
-            Bundle bundle = new Bundle();
90
-            bundle.putBoolean("showTitle", true);
91
-            navigation(R.id.houseListFragment, bundle);
92
-        });
93
-        mBinding.tvPersonCount.setOnClickListener(v -> {
94
-            // 人员列表
95
-            Bundle bundle = new Bundle();
96
-            bundle.putBoolean("showTitle", true);
97
-            navigation(R.id.personListFragment, bundle);
98
-        });
85
+//        mBinding.tvHouseCount.setOnClickListener(v -> {
86
+//            // 仓列表
87
+//            Bundle bundle = new Bundle();
88
+//            bundle.putBoolean("showTitle", true);
89
+//            navigation(R.id.houseListFragment, bundle);
90
+//        });
91
+//        mBinding.tvPersonCount.setOnClickListener(v -> {
92
+//            // 人员列表
93
+//            Bundle bundle = new Bundle();
94
+//            bundle.putBoolean("showTitle", true);
95
+//            navigation(R.id.personListFragment, bundle);
96
+//        });
99 97
 
100 98
         // 初始化轮播图
101 99
         initBanner();
@@ -110,6 +108,18 @@ public class HomeFragment extends BaseFragment<FragmentHomeBinding> {
110 108
 
111 109
     @Override
112 110
     protected void onFirstShow() {
111
+        if (mPieChartHouseStatus == null) {
112
+            mPieChartHouseStatus = new MyPieChart(mBinding.pieHouseStatus);
113
+        }
114
+
115
+        if (mBarChartFoodType == null) {
116
+            mBarChartFoodType = new MyBarChart(mBinding.barFoodType);
117
+        }
118
+
119
+        if (mPieChartStorageStatus == null) {
120
+            mPieChartStorageStatus = new MyPieChart(mBinding.pieStorageStatus);
121
+        }
122
+
113 123
         getData();
114 124
     }
115 125
 
@@ -120,18 +130,10 @@ public class HomeFragment extends BaseFragment<FragmentHomeBinding> {
120 130
         getFoodType();
121 131
         getStorageStatus();
122 132
 
123
-        UserBean user = UserModel.get().getUser();
124
-        if (user == null) return;
125
-        mBinding.tvCompany.setText(user.getDepotName());
126
-        Glide.with(getContext())
127
-                .load(UrlPath.image_host + user.getPheadPortrait())
128
-                .placeholder(R.drawable.ic_img_loading)
129
-                .error(R.drawable.ic_user_empty)
130
-                .into(mBinding.ivUser);
131
-
132 133
         getTodoCount();
133 134
         getNoticeCount();
134 135
         getAnnounceList();
136
+        getUserInfo();
135 137
     }
136 138
 
137 139
 
@@ -147,41 +149,137 @@ public class HomeFragment extends BaseFragment<FragmentHomeBinding> {
147 149
         mBannerUtils.setImagesResId(list);
148 150
     }
149 151
 
152
+    /**
153
+     * 仓房状态饼图
154
+     */
150 155
     private void getHouseStatus() {
151
-        if (mPieChartHouseStatus == null)
152
-            mPieChartHouseStatus = new MyPieChart(mBinding.pieHouseStatus);
153
-        // 仓房状态
154
-        List<PieEntry> pieEntries = new ArrayList<>();
155
-        pieEntries.add(new PieEntry(200f, "入库"));
156
-        pieEntries.add(new PieEntry(290f, "出库"));
157
-        pieEntries.add(new PieEntry(240f, "通风"));
158
-        pieEntries.add(new PieEntry(160f, "熏蒸"));
159
-        mPieChartHouseStatus.showChart(pieEntries, "仓房状态");
156
+
157
+        UserBean user = UserModel.get().getUser();
158
+        if (user == null) return;
159
+        String depotId = user.getDepotId();
160
+        if (depotId == null) return;
161
+        // 请求后台接口
162
+        DepotModel.get().getWarehouseStatus(Integer.parseInt(depotId), new DataCallback<List<Map<String, Object>>>() {
163
+            @Override
164
+            public void onSuccess(List<Map<String, Object>> data) {
165
+                if (!isActive()) return;
166
+                mBinding.refreshLayout.setRefreshing(false);
167
+
168
+                if (data == null || data.size() == 0) return;
169
+
170
+                // 将数据源 转为 饼图数据
171
+                List<PieEntry> pieEntries = new ArrayList<>();
172
+                for (Map<String, Object> item : data) {
173
+                    String count = (String) item.get("count");
174
+                    String status = (String) item.get("warehouseStatus");
175
+                    if (count == null) count = "0";
176
+                    if (status == null) status = "";
177
+                    pieEntries.add(new PieEntry(Float.parseFloat(count), status));
178
+                }
179
+                List<Integer> list = Arrays.asList(
180
+                        Color.parseColor("#FFA100"),
181
+                        Color.parseColor("#1FA2EB"),
182
+                        Color.parseColor("#F3DE38"),
183
+                        Color.parseColor("#89BF6B"));
184
+                // 显示饼图
185
+                mPieChartHouseStatus.showChart(pieEntries, "仓房状态", list);
186
+            }
187
+
188
+            @Override
189
+            public void onError(String error) {
190
+                super.onError(error);
191
+                if (!isActive()) return;
192
+                mBinding.refreshLayout.setRefreshing(false);
193
+            }
194
+        });
160 195
     }
161 196
 
197
+    /**
198
+     * 粮食品种柱状图
199
+     */
162 200
     private void getFoodType() {
163
-        if (mBarChartFoodType == null)
164
-            mBarChartFoodType = new MyBarChart(mBinding.barFoodType);
201
+        UserBean user = UserModel.get().getUser();
202
+        if (user == null) return;
203
+        String depotId = user.getDepotId();
204
+        if (depotId == null) return;
205
+        DepotModel.get().getFoodTypeCount(Integer.parseInt(depotId), new DataCallback<List<Map<String, Object>>>() {
206
+            @Override
207
+            public void onSuccess(List<Map<String, Object>> data) {
208
+                if (!isActive()) return;
209
+                mBinding.refreshLayout.setRefreshing(false);
210
+
211
+                if (data == null || data.size() == 0) return;
212
+
213
+                // 将数据源 转为 饼图数据
214
+                List<String> labelList = new ArrayList<>();
215
+                ArrayList<BarEntry> valueList = new ArrayList<>();
216
+                for (int i = 0; i < data.size(); i++) {
217
+                    Map<String, Object> item = data.get(i);
218
+
219
+                    String label = (String) item.get("grainVarieties");
220
+                    if (label == null) label = "";
221
+                    labelList.add(label);
222
+
223
+                    String count = (String) item.get("count");
224
+                    if (count == null) count = "0";
225
+                    valueList.add(new BarEntry(i, Float.parseFloat(count)));
226
+
227
+                }
228
+                mBarChartFoodType.showChart(labelList, valueList);
229
+            }
230
+
231
+            @Override
232
+            public void onError(String error) {
233
+                super.onError(error);
234
+                if (!isActive()) return;
235
+                mBinding.refreshLayout.setRefreshing(false);
236
+            }
237
+        });
165 238
 
166
-        // 粮食品种
167
-        ArrayList<BarEntry> barEntries = new ArrayList<>();
168
-        barEntries.add(new BarEntry(0, 140));
169
-        barEntries.add(new BarEntry(1, 120));
170
-        barEntries.add(new BarEntry(2, 80));
171
-        barEntries.add(new BarEntry(3, 50));
172
-        List<String> workTypeLabels = Arrays.asList("玉米", "小麦", "大豆", "稻谷");
173
-        mBarChartFoodType.showChart(workTypeLabels, barEntries);
174 239
     }
175 240
 
241
+    /**
242
+     * 存储状态饼图
243
+     */
176 244
     private void getStorageStatus() {
177
-        if (mPieChartStorageStatus == null)
178
-            mPieChartStorageStatus = new MyPieChart(mBinding.pieStorageStatus);
179
-        // 储存状态
180
-        List<PieEntry> pieEntries = new ArrayList<>();
181
-        pieEntries.add(new PieEntry(200f, "空仓"));
182
-        pieEntries.add(new PieEntry(290f, "满仓"));
183
-        pieEntries.add(new PieEntry(240f, "半仓"));
184
-        mPieChartStorageStatus.showChart(pieEntries, "储存状态");
245
+
246
+        UserBean user = UserModel.get().getUser();
247
+        if (user == null) return;
248
+        String depotId = user.getDepotId();
249
+        if (depotId == null) return;
250
+        // 请求后台接口
251
+        DepotModel.get().getStorageStatus(Integer.parseInt(depotId), new DataCallback<List<Map<String, Object>>>() {
252
+            @Override
253
+            public void onSuccess(List<Map<String, Object>> data) {
254
+                if (!isActive()) return;
255
+                mBinding.refreshLayout.setRefreshing(false);
256
+
257
+                if (data == null || data.size() == 0) return;
258
+
259
+                // 将数据源 转为 饼图数据
260
+                List<PieEntry> pieEntries = new ArrayList<>();
261
+                for (Map<String, Object> item : data) {
262
+                    String count = (String) item.get("count");
263
+                    String status = (String) item.get("storageStatus");
264
+                    if (count == null) count = "0";
265
+                    if (status == null) status = "";
266
+                    pieEntries.add(new PieEntry(Float.parseFloat(count), status));
267
+                }
268
+                List<Integer> list = Arrays.asList(
269
+                        Color.parseColor("#057B43"),
270
+                        Color.parseColor("#8ABF6B"),
271
+                        Color.parseColor("#F3DE38"));
272
+                // 显示饼图
273
+                mPieChartStorageStatus.showChart(pieEntries, "储存状态", list);
274
+            }
275
+
276
+            @Override
277
+            public void onError(String error) {
278
+                super.onError(error);
279
+                if (!isActive()) return;
280
+                mBinding.refreshLayout.setRefreshing(false);
281
+            }
282
+        });
185 283
     }
186 284
 
187 285
 
@@ -203,8 +301,8 @@ public class HomeFragment extends BaseFragment<FragmentHomeBinding> {
203 301
             @Override
204 302
             public void onSuccess(Integer data) {
205 303
                 if (!isActive()) return;
206
-
207 304
                 mBinding.refreshLayout.setRefreshing(false);
305
+
208 306
                 if ((int) data == 0) {
209 307
                     mBinding.tvTodoCount.setVisibility(View.GONE);
210 308
                     return;
@@ -212,6 +310,13 @@ public class HomeFragment extends BaseFragment<FragmentHomeBinding> {
212 310
                 mBinding.tvTodoCount.setVisibility(View.VISIBLE);
213 311
                 mBinding.tvTodoCount.setText(data + "");
214 312
             }
313
+
314
+            @Override
315
+            public void onError(String error) {
316
+                super.onError(error);
317
+                if (!isActive()) return;
318
+                mBinding.refreshLayout.setRefreshing(false);
319
+            }
215 320
         });
216 321
     }
217 322
 
@@ -223,6 +328,7 @@ public class HomeFragment extends BaseFragment<FragmentHomeBinding> {
223 328
             @Override
224 329
             public void onSuccess(Integer data) {
225 330
                 if (!isActive()) return;
331
+                mBinding.refreshLayout.setRefreshing(false);
226 332
 
227 333
                 if ((int) data == 0) {
228 334
                     mBinding.tvNoticeCount.setVisibility(View.GONE);
@@ -231,6 +337,13 @@ public class HomeFragment extends BaseFragment<FragmentHomeBinding> {
231 337
                 mBinding.tvNoticeCount.setVisibility(View.VISIBLE);
232 338
                 mBinding.tvNoticeCount.setText(data + "");
233 339
             }
340
+
341
+            @Override
342
+            public void onError(String error) {
343
+                super.onError(error);
344
+                if (!isActive()) return;
345
+                mBinding.refreshLayout.setRefreshing(false);
346
+            }
234 347
         });
235 348
     }
236 349
 
@@ -243,6 +356,7 @@ public class HomeFragment extends BaseFragment<FragmentHomeBinding> {
243 356
             @Override
244 357
             public void onSuccess(List<AnnounceBean> data) {
245 358
                 if (!isActive()) return;
359
+                mBinding.refreshLayout.setRefreshing(false);
246 360
 
247 361
                 if (data.size() == 0) return;
248 362
 
@@ -259,6 +373,48 @@ public class HomeFragment extends BaseFragment<FragmentHomeBinding> {
259 373
                         })
260 374
                 ;
261 375
             }
376
+
377
+            @Override
378
+            public void onError(String error) {
379
+                super.onError(error);
380
+                if (!isActive()) return;
381
+                mBinding.refreshLayout.setRefreshing(false);
382
+            }
383
+        });
384
+    }
385
+
386
+    /**
387
+     * 收到消息 刷新用户信息
388
+     */
389
+    @Subscribe(threadMode = ThreadMode.MAIN)
390
+    public void onUserEvent(UserBean event) {
391
+        getUserInfo();
392
+    }
393
+
394
+    /**
395
+     * 获取用户信息
396
+     */
397
+    private void getUserInfo() {
398
+        UserModel.get().refreshUser(new DataCallback<UserBean>() {
399
+            @Override
400
+            public void onSuccess(UserBean user) {
401
+                if (!isActive()) return;
402
+                mBinding.refreshLayout.setRefreshing(false);
403
+
404
+                mBinding.tvCompany.setText(user.getDepotName());
405
+                Glide.with(getContext())
406
+                        .load(UrlPath.image_host + user.getPheadPortrait())
407
+                        .placeholder(R.drawable.ic_img_loading)
408
+                        .error(R.drawable.ic_user_empty)
409
+                        .into(mBinding.ivUser);
410
+            }
411
+
412
+            @Override
413
+            public void onError(String error) {
414
+                super.onError(error);
415
+                if (!isActive()) return;
416
+                mBinding.refreshLayout.setRefreshing(false);
417
+            }
262 418
         });
263 419
     }
264 420
 

+ 28 - 0
app/src/main/java/com/unis/sxzcl/ui/home/MainFragment.java

@@ -10,12 +10,16 @@ import androidx.fragment.app.Fragment;
10 10
 import androidx.viewpager.widget.ViewPager;
11 11
 
12 12
 import com.unis.model.DataCallback;
13
+import com.unis.model.DepotModel;
13 14
 import com.unis.model.VersionModel;
15
+import com.unis.model.bean.MultiDepotBean;
14 16
 import com.unis.model.bean.VersionBean;
17
+import com.unis.sxzcl.R;
15 18
 import com.unis.sxzcl.base.BaseFragment;
16 19
 import com.unis.sxzcl.databinding.FragmentMainBinding;
17 20
 import com.unis.sxzcl.ui.work_module.WorkModuleFragment;
18 21
 import com.unis.sxzcl.widget.MyFragmentStatePagerAdapter;
22
+import com.unis.sxzcl.widget.dialog.SystemDialog;
19 23
 
20 24
 import java.util.ArrayList;
21 25
 import java.util.List;
@@ -40,6 +44,7 @@ public class MainFragment extends BaseFragment<FragmentMainBinding> {
40 44
     private boolean[] mTabTopWhite;
41 45
 
42 46
     private int indexFlag = -1;//tab选中标记
47
+    private SystemDialog mSelectDepotDialog;
43 48
 
44 49
 
45 50
     @Override
@@ -80,6 +85,14 @@ public class MainFragment extends BaseFragment<FragmentMainBinding> {
80 85
             @Override
81 86
             public void onPageSelected(int position) {
82 87
                 updateTab(position);
88
+
89
+                if (position == mFragmentList.size() - 1) {
90
+                    // 作业功能列表时 未选库弹出提示
91
+                    MultiDepotBean selectDepot = DepotModel.get().getSelectDepot();
92
+                    if (selectDepot == null) {
93
+                        showSelectDepotDialog();
94
+                    }
95
+                }
83 96
             }
84 97
 
85 98
             @Override
@@ -89,6 +102,21 @@ public class MainFragment extends BaseFragment<FragmentMainBinding> {
89 102
         });
90 103
     }
91 104
 
105
+    // 弹出选择粮库对话框
106
+    public void showSelectDepotDialog() {
107
+        if (mSelectDepotDialog == null)
108
+            mSelectDepotDialog = new SystemDialog(getContext())
109
+                    .setHideTitle()
110
+                    .setMsg("请先选择粮库")
111
+                    .setLeftButton("取消", null)
112
+                    .setRightButton("去选择", dialog -> {
113
+                        mSelectDepotDialog.dismiss();
114
+                        // 切换组织架构
115
+                        navigation(R.id.companyListFragment);
116
+                    });
117
+        mSelectDepotDialog.show();
118
+    }
119
+
92 120
     /**
93 121
      * 初始化Fragment
94 122
      */

+ 1 - 0
app/src/main/java/com/unis/sxzcl/ui/user/UserFragment.java

@@ -227,6 +227,7 @@ public class UserFragment extends BaseFragment<FragmentUserBinding> {
227 227
                 if (!isActive()) return;
228 228
                 hideProgress();
229 229
                 ToastTool.showLong("头像修改成功!");
230
+                EventBus.getDefault().post(new UserBean());
230 231
             }
231 232
 
232 233
             @Override

+ 1 - 0
app/src/main/java/com/unis/sxzcl/ui/work_module/WorkModuleFragment.java

@@ -122,6 +122,7 @@ public class WorkModuleFragment extends BaseListFragment<FragmentWorkModuleBindi
122 122
 
123 123
     @Override
124 124
     protected void onFirstShow() {
125
+
125 126
         onRefresh();
126 127
     }
127 128
 

+ 16 - 7
app/src/main/java/com/unis/sxzcl/widget/MyPieChart.java

@@ -101,16 +101,25 @@ public class MyPieChart {
101 101
     }
102 102
 
103 103
     public void showChart(List<PieEntry> values, String name) {
104
+        showChart(values, name, null);
105
+    }
106
+
107
+    public void showChart(List<PieEntry> values, String name, List<Integer> colors) {
104 108
         //设置PieChart内部圆文字的内容
105 109
         mPieChart.setCenterText(name);
106 110
         PieDataSet pieDataSet = new PieDataSet(values, name);
107
-        //分别为每个分组设置颜色
108
-        pieDataSet.setColors(
109
-                Color.parseColor("#47C7E8"),
110
-                Color.parseColor("#A5E7BA"),
111
-                Color.parseColor("#F56D91"),
112
-                Color.parseColor("#FA9C80"),
113
-                Color.parseColor("#968FEB"));
111
+
112
+        if (colors == null) {
113
+            //分别为每个分组设置颜色
114
+            pieDataSet.setColors(
115
+                    Color.parseColor("#47C7E8"),
116
+                    Color.parseColor("#A5E7BA"),
117
+                    Color.parseColor("#F56D91"),
118
+                    Color.parseColor("#FA9C80"),
119
+                    Color.parseColor("#968FEB"));
120
+        } else {
121
+            pieDataSet.setColors(colors);
122
+        }
114 123
 
115 124
         //设置饼块选中时偏离饼图中心的距离
116 125
         pieDataSet.setSelectionShift(8f);

+ 1 - 1
app/src/main/res/layout/fragment_home.xml

@@ -51,7 +51,7 @@
51 51
                 android:layout_width="match_parent"
52 52
                 android:layout_height="match_parent"
53 53
                 android:scaleType="centerCrop"
54
-                android:src="@drawable/no_banner" />
54
+                android:src="@drawable/ic_user_empty" />
55 55
         </androidx.cardview.widget.CardView>
56 56
 
57 57
 

+ 87 - 94
app/src/main/res/layout/fragment_person_detail.xml

@@ -22,141 +22,134 @@
22 22
             android:background="@color/colorWhite"
23 23
             android:orientation="vertical">
24 24
 
25
-            <androidx.cardview.widget.CardView
26
-                android:layout_width="140dp"
27
-                android:layout_height="140dp"
28
-                android:layout_gravity="center_horizontal"
29
-                android:layout_marginTop="16dp"
30
-                android:layout_marginBottom="8dp"
31
-                app:cardCornerRadius="70dp"
32
-                app:cardElevation="4dp">
33
-
34
-                <ImageView
35
-                    android:id="@+id/iv_show"
36
-                    android:layout_width="match_parent"
37
-                    android:layout_height="match_parent"
38
-                    android:scaleType="centerCrop"
39
-                    android:src="@drawable/no_banner" />
40
-
41
-            </androidx.cardview.widget.CardView>
42
-
43
-            <TextView
44
-                android:id="@+id/tv_name"
45
-                android:layout_width="wrap_content"
25
+            <LinearLayout
26
+                android:layout_width="match_parent"
46 27
                 android:layout_height="wrap_content"
47
-                android:layout_gravity="center_horizontal"
48
-                android:text=""
49
-                android:textColor="@color/colorTextBlack"
50
-                android:textSize="?attr/textSizeXXX"
51
-                android:textStyle="bold" />
28
+                android:background="@color/colorBackground"
29
+                android:orientation="vertical">
30
+
31
+                <androidx.cardview.widget.CardView
32
+                    android:layout_width="140dp"
33
+                    android:layout_height="140dp"
34
+                    android:layout_gravity="center_horizontal"
35
+                    android:layout_marginTop="32dp"
36
+                    app:cardCornerRadius="70dp"
37
+                    app:cardElevation="8dp">
38
+
39
+                    <ImageView
40
+                        android:id="@+id/iv_show"
41
+                        android:layout_width="match_parent"
42
+                        android:layout_height="match_parent"
43
+                        android:scaleType="centerCrop"
44
+                        android:src="@drawable/ic_user_empty" />
45
+
46
+                </androidx.cardview.widget.CardView>
47
+
48
+                <TextView
49
+                    android:id="@+id/tv_name"
50
+                    android:layout_width="wrap_content"
51
+                    android:layout_height="wrap_content"
52
+                    android:layout_gravity="center_horizontal"
53
+                    android:layout_marginTop="8dp"
54
+                    android:layout_marginBottom="32dp"
55
+                    android:text="昵称"
56
+                    android:textColor="@color/colorText33"
57
+                    android:textSize="?attr/textSizeXXXX"
58
+                    android:textStyle="bold" />
59
+            </LinearLayout>
60
+
52 61
 
53 62
             <TextView
54
-                android:layout_width="wrap_content"
55
-                android:layout_height="wrap_content"
56
-                android:layout_marginLeft="16dp"
57
-                android:layout_marginTop="16dp"
58
-                android:text="性别"
59
-                android:textColor="@color/colorTextBlack"
60
-                android:textSize="?attr/textSizeXX" />
63
+                style="@style/person_detail_title"
64
+                android:text="性别" />
61 65
 
62 66
             <TextView
63 67
                 android:id="@+id/tv_sex"
64
-                android:layout_width="wrap_content"
65
-                android:layout_height="wrap_content"
66
-                android:layout_marginLeft="16dp"
67
-                android:text=""
68
-                android:textColor="@color/colorTheme"
69
-                android:textSize="?attr/textSizeXXX" />
68
+                style="@style/person_detail_content"
69
+                android:text="性别" />
70
+
71
+            <View
72
+                style="@style/line_16"
73
+                android:layout_marginTop="16dp" />
70 74
 
71 75
             <TextView
72
-                android:layout_width="wrap_content"
73
-                android:layout_height="wrap_content"
74
-                android:layout_marginLeft="16dp"
75
-                android:layout_marginTop="16dp"
76
-                android:text="所属公司"
77
-                android:textColor="@color/colorTextBlack"
78
-                android:textSize="?attr/textSizeXX" />
76
+                style="@style/person_detail_title"
77
+                android:text="所属公司" />
79 78
 
80 79
             <TextView
81 80
                 android:id="@+id/tv_company"
82
-                android:layout_width="wrap_content"
83
-                android:layout_height="wrap_content"
84
-                android:layout_marginLeft="16dp"
85
-                android:text=""
86
-                android:textColor="@color/colorTheme"
87
-                android:textSize="?attr/textSizeXXX" />
81
+                style="@style/person_detail_content"
82
+                android:text="所属公司" />
83
+
84
+            <View
85
+                style="@style/line_16"
86
+                android:layout_marginTop="16dp" />
88 87
 
89 88
             <TextView
90
-                android:layout_width="wrap_content"
91
-                android:layout_height="wrap_content"
92
-                android:layout_marginLeft="16dp"
93
-                android:layout_marginTop="16dp"
94
-                android:text="所属科室"
95
-                android:textColor="@color/colorTextBlack"
96
-                android:textSize="?attr/textSizeXX" />
89
+                style="@style/person_detail_title"
90
+                android:text="所属科室" />
97 91
 
98 92
             <TextView
99 93
                 android:id="@+id/tv_deportment"
100
-                android:layout_width="wrap_content"
101
-                android:layout_height="wrap_content"
102
-                android:layout_marginLeft="16dp"
103
-                android:text=""
104
-                android:textColor="@color/colorTheme"
105
-                android:textSize="?attr/textSizeXXX" />
94
+                style="@style/person_detail_content"
95
+                android:text="所属科室" />
96
+
97
+            <View
98
+                style="@style/line_16"
99
+                android:layout_marginTop="16dp" />
106 100
 
107 101
             <TextView
108
-                android:layout_width="wrap_content"
109
-                android:layout_height="wrap_content"
110
-                android:layout_marginLeft="16dp"
111
-                android:layout_marginTop="16dp"
112
-                android:text="职位"
113
-                android:textColor="@color/colorTextBlack"
114
-                android:textSize="?attr/textSizeXX" />
102
+                style="@style/person_detail_title"
103
+                android:text="职位" />
115 104
 
116 105
             <TextView
117 106
                 android:id="@+id/tv_post"
118
-                android:layout_width="wrap_content"
119
-                android:layout_height="wrap_content"
120
-                android:layout_marginLeft="16dp"
121
-                android:text=""
122
-                android:textColor="@color/colorTheme"
123
-                android:textSize="?attr/textSizeXXX" />
107
+                style="@style/person_detail_content"
108
+                android:text="职位" />
124 109
 
125
-            <TextView
126
-                android:layout_width="wrap_content"
127
-                android:layout_height="wrap_content"
128
-                android:layout_marginLeft="16dp"
129
-                android:layout_marginTop="16dp"
130
-                android:text="手机号"
131
-                android:textColor="@color/colorTextBlack"
132
-                android:textSize="?attr/textSizeXX" />
110
+            <View
111
+                style="@style/line_16"
112
+                android:layout_marginTop="16dp" />
133 113
 
134 114
             <LinearLayout
135 115
                 android:layout_width="match_parent"
136 116
                 android:layout_height="wrap_content"
137
-                android:layout_marginLeft="16dp"
138
-                android:layout_marginRight="16dp">
117
+                android:orientation="horizontal">
139 118
 
140
-                <TextView
141
-                    android:id="@+id/tv_phone"
119
+                <LinearLayout
142 120
                     android:layout_width="0dp"
143 121
                     android:layout_height="wrap_content"
144 122
                     android:layout_weight="1"
145
-                    android:text=""
146
-                    android:textColor="@color/colorTheme"
147
-                    android:textSize="?attr/textSizeXXX" />
123
+                    android:orientation="vertical">
124
+
125
+                    <TextView
126
+                        style="@style/person_detail_title"
127
+                        android:text="手机号" />
128
+
129
+                    <TextView
130
+                        android:id="@+id/tv_phone"
131
+                        style="@style/person_detail_content"
132
+                        android:layout_marginBottom="16dp"
133
+                        android:text="" />
134
+                </LinearLayout>
135
+
148 136
 
149 137
                 <TextView
150 138
                     android:id="@+id/tv_call"
151 139
                     android:layout_width="wrap_content"
152 140
                     android:layout_height="wrap_content"
141
+                    android:layout_gravity="center"
142
+                    android:layout_marginRight="16dp"
153 143
                     android:background="@drawable/accent_radius_stroke_bg"
154 144
                     android:paddingLeft="16dp"
155 145
                     android:paddingTop="8dp"
156 146
                     android:paddingRight="16dp"
157 147
                     android:paddingBottom="8dp"
158 148
                     android:text="拨打电话"
159
-                    android:textColor="@color/colorTheme" />
149
+                    android:textColor="@color/colorTheme"
150
+                    android:textSize="?attr/textSizeXX"
151
+                    android:textStyle="bold" />
152
+
160 153
             </LinearLayout>
161 154
 
162 155
 

+ 2 - 1
app/src/main/res/layout/item_list_announce.xml

@@ -24,7 +24,8 @@
24 24
         android:layout_marginRight="16dp"
25 25
         android:layout_toRightOf="@id/v_flag"
26 26
         android:text="标题"
27
-        android:textColor="@color/colorText33"
27
+        android:textStyle="bold"
28
+        android:textColor="@color/colorTheme"
28 29
         android:textSize="?attr/textSizeXX" />
29 30
 
30 31
     <TextView

+ 19 - 1
app/src/main/res/values/styles.xml

@@ -156,7 +156,6 @@
156 156
     <style name="home_info_text">
157 157
         <item name="android:layout_width">wrap_content</item>
158 158
         <item name="android:layout_height">wrap_content</item>
159
-        <item name="android:foreground">?android:selectableItemBackground</item>
160 159
         <item name="android:gravity">center</item>
161 160
         <item name="android:paddingLeft">24dp</item>
162 161
         <item name="android:paddingRight">24dp</item>
@@ -166,4 +165,23 @@
166 165
         <item name="android:textSize">?attr/textSizeXX</item>
167 166
     </style>
168 167
 
168
+    <style name="person_detail_title">
169
+        <item name="android:layout_width">wrap_content</item>
170
+        <item name="android:layout_height">wrap_content</item>
171
+        <item name="android:layout_marginLeft">16dp</item>
172
+        <item name="android:layout_marginTop">16dp</item>
173
+        <item name="android:textColor">@color/colorText55</item>
174
+        <item name="android:textSize">?attr/textSizeXX</item>
175
+    </style>
176
+
177
+    <style name="person_detail_content">
178
+        <item name="android:layout_width">wrap_content</item>
179
+        <item name="android:layout_height">wrap_content</item>
180
+        <item name="android:layout_marginLeft">16dp</item>
181
+        <item name="android:layout_marginTop">8dp</item>
182
+        <item name="android:textColor">@color/colorText33</item>
183
+        <item name="android:textSize">?attr/textSizeXXX</item>
184
+    </style>
185
+
186
+
169 187
 </resources>

+ 2 - 2
model/src/main/java/com/unis/model/BasicModel.java

@@ -133,9 +133,9 @@ public class BasicModel {
133 133
      * 获取人员字典
134 134
      */
135 135
     public void getPersonDictionary() {
136
-        String depotId = UserModel.get().getUser().getDepotId();
136
+//        String depotId = UserModel.get().getUser().getDepotId();
137 137
         GetRequest<String> request = OkGo.get(UrlPath.person_dictionary);
138
-        request.params("depotId", depotId);
138
+//        request.params("depotId", depotId);
139 139
         request.execute(new MyStringCallback() {
140 140
             @Override
141 141
             protected void onSuccessResult(Response<String> response) throws JSONException {

+ 86 - 0
model/src/main/java/com/unis/model/DepotModel.java

@@ -4,13 +4,16 @@ import com.google.gson.Gson;
4 4
 import com.google.gson.reflect.TypeToken;
5 5
 import com.lzy.okgo.OkGo;
6 6
 import com.lzy.okgo.model.Response;
7
+import com.lzy.okgo.request.PostRequest;
7 8
 import com.unis.model.bean.MultiDepotBean;
8 9
 import com.xyxsbj.mylibrary.tool.SPTool;
9 10
 
10 11
 import org.json.JSONException;
11 12
 
12 13
 import java.lang.reflect.Type;
14
+import java.util.HashMap;
13 15
 import java.util.List;
16
+import java.util.Map;
14 17
 
15 18
 /**
16 19
  * 包名: com.unis.model
@@ -68,6 +71,7 @@ public class DepotModel {
68 71
     public void saveSelectDepot(MultiDepotBean bean) {
69 72
         SPTool.saveString(Constant.KEY_SELECT_DEPOT, new Gson().toJson(bean));
70 73
     }
74
+
71 75
     public void removeSelectDepot() {
72 76
         SPTool.remove(Constant.KEY_SELECT_DEPOT);
73 77
     }
@@ -83,4 +87,86 @@ public class DepotModel {
83 87
         return bean;
84 88
     }
85 89
 
90
+    /**
91
+     * 获取存储状态统计
92
+     */
93
+    public void getStorageStatus(Integer depotId, final DataCallback<List<Map<String, Object>>> callback) {
94
+        Map<String, Object> map = new HashMap<>();
95
+        map.put("depotId", depotId);
96
+        map.put("storageStatus", "s");
97
+        PostRequest<String> request = OkGo.post(UrlPath.home_percent);
98
+        request.upJson(new Gson().toJson(map));
99
+        request.execute(new MyStringCallback() {
100
+            @Override
101
+            protected void onSuccessResult(Response<String> response) throws JSONException {
102
+                String json = getDataJson(response);
103
+                List<Map<String, Object>> list =
104
+                        new Gson().fromJson(json, new TypeToken<List<Map<String, Object>>>() {
105
+                        }.getType());
106
+                callback.onSuccess(list);
107
+            }
108
+
109
+            @Override
110
+            public void onError(Response<String> response) {
111
+                super.onError(response);
112
+                callback.onError(getErrorMsg(response));
113
+            }
114
+        });
115
+    }
116
+
117
+    /**
118
+     * 获取仓房状态统计
119
+     */
120
+    public void getWarehouseStatus(Integer depotId, final DataCallback<List<Map<String, Object>>> callback) {
121
+        Map<String, Object> map = new HashMap<>();
122
+        map.put("depotId", depotId);
123
+        map.put("warehouseStatus", "w");
124
+        PostRequest<String> request = OkGo.post(UrlPath.home_percent);
125
+        request.upJson(new Gson().toJson(map));
126
+        request.execute(new MyStringCallback() {
127
+            @Override
128
+            protected void onSuccessResult(Response<String> response) throws JSONException {
129
+                String json = getDataJson(response);
130
+                List<Map<String, Object>> list =
131
+                        new Gson().fromJson(json, new TypeToken<List<Map<String, Object>>>() {
132
+                        }.getType());
133
+                callback.onSuccess(list);
134
+            }
135
+
136
+            @Override
137
+            public void onError(Response<String> response) {
138
+                super.onError(response);
139
+                callback.onError(getErrorMsg(response));
140
+            }
141
+        });
142
+    }
143
+
144
+    /**
145
+     * 获取粮食品种统计
146
+     */
147
+    public void getFoodTypeCount(Integer depotId, final DataCallback<List<Map<String, Object>>> callback) {
148
+        Map<String, Object> map = new HashMap<>();
149
+        map.put("depotId", depotId);
150
+        map.put("grainVarieties", "g");
151
+        PostRequest<String> request = OkGo.post(UrlPath.home_percent);
152
+        request.upJson(new Gson().toJson(map));
153
+        request.execute(new MyStringCallback() {
154
+            @Override
155
+            protected void onSuccessResult(Response<String> response) throws JSONException {
156
+                String json = getDataJson(response);
157
+                List<Map<String, Object>> list =
158
+                        new Gson().fromJson(json, new TypeToken<List<Map<String, Object>>>() {
159
+                        }.getType());
160
+                callback.onSuccess(list);
161
+            }
162
+
163
+            @Override
164
+            public void onError(Response<String> response) {
165
+                super.onError(response);
166
+                callback.onError(getErrorMsg(response));
167
+            }
168
+        });
169
+    }
170
+
171
+
86 172
 }

+ 3 - 0
model/src/main/java/com/unis/model/MyStringCallback.java

@@ -30,6 +30,9 @@ public abstract class MyStringCallback extends StringCallback {
30 30
     @Override
31 31
     public void onStart(Request<String, ? extends Request> request) {
32 32
         super.onStart(request);
33
+//        CookieStore store = OkGo.getInstance().getCookieJar().getCookieStore();
34
+//        List<Cookie> allCookie = store.getAllCookie();
35
+//        LogTool.d("所有cookie如下:" + allCookie.toString());
33 36
     }
34 37
 
35 38
     protected abstract void onSuccessResult(Response<String> response) throws JSONException;

+ 10 - 1
model/src/main/java/com/unis/model/UrlPath.java

@@ -34,6 +34,8 @@ public class UrlPath {
34 34
 
35 35
     // 新增用户
36 36
     public static final String user_add = host + "/api/csc-szls-system-manage/user/authority_button/add";
37
+    // 用户信息
38
+    public static final String user_info = host + "/api/csc-szls-system-manage/user/authority/getById";
37 39
 
38 40
 
39 41
     /****************** 库 ******************/
@@ -67,7 +69,6 @@ public class UrlPath {
67 69
     public static final String person_dictionary = host + "/api/csc-szls-system-manage/user/authority/getAll";
68 70
 
69 71
 
70
-
71 72
     /****************** 部门 ******************/
72 73
     // 部门字典
73 74
     public static final String department_dictionary = host + "/api/csc-szls-system-manage/sysDepartment/authority/getAllMAP";
@@ -121,4 +122,12 @@ public class UrlPath {
121 122
     public static final String announce_list = host + "/api/csc-szls-message/sysAnnouncementUser/authority/getPage";
122 123
 
123 124
 
125
+    /****************** 首页 ******************/
126
+    // 获取统计图
127
+    public static final String home_percent = host + "/api/csc-szls-system-manage/basicsWarehouse/authority/getPercent";
128
+
129
+
130
+
131
+
132
+
124 133
 }

+ 34 - 2
model/src/main/java/com/unis/model/UserModel.java

@@ -16,6 +16,7 @@ import com.unis.model.bean.person.PersonBean;
16 16
 import com.unis.model.bean.person.PersonTreeBean;
17 17
 import com.xyxsbj.mylibrary.tool.LogTool;
18 18
 import com.xyxsbj.mylibrary.tool.SPTool;
19
+import com.xyxsbj.mylibrary.tool.ToastTool;
19 20
 
20 21
 import org.json.JSONException;
21 22
 
@@ -119,13 +120,14 @@ public class UserModel {
119 120
                         // 添加cookie
120 121
                         HttpUrl httpUrl = HttpUrl.parse(UrlPath.host);
121 122
                         Cookie.Builder builder = new Cookie.Builder();
122
-                        Cookie cookieToken = builder.name("Token").value(tokenType + "%20" + accessToken).domain(httpUrl.host()).build();
123
+//                        Cookie cookieToken = builder.name("Token").value(tokenType + "%20" + accessToken).domain(httpUrl.host()).build();
124
+                        Cookie cookieToken = builder.name("Token").value(token).domain(httpUrl.host()).build();
123 125
                         CookieStore cookieStore = OkGo.getInstance().getCookieJar().getCookieStore();
124 126
                         cookieStore.saveCookie(httpUrl, cookieToken);
125 127
 
126 128
                         CookieStore store = OkGo.getInstance().getCookieJar().getCookieStore();
127 129
                         List<Cookie> allCookie = store.getAllCookie();
128
-                        LogTool.i("所有cookie如下:" + allCookie.toString());
130
+                        LogTool.d("所有cookie如下:" + allCookie.toString());
129 131
 
130 132
                         if (callBack != null)
131 133
                             callBack.onSuccess(bean);
@@ -140,6 +142,36 @@ public class UserModel {
140 142
     }
141 143
 
142 144
     /**
145
+     * 刷新用户信息
146
+     */
147
+    public void refreshUser(final DataCallback<UserBean> callback) {
148
+        UserBean user = getUser();
149
+        if (user == null) {
150
+            ToastTool.showLong("没有用户信息");
151
+            callback.onError(null);
152
+            return;
153
+        }
154
+
155
+        GetRequest<String> request = OkGo.get(UrlPath.user_info + "/" + user.getUid());
156
+        request.execute(new MyStringCallback() {
157
+            @Override
158
+            protected void onSuccessResult(Response<String> response) throws JSONException {
159
+                String json = getDataJson(response);
160
+                SPTool.saveString(Constant.KEY_USER, json);
161
+                UserBean bean = new Gson().fromJson(json, UserBean.class);
162
+
163
+                callback.onSuccess(bean);
164
+            }
165
+
166
+            @Override
167
+            public void onError(Response<String> response) {
168
+                super.onError(response);
169
+                callback.onError(getErrorMsg(response));
170
+            }
171
+        });
172
+    }
173
+
174
+    /**
143 175
      * 获取用户信息
144 176
      */
145 177
     public UserBean getUser() {