Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
黄嘉阳
/
iot-platform-server
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
14cea1ba
authored
Dec 05, 2023
by
huangjy
Browse files
Options
_('Browse Files')
Download
Plain Diff
Merge remote-tracking branch 'origin/dev'
parents
975db581
624c867b
Hide whitespace changes
Inline
Side-by-side
Showing
49 changed files
with
1534 additions
and
145 deletions
db/上线后sql/update.sql
saas-module/src/main/java/com/makeit/controller/device/PlatDeviceLogController.java
saas-module/src/main/java/com/makeit/controller/device/SaasDeviceController.java
server-common/src/main/java/com/makeit/module/iot/service/IotCommonService.java
server-common/src/main/java/com/makeit/module/iot/service/IotDevicePropertiesOperateService.java
server-common/src/main/java/com/makeit/oss/AccessoryRepository.java
server-common/src/main/java/com/makeit/oss/AliyunOSSRepository.java
server-common/src/main/java/com/makeit/shengwang/agora/service/ShengwangService.java
server-common/src/main/java/com/makeit/utils/FileUtils.java
server-common/src/main/java/com/makeit/utils/data/excel/ExcelValidatorUtil.java
server-generator/src/test/java/CodeGenerator.java
server-module/src/main/java/com/makeit/module/controller/alarm/PlatAlarmRecordController.java
server-module/src/main/java/com/makeit/module/controller/children/alarm/PlatAlarmRecordChildrenController.java
server-module/src/main/java/com/makeit/module/controller/space/PlatSpaceController.java
server-module/src/main/java/com/makeit/module/controller/wechat/alarm/PlatAlarmRecordWechatController.java
server-service/src/main/java/com/makeit/dto/platform/alarm/PlatAlarmRecordQueryDTO.java
server-service/src/main/java/com/makeit/dto/platform/auth/PlatUserImportDTO.java
server-service/src/main/java/com/makeit/dto/platform/device/PlatDeviceBaseAttrDTO.java
server-service/src/main/java/com/makeit/dto/platform/device/PlatDeviceQueryDTO.java
server-service/src/main/java/com/makeit/dto/platform/elder/children/PlatElderChildrenInfoDTOVO.java
server-service/src/main/java/com/makeit/entity/platform/alarm/PlatAlarmRecord.java
server-service/src/main/java/com/makeit/entity/platform/device/PlatDevice.java
server-service/src/main/java/com/makeit/entity/platform/device/PlatDeviceLog.java
server-service/src/main/java/com/makeit/enums/report/PlatformTypeEnum.java
server-service/src/main/java/com/makeit/mapper/platform/device/PlatDeviceLogMapper.java
server-service/src/main/java/com/makeit/service/platform/alarm/PlatAlarmRecordService.java
server-service/src/main/java/com/makeit/service/platform/alarm/impl/PlatAlarmRecordServiceImpl.java
server-service/src/main/java/com/makeit/service/platform/auth/impl/PlatOrgServiceImpl.java
server-service/src/main/java/com/makeit/service/platform/auth/impl/PlatUserServiceImpl.java
server-service/src/main/java/com/makeit/service/platform/device/PlatDeviceLogService.java
server-service/src/main/java/com/makeit/service/platform/device/PlatDeviceService.java
server-service/src/main/java/com/makeit/service/platform/device/impl/PlatDeviceLogServiceImpl.java
server-service/src/main/java/com/makeit/service/platform/device/impl/PlatDeviceServiceImpl.java
server-service/src/main/java/com/makeit/service/platform/elder/impl/PlatElderRealTimeServiceImpl.java
server-service/src/main/java/com/makeit/service/platform/elder/impl/PlatElderServiceImpl.java
server-service/src/main/java/com/makeit/service/platform/space/impl/PlatBedServiceImpl.java
server-service/src/main/java/com/makeit/service/platform/space/impl/PlatSpaceServiceImpl.java
server-service/src/main/java/com/makeit/service/platform/workstation/impl/WorkStationServiceImpl.java
server-service/src/main/java/com/makeit/vo/platform/alarm/PlatAlarmRecordVO.java
server-service/src/main/java/com/makeit/vo/platform/device/PlatDeviceListVO.java
server-service/src/main/java/com/makeit/vo/platform/elder/PlatElderListVO.java
server-service/src/main/java/com/makeit/vo/platform/elder/realtime/PlatElderRealTimeHeartRespiratoryVO.java
server-service/src/main/java/com/makeit/vo/platform/workstation/WorkStationHomeBedVO.java
server-service/src/main/java/com/makeit/vo/platform/workstation/WorkStationInstitutionBedVO.java
server-service/src/main/resources/mappers/PlatBedMapper.xml
server-service/src/main/resources/mappers/PlatDeviceMapper.xml
server-web/src/main/resources/application-dev.yml
server-web/src/main/resources/application-test.yml
server-web/src/main/resources/logback-spring.xml
db/上线后sql/update.sql
View file @
14cea1ba
ALTER
TABLE
`plat_device_other`
ALTER
TABLE
`plat_device_other`
...
...
@@ -4,7 +4,8 @@ ADD COLUMN `secure_key` varchar(255) COMMENT '密钥key' AFTER `secure_id`;
ALTER
TABLE
`plat_alarm_record`
ADD
COLUMN
`misinformation_flag`
char
(
1
)
DEFAULT
0
COMMENT
'是否误报 1 误报 0 没有误报'
AFTER
`read_flag`
;
ADD
COLUMN
`misinformation_flag`
char
(
1
)
DEFAULT
0
COMMENT
'是否误报 1 误报 0 没有误报'
AFTER
`read_flag`
ADD
COLUMN
`wechat_read_flag`
char
(
1
)
DEFAULT
0
COMMENT
'小程序端是否读取 0未读 1已读'
AFTER
`misinformation_flag`
;
ALTER
TABLE
`plat_elder_report_month`
...
...
@@ -37,4 +38,20 @@ ADD COLUMN `activation_time` int8 COMMENT '激活时间' AFTER `expire_time`;
ALTER
TABLE
`plat_tenant`
ADD
COLUMN
`appid`
varchar
(
64
)
COMMENT
'appid'
AFTER
`url`
,
ADD
COLUMN
`secret`
varchar
(
64
)
COMMENT
'secret'
AFTER
`appid`
;
\ No newline at end of file
ADD
COLUMN
`secret`
varchar
(
64
)
COMMENT
'secret'
AFTER
`appid`
;
CREATE
TABLE
`plat_device_log`
(
`id`
VARCHAR
(
64
)
NOT
NULL
COMMENT
'id'
,
`device_id`
VARCHAR
(
64
)
DEFAULT
NULL
COMMENT
'iot设备sn'
,
`type`
VARCHAR
(
1
)
DEFAULT
NULL
COMMENT
'类型 1 误报'
,
`product_name`
VARCHAR
(
64
)
DEFAULT
NULL
COMMENT
'产品名称'
,
`url`
VARCHAR
(
256
)
DEFAULT
NULL
COMMENT
'日志url'
,
`file_name`
VARCHAR
(
256
)
DEFAULT
NULL
COMMENT
'文件名称'
,
`create_date`
datetime
NOT
NULL
COMMENT
'创建时间'
,
`update_date`
datetime
NOT
NULL
COMMENT
'更新时间'
,
`del_flag`
CHAR
(
1
)
DEFAULT
NULL
COMMENT
'删除标识'
,
`create_by`
VARCHAR
(
64
)
DEFAULT
NULL
COMMENT
'创建人'
,
`update_by`
VARCHAR
(
64
)
DEFAULT
NULL
COMMENT
'更新人'
,
`tenant_id`
varchar
(
64
)
DEFAULT
NULL
COMMENT
' 租户id'
,
PRIMARY
KEY
(
`id`
)
)
ENGINE
=
INNODB
DEFAULT
CHARSET
=
utf8mb4
ROW_FORMAT
=
COMPACT
COMMENT
=
'设备日志'
;
\ No newline at end of file
saas-module/src/main/java/com/makeit/controller/device/PlatDeviceLogController.java
0 → 100644
View file @
14cea1ba
package
com
.
makeit
.
controller
.
device
;
import
com.makeit.common.page.PageReqDTO
;
import
com.makeit.common.page.PageVO
;
import
com.makeit.common.response.ApiResponseEntity
;
import
com.makeit.common.response.ApiResponseUtils
;
import
com.makeit.entity.platform.device.PlatDeviceLog
;
import
com.makeit.global.aspect.tenant.TenantIdIgnore
;
import
com.makeit.service.platform.device.PlatDeviceLogService
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
/**
* <p>
* 设备日志 前端控制器
* </p>
*
* @author eugene young
* @since 2023-12-01
*/
@RestController
@RequestMapping
(
"/saas/deviceLog"
)
@Api
(
tags
=
"租户管理-查看设备日志"
)
public
class
PlatDeviceLogController
{
@Autowired
private
PlatDeviceLogService
platDeviceLogService
;
@ApiOperation
(
"列表"
)
@PostMapping
(
"page"
)
@TenantIdIgnore
public
ApiResponseEntity
<
PageVO
<
PlatDeviceLog
>>
page
(
@RequestBody
PageReqDTO
<
PlatDeviceLog
>
pageReqDTO
)
{
return
ApiResponseUtils
.
success
(
platDeviceLogService
.
pageList
(
pageReqDTO
));
}
}
saas-module/src/main/java/com/makeit/controller/device/SaasDeviceController.java
View file @
14cea1ba
...
...
@@ -14,8 +14,11 @@ import com.makeit.entity.platform.device.PlatDevice;
import
com.makeit.global.annotation.AuthIgnore
;
import
com.makeit.global.aspect.tenant.TenantIdIgnore
;
import
com.makeit.module.iot.vo.DeviceProperties
;
import
com.makeit.service.platform.alarm.PlatAlarmRecordService
;
import
com.makeit.service.platform.device.PlatDeviceService
;
import
com.makeit.service.saas.SaasOperationLogService
;
import
com.makeit.shengwang.agora.dto.PlatCallingDeviceDTO
;
import
com.makeit.shengwang.agora.vo.PlatAlarmCallDeviceVO
;
import
com.makeit.vo.platform.device.PlatDeviceListVO
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
...
...
@@ -23,6 +26,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.multipart.MultipartFile
;
import
java.io.IOException
;
import
java.util.List
;
@Api
(
tags
=
"租户管理-租户设备管理"
)
...
...
@@ -33,6 +37,8 @@ public class SaasDeviceController {
private
PlatDeviceService
platDeviceService
;
@Autowired
private
SaasOperationLogService
saasOperationLogService
;
@Autowired
private
PlatAlarmRecordService
platAlarmRecordService
;
@ApiOperation
(
"列表"
)
@PostMapping
(
"page"
)
...
...
@@ -90,6 +96,13 @@ public class SaasDeviceController {
return
ApiResponseUtils
.
success
();
}
@ApiOperation
(
"呼叫设备rtm"
)
@PostMapping
(
"callingDeviceAuthRtm"
)
@TenantIdIgnore
public
ApiResponseEntity
<
PlatAlarmCallDeviceVO
>
callingDeviceAuthRtm
(
@RequestBody
PlatCallingDeviceDTO
dto
)
{
return
ApiResponseUtils
.
success
(
platAlarmRecordService
.
callingDeviceAuthIgnoreRtm
(
dto
));
}
@ApiOperation
(
"激活设备license"
)
@PostMapping
(
"active"
)
@TenantIdIgnore
...
...
@@ -98,13 +111,20 @@ public class SaasDeviceController {
return
ApiResponseUtils
.
success
();
}
@ApiOperation
(
"设备呼叫设备"
)
@PostMapping
(
"callingDevice"
)
@TenantIdIgnore
public
ApiResponseEntity
<
PlatAlarmCallDeviceVO
>
callingDevice
(
@RequestBody
PlatCallingDeviceDTO
dto
)
{
return
ApiResponseUtils
.
success
(
platDeviceService
.
callingDevice
(
dto
));
}
@ApiOperation
(
"设备日志推送"
)
@PostMapping
(
"devicePushLog"
)
@TenantIdIgnore
@AuthIgnore
public
ApiResponseEntity
devicePushLog
(
@RequestParam
(
value
=
"
file
"
,
required
=
false
)
MultipartFile
multipartFile
,
@RequestParam
(
value
=
"deviceId"
)
String
deviceId
)
{
platDeviceService
.
devicePushLog
(
multipartFile
);
public
ApiResponseEntity
devicePushLog
(
@RequestParam
(
value
=
"
rawData
"
,
required
=
false
)
MultipartFile
multipartFile
,
@RequestParam
(
value
=
"deviceId"
)
String
deviceId
)
throws
IOException
{
platDeviceService
.
devicePushLog
(
multipartFile
,
deviceId
);
return
ApiResponseUtils
.
success
();
}
...
...
server-common/src/main/java/com/makeit/module/iot/service/IotCommonService.java
View file @
14cea1ba
...
...
@@ -31,6 +31,8 @@ public class IotCommonService {
@Value
(
"${iot.url:}"
)
public
String
iotUrl
;
@Value
(
"${iot.uploadUrl:}"
)
public
String
uploadUrl
;
protected
static
HttpClient
httpClient
=
HttpClientBuilder
.
create
().
build
();
...
...
server-common/src/main/java/com/makeit/module/iot/service/IotDevicePropertiesOperateService.java
View file @
14cea1ba
...
...
@@ -101,4 +101,26 @@ public class IotDevicePropertiesOperateService extends IotCommonService {
}
return
""
;
}
public
String
deviceFunctionAttr
(
String
deviceId
,
Long
timestamp
)
{
String
url
=
iotUrl
+
"device/invoked/"
+
deviceId
+
"/function/misinformation"
;
Map
<
String
,
Map
<
String
,
Object
>>
map
=
Maps
.
newHashMap
();
Map
<
String
,
Object
>
reqMap
=
Maps
.
newHashMap
();
reqMap
.
put
(
"timestamp"
,
timestamp
);
reqMap
.
put
(
"url"
,
uploadUrl
);
map
.
put
(
"misinformationNotify"
,
reqMap
);
HttpRequest
request
=
buildRequest
(
url
,
JSON
.
toJSONString
(
map
));
try
{
ResponseMessage
responseMessage
=
sendPost
(
url
,
request
);
log
.
info
(
"发送误报通知到设备返回信息:{}"
,
responseMessage
.
getMessage
());
if
(
responseMessage
.
getStatus
()
!=
200
)
{
String
errorMsg
=
responseMessage
.
getMessage
();
log
.
error
(
"发送误报通知失败:{}"
,
errorMsg
);
return
errorMsg
;
}
}
catch
(
IOException
e
)
{
log
.
error
(
"调用:{}接口异常:{}"
,
url
,
e
.
getMessage
());
}
return
""
;
}
}
server-common/src/main/java/com/makeit/oss/AccessoryRepository.java
0 → 100644
View file @
14cea1ba
package
com
.
makeit
.
oss
;
import
org.springframework.web.multipart.MultipartFile
;
import
javax.validation.constraints.NotNull
;
import
java.io.File
;
import
java.io.FileNotFoundException
;
import
java.io.InputStream
;
import
java.net.URL
;
public
interface
AccessoryRepository
{
/**
* 根据保存的相对路径获取存储的文件对象
*
* @return java.io.File
* @Author 滕鑫源
* @Date 2020/8/20 14:46
* @Param path
* @Param fileName
**/
File
get
(
String
path
,
String
fileName
)
throws
FileNotFoundException
;
URL
getURL
(
String
path
,
String
fileName
)
throws
FileNotFoundException
;
/**
* 根据保存的相对路径获取可下载文件的完整http路径
*
* @Author 滕鑫源
* @Date 2020/8/26 10:46
* @param path
* @param fileName
* @return
**/
// String getUrl(String path, String fileName);
/**
* 根据给定的多个相对路径获取多个存储的文件对象
*
* @Author 滕鑫源
* @Date 2020/8/26 10:46
* @param urls
* @return
**/
// List<File> findList(String... urls);
/**
* 保存文件对象
*
* @Author 滕鑫源
* @Date 2020/8/20 14:47
* @Param file
* @Param fileName
**/
File
save
(
File
file
,
String
path
,
String
fileName
);
/**
* 保存文件流文件为文件对象
*
* @Author 滕鑫源
* @Date 2020/8/20 14:49
* @Param file
* @Param fileName
**/
String
save
(
MultipartFile
file
,
String
path
,
String
fileName
);
/**
* 保存输入流为文件对象
*
* @Author 滕鑫源
* @Date 2020/8/20 14:47
* @Param file
* @Param fileName
**/
File
save
(
InputStream
is
,
String
path
,
@NotNull
String
fileName
);
}
server-common/src/main/java/com/makeit/oss/AliyunOSSRepository.java
0 → 100644
View file @
14cea1ba
package
com
.
makeit
.
oss
;
import
com.aliyun.oss.OSS
;
import
com.aliyun.oss.OSSClientBuilder
;
import
com.aliyun.oss.OSSException
;
import
com.aliyun.oss.model.OSSObject
;
import
com.aliyun.oss.model.ObjectMetadata
;
import
com.aliyun.oss.model.PutObjectRequest
;
import
com.makeit.utils.FileUtils
;
import
org.apache.commons.lang3.time.DateUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnProperty
;
import
org.springframework.stereotype.Component
;
import
org.springframework.web.multipart.MultipartFile
;
import
javax.validation.constraints.NotNull
;
import
java.io.File
;
import
java.io.FileNotFoundException
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.net.URL
;
import
java.nio.charset.StandardCharsets
;
import
java.util.Date
;
/**
* aliyunOSS存储服务类
*
* @author 滕鑫源
* @date 2020/8/20 14:42
*/
@Component
public
class
AliyunOSSRepository
implements
AccessoryRepository
{
private
final
Logger
logger
=
LoggerFactory
.
getLogger
(
getClass
());
@Value
(
"${aliyun.oss.baseDir}"
)
private
String
accessoryBaseDir
;
@Value
(
"${aliyun.oss.endpoint}"
)
private
String
endpoint
;
@Value
(
"${aliyun.oss.accessKey}"
)
private
String
accessKeyId
;
@Value
(
"${aliyun.oss.secretKey}"
)
private
String
accessKeySecret
;
@Value
(
"${aliyun.oss.bucket}"
)
private
String
bucketName
;
@Override
public
File
get
(
String
path
,
String
fileName
)
throws
FileNotFoundException
{
logger
.
debug
(
"开始从aliyun-oss获取文件: {}{}{}"
,
path
,
"/"
,
fileName
);
long
begin
=
System
.
currentTimeMillis
();
InputStream
is
=
null
;
try
{
if
(
path
==
null
)
{
path
=
""
;
}
OSS
client
=
new
OSSClientBuilder
().
build
(
endpoint
,
accessKeyId
,
accessKeySecret
);
OSSObject
object
=
client
.
getObject
(
bucketName
,
accessoryBaseDir
+
"/"
+
path
+
"/"
+
fileName
);
is
=
object
.
getObjectContent
();
File
localTempDir
=
new
File
(
FileUtils
.
getTempDirectory
()
+
File
.
separator
+
accessoryBaseDir
+
File
.
separator
+
path
);
FileUtils
.
createDirectory
(
localTempDir
.
getPath
());
File
dest
=
new
File
(
localTempDir
,
fileName
);
FileUtils
.
copyInputStreamToFile
(
is
,
dest
);
client
.
shutdown
();
return
dest
;
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
catch
(
OSSException
e
)
{
throw
new
FileNotFoundException
(
"指定的文件不存在"
);
}
finally
{
if
(
is
!=
null
){
try
{
is
.
close
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
}
logger
.
debug
(
"完成从aliyun-oss获取文件: {}"
,
System
.
currentTimeMillis
()
-
begin
);
}
return
null
;
}
@Override
public
URL
getURL
(
String
path
,
String
fileName
)
throws
FileNotFoundException
{
logger
.
debug
(
"开始从aliyun-oss获取文件: {}{}{}"
,
path
,
"/"
,
fileName
);
long
begin
=
System
.
currentTimeMillis
();
URL
downloadURL
=
null
;
try
{
if
(
path
==
null
)
{
path
=
""
;
}
OSS
client
=
new
OSSClientBuilder
().
build
(
endpoint
,
accessKeyId
,
accessKeySecret
);
Date
expireDate
=
DateUtils
.
addHours
(
new
Date
(),
1
);
downloadURL
=
client
.
generatePresignedUrl
(
bucketName
,
accessoryBaseDir
+
"/"
+
path
+
"/"
+
fileName
,
expireDate
);
return
downloadURL
;
}
catch
(
OSSException
e
)
{
throw
new
FileNotFoundException
(
"指定的文件不存在"
);
}
finally
{
logger
.
debug
(
"完成从aliyun-oss获取文件临时授权路径 {}, 耗时: {}"
,
downloadURL
,
System
.
currentTimeMillis
()
-
begin
);
}
}
/**
* 保存文件对象
*
* @param file
* @param path
* @param fileName
* @Author 滕鑫源
* @Date 2020/8/20 14:47
*/
@Override
public
File
save
(
File
file
,
String
path
,
String
fileName
)
{
logger
.
debug
(
"开始向aliyun-oss保存文件: {}"
,
fileName
);
long
begin
=
System
.
currentTimeMillis
();
OSS
client
=
new
OSSClientBuilder
().
build
(
endpoint
,
accessKeyId
,
accessKeySecret
);
ObjectMetadata
meta
=
new
ObjectMetadata
();
meta
.
setContentDisposition
(
"attachment;filename="
+
new
String
(
fileName
.
getBytes
(),
StandardCharsets
.
ISO_8859_1
));
PutObjectRequest
putObjectRequest
=
new
PutObjectRequest
(
bucketName
,
accessoryBaseDir
+
"/"
+
path
+
"/"
+
fileName
,
file
,
meta
);
client
.
putObject
(
putObjectRequest
);
client
.
shutdown
();
logger
.
debug
(
"完成向aliyun-oss保存文件: {}"
,
System
.
currentTimeMillis
()
-
begin
);
return
file
;
}
/**
* 保存文件流文件为文件对象
*
* @param file
* @param path
* @param fileName
* @Author 滕鑫源
* @Date 2020/8/20 14:49
*/
@Override
public
String
save
(
MultipartFile
file
,
String
path
,
String
fileName
)
{
logger
.
debug
(
"开始向aliyun-oss保存文件: {}"
,
fileName
);
long
begin
=
System
.
currentTimeMillis
();
try
{
OSS
client
=
new
OSSClientBuilder
().
build
(
endpoint
,
accessKeyId
,
accessKeySecret
);
ObjectMetadata
meta
=
new
ObjectMetadata
();
meta
.
setContentDisposition
(
"attachment;filename="
+
new
String
(
fileName
.
getBytes
(),
StandardCharsets
.
ISO_8859_1
));
PutObjectRequest
putObjectRequest
=
new
PutObjectRequest
(
bucketName
,
accessoryBaseDir
+
"/"
+
path
+
(
path
.
endsWith
(
"/"
)
?
""
:
"/"
)
+
fileName
,
file
.
getInputStream
(),
meta
);
client
.
putObject
(
putObjectRequest
);
client
.
shutdown
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
logger
.
debug
(
"完成向aliyun-oss保存文件: {}"
,
System
.
currentTimeMillis
()
-
begin
);
return
bucketName
+
"."
+
endpoint
+
"/"
+
accessoryBaseDir
+
"/"
+
path
+
"/"
+
fileName
;
}
/**
* 保存输入流为文件对象
*
* @param is
* @param path
* @param fileName
* @Author 滕鑫源
* @Date 2020/8/20 14:47
*/
@Override
public
File
save
(
InputStream
is
,
String
path
,
@NotNull
String
fileName
)
{
logger
.
debug
(
"开始向aliyun-oss保存文件: {}"
,
fileName
);
long
begin
=
System
.
currentTimeMillis
();
try
{
OSS
client
=
new
OSSClientBuilder
().
build
(
endpoint
,
accessKeyId
,
accessKeySecret
);
ObjectMetadata
meta
=
new
ObjectMetadata
();
meta
.
setContentDisposition
(
"attachment;filename="
+
new
String
(
fileName
.
getBytes
(),
StandardCharsets
.
ISO_8859_1
));
PutObjectRequest
putObjectRequest
=
new
PutObjectRequest
(
bucketName
,
accessoryBaseDir
+
"/"
+
path
+
(
path
.
endsWith
(
"/"
)
?
""
:
"/"
)
+
fileName
,
is
,
meta
);
client
.
putObject
(
putObjectRequest
);
client
.
shutdown
();
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
logger
.
debug
(
"完成向aliyun-oss保存文件: {}"
,
System
.
currentTimeMillis
()
-
begin
);
return
null
;
}
}
server-common/src/main/java/com/makeit/shengwang/agora/service/ShengwangService.java
View file @
14cea1ba
...
...
@@ -3,6 +3,7 @@ package com.makeit.shengwang.agora.service;
import
com.alibaba.fastjson.JSON
;
import
com.makeit.config.ShengwangProperties
;
import
com.makeit.shengwang.agora.dto.PlatCallingDeviceDTO
;
import
com.makeit.shengwang.agora.media.RtcTokenBuilder2
;
import
com.makeit.shengwang.agora.rtm.RtmTokenBuilder2
;
import
com.makeit.shengwang.agora.vo.PlatAlarmCallDeviceVO
;
import
org.apache.commons.lang3.StringUtils
;
...
...
@@ -43,4 +44,19 @@ public class ShengwangService {
shengwangProperties
.
getTokenExpirationInSeconds
(),
TimeUnit
.
SECONDS
);
return
platAlarmCallDeviceVO
;
}
public
PlatAlarmCallDeviceVO
callingDeviceAuthIgnoreRtc
(
String
deviceId
)
{
PlatAlarmCallDeviceVO
platAlarmCallDeviceVO
=
new
PlatAlarmCallDeviceVO
();
platAlarmCallDeviceVO
.
setDeviceId
(
deviceId
);
platAlarmCallDeviceVO
.
setAppId
(
shengwangProperties
.
getAppId
());
LocalDateTime
now
=
LocalDateTime
.
now
();
DateTimeFormatter
dateTimeFormatter
=
DateTimeFormatter
.
ofPattern
(
"yyyyMMddHHmmss"
);
String
channelName
=
String
.
format
(
"%s:%s"
,
"RTC"
,
now
.
format
(
dateTimeFormatter
));
RtcTokenBuilder2
token
=
new
RtcTokenBuilder2
();
String
result
=
token
.
buildTokenWithUid
(
shengwangProperties
.
getAppId
(),
shengwangProperties
.
getAppCertificate
(),
channelName
,
0
,
RtcTokenBuilder2
.
Role
.
ROLE_SUBSCRIBER
,
shengwangProperties
.
getTokenExpirationInSeconds
(),
shengwangProperties
.
getPrivilegeExpirationInSeconds
());
platAlarmCallDeviceVO
.
setAccessToken
(
result
);
platAlarmCallDeviceVO
.
setChannelName
(
channelName
);
return
platAlarmCallDeviceVO
;
}
}
server-common/src/main/java/com/makeit/utils/FileUtils.java
0 → 100644
View file @
14cea1ba
/**
* Copyright © 2021-2026 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
*/
package
com
.
makeit
.
utils
;
import
cn.hutool.core.util.StrUtil
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
java.io.*
;
/**
* 文件操作工具类
* 实现文件的创建、删除、复制、压缩、解压以及目录的创建、删除、复制、压缩解压等功能
* @author jeeplus
* @version 2021-06-21
*/
public
class
FileUtils
extends
org
.
apache
.
commons
.
io
.
FileUtils
{
private
static
Logger
log
=
LoggerFactory
.
getLogger
(
FileUtils
.
class
);
/**
* 判断是否是文件
* @param source
*/
public
static
boolean
isFile
(
String
source
)
{
return
new
File
(
source
).
isFile
();
}
/**
* 判断是否是目录
* @param source
*/
public
static
boolean
isFolder
(
String
source
)
{
return
new
File
(
source
).
isDirectory
();
}
/**
* 复制单个文件,如果目标文件存在,则不覆盖
* @param srcFileName 待复制的文件名
* @param descFileName 目标文件名
* @return 如果复制成功,则返回true,否则返回false
*/
public
static
boolean
copyFile
(
String
srcFileName
,
String
descFileName
)
{
return
FileUtils
.
copyFileCover
(
srcFileName
,
descFileName
,
false
);
}
/**
* 复制单个文件
* @param srcFileName 待复制的文件名
* @param descFileName 目标文件名
* @param coverlay 如果目标文件已存在,是否覆盖
* @return 如果复制成功,则返回true,否则返回false
*/
public
static
boolean
copyFileCover
(
String
srcFileName
,
String
descFileName
,
boolean
coverlay
)
{
File
srcFile
=
new
File
(
srcFileName
);
// 判断源文件是否存在
if
(!
srcFile
.
exists
())
{
log
.
debug
(
"复制文件失败,源文件 "
+
srcFileName
+
" 不存在!"
);
return
false
;
}
// 判断源文件是否是合法的文件
else
if
(!
srcFile
.
isFile
())
{
log
.
debug
(
"复制文件失败,"
+
srcFileName
+
" 不是一个文件!"
);
return
false
;
}
File
descFile
=
new
File
(
descFileName
);
// 判断目标文件是否存在
if
(
descFile
.
exists
())
{
// 如果目标文件存在,并且允许覆盖
if
(
coverlay
)
{
log
.
debug
(
"目标文件已存在,准备删除!"
);
if
(!
FileUtils
.
delFile
(
descFileName
))
{
log
.
debug
(
"删除目标文件 "
+
descFileName
+
" 失败!"
);
return
false
;
}
}
else
{
log
.
debug
(
"复制文件失败,目标文件 "
+
descFileName
+
" 已存在!"
);
return
false
;
}
}
else
{
if
(!
descFile
.
getParentFile
().
exists
())
{
// 如果目标文件所在的目录不存在,则创建目录
log
.
debug
(
"目标文件所在的目录不存在,创建目录!"
);
// 创建目标文件所在的目录
if
(!
descFile
.
getParentFile
().
mkdirs
())
{
log
.
debug
(
"创建目标文件所在的目录失败!"
);
return
false
;
}
}
}
// 准备复制文件
// 读取的位数
int
readByte
=
0
;
InputStream
ins
=
null
;
OutputStream
outs
=
null
;
try
{
// 打开源文件
ins
=
new
FileInputStream
(
srcFile
);
// 打开目标文件的输出流
outs
=
new
FileOutputStream
(
descFile
);
byte
[]
buf
=
new
byte
[
1024
];
// 一次读取1024个字节,当readByte为-1时表示文件已经读取完毕
while
((
readByte
=
ins
.
read
(
buf
))
!=
-
1
)
{
// 将读取的字节流写入到输出流
outs
.
write
(
buf
,
0
,
readByte
);
}
log
.
debug
(
"复制单个文件 "
+
srcFileName
+
" 到"
+
descFileName
+
"成功!"
);
return
true
;
}
catch
(
Exception
e
)
{
log
.
debug
(
"复制文件失败:"
+
e
.
getMessage
());
return
false
;
}
finally
{
// 关闭输入输出流,首先关闭输出流,然后再关闭输入流
if
(
outs
!=
null
)
{
try
{
outs
.
close
();
}
catch
(
IOException
oute
)
{
oute
.
printStackTrace
();
}
}
if
(
ins
!=
null
)
{
try
{
ins
.
close
();
}
catch
(
IOException
ine
)
{
ine
.
printStackTrace
();
}
}
}
}
/**
* 复制整个目录的内容,如果目标目录存在,则不覆盖
* @param srcDirName 源目录名
* @param descDirName 目标目录名
* @return 如果复制成功返回true,否则返回false
*/
public
static
boolean
copyDirectory
(
String
srcDirName
,
String
descDirName
)
{
return
FileUtils
.
copyDirectoryCover
(
srcDirName
,
descDirName
,
false
);
}
/**
* 复制整个目录的内容
* @param srcDirName 源目录名
* @param descDirName 目标目录名
* @param coverlay 如果目标目录存在,是否覆盖
* @return 如果复制成功返回true,否则返回false
*/
public
static
boolean
copyDirectoryCover
(
String
srcDirName
,
String
descDirName
,
boolean
coverlay
)
{
File
srcDir
=
new
File
(
srcDirName
);
// 判断源目录是否存在
if
(!
srcDir
.
exists
())
{
log
.
debug
(
"复制目录失败,源目录 "
+
srcDirName
+
" 不存在!"
);
return
false
;
}
// 判断源目录是否是目录
else
if
(!
srcDir
.
isDirectory
())
{
log
.
debug
(
"复制目录失败,"
+
srcDirName
+
" 不是一个目录!"
);
return
false
;
}
// 如果目标文件夹名不以文件分隔符结尾,自动添加文件分隔符
String
descDirNames
=
descDirName
;
if
(!
descDirNames
.
endsWith
(
File
.
separator
))
{
descDirNames
=
descDirNames
+
File
.
separator
;
}
File
descDir
=
new
File
(
descDirNames
);
// 如果目标文件夹存在
if
(
descDir
.
exists
())
{
if
(
coverlay
)
{
// 允许覆盖目标目录
log
.
debug
(
"目标目录已存在,准备删除!"
);
if
(!
FileUtils
.
delFile
(
descDirNames
))
{
log
.
debug
(
"删除目录 "
+
descDirNames
+
" 失败!"
);
return
false
;
}
}
else
{
log
.
debug
(
"目标目录复制失败,目标目录 "
+
descDirNames
+
" 已存在!"
);
return
false
;
}
}
else
{
// 创建目标目录
log
.
debug
(
"目标目录不存在,准备创建!"
);
if
(!
descDir
.
mkdirs
())
{
log
.
debug
(
"创建目标目录失败!"
);
return
false
;
}
}
boolean
flag
=
true
;
// 列出源目录下的所有文件名和子目录名
File
[]
files
=
srcDir
.
listFiles
();
for
(
int
i
=
0
;
i
<
files
.
length
;
i
++)
{
// 如果是一个单个文件,则直接复制
if
(
files
[
i
].
isFile
())
{
flag
=
FileUtils
.
copyFile
(
files
[
i
].
getAbsolutePath
(),
descDirName
+
files
[
i
].
getName
());
// 如果拷贝文件失败,则退出循环
if
(!
flag
)
{
break
;
}
}
// 如果是子目录,则继续复制目录
if
(
files
[
i
].
isDirectory
())
{
flag
=
FileUtils
.
copyDirectory
(
files
[
i
]
.
getAbsolutePath
(),
descDirName
+
files
[
i
].
getName
());
// 如果拷贝目录失败,则退出循环
if
(!
flag
)
{
break
;
}
}
}
if
(!
flag
)
{
log
.
debug
(
"复制目录 "
+
srcDirName
+
" 到 "
+
descDirName
+
" 失败!"
);
return
false
;
}
log
.
debug
(
"复制目录 "
+
srcDirName
+
" 到 "
+
descDirName
+
" 成功!"
);
return
true
;
}
/**
*
* 删除文件,可以删除单个文件或文件夹
*
* @param fileName 被删除的文件名
* @return 如果删除成功,则返回true,否是返回false
*/
public
static
boolean
delFile
(
String
fileName
)
{
File
file
=
new
File
(
fileName
);
if
(!
file
.
exists
())
{
log
.
debug
(
fileName
+
" 文件不存在!"
);
return
true
;
}
else
{
if
(
file
.
isFile
())
{
return
FileUtils
.
deleteFile
(
fileName
);
}
else
{
return
FileUtils
.
deleteDirectory
(
fileName
);
}
}
}
/**
*
* 删除单个文件
*
* @param fileName 被删除的文件名
* @return 如果删除成功,则返回true,否则返回false
*/
public
static
boolean
deleteFile
(
String
fileName
)
{
File
file
=
new
File
(
fileName
);
if
(
file
.
exists
()
&&
file
.
isFile
())
{
if
(
file
.
delete
())
{
log
.
debug
(
"删除文件 "
+
fileName
+
" 成功!"
);
return
true
;
}
else
{
log
.
debug
(
"删除文件 "
+
fileName
+
" 失败!"
);
return
false
;
}
}
else
{
log
.
debug
(
fileName
+
" 文件不存在!"
);
return
true
;
}
}
/**
*
* 删除目录及目录下的文件
*
* @param dirName 被删除的目录所在的文件路径
* @return 如果目录删除成功,则返回true,否则返回false
*/
public
static
boolean
deleteDirectory
(
String
dirName
)
{
String
dirNames
=
dirName
;
if
(!
dirNames
.
endsWith
(
File
.
separator
))
{
dirNames
=
dirNames
+
File
.
separator
;
}
File
dirFile
=
new
File
(
dirNames
);
if
(!
dirFile
.
exists
()
||
!
dirFile
.
isDirectory
())
{
log
.
debug
(
dirNames
+
" 目录不存在!"
);
return
true
;
}
boolean
flag
=
true
;
// 列出全部文件及子目录
File
[]
files
=
dirFile
.
listFiles
();
for
(
int
i
=
0
;
i
<
files
.
length
;
i
++)
{
// 删除子文件
if
(
files
[
i
].
isFile
())
{
flag
=
FileUtils
.
deleteFile
(
files
[
i
].
getAbsolutePath
());
// 如果删除文件失败,则退出循环
if
(!
flag
)
{
break
;
}
}
// 删除子目录
else
if
(
files
[
i
].
isDirectory
())
{
flag
=
FileUtils
.
deleteDirectory
(
files
[
i
]
.
getAbsolutePath
());
// 如果删除子目录失败,则退出循环
if
(!
flag
)
{
break
;
}
}
}
if
(!
flag
)
{
log
.
debug
(
"删除目录失败!"
);
return
false
;
}
// 删除当前目录
if
(
dirFile
.
delete
())
{
log
.
debug
(
"删除目录 "
+
dirName
+
" 成功!"
);
return
true
;
}
else
{
log
.
debug
(
"删除目录 "
+
dirName
+
" 失败!"
);
return
false
;
}
}
/**
* 创建单个文件
* @param descFileName 文件名,包含路径
* @return 如果创建成功,则返回true,否则返回false
*/
public
static
boolean
createFile
(
String
descFileName
)
{
File
file
=
new
File
(
descFileName
);
if
(
file
.
exists
())
{
log
.
debug
(
"文件 "
+
descFileName
+
" 已存在!"
);
return
false
;
}
if
(
descFileName
.
endsWith
(
File
.
separator
))
{
log
.
debug
(
descFileName
+
" 为目录,不能创建目录!"
);
return
false
;
}
if
(!
file
.
getParentFile
().
exists
())
{
// 如果文件所在的目录不存在,则创建目录
if
(!
file
.
getParentFile
().
mkdirs
())
{
log
.
debug
(
"创建文件所在的目录失败!"
);
return
false
;
}
}
// 创建文件
try
{
if
(
file
.
createNewFile
())
{
log
.
debug
(
descFileName
+
" 文件创建成功!"
);
return
true
;
}
else
{
log
.
debug
(
descFileName
+
" 文件创建失败!"
);
return
false
;
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
log
.
debug
(
descFileName
+
" 文件创建失败!"
);
return
false
;
}
}
/**
* 创建目录
* @param descDirName 目录名,包含路径
* @return 如果创建成功,则返回true,否则返回false
*/
public
static
boolean
createDirectory
(
String
descDirName
)
{
String
descDirNames
=
descDirName
;
if
(!
descDirNames
.
endsWith
(
File
.
separator
))
{
descDirNames
=
descDirNames
+
File
.
separator
;
}
File
descDir
=
new
File
(
descDirNames
);
if
(
descDir
.
exists
())
{
log
.
debug
(
"目录 "
+
descDirNames
+
" 已存在!"
);
return
false
;
}
// 创建目录
if
(
descDir
.
mkdirs
())
{
log
.
debug
(
"目录 "
+
descDirNames
+
" 创建成功!"
);
return
true
;
}
else
{
log
.
debug
(
"目录 "
+
descDirNames
+
" 创建失败!"
);
return
false
;
}
}
/**
* 获取可以创建的文件名(如果有同名文件存在,参照Windows系统重命名为xxx(2).xxx)
* @param name
* @param index
* @return
*/
public
static
File
getAvailableFile
(
String
name
,
int
index
){
File
newFile
=
null
;
String
suffix
=
StrUtil
.
subAfter
(
name
,
"."
,
true
);
String
filePath
=
StrUtil
.
subBefore
(
name
,
"."
,
true
);
if
(
index
==
0
){
newFile
=
new
File
(
filePath
+
"."
+
suffix
);
}
else
{
newFile
=
new
File
(
filePath
+
"("
+
index
+
")"
+
"."
+
suffix
);
}
if
(
newFile
.
exists
()){
return
getAvailableFile
(
name
,
index
+
1
);
}
else
{
return
newFile
;
}
};
/**
* 获取可以创建的目录名(如果有同名目录存在,参照Windows系统重命名为xxx(2))
* @param name
* @param index
* @return
*/
public
static
File
getAvailableFolder
(
String
name
,
int
index
){
File
newFolder
=
null
;
if
(
index
==
0
){
newFolder
=
new
File
(
name
);
}
else
{
newFolder
=
new
File
(
name
+
"("
+
index
+
")"
);
}
if
(
newFolder
.
exists
()){
return
getAvailableFolder
(
name
,
index
+
1
);
}
else
{
return
newFolder
;
}
};
/**
* 写入文件
*/
public
static
void
writeToFile
(
String
fileName
,
String
content
,
boolean
append
)
{
try
{
FileUtils
.
write
(
new
File
(
fileName
),
content
,
"utf-8"
,
append
);
log
.
debug
(
"文件 "
+
fileName
+
" 写入成功!"
);
}
catch
(
IOException
e
)
{
log
.
debug
(
"文件 "
+
fileName
+
" 写入失败! "
+
e
.
getMessage
());
}
}
/**
* 写入文件
*/
public
static
void
writeToFile
(
String
fileName
,
String
content
,
String
encoding
,
boolean
append
)
{
try
{
FileUtils
.
write
(
new
File
(
fileName
),
content
,
encoding
,
append
);
log
.
debug
(
"文件 "
+
fileName
+
" 写入成功!"
);
}
catch
(
IOException
e
)
{
log
.
debug
(
"文件 "
+
fileName
+
" 写入失败! "
+
e
.
getMessage
());
}
}
/**
* 获取待压缩文件在ZIP文件中entry的名字,即相对于跟目录的相对路径名
* @param dirPath 目录名
* @param file entry文件名
* @return
*/
private
static
String
getEntryName
(
String
dirPath
,
File
file
)
{
String
dirPaths
=
dirPath
;
if
(!
dirPaths
.
endsWith
(
File
.
separator
))
{
dirPaths
=
dirPaths
+
File
.
separator
;
}
String
filePath
=
file
.
getAbsolutePath
();
// 对于目录,必须在entry名字后面加上"/",表示它将以目录项存储
if
(
file
.
isDirectory
())
{
filePath
+=
"/"
;
}
int
index
=
filePath
.
indexOf
(
dirPaths
);
return
filePath
.
substring
(
index
+
dirPaths
.
length
());
}
}
server-common/src/main/java/com/makeit/utils/data/excel/ExcelValidatorUtil.java
View file @
14cea1ba
package
com
.
makeit
.
utils
.
data
.
excel
;
import
cn.hutool.core.collection.CollUtil
;
import
com.alibaba.excel.annotation.ExcelProperty
;
import
com.makeit.common.vo.ExcelErrorVo
;
import
com.makeit.common.vo.ExcelImportVo
;
...
...
@@ -194,18 +195,23 @@ public class ExcelValidatorUtil {
}
List
<
ExcelErrorVo
>
errorVoList
=
bizValidate
(
beanMap
,
row
.
stream
().
collect
(
Collectors
.
groupingBy
(
ExcelErrorVo:
:
getTitle
)),
start
+
i
,
o
);
if
(
errorVoList
==
null
||
errorVoList
.
isEmpty
())
{
if
(
CollUtil
.
isEmpty
(
errorVoList
)
||
errorVoList
.
isEmpty
())
{
successCount
++;
}
excelErrorVoList
.
addAll
(
errorVoList
);
}
int
errorCount
=
list
.
size
()
-
successCount
;
ExcelImportVo
excelImportVo
=
new
ExcelImportVo
();
excelImportVo
.
setTotalCount
(
list
.
size
());
excelImportVo
.
setErrorCount
(
list
.
size
()
-
success
Count
);
excelImportVo
.
setErrorCount
(
error
Count
);
excelImportVo
.
setSuccessCount
(
successCount
);
excelImportVo
.
setList
(
excelErrorVoList
);
excelImportVo
.
setMatchesCount
(
successCount
);
if
(
errorCount
>
0
)
{
excelImportVo
.
setSuccessCount
(
0
);
}
if
(
excelImportVo
.
getErrorCount
()
==
0
&&
saveBatch
!=
null
)
{
saveBatch
.
accept
(
list
);
...
...
server-generator/src/test/java/CodeGenerator.java
View file @
14cea1ba
...
...
@@ -106,7 +106,7 @@ public class CodeGenerator {
// 使用重点 下列字段填写表名 运行方法
// strategy.setInclude("edu_teacher","..."); // 多表-逆向工程
strategy
.
setInclude
(
"plat_
region_setting_fix"
,
"plat_elder_coordinate_record
"
);
strategy
.
setInclude
(
"plat_
device_log
"
);
strategy
.
setNaming
(
NamingStrategy
.
underline_to_camel
);
//数据库表映射到实体的命名策略
strategy
.
setTablePrefix
(
pc
.
getModuleName
()
+
"_"
);
//生成实体属性时去掉表"_"前缀并且第一个字母大写 如:gmt_create -> gmtCreate
...
...
server-module/src/main/java/com/makeit/module/controller/alarm/PlatAlarmRecordController.java
View file @
14cea1ba
...
...
@@ -59,6 +59,14 @@ public class PlatAlarmRecordController {
return
ApiResponseUtils
.
success
();
}
@PostMapping
(
"misinformation1"
)
@AuthIgnore
@TenantIdIgnore
public
ApiResponseEntity
<
Void
>
misinformation1
(
@RequestBody
BaseIdDTO
dto
)
{
platAlarmRecordService
.
misinformation
(
dto
.
getId
());
return
ApiResponseUtils
.
success
();
}
@ApiOperation
(
"未读条数"
)
@PostMapping
(
"unreadCount"
)
public
ApiResponseEntity
<
Integer
>
unreadCount
(
@RequestBody
PlatAlarmRecordQueryDTO
dto
)
{
...
...
server-module/src/main/java/com/makeit/module/controller/children/alarm/PlatAlarmRecordChildrenController.java
View file @
14cea1ba
...
...
@@ -7,6 +7,7 @@ import com.makeit.common.page.PageVO;
import
com.makeit.common.response.ApiResponseEntity
;
import
com.makeit.common.response.ApiResponseUtils
;
import
com.makeit.dto.platform.alarm.PlatAlarmRecordQueryDTO
;
import
com.makeit.enums.report.PlatformTypeEnum
;
import
com.makeit.global.aspect.tenant.TenantIdIgnore
;
import
com.makeit.service.platform.alarm.PlatAlarmRecordService
;
import
com.makeit.vo.platform.alarm.PlatAlarmRecordVO
;
...
...
@@ -44,7 +45,7 @@ public class PlatAlarmRecordChildrenController {
@PostMapping
(
"read"
)
@TenantIdIgnore
public
ApiResponseEntity
<
Void
>
read
(
@RequestBody
BaseIdDTO
dto
)
{
platAlarmRecordService
.
read
(
dto
.
getId
());
platAlarmRecordService
.
read
(
dto
.
getId
()
,
PlatformTypeEnum
.
PC
);
return
ApiResponseUtils
.
success
();
}
...
...
server-module/src/main/java/com/makeit/module/controller/space/PlatSpaceController.java
View file @
14cea1ba
...
...
@@ -17,11 +17,7 @@ import io.swagger.annotations.Api;
import
io.swagger.annotations.ApiOperation
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.multipart.MultipartFile
;
import
javax.servlet.http.HttpServletResponse
;
...
...
server-module/src/main/java/com/makeit/module/controller/wechat/alarm/PlatAlarmRecordWechatController.java
View file @
14cea1ba
...
...
@@ -9,6 +9,7 @@ import com.makeit.common.response.ApiResponseEntity;
import
com.makeit.common.response.ApiResponseUtils
;
import
com.makeit.dto.platform.alarm.PlatAlarmRecordQueryDTO
;
import
com.makeit.enums.CommonEnum
;
import
com.makeit.enums.report.PlatformTypeEnum
;
import
com.makeit.service.platform.alarm.PlatAlarmRecordService
;
import
com.makeit.utils.user.common.CommonUserUtil
;
import
com.makeit.vo.platform.alarm.PlatAlarmRecordVO
;
...
...
@@ -61,7 +62,7 @@ public class PlatAlarmRecordWechatController {
@ApiOperation
(
"已读"
)
@PostMapping
(
"read"
)
public
ApiResponseEntity
<
Void
>
read
(
@RequestBody
BaseIdDTO
dto
)
{
platAlarmRecordService
.
read
(
dto
.
getId
());
platAlarmRecordService
.
read
(
dto
.
getId
()
,
PlatformTypeEnum
.
WECHAT
);
return
ApiResponseUtils
.
success
();
}
@ApiOperation
(
"通知家属"
)
...
...
server-service/src/main/java/com/makeit/dto/platform/alarm/PlatAlarmRecordQueryDTO.java
View file @
14cea1ba
...
...
@@ -70,6 +70,9 @@ public class PlatAlarmRecordQueryDTO extends BaseTenantDTO {
private
String
readFlag
;
@ApiModelProperty
(
value
=
"微信端 0-未读 1-已读"
)
private
String
wechatReadFlag
;
}
server-service/src/main/java/com/makeit/dto/platform/auth/PlatUserImportDTO.java
View file @
14cea1ba
...
...
@@ -25,6 +25,12 @@ public class PlatUserImportDTO {
private
String
roleName
;
@ExcelProperty
(
value
=
{
headDesc
,
"备注"
})
private
String
remark
;
/**
* excel中无此字段
* 导入手机号会作为账号使用,所以导入需要特殊处理,手机号没有判重后,账号要再判断下有没有判重
*/
@ExcelProperty
(
value
=
{
headDesc
,
"账户"
})
private
String
account
;
@ExcelIgnore
...
...
server-service/src/main/java/com/makeit/dto/platform/device/PlatDeviceBaseAttrDTO.java
View file @
14cea1ba
...
...
@@ -45,7 +45,7 @@ public class PlatDeviceBaseAttrDTO {
@Data
static
class
DeviceAttrRange
{
public
static
class
DeviceAttrRange
{
private
Integer
max
;
private
Integer
min
;
}
...
...
server-service/src/main/java/com/makeit/dto/platform/device/PlatDeviceQueryDTO.java
View file @
14cea1ba
...
...
@@ -39,6 +39,8 @@ public class PlatDeviceQueryDTO extends BaseTenantDTO {
@ApiModelProperty
(
value
=
"组织id"
)
private
String
orgId
;
@ApiModelProperty
(
value
=
"设备是否激活 1 激活 0 没激活"
)
private
Integer
active
;
@ApiModelProperty
(
value
=
"数据权限"
)
private
List
<
String
>
orgIds
;
...
...
server-service/src/main/java/com/makeit/dto/platform/elder/children/PlatElderChildrenInfoDTOVO.java
View file @
14cea1ba
...
...
@@ -28,8 +28,6 @@ public class PlatElderChildrenInfoDTOVO extends BaseTenantDTO {
@ApiModelProperty
(
value
=
"长者id"
)
private
String
elderName
;
@NotBlank
(
message
=
"姓名不能为空"
)
@Size
(
max
=
50
,
message
=
"姓名最长为50个字符"
)
@ApiModelProperty
(
value
=
"姓名"
)
private
String
name
;
...
...
server-service/src/main/java/com/makeit/entity/platform/alarm/PlatAlarmRecord.java
View file @
14cea1ba
...
...
@@ -91,6 +91,9 @@ public class PlatAlarmRecord extends BaseBusEntity {
@ApiModelProperty
(
value
=
"是否误报 1 误报 0 没有误报"
)
private
String
misinformationFlag
;
@ApiModelProperty
(
value
=
"微信端 0-未读 1-已读"
)
private
String
wechatReadFlag
;
}
...
...
server-service/src/main/java/com/makeit/entity/platform/device/PlatDevice.java
View file @
14cea1ba
package
com
.
makeit
.
entity
.
platform
.
device
;
import
com.baomidou.mybatisplus.annotation.TableField
;
import
com.fasterxml.jackson.annotation.JsonFormat
;
import
com.makeit.common.entity.BaseBusEntity
;
import
com.makeit.module.iot.enums.DeviceState
;
...
...
@@ -81,6 +82,9 @@ public class PlatDevice extends BaseBusEntity {
private
Long
expireTime
;
@ApiModelProperty
(
value
=
"激活时间"
)
private
Long
activationTime
;
@ApiModelProperty
(
value
=
"设备是否激活 1 激活 0 没激活"
)
@TableField
(
exist
=
false
)
private
Integer
active
;
@ApiModelProperty
(
value
=
"设备类型 0-呼吸心率雷达 1-空间人体雷达 2-跌倒检测雷达"
)
private
String
category
;
...
...
@@ -92,4 +96,5 @@ public class PlatDevice extends BaseBusEntity {
private
LocalDateTime
endDate
;
}
server-service/src/main/java/com/makeit/entity/platform/device/PlatDeviceLog.java
0 → 100644
View file @
14cea1ba
package
com
.
makeit
.
entity
.
platform
.
device
;
import
com.baomidou.mybatisplus.annotation.TableField
;
import
com.fasterxml.jackson.annotation.JsonFormat
;
import
com.makeit.common.entity.BaseBusEntity
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
lombok.EqualsAndHashCode
;
import
java.time.LocalDateTime
;
/**
* <p>
* 设备日志
* </p>
*
* @author eugene young
* @since 2023-12-01
*/
@Data
@EqualsAndHashCode
(
callSuper
=
true
)
@ApiModel
(
value
=
"PlatDeviceLog对象"
,
description
=
"设备日志"
)
public
class
PlatDeviceLog
extends
BaseBusEntity
{
private
static
final
long
serialVersionUID
=
1L
;
@ApiModelProperty
(
value
=
"iot设备sn"
)
private
String
deviceId
;
@ApiModelProperty
(
value
=
"类型 1 误报"
)
private
String
type
;
@ApiModelProperty
(
value
=
"产品名称"
)
private
String
productName
;
@ApiModelProperty
(
value
=
"日志url"
)
private
String
url
;
@ApiModelProperty
(
value
=
"文件名称"
)
private
String
fileName
;
@JsonFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
)
@ApiModelProperty
(
"开始时间"
)
@TableField
(
exist
=
false
)
private
LocalDateTime
startTime
;
@JsonFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
)
@ApiModelProperty
(
"结束时间"
)
@TableField
(
exist
=
false
)
private
LocalDateTime
endTime
;
}
server-service/src/main/java/com/makeit/enums/report/PlatformTypeEnum.java
0 → 100644
View file @
14cea1ba
package
com
.
makeit
.
enums
.
report
;
import
lombok.AllArgsConstructor
;
import
lombok.Getter
;
/**
* @author wangz
*/
@Getter
@AllArgsConstructor
public
enum
PlatformTypeEnum
{
PC
(
"1"
,
"pc端"
),
WECHAT
(
"2"
,
"微信小程序"
);
private
String
code
;
private
String
value
;
}
server-service/src/main/java/com/makeit/mapper/platform/device/PlatDeviceLogMapper.java
0 → 100644
View file @
14cea1ba
package
com
.
makeit
.
mapper
.
platform
.
device
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
com.makeit.entity.platform.device.PlatDeviceLog
;
/**
* <p>
* 设备日志 Mapper 接口
* </p>
*
* @author eugene young
* @since 2023-12-01
*/
public
interface
PlatDeviceLogMapper
extends
BaseMapper
<
PlatDeviceLog
>
{
}
server-service/src/main/java/com/makeit/service/platform/alarm/PlatAlarmRecordService.java
View file @
14cea1ba
...
...
@@ -9,6 +9,7 @@ import com.makeit.dto.platform.alarm.PlatAlarmRecordQueryDTO;
import
com.makeit.entity.platform.alarm.PlatAlarmConfig
;
import
com.makeit.entity.platform.alarm.PlatAlarmRecord
;
import
com.makeit.entity.platform.elder.PlatElder
;
import
com.makeit.enums.report.PlatformTypeEnum
;
import
com.makeit.shengwang.agora.dto.PlatCallingDeviceDTO
;
import
com.makeit.shengwang.agora.vo.PlatAlarmCallDeviceVO
;
import
com.makeit.vo.platform.alarm.PlatAlarmRecordVO
;
...
...
@@ -64,7 +65,7 @@ public interface PlatAlarmRecordService extends IService<PlatAlarmRecord> {
void
dealAlarm
(
BaseIdDTO
dto
);
void
read
(
String
id
);
void
read
(
String
id
,
PlatformTypeEnum
typeEnum
);
Integer
unreadCount
(
PlatAlarmRecordQueryDTO
dto
);
...
...
server-service/src/main/java/com/makeit/service/platform/alarm/impl/PlatAlarmRecordServiceImpl.java
View file @
14cea1ba
...
...
@@ -13,7 +13,6 @@ import com.makeit.common.entity.BaseBusEntity;
import
com.makeit.common.entity.BaseEntity
;
import
com.makeit.common.page.PageReqDTO
;
import
com.makeit.common.page.PageVO
;
import
com.makeit.config.ShengwangProperties
;
import
com.makeit.dto.platform.alarm.PlatAlarmCheckDTO
;
import
com.makeit.dto.platform.alarm.PlatAlarmRecordQueryDTO
;
import
com.makeit.entity.platform.alarm.PlatAlarmConfig
;
...
...
@@ -28,9 +27,11 @@ import com.makeit.entity.platform.space.PlatRoom;
import
com.makeit.entity.platform.space.PlatRoomBedDevice
;
import
com.makeit.entity.saas.PlatTenant
;
import
com.makeit.enums.CommonEnum
;
import
com.makeit.enums.report.PlatformTypeEnum
;
import
com.makeit.exception.BusinessException
;
import
com.makeit.global.aspect.tenant.TenantIdIgnore
;
import
com.makeit.mapper.platform.alarm.PlatAlarmRecordMapper
;
import
com.makeit.module.iot.service.IotDevicePropertiesOperateService
;
import
com.makeit.service.platform.alarm.PlatAlarmConfigService
;
import
com.makeit.service.platform.alarm.PlatAlarmRecordService
;
import
com.makeit.service.platform.auth.PlatOrgService
;
...
...
@@ -43,8 +44,6 @@ import com.makeit.service.platform.space.PlatRoomBedDeviceService;
import
com.makeit.service.platform.space.PlatRoomService
;
import
com.makeit.service.saas.PlatTenantService
;
import
com.makeit.shengwang.agora.dto.PlatCallingDeviceDTO
;
import
com.makeit.shengwang.agora.media.RtcTokenBuilder2
;
import
com.makeit.shengwang.agora.rtm.RtmTokenBuilder2
;
import
com.makeit.shengwang.agora.service.ShengwangService
;
import
com.makeit.shengwang.agora.vo.PlatAlarmCallDeviceVO
;
import
com.makeit.utils.data.convert.BeanDtoVoUtils
;
...
...
@@ -62,14 +61,12 @@ import lombok.extern.slf4j.Slf4j;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.redis.core.StringRedisTemplate
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
java.sql.Timestamp
;
import
java.time.LocalDateTime
;
import
java.time.format.DateTimeFormatter
;
import
java.util.*
;
import
java.util.concurrent.TimeUnit
;
import
java.util.regex.Matcher
;
import
java.util.regex.Pattern
;
import
java.util.stream.Collectors
;
...
...
@@ -111,9 +108,9 @@ public class PlatAlarmRecordServiceImpl extends ServiceImpl<PlatAlarmRecordMappe
@Autowired
private
PlatDeviceService
platDeviceService
;
@Autowired
private
ShengwangProperties
shengwangProperties
;
@Autowired
private
ShengwangService
shengwangService
;
@Autowired
private
IotDevicePropertiesOperateService
iotDevicePropertiesOperateService
;
@Override
...
...
@@ -127,6 +124,14 @@ public class PlatAlarmRecordServiceImpl extends ServiceImpl<PlatAlarmRecordMappe
JoinUtil
.
join
(
dtos
,
platAlarmConfigService
,
PlatAlarmRecordVO:
:
getAlarmId
,
BaseEntity:
:
getId
,
(
t
,
m
)
->
t
.
setNotifyRelation
(
m
.
getNotifyRelation
()));
List
<
PlatDevice
>
platDeviceList
=
platDeviceService
.
list
();
Map
<
String
,
PlatDevice
>
deviceMap
=
StreamUtil
.
toMap
(
platDeviceList
,
BaseEntity:
:
getId
);
for
(
PlatAlarmRecordVO
platAlarmRecordVO
:
dtos
)
{
PlatDevice
platDevice
=
deviceMap
.
get
(
platAlarmRecordVO
.
getDeviceId
());
if
(
platDevice
!=
null
)
{
platAlarmRecordVO
.
setDevice
(
platDevice
);
}
}
return
PageUtil
.
toPageVO
(
dtos
,
page
);
}
...
...
@@ -162,18 +167,27 @@ public class PlatAlarmRecordServiceImpl extends ServiceImpl<PlatAlarmRecordMappe
choiceOrgIdList
.
addAll
(
Lists
.
newArrayList
(
param
.
getOrgId
().
split
(
","
)));
}
List
<
String
>
orgIdList
=
Lists
.
newArrayList
();
if
(
CollectionUtils
.
isNotEmpty
(
choiceOrgIdList
))
{
orgIdList
=
choiceOrgIdList
;
}
if
(
CollectionUtils
.
isNotEmpty
(
typeOrgIdList
))
{
if
(
com
.
makeit
.
utils
.
old
.
StringUtils
.
isNotEmpty
(
param
.
getType
())
&&
com
.
makeit
.
utils
.
old
.
StringUtils
.
isEmpty
(
param
.
getOrgId
()))
{
orgIdList
=
typeOrgIdList
;
if
(
CollectionUtils
.
isEmpty
(
orgIdList
))
{
orgIdList
.
add
(
"-1"
);
}
}
if
(
CollectionUtils
.
isNotEmpty
(
choiceOrgIdList
)
&&
CollectionUtils
.
isNotEmpty
(
typeOrgIdList
))
{
orgIdList
=
new
ArrayList
<>(
CollectionUtils
.
intersection
(
typeOrgIdList
,
choiceOrgIdList
));
if
(
com
.
makeit
.
utils
.
old
.
StringUtils
.
isNotEmpty
(
param
.
getOrgId
())
&&
com
.
makeit
.
utils
.
old
.
StringUtils
.
isEmpty
(
param
.
getType
()))
{
orgIdList
=
choiceOrgIdList
;
if
(
CollectionUtils
.
isEmpty
(
orgIdList
))
{
orgIdList
.
add
(
"-1"
);
}
}
if
(
com
.
makeit
.
utils
.
old
.
StringUtils
.
isNotEmpty
(
param
.
getOrgId
())
&&
com
.
makeit
.
utils
.
old
.
StringUtils
.
isNotEmpty
(
param
.
getType
()))
{
if
(
CollectionUtils
.
isNotEmpty
(
choiceOrgIdList
)
&&
CollectionUtils
.
isNotEmpty
(
typeOrgIdList
))
{
orgIdList
=
new
ArrayList
<>(
CollectionUtils
.
intersection
(
typeOrgIdList
,
choiceOrgIdList
));
if
(
CollectionUtils
.
isEmpty
(
orgIdList
))
{
orgIdList
.
add
(
"-1"
);
}
}
}
return
new
LambdaQueryWrapper
<
PlatAlarmRecord
>().
ge
(
Objects
.
nonNull
(
param
.
getCreateDateFrom
()),
BaseEntity:
:
getCreateDate
,
param
.
getCreateDateFrom
())
.
eq
(
StringUtils
.
isNotBlank
(
param
.
getId
()),
BaseEntity:
:
getId
,
param
.
getId
())
...
...
@@ -188,6 +202,7 @@ public class PlatAlarmRecordServiceImpl extends ServiceImpl<PlatAlarmRecordMappe
.
in
(
CollectionUtils
.
isNotEmpty
(
param
.
getElderIdList
()),
PlatAlarmRecord:
:
getElderIds
,
param
.
getElderIdList
())
.
eq
(
StringUtils
.
isNotBlank
(
param
.
getNoticeStatus
()),
PlatAlarmRecord:
:
getNoticeStatus
,
param
.
getNoticeStatus
())
.
eq
(
StringUtils
.
isNotBlank
(
param
.
getReadFlag
()),
PlatAlarmRecord:
:
getReadFlag
,
param
.
getReadFlag
())
.
eq
(
StringUtils
.
isNotBlank
(
param
.
getWechatReadFlag
()),
PlatAlarmRecord:
:
getWechatReadFlag
,
param
.
getWechatReadFlag
())
.
orderByDesc
(
BaseEntity:
:
getCreateDate
)
;
}
...
...
@@ -540,11 +555,15 @@ public class PlatAlarmRecordServiceImpl extends ServiceImpl<PlatAlarmRecordMappe
}
@Override
@Transactional
public
void
read
(
String
id
)
{
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
read
(
String
id
,
PlatformTypeEnum
typeEnum
)
{
LambdaUpdateWrapper
<
PlatAlarmRecord
>
recordLambdaUpdateWrapper
=
Wrappers
.
lambdaUpdate
(
PlatAlarmRecord
.
class
)
.
eq
(
BaseEntity:
:
getId
,
id
)
.
set
(
PlatAlarmRecord:
:
getReadFlag
,
CommonEnum
.
YES
.
getValue
());
.
eq
(
BaseEntity:
:
getId
,
id
);
if
(
PlatformTypeEnum
.
WECHAT
.
equals
(
typeEnum
))
{
recordLambdaUpdateWrapper
.
set
(
PlatAlarmRecord:
:
getWechatReadFlag
,
CommonEnum
.
YES
.
getValue
());
}
else
{
recordLambdaUpdateWrapper
.
set
(
PlatAlarmRecord:
:
getReadFlag
,
CommonEnum
.
YES
.
getValue
());
}
update
(
recordLambdaUpdateWrapper
);
}
...
...
@@ -578,15 +597,21 @@ public class PlatAlarmRecordServiceImpl extends ServiceImpl<PlatAlarmRecordMappe
platAlarmRecord
.
setStatus
(
CommonEnum
.
YES
.
getValue
());
platAlarmRecord
.
setDealDate
(
LocalDateTime
.
now
());
CommonUserVO
user
=
CommonUserUtil
.
getUser
();
platAlarmRecord
.
setDealUser
(
user
.
getName
());
//
platAlarmRecord.setDealUser(user.getName());
updateById
(
platAlarmRecord
);
// todo 误报结果写入设备
String
deviceId
=
platAlarmRecord
.
getDeviceId
();
PlatDevice
platDevice
=
platDeviceService
.
getById
(
deviceId
);
if
(
platDevice
==
null
)
{
throw
new
RuntimeException
(
"找不到告警关联的设备,设备已解绑"
+
deviceId
);
}
Timestamp
timestamp
=
Timestamp
.
valueOf
(
platAlarmRecord
.
getCreateDate
());
log
.
info
(
"开始想设备发送误报通知"
);
iotDevicePropertiesOperateService
.
deviceFunctionAttr
(
platDevice
.
getOriDeviceId
(),
timestamp
.
getTime
());
}
@Override
public
PlatAlarmCallDeviceVO
callingDevice
(
PlatCallingDeviceDTO
dto
)
{
PlatAlarmCallDeviceVO
platAlarmCallDeviceVO
=
new
PlatAlarmCallDeviceVO
();
PlatAlarmRecord
platAlarmRecord
=
getById
(
dto
.
getId
());
if
(
platAlarmRecord
==
null
)
{
throw
new
RuntimeException
(
"告警记录为空:"
+
dto
.
getId
());
...
...
@@ -596,17 +621,7 @@ public class PlatAlarmRecordServiceImpl extends ServiceImpl<PlatAlarmRecordMappe
if
(
platDevice
==
null
)
{
throw
new
RuntimeException
(
"找不到告警关联的设备,设备已解绑"
+
deviceId
);
}
platAlarmCallDeviceVO
.
setDeviceId
(
platDevice
.
getOriDeviceId
());
platAlarmCallDeviceVO
.
setAppId
(
shengwangProperties
.
getAppId
());
LocalDateTime
now
=
LocalDateTime
.
now
();
DateTimeFormatter
dateTimeFormatter
=
DateTimeFormatter
.
ofPattern
(
"yyyyMMddHHmmss"
);
String
channelName
=
String
.
format
(
"%s:%s"
,
"RTC"
,
now
.
format
(
dateTimeFormatter
));
RtcTokenBuilder2
token
=
new
RtcTokenBuilder2
();
String
result
=
token
.
buildTokenWithUid
(
shengwangProperties
.
getAppId
(),
shengwangProperties
.
getAppCertificate
(),
channelName
,
0
,
RtcTokenBuilder2
.
Role
.
ROLE_SUBSCRIBER
,
shengwangProperties
.
getTokenExpirationInSeconds
(),
shengwangProperties
.
getPrivilegeExpirationInSeconds
());
platAlarmCallDeviceVO
.
setAccessToken
(
result
);
platAlarmCallDeviceVO
.
setChannelName
(
channelName
);
return
platAlarmCallDeviceVO
;
return
shengwangService
.
callingDeviceAuthIgnoreRtc
(
platDevice
.
getOriDeviceId
());
}
@Override
...
...
server-service/src/main/java/com/makeit/service/platform/auth/impl/PlatOrgServiceImpl.java
View file @
14cea1ba
...
...
@@ -413,11 +413,6 @@ public class PlatOrgServiceImpl extends ServiceImpl<PlatOrgMapper, PlatOrg>
.
eq
(
PlatOrg:
:
getStatus
,
CommonEnum
.
YES
.
getValue
())
);
if
(
typeFlag
||
nameFlag
)
{
Map
<
String
,
List
<
PlatOrg
>>
parentIdMap
=
orgList
.
stream
().
collect
(
Collectors
.
groupingBy
(
PlatOrg:
:
getParentId
));
orgList
.
forEach
(
vo
->
{
List
<
PlatOrg
>
childList
=
parentIdMap
.
get
(
vo
.
getId
());
vo
.
setChildren
(
childList
);
});
return
orgList
;
}
return
getOrgTree
(
orgList
,
Collections
.
singletonList
(
TenantIdUtil
.
getTenantId
()));
...
...
server-service/src/main/java/com/makeit/service/platform/auth/impl/PlatUserServiceImpl.java
View file @
14cea1ba
package
com
.
makeit
.
service
.
platform
.
auth
.
impl
;
import
cn.hutool.core.collection.CollUtil
;
import
cn.hutool.core.util.StrUtil
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper
;
...
...
@@ -219,23 +221,33 @@ public class PlatUserServiceImpl extends ServiceImpl<PlatUserMapper, PlatUser>
}
/**
* 平台用户唯一校验
* @param dto
*/
private
void
checkPerson
(
PlatPersonDTOVO
dto
)
{
// 账户全局唯一
List
<
PlatUser
>
countList
=
list
(
Wrappers
.<
PlatUser
>
lambdaQuery
().
eq
(
PlatUser:
:
getAccount
,
dto
.
getAccount
())
.
ne
(
StrUtil
.
isNotBlank
(
dto
.
getId
()),
PlatUser:
:
getId
,
dto
.
getId
()));
List
<
PlatUser
>
userList
=
list
(
new
QueryWrapper
<
PlatUser
>().
lambda
()
.
eq
(
PlatUser:
:
getIsTenant
,
IsTenantAccountEnum
.
NO
.
getValue
())
.
and
(
qw
->
qw
.
eq
(
PlatUser:
:
getAccount
,
dto
.
getAccount
())
.
or
()
.
eq
(
PlatUser:
:
getMobile
,
dto
.
getMobile
())
.
and
(
qw
->
qw
.
eq
(
PlatUser:
:
getMobile
,
dto
.
getMobile
())
.
or
()
.
eq
(
StringUtils
.
isNotBlank
(
dto
.
getEmail
()),
PlatUser:
:
getEmail
,
dto
.
getEmail
())
)
);
if
(
CollUtil
.
isNotEmpty
(
countList
))
{
throw
new
BusinessException
(
CodeMessageEnum
.
SYSTEM_ERROR_USER_ACCOUNT_DUPLICATE
);
}
userList
.
forEach
(
e
->
{
if
(
e
.
getAccount
().
equals
(
dto
.
getAccount
())
&&
!
e
.
getId
().
equals
(
dto
.
getId
()))
{
throw
new
BusinessException
(
CodeMessageEnum
.
SYSTEM_ERROR_USER_ACCOUNT_DUPLICATE
);
}
//
if (e.getAccount().equals(dto.getAccount()) && !e.getId().equals(dto.getId())) {
//
throw new BusinessException(CodeMessageEnum.SYSTEM_ERROR_USER_ACCOUNT_DUPLICATE);
//
}
if
(
e
.
getMobile
().
equals
(
dto
.
getMobile
())
&&
!
e
.
getId
().
equals
(
dto
.
getId
()))
{
throw
new
BusinessException
(
CodeMessageEnum
.
SYSTEM_ERROR_USER_MOBILE_DUPLICATE
);
}
...
...
@@ -599,6 +611,7 @@ public class PlatUserServiceImpl extends ServiceImpl<PlatUserMapper, PlatUser>
TokenUtil
.
platLogin
(
TokenUtil
.
tntGetToken
(),
userLoginVO
);
supperRoleMenuList
(
userLoginVO
);
filterOrgManageMenu
(
userLoginVO
);
setRoleMenuToRedis
(
userLoginVO
);
return
userLoginVO
;
}
...
...
@@ -607,12 +620,36 @@ public class PlatUserServiceImpl extends ServiceImpl<PlatUserMapper, PlatUser>
List
<
PlatMenu
>
menuList
=
getMenuListByUserId
(
userLoginVO
);
fillMenuList
(
menuList
,
userLoginVO
);
filterOrgManageMenu
(
userLoginVO
);
setRoleMenuToRedis
(
userLoginVO
);
return
userLoginVO
;
}
/**
* 用户所在的角色不是根组织上的角色,就不返回 “组织管理” 菜单
* @param userLoginVO
*/
private
void
filterOrgManageMenu
(
PlatUserLoginVO
userLoginVO
)
{
List
<
PlatMenuDTOVO
>
menuList
=
userLoginVO
.
getMenuList
();
if
(
CollUtil
.
isEmpty
(
menuList
))
{
return
;
}
String
tenantId
=
userLoginVO
.
getTenantId
();
if
(
StrUtil
.
isBlank
(
tenantId
))
{
return
;
}
PlatOrg
platOrg
=
platOrgService
.
getById
(
userLoginVO
.
getOrgId
());
if
(
platOrg
!=
null
&&
!
"0"
.
equals
(
platOrg
.
getParentId
()))
{
PlatMenuDTOVO
platMenuDTOVO
=
menuList
.
stream
().
filter
(
m
->
"组织管理"
.
equals
(
m
.
getName
())).
findFirst
().
orElse
(
null
);
if
(
platMenuDTOVO
==
null
||
CollUtil
.
isEmpty
(
platMenuDTOVO
.
getChildren
()))
{
return
;
}
platMenuDTOVO
.
getChildren
().
removeIf
(
m
->
"组织管理"
.
equals
(
m
.
getName
()));
}
}
@Override
public
PlatUserLoginVO
getRoleAndMenuList2
()
{
//TODO 用join做
...
...
@@ -1140,10 +1177,12 @@ public class PlatUserServiceImpl extends ServiceImpl<PlatUserMapper, PlatUser>
Map
<
String
,
String
>
roleNameMap
=
roleList
.
stream
().
collect
(
Collectors
.
toMap
(
vo
->
vo
.
getOrgId
()+
vo
.
getName
(),
BaseEntity:
:
getId
,
(
a
,
b
)
->
a
));
LambdaQueryWrapper
<
PlatUser
>
userLambdaQueryWrapper
=
new
LambdaQueryWrapper
<>();
userLambdaQueryWrapper
.
select
(
PlatUser:
:
getMobile
,
PlatUser:
:
getEmail
,
BaseEntity:
:
getId
);
userLambdaQueryWrapper
.
select
(
PlatUser:
:
getMobile
,
PlatUser:
:
getEmail
,
PlatUser:
:
getAccount
,
BaseEntity:
:
getId
);
List
<
PlatUser
>
userList
=
this
.
list
(
userLambdaQueryWrapper
);
Map
<
String
,
String
>
mobileMap
=
userList
.
stream
().
collect
(
Collectors
.
toMap
(
PlatUser:
:
getMobile
,
BaseEntity:
:
getId
,
(
a
,
b
)
->
a
));
Map
<
String
,
String
>
emailMap
=
userList
.
stream
().
filter
(
vo
->
StringUtils
.
isNotBlank
(
vo
.
getEmail
())).
collect
(
Collectors
.
toMap
(
PlatUser:
:
getEmail
,
BaseEntity:
:
getId
,
(
a
,
b
)
->
a
));
Map
<
String
,
String
>
accountMap
=
userList
.
stream
().
collect
(
Collectors
.
toMap
(
PlatUser:
:
getAccount
,
BaseEntity:
:
getId
,
(
a
,
b
)
->
a
));
return
ExcelValidatorUtil
.
validateMain
(
3
,
platUserImportDTOS
,
list
->
{
List
<
ExcelErrorVo
>
errorVoList
=
new
ArrayList
<>();
...
...
@@ -1157,6 +1196,7 @@ public class PlatUserServiceImpl extends ServiceImpl<PlatUserMapper, PlatUser>
PlatOrg
platOrg
=
Optional
.
ofNullable
(
orgNameMap
.
get
(
dto
.
getOrgName
())).
orElse
(
new
PlatOrg
());
ExcelErrorVo
.
notExists
(
platOrg
.
getId
(),
errorVoList
,
start
+
i
,
"*所属组织"
);
ExcelErrorVo
.
notExists
(
roleNameMap
.
get
(
platOrg
.
getId
()+
dto
.
getRoleName
()),
errorVoList
,
start
+
i
,
"*角色"
);
ExcelErrorVo
.
exists
(
accountMap
,
dto
.
getMobile
(),
errorVoList
,
start
+
i
,
"账户*"
);
ExcelErrorVo
.
exists
(
mobileMap
,
dto
.
getMobile
(),
errorVoList
,
start
+
i
,
"手机号*"
);
ExcelErrorVo
.
exists
(
emailMap
,
dto
.
getEmail
(),
errorVoList
,
start
+
i
,
"邮箱"
);
}
...
...
server-service/src/main/java/com/makeit/service/platform/device/PlatDeviceLogService.java
0 → 100644
View file @
14cea1ba
package
com
.
makeit
.
service
.
platform
.
device
;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
com.makeit.common.page.PageReqDTO
;
import
com.makeit.common.page.PageVO
;
import
com.makeit.entity.platform.device.PlatDeviceLog
;
/**
* <p>
* 设备日志 服务类
* </p>
*
* @author eugene young
* @since 2023-12-01
*/
public
interface
PlatDeviceLogService
extends
IService
<
PlatDeviceLog
>
{
PageVO
<
PlatDeviceLog
>
pageList
(
PageReqDTO
<
PlatDeviceLog
>
pageReqDTO
);
}
server-service/src/main/java/com/makeit/service/platform/device/PlatDeviceService.java
View file @
14cea1ba
...
...
@@ -18,6 +18,7 @@ import com.makeit.vo.platform.device.PlatDeviceListVO;
import
com.makeit.vo.platform.device.PlatDeviceViewVO
;
import
org.springframework.web.multipart.MultipartFile
;
import
java.io.IOException
;
import
java.util.List
;
/**
...
...
@@ -90,5 +91,5 @@ public interface PlatDeviceService extends IService<PlatDevice> {
PlatAlarmCallDeviceVO
callingDevice
(
PlatCallingDeviceDTO
dto
);
void
devicePushLog
(
MultipartFile
multipartFile
)
;
void
devicePushLog
(
MultipartFile
multipartFile
,
String
deviceId
)
throws
IOException
;
}
server-service/src/main/java/com/makeit/service/platform/device/impl/PlatDeviceLogServiceImpl.java
0 → 100644
View file @
14cea1ba
package
com
.
makeit
.
service
.
platform
.
device
.
impl
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.makeit.common.page.PageReqDTO
;
import
com.makeit.common.page.PageVO
;
import
com.makeit.dto.platform.device.PlatDeviceQueryDTO
;
import
com.makeit.entity.platform.alarm.PlatAlarmRecord
;
import
com.makeit.entity.platform.device.PlatDevice
;
import
com.makeit.entity.platform.device.PlatDeviceLog
;
import
com.makeit.mapper.platform.device.PlatDeviceLogMapper
;
import
com.makeit.service.platform.device.PlatDeviceLogService
;
import
com.makeit.utils.data.convert.PageUtil
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
/**
* <p>
* 设备日志 服务实现类
* </p>
*
* @author eugene young
* @since 2023-12-01
*/
@Service
public
class
PlatDeviceLogServiceImpl
extends
ServiceImpl
<
PlatDeviceLogMapper
,
PlatDeviceLog
>
implements
PlatDeviceLogService
{
@Autowired
private
PlatDeviceLogMapper
platDeviceLogMapper
;
@Override
public
PageVO
<
PlatDeviceLog
>
pageList
(
PageReqDTO
<
PlatDeviceLog
>
pageReqDTO
)
{
PlatDeviceLog
dto
=
pageReqDTO
.
getData
();
Page
<
PlatDeviceLog
>
p
=
PageUtil
.
toMpPage
(
pageReqDTO
);
LambdaQueryWrapper
<
PlatDeviceLog
>
lambdaQueryWrapper
=
new
QueryWrapper
<
PlatDeviceLog
>().
lambda
()
.
eq
(
StringUtils
.
isNotEmpty
(
dto
.
getDeviceId
()),
PlatDeviceLog:
:
getDeviceId
,
dto
.
getDeviceId
())
.
eq
(
StringUtils
.
isNotEmpty
(
dto
.
getProductName
()),
PlatDeviceLog:
:
getProductName
,
dto
.
getProductName
())
.
eq
(
StringUtils
.
isNotEmpty
(
dto
.
getTenantId
()),
PlatDeviceLog:
:
getTenantId
,
dto
.
getTenantId
())
.
ge
(
dto
.
getStartTime
()
!=
null
,
PlatDeviceLog:
:
getCreateDate
,
dto
.
getStartTime
())
.
ge
(
dto
.
getEndTime
()
!=
null
,
PlatDeviceLog:
:
getCreateDate
,
dto
.
getEndTime
());
Page
<
PlatDeviceLog
>
deviceLogPage
=
platDeviceLogMapper
.
selectPage
(
p
,
lambdaQueryWrapper
);
return
PageUtil
.
toPageVO
(
deviceLogPage
.
getRecords
(),
deviceLogPage
);
}
}
server-service/src/main/java/com/makeit/service/platform/device/impl/PlatDeviceServiceImpl.java
View file @
14cea1ba
package
com
.
makeit
.
service
.
platform
.
device
.
impl
;
import
cn.hutool.core.bean.BeanUtil
;
import
cn.hutool.core.date.DatePattern
;
import
cn.hutool.core.date.DateUtil
;
import
cn.hutool.crypto.SecureUtil
;
import
com.alibaba.fastjson.JSON
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
...
...
@@ -23,6 +27,7 @@ import com.makeit.dto.saas.device.PlatDeviceEditSaasDTO;
import
com.makeit.dto.wechat.device.*
;
import
com.makeit.entity.platform.auth.PlatOrg
;
import
com.makeit.entity.platform.device.PlatDevice
;
import
com.makeit.entity.platform.device.PlatDeviceLog
;
import
com.makeit.entity.platform.device.PlatDeviceOther
;
import
com.makeit.entity.platform.elder.PlatElder
;
import
com.makeit.entity.platform.space.PlatRegionSetting
;
...
...
@@ -44,8 +49,9 @@ import com.makeit.module.iot.vo.DeviceProperties;
import
com.makeit.module.iot.vo.DeviceState
;
import
com.makeit.module.system.service.SysDictionaryCategoryService
;
import
com.makeit.module.system.vo.DictionaryVo
;
import
com.makeit.oss.AliyunOSSRepository
;
import
com.makeit.service.platform.auth.PlatOrgService
;
import
com.makeit.service.platform.
auth.PlatRole
Service
;
import
com.makeit.service.platform.
device.PlatDeviceLog
Service
;
import
com.makeit.service.platform.device.PlatDeviceOtherService
;
import
com.makeit.service.platform.device.PlatDeviceService
;
import
com.makeit.service.platform.elder.PlatElderService
;
...
...
@@ -60,17 +66,14 @@ import com.makeit.shengwang.agora.service.ShengwangService;
import
com.makeit.shengwang.agora.vo.PlatAlarmCallDeviceVO
;
import
com.makeit.utils.DeviceCacheUtil
;
import
com.makeit.utils.data.convert.BeanDtoVoUtils
;
import
com.makeit.utils.data.convert.JsonUtil
;
import
com.makeit.utils.data.convert.PageUtil
;
import
com.makeit.utils.data.convert.StreamUtil
;
import
com.makeit.utils.old.StringUtils
;
import
com.makeit.utils.request.RequestUtil
;
import
com.makeit.utils.sql.join.JoinUtil
;
import
com.makeit.vo.platform.device.PlatChildDeviceListVO
;
import
com.makeit.vo.platform.device.PlatDeviceActiveVO
;
import
com.makeit.vo.platform.device.PlatDeviceListVO
;
import
com.makeit.vo.platform.device.PlatDeviceViewVO
;
import
lombok.Data
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.springframework.beans.BeanUtils
;
...
...
@@ -79,6 +82,7 @@ import org.springframework.stereotype.Service;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.web.multipart.MultipartFile
;
import
java.io.IOException
;
import
java.time.LocalDateTime
;
import
java.time.ZoneOffset
;
import
java.time.format.DateTimeFormatter
;
...
...
@@ -130,7 +134,16 @@ public class PlatDeviceServiceImpl extends ServiceImpl<PlatDeviceMapper, PlatDev
private
ShengwangService
shengwangService
;
@Autowired
private
ShengwangProperties
shengwangProperties
;
@Autowired
private
AliyunOSSRepository
aliyunOSSRepository
;
@Autowired
private
PlatDeviceLogService
platDeviceLogService
;
/**
* 平台设备列表
* @param pageReqDTO
* @return
*/
@Override
public
PageVO
<
PlatDeviceListVO
>
page
(
PageReqDTO
<
PlatDeviceQueryDTO
>
pageReqDTO
)
{
PlatDeviceQueryDTO
dto
=
pageReqDTO
.
getData
();
...
...
@@ -214,7 +227,15 @@ public class PlatDeviceServiceImpl extends ServiceImpl<PlatDeviceMapper, PlatDev
return
PageVO
.
emptyPage
();
}
List
<
PlatRoomBedDevice
>
platRoomBedDevices
=
platRoomBedDeviceService
.
list
(
new
QueryWrapper
<
PlatRoomBedDevice
>().
lambda
()
.
eq
(
PlatRoomBedDevice:
:
getRoomId
,
platElder
.
getRoomId
()));
.
eq
(
PlatRoomBedDevice:
:
getRoomId
,
platElder
.
getRoomId
())
.
isNull
(
PlatRoomBedDevice:
:
getBedId
));
if
(
StringUtils
.
isNotEmpty
(
platElder
.
getBedId
()))
{
PlatRoomBedDevice
bedDeviceServiceOne
=
platRoomBedDeviceService
.
getOne
(
new
QueryWrapper
<
PlatRoomBedDevice
>().
lambda
()
.
eq
(
PlatRoomBedDevice:
:
getBedId
,
platElder
.
getBedId
()));
if
(
bedDeviceServiceOne
!=
null
)
{
platRoomBedDevices
.
add
(
bedDeviceServiceOne
);
}
}
if
(
CollectionUtils
.
isEmpty
(
platRoomBedDevices
))
{
return
PageVO
.
emptyPage
();
}
...
...
@@ -368,18 +389,32 @@ public class PlatDeviceServiceImpl extends ServiceImpl<PlatDeviceMapper, PlatDev
}
/**
* saas设备列表
* @param pageReqDTO
* @return
*/
@Override
public
PageVO
<
PlatDeviceListVO
>
pageSaas
(
PageReqDTO
<
PlatDevice
>
pageReqDTO
)
{
PlatDevice
param
=
pageReqDTO
.
getData
();
Page
<
PlatDevice
>
page
=
PageUtil
.
toMpPage
(
pageReqDTO
);
LambdaQueryWrapper
<
PlatDevice
>
lambdaQueryWrapper
=
getLambdaQueryWrapper
(
param
);
Page
<
PlatDevice
>
devicePage
=
page
(
page
,
lambdaQueryWrapper
);
List
<
PlatDevice
>
records
=
devicePage
.
getRecords
();
List
<
PlatDeviceListVO
>
platDeviceListVOS
=
BeanDtoVoUtils
.
listVo
(
records
,
PlatDeviceListVO
.
class
);
JoinUtil
.
join
(
platDeviceListVOS
,
platTenantService
,
BaseTenantDTO:
:
getTenantId
,
BaseEntity:
:
getId
,
(
d
,
o
)
->
{
//PlatDevice param = pageReqDTO.getData();
//Page<PlatDevice> page = PageUtil.toMpPage(pageReqDTO);
//LambdaQueryWrapper<PlatDevice> lambdaQueryWrapper = getLambdaQueryWrapper(param);
//Page<PlatDevice> devicePage = page(page, lambdaQueryWrapper);
//List<PlatDevice> records = devicePage.getRecords();
PlatDeviceQueryDTO
platDeviceQueryDTO
=
BeanUtil
.
copyProperties
(
pageReqDTO
.
getData
(),
PlatDeviceQueryDTO
.
class
);
PageReqDTO
<
PlatDeviceQueryDTO
>
request
=
new
PageReqDTO
<>();
request
.
setData
(
platDeviceQueryDTO
);
request
.
setPage
(
pageReqDTO
.
getPage
());
request
.
setLimit
(
pageReqDTO
.
getLimit
());
PageVO
<
PlatDeviceListVO
>
pageVO
=
page
(
request
);
//List<PlatDeviceListVO> platDeviceListVOS = BeanDtoVoUtils.listVo(pageVO.getList(), PlatDeviceListVO.class);
JoinUtil
.
join
(
pageVO
.
getList
(),
platTenantService
,
BaseTenantDTO:
:
getTenantId
,
BaseEntity:
:
getId
,
(
d
,
o
)
->
{
d
.
setTenantName
(
o
.
getName
());
});
return
PageUtil
.
toPageVO
(
platDeviceListVOS
,
devicePage
);
return
pageVO
;
}
@Override
...
...
@@ -461,7 +496,7 @@ public class PlatDeviceServiceImpl extends ServiceImpl<PlatDeviceMapper, PlatDev
.
eq
(
StringUtils
.
isNotBlank
(
param
.
getStatus
()),
PlatDevice:
:
getStatus
,
param
.
getStatus
())
.
like
(
StringUtils
.
isNotBlank
(
param
.
getProductName
()),
PlatDevice:
:
getProductName
,
param
.
getProductName
())
.
eq
(
StringUtils
.
isNotBlank
(
param
.
getTenantId
()),
BaseBusEntity:
:
getTenantId
,
param
.
getTenantId
())
.
orderByDesc
(
BaseEntity:
:
getUpdateDate
);
.
orderByDesc
(
BaseEntity:
:
getUpdateDate
)
.
orderByDesc
(
BaseEntity:
:
getId
)
;
}
@Override
...
...
@@ -496,7 +531,7 @@ public class PlatDeviceServiceImpl extends ServiceImpl<PlatDeviceMapper, PlatDev
.
eq
(
PlatDeviceOther:
:
getOriDeviceId
,
deviceId
)
.
last
(
"limit 1"
));
PlatDeviceBaseAttrDTO
platDeviceBaseAttrDTO
=
JSON
.
parseObject
(
deviceOther
.
getAttribute
(),
PlatDeviceBaseAttrDTO
.
class
);
return
platDeviceBaseAttrDTO
;
return
platDeviceBaseAttrDTO
==
null
?
new
PlatDeviceBaseAttrDTO
()
:
platDeviceBaseAttrDTO
;
}
private
static
Map
<
String
,
Object
>
getReqMap
(
PlatDeviceBaseAttrDTO
dto
,
PlatDeviceBaseAttrDTO
platDeviceBaseAttrDTO
)
{
...
...
@@ -507,14 +542,23 @@ public class PlatDeviceServiceImpl extends ServiceImpl<PlatDeviceMapper, PlatDev
if
(!
Objects
.
equals
(
platDeviceBaseAttrDTO
.
getRadarMount
(),
dto
.
getRadarMount
()))
{
map
.
put
(
"radarMount"
,
dto
.
getRadarMount
());
}
if
(!
Objects
.
equals
(
platDeviceBaseAttrDTO
.
getRadarHight
(),
dto
.
getRadarHight
()))
{
map
.
put
(
"radarHight"
,
dto
.
getRadarHight
());
}
if
(!
Objects
.
equals
(
platDeviceBaseAttrDTO
.
getRadarDelay
(),
dto
.
getRadarDelay
()))
{
map
.
put
(
"radarDelay"
,
dto
.
getRadarDelay
()
);
}
if
(!
Objects
.
equals
(
platDeviceBaseAttrDTO
.
getRadarDistance
(),
dto
.
getRadarDistance
()))
{
map
.
put
(
"radarDistance"
,
JSON
.
toJSONString
(
dto
.
getRadarDistance
()));
PlatDeviceBaseAttrDTO
.
DeviceAttrRange
radarDistance
=
platDeviceBaseAttrDTO
.
getRadarDistance
();
if
(!
Objects
.
equals
(
radarDistance
,
dto
.
getRadarDistance
()))
{
if
(
radarDistance
!=
null
&&
radarDistance
.
getMax
()
!=
null
&&
radarDistance
.
getMin
()
!=
null
)
{
map
.
put
(
"radarDistance"
,
JSON
.
toJSONString
(
dto
.
getRadarDistance
()));
}
}
if
(!
Objects
.
equals
(
platDeviceBaseAttrDTO
.
getRadarAngle
(),
dto
.
getRadarAngle
()))
{
map
.
put
(
"radarAngle"
,
JSON
.
toJSONString
(
dto
.
getRadarAngle
()));
PlatDeviceBaseAttrDTO
.
DeviceAttrRange
radarAngle
=
platDeviceBaseAttrDTO
.
getRadarAngle
();
if
(!
Objects
.
equals
(
radarAngle
,
dto
.
getRadarAngle
()))
{
if
(
radarAngle
!=
null
&&
radarAngle
.
getMax
()
!=
null
&&
radarAngle
.
getMin
()
!=
null
)
{
map
.
put
(
"radarAngle"
,
JSON
.
toJSONString
(
dto
.
getRadarAngle
()));
}
}
return
map
;
}
...
...
@@ -526,10 +570,10 @@ public class PlatDeviceServiceImpl extends ServiceImpl<PlatDeviceMapper, PlatDev
log
.
info
(
"写入设备属性请求参数:{}"
,
JSON
.
toJSONString
(
dto
));
Map
<
String
,
Object
>
map
=
Maps
.
newHashMap
();
map
.
put
(
"usrServerInfo"
,
JSON
.
toJSONString
(
usrServerInfo
));
String
result
=
devicePropertiesOperateService
.
deviceWriteAttr
(
deviceId
,
map
);
/*
String result = devicePropertiesOperateService.deviceWriteAttr(deviceId, map);
if (StringUtils.isNotEmpty(result)) {
throw new RuntimeException("设备写入失败:" + result);
}
}
*/
List
<
PlatDeviceOther
>
platDeviceOtherList
=
platDeviceOtherService
.
list
(
new
QueryWrapper
<
PlatDeviceOther
>().
lambda
()
.
eq
(
PlatDeviceOther:
:
getOriDeviceId
,
deviceId
));
for
(
PlatDeviceOther
platDeviceOther
:
platDeviceOtherList
)
{
...
...
@@ -837,7 +881,28 @@ public class PlatDeviceServiceImpl extends ServiceImpl<PlatDeviceMapper, PlatDev
}
@Override
public
void
devicePushLog
(
MultipartFile
multipartFile
)
{
public
void
devicePushLog
(
MultipartFile
file
,
String
deviceId
)
throws
IOException
{
log
.
info
(
"接受到设备上传的文件,设备id:{}"
,
deviceId
);
String
uploadPath
=
DateUtil
.
format
(
new
Date
(),
DatePattern
.
PURE_DATE_FORMAT
);
String
name
=
file
.
getOriginalFilename
();
String
md5
=
SecureUtil
.
md5
(
file
.
getInputStream
()).
substring
(
8
,
24
);
String
type
=
name
.
substring
(
name
.
lastIndexOf
(
"."
));
String
fileName
=
md5
+
type
;
String
url
=
aliyunOSSRepository
.
save
(
file
,
uploadPath
,
fileName
);
PlatDevice
platDevice
=
getOne
(
new
QueryWrapper
<
PlatDevice
>().
lambda
().
eq
(
PlatDevice:
:
getOriDeviceId
,
deviceId
)
.
orderByDesc
(
BaseEntity:
:
getCreateDate
)
.
last
(
"limit 1"
));
if
(
platDevice
==
null
)
{
throw
new
RuntimeException
(
"找不到设备id:"
+
deviceId
);
}
PlatDeviceLog
platDeviceLog
=
new
PlatDeviceLog
();
platDeviceLog
.
setDeviceId
(
deviceId
);
platDeviceLog
.
setProductName
(
platDevice
.
getProductName
());
platDeviceLog
.
setType
(
"1"
);
platDeviceLog
.
setTenantId
(
platDevice
.
getTenantId
());
platDeviceLog
.
setUrl
(
url
);
platDeviceLog
.
setFileName
(
name
);
platDeviceLogService
.
save
(
platDeviceLog
);
}
}
server-service/src/main/java/com/makeit/service/platform/elder/impl/PlatElderRealTimeServiceImpl.java
View file @
14cea1ba
...
...
@@ -375,7 +375,7 @@ public class PlatElderRealTimeServiceImpl implements PlatElderRealTimeService {
if
(
platDevice
==
null
)
{
return
vo
;
}
vo
.
setDeviceId
(
platDevice
.
getOriDeviceId
());
String
result
=
redisTemplate
.
opsForValue
().
get
(
DEVICE_BR_DATA
+
platDevice
.
getOriDeviceId
());
log
.
info
(
"实时获取设备呼吸数据:{}"
,
result
);
if
(
result
!=
null
)
{
...
...
@@ -499,7 +499,7 @@ public class PlatElderRealTimeServiceImpl implements PlatElderRealTimeService {
List
<
PlatDevice
>
fallDeviceList
=
Lists
.
newArrayList
();
if
(
StringUtils
.
isNotBlank
(
platElderIdDTO
.
getDeviceId
()))
{
PlatDevice
device
=
platDeviceService
.
getOne
(
new
QueryWrapper
<
PlatDevice
>().
lambda
()
.
eq
(
PlatDevice:
:
get
OriDevice
Id
,
platElderIdDTO
.
getDeviceId
()).
last
(
"limit 1"
));
.
eq
(
PlatDevice:
:
getId
,
platElderIdDTO
.
getDeviceId
()).
last
(
"limit 1"
));
if
(
device
!=
null
)
{
deviceListSpace
.
add
(
device
);
}
...
...
server-service/src/main/java/com/makeit/service/platform/elder/impl/PlatElderServiceImpl.java
View file @
14cea1ba
...
...
@@ -37,6 +37,7 @@ import com.makeit.mapper.platform.elder.PlatElderMapper;
import
com.makeit.module.system.service.SysConfigService
;
import
com.makeit.module.system.vo.SysConfigVO
;
import
com.makeit.service.platform.auth.PlatOrgService
;
import
com.makeit.service.platform.device.PlatDeviceService
;
import
com.makeit.service.platform.elder.*
;
import
com.makeit.service.platform.space.PlatBedService
;
import
com.makeit.service.platform.space.PlatRoomBedDeviceService
;
...
...
@@ -53,7 +54,6 @@ import com.makeit.utils.sql.join.JoinUtil;
import
com.makeit.utils.sys.FileUtil
;
import
com.makeit.utils.user.plat.PlatUserUtil
;
import
com.makeit.utils.user.plat.PlatUserVO
;
import
com.makeit.utils.user.wechat.WechatUserUtil
;
import
com.makeit.vo.platform.elder.PlatElderExportVO
;
import
com.makeit.vo.platform.elder.PlatElderListVO
;
import
com.makeit.vo.wechat.elder.PlatElderChildrenInfoWechatVO
;
...
...
@@ -115,6 +115,8 @@ public class PlatElderServiceImpl extends ServiceImpl<PlatElderMapper, PlatElder
private
PersonalConfigCacheUtil
personalConfigCacheUtil
;
@Autowired
private
SysConfigService
sysConfigService
;
@Autowired
private
PlatDeviceService
platDeviceService
;
private
LambdaQueryWrapper
<
PlatElder
>
lambdaQueryWrapper
(
PlatElderQueryDTO
dto
)
{
List
<
String
>
typeOrgIdList
=
Lists
.
newArrayList
();
...
...
@@ -127,19 +129,27 @@ public class PlatElderServiceImpl extends ServiceImpl<PlatElderMapper, PlatElder
choiceOrgIdList
.
addAll
(
Lists
.
newArrayList
(
dto
.
getOrgId
().
split
(
","
)));
}
List
<
String
>
orgIdList
=
Lists
.
newArrayList
();
if
(
CollectionUtils
.
isNotEmpty
(
choiceOrgIdList
))
{
orgIdList
=
choiceOrgIdList
;
}
if
(
CollectionUtils
.
isNotEmpty
(
typeOrgIdList
))
{
if
(
StringUtils
.
isNotEmpty
(
dto
.
getType
())
&&
StringUtils
.
isEmpty
(
dto
.
getOrgId
()))
{
orgIdList
=
typeOrgIdList
;
}
if
(
CollectionUtils
.
isNotEmpty
(
choiceOrgIdList
)
&&
CollectionUtils
.
isNotEmpty
(
typeOrgIdList
))
{
orgIdList
=
new
ArrayList
<>(
CollectionUtils
.
intersection
(
typeOrgIdList
,
choiceOrgIdList
));
if
(
CollectionUtils
.
isEmpty
(
orgIdList
))
{
orgIdList
.
add
(
"-1"
);
}
}
if
(
StringUtils
.
isNotEmpty
(
dto
.
getOrgId
())
&&
StringUtils
.
isEmpty
(
dto
.
getType
()))
{
orgIdList
=
choiceOrgIdList
;
if
(
CollectionUtils
.
isEmpty
(
orgIdList
))
{
orgIdList
.
add
(
"-1"
);
}
}
if
(
StringUtils
.
isNotEmpty
(
dto
.
getOrgId
())
&&
StringUtils
.
isNotEmpty
(
dto
.
getType
()))
{
if
(
CollectionUtils
.
isNotEmpty
(
choiceOrgIdList
)
&&
CollectionUtils
.
isNotEmpty
(
typeOrgIdList
))
{
orgIdList
=
new
ArrayList
<>(
CollectionUtils
.
intersection
(
typeOrgIdList
,
choiceOrgIdList
));
if
(
CollectionUtils
.
isEmpty
(
orgIdList
))
{
orgIdList
.
add
(
"-1"
);
}
}
}
return
new
QueryWrapper
<
PlatElder
>().
lambda
()
.
like
(
StringUtils
.
isNotBlank
(
dto
.
getName
()),
PlatElder:
:
getName
,
dto
.
getName
())
.
like
(
StringUtils
.
isNotBlank
(
dto
.
getPhone
()),
PlatElder:
:
getPhone
,
dto
.
getPhone
())
...
...
@@ -216,6 +226,46 @@ public class PlatElderServiceImpl extends ServiceImpl<PlatElderMapper, PlatElder
fill
(
list
);
List
<
String
>
roomIds
=
list
.
stream
().
filter
(
platElderListVO
->
StringUtils
.
isNotEmpty
(
platElderListVO
.
getRoomId
()))
.
map
(
PlatElderListVO:
:
getRoomId
).
collect
(
Collectors
.
toList
());
List
<
PlatRoomBedDevice
>
platRoomDevices
=
platRoomBedDeviceService
.
list
(
new
QueryWrapper
<
PlatRoomBedDevice
>().
lambda
()
.
in
(
PlatRoomBedDevice:
:
getRoomId
,
roomIds
)
.
isNull
(
PlatRoomBedDevice:
:
getBedId
));
List
<
PlatRoomBedDevice
>
platBedDevices
=
platRoomBedDeviceService
.
list
(
new
QueryWrapper
<
PlatRoomBedDevice
>().
lambda
()
.
in
(
PlatRoomBedDevice:
:
getRoomId
,
roomIds
)
.
isNotNull
(
PlatRoomBedDevice:
:
getBedId
));
Map
<
String
,
List
<
PlatRoomBedDevice
>>
roomDeviceMap
=
StreamUtil
.
groupBy
(
platRoomDevices
,
PlatRoomBedDevice:
:
getRoomId
);
Map
<
String
,
PlatRoomBedDevice
>
bedDeviceMap
=
StreamUtil
.
toMap
(
platBedDevices
,
PlatRoomBedDevice:
:
getBedId
);
List
<
PlatDevice
>
platDeviceList
=
platDeviceService
.
list
();
Map
<
String
,
PlatDevice
>
deviceMap
=
StreamUtil
.
toMap
(
platDeviceList
,
BaseEntity:
:
getId
);
for
(
PlatElderListVO
vo
:
list
)
{
List
<
PlatDevice
>
deviceList
=
Lists
.
newArrayList
();
if
(
StringUtils
.
isNotEmpty
(
vo
.
getRoomId
()))
{
List
<
PlatRoomBedDevice
>
platRoomBedDevices
=
roomDeviceMap
.
get
(
vo
.
getRoomId
());
if
(
CollectionUtils
.
isNotEmpty
(
platRoomBedDevices
))
{
List
<
String
>
tempDeviceIdList
=
StreamUtil
.
map
(
platRoomBedDevices
,
PlatRoomBedDevice:
:
getDeviceId
);
for
(
String
s
:
tempDeviceIdList
)
{
PlatDevice
platDevice
=
deviceMap
.
get
(
s
);
if
(
platDevice
!=
null
)
{
deviceList
.
add
(
platDevice
);
}
}
}
}
if
(
StringUtils
.
isNotEmpty
(
vo
.
getBedId
()))
{
PlatRoomBedDevice
platRoomBedDevice
=
bedDeviceMap
.
get
(
vo
.
getBedId
());
if
(
platRoomBedDevice
!=
null
)
{
PlatDevice
platDevice
=
deviceMap
.
get
(
platRoomBedDevice
.
getDeviceId
());
if
(
platDevice
!=
null
)
{
deviceList
.
add
(
platDevice
);
}
}
}
vo
.
setDeviceList
(
deviceList
);
}
return
PageUtil
.
toPageVO
(
list
,
voPage
);
}
...
...
@@ -441,6 +491,9 @@ public class PlatElderServiceImpl extends ServiceImpl<PlatElderMapper, PlatElder
//List<SysConfigVO> sysConfigVOS1 = sysConfigService.viewListByCategoryCode(SysConfigCategoryConst.ELDER_CERTIFICATE_TYPE);
ExcelImportVo
result
=
new
ExcelImportVo
();
return
ExcelValidatorUtil
.
validateMain
(
3
,
list
,
l
->
{
int
start
=
3
;
...
...
@@ -468,10 +521,10 @@ public class PlatElderServiceImpl extends ServiceImpl<PlatElderMapper, PlatElder
List
<
String
>
excelField
=
Arrays
.
asList
(
"
小区
"
,
"
楼栋
"
,
"
单元
"
,
"
楼层
"
"
一级空间
"
,
"
二级空间
"
,
"
三级空间
"
,
"
四级空间
"
);
List
<
String
>
spaceName
=
Arrays
.
asList
(
...
...
@@ -556,7 +609,7 @@ public class PlatElderServiceImpl extends ServiceImpl<PlatElderMapper, PlatElder
);
if
(
c
==
0
&&
StreamUtil
.
anyMatch
(
roomAndBed
,
StringUtils:
:
isNotBlank
))
{
errorVoList
.
add
(
new
ExcelErrorVo
(
i
+
start
,
"
小区、楼栋、单元、楼层
"
,
"不能为空"
));
errorVoList
.
add
(
new
ExcelErrorVo
(
i
+
start
,
"
一级空间,二级空间,三级空间,四级空间
"
,
"不能为空"
));
for
(
int
j
=
0
;
j
<
2
;
j
++)
{
if
(
StringUtils
.
isBlank
(
roomAndBed
.
get
(
j
)))
{
...
...
server-service/src/main/java/com/makeit/service/platform/space/impl/PlatBedServiceImpl.java
View file @
14cea1ba
package
com
.
makeit
.
service
.
platform
.
space
.
impl
;
import
cn.hutool.core.util.StrUtil
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
...
...
@@ -171,18 +172,35 @@ public class PlatBedServiceImpl extends ServiceImpl<PlatBedMapper, PlatBed> impl
choiceOrgIdList
.
addAll
(
Lists
.
newArrayList
(
dto
.
getOrgId
().
split
(
","
)));
}
List
<
String
>
orgIdList
=
Lists
.
newArrayList
();
if
(
CollectionUtils
.
isNotEmpty
(
choiceOrgIdList
))
{
orgIdList
=
choiceOrgIdList
;
}
if
(
CollectionUtils
.
isNotEmpty
(
typeOrgIdList
))
{
if
(
com
.
makeit
.
utils
.
old
.
StringUtils
.
isNotEmpty
(
dto
.
getOrgType
())
&&
com
.
makeit
.
utils
.
old
.
StringUtils
.
isEmpty
(
dto
.
getOrgId
()))
{
orgIdList
=
typeOrgIdList
;
if
(
CollectionUtils
.
isEmpty
(
orgIdList
))
{
orgIdList
.
add
(
"-1"
);
}
}
if
(
CollectionUtils
.
isNotEmpty
(
choiceOrgIdList
)
&&
CollectionUtils
.
isNotEmpty
(
typeOrgIdList
))
{
orgIdList
=
new
ArrayList
<>(
CollectionUtils
.
intersection
(
typeOrgIdList
,
choiceOrgIdList
));
if
(
com
.
makeit
.
utils
.
old
.
StringUtils
.
isNotEmpty
(
dto
.
getOrgId
())
&&
com
.
makeit
.
utils
.
old
.
StringUtils
.
isEmpty
(
dto
.
getOrgType
()))
{
orgIdList
=
choiceOrgIdList
;
if
(
CollectionUtils
.
isEmpty
(
orgIdList
))
{
orgIdList
.
add
(
"-1"
);
}
}
if
(
com
.
makeit
.
utils
.
old
.
StringUtils
.
isNotEmpty
(
dto
.
getOrgId
())
&&
com
.
makeit
.
utils
.
old
.
StringUtils
.
isNotEmpty
(
dto
.
getOrgType
()))
{
if
(
CollectionUtils
.
isNotEmpty
(
choiceOrgIdList
)
&&
CollectionUtils
.
isNotEmpty
(
typeOrgIdList
))
{
orgIdList
=
new
ArrayList
<>(
CollectionUtils
.
intersection
(
typeOrgIdList
,
choiceOrgIdList
));
if
(
CollectionUtils
.
isEmpty
(
orgIdList
))
{
orgIdList
.
add
(
"-1"
);
}
}
}
// 数据权限
if
(
StrUtil
.
isBlank
(
dto
.
getOrgId
())
&&
StrUtil
.
isBlank
(
dto
.
getType
()))
{
//查询用户权限组织id
List
<
PlatOrg
>
orgs
=
platOrgService
.
belongToScopeList
(
new
PlatOrg
());
orgIdList
=
orgs
.
stream
().
map
(
PlatOrg:
:
getId
).
collect
(
Collectors
.
toList
());
}
return
baseMapper
.
selectBySpaceIdAndStatus
(
new
Page
<>(
pageReqDTO
.
getPage
(),
pageReqDTO
.
getLimit
()),
dto
,
orgIdList
);
}
...
...
server-service/src/main/java/com/makeit/service/platform/space/impl/PlatSpaceServiceImpl.java
View file @
14cea1ba
package
com
.
makeit
.
service
.
platform
.
space
.
impl
;
import
cn.hutool.core.collection.CollUtil
;
import
cn.hutool.core.util.StrUtil
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.baomidou.mybatisplus.core.toolkit.Wrappers
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.github.xiaoymin.knife4j.core.util.CollectionUtils
;
import
com.google.common.collect.Lists
;
...
...
@@ -16,7 +19,6 @@ import com.makeit.entity.platform.space.PlatRoom;
import
com.makeit.entity.platform.space.PlatSpace
;
import
com.makeit.enums.CodeMessageEnum
;
import
com.makeit.enums.CommonEnum
;
import
com.makeit.enums.platform.space.PlatSpaceEnum
;
import
com.makeit.exception.BusinessException
;
import
com.makeit.mapper.platform.space.PlatSpaceMapper
;
import
com.makeit.service.platform.auth.PlatOrgService
;
...
...
@@ -40,6 +42,7 @@ import org.springframework.web.multipart.MultipartFile;
import
java.util.*
;
import
java.util.function.BiConsumer
;
import
java.util.function.Function
;
import
java.util.regex.Matcher
;
import
java.util.regex.Pattern
;
import
java.util.stream.Collectors
;
...
...
@@ -150,6 +153,25 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace
platRoom
.
setSpacePath
(
dto
.
getParentPath
()
+
","
+
space
.
getId
());
platRoomService
.
updateById
(
platRoom
);
}
List
<
String
>
roomIds
=
platRoomList
.
stream
().
map
(
PlatRoom:
:
getId
).
collect
(
Collectors
.
toList
());
Map
<
String
,
PlatRoom
>
roomMap
=
platRoomList
.
stream
().
collect
(
Collectors
.
toMap
(
PlatRoom:
:
getId
,
Function
.
identity
()));
if
(
CollUtil
.
isEmpty
(
roomIds
))
{
return
;
}
List
<
PlatElder
>
elderList
=
platElderService
.
list
(
Wrappers
.<
PlatElder
>
lambdaQuery
().
in
(
PlatElder:
:
getRoomId
,
roomIds
));
if
(
CollUtil
.
isNotEmpty
(
elderList
))
{
elderList
.
forEach
(
e
->
{
String
roomId
=
e
.
getRoomId
();
if
(
StrUtil
.
isBlank
(
roomId
)
||
!
roomMap
.
containsKey
(
roomId
))
{
return
;
}
PlatRoom
platRoom
=
roomMap
.
get
(
roomId
);
e
.
setSpacePath
(
platRoom
.
getSpacePath
()
+
","
+
e
.
getBedId
());
platElderService
.
updateById
(
e
);
});
}
}
@Override
...
...
@@ -488,6 +510,7 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace
// 进行匹配
if
(!
matcher
.
find
()){
errorVoList
.
add
(
new
ExcelErrorVo
(
i
+
3
,
excelField
.
get
(
4
),
"床位数量格式错误"
));
errorFlag
=
true
;
}
}
...
...
@@ -513,7 +536,8 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace
if
(!
firstSpaceNameMap
.
containsKey
(
item
.
getCommunity
()))
{
PlatSpace
platSpace
=
new
PlatSpace
();
platSpace
.
setName
(
item
.
getCommunity
());
platSpace
.
setType
(
PlatSpaceEnum
.
TypeEnum
.
COMMUNITY
.
getValue
());
// bug 29480 空间类型默认为空
// platSpace.setType(PlatSpaceEnum.TypeEnum.COMMUNITY.getValue());
platSpace
.
setOrgId
(
orgId
);
if
(
org
!=
null
)
{
platSpace
.
setAttribute
(
org
.
getType
());
...
...
@@ -544,7 +568,7 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace
if
(!
childrenIdMap
.
containsKey
(
secondKey
))
{
PlatSpace
platSpace
=
new
PlatSpace
();
platSpace
.
setName
(
item
.
getBuilding
());
platSpace
.
setType
(
PlatSpaceEnum
.
TypeEnum
.
BUILDING
.
getValue
());
//
platSpace.setType(PlatSpaceEnum.TypeEnum.BUILDING.getValue());
platSpace
.
setOrgId
(
orgId
);
platSpace
.
setParentId
(
firstId
);
platSpace
.
setParentPath
(
firstId
);
...
...
@@ -581,7 +605,7 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace
if
(!
childrenIdMap
.
containsKey
(
threeKey
))
{
PlatSpace
platSpace
=
new
PlatSpace
();
platSpace
.
setName
(
item
.
getUnit
());
platSpace
.
setType
(
PlatSpaceEnum
.
TypeEnum
.
UNIT
.
getValue
());
//
platSpace.setType(PlatSpaceEnum.TypeEnum.UNIT.getValue());
platSpace
.
setOrgId
(
orgId
);
platSpace
.
setParentId
(
secondId
);
platSpace
.
setParentPath
(
firstId
+
","
+
secondId
);
...
...
@@ -618,7 +642,7 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace
if
(!
childrenIdMap
.
containsKey
(
fourKey
))
{
PlatSpace
platSpace
=
new
PlatSpace
();
platSpace
.
setName
(
item
.
getFloor
());
platSpace
.
setType
(
PlatSpaceEnum
.
TypeEnum
.
FLOOR
.
getValue
());
//
platSpace.setType(PlatSpaceEnum.TypeEnum.FLOOR.getValue());
platSpace
.
setOrgId
(
orgId
);
if
(
org
!=
null
)
{
platSpace
.
setAttribute
(
org
.
getType
());
...
...
@@ -698,6 +722,7 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace
excelImportVo
.
setErrorCount
(
errorCount
);
excelImportVo
.
setSuccessCount
(
successCount
);
excelImportVo
.
setList
(
errorVoList
);
excelImportVo
.
setMatchesCount
(
successCount
);
if
(
errorCount
>
0
){
excelImportVo
.
setSuccessCount
(
0
);
excelImportVo
.
setMatchesCount
(
successCount
);
...
...
server-service/src/main/java/com/makeit/service/platform/workstation/impl/WorkStationServiceImpl.java
View file @
14cea1ba
...
...
@@ -2,6 +2,7 @@ package com.makeit.service.platform.workstation.impl;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.google.common.collect.Lists
;
import
com.makeit.common.entity.BaseEntity
;
import
com.makeit.common.page.PageReqDTO
;
import
com.makeit.common.page.PageVO
;
...
...
@@ -14,6 +15,7 @@ import com.makeit.entity.platform.auth.PlatOrg;
import
com.makeit.entity.platform.device.PlatDevice
;
import
com.makeit.entity.platform.elder.PlatElder
;
import
com.makeit.entity.platform.space.PlatBed
;
import
com.makeit.entity.platform.space.PlatRoomBedDevice
;
import
com.makeit.entity.platform.space.PlatSpace
;
import
com.makeit.entity.saas.analysis.SaasModelManage
;
import
com.makeit.entity.saas.analysis.SaasSleepAnalysisModel
;
...
...
@@ -29,15 +31,19 @@ import com.makeit.module.iot.service.IotProductDeviceService;
import
com.makeit.module.iot.vo.breathe.DeviceInfoContentBreathe
;
import
com.makeit.service.platform.alarm.PlatAlarmRecordService
;
import
com.makeit.service.platform.auth.PlatOrgService
;
import
com.makeit.service.platform.device.PlatDeviceService
;
import
com.makeit.service.platform.elder.PlatElderDayReportDayService
;
import
com.makeit.service.platform.elder.PlatElderRealTimeService
;
import
com.makeit.service.platform.elder.PlatElderService
;
import
com.makeit.service.platform.space.PlatBedService
;
import
com.makeit.service.platform.space.PlatRoomBedDeviceService
;
import
com.makeit.service.platform.space.PlatRoomService
;
import
com.makeit.service.platform.space.PlatSpaceService
;
import
com.makeit.service.platform.workstation.WorkStationService
;
import
com.makeit.service.saas.SaasModelManageService
;
import
com.makeit.service.saas.SaasSleepAnalysisModelService
;
import
com.makeit.shengwang.agora.service.ShengwangService
;
import
com.makeit.shengwang.agora.vo.PlatAlarmCallDeviceVO
;
import
com.makeit.utils.StandardDeviationUtil
;
import
com.makeit.utils.data.convert.PageUtil
;
import
com.makeit.utils.data.convert.StreamUtil
;
...
...
@@ -88,6 +94,10 @@ public class WorkStationServiceImpl implements WorkStationService {
private
PlatElderDayReportDayService
platElderDayReportDayService
;
@Autowired
private
IotProductDeviceService
iotProductDeviceService
;
@Autowired
private
PlatRoomBedDeviceService
platRoomBedDeviceService
;
@Autowired
private
PlatDeviceService
platDeviceService
;
@Override
public
WorkStationInstitutionStatisticsVO
institutionStatistics
(
WorkStationQueryDTO
dto
)
{
...
...
@@ -256,12 +266,38 @@ public class WorkStationServiceImpl implements WorkStationService {
}
LocalDateTime
now
=
LocalDateTime
.
now
();
LocalDateTime
start
=
now
.
minusSeconds
(
10
);
List
<
PlatRoomBedDevice
>
platRoomDevices
=
platRoomBedDeviceService
.
list
(
new
QueryWrapper
<
PlatRoomBedDevice
>().
lambda
()
.
in
(
PlatRoomBedDevice:
:
getRoomId
,
roomIds
)
.
isNull
(
PlatRoomBedDevice:
:
getBedId
));
List
<
PlatRoomBedDevice
>
platBedDevices
=
platRoomBedDeviceService
.
list
(
new
QueryWrapper
<
PlatRoomBedDevice
>().
lambda
()
.
in
(
PlatRoomBedDevice:
:
getRoomId
,
roomIds
)
.
isNotNull
(
PlatRoomBedDevice:
:
getBedId
));
Map
<
String
,
List
<
PlatRoomBedDevice
>>
roomDeviceMap
=
StreamUtil
.
groupBy
(
platRoomDevices
,
PlatRoomBedDevice:
:
getRoomId
);
Map
<
String
,
PlatRoomBedDevice
>
bedDeviceMap
=
StreamUtil
.
toMap
(
platBedDevices
,
PlatRoomBedDevice:
:
getBedId
);
List
<
PlatDevice
>
platDeviceList
=
platDeviceService
.
list
();
Map
<
String
,
PlatDevice
>
deviceMap
=
StreamUtil
.
toMap
(
platDeviceList
,
BaseEntity:
:
getId
);
for
(
WorkStationInstitutionRoomVO
vo
:
roomVOList
)
{
vo
.
setPathName
(
vo
.
getPathName
()
+
"-"
+
vo
.
getRoomName
());
List
<
PlatDevice
>
deviceList
=
Lists
.
newArrayList
();
if
(
bedMap
.
get
(
vo
.
getRoomId
())
!=
null
)
{
List
<
WorkStationInstitutionBedVO
>
roomBedVos
=
bedMap
.
get
(
vo
.
getRoomId
());
//获取告警类型及老人状态
for
(
WorkStationInstitutionBedVO
r
:
roomBedVos
){
List
<
PlatRoomBedDevice
>
platRoomBedDevices
=
roomDeviceMap
.
get
(
r
.
getRoomId
());
if
(
CollectionUtils
.
isNotEmpty
(
platRoomBedDevices
))
{
List
<
String
>
tempDeviceIdList
=
StreamUtil
.
map
(
platRoomBedDevices
,
PlatRoomBedDevice:
:
getDeviceId
);
for
(
String
s
:
tempDeviceIdList
)
{
PlatDevice
platDevice
=
deviceMap
.
get
(
s
);
if
(
platDevice
!=
null
)
{
deviceList
.
add
(
platDevice
);
}
}
}
if
(
StringUtil
.
isNotEmpty
(
r
.
getElderId
())
)
{
if
(
elderAlarmTypeMap
.
containsKey
(
r
.
getElderId
())){
r
.
setAlarmTypeMap
(
elderAlarmTypeMap
.
get
(
r
.
getElderId
()));
...
...
@@ -271,24 +307,16 @@ public class WorkStationServiceImpl implements WorkStationService {
platElderIdDTO
.
setElderId
(
r
.
getElderId
());
PlatElderRealTimeHeartRespiratoryVO
heartRespiratoryVO
=
platElderRealTimeService
.
heartRespiratory
(
platElderIdDTO
);
r
.
setElderStatus
(
heartRespiratoryVO
.
getStatus
());
/* PlatElderRealTimeNowVO nowStatus = platElderRealTimeService.nowStatus(platElderIdDTO);
if(nowStatus.getStatus()!=null){
DeviceInfoContentBreathe deviceInfoContentBreathe = getNowDataBreathe(platElderIdDTO.getElderId(), platElderIdDTO.getDeviceId());
//离床:雷达状态上报无人
//翻身:雷达上报的数据符合IOT平台睡眠质量分析模型中配置的翻身规则
//睡眠:雷达上报的数据符合IOT平台睡眠质量分析模型中的入睡时间,状态变更为睡眠
//静息:雷达上报有人,且非睡眠
if(DeviceInfoContentBreatheEnum.PersonStateEnum.NOBODY.getValue().equals(nowStatus.getStatus())){
r.setElderStatus(WorkStationStatusEnum.NowStatus.OUT.getValue());
}else if(nowStatus.getBodyMove()!=null && nowStatus.getBodyMove() > turnedThreshold){
r.setElderStatus(WorkStationStatusEnum.NowStatus.TURNED.getValue());
}else {
List<PlatElderCoordinateVO> coordinateList = platElderDayReportDayService.coordinateList(platElderIdDTO.getElderId(), platElderIdDTO.getDeviceId(), start, now);
nowStatusRest(r, platElderIdDTO, deviceInfoContentBreathe, coordinateList);
nowStatusSleep(r, platElderIdDTO, deviceInfoContentBreathe);
PlatRoomBedDevice
platRoomBedDevice
=
bedDeviceMap
.
get
(
r
.
getBedId
());
if
(
platRoomBedDevice
!=
null
)
{
PlatDevice
platDevice
=
deviceMap
.
get
(
platRoomBedDevice
.
getDeviceId
());
if
(
platDevice
!=
null
)
{
deviceList
.
add
(
platDevice
);
}
}
*/
}
}
r
.
setDeviceList
(
deviceList
);
}
vo
.
setList
(
roomBedVos
);
...
...
@@ -546,6 +574,8 @@ public class WorkStationServiceImpl implements WorkStationService {
new
Page
<>(
page
.
getPage
(),
page
.
getLimit
()),
page
.
getData
());
List
<
WorkStationHomeBedVO
>
list
=
pages
.
getRecords
();
List
<
String
>
roomIds
=
list
.
stream
().
map
(
WorkStationHomeBedVO:
:
getRoomId
).
collect
(
Collectors
.
toList
());
JoinUtil
.
joinSplit
(
list
,
platSpaceService
,
WorkStationHomeBedVO:
:
getSpacePath
,
PlatSpace:
:
getId
,
(
e
,
l
)
->
{
e
.
setPathName
(
StreamUtil
.
join
(
l
,
Objects:
:
nonNull
,
PlatSpace:
:
getName
,
"-"
));
});
...
...
@@ -554,8 +584,32 @@ public class WorkStationServiceImpl implements WorkStationService {
e
.
setAvatarPath
(
f
.
getFullUrl
());
});
List
<
PlatRoomBedDevice
>
platRoomDevices
=
platRoomBedDeviceService
.
list
(
new
QueryWrapper
<
PlatRoomBedDevice
>().
lambda
()
.
in
(
PlatRoomBedDevice:
:
getRoomId
,
roomIds
)
.
isNull
(
PlatRoomBedDevice:
:
getBedId
));
List
<
PlatRoomBedDevice
>
platBedDevices
=
platRoomBedDeviceService
.
list
(
new
QueryWrapper
<
PlatRoomBedDevice
>().
lambda
()
.
in
(
PlatRoomBedDevice:
:
getRoomId
,
roomIds
)
.
isNotNull
(
PlatRoomBedDevice:
:
getBedId
));
Map
<
String
,
List
<
PlatRoomBedDevice
>>
roomDeviceMap
=
StreamUtil
.
groupBy
(
platRoomDevices
,
PlatRoomBedDevice:
:
getRoomId
);
Map
<
String
,
PlatRoomBedDevice
>
bedDeviceMap
=
StreamUtil
.
toMap
(
platBedDevices
,
PlatRoomBedDevice:
:
getBedId
);
List
<
PlatDevice
>
platDeviceList
=
platDeviceService
.
list
();
Map
<
String
,
PlatDevice
>
deviceMap
=
StreamUtil
.
toMap
(
platDeviceList
,
BaseEntity:
:
getId
);
for
(
WorkStationHomeBedVO
vo
:
list
){
vo
.
setPathName
(
vo
.
getPathName
()
+
"-"
+
vo
.
getRoomName
());
List
<
PlatDevice
>
deviceList
=
Lists
.
newArrayList
();
List
<
PlatRoomBedDevice
>
platRoomBedDevices
=
roomDeviceMap
.
get
(
vo
.
getRoomId
());
if
(
CollectionUtils
.
isNotEmpty
(
platRoomBedDevices
))
{
List
<
String
>
tempDeviceIdList
=
StreamUtil
.
map
(
platRoomBedDevices
,
PlatRoomBedDevice:
:
getDeviceId
);
for
(
String
s
:
tempDeviceIdList
)
{
PlatDevice
platDevice
=
deviceMap
.
get
(
s
);
if
(
platDevice
!=
null
)
{
deviceList
.
add
(
platDevice
);
}
}
}
if
(
StringUtil
.
isNotEmpty
(
vo
.
getElderId
())
)
{
if
(
elderAlarmTypeMap
.
containsKey
(
vo
.
getElderId
())){
vo
.
setAlarmTypeMap
(
elderAlarmTypeMap
.
get
(
vo
.
getElderId
()));
...
...
@@ -564,10 +618,21 @@ public class WorkStationServiceImpl implements WorkStationService {
PlatElderIdDTO
platElderIdDTO
=
new
PlatElderIdDTO
();
platElderIdDTO
.
setElderId
(
vo
.
getElderId
());
PlatElderRealTimeHeartRespiratoryVO
respiratoryVO
=
platElderRealTimeService
.
heartRespiratory
(
platElderIdDTO
);
vo
.
setElderStatus
(
respiratoryVO
.
getStatus
());
vo
.
setHeartRate
(
respiratoryVO
.
getHeartRate
());
vo
.
setRespiratoryRate
(
respiratoryVO
.
getRespiratoryRate
());
PlatRoomBedDevice
platRoomBedDevice
=
bedDeviceMap
.
get
(
vo
.
getBedId
());
if
(
platRoomBedDevice
!=
null
)
{
PlatDevice
platDevice
=
deviceMap
.
get
(
platRoomBedDevice
.
getDeviceId
());
if
(
platDevice
!=
null
)
{
deviceList
.
add
(
platDevice
);
}
}
vo
.
setDeviceList
(
deviceList
);
}
}
return
PageUtil
.
toPageVO
(
pages
);
...
...
server-service/src/main/java/com/makeit/vo/platform/alarm/PlatAlarmRecordVO.java
View file @
14cea1ba
...
...
@@ -2,6 +2,7 @@ package com.makeit.vo.platform.alarm;
import
com.fasterxml.jackson.annotation.JsonFormat
;
import
com.makeit.common.dto.BaseTenantDTO
;
import
com.makeit.entity.platform.device.PlatDevice
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
...
...
@@ -62,9 +63,13 @@ public class PlatAlarmRecordVO extends BaseTenantDTO {
@ApiModelProperty
(
value
=
"0-未读 1-已读"
)
private
String
readFlag
;
@ApiModelProperty
(
value
=
"微信端 0-未读 1-已读"
)
private
String
wechatReadFlag
;
@ApiModelProperty
(
value
=
"是否误报 1 误报 0 没有误报"
)
private
String
misinformationFlag
;
private
String
deviceId
;
private
PlatDevice
device
;
}
server-service/src/main/java/com/makeit/vo/platform/device/PlatDeviceListVO.java
View file @
14cea1ba
...
...
@@ -93,6 +93,8 @@ public class PlatDeviceListVO extends BaseTenantDTO {
private
String
roomName
;
private
String
bedName
;
@ApiModelProperty
(
value
=
"许可证"
)
private
String
deviceLicense
;
}
server-service/src/main/java/com/makeit/vo/platform/elder/PlatElderListVO.java
View file @
14cea1ba
...
...
@@ -2,12 +2,14 @@ package com.makeit.vo.platform.elder;
import
com.fasterxml.jackson.annotation.JsonFormat
;
import
com.makeit.common.dto.BaseTenantDTO
;
import
com.makeit.entity.platform.device.PlatDevice
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
lombok.EqualsAndHashCode
;
import
java.time.LocalDateTime
;
import
java.util.List
;
/**
* <p>
...
...
@@ -137,5 +139,7 @@ public class PlatElderListVO extends BaseTenantDTO {
private
String
updateBy
;
@ApiModelProperty
(
value
=
"头像文件id"
)
private
String
avatar
;
@ApiModelProperty
(
"设备列表"
)
private
List
<
PlatDevice
>
deviceList
;
}
server-service/src/main/java/com/makeit/vo/platform/elder/realtime/PlatElderRealTimeHeartRespiratoryVO.java
View file @
14cea1ba
...
...
@@ -23,5 +23,7 @@ public class PlatElderRealTimeHeartRespiratoryVO {
@ApiModelProperty
(
"状态"
)
private
String
status
;
@ApiModelProperty
(
"设备id"
)
private
String
deviceId
;
}
server-service/src/main/java/com/makeit/vo/platform/workstation/WorkStationHomeBedVO.java
View file @
14cea1ba
package
com
.
makeit
.
vo
.
platform
.
workstation
;
import
com.makeit.entity.platform.device.PlatDevice
;
import
com.makeit.shengwang.agora.vo.PlatAlarmCallDeviceVO
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
...
...
@@ -64,6 +66,8 @@ public class WorkStationHomeBedVO {
@ApiModelProperty
(
"呼吸率"
)
private
Integer
respiratoryRate
;
@ApiModelProperty
(
"设备列表"
)
private
List
<
PlatDevice
>
deviceList
;
@ApiModelProperty
(
value
=
"告警类型"
)
private
Map
<
String
,
String
>
alarmTypeMap
;
...
...
server-service/src/main/java/com/makeit/vo/platform/workstation/WorkStationInstitutionBedVO.java
View file @
14cea1ba
package
com
.
makeit
.
vo
.
platform
.
workstation
;
import
com.makeit.entity.platform.device.PlatDevice
;
import
com.makeit.shengwang.agora.vo.PlatAlarmCallDeviceVO
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
...
...
@@ -43,7 +45,8 @@ public class WorkStationInstitutionBedVO {
@ApiModelProperty
(
value
=
"长者状态"
)
private
String
elderStatus
;
@ApiModelProperty
(
"设备列表"
)
private
List
<
PlatDevice
>
deviceList
;
@ApiModelProperty
(
value
=
"告警类型"
)
private
Map
<
String
,
String
>
alarmTypeMap
;
}
server-service/src/main/resources/mappers/PlatBedMapper.xml
View file @
14cea1ba
...
...
@@ -12,7 +12,7 @@
LEFT JOIN plat_elder pe on pe.bed_id = pb.id
<where>
pb.del_flag = 0
<if
test=
"dto.id != null and dto.id != ''"
>
<if
test=
"dto.id != null and dto.id != ''
and dto.type == 1
"
>
AND FIND_IN_SET(#{dto.id},pm.space_path)
</if>
<if
test=
"dto.status != null and dto.status != ''"
>
...
...
@@ -24,6 +24,9 @@
#{item}
</foreach>
</if>
<if
test=
"dto.id != null and dto.id != '' and dto.type == 2"
>
AND pm.id = #{dto.id}
</if>
</where>
</select>
...
...
server-service/src/main/resources/mappers/PlatDeviceMapper.xml
View file @
14cea1ba
...
...
@@ -40,6 +40,17 @@
<if
test=
"param.orgId != null and param.orgId != '' "
>
and pd.org_id = #{param.orgId}
</if>
<if
test=
"param.tenantId != null and param.tenantId != ''"
>
and pd.tenant_id = #{param.tenantId}
</if>
<choose>
<when
test=
"param.active !=null and param.active !='' and param.active == 1"
>
and pd.device_license is not null
</when>
<when
test=
"param.active !=null and param.active !='' and param.active == 0"
>
and pd.device_license is null
</when>
</choose>
<if
test=
"param.orgIds != null and param.orgIds.size() > 0 "
>
AND pd.org_id in
<foreach
collection=
"param.orgIds"
item=
"item"
separator=
","
open=
"("
close=
")"
index=
""
>
...
...
server-web/src/main/resources/application-dev.yml
View file @
14cea1ba
...
...
@@ -62,6 +62,11 @@ mybatis-plus:
configuration
:
log-impl
:
org.apache.ibatis.logging.stdout.StdOutImpl
logging
:
level
:
root
:
debug
file
:
filePath
:
file
file
:
D:/pro/${file.filePath}
...
...
@@ -109,6 +114,7 @@ libreOffice: C:\\Program Files\\LibreOffice\\program\\soffice
iot
:
url
:
https://iot.qa.insightica.cn/api/
uploadUrl
:
https://saas.qa.insightica.cn/api/saas/device/devicePushLog
clientId
:
fyxmb5h52iKwE2Hi
secureKey
:
22fZbnH36wdHn7ZTyKKHraFw233npcez
sync
:
...
...
@@ -163,6 +169,16 @@ shengwang:
pid
:
9851781E9E31453DA3C572A4A4AF9402
aliyun
:
oss
:
accessKey
:
LTAI5tMjaFCiaYYLmtCLiuMj
secretKey
:
Oq1925mQ8663nxaf83MyoOGAbVM71H
endpoint
:
oss-cn-shenzhen.aliyuncs.com
bucket
:
kangyang-oss
baseDir
:
kangyang
server-web/src/main/resources/application-test.yml
View file @
14cea1ba
...
...
@@ -105,6 +105,7 @@ libreOffice: /home/group1_lzy/iot-server/LibreOffice/program/soffice
iot
:
url
:
https://iot.qa.insightica.cn/api/
uploadUrl
:
https://saas.qa.insightica.cn/api/saas/device/devicePushLog
clientId
:
fyxmb5h52iKwE2Hi
secureKey
:
22fZbnH36wdHn7ZTyKKHraFw233npcez
...
...
@@ -157,3 +158,12 @@ shengwang:
customerSecret
:
bd81828a133140a58dfb04e9d80eba43
pid
:
9851781E9E31453DA3C572A4A4AF9402
aliyun
:
oss
:
accessKey
:
LTAI5tMjaFCiaYYLmtCLiuMj
secretKey
:
Oq1925mQ8663nxaf83MyoOGAbVM71H
endpoint
:
oss-cn-shenzhen.aliyuncs.com
bucket
:
kangyang-oss
baseDir
:
kangyang
server-web/src/main/resources/logback-spring.xml
View file @
14cea1ba
...
...
@@ -7,11 +7,6 @@
<property
name=
"pattern"
value=
"%d{yyyy-MM-dd HH:mm:ss.SSS} [%X{appName}] [%X{profile}] [%X{traceId:-},%X{spanId:-}] [%X{requestId}] [%X{userId}] [%thread] %-5level %logger{50} - %msg%n"
/>
<springProfile
name=
"dev"
>
<property
name=
"logback.logdir"
value=
"/home/group1_lzy/iot-server/logs"
/>
<property
name=
"logback.appname"
value=
"app"
/>
</springProfile>
<springProfile
name=
"prod"
>
<property
name=
"logback.logdir"
value=
"/home/group1_lzy/iot-server/logs"
/>
<property
name=
"logback.appname"
value=
"app"
/>
...
...
@@ -132,11 +127,6 @@
<appender-ref
ref=
"FILEERRORLOG"
/>
<appender-ref
ref=
"FILEWARNLOG"
/>
</logger>
<logger
name=
"com.makeit"
level=
"ERROR"
additivity=
"false"
>
<appender-ref
ref=
"FILEINFOLOG"
/>
<appender-ref
ref=
"FILEERRORLOG"
/>
<appender-ref
ref=
"FILEWARNLOG"
/>
</logger>
</springProfile>
<springProfile
name=
"test"
>
...
...
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