فهرست منبع

地面车实时数据

Administrator 2 سال پیش
والد
کامیت
5ca4a009d7

+ 10 - 61
ruoyi-admin/src/main/java/com/ruoyi/web/controller/parkLot/GetCameraPreviewURL.java

@@ -134,39 +134,19 @@ public class GetCameraPreviewURL {
          */
         String result = ArtemisHttpUtil.doPostStringArtemis(path, body, null, null, contentType , null);// post请求application/json类型参数
         System.out.println(result);
-        /**
-         * {
-         *     "code": "0",
-         *     "msg": "success",
-         *     "data": {
-         *         "total": 1,
-         *         "pageNo": 1,
-         *         "pageSize": 15,
-         *         "list": [
-         *             {
-         *                 "inRecordSyscode": "h45h45h45ghhn45tg245g45r",
-         *                 "vehiclePicUri": "/pic?=d7ei703i10cd*73a-d5108a--22c6592ai2b4*=3d4id=",
-         *                 "cardNo": "613453453",
-         *                 "inTime": "2018-07-26T15:00:00+08:00",
-         *                 "parkTime": "1天1小时1分钟",
-         *                 "parkSyscode": "hju56jyt54h4h245g2345g345fg",
-         *                 "parkName": "停车库1",
-         *                 "plateNoPicUri": "/pic?=d7ei703i10cd*73a-d5108a--22c592ai2b4*=3",
-         *                 "aswSyscode": "g45ghertg34fh4hy245tgy234tg5",
-         *                 "plateNo": "浙A12345"
-         *             }
-         *         ]
-         *     }
-         * }
-         */
         return result;
     }
 
     /**
      * 查询车辆包期信息
+     * @param plateNo 车牌
+     * @param startTime 查询开始时间
+     * @param endTime 查询结束时间
+     * @param pageNo 目标页码  必须
+     * @param pageSize 每页记录数 必须
      * @return
      */
-    public static String GetChargeURL(String startTime,String endTime,String pageNo,String pageSize) {
+    public static String GetChargeURL(String plateNo,String startTime,String endTime,String pageNo,String pageSize) {
         /**
          * STEP1:设置平台参数,根据实际情况,设置host appkey appsecret 三个参数.
          */
@@ -207,47 +187,16 @@ public class GetCameraPreviewURL {
             jsonBody.put("pageNo",pageNo);
             jsonBody.put("pageSize",pageSize);
         }
+        if (StringUtils.isNotBlank(plateNo)){
+            jsonBody.put("plateNo",plateNo);
+
+        }
         String body = jsonBody.toJSONString();
         /**
          * STEP6:调用接口
          */
         String result = ArtemisHttpUtil.doPostStringArtemis(path, body, null, null, contentType , null);// post请求application/json类型参数
         System.out.println(result);
-        /**
-         * {
-         *     "code": "0",
-         *     "msg": "success",
-         *     "data": {
-         *         "total": 1,
-         *         "pageNo": 1,
-         *         "pageSize": 15,
-         *         "list": [
-         *             {
-         *                 "regionIndexCode": "s7f0wef9-weuf0we0f",
-         *                 "vehicleId": "as78da790sd99u29u9129uddav90s",
-         *                 "plateNo": "浙A12345",
-         *                 "cardNo": "6518959562033",
-         *                 "personId": "as9du12d9219d1-2ud012d22d",
-         *                 "personName": "Jack",
-         *                 "categoryCode": "0ff8231a93604c4d849dad519451fb03",
-         *                 "categoryName": "VIP车辆"
-         *                 "validity": [
-         *                     {
-         *                         "parkSyscode": "gqwerg354g345g35g",
-         *                         "parkName": "停车库1",
-         *                         "functionTime": [
-         *                             {
-         *                                 "startTime": "2018-07-26",
-         *                                 "endTime": "2018-07-27"
-         *                             }
-         *                         ]
-         *                     }
-         *                 ]
-         *             }
-         *         ]
-         *     }
-         * }
-         */
         return result;
     }
 }

+ 170 - 13
ruoyi-admin/src/main/java/com/ruoyi/web/controller/parkLot/ParkLotController.java

@@ -3,20 +3,28 @@ package com.ruoyi.web.controller.parkLot;
 import com.alibaba.fastjson2.JSONArray;
 import com.alibaba.fastjson2.JSONObject;
 import com.ruoyi.common.core.controller.BaseController;
-import com.ruoyi.common.core.domain.AjaxResult;
+
 import com.ruoyi.common.core.page.TableDataInfo;
 import com.ruoyi.common.core.redis.RedisCache;
+
 import com.ruoyi.common.utils.StringUtils;
-import org.apache.commons.lang3.time.DateFormatUtils;
+
+import com.ruoyi.system.domain.vo.TempCarInRecordVo;
+import org.joda.time.DateTime;
+
+import org.joda.time.format.DateTimeFormat;
+import org.joda.time.format.DateTimeFormatter;
+
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.data.redis.core.RedisTemplate;
-import org.springframework.format.annotation.DateTimeFormat;
+
 import org.springframework.web.bind.annotation.*;
 
-import java.time.LocalDateTime;
-import java.time.format.DateTimeFormatter;
-import java.time.temporal.TemporalAccessor;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+
+import java.util.ArrayList;
 import java.util.Date;
+
 import java.util.concurrent.TimeUnit;
 
 import static com.ruoyi.common.constant.CacheConstants.LEFT_PLACE;
@@ -39,7 +47,7 @@ public class ParkLotController extends BaseController {
     public String parkLotNum() {
         //先去查redis
         String leftPlaceRedis = redisCache.getCacheObject(LEFT_PLACE);
-        if (StringUtils.isEmpty(leftPlaceRedis)){
+        if (StringUtils.isEmpty(leftPlaceRedis)) {
             leftPlaceRedis = "0";
             String result = GetCameraPreviewURL.GetCameraPreviewURL();
             JSONObject jsonObject = JSONObject.parseObject(result);
@@ -48,21 +56,170 @@ public class ParkLotController extends BaseController {
                 JSONArray data = jsonObject.getJSONArray("data");
                 leftPlaceRedis = data.getJSONObject(0).getString("leftPlace");
                 System.out.println(leftPlaceRedis);
-            }else {
+            } else {
                 System.out.println(jsonObject.getString("msg"));
             }
-            redisCache.setCacheObject(LEFT_PLACE,leftPlaceRedis,5, TimeUnit.SECONDS);
+            redisCache.setCacheObject(LEFT_PLACE, leftPlaceRedis, 5, TimeUnit.SECONDS);
         }
         return leftPlaceRedis;
     }
 
     /**
      * 获取实时地面停车场场内车数据
+     *
      * @return
      */
     @PostMapping("/tempCarInRecords")
-    public TableDataInfo tempCarInRecords(String plateNo,String startTime,String endTime,String pageNo,String pageSize) {
-       // String result = GetCameraPreviewURL.GetChargeURL("2018-07-26T15:00:00+08:00",);
-      return   getDataTable(null);
+    public TableDataInfo tempCarInRecords(String plateNo, String startTime, String endTime, String pageNo, String pageSize) {
+        //所有固定车车牌
+        ArrayList chargeList = chargeList(plateNo);
+        DateTimeFormatter formatter = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss");
+        DateTime parseStartTime = DateTime.parse(startTime, formatter);
+        DateTime parseEndTime = DateTime.parse(endTime, formatter);
+        startTime = parseStartTime.toString("yyyy-MM-dd'T'HH:mm:ss") + "+08:00";
+        endTime = parseEndTime.toString("yyyy-MM-dd'T'HH:mm:ss") + "+08:00";
+        //获取所有在场车辆
+        String result = GetCameraPreviewURL.GetTempCarInRecordsURL(plateNo, startTime, endTime, pageNo, pageSize);
+        /**
+         * {
+         *     "code": "0",
+         *     "msg": "success",
+         *     "data": {
+         *         "total": 1,
+         *         "pageNo": 1,
+         *         "pageSize": 15,
+         *         "list": [
+         *             {
+         *                 "inRecordSyscode": "h45h45h45ghhn45tg245g45r",
+         *                 "vehiclePicUri": "/pic?=d7ei703i10cd*73a-d5108a--22c6592ai2b4*=3d4id=",
+         *                 "cardNo": "613453453",
+         *                 "inTime": "2018-07-26T15:00:00+08:00",
+         *                 "parkTime": "1天1小时1分钟",
+         *                 "parkSyscode": "hju56jyt54h4h245g2345g345fg",
+         *                 "parkName": "停车库1",
+         *                 "plateNoPicUri": "/pic?=d7ei703i10cd*73a-d5108a--22c592ai2b4*=3",
+         *                 "aswSyscode": "g45ghertg34fh4hy245tgy234tg5",
+         *                 "plateNo": "浙A12345"
+         *             }
+         *         ]
+         *     }
+         * }
+         */
+        JSONObject jsonObject = JSONObject.parseObject(result);
+        String code = jsonObject.getString("code");
+        //定义返回值
+        ArrayList tempCarInRecordList = new ArrayList<>();
+        if ("0".equals(code)) {
+            String data = jsonObject.getString("data");
+            JSONObject jsonObjectData = JSONObject.parseObject(data);
+            JSONArray list = jsonObjectData.getJSONArray("list");
+            if (list != null && list.size() > 0){
+                for (int i = 0; i < list.size(); i++) {
+                    JSONObject jsonObjectTempCarInRecord = list.getJSONObject(i);
+                    String plateNoTempCarInRecord = jsonObjectTempCarInRecord.getString("plateNo");
+                    boolean contains = chargeList.contains(plateNoTempCarInRecord);
+                    if (contains){
+                        TempCarInRecordVo tempCarInRecordVo = new TempCarInRecordVo();
+                        tempCarInRecordVo.setPlateNo(plateNoTempCarInRecord);
+                        tempCarInRecordVo.setParkTime(jsonObjectTempCarInRecord.getString("parkTime"));
+                        tempCarInRecordVo.setInTime(zDate(jsonObjectTempCarInRecord.getString("inTime")));
+                        tempCarInRecordList.add(tempCarInRecordVo);
+                    }
+                }
+            }
+        }
+        return getDataTable(tempCarInRecordList);
+    }
+
+    /**
+     * 所有固定车车牌
+     *
+     * @return
+     */
+    public ArrayList chargeList(String plateNo) {
+        DateTime dt = new DateTime();
+        String timestamp = dt.toString("yyyy-MM-dd'T'HH:mm:ss") + "+08:00";
+        /**
+         * {
+         *     "code": "0",
+         *     "msg": "success",
+         *     "data": {
+         *         "total": 1,
+         *         "pageNo": 1,
+         *         "pageSize": 15,
+         *         "list": [
+         *             {
+         *                 "regionIndexCode": "s7f0wef9-weuf0we0f",
+         *                 "vehicleId": "as78da790sd99u29u9129uddav90s",
+         *                 "plateNo": "浙A12345",
+         *                 "cardNo": "6518959562033",
+         *                 "personId": "as9du12d9219d1-2ud012d22d",
+         *                 "personName": "Jack",
+         *                 "categoryCode": "0ff8231a93604c4d849dad519451fb03",
+         *                 "categoryName": "VIP车辆"
+         *                 "validity": [
+         *                     {
+         *                         "parkSyscode": "gqwerg354g345g35g",
+         *                         "parkName": "停车库1",
+         *                         "functionTime": [
+         *                             {
+         *                                 "startTime": "2018-07-26",
+         *                                 "endTime": "2018-07-27"
+         *                             }
+         *                         ]
+         *                     }
+         *                 ]
+         *             }
+         *         ]
+         *     }
+         * }
+         */
+        //固定车车牌集合
+        ArrayList plateNoList = new ArrayList();
+        boolean totalCharge = true;
+        int pageNoCharge = 0;
+        while (totalCharge) {
+            totalCharge = false;
+            pageNoCharge = 1 + pageNoCharge;
+            //查询出所有未过期的固定车
+            String resultCharge = GetCameraPreviewURL.GetChargeURL(plateNo, "2018-07-26T15:00:00+08:00", timestamp, String.valueOf(pageNoCharge), "1000");
+            JSONObject jsonObjectCharge = JSONObject.parseObject(resultCharge);
+            String codeCharge = jsonObjectCharge.getString("code");
+            if ("0".equals(codeCharge)) {
+                String dataCharge = jsonObjectCharge.getString("data");
+                JSONObject jsonObjectDataCharge = JSONObject.parseObject(dataCharge);
+                JSONArray listCharge = jsonObjectDataCharge.getJSONArray("list");
+                if (listCharge != null && listCharge.size() > 0) {
+                    for (int i = 0; i < listCharge.size(); i++) {
+                        JSONObject jsonObjectList = listCharge.getJSONObject(i);
+                        //固定车车牌
+                        String plateNoCharge = jsonObjectList.getString("plateNo");
+                        plateNoList.add(plateNoCharge);
+                    }
+                    if (listCharge.size() == 1000) {
+                        totalCharge = true;
+                    }
+                }
+            }
+        }
+        return plateNoList;
+    }
+
+    /**
+     * ISO8601转data
+     *
+     * @param tDate
+     * @return
+     */
+    public static String zDate(String tDate) {
+        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
+        Date date2 = null;
+        try {
+            date2 = format.parse(tDate);
+            return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(date2);
+        } catch (ParseException e) {
+            e.printStackTrace();
+            return null;
+        }
     }
 }

+ 43 - 0
ruoyi-system/src/main/java/com/ruoyi/system/domain/vo/TempCarInRecordVo.java

@@ -0,0 +1,43 @@
+package com.ruoyi.system.domain.vo;
+
+/**
+ * @Author: tjf
+ * @Date: 2023/1/4 11:52
+ * @Describe:
+ */
+public class TempCarInRecordVo {
+    /** 车牌号 */
+    private String plateNo;
+    /**
+     *停车时长
+     */
+    private String parkTime;
+    /**
+     * 入场时间
+     */
+    private String inTime;
+
+    public String getPlateNo() {
+        return plateNo;
+    }
+
+    public void setPlateNo(String plateNo) {
+        this.plateNo = plateNo;
+    }
+
+    public String getParkTime() {
+        return parkTime;
+    }
+
+    public void setParkTime(String parkTime) {
+        this.parkTime = parkTime;
+    }
+
+    public String getInTime() {
+        return inTime;
+    }
+
+    public void setInTime(String inTime) {
+        this.inTime = inTime;
+    }
+}