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 6683c185
authored
Apr 14, 2021
by
111-PC\111
Browse Files
Options
Browse Files
Tag
Download
Plain Diff
Merge remote-tracking branch 'origin/dev' into dev
2 parents
bc37ea53
69219925
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
103 additions
and
52 deletions
src/main/java/com/glsx/smart/constant/Constants.java
src/main/java/com/glsx/smart/controller/SceneController.java
src/main/java/com/glsx/smart/pojo/DeviceMessage.java
src/main/java/com/glsx/smart/service/impl/SmartSceneDataServiceImpl.java
src/main/java/com/glsx/smart/service/impl/SmartTemplateParamServiceImpl.java
src/main/java/com/glsx/smart/constant/Constants.java
View file @
6683c18
...
@@ -15,4 +15,6 @@ public class Constants {
...
@@ -15,4 +15,6 @@ public class Constants {
public
final
static
String
SCENE_CONDITION_STATUS
=
"scene_condition_status"
;
public
final
static
String
SCENE_CONDITION_STATUS
=
"scene_condition_status"
;
public
final
static
String
SCENE_CONTENT_DEVICE
=
"scene_content_device"
;
}
}
src/main/java/com/glsx/smart/controller/SceneController.java
View file @
6683c18
...
@@ -4,11 +4,7 @@ import com.alibaba.fastjson.JSON;
...
@@ -4,11 +4,7 @@ import com.alibaba.fastjson.JSON;
import
com.glsx.smart.dao.entity.SmartScene
;
import
com.glsx.smart.dao.entity.SmartScene
;
import
com.glsx.smart.dao.entity.SmartUserRelation
;
import
com.glsx.smart.dao.entity.SmartUserRelation
;
import
com.glsx.smart.pojo.OrderResponse
;
import
com.glsx.smart.pojo.OrderResponse
;
import
com.glsx.smart.service.SmartSceneDataService
;
import
com.glsx.smart.service.*
;
import
com.glsx.smart.service.SmartSceneLogService
;
import
com.glsx.smart.service.SmartSceneService
;
import
com.glsx.smart.service.SmartUserRelationService
;
import
com.glsx.smart.service.UserKafkaService
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.Api
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
@@ -57,10 +53,10 @@ public class SceneController {
...
@@ -57,10 +53,10 @@ public class SceneController {
@RequestMapping
(
value
=
"/getScenList"
,
method
=
{
RequestMethod
.
GET
,
RequestMethod
.
POST
})
@RequestMapping
(
value
=
"/getScenList"
,
method
=
{
RequestMethod
.
GET
,
RequestMethod
.
POST
})
public
List
<
SmartScene
>
getScenList
(
@RequestBody
SmartScene
scene
)
{
public
List
<
SmartScene
>
getScenList
(
@RequestBody
SmartScene
scene
)
{
log
.
info
(
"/scene/getList param: {}"
,
JSON
.
toJSONString
(
scene
));
log
.
info
(
"/scene/getList param: {}"
,
JSON
.
toJSONString
(
scene
));
SmartUserRelation
smartUserRelation
=
new
SmartUserRelation
();
SmartUserRelation
smartUserRelation
=
new
SmartUserRelation
();
smartUserRelation
.
setUserId
(
scene
.
getUserId
());
smartUserRelation
.
setUserId
(
scene
.
getUserId
());
SmartUserRelation
user
=
userRelationService
.
getSingle
(
smartUserRelation
);
SmartUserRelation
user
=
userRelationService
.
getSingle
(
smartUserRelation
);
if
(
user
==
null
)
{
if
(
user
==
null
)
{
return
null
;
return
null
;
}
}
scene
.
setUserId
(
user
.
getId
());
scene
.
setUserId
(
user
.
getId
());
...
@@ -71,7 +67,7 @@ public class SceneController {
...
@@ -71,7 +67,7 @@ public class SceneController {
public
SmartScene
getById
(
Long
id
)
{
public
SmartScene
getById
(
Long
id
)
{
log
.
info
(
"/scene/getById param: {}"
,
id
);
log
.
info
(
"/scene/getById param: {}"
,
id
);
SmartScene
scene
=
sceneService
.
getById
(
id
);
SmartScene
scene
=
sceneService
.
getById
(
id
);
if
(
scene
!=
null
)
{
if
(
scene
!=
null
)
{
scene
.
setDataList
(
sceneDataService
.
getBySceneId
(
id
));
scene
.
setDataList
(
sceneDataService
.
getBySceneId
(
id
));
}
}
return
scene
;
return
scene
;
...
@@ -81,8 +77,8 @@ public class SceneController {
...
@@ -81,8 +77,8 @@ public class SceneController {
public
boolean
save
(
@RequestBody
SmartScene
scene
)
{
public
boolean
save
(
@RequestBody
SmartScene
scene
)
{
scene
.
setCreateTime
(
new
Date
());
scene
.
setCreateTime
(
new
Date
());
log
.
info
(
"用户新增调用/scene/add param: {}"
,
JSON
.
toJSONString
(
scene
));
log
.
info
(
"用户新增调用/scene/add param: {}"
,
JSON
.
toJSONString
(
scene
));
boolean
flag
=
sceneService
.
insert
(
scene
)
>
0
?
true
:
false
;
boolean
flag
=
sceneService
.
insert
(
scene
)
>
0
;
if
(
flag
)
{
if
(
flag
)
{
userKafkaService
.
addDeviceData
(
scene
);
//推送数据至kafka
userKafkaService
.
addDeviceData
(
scene
);
//推送数据至kafka
sceneLogService
.
insertWrapper
(
scene
.
getUserId
(),
sceneLogService
.
insertWrapper
(
scene
.
getUserId
(),
"新增场景数据:"
+
scene
.
getId
(),
JSON
.
toJSONString
(
scene
));
"新增场景数据:"
+
scene
.
getId
(),
JSON
.
toJSONString
(
scene
));
...
@@ -94,8 +90,8 @@ public class SceneController {
...
@@ -94,8 +90,8 @@ public class SceneController {
public
boolean
update
(
@RequestBody
SmartScene
scene
)
{
public
boolean
update
(
@RequestBody
SmartScene
scene
)
{
scene
.
setUpdateTime
(
new
Date
());
scene
.
setUpdateTime
(
new
Date
());
log
.
info
(
"用户更新调用/scene/update param: {}"
,
JSON
.
toJSONString
(
scene
));
log
.
info
(
"用户更新调用/scene/update param: {}"
,
JSON
.
toJSONString
(
scene
));
boolean
flag
=
sceneService
.
update
(
scene
)
>
0
?
true
:
false
;
boolean
flag
=
sceneService
.
update
(
scene
)
>
0
;
if
(
flag
)
{
if
(
flag
)
{
userKafkaService
.
addDeviceData
(
scene
);
//推送数据至kafka
userKafkaService
.
addDeviceData
(
scene
);
//推送数据至kafka
sceneLogService
.
insertWrapper
(
scene
.
getUserId
(),
sceneLogService
.
insertWrapper
(
scene
.
getUserId
(),
"更新场景数据:"
+
scene
.
getId
(),
JSON
.
toJSONString
(
scene
));
"更新场景数据:"
+
scene
.
getId
(),
JSON
.
toJSONString
(
scene
));
...
@@ -108,7 +104,7 @@ public class SceneController {
...
@@ -108,7 +104,7 @@ public class SceneController {
log
.
info
(
"用户删除场景调用/scene/delete param: {}"
,
scene
.
getId
());
log
.
info
(
"用户删除场景调用/scene/delete param: {}"
,
scene
.
getId
());
SmartScene
data
=
sceneService
.
getById
(
scene
.
getId
());
SmartScene
data
=
sceneService
.
getById
(
scene
.
getId
());
int
i
=
sceneService
.
deleteByPrimaryKey
(
scene
.
getId
());
int
i
=
sceneService
.
deleteByPrimaryKey
(
scene
.
getId
());
if
(
i
>
0
)
{
if
(
i
>
0
)
{
sceneDataService
.
deleteBySceneId
(
scene
.
getId
());
sceneDataService
.
deleteBySceneId
(
scene
.
getId
());
sceneLogService
.
insertWrapper
(
data
.
getUserId
(),
sceneLogService
.
insertWrapper
(
data
.
getUserId
(),
"删除场景数据:"
+
data
.
getId
(),
JSON
.
toJSONString
(
data
));
"删除场景数据:"
+
data
.
getId
(),
JSON
.
toJSONString
(
data
));
...
@@ -121,7 +117,7 @@ public class SceneController {
...
@@ -121,7 +117,7 @@ public class SceneController {
public
boolean
updateStatus
(
@RequestBody
SmartScene
scene
)
{
public
boolean
updateStatus
(
@RequestBody
SmartScene
scene
)
{
scene
.
setUpdateTime
(
new
Date
());
scene
.
setUpdateTime
(
new
Date
());
log
.
info
(
"用户更新调用/scene/updateStatus param: {}"
,
JSON
.
toJSONString
(
scene
));
log
.
info
(
"用户更新调用/scene/updateStatus param: {}"
,
JSON
.
toJSONString
(
scene
));
return
sceneService
.
updateByPrimaryKeySelective
(
scene
)
>
0
?
true
:
false
;
return
sceneService
.
updateByPrimaryKeySelective
(
scene
)
>
0
;
}
}
@RequestMapping
(
value
=
"/issueOrder"
,
method
=
{
RequestMethod
.
POST
})
@RequestMapping
(
value
=
"/issueOrder"
,
method
=
{
RequestMethod
.
POST
})
...
...
src/main/java/com/glsx/smart/pojo/DeviceMessage.java
deleted
100644 → 0
View file @
bc37ea5
package
com
.
glsx
.
smart
.
pojo
;
import
lombok.Data
;
import
lombok.ToString
;
import
java.io.Serializable
;
/**
* @author think.wang
* @version 1.0.0
* @Title DeviceMessage
* @Package com.glsx.smart.pojo
* @Description kafka传送数据
* @date 2021/4/11
*/
@Data
@ToString
public
class
DeviceMessage
implements
Serializable
{
/**
* 设备id
*/
private
String
deviceId
;
/**
* 设备围栏经纬度 格式 经度值:纬度值
*/
private
String
lngAndLat
;
/**
* 操作类型 1新增 2更新设备围栏经纬度 3删除
*/
private
Integer
type
;
}
src/main/java/com/glsx/smart/service/impl/SmartSceneDataServiceImpl.java
View file @
6683c18
package
com
.
glsx
.
smart
.
service
.
impl
;
package
com
.
glsx
.
smart
.
service
.
impl
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
import
com.glsx.plat.common.utils.StringUtils
;
import
com.glsx.smart.constant.Constants
;
import
com.glsx.smart.dao.entity.SmartDeviceOrder
;
import
com.glsx.smart.dao.entity.SmartDeviceOrdervalue
;
import
com.glsx.smart.dao.entity.SmartScenceSupstatus
;
import
com.glsx.smart.dao.entity.SmartSceneData
;
import
com.glsx.smart.dao.entity.SmartSceneData
;
import
com.glsx.smart.dao.mapper.SmartDeviceOrderMapper
;
import
com.glsx.smart.dao.mapper.SmartDeviceOrdervalueMapper
;
import
com.glsx.smart.dao.mapper.SmartScenceSupstatusMapper
;
import
com.glsx.smart.dao.mapper.SmartSceneDataMapper
;
import
com.glsx.smart.dao.mapper.SmartSceneDataMapper
;
import
com.glsx.smart.exception.BusinessException
;
import
com.glsx.smart.exception.BusinessException
;
import
com.glsx.smart.exception.ResultEnum
;
import
com.glsx.smart.exception.ResultEnum
;
...
@@ -25,6 +35,15 @@ public class SmartSceneDataServiceImpl implements SmartSceneDataService {
...
@@ -25,6 +35,15 @@ public class SmartSceneDataServiceImpl implements SmartSceneDataService {
@Resource
@Resource
private
SmartSceneDataMapper
sceneDataMapper
;
private
SmartSceneDataMapper
sceneDataMapper
;
@Resource
private
SmartDeviceOrderMapper
deviceOrderMapper
;
@Resource
private
SmartDeviceOrdervalueMapper
orderValueMapper
;
@Resource
private
SmartScenceSupstatusMapper
supstatusMapper
;
@Override
@Override
public
int
deleteByPrimaryKey
(
Long
id
)
{
public
int
deleteByPrimaryKey
(
Long
id
)
{
return
sceneDataMapper
.
deleteByPrimaryKey
(
id
);
return
sceneDataMapper
.
deleteByPrimaryKey
(
id
);
...
@@ -51,8 +70,33 @@ public class SmartSceneDataServiceImpl implements SmartSceneDataService {
...
@@ -51,8 +70,33 @@ public class SmartSceneDataServiceImpl implements SmartSceneDataService {
@Override
@Override
public
List
<
SmartSceneData
>
getBySceneId
(
Long
sceneId
)
{
public
List
<
SmartSceneData
>
getBySceneId
(
Long
sceneId
)
{
return
sceneDataMapper
.
getBySceneId
(
sceneId
);
List
<
SmartSceneData
>
dataList
=
sceneDataMapper
.
getBySceneId
(
sceneId
);
for
(
SmartSceneData
data
:
dataList
)
{
if
(
StringUtils
.
isNotEmpty
(
data
.
getDeviceId
())){
JSONObject
jsonObject
=
JSON
.
parseObject
(
data
.
getParamValue
());
//触发条件设备状态
Long
orderId
=
jsonObject
.
getLong
(
"orderId"
);
if
(
Constants
.
SCENE_CONDITION_STATUS
.
equals
(
data
.
getParamKey
())){
SmartScenceSupstatus
supstatus
=
supstatusMapper
.
selectByPrimaryKey
(
orderId
);
jsonObject
.
put
(
"orderName"
,
supstatus
.
getSceneSupstatusValue
());
}
//执行内容设备功能
if
(
Constants
.
SCENE_CONTENT_DEVICE
.
equals
(
data
.
getParamKey
())){
SmartDeviceOrder
order
=
deviceOrderMapper
.
selectByPrimaryKey
(
orderId
);
jsonObject
.
put
(
"orderName"
,
order
.
getOrderValue
());
if
(
"2"
.
equals
(
order
.
getOrderType
())){
SmartDeviceOrdervalue
orderValue
=
orderValueMapper
.
selectByPrimaryKey
(
jsonObject
.
getLong
(
"valueId"
));
jsonObject
.
put
(
"valueName"
,
orderValue
.
getDeviceStatusValue
());
}
}
}
data
.
setParamValue
(
JSON
.
toJSONString
(
jsonObject
));
}
}
return
dataList
;
}
@Override
@Override
public
int
deleteBySceneId
(
Long
sceneId
)
{
public
int
deleteBySceneId
(
Long
sceneId
)
{
...
...
src/main/java/com/glsx/smart/service/impl/SmartTemplateParamServiceImpl.java
View file @
6683c18
package
com
.
glsx
.
smart
.
service
.
impl
;
package
com
.
glsx
.
smart
.
service
.
impl
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
import
com.glsx.smart.constant.Constants
;
import
com.glsx.smart.dao.entity.SmartDeviceOrder
;
import
com.glsx.smart.dao.entity.SmartDeviceOrdervalue
;
import
com.glsx.smart.dao.entity.SmartScenceSupstatus
;
import
com.glsx.smart.dao.entity.SmartTemplateParam
;
import
com.glsx.smart.dao.entity.SmartTemplateParam
;
import
com.glsx.smart.dao.mapper.
SmartTemplateParamMapper
;
import
com.glsx.smart.dao.mapper.
*
;
import
com.glsx.smart.exception.BusinessException
;
import
com.glsx.smart.exception.BusinessException
;
import
com.glsx.smart.exception.ResultEnum
;
import
com.glsx.smart.exception.ResultEnum
;
import
com.glsx.smart.service.SmartTemplateParamService
;
import
com.glsx.smart.service.SmartTemplateParamService
;
...
@@ -25,6 +31,18 @@ public class SmartTemplateParamServiceImpl implements SmartTemplateParamService
...
@@ -25,6 +31,18 @@ public class SmartTemplateParamServiceImpl implements SmartTemplateParamService
@Resource
@Resource
private
SmartTemplateParamMapper
templateParamMapper
;
private
SmartTemplateParamMapper
templateParamMapper
;
@Resource
private
SmartProductTypeMapper
productTypeMapper
;
@Resource
private
SmartDeviceOrderMapper
deviceOrderMapper
;
@Resource
private
SmartDeviceOrdervalueMapper
orderValueMapper
;
@Resource
private
SmartScenceSupstatusMapper
supstatusMapper
;
@Override
@Override
public
int
deleteByPrimaryKey
(
Long
id
)
{
public
int
deleteByPrimaryKey
(
Long
id
)
{
return
templateParamMapper
.
deleteByPrimaryKey
(
id
);
return
templateParamMapper
.
deleteByPrimaryKey
(
id
);
...
@@ -52,7 +70,33 @@ public class SmartTemplateParamServiceImpl implements SmartTemplateParamService
...
@@ -52,7 +70,33 @@ public class SmartTemplateParamServiceImpl implements SmartTemplateParamService
@Override
@Override
public
List
<
SmartTemplateParam
>
getByTemplateId
(
Long
templateId
)
{
public
List
<
SmartTemplateParam
>
getByTemplateId
(
Long
templateId
)
{
return
templateParamMapper
.
getByTemplateId
(
templateId
);
List
<
SmartTemplateParam
>
templateList
=
templateParamMapper
.
getByTemplateId
(
templateId
);
for
(
SmartTemplateParam
data
:
templateList
)
{
JSONObject
jsonObject
=
JSON
.
parseObject
(
data
.
getParamValue
());
//触发条件设备状态
if
(
Constants
.
SCENE_CONDITION_STATUS
.
equals
(
data
.
getParamKey
())){
Long
orderId
=
jsonObject
.
getLong
(
"orderId"
);
Long
typeId
=
jsonObject
.
getLong
(
"select"
);
SmartScenceSupstatus
supstatus
=
supstatusMapper
.
selectByPrimaryKey
(
orderId
);
jsonObject
.
put
(
"orderName"
,
supstatus
.
getSceneSupstatusValue
());
jsonObject
.
put
(
"productName"
,
productTypeMapper
.
selectByPrimaryKey
(
typeId
).
getTypeName
());
}
//执行内容设备功能
if
(
Constants
.
SCENE_CONTENT_DEVICE
.
equals
(
data
.
getParamKey
())){
Long
orderId
=
jsonObject
.
getLong
(
"orderId"
);
Long
typeId
=
jsonObject
.
getLong
(
"select"
);
SmartDeviceOrder
order
=
deviceOrderMapper
.
selectByPrimaryKey
(
orderId
);
jsonObject
.
put
(
"orderName"
,
order
.
getOrderValue
());
if
(
"2"
.
equals
(
order
.
getOrderType
())){
SmartDeviceOrdervalue
orderValue
=
orderValueMapper
.
selectByPrimaryKey
(
jsonObject
.
getLong
(
"valueId"
));
jsonObject
.
put
(
"valueName"
,
orderValue
.
getDeviceStatusValue
());
}
jsonObject
.
put
(
"productName"
,
productTypeMapper
.
selectByPrimaryKey
(
typeId
).
getTypeName
());
}
data
.
setParamValue
(
JSON
.
toJSONString
(
jsonObject
));
}
return
templateList
;
}
}
@Override
@Override
...
...
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