|  |  | 
 |  |  | package com.doumee.keyCabinet.ui.keyCabinet; | 
 |  |  |  | 
 |  |  | import android.app.Application; | 
 |  |  | import android.text.TextUtils; | 
 |  |  |  | 
 |  |  | import androidx.annotation.NonNull; | 
 |  |  | import androidx.databinding.ObservableField; | 
 |  |  | 
 |  |  |  | 
 |  |  | import com.doumee.keyCabinet.MApplication; | 
 |  |  | import com.doumee.keyCabinet.bean.CabinetDetailBean; | 
 |  |  | import com.doumee.keyCabinet.bean.LoginBean; | 
 |  |  | import com.doumee.keyCabinet.bean.ManageKeyCabinetBean; | 
 |  |  | import com.doumee.keyCabinet.dao.CabinetGridDo; | 
 |  |  | import com.doumee.keyCabinet.event.HttpEvent; | 
 |  |  | import com.doumee.keyCabinet.http.Apis; | 
 |  |  | import com.doumee.keyCabinet.http.param.BaseResponse; | 
 |  |  | import com.doumee.keyCabinet.http.param.BatchOpenGridAdminParam; | 
 |  |  | import com.doumee.keyCabinet.http.param.CancelFaultParam; | 
 |  |  | import com.doumee.keyCabinet.http.param.CloseGridParam; | 
 |  |  | import com.doumee.keyCabinet.http.param.MarkFaultParam; | 
 |  |  | import com.doumee.keyCabinet.http.param.MarkRepairParam; | 
 |  |  | import com.doumee.keyCabinet.utils.ParamsUtil; | 
 |  |  | 
 |  |  | import com.doumee.lib_coremodel.base.DataViewModel; | 
 |  |  | import com.doumee.lib_coremodel.http.rxJava.SimpleObserver; | 
 |  |  | import com.doumee.lib_coremodel.http.utils.RxUtils; | 
 |  |  |  | 
 |  |  | import org.greenrobot.eventbus.EventBus; | 
 |  |  |  | 
 |  |  | import java.util.ArrayList; | 
 |  |  | import java.util.List; | 
 |  |  | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     public void getCabinetDetail(){ | 
 |  |  |         CabinetDetailBean bean = new CabinetDetailBean(); | 
 |  |  |         /*CabinetDetailBean bean = new CabinetDetailBean(); | 
 |  |  |         bean.setGridNum(24); | 
 |  |  |         bean.setOnlineKeyNum(1); | 
 |  |  |         bean.setOutKeyNum(2); | 
 |  |  | 
 |  |  |         b4.setWorkingStatus(1); | 
 |  |  |         b4.setBindStatus(1); | 
 |  |  |  | 
 |  |  |         datasLD.setValue(datas); | 
 |  |  |         datasLD.setValue(datas);*/ | 
 |  |  |  | 
 |  |  |         if(true){ | 
 |  |  |             return; | 
 |  |  |         } | 
 |  |  |         showLoading(true); | 
 |  |  |         getRetrofitService(Apis.class).getCabinetDetail(MApplication.getLoginBean().getToken(), | 
 |  |  |                         MApplication.getConfigBean().getId()) | 
 |  |  | 
 |  |  |                         if(200==response.getCode()){ | 
 |  |  |                             dataOb.set(response.getData()); | 
 |  |  |                             if(response.getData()!=null){ | 
 |  |  |                                 MApplication.getLoginBean().setMemberId(response.getData().getMemberId()); | 
 |  |  |                                 if(response.getData().getCabinetGridInfoVOList()!=null){ | 
 |  |  |                                     datasLD.setValue(response.getData().getCabinetGridInfoVOList()); | 
 |  |  |                                 }else { | 
 |  |  | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     public void batchOpenGridAdmin(List<Integer> gridIdList,boolean isAll){ | 
 |  |  |         if(isAll) { | 
 |  |  |         /*if(isAll) { | 
 |  |  |             doAction(8); | 
 |  |  |         }else { | 
 |  |  |             doAction(10); | 
 |  |  |         } | 
 |  |  |         if(true){ | 
 |  |  |             return; | 
 |  |  |         } | 
 |  |  |         }*/ | 
 |  |  |         showLoading(true); | 
 |  |  |         BatchOpenGridAdminParam param = new BatchOpenGridAdminParam(); | 
 |  |  |         param.setCabinetId(MApplication.getConfigBean().getId()); | 
 |  |  | 
 |  |  |                     @Override | 
 |  |  |                     public void onNext(@NonNull BaseResponse response) { | 
 |  |  |                         if(200==response.getCode()){ | 
 |  |  |                             EventBus.getDefault().post(new HttpEvent("批量开门 - 管理员接口成功")); | 
 |  |  |                             if(isAll) { | 
 |  |  |                                 doAction(8); | 
 |  |  |                             }else { | 
 |  |  | 
 |  |  |                 .subscribe(new SimpleObserver<BaseResponse>(rxJavaGcManager) { | 
 |  |  |                     @Override | 
 |  |  |                     public void onNext(@NonNull BaseResponse response) { | 
 |  |  |                         EventBus.getDefault().post(new HttpEvent("标记柜格正常接口成功")); | 
 |  |  |                         if(200==response.getCode()){ | 
 |  |  |                             getCabinetDetail(); | 
 |  |  |                         }else { | 
 |  |  | 
 |  |  |                     @Override | 
 |  |  |                     public void onNext(@NonNull BaseResponse response) { | 
 |  |  |                         if(200==response.getCode()){ | 
 |  |  |                             EventBus.getDefault().post(new HttpEvent("标记柜格故障接口成功")); | 
 |  |  |                             getCabinetDetail(); | 
 |  |  |                         }else { | 
 |  |  |                             toast(response.getMessage()); | 
 |  |  | 
 |  |  |                     @Override | 
 |  |  |                     public void onNext(@NonNull BaseResponse response) { | 
 |  |  |                         if(200==response.getCode()){ | 
 |  |  |                             EventBus.getDefault().post(new HttpEvent("标记维修保养接口成功")); | 
 |  |  |                             getCabinetDetail(); | 
 |  |  |                         }else { | 
 |  |  |                             toast(response.getMessage()); | 
 |  |  | 
 |  |  |                 }); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |      * 关门 | 
 |  |  |      * @param gridDo | 
 |  |  |      */ | 
 |  |  |     public void closeGrid(CabinetGridDo gridDo){ | 
 |  |  |         CloseGridParam param = new CloseGridParam(); | 
 |  |  |         LoginBean loginBean = MApplication.getLoginBean(); | 
 |  |  |         param.setCabinetId(MApplication.getConfigBean().getId()); | 
 |  |  |         param.setAuthType(loginBean.getAuthType()); | 
 |  |  |         param.setMemberId(loginBean.getMemberId()); | 
 |  |  |         param.setGridId(gridDo.getGridId()); | 
 |  |  |         param.setKeyStatus(!TextUtils.isEmpty(gridDo.getCurKeyCode())?1:2); | 
 |  |  |         toast(gridDo.getGridKey()+"关闭,当前钥匙号:"+gridDo.getCurKeyCode()); | 
 |  |  |         getRetrofitService(Apis.class).closeGrid(ParamsUtil.encodeRequestBody(param)) | 
 |  |  |                 .compose(RxUtils.schedulersTransformer()) | 
 |  |  |                 .subscribe(new SimpleObserver<BaseResponse>(rxJavaGcManager) { | 
 |  |  |                     @Override | 
 |  |  |                     public void onNext(@NonNull BaseResponse response) { | 
 |  |  |                         if(response.getCode()==200){ | 
 |  |  |                             EventBus.getDefault().post(new HttpEvent("关闭柜格接口成功")); | 
 |  |  |                             getCabinetDetail(); | 
 |  |  |                             doAction(11); | 
 |  |  |                         } | 
 |  |  |                     } | 
 |  |  |  | 
 |  |  |                     @Override | 
 |  |  |                     public void onError(@NonNull Throwable e) { | 
 |  |  |  | 
 |  |  |                     } | 
 |  |  |  | 
 |  |  |                     @Override | 
 |  |  |                     public void onComplete() { | 
 |  |  |  | 
 |  |  |                     } | 
 |  |  |                 }); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     public MutableLiveData<List<ManageKeyCabinetBean>> getDatasLD() { | 
 |  |  |         return datasLD; | 
 |  |  |     } |