Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
eshiled-new
/
ne-shield-trialdrive-admin
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 09dad5a8
authored
Sep 13, 2021
by
刘宇峰
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
新增车辆-车型管理-优化
1 parent
3e46f85d
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
55 additions
and
38 deletions
src/main/java/cn/com/glsx/admin/modules/service/VehicleService.java
src/test/java/cn/com/glsx/admin/modules/service/VehicleServiceTest.java
src/main/java/cn/com/glsx/admin/modules/service/VehicleService.java
View file @
09dad5a
...
...
@@ -49,6 +49,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.cache.annotation.Cacheable
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.util.StopWatch
;
import
java.io.FileNotFoundException
;
import
java.io.InputStream
;
...
...
@@ -146,6 +147,40 @@ public class VehicleService {
return
selected
;
}
private
static
String
transWeekFrequency
(
String
week
,
String
weekTimer
)
{
StringBuilder
sb
=
new
StringBuilder
(
weekTimer
+
"/星期"
);
for
(
int
i
=
0
;
i
<
week
.
length
();
i
++)
{
char
c
=
week
.
charAt
(
i
);
switch
(
c
)
{
case
'1'
:
sb
.
append
(
"一、"
);
break
;
case
'2'
:
sb
.
append
(
"二、"
);
break
;
case
'3'
:
sb
.
append
(
"三、"
);
break
;
case
'4'
:
sb
.
append
(
"四、"
);
break
;
case
'5'
:
sb
.
append
(
"五、"
);
break
;
case
'6'
:
sb
.
append
(
"六、"
);
break
;
case
'7'
:
sb
.
append
(
"七、"
);
break
;
default
:
break
;
}
}
String
str
=
sb
.
toString
();
return
str
.
substring
(
0
,
str
.
length
()
-
1
);
}
public
PageInfo
<
TrialDriveVehiclePageDTO
>
searchTrialDrive
(
VehicleManageSearch
search
)
{
PageHelper
.
startPage
(
search
.
getPageNumber
(),
search
.
getPageSize
());
List
<
TrialDriveVehiclePageDTO
>
listDriveVehicle
=
vehicleMapper
.
searchTrialDrive
(
search
);
...
...
@@ -826,7 +861,7 @@ public class VehicleService {
}
@Cacheable
(
value
=
"carbrand"
,
key
=
"#brandId"
)
public
Carbrand
getByBrandId
(
Integer
brandId
)
{
public
Carbrand
getBy
Parent
BrandId
(
Integer
brandId
)
{
return
carbrandService
.
getParentBrandByBrandId
(
brandId
);
}
...
...
@@ -836,22 +871,32 @@ public class VehicleService {
}
public
void
saveVehicleTypes
(
VehicleTypesBO
typesBO
,
Long
userId
)
{
StopWatch
sw
=
new
StopWatch
();
Date
now
=
new
Date
();
List
<
Carbrand
>
carBrandList
=
this
.
getAllBrandList
();
Map
<
Integer
,
Carbrand
>
carBrandMap
=
carBrandList
.
stream
().
collect
(
Collectors
.
toMap
(
Carbrand:
:
getBid
,
pd
->
pd
));
List
<
TenantVehicleType
>
tvTypeList
=
Lists
.
newArrayListWithCapacity
(
typesBO
.
getTypeIds
().
size
());
sw
.
start
(
"task1"
);
log
.
info
(
"本次处理 {} 车型{}条"
,
typesBO
.
getTenantName
(),
typesBO
.
getTypeIds
().
size
());
typesBO
.
getTypeIds
().
forEach
(
tId
->
{
Cartype
carType
=
this
.
getByTypeId
(
tId
);
if
(
carType
!=
null
)
{
Carbrand
carBrand
=
this
.
getByBrandId
(
carType
.
getCarBrandId
());
//
Carbrand carBrand = this.getByBrandId(carType.getCarBrandId());
TenantVehicleType
tvType
=
new
TenantVehicleType
();
tvType
.
setTenantId
(
typesBO
.
getTenantId
());
tvType
.
setTenantName
(
typesBO
.
getTenantName
());
tvType
.
setName
(
typesBO
.
getName
());
tvType
.
setBrandId
(
carType
.
getCarBrandPId
());
Carbrand
carBrand
=
carBrandMap
.
get
(
carType
.
getCarBrandPId
());
if
(
carBrand
!=
null
)
{
tvType
.
setBrandId
(
carBrand
.
getBid
());
tvType
.
setBrandName
(
carBrand
.
getBrand
());
}
tvType
.
setSubBrandId
(
carType
.
getCarBrandId
());
...
...
@@ -866,10 +911,16 @@ public class VehicleService {
tvTypeList
.
add
(
tvType
);
}
});
sw
.
stop
();
log
.
info
(
"{} 耗时:{} s"
,
sw
.
getLastTaskName
(),
sw
.
getLastTaskTimeMillis
());
//redisUtils.set("TenantVehicleType" + typesBO.getTenantId(), tvTypeList);
sw
.
start
(
"task2"
);
syncData2Db
(
typesBO
.
getTenantId
(),
tvTypeList
);
sw
.
stop
();
log
.
info
(
sw
.
prettyPrint
());
log
.
info
(
"总耗时:{} s"
,
sw
.
getTotalTimeSeconds
());
}
//@Async
...
...
@@ -1453,40 +1504,6 @@ public class VehicleService {
return
list
;
}
private
static
String
transWeekFrequency
(
String
week
,
String
weekTimer
)
{
StringBuilder
sb
=
new
StringBuilder
(
weekTimer
+
"/星期"
);
for
(
int
i
=
0
;
i
<
week
.
length
();
i
++)
{
char
c
=
week
.
charAt
(
i
);
switch
(
c
)
{
case
'1'
:
sb
.
append
(
"一、"
);
break
;
case
'2'
:
sb
.
append
(
"二、"
);
break
;
case
'3'
:
sb
.
append
(
"三、"
);
break
;
case
'4'
:
sb
.
append
(
"四、"
);
break
;
case
'5'
:
sb
.
append
(
"五、"
);
break
;
case
'6'
:
sb
.
append
(
"六、"
);
break
;
case
'7'
:
sb
.
append
(
"七、"
);
break
;
default
:
break
;
}
}
String
str
=
sb
.
toString
();
return
str
.
substring
(
0
,
str
.
length
()
-
1
);
}
/**
* 删除车辆信息
*
...
...
src/test/java/cn/com/glsx/admin/modules/service/VehicleServiceTest.java
View file @
09dad5a
This diff is collapsed.
Click to expand it.
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