|
@@ -36,6 +36,7 @@ public class CameraHKVSSync {
|
|
@Transactional
|
|
@Transactional
|
|
public Result sync(@RequestBody Map<String, Integer> params) throws Exception {
|
|
public Result sync(@RequestBody Map<String, Integer> params) throws Exception {
|
|
Integer farmId = params.get("farmId");
|
|
Integer farmId = params.get("farmId");
|
|
|
|
+ String region = "";
|
|
if (farmId == 21){
|
|
if (farmId == 21){
|
|
//获取默认控制中心 正康区域 的上级,暂时不用
|
|
//获取默认控制中心 正康区域 的上级,暂时不用
|
|
// System.out.println(testGetDefaultUnit());
|
|
// System.out.println(testGetDefaultUnit());
|
|
@@ -63,8 +64,18 @@ public class CameraHKVSSync {
|
|
}
|
|
}
|
|
return new Result(10000, "同步成功", false);
|
|
return new Result(10000, "同步成功", false);
|
|
}else {
|
|
}else {
|
|
|
|
+ switch (farmId){
|
|
|
|
+ case 23:
|
|
|
|
+ region = PJ_REGION;
|
|
|
|
+ break;
|
|
|
|
+ case 24:
|
|
|
|
+ region = DY_REGION;
|
|
|
|
+ break;
|
|
|
|
+ default:
|
|
|
|
+ return new Result(10001,"该牧场无服务",false);
|
|
|
|
+ }
|
|
// 海康新平台
|
|
// 海康新平台
|
|
- String callPostApiGetSubRegions = callPostApiGetSubRegions();
|
|
|
|
|
|
+ String callPostApiGetSubRegions = callPostApiGetSubRegions(region);
|
|
HkvsRegionDto hkvsRegionDto = JSONUtil.toBean(callPostApiGetSubRegions, HkvsRegionDto.class);
|
|
HkvsRegionDto hkvsRegionDto = JSONUtil.toBean(callPostApiGetSubRegions, HkvsRegionDto.class);
|
|
if (ObjectUtil.isNotEmpty(hkvsRegionDto) && "0".equals(hkvsRegionDto.getCode())) {
|
|
if (ObjectUtil.isNotEmpty(hkvsRegionDto) && "0".equals(hkvsRegionDto.getCode())) {
|
|
List<RegionDto> hkvsRegionDtoData = hkvsRegionDto.getData();
|
|
List<RegionDto> hkvsRegionDtoData = hkvsRegionDto.getData();
|
|
@@ -74,11 +85,9 @@ public class CameraHKVSSync {
|
|
cameraAreaService.NewSync(params,hkvsRegionDtoDatumList);
|
|
cameraAreaService.NewSync(params,hkvsRegionDtoDatumList);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- }else {
|
|
|
|
- return new Result(10001, hkvsRegionDto.getMsg(), false);
|
|
|
|
}
|
|
}
|
|
//获取监控点
|
|
//获取监控点
|
|
- String callPostApiGetCameras = callPostApiGetCameras();
|
|
|
|
|
|
+ String callPostApiGetCameras = callPostApiGetCameras(region);
|
|
HkvsNewCameraDto hkvsNewCameraDto = JSONUtil.toBean(callPostApiGetCameras, HkvsNewCameraDto.class);
|
|
HkvsNewCameraDto hkvsNewCameraDto = JSONUtil.toBean(callPostApiGetCameras, HkvsNewCameraDto.class);
|
|
if (ObjectUtil.isNotEmpty(hkvsNewCameraDto) && "0".equals(hkvsNewCameraDto.getCode())) {
|
|
if (ObjectUtil.isNotEmpty(hkvsNewCameraDto) && "0".equals(hkvsNewCameraDto.getCode())) {
|
|
List<NewCameraDto> hkvsNewCameraDtoData = hkvsNewCameraDto.getData();
|
|
List<NewCameraDto> hkvsNewCameraDtoData = hkvsNewCameraDto.getData();
|
|
@@ -268,9 +277,9 @@ public class CameraHKVSSync {
|
|
// System.out.println(hkvsRegionDtoDatumList);
|
|
// System.out.println(hkvsRegionDtoDatumList);
|
|
// }
|
|
// }
|
|
// }
|
|
// }
|
|
- String callPostApiGetCameras = callPostApiGetCameras();
|
|
|
|
|
|
+// String callPostApiGetCameras = callPostApiGetCameras();
|
|
// System.out.println(callPostApiGetCameras);
|
|
// System.out.println(callPostApiGetCameras);
|
|
- HkvsNewCameraDto hkvsNewCameraDto = JSONUtil.toBean(callPostApiGetCameras, HkvsNewCameraDto.class);
|
|
|
|
|
|
+// HkvsNewCameraDto hkvsNewCameraDto = JSONUtil.toBean(callPostApiGetCameras, HkvsNewCameraDto.class);
|
|
// if (ObjectUtil.isNotEmpty(hkvsNewCameraDto) && "0".equals(hkvsNewCameraDto.getCode())) {
|
|
// if (ObjectUtil.isNotEmpty(hkvsNewCameraDto) && "0".equals(hkvsNewCameraDto.getCode())) {
|
|
// List<NewCameraDto> hkvsNewCameraDtoData = hkvsNewCameraDto.getData();
|
|
// List<NewCameraDto> hkvsNewCameraDtoData = hkvsNewCameraDto.getData();
|
|
// for (NewCameraDto hkvsNewCameraDtoDatum : hkvsNewCameraDtoData) {
|
|
// for (NewCameraDto hkvsNewCameraDtoDatum : hkvsNewCameraDtoData) {
|
|
@@ -520,13 +529,15 @@ public class CameraHKVSSync {
|
|
private static final String PJ_REGION = "70405f14-1cb5-4413-8bef-38e4a365cbee";
|
|
private static final String PJ_REGION = "70405f14-1cb5-4413-8bef-38e4a365cbee";
|
|
|
|
|
|
private static final String PW_REGION = "66096289-bd19-4390-a5d5-71a31e970b0b";
|
|
private static final String PW_REGION = "66096289-bd19-4390-a5d5-71a31e970b0b";
|
|
|
|
+
|
|
|
|
+ private static final String DY_REGION = "a09ba2d8-8236-4de6-8e53-9008912d7b72";
|
|
/**
|
|
/**
|
|
* 调用POST请求类型接口,这里以分页获取区域列表为例
|
|
* 调用POST请求类型接口,这里以分页获取区域列表为例
|
|
* 接口实际url:https://ip:port/artemis/api/api/resource/v1/regions
|
|
* 接口实际url:https://ip:port/artemis/api/api/resource/v1/regions
|
|
*
|
|
*
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
- public static String callPostApiGetSubRegions() throws Exception {
|
|
|
|
|
|
+ public static String callPostApiGetSubRegions(String region) throws Exception {
|
|
/**
|
|
/**
|
|
* https://ip:port/artemis/api/resource/v2/regions/subRegions
|
|
* https://ip:port/artemis/api/resource/v2/regions/subRegions
|
|
* 根据区域编号获取下一级区域列表v2
|
|
* 根据区域编号获取下一级区域列表v2
|
|
@@ -544,7 +555,7 @@ public class CameraHKVSSync {
|
|
Map<String, Object> paramMap = new HashMap<String, Object>();// post请求Form表单参数
|
|
Map<String, Object> paramMap = new HashMap<String, Object>();// post请求Form表单参数
|
|
paramMap.put("resourceType", "camera");
|
|
paramMap.put("resourceType", "camera");
|
|
// 正康:500d8b6a-2554-43f3-bda7-e686577eb741 浦江:70405f14-1cb5-4413-8bef-38e4a365cbee 平望:66096289-bd19-4390-a5d5-71a31e970b0b
|
|
// 正康:500d8b6a-2554-43f3-bda7-e686577eb741 浦江:70405f14-1cb5-4413-8bef-38e4a365cbee 平望:66096289-bd19-4390-a5d5-71a31e970b0b
|
|
- paramMap.put("parentIndexCode", PJ_REGION);
|
|
|
|
|
|
+ paramMap.put("parentIndexCode", region);
|
|
paramMap.put("pageNo", 1);
|
|
paramMap.put("pageNo", 1);
|
|
paramMap.put("pageSize", 1000);
|
|
paramMap.put("pageSize", 1000);
|
|
String body = JSON.toJSON(paramMap).toString();
|
|
String body = JSON.toJSON(paramMap).toString();
|
|
@@ -556,7 +567,7 @@ public class CameraHKVSSync {
|
|
return ArtemisHttpUtil.doPostStringArtemis(config, path, body, null, null, "application/json");
|
|
return ArtemisHttpUtil.doPostStringArtemis(config, path, body, null, null, "application/json");
|
|
}
|
|
}
|
|
|
|
|
|
- public static String callPostApiGetCameras() throws Exception {
|
|
|
|
|
|
+ public static String callPostApiGetCameras(String region) throws Exception {
|
|
/**
|
|
/**
|
|
* https://ip:port/artemis/api/resource/v1/regions/regionIndexCode/cameras
|
|
* https://ip:port/artemis/api/resource/v1/regions/regionIndexCode/cameras
|
|
* 根据指定的区域编号获取该区域下的监控点列表信息,返回结果分页展示。
|
|
* 根据指定的区域编号获取该区域下的监控点列表信息,返回结果分页展示。
|
|
@@ -568,7 +579,7 @@ public class CameraHKVSSync {
|
|
config.setAppSecret(NEW_SECRET);// 秘钥appSecret
|
|
config.setAppSecret(NEW_SECRET);// 秘钥appSecret
|
|
final String getCamsApi = ARTEMIS_PATH + CAMERAS_PATH;
|
|
final String getCamsApi = ARTEMIS_PATH + CAMERAS_PATH;
|
|
Map<String, Object> paramMap = new HashMap<String, Object>();// post请求Form表单参数
|
|
Map<String, Object> paramMap = new HashMap<String, Object>();// post请求Form表单参数
|
|
- String[] regionIndexCodes = {PJ_REGION};
|
|
|
|
|
|
+ String[] regionIndexCodes = {region};
|
|
paramMap.put("regionIndexCodes",regionIndexCodes);
|
|
paramMap.put("regionIndexCodes",regionIndexCodes);
|
|
paramMap.put("isSubRegion",true);
|
|
paramMap.put("isSubRegion",true);
|
|
paramMap.put("pageNo",1);
|
|
paramMap.put("pageNo",1);
|