Browse Source

Merge branch 'dev_trial' of https://gitea.free-sun.vip/free-sun/FS-IOT into dev_trial

release_0.0.2
wenlele 2 years ago
parent
commit
8d29279fd9
  1. 196
      code/VideoAccess-VCMP/api/app/lib/schedule/freshYingshiState.js
  2. 14
      code/VideoAccess-VCMP/api/app/lib/service/socket.js
  3. 2
      code/VideoAccess-VCMP/api/app/lib/utils/xlsxDownload.js
  4. 27
      code/VideoAccess-VCMP/web/client/src/app.jsx
  5. 16
      code/VideoAccess-VCMP/web/client/src/layout/actions/webSocket.js
  6. 5
      code/VideoAccess-VCMP/web/client/src/layout/index.jsx
  7. 4
      code/VideoAccess-VCMP/web/package.json

196
code/VideoAccess-VCMP/api/app/lib/schedule/freshYingshiState.js

@ -7,107 +7,107 @@ module.exports = function (app, opts) {
'*/1 * * * *', '*/1 * * * *',
async () => { async () => {
// try { try {
// const startTime = moment() const startTime = moment()
// const { models } = app.fs.dc const { models } = app.fs.dc
// const { token4yingshi } = app.fs.utils const { token4yingshi } = app.fs.utils
// const secretRes = await models.SecretYingshi.findAll() const secretRes = await models.SecretYingshi.findAll()
// let deviceList = [] let deviceList = []
// for (let s of secretRes) { for (let s of secretRes) {
// const tokenYingshi = await token4yingshi(s.dataValues) const tokenYingshi = await token4yingshi(s.dataValues)
// // 查询所有设备 // 查询所有设备
// let pageStart = 0 let pageStart = 0
// while (pageStart >= 0) { while (pageStart >= 0) {
// const deviceRes = await app.fs.yingshiRequest.post('lapp/device/list', { const deviceRes = await app.fs.yingshiRequest.post('lapp/device/list', {
// query: { query: {
// accessToken: tokenYingshi, accessToken: tokenYingshi,
// pageStart, pageStart,
// pageSize: 50 pageSize: 50
// } }
// }) })
// if (deviceRes.code == 200) { if (deviceRes.code == 200) {
// if (deviceRes.data.length) { if (deviceRes.data.length) {
// deviceList = deviceList.concat.apply(deviceList, deviceRes.data) deviceList = deviceList.concat.apply(deviceList, deviceRes.data)
// for (let d of deviceRes.data) { for (let d of deviceRes.data) {
// const existD = await models.GbCamera.findOne({ const existD = await models.GbCamera.findOne({
// where: { where: {
// streamid: d.deviceSerial streamid: d.deviceSerial
// } }
// }) })
// let storageD = { let storageD = {
// level: 0, level: 0,
// ipctype: 'yingshi', ipctype: 'yingshi',
// streamid: d.deviceSerial, streamid: d.deviceSerial,
// online: d.status ? 'ON' : 'OFF', online: d.status ? 'ON' : 'OFF',
// name: d.deviceName, name: d.deviceName,
// } }
// if (existD) { if (existD) {
// if (existD.online != storageD.online) { if (existD.online != storageD.online) {
// // 状态更新 // 状态更新
// await models.GbCamera.update(storageD, { await models.GbCamera.update(storageD, {
// where: { where: {
// id: existD.id id: existD.id
// } }
// }) })
// // 状态推送 // 状态推送
// // const { connected } = app.socket.sockets const { connected } = app.socket.sockets
// // const roomId = 'ROOM_' + Math.random() + '_' + d.deviceSerial const roomId = 'ROOM_' + Math.random() + '_' + d.deviceSerial
// // let cameraName = '' let cameraName = ''
// // if (connected) { if (connected) {
// // for (let c in connected) { for (let c in connected) {
// // const { client: { conn: { request: { _query } } } } = connected[c] const { client: { conn: { request: { _query } } } } = connected[c]
// // if (_query && _query.token) { if (_query && _query.token) {
// // let userInfo = await app.redis.hget(_query.token, 'userInfo'); let userInfo = await app.redis.hget(_query.token, 'userInfo');
// // if (userInfo) { if (userInfo) {
// // userInfo = JSON.parse(userInfo) userInfo = JSON.parse(userInfo)
// // const corCameraRes = await models.Camera.findOne({ const corCameraRes = await models.Camera.findOne({
// // where: { where: {
// // gbId: existD.id, gbId: existD.id,
// // createUserId: userInfo.id createUserId: userInfo.id
// // } }
// // }) })
// // // TODO 管理员判断 // TODO 管理员判断
// // if (corCameraRes) { if (corCameraRes) {
// // cameraName = corCameraRes.name cameraName = corCameraRes.name
// // connected[c].join(roomId) connected[c].join(roomId)
// // } }
// // } }
// // } }
// // } }
// // app.socket.to(roomId).emit('CAMERA_ONLINE', { app.socket.to(roomId).emit('CAMERA_ONLINE', {
// // ipctype: 'yingshi', ipctype: 'yingshi',
// // online: storageD.online, online: storageD.online,
// // gbId: existD.id, gbId: existD.id,
// // name: cameraName name: cameraName
// // }) })
// // } }
// } }
// } else { } else {
// const yingshiRes = await models.GbCamera.create(storageD) const yingshiRes = await models.GbCamera.create(storageD)
// await models.Camera.update({ await models.Camera.update({
// gbId: yingshiRes.id gbId: yingshiRes.id
// }, { }, {
// where: { where: {
// serialNo: d.deviceSerial serialNo: d.deviceSerial
// } }
// }) })
// } }
// } }
// pageStart++ pageStart++
// } else { } else {
// pageStart = -1 pageStart = -1
// } }
// } }
// } }
// } }
// // console.log(deviceList); // console.log(deviceList);
// console.info(`萤石状态查询用时 ${moment().diff(startTime, 'seconds')} s`) console.info(`萤石状态查询用时 ${moment().diff(startTime, 'seconds')} s`)
// } catch (error) { } catch (error) {
// app.fs.logger.error(`sechedule: freshYingshiState, error: ${error}`); app.fs.logger.error(`sechedule: freshYingshiState, error: ${error}`);
// } }
}); });
return { return {

14
code/VideoAccess-VCMP/api/app/lib/service/socket.js

@ -11,16 +11,16 @@ module.exports = async function factory (app, opts) {
// 使用测试 保持链接 // 使用测试 保持链接
setInterval(async () => { setInterval(async () => {
const { connected } = app.socket.sockets const { connected } = app.socket.sockets
const roomId = 'ROOM_' + Math.random() const roomId = 'ROOM_' + Math.random()
if (connected) { if (connected) {
for (let c in connected) { for (let c in connected) {
connected[c].join(roomId) connected[c].join(roomId)
} }
app.socket.to(roomId).emit('TEST', { someProperty: `【星域 ROOM:${roomId}】呼叫自然选择号!!!`, }) app.socket.to(roomId).emit('TEST', { someProperty: `【星域 ROOM:${roomId}】呼叫自然选择号!!!`, })
} }
app.socket.emit('TEST', { someProperty: '【广播】呼叫青铜时代号!!!', }) // app.socket.emit('TEST', { someProperty: '【广播】呼叫青铜时代号!!!', })
}, 500) }, 3000)
} }

2
code/VideoAccess-VCMP/api/app/lib/utils/xlsxDownload.js

@ -10,7 +10,7 @@ module.exports = function (app, opts) {
//递归创建目录 同步方法 //递归创建目录 同步方法
async function makeDir (dir) { async function makeDir (dir) {
if (!fs.existsSync(dir)) { if (!fs.existsSync(dir)) {
this.makeDir(path.dirname(dir)) makeDir(path.dirname(dir))
fs.mkdirSync(dir, function (err) { fs.mkdirSync(dir, function (err) {
if (err) { if (err) {
throw err throw err

27
code/VideoAccess-VCMP/web/client/src/app.jsx

@ -16,21 +16,22 @@ import application from './sections/application';
import member from './sections/member'; import member from './sections/member';
const App = props => { const App = props => {
const { projectName } = props const { projectName } = props
useEffect(() => { useEffect(() => {
document.title = projectName; document.title = projectName;
}, []) }, [])
return ( return (
<Layout <Layout
title={projectName} title={projectName}
sections={[Example, sections={[
Auth, Monitor, EquipmentWarehouse, AiAbility, offline, // Example,
openness, journaling, archive, application, member, system Auth, Monitor, EquipmentWarehouse, AiAbility, offline,
]} openness, journaling, archive, application, member, system
/> ]}
) />
)
} }
export default App; export default App;

16
code/VideoAccess-VCMP/web/client/src/layout/actions/webSocket.js

@ -23,27 +23,11 @@ export function initWebSocket ({ ioUrl, token }) {
const socket = io( const socket = io(
ioUrl ioUrl
// 'http://127.0.0.1:4000' // 'http://127.0.0.1:4000'
// '_api/'
, { , {
query: { query: {
token: token token: token
}, },
}); });
socket.on("connect", () => {
console.log('connect');
});
socket.io.on("error", (error) => {
console.error(error);
});
socket.io.on("reconnect_error", (error) => {
console.error(error);
});
socket.io.on("reconnect_failed", () => {
console.error(error);
});
socket.on('TEST', function (msg) {
console.info(msg);
});
dispatch({ dispatch({
type: INIT_WEB_SOCKET, type: INIT_WEB_SOCKET,
payload: { payload: {

5
code/VideoAccess-VCMP/web/client/src/layout/index.jsx

@ -84,10 +84,6 @@ const Root = props => {
} }
} }
useEffect(async () => { useEffect(async () => {
let innerRoutes = [] let innerRoutes = []
let outerRoutes = [] let outerRoutes = []
@ -158,7 +154,6 @@ const Root = props => {
// IOT system cross // IOT system cross
window.addEventListener('message', async function (e) { // message window.addEventListener('message', async function (e) { // message
const { data } = e const { data } = e
console.log(e);
if (data && data.action) { if (data && data.action) {
if (data.action == 'initUser') { if (data.action == 'initUser') {
await store.dispatch(actions.auth.initAuth(data.user)) await store.dispatch(actions.auth.initAuth(data.user))

4
code/VideoAccess-VCMP/web/package.json

@ -66,8 +66,8 @@
"perfect-scrollbar": "^1.5.5", "perfect-scrollbar": "^1.5.5",
"qs": "^6.10.5", "qs": "^6.10.5",
"screenfull": "5.2.0", "screenfull": "5.2.0",
"socket.io-client": "^4.5.0", "socket.io-client": "^1.7.4",
"socket.io-parser": "^4.2.0", "socket.io-parser": "^3.4.1",
"superagent": "^6.1.0", "superagent": "^6.1.0",
"webpack": "^5.3.2", "webpack": "^5.3.2",
"webpack-bundle-analyzer": "^4.1.0", "webpack-bundle-analyzer": "^4.1.0",

Loading…
Cancel
Save