物联设备拉取录像机自动拉取摄像头
This commit is contained in:
parent
5324a8d969
commit
3df8b6c57e
|
|
@ -285,7 +285,18 @@ public class DeviceManagerController extends JeecgController<DeviceManager, IDev
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设备集成-拉取监控设备
|
* 设备集成-拉取录像机设备
|
||||||
|
*
|
||||||
|
* @param deviceIntegration
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@RequestMapping(value = "/pullRecorder", method = RequestMethod.POST)
|
||||||
|
public Result<String> pullRecorder(@RequestBody DeviceIntegration deviceIntegration) {
|
||||||
|
return service.pullRecorder(deviceIntegration);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备集成-拉取摄像头设备
|
||||||
*
|
*
|
||||||
* @param deviceIntegration
|
* @param deviceIntegration
|
||||||
* @return
|
* @return
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,7 @@ public interface IDeviceManagerService extends IService<DeviceManager> {
|
||||||
void editPreviewSn(DevicePreview devicePreview);
|
void editPreviewSn(DevicePreview devicePreview);
|
||||||
void bindPreview(DevicePreview devicePreview);
|
void bindPreview(DevicePreview devicePreview);
|
||||||
IPage<DeviceIntegration> findCameraPage(Page<DeviceIntegration> page, DeviceIntegration deviceIntegration);
|
IPage<DeviceIntegration> findCameraPage(Page<DeviceIntegration> page, DeviceIntegration deviceIntegration);
|
||||||
|
Result<String> pullRecorder(DeviceIntegration deviceIntegration);
|
||||||
Result<String> pullCamera(DeviceIntegration deviceIntegration);
|
Result<String> pullCamera(DeviceIntegration deviceIntegration);
|
||||||
IPage<DeviceIntegration> findNetworkPage(Page<DeviceIntegration> page, DeviceIntegration deviceIntegration);
|
IPage<DeviceIntegration> findNetworkPage(Page<DeviceIntegration> page, DeviceIntegration deviceIntegration);
|
||||||
IPage<DeviceIntegration> findElectricityPage(Page<DeviceIntegration> page, DeviceIntegration deviceIntegration);
|
IPage<DeviceIntegration> findElectricityPage(Page<DeviceIntegration> page, DeviceIntegration deviceIntegration);
|
||||||
|
|
|
||||||
|
|
@ -240,8 +240,30 @@ public class DeviceManagerServiceImpl extends ServiceImpl<DeviceManagerMapper, D
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 拉取监控设备
|
* 拉取录像机设备
|
||||||
*
|
* @param deviceIntegration
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Result<String> pullRecorder(DeviceIntegration deviceIntegration){
|
||||||
|
String mac = formatMacAddress(deviceIntegration.getSn());
|
||||||
|
CameraInfo cameraInfo = new CameraInfo();
|
||||||
|
cameraInfo.setMac(mac);
|
||||||
|
cameraInfo.setDeviceType(deviceIntegration.getDeviceType());
|
||||||
|
Result<String> res = cameraInfoService.syncRecorderDevice(cameraInfo);
|
||||||
|
if(!res.isSuccess()){
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
res = syncBizService.syncDevice(deviceIntegration.getOrgCode(),deviceIntegration.getSn(),deviceIntegration.getDeviceType());
|
||||||
|
if(!res.isSuccess()){
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
deviceIntegration.setDeviceStatus("正常");
|
||||||
|
baseMapper.editPreviewStatusBySn(deviceIntegration);
|
||||||
|
return Result.OK("拉取设备成功!");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 拉取摄像头设备
|
||||||
* @param deviceIntegration
|
* @param deviceIntegration
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -254,8 +276,8 @@ public class DeviceManagerServiceImpl extends ServiceImpl<DeviceManagerMapper, D
|
||||||
if (!res.isSuccess()) {
|
if (!res.isSuccess()) {
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
res = syncBizService.syncDevice(deviceIntegration.getOrgCode(), deviceIntegration.getSn());
|
res = syncBizService.syncDevice(deviceIntegration.getOrgCode(),deviceIntegration.getSn(),deviceIntegration.getDeviceType());
|
||||||
if (!res.isSuccess()) {
|
if(!res.isSuccess()){
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
deviceIntegration.setDeviceStatus("正常");
|
deviceIntegration.setDeviceStatus("正常");
|
||||||
|
|
@ -352,7 +374,7 @@ public class DeviceManagerServiceImpl extends ServiceImpl<DeviceManagerMapper, D
|
||||||
}
|
}
|
||||||
tqDeviceInfoService.getAllMeter(true);
|
tqDeviceInfoService.getAllMeter(true);
|
||||||
tqDeviceInfoService.getAllCollector(true);
|
tqDeviceInfoService.getAllCollector(true);
|
||||||
syncBizService.syncDevice(deviceIntegration.getOrgCode(), deviceIntegration.getSn());
|
syncBizService.syncDevice(deviceIntegration.getOrgCode(),deviceIntegration.getSn(),deviceIntegration.getDeviceType());
|
||||||
deviceIntegration.setDeviceStatus("正常");
|
deviceIntegration.setDeviceStatus("正常");
|
||||||
baseMapper.editPreviewStatusBySn(deviceIntegration);
|
baseMapper.editPreviewStatusBySn(deviceIntegration);
|
||||||
return Result.OK("拉取水表成功!");
|
return Result.OK("拉取水表成功!");
|
||||||
|
|
@ -379,8 +401,8 @@ public class DeviceManagerServiceImpl extends ServiceImpl<DeviceManagerMapper, D
|
||||||
if (!res.isSuccess()) {
|
if (!res.isSuccess()) {
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
res = syncBizService.syncDevice(deviceIntegration.getOrgCode(), deviceIntegration.getSn());
|
res = syncBizService.syncDevice(deviceIntegration.getOrgCode(),deviceIntegration.getSn(),deviceIntegration.getDeviceType());
|
||||||
if (!res.isSuccess()) {
|
if(!res.isSuccess()){
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
deviceIntegration.setDeviceStatus("正常");
|
deviceIntegration.setDeviceStatus("正常");
|
||||||
|
|
|
||||||
|
|
@ -354,7 +354,7 @@ public class DsElectricityMeterServiceImpl extends ServiceImpl<DsElectricityMete
|
||||||
DsElectricityMeter dme905 = baseMapper.getElectricityMeterPreview(entity905);
|
DsElectricityMeter dme905 = baseMapper.getElectricityMeterPreview(entity905);
|
||||||
dme905.setSim(dcode905);
|
dme905.setSim(dcode905);
|
||||||
baseMapper.updateElectrictySim(dme905);
|
baseMapper.updateElectrictySim(dme905);
|
||||||
syncBizService.syncDevice(dme905.getOrgCode(),sn);
|
syncBizService.syncDevice(dme905.getOrgCode(),sn,"db");
|
||||||
DeviceIntegration deviceIntegration = new DeviceIntegration();
|
DeviceIntegration deviceIntegration = new DeviceIntegration();
|
||||||
deviceIntegration.setDeviceStatus("正常");
|
deviceIntegration.setDeviceStatus("正常");
|
||||||
deviceIntegration.setSn(sn);
|
deviceIntegration.setSn(sn);
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,7 @@ public interface SyncBizMapper extends BaseMapper<NuBaseInfo> {
|
||||||
List<HumidDevice> getHumidDeviceListByDepartId(String departId);
|
List<HumidDevice> getHumidDeviceListByDepartId(String departId);
|
||||||
|
|
||||||
List<CameraInfo> getCameraListBySn(String sn);
|
List<CameraInfo> getCameraListBySn(String sn);
|
||||||
|
List<CameraInfo> getCameraListByParent(String parentId);
|
||||||
List<CameraCapability> getCameraCapabilityBySn(String sn);
|
List<CameraCapability> getCameraCapabilityBySn(String sn);
|
||||||
List<ElectricityMeter> getElectricityMeterListBySn(String sn);
|
List<ElectricityMeter> getElectricityMeterListBySn(String sn);
|
||||||
List<WaterMeter> getWaterMeterListBySn(String sn);
|
List<WaterMeter> getWaterMeterListBySn(String sn);
|
||||||
|
|
|
||||||
|
|
@ -419,6 +419,41 @@
|
||||||
order by id asc
|
order by id asc
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<select id="getCameraListByParent" parameterType="String" resultType="com.nu.modules.syncbiz.entity.CameraInfo">
|
||||||
|
select
|
||||||
|
id,
|
||||||
|
device_index as deviceIndex,
|
||||||
|
device_name as deviceName,
|
||||||
|
device_type as deviceType,
|
||||||
|
device_status as deviceStatus,
|
||||||
|
device_model as deviceModel,
|
||||||
|
ip as ip,
|
||||||
|
mac as mac,
|
||||||
|
region_id as regionId,
|
||||||
|
region_name as regionName,
|
||||||
|
parent_id as parentId,
|
||||||
|
parent_device_name as parentDeviceName,
|
||||||
|
project_id as projectId,
|
||||||
|
project_name as projectName,
|
||||||
|
firmware_ver as firmwareVer,
|
||||||
|
hardware_ver as hardwareVer,
|
||||||
|
manager_auth_type as managerAuthType,
|
||||||
|
msg_auth_type as msgAuthType,
|
||||||
|
sip_code as sipCode,
|
||||||
|
location_name as locationName,
|
||||||
|
system_type as systemType,
|
||||||
|
protocol as protocol,
|
||||||
|
channel as channel,
|
||||||
|
ftp_ip as ftpIp,
|
||||||
|
ftp_port as ftpPort,
|
||||||
|
ftp_username as ftpUsername,
|
||||||
|
ftp_password as ftpPassword,
|
||||||
|
ftp_uploadpath as ftpUploadpath
|
||||||
|
from nu_iot_tplink_camera
|
||||||
|
where parent_id = #{parentId}
|
||||||
|
order by id asc
|
||||||
|
</select>
|
||||||
|
|
||||||
<select id="getCameraCapabilityBySn" parameterType="String" resultType="com.nu.modules.syncbiz.entity.CameraCapability">
|
<select id="getCameraCapabilityBySn" parameterType="String" resultType="com.nu.modules.syncbiz.entity.CameraCapability">
|
||||||
select
|
select
|
||||||
a.id,
|
a.id,
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,6 @@ public interface ISyncBizService extends IService<NuBaseInfo> {
|
||||||
Result<String> syncReleaseIot(String departId, IotSyncBizMQDto dto);
|
Result<String> syncReleaseIot(String departId, IotSyncBizMQDto dto);
|
||||||
Result<String> syncUnbindIot(String departId, IotSyncBizMQDto dto);
|
Result<String> syncUnbindIot(String departId, IotSyncBizMQDto dto);
|
||||||
Result<String> syncUpdateBindIot(String departId, IotSyncBizMQDto dto);
|
Result<String> syncUpdateBindIot(String departId, IotSyncBizMQDto dto);
|
||||||
Result<String> syncDevice(String orgCode, String sn);
|
Result<String> syncDevice(String orgCode, String sn, String deviceType);
|
||||||
String addLog(String orgCode,String orgName,String json,String type,String iotType);
|
String addLog(String orgCode,String orgName,String json,String type,String iotType);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,8 @@ import org.jeecg.common.api.vo.Result;
|
||||||
import org.springframework.beans.BeanUtils;
|
import org.springframework.beans.BeanUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -367,37 +369,79 @@ public class SyncBizServiceImpl extends ServiceImpl<SyncBizMapper, NuBaseInfo> i
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Result<String> syncDevice(String orgCode,String sn){
|
public Result<String> syncDevice(String orgCode,String sn, String deviceType){
|
||||||
if(orgCode!=null&&!orgCode.equals("")){
|
if(orgCode!=null&&!orgCode.equals("")){
|
||||||
System.out.println("==========>开始发送MQ");
|
System.out.println("==========>开始发送MQ");
|
||||||
System.out.println("==========>orgCode:"+orgCode);
|
System.out.println("==========>orgCode:"+orgCode);
|
||||||
System.out.println("==========>sn:"+sn);
|
System.out.println("==========>sn:"+sn);
|
||||||
System.out.println("==========>结束发送MQ");
|
System.out.println("==========>结束发送MQ");
|
||||||
IotSyncBizMQDto dto = new IotSyncBizMQDto();
|
IotSyncBizMQDto dto = new IotSyncBizMQDto();
|
||||||
//通过sn获取摄像头列表
|
|
||||||
List<CameraInfo> cameraList = baseMapper.getCameraListBySn(sn);
|
|
||||||
if(cameraList.size()>0){
|
|
||||||
for(int i=0;i<cameraList.size();i++){
|
|
||||||
CameraInfo entity = cameraList.get(i);
|
|
||||||
String resId = addLog(orgCode,"", JSON.toJSONString(entity),"推送","TPLINK");
|
|
||||||
entity.setLogId(resId);
|
|
||||||
}
|
|
||||||
List<IotCameraInfoMQDto> cameraMQDtoList = BeanUtil.copyToList(cameraList, IotCameraInfoMQDto.class);
|
|
||||||
//将摄像头信息存放到MQ类中
|
|
||||||
dto.setCameraInfoList(cameraMQDtoList);
|
|
||||||
}
|
|
||||||
|
|
||||||
//通过sn获取摄像头获取能力集信息
|
if(deviceType.equals("NETWORKVIDEORECORDER")){
|
||||||
List<CameraCapability> capabilityList = baseMapper.getCameraCapabilityBySn(sn);
|
List<CameraInfo> deviceList = new ArrayList<>();
|
||||||
if(capabilityList.size()>0){
|
List<CameraCapability> ipcCapabilityList = new ArrayList<>();
|
||||||
for(int i=0;i<capabilityList.size();i++){
|
List<CameraInfo> cameraList = baseMapper.getCameraListBySn(sn);
|
||||||
CameraCapability entity = capabilityList.get(i);
|
if(cameraList.size()>0){
|
||||||
String resId = addLog(orgCode,"", JSON.toJSONString(entity),"推送","摄像头能力集");
|
for(int i=0;i<cameraList.size();i++){
|
||||||
entity.setLogId(resId);
|
CameraInfo entity = cameraList.get(i);
|
||||||
|
String resId = addLog(orgCode,"", JSON.toJSONString(entity),"推送","TPLINK");
|
||||||
|
entity.setLogId(resId);
|
||||||
|
deviceList.add(entity);
|
||||||
|
|
||||||
|
List<CameraInfo> childList = baseMapper.getCameraListByParent(entity.getDeviceIndex());
|
||||||
|
if(childList.size()>0){
|
||||||
|
for(int j=0;j<childList.size();j++){
|
||||||
|
CameraInfo child = childList.get(j);
|
||||||
|
String cresId = addLog(orgCode,"", JSON.toJSONString(child),"推送","TPLINK");
|
||||||
|
child.setLogId(cresId);
|
||||||
|
deviceList.add(child);
|
||||||
|
|
||||||
|
//通过sn获取摄像头获取能力集信息
|
||||||
|
List<CameraCapability> capabilityList = baseMapper.getCameraCapabilityBySn(child.getMac());
|
||||||
|
if(capabilityList.size()>0){
|
||||||
|
for(int k=0;k<capabilityList.size();k++){
|
||||||
|
CameraCapability capability = capabilityList.get(k);
|
||||||
|
String presId = addLog(orgCode,"", JSON.toJSONString(capability),"推送","摄像头能力集");
|
||||||
|
capability.setLogId(presId);
|
||||||
|
ipcCapabilityList.add(capability);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
List<IotCameraInfoMQDto> cameraMQDtoList = BeanUtil.copyToList(deviceList, IotCameraInfoMQDto.class);
|
||||||
|
//将摄像头信息存放到MQ类中
|
||||||
|
dto.setCameraInfoList(cameraMQDtoList);
|
||||||
|
List<IotCameraCapabilityMQDto> capabilityMQDtoList = BeanUtil.copyToList(ipcCapabilityList, IotCameraCapabilityMQDto.class);
|
||||||
|
//将能力集信息存放到MQ类中
|
||||||
|
dto.setCapabilityList(capabilityMQDtoList);
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
//通过sn获取摄像头列表
|
||||||
|
List<CameraInfo> cameraList = baseMapper.getCameraListBySn(sn);
|
||||||
|
if(cameraList.size()>0){
|
||||||
|
for(int i=0;i<cameraList.size();i++){
|
||||||
|
CameraInfo entity = cameraList.get(i);
|
||||||
|
String resId = addLog(orgCode,"", JSON.toJSONString(entity),"推送","TPLINK");
|
||||||
|
entity.setLogId(resId);
|
||||||
|
}
|
||||||
|
List<IotCameraInfoMQDto> cameraMQDtoList = BeanUtil.copyToList(cameraList, IotCameraInfoMQDto.class);
|
||||||
|
//将摄像头信息存放到MQ类中
|
||||||
|
dto.setCameraInfoList(cameraMQDtoList);
|
||||||
|
}
|
||||||
|
|
||||||
|
//通过sn获取摄像头获取能力集信息
|
||||||
|
List<CameraCapability> capabilityList = baseMapper.getCameraCapabilityBySn(sn);
|
||||||
|
if(capabilityList.size()>0){
|
||||||
|
for(int i=0;i<capabilityList.size();i++){
|
||||||
|
CameraCapability entity = capabilityList.get(i);
|
||||||
|
String resId = addLog(orgCode,"", JSON.toJSONString(entity),"推送","摄像头能力集");
|
||||||
|
entity.setLogId(resId);
|
||||||
|
}
|
||||||
|
List<IotCameraCapabilityMQDto> capabilityMQDtoList = BeanUtil.copyToList(capabilityList, IotCameraCapabilityMQDto.class);
|
||||||
|
//将能力集信息存放到MQ类中
|
||||||
|
dto.setCapabilityList(capabilityMQDtoList);
|
||||||
}
|
}
|
||||||
List<IotCameraCapabilityMQDto> capabilityMQDtoList = BeanUtil.copyToList(capabilityList, IotCameraCapabilityMQDto.class);
|
|
||||||
//将能力集信息存放到MQ类中
|
|
||||||
dto.setCapabilityList(capabilityMQDtoList);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//通过sn获取电表信息
|
//通过sn获取电表信息
|
||||||
|
|
|
||||||
|
|
@ -138,6 +138,10 @@ public class CameraInfo implements Serializable {
|
||||||
private String topTime;
|
private String topTime;
|
||||||
@TableField(exist = false)
|
@TableField(exist = false)
|
||||||
private String isIntensiveMonitor;
|
private String isIntensiveMonitor;
|
||||||
|
@TableField(exist = false)
|
||||||
|
private String hasPassword;
|
||||||
|
@TableField(exist = false)
|
||||||
|
private String activeSupport;
|
||||||
/**护理单元*/
|
/**护理单元*/
|
||||||
@ApiModelProperty(value = "护理单元ID")
|
@ApiModelProperty(value = "护理单元ID")
|
||||||
@Dict(dictTable ="nu_base_info",dicText = "nu_name",dicCode = "nu_id")
|
@Dict(dictTable ="nu_base_info",dicText = "nu_name",dicCode = "nu_id")
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,7 @@ public interface ICameraInfoService extends IService<CameraInfo> {
|
||||||
void sync(String jsonResponse);
|
void sync(String jsonResponse);
|
||||||
void syncCapability(String deviceIndex,String jsonResponse);
|
void syncCapability(String deviceIndex,String jsonResponse);
|
||||||
Result<String> syncAllDevices(CameraInfo cameraInfo);
|
Result<String> syncAllDevices(CameraInfo cameraInfo);
|
||||||
|
Result<String> syncRecorderDevice(CameraInfo cameraInfo);
|
||||||
Result<String> syncDevicesStatus(CameraInfo cameraInfo);
|
Result<String> syncDevicesStatus(CameraInfo cameraInfo);
|
||||||
Result<String> syncProjectIpcDevice(CameraInfo cameraInfo);
|
Result<String> syncProjectIpcDevice(CameraInfo cameraInfo);
|
||||||
Result<JSONObject> getIpcCapability(CameraInfo cameraInfo);
|
Result<JSONObject> getIpcCapability(CameraInfo cameraInfo);
|
||||||
|
|
|
||||||
|
|
@ -329,6 +329,134 @@ public class CameraInfoServiceImpl extends ServiceImpl<CameraInfoMapper, CameraI
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 同步录像机设备
|
||||||
|
*
|
||||||
|
* @param param
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Result<String> syncRecorderDevice(CameraInfo param){
|
||||||
|
String errMsg = "";
|
||||||
|
ProjectInfo pi = new ProjectInfo();
|
||||||
|
pi.setStatus(1);//正常状态
|
||||||
|
List<ProjectInfo> projectList = projectMapper.findList(pi);
|
||||||
|
String[] macs = null;
|
||||||
|
String mac = param.getMac();
|
||||||
|
if(mac!=null&&!mac.equals("")){
|
||||||
|
macs = mac.split(",");
|
||||||
|
}
|
||||||
|
if(projectList!=null&&projectList.size()>0){
|
||||||
|
for(int i=0;i< projectList.size();i++){
|
||||||
|
ProjectInfo projectInfo = projectList.get(i);
|
||||||
|
StringBuffer sb = new StringBuffer();
|
||||||
|
sb.append("{");
|
||||||
|
sb.append("\"start\"").append(":0").append(",");
|
||||||
|
sb.append("\"limit\"").append(":1000").append(",");
|
||||||
|
sb.append("\"filterAnd\"").append(":").append("{");
|
||||||
|
sb.append("\"deviceTypeList\"").append(":[").append("\"").append("NETWORKVIDEORECORDER").append("\"").append("],");
|
||||||
|
if(macs!=null&&macs.length>0){
|
||||||
|
StringBuffer msb = new StringBuffer();
|
||||||
|
for(int m=0;m<macs.length;m++){
|
||||||
|
msb.append("\"").append(macs[m]).append("\",");
|
||||||
|
}
|
||||||
|
String macStr = msb.toString();
|
||||||
|
macStr = macStr.substring(0,macStr.length()-1);
|
||||||
|
sb.append("\"macList\"").append(":[").append(macStr).append("],");
|
||||||
|
}
|
||||||
|
sb.append("\"projectId\"").append(":").append("\"").append(projectInfo.getProjectId()).append("\"");
|
||||||
|
sb.append("},");
|
||||||
|
sb.append("\"sort\"").append(":").append("[{");
|
||||||
|
sb.append("\"key\"").append(":").append("\"deviceIndex\"").append(",");
|
||||||
|
sb.append("\"value\"").append(":").append("\"asc\"");
|
||||||
|
sb.append("}]");
|
||||||
|
sb.append("}");
|
||||||
|
String jsonResponse = tumsApi.getDeviceList(sb.toString());
|
||||||
|
JSONObject jsonObject = new JSONObject(jsonResponse);
|
||||||
|
String errorCode = jsonObject.getStr("error_code");
|
||||||
|
if(errorCode.equals("0")){
|
||||||
|
JSONObject result = (JSONObject)jsonObject.get("result");
|
||||||
|
if(result.getInt("total")>0){
|
||||||
|
JSONArray list = result.getJSONArray("list");
|
||||||
|
for(int j=0;j<list.size();j++){
|
||||||
|
ObjectMapper mapper = new ObjectMapper();
|
||||||
|
JSONObject json = (JSONObject)list.get(j);
|
||||||
|
String jsonString = json.toString();
|
||||||
|
try {
|
||||||
|
CameraInfo cameraInfo = mapper.readValue(jsonString, CameraInfo.class);
|
||||||
|
String sn = cameraInfo.getMac();
|
||||||
|
sn = sn.replaceAll("-","");
|
||||||
|
cameraInfo.setMac(sn);
|
||||||
|
CameraInfo entity = baseMapper.getByDeviceId(cameraInfo);
|
||||||
|
if(entity==null){
|
||||||
|
baseMapper.insert(cameraInfo);
|
||||||
|
}else{
|
||||||
|
//修改
|
||||||
|
cameraInfo.setId(entity.getId());
|
||||||
|
baseMapper.updateById(cameraInfo);
|
||||||
|
}
|
||||||
|
JSONObject extend = json.getJSONObject("extend");
|
||||||
|
if(extend!=null){
|
||||||
|
JSONArray channelList = extend.getJSONArray("channelList");
|
||||||
|
for(int k=0;k<channelList.size();k++){
|
||||||
|
JSONObject channelObj = (JSONObject)channelList.get(k);
|
||||||
|
String channelObjString = channelObj.toString();
|
||||||
|
CameraInfo sxtInfo = mapper.readValue(channelObjString, CameraInfo.class);
|
||||||
|
CameraInfo sxtEntity = baseMapper.getByDeviceId(sxtInfo);
|
||||||
|
if(sxtEntity==null){
|
||||||
|
//新增
|
||||||
|
TumsConfig tumsConfig = tumsConfigMapper.getByCode();
|
||||||
|
sxtInfo.setFtpIp(tumsConfig.getFtpIp());
|
||||||
|
sxtInfo.setFtpPort(tumsConfig.getFtpPort());
|
||||||
|
sxtInfo.setFtpUsername(tumsConfig.getFtpUsername());
|
||||||
|
sxtInfo.setFtpPassword(tumsConfig.getFtpPassword());
|
||||||
|
sxtInfo.setFtpUploadpath(tumsConfig.getFtpUploadpath());
|
||||||
|
String sxtMac = sxtInfo.getMac();
|
||||||
|
sxtMac = sxtMac.replaceAll("-","");
|
||||||
|
sxtInfo.setMac(sxtMac);
|
||||||
|
baseMapper.insert(sxtInfo);
|
||||||
|
}else{
|
||||||
|
//修改
|
||||||
|
sxtInfo.setId(sxtEntity.getId());
|
||||||
|
baseMapper.updateById(sxtInfo);
|
||||||
|
}
|
||||||
|
syncIpcCapability(sxtInfo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//同步能力集
|
||||||
|
if(cameraInfo.getDeviceType().equals("SURVEILLANCECAMERA")) {
|
||||||
|
syncIpcCapability(cameraInfo);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
errMsg = "拉取设备失败,请检查设备标识!";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}else{
|
||||||
|
try{
|
||||||
|
ErrorCode errVo = errorCodeService.getByCode(errorCode);
|
||||||
|
errMsg += errVo.getErrorMsg();
|
||||||
|
}catch (Exception e){
|
||||||
|
errMsg += errorCode;
|
||||||
|
}
|
||||||
|
log.info("syncAllDevices:{}",errMsg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if(errMsg.equals("")){
|
||||||
|
return Result.OK("同步设备成功!");
|
||||||
|
}else{
|
||||||
|
return Result.error(errMsg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 同步设备在线状态
|
* 同步设备在线状态
|
||||||
*
|
*
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue