Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
data_management_system
Project
Project
Details
Activity
Releases
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
张伯涛
data_management_system
Commits
020e2116
Commit
020e2116
authored
Dec 02, 2022
by
秦嘉
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
核酸模块代码优化
parent
89edc54f
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
96 additions
and
56 deletions
+96
-56
HscjMapper.java
...tem/src/main/java/com/ruoyi/system/mapper/HscjMapper.java
+15
-8
HscjServiceImpl.java
...n/java/com/ruoyi/system/service/impl/HscjServiceImpl.java
+69
-48
HscjMapper.xml
ruoyi-system/src/main/resources/mapper/system/HscjMapper.xml
+12
-0
No files found.
ruoyi-system/src/main/java/com/ruoyi/system/mapper/HscjMapper.java
View file @
020e2116
...
...
@@ -2,6 +2,7 @@ package com.ruoyi.system.mapper;
import
java.util.List
;
import
com.ruoyi.system.domain.Hscj
;
import
org.apache.ibatis.annotations.Param
;
/**
* 核酸采集Mapper接口
...
...
@@ -60,4 +61,10 @@ public interface HscjMapper
public
int
deleteHscjByIds
(
Long
[]
ids
);
List
<
Hscj
>
checkCard
(
Hscj
hscj
);
List
<
Hscj
>
checkCardBatch
(
List
<
Hscj
>
hscjList
);
void
insertBatch
(
List
<
Hscj
>
insertList
);
void
updateBatch
(
List
<
Hscj
>
updateList
);
}
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/HscjServiceImpl.java
View file @
020e2116
...
...
@@ -65,7 +65,7 @@ public class HscjServiceImpl implements IHscjService {
@Override
public
int
insertHscj
(
Hscj
hscj
)
{
String
createBy
=
DataUtils
.
getValue
(
hscj
.
getArea
(),
hscj
.
getStreet
(),
hscj
.
getCommittee
());
if
(
createBy
.
equals
(
"null"
))
if
(
createBy
.
equals
(
"null"
))
throw
new
ServiceException
(
"所选居住地、街道、社区不存在"
);
if
(
CheckUtils
.
checkCard
(
hscj
.
getCardNo
()))
hscj
.
setCheckCard
(
"正确"
);
...
...
@@ -88,7 +88,7 @@ public class HscjServiceImpl implements IHscjService {
@Override
public
int
updateHscj
(
Hscj
hscj
)
{
String
createBy
=
DataUtils
.
getValue
(
hscj
.
getArea
(),
hscj
.
getStreet
(),
hscj
.
getCommittee
());
if
(
createBy
.
equals
(
"null"
))
if
(
createBy
.
equals
(
"null"
))
throw
new
ServiceException
(
"所选居住地、街道、社区不存在"
);
List
<
Hscj
>
list
=
hscjMapper
.
checkCard
(
hscj
);
if
(!
list
.
isEmpty
())
...
...
@@ -127,7 +127,6 @@ public class HscjServiceImpl implements IHscjService {
}
List
<
Hscj
>
trueList
=
new
ArrayList
<>();
List
<
Hscj
>
failureList
=
new
ArrayList
<>();
for
(
Hscj
hscj
:
list
)
{
if
(
StringUtils
.
isEmpty
(
hscj
.
getProvince
()))
{
hscj
.
setProvince
(
"河北省"
);
...
...
@@ -163,7 +162,7 @@ public class HscjServiceImpl implements IHscjService {
// continue;
// }
List
<
Hscj
>
hsctList
=
list
.
stream
().
filter
(
l
->
hscj
.
getCardNo
().
equals
(
l
.
getCardNo
())
&&
l
.
getCjTime
()!=
null
&&
hscj
.
getCardNo
().
equals
(
l
.
getCardNo
())
&&
l
.
getCjTime
()
!=
null
&&
DateUtils
.
dateTime
(
hscj
.
getCjTime
()).
equals
(
DateUtils
.
dateTime
(
l
.
getCjTime
())))
.
collect
(
Collectors
.
toList
());
if
(
hsctList
.
size
()
>
1
)
{
...
...
@@ -240,84 +239,106 @@ public class HscjServiceImpl implements IHscjService {
// continue;
// }
// }
String
community
=
""
;
String
committee
=
""
;
String
street
=
""
;
if
(
StringUtils
.
isNotEmpty
(
hscj
.
getCommunity
())){
//如果小区不为空,去数据字典匹配value
//如果小区不为空,去数据字典匹配value
if
(
StringUtils
.
isNotEmpty
(
hscj
.
getCommunity
()))
{
List
<
SysDictData
>
communitys
=
DictUtils
.
getDictCache
(
"community"
);
List
<
String
>
values
=
communitys
.
stream
().
filter
(
l
->
hscj
.
getCommunity
().
equals
(
l
.
getDictLabel
()))
List
<
String
>
values
=
communitys
.
stream
().
filter
(
l
->
hscj
.
getCommunity
().
equals
(
l
.
getDictLabel
()))
.
map
(
SysDictData:
:
getDictValue
).
collect
(
Collectors
.
toList
());
if
(!
values
.
isEmpty
())
community
=
values
.
get
(
0
);
hscj
.
setCommunity
(
values
.
get
(
0
)
);
else
{
failureList
.
add
(
hscj
);
continue
;
}
}
if
(
StringUtils
.
isNotEmpty
(
hscj
.
getCommittee
())){
//如果委员会不为空,去数据字典匹配value
//如果委员会不为空,去数据字典匹配value
if
(
StringUtils
.
isNotEmpty
(
hscj
.
getCommittee
()))
{
List
<
SysDictData
>
communitys
=
DictUtils
.
getDictCache
(
"committee"
);
List
<
String
>
values
=
communitys
.
stream
().
filter
(
l
->
hscj
.
getCommittee
().
equals
(
l
.
getDictLabel
()))
List
<
String
>
values
=
communitys
.
stream
().
filter
(
l
->
hscj
.
getCommittee
().
equals
(
l
.
getDictLabel
()))
.
map
(
SysDictData:
:
getDictValue
).
collect
(
Collectors
.
toList
());
if
(!
values
.
isEmpty
())
committee
=
values
.
get
(
0
);
hscj
.
setCommittee
(
values
.
get
(
0
)
);
else
{
failureList
.
add
(
hscj
);
continue
;
}
}
if
(
StringUtils
.
isNotEmpty
(
hscj
.
getStreet
())){
//如果街道不为空,去数据字典匹配value
//如果街道不为空,去数据字典匹配value
if
(
StringUtils
.
isNotEmpty
(
hscj
.
getStreet
()))
{
List
<
SysDictData
>
communitys
=
DictUtils
.
getDictCache
(
"street_town"
);
List
<
String
>
values
=
communitys
.
stream
().
filter
(
l
->
hscj
.
getStreet
().
equals
(
l
.
getDictLabel
()))
List
<
String
>
values
=
communitys
.
stream
().
filter
(
l
->
hscj
.
getStreet
().
equals
(
l
.
getDictLabel
()))
.
map
(
SysDictData:
:
getDictValue
).
collect
(
Collectors
.
toList
());
if
(!
values
.
isEmpty
())
street
=
values
.
get
(
0
);
hscj
.
setStreet
(
values
.
get
(
0
)
);
else
{
failureList
.
add
(
hscj
);
continue
;
}
}
if
((
StringUtils
.
isNotEmpty
(
community
)&&
StringUtils
.
isEmpty
(
committee
))||
(
StringUtils
.
isNotEmpty
(
committee
)&&
StringUtils
.
isEmpty
(
street
))){
if
(
StringUtils
.
isNotEmpty
(
hscj
.
getCommunity
())
&&
StringUtils
.
isEmpty
(
hscj
.
getCommittee
()))
{
failureList
.
add
(
hscj
);
continue
;
}
if
(
StringUtils
.
isNotEmpty
(
hscj
.
getCommittee
())
&&
StringUtils
.
isEmpty
(
hscj
.
getStreet
()))
{
failureList
.
add
(
hscj
);
continue
;
}
Hscj
hscjQuerry
=
new
Hscj
();
hscjQuerry
.
setCardNo
(
hscj
.
getCardNo
());
hscjQuerry
.
setCjTime
(
hscj
.
getCjTime
());
List
<
Hscj
>
hscjs
=
hscjMapper
.
checkCard
(
hscjQuerry
);
if
(!
hscjs
.
isEmpty
())
{
for
(
Hscj
hscjUpdate:
hscjs
){
hscj
.
setId
(
hscjUpdate
.
getId
());
hscj
.
setCommunity
(
community
);
hscj
.
setCommittee
(
committee
);
hscj
.
setStreet
(
street
);
hscjMapper
.
updateHscj
(
hscj
);
}
}
else
{
if
(
CheckUtils
.
checkCard
(
hscj
.
getCardNo
()))
{
hscj
.
setCheckCard
(
"正确"
);
hscj
.
setCommunity
(
community
);
hscj
.
setCommittee
(
committee
);
hscj
.
setStreet
(
street
);
trueList
.
add
(
hscj
);
}
else
{
hscj
.
setCheckCard
(
"不正确"
);
failureList
.
add
(
hscj
);
continue
;
}
}
}
else
{
failureList
.
add
(
hscj
);
}
}
if
(!
trueList
.
isEmpty
())
{
for
(
Hscj
hscj
:
trueList
)
{
String
createBy
=
DataUtils
.
getValue
(
hscj
.
getArea
(),
hscj
.
getStreet
(),
hscj
.
getCommittee
());
hscj
.
setCreateBy
(
createBy
);
hscj
.
setCreateTime
(
DateUtils
.
getNowDate
());
hscjMapper
.
insertHscj
(
hscj
);
// 因为数据量过大,所以将list拆分为每个数组100条的形式
List
<
Hscj
>
hscjList
=
new
ArrayList
<>();
int
listSize
=
trueList
.
size
();
int
count
=
listSize
/
100
;
for
(
int
i
=
0
;
i
<
count
;
i
++)
{
hscjList
=
trueList
.
subList
(
i
*
100
,(
i
+
1
)*
100
-
1
);
//1、从集合中获取到所有查询所需的条件,进行批量数据查询
List
<
Hscj
>
hscjs
=
hscjMapper
.
checkCardBatch
(
hscjList
);
//2、循环数据进行判断是否是新增还是更新
List
<
Hscj
>
updateList
=
new
ArrayList
<>();
List
<
Hscj
>
insertList
=
new
ArrayList
<>();
if
(!
hscjs
.
isEmpty
())
{
for
(
Hscj
hscj
:
hscjs
)
{
updateList
.
addAll
(
hscjList
.
stream
().
filter
(
l
->
hscj
.
getCardNo
().
equals
(
l
.
getCardNo
())).
collect
(
Collectors
.
toList
()));
insertList
.
addAll
(
hscjList
.
stream
().
filter
(
l
->
!(
hscj
.
getCardNo
().
equals
(
l
.
getCardNo
()))).
collect
(
Collectors
.
toList
()));
}
}
else
{
insertList
.
addAll
(
hscjList
);
}
//3、将数据分别写入到更新数据集合和插入数据集合中
//4、判断新增集合和插入集合是否有数据,如果有数据则执行SQL语句
if
(!
insertList
.
isEmpty
())
{
hscjMapper
.
insertBatch
(
insertList
);
}
if
(!
updateList
.
isEmpty
())
{
hscjMapper
.
updateBatch
(
updateList
);
}
}
//判断是否还有剩余?如果有甚于数据,则,则将剩余数据取出,按照上面循环体中的代码逻辑执行即可
if
(
listSize
%
100
!=
0
)
{
hscjList
=
trueList
.
subList
(
count
*
100
,
listSize
-
1
);
}
// List<Hscj> hscjs = hscjMapper.checkCard(hscj);
// if (!hscjs.isEmpty()) {
// hscjMapper.updateHscj(hscj);
// continue;
// }
// String createBy = DataUtils.getValue(hscj.getArea(), hscj.getStreet(), hscj.getCommittee());
// hscj.setCreateBy(createBy);
// hscj.setCreateTime(DateUtils.getNowDate());
// hscjMapper.insertHscj(hscj);
}
if
(!
failureList
.
isEmpty
())
{
ExcelUtil
<
Hscj
>
util
=
new
ExcelUtil
<
Hscj
>(
Hscj
.
class
);
util
.
exportExcel
(
response
,
failureList
,
"核算采集错误数据"
);
...
...
ruoyi-system/src/main/resources/mapper/system/HscjMapper.xml
View file @
020e2116
...
...
@@ -121,6 +121,16 @@
and date_format(cj_time,'%y%m%d') = date_format(#{cjTime},'%y%m%d')
<if
test=
"id != null"
>
and id != #{id}
</if>
</select>
<select
id=
"checkCardBatch"
resultType=
"com.ruoyi.system.domain.Hscj"
>
SELECT id, card_no
FROM hscj
WHERE del_flag ='0'
AND card_no IN
<foreach
collection=
"hscjList"
item=
"item"
index=
"index"
open=
"("
separator=
","
close=
")"
>
#{item.cardNo}
</foreach>
</select>
<insert
id=
"insertHscj"
parameterType=
"Hscj"
useGeneratedKeys=
"true"
keyProperty=
"id"
>
insert into hscj
...
...
@@ -193,6 +203,7 @@
<if
test=
"remark != null"
>
#{remark},
</if>
</trim>
</insert>
<insert
id=
"insertBatch"
></insert>
<update
id=
"updateHscj"
parameterType=
"Hscj"
>
update hscj
...
...
@@ -231,6 +242,7 @@
</trim>
where id = #{id}
</update>
<update
id=
"updateBatch"
></update>
<delete
id=
"deleteHscjById"
parameterType=
"Long"
>
delete
...
...
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