根据vin查询所有电子围栏
parent
bcc839a73c
commit
f04191932d
|
@ -37,7 +37,7 @@ public class FenceTag {
|
|||
* 字段属性:围栏标签主键id
|
||||
*/
|
||||
@TableId(type = IdType.AUTO)
|
||||
private String fenceTagId;
|
||||
private Integer fenceTagId;
|
||||
/**
|
||||
* 字段属性:围栏标签名称
|
||||
*/
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
package com.dragon.vehicle.history.domain.common;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 车辆围栏标签的中间表
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class VehicleTag {
|
||||
private Integer vehicleTagId;
|
||||
private Integer fenceTagId;
|
||||
private Integer carVin;
|
||||
private String createdBy;
|
||||
private Date createdTime;
|
||||
private String updatedBy;
|
||||
private Date updatedTime;
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
package com.dragon.vehicle.history.domain.common.resp;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 响应车辆的电子围栏
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class AddVehicleTagResp {
|
||||
private Integer vehicleTagId;
|
||||
private Integer fenceTagId;
|
||||
private Integer fenceId;
|
||||
private String createdBy;
|
||||
private Date createdTime;
|
||||
private String updatedBy;
|
||||
private Date updatedTime;
|
||||
}
|
|
@ -0,0 +1,58 @@
|
|||
package com.dragon.vehicle.history.domain.common.resp;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 响应的电子围栏列表
|
||||
*/
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class SelFenceResp {
|
||||
/**
|
||||
* 字段属性:围栏主键id
|
||||
*/
|
||||
private Integer fenceId;
|
||||
/**
|
||||
* 字段属性:围栏名称
|
||||
*/
|
||||
private String fenceName;
|
||||
/**
|
||||
* 字段属性:围栏数据
|
||||
*/
|
||||
private String fenceData;
|
||||
/**s
|
||||
* 字段属性:围栏状态
|
||||
*/
|
||||
private Integer status;
|
||||
/**
|
||||
* 字段属性:告警类型
|
||||
*/
|
||||
private Integer alarmType;
|
||||
/**
|
||||
* 字段属性:围栏标签id
|
||||
*/
|
||||
private Integer fenceTagId;
|
||||
/**
|
||||
* 字段属性:创建人
|
||||
*/
|
||||
private String createdBy;
|
||||
/**
|
||||
* 字段属性:创建时间
|
||||
*/
|
||||
private Date createdTime;
|
||||
/**
|
||||
* 字段属性:更新人
|
||||
*/
|
||||
private String updatedBy;
|
||||
/**
|
||||
* 字段属性:更新时间
|
||||
*/
|
||||
private Date updatedTime;
|
||||
}
|
|
@ -110,5 +110,4 @@ public class WebLogAspect {
|
|||
}
|
||||
return description.toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ import com.dragon.vehicle.fence.server.aop.WebLog;
|
|||
import com.dragon.vehicle.fence.server.service.FenceTagService;
|
||||
import com.dragon.vehicle.history.domain.common.Fence;
|
||||
import com.dragon.vehicle.history.domain.common.FenceTag;
|
||||
import com.dragon.vehicle.history.domain.common.Point;
|
||||
import com.dragon.vehicle.history.domain.common.req.AddFenceTagReq;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
@ -50,9 +51,9 @@ public class FenceTagController {
|
|||
return Result.success(tagService.save(fenceTag),"添加围栏成功");
|
||||
}
|
||||
|
||||
@PostMapping("/carAndFence")
|
||||
public Result CarAndFence(){
|
||||
|
||||
return null;
|
||||
@PostMapping("/carAndFence")
|
||||
public Result CarAndFence(@RequestBody Point point){
|
||||
return tagService.CarAndFence(point);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ import com.dragon.vehicle.fence.server.mapper.VehicleFenceMapper;
|
|||
import com.dragon.vehicle.history.domain.common.Fence;
|
||||
import com.dragon.vehicle.fence.server.service.VehicleFenceService;
|
||||
import com.dragon.vehicle.history.domain.common.req.AddFenceReq;
|
||||
import com.dragon.vehicle.history.domain.common.resp.SelFenceResp;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
|
@ -67,6 +68,16 @@ public class VehicleFenceController {
|
|||
return Result.success(vehicleFenceMapper.updateById(fence),"添加围栏数据成功");
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据vin查询所有的电子围栏
|
||||
* @param vin
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/queryBy/{vin}")
|
||||
public Result<List<SelFenceResp>> queryBy(@PathVariable String vin){
|
||||
return vehicleFenceService.queryBy(vin);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -2,7 +2,12 @@ package com.dragon.vehicle.fence.server.mapper;
|
|||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.dragon.vehicle.history.domain.common.Fence;
|
||||
import com.dragon.vehicle.history.domain.common.FenceTag;
|
||||
import com.dragon.vehicle.history.domain.common.resp.SelFenceResp;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -13,4 +18,8 @@ import org.apache.ibatis.annotations.Mapper;
|
|||
*/
|
||||
@Mapper
|
||||
public interface VehicleFenceMapper extends BaseMapper<Fence> {
|
||||
|
||||
List<FenceTag> queryBy(@Param("vin") String vin);
|
||||
|
||||
List<SelFenceResp> selectIdFence(@Param("fenceTagId") Integer fenceTagId);
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
|||
import com.dragon.common.core.domain.Result;
|
||||
import com.dragon.vehicle.history.domain.common.Fence;
|
||||
import com.dragon.vehicle.history.domain.common.FenceTag;
|
||||
import com.dragon.vehicle.history.domain.common.Point;
|
||||
import com.dragon.vehicle.history.domain.common.req.AddFenceTagReq;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
|
@ -14,4 +15,6 @@ public interface FenceTagService extends IService<FenceTag> {
|
|||
Result<List<Fence>> selectIdFence(Integer fenceTagId);
|
||||
|
||||
FenceTag insert(AddFenceTagReq addFenceTagReq);
|
||||
|
||||
Result CarAndFence(Point point);
|
||||
}
|
||||
|
|
|
@ -1,12 +1,18 @@
|
|||
package com.dragon.vehicle.fence.server.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.dragon.common.core.domain.Result;
|
||||
import com.dragon.vehicle.history.domain.common.Fence;
|
||||
import com.dragon.vehicle.history.domain.common.req.AddFenceReq;
|
||||
import com.dragon.vehicle.history.domain.common.resp.SelFenceResp;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface VehicleFenceService extends IService<Fence> {
|
||||
|
||||
Fence insertFence(AddFenceReq addFenceReq);
|
||||
|
||||
Fence updateFence(AddFenceReq addFenceReq);
|
||||
|
||||
Result<List<SelFenceResp>> queryBy(String vin);
|
||||
}
|
||||
|
|
|
@ -6,13 +6,19 @@ import com.dragon.vehicle.fence.server.mapper.FenceTagMapper;
|
|||
import com.dragon.vehicle.fence.server.service.FenceTagService;
|
||||
import com.dragon.vehicle.history.domain.common.Fence;
|
||||
import com.dragon.vehicle.history.domain.common.FenceTag;
|
||||
import com.dragon.vehicle.history.domain.common.Point;
|
||||
import com.dragon.vehicle.history.domain.common.req.AddFenceTagReq;
|
||||
import com.dragon.vehicle.history.domain.utils.PolygonUtil;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.awt.geom.Point2D;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
@Log4j2
|
||||
public class FenceTagServiceImpl extends ServiceImpl<FenceTagMapper, FenceTag> implements FenceTagService{
|
||||
@Autowired
|
||||
private FenceTagMapper fenceTagMapper;
|
||||
|
@ -30,4 +36,41 @@ public class FenceTagServiceImpl extends ServiceImpl<FenceTagMapper, FenceTag> i
|
|||
return new FenceTag();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result CarAndFence(Point point) {
|
||||
/*Point2D.Double point = new Point2D.Double();
|
||||
point.setLocation(116.52759064548436,39.88327456453143);
|
||||
List<Point2D.Double> pts = new ArrayList<>();
|
||||
Point2D.Double point1 = new Point2D.Double();
|
||||
point1.setLocation(116.48965348217772,39.90816602515441);
|
||||
Point2D.Double point2 = new Point2D.Double();
|
||||
point2.setLocation(116.54338349316404,39.9097461301072);
|
||||
Point2D.Double point3 = new Point2D.Double();
|
||||
point3.setLocation(116.54836167309568,39.8699690729595);
|
||||
Point2D.Double point4 = new Point2D.Double();
|
||||
point4.setLocation(116.4889668366699,39.87181355267268);
|
||||
pts.add(point1);
|
||||
pts.add(point2);
|
||||
pts.add(point3);
|
||||
pts.add(point4);
|
||||
boolean inPolygon = isInPolygon(point,pts);
|
||||
System.out.println(inPolygon);*/
|
||||
//通过中间表拿到当前车辆id绑定的电子围栏的数据
|
||||
|
||||
Point2D.Double point1= new Point2D.Double();
|
||||
point1.setLocation(point1.x,point1.y);
|
||||
List<Point2D.Double> pts = new ArrayList<>();
|
||||
|
||||
for (int i = 0; i < pts.size(); i++) {
|
||||
|
||||
}
|
||||
boolean inPolygon = PolygonUtil.isInPolygon(point1, pts);
|
||||
if (!inPolygon){
|
||||
log.info("目标车辆驶出报警~");
|
||||
log.info("车都开不明白,回家吃奶去吧~");
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,19 +1,26 @@
|
|||
package com.dragon.vehicle.fence.server.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.dragon.common.core.domain.Result;
|
||||
import com.dragon.common.security.utils.SecurityUtils;
|
||||
import com.dragon.system.common.domain.SysUser;
|
||||
import com.dragon.vehicle.fence.server.mapper.VehicleFenceMapper;
|
||||
import com.dragon.vehicle.history.domain.common.Fence;
|
||||
import com.dragon.vehicle.fence.server.service.VehicleFenceService;
|
||||
import com.dragon.vehicle.history.domain.common.FenceTag;
|
||||
import com.dragon.vehicle.history.domain.common.req.AddFenceReq;
|
||||
import com.dragon.vehicle.history.domain.common.resp.SelFenceResp;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@Service
|
||||
public class VehicleFenceServiceImpl extends ServiceImpl<VehicleFenceMapper, Fence> implements VehicleFenceService {
|
||||
@Autowired
|
||||
private VehicleFenceMapper vehicleFenceMapper;
|
||||
@Override
|
||||
public Fence insertFence(AddFenceReq addFenceReq) {
|
||||
Fence fence = new Fence();
|
||||
|
@ -36,4 +43,16 @@ public class VehicleFenceServiceImpl extends ServiceImpl<VehicleFenceMapper, Fen
|
|||
fence.setFenceData(addFenceReq.getFenceData());
|
||||
return fence;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result<List<SelFenceResp>> queryBy(String vin) {
|
||||
//查询vin下所有的电子围栏标签表
|
||||
List<FenceTag> fences = vehicleFenceMapper.queryBy(vin);
|
||||
List<SelFenceResp> fences1 = null;
|
||||
for (FenceTag fence : fences) {
|
||||
fences1 = vehicleFenceMapper.selectIdFence(fence.getFenceTagId());
|
||||
}
|
||||
Result<List<SelFenceResp>> result = Result.success(fences1);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,18 @@
|
|||
<?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.dragon.vehicle.fence.server.mapper.VehicleFenceMapper">
|
||||
|
||||
|
||||
<select id="queryBy" resultType="com.dragon.vehicle.history.domain.common.FenceTag">
|
||||
select
|
||||
f.*
|
||||
from vehicle_tag v
|
||||
left join car c on v.car_vin = c.car_vin
|
||||
left join fence_tag f on v.car_vin = c.car_vin
|
||||
where
|
||||
c.car_vin = #{vin}
|
||||
</select>
|
||||
<select id="selectIdFence" resultType="com.dragon.vehicle.history.domain.common.resp.SelFenceResp">
|
||||
select*from fence where fence_tag_id = #{fenceTagId}
|
||||
</select>
|
||||
</mapper>
|
||||
|
|
Loading…
Reference in New Issue