Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
孙克
/
smf-core
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
作业
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit 23014017
由
LN
编写于
2025-07-03 16:45:37 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
1
1 个父辈
13048cf2
显示空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
65 行增加
和
33 行删除
src/main/java/com/neotel/smfcore/custom/zhongcheSp1568/ZhongCheSPApi.java
src/main/java/com/neotel/smfcore/custom/zhongcheSp1568/ZhongCheSPApi.java
查看文件 @
2301401
...
@@ -19,10 +19,7 @@ import lombok.extern.slf4j.Slf4j;
...
@@ -19,10 +19,7 @@ import lombok.extern.slf4j.Slf4j;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
java.util.ArrayList
;
import
java.util.*
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
@Service
@Service
@Slf4j
@Slf4j
...
@@ -109,24 +106,42 @@ public class ZhongCheSPApi extends BaseSmfApiListener {
...
@@ -109,24 +106,42 @@ public class ZhongCheSPApi extends BaseSmfApiListener {
String
resultCode
=
(
String
)
response
.
get
(
"resultCode"
);
String
resultCode
=
(
String
)
response
.
get
(
"resultCode"
);
if
(
"0000"
.
equals
(
resultCode
))
{
if
(
"0000"
.
equals
(
resultCode
))
{
Object
resultDataObj
=
response
.
get
(
"resultData"
);
Object
resultDataObj
=
response
.
get
(
"resultData"
);
if
(
resultDataObj
instanceof
List
)
{
Map
<
String
,
Object
>
materialData
=
null
;
List
<
Object
>
resultDataList
=
(
List
<
Object
>)
resultDataObj
;
try
{
if
(!
resultDataList
.
isEmpty
())
{
if
(
resultDataObj
instanceof
Map
)
{
Map
<
String
,
Object
>
materialData
=
(
Map
<
String
,
Object
>)
resultDataList
.
get
(
0
);
Map
<
String
,
Object
>
resultDataMap
=
(
Map
<
String
,
Object
>)
resultDataObj
;
Object
dataListObj
=
resultDataMap
.
get
(
"data"
);
if
(
dataListObj
instanceof
List
)
{
List
<
Map
<
String
,
Object
>>
dataList
=
(
List
<
Map
<
String
,
Object
>>)
dataListObj
;
if
(!
dataList
.
isEmpty
())
{
materialData
=
dataList
.
get
(
0
);
log
.
info
(
"成功解析MES数据,物料编码: "
+
materialData
.
get
(
"mtrl_code"
));
}
else
{
log
.
warn
(
"MES返回的data数据列表为空"
);
}
}
else
{
log
.
error
(
"MES返回数据格式错误:data字段不是数组类型"
);
}
}
else
{
log
.
error
(
"MES返回数据格式错误:resultData不是对象类型"
);
}
}
catch
(
Exception
ex
)
{
log
.
error
(
"canPutInAfterResolve 解析数据失败:"
+
ex
.
getMessage
());
}
if
(
materialData
!=
null
)
{
// 保存物料配置信息到component
// 保存物料配置信息到component
// 锡膏类型
// 锡膏类型
String
pn
=
materialData
.
get
(
"sr_type"
).
toString
();
Object
srTypeObj
=
materialData
.
get
(
"sr_type"
);
if
(
ObjectUtil
.
isEmpty
(
pn
))
{
if
(
srTypeObj
==
null
)
{
log
.
error
(
"canPutInAfterResolve 失败,resultCode: "
+
resultCode
+
", sr_type为空: "
);
log
.
error
(
"canPutInAfterResolve 失败,resultCode: "
+
resultCode
+
", sr_type为空: "
);
throw
new
ValidateException
(
"smfcore.mesApi.inCheck.error"
,
"MES查询失败["
+
resultCode
+
"]: sr_type为空"
);
// throw new ValidateException("smfcore.mesApi.inCheck.error", "MES查询失败[" + resultCode + "]: sr_type为空");
}
if
(
barcode
.
getPartNumber
()!=
pn
){
barcode
.
setPartNumber
(
pn
);
barcodeManager
.
save
(
barcode
);
}
}
// sr_type 是锡膏类型,不需要修改 partNumber
log
.
info
(
"获取到锡膏类型 sr_type: "
+
srTypeObj
.
toString
());
// 根据物料编码查找或创建Component
// 根据物料编码查找或创建Component
Component
component
=
componentManager
.
findOneByPN
(
barcode
.
getPartNumber
());
Component
component
=
componentManager
.
findOneByPN
(
barcode
.
getPartNumber
());
if
(
component
==
null
)
{
if
(
component
==
null
)
{
...
@@ -137,12 +152,13 @@ public class ZhongCheSPApi extends BaseSmfApiListener {
...
@@ -137,12 +152,13 @@ public class ZhongCheSPApi extends BaseSmfApiListener {
component
.
setAmount
(
1
);
component
.
setAmount
(
1
);
log
.
info
(
"创建新的Component,物料编码: "
+
barcode
.
getPartNumber
());
log
.
info
(
"创建新的Component,物料编码: "
+
barcode
.
getPartNumber
());
}
}
// 回温时间(小时)
// 回温时间(小时)- 注意这里返回的是double类型
Object
tempDpart
=
materialData
.
get
(
"temp_dpart"
);
Object
tempDpart
=
materialData
.
get
(
"temp_dpart"
);
if
(
tempDpart
!=
null
)
{
if
(
tempDpart
!=
null
)
{
int
warmTimeHours
=
Integer
.
parseInt
(
tempDpart
.
toString
());
double
warmTimeHours
=
Double
.
parseDouble
(
tempDpart
.
toString
());
component
.
setWarmTime
(
warmTimeHours
*
60
);
// 转换为分钟保存
component
.
setWarmTime
((
int
)
(
warmTimeHours
*
60
)
);
// 转换为分钟保存
//
component.updateAppendData("temp_dpart", tempDpart.toString());
component
.
updateAppendData
(
"temp_dpart"
,
tempDpart
.
toString
());
}
}
// 回温超时(分钟)
// 回温超时(分钟)
...
@@ -151,11 +167,11 @@ public class ZhongCheSPApi extends BaseSmfApiListener {
...
@@ -151,11 +167,11 @@ public class ZhongCheSPApi extends BaseSmfApiListener {
component
.
updateAppendData
(
"temp_over_dpart"
,
tempOverDpart
.
toString
());
component
.
updateAppendData
(
"temp_over_dpart"
,
tempOverDpart
.
toString
());
}
}
// 搅拌时间(分钟)
// 搅拌时间(分钟)- 注意这里返回的是double类型
Object
stirDpart
=
materialData
.
get
(
"stir_dpart"
);
Object
stirDpart
=
materialData
.
get
(
"stir_dpart"
);
if
(
stirDpart
!=
null
)
{
if
(
stirDpart
!=
null
)
{
int
mixTimeMinutes
=
Integer
.
parseInt
(
stirDpart
.
toString
());
double
mixTimeMinutes
=
Double
.
parseDouble
(
stirDpart
.
toString
());
component
.
setMixTime
(
mixTimeMinutes
*
60
);
// 转换为秒保存
component
.
setMixTime
((
int
)
(
mixTimeMinutes
*
60
)
);
// 转换为秒保存
component
.
updateAppendData
(
"stir_dpart"
,
stirDpart
.
toString
());
component
.
updateAppendData
(
"stir_dpart"
,
stirDpart
.
toString
());
}
}
...
@@ -196,11 +212,16 @@ public class ZhongCheSPApi extends BaseSmfApiListener {
...
@@ -196,11 +212,16 @@ public class ZhongCheSPApi extends BaseSmfApiListener {
component
.
updateAppendData
(
"must_stir_dpart"
,
mustStirDpart
.
toString
());
component
.
updateAppendData
(
"must_stir_dpart"
,
mustStirDpart
.
toString
());
}
}
// 保存锡膏类型信息
if
(
ObjectUtil
.
isNotEmpty
(
srTypeObj
)){
component
.
updateAppendData
(
"sr_type"
,
srTypeObj
.
toString
());
}
// 保存Component到数据库
// 保存Component到数据库
component
=
componentManager
.
save
(
component
);
component
=
componentManager
.
save
(
component
);
log
.
info
(
"canPutInAfterResolve 成功获取并保存物料配置到Component,物料编码: "
+
barcode
.
getPartNumber
()+
",回温时间="
+
component
.
getWarmTime
()+
",搅拌时间="
+
component
.
getMixTime
());
log
.
info
(
"canPutInAfterResolve 成功获取并保存物料配置到Component,物料编码: "
+
barcode
.
getPartNumber
()
}
+
", 回温时间="
+
component
.
getWarmTime
()
+
"分钟,搅拌时间="
+
component
.
getMixTime
()
+
"秒,锡膏类型="
+
srTypeObj
.
toString
());
}
}
return
barcode
;
return
barcode
;
}
else
{
}
else
{
...
@@ -214,10 +235,10 @@ public class ZhongCheSPApi extends BaseSmfApiListener {
...
@@ -214,10 +235,10 @@ public class ZhongCheSPApi extends BaseSmfApiListener {
}
}
}
catch
(
ApiException
apiException
)
{
}
catch
(
ApiException
apiException
)
{
log
.
error
(
"canPutInAfterResolve, url="
+
inCheckUrl
+
" apiException: "
+
apiException
.
toString
());
log
.
error
(
"canPutInAfterResolve, url="
+
inCheckUrl
+
" apiException: "
+
apiException
.
getMessage
());
throw
new
ValidateException
(
"smfcore.mesApi.inCheck.error"
,
"MES接口调用异常:"
+
apiException
.
getMessage
());
throw
new
ValidateException
(
"smfcore.mesApi.inCheck.error"
,
"MES接口调用异常:"
+
apiException
.
getMessage
());
}
catch
(
Exception
exception
)
{
}
catch
(
Exception
exception
)
{
log
.
error
(
"canPutInAfterResolve, url="
+
inCheckUrl
+
" exception: "
+
exception
.
toString
());
log
.
error
(
"canPutInAfterResolve, url="
+
inCheckUrl
+
" exception: "
+
exception
.
getMessage
());
throw
new
ValidateException
(
"smfcore.mesApi.inCheck.error"
,
"MES验证异常:"
+
exception
.
getMessage
());
throw
new
ValidateException
(
"smfcore.mesApi.inCheck.error"
,
"MES验证异常:"
+
exception
.
getMessage
());
}
}
}
}
...
@@ -268,15 +289,26 @@ public class ZhongCheSPApi extends BaseSmfApiListener {
...
@@ -268,15 +289,26 @@ public class ZhongCheSPApi extends BaseSmfApiListener {
// }
// }
Barcode
barcode
=
barcodeManager
.
get
(
task
.
getBarcode
());
Barcode
barcode
=
barcodeManager
.
findByBarcode
(
task
.
getBarcode
());
String
rsType
=
null
;
String
rsType
=
null
;
if
(!
task
.
isFinished
()){
//只有结束的任务才更新
return
false
;
}
if
(
barcode
==
null
)
{
log
.
error
(
"TaskStatusChange, 任务="
+
task
.
getBarcode
()
+
"/"
+
task
.
getPosName
()
+
" 未找到条码暂不处理: "
);
return
false
;
}
if
(
task
.
isCheckOutTask
())
{
if
(
task
.
isCheckOutTask
())
{
// 领用 - 暂不支持,需要根据业务逻辑确定具体的操作类型
// 领用 - 暂不支持,需要根据业务逻辑确定具体的操作类型
log
.
warn
(
"TaskStatusChange: 领用操作暂不支持,需要进一步确认业务逻辑"
);
//
log.warn("TaskStatusChange: 领用操作暂不支持,需要进一步确认业务逻辑");
return
false
;
return
false
;
}
else
if
(
task
.
isPutInTask
())
{
}
else
if
(
task
.
isPutInTask
())
{
StoragePos
pos
=
storagePosManager
.
getByPosName
(
task
.
getPosName
());
StoragePos
pos
=
storagePosManager
.
getByPosName
(
task
.
getPosName
());
if
(
pos
==
null
)
{
log
.
error
(
"TaskStatusChange, 任务="
+
task
.
getBarcode
()
+
"/"
+
task
.
getPosName
()
+
" 未找到库位暂不处理 "
);
return
false
;
}
if
(!
pos
.
isWarmPos
())
{
if
(!
pos
.
isWarmPos
())
{
// 入库到冷藏区
// 入库到冷藏区
rsType
=
"LC"
;
// 冷藏
rsType
=
"LC"
;
// 冷藏
...
@@ -350,9 +382,9 @@ public class ZhongCheSPApi extends BaseSmfApiListener {
...
@@ -350,9 +382,9 @@ public class ZhongCheSPApi extends BaseSmfApiListener {
}
}
}
catch
(
ApiException
apiException
)
{
}
catch
(
ApiException
apiException
)
{
log
.
error
(
"TaskStatusChange, url="
+
url
+
" apiException: "
+
apiException
.
toString
());
log
.
error
(
"TaskStatusChange, url="
+
url
+
" apiException: "
+
apiException
.
getMessage
());
}
catch
(
Exception
exception
)
{
}
catch
(
Exception
exception
)
{
log
.
error
(
"TaskStatusChange, url="
+
url
+
" exception: "
+
exception
.
toString
());
log
.
error
(
"TaskStatusChange, url="
+
url
+
" exception: "
+
exception
.
getMessage
());
}
}
return
false
;
return
false
;
}
}
...
...
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论