Commit 8b004856 by 杨林龙

1.9.0 仲利车辆列表增加最后定位时间字段

1 parent f3636486
package cn.com.glsx.admin.modules.entity;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
import javax.persistence.*;
@Data
@Table(name = "t_device_location")
public class DeviceLocation implements Serializable {
/**
* 主键id
*/
@Id
@Column(name = "id", unique = true, nullable = false)
@GeneratedValue(strategy = GenerationType.IDENTITY, generator = "SELECT LAST_INSERT_ID()")
private Integer id;
/**
* 设备号
*/
private String sn;
/**
* 最后gps时间
*/
@Column(name = "last_gps_time")
private Date lastGpsTime;
/**
* 最后基站时间
*/
@Column(name = "last_bs_time")
private Date lastBsTime;
/**
* 速度
*/
private Integer speed;
/**
* 对应大数据侧状态
1、静止
3、行驶
*/
@Column(name = "stay_status")
private Integer stayStatus;
/**
* 设备状态最新更新时间
*/
@Column(name = "stay_status_updatetime")
private Date stayStatusUpdatetime;
/**
* 创建时间
*/
@Column(name = "created_time")
private Date createdTime;
/**
* 更新时间
*/
@Column(name = "updated_time")
private Date updatedTime;
}
\ No newline at end of file
package cn.com.glsx.admin.modules.mapper;
import cn.com.glsx.admin.modules.entity.DeviceLocation;
import java.util.List;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import com.glsx.plat.mybatis.mapper.CommonBaseMapper;
@Mapper
public interface DeviceLocationMapper extends CommonBaseMapper<DeviceLocation> {
List<DeviceLocation> findLocationListBySnList(@Param("snList") List<String> snList);
}
\ No newline at end of file
......@@ -41,6 +41,11 @@ public class VehicleInfoPageDTO extends BaseOrgDto {
private String vin;
/**
* 店面名称
*/
private String shopName;
/**
* 设备号
*/
private String sn;
......@@ -86,12 +91,17 @@ public class VehicleInfoPageDTO extends BaseOrgDto {
private String activateTime;
/**
* 最后定位时间
*/
private String lastPoiTime;
/**
* 设备状态 (0 行驶中 1 静止 2离线 3 在线)
*/
private Integer deviceState;
/**
* 设备状态字符串 (0 行驶中 1 静止 2离线 3 在线)
* 设备状态字符串 (0 行驶中 1 静止 2离线 3 在线)
*/
private String deviceStateStr;
......@@ -111,7 +121,7 @@ public class VehicleInfoPageDTO extends BaseOrgDto {
private String enableFre;
/**
* 是否支持调频/断油断电 0:均不支持 1:支持调频 2:断开油电 3:恢复油电
* 是否支持调频/断油断电 0:均不支持 1:支持调频 2:断开油电 3:恢复油电
*/
private Integer adjFreq;
......
......@@ -104,6 +104,12 @@ public class VehicleInfoExport extends BaseOrgDto {
private String activateTime;
/**
* 最后定位时间
*/
@ExcelProperty(value = "最后定位时间", index = 10)
private String lastPoiTime;
/**
* 设备状态数值 (0 行驶中 1 静止 2离线 3 在线)
*/
@ExcelIgnore
......@@ -112,7 +118,7 @@ public class VehicleInfoExport extends BaseOrgDto {
/**
* 设备状态字符串 (0 行驶中 1 静止 2离线 3 在线)
*/
@ExcelProperty(value = "设备状态", index = 10)
@ExcelProperty(value = "设备状态", index = 11)
private String deviceStateStr;
/**
......@@ -124,13 +130,13 @@ public class VehicleInfoExport extends BaseOrgDto {
/**
* 特殊状态
*/
@ExcelProperty(value = "调频状态", index = 11)
@ExcelProperty(value = "调频状态", index = 12)
private String specialState;
/**
* 调频时间
*/
@ExcelProperty(value = "调频时间", index = 12)
@ExcelProperty(value = "调频时间", index = 13)
private String freqTime;
/**
......@@ -142,43 +148,43 @@ public class VehicleInfoExport extends BaseOrgDto {
/**
* 调频模式 数值转换为字符串之后的值
*/
@ExcelProperty(value = "调频模式", index = 13)
@ExcelProperty(value = "调频模式", index = 14)
private String freqTypeStr;
/**
* 上点频次
*/
@ExcelProperty(value = "上点频次", index = 14)
@ExcelProperty(value = "上点频次", index = 15)
private String frequency;
/**
* 调频上点个数
*/
@ExcelProperty(value = "调频上点个数", index = 15)
@ExcelProperty(value = "调频上点个数", index = 16)
private Integer freTotal;
/**
* 设备上点总个数
*/
@ExcelProperty(value = "设备上点总个数", index = 16)
@ExcelProperty(value = "设备上点总个数", index = 17)
private Integer devicePointTotal;
/**
* 剩余电量 转为字符串 增加%号
*/
@ExcelProperty(value = "剩余电量", index = 17)
@ExcelProperty(value = "剩余电量", index = 18)
private String batteryLevel;
/**
* 结清标识:0未结清,1结清
*/
@ExcelProperty(value = "是否结清", index = 18)
@ExcelProperty(value = "是否结清", index = 19)
private String settleFlag;
@ExcelProperty(value = "操作人", index = 19)
@ExcelProperty(value = "操作人", index = 20)
private String username;
@ExcelProperty(value = "调频操作人", index = 20)
@ExcelProperty(value = "调频操作人", index = 21)
private String operation;
@ExcelIgnore
......
......@@ -7,6 +7,7 @@ import cn.com.glsx.admin.common.enums.*;
import cn.com.glsx.admin.common.exception.AdminException;
import cn.com.glsx.admin.modules.converter.FreqConverter;
import cn.com.glsx.admin.modules.entity.*;
import cn.com.glsx.admin.modules.entity.DeviceLocation;
import cn.com.glsx.admin.modules.mapper.*;
import cn.com.glsx.admin.modules.model.*;
import cn.com.glsx.admin.modules.model.datasync.DeviceActiveSync;
......@@ -41,6 +42,7 @@ import cn.com.glsx.usercenter.api.dto.response.CUser;
import cn.com.glsx.usercenter.api.dto.response.User;
import cn.com.glsx.usercenter.api.dto.tree.OrgTreeModel;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
......@@ -178,6 +180,9 @@ public class VehicleService extends AbstractCommonService {
@Autowired
private RemoteDeviceFreqService remoteDeviceFreqService;
@Autowired
private DeviceLocationMapper deviceLocationMapper;
private static CarInfoSelected applyCarBrandConvert(TenantVehicleType tvt) {
CarInfoSelected selected = new CarInfoSelected();
selected.setId(Math.toIntExact(tvt.getBrandId()));
......@@ -1057,6 +1062,15 @@ public class VehicleService extends AbstractCommonService {
deviceFreqMap = freqModelList.stream().collect(Collectors.toMap(DeviceFreqModel::getSn, Function.identity(), (k1, k2) -> k2));
}
// 查询设备最后定位点数据
List<String> snList = vehicleInfoList.stream().map(VehicleInfoPageDTO::getSn).filter(Objects::nonNull)
.collect(Collectors.toList());
Map<String, DeviceLocation> deviceLocationMap = Maps.newHashMap();
List<DeviceLocation> deviceLocationList = deviceLocationMapper.findLocationListBySnList(snList);
if (CollectionUtils.isNotEmpty(deviceLocationList)) {
deviceLocationMap = deviceLocationList.stream().collect(Collectors.toMap(DeviceLocation::getSn, Function.identity(), (k1, k2) -> k2));
}
String supAdjFreq = PropertiesUtils.getProperty("support.adj.freq");
for (VehicleInfoPageDTO vehicleInfo : vehicleInfoList) {
......@@ -1068,6 +1082,8 @@ public class VehicleService extends AbstractCommonService {
//设置调频信息
setVehicleAdjFreq(supAdjFreq, vehicleInfo, deviceFreqMap.get(vehicleInfo.getSn()));
//设置设备定位数据
setDeviceLocation(vehicleInfo, deviceLocationMap);
//设置设备状态
DeviceStatusModel statusModel = deviceStatusMap.get(vehicleInfo.getSn());
......@@ -1089,6 +1105,25 @@ public class VehicleService extends AbstractCommonService {
}
/**
* 设置设备定位数据
*
* @param vehicleInfo 车辆设备数据
* @param deviceLocationMap 设备定位数据 map
*/
private void setDeviceLocation(VehicleInfoPageDTO vehicleInfo, Map<String, DeviceLocation> deviceLocationMap) {
DeviceLocation deviceLocation = deviceLocationMap.get(vehicleInfo.getSn());
if (Objects.isNull(deviceLocation.getLastGpsTime()) && Objects.nonNull(deviceLocation.getLastBsTime())) {
vehicleInfo.setLastPoiTime(DateUtil.formatDateTime(deviceLocation.getLastBsTime()));
} else if (Objects.nonNull(deviceLocation.getLastGpsTime()) && Objects.isNull(deviceLocation.getLastBsTime())) {
vehicleInfo.setLastPoiTime(DateUtil.formatDateTime(deviceLocation.getLastGpsTime()));
} else if (Objects.nonNull(deviceLocation.getLastGpsTime()) && Objects.nonNull(deviceLocation.getLastBsTime())) {
vehicleInfo.setLastPoiTime(DateUtil.formatDateTime(new Date(Math.max(deviceLocation.getLastGpsTime().getTime(), deviceLocation.getLastBsTime().getTime()))));
} else {
vehicleInfo.setLastPoiTime(null);
}
}
/**
* 设置车辆调频状态
*
* @param supAdjFreq
......
......@@ -69,6 +69,7 @@
<!-- table可以有多个,每个数据库中的表都可以写一个table,tableName表示要匹配的数据库表,也可以在tableName属性中通过使用%通配符来匹配所有数据库表,只有匹配的表才会自动生成文件 enableSelectByPrimaryKey相应的配置表示是否生成相应的接口 -->
<!-- <table tableName="t_vehicle" domainObjectName="Vehicle" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"/>-->
<table tableName="t_fake_offline_change_frequently" domainObjectName="FakeOfflineChangeFrequently" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"/>
<!-- <table tableName="t_fake_offline_change_frequently" domainObjectName="FakeOfflineChangeFrequently" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"/> -->
<table tableName="t_device_location" domainObjectName="DeviceLocation" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"/>
</context>
</generatorConfiguration>
\ No newline at end of file
<?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.DeviceLocationMapper">
<resultMap id="BaseResultMap" type="cn.com.glsx.admin.modules.entity.DeviceLocation">
<!--
WARNING - @mbg.generated
-->
<id column="id" jdbcType="INTEGER" property="id" />
<result column="sn" jdbcType="VARCHAR" property="sn" />
<result column="last_gps_time" jdbcType="TIMESTAMP" property="lastGpsTime" />
<result column="last_bs_time" jdbcType="TIMESTAMP" property="lastBsTime" />
<result column="speed" jdbcType="INTEGER" property="speed" />
<result column="stay_status" jdbcType="TINYINT" property="stayStatus" />
<result column="stay_status_updatetime" jdbcType="TIMESTAMP" property="stayStatusUpdatetime" />
<result column="created_time" jdbcType="TIMESTAMP" property="createdTime" />
<result column="updated_time" jdbcType="TIMESTAMP" property="updatedTime" />
</resultMap>
<sql id="Base_Column_List">
<!--
WARNING - @mbg.generated
-->
id, sn, last_gps_time, last_bs_time, speed, stay_status, stay_status_updatetime,
created_time, updated_time
</sql>
<!-- findLocationListBySnList -->
<select id="findLocationListBySnList" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
FROM t_device_location
where sn in
<foreach collection="snList" separator="," open="(" close=")" item="item">
#{item}
</foreach>
</select>
</mapper>
\ No newline at end of file
......@@ -509,6 +509,7 @@
tw.partner_order_no bizOrderNo,
tv.owner_name ownerName,
tv.vin ,
tw.shop_name as shopName ,
tvd.sn ,
td.source deviceType,
case when td.source = 1 then '有线' when td.source = 0 then '无线' else '--' end as deviceTypeStr,
......@@ -517,7 +518,7 @@
tv.vehicle_type vehicleType,
tv.vehicle_usages vehicleUsages,
tv.settle_flag settleFlag,
tv.created_date activateTime,
tv.created_date activateTime
<!--(SELECT temp.status FROM t_device_freq temp where temp.vehicle_id = tv.id and temp.sn = tvd.sn order by created_date desc limit 1) AS freqStatus,-->
tv.created_by createdBy
from t_vehicle tv
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!