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 d74fd8be
authored
Apr 16, 2022
by
向延琳
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
增加最大限制
1 parent
07d49356
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
107 additions
and
7 deletions
src/main/java/cn/com/glsx/admin/common/constants/Constants.java
src/main/java/cn/com/glsx/admin/modules/controller/JourneyController.java
src/main/java/cn/com/glsx/admin/modules/mapper/VehicleMapper.java
src/main/java/cn/com/glsx/admin/modules/service/JourneyService.java
src/main/resources/mapper/VehicleMapper.xml
src/main/java/cn/com/glsx/admin/common/constants/Constants.java
View file @
d74fd8b
...
@@ -131,4 +131,9 @@ public final class Constants {
...
@@ -131,4 +131,9 @@ public final class Constants {
* 包活干返回成功码
* 包活干返回成功码
*/
*/
public
static
final
int
BHG_RET_CODE_SUCCESS
=
200
;
public
static
final
int
BHG_RET_CODE_SUCCESS
=
200
;
/**
* 导出最大限制
*/
public
static
final
int
MAX_EXPORT_LIMIT
=
10000
;
}
}
src/main/java/cn/com/glsx/admin/modules/controller/JourneyController.java
View file @
d74fd8b
package
cn
.
com
.
glsx
.
admin
.
modules
.
controller
;
package
cn
.
com
.
glsx
.
admin
.
modules
.
controller
;
import
cn.com.glsx.admin.common.constants.Constants
;
import
cn.com.glsx.admin.common.exception.AdminException
;
import
cn.com.glsx.admin.modules.model.export.JourneyDetailExport
;
import
cn.com.glsx.admin.modules.model.export.JourneyDetailExport
;
import
cn.com.glsx.admin.modules.model.export.JourneyExport
;
import
cn.com.glsx.admin.modules.model.export.JourneyExport
;
import
cn.com.glsx.admin.modules.model.param.JourneyDailySearch
;
import
cn.com.glsx.admin.modules.model.param.JourneyDailySearch
;
...
@@ -48,8 +50,6 @@ public class JourneyController {
...
@@ -48,8 +50,6 @@ public class JourneyController {
/**
/**
* 查询通用里程列表
* 查询通用里程列表
*
*
* @param journeySearch
* @return
*/
*/
@GetMapping
(
"/search"
)
@GetMapping
(
"/search"
)
@ApiOperation
(
value
=
"查询通用里程列表"
)
@ApiOperation
(
value
=
"查询通用里程列表"
)
...
@@ -62,18 +62,30 @@ public class JourneyController {
...
@@ -62,18 +62,30 @@ public class JourneyController {
/**
/**
* 导出通用里程报表
* 导出通用里程报表
*
*
* @param journeySearch
* @return
*/
*/
@GetMapping
(
"/export"
)
@GetMapping
(
"/export"
)
@ApiOperation
(
value
=
"导出通用里程报表"
)
@ApiOperation
(
value
=
"导出通用里程报表"
)
public
R
<
String
>
exportJourneyList
(
JourneySearch
journeySearch
)
{
public
R
<
String
>
exportJourneyList
(
JourneySearch
journeySearch
)
{
// 限制
long
t1
=
System
.
currentTimeMillis
();
Integer
total
=
journeyService
.
countJourneyList
(
journeySearch
);
if
(
total
>
Constants
.
MAX_EXPORT_LIMIT
)
{
throw
new
AdminException
(
"数据过大不能导出,请筛选数据,控制在 1万 条以下; 当前数据量"
+
total
+
" 条"
);
}
log
.
info
(
"导出数量{}"
,
total
);
String
fileName
=
FdfsUtils
.
getFileName
(
"通用里程报表"
);
String
fileName
=
FdfsUtils
.
getFileName
(
"通用里程报表"
);
List
<
JourneyExport
>
journeyList
=
journeyService
.
findJourneyList
(
journeySearch
);
List
<
JourneyExport
>
journeyList
=
journeyService
.
findJourneyList
(
journeySearch
);
long
t2
=
System
.
currentTimeMillis
();
log
.
info
(
"数据查询耗时{}"
,
t2
-
t1
);
// 将文件写入内存流 然后上传到文件服务器 返回文件服务器的地址给前端 前端执行下载
// 将文件写入内存流 然后上传到文件服务器 返回文件服务器的地址给前端 前端执行下载
ByteArrayOutputStream
outputStream
=
new
ByteArrayOutputStream
();
ByteArrayOutputStream
outputStream
=
new
ByteArrayOutputStream
();
EasyExcelUtils
.
writeExcel
(
outputStream
,
journeyList
,
fileName
,
JourneyExport
.
class
);
EasyExcelUtils
.
writeExcel
(
outputStream
,
journeyList
,
fileName
,
JourneyExport
.
class
);
FileUploadServerData
uploadServerData
=
FileUploadUtil
.
uploadToFileSystem
(
fileName
,
outputStream
.
toByteArray
(),
FileConstants
.
EXCEL_TYPE_XLSX
);
FileUploadServerData
uploadServerData
=
FileUploadUtil
.
uploadToFileSystem
(
fileName
,
outputStream
.
toByteArray
(),
FileConstants
.
EXCEL_TYPE_XLSX
);
long
t3
=
System
.
currentTimeMillis
();
log
.
info
(
"上传uploadToFileSystem耗时{}"
,
t3
-
t2
);
log
.
info
(
"总耗时{}"
,
t3
-
t1
);
return
R
.
ok
().
data
(
uploadServerData
.
getSecureUrl
());
return
R
.
ok
().
data
(
uploadServerData
.
getSecureUrl
());
}
}
...
@@ -102,6 +114,12 @@ public class JourneyController {
...
@@ -102,6 +114,12 @@ public class JourneyController {
@ApiOperation
(
value
=
"导出通用里程详情报表"
)
@ApiOperation
(
value
=
"导出通用里程详情报表"
)
public
R
<
String
>
exportJourneyDetailList
(
JourneyDetailSearch
journeyDetailSearch
)
{
public
R
<
String
>
exportJourneyDetailList
(
JourneyDetailSearch
journeyDetailSearch
)
{
checkQueryParams
(
journeyDetailSearch
);
checkQueryParams
(
journeyDetailSearch
);
//限制
Integer
total
=
journeyService
.
countJourneyDetailList
(
journeyDetailSearch
);
if
(
total
>
Constants
.
MAX_EXPORT_LIMIT
)
{
throw
new
AdminException
(
"数据过大不能导出,请筛选数据,控制在 1万 条以下; 当前数据量"
+
total
+
" 条"
);
}
log
.
info
(
"导出数量{}"
,
total
);
String
fileName
=
FdfsUtils
.
getFileName
(
"单设备里程报表"
);
String
fileName
=
FdfsUtils
.
getFileName
(
"单设备里程报表"
);
List
<
JourneyDetailExport
>
journeyList
=
journeyService
.
findJourneyDetailList
(
journeyDetailSearch
);
List
<
JourneyDetailExport
>
journeyList
=
journeyService
.
findJourneyDetailList
(
journeyDetailSearch
);
// 将文件写入内存流 然后上传到文件服务器 返回文件服务器的地址给前端 前端执行下载
// 将文件写入内存流 然后上传到文件服务器 返回文件服务器的地址给前端 前端执行下载
...
...
src/main/java/cn/com/glsx/admin/modules/mapper/VehicleMapper.java
View file @
d74fd8b
...
@@ -177,6 +177,15 @@ public interface VehicleMapper extends CommonBaseMapper<Vehicle> {
...
@@ -177,6 +177,15 @@ public interface VehicleMapper extends CommonBaseMapper<Vehicle> {
List
<
JourneyExport
>
findJourneyList
(
JourneySearch
journeySearch
);
List
<
JourneyExport
>
findJourneyList
(
JourneySearch
journeySearch
);
/**
/**
* 根据权限获取该账户下 所有设备里程基础信息集合数量
* @param journeySearch 查询条件
* @return 数量
*/
@DataPerm
(
showSql
=
true
)
@DataPermShare
(
showSql
=
true
)
Integer
countJourneyList
(
JourneySearch
journeySearch
);
/**
* 根据权限获取该账户下 所有设备离线信息集合
* 根据权限获取该账户下 所有设备离线信息集合
*
*
* @param offlineSearch
* @param offlineSearch
...
@@ -206,6 +215,14 @@ public interface VehicleMapper extends CommonBaseMapper<Vehicle> {
...
@@ -206,6 +215,14 @@ public interface VehicleMapper extends CommonBaseMapper<Vehicle> {
List
<
JourneyDetailExport
>
findJourneyDetailList
(
JourneyDetailSearch
journeyDetailSearch
);
List
<
JourneyDetailExport
>
findJourneyDetailList
(
JourneyDetailSearch
journeyDetailSearch
);
/**
/**
* 根据权限获取该账户下 获取所有设备数据详细里程基本信息 数量
* @param journeyDetailSearch 查询条件
* @return 数量
*/
@DataPerm
(
showSql
=
true
)
Integer
countJourneyDetailList
(
JourneyDetailSearch
journeyDetailSearch
);
/**
* 根据权限获取该账户下 获取设备激活数据
* 根据权限获取该账户下 获取设备激活数据
*
*
* @param appendSql 拼接SQl
* @param appendSql 拼接SQl
...
...
src/main/java/cn/com/glsx/admin/modules/service/JourneyService.java
View file @
d74fd8b
...
@@ -68,6 +68,17 @@ public class JourneyService {
...
@@ -68,6 +68,17 @@ public class JourneyService {
}
}
/**
/**
* 统计列表数量
*/
public
Integer
countJourneyList
(
JourneySearch
search
)
{
if
(
search
.
getOrgId
()
!=
null
)
{
search
.
setCheckedOrgIds
(
Lists
.
newArrayList
(
search
.
getOrgId
()));
userApiService
.
setCheckedOrgUsers
(
search
);
}
return
vehicleMapper
.
countJourneyList
(
search
);
}
/**
* 里程单位转换
* 里程单位转换
*/
*/
private
JourneyExport
convertKm
(
JourneyExport
journey
)
{
private
JourneyExport
convertKm
(
JourneyExport
journey
)
{
...
@@ -111,17 +122,23 @@ public class JourneyService {
...
@@ -111,17 +122,23 @@ public class JourneyService {
* @return
* @return
*/
*/
public
List
<
JourneyDetailExport
>
findJourneyDetailList
(
JourneyDetailSearch
journeyDetailSearch
)
{
public
List
<
JourneyDetailExport
>
findJourneyDetailList
(
JourneyDetailSearch
journeyDetailSearch
)
{
// List<JourneyDetailExport> journeyDetailList = Lists.newArrayList();
if
(
journeyDetailSearch
.
getOrgId
()
!=
null
)
{
if
(
journeyDetailSearch
.
getOrgId
()
!=
null
)
{
journeyDetailSearch
.
setCheckedOrgIds
(
Lists
.
newArrayList
(
journeyDetailSearch
.
getOrgId
()));
journeyDetailSearch
.
setCheckedOrgIds
(
Lists
.
newArrayList
(
journeyDetailSearch
.
getOrgId
()));
userApiService
.
setCheckedOrgUsers
(
journeyDetailSearch
);
userApiService
.
setCheckedOrgUsers
(
journeyDetailSearch
);
}
}
List
<
JourneyDetailExport
>
journeyDetailExportList
=
vehicleMapper
.
findJourneyDetailList
(
journeyDetailSearch
);
List
<
JourneyDetailExport
>
journeyDetailExportList
=
vehicleMapper
.
findJourneyDetailList
(
journeyDetailSearch
);
log
.
info
(
"journeyDetailExportList size()大小==="
+
journeyDetailExportList
.
size
());
log
.
info
(
"journeyDetailExportList size()大小==="
+
journeyDetailExportList
.
size
());
//getDeviceDetailMileage(journeyDetailList, journeyDetailExportList, journeyDetailSearch);
return
journeyDetailExportList
;
return
journeyDetailExportList
;
}
}
public
Integer
countJourneyDetailList
(
JourneyDetailSearch
journeyDetailSearch
)
{
if
(
journeyDetailSearch
.
getOrgId
()
!=
null
)
{
journeyDetailSearch
.
setCheckedOrgIds
(
Lists
.
newArrayList
(
journeyDetailSearch
.
getOrgId
()));
userApiService
.
setCheckedOrgUsers
(
journeyDetailSearch
);
}
return
vehicleMapper
.
countJourneyDetailList
(
journeyDetailSearch
);
}
private
void
getDeviceDetailMileage
(
List
<
JourneyDetailExport
>
dataList
,
List
<
JourneyDetailExport
>
journeyDetailList
,
JourneyDetailSearch
journeyDetailSearch
)
{
private
void
getDeviceDetailMileage
(
List
<
JourneyDetailExport
>
dataList
,
List
<
JourneyDetailExport
>
journeyDetailList
,
JourneyDetailSearch
journeyDetailSearch
)
{
log
.
info
(
"###get device detail mileage start###"
);
log
.
info
(
"###get device detail mileage start###"
);
if
(
CollectionUtils
.
isEmpty
(
journeyDetailList
))
{
if
(
CollectionUtils
.
isEmpty
(
journeyDetailList
))
{
...
@@ -161,7 +178,6 @@ public class JourneyService {
...
@@ -161,7 +178,6 @@ public class JourneyService {
oneData
.
add
(
journeyDailyExport
.
getSn
());
oneData
.
add
(
journeyDailyExport
.
getSn
());
oneData
.
add
(
journeyDailyExport
.
getVin
());
oneData
.
add
(
journeyDailyExport
.
getVin
());
Map
<
String
,
DeviceJourneyDailyDTO
>
journeyDailyMap
=
dailyJourneyRecordsMap
.
get
(
journeyDailyExport
.
getSn
());
Map
<
String
,
DeviceJourneyDailyDTO
>
journeyDailyMap
=
dailyJourneyRecordsMap
.
get
(
journeyDailyExport
.
getSn
());
//remoteMileageTotalService.getDailyJourneyRecords(journeyDailyExport.getSn(), search.getJourneyStartTime(), search.getJourneyEndTime());
// 按照日期顺序封装每天的数据
// 按照日期顺序封装每天的数据
for
(
String
dateTime
:
collectDateList
)
{
for
(
String
dateTime
:
collectDateList
)
{
if
(
journeyDailyMap
==
null
||
journeyDailyMap
.
isEmpty
()
||
Objects
.
isNull
(
journeyDailyMap
.
get
(
dateTime
)))
{
if
(
journeyDailyMap
==
null
||
journeyDailyMap
.
isEmpty
()
||
Objects
.
isNull
(
journeyDailyMap
.
get
(
dateTime
)))
{
...
...
src/main/resources/mapper/VehicleMapper.xml
View file @
d74fd8b
...
@@ -804,6 +804,31 @@
...
@@ -804,6 +804,31 @@
order by tvd.id desc
order by tvd.id desc
</select>
</select>
<select
id=
"countJourneyList"
resultType=
"java.lang.Integer"
>
select count(1)
from t_vehicle tv
left join t_vehicle_device tvd on tvd.vehicle_id = tv.id
left join t_device_journey_overview tdjo on tvd.id = tdjo.vd_id
left join t_device td on td.sn = tvd.sn
left join t_workorder tw on tw.id = tv.workorder_id and tw.del_flag = 0
where tv.del_flag = 0
and tvd.bind_status = 1
and tvd.del_flag = 0
and td.source = 1
<if
test=
"checkedUserIdsStr != null and checkedUserIdsStr !=''"
>
and find_in_set(tv.created_by,#{checkedUserIdsStr})
</if>
<if
test=
"keywords != null and keywords !=''"
>
and(
tw.partner_order_no like '%${keywords}%'
or tv.vin like '%${keywords}%'
or tv.owner_name like '%${keywords}%'
or tvd.sn like '%${keywords}%'
)
</if>
order by tvd.id desc
</select>
<select
id=
"findOfflineList"
resultType=
"cn.com.glsx.admin.modules.model.export.OfflineExport"
>
<select
id=
"findOfflineList"
resultType=
"cn.com.glsx.admin.modules.model.export.OfflineExport"
>
select tvd.id, tw.partner_order_no as workOrderNo,
select tvd.id, tw.partner_order_no as workOrderNo,
tv.owner_name as ownerName,
tv.owner_name as ownerName,
...
@@ -912,6 +937,25 @@
...
@@ -912,6 +937,25 @@
order by tvd.id desc
order by tvd.id desc
</select>
</select>
<select
id=
"countJourneyDetailList"
resultType=
"java.lang.Integer"
>
select count(1)
left join t_vehicle_device tvd on tvd.id = tdj.vd_id
left join t_vehicle tv on tvd.id = tvd.vehicle_id
left join t_device td on td.sn = tvd.sn
left join t_workorder tw on tw.id = tv.workorder_id and tw.del_flag = 0
where tv.del_flag = 0
and tvd.bind_status = 1
and tvd.del_flag = 0
and td.source = 1
<if
test=
"checkedUserIdsStr != null and checkedUserIdsStr !=''"
>
and find_in_set(tv.created_by,#{checkedUserIdsStr})
</if>
<if
test=
"sn != null and sn !=''"
>
and tvd.sn = #{sn}
</if>
order by tvd.id desc
</select>
<select
id=
"getActiveDeviceInfoWithAuth"
resultType=
"cn.com.glsx.admin.modules.model.ActiveDeviceVo"
>
<select
id=
"getActiveDeviceInfoWithAuth"
resultType=
"cn.com.glsx.admin.modules.model.ActiveDeviceVo"
>
SELECT count(temp.id) AS activeNumber,
SELECT count(temp.id) AS activeNumber,
<choose>
<choose>
...
...
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