曹煤炭车辆闸机对接
parent
a25574ef1f
commit
37474aa188
|
@ -2,6 +2,7 @@ package com.zcloud.util;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSONArray;
|
import com.alibaba.fastjson.JSONArray;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.google.gson.JsonObject;
|
||||||
import com.zcloud.entity.PageData;
|
import com.zcloud.entity.PageData;
|
||||||
import com.zcloud.service.doorDevice.DoorDeviceService;
|
import com.zcloud.service.doorDevice.DoorDeviceService;
|
||||||
import com.zcloud.util.hk.HKUtil;
|
import com.zcloud.util.hk.HKUtil;
|
||||||
|
@ -20,57 +21,63 @@ import java.util.Map;
|
||||||
public class DoorDeviceScheduled {
|
public class DoorDeviceScheduled {
|
||||||
@Autowired
|
@Autowired
|
||||||
private DoorDeviceService doorDeviceService;
|
private DoorDeviceService doorDeviceService;
|
||||||
// @Scheduled(cron ="0 30 0 * * ?")//每天12点30
|
@Scheduled(cron ="0 30 0 * * ?")//每天12点30
|
||||||
@Scheduled(cron ="*/20 * * * * ?")//测试
|
//@Scheduled(cron ="*/20 * * * * ?")//测试
|
||||||
public void scheduled(){
|
public void scheduled(){
|
||||||
|
//先定义存的内容
|
||||||
|
List<PageData> doorList = new ArrayList<>();
|
||||||
|
//获取车辆的闸机信息----- start
|
||||||
PageData pageData = new PageData();
|
PageData pageData = new PageData();
|
||||||
Map<String, Object> carDoorInfo = HKUtil.getCarDoorList(pageData);
|
Map<String, Object> carDoorInfo = HKUtil.getCarDoorList(pageData);
|
||||||
Object data = carDoorInfo.get("data");
|
Object carDoordata = carDoorInfo.get("data");
|
||||||
List<PageData> dataList = JSONArray.parseArray(data.toString(), PageData.class);
|
List<PageData> CarDoordataList = JSONArray.parseArray(carDoordata.toString(), PageData.class);
|
||||||
String parkIndexCodes = "";
|
String parkIndexCodes = "";
|
||||||
System.out.println(dataList);
|
for (PageData pd : CarDoordataList) {
|
||||||
for (PageData pd : dataList) {
|
|
||||||
parkIndexCodes = parkIndexCodes + pd.getString("parkIndexCode")+",";
|
parkIndexCodes = parkIndexCodes + pd.getString("parkIndexCode")+",";
|
||||||
}
|
}
|
||||||
Map<String, Object> carDoorDevice = HKUtil.getCarDoorInfo(parkIndexCodes);
|
Map<String, Object> carDoorDevice = HKUtil.getCarDoorInfo(parkIndexCodes);
|
||||||
System.out.println(carDoorDevice);
|
List<PageData> carDoorList = JSONArray.parseArray(carDoorDevice.get("data").toString(),PageData.class);
|
||||||
Map<String, Object> root = HKUtil.getRoot();
|
for(PageData carData:carDoorList){
|
||||||
System.out.println(root);
|
carData.put("indexCode",carData.getString("entranceIndexCode"));
|
||||||
|
carData.put("name",carData.getString("entranceName"));
|
||||||
// PageData pageData = new PageData();
|
}
|
||||||
// Boolean hasNext = true;
|
doorList.addAll(carDoorList);
|
||||||
// List<PageData> doorList = new ArrayList<>();
|
//获取车辆的闸机信息----- end
|
||||||
// int pageNo = 1;
|
//获取人员的闸机信息----- start
|
||||||
// int pageSize = 100;
|
Boolean hasNext = true;
|
||||||
// while (hasNext) {
|
int pageNo = 1;
|
||||||
// pageData.put("pageNo",pageNo);
|
int pageSize = 100;
|
||||||
// pageData.put("pageSize",pageSize);
|
while (hasNext) {
|
||||||
// Map<String, Object> gateMachineInfo = HKUtil.getGateMachineInfo(pageData);
|
pageData.put("pageNo",pageNo);
|
||||||
// JSONObject data = (JSONObject) gateMachineInfo.get("data");
|
pageData.put("pageSize",pageSize);
|
||||||
// Object list = data.get("list");
|
Map<String, Object> gateMachineInfo = HKUtil.getGateMachineInfo(pageData);
|
||||||
// List<PageData> dataList = JSONArray.parseArray(list.toString(), PageData.class);
|
JSONObject data = (JSONObject) gateMachineInfo.get("data");
|
||||||
// doorList.addAll(dataList);
|
Object list = data.get("list");
|
||||||
// if (dataList.size()<100){
|
List<PageData> dataList = JSONArray.parseArray(list.toString(), PageData.class);
|
||||||
// hasNext = false;
|
doorList.addAll(dataList);
|
||||||
// }else {
|
if (dataList.size()<100){
|
||||||
// pageNo++;
|
hasNext = false;
|
||||||
// }
|
}else {
|
||||||
// }
|
pageNo++;
|
||||||
//
|
}
|
||||||
// for (PageData doordevice : doorList) {
|
}
|
||||||
// try {
|
//获取人员的闸机信息----- end
|
||||||
// PageData byIndexCode = doorDeviceService.findByIndexCode(doordevice);
|
//执行存储 ----- start
|
||||||
// if (!Tools.isEmpty(byIndexCode)) {
|
for (PageData doordevice : doorList) {
|
||||||
// doorDeviceService.edit(doordevice);
|
try {
|
||||||
// }else {
|
PageData byIndexCode = doorDeviceService.findByIndexCode(doordevice);
|
||||||
// String uuid = get32UUID();
|
if (!Tools.isEmpty(byIndexCode)) {
|
||||||
// doordevice.put("DOORDEVICE_ID",uuid);
|
doorDeviceService.edit(doordevice);
|
||||||
// doorDeviceService.save(doordevice);
|
}else {
|
||||||
// }
|
String uuid = get32UUID();
|
||||||
// } catch (Exception e) {
|
doordevice.put("DOORDEVICE_ID",uuid);
|
||||||
// throw new RuntimeException(e);
|
doorDeviceService.save(doordevice);
|
||||||
// }
|
}
|
||||||
// }
|
} catch (Exception e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//执行存储 ----- end
|
||||||
}
|
}
|
||||||
|
|
||||||
/**得到32位的uuid
|
/**得到32位的uuid
|
||||||
|
|
|
@ -32,7 +32,9 @@
|
||||||
resourceType,
|
resourceType,
|
||||||
sort,
|
sort,
|
||||||
treatyType,
|
treatyType,
|
||||||
updateTime
|
updateTime,
|
||||||
|
parkIndexCode,
|
||||||
|
roadNum
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
<!-- 字段值 -->
|
<!-- 字段值 -->
|
||||||
|
@ -60,7 +62,9 @@
|
||||||
#{resourceType},
|
#{resourceType},
|
||||||
#{sort},
|
#{sort},
|
||||||
#{treatyType},
|
#{treatyType},
|
||||||
#{updateTime}
|
#{updateTime},
|
||||||
|
#{parkIndexCode},
|
||||||
|
#{roadNum}
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
<!-- 新增-->
|
<!-- 新增-->
|
||||||
|
@ -109,7 +113,9 @@
|
||||||
resourceType = #{resourceType},
|
resourceType = #{resourceType},
|
||||||
sort = #{sort},
|
sort = #{sort},
|
||||||
treatyType = #{treatyType},
|
treatyType = #{treatyType},
|
||||||
updateTime = #{updateTime}
|
updateTime = #{updateTime},
|
||||||
|
parkIndexCode= #{parkIndexCode},
|
||||||
|
roadNum = #{roadNum}
|
||||||
where
|
where
|
||||||
indexCode = #{indexCode}
|
indexCode = #{indexCode}
|
||||||
</update>
|
</update>
|
||||||
|
|
Loading…
Reference in New Issue