Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
open-source
/
chejia-smart-service
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 372c3133
authored
May 08, 2021
by
wnb0128
Browse Files
Options
Browse Files
Tag
Download
Plain Diff
Merge branch 'dev' of 192.168.3.233:open-source/chejia-smart-service into dev
2 parents
1c8599a3
c2b3e389
Show whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
235 additions
and
215 deletions
src/main/java/cn/com/glsx/smart/common/exception/BusinessException.java
src/main/java/cn/com/glsx/smart/common/exception/ChejiaBusinessException.java
src/main/java/cn/com/glsx/smart/common/exception/ChejiaSmartExceptionHandler.java
src/main/java/cn/com/glsx/smart/common/filter/ChejiaCorsFilter.java
src/main/java/cn/com/glsx/smart/modules/controller/SysCodeController.java
src/main/java/cn/com/glsx/smart/modules/controller/UserDeviceController.java
src/main/java/cn/com/glsx/smart/modules/service/impl/AiLockingKeyServiceImpl.java
src/main/java/cn/com/glsx/smart/modules/service/impl/AiLockingKeyShareServiceImpl.java
src/main/java/cn/com/glsx/smart/modules/service/impl/SmartProductServiceImpl.java
src/main/java/cn/com/glsx/smart/modules/service/impl/SmartProductTypeServiceImpl.java
src/main/java/cn/com/glsx/smart/modules/service/impl/SmartSceneDataServiceImpl.java
src/main/java/cn/com/glsx/smart/modules/service/impl/SmartSceneServiceImpl.java
src/main/java/cn/com/glsx/smart/modules/service/impl/SmartSysCodeServiceImpl.java
src/main/java/cn/com/glsx/smart/modules/service/impl/SmartSysFileServiceImpl.java
src/main/java/cn/com/glsx/smart/modules/service/impl/SmartTemplateParamServiceImpl.java
src/main/java/cn/com/glsx/smart/modules/service/impl/SmartUserDeviceServiceImpl.java
src/main/java/cn/com/glsx/smart/modules/service/impl/SmartUserRelationServiceImpl.java
src/main/java/cn/com/glsx/smart/common/exception/BusinessException.java
deleted
100644 → 0
View file @
1c8599a
package
cn
.
com
.
glsx
.
smart
.
common
.
exception
;
/**
* <p>Description:
* <p>Project: chejia-smart
*
* @author wbh
* @date 2021-03-16
*/
public
class
BusinessException
extends
RuntimeException
{
private
Integer
code
;
private
String
message
;
public
BusinessException
()
{}
public
BusinessException
(
ResultEnum
resultEnum
)
{
this
.
code
=
resultEnum
.
getCode
();
this
.
message
=
resultEnum
.
getMessage
();
}
public
Integer
getCode
()
{
return
code
;
}
public
void
setCode
(
Integer
code
)
{
this
.
code
=
code
;
}
@Override
public
String
getMessage
()
{
return
message
;
}
public
void
setMessage
(
String
message
)
{
this
.
message
=
message
;
}
public
static
BusinessException
create
(
int
code
,
String
message
){
BusinessException
businessException
=
new
BusinessException
();
businessException
.
code
=
code
;
businessException
.
message
=
message
;
return
businessException
;
}
public
static
BusinessException
create
(
ResultEnum
resultEnum
)
{
return
create
(
resultEnum
.
getCode
(),
resultEnum
.
getMessage
());
}
public
static
BusinessException
create
(
ResultEnum
resultEnum
,
Object
...
args
)
{
String
message
=
String
.
format
(
resultEnum
.
getMessage
(),
args
);
return
create
(
resultEnum
.
getCode
(),
message
);
}
}
src/main/java/cn/com/glsx/smart/common/exception/ChejiaBusinessException.java
0 → 100644
View file @
372c313
package
cn
.
com
.
glsx
.
smart
.
common
.
exception
;
import
com.glsx.plat.exception.BusinessException
;
/**
* <p>Description: 车家智能异常类
* <p>Project: chejia-smart
*
* @author wbh
* @date 2021-03-16
*/
public
class
ChejiaBusinessException
extends
BusinessException
{
private
ChejiaBusinessException
(
int
code
,
String
message
)
{
super
(
BusinessException
.
create
(
code
,
message
));
}
//private ChejiaBusinessException(ResultEnum resultEnum) {
// this(resultEnum.getCode(), resultEnum.getMessage());
//}
public
static
ChejiaBusinessException
create
(
int
code
,
String
message
){
return
new
ChejiaBusinessException
(
code
,
message
);
}
//public static ChejiaBusinessException create(ResultEnum resultEnum) {
// return create(resultEnum.getCode(), resultEnum.getMessage());
//}
public
static
ChejiaBusinessException
create
(
ResultEnum
resultEnum
,
Object
...
args
)
{
String
message
=
String
.
format
(
resultEnum
.
getMessage
(),
args
);
return
create
(
resultEnum
.
getCode
(),
message
);
}
}
src/main/java/cn/com/glsx/smart/common/exception/ChejiaSmartExceptionHandler.java
View file @
372c313
...
@@ -3,9 +3,6 @@ package cn.com.glsx.smart.common.exception;
...
@@ -3,9 +3,6 @@ package cn.com.glsx.smart.common.exception;
import
com.glsx.plat.core.web.R
;
import
com.glsx.plat.core.web.R
;
import
com.glsx.plat.exception.GlobalExceptionHandler
;
import
com.glsx.plat.exception.GlobalExceptionHandler
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.validation.BindException
;
import
org.springframework.web.bind.MethodArgumentNotValidException
;
import
org.springframework.web.bind.ServletRequestBindingException
;
import
org.springframework.web.bind.annotation.ExceptionHandler
;
import
org.springframework.web.bind.annotation.ExceptionHandler
;
import
org.springframework.web.bind.annotation.RestControllerAdvice
;
import
org.springframework.web.bind.annotation.RestControllerAdvice
;
...
@@ -15,21 +12,21 @@ import org.springframework.web.bind.annotation.RestControllerAdvice;
...
@@ -15,21 +12,21 @@ import org.springframework.web.bind.annotation.RestControllerAdvice;
*
*
* @author wbh
* @author wbh
* @date 2021-03-16
* @date 2021-03-16
* @deprecated 抛出异常,让上游服务捕获信息
*/
*/
@Slf4j
@Slf4j
@RestControllerAdvice
@RestControllerAdvice
public
class
ChejiaSmartExceptionHandler
extends
GlobalExceptionHandler
{
public
class
ChejiaSmartExceptionHandler
extends
GlobalExceptionHandler
{
@ExceptionHandler
({
BusinessException
.
class
})
@ExceptionHandler
({
Chejia
BusinessException
.
class
})
public
R
handleBusinessException
(
BusinessException
e
)
{
public
R
handleBusinessException
(
Chejia
BusinessException
e
)
{
log
.
error
(
"业务异常"
,
e
);
log
.
error
(
"业务异常"
,
e
);
return
R
.
error
(
e
.
getMessage
());
R
r
=
e
.
getResultEntity
();
return
R
.
error
(
r
.
getCode
(),
r
.
getMessage
());
}
}
@ExceptionHandler
({
CarKeyException
.
class
})
@ExceptionHandler
({
CarKeyException
.
class
})
public
R
handleCarKeyException
(
CarKeyException
e
)
{
public
R
handleCarKeyException
(
CarKeyException
e
)
{
log
.
error
(
"车钥匙异常"
,
e
);
log
.
error
(
"车钥匙异常"
,
e
);
return
R
.
error
(
e
.
getCode
(),
e
.
getMessage
());
return
R
.
error
(
e
.
getCode
(),
e
.
getMessage
());
}
}
//@ExceptionHandler({ServletRequestBindingException.class, MethodArgumentNotValidException.class,
//@ExceptionHandler({ServletRequestBindingException.class, MethodArgumentNotValidException.class,
...
@@ -38,7 +35,7 @@ public class ChejiaSmartExceptionHandler extends GlobalExceptionHandler {
...
@@ -38,7 +35,7 @@ public class ChejiaSmartExceptionHandler extends GlobalExceptionHandler {
// log.error("参数错误", e);
// log.error("参数错误", e);
// return R.error(ResultEnum.PARAM_ERROR.getCode(), ResultEnum.PARAM_ERROR.getMessage());
// return R.error(ResultEnum.PARAM_ERROR.getCode(), ResultEnum.PARAM_ERROR.getMessage());
//}
//}
//
//@ExceptionHandler(Exception.class)
//@ExceptionHandler(Exception.class)
//public R handleException(Exception e) {
//public R handleException(Exception e) {
// log.error("未知异常", e);
// log.error("未知异常", e);
...
...
src/main/java/cn/com/glsx/smart/common/filter/ChejiaCorsFilter.java
View file @
372c313
package
cn
.
com
.
glsx
.
smart
.
common
.
filter
;
package
cn
.
com
.
glsx
.
smart
.
common
.
filter
;
import
com.glsx.plat.common.utils.StringUtils
;
import
javax.servlet.Filter
;
import
org.springframework.http.HttpHeaders
;
import
javax.servlet.FilterChain
;
import
org.springframework.http.HttpMethod
;
import
javax.servlet.ServletException
;
import
org.springframework.stereotype.Component
;
import
javax.servlet.ServletRequest
;
import
javax.servlet.ServletResponse
;
import
javax.servlet.*
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.util.Enumeration
;
import
java.util.Enumeration
;
import
com.glsx.plat.common.utils.StringUtils
;
import
org.springframework.http.HttpHeaders
;
import
org.springframework.http.HttpMethod
;
/**
/**
* <p>Description: 跨域配置
* <p>Description: 跨域配置
...
@@ -18,8 +20,7 @@ import java.util.Enumeration;
...
@@ -18,8 +20,7 @@ import java.util.Enumeration;
* @author wbh
* @author wbh
* @date 2021-03-18
* @date 2021-03-18
*/
*/
//TODO 跨域有默认的拦截器,请对比后处理 宝辉 已存在com.glsx.plat.web.filter.CorsFilter
//@Component
@Component
public
class
ChejiaCorsFilter
implements
Filter
{
public
class
ChejiaCorsFilter
implements
Filter
{
@Override
@Override
public
void
doFilter
(
ServletRequest
request
,
ServletResponse
response
,
FilterChain
chain
)
public
void
doFilter
(
ServletRequest
request
,
ServletResponse
response
,
FilterChain
chain
)
...
...
src/main/java/cn/com/glsx/smart/modules/controller/SysCodeController.java
View file @
372c313
package
cn
.
com
.
glsx
.
smart
.
modules
.
controller
;
package
cn
.
com
.
glsx
.
smart
.
modules
.
controller
;
import
java.util.List
;
import
cn.com.glsx.smart.common.exception.ResultEnum
;
import
cn.com.glsx.smart.common.exception.ResultEnum
;
import
cn.com.glsx.smart.modules.entity.SmartSysCode
;
import
cn.com.glsx.smart.modules.entity.SmartSysCode
;
import
cn.com.glsx.smart.modules.service.SmartSysCodeService
;
import
cn.com.glsx.smart.modules.service.SmartSysCodeService
;
...
@@ -13,8 +14,6 @@ import org.springframework.web.bind.annotation.RequestMapping;
...
@@ -13,8 +14,6 @@ import org.springframework.web.bind.annotation.RequestMapping;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.RestController
;
import
java.util.List
;
/**
/**
* <p>Description:
* <p>Description:
* <p>Project: chejia-smart
* <p>Project: chejia-smart
...
...
src/main/java/cn/com/glsx/smart/modules/controller/UserDeviceController.java
View file @
372c313
package
cn
.
com
.
glsx
.
smart
.
modules
.
controller
;
package
cn
.
com
.
glsx
.
smart
.
modules
.
controller
;
import
cn.com.glsx.smart.common.exception.BusinessException
;
import
java.util.List
;
import
cn.com.glsx.smart.common.exception.ChejiaBusinessException
;
import
cn.com.glsx.smart.common.exception.ResultEnum
;
import
cn.com.glsx.smart.common.exception.ResultEnum
;
import
cn.com.glsx.smart.modules.entity.SmartUserDevice
;
import
cn.com.glsx.smart.modules.entity.SmartUserDevice
;
import
cn.com.glsx.smart.modules.service.SmartUserDeviceService
;
import
cn.com.glsx.smart.modules.service.SmartUserDeviceService
;
...
@@ -14,8 +15,6 @@ import org.springframework.web.bind.annotation.RequestMapping;
...
@@ -14,8 +15,6 @@ import org.springframework.web.bind.annotation.RequestMapping;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.RestController
;
import
java.util.List
;
/**
/**
* <p>Description: 用户设备业务
* <p>Description: 用户设备业务
* <p>Project: chejia-smart
* <p>Project: chejia-smart
...
@@ -40,7 +39,7 @@ public class UserDeviceController {
...
@@ -40,7 +39,7 @@ public class UserDeviceController {
public
List
<
SmartUserDevice
>
getList
(
SmartUserDevice
req
)
{
public
List
<
SmartUserDevice
>
getList
(
SmartUserDevice
req
)
{
log
.
info
(
"$$$$ /userDevice/getList param: {}"
,
JSON
.
toJSONString
(
req
));
log
.
info
(
"$$$$ /userDevice/getList param: {}"
,
JSON
.
toJSONString
(
req
));
if
(
req
.
getUserId
()
==
null
)
{
if
(
req
.
getUserId
()
==
null
)
{
throw
BusinessException
.
create
(
ResultEnum
.
PARAM_EMPTY
,
"userId"
);
throw
Chejia
BusinessException
.
create
(
ResultEnum
.
PARAM_EMPTY
,
"userId"
);
}
}
return
userDeviceService
.
getList
(
req
);
return
userDeviceService
.
getList
(
req
);
}
}
...
@@ -55,7 +54,7 @@ public class UserDeviceController {
...
@@ -55,7 +54,7 @@ public class UserDeviceController {
public
SmartUserDevice
getByDeviceId
(
SmartUserDevice
req
)
{
public
SmartUserDevice
getByDeviceId
(
SmartUserDevice
req
)
{
log
.
info
(
"$$$$ /userDevice/getByDeviceId param: {}"
,
JSON
.
toJSONString
(
req
));
log
.
info
(
"$$$$ /userDevice/getByDeviceId param: {}"
,
JSON
.
toJSONString
(
req
));
if
(
StringUtils
.
isBlank
(
req
.
getDeviceId
()))
{
if
(
StringUtils
.
isBlank
(
req
.
getDeviceId
()))
{
throw
BusinessException
.
create
(
ResultEnum
.
PARAM_EMPTY
,
"deviceId"
);
throw
Chejia
BusinessException
.
create
(
ResultEnum
.
PARAM_EMPTY
,
"deviceId"
);
}
}
return
userDeviceService
.
getByDeviceId
(
req
);
return
userDeviceService
.
getByDeviceId
(
req
);
}
}
...
@@ -70,7 +69,7 @@ public class UserDeviceController {
...
@@ -70,7 +69,7 @@ public class UserDeviceController {
public
boolean
save
(
@RequestBody
SmartUserDevice
req
)
{
public
boolean
save
(
@RequestBody
SmartUserDevice
req
)
{
log
.
info
(
"$$$$ /userDevice/save param: {}"
,
JSON
.
toJSONString
(
req
));
log
.
info
(
"$$$$ /userDevice/save param: {}"
,
JSON
.
toJSONString
(
req
));
if
(
StringUtils
.
isBlank
(
req
.
getDeviceId
())
||
req
.
getChannel
()
==
null
)
{
if
(
StringUtils
.
isBlank
(
req
.
getDeviceId
())
||
req
.
getChannel
()
==
null
)
{
throw
BusinessException
.
create
(
ResultEnum
.
PARAM_EMPTY
,
"deviceId, channel"
);
throw
Chejia
BusinessException
.
create
(
ResultEnum
.
PARAM_EMPTY
,
"deviceId, channel"
);
}
}
return
userDeviceService
.
save
(
req
)
>
0
;
return
userDeviceService
.
save
(
req
)
>
0
;
}
}
...
@@ -85,7 +84,7 @@ public class UserDeviceController {
...
@@ -85,7 +84,7 @@ public class UserDeviceController {
public
boolean
deleteDevice
(
@RequestBody
SmartUserDevice
req
)
{
public
boolean
deleteDevice
(
@RequestBody
SmartUserDevice
req
)
{
log
.
info
(
"$$$$ /userDevice/deleteDevice param: {}"
,
JSON
.
toJSONString
(
req
));
log
.
info
(
"$$$$ /userDevice/deleteDevice param: {}"
,
JSON
.
toJSONString
(
req
));
if
(
StringUtils
.
isBlank
(
req
.
getDeviceId
())
||
req
.
getChannel
()
==
null
)
{
if
(
StringUtils
.
isBlank
(
req
.
getDeviceId
())
||
req
.
getChannel
()
==
null
)
{
throw
BusinessException
.
create
(
ResultEnum
.
PARAM_EMPTY
,
"deviceId, channel"
);
throw
Chejia
BusinessException
.
create
(
ResultEnum
.
PARAM_EMPTY
,
"deviceId, channel"
);
}
}
return
userDeviceService
.
deleteDevice
(
req
)
>
0
;
return
userDeviceService
.
deleteDevice
(
req
)
>
0
;
}
}
...
@@ -100,7 +99,7 @@ public class UserDeviceController {
...
@@ -100,7 +99,7 @@ public class UserDeviceController {
public
String
getUserBindKey
(
String
token
)
{
public
String
getUserBindKey
(
String
token
)
{
log
.
info
(
"$$$$ /userDevice/getUserBindKey param: {}"
,
token
);
log
.
info
(
"$$$$ /userDevice/getUserBindKey param: {}"
,
token
);
if
(
StringUtils
.
isBlank
(
token
))
{
if
(
StringUtils
.
isBlank
(
token
))
{
throw
BusinessException
.
create
(
ResultEnum
.
PARAM_EMPTY
,
"token"
);
throw
Chejia
BusinessException
.
create
(
ResultEnum
.
PARAM_EMPTY
,
"token"
);
}
}
return
userDeviceService
.
getUserBindKey
(
token
);
return
userDeviceService
.
getUserBindKey
(
token
);
}
}
...
...
src/main/java/cn/com/glsx/smart/modules/service/impl/AiLockingKeyServiceImpl.java
View file @
372c313
package
cn
.
com
.
glsx
.
smart
.
modules
.
service
.
impl
;
package
cn
.
com
.
glsx
.
smart
.
modules
.
service
.
impl
;
import
cn.com.glsx.smart.modules.entity.*
;
import
java.util.ArrayList
;
import
cn.com.glsx.smart.common.exception.BusinessException
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.stream.Collectors
;
import
cn.com.glsx.smart.common.exception.ChejiaBusinessException
;
import
cn.com.glsx.smart.common.exception.ResultEnum
;
import
cn.com.glsx.smart.common.exception.ResultEnum
;
import
cn.com.glsx.smart.modules.model.request.*
;
import
cn.com.glsx.smart.modules.model.response.SmartCarKeyResponse
;
import
cn.com.glsx.smart.modules.service.*
;
import
cn.com.glsx.smart.common.utils.AesEncryptUtils
;
import
cn.com.glsx.smart.common.utils.AesEncryptUtils
;
import
cn.com.glsx.smart.common.utils.JwtUtil
;
import
cn.com.glsx.smart.common.utils.JwtUtil
;
import
cn.com.glsx.smart.common.utils.SnowflakeWorker
;
import
cn.com.glsx.smart.common.utils.SnowflakeWorker
;
import
cn.com.glsx.smart.modules.entity.SmartKeyBlueSense
;
import
cn.com.glsx.smart.modules.entity.SmartKeyBlueSenseExample
;
import
cn.com.glsx.smart.modules.entity.SmartKeyCommandLog
;
import
cn.com.glsx.smart.modules.entity.SmartVehicleBlueKey
;
import
cn.com.glsx.smart.modules.entity.SmartVehicleBlueKeyExample
;
import
cn.com.glsx.smart.modules.entity.SmartVehicleBlueShareKey
;
import
cn.com.glsx.smart.modules.entity.SmartVehicleBlueShareKeyExample
;
import
cn.com.glsx.smart.modules.model.request.SmartCarKeyActionLogBatchRequest
;
import
cn.com.glsx.smart.modules.model.request.SmartCarKeyAutoSenseRequest
;
import
cn.com.glsx.smart.modules.model.request.SmartCarKeyCommandRequest
;
import
cn.com.glsx.smart.modules.model.request.SmartCarKeyNameRequest
;
import
cn.com.glsx.smart.modules.model.request.SmartCarKeyRegisterRequest
;
import
cn.com.glsx.smart.modules.model.request.SmartCarKeyRequest
;
import
cn.com.glsx.smart.modules.model.request.SmartCarKeyTokenRequest
;
import
cn.com.glsx.smart.modules.model.request.SmartCarKeyUserRequest
;
import
cn.com.glsx.smart.modules.model.request.SmartKeyPrimaryShareEditReq
;
import
cn.com.glsx.smart.modules.model.request.SmartShareCarKeyPageRequest
;
import
cn.com.glsx.smart.modules.model.response.SmartCarKeyResponse
;
import
cn.com.glsx.smart.modules.service.AiLockingKeyService
;
import
cn.com.glsx.smart.modules.service.SmartKeyBlueSenseService
;
import
cn.com.glsx.smart.modules.service.SmartKeyCommandLogService
;
import
cn.com.glsx.smart.modules.service.SmartVehicleBlueKeyService
;
import
cn.com.glsx.smart.modules.service.SmartVehicleBlueShareKeyService
;
import
cn.hutool.core.date.DateUtil
;
import
cn.hutool.core.date.DateUtil
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.nacos.common.utils.CollectionUtils
;
import
com.alibaba.nacos.common.utils.CollectionUtils
;
...
@@ -22,9 +47,6 @@ import org.springframework.beans.BeanUtils;
...
@@ -22,9 +47,6 @@ import org.springframework.beans.BeanUtils;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
java.util.*
;
import
java.util.stream.Collectors
;
/**
/**
* <p>Description:智能车钥匙service
* <p>Description:智能车钥匙service
* <p>Project: chejia-smart
* <p>Project: chejia-smart
...
@@ -75,7 +97,7 @@ public class AiLockingKeyServiceImpl implements AiLockingKeyService {
...
@@ -75,7 +97,7 @@ public class AiLockingKeyServiceImpl implements AiLockingKeyService {
try
{
try
{
crep_encrypt
=
aesEncryptUtils
.
encrypt
(
crep
);
crep_encrypt
=
aesEncryptUtils
.
encrypt
(
crep
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
throw
new
BusinessException
(
ResultEnum
.
CAR_KEY_EXCEP_1
);
throw
ChejiaBusinessException
.
create
(
ResultEnum
.
CAR_KEY_EXCEP_1
);
}
}
//新增车钥匙
//新增车钥匙
...
@@ -92,7 +114,7 @@ public class AiLockingKeyServiceImpl implements AiLockingKeyService {
...
@@ -92,7 +114,7 @@ public class AiLockingKeyServiceImpl implements AiLockingKeyService {
//如果车钥匙有数据,但是crep为空字符串
//如果车钥匙有数据,但是crep为空字符串
if
(
StringUtils
.
isEmpty
(
crepCode
))
{
if
(
StringUtils
.
isEmpty
(
crepCode
))
{
throw
new
BusinessException
(
ResultEnum
.
CAR_KEY_EXCEP_10
);
throw
ChejiaBusinessException
.
create
(
ResultEnum
.
CAR_KEY_EXCEP_10
);
}
}
//如果车钥匙有对应的crep,返回钥匙信息
//如果车钥匙有对应的crep,返回钥匙信息
...
@@ -108,8 +130,9 @@ public class AiLockingKeyServiceImpl implements AiLockingKeyService {
...
@@ -108,8 +130,9 @@ public class AiLockingKeyServiceImpl implements AiLockingKeyService {
SmartVehicleBlueKeyExample
example
=
smartVehicleBlueKeyService
.
getBlueKeyExampleByUserAndSn
(
Long
.
valueOf
(
request
.
getUserId
()),
request
.
getSn
());
SmartVehicleBlueKeyExample
example
=
smartVehicleBlueKeyService
.
getBlueKeyExampleByUserAndSn
(
Long
.
valueOf
(
request
.
getUserId
()),
request
.
getSn
());
List
<
SmartVehicleBlueKey
>
keyList
=
smartVehicleBlueKeyService
.
selectByExample
(
example
);
List
<
SmartVehicleBlueKey
>
keyList
=
smartVehicleBlueKeyService
.
selectByExample
(
example
);
if
(
CollectionUtils
.
isEmpty
(
keyList
))
if
(
CollectionUtils
.
isEmpty
(
keyList
))
{
return
R
.
ok
();
return
R
.
ok
();
}
SmartVehicleBlueKey
blueKey
=
keyList
.
get
(
0
);
SmartVehicleBlueKey
blueKey
=
keyList
.
get
(
0
);
...
@@ -171,7 +194,7 @@ public class AiLockingKeyServiceImpl implements AiLockingKeyService {
...
@@ -171,7 +194,7 @@ public class AiLockingKeyServiceImpl implements AiLockingKeyService {
try
{
try
{
crep
=
aesEncryptUtils
.
decrypt
(
carKeyCommandRequest
.
getCrepCode
());
crep
=
aesEncryptUtils
.
decrypt
(
carKeyCommandRequest
.
getCrepCode
());
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
throw
new
BusinessException
(
ResultEnum
.
CAR_KEY_EXCEP_4
);
throw
ChejiaBusinessException
.
create
(
ResultEnum
.
CAR_KEY_EXCEP_4
);
}
}
//明文存储crep
//明文存储crep
logData
.
setCrepCode
(
crep
);
logData
.
setCrepCode
(
crep
);
...
@@ -243,9 +266,9 @@ public class AiLockingKeyServiceImpl implements AiLockingKeyService {
...
@@ -243,9 +266,9 @@ public class AiLockingKeyServiceImpl implements AiLockingKeyService {
return
exist
;
return
exist
;
});
});
if
(
IfExist
)
if
(
IfExist
)
{
return
R
.
error
(
"keyName重复,已存在"
);
return
R
.
error
(
"keyName重复,已存在"
);
else
{
}
else
{
for
(
SmartVehicleBlueKey
blueKey
:
keyList
)
{
for
(
SmartVehicleBlueKey
blueKey
:
keyList
)
{
//更新该设备的名称
//更新该设备的名称
if
(
sn
.
equals
(
blueKey
.
getSn
())
&&
!
keyName
.
equals
(
blueKey
.
getKeyName
()))
{
if
(
sn
.
equals
(
blueKey
.
getSn
())
&&
!
keyName
.
equals
(
blueKey
.
getKeyName
()))
{
...
@@ -339,7 +362,7 @@ public class AiLockingKeyServiceImpl implements AiLockingKeyService {
...
@@ -339,7 +362,7 @@ public class AiLockingKeyServiceImpl implements AiLockingKeyService {
secretKey
=
aesEncryptUtils
.
decryptSecret
(
secretKey_db
);
secretKey
=
aesEncryptUtils
.
decryptSecret
(
secretKey_db
);
}
}
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
throw
new
BusinessException
(
ResultEnum
.
CAR_KEY_EXCEP_12
);
throw
ChejiaBusinessException
.
create
(
ResultEnum
.
CAR_KEY_EXCEP_12
);
}
}
String
crepCode
=
key
.
getCrepCode
();
String
crepCode
=
key
.
getCrepCode
();
...
@@ -352,7 +375,7 @@ public class AiLockingKeyServiceImpl implements AiLockingKeyService {
...
@@ -352,7 +375,7 @@ public class AiLockingKeyServiceImpl implements AiLockingKeyService {
secret_key_encrypt
=
aesEncryptUtils
.
encrypt
(
secretKey
);
secret_key_encrypt
=
aesEncryptUtils
.
encrypt
(
secretKey
);
}
}
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
throw
new
BusinessException
(
ResultEnum
.
CAR_KEY_EXCEP_13
);
throw
ChejiaBusinessException
.
create
(
ResultEnum
.
CAR_KEY_EXCEP_13
);
}
}
//拷贝属性
//拷贝属性
...
@@ -442,7 +465,7 @@ public class AiLockingKeyServiceImpl implements AiLockingKeyService {
...
@@ -442,7 +465,7 @@ public class AiLockingKeyServiceImpl implements AiLockingKeyService {
crep
=
aesEncryptUtils
.
decrypt
(
request
.
getCrepCode
());
crep
=
aesEncryptUtils
.
decrypt
(
request
.
getCrepCode
());
keySecret
=
aesEncryptUtils
.
decrypt
(
request
.
getSecretKey
());
keySecret
=
aesEncryptUtils
.
decrypt
(
request
.
getSecretKey
());
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
throw
new
BusinessException
(
ResultEnum
.
CAR_KEY_EXCEP_5
);
throw
ChejiaBusinessException
.
create
(
ResultEnum
.
CAR_KEY_EXCEP_5
);
}
}
//将密钥明文加密后存入数据库
//将密钥明文加密后存入数据库
...
@@ -452,7 +475,7 @@ public class AiLockingKeyServiceImpl implements AiLockingKeyService {
...
@@ -452,7 +475,7 @@ public class AiLockingKeyServiceImpl implements AiLockingKeyService {
try
{
try
{
secretKey_db
=
aesEncryptUtils
.
encryptSecret
(
keySecret
);
secretKey_db
=
aesEncryptUtils
.
encryptSecret
(
keySecret
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
throw
new
BusinessException
(
ResultEnum
.
CAR_KEY_EXCEP_7
);
throw
ChejiaBusinessException
.
create
(
ResultEnum
.
CAR_KEY_EXCEP_7
);
}
}
}
}
//查询车钥匙
//查询车钥匙
...
@@ -465,7 +488,7 @@ public class AiLockingKeyServiceImpl implements AiLockingKeyService {
...
@@ -465,7 +488,7 @@ public class AiLockingKeyServiceImpl implements AiLockingKeyService {
//车钥匙不存在
//车钥匙不存在
if
(
CollectionUtils
.
isEmpty
(
smartVehicleBlueKeyList
))
{
if
(
CollectionUtils
.
isEmpty
(
smartVehicleBlueKeyList
))
{
throw
new
BusinessException
(
ResultEnum
.
CAR_KEY_EXCEP_3
);
throw
ChejiaBusinessException
.
create
(
ResultEnum
.
CAR_KEY_EXCEP_3
);
}
}
SmartVehicleBlueKey
smartVehicleBlueKey
=
smartVehicleBlueKeyList
.
get
(
0
);
SmartVehicleBlueKey
smartVehicleBlueKey
=
smartVehicleBlueKeyList
.
get
(
0
);
...
@@ -504,7 +527,7 @@ public class AiLockingKeyServiceImpl implements AiLockingKeyService {
...
@@ -504,7 +527,7 @@ public class AiLockingKeyServiceImpl implements AiLockingKeyService {
smartKeyBlueSenseService
.
updateByPrimaryKeySelective
(
blueSense
);
smartKeyBlueSenseService
.
updateByPrimaryKeySelective
(
blueSense
);
}
}
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
throw
new
BusinessException
(
ResultEnum
.
CAR_KEY_EXCEP_9
);
throw
ChejiaBusinessException
.
create
(
ResultEnum
.
CAR_KEY_EXCEP_9
);
}
}
...
@@ -551,7 +574,7 @@ public class AiLockingKeyServiceImpl implements AiLockingKeyService {
...
@@ -551,7 +574,7 @@ public class AiLockingKeyServiceImpl implements AiLockingKeyService {
//保存车钥匙
//保存车钥匙
smartVehicleBlueKeyService
.
insert
(
newKey
);
smartVehicleBlueKeyService
.
insert
(
newKey
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
throw
new
BusinessException
(
ResultEnum
.
CAR_KEY_EXCEP_8
);
throw
ChejiaBusinessException
.
create
(
ResultEnum
.
CAR_KEY_EXCEP_8
);
}
}
//拷贝属性,crep用密文传输
//拷贝属性,crep用密文传输
...
@@ -568,7 +591,7 @@ public class AiLockingKeyServiceImpl implements AiLockingKeyService {
...
@@ -568,7 +591,7 @@ public class AiLockingKeyServiceImpl implements AiLockingKeyService {
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
String
error_msg
=
"智能车钥匙查询,secretKey解密异常,crep存在:"
+
crepExist
+
",crep:"
+
crepCode
;
String
error_msg
=
"智能车钥匙查询,secretKey解密异常,crep存在:"
+
crepExist
+
",crep:"
+
crepCode
;
log
.
info
(
error_msg
);
log
.
info
(
error_msg
);
throw
new
BusinessException
(
ResultEnum
.
CAR_KEY_EXCEP_6
);
throw
ChejiaBusinessException
.
create
(
ResultEnum
.
CAR_KEY_EXCEP_6
);
}
}
}
}
...
@@ -584,7 +607,7 @@ public class AiLockingKeyServiceImpl implements AiLockingKeyService {
...
@@ -584,7 +607,7 @@ public class AiLockingKeyServiceImpl implements AiLockingKeyService {
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
String
error_msg
=
"智能车钥匙查询加密异常,crep存在:"
+
crepExist
+
",crep:"
+
crepCode
;
String
error_msg
=
"智能车钥匙查询加密异常,crep存在:"
+
crepExist
+
",crep:"
+
crepCode
;
log
.
info
(
error_msg
);
log
.
info
(
error_msg
);
throw
new
BusinessException
(
ResultEnum
.
CAR_KEY_EXCEP_2
);
throw
ChejiaBusinessException
.
create
(
ResultEnum
.
CAR_KEY_EXCEP_2
);
}
}
BeanUtils
.
copyProperties
(
carkey
,
response
);
BeanUtils
.
copyProperties
(
carkey
,
response
);
...
...
src/main/java/cn/com/glsx/smart/modules/service/impl/AiLockingKeyShareServiceImpl.java
View file @
372c313
package
cn
.
com
.
glsx
.
smart
.
modules
.
service
.
impl
;
package
cn
.
com
.
glsx
.
smart
.
modules
.
service
.
impl
;
import
cn.com.glsx.smart.modules.entity.*
;
import
java.text.ParseException
;
import
cn.com.glsx.smart.common.exception.BusinessException
;
import
java.text.SimpleDateFormat
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
cn.com.glsx.smart.common.exception.ChejiaBusinessException
;
import
cn.com.glsx.smart.common.exception.ResultEnum
;
import
cn.com.glsx.smart.common.exception.ResultEnum
;
import
cn.com.glsx.smart.common.redis.RedisService
;
import
cn.com.glsx.smart.common.utils.AesEncryptUtils
;
import
cn.com.glsx.smart.common.utils.JwtUtil
;
import
cn.com.glsx.smart.modules.entity.SmartKeyCommandShareLog
;
import
cn.com.glsx.smart.modules.entity.SmartShareKeyBlueKey
;
import
cn.com.glsx.smart.modules.entity.SmartVehicleBlueKey
;
import
cn.com.glsx.smart.modules.entity.SmartVehicleBlueShareKey
;
import
cn.com.glsx.smart.modules.entity.SmartVehicleBlueShareKeyExample
;
import
cn.com.glsx.smart.modules.model.request.SmartCarKeyReceiveRequest
;
import
cn.com.glsx.smart.modules.model.request.SmartCarKeyReceiveRequest
;
import
cn.com.glsx.smart.modules.model.request.SmartCarKeyShareActionLogBatchRequest
;
import
cn.com.glsx.smart.modules.model.request.SmartCarKeyShareActionLogBatchRequest
;
import
cn.com.glsx.smart.modules.model.request.SmartCarKeyShareLogRequest
;
import
cn.com.glsx.smart.modules.model.request.SmartCarKeyShareLogRequest
;
import
cn.com.glsx.smart.modules.model.request.SmartShareKeyEditReq
;
import
cn.com.glsx.smart.modules.model.request.SmartShareKeyEditReq
;
import
cn.com.glsx.smart.common.redis.RedisService
;
import
cn.com.glsx.smart.modules.service.AiLockingKeyShareService
;
import
cn.com.glsx.smart.modules.service.AiLockingKeyShareService
;
import
cn.com.glsx.smart.modules.service.SmartKeyCommandShareLogService
;
import
cn.com.glsx.smart.modules.service.SmartKeyCommandShareLogService
;
import
cn.com.glsx.smart.modules.service.SmartVehicleBlueKeyService
;
import
cn.com.glsx.smart.modules.service.SmartVehicleBlueKeyService
;
import
cn.com.glsx.smart.modules.service.SmartVehicleBlueShareKeyService
;
import
cn.com.glsx.smart.modules.service.SmartVehicleBlueShareKeyService
;
import
cn.com.glsx.smart.common.utils.AesEncryptUtils
;
import
cn.com.glsx.smart.common.utils.JwtUtil
;
import
cn.hutool.core.date.DateUtil
;
import
cn.hutool.core.date.DateUtil
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.nacos.common.utils.StringUtils
;
import
com.alibaba.nacos.common.utils.StringUtils
;
...
@@ -26,10 +37,6 @@ import org.apache.dubbo.common.utils.Assert;
...
@@ -26,10 +37,6 @@ import org.apache.dubbo.common.utils.Assert;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
java.text.ParseException
;
import
java.text.SimpleDateFormat
;
import
java.util.*
;
/**
/**
* <p>Description:智能车钥匙service
* <p>Description:智能车钥匙service
* <p>Project: chejia-smart
* <p>Project: chejia-smart
...
@@ -83,8 +90,9 @@ public class AiLockingKeyShareServiceImpl implements AiLockingKeyShareService {
...
@@ -83,8 +90,9 @@ public class AiLockingKeyShareServiceImpl implements AiLockingKeyShareService {
SmartVehicleBlueKey
key
=
keyList
.
get
(
0
);
SmartVehicleBlueKey
key
=
keyList
.
get
(
0
);
//将数据库密钥解密成明文
//将数据库密钥解密成明文
List
<
String
>
arr
=
encryptKey
(
key
.
getCrepCode
(),
key
.
getSecretKey
());
List
<
String
>
arr
=
encryptKey
(
key
.
getCrepCode
(),
key
.
getSecretKey
());
if
(
CollectionUtils
.
isEmpty
(
arr
)
||
arr
.
size
()
!=
2
)
if
(
CollectionUtils
.
isEmpty
(
arr
)
||
arr
.
size
()
!=
2
)
{
return
R
.
error
(
"钥匙信息不完整"
);
return
R
.
error
(
"钥匙信息不完整"
);
}
key
.
setCrepCode
(
arr
.
get
(
0
));
key
.
setCrepCode
(
arr
.
get
(
0
));
key
.
setSecretKey
(
arr
.
get
(
1
));
key
.
setSecretKey
(
arr
.
get
(
1
));
...
@@ -107,7 +115,7 @@ public class AiLockingKeyShareServiceImpl implements AiLockingKeyShareService {
...
@@ -107,7 +115,7 @@ public class AiLockingKeyShareServiceImpl implements AiLockingKeyShareService {
//setnx,只允许一个人领取钥匙
//setnx,只允许一个人领取钥匙
boolean
res
=
redisService
.
setnx
(
"receive_share_key:"
+
token
,
userId
);
boolean
res
=
redisService
.
setnx
(
"receive_share_key:"
+
token
,
userId
);
if
(!
res
)
{
if
(!
res
)
{
throw
new
BusinessException
(
ResultEnum
.
CAR_KEY_EXCEP_14
);
throw
ChejiaBusinessException
.
create
(
ResultEnum
.
CAR_KEY_EXCEP_14
);
}
}
//已领取
//已领取
...
@@ -185,13 +193,15 @@ public class AiLockingKeyShareServiceImpl implements AiLockingKeyShareService {
...
@@ -185,13 +193,15 @@ public class AiLockingKeyShareServiceImpl implements AiLockingKeyShareService {
public
R
getShareLockingKey
(
String
keyid
)
{
public
R
getShareLockingKey
(
String
keyid
)
{
List
<
SmartShareKeyBlueKey
>
keyList
=
shareKeyService
.
getShareKeyListByKeyId
(
Long
.
valueOf
(
keyid
));
List
<
SmartShareKeyBlueKey
>
keyList
=
shareKeyService
.
getShareKeyListByKeyId
(
Long
.
valueOf
(
keyid
));
if
(
CollectionUtils
.
isEmpty
(
keyList
))
if
(
CollectionUtils
.
isEmpty
(
keyList
))
{
return
R
.
ok
().
data
(
null
);
return
R
.
ok
().
data
(
null
);
}
SmartShareKeyBlueKey
key
=
keyList
.
get
(
0
);
SmartShareKeyBlueKey
key
=
keyList
.
get
(
0
);
List
<
String
>
arr
=
encryptKey
(
key
.
getCrepCode
(),
key
.
getSecretKey
());
List
<
String
>
arr
=
encryptKey
(
key
.
getCrepCode
(),
key
.
getSecretKey
());
if
(
CollectionUtils
.
isEmpty
(
arr
)
||
arr
.
size
()
!=
2
)
if
(
CollectionUtils
.
isEmpty
(
arr
)
||
arr
.
size
()
!=
2
)
{
return
R
.
error
(
"钥匙信息不完整"
);
return
R
.
error
(
"钥匙信息不完整"
);
}
key
.
setCrepCode
(
arr
.
get
(
0
));
key
.
setCrepCode
(
arr
.
get
(
0
));
key
.
setSecretKey
(
arr
.
get
(
1
));
key
.
setSecretKey
(
arr
.
get
(
1
));
...
@@ -215,8 +225,9 @@ public class AiLockingKeyShareServiceImpl implements AiLockingKeyShareService {
...
@@ -215,8 +225,9 @@ public class AiLockingKeyShareServiceImpl implements AiLockingKeyShareService {
keys
.
stream
().
forEach
(
key
->
{
keys
.
stream
().
forEach
(
key
->
{
//将数据库密钥解密成明文
//将数据库密钥解密成明文
List
<
String
>
arr
=
encryptKey
(
key
.
getCrepCode
(),
key
.
getSecretKey
());
List
<
String
>
arr
=
encryptKey
(
key
.
getCrepCode
(),
key
.
getSecretKey
());
if
(
CollectionUtils
.
isEmpty
(
arr
)
||
arr
.
size
()
!=
2
)
if
(
CollectionUtils
.
isEmpty
(
arr
)
||
arr
.
size
()
!=
2
)
{
throw
new
BusinessException
(
ResultEnum
.
CAR_KEY_EXCEP_21
);
throw
ChejiaBusinessException
.
create
(
ResultEnum
.
CAR_KEY_EXCEP_21
);
}
key
.
setCrepCode
(
arr
.
get
(
0
));
key
.
setCrepCode
(
arr
.
get
(
0
));
key
.
setSecretKey
(
arr
.
get
(
1
));
key
.
setSecretKey
(
arr
.
get
(
1
));
...
@@ -232,7 +243,7 @@ public class AiLockingKeyShareServiceImpl implements AiLockingKeyShareService {
...
@@ -232,7 +243,7 @@ public class AiLockingKeyShareServiceImpl implements AiLockingKeyShareService {
List
<
SmartVehicleBlueKey
>
keyList
=
blueKeyService
.
selectById
(
keyid
);
List
<
SmartVehicleBlueKey
>
keyList
=
blueKeyService
.
selectById
(
keyid
);
if
(
CollectionUtils
.
isEmpty
(
keyList
))
{
if
(
CollectionUtils
.
isEmpty
(
keyList
))
{
throw
new
BusinessException
(
ResultEnum
.
CAR_KEY_EXCEP_19
);
throw
ChejiaBusinessException
.
create
(
ResultEnum
.
CAR_KEY_EXCEP_19
);
}
}
SmartVehicleBlueKey
blueKey
=
keyList
.
get
(
0
);
SmartVehicleBlueKey
blueKey
=
keyList
.
get
(
0
);
...
@@ -243,13 +254,13 @@ public class AiLockingKeyShareServiceImpl implements AiLockingKeyShareService {
...
@@ -243,13 +254,13 @@ public class AiLockingKeyShareServiceImpl implements AiLockingKeyShareService {
//主钥匙是否信息完整
//主钥匙是否信息完整
if
(
StringUtils
.
isBlank
(
crepCode
)
||
StringUtils
.
isBlank
(
secretKey
)
||
StringUtils
.
isBlank
(
smartLockMac
))
{
if
(
StringUtils
.
isBlank
(
crepCode
)
||
StringUtils
.
isBlank
(
secretKey
)
||
StringUtils
.
isBlank
(
smartLockMac
))
{
throw
new
BusinessException
(
ResultEnum
.
CAR_KEY_EXCEP_21
);
throw
ChejiaBusinessException
.
create
(
ResultEnum
.
CAR_KEY_EXCEP_21
);
}
}
//主钥匙是否关闭分享
//主钥匙是否关闭分享
int
status
=
blueKey
.
getShareStatus
();
int
status
=
blueKey
.
getShareStatus
();
if
(
status
==
0
)
{
if
(
status
==
0
)
{
throw
new
BusinessException
(
ResultEnum
.
CAR_KEY_EXCEP_20
);
throw
ChejiaBusinessException
.
create
(
ResultEnum
.
CAR_KEY_EXCEP_20
);
}
}
...
@@ -257,7 +268,7 @@ public class AiLockingKeyShareServiceImpl implements AiLockingKeyShareService {
...
@@ -257,7 +268,7 @@ public class AiLockingKeyShareServiceImpl implements AiLockingKeyShareService {
boolean
isReceive
=
isKeyReceive
(
keyShareID
);
boolean
isReceive
=
isKeyReceive
(
keyShareID
);
if
(
isReceive
)
{
if
(
isReceive
)
{
throw
new
BusinessException
(
ResultEnum
.
CAR_KEY_EXCEP_14
);
throw
ChejiaBusinessException
.
create
(
ResultEnum
.
CAR_KEY_EXCEP_14
);
}
}
//校验过期时间
//校验过期时间
...
@@ -267,7 +278,7 @@ public class AiLockingKeyShareServiceImpl implements AiLockingKeyShareService {
...
@@ -267,7 +278,7 @@ public class AiLockingKeyShareServiceImpl implements AiLockingKeyShareService {
SmartVehicleBlueShareKey
shareKey
=
shareKeyService
.
selectByPrimaryKey
(
keyShareID
);
SmartVehicleBlueShareKey
shareKey
=
shareKeyService
.
selectByPrimaryKey
(
keyShareID
);
if
(
null
==
shareKey
)
{
if
(
null
==
shareKey
)
{
throw
new
BusinessException
(
ResultEnum
.
CAR_KEY_EXCEP_15
);
throw
ChejiaBusinessException
.
create
(
ResultEnum
.
CAR_KEY_EXCEP_15
);
}
}
Date
expireDate
=
shareKey
.
getExpireTime
();
Date
expireDate
=
shareKey
.
getExpireTime
();
...
@@ -277,11 +288,12 @@ public class AiLockingKeyShareServiceImpl implements AiLockingKeyShareService {
...
@@ -277,11 +288,12 @@ public class AiLockingKeyShareServiceImpl implements AiLockingKeyShareService {
nowDate
=
sdf
.
parse
(
nowTime
);
nowDate
=
sdf
.
parse
(
nowTime
);
}
catch
(
ParseException
e
)
{
}
catch
(
ParseException
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
throw
new
BusinessException
(
ResultEnum
.
CAR_KEY_EXCEP_15
);
throw
ChejiaBusinessException
.
create
(
ResultEnum
.
CAR_KEY_EXCEP_15
);
}
}
if
(
nowDate
.
after
(
expireDate
))
if
(
nowDate
.
after
(
expireDate
))
{
throw
new
BusinessException
(
ResultEnum
.
CAR_KEY_EXCEP_16
);
throw
ChejiaBusinessException
.
create
(
ResultEnum
.
CAR_KEY_EXCEP_16
);
}
return
shareKey
;
return
shareKey
;
}
}
...
@@ -291,9 +303,9 @@ public class AiLockingKeyShareServiceImpl implements AiLockingKeyShareService {
...
@@ -291,9 +303,9 @@ public class AiLockingKeyShareServiceImpl implements AiLockingKeyShareService {
try
{
try
{
claims
=
jwtUtil
.
getClaimsFromToken
(
token
);
claims
=
jwtUtil
.
getClaimsFromToken
(
token
);
}
catch
(
ExpiredJwtException
e
)
{
}
catch
(
ExpiredJwtException
e
)
{
throw
new
BusinessException
(
ResultEnum
.
CAR_KEY_EXCEP_18
);
throw
ChejiaBusinessException
.
create
(
ResultEnum
.
CAR_KEY_EXCEP_18
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
throw
new
BusinessException
(
ResultEnum
.
CAR_KEY_EXCEP_17
);
throw
ChejiaBusinessException
.
create
(
ResultEnum
.
CAR_KEY_EXCEP_17
);
}
}
return
claims
;
return
claims
;
}
}
...
@@ -308,7 +320,7 @@ public class AiLockingKeyShareServiceImpl implements AiLockingKeyShareService {
...
@@ -308,7 +320,7 @@ public class AiLockingKeyShareServiceImpl implements AiLockingKeyShareService {
secretKey
=
aesEncryptUtils
.
decryptSecret
(
secretKey_db
);
secretKey
=
aesEncryptUtils
.
decryptSecret
(
secretKey_db
);
}
}
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
throw
new
BusinessException
(
ResultEnum
.
CAR_KEY_EXCEP_12
);
throw
ChejiaBusinessException
.
create
(
ResultEnum
.
CAR_KEY_EXCEP_12
);
}
}
...
@@ -326,7 +338,7 @@ public class AiLockingKeyShareServiceImpl implements AiLockingKeyShareService {
...
@@ -326,7 +338,7 @@ public class AiLockingKeyShareServiceImpl implements AiLockingKeyShareService {
arr
.
add
(
secret_key_encrypt
);
arr
.
add
(
secret_key_encrypt
);
}
}
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
throw
new
BusinessException
(
ResultEnum
.
CAR_KEY_EXCEP_13
);
throw
ChejiaBusinessException
.
create
(
ResultEnum
.
CAR_KEY_EXCEP_13
);
}
}
return
arr
;
return
arr
;
...
...
src/main/java/cn/com/glsx/smart/modules/service/impl/SmartProductServiceImpl.java
View file @
372c313
package
cn
.
com
.
glsx
.
smart
.
modules
.
service
.
impl
;
package
cn
.
com
.
glsx
.
smart
.
modules
.
service
.
impl
;
import
javax.annotation.Resource
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.stream.Collectors
;
import
cn.com.glsx.smart.common.constant.Constants
;
import
cn.com.glsx.smart.common.constant.Constants
;
import
cn.com.glsx.smart.common.enums.DeviceChannelEnum
;
import
cn.com.glsx.smart.common.enums.DeviceChannelEnum
;
import
cn.com.glsx.smart.common.exception.ChejiaBusinessException
;
import
cn.com.glsx.smart.common.exception.ResultEnum
;
import
cn.com.glsx.smart.modules.entity.SmartDeviceOrder
;
import
cn.com.glsx.smart.modules.entity.SmartDeviceOrder
;
import
cn.com.glsx.smart.modules.entity.SmartProduct
;
import
cn.com.glsx.smart.modules.entity.SmartProduct
;
import
cn.com.glsx.smart.modules.entity.SmartSysCode
;
import
cn.com.glsx.smart.modules.entity.SmartSysCode
;
import
cn.com.glsx.smart.modules.mapper.SmartDeviceOrderMapper
;
import
cn.com.glsx.smart.modules.mapper.SmartDeviceOrderMapper
;
import
cn.com.glsx.smart.modules.mapper.SmartProductMapper
;
import
cn.com.glsx.smart.modules.mapper.SmartProductMapper
;
import
cn.com.glsx.smart.modules.mapper.SmartSysCodeMapper
;
import
cn.com.glsx.smart.modules.mapper.SmartSysCodeMapper
;
import
cn.com.glsx.smart.common.exception.BusinessException
;
import
cn.com.glsx.smart.common.exception.ResultEnum
;
import
cn.com.glsx.smart.modules.service.BaseService
;
import
cn.com.glsx.smart.modules.service.BaseService
;
import
cn.com.glsx.smart.modules.service.SmartProductService
;
import
cn.com.glsx.smart.modules.service.SmartProductService
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONArray
;
...
@@ -21,12 +26,6 @@ import org.springframework.beans.factory.annotation.Autowired;
...
@@ -21,12 +26,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.transaction.annotation.Transactional
;
import
javax.annotation.Resource
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.stream.Collectors
;
/**
/**
* <p>Description: 产品列表业务
* <p>Description: 产品列表业务
* <p>Project: chejia-smart
* <p>Project: chejia-smart
...
@@ -84,7 +83,7 @@ public class SmartProductServiceImpl extends BaseService implements SmartProduct
...
@@ -84,7 +83,7 @@ public class SmartProductServiceImpl extends BaseService implements SmartProduct
public
SmartProduct
getById
(
Long
id
)
{
public
SmartProduct
getById
(
Long
id
)
{
SmartProduct
product
=
productMapper
.
getById
(
id
);
SmartProduct
product
=
productMapper
.
getById
(
id
);
if
(
product
==
null
)
{
if
(
product
==
null
)
{
throw
new
BusinessException
(
ResultEnum
.
PRODUCT_NOT_FOUND
);
throw
ChejiaBusinessException
.
create
(
ResultEnum
.
PRODUCT_NOT_FOUND
);
}
}
return
product
;
return
product
;
}
}
...
@@ -177,7 +176,7 @@ public class SmartProductServiceImpl extends BaseService implements SmartProduct
...
@@ -177,7 +176,7 @@ public class SmartProductServiceImpl extends BaseService implements SmartProduct
if
(
product
.
getId
()
==
null
)
{
if
(
product
.
getId
()
==
null
)
{
int
nameCount
=
productMapper
.
countByProductName
(
product
.
getProductName
());
int
nameCount
=
productMapper
.
countByProductName
(
product
.
getProductName
());
if
(
nameCount
>
0
)
{
if
(
nameCount
>
0
)
{
throw
new
BusinessException
(
ResultEnum
.
PRODUCT_NAME_DUPLICATE
);
throw
ChejiaBusinessException
.
create
(
ResultEnum
.
PRODUCT_NAME_DUPLICATE
);
}
}
product
.
setCreateTime
(
now
);
product
.
setCreateTime
(
now
);
product
.
setCreateBy
(
0L
);
product
.
setCreateBy
(
0L
);
...
@@ -187,7 +186,7 @@ public class SmartProductServiceImpl extends BaseService implements SmartProduct
...
@@ -187,7 +186,7 @@ public class SmartProductServiceImpl extends BaseService implements SmartProduct
if
(
record
!=
null
)
{
if
(
record
!=
null
)
{
success
=
productMapper
.
updateByPrimaryKeySelective
(
product
)
>
0
;
success
=
productMapper
.
updateByPrimaryKeySelective
(
product
)
>
0
;
}
else
{
}
else
{
throw
new
BusinessException
(
ResultEnum
.
PRODUCT_NOT_FOUND
);
throw
ChejiaBusinessException
.
create
(
ResultEnum
.
PRODUCT_NOT_FOUND
);
}
}
}
}
...
@@ -224,7 +223,7 @@ public class SmartProductServiceImpl extends BaseService implements SmartProduct
...
@@ -224,7 +223,7 @@ public class SmartProductServiceImpl extends BaseService implements SmartProduct
boolean
success
;
boolean
success
;
SmartProduct
product
=
productMapper
.
selectByPrimaryKey
(
id
);
SmartProduct
product
=
productMapper
.
selectByPrimaryKey
(
id
);
if
(
product
==
null
)
{
if
(
product
==
null
)
{
throw
new
BusinessException
(
ResultEnum
.
PRODUCT_NOT_FOUND
);
throw
ChejiaBusinessException
.
create
(
ResultEnum
.
PRODUCT_NOT_FOUND
);
}
}
product
.
setStatus
((
byte
)
(
product
.
getStatus
()
^
0b00000001
));
product
.
setStatus
((
byte
)
(
product
.
getStatus
()
^
0b00000001
));
success
=
productMapper
.
updateByPrimaryKeySelective
(
product
)
>
0
;
success
=
productMapper
.
updateByPrimaryKeySelective
(
product
)
>
0
;
...
...
src/main/java/cn/com/glsx/smart/modules/service/impl/SmartProductTypeServiceImpl.java
View file @
372c313
package
cn
.
com
.
glsx
.
smart
.
modules
.
service
.
impl
;
package
cn
.
com
.
glsx
.
smart
.
modules
.
service
.
impl
;
import
javax.annotation.Resource
;
import
java.util.ArrayList
;
import
java.util.Comparator
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.stream.Collectors
;
import
cn.com.glsx.smart.common.constant.Constants
;
import
cn.com.glsx.smart.common.constant.Constants
;
import
cn.com.glsx.smart.common.exception.ChejiaBusinessException
;
import
cn.com.glsx.smart.common.exception.ResultEnum
;
import
cn.com.glsx.smart.modules.entity.SmartProduct
;
import
cn.com.glsx.smart.modules.entity.SmartProduct
;
import
cn.com.glsx.smart.modules.entity.SmartProductType
;
import
cn.com.glsx.smart.modules.entity.SmartProductType
;
import
cn.com.glsx.smart.modules.entity.SmartUserDevice
;
import
cn.com.glsx.smart.modules.entity.SmartUserDevice
;
import
cn.com.glsx.smart.modules.mapper.SmartProductMapper
;
import
cn.com.glsx.smart.modules.mapper.SmartProductMapper
;
import
cn.com.glsx.smart.modules.mapper.SmartProductTypeMapper
;
import
cn.com.glsx.smart.modules.mapper.SmartProductTypeMapper
;
import
cn.com.glsx.smart.modules.mapper.SmartUserDeviceMapper
;
import
cn.com.glsx.smart.modules.mapper.SmartUserDeviceMapper
;
import
cn.com.glsx.smart.common.exception.BusinessException
;
import
cn.com.glsx.smart.common.exception.ResultEnum
;
import
cn.com.glsx.smart.modules.model.response.RemoteDeviceResp
;
import
cn.com.glsx.smart.modules.model.response.RemoteDeviceResp
;
import
cn.com.glsx.smart.modules.service.BaseService
;
import
cn.com.glsx.smart.modules.service.BaseService
;
import
cn.com.glsx.smart.modules.service.SmartProductTypeService
;
import
cn.com.glsx.smart.modules.service.SmartProductTypeService
;
...
@@ -21,10 +29,6 @@ import org.springframework.beans.factory.annotation.Value;
...
@@ -21,10 +29,6 @@ import org.springframework.beans.factory.annotation.Value;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.transaction.annotation.Transactional
;
import
javax.annotation.Resource
;
import
java.util.*
;
import
java.util.stream.Collectors
;
/**
/**
* <p>Description: 产品类型业务
* <p>Description: 产品类型业务
* <p>Project: chejia-smart
* <p>Project: chejia-smart
...
@@ -86,7 +90,7 @@ public class SmartProductTypeServiceImpl extends BaseService implements SmartPro
...
@@ -86,7 +90,7 @@ public class SmartProductTypeServiceImpl extends BaseService implements SmartPro
public
SmartProductType
getById
(
Long
id
)
{
public
SmartProductType
getById
(
Long
id
)
{
SmartProductType
productType
=
productTypeMapper
.
getById
(
id
);
SmartProductType
productType
=
productTypeMapper
.
getById
(
id
);
if
(
productType
==
null
)
{
if
(
productType
==
null
)
{
throw
new
BusinessException
(
ResultEnum
.
PRODUCT_TYPE_NOT_FOUND
);
throw
ChejiaBusinessException
.
create
(
ResultEnum
.
PRODUCT_TYPE_NOT_FOUND
);
}
}
return
productType
;
return
productType
;
}
}
...
@@ -108,7 +112,7 @@ public class SmartProductTypeServiceImpl extends BaseService implements SmartPro
...
@@ -108,7 +112,7 @@ public class SmartProductTypeServiceImpl extends BaseService implements SmartPro
if
(
productType
.
getId
()
==
null
)
{
if
(
productType
.
getId
()
==
null
)
{
int
nameCount
=
productTypeMapper
.
countByProductTypeName
(
productType
.
getTypeName
());
int
nameCount
=
productTypeMapper
.
countByProductTypeName
(
productType
.
getTypeName
());
if
(
nameCount
>
0
)
{
if
(
nameCount
>
0
)
{
throw
new
BusinessException
(
ResultEnum
.
PRODUCT_TYPE_NAME_DUPLICATE
);
throw
ChejiaBusinessException
.
create
(
ResultEnum
.
PRODUCT_TYPE_NAME_DUPLICATE
);
}
}
productType
.
setCreateTime
(
now
);
productType
.
setCreateTime
(
now
);
productType
.
setCreateBy
(
0L
);
productType
.
setCreateBy
(
0L
);
...
@@ -118,7 +122,7 @@ public class SmartProductTypeServiceImpl extends BaseService implements SmartPro
...
@@ -118,7 +122,7 @@ public class SmartProductTypeServiceImpl extends BaseService implements SmartPro
if
(
record
!=
null
)
{
if
(
record
!=
null
)
{
success
=
productTypeMapper
.
updateByPrimaryKeySelective
(
productType
)
>
0
;
success
=
productTypeMapper
.
updateByPrimaryKeySelective
(
productType
)
>
0
;
}
else
{
}
else
{
throw
new
BusinessException
(
ResultEnum
.
PRODUCT_TYPE_NOT_FOUND
);
throw
ChejiaBusinessException
.
create
(
ResultEnum
.
PRODUCT_TYPE_NOT_FOUND
);
}
}
}
}
...
...
src/main/java/cn/com/glsx/smart/modules/service/impl/SmartSceneDataServiceImpl.java
View file @
372c313
package
cn
.
com
.
glsx
.
smart
.
modules
.
service
.
impl
;
package
cn
.
com
.
glsx
.
smart
.
modules
.
service
.
impl
;
import
javax.annotation.Resource
;
import
java.util.List
;
import
cn.com.glsx.smart.common.constant.Constants
;
import
cn.com.glsx.smart.common.constant.Constants
;
import
cn.com.glsx.smart.common.exception.ChejiaBusinessException
;
import
cn.com.glsx.smart.common.exception.ResultEnum
;
import
cn.com.glsx.smart.modules.entity.SmartDeviceOrder
;
import
cn.com.glsx.smart.modules.entity.SmartDeviceOrder
;
import
cn.com.glsx.smart.modules.entity.SmartDeviceOrdervalue
;
import
cn.com.glsx.smart.modules.entity.SmartDeviceOrdervalue
;
import
cn.com.glsx.smart.modules.entity.SmartScenceSupstatus
;
import
cn.com.glsx.smart.modules.entity.SmartScenceSupstatus
;
...
@@ -9,8 +13,6 @@ import cn.com.glsx.smart.modules.mapper.SmartDeviceOrderMapper;
...
@@ -9,8 +13,6 @@ import cn.com.glsx.smart.modules.mapper.SmartDeviceOrderMapper;
import
cn.com.glsx.smart.modules.mapper.SmartDeviceOrdervalueMapper
;
import
cn.com.glsx.smart.modules.mapper.SmartDeviceOrdervalueMapper
;
import
cn.com.glsx.smart.modules.mapper.SmartScenceSupstatusMapper
;
import
cn.com.glsx.smart.modules.mapper.SmartScenceSupstatusMapper
;
import
cn.com.glsx.smart.modules.mapper.SmartSceneDataMapper
;
import
cn.com.glsx.smart.modules.mapper.SmartSceneDataMapper
;
import
cn.com.glsx.smart.common.exception.BusinessException
;
import
cn.com.glsx.smart.common.exception.ResultEnum
;
import
cn.com.glsx.smart.modules.service.SmartSceneDataService
;
import
cn.com.glsx.smart.modules.service.SmartSceneDataService
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
...
@@ -18,9 +20,6 @@ import com.glsx.plat.common.utils.StringUtils;
...
@@ -18,9 +20,6 @@ import com.glsx.plat.common.utils.StringUtils;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
javax.annotation.Resource
;
import
java.util.List
;
/**
/**
* <p>Description:
* <p>Description:
* <p>Project: chejia-smart
* <p>Project: chejia-smart
...
@@ -58,7 +57,7 @@ public class SmartSceneDataServiceImpl implements SmartSceneDataService {
...
@@ -58,7 +57,7 @@ public class SmartSceneDataServiceImpl implements SmartSceneDataService {
if
(
record
!=
null
)
{
if
(
record
!=
null
)
{
return
sceneDataMapper
.
updateByPrimaryKeySelective
(
sceneData
);
return
sceneDataMapper
.
updateByPrimaryKeySelective
(
sceneData
);
}
else
{
}
else
{
throw
new
BusinessException
(
ResultEnum
.
ID_NOT_FOUND
);
throw
ChejiaBusinessException
.
create
(
ResultEnum
.
ID_NOT_FOUND
);
}
}
}
}
}
}
...
...
src/main/java/cn/com/glsx/smart/modules/service/impl/SmartSceneServiceImpl.java
View file @
372c313
package
cn
.
com
.
glsx
.
smart
.
modules
.
service
.
impl
;
package
cn
.
com
.
glsx
.
smart
.
modules
.
service
.
impl
;
import
javax.annotation.Resource
;
import
java.io.IOException
;
import
java.text.MessageFormat
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.concurrent.TimeUnit
;
import
java.util.stream.Collectors
;
import
cn.com.glsx.didicb.app.enums.MessageTypeEnum
;
import
cn.com.glsx.didicb.app.enums.MessageTypeEnum
;
import
cn.com.glsx.didicb.app.model.CarAssistantInfo
;
import
cn.com.glsx.didicb.app.model.CarAssistantInfo
;
import
cn.com.glsx.didicb.app.remote.CarAssistantInfoRemote
;
import
cn.com.glsx.didicb.app.remote.CarAssistantInfoRemote
;
import
cn.com.glsx.smart.common.constant.Constants
;
import
cn.com.glsx.smart.common.constant.Constants
;
import
cn.com.glsx.smart.common.exception.ChejiaBusinessException
;
import
cn.com.glsx.smart.common.exception.ResultEnum
;
import
cn.com.glsx.smart.common.redis.RedisService
;
import
cn.com.glsx.smart.common.utils.HttpUtil
;
import
cn.com.glsx.smart.modules.entity.SmartDeviceStatus
;
import
cn.com.glsx.smart.modules.entity.SmartDeviceStatus
;
import
cn.com.glsx.smart.modules.entity.SmartScene
;
import
cn.com.glsx.smart.modules.entity.SmartScene
;
import
cn.com.glsx.smart.modules.entity.SmartSceneData
;
import
cn.com.glsx.smart.modules.entity.SmartSceneData
;
import
cn.com.glsx.smart.modules.mapper.SmartDeviceStatusMapper
;
import
cn.com.glsx.smart.modules.mapper.SmartDeviceStatusMapper
;
import
cn.com.glsx.smart.modules.mapper.SmartSceneDataMapper
;
import
cn.com.glsx.smart.modules.mapper.SmartSceneDataMapper
;
import
cn.com.glsx.smart.modules.mapper.SmartSceneMapper
;
import
cn.com.glsx.smart.modules.mapper.SmartSceneMapper
;
import
cn.com.glsx.smart.common.exception.BusinessException
;
import
cn.com.glsx.smart.common.exception.ResultEnum
;
import
cn.com.glsx.smart.modules.model.ExecuteTaskVo
;
import
cn.com.glsx.smart.modules.model.ExecuteTaskVo
;
import
cn.com.glsx.smart.modules.model.OrderResponse
;
import
cn.com.glsx.smart.modules.model.OrderResponse
;
import
cn.com.glsx.smart.modules.model.ResponseVo
;
import
cn.com.glsx.smart.modules.model.ResponseVo
;
import
cn.com.glsx.smart.common.redis.RedisService
;
import
cn.com.glsx.smart.modules.service.BaseService
;
import
cn.com.glsx.smart.modules.service.BaseService
;
import
cn.com.glsx.smart.modules.service.SmartSceneService
;
import
cn.com.glsx.smart.modules.service.SmartSceneService
;
import
cn.com.glsx.smart.common.utils.HttpUtil
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
...
@@ -29,13 +39,6 @@ import org.springframework.beans.factory.annotation.Value;
...
@@ -29,13 +39,6 @@ import org.springframework.beans.factory.annotation.Value;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.transaction.annotation.Transactional
;
import
javax.annotation.Resource
;
import
java.io.IOException
;
import
java.text.MessageFormat
;
import
java.util.*
;
import
java.util.concurrent.TimeUnit
;
import
java.util.stream.Collectors
;
/**
/**
* <p>Description:
* <p>Description:
* <p>Project: chejia-smart
* <p>Project: chejia-smart
...
@@ -93,7 +96,7 @@ public class SmartSceneServiceImpl extends BaseService implements SmartSceneServ
...
@@ -93,7 +96,7 @@ public class SmartSceneServiceImpl extends BaseService implements SmartSceneServ
if
(
record
!=
null
)
{
if
(
record
!=
null
)
{
return
sceneMapper
.
updateByPrimaryKeySelective
(
scene
);
return
sceneMapper
.
updateByPrimaryKeySelective
(
scene
);
}
else
{
}
else
{
throw
new
BusinessException
(
ResultEnum
.
ID_NOT_FOUND
);
throw
ChejiaBusinessException
.
create
(
ResultEnum
.
ID_NOT_FOUND
);
}
}
}
}
}
}
...
...
src/main/java/cn/com/glsx/smart/modules/service/impl/SmartSysCodeServiceImpl.java
View file @
372c313
package
cn
.
com
.
glsx
.
smart
.
modules
.
service
.
impl
;
package
cn
.
com
.
glsx
.
smart
.
modules
.
service
.
impl
;
import
javax.annotation.Resource
;
import
java.util.List
;
import
cn.com.glsx.smart.common.exception.ChejiaBusinessException
;
import
cn.com.glsx.smart.common.exception.ResultEnum
;
import
cn.com.glsx.smart.modules.entity.SmartSysCode
;
import
cn.com.glsx.smart.modules.entity.SmartSysCode
;
import
cn.com.glsx.smart.modules.mapper.SmartSysCodeMapper
;
import
cn.com.glsx.smart.modules.mapper.SmartSysCodeMapper
;
import
cn.com.glsx.smart.common.exception.BusinessException
;
import
cn.com.glsx.smart.common.exception.ResultEnum
;
import
cn.com.glsx.smart.modules.service.BaseService
;
import
cn.com.glsx.smart.modules.service.BaseService
;
import
cn.com.glsx.smart.modules.service.SmartSysCodeService
;
import
cn.com.glsx.smart.modules.service.SmartSysCodeService
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
javax.annotation.Resource
;
import
java.util.List
;
/**
/**
* <p>Description:
* <p>Description:
* <p>Project: chejia-smart
* <p>Project: chejia-smart
...
@@ -52,7 +51,7 @@ public class SmartSysCodeServiceImpl extends BaseService implements SmartSysCode
...
@@ -52,7 +51,7 @@ public class SmartSysCodeServiceImpl extends BaseService implements SmartSysCode
if
(
record
!=
null
)
{
if
(
record
!=
null
)
{
return
sysCodeMapper
.
updateByPrimaryKeySelective
(
sysCode
);
return
sysCodeMapper
.
updateByPrimaryKeySelective
(
sysCode
);
}
else
{
}
else
{
throw
new
BusinessException
(
ResultEnum
.
ID_NOT_FOUND
);
throw
ChejiaBusinessException
.
create
(
ResultEnum
.
ID_NOT_FOUND
);
}
}
}
}
}
}
...
...
src/main/java/cn/com/glsx/smart/modules/service/impl/SmartSysFileServiceImpl.java
View file @
372c313
package
cn
.
com
.
glsx
.
smart
.
modules
.
service
.
impl
;
package
cn
.
com
.
glsx
.
smart
.
modules
.
service
.
impl
;
import
javax.annotation.Resource
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.stream.Collectors
;
import
cn.com.glsx.smart.common.exception.ChejiaBusinessException
;
import
cn.com.glsx.smart.common.exception.ResultEnum
;
import
cn.com.glsx.smart.modules.entity.SmartSysFile
;
import
cn.com.glsx.smart.modules.entity.SmartSysFile
;
import
cn.com.glsx.smart.modules.mapper.SmartSysFileMapper
;
import
cn.com.glsx.smart.modules.mapper.SmartSysFileMapper
;
import
cn.com.glsx.smart.common.exception.BusinessException
;
import
cn.com.glsx.smart.common.exception.ResultEnum
;
import
cn.com.glsx.smart.modules.model.FileDTO
;
import
cn.com.glsx.smart.modules.model.FileDTO
;
import
cn.com.glsx.smart.modules.service.SmartSysFileService
;
import
cn.com.glsx.smart.modules.service.SmartSysFileService
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
javax.annotation.Resource
;
import
java.util.*
;
import
java.util.stream.Collectors
;
/**
/**
* <p>Description:
* <p>Description:
* <p>Project: chejia-smart
* <p>Project: chejia-smart
...
@@ -36,7 +39,7 @@ public class SmartSysFileServiceImpl implements SmartSysFileService {
...
@@ -36,7 +39,7 @@ public class SmartSysFileServiceImpl implements SmartSysFileService {
if
(
record
!=
null
)
{
if
(
record
!=
null
)
{
fileMapper
.
updateByPrimaryKeySelective
(
sysFile
);
fileMapper
.
updateByPrimaryKeySelective
(
sysFile
);
}
else
{
}
else
{
throw
new
BusinessException
(
ResultEnum
.
ID_NOT_FOUND
);
throw
ChejiaBusinessException
.
create
(
ResultEnum
.
ID_NOT_FOUND
);
}
}
}
}
return
sysFile
.
getId
();
return
sysFile
.
getId
();
...
...
src/main/java/cn/com/glsx/smart/modules/service/impl/SmartTemplateParamServiceImpl.java
View file @
372c313
package
cn
.
com
.
glsx
.
smart
.
modules
.
service
.
impl
;
package
cn
.
com
.
glsx
.
smart
.
modules
.
service
.
impl
;
import
javax.annotation.Resource
;
import
java.util.List
;
import
cn.com.glsx.smart.common.constant.Constants
;
import
cn.com.glsx.smart.common.constant.Constants
;
import
cn.com.glsx.smart.common.exception.ChejiaBusinessException
;
import
cn.com.glsx.smart.common.exception.ResultEnum
;
import
cn.com.glsx.smart.modules.entity.SmartDeviceOrder
;
import
cn.com.glsx.smart.modules.entity.SmartDeviceOrder
;
import
cn.com.glsx.smart.modules.entity.SmartDeviceOrdervalue
;
import
cn.com.glsx.smart.modules.entity.SmartDeviceOrdervalue
;
import
cn.com.glsx.smart.modules.entity.SmartScenceSupstatus
;
import
cn.com.glsx.smart.modules.entity.SmartScenceSupstatus
;
import
cn.com.glsx.smart.modules.entity.SmartTemplateParam
;
import
cn.com.glsx.smart.modules.entity.SmartTemplateParam
;
import
cn.com.glsx.smart.modules.mapper.*
;
import
cn.com.glsx.smart.modules.mapper.SmartDeviceOrderMapper
;
import
cn.com.glsx.smart.common.exception.BusinessException
;
import
cn.com.glsx.smart.modules.mapper.SmartDeviceOrdervalueMapper
;
import
cn.com.glsx.smart.common.exception.ResultEnum
;
import
cn.com.glsx.smart.modules.mapper.SmartProductTypeMapper
;
import
cn.com.glsx.smart.modules.mapper.SmartScenceSupstatusMapper
;
import
cn.com.glsx.smart.modules.mapper.SmartTemplateParamMapper
;
import
cn.com.glsx.smart.modules.service.SmartTemplateParamService
;
import
cn.com.glsx.smart.modules.service.SmartTemplateParamService
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
javax.annotation.Resource
;
import
java.util.List
;
/**
/**
* <p>Description:
* <p>Description:
* <p>Project: chejia-smart
* <p>Project: chejia-smart
...
@@ -58,7 +61,7 @@ public class SmartTemplateParamServiceImpl implements SmartTemplateParamService
...
@@ -58,7 +61,7 @@ public class SmartTemplateParamServiceImpl implements SmartTemplateParamService
if
(
record
!=
null
)
{
if
(
record
!=
null
)
{
return
templateParamMapper
.
updateByPrimaryKeySelective
(
templateParam
);
return
templateParamMapper
.
updateByPrimaryKeySelective
(
templateParam
);
}
else
{
}
else
{
throw
new
BusinessException
(
ResultEnum
.
ID_NOT_FOUND
);
throw
ChejiaBusinessException
.
create
(
ResultEnum
.
ID_NOT_FOUND
);
}
}
}
}
}
}
...
...
src/main/java/cn/com/glsx/smart/modules/service/impl/SmartUserDeviceServiceImpl.java
View file @
372c313
package
cn
.
com
.
glsx
.
smart
.
modules
.
service
.
impl
;
package
cn
.
com
.
glsx
.
smart
.
modules
.
service
.
impl
;
import
javax.annotation.Resource
;
import
javax.transaction.Transactional
;
import
java.nio.charset.StandardCharsets
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
cn.com.glsx.smart.common.constant.Constants
;
import
cn.com.glsx.smart.common.constant.Constants
;
import
cn.com.glsx.smart.common.exception.ChejiaBusinessException
;
import
cn.com.glsx.smart.common.exception.ResultEnum
;
import
cn.com.glsx.smart.common.redis.RedisService
;
import
cn.com.glsx.smart.modules.entity.SmartUserChannel
;
import
cn.com.glsx.smart.modules.entity.SmartUserChannel
;
import
cn.com.glsx.smart.modules.entity.SmartUserDevice
;
import
cn.com.glsx.smart.modules.entity.SmartUserDevice
;
import
cn.com.glsx.smart.modules.entity.SmartUserRelation
;
import
cn.com.glsx.smart.modules.entity.SmartUserRelation
;
...
@@ -8,9 +18,6 @@ import cn.com.glsx.smart.modules.mapper.SmartProductMapper;
...
@@ -8,9 +18,6 @@ import cn.com.glsx.smart.modules.mapper.SmartProductMapper;
import
cn.com.glsx.smart.modules.mapper.SmartUserChannelMapper
;
import
cn.com.glsx.smart.modules.mapper.SmartUserChannelMapper
;
import
cn.com.glsx.smart.modules.mapper.SmartUserDeviceMapper
;
import
cn.com.glsx.smart.modules.mapper.SmartUserDeviceMapper
;
import
cn.com.glsx.smart.modules.mapper.SmartUserRelationMapper
;
import
cn.com.glsx.smart.modules.mapper.SmartUserRelationMapper
;
import
cn.com.glsx.smart.common.exception.BusinessException
;
import
cn.com.glsx.smart.common.exception.ResultEnum
;
import
cn.com.glsx.smart.common.redis.RedisService
;
import
cn.com.glsx.smart.modules.service.BaseService
;
import
cn.com.glsx.smart.modules.service.BaseService
;
import
cn.com.glsx.smart.modules.service.SmartUserDeviceService
;
import
cn.com.glsx.smart.modules.service.SmartUserDeviceService
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSON
;
...
@@ -22,14 +29,6 @@ import org.springframework.beans.factory.annotation.Autowired;
...
@@ -22,14 +29,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
javax.annotation.Resource
;
import
javax.transaction.Transactional
;
import
java.nio.charset.StandardCharsets
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
/**
/**
* <p>Description: 用户设备业务
* <p>Description: 用户设备业务
* <p>Project: chejia-smart
* <p>Project: chejia-smart
...
@@ -79,7 +78,7 @@ public class SmartUserDeviceServiceImpl extends BaseService implements SmartUser
...
@@ -79,7 +78,7 @@ public class SmartUserDeviceServiceImpl extends BaseService implements SmartUser
public
SmartUserDevice
getByDeviceId
(
SmartUserDevice
req
)
{
public
SmartUserDevice
getByDeviceId
(
SmartUserDevice
req
)
{
SmartUserDevice
userDevice
=
userDeviceMapper
.
getByDeviceId
(
req
);
SmartUserDevice
userDevice
=
userDeviceMapper
.
getByDeviceId
(
req
);
if
(
userDevice
==
null
)
{
if
(
userDevice
==
null
)
{
throw
BusinessException
.
create
(
ResultEnum
.
DEVICE_NOT_FOUND
);
throw
Chejia
BusinessException
.
create
(
ResultEnum
.
DEVICE_NOT_FOUND
);
}
}
return
userDevice
;
return
userDevice
;
}
}
...
@@ -95,14 +94,14 @@ public class SmartUserDeviceServiceImpl extends BaseService implements SmartUser
...
@@ -95,14 +94,14 @@ public class SmartUserDeviceServiceImpl extends BaseService implements SmartUser
SmartUserDevice
savedUserDevice
=
userDeviceMapper
.
selectOne
(
record
);
SmartUserDevice
savedUserDevice
=
userDeviceMapper
.
selectOne
(
record
);
if
(
savedUserDevice
==
null
)
{
if
(
savedUserDevice
==
null
)
{
if
(
StringUtils
.
isBlank
(
req
.
getUid
()))
{
if
(
StringUtils
.
isBlank
(
req
.
getUid
()))
{
throw
BusinessException
.
create
(
ResultEnum
.
PARAM_EMPTY
,
"uid"
);
throw
Chejia
BusinessException
.
create
(
ResultEnum
.
PARAM_EMPTY
,
"uid"
);
}
}
// 根据第三方用户 id 查询用户绑定信息
// 根据第三方用户 id 查询用户绑定信息
SmartUserChannel
ucRecord
=
new
SmartUserChannel
();
SmartUserChannel
ucRecord
=
new
SmartUserChannel
();
ucRecord
.
setThirdId
(
req
.
getUid
());
ucRecord
.
setThirdId
(
req
.
getUid
());
SmartUserChannel
savedUserChannel
=
userChannelMapper
.
selectOne
(
ucRecord
);
SmartUserChannel
savedUserChannel
=
userChannelMapper
.
selectOne
(
ucRecord
);
if
(
savedUserChannel
==
null
)
{
if
(
savedUserChannel
==
null
)
{
throw
BusinessException
.
create
(
ResultEnum
.
USER_NOT_FOUND
);
throw
Chejia
BusinessException
.
create
(
ResultEnum
.
USER_NOT_FOUND
);
}
}
// 插入用户信息
// 插入用户信息
req
.
setUserId
(
savedUserChannel
.
getUserId
());
req
.
setUserId
(
savedUserChannel
.
getUserId
());
...
@@ -113,7 +112,7 @@ public class SmartUserDeviceServiceImpl extends BaseService implements SmartUser
...
@@ -113,7 +112,7 @@ public class SmartUserDeviceServiceImpl extends BaseService implements SmartUser
this
.
subscribeDevice
(
req
);
this
.
subscribeDevice
(
req
);
}
else
{
}
else
{
if
(
StringUtils
.
isBlank
(
req
.
getDeviceName
()))
{
if
(
StringUtils
.
isBlank
(
req
.
getDeviceName
()))
{
throw
BusinessException
.
create
(
ResultEnum
.
PARAM_EMPTY
,
"deviceName"
);
throw
Chejia
BusinessException
.
create
(
ResultEnum
.
PARAM_EMPTY
,
"deviceName"
);
}
}
savedUserDevice
.
setDeviceName
(
req
.
getDeviceName
());
savedUserDevice
.
setDeviceName
(
req
.
getDeviceName
());
savedUserDevice
.
setUpdateTime
(
now
);
savedUserDevice
.
setUpdateTime
(
now
);
...
@@ -176,7 +175,7 @@ public class SmartUserDeviceServiceImpl extends BaseService implements SmartUser
...
@@ -176,7 +175,7 @@ public class SmartUserDeviceServiceImpl extends BaseService implements SmartUser
if
(
Constants
.
USER_CHANNEL_AQARA
.
equals
(
req
.
getChannel
()))
{
if
(
Constants
.
USER_CHANNEL_AQARA
.
equals
(
req
.
getChannel
()))
{
// 只有绿米的设备需要订阅
// 只有绿米的设备需要订阅
if
(
StringUtils
.
isBlank
(
req
.
getPlatformProductId
()))
{
if
(
StringUtils
.
isBlank
(
req
.
getPlatformProductId
()))
{
throw
BusinessException
.
create
(
ResultEnum
.
PARAM_EMPTY
,
"platformProductId"
);
throw
Chejia
BusinessException
.
create
(
ResultEnum
.
PARAM_EMPTY
,
"platformProductId"
);
}
}
// 通过用户手机号获取用户 token
// 通过用户手机号获取用户 token
SmartUserRelation
userRelation
=
userRelationMapper
.
selectByPrimaryKey
(
req
.
getUserId
());
SmartUserRelation
userRelation
=
userRelationMapper
.
selectByPrimaryKey
(
req
.
getUserId
());
...
@@ -203,7 +202,7 @@ public class SmartUserDeviceServiceImpl extends BaseService implements SmartUser
...
@@ -203,7 +202,7 @@ public class SmartUserDeviceServiceImpl extends BaseService implements SmartUser
log
.
info
(
"$$$$ subscribeDevice resp = {}"
,
respJson
);
log
.
info
(
"$$$$ subscribeDevice resp = {}"
,
respJson
);
JSONObject
respObj
=
JSON
.
parseObject
(
respJson
);
JSONObject
respObj
=
JSON
.
parseObject
(
respJson
);
if
(!
"200"
.
equals
(
respObj
.
getString
(
"code"
)))
{
if
(!
"200"
.
equals
(
respObj
.
getString
(
"code"
)))
{
throw
BusinessException
.
create
(
ResultEnum
.
DEVICE_SUBSCRIBE_ERROR
);
throw
Chejia
BusinessException
.
create
(
ResultEnum
.
DEVICE_SUBSCRIBE_ERROR
);
}
}
}
}
}
}
...
...
src/main/java/cn/com/glsx/smart/modules/service/impl/SmartUserRelationServiceImpl.java
View file @
372c313
package
cn
.
com
.
glsx
.
smart
.
modules
.
service
.
impl
;
package
cn
.
com
.
glsx
.
smart
.
modules
.
service
.
impl
;
import
javax.annotation.Resource
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
cn.com.glsx.smart.common.constant.Constants
;
import
cn.com.glsx.smart.common.constant.Constants
;
import
cn.com.glsx.smart.common.exception.ChejiaBusinessException
;
import
cn.com.glsx.smart.common.exception.ResultEnum
;
import
cn.com.glsx.smart.modules.entity.SmartUserChannel
;
import
cn.com.glsx.smart.modules.entity.SmartUserChannel
;
import
cn.com.glsx.smart.modules.entity.SmartUserRelation
;
import
cn.com.glsx.smart.modules.entity.SmartUserRelation
;
import
cn.com.glsx.smart.modules.mapper.SmartUserChannelMapper
;
import
cn.com.glsx.smart.modules.mapper.SmartUserChannelMapper
;
import
cn.com.glsx.smart.modules.mapper.SmartUserRelationMapper
;
import
cn.com.glsx.smart.modules.mapper.SmartUserRelationMapper
;
import
cn.com.glsx.smart.common.exception.BusinessException
;
import
cn.com.glsx.smart.common.exception.ResultEnum
;
import
cn.com.glsx.smart.modules.service.SmartUserRelationService
;
import
cn.com.glsx.smart.modules.service.SmartUserRelationService
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
...
@@ -16,12 +21,6 @@ import lombok.extern.slf4j.Slf4j;
...
@@ -16,12 +21,6 @@ import lombok.extern.slf4j.Slf4j;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
javax.annotation.Resource
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
/**
/**
* <p>Description:
* <p>Description:
* <p>Project: chejia-smart
* <p>Project: chejia-smart
...
@@ -63,7 +62,7 @@ public class SmartUserRelationServiceImpl implements SmartUserRelationService {
...
@@ -63,7 +62,7 @@ public class SmartUserRelationServiceImpl implements SmartUserRelationService {
if
(
record
!=
null
)
{
if
(
record
!=
null
)
{
return
relationMapper
.
updateByPrimaryKeySelective
(
userRelation
);
return
relationMapper
.
updateByPrimaryKeySelective
(
userRelation
);
}
else
{
}
else
{
throw
new
BusinessException
(
ResultEnum
.
ID_NOT_FOUND
);
throw
ChejiaBusinessException
.
create
(
ResultEnum
.
ID_NOT_FOUND
);
}
}
}
}
}
}
...
@@ -183,6 +182,7 @@ public class SmartUserRelationServiceImpl implements SmartUserRelationService {
...
@@ -183,6 +182,7 @@ public class SmartUserRelationServiceImpl implements SmartUserRelationService {
* @param mobile
* @param mobile
* @return
* @return
*/
*/
@Override
public
Map
<
String
,
String
>
syncAqaraUserCore
(
String
mobile
){
public
Map
<
String
,
String
>
syncAqaraUserCore
(
String
mobile
){
Map
<
String
,
String
>
object
=
new
HashMap
<>();
Map
<
String
,
String
>
object
=
new
HashMap
<>();
object
.
put
(
"account"
,
mobile
);
object
.
put
(
"account"
,
mobile
);
...
...
Write
Preview
Markdown
is supported
Attach a file
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 post a comment