|
|
@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONArray; |
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
|
|
|
import com.yxt.supervise.monitor.api.entity.CallPolice; |
|
|
|
import com.yxt.supervise.monitor.api.entity.Device; |
|
|
@ -12,6 +13,7 @@ import com.yxt.supervise.monitor.api.entity.DeviceLog; |
|
|
|
import com.yxt.supervise.monitor.api.entity.MessageInfo; |
|
|
|
import com.yxt.supervise.monitor.api.vo.MessageVo; |
|
|
|
import com.yxt.supervise.monitor.api.vo.PageVo; |
|
|
|
import com.yxt.supervise.monitor.biz.callpolice.CallRest; |
|
|
|
import com.yxt.supervise.monitor.biz.callpolice.YCallPoliceMapper; |
|
|
|
import com.yxt.supervise.monitor.biz.device.YDeviceMapper; |
|
|
|
import com.yxt.supervise.monitor.biz.device.YDeviceService; |
|
|
@ -22,14 +24,14 @@ import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
import javax.annotation.Resource; |
|
|
|
import java.util.Date; |
|
|
|
import java.util.HashMap; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
import java.util.*; |
|
|
|
|
|
|
|
@Service |
|
|
|
public class YMessageInfoService extends ServiceImpl<YMessageInfoMapper, MessageInfo> { |
|
|
|
|
|
|
|
@Resource |
|
|
|
YDeviceService yDeviceService; |
|
|
|
|
|
|
|
@Resource |
|
|
|
YCallPoliceMapper yCallPoliceMapper; |
|
|
|
|
|
|
@ -147,4 +149,44 @@ public class YMessageInfoService extends ServiceImpl<YMessageInfoMapper, Message |
|
|
|
} |
|
|
|
return athleteBOIPage; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void getCallMessage() { |
|
|
|
String url = "https://api2.hik-cloud.com/api/v1/open/basic/devices/list?groupNo=A1181&pageNo=1&pageSize=500"; |
|
|
|
String result = ""; |
|
|
|
try { |
|
|
|
result = HttpUtils.sendGet(url, SyncService.haiKangToken); |
|
|
|
} catch (Exception e) { |
|
|
|
System.out.println(e); |
|
|
|
} |
|
|
|
JSONObject jsonObject = JSONObject.parseObject(result); |
|
|
|
JSONObject dataJson = (JSONObject) jsonObject.get("data"); |
|
|
|
JSONArray jsonArray = (JSONArray) dataJson.get("rows"); |
|
|
|
String deviceSerial = ""; |
|
|
|
String deviceStatus = ""; |
|
|
|
IPage<Device> iPage = new Page<>(); |
|
|
|
List<CallPolice> list = new ArrayList<>(); |
|
|
|
for (Object obj : jsonArray) { |
|
|
|
JSONObject objJson = (JSONObject) obj; |
|
|
|
deviceSerial = objJson.get("deviceSerial").toString(); |
|
|
|
deviceStatus = objJson.get("deviceStatus").toString(); |
|
|
|
if ("0".equals(deviceStatus)) { // 报警
|
|
|
|
CallPolice callPolice = new CallPolice(); |
|
|
|
callPolice.setCreateTime(new Date()); |
|
|
|
callPolice.setMsgType("handAdd"); |
|
|
|
callPolice.setContent("设备离线报警"); |
|
|
|
QueryWrapper<Device> wrapper = new QueryWrapper<>(); |
|
|
|
wrapper.eq("serialNumber", deviceSerial); |
|
|
|
List<Device> listSmall = yDeviceService.list(wrapper); |
|
|
|
if (listSmall.size() > 0) { |
|
|
|
callPolice.setDeviceId(listSmall.get(0).getId().toString()); |
|
|
|
list.add(callPolice); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
for (CallPolice cl : list) { |
|
|
|
yCallPoliceMapper.insert(cl); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|