Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
emport-api
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
刘泽志
emport-api
Commits
02c07e5e
Commit
02c07e5e
authored
Mar 08, 2023
by
刘泽志
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
功能完善
parent
1714bdb0
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
127 additions
and
23 deletions
+127
-23
README.MD
README.MD
+10
-0
DataFieldController.java
...yf/his/web/controller/dataImport/DataFieldController.java
+10
-1
DictDataController.java
...byf/his/web/controller/dataImport/DictDataController.java
+0
-0
ExcelDataController.java
...yf/his/web/controller/dataImport/ExcelDataController.java
+8
-1
QueryAreaParam.java
.../tbyf/his/web/dataImport/domain/param/QueryAreaParam.java
+27
-0
UpdateFieldParam.java
...byf/his/web/dataImport/domain/param/UpdateFieldParam.java
+1
-1
DataFieldServiceImpl.java
...his/web/dataImport/service/impl/DataFieldServiceImpl.java
+23
-12
ExcelDataServiceImpl.java
...his/web/dataImport/service/impl/ExcelDataServiceImpl.java
+46
-7
application.yml
admin-api/src/main/resources/application.yml
+1
-1
DataFieldMapper.xml
admin-api/src/main/resources/mapper/DataFieldMapper.xml
+1
-0
No files found.
README.MD
View file @
02c07e5e
...
@@ -37,4 +37,13 @@ CREATE TABLE T0801_TCMHOSP_BACKUP AS
...
@@ -37,4 +37,13 @@ CREATE TABLE T0801_TCMHOSP_BACKUP AS
SELECT *
SELECT *
FROM T0801_TCMHOSP;
FROM T0801_TCMHOSP;
```
```
需要固定的字段 必须选填
ORG_NAME 机构名称
ORG_CODE 组织机构代码
AREA_NUMBER_CODE 行政区划代码
UNIFORM_CREDIT_NUMBER 统一社会信用代码
MAILING_ADDRESS / ADDRESS_OF_ORG 通信地址/医院类型模板的地址
```
```
\ No newline at end of file
admin-api/src/main/java/com/tbyf/his/web/controller/dataImport/DataFieldController.java
View file @
02c07e5e
...
@@ -9,7 +9,6 @@ import com.tbyf.his.common.annotation.IgnoreWebSecurity;
...
@@ -9,7 +9,6 @@ import com.tbyf.his.common.annotation.IgnoreWebSecurity;
import
com.tbyf.his.common.core.domain.AjaxResult
;
import
com.tbyf.his.common.core.domain.AjaxResult
;
import
com.tbyf.his.common.core.page.TableDataInfo
;
import
com.tbyf.his.common.core.page.TableDataInfo
;
import
com.tbyf.his.common.core.text.StrFormatter
;
import
com.tbyf.his.common.core.text.StrFormatter
;
import
com.tbyf.his.common.exception.base.BaseException
;
import
com.tbyf.his.common.utils.StringUtils
;
import
com.tbyf.his.common.utils.StringUtils
;
import
com.tbyf.his.common.utils.bean.BeanUtils
;
import
com.tbyf.his.common.utils.bean.BeanUtils
;
import
com.tbyf.his.web.dataImport.DataImportUtils
;
import
com.tbyf.his.web.dataImport.DataImportUtils
;
...
@@ -218,6 +217,13 @@ public class DataFieldController {
...
@@ -218,6 +217,13 @@ public class DataFieldController {
@PostMapping
(
"/meta"
)
@PostMapping
(
"/meta"
)
@ApiOperation
(
"元字段新增"
)
@ApiOperation
(
"元字段新增"
)
public
AjaxResult
addMetaField
(
@RequestBody
@Validated
MetaField
field
)
{
public
AjaxResult
addMetaField
(
@RequestBody
@Validated
MetaField
field
)
{
field
.
setFieldType
(
field
.
getFieldType
().
toUpperCase
());
final
LambdaQueryWrapper
<
MetaField
>
wrapper
=
Wrappers
.
lambdaQuery
(
MetaField
.
class
)
.
eq
(
MetaField:
:
getFieldName
,
field
.
getFieldName
());
final
long
count
=
metaFieldService
.
count
(
wrapper
);
if
(
count
>
0
)
{
return
AjaxResult
.
error
(
"不能新增相同名称的字段"
);
}
metaFieldService
.
save
(
field
);
metaFieldService
.
save
(
field
);
return
AjaxResult
.
success
();
return
AjaxResult
.
success
();
}
}
...
@@ -226,6 +232,9 @@ public class DataFieldController {
...
@@ -226,6 +232,9 @@ public class DataFieldController {
@PostMapping
(
"/meta/update"
)
@PostMapping
(
"/meta/update"
)
@ApiOperation
(
"修改元字段"
)
@ApiOperation
(
"修改元字段"
)
public
AjaxResult
updateMeatField
(
@RequestBody
@Validated
MetaField
field
)
{
public
AjaxResult
updateMeatField
(
@RequestBody
@Validated
MetaField
field
)
{
if
(
StringUtils
.
isNotBlank
(
field
.
getFieldType
()))
{
field
.
setFieldType
(
field
.
getFieldType
().
toUpperCase
());
}
metaFieldService
.
updateById
(
field
);
metaFieldService
.
updateById
(
field
);
return
AjaxResult
.
success
();
return
AjaxResult
.
success
();
}
}
...
...
admin-api/src/main/java/com/tbyf/his/web/controller/dataImport/DictDataController.java
View file @
02c07e5e
This diff is collapsed.
Click to expand it.
admin-api/src/main/java/com/tbyf/his/web/controller/dataImport/ExcelDataController.java
View file @
02c07e5e
...
@@ -150,6 +150,9 @@ public class ExcelDataController {
...
@@ -150,6 +150,9 @@ public class ExcelDataController {
.
eq
(
DataDict:
:
getType
,
"area"
));
.
eq
(
DataDict:
:
getType
,
"area"
));
DataTemplate
template
=
dataTemplateService
.
getById
(
excelData
.
getTemplateId
());
DataTemplate
template
=
dataTemplateService
.
getById
(
excelData
.
getTemplateId
());
String
sql
=
"SELECT ROWCODE, '{}' AS ORG_TYPE,ORG_NAME,MAILING_ADDRESS,AREA_NUMBER_CODE FROM {} WHERE YEAROOFDATARECORD='{}年'"
;
String
sql
=
"SELECT ROWCODE, '{}' AS ORG_TYPE,ORG_NAME,MAILING_ADDRESS,AREA_NUMBER_CODE FROM {} WHERE YEAROOFDATARECORD='{}年'"
;
if
(
StringUtils
.
equals
(
"中医类医院"
,
template
.
getOrgName
()))
{
sql
=
"SELECT ROWCODE, '{}' AS ORG_TYPE,ORG_NAME, ADDRESS_OF_ORG AS MAILING_ADDRESS,AREA_NUMBER_CODE FROM {} WHERE YEAROOFDATARECORD='{}年'"
;
}
try
{
try
{
DataSourceService
.
switchDb
(
template
.
getDataSourceId
());
DataSourceService
.
switchDb
(
template
.
getDataSourceId
());
List
<
AreaDict
>
areaDictList
=
jdbcTemplate
.
query
(
List
<
AreaDict
>
areaDictList
=
jdbcTemplate
.
query
(
...
@@ -167,10 +170,11 @@ public class ExcelDataController {
...
@@ -167,10 +170,11 @@ public class ExcelDataController {
return
true
;
return
true
;
}
}
final
Optional
<
DataDict
>
first
=
areaList
.
stream
().
filter
(
item
->
StringUtils
.
equals
(
item
.
getValue
(),
area
.
getAREA_NUMBER_CODE
())).
findFirst
();
final
Optional
<
DataDict
>
first
=
areaList
.
stream
().
filter
(
item
->
StringUtils
.
equals
(
item
.
getValue
(),
area
.
getAREA_NUMBER_CODE
())).
findFirst
();
return
!
first
.
map
(
dataDict
->
area
.
getORG_NAME
().
startsWith
(
dataDict
.
getLabel
())).
orElse
(
true
);
return
first
.
map
(
dataDict
->
!
area
.
getORG_NAME
().
startsWith
(
dataDict
.
getLabel
())).
orElse
(
true
);
})
})
.
collect
(
Collectors
.
toList
());
.
collect
(
Collectors
.
toList
());
}
}
areaDictList
.
sort
(
Comparator
.
comparingInt
(
x
->
x
.
getAREA_NUMBER_CODE
().
hashCode
()));
return
AjaxResult
.
success
(
areaDictList
);
return
AjaxResult
.
success
(
areaDictList
);
}
finally
{
}
finally
{
DataSourceService
.
switchDefault
();
DataSourceService
.
switchDefault
();
...
@@ -188,6 +192,9 @@ public class ExcelDataController {
...
@@ -188,6 +192,9 @@ public class ExcelDataController {
.
eq
(
ExcelData:
:
getYear
,
area
.
getYear
())
.
eq
(
ExcelData:
:
getYear
,
area
.
getYear
())
.
eq
(
ExcelData:
:
getType
,
"1"
),
false
);
.
eq
(
ExcelData:
:
getType
,
"1"
),
false
);
DataTemplate
template
=
dataTemplateService
.
getById
(
excelData
.
getTemplateId
());
DataTemplate
template
=
dataTemplateService
.
getById
(
excelData
.
getTemplateId
());
if
(
StringUtils
.
equals
(
"中医类医院"
,
template
.
getOrgName
()))
{
sql
=
"UPDATE {} SET ORG_NAME = '{}' ,ADDRESS_OF_ORG='{}',AREA_NUMBER_CODE='{}' WHERE ROWCODE = '{}'"
;
}
try
{
try
{
DataSourceService
.
switchDb
(
template
.
getDataSourceId
());
DataSourceService
.
switchDb
(
template
.
getDataSourceId
());
jdbcTemplate
.
execute
(
StrFormatter
.
format
(
sql
,
jdbcTemplate
.
execute
(
StrFormatter
.
format
(
sql
,
...
...
admin-api/src/main/java/com/tbyf/his/web/dataImport/domain/param/QueryAreaParam.java
0 → 100644
View file @
02c07e5e
package
com
.
tbyf
.
his
.
web
.
dataImport
.
domain
.
param
;
import
com.tbyf.his.web.dataImport.domain.ParamMp
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
lombok.EqualsAndHashCode
;
import
lombok.experimental.Accessors
;
/**
* @author lzz
* @date 2023/1/10 17:01
*/
@EqualsAndHashCode
(
callSuper
=
true
)
@Data
@Accessors
(
chain
=
true
)
@ApiModel
(
value
=
"查询机构"
,
description
=
"查询机构"
)
public
class
QueryAreaParam
extends
ParamMp
{
@ApiModelProperty
(
value
=
"区域编码"
)
private
String
value
;
@ApiModelProperty
(
value
=
"区域名称"
)
private
String
label
;
}
admin-api/src/main/java/com/tbyf/his/web/dataImport/domain/param/UpdateFieldParam.java
View file @
02c07e5e
...
@@ -37,7 +37,7 @@ public class UpdateFieldParam implements Serializable {
...
@@ -37,7 +37,7 @@ public class UpdateFieldParam implements Serializable {
private
String
coordinate
;
private
String
coordinate
;
@ApiModelProperty
(
value
=
"排序字段"
)
@ApiModelProperty
(
value
=
"排序字段"
)
private
Integer
sort
=
0
;
private
Integer
sort
;
@ApiModelProperty
(
value
=
"数据库字段名"
)
@ApiModelProperty
(
value
=
"数据库字段名"
)
private
String
field
;
private
String
field
;
...
...
admin-api/src/main/java/com/tbyf/his/web/dataImport/service/impl/DataFieldServiceImpl.java
View file @
02c07e5e
...
@@ -6,24 +6,19 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
...
@@ -6,24 +6,19 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import
com.tbyf.his.common.annotation.DataSource
;
import
com.tbyf.his.common.annotation.DataSource
;
import
com.tbyf.his.common.enums.DataSourceType
;
import
com.tbyf.his.common.enums.DataSourceType
;
import
com.tbyf.his.common.utils.StringUtils
;
import
com.tbyf.his.common.utils.StringUtils
;
import
com.tbyf.his.web.dataImport.DataImportUtils
;
import
com.tbyf.his.web.dataImport.domain.param.QueryFieldParam
;
import
com.tbyf.his.web.dataImport.domain.param.QueryFieldParam
;
import
com.tbyf.his.web.dataImport.domain.vo.CreateFieldVO
;
import
com.tbyf.his.web.dataImport.domain.vo.CreateFieldVO
;
import
com.tbyf.his.web.dataImport.domain.vo.DataFieldVO
;
import
com.tbyf.his.web.dataImport.domain.vo.DataFieldVO
;
import
com.tbyf.his.web.dataImport.domain.vo.VerifyVO
;
import
com.tbyf.his.web.dataImport.domain.vo.VerifyVO
;
import
com.tbyf.his.web.dataImport.entity.DataField
;
import
com.tbyf.his.web.dataImport.entity.DataField
;
import
com.tbyf.his.web.dataImport.entity.DataTemplate
;
import
com.tbyf.his.web.dataImport.entity.DataTemplate
;
import
com.tbyf.his.web.dataImport.entity.MetaField
;
import
com.tbyf.his.web.dataImport.mapper.DataFieldMapper
;
import
com.tbyf.his.web.dataImport.mapper.DataFieldMapper
;
import
com.tbyf.his.web.dataImport.service.DataFieldService
;
import
com.tbyf.his.web.dataImport.service.DataFieldService
;
import
com.tbyf.his.web.dataImport.service.DataTemplateService
;
import
com.tbyf.his.web.dataImport.service.DataTemplateService
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.RegExUtils
;
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
org.springframework.util.CollectionUtils
;
import
java.util.Comparator
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Optional
;
import
java.util.Optional
;
...
@@ -64,18 +59,34 @@ public class DataFieldServiceImpl extends ServiceImpl<DataFieldMapper, DataField
...
@@ -64,18 +59,34 @@ public class DataFieldServiceImpl extends ServiceImpl<DataFieldMapper, DataField
if
(
StringUtils
.
isBlank
(
field
.
getTitle
()))
{
if
(
StringUtils
.
isBlank
(
field
.
getTitle
()))
{
return
;
return
;
}
}
Optional
<
DataField
>
fieldOptional
=
fieldMatchList
.
stream
().
filter
(
item
->
{
// 先进行字段与code双匹配
Optional
<
DataField
>
optional
=
fieldMatchList
.
stream
().
filter
(
item
->
{
// 1.先判断两个是否相等
// 1.先判断两个是否相等
if
(
StringUtils
.
equals
(
item
.
getTitle
().
trim
(),
field
.
getTitle
().
trim
()))
{
if
(
StringUtils
.
equals
(
item
.
getTitle
().
trim
(),
field
.
getTitle
().
trim
())
&&
StringUtils
.
equals
(
item
.
getCode
(),
field
.
getCode
()))
{
return
true
;
return
true
;
}
}
// 去除五角星号再判断
// 去除五角星号再判断
return
StringUtils
.
equals
(
item
.
getTitle
().
replaceAll
(
"★"
,
""
).
replaceAll
(
":"
,
""
).
trim
(),
return
StringUtils
.
equals
(
item
.
getTitle
().
replaceAll
(
"★"
,
""
).
replaceAll
(
":"
,
""
).
trim
(),
field
.
getTitle
().
replaceAll
(
"★"
,
""
).
replaceAll
(
":"
,
""
).
trim
());
field
.
getTitle
().
replaceAll
(
"★"
,
""
).
replaceAll
(
":"
,
""
).
trim
())
&&
StringUtils
.
equals
(
item
.
getCode
(),
field
.
getCode
());
}).
findFirst
();
}).
findFirst
();
fieldOptional
.
ifPresent
(
f
->{
if
(
optional
.
isPresent
())
{
field
.
setField
(
f
.
getField
());
field
.
setField
(
optional
.
get
().
getField
());
});
}
else
{
Optional
<
DataField
>
fieldOptional
=
fieldMatchList
.
stream
().
filter
(
item
->
{
// 1.先判断两个是否相等
if
(
StringUtils
.
equals
(
item
.
getTitle
().
trim
(),
field
.
getTitle
().
trim
()))
{
return
true
;
}
// 去除五角星号再判断
return
StringUtils
.
equals
(
item
.
getTitle
().
replaceAll
(
"★"
,
""
).
replaceAll
(
":"
,
""
).
trim
(),
field
.
getTitle
().
replaceAll
(
"★"
,
""
).
replaceAll
(
":"
,
""
).
trim
());
}).
findFirst
();
fieldOptional
.
ifPresent
(
f
->
{
field
.
setField
(
f
.
getField
());
});
}
}
}
@Override
@Override
...
...
admin-api/src/main/java/com/tbyf/his/web/dataImport/service/impl/ExcelDataServiceImpl.java
View file @
02c07e5e
...
@@ -7,6 +7,7 @@ import com.tbyf.his.common.annotation.DataSource;
...
@@ -7,6 +7,7 @@ import com.tbyf.his.common.annotation.DataSource;
import
com.tbyf.his.common.annotation.Excel
;
import
com.tbyf.his.common.annotation.Excel
;
import
com.tbyf.his.common.core.text.StrFormatter
;
import
com.tbyf.his.common.core.text.StrFormatter
;
import
com.tbyf.his.common.enums.DataSourceType
;
import
com.tbyf.his.common.enums.DataSourceType
;
import
com.tbyf.his.common.exception.base.BaseException
;
import
com.tbyf.his.common.utils.StringUtils
;
import
com.tbyf.his.common.utils.StringUtils
;
import
com.tbyf.his.web.dataImport.DataImportUtils
;
import
com.tbyf.his.web.dataImport.DataImportUtils
;
import
com.tbyf.his.web.dataImport.core.*
;
import
com.tbyf.his.web.dataImport.core.*
;
...
@@ -75,7 +76,7 @@ public class ExcelDataServiceImpl extends ServiceImpl<ExcelDataMapper, ExcelData
...
@@ -75,7 +76,7 @@ public class ExcelDataServiceImpl extends ServiceImpl<ExcelDataMapper, ExcelData
try
{
try
{
DataSourceService
.
switchDb
(
template
.
getDataSourceId
());
DataSourceService
.
switchDb
(
template
.
getDataSourceId
());
// 需要先清空临时表的数据,按照年份
// 需要先清空临时表的数据,按照年份
dataList
=
jdbcTemplate
.
query
(
StrFormatter
.
format
(
sqlTemplate
,
fieldSql
,
template
.
getTableName
(),
template
.
getYear
()
+
"年"
),
new
StringColumnRowMapper
());
dataList
=
jdbcTemplate
.
query
(
StrFormatter
.
format
(
sqlTemplate
,
fieldSql
,
template
.
getTableName
()
+
"_TEMP"
,
template
.
getYear
()
+
"年"
),
new
StringColumnRowMapper
());
// 解析数据到values里面
// 解析数据到values里面
for
(
VerifyVO
verifyVO
:
verifyList
)
{
for
(
VerifyVO
verifyVO
:
verifyList
)
{
dataList
.
forEach
(
map
->
{
dataList
.
forEach
(
map
->
{
...
@@ -458,6 +459,7 @@ public class ExcelDataServiceImpl extends ServiceImpl<ExcelDataMapper, ExcelData
...
@@ -458,6 +459,7 @@ public class ExcelDataServiceImpl extends ServiceImpl<ExcelDataMapper, ExcelData
@Override
@Override
public
void
importData
(
ExcelData
excelData
)
{
public
void
importData
(
ExcelData
excelData
)
{
long
startTime
=
System
.
currentTimeMillis
();
final
DataTemplate
template
=
dataTemplateService
.
getById
(
excelData
.
getTemplateId
());
final
DataTemplate
template
=
dataTemplateService
.
getById
(
excelData
.
getTemplateId
());
// 获取元字段与所有校验对象
// 获取元字段与所有校验对象
List
<
VerifyVO
>
verifyList
=
dataTemplateService
.
getVerify
(
template
.
getId
());
List
<
VerifyVO
>
verifyList
=
dataTemplateService
.
getVerify
(
template
.
getId
());
...
@@ -480,18 +482,52 @@ public class ExcelDataServiceImpl extends ServiceImpl<ExcelDataMapper, ExcelData
...
@@ -480,18 +482,52 @@ public class ExcelDataServiceImpl extends ServiceImpl<ExcelDataMapper, ExcelData
}
}
vo
.
setCoordinate
(
s
);
vo
.
setCoordinate
(
s
);
}
}
int
a
=
0
;
// 整数位长度
int
b
=
0
;
// 小数位长度
int
l
=
0
;
// 字段长度
if
(
StringUtils
.
containsIgnoreCase
(
vo
.
getFieldType
(),
"NUMBER"
))
{
final
String
[]
numbers
=
vo
.
getFieldType
().
replaceAll
(
"NUMBER"
,
""
)
.
replaceAll
(
"\\("
,
""
)
.
replaceAll
(
"\\)"
,
""
)
.
split
(
","
);
b
=
Integer
.
parseInt
(
numbers
[
1
]);
a
=
Integer
.
parseInt
(
numbers
[
0
])
-
b
;
}
else
if
(
StringUtils
.
containsIgnoreCase
(
vo
.
getFieldType
(),
"VARCHAR2"
))
{
l
=
Integer
.
parseInt
(
vo
.
getFieldType
().
replaceAll
(
"VARCHAR2"
,
""
)
.
replaceAll
(
"\\("
,
""
)
.
replaceAll
(
"\\)"
,
""
));
}
final
String
[]
coords
=
vo
.
getCoordinate
().
split
(
","
);
final
String
[]
coords
=
vo
.
getCoordinate
().
split
(
","
);
// TODO 这里减1的原因是excel表名的行号1实际上的下标为0
// TODO 这里减1的原因是excel表名的行号1实际上的下标为0
int
rowStart
=
Integer
.
parseInt
(
coords
[
1
])
-
1
;
int
rowStart
=
Integer
.
parseInt
(
coords
[
1
])
-
1
;
final
Row
row
=
sheet
.
getRow
(
rowStart
);
final
Row
row
=
sheet
.
getRow
(
rowStart
);
for
(
Integer
column
:
columnList
)
{
for
(
Integer
column
:
columnList
)
{
try
{
final
Cell
cell
=
row
.
getCell
(
column
,
Row
.
MissingCellPolicy
.
RETURN_BLANK_AS_NULL
);
final
Cell
cell
=
row
.
getCell
(
column
,
Row
.
MissingCellPolicy
.
RETURN_BLANK_AS_NULL
);
final
String
cellValue
=
DiConfig
.
getValue
(
cell
);
vo
.
addValue
(
DiConfig
.
getValue
(
cell
));
if
(
StringUtils
.
containsIgnoreCase
(
vo
.
getFieldType
(),
"NUMBER"
))
{
}
catch
(
Exception
ignore
)
{
// i是整数位长度
int
i
=
cellValue
.
indexOf
(
"."
);
if
(
i
==
-
1
)
{
i
=
cellValue
.
length
();
}
int
k
=
cellValue
.
length
()
-
i
-
1
;
if
(
i
>
a
||
k
>
b
)
{
throw
new
BaseException
(
StrFormatter
.
format
(
"字段数据:[{}],字段类型:[{}],字段名称:[{}],数据精度异常,请修改数据元与数据库相对应字段信息"
,
cellValue
,
vo
.
getFieldType
(),
vo
.
getFieldName
(),
cellValue
));
}
}
else
if
(
StringUtils
.
containsIgnoreCase
(
vo
.
getFieldType
(),
"VARCHAR2"
))
{
if
(
l
<
cellValue
.
length
())
{
throw
new
BaseException
(
StrFormatter
.
format
(
"字段数据:[{}],字段类型:[{}],字段名称:[{}],数据长度不足,请修改数据元与数据库相对应字段信息"
,
cellValue
,
vo
.
getFieldType
(),
vo
.
getFieldName
(),
cellValue
));
}
}
}
vo
.
addValue
(
cellValue
);
}
}
}
}
log
.
info
(
"解析数据用时:[{}]"
,
System
.
currentTimeMillis
()
-
startTime
);
startTime
=
System
.
currentTimeMillis
();
// 直接导入临时表
// 直接导入临时表
String
insertSql
=
"INSERT INTO {}("
+
verifyList
.
stream
()
String
insertSql
=
"INSERT INTO {}("
+
verifyList
.
stream
()
.
map
(
VerifyVO:
:
getFieldName
).
collect
(
Collectors
.
joining
(
","
))
.
map
(
VerifyVO:
:
getFieldName
).
collect
(
Collectors
.
joining
(
","
))
...
@@ -512,9 +548,12 @@ public class ExcelDataServiceImpl extends ServiceImpl<ExcelDataMapper, ExcelData
...
@@ -512,9 +548,12 @@ public class ExcelDataServiceImpl extends ServiceImpl<ExcelDataMapper, ExcelData
// 需要先清空临时表的数据,按照年份
// 需要先清空临时表的数据,按照年份
jdbcTemplate
.
execute
(
StrFormatter
.
format
(
"DELETE FROM {} WHERE YEAROOFDATARECORD = '{}'"
jdbcTemplate
.
execute
(
StrFormatter
.
format
(
"DELETE FROM {} WHERE YEAROOFDATARECORD = '{}'"
,
template
.
getTableName
()
+
"_TEMP"
,
template
.
getYear
()
+
"年"
));
,
template
.
getTableName
()
+
"_TEMP"
,
template
.
getYear
()
+
"年"
));
jdbcTemplate
.
batchUpdate
(
sqlArr
);
jdbcTemplate
.
batchUpdate
(
sqlArr
);
}
catch
(
Exception
e
)
{
log
.
info
(
"导入数据用时:[{}]"
,
System
.
currentTimeMillis
()
-
startTime
);
throw
new
RuntimeException
(
e
);
}
catch
(
Throwable
e
)
{
log
.
error
(
"数据导入错误"
,
e
);
throw
new
BaseException
(
e
.
getCause
().
getMessage
());
}
finally
{
}
finally
{
DataSourceService
.
switchDefault
();
DataSourceService
.
switchDefault
();
}
}
...
...
admin-api/src/main/resources/application.yml
View file @
02c07e5e
...
@@ -46,7 +46,7 @@ spring:
...
@@ -46,7 +46,7 @@ spring:
# 国际化资源文件路径
# 国际化资源文件路径
basename
:
i18n/messages
basename
:
i18n/messages
profiles
:
profiles
:
active
:
druid
active
:
zyy
# 文件上传
# 文件上传
servlet
:
servlet
:
multipart
:
multipart
:
...
...
admin-api/src/main/resources/mapper/DataFieldMapper.xml
View file @
02c07e5e
...
@@ -40,6 +40,7 @@
...
@@ -40,6 +40,7 @@
and mf.field_name like concat('%', #{param.field}, '%')
and mf.field_name like concat('%', #{param.field}, '%')
</if>
</if>
</where>
</where>
order by df.sort
</select>
</select>
<select
id=
"listFieldMatchList"
resultType=
"com.tbyf.his.web.dataImport.entity.DataField"
>
<select
id=
"listFieldMatchList"
resultType=
"com.tbyf.his.web.dataImport.entity.DataField"
>
...
...
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