修改有关于设备相关的接口,入参参数更改
This commit is contained in:
@@ -59,7 +59,7 @@ public class DeviceControlActivity extends BaseActivity<DeviceControlLayoutBindi
|
|||||||
mDeviceEntity = (WaterDeviceEntity) bundle.getSerializable("device_info");
|
mDeviceEntity = (WaterDeviceEntity) bundle.getSerializable("device_info");
|
||||||
if(mDeviceEntity != null){
|
if(mDeviceEntity != null){
|
||||||
showLoadingDialog();
|
showLoadingDialog();
|
||||||
mPresenter.getDeviceDetailInfo(mDeviceEntity.getId());
|
mPresenter.getDeviceDetailInfo(mDeviceEntity.getDeviceNo());
|
||||||
viewBinding.includedTitle.tvTitle.setText(mDeviceEntity.getDeviceName());
|
viewBinding.includedTitle.tvTitle.setText(mDeviceEntity.getDeviceName());
|
||||||
if(mDeviceEntity.getWorkStatus().equals("1")){
|
if(mDeviceEntity.getWorkStatus().equals("1")){
|
||||||
viewBinding.tvDeviceStatus.setText(getString(R.string.device_status_working));
|
viewBinding.tvDeviceStatus.setText(getString(R.string.device_status_working));
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ public class DeviceImpl implements DeviceContract.DataModel{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void getDeviceInfomation(Map<String, String> map, IndexContract.CallBack callBack) {
|
public void getDeviceInfomation(Map<String, String> map, IndexContract.CallBack callBack) {
|
||||||
String deviceID = map.get("id");
|
String deviceID = map.get("deviceNo");
|
||||||
NetWorkManager.getRequest().getDeviceDetailInfo(NetWorkManager.getToken(), deviceID)
|
NetWorkManager.getRequest().getDeviceDetailInfo(NetWorkManager.getToken(), deviceID)
|
||||||
.subscribeOn(Schedulers.io())
|
.subscribeOn(Schedulers.io())
|
||||||
.unsubscribeOn(Schedulers.io())
|
.unsubscribeOn(Schedulers.io())
|
||||||
@@ -132,9 +132,9 @@ public class DeviceImpl implements DeviceContract.DataModel{
|
|||||||
* @param callBack
|
* @param callBack
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void deleteDevice(String devID, IndexContract.CallBack callBack) {
|
public void deleteDevice(String deviceNo, IndexContract.CallBack callBack) {
|
||||||
try {
|
try {
|
||||||
NetWorkManager.getRequest().unBindDevice(NetWorkManager.getToken(), devID)
|
NetWorkManager.getRequest().unBindDevice(NetWorkManager.getToken(), deviceNo)
|
||||||
.subscribeOn(Schedulers.io())
|
.subscribeOn(Schedulers.io())
|
||||||
.unsubscribeOn(Schedulers.io())
|
.unsubscribeOn(Schedulers.io())
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
|
|||||||
@@ -55,11 +55,11 @@ public class DevicePresenter extends BasePresenter<DeviceContract.DeviceView> {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取设备详情信息
|
* 获取设备详情信息
|
||||||
* @param deviceID
|
* @param deviceNo
|
||||||
*/
|
*/
|
||||||
public void getDeviceDetailInfo(String deviceID) {
|
public void getDeviceDetailInfo(String deviceNo) {
|
||||||
Map<String,String> map = new HashMap<>();
|
Map<String,String> map = new HashMap<>();
|
||||||
map.put("id",deviceID);
|
map.put("deviceNo",deviceNo);
|
||||||
impl.getDeviceInfomation(map, new IndexContract.CallBack<WaterDeviceEntity>() {
|
impl.getDeviceInfomation(map, new IndexContract.CallBack<WaterDeviceEntity>() {
|
||||||
@Override
|
@Override
|
||||||
public void success(WaterDeviceEntity bean, int total) {
|
public void success(WaterDeviceEntity bean, int total) {
|
||||||
@@ -84,7 +84,7 @@ public class DevicePresenter extends BasePresenter<DeviceContract.DeviceView> {
|
|||||||
public void updateDeviceInfo(WaterDeviceEntity mDeviceEntity) {
|
public void updateDeviceInfo(WaterDeviceEntity mDeviceEntity) {
|
||||||
try {
|
try {
|
||||||
JSONObject json = new JSONObject();
|
JSONObject json = new JSONObject();
|
||||||
json.put("id",mDeviceEntity.getId());
|
json.put("deviceNo",mDeviceEntity.getDeviceNo());
|
||||||
json.put("deviceName",mDeviceEntity.getDeviceName());
|
json.put("deviceName",mDeviceEntity.getDeviceName());
|
||||||
json.put("wifiName",mDeviceEntity.getWifiName());
|
json.put("wifiName",mDeviceEntity.getWifiName());
|
||||||
json.put("wifiPassword",mDeviceEntity.getWifiPassword());
|
json.put("wifiPassword",mDeviceEntity.getWifiPassword());
|
||||||
@@ -113,7 +113,7 @@ public class DevicePresenter extends BasePresenter<DeviceContract.DeviceView> {
|
|||||||
* @param deviceEntity
|
* @param deviceEntity
|
||||||
*/
|
*/
|
||||||
public void unBindDevice(WaterDeviceEntity deviceEntity) {
|
public void unBindDevice(WaterDeviceEntity deviceEntity) {
|
||||||
impl.deleteDevice(deviceEntity.getId(), new IndexContract.CallBack<BaseBean>() {
|
impl.deleteDevice(deviceEntity.getDeviceNo(), new IndexContract.CallBack<BaseBean>() {
|
||||||
@Override
|
@Override
|
||||||
public void success(BaseBean bean, int total) {
|
public void success(BaseBean bean, int total) {
|
||||||
if (DevicePresenter.this.getView() != null) {
|
if (DevicePresenter.this.getView() != null) {
|
||||||
|
|||||||
@@ -61,8 +61,8 @@ public interface Request {
|
|||||||
@POST("app/v1/addDevice")
|
@POST("app/v1/addDevice")
|
||||||
Observable<BaseBean> addDevice(@HeaderMap Map<String, String> headMap, @Body RequestBody requestBody);
|
Observable<BaseBean> addDevice(@HeaderMap Map<String, String> headMap, @Body RequestBody requestBody);
|
||||||
//获取设备详细信息
|
//获取设备详细信息
|
||||||
@GET("app/v1/device/{id}")
|
@GET("app/v1/device/{deviceNo}")
|
||||||
Observable<BaseBean<WaterDeviceEntity>> getDeviceDetailInfo(@HeaderMap Map<String, String> headMap, @Path("id") String id);
|
Observable<BaseBean<WaterDeviceEntity>> getDeviceDetailInfo(@HeaderMap Map<String, String> headMap, @Path("deviceNo") String id);
|
||||||
|
|
||||||
//开启/关闭设备
|
//开启/关闭设备
|
||||||
@PUT("app/v1/switchDevice")
|
@PUT("app/v1/switchDevice")
|
||||||
@@ -115,8 +115,8 @@ public interface Request {
|
|||||||
|
|
||||||
|
|
||||||
//删除设备
|
//删除设备
|
||||||
@DELETE("app/v1/deleteDevice/{ids}")
|
@DELETE("app/v1/deleteDevice/{deviceNo}")
|
||||||
Observable<BaseBean> unBindDevice(@HeaderMap Map<String,String> headMap, @Path("ids") String id);
|
Observable<BaseBean> unBindDevice(@HeaderMap Map<String,String> headMap, @Path("deviceNo") String id);
|
||||||
|
|
||||||
//排程解绑设备
|
//排程解绑设备
|
||||||
@DELETE("app/v1/deleteScheduleDevice")
|
@DELETE("app/v1/deleteScheduleDevice")
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ public class BindDeviceFragment extends BaseFragment<PlanBindDeviceLayoutBinding
|
|||||||
for(WaterDeviceEntity.DeviceListBean bean : mDeviceList){
|
for(WaterDeviceEntity.DeviceListBean bean : mDeviceList){
|
||||||
if(bean.getStatus().equals("1")){
|
if(bean.getStatus().equals("1")){
|
||||||
isSelected = true;
|
isSelected = true;
|
||||||
selected.add(bean.getId());
|
selected.add(bean.getDeviceNo());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(!isSelected){
|
if(!isSelected){
|
||||||
|
|||||||
@@ -32,12 +32,12 @@ public class PlanBoundDeviceFragment extends BaseFragment<PlanBoundDeviceLayoutB
|
|||||||
@Override
|
@Override
|
||||||
public void initData(Bundle state) {
|
public void initData(Bundle state) {
|
||||||
// 初始化适配器,如果有数据则设置
|
// 初始化适配器,如果有数据则设置
|
||||||
if (mEditEntity != null && mEditEntity.getDeviceIds() != null) {
|
if (mEditEntity != null && mEditEntity.getDeviceNos() != null) {
|
||||||
mAdapter = new PlanBoundDeviceAdapter(mContext, R.layout.plan_bound_device_item, mEditEntity.getDeviceIds());
|
mAdapter = new PlanBoundDeviceAdapter(mContext, R.layout.plan_bound_device_item, mEditEntity.getDeviceNos());
|
||||||
viewBinding.rvDevices.setAdapter(mAdapter);
|
viewBinding.rvDevices.setAdapter(mAdapter);
|
||||||
|
|
||||||
// 根据数据状态显示/隐藏视图
|
// 根据数据状态显示/隐藏视图
|
||||||
if (mEditEntity.getDeviceIds().isEmpty()) {
|
if (mEditEntity.getDeviceNos().isEmpty()) {
|
||||||
viewBinding.linearContent.setVisibility(View.GONE);
|
viewBinding.linearContent.setVisibility(View.GONE);
|
||||||
viewBinding.relNoresult.setVisibility(View.VISIBLE);
|
viewBinding.relNoresult.setVisibility(View.VISIBLE);
|
||||||
} else {
|
} else {
|
||||||
@@ -66,7 +66,7 @@ public class PlanBoundDeviceFragment extends BaseFragment<PlanBoundDeviceLayoutB
|
|||||||
public void onConfirmClick() {
|
public void onConfirmClick() {
|
||||||
showLoadingDialog();
|
showLoadingDialog();
|
||||||
mPresenter.planUnbindDevice(mEditEntity.getId(),
|
mPresenter.planUnbindDevice(mEditEntity.getId(),
|
||||||
mEditEntity.getDeviceIds().get(position).getId(),
|
mEditEntity.getDeviceNos().get(position).getDeviceNo(),
|
||||||
position);
|
position);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -94,20 +94,20 @@ public class PlanBoundDeviceFragment extends BaseFragment<PlanBoundDeviceLayoutB
|
|||||||
if (viewBinding == null) {
|
if (viewBinding == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (mEditEntity == null || mEditEntity.getDeviceIds() == null) {
|
if (mEditEntity == null || mEditEntity.getDeviceNos() == null) {
|
||||||
viewBinding.linearContent.setVisibility(View.GONE);
|
viewBinding.linearContent.setVisibility(View.GONE);
|
||||||
viewBinding.relNoresult.setVisibility(View.VISIBLE);
|
viewBinding.relNoresult.setVisibility(View.VISIBLE);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mEditEntity.getDeviceIds().isEmpty()) {
|
if (mEditEntity.getDeviceNos().isEmpty()) {
|
||||||
viewBinding.linearContent.setVisibility(View.GONE);
|
viewBinding.linearContent.setVisibility(View.GONE);
|
||||||
viewBinding.relNoresult.setVisibility(View.VISIBLE);
|
viewBinding.relNoresult.setVisibility(View.VISIBLE);
|
||||||
} else {
|
} else {
|
||||||
viewBinding.linearContent.setVisibility(View.VISIBLE);
|
viewBinding.linearContent.setVisibility(View.VISIBLE);
|
||||||
viewBinding.relNoresult.setVisibility(View.GONE);
|
viewBinding.relNoresult.setVisibility(View.GONE);
|
||||||
if (mAdapter != null) {
|
if (mAdapter != null) {
|
||||||
mAdapter.setNewData(mEditEntity.getDeviceIds());
|
mAdapter.setNewData(mEditEntity.getDeviceNos());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -166,7 +166,7 @@ public class PlanBoundDeviceFragment extends BaseFragment<PlanBoundDeviceLayoutB
|
|||||||
hideDialogLoading();
|
hideDialogLoading();
|
||||||
ToastUtil.showShort(mContext, "解绑成功");
|
ToastUtil.showShort(mContext, "解绑成功");
|
||||||
mAdapter.notifyItemRemoved(position);
|
mAdapter.notifyItemRemoved(position);
|
||||||
mEditEntity.getDeviceIds().remove(position);
|
mEditEntity.getDeviceNos().remove(position);
|
||||||
if (mAdapter.getItemCount() != 0) {
|
if (mAdapter.getItemCount() != 0) {
|
||||||
viewBinding.relNoresult.setVisibility(View.GONE);
|
viewBinding.relNoresult.setVisibility(View.GONE);
|
||||||
viewBinding.linearContent.setVisibility(View.VISIBLE);
|
viewBinding.linearContent.setVisibility(View.VISIBLE);
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ public class WaterPlanWeekEntity implements Serializable {
|
|||||||
private String userId;
|
private String userId;
|
||||||
private String name;
|
private String name;
|
||||||
private List<WaterDeviceEntity> deviceIds;
|
private List<WaterDeviceEntity> deviceIds;
|
||||||
|
private List<WaterDeviceEntity> deviceNos;
|
||||||
private String status = "1";
|
private String status = "1";
|
||||||
private List<DetailsBean> details;
|
private List<DetailsBean> details;
|
||||||
|
|
||||||
|
|||||||
@@ -195,19 +195,19 @@ public class WaterPlanPresenter extends BasePresenter<WaterPlanContract.WaterPla
|
|||||||
/**
|
/**
|
||||||
* 排程绑定设备
|
* 排程绑定设备
|
||||||
* @param entity
|
* @param entity
|
||||||
* @param deviceIds
|
* @param deviceNo
|
||||||
*/
|
*/
|
||||||
public void planBindWithDevices(WaterPlanWeekEntity entity, String deviceIds) {
|
public void planBindWithDevices(WaterPlanWeekEntity entity, String deviceNo) {
|
||||||
try {
|
try {
|
||||||
JSONObject json = new JSONObject();
|
JSONObject json = new JSONObject();
|
||||||
json.put("scheduleId", entity.getId());
|
json.put("scheduleId", entity.getId());
|
||||||
// 将逗号分隔的字符串转换为 JSONArray (数字类型)
|
// 将逗号分隔的字符串转换为 JSONArray (数字类型)
|
||||||
JSONArray deviceIdArray = new JSONArray();
|
JSONArray deviceIdArray = new JSONArray();
|
||||||
String[] idArray = deviceIds.split(",");
|
String[] idArray = deviceNo.split(",");
|
||||||
for (String id : idArray) {
|
for (String id : idArray) {
|
||||||
deviceIdArray.put(id);
|
deviceIdArray.put(id);
|
||||||
}
|
}
|
||||||
json.put("deviceIds", deviceIdArray);
|
json.put("deviceNos", deviceIdArray);
|
||||||
impl.planBindDevice(json, new WaterPlanContract.CallBack<BaseBean>() {
|
impl.planBindDevice(json, new WaterPlanContract.CallBack<BaseBean>() {
|
||||||
@Override
|
@Override
|
||||||
public void success(BaseBean bean, int total) {
|
public void success(BaseBean bean, int total) {
|
||||||
@@ -288,7 +288,7 @@ public class WaterPlanPresenter extends BasePresenter<WaterPlanContract.WaterPla
|
|||||||
public void planUnbindDevice(String planID, String deviceID,int position) {
|
public void planUnbindDevice(String planID, String deviceID,int position) {
|
||||||
Map<String,String> map = new HashMap<>();
|
Map<String,String> map = new HashMap<>();
|
||||||
map.put("scheduleId",planID);
|
map.put("scheduleId",planID);
|
||||||
map.put("deviceId",deviceID);
|
map.put("deviceNo",deviceID);
|
||||||
impl.planUnbindDevice(map, new WaterPlanContract.CallBack<BaseBean>() {
|
impl.planUnbindDevice(map, new WaterPlanContract.CallBack<BaseBean>() {
|
||||||
@Override
|
@Override
|
||||||
public void success(BaseBean bean, int total) {
|
public void success(BaseBean bean, int total) {
|
||||||
|
|||||||
Reference in New Issue
Block a user