Browse Source

上报处理数据

dev
巴林闲侠 2 years ago
parent
commit
9e51bbe72a
  1. 14
      api/app/lib/controllers/report/index.js
  2. 437
      api/app/lib/models/report.js
  3. 8
      scripts/1.2.3/schema/2.update_report.sql

14
api/app/lib/controllers/report/index.js

@ -32,7 +32,6 @@ async function reportList (ctx) {
` `
const res = await sequelize.query(sqlStr, { type: QueryTypes.SELECT }) const res = await sequelize.query(sqlStr, { type: QueryTypes.SELECT })
let a = 1
findUsers = res.map(item => { findUsers = res.map(item => {
return item.id return item.id
}) })
@ -192,10 +191,15 @@ async function reportHandle (ctx) {
const { reportId } = ctx.params const { reportId } = ctx.params
const { handleState } = ctx.request.body const { handleState } = ctx.request.body
const data = ctx.request.body
await models.Report.update({ /**
handleState: handleState * data = {
}, { * handleState,
* handleContent,
* handlePic
* }
*/
await models.Report.update(data, {
where: { where: {
id: reportId id: reportId
} }

437
api/app/lib/models/report.js

@ -3,214 +3,231 @@
'use strict'; 'use strict';
module.exports = dc => { module.exports = dc => {
const DataTypes = dc.ORM; const DataTypes = dc.ORM;
const sequelize = dc.orm; const sequelize = dc.orm;
const Report = sequelize.define("report", { const Report = sequelize.define("report", {
id: { id: {
index: 1, index: 1,
type: DataTypes.INTEGER, type: DataTypes.INTEGER,
allowNull: false, allowNull: false,
defaultValue: null, defaultValue: null,
comment: null, comment: null,
primaryKey: true, primaryKey: true,
field: "id", field: "id",
autoIncrement: true, autoIncrement: true,
unique: "report_id_uindex" unique: "report_id_uindex"
}, },
reportType: { reportType: {
index: 2, index: 2,
type: DataTypes.STRING, type: DataTypes.STRING,
allowNull: false, allowNull: false,
defaultValue: null, defaultValue: null,
comment: "上报类型", comment: "上报类型",
primaryKey: false, primaryKey: false,
field: "report_type", field: "report_type",
autoIncrement: false autoIncrement: false
}, },
projectType: { projectType: {
index: 3, index: 3,
type: DataTypes.STRING, type: DataTypes.STRING,
allowNull: false, allowNull: false,
defaultValue: null, defaultValue: null,
comment: "工程类型", comment: "工程类型",
primaryKey: false, primaryKey: false,
field: "project_type", field: "project_type",
autoIncrement: false autoIncrement: false
}, },
road: { road: {
index: 4, index: 4,
type: DataTypes.STRING, type: DataTypes.STRING,
allowNull: true, allowNull: true,
defaultValue: null, defaultValue: null,
comment: '所属道路', comment: '所属道路',
primaryKey: false, primaryKey: false,
field: "road", field: "road",
autoIncrement: false autoIncrement: false
}, },
roadSectionStart: { roadSectionStart: {
index: 5, index: 5,
type: DataTypes.STRING, type: DataTypes.STRING,
allowNull: true, allowNull: true,
defaultValue: null, defaultValue: null,
comment: '开始路段', comment: '开始路段',
primaryKey: false, primaryKey: false,
field: "road_section_start", field: "road_section_start",
autoIncrement: false autoIncrement: false
}, },
roadSectionEnd: { roadSectionEnd: {
index: 6, index: 6,
type: DataTypes.STRING, type: DataTypes.STRING,
allowNull: true, allowNull: true,
defaultValue: null, defaultValue: null,
comment: '结束路段', comment: '结束路段',
primaryKey: false, primaryKey: false,
field: "road_section_end", field: "road_section_end",
autoIncrement: false autoIncrement: false
}, },
longitude: { longitude: {
index: 7, index: 7,
type: DataTypes.DOUBLE, type: DataTypes.DOUBLE,
allowNull: true, allowNull: true,
defaultValue: null, defaultValue: null,
comment: '经度', comment: '经度',
primaryKey: false, primaryKey: false,
field: "longitude", field: "longitude",
autoIncrement: false autoIncrement: false
}, },
latitude: { latitude: {
index: 8, index: 8,
type: DataTypes.DOUBLE, type: DataTypes.DOUBLE,
allowNull: true, allowNull: true,
defaultValue: null, defaultValue: null,
comment: '纬度', comment: '纬度',
primaryKey: false, primaryKey: false,
field: "latitude", field: "latitude",
autoIncrement: false autoIncrement: false
}, },
content: { content: {
index: 9, index: 9,
type: DataTypes.STRING, type: DataTypes.STRING,
allowNull: true, allowNull: true,
defaultValue: null, defaultValue: null,
comment: '具体内容', comment: '具体内容',
primaryKey: false, primaryKey: false,
field: "content", field: "content",
autoIncrement: false autoIncrement: false
}, },
scenePic: { scenePic: {
index: 10, index: 10,
type: DataTypes.ARRAY(DataTypes.STRING), type: DataTypes.ARRAY(DataTypes.STRING),
allowNull: true, allowNull: true,
defaultValue: null, defaultValue: null,
comment: null, comment: null,
primaryKey: false, primaryKey: false,
field: "scene_pic", field: "scene_pic",
autoIncrement: false autoIncrement: false
}, },
conserveBeforePic: { conserveBeforePic: {
index: 11, index: 11,
type: DataTypes.ARRAY(DataTypes.STRING), type: DataTypes.ARRAY(DataTypes.STRING),
allowNull: true, allowNull: true,
defaultValue: null, defaultValue: null,
comment: null, comment: null,
primaryKey: false, primaryKey: false,
field: "conserve_before_pic", field: "conserve_before_pic",
autoIncrement: false autoIncrement: false
}, },
conserveUnderwayPic: { conserveUnderwayPic: {
index: 12, index: 12,
type: DataTypes.ARRAY(DataTypes.STRING), type: DataTypes.ARRAY(DataTypes.STRING),
allowNull: true, allowNull: true,
defaultValue: null, defaultValue: null,
comment: null, comment: null,
primaryKey: false, primaryKey: false,
field: "conserve_underway_pic", field: "conserve_underway_pic",
autoIncrement: false autoIncrement: false
}, },
conserveAfterPic: { conserveAfterPic: {
index: 13, index: 13,
type: DataTypes.ARRAY(DataTypes.STRING), type: DataTypes.ARRAY(DataTypes.STRING),
allowNull: true, allowNull: true,
defaultValue: null, defaultValue: null,
comment: null, comment: null,
primaryKey: false, primaryKey: false,
field: "conserve_after_pic", field: "conserve_after_pic",
autoIncrement: false autoIncrement: false
}, },
userId: { userId: {
index: 14, index: 14,
type: DataTypes.INTEGER, type: DataTypes.INTEGER,
allowNull: true, allowNull: true,
defaultValue: null, defaultValue: null,
comment: null, comment: null,
primaryKey: false, primaryKey: false,
field: "user_id", field: "user_id",
autoIncrement: false autoIncrement: false
}, },
time: { time: {
index: 15, index: 15,
type: DataTypes.DATE, type: DataTypes.DATE,
allowNull: false, allowNull: false,
defaultValue: null, defaultValue: null,
comment: '创建日期', comment: '创建日期',
primaryKey: false, primaryKey: false,
field: "time", field: "time",
autoIncrement: false autoIncrement: false
}, },
address: { address: {
index: 16, index: 16,
type: DataTypes.STRING, type: DataTypes.STRING,
allowNull: true, allowNull: true,
defaultValue: null, defaultValue: null,
comment: '具体位置', comment: '具体位置',
primaryKey: false, primaryKey: false,
field: "address", field: "address",
autoIncrement: false autoIncrement: false
}, },
projectName: { projectName: {
index: 17, index: 17,
type: DataTypes.STRING, type: DataTypes.STRING,
allowNull: true, allowNull: true,
defaultValue: null, defaultValue: null,
comment: "工程名称", comment: "工程名称",
primaryKey: false, primaryKey: false,
field: "project_name", field: "project_name",
autoIncrement: false autoIncrement: false
}, },
handleState: { handleState: {
index: 18, index: 18,
type: DataTypes.STRING, type: DataTypes.STRING,
allowNull: false, allowNull: false,
defaultValue: "已处理", defaultValue: "已处理",
// comment: "处理状态", // comment: "处理状态",
primaryKey: false, primaryKey: false,
field: "handle_state", field: "handle_state",
autoIncrement: false autoIncrement: false
}, },
routeCode: { routeCode: {
type: DataTypes.STRING, type: DataTypes.STRING,
allowNull: true, allowNull: true,
defaultValue: null, defaultValue: null,
comment: null, comment: null,
primaryKey: false, primaryKey: false,
field: "route_code", field: "route_code",
autoIncrement: false autoIncrement: false
}, },
performerId: { performerId: {
type: DataTypes.INTEGER, type: DataTypes.INTEGER,
allowNull: true, allowNull: true,
defaultValue: null, defaultValue: null,
comment: "执行者", comment: "执行者",
primaryKey: false, primaryKey: false,
field: "performer_id", field: "performer_id",
autoIncrement: false autoIncrement: false
} },
handleContent: {
}, { type: DataTypes.STRING,
tableName: "report", allowNull: true,
comment: "", defaultValue: null,
indexes: [] comment: "",
}); primaryKey: false,
dc.models.Report = Report; field: "handle_content",
return Report; autoIncrement: false
},
handlePic: {
type: DataTypes.ARRAY(DataTypes.STRING),
allowNull: true,
defaultValue: null,
comment: null,
primaryKey: false,
field: "handle_pic",
autoIncrement: false
},
}, {
tableName: "report",
comment: "",
indexes: []
});
dc.models.Report = Report;
return Report;
}; };

8
scripts/1.2.3/schema/2.update_report.sql

@ -1,2 +1,6 @@
alter table report ALTER TABLE report add code_road varchar(512);
add code_road varchar(512);
ALTER TABLE report add handle_content varchar(1024); comment
ON column report.handle_content is '执行内容描述';
ALTER TABLE report add handle_pic varchar(1204) [];
Loading…
Cancel
Save