diff --git a/api/app/lib/models/application.js b/api/app/lib/models/application.js deleted file mode 100644 index e51fd54..0000000 --- a/api/app/lib/models/application.js +++ /dev/null @@ -1,88 +0,0 @@ -/* eslint-disable*/ -'use strict'; - -module.exports = dc => { - const DataTypes = dc.ORM; - const sequelize = dc.orm; - const Application = sequelize.define("application", { - id: { - type: DataTypes.INTEGER, - allowNull: false, - defaultValue: null, - comment: null, - primaryKey: true, - field: "id", - autoIncrement: true, - unique: "application_id_uindex" - }, - name: { - type: DataTypes.STRING, - allowNull: false, - defaultValue: null, - comment: null, - primaryKey: false, - field: "name", - autoIncrement: false - }, - type: { - type: DataTypes.ARRAY(DataTypes.STRING), - allowNull: true, - defaultValue: null, - comment: "web / app / wxapp / other", - primaryKey: false, - field: "type", - autoIncrement: false - }, - appKey: { - type: DataTypes.STRING, - allowNull: false, - defaultValue: null, - comment: null, - primaryKey: false, - field: "app_key", - autoIncrement: false - }, - appSecret: { - type: DataTypes.STRING, - allowNull: false, - defaultValue: null, - comment: null, - primaryKey: false, - field: "app_secret", - autoIncrement: false - }, - createUserId: { - type: DataTypes.INTEGER, - allowNull: false, - defaultValue: null, - comment: null, - primaryKey: false, - field: "create_user_id", - autoIncrement: false - }, - createTime: { - type: DataTypes.DATE, - allowNull: false, - defaultValue: null, - comment: null, - primaryKey: false, - field: "create_time", - autoIncrement: false - }, - forbidden: { - type: DataTypes.BOOLEAN, - allowNull: false, - defaultValue: null, - comment: null, - primaryKey: false, - field: "forbidden", - autoIncrement: false - } - }, { - tableName: "application", - comment: "", - indexes: [] - }); - dc.models.Application = Application; - return Application; -}; \ No newline at end of file diff --git a/api/app/lib/models/ax_project.js b/api/app/lib/models/ax_project.js deleted file mode 100644 index b060ff5..0000000 --- a/api/app/lib/models/ax_project.js +++ /dev/null @@ -1,35 +0,0 @@ -/* eslint-disable*/ -'use strict'; - -module.exports = dc => { - const DataTypes = dc.ORM; - const sequelize = dc.orm; - const AxProject = sequelize.define("axProject", { - id: { - type: DataTypes.INTEGER, - allowNull: false, - defaultValue: null, - comment: null, - primaryKey: true, - field: "id", - autoIncrement: false, - unique: "ax_project_id_uindex" - }, - name: { - type: DataTypes.STRING, - allowNull: false, - defaultValue: null, - comment: null, - primaryKey: false, - field: "name", - autoIncrement: false - } - }, { - tableName: "ax_project", - comment: "", - indexes: [] - }); - - dc.models.AxProject = AxProject; - return AxProject; -}; \ No newline at end of file diff --git a/api/app/lib/schedule/index.js b/api/app/lib/schedule/index.js new file mode 100644 index 0000000..121b8a9 --- /dev/null +++ b/api/app/lib/schedule/index.js @@ -0,0 +1,36 @@ +'use strict'; + +const fs = require('fs'); +const nodeSchedule = require('node-schedule'); + +// 将定时任务汇集未来可根据需要选取操作 +module.exports = async function (app, opts) { + + const scheduleInit = ({ + interval, immediate, proRun, + }, callback) => { + if (proRun && opts.dev) { + return; + } + const j = nodeSchedule.scheduleJob(interval, callback); + if (immediate && (!proRun || (proRun && !opts.dev))) { + setTimeout(callback, 0) + } + return j; + } + + app.fs.scheduleInit = scheduleInit + + fs.readdirSync(__dirname).forEach((filename) => { + if (!['index.js'].some(f => filename == f)) { + const scheduleList = require(`./${filename}`)(app, opts) + for (let k of Object.keys(scheduleList)) { + console.info(`定时任务 ${k} 启动`); + } + app.fs.schedule = { + ...app.fs.schedule, + ...scheduleList, + } + } + }); +}; diff --git a/api/app/lib/service/mqttVideoServer.js b/api/app/lib/service/mqttVideoServer.js index 69b4046..7b85386 100644 --- a/api/app/lib/service/mqttVideoServer.js +++ b/api/app/lib/service/mqttVideoServer.js @@ -16,24 +16,7 @@ module.exports = async function factory (app, opts) { }) client.on('message', async (top, message) => { - let msgStr = message.toString(); - let msg = JSON.parse(msgStr.replace(/\\/g, '')); - if (msg.id && msg.online) { - const { cameraStatePush } = app.fs.utils - const { models } = app.fs.dc - const gbCameraRes = await models.GbCamera.findOne({ - where: { - id: msg.id - } - }) - if (gbCameraRes) { - cameraStatePush({ - gbId: msg.id, - online: msg.online, - ipctype: gbCameraRes.ipctype, - }) - } - } + }); app.mqttVideoServer = client diff --git a/script/.vscode/settings.json b/script/.vscode/settings.json deleted file mode 100644 index ab3b243..0000000 --- a/script/.vscode/settings.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "editor.wordWrap": "on" -} \ No newline at end of file diff --git a/script/0.0.1/0_init_db.sql b/script/0.0.1/0_init_db.sql deleted file mode 100644 index bc4c4c9..0000000 --- a/script/0.0.1/0_init_db.sql +++ /dev/null @@ -1,543 +0,0 @@ -/* - Navicat Premium Data Transfer - - Source Server : 10.8.30.32 - Source Server Type : PostgreSQL - Source Server Version : 90515 - Source Host : 10.8.30.32:5432 - Source Catalog : video_access - Source Schema : public - - Target Server Type : PostgreSQL - Target Server Version : 90515 - File Encoding : 65001 - - Date: 06/07/2022 11:45:25 -*/ - - --- ---------------------------- --- Sequence structure for camera_ability_bind_id_seq --- ---------------------------- -DROP SEQUENCE IF EXISTS "public"."camera_ability_bind_id_seq"; -CREATE SEQUENCE "public"."camera_ability_bind_id_seq" -INCREMENT 1 -MINVALUE 1 -MAXVALUE 9223372036854775807 -START 1 -CACHE 1; - --- ---------------------------- --- Sequence structure for camera_id_seq --- ---------------------------- -DROP SEQUENCE IF EXISTS "public"."camera_id_seq"; -CREATE SEQUENCE "public"."camera_id_seq" -INCREMENT 1 -MINVALUE 1 -MAXVALUE 9223372036854775807 -START 1 -CACHE 1; - --- ---------------------------- --- Sequence structure for camera_remark_id_seq --- ---------------------------- -DROP SEQUENCE IF EXISTS "public"."camera_remark_id_seq"; -CREATE SEQUENCE "public"."camera_remark_id_seq" -INCREMENT 1 -MINVALUE 1 -MAXVALUE 9223372036854775807 -START 1 -CACHE 1; - --- ---------------------------- --- Sequence structure for gbCamera_id_seq --- ---------------------------- -DROP SEQUENCE IF EXISTS "public"."gbCamera_id_seq"; -CREATE SEQUENCE "public"."gbCamera_id_seq" -INCREMENT 1 -MINVALUE 1 -MAXVALUE 9223372036854775807 -START 1 -CACHE 1; - --- ---------------------------- --- Sequence structure for gb_id_seq --- ---------------------------- -DROP SEQUENCE IF EXISTS "public"."gb_id_seq"; -CREATE SEQUENCE "public"."gb_id_seq" -INCREMENT 1 -MINVALUE 1 -MAXVALUE 9223372036854775807 -START 1 -CACHE 1; - --- ---------------------------- --- Sequence structure for nvr_id_seq --- ---------------------------- -DROP SEQUENCE IF EXISTS "public"."nvr_id_seq"; -CREATE SEQUENCE "public"."nvr_id_seq" -INCREMENT 1 -MINVALUE 1 -MAXVALUE 9223372036854775807 -START 1 -CACHE 1; - --- ---------------------------- --- Sequence structure for secret_yingshi_id_seq --- ---------------------------- -DROP SEQUENCE IF EXISTS "public"."secret_yingshi_id_seq"; -CREATE SEQUENCE "public"."secret_yingshi_id_seq" -INCREMENT 1 -MINVALUE 1 -MAXVALUE 9223372036854775807 -START 1 -CACHE 1; - --- ---------------------------- --- Sequence structure for t_upload_comm_http_id_seq --- ---------------------------- -DROP SEQUENCE IF EXISTS "public"."t_upload_comm_http_id_seq"; -CREATE SEQUENCE "public"."t_upload_comm_http_id_seq" -INCREMENT 1 -MINVALUE 1 -MAXVALUE 9223372036854775807 -START 1 -CACHE 1; - --- ---------------------------- --- Sequence structure for vender_id_seq --- ---------------------------- -DROP SEQUENCE IF EXISTS "public"."vender_id_seq"; -CREATE SEQUENCE "public"."vender_id_seq" -INCREMENT 1 -MINVALUE 1 -MAXVALUE 9223372036854775807 -START 1 -CACHE 1; - --- ---------------------------- --- Table structure for ax_project --- ---------------------------- -DROP TABLE IF EXISTS "public"."ax_project"; -CREATE TABLE "public"."ax_project" ( - "id" int4 NOT NULL, - "name" varchar(64) COLLATE "pg_catalog"."default" NOT NULL -) -; -COMMENT ON TABLE "public"."ax_project" IS '安心云项目副表,主要用于和camera等进行联合查询 -在安心云进行摄像头绑定的时候进行同步'; - --- ---------------------------- --- Records of ax_project --- ---------------------------- -INSERT INTO "public"."ax_project" VALUES (1, '安心云项目'); - --- ---------------------------- --- Table structure for camera --- ---------------------------- -DROP TABLE IF EXISTS "public"."camera"; -CREATE TABLE "public"."camera" ( - "id" int4 NOT NULL DEFAULT nextval('camera_id_seq'::regclass), - "type" varchar(16) COLLATE "pg_catalog"."default" NOT NULL, - "name" varchar(128) COLLATE "pg_catalog"."default", - "channel_name" varchar(64) COLLATE "pg_catalog"."default", - "external_domain" varchar(64) COLLATE "pg_catalog"."default", - "rtmp" varchar(1024) COLLATE "pg_catalog"."default", - "serial_no" varchar(128) COLLATE "pg_catalog"."default", - "cloud_control" bool, - "high_definition" bool, - "voice" bool, - "memory_card" varchar(32) COLLATE "pg_catalog"."default", - "vender_id" int4, - "cascade_type" varchar(32) COLLATE "pg_catalog"."default", - "sip" varchar(1024) COLLATE "pg_catalog"."default", - "longitude" numeric(16,12), - "latitude" numeric(16,12), - "forbidden" bool NOT NULL DEFAULT false, - "create_time" timestamptz(6) NOT NULL, - "recycle_time" timestamptz(6), - "delete" bool NOT NULL DEFAULT false, - "create_user_id" int4 NOT NULL, - "nvr_id" int4, - "model" varchar(128) COLLATE "pg_catalog"."default", - "kind_id" int4, - "yingshi_secret_id" int4, - "gb_id" int4, - "top_serial_no" varchar(128) COLLATE "pg_catalog"."default" -) -; -COMMENT ON COLUMN "public"."camera"."type" IS '设备类型:yingshi - 萤石;nvr - NVR摄像头;ipc - IPC 网络摄像头;cascade - 级联摄像头'; -COMMENT ON COLUMN "public"."camera"."name" IS '设备名称/安装位置'; -COMMENT ON COLUMN "public"."camera"."channel_name" IS '通道名称'; -COMMENT ON COLUMN "public"."camera"."external_domain" IS '外域名称'; -COMMENT ON COLUMN "public"."camera"."serial_no" IS '设备编号'; -COMMENT ON COLUMN "public"."camera"."cloud_control" IS '云台控制'; -COMMENT ON COLUMN "public"."camera"."high_definition" IS '高清支持'; -COMMENT ON COLUMN "public"."camera"."voice" IS '语音对讲支持'; -COMMENT ON COLUMN "public"."camera"."memory_card" IS '内存卡容量'; -COMMENT ON COLUMN "public"."camera"."vender_id" IS '设备厂商id'; -COMMENT ON COLUMN "public"."camera"."cascade_type" IS '级联方式:up - 上级联;down - 下级联'; -COMMENT ON COLUMN "public"."camera"."longitude" IS '经度'; -COMMENT ON COLUMN "public"."camera"."latitude" IS '维度'; -COMMENT ON COLUMN "public"."camera"."forbidden" IS '是否禁用'; -COMMENT ON COLUMN "public"."camera"."recycle_time" IS '放入回收站时间'; -COMMENT ON COLUMN "public"."camera"."delete" IS '是否彻底删除'; -COMMENT ON COLUMN "public"."camera"."model" IS '型号'; -COMMENT ON COLUMN "public"."camera"."top_serial_no" IS 'gb设备 level=0 的 steamid '; - --- ---------------------------- --- Table structure for camera_ability --- ---------------------------- -DROP TABLE IF EXISTS "public"."camera_ability"; -CREATE TABLE "public"."camera_ability" ( - "id" int4 NOT NULL, - "ability" varchar(64) COLLATE "pg_catalog"."default" NOT NULL -) -; -COMMENT ON TABLE "public"."camera_ability" IS '摄像机能力'; - --- ---------------------------- --- Records of camera_ability --- ---------------------------- -INSERT INTO "public"."camera_ability" VALUES (1, '普通摄像头'); -INSERT INTO "public"."camera_ability" VALUES (2, '人流量计数'); -INSERT INTO "public"."camera_ability" VALUES (3, '热成像'); -INSERT INTO "public"."camera_ability" VALUES (4, 'AI摄像头'); -INSERT INTO "public"."camera_ability" VALUES (1314, '其他'); - --- ---------------------------- --- Table structure for camera_ability_bind --- ---------------------------- -DROP TABLE IF EXISTS "public"."camera_ability_bind"; -CREATE TABLE "public"."camera_ability_bind" ( - "id" int4 NOT NULL DEFAULT nextval('camera_ability_bind_id_seq'::regclass), - "camera_id" int4 NOT NULL, - "ability_id" int4 NOT NULL -) -; - --- ---------------------------- --- Table structure for camera_kind --- ---------------------------- -DROP TABLE IF EXISTS "public"."camera_kind"; -CREATE TABLE "public"."camera_kind" ( - "id" int4 NOT NULL, - "kind" varchar(64) COLLATE "pg_catalog"."default" NOT NULL -) -; -COMMENT ON TABLE "public"."camera_kind" IS '摄像机类型'; - --- ---------------------------- --- Records of camera_kind --- ---------------------------- -INSERT INTO "public"."camera_kind" VALUES (1, '枪机'); -INSERT INTO "public"."camera_kind" VALUES (2, '球机'); -INSERT INTO "public"."camera_kind" VALUES (1314, '其他'); - --- ---------------------------- --- Table structure for camera_remark --- ---------------------------- -DROP TABLE IF EXISTS "public"."camera_remark"; -CREATE TABLE "public"."camera_remark" ( - "id" int4 NOT NULL DEFAULT nextval('camera_remark_id_seq'::regclass), - "camera_id" int4 NOT NULL, - "remark" varchar(256) COLLATE "pg_catalog"."default" NOT NULL -) -; - --- ---------------------------- --- Table structure for gbCamera --- ---------------------------- -DROP TABLE IF EXISTS "public"."gbCamera"; -CREATE TABLE "public"."gbCamera" ( - "id" int4 NOT NULL DEFAULT nextval('gb_id_seq'::regclass), - "level" int4, - "parent" varchar(32) COLLATE "pg_catalog"."default", - "streamid" varchar(255) COLLATE "pg_catalog"."default", - "online" varchar(255) COLLATE "pg_catalog"."default", - "manufactuer" varchar(255) COLLATE "pg_catalog"."default", - "model" varchar(255) COLLATE "pg_catalog"."default", - "civilCode" varchar(255) COLLATE "pg_catalog"."default", - "adddress" varchar(255) COLLATE "pg_catalog"."default", - "name" varchar(255) COLLATE "pg_catalog"."default", - "Addr" varchar(255) COLLATE "pg_catalog"."default", - "Sipip" varchar(255) COLLATE "pg_catalog"."default", - "ipctype" varchar(255) COLLATE "pg_catalog"."default", - "registerTime" varchar(255) COLLATE "pg_catalog"."default" DEFAULT ''::character varying, - "updateTime" varchar(255) COLLATE "pg_catalog"."default", - "playUrl" jsonb -) -; -COMMENT ON COLUMN "public"."gbCamera"."playUrl" IS '播放地址集合'; - --- ---------------------------- --- Table structure for nvr --- ---------------------------- -DROP TABLE IF EXISTS "public"."nvr"; -CREATE TABLE "public"."nvr" ( - "id" int4 NOT NULL DEFAULT nextval('nvr_id_seq'::regclass), - "name" varchar(64) COLLATE "pg_catalog"."default" NOT NULL, - "vender_id" int4, - "serial_no" varchar(64) COLLATE "pg_catalog"."default" NOT NULL, - "region_code" varchar(64) COLLATE "pg_catalog"."default", - "longitude" numeric(16,12) NOT NULL, - "latitude" numeric(16,12) NOT NULL, - "create_time" timestamptz(6) NOT NULL DEFAULT now(), - "channel_count" int4, - "port" varchar(32) COLLATE "pg_catalog"."default", - "delete" bool NOT NULL DEFAULT false, - "create_user_id" int4 NOT NULL -) -; -COMMENT ON COLUMN "public"."nvr"."vender_id" IS '设备厂家id'; -COMMENT ON COLUMN "public"."nvr"."serial_no" IS '设备编号'; -COMMENT ON COLUMN "public"."nvr"."region_code" IS '行政区码'; -COMMENT ON COLUMN "public"."nvr"."create_time" IS '创建时间'; -COMMENT ON COLUMN "public"."nvr"."channel_count" IS '通道数'; -COMMENT ON COLUMN "public"."nvr"."port" IS '端口'; - --- ---------------------------- --- Table structure for secret_yingshi --- ---------------------------- -DROP TABLE IF EXISTS "public"."secret_yingshi"; -CREATE TABLE "public"."secret_yingshi" ( - "id" int4 NOT NULL DEFAULT nextval('secret_yingshi_id_seq'::regclass), - "key" varchar(512) COLLATE "pg_catalog"."default" NOT NULL, - "secret" varchar(512) COLLATE "pg_catalog"."default" NOT NULL, - "token" varchar(512) COLLATE "pg_catalog"."default", - "expire" varchar(512) COLLATE "pg_catalog"."default" -) -; - --- ---------------------------- --- Records of secret_yingshi --- ---------------------------- -INSERT INTO "public"."secret_yingshi" VALUES (2, '3ea2b502f6804d64b43e4cb3d135665c', '331c85c5b7ce76179f6eb7dccb8aeb27', 'at.culo424j9drz8atx9uikeq5e2mzkhnhx-490csubqrh-1o3hcaz-szuvfax6f', '1657681218109'); -INSERT INTO "public"."secret_yingshi" VALUES (3, 'd0704fb9d5d14a6682c1c1d592c12512', '93d023269495b86be62cdfdcf34a6cd1', 'at.1y2mk5fh2myswbkp017pmvdi0v1zbdrw-5j39z78wsp-0x4vi2j-a3mxjlt32', '1657683606281'); -INSERT INTO "public"."secret_yingshi" VALUES (1, '5d16a667e1c2423d9d0d634f781810b4', '0cc4e1ec4e6a53ea3dabeb09cd5f468b', 'at.9gq3xwwbazkk33y177ucqtk936bmd0sz-41x4xf24sh-1cn7x82-4lf7davve', '1657681803201'); - --- ---------------------------- --- Table structure for t_upload_comm_http --- ---------------------------- -DROP TABLE IF EXISTS "public"."t_upload_comm_http"; -CREATE TABLE "public"."t_upload_comm_http" ( - "id" int4 NOT NULL DEFAULT nextval('t_upload_comm_http_id_seq'::regclass), - "content" json NOT NULL, - "enable" bool NOT NULL DEFAULT true, - "description" varchar(255) COLLATE "pg_catalog"."default" -) -; - --- ---------------------------- --- Table structure for vender --- ---------------------------- -DROP TABLE IF EXISTS "public"."vender"; -CREATE TABLE "public"."vender" ( - "id" int4 NOT NULL DEFAULT nextval('vender_id_seq'::regclass), - "name" varchar(64) COLLATE "pg_catalog"."default" NOT NULL -) -; -COMMENT ON TABLE "public"."vender" IS '设备厂商'; - --- ---------------------------- --- Records of vender --- ---------------------------- -INSERT INTO "public"."vender" VALUES (2, '海康威视'); -INSERT INTO "public"."vender" VALUES (3, '大华'); -INSERT INTO "public"."vender" VALUES (1, '飞尚科技'); -INSERT INTO "public"."vender" VALUES (1314, '其他'); - --- ---------------------------- --- Alter sequences owned by --- ---------------------------- -ALTER SEQUENCE "public"."camera_ability_bind_id_seq" -OWNED BY "public"."camera_ability_bind"."id"; - --- ---------------------------- --- Alter sequences owned by --- ---------------------------- -ALTER SEQUENCE "public"."camera_id_seq" -OWNED BY "public"."camera"."id"; - --- ---------------------------- --- Alter sequences owned by --- ---------------------------- -ALTER SEQUENCE "public"."camera_remark_id_seq" -OWNED BY "public"."camera_remark"."id"; - --- ---------------------------- --- Alter sequences owned by --- ---------------------------- -SELECT setval('"public"."gbCamera_id_seq"', 2, false); - --- ---------------------------- --- Alter sequences owned by --- ---------------------------- - --- ---------------------------- --- Alter sequences owned by --- ---------------------------- -ALTER SEQUENCE "public"."nvr_id_seq" -OWNED BY "public"."nvr"."id"; - --- ---------------------------- --- Alter sequences owned by --- ---------------------------- -ALTER SEQUENCE "public"."secret_yingshi_id_seq" -OWNED BY "public"."secret_yingshi"."id"; -SELECT setval('"public"."secret_yingshi_id_seq"', 4, true); - --- ---------------------------- --- Alter sequences owned by --- ---------------------------- -SELECT setval('"public"."t_upload_comm_http_id_seq"', 2, false); - --- ---------------------------- --- Alter sequences owned by --- ---------------------------- -ALTER SEQUENCE "public"."vender_id_seq" -OWNED BY "public"."vender"."id"; -SELECT setval('"public"."vender_id_seq"', 4, true); - --- ---------------------------- --- Indexes structure for table ax_project --- ---------------------------- -CREATE UNIQUE INDEX "ax_project_id_uindex" ON "public"."ax_project" USING btree ( - "id" "pg_catalog"."int4_ops" ASC NULLS LAST -); - --- ---------------------------- --- Primary Key structure for table ax_project --- ---------------------------- -ALTER TABLE "public"."ax_project" ADD CONSTRAINT "ax_project_pk" PRIMARY KEY ("id"); - --- ---------------------------- --- Indexes structure for table camera --- ---------------------------- -CREATE UNIQUE INDEX "camera_id_uindex" ON "public"."camera" USING btree ( - "id" "pg_catalog"."int4_ops" ASC NULLS LAST -); - --- ---------------------------- --- Primary Key structure for table camera --- ---------------------------- -ALTER TABLE "public"."camera" ADD CONSTRAINT "camera_pk" PRIMARY KEY ("id"); - --- ---------------------------- --- Indexes structure for table camera_ability --- ---------------------------- -CREATE UNIQUE INDEX "camera_ability_id_uindex" ON "public"."camera_ability" USING btree ( - "id" "pg_catalog"."int4_ops" ASC NULLS LAST -); - --- ---------------------------- --- Primary Key structure for table camera_ability --- ---------------------------- -ALTER TABLE "public"."camera_ability" ADD CONSTRAINT "camera_ability_pk" PRIMARY KEY ("id"); - --- ---------------------------- --- Indexes structure for table camera_ability_bind --- ---------------------------- -CREATE UNIQUE INDEX "camera_ability_bind_id_uindex" ON "public"."camera_ability_bind" USING btree ( - "id" "pg_catalog"."int4_ops" ASC NULLS LAST -); - --- ---------------------------- --- Primary Key structure for table camera_ability_bind --- ---------------------------- -ALTER TABLE "public"."camera_ability_bind" ADD CONSTRAINT "camera_ability_bind_pk" PRIMARY KEY ("id"); - --- ---------------------------- --- Indexes structure for table camera_kind --- ---------------------------- -CREATE UNIQUE INDEX "camera_kind_id_uindex" ON "public"."camera_kind" USING btree ( - "id" "pg_catalog"."int4_ops" ASC NULLS LAST -); - --- ---------------------------- --- Primary Key structure for table camera_kind --- ---------------------------- -ALTER TABLE "public"."camera_kind" ADD CONSTRAINT "camera_kind_pk" PRIMARY KEY ("id"); - --- ---------------------------- --- Indexes structure for table camera_remark --- ---------------------------- -CREATE UNIQUE INDEX "camera_remark_id_uindex" ON "public"."camera_remark" USING btree ( - "id" "pg_catalog"."int4_ops" ASC NULLS LAST -); - --- ---------------------------- --- Primary Key structure for table camera_remark --- ---------------------------- -ALTER TABLE "public"."camera_remark" ADD CONSTRAINT "camera_remark_pk" PRIMARY KEY ("id"); - --- ---------------------------- --- Primary Key structure for table gbCamera --- ---------------------------- -ALTER TABLE "public"."gbCamera" ADD CONSTRAINT "gbCamera1_copy1_pkey" PRIMARY KEY ("id"); - - --- ---------------------------- --- Indexes structure for table nvr --- ---------------------------- -CREATE UNIQUE INDEX "nvr_id_uindex" ON "public"."nvr" USING btree ( - "id" "pg_catalog"."int4_ops" ASC NULLS LAST -); - --- ---------------------------- --- Primary Key structure for table nvr --- ---------------------------- -ALTER TABLE "public"."nvr" ADD CONSTRAINT "nvr_pk" PRIMARY KEY ("id"); - --- ---------------------------- --- Indexes structure for table secret_yingshi --- ---------------------------- -CREATE UNIQUE INDEX "secret_yingshi_id_uindex" ON "public"."secret_yingshi" USING btree ( - "id" "pg_catalog"."int4_ops" ASC NULLS LAST -); - --- ---------------------------- --- Primary Key structure for table secret_yingshi --- ---------------------------- -ALTER TABLE "public"."secret_yingshi" ADD CONSTRAINT "secret_yingshi_pk" PRIMARY KEY ("id"); - --- ---------------------------- --- Primary Key structure for table t_upload_comm_http --- ---------------------------- -ALTER TABLE "public"."t_upload_comm_http" ADD CONSTRAINT "t_upload_comm_http_pkey" PRIMARY KEY ("id"); - --- ---------------------------- --- Indexes structure for table vender --- ---------------------------- -CREATE UNIQUE INDEX "vender_id_uindex" ON "public"."vender" USING btree ( - "id" "pg_catalog"."int4_ops" ASC NULLS LAST -); - --- ---------------------------- --- Primary Key structure for table vender --- ---------------------------- -ALTER TABLE "public"."vender" ADD CONSTRAINT "vender_pk" PRIMARY KEY ("id"); - --- ---------------------------- --- Foreign Keys structure for table camera --- ---------------------------- -ALTER TABLE "public"."camera" ADD CONSTRAINT "camera_camera_kind_id_fk" FOREIGN KEY ("kind_id") REFERENCES "public"."camera_kind" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION; -ALTER TABLE "public"."camera" ADD CONSTRAINT "camera_nvr_id_fk" FOREIGN KEY ("nvr_id") REFERENCES "public"."nvr" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION; -ALTER TABLE "public"."camera" ADD CONSTRAINT "camera_secret_yingshi_id_fk" FOREIGN KEY ("yingshi_secret_id") REFERENCES "public"."secret_yingshi" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION; -ALTER TABLE "public"."camera" ADD CONSTRAINT "camera_vender_id_fk" FOREIGN KEY ("vender_id") REFERENCES "public"."vender" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION; - --- ---------------------------- --- Foreign Keys structure for table camera_ability_bind --- ---------------------------- -ALTER TABLE "public"."camera_ability_bind" ADD CONSTRAINT "camera_ability_bind_camera_ability_id_fk" FOREIGN KEY ("ability_id") REFERENCES "public"."camera_ability" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION; -ALTER TABLE "public"."camera_ability_bind" ADD CONSTRAINT "camera_ability_bind_camera_id_fk" FOREIGN KEY ("camera_id") REFERENCES "public"."camera" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION; - --- ---------------------------- --- Foreign Keys structure for table camera_remark --- ---------------------------- -ALTER TABLE "public"."camera_remark" ADD CONSTRAINT "camera_remark_camera_id_fk" FOREIGN KEY ("camera_id") REFERENCES "public"."camera" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION; - --- ---------------------------- --- Foreign Keys structure for table nvr --- ---------------------------- -ALTER TABLE "public"."nvr" ADD CONSTRAINT "nvr_vender_id_fk" FOREIGN KEY ("vender_id") REFERENCES "public"."vender" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION; diff --git a/script/1.0.0/1.init_tables.sql b/script/1.0.0/1.init_tables.sql new file mode 100644 index 0000000..e69de29 diff --git a/script/1.1.0/1.camera_remark.sql b/script/1.1.0/1.camera_remark.sql deleted file mode 100644 index 0145cda..0000000 --- a/script/1.1.0/1.camera_remark.sql +++ /dev/null @@ -1,14 +0,0 @@ -create table if not exists camera_remark -( - id serial not null, - camera_id integer not null, - remark varchar(256) not null, - constraint camera_remark_pk - primary key (id), - constraint camera_remark_camera_id_fk - foreign key (camera_id) references camera -); - -create unique index if not exists camera_remark_id_uindex - on camera_remark (id); - diff --git a/script/1.1.1/data/1_update_status_code_data/.vscode/launch.json b/script/1.1.1/data/1_update_status_code_data/.vscode/launch.json deleted file mode 100644 index 3a3fcba..0000000 --- a/script/1.1.1/data/1_update_status_code_data/.vscode/launch.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - // 使用 IntelliSense 了解相关属性。 - // 悬停以查看现有属性的描述。 - // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387 - "version": "0.2.0", - "configurations": [ - { - "type": "node", - "request": "launch", - "name": "启动程序", - "skipFiles": [ - "/**" - ], - "program": "${workspaceFolder}\\index.js" - } - ] -} \ No newline at end of file diff --git a/script/1.1.1/data/1_update_status_code_data/index.js b/script/1.1.1/data/1_update_status_code_data/index.js deleted file mode 100644 index 32214fe..0000000 --- a/script/1.1.1/data/1_update_status_code_data/index.js +++ /dev/null @@ -1,69 +0,0 @@ -try { - const { Pool, Client } = require('pg') - const XLSX = require('xlsx') - const path = require('path') - - // 连接数据库 - const pool = new Pool({ - user: 'postgres', - host: '10.8.30.32', - database: 'video_access', - password: '123', - port: 5432, - }) - - const fun = async () => { - // note: we don't try/catch this because if connecting throws an exception - // we don't need to dispose of the client (it will be undefined) - const client = await pool.connect() - try { - await client.query('BEGIN') - - // 读取数据文件 - let workbook = XLSX.readFile(path.join(__dirname, '云录制错误码.xlsx')) - let firstSheetName = workbook.SheetNames[0]; - let worksheet = workbook.Sheets[firstSheetName]; - let res = XLSX.utils.sheet_to_json(worksheet); - - // console.log(res); - - for (let d of res) { - let statusRes = await client.query(`SELECT * FROM camera_status WHERE status=$1`, [d['错误码']]); - let statusRows = statusRes.rows - - if (statusRows.length) { - - } else { - console.log(`增加${d['错误码']}`); - const statusInQuery = `INSERT INTO "camera_status" (platform, status, describe, paraphrase) VALUES($1, $2, $3, $4) RETURNING id;` - const statusRows = (await client.query(statusInQuery, ['yingshi', d['错误码'], d['错误描述'], d['释义']])).rows - // console.log(statusRows); - if (d['解决方案']) { - let resolveArr = d['解决方案'].split(';'); - // await client.query(`DELETE FROM "camera_status_solution" WHERE status_id=$1`, [statusRows[0].id]); - for (let r of resolveArr) { - await client.query( - `INSERT INTO "camera_status_resolve" (status_id, resolve) VALUES($1, $2) RETURNING id;`, - [statusRows[0].id, r] - ) - } - } - } - } - - // await client.query('ROLLBACK') - await client.query('COMMIT') - console.log('执行完毕~') - } catch (e) { - await client.query('ROLLBACK') - console.log('执行错误~') - throw e - } finally { - client.release(); - } - } - - fun() -} catch (error) { - console.error(error) -} diff --git a/script/1.1.1/data/1_update_status_code_data/package.json b/script/1.1.1/data/1_update_status_code_data/package.json deleted file mode 100644 index 0f66f5f..0000000 --- a/script/1.1.1/data/1_update_status_code_data/package.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "name": "appkey-generator", - "version": "1.0.0", - "description": "tool", - "main": "index.js", - "scripts": { - "test": "mocha", - "start": "set NODE_ENV=development&&node index" - }, - "author": "liu", - "license": "ISC", - "dependencies": { - "pg": "^7.18.2", - "xlsx": "^0.17.1" - } -} diff --git a/script/1.1.1/data/1_update_status_code_data/云录制错误码.xlsx b/script/1.1.1/data/1_update_status_code_data/云录制错误码.xlsx deleted file mode 100644 index 00c8889..0000000 Binary files a/script/1.1.1/data/1_update_status_code_data/云录制错误码.xlsx and /dev/null differ diff --git a/script/1.1.1/data/2.insert_camera_status.sql b/script/1.1.1/data/2.insert_camera_status.sql deleted file mode 100644 index 8a61c08..0000000 --- a/script/1.1.1/data/2.insert_camera_status.sql +++ /dev/null @@ -1,141 +0,0 @@ - --- ---------------------------- --- Records of camera_status --- ---------------------------- -INSERT INTO "public"."camera_status" VALUES (2, 'yingshi', '5000', '服务端内部处理异常', '服务端内部错误码', 'f', NULL); -INSERT INTO "public"."camera_status" VALUES (3, 'yingshi', '5400', '私有化协议vtm检测私有化协议中码流类型小于0或者设备序列号为空等非法参数场景返回(app不重试取流)', '客户端参数出错', 'f', NULL); -INSERT INTO "public"."camera_status" VALUES (4, 'yingshi', '5402', '回放找不到录像文件', '设备回放找不到录像文件', 'f', NULL); -INSERT INTO "public"."camera_status" VALUES (5, 'yingshi', '5403', '操作码或信令密钥与设备不匹配', '操作码或信令密钥与设备不匹配', 'f', NULL); -INSERT INTO "public"."camera_status" VALUES (6, 'yingshi', '5404', '设备不在线', '设备不在线', 'f', NULL); -INSERT INTO "public"."camera_status" VALUES (7, 'yingshi', '5405', '流媒体向设备发送或接受信令超时/cas响应超时', '设备回应信令10秒超时', 'f', NULL); -INSERT INTO "public"."camera_status" VALUES (8, 'yingshi', '5406', 'token失效', 'token失效', 'f', NULL); -INSERT INTO "public"."camera_status" VALUES (9, 'yingshi', '5407', '客户端的URL格式错误', '客户端的URL格式错误', 'f', NULL); -INSERT INTO "public"."camera_status" VALUES (10, 'yingshi', '5409', '预览开启隐私保护', '预览开启隐私保护', 'f', NULL); -INSERT INTO "public"."camera_status" VALUES (11, 'yingshi', '5411', 'token无权限', 'token无权限、用户无权限', 'f', NULL); -INSERT INTO "public"."camera_status" VALUES (12, 'yingshi', '5412', 'session不存在', 'session不存在', 'f', NULL); -INSERT INTO "public"."camera_status" VALUES (13, 'yingshi', '5413', '验证token的他异常(不具体)', 'token验证失败', 'f', NULL); -INSERT INTO "public"."camera_status" VALUES (14, 'yingshi', '5415', '设备通道错', '设备判断请求通道不存在', 'f', NULL); -INSERT INTO "public"."camera_status" VALUES (15, 'yingshi', '5416', '设备资源受限', '设备资源受限', 'f', NULL); -INSERT INTO "public"."camera_status" VALUES (16, 'yingshi', '5451', '设备不支持的码流类型', '设备不支持的码流类型', 'f', NULL); -INSERT INTO "public"."camera_status" VALUES (17, 'yingshi', '5452', '设备链接流媒体服务器失败', '设备链接流媒体服务器失败', 'f', NULL); -INSERT INTO "public"."camera_status" VALUES (18, 'yingshi', '5454', '流媒体中关于设备取流会话不存在', '流媒体中关于设备取流会话不存在', 'f', NULL); -INSERT INTO "public"."camera_status" VALUES (19, 'yingshi', '5455', '设备通道未关联', '设备通道未关联', 'f', NULL); -INSERT INTO "public"."camera_status" VALUES (20, 'yingshi', '5456', '设备通道关联设备不在线', '设备通道关联设备不在线', 'f', NULL); -INSERT INTO "public"."camera_status" VALUES (21, 'yingshi', '5457', '客户端不支持端到端加密', '客户端不支持端到端加密', 'f', NULL); -INSERT INTO "public"."camera_status" VALUES (22, 'yingshi', '5458', '设备不支持当前并发ECDH密', '设备不支持当前并发ECDH密', 'f', NULL); -INSERT INTO "public"."camera_status" VALUES (23, 'yingshi', '5459', 'VTDU 处理ECDH 加密失败', NULL, 'f', NULL); -INSERT INTO "public"."camera_status" VALUES (24, 'yingshi', '5492', '设备不支持的命令', '设备不支持的命令', 'f', NULL); -INSERT INTO "public"."camera_status" VALUES (25, 'yingshi', '5500', '服务器处理失败', '服务器处理失败', 'f', NULL); -INSERT INTO "public"."camera_status" VALUES (26, 'yingshi', '5503', 'vtm返回分配vtdu失败', 'vtm返回分配vtdu失败', 'f', NULL); -INSERT INTO "public"."camera_status" VALUES (27, 'yingshi', '5504', '流媒体vtdu达到最大负载', '流媒体vtdu达到最大负载', 'f', NULL); -INSERT INTO "public"."camera_status" VALUES (28, 'yingshi', '5544', '设备返回无视频源', NULL, 'f', NULL); -INSERT INTO "public"."camera_status" VALUES (29, 'yingshi', '5545', '视频分享时间已经结束', NULL, 'f', NULL); -INSERT INTO "public"."camera_status" VALUES (30, 'yingshi', '5546', 'vtdu返回达到取流并发路数限制', NULL, 'f', NULL); -INSERT INTO "public"."camera_status" VALUES (31, 'yingshi', '5547', 'vtdu返回开放平台用户并发限制', NULL, 'f', NULL); -INSERT INTO "public"."camera_status" VALUES (32, 'yingshi', '5556', 'ticket校验失败', NULL, 'f', NULL); -INSERT INTO "public"."camera_status" VALUES (33, 'yingshi', '5557', '回放服务器等待流头超时', NULL, 'f', NULL); -INSERT INTO "public"."camera_status" VALUES (34, 'yingshi', '5558', '查找录像开始时间错误', NULL, 'f', NULL); -INSERT INTO "public"."camera_status" VALUES (35, 'yingshi', '5560', '群组分享取流二次验证失败', NULL, 'f', NULL); -INSERT INTO "public"."camera_status" VALUES (36, 'yingshi', '5561', '分享群组用户被锁住', NULL, 'f', NULL); -INSERT INTO "public"."camera_status" VALUES (37, 'yingshi', '5562', '群组分享用户权限变更', NULL, 'f', NULL); -INSERT INTO "public"."camera_status" VALUES (38, 'yingshi', '5563', '认证服务连接失败', NULL, 'f', NULL); -INSERT INTO "public"."camera_status" VALUES (39, 'yingshi', '5564', '认证超时', NULL, 'f', NULL); -INSERT INTO "public"."camera_status" VALUES (40, 'yingshi', '5565', '缓存无效', NULL, 'f', NULL); -INSERT INTO "public"."camera_status" VALUES (41, 'yingshi', '5566', '不在分享时间内预览', NULL, 'f', NULL); -INSERT INTO "public"."camera_status" VALUES (42, 'yingshi', '5567', '分享通道被锁定', NULL, 'f', NULL); -INSERT INTO "public"."camera_status" VALUES (43, 'yingshi', '5568', '未找到认证类型', NULL, 'f', NULL); -INSERT INTO "public"."camera_status" VALUES (44, 'yingshi', '5569', '认证返回的参数异常', NULL, 'f', NULL); -INSERT INTO "public"."camera_status" VALUES (45, 'yingshi', '5600', '分享设备不在分享时间内', NULL, 'f', NULL); -INSERT INTO "public"."camera_status" VALUES (46, 'yingshi', '5601', '群组分享用户没权限', NULL, 'f', NULL); -INSERT INTO "public"."camera_status" VALUES (47, 'yingshi', '5602', '群组分享权限变更', NULL, 'f', NULL); -INSERT INTO "public"."camera_status" VALUES (48, 'yingshi', '5530', '机房故障不可用', NULL, 'f', NULL); -INSERT INTO "public"."camera_status" VALUES (49, 'yingshi', '5701', 'cas信令返回格式错误', NULL, 'f', NULL); -INSERT INTO "public"."camera_status" VALUES (50, 'yingshi', '5702', 'SPGW请求Cas、Status透传超时', NULL, 'f', NULL); -INSERT INTO "public"."camera_status" VALUES (51, 'yingshi', '5703', 'SPGW请求http不通', NULL, 'f', NULL); -INSERT INTO "public"."camera_status" VALUES (52, 'yingshi', '6001', '客户端参数出错', NULL, 'f', NULL); -INSERT INTO "public"."camera_status" VALUES (53, 'yingshi', '6099', '客户端默认错误', NULL, 'f', NULL); -INSERT INTO "public"."camera_status" VALUES (54, 'yingshi', '6101', '不支持的命令', NULL, 'f', NULL); -INSERT INTO "public"."camera_status" VALUES (55, 'yingshi', '6102', '设备流头发送失败', NULL, 'f', NULL); -INSERT INTO "public"."camera_status" VALUES (56, 'yingshi', '6103', 'cas/设备返回错误1', NULL, 'f', NULL); -INSERT INTO "public"."camera_status" VALUES (57, 'yingshi', '6104', 'cas/设备返回错误-1', NULL, 'f', NULL); -INSERT INTO "public"."camera_status" VALUES (58, 'yingshi', '6105', '设备返回错误码3', NULL, 'f', NULL); -INSERT INTO "public"."camera_status" VALUES (59, 'yingshi', '6106', '设备返回错误码4', '一般常见于多通道设 备预览 1、通道不存在 2、通道子码流不存在 3、通道不在线', 'f', NULL); -INSERT INTO "public"."camera_status" VALUES (60, 'yingshi', '6107', '设备返回错误码5', NULL, 'f', NULL); -INSERT INTO "public"."camera_status" VALUES (61, 'yingshi', '6108', 'cas信令回应重复', NULL, 'f', NULL); -INSERT INTO "public"."camera_status" VALUES (62, 'yingshi', '6109', '视频广场取消分享', NULL, 'f', NULL); -INSERT INTO "public"."camera_status" VALUES (63, 'yingshi', '6110', '设备信令默认错误', '设备错误返回的错误码,不具体', 'f', NULL); -INSERT INTO "public"."camera_status" VALUES (64, 'yingshi', '6501', '设备数据链路和实际链路不匹配', NULL, 'f', NULL); -INSERT INTO "public"."camera_status" VALUES (65, 'yingshi', '6502', '设备数据链路重复建立连接', NULL, 'f', NULL); -INSERT INTO "public"."camera_status" VALUES (66, 'yingshi', '6503', '设备数据链路端口不匹配', NULL, 'f', NULL); -INSERT INTO "public"."camera_status" VALUES (67, 'yingshi', '6504', '缓存设备数据链路失败(内存块不足)', NULL, 'f', NULL); -INSERT INTO "public"."camera_status" VALUES (68, 'yingshi', '6505', '设备发送确认头消息重复', NULL, 'f', NULL); -INSERT INTO "public"."camera_status" VALUES (69, 'yingshi', '6506', '设备数据先于确定头部到达', NULL, 'f', NULL); -INSERT INTO "public"."camera_status" VALUES (70, 'yingshi', '6508', '设备数据头部长度非法', NULL, 'f', NULL); -INSERT INTO "public"."camera_status" VALUES (71, 'yingshi', '6509', '索引找不到设备数据管理块', NULL, 'f', NULL); -INSERT INTO "public"."camera_status" VALUES (72, 'yingshi', '6510', '设备数据链路vtdu内存块协议状态不匹配', NULL, 'f', NULL); -INSERT INTO "public"."camera_status" VALUES (73, 'yingshi', '6511', '设备数据头部没有streamkey错误', NULL, 'f', NULL); -INSERT INTO "public"."camera_status" VALUES (74, 'yingshi', '6512', '设备数据头部非法(较笼统)', NULL, 'f', NULL); -INSERT INTO "public"."camera_status" VALUES (75, 'yingshi', '6513', '设备数据长度过小', NULL, 'f', NULL); -INSERT INTO "public"."camera_status" VALUES (76, 'yingshi', '6514', '设备老协议推流头部没有streamkey错误', NULL, 'f', NULL); -INSERT INTO "public"."camera_status" VALUES (77, 'yingshi', '6515', '设备老协议推流数据非法', NULL, 'f', NULL); -INSERT INTO "public"."camera_status" VALUES (78, 'yingshi', '6516', '设备老协议索引找不到内存管理块', NULL, 'f', NULL); -INSERT INTO "public"."camera_status" VALUES (79, 'yingshi', '6517', '设备老协议推流数据非法', NULL, 'f', NULL); -INSERT INTO "public"."camera_status" VALUES (80, 'yingshi', '6518', '设备数据包过大', NULL, 'f', NULL); -INSERT INTO "public"."camera_status" VALUES (81, 'yingshi', '6519', '设备推流链路网络不稳定', '设备长时间未推流超时', 'f', NULL); -INSERT INTO "public"."camera_status" VALUES (82, 'yingshi', '6520', '设备推流链路网络不稳定(默认)', '设备网络异常', 'f', NULL); - - - - - --- ---------------------------- --- Records of camera_status_resolve --- ---------------------------- -INSERT INTO "public"."camera_status_resolve" VALUES (2, 2, '检测服务端是否正常'); -INSERT INTO "public"."camera_status_resolve" VALUES (3, 3, '刷新重试'); -INSERT INTO "public"."camera_status_resolve" VALUES (4, 4, '检查是否有存储卡并且接触良好'); -INSERT INTO "public"."camera_status_resolve" VALUES (5, 6, '检查设备网络'); -INSERT INTO "public"."camera_status_resolve" VALUES (6, 6, '重启设备接入萤石云'); -INSERT INTO "public"."camera_status_resolve" VALUES (7, 7, '检查设备网络'); -INSERT INTO "public"."camera_status_resolve" VALUES (8, 7, '重启设备'); -INSERT INTO "public"."camera_status_resolve" VALUES (9, 8, '刷新重试或者重启设备'); -INSERT INTO "public"."camera_status_resolve" VALUES (10, 9, '刷新重试'); -INSERT INTO "public"."camera_status_resolve" VALUES (11, 13, '刷新重试'); -INSERT INTO "public"."camera_status_resolve" VALUES (12, 14, '刷新重试'); -INSERT INTO "public"."camera_status_resolve" VALUES (13, 15, '刷新重试'); -INSERT INTO "public"."camera_status_resolve" VALUES (14, 16, '刷新重试或者切换到高清模式'); -INSERT INTO "public"."camera_status_resolve" VALUES (15, 17, '检查设备网络,重启设备,刷新重试'); -INSERT INTO "public"."camera_status_resolve" VALUES (16, 19, '检查设备通道是否关联'); -INSERT INTO "public"."camera_status_resolve" VALUES (17, 20, '检查设备通道是否上线'); -INSERT INTO "public"."camera_status_resolve" VALUES (18, 25, '刷新重试'); -INSERT INTO "public"."camera_status_resolve" VALUES (19, 26, 'vtdu服务异常,请请稍后重试'); -INSERT INTO "public"."camera_status_resolve" VALUES (20, 27, '服务器负载达到上限,请稍后重试'); -INSERT INTO "public"."camera_status_resolve" VALUES (21, 28, '设备是否接触良好'); -INSERT INTO "public"."camera_status_resolve" VALUES (22, 28, '如果一直无法解决,请联系技术支持'); -INSERT INTO "public"."camera_status_resolve" VALUES (23, 30, '请升级为企业版,放开并发限制'); -INSERT INTO "public"."camera_status_resolve" VALUES (24, 31, '请确定开放平台用户预览是否超过用户并发数量限制'); -INSERT INTO "public"."camera_status_resolve" VALUES (25, 33, '刷新重试,检测设备网络,重启设备'); -INSERT INTO "public"."camera_status_resolve" VALUES (26, 48, '刷新重试'); -INSERT INTO "public"."camera_status_resolve" VALUES (27, 49, '刷新重试'); -INSERT INTO "public"."camera_status_resolve" VALUES (28, 50, '刷新重试'); -INSERT INTO "public"."camera_status_resolve" VALUES (29, 51, '刷新重试'); -INSERT INTO "public"."camera_status_resolve" VALUES (30, 52, '刷新重试'); -INSERT INTO "public"."camera_status_resolve" VALUES (31, 54, '刷新重试'); -INSERT INTO "public"."camera_status_resolve" VALUES (32, 55, '刷新重试'); -INSERT INTO "public"."camera_status_resolve" VALUES (33, 56, '刷新重试'); -INSERT INTO "public"."camera_status_resolve" VALUES (34, 57, '刷新重试'); -INSERT INTO "public"."camera_status_resolve" VALUES (35, 58, '刷新重试'); -INSERT INTO "public"."camera_status_resolve" VALUES (36, 59, '刷新重试'); -INSERT INTO "public"."camera_status_resolve" VALUES (37, 60, '刷新重试'); -INSERT INTO "public"."camera_status_resolve" VALUES (38, 61, '刷新重试'); -INSERT INTO "public"."camera_status_resolve" VALUES (39, 63, '刷新重试,或者重启设备'); -INSERT INTO "public"."camera_status_resolve" VALUES (40, 64, '刷新重试'); -INSERT INTO "public"."camera_status_resolve" VALUES (41, 65, '刷新重试'); -INSERT INTO "public"."camera_status_resolve" VALUES (42, 66, '刷新重试'); -INSERT INTO "public"."camera_status_resolve" VALUES (43, 67, '刷新重试'); -INSERT INTO "public"."camera_status_resolve" VALUES (44, 68, '刷新重试'); -INSERT INTO "public"."camera_status_resolve" VALUES (45, 69, '刷新重试'); -INSERT INTO "public"."camera_status_resolve" VALUES (46, 70, '刷新重试,或者重启设备'); -INSERT INTO "public"."camera_status_resolve" VALUES (47, 71, '刷新重试'); -INSERT INTO "public"."camera_status_resolve" VALUES (48, 80, '刷新重试,或者重启设备'); - diff --git a/script/1.1.1/schema/1.create_camera_status_table.sql b/script/1.1.1/schema/1.create_camera_status_table.sql deleted file mode 100644 index 43270b6..0000000 --- a/script/1.1.1/schema/1.create_camera_status_table.sql +++ /dev/null @@ -1,140 +0,0 @@ -create table if not exists camera_status -( - id serial not null, - platform varchar(32) not null, - status varchar(32) not null, - describe varchar(1024), - paraphrase varchar(1024), - forbidden boolean default false not null, - paraphrase_custom varchar(1024), - constraint camera_status_pk - primary key (id) -); - -comment on column camera_status.platform is '平台分类 yingshi gb'; - -comment on column camera_status.describe is '错误描述'; - -comment on column camera_status.paraphrase is '释义'; - -comment on column camera_status.forbidden is '是否禁用'; - -comment on column camera_status.paraphrase_custom is '自定义释义'; - -create unique index if not exists camera_status_id_uindex - on camera_status (id); - - - -create table if not exists camera_status_log -( - id serial not null, - status_id integer not null, - time timestamp not null, - constraint camera_status_log_pk - primary key (id), - constraint camera_status_log_camera_status_id_fk - foreign key (status_id) references camera_status -); - -create unique index if not exists camera_status_log_id_uindex - on camera_status_log (id); - -create unique index if not exists camera_status_log_id_uindex_2 - on camera_status_log (id); - - -create table if not exists camera_status_push_config -( - id serial not null, - name varchar(64) not null, - push_way varchar(32) not null, - notice_way varchar(32) not null, - create_user integer not null, - forbidden boolean default false not null, - timing varchar(32), - constraint camera_online_status_push_config_pk - primary key (id) -); - -comment on column camera_status_push_config.push_way is '推送方式 email / phone'; - -comment on column camera_status_push_config.notice_way is '通知方式 offline / online / timing'; - -comment on column camera_status_push_config.timing is '定时推送时间'; - -create unique index if not exists camera_online_status_push_config_id_uindex - on camera_status_push_config (id); - - - -create table if not exists camera_status_push_log -( - id serial not null, - push_config_id integer, - receiver jsonb not null, - time timestamp, - push_way varchar(128) not null, - constraint camera_status_push_log_pk - primary key (id) -); - -comment on table camera_status_push_log is '上下线推送日志'; - -create unique index if not exists camera_status_push_log_id_uindex - on camera_status_push_log (id); - - - -create table if not exists camera_status_push_monitor -( - id serial not null, - config_id integer not null, - camera_id integer not null, - constraint camera_status_push_monitor_pk - primary key (id), - constraint camera_status_push_monitor_camera_id_fk - foreign key (camera_id) references camera, - constraint camera_status_push_monitor_camera_status_push_config_id_fk - foreign key (config_id) references camera_status_push_config -); - -create unique index if not exists camera_status_push_monitor_id_uindex - on camera_status_push_monitor (id); - - - -create table if not exists camera_status_push_receiver -( - id serial not null, - config_id integer not null, - receiver varchar(64) not null, - constraint camera_status_push_receiver_pk - primary key (id), - constraint camera_status_push_receiver_camera_status_push_config_id_fk - foreign key (config_id) references camera_status_push_config -); - -comment on column camera_status_push_receiver.receiver is '接受者信息 邮箱或者电话号码'; - -create unique index if not exists camera_status_push_receiver_id_uindex - on camera_status_push_receiver (id); - - -create table if not exists camera_status_resolve -( - id serial not null, - status_id integer not null, - resolve varchar(1024) not null, - constraint camera_status_resolve_pk - primary key (id), - constraint camera_status_resolve_camera_status_id_fk - foreign key (status_id) references camera_status -); - -comment on table camera_status_resolve is '错误码解决方案'; - -create unique index if not exists camera_status_resolve_id_uindex - on camera_status_resolve (id); - - diff --git a/script/1.1.2/schema/1.update_camera_status_config.sql b/script/1.1.2/schema/1.update_camera_status_config.sql deleted file mode 100644 index 84367fe..0000000 --- a/script/1.1.2/schema/1.update_camera_status_config.sql +++ /dev/null @@ -1,21 +0,0 @@ -alter table camera_status_push_config alter column notice_way type varchar[32] using notice_way::varchar[32]; - - - -DROP TABLE if exists camera_status_push_log; -create table if not exists camera_status_push_log -( - id serial not null, - push_config_id integer, - time timestamp, - push_way varchar(128) not null, - camera integer[] not null, - receiver character varying[] not null, - constraint camera_status_push_log_pk - primary key (id) -); - -comment on table camera_status_push_log is '上下线推送日志'; - -create unique index if not exists camera_status_push_log_id_uindex - on camera_status_push_log (id); diff --git a/script/1.1.2/schema/2.update_push_log.sql b/script/1.1.2/schema/2.update_push_log.sql deleted file mode 100644 index d41162e..0000000 --- a/script/1.1.2/schema/2.update_push_log.sql +++ /dev/null @@ -1,5 +0,0 @@ -alter table camera_status_push_log - add timing varchar(64); - -alter table camera_status_push_log - add notice_way varchar[]; \ No newline at end of file diff --git a/script/1.1.2/schema/3.update_camera_channel_no.sql b/script/1.1.2/schema/3.update_camera_channel_no.sql deleted file mode 100644 index 1b3250a..0000000 --- a/script/1.1.2/schema/3.update_camera_channel_no.sql +++ /dev/null @@ -1,4 +0,0 @@ -alter table camera - add channel_no varchar(128); - -comment on column camera.channel_no is '通道号'; diff --git a/script/1.1.2/schema/4.create_camera_status_offline_log.sql b/script/1.1.2/schema/4.create_camera_status_offline_log.sql deleted file mode 100644 index 56c1ead..0000000 --- a/script/1.1.2/schema/4.create_camera_status_offline_log.sql +++ /dev/null @@ -1,13 +0,0 @@ -create table if not exists camera_status_offline_log -( - id serial not null, - camera_id integer not null, - status varchar(32) not null, - time timestamp not null, - constraint camera_status_offline_log_pk - primary key (id) -); - -create unique index if not exists camera_status_offline_log_id_uindex - on camera_status_offline_log (id); - diff --git a/script/1.2.1/schema/1.create_application.sql b/script/1.2.1/schema/1.create_application.sql deleted file mode 100644 index f117d3d..0000000 --- a/script/1.2.1/schema/1.create_application.sql +++ /dev/null @@ -1,19 +0,0 @@ -create table if not exists application -( - id serial not null, - name varchar(32) not null, - type character varying[], - app_key varchar(64) not null, - app_secret varchar(64) not null, - create_user_id integer not null, - create_time timestamp not null, - forbidden boolean default false not null, - constraint application_pk - primary key (id) -); - -comment on column application.type is 'web / app / wxapp / other'; - -create unique index if not exists application_id_uindex - on application (id); - diff --git a/script/1.3.0/schema/1.alert_gbcamera_did.sql b/script/1.3.0/schema/1.alert_gbcamera_did.sql deleted file mode 100644 index 079d2c7..0000000 --- a/script/1.3.0/schema/1.alert_gbcamera_did.sql +++ /dev/null @@ -1,4 +0,0 @@ -alter table "gbCamera" - add did varchar(128); - -comment on column "gbCamera".did is '设备自定义id'; diff --git a/script/1.3.0/schema/2.create_mirror_table.sql b/script/1.3.0/schema/2.create_mirror_table.sql deleted file mode 100644 index 2a8cae7..0000000 --- a/script/1.3.0/schema/2.create_mirror_table.sql +++ /dev/null @@ -1,90 +0,0 @@ -create table if not exists mirror -( - id serial not null, - template varchar(63) not null, - create_user integer not null, - create_time timestamp with time zone not null, - update_time timestamp with time zone, - title varchar(128), - show_header boolean not null, - publish boolean default false not null, - mid varchar(32) not null, - publish_time timestamp with time zone, - constraint mirror_pk - primary key (id) -); - -comment on column mirror.template is '模板标识'; - -create unique index if not exists mirror_id_uindex - on mirror (id); - -create table if not exists mirror_tree -( - id serial not null, - name varchar(64) not null, - level integer not null, - dependence integer, - mirror_id integer not null, - constraint mirror_tree_pk - primary key (id), - constraint mirror_tree_mirror_id_fk - foreign key (mirror_id) references mirror -); - -comment on table mirror_tree is '镜像服务的树节点'; - -comment on column mirror_tree.level is '层级标注'; - -create unique index if not exists mirror_tree_id_uindex - on mirror_tree (id); - -create table if not exists mirror_filter_group -( - id serial not null, - name varchar(64) not null, - forbidden boolean default false not null, - mirror_id integer not null, - constraint mirror_filter_group_pk - primary key (id), - constraint mirror_filter_group_mirror_id_fk - foreign key (mirror_id) references mirror -); - -comment on table mirror_filter_group is '筛选分组'; - -create unique index if not exists mirror_filter_group_id_uindex - on mirror_filter_group (id); - -create table if not exists mirror_filter -( - id serial not null, - name varchar(64) not null, - group_id integer not null, - constraint mirror_filter_pk - primary key (id), - constraint mirror_filter_mirror_filter_group_id_fk - foreign key (group_id) references mirror_filter_group -); - -create unique index if not exists mirror_filter_id_uindex - on mirror_filter (id); - -create table if not exists mirror_camera -( - id serial not null, - camera_id integer not null, - tree_ids integer[] not null, - filter_ids integer[], - mirror_id integer not null, - constraint mirror_camera_pk - primary key (id), - constraint mirror_camera_camera_id_fk - foreign key (camera_id) references camera, - constraint mirror_camera_mirror_id_fk - foreign key (mirror_id) references mirror -); - -create unique index if not exists mirror_camera_id_uindex - on mirror_camera (id); - diff --git a/script/1.3.1/data/1_sync_camera_data/.vscode/launch.json b/script/1.3.1/data/1_sync_camera_data/.vscode/launch.json deleted file mode 100644 index 3a3fcba..0000000 --- a/script/1.3.1/data/1_sync_camera_data/.vscode/launch.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - // 使用 IntelliSense 了解相关属性。 - // 悬停以查看现有属性的描述。 - // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387 - "version": "0.2.0", - "configurations": [ - { - "type": "node", - "request": "launch", - "name": "启动程序", - "skipFiles": [ - "/**" - ], - "program": "${workspaceFolder}\\index.js" - } - ] -} \ No newline at end of file diff --git a/script/1.3.1/data/1_sync_camera_data/Dockerfile b/script/1.3.1/data/1_sync_camera_data/Dockerfile deleted file mode 100644 index 2aa1f3c..0000000 --- a/script/1.3.1/data/1_sync_camera_data/Dockerfile +++ /dev/null @@ -1,8 +0,0 @@ - -FROM repository.anxinyun.cn/base-images/nodejs12:20.10.12.2 -COPY . /var/app -WORKDIR /var/app -RUN npm cache clean -f -RUN rm -rf package-lock.json -RUN npm install --registry http://10.8.30.22:7000 -CMD ["node", "index.js"] \ No newline at end of file diff --git a/script/1.3.1/data/1_sync_camera_data/index.js b/script/1.3.1/data/1_sync_camera_data/index.js deleted file mode 100644 index c508ff1..0000000 --- a/script/1.3.1/data/1_sync_camera_data/index.js +++ /dev/null @@ -1,156 +0,0 @@ -try { - const { Pool, Client } = require('pg') - const XLSX = require('xlsx') - const path = require('path') - const request = require('superagent') - const moment = require('moment') - - // 连接数据库 - const vcmpPool = new Pool({ - user: 'FashionAdmin', - host: '10.8.40.223', - database: 'video-access', - password: 'Fas123_', - port: 5432, - }) - const anxinPool = new Pool({ - user: 'FashionAdmin', - host: '10.8.40.223', - database: 'AnxinCloud', - password: 'Fas123_', - port: 5432, - }) - - - const fun = async () => { - // note: we don't try/catch this because if connecting throws an exception - // we don't need to dispose of the client (it will be undefined) - const vcmpClient = await vcmpPool.connect() - const anxinClient = await anxinPool.connect() - try { - await vcmpClient.query('BEGIN') - const yingshiHost = 'https://open.ys7.com/api/' - // 获取全部萤石摄像头信息 - const anxinYSRes = await anxinClient.query(`SELECT * FROM t_video_ipc WHERE type=$1`, ['yingshi']); - // console.log(anxinYSRes); - // 获取所有萤石账号信息 - const secretYSRes = await vcmpClient.query(`SELECT * FROM secret_yingshi`) - const secretRes = secretYSRes.rows - // console.log('secretRes', secretRes); - - let addSuccessCount = 0 - let addRepeatCount = 0 - let addUnlegalCount = 0 - let addNoAuthCount = 0 - for (let c of anxinYSRes.rows) { - console.log(`处理序列号:${c.serial_no}`) - if (!c.serial_no) { - addUnlegalCount += 1 - continue - } - let vcmpExistRes = await vcmpClient.query( - `SELECT * FROM "gbCamera" WHERE streamid=$1`, [c.serial_no] - ) - let vcmpExistRows = vcmpExistRes.rows - - let cameraExistRes = await vcmpClient.query(`SELECT * FROM camera WHERE serial_no=$1`, [c.serial_no]) - let cameraRes = cameraExistRes.rows || [] - - let repeatCamera = cameraRes.find(cr => { - return ( - !cr.channel_no && c.channel_no == 1 - ) || (cr.channel_no == c.channel_no) - }) - if (repeatCamera) { - console.log(`当前设备序列号 ${c.serial_no} 通道号 ${c.channel_no} 已存在`); - console.log(`已存在 id=${repeatCamera.id} 通道号 ${repeatCamera.channel_no}`); - addRepeatCount++ - continue - } - - if (vcmpExistRows.length) { - let beloneSecretId = null - let serialUnlegal = false - for (let s of secretRes) { - let start = (new Date()).getTime(); - console.log(`当前查询账号key ${s.key}`); - if (!s.newToken) { - const tokenRes = await request.post(`${yingshiHost}lapp/token/get`).query({ - appKey: s.key, - appSecret: s.secret - }) - console.log(`查询 token 结果`, tokenRes.body); - - if (tokenRes.body.code == 200 && tokenRes.body.data) { - const { accessToken, expireTime } = tokenRes.body.data - s.newToken = accessToken - - } else { - throw `未能获取萤石token ${s.key} ${tokenRes.body.code}` - } - } - - while (((new Date()).getTime() - start) < 3000) {//限制频率 - continue; - } - - // 检测设备所属 - const cameraState = await request.post(`${yingshiHost}lapp/device/info`).query({ - accessToken: s.newToken, - deviceSerial: c.serial_no - }) - console.log(`查询设备所属结果`, cameraState.body.code, cameraState.body.msg); - if (cameraState.body.code == 200) { - console.log(`所属萤石账号 ${s.key}`); - beloneSecretId = s.id - break - } else if (cameraState.body.code == 20018) { - - } else if (cameraState.body.code == 20014) { - serialUnlegal = true - break - } - } - if (serialUnlegal) { - addUnlegalCount++ - continue - } - - if (!beloneSecretId) { - console.error('没有查询到所属账号') - console.log(vcmpExistRows); - addNoAuthCount++ - continue - } - - const cameraInQuery = `INSERT INTO "camera" (type, name, serial_no, cloud_control,longitude,latitude,create_time,create_user_id,yingshi_secret_id,gb_id,channel_no) VALUES($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11) RETURNING id;` - await vcmpClient.query(cameraInQuery, ['yingshi', c.name, c.serial_no, c.has_ptz, c.longitude, c.latitude, moment().format(), 1, beloneSecretId, vcmpExistRows[0].id, c.channel_no]) - addSuccessCount++ - } else { - console.error('当前序列号不存在,应在 vcmp 添加相应萤石账号'); - addNoAuthCount++ - } - } - console.log(` - 共 ${anxinYSRes.rows.length} - 添加 ${addSuccessCount} - 已有 ${addRepeatCount} - 序列号不合法 ${addUnlegalCount} - 无所属 ${addNoAuthCount} - `); - // await client.query('ROLLBACK') - await vcmpClient.query('COMMIT') - console.log('执行完毕~') - } catch (e) { - await vcmpClient.query('ROLLBACK') - console.log('执行错误~') - throw e - } finally { - vcmpClient.release(); - } - } - - fun() -} catch (error) { - console.error(error) -} diff --git a/script/1.3.1/data/1_sync_camera_data/package.json b/script/1.3.1/data/1_sync_camera_data/package.json deleted file mode 100644 index 55bf7c5..0000000 --- a/script/1.3.1/data/1_sync_camera_data/package.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "name": "appkey-generator", - "version": "1.0.0", - "description": "tool", - "main": "index.js", - "scripts": { - "test": "mocha", - "start": "set NODE_ENV=development&&node index" - }, - "author": "liu", - "license": "ISC", - "dependencies": { - "moment": "^2.29.4", - "pg": "^7.18.2", - "superagent": "3.5.2", - "xlsx": "^0.17.1" - } -}