Commit 2cbcca77 authored by 耿迪迪's avatar 耿迪迪

位置信息入库

parent 9d695d48
......@@ -50,6 +50,19 @@
<artifactId>spring-boot-starter-cache</artifactId>
</dependency>
<!--mysql数据库驱动-->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<!--mybatis-->
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>2.1.0</version>
</dependency>
</dependencies>
<build>
......
package com.zehong;
import org.mybatis.spring.annotation.MapperScan;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.SpringApplication;
......@@ -10,6 +11,7 @@ import org.springframework.scheduling.annotation.EnableScheduling;
@EnableCaching
@EnableScheduling
@SpringBootApplication
@MapperScan("com.zehong.**.mapper")
public class VehicleActualPositionApplication {
private static final Logger log = LoggerFactory.getLogger(VehicleActualPositionApplication.class);
......
package com.zehong.web.endpoint;
import com.zehong.commons.util.CoordTransform;
import com.zehong.protocol.basics.JTMessage;
import com.zehong.protocol.commons.JT808;
import com.zehong.protocol.t808.*;
import com.zehong.web.model.entity.DeviceDO;
import com.zehong.web.model.entity.TReportVehicleLocation;
import com.zehong.web.model.enums.SessionKey;
import com.zehong.web.service.FileService;
import com.zehong.web.service.ITReportVehicleLocationService;
import io.github.yezhihao.netmc.core.annotation.Async;
import io.github.yezhihao.netmc.core.annotation.AsyncBatch;
import io.github.yezhihao.netmc.core.annotation.Endpoint;
......@@ -9,15 +18,14 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import com.zehong.protocol.basics.JTMessage;
import com.zehong.protocol.commons.JT808;
import com.zehong.protocol.t808.*;
import com.zehong.web.model.entity.DeviceDO;
import com.zehong.web.model.enums.SessionKey;
import com.zehong.web.service.FileService;
import org.springframework.util.CollectionUtils;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.ZoneOffset;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import static com.zehong.protocol.commons.JT808.*;
......@@ -31,6 +39,9 @@ public class JT808Endpoint {
@Autowired
private FileService fileService;
@Autowired
private ITReportVehicleLocationService reportVehicleLocationService;
@Mapping(types = 终端通用应答, desc = "终端通用应答")
public Object T0001(T0001 message, Session session) {
session.response(message);
......@@ -116,6 +127,20 @@ public class JT808Endpoint {
@Mapping(types = 位置信息汇报, desc = "位置信息汇报")
public void T0200(List<T0200> list) {
log.info("=========locationInfo============" + list.toString());
if(!CollectionUtils.isEmpty(list)){
List<TReportVehicleLocation> locations = new ArrayList<>();
for(T0200 info : list){
TReportVehicleLocation location = new TReportVehicleLocation();
location.setTerminalPhone(info.getClientId());
double[] lngLat = {info.getLongitude()/Math.pow(10,6),info.getLatitude()/Math.pow(10,6)};
double[] transLngLat = CoordTransform.wgs84togcj02(lngLat);
location.setLongitude(new BigDecimal(transLngLat[0]));
location.setLatitude(new BigDecimal(transLngLat[1]));
location.setReportTime(Date.from(info.getDeviceTime().atZone(ZoneId.systemDefault()).toInstant()));
locations.add(location);
}
reportVehicleLocationService.batchInsertReportVehicleLocationInfo(locations);
}
}
@Mapping(types = 定位数据批量上传, desc = "定位数据批量上传")
......
package com.zehong.web.mapper;
import com.zehong.web.model.entity.TReportVehicleLocation;
import java.util.List;
/**
* 车辆上报位置信息Mapper接口
*
* @author zehong
* @date 2024-08-21
*/
public interface TReportVehicleLocationMapper
{
/**
* 查询车辆上报位置信息
*
* @param locationId 车辆上报位置信息ID
* @return 车辆上报位置信息
*/
TReportVehicleLocation selectTReportVehicleLocationById(Long locationId);
/**
* 查询车辆上报位置信息列表
*
* @param tReportVehicleLocation 车辆上报位置信息
* @return 车辆上报位置信息集合
*/
List<TReportVehicleLocation> selectTReportVehicleLocationList(TReportVehicleLocation tReportVehicleLocation);
/**
* 新增车辆上报位置信息
*
* @param tReportVehicleLocation 车辆上报位置信息
* @return 结果
*/
int insertTReportVehicleLocation(TReportVehicleLocation tReportVehicleLocation);
/**
* 修改车辆上报位置信息
*
* @param tReportVehicleLocation 车辆上报位置信息
* @return 结果
*/
int updateTReportVehicleLocation(TReportVehicleLocation tReportVehicleLocation);
/**
* 删除车辆上报位置信息
*
* @param locationId 车辆上报位置信息ID
* @return 结果
*/
int deleteTReportVehicleLocationById(Long locationId);
/**
* 批量删除车辆上报位置信息
*
* @param locationIds 需要删除的数据ID
* @return 结果
*/
int deleteTReportVehicleLocationByIds(Long[] locationIds);
/**
* 批量新增车辆位置信息
* @param list
* @return
*/
int batchInsertReportVehicleLocationInfo(List<TReportVehicleLocation> list);
}
package com.zehong.web.model.entity;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import java.math.BigDecimal;
import java.util.Date;
/**
* 车辆上报位置信息对象 t_report_vehicle_location
*
* @author zehong
* @date 2024-08-21
*/
public class TReportVehicleLocation {
private static final long serialVersionUID = 1L;
/** 定位主键 */
private Long locationId;
/** 终端手机号 */
private String terminalPhone;
/** 经度 */
private BigDecimal longitude;
/** 纬度 */
private BigDecimal latitude;
/** 创建时间 */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date reportTime;
/** 是否删除(0正常,1删除) */
private String isDel;
/** 备注 */
private String remarks;
public void setLocationId(Long locationId)
{
this.locationId = locationId;
}
public Long getLocationId()
{
return locationId;
}
public void setTerminalPhone(String terminalPhone)
{
this.terminalPhone = terminalPhone;
}
public String getTerminalPhone()
{
return terminalPhone;
}
public void setLongitude(BigDecimal longitude)
{
this.longitude = longitude;
}
public BigDecimal getLongitude()
{
return longitude;
}
public void setLatitude(BigDecimal latitude)
{
this.latitude = latitude;
}
public BigDecimal getLatitude()
{
return latitude;
}
public void setReportTime(Date reportTime)
{
this.reportTime = reportTime;
}
public Date getReportTime()
{
return reportTime;
}
public void setIsDel(String isDel)
{
this.isDel = isDel;
}
public String getIsDel()
{
return isDel;
}
public void setRemarks(String remarks)
{
this.remarks = remarks;
}
public String getRemarks()
{
return remarks;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("locationId", getLocationId())
.append("terminalPhone", getTerminalPhone())
.append("longitude", getLongitude())
.append("latitude", getLatitude())
.append("reportTime", getReportTime())
.append("isDel", getIsDel())
.append("remarks", getRemarks())
.toString();
}
}
package com.zehong.web.service;
import com.zehong.web.model.entity.TReportVehicleLocation;
import java.util.List;
/**
* 车辆上报位置信息Service接口
*
* @author zehong
* @date 2024-08-21
*/
public interface ITReportVehicleLocationService
{
/**
* 查询车辆上报位置信息
*
* @param locationId 车辆上报位置信息ID
* @return 车辆上报位置信息
*/
TReportVehicleLocation selectTReportVehicleLocationById(Long locationId);
/**
* 查询车辆上报位置信息列表
*
* @param tReportVehicleLocation 车辆上报位置信息
* @return 车辆上报位置信息集合
*/
List<TReportVehicleLocation> selectTReportVehicleLocationList(TReportVehicleLocation tReportVehicleLocation);
/**
* 新增车辆上报位置信息
*
* @param tReportVehicleLocation 车辆上报位置信息
* @return 结果
*/
int insertTReportVehicleLocation(TReportVehicleLocation tReportVehicleLocation);
/**
* 修改车辆上报位置信息
*
* @param tReportVehicleLocation 车辆上报位置信息
* @return 结果
*/
int updateTReportVehicleLocation(TReportVehicleLocation tReportVehicleLocation);
/**
* 批量删除车辆上报位置信息
*
* @param locationIds 需要删除的车辆上报位置信息ID
* @return 结果
*/
int deleteTReportVehicleLocationByIds(Long[] locationIds);
/**
* 删除车辆上报位置信息信息
*
* @param locationId 车辆上报位置信息ID
* @return 结果
*/
int deleteTReportVehicleLocationById(Long locationId);
/**
* 批量新增车辆位置信息
* @param list
* @return
*/
int batchInsertReportVehicleLocationInfo(List<TReportVehicleLocation> list);
}
package com.zehong.web.service.impl;
import com.zehong.web.mapper.TReportVehicleLocationMapper;
import com.zehong.web.model.entity.TReportVehicleLocation;
import com.zehong.web.service.ITReportVehicleLocationService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.List;
/**
* 车辆上报位置信息Service业务层处理
*
* @author zehong
* @date 2024-08-21
*/
@Service
public class TReportVehicleLocationServiceImpl implements ITReportVehicleLocationService
{
@Resource
private TReportVehicleLocationMapper tReportVehicleLocationMapper;
/**
* 查询车辆上报位置信息
*
* @param locationId 车辆上报位置信息ID
* @return 车辆上报位置信息
*/
@Override
public TReportVehicleLocation selectTReportVehicleLocationById(Long locationId)
{
return tReportVehicleLocationMapper.selectTReportVehicleLocationById(locationId);
}
/**
* 查询车辆上报位置信息列表
*
* @param tReportVehicleLocation 车辆上报位置信息
* @return 车辆上报位置信息
*/
@Override
public List<TReportVehicleLocation> selectTReportVehicleLocationList(TReportVehicleLocation tReportVehicleLocation)
{
return tReportVehicleLocationMapper.selectTReportVehicleLocationList(tReportVehicleLocation);
}
/**
* 新增车辆上报位置信息
*
* @param tReportVehicleLocation 车辆上报位置信息
* @return 结果
*/
@Override
public int insertTReportVehicleLocation(TReportVehicleLocation tReportVehicleLocation)
{
return tReportVehicleLocationMapper.insertTReportVehicleLocation(tReportVehicleLocation);
}
/**
* 修改车辆上报位置信息
*
* @param tReportVehicleLocation 车辆上报位置信息
* @return 结果
*/
@Override
public int updateTReportVehicleLocation(TReportVehicleLocation tReportVehicleLocation)
{
return tReportVehicleLocationMapper.updateTReportVehicleLocation(tReportVehicleLocation);
}
/**
* 批量删除车辆上报位置信息
*
* @param locationIds 需要删除的车辆上报位置信息ID
* @return 结果
*/
@Override
public int deleteTReportVehicleLocationByIds(Long[] locationIds)
{
return tReportVehicleLocationMapper.deleteTReportVehicleLocationByIds(locationIds);
}
/**
* 删除车辆上报位置信息信息
*
* @param locationId 车辆上报位置信息ID
* @return 结果
*/
@Override
public int deleteTReportVehicleLocationById(Long locationId)
{
return tReportVehicleLocationMapper.deleteTReportVehicleLocationById(locationId);
}
/**
* 批量新增车辆位置信息
* @param list
* @return
*/
@Transactional(rollbackFor = Exception.class)
public int batchInsertReportVehicleLocationInfo(List<TReportVehicleLocation> list){
return tReportVehicleLocationMapper.batchInsertReportVehicleLocationInfo(list);
}
}
......@@ -13,4 +13,12 @@ jt-server:
alarm-file:
enable: true
port: 7612
path: /www/vehicleActualPositionls/jt_data/alarm_file
\ No newline at end of file
path: /www/vehicleActualPositionls/jt_data/alarm_file
#mysql
spring:
datasource:
username: jkqrq
password: ME3A3aWytZKASGJn
url: jdbc:mysql://110.249.142.166:33060/economic_opening?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
driver-class-name: com.mysql.cj.jdbc.Driver
......@@ -14,4 +14,12 @@ jt-server:
alarm-file:
enable: true
port: 7612
path: D:/jt_data/alarm_file
\ No newline at end of file
path: D:/jt_data/alarm_file
#mysql
spring:
datasource:
username: jkqrq
password: ME3A3aWytZKASGJn
url: jdbc:mysql://110.249.142.166:33060/economic_opening?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
driver-class-name: com.mysql.cj.jdbc.Driver
......@@ -28,4 +28,13 @@ logging:
com.zehong: debug
org.springframework: warn
file:
path: ./logs
\ No newline at end of file
path: ./logs
#mybatis的相关配置
mybatis:
#mapper配置文件
mapper-locations: classpath:mapper/*.xml
type-aliases-package: com.zehong.web.model.entity
#开启驼峰命名
configuration:
map-underscore-to-camel-case: true
\ 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="com.zehong.web.mapper.TReportVehicleLocationMapper">
<resultMap type="TReportVehicleLocation" id="TReportVehicleLocationResult">
<result property="locationId" column="location_id" />
<result property="terminalPhone" column="terminal_phone" />
<result property="longitude" column="longitude" />
<result property="latitude" column="latitude" />
<result property="reportTime" column="report_time" />
<result property="isDel" column="is_del" />
<result property="remarks" column="remarks" />
</resultMap>
<sql id="selectTReportVehicleLocationVo">
select location_id, terminal_phone, longitude, latitude, report_time, is_del, remarks from t_report_vehicle_location
</sql>
<select id="selectTReportVehicleLocationList" parameterType="TReportVehicleLocation" resultMap="TReportVehicleLocationResult">
<include refid="selectTReportVehicleLocationVo"/>
<where>
<if test="terminalPhone != null and terminalPhone != ''"> and terminal_phone = #{terminalPhone}</if>
</where>
</select>
<select id="selectTReportVehicleLocationById" parameterType="Long" resultMap="TReportVehicleLocationResult">
<include refid="selectTReportVehicleLocationVo"/>
where location_id = #{locationId}
</select>
<insert id="insertTReportVehicleLocation" parameterType="TReportVehicleLocation" useGeneratedKeys="true" keyProperty="locationId">
insert into t_report_vehicle_location
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="terminalPhone != null">terminal_phone,</if>
<if test="longitude != null">longitude,</if>
<if test="latitude != null">latitude,</if>
<if test="reportTime != null">report_time,</if>
<if test="isDel != null">is_del,</if>
<if test="remarks != null">remarks,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="terminalPhone != null">#{terminalPhone},</if>
<if test="longitude != null">#{longitude},</if>
<if test="latitude != null">#{latitude},</if>
<if test="reportTime != null">#{reportTime},</if>
<if test="isDel != null">#{isDel},</if>
<if test="remarks != null">#{remarks},</if>
</trim>
</insert>
<update id="updateTReportVehicleLocation" parameterType="TReportVehicleLocation">
update t_report_vehicle_location
<trim prefix="SET" suffixOverrides=",">
<if test="terminalPhone != null">terminal_phone = #{terminalPhone},</if>
<if test="longitude != null">longitude = #{longitude},</if>
<if test="latitude != null">latitude = #{latitude},</if>
<if test="reportTime != null">report_time = #{reportTime},</if>
<if test="isDel != null">is_del = #{isDel},</if>
<if test="remarks != null">remarks = #{remarks},</if>
</trim>
where location_id = #{locationId}
</update>
<delete id="deleteTReportVehicleLocationById" parameterType="Long">
delete from t_report_vehicle_location where location_id = #{locationId}
</delete>
<delete id="deleteTReportVehicleLocationByIds" parameterType="String">
delete from t_report_vehicle_location where location_id in
<foreach item="locationId" collection="array" open="(" separator="," close=")">
#{locationId}
</foreach>
</delete>
<insert id="batchInsertReportVehicleLocationInfo" parameterType="java.util.List" useGeneratedKeys="true" keyProperty="locationId">
insert into t_report_vehicle_location(terminal_phone,longitude,latitude,report_time,is_del,remarks)
values
<foreach collection="list" item="item" separator=",">
(#{item.terminalPhone},#{item.longitude},#{item.latitude},#{item.reportTime},#{item.isDel},#{item.remarks})
</foreach>
</insert>
</mapper>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment