204 lines
6.5 KiB
Plaintext
204 lines
6.5 KiB
Plaintext
package com.securityControl.system.service.impl;
|
|
|
|
import com.securityControl.common.core.utils.aes.DateTimeHelper;
|
|
import com.securityControl.common.core.utils.aes.ListHelper;
|
|
import com.securityControl.common.core.utils.aes.StringHelper;
|
|
import com.securityControl.common.redis.service.RedisService;
|
|
import com.securityControl.system.domain.vo.*;
|
|
import com.securityControl.system.mapper.ScheduleBallDao;
|
|
import com.securityControl.system.utils.SysVideoConfigUtil;
|
|
import com.securityControl.system.utils.VideoUtil;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
import javax.annotation.Resource;
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
|
|
/**
|
|
*
|
|
*/
|
|
@Slf4j
|
|
@Service
|
|
public class ScheduleBallServiceImpl {
|
|
|
|
@Autowired
|
|
private ScheduleBallDao dao;
|
|
|
|
@Resource
|
|
SysVideoConfigUtil configUtil;
|
|
|
|
|
|
@Resource
|
|
private RedisService redisService;
|
|
|
|
/**
|
|
* BNS 当日施工球机
|
|
*/
|
|
public void QxDeviceState() {
|
|
try{
|
|
List<String> list=new ArrayList<>();
|
|
list.add("2");list.add("to-2");
|
|
List<SystemDeviceVo> deviceVoList=dao.getSgDevice(list);
|
|
Map<String, Object> map= configUtil.getMaps();
|
|
String url= configUtil.getUrl();
|
|
getQxDeviceState(deviceVoList,map,url);
|
|
}catch (Exception e){
|
|
log.error(e.toString(),e);
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
* Bns 全部球机
|
|
*/
|
|
public void QxUpdateDeviceState() {
|
|
try{
|
|
List<String> list=new ArrayList<>();
|
|
list.add("2");list.add("to-2");
|
|
List<SystemDeviceVo> deviceVoList=dao.getAllDeviceList(list);
|
|
if(ListHelper.isNotEmpty(deviceVoList)){
|
|
Map<String, Object> map= configUtil.getMaps();
|
|
String url= configUtil.getUrl();
|
|
|
|
List<SystemDeviceVo> puids=new ArrayList<>();
|
|
int j=1;
|
|
for (int i = 0; i <deviceVoList.size() ; i++) {
|
|
puids.add(deviceVoList.get(i));
|
|
if(j%50==0){
|
|
getQxDeviceState(puids,map,url);
|
|
puids.clear();
|
|
}
|
|
j++;
|
|
}
|
|
getQxDeviceState(puids,map,url);
|
|
}
|
|
|
|
|
|
}catch (Exception e){
|
|
log.error(e.toString(),e);
|
|
}
|
|
}
|
|
/**
|
|
* 通道二设备解析处理
|
|
* @param deviceVoList
|
|
*/
|
|
public void getQxDeviceState(List<SystemDeviceVo> deviceVoList,Map<String, Object> map , String URL){
|
|
try{
|
|
List<String> params=new ArrayList<>();
|
|
for (SystemDeviceVo dev:deviceVoList) {
|
|
params.add(dev.getPuId());
|
|
}
|
|
if(ListHelper.isNotEmpty(params)) {
|
|
List<SystemReturnEntity> result = VideoUtil.getBallStatus(params, null,map,URL);//返回的数据
|
|
for (SystemReturnEntity data : result) {
|
|
if (StringHelper.isNotEmpty(data.getOnlineFlag())) {//
|
|
dao.updateDeviceState(data, DateTimeHelper.getNowTime());//更新数据库
|
|
}
|
|
}
|
|
}
|
|
}catch (Exception e){
|
|
log.error(e.toString(),e);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
* 上下线记录
|
|
*/
|
|
public void getTyUpdateDeviceTime( ){
|
|
try{
|
|
List<SystemDeviceVo> deviceVoList=dao.getTyDeviceList();//获取施工的统一视频设备
|
|
for (SystemDeviceVo deviceVo:deviceVoList) {//从统一视频获取上线下记录
|
|
String puid=deviceVo.getPuId();
|
|
List<String> list=new ArrayList<>();
|
|
list.add(deviceVo.getTCode());
|
|
List<SDevUpDownVo> upDownVoList =VideoUtil.getDevUpDown(list,DateTimeHelper.getNowDay(),DateTimeHelper.getNextDay());// 查询设备上线下记录
|
|
if(ListHelper.isNotEmpty(upDownVoList)){
|
|
for (SDevUpDownVo vo : upDownVoList) {//上下线记录入库
|
|
if (vo != null) {
|
|
List<SUpDownVo> updownList = vo.getRows();
|
|
if (ListHelper.isNotEmpty(updownList)) {
|
|
for (SUpDownVo upDownVo : updownList) {//
|
|
dao.replaceUpdown(puid,DateTimeHelper.getTimesUPDown(upDownVo.getOnlineTime()),DateTimeHelper.getTimesUPDown(upDownVo.getOfflineTime()),DateTimeHelper.getNextDay());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}catch (Exception e){
|
|
log.error(e.toString(),e);
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
* 通道一 当日施工球机状态更新
|
|
*/
|
|
public void TyDeviceState(){
|
|
try {
|
|
String config=redisService.get("video","config");
|
|
if("ty".equals(config)){
|
|
List<SystemDeviceVo> deviceVoList=dao.getTYClassMettintState();
|
|
getTyDeviceState(deviceVoList);
|
|
}
|
|
}catch (Exception e){
|
|
log.error(e.toString(),e);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 通道一设备处理
|
|
* @param deviceVoList
|
|
*/
|
|
public void getTyDeviceState(List<SystemDeviceVo> deviceVoList){
|
|
try{
|
|
List<String> list=new ArrayList<>();
|
|
if(ListHelper.isNotEmpty(deviceVoList)){
|
|
for (SystemDeviceVo vo:deviceVoList) {
|
|
String tCode=vo.getTCode();
|
|
if(StringHelper.isNotEmpty(tCode)){
|
|
list.add(tCode);
|
|
}
|
|
int size=list.size();
|
|
if(ListHelper.isNotEmpty(list)){
|
|
if(size%40==0){
|
|
getTyDeviceList(list);
|
|
list.clear();
|
|
}
|
|
}
|
|
}
|
|
getTyDeviceList(list);
|
|
}
|
|
|
|
}catch (Exception e){
|
|
log.error(e.toString(),e);
|
|
}
|
|
}
|
|
/**
|
|
* 数据请求进行更改状态
|
|
* @param list
|
|
*/
|
|
public void getTyDeviceList( List<String> list){
|
|
try{
|
|
List<TYDeviceResultValue> resultValues= VideoUtil.getDeviceList(list);
|
|
for (TYDeviceResultValue res: resultValues) {
|
|
if(StringHelper.isNotEmpty(res.getStatus())){
|
|
dao.refreshTyDevice(res);
|
|
}
|
|
|
|
}
|
|
}catch (Exception e){
|
|
log.error(e.toString(),e);
|
|
}
|
|
}
|
|
|
|
}
|