aijinhui
2023-11-01 9dbd1b03adca3920a249b9079153d5f53d01a47d
清淤数据逻辑
已修改4个文件
185 ■■■■■ 文件已修改
ard-work/src/main/java/com/ruoyi/sy/controller/OilWallController.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ard-work/src/main/java/com/ruoyi/sy/domain/ArdAccessFence.java 5 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ard-work/src/main/java/com/ruoyi/sy/domain/ArdAccessNum.java 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ard-work/src/main/java/com/ruoyi/sy/gps31/PushClientImplPosition.java 172 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ard-work/src/main/java/com/ruoyi/sy/controller/OilWallController.java
@@ -8,7 +8,6 @@
import com.ruoyi.sy.domain.*;
import com.ruoyi.sy.param.OilWallParam;
import com.ruoyi.sy.service.*;
import com.ruoyi.system.service.ISysConfigService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
@@ -101,6 +100,5 @@
    public AjaxResult updTime(@RequestBody ArdAccessNum ardAccessNum){
        return AjaxResult.success(ardAccessNumService.add(ardAccessNum));
    }
}
ard-work/src/main/java/com/ruoyi/sy/domain/ArdAccessFence.java
@@ -20,6 +20,9 @@
    private String intoUnloadTime;
    private String outShipmentId;
    private String outShipmentTime;
    private String lastTime;
    private String isWarning;
    private String isDel;
    private String nowWallName;
    private String alarmLng;
    private String alarmLat;
}
ard-work/src/main/java/com/ruoyi/sy/domain/ArdAccessNum.java
@@ -7,7 +7,7 @@
 */
@Data
public class ArdAccessNum {
    private String id;
    private String name;
    private String num;
    private int carousel;
    private int call;
    private int alarm;
}
ard-work/src/main/java/com/ruoyi/sy/gps31/PushClientImplPosition.java
@@ -14,6 +14,7 @@
import com.gps31.push.util.MapUtil;
import com.ruoyi.common.utils.spring.SpringUtils;
import com.ruoyi.sy.domain.ArdAccessFence;
import com.ruoyi.sy.domain.ArdAccessNum;
import com.ruoyi.sy.domain.ArdOilWall;
import com.ruoyi.sy.domain.ArdSyCarLock;
import com.ruoyi.sy.service.ArdAccessFenceService;
@@ -24,6 +25,7 @@
import org.apache.commons.logging.LogFactory;
import java.awt.geom.Point2D;
import java.text.SimpleDateFormat;
import java.util.*;
/**
@@ -93,10 +95,11 @@
                List<Point2D.Double> pts = new ArrayList<Point2D.Double>();
                //查询定位油车表中是否有该车辆
                ArdAccessFence ardAccessFence = SpringUtils.getBean(ArdAccessFenceService.class).queryAccess(carId);
                //查询所有装油点围栏
                List<ArdOilWall> ardOilWalls = SpringUtils.getBean(ArdOilWallService.class).accessAll();
                //如果没有说明车辆未进入装油点,需要匹配所有装油点围栏
                if(ardAccessFence==null){
                    //车辆未进入装油点
                    List<ArdOilWall> ardOilWalls = SpringUtils.getBean(ArdOilWallService.class).accessAll();
                    for (int i = 0; i < ardOilWalls.size(); i++) {
                        pts.clear();
                        ArdOilWall ardOilWall = ardOilWalls.get(i);
@@ -116,81 +119,130 @@
                            ardAccessFence1.setIntoShipmentTime(time);
                            ardAccessFence1.setLng(lng);
                            ardAccessFence1.setLat(lat);
                            ardAccessFence1.setLastTime(time);
                            ardAccessFence1.setNowWallName(ardOilWall.getName());
                            ((ArdAccessFenceServiceImpl)SpringUtils.getBean("ArdAccessFenceServiceImpl")).access(ardAccessFence1);
                            break;
                        }
                    }
                }else {
                    //如果车辆有数据判断是否有进入围栏ID,如果没有更新或赋值经纬度,判断是否进入围栏
                    //如果有进入围栏ID,判断是否开出装油点
                    String out = ardAccessFence.getOutShipmentId();
                    if(out == null){
                        //车辆未开出装油点
                        String into = ardAccessFence.getIntoShipmentId();
                        ArdOilWall ardOilWall = SpringUtils.getBean(ArdOilWallService.class).one(into);
                        pts.clear();
                        String[] coord = ardOilWall.getCoord().split(",");
                        for (int j = 0; j < coord.length; j = j + 3) {
                            pts.add(new Point2D.Double(Double.parseDouble(coord[j]), Double.parseDouble(coord[j + 1])));
                        }
                        if (!GeoTools.IsPtInPoly(point, pts)) {
                            //车辆开出装油点
                            ardAccessFence.setOutShipmentId(into);
                            ardAccessFence.setOutShipmentTime(time);
                        }
                    if(ardAccessFence.getIntoShipmentId()==null){
                        ardAccessFence.setLng(lng);
                        ardAccessFence.setLat(lat);
                        SpringUtils.getBean(ArdAccessFenceService.class).updAccess(ardAccessFence);
                        for (int i = 0; i < ardOilWalls.size(); i++) {
                            pts.clear();
                            ArdOilWall ardOilWall = ardOilWalls.get(i);
                            String[] coord = ardOilWall.getCoord().split(",");
                            for (int j = 0; j < coord.length; j = j + 3) {
                                pts.add(new Point2D.Double(Double.parseDouble(coord[j]), Double.parseDouble(coord[j+1])));
                            }
                            if(GeoTools.IsPtInPoly(point, pts)){
                                //进入装油点入库
                                ardAccessFence.setIntoShipmentId(ardOilWall.getId());
                                ardAccessFence.setIntoShipmentTime(time);
                                ardAccessFence.setNowWallName(ardOilWall.getName());
                                ardAccessFence.setLastTime(time);
                                break;
                            }
                        }
                        ((ArdAccessFenceServiceImpl)SpringUtils.getBean("ArdAccessFenceServiceImpl")).updAccess(ardAccessFence);
                    }else {
                        //车辆已经开出装油点,判断是否进入卸油点
                        String unload = ardAccessFence.getIntoUnloadId();
                        //如果unload为空,判断是否进入卸油点
                        if (unload == null) {
                            //车辆未进入卸油点
                            List<ArdOilWall> ardOilWalls = SpringUtils.getBean(ArdOilWallService.class).uploadAll();
                            //是否在路上
                            Boolean isRoad = true;
                            for (int i = 0; i < ardOilWalls.size(); i++) {
                                pts.clear();
                                ArdOilWall ardOilWall = ardOilWalls.get(i);
                                String[] coord = ardOilWall.getCoord().split(",");
                                for (int j = 0; j < coord.length; j = j + 3) {
                                    pts.add(new Point2D.Double(Double.parseDouble(coord[j]), Double.parseDouble(coord[j + 1])));
                                }
                                if (GeoTools.IsPtInPoly(point, pts)) {
                                    //进入卸油点,存入卸油点围栏ID
                                    ardAccessFence.setIntoUnloadId(ardOilWall.getId());
                                    ardAccessFence.setIntoUnloadTime(time);
                                    ardAccessFence.setLng(lng);
                                    ardAccessFence.setLat(lat);
                                    ((ArdAccessFenceServiceImpl) SpringUtils.getBean("ArdAccessFenceServiceImpl")).updAccess(ardAccessFence);
                                    //已经进入卸油点,不在路上不需要停车报警
                                    isRoad = false;
                                    break;
                                }
                            }
                            if(isRoad){
                                //如果在路上需要记录每次坐标与上次是否相同,如果一样更新停留时间
                            }
                        }else {
                            //车辆已经进入卸油点,判断是否已经开出卸油点
                            ArdOilWall ardOilWall = ((ArdOilWallServiceImpl) SpringUtils.getBean("ArdOilWallServiceImpl")).one(unload);
                        //如果有进入围栏ID,判断是否开出装油点
                        String out = ardAccessFence.getOutShipmentId();
                        if(out == null){
                            //车辆未开出装油点
                            String into = ardAccessFence.getIntoShipmentId();
                            ArdOilWall ardOilWall = SpringUtils.getBean(ArdOilWallService.class).one(into);
                            pts.clear();
                            String[] coord = ardOilWall.getCoord().split(",");
                            for (int j = 0; j < coord.length; j = j + 3) {
                                pts.add(new Point2D.Double(Double.parseDouble(coord[j]), Double.parseDouble(coord[j + 1])));
                            }
                            if (!GeoTools.IsPtInPoly(point, pts)) {
                                //开出了卸油点围栏,删除该条车辆数据
                                ((ArdAccessFenceServiceImpl) SpringUtils.getBean("ArdAccessFenceServiceImpl")).delAccess(carId);
                                //车辆开出装油点
                                ardAccessFence.setOutShipmentId(into);
                                ardAccessFence.setOutShipmentTime(time);
                                ardAccessFence.setNowWallName(ardOilWall.getName());
                                ardAccessFence.setLastTime(time);
                            }
                            ardAccessFence.setLng(lng);
                            ardAccessFence.setLat(lat);
                            ((ArdAccessFenceServiceImpl) SpringUtils.getBean("ArdAccessFenceServiceImpl")).updAccess(ardAccessFence);
                        }else {
                            //车辆已经开出装油点,判断是否进入卸油点
                            String unload = ardAccessFence.getIntoUnloadId();
                            //如果unload为空,判断是否进入卸油点
                            if (unload == null) {
                                //车辆未进入卸油点
                                List<ArdOilWall> ardOilWallUpload = SpringUtils.getBean(ArdOilWallService.class).uploadAll();
                                //是否在路上
                                Boolean isRoad = true;
                                for (int i = 0; i < ardOilWallUpload.size(); i++) {
                                    pts.clear();
                                    ArdOilWall ardOilWall = ardOilWallUpload.get(i);
                                    String[] coord = ardOilWall.getCoord().split(",");
                                    for (int j = 0; j < coord.length; j = j + 3) {
                                        pts.add(new Point2D.Double(Double.parseDouble(coord[j]), Double.parseDouble(coord[j + 1])));
                                    }
                                    if (GeoTools.IsPtInPoly(point, pts)) {
                                        //进入卸油点,存入卸油点围栏ID
                                        ardAccessFence.setIntoUnloadId(ardOilWall.getId());
                                        ardAccessFence.setIntoUnloadTime(time);
                                        ardAccessFence.setLng(lng);
                                        ardAccessFence.setLat(lat);
                                        ardAccessFence.setNowWallName(ardOilWall.getName());
                                        ardAccessFence.setLastTime(time);
                                        ((ArdAccessFenceServiceImpl) SpringUtils.getBean("ArdAccessFenceServiceImpl")).updAccess(ardAccessFence);
                                        //已经进入卸油点,不在路上不需要停车报警
                                        isRoad = false;
                                        break;
                                    }
                                }
                                if(isRoad){
                                    //如果在路上判断坐标是否与上次一样
                                    if(ardAccessFence.getLng().equals(lng) && ardAccessFence.getLat().equals(lat)){
                                        //如果坐标一样时间相减
                                        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
                                        Date nowTime = sdf.parse(time);
                                        Date lastTime = sdf.parse(ardAccessFence.getLastTime());
                                        Long diff = (nowTime.getTime() - lastTime.getTime())/1000;
                                        List<ArdAccessNum> list = ((ArdAccessNumServiceImpl) SpringUtils.getBean("ArdAccessNumServiceImpl")).queryNum();
                                        if(list.size()>0){
                                            int alarm = list.get(0).getAlarm();
                                            if(diff>=alarm){
                                                ardAccessFence.setIsWarning("1");
                                                ardAccessFence.setAlarmLat(lat);
                                                ardAccessFence.setAlarmLng(lng);
                                                ((ArdAccessFenceServiceImpl) SpringUtils.getBean("ArdAccessFenceServiceImpl")).updAccess(ardAccessFence);
                                            }
                                        }
                                    }else {
                                        //如果不一样更新坐标
                                        ardAccessFence.setLat(lat);
                                        ardAccessFence.setLng(lng);
                                        ardAccessFence.setLastTime(time);
                                        ((ArdAccessFenceServiceImpl) SpringUtils.getBean("ArdAccessFenceServiceImpl")).updAccess(ardAccessFence);
                                    }
                                }
                            }else {
                                //未开出卸油点,更新经纬度保存
                                ardAccessFence.setLng(lng);
                                ardAccessFence.setLat(lat);
                                ((ArdAccessFenceServiceImpl)SpringUtils.getBean("ArdAccessFenceServiceImpl")).updAccess(ardAccessFence);
                                //车辆已经进入卸油点,判断是否已经开出卸油点
                                ArdOilWall ardOilWall = ((ArdOilWallServiceImpl) SpringUtils.getBean("ArdOilWallServiceImpl")).one(unload);
                                pts.clear();
                                String[] coord = ardOilWall.getCoord().split(",");
                                for (int j = 0; j < coord.length; j = j + 3) {
                                    pts.add(new Point2D.Double(Double.parseDouble(coord[j]), Double.parseDouble(coord[j + 1])));
                                }
                                if (!GeoTools.IsPtInPoly(point, pts)) {
                                    //开出了卸油点围栏,删除该条车辆数据
                                    ((ArdAccessFenceServiceImpl) SpringUtils.getBean("ArdAccessFenceServiceImpl")).delAccess(carId);
                                }else {
                                    //未开出卸油点,更新经纬度保存
                                    ardAccessFence.setLng(lng);
                                    ardAccessFence.setLat(lat);
                                    ardAccessFence.setLastTime(time);
                                    ((ArdAccessFenceServiceImpl)SpringUtils.getBean("ArdAccessFenceServiceImpl")).updAccess(ardAccessFence);
                                }
                            }
                        }
                    }