Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
孙克
/
smf-core
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
作业
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit 437a3c12
由
zshaohui
编写于
2022-10-24 09:44:59 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
立臻项目功能提交
1 个父辈
4a9001b6
显示空白字符变更
内嵌
并排
正在显示
24 个修改的文件
包含
1123 行增加
和
291 行删除
src/main/java/com/neotel/smfcore/common/utils/HttpHelper.java
src/main/java/com/neotel/smfcore/core/api/SmfApi.java
src/main/java/com/neotel/smfcore/core/api/listener/DefaultSmfApiListener.java
src/main/java/com/neotel/smfcore/core/api/listener/ISmfApiListener.java
src/main/java/com/neotel/smfcore/core/barcode/bean/BarcodeRule.java
src/main/java/com/neotel/smfcore/core/device/handler/impl/BaseDeviceHandler.java
src/main/java/com/neotel/smfcore/core/device/rest/DeviceController.java
src/main/java/com/neotel/smfcore/core/order/LiteOrderCache.java
src/main/java/com/neotel/smfcore/core/order/service/po/LiteOrderItem.java
src/main/java/com/neotel/smfcore/core/storage/service/manager/IStoragePosManager.java
src/main/java/com/neotel/smfcore/core/storage/service/manager/impl/StoragePosManagerImpl.java
src/main/java/com/neotel/smfcore/core/system/service/po/DataLog.java
src/main/java/com/neotel/smfcore/custom/advantech/AdvantechApi.java
src/main/java/com/neotel/smfcore/custom/hella/handler/HellaApiHandler.java
src/main/java/com/neotel/smfcore/custom/hella/handler/HellaServiceHandler.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/agvBox/rest/WarehouseController.java
src/main/java/com/neotel/smfcore/custom/lizhen/agvBox/util/StationCacheUtil.java
src/main/java/com/neotel/smfcore/custom/lizhen/innerBox/rest/InnerBoxRestController.java
src/main/java/com/neotel/smfcore/custom/lizhen/innerBox/util/PreWarningItemCache.java
src/main/java/com/neotel/smfcore/custom/lizhen/innerBox/util/service/PreWarningItemManager.java
src/main/java/com/neotel/smfcore/custom/panacim/PanaApiController.java
src/main/java/com/neotel/smfcore/custom/siemens/SiemensApi.java
src/main/java/com/neotel/smfcore/common/utils/HttpHelper.java
查看文件 @
437a3c1
...
...
@@ -8,8 +8,10 @@ import lombok.val;
import
org.apache.http.HttpEntity
;
import
org.apache.http.NameValuePair
;
import
org.apache.http.client.HttpClient
;
import
org.apache.http.client.config.RequestConfig
;
import
org.apache.http.client.entity.UrlEncodedFormEntity
;
import
org.apache.http.client.methods.CloseableHttpResponse
;
import
org.apache.http.client.methods.HttpGet
;
import
org.apache.http.client.methods.HttpPost
;
import
org.apache.http.client.utils.URIBuilder
;
import
org.apache.http.entity.StringEntity
;
...
...
@@ -141,4 +143,41 @@ public class HttpHelper {
}
/**
* 发送HttpGet请求
*
* @param url
* @return
*/
public
static
String
sendGet
(
String
url
)
{
HttpGet
httpget
=
new
HttpGet
(
url
);
RequestConfig
build
=
RequestConfig
.
custom
().
setSocketTimeout
(
5000
)
.
setConnectTimeout
(
5000
)
.
setConnectionRequestTimeout
(
5000
).
build
();
httpget
.
setConfig
(
build
);
CloseableHttpResponse
response
=
null
;
try
{
CloseableHttpClient
httpClient
=
HttpClients
.
createDefault
();
response
=
httpClient
.
execute
(
httpget
);
}
catch
(
IOException
e1
)
{
e1
.
printStackTrace
();
}
String
result
=
null
;
try
{
HttpEntity
entity
=
response
.
getEntity
();
if
(
entity
!=
null
)
{
result
=
EntityUtils
.
toString
(
entity
);
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
finally
{
try
{
response
.
close
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
}
return
result
;
}
}
src/main/java/com/neotel/smfcore/core/api/SmfApi.java
查看文件 @
437a3c1
...
...
@@ -55,6 +55,9 @@ public class SmfApi {
@Value
(
"${api.fetchOrderUrl:}"
)
protected
String
fetchOrderUrl
=
""
;
@Value
(
"${api.barcodeInfoUrl:}"
)
protected
String
barcodeInfoUrl
=
""
;
@PostConstruct
public
void
init
(){
apiName
=
dataCache
.
getConfigCache
(
"api.name"
,
apiName
);
...
...
@@ -65,6 +68,7 @@ public class SmfApi {
orderNotifyUrl
=
dataCache
.
getConfigCache
(
"api.orderNotifyUrl"
,
orderNotifyUrl
);
fetchInListUrl
=
dataCache
.
getConfigCache
(
"api.fetchInListUrl"
,
fetchInListUrl
);
fetchOrderUrl
=
dataCache
.
getConfigCache
(
"api.fetchOrderUrl"
,
fetchOrderUrl
);
barcodeInfoUrl
=
dataCache
.
getConfigCache
(
"api.barcodeInfoUrl"
,
barcodeInfoUrl
);
}
/**
...
...
@@ -145,9 +149,6 @@ public class SmfApi {
}
public
LiteOrder
fetchOrder
(
String
orderNumber
,
String
username
){
if
(
orderNumber
==
null
){
throw
new
ValidateException
(
"smfcore.fetchOrder.orderNumber.empty"
,
"工单号不能为空"
);
}
if
(
isUrlExist
(
fetchOrderUrl
)){
for
(
ISmfApiListener
apiListener
:
apiListenerList
)
{
if
(
apiListener
.
isForThisApi
(
apiName
)){
...
...
@@ -174,4 +175,17 @@ public class SmfApi {
return
false
;
}
public
Barcode
barcodeInfo
(
Barcode
barcode
)
{
if
(
isUrlExist
(
barcodeInfoUrl
))
{
for
(
ISmfApiListener
apiListener
:
apiListenerList
)
{
if
(
apiListener
.
isForThisApi
(
apiName
))
{
Barcode
responseBarcode
=
apiListener
.
barcodeInfo
(
barcodeInfoUrl
,
barcode
);
if
(
responseBarcode
!=
null
)
{
return
responseBarcode
;
}
}
}
}
return
null
;
}
}
src/main/java/com/neotel/smfcore/core/api/listener/DefaultSmfApiListener.java
查看文件 @
437a3c1
...
...
@@ -246,4 +246,9 @@ public class DefaultSmfApiListener extends BaseSmfApiListener {
public
LiteOrder
fetchOrder
(
String
fetchOrderUrl
,
String
orderNumber
,
String
username
){
return
null
;
}
@Override
public
Barcode
barcodeInfo
(
String
barcodeInfoUrl
,
Barcode
barcode
)
{
return
null
;
}
}
src/main/java/com/neotel/smfcore/core/api/listener/ISmfApiListener.java
查看文件 @
437a3c1
...
...
@@ -48,4 +48,6 @@ public interface ISmfApiListener {
* @return
*/
LiteOrder
fetchOrder
(
String
url
,
String
orderNumber
,
String
username
);
Barcode
barcodeInfo
(
String
barcodeInfoUrl
,
Barcode
barcode
);
}
src/main/java/com/neotel/smfcore/core/barcode/bean/BarcodeRule.java
查看文件 @
437a3c1
...
...
@@ -200,6 +200,19 @@ public class BarcodeRule {
log
.
info
(
"expireDay: 为"
+
newRule
.
expireDay_item
.
toString
());
}
}
if
(!
newRule
.
dateCode_item
.
hasThisField
()){
if
(
newRule
.
dateCode_item
.
matchRule
(
fieldValue
,
i
)){
log
.
info
(
"dateCode: 为"
+
newRule
.
dateCode_item
.
toString
());
}
}
if
(!
newRule
.
providerNumber_item
.
hasThisField
()){
if
(
newRule
.
providerNumber_item
.
matchRule
(
fieldValue
,
i
)){
log
.
info
(
"providerNumber: 为"
+
newRule
.
providerNumber_item
.
toString
());
}
}
}
boolean
validRule
=
false
;
if
(
newRule
.
partNumber_item
.
hasThisField
()){
...
...
@@ -234,6 +247,8 @@ public class BarcodeRule {
private
RuleItem
batch_item
=
new
RuleItem
(
"BATCH"
);
private
RuleItem
msl_item
=
new
RuleItem
(
"MSL"
);
private
RuleItem
memo_item
=
new
RuleItem
(
"MEMO"
);
private
RuleItem
dateCode_item
=
new
RuleItem
(
"DATECODE"
);
private
RuleItem
providerNumber_item
=
new
RuleItem
(
"PROVIDERNUMBER"
);
private
class
RuleItem
{
private
RuleItem
(
String
ruleName
)
{
...
...
@@ -541,6 +556,9 @@ public class BarcodeRule {
}
if
(
batch_item
.
hasThisField
()){
String
batch
=
batch_item
.
getStrValue
(
codeArr
);
if
(
batch
.
indexOf
(
"-"
)
!=
-
1
){
batch
=
batch
.
substring
(
0
,
batch
.
indexOf
(
"-"
));
}
b
.
setBatch
(
batch
);
}
int
quantity
=
1
;
...
...
@@ -590,8 +608,28 @@ public class BarcodeRule {
b
.
setMemo
(
memo
);
}
if
(
dateCode_item
.
hasThisField
()){
String
dateCode
=
dateCode_item
.
getStrValue
(
codeArr
);
if
(
dateCode
.
indexOf
(
"-"
)
!=
-
1
){
dateCode
=
dateCode
.
substring
(
dateCode
.
indexOf
(
"-"
)+
1
,
dateCode
.
length
());
}
b
.
setDateCode
(
dateCode
);
}
if
(
providerNumber_item
.
hasThisField
()){
String
providerNumber
=
providerNumber_item
.
getStrValue
(
codeArr
);
if
(
providerNumber
.
indexOf
(
"-"
)
!=
-
1
){
providerNumber
=
providerNumber
.
substring
(
providerNumber
.
indexOf
(
"-"
)+
1
,
providerNumber
.
length
());
}
b
.
setProviderNumber
(
providerNumber
);
}
b
.
setBarcode
(
reelId
);
codeBean
.
setCodeStr
(
reelId
);
//如果是立臻的,则取-前面的
if
(
partNumber
.
indexOf
(
"-"
)
!=
-
1
){
partNumber
=
partNumber
.
substring
(
0
,
partNumber
.
indexOf
(
"-"
));
}
b
.
setPartNumber
(
partNumber
);
b
.
setAmount
(
quantity
);
b
.
setProduceDate
(
produceDate
);
...
...
@@ -727,6 +765,18 @@ public class BarcodeRule {
codeStr
=
"CS0001-1"
;
rule
=
"RI[-1:6:-1]PN[-1:2:-1]"
;
codeStr
=
"107S0257-017425|YB1N27N06-2216|20000|M1001742524EA09EUT|MURATA"
;
rule
=
"PN[-1:20:-1]PROVIDERNUMBER[-1:20:-1]|BATCH[-1:20:-1]DATECODE[-1:20:-1]|QTY|RI|SP"
;
codeStr
=
"103S00421-797001|TPA221300067-20220320|20000|A1079700122220C406|CYNTEC|TPA2213000670000C406"
;
rule
=
"PN[-1:20:-1]PROVIDERNUMBER[-1:20:-1]|BATCH[-1:20:-1]DATECODE[-1:20:-1]|QTY|4|SP|RI"
;
codeStr
=
"138S00138-012207|2022-1015|41625|L130122074222008AL|KYOCERA|"
;
rule
=
"PN[-1:20:-1]PROVIDERNUMBER[-1:20:-1]|BATCH[-1:20:-1]DATECODE[-1:20:-1]|QTY|RI|SP|6"
;
BarcodeRule
br
=
BarcodeRule
.
newRule
(
rule
);
Barcode
b
=
br
.
toCodeBean
(
codeStr
).
getBarcode
();
if
(
b
!=
null
){
...
...
@@ -739,6 +789,9 @@ public class BarcodeRule {
System
.
out
.
println
(
"EXPDATE:"
+
b
.
getExpireDate
());
System
.
out
.
println
(
"Supllier:"
+
b
.
getProvider
());
System
.
out
.
println
(
"Memo:"
+
b
.
getMemo
());
System
.
out
.
println
(
"DataCode:"
+
b
.
getDateCode
());
System
.
out
.
println
(
"ProviderNumber:"
+
b
.
getProviderNumber
());
//System.out.println("Provider:"+b.getProvider());
}
else
{
log
.
info
(
"解析失败"
);
}
...
...
src/main/java/com/neotel/smfcore/core/device/handler/impl/BaseDeviceHandler.java
查看文件 @
437a3c1
...
...
@@ -241,12 +241,13 @@ public class BaseDeviceHandler implements IDeviceHandler {
}
//本地难条码是否可以入库
verifyBarcodePutIn
(
Lists
.<
Storage
>
newArrayList
(
storage
),
barcodeSave
);
//从API验证
Barcode
barcodeFromApi
=
smfApi
.
canPutInAfterResolve
(
barcodeSave
);
/*
Barcode barcodeFromApi = smfApi.canPutInAfterResolve(barcodeSave);
if (barcodeFromApi != null) {
barcodeSave = barcodeFromApi;
}
}
*/
// //西门子接口验证
// boolean result=SiemensApi.getMaterialLot(1, storage.getId(),storage.getName(),barcodeSave.getBarcode());
...
...
src/main/java/com/neotel/smfcore/core/device/rest/DeviceController.java
查看文件 @
437a3c1
...
...
@@ -10,6 +10,8 @@ import com.neotel.smfcore.common.bean.ResultBean;
import
com.neotel.smfcore.common.exception.ValidateException
;
import
com.neotel.smfcore.common.utils.Constants
;
import
com.neotel.smfcore.common.utils.ReelLockPosUtil
;
import
com.neotel.smfcore.core.api.SmfApi
;
import
com.neotel.smfcore.core.api.listener.ISmfApiListener
;
import
com.neotel.smfcore.core.barcode.service.po.Barcode
;
import
com.neotel.smfcore.core.barcode.utils.CodeResolve
;
import
com.neotel.smfcore.core.device.bean.PosInfo
;
...
...
@@ -57,6 +59,9 @@ public class DeviceController {
@Autowired
private
IStoragePosManager
storagePosManager
;
@Autowired
private
SmfApi
smfApi
;
private
Map
<
String
,
IDeviceHandler
>
handlerMap
=
new
HashMap
<>();
public
DeviceController
(
List
<
IDeviceHandler
>
deviceHandlerList
)
{
...
...
@@ -155,10 +160,21 @@ public class DeviceController {
try
{
Barcode
barcode
=
codeResolve
.
resolveOneValideBarcode
(
code
);
if
(
barcode
==
null
)
{
throw
new
ValidateException
(
"smfcore.error.barcode.invalid"
,
"{0}不是有效的条码"
,
new
String
[]{
code
});
}
Barcode
barcodeCanPutIn
=
smfApi
.
canPutInAfterResolve
(
barcode
);
if
(
barcodeCanPutIn
!=
null
){
barcode
=
barcodeCanPutIn
;
}
Barcode
barcodeApi
=
smfApi
.
barcodeInfo
(
barcode
);
if
(
barcodeApi
!=
null
){
barcode
=
barcodeApi
;
}
for
(
DataLog
dataLog
:
taskService
.
getQueueTasks
())
{
// if(!dataLog.isPackageReel()){
//已经在任务当中,返回对应的信息
...
...
src/main/java/com/neotel/smfcore/core/order/LiteOrderCache.java
查看文件 @
437a3c1
...
...
@@ -8,6 +8,7 @@ import com.neotel.smfcore.common.exception.ValidateException;
import
com.neotel.smfcore.common.utils.Constants
;
import
com.neotel.smfcore.common.utils.SecurityUtils
;
import
com.neotel.smfcore.core.api.SmfApi
;
import
com.neotel.smfcore.core.barcode.service.manager.IBarcodeManager
;
import
com.neotel.smfcore.core.barcode.service.po.Barcode
;
import
com.neotel.smfcore.core.device.enums.OP
;
import
com.neotel.smfcore.core.device.enums.OP_STATUS
;
...
...
@@ -27,6 +28,8 @@ import com.neotel.smfcore.core.system.service.po.DataLog;
import
com.neotel.smfcore.core.system.util.TaskService
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.mongodb.core.query.Criteria
;
import
org.springframework.data.mongodb.core.query.Query
;
import
org.springframework.stereotype.Service
;
import
java.util.*
;
...
...
@@ -53,9 +56,13 @@ public class LiteOrderCache {
@Autowired
private
IStoragePosManager
storagePosManager
;
@Autowired
private
SmfApi
smfApi
;
@Autowired
private
IBarcodeManager
barcodeManager
;
/**
* 正在执行的liteOrderMap, key 为orderNo,value 为order
*/
...
...
@@ -218,7 +225,7 @@ public class LiteOrderCache {
}
else
if
(
liteOrder
.
isOutTails
()){
// setStatus(LITEORDER_STATUS.TAILS_FINISHED);
liteOrder
.
setClosed
(
true
);
}
else
if
(
liteOrder
.
is
OutTails
()){
}
else
if
(
liteOrder
.
is
New
()){
liteOrder
.
setClosed
(
true
);
}
...
...
@@ -398,10 +405,12 @@ public class LiteOrderCache {
if
(
cacheOrder
.
getType
()==
2
){
//RI
pos
=
storagePosManager
.
getByBarcode
(
orderItem
.
getRi
());
if
(
excludePosIds
.
contains
(
pos
.
getId
()))
{
if
(
pos
!=
null
)
{
if
(
excludePosIds
.
contains
(
pos
.
getId
()))
{
log
.
info
(
"工单["
+
orderNo
+
"]RI出库,任务数["
+
taskReelCount
+
"]出库位置仓位【"
+
pos
.
getPosName
()
+
"】RI=["
+
pos
.
getBarcode
().
getBarcode
()
+
"]已在操作队列中,跳过不处理"
);
break
;
}
}
}
else
{
//PN
pos
=
storagePosManager
.
findPartNumberInStorages
(
availableStorageIds
,
partNumber
,
excludePosIds
,
checkoutType
);
...
...
@@ -416,13 +425,19 @@ public class LiteOrderCache {
DataLog
task
=
newTask
(
pos
)
;
task
.
setSourceId
(
cacheOrder
.
getId
());
if
(
pos
.
getBarcode
().
getBarcode
().
startsWith
(
"CS"
)
||
pos
.
getBarcode
().
getBarcode
().
startsWith
(
"CM"
)
||
pos
.
getBarcode
().
getBarcode
().
startsWith
(
"CB"
)){
taskReelCount
=
cacheOrder
.
getOrderItems
().
size
();
}
else
{
task
.
setSourceName
(
cacheOrder
.
getOrderNo
());
}
task
.
setSubSourceId
(
orderItem
.
getId
());
task
.
setSubSourceInfo
(
orderItem
.
getFeederInfo
());
task
.
setType
(
OP
.
CHECKOUT
);
task
.
setLightColor
(
nextColor
.
getRgb
());
task
.
setStatus
(
OP_STATUS
.
WAIT
.
name
());
task
.
setPartNumber
(
orderItem
.
getPn
());
task
.
setPartNumber
(
pos
.
getBarcode
().
getPartNumber
());
// task = dataLogDao.save(task);
taskService
.
addTaskToExecute
(
task
);
}
...
...
@@ -432,9 +447,7 @@ public class LiteOrderCache {
}
}
}
}
cacheOrder
.
setTaskReelCount
(
taskReelCount
);
cacheOrder
.
setTotalTaskReelCount
(
cacheOrder
.
getTotalTaskReelCount
()+
taskReelCount
);
log
.
info
(
"工单["
+
orderNo
+
"]任务分配结束,任务数["
+
taskReelCount
+
"]"
);
...
...
@@ -603,12 +616,59 @@ public class LiteOrderCache {
public
Collection
<
String
>
excludeBarcodeIds
()
{
Collection
<
String
>
barcodeIds
=
new
ArrayList
<>();
Collection
<
LiteOrder
>
liteOrders
=
liteOrderMap
.
values
();
if
(
liteOrders
!=
null
&&
!
liteOrders
.
isEmpty
())
{
for
(
LiteOrder
liteOrder
:
liteOrderMap
.
values
())
{
List
<
LiteOrderItem
>
orderItems
=
liteOrder
.
getOrderItems
();
for
(
LiteOrderItem
orderItem
:
orderItems
)
{
barcodeIds
.
add
(
orderItem
.
getRi
());
}
}
}
return
barcodeIds
;
}
public
String
executeOrderByBarcode
(
String
barcode
){
Collection
<
LiteOrder
>
liteOrders
=
liteOrderMap
.
values
();
if
(
liteOrders
!=
null
&&
!
liteOrders
.
isEmpty
())
{
for
(
LiteOrder
liteOrder
:
liteOrderMap
.
values
())
{
for
(
LiteOrderItem
orderItem
:
liteOrder
.
getOrderItems
())
{
if
(
orderItem
.
getRi
().
equals
(
barcode
))
{
return
liteOrder
.
getOrderNo
();
}
}
}
}
return
null
;
}
public
Collection
<
LiteOrderItem
>
executeItems
()
{
Collection
<
LiteOrderItem
>
items
=
new
ArrayList
<>();
Collection
<
LiteOrder
>
liteOrders
=
liteOrderMap
.
values
();
if
(
liteOrders
!=
null
&&
!
liteOrders
.
isEmpty
())
{
for
(
LiteOrder
liteOrder
:
liteOrderMap
.
values
())
{
List
<
LiteOrderItem
>
orderItems
=
liteOrder
.
getOrderItems
();
for
(
LiteOrderItem
orderItem
:
orderItems
)
{
items
.
add
(
orderItem
);
}
}
}
return
items
;
}
public
Collection
<
String
>
executePartNumber
(){
Collection
<
String
>
partNumbers
=
new
ArrayList
<>();
Collection
<
LiteOrder
>
liteOrders
=
liteOrderMap
.
values
();
if
(
liteOrders
!=
null
&&
!
liteOrders
.
isEmpty
())
{
for
(
LiteOrder
liteOrder
:
liteOrderMap
.
values
())
{
List
<
LiteOrderItem
>
orderItems
=
liteOrder
.
getOrderItems
();
for
(
LiteOrderItem
orderItem
:
orderItems
)
{
partNumbers
.
add
(
orderItem
.
getPn
());
}
}
}
return
partNumbers
;
}
}
src/main/java/com/neotel/smfcore/core/order/service/po/LiteOrderItem.java
查看文件 @
437a3c1
...
...
@@ -80,6 +80,12 @@ public class LiteOrderItem extends BasePo implements Serializable ,Comparable<Li
*/
private
String
side
=
""
;
/**
* 库位
*/
private
String
posName
;
/**
* 出库是否满足要求,已出库数量大于需求数量
*/
...
...
src/main/java/com/neotel/smfcore/core/storage/service/manager/IStoragePosManager.java
查看文件 @
437a3c1
...
...
@@ -66,4 +66,6 @@ public interface IStoragePosManager extends IBaseManager<StoragePos> {
List
<
StoragePos
>
findPosList
(
String
storageId
,
List
<
String
>
posNames
);
List
<
StoragePos
>
getSameSizeContinuityEmptyPosList
(
Storage
storage
,
Barcode
barcode
)
throws
ValidateException
;
StoragePos
findByQueryOne
(
Query
query
);
}
src/main/java/com/neotel/smfcore/core/storage/service/manager/impl/StoragePosManagerImpl.java
查看文件 @
437a3c1
...
...
@@ -30,7 +30,6 @@ import org.springframework.stereotype.Service;
import
java.util.*
;
import
java.util.concurrent.ConcurrentHashMap
;
import
java.util.regex.Pattern
;
@Service
@Slf4j
...
...
@@ -562,6 +561,11 @@ public class StoragePosManagerImpl implements IStoragePosManager {
return
new
ArrayList
<>();
}
@Override
public
StoragePos
findByQueryOne
(
Query
query
)
{
return
storagePosDao
.
findOne
(
query
);
}
/**
* 获取下一库位的库位名(后缀数字+1)
*/
...
...
src/main/java/com/neotel/smfcore/core/system/service/po/DataLog.java
查看文件 @
437a3c1
...
...
@@ -302,9 +302,9 @@ public class DataLog extends BasePo implements Serializable {
*/
public
boolean
needRemoveFromCache
(){
if
(
isFinished
()
||
isCancel
()){
//
if(System.currentTimeMillis() - super.getUpdateDate().getTime() > 5 * 60 * 1000){
if
(
System
.
currentTimeMillis
()
-
super
.
getUpdateDate
().
getTime
()
>
5
*
60
*
1000
){
return
true
;
//
}
}
}
return
false
;
}
...
...
src/main/java/com/neotel/smfcore/custom/advantech/AdvantechApi.java
查看文件 @
437a3c1
...
...
@@ -392,6 +392,11 @@ public class AdvantechApi extends BaseSmfApiListener {
}
@Override
public
Barcode
barcodeInfo
(
String
barcodeInfoUrl
,
Barcode
barcode
)
{
return
null
;
}
@Override
public
boolean
isForThisApi
(
String
apiName
)
{
return
apiName
!=
null
&&
apiName
.
equalsIgnoreCase
(
"Advantech"
);
}
...
...
src/main/java/com/neotel/smfcore/custom/hella/handler/HellaApiHandler.java
查看文件 @
437a3c1
...
...
@@ -26,6 +26,11 @@ public class HellaApiHandler extends BaseSmfApiListener {
}
@Override
public
Barcode
barcodeInfo
(
String
barcodeInfoUrl
,
Barcode
barcode
)
{
return
null
;
}
@Override
public
boolean
isForThisApi
(
String
apiName
)
{
return
apiName
!=
null
&&
apiName
.
equalsIgnoreCase
(
"Hella"
);
}
...
...
src/main/java/com/neotel/smfcore/custom/hella/handler/HellaServiceHandler.java
查看文件 @
437a3c1
...
...
@@ -577,6 +577,11 @@ public class HellaServiceHandler extends BaseSmfApiListener implements IoHandler
}
}
@Override
public
Barcode
barcodeInfo
(
String
barcodeInfoUrl
,
Barcode
barcode
)
{
return
null
;
}
@Override
public
void
exceptionCaught
(
IoSession
session
,
Throwable
cause
)
throws
Exception
{
...
...
src/main/java/com/neotel/smfcore/custom/lizhen/LizhenApi.java
查看文件 @
437a3c1
package
com
.
neotel
.
smfcore
.
custom
.
lizhen
;
import
com.alibaba.fastjson.JSONObject
;
import
com.neotel.smfcore.common.exception.ApiException
;
import
com.neotel.smfcore.common.exception.ValidateException
;
import
com.neotel.smfcore.common.utils.HttpHelper
;
import
com.neotel.smfcore.common.utils.JsonUtil
;
import
com.neotel.smfcore.common.utils.StringUtils
;
import
com.neotel.smfcore.core.api.listener.BaseSmfApiListener
;
import
com.neotel.smfcore.core.api.listener.DefaultSmfApiListener
;
import
com.neotel.smfcore.core.barcode.service.po.Barcode
;
import
com.neotel.smfcore.core.order.LiteOrderCache
;
import
com.neotel.smfcore.core.order.service.po.LiteOrder
;
import
com.neotel.smfcore.core.system.service.po.DataLog
;
import
com.neotel.smfcore.custom.lizhen.innerBox.bean.PreWarningItem
;
import
com.neotel.smfcore.custom.lizhen.innerBox.util.PreWarningItemCache
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Service
;
import
java.text.SimpleDateFormat
;
import
java.util.*
;
@Slf4j
public
class
LizhenApi
extends
BaseSmfApiListener
{
@Service
public
class
LizhenApi
extends
DefaultSmfApiListener
{
@Autowired
private
LiteOrderCache
liteOrderCache
;
@Value
(
"${api.fetchGRUrl}"
)
private
String
fetchGRUrl
;
//7.获取MES物料数量
public
Barcode
getReelNum
(
String
reelNumUrl
,
String
reelId
){
log
.
info
(
"获取MES物料数量入参为:"
+
reelId
);
@Value
(
"${api.plant}"
)
private
String
plant
;
/**
* 获取gr标签的料卷数
* @param barcode
* @return
*/
public
int
fetchGR
(
Barcode
barcode
)
{
Map
<
String
,
Object
>
paramMap
=
new
HashMap
<>();
paramMap
.
put
(
"plant"
,
plant
);
paramMap
.
put
(
"gr_code"
,
barcode
.
getBarcode
());
paramMap
.
put
(
"gr_item"
,
barcode
.
getMemo
());
paramMap
.
put
(
"partNumber"
,
barcode
.
getPartNumber
());
log
.
info
(
"gr标签入参为:"
+
JsonUtil
.
toJsonStr
(
paramMap
));
try
{
String
result
=
HttpHelper
.
postJson
(
fetchGRUrl
,
paramMap
);
log
.
info
(
"gr标签出参为:"
+
result
);
}
catch
(
ApiException
e
)
{
e
.
printStackTrace
();
}
return
0
;
}
@Override
public
Barcode
barcodeInfo
(
String
barcodeInfoUrl
,
Barcode
barcode
)
{
log
.
info
(
"获取MES物料数量入参为:"
+
barcode
.
getBarcode
());
try
{
String
result
=
HttpHelper
.
postJson
(
reelNumUrl
,
reelId
);
String
result
=
HttpHelper
.
postJson
(
barcodeInfoUrl
,
barcode
.
getBarcode
()
);
log
.
info
(
"获取MES物料数量出参为:"
+
result
);
Map
<
String
,
Object
>
resultMap
=
JsonUtil
.
toMap
(
result
);
Object
status
=
resultMap
.
get
(
"status"
);
if
(
status
!=
null
){
if
(
status
.
equals
(
200
)){
Map
<
String
,
Object
>
dataMap
=
JsonUtil
.
toMap
(
resultMap
.
get
(
"data"
).
toString
());
String
reelID
=
dataMap
.
get
(
"reelID"
)
==
null
?
""
:
dataMap
.
get
(
"reelID"
).
toString
();
String
partNum
=
dataMap
.
get
(
"partNum"
)
==
null
?
""
:
dataMap
.
get
(
"partNum"
).
toString
();
String
partSpec
=
dataMap
.
get
(
"partSpec"
)
==
null
?
""
:
dataMap
.
get
(
"partSpec"
).
toString
();
int
qty
=
dataMap
.
get
(
"qty"
)
==
null
?
0
:
Integer
.
valueOf
(
dataMap
.
get
(
"qty"
).
toString
());
String
vendor
=
dataMap
.
get
(
"vendor"
)
==
null
?
""
:
dataMap
.
get
(
"vendor"
).
toString
();
String
vendorNum
=
dataMap
.
get
(
"vendorNum"
)
==
null
?
""
:
dataMap
.
get
(
"vendorNum"
).
toString
();
String
dataCode
=
dataMap
.
get
(
"dataCode"
)
==
null
?
""
:
dataMap
.
get
(
"dataCode"
).
toString
();
String
lotCode
=
dataMap
.
get
(
"lotCode"
)
==
null
?
""
:
dataMap
.
get
(
"lotCode"
).
toString
();
Barcode
barcode
=
new
Barcode
();
JSONObject
resultJson
=
JsonUtil
.
toObj
(
result
,
JSONObject
.
class
);
Integer
status
=
resultJson
.
getInteger
(
"status"
);
if
(
status
!=
null
)
{
if
(
status
==
200
)
{
JSONObject
dataJson
=
resultJson
.
getJSONObject
(
"data"
);
String
reelID
=
dataJson
.
get
(
"reelID"
)
==
null
?
""
:
dataJson
.
get
(
"reelID"
).
toString
();
String
partNum
=
dataJson
.
get
(
"partNum"
)
==
null
?
""
:
dataJson
.
get
(
"partNum"
).
toString
();
String
partSpec
=
dataJson
.
get
(
"partSpec"
)
==
null
?
""
:
dataJson
.
get
(
"partSpec"
).
toString
();
int
qty
=
dataJson
.
get
(
"qty"
)
==
null
?
0
:
Integer
.
valueOf
(
dataJson
.
get
(
"qty"
).
toString
());
String
vendor
=
dataJson
.
get
(
"vendor"
)
==
null
?
""
:
dataJson
.
get
(
"vendor"
).
toString
();
String
vendorNum
=
dataJson
.
get
(
"vendorNum"
)
==
null
?
""
:
dataJson
.
get
(
"vendorNum"
).
toString
();
String
dataCode
=
dataJson
.
get
(
"dataCode"
)
==
null
?
""
:
dataJson
.
get
(
"dataCode"
).
toString
();
String
lotCode
=
dataJson
.
get
(
"lotCode"
)
==
null
?
""
:
dataJson
.
get
(
"lotCode"
).
toString
();
if
(
StringUtils
.
isBlank
(
reelID
)){
return
null
;
}
barcode
.
setBarcode
(
reelID
);
barcode
.
setPartNumber
(
partNum
);
barcode
.
setAmount
(
qty
);
...
...
@@ -57,68 +96,169 @@ public class LizhenApi extends BaseSmfApiListener {
return
null
;
}
/**
* 入库验证
* @param inCheckUrl
* @param barcode
* @return
* @throws ValidateException
*/
@Override
public
Barcode
canPutIn
(
String
inCheckUrl
,
Barcode
barcode
)
throws
ValidateException
{
String
resultStr
=
"false"
;
Map
<
String
,
Object
>
paramMap
=
new
HashMap
<>();
paramMap
.
put
(
"ipn"
,
barcode
.
getPartNumber
());
paramMap
.
put
(
"reelId"
,
barcode
.
getBarcode
());
paramMap
.
put
(
"wo"
,
""
);
paramMap
.
put
(
"datecode"
,
barcode
.
getDateCode
());
paramMap
.
put
(
"lot"
,
barcode
.
getBatch
());
paramMap
.
put
(
"vendor"
,
barcode
.
getProvider
());
String
param
=
JsonUtil
.
toJsonStr
(
paramMap
);
log
.
info
(
"禁用料接口wmsCheckReelfob入参为:"
+
param
);
try
{
String
result
=
HttpHelper
.
postJson
(
inCheckUrl
,
paramMap
);
log
.
info
(
barcode
.
getBarcode
()
+
"禁用料接口wmsCheckReelfob出参为:"
+
result
);
JSONObject
resultJson
=
JsonUtil
.
toObj
(
result
,
JSONObject
.
class
);
if
(
resultJson
!=
null
)
{
if
(
resultJson
.
getString
(
"data"
)
!=
null
)
{
JSONObject
dataJson
=
resultJson
.
getJSONObject
(
"data"
);
if
(
dataJson
.
get
(
"result"
)
!=
null
&&
dataJson
.
getBoolean
(
"result"
)
==
true
)
{
resultStr
=
""
;
}
else
{
resultStr
=
dataJson
.
get
(
"message"
).
toString
();
}
}
}
//log.info("禁用料接口wmsCheckReelfob出参为:" + result);
}
catch
(
ApiException
e
)
{
e
.
printStackTrace
();
}
if
(
StringUtils
.
isNotBlank
(
resultStr
))
{
throw
new
ValidateException
(
"smfcore.mesApi.inCheck.ng"
,
"MES验证失败:"
+
barcode
.
getBarcode
()
+
"验证失败:"
+
resultStr
);
}
return
barcode
;
}
//3.IMES提供接收发料明细接口
public
void
saveReelInfo
(
String
outNotifyUrl
,
DataLog
task
){
Map
<
String
,
Object
>
paramMap
=
new
HashMap
<>();
Map
<
String
,
Object
>
dataMap
=
new
HashMap
<>();
/**
* 保存物料接口
* @param inNotifyUrl
* @param task
*/
@Override
public
void
inTaskStatusChange
(
String
inNotifyUrl
,
DataLog
task
)
{
Map
<
String
,
Object
>
paramMap
=
new
HashMap
<>();
Map
<
String
,
Object
>
dataMap
=
new
HashMap
<>();
String
sourceId
=
task
.
getSourceId
();
dataMap
.
put
(
"pickingid"
,
""
);
LiteOrder
liteOrder
=
liteOrderCache
.
getOrderSortItems
(
sourceId
);
if
(
liteOrder
!=
null
){
dataMap
.
put
(
"pickingid"
,
liteOrder
.
getOrderNo
());
}
dataMap
.
put
(
"wo"
,
""
);
dataMap
.
put
(
"reelno"
,
task
.
getBarcode
());
dataMap
.
put
(
"ipn"
,
task
.
getPartNumber
());
dataMap
.
put
(
"qty"
,
task
.
getNum
());
dataMap
.
put
(
"datecode"
,
new
SimpleDateFormat
(
"yyyyMMdd"
).
format
(
new
Date
()));
dataMap
.
put
(
"lot"
,
task
.
getPosName
());
dataMap
.
put
(
"vendor"
,
task
.
getPosName
());
dataMap
.
put
(
"batch"
,
task
.
getBatchId
());
if
(
liteOrder
!=
null
)
{
dataMap
.
put
(
"pickingid"
,
liteOrder
.
getOrderNo
());
}
//dataMap.put("pickingid", "20220214162216");
dataMap
.
put
(
"wo"
,
""
);
dataMap
.
put
(
"reelno"
,
task
.
getBarcode
());
dataMap
.
put
(
"ipn"
,
task
.
getPartNumber
());
Barcode
barcode
=
barcodeManager
.
findByBarcode
(
task
.
getBarcode
());
if
(
barcode
!=
null
)
{
dataMap
.
put
(
"qty"
,
barcode
.
getAmount
());
dataMap
.
put
(
"datecode"
,
barcode
.
getDateCode
());
dataMap
.
put
(
"lot"
,
barcode
.
getBatch
());
dataMap
.
put
(
"vendor"
,
barcode
.
getProvider
());
dataMap
.
put
(
"batch"
,
""
);
}
paramMap
.
put
(
"data"
,
Arrays
.
asList
(
dataMap
));
String
param
=
JsonUtil
.
toJsonStr
(
paramMap
);
log
.
info
(
"IMES提供接收发料明细接口入参为:"
+
param
);
try
{
String
result
=
HttpHelper
.
postJson
(
out
NotifyUrl
,
paramMap
);
String
result
=
HttpHelper
.
postJson
(
in
NotifyUrl
,
paramMap
);
log
.
info
(
"IMES提供接收发料明细接口出参为:"
+
result
);
}
catch
(
ApiException
e
)
{
e
.
printStackTrace
();
}
}
//2.禁用料接口MES提供外围系统调用
public
static
String
wmsCheckReelfob
(
String
checkReelfobUrl
,
Barcode
barcode
)
{
String
resultStr
=
"false"
;
/**
* 保存物料接口
* @param outNotifyUrl
* @param task
*/
@Override
public
void
outTaskStatusChange
(
String
outNotifyUrl
,
DataLog
task
)
{
Map
<
String
,
Object
>
paramMap
=
new
HashMap
<>();
paramMap
.
put
(
"ipn"
,
barcode
.
getPartNumber
());
paramMap
.
put
(
"reelId"
,
barcode
.
getBarcode
());
paramMap
.
put
(
"wo"
,
""
);
paramMap
.
put
(
"datecode"
,
barcode
.
getDateCode
());
paramMap
.
put
(
"lot"
,
barcode
.
getPosName
());
paramMap
.
put
(
"vendor"
,
barcode
.
getProviderNumber
());
Map
<
String
,
Object
>
dataMap
=
new
HashMap
<>();
String
sourceId
=
task
.
getSourceId
();
dataMap
.
put
(
"pickingid"
,
""
);
LiteOrder
liteOrder
=
liteOrderCache
.
getOrderSortItems
(
sourceId
);
if
(
liteOrder
!=
null
)
{
dataMap
.
put
(
"pickingid"
,
liteOrder
.
getSo
());
}
dataMap
.
put
(
"wo"
,
""
);
dataMap
.
put
(
"reelno"
,
task
.
getBarcode
());
dataMap
.
put
(
"ipn"
,
task
.
getPartNumber
());
Barcode
barcode
=
barcodeManager
.
findByBarcode
(
task
.
getBarcode
());
if
(
barcode
!=
null
)
{
dataMap
.
put
(
"qty"
,
barcode
.
getAmount
());
dataMap
.
put
(
"datecode"
,
barcode
.
getDateCode
());
dataMap
.
put
(
"lot"
,
barcode
.
getBatch
());
dataMap
.
put
(
"vendor"
,
barcode
.
getProvider
());
dataMap
.
put
(
"batch"
,
""
);
}
paramMap
.
put
(
"data"
,
Arrays
.
asList
(
dataMap
));
String
param
=
JsonUtil
.
toJsonStr
(
paramMap
);
log
.
info
(
"
禁用料接口wmsCheckReelfob
入参为:"
+
param
);
log
.
info
(
"
IMES提供接收发料明细接口
入参为:"
+
param
);
try
{
String
result
=
HttpHelper
.
postJson
(
checkReelfobUrl
,
paramMap
);
Map
<
String
,
Object
>
resultMap
=
JsonUtil
.
toMap
(
result
);
if
(
resultMap
!=
null
)
{
String
result
=
HttpHelper
.
postJson
(
outNotifyUrl
,
paramMap
);
log
.
info
(
"IMES提供接收发料明细接口出参为:"
+
result
);
}
catch
(
ApiException
e
)
{
e
.
printStackTrace
();
}
}
/**
* 获取到需求单数据
* @param fetchOrderUrl
* @param orderNumber
* @param username
* @return
*/
@Override
public
LiteOrder
fetchOrder
(
String
fetchOrderUrl
,
String
orderNumber
,
String
username
)
{
log
.
info
(
"收到需求单号--"
+
orderNumber
);
String
result
=
HttpHelper
.
sendGet
(
fetchOrderUrl
+
"workorder="
+
orderNumber
);
log
.
info
(
orderNumber
+
"返回数据为--"
+
result
);
if
(
StringUtils
.
isNotBlank
(
result
))
{
List
<
PreWarningItem
>
items
=
new
ArrayList
<>();
Map
resultMap
=
JsonUtil
.
toObj
(
result
,
Map
.
class
);
if
(
resultMap
.
get
(
"data"
)
!=
null
)
{
Map
<
String
,
Object
>
dataMap
=
JsonUtil
.
toMap
(
resultMap
.
get
(
"data"
).
toString
());
if
(
dataMap
.
get
(
"result"
)
!=
null
&&
dataMap
.
get
(
"result"
).
equals
(
true
))
{
resultStr
=
""
;
}
else
{
resultStr
=
dataMap
.
get
(
"message"
).
toString
();
List
<
Map
>
datas
=
JsonUtil
.
toList
(
resultMap
.
get
(
"data"
).
toString
(),
Map
.
class
);
for
(
Map
data
:
datas
)
{
String
line
=
data
.
get
(
"LINE"
).
toString
();
String
face
=
data
.
get
(
"FACE"
).
toString
();
String
machine
=
data
.
get
(
"MACHINE"
).
toString
();
String
slot
=
data
.
get
(
"SLOT"
).
toString
();
String
module
=
data
.
get
(
"MODULE"
).
toString
();
String
partNumber
=
data
.
get
(
"ITEM_PART_NUMBER"
).
toString
();
PreWarningItem
item
=
new
PreWarningItem
();
item
.
setLine
(
line
);
item
.
setPartnumber
(
partNumber
);
item
.
setSubslot
(
""
);
item
.
setSlot
(
slot
);
item
.
setSide
(
face
);
item
.
setMachinename
(
machine
);
item
.
setStation
(
module
);
items
.
add
(
item
);
}
}
if
(
items
!=
null
&&
!
items
.
isEmpty
())
{
return
PreWarningItemCache
.
createAndExecuteLiteOrder
(
items
);
}
log
.
info
(
"禁用料接口wmsCheckReelfob出参为:"
+
result
);
}
catch
(
ApiException
e
)
{
e
.
printStackTrace
();
}
return
resultStr
;
return
null
;
}
@Override
...
...
src/main/java/com/neotel/smfcore/custom/lizhen/LizhenController.java
查看文件 @
437a3c1
...
...
@@ -3,25 +3,30 @@ package com.neotel.smfcore.custom.lizhen;
import
com.neotel.smfcore.common.bean.ResultBean
;
import
com.neotel.smfcore.common.utils.JsonUtil
;
import
com.neotel.smfcore.common.utils.StringUtils
;
import
com.neotel.smfcore.core.barcode.service.po.Barcode
;
import
com.neotel.smfcore.core.device.enums.OP_STATUS
;
import
com.neotel.smfcore.core.order.LiteOrderCache
;
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.storage.service.manager.IStoragePosManager
;
import
com.neotel.smfcore.core.storage.service.po.StoragePos
;
import
com.neotel.smfcore.custom.lizhen.innerBox.bean.PreWarningItem
;
import
com.neotel.smfcore.custom.lizhen.innerBox.util.PreWarningItemCache
;
import
com.neotel.smfcore.custom.lizhen.innerBox.util.service.PreWarningItemManager
;
import
com.neotel.smfcore.security.annotation.AnonymousAccess
;
import
io.swagger.annotations.ApiOperation
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.domain.Sort
;
import
org.springframework.data.mongodb.core.query.Criteria
;
import
org.springframework.data.mongodb.core.query.Query
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.*
;
@Slf4j
@RestController
...
...
@@ -34,78 +39,78 @@ public class LizhenController {
@Autowired
private
LiteOrderCache
liteOrderCache
;
//1.发料明细
@Autowired
private
IStoragePosManager
storagePosManager
;
@Autowired
private
PreWarningItemManager
preWarningItemManager
;
/**
* 发料明细
*
* @param params
* @return
*/
@PostMapping
(
"/EPickingList"
)
@AnonymousAccess
public
ResultBean
EPickingList
(
@RequestBody
List
<
Map
<
String
,
Object
>>
params
)
{
if
(
params
==
null
||
params
.
isEmpty
())
{
return
ResultBean
.
newErrorResult
(-
1
,
"smfcore.valueCanotNull"
,
"参数不能为空"
);
}
log
.
info
(
"发料明细数据--"
+
JsonUtil
.
toJsonStr
(
params
));
for
(
Map
<
String
,
Object
>
param
:
params
)
{
String
pickingId
=
param
.
get
(
"picking_id"
)
==
null
?
""
:
param
.
get
(
"picking_id"
).
toString
();
//工单号
if
(
StringUtils
.
isBlank
(
pickingId
))
{
return
ResultBean
.
newErrorResult
(-
1
,
"smfcore.valueCanotNull"
,
"{}不能为空"
,
new
String
[]{
"picking_id"
});
}
String
plantCode
=
param
.
get
(
"plant_code"
)
==
null
?
""
:
param
.
get
(
"plant_code"
).
toString
();
//需求单号
if
(
StringUtils
.
isBlank
(
plantCode
))
{
return
ResultBean
.
newErrorResult
(-
1
,
"smfcore.valueCanotNull"
,
"{}不能为空"
,
new
String
[]{
"plant_code"
});
//任务单号
String
orderNo
=
param
.
get
(
"picking_id"
)
==
null
?
""
:
param
.
get
(
"picking_id"
).
toString
();
if
(
StringUtils
.
isBlank
(
orderNo
))
{
return
ResultBean
.
newErrorResult
(-
1
,
""
,
"picking_id不能为空"
);
}
String
line
=
param
.
get
(
"line"
)
==
null
?
""
:
param
.
get
(
"line"
).
toString
();
//线别
//线别
String
line
=
param
.
get
(
"line"
)
==
null
?
""
:
param
.
get
(
"line"
).
toString
();
if
(
StringUtils
.
isBlank
(
line
))
{
return
ResultBean
.
newErrorResult
(-
1
,
"
smfcore.valueCanotNull"
,
"{}不能为空"
,
new
String
[]{
"line"
}
);
return
ResultBean
.
newErrorResult
(-
1
,
"
"
,
"line不能为空"
);
}
//设置工单信息
LiteOrder
liteOrder
=
new
LiteOrder
();
liteOrder
.
setOrderNo
(
pickingId
);
liteOrder
.
setOrderNo
(
preWarningItemManager
.
getNextId
(
"L"
+
PreWarningItemCache
.
class
.
getName
()));
liteOrder
.
setSo
(
orderNo
);
liteOrder
.
setLine
(
line
);
//开始处理工单详情信息
List
<
LiteOrderItem
>
liteOrderItems
=
new
ArrayList
<>();
String
item
=
param
.
get
(
"ITEM"
)
==
null
?
""
:
param
.
get
(
"ITEM"
).
toString
();
if
(
StringUtils
.
isBlank
(
item
))
{
return
ResultBean
.
newErrorResult
(-
1
,
"smfcore.valueCanotNull"
,
"{}不能为空"
,
new
String
[]{
"item"
});
}
List
<
Map
>
itemMaps
=
JsonUtil
.
toList
(
item
,
Map
.
class
);
for
(
Map
itemMap
:
itemMaps
)
{
String
face
=
itemMap
.
get
(
"face"
)
==
null
?
""
:
itemMap
.
get
(
"face"
).
toString
();
//面别
if
(
StringUtils
.
isBlank
(
face
))
{
return
ResultBean
.
newErrorResult
(-
1
,
"smfcore.valueCanotNull"
,
"{}不能为空"
,
new
String
[]{
"face"
});
}
String
mo
=
itemMap
.
get
(
"mo"
)
==
null
?
""
:
itemMap
.
get
(
"mo"
).
toString
();
if
(
StringUtils
.
isBlank
(
mo
))
{
return
ResultBean
.
newErrorResult
(-
1
,
"smfcore.valueCanotNull"
,
"{}不能为空"
,
new
String
[]{
"mo"
});
}
String
materialCode
=
itemMap
.
get
(
"material_code"
)
==
null
?
""
:
itemMap
.
get
(
"material_code"
).
toString
();
//物料编号
if
(
StringUtils
.
isBlank
(
materialCode
))
{
return
ResultBean
.
newErrorResult
(-
1
,
"smfcore.valueCanotNull"
,
"{}不能为空"
,
new
String
[]{
"material_code"
});
}
String
brand
=
itemMap
.
get
(
"brand"
)
==
null
?
""
:
itemMap
.
get
(
"brand"
).
toString
();
//品牌
String
batchCode
=
itemMap
.
get
(
"batch_code"
)
==
null
?
""
:
itemMap
.
get
(
"batch_code"
).
toString
();
//批次号
Integer
reqQty
=
itemMap
.
get
(
"req_qty"
)
==
null
?
null
:
Integer
.
valueOf
(
itemMap
.
get
(
"req_qty"
).
toString
());
//数量
Integer
reqReel
=
itemMap
.
get
(
"req_reel"
)
==
null
?
null
:
Integer
.
valueOf
(
itemMap
.
get
(
"req_reel"
).
toString
());
//盘数
String
warehouse
=
itemMap
.
get
(
"warehouse"
)
==
null
?
""
:
itemMap
.
get
(
"material_code"
).
toString
();
//位置
if
(
StringUtils
.
isBlank
(
warehouse
))
{
return
ResultBean
.
newErrorResult
(-
1
,
"smfcore.valueCanotNull"
,
"{}不能为空"
,
new
String
[]{
"material_code"
});
}
//工单详情进行赋值操作
LiteOrderItem
liteOrderItem
=
new
LiteOrderItem
();
liteOrderItem
.
setPn
(
materialCode
);
liteOrderItem
.
setSide
(
face
);
liteOrderItem
.
setNeedNum
(
reqQty
);
liteOrderItem
.
setNeedReelCount
(
reqReel
);
liteOrderItem
.
setFeederInfo
(
warehouse
);
if
(
itemMap
.
get
(
"SLOT"
)
!=
null
){
String
slot
=
JsonUtil
.
toJsonStr
(
itemMap
.
get
(
"SLOT"
));
List
<
Map
>
slotMaps
=
JsonUtil
.
toList
(
slot
,
Map
.
class
);
for
(
Map
slotMap
:
slotMaps
)
{
String
machine
=
slotMap
.
get
(
"machine"
)
==
null
?
null
:
slotMap
.
get
(
"machine"
).
toString
();
//机器编号
String
zone
=
slotMap
.
get
(
"zone"
)
==
null
?
null
:
slotMap
.
get
(
"zone"
).
toString
();
//区域
}
}
liteOrderItems
.
add
(
liteOrderItem
);
}
liteOrder
.
setOrderItems
(
liteOrderItems
);
liteOrder
.
setType
(
2
);
//liteOrderItem
List
<
LiteOrderItem
>
orderItems
=
new
ArrayList
<>();
String
itemStr
=
param
.
get
(
"ITEM"
)
==
null
?
""
:
param
.
get
(
"ITEM"
).
toString
();
if
(
StringUtils
.
isBlank
(
itemStr
))
{
return
ResultBean
.
newErrorResult
(-
1
,
""
,
"ITEM不能为空"
);
}
List
<
Map
>
items
=
JsonUtil
.
toList
(
itemStr
,
Map
.
class
);
for
(
Map
item
:
items
)
{
String
face
=
item
.
get
(
"face"
)
==
null
?
""
:
item
.
get
(
"face"
).
toString
();
String
mo
=
item
.
get
(
"mo"
)
==
null
?
""
:
item
.
get
(
"mo"
).
toString
();
String
materialCode
=
item
.
get
(
"material_code"
)
==
null
?
""
:
item
.
get
(
"material_code"
).
toString
();
String
brand
=
item
.
get
(
"brand"
)
==
null
?
""
:
item
.
get
(
"brand"
).
toString
();
String
batchCode
=
item
.
get
(
"batch_code"
)
==
null
?
""
:
item
.
get
(
"batch_code"
).
toString
();
int
reqQty
=
item
.
get
(
"req_qty"
)
==
null
?
0
:
Integer
.
valueOf
(
item
.
get
(
"req_qty"
).
toString
());
int
reqReel
=
item
.
get
(
"req_reel"
)
==
null
?
0
:
Integer
.
valueOf
(
item
.
get
(
"req_reel"
).
toString
());
String
warehouse
=
item
.
get
(
"warehouse"
)
==
null
?
""
:
item
.
get
(
"warehouse"
).
toString
();
List
<
Barcode
>
barcodes
=
getBarcodesBypn
(
materialCode
,
reqQty
);
if
(
barcodes
!=
null
&&
!
barcodes
.
isEmpty
()){
for
(
Barcode
barcode
:
barcodes
)
{
LiteOrderItem
orderItem
=
new
LiteOrderItem
();
orderItem
.
setSide
(
face
);
orderItem
.
setPn
(
materialCode
);
orderItem
.
setRi
(
barcode
.
getBarcode
());
orderItem
.
setNeedNum
(
barcode
.
getAmount
());
orderItem
.
setPosName
(
barcode
.
getPosName
());
orderItems
.
add
(
orderItem
);
}
}
}
if
(
orderItems
!=
null
&&
!
orderItems
.
isEmpty
())
{
liteOrder
.
setTaskReelCount
(
orderItems
.
size
());
liteOrder
.
setTotalTaskReelCount
(
orderItems
.
size
());
liteOrder
.
setOrderItems
(
orderItems
);
liteOrder
=
liteOrderManager
.
createWithItems
(
liteOrder
);
log
.
info
(
"新增加订单:"
+
liteOrder
.
getOrderNo
()
+
"["
+
liteOrder
.
getId
()
+
"],共"
+
orderItems
.
size
()
+
"条工单详情"
);
liteOrderCache
.
addOrderToMap
(
liteOrder
);
}
}
return
ResultBean
.
newOkResult
(
""
);
}
...
...
@@ -113,21 +118,20 @@ public class LizhenController {
@ApiOperation
(
"5.缺料预警"
)
@PostMapping
(
"/mPickingList"
)
@AnonymousAccess
public
ResultBean
mPickingList
(
@RequestBody
Map
<
String
,
List
<
Map
<
String
,
String
>>>
paramMap
)
{
List
<
Map
<
String
,
String
>>
datas
=
paramMap
.
get
(
"data"
);
if
(
datas
==
null
||
datas
.
isEmpty
())
{
return
ResultBean
.
newErrorResult
(-
1
,
""
,
"data不能为空"
);
public
ResultBean
mPickingList
(
@RequestBody
List
<
Map
<
String
,
String
>>
params
)
{
if
(
params
==
null
||
params
.
isEmpty
())
{
return
ResultBean
.
newErrorResult
(-
1
,
""
,
"数据不能为空"
);
}
List
<
PreWarningItem
>
items
=
new
ArrayList
<>();
for
(
Map
<
String
,
String
>
data
:
data
s
)
{
for
(
Map
<
String
,
String
>
data
:
param
s
)
{
PreWarningItem
item
=
new
PreWarningItem
();
item
.
setMachinename
(
data
.
get
(
"
machinename
"
));
item
.
setStation
(
data
.
get
(
"
station
"
));
item
.
setSide
(
data
.
get
(
"
side
"
));
item
.
setSlot
(
data
.
get
(
"
slot
"
));
item
.
setSubslot
(
data
.
get
(
"
subslot
"
));
item
.
setPartnumber
(
data
.
get
(
"
partnumber
"
));
item
.
setLine
(
data
.
get
(
"
line
"
));
item
.
setMachinename
(
data
.
get
(
"
MACHINENAME
"
));
item
.
setStation
(
data
.
get
(
"
STATION
"
));
item
.
setSide
(
data
.
get
(
"
SIDE
"
));
item
.
setSlot
(
data
.
get
(
"
SLOT
"
));
item
.
setSubslot
(
data
.
get
(
"
SUBSLOT
"
));
item
.
setPartnumber
(
data
.
get
(
"
PARTNUMBER
"
));
item
.
setLine
(
data
.
get
(
"
LINE
"
));
items
.
add
(
item
);
}
if
(
items
!=
null
&&
!
items
.
isEmpty
())
{
...
...
@@ -137,4 +141,34 @@ public class LizhenController {
}
private
List
<
Barcode
>
getBarcodesBypn
(
String
partNumber
,
int
reqQty
)
{
Query
q
=
new
Query
();
Criteria
c
=
Criteria
.
where
(
"barcode.subCodeList.partNumber"
).
is
(
partNumber
);
//料箱中parnumber的物料
c
.
and
(
"barcode"
).
exists
(
true
).
and
(
"enabled"
).
is
(
true
);
Collection
<
String
>
barcodeIds
=
liteOrderCache
.
excludeBarcodeIds
();
Sort
sort
=
Sort
.
by
(
Sort
.
Direction
.
ASC
,
"canCheckOutTime"
,
"barcode.usedCount"
);
List
<
StoragePos
>
storagePoss
=
storagePosManager
.
findByQuery
(
q
.
addCriteria
(
c
).
with
(
sort
));
List
<
Barcode
>
barcodes
=
new
ArrayList
<>();
int
amount
=
0
;
if
(
storagePoss
!=
null
&&
!
storagePoss
.
isEmpty
())
{
for
(
StoragePos
pos
:
storagePoss
)
{
List
<
Barcode
>
subCodeList
=
pos
.
getBarcode
().
getSubCodeList
();
for
(
Barcode
barcode
:
subCodeList
)
{
if
(
barcode
.
getPartNumber
().
equals
(
partNumber
))
{
if
(
barcodeIds
!=
null
&&
!
barcodeIds
.
isEmpty
()){
if
(
barcodeIds
.
contains
(
barcode
.
getBarcode
())){
continue
;
}
}
barcodes
.
add
(
barcode
);
amount
=
amount
+
barcode
.
getAmount
();
if
(
amount
>=
reqQty
)
{
break
;
}
}
}
}
}
return
barcodes
;
}
}
src/main/java/com/neotel/smfcore/custom/lizhen/agvBox/rest/WarehouseController.java
查看文件 @
437a3c1
...
...
@@ -8,6 +8,7 @@ import com.neotel.smfcore.common.utils.JsonUtil;
import
com.neotel.smfcore.common.utils.ReelLockPosUtil
;
import
com.neotel.smfcore.common.utils.SecurityUtils
;
import
com.neotel.smfcore.common.utils.StringUtils
;
import
com.neotel.smfcore.core.api.SmfApi
;
import
com.neotel.smfcore.core.barcode.bean.CodeBean
;
import
com.neotel.smfcore.core.barcode.service.manager.IBarcodeManager
;
import
com.neotel.smfcore.core.barcode.service.po.Barcode
;
...
...
@@ -15,6 +16,11 @@ import com.neotel.smfcore.core.barcode.utils.CodeResolve;
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.order.LiteOrderCache
;
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.storage.enums.DeviceType
;
import
com.neotel.smfcore.core.storage.service.manager.IStoragePosManager
;
import
com.neotel.smfcore.core.storage.service.po.Storage
;
...
...
@@ -22,9 +28,11 @@ import com.neotel.smfcore.core.storage.service.po.StoragePos;
import
com.neotel.smfcore.core.system.service.manager.IDataLogManager
;
import
com.neotel.smfcore.core.system.service.po.DataLog
;
import
com.neotel.smfcore.core.system.util.TaskService
;
import
com.neotel.smfcore.custom.lizhen.LizhenApi
;
import
com.neotel.smfcore.custom.lizhen.agvBox.bean.Station
;
import
com.neotel.smfcore.custom.lizhen.agvBox.util.StationCacheUtil
;
import
com.neotel.smfcore.security.annotation.AnonymousAccess
;
import
com.sun.org.apache.regexp.internal.RE
;
import
io.swagger.annotations.ApiOperation
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.logging.log4j.util.Strings
;
...
...
@@ -37,6 +45,9 @@ import org.springframework.web.bind.annotation.RequestMapping;
import
org.springframework.web.bind.annotation.RestController
;
import
java.util.*
;
import
java.util.concurrent.ConcurrentHashMap
;
import
java.util.concurrent.ConcurrentMap
;
import
java.util.concurrent.CopyOnWriteArrayList
;
import
java.util.regex.Pattern
;
import
java.util.stream.Collectors
;
...
...
@@ -51,7 +62,6 @@ public class WarehouseController {
@Autowired
private
IBarcodeManager
barcodeManager
;
@Autowired
private
CodeResolve
codeResolve
;
...
...
@@ -67,6 +77,25 @@ public class WarehouseController {
@Autowired
private
DataCache
dataCache
;
@Autowired
private
LizhenApi
lizhenApi
;
@Autowired
private
SmfApi
smfApi
;
@Autowired
private
LiteOrderCache
liteOrderCache
;
@Autowired
private
ILiteOrderManager
liteOrderManager
;
@Autowired
private
ILiteOrderItemManager
liteOrderItemManager
;
private
static
Map
<
String
,
Map
<
String
,
Integer
>>
boxALlCountMap
=
new
ConcurrentHashMap
<>();
private
static
Map
<
String
,
Integer
>
boxCount
=
new
ConcurrentHashMap
<>();
@ApiOperation
(
"选择物料"
)
@RequestMapping
(
"/chooseReel"
)
...
...
@@ -80,6 +109,13 @@ public class WarehouseController {
return
ResultBean
.
newErrorResult
(-
1
,
""
,
"请核实尺寸,数量,工位名称是否为空"
,
new
String
[]{});
}
String
grLabel
=
paramMap
.
get
(
"grLabel"
);
//GR标签
if
(
StringUtils
.
isNotBlank
(
grLabel
))
{
CodeBean
codeBean
=
codeResolve
.
resolveSingleCode
(
grLabel
);
if
(
codeBean
.
isValid
())
{
int
grNum
=
lizhenApi
.
fetchGR
(
codeBean
.
getBarcode
());
}
}
int
platsize
=
getPlatsizeOrHeight
(
size
,
0
);
int
height
=
getPlatsizeOrHeight
(
size
,
1
);
...
...
@@ -94,6 +130,7 @@ public class WarehouseController {
station
.
setReelNum
(
Integer
.
valueOf
(
num
));
station
.
setReelCurrentNum
(
0
);
station
.
setLastScanBoxCode
(
null
);
station
.
setBoxCurrentNum
(
0
);
StationCacheUtil
.
updateStation
(
station
);
return
ResultBean
.
newOkResult
(
""
);
}
...
...
@@ -109,57 +146,13 @@ public class WarehouseController {
return
ResultBean
.
newErrorResult
(-
1
,
""
,
"尺寸不能为空"
,
new
String
[]{});
}
StoragePos
pos
=
getEmptyBoxPos
(
platsize
);
if
(
pos
==
null
){
return
ResultBean
.
newErrorResult
(-
1
,
""
,
"未找到可用料箱"
,
new
String
[]{});
if
(
pos
==
null
)
{
return
ResultBean
.
newErrorResult
(-
1
,
""
,
"未找到可用料箱"
,
new
String
[]{});
}
generateTask
(
dataCache
.
getStorageById
(
pos
.
getStorageId
()),
pos
.
getBarcode
(),
pos
,
OP
.
CHECKOUT
,
OP_STATUS
.
WAIT
.
name
(),
name
);
generateTask
(
dataCache
.
getStorageById
(
pos
.
getStorageId
()),
pos
.
getBarcode
(),
pos
,
OP
.
CHECKOUT
,
OP_STATUS
.
WAIT
.
name
(),
name
);
return
ResultBean
.
newOkResult
(
""
);
}
private
StoragePos
getEmptyBoxPos
(
String
platsize
)
{
//得到料盒类型
String
boxCode
=
""
;
if
(
"7"
.
equals
(
platsize
))
{
boxCode
=
"CS"
;
}
else
if
(
"13"
.
equals
(
platsize
))
{
boxCode
=
"CM"
;
}
else
if
(
"15"
.
equals
(
platsize
))
{
boxCode
=
"CB"
;
}
//料仓类型是agv的
String
storageId
=
""
;
Collection
<
Storage
>
storages
=
dataCache
.
getAllStorage
().
values
();
for
(
Storage
storage
:
storages
)
{
if
(
storage
.
isType
(
new
DeviceType
[]{
DeviceType
.
AGV_BOX
}))
{
storageId
=
storage
.
getId
();
}
}
Criteria
c
=
Criteria
.
where
(
"barcode"
).
exists
(
true
)
.
and
(
"enabled"
).
is
(
true
);
//可用
//排除掉正在执行的仓位
Collection
<
String
>
excludePosIds
=
taskService
.
excludePosIds
();
log
.
info
(
"excludePosIds--"
+
JsonUtil
.
toJsonStr
(
excludePosIds
));
if
(
excludePosIds
!=
null
&&
!
excludePosIds
.
isEmpty
())
{
c
.
and
(
"id"
).
nin
(
excludePosIds
);
}
if
(
StringUtils
.
isNotBlank
(
storageId
))
{
c
.
and
(
"storageId"
).
is
(
storageId
);
}
if
(
StringUtils
.
isNotBlank
(
boxCode
))
{
Pattern
pattern
=
Pattern
.
compile
(
"^.*"
+
boxCode
+
".*$"
,
Pattern
.
CASE_INSENSITIVE
);
c
.
and
(
"barcode.barcode"
).
regex
(
pattern
);
}
Query
q
=
new
Query
(
c
).
with
(
Sort
.
by
(
Sort
.
Direction
.
ASC
,
"barcode.amount"
)).
limit
(
1
);
List
<
StoragePos
>
storagePoss
=
storagePosManager
.
findByQuery
(
q
);
if
(
storagePoss
!=
null
&&
!
storagePoss
.
isEmpty
())
{
return
storagePoss
.
get
(
0
);
}
return
null
;
}
@ApiOperation
(
"获取工位详情"
)
@RequestMapping
(
"/getStation"
)
...
...
@@ -174,59 +167,95 @@ public class WarehouseController {
}
@ApiOperation
(
"
操作料盒内的物料信息
"
)
@ApiOperation
(
"
扫码入库
"
)
@RequestMapping
(
value
=
"/operatePos"
)
@AnonymousAccess
//先扫条码 再扫料箱
public
ResultBean
operatePos
(
@RequestBody
Map
<
String
,
String
>
paramMap
)
{
String
code
=
paramMap
.
get
(
"code"
);
//条码
String
name
=
paramMap
.
get
(
"name"
);
//工位名称
log
.
info
(
"收到物料信息,条码为:{},工位为:{}"
,
code
,
name
);
String
code
=
paramMap
.
get
(
"code"
);
//条码
Station
station
=
StationCacheUtil
.
getStation
(
name
);
if
(
station
==
null
)
{
return
ResultBean
.
newErrorResult
(-
1
,
""
,
name
+
"工位不存在"
,
new
String
[]{});
}
//条码信息
String
barcodeStr
=
""
;
if
(
code
.
startsWith
(
"C"
)
&&
code
.
indexOf
(
"-"
)
!=
-
1
)
{
station
.
setLastScanBoxCode
(
code
);
//设置扫描的隔口信息
barcodeStr
=
code
.
substring
(
0
,
code
.
indexOf
(
"-"
));
}
else
{
barcodeStr
=
code
;
}
Station
station
=
StationCacheUtil
.
getStation
(
name
);
String
currentRfid
=
station
.
getCurrentRfid
();
if
(
station
==
null
)
{
return
ResultBean
.
newErrorResult
(-
1
,
""
,
name
+
"工位不存在"
,
new
String
[]{});
log
.
info
(
"收到物料信息,条码为:{},工位为:{}"
,
code
,
name
);
String
currentRfid
=
station
.
getCurrentRfid
();
//当前料箱的信息
if
(
StringUtils
.
isBlank
(
currentRfid
))
{
return
ResultBean
.
newErrorResult
(-
1
,
""
,
"料箱不存在"
,
new
String
[]{});
}
//先判断是否料盒
String
newCodeStr
=
"="
+
station
.
getPlatsize
()
+
"x"
+
station
.
getHeight
()
+
"="
+
barcodeStr
;
CodeBean
codeBean
=
codeResolve
.
resolveSingleCode
(
newCodeStr
);
if
(!
codeBean
.
isValid
())
{
return
ResultBean
.
newErrorResult
(-
1
,
""
,
code
+
"解析条码失败"
,
new
String
[]{});
}
if
(
codeBean
.
isValid
())
{
Barcode
barcode
=
codeBean
.
getBarcode
();
String
partNumber
=
barcode
.
getPartNumber
();
//如果是箱子的话 则取下边的
if
(
partNumber
.
equals
(
"CS"
)
||
partNumber
.
equals
(
"CM"
)
||
partNumber
.
equals
(
"CB"
)
||
partNumber
.
equals
(
"CN"
))
{
if
(
StringUtils
.
isBlank
(
currentRfid
))
{
return
ResultBean
.
newErrorResult
(-
1
,
""
,
"RFID不存在"
,
new
String
[]{});
}
else
if
(!
currentRfid
.
startsWith
(
barcode
.
getBarcode
()))
{
return
ResultBean
.
newErrorResult
(-
1
,
""
,
"RFID"
+
currentRfid
+
"与"
+
barcode
.
getBarcode
()
+
"不一致"
,
new
String
[]{});
if
(
partNumber
.
equals
(
"CS"
)
||
partNumber
.
equals
(
"CM"
)
||
partNumber
.
equals
(
"CB"
))
{
if
(!
currentRfid
.
startsWith
(
barcode
.
getBarcode
()))
{
return
ResultBean
.
newErrorResult
(-
1
,
""
,
"料箱"
+
currentRfid
+
"与料箱隔口码"
+
barcode
.
getBarcode
()
+
"不一致"
,
new
String
[]{});
}
//判断当前是否有正在执行的任务
DataLog
dataLog
=
getExecuteTask
(
barcode
.
getBarcode
());
if
(
dataLog
!=
null
)
{
if
(
dataLog
.
isPutInTask
())
{
//已有入库任务
return
ResultBean
.
newErrorResult
(-
1
,
""
,
"物料["
+
dataLog
.
getBarcode
()
+
"]已有入库任务,需继续执行入库动作"
,
new
String
[]{});
}
else
if
(
dataLog
.
isCheckOutTask
())
{
//已有出库任务
return
ResultBean
.
newErrorResult
(-
1
,
""
,
"物料["
+
dataLog
.
getBarcode
()
+
"]已有出库任务,需继续执行出库动作"
,
new
String
[]{});
}
}
//判断料箱是否在库位中
StoragePos
pos
=
storagePosManager
.
getByBarcode
(
barcode
.
getBarcode
());
if
(
pos
!=
null
)
{
return
ResultBean
.
newErrorResult
(-
1
,
""
,
"料箱"
+
barcode
.
getBarcode
()
+
"已存在库位"
+
pos
.
getPosName
());
}
station
.
setLastScanBoxCode
(
code
);
StationCacheUtil
.
updateStation
(
station
);
barcodeManager
.
save
(
barcode
);
}
else
{
String
lastScanBoxCode
=
station
.
getLastScanBoxCode
();
//再加个rfid判断
if
(
Strings
.
isBlank
(
lastScanBoxCode
))
{
//提示要先扫料箱
return
ResultBean
.
newErrorResult
(-
1
,
""
,
"请先扫描料箱,再扫描条码"
);
}
StationCacheUtil
.
saveReelToBoxCode
(
station
);
Barcode
barcodeApi
=
smfApi
.
barcodeInfo
(
barcode
);
if
(
barcodeApi
!=
null
)
{
barcode
=
barcodeApi
;
}
//判断是否已经在其他料箱中
Query
q
=
new
Query
();
q
.
addCriteria
(
Criteria
.
where
(
"subCodeList.barcode"
).
is
(
barcode
.
getBarcode
()));
List
<
Barcode
>
barcodes
=
barcodeManager
.
findByQuery
(
q
);
if
(
barcodes
!=
null
&&
!
barcodes
.
isEmpty
())
{
return
ResultBean
.
newErrorResult
(-
1
,
""
,
"物料"
+
barcode
.
getBarcode
()
+
"已存在料箱:"
+
barcodes
.
get
(
0
).
getBarcode
());
}
int
reelCurrentNum
=
station
.
getReelCurrentNum
();
station
.
setReelCurrentNum
(
reelCurrentNum
+
1
);
String
boxBarcode
=
lastScanBoxCode
.
substring
(
0
,
lastScanBoxCode
.
indexOf
(
"-"
));
//获取到料箱条码
Barcode
pidBarcode
=
barcodeManager
.
findByBarcode
(
boxBarcode
);
barcode
.
setHostBarcodeId
(
pidBarcode
.
getId
());
barcode
.
setPosName
(
lastScanBoxCode
);
barcodeManager
.
save
(
barcode
);
finishTask
(
pidBarcode
,
1
,
null
,
barcode
,
1
);
}
}
StationCacheUtil
.
updateStation
(
station
);
return
ResultBean
.
newOkResult
(
StationCacheUtil
.
getStation
(
name
));
}
...
...
@@ -239,10 +268,9 @@ public class WarehouseController {
String
code
=
paramMap
.
get
(
"barcode"
);
//料箱条码
String
name
=
paramMap
.
get
(
"name"
);
//工位名称
String
cids
=
paramMap
.
get
(
"cids"
);
//料仓cid
cids
=
"so1131"
;
log
.
info
(
"完成装箱并入库,条码为:{},工位为:{}"
,
code
,
name
);
log
.
info
(
"完成装箱并入库,条码为:{},工位为:{}"
,
code
,
name
);
//校验是否存在
code
=
code
.
replace
(
"A"
,
""
).
replace
(
"B"
,
""
);
...
...
@@ -250,6 +278,7 @@ public class WarehouseController {
if
(
barcode
==
null
)
{
return
ResultBean
.
newErrorResult
(-
1
,
""
,
code
+
"料箱不存在"
,
null
);
}
Station
station
=
StationCacheUtil
.
getStation
(
name
);
if
(
station
==
null
)
{
return
ResultBean
.
newErrorResult
(-
1
,
""
,
name
+
"工位不存在"
,
new
String
[]{});
...
...
@@ -257,9 +286,9 @@ public class WarehouseController {
//校验rfid是否一致
String
currentRfid
=
station
.
getCurrentRfid
();
if
(
StringUtils
.
isBlank
(
currentRfid
))
{
return
ResultBean
.
newErrorResult
(-
1
,
""
,
"
RFID
不存在"
,
new
String
[]{});
return
ResultBean
.
newErrorResult
(-
1
,
""
,
"
料箱
不存在"
,
new
String
[]{});
}
else
if
(!
currentRfid
.
startsWith
(
barcode
.
getBarcode
()))
{
return
ResultBean
.
newErrorResult
(-
1
,
""
,
"
RFID
"
+
currentRfid
+
"与"
+
barcode
.
getBarcode
()
+
"不一致"
,
new
String
[]{});
return
ResultBean
.
newErrorResult
(-
1
,
""
,
"
料箱
"
+
currentRfid
+
"与"
+
barcode
.
getBarcode
()
+
"不一致"
,
new
String
[]{});
}
//先找可用料仓
...
...
@@ -285,22 +314,20 @@ public class WarehouseController {
if
(
storageList
.
isEmpty
())
{
return
ResultBean
.
newErrorResult
(-
1
,
""
,
"料仓不存在"
,
new
String
[]{});
}
//判断是否有出入库任务
for
(
DataLog
dataLog
:
taskService
.
getQueueTasks
())
{
// if(!dataLog.isPackageReel()){
//已经在任务当中,返回对应的信息
if
(
dataLog
.
getBarcode
().
equals
(
barcode
.
getBarcode
()))
{
DataLog
dataLog
=
getExecuteTask
(
barcode
.
getBarcode
());
if
(
dataLog
!=
null
)
{
if
(
dataLog
.
isPutInTask
())
{
//已有入库任务
return
ResultBean
.
newErrorResult
(-
1
,
""
,
"物料["
+
dataLog
.
getBarcode
()
+
"]已有入库任务,需继续执行入库动作"
,
new
String
[]{});
}
else
{
}
else
if
(
dataLog
.
isCheckOutTask
())
{
//已有出库任务
return
ResultBean
.
newErrorResult
(-
1
,
""
,
"物料["
+
dataLog
.
getBarcode
()
+
"]已有出库任务,需继续执行出库动作"
,
new
String
[]{});
}
}
}
//开始寻找空箱
StoragePos
pos
=
taskService
.
findEmptyPosForPutIn
(
storageList
,
barcode
,
""
,
""
);
if
(
pos
==
null
)
{
throw
new
ValidateException
(
""
,
"["
+
barcode
.
getBarcode
()
+
"]未找到可用的["
+
barcode
.
getPlateSize
()
+
"x"
+
barcode
.
getHeight
()
+
"]仓位"
,
null
);
}
...
...
@@ -330,48 +357,336 @@ public class WarehouseController {
//同时清空lastScanBoxCode
station
.
setLastScanBoxCode
(
null
);
StationCacheUtil
.
saveBoxToBoxCode
(
station
);
String
boxStr
=
currentRfid
.
replaceAll
(
"A"
,
""
).
replaceAll
(
"B"
,
""
);
if
(
boxALlCountMap
.
get
(
boxStr
)
!=
null
){
boxALlCountMap
.
remove
(
boxStr
);
}
if
(
boxCount
.
get
(
boxStr
)
!=
null
){
boxCount
.
remove
(
boxStr
);
}
return
ResultBean
.
newOkResult
(
station
);
}
@ApiOperation
(
"扫码出库"
)
@RequestMapping
(
"/finishBoxOut"
)
@ApiOperation
(
"出库页面展示"
)
@RequestMapping
(
"/outIndex"
)
@AnonymousAccess
public
ResultBean
finishBoxOut
(
@RequestBody
Map
<
String
,
String
>
paramMap
)
{
String
code
=
paramMap
.
get
(
"barcode"
);
Barcode
barcode
=
barcodeManager
.
findByBarcode
(
code
);
public
ResultBean
outIndex
(
@RequestBody
Map
<
String
,
String
>
paramMap
)
{
String
name
=
paramMap
.
get
(
"name"
);
//工位名称
String
barcodeStr
=
paramMap
.
get
(
"barcode"
);
//隔扣码
Station
station
=
StationCacheUtil
.
getStation
(
name
);
if
(
station
==
null
)
{
return
ResultBean
.
newErrorResult
(-
1
,
""
,
name
+
"工位不存在"
,
new
String
[]{});
}
//判断当前工位是否有料箱
String
currentRfid
=
station
.
getCurrentRfid
();
if
(
StringUtils
.
isBlank
(
currentRfid
))
{
return
ResultBean
.
newErrorResult
(-
1
,
""
,
"料箱不存在"
,
new
String
[]{});
}
String
boxStr
=
currentRfid
.
replaceAll
(
"A"
,
""
).
replaceAll
(
"B"
,
""
);
//处理要出库的物料
if
(
StringUtils
.
isNotBlank
(
barcodeStr
))
{
CodeBean
codeBean
=
codeResolve
.
resolveSingleCode
(
barcodeStr
);
if
(!
codeBean
.
isValid
())
{
return
ResultBean
.
newErrorResult
(-
1
,
""
,
barcodeStr
+
"解析条码失败"
,
new
String
[]{});
}
String
code
=
codeBean
.
getBarcode
().
getBarcode
();
if
(
code
.
startsWith
(
"CS"
)
||
code
.
startsWith
(
"CM"
)
||
code
.
startsWith
(
"CB"
))
{
return
ResultBean
.
newErrorResult
(-
1
,
""
,
"请扫描物料条码"
);
}
Barcode
barcode
=
barcodeManager
.
findByBarcode
(
codeBean
.
getBarcode
().
getBarcode
());
if
(
barcode
==
null
)
{
return
ResultBean
.
newErrorResult
(-
1
,
""
,
code
+
"物料不存在"
,
new
String
[]{});
return
ResultBean
.
newErrorResult
(-
1
,
""
,
barcodeStr
+
"未找到对应得物料"
);
}
Barcode
barcodeApi
=
smfApi
.
canPutInAfterResolve
(
barcode
);
if
(
barcodeApi
!=
null
)
{
barcode
=
barcodeApi
;
}
int
amount
=
barcode
.
getAmount
();
barcode
.
setAmount
(
amount
-
1
);
Barcode
pidBarcode
=
barcodeManager
.
get
(
barcode
.
getHostBarcodeId
());
//判断扫描的料号与正在执行的是否一致
Collection
<
String
>
executePartNumbers
=
liteOrderCache
.
executePartNumber
();
if
(
executePartNumbers
!=
null
&&
!
executePartNumbers
.
isEmpty
())
{
if
(!
executePartNumbers
.
contains
(
barcode
.
getPartNumber
()))
{
return
ResultBean
.
newErrorResult
(-
1
,
""
,
"当前物料不在允许出库"
);
}
}
String
posName
=
barcode
.
getPosName
();
Map
<
String
,
Integer
>
boxCountMap
=
boxALlCountMap
.
get
(
boxStr
);
if
(
boxCountMap
==
null
)
{
return
ResultBean
.
newErrorResult
(-
1
,
""
,
"当前料箱没有要出库的物料"
);
}
if
(
StringUtils
.
isBlank
(
posName
)
||
!
posName
.
startsWith
(
boxStr
)){
return
ResultBean
.
newErrorResult
(-
1
,
""
,
barcode
.
getBarcode
()+
"不在料箱"
+
boxStr
);
}
int
count
=
boxCountMap
.
get
(
posName
);
if
(
count
==
0
)
{
return
ResultBean
.
newErrorResult
(-
1
,
""
,
posName
+
"没有出库任务"
);
}
//得到正在执行的工单
String
orderId
=
null
;
Collection
<
LiteOrderItem
>
items
=
liteOrderCache
.
executeItems
();
for
(
LiteOrderItem
item
:
items
)
{
String
pn
=
item
.
getPn
();
if
(
pn
.
equals
(
barcode
.
getPartNumber
())
&&
posName
.
equals
(
item
.
getPosName
()))
{
DataLog
executeTask
=
getExecuteTask
(
item
.
getRi
());
if
(
executeTask
==
null
)
{
if
(
item
.
getTotalOutNum
()
!=
item
.
getNeedNum
())
{
item
.
setRi
(
barcode
.
getBarcode
());
orderId
=
item
.
getOrderId
();
liteOrderItemManager
.
save
(
item
);
break
;
}
}
}
}
if
(
StringUtils
.
isNotBlank
(
orderId
)){
LiteOrder
liteOrder
=
liteOrderManager
.
get
(
orderId
);
List
<
LiteOrderItem
>
orderItems
=
liteOrderItemManager
.
findOrderItems
(
orderId
);
liteOrder
.
setOrderItems
(
orderItems
);
liteOrder
=
liteOrderManager
.
createWithItems
(
liteOrder
);
liteOrderCache
.
addOrderToMap
(
liteOrder
);
}
//生成出库任务
Barcode
pidBarcode
=
barcodeManager
.
findByBarcode
(
boxStr
);
finishTask
(
pidBarcode
,
OP
.
CHECKOUT
,
null
,
barcode
,
1
);
return
ResultBean
.
newOkResult
(
""
);
}
@ApiOperation
(
"出库页面展示"
)
@RequestMapping
(
"/outIndex"
)
public
ResultBean
outIndex
(
@RequestBody
Map
<
String
,
String
>
paramMap
)
{
String
barcode
=
paramMap
.
get
(
"barcode"
);
//料箱barcode
Query
query
=
new
Query
();
Pattern
pattern
=
Pattern
.
compile
(
"^.*"
+
barcode
+
".*$"
,
Pattern
.
CASE_INSENSITIVE
);
Criteria
criteria
=
Criteria
.
where
(
"posName"
).
regex
(
pattern
);
List
<
Barcode
>
barcodes
=
barcodeManager
.
findByQuery
(
query
.
addCriteria
(
criteria
));
List
<
Map
<
String
,
String
>>
results
=
new
ArrayList
<>();
if
(
barcodes
!=
null
&&
!
barcodes
.
isEmpty
())
{
//获取料箱中的物料信息
Barcode
pidBarcode
=
barcodeManager
.
findByBarcode
(
boxStr
);
if
(
pidBarcode
==
null
){
return
ResultBean
.
newErrorResult
(-
1
,
""
,
boxStr
+
"未找到物料信息"
);
}
List
<
Barcode
>
subCodeList
=
pidBarcode
.
getSubCodeList
();
//需要出库的数量
Map
<
String
,
Integer
>
boxCountMap
=
new
HashMap
<>();
boxCountMap
.
put
(
boxStr
+
"-1"
,
0
);
boxCountMap
.
put
(
boxStr
+
"-2"
,
0
);
boxCountMap
.
put
(
boxStr
+
"-3"
,
0
);
boxCountMap
.
put
(
boxStr
+
"-4"
,
0
);
boxCountMap
.
put
(
boxStr
+
"-5"
,
0
);
boxCountMap
.
put
(
boxStr
+
"-6"
,
0
);
boxCountMap
.
put
(
boxStr
+
"-7"
,
0
);
boxCountMap
.
put
(
boxStr
+
"-8"
,
0
);
//得到正在执行的工单数据
List
<
LiteOrderItem
>
orderItems
=
new
ArrayList
<>();
Collection
<
LiteOrderItem
>
liteOrderItems
=
liteOrderCache
.
executeItems
();
for
(
LiteOrderItem
liteOrderItem
:
liteOrderItems
)
{
if
(
liteOrderItem
.
getNeedNum
()
!=
liteOrderItem
.
getTotalOutNum
()){
orderItems
.
add
(
liteOrderItem
);
}
}
if
(
orderItems
!=
null
&&
!
orderItems
.
isEmpty
()){
Map
<
String
,
Long
>
boxCount
=
orderItems
.
stream
().
collect
(
Collectors
.
groupingBy
(
LiteOrderItem:
:
getPosName
,
Collectors
.
counting
()));
for
(
Map
.
Entry
<
String
,
Long
>
countEntry
:
boxCount
.
entrySet
())
{
if
(
countEntry
.
getValue
()
!=
null
)
{
boxCountMap
.
put
(
countEntry
.
getKey
(),
countEntry
.
getValue
().
intValue
());
}
}
}
if
(
boxALlCountMap
.
get
(
boxStr
)
!=
null
){
boxALlCountMap
.
remove
(
boxStr
);
}
boxALlCountMap
.
put
(
boxStr
,
boxCountMap
);
//料箱总数量
if
(
boxCount
.
get
(
boxStr
)
==
null
)
{
boxCount
.
put
(
boxStr
,
subCodeList
.
size
());
}
//判断是否全部出库
Map
<
String
,
Long
>
subCountMap
=
subCodeList
.
stream
().
collect
(
Collectors
.
groupingBy
(
Barcode:
:
getPosName
,
Collectors
.
counting
()));
for
(
Map
.
Entry
<
String
,
Long
>
countMap
:
subCountMap
.
entrySet
())
{
String
posName
=
countMap
.
getKey
();
int
count
=
boxCountMap
.
get
(
posName
);
if
(
count
!=
0
&&
count
==
countMap
.
getValue
())
{
boxCountMap
.
put
(
posName
,
-
1
);
}
}
List
<
Integer
>
boxPartitionCounts
=
new
ArrayList
<>();
if
(
currentRfid
.
endsWith
(
"A"
))
{
boxPartitionCounts
.
add
(
boxCountMap
.
get
(
boxStr
+
"-8"
));
boxPartitionCounts
.
add
(
boxCountMap
.
get
(
boxStr
+
"-7"
));
boxPartitionCounts
.
add
(
boxCountMap
.
get
(
boxStr
+
"-6"
));
boxPartitionCounts
.
add
(
boxCountMap
.
get
(
boxStr
+
"-5"
));
boxPartitionCounts
.
add
(
boxCountMap
.
get
(
boxStr
+
"-1"
));
boxPartitionCounts
.
add
(
boxCountMap
.
get
(
boxStr
+
"-2"
));
boxPartitionCounts
.
add
(
boxCountMap
.
get
(
boxStr
+
"-3"
));
boxPartitionCounts
.
add
(
boxCountMap
.
get
(
boxStr
+
"-4"
));
}
else
if
(
currentRfid
.
endsWith
(
"B"
))
{
boxPartitionCounts
.
add
(
boxCountMap
.
get
(
boxStr
+
"-4"
));
boxPartitionCounts
.
add
(
boxCountMap
.
get
(
boxStr
+
"-3"
));
boxPartitionCounts
.
add
(
boxCountMap
.
get
(
boxStr
+
"-2"
));
boxPartitionCounts
.
add
(
boxCountMap
.
get
(
boxStr
+
"-1"
));
boxPartitionCounts
.
add
(
boxCountMap
.
get
(
boxStr
+
"-5"
));
boxPartitionCounts
.
add
(
boxCountMap
.
get
(
boxStr
+
"-6"
));
boxPartitionCounts
.
add
(
boxCountMap
.
get
(
boxStr
+
"-7"
));
boxPartitionCounts
.
add
(
boxCountMap
.
get
(
boxStr
+
"-8"
));
}
Map
<
String
,
Object
>
resultMap
=
new
HashMap
<>();
resultMap
.
put
(
"boxPartitionCounts"
,
boxPartitionCounts
);
//展示数量
resultMap
.
put
(
"boxAllCount"
,
boxCount
.
get
(
boxStr
));
//料箱总数量
resultMap
.
put
(
"boxRemainingCount"
,
subCodeList
.
size
());
//剩余数量
resultMap
.
put
(
"box"
,
currentRfid
);
//箱子号
return
ResultBean
.
newOkResult
(
resultMap
);
/*String currentRfid = station.getCurrentRfid();
if (barcodeStr.startsWith("CS") || barcodeStr.startsWith("CB") || barcodeStr.startsWith("CM")) {
if (barcodeStr.indexOf("-") != -1) {
station.setLastScanBoxCode(barcodeStr);
barcodeStr = barcodeStr.substring(0, barcodeStr.indexOf("-"));
}
if (StringUtils.isBlank(currentRfid)) {
return ResultBean.newErrorResult(-1, "", "料箱不存在", new String[]{});
} else if (!currentRfid.startsWith(barcodeStr)) {
return ResultBean.newErrorResult(-1, "", "料箱" + currentRfid + "与" + barcodeStr + "不一致", new String[]{});
}
} else {
String lastScanBoxCode = station.getLastScanBoxCode();
if (Strings.isBlank(lastScanBoxCode)) {
//提示要先扫料箱
return ResultBean.newErrorResult(-1, "", "请先扫描料箱,再扫描条码");
}
CodeBean codeBean = codeResolve.resolveSingleCode(barcodeStr);
if (!codeBean.isValid()) {
return ResultBean.newErrorResult(-1, "", barcodeStr + "解析条码失败", new String[]{});
}
Barcode barcode = barcodeManager.findByBarcode(codeBean.getBarcode().getBarcode());
if (barcode == null) {
return ResultBean.newErrorResult(-1, "", barcodeStr + "未找到对应得物料");
}
Barcode barcodeApi = smfApi.canPutInAfterResolve(barcode);
if (barcodeApi != null){
barcode = barcodeApi;
}
if (!lastScanBoxCode.equals(barcode.getPosName())) {
return ResultBean.newErrorResult(-1, "", barcodeStr + "存在库位:" + barcode.getPosName());
}
//生成出库任务
Barcode pidBarcode = barcodeManager.findByBarcode(lastScanBoxCode.substring(0, lastScanBoxCode.indexOf("-")));
barcode.setAmount(0);
finishTask(pidBarcode, OP.CHECKOUT, null, barcode, 1);
}
String boxStr = currentRfid.replaceAll("A", "").replaceAll("B", "");
Barcode pidBarcode = barcodeManager.findByBarcode(boxStr);
//获取到箱子里物料信息
List<Barcode> subCodeList = pidBarcode.getSubCodeList();
Map<String, Object> resultMap = new HashMap<>();
resultMap.put(boxStr + "-1", 0l);
resultMap.put(boxStr + "-2", 0l);
resultMap.put(boxStr + "-3", 0l);
resultMap.put(boxStr + "-4", 0l);
resultMap.put(boxStr + "-5", 0l);
resultMap.put(boxStr + "-6", 0l);
resultMap.put(boxStr + "-7", 0l);
resultMap.put(boxStr + "-8", 0l);
resultMap.put("boxAllCount", 0);
resultMap.put("boxRemainingCount", 0);
resultMap.put("box", currentRfid);
Collection<String> excludeBarcodes = liteOrderCache.excludeBarcodeIds();
for (Barcode subBarcode : subCodeList) {
if (excludeBarcodes != null && !excludeBarcodes.isEmpty()) {
boolean contains = excludeBarcodes.contains(subBarcode.getBarcode());
if (contains) {
DataLog task = null;
List<DataLog> allTasks = taskService.getAllTasks();
for (DataLog dataLog : allTasks) {
if (dataLog.getBarcode().equals(subBarcode.getBarcode())) {
task = dataLog;
break;
}
}
if (task == null) {
long count = (long) resultMap.get(subBarcode.getPosName());
if (count != 0) {
resultMap.put(subBarcode.getPosName(), count + 1);
} else {
resultMap.put(subBarcode.getPosName(), 1l);
}
}
}
}
}
Map
<
String
,
List
<
Barcode
>>
barcodesPosNameMap
=
barcodes
.
stream
().
collect
(
Collectors
.
groupingBy
(
Barcode:
:
getPosName
));
for
(
Map
.
Entry
<
String
,
List
<
Barcode
>>
barcodePosNameMap
:
barcodesPosNameMap
.
entrySet
())
{
Map
<
String
,
String
>
resultMap
=
new
HashMap
<>();
String
posName
=
barcodePosNameMap
.
getKey
();
List
<
Barcode
>
barcodePosNames
=
barcodePosNameMap
.
getValue
();
resultMap
.
put
(
"posName"
,
posName
);
resultMap
.
put
(
"posNameSize"
,
barcodePosNames
.
size
()
+
""
);
results
.
add
(
resultMap
);
if (subCodeList != null && !subCodeList.isEmpty()) {
if (boxCount.get(boxStr) == null) {
boxCount.put(boxStr, subCodeList.size());
}
resultMap.put("boxAllCount", boxCount.get(boxStr)); //料箱总数量
resultMap.put("boxRemainingCount", subCodeList.size()); //剩余数量
Map<String, Long> subCountMap = subCodeList.stream().collect(Collectors.groupingBy(Barcode::getPosName, Collectors.counting()));
for (Map.Entry<String, Long> countMap : subCountMap.entrySet()) {
String posName = countMap.getKey();
long count = (long) resultMap.get(posName);
if (count != 0 && count == countMap.getValue()) {
resultMap.put(posName, -1);
}
}
}
return
ResultBean
.
newOkResult
(
results
);
List<Object> boxPartitionCounts = new ArrayList<>();
if (currentRfid.endsWith("A")) {
boxPartitionCounts.add(resultMap.get(boxStr + "-8"));
boxPartitionCounts.add(resultMap.get(boxStr + "-7"));
boxPartitionCounts.add(resultMap.get(boxStr + "-6"));
boxPartitionCounts.add(resultMap.get(boxStr + "-5"));
boxPartitionCounts.add(resultMap.get(boxStr + "-1"));
boxPartitionCounts.add(resultMap.get(boxStr + "-2"));
boxPartitionCounts.add(resultMap.get(boxStr + "-3"));
boxPartitionCounts.add(resultMap.get(boxStr + "-4"));
} else if (currentRfid.endsWith("B")) {
boxPartitionCounts.add(resultMap.get(boxStr + "-4"));
boxPartitionCounts.add(resultMap.get(boxStr + "-3"));
boxPartitionCounts.add(resultMap.get(boxStr + "-2"));
boxPartitionCounts.add(resultMap.get(boxStr + "-1"));
boxPartitionCounts.add(resultMap.get(boxStr + "-5"));
boxPartitionCounts.add(resultMap.get(boxStr + "-6"));
boxPartitionCounts.add(resultMap.get(boxStr + "-7"));
boxPartitionCounts.add(resultMap.get(boxStr + "-8"));
}
resultMap.put("boxPartitionCounts",boxPartitionCounts);
return ResultBean.newOkResult(resultMap);*/
}
@ApiOperation
(
"已全部完成装箱"
)
@RequestMapping
(
"/finishPutIn"
)
public
ResultBean
finishPutIn
(
@RequestBody
Map
<
String
,
String
>
paramMap
)
{
String
name
=
paramMap
.
get
(
"name"
);
Station
station
=
StationCacheUtil
.
getStation
(
name
);
if
(
station
==
null
)
{
return
ResultBean
.
newErrorResult
(-
1
,
""
,
name
+
"工位不存在"
,
new
String
[]{});
}
station
.
setReelCurrentNum
(
0
);
station
.
setLastScanBoxCode
(
null
);
station
.
setBoxCurrentNum
(
0
);
station
.
setCurrentRfid
(
null
);
station
.
setReelNum
(
0
);
station
.
setBoxNum
(
0
);
StationCacheUtil
.
updateStation
(
station
);
return
ResultBean
.
newOkResult
(
station
);
}
...
...
@@ -395,20 +710,19 @@ public class WarehouseController {
*/
private
void
finishTask
(
Barcode
pidBarcode
,
int
opType
,
DataLog
currentTask
,
Barcode
subBarcode
,
int
opQty
)
throws
ValidateException
{
//更新barcode缓存
pidBarcode
.
UpdateSubCode
(
subBarcode
);
int
subAmout
=
subBarcode
.
getAmount
();
//更新pidBarcode的数量
int
amount
=
pidBarcode
.
getAmount
();
if
(
opType
==
OP
.
PUT_IN
)
{
pidBarcode
.
setAmount
(
amount
+
opQty
);
}
else
{
pidBarcode
.
setAmount
(
amount
-
opQty
);
subBarcode
.
setAmount
(
0
);
}
if
(
opType
==
OP
.
CHECKOUT
&&
subBarcode
.
getAmount
()
<=
0
)
{
//数量为0直接删除
barcodeManager
.
delet
e
(
subBarcode
);
}
//更新barcode缓存
pidBarcode
.
UpdateSubCod
e
(
subBarcode
);
barcodeManager
.
saveBarcode
(
pidBarcode
);
DataLog
task
=
null
;
...
...
@@ -431,17 +745,103 @@ public class WarehouseController {
task
.
setStatus
(
OP_STATUS
.
FINISHED
.
name
());
task
.
setPartNumber
(
subBarcode
.
getPartNumber
());
task
.
setBarcode
(
subBarcode
.
getBarcode
());
task
.
setNum
(
opQty
);
task
.
setNum
(
subAmout
);
task
.
setType
(
opType
);
task
.
setCid
(
pidBarcode
.
getPartNumber
());
task
.
setStorageName
(
pidBarcode
.
getBarcode
());
task
.
setPosName
(
pidBarcode
.
getBarcode
());
task
.
setOperator
(
SecurityUtils
.
getLoginUsername
());
String
orderNo
=
liteOrderCache
.
executeOrderByBarcode
(
subBarcode
.
getBarcode
());
if
(
StringUtils
.
isNotBlank
(
orderNo
)){
task
.
setSourceName
(
orderNo
);
LiteOrder
liteOrder
=
liteOrderCache
.
getOrderSortItems
(
orderNo
);
for
(
LiteOrderItem
orderItem
:
liteOrder
.
getOrderItems
())
{
if
(
orderItem
.
getRi
().
equals
(
subBarcode
.
getBarcode
())){
if
(!
orderItem
.
isOutFinished
()){
task
.
setSubSourceId
(
orderItem
.
getId
());
break
;
}
}
}
}
task
=
dataLogManager
.
save
(
task
);
taskService
.
moveTaskToFinished
(
task
);
taskService
.
updateFinishedTask
(
task
);
if
(
opType
==
OP
.
CHECKOUT
&&
subBarcode
.
getAmount
()
<=
0
)
{
//数量为0直接删除
barcodeManager
.
delete
(
subBarcode
);
}
}
private
int
getPlatsizeOrHeight
(
String
size
,
int
index
)
{
return
Integer
.
valueOf
(
size
.
split
(
"X"
)[
index
]);
}
private
StoragePos
getEmptyBoxPos
(
String
platsize
)
{
//得到料盒类型
String
boxCode
=
""
;
if
(
"7"
.
equals
(
platsize
))
{
boxCode
=
"CS"
;
}
else
if
(
"13"
.
equals
(
platsize
))
{
boxCode
=
"CM"
;
}
else
if
(
"15"
.
equals
(
platsize
))
{
boxCode
=
"CB"
;
}
//料仓类型是agv的
String
storageId
=
""
;
Collection
<
Storage
>
storages
=
dataCache
.
getAllStorage
().
values
();
for
(
Storage
storage
:
storages
)
{
if
(
storage
.
isType
(
new
DeviceType
[]{
DeviceType
.
AGV_BOX
}))
{
storageId
=
storage
.
getId
();
}
}
Criteria
c
=
Criteria
.
where
(
"barcode"
).
exists
(
true
)
.
and
(
"enabled"
).
is
(
true
);
//可用
//排除掉正在执行的仓位
Collection
<
String
>
excludePosIds
=
taskService
.
excludePosIds
();
log
.
info
(
"excludePosIds--"
+
JsonUtil
.
toJsonStr
(
excludePosIds
));
if
(
excludePosIds
!=
null
&&
!
excludePosIds
.
isEmpty
())
{
c
.
and
(
"id"
).
nin
(
excludePosIds
);
}
if
(
StringUtils
.
isNotBlank
(
storageId
))
{
c
.
and
(
"storageId"
).
is
(
storageId
);
}
if
(
StringUtils
.
isNotBlank
(
boxCode
))
{
Pattern
pattern
=
Pattern
.
compile
(
"^.*"
+
boxCode
+
".*$"
,
Pattern
.
CASE_INSENSITIVE
);
c
.
and
(
"barcode.barcode"
).
regex
(
pattern
);
}
Query
q
=
new
Query
(
c
).
with
(
Sort
.
by
(
Sort
.
Direction
.
ASC
,
"barcode.amount"
)).
limit
(
1
);
List
<
StoragePos
>
storagePoss
=
storagePosManager
.
findByQuery
(
q
);
if
(
storagePoss
!=
null
&&
!
storagePoss
.
isEmpty
())
{
return
storagePoss
.
get
(
0
);
}
return
null
;
}
private
DataLog
getExecuteTask
(
String
barcode
)
{
List
<
DataLog
>
allTasks
=
taskService
.
getAllTasks
();
for
(
DataLog
dataLog
:
allTasks
)
{
if
(
dataLog
.
getBarcode
().
equals
(
barcode
))
{
if
(!
dataLog
.
isCancel
()
&&
!
dataLog
.
isFinished
())
{
return
dataLog
;
}
}
}
return
null
;
}
/**
* 根据料箱编号获取到所有物料
*
* @param boxBarcode
* @return
*/
private
List
<
Barcode
>
getAllBarcodeByBox
(
String
boxBarcode
)
{
Query
query
=
new
Query
();
Pattern
pattern
=
Pattern
.
compile
(
"^"
+
boxBarcode
+
".*$"
,
Pattern
.
CASE_INSENSITIVE
);
Criteria
criteria
=
Criteria
.
where
(
"posName"
).
regex
(
pattern
);
return
barcodeManager
.
findByQuery
(
query
.
addCriteria
(
criteria
));
}
}
src/main/java/com/neotel/smfcore/custom/lizhen/agvBox/util/StationCacheUtil.java
查看文件 @
437a3c1
...
...
@@ -39,7 +39,7 @@ public class StationCacheUtil {
@PostConstruct
public
void
init
()
{
log
.
info
(
"开始工位缓存信息"
);
for
(
int
i
=
1
;
i
<
5
;
i
++)
{
for
(
int
i
=
1
;
i
<
=
5
;
i
++)
{
String
stationName
=
"s"
+
i
;
Station
station
=
dataCache
.
getCache
(
stationName
);
if
(
station
==
null
){
...
...
@@ -68,7 +68,7 @@ public class StationCacheUtil {
Station
station
=
getStation
(
stationName
);
if
(
station
!=
null
){
String
oldRfid
=
station
.
getCurrentRfid
();
if
(!
oldRfid
.
equals
(
r
fid
))
{
if
(!
rfid
.
equals
(
oldR
fid
))
{
log
.
info
(
"工位"
+
stationName
+
" 切换料箱,当前料箱:"
+
rfid
+
",上一料箱:"
+
oldRfid
);
station
.
setCurrentRfid
(
rfid
);
updateStation
(
station
);
...
...
src/main/java/com/neotel/smfcore/custom/lizhen/innerBox/rest/InnerBoxRestController.java
查看文件 @
437a3c1
...
...
@@ -237,7 +237,7 @@ public class InnerBoxRestController {
rfid
=
rfid
.
replaceAll
(
"A"
,
""
).
replaceAll
(
"B"
,
""
);
Pattern
pattern
=
Pattern
.
compile
(
"^"
+
rfid
+
".*$"
,
Pattern
.
CASE_INSENSITIVE
);
List
<
LiteOrder
>
liteOrders
=
liteOrderManager
.
findByQuery
(
new
Query
(
Criteria
.
where
(
"boxNumber"
).
regex
(
pattern
)));
if
(
liteOrders
!=
null
&&
liteOrders
.
isEmpty
())
{
if
(
liteOrders
!=
null
&&
!
liteOrders
.
isEmpty
())
{
for
(
LiteOrder
liteOrder
:
liteOrders
)
{
liteOrder
.
setBoxNumber
(
""
);
liteOrderManager
.
save
(
liteOrder
);
...
...
src/main/java/com/neotel/smfcore/custom/lizhen/innerBox/util/PreWarningItemCache.java
查看文件 @
437a3c1
package
com
.
neotel
.
smfcore
.
custom
.
lizhen
.
innerBox
.
util
;
import
com.neotel.smfcore.common.base.AbstractBaseDao
;
import
com.neotel.smfcore.common.exception.ValidateException
;
import
com.neotel.smfcore.common.utils.Constants
;
import
com.neotel.smfcore.common.utils.StringUtils
;
import
com.neotel.smfcore.core.api.SmfApi
;
import
com.neotel.smfcore.core.barcode.service.po.Barcode
;
import
com.neotel.smfcore.core.device.util.DataCache
;
import
com.neotel.smfcore.core.order.LiteOrderCache
;
...
...
@@ -17,6 +19,8 @@ import com.neotel.smfcore.core.system.service.po.DataLog;
import
com.neotel.smfcore.core.system.util.TaskService
;
import
com.neotel.smfcore.custom.lizhen.LizhenApi
;
import
com.neotel.smfcore.custom.lizhen.innerBox.bean.PreWarningItem
;
import
com.neotel.smfcore.custom.lizhen.innerBox.util.service.PreWarningItemManager
;
import
com.neotel.smfcore.security.annotation.AnonymousAccess
;
import
jdk.nashorn.internal.runtime.arrays.ArrayIndex
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.logging.log4j.util.Strings
;
...
...
@@ -25,6 +29,8 @@ import org.springframework.data.domain.Sort;
import
org.springframework.data.mongodb.core.query.Criteria
;
import
org.springframework.data.mongodb.core.query.Query
;
import
org.springframework.stereotype.Service
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
java.util.*
;
import
java.util.concurrent.CopyOnWriteArrayList
;
...
...
@@ -34,12 +40,13 @@ import java.util.stream.Collectors;
/**
* 机台预警信息缓存
*
* @author sunke
* @date 2022/10/9 3:31 PM
*/
@Slf4j
@Service
public
class
PreWarningItemCache
extends
AbstractBaseDao
{
public
class
PreWarningItemCache
{
/**
* 预警列表缓存
...
...
@@ -56,6 +63,9 @@ public class PreWarningItemCache extends AbstractBaseDao {
private
static
IStoragePosManager
storagePosManager
;
private
static
SmfApi
smfApi
;
private
static
PreWarningItemManager
preWarningItemManager
;
/**
* 添加到预警列表缓存中
...
...
@@ -64,7 +74,6 @@ public class PreWarningItemCache extends AbstractBaseDao {
updateItem
(
items
,
false
);
}
private
AtomicInteger
atomicInteger
=
new
AtomicInteger
(
0
);
/**
* 从缓存列表中取出预警Item生成工单并执行
...
...
@@ -130,7 +139,7 @@ public class PreWarningItemCache extends AbstractBaseDao {
*
* @param lineItems
*/
p
rivate
static
void
createAndExecuteLiteOrder
(
List
<
PreWarningItem
>
lineItems
)
{
p
ublic
static
LiteOrder
createAndExecuteLiteOrder
(
List
<
PreWarningItem
>
lineItems
)
{
List
<
String
>
noPossPosIds
=
new
ArrayList
<>();
List
<
String
>
outPosIds
=
new
ArrayList
<>();
//得到料仓id
...
...
@@ -145,8 +154,8 @@ public class PreWarningItemCache extends AbstractBaseDao {
//处理线别需求单
LiteOrder
liteOrder
=
new
LiteOrder
();
liteOrder
.
setType
(
2
);
liteOrder
.
setOrderNo
(
new
PreWarningItemCache
().
getSeq
());
liteOrder
.
setSo
(
new
PreWarningItemCache
().
getSeq
(
));
liteOrder
.
setOrderNo
(
getSeq
());
//liteOrder.setSo(getSeq(2
));
List
<
LiteOrderItem
>
orderItems
=
new
ArrayList
<>();
for
(
PreWarningItem
item
:
lineItems
)
{
liteOrder
.
setLine
(
item
.
getLine
());
...
...
@@ -164,19 +173,25 @@ public class PreWarningItemCache extends AbstractBaseDao {
if
(
StringUtils
.
isNotBlank
(
storageId
))
{
c
.
and
(
"storageId"
).
is
(
storageId
);
}
List
<
String
>
posIds
=
new
ArrayList
<>();
//排除已经执行过的物料barcode
if
(
outPosIds
!=
null
&&
!
outPosIds
.
isEmpty
())
{
c
.
and
(
"id"
).
not
().
in
(
outPosIds
);
posIds
.
addAll
(
outPosIds
);
}
//排除校验没通过的
if
(
noPossPosIds
!=
null
&&
!
noPossPosIds
.
isEmpty
())
{
// c.and("id").not().in
(noPossPosIds);
posIds
.
addAll
(
noPossPosIds
);
}
//排除正在执行出库的工位
Collection
<
String
>
excludePosIds
=
taskService
.
excludePosIds
();
if
(
excludePosIds
!=
null
&&
!
excludePosIds
.
isEmpty
())
{
// c.and("id").not().in
(excludePosIds);
posIds
.
addAll
(
excludePosIds
);
}
if
(
posIds
!=
null
&&
!
posIds
.
isEmpty
())
{
c
.
and
(
"id"
).
not
().
in
(
posIds
);
}
//排除正在执行的工单物料
Collection
<
String
>
excludeBarcodeIds
=
liteOrderCache
.
excludeBarcodeIds
();
if
(
excludeBarcodeIds
!=
null
&&
!
excludeBarcodeIds
.
isEmpty
())
{
...
...
@@ -200,9 +215,10 @@ public class PreWarningItemCache extends AbstractBaseDao {
}
else
{
for
(
StoragePos
pos
:
storagePoss
)
{
Barcode
barcode
=
pos
.
getBarcode
();
//String checkResult = LizhenApi.wmsCheckReelfob("", barcode);
String
checkResult
=
""
;
//立臻校验时,需要切换
if
(
StringUtils
.
isBlank
(
checkResult
))
{
try
{
Barcode
barcodeApi
=
smfApi
.
canPutInAfterResolve
(
barcode
);
//String checkResult = ""; //立臻校验时,需要切换
if
(
barcodeApi
!=
null
)
{
outPosIds
.
add
(
pos
.
getId
());
//防止其他地方出库
orderItem
.
setRi
(
barcode
.
getBarcode
());
orderItem
.
setNeedNum
(
1
);
...
...
@@ -210,10 +226,13 @@ public class PreWarningItemCache extends AbstractBaseDao {
flag
=
false
;
break
;
}
else
{
log
.
info
(
"partNumber:{}校验失败:{}"
,
barcode
.
getPartNumber
(),
checkResult
);
log
.
info
(
"partNumber:{}校验失败:{}"
,
barcode
.
getPartNumber
()
);
noPossPosIds
.
add
(
pos
.
getId
());
continue
;
}
}
catch
(
ValidateException
e
)
{
e
.
printStackTrace
();
}
}
}
}
...
...
@@ -222,9 +241,9 @@ public class PreWarningItemCache extends AbstractBaseDao {
liteOrder
.
setOrderItems
(
orderItems
);
liteOrder
.
setTaskReelCount
(
orderItems
.
size
());
liteOrder
=
liteOrderManager
.
createWithItems
(
liteOrder
);
liteOrderManager
.
save
(
liteOrder
);
liteOrderCache
.
addOrderToMap
(
liteOrder
);
}
return
liteOrder
;
}
private
static
synchronized
void
updateItem
(
List
<
PreWarningItem
>
items
,
boolean
remove
)
{
...
...
@@ -283,18 +302,17 @@ public class PreWarningItemCache extends AbstractBaseDao {
PreWarningItemCache
.
storagePosManager
=
storagePosManager
;
}
//待修改----
private
String
getSeq
()
{
// return "H" + getNextId(getEntityClass().getName());
int
seq
=
atomicInteger
.
addAndGet
(
1
);
return
"H"
+
seq
;
@Autowired
public
void
setSmfApi
(
SmfApi
smfApi
)
{
PreWarningItemCache
.
smfApi
=
smfApi
;
}
@Autowired
public
void
setPreWarningItemManager
(
PreWarningItemManager
itemManager
){
PreWarningItemCache
.
preWarningItemManager
=
itemManager
;
}
@Override
public
Class
getEntityClass
()
{
return
PreWarningItemCache
.
class
;
private
static
String
getSeq
()
{
return
"H"
+
preWarningItemManager
.
getNextId
(
PreWarningItemCache
.
class
.
getName
());
}
}
src/main/java/com/neotel/smfcore/custom/lizhen/innerBox/util/service/PreWarningItemManager.java
0 → 100644
查看文件 @
437a3c1
package
com
.
neotel
.
smfcore
.
custom
.
lizhen
.
innerBox
.
util
.
service
;
import
com.neotel.smfcore.common.base.AbstractBaseDao
;
import
com.neotel.smfcore.custom.lizhen.innerBox.util.PreWarningItemCache
;
import
org.springframework.stereotype.Service
;
@Service
public
class
PreWarningItemManager
extends
AbstractBaseDao
{
@Override
public
Class
getEntityClass
()
{
return
PreWarningItemCache
.
class
;
}
}
src/main/java/com/neotel/smfcore/custom/panacim/PanaApiController.java
查看文件 @
437a3c1
...
...
@@ -427,6 +427,11 @@ public class PanaApiController extends BaseSmfApiListener {
}
@Override
public
Barcode
barcodeInfo
(
String
barcodeInfoUrl
,
Barcode
barcode
)
{
return
null
;
}
@Override
public
void
inTaskStatusChange
(
String
inNotifyUrl
,
DataLog
task
)
{
if
(
task
.
isFinished
()){
if
(
task
.
isPutInTask
()){
...
...
src/main/java/com/neotel/smfcore/custom/siemens/SiemensApi.java
查看文件 @
437a3c1
...
...
@@ -190,6 +190,11 @@ public class SiemensApi extends BaseSmfApiListener {
}
}
@Override
public
Barcode
barcodeInfo
(
String
barcodeInfoUrl
,
Barcode
barcode
)
{
return
null
;
}
public
static
LotCheckInfo
lotCheckIn
(
String
lot
,
String
url
,
String
deviceId
)
{
if
(
ObjectUtil
.
isEmpty
(
url
))
{
log
.
info
(
"没有配置Siemens,无需验证"
);
...
...
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论