mirror of
https://gitee.com/beecue/fastbee.git
synced 2025-12-17 16:36:03 +08:00
前端添加设备功能
This commit is contained in:
@@ -201,7 +201,7 @@ public class DeviceEditFragment extends BaseFragment {
|
||||
txt_device_category.setText(device.getCategoryName());
|
||||
txt_firmware_version.setText("v"+device.getFirmwareVersion());
|
||||
txt_create_time.setText(device.getCreateTime());
|
||||
sp_device_temperature.setText(device.getDeviceTemp()+"℃");
|
||||
sp_device_temperature.setText(device.getDeviceTemp()==null?0+"℃":device.getDeviceTemp()+"℃");
|
||||
}
|
||||
@Override
|
||||
public void onError(ApiException e) {
|
||||
|
||||
@@ -160,7 +160,7 @@ public class SimpleTabFragment extends BaseFragment {
|
||||
// cardViewParams.width=(widthPixels-space)/2;
|
||||
|
||||
holder.text(R.id.device_item_title, device.getDeviceName());
|
||||
holder.text(R.id.device_item_temp, device.getDeviceTemperature()+"℃");
|
||||
holder.text(R.id.device_item_temp, device.getDeviceTemperature()==null? 0+"℃":device.getDeviceTemperature()+"℃");
|
||||
holder.text(R.id.device_item_category, device.getCategoryName());
|
||||
|
||||
//状态图标
|
||||
@@ -168,13 +168,14 @@ public class SimpleTabFragment extends BaseFragment {
|
||||
SwitchIconView alarmView=holder.findViewById(R.id.device_item_alarm_icon);
|
||||
SwitchIconView switchIconView=holder.findViewById(R.id.device_item_switch_button);
|
||||
SwitchIconView lightIconView=holder.findViewById(R.id.device_item_light_button);
|
||||
radarView.setIconEnabled(device.getIsRadar()==1 && device.getIsOnline()==1?true:false);
|
||||
alarmView.setIconEnabled(device.getIsAlarm()==1 && device.getIsOnline()==1?true:false);
|
||||
switchIconView.setIconEnabled(device.getRelayStatus()==1 && device.getIsOnline()==1?true:false);
|
||||
lightIconView.setIconEnabled(device.getLightStatus()==1 && device.getIsOnline()==1?true:false);
|
||||
radarView.setIconEnabled(device.getIsRadar()!=null && device.getIsRadar()==1 && device.getIsOnline()==1?true:false);
|
||||
alarmView.setIconEnabled(device.getIsAlarm()!=null && device.getIsAlarm()==1 && device.getIsOnline()==1?true:false);
|
||||
switchIconView.setIconEnabled(device.getRelayStatus()!=null && device.getRelayStatus()==1 && device.getIsOnline()==1?true:false);
|
||||
lightIconView.setIconEnabled(device.getLightStatus()!=null && device.getLightStatus()==1 && device.getIsOnline()==1?true:false);
|
||||
|
||||
//显示网络信号:wifi信号强度(信号极好4格[-55—— 0],信号好3格[-70—— -55),信号一般2格[-85—— -70),信号差1格[-100—— -85))
|
||||
AppCompatImageView wifiView=holder.findViewById(R.id.device_item_wifi_icon);
|
||||
if(device.getIsOnline()!=null && device.getRssi()!=null) {
|
||||
if (device.getIsOnline() == 1 && device.getRssi() >= -55) {
|
||||
wifiView.setImageDrawable(getResources().getDrawable((R.drawable.wifi_4)));
|
||||
} else if (device.getIsOnline() == 1 && device.getRssi() >= 70) {
|
||||
@@ -183,13 +184,12 @@ public class SimpleTabFragment extends BaseFragment {
|
||||
wifiView.setImageDrawable(getResources().getDrawable((R.drawable.wifi_2)));
|
||||
} else if (device.getIsOnline() == 1 && device.getRssi() >= -100) {
|
||||
wifiView.setImageDrawable(getResources().getDrawable((R.drawable.wifi_1)));
|
||||
}else{
|
||||
wifiView.setImageDrawable(getResources().getDrawable((R.drawable.wifi_0)));
|
||||
}
|
||||
}
|
||||
|
||||
//其他文字、标题和图片
|
||||
FrameLayout flTitle=holder.findViewById(R.id.device_item_fl_title);
|
||||
if(device.getIsOnline()==1){
|
||||
if(device.getIsOnline()!=null && device.getIsOnline()==1){
|
||||
holder.text(R.id.device_item_wifi, "在线");
|
||||
flTitle.setBackgroundColor(Color.argb(255, 63, 208, 173));
|
||||
}else{
|
||||
|
||||
@@ -124,7 +124,7 @@
|
||||
android:layout_width="@dimen/config_margin_14dp"
|
||||
android:layout_height="@dimen/config_margin_14dp"
|
||||
android:layout_gravity="bottom"
|
||||
app:srcCompat="@drawable/wifi_2" />
|
||||
app:srcCompat="@drawable/wifi_0" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/device_item_wifi"
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
******************************************************************************/
|
||||
package com.ruoyi.system.controller;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
import com.ruoyi.common.core.domain.model.LoginUser;
|
||||
@@ -112,6 +113,9 @@ public class IotDeviceController extends BaseController
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody IotDevice iotDevice)
|
||||
{
|
||||
LoginUser user=(LoginUser)SecurityContextHolder.getContext().getAuthentication().getPrincipal();
|
||||
iotDevice.setOwnerId(user.getUser().getUserId().toString());
|
||||
iotDevice.setDeviceTemp(BigDecimal.valueOf(0));
|
||||
return toAjax(iotDeviceService.insertIotDevice(iotDevice));
|
||||
}
|
||||
|
||||
|
||||
@@ -115,11 +115,18 @@ public class IotDeviceSetController extends BaseController
|
||||
set.setDeviceId(device.getDeviceId());
|
||||
set.setDeviceNum(device.getDeviceNum());
|
||||
set.setOwnerId(device.getOwnerId());
|
||||
set.setIsRadar(0);
|
||||
set.setIsAlarm(0);
|
||||
set.setRadarInterval(5);
|
||||
set.setIsRfControl(0);
|
||||
set.setIsRfLearn(0);
|
||||
set.setRfOneFunc(1);
|
||||
set.setRfTwoFunc(2);
|
||||
set.setRfThreeFunc(3);
|
||||
set.setRfFourFunc(4);
|
||||
set.setIsRfClear(0);
|
||||
set.setIsAp(0);
|
||||
set.setIsReset(0);
|
||||
}
|
||||
}
|
||||
return AjaxResult.success(set);
|
||||
@@ -147,11 +154,11 @@ public class IotDeviceSetController extends BaseController
|
||||
public AjaxResult edit(@RequestBody IotDeviceSet iotDeviceSet)
|
||||
{
|
||||
IotDeviceStatus status=iotDeviceStatusService.selectIotDeviceStatusByDeviceId(iotDeviceSet.getDeviceId());
|
||||
if(status.getIsOnline()!=1){return AjaxResult.error("设备已离线,不能更新配置。");}
|
||||
if(status==null || status.getIsOnline()==0){return AjaxResult.error("设备已离线,不能更新状态。");}
|
||||
// 存储
|
||||
iotDeviceSetService.updateIotDeviceSet(iotDeviceSet);
|
||||
|
||||
//
|
||||
//mqtt发布
|
||||
IotDeviceSet set=iotDeviceSetService.selectIotDeviceSetByDeviceId(iotDeviceSet.getDeviceId());
|
||||
if(iotDeviceSet.getIsRadar()!=null){
|
||||
set.setIsRadar(iotDeviceSet.getIsRadar());
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
******************************************************************************/
|
||||
package com.ruoyi.system.controller;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
@@ -121,12 +122,18 @@ public class IotDeviceStatusController extends BaseController
|
||||
status=new IotDeviceStatus();
|
||||
status.setDeviceId(device.getDeviceId());
|
||||
status.setDeviceNum(device.getDeviceNum());
|
||||
status.setRelayStatus(0);
|
||||
status.setLightStatus(0);
|
||||
status.setLightMode(0);
|
||||
status.setBrightness(100);
|
||||
status.setLightInterval(500);
|
||||
status.setFadeTime(300);
|
||||
status.setRed(255L);
|
||||
status.setBlue(255L);
|
||||
status.setGreen(255L);
|
||||
status.setAirTemperature(BigDecimal.valueOf(0));
|
||||
status.setAirHumidity(BigDecimal.valueOf(0));
|
||||
status.setDeviceTemperature(BigDecimal.valueOf(0));
|
||||
}
|
||||
}
|
||||
return AjaxResult.success(status);
|
||||
@@ -154,7 +161,7 @@ public class IotDeviceStatusController extends BaseController
|
||||
public AjaxResult edit(@RequestBody IotDeviceStatus iotDeviceStatus)
|
||||
{
|
||||
IotDeviceStatus status=iotDeviceStatusService.selectIotDeviceStatusByDeviceId(iotDeviceStatus.getDeviceId());
|
||||
if(status.getIsOnline()!=1){return AjaxResult.error("设备已离线,不能更新状态。");}
|
||||
if(status==null || status.getIsOnline()==0){return AjaxResult.error("设备已离线,不能更新状态。");}
|
||||
// 存储
|
||||
iotDeviceStatusService.updateIotDeviceStatus(iotDeviceStatus);
|
||||
|
||||
|
||||
@@ -94,7 +94,7 @@
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
<!-- <el-row :gutter="10" class="mb8">
|
||||
<el-row :gutter="10" class="mb8">
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="primary"
|
||||
@@ -138,7 +138,7 @@
|
||||
>导出</el-button>
|
||||
</el-col>
|
||||
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
||||
</el-row> -->
|
||||
</el-row>
|
||||
|
||||
<el-table
|
||||
v-loading="loading"
|
||||
@@ -147,7 +147,7 @@
|
||||
border
|
||||
:row-class-name="tableRowClassName"
|
||||
>
|
||||
<!-- <el-table-column type="selection" width="45" align="center" /> -->
|
||||
<el-table-column type="selection" width="45" align="center" />
|
||||
<el-table-column label="序号" width="50" align="center" prop="deviceId" />
|
||||
<el-table-column label="编号" align="center" prop="deviceNum" />
|
||||
<el-table-column label="名称" align="center" prop="deviceName" />
|
||||
@@ -286,14 +286,11 @@
|
||||
<el-input
|
||||
v-model="form.deviceNum"
|
||||
placeholder="请输入编号"
|
||||
:disabled="true"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="分类" prop="categoryId">
|
||||
<el-select
|
||||
v-model="form.categoryId"
|
||||
placeholder="请选择分类"
|
||||
:disabled="true"
|
||||
>
|
||||
<el-option
|
||||
v-for="category in categoryList"
|
||||
@@ -307,7 +304,6 @@
|
||||
<el-input
|
||||
v-model="form.firmwareVersion"
|
||||
placeholder="请输入固件版本"
|
||||
:disabled="true"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="名称" prop="deviceName">
|
||||
@@ -541,7 +537,7 @@
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="11" offset="1">
|
||||
<el-col :span="11" :offset="1">
|
||||
<el-form-item label="按键二" prop="rfTwoFunc">
|
||||
<el-select v-model="setForm.rfTwoFunc" placeholder="请选择按键二">
|
||||
<el-option
|
||||
@@ -565,7 +561,7 @@
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="11" offset="1">
|
||||
<el-col :span="11" :offset="1">
|
||||
<el-form-item label="按键四" prop="rfFourFunc">
|
||||
<el-select v-model="setForm.rfFourFunc" placeholder="请选择按键四">
|
||||
<el-option
|
||||
|
||||
Reference in New Issue
Block a user