曹煤炭车辆闸机对接
parent
a25574ef1f
commit
37474aa188
|
@ -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<PageData> doorList = new ArrayList<>();
|
||||
//获取车辆的闸机信息----- start
|
||||
PageData pageData = new PageData();
|
||||
Map<String, Object> carDoorInfo = HKUtil.getCarDoorList(pageData);
|
||||
Object data = carDoorInfo.get("data");
|
||||
List<PageData> dataList = JSONArray.parseArray(data.toString(), PageData.class);
|
||||
Object carDoordata = carDoorInfo.get("data");
|
||||
List<PageData> 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<String, Object> carDoorDevice = HKUtil.getCarDoorInfo(parkIndexCodes);
|
||||
System.out.println(carDoorDevice);
|
||||
Map<String, Object> root = HKUtil.getRoot();
|
||||
System.out.println(root);
|
||||
|
||||
// PageData pageData = new PageData();
|
||||
// Boolean hasNext = true;
|
||||
// List<PageData> doorList = new ArrayList<>();
|
||||
// int pageNo = 1;
|
||||
// int pageSize = 100;
|
||||
// while (hasNext) {
|
||||
// pageData.put("pageNo",pageNo);
|
||||
// pageData.put("pageSize",pageSize);
|
||||
// Map<String, Object> gateMachineInfo = HKUtil.getGateMachineInfo(pageData);
|
||||
// JSONObject data = (JSONObject) gateMachineInfo.get("data");
|
||||
// Object list = data.get("list");
|
||||
// List<PageData> 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<PageData> 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<String, Object> gateMachineInfo = HKUtil.getGateMachineInfo(pageData);
|
||||
JSONObject data = (JSONObject) gateMachineInfo.get("data");
|
||||
Object list = data.get("list");
|
||||
List<PageData> 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
|
||||
|
|
|
@ -32,7 +32,9 @@
|
|||
resourceType,
|
||||
sort,
|
||||
treatyType,
|
||||
updateTime
|
||||
updateTime,
|
||||
parkIndexCode,
|
||||
roadNum
|
||||
</sql>
|
||||
|
||||
<!-- 字段值 -->
|
||||
|
@ -60,7 +62,9 @@
|
|||
#{resourceType},
|
||||
#{sort},
|
||||
#{treatyType},
|
||||
#{updateTime}
|
||||
#{updateTime},
|
||||
#{parkIndexCode},
|
||||
#{roadNum}
|
||||
</sql>
|
||||
|
||||
<!-- 新增-->
|
||||
|
@ -109,7 +113,9 @@
|
|||
resourceType = #{resourceType},
|
||||
sort = #{sort},
|
||||
treatyType = #{treatyType},
|
||||
updateTime = #{updateTime}
|
||||
updateTime = #{updateTime},
|
||||
parkIndexCode= #{parkIndexCode},
|
||||
roadNum = #{roadNum}
|
||||
where
|
||||
indexCode = #{indexCode}
|
||||
</update>
|
||||
|
|
Loading…
Reference in New Issue