Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
孙克
/
smf-core
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
作业
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit 5533f4dc
由
zshaohui
编写于
2024-09-04 14:09:21 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
抛送出料口设备信息和心跳到中控
1 个父辈
68f6a5ae
显示空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
102 行增加
和
92 行删除
src/main/java/com/neotel/smfcore/custom/lizhen/kafka/service/KafkaService.java
src/main/java/com/neotel/smfcore/custom/lizhen/kafka/service/KafkaService.java
查看文件 @
5533f4d
...
...
@@ -56,7 +56,7 @@ public class KafkaService {
/**
*
设备状态发送
*
料仓---设备状态
*/
@Scheduled
(
fixedRate
=
1000
*
60
*
1
)
public
void
setMachineStatus
()
{
...
...
@@ -156,7 +156,7 @@ public class KafkaService {
/**
*
心跳数据发送
*
料仓--心跳数据
*/
@Scheduled
(
fixedRate
=
1000
*
60
*
5
)
public
void
setHeartbeat
()
{
...
...
@@ -201,9 +201,103 @@ public class KafkaService {
/**
* MachineParameter发送
*/
@Scheduled
(
fixedRate
=
1000
*
60
*
5
)
public
void
setMachineParameter
()
{
log
.
info
(
"MachineParameter开始发送"
);
List
<
String
>
machineIdList
=
getMachineIdList
();
for
(
String
machineId
:
machineIdList
)
{
List
<
String
>
storageIdList
=
new
ArrayList
<>();
int
totalCount
=
0
;
int
usedCount
=
0
;
int
emptyCount
=
0
;
List
<
Storage
>
storageList
=
dataCache
.
getStorageByMachineId
(
machineId
);
for
(
Storage
storage
:
storageList
)
{
totalCount
=
totalCount
+
storage
.
getTotalSlots
();
emptyCount
=
emptyCount
+
storage
.
getEmptySlots
();
usedCount
=
usedCount
+
(
storage
.
getTotalSlots
()
-
storage
.
getEmptySlots
());
storageIdList
.
add
(
storage
.
getId
());
}
int
todayInCount
=
getTodayInOutCount
(
storageIdList
,
OP
.
PUT_IN
);
int
todayOutCount
=
getTodayInOutCount
(
storageIdList
,
OP
.
CHECKOUT
);
MachineParameter
machineParameter
=
new
MachineParameter
();
String
dateStr
=
DateUtil
.
format
(
new
Date
(),
"yyyy-MM-dd HH:mm:ss.SSS"
);
machineParameter
.
setOccurrenceTime
(
dateStr
);
machineParameter
.
setMachineID
(
machineId
);
machineParameter
.
setContentType
(
"F"
);
machineParameter
.
setMachineType
(
"智能仓储位"
);
machineParameter
.
setSupplierID
(
"NEOTEL"
);
machineParameter
.
setProgramName
(
""
);
machineParameter
.
setProgramVersion
(
""
);
machineParameter
.
setSerialNumber
(
""
);
machineParameter
.
setResult
(
""
);
machineParameter
.
setEmpNo
(
""
);
machineParameter
.
setClientIP
(
""
);
List
<
MachineParameterData
>
dataList
=
new
ArrayList
<>();
dataList
.
add
(
new
MachineParameterData
(
"totalCount"
,
totalCount
+
""
));
dataList
.
add
(
new
MachineParameterData
(
"emptyCount"
,
emptyCount
+
""
));
dataList
.
add
(
new
MachineParameterData
(
"usedCount"
,
usedCount
+
""
));
dataList
.
add
(
new
MachineParameterData
(
"todayInCount"
,
todayInCount
+
""
));
dataList
.
add
(
new
MachineParameterData
(
"todayOutCount"
,
todayOutCount
+
""
));
machineParameter
.
setData
(
dataList
);
String
machineParameterStr
=
JSON
.
toJSONString
(
machineParameter
);
//log.info("MachineParameter主题为:" + KafkaConfig.MACHINEPARAMETER_TOPIC + "内容为:" + machineParameterStr);
ListenableFuture
future
=
kafkaTemplate
.
send
(
KafkaConfig
.
MACHINEPARAMETER_TOPIC
,
machineParameterStr
);
//log.info("MachineParameter返回结果为:" + JSON.toJSONString(future));
}
log
.
info
(
"MachineParameter结束发送"
);
}
//发送出料口信息
/**
* 发送出料口心跳
*/
@Scheduled
(
fixedRate
=
1000
*
60
*
5
)
public
void
setStorageHeartbeat
()
{
log
.
info
(
"发送出料口心跳开始"
);
EquipStatusBean
statusBean
=
EquipStatusUtil
.
getStatusBean
(
KafkaConfig
.
LINE_CID
);
List
<
EquipStatus
>
statusList
=
statusBean
.
getStatusList
();
if
(
statusList
!=
null
&&
!
statusList
.
isEmpty
())
{
for
(
EquipStatus
equipStatus
:
statusList
)
{
int
status
=
equipStatus
.
getStatus
();
//状态
String
module
=
equipStatus
.
getModule
();
//出口
String
currentStatus
=
"1"
;
//正常
if
(
2
==
status
||
3
==
status
)
{
currentStatus
=
"3"
;
//故障
}
if
(
0
==
status
)
{
currentStatus
=
"5"
;
//离线
}
if
(
"1"
.
equals
(
currentStatus
))
{
Heartbeat
heartbeat
=
new
Heartbeat
();
String
dateStr
=
DateUtil
.
format
(
new
Date
(),
"yyyy-MM-dd HH:mm:ss.SSS"
);
heartbeat
.
setOccurrenceTime
(
dateStr
);
heartbeat
.
setMachineID
(
module
);
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
(
"发送出料口心跳结束"
);
}
/**
* 设备状态发送
*/
@Scheduled
(
fixedRate
=
1000
*
60
*
1
)
@Scheduled
(
fixedRate
=
1000
*
60
*
5
)
public
void
setStorageExportStatus
()
{
log
.
info
(
"发送出料口信息开始"
);
...
...
@@ -244,24 +338,24 @@ public class KafkaService {
machineStatus
.
setErrorMsg
(
equipMsg
.
getMsg
());
machineStatus
.
setClientIP
(
""
);
String
statusStr
=
JSON
.
toJSONString
(
machineStatus
);
//
log.info("出料口主题为:" + KafkaConfig.MACHINESTATUS_TOPIC + "内容为:" + statusStr);
log
.
info
(
"出料口主题为:"
+
KafkaConfig
.
MACHINESTATUS_TOPIC
+
"内容为:"
+
statusStr
);
ListenableFuture
future
=
kafkaTemplate
.
send
(
KafkaConfig
.
MACHINESTATUS_TOPIC
,
statusStr
);
//
log.info("出料口返回结果为:" + JSON.toJSONString(future));
log
.
info
(
"出料口返回结果为:"
+
JSON
.
toJSONString
(
future
));
}
}
else
{
MachineStatus
machineStatus
=
new
MachineStatus
();
String
dateStr
=
DateUtil
.
format
(
new
Date
(),
"yyyy-MM-dd HH:mm:ss.SSS"
);
machineStatus
.
setOccurrenceTime
(
dateStr
);
machineStatus
.
setMachineID
(
StorageExportConfig
.
getMachineId
(
module
)
);
machineStatus
.
setMachineID
(
module
);
machineStatus
.
setTopicType
(
KafkaConfig
.
MACHINESTATUS_TOPIC
);
machineStatus
.
setCurrentStatus
(
currentStatus
);
machineStatus
.
setErrorCode
(
""
);
machineStatus
.
setErrorMsg
(
""
);
machineStatus
.
setClientIP
(
""
);
String
statusStr
=
JSON
.
toJSONString
(
machineStatus
);
//
log.info("出料口主题为:" + KafkaConfig.MACHINESTATUS_TOPIC + "内容为:" + statusStr);
log
.
info
(
"出料口主题为:"
+
KafkaConfig
.
MACHINESTATUS_TOPIC
+
"内容为:"
+
statusStr
);
ListenableFuture
future
=
kafkaTemplate
.
send
(
KafkaConfig
.
MACHINESTATUS_TOPIC
,
statusStr
);
//
log.info("出料口返回结果为:" + JSON.toJSONString(future));
log
.
info
(
"出料口返回结果为:"
+
JSON
.
toJSONString
(
future
));
}
}
}
...
...
@@ -269,94 +363,10 @@ public class KafkaService {
}
/**
* 发送出料口心跳
*/
@Scheduled
(
fixedRate
=
1000
*
60
*
5
)
public
void
setStorageHeartbeat
()
{
log
.
info
(
"发送出料口心跳开始"
);
EquipStatusBean
statusBean
=
EquipStatusUtil
.
getStatusBean
(
KafkaConfig
.
LINE_CID
);
List
<
EquipStatus
>
statusList
=
statusBean
.
getStatusList
();
if
(
statusList
!=
null
&&
!
statusList
.
isEmpty
())
{
for
(
EquipStatus
equipStatus
:
statusList
)
{
int
status
=
equipStatus
.
getStatus
();
//状态
String
module
=
equipStatus
.
getModule
();
//出口
String
currentStatus
=
"1"
;
//正常
if
(
2
==
status
||
3
==
status
)
{
currentStatus
=
"3"
;
//故障
}
if
(
0
==
status
)
{
currentStatus
=
"5"
;
//离线
}
if
(
"1"
.
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
(
module
));
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
)
public
void
setMachineParameter
()
{
log
.
info
(
"MachineParameter开始发送"
);
List
<
String
>
machineIdList
=
getMachineIdList
();
for
(
String
machineId
:
machineIdList
)
{
List
<
String
>
storageIdList
=
new
ArrayList
<>();
int
totalCount
=
0
;
int
usedCount
=
0
;
int
emptyCount
=
0
;
List
<
Storage
>
storageList
=
dataCache
.
getStorageByMachineId
(
machineId
);
for
(
Storage
storage
:
storageList
)
{
totalCount
=
totalCount
+
storage
.
getTotalSlots
();
emptyCount
=
emptyCount
+
storage
.
getEmptySlots
();
usedCount
=
usedCount
+
(
storage
.
getTotalSlots
()
-
storage
.
getEmptySlots
());
storageIdList
.
add
(
storage
.
getId
());
}
int
todayInCount
=
getTodayInOutCount
(
storageIdList
,
OP
.
PUT_IN
);
int
todayOutCount
=
getTodayInOutCount
(
storageIdList
,
OP
.
CHECKOUT
);
MachineParameter
machineParameter
=
new
MachineParameter
();
String
dateStr
=
DateUtil
.
format
(
new
Date
(),
"yyyy-MM-dd HH:mm:ss.SSS"
);
machineParameter
.
setOccurrenceTime
(
dateStr
);
machineParameter
.
setMachineID
(
machineId
);
machineParameter
.
setContentType
(
"F"
);
machineParameter
.
setMachineType
(
"智能仓储位"
);
machineParameter
.
setSupplierID
(
"NEOTEL"
);
machineParameter
.
setProgramName
(
""
);
machineParameter
.
setProgramVersion
(
""
);
machineParameter
.
setSerialNumber
(
""
);
machineParameter
.
setResult
(
""
);
machineParameter
.
setEmpNo
(
""
);
machineParameter
.
setClientIP
(
""
);
List
<
MachineParameterData
>
dataList
=
new
ArrayList
<>();
dataList
.
add
(
new
MachineParameterData
(
"totalCount"
,
totalCount
+
""
));
dataList
.
add
(
new
MachineParameterData
(
"emptyCount"
,
emptyCount
+
""
));
dataList
.
add
(
new
MachineParameterData
(
"usedCount"
,
usedCount
+
""
));
dataList
.
add
(
new
MachineParameterData
(
"todayInCount"
,
todayInCount
+
""
));
dataList
.
add
(
new
MachineParameterData
(
"todayOutCount"
,
todayOutCount
+
""
));
machineParameter
.
setData
(
dataList
);
String
machineParameterStr
=
JSON
.
toJSONString
(
machineParameter
);
//log.info("MachineParameter主题为:" + KafkaConfig.MACHINEPARAMETER_TOPIC + "内容为:" + machineParameterStr);
ListenableFuture
future
=
kafkaTemplate
.
send
(
KafkaConfig
.
MACHINEPARAMETER_TOPIC
,
machineParameterStr
);
//log.info("MachineParameter返回结果为:" + JSON.toJSONString(future));
}
log
.
info
(
"MachineParameter结束发送"
);
}
public
int
getTodayInOutCount
(
List
<
String
>
storageIdList
,
int
type
)
{
...
...
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论