Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
刘栋
/
infynova-udi
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
b7150e10
authored
May 17, 2024
by
刘栋
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
UDI-校验逻辑增加
parent
b3c5e98a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
56 additions
and
16 deletions
saas-udi-service/src/main/java/com/infynova/udi/service/impl/TaskImportServiceImpl.java
saas-udi-service/src/main/java/com/infynova/udi/service/impl/TaskImportServiceImpl.java
View file @
b7150e10
...
...
@@ -82,23 +82,14 @@ public class TaskImportServiceImpl implements TaskImportService {
boolean
errorFlag
=
false
;
for
(
TaskUdiExcelImportVo
importVo
:
excelList
)
{
StringBuilder
errorBuilder
=
new
StringBuilder
();
// 校验逻辑 - 是否还有较深的校验逻辑 todo
if
(
StringUtils
.
isBlank
(
importVo
.
getUdiCode
())
&&
StringUtils
.
isBlank
(
importVo
.
getYiBaoCode
())
&&
StringUtils
.
isBlank
(
importVo
.
getCompanyName
())
&&
StringUtils
.
isBlank
(
importVo
.
getProductFactoryCode
())
&&
StringUtils
.
isBlank
(
importVo
.
getBrandName
())
&&
StringUtils
.
isBlank
(
importVo
.
getProductName
())
&&
StringUtils
.
isBlank
(
importVo
.
getSpecification
())
&&
StringUtils
.
isBlank
(
importVo
.
getModel
())
){
errorFlag
=
true
;
errorBuilder
.
append
(
"必填字段不能都为空"
);
}
// 校验逻辑
this
.
valid
(
importVo
,
errorBuilder
);
TaskUdiExcelExportVo
taskUdiExcelExportVo
=
new
TaskUdiExcelExportVo
();
BeanUtils
.
copyProperties
(
importVo
,
taskUdiExcelExportVo
);
if
(
StringUtils
.
isNotBlank
(
errorBuilder
.
toString
())){
errorFlag
=
true
;
taskUdiExcelExportVo
.
setResult
(
errorBuilder
.
toString
());
}
else
{
taskUdiExcelExportVo
.
setResult
(
"成功"
);
...
...
@@ -112,7 +103,12 @@ public class TaskImportServiceImpl implements TaskImportService {
UploadResultVo
resultUpload
=
upload
(
resultList
,
TaskUdiExcelExportVo
.
class
);
if
(!
errorFlag
){
// 处理返回
ImportItemCount
count
=
new
ImportItemCount
();
if
(
errorFlag
){
count
.
addFailNum
(
excelList
.
size
());
}
else
{
stopWatch
.
stop
();
stopWatch
.
start
(
"保存任务"
);
// 判断成功后,将源文件上传,得到源文件保存地址
...
...
@@ -123,10 +119,9 @@ public class TaskImportServiceImpl implements TaskImportService {
Integer
taskFileCount
=
excelList
.
size
();
// 保存到task中
taskHelper
.
saveTask
(
taskFileSize
,
taskFileCount
,
taskFileAddress
,
taskFileId
);
count
.
addSuccessNum
(
excelList
.
size
());
}
// 处理返回
ImportItemCount
count
=
new
ImportItemCount
();
count
.
addTotalNum
(
excelList
.
size
());
stopWatch
.
stop
();
...
...
@@ -178,4 +173,49 @@ public class TaskImportServiceImpl implements TaskImportService {
return
upload
;
}
/**
* 校验逻辑
*/
private
void
valid
(
TaskUdiExcelImportVo
importVo
,
StringBuilder
errorBuilder
){
// 校验逻辑 - 是否还有较深的校验逻辑 todo
if
(
StringUtils
.
isBlank
(
importVo
.
getUdiCode
())
&&
StringUtils
.
isBlank
(
importVo
.
getYiBaoCode
())
&&
StringUtils
.
isBlank
(
importVo
.
getCompanyName
())
&&
StringUtils
.
isBlank
(
importVo
.
getProductFactoryCode
())
&&
StringUtils
.
isBlank
(
importVo
.
getBrandName
())
&&
StringUtils
.
isBlank
(
importVo
.
getProductName
())
&&
StringUtils
.
isBlank
(
importVo
.
getSpecification
())
&&
StringUtils
.
isBlank
(
importVo
.
getModel
())
){
errorBuilder
.
append
(
"必填字段不能都为空"
);
}
String
udiCode
=
importVo
.
getUdiCode
();
if
(
StringUtils
.
isNotBlank
(
udiCode
)){
if
(!
udiPrefixValid
(
udiCode
)){
errorBuilder
.
append
(
"udi数据格式不正确(69开头或者MA开头);"
);
}
}
String
yiBaoCode
=
importVo
.
getYiBaoCode
();
if
(
StringUtils
.
isNotBlank
(
yiBaoCode
)){
if
(!
yiBaoCodePrefixValid
(
yiBaoCode
)){
errorBuilder
.
append
(
"医保编码数据格式不正确(C开头);"
);
}
}
}
/**
* udi字符串开头匹配
*/
private
boolean
udiPrefixValid
(
String
input
)
{
return
input
.
startsWith
(
"69"
)
||
input
.
startsWith
(
"MA"
);
}
/**
* 医保编码字符串开头匹配
*/
private
boolean
yiBaoCodePrefixValid
(
String
input
)
{
return
input
.
startsWith
(
"C"
);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment