Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gxpt_ht
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
pseer
gxpt_ht
Commits
a38cc7f2
Commit
a38cc7f2
authored
Jan 15, 2024
by
YG8999
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
设备状态异常变更监控提醒
parent
be946344
Hide whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
827 additions
and
21 deletions
+827
-21
DeviceStatusLogController.java
...hare/web/controller/system/DeviceStatusLogController.java
+104
-0
DeviceStatusEnum.java
...on/src/main/java/share/common/enums/DeviceStatusEnum.java
+49
-0
SmsTypeEnum.java
...-common/src/main/java/share/common/enums/SmsTypeEnum.java
+1
-0
DeviceTask.java
share-quartz/src/main/java/share/quartz/task/DeviceTask.java
+26
-0
DeviceGateway.java
...stem/src/main/java/share/system/domain/DeviceGateway.java
+2
-4
DeviceLog.java
...e-system/src/main/java/share/system/domain/DeviceLog.java
+2
-4
DeviceStatusLog.java
...em/src/main/java/share/system/domain/DeviceStatusLog.java
+101
-0
DeviceLogMapper.java
...em/src/main/java/share/system/mapper/DeviceLogMapper.java
+10
-0
DeviceStatusLogMapper.java
.../main/java/share/system/mapper/DeviceStatusLogMapper.java
+62
-0
SnowFlakeUtil.java
...system/src/main/java/share/system/mqtt/SnowFlakeUtil.java
+11
-0
DeviceStatusLogService.java
...ain/java/share/system/service/DeviceStatusLogService.java
+68
-0
SmsService.java
...system/src/main/java/share/system/service/SmsService.java
+7
-0
DeviceStatusLogServiceImpl.java
...share/system/service/impl/DeviceStatusLogServiceImpl.java
+135
-0
MqttxServiceImpl.java
...main/java/share/system/service/impl/MqttxServiceImpl.java
+100
-8
SmsServiceImpl.java
...c/main/java/share/system/service/impl/SmsServiceImpl.java
+15
-4
DeviceLogMapper.xml
...stem/src/main/resources/mapper/system/DeviceLogMapper.xml
+17
-1
DeviceStatusLogMapper.xml
...rc/main/resources/mapper/system/DeviceStatusLogMapper.xml
+117
-0
No files found.
share-admin/src/main/java/share/web/controller/system/DeviceStatusLogController.java
0 → 100644
View file @
a38cc7f2
package
share
.
web
.
controller
.
system
;
import
java.util.List
;
import
javax.servlet.http.HttpServletResponse
;
import
org.springframework.security.access.prepost.PreAuthorize
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.PutMapping
;
import
org.springframework.web.bind.annotation.DeleteMapping
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
share.common.annotation.Log
;
import
share.common.core.controller.BaseController
;
import
share.common.core.domain.AjaxResult
;
import
share.common.enums.BusinessType
;
import
share.system.domain.DeviceStatusLog
;
import
share.system.service.DeviceStatusLogService
;
import
share.common.utils.poi.ExcelUtil
;
import
share.common.core.page.TableDataInfo
;
/**
* 设备状态变更记录Controller
*
* @author wuwenlong
* @date 2024-01-15
*/
@RestController
@RequestMapping
(
"/system/statusLog"
)
public
class
DeviceStatusLogController
extends
BaseController
{
@Autowired
private
DeviceStatusLogService
deviceStatusLogService
;
/**
* 查询设备状态变更记录列表
*/
@PreAuthorize
(
"@ss.hasPermi('system:statusLog:list')"
)
@GetMapping
(
"/list"
)
public
TableDataInfo
list
(
DeviceStatusLog
deviceStatusLog
)
{
startPage
();
List
<
DeviceStatusLog
>
list
=
deviceStatusLogService
.
selectDeviceStatusLogList
(
deviceStatusLog
);
return
getDataTable
(
list
);
}
/**
* 导出设备状态变更记录列表
*/
@PreAuthorize
(
"@ss.hasPermi('system:statusLog:export')"
)
@Log
(
title
=
"设备状态变更记录"
,
businessType
=
BusinessType
.
EXPORT
)
@PostMapping
(
"/export"
)
public
void
export
(
HttpServletResponse
response
,
DeviceStatusLog
deviceStatusLog
)
{
List
<
DeviceStatusLog
>
list
=
deviceStatusLogService
.
selectDeviceStatusLogList
(
deviceStatusLog
);
ExcelUtil
<
DeviceStatusLog
>
util
=
new
ExcelUtil
<
DeviceStatusLog
>(
DeviceStatusLog
.
class
);
util
.
exportExcel
(
response
,
list
,
"设备状态变更记录数据"
);
}
/**
* 获取设备状态变更记录详细信息
*/
@PreAuthorize
(
"@ss.hasPermi('system:statusLog:query')"
)
@GetMapping
(
value
=
"/{id}"
)
public
AjaxResult
getInfo
(
@PathVariable
(
"id"
)
Long
id
)
{
return
success
(
deviceStatusLogService
.
selectDeviceStatusLogById
(
id
));
}
/**
* 新增设备状态变更记录
*/
@PreAuthorize
(
"@ss.hasPermi('system:statusLog:add')"
)
@Log
(
title
=
"设备状态变更记录"
,
businessType
=
BusinessType
.
INSERT
)
@PostMapping
public
AjaxResult
add
(
@RequestBody
DeviceStatusLog
deviceStatusLog
)
{
return
toAjax
(
deviceStatusLogService
.
insertDeviceStatusLog
(
deviceStatusLog
));
}
/**
* 修改设备状态变更记录
*/
@PreAuthorize
(
"@ss.hasPermi('system:statusLog:edit')"
)
@Log
(
title
=
"设备状态变更记录"
,
businessType
=
BusinessType
.
UPDATE
)
@PutMapping
public
AjaxResult
edit
(
@RequestBody
DeviceStatusLog
deviceStatusLog
)
{
return
toAjax
(
deviceStatusLogService
.
updateDeviceStatusLog
(
deviceStatusLog
));
}
/**
* 删除设备状态变更记录
*/
@PreAuthorize
(
"@ss.hasPermi('system:statusLog:remove')"
)
@Log
(
title
=
"设备状态变更记录"
,
businessType
=
BusinessType
.
DELETE
)
@DeleteMapping
(
"/{ids}"
)
public
AjaxResult
remove
(
@PathVariable
Long
[]
ids
)
{
return
toAjax
(
deviceStatusLogService
.
deleteDeviceStatusLogByIds
(
ids
));
}
}
share-common/src/main/java/share/common/enums/DeviceStatusEnum.java
0 → 100644
View file @
a38cc7f2
package
share
.
common
.
enums
;
import
cn.hutool.core.util.StrUtil
;
import
java.util.Arrays
;
import
java.util.List
;
import
java.util.stream.Collectors
;
/**
* @className: share.common.enums.DeviceStatusEnum
* @description: 设备状态
* @author: lwj
* @create: 2024-01-15 10:12
*/
public
enum
DeviceStatusEnum
{
DEVICE_OFFLINE
(
"0"
,
"离线"
),
DEVICE_ONLINE
(
"1"
,
"在线"
),
DEVICE_OUTAGE
(
"2"
,
"断电"
),
DEVICE_ENERGIZE
(
"3"
,
"取电"
)
;
private
String
code
;
private
String
name
;
DeviceStatusEnum
(
String
code
,
String
name
)
{
this
.
code
=
code
;
this
.
name
=
name
;
}
public
static
String
getNameStr
(
String
code
)
{
if
(
StrUtil
.
isNotBlank
(
code
))
{
for
(
DeviceStatusEnum
statusEnum
:
DeviceStatusEnum
.
values
())
{
if
(
statusEnum
.
code
.
equals
(
code
))
{
return
statusEnum
.
name
;
}
}
}
return
""
;
}
public
String
getCode
()
{
return
code
;
}
public
String
getName
()
{
return
name
;
}
}
share-common/src/main/java/share/common/enums/SmsTypeEnum.java
View file @
a38cc7f2
...
@@ -14,6 +14,7 @@ public enum SmsTypeEnum {
...
@@ -14,6 +14,7 @@ public enum SmsTypeEnum {
SMS_ORDER_START_TEMP
(
4
,
"sms.order.start.template"
,
"订单即将开始提示短信"
),
SMS_ORDER_START_TEMP
(
4
,
"sms.order.start.template"
,
"订单即将开始提示短信"
),
SMS_ORDER_END_TEMP
(
5
,
"sms.order.end.template"
,
"订单即结束始提示短信"
),
SMS_ORDER_END_TEMP
(
5
,
"sms.order.end.template"
,
"订单即结束始提示短信"
),
SMS_CLEAN_RECORDS_STOP_TEMP
(
6
,
"sms.clean.records.stop.template"
,
"保洁任务中断短信提醒"
),
SMS_CLEAN_RECORDS_STOP_TEMP
(
6
,
"sms.clean.records.stop.template"
,
"保洁任务中断短信提醒"
),
SMS_DEVICE_ABNORMAL_TEMP
(
7
,
"sms.device.abnormal.template"
,
"设备状态异常变更短信提醒"
),
;
;
private
Integer
code
;
private
Integer
code
;
...
...
share-quartz/src/main/java/share/quartz/task/DeviceTask.java
0 → 100644
View file @
a38cc7f2
package
share
.
quartz
.
task
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
share.system.service.DeviceStatusLogService
;
/**
* @className: share.quartz.task.DeviceTask
* @description: 设备定时任务
* @author: lwj
* @create: 2024-01-15 16:54
*/
@Component
(
"deviceTask"
)
public
class
DeviceTask
{
@Autowired
private
DeviceStatusLogService
deviceStatusLogService
;
/**
* 设备异常状态短信提醒任务
*/
public
void
sendSmsByYc
()
{
deviceStatusLogService
.
sendSmsByYc
();
}
}
share-system/src/main/java/share/system/domain/DeviceGateway.java
View file @
a38cc7f2
package
share
.
system
.
domain
;
package
share
.
system
.
domain
;
import
com.baomidou.mybatisplus.annotation.IdType
;
import
com.baomidou.mybatisplus.annotation.*
;
import
com.baomidou.mybatisplus.annotation.TableId
;
import
org.apache.commons.lang3.builder.ToStringBuilder
;
import
org.apache.commons.lang3.builder.ToStringBuilder
;
import
org.apache.commons.lang3.builder.ToStringStyle
;
import
org.apache.commons.lang3.builder.ToStringStyle
;
import
share.common.annotation.Excel
;
import
share.common.annotation.Excel
;
import
share.common.core.domain.BaseEntity
;
import
share.common.core.domain.BaseEntity
;
import
com.baomidou.mybatisplus.annotation.TableField
;
import
com.baomidou.mybatisplus.annotation.TableLogic
;
import
lombok.Data
;
import
lombok.Data
;
/**
/**
* 设备网关信息对象 s_device_gateway
* 设备网关信息对象 s_device_gateway
...
@@ -16,6 +13,7 @@ import lombok.Data;
...
@@ -16,6 +13,7 @@ import lombok.Data;
* @date 2023-11-03
* @date 2023-11-03
*/
*/
@Data
@Data
@TableName
(
value
=
"s_device_gateway"
)
public
class
DeviceGateway
extends
BaseEntity
public
class
DeviceGateway
extends
BaseEntity
{
{
private
static
final
long
serialVersionUID
=
1L
;
private
static
final
long
serialVersionUID
=
1L
;
...
...
share-system/src/main/java/share/system/domain/DeviceLog.java
View file @
a38cc7f2
package
share
.
system
.
domain
;
package
share
.
system
.
domain
;
import
com.baomidou.mybatisplus.annotation.IdType
;
import
com.baomidou.mybatisplus.annotation.*
;
import
com.baomidou.mybatisplus.annotation.TableId
;
import
org.apache.commons.lang3.builder.ToStringBuilder
;
import
org.apache.commons.lang3.builder.ToStringBuilder
;
import
org.apache.commons.lang3.builder.ToStringStyle
;
import
org.apache.commons.lang3.builder.ToStringStyle
;
import
share.common.annotation.Excel
;
import
share.common.annotation.Excel
;
import
share.common.core.domain.BaseEntity
;
import
share.common.core.domain.BaseEntity
;
import
com.baomidou.mybatisplus.annotation.TableField
;
import
com.baomidou.mybatisplus.annotation.TableLogic
;
import
lombok.Data
;
import
lombok.Data
;
/**
/**
* 设备操作日志对象 s_device_log
* 设备操作日志对象 s_device_log
...
@@ -16,6 +13,7 @@ import lombok.Data;
...
@@ -16,6 +13,7 @@ import lombok.Data;
* @date 2023-11-03
* @date 2023-11-03
*/
*/
@Data
@Data
@TableName
(
value
=
"s_device_log"
)
public
class
DeviceLog
extends
BaseEntity
public
class
DeviceLog
extends
BaseEntity
{
{
private
static
final
long
serialVersionUID
=
1L
;
private
static
final
long
serialVersionUID
=
1L
;
...
...
share-system/src/main/java/share/system/domain/DeviceStatusLog.java
0 → 100644
View file @
a38cc7f2
package
share
.
system
.
domain
;
import
com.baomidou.mybatisplus.annotation.*
;
import
com.fasterxml.jackson.annotation.JsonFormat
;
import
org.apache.commons.lang3.builder.ToStringBuilder
;
import
org.apache.commons.lang3.builder.ToStringStyle
;
import
share.common.annotation.Excel
;
import
share.common.core.domain.BaseEntity
;
import
lombok.Data
;
import
java.io.Serializable
;
import
java.util.Date
;
/**
* 设备状态变更记录对象 s_device_status_log
*
* @author wuwenlong
* @date 2024-01-15
*/
@Data
@TableName
(
value
=
"s_device_status_log"
)
public
class
DeviceStatusLog
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
/** $column.columnComment */
@TableId
(
type
=
IdType
.
AUTO
)
private
Long
id
;
/** 设备id */
@Excel
(
name
=
"设备id"
)
private
String
devId
;
/** 设备mac */
@Excel
(
name
=
"设备mac"
)
private
String
devMac
;
/** 是否异常变更:1-是,0-否 */
@Excel
(
name
=
"是否异常变更:1-是,0-否"
)
private
Integer
isAbnormal
;
/** 设备当前状态 */
@Excel
(
name
=
"设备当前状态"
)
@TableField
(
value
=
"`status`"
)
private
String
status
;
/** $column.columnComment */
@Excel
(
name
=
"${comment}"
,
readConverterExp
=
"$column.readConverterExp()"
)
private
Long
roomId
;
/** 电量、电压 */
@Excel
(
name
=
"电量、电压"
)
private
String
voltage
;
/** 信号值 */
@Excel
(
name
=
"信号值"
)
private
String
signalValue
;
/** 变更操作记录id */
@Excel
(
name
=
"变更操作记录id"
)
private
Long
operateLogId
;
/** 是否已发送短信:1-是,0-否 */
@Excel
(
name
=
"是否已发送短信:1-是,0-否"
)
private
Integer
isSendSms
;
/** 变更前的设备状态 */
@Excel
(
name
=
"变更前的设备状态"
)
private
String
previousStatus
;
/** 创建时间 */
@JsonFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
)
private
Date
createTime
;
/** 更新时间 */
@JsonFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
)
private
Date
updateTime
;
/** 备注 */
private
String
remark
;
@Override
public
String
toString
()
{
return
new
ToStringBuilder
(
this
,
ToStringStyle
.
MULTI_LINE_STYLE
)
.
append
(
"id"
,
getId
())
.
append
(
"devId"
,
getDevId
())
.
append
(
"devMac"
,
getDevMac
())
.
append
(
"isAbnormal"
,
getIsAbnormal
())
.
append
(
"status"
,
getStatus
())
.
append
(
"roomId"
,
getRoomId
())
.
append
(
"voltage"
,
getVoltage
())
.
append
(
"signalValue"
,
getSignalValue
())
.
append
(
"createTime"
,
getCreateTime
())
.
append
(
"updateTime"
,
getUpdateTime
())
.
append
(
"remark"
,
getRemark
())
.
append
(
"operateLogId"
,
getOperateLogId
())
.
append
(
"isSendSms"
,
getIsSendSms
())
.
toString
();
}
}
share-system/src/main/java/share/system/mapper/DeviceLogMapper.java
View file @
a38cc7f2
package
share
.
system
.
mapper
;
package
share
.
system
.
mapper
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.List
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
org.apache.ibatis.annotations.Param
;
import
share.system.domain.DeviceLog
;
import
share.system.domain.DeviceLog
;
/**
/**
...
@@ -61,4 +63,12 @@ public interface DeviceLogMapper extends BaseMapper<DeviceLog>
...
@@ -61,4 +63,12 @@ public interface DeviceLogMapper extends BaseMapper<DeviceLog>
public
int
deleteDeviceLogByIds
(
Long
[]
ids
);
public
int
deleteDeviceLogByIds
(
Long
[]
ids
);
int
updateBySeq
(
DeviceLog
deviceLog
);
int
updateBySeq
(
DeviceLog
deviceLog
);
/**
* 查询每个设备最大id数据
* @param devIds
* @return
*/
List
<
DeviceLog
>
selectListByMaxId
(
@Param
(
"devIds"
)
List
<
String
>
devIds
,
@Param
(
"startDate"
)
Date
startDate
);
}
}
share-system/src/main/java/share/system/mapper/DeviceStatusLogMapper.java
0 → 100644
View file @
a38cc7f2
package
share
.
system
.
mapper
;
import
java.util.List
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
share.system.domain.DeviceStatusLog
;
/**
* 设备状态变更记录Mapper接口
*
* @author wuwenlong
* @date 2024-01-15
*/
public
interface
DeviceStatusLogMapper
extends
BaseMapper
<
DeviceStatusLog
>
{
/**
* 查询设备状态变更记录
*
* @param id 设备状态变更记录主键
* @return 设备状态变更记录
*/
public
DeviceStatusLog
selectDeviceStatusLogById
(
Long
id
);
/**
* 查询设备状态变更记录列表
*
* @param deviceStatusLog 设备状态变更记录
* @return 设备状态变更记录集合
*/
public
List
<
DeviceStatusLog
>
selectDeviceStatusLogList
(
DeviceStatusLog
deviceStatusLog
);
/**
* 新增设备状态变更记录
*
* @param deviceStatusLog 设备状态变更记录
* @return 结果
*/
public
int
insertDeviceStatusLog
(
DeviceStatusLog
deviceStatusLog
);
/**
* 修改设备状态变更记录
*
* @param deviceStatusLog 设备状态变更记录
* @return 结果
*/
public
int
updateDeviceStatusLog
(
DeviceStatusLog
deviceStatusLog
);
/**
* 删除设备状态变更记录
*
* @param id 设备状态变更记录主键
* @return 结果
*/
public
int
deleteDeviceStatusLogById
(
Long
id
);
/**
* 批量删除设备状态变更记录
*
* @param ids 需要删除的数据主键集合
* @return 结果
*/
public
int
deleteDeviceStatusLogByIds
(
Long
[]
ids
);
}
share-system/src/main/java/share/system/mqtt/SnowFlakeUtil.java
View file @
a38cc7f2
...
@@ -83,6 +83,17 @@ public class SnowFlakeUtil {
...
@@ -83,6 +83,17 @@ public class SnowFlakeUtil {
long
between
=
cn
.
hutool
.
core
.
date
.
DateUtil
.
between
(
cn
.
hutool
.
core
.
date
.
DateUtil
.
date
(),
long
between
=
cn
.
hutool
.
core
.
date
.
DateUtil
.
between
(
cn
.
hutool
.
core
.
date
.
DateUtil
.
date
(),
date2
,
DateUnit
.
SECOND
);
date2
,
DateUnit
.
SECOND
);
System
.
out
.
println
(
between
);
System
.
out
.
println
(
between
);
String
decimalString
=
"1"
;
int
decimal
=
Integer
.
parseInt
(
decimalString
);
String
binaryString
=
Integer
.
toBinaryString
(
decimal
);
System
.
out
.
println
(
"十进制字符串 "
+
decimalString
+
" 转换为二进制是 "
+
binaryString
);
String
[]
binaryArray
=
binaryString
.
split
(
"(?<=\\G.)"
);
for
(
String
binary
:
binaryArray
)
{
System
.
out
.
println
(
binary
);
}
Date
startDate
=
DateUtil
.
offsetMinute
(
DateUtil
.
date
(),
-
3
);
System
.
out
.
println
(
DateUtil
.
formatDateTime
(
startDate
));
}
}
...
...
share-system/src/main/java/share/system/service/DeviceStatusLogService.java
0 → 100644
View file @
a38cc7f2
package
share
.
system
.
service
;
import
java.util.List
;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
share.system.domain.DeviceStatusLog
;
/**
* 设备状态变更记录Service接口
*
* @author wuwenlong
* @date 2024-01-15
*/
public
interface
DeviceStatusLogService
extends
IService
<
DeviceStatusLog
>
{
/**
* 查询设备状态变更记录
*
* @param id 设备状态变更记录主键
* @return 设备状态变更记录
*/
public
DeviceStatusLog
selectDeviceStatusLogById
(
Long
id
);
/**
* 查询设备状态变更记录列表
*
* @param deviceStatusLog 设备状态变更记录
* @return 设备状态变更记录集合
*/
public
List
<
DeviceStatusLog
>
selectDeviceStatusLogList
(
DeviceStatusLog
deviceStatusLog
);
/**
* 新增设备状态变更记录
*
* @param deviceStatusLog 设备状态变更记录
* @return 结果
*/
public
int
insertDeviceStatusLog
(
DeviceStatusLog
deviceStatusLog
);
/**
* 修改设备状态变更记录
*
* @param deviceStatusLog 设备状态变更记录
* @return 结果
*/
public
int
updateDeviceStatusLog
(
DeviceStatusLog
deviceStatusLog
);
/**
* 批量删除设备状态变更记录
*
* @param ids 需要删除的设备状态变更记录主键集合
* @return 结果
*/
public
int
deleteDeviceStatusLogByIds
(
Long
[]
ids
);
/**
* 删除设备状态变更记录信息
*
* @param id 设备状态变更记录主键
* @return 结果
*/
public
int
deleteDeviceStatusLogById
(
Long
id
);
/**
* 异常变更记录发送短信
* @return
*/
boolean
sendSmsByYc
();
}
share-system/src/main/java/share/system/service/SmsService.java
View file @
a38cc7f2
...
@@ -2,6 +2,7 @@ package share.system.service;
...
@@ -2,6 +2,7 @@ package share.system.service;
import
cn.hutool.json.JSONArray
;
import
cn.hutool.json.JSONArray
;
import
share.system.domain.DeviceStatusLog
;
import
share.system.domain.SRoom
;
import
share.system.domain.SRoom
;
import
share.system.domain.SStore
;
import
share.system.domain.SStore
;
...
@@ -53,5 +54,11 @@ public interface SmsService {
...
@@ -53,5 +54,11 @@ public interface SmsService {
*/
*/
boolean
sendSmsCleanRecordsStopRemind
(
String
phone
,
SStore
store
,
SRoom
room
);
boolean
sendSmsCleanRecordsStopRemind
(
String
phone
,
SStore
store
,
SRoom
room
);
/**
* 设备异常变更,发送短信通知
* @return
*/
boolean
sendSmsDeviceAbnormal
(
String
phone
,
DeviceStatusLog
deviceStatusLog
,
SStore
store
,
SRoom
room
);
}
}
share-system/src/main/java/share/system/service/impl/DeviceStatusLogServiceImpl.java
0 → 100644
View file @
a38cc7f2
package
share
.
system
.
service
.
impl
;
import
java.util.List
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
share.common.enums.SmsTypeEnum
;
import
share.common.enums.YesNoEnum
;
import
share.common.utils.DateUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
share.system.domain.*
;
import
share.system.mapper.DeviceStatusLogMapper
;
import
share.system.mapper.SRoomMapper
;
import
share.system.mapper.SStoreMapper
;
import
share.system.mapper.SysConfigMapper
;
import
share.system.service.DeviceStatusLogService
;
import
share.system.service.SmsService
;
/**
* 设备状态变更记录Service业务层处理
*
* @author wuwenlong
* @date 2024-01-15
*/
@Service
public
class
DeviceStatusLogServiceImpl
extends
ServiceImpl
<
DeviceStatusLogMapper
,
DeviceStatusLog
>
implements
DeviceStatusLogService
{
@Autowired
private
DeviceStatusLogMapper
deviceStatusLogMapper
;
@Autowired
private
SRoomMapper
roomMapper
;
@Autowired
private
SStoreMapper
storeMapper
;
@Autowired
private
SysConfigMapper
sysConfigMapper
;
@Autowired
private
SmsService
smsService
;
/**
* 查询设备状态变更记录
*
* @param id 设备状态变更记录主键
* @return 设备状态变更记录
*/
@Override
public
DeviceStatusLog
selectDeviceStatusLogById
(
Long
id
)
{
return
deviceStatusLogMapper
.
selectDeviceStatusLogById
(
id
);
}
/**
* 查询设备状态变更记录列表
*
* @param deviceStatusLog 设备状态变更记录
* @return 设备状态变更记录
*/
@Override
public
List
<
DeviceStatusLog
>
selectDeviceStatusLogList
(
DeviceStatusLog
deviceStatusLog
)
{
return
deviceStatusLogMapper
.
selectDeviceStatusLogList
(
deviceStatusLog
);
}
/**
* 新增设备状态变更记录
*
* @param deviceStatusLog 设备状态变更记录
* @return 结果
*/
@Override
public
int
insertDeviceStatusLog
(
DeviceStatusLog
deviceStatusLog
)
{
deviceStatusLog
.
setCreateTime
(
DateUtils
.
getNowDate
());
return
deviceStatusLogMapper
.
insertDeviceStatusLog
(
deviceStatusLog
);
}
/**
* 修改设备状态变更记录
*
* @param deviceStatusLog 设备状态变更记录
* @return 结果
*/
@Override
public
int
updateDeviceStatusLog
(
DeviceStatusLog
deviceStatusLog
)
{
deviceStatusLog
.
setUpdateTime
(
DateUtils
.
getNowDate
());
return
deviceStatusLogMapper
.
updateDeviceStatusLog
(
deviceStatusLog
);
}
/**
* 批量删除设备状态变更记录
*
* @param ids 需要删除的设备状态变更记录主键
* @return 结果
*/
@Override
public
int
deleteDeviceStatusLogByIds
(
Long
[]
ids
)
{
return
deviceStatusLogMapper
.
deleteDeviceStatusLogByIds
(
ids
);
}
/**
* 删除设备状态变更记录信息
*
* @param id 设备状态变更记录主键
* @return 结果
*/
@Override
public
int
deleteDeviceStatusLogById
(
Long
id
)
{
return
deviceStatusLogMapper
.
deleteDeviceStatusLogById
(
id
);
}
@Override
public
boolean
sendSmsByYc
()
{
// 设备状态变更信息查询
LambdaQueryWrapper
<
DeviceStatusLog
>
queryWrapper
=
new
LambdaQueryWrapper
();
queryWrapper
.
eq
(
DeviceStatusLog:
:
getIsSendSms
,
YesNoEnum
.
no
.
getIndex
());
queryWrapper
.
eq
(
DeviceStatusLog:
:
getIsAbnormal
,
YesNoEnum
.
yes
.
getIndex
());
List
<
DeviceStatusLog
>
list
=
deviceStatusLogMapper
.
selectList
(
queryWrapper
);
list
.
stream
().
forEach
(
log
->
{
SRoom
room
=
roomMapper
.
selectSRoomById
(
log
.
getRoomId
());
if
(
room
!=
null
)
{
SStore
store
=
storeMapper
.
selectSStoreById
(
room
.
getStoreId
());
SysConfig
config
=
sysConfigMapper
.
checkConfigKeyUnique
(
"system.device.phone"
);
boolean
b
=
smsService
.
sendSmsDeviceAbnormal
(
config
.
getConfigValue
(),
log
,
store
,
room
);
if
(
b
)
{
log
.
setIsSendSms
(
YesNoEnum
.
yes
.
getIndex
());
}
}
});
return
updateBatchById
(
list
);
}
}
share-system/src/main/java/share/system/service/impl/MqttxServiceImpl.java
View file @
a38cc7f2
...
@@ -6,26 +6,30 @@ import cn.hutool.core.util.StrUtil;
...
@@ -6,26 +6,30 @@ import cn.hutool.core.util.StrUtil;
import
cn.hutool.json.JSONArray
;
import
cn.hutool.json.JSONArray
;
import
cn.hutool.json.JSONObject
;
import
cn.hutool.json.JSONObject
;
import
cn.hutool.json.JSONUtil
;
import
cn.hutool.json.JSONUtil
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
share.common.constant.MqttConstants
;
import
share.common.constant.MqttConstants
;
import
share.common.enums.MqttOpType
;
import
share.common.enums.*
;
import
share.common.enums.MqttOpenType
;
import
share.common.enums.MqttReportType
;
import
share.common.enums.OpTypeEnum
;
import
share.common.utils.DateUtils
;
import
share.common.utils.DateUtils
;
import
share.system.domain.Device
;
import
share.system.domain.Device
;
import
share.system.domain.DeviceGateway
;
import
share.system.domain.DeviceGateway
;
import
share.system.domain.DeviceLog
;
import
share.system.domain.DeviceLog
;
import
share.system.domain.DeviceStatusLog
;
import
share.system.domain.vo.MqttxVo
;
import
share.system.domain.vo.MqttxVo
;
import
share.system.mapper.DeviceGatewayMapper
;
import
share.system.mapper.DeviceGatewayMapper
;
import
share.system.mapper.DeviceLogMapper
;
import
share.system.mapper.DeviceLogMapper
;
import
share.system.mapper.DeviceMapper
;
import
share.system.mapper.DeviceMapper
;
import
share.system.mapper.DeviceStatusLogMapper
;
import
share.system.service.DeviceStatusLogService
;
import
share.system.service.MqttxService
;
import
share.system.service.MqttxService
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.function.Function
;
import
java.util.stream.Collectors
;
/**
/**
* @className: share.system.service.impl.MqttxServiceImpl
* @className: share.system.service.impl.MqttxServiceImpl
...
@@ -42,6 +46,8 @@ public class MqttxServiceImpl implements MqttxService {
...
@@ -42,6 +46,8 @@ public class MqttxServiceImpl implements MqttxService {
private
DeviceMapper
deviceMapper
;
private
DeviceMapper
deviceMapper
;
@Autowired
@Autowired
private
DeviceLogMapper
deviceLogMapper
;
private
DeviceLogMapper
deviceLogMapper
;
@Autowired
private
DeviceStatusLogService
deviceStatusLogService
;
/**
/**
* 清除网关锁id列表
* 清除网关锁id列表
...
@@ -526,17 +532,103 @@ public class MqttxServiceImpl implements MqttxService {
...
@@ -526,17 +532,103 @@ public class MqttxServiceImpl implements MqttxService {
if
(
json
.
size
()
>
0
)
{
if
(
json
.
size
()
>
0
)
{
JSONArray
array
=
json
.
getJSONArray
(
"params"
);
JSONArray
array
=
json
.
getJSONArray
(
"params"
);
if
(
array
!=
null
&&
array
.
size
()
>
0
)
{
if
(
array
!=
null
&&
array
.
size
()
>
0
)
{
List
<
String
>
devIds
=
new
ArrayList
<>();
for
(
Object
o
:
array
)
{
JSONArray
jsonArray
=
JSONUtil
.
parseArray
(
o
);
devIds
.
add
(
jsonArray
.
getStr
(
0
));
}
// 设备信息查询
LambdaQueryWrapper
<
Device
>
queryWrapper
=
new
LambdaQueryWrapper
();
queryWrapper
.
in
(
Device:
:
getDevId
,
devIds
);
List
<
Device
>
deviceList
=
deviceMapper
.
selectList
(
queryWrapper
);
// 将List转换为Map
Map
<
String
,
Device
>
map
=
deviceList
.
stream
()
.
collect
(
Collectors
.
toMap
(
Device:
:
getDevId
,
Function
.
identity
()));
// 设备操作日志(最近3分钟内的最新操作日志)
Date
startDate
=
DateUtil
.
offsetMinute
(
DateUtil
.
date
(),
-
3
);
List
<
DeviceLog
>
deviceLogList
=
deviceLogMapper
.
selectListByMaxId
(
devIds
,
startDate
);
// 将List转换为Map
Map
<
String
,
DeviceLog
>
deviceLogMap
=
deviceLogList
.
stream
()
.
collect
(
Collectors
.
toMap
(
DeviceLog:
:
getDevId
,
Function
.
identity
()));
// 判断设备状态是否变更
List
<
DeviceStatusLog
>
statusLogs
=
new
ArrayList
<>();
// 设备信息
List
<
Device
>
list
=
new
ArrayList
<>();
List
<
Device
>
list
=
new
ArrayList
<>();
for
(
Object
o
:
array
)
{
for
(
Object
o
:
array
)
{
// 默认离线
String
status
=
DeviceStatusEnum
.
DEVICE_OFFLINE
.
getCode
();
JSONArray
jsonArray
=
JSONUtil
.
parseArray
(
o
);
JSONArray
jsonArray
=
JSONUtil
.
parseArray
(
o
);
String
devId
=
jsonArray
.
getStr
(
0
);
// 当前数据库设备信息
Device
dev
=
map
.
get
(
devId
);
String
statusStr
=
jsonArray
.
getStr
(
3
);
// 十进制转二进制
int
decimal
=
Integer
.
parseInt
(
statusStr
);
String
binary
=
Integer
.
toBinaryString
(
decimal
);
String
[]
binaryArray
=
binary
.
split
(
"(?<=\\G.)"
);
if
(
binaryArray
.
length
>
0
)
{
String
bit0
=
binaryArray
[
0
];
if
(
"1"
.
equals
(
bit0
))
{
if
(
binaryArray
.
length
>
2
)
{
String
bit2
=
binaryArray
[
2
];
if
(
"1"
.
equals
(
bit2
))
{
status
=
DeviceStatusEnum
.
DEVICE_ENERGIZE
.
getCode
();
}
else
{
status
=
DeviceStatusEnum
.
DEVICE_OUTAGE
.
getCode
();
}
}
else
if
(
dev
!=
null
){
// 设备类型判断
if
(
DeviceType
.
DEVICE_0001
.
getCode
().
equals
(
dev
.
getDevType
()))
{
status
=
DeviceStatusEnum
.
DEVICE_OUTAGE
.
getCode
();
}
else
if
(
DeviceType
.
DEVICE_CCEE
.
getCode
().
equals
(
dev
.
getDevType
()))
{
status
=
DeviceStatusEnum
.
DEVICE_ONLINE
.
getCode
();
}
}
}
}
if
(
dev
!=
null
&&
!
status
.
equals
(
dev
.
getStatus
()))
{
DeviceStatusLog
deviceStatusLog
=
new
DeviceStatusLog
();
deviceStatusLog
.
setDevId
(
devId
);
deviceStatusLog
.
setDevMac
(
dev
.
getDevMac
());
deviceStatusLog
.
setRoomId
(
dev
.
getRoomId
());
deviceStatusLog
.
setSignalValue
(
jsonArray
.
getStr
(
1
));
deviceStatusLog
.
setVoltage
(
jsonArray
.
getStr
(
2
));
deviceStatusLog
.
setStatus
(
status
);
deviceStatusLog
.
setPreviousStatus
(
dev
.
getStatus
());
deviceStatusLog
.
setCreateTime
(
DateUtils
.
getNowDate
());
deviceStatusLog
.
setIsSendSms
(
YesNoEnum
.
no
.
getIndex
());
deviceStatusLog
.
setIsAbnormal
(
YesNoEnum
.
no
.
getIndex
());
if
(
DeviceStatusEnum
.
DEVICE_OFFLINE
.
getCode
().
equals
(
status
))
{
// 变更设备为离线状态
deviceStatusLog
.
setIsAbnormal
(
YesNoEnum
.
yes
.
getIndex
());
}
else
{
DeviceLog
deviceLog
=
deviceLogMap
.
get
(
devId
);
if
(
deviceLog
!=
null
)
{
deviceStatusLog
.
setOperateLogId
(
deviceLog
.
getId
());
if
(
DeviceType
.
DEVICE_0001
.
getCode
().
equals
(
dev
.
getDevType
()))
{
if
(!
DeviceStatusEnum
.
getNameStr
(
status
).
equals
(
deviceLog
.
getMqttDescribe
()))
{
// 平台3分钟内最新操作类型与设备变更状态不匹配
deviceStatusLog
.
setIsAbnormal
(
YesNoEnum
.
yes
.
getIndex
());
}
}
}
else
{
// 异常设备状态变更,非平台操作变更
deviceStatusLog
.
setIsAbnormal
(
YesNoEnum
.
yes
.
getIndex
());
}
}
statusLogs
.
add
(
deviceStatusLog
);
}
// 更新设备信息
Device
device
=
new
Device
();
Device
device
=
new
Device
();
device
.
setDevId
(
jsonArray
.
get
(
0
).
toString
()
);
device
.
setDevId
(
devId
);
device
.
setSignalValue
(
jsonArray
.
get
(
1
).
toString
(
));
device
.
setSignalValue
(
jsonArray
.
get
Str
(
1
));
device
.
setVoltage
(
jsonArray
.
get
(
2
).
toString
(
));
device
.
setVoltage
(
jsonArray
.
get
Str
(
2
));
device
.
setStatus
(
jsonArray
.
get
(
3
).
toString
()
);
device
.
setStatus
(
status
);
device
.
setUpdateTime
(
DateUtils
.
getNowDate
());
device
.
setUpdateTime
(
DateUtils
.
getNowDate
());
list
.
add
(
device
);
list
.
add
(
device
);
}
}
// 插入设备变更记录
deviceStatusLogService
.
saveBatch
(
statusLogs
);
return
0
<
deviceMapper
.
updateBatch
(
list
);
return
0
<
deviceMapper
.
updateBatch
(
list
);
}
}
}
}
...
...
share-system/src/main/java/share/system/service/impl/SmsServiceImpl.java
View file @
a38cc7f2
...
@@ -10,14 +10,12 @@ import org.springframework.beans.factory.annotation.Value;
...
@@ -10,14 +10,12 @@ import org.springframework.beans.factory.annotation.Value;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
share.common.constant.Constants
;
import
share.common.constant.Constants
;
import
share.common.core.redis.RedisUtil
;
import
share.common.core.redis.RedisUtil
;
import
share.common.enums.DeviceStatusEnum
;
import
share.common.enums.SmsTypeEnum
;
import
share.common.enums.SmsTypeEnum
;
import
share.common.exception.base.BaseException
;
import
share.common.exception.base.BaseException
;
import
share.common.utils.BaseUtil
;
import
share.common.utils.BaseUtil
;
import
share.common.utils.SmsUtil
;
import
share.common.utils.SmsUtil
;
import
share.system.domain.SRoom
;
import
share.system.domain.*
;
import
share.system.domain.SStore
;
import
share.system.domain.SmsLog
;
import
share.system.domain.SysConfig
;
import
share.system.mapper.SysConfigMapper
;
import
share.system.mapper.SysConfigMapper
;
import
share.system.service.SConsumerService
;
import
share.system.service.SConsumerService
;
import
share.system.service.SmsLogService
;
import
share.system.service.SmsLogService
;
...
@@ -157,6 +155,19 @@ public class SmsServiceImpl implements SmsService {
...
@@ -157,6 +155,19 @@ public class SmsServiceImpl implements SmsService {
}
}
}
}
@Override
public
boolean
sendSmsDeviceAbnormal
(
String
phone
,
DeviceStatusLog
deviceStatusLog
,
SStore
store
,
SRoom
room
)
{
// 通过配置获取短信模版
SysConfig
config
=
sysConfigMapper
.
checkConfigKeyUnique
(
SmsTypeEnum
.
SMS_DEVICE_ABNORMAL_TEMP
.
getValue
());
if
(
config
!=
null
)
{
String
content
=
MessageFormat
.
format
(
config
.
getConfigValue
(),
store
.
getName
(),
room
.
getName
(),
DeviceStatusEnum
.
getNameStr
(
deviceStatusLog
.
getStatus
()));
return
sendSms
(
phone
,
SmsTypeEnum
.
SMS_DEVICE_ABNORMAL_TEMP
.
getCode
(),
content
);
}
else
{
return
Boolean
.
FALSE
;
}
}
private
String
getSmsContent
(
String
phone
,
Integer
tag
)
{
private
String
getSmsContent
(
String
phone
,
Integer
tag
)
{
// 验证码 特殊处理 code
// 验证码 特殊处理 code
if
(
tag
.
equals
(
SmsTypeEnum
.
SMS_CODE_TEMP
.
getCode
()))
{
if
(
tag
.
equals
(
SmsTypeEnum
.
SMS_CODE_TEMP
.
getCode
()))
{
...
...
share-system/src/main/resources/mapper/system/DeviceLogMapper.xml
View file @
a38cc7f2
...
@@ -42,7 +42,23 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
...
@@ -42,7 +42,23 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<include
refid=
"selectDeviceLogVo"
/>
<include
refid=
"selectDeviceLogVo"
/>
where id = #{id}
where id = #{id}
</select>
</select>
<select
id=
"selectListByMaxId"
resultMap=
"DeviceLogResult"
>
SELECT t1.id, t1.dev_mac, t1.dev_id, t1.seq, t1.mqtt_type, t1.mqtt_describe, t1.payload, t1.topic,
t1.create_by, t1.create_time, t1.update_by, t1.update_time, t1.remark
FROM s_device_log t1
JOIN (
SELECT MAX(id) AS max_id
FROM s_device_log
where mqtt_describe in ('开门','关门','取电','断电')
and create_time > #{startDate}
and dev_id in
<foreach
collection=
"devIds"
item=
"devId"
separator=
","
open=
"("
close=
")"
>
#{devId}
</foreach>
GROUP BY dev_id
) t2 ON t1.id = t2.max_id
</select>
<insert
id=
"insertDeviceLog"
parameterType=
"DeviceLog"
useGeneratedKeys=
"true"
keyProperty=
"id"
>
<insert
id=
"insertDeviceLog"
parameterType=
"DeviceLog"
useGeneratedKeys=
"true"
keyProperty=
"id"
>
insert into s_device_log
insert into s_device_log
<trim
prefix=
"("
suffix=
")"
suffixOverrides=
","
>
<trim
prefix=
"("
suffix=
")"
suffixOverrides=
","
>
...
...
share-system/src/main/resources/mapper/system/DeviceStatusLogMapper.xml
0 → 100644
View file @
a38cc7f2
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper
namespace=
"share.system.mapper.DeviceStatusLogMapper"
>
<resultMap
type=
"DeviceStatusLog"
id=
"DeviceStatusLogResult"
>
<result
property=
"id"
column=
"id"
/>
<result
property=
"devId"
column=
"dev_id"
/>
<result
property=
"devMac"
column=
"dev_mac"
/>
<result
property=
"isAbnormal"
column=
"is_abnormal"
/>
<result
property=
"status"
column=
"status"
/>
<result
property=
"roomId"
column=
"room_id"
/>
<result
property=
"voltage"
column=
"voltage"
/>
<result
property=
"signalValue"
column=
"signal_value"
/>
<result
property=
"createTime"
column=
"create_time"
/>
<result
property=
"updateTime"
column=
"update_time"
/>
<result
property=
"remark"
column=
"remark"
/>
<result
property=
"operateLogId"
column=
"operate_log_id"
/>
<result
property=
"isSendSms"
column=
"is_send_sms"
/>
<result
property=
"previousStatus"
column=
"previous_status"
/>
</resultMap>
<sql
id=
"selectDeviceStatusLogVo"
>
select id, dev_id, dev_mac, is_abnormal, status, room_id, voltage, signal_value, create_time, update_time,
remark, operate_log_id, is_send_sms, previous_status from s_device_status_log
</sql>
<select
id=
"selectDeviceStatusLogList"
parameterType=
"DeviceStatusLog"
resultMap=
"DeviceStatusLogResult"
>
<include
refid=
"selectDeviceStatusLogVo"
/>
<where>
<if
test=
"devId != null and devId != ''"
>
and dev_id = #{devId}
</if>
<if
test=
"devMac != null and devMac != ''"
>
and dev_mac = #{devMac}
</if>
<if
test=
"isAbnormal != null "
>
and is_abnormal = #{isAbnormal}
</if>
<if
test=
"status != null and status != ''"
>
and status = #{status}
</if>
<if
test=
"roomId != null "
>
and room_id = #{roomId}
</if>
<if
test=
"voltage != null and voltage != ''"
>
and voltage = #{voltage}
</if>
<if
test=
"signalValue != null and signalValue != ''"
>
and signal_value = #{signalValue}
</if>
<if
test=
"operateLogId != null "
>
and operate_log_id = #{operateLogId}
</if>
<if
test=
"isSendSms != null "
>
and is_send_sms = #{isSendSms}
</if>
</where>
order by create_time desc
</select>
<select
id=
"selectDeviceStatusLogById"
parameterType=
"Long"
resultMap=
"DeviceStatusLogResult"
>
<include
refid=
"selectDeviceStatusLogVo"
/>
where id = #{id}
</select>
<insert
id=
"insertDeviceStatusLog"
parameterType=
"DeviceStatusLog"
>
insert into s_device_status_log
<trim
prefix=
"("
suffix=
")"
suffixOverrides=
","
>
<if
test=
"id != null"
>
id,
</if>
<if
test=
"devId != null"
>
dev_id,
</if>
<if
test=
"devMac != null"
>
dev_mac,
</if>
<if
test=
"isAbnormal != null"
>
is_abnormal,
</if>
<if
test=
"status != null"
>
status,
</if>
<if
test=
"roomId != null"
>
room_id,
</if>
<if
test=
"voltage != null"
>
voltage,
</if>
<if
test=
"signalValue != null"
>
signal_value,
</if>
<if
test=
"createTime != null"
>
create_time,
</if>
<if
test=
"updateTime != null"
>
update_time,
</if>
<if
test=
"remark != null"
>
remark,
</if>
<if
test=
"operateLogId != null"
>
operate_log_id,
</if>
<if
test=
"isSendSms != null"
>
is_send_sms,
</if>
<if
test=
"previousStatus != null"
>
previous_status,
</if>
</trim>
<trim
prefix=
"values ("
suffix=
")"
suffixOverrides=
","
>
<if
test=
"id != null"
>
#{id},
</if>
<if
test=
"devId != null"
>
#{devId},
</if>
<if
test=
"devMac != null"
>
#{devMac},
</if>
<if
test=
"isAbnormal != null"
>
#{isAbnormal},
</if>
<if
test=
"status != null"
>
#{status},
</if>
<if
test=
"roomId != null"
>
#{roomId},
</if>
<if
test=
"voltage != null"
>
#{voltage},
</if>
<if
test=
"signalValue != null"
>
#{signalValue},
</if>
<if
test=
"createTime != null"
>
#{createTime},
</if>
<if
test=
"updateTime != null"
>
#{updateTime},
</if>
<if
test=
"remark != null"
>
#{remark},
</if>
<if
test=
"operateLogId != null"
>
#{operateLogId},
</if>
<if
test=
"isSendSms != null"
>
#{isSendSms},
</if>
<if
test=
"previousStatus != null"
>
#{previousStatus},
</if>
</trim>
</insert>
<update
id=
"updateDeviceStatusLog"
parameterType=
"DeviceStatusLog"
>
update s_device_status_log
<trim
prefix=
"SET"
suffixOverrides=
","
>
<if
test=
"devId != null"
>
dev_id = #{devId},
</if>
<if
test=
"devMac != null"
>
dev_mac = #{devMac},
</if>
<if
test=
"isAbnormal != null"
>
is_abnormal = #{isAbnormal},
</if>
<if
test=
"status != null"
>
status = #{status},
</if>
<if
test=
"roomId != null"
>
room_id = #{roomId},
</if>
<if
test=
"voltage != null"
>
voltage = #{voltage},
</if>
<if
test=
"signalValue != null"
>
signal_value = #{signalValue},
</if>
<if
test=
"createTime != null"
>
create_time = #{createTime},
</if>
<if
test=
"updateTime != null"
>
update_time = #{updateTime},
</if>
<if
test=
"remark != null"
>
remark = #{remark},
</if>
<if
test=
"operateLogId != null"
>
operate_log_id = #{operateLogId},
</if>
<if
test=
"isSendSms != null"
>
is_send_sms = #{isSendSms},
</if>
<if
test=
"previousStatus != null"
>
previous_status = #{previousStatus},
</if>
</trim>
where id = #{id}
</update>
<delete
id=
"deleteDeviceStatusLogById"
parameterType=
"Long"
>
delete from s_device_status_log where id = #{id}
</delete>
<delete
id=
"deleteDeviceStatusLogByIds"
parameterType=
"String"
>
delete from s_device_status_log where id in
<foreach
item=
"id"
collection=
"array"
open=
"("
separator=
","
close=
")"
>
#{id}
</foreach>
</delete>
</mapper>
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment