Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
孙克
/
smf-core
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
作业
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit a5f6bf1a
由
zshaohui
编写于
2022-10-09 15:17:12 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
功能优化
1 个父辈
89f66815
显示空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
68 行增加
和
34 行删除
src/main/java/com/neotel/smfcore/common/utils/HttpHelper.java
src/main/java/com/neotel/smfcore/custom/lizhen/LizhenApi.java
src/main/java/com/neotel/smfcore/custom/lizhen/rest/WarehouseController.java
src/main/java/com/neotel/smfcore/common/utils/HttpHelper.java
查看文件 @
a5f6bf1
...
...
@@ -35,6 +35,37 @@ public class HttpHelper {
// 编码方式
private
static
final
String
CONTENT_CHARSET
=
"UTF-8"
;
public
static
String
postJson
(
String
url
,
Object
object
)
throws
ApiException
{
HttpPost
httpPost
=
new
HttpPost
(
url
);
httpPost
.
addHeader
(
"Content-Type"
,
"application/json;charset=utf-8"
);
// 设置请求参数
if
(
object
!=
null
)
{
ObjectMapper
mapper
=
new
ObjectMapper
();
try
{
String
requestBody
=
mapper
.
writeValueAsString
(
object
);
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
);
//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
){
throw
new
ApiException
(
"Request to ["
+
url
+
"] failed:"
+
e
.
getMessage
());
}
}
public
static
String
postJson
(
String
url
,
Map
<
String
,
Object
>
params
)
throws
ApiException
{
HttpPost
httpPost
=
new
HttpPost
(
url
);
httpPost
.
addHeader
(
"Content-Type"
,
"application/json;charset=utf-8"
);
...
...
src/main/java/com/neotel/smfcore/custom/lizhen/LizhenApi.java
查看文件 @
a5f6bf1
...
...
@@ -22,19 +22,18 @@ public class LizhenApi extends BaseSmfApiListener {
//7.获取MES物料数量
public
void
getReelNum
(
String
reelNumUrl
,
String
reelId
){
Map
<
String
,
Object
>
paramMap
=
new
HashMap
<>();
paramMap
.
put
(
"reelId"
,
reelId
);
String
param
=
JsonUtil
.
toJsonStr
(
paramMap
);
log
.
info
(
"获取MES物料数量入参为:"
+
param
);
public
Barcode
getReelNum
(
String
reelNumUrl
,
String
reelId
){
log
.
info
(
"获取MES物料数量入参为:"
+
reelId
);
try
{
String
result
=
HttpHelper
.
postJson
(
reelNumUrl
,
paramMap
);
String
result
=
HttpHelper
.
postJson
(
reelNumUrl
,
reelId
);
log
.
info
(
"获取MES物料数量出参为:"
+
result
);
}
catch
(
ApiException
e
)
{
e
.
printStackTrace
();
}
return
null
;
}
//3.IMES提供接收发料明细接口
public
void
saveReelInfo
(
String
outNotifyUrl
,
DataLog
task
){
Map
<
String
,
Object
>
paramMap
=
new
HashMap
<>();
...
...
@@ -67,12 +66,12 @@ public class LizhenApi extends BaseSmfApiListener {
//2.禁用料接口MES提供外围系统调用
public
void
wmsCheckReelfob
(
String
checkReelfobUrl
,
Barcode
barcode
)
{
public
void
wmsCheckReelfob
(
String
checkReelfobUrl
,
Barcode
barcode
)
{
Map
<
String
,
Object
>
paramMap
=
new
HashMap
<>();
paramMap
.
put
(
"ipn"
,
barcode
.
getPartNumber
());
paramMap
.
put
(
"reelId"
,
barcode
.
getBarcode
());
paramMap
.
put
(
"wo"
,
""
);
paramMap
.
put
(
"datecode"
,
new
SimpleDateFormat
(
"yyyyMMdd"
).
format
(
new
Date
()));
paramMap
.
put
(
"datecode"
,
new
SimpleDateFormat
(
"yyyyMMdd"
).
format
(
barcode
.
getProduce
Date
()));
paramMap
.
put
(
"lot"
,
barcode
.
getPosName
());
paramMap
.
put
(
"vendor"
,
barcode
.
getProviderNumber
());
String
param
=
JsonUtil
.
toJsonStr
(
paramMap
);
...
...
src/main/java/com/neotel/smfcore/custom/lizhen/rest/WarehouseController.java
查看文件 @
a5f6bf1
...
...
@@ -79,7 +79,7 @@ public class WarehouseController {
String
size
=
paramMap
.
get
(
"size"
);
//尺寸 "7X8"
String
num
=
paramMap
.
get
(
"num"
);
//数量
String
name
=
paramMap
.
get
(
"name"
);
//工位名称
log
.
info
(
"{}:收到选择物料信息,尺寸为:{},数量为:{}"
,
name
,
size
,
num
);
if
(
StringUtils
.
isBlank
(
size
)
||
StringUtils
.
isBlank
(
num
)
||
StringUtils
.
isBlank
(
name
))
{
return
ResultBean
.
newErrorResult
(-
1
,
""
,
"请核实尺寸,数量,工位名称是否为空"
,
new
String
[]{});
}
...
...
@@ -106,27 +106,34 @@ public class WarehouseController {
public
ResultBean
callEmptyBox
(
@RequestBody
Map
<
String
,
String
>
paramMap
)
{
String
size
=
paramMap
.
get
(
"size"
);
//尺寸
String
name
=
paramMap
.
get
(
"name"
);
//工位名称
log
.
info
(
"{}:收到呼叫空箱信息,尺寸为:{}"
,
name
,
size
);
if
(
StringUtils
.
isBlank
(
size
))
{
return
ResultBean
.
newErrorResult
(-
1
,
""
,
"尺寸不能为空"
,
new
String
[]{});
}
int
platsize
=
getPlatsizeOrHeight
(
size
,
0
);
//按料箱的amount数量进行排序
List
<
Barcode
>
boxBarcodes
=
new
ArrayList
<>();
List
<
StoragePos
>
notEmptyStoragePos
=
storagePosManager
.
findNotEmpty
();
for
(
StoragePos
storagePos
:
notEmptyStoragePos
)
{
Barcode
boxBarcode
=
storagePos
.
getBarcode
()
;
//左匹配
String
regexName
=
""
;
if
(
platsize
==
7
)
{
if
(
boxBarcode
.
getBarcode
().
startsWith
(
"CS"
))
{
boxBarcodes
.
add
(
boxBarcode
);
}
regexName
=
"CS"
;
}
else
if
(
platsize
==
13
)
{
if
(
boxBarcode
.
getBarcode
().
startsWith
(
"CM"
))
{
boxBarcodes
.
add
(
boxBarcode
);
}
regexName
=
"CM"
;
}
else
if
(
platsize
==
15
)
{
if
(
boxBarcode
.
getBarcode
().
startsWith
(
"CB"
))
{
boxBarcodes
.
add
(
boxBarcode
);
}
}
regexName
=
"CB"
;
}
Pattern
pattern
=
Pattern
.
compile
(
"^"
+
regexName
+
".*$"
,
Pattern
.
CASE_INSENSITIVE
);
//查询不为空的料箱
Criteria
c
=
Criteria
.
where
(
"barcode"
).
exists
(
true
)
.
and
(
"enabled"
).
is
(
true
);
//可用;
c
.
and
(
"barcode.barcode"
).
regex
(
pattern
);
List
<
StoragePos
>
notEmptyStoragePos
=
storagePosManager
.
findByQuery
(
new
Query
(
c
));
if
(
boxBarcodes
.
isEmpty
())
{
return
ResultBean
.
newErrorResult
(-
1
,
""
,
"未找到可用料箱"
,
new
String
[]{});
}
...
...
@@ -158,6 +165,7 @@ public class WarehouseController {
public
ResultBean
operatePos
(
@RequestBody
Map
<
String
,
String
>
paramMap
)
{
String
code
=
paramMap
.
get
(
"code"
);
//条码
String
name
=
paramMap
.
get
(
"name"
);
//工位名称
log
.
info
(
"收到物料信息,条码为:{},工位为:{}"
,
code
,
name
);
String
barcodeStr
=
""
;
if
(
code
.
startsWith
(
"C"
)
&&
code
.
indexOf
(
"-"
)
!=
-
1
)
{
barcodeStr
=
code
.
substring
(
0
,
code
.
indexOf
(
"-"
));
...
...
@@ -172,8 +180,8 @@ public class WarehouseController {
//先判断是否料盒
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
())
{
return
ResultBean
.
newErrorResult
(-
1
,
""
,
code
+
"解析条码失败"
,
new
String
[]{});
}
if
(
codeBean
.
isValid
())
{
Barcode
barcode
=
codeBean
.
getBarcode
();
...
...
@@ -194,15 +202,9 @@ public class WarehouseController {
if
(
Strings
.
isBlank
(
lastScanBoxCode
))
{
//提示要先扫料箱
return
ResultBean
.
newErrorResult
(-
1
,
""
,
"请先扫描料箱,再扫描条码"
);
}
/*else {
if (StringUtils.isBlank(currentRfid)) {
throw new ValidateException("", "{}不存在", new String[]{currentRfid});
} else if (!currentRfid.startsWith(barcode.getBarcode())) {
return ResultBean.newErrorResult(-1,"", "{}与{}不一致", new String[]{code, currentRfid});
}
}*/
StationCacheUtil
.
saveReelToBoxCode
(
station
);
String
boxBarcode
=
lastScanBoxCode
.
substring
(
0
,
code
.
indexOf
(
"-"
));
String
boxBarcode
=
lastScanBoxCode
.
substring
(
0
,
code
.
indexOf
(
"-"
));
//获取到料箱条码
Barcode
pidBarcode
=
barcodeManager
.
findByBarcode
(
boxBarcode
);
barcode
.
setHostBarcodeId
(
pidBarcode
.
getId
());
barcode
.
setPosName
(
lastScanBoxCode
);
...
...
@@ -224,11 +226,13 @@ public class WarehouseController {
cids
=
"so1131"
;
log
.
info
(
"完成装箱并入库,条码为:{},工位为:{}"
,
code
,
name
);
//校验是否存在
code
=
code
.
replace
(
"A"
,
""
).
replace
(
"B"
,
""
)
.
replace
(
"-"
,
""
)
;
code
=
code
.
replace
(
"A"
,
""
).
replace
(
"B"
,
""
);
Barcode
barcode
=
barcodeManager
.
findByBarcode
(
code
);
if
(
barcode
==
null
)
{
return
ResultBean
.
newErrorResult
(-
1
,
""
,
code
+
"不存在"
,
null
);
return
ResultBean
.
newErrorResult
(-
1
,
""
,
code
+
"
料箱
不存在"
,
null
);
}
Station
station
=
StationCacheUtil
.
getStation
(
name
);
if
(
station
==
null
)
{
...
...
@@ -383,7 +387,7 @@ public class WarehouseController {
if
(
opType
==
OP
.
PUT_IN
)
{
pidBarcode
.
setAmount
(
amount
+
opQty
);
}
else
{
pidBarcode
.
setAmount
(
amount
-
1
);
pidBarcode
.
setAmount
(
amount
-
opQty
);
}
if
(
opType
==
OP
.
CHECKOUT
&&
subBarcode
.
getAmount
()
<=
0
)
{
//数量为0直接删除
...
...
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论