Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
孙克
/
smf-core
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
作业
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit 3be0048e
由
zshaohui
编写于
2023-11-22 14:46:07 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
工单出库逻辑修改
1 个父辈
8fde5746
显示空白字符变更
内嵌
并排
正在显示
19 个修改的文件
包含
284 行增加
和
151 行删除
src/main/java/com/neotel/smfcore/SmfCoreApplication.java
src/main/java/com/neotel/smfcore/common/init/MainTimer.java
src/main/java/com/neotel/smfcore/common/utils/Constants.java
src/main/java/com/neotel/smfcore/common/utils/HttpHelper.java
src/main/java/com/neotel/smfcore/core/device/util/DataCache.java
src/main/java/com/neotel/smfcore/core/order/service/po/LiteOrderItem.java
src/main/java/com/neotel/smfcore/core/system/rest/SettingsController.java
src/main/java/com/neotel/smfcore/core/system/rest/bean/LineConfig.java
src/main/java/com/neotel/smfcore/core/system/rest/bean/dto/SysSettingsDto.java
src/main/java/com/neotel/smfcore/core/system/util/TaskService.java
src/main/java/com/neotel/smfcore/custom/lizhen/LizhenApi.java
src/main/java/com/neotel/smfcore/custom/lizhen/LizhenController.java
src/main/java/com/neotel/smfcore/custom/lizhen/innerBox/rest/InnerBoxRestController.java
src/main/java/com/neotel/smfcore/custom/lizhen/innerBox/rest/PrinterRestController.java
src/main/java/com/neotel/smfcore/custom/lizhen/innerBox/util/PreWarningItemCache.java
src/main/java/com/neotel/smfcore/custom/lizhen/kafka/service/KafkaService.java
src/main/java/com/neotel/smfcore/custom/lizhen/report/inner/InnerReportController.java
src/main/java/com/neotel/smfcore/custom/lizhen/third/maicheng/util/StationStatusCache.java
src/main/resources/config/application.yml
src/main/java/com/neotel/smfcore/SmfCoreApplication.java
查看文件 @
3be0048
...
...
@@ -15,7 +15,7 @@ import org.springframework.scheduling.annotation.EnableScheduling;
import
org.springframework.web.bind.annotation.RestController
;
//@EnableAsync
@EnableScheduling
//
@EnableScheduling
@EnableKafka
@RestController
@SpringBootApplication
...
...
src/main/java/com/neotel/smfcore/common/init/MainTimer.java
查看文件 @
3be0048
...
...
@@ -46,7 +46,7 @@ public class MainTimer {
public
void
run
()
{
timerTask
();
}
},
5
,
1
0
,
TimeUnit
.
SECONDS
);
},
5
,
3
0
,
TimeUnit
.
SECONDS
);
//log.info("如果是人工叫料,则每2分钟执行一次");
scheduledThreadPool
.
scheduleAtFixedRate
(
new
Runnable
()
{
...
...
@@ -72,18 +72,11 @@ public class MainTimer {
}
private
void
timerTask
()
{
if
(!
preGenerateTaskTime
())
{
return
;
}
lastPreGenerateTaskTime
=
System
.
currentTimeMillis
();
try
{
log
.
info
(
"生成缺料预警任务"
);
//PreWarningItemCache.runTimer(0);
PreWarningItemCache
.
runTimer
(
1
);
//liteOrderCache.runTimer(0);
//log.info("生成缺料预警任务");
PreWarningItemCache
.
runTimer
();
//设备状态判断
DevicesStatusUtil
.
runTimer
();
//其他设备状态判断
EquipStatusUtil
.
runTimer
();
}
catch
(
Exception
e
)
{
...
...
src/main/java/com/neotel/smfcore/common/utils/Constants.java
查看文件 @
3be0048
...
...
@@ -175,4 +175,14 @@ public class Constants {
* 工单生成个数
*/
public
static
final
String
CACHE_preGenerateTask_Times
=
"preGenerateTask_times"
;
/**
* 线体配置
*/
public
static
final
String
CACHE_lineConfigList
=
"CACHE_lineConfigList"
;
/**
* 迈征配置分钟
*/
public
static
final
String
CACHE_maiZhengMinute
=
"maiZhengMinute"
;
}
src/main/java/com/neotel/smfcore/common/utils/HttpHelper.java
查看文件 @
3be0048
...
...
@@ -46,24 +46,36 @@ public class HttpHelper {
ObjectMapper
mapper
=
new
ObjectMapper
();
try
{
String
requestBody
=
mapper
.
writeValueAsString
(
object
);
httpPost
.
setEntity
(
new
StringEntity
(
requestBody
,
CONTENT_CHARSET
));
httpPost
.
setEntity
(
new
StringEntity
(
requestBody
,
CONTENT_CHARSET
));
}
catch
(
JsonProcessingException
e
)
{
throw
new
ApiException
(
"Request params to ["
+
url
+
"] failed:"
+
e
.
getMessage
());
}
catch
(
Exception
e
)
{
throw
new
ApiException
(
"Request params to ["
+
url
+
"] failed:"
+
e
.
getMessage
());
}
}
try
{
CloseableHttpClient
httpClient
=
HttpClients
.
createDefault
();
CloseableHttpResponse
response
=
httpClient
.
execute
(
httpPost
);
CloseableHttpClient
httpClient
=
null
;
CloseableHttpResponse
response
=
null
;
try
{
httpClient
=
HttpClients
.
createDefault
();
response
=
httpClient
.
execute
(
httpPost
);
//System.out.println(response.getStatusLine().getStatusCode() + "\n");
HttpEntity
entity
=
response
.
getEntity
();
String
responseContent
=
EntityUtils
.
toString
(
entity
,
CONTENT_CHARSET
);
response
.
close
();
httpClient
.
close
();
return
responseContent
;
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
throw
new
ApiException
(
"Request to ["
+
url
+
"] failed:"
+
e
.
getMessage
());
}
finally
{
try
{
if
(
response
!=
null
)
{
response
.
close
();
}
if
(
httpClient
!=
null
)
{
httpClient
.
close
();
}
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
}
}
...
...
@@ -76,24 +88,37 @@ public class HttpHelper {
ObjectMapper
mapper
=
new
ObjectMapper
();
try
{
String
requestBody
=
mapper
.
writeValueAsString
(
params
);
httpPost
.
setEntity
(
new
StringEntity
(
requestBody
,
CONTENT_CHARSET
));
httpPost
.
setEntity
(
new
StringEntity
(
requestBody
,
CONTENT_CHARSET
));
}
catch
(
JsonProcessingException
e
)
{
throw
new
ApiException
(
"Request params to ["
+
url
+
"] failed:"
+
e
.
getMessage
());
}
catch
(
Exception
e
)
{
throw
new
ApiException
(
"Request params to ["
+
url
+
"] failed:"
+
e
.
getMessage
());
}
}
try
{
CloseableHttpClient
httpClient
=
HttpClients
.
createDefault
();
CloseableHttpResponse
response
=
httpClient
.
execute
(
httpPost
);
CloseableHttpClient
httpClient
=
null
;
CloseableHttpResponse
response
=
null
;
try
{
httpClient
=
HttpClients
.
createDefault
();
response
=
httpClient
.
execute
(
httpPost
);
//System.out.println(response.getStatusLine().getStatusCode() + "\n");
HttpEntity
entity
=
response
.
getEntity
();
String
responseContent
=
EntityUtils
.
toString
(
entity
,
CONTENT_CHARSET
);
response
.
close
();
httpClient
.
close
();
return
responseContent
;
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
throw
new
ApiException
(
"Request to ["
+
url
+
"] failed:"
+
e
.
getMessage
());
}
finally
{
try
{
if
(
response
!=
null
)
{
response
.
close
();
}
if
(
httpClient
!=
null
)
{
httpClient
.
close
();
}
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
}
}
...
...
@@ -122,15 +147,16 @@ public class HttpHelper {
params
.
add
(
new
BasicNameValuePair
(
entry
.
getKey
(),
value
));
}
}
CloseableHttpClient
httpClient
=
null
;
CloseableHttpResponse
response
=
null
;
try
{
URI
uri
=
new
URIBuilder
(
url
).
setParameters
(
params
).
build
();
log
.
info
(
"执行MES请求:"
+
uri
.
toString
());
HttpPost
httpPost
=
new
HttpPost
(
uri
);
httpPost
.
addHeader
(
"Content-Type"
,
"application/json;charset=utf-8"
);
// httpPost.setEntity(new UrlEncodedFormEntity(params, CONTENT_CHARSET));
CloseableHttpClient
httpClient
=
HttpClients
.
createDefault
();
CloseableHttpResponse
response
=
httpClient
.
execute
(
httpPost
);
httpClient
=
HttpClients
.
createDefault
();
response
=
httpClient
.
execute
(
httpPost
);
HttpEntity
entity
=
response
.
getEntity
();
String
responseContent
=
EntityUtils
.
toString
(
entity
,
CONTENT_CHARSET
);
response
.
close
();
...
...
@@ -138,6 +164,17 @@ public class HttpHelper {
return
responseContent
;
}
catch
(
Exception
e
)
{
throw
new
ApiException
(
"Request params to ["
+
url
+
"] failed:"
+
e
.
getMessage
());
}
finally
{
try
{
if
(
response
!=
null
)
{
response
.
close
();
}
if
(
httpClient
!=
null
)
{
httpClient
.
close
();
}
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
}
}
...
...
@@ -156,9 +193,10 @@ public class HttpHelper {
.
setConnectTimeout
(
5000
)
.
setConnectionRequestTimeout
(
5000
).
build
();
httpget
.
setConfig
(
build
);
CloseableHttpClient
httpClient
=
null
;
CloseableHttpResponse
response
=
null
;
try
{
CloseableHttpClient
httpClient
=
HttpClients
.
createDefault
();
httpClient
=
HttpClients
.
createDefault
();
response
=
httpClient
.
execute
(
httpget
);
}
catch
(
IOException
e1
)
{
e1
.
printStackTrace
();
...
...
@@ -173,7 +211,12 @@ public class HttpHelper {
e
.
printStackTrace
();
}
finally
{
try
{
if
(
httpClient
!=
null
){
httpClient
.
close
();
}
if
(
response
!=
null
)
{
response
.
close
();
}
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
...
...
src/main/java/com/neotel/smfcore/core/device/util/DataCache.java
查看文件 @
3be0048
...
...
@@ -23,6 +23,7 @@ import com.neotel.smfcore.core.storage.service.manager.IStoragePosManager;
import
com.neotel.smfcore.core.storage.service.po.Storage
;
import
com.neotel.smfcore.core.storage.service.po.StoragePos
;
import
com.neotel.smfcore.core.system.bean.OrderSetting
;
import
com.neotel.smfcore.core.system.rest.bean.LineConfig
;
import
com.neotel.smfcore.core.system.service.dao.ICacheItemDao
;
import
com.neotel.smfcore.core.system.service.dao.ISettingsDao
;
import
com.neotel.smfcore.core.system.service.po.CacheItem
;
...
...
@@ -709,4 +710,16 @@ public class DataCache {
}
return
0
;
}
public
int
getLineConfigMinute
(
String
line
)
{
List
<
LineConfig
>
lineConfigList
=
getCache
(
Constants
.
CACHE_lineConfigList
);
if
(
lineConfigList
!=
null
&&
!
lineConfigList
.
isEmpty
()){
for
(
LineConfig
lineConfig
:
lineConfigList
)
{
if
(
lineConfig
.
getLine
().
equals
(
line
)){
return
lineConfig
.
getMinute
();
}
}
}
return
0
;
}
}
src/main/java/com/neotel/smfcore/core/order/service/po/LiteOrderItem.java
查看文件 @
3be0048
...
...
@@ -219,6 +219,9 @@ public class LiteOrderItem extends BasePo implements Serializable ,Comparable<Li
*/
private
Date
issuanceDate
;
private
Date
receiveDate
;
/**
* 出库是否满足要求,已出库数量大于需求数量
*/
...
...
src/main/java/com/neotel/smfcore/core/system/rest/SettingsController.java
查看文件 @
3be0048
...
...
@@ -13,6 +13,7 @@ import com.neotel.smfcore.core.language.service.po.LanguageMsg;
import
com.neotel.smfcore.core.storage.enums.DeviceType
;
import
com.neotel.smfcore.core.storage.service.po.Storage
;
import
com.neotel.smfcore.core.system.bean.OrderSetting
;
import
com.neotel.smfcore.core.system.rest.bean.LineConfig
;
import
com.neotel.smfcore.core.system.rest.bean.dto.SettingsDto
;
import
com.neotel.smfcore.core.system.rest.bean.dto.SysSettingsDto
;
import
com.neotel.smfcore.core.system.rest.bean.mapstruct.SettingsMapper
;
...
...
@@ -76,6 +77,9 @@ public class SettingsController {
String
permissionPassword
=
dataCache
.
getCache
(
Constants
.
CACHE_permissionPassword
);
String
floor
=
dataCache
.
getCache
(
Constants
.
CACHE_floor
);
Integer
preGenerateTaskTimes
=
dataCache
.
getCache
(
Constants
.
CACHE_preGenerateTask_Times
);
List
<
LineConfig
>
lineConfigList
=
dataCache
.
getCache
(
Constants
.
CACHE_lineConfigList
);
Integer
maiZhengMinute
=
dataCache
.
getCache
(
Constants
.
CACHE_maiZhengMinute
);
SysSettingsDto
dto
=
new
SysSettingsDto
();
dto
.
setStartJob
(
startJob
);
dto
.
setStopOut
(
stopOut
);
...
...
@@ -84,6 +88,8 @@ public class SettingsController {
dto
.
setPermissionPassword
(
permissionPassword
);
dto
.
setFloor
(
floor
);
dto
.
setPreGenerateTaskTimes
(
preGenerateTaskTimes
);
dto
.
setLineConfigList
(
lineConfigList
);
dto
.
setMaiZhengMinute
(
maiZhengMinute
);
return
dto
;
}
...
...
@@ -98,12 +104,24 @@ public class SettingsController {
dataCache
.
updateCache
(
Constants
.
CACHE_permissionPassword
,
sysSettingsDto
.
getPermissionPassword
());
dataCache
.
updateCache
(
Constants
.
CACHE_floor
,
sysSettingsDto
.
getFloor
());
dataCache
.
updateCache
(
Constants
.
CACHE_preGenerateTask_Times
,
sysSettingsDto
.
getPreGenerateTaskTimes
());
List
<
LineConfig
>
lineConfigList
=
sysSettingsDto
.
getLineConfigList
();
if
(
lineConfigList
==
null
){
lineConfigList
=
new
ArrayList
<>();
}
dataCache
.
updateCache
(
Constants
.
CACHE_lineConfigList
,
lineConfigList
);
if
(
sysSettingsDto
.
getMaiZhengMinute
()
!=
null
)
{
dataCache
.
updateCache
(
Constants
.
CACHE_maiZhengMinute
,
sysSettingsDto
.
getMaiZhengMinute
());
}
log
.
info
(
"更改系统设置:stopout="
+
sysSettingsDto
.
isStopOut
()
+
",stopjob="
+
sysSettingsDto
.
isStartJob
()
+
",backUpMonth="
+
sysSettingsDto
.
getBackUpMonth
()
+
",preGenerateTask="
+
sysSettingsDto
.
getPreGenerateTask
()
+
",permissionPassword="
+
sysSettingsDto
.
getPermissionPassword
()
+
",floor="
+
sysSettingsDto
.
getFloor
()
+
",preGenerateTaskTimes="
+
sysSettingsDto
.
getPreGenerateTaskTimes
()
+
",lineConfigList="
+
sysSettingsDto
.
getLineConfigList
()
+
",maiZhengMinute="
+
sysSettingsDto
.
getMaiZhengMinute
()
);
return
ResultBean
.
newOkResult
(
"保存成功"
);
}
...
...
src/main/java/com/neotel/smfcore/core/system/rest/bean/LineConfig.java
0 → 100644
查看文件 @
3be0048
package
com
.
neotel
.
smfcore
.
core
.
system
.
rest
.
bean
;
import
lombok.Data
;
@Data
public
class
LineConfig
{
private
String
line
;
private
int
minute
;
}
src/main/java/com/neotel/smfcore/core/system/rest/bean/dto/SysSettingsDto.java
查看文件 @
3be0048
package
com
.
neotel
.
smfcore
.
core
.
system
.
rest
.
bean
.
dto
;
import
com.neotel.smfcore.core.system.rest.bean.LineConfig
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
lombok.Getter
;
import
lombok.Setter
;
import
java.io.Serializable
;
import
java.util.List
;
@Getter
@Setter
public
class
SysSettingsDto
implements
Serializable
{
...
...
@@ -30,4 +34,12 @@ public class SysSettingsDto implements Serializable {
@ApiModelProperty
(
"楼层信息"
)
private
String
floor
=
""
;
@ApiModelProperty
(
"线体配置"
)
private
List
<
LineConfig
>
lineConfigList
;
@ApiModelProperty
(
"迈征配置时间"
)
private
Integer
maiZhengMinute
;
}
src/main/java/com/neotel/smfcore/core/system/util/TaskService.java
查看文件 @
3be0048
...
...
@@ -540,8 +540,11 @@ public class TaskService {
if
(
outTask
!=
null
)
{
log
.
info
(
outTask
.
getSourceName
()+
"barcode为:"
+
outTask
.
getBarcode
()+
"面别为:"
+
outTask
.
getSide
());
if
(
StringUtils
.
isNotBlank
(
outTask
.
getSide
()))
{
exportMap
.
put
(
cid
,
outTask
.
getSide
());
}
}
return
outTask
;
}
...
...
src/main/java/com/neotel/smfcore/custom/lizhen/LizhenApi.java
查看文件 @
3be0048
...
...
@@ -517,7 +517,7 @@ public class LizhenApi extends DefaultSmfApiListener {
}
}
if
(
items
!=
null
&&
!
items
.
isEmpty
())
{
return
PreWarningItemCache
.
createAndExecuteLiteOrder
(
items
,
2
,
false
);
return
PreWarningItemCache
.
createAndExecuteLiteOrder
(
items
,
false
);
}
}
return
null
;
...
...
src/main/java/com/neotel/smfcore/custom/lizhen/LizhenController.java
查看文件 @
3be0048
...
...
@@ -232,7 +232,12 @@ public class LizhenController {
item
.
setPartnumber
(
data
.
get
(
"PARTNUMBER"
));
item
.
setLine
(
data
.
get
(
"LINE"
));
item
.
setItemId
(
data
.
get
(
"ID"
));
try
{
item
.
setPriority
(
Integer
.
valueOf
(
data
.
get
(
"PRIORITY"
)));
}
catch
(
NumberFormatException
e
)
{
e
.
printStackTrace
();
item
.
setPriority
(
0
);
}
item
.
setReel
(
data
.
get
(
"REEL"
));
item
.
setBrand
(
data
.
get
(
"VENDOR"
));
...
...
src/main/java/com/neotel/smfcore/custom/lizhen/innerBox/rest/InnerBoxRestController.java
查看文件 @
3be0048
...
...
@@ -94,7 +94,7 @@ public class InnerBoxRestController {
String
hSerial
=
request
.
getParameter
(
"hSerial"
);
//工单序号
String
outlet
=
request
.
getParameter
(
"outlet"
);
//出口位置
String
boxSide
=
request
.
getParameter
(
"boxSide"
);
//料箱隔口
log
.
info
(
"IA 出库更新任务状态--barcode:{},status:{},loc:{},hSerial:{},outlet:{},boxSide:{}
"
,
code
,
status
,
loc
,
hSerial
,
outlet
,
boxSide
);
log
.
info
(
"IA 出库更新任务状态--barcode:{},status:{},loc:{},hSerial:{},outlet:{},boxSide:{}
,cid:{},outlet:{}"
,
code
,
status
,
loc
,
hSerial
,
outlet
,
boxSide
,
cid
,
outlet
);
CodeBean
codeBean
=
codeResolve
.
resolveSingleCode
(
code
);
Barcode
barcode
=
codeBean
.
getBarcode
();
...
...
@@ -121,7 +121,7 @@ public class InnerBoxRestController {
return
ResultBean
.
newErrorResult
(
304
,
"smfcore.task.hasEnd"
,
"任务已完成"
);
}
status
=
status
.
toUpperCase
();
log
.
info
(
"更新任务状态:{}-->{}"
,
opTask
.
getStatus
(),
status
);
//
log.info("更新任务状态:{}-->{}", opTask.getStatus(), status);
//调用此接口的肯定是料盘已出仓位的
if
(
opTask
.
isExecuting
()){
...
...
src/main/java/com/neotel/smfcore/custom/lizhen/innerBox/rest/PrinterRestController.java
查看文件 @
3be0048
...
...
@@ -61,6 +61,8 @@ public class PrinterRestController {
String
code
=
paramMap
.
get
(
"code"
);
log
.
info
(
"补打印标签:"
+
code
);
CodeBean
codeBean
=
codeResolve
.
resolveSingleCode
(
code
);
Barcode
barcode
=
codeBean
.
getBarcode
();
...
...
src/main/java/com/neotel/smfcore/custom/lizhen/innerBox/util/PreWarningItemCache.java
查看文件 @
3be0048
package
com
.
neotel
.
smfcore
.
custom
.
lizhen
.
innerBox
.
util
;
import
com.alibaba.fastjson.JSON
;
import
com.mks.api.response.Item
;
import
com.neotel.smfcore.common.utils.Constants
;
import
com.neotel.smfcore.common.utils.StringUtils
;
import
com.neotel.smfcore.core.device.util.DataCache
;
...
...
@@ -9,6 +10,7 @@ import com.neotel.smfcore.core.order.service.manager.ILiteOrderItemManager;
import
com.neotel.smfcore.core.order.service.manager.ILiteOrderManager
;
import
com.neotel.smfcore.core.order.service.po.LiteOrder
;
import
com.neotel.smfcore.core.order.service.po.LiteOrderItem
;
import
com.neotel.smfcore.core.system.rest.bean.LineConfig
;
import
com.neotel.smfcore.custom.lizhen.innerBox.bean.PreWarningItem
;
import
com.neotel.smfcore.custom.lizhen.innerBox.service.manager.IPreWarningItemManager
;
import
com.neotel.smfcore.custom.lizhen.innerBox.util.service.PreWarningItemCacheManager
;
...
...
@@ -22,7 +24,9 @@ import org.springframework.data.mongodb.core.query.Query;
import
org.springframework.stereotype.Service
;
import
java.util.ArrayList
;
import
java.util.Comparator
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.concurrent.CopyOnWriteArrayList
;
import
java.util.stream.Collectors
;
...
...
@@ -66,112 +70,99 @@ public class PreWarningItemCache {
/**
* 从缓存列表中取出预警Item生成工单并执行
*/
private
static
void
generateTask
(
int
priority
)
{
boolean
hasIdleBox
=
true
;
if
(
hasIdleBox
)
{
//每次最多出多少盘
//int maxReelCount = 30;
//如果取不到,从数据库中取
if
(
queueItemList
==
null
||
queueItemList
.
isEmpty
())
{
private
static
void
generateTask
()
{
if
(
queueItemList
==
null
||
queueItemList
.
isEmpty
()){
queueItemList
=
preWarningItemManager
.
findAll
();
}
if
(
queueItemList
==
null
||
queueItemList
.
isEmpty
())
{
return
;
if
(
queueItemList
!=
null
&&
!
queueItemList
.
isEmpty
())
{
//迈征集合
List
<
PreWarningItem
>
maiZhengItemList
=
new
ArrayList
<>();
//其他工单集合
List
<
PreWarningItem
>
otherItemList
=
new
ArrayList
<>();
//挑出迈征和其他工单
Map
<
String
,
String
>
stationStatusMap
=
StationStatusCache
.
getStationStatusMap
();
for
(
PreWarningItem
item
:
queueItemList
)
{
String
station
=
item
.
getStation
();
String
partnumber
=
item
.
getPartnumber
();
String
slot
=
item
.
getSlot
();
String
line
=
item
.
getLine
();
String
side
=
item
.
getSide
();
String
key
=
station
+
"_"
+
partnumber
+
"_"
+
slot
+
"_"
+
line
+
"_"
+
side
;
String
value
=
stationStatusMap
.
get
(
key
);
if
(
StringUtils
.
isNotBlank
(
value
))
{
maiZhengItemList
.
add
(
item
);
}
else
{
otherItemList
.
add
(
item
);
}
}
//优先生成迈征的信息
List
<
StationStatus
>
stationStatusList
=
stationStatusCache
.
getAllStationStatus
();
if
(
stationStatusList
!=
null
&&
!
stationStatusList
.
isEmpty
())
{
for
(
StationStatus
stationStatus
:
stationStatusList
)
{
List
<
PreWarningItem
>
lineItems
=
new
ArrayList
<>();
//处理迈征工单信息
if
(
maiZhengItemList
!=
null
&&
!
maiZhengItemList
.
isEmpty
())
{
maiZhengItemList
=
maiZhengItemList
.
stream
().
sorted
(
Comparator
.
comparing
(
PreWarningItem:
:
getReceiveDate
)).
collect
(
Collectors
.
toList
());
if
(
queueItemList
!=
null
&&
!
queueItemList
.
isEmpty
())
{
int
minute
=
dataCache
.
getCache
(
Constants
.
CACHE_maiZhengMinute
);
if
(
minute
==
0
)
{
minute
=
20
;
}
String
line
=
stationStatus
.
getLINE
();
//产线
String
trackNumber
=
stationStatus
.
getTrackNumber
();
//轨道号
String
side
=
stationStatus
.
getSIDE
();
//面别
//如果第一条接受的时间和当前时间相差超过设定时间
PreWarningItem
firstItem
=
maiZhengItemList
.
get
(
0
);
if
(
System
.
currentTimeMillis
()
-
firstItem
.
getReceiveDate
().
getTime
()
>
1000
*
60
*
minute
)
{
log
.
info
(
"开始生成迈征的工单信息,line为:"
+
line
+
",side为:"
+
side
+
",trackNumber为:"
+
trackNumber
);
//获取迈征的线体
List
<
String
>
lineList
=
StationStatusCache
.
getStationStatusLineList
();
if
(
lineList
!=
null
&&
!
lineList
.
isEmpty
())
{
for
(
String
cacheLine
:
lineList
)
{
List
<
PreWarningItem
>
itemList
=
new
ArrayList
<>();
for
(
PreWarningItem
item
:
maiZhengItemList
)
{
String
line
=
item
.
getLine
();
String
station
=
item
.
getStation
();
String
side
=
item
.
getSide
();
try
{
List
<
PreWarningItem
>
itemList
=
new
ArrayList
<>(
queueItemList
);
for
(
PreWarningItem
item
:
itemList
)
{
//判断产线,面别,
if
(
StringUtils
.
isNotBlank
(
line
)
&&
StringUtils
.
isNotBlank
(
side
)
&&
StringUtils
.
isNotBlank
(
trackNumber
)
)
{
if
(
line
.
equals
(
item
.
getLine
())
&&
side
.
equals
(
item
.
getSide
())
&&
StringUtils
.
isNotBlank
(
item
.
getStation
())
&&
item
.
getStation
().
endsWith
(
trackNumber
))
{
//再判断料号是否相同
for
(
StationStatus
status
:
stationStatusList
)
{
String
station
=
status
.
getSTATION
();
String
slot
=
status
.
getSLOT
();
String
partnumber
=
status
.
getPARTNUMBER
();
if
(
StringUtils
.
isNotBlank
(
partnumber
)
&&
StringUtils
.
isNotBlank
(
slot
)
&&
StringUtils
.
isNotBlank
(
station
))
{
if
(
station
.
equals
(
item
.
getStation
())
&&
slot
.
equals
(
item
.
getSlot
())
&&
partnumber
.
equals
(
item
.
getPartnumber
())
&&
line
.
equals
(
status
.
getLINE
())
&&
side
.
equals
(
status
.
getSIDE
())
)
{
log
.
info
(
"开始添加迈征的工单明细,station为:"
+
station
+
",slot为:"
+
slot
+
",partnumber为:"
+
partnumber
);
lineItems
.
add
(
item
);
String
trackNumber
=
""
;
if
(
StringUtils
.
isNotBlank
(
station
))
{
trackNumber
=
station
.
substring
(
station
.
length
()
-
1
);
}
line
=
line
+
"_"
+
side
+
"_"
+
trackNumber
;
if
(
line
.
equals
(
cacheLine
))
{
itemList
.
add
(
item
);
}
}
if
(
itemList
!=
null
&&
!
itemList
.
isEmpty
())
{
createAndExecuteLiteOrder
(
itemList
,
true
);
}
}
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
log
.
error
(
"生成迈征工单报错:"
+
e
.
getMessage
());
}
}
if
(
lineItems
!=
null
&&
!
lineItems
.
isEmpty
())
{
createAndExecuteLiteOrder
(
lineItems
,
priority
,
true
);
}
}
}
//处理其他工单信息
if
(
otherItemList
!=
null
&&
!
otherItemList
.
isEmpty
())
{
Map
<
String
,
List
<
PreWarningItem
>>
otherItemGroupMap
=
otherItemList
.
stream
().
collect
(
Collectors
.
groupingBy
(
PreWarningItem:
:
getLine
));
for
(
Map
.
Entry
<
String
,
List
<
PreWarningItem
>>
otherItemEntry
:
otherItemGroupMap
.
entrySet
())
{
//线体名称
String
line
=
otherItemEntry
.
getKey
();
//线体对应的item
List
<
PreWarningItem
>
itemList
=
otherItemEntry
.
getValue
();
//按创建时间进行升序排列
itemList
=
itemList
.
stream
().
sorted
(
Comparator
.
comparing
(
PreWarningItem:
:
getReceiveDate
)).
collect
(
Collectors
.
toList
());
log
.
info
(
"开始生成其他工单"
);
Integer
preGenerateTaskTimes
=
dataCache
.
getCache
(
Constants
.
CACHE_preGenerateTask_Times
);
if
(
preGenerateTaskTimes
==
null
||
preGenerateTaskTimes
==
0
)
{
preGenerateTaskTimes
=
2
;
int
minute
=
dataCache
.
getLineConfigMinute
(
line
);
if
(
minute
==
0
)
{
minute
=
20
;
}
for
(
int
time
=
0
;
time
<
preGenerateTaskTimes
;
time
++)
{
//最早的一条预警时间
List
<
PreWarningItem
>
lineItems
=
new
ArrayList
<>();
String
firstItemLine
=
""
;
if
(
queueItemList
!=
null
&&
!
queueItemList
.
isEmpty
())
{
List
<
PreWarningItem
>
itemList
=
new
ArrayList
<>(
queueItemList
);
for
(
PreWarningItem
preWarningItem
:
itemList
)
{
String
itemLine
=
preWarningItem
.
getLine
();
if
(
Strings
.
isNotBlank
(
itemLine
))
{
if
(
firstItemLine
.
isEmpty
())
{
firstItemLine
=
itemLine
;
if
(
System
.
currentTimeMillis
()
-
preWarningItem
.
getReceiveDate
().
getTime
()
<
1
*
60
*
1000
)
{
return
;
}
PreWarningItem
firstItem
=
itemList
.
get
(
0
);
if
(
System
.
currentTimeMillis
()
-
firstItem
.
getReceiveDate
().
getTime
()
<
1000
*
60
*
minute
)
{
continue
;
}
//同一个线别的生成一个工单
if
(
itemLine
.
equals
(
firstItemLine
))
{
log
.
info
(
"添加明细数据,id为:"
+
preWarningItem
.
getItemId
());
lineItems
.
add
(
preWarningItem
);
createAndExecuteLiteOrder
(
itemList
,
false
);
}
}
}
}
if
(!
lineItems
.
isEmpty
())
{
createAndExecuteLiteOrder
(
lineItems
,
priority
,
false
);
}
}
}
}
/**
...
...
@@ -179,7 +170,7 @@ public class PreWarningItemCache {
*
* @param lineItems
*/
public
static
synchronized
LiteOrder
createAndExecuteLiteOrder
(
List
<
PreWarningItem
>
lineItems
,
int
priority
,
boolean
maiZheng
)
{
public
static
synchronized
LiteOrder
createAndExecuteLiteOrder
(
List
<
PreWarningItem
>
lineItems
,
boolean
maiZheng
)
{
//1.得到优先级比较高的
LiteOrder
liteOrder
=
new
LiteOrder
();
//List<PreWarningItem> itemsPri = new ArrayList<>();
...
...
@@ -211,6 +202,7 @@ public class PreWarningItemCache {
orderItem
.
setMachineName
(
item
.
getMachinename
());
orderItem
.
setReel
(
item
.
getReel
());
orderItem
.
setBrand
(
item
.
getBrand
());
orderItem
.
setReceiveDate
(
item
.
getReceiveDate
());
orderItems
.
add
(
orderItem
);
}
}
...
...
@@ -220,7 +212,7 @@ public class PreWarningItemCache {
liteOrder
.
setTaskReelCount
(
orderItems
.
size
());
liteOrder
.
setMaiZheng
(
maiZheng
);
liteOrder
=
liteOrderManager
.
createWithItems
(
liteOrder
);
log
.
info
(
"生成工单信息为:"
+
liteOrder
.
getOrderNo
());
log
.
info
(
"生成工单信息为:"
+
liteOrder
.
getOrderNo
());
liteOrderCache
.
addOrderToMap
(
liteOrder
);
}
//工单生成后,从缓存中清除
...
...
@@ -252,7 +244,7 @@ public class PreWarningItemCache {
c
.
and
(
"warningItemId"
).
is
(
itemIds
.
get
(
0
));
LiteOrderItem
orderItem
=
liteOrderItemManager
.
findOne
(
new
Query
().
addCriteria
(
c
));
if
(
orderItem
!=
null
){
if
(
orderItem
!=
null
)
{
String
warningItemId
=
orderItem
.
getWarningItemId
();
newItems
=
newItems
.
stream
()
.
filter
(
item
->
!
item
.
getItemId
().
equals
(
warningItemId
))
...
...
@@ -266,7 +258,7 @@ public class PreWarningItemCache {
queueItemList
.
addAll
(
newItems
);
}
for
(
PreWarningItem
item
:
newItems
)
{
log
.
info
(
"mes缺料预警信息为:"
+
JSON
.
toJSONString
(
item
));
log
.
info
(
"mes缺料预警信息为:"
+
JSON
.
toJSONString
(
item
));
preWarningItemManager
.
save
(
item
);
}
}
...
...
@@ -278,13 +270,13 @@ public class PreWarningItemCache {
/**
* 定时执行,从缓存列表中取出预警Item生成工单并执行
*/
public
static
void
runTimer
(
int
priority
)
{
public
static
void
runTimer
()
{
if
(
processing
)
{
return
;
}
processing
=
true
;
try
{
generateTask
(
priority
);
generateTask
();
}
catch
(
Exception
e
)
{
log
.
error
(
"预警缓存定时器出错"
,
e
);
}
finally
{
...
...
@@ -318,7 +310,7 @@ public class PreWarningItemCache {
}
@Autowired
public
void
setPreWarningItemManager
(
IPreWarningItemManager
preWarningItemManager
)
{
public
void
setPreWarningItemManager
(
IPreWarningItemManager
preWarningItemManager
)
{
PreWarningItemCache
.
preWarningItemManager
=
preWarningItemManager
;
}
...
...
src/main/java/com/neotel/smfcore/custom/lizhen/kafka/service/KafkaService.java
查看文件 @
3be0048
...
...
@@ -19,7 +19,11 @@ import org.springframework.scheduling.annotation.Scheduled;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.concurrent.ListenableFuture
;
import
javax.annotation.PostConstruct
;
import
java.util.*
;
import
java.util.concurrent.Executors
;
import
java.util.concurrent.ScheduledExecutorService
;
import
java.util.concurrent.TimeUnit
;
import
java.util.stream.Collectors
;
//@Async
...
...
@@ -37,10 +41,21 @@ public class KafkaService {
Map
<
String
,
String
>
statusMap
=
Maps
.
newConcurrentMap
();
ScheduledExecutorService
scheduledThreadPool
=
Executors
.
newScheduledThreadPool
(
1
);
@PostConstruct
void
init
(){
scheduledThreadPool
.
scheduleAtFixedRate
(
()
->
{
setMachineStatus
();
setHeartbeat
();
},
5
,
60
,
TimeUnit
.
SECONDS
);
}
/**
* 设备状态发送
*/
@Scheduled
(
fixedRate
=
1000
*
60
*
1
)
//@Scheduled(fixedRate = 1000 * 60 * 2
)
public
void
setMachineStatus
()
{
log
.
info
(
"发送设备状态开始"
);
Collection
<
Storage
>
storages
=
dataCache
.
getAllStorage
().
values
();
...
...
@@ -111,7 +126,7 @@ public class KafkaService {
/**
* 心跳数据发送
*/
@Scheduled
(
fixedRate
=
1000
*
60
*
5
)
//
@Scheduled(fixedRate = 1000 * 60 * 5)
public
void
setHeartbeat
()
{
log
.
info
(
"发送心跳开始"
);
//根据machineId,找到设备状态,是否正常
...
...
src/main/java/com/neotel/smfcore/custom/lizhen/report/inner/InnerReportController.java
查看文件 @
3be0048
...
...
@@ -328,6 +328,7 @@ public class InnerReportController {
resultMap
.
put
(
"料号"
,
dto
.
getPn
()
==
null
?
""
:
dto
.
getPn
());
resultMap
.
put
(
"需求卷"
,
dto
.
getNeedReelCount
());
resultMap
.
put
(
"实发卷"
,
dto
.
getOutReelCount
());
resultMap
.
put
(
"创建时间"
,
dto
.
getCreateDate
());
results
.
add
(
resultMap
);
}
try
{
...
...
src/main/java/com/neotel/smfcore/custom/lizhen/third/maicheng/util/StationStatusCache.java
查看文件 @
3be0048
package
com
.
neotel
.
smfcore
.
custom
.
lizhen
.
third
.
maicheng
.
util
;
import
com.alibaba.fastjson.JSONObject
;
import
com.google.common.collect.Lists
;
import
com.google.common.collect.Maps
;
import
com.neotel.smfcore.common.utils.StringUtils
;
import
com.neotel.smfcore.core.device.util.DataCache
;
import
com.neotel.smfcore.custom.lizhen.third.maicheng.api.MaiZhengApi
;
import
com.neotel.smfcore.custom.lizhen.third.maicheng.bean.StationStatus
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Service
;
import
javax.annotation.PostConstruct
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.concurrent.CopyOnWriteArrayList
;
import
java.util.stream.Collectors
;
@Service
...
...
@@ -24,10 +23,13 @@ public class StationStatusCache {
@Autowired
private
DataCache
dataCache
;
public
static
final
String
MAI
CHENG_STATIONSTATUS_CACHE
=
"MaiChengStationStatusCache
"
;
public
static
final
String
MAI
ZHENG_STATIONSTATUS_CACHE_Map
=
"MaiZhengStationStatusCacheMap
"
;
p
rivate
static
List
<
StationStatus
>
stationStatusList
=
Lists
.
newCopyOnWriteArrayList
()
;
p
ublic
static
final
String
MAIZHENG_STATIONSTATUS_CACHE_Line_List
=
"MaiZhengStationStatusCacheLineList"
;
public
static
List
<
String
>
stationStatusLineList
=
new
CopyOnWriteArrayList
<>();
private
static
Map
<
String
,
String
>
stationStatusMap
=
Maps
.
newConcurrentMap
();
@PostConstruct
public
void
init
()
{
...
...
@@ -36,9 +38,13 @@ public class StationStatusCache {
if
(
statusList
!=
null
&&
!
statusList
.
isEmpty
())
{
updateStatusList
(
statusList
);
}
else
{
List
<
StationStatus
>
statusCacheList
=
dataCache
.
getCache
(
MAICHENG_STATIONSTATUS_CACHE
);
if
(
statusCacheList
!=
null
&&
!
statusCacheList
.
isEmpty
())
{
updateStatusList
(
statusCacheList
);
Map
<
String
,
String
>
cacheMap
=
dataCache
.
getCache
(
MAIZHENG_STATIONSTATUS_CACHE_Map
);
if
(
cacheMap
!=
null
)
{
stationStatusMap
.
putAll
(
cacheMap
);
}
List
<
String
>
cacheLineList
=
dataCache
.
getCache
(
MAIZHENG_STATIONSTATUS_CACHE_Line_List
);
if
(
cacheLineList
!=
null
)
{
stationStatusLineList
.
addAll
(
cacheLineList
);
}
}
}
catch
(
Exception
e
)
{
...
...
@@ -47,30 +53,39 @@ public class StationStatusCache {
}
public
void
updateStatusList
(
List
<
StationStatus
>
statusList
)
{
stationStatusList
.
clear
();
stationStatusList
.
addAll
(
statusList
);
dataCache
.
updateCache
(
MAICHENG_STATIONSTATUS_CACHE
,
stationStatusList
);
}
stationStatusMap
.
clear
();
stationStatusLineList
.
clear
();
for
(
StationStatus
stationStatus
:
statusList
)
{
String
station
=
stationStatus
.
getSTATION
();
String
partnumber
=
stationStatus
.
getPARTNUMBER
();
String
slot
=
stationStatus
.
getSLOT
();
String
line
=
stationStatus
.
getLINE
();
String
side
=
stationStatus
.
getSIDE
();
String
key
=
station
+
"_"
+
partnumber
+
"_"
+
slot
+
"_"
+
line
+
"_"
+
side
;
stationStatusMap
.
put
(
key
,
key
);
public
List
<
StationStatus
>
getAllStationStatus
()
{
List
<
StationStatus
>
statusList
=
new
ArrayList
<>();
if
(
stationStatusList
==
null
||
stationStatusList
.
isEmpty
())
{
stationStatusList
=
dataCache
.
getCache
(
MAICHENG_STATIONSTATUS_CACHE
);
}
if
(
stationStatusList
!=
null
&&
!
stationStatusList
.
isEmpty
())
{
for
(
StationStatus
status
:
stationStatusList
)
{
String
station
=
status
.
getSTATION
();
String
trackNumber
=
""
;
if
(
StringUtils
.
isNotBlank
(
station
))
{
String
trackNumber
=
station
.
substring
(
station
.
length
()
-
1
);
status
.
setTrackNumber
(
trackNumber
);
trackNumber
=
station
.
substring
(
station
.
length
()
-
1
);
}
statusList
.
add
(
status
);
String
cacheLine
=
line
+
"_"
+
side
+
"_"
+
trackNumber
;
stationStatusLineList
.
add
(
cacheLine
);
}
dataCache
.
updateCache
(
MAIZHENG_STATIONSTATUS_CACHE_Map
,
stationStatusMap
);
if
(
stationStatusLineList
!=
null
&&
!
stationStatusLineList
.
isEmpty
()){
stationStatusLineList
=
stationStatusLineList
.
stream
().
distinct
().
collect
(
Collectors
.
toList
());
dataCache
.
updateCache
(
MAIZHENG_STATIONSTATUS_CACHE_Line_List
,
stationStatusLineList
);
}
}
if
(
statusList
!=
null
&&
!
statusList
.
isEmpty
())
{
statusList
=
statusList
.
stream
().
distinct
().
collect
(
Collectors
.
toList
())
;
public
static
Map
<
String
,
String
>
getStationStatusMap
()
{
return
stationStatusMap
;
}
return
statusList
;
public
static
List
<
String
>
getStationStatusLineList
()
{
return
stationStatusLineList
;
}
}
src/main/resources/config/application.yml
查看文件 @
3be0048
...
...
@@ -13,7 +13,7 @@ api:
fetchGRUrl
:
#http://10.42.25.199:8082/api/wcs/fetchGR #gr标签
brandQtyUrl
:
#http://172.30.170.199:8082/api/wcs/brandQty #gr标签满卷数
importUrl
:
#http://10.42.222.52:8001/smf-core/ext/forward/getDataLogs #内仓导入外仓picking虚拟仓数据
checkReelMeasure
:
#http://10.190.25.1
49
:8001/Sct/CheckReelMeasure #散料量测接口
checkReelMeasure
:
#http://10.190.25.1
24
:8001/Sct/CheckReelMeasure #散料量测接口
plant
:
2810
werks
:
2810
outerFactory
:
...
...
@@ -40,7 +40,7 @@ lizhen:
url
:
http://172.30.97.63:8001/smf-core/api/Mes/machineCallMaterial
F4
:
name
:
4F
line
:
B03-4FSMT-11,B03-4FSMT-01,B03-4FSMT-13,B03-4FSMT-03,B03-4FSMT-14
line
:
B03-4FSMT-11,B03-4FSMT-01,B03-4FSMT-13,B03-4FSMT-03,B03-4FSMT-14
,B03-4FSMT-04
url
:
http://172.25.252.12:8001/smf-core/api/Mes/machineCallMaterial
...
...
@@ -102,6 +102,5 @@ app:
type
:
"
"
menu
:
show
:
meInventory,meExpiredReport,meChangeReport,meprohibitedReport
show
:
#innerMaterial
hide
:
\ No newline at end of file
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论