Merge remote-tracking branch 'origin/0205cmt' into 0205cmt

0927cmt
songwenxuan 2024-06-06 17:04:01 +08:00
commit 91dd408f2c
10 changed files with 427 additions and 16 deletions

View File

@ -488,7 +488,7 @@ public class OutSourcedController extends BaseController {
String errInfo = "success";
PageData pd = new PageData();
pd = this.getPageData();
if (!StringUtils.equals(Jurisdiction.getUsername(), "admin")) {
if (!StringUtils.equals(Jurisdiction.getUSER_ID(), "c5187fb9565649a89267f9adf6b0fab6")) {
if (!StringUtils.equals(Jurisdiction.getCORPINFO_ID(), "1e6dbbe16004402f8d2c0e52afd9a676")
&& !StringUtils.equals(Jurisdiction.getCORPINFO_ID(), "3a854eefa7894e06aaa1a2611bca80f6")
&& !StringUtils.equals(Jurisdiction.getCORPINFO_ID(), "020578a4c1f04bc692ee25145c2efbe5")

View File

@ -61,6 +61,8 @@ public class VideoResourcesController extends BaseController {
pd.put("CORPINFO_ID", Jurisdiction.getCORPINFO_ID()); //操作人
pd.put("ISDELETE", "0"); //是否删除
videoResourcesService.save(pd);
// 新增摄像头信息后更新最新的设备国标编号和通道国标编号
videoResourcesService.updateAllNationalCode();
map.put("dockData", JSON.toJSONString(pd));
map.put("result", errInfo);
}else {

View File

@ -3,6 +3,7 @@ package com.zcloud.controller.map;
import com.zcloud.controller.base.BaseController;
import com.zcloud.entity.Page;
import com.zcloud.entity.PageData;
import com.zcloud.service.keyProjects.OutSourcedService;
import com.zcloud.service.map.MapEightService;
import com.zcloud.service.map.MapKetProjectService;
import com.zcloud.util.Jurisdiction;
@ -31,7 +32,7 @@ public class MapKeyProjectController extends BaseController {
private MapKetProjectService mapKetProjectService;
@Autowired
private MapEightService mapEightService;
private OutSourcedService outsourcedService;
@Value("${cfd.prevention.api.url}")
private String cfdUrl;
@ -76,7 +77,11 @@ public class MapKeyProjectController extends BaseController {
pd = this.getPageData();
pd.put("CORPINFO_ID", Jurisdiction.getCORPINFO_ID()); // 企业
page.setPd(pd);
return mapKetProjectService.list(page);
List<PageData> varList = outsourcedService.list(page); //列出OutSourced列表
map.put("varList", varList);
map.put("page", page);
map.put("result", errInfo);
return map;
}
/**

View File

@ -2,6 +2,7 @@ package com.zcloud.mapper.dsno2.keyProjects;
import com.zcloud.entity.Page;
import com.zcloud.entity.PageData;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@ -59,5 +60,32 @@ public interface VideoResourcesMapper {
List<PageData> listByOutsourced(Page page);
List<PageData> getPageOutSourceBySidlistPage(Page pd);
/**
* 线
* @param onlineDeviceList
*/
void updateOnlineStatus(@Param("onlineList") List<String> onlineDeviceList);
/**
* 线
* @param offlineDeviceList
*/
void updateOfflineStatus(@Param("offlineList") List<String> offlineDeviceList);
/**
* 线
*/
void updateOfflineStatusAll();
/**
*
*/
void updateNationalCode();
/**
*
*/
void updateTHONationalCode();
}

View File

@ -53,5 +53,9 @@ public interface VideoResourcesService {
List<PageData> getPageOutSourceBySid(Page pd);
void videoDevicesUpdateOnlineStatus();
void updateAllNationalCode();
}

View File

@ -5,12 +5,17 @@ import com.zcloud.entity.PageData;
import com.zcloud.mapper.dsno2.keyProjects.VideoManagerMapper;
import com.zcloud.mapper.dsno2.keyProjects.VideoResourcesMapper;
import com.zcloud.service.keyProjects.VideoResourcesService;
import com.zcloud.util.HeartBreakUtil;
import com.zcloud.util.InitPageDataUtil;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
*
@ -107,5 +112,54 @@ public class VideoResourcesServiceImpl implements VideoResourcesService {
return videoResourcesMapper.getPageOutSourceBySidlistPage(pd);
}
@Override
public void videoDevicesUpdateOnlineStatus() {
try {
// 从摄像头接口中获取所有摄像头列表
// 获取摄像头列表
List<HashMap> channelList = HeartBreakUtil.getList();
if (channelList != null && channelList.size() > 0) {
Map<String, Boolean> deviceMap = new HashMap<>();
// 将设备列表的设备id和是否在线状态封装到map中
for (HashMap device : channelList) {
// 判断设备状态是否在线根据STATUS字段
Boolean onlineStatus = false;
if (StringUtils.equals(device.get("Status").toString(),"ON")) {
onlineStatus = true;
}
// 将设备国标编号和通道国标编号拼在一起放到key里
deviceMap.put(device.get("DeviceID").toString() + "-" + device.get("ID").toString(), onlineStatus);
}
// 将在线和不在线的设备id分开来
List<String> onlineDeviceList = new ArrayList<>(); // 在线设备id
// 将数据库中的所有设备查询出来
List<PageData> videoResourcesList = videoResourcesMapper.listAll(new PageData());
for (PageData videoResources : videoResourcesList) {
// 将设备列表的设别国标编号和通道国标编号拼在一起
String deviceCombId = videoResources.getString("NATIONAL_STANDARD_ID") + "-" + videoResources.getString("THO_NATIONAL_STANDARD_ID");
if (deviceMap.containsKey(deviceCombId) && deviceMap.get(deviceCombId)) {
onlineDeviceList.add(videoResources.getString("VIDEO_RESOURCES_ID"));
}
}
// 批量更新摄像头在线状态
videoResourcesMapper.updateOnlineStatus(onlineDeviceList);
videoResourcesMapper.updateOfflineStatus(onlineDeviceList);
} else {
// 获取摄像头列表为空
System.out.println("获取摄像头列表为空");
// 批量更新摄像头状态为离线
videoResourcesMapper.updateOfflineStatusAll();
}
} catch (Exception e) {
throw new RuntimeException(e);
}
}
@Override
public void updateAllNationalCode() {
videoResourcesMapper.updateNationalCode();
videoResourcesMapper.updateTHONationalCode();
}
}

View File

@ -0,0 +1,161 @@
package com.zcloud.util;
import com.alibaba.fastjson.JSONObject;
import com.zcloud.entity.PageData;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
*
* luoxiaobao
* www.qdkjchina.com
*/
public class HeartBreakUtil {
private static final String host = "https://arqsp.qhdsafety.com:10010";
// https://arqsp.qhdsafety.com:10010/api/v1/device/list?q=&start=10&limit=10&online=true&sort=ID&order=asc&_=1710834460090
// https://arqsp.qhdsafety.com:10010/api/v1/device/list
private static String URLToken = "MvEXr3blIlazed1m8AfR22l7ZjLYXuF7WCAKL_wEwN7.oxNzExNTk0MjcyLCJwIjoiNTgwNjEwMGMyZDU2Y2UwMmIzZWYwYTZkZTg5NWQ5ZTliYjYwYTIxMGE4Yjc0NDE5OWE4YTEwZWM4OTYyMmMyOCIsInQiOjE3MTA5ODk0NzIsInUiOiIwYjUxNDkwMzcwIn0eyJlIj.GciOiJIUzI1NiIsInR5cCI6IkpXVCJ9eyJhb";
public static void main(String[] args) {
// getLogin();
// getList();
}
public static void logout (){
}
public static String getLogin (){
String sasd = MD5.md5("Zykj@zcloud88888");
PageData pd = new PageData();
pd.put("username", "admin");
pd.put("password", sasd);
pd.put("url_token_only", "true");
Map returnMap = getGETTest(host + "/api/v1/login" , pd);
// 返回结果为空时将返回的token改为空
if (Tools.isEmpty(returnMap)) {
return null;
}
String urlToken = returnMap.get("URLToken").toString();
System.out.println(returnMap);
return urlToken;
}
public static List<HashMap> getList (){
PageData pd = new PageData();
pd.put("token", URLToken);
Map returnMap = getGETTest(host + "/api/v1/device/channellist" , pd);
if (Tools.isEmpty(returnMap)) {
return new ArrayList<>();
}
// System.out.println(returnMap);
// System.out.println(deviceList);
// return (List<HashMap>) returnMap.get("DeviceList");
return (List<HashMap>) returnMap.get("ChannelList");
}
/**
* tokentoken
* @return
*/
public static boolean updateToken() {
String token = getLogin();
// 如果返回token为空则登录获取失败
if (Tools.notEmpty(token)) {
URLToken = getLogin();
return true;
} else {
return false;
}
}
public static Map getGETTest (String httpUrl , PageData pd ){
HttpURLConnection connection = null;
InputStream is = null;
BufferedReader br = null;
StringBuffer result = new StringBuffer();
// ?username=admin&password=234f3424be5a75ad898a1b55f6e34d9e&url_token_only=true
StringBuffer nameValue = new StringBuffer();
Map<Object, Object> map = (Map)pd;
System.out.print("参数:{");
for(Map.Entry<Object, Object> entry : map.entrySet()){
System.out.print(entry.getKey().toString() + ":" + entry.getValue().toString() + ",");
nameValue.append(entry.getKey().toString()+"=" + entry.getValue().toString() + "&");
}
System.out.println("}");
String parameter = "";
if(nameValue.length()>0){
parameter = "?"+nameValue.toString().substring(0,nameValue.length()-1);
}
System.out.println( "地址:"+httpUrl + parameter);
try {
//创建连接
URL url = new URL(httpUrl + parameter);
connection = (HttpURLConnection) url.openConnection();
//设置请求方式
connection.setRequestMethod("GET");
//设置连接超时时间
connection.setReadTimeout(15000);
//开始连接
connection.connect();
//获取响应数据
if (connection.getResponseCode() == 200) {
//获取返回的数据
is = connection.getInputStream();
if (null != is) {
br = new BufferedReader(new InputStreamReader(is, "UTF-8"));
String temp = null;
while (null != (temp = br.readLine())) {
result.append(temp);
}
}
}
} catch (IOException e) {
e.printStackTrace();
} finally {
if (null != br) {
try {
br.close();
} catch (IOException e) {
e.printStackTrace();
}
}
if (null != is) {
try {
is.close();
} catch (IOException e) {
e.printStackTrace();
}
}
//关闭远程连接
connection.disconnect();
}
// return result.toString();
/**
* json,json
*/
JSONObject jsonObject = null;
try{
if (Tools.notEmpty(result.toString())) {
jsonObject = JSONObject.parseObject(result.toString());
Map<String, Object> maps = new HashMap<String, Object>();
maps = HttpClientService.parseJSON2Map(jsonObject);
return maps;
} else {
return null;
}
}catch (Exception e){
e.printStackTrace();
return null;
}
}
}

View File

@ -0,0 +1,68 @@
package com.zcloud.util;
import com.zcloud.service.keyProjects.VideoResourcesService;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.core.annotation.Order;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
/**
* 线
* @author limingyu
* @date 2024-03-21
*/
@Component
@Order(value = 2)
public class VideoHeartBreakScheduled implements ApplicationRunner {
@Resource
private VideoResourcesService videoResourcesService;
/**
* 线
*/
@Scheduled(cron ="0 0/5 * * * ?") //每5分钟执行一次
private void videoEquipmentScheduled(){
try {
System.out.println("============更新摄像头在线状态============");
videoResourcesService.videoDevicesUpdateOnlineStatus();
System.out.println("============更新摄像头状态成功============");
} catch (Exception e) {
throw new RuntimeException(e);
}
}
/**
* LiveGBStokentoken7
*/
@Scheduled(cron ="0 0 0/5 * * ?") //测试 每5天执行一次
private static void getLoginToken() throws Exception{
try {
System.out.println("===============更新LiveGBS登录token============");
boolean result = HeartBreakUtil.updateToken();
if (result) {
System.out.println("===============更新LiveGBS登录token成功=========");
} else {
System.out.println("===============更新LiveGBS登录token失败=========");
}
} catch (Exception e) {
throw new RuntimeException(e);
}
}
/**
*
* @throws Exception
*/
@Override
public void run(ApplicationArguments args) {
try{
getLoginToken();
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}

View File

@ -175,10 +175,12 @@
<select id="datalistPage" parameterType="page" resultType="pd">
select
<include refid="Field"></include>,
pv.INDEXCODE
pv.INDEXCODE,
r.ONLINE_STATUS
from
<include refid="tableName"></include> f
left join bus_platformvideomanagement pv on pv.PLATFORMVIDEOMANAGEMENT_ID = f.PLATFORMVIDEOMANAGEMENT_ID
left join bus_video_resources r on r.VIDEO_RESOURCES_ID = f.VIDEO_RESOURCES_ID
where f.ISDELETE = '0'
<if test="pd.OUTSOURCED_ID != null and pd.OUTSOURCED_ID != ''"><!-- 关键词检索 -->
and f.OUTSOURCED_ID=#{pd.OUTSOURCED_ID}

View File

@ -15,6 +15,7 @@
<sql id="Field">
f.VIDEO_RESOURCES_ID,
f.UNITS_ID,
f.CORPINFO_ID,
f.MODEL,
f.UNIT_USE,
f.PERSON,
@ -22,8 +23,10 @@
f.VIDEONAME,
f.VIDEOURL,
f.REMAKE,
f.CORPINFO_ID,
f.CODE
f.CODE,
f.ONLINE_STATUS,
f.NATIONAL_STANDARD_ID,
f.THO_NATIONAL_STANDARD_ID
</sql>
<!-- 字段用于新增 -->
@ -32,6 +35,7 @@
VIDEONAME,
VIDEOURL,
UNITS_ID,
CORPINFO_ID,
MODEL,
UNIT_USE,
PERSON,
@ -42,26 +46,33 @@
CREATTIME,
OPERATOR,
OPERATTIME,
ISDELETE
ISDELETE,
ONLINE_STATUS,
NATIONAL_STANDARD_ID,
THO_NATIONAL_STANDARD_ID
</sql>
<!-- 字段值 -->
<sql id="FieldValue">
#{VIDEO_RESOURCES_ID},
#{VIDEONAME},
#{VIDEOURL},
#{VIDEONAME},
#{VIDEOURL},
#{UNITS_ID},
#{CORPINFO_ID},
#{MODEL},
#{UNIT_USE},
#{PERSON},
#{PHONE},
#{CODE},
#{REMAKE},
#{CREATOR},
#{CREATTIME},
#{OPERATOR},
#{OPERATTIME},
#{ISDELETE}
#{CODE},
#{REMAKE},
#{CREATOR},
#{CREATTIME},
#{OPERATOR},
#{OPERATTIME},
#{ISDELETE},
#{ONLINE_STATUS},
#{NATIONAL_STANDARD_ID},
#{THO_NATIONAL_STANDARD_ID}
</sql>
<!-- 新增-->
@ -223,4 +234,80 @@
#{item}
</foreach>
</delete>
<update id="updateOnlineStatus">
update
<include refid="tableName"></include>
set
ONLINE_STATUS = 0
where
VIDEO_RESOURCES_ID IN
<foreach collection="onlineList" index="index" open="(" close=")" separator="," item="item">
#{item}
</foreach>
</update>
<update id="updateOfflineStatus">
update
<include refid="tableName"></include>
set
ONLINE_STATUS = 1
where
VIDEO_RESOURCES_ID NOT IN
<foreach collection="offlineList" index="index" open="(" close=")" separator="," item="item">
#{item}
</foreach>
OR NATIONAL_STANDARD_ID IS NULL
</update>
<update id="updateOfflineStatusAll">
update
<include refid="tableName"></include>
set
ONLINE_STATUS = 1
where
ONLINE_STATUS IS NOT NULL
</update>
<update id="updateNationalCode">
UPDATE
<include refid="tableName"></include> bvr1
SET
bvr1.NATIONAL_STANDARD_ID =
(
SELECT
temp.NATIONAL_STANDARD_ID
FROM
(
SELECT
bvr2.VIDEO_RESOURCES_ID,
SUBSTRING_INDEX( SUBSTRING_INDEX( SUBSTRING_INDEX( IF( LOCATE( 'arqsp.qhdsafety.com:10010/play.html', bvr2.VIDEOURL ) > 0, bvr2.VIDEOURL, NULL ), '?', -1 ), '&amp;', 1 ), '=', -1 ) AS NATIONAL_STANDARD_ID
FROM
bus_video_resources bvr2
) temp
WHERE
temp.VIDEO_RESOURCES_ID = bvr1.VIDEO_RESOURCES_ID
)
</update>
<update id="updateTHONationalCode">
UPDATE <include refid="tableName"></include> bvr1
SET bvr1.THO_NATIONAL_STANDARD_ID = (
SELECT
temp.NATIONAL_STANDARD_ID
FROM
(
SELECT
bvr2.VIDEO_RESOURCES_ID,
SUBSTRING_INDEX(SUBSTRING_INDEX(SUBSTRING_INDEX(SUBSTRING_INDEX( IF ( LOCATE( 'arqsp.qhdsafety.com:10010/play.html', bvr2.VIDEOURL ) > 0, bvr2.VIDEOURL, NULL ), '?', - 1 ),'&amp;',2 ),'&amp;',-1),'=',-1)
AS NATIONAL_STANDARD_ID
FROM
bus_video_resources bvr2
) temp
WHERE
temp.VIDEO_RESOURCES_ID = bvr1.VIDEO_RESOURCES_ID
)
</update>
</mapper>