Commit 1d60f733 by 向延琳

Merge branch 'develop' of http://192.168.3.233:8090/eshiled-new/ne-shield-triald…

…rive-admin into develop
2 parents 182c619f 311ac0de
......@@ -62,8 +62,7 @@ public class ReportDeviceDTO extends BaseOrgDto {
/**
* 定位时间
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date gpsTime;
private String gpsTime;
/**
* 定位地点
......
......@@ -2,6 +2,7 @@ package cn.com.glsx.admin.modules.model.export;
import cn.com.glsx.admin.modules.model.BaseOrgDto;
import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
......@@ -25,49 +26,75 @@ public class ReportDeviceExport extends BaseOrgDto {
/**
* 业务工单号
*/
@ExcelProperty("业务工单号")
private String bizOrderNo;
/**
* 设备号
*/
@ExcelProperty("设备号")
private String sns;
/**
* 车牌号
*/
@ExcelProperty("车牌号")
private String licensePlate;
/**
* 是否激活
*/
@ExcelProperty("是否激活")
private String activateFlag;
/**
* 车主姓名
*/
@ExcelProperty("姓名")
private String ownerName;
/**
* 车架号VIN码
*/
@ExcelProperty("车架号")
private String vin;
@ExcelProperty("所属组织")
private String belongLevels;
/**
* 设备激活时间
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@ExcelProperty("设备激活时间")
private Date activateTime;
/**
* 定位时间
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date gpsTime;
@ExcelProperty("定位时间")
private String gpsTime;
/**
* 定位地点
*/
@ExcelProperty("定位地点")
private String gpsAddress;
/**
* 工单激活时间
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@ExcelProperty("工单激活时间")
private Date woActivateTime;
@ExcelProperty("租赁属性")
private String rentP;
@ExcelProperty("车辆说明")
private String vehicleRemark;
@ExcelProperty("备注")
private String remark;
}
......@@ -2,6 +2,7 @@ package cn.com.glsx.admin.modules.model.export;
import cn.com.glsx.admin.modules.model.BaseOrgDto;
import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
......@@ -25,48 +26,69 @@ public class ReportVehicleExport extends BaseOrgDto {
/**
* 业务工单号
*/
@ExcelProperty("业务工单号")
private String bizOrderNo;
/**
* 车牌号
*/
@ExcelProperty("车牌号")
private String licensePlate;
/**
* 车主姓名
*/
@ExcelProperty("姓名")
private String ownerName;
/**
* 车架号VIN码
*/
@ExcelProperty("车架号")
private String vin;
/**
* 设备号
*/
private String sns;
/**
* 设备组合
*/
@ExcelProperty("设备组合")
private String deviceCompose;
/**
* 工单创建时间
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@ExcelProperty("工单接收时间")
private Date createdDate;
/**
* 车辆激活时间(也是车辆创建时间)
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@ExcelProperty("车辆激活时间")
private Date activateTime;
@ExcelProperty("所属组织")
private String belongLevels;
@ExcelProperty("店面名称")
private String shopName;
@ExcelProperty("车辆说明")
private String remark;
@ExcelProperty("车型")
private String modelName;
/**
* 激活人
*/
@ExcelProperty("激活人")
private String activator;
/**
* 设备号
*/
@ExcelProperty("设备号")
private String sns;
}
......@@ -8,15 +8,27 @@ import cn.com.glsx.admin.modules.model.export.ReportDeviceExport;
import cn.com.glsx.admin.modules.model.export.ReportVehicleExport;
import cn.com.glsx.admin.modules.model.param.ReportDeviceSearch;
import cn.com.glsx.admin.modules.model.param.ReportVehicleSearch;
import cn.com.glsx.admin.modules.remote.RemoteGpsBsService;
import cn.com.glsx.devicemonitor.api.dto.response.GpsBsData;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.stereotype.Service;
import org.springframework.util.StopWatch;
import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import java.util.stream.Collectors;
@Slf4j
@Service
......@@ -31,6 +43,13 @@ public class OpereportService extends AbstractCommonService {
@Autowired
private OrganizationApiService organizationApiService;
@Autowired
private RemoteGpsBsService remoteGpsBsService;
@Autowired
@Qualifier("threadPoolTaskExecutor")
private ThreadPoolTaskExecutor threadPoolTaskExecutor;
public PageInfo<ReportVehicleDTO> vehicleSearch(ReportVehicleSearch search) {
setOrgCheckedAuth(search);
......@@ -63,6 +82,23 @@ public class OpereportService extends AbstractCommonService {
List<ReportDeviceDTO> list = vehicleDeviceMapper.searchReportDevice(search);
List<String> snList = list.stream().map(ReportDeviceDTO::getSns).collect(Collectors.toList());
Map<String, GpsBsData> gpsBsDataMap = remoteGpsBsService.getLastGpsBsBatchBySns(snList);
list.forEach(rdd -> {
GpsBsData gpsBsData = gpsBsDataMap.get(rdd.getSns());
if (gpsBsData != null) {
if (gpsBsData.getGpsLocation() != null) {
rdd.setGpsTime(gpsBsData.getGpsLocation().getDateTime());
rdd.setGpsAddress(gpsBsData.getGpsLocation().getAddress());
} else if (gpsBsData.getBsLocation() != null) {
rdd.setGpsTime(gpsBsData.getBsLocation().getDateTime());
rdd.setGpsAddress(gpsBsData.getBsLocation().getAddress());
}
}
});
organizationApiService.drawAllLevel(list);
return new PageInfo<>(list);
......@@ -72,11 +108,75 @@ public class OpereportService extends AbstractCommonService {
setOrgCheckedAuth(search);
StopWatch sw = new StopWatch();
sw.start("report deviceExport task1");
List<ReportDeviceExport> list = vehicleDeviceMapper.exportReportDevice(search);
sw.stop();
sw.start("report deviceExport task2");
try {
getDeviceLocations(list);
} catch (InterruptedException | ExecutionException e) {
throw new RuntimeException(e);
}
sw.stop();
sw.start("report deviceExport task3");
organizationApiService.drawAllLevel(list);
sw.stop();
log.info("report deviceExport任务耗时概览:{},总耗时:{}秒", sw.prettyPrint(), sw.getTotalTimeSeconds());
return list;
}
public void getDeviceLocations(List<ReportDeviceExport> dataList) throws InterruptedException, ExecutionException {
if (CollectionUtils.isEmpty(dataList)) {
return;
}
List<String> snList = dataList.stream().map(ReportDeviceExport::getSns).collect(Collectors.toList());
//切分成一个list去请求
List<List<String>> partList = Lists.partition(snList, 1000);
CompletableFuture<Map<String, GpsBsData>>[] futures = new CompletableFuture[partList.size()];
//异步请求
for (int i = 0; i < partList.size(); i++) {
List<String> subSnList = partList.get(i);
log.info("总处理条数:{},总处理批次:{},开始处理第{}批({})", dataList.size(), partList.size(), i, subSnList.size());
CompletableFuture<Map<String, GpsBsData>> completableFuture = CompletableFuture.supplyAsync(() -> remoteGpsBsService.getLastGpsBsBySns(subSnList), threadPoolTaskExecutor)
.exceptionally(Error -> Maps.newHashMap());
futures[i] = completableFuture;
}
// List列表转成CompletableFuture的Array数组,使其可以作为allOf()的参数
// 使用join()方法使得主线程阻塞,并等待所有并行线程完成
CompletableFuture.allOf(futures).join();
Map<String, GpsBsData> gpsBsDataMap = Maps.newHashMap();
//异步结果
for (CompletableFuture<Map<String, GpsBsData>> item : futures) {
Map<String, GpsBsData> map = item.get();
gpsBsDataMap.putAll(map);
}
dataList.forEach(rdd -> {
GpsBsData gpsBsData = gpsBsDataMap.get(rdd.getSns());
if (gpsBsData != null) {
if (gpsBsData.getGpsLocation() != null) {
rdd.setGpsTime(gpsBsData.getGpsLocation().getDateTime());
rdd.setGpsAddress(gpsBsData.getGpsLocation().getAddress());
} else if (gpsBsData.getBsLocation() != null) {
rdd.setGpsTime(gpsBsData.getBsLocation().getDateTime());
rdd.setGpsAddress(gpsBsData.getBsLocation().getAddress());
}
}
});
}
}
......@@ -1250,60 +1250,90 @@
<select id="searchReportVehicle" resultType="cn.com.glsx.admin.modules.model.ReportVehicleDTO">
select tv.id,
tv.workorder_id workOrderId,
tw.partner_order_no bizOrderNo,
tv.owner_name ownerName,
tv.vin,
twv.device_compose deviceCompose,
group_concat(tvd.sn order by source desc) sns,
group_concat(td.device_type order by source desc) deviceTypes,
group_concat(td.source order by source desc) deviceSources,
tv.license_plate licensePlate,
tv.created_date activateTime,
tw.created_date createdDate,
tw.mechanic_name activator,
tv.created_by createdBy
tv.workorder_id workOrderId,
tw.partner_order_no bizOrderNo,
tv.owner_name ownerName,
tv.vin,
twv.device_compose deviceCompose,
group_concat(tvd.sn order by source desc) sns,
group_concat(td.device_type order by source desc) deviceTypes,
group_concat(td.source order by source desc) deviceSources,
tv.license_plate licensePlate,
tv.created_date activateTime,
tw.created_date createdDate,
tw.mechanic_name activator,
tv.created_by createdBy
from t_vehicle tv
left join t_vehicle_device tvd on tvd.vehicle_id = tv.id
left join t_workorder tw on tw.id = tv.workorder_id
left join t_workorder_vehicle twv on twv.workorder_id = tw.id
left join t_device td on td.sn = tvd.sn
left join t_user tu on tu.id = tv.created_by
left join t_vehicle_device tvd on tvd.vehicle_id = tv.id
left join t_workorder tw on tw.id = tv.workorder_id
left join t_workorder_vehicle twv on twv.workorder_id = tw.id
left join t_device td on td.sn = tvd.sn
left join t_user tu on tu.id = tv.created_by
where tv.del_flag = 0
and tvd.del_flag = 0
and tvd.bind_status = 1
and tvd.del_flag = 0
and tvd.bind_status = 1
<if test="checkedUserIdsStr != null and checkedUserIdsStr !=''">
and find_in_set(tv.created_by,#{checkedUserIdsStr})
</if>
<if test="activateBeginTime != null and activateBeginTime != '' and activateEndTime != null and activateEndTime != ''">
and DATE_FORMAT(tv.created_date,'%Y-%m-%d') between #{activateBeginTime} and #{activateEndTime}
</if>
<if test="orderBeginTime != null and orderBeginTime != '' and orderEndTime != null and orderEndTime != ''">
and DATE_FORMAT(tw.created_date,'%Y-%m-%d') between #{orderBeginTime} and #{orderEndTime}
</if>
<if test="term != null and term !=''">
and(
tv.owner_name like '%${term}%'
or tv.vin like '%${term}%'
or tvd.sn like '%${term}%'
or tw.partner_order_no like '%${term}%'
)
</if>
group by tv.id
order by tv.created_date desc
</select>
<select id="exportReportVehicle" resultType="cn.com.glsx.admin.modules.model.export.ReportVehicleExport">
select tv.id,
tv.workorder_id workOrderId,
tw.partner_order_no bizOrderNo,
tv.owner_name ownerName,
tv.vin,
twv.device_compose deviceCompose,
group_concat(tvd.sn order by source desc) sns,
group_concat(td.device_type order by source desc) deviceTypes,
group_concat(td.source order by source desc) deviceSources,
tv.license_plate licensePlate,
tv.created_date activateTime,
tw.created_date createdDate,
tw.mechanic_name activator,
tv.created_by createdBy
tv.workorder_id workOrderId,
tw.partner_order_no bizOrderNo,
tv.owner_name ownerName,
tv.vin,
twv.device_compose deviceCompose,
group_concat(tvd.sn order by source desc) sns,
group_concat(td.device_type order by source desc) deviceTypes,
group_concat(td.source order by source desc) deviceSources,
tv.license_plate licensePlate,
tv.created_date activateTime,
tw.created_date createdDate,
tw.mechanic_name activator,
tv.created_by createdBy
from t_vehicle tv
left join t_vehicle_device tvd on tvd.vehicle_id = tv.id
left join t_workorder tw on tw.id = tv.workorder_id
left join t_workorder_vehicle twv on twv.workorder_id = tw.id
left join t_device td on td.sn = tvd.sn
left join t_user tu on tu.id = tv.created_by
left join t_vehicle_device tvd on tvd.vehicle_id = tv.id
left join t_workorder tw on tw.id = tv.workorder_id
left join t_workorder_vehicle twv on twv.workorder_id = tw.id
left join t_device td on td.sn = tvd.sn
left join t_user tu on tu.id = tv.created_by
where tv.del_flag = 0
and tvd.del_flag = 0
and tvd.bind_status = 1
and tvd.del_flag = 0
and tvd.bind_status = 1
<if test="checkedUserIdsStr != null and checkedUserIdsStr !=''">
and find_in_set(tv.created_by,#{checkedUserIdsStr})
</if>
<if test="activateBeginTime != null and activateBeginTime != '' and activateEndTime != null and activateEndTime != ''">
and DATE_FORMAT(tv.created_date,'%Y-%m-%d') between #{activateBeginTime} and #{activateEndTime}
</if>
<if test="orderBeginTime != null and orderBeginTime != '' and orderEndTime != null and orderEndTime != ''">
and DATE_FORMAT(tw.created_date,'%Y-%m-%d') between #{orderBeginTime} and #{orderEndTime}
</if>
<if test="term != null and term !=''">
and(
tv.owner_name like '%${term}%'
or tv.vin like '%${term}%'
or tvd.sn like '%${term}%'
or tw.partner_order_no like '%${term}%'
)
</if>
group by tv.id
order by tv.created_date desc
</select>
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!