mirror of
https://github.com/niushuai233/DevControl.git
synced 2024-10-27 22:43:20 +08:00
style: 代码格式化
This commit is contained in:
parent
3f376200e5
commit
1968904318
@ -7,8 +7,6 @@ import androidx.navigation.NavController;
|
|||||||
import androidx.navigation.Navigation;
|
import androidx.navigation.Navigation;
|
||||||
import androidx.navigation.ui.NavigationUI;
|
import androidx.navigation.ui.NavigationUI;
|
||||||
|
|
||||||
import com.google.android.material.bottomnavigation.BottomNavigationView;
|
|
||||||
|
|
||||||
import cc.niushuai.project.devcontrol.base.App;
|
import cc.niushuai.project.devcontrol.base.App;
|
||||||
import cc.niushuai.project.devcontrol.databinding.ActivityMainBinding;
|
import cc.niushuai.project.devcontrol.databinding.ActivityMainBinding;
|
||||||
|
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
package cc.niushuai.project.devcontrol.base.enums;
|
package cc.niushuai.project.devcontrol.base.enums;
|
||||||
|
|
||||||
import android.widget.TextView;
|
|
||||||
|
|
||||||
import cc.niushuai.project.devcontrol.R;
|
import cc.niushuai.project.devcontrol.R;
|
||||||
import cc.niushuai.project.devcontrol.base.ui.BaseActivity;
|
import cc.niushuai.project.devcontrol.base.ui.BaseActivity;
|
||||||
import cc.niushuai.project.devcontrol.ui.custom.DeviceCustomActivity;
|
import cc.niushuai.project.devcontrol.ui.custom.DeviceCustomActivity;
|
||||||
|
@ -14,14 +14,6 @@ public enum OnOffEnum {
|
|||||||
this.text = text;
|
this.text = text;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getValue() {
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getText() {
|
|
||||||
return text;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static OnOffEnum matchByValue(String value) {
|
public static OnOffEnum matchByValue(String value) {
|
||||||
for (OnOffEnum onOffEnum : OnOffEnum.values()) {
|
for (OnOffEnum onOffEnum : OnOffEnum.values()) {
|
||||||
if (onOffEnum.getValue().equals(value)) {
|
if (onOffEnum.getValue().equals(value)) {
|
||||||
@ -30,4 +22,12 @@ public enum OnOffEnum {
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getValue() {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getText() {
|
||||||
|
return text;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,15 @@ public enum YesNoEnum {
|
|||||||
this.text = text;
|
this.text = text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static YesNoEnum matchByValue(String value) {
|
||||||
|
for (YesNoEnum onOffEnum : YesNoEnum.values()) {
|
||||||
|
if (onOffEnum.getValue().equals(value)) {
|
||||||
|
return onOffEnum;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
public String getValue() {
|
public String getValue() {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
@ -27,13 +36,4 @@ public enum YesNoEnum {
|
|||||||
public String getText() {
|
public String getText() {
|
||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static YesNoEnum matchByValue(String value) {
|
|
||||||
for (YesNoEnum onOffEnum : YesNoEnum.values()) {
|
|
||||||
if (onOffEnum.getValue().equals(value)) {
|
|
||||||
return onOffEnum;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -9,11 +9,11 @@ import androidx.appcompat.widget.AppCompatImageButton;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import cc.niushuai.project.devcontrol.R;
|
import cc.niushuai.project.devcontrol.R;
|
||||||
import cc.niushuai.project.devcontrol.base.util.GlobalVariables;
|
|
||||||
import cc.niushuai.project.devcontrol.vo.DeviceInfo;
|
|
||||||
import cc.niushuai.project.devcontrol.base.util.ActivityUtil;
|
import cc.niushuai.project.devcontrol.base.util.ActivityUtil;
|
||||||
|
import cc.niushuai.project.devcontrol.base.util.GlobalVariables;
|
||||||
import cc.niushuai.project.devcontrol.base.util.Keys;
|
import cc.niushuai.project.devcontrol.base.util.Keys;
|
||||||
import cc.niushuai.project.devcontrol.base.util.UiUtil;
|
import cc.niushuai.project.devcontrol.base.util.UiUtil;
|
||||||
|
import cc.niushuai.project.devcontrol.vo.DeviceInfo;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -2,7 +2,6 @@ package cc.niushuai.project.devcontrol.base.util;
|
|||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -4,10 +4,10 @@ import java.util.HashMap;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import cc.niushuai.project.devcontrol.base.ui.BaseActivity;
|
||||||
import cc.niushuai.project.devcontrol.db.DB;
|
import cc.niushuai.project.devcontrol.db.DB;
|
||||||
import cc.niushuai.project.devcontrol.db.entity.Device;
|
import cc.niushuai.project.devcontrol.db.entity.Device;
|
||||||
import cc.niushuai.project.devcontrol.vo.DeviceInfo;
|
import cc.niushuai.project.devcontrol.vo.DeviceInfo;
|
||||||
import cc.niushuai.project.devcontrol.base.ui.BaseActivity;
|
|
||||||
|
|
||||||
public class GlobalVariables {
|
public class GlobalVariables {
|
||||||
|
|
||||||
@ -35,6 +35,7 @@ public class GlobalVariables {
|
|||||||
public static Class<? extends BaseActivity> getDeviceAddActivity(String deviceId) {
|
public static Class<? extends BaseActivity> getDeviceAddActivity(String deviceId) {
|
||||||
return getDeviceInfo(deviceId).getDeviceType().getDeviceAddActivity();
|
return getDeviceInfo(deviceId).getDeviceType().getDeviceAddActivity();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Class<? extends BaseActivity> getDeviceOperateActivity(String deviceId) {
|
public static Class<? extends BaseActivity> getDeviceOperateActivity(String deviceId) {
|
||||||
return getDeviceInfo(deviceId).getDeviceType().getDeviceOperateActivity();
|
return getDeviceInfo(deviceId).getDeviceType().getDeviceOperateActivity();
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,26 @@ public class IdWorker {
|
|||||||
private long datacenterId; //数据id
|
private long datacenterId; //数据id
|
||||||
//12位的序列号
|
//12位的序列号
|
||||||
private long sequence;
|
private long sequence;
|
||||||
|
//初始时间戳
|
||||||
|
private long twepoch = 1288834974657L;
|
||||||
|
//长度为5位
|
||||||
|
private long workerIdBits = 5L;
|
||||||
|
private long datacenterIdBits = 5L;
|
||||||
|
//最大值
|
||||||
|
private long maxWorkerId = -1L ^ (-1L << workerIdBits);
|
||||||
|
private long maxDatacenterId = -1L ^ (-1L << datacenterIdBits);
|
||||||
|
//序列号id长度
|
||||||
|
private long sequenceBits = 12L;
|
||||||
|
//序列号最大值
|
||||||
|
private long sequenceMask = -1L ^ (-1L << sequenceBits);
|
||||||
|
//工作id需要左移的位数,12位
|
||||||
|
private long workerIdShift = sequenceBits;
|
||||||
|
//数据id需要左移位数 12+5=17位
|
||||||
|
private long datacenterIdShift = sequenceBits + workerIdBits;
|
||||||
|
//时间戳需要左移位数 12+5+5=22位
|
||||||
|
private long timestampLeftShift = sequenceBits + workerIdBits + datacenterIdBits;
|
||||||
|
//上次时间戳,初始值为负数
|
||||||
|
private long lastTimestamp = -1L;
|
||||||
|
|
||||||
public IdWorker(long workerId, long datacenterId, long sequence) {
|
public IdWorker(long workerId, long datacenterId, long sequence) {
|
||||||
// sanity check for workerId
|
// sanity check for workerId
|
||||||
@ -26,29 +46,21 @@ public class IdWorker {
|
|||||||
this.sequence = sequence;
|
this.sequence = sequence;
|
||||||
}
|
}
|
||||||
|
|
||||||
//初始时间戳
|
//---------------测试---------------
|
||||||
private long twepoch = 1288834974657L;
|
public static void main(String[] args) {
|
||||||
|
IdWorker worker = new IdWorker(1, 1, 1);
|
||||||
|
for (int i = 0; i < 30; i++) {
|
||||||
|
System.out.println(worker.nextId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//长度为5位
|
public static long getNextId() {
|
||||||
private long workerIdBits = 5L;
|
return INSTANCE.nextId();
|
||||||
private long datacenterIdBits = 5L;
|
}
|
||||||
//最大值
|
|
||||||
private long maxWorkerId = -1L ^ (-1L << workerIdBits);
|
|
||||||
private long maxDatacenterId = -1L ^ (-1L << datacenterIdBits);
|
|
||||||
//序列号id长度
|
|
||||||
private long sequenceBits = 12L;
|
|
||||||
//序列号最大值
|
|
||||||
private long sequenceMask = -1L ^ (-1L << sequenceBits);
|
|
||||||
|
|
||||||
//工作id需要左移的位数,12位
|
public static String getNextIdStr() {
|
||||||
private long workerIdShift = sequenceBits;
|
return getNextId() + "";
|
||||||
//数据id需要左移位数 12+5=17位
|
}
|
||||||
private long datacenterIdShift = sequenceBits + workerIdBits;
|
|
||||||
//时间戳需要左移位数 12+5+5=22位
|
|
||||||
private long timestampLeftShift = sequenceBits + workerIdBits + datacenterIdBits;
|
|
||||||
|
|
||||||
//上次时间戳,初始值为负数
|
|
||||||
private long lastTimestamp = -1L;
|
|
||||||
|
|
||||||
public long getWorkerId() {
|
public long getWorkerId() {
|
||||||
return workerId;
|
return workerId;
|
||||||
@ -113,20 +125,4 @@ public class IdWorker {
|
|||||||
private long timeGen() {
|
private long timeGen() {
|
||||||
return System.currentTimeMillis();
|
return System.currentTimeMillis();
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------测试---------------
|
|
||||||
public static void main(String[] args) {
|
|
||||||
IdWorker worker = new IdWorker(1, 1, 1);
|
|
||||||
for (int i = 0; i < 30; i++) {
|
|
||||||
System.out.println(worker.nextId());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static long getNextId() {
|
|
||||||
return INSTANCE.nextId();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String getNextIdStr() {
|
|
||||||
return getNextId() + "";
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -4,7 +4,6 @@ import android.app.Activity;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
import android.util.TypedValue;
|
import android.util.TypedValue;
|
||||||
import android.view.View;
|
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
@ -19,7 +19,10 @@ public class DB {
|
|||||||
private static boolean INIT_FLAG = false;
|
private static boolean INIT_FLAG = false;
|
||||||
|
|
||||||
private static DB db;
|
private static DB db;
|
||||||
|
private Context context;
|
||||||
|
private DaoMaster.OpenHelper openHelper;
|
||||||
|
private DaoMaster daoMaster;
|
||||||
|
private DaoSession daoSession;
|
||||||
private DB() {
|
private DB() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -30,10 +33,27 @@ public class DB {
|
|||||||
return db;
|
return db;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Context context;
|
/**
|
||||||
private DaoMaster.OpenHelper openHelper;
|
* daoSession 对外暴漏入口
|
||||||
private DaoMaster daoMaster;
|
*
|
||||||
private DaoSession daoSession;
|
* @author niushuai
|
||||||
|
* @date: 2022/10/24 11:04
|
||||||
|
* @return: {@link DaoSession}
|
||||||
|
*/
|
||||||
|
public static DaoSession session() {
|
||||||
|
return DB.getInstance().getDaoSession();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备操作入口
|
||||||
|
*
|
||||||
|
* @author niushuai
|
||||||
|
* @date: 2022/10/24 11:05
|
||||||
|
* @return: {@link DeviceDao}
|
||||||
|
*/
|
||||||
|
public static DeviceDao getDeviceDao() {
|
||||||
|
return session().getDeviceDao();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 初始化数据库表结构
|
* 初始化数据库表结构
|
||||||
@ -80,26 +100,4 @@ public class DB {
|
|||||||
}
|
}
|
||||||
return daoSession;
|
return daoSession;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* daoSession 对外暴漏入口
|
|
||||||
*
|
|
||||||
* @author niushuai
|
|
||||||
* @date: 2022/10/24 11:04
|
|
||||||
* @return: {@link DaoSession}
|
|
||||||
*/
|
|
||||||
public static DaoSession session() {
|
|
||||||
return DB.getInstance().getDaoSession();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 设备操作入口
|
|
||||||
*
|
|
||||||
* @author niushuai
|
|
||||||
* @date: 2022/10/24 11:05
|
|
||||||
* @return: {@link DeviceDao}
|
|
||||||
*/
|
|
||||||
public static DeviceDao getDeviceDao() {
|
|
||||||
return session().getDeviceDao();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
package cc.niushuai.project.devcontrol.db.entity;
|
package cc.niushuai.project.devcontrol.db.entity;
|
||||||
|
|
||||||
import org.greenrobot.greendao.annotation.Entity;
|
import org.greenrobot.greendao.annotation.Entity;
|
||||||
import org.greenrobot.greendao.annotation.Id;
|
|
||||||
import org.greenrobot.greendao.annotation.Generated;
|
import org.greenrobot.greendao.annotation.Generated;
|
||||||
|
import org.greenrobot.greendao.annotation.Id;
|
||||||
import org.greenrobot.greendao.annotation.Index;
|
import org.greenrobot.greendao.annotation.Index;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package cc.niushuai.project.devcontrol.db.entity;
|
package cc.niushuai.project.devcontrol.db.entity;
|
||||||
|
|
||||||
import org.greenrobot.greendao.annotation.Entity;
|
import org.greenrobot.greendao.annotation.Entity;
|
||||||
|
|
||||||
import org.greenrobot.greendao.annotation.Generated;
|
import org.greenrobot.greendao.annotation.Generated;
|
||||||
import org.greenrobot.greendao.annotation.Id;
|
import org.greenrobot.greendao.annotation.Id;
|
||||||
|
|
||||||
|
@ -3,29 +3,22 @@ package cc.niushuai.project.devcontrol.ui.deviceadd;
|
|||||||
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.TextView;
|
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
|
||||||
|
|
||||||
import cc.niushuai.project.devcontrol.R;
|
import cc.niushuai.project.devcontrol.R;
|
||||||
import cc.niushuai.project.devcontrol.base.enums.YesNoEnum;
|
|
||||||
import cc.niushuai.project.devcontrol.base.util.CommonUiUtil;
|
|
||||||
import cc.niushuai.project.devcontrol.base.util.IdWorker;
|
|
||||||
import cc.niushuai.project.devcontrol.base.util.UiUtil;
|
|
||||||
import cc.niushuai.project.devcontrol.db.DB;
|
|
||||||
import cc.niushuai.project.devcontrol.db.entity.Device;
|
|
||||||
import cc.niushuai.project.devcontrol.vo.DeviceInfo;
|
|
||||||
import cc.niushuai.project.devcontrol.base.enums.DeviceTypeEnum;
|
import cc.niushuai.project.devcontrol.base.enums.DeviceTypeEnum;
|
||||||
import cc.niushuai.project.devcontrol.base.enums.OnOffEnum;
|
import cc.niushuai.project.devcontrol.base.enums.OnOffEnum;
|
||||||
|
import cc.niushuai.project.devcontrol.base.enums.YesNoEnum;
|
||||||
import cc.niushuai.project.devcontrol.base.ui.BaseActivity;
|
import cc.niushuai.project.devcontrol.base.ui.BaseActivity;
|
||||||
import cc.niushuai.project.devcontrol.base.util.ActivityUtil;
|
import cc.niushuai.project.devcontrol.base.util.ActivityUtil;
|
||||||
import cc.niushuai.project.devcontrol.base.util.GlobalVariables;
|
import cc.niushuai.project.devcontrol.base.util.CommonUiUtil;
|
||||||
|
import cc.niushuai.project.devcontrol.base.util.IdWorker;
|
||||||
import cc.niushuai.project.devcontrol.base.util.Keys;
|
import cc.niushuai.project.devcontrol.base.util.Keys;
|
||||||
import cc.niushuai.project.devcontrol.base.util.ToastUtil;
|
import cc.niushuai.project.devcontrol.base.util.ToastUtil;
|
||||||
import cc.niushuai.project.devcontrol.databinding.ActivityDeviceAddPowerSwitchBinding;
|
import cc.niushuai.project.devcontrol.databinding.ActivityDeviceAddPowerSwitchBinding;
|
||||||
|
import cc.niushuai.project.devcontrol.db.DB;
|
||||||
|
import cc.niushuai.project.devcontrol.db.entity.Device;
|
||||||
import cc.niushuai.project.devcontrol.ui.powerswitch.PowerSwitchActivity;
|
import cc.niushuai.project.devcontrol.ui.powerswitch.PowerSwitchActivity;
|
||||||
import cn.hutool.core.date.DateUtil;
|
import cn.hutool.core.date.DateUtil;
|
||||||
import cn.hutool.core.util.IdUtil;
|
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
|
||||||
public class DeviceAddPowerSwitchActivity extends BaseActivity {
|
public class DeviceAddPowerSwitchActivity extends BaseActivity {
|
||||||
|
@ -16,7 +16,6 @@ import androidx.fragment.app.Fragment;
|
|||||||
import androidx.lifecycle.ViewModelProvider;
|
import androidx.lifecycle.ViewModelProvider;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Comparator;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
@ -2,7 +2,6 @@ package cc.niushuai.project.devcontrol.ui.powerswitch;
|
|||||||
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.Toast;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
@ -2,24 +2,15 @@ package cc.niushuai.project.devcontrol.ui.powerswitch;
|
|||||||
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.TextView;
|
|
||||||
import android.widget.Toast;
|
|
||||||
|
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
import cc.niushuai.project.devcontrol.R;
|
import cc.niushuai.project.devcontrol.R;
|
||||||
import cc.niushuai.project.devcontrol.base.enums.DeviceTypeEnum;
|
|
||||||
import cc.niushuai.project.devcontrol.base.enums.OnOffEnum;
|
|
||||||
import cc.niushuai.project.devcontrol.base.ui.BaseActivity;
|
import cc.niushuai.project.devcontrol.base.ui.BaseActivity;
|
||||||
import cc.niushuai.project.devcontrol.base.util.CommonUiUtil;
|
import cc.niushuai.project.devcontrol.base.util.CommonUiUtil;
|
||||||
import cc.niushuai.project.devcontrol.base.util.GlobalVariables;
|
import cc.niushuai.project.devcontrol.base.util.GlobalVariables;
|
||||||
import cc.niushuai.project.devcontrol.base.util.ToastUtil;
|
|
||||||
import cc.niushuai.project.devcontrol.base.util.UiUtil;
|
|
||||||
import cc.niushuai.project.devcontrol.databinding.ActivityPowerSwitchSetParamBinding;
|
import cc.niushuai.project.devcontrol.databinding.ActivityPowerSwitchSetParamBinding;
|
||||||
import cc.niushuai.project.devcontrol.db.DB;
|
import cc.niushuai.project.devcontrol.db.DB;
|
||||||
import cc.niushuai.project.devcontrol.db.entity.Device;
|
|
||||||
import cc.niushuai.project.devcontrol.vo.DeviceInfo;
|
import cc.niushuai.project.devcontrol.vo.DeviceInfo;
|
||||||
|
|
||||||
public class PowerSwitchSetParamActivity extends BaseActivity {
|
public class PowerSwitchSetParamActivity extends BaseActivity {
|
||||||
|
@ -72,6 +72,63 @@ public class DeviceInfo extends BaseVO {
|
|||||||
*/
|
*/
|
||||||
private Integer order;
|
private Integer order;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* mock 假数据
|
||||||
|
*
|
||||||
|
* @author niushuai
|
||||||
|
* @date: 2022/10/17 17:02
|
||||||
|
* @return: {@link List<DeviceInfo>}
|
||||||
|
*/
|
||||||
|
public static List<DeviceInfo> mock(int size, int iconId) {
|
||||||
|
List<DeviceInfo> list = new ArrayList<>();
|
||||||
|
|
||||||
|
for (int i = 0; i < size; i++) {
|
||||||
|
DeviceInfo device = new DeviceInfo();
|
||||||
|
device.setId(IdWorker.getNextIdStr());
|
||||||
|
device.setDeviceName("卧室灯开关" + (i + 1));
|
||||||
|
device.setIconId(iconId);
|
||||||
|
device.setRemark("卧室灯开关-树莓派");
|
||||||
|
device.setDeviceType(DeviceTypeEnum.Power_Switch);
|
||||||
|
device.setOnOff(OnOffEnum.OFF);
|
||||||
|
device.setCommandPath("/path/file");
|
||||||
|
device.setCommandOpen("-c light -t 1");
|
||||||
|
device.setCommandClose("-c light -t 0");
|
||||||
|
list.add(device);
|
||||||
|
|
||||||
|
GlobalVariables.DEVICE_INFO_MAP.put(device.getId(), device);
|
||||||
|
}
|
||||||
|
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* device to deviceInfo
|
||||||
|
*
|
||||||
|
* @param device
|
||||||
|
* @author niushuai
|
||||||
|
* @date: 2022/10/25 14:13
|
||||||
|
* @return: {@link DeviceInfo}
|
||||||
|
*/
|
||||||
|
public static DeviceInfo parseDevice(Device device) {
|
||||||
|
|
||||||
|
DeviceInfo _this = new DeviceInfo();
|
||||||
|
_this.setId(device.getId() + "");
|
||||||
|
_this.setDeviceName(device.getDeviceName());
|
||||||
|
_this.setDeviceType(DeviceTypeEnum.matchByValue(device.getDeviceType()));
|
||||||
|
_this.setOnOff(OnOffEnum.matchByValue(device.getOnOff()));
|
||||||
|
_this.setRemark(device.getRemark());
|
||||||
|
_this.setIconId(device.getIconId());
|
||||||
|
_this.setCommandPath(device.getCommandPath());
|
||||||
|
_this.setCommandStatus(device.getCommandStatus());
|
||||||
|
_this.setCommandOpen(device.getCommandOpen());
|
||||||
|
_this.setCommandClose(device.getCommandClose());
|
||||||
|
_this.setOrder(device.getOrder());
|
||||||
|
_this.setIsDeleted(device.getIsDeleted());
|
||||||
|
_this.setCreateTime(DateFormatUtil.parseDateTime(device.getCreateTime()));
|
||||||
|
|
||||||
|
return _this;
|
||||||
|
}
|
||||||
|
|
||||||
public Integer getOrder() {
|
public Integer getOrder() {
|
||||||
return order;
|
return order;
|
||||||
}
|
}
|
||||||
@ -152,64 +209,6 @@ public class DeviceInfo extends BaseVO {
|
|||||||
this.commandExtra = commandExtra;
|
this.commandExtra = commandExtra;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* mock 假数据
|
|
||||||
*
|
|
||||||
* @author niushuai
|
|
||||||
* @date: 2022/10/17 17:02
|
|
||||||
* @return: {@link List<DeviceInfo>}
|
|
||||||
*/
|
|
||||||
public static List<DeviceInfo> mock(int size, int iconId) {
|
|
||||||
List<DeviceInfo> list = new ArrayList<>();
|
|
||||||
|
|
||||||
for (int i = 0; i < size; i++) {
|
|
||||||
DeviceInfo device = new DeviceInfo();
|
|
||||||
device.setId(IdWorker.getNextIdStr());
|
|
||||||
device.setDeviceName("卧室灯开关" + (i + 1));
|
|
||||||
device.setIconId(iconId);
|
|
||||||
device.setRemark("卧室灯开关-树莓派");
|
|
||||||
device.setDeviceType(DeviceTypeEnum.Power_Switch);
|
|
||||||
device.setOnOff(OnOffEnum.OFF);
|
|
||||||
device.setCommandPath("/path/file");
|
|
||||||
device.setCommandOpen("-c light -t 1");
|
|
||||||
device.setCommandClose("-c light -t 0");
|
|
||||||
list.add(device);
|
|
||||||
|
|
||||||
GlobalVariables.DEVICE_INFO_MAP.put(device.getId(), device);
|
|
||||||
}
|
|
||||||
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* device to deviceInfo
|
|
||||||
*
|
|
||||||
* @param device
|
|
||||||
* @author niushuai
|
|
||||||
* @date: 2022/10/25 14:13
|
|
||||||
* @return: {@link DeviceInfo}
|
|
||||||
*/
|
|
||||||
public static DeviceInfo parseDevice(Device device) {
|
|
||||||
|
|
||||||
DeviceInfo _this = new DeviceInfo();
|
|
||||||
_this.setId(device.getId() + "");
|
|
||||||
_this.setDeviceName(device.getDeviceName());
|
|
||||||
_this.setDeviceType(DeviceTypeEnum.matchByValue(device.getDeviceType()));
|
|
||||||
_this.setOnOff(OnOffEnum.matchByValue(device.getOnOff()));
|
|
||||||
_this.setRemark(device.getRemark());
|
|
||||||
_this.setIconId(device.getIconId());
|
|
||||||
_this.setCommandPath(device.getCommandPath());
|
|
||||||
_this.setCommandStatus(device.getCommandStatus());
|
|
||||||
_this.setCommandOpen(device.getCommandOpen());
|
|
||||||
_this.setCommandClose(device.getCommandClose());
|
|
||||||
_this.setOrder(device.getOrder());
|
|
||||||
_this.setIsDeleted(device.getIsDeleted());
|
|
||||||
_this.setCreateTime(DateFormatUtil.parseDateTime(device.getCreateTime()));
|
|
||||||
|
|
||||||
return _this;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* deviceInfo to device
|
* deviceInfo to device
|
||||||
*
|
*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user