多选查询条件转换
//多选查询条件转换:
//"123,2342,123123"->List<String>
if (Func.isNotEmpty(exerciseTrendReq.getBirdRecordIds())) {
List<String> birdRecordIds = new ArrayList<>();
Arrays.stream(exerciseTrendReq.getBirdRecordIds().split(",")).forEach(item -> birdRecordIds.add(item));
}
日期格式转换:
日期格式转换:
日期加一天 转格式为'yyyy-MM-dd'
if (Func.isNotEmpty(exerciseTrendReq.getEndTime())) {
Date endDate = DateUtil.parse(exerciseTrendReq.getEndTime(), DateUtil.PATTERN_DATE);
exerciseTrendReq.setEndTime(DateUtil.formatDate(DateUtil.plusDays(endDate, 1)));
}
日期格式化
LocalDateTime ->"yyyy-MM-dd HH:mm" "yyyyMMddHHmmss" "yyyy-MM-dd" "HH:mm:ss"
DateUtil DateTimeUtil.parseDateTime 方法
String time = DateUtil.format(birdHistoricalTrack.getPickTime(),"yyyy-MM-dd HH:mm");
MybatisPlus查询
List<BirdHistoricalTrack> birdHistoricalTracks = list(new QueryWrapper<BirdHistoricalTrack>()
.eq("bird_record_id",birdRecordId)
.gt(Func.isNotBlank(exerciseTrendReq.getStartTime()), "pick_time", exerciseTrendReq.getStartTime())
.lt(Func.isNotBlank(exerciseTrendReq.getEndTime()), "pick_time", exerciseTrendReq.getEndTime())
.orderByAsc("pick_time"));
public interface DeviceConstant {
String RANGE_MSG = "%s,编号:%s目前已飞回限定范围";
String EXERCISE_MSG = "%s,编号:%s目前活动量已恢复正常";
String RANGE_OUT_MSG = "%s,编号:%s目前已飞出限定范围";
String LONG_TIME_STAY = "%s,编号:%s目前长时间停留,请及时处理";
/**
* 经度标识
*
* @author wangjunma
* @version 1.0
* @date 2021/11/1 16:26
*/
@Getter
enum LoncEnum {
/**
* 经度标签为E时,取原始值
*/
E("E"),
/**
* 经度标签为W时,需要取负
*/
W("W");
private String value;
LoncEnum(String value) {
this.value = value;
}
}
/**
* 维度标识
*
* @author wangjunma
* @version 1.0
* @date 2021/11/1 16:26
*/
/**
* 报警类型枚举
*
* @author wangjunma
* @version 1.0
* @date 2021/11/1 16:26
*/
@Getter
enum AlarmTypeEnum {
/**
* 范围报警
*/
RANGE(1, "范围报警"),
/**
* 活动量报警
*/
EXERCISE(2, "活动量报警");
private int value;
private String name;
AlarmTypeEnum(int value, String name) {
this.value = value;
this.name = name;
}
public static String convertAlarm(Integer alarmType, String name, String code) {
if (Func.isEmpty(alarmType)) {
return null;
}
if (RANGE.getValue() == alarmType.intValue()) {
return String.format(RANGE_OUT_MSG,name,code);
} else if (EXERCISE.getValue() == alarmType.intValue()) {
return String.format(LONG_TIME_STAY,name,code);
}
return null;
}
}
/**
* 报警状态 枚举
*
* @author wangjunma
* @version 1.0
* @date 2021/11/1 16:26
*/
@Getter
enum AlarmStatusEnum {
/**
* 范围报警
*/
ALARMING(0, "报警中"),
/**
* 活动量报警
*/
ALARM_CLEARED(1, "已消警");
private int value;
private String name;
AlarmStatusEnum(int value, String name) {
this.value = value;
this.name = name;
}
}
/**
* 申请状态
*/
enum UnbindApplyTypeEnum {
AUDITING(1, "待处理"),
UNBIND(2, "已处理"),
INVALID(3, "无效");
@Getter
private Integer code;
@Getter
private String desc;
UnbindApplyTypeEnum(Integer code, String desc) {
this.code = code;
this.desc = desc;
}
public static UnbindApplyTypeEnum valueOf(Integer code) {
for (UnbindApplyTypeEnum type : UnbindApplyTypeEnum.values()) {
if (Objects.equals(type.getCode(), code)) {
return type;
}
}
throw new MsgException("申请状态无效"); // 自定义异常
}
}
}
对象属性复制
BeanUtil.copy()
CameraSettingRequest settingReq = BeanUtil.copy(infraredCamerParam, CameraSettingRequest.class);
常用命名
req 请求
respone 响应