明树Git Lab

Commit 22bcd01f authored by zfp1's avatar zfp1

update

parent 2ceedc38
Pipeline #106720 passed with stage
in 3 seconds
...@@ -3,6 +3,89 @@ const _ = require("lodash"); ...@@ -3,6 +3,89 @@ const _ = require("lodash");
const { Op } = require('sequelize'); const { Op } = require('sequelize');
// ---------------- 信息报送 RcXxbs ----------------
// 创建信息报送
async function createXxbs(req, res, next) {
try {
req.body.creator = req.user.id;
let ret = await DB.RcXxbs.create(req.body);
return res.sendData(ret);
} catch (error) {
next(error);
}
}
// 更新信息报送
async function updateXxbs(req, res, next) {
try {
if (!req.body.id) return res.sendError(errorMessage.paramsError);
let ret = await DB.RcXxbs.findOne({ where: { id: req.body.id }, raw: true });
if (!(ret && ret.id)) return res.sendError(errorMessage.resourceNotFound);
await DB.RcXxbs.update(req.body, { where: { id: req.body.id } });
return res.sendData({});
} catch (error) {
next(error);
}
}
// 获取单个信息报送
async function getXxbs(req, res, next) {
try {
if (!req.body.id) return res.sendError(errorMessage.paramsError);
let info = await DB.RcXxbs.findOne({ where: { id: req.body.id, del: 0 }, raw: true });
if (!(info && info.id)) return res.sendError(errorMessage.resourceNotFound);
return res.sendData(info);
} catch (error) {
next(error);
}
}
// 获取信息报送列表
async function getXxbsList(req, res, next) {
try {
let page = req.body.page || 1;
let limit = req.body.pagesize || req.body.pageSize || 10;
let offset = (page - 1) * limit;
let search = {};
search.order = [['createdAt', 'DESC']];
search.limit = limit;
search.offset = offset;
let where = { del: 0 };
if (req.body.wjmc) {
where.wjmc = { [Op.like]: `%${req.body.wjmc}%` };
}
if (req.body.bzr) {
where.bzr = { [Op.like]: `%${req.body.bzr}%` };
}
if (req.body.projectId) {
where.projectId = req.body.projectId;
}
if (req.body.nd) {
where.nd = req.body.nd;
}
search.where = where;
if (req.body.attributes && req.body.attributes.length) {
search.attributes = req.body.attributes;
}
let ret = await DB.RcXxbs.findAndCountAll(search);
return res.sendData(ret);
} catch (error) {
next(error);
}
}
// 删除信息报送
async function deleteXxbs(req, res, next) {
try {
await DB.RcXxbs.update({ del: 1 }, { where: { id: req.body.id } });
return res.sendData({});
} catch (error) {
next(error);
}
}
// ---------------- 投资规划 RcTzgh ---------------- // ---------------- 投资规划 RcTzgh ----------------
// 创建投资规划 // 创建投资规划
async function createTzgh(req, res, next) { async function createTzgh(req, res, next) {
...@@ -95,20 +178,8 @@ async function deleteTzgh(req, res, next) { ...@@ -95,20 +178,8 @@ async function deleteTzgh(req, res, next) {
async function createTxjs(req, res, next) { async function createTxjs(req, res, next) {
try { try {
req.body.creator = req.user.id; req.body.creator = req.user.id;
if (!req.body.projectId) {
return res.sendError(errorMessage.paramsError);
}
// 创建主表
let ret = await DB.RcTxjs.create(req.body); let ret = await DB.RcTxjs.create(req.body);
// 处理附件/子表
let wjs = (req.body.rcTxjsWjs || []).map(o => { o.projectId = req.body.projectId; o.sourceId = ret.id; return o });
if (wjs.length) {
await DB.RcTxjsWj.bulkCreate(wjs);
}
return res.sendData(ret); return res.sendData(ret);
} catch (error) { } catch (error) {
next(error); next(error);
} }
...@@ -116,27 +187,13 @@ async function createTxjs(req, res, next) { ...@@ -116,27 +187,13 @@ async function createTxjs(req, res, next) {
async function updateTxjs(req, res, next) { async function updateTxjs(req, res, next) {
try { try {
if (!(req.body.id && req.body.projectId)) { if (!req.body.id) {
return res.sendError(errorMessage.paramsError); return res.sendError(errorMessage.paramsError);
} }
let ret = await DB.RcTxjs.findOne({ where: { id: req.body.id }, raw: true }); let ret = await DB.RcTxjs.findOne({ where: { id: req.body.id }, raw: true });
if (!(ret && ret.id)) { if (!(ret && ret.id)) {
return res.sendError(errorMessage.resourceNotFound); return res.sendError(errorMessage.resourceNotFound);
} }
// 处理子表 rc 文件
let arr = req.body.rcTxjsWjs || [];
let ids = [], infos = [], newArr = [];
(arr || []).map(o => {
if (!o.id) {
if (!_.isEmpty(o)) { o.projectId = req.body.projectId; o.sourceId = ret.id; newArr.push(o); }
} else { ids.push(o.id); infos.push(o); }
return o;
});
await DB.RcTxjsWj.destroy({ where: { projectId: req.body.projectId, sourceId: ret.id, id: { [Op.notIn]: ids } } });
if (newArr.length) await DB.RcTxjsWj.bulkCreate(newArr);
await Promise.all(infos.map(item => { return DB.RcTxjsWj.update(item, { where: { id: item.id } }) }));
await DB.RcTxjs.update(req.body, { where: { id: req.body.id } }); await DB.RcTxjs.update(req.body, { where: { id: req.body.id } });
return res.sendData({}); return res.sendData({});
} catch (error) { } catch (error) {
...@@ -145,18 +202,13 @@ async function updateTxjs(req, res, next) { ...@@ -145,18 +202,13 @@ async function updateTxjs(req, res, next) {
} }
async function getTxjs(req, res, next) { async function getTxjs(req, res, next) {
try { try {
let search = {}; if (!req.body.id) {
if (req.body.id) search.id = req.body.id;
if (req.body.projectId) search.projectId = req.body.projectId;
if (_.isEmpty(search)) {
return res.sendError(errorMessage.paramsError); return res.sendError(errorMessage.paramsError);
} }
let tx = await DB.RcTxjs.findOne({ where: search, raw: true }); let tx = await DB.RcTxjs.findOne({ where: { id: req.body.id }, raw: true });
if (!(tx && tx.id && tx.projectId)) { if (!(tx && tx.id)) {
return res.sendError(errorMessage.resourceNotFound); return res.sendError(errorMessage.resourceNotFound);
} }
let wjs = await DB.RcTxjsWj.findAll({ where: { projectId: tx.projectId, sourceId: tx.id }, raw: true });
tx.rcTxjsWjs = wjs || [];
return res.sendData(tx); return res.sendData(tx);
} catch (error) { } catch (error) {
next(error); next(error);
...@@ -169,23 +221,21 @@ async function getTxjsList(req, res, next) { ...@@ -169,23 +221,21 @@ async function getTxjsList(req, res, next) {
let page = req.body.page || 1; let page = req.body.page || 1;
let limit = req.body.pagesize || req.body.pageSize || 10; let limit = req.body.pagesize || req.body.pageSize || 10;
let offset = (page - 1) * limit; let offset = (page - 1) * limit;
let search = {}; let search = {};
search.order = [['createdAt', 'DESC']]; search.order = [['createdAt', 'DESC']];
search.limit = limit; search.limit = limit;
search.offset = offset; search.offset = offset;
let where = { del: 0 }; let where = { del: 0 };
if (req.body.projectName) { if (req.body.wjmc) {
where = { where.wjmc = { [Op.like]: `%${req.body.wjmc}%` };
[Op.or]: [ }
{ projectName: { [Op.like]: `%${req.body.projectName}%` } }, if (req.body.wjcj) {
], where.wjcj = req.body.wjcj;
del: 0 }
} if (req.body.wjlb) {
where.wjlb = req.body.wjlb;
} }
search.where = where; search.where = where;
if (req.body.attributes && req.body.attributes.length) { if (req.body.attributes && req.body.attributes.length) {
search.attributes = req.body.attributes; search.attributes = req.body.attributes;
} }
...@@ -421,4 +471,11 @@ module.exports = { ...@@ -421,4 +471,11 @@ module.exports = {
getTzgh, getTzgh,
getTzghList, getTzghList,
deleteTzgh, deleteTzgh,
// 信息报送
createXxbs,
updateXxbs,
getXxbs,
getXxbsList,
deleteXxbs,
} }
\ No newline at end of file
...@@ -75,15 +75,17 @@ const ThYyqtzhszb = require('./model/jt/thYyqtzhszb'); ...@@ -75,15 +75,17 @@ const ThYyqtzhszb = require('./model/jt/thYyqtzhszb');
const ThYyqtzjc = require('./model/jt/thYyqtzjc'); const ThYyqtzjc = require('./model/jt/thYyqtzjc');
const ThYyqtzjcTzfx = require('./model/jt/thYyqtzjcTzfx'); const ThYyqtzjcTzfx = require('./model/jt/thYyqtzjcTzfx');
const ThYyqtzjcZxjc = require('./model/jt/thYyqtzjcZxjc'); const ThYyqtzjcZxjc = require('./model/jt/thYyqtzjcZxjc');
const ThYyqtzjcrcjc = require('./model/jt/thYyqtzjcrcjc'); // const ThYyqtzjcrcjc = require('./model/jt/thYyqtzjcrcjc');
const ThYjgl = require("./model/jt/thYjgl"); const ThYjgl = require("./model/jt/thYjgl");
const RcTxjs = require('./model/jt/rcTxjs'); const RcTxjs = require('./model/jt/rcTxjs');
const RcTxjsWj = require('./model/jt/rcTxjswj');
const RcCgqygl = require('./model/jt/rcCgqygl'); const RcCgqygl = require('./model/jt/rcCgqygl');
const RcCgqyglTzfh = require('./model/jt/rcCgqyglTzfh'); const RcCgqyglTzfh = require('./model/jt/rcCgqyglTzfh');
const RcCgqyglWtyy = require('./model/jt/rcCgqyglWtyy'); const RcCgqyglWtyy = require('./model/jt/rcCgqyglWtyy');
const RcTzgh = require('./model/jt/rcTzgh');
const RcXxbs = require('./model/jt/rcXxbs');
const RcTwhgl = require('./model/jt/rcTwhgl');
/** /**
* 业务表 * 业务表
*/ */
...@@ -139,15 +141,15 @@ global.DB = { ...@@ -139,15 +141,15 @@ global.DB = {
TzZdfx, TzZdfx,
TzZdfxcz, TzZdfxcz,
TzZdfxcwzb, // TzZdfxcwzb,
TzZdfxqk, // TzZdfxqk,
TzJsqtzjc, TzJsqtzjc,
TzJsqtzjcTzfx, TzJsqtzjcTzfx,
TzJsqtzjcrcjc, // TzJsqtzjcrcjc,
TzJsqtzjcZxjc, TzJsqtzjcZxjc,
TzZdsxsp, TzZdsxsp,
TzZdsxspfl, // TzZdsxspfl,
TzXmtc, TzXmtc,
TzXmtcCwzb, TzXmtcCwzb,
...@@ -158,17 +160,16 @@ global.DB = { ...@@ -158,17 +160,16 @@ global.DB = {
ThYyqtzjc, ThYyqtzjc,
ThYyqtzjcTzfx, ThYyqtzjcTzfx,
ThYyqtzjcZxjc, ThYyqtzjcZxjc,
ThYyqtzjcrcjc, // ThYyqtzjcrcjc,
ThYjgl, ThYjgl,
RcTxjs, RcTxjs,
RcTxjsWj,
RcCgqygl, RcCgqygl,
RcCgqyglTzfh, RcCgqyglTzfh,
RcCgqyglWtyy, RcCgqyglWtyy,
RcTzgh,
RcTwhgl,
RcXxbs,
} }
......
...@@ -32,9 +32,7 @@ const RcTwhgl = sequelize.define('RcTwhgl', { ...@@ -32,9 +32,7 @@ const RcTwhgl = sequelize.define('RcTwhgl', {
comment: '会议地点' comment: '会议地点'
}, },
meetingLevel: { meetingLevel: {
type: DataTypes.ENUM('company', 'department', 'project'), type: DataTypes.STRING,
allowNull: false,
defaultValue: 'company',
comment: '会议层级:company-公司级,department-部门级,project-项目级' comment: '会议层级:company-公司级,department-部门级,project-项目级'
}, },
attendingLeaders: { attendingLeaders: {
......
...@@ -9,19 +9,40 @@ const RcTxjs = sequelize.define('RcTxjs', { ...@@ -9,19 +9,40 @@ const RcTxjs = sequelize.define('RcTxjs', {
primaryKey: true, primaryKey: true,
autoIncrement: true autoIncrement: true
}, },
projectName: { wjmc: {
type: DataTypes.STRING, type: DataTypes.STRING,
comment: "项目名称", comment: "文件名称",
}, },
creator: { bbsj: {
type: DataTypes.INTEGER, type: DataTypes.DATE,
comment: "创建人" get() {
const rawValue = this.getDataValue('bbsj');
return rawValue ? moment(rawValue).format('YYYY-MM-DD') : '';
}
}, },
projectId: { wjcj: {
type: DataTypes.STRING,
comment: "文件层级",
},
wjlb: {
type: DataTypes.STRING,
comment: "文件类别",
},
fjsc: {
type: DataTypes.JSON,
comment: "附件上传",
},
creator: {
type: DataTypes.INTEGER, type: DataTypes.INTEGER,
comment: "所属项目ID", comment: "创建人"
}, },
// projectId: {
// type: DataTypes.INTEGER,
// comment: "所属项目ID",
// },
del: { del: {
type: DataTypes.INTEGER, type: DataTypes.INTEGER,
defaultValue: 0, defaultValue: 0,
......
const { DataTypes } = require('sequelize');
const sequelize = require('../index');
const moment = require('moment');
//投中管理- 建设期投资检查
const RcTxjsWj = sequelize.define('RcTxjsWj', {
id: {
type: DataTypes.INTEGER,
primaryKey: true,
autoIncrement: true
},
wjlx: {
type: DataTypes.STRING,
comment: "文件类型"
},
wj: {
type: DataTypes.JSON,
comment: "文件上传"
},
wjsm: {
type: DataTypes.TEXT,
comment: "文件说明"
},
cj: {
type: DataTypes.STRING,
comment: "层级"
},
sourceId: {
type: DataTypes.INTEGER,
comment: "所属主表id"
},
projectId: {
type: DataTypes.INTEGER,
comment: "所属项目ID",
},
del: {
type: DataTypes.INTEGER,
defaultValue: 0,
comment: "0 正常 1 删除"
},
createdAt: {
type: DataTypes.DATE,
defaultValue: new Date(),
get() {
const rawValue = this.getDataValue('createdAt');
return rawValue ? moment(rawValue).format('YYYY-MM-DD HH:mm:ss') : '';
}
},
updatedAt: { // 同样处理 updatedAt
type: DataTypes.DATE,
defaultValue: new Date(),
get() {
const rawValue = this.getDataValue('updatedAt');
return rawValue ? moment(rawValue).format('YYYY-MM-DD HH:mm:ss') : '';
}
}
}, {
tableName: 'jt_rc_rctxwj', // 指定表名(如果与模型名不同)
timestamps: true, // 是否自动添加 createdAt 和 updatedAt 字段(覆盖全局设置)
});
// 同步模型到数据库(创建表)
RcTxjsWj.sync({
// force: false,
// force: true ,//会删除已存在表并重新创建
alter: true
})
.then(() => {
console.log('RcTxjsWj 表同步成功');
});
module.exports = RcTxjsWj;
\ No newline at end of file
...@@ -2,8 +2,8 @@ const { DataTypes } = require('sequelize'); ...@@ -2,8 +2,8 @@ const { DataTypes } = require('sequelize');
const sequelize = require('../index'); const sequelize = require('../index');
const moment = require('moment'); const moment = require('moment');
//投中管理- 建设期投资检查 //投中管理- 投资规划
const RcTxjsWj = sequelize.define('RcTxjsWj', { const RcTzgh = sequelize.define('RcTzgh', {
id: { id: {
type: DataTypes.INTEGER, type: DataTypes.INTEGER,
primaryKey: true, primaryKey: true,
...@@ -66,10 +66,10 @@ const RcTxjsWj = sequelize.define('RcTxjsWj', { ...@@ -66,10 +66,10 @@ const RcTxjsWj = sequelize.define('RcTxjsWj', {
projectId: { // projectId: {
type: DataTypes.INTEGER, // type: DataTypes.INTEGER,
comment: "所属项目ID", // comment: "所属项目ID",
}, // },
del: { del: {
type: DataTypes.INTEGER, type: DataTypes.INTEGER,
defaultValue: 0, defaultValue: 0,
...@@ -96,19 +96,19 @@ const RcTxjsWj = sequelize.define('RcTxjsWj', { ...@@ -96,19 +96,19 @@ const RcTxjsWj = sequelize.define('RcTxjsWj', {
} }
} }
}, { }, {
tableName: 'jt_rc_rctxwj', // 指定表名(如果与模型名不同) tableName: 'jt_rc_tzgh', // 指定表名(如果与模型名不同)
timestamps: true, // 是否自动添加 createdAt 和 updatedAt 字段(覆盖全局设置) timestamps: true, // 是否自动添加 createdAt 和 updatedAt 字段(覆盖全局设置)
}); });
// 同步模型到数据库(创建表) // 同步模型到数据库(创建表)
RcTxjsWj.sync({ RcTzgh.sync({
// force: false, // force: false,
// force: true ,//会删除已存在表并重新创建 // force: true ,//会删除已存在表并重新创建
alter: true alter: true
}) })
.then(() => { .then(() => {
console.log('RcTxjsWj 表同步成功'); console.log('RcTzgh 表同步成功');
}); });
module.exports = RcTxjsWj; module.exports = RcTzgh;
\ No newline at end of file \ No newline at end of file
...@@ -9,10 +9,35 @@ const RcXxbs = sequelize.define('RcXxbs', { ...@@ -9,10 +9,35 @@ const RcXxbs = sequelize.define('RcXxbs', {
primaryKey: true, primaryKey: true,
autoIncrement: true autoIncrement: true
}, },
nd: {
type: DataTypes.DATE,
get() {
const rawValue = this.getDataValue('nd');
return rawValue ? moment(rawValue).format('YYYY') : '';
}
},
wjmc: {
type: DataTypes.STRING,
comment: "文件名称",
},
fjsc: {
type: DataTypes.JSON,
comment: "附件上传",
},
bzr: {
type: DataTypes.STRING,
comment: "编制人",
},
bzrbm: {
type: DataTypes.STRING(500),
comment: "编制人部门",
},
sourceId: { sourceId: {
type: DataTypes.INTEGER, type: DataTypes.INTEGER,
comment: "所属主表id" comment: "所属主表id"
...@@ -26,7 +51,7 @@ const RcXxbs = sequelize.define('RcXxbs', { ...@@ -26,7 +51,7 @@ const RcXxbs = sequelize.define('RcXxbs', {
defaultValue: 0, defaultValue: 0,
comment: "0 正常 1 删除" comment: "0 正常 1 删除"
}, },
creator: { creator: {
type: DataTypes.INTEGER, type: DataTypes.INTEGER,
comment: "创建人" comment: "创建人"
}, },
......
...@@ -166,10 +166,11 @@ router.post('/deleteTzgh', projectRcController.deleteTzgh); ...@@ -166,10 +166,11 @@ router.post('/deleteTzgh', projectRcController.deleteTzgh);
//4.4 信息报送 //4.4 信息报送
router.post('/createXxbs', projectRcController.createXxbs);
router.post('/updateXxbs', projectRcController.updateXxbs);
router.post('/getXxbs', projectRcController.getXxbs);
router.post('/getXxbsList', projectRcController.getXxbsList);
router.post('/deleteXxbs', projectRcController.deleteXxbs);
//4.5 投委会管理 //4.5 投委会管理
router.post('/createTwhgl', projectRcController.createTwhgl); router.post('/createTwhgl', projectRcController.createTwhgl);
router.post('/updateTwhgl', projectRcController.updateTwhgl); router.post('/updateTwhgl', projectRcController.updateTwhgl);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment