Commit b1787957 by 杨林龙

新E盾 1.30 版本开发

1 parent 90aa13fd
Showing 30 changed files with 1202 additions and 69 deletions
package cn.com.glsx.admin.modules.controller;
import cn.com.glsx.admin.modules.model.export.DailyMileageReportExport;
import cn.com.glsx.admin.modules.model.export.MileageReportExport;
import cn.com.glsx.admin.modules.model.param.DailyMileageSearch;
import cn.com.glsx.admin.modules.model.param.MileageSearch;
import cn.com.glsx.admin.modules.service.MileageService;
import cn.com.glsx.admin.modules.utils.DateUtil;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.glsx.plat.common.annotation.SysLog;
import com.glsx.plat.common.enums.OperateType;
import com.glsx.plat.core.web.R;
import com.glsx.plat.office.excel.EasyExcelUtils;
import com.google.common.collect.Lists;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.time.DateFormatUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
* 项目名:ne-shield-trialdrive-admin
* 包名: cn.com.glsx.admin.modules.controller
* 作者: Yanglinlong
* 日期: 2021/10/18 14:44
*/
@Slf4j
@RestController
@RequestMapping(value = "/mileagestatistics")
@Api(value = "里程统计", tags = {"里程统计"})
public class MileageController {
@Autowired
private MileageService mileageService;
@Autowired
private HttpServletResponse response;
@GetMapping("/search")
@SysLog(module = "查询里程统计", value = "查询里程统计", action = OperateType.QUERY)
@ApiOperation(value = "查询里程统计")
public R search(MileageSearch search) {
Page<Object> page = PageHelper.startPage(search.getPageNumber(), search.getPageSize(), true);
// 优先查询试驾 d_electric_fence_drive 表获取分页页数
List<MileageReportExport> mileagePageList = mileageService.search(search);
return R.ok().putPageData(mileagePageList, page.getTotal());
}
@GetMapping(value = "/export")
@SysLog(module = "导出里程统计报表", value = "导出里程统计报表", action = OperateType.QUERY)
@ApiOperation(value = "导出里程统计报表")
public void exportMileageReport(MileageSearch search) throws Exception {
log.info("里程统计报表导出===start");
String fileName = "里程统计(按日" + DateFormatUtils.format(new Date(), "yyyy-MM-dd") + ")表";
// 优先查询试驾 d_electric_fence_drive 表获取分页页数
List<MileageReportExport> mileagePageList = mileageService.search(search);
EasyExcelUtils.writeExcel(response, mileagePageList, fileName, "Sheet1", MileageReportExport.class);
log.info("里程统计报表导出===end");
}
@GetMapping(value = "/exportdailydetails")
@SysLog(module = "导出每日里程统计报表", value = "导出每日里程统计报表", action = OperateType.QUERY)
@ApiOperation(value = "导出每日里程统计报表")
public void exportDailyMileageReport(MileageSearch search) throws Exception {
log.info("日里程详细报表导出===start");
String fileName = "日里程统计(按日" + DateFormatUtils.format(new Date(), "yyyy-MM-dd") + ")表";
List<String> dateList = DateUtil.getStaticYMD(search.getMileageStartTime(), search.getMileageEndTime());
List<List<String>> headList = new ArrayList<>();
headList.add(Lists.newArrayList("日里程报表"));
headList.add(dateList);
// 封装数据
List<List<String>> dailyStatisticList = mileageService.exportDailyStatistics(search);
EasyExcelUtils.writeExcel(response, dailyStatisticList, fileName, "日里程报表", headList);
}
@GetMapping(value = "/getsnbyvin")
@SysLog(module = "根据车架号获取其绑定过的所有设备号", value = "根据车架号获取其绑定过的所有设备号", action = OperateType.QUERY)
@ApiOperation(value = "根据车架号获取其绑定过的所有设备号")
public R<List<String>> getSnByVin(@RequestParam("vin") String vin) {
List<String> snList = mileageService.getSnByVin(vin);
return R.ok().data(snList);
}
@GetMapping("/dailysearch")
@SysLog(module = "查询里程详情统计", value = "查询里程详情统计", action = OperateType.QUERY)
@ApiOperation(value = "查询里程详情统计")
public R dailySearch(DailyMileageSearch search) {
Page<Object> page = PageHelper.startPage(search.getPageNumber(), search.getPageSize(), true);
// 优先查询试驾 d_electric_fence_drive 表获取分页页数
List<DailyMileageReportExport> dailyMileagePageList = mileageService.dailySearch(search);
return R.ok().putPageData(dailyMileagePageList, page.getTotal());
}
@GetMapping("/dailyexport")
@SysLog(module = "导出里程详情统计", value = "导出里程详情统计", action = OperateType.QUERY)
@ApiOperation(value = "导出里程详情统计")
public R dailyExport(DailyMileageSearch search) {
Page<Object> page = PageHelper.startPage(search.getPageNumber(), search.getPageSize(), true);
// 优先查询试驾 d_electric_fence_drive 表获取分页页数
List<DailyMileageReportExport> dailyMileagePageList = mileageService.dailySearch(search);
return R.ok().putPageData(dailyMileagePageList, page.getTotal());
}
}
package cn.com.glsx.admin.modules.controller;
import cn.com.glsx.admin.modules.model.export.OilReportExport;
import cn.com.glsx.admin.modules.model.param.OilSearch;
import cn.com.glsx.admin.modules.service.OilService;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.glsx.plat.common.annotation.SysLog;
import com.glsx.plat.common.enums.OperateType;
import com.glsx.plat.core.web.R;
import com.glsx.plat.office.excel.EasyExcelUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.time.DateFormatUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletResponse;
import java.util.Date;
import java.util.List;
/**
* 项目名:ne-shield-trialdrive-admin
* 包名: cn.com.glsx.admin.modules.controller
* 作者: Yanglinlong
* 日期: 2021/10/18 14:44
*/
@Slf4j
@RestController
@RequestMapping(value = "/oilstatistics")
@Api(value = "油耗统计", tags = {"油耗统计"})
public class OilController {
@Autowired
private OilService oilService;
@Autowired
private HttpServletResponse response;
@GetMapping("/search")
@SysLog(module = "查询油耗统计", value = "查询油耗统计", action = OperateType.QUERY)
@ApiOperation(value = "查询油耗统计")
public R search(OilSearch search) {
Page<Object> page = PageHelper.startPage(search.getPageNumber(), search.getPageSize(), true);
// 优先查询油耗 t_electric_oil_mileage 表获取分页页数
List<OilReportExport> oilPageList = oilService.search(search);
return R.ok().putPageData(oilPageList, page.getTotal());
}
@GetMapping(value = "/export")
@SysLog(module = "导出油耗统计", value = "导出油耗统计", action = OperateType.QUERY)
@ApiOperation(value = "导出油耗统计")
public void exportTrialDriveReport(OilSearch search) throws Exception {
log.info("油耗统计报表导出===start");
String fileName = "油耗统计(按日" + DateFormatUtils.format(new Date(), "yyyy-MM-dd") + ")表";
// 优先查询油耗 t_electric_oil_mileage 表获取分页页数
List<OilReportExport> oilPageList = oilService.search(search);
EasyExcelUtils.writeExcel(response, oilPageList, fileName, "Sheet1", OilReportExport.class);
log.info("油耗统计报表导出===end");
}
}
...@@ -21,26 +21,63 @@ public class ElectricFenceDrive implements Serializable { ...@@ -21,26 +21,63 @@ public class ElectricFenceDrive implements Serializable {
@GeneratedValue(strategy = IDENTITY) @GeneratedValue(strategy = IDENTITY)
private Integer id; private Integer id;
@Column(name = "sn") /**
* 设备号
*/
private String sn; private String sn;
/**
* 外键:电子围栏表主键
*/
@Column(name = "fence_id") @Column(name = "fence_id")
private Long fenceId; private Integer fenceId;
/**
* 业务渠道标识,旧e盾:11 新E盾:12
*/
@Column(name = "sve_system_id") @Column(name = "sve_system_id")
private Integer sveSystemId; private Integer sveSystemId;
/**
* 行程开始时间
*/
@Column(name = "journey_time") @Column(name = "journey_time")
private Integer journeyTime; private Date journeyTime;
@Column(name = "percent") /**
* 重合度(百分百),如值为20,即为20%
*/
private Integer percent; private Integer percent;
@Column(name = "created_date", length = 19, updatable = false) /**
private Date createdDate; * 车辆设备关系表id
*/
@Column(name = "vd_id")
private Integer vdId;
@Column(name = "updated_date", length = 19) /**
private Date updatedDate; * 行程结束时间
*/
@Column(name = "journey_end_time")
private Date journeyEndTime;
/**
* 行程里程(米)
*/
@Column(name = "total_mileage")
private Integer totalMileage;
/**
* 创建时间
*/
@Column(name = "created_time", length = 19, updatable = false)
private Date createdTime;
/**
* 更新时间
*/
@Column(name = "updated_time", length = 19)
private Date updatedTime;
@Transient @Transient
private String shopCode; private String shopCode;
......
...@@ -76,5 +76,11 @@ public class ElectricInStoreDrive implements Serializable { ...@@ -76,5 +76,11 @@ public class ElectricInStoreDrive implements Serializable {
@Transient @Transient
private Integer dayOfMonth; private Integer dayOfMonth;
/**
* 每天在店数据统计
*/
@Transient
private Integer instoreCnt;
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
} }
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.admin.modules.entity;
import lombok.Data;
import javax.persistence.Column;
import javax.persistence.Id;
import javax.persistence.Table;
import java.io.Serializable;
import java.util.Date;
/**
* 试驾里程油耗表
* @TableName t_electric_oil_mileage
*/
@Table(name="t_electric_oil_mileage")
@Data
public class ElectricOilMileage implements Serializable {
/**
*
*/
@Id
private Integer id;
/**
* 设备号
*/
private String sn;
/**
* 工厂ID
*/
@Column(name = "fac_id")
private String facId;
/**
* 行程开始时间
*/
@Column(name = "begin_time")
private Date beginTime;
/**
* 行程结束时间
*/
@Column(name = "end_time")
private Date endTime;
/**
* 驾驶时长 单位秒
*/
@Column(name = "total_time")
private Integer totalTime;
/**
* 行驶里程 单位米
*/
private Integer mileage;
/**
* 行驶油耗
*/
private Integer oil;
/**
* 怠速时间
*/
@Column(name = "idle_time")
private Integer idleTime;
/**
* 急加速总次数
*/
@Column(name = "rush_up_count")
private Integer rushUpCount;
/**
* 急减速总次数
*/
@Column(name = "rush_slow_count")
private Integer rushSlowCount;
/**
* 急转弯总次数
*/
@Column(name = "rush_turn_count")
private Integer rushTurnCount;
/**
* 超速次数
*/
@Column(name = "over_speed_count")
private Integer overSpeedCount;
/**
* 行程开始时间
*/
private Date time;
/**
* 车辆设备关系id
*/
@Column(name = "vd_id")
private Integer vdId;
/**
* 创建时间
*/
@Column(name = "created_time")
private Date createdTime;
/**
* 更新时间
*/
@Column(name = "updated_time")
private Date updatedTime;
private static final long serialVersionUID = 1L;
}
\ No newline at end of file \ No newline at end of file
...@@ -34,7 +34,7 @@ public interface ElectricInStoreDriveMapper extends CommonBaseMapper<ElectricInS ...@@ -34,7 +34,7 @@ public interface ElectricInStoreDriveMapper extends CommonBaseMapper<ElectricInS
/** /**
* 获取统计数据 * 获取统计数据
* *
* @param search * @param search 查询条件
* @return * @return
*/ */
List<ElectricInStoreDrive> getInStoreDataListBySn(ElectricInStoreSearch search); List<ElectricInStoreDrive> getInStoreDataListBySn(ElectricInStoreSearch search);
......
package cn.com.glsx.admin.modules.mapper;
import cn.com.glsx.admin.modules.entity.ElectricOilMileage;
import cn.com.glsx.admin.modules.model.export.OilReportExport;
import cn.com.glsx.admin.modules.model.param.OilSearch;
import com.glsx.plat.common.annotation.DataPerm;
import com.glsx.plat.mybatis.mapper.CommonBaseMapper;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
@Mapper
public interface ElectricOilMileageMapper extends CommonBaseMapper<ElectricOilMileage> {
@DataPerm(showSql = true)
List<OilReportExport> getAllTestDrive(OilSearch search);
List<OilReportExport> getStatisticalData(OilSearch search);
}
...@@ -14,6 +14,7 @@ import java.util.List; ...@@ -14,6 +14,7 @@ import java.util.List;
*/ */
@Mapper @Mapper
public interface TrialDriveReportMapper extends CommonBaseMapper<ElectricFenceDrive> { public interface TrialDriveReportMapper extends CommonBaseMapper<ElectricFenceDrive> {
@DataPerm(showSql = true) @DataPerm(showSql = true)
List<TrialDriveReportExport> getTestDrivePageList(TrialDriveReportSearch search); List<TrialDriveReportExport> getTestDrivePageList(TrialDriveReportSearch search);
......
package cn.com.glsx.admin.modules.mapper;
import cn.com.glsx.admin.modules.entity.ElectricFenceDrive;
import cn.com.glsx.admin.modules.model.export.DailyMileageReportExport;
import cn.com.glsx.admin.modules.model.export.DeviceDailyExport;
import cn.com.glsx.admin.modules.model.export.MileageReportExport;
import cn.com.glsx.admin.modules.model.param.DailyMileageSearch;
import cn.com.glsx.admin.modules.model.param.MileageSearch;
import com.glsx.plat.common.annotation.DataPerm;
import com.glsx.plat.mybatis.mapper.CommonBaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@Mapper
public interface TrialMileageMapper extends CommonBaseMapper<ElectricFenceDrive> {
@DataPerm(showSql = true)
List<MileageReportExport> getAllTestDrive(MileageSearch search);
MileageReportExport getStatisticalData(MileageSearch search);
List<String> getSnByVin(@Param("vin") String vin);
List<DailyMileageReportExport> dailySearch(DailyMileageSearch search);
List<DeviceDailyExport> findDailyData(MileageSearch search);
}
package cn.com.glsx.admin.modules.model.export;
import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty;
import lombok.Data;
/**
* 里程详细导出表
*/
@Data
public class DailyMileageReportExport {
@ExcelProperty(value = "工单号", index = 0)
private String orderNo;
@ExcelProperty(value = "姓名", index = 1)
private String ownerName;
@ExcelProperty(value = "设备号", index = 2)
private String sn;
@ExcelProperty(value = "车架号", index = 3)
private String vin;
@ExcelProperty(value = "行程开始时间", index = 4)
private String mileageStartTime;
@ExcelProperty(value = "行程结束时间", index = 5)
private String mileageEndTime;
@ExcelProperty(value = "行驶时长", index = 6)
private String drivingTime;
@ExcelIgnore
private Integer drivingTimeNum;
@ExcelProperty(value = "行驶里程km", index = 7)
private String drivingMileage;
}
package cn.com.glsx.admin.modules.model.export;
import lombok.Data;
@Data
public class DeviceDailyExport {
private String sn;
private String vin;
private String mileageTime;
private String drivingMileage;
}
...@@ -12,11 +12,6 @@ import lombok.Data; ...@@ -12,11 +12,6 @@ import lombok.Data;
*/ */
@Data @Data
public class ElectricInStoreExport extends ReportOrgDto { public class ElectricInStoreExport extends ReportOrgDto {
/**
* 车辆Id
*/
@ExcelIgnore
private Long vehicleId;
@ExcelProperty(value = "特约店代码", index = 4) @ExcelProperty(value = "特约店代码", index = 4)
private String shopCode; private String shopCode;
......
package cn.com.glsx.admin.modules.model.export;
import com.alibaba.excel.annotation.ExcelProperty;
import lombok.Data;
/**
* 里程数据导出表
*/
@Data
public class MileageReportExport {
@ExcelProperty(value = "工单号", index = 0)
private String orderNo;
@ExcelProperty(value = "姓名", index = 1)
private String ownerName;
@ExcelProperty(value = "设备号", index = 2)
private String sn;
@ExcelProperty(value = "车架号", index = 3)
private String vin;
@ExcelProperty(value = "总行驶次数", index = 4)
private String totalTripsNum;
@ExcelProperty(value = "总里程(Km)", index = 5)
private String totalMileage;
}
package cn.com.glsx.admin.modules.model.export;
import cn.com.glsx.admin.modules.model.ReportOrgDto;
import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty;
import lombok.Data;
/**
* 油耗统计报表
*/
@Data
public class OilReportExport extends ReportOrgDto {
/**
* 每辆车每天的油耗总量
*/
@ExcelIgnore
private Integer oilCnt;
/**
* 获取当前天数
*/
@ExcelIgnore
private Integer dayCount;
@ExcelProperty(value = "特约店代码", index = 4)
private String shopCode;
@ExcelProperty(value = "特约店名称", index = 5)
private String shopName;
@ExcelProperty(value = "车型", index = 6)
private String modelName;
@ExcelProperty(value = "设备号", index = 7)
private String sn;
@ExcelProperty(value = "车架号VIN码", index = 8)
private String vin;
/**
* 年月
*/
@ExcelProperty(value = "时间", index = 9)
private String statDate;
@ExcelProperty(value = "1日", index = 10)
private Integer dayNum1;
@ExcelProperty(value = "2日", index = 11)
private Integer dayNum2;
@ExcelProperty(value = "3日", index = 12)
private Integer dayNum3;
@ExcelProperty(value = "4日", index = 13)
private Integer dayNum4;
@ExcelProperty(value = "5日", index = 14)
private Integer dayNum5;
@ExcelProperty(value = "6日", index = 15)
private Integer dayNum6;
@ExcelProperty(value = "7日", index = 16)
private Integer dayNum7;
@ExcelProperty(value = "8日", index = 17)
private Integer dayNum8;
@ExcelProperty(value = "9日", index = 18)
private Integer dayNum9;
@ExcelProperty(value = "10日", index = 19)
private Integer dayNum10;
@ExcelProperty(value = "11日", index = 20)
private Integer dayNum11;
@ExcelProperty(value = "12日", index = 21)
private Integer dayNum12;
@ExcelProperty(value = "13日", index = 22)
private Integer dayNum13;
@ExcelProperty(value = "14日", index = 23)
private Integer dayNum14;
@ExcelProperty(value = "15日", index = 24)
private Integer dayNum15;
@ExcelProperty(value = "16日", index = 25)
private Integer dayNum16;
@ExcelProperty(value = "17日", index = 26)
private Integer dayNum17;
@ExcelProperty(value = "18日", index = 27)
private Integer dayNum18;
@ExcelProperty(value = "19日", index = 28)
private Integer dayNum19;
@ExcelProperty(value = "20日", index = 29)
private Integer dayNum20;
@ExcelProperty(value = "21日", index = 30)
private Integer dayNum21;
@ExcelProperty(value = "22日", index = 31)
private Integer dayNum22;
@ExcelProperty(value = "23日", index = 32)
private Integer dayNum23;
@ExcelProperty(value = "24日", index = 33)
private Integer dayNum24;
@ExcelProperty(value = "25日", index = 34)
private Integer dayNum25;
@ExcelProperty(value = "26日", index = 35)
private Integer dayNum26;
@ExcelProperty(value = "27日", index = 36)
private Integer dayNum27;
@ExcelProperty(value = "28日", index = 37)
private Integer dayNum28;
@ExcelProperty(value = "29日", index = 38)
private Integer dayNum29;
@ExcelProperty(value = "30日", index = 39)
private Integer dayNum30;
@ExcelProperty(value = "31日", index = 40)
private Integer dayNum31;
@ExcelProperty(value = "总计(升)", index = 41)
private Integer summation;
}
package cn.com.glsx.admin.modules.model.param;
import cn.hutool.db.Page;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
@EqualsAndHashCode(callSuper = true)
@Data
@Accessors(chain = true)
@ApiModel("每日里程详情查询实体类")
public class DailyMileageSearch extends Page {
/**
* 里程开始时间
*/
@ApiModelProperty("里程开始时间")
private String mileageStartTime;
/**
* 里程结束时间
*/
@ApiModelProperty("里程结束时间")
private String mileageEndTime;
/**
* 设备号
*/
@ApiModelProperty("设备号")
private String sn;
/**
* 车架号
*/
@ApiModelProperty("车架号")
private String vin;
}
...@@ -26,7 +26,7 @@ public class ElectricInStoreSearch extends Page { ...@@ -26,7 +26,7 @@ public class ElectricInStoreSearch extends Page {
private String keywords; private String keywords;
/** /**
* 车辆id * 车架号
*/ */
private Long vehicleId; private String vin;
} }
package cn.com.glsx.admin.modules.model.param;
import cn.hutool.db.Page;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import java.util.Date;
@EqualsAndHashCode(callSuper = true)
@Data
@Accessors(chain = true)
@ApiModel("里程查询实体参数")
public class MileageSearch extends Page {
/**
* 组织Id
*/
@ApiModelProperty(value = "组织Id")
private String orgId;
/**
* 工单号
*/
@ApiModelProperty("工单号")
private String orderNo;
/**
* 车架号
*/
@ApiModelProperty("车架号")
private String vin;
/**
* 姓名
*/
@ApiModelProperty("姓名")
private String ownerName;
/**
* 设备号
*/
@ApiModelProperty("设备号")
private String sn;
/**
* 里程开始时间
*/
@ApiModelProperty("里程开始时间")
private Date mileageStartTime;
/**
* 里程结束时间
*/
@ApiModelProperty("里程结束时间")
private Date mileageEndTime;
}
package cn.com.glsx.admin.modules.model.param;
import cn.hutool.db.Page;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
@EqualsAndHashCode(callSuper = true)
@Data
@Accessors(chain = true)
@ApiModel("油耗查询实体参数")
public class OilSearch extends Page {
/**
* 查询年份
*/
@ApiModelProperty("查询年份")
private String year;
/**
* 查询月份
*/
@ApiModelProperty("查询月份")
private String month;
/**
* 特约店代码 |特约店名称 | 车架号 | 车型
*/
@ApiModelProperty("特约店代码|特约店名称|车架号|车型")
private String keywords;
/**
* 车架号
*/
private String vin;
}
package cn.com.glsx.admin.modules.service;
import cn.com.glsx.admin.modules.mapper.TrialMileageMapper;
import cn.com.glsx.admin.modules.model.export.DailyMileageReportExport;
import cn.com.glsx.admin.modules.model.export.DeviceDailyExport;
import cn.com.glsx.admin.modules.model.export.MileageReportExport;
import cn.com.glsx.admin.modules.model.param.DailyMileageSearch;
import cn.com.glsx.admin.modules.model.param.MileageSearch;
import cn.com.glsx.admin.modules.utils.DateUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.*;
import java.util.stream.Collectors;
/**
* 项目名:ne-shield-trialdrive-admin
* 包名: cn.com.glsx.admin.modules.service
* 作者: Yanglinlong
* 日期: 2021/10/18 14:51
*/
@Slf4j
@Service
public class MileageService {
@Autowired
private TrialMileageMapper trialMileageMapper;
public List<MileageReportExport> search(MileageSearch search) {
List<MileageReportExport> mileageReportExportList = trialMileageMapper.getAllTestDrive(search);
log.info("全部试驾车辆的数量===" + mileageReportExportList.size());
for (MileageReportExport mileageReportExport : mileageReportExportList) {
MileageReportExport statisticalData = trialMileageMapper.getStatisticalData(search);
mileageReportExport.setTotalTripsNum(statisticalData.getTotalTripsNum());
mileageReportExport.setTotalMileage(statisticalData.getTotalMileage());
}
return mileageReportExportList;
}
public List<List<String>> exportDailyStatistics(MileageSearch search) {
List<List<String>> dataList = new ArrayList<>();
List<DeviceDailyExport> deviceDailyExportList = trialMileageMapper.findDailyData(search);
Map<String, DeviceDailyExport> snVinMap = new HashMap<>();
deviceDailyExportList.forEach(deviceDailyExport -> snVinMap.put(deviceDailyExport.getSn(), deviceDailyExport));
Set<String> snList = deviceDailyExportList.stream().map(DeviceDailyExport::getSn).collect(Collectors.toSet());
for (String sn : snList) {
List<String> oneData = new ArrayList<>();
oneData.add(sn);
oneData.add(snVinMap.get(sn).getVin());
List<DeviceDailyExport> dailyExportList = deviceDailyExportList.stream().filter(deviceDailyExport -> deviceDailyExport.getSn().equals(sn)).sorted(Comparator.comparing(DeviceDailyExport::getMileageTime)).collect(Collectors.toList());
for (DeviceDailyExport deviceDailyExport : dailyExportList) {
String drivingMileage = deviceDailyExport.getDrivingMileage();
drivingMileage = drivingMileage == null ? "0" : drivingMileage;
oneData.add(drivingMileage + "公里");
}
dataList.add(oneData);
}
return dataList;
}
public List<String> getSnByVin(String vin) {
return trialMileageMapper.getSnByVin(vin);
}
public List<DailyMileageReportExport> dailySearch(DailyMileageSearch search) {
List<DailyMileageReportExport> dailyMileageReportExportList = trialMileageMapper.dailySearch(search);
for (DailyMileageReportExport dailyMileageReportExport : dailyMileageReportExportList) {
Integer drivingTimeNum = dailyMileageReportExport.getDrivingTimeNum();
if (drivingTimeNum != null) {
dailyMileageReportExport.setDrivingTime(DateUtil.conver(drivingTimeNum));
}
}
return dailyMileageReportExportList;
}
}
...@@ -442,9 +442,10 @@ public class DateUtil extends org.apache.commons.lang.time.DateUtils { ...@@ -442,9 +442,10 @@ public class DateUtil extends org.apache.commons.lang.time.DateUtils {
} }
public static List<String> getStaticYMD(Date startDate, Date endDate) { public static List<String> getStaticYMD(Date startDate, Date endDate) {
List<Date> dates = new ArrayList<Date>(); List<String> dateStr = new ArrayList<>();
List<String> dateStr = new ArrayList<String>(); dateStr.add("设备号");
dateStr.add("车架号");
// 获取两个日期的天数差
long daydiff = getDiffDays(startDate, endDate); long daydiff = getDiffDays(startDate, endDate);
dateStr.add(DateUtils.formatDate(startDate, "YYYY-MM-dd")); dateStr.add(DateUtils.formatDate(startDate, "YYYY-MM-dd"));
for (int i = 1; i < daydiff; i++) { for (int i = 1; i < daydiff; i++) {
...@@ -796,12 +797,10 @@ public class DateUtil extends org.apache.commons.lang.time.DateUtils { ...@@ -796,12 +797,10 @@ public class DateUtil extends org.apache.commons.lang.time.DateUtils {
int K = s / 60; int K = s / 60;
s = s % 60; s = s % 60;
int M = s; int M = s;
return N + "小时" + K + "分"; return N + "小时" + K + "分" + M + "秒";
} else { } else {
return "0"; return "0";
} }
} }
/*** /***
......
...@@ -17,6 +17,12 @@ ...@@ -17,6 +17,12 @@
<result property="updatedTime" column="updated_time" jdbcType="TIMESTAMP"/> <result property="updatedTime" column="updated_time" jdbcType="TIMESTAMP"/>
</resultMap> </resultMap>
<resultMap id="InStoreDataMap" type="cn.com.glsx.admin.modules.entity.ElectricInStoreDrive">
<result property="instoreCnt" column="instoreCnt" jdbcType="INTEGER"/>
<result property="gpsTime" column="gps_time" jdbcType="TIMESTAMP"/>
<result property="dayOfMonth" column="dayOfMonth" jdbcType="INTEGER"/>
</resultMap>
<sql id="Base_Column_List"> <sql id="Base_Column_List">
id,sn,fence_id, id,sn,fence_id,
sve_system_id,position_state,gps_state, sve_system_id,position_state,gps_state,
...@@ -33,7 +39,6 @@ ...@@ -33,7 +39,6 @@
tu.account shopCode, tu.account shopCode,
tu.username shopName, tu.username shopName,
tv.vin, tv.vin,
tv.id as vehicleId,
tv.model_name as modelName, tv.model_name as modelName,
GROUP_CONCAT(td.sn) as sn, GROUP_CONCAT(td.sn) as sn,
tv.created_by as createdBy tv.created_by as createdBy
...@@ -61,32 +66,21 @@ ...@@ -61,32 +66,21 @@
order by tu.account order by tu.account
</select> </select>
<select id="getInStoreDataListBySn" resultMap="BaseResultMap"> <select id="getInStoreDataListBySn" resultMap="InStoreDataMap">
select teid.position_state , select
teid.gps_state , case when teid.gps_state = 1 then 0 when teid.gps_state = 2 then count(1) else 0 end instoreCnt ,
teid.gps_time , teid.gps_time ,
day(teid.gps_time) as dayOfMonth, day(teid.gps_time) as dayOfMonth
tvd.sn
from t_electric_instore_drive teid from t_electric_instore_drive teid
left join t_vehicle_device tvd on tvd.sn = teid.sn left join t_vehicle_device tvd on tvd.id = teid.vd_id
left join t_vehicle tv on tv.id = tvd.vehicle_id
<where> <where>
<choose> <if test="year != null and year != '' and month != null and month != '' ">
<when test="year != null and year != '' and month != null and month != '' "> left(teid.gps_time,7) = CONCAT(#{year},'-',#{month})
left(teid.gps_time,7) = CONCAT(#{year},'-',#{month}) </if>
</when> and tv.vin = #{vin}
<otherwise> and tv.del_flag = 0
<if test="year != null and year != '' ">
left(teid.gps_time,4) = #{year}
</if>
<if test="month != null and month != '' ">
right(left(teid.gps_time,7),2) = #{month}
</if>
</otherwise>
</choose>
and tvd.vehicle_id = #{vehicleId}
and tvd.bind_status = 1
and tvd.trial_type = 1
and tvd.del_flag = 0
</where> </where>
group by tv.vin, left(teid.gps_time,10)
</select> </select>
</mapper> </mapper>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.com.glsx.admin.modules.mapper.ElectricOilMileageMapper">
<resultMap id="BaseResultMap" type="cn.com.glsx.admin.modules.entity.ElectricOilMileage">
<id property="id" column="id" jdbcType="INTEGER"/>
<result property="sn" column="sn" jdbcType="VARCHAR"/>
<result property="facId" column="fac_id" jdbcType="VARCHAR"/>
<result property="beginTime" column="begin_time" jdbcType="TIMESTAMP"/>
<result property="endTime" column="end_time" jdbcType="TIMESTAMP"/>
<result property="totalTime" column="total_time" jdbcType="INTEGER"/>
<result property="mileage" column="mileage" jdbcType="INTEGER"/>
<result property="oil" column="oil" jdbcType="INTEGER"/>
<result property="idleTime" column="idle_time" jdbcType="INTEGER"/>
<result property="rushUpCount" column="rush_up_count" jdbcType="INTEGER"/>
<result property="rushSlowCount" column="rush_slow_count" jdbcType="INTEGER"/>
<result property="rushTurnCount" column="rush_turn_count" jdbcType="INTEGER"/>
<result property="overSpeedCount" column="over_speed_count" jdbcType="INTEGER"/>
<result property="time" column="time" jdbcType="TIMESTAMP"/>
<result property="vdId" column="vd_id" jdbcType="INTEGER"/>
<result property="createdTime" column="created_time" jdbcType="TIMESTAMP"/>
<result property="updatedTime" column="updated_time" jdbcType="TIMESTAMP"/>
</resultMap>
<sql id="Base_Column_List">
id,sn,fac_id,
begin_time,end_time,total_time,
mileage,oil,idle_time,
rush_up_count,rush_slow_count,rush_turn_count,
over_speed_count,time,vd_id,
created_time,updated_time
</sql>
<select id="getAllTestDrive" resultType="cn.com.glsx.admin.modules.model.export.OilReportExport">
SELECT
tu.account shopCode,
tu.username shopName,
tv.vin,
tv.model_name as modelName,
GROUP_CONCAT(td.sn) as sn,
tv.created_by as createdBy
FROM t_vehicle tv
inner join t_trial_drive_vehicle ttdv on ttdv.vehicle_id = tv.id
LEFT JOIN t_vehicle_device tvd on tvd.vehicle_id = tv.id
LEFT JOIN t_device td on td.sn = tvd.sn
LEFT JOIN t_user tu ON tu.id = tv.created_by
WHERE tu.del_flag = 0
AND tv.del_flag = 0
AND ttdv.del_flag = 0
AND tvd.bind_status = 1
AND tvd.trial_type = 1
AND tvd.del_flag = 0
AND td.del_flag = 0
<if test="keywords != null and keywords!='' ">
and (
tu.account like '%${keywords}%'
or tu.username like '%${keywords}%'
or tv.vin like '%${keywords}%'
or tv.model_name like '%${keywords}%'
)
</if>
group by tv.vin
order by tu.account
</select>
<select id="getStatisticalData" resultType="cn.com.glsx.admin.modules.model.export.OilReportExport">
select
tv.vin,
sum(teom.oil) as oilCnt,
left(teom.begin_time,7) as statDate,
day(teom.begin_time) as dayCount
from t_electric_oil_mileage teom
left join t_vehicle_device tvd on tvd.id = teom.vd_id
left join t_vehicle tv on tv.id = tvd.vehicle_id
<where>
<if test="year != null and year != '' and month != null and month != '' ">
left(teom.begin_time,7) = CONCAT(#{year},'-',#{month})
</if>
and tv.vin = #{vin}
and tv.del_flag = 0
</where>
group by tv.vin, left(teom.begin_time,10)
</select>
</mapper>
...@@ -58,31 +58,22 @@ ...@@ -58,31 +58,22 @@
<select id="getTestDriveData" parameterType="cn.com.glsx.admin.modules.model.param.TrialDriveReportSearch" <select id="getTestDriveData" parameterType="cn.com.glsx.admin.modules.model.param.TrialDriveReportSearch"
resultType="cn.com.glsx.admin.modules.model.export.TrialDriveReportExport"> resultType="cn.com.glsx.admin.modules.model.export.TrialDriveReportExport">
select tsfd.drive_num as cnttotal, select
tv.vin,
sum(tsfd.drive_num) as cnttotal,
left(tsfd.drive_time,7) as statDate, left(tsfd.drive_time,7) as statDate,
day(str_to_date(tsfd.drive_time, '%Y-%m-%d')) as dayCount, day(str_to_date(tsfd.drive_time, '%Y-%m-%d')) as dayCount
tvd.sn
from t_statistics_fence_drive tsfd from t_statistics_fence_drive tsfd
left join t_vehicle_device tvd on tvd.sn = tsfd.sn left join t_vehicle_device tvd on tvd.id = tsfd.vd_id
left join t_vehicle tv on tv.id = tvd.vehicle_id
<where> <where>
<choose> <if test="year != null and year != '' and month != null and month != '' ">
<when test="year != null and year != '' and month != null and month != '' "> left(tsfd.drive_time,7) = CONCAT(#{year},'-',#{month})
left(tsfd.drive_time,7) = CONCAT(#{year},'-',#{month}) </if>
</when> and tv.vin = #{vin}
<otherwise> and tv.del_flag = 0
<if test="year != null and year != '' ">
left(tsfd.drive_time,4) = #{year}
</if>
<if test="month != null and month != '' ">
right(left(tsfd.drive_time,7),2) = #{month}
</if>
</otherwise>
</choose>
and tvd.vehicle_id = #{vehicleId}
and tvd.bind_status = 1
and tvd.trial_type = 1
and tvd.del_flag = 0
</where> </where>
group by tv.vin, tsfd.drive_time
</select> </select>
<select id="getYearWithData" resultType="java.lang.String"> <select id="getYearWithData" resultType="java.lang.String">
......
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.com.glsx.admin.modules.mapper.TrialMileageMapper">
<resultMap id="BaseResultMap" type="cn.com.glsx.admin.modules.entity.ElectricFenceDrive">
<id property="id" column="id" jdbcType="INTEGER"/>
<result property="sn" column="sn" jdbcType="VARCHAR"/>
<result property="fenceId" column="fence_id" jdbcType="INTEGER"/>
<result property="sveSystemId" column="sve_system_id" jdbcType="INTEGER"/>
<result property="journeyTime" column="journey_time" jdbcType="TIMESTAMP"/>
<result property="percent" column="percent" jdbcType="INTEGER"/>
<result property="vdId" column="vd_id" jdbcType="INTEGER"/>
<result property="journeyEndTime" column="journey_end_time" jdbcType="TIMESTAMP"/>
<result property="totalMileage" column="total_mileage" jdbcType="INTEGER"/>
<result property="createdTime" column="created_time" jdbcType="TIMESTAMP"/>
<result property="updatedTime" column="updated_time" jdbcType="TIMESTAMP"/>
</resultMap>
<sql id="Base_Column_List">
id,sn,fence_id,
sve_system_id,journey_time,percent,
vd_id,journey_end_time,total_mileage,
created_time,updated_time
</sql>
<select id="getAllTestDrive" resultType="cn.com.glsx.admin.modules.model.export.MileageReportExport">
SELECT
tw.order_no orderNo,
tv.owner_name ownerName,
GROUP_CONCAT(td.sn) sn,
tv.vin
FROM t_vehicle tv
inner join t_trial_drive_vehicle ttdv on ttdv.vehicle_id = tv.id
LEFT JOIN t_vehicle_device tvd on tvd.vehicle_id = tv.id
LEFT JOIN t_device td on td.sn = tvd.sn
LEFT JOIN t_workorder tw ON tw.id = tv.workorder_id
WHERE tw.del_flag = 0
AND tv.del_flag = 0
AND ttdv.del_flag = 0
AND tvd.bind_status = 1
AND tvd.trial_type = 1
AND td.del_flag = 0
<if test="orgId != null and orgId!='' ">
tv.created_by = #{orgId}
</if>
<if test="orderNo != null and orderNo!='' ">
tw.order_no = #{orderNo}
</if>
<if test="vin != null and vin!='' ">
tv.vin = #{vin}
</if>
<if test="ownerName != null and ownerName!='' ">
tv.owner_name = #{ownerName}
</if>
<if test="sn != null and sn!='' ">
td.sn = #{sn}
</if>
group by tv.vin
</select>
<select id="getStatisticalData" resultType="cn.com.glsx.admin.modules.model.export.MileageReportExport">
select
count(1) as totalTripsNum,
sum(total_mileage)/1000 as totalMileage
from t_electric_fence_drive tefd
left join t_vehicle_device tvd on tvd.id = tefd.vd_id
left join t_vehicle tv on tv.id = tvd.vehicle_id
where tv.vin = #{vin}
and tvd.del_flag = 0
and tv.del_flag = 0
</select>
<select id="getSnByVin" resultType="java.lang.String">
select
tvd.sn
from t_vehicle_device tvd
left join t_vehicle tv on tv.id = tvd.vehicle_id
left join t_device td on td.sn = tvd.sn
where tv.vin = #{vin}
and tv.del_flag = 0
and td.del_flag = 0
</select>
<select id="dailySearch" resultType="cn.com.glsx.admin.modules.model.export.DailyMileageReportExport">
select
tw.order_no orderNo ,
tv.owner_name ownerName ,
tvd.sn ,
tv.vin ,
tefd.journey_time mileageStartTime ,
tefd.journey_end_time mileageEndTime ,
TIMESTAMPDIFF(second ,tefd.journey_time,tefd.journey_end_time) drivingTimeNum,
tefd.total_mileage/1000 drivingMileage
from t_electric_fence_drive tefd
left join t_vehicle_device tvd on tvd.id = tefd.vd_id
left join t_vehicle tv on tv.id = tvd.vehicle_id
left join t_workorder tw on tw.id = tv.workorder_id
where 1 = 1
<if test="vin != null and vin!='' ">
and tv.vin = #{vin}
</if>
<if test="sn != null and sn!='' ">
and td.sn = #{sn}
</if>
<if test="mileageStartTime != null">
and tefd.journey_time &gt;= #{mileageStartTime}
</if>
<if test="mileageEndTime != null">
and tefd.journey_end_time &lt;= #{mileageEndTime}
</if>
</select>
<select id="findDailyData" resultType="cn.com.glsx.admin.modules.model.export.DeviceDailyExport">
select
tefd.sn ,
tv.vin ,
sum(total_mileage)/1000 drivingMileage ,
left(tefd.journey_time,10) as mileageTime
from t_electric_fence_drive tefd
left join t_vehicle_device tvd on tvd.id = tefd.vd_id
left join t_vehicle tv on tv.id = tvd.vehicle_id
left join t_workorder tw on tw.id = tv.workorder_id
<where>
<if test="orgId != null">
tv.created_by = #{orgId}
</if>
<if test="orderNo != null and orderNo!='' ">
tw.order_no = #{orderNo}
</if>
<if test="vin != null and vin!='' ">
tv.vin = #{vin}
</if>
<if test="ownerName != null and ownerName!='' ">
tv.owner_name = #{ownerName}
</if>
<if test="sn != null and sn!='' ">
tefd.sn = #{sn}
</if>
<if test="mileageStartTime != null">
and tefd.journey_time &gt;= #{mileageStartTime}
</if>
<if test="mileageEndTime != null">
and tefd.journey_end_time &lt;= #{mileageEndTime}
</if>
</where>
group by tefd.sn , left(tefd.journey_time,10)
order by left(tefd.journey_time,10)
</select>
</mapper>
...@@ -102,7 +102,7 @@ public class ElectricInStoreDriveServiceTest { ...@@ -102,7 +102,7 @@ public class ElectricInStoreDriveServiceTest {
// 如果sn不为null 则封装每天具体数据 // 如果sn不为null 则封装每天具体数据
if (electricInStoreExport.getSn() != null) { if (electricInStoreExport.getSn() != null) {
search.setVehicleId(electricInStoreExport.getVehicleId()); search.setVin(electricInStoreExport.getVin());
List<ElectricInStoreDrive> inStoreDataList = inStoreDriveMapper.getInStoreDataListBySn(search); List<ElectricInStoreDrive> inStoreDataList = inStoreDriveMapper.getInStoreDataListBySn(search);
Integer num1 = 0; Integer num1 = 0;
Integer num2 = 0; Integer num2 = 0;
...@@ -300,7 +300,7 @@ public class ElectricInStoreDriveServiceTest { ...@@ -300,7 +300,7 @@ public class ElectricInStoreDriveServiceTest {
@Test @Test
public void test03() { public void test03() {
ElectricInStoreSearch search = new ElectricInStoreSearch(); ElectricInStoreSearch search = new ElectricInStoreSearch();
search.setVehicleId(5498L); search.setVin("5498L");
List<ElectricInStoreDrive> inStoreDataList = inStoreDriveMapper.getInStoreDataListBySn(search); List<ElectricInStoreDrive> inStoreDataList = inStoreDriveMapper.getInStoreDataListBySn(search);
System.out.println("inStoreDataList = " + JSON.toJSONString(inStoreDataList)); System.out.println("inStoreDataList = " + JSON.toJSONString(inStoreDataList));
} }
......
package cn.com.glsx.admin.modules.service;
import cn.com.glsx.Application;
import cn.com.glsx.admin.modules.model.export.DailyMileageReportExport;
import cn.com.glsx.admin.modules.model.export.MileageReportExport;
import cn.com.glsx.admin.modules.model.param.DailyMileageSearch;
import cn.com.glsx.admin.modules.model.param.MileageSearch;
import com.alibaba.fastjson.JSON;
import lombok.extern.slf4j.Slf4j;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import java.util.List;
@Slf4j
@RunWith(SpringRunner.class)
@SpringBootTest(classes = Application.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
public class MileageServiceTest {
@Autowired
private MileageService mileageService;
@Test
public void search() {
MileageSearch search = new MileageSearch();
List<MileageReportExport> mileageReportExportList = mileageService.search(search);
System.out.println("mileageReportExportList = " + JSON.toJSONString(mileageReportExportList));
}
@Test
public void dailySearch() {
DailyMileageSearch search = new DailyMileageSearch();
List<DailyMileageReportExport> dailyMileageReportExports = mileageService.dailySearch(search);
System.out.println("dailyMileageReportExports = " + JSON.toJSONString(dailyMileageReportExports));
}
@Test
public void getSnByVin() {
String vin = "LHGCV1662L8022481";
List<String> snByVin = mileageService.getSnByVin(vin);
System.out.println("snByVin = " + JSON.toJSONString(snByVin));
}
@Test
public void exportDailyStatistics() {
MileageSearch search = new MileageSearch();
List<List<String>> lists = mileageService.exportDailyStatistics(search);
System.out.println("lists = " + JSON.toJSONString(lists));
}
}
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.admin.modules.service;
import cn.com.glsx.Application;
import cn.com.glsx.admin.modules.model.export.OilReportExport;
import cn.com.glsx.admin.modules.model.param.OilSearch;
import com.alibaba.fastjson.JSON;
import lombok.extern.slf4j.Slf4j;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import java.util.List;
@Slf4j
@RunWith(SpringRunner.class)
@SpringBootTest(classes = Application.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
public class OilServiceTest {
@Autowired
private OilService oilService;
@Test
public void search() {
OilSearch search = new OilSearch();
List<OilReportExport> oilReportExportList = oilService.search(search);
System.out.println("oilReportExportList = " + JSON.toJSONString(oilReportExportList));
}
}
\ No newline at end of file \ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!