Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
孙克
/
smf-core
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
作业
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit e5e54a0c
由
zshaohui
编写于
2023-12-18 14:11:27 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
1.出入库数据统计,7点到7点
2.状态为3时,errorCode为空问题 3.出料口增加心跳发送
1 个父辈
8ee5ccf5
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
75 行增加
和
16 行删除
src/main/java/com/neotel/smfcore/custom/lizhen/kafka/service/KafkaService.java
src/main/java/com/neotel/smfcore/custom/lizhen/kafka/service/KafkaService.java
查看文件 @
e5e54a0
...
...
@@ -10,7 +10,6 @@ import com.neotel.smfcore.core.device.enums.BOX_STATUS;
import
com.neotel.smfcore.core.device.enums.OP
;
import
com.neotel.smfcore.core.device.enums.OP_STATUS
;
import
com.neotel.smfcore.core.device.util.DataCache
;
import
com.neotel.smfcore.core.storage.service.manager.IStoragePosManager
;
import
com.neotel.smfcore.core.storage.service.po.Storage
;
import
com.neotel.smfcore.core.system.service.manager.IDataLogManager
;
import
com.neotel.smfcore.core.system.util.DevicesStatusUtil
;
...
...
@@ -84,14 +83,15 @@ public class KafkaService {
}
String
msg
=
statusBean
.
getMsg
();
String
errorCode
=
statusBean
.
getErrorCode
();
String
[]
msgStr
=
msg
.
split
(
"\r\n"
,
-
1
);
String
[]
errorCodeStr
=
errorCode
.
split
(
"\r\n"
,
-
1
);
for
(
int
i
=
0
;
i
<
errorCodeStr
.
length
;
i
++)
{
Map
<
String
,
String
>
map
=
new
HashMap
<>();
map
.
put
(
"errorCode"
,
errorCodeStr
[
i
]);
map
.
put
(
"msg"
,
msgStr
[
i
]);
msgList
.
add
(
map
);
if
(
StringUtils
.
isNotBlank
(
msg
)
&&
StringUtils
.
isNotBlank
(
errorCode
))
{
String
[]
msgStr
=
msg
.
split
(
"\r\n"
);
String
[]
errorCodeStr
=
errorCode
.
split
(
"\r\n"
);
for
(
int
i
=
0
;
i
<
errorCodeStr
.
length
;
i
++)
{
Map
<
String
,
String
>
map
=
new
HashMap
<>();
map
.
put
(
"errorCode"
,
errorCodeStr
[
i
]);
map
.
put
(
"msg"
,
msgStr
[
i
]);
msgList
.
add
(
map
);
}
}
}
}
...
...
@@ -132,8 +132,13 @@ public class KafkaService {
log
.
info
(
"返回结果为:"
+
JSON
.
toJSONString
(
future
));
}
}
else
{
status
.
setErrorCode
(
""
);
status
.
setErrorMsg
(
""
);
if
(
"3"
.
equals
(
currentStatus
)){
status
.
setErrorCode
(
"10100038"
);
status
.
setErrorMsg
(
"设备未启动"
);
}
else
{
status
.
setErrorCode
(
""
);
status
.
setErrorMsg
(
""
);
}
String
statusStr
=
JSON
.
toJSONString
(
status
);
log
.
info
(
"主题为:"
+
KafkaConfig
.
MACHINESTATUS_TOPIC
+
"内容为:"
+
statusStr
);
ListenableFuture
future
=
kafkaTemplate
.
send
(
KafkaConfig
.
MACHINESTATUS_TOPIC
,
statusStr
);
...
...
@@ -166,8 +171,7 @@ public class KafkaService {
if
(
statusBean
.
timeOut
())
{
normal
=
false
;
}
else
{
int
status
=
statusBean
.
getStatus
();
if
(
status
==
BOX_STATUS
.
EMERGENCY
||
status
==
BOX_STATUS
.
PROBLEM
)
{
if
(!
statusBean
.
isAvailable
())
{
normal
=
false
;
}
}
...
...
@@ -233,6 +237,44 @@ public class KafkaService {
/**
* 发送出料口心跳
*/
@Scheduled
(
fixedRate
=
1000
*
60
*
5
)
public
void
setStorageHeartbeat
()
{
log
.
info
(
"发送出料口心跳开始"
);
for
(
Map
.
Entry
<
String
,
StorageExport
>
exportEntry
:
StorageExportUtil
.
exportMap
.
entrySet
())
{
if
(
exportEntry
.
getKey
().
contains
(
StorageExportUtil
.
OUT_STATION
))
{
continue
;
}
//默认是等待中2,禁用是故障3,有任务是运行1
String
currentStatus
=
"2"
;
StorageExport
export
=
exportEntry
.
getValue
();
if
(
export
.
isDisable
())
{
currentStatus
=
"3"
;
}
else
{
if
(
StringUtils
.
isNotBlank
(
export
.
getHSerial
()))
{
currentStatus
=
"1"
;
}
}
if
(!
"3"
.
equals
(
currentStatus
))
{
Heartbeat
heartbeat
=
new
Heartbeat
();
String
dateStr
=
DateUtil
.
format
(
new
Date
(),
"yyyy-MM-dd HH:mm:ss.SSS"
);
heartbeat
.
setOccurrenceTime
(
dateStr
);
heartbeat
.
setMachineID
(
StorageExportConfig
.
getMachineId
(
exportEntry
.
getKey
()));
heartbeat
.
setTopicType
(
KafkaConfig
.
HEARTBEAT_TOPIC
);
String
statusStr
=
JSON
.
toJSONString
(
heartbeat
);
log
.
info
(
"出料口主题为:"
+
KafkaConfig
.
HEARTBEAT_TOPIC
+
"内容为:"
+
statusStr
);
ListenableFuture
future
=
kafkaTemplate
.
send
(
KafkaConfig
.
HEARTBEAT_TOPIC
,
statusStr
);
log
.
info
(
"出料口返回结果为:"
+
JSON
.
toJSONString
(
future
));
}
}
log
.
info
(
"发送出料口心跳结束"
);
}
/**
* MachineParameter发送
*/
@Scheduled
(
fixedRate
=
1000
*
60
*
5
)
...
...
@@ -287,11 +329,9 @@ public class KafkaService {
public
int
getTodayInOutCount
(
List
<
String
>
storageIdList
,
int
type
)
{
String
todayStr
=
DateUtil
.
today
();
DateTime
today
=
DateUtil
.
parse
(
todayStr
,
"yyyy-MM-dd"
);
Query
q
=
new
Query
();
Criteria
c
=
new
Criteria
();
c
.
and
(
"updateDate"
).
gte
(
today
);
//时间大于今天
c
.
and
(
"updateDate"
).
gte
(
getDate
()
);
//时间大于今天
c
.
and
(
"status"
).
in
(
OP_STATUS
.
END
.
name
(),
OP_STATUS
.
FINISHED
.
name
());
// 任务是完成的
c
.
and
(
"storageId"
).
in
(
storageIdList
);
c
.
and
(
"type"
).
is
(
type
);
...
...
@@ -299,6 +339,25 @@ public class KafkaService {
}
private
Date
getDate
()
{
//1.获取到当前时间
Date
currentDate
=
new
Date
();
//2.获取到今天的开始时间
String
currentDay
=
DateUtil
.
format
(
currentDate
,
"yyyy-MM-dd"
);
currentDay
+=
" 07:00:00"
;
Date
startDate
=
DateUtil
.
parse
(
currentDay
,
"yyyy-MM-dd HH:mm:ss"
);
//3.如果当前时间大于今天开始时间,则返回
if
(
currentDate
.
getTime
()
>
startDate
.
getTime
())
{
return
startDate
;
}
else
{
startDate
=
DateUtil
.
offsetDay
(
startDate
,
-
1
);
}
log
.
info
(
"获取到开始时间为:"
+
startDate
);
return
startDate
;
}
public
List
<
String
>
getMachineIdList
()
{
//找出所有的machineId
List
<
String
>
machineIdList
=
new
ArrayList
<>();
...
...
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论