Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
孙克
/
SmdBox
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
作业
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit f06b450c
由
zshaohui
编写于
2022-09-19 16:02:23 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
1.版本回退
2.提交指令功能代码
1 个父辈
d552d15a
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
123 行增加
和
0 行删除
myproject/src/main/java/com/myproject/bean/Command.java
myproject/src/main/java/com/myproject/bean/utils/StatusBean.java
myproject/src/main/java/com/myproject/webapp/controller/CommandController.java
myproject/src/main/java/com/myproject/bean/Command.java
0 → 100644
查看文件 @
f06b450
package
com
.
myproject
.
bean
;
public
class
Command
{
private
String
cid
;
private
String
name
;
private
Integer
value
;
@Override
public
String
toString
()
{
return
"Command{"
+
"cid='"
+
cid
+
'\''
+
", name='"
+
name
+
'\''
+
", value="
+
value
+
'}'
;
}
public
String
getCid
()
{
return
cid
;
}
public
void
setCid
(
String
cid
)
{
this
.
cid
=
cid
;
}
public
String
getName
()
{
return
name
;
}
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
public
Integer
getValue
()
{
return
value
;
}
public
void
setValue
(
Integer
value
)
{
this
.
value
=
value
;
}
}
myproject/src/main/java/com/myproject/bean/utils/StatusBean.java
查看文件 @
f06b450
...
@@ -220,6 +220,10 @@ public class StatusBean {
...
@@ -220,6 +220,10 @@ public class StatusBean {
public
void
addOp
(
Map
<
String
,
String
>
opMap
){
public
void
addOp
(
Map
<
String
,
String
>
opMap
){
if
(
opMap
!=
null
&&
!
opMap
.
isEmpty
()){
if
(
opMap
!=
null
&&
!
opMap
.
isEmpty
()){
for
(
Map
.
Entry
<
String
,
String
>
op
:
opMap
.
entrySet
())
{
for
(
Map
.
Entry
<
String
,
String
>
op
:
opMap
.
entrySet
())
{
if
(
"NEED_EMPTY"
.
equals
(
op
.
getKey
())
||
"TAKE_STATUS"
.
equals
(
op
.
getKey
())
||
"OUT_STATUS"
.
equals
(
op
.
getKey
())
||
"IN_STATUS"
.
equals
(
op
.
getKey
()))
{
continue
;
}
data
.
put
(
op
.
getKey
(),
op
.
getValue
());
data
.
put
(
op
.
getKey
(),
op
.
getValue
());
}
}
}
}
...
...
myproject/src/main/java/com/myproject/webapp/controller/CommandController.java
0 → 100644
查看文件 @
f06b450
package
com
.
myproject
.
webapp
.
controller
;
import
com.myproject.bean.Command
;
import
com.myproject.bean.json.ResultBean
;
import
com.myproject.bean.utils.StatusBean
;
import
com.myproject.webapp.controller.webService.ITaskService
;
import
com.myproject.webapp.controller.webService.StorageDataController
;
import
org.apache.logging.log4j.LogManager
;
import
org.apache.logging.log4j.Logger
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
java.util.Map
;
@RequestMapping
(
"/smf/rest/api"
)
public
class
CommandController
{
@Autowired
private
ITaskService
taskService
;
protected
final
transient
Logger
log
=
LogManager
.
getLogger
(
getClass
());
/**
* 接收指令
*
* @param command
* @return
*/
@RequestMapping
(
value
=
"/opDeviceIo"
)
public
ResultBean
opDeviceIo
(
@RequestBody
Command
command
)
{
String
cid
=
command
.
getCid
();
String
name
=
command
.
getName
();
Integer
value
=
command
.
getValue
();
log
.
info
(
"{}收到数据为:{}"
,
"opDeviceIo"
,
cid
+
"--"
+
"--"
+
name
+
"--"
+
value
);
if
(
"NEED_EMPTY"
.
equals
(
name
)
||
"TAKE_STATUS"
.
equals
(
name
)
||
"OUT_STATUS"
.
equals
(
name
)
||
"IN_STATUS"
.
equals
(
name
))
{
return
ResultBean
.
newErrorResult
(-
1
,
"No Implementation"
);
}
String
opValue
=
""
;
if
(
value
==
0
)
{
opValue
=
"close"
;
}
else
if
(
value
==
1
)
{
opValue
=
"open"
;
}
StorageDataController
.
addOp
(
cid
,
name
,
opValue
);
return
ResultBean
.
newOkResult
(
""
);
}
/**
* 获取指定
*
* @param params
* @return
*/
@RequestMapping
(
value
=
"/getStatus"
)
public
ResultBean
getStatus
(
@RequestBody
Map
<
String
,
String
>
params
)
{
String
cid
=
params
.
get
(
"cid"
);
String
name
=
params
.
get
(
"name"
);
log
.
info
(
"{}收到数据为:{}"
,
"getStatus"
,
cid
+
"--"
+
"--"
+
name
);
if
(
"NEED_EMPTY"
.
equals
(
name
)
||
"TAKE_STATUS"
.
equals
(
name
)
||
"OUT_STATUS"
.
equals
(
name
)
||
"IN_STATUS"
.
equals
(
name
))
{
return
ResultBean
.
newErrorResult
(-
1
,
"No Implementation"
);
}
StatusBean
statusBean
=
taskService
.
getStatus
(
cid
);
log
.
info
(
"是否存在为:"
+
statusBean
==
null
);
if
(
statusBean
!=
null
)
{
String
value
=
statusBean
.
getFromData
(
name
);
Integer
opValue
=
null
;
if
(
"open"
.
equals
(
value
)
||
"1"
.
equals
(
value
))
{
opValue
=
1
;
}
else
if
(
"close"
.
equals
(
value
)
||
"0"
.
equals
(
value
))
{
opValue
=
0
;
}
if
(
opValue
!=
null
)
{
return
ResultBean
.
newOkResult
(
opValue
);
}
}
return
ResultBean
.
newErrorResult
(-
1
,
"Not Found"
);
}
}
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论