246 lines
8.4 KiB
Plaintext
246 lines
8.4 KiB
Plaintext
package com.sercurityControl.proteam.service.impl;
|
|
|
|
import com.alibaba.fastjson2.JSON;
|
|
import com.securityControl.common.core.utils.aes.ListHelper;
|
|
import com.securityControl.common.core.utils.aes.StringHelper;
|
|
import com.sercurityControl.proteam.domain.BallGbBean;
|
|
import com.sercurityControl.proteam.domain.BallUpDownEntity;
|
|
import com.sercurityControl.proteam.domain.ParamsVo;
|
|
import com.sercurityControl.proteam.domain.ReturnDataEntity;
|
|
import com.sercurityControl.proteam.domain.ty.ResultValue;
|
|
import com.sercurityControl.proteam.dutyTask.domain.BallStateVo;
|
|
import com.sercurityControl.proteam.mapper.BnsVideoMapper;
|
|
import com.sercurityControl.proteam.service.BnsVideoService;
|
|
import com.sercurityControl.proteam.util.*;
|
|
import org.bytedeco.flycapture.FlyCapture2.MACAddress;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.LoggerFactory;
|
|
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;
|
|
|
|
@Service
|
|
public class BnsVideoServiceImpl implements BnsVideoService {
|
|
private static final Logger log = LoggerFactory.getLogger(BnsVideoServiceImpl.class);
|
|
|
|
@Autowired
|
|
private BnsVideoMapper mapper;
|
|
|
|
@Resource
|
|
private VideoConfigUtil configUtil;
|
|
|
|
|
|
|
|
@Override
|
|
public BallGbBean findBeanByMac(String macId) {
|
|
BallGbBean bean=new BallGbBean();
|
|
List<BallGbBean> list=mapper.findBeanByMac(macId.trim());
|
|
if(list!=null && list.size()>0){
|
|
bean=list.get(0);
|
|
try{
|
|
String config=configUtil.getConfig();
|
|
if("ty".equals(config)){
|
|
List<String> params=new ArrayList<>();
|
|
if(StringHelper.isNotEmpty(bean.getTCode())){
|
|
params.add(bean.getTCode());
|
|
List<ResultValue> result=TyVideoUtil.getDeviceList(params);
|
|
if(ListHelper.isNotEmpty(result)){
|
|
bean.setIsOnline(result.get(0).getStatus());
|
|
}else{
|
|
bean.setIsOnline("1");
|
|
}
|
|
}else{
|
|
bean.setIsOnline("1");
|
|
}
|
|
}else if("all".equals(config)){
|
|
bean.setIsOnline("1");
|
|
}else{
|
|
String status =getBallStateQX(bean.getPuId());
|
|
bean.setIsOnline(status);
|
|
}
|
|
}catch (Exception e){
|
|
log.error(e.toString(),e);
|
|
}
|
|
}
|
|
return bean;
|
|
}
|
|
|
|
/**
|
|
*
|
|
* @param decryptPuid
|
|
* @return
|
|
*/
|
|
@Override
|
|
public String findDeviceStatus(String decryptPuid) {
|
|
String status="1";
|
|
try{
|
|
status =getBallStateQX(decryptPuid);
|
|
}catch (Exception e){
|
|
log.error(e.toString(),e);
|
|
}
|
|
return status;
|
|
}
|
|
|
|
|
|
@Override
|
|
public List<BallUpDownEntity> findBallUpDown(String param) {
|
|
List<BallUpDownEntity> listEntity = new ArrayList<>();
|
|
try{
|
|
ParamsVo paramsVo = JSON.parseObject(param, ParamsVo.class);
|
|
if(StringHelper.isEmpty(paramsVo.getStartTime()) || StringHelper.isEmpty(paramsVo.getEndTime())){
|
|
paramsVo.setStartTime(DateTimeHelper.getNowDate());
|
|
paramsVo.setEndTime(DateTimeHelper.getNowDate());
|
|
}
|
|
String startTime = DateTimeHelper.getStartTime(paramsVo.getStartTime());
|
|
String endTime = DateTimeHelper.getEndTime(paramsVo.getEndTime());
|
|
List<BallGbBean> list=mapper.findBeanByMac(paramsVo.getMacId().trim());
|
|
if(ListHelper.isNotEmpty(list)){
|
|
String puid=list.get(0).getPuId();
|
|
Map<String, Object> map= configUtil.getMaps();
|
|
String url= configUtil.getUrl();
|
|
String token = QxVideotape.login(map,url);
|
|
String xml = QxVideotape.getBallUpDown(puid, token, startTime, endTime,url);
|
|
if (StringHelper.isNotEmpty(xml)) {
|
|
List<BallUpDownEntity> xmlData = PostXml.getXmlData(xml);
|
|
for (BallUpDownEntity entity : xmlData) {
|
|
entity.setPuid(puid);
|
|
listEntity.add(entity);
|
|
}
|
|
}
|
|
}
|
|
}catch (Exception e){
|
|
log.error(e.toString(),e);
|
|
}
|
|
return listEntity;
|
|
}
|
|
|
|
/**
|
|
* 防止异常
|
|
* @param puid
|
|
* @return
|
|
*/
|
|
public String getBallStateQX(String puid){
|
|
String status="1";
|
|
try{
|
|
Map<String, Object> map= configUtil.getMaps();
|
|
String url= configUtil.getUrl();
|
|
String token = QxVideotape.login(map,url);
|
|
if(StringHelper.isEmpty(token)){
|
|
return status;
|
|
}
|
|
status = QxVideotape.getBallStatus(puid.trim(), token,map,url);
|
|
}catch (Exception e){
|
|
log.error(e.toString(),e);
|
|
}
|
|
return status;
|
|
}
|
|
|
|
/**
|
|
* 通过统一视频查询状态
|
|
* @param puids
|
|
* @return
|
|
*/
|
|
public List<BallStateVo> getBallStateTys(List<String> puids){
|
|
List<BallStateVo> list=new ArrayList<>();
|
|
String status="1";
|
|
try{
|
|
List<String> params=new ArrayList<>();
|
|
for (String puid:puids) {
|
|
BallStateVo voo=new BallStateVo();
|
|
params.add(puid);
|
|
List<String> tcodeList=mapper.getTcodeList(params);
|
|
params.clear();
|
|
List<ResultValue> result=TyVideoUtil.getDeviceList(tcodeList);
|
|
if(ListHelper.isNotEmpty(result)){
|
|
voo.setIsOnline(result.get(0).getStatus());
|
|
}else{
|
|
voo.setIsOnline(status);
|
|
}
|
|
voo.setPuid(puid);
|
|
list.add(voo);
|
|
}
|
|
}catch (Exception e){
|
|
for (String puid:puids) {
|
|
BallStateVo voo=new BallStateVo();
|
|
voo.setIsOnline(status);
|
|
voo.setPuid(puid);
|
|
list.add(voo);
|
|
}
|
|
|
|
log.error(e.toString(),e);
|
|
}
|
|
return list;
|
|
}
|
|
|
|
|
|
public String getTyStatus(String puid){
|
|
try{
|
|
List<String> params=new ArrayList<>();
|
|
params.add(puid);
|
|
List<String> tcodeList=mapper.getTcodeList(params);
|
|
List<ResultValue> result=TyVideoUtil.getDeviceList(tcodeList);
|
|
if(ListHelper.isNotEmpty(result)){
|
|
return result.get(0).getStatus();
|
|
}else{
|
|
return "1";
|
|
}
|
|
|
|
}catch (Exception e){
|
|
log.error(e.toString(),e);
|
|
}
|
|
|
|
return "1";
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
* 防止异常
|
|
* @param
|
|
* @return
|
|
*/
|
|
public List<BallStateVo> getBallStateQXS(List<String> puids){
|
|
List<BallStateVo> list=new ArrayList<>();
|
|
String status="1";
|
|
try{
|
|
Map<String, Object> map= configUtil.getMaps();
|
|
String url= configUtil.getUrl();
|
|
String token = QxVideotape.login(map,url);
|
|
List<ReturnDataEntity> returnL = QxVideotape.getBallStatuss(puids, token,url);
|
|
if(ListHelper.isNotEmpty(returnL)){
|
|
for (ReturnDataEntity vo:returnL) {
|
|
BallStateVo voo=new BallStateVo();
|
|
voo.setPuid(vo.getPUID());
|
|
if(StringHelper.isNotEmpty(vo.getOnlineFlag())){
|
|
voo.setIsOnline(vo.getOnlineFlag());
|
|
}else{
|
|
voo.setIsOnline(status);
|
|
}
|
|
list.add(voo);
|
|
}
|
|
}else{
|
|
for (String puid:puids) {
|
|
BallStateVo voo=new BallStateVo();
|
|
voo.setIsOnline(status);
|
|
voo.setPuid(puid);
|
|
list.add(voo);
|
|
}
|
|
}
|
|
}catch (Exception e){
|
|
for (String puid:puids) {
|
|
BallStateVo voo=new BallStateVo();
|
|
voo.setIsOnline(status);
|
|
voo.setPuid(puid);
|
|
list.add(voo);
|
|
}
|
|
|
|
log.error(e.toString(),e);
|
|
}
|
|
return list;
|
|
}
|
|
}
|