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
673d8bb6
Commit
673d8bb6
authored
Jan 17, 2024
by
wuwenlong
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'dev' into test
parents
81c8f97b
513d2852
Hide whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
384 additions
and
65 deletions
+384
-65
SmsStatusEnum.java
...ommon/src/main/java/share/common/enums/SmsStatusEnum.java
+73
-0
SmsTypeEnum.java
...-common/src/main/java/share/common/enums/SmsTypeEnum.java
+1
-1
SmsUtil.java
share-common/src/main/java/share/common/utils/SmsUtil.java
+49
-29
DeviceTask.java
share-quartz/src/main/java/share/quartz/task/DeviceTask.java
+15
-0
DeviceGateway.java
...stem/src/main/java/share/system/domain/DeviceGateway.java
+10
-0
DeviceLog.java
...e-system/src/main/java/share/system/domain/DeviceLog.java
+19
-0
DeviceStatusLog.java
...em/src/main/java/share/system/domain/DeviceStatusLog.java
+12
-0
DeviceGatewayService.java
.../main/java/share/system/service/DeviceGatewayService.java
+7
-0
DeviceGatewayServiceImpl.java
...a/share/system/service/impl/DeviceGatewayServiceImpl.java
+25
-0
DeviceLogServiceImpl.java
.../java/share/system/service/impl/DeviceLogServiceImpl.java
+44
-2
DeviceStatusLogServiceImpl.java
...share/system/service/impl/DeviceStatusLogServiceImpl.java
+27
-1
MqttxServiceImpl.java
...main/java/share/system/service/impl/MqttxServiceImpl.java
+21
-5
SmsServiceImpl.java
...c/main/java/share/system/service/impl/SmsServiceImpl.java
+52
-23
DeviceGatewayMapper.xml
.../src/main/resources/mapper/system/DeviceGatewayMapper.xml
+12
-1
DeviceLogMapper.xml
...stem/src/main/resources/mapper/system/DeviceLogMapper.xml
+15
-3
SaobeiApiLogMapper.xml
...m/src/main/resources/mapper/system/SaobeiApiLogMapper.xml
+1
-0
SmsLogMapper.xml
...-system/src/main/resources/mapper/system/SmsLogMapper.xml
+1
-0
No files found.
share-common/src/main/java/share/common/enums/SmsStatusEnum.java
0 → 100644
View file @
673d8bb6
package
share
.
common
.
enums
;
import
cn.hutool.core.util.StrUtil
;
/**
* @className: share.common.enums.SmsStatusEnum
* @description: 短信返回状态
* @author: lwj
* @create: 2024-01-17 10:45
*/
public
enum
SmsStatusEnum
{
SMS_STATUS_0
(
0
,
"成功"
),
SMS_STATUS_2
(
2
,
"IP错误"
),
SMS_STATUS_3
(
3
,
"账号密码错误"
),
SMS_STATUS_5
(
5
,
"其它错误"
),
SMS_STATUS_6
(
5
,
"接入点错误"
),
SMS_STATUS_7
(
7
,
"账号状态异常"
),
SMS_STATUS_11
(
11
,
"系统内部错误,请联系管理员"
),
SMS_STATUS_30
(
30
,
"action=statis时:endTime<begin或 endTime-beginTime>180,结束时间不能小于开始时间,间隔不能大于180天; action=select时:date错, date大于当天日期, date不在过去180天内"
),
SMS_STATUS_31
(
31
,
"action=templateAdd或action=templateDelete时操作过于频繁,建议每10秒操作一次"
),
SMS_STATUS_32
(
32
,
"condition错,只能为APMID或MOBILE"
),
SMS_STATUS_33
(
33
,
"值列表过多,最多只能1000"
),
SMS_STATUS_34
(
34
,
"请求参数有误"
),
SMS_STATUS_35
(
35
,
"mobileEencryptionMode=aes时,解析后的正确号码数为0"
),
SMS_STATUS_36
(
36
,
"未找到模板"
),
SMS_STATUS_37
(
37
,
"模板状态有误"
),
SMS_STATUS_38
(
38
,
"模板时间不允许"
),
SMS_STATUS_39
(
39
,
"不支持此接口"
),
SMS_STATUS_100
(
100
,
"系统内部错误,请联系管理员"
),
// SMS_RESULT_0(0, "成功"),
SMS_RESULT_10
(
10
,
"原发号码错误,即extno错误"
),
SMS_RESULT_15
(
15
,
"余额不足"
),
// SMS_RESULT_100(100, "系统内部错误,请联系管理员"),
;
private
Integer
code
;
private
String
name
;
SmsStatusEnum
(
Integer
code
,
String
name
)
{
this
.
code
=
code
;
this
.
name
=
name
;
}
public
static
String
getNameStr
(
Integer
code
)
{
if
(
code
!=
null
)
{
for
(
SmsStatusEnum
statusEnum
:
SmsStatusEnum
.
values
())
{
if
(
statusEnum
.
code
.
equals
(
code
))
{
return
statusEnum
.
name
;
}
}
}
return
""
;
}
public
Integer
getCode
()
{
return
code
;
}
public
void
setCode
(
Integer
code
)
{
this
.
code
=
code
;
}
public
String
getName
()
{
return
name
;
}
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
}
share-common/src/main/java/share/common/enums/SmsTypeEnum.java
View file @
673d8bb6
...
...
@@ -12,7 +12,7 @@ public enum SmsTypeEnum {
SMS_CLEAN_RECORDS_TEMP
(
2
,
"sms.clean.records.template"
,
"保洁任务短信提示"
),
SMS_CLEAN_RECORDS_TEMP_15
(
3
,
"sms.clean.records.template.15"
,
"即将保洁任务短信提醒"
),
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_DEVICE_ABNORMAL_TEMP
(
7
,
"sms.device.abnormal.template"
,
"设备状态异常变更短信提醒"
),
;
...
...
share-common/src/main/java/share/common/utils/SmsUtil.java
View file @
673d8bb6
...
...
@@ -3,8 +3,10 @@ package share.common.utils;
import
cn.hutool.core.date.DateUtil
;
import
cn.hutool.core.util.StrUtil
;
import
cn.hutool.crypto.SecureUtil
;
import
cn.hutool.json.JSONArray
;
import
cn.hutool.json.JSONObject
;
import
cn.hutool.json.JSONUtil
;
import
lombok.SneakyThrows
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.http.HttpEntity
;
import
org.springframework.http.HttpHeaders
;
...
...
@@ -16,6 +18,7 @@ import share.common.utils.http.RestTemplateUtil;
import
share.common.exception.base.BaseException
;
import
java.text.MessageFormat
;
import
java.util.concurrent.CompletableFuture
;
/**
* @author wuwenlong
...
...
@@ -47,9 +50,6 @@ public class SmsUtil {
if
(
result
==
null
)
{
throw
new
BaseException
(
"短信平台接口异常!"
);
}
if
(!
SmsConts
.
SUCCESS_CODE
.
equals
(
result
.
getInt
(
"status"
)))
{
throw
new
BaseException
(
"短信平台接口: "
+
result
.
getStr
(
"status"
));
}
return
result
;
}
...
...
@@ -69,34 +69,54 @@ public class SmsUtil {
return
SecureUtil
.
md5
(
StrUtil
.
concat
(
true
,
password
,
extno
,
mobile
,
content
));
}
public
static
void
main
(
String
[]
args
)
{
Integer
code
=
BaseUtil
.
randomCount
(
111111
,
999999
);
String
content
=
MessageFormat
.
format
(
SmsConts
.
smsCodeTemp
,
code
.
toString
(),
"5"
);
// 发送内容添加短信签名
String
smsContent
=
StrUtil
.
concat
(
true
,
"【凑角】"
,
content
);
String
mobile
=
"13724108012"
;
JSONObject
param
=
JSONUtil
.
createObj
();
param
.
put
(
"action"
,
"send"
);
param
.
put
(
"account"
,
"799243"
);
param
.
put
(
"password"
,
SecureUtil
.
md5
(
StrUtil
.
concat
(
true
,
"RjaI8uA"
,
"10690"
,
mobile
,
smsContent
)));
// param.put("password","RjaI8uA");
param
.
put
(
"mobile"
,
mobile
);
// param.put("mobileEencryptionMode", "");
param
.
put
(
"content"
,
smsContent
);
param
.
put
(
"extno"
,
"10690"
);
// param.put("atTime", "");
System
.
out
.
println
(
JSONUtil
.
toJsonStr
(
param
));
HttpHeaders
headers
=
new
HttpHeaders
();
headers
.
setContentType
(
MediaType
.
APPLICATION_JSON_UTF8
);
headers
.
add
(
"user-agent"
,
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.99 Safari/537.36"
);
headers
.
add
(
"Accept"
,
MediaType
.
APPLICATION_JSON
.
toString
());
public
static
void
main
(
String
[]
args
)
{
// Integer code = BaseUtil.randomCount(111111, 999999);
// String content = MessageFormat.format(SmsConts.smsCodeTemp, code.toString(), "5");
// // 发送内容添加短信签名
// String smsContent = StrUtil.concat(true, "【凑角】", content);
// String mobile = "13724108012";
// JSONObject param = JSONUtil.createObj();
// param.put("action", "send");
// param.put("account", "799243");
// param.put("password", SecureUtil.md5(StrUtil.concat(true, "RjaI8uA", "10690", mobile, smsContent)));
//// param.put("password","RjaI8uA");
// param.put("mobile", mobile);
//// param.put("mobileEencryptionMode", "");
// param.put("content", smsContent);
// param.put("extno", "10690");
//// param.put("atTime", "");
// System.out.println(JSONUtil.toJsonStr(param));
// HttpHeaders headers = new HttpHeaders();
//
// headers.setContentType(MediaType.APPLICATION_JSON_UTF8);
// headers.add("user-agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.99 Safari/537.36");
//
// headers.add("Accept", MediaType.APPLICATION_JSON.toString());
//
// HttpEntity<JSONObject> requestEntity = new HttpEntity<>(param, headers);
// RestTemplate restTemplate = new RestTemplate();
// cn.hutool.json.JSONObject body = restTemplate.postForEntity("http://121.36.230.249:7862/smsv2", requestEntity, cn.hutool.json.JSONObject.class).getBody();
// System.out.println(JSONUtil.toJsonStr(body));
CompletableFuture
<
String
>
future
=
CompletableFuture
.
supplyAsync
(()
->
{
// 模拟长时间运行的操作
try
{
Thread
.
sleep
(
2000
);
System
.
out
.
println
(
"hello h2t111"
);
}
catch
(
InterruptedException
e
)
{
e
.
printStackTrace
();
}
return
"Result: "
+
111
;
});
// System.out.println(future.join());
System
.
out
.
println
(
"future.join()"
);
try
{
Thread
.
sleep
(
4000
);
System
.
out
.
println
(
"hello h2t2211"
);
}
catch
(
InterruptedException
e
)
{
e
.
printStackTrace
();
}
HttpEntity
<
JSONObject
>
requestEntity
=
new
HttpEntity
<>(
param
,
headers
);
RestTemplate
restTemplate
=
new
RestTemplate
();
cn
.
hutool
.
json
.
JSONObject
body
=
restTemplate
.
postForEntity
(
"http://121.36.230.249:7862/smsv2"
,
requestEntity
,
cn
.
hutool
.
json
.
JSONObject
.
class
).
getBody
();
System
.
out
.
println
(
JSONUtil
.
toJsonStr
(
body
));
}
}
share-quartz/src/main/java/share/quartz/task/DeviceTask.java
View file @
673d8bb6
...
...
@@ -2,6 +2,7 @@ package share.quartz.task;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
share.system.service.DeviceGatewayService
;
import
share.system.service.DeviceStatusLogService
;
/**
...
...
@@ -15,12 +16,26 @@ public class DeviceTask {
@Autowired
private
DeviceStatusLogService
deviceStatusLogService
;
@Autowired
private
DeviceGatewayService
deviceGatewayService
;
/**
* 设备异常状态短信提醒任务
*/
public
void
sendSmsByYc
()
{
// 设备状态异常变更发送短信
deviceStatusLogService
.
sendSmsByYc
();
}
/**
* 设备网关状态监控
*/
public
void
deviceGatewayStatusMonitor
()
{
// 更新网关状态
boolean
b
=
deviceGatewayService
.
deviceGatewayStatusMonitor
();
if
(
b
)
{
// 离线网关,发送短信提醒
}
}
}
share-system/src/main/java/share/system/domain/DeviceGateway.java
View file @
673d8bb6
...
...
@@ -6,6 +6,9 @@ import org.apache.commons.lang3.builder.ToStringStyle;
import
share.common.annotation.Excel
;
import
share.common.core.domain.BaseEntity
;
import
lombok.Data
;
import
java.util.Date
;
/**
* 设备网关信息对象 s_device_gateway
*
...
...
@@ -48,10 +51,12 @@ public class DeviceGateway extends BaseEntity
/** 网络分组 */
@Excel
(
name
=
"网络分组"
)
@TableField
(
value
=
"`group`"
)
private
String
group
;
/** 设备状态 */
@Excel
(
name
=
"设备状态"
)
@TableField
(
value
=
"`status`"
)
private
String
status
;
/** mqtt服务器IP/域名 */
...
...
@@ -74,6 +79,11 @@ public class DeviceGateway extends BaseEntity
@Excel
(
name
=
"设备位置"
)
private
String
devPosition
;
/** 网关最后上报时间 */
private
Date
lastReportDate
;
/** 网关最后上报内容 */
private
String
lastReportContent
;
@Override
public
String
toString
()
{
...
...
share-system/src/main/java/share/system/domain/DeviceLog.java
View file @
673d8bb6
...
...
@@ -50,6 +50,25 @@ public class DeviceLog extends BaseEntity
@Excel
(
name
=
"消息主题"
)
private
String
topic
;
@Excel
(
name
=
"消息回复结果"
)
@TableField
(
value
=
"`result`"
)
private
String
result
;
@Excel
(
name
=
"描述"
)
private
String
description
;
/**
* 房间名称
*/
@TableField
(
exist
=
false
)
private
String
roomName
;
/**
* 门店名称
*/
@TableField
(
exist
=
false
)
private
String
storeName
;
@Override
public
String
toString
()
{
...
...
share-system/src/main/java/share/system/domain/DeviceStatusLog.java
View file @
673d8bb6
...
...
@@ -79,6 +79,18 @@ public class DeviceStatusLog implements Serializable
/** 备注 */
private
String
remark
;
/**
* 房间名称
*/
@TableField
(
exist
=
false
)
private
String
roomName
;
/**
* 门店名称
*/
@TableField
(
exist
=
false
)
private
String
storeName
;
@Override
public
String
toString
()
{
...
...
share-system/src/main/java/share/system/service/DeviceGatewayService.java
View file @
673d8bb6
...
...
@@ -59,4 +59,11 @@ public interface DeviceGatewayService extends IService<DeviceGateway>
* @return 结果
*/
public
int
deleteDeviceGatewayById
(
Long
id
);
/**
* 网关状态监控
* @return
*/
boolean
deviceGatewayStatusMonitor
();
}
share-system/src/main/java/share/system/service/impl/DeviceGatewayServiceImpl.java
View file @
673d8bb6
package
share
.
system
.
service
.
impl
;
import
java.util.Date
;
import
java.util.List
;
import
cn.hutool.core.date.DateUtil
;
import
com.baomidou.mybatisplus.core.conditions.Wrapper
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
share.common.enums.DeviceStatusEnum
;
import
share.common.utils.DateUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
...
...
@@ -94,4 +99,24 @@ public class DeviceGatewayServiceImpl extends ServiceImpl<DeviceGatewayMapper, D
{
return
deviceGatewayMapper
.
deleteDeviceGatewayById
(
id
);
}
/**
* 网关状态监控
* @return
*/
@Override
public
boolean
deviceGatewayStatusMonitor
()
{
List
<
DeviceGateway
>
list
=
deviceGatewayMapper
.
selectDeviceGatewayList
(
new
DeviceGateway
());
list
.
stream
().
forEach
(
gateway
->
{
Date
lastReportDate
=
gateway
.
getLastReportDate
();
// 网关上报(最近10分钟内没有上报数据,网关设备离线)
Date
startDate
=
DateUtil
.
offsetMinute
(
DateUtil
.
date
(),
-
10
);
if
(
lastReportDate
!=
null
&&
lastReportDate
.
compareTo
(
startDate
)
>
0
)
{
gateway
.
setStatus
(
DeviceStatusEnum
.
DEVICE_ONLINE
.
getCode
());
}
else
{
gateway
.
setStatus
(
DeviceStatusEnum
.
DEVICE_OFFLINE
.
getCode
());
}
});
return
this
.
updateBatchById
(
list
);
}
}
share-system/src/main/java/share/system/service/impl/DeviceLogServiceImpl.java
View file @
673d8bb6
package
share
.
system
.
service
.
impl
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.stream.Collectors
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
share.common.utils.DateUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
share.common.utils.SecurityUtils
;
import
share.system.domain.*
;
import
share.system.domain.vo.MqttxVo
;
import
share.system.mapper.DeviceLogMapper
;
import
share.system.domain.DeviceLog
;
import
share.system.mapper.DeviceMapper
;
import
share.system.mapper.SRoomMapper
;
import
share.system.mapper.SStoreMapper
;
import
share.system.service.DeviceLogService
;
/**
...
...
@@ -22,6 +29,12 @@ public class DeviceLogServiceImpl extends ServiceImpl<DeviceLogMapper, DeviceLog
{
@Autowired
private
DeviceLogMapper
deviceLogMapper
;
@Autowired
private
SRoomMapper
roomMapper
;
@Autowired
private
SStoreMapper
storeMapper
;
@Autowired
private
DeviceMapper
deviceMapper
;
/**
* 查询设备操作日志
...
...
@@ -44,7 +57,36 @@ public class DeviceLogServiceImpl extends ServiceImpl<DeviceLogMapper, DeviceLog
@Override
public
List
<
DeviceLog
>
selectDeviceLogList
(
DeviceLog
deviceLog
)
{
return
deviceLogMapper
.
selectDeviceLogList
(
deviceLog
);
List
<
DeviceLog
>
list
=
deviceLogMapper
.
selectDeviceLogList
(
deviceLog
);
if
(
list
.
size
()
>
0
)
{
List
<
String
>
devIds
=
list
.
stream
().
map
(
DeviceLog:
:
getDevId
).
collect
(
Collectors
.
toList
());
// 设备信息查询
LambdaQueryWrapper
<
Device
>
queryDeviceWrapper
=
new
LambdaQueryWrapper
();
queryDeviceWrapper
.
in
(
Device:
:
getDevId
,
devIds
);
List
<
Device
>
deviceList
=
deviceMapper
.
selectList
(
queryDeviceWrapper
);
// 提取roomId,方便批量查询
List
<
Long
>
roomIds
=
deviceList
.
stream
().
map
(
Device:
:
getRoomId
).
collect
(
Collectors
.
toList
());
Map
<
String
,
Long
>
deviceRoomMap
=
deviceList
.
stream
().
collect
(
Collectors
.
toMap
(
Device:
:
getDevId
,
Device:
:
getRoomId
));
if
(
roomIds
!=
null
&&
roomIds
.
size
()
>
0
)
{
// 房间信息查询
LambdaQueryWrapper
<
SRoom
>
queryWrapper
=
new
LambdaQueryWrapper
();
queryWrapper
.
in
(
SRoom:
:
getId
,
roomIds
);
List
<
SRoom
>
roomList
=
roomMapper
.
selectList
(
queryWrapper
);
Map
<
Long
,
String
>
roomMap
=
roomList
.
stream
().
collect
(
Collectors
.
toMap
(
SRoom:
:
getId
,
SRoom:
:
getName
));
Map
<
Long
,
Long
>
roomStoreMap
=
roomList
.
stream
().
collect
(
Collectors
.
toMap
(
SRoom:
:
getId
,
SRoom:
:
getStoreId
));
// 门店信息查询
List
<
Long
>
storeIds
=
roomList
.
stream
().
map
(
SRoom:
:
getStoreId
).
collect
(
Collectors
.
toList
());
LambdaQueryWrapper
<
SStore
>
queryStoreWrapper
=
new
LambdaQueryWrapper
();
queryStoreWrapper
.
in
(
SStore:
:
getId
,
storeIds
);
List
<
SStore
>
storeList
=
storeMapper
.
selectList
(
queryStoreWrapper
);
Map
<
Long
,
String
>
storeMap
=
storeList
.
stream
().
collect
(
Collectors
.
toMap
(
SStore:
:
getId
,
SStore:
:
getName
));
list
.
stream
().
forEach
(
log
->
{
log
.
setRoomName
(
roomMap
.
get
(
deviceRoomMap
.
get
(
log
.
getDevId
())));
log
.
setStoreName
(
storeMap
.
get
(
roomStoreMap
.
get
(
deviceRoomMap
.
get
(
log
.
getDevId
()))));
});
}
}
return
list
;
}
/**
...
...
share-system/src/main/java/share/system/service/impl/DeviceStatusLogServiceImpl.java
View file @
673d8bb6
package
share
.
system
.
service
.
impl
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Set
;
import
java.util.stream.Collectors
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
...
...
@@ -58,7 +61,30 @@ public class DeviceStatusLogServiceImpl extends ServiceImpl<DeviceStatusLogMappe
@Override
public
List
<
DeviceStatusLog
>
selectDeviceStatusLogList
(
DeviceStatusLog
deviceStatusLog
)
{
return
deviceStatusLogMapper
.
selectDeviceStatusLogList
(
deviceStatusLog
);
List
<
DeviceStatusLog
>
list
=
deviceStatusLogMapper
.
selectDeviceStatusLogList
(
deviceStatusLog
);
if
(
list
.
size
()
>
0
)
{
// 提取roomId,方便批量查询
List
<
Long
>
roomIds
=
list
.
stream
().
map
(
DeviceStatusLog:
:
getRoomId
).
collect
(
Collectors
.
toList
());
if
(
roomIds
!=
null
&&
roomIds
.
size
()
>
0
)
{
// 房间信息查询
LambdaQueryWrapper
<
SRoom
>
queryWrapper
=
new
LambdaQueryWrapper
();
queryWrapper
.
in
(
SRoom:
:
getId
,
roomIds
);
List
<
SRoom
>
roomList
=
roomMapper
.
selectList
(
queryWrapper
);
Map
<
Long
,
String
>
roomMap
=
roomList
.
stream
().
collect
(
Collectors
.
toMap
(
SRoom:
:
getId
,
SRoom:
:
getName
));
Map
<
Long
,
Long
>
roomStoreMap
=
roomList
.
stream
().
collect
(
Collectors
.
toMap
(
SRoom:
:
getId
,
SRoom:
:
getStoreId
));
// 门店信息查询
List
<
Long
>
storeIds
=
roomList
.
stream
().
map
(
SRoom:
:
getStoreId
).
collect
(
Collectors
.
toList
());
LambdaQueryWrapper
<
SStore
>
queryStoreWrapper
=
new
LambdaQueryWrapper
();
queryStoreWrapper
.
in
(
SStore:
:
getId
,
storeIds
);
List
<
SStore
>
storeList
=
storeMapper
.
selectList
(
queryStoreWrapper
);
Map
<
Long
,
String
>
storeMap
=
storeList
.
stream
().
collect
(
Collectors
.
toMap
(
SStore:
:
getId
,
SStore:
:
getName
));
list
.
stream
().
forEach
(
log
->
{
log
.
setRoomName
(
roomMap
.
get
(
log
.
getRoomId
()));
log
.
setStoreName
(
storeMap
.
get
(
roomStoreMap
.
get
(
log
.
getRoomId
())));
});
}
}
return
list
;
}
/**
...
...
share-system/src/main/java/share/system/service/impl/MqttxServiceImpl.java
View file @
673d8bb6
...
...
@@ -530,6 +530,18 @@ public class MqttxServiceImpl implements MqttxService {
private
boolean
updateDevice
(
String
topic
,
String
payload
)
{
JSONObject
json
=
JSONUtil
.
parseObj
(
payload
);
if
(
json
.
size
()
>
0
)
{
// 网关devId
String
gatewayDevId
=
json
.
getStr
(
"devId"
);
// 网关信息查询
DeviceGateway
deviceGateway
=
deviceGatewayMapper
.
selectDeviceGatewayByDevId
(
gatewayDevId
);
if
(
deviceGateway
!=
null
)
{
deviceGateway
.
setLastReportDate
(
DateUtil
.
date
());
deviceGateway
.
setLastReportContent
(
payload
);
deviceGateway
.
setUpdateTime
(
DateUtil
.
date
());
// 更新网关信息
deviceGatewayMapper
.
updateDeviceGateway
(
deviceGateway
);
}
// 设备上报信息
JSONArray
array
=
json
.
getJSONArray
(
"params"
);
if
(
array
!=
null
&&
array
.
size
()
>
0
)
{
List
<
String
>
devIds
=
new
ArrayList
<>();
...
...
@@ -644,11 +656,15 @@ public class MqttxServiceImpl implements MqttxService {
private
boolean
updateDeviceLog
(
String
topic
,
String
payload
)
{
JSONObject
json
=
JSONUtil
.
parseObj
(
payload
);
if
(
json
.
size
()
>
0
)
{
DeviceLog
deviceLog
=
new
DeviceLog
();
String
seq
=
json
.
getStr
(
"seq"
);
deviceLog
.
setSeq
(
seq
);
deviceLog
.
setRemark
(
payload
);
return
0
<
deviceLogMapper
.
updateBySeq
(
deviceLog
);
JSONArray
array
=
json
.
getJSONArray
(
"params"
);
if
(
array
!=
null
&&
array
.
size
()
>
0
)
{
DeviceLog
deviceLog
=
new
DeviceLog
();
String
seq
=
json
.
getStr
(
"seq"
);
deviceLog
.
setSeq
(
seq
);
deviceLog
.
setRemark
(
payload
);
deviceLog
.
setResult
(
array
.
getStr
(
1
));
return
0
<
deviceLogMapper
.
updateBySeq
(
deviceLog
);
}
}
return
false
;
}
...
...
share-system/src/main/java/share/system/service/impl/SmsServiceImpl.java
View file @
673d8bb6
package
share
.
system
.
service
.
impl
;
import
cn.hutool.core.util.StrUtil
;
import
cn.hutool.json.JSONArray
;
import
cn.hutool.json.JSONObject
;
import
cn.hutool.json.JSONUtil
;
import
org.slf4j.Logger
;
...
...
@@ -9,8 +10,10 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Service
;
import
share.common.constant.Constants
;
import
share.common.constant.SmsConts
;
import
share.common.core.redis.RedisUtil
;
import
share.common.enums.DeviceStatusEnum
;
import
share.common.enums.SmsStatusEnum
;
import
share.common.enums.SmsTypeEnum
;
import
share.common.exception.base.BaseException
;
import
share.common.utils.BaseUtil
;
...
...
@@ -201,13 +204,13 @@ public class SmsServiceImpl implements SmsService {
String
smsContent
=
StrUtil
.
concat
(
true
,
signature
,
content
);
String
phoneStr
=
String
.
join
(
","
,
phoneList
);
JSONObject
param
=
JSONUtil
.
createObj
();
param
.
pu
t
(
"action"
,
"send"
);
param
.
pu
t
(
"account"
,
userName
);
param
.
pu
t
(
"password"
,
smsUtil
.
md5Password
(
passWord
,
extno
,
phoneStr
,
smsContent
));
param
.
pu
t
(
"mobile"
,
phoneStr
);
param
.
se
t
(
"action"
,
"send"
);
param
.
se
t
(
"account"
,
userName
);
param
.
se
t
(
"password"
,
smsUtil
.
md5Password
(
passWord
,
extno
,
phoneStr
,
smsContent
));
param
.
se
t
(
"mobile"
,
phoneStr
);
// param.put("mobileEencryptionMode", "");
param
.
pu
t
(
"content"
,
smsContent
);
param
.
pu
t
(
"extno"
,
extno
);
param
.
se
t
(
"content"
,
smsContent
);
param
.
se
t
(
"extno"
,
extno
);
// param.put("atTime", "");
// 短信日志
SmsLog
smsLog
=
new
SmsLog
();
...
...
@@ -217,14 +220,14 @@ public class SmsServiceImpl implements SmsService {
smsLog
.
setSmsType
(
smsType
);
try
{
JSONObject
jsonObject
=
smsUtil
.
postFrom
(
url
,
param
);
smsLog
.
setResult
(
1
);
smsLog
.
setResultParam
(
JSONUtil
.
toJsonStr
(
jsonObject
));
checkResult
(
jsonObject
,
smsLog
);
smsLogService
.
insertSmsLog
(
smsLog
);
return
jsonObject
;
}
catch
(
BaseException
exception
)
{
// 异常日志
smsLog
.
setResult
(
0
);
smsLog
.
setRe
sultParam
(
exception
.
getDefaultMessage
());
smsLog
.
setRe
mark
(
exception
.
getDefaultMessage
());
smsLogService
.
insertSmsLog
(
smsLog
);
}
return
null
;
...
...
@@ -240,13 +243,13 @@ public class SmsServiceImpl implements SmsService {
// 发送内容添加短信签名
String
smsContent
=
StrUtil
.
concat
(
true
,
signature
,
content
);
JSONObject
param
=
JSONUtil
.
createObj
();
param
.
pu
t
(
"action"
,
"send"
);
param
.
pu
t
(
"account"
,
userName
);
param
.
pu
t
(
"password"
,
smsUtil
.
md5Password
(
passWord
,
extno
,
phone
,
smsContent
));
param
.
pu
t
(
"mobile"
,
phone
);
param
.
se
t
(
"action"
,
"send"
);
param
.
se
t
(
"account"
,
userName
);
param
.
se
t
(
"password"
,
smsUtil
.
md5Password
(
passWord
,
extno
,
phone
,
smsContent
));
param
.
se
t
(
"mobile"
,
phone
);
// param.put("mobileEencryptionMode", "");
param
.
pu
t
(
"content"
,
smsContent
);
param
.
pu
t
(
"extno"
,
extno
);
param
.
se
t
(
"content"
,
smsContent
);
param
.
se
t
(
"extno"
,
extno
);
// param.put("atTime", "");
// 短信日志
SmsLog
smsLog
=
new
SmsLog
();
...
...
@@ -256,14 +259,14 @@ public class SmsServiceImpl implements SmsService {
smsLog
.
setSmsType
(
smsType
);
try
{
JSONObject
jsonObject
=
smsUtil
.
postFrom
(
url
,
param
);
smsLog
.
setResult
(
1
);
smsLog
.
setResultParam
(
JSONUtil
.
toJsonStr
(
jsonObject
));
checkResult
(
jsonObject
,
smsLog
);
smsLogService
.
insertSmsLog
(
smsLog
);
return
jsonObject
;
}
catch
(
BaseException
exception
)
{
// 异常日志
smsLog
.
setResult
(
0
);
smsLog
.
setRe
sultParam
(
exception
.
getDefaultMessage
());
smsLog
.
setRe
mark
(
exception
.
getDefaultMessage
());
smsLogService
.
insertSmsLog
(
smsLog
);
}
return
null
;
...
...
@@ -288,12 +291,12 @@ public class SmsServiceImpl implements SmsService {
}
JSONObject
param
=
JSONUtil
.
createObj
();
param
.
pu
t
(
"action"
,
"p2p"
);
param
.
pu
t
(
"account"
,
userName
);
param
.
pu
t
(
"password"
,
smsUtil
.
md5Password
(
passWord
,
extno
,
""
,
content
));
param
.
pu
t
(
"mobileContentKvp"
,
map
);
param
.
se
t
(
"action"
,
"p2p"
);
param
.
se
t
(
"account"
,
userName
);
param
.
se
t
(
"password"
,
smsUtil
.
md5Password
(
passWord
,
extno
,
""
,
content
));
param
.
se
t
(
"mobileContentKvp"
,
map
);
// param.put("mobileEencryptionMode", "");
param
.
pu
t
(
"extno"
,
extno
);
param
.
se
t
(
"extno"
,
extno
);
// param.put("atTime", "");
// 短信日志
SmsLog
smsLog
=
new
SmsLog
();
...
...
@@ -303,18 +306,44 @@ public class SmsServiceImpl implements SmsService {
smsLog
.
setSmsType
(
smsType
);
try
{
JSONObject
jsonObject
=
smsUtil
.
postFrom
(
url
,
param
);
smsLog
.
setResult
(
1
);
smsLog
.
setResultParam
(
JSONUtil
.
toJsonStr
(
jsonObject
));
checkResult
(
jsonObject
,
smsLog
);
smsLogService
.
insertSmsLog
(
smsLog
);
return
jsonObject
;
}
catch
(
BaseException
exception
)
{
// 异常日志
smsLog
.
setResult
(
0
);
smsLog
.
setRe
sultParam
(
exception
.
getDefaultMessage
());
smsLog
.
setRe
mark
(
exception
.
getDefaultMessage
());
smsLogService
.
insertSmsLog
(
smsLog
);
}
return
null
;
}
private
void
checkResult
(
JSONObject
result
,
SmsLog
smsLog
)
{
if
(!
SmsConts
.
SUCCESS_CODE
.
equals
(
result
.
getInt
(
"status"
)))
{
smsLog
.
setResult
(
0
);
smsLog
.
setRemark
(
SmsStatusEnum
.
getNameStr
(
result
.
getInt
(
"status"
)));
}
else
{
JSONArray
array
=
result
.
getJSONArray
(
"list"
);
if
(
array
!=
null
&&
array
.
size
()
>
0
)
{
StringBuilder
sb
=
new
StringBuilder
();
boolean
isSuccess
=
Boolean
.
TRUE
;
for
(
Object
o
:
array
)
{
JSONObject
json
=
JSONUtil
.
parseObj
(
o
);
sb
.
append
(
json
.
getStr
(
"mobile"
)).
append
(
": "
);
sb
.
append
(
SmsStatusEnum
.
getNameStr
(
json
.
getInt
(
"result"
))).
append
(
","
);
if
(!
SmsConts
.
SUCCESS_CODE
.
equals
(
json
.
getInt
(
"result"
))){
isSuccess
=
Boolean
.
FALSE
;
}
}
// 判断字符串长度大于1并且最后一个字符为逗号时才进行处理
if
(
sb
.
length
()
>
1
&&
sb
.
charAt
(
sb
.
length
()
-
1
)
==
','
)
{
sb
.
deleteCharAt
(
sb
.
length
()
-
1
);
}
smsLog
.
setResult
(
isSuccess
?
1
:
0
);
smsLog
.
setRemark
(
sb
.
toString
());
}
}
}
}
share-system/src/main/resources/mapper/system/DeviceGatewayMapper.xml
View file @
673d8bb6
...
...
@@ -24,10 +24,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result
property=
"updateTime"
column=
"update_time"
/>
<result
property=
"remark"
column=
"remark"
/>
<result
property=
"devPosition"
column=
"dev_position"
/>
<result
property=
"lastReportDate"
column=
"last_report_date"
/>
<result
property=
"lastReportContent"
column=
"last_report_content"
/>
</resultMap>
<sql
id=
"selectDeviceGatewayVo"
>
select id, dev_name, dev_mac, dev_id, dev_psw, dev_ver, dev_type, `group`, status, mqtt_iP, mqtt_port, mqtt_user, mqtt_paswd, create_by, create_time, update_by, update_time, remark, dev_position from s_device_gateway
select id, dev_name, dev_mac, dev_id, dev_psw, dev_ver, dev_type, `group`, status, mqtt_iP, mqtt_port,
mqtt_user, mqtt_paswd, create_by, create_time, update_by, update_time, remark,
dev_position, last_report_date, last_report_content
from s_device_gateway
</sql>
<select
id=
"selectDeviceGatewayList"
parameterType=
"DeviceGateway"
resultMap=
"DeviceGatewayResult"
>
...
...
@@ -79,6 +84,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if
test=
"updateTime != null"
>
update_time,
</if>
<if
test=
"remark != null"
>
remark,
</if>
<if
test=
"devPosition != null"
>
dev_position,
</if>
<if
test=
"lastReportDate != null"
>
last_report_date,
</if>
<if
test=
"lastReportContent != null"
>
last_report_content,
</if>
</trim>
<trim
prefix=
"values ("
suffix=
")"
suffixOverrides=
","
>
<if
test=
"devName != null"
>
#{devName},
</if>
...
...
@@ -99,6 +106,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if
test=
"updateTime != null"
>
#{updateTime},
</if>
<if
test=
"remark != null"
>
#{remark},
</if>
<if
test=
"devPosition != null"
>
#{devPosition},
</if>
<if
test=
"lastReportDate != null"
>
#{lastReportDate},
</if>
<if
test=
"lastReportContent != null"
>
#{lastReportContent},
</if>
</trim>
</insert>
...
...
@@ -123,6 +132,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if
test=
"updateTime != null"
>
update_time = #{updateTime},
</if>
<if
test=
"remark != null"
>
remark = #{remark},
</if>
<if
test=
"devPosition != null"
>
dev_position = #{devPosition},
</if>
<if
test=
"lastReportDate != null"
>
last_report_date = #{lastReportDate},
</if>
<if
test=
"lastReportContent != null"
>
last_report_content = #{lastReportContent},
</if>
</trim>
where id = #{id}
</update>
...
...
share-system/src/main/resources/mapper/system/DeviceLogMapper.xml
View file @
673d8bb6
...
...
@@ -18,10 +18,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result
property=
"updateBy"
column=
"update_by"
/>
<result
property=
"updateTime"
column=
"update_time"
/>
<result
property=
"remark"
column=
"remark"
/>
<result
property=
"result"
column=
"result"
/>
<result
property=
"description"
column=
"description"
/>
</resultMap>
<sql
id=
"selectDeviceLogVo"
>
select id, dev_mac, dev_id, seq, mqtt_type, mqtt_describe, payload, topic, create_by, create_time, update_by, update_time, remark from s_device_log
select id, dev_mac, dev_id, seq, mqtt_type, mqtt_describe, payload, topic, create_by, create_time,
update_by, update_time, remark, `result`, description from s_device_log
</sql>
<select
id=
"selectDeviceLogList"
parameterType=
"DeviceLog"
resultMap=
"DeviceLogResult"
>
...
...
@@ -44,7 +47,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</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
t1.create_by, t1.create_time, t1.update_by, t1.update_time, t1.remark,
t1.`result`, t1.description
FROM s_device_log t1
JOIN (
SELECT MAX(id) AS max_id
...
...
@@ -74,6 +78,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if
test=
"updateBy != null"
>
update_by,
</if>
<if
test=
"updateTime != null"
>
update_time,
</if>
<if
test=
"remark != null"
>
remark,
</if>
<if
test=
"result != null"
>
`result`,
</if>
<if
test=
"description != null"
>
description,
</if>
</trim>
<trim
prefix=
"values ("
suffix=
")"
suffixOverrides=
","
>
<if
test=
"devMac != null"
>
#{devMac},
</if>
...
...
@@ -88,6 +94,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if
test=
"updateBy != null"
>
#{updateBy},
</if>
<if
test=
"updateTime != null"
>
#{updateTime},
</if>
<if
test=
"remark != null"
>
#{remark},
</if>
<if
test=
"result != null"
>
#{result},
</if>
<if
test=
"description != null"
>
#{description},
</if>
</trim>
</insert>
...
...
@@ -106,11 +114,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if
test=
"updateBy != null"
>
update_by = #{updateBy},
</if>
<if
test=
"updateTime != null"
>
update_time = #{updateTime},
</if>
<if
test=
"remark != null"
>
remark = #{remark},
</if>
<if
test=
"result != null"
>
`result` = #{result},
</if>
<if
test=
"description != null"
>
description = #{description},
</if>
</trim>
where id = #{id}
</update>
<update
id=
"updateBySeq"
parameterType=
"DeviceLog"
>
update s_device_log set remark = #{remark} where seq = #{seq}
update s_device_log
set remark = #{remark},`result` = #{result}
where seq = #{seq}
</update>
<delete
id=
"deleteDeviceLogById"
parameterType=
"Long"
>
...
...
share-system/src/main/resources/mapper/system/SaobeiApiLogMapper.xml
View file @
673d8bb6
...
...
@@ -49,6 +49,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if
test=
"resultMsg != null and resultMsg != ''"
>
and result_msg = #{resultMsg}
</if>
<if
test=
"flag != null and flag != ''"
>
and flag = #{flag}
</if>
</where>
order by create_time desc
</select>
<select
id=
"selectSaobeiApiLogById"
parameterType=
"Long"
resultMap=
"SaobeiApiLogResult"
>
...
...
share-system/src/main/resources/mapper/system/SmsLogMapper.xml
View file @
673d8bb6
...
...
@@ -35,6 +35,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if
test=
"result != null "
>
and result = #{result}
</if>
<if
test=
"resultParam != null and resultParam != ''"
>
and result_param = #{resultParam}
</if>
</where>
order by create_time desc
</select>
<select
id=
"selectSmsLogById"
parameterType=
"Long"
resultMap=
"SmsLogResult"
>
...
...
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