Browse Source

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

release_0.0.2
wenlele 3 years ago
parent
commit
6369ae4c5e
  1. 21
      code/VideoAccess-VCMP/api/app/lib/controllers/camera/create.js
  2. 44
      code/VideoAccess-VCMP/api/app/lib/controllers/camera/index.js
  3. 17
      code/VideoAccess-VCMP/api/app/lib/controllers/nvr/index.js
  4. 7
      code/VideoAccess-VCMP/web/client/src/components/videoPlay.jsx
  5. 9
      code/VideoAccess-VCMP/web/client/src/layout/actions/global.js
  6. 35
      code/VideoAccess-VCMP/web/client/src/layout/components/sider/index.jsx
  7. 4
      code/VideoAccess-VCMP/web/client/src/layout/containers/layout/index.jsx
  8. 8
      code/VideoAccess-VCMP/web/client/src/layout/index.jsx
  9. 6
      code/VideoAccess-VCMP/web/client/src/sections/auth/actions/auth.js
  10. 7
      code/VideoAccess-VCMP/web/client/src/sections/auth/containers/login.jsx
  11. 2
      code/VideoAccess-VCMP/web/client/src/sections/equipmentWarehouse/containers/camera.jsx
  12. 3
      code/VideoAccess-VCMP/web/client/src/utils/index.js
  13. 1
      code/VideoAccess-VCMP/web/client/src/utils/webapi.js
  14. 13
      code/VideoAccess-VCMP/web/config.js
  15. 2
      code/VideoAccess-VCMP/web/package.json
  16. 7
      code/VideoAccess-VCMP/web/routes/attachment/index.js

21
code/VideoAccess-VCMP/api/app/lib/controllers/camera/create.js

@ -350,10 +350,11 @@ async function getCascadeSipList (ctx) {
const { models } = ctx.fs.dc
const sipListRes = await models.GbCamera.findAll({
attributes: ['id', 'streamid'],
attributes: ['id', 'sipip'],
where: {
level: 0,
ipctype: '级联',
sipip: { $ne: null }
}
})
ctx.status = 200;
@ -383,7 +384,9 @@ async function verifyCascadeCamera (ctx) {
async function createCascadeCamera (ctx) {
let errMsg = '添加级联摄像头信息失败'
const transaction = await ctx.fs.dc.orm.transaction();
try {
const { models } = ctx.fs.dc
const { userId, token } = ctx.fs.api
const { sip, externalDomain, cascadeType } = ctx.request.body
const { utils: { getGbCameraLevel3ByStreamId, verifyCascadeInfo } } = ctx.app.fs
@ -396,7 +399,8 @@ async function createCascadeCamera (ctx) {
await models.Camera.findAll({
where: {
type: 'cascade',
serialNo: { $in: allCameraIds }
serialNo: { $in: allCameraIds },
delete: false
}
}) : []
let addData = []
@ -410,13 +414,19 @@ async function createCascadeCamera (ctx) {
}
const added = addedCmeraRes.some(ac => ac.streamid == c.streamid)
if (added) {
updateData.push({
let data = {
...storageData,
id: added.id,
}
updateData.push(data)
await models.Camera.update(data, {
where: { id: added.id },
transaction
})
} else {
addData.push({
...storageData,
type: 'cascade',
serialNo: c.streamid,
createTime: moment().format(),
createUserId: userId,
@ -424,8 +434,13 @@ async function createCascadeCamera (ctx) {
})
}
}
await models.Camera.bulkCreate(addData, {
transaction
})
await transaction.commit();
ctx.status = 204;
} catch (error) {
await transaction.rollback();
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`);
ctx.status = 400;
ctx.body = {

44
code/VideoAccess-VCMP/api/app/lib/controllers/camera/index.js

@ -5,7 +5,7 @@ const moment = require('moment')
async function getCameraProject (ctx, next) {
try {
const models = ctx.fs.dc.models;
const { limit, page, orderBy, orderDirection, keyword, abilityId, type, venderId, nvrId } = ctx.query
const { limit, page, orderBy, orderDirection, keyword, abilityId, type, venderId, nvrId, externalDomain } = ctx.query
const { userId, token } = ctx.fs.api
let findOption = {
@ -22,9 +22,13 @@ async function getCameraProject (ctx, next) {
model: models.CameraKind
}, {
model: models.Nvr,
where: nvrId ? {
id: nvrId
} : {},
required: Boolean(nvrId),
attributes: ['id', 'name', 'serialNo']
}]
}],
distinct: true
}
let abilityFind = {
model: models.CameraAbility
@ -36,11 +40,15 @@ async function getCameraProject (ctx, next) {
findOption.offset = page * limit
}
if (keyword) {
findOption.where.$or = [{
name: { $like: `%${keyword}%` }
}, {
serialNo: { $like: `%${keyword}%` }
}]
findOption.where.name = { $like: `%${keyword}%` }
// findOption.where.$or = [
// {
// name: { $like: `%${keyword}%` }
// },
// // {
// // serialNo: { $like: `%${keyword}%` }
// // }
// ]
}
if (type) {
findOption.where.type = type
@ -53,12 +61,18 @@ async function getCameraProject (ctx, next) {
abilityId: abilityId
}
}
if (externalDomain) {
findOption.where.externalDomain = externalDomain
}
findOption.include.push(abilityFind)
const cameraRes = await models.Camera.findAll(findOption)
const total = await models.Camera.count({
where: findOption.where
})
delete findOption.order
delete findOption.limit
delete findOption.offset
delete findOption.attributes
const total = await models.Camera.count(findOption)
let cameraIds = []
let createUserIds = new Set()
@ -80,12 +94,10 @@ async function getCameraProject (ctx, next) {
: []
for (let { dataValues: camera } of cameraRes) {
const corBindCamera = axbindCameraRes.find(b => b.cameraId == camera.id)
if (corBindCamera) {
camera.station = corBindCamera.stations
} else {
camera.station = []
}
const corBindCamera = axbindCameraRes.filter(b => b.cameraId == camera.id)
camera.station = corBindCamera.reduce((station, c) => {
return station.concat.apply(station, c.stations)
}, [])
const corUser = corUsers.find(u => u.id == camera.createUserId)
camera.createUser = {

17
code/VideoAccess-VCMP/api/app/lib/controllers/nvr/index.js

@ -132,7 +132,24 @@ async function get (ctx) {
findOption.where.venderId = venderId
}
if (state) {
const onLineMap = {
ON: ['ON', 'ONLINE'],
OFF: ['OFF'],
// UNKONW: [],
DISABLED: []
}
let unknowState = []
for (let k in onLineMap) {
unknowState = unknowState.concat(onLineMap[k])
}
gbNvrOption.where = {
online: state == 'UNKONW' ?
{ $notIn: unknowState }
: { $in: onLineMap[state] }
}
gbNvrOption.required = true
}
findOption.include.push(gbNvrOption)

7
code/VideoAccess-VCMP/web/client/src/components/videoPlay.jsx

@ -12,7 +12,12 @@ const VideoPlay = ({ height, width }) => {
const [operationState, setoperationState] = useState()
const operation = [{
key: 'control',
click: () => { console.log(121212); }
click: () => {
console.log(object);
const nextOperationState = JSON.parse(JSON.stringify(operationState))
nextOperationState['control'].select = !nextOperationState['control'].select
setoperationState(nextOperationState)
}
}, {
key: 'talk',
click: () => { console.log(121212); }

9
code/VideoAccess-VCMP/web/client/src/layout/actions/global.js

@ -31,12 +31,13 @@ export function resize (clientHeight, clientWidth) {
export const INIT_API_ROOT = 'INIT_API_ROOT';
export function initApiRoot () {
return dispatch => {
RouteRequest.get(RouteTable.apiRoot).then(res => {
localStorage.setItem('apiRoot', res.root);
dispatch({
return RouteRequest.get(RouteTable.apiRoot).then(res => {
localStorage.setItem('apiRoot', JSON.stringify(res));
return dispatch({
type: INIT_API_ROOT,
payload: {
apiRoot: res.root
apiRoot: res.root,
iotAuthWeb: res.iotAuthWeb
}
})
});

35
code/VideoAccess-VCMP/web/client/src/layout/components/sider/index.jsx

@ -6,7 +6,7 @@ import { push } from 'react-router-redux';
let scrollbar = null
const Sider = props => {
const { collapsed, clientHeight, dispatch } = props
const { collapsed, clientHeight, dispatch, pathname } = props
const [items, setItems] = useState([])
const [selectedKeys, setSelectedKeys] = useState([])
const [openKeys, setOpenKeys] = useState([])
@ -14,6 +14,27 @@ const Sider = props => {
useEffect(() => {
const { sections, dispatch, user } = props;
let nextItems = []
const initKeys = (items, lastKeys) => {
for (let it of items) {
if (it.to && it.to == pathname) {
lastKeys.selectedKeys.push(it.itemKey)
return lastKeys
} else if (it.items && it.items.length) {
const preLastKeys = JSON.parse(JSON.stringify(lastKeys))
preLastKeys.openKeys.push(it.itemKey)
const nextKeys = initKeys(it.items, JSON.parse(JSON.stringify(preLastKeys)))
if (nextKeys.selectedKeys.length > preLastKeys.selectedKeys.length || nextKeys.openKeys.length > preLastKeys.openKeys.length) {
return nextKeys
}
}
}
return lastKeys
return {
selectedKeys: [],
openKeys: []
}
}
for (let c of sections) {
if (typeof c.getNavItem == 'function') {
let item = c.getNavItem(user, dispatch);
@ -24,6 +45,17 @@ const Sider = props => {
}
setItems(nextItems)
const { selectedKeys, openKeys } = initKeys(
nextItems,
{
selectedKeys: [],
openKeys: []
}
)
if (selectedKeys.length || openKeys.length) {
setSelectedKeys(selectedKeys)
setOpenKeys(openKeys)
} else {
const lastSelectedKeys = localStorage.getItem('vcmp_selected_sider')
if (lastSelectedKeys) {
setSelectedKeys(JSON.parse(lastSelectedKeys))
@ -32,6 +64,7 @@ const Sider = props => {
if (lastOpenKeys) {
setOpenKeys(JSON.parse(lastOpenKeys))
}
}
scrollbar = new PerfectScrollbar('#page-slider', { suppressScrollX: true });
}, [])

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

@ -90,9 +90,7 @@ const LayoutContainer = props => {
}}>
<video
autoPlay loop muted
style={{
// width: "100%", objectFit: "cover", objectPosition: 'left top', height: 'calc(100vh - 4px)'
}}
style={{}}
src="/assets/video/cross_loading.mp4"
type="video/mp4"
/>

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

@ -83,7 +83,7 @@ const Root = props => {
}
}
useEffect(() => {
useEffect(async () => {
let innerRoutes = []
let outerRoutes = []
let reducers = {}
@ -126,8 +126,8 @@ const Root = props => {
store.dispatch(resize(document.body.clientHeight, document.body.clientWidth));
store.dispatch(actions.auth.initAuth());
store.dispatch(initWebSocket({}))
store.dispatch(initApiRoot())
const resourceRoot = await store.dispatch(initApiRoot())
console.log(resourceRoot);
const combineRoutes = flatRoutes(innerRoutes);
setInnerRoutes(combineRoutes)
@ -163,7 +163,7 @@ const Root = props => {
setAuthCrossLoading(false)
});
setAuthCrossLoading(false)
// setAuthCrossLoading(false)
}, [])
return (

6
code/VideoAccess-VCMP/web/client/src/sections/auth/actions/auth.js

@ -1,6 +1,6 @@
'use strict';
import { ApiTable, AuthRequest } from '$utils'
import { ApiTable, AxyRequest } from '$utils'
export const INIT_AUTH = 'INIT_AUTH';
export function initAuth (userData) {
@ -42,7 +42,7 @@ export function login (username, password) {
// },
// });
return AuthRequest.post(ApiTable.login, { username, password })
return AxyRequest.post(ApiTable.login, { username, password, domain: 'anxinyun' })
.then(user => {
sessionStorage.setItem('user', JSON.stringify(user));
return dispatch({
@ -64,7 +64,7 @@ export function login (username, password) {
export const LOGOUT = 'LOGOUT';
export function logout () {
const user = JSON.parse(sessionStorage.getItem('user'))
AuthRequest.put(ApiTable.logout, {
AxyRequest.post(ApiTable.logout, {
token: user.token
});
sessionStorage.removeItem('user');

7
code/VideoAccess-VCMP/web/client/src/sections/auth/containers/login.jsx

@ -48,9 +48,10 @@ const Login = props => {
width: 446,
height: 348,
padding: '45px 60px',
backgroundImage: "url('/assets/images/background/loginbg.png')",
backgroundSize: '100% 100%',
backgroundRepeat: 'no-repeat',
// backgroundImage: "url('/assets/images/background/loginbg.png')",
// backgroundSize: '100% 100%',
// backgroundRepeat: 'no-repeat',
background: 'linear-gradient(rgba(255,255,255,1),rgba(255,255,255,.3))',
position: 'absolute',
top: '33.89%',
right: '16.43%',

2
code/VideoAccess-VCMP/web/client/src/sections/equipmentWarehouse/containers/camera.jsx

@ -717,7 +717,7 @@ const CameraHeader = (props) => {
""
)}
{
// <VideoPlayModal visible={true} />
<VideoPlayModal visible={true} />
}
</>
);

3
code/VideoAccess-VCMP/web/client/src/utils/index.js

@ -1,7 +1,7 @@
'use strict';
import { isAuthorized } from './func';
import { AuthorizationCode } from './authCode';
import { ApiTable, RouteTable, AuthRequest } from './webapi'
import { ApiTable, RouteTable, AuthRequest, AxyRequest } from './webapi'
export {
isAuthorized,
@ -11,4 +11,5 @@ export {
ApiTable,
RouteTable,
AuthRequest,
AxyRequest,
}

1
code/VideoAccess-VCMP/web/client/src/utils/webapi.js

@ -2,6 +2,7 @@
import { ProxyRequest } from "@peace/utils";
export const AuthRequest = new ProxyRequest("_auth");
export const AxyRequest = new ProxyRequest("_axy");
export const ApiTable = {
login: "login",

13
code/VideoAccess-VCMP/web/config.js

@ -13,13 +13,17 @@ dev && console.log('\x1B[33m%s\x1b[0m', '请遵循并及时更新 readme.md,
args.option(['p', 'port'], '启动端口');
args.option(['u', 'api-url'], 'webapi的URL');
args.option('apiAuthUrl', 'IOT 鉴权 api');
args.option('apiAnxinyunUrl', '安心云 api');
args.option('iotAuthWeb', 'IOT 鉴权 web');
const flags = args.parse(process.argv);
const API_URL = process.env.API_URL || flags.apiUrl;
const API_AUTH_URL = process.env.API_AUTH_URL || flags.apiAuthUrl;
const IOT_AUTH_WEB = process.env.IOT_AUTH_WEB || flags.iotAuthWeb;
const API_ANXINYUN_URL = process.env.API_ANXINYUN_URL || flags.apiAnxinyunUrl;
if (!API_URL) {
if (!API_URL || !API_ANXINYUN_URL || !API_AUTH_URL) {
console.log('缺少启动参数,异常退出');
args.showHelp();
process.exit(-1);
@ -40,10 +44,17 @@ const product = {
host: API_AUTH_URL,
match: /^\/_auth\//,
}
}, {
entry: require('./middlewares/proxy').entry,
opts: {
host: API_ANXINYUN_URL,
match: /^\/_axy\//,
}
}, {
entry: require('./routes').entry,
opts: {
apiUrl: API_URL,
iotAuthWeb: IOT_AUTH_WEB,
staticRoot: './client',
}
}, {

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

@ -7,7 +7,7 @@
"test": "mocha",
"start-vite": "cross-env NODE_ENV=developmentVite npm run start-params",
"start": "cross-env NODE_ENV=development npm run start-params",
"start-params": "node server -p 5000 -u http://10.8.30.7:4000 --apiAuthUrl http://10.8.30.7:4200",
"start-params": "node server -p 5000 -u http://10.8.30.7:4000 --apiAuthUrl http://10.8.30.7:4200 --apiAnxinyunUrl http://10.8.30.7:4100 --iotAuthWeb http://localhost:5200",
"deploy": "export NODE_ENV=production&& npm run build && node server",
"build-dev": "cross-env NODE_ENV=development&&webpack --config webpack.config.js",
"build": "export NODE_ENV=production&&webpack --config webpack.config.prod.js"

7
code/VideoAccess-VCMP/web/routes/attachment/index.js

@ -19,10 +19,13 @@ module.exports = {
entry: function (app, router, opts) {
const getApiRoot = async function (ctx) {
const { apiUrl } = opts;
const { apiUrl, iotAuthWeb } = opts;
ctx.status = 200;
ctx.body = { root: apiUrl };
ctx.body = {
root: apiUrl,
iotAuthWeb
};
};
let upload = async function (ctx, next) {

Loading…
Cancel
Save