diff --git a/src/main/java/com/zcloud/util/DoorDeviceScheduled.java b/src/main/java/com/zcloud/util/DoorDeviceScheduled.java index a6db1fe4..cdc34563 100644 --- a/src/main/java/com/zcloud/util/DoorDeviceScheduled.java +++ b/src/main/java/com/zcloud/util/DoorDeviceScheduled.java @@ -2,6 +2,7 @@ package com.zcloud.util; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; +import com.google.gson.JsonObject; import com.zcloud.entity.PageData; import com.zcloud.service.doorDevice.DoorDeviceService; import com.zcloud.util.hk.HKUtil; @@ -20,57 +21,63 @@ import java.util.Map; public class DoorDeviceScheduled { @Autowired private DoorDeviceService doorDeviceService; -// @Scheduled(cron ="0 30 0 * * ?")//每天12点30 - @Scheduled(cron ="*/20 * * * * ?")//测试 + @Scheduled(cron ="0 30 0 * * ?")//每天12点30 + //@Scheduled(cron ="*/20 * * * * ?")//测试 public void scheduled(){ + //先定义存的内容 + List doorList = new ArrayList<>(); + //获取车辆的闸机信息----- start PageData pageData = new PageData(); Map carDoorInfo = HKUtil.getCarDoorList(pageData); - Object data = carDoorInfo.get("data"); - List dataList = JSONArray.parseArray(data.toString(), PageData.class); + Object carDoordata = carDoorInfo.get("data"); + List CarDoordataList = JSONArray.parseArray(carDoordata.toString(), PageData.class); String parkIndexCodes = ""; - System.out.println(dataList); - for (PageData pd : dataList) { + for (PageData pd : CarDoordataList) { parkIndexCodes = parkIndexCodes + pd.getString("parkIndexCode")+","; } Map carDoorDevice = HKUtil.getCarDoorInfo(parkIndexCodes); - System.out.println(carDoorDevice); - Map root = HKUtil.getRoot(); - System.out.println(root); - -// PageData pageData = new PageData(); -// Boolean hasNext = true; -// List doorList = new ArrayList<>(); -// int pageNo = 1; -// int pageSize = 100; -// while (hasNext) { -// pageData.put("pageNo",pageNo); -// pageData.put("pageSize",pageSize); -// Map gateMachineInfo = HKUtil.getGateMachineInfo(pageData); -// JSONObject data = (JSONObject) gateMachineInfo.get("data"); -// Object list = data.get("list"); -// List dataList = JSONArray.parseArray(list.toString(), PageData.class); -// doorList.addAll(dataList); -// if (dataList.size()<100){ -// hasNext = false; -// }else { -// pageNo++; -// } -// } -// -// for (PageData doordevice : doorList) { -// try { -// PageData byIndexCode = doorDeviceService.findByIndexCode(doordevice); -// if (!Tools.isEmpty(byIndexCode)) { -// doorDeviceService.edit(doordevice); -// }else { -// String uuid = get32UUID(); -// doordevice.put("DOORDEVICE_ID",uuid); -// doorDeviceService.save(doordevice); -// } -// } catch (Exception e) { -// throw new RuntimeException(e); -// } -// } + List carDoorList = JSONArray.parseArray(carDoorDevice.get("data").toString(),PageData.class); + for(PageData carData:carDoorList){ + carData.put("indexCode",carData.getString("entranceIndexCode")); + carData.put("name",carData.getString("entranceName")); + } + doorList.addAll(carDoorList); + //获取车辆的闸机信息----- end + //获取人员的闸机信息----- start + Boolean hasNext = true; + int pageNo = 1; + int pageSize = 100; + while (hasNext) { + pageData.put("pageNo",pageNo); + pageData.put("pageSize",pageSize); + Map gateMachineInfo = HKUtil.getGateMachineInfo(pageData); + JSONObject data = (JSONObject) gateMachineInfo.get("data"); + Object list = data.get("list"); + List dataList = JSONArray.parseArray(list.toString(), PageData.class); + doorList.addAll(dataList); + if (dataList.size()<100){ + hasNext = false; + }else { + pageNo++; + } + } + //获取人员的闸机信息----- end + //执行存储 ----- start + for (PageData doordevice : doorList) { + try { + PageData byIndexCode = doorDeviceService.findByIndexCode(doordevice); + if (!Tools.isEmpty(byIndexCode)) { + doorDeviceService.edit(doordevice); + }else { + String uuid = get32UUID(); + doordevice.put("DOORDEVICE_ID",uuid); + doorDeviceService.save(doordevice); + } + } catch (Exception e) { + throw new RuntimeException(e); + } + } + //执行存储 ----- end } /**得到32位的uuid diff --git a/src/main/resources/mybatis/datasource/doorDevice/DoorDeviceMapper.xml b/src/main/resources/mybatis/datasource/doorDevice/DoorDeviceMapper.xml index 84c51718..514b3321 100644 --- a/src/main/resources/mybatis/datasource/doorDevice/DoorDeviceMapper.xml +++ b/src/main/resources/mybatis/datasource/doorDevice/DoorDeviceMapper.xml @@ -32,7 +32,9 @@ resourceType, sort, treatyType, - updateTime + updateTime, + parkIndexCode, + roadNum @@ -60,7 +62,9 @@ #{resourceType}, #{sort}, #{treatyType}, - #{updateTime} + #{updateTime}, + #{parkIndexCode}, + #{roadNum} @@ -109,7 +113,9 @@ resourceType = #{resourceType}, sort = #{sort}, treatyType = #{treatyType}, - updateTime = #{updateTime} + updateTime = #{updateTime}, + parkIndexCode= #{parkIndexCode}, + roadNum = #{roadNum} where indexCode = #{indexCode}