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 97ab46d3
authored
Mar 27, 2021
by
111-PC\111
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
[+]下发指令代码修改
1 parent
4561cdc7
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
43 additions
and
13 deletions
src/main/java/com/glsx/smart/controller/SceneController.java
src/main/java/com/glsx/smart/pojo/OrderResponse.java
src/main/java/com/glsx/smart/service/SmartSceneService.java
src/main/java/com/glsx/smart/service/impl/SmartSceneServiceImpl.java
src/main/java/com/glsx/smart/controller/SceneController.java
View file @
97ab46d
package
com
.
glsx
.
smart
.
controller
;
package
com
.
glsx
.
smart
.
controller
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSON
;
import
com.glsx.plat.core.web.R
;
import
com.glsx.smart.dao.entity.SmartScene
;
import
com.glsx.smart.dao.entity.SmartScene
;
import
com.glsx.smart.pojo.OrderResponse
;
import
com.glsx.smart.service.SmartSceneDataService
;
import
com.glsx.smart.service.SmartSceneDataService
;
import
com.glsx.smart.service.SmartSceneService
;
import
com.glsx.smart.service.SmartSceneService
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.Api
;
...
@@ -72,7 +74,7 @@ public class SceneController {
...
@@ -72,7 +74,7 @@ public class SceneController {
}
}
@RequestMapping
(
value
=
"/issueOrder"
,
method
=
{
RequestMethod
.
POST
})
@RequestMapping
(
value
=
"/issueOrder"
,
method
=
{
RequestMethod
.
POST
})
public
boolean
issueOrder
(
@RequestBody
SmartScene
scene
)
{
public
List
<
OrderResponse
>
issueOrder
(
@RequestBody
SmartScene
scene
)
{
return
sceneService
.
issueOrder
(
scene
);
return
sceneService
.
issueOrder
(
scene
);
}
}
}
}
src/main/java/com/glsx/smart/pojo/OrderResponse.java
0 → 100644
View file @
97ab46d
package
com
.
glsx
.
smart
.
pojo
;
import
lombok.Data
;
/**
* @author zhouhaibao
* @date 2021/3/26 17:57
*/
@Data
public
class
OrderResponse
{
private
String
deviceName
;
private
String
message
;
private
boolean
result
;
private
Integer
code
;
}
src/main/java/com/glsx/smart/service/SmartSceneService.java
View file @
97ab46d
package
com
.
glsx
.
smart
.
service
;
package
com
.
glsx
.
smart
.
service
;
import
com.glsx.smart.dao.entity.SmartScene
;
import
com.glsx.smart.dao.entity.SmartScene
;
import
com.glsx.smart.pojo.OrderResponse
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.util.List
;
import
java.util.List
;
...
@@ -30,6 +31,5 @@ public interface SmartSceneService {
...
@@ -30,6 +31,5 @@ public interface SmartSceneService {
int
updateByPrimaryKeySelective
(
SmartScene
record
);
int
updateByPrimaryKeySelective
(
SmartScene
record
);
List
<
OrderResponse
>
issueOrder
(
SmartScene
scene
);
boolean
issueOrder
(
SmartScene
scene
);
}
}
src/main/java/com/glsx/smart/service/impl/SmartSceneServiceImpl.java
View file @
97ab46d
package
com
.
glsx
.
smart
.
service
.
impl
;
package
com
.
glsx
.
smart
.
service
.
impl
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
com.glsx.plat.core.web.R
;
import
com.glsx.smart.dao.entity.SmartProduct
;
import
com.glsx.smart.dao.entity.SmartScene
;
import
com.glsx.smart.dao.entity.SmartScene
;
import
com.glsx.smart.dao.entity.SmartSceneData
;
import
com.glsx.smart.dao.entity.SmartSceneData
;
import
com.glsx.smart.dao.mapper.SmartProductMapper
;
import
com.glsx.smart.dao.mapper.SmartSceneDataMapper
;
import
com.glsx.smart.dao.mapper.SmartSceneDataMapper
;
import
com.glsx.smart.dao.mapper.SmartSceneMapper
;
import
com.glsx.smart.dao.mapper.SmartSceneMapper
;
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.pojo.ExecuteTaskVo
;
import
com.glsx.smart.pojo.ExecuteTaskVo
;
import
com.glsx.smart.pojo.OrderResponse
;
import
com.glsx.smart.pojo.ResponseVo
;
import
com.glsx.smart.pojo.ResponseVo
;
import
com.glsx.smart.service.BaseService
;
import
com.glsx.smart.service.BaseService
;
import
com.glsx.smart.service.SmartSceneService
;
import
com.glsx.smart.service.SmartSceneService
;
...
@@ -44,6 +48,8 @@ public class SmartSceneServiceImpl extends BaseService implements SmartSceneServ
...
@@ -44,6 +48,8 @@ public class SmartSceneServiceImpl extends BaseService implements SmartSceneServ
@Resource
@Resource
private
SmartSceneDataMapper
sceneDataMapper
;
private
SmartSceneDataMapper
sceneDataMapper
;
@Resource
private
SmartProductMapper
productMapper
;
@Value
(
"${orderIssueurl}"
)
@Value
(
"${orderIssueurl}"
)
private
String
orderIssueurl
;
private
String
orderIssueurl
;
...
@@ -146,8 +152,8 @@ public class SmartSceneServiceImpl extends BaseService implements SmartSceneServ
...
@@ -146,8 +152,8 @@ public class SmartSceneServiceImpl extends BaseService implements SmartSceneServ
}
}
@Override
@Override
public
boolean
issueOrder
(
SmartScene
scene
)
{
public
List
<
OrderResponse
>
issueOrder
(
SmartScene
scene
)
{
boolean
flag
=
false
;
List
<
OrderResponse
>
orderResponseList
=
new
ArrayList
<>()
;
List
<
SmartSceneData
>
smartTemplateParamList
=
sceneDataMapper
.
getBySceneId
(
scene
.
getId
());
List
<
SmartSceneData
>
smartTemplateParamList
=
sceneDataMapper
.
getBySceneId
(
scene
.
getId
());
if
(
CollectionUtils
.
isEmpty
(
smartTemplateParamList
))
{
if
(
CollectionUtils
.
isEmpty
(
smartTemplateParamList
))
{
log
.
info
(
"未查到该场景id的条件{}"
,
scene
.
getId
());
log
.
info
(
"未查到该场景id的条件{}"
,
scene
.
getId
());
...
@@ -157,9 +163,9 @@ public class SmartSceneServiceImpl extends BaseService implements SmartSceneServ
...
@@ -157,9 +163,9 @@ public class SmartSceneServiceImpl extends BaseService implements SmartSceneServ
if
(
CollectionUtils
.
isEmpty
(
orders
))
{
if
(
CollectionUtils
.
isEmpty
(
orders
))
{
log
.
info
(
"未查到该场景id的指令{}"
,
scene
.
getId
());
log
.
info
(
"未查到该场景id的指令{}"
,
scene
.
getId
());
}
else
{
}
else
{
int
count
=
0
;
try
{
try
{
for
(
int
i
=
0
;
i
<
orders
.
size
();
i
++)
{
for
(
int
i
=
0
;
i
<
orders
.
size
();
i
++)
{
OrderResponse
orderResponse
=
new
OrderResponse
();
Map
<
String
,
List
<
Map
<
String
,
Object
>>>
ordermaps
=
new
HashMap
<>();
Map
<
String
,
List
<
Map
<
String
,
Object
>>>
ordermaps
=
new
HashMap
<>();
SmartSceneData
index
=
orders
.
get
(
i
);
SmartSceneData
index
=
orders
.
get
(
i
);
List
<
Map
<
String
,
Object
>>
maps
=
new
ArrayList
<>();
List
<
Map
<
String
,
Object
>>
maps
=
new
ArrayList
<>();
...
@@ -195,22 +201,28 @@ public class SmartSceneServiceImpl extends BaseService implements SmartSceneServ
...
@@ -195,22 +201,28 @@ public class SmartSceneServiceImpl extends BaseService implements SmartSceneServ
ResponseVo
responseVo
=
JSONObject
.
toJavaObject
(
jsonObject
,
ResponseVo
.
class
);
ResponseVo
responseVo
=
JSONObject
.
toJavaObject
(
jsonObject
,
ResponseVo
.
class
);
if
(
responseVo
.
getCode
().
equals
(
"200"
))
{
if
(
responseVo
.
getCode
().
equals
(
"200"
))
{
log
.
info
(
"设备{}下发成功"
,
devideId
);
log
.
info
(
"设备{}下发成功"
,
devideId
);
count
++;
orderResponse
.
setMessage
(
"下发成功"
);
orderResponse
.
setResult
(
true
);
}
else
{
}
else
{
log
.
info
(
"设备{}下发失败,错误信息为{}"
,
devideId
,
responseVo
.
getMessage
());
log
.
info
(
"设备{}下发失败,错误信息为{}"
,
devideId
,
responseVo
.
getMessage
());
orderResponse
.
setResult
(
false
);
orderResponse
.
setMessage
(
responseVo
.
getMessage
());
orderResponse
.
setCode
(
Integer
.
parseInt
(
responseVo
.
getCode
()));
}
SmartProduct
smartProduct
=
new
SmartProduct
();
smartProduct
.
setPlatformProductId
(
devideId
);
List
<
SmartProduct
>
byCondition
=
productMapper
.
getByCondition
(
smartProduct
);
if
(
CollectionUtils
.
isNotEmpty
(
byCondition
))
{
orderResponse
.
setDeviceName
(
byCondition
.
get
(
0
).
getProductName
());
}
}
orderResponseList
.
add
(
orderResponse
);
}
}
}
}
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
log
.
info
(
"下发异常,{}"
,
e
);
log
.
info
(
"下发异常,{}"
,
e
);
return
flag
;
}
}
if
(
count
==
orders
.
size
())
{
flag
=
true
;
}
}
}
return
orderResponseList
;
return
flag
;
}
}
}
}
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