| | |
| | | */ |
| | | package org.springblade.jfpt.equipment.controller; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; |
| | | import io.swagger.annotations.*; |
| | |
| | | import org.springblade.jfpt.equipment.vo.EquipmentVO; |
| | | import org.springblade.jfpt.equipment.vo.EquipmentVOS; |
| | | import org.springblade.jfpt.equipment.wrapper.EqWrapper; |
| | | import org.springblade.jfpt.hk.constant.HkConstant; |
| | | import org.springblade.jfpt.hk.constant.ProtocolConstant; |
| | | import org.springblade.jfpt.hk.util.GetCameraPreviewURL; |
| | | import org.springblade.system.entity.Region; |
| | | import org.springblade.system.user.entity.User; |
| | | import org.springframework.web.bind.annotation.*; |
| | |
| | | page.getRecords().get(j).setDeptName(deptNameBuiffer.substring(0,deptNameBuiffer.length()-1)); |
| | | } |
| | | |
| | | String expireTime = page.getRecords().get(j).getExpireTime(); |
| | | //1.获取当前时间 |
| | | Date dd = new Date(); |
| | | SimpleDateFormat sim = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | | String end = sim.format(dd); |
| | | //把string类型转换为long类型的 |
| | | |
| | | if (expireTime != null) { |
| | | long st = sim.parse(expireTime).getTime(); |
| | | long en = sim.parse(end).getTime(); |
| | | //计算天数 |
| | | int day = (int) ((st - en) / 86400000); |
| | | if (day <= 30) { |
| | | page.getRecords().get(j).setType(1); |
| | | } else { |
| | | page.getRecords().get(j).setType(0); |
| | | } |
| | | } |
| | | |
| | | //判断设备是否在线 |
| | | String Heartbeat = page.getRecords().get(j).getHeartbeat(); |
| | | if (Heartbeat != null){ |
| | | long st = sim.parse(Heartbeat).getTime(); |
| | | long en = sim.parse(end).getTime(); |
| | | if ((en - st) >= (60 * 60 * 24 * 1000)){ |
| | | page.getRecords().get(j).setOnlineStatus("0"); |
| | | }else{ |
| | | page.getRecords().get(j).setOnlineStatus("1"); |
| | | } |
| | | }else{ |
| | | page.getRecords().get(j).setOnlineStatus("0"); |
| | | } |
| | | // String expireTime = page.getRecords().get(j).getExpireTime(); |
| | | // //1.获取当前时间 |
| | | // Date dd = new Date(); |
| | | // SimpleDateFormat sim = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | | // String end = sim.format(dd); |
| | | // //把string类型转换为long类型的 |
| | | // |
| | | // if (expireTime != null) { |
| | | // long st = sim.parse(expireTime).getTime(); |
| | | // long en = sim.parse(end).getTime(); |
| | | // //计算天数 |
| | | // int day = (int) ((st - en) / 86400000); |
| | | // if (day <= 30) { |
| | | // page.getRecords().get(j).setType(1); |
| | | // } else { |
| | | // page.getRecords().get(j).setType(0); |
| | | // } |
| | | // } |
| | | // |
| | | // //判断设备是否在线 |
| | | // String Heartbeat = page.getRecords().get(j).getHeartbeat(); |
| | | // if (Heartbeat != null){ |
| | | // long st = sim.parse(Heartbeat).getTime(); |
| | | // long en = sim.parse(end).getTime(); |
| | | // if ((en - st) >= (60 * 60 * 24 * 1000)){ |
| | | // page.getRecords().get(j).setOnlineStatus("0"); |
| | | // }else{ |
| | | // page.getRecords().get(j).setOnlineStatus("1"); |
| | | // } |
| | | // }else{ |
| | | // page.getRecords().get(j).setOnlineStatus("0"); |
| | | // } |
| | | } |
| | | |
| | | |
| | |
| | | response.setHeader("Access-Control-Allow-Methods", "POST, GET, OPTIONS, DELETE"); |
| | | response.setHeader("Access-Control-Allow-Credentials", "true"); |
| | | //返回 |
| | | return R.data(equipmentService.selectEquimentPlayInfo(equipmentPlayInfo)); |
| | | // equipmentService.selectEquimentPlayInfo(equipmentPlayInfo) |
| | | |
| | | JSONObject res = new JSONObject(); |
| | | |
| | | //根据设备id获取设备编号 |
| | | String result1 = GetCameraPreviewURL.QueryCameraPreviewURL(HkConstant.camerasID, equipmentPlayInfo.getNumber(), "encodeDevice", "deviceCode"); |
| | | |
| | | JSONObject jsonObject1 = JSONObject.parseObject(result1); |
| | | JSONObject res1 = (JSONObject) jsonObject1.get("data"); |
| | | JSONArray arr1 = JSON.parseArray(res1.getString("list")); |
| | | if (arr1.size() > 0){ |
| | | JSONObject data1 = (JSONObject) arr1.get(0); |
| | | String code1 = data1.get("indexCode").toString(); |
| | | |
| | | //根据设备编号获取子节点编号 |
| | | String result2 = GetCameraPreviewURL.QueryCameraPreviewURL(HkConstant.camerasID, code1, "camera", "parentIndexCode"); |
| | | |
| | | JSONObject jsonObject2 = JSONObject.parseObject(result2); |
| | | JSONObject res2 = (JSONObject) jsonObject2.get("data"); |
| | | JSONArray arr2 = JSON.parseArray(res2.getString("list")); |
| | | JSONObject data2 = (JSONObject) arr2.get(0); |
| | | String code2 = data2.get("indexCode").toString(); |
| | | |
| | | //根据子节点编号获取设备播放地址 |
| | | String result3 = GetCameraPreviewURL.GetCameraPreviewURL(HkConstant.previewURLs, code2, ProtocolConstant.HLS); |
| | | res = JSONObject.parseObject(result3); |
| | | } |
| | | |
| | | return R.data(res); |
| | | } |
| | | |
| | | |