|
|
@@ -25,11 +25,15 @@ import android.widget.ImageView;
|
|
|
import android.widget.PopupWindow;
|
|
|
|
|
|
import com.google.gson.Gson;
|
|
|
+import com.google.gson.reflect.TypeToken;
|
|
|
import com.ygtx.emcs.R;
|
|
|
import com.ygtx.emcs.activity.adapter.FunctionMenuAdapter;
|
|
|
import com.ygtx.emcs.activity.adapter.MainListViewAdapter;
|
|
|
+import com.ygtx.emcs.activity.model.ConfigModel;
|
|
|
import com.ygtx.emcs.activity.model.EventMessage;
|
|
|
import com.ygtx.emcs.activity.model.MainModel;
|
|
|
+import com.ygtx.emcs.activity.model.MaterialStockModel;
|
|
|
+import com.ygtx.emcs.activity.model.StockModel;
|
|
|
import com.ygtx.emcs.activity.model.TaskModel;
|
|
|
import com.ygtx.emcs.activity.model.UserModel;
|
|
|
import com.ygtx.emcs.comm.BaseActivity;
|
|
|
@@ -58,6 +62,7 @@ import org.xutils.common.Callback;
|
|
|
import org.xutils.http.RequestParams;
|
|
|
import org.xutils.x;
|
|
|
|
|
|
+import java.lang.reflect.Type;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
import java.util.UUID;
|
|
|
@@ -123,6 +128,10 @@ public class HomeActivity extends BaseActivity {
|
|
|
}
|
|
|
|
|
|
private void initLogin(){
|
|
|
+ CacheService.getInstance(context).saveCache(CACHE_BIND_CONFIG, "in_stock_flag", "RK");
|
|
|
+ CacheService.getInstance(context).saveCache(CACHE_BIND_CONFIG, "out_stock_flag", "CK");
|
|
|
+ CacheService.getInstance(context).saveCache(CACHE_BIND_CONFIG, "box_flag", "BOX");
|
|
|
+
|
|
|
String userStr = CacheService.getInstance(context).getCache(CACHE_LOGIN_KEY, "user");
|
|
|
if(!StringUtils.isEmpty(userStr)){
|
|
|
Constant.user = new Gson().fromJson(userStr, UserModel.class);
|
|
|
@@ -131,9 +140,6 @@ public class HomeActivity extends BaseActivity {
|
|
|
checkToken(Constant.user.getLoginName(), Constant.user.getLoginPwd());
|
|
|
}
|
|
|
}
|
|
|
- CacheService.getInstance(context).saveCache(CACHE_BIND_CONFIG, "in_stock_flag", "RK");
|
|
|
- CacheService.getInstance(context).saveCache(CACHE_BIND_CONFIG, "out_stock_flag", "CK");
|
|
|
- CacheService.getInstance(context).saveCache(CACHE_BIND_CONFIG, "box_flag", "BOX");
|
|
|
}
|
|
|
|
|
|
private void initView(){
|
|
|
@@ -226,6 +232,7 @@ public class HomeActivity extends BaseActivity {
|
|
|
popupWindow2.dismiss();
|
|
|
}
|
|
|
getUserInfo(loginName, loginPwd);
|
|
|
+ getConfig();
|
|
|
} catch (JSONException e) {
|
|
|
e.printStackTrace();
|
|
|
mylog.error(e);
|
|
|
@@ -296,30 +303,28 @@ public class HomeActivity extends BaseActivity {
|
|
|
});
|
|
|
}
|
|
|
|
|
|
- private void getConfig(String key){
|
|
|
- RequestParams params = httParams(Constant.GET_INFO);
|
|
|
+ private void getConfig(){
|
|
|
+ RequestParams params = httParams(Constant.GET_CONFIG);
|
|
|
+ params.addBodyParameter("configKey", "rms.");
|
|
|
x.http().get(params, new Callback.CommonCallback<JSONObject>() {
|
|
|
@Override
|
|
|
public void onSuccess(JSONObject rs) {
|
|
|
mylog.info(rs);
|
|
|
-// try {
|
|
|
-// if (rs.getInt ("code")== 200) {
|
|
|
-// Constant.user = new Gson().fromJson(rs.getString("user"), UserModel.class);
|
|
|
-// Constant.user.setLoginName(loginName);
|
|
|
-// Constant.user.setLoginPwd(loginPwd);
|
|
|
-// Object userName = Constant.user.getUserName();
|
|
|
-// if (userName != null) {
|
|
|
-// showUser();
|
|
|
-// }
|
|
|
-// }else if(rs.getInt("code") == 401){
|
|
|
-// ToastUtils.showToast(context, "会话过期");
|
|
|
-// logoutAuth(rs.getInt("code"));
|
|
|
-// }else{
|
|
|
-// ToastUtils.showToast(context, rs.getString("msg"));
|
|
|
-// }
|
|
|
-// } catch (JSONException e) {
|
|
|
-// e.printStackTrace();
|
|
|
-// }
|
|
|
+ try{
|
|
|
+ if (rs.getInt("code") == 200) {
|
|
|
+ Type rds = new TypeToken<List<ConfigModel>>() {}.getType();
|
|
|
+ List<ConfigModel> configModels = new Gson().fromJson(rs.get("rows").toString(), rds);
|
|
|
+ setCache(configModels);
|
|
|
+ }else if(rs.getInt("code") == 401){
|
|
|
+ ToastUtils.showToast(context, "会话过期");
|
|
|
+ logoutAuth(rs.getInt("code"));
|
|
|
+ }else{
|
|
|
+ ToastUtils.showToast(context, rs.getString("msg"));
|
|
|
+ }
|
|
|
+ } catch (JSONException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ mylog.error("回调异常:", e);
|
|
|
+ }
|
|
|
}
|
|
|
@Override
|
|
|
public void onError(Throwable ex, boolean isOnCallback) {
|
|
|
@@ -338,6 +343,22 @@ public class HomeActivity extends BaseActivity {
|
|
|
});
|
|
|
}
|
|
|
|
|
|
+ private void setCache(List<ConfigModel> stockModels){
|
|
|
+ stockModels.forEach(item->{
|
|
|
+ String key = item.getConfigKey();
|
|
|
+ String val = item.getConfigValue();
|
|
|
+ if(key.equals(Constant.BOX_KEY)){
|
|
|
+ CacheService.getInstance(context).saveCache(CACHE_BIND_CONFIG, "box_flag", val);
|
|
|
+ }
|
|
|
+ if(key.equals(Constant.IN_STOCK_KEY)){
|
|
|
+ CacheService.getInstance(context).saveCache(CACHE_BIND_CONFIG, "in_stock_flag", val);
|
|
|
+ }
|
|
|
+ if(key.equals(Constant.OUT_STOCK_KEY)){
|
|
|
+ CacheService.getInstance(context).saveCache(CACHE_BIND_CONFIG, "out_stock_flag", val);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
protected String getCommonTopTitle() {
|
|
|
return Res.getString("app_name");
|
|
|
@@ -511,16 +532,6 @@ public class HomeActivity extends BaseActivity {
|
|
|
mainViewAdapter.notifyDataSetChanged();
|
|
|
}
|
|
|
|
|
|
- public void update(){
|
|
|
- UpdateManager updateManager = new UpdateManager(context);
|
|
|
- try {
|
|
|
- updateManager.checkUpdate(context);
|
|
|
- }catch (Exception ex){
|
|
|
- ex.printStackTrace();
|
|
|
- mylog.error("更新检测异常", ex);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
@Subscribe(threadMode = ThreadMode.MAIN, sticky = true, priority = 1)
|
|
|
public void onReceiveMsg(EventMessage message){
|
|
|
if(message.getType() == 1){
|