diff --git a/api/.vscode/launch.json b/api/.vscode/launch.json index 18401bb..1adc141 100644 --- a/api/.vscode/launch.json +++ b/api/.vscode/launch.json @@ -15,7 +15,8 @@ "args": [ "-p 4900", // 研发 - "-g postgres://postgres:123456@10.8.30.166:5432/XunJian", + // "-g postgres://postgres:123456@10.8.30.39:5432/PumpStation", + "-g postgres://FashionAdmin:123456@10.8.30.156:5432/PumpStation", // 测试 // "--apiEmisUrl http://10.8.30.161:1111", // "--qnak XuDgkao6cL0HidoMAPnA5OB10Mc_Ew08mpIfRJK5", diff --git a/api/app/lib/controllers/auth/index.js b/api/app/lib/controllers/auth/index.js index 85a6ab1..7a163b4 100644 --- a/api/app/lib/controllers/auth/index.js +++ b/api/app/lib/controllers/auth/index.js @@ -5,158 +5,128 @@ const MD5 = require('crypto-js/md5'); const moment = require('moment'); const uuid = require('uuid'); -async function login(ctx, next) { - try { - const transaction = await ctx.fs.dc.orm.transaction(); - - const models = ctx.fs.dc.models; - const params = ctx.request.body; - let password = Hex.stringify(MD5(params.password)); - const userRes = await models.User.findOne({ - where: { - username: params.username, - password: password, - delete: false, - enable: true - }, - attributes: { exclude: ['password'] }, - include: [{ - attributes: ["resourceId"], - model: models.UserResource - }] - }); - - - if (!userRes) { - ctx.status = 400; - ctx.body = { - "message": "账号或密码错误" - } - } - - if (userRes) - if (userRes && !userRes.enable) { - ctx.status = 400; - ctx.body = { message: "该用户已被禁用" } - } else { - const token = uuid.v4(); - let deptInfo = null; - if (userRes) { - const { departmentId } = userRes.dataValues; - deptInfo = await models.Department.findOne({ - where: { - id: departmentId - } - }) - } - - if (!userRes) { - ctx.status = 400; - ctx.body = { message: "暂无登录权限,请联系管理员" } - return; - } - - let userData = userRes.dataValues; - let userRslt = Object.assign(userData, { - authorized: true, - token: token, - userResources: userRes ? userRes.userResources.map(r => r.resourceId) : [], - type: deptInfo ? deptInfo.type : '', - deptName: deptInfo ? deptInfo.name : '', - }); - await models.UserToken.create({ - token: token, - userInfo: userRslt, - expired: moment().add(30, 'days').format() - }); - - ctx.status = 200; - ctx.body = userRslt; - } - await transaction.commit(); - } catch (error) { - await transaction.rollback(); - ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); - ctx.status = 400; - ctx.body = { - "message": "登录失败" - } - } +async function login (ctx, next) { + try { + // const transaction = await ctx.fs.dc.orm.transaction(); + + const models = ctx.fs.dc.models; + const params = ctx.request.body; + let password = Hex.stringify(MD5(params.password)); + const userRes = await models.User.findOne({ + where: { + username: params.username, + password: password, + } + }); + + + if (userRes) { + const token = uuid.v4(); + const userInfo = { + authorized: true, + ...userRes.dataValues, + token, + }; + // 记录token + const expiredDay = 7; + const expired = moment().add(expiredDay, 'day').format('YYYY-MM-DD HH:mm:ss') + await models.UserToken.create({ + token: token, + userInfo: userInfo, + expired: expired + }); + ctx.status = 200; + ctx.body = userInfo; + } else { + ctx.status = 400; + ctx.body = { + "message": "账号或密码错误" + } + } + // await transaction.commit(); + } catch (error) { + // await transaction.rollback(); + ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); + ctx.status = 400; + ctx.body = { + "message": "登录失败" + } + } } -async function varfiyCode(ctx) { - try { - const { models } = ctx.fs.dc; - const { pushBySms, pushByEmail } = ctx.app.fs.utils - const { phone, sig, r } = ctx.request.body - - // 伪造的请求可能由相同的sig参数组成 - const checkSigUsed = await models.PhoneValidateCode.findOne({ - where: { sig: sig } - }); - if (checkSigUsed) { - throw '参数错误!' - } - - // 验证sig正确性 - const checkSig = Hex.stringify(SHA1(phone + r)); - if (!r || !sig || sig != checkSig) { - throw '参数错误!' - } - - let varifyCode = '' - for (let i = 0; i < 6; i++) { - varifyCode += Math.floor(Math.random() * 10) - } - - // await pushBySms({ - // phone: phone, - // templateCode: 'SMS_248250074', - // templateParam: { - // code: varifyCode - // }, - // }) - - await models.PhoneValidateCode.create({ - phone: phone, - code: varifyCode, - sig: sig, - expired: moment().add(10, 'minutes').format('YYYY-MM-DD HH:mm:ss') - }) - - ctx.status = 204; - } catch (error) { - ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); - ctx.status = 400; - ctx.body = { - message: typeof error == 'string' ? error : '获取验证码失败' - } - } +async function varfiyCode (ctx) { + try { + const { models } = ctx.fs.dc; + const { pushBySms, pushByEmail } = ctx.app.fs.utils + const { phone, sig, r } = ctx.request.body + + // 伪造的请求可能由相同的sig参数组成 + const checkSigUsed = await models.PhoneValidateCode.findOne({ + where: { sig: sig } + }); + if (checkSigUsed) { + throw '参数错误!' + } + + // 验证sig正确性 + const checkSig = Hex.stringify(SHA1(phone + r)); + if (!r || !sig || sig != checkSig) { + throw '参数错误!' + } + + let varifyCode = '' + for (let i = 0; i < 6; i++) { + varifyCode += Math.floor(Math.random() * 10) + } + + // await pushBySms({ + // phone: phone, + // templateCode: 'SMS_248250074', + // templateParam: { + // code: varifyCode + // }, + // }) + + await models.PhoneValidateCode.create({ + phone: phone, + code: varifyCode, + sig: sig, + expired: moment().add(10, 'minutes').format('YYYY-MM-DD HH:mm:ss') + }) + + ctx.status = 204; + } catch (error) { + ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); + ctx.status = 400; + ctx.body = { + message: typeof error == 'string' ? error : '获取验证码失败' + } + } } -async function logout(ctx) { - try { - const models = ctx.fs.dc.models; - const params = ctx.request.body; - - await models.UserToken.destroy({ - where: { - token: params.token, - } - }); - - ctx.status = 204; - } catch (error) { - ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); - ctx.status = 400; - ctx.body = { - message: typeof error == 'string' ? error : undefined - } - } +async function logout (ctx) { + try { + const models = ctx.fs.dc.models; + const params = ctx.request.body; + + await models.UserToken.destroy({ + where: { + token: params.token, + } + }); + + ctx.status = 204; + } catch (error) { + ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); + ctx.status = 400; + ctx.body = { + message: typeof error == 'string' ? error : undefined + } + } } module.exports = { - login, - varfiyCode, - logout, + login, + varfiyCode, + logout, }; \ No newline at end of file diff --git a/api/app/lib/index.js b/api/app/lib/index.js index ee32d26..c6224e4 100644 --- a/api/app/lib/index.js +++ b/api/app/lib/index.js @@ -53,25 +53,25 @@ module.exports.models = function (dc) { // dc = { orm: Sequelize对象, ORM: Seq require(`./models/${filename}`)(dc) }); - const { Department, User, UserResource, Resource, Project, Point, PatrolPlan - } = dc.models; + // const { Department, User, UserResource, Resource, Project, Point, PatrolPlan + // } = dc.models; - UserResource.belongsTo(User, { foreignKey: 'userId', targetKey: 'id' }); - User.hasMany(UserResource, { foreignKey: 'userId', sourceKey: 'id' }); + // UserResource.belongsTo(User, { foreignKey: 'userId', targetKey: 'id' }); + // User.hasMany(UserResource, { foreignKey: 'userId', sourceKey: 'id' }); - UserResource.belongsTo(Resource, { foreignKey: 'resourceId', targetKey: 'code' }); - Resource.hasMany(UserResource, { foreignKey: 'resourceId', sourceKey: 'code' }); - Resource.hasMany(Resource, { foreignKey: 'parentResource', sourceKey: 'code' }); + // UserResource.belongsTo(Resource, { foreignKey: 'resourceId', targetKey: 'code' }); + // Resource.hasMany(UserResource, { foreignKey: 'resourceId', sourceKey: 'code' }); + // Resource.hasMany(Resource, { foreignKey: 'parentResource', sourceKey: 'code' }); - User.belongsTo(Department, { foreignKey: 'departmentId', targetKey: 'id' }); - Department.hasMany(User, { foreignKey: 'departmentId', sourceKey: 'id' }); + // User.belongsTo(Department, { foreignKey: 'departmentId', targetKey: 'id' }); + // Department.hasMany(User, { foreignKey: 'departmentId', sourceKey: 'id' }); - Point.belongsTo(Project, { foreignKey: 'projectId', targetKey: 'id' }); - Project.hasMany(Point, { foreignKey: 'projectId', sourceKey: 'id' }); + // Point.belongsTo(Project, { foreignKey: 'projectId', targetKey: 'id' }); + // Project.hasMany(Point, { foreignKey: 'projectId', sourceKey: 'id' }); - PatrolPlan.belongsTo(Project, { foreignKey: 'structureId', targetKey: 'id' }); - Project.hasMany(PatrolPlan, { foreignKey: 'structureId', sourceKey: 'id' }); + // PatrolPlan.belongsTo(Project, { foreignKey: 'structureId', targetKey: 'id' }); + // Project.hasMany(PatrolPlan, { foreignKey: 'structureId', sourceKey: 'id' }); - PatrolPlan.belongsTo(User, { foreignKey: 'userId', targetKey: 'id' }); - User.hasMany(PatrolPlan, { foreignKey: 'userId', sourceKey: 'id' }); + // PatrolPlan.belongsTo(User, { foreignKey: 'userId', targetKey: 'id' }); + // User.hasMany(PatrolPlan, { foreignKey: 'userId', sourceKey: 'id' }); }; diff --git a/api/app/lib/models/department.js b/api/app/lib/models/department.js deleted file mode 100644 index db844db..0000000 --- a/api/app/lib/models/department.js +++ /dev/null @@ -1,56 +0,0 @@ -/* eslint-disable*/ -'use strict'; - -module.exports = dc => { - const DataTypes = dc.ORM; - const sequelize = dc.orm; - const Department = sequelize.define("department", { - id: { - type: DataTypes.INTEGER, - allowNull: false, - defaultValue: null, - comment: null, - primaryKey: true, - field: "id", - autoIncrement: true, - unique: "department_id_uindex" - }, - name: { - type: DataTypes.STRING, - allowNull: false, - defaultValue: null, - comment: null, - primaryKey: false, - field: "name", - autoIncrement: false - }, - dependence: { - type: DataTypes.INTEGER, - allowNull: true, - defaultValue: null, - comment: "上级部门/从属", - primaryKey: false, - field: "dependence", - autoIncrement: false - }, - type: { - type: DataTypes.INTEGER, - allowNull: true, - defaultValue: null, - comment: "", - primaryKey: false, - field: "type", - autoIncrement: false - } - }, { - tableName: "department", - comment: "", - indexes: [] - }); - - dc.models.Department = Department; - - - - return Department; -}; \ No newline at end of file diff --git a/api/app/lib/models/patrol_plan.js b/api/app/lib/models/patrol_plan.js deleted file mode 100644 index 91e5ddd..0000000 --- a/api/app/lib/models/patrol_plan.js +++ /dev/null @@ -1,105 +0,0 @@ -/* eslint-disable*/ -'use strict'; - -module.exports = dc => { - const DataTypes = dc.ORM; - const sequelize = dc.orm; - const PatrolPlan = sequelize.define("PatrolPlan", { - id: { - type: DataTypes.INTEGER, - allowNull: false, - defaultValue: null, - comment: null, - primaryKey: true, - field: "id", - autoIncrement: true, - unique: "patrol_plan_id_uindex" - }, - name: { - type: DataTypes.STRING, - allowNull: false, - defaultValue: null, - comment: null, - primaryKey: false, - field: "name", - autoIncrement: false - }, - way: { - type: DataTypes.STRING, - allowNull: true, - defaultValue: null, - comment: null, - primaryKey: false, - field: "way", - autoIncrement: false - }, - structureId: { - type: DataTypes.INTEGER, - allowNull: true, - defaultValue: null, - comment: null, - primaryKey: false, - field: "structure_id", - autoIncrement: false - }, - startTime: { - type: DataTypes.DATE, - allowNull: true, - defaultValue: null, - comment: null, - primaryKey: false, - field: "start_time", - autoIncrement: false - }, - endTime: { - type: DataTypes.DATE, - allowNull: true, - defaultValue: null, - comment: null, - primaryKey: false, - field: "end_time", - autoIncrement: false - }, - frequency: { - type: DataTypes.STRING, - allowNull: true, - defaultValue: null, - comment: null, - primaryKey: false, - field: "frequency", - autoIncrement: false - }, - points: { - type: DataTypes.JSONB, - allowNull: true, - defaultValue: null, - comment: null, - primaryKey: false, - field: "points", - autoIncrement: false - }, - userId: { - type: DataTypes.INTEGER, - allowNull: true, - comment: null, - primaryKey: false, - field: "user_id", - autoIncrement: false, - }, - patrolCount: { - type: DataTypes.INTEGER, - allowNull: false, - defaultValue: 0, - comment: null, - primaryKey: false, - field: "patrol_count", - autoIncrement: false - }, - }, { - tableName: "patrol_plan", - comment: "", - indexes: [] - }); - dc.models.PatrolPlan = PatrolPlan; - return PatrolPlan; -}; \ No newline at end of file diff --git a/api/app/lib/models/patrol_record.js b/api/app/lib/models/patrol_record.js deleted file mode 100644 index a71d7ca..0000000 --- a/api/app/lib/models/patrol_record.js +++ /dev/null @@ -1,55 +0,0 @@ -/* eslint-disable*/ -'use strict'; - -module.exports = dc => { - const DataTypes = dc.ORM; - const sequelize = dc.orm; - const PatrolRecord = sequelize.define("PatrolRecord", { - id: { - field: "id", - type: DataTypes.INTEGER, - allowNull: false, - primaryKey: true, - autoIncrement: true, - }, - patrolPlanId: { - field: "patrol_plan_id", - type: DataTypes.INTEGER, - allowNull: false, - primaryKey: false, - autoIncrement: false - }, - lastInspectionTime: { - field: "last_inspection_time", - type: DataTypes.DATE, - allowNull: true, - }, - inspectionTime: { - field: "inspection_time", - type: DataTypes.DATE, - allowNull: true, - }, - points: { - field: "points", - type: DataTypes.JSONB, - allowNull: true, - }, - alarm: { - field: "alarm", - type: DataTypes.BOOLEAN, - allowNull: false, - defaultValue: false, - }, - pointId: { - field: "point_id", - type: DataTypes.INTEGER, - allowNull: false, - }, - }, { - tableName: "patrol_record", - comment: "", - indexes: [] - }); - dc.models.PatrolRecord = PatrolRecord; - return PatrolRecord; -}; \ No newline at end of file diff --git a/api/app/lib/models/point.js b/api/app/lib/models/point.js deleted file mode 100644 index 978fc7c..0000000 --- a/api/app/lib/models/point.js +++ /dev/null @@ -1,79 +0,0 @@ -/* eslint-disable*/ -'use strict'; - -module.exports = dc => { - const DataTypes = dc.ORM; - const sequelize = dc.orm; - const Point = sequelize.define("point", { - id: { - type: DataTypes.INTEGER, - allowNull: false, - defaultValue: null, - comment: null, - primaryKey: true, - field: "id", - autoIncrement: true, - unique: "point_id_uindex" - }, - projectId: { - type: DataTypes.INTEGER, - allowNull: true, - defaultValue: null, - comment: null, - primaryKey: false, - field: "project_id", - autoIncrement: false - }, - name: { - type: DataTypes.STRING, - allowNull: true, - defaultValue: null, - comment: null, - primaryKey: false, - field: "name", - autoIncrement: false - }, - longitude: { - type: DataTypes.STRING, - allowNull: true, - defaultValue: null, - comment: null, - primaryKey: false, - field: "longitude", - autoIncrement: false - }, - latitude: { - type: DataTypes.STRING, - allowNull: true, - defaultValue: null, - comment: null, - primaryKey: false, - field: "latitude", - autoIncrement: false - }, - describe: { - type: DataTypes.STRING, - allowNull: true, - defaultValue: null, - comment: null, - primaryKey: false, - field: "describe", - autoIncrement: false - }, - qrCode: { - type: DataTypes.STRING, - allowNull: true, - defaultValue: null, - comment: null, - primaryKey: false, - field: "qr_code", - autoIncrement: false - }, - }, { - tableName: "point", - comment: "", - indexes: [] - }); - dc.models.Point = Point; - return Point; -}; \ No newline at end of file diff --git a/api/app/lib/models/project.js b/api/app/lib/models/project.js deleted file mode 100644 index 8543137..0000000 --- a/api/app/lib/models/project.js +++ /dev/null @@ -1,97 +0,0 @@ -/* eslint-disable*/ -'use strict'; - -module.exports = dc => { - const DataTypes = dc.ORM; - const sequelize = dc.orm; - const Project = sequelize.define("project", { - id: { - type: DataTypes.INTEGER, - allowNull: false, - defaultValue: null, - comment: null, - primaryKey: true, - field: "id", - autoIncrement: true, - unique: "project_id_uindex" - }, - img: { - type: DataTypes.ARRAY(DataTypes.STRING), - allowNull: false, - defaultValue: null, - comment: null, - primaryKey: false, - field: "img", - autoIncrement: false - }, - userId: { - type: DataTypes.INTEGER, - allowNull: false, - defaultValue: null, - comment: null, - primaryKey: false, - field: "user_id", - autoIncrement: false - }, - name: { - type: DataTypes.STRING, - allowNull: false, - defaultValue: null, - comment: null, - primaryKey: false, - field: "name", - autoIncrement: false - }, - type: { - type: DataTypes.STRING, - allowNull: true, - defaultValue: null, - comment: null, - primaryKey: false, - field: "type", - autoIncrement: false - }, - longitude: { - type: DataTypes.STRING, - allowNull: true, - defaultValue: null, - comment: null, - primaryKey: false, - field: "longitude", - autoIncrement: false - }, - latitude: { - type: DataTypes.STRING, - allowNull: true, - defaultValue: null, - comment: null, - primaryKey: false, - field: "latitude", - autoIncrement: false - }, - describe: { - type: DataTypes.STRING, - allowNull: true, - defaultValue: null, - comment: null, - primaryKey: false, - field: "describe", - autoIncrement: false - }, - qrCode: { - type: DataTypes.STRING, - allowNull: true, - defaultValue: null, - comment: null, - primaryKey: false, - field: "qr_code", - autoIncrement: false - }, - }, { - tableName: "project", - comment: "", - indexes: [] - }); - dc.models.Project = Project; - return Project; -}; \ No newline at end of file diff --git a/api/app/lib/models/resource.js b/api/app/lib/models/resource.js deleted file mode 100644 index f8ab18c..0000000 --- a/api/app/lib/models/resource.js +++ /dev/null @@ -1,44 +0,0 @@ -/* eslint-disable*/ -'use strict'; - -module.exports = dc => { - const DataTypes = dc.ORM; - const sequelize = dc.orm; - const Resource = sequelize.define("resource", { - code: { - type: DataTypes.STRING, - allowNull: false, - defaultValue: null, - comment: null, - primaryKey: true, - field: "code", - autoIncrement: false, - unique: "resource_code_uindex" - }, - name: { - type: DataTypes.STRING, - allowNull: false, - defaultValue: null, - comment: null, - primaryKey: false, - field: "name", - autoIncrement: false, - unique: "resource_name_uindex" - }, - parentResource: { - type: DataTypes.STRING, - allowNull: true, - defaultValue: null, - comment: null, - primaryKey: false, - field: "parent_resource", - autoIncrement: false - } - }, { - tableName: "resource", - comment: "", - indexes: [] - }); - dc.models.Resource = Resource; - return Resource; -}; \ No newline at end of file diff --git a/api/app/lib/models/user.js b/api/app/lib/models/user.js index 3ea7040..a3196b9 100644 --- a/api/app/lib/models/user.js +++ b/api/app/lib/models/user.js @@ -13,7 +13,7 @@ module.exports = dc => { primaryKey: true, field: "id", autoIncrement: true, - unique: "user_id_uindex" + unique: "t_user_id_uindex" }, name: { type: DataTypes.STRING, @@ -42,62 +42,8 @@ module.exports = dc => { field: "password", autoIncrement: false }, - departmentId: { - type: DataTypes.INTEGER, - allowNull: false, - defaultValue: null, - comment: "部门id", - primaryKey: false, - field: "department_id", - autoIncrement: false - }, - email: { - type: DataTypes.STRING, - allowNull: true, - defaultValue: null, - comment: null, - primaryKey: false, - field: "email", - autoIncrement: false - }, - enable: { - type: DataTypes.BOOLEAN, - allowNull: false, - defaultValue: null, - comment: "启用状态", - primaryKey: false, - field: "enable", - autoIncrement: false - }, - delete: { - type: DataTypes.BOOLEAN, - allowNull: false, - defaultValue: null, - comment: null, - primaryKey: false, - field: "delete", - autoIncrement: false - }, - phone: { - type: DataTypes.STRING, - allowNull: false, - defaultValue: null, - comment: "手机号(小程序使用手机号登录)", - primaryKey: false, - field: "phone", - autoIncrement: false - }, - post: { - type: DataTypes.STRING, - allowNull: true, - defaultValue: null, - comment: "职位", - primaryKey: false, - field: "post", - autoIncrement: false - } }, { - tableName: "user", + tableName: "t_user", comment: "", indexes: [] }); diff --git a/api/app/lib/models/user_resource.js b/api/app/lib/models/user_resource.js deleted file mode 100644 index dc8581b..0000000 --- a/api/app/lib/models/user_resource.js +++ /dev/null @@ -1,52 +0,0 @@ -/* eslint-disable*/ -'use strict'; - -module.exports = dc => { - const DataTypes = dc.ORM; - const sequelize = dc.orm; - const UserResource = sequelize.define("userResource", { - id: { - type: DataTypes.INTEGER, - allowNull: false, - defaultValue: null, - comment: null, - primaryKey: true, - field: "id", - autoIncrement: true, - unique: "post_resource_id_uindex" - }, - userId: { - type: DataTypes.INTEGER, - allowNull: false, - defaultValue: null, - comment: null, - primaryKey: false, - field: "user_id", - autoIncrement: false, - references: { - key: "id", - model: "post" - } - }, - resourceId: { - type: DataTypes.STRING, - allowNull: false, - defaultValue: null, - comment: null, - primaryKey: false, - field: "resource", - autoIncrement: false, - references: { - key: "code", - model: "resource" - } - } - }, { - tableName: "user_resource", - comment: "", - indexes: [] - }); - - dc.models.UserResource = UserResource; - return UserResource; -}; \ No newline at end of file diff --git a/api/app/lib/models/user_token.js b/api/app/lib/models/user_token.js index 3f2354e..9cd835a 100644 --- a/api/app/lib/models/user_token.js +++ b/api/app/lib/models/user_token.js @@ -13,7 +13,7 @@ module.exports = dc => { primaryKey: true, field: "token", autoIncrement: false, - unique: "user_token_token_uindex" + unique: "t_user_token_token_uindex" }, userInfo: { type: DataTypes.JSONB, @@ -34,7 +34,7 @@ module.exports = dc => { autoIncrement: false } }, { - tableName: "user_token", + tableName: "t_user_token", comment: "", indexes: [] }); diff --git a/scripts/0.1/schema/0.1user.sql b/scripts/0.1/schema/0.1user.sql new file mode 100644 index 0000000..0969ab7 --- /dev/null +++ b/scripts/0.1/schema/0.1user.sql @@ -0,0 +1,26 @@ +create table t_user +( + id serial not null + constraint t_user_pk + primary key, + name varchar(255), + username varchar(255) not null, + password varchar(255) not null +); + +comment on table t_user is '用户表'; + +comment on column t_user.id is '唯一标识'; + +comment on column t_user.name is '姓名'; + +comment on column t_user.username is '用户名'; + +comment on column t_user.password is '密码'; + + +create unique index t_user_id_uindex + on t_user (id); + + +INSERT INTO public.t_user (id, name, username, password) VALUES (DEFAULT, '超级管理员', 'SuperAdmin', 'e10adc3949ba59abbe56e057f20f883e') \ No newline at end of file diff --git a/web/client/assets/images/map.svg b/web/client/assets/images/map.svg new file mode 100644 index 0000000..03ae03a --- /dev/null +++ b/web/client/assets/images/map.svg @@ -0,0 +1,22 @@ + + + 南昌县 + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/web/client/assets/images/monitor/end.png b/web/client/assets/images/monitor/end.png new file mode 100644 index 0000000..32e9a76 Binary files /dev/null and b/web/client/assets/images/monitor/end.png differ diff --git a/web/client/assets/images/monitor/lower-left.png b/web/client/assets/images/monitor/lower-left.png new file mode 100644 index 0000000..75e3866 Binary files /dev/null and b/web/client/assets/images/monitor/lower-left.png differ diff --git a/web/client/assets/images/monitor/lower-right.png b/web/client/assets/images/monitor/lower-right.png new file mode 100644 index 0000000..323a78c Binary files /dev/null and b/web/client/assets/images/monitor/lower-right.png differ diff --git a/web/client/assets/images/monitor/point.png b/web/client/assets/images/monitor/point.png new file mode 100644 index 0000000..5359019 Binary files /dev/null and b/web/client/assets/images/monitor/point.png differ diff --git a/web/client/assets/images/monitor/pump-p.png b/web/client/assets/images/monitor/pump-p.png new file mode 100644 index 0000000..dea7a1c Binary files /dev/null and b/web/client/assets/images/monitor/pump-p.png differ diff --git a/web/client/assets/images/monitor/pumpPP.png b/web/client/assets/images/monitor/pumpPP.png new file mode 100644 index 0000000..c9727d2 Binary files /dev/null and b/web/client/assets/images/monitor/pumpPP.png differ diff --git a/web/client/assets/images/monitor/pumpPo.png b/web/client/assets/images/monitor/pumpPo.png new file mode 100644 index 0000000..ae56cf8 Binary files /dev/null and b/web/client/assets/images/monitor/pumpPo.png differ diff --git a/web/client/assets/images/number/good1.png b/web/client/assets/images/number/good1.png new file mode 100644 index 0000000..4191798 Binary files /dev/null and b/web/client/assets/images/number/good1.png differ diff --git a/web/client/assets/images/number/good10.png b/web/client/assets/images/number/good10.png new file mode 100644 index 0000000..bd930e7 Binary files /dev/null and b/web/client/assets/images/number/good10.png differ diff --git a/web/client/assets/images/number/good11.png b/web/client/assets/images/number/good11.png new file mode 100644 index 0000000..b37e6b3 Binary files /dev/null and b/web/client/assets/images/number/good11.png differ diff --git a/web/client/assets/images/number/good12.png b/web/client/assets/images/number/good12.png new file mode 100644 index 0000000..87722ee Binary files /dev/null and b/web/client/assets/images/number/good12.png differ diff --git a/web/client/assets/images/number/good2.png b/web/client/assets/images/number/good2.png new file mode 100644 index 0000000..8a8d049 Binary files /dev/null and b/web/client/assets/images/number/good2.png differ diff --git a/web/client/assets/images/number/good3.png b/web/client/assets/images/number/good3.png new file mode 100644 index 0000000..7aaa37c Binary files /dev/null and b/web/client/assets/images/number/good3.png differ diff --git a/web/client/assets/images/number/good4.png b/web/client/assets/images/number/good4.png new file mode 100644 index 0000000..1fac22f Binary files /dev/null and b/web/client/assets/images/number/good4.png differ diff --git a/web/client/assets/images/number/good5.png b/web/client/assets/images/number/good5.png new file mode 100644 index 0000000..882c39b Binary files /dev/null and b/web/client/assets/images/number/good5.png differ diff --git a/web/client/assets/images/number/good6.png b/web/client/assets/images/number/good6.png new file mode 100644 index 0000000..2f68253 Binary files /dev/null and b/web/client/assets/images/number/good6.png differ diff --git a/web/client/assets/images/number/good7.png b/web/client/assets/images/number/good7.png new file mode 100644 index 0000000..492db45 Binary files /dev/null and b/web/client/assets/images/number/good7.png differ diff --git a/web/client/assets/images/number/good8.png b/web/client/assets/images/number/good8.png new file mode 100644 index 0000000..6c68beb Binary files /dev/null and b/web/client/assets/images/number/good8.png differ diff --git a/web/client/assets/images/number/good9.png b/web/client/assets/images/number/good9.png new file mode 100644 index 0000000..6e0fc66 Binary files /dev/null and b/web/client/assets/images/number/good9.png differ diff --git a/web/client/assets/images/number/problem1.png b/web/client/assets/images/number/problem1.png new file mode 100644 index 0000000..a2beb61 Binary files /dev/null and b/web/client/assets/images/number/problem1.png differ diff --git a/web/client/assets/images/number/problem10.png b/web/client/assets/images/number/problem10.png new file mode 100644 index 0000000..b6f1934 Binary files /dev/null and b/web/client/assets/images/number/problem10.png differ diff --git a/web/client/assets/images/number/problem11.png b/web/client/assets/images/number/problem11.png new file mode 100644 index 0000000..61d5589 Binary files /dev/null and b/web/client/assets/images/number/problem11.png differ diff --git a/web/client/assets/images/number/problem12.png b/web/client/assets/images/number/problem12.png new file mode 100644 index 0000000..2d1c811 Binary files /dev/null and b/web/client/assets/images/number/problem12.png differ diff --git a/web/client/assets/images/number/problem2.png b/web/client/assets/images/number/problem2.png new file mode 100644 index 0000000..7ac2bc8 Binary files /dev/null and b/web/client/assets/images/number/problem2.png differ diff --git a/web/client/assets/images/number/problem3.png b/web/client/assets/images/number/problem3.png new file mode 100644 index 0000000..59c86d8 Binary files /dev/null and b/web/client/assets/images/number/problem3.png differ diff --git a/web/client/assets/images/number/problem4.png b/web/client/assets/images/number/problem4.png new file mode 100644 index 0000000..00d7a7f Binary files /dev/null and b/web/client/assets/images/number/problem4.png differ diff --git a/web/client/assets/images/number/problem5.png b/web/client/assets/images/number/problem5.png new file mode 100644 index 0000000..4f14967 Binary files /dev/null and b/web/client/assets/images/number/problem5.png differ diff --git a/web/client/assets/images/number/problem6.png b/web/client/assets/images/number/problem6.png new file mode 100644 index 0000000..8880b6c Binary files /dev/null and b/web/client/assets/images/number/problem6.png differ diff --git a/web/client/assets/images/number/problem7.png b/web/client/assets/images/number/problem7.png new file mode 100644 index 0000000..1d12ee9 Binary files /dev/null and b/web/client/assets/images/number/problem7.png differ diff --git a/web/client/assets/images/number/problem8.png b/web/client/assets/images/number/problem8.png new file mode 100644 index 0000000..117c457 Binary files /dev/null and b/web/client/assets/images/number/problem8.png differ diff --git a/web/client/assets/images/number/problem9.png b/web/client/assets/images/number/problem9.png new file mode 100644 index 0000000..6fce066 Binary files /dev/null and b/web/client/assets/images/number/problem9.png differ diff --git a/web/client/index.html b/web/client/index.html index 8edf655..fdf026a 100644 --- a/web/client/index.html +++ b/web/client/index.html @@ -12,7 +12,7 @@ } + src="https://webapi.amap.com/maps?v=2.0&key=00f9a29dedcdbd8befec3dfe0cef5003&plugin=AMap.AutoComplete,AMap.PlaceSearch,aMap.DistrictSearch"> diff --git a/web/client/src/layout/containers/layout/index.js b/web/client/src/layout/containers/layout/index.js index 34f3d57..b04d7aa 100644 --- a/web/client/src/layout/containers/layout/index.js +++ b/web/client/src/layout/containers/layout/index.js @@ -34,7 +34,7 @@ const LayoutContainer = props => { const resize_ = (collapsed) => { const extraHeight = headerHeight + footerHeight; - console.log(document.body.clientHeight); + dispatch(resize( document.body.clientHeight - extraHeight - 12, document.body.clientWidth - (collapsed ? 120 : 220) diff --git a/web/client/src/layout/containers/layout/index.less b/web/client/src/layout/containers/layout/index.less index d55219a..ce3bc72 100644 --- a/web/client/src/layout/containers/layout/index.less +++ b/web/client/src/layout/containers/layout/index.less @@ -1,2 +1,3 @@ @import '~perfect-scrollbar/css/perfect-scrollbar.css'; -@import '~nprogress/nprogress.css'; \ No newline at end of file +@import '~nprogress/nprogress.css'; +@import '~simplebar-react/dist/simplebar.min.css'; \ No newline at end of file diff --git a/web/client/src/sections/auth/containers/login.js b/web/client/src/sections/auth/containers/login.js index 708058f..63b673b 100644 --- a/web/client/src/sections/auth/containers/login.js +++ b/web/client/src/sections/auth/containers/login.js @@ -157,7 +157,6 @@ const Login = props => { function mapStateToProps (state) { const { auth, global } = state; - console.log(global); return { user: auth.user, error: auth.error, diff --git a/web/client/src/sections/bigScreen/components/amap.js b/web/client/src/sections/bigScreen/components/amap.js index 24f5a60..240485d 100644 --- a/web/client/src/sections/bigScreen/components/amap.js +++ b/web/client/src/sections/bigScreen/components/amap.js @@ -1,48 +1,114 @@ import React, { useEffect, useState } from 'react'; let map = ''; -const Amap = (props) => { - const [mapComplete, setMapComplete] = useState(false); - - useEffect(() => { - drawMap(); - }, []); - const drawMap = () => { - try { - if (AMap) loadMap(); - } catch (e) { - var script = document.createElement("script"); - script.src = "https://webapi.amap.com/maps?v=2.0&key=00f9a29dedcdbd8befec3dfe0cef5003&plugin=AMap.AutoComplete,AMap.PlaceSearch"; - document.body.appendChild(script); - loadMap(); - } - } - - const loadMap = () => { - map = new AMap.Map("amapId", { - resizeEnable: true, - center: [115.99255, 28.503617], // 地图中心点,初始定位加载显示楼块 - zoom: 14, // 地图显示的缩放级别 - zooms: [5, 20], - pitch: 0, // 地图俯仰角度,有效范围 0 度- 83 度 - viewMode: '3D', // 地图模式 - mapStyle: 'amap://styles/fb26776387242721c2fc32e2cb1daccc', // 主题样式 - // rotation: 60 - // showLabel: false - }); - - map.on('complete', function () { - console.log("map-complete") - setMapComplete(true); - }); - window.onload = function () { - console.log("window.onload") - } - }; - - return
-
-
+const Amap = ({ showData }) => { + const [mapComplete, setMapComplete] = useState(false); + + useEffect(() => { + drawMap(); + }, []); + + useEffect(() => { + if (AMap && showData?.length) { + renderMarkers(showData) + } + }, [showData, AMap]); + + const drawMap = () => { + try { + if (AMap) loadMap(); + } catch (e) { + var script = document.createElement("script"); + script.src = "https://webapi.amap.com/maps?v=2.0&key=00f9a29dedcdbd8befec3dfe0cef5003&plugin=AMap.AutoComplete,AMap.PlaceSearch,AMap.Marker"; + document.body.appendChild(script); + loadMap(); + } + } + + const loadMap = () => { + // 图片图层 实现瓦片地图中国地图样式 bounds 第一个点为左下角 第二个点为右上角 + const imageLayer = new AMap.ImageLayer({ + url: '/assets/images/map.svg', + bounds: new AMap.Bounds( + [115.800221, 28.265659], + [116.334849, 28.973298], + ), + zooms: [3, 14], + }); + + map = new AMap.Map("amapId", { + resizeEnable: true, + center: [115.99255, 28.503617], // 地图中心点,初始定位加载显示楼块 + zoom: 10.3, // 地图显示的缩放级别 + zooms: [5, 20], + pitch: 0, // 地图俯仰角度,有效范围 0 度- 83 度 + viewMode: '3D', // 地图模式 + mapStyle: 'amap://styles/fb26776387242721c2fc32e2cb1daccc', // 主题样式 + // rotation: 60 + // showLabel: false + layers: [ + AMap.createDefaultLayer(), + imageLayer, + ], + }); + + + + + + map.on('complete', function () { + console.log("map-complete") + setMapComplete(true); + }); + window.onload = function () { + console.log("window.onload") + } + + + }; + + const renderMarkers = (data) => { + + + + // 初始层级 zoom14以下显示聚合点 + // const data = [ + // { lng: 116.117906, lat: 28.678096, name: 'ndjsa d dwqa', }, + + // ] + + + if (data?.length > 0) { + // map.clearMap(); + map.setZoom(10.3) + map.setCenter([116.054664, 28.538966]) + map.setPitch(22.9) + map.setRotation(1.7000) + data?.map((x, index) => { + let marker = new AMap.Marker({ + position: new AMap.LngLat(x.lng, x.lat), + // 将一张图片的地址设置为 icon + icon: '/assets/images/monitor/point.png', + // 设置了 icon 以后,设置 icon 的偏移量,以 icon 的 [center bottom] 为原点 + offset: new AMap.Pixel(-13, -30), + zooms: [5, 20], + title: x.name, + content: `
+ +
${x.name}
+
` + }); + map.add(marker); + }) + } + + } + + return
+
+
} export default Amap; \ No newline at end of file diff --git a/web/client/src/sections/bigScreen/components/basis.js b/web/client/src/sections/bigScreen/components/basis.js index 71971b3..93a28da 100644 --- a/web/client/src/sections/bigScreen/components/basis.js +++ b/web/client/src/sections/bigScreen/components/basis.js @@ -1,47 +1,232 @@ -import React, { useEffect, useState } from 'react'; +import React, { useEffect, useState, useRef } from 'react'; import { connect } from 'react-redux'; import { Spin, Card, Modal, TreeSelect, message } from 'antd'; import ProForm, { ProFormText, ModalForm, ProFormSwitch, ProFormTreeSelect } from '@ant-design/pro-form'; +import moment from 'moment' +import CardTitle from './public/cardTitle' +import SimpleBar from 'simplebar-react'; import Left_1 from './basis/left_1'; -import Left_2 from './basis/left_2'; import Right_1 from './basis/right_1'; import Right_2 from './basis/right_2'; +import { POWER_STATIONS } from './shuizhan_detail'; import './basis.less' -const Basis = ({ user, module, setModule }) => { +const Basis = ({ actions, dispatch, user, setshowData }) => { - useEffect(() => { + const { bigScreen } = actions + const [siteList, setSiteList] = useState([]) //站点列表 + const [strucId, setStrucId] = useState() //站点ID + const [pageRefresh1, setPageRefresh1] = useState(false) + const [pageRefresh2, setPageRefresh2] = useState(false) + const [pageRefresh3, setPageRefresh3] = useState(false) + const [left2List, setleft2List] = useState([]) + const [depthWater, setDepthWater] = useState([]) + const [information, setInformation] = useState({}) + + const left1Data = useRef([]) + const left2Data = useRef([]) + const pumpNumber = useRef(0) + + useEffect(async () => { + await dispatch(bigScreen.axyData({ type: 'get', url: `organizations/{orgId}/structures` })).then(async res => { + if (res.success) { + setSiteList(res.payload.data?.map(v => ({ value: v.id, label: v.name, latitude: v.latitude, longitude: v.longitude })) || []) + setshowData(res.payload.data?.map(v => ({ name: v.name, lat: v.latitude, lng: v.longitude })) || []) + setStrucId(res.payload.data[0]?.id) + for (let key in POWER_STATIONS) { + if (POWER_STATIONS[key]?.name == res.payload.data[0]?.name) { + setInformation(POWER_STATIONS[key]) + } + } + //获取所有泵站的集水池液位 + res.payload.data?.map(async v => { + await dispatch(bigScreen.axyData({ type: 'get', url: `structures/${v.id}/factors` })).then(async r => { + //泵站信息 + let informationId = r.payload.data?.find(v => v.name == '泵站信息')?.id + if (informationId) { + await dispatch(bigScreen.axyData({ + type: 'get', url: `structures/${v.id}/stations`, + params: { query: { factorId: informationId } } + })).then(async p => { + if (p.success) { + await dispatch(bigScreen.axyData({ + type: 'get', url: `stations/theme/data`, params: { + query: { + stations: p.payload.data[0]?.groups[0]?.stations[0]?.id, + startTime: moment().startOf('day').format('YYYY-MM-DD HH:mm:ss'), + endTime: moment().endOf('day').format('YYYY-MM-DD HH:mm:ss'), + limit: 1 + } + } + })).then(async d => { + if (d.success) { + left1Data.current?.push({ name: v.name, level: d.payload.data?.stations[0]?.data[0]?.sLiquid_level || 0 }) + setPageRefresh1(!pageRefresh1) + } + }) + } + + }) + } + + //水泵信息 + let waterId = r.payload.data?.find(v => v.name == '泵站水泵')?.id + if (waterId) { + await dispatch(bigScreen.axyData({ + type: 'get', url: `structures/${v.id}/stations`, + params: { query: { factorId: waterId } } + })).then(async p => { + if (p.success) { + pumpNumber.current += p.payload.data[0]?.groups[0]?.stations.length || 0 + setPageRefresh3(!pageRefresh3) + let dataId = [] + p.payload.data?.map(v => { + v.groups?.map(s => { + s.stations?.map(f => { + dataId.push(f.id) + }) + }) + }) + if (dataId.length) { + // 当前时间 + await dispatch(bigScreen.axyData({ + type: 'get', url: `stations/theme/data`, params: { + query: { + stations: dataId.join(), + startTime: moment().startOf('day').format('YYYY:MM:DD HH:mm:ss'), + endTime: moment().endOf('day').format('YYYY:MM:DD HH:mm:ss'), + limit: 1 + } + } + })).then(d => { + if (d.success) { + left2Data.current?.push({ name: v.name, data: d.payload.data?.stations }) + setPageRefresh2(!pageRefresh2) + } + }) + } + } + }) + } + }) + }) + } + }) }, []) - const left1Data = [ - { name: '雄溪站站站站', level: 3 }, - { name: '雄溪站', level: 3 }, - { name: '雄溪站', level: 3 }, - { name: '雄溪站', level: 3 }, - { name: '雄溪站', level: 3 }, - { name: '雄溪站', level: 3 }, - { name: '雄溪站', level: 3 }, - { name: '雄溪站', level: 3 }, - { name: '雄溪站', level: 3 }, - { name: '雄溪站', level: 3 }, - ] + + useEffect(async () => { + if (strucId) { + await dispatch(bigScreen.axyData({ type: 'get', url: `structures/${strucId}/factors` })).then(async r => { + //泵站信息 + let informationId = r.payload.data?.find(v => v.name == '泵站信息')?.id + if (informationId) { + await dispatch(bigScreen.axyData({ + type: 'get', url: `structures/${strucId}/stations`, + params: { query: { factorId: informationId } } + })).then(async p => { + if (p.success) { + await dispatch(bigScreen.axyData({ + type: 'get', url: `stations/theme/data`, params: { + query: { + stations: p.payload.data[0]?.groups[0]?.stations[0]?.id, + startTime: moment().add(-24, 'hours').format('YYYY-MM-DD HH:mm:ss'), + endTime: moment().format('YYYY-MM-DD HH:mm:ss'), + limit: 1440 + } + } + })).then(async d => { + if (d.success) { + setDepthWater(d.payload.data?.stations[0]?.data) + } + }) + } + + }) + } + }) + } + + + }, [strucId]) + + return
- - -
+ +
+ +
+
+
地点
+
编号
+
+ + {left2Data.current.map(v =>
+
{v.name}
+
+ {v.data?.map((s, i) => ) + + } + +
+ + +
)} +
+ + + +
+ +
+ +
- - + + +
+
+
+ + 泵站数量:{siteList?.length || 0} +
+
+ + 提升泵数量:{pumpNumber.current} +
} -function mapStateToProps(state) { +function mapStateToProps (state) { const { auth, global } = state; return { user: auth.user, clientHeight: global.clientHeight, + actions: global.actions, }; } diff --git a/web/client/src/sections/bigScreen/components/basis.less b/web/client/src/sections/bigScreen/components/basis.less index fdb330f..b70b22b 100644 --- a/web/client/src/sections/bigScreen/components/basis.less +++ b/web/client/src/sections/bigScreen/components/basis.less @@ -6,7 +6,7 @@ .super-screen-card { position: absolute; top: 100px; - width: 23%; + width: 26%; height: calc(100% - 100px); z-index: 7; color: #fff; diff --git a/web/client/src/sections/bigScreen/components/basis/left_1.js b/web/client/src/sections/bigScreen/components/basis/left_1.js index c980b4c..49eb681 100644 --- a/web/client/src/sections/bigScreen/components/basis/left_1.js +++ b/web/client/src/sections/bigScreen/components/basis/left_1.js @@ -3,20 +3,25 @@ import CardTitle from '../public/cardTitle'; import '../basis.less'; import './left_1.less'; -export default function Left_1(props) { - const { data } = props; - return ( -
- -
- {data?.map(d =>
- -
-
{d.name}
-
{d.level} m
-
-
)} + +export default function Left_1 (props) { + const { data } = props; + + return ( +
+ +
+ {data?.map(d =>
+
+ +
+
{d.name}
+
{d.level?.toFixed(2) || 0} m
+
+
+
)} + +
-
- ) + ) } diff --git a/web/client/src/sections/bigScreen/components/basis/left_1.less b/web/client/src/sections/bigScreen/components/basis/left_1.less index cb505b3..f1f6e43 100644 --- a/web/client/src/sections/bigScreen/components/basis/left_1.less +++ b/web/client/src/sections/bigScreen/components/basis/left_1.less @@ -1,47 +1,54 @@ .liquid-level-content { - display: flex; - flex-wrap: wrap; - justify-content: flex-start; - overflow-y: auto; - - .liquid-level { - width: 46%; - display: flex; - justify-content: space-evenly; - align-items: center; - - .img { - width: 84px; - height: 76px; - } + display: inline-block; + overflow-y: auto; - .info { - width: 101px; - height: 80%; - display: flex; - flex-direction: column; - justify-content: flex-end; - align-items: center; - font-size: 1rem; - text-align: center; - font-family: D-DIN-Italic; + .liquid-level { + width: 100%; + height: 80px; + display: flex; + align-items: center; + .img { + width: 84px; + height: 76px; + } - .name { - background-image: url(/assets/images/monitor/gradation-bg.svg); - width: 100%; - } + .info { + width: 100px; + height: 80%; + display: flex; + flex-direction: column; + align-items: center; + font-size: 1rem; + text-align: center; + font-family: D-DIN-Italic; + justify-content: space-around; + .name { + background-image: url(/assets/images/monitor/gradation-bg.svg); + width: 100%; + overflow: hidden; + white-space: nowrap; + text-overflow: ellipsis; + } - .level { - background-image: linear-gradient(90deg, #24396e00 2%, #24396e70 51%, #24396e00 100%); - width: 100%; - margin-top: 5px; + .level { + background-image: linear-gradient( + 90deg, + #24396e00 2%, + #24396e70 51%, + #24396e00 100% + ); + width: 100%; + margin-top: 5px; + overflow: hidden; + white-space: nowrap; + text-overflow: ellipsis; - .num { - font-size: 1.25rem; - line-height: 1.25rem; - letter-spacing: 2.08px; - } - } + .num { + font-size: 1.25rem; + line-height: 1.25rem; + letter-spacing: 2.08px; } + } } -} \ No newline at end of file + } +} diff --git a/web/client/src/sections/bigScreen/components/basis/left_2.js b/web/client/src/sections/bigScreen/components/basis/left_2.js deleted file mode 100644 index b0caae0..0000000 --- a/web/client/src/sections/bigScreen/components/basis/left_2.js +++ /dev/null @@ -1,13 +0,0 @@ -import React from 'react'; -import CardTitle from '../public/cardTitle'; -import '../basis.less'; - -export default function Left_2(props) { - return ( -
- -
- -
- ) -} diff --git a/web/client/src/sections/bigScreen/components/basis/right_1.js b/web/client/src/sections/bigScreen/components/basis/right_1.js index 21299aa..3e2d114 100644 --- a/web/client/src/sections/bigScreen/components/basis/right_1.js +++ b/web/client/src/sections/bigScreen/components/basis/right_1.js @@ -4,97 +4,98 @@ import { Select } from 'antd'; import '../basis.less'; import './right_1.less'; -export default function Right_1(props) { - const renderSelect = () => { - return + } + + return ( +
+ +
+
+ +
+
+
+
{data?.water_type}
+
水泵型号
+
+
+
+
+
电动机型号:
+
{data?.elc_type}
+
+
+
+
+
+
变压器型号:
+
{data?.by_type}
+
+
+
+
-
-
-
所属区域:
-
{'象湖站'}
+
+
+
+
类型:
+
{data?.func}
+
+
+
+
泵站规模:
+
{data?.power} (kw)
+
+
+
+
+
机组数量:
+
{data?.num} 台
+
+
+
+
泵站建成时间:
+
{data?.year?.split(',')[0]}
+
+
+
+
+
泵站除险加固时间:
+
{data?.year?.split(',')[1]}
+
+
+
+
所属区域:
+
{data?.area}
+
+
-
-
+
-
- ) + ) } diff --git a/web/client/src/sections/bigScreen/components/basis/right_1.less b/web/client/src/sections/bigScreen/components/basis/right_1.less index 078d8d8..31c581f 100644 --- a/web/client/src/sections/bigScreen/components/basis/right_1.less +++ b/web/client/src/sections/bigScreen/components/basis/right_1.less @@ -23,6 +23,7 @@ justify-content: space-evenly; .detail-item { + width: 100%; height: 32%; .item { @@ -37,14 +38,14 @@ font-family: SourceHanSansCN-Regular; font-weight: 400; font-size: 14px; - color: #C3E6FF; + color: #c3e6ff; } .value { font-family: D-DIN; font-weight: DIN; font-size: 16px; - color: #FFFFFF; + color: #ffffff; } } @@ -54,21 +55,27 @@ } .pump-models { + width: 100%; background-image: url(/assets/images/monitor/pump-models-bg.svg); background-size: cover; .pump-models-value { + width: calc(100% - 60px); font-family: YouSheBiaoTiHei; font-size: 20px; - color: #FFFFFF; + color: #ffffff; letter-spacing: 0; + overflow: hidden; + white-space: nowrap; + text-overflow: ellipsis; } .pump-models-key { + width: 58px; font-family: SourceHanSansCN-Medium; font-weight: 500; font-size: 12px; - color: #C3E6FF; + color: #c3e6ff; letter-spacing: 0; display: flex; align-items: flex-end; @@ -104,13 +111,13 @@ font-family: SourceHanSansCN-Medium; font-weight: 500; font-size: 13px; - color: #63B0FF; + color: #63b0ff; } .value { font-family: YouSheBiaoTiHei; font-size: 16px; - color: #FFFFFF; + color: #ffffff; } } @@ -118,8 +125,8 @@ width: 2px; height: 19px; opacity: 0.45; - background-color: #5F82DC; + background-color: #5f82dc; } } } -} \ No newline at end of file +} diff --git a/web/client/src/sections/bigScreen/components/basis/right_2.js b/web/client/src/sections/bigScreen/components/basis/right_2.js index ec396e4..564258f 100644 --- a/web/client/src/sections/bigScreen/components/basis/right_2.js +++ b/web/client/src/sections/bigScreen/components/basis/right_2.js @@ -1,14 +1,92 @@ import React from 'react'; import CardTitle from '../public/cardTitle'; import '../basis.less'; +import ReactECharts from 'echarts-for-react'; +import moment from 'moment' -export default function Right_2(props) { - return ( -
- -
+export default function Right_2 ({ depthWater }) { + return ( +
+ +
+
+
+ v.time) + }, + { + type: 'inside', + }, + ], + tooltip: { + trigger: 'axis' + }, + legend: { + data: ['集水池液位', '池前(上游)液位'], + right: '10%', + textStyle: { + color: '#FFF', + }, + }, + xAxis: { + type: 'category', + name: "时间", + boundaryGap: false, + data: depthWater?.map(v => moment(v.time).format('MM-DD HH:mm')) + }, + yAxis: { + type: 'value', + name: "单位:M", + areaStyle: { + color: '#FFF', + }, + }, + series: [ + { + type: 'line', + name: '集水池液位', + smooth: true, + areaStyle: { + color: '#0e9cff26', + }, + data: depthWater?.map(v => v.sLiquid_level) + }, + { + type: 'line', + name: '池前(上游)液位', + smooth: true, + areaStyle: { + color: '#0e9cff26', + }, + data: depthWater?.map(v => v.sGrille_level) + }, + + ] + }} + notMerge={true} + lazyUpdate={true} + theme={'ReactEChart'} + // onChartReady={this.onChartReadyCallback} + // onEvents={EventsDict} + // opts={} + /> + + +
-
- ) + ) } diff --git a/web/client/src/sections/bigScreen/components/capacity.js b/web/client/src/sections/bigScreen/components/capacity.js index 6c6655c..df39412 100644 --- a/web/client/src/sections/bigScreen/components/capacity.js +++ b/web/client/src/sections/bigScreen/components/capacity.js @@ -18,7 +18,6 @@ const Capacity = ({ actions, dispatch, user, }) => { useEffect(() => { dispatch(bigScreen.axyData({ type: 'get', url: `organizations/{orgId}/structures` })).then(res => { - // console.log(res); if (res.success) { setSiteList(res.payload.data?.map(v => ({ value: v.id, label: v.name })) || []) setStrucId(res.payload.data[0]?.id) @@ -123,7 +122,6 @@ const Capacity = ({ actions, dispatch, user, }) => { let find2 = month?.find(c => c.id == u.id) let find3 = year?.find(c => c.id == u.id) - // console.log(find1); pumpSun.push({ today: u?.data[0]?.eMotor_EQ && find1?.data[0]?.eMotor_EQ ? (u?.data[0]?.eMotor_EQ - find1?.data[0]?.eMotor_EQ) : '--', sameMonth: u?.data[0]?.eMotor_EQ && find2?.data[0]?.eMotor_EQ ? (u?.data[0]?.eMotor_EQ - find2?.data[0]?.eMotor_EQ) : '--', @@ -227,7 +225,7 @@ const Capacity = ({ actions, dispatch, user, }) => { let find2 = month?.find(c => c.id == u.id) let find3 = year?.find(c => c.id == u.id) - // console.log(find1); + cabinetSun.push({ today: u?.data[0]?.eQF_EQ && find1?.data[0]?.eQF_EQ ? (u?.data[0]?.eQF_EQ - find1?.data[0]?.eQF_EQ) : '--', sameMonth: u?.data[0]?.eQF_EQ && find2?.data[0]?.eQF_EQ ? (u?.data[0]?.eQF_EQ - find2?.data[0]?.eQF_EQ) : '--', @@ -284,21 +282,6 @@ const Capacity = ({ actions, dispatch, user, }) => { }) } - await dispatch(bigScreen.axyData({ - type: 'get', url: `stations/theme/data`, params: { - query: { - stations: 56643, - startTime: moment().startOf('day').format('YYYY-MM-DD HH:mm:ss'), - endTime: moment().endOf('day').format('YYYY-MM-DD HH:mm:ss'), - limit: 1 - } - } - })).then(d => { - if (d.success) { - - - } - }) setPumpData(pump) setCabinetData(cabinetSun) @@ -358,7 +341,7 @@ const Capacity = ({ actions, dispatch, user, }) => {
{[1, 3, 5].includes(v.data[0]?.sMotor_RunMode) ? '启动' : [2, 4, 7].includes(v.data[0]?.sMotor_RunMode) ? '停止' : v.data[0]?.sMotor_RunMode == 7 ? '故障' : '无状态'}
+ }}>{[1, 3, 5].includes(v.data[0]?.sMotor_RunMode) ? '停止' : [2, 4, 6].includes(v.data[0]?.sMotor_RunMode) ? '运行' : v.data[0]?.sMotor_RunMode == 7 ? '故障' : '无状态'}
diff --git a/web/client/src/sections/bigScreen/components/shuizhan_detail.js b/web/client/src/sections/bigScreen/components/shuizhan_detail.js new file mode 100644 index 0000000..828967b --- /dev/null +++ b/web/client/src/sections/bigScreen/components/shuizhan_detail.js @@ -0,0 +1,28 @@ +const POWER_STATIONS = { + '象湖站': { area: '象湖站', name: '象湖电排站', func: '排涝', power: 1050, num: 5, elc_type: 'JsL10—12(210KW)', water_type: '1200ZLB—160轴流泵', by_type: 's9—M500KVA、s9—M800KVA', year: ' 2008年, 空', rightTo: '县城管局', managerUnit: '南昌县象湖联圩管理站', managers: '胡铁根、陈江、陈亮', costFrom: '南昌县象湖联圩管理站', remark: '空' }, + '沥山站': { area: '象湖站', name: '沥山电排站', func: '排涝', power: 1680, num: 8, elc_type: 'JsL10—12(210KW)', water_type: '1200ZLB—160轴流泵', by_type: 's9—M1000KVA/2', year: ' 2004年, 空', rightTo: '县城管局', managerUnit: '南昌县象湖联圩管理站', managers: '宗磊、李文章、熊大方', costFrom: '南昌县象湖联圩管理站', remark: '空' }, + '雄溪站': { area: '象湖站', name: '雄溪电排站', func: '排涝', power: 630, num: 3, elc_type: 'JsL10—12(210KW)', water_type: '1200ZLB—160轴流泵', by_type: 's9—M315KVA、s9—M500KVA', year: ' 2004年, 空', rightTo: '县城管局', managerUnit: '南昌县象湖联圩管理站', managers: '涂三毛、刘文红彭伟红、童珊玲、李跃兰(县聘泵站值守人员)', costFrom: '南昌县象湖联圩管理站', remark: '空' }, + '张坊站': { area: '象湖站', name: '张坊电排站', func: '排涝', power: 2500, num: 5, elc_type: 'YL630-16/1430(500KW)', water_type: '1400ZLB-5立式半调节轴流泵', by_type: 'SCB11-160/10/0.4', year: ' 2020年, 空', rightTo: '县城管局', managerUnit: '还未明确管理单位,由水利局代管', managers: '康玉明、赵先福、殷长和、肖玉平', costFrom: '水利局垫付', remark: '工资发放至2021年12月止' }, + '万寿湖站': { area: '象湖站', name: '万寿湖电排站', func: '排涝', power: 660, num: 3, elc_type: 'JsL14—12(220KW)', water_type: '1000ZLB-5立式半调节轴流泵', by_type: 'SCB11-1000/10/0.4、SCB11-80/10/0.4', year: ' 2020年, 空', rightTo: '县城管局', managerUnit: '还未明确管理单位,由水利局代管', managers: '夏小生、王刚', costFrom: '水利局垫付', remark: '工资发放至2021年12月止' }, + '八月湖站': { area: '东新乡', name: '八月湖一站', func: '排灌结合', power: 840, num: 4, elc_type: 'JSL12—14', water_type: '1000ZLB—4轴流泵', by_type: 'S91000KVA', year: ' 1974年, 2009年', rightTo: '县城管局', managerUnit: '东新乡', managers: '邓重志、熊春华、邓仁凯、邓小玉、邓必华', costFrom: '由排灌站直接在乡财务办理缴费', remark: '空' }, + '新八月湖站': { area: '东新乡', name: '八月湖二站', func: '纯排', power: 1050, num: 5, elc_type: 'JSL12—14', water_type: '1000ZLB—4轴流泵', by_type: 'S9800KVA2', year: ' 1985.4年, 2009年', rightTo: '县城管局', managerUnit: '东新乡', managers: '邓重志、熊春华、邓仁凯、邓小玉、邓必华', costFrom: '由排灌站直接在乡财务办理缴费', remark: '空' }, + '河下站': { area: '东新乡', name: '河下电排站', func: '排灌结合', power: 320, num: 4, elc_type: 'Y—200T—4', water_type: 'ZLB28—70轴流泵', by_type: 'S9315KVA', year: ' 1972年, 1987年', rightTo: '县城管局', managerUnit: '河下村', managers: '万增福', costFrom: '由河下村排灌站直接缴费', remark: '空' }, + '石岐站': { area: '东新乡', name: '石岐电排站', func: '排灌结合', power: 340, num: 3, elc_type: 'Y—200T—4', water_type: 'ZLB28—70轴流泵', by_type: 'S9315KVA', year: ' 1974年, 1988年', rightTo: '县城管局', managerUnit: '石岐村', managers: '万象保', costFrom: '由石岐村排灌站直接缴费', remark: '空' }, + '东新乡': { area: '东新乡', name: '利用姚家塘电排站', func: '排灌结合', power: 240, num: 3, elc_type: 'Y—200T—4', water_type: 'ZLB28—70轴流泵', by_type: 'S9315KVA', year: ' 1974年, 1992年', rightTo: '县城管局', managerUnit: '利用村', managers: '蒋淑仁', costFrom: '由利用村排灌站直接缴费', remark: '空' }, + '东新乡': { area: '东新乡', name: '汇仁大道排水泵站', func: '纯排', power: 260, num: 2, elc_type: 'Y67—130kw', water_type: '20ZLB—70轴流泵', by_type: '315KVA箱式变压器', year: ' 2014年, 空', rightTo: '县城管局', managerUnit: '东新乡', managers: '蒋国冬', costFrom: '由乡水管站直接垂管缴费', remark: '空' }, + '东新乡': { area: '东新乡', name: '小洲杨家湾电排站', func: '纯排', power: 60, num: 2, elc_type: 'Y—200T—4', water_type: 'ZLB28—70轴流泵', by_type: '80KVA箱式变压器', year: ' 2013年, 空', rightTo: '县城管局', managerUnit: '东新乡', managers: '胡又莲', costFrom: '由乡水管站直接垂管缴费', remark: '空' }, + '东新乡': { area: '东新乡', name: '石岐补水站', func: '灌溉', power: 260, num: 2, elc_type: 'Y67—130kw', water_type: '20ZLB—70轴流泵', by_type: 'S9_315KVA变压器', year: ' 2014年, 空', rightTo: '县城管局', managerUnit: '东新乡', managers: '万和全', costFrom: '由乡水管站直接垂管缴费', remark: '空' }, + '象湖一号闸': { area: '东新乡', name: '象湖南电排站', func: '纯排', power: 60, num: 2, elc_type: 'Y—200T—4', water_type: 'ZLB28—70轴流泵', by_type: '80KVA箱式变压器', year: ' 2013年, 空', rightTo: '县城管局', managerUnit: '东新乡', managers: '陶小弟', costFrom: '由乡水管站直接垂管缴费', remark: '空' }, + '东新乡': { area: '东新乡', name: '东莲路节制闸', func: '排涝', power: '空', num: '空', elc_type: '空', water_type: '空', by_type: '空', year: ' 2009年, 空', rightTo: '县城管局', managerUnit: '东新乡', managers: '蒋永新', costFrom: '由乡水管站直接垂管缴费', remark: '调节东莲路景观明渠水位' }, + '三山站': { area: '富山乡', name: '三山电排站', func: '排涝', power: 390, num: 3, elc_type: '空', water_type: '空', by_type: '空', year: ' 1973年, 2008年', rightTo: '县城管局', managerUnit: '三山村村委会', managers: '空', costFrom: '富山乡', remark: '空' }, + '河外泵站': { area: '富山乡', name: '河外电排站站', func: '排涝', power: 90, num: 2, elc_type: '空', water_type: '空', by_type: '空', year: ' 1984年, 2021年', rightTo: '县城管局', managerUnit: '三山村村委会', managers: '空', costFrom: '富山乡', remark: '空' }, + '东山站': { area: '富山乡', name: '东山电排站', func: '排涝', power: 2010, num: 12, elc_type: '6台180、6台155', water_type: '空', by_type: '1250、1650', year: ' 1983年, 2008年', rightTo: '富山乡', managerUnit: '富山乡', managers: '空', costFrom: '富山乡', remark: '排涝能力偏小' }, + '河口电排站': { area: '县城投', name: '河口电排站', func: '排涝', power: 6250, num: 5, elc_type: 'TL1250-30/2600(12500KW)', water_type: '2050ZLQ轴流泵', by_type: 'SCB11-630/10/0.4(2台)', year: ' 2021年, 空', rightTo: '县城管局', managerUnit: '县城投公司', managers: '空', costFrom: '县城投公司', remark: '空' }, + '县城投': { area: '县城投', name: '芳湖路提升泵站', func: '排涝', power: 225, num: 3, elc_type: 'Y2-315M-8(75KW)', water_type: 'ZLDB-立式单基础轴流泵', by_type: 'ZGS13-200KVA、ZGS13-400KVA', year: ' 2019年, 空', rightTo: '县城管局', managerUnit: '还未明确管理单位,由工人代管', managers: '廖良斌', costFrom: '县城投公司', remark: '空' }, + '县城投': { area: '县城投', name: '三干渠富山大道闸', func: '控制闸', power: '空', num: 2, elc_type: '空', water_type: '空', by_type: '空', year: ' 2018年, 空', rightTo: '县城管局', managerUnit: '县城投公司(水投公司)', managers: '葛江波', costFrom: '县城投公司(水投公司)', remark: '空' }, + '县城投': { area: '县城投', name: '三干渠银湖二路明渠闸', func: '控制闸', power: '空', num: 2, elc_type: '空', water_type: '空', by_type: '空', year: ' 2018年, 空', rightTo: '县城管局', managerUnit: '县城投公司(水投公司)', managers: '葛江波', costFrom: '县城投公司(水投公司)', remark: '空' }, + '县城投': { area: '县城投', name: '三干渠汇仁大道明渠闸', func: '控制闸', power: '空', num: 2, elc_type: '空', water_type: '空', by_type: '空', year: ' 2018年, 空', rightTo: '县城管局', managerUnit: '县城投公司(水投公司)', managers: '葛江波', costFrom: '县城投公司(水投公司)', remark: '空' }, +} + + +export { POWER_STATIONS } \ No newline at end of file diff --git a/web/client/src/sections/bigScreen/containers/systemManagement.js b/web/client/src/sections/bigScreen/containers/systemManagement.js index 18dcd04..094838d 100644 --- a/web/client/src/sections/bigScreen/containers/systemManagement.js +++ b/web/client/src/sections/bigScreen/containers/systemManagement.js @@ -15,7 +15,8 @@ const TreeNode = Tree.TreeNode; const SystemManagement = ({ clientHeight, user, history }) => { - const [module, setModule] = useState('capacity') + const [module, setModule] = useState('basis') + const [showData, setshowData] = useState([]) useEffect(() => { }, []) @@ -33,8 +34,8 @@ const SystemManagement = ({ clientHeight, user, history }) => {
{module == 'basis' ? <> -
- +
+ : ""} {module == 'capacity' ? : ""} {module == 'electrical' ? : ""} @@ -43,7 +44,7 @@ const SystemManagement = ({ clientHeight, user, history }) => { ) } -function mapStateToProps(state) { +function mapStateToProps (state) { const { auth, global } = state; return { user: auth.user, diff --git a/web/package.json b/web/package.json index 6ea0a81..a1e17ed 100644 --- a/web/package.json +++ b/web/package.json @@ -100,6 +100,7 @@ "react-router-breadcrumbs-hoc": "^4.0.1", "react-sortable-hoc": "^2.0.0", "shortid": "^2.2.16", + "simplebar-react": "^3.2.4", "superagent": "^6.1.0", "uuid": "^8.3.1", "webpack-dev-server": "^3.11.2",