From 4e837c1e8c6f8a7252fb95776a1530ab737bb684 Mon Sep 17 00:00:00 2001
From: wang-hao-jie <1550036656@qq.com>
Date: 星期一, 06 六月 2022 15:32:42 +0800
Subject: [PATCH] 最新版本

---
 xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/controller/DrivingRecordController.java  |    1 
 xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/schedulings/CarLocationScheduleImpl.java |   74 +++++++++
 xboot-modules/xboot-your/src/main/resources/mapper/CarLocationMapper.xml                             |    5 
 xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/controller/face/FaceImgController.java   |    8 
 xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/entity/CarLocation.java                  |   52 ++++++
 xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/schedulings/OrderDealScheduleImpl.java   |  142 ++++++++--------
 xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/service/ICarLocationService.java         |   14 +
 xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/serviceimpl/ICarLocationServiceImpl.java |   26 +++
 xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/controller/CarLocationController.java    |   77 +++++++++
 xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/util/MQTT.java                           |   26 ++-
 xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/mapper/CarLocationMapper.java            |   14 +
 11 files changed, 356 insertions(+), 83 deletions(-)

diff --git a/xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/controller/CarLocationController.java b/xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/controller/CarLocationController.java
new file mode 100644
index 0000000..b366ac5
--- /dev/null
+++ b/xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/controller/CarLocationController.java
@@ -0,0 +1,77 @@
+package cn.exrick.xboot.your.controller;
+
+import cn.exrick.xboot.core.common.utils.PageUtil;
+import cn.exrick.xboot.core.common.utils.ResultUtil;
+import cn.exrick.xboot.core.common.vo.PageVo;
+import cn.exrick.xboot.core.common.vo.Result;
+import cn.exrick.xboot.your.entity.CarLocation;
+import cn.exrick.xboot.your.service.ICarLocationService;
+import cn.hutool.core.util.StrUtil;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.List;
+
+/**
+ * @author whj
+ */
+@Slf4j
+@RestController
+@Api(tags = "杞﹁締瀹氫綅琛ㄧ鐞嗘帴鍙�")
+@RequestMapping("/xboot/carLocation")
+@Transactional
+public class CarLocationController {
+
+    @Autowired
+    private ICarLocationService iCarLocationService;
+
+    @RequestMapping(value = "/get/{id}", method = RequestMethod.GET)
+    @ApiOperation(value = "閫氳繃id鑾峰彇")
+    public Result<CarLocation> get(@PathVariable String id) {
+
+        CarLocation carLocation = iCarLocationService.getById(id);
+        return new ResultUtil<CarLocation>().setData(carLocation);
+    }
+
+    @RequestMapping(value = "/getAll", method = RequestMethod.GET)
+    @ApiOperation(value = "鑾峰彇鍏ㄩ儴鏁版嵁")
+    public Result<List<CarLocation>> getAll() {
+
+        List<CarLocation> list = iCarLocationService.list();
+        return new ResultUtil<List<CarLocation>>().setData(list);
+    }
+
+    @RequestMapping(value = "/getByPage", method = RequestMethod.GET)
+    @ApiOperation(value = "鍒嗛〉鑾峰彇")
+    public Result<IPage<CarLocation>> getByPage(PageVo page) {
+
+        IPage<CarLocation> data = iCarLocationService.page(PageUtil.initMpPage(page));
+        return new ResultUtil<IPage<CarLocation>>().setData(data);
+    }
+
+    @RequestMapping(value = "/insertOrUpdate", method = RequestMethod.POST)
+    @ApiOperation(value = "缂栬緫鎴栨洿鏂版暟鎹�")
+    public Result<CarLocation> saveOrUpdate(CarLocation carLocation) {
+
+        if (iCarLocationService.saveOrUpdate(carLocation)) {
+            return new ResultUtil<CarLocation>().setData(carLocation);
+        }
+        return new ResultUtil<CarLocation>().setErrorMsg("鎿嶄綔澶辫触");
+    }
+
+    @RequestMapping(value = "/delByIds", method = RequestMethod.POST)
+    @ApiOperation(value = "鎵归噺閫氳繃id鍒犻櫎")
+    public Result<Object> delAllByIds(@RequestParam String[] ids) {
+
+        for (String id : ids) {
+            iCarLocationService.removeById(id);
+        }
+        return ResultUtil.success("鎵归噺閫氳繃id鍒犻櫎鏁版嵁鎴愬姛");
+    }
+}
diff --git a/xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/controller/DrivingRecordController.java b/xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/controller/DrivingRecordController.java
index 569d7af..fba72ed 100644
--- a/xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/controller/DrivingRecordController.java
+++ b/xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/controller/DrivingRecordController.java
@@ -97,6 +97,7 @@
         DrivingRecord drivingRecord = iDrivingRecordService.getOne(wrapper);
         if(drivingRecord==null){
             drivingRecord = new DrivingRecord();
+            drivingRecord.setCarId(carId);
         }
         drivingRecord.setMileage(mileage);
         drivingRecord.setInTime(DateUtil.parseDate(inDate));
diff --git a/xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/controller/face/FaceImgController.java b/xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/controller/face/FaceImgController.java
index d0fc4cc..ddbed52 100644
--- a/xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/controller/face/FaceImgController.java
+++ b/xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/controller/face/FaceImgController.java
@@ -86,9 +86,13 @@
                 return;
             }
 
-            String format = DateUtil.format(new Date(),"yyyy-MM-dd HH:mm");
+            Date date1 = new Date();
+            long time = date1.getTime()-2*60*1000;
+            Date date = new Date(time);
+            String format1 = DateUtil.format(date,"yyyy-MM-dd HH:mm:ss");
+            String format2 = DateUtil.format(date1,"yyyy-MM-dd HH:mm:ss");
             QueryWrapper<Alarm> awrapper = new QueryWrapper<>();
-            awrapper.between("create_time",format+"00",format+"59");
+            awrapper.between("create_time",format1,format2);
             awrapper.eq("car_no",one.getCarNo());
             awrapper.eq("type",5);
             List<Alarm> list = iAlarmService.list(awrapper);
diff --git a/xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/entity/CarLocation.java b/xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/entity/CarLocation.java
new file mode 100644
index 0000000..eab0d0b
--- /dev/null
+++ b/xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/entity/CarLocation.java
@@ -0,0 +1,52 @@
+package cn.exrick.xboot.your.entity;
+
+import cn.exrick.xboot.core.base.XbootBaseEntity;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import org.hibernate.annotations.DynamicInsert;
+import org.hibernate.annotations.DynamicUpdate;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import javax.persistence.Entity;
+import javax.persistence.Table;
+import javax.persistence.Transient;
+import java.util.Date;
+
+/**
+ * @author Exrick
+ */
+@Data
+@Entity
+@DynamicInsert
+@DynamicUpdate
+@Table(name = "t_car_location")
+@TableName("t_car_location")
+@ApiModel(value = "杞﹁締瀹氫綅琛�")
+public class CarLocation extends XbootBaseEntity {
+
+    private static final long serialVersionUID = 1L;
+
+    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @ApiModelProperty(value = "瀹氫綅鏃堕棿")
+    private Date locationTime;
+
+    @ApiModelProperty(value = "鐗岀収")
+    private String carNo;
+
+    @ApiModelProperty(value = "code")
+    private String code;
+
+    @ApiModelProperty(value = "缁忓害")
+    private String lng;
+
+    @ApiModelProperty(value = "绾害")
+    private String lat;
+
+    @ApiModelProperty(value = "閫熷害")
+    private int speed;
+}
\ No newline at end of file
diff --git a/xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/mapper/CarLocationMapper.java b/xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/mapper/CarLocationMapper.java
new file mode 100644
index 0000000..4532227
--- /dev/null
+++ b/xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/mapper/CarLocationMapper.java
@@ -0,0 +1,14 @@
+package cn.exrick.xboot.your.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import cn.exrick.xboot.your.entity.CarLocation;
+
+import java.util.List;
+
+/**
+ * 杞﹁締瀹氫綅琛ㄦ暟鎹鐞嗗眰
+ * @author whj
+ */
+public interface CarLocationMapper extends BaseMapper<CarLocation> {
+
+}
\ No newline at end of file
diff --git a/xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/schedulings/CarLocationScheduleImpl.java b/xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/schedulings/CarLocationScheduleImpl.java
new file mode 100644
index 0000000..a376046
--- /dev/null
+++ b/xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/schedulings/CarLocationScheduleImpl.java
@@ -0,0 +1,74 @@
+//package cn.exrick.xboot.your.schedulings;
+//import cn.exrick.xboot.your.entity.Car;
+//import cn.exrick.xboot.your.entity.CarLocation;
+//import cn.exrick.xboot.your.service.*;
+//import cn.exrick.xboot.your.util.HaiKangPost;
+//import cn.hutool.core.date.DateUtil;
+//import cn.hutool.core.util.StrUtil;
+//import cn.hutool.json.JSONArray;
+//import cn.hutool.json.JSONObject;
+//import cn.hutool.json.JSONUtil;
+//import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+//import org.springframework.beans.factory.annotation.Autowired;
+//import org.springframework.scheduling.annotation.Scheduled;
+//import org.springframework.stereotype.Component;
+//
+//import java.util.ArrayList;
+//import java.util.List;
+//
+////杞﹁締瀹氫綅缁熻
+//@Component
+//public class CarLocationScheduleImpl {
+//
+//    @Autowired
+//    private ICarService iCarService;
+//    @Autowired
+//    private HaiKangPost haiKangPost;
+//    @Autowired
+//    private ICarLocationService iCarLocationService;
+//
+//    @Scheduled(cron="0 0/10 5,20 * * ? ")//鍗佸垎閽熶竴娆�
+//    public void execute(){
+//        List<Car> list = iCarService.list();
+//        List<String> list2 = new ArrayList<>();
+//
+//        for(int i=0;i<list.size();i++){
+//            if(!StrUtil.isEmpty(list.get(i).getCode())){
+//                list2.add(list.get(i).getCode());
+//            }
+//        }
+//
+//        String codes[] = new String[list2.size()];
+//        for(int i=0;i<list2.size();i++){
+//            codes[i] = list2.get(i);
+//        }
+//        String latestGps = haiKangPost.findLatestGps(codes);
+//        JSONArray objects = JSONUtil.parseArray(latestGps);
+//        for(int i=0;i<objects.size();i++){
+//            String s = objects.get(i).toString();
+//            JSONObject jsonObject = JSONUtil.parseObj(s);
+//            String time = jsonObject.getStr("time");
+//            String time2 = time.substring(0,10)+" "+time.substring(11,16)+":00";
+//            String carNo = jsonObject.getStr("carNo");
+//            QueryWrapper<CarLocation> wrapper = new QueryWrapper<>();
+//            wrapper.eq("location_time",time2);
+//            wrapper.eq("car_no",carNo);
+//            int count = iCarLocationService.count(wrapper);
+//            if(count>0){
+//                continue;
+//            }
+//            Integer speed = jsonObject.getInt("speed")/10000;
+//            String lng = String.valueOf(jsonObject.getInt("longitude")/360000);
+//            String lat = String.valueOf(jsonObject.getInt("latitude")/360000);
+//            String code = jsonObject.getStr("vehicleIndexCode");
+//            CarLocation obj = new CarLocation();
+//            obj.setCarNo(carNo);
+//            obj.setCode(code);
+//            obj.setLat(lat);
+//            obj.setLng(lng);
+//            obj.setLocationTime(DateUtil.parse(time2,"yyyy-MM-dd HH:mm:ss"));
+//            obj.setSpeed(speed);
+//            iCarLocationService.save(obj);
+//        }
+//    }
+//}
diff --git a/xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/schedulings/OrderDealScheduleImpl.java b/xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/schedulings/OrderDealScheduleImpl.java
index b95adad..10a3b9f 100644
--- a/xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/schedulings/OrderDealScheduleImpl.java
+++ b/xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/schedulings/OrderDealScheduleImpl.java
@@ -1,71 +1,71 @@
-//package cn.exrick.xboot.your.schedulings;
-//import cn.exrick.xboot.your.entity.*;
-//import cn.exrick.xboot.your.service.*;
-//import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-//import org.springframework.beans.factory.annotation.Autowired;
-//import org.springframework.scheduling.annotation.Scheduled;
-//import org.springframework.stereotype.Component;
-//
-//import java.text.SimpleDateFormat;
-//import java.util.Calendar;
-//import java.util.Date;
-//import java.util.List;
-//
-////鍒犻櫎鍘嗗彶鏁版嵁
-//@Component
-//public class OrderDealScheduleImpl {
-//
-//    @Autowired
-//    private IOrderTaskOriginalService iOrderTaskOriginalService;
-//
-//    @Autowired
-//    private IOrderDetailOriginalService iOrderDetailOriginalService;
-//
-//    @Autowired
-//    private IOrderTaskService iOrderTaskService;
-//
-//    @Autowired
-//    private IOrderDetailService iOrderDetailService;
-//
-//    @Autowired
-//    private IDuoZhengService iDuoZhengService;
-//
-//    @Scheduled(cron="0 0 21 * * ?")//姣忔櫄涓嬪崍9鐐规墽琛�
-//    //@Scheduled(cron="0 33 17 * * ?")//娴嬭瘯
-//    public void execute(){
-//        String day = getDay(-15);
-//        QueryWrapper<OrderTask> wrapper = new QueryWrapper<>();
-//        wrapper.lt("send_Date",day);
-//        iOrderTaskService.remove(wrapper);
-//
-//        QueryWrapper<OrderDetail> wrapper2 = new QueryWrapper<>();
-//        wrapper2.lt("create_time",day+" 00:00:00");
-//        iOrderDetailService.remove(wrapper2);
-//
-//        String day2 = getDay(-30);
-//        QueryWrapper<OrderTaskOriginal> wrapper3 = new QueryWrapper<>();
-//        wrapper3.lt("create_time",day2+" 00:00:00");
-//        iOrderTaskOriginalService.remove(wrapper3);
-//
-//        QueryWrapper<OrderDetailOriginal> wrapper4 = new QueryWrapper<>();
-//        wrapper4.lt("create_time",day2+" 00:00:00");
-//        iOrderDetailOriginalService.remove(wrapper4);
-//
-//        QueryWrapper<DuoZheng> wrapper5 = new QueryWrapper<>();
-//        iDuoZhengService.remove(wrapper5);
-//
-//        List<DuoZheng> list = iDuoZhengService.getYiHuDuoZheng();
-//        iDuoZhengService.saveBatch(list);
-//    }
-//
-//    private String getDay(int day){
-//        Date dNow = new Date();   //褰撳墠鏃堕棿
-//        Calendar calendar = Calendar.getInstance(); //寰楀埌鏃ュ巻
-//        calendar.setTime(dNow);//鎶婂綋鍓嶆椂闂磋祴缁欐棩鍘�
-//        calendar.add(Calendar.DAY_OF_MONTH, day);  //璁剧疆涓哄墠n澶�
-//        Date dBefore = calendar.getTime();   //寰楀埌鍓嶄竴澶╃殑鏃堕棿
-//        SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd"); //璁剧疆鏃堕棿鏍煎紡
-//        String defaultStartDate = sdf.format(dBefore);
-//        return defaultStartDate;
-//    }
-//}
+package cn.exrick.xboot.your.schedulings;
+import cn.exrick.xboot.your.entity.*;
+import cn.exrick.xboot.your.service.*;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.scheduling.annotation.Scheduled;
+import org.springframework.stereotype.Component;
+
+import java.text.SimpleDateFormat;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.List;
+
+//鍒犻櫎鍘嗗彶鏁版嵁
+@Component
+public class OrderDealScheduleImpl {
+
+    @Autowired
+    private IOrderTaskOriginalService iOrderTaskOriginalService;
+
+    @Autowired
+    private IOrderDetailOriginalService iOrderDetailOriginalService;
+
+    @Autowired
+    private IOrderTaskService iOrderTaskService;
+
+    @Autowired
+    private IOrderDetailService iOrderDetailService;
+
+    @Autowired
+    private IDuoZhengService iDuoZhengService;
+
+    @Scheduled(cron="0 0 21 * * ?")//姣忔櫄涓嬪崍9鐐规墽琛�
+    //@Scheduled(cron="0 33 17 * * ?")//娴嬭瘯
+    public void execute(){
+        String day = getDay(-14);
+        QueryWrapper<OrderTask> wrapper = new QueryWrapper<>();
+        wrapper.lt("send_Date",day);
+        iOrderTaskService.remove(wrapper);
+
+        QueryWrapper<OrderDetail> wrapper2 = new QueryWrapper<>();
+        wrapper2.lt("create_time",day+" 00:00:00");
+        iOrderDetailService.remove(wrapper2);
+
+        String day2 = getDay(-30);
+        QueryWrapper<OrderTaskOriginal> wrapper3 = new QueryWrapper<>();
+        wrapper3.lt("create_time",day2+" 00:00:00");
+        iOrderTaskOriginalService.remove(wrapper3);
+
+        QueryWrapper<OrderDetailOriginal> wrapper4 = new QueryWrapper<>();
+        wrapper4.lt("create_time",day2+" 00:00:00");
+        iOrderDetailOriginalService.remove(wrapper4);
+
+        QueryWrapper<DuoZheng> wrapper5 = new QueryWrapper<>();
+        iDuoZhengService.remove(wrapper5);
+
+        List<DuoZheng> list = iDuoZhengService.getYiHuDuoZheng();
+        iDuoZhengService.saveBatch(list);
+    }
+
+    private String getDay(int day){
+        Date dNow = new Date();   //褰撳墠鏃堕棿
+        Calendar calendar = Calendar.getInstance(); //寰楀埌鏃ュ巻
+        calendar.setTime(dNow);//鎶婂綋鍓嶆椂闂磋祴缁欐棩鍘�
+        calendar.add(Calendar.DAY_OF_MONTH, day);  //璁剧疆涓哄墠n澶�
+        Date dBefore = calendar.getTime();   //寰楀埌鍓嶄竴澶╃殑鏃堕棿
+        SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd"); //璁剧疆鏃堕棿鏍煎紡
+        String defaultStartDate = sdf.format(dBefore);
+        return defaultStartDate;
+    }
+}
diff --git a/xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/service/ICarLocationService.java b/xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/service/ICarLocationService.java
new file mode 100644
index 0000000..924326c
--- /dev/null
+++ b/xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/service/ICarLocationService.java
@@ -0,0 +1,14 @@
+package cn.exrick.xboot.your.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import cn.exrick.xboot.your.entity.CarLocation;
+
+import java.util.List;
+
+/**
+ * 杞﹁締瀹氫綅琛ㄦ帴鍙�
+ * @author whj
+ */
+public interface ICarLocationService extends IService<CarLocation> {
+
+}
\ No newline at end of file
diff --git a/xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/serviceimpl/ICarLocationServiceImpl.java b/xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/serviceimpl/ICarLocationServiceImpl.java
new file mode 100644
index 0000000..7c51058
--- /dev/null
+++ b/xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/serviceimpl/ICarLocationServiceImpl.java
@@ -0,0 +1,26 @@
+package cn.exrick.xboot.your.serviceimpl;
+
+import cn.exrick.xboot.your.mapper.CarLocationMapper;
+import cn.exrick.xboot.your.entity.CarLocation;
+import cn.exrick.xboot.your.service.ICarLocationService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * 杞﹁締瀹氫綅琛ㄦ帴鍙e疄鐜�
+ * @author whj
+ */
+@Slf4j
+@Service
+@Transactional
+public class ICarLocationServiceImpl extends ServiceImpl<CarLocationMapper, CarLocation> implements ICarLocationService {
+
+    @Autowired
+    private CarLocationMapper carLocationMapper;
+}
\ No newline at end of file
diff --git a/xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/util/MQTT.java b/xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/util/MQTT.java
index 551aa74..aab6372 100644
--- a/xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/util/MQTT.java
+++ b/xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/util/MQTT.java
@@ -6,6 +6,7 @@
 import cn.exrick.xboot.your.service.IAlarmService;
 import cn.exrick.xboot.your.service.ICarService;
 import cn.exrick.xboot.your.service.IEventLogService;
+import cn.hutool.core.date.DateUtil;
 import cn.hutool.json.JSONArray;
 import cn.hutool.json.JSONObject;
 import cn.hutool.json.JSONUtil;
@@ -15,6 +16,7 @@
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
+import java.util.Date;
 import java.util.List;
 
 
@@ -110,16 +112,6 @@
                                         return;
                                     }
 
-                                    String format = alarmTime.substring(0,17);
-                                    QueryWrapper<Alarm> awrapper = new QueryWrapper<>();
-                                    awrapper.between("create_time",format+"00",format+"59");
-                                    awrapper.eq("car_no",car.getCarNo());
-                                    awrapper.eq("type",1);
-                                    List<Alarm> list = iAlarmService.list(awrapper);
-                                    if(list.size()>0){
-                                        return;
-                                    }
-
                                     Alarm alarm = new Alarm();
                                     if(eventType.equals("132371")){
                                         alarm.setType(1);
@@ -140,6 +132,20 @@
                                         return;
                                     }
 
+                                    Date date1 = new Date();
+                                    long time = date1.getTime()-2*60*1000;
+                                    Date date = new Date(time);
+                                    String format1 = DateUtil.format(date,"yyyy-MM-dd HH:mm:ss");
+                                    String format2 = DateUtil.format(date1,"yyyy-MM-dd HH:mm:ss");
+                                    QueryWrapper<Alarm> awrapper = new QueryWrapper<>();
+                                    awrapper.between("create_time",format1,format2);
+                                    awrapper.eq("car_no",car.getCarNo());
+                                    awrapper.eq("type",alarm.getType());
+                                    List<Alarm> list = iAlarmService.list(awrapper);
+                                    if(list.size()>0){
+                                        return;
+                                    }
+
                                     alarm.setAlarmId(alarmId);
                                     alarm.setCarId(car.getId());
                                     alarm.setCarNo(car.getCarNo());
diff --git a/xboot-modules/xboot-your/src/main/resources/mapper/CarLocationMapper.xml b/xboot-modules/xboot-your/src/main/resources/mapper/CarLocationMapper.xml
new file mode 100644
index 0000000..b729467
--- /dev/null
+++ b/xboot-modules/xboot-your/src/main/resources/mapper/CarLocationMapper.xml
@@ -0,0 +1,5 @@
+<?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.exrick.xboot.your.mapper.CarLocationMapper">
+
+</mapper>
\ No newline at end of file

--
Gitblit v1.9.1