Browse Source

did

release_1.3.0
巴林闲侠 2 years ago
parent
commit
738e12ada2
  1. 15
      code/VideoAccess-VCMP/api/app/lib/index.js
  2. 97
      code/VideoAccess-VCMP/api/app/lib/models/mirror.js
  3. 56
      code/VideoAccess-VCMP/api/app/lib/models/mirror_camera.js
  4. 47
      code/VideoAccess-VCMP/api/app/lib/models/mirror_filter.js
  5. 56
      code/VideoAccess-VCMP/api/app/lib/models/mirror_filter_group.js
  6. 65
      code/VideoAccess-VCMP/api/app/lib/models/mirror_tree.js
  7. 32
      code/VideoAccess-VCMP/api/app/lib/schedule/freshYingshiMsg.js
  8. 2
      code/VideoAccess-VCMP/api/sequelize-automate.config.js
  9. 4
      code/VideoAccess-VCMP/script/1.3.0/schema/1.alert_gbcamera_did.sql
  10. 1
      code/VideoAccess-VCMP/web/client/src/layout/components/header/index.jsx
  11. 8
      code/VideoAccess-VCMP/web/client/src/layout/index.jsx
  12. 4
      code/VideoAccess-VCMP/web/webpack.config.js

15
code/VideoAccess-VCMP/api/app/lib/index.js

@ -55,7 +55,8 @@ module.exports.models = function (dc) { // dc = { orm: Sequelize对象, ORM: Seq
const {
Nvr, Camera, CameraAbility, CameraAbilityBind, CameraKind, CameraRemark,
GbCamera, SecretYingshi, Vender, CameraStatus, CameraStatusResolve, CameraStatusLog,
CameraStatusPushConfig, CameraStatusPushMonitor, CameraStatusPushLog, CameraStatusPushReceiver, CameraStatusOfflineLog
CameraStatusPushConfig, CameraStatusPushMonitor, CameraStatusPushLog, CameraStatusPushReceiver, CameraStatusOfflineLog,
Mirror, MirrorTree, MirrorFilterGroup, MirrorFilter, MirrorCamera
} = dc.models;
// Nvr.belongsTo(User, { foreignKey: 'userId', targetKey: 'id' });
@ -107,4 +108,16 @@ module.exports.models = function (dc) { // dc = { orm: Sequelize对象, ORM: Seq
CameraStatusOfflineLog.belongsTo(Camera, { foreignKey: 'cameraId', targetKey: 'id' });
Camera.hasMany(CameraStatusOfflineLog, { foreignKey: 'cameraId', sourceKey: 'id' });
MirrorTree.belongsTo(Mirror, { foreignKey: 'mirrorId', targetKey: 'id' });
Mirror.hasMany(MirrorTree, { foreignKey: 'mirrorId', sourceKey: 'id' });
MirrorFilterGroup.belongsTo(Mirror, { foreignKey: 'mirrorId', targetKey: 'id' });
Mirror.hasMany(MirrorFilterGroup, { foreignKey: 'mirrorId', sourceKey: 'id' });
MirrorFilter.belongsTo(MirrorFilterGroup, { foreignKey: 'groupId', targetKey: 'id' });
MirrorFilterGroup.hasMany(MirrorFilter, { foreignKey: 'groupId', sourceKey: 'id' });
MirrorCamera.belongsTo(Camera, { foreignKey: 'cameraId', targetKey: 'id' });
Camera.hasMany(MirrorCamera, { foreignKey: 'cameraId', sourceKey: 'id' });
};

97
code/VideoAccess-VCMP/api/app/lib/models/mirror.js

@ -0,0 +1,97 @@
/* eslint-disable*/
'use strict';
module.exports = dc => {
const DataTypes = dc.ORM;
const sequelize = dc.orm;
const Mirror = sequelize.define("mirror", {
id: {
type: DataTypes.INTEGER,
allowNull: false,
defaultValue: null,
comment: null,
primaryKey: true,
field: "id",
autoIncrement: true,
unique: "mirror_id_uindex"
},
template: {
type: DataTypes.STRING,
allowNull: false,
defaultValue: null,
comment: "模板标识",
primaryKey: false,
field: "template",
autoIncrement: false
},
createUser: {
type: DataTypes.INTEGER,
allowNull: false,
defaultValue: null,
comment: null,
primaryKey: false,
field: "create_user",
autoIncrement: false
},
createTime: {
type: DataTypes.DATE,
allowNull: false,
defaultValue: null,
comment: null,
primaryKey: false,
field: "create_time",
autoIncrement: false
},
updateTime: {
type: DataTypes.DATE,
allowNull: true,
defaultValue: null,
comment: null,
primaryKey: false,
field: "update_time",
autoIncrement: false
},
title: {
type: DataTypes.STRING,
allowNull: true,
defaultValue: null,
comment: null,
primaryKey: false,
field: "title",
autoIncrement: false
},
showHeader: {
type: DataTypes.BOOLEAN,
allowNull: false,
defaultValue: null,
comment: null,
primaryKey: false,
field: "show_header",
autoIncrement: false
},
publish: {
type: DataTypes.BOOLEAN,
allowNull: false,
defaultValue: null,
comment: null,
primaryKey: false,
field: "publish",
autoIncrement: false
},
mid: {
type: DataTypes.STRING,
allowNull: false,
defaultValue: null,
comment: null,
primaryKey: false,
field: "mid",
autoIncrement: false
}
}, {
tableName: "mirror",
comment: "",
indexes: []
});
dc.models.Mirror = Mirror;
return Mirror;
};

56
code/VideoAccess-VCMP/api/app/lib/models/mirror_camera.js

@ -0,0 +1,56 @@
/* eslint-disable*/
'use strict';
module.exports = dc => {
const DataTypes = dc.ORM;
const sequelize = dc.orm;
const MirrorCamera = sequelize.define("mirrorCamera", {
id: {
type: DataTypes.INTEGER,
allowNull: false,
defaultValue: null,
comment: null,
primaryKey: true,
field: "id",
autoIncrement: true,
unique: "mirror_camera_id_uindex"
},
cameraId: {
type: DataTypes.INTEGER,
allowNull: false,
defaultValue: null,
comment: null,
primaryKey: false,
field: "camera_id",
autoIncrement: false,
references: {
key: "id",
model: "camera"
}
},
mirrorIds: {
type: DataTypes.ARRAY(DataTypes.INTEGER),
allowNull: false,
defaultValue: null,
comment: null,
primaryKey: false,
field: "mirror_ids",
autoIncrement: false
},
filterIds: {
type: DataTypes.ARRAY(DataTypes.INTEGER),
allowNull: true,
defaultValue: null,
comment: null,
primaryKey: false,
field: "filter_ids",
autoIncrement: false
}
}, {
tableName: "mirror_camera",
comment: "",
indexes: []
});
dc.models.MirrorCamera = MirrorCamera;
return MirrorCamera;
};

47
code/VideoAccess-VCMP/api/app/lib/models/mirror_filter.js

@ -0,0 +1,47 @@
/* eslint-disable*/
'use strict';
module.exports = dc => {
const DataTypes = dc.ORM;
const sequelize = dc.orm;
const MirrorFilter = sequelize.define("mirrorFilter", {
id: {
type: DataTypes.INTEGER,
allowNull: false,
defaultValue: null,
comment: null,
primaryKey: true,
field: "id",
autoIncrement: true,
unique: "mirror_filter_id_uindex"
},
name: {
type: DataTypes.STRING,
allowNull: false,
defaultValue: null,
comment: null,
primaryKey: false,
field: "name",
autoIncrement: false
},
groupId: {
type: DataTypes.INTEGER,
allowNull: false,
defaultValue: null,
comment: null,
primaryKey: false,
field: "group_id",
autoIncrement: false,
references: {
key: "id",
model: "mirrorFilterGroup"
}
}
}, {
tableName: "mirror_filter",
comment: "",
indexes: []
});
dc.models.MirrorFilter = MirrorFilter;
return MirrorFilter;
};

56
code/VideoAccess-VCMP/api/app/lib/models/mirror_filter_group.js

@ -0,0 +1,56 @@
/* eslint-disable*/
'use strict';
module.exports = dc => {
const DataTypes = dc.ORM;
const sequelize = dc.orm;
const MirrorFilterGroup = sequelize.define("mirrorFilterGroup", {
id: {
type: DataTypes.INTEGER,
allowNull: false,
defaultValue: null,
comment: null,
primaryKey: true,
field: "id",
autoIncrement: true,
unique: "mirror_filter_group_id_uindex"
},
name: {
type: DataTypes.STRING,
allowNull: false,
defaultValue: null,
comment: null,
primaryKey: false,
field: "name",
autoIncrement: false
},
forbidden: {
type: DataTypes.BOOLEAN,
allowNull: false,
defaultValue: null,
comment: null,
primaryKey: false,
field: "forbidden",
autoIncrement: false
},
mirrorId: {
type: DataTypes.INTEGER,
allowNull: false,
defaultValue: null,
comment: null,
primaryKey: false,
field: "mirror_id",
autoIncrement: false,
references: {
key: "id",
model: "mirror"
}
}
}, {
tableName: "mirror_filter_group",
comment: "",
indexes: []
});
dc.models.MirrorFilterGroup = MirrorFilterGroup;
return MirrorFilterGroup;
};

65
code/VideoAccess-VCMP/api/app/lib/models/mirror_tree.js

@ -0,0 +1,65 @@
/* eslint-disable*/
'use strict';
module.exports = dc => {
const DataTypes = dc.ORM;
const sequelize = dc.orm;
const MirrorTree = sequelize.define("mirrorTree", {
id: {
type: DataTypes.INTEGER,
allowNull: false,
defaultValue: null,
comment: null,
primaryKey: true,
field: "id",
autoIncrement: true,
unique: "mirror_tree_id_uindex"
},
name: {
type: DataTypes.STRING,
allowNull: false,
defaultValue: null,
comment: null,
primaryKey: false,
field: "name",
autoIncrement: false
},
level: {
type: DataTypes.INTEGER,
allowNull: false,
defaultValue: null,
comment: "层级标注",
primaryKey: false,
field: "level",
autoIncrement: false
},
dependence: {
type: DataTypes.INTEGER,
allowNull: true,
defaultValue: null,
comment: null,
primaryKey: false,
field: "dependence",
autoIncrement: false
},
mirrorId: {
type: DataTypes.INTEGER,
allowNull: false,
defaultValue: null,
comment: null,
primaryKey: false,
field: "mirror_id",
autoIncrement: false,
references: {
key: "id",
model: "mirror"
}
}
}, {
tableName: "mirror_tree",
comment: "",
indexes: []
});
dc.models.MirrorTree = MirrorTree;
return MirrorTree;
};

32
code/VideoAccess-VCMP/api/app/lib/schedule/freshYingshiMsg.js

@ -33,7 +33,9 @@ module.exports = function (app, opts) {
deviceList = deviceList.concat.apply(deviceList, deviceRes.data)
for (let d of deviceRes.data) {
// if(d.deviceSerial = 'J29900896'){
// console.log(d);
// }
const existD = await models.GbCamera.findOne({
where: {
streamid: d.deviceSerial
@ -48,6 +50,26 @@ module.exports = function (app, opts) {
name: d.deviceName,
}
if (existD) {
// 创建过但是没有赋予did
if (!existD.did) {
const yingshiCount = await models.GbCamera.count({
where: {
ipctype: 'yingshi',
id: { $lt: existD.id }
}
})
let random2place = Math.floor(Math.random() * 99)
if (random2place < 10) {
random2place = '0' + random2place
}
storageD.did = 'SE' + 'Dvs' + 'Y02' + 'T' + moment().format('YYMMDD') + (yingshiCount + 1) + random2place
await models.GbCamera.update(storageD, {
where: {
id: existD.id
}
})
}
// 状态改变
if (existD.online != storageD.online) {
// 状态更新
@ -94,10 +116,14 @@ module.exports = function (app, opts) {
// 生成 did
const yingshiCount = await models.GbCamera.count({
where: {
type: 'yingshi'
ipctype: 'yingshi'
}
})
storageD.did = 'SE' + 'Dvs' + 'Y02' + 'T' + moment().format('YYMMDD') + (yingshiCount + 1) + Math.ceil(Math.random() * 99)
let random2place = Math.floor(Math.random() * 99)
if (random2place < 10) {
random2place = '0' + random2place
}
storageD.did = 'SE' + 'Dvs' + 'Y02' + 'T' + moment().format('YYMMDD') + (yingshiCount + 1) + random2place
const yingshiRes = await models.GbCamera.create(storageD)
await models.Camera.update({
gbId: yingshiRes.id

2
code/VideoAccess-VCMP/api/sequelize-automate.config.js

@ -26,7 +26,7 @@ module.exports = {
dir: './app/lib/models', // 指定输出 models 文件的目录
typesDir: 'models', // 指定输出 TypeScript 类型定义的文件目录,只有 TypeScript / Midway 等会有类型定义
emptyDir: false, // !!! 谨慎操作 生成 models 之前是否清空 `dir` 以及 `typesDir`
tables: ['application'], // 指定生成哪些表的 models,如 ['user', 'user_post'];如果为 null,则忽略改属性
tables: ['mirror','mirror_camera','mirror_filter','mirror_filter_group','mirror_tree'], // 指定生成哪些表的 models,如 ['user', 'user_post'];如果为 null,则忽略改属性
skipTables: [], // 指定跳过哪些表的 models,如 ['user'];如果为 null,则忽略改属性
tsNoCheck: false, // 是否添加 `@ts-nocheck` 注释到 models 文件中
ignorePrefix: [], // 生成的模型名称忽略的前缀,因为 项目中有以下表名是以 t_ 开头的,在实际模型中不需要, 可以添加多个 [ 't_data_', 't_',] ,长度较长的 前缀放前面

4
code/VideoAccess-VCMP/script/1.3.0/schema/1.alert_gbcamera_did.sql

@ -0,0 +1,4 @@
alter table "gbCamera"
add did varchar(128);
comment on column "gbCamera".did is '设备自定义id';

1
code/VideoAccess-VCMP/web/client/src/layout/components/header/index.jsx

@ -6,7 +6,6 @@ import { Nav, Avatar, Dropdown } from "@douyinfe/semi-ui";
const Header = (props) => {
const { dispatch, history, user, actions, socket } = props;
console.log(__webpack_public_path__);
return (
<>
<Nav

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

@ -174,7 +174,11 @@ const Root = props => {
const microAppListen = async (data) => {
console.log('xxxx', data);
if (data.action == 'initMicro') {
await store.dispatch(push('/noMatch'));
await store.dispatch(actions.auth.initAuth({
authorized: true,
token: data.data.token,
}))
// await store.dispatch(push('/noMatch'));
setMicroAppWaiting(false)
}
}
@ -187,7 +191,7 @@ const Root = props => {
setMicroAppWaiting(false)
}
// setMicroAppWaiting(false)
}, [])
return (

4
code/VideoAccess-VCMP/web/webpack.config.js

@ -13,8 +13,8 @@ module.exports = {
devServer: {
historyApiFallback: true,
// 为 MicroApp 配置跨域
'Access-Control-Allow-Origin': '*',
allowedHosts: ['127.0.0.1:5100'],
// 'Access-Control-Allow-Origin': '*',
// allowedHosts: ['127.0.0.1:5100'],
},
entry: {
app: ["@babel/polyfill", PATHS.app]

Loading…
Cancel
Save