Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
eshiled-new
/
ne-shield-standard-interfaces
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
1
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit feb79afb
authored
Mar 01, 2022
by
levphon
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
工单标准接口-数据迁移
1 parent
dcb7bde5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
104 additions
and
34 deletions
src/main/java/cn/com/glsx/stdinterface/modules/mapper/VehicleMapper.java
src/main/java/cn/com/glsx/stdinterface/modules/model/ZhongliAccountModel.java
src/main/java/cn/com/glsx/stdinterface/modules/service/ZhongliVehicleService.java
src/main/resources/mapper/VehicleMapper.xml
src/main/resources/mapper/ZhongliAccountMapper.xml
src/main/java/cn/com/glsx/stdinterface/modules/mapper/VehicleMapper.java
View file @
feb79af
...
...
@@ -6,6 +6,7 @@ import com.glsx.plat.mybatis.mapper.CommonBaseMapper;
import
org.apache.ibatis.annotations.Mapper
;
import
org.apache.ibatis.annotations.Param
;
import
java.util.Collection
;
import
java.util.List
;
@Mapper
...
...
@@ -13,8 +14,12 @@ public interface VehicleMapper extends CommonBaseMapper<Vehicle> {
Vehicle
selectByWorkOrderId
(
@Param
(
"workOrderId"
)
Long
workOrderId
);
List
<
Vehicle
>
selectAllByNoNullRefVehicleId
();
List
<
Vehicle
>
selectAllByNotNullRefVehicleId
();
List
<
Vehicle
>
selectByNullCreateBy
();
Vehicle
selectByRefVehicleId
(
@Param
(
"refVehicleId"
)
Long
refVehicleId
);
int
updateCreateByByRefVehicleIds
(
@Param
(
"userId"
)
Long
userId
,
@Param
(
"refVehicleIds"
)
Collection
<
Long
>
refVehicleIds
);
}
\ No newline at end of file
src/main/java/cn/com/glsx/stdinterface/modules/model/ZhongliAccountModel.java
View file @
feb79af
...
...
@@ -6,6 +6,7 @@ import lombok.Data;
public
class
ZhongliAccountModel
{
private
String
level
;
private
Long
userId
;
//新系统id
private
String
account
;
private
String
username
;
private
String
department
;
...
...
src/main/java/cn/com/glsx/stdinterface/modules/service/ZhongliVehicleService.java
View file @
feb79af
...
...
@@ -39,7 +39,11 @@ public class ZhongliVehicleService {
public
void
linkVehicle2Account
()
{
List
<
ZhongliAccountModel
>
accountModelList
=
zhongliAccountMapper
.
selectByLevel
(
null
);
Map
<
String
,
List
<
ZhongliAccountModel
>>
accountMapByRoleName
=
accountModelList
.
stream
().
collect
(
Collectors
.
groupingBy
(
ZhongliAccountModel:
:
getRoleName
));
Map
<
String
,
ZhongliAccountModel
>
accountMap
=
accountModelList
.
stream
().
collect
(
Collectors
.
toMap
(
ZhongliAccountModel:
:
getAccount
,
v
->
v
));
Map
<
String
,
List
<
ZhongliAccountModel
>>
accountMapByRoleName
=
accountModelList
.
stream
()
.
filter
(
zam
->
zam
.
getRoleName
().
equals
(
"仲利法务"
)
||
zam
.
getRoleName
().
equals
(
"仲利收车"
))
.
collect
(
Collectors
.
groupingBy
(
ZhongliAccountModel:
:
getRoleName
));
Map
<
String
,
List
<
ZhongliAccountModel
>>
accountMapByLevel
=
accountModelList
.
stream
()
.
filter
(
zam
->
!
zam
.
getRoleName
().
equals
(
"仲利法务"
)
&&
!
zam
.
getRoleName
().
equals
(
"仲利收车"
))
...
...
@@ -47,46 +51,87 @@ public class ZhongliVehicleService {
.
collect
(
Collectors
.
groupingBy
(
ZhongliAccountModel:
:
getLevel
));
//全部同步车辆
List
<
Vehicle
>
vehicleList
=
vehicleMapper
.
selectAllByNoNullRefVehicleId
();
List
<
Vehicle
>
vehicleList
=
vehicleMapper
.
selectAllByNo
t
NullRefVehicleId
();
Map
<
Long
,
Vehicle
>
vehicleMap
=
vehicleList
.
stream
().
collect
(
Collectors
.
toMap
(
Vehicle:
:
getRefVehicleId
,
v
->
v
));
log
.
info
(
"绝对授权方式"
);
accountMapByRoleName
.
forEach
((
k
,
v
)
->
{
v
.
forEach
(
account
->
{
ZhongliAccountModel
zlgj
=
accountMap
.
get
(
"zlgj"
);
log
.
info
(
"绝对授权方式==============================================="
);
accountMapByRoleName
.
forEach
((
k
,
v
)
->
v
.
forEach
(
account
->
{
List
<
ZhongliVehicle
>
zhongliVehicleList
=
zhongliVehicleMapper
.
selectByAccount
(
account
.
getAccount
());
log
.
info
(
"账号{}(角色为:{})的车辆数:{}"
,
account
.
getAccount
(),
k
,
zhongliVehicleList
.
size
());
List
<
VehiclePermit
>
permitList
=
Lists
.
newArrayList
();
zhongliVehicleList
.
forEach
(
zv
->
{
Vehicle
vehicle
=
vehicleMap
.
get
(
zv
.
getVehicleId
());
if
(
vehicle
==
null
)
{
return
;
}
VehiclePermit
vp
=
new
VehiclePermit
();
vp
.
setContentId
(
vehicle
.
getId
());
vp
.
setAccorderId
(
zlgj
.
getUserId
());
vp
.
setReceiverId
(
account
.
getUserId
());
vp
.
setContentType
(
0
);
vp
.
setPermitType
(
1
);
vp
.
setCreatedDate
(
new
Date
());
permitList
.
add
(
vp
);
});
if
(
CollectionUtils
.
isNotEmpty
(
permitList
))
{
vehiclePermitMapper
.
insertList
(
permitList
);
}
}));
log
.
info
(
"相对授权方式================================================="
);
List
<
ZhongliAccountModel
>
accountModels1
=
accountMapByLevel
.
get
(
"一级"
);
if
(
CollectionUtils
.
isNotEmpty
(
accountModels1
))
{
accountModels1
.
forEach
(
account
->
{
List
<
ZhongliVehicle
>
zhongliVehicleList
=
zhongliVehicleMapper
.
selectByAccount
(
account
.
getAccount
());
log
.
info
(
"账号{}(角色为:{})的车辆数:{}"
,
account
.
getAccount
(),
k
,
zhongliVehicleList
.
size
());
if
(
k
.
equals
(
"仲利法务"
)
||
k
.
equals
(
"仲利收车"
))
{
List
<
VehiclePermit
>
permitList
=
Lists
.
newArrayList
();
zhongliVehicleList
.
forEach
(
zv
->
{
Vehicle
vehicle
=
vehicleMap
.
get
(
zv
.
getVehicleId
());
if
(
vehicle
==
null
)
{
return
;
}
VehiclePermit
vp
=
new
VehiclePermit
();
vp
.
setContentId
(
vehicle
.
getId
());
vp
.
setAccorderId
(
0L
);
vp
.
setReceiverId
(
1L
);
vp
.
setContentType
(
0
);
vp
.
setPermitType
(
1
);
vp
.
setCreatedDate
(
new
Date
());
permitList
.
add
(
vp
);
});
if
(
CollectionUtils
.
isNotEmpty
(
permitList
))
{
//vehiclePermitMapper.insertList(permitList);
}
log
.
info
(
"一级账号{}的车辆数:{}"
,
account
.
getAccount
(),
zhongliVehicleList
.
size
());
List
<
Long
>
vehicleIds
=
Lists
.
newArrayList
();
zhongliVehicleList
.
forEach
(
zv
->
vehicleIds
.
add
(
zv
.
getVehicleId
()));
if
(
CollectionUtils
.
isNotEmpty
(
vehicleIds
))
{
vehicleMapper
.
updateCreateByByRefVehicleIds
(
account
.
getUserId
(),
vehicleIds
);
}
});
}
);
}
log
.
info
(
"相对授权方式
"
);
accountMapByLevel
.
forEach
((
k
,
v
)
->
{
v
.
forEach
(
account
->
{
List
<
ZhongliAccountModel
>
accountModels2
=
accountMapByLevel
.
get
(
"二级
"
);
if
(
CollectionUtils
.
isNotEmpty
(
accountModels2
))
{
accountModels2
.
forEach
(
account
->
{
List
<
ZhongliVehicle
>
zhongliVehicleList
=
zhongliVehicleMapper
.
selectByAccount
(
account
.
getAccount
());
log
.
info
(
"
{}账号{}(角色为:{})的车辆数:{}"
,
k
,
account
.
getAccount
(),
k
,
zhongliVehicleList
.
size
());
log
.
info
(
"
二级账号{}的车辆数:{}"
,
account
.
getAccount
()
,
zhongliVehicleList
.
size
());
List
<
Long
>
vehicleIds
=
Lists
.
newArrayList
();
zhongliVehicleList
.
forEach
(
zv
->
vehicleIds
.
add
(
zv
.
getVehicleId
()));
if
(
CollectionUtils
.
isNotEmpty
(
vehicleIds
))
{
vehicleMapper
.
updateCreateByByRefVehicleIds
(
account
.
getUserId
(),
vehicleIds
);
}
});
}
);
}
List
<
ZhongliAccountModel
>
accountModels3
=
accountMapByLevel
.
get
(
"三级"
);
if
(
CollectionUtils
.
isNotEmpty
(
accountModels3
))
{
accountModels3
.
forEach
(
account
->
{
List
<
ZhongliVehicle
>
zhongliVehicleList
=
zhongliVehicleMapper
.
selectByAccount
(
account
.
getAccount
());
log
.
info
(
"三级账号{}的车辆数:{}"
,
account
.
getAccount
(),
zhongliVehicleList
.
size
());
List
<
Long
>
vehicleIds
=
Lists
.
newArrayList
();
zhongliVehicleList
.
forEach
(
zv
->
vehicleIds
.
add
(
zv
.
getVehicleId
()));
if
(
CollectionUtils
.
isNotEmpty
(
vehicleIds
))
{
vehicleMapper
.
updateCreateByByRefVehicleIds
(
account
.
getUserId
(),
vehicleIds
);
}
});
}
//最后还没有创建人的直接丢到仲利国际上面
List
<
Vehicle
>
noCreateByVehicles
=
vehicleMapper
.
selectByNullCreateBy
();
if
(
CollectionUtils
.
isNotEmpty
(
noCreateByVehicles
))
{
List
<
Long
>
vehicleIds
=
Lists
.
newArrayList
();
noCreateByVehicles
.
forEach
(
vehicle
->
vehicleIds
.
add
(
vehicle
.
getRefVehicleId
()));
if
(
CollectionUtils
.
isNotEmpty
(
vehicleIds
))
{
vehicleMapper
.
updateCreateByByRefVehicleIds
(
zlgj
.
getUserId
(),
vehicleIds
);
}
}
}
}
src/main/resources/mapper/VehicleMapper.xml
View file @
feb79af
...
...
@@ -72,7 +72,7 @@
and workorder_id = #{workOrderId}
</select>
<select
id=
"selectAllByNoNullRefVehicleId"
resultMap=
"BaseResultMap"
>
<select
id=
"selectAllByNo
t
NullRefVehicleId"
resultMap=
"BaseResultMap"
>
select
<include
refid=
"Base_Column_List"
/>
from t_vehicle
...
...
@@ -88,4 +88,23 @@
and ref_vehicle_id = #{refVehicleId}
limit 1
</select>
<select
id=
"selectByNullCreateBy"
resultMap=
"BaseResultMap"
>
select
<include
refid=
"Base_Column_List"
/>
from t_vehicle
where del_flag = 0
and ref_vehicle_id is not null
and created_by is null
</select>
<update
id=
"updateCreateByByRefVehicleIds"
>
update t_vehicle
set created_by = #{userId}
where ref_vehicle_id is not null
and ref_vehicle_id in
<foreach
collection=
"refVehicleIds"
open=
"("
close=
")"
separator=
","
item=
"item"
>
#{item}
</foreach>
</update>
</mapper>
\ No newline at end of file
src/main/resources/mapper/ZhongliAccountMapper.xml
View file @
feb79af
...
...
@@ -30,7 +30,7 @@
</sql>
<select
id=
"selectByLevel"
resultType=
"cn.com.glsx.stdinterface.modules.model.ZhongliAccountModel"
>
select `level`, account, username, department, role_name roleName
select `level`,
created_by userId,
account, username, department, role_name roleName
from t_zhongli_account
where del_flag = 0
<if
test=
"level != null and level != ''"
>
...
...
Write
Preview
Markdown
is supported
Attach a file
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 post a comment