Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
孙克
/
smf-core
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
作业
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit 57b39e6a
由
孙克
编写于
2024-07-11 15:11:29 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
SO21476增加入库时读取D:/remain/文件夹中唯一码进行数量修改
1 个父辈
0c20753d
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
88 行增加
和
2 行删除
src/main/java/com/neotel/smfcore/custom/so21476/ReplaceQtyApiHandler.java
src/main/resources/config/application.yml
src/main/java/com/neotel/smfcore/custom/so21476/ReplaceQtyApiHandler.java
0 → 100644
查看文件 @
57b39e6
package
com
.
neotel
.
smfcore
.
custom
.
so21476
;
import
cn.hutool.core.io.FileUtil
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
com.neotel.smfcore.common.exception.ValidateException
;
import
com.neotel.smfcore.common.utils.DateUtil
;
import
com.neotel.smfcore.common.utils.HttpHelper
;
import
com.neotel.smfcore.common.utils.JsonUtil
;
import
com.neotel.smfcore.core.api.bean.ApiResult
;
import
com.neotel.smfcore.core.api.bean.CodeValidateParam
;
import
com.neotel.smfcore.core.api.listener.DefaultSmfApiListener
;
import
com.neotel.smfcore.core.barcode.service.manager.IComponentManager
;
import
com.neotel.smfcore.core.barcode.service.po.Barcode
;
import
com.neotel.smfcore.core.barcode.service.po.Component
;
import
com.neotel.smfcore.core.barcode.utils.CodeResolve
;
import
com.neotel.smfcore.core.system.service.po.DataLog
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.logging.log4j.util.Strings
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
java.io.File
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
@Service
@Slf4j
public
class
ReplaceQtyApiHandler
extends
DefaultSmfApiListener
{
/**
*
api:
#name: SO21476
#inCheckUrl: /Volumes/E/项目文件/21476&SO1442DUO
*/
@Override
public
boolean
isForThisApi
(
String
apiName
)
{
return
apiName
!=
null
&&
apiName
.
equalsIgnoreCase
(
"SO21476"
);
}
@Override
public
Barcode
canPutInAfterResolve
(
String
inCheckUrl
,
CodeValidateParam
params
,
Barcode
barcode
)
throws
ValidateException
{
try
{
String
remainQty
=
""
;
File
folder
=
new
File
(
inCheckUrl
);
File
[]
uidFiles
=
folder
.
listFiles
();
String
uidPrefix
=
barcode
.
getBarcode
()
+
"@"
;
for
(
File
uidFile
:
uidFiles
)
{
if
(
uidFile
.
getName
().
startsWith
(
uidPrefix
)){
log
.
info
(
"查找到["
+
barcode
.
getBarcode
()+
"]对应的文件:"
+
uidFile
.
getAbsolutePath
()+
",开始读取"
);
List
<
String
>
contentLines
=
FileUtil
.
readLines
(
uidFile
,
"UTF-8"
);
for
(
int
i
=
0
;
i
<
contentLines
.
size
();
i
++)
{
String
line
=
contentLines
.
get
(
i
);
if
(
line
.
startsWith
(
"PartsName,Comment,PartsLotID,Remain,"
)){
String
nextLine
=
contentLines
.
get
(
i
+
1
);
String
[]
parts
=
nextLine
.
split
(
","
);
if
(
parts
.
length
>
3
)
{
remainQty
=
parts
[
3
].
trim
();
// Taking the 4th element which is Remain
}
break
;
}
}
break
;
}
}
if
(
remainQty
.
isEmpty
()){
log
.
info
(
"未解析出["
+
barcode
.
getBarcode
()+
"]的剩余数量"
);
}
else
{
log
.
info
(
"从文件中解析出["
+
barcode
.
getBarcode
()+
"]的剩余数量为:"
+
remainQty
+
"使用此数量入库"
);
int
qty
=
Integer
.
valueOf
(
remainQty
);
if
(
qty
>
0
){
barcode
.
setAmount
(
qty
);
}
barcode
=
barcodeManager
.
saveBarcode
(
barcode
);
return
barcode
;
}
}
catch
(
Exception
e
)
{
log
.
error
(
"入库修改数量接口出错:"
+
e
.
getMessage
());
throw
new
ValidateException
(
"smfcore.mesApi.inCheck.error"
,
"修改数量出错:"
+
e
.
getMessage
());
}
return
null
;
}
}
src/main/resources/config/application.yml
查看文件 @
57b39e6
...
...
@@ -2,8 +2,8 @@ server:
port
:
8800
api
:
name
:
inCheckUrl
:
name
:
SO21476
inCheckUrl
:
D:\remain\
outNotifyUrl
:
inNotifyUrl
:
...
...
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论