监控设备页面优化
This commit is contained in:
parent
239a82088c
commit
e8b2bbe02d
|
|
@ -155,7 +155,19 @@ public class CameraInfoController extends JeecgController<CameraInfo, ICameraInf
|
|||
}
|
||||
|
||||
/**
|
||||
* 同步此项目下的IPC设备
|
||||
* 同步设备在线状态
|
||||
*
|
||||
* @param cameraInfo
|
||||
* @return
|
||||
*/
|
||||
@GetMapping(value = "/syncDevicesStatus")
|
||||
public Result<String> syncDevicesStatus(CameraInfo cameraInfo) {
|
||||
return service.syncDevicesStatus(cameraInfo);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 同步此项目下的IPC设备 作废
|
||||
*
|
||||
* @param cameraInfo
|
||||
* @return
|
||||
|
|
|
|||
|
|
@ -323,6 +323,8 @@ public class CameraInfo implements Serializable {
|
|||
private String maintainStatus;//维修状态 0正常 1报修 2报废
|
||||
private String reserveDepartId;//预留机构ID
|
||||
private String reserveDepartName;//预留机构名称
|
||||
private String remarks;//备注
|
||||
private String izAllocate;//是否分配
|
||||
|
||||
@TableField(exist = false)
|
||||
private String checkType;
|
||||
|
|
|
|||
|
|
@ -28,7 +28,9 @@ public class CameraCapabilitySyncJob implements Job {
|
|||
//摄像头能力集同步,每10分钟
|
||||
@Override
|
||||
public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
|
||||
List<CameraInfo> list = service.findAllList();
|
||||
CameraInfo params = new CameraInfo();
|
||||
params.setDeviceType("SURVEILLANCECAMERA");
|
||||
List<CameraInfo> list = service.findAllList(params);
|
||||
if(list!=null&&list.size()>0){
|
||||
for(int i=0;i< list.size();i++){
|
||||
CameraInfo cameraInfo = list.get(i);
|
||||
|
|
|
|||
|
|
@ -37,28 +37,132 @@ public class CameraDeviceSyncJob implements Job {
|
|||
if(projectList!=null&&projectList.size()>0){
|
||||
for(int i=0;i< projectList.size();i++){
|
||||
ProjectInfo projectInfo = projectList.get(i);
|
||||
String jsonRequest = "{\n" +
|
||||
" \"start\": 0,\n" +
|
||||
" \"limit\": 1000,\n" +
|
||||
" \"filterAnd\": {\n"+
|
||||
" \"projectId\": \""+projectInfo.getProjectId()+"\",\n"+
|
||||
" \"deviceTypeList\": [\"SURVEILLANCECAMERA\"]\n"+
|
||||
" },\n"+
|
||||
" \"sort\": [{\n"+
|
||||
" \"key\": \"deviceIndex\",\n"+
|
||||
" \"value\": \"asc\"\n"+
|
||||
" }]\n"+
|
||||
"}";
|
||||
// System.out.println(jsonRequest);
|
||||
String jsonResponse = tumsApi.getDeviceList(jsonRequest);
|
||||
JSONObject jsonObject = new JSONObject(jsonResponse);
|
||||
String errorCode = jsonObject.getStr("error_code");
|
||||
if(errorCode.equals("0")){
|
||||
service.sync(jsonResponse);
|
||||
}else{
|
||||
log.error("CameraDeviceSyncJob:{}-{}", DateUtils.now(),jsonObject.getStr("msg"));
|
||||
}
|
||||
getRecorder(projectInfo.getProjectId());
|
||||
getCamera(projectInfo.getProjectId());
|
||||
getRouter(projectInfo.getProjectId());
|
||||
getSwitch(projectInfo.getProjectId());
|
||||
getAp(projectInfo.getProjectId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//获取录像机
|
||||
private void getRecorder(String projectId){
|
||||
String jsonRequest = "{\n" +
|
||||
" \"start\": 0,\n" +
|
||||
" \"limit\": 1000,\n" +
|
||||
" \"filterAnd\": {\n"+
|
||||
" \"projectId\": \""+projectId+"\",\n"+
|
||||
" \"deviceTypeList\": [\"NETWORKVIDEORECORDER\"]\n"+
|
||||
" },\n"+
|
||||
" \"sort\": [{\n"+
|
||||
" \"key\": \"deviceIndex\",\n"+
|
||||
" \"value\": \"asc\"\n"+
|
||||
" }]\n"+
|
||||
"}";
|
||||
String jsonResponse = tumsApi.getDeviceList(jsonRequest);
|
||||
JSONObject jsonObject = new JSONObject(jsonResponse);
|
||||
String errorCode = jsonObject.getStr("error_code");
|
||||
if(errorCode.equals("0")){
|
||||
service.sync(jsonResponse);
|
||||
}else{
|
||||
log.error("CameraDeviceSyncJob-getRecorder:{}-{}", DateUtils.now(),jsonObject.getStr("msg"));
|
||||
}
|
||||
}
|
||||
|
||||
//获取摄像头
|
||||
private void getCamera(String projectId){
|
||||
String jsonRequest = "{\n" +
|
||||
" \"start\": 0,\n" +
|
||||
" \"limit\": 1000,\n" +
|
||||
" \"filterAnd\": {\n"+
|
||||
" \"projectId\": \""+projectId+"\",\n"+
|
||||
" \"deviceTypeList\": [\"SURVEILLANCECAMERA\"]\n"+
|
||||
" },\n"+
|
||||
" \"sort\": [{\n"+
|
||||
" \"key\": \"deviceIndex\",\n"+
|
||||
" \"value\": \"asc\"\n"+
|
||||
" }]\n"+
|
||||
"}";
|
||||
String jsonResponse = tumsApi.getDeviceList(jsonRequest);
|
||||
JSONObject jsonObject = new JSONObject(jsonResponse);
|
||||
String errorCode = jsonObject.getStr("error_code");
|
||||
if(errorCode.equals("0")){
|
||||
service.sync(jsonResponse);
|
||||
}else{
|
||||
log.error("CameraDeviceSyncJob-getCamera:{}-{}", DateUtils.now(),jsonObject.getStr("msg"));
|
||||
}
|
||||
}
|
||||
|
||||
//获取路由器
|
||||
private void getRouter(String projectId){
|
||||
String jsonRequest = "{\n" +
|
||||
" \"start\": 0,\n" +
|
||||
" \"limit\": 1000,\n" +
|
||||
" \"filterAnd\": {\n"+
|
||||
" \"projectId\": \""+projectId+"\",\n"+
|
||||
" \"deviceTypeList\": [\"ROUTER\"]\n"+
|
||||
" },\n"+
|
||||
" \"sort\": [{\n"+
|
||||
" \"key\": \"deviceIndex\",\n"+
|
||||
" \"value\": \"asc\"\n"+
|
||||
" }]\n"+
|
||||
"}";
|
||||
String jsonResponse = tumsApi.getDeviceList(jsonRequest);
|
||||
JSONObject jsonObject = new JSONObject(jsonResponse);
|
||||
String errorCode = jsonObject.getStr("error_code");
|
||||
if(errorCode.equals("0")){
|
||||
service.sync(jsonResponse);
|
||||
}else{
|
||||
log.error("CameraDeviceSyncJob-getRouter:{}-{}", DateUtils.now(),jsonObject.getStr("msg"));
|
||||
}
|
||||
}
|
||||
|
||||
//获取交换机
|
||||
private void getSwitch(String projectId){
|
||||
String jsonRequest = "{\n" +
|
||||
" \"start\": 0,\n" +
|
||||
" \"limit\": 1000,\n" +
|
||||
" \"filterAnd\": {\n"+
|
||||
" \"projectId\": \""+projectId+"\",\n"+
|
||||
" \"deviceTypeList\": [\"SWITCH\"]\n"+
|
||||
" },\n"+
|
||||
" \"sort\": [{\n"+
|
||||
" \"key\": \"deviceIndex\",\n"+
|
||||
" \"value\": \"asc\"\n"+
|
||||
" }]\n"+
|
||||
"}";
|
||||
String jsonResponse = tumsApi.getDeviceList(jsonRequest);
|
||||
JSONObject jsonObject = new JSONObject(jsonResponse);
|
||||
String errorCode = jsonObject.getStr("error_code");
|
||||
if(errorCode.equals("0")){
|
||||
service.sync(jsonResponse);
|
||||
}else{
|
||||
log.error("CameraDeviceSyncJob-getSwitch:{}-{}", DateUtils.now(),jsonObject.getStr("msg"));
|
||||
}
|
||||
}
|
||||
|
||||
//获取无线AP
|
||||
private void getAp(String projectId){
|
||||
String jsonRequest = "{\n" +
|
||||
" \"start\": 0,\n" +
|
||||
" \"limit\": 1000,\n" +
|
||||
" \"filterAnd\": {\n"+
|
||||
" \"projectId\": \""+projectId+"\",\n"+
|
||||
" \"deviceTypeList\": [\"AP\"]\n"+
|
||||
" },\n"+
|
||||
" \"sort\": [{\n"+
|
||||
" \"key\": \"deviceIndex\",\n"+
|
||||
" \"value\": \"asc\"\n"+
|
||||
" }]\n"+
|
||||
"}";
|
||||
String jsonResponse = tumsApi.getDeviceList(jsonRequest);
|
||||
JSONObject jsonObject = new JSONObject(jsonResponse);
|
||||
String errorCode = jsonObject.getStr("error_code");
|
||||
if(errorCode.equals("0")){
|
||||
service.sync(jsonResponse);
|
||||
}else{
|
||||
log.error("CameraDeviceSyncJob-getAp:{}-{}", DateUtils.now(),jsonObject.getStr("msg"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ import java.util.List;
|
|||
public interface CameraInfoMapper extends BaseMapper<CameraInfo> {
|
||||
IPage<CameraInfo> findPage(Page<CameraInfo> page, @Param("params") CameraInfo cameraInfo);
|
||||
List<CameraInfo> findList(CameraInfo cameraInfo);
|
||||
List<CameraInfo> findAllList();
|
||||
List<CameraInfo> findAllList(CameraInfo cameraInfo);
|
||||
IPage<CameraInfo> findNuPage(Page<CameraInfo> page, @Param("params") CameraInfo cameraInfo);
|
||||
CameraInfo getByDeviceId(CameraInfo cameraInfo);
|
||||
CameraInfo getCapabilityByDeviceId(CameraInfo cameraInfo);
|
||||
|
|
|
|||
|
|
@ -38,7 +38,9 @@
|
|||
a.ftp_uploadpath as ftpUploadpath,
|
||||
a.old_server_url as oldServerUrl,
|
||||
a.sn,
|
||||
a.maintain_status
|
||||
a.maintain_status,
|
||||
a.remarks,
|
||||
a.iz_allocate
|
||||
from nu_iot_tplink_camera a left join nu_base_info b on a.nu_id = b.nu_id
|
||||
left join nu_iot_tplink_camera_capability c on a.device_index = c.device_index
|
||||
<where>
|
||||
|
|
@ -75,6 +77,12 @@
|
|||
<if test="params.checkType != null and params.checkType != '' and params.checkType == 0">
|
||||
AND a.nu_id is null
|
||||
</if>
|
||||
<if test="params.deviceType != null and params.deviceType != ''">
|
||||
AND a.device_type = #{params.deviceType}
|
||||
</if>
|
||||
<if test="params.izAllocate != null and params.izAllocate != ''">
|
||||
AND a.iz_allocate = #{params.izAllocate}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
|
|
@ -108,7 +116,9 @@
|
|||
a.ftp_port as ftpPort,
|
||||
a.ftp_username as ftpUsername,
|
||||
a.ftp_password as ftpPassword,
|
||||
a.ftp_uploadpath as ftpUploadpath
|
||||
a.ftp_uploadpath as ftpUploadpath,
|
||||
a.remarks,
|
||||
a.iz_allocate
|
||||
from nu_iot_tplink_camera a left join nu_base_info b on a.nu_id = b.nu_id
|
||||
<where>
|
||||
<if test="projectId != null and projectId != ''">
|
||||
|
|
@ -152,8 +162,15 @@
|
|||
ftp_port as ftpPort,
|
||||
ftp_username as ftpUsername,
|
||||
ftp_password as ftpPassword,
|
||||
ftp_uploadpath as ftpUploadpath
|
||||
ftp_uploadpath as ftpUploadpath,
|
||||
a.remarks,
|
||||
a.iz_allocate
|
||||
from nu_iot_tplink_camera a
|
||||
<where>
|
||||
<if test="deviceType != null and deviceType != ''">
|
||||
AND device_type = #{deviceType}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="findNuPage" parameterType="com.nu.modules.tplink.camera.entity.CameraInfo" resultType="com.nu.modules.tplink.camera.entity.CameraInfo">
|
||||
|
|
@ -200,7 +217,9 @@
|
|||
a.ftp_port as ftpPort,
|
||||
a.ftp_username as ftpUsername,
|
||||
a.ftp_password as ftpPassword,
|
||||
a.ftp_uploadpath as ftpUploadpath
|
||||
a.ftp_uploadpath as ftpUploadpath,
|
||||
a.remarks,
|
||||
a.iz_allocate
|
||||
from nu_iot_tplink_camera a left join nu_base_info b on a.nu_id = b.id
|
||||
where device_index = #{deviceIndex}
|
||||
</select>
|
||||
|
|
@ -344,7 +363,9 @@
|
|||
a.ftp_port as ftpPort,
|
||||
a.ftp_username as ftpUsername,
|
||||
a.ftp_password as ftpPassword,
|
||||
a.ftp_uploadpath as ftpUploadpath
|
||||
a.ftp_uploadpath as ftpUploadpath,
|
||||
a.remarks,
|
||||
a.iz_allocate
|
||||
from nu_iot_tplink_camera a
|
||||
where device_index = #{deviceIndex}
|
||||
</select>
|
||||
|
|
@ -404,7 +425,9 @@
|
|||
a.old_server_url as oldServerUrl,
|
||||
a.old_depart_id as oldDepartId,
|
||||
a.old_depart_name as oldDepartName,
|
||||
c.area_flag as areaFlag
|
||||
c.area_flag as areaFlag,
|
||||
a.remarks,
|
||||
a.iz_allocate
|
||||
from nu_iot_tplink_camera a
|
||||
left join nu_base_info c on a.nu_id = c.nu_id
|
||||
<where>
|
||||
|
|
@ -507,7 +530,9 @@
|
|||
a.old_server_url as oldServerUrl,
|
||||
a.old_depart_id as oldDepartId,
|
||||
a.old_depart_name as oldDepartName,
|
||||
c.area_flag as areaFlag
|
||||
c.area_flag as areaFlag,
|
||||
a.remarks,
|
||||
a.iz_allocate
|
||||
from nu_iot_tplink_camera a
|
||||
left join nu_base_info c on a.nu_id = c.nu_id
|
||||
where a.depart_server_url = #{params.departServerUrl}
|
||||
|
|
|
|||
|
|
@ -21,13 +21,14 @@ import java.util.Map;
|
|||
public interface ICameraInfoService extends IService<CameraInfo> {
|
||||
IPage<CameraInfo> findPage(Page<CameraInfo> page, CameraInfo cameraInfo);
|
||||
List<CameraTreeModel> findModelList(CameraInfo cameraInfo);
|
||||
List<CameraInfo> findAllList();
|
||||
List<CameraInfo> findAllList(CameraInfo cameraInfo);
|
||||
IPage<CameraInfo> findNuPage(Page<CameraInfo> page, CameraInfo cameraInfo);
|
||||
void edit(CameraInfo cameraInfo);
|
||||
void rebootDevice(CameraInfo cameraInfo);
|
||||
void sync(String jsonResponse);
|
||||
void syncCapability(String deviceIndex,String jsonResponse);
|
||||
Result<String> syncAllDevices(CameraInfo cameraInfo);
|
||||
Result<String> syncDevicesStatus(CameraInfo cameraInfo);
|
||||
Result<String> syncProjectIpcDevice(CameraInfo cameraInfo);
|
||||
Result<JSONObject> getIpcCapability(CameraInfo cameraInfo);
|
||||
Result<JSONObject> getImageCommon(Map<String,Object> map);
|
||||
|
|
|
|||
|
|
@ -89,8 +89,8 @@ public class CameraInfoServiceImpl extends ServiceImpl<CameraInfoMapper, CameraI
|
|||
* 获取所有摄像头信息
|
||||
* @return
|
||||
*/
|
||||
public List<CameraInfo> findAllList(){
|
||||
return baseMapper.findAllList();
|
||||
public List<CameraInfo> findAllList(CameraInfo cameraInfo){
|
||||
return baseMapper.findAllList(cameraInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -195,12 +195,15 @@ public class CameraInfoServiceImpl extends ServiceImpl<CameraInfoMapper, CameraI
|
|||
CameraInfo entity = baseMapper.getByDeviceId(cameraInfo);
|
||||
if(entity==null){
|
||||
//新增
|
||||
TumsConfig tumsConfig = tumsConfigMapper.getByCode();
|
||||
cameraInfo.setFtpIp(tumsConfig.getFtpIp());
|
||||
cameraInfo.setFtpPort(tumsConfig.getFtpPort());
|
||||
cameraInfo.setFtpUsername(tumsConfig.getFtpUsername());
|
||||
cameraInfo.setFtpPassword(tumsConfig.getFtpPassword());
|
||||
cameraInfo.setFtpUploadpath(tumsConfig.getFtpUploadpath());
|
||||
cameraInfo.setIzAllocate("N");
|
||||
if(cameraInfo.getDeviceType().equals("SURVEILLANCECAMERA")) {
|
||||
TumsConfig tumsConfig = tumsConfigMapper.getByCode();
|
||||
cameraInfo.setFtpIp(tumsConfig.getFtpIp());
|
||||
cameraInfo.setFtpPort(tumsConfig.getFtpPort());
|
||||
cameraInfo.setFtpUsername(tumsConfig.getFtpUsername());
|
||||
cameraInfo.setFtpPassword(tumsConfig.getFtpPassword());
|
||||
cameraInfo.setFtpUploadpath(tumsConfig.getFtpUploadpath());
|
||||
}
|
||||
baseMapper.insert(cameraInfo);
|
||||
}else{
|
||||
//修改
|
||||
|
|
@ -255,38 +258,44 @@ public class CameraInfoServiceImpl extends ServiceImpl<CameraInfoMapper, CameraI
|
|||
@Override
|
||||
public Result<String> syncAllDevices(CameraInfo cameraInfo){
|
||||
String errMsg = "";
|
||||
ProjectInfo pi = new ProjectInfo();
|
||||
pi.setStatus(1);//正常状态
|
||||
List<ProjectInfo> projectList = projectMapper.findList(pi);
|
||||
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("\"SURVEILLANCECAMERA\"").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")){
|
||||
syncProjectIpc(jsonResponse);
|
||||
}else{
|
||||
try{
|
||||
ErrorCode errVo = errorCodeService.getByCode(errorCode);
|
||||
errMsg += errVo.getErrorMsg();
|
||||
}catch (Exception e){
|
||||
errMsg += errorCode;
|
||||
String deviceTypes = cameraInfo.getDeviceType();
|
||||
if(deviceTypes!=null&&!deviceTypes.equals("")){
|
||||
ProjectInfo pi = new ProjectInfo();
|
||||
pi.setStatus(1);//正常状态
|
||||
List<ProjectInfo> projectList = projectMapper.findList(pi);
|
||||
String[] dt = deviceTypes.split(",");
|
||||
for(String deviceType :dt){
|
||||
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(deviceType).append("\"").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")){
|
||||
syncProjectIpc(jsonResponse);
|
||||
}else{
|
||||
try{
|
||||
ErrorCode errVo = errorCodeService.getByCode(errorCode);
|
||||
errMsg += errVo.getErrorMsg();
|
||||
}catch (Exception e){
|
||||
errMsg += errorCode;
|
||||
}
|
||||
log.info("syncAllDevices:{}",errMsg);
|
||||
}
|
||||
}
|
||||
log.info("syncAllDevices:{}",errMsg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -298,7 +307,65 @@ public class CameraInfoServiceImpl extends ServiceImpl<CameraInfoMapper, CameraI
|
|||
}
|
||||
|
||||
/**
|
||||
* 同步此项目下的IPC设备
|
||||
* 同步设备在线状态
|
||||
*
|
||||
* @param cameraInfo
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Result<String> syncDevicesStatus(CameraInfo cameraInfo){
|
||||
String errMsg = "";
|
||||
String deviceTypes = cameraInfo.getDeviceType();
|
||||
if(deviceTypes!=null&&!deviceTypes.equals("")){
|
||||
ProjectInfo pi = new ProjectInfo();
|
||||
pi.setStatus(1);//正常状态
|
||||
List<ProjectInfo> projectList = projectMapper.findList(pi);
|
||||
String[] dt = deviceTypes.split(",");
|
||||
for(String deviceType :dt){
|
||||
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(deviceType).append("\"").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")){
|
||||
syncStatus(jsonResponse);
|
||||
}else{
|
||||
try{
|
||||
ErrorCode errVo = errorCodeService.getByCode(errorCode);
|
||||
errMsg += errVo.getErrorMsg();
|
||||
}catch (Exception e){
|
||||
errMsg += errorCode;
|
||||
}
|
||||
log.info("syncDevicesStatus:{}",errMsg);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(errMsg.equals("")){
|
||||
return Result.OK("同步设备成功!");
|
||||
}else{
|
||||
return Result.error(errMsg);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 同步此项目下的IPC设备 作废
|
||||
*
|
||||
* @param cameraInfo
|
||||
* @return
|
||||
|
|
@ -356,12 +423,15 @@ public class CameraInfoServiceImpl extends ServiceImpl<CameraInfoMapper, CameraI
|
|||
CameraInfo entity = baseMapper.getByDeviceId(cameraInfo);
|
||||
if(entity==null){
|
||||
//新增
|
||||
TumsConfig tumsConfig = tumsConfigMapper.getByCode();
|
||||
cameraInfo.setFtpIp(tumsConfig.getFtpIp());
|
||||
cameraInfo.setFtpPort(tumsConfig.getFtpPort());
|
||||
cameraInfo.setFtpUsername(tumsConfig.getFtpUsername());
|
||||
cameraInfo.setFtpPassword(tumsConfig.getFtpPassword());
|
||||
cameraInfo.setFtpUploadpath(tumsConfig.getFtpUploadpath());
|
||||
cameraInfo.setIzAllocate("N");
|
||||
if(cameraInfo.getDeviceType().equals("SURVEILLANCECAMERA")){
|
||||
TumsConfig tumsConfig = tumsConfigMapper.getByCode();
|
||||
cameraInfo.setFtpIp(tumsConfig.getFtpIp());
|
||||
cameraInfo.setFtpPort(tumsConfig.getFtpPort());
|
||||
cameraInfo.setFtpUsername(tumsConfig.getFtpUsername());
|
||||
cameraInfo.setFtpPassword(tumsConfig.getFtpPassword());
|
||||
cameraInfo.setFtpUploadpath(tumsConfig.getFtpUploadpath());
|
||||
}
|
||||
baseMapper.insert(cameraInfo);
|
||||
}else{
|
||||
//修改
|
||||
|
|
@ -369,7 +439,40 @@ public class CameraInfoServiceImpl extends ServiceImpl<CameraInfoMapper, CameraI
|
|||
baseMapper.updateById(cameraInfo);
|
||||
}
|
||||
//同步能力集
|
||||
syncIpcCapability(cameraInfo);
|
||||
if(cameraInfo.getDeviceType().equals("SURVEILLANCECAMERA")) {
|
||||
syncIpcCapability(cameraInfo);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 同步设备在线状态
|
||||
* @param jsonResponse
|
||||
* @return
|
||||
*/
|
||||
private void syncStatus(String jsonResponse){
|
||||
JSONObject jsonObject = new JSONObject(jsonResponse);
|
||||
if(jsonObject.getInt("error_code").equals(0)){
|
||||
JSONObject result = (JSONObject)jsonObject.get("result");
|
||||
if(result.getInt("total")>0){
|
||||
JSONArray list = result.getJSONArray("list");
|
||||
for(int i=0;i<list.size();i++){
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
String jsonString = list.get(i).toString();
|
||||
try {
|
||||
CameraInfo cameraInfo = mapper.readValue(jsonString, CameraInfo.class);
|
||||
CameraInfo entity = baseMapper.getByDeviceId(cameraInfo);
|
||||
if(entity!=null){
|
||||
CameraInfo ci = new CameraInfo();
|
||||
ci.setId(entity.getId());
|
||||
ci.setDeviceStatus(cameraInfo.getDeviceStatus());
|
||||
baseMapper.updateById(ci);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,6 +53,12 @@ public class TumsConfigController extends JeecgController<TumsConfig, ITumsConfi
|
|||
return Result.OK(pageList);
|
||||
}
|
||||
|
||||
@GetMapping(value = "/getByCode")
|
||||
public Result<TumsConfig> getByCode(TumsConfig tumsConfig) {
|
||||
TumsConfig entity = service.getByCode();
|
||||
return Result.OK(entity);
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加
|
||||
*
|
||||
|
|
|
|||
Loading…
Reference in New Issue