Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
孙克
/
smf-core
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
作业
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit 889be16a
由
sunke
编写于
2022-10-10 10:16:29 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
机台预警信息处理
1 个父辈
b9b9cab9
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
148 行增加
和
1 行删除
src/main/java/com/neotel/smfcore/common/init/MainTimer.java
src/main/java/com/neotel/smfcore/custom/lizhen/innerBox/bean/PreWarningItem.java
src/main/java/com/neotel/smfcore/custom/lizhen/innerBox/util/PreWarningItemCache.java
src/main/java/com/neotel/smfcore/common/init/MainTimer.java
查看文件 @
889be16
...
...
@@ -6,6 +6,7 @@ import com.neotel.smfcore.core.system.service.po.DataLog;
import
com.neotel.smfcore.core.system.util.DevicesStatusUtil
;
import
com.neotel.smfcore.core.system.util.EquipStatusUtil
;
import
com.neotel.smfcore.core.system.util.TaskService
;
import
com.neotel.smfcore.custom.lizhen.innerBox.util.PreWarningItemCache
;
import
org.apache.logging.log4j.LogManager
;
import
org.apache.logging.log4j.Logger
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -59,8 +60,8 @@ public class MainTimer {
private
void
timerTask
(){
try
{
PreWarningItemCache
.
runTimer
();
liteOrderCache
.
runTimer
();
//设备状态判断
DevicesStatusUtil
.
runTimer
();
...
...
src/main/java/com/neotel/smfcore/custom/lizhen/innerBox/bean/PreWarningItem.java
查看文件 @
889be16
...
...
@@ -2,6 +2,8 @@ package com.neotel.smfcore.custom.lizhen.innerBox.bean;
import
lombok.Data
;
import
java.util.Date
;
/**
* 接收到的机台预警(出库信息)
* @author sunke
...
...
@@ -24,4 +26,9 @@ public class PreWarningItem {
private
String
slot
;
private
String
subslot
;
private
String
partnumber
;
/**
* 接收时间
*/
private
Date
receiveDate
=
new
Date
();
}
src/main/java/com/neotel/smfcore/custom/lizhen/innerBox/util/PreWarningItemCache.java
查看文件 @
889be16
package
com
.
neotel
.
smfcore
.
custom
.
lizhen
.
innerBox
.
util
;
import
com.neotel.smfcore.core.device.util.DataCache
;
import
com.neotel.smfcore.core.order.LiteOrderCache
;
import
com.neotel.smfcore.core.storage.enums.DeviceType
;
import
com.neotel.smfcore.core.storage.service.po.Storage
;
import
com.neotel.smfcore.core.system.service.po.DataLog
;
import
com.neotel.smfcore.core.system.util.TaskService
;
import
com.neotel.smfcore.custom.lizhen.innerBox.bean.PreWarningItem
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.logging.log4j.util.Strings
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
java.util.ArrayList
;
import
java.util.Collection
;
import
java.util.List
;
import
java.util.concurrent.CopyOnWriteArrayList
;
/**
* 机台预警信息缓存
* @author sunke
* @date 2022/10/9 3:31 PM
*/
@Slf4j
public
class
PreWarningItemCache
{
/**
* 预警列表缓存
*/
private
static
List
<
PreWarningItem
>
queueItemList
=
new
CopyOnWriteArrayList
<>();
private
static
LiteOrderCache
liteOrderCache
;
private
static
TaskService
taskService
;
private
static
DataCache
dataCache
;
/**
* 添加到预警列表缓存中
*/
public
static
void
addItems
(
List
<
PreWarningItem
>
items
){
updateItem
(
items
,
false
);
}
/**
* 从缓存列表中取出预警Item生成工单并执行
*/
private
static
void
generateTask
(){
boolean
hasIdleBox
=
false
;
//有料仓空闲下来就需要生成任务,保证料仓不空闲,提高节拍
Collection
<
Storage
>
boxList
=
dataCache
.
getAllStorage
().
values
();
for
(
Storage
storage
:
boxList
)
{
if
(
storage
.
isStorage
(
DeviceType
.
SMD_XLR
)){
Collection
<
DataLog
>
boxQueueTasks
=
taskService
.
getQueueTasks
(
storage
.
getCid
());
if
(
boxQueueTasks
.
isEmpty
()){
//料仓空闲,没有待执行的任务
hasIdleBox
=
true
;
break
;
}
}
}
if
(
hasIdleBox
){
//最早的一条预警时间
List
<
PreWarningItem
>
lineItems
=
new
ArrayList
<>();
String
firstItemLine
=
""
;
//每次最多出多少盘
int
maxReelCount
=
30
;
for
(
PreWarningItem
preWarningItem
:
queueItemList
)
{
String
itemLine
=
preWarningItem
.
getLine
();
if
(
Strings
.
isNotBlank
(
itemLine
)){
if
(
firstItemLine
.
isEmpty
()){
firstItemLine
=
itemLine
;
if
(
preWarningItem
.
getReceiveDate
().
getTime
()
-
System
.
currentTimeMillis
()
<
1
*
60
*
1000
){
//不到1分钟,暂不执行
return
;
}
}
//同一个线别的生成一个工单
if
(
itemLine
.
equals
(
firstItemLine
)){
lineItems
.
add
(
preWarningItem
);
}
if
(
lineItems
.
size
()
>
maxReelCount
){
break
;
}
}
}
if
(!
lineItems
.
isEmpty
()){
createAndExecuteLiteOrder
(
lineItems
);
//工单生成后,从缓存中清除
updateItem
(
lineItems
,
true
);
}
}
}
/**
* 根据预警信息挑选物料, 生成工单任务并执行
* @param lineItems
*/
private
static
void
createAndExecuteLiteOrder
(
List
<
PreWarningItem
>
lineItems
){
//TODO: 挑选物料,生成工单任务并执行
}
private
static
synchronized
void
updateItem
(
List
<
PreWarningItem
>
items
,
boolean
remove
){
if
(
remove
){
queueItemList
.
remove
(
items
);
}
else
{
queueItemList
.
addAll
(
items
);
}
}
private
static
boolean
processing
=
false
;
/**
* 定时执行,从缓存列表中取出预警Item生成工单并执行
*/
public
static
void
runTimer
(){
if
(
processing
){
return
;
}
processing
=
true
;
try
{
generateTask
();
}
catch
(
Exception
e
){
log
.
error
(
"预警缓存定时器出错"
,
e
);
}
finally
{
processing
=
false
;
}
}
@Autowired
public
void
setTaskService
(
TaskService
taskService
)
{
PreWarningItemCache
.
taskService
=
taskService
;
}
@Autowired
public
void
setLiteOrderCache
(
LiteOrderCache
liteOrderCache
)
{
PreWarningItemCache
.
liteOrderCache
=
liteOrderCache
;
}
@Autowired
public
void
setDataCache
(
DataCache
dataCache
)
{
PreWarningItemCache
.
dataCache
=
dataCache
;
}
}
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论