diff --git a/api/app/lib/controllers/data/project.js b/api/app/lib/controllers/data/project.js new file mode 100644 index 00000000..afc49772 --- /dev/null +++ b/api/app/lib/controllers/data/project.js @@ -0,0 +1,77 @@ +'use strict'; + +'use strict'; + +async function projectGet (ctx) { + try { + const models = ctx.fs.dc.models; + const { type } = ctx.query; + + const projectRes = await models.Project.findAll({ + where: { + type + }, + order: [['id', 'DESC']] + }) + + ctx.status = 200; + ctx.body = projectRes + } catch (error) { + ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); + ctx.status = 400; + ctx.body = { + message: typeof error == 'string' ? error : undefined + } + } +} + +async function projectEdit (ctx) { + try { + const models = ctx.fs.dc.models; + const data = ctx.request.body; + + if (!data.projectId) { + await models.Project.create(data) + } else { + await models.Project.update( + data, { + where: { + id: data.projectId + } + }) + } + + 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 projectDel (ctx) { + try { + const models = ctx.fs.dc.models; + const { projectId } = ctx.params; + + await models.Project.destroy({ + where: { + id: projectId + } + }) + + 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 = { + projectGet, projectEdit, projectDel, +}; \ No newline at end of file diff --git a/api/app/lib/models/project.js b/api/app/lib/models/project.js new file mode 100644 index 00000000..b20bdfb8 --- /dev/null +++ b/api/app/lib/models/project.js @@ -0,0 +1,124 @@ +/* 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" + }, + entryName: { + type: DataTypes.STRING, + allowNull: true, + defaultValue: null, + comment: "项目名称", + primaryKey: false, + field: "entry_name", + autoIncrement: false + }, + projectMileage: { + type: DataTypes.STRING, + allowNull: true, + defaultValue: null, + comment: "工程里程", + primaryKey: false, + field: "project_mileage", + autoIncrement: false + }, + investment: { + type: DataTypes.STRING, + allowNull: true, + defaultValue: null, + comment: "投资", + primaryKey: false, + field: "investment", + autoIncrement: false + }, + buildUnit: { + type: DataTypes.STRING, + allowNull: true, + defaultValue: null, + comment: "建设单位", + primaryKey: false, + field: "build_unit", + autoIncrement: false + }, + constructionControlUnit: { + type: DataTypes.STRING, + allowNull: true, + defaultValue: null, + comment: "监理单位", + primaryKey: false, + field: "construction_control_unit", + autoIncrement: false + }, + designUnit: { + type: DataTypes.STRING, + allowNull: true, + defaultValue: null, + comment: "设计单位", + primaryKey: false, + field: "design_unit", + autoIncrement: false + }, + constructionUnit: { + type: DataTypes.STRING, + allowNull: true, + defaultValue: null, + comment: "施工单位", + primaryKey: false, + field: "construction_unit", + autoIncrement: false + }, + supervisorAndSupervisor: { + type: DataTypes.STRING, + allowNull: true, + defaultValue: null, + comment: "监督负责人及监督人员", + primaryKey: false, + field: "supervisor_and_supervisor", + autoIncrement: false + }, + projectProgress: { + type: DataTypes.STRING, + allowNull: true, + defaultValue: null, + comment: "项目进展情况", + primaryKey: false, + field: "project_progress", + autoIncrement: false + }, + done: { + type: DataTypes.BOOLEAN, + allowNull: false, + defaultValue: null, + comment: null, + primaryKey: false, + field: "done", + autoIncrement: false + }, + type: { + type: DataTypes.STRING, + allowNull: false, + defaultValue: null, + comment: "类型 道路:road / 桥梁:bridge", + primaryKey: false, + field: "type", + autoIncrement: false + } + }, { + tableName: "project", + comment: "", + indexes: [] + }); + dc.models.Project = Project; + return Project; +}; \ No newline at end of file diff --git a/api/app/lib/routes/data/index.js b/api/app/lib/routes/data/index.js index 1f7dc129..ad4561d6 100644 --- a/api/app/lib/routes/data/index.js +++ b/api/app/lib/routes/data/index.js @@ -3,6 +3,7 @@ const vehicle = require('../../controllers/data/vehicle'); const road = require('../../controllers/data/road'); const bridge = require('../../controllers/data/bridge'); +const project = require('../../controllers/data/project'); module.exports = function (app, router, opts) { @@ -62,4 +63,16 @@ module.exports = function (app, router, opts) { app.fs.api.logAttr['DEL/bridge/:bridgeId'] = { content: '删除桥梁数据', visible: false }; router.del('/bridge/:bridgeId', bridge.bridgeDel); // 桥梁 END + + // project + app.fs.api.logAttr['GET/project'] = { content: '获取工程数据', visible: true }; + router.get('/project', project.projectGet); + + app.fs.api.logAttr['PUT/project'] = { content: '编辑工程数据', visible: true }; + router.put('/project', project.projectEdit); + + app.fs.api.logAttr['DEL/project/:projectId'] = { content: '删除工程数据', visible: false }; + router.del('/project/:projectId', project.projectDel); + + // project END }; diff --git a/scripts/0.0.1/data/工具脚本(无需执行)/data/工程一览/桥梁.xls b/scripts/0.0.1/data/工具脚本(无需执行)/data/工程一览/桥梁.xls new file mode 100644 index 00000000..aa73ae7c Binary files /dev/null and b/scripts/0.0.1/data/工具脚本(无需执行)/data/工程一览/桥梁.xls differ diff --git a/scripts/0.0.1/data/工具脚本(无需执行)/data/工程一览/道路.xls b/scripts/0.0.1/data/工具脚本(无需执行)/data/工程一览/道路.xls new file mode 100644 index 00000000..1f938dea Binary files /dev/null and b/scripts/0.0.1/data/工具脚本(无需执行)/data/工程一览/道路.xls differ diff --git a/scripts/0.0.1/data/工具脚本(无需执行)/dataIn.js b/scripts/0.0.1/data/工具脚本(无需执行)/dataIn.js index dd2ee88d..cd1bff65 100644 --- a/scripts/0.0.1/data/工具脚本(无需执行)/dataIn.js +++ b/scripts/0.0.1/data/工具脚本(无需执行)/dataIn.js @@ -103,6 +103,20 @@ try { // defaultKey: ['type'], // defaultValue: ['危货'], // }, + // { + // path: ['./data/工程一览/道路.xls'], + // n: '工程一览', + // tableName: 'project', + // defaultKey: ['done', 'type'], + // defaultValue: [false, 'road'], + // }, + // { + // path: ['./data/工程一览/桥梁.xls'], + // n: '工程一览', + // tableName: 'project', + // defaultKey: ['done', 'type'], + // defaultValue: [false, 'bridge'], + // }, ] for (let f of fileList) { @@ -126,6 +140,12 @@ try { if (v) { insertKeys.push(keyMap[k]); insertValues.push(v); + + if (f.n == '工程一览') { + if (k == '项目进展情况' && v == '已完工') { + insertValues[0] = true + } + } } } insertStr += insertKeys.join(',') + ') VALUES ('; diff --git a/scripts/0.0.1/data/工具脚本(无需执行)/index.js b/scripts/0.0.1/data/工具脚本(无需执行)/index.js index 70d8fcac..4d2e20ab 100644 --- a/scripts/0.0.1/data/工具脚本(无需执行)/index.js +++ b/scripts/0.0.1/data/工具脚本(无需执行)/index.js @@ -75,11 +75,16 @@ try { // n: '运政业户', // tableName: 'municipal_business' // }, - { - path: './data/桥梁/桥第三方.xls', - n: '桥梁', - tableName: 'bridge' - } + // { + // path: './data/桥梁/桥第三方.xls', + // n: '桥梁', + // tableName: 'bridge' + // }, + // { + // path: './data/工程一览/道路.xls', + // n: '工程一览', + // tableName: 'project' + // }, ] for (let f of fileList) { diff --git a/scripts/0.0.1/data/工具脚本(无需执行)/工程一览_字段对应.json b/scripts/0.0.1/data/工具脚本(无需执行)/工程一览_字段对应.json new file mode 100644 index 00000000..20911cc4 --- /dev/null +++ b/scripts/0.0.1/data/工具脚本(无需执行)/工程一览_字段对应.json @@ -0,0 +1,11 @@ +{ + "项目名称": "entryName", + "工程里程": "projectMileage", + "投资": "investment", + "建设单位": "buildUnit", + "监理单位": "constructionControlUnit", + "设计单位": "designUnit", + "施工单位": "constructionUnit", + "监督负责人及监督人员": "supervisorAndSupervisor", + "项目进展情况": "projectProgress" +} \ No newline at end of file diff --git a/scripts/0.0.1/data/工具脚本(无需执行)/工程一览_数据字段对应.json b/scripts/0.0.1/data/工具脚本(无需执行)/工程一览_数据字段对应.json new file mode 100644 index 00000000..8e10c5c2 --- /dev/null +++ b/scripts/0.0.1/data/工具脚本(无需执行)/工程一览_数据字段对应.json @@ -0,0 +1,11 @@ +{ + "entryName": "项目名称", + "projectMileage": "工程里程", + "investment": "投资", + "buildUnit": "建设单位", + "constructionControlUnit": "监理单位", + "designUnit": "设计单位", + "constructionUnit": "施工单位", + "supervisorAndSupervisor": "监督负责人及监督人员", + "projectProgress": "项目进展情况" +} \ No newline at end of file diff --git a/scripts/0.0.1/data/工具脚本(无需执行)/工程一览_数据库表对应.json b/scripts/0.0.1/data/工具脚本(无需执行)/工程一览_数据库表对应.json new file mode 100644 index 00000000..68625e66 --- /dev/null +++ b/scripts/0.0.1/data/工具脚本(无需执行)/工程一览_数据库表对应.json @@ -0,0 +1,11 @@ +{ + "项目名称": "entry_name", + "工程里程": "project_mileage", + "投资": "investment", + "建设单位": "build_unit", + "监理单位": "construction_control_unit", + "设计单位": "design_unit", + "施工单位": "construction_unit", + "监督负责人及监督人员": "supervisor_and_supervisor", + "项目进展情况": "project_progress" +} \ No newline at end of file diff --git a/scripts/0.0.1/data/工具脚本(无需执行)/工程一览_数据脚本对应.sql b/scripts/0.0.1/data/工具脚本(无需执行)/工程一览_数据脚本对应.sql new file mode 100644 index 00000000..8bf79e97 --- /dev/null +++ b/scripts/0.0.1/data/工具脚本(无需执行)/工程一览_数据脚本对应.sql @@ -0,0 +1,15 @@ +-- 工程一览 + +CREATE TABLE if not exists "project" ( id serial not null ); + +CREATE unique index if not exists project_id_uindex +ON project (id); alter TABLE project add constraint project_pk primary key (id); alter TABLE project add Entry_Name varchar(1024); comment +ON column project.Entry_Name is '项目名称'; alter TABLE project add Project_Mileage varchar(1024); comment +ON column project.Project_Mileage is '工程里程'; alter TABLE project add Investment varchar(1024); comment +ON column project.Investment is '投资'; alter TABLE project add Build_Unit varchar(1024); comment +ON column project.Build_Unit is '建设单位'; alter TABLE project add Construction_Control_Unit varchar(1024); comment +ON column project.Construction_Control_Unit is '监理单位'; alter TABLE project add Design_Unit varchar(1024); comment +ON column project.Design_Unit is '设计单位'; alter TABLE project add Construction_Unit varchar(1024); comment +ON column project.Construction_Unit is '施工单位'; alter TABLE project add Supervisor_And_Supervisor varchar(1024); comment +ON column project.Supervisor_And_Supervisor is '监督负责人及监督人员'; alter TABLE project add Project_Progress varchar(1024); comment +ON column project.Project_Progress is '项目进展情况'; \ No newline at end of file