Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
huang.tao
/
jmai-platform
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
2b37ca2a
authored
Jan 12, 2026
by
zhu.zewen
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
修复Excel解析
parent
c8e54fb7
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
55 additions
and
10 deletions
jmai-physic/src/main/java/com/jmai/physic/controller/PhysicRecordController.java
jmai-sys/src/main/java/com/jmai/sys/doc/importer/DefaultImporter.java
jmai-physic/src/main/java/com/jmai/physic/controller/PhysicRecordController.java
View file @
2b37ca2a
...
@@ -13,10 +13,7 @@ import com.jmai.physic.vo.PhysicRecordVO;
...
@@ -13,10 +13,7 @@ import com.jmai.physic.vo.PhysicRecordVO;
import
com.jmai.physic.vo.PhysicVO
;
import
com.jmai.physic.vo.PhysicVO
;
import
com.jmai.sys.AbstractService
;
import
com.jmai.sys.AbstractService
;
import
com.jmai.sys.aop.Auth
;
import
com.jmai.sys.aop.Auth
;
import
com.jmai.sys.doc.importer.DefaultImporter
;
import
com.jmai.sys.doc.importer.*
;
import
com.jmai.sys.doc.importer.ImportField
;
import
com.jmai.sys.doc.importer.ImportItemBatchHandler
;
import
com.jmai.sys.doc.importer.ImportResult
;
import
com.jmai.sys.dto.ResponseData
;
import
com.jmai.sys.dto.ResponseData
;
import
io.swagger.annotations.*
;
import
io.swagger.annotations.*
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
...
@@ -80,6 +77,31 @@ public class PhysicRecordController extends AbstractService {
...
@@ -80,6 +77,31 @@ public class PhysicRecordController extends AbstractService {
new
ImportField
(
"diseaseName"
,
"*疾病名称"
,
true
,
false
)
new
ImportField
(
"diseaseName"
,
"*疾病名称"
,
true
,
false
)
);
);
private
static
final
PrescriptionConverter
PRESCRIPTION_CONVERTER
=
new
PrescriptionConverter
();
private
static
class
PrescriptionConverter
extends
DefaultImportConverter
<
PrescriptionDTO
>
{
public
PrescriptionConverter
()
{
super
(
PrescriptionDTO
.
class
);
}
@Override
public
PrescriptionDTO
convert
(
Map
<
String
,
Object
>
item
)
{
String
sex
=
(
String
)
item
.
remove
(
"sickSex"
);
if
(
ObjectUtil
.
isNotEmpty
(
sex
))
{
// 1 - 男、2 - 女、0 - 其他
sex
=
ObjectUtil
.
equals
(
sex
,
"男"
)
?
"1"
:
ObjectUtil
.
equals
(
sex
,
"女"
)
?
"2"
:
"0"
;
item
.
put
(
"sickSex"
,
sex
);
}
PrescriptionDTO
prescription
=
new
PrescriptionDTO
();
copyTo
(
item
,
prescription
);
return
prescription
;
}
}
@ApiOperation
(
"解析处方(患者)信息"
)
@ApiOperation
(
"解析处方(患者)信息"
)
@PostMapping
(
"/parsePrescription"
)
@PostMapping
(
"/parsePrescription"
)
public
ResponseData
<
Collection
<
PrescriptionDTO
>>
parsePrescription
(
@RequestParam
(
value
=
"file"
)
MultipartFile
file
)
{
public
ResponseData
<
Collection
<
PrescriptionDTO
>>
parsePrescription
(
@RequestParam
(
value
=
"file"
)
MultipartFile
file
)
{
...
@@ -88,19 +110,16 @@ public class PhysicRecordController extends AbstractService {
...
@@ -88,19 +110,16 @@ public class PhysicRecordController extends AbstractService {
ConcurrentLinkedQueue
<
PrescriptionDTO
>
prescriptions
=
new
ConcurrentLinkedQueue
<>();
ConcurrentLinkedQueue
<
PrescriptionDTO
>
prescriptions
=
new
ConcurrentLinkedQueue
<>();
ImportItemBatchHandler
<
PrescriptionDTO
>
itemBatchHandler
=
items
->
{
ImportItemBatchHandler
<
PrescriptionDTO
>
itemBatchHandler
=
items
->
{
prescriptions
.
addAll
(
items
);
prescriptions
.
addAll
(
items
);
return
items
.
stream
()
return
Collections
.
emptyMap
();
.
collect
(
Collectors
.
toMap
(
PrescriptionDTO:
:
getPrescriptionNumber
,
e
->
""
));
};
};
DefaultImporter
<
PrescriptionDTO
>
importer
=
new
DefaultImporter
<>(
bizKey
,
DefaultImporter
<
PrescriptionDTO
>
importer
=
new
DefaultImporter
<>(
bizKey
,
PrescriptionDTO
.
class
,
PRESCRIPTION_FIELDS
,
itemBatchHandler
,
file
,
ac
);
PrescriptionDTO
.
class
,
PRESCRIPTION_FIELDS
,
PRESCRIPTION_CONVERTER
,
itemBatchHandler
,
file
,
ac
);
ImportResult
result
=
execWithLock
(
bizKey
,
importer:
:
run
);
ImportResult
result
=
execWithLock
(
bizKey
,
importer:
:
run
);
if
(
ObjectUtil
.
equals
(
result
.
getStat
().
getSuccessNum
().
get
(),
result
.
getStat
().
getTotalNum
().
get
()))
{
if
(
ObjectUtil
.
equals
(
result
.
getStat
().
getSuccessNum
().
get
(),
result
.
getStat
().
getTotalNum
().
get
()))
{
// 成功
// 成功
log
.
debug
(
"解析结果:result={},prescriptions={}"
,
toJSONString
(
result
),
toJSONString
(
prescriptions
));
return
ResponseData
.
ok
(
prescriptions
);
return
ResponseData
.
ok
(
prescriptions
);
}
else
{
}
else
{
throw
new
ServiceException
(
"解析失败:"
+
toJSONString
(
result
));
throw
new
ServiceException
(
"解析失败:"
+
toJSONString
(
result
));
...
...
jmai-sys/src/main/java/com/jmai/sys/doc/importer/DefaultImporter.java
View file @
2b37ca2a
...
@@ -106,6 +106,32 @@ public class DefaultImporter<T> extends ExcelImporter<Map, String> {
...
@@ -106,6 +106,32 @@ public class DefaultImporter<T> extends ExcelImporter<Map, String> {
String
bizKey
,
String
bizKey
,
Class
<
T
>
itemType
,
Class
<
T
>
itemType
,
List
<
ImportField
>
itemFields
,
List
<
ImportField
>
itemFields
,
DefaultImportConverter
<
T
>
itemConverter
,
ImportItemBatchHandler
<
T
>
itemBatchHandler
,
MultipartFile
importFile
,
ApplicationContext
ac
)
{
super
(
Map
.
class
);
this
.
bizKey
=
bizKey
;
this
.
importFile
=
importFile
;
this
.
itemFields
=
new
ArrayList
<>(
itemFields
.
size
()
+
1
);
this
.
itemFields
.
addAll
(
itemFields
);
this
.
itemFields
.
add
(
new
ImportField
(
RESULT_FIELD_CODE
,
RESULT_FIELD_NAME
,
false
,
false
));
this
.
itemConverter
=
itemConverter
;
this
.
itemHandler
=
null
;
this
.
itemBatchHandler
=
itemBatchHandler
;
checkInit
();
// 自动装载依赖
ac
.
getAutowireCapableBeanFactory
().
autowireBean
(
this
);
}
public
DefaultImporter
(
String
bizKey
,
Class
<
T
>
itemType
,
List
<
ImportField
>
itemFields
,
ImportItemBatchHandler
<
T
>
itemBatchHandler
,
ImportItemBatchHandler
<
T
>
itemBatchHandler
,
MultipartFile
importFile
,
MultipartFile
importFile
,
ApplicationContext
ac
)
{
ApplicationContext
ac
)
{
...
...
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