明树Git Lab

Commit 44b716e0 authored by zfp1's avatar zfp1

1

parent 0e6aa3c4
Pipeline #106034 passed with stage
in 3 seconds
......@@ -638,21 +638,21 @@ async function createJsqtzjc(req, res, next) {
// newjsqtzjcrcjcs.push(element);
// }
// delete req.body.jsqtzjcrcjcs;
// //专项检查
// let jsqtzjcZxjcs = req.body.jsqtzjcZxjcs || [];
// let newjsqtzjcZxjcs = [];
// for (let index = 0; index < jsqtzjcZxjcs.length; index++) {
// let element = jsqtzjcZxjcs[index];
// element.projectId = req.body.projectId;
// element.fjcl = (element.fjcl || []).map(o => { return o && o.id || o });
// newjsqtzjcZxjcs.push(element);
// }
// delete req.body.jsqtzjcZxjcs;
//专项检查
let jsqtzjcZxjcs = req.body.jsqtzjcZxjcs || [];
let newjsqtzjcZxjcs = [];
for (let index = 0; index < jsqtzjcZxjcs.length; index++) {
let element = jsqtzjcZxjcs[index];
element.projectId = req.body.projectId;
element.fjcl = (element.fjcl || []).map(o => { return o && o.id || o });
newjsqtzjcZxjcs.push(element);
}
delete req.body.jsqtzjcZxjcs;
//创建
await DB.TzJsqtzjcTzfx.bulkCreate(jsqtzjcTzfxs);
// await DB.TzJsqtzjcrcjc.bulkCreate(jsqtzjcrcjcs);
// await DB.TzJsqtzjcZxjc.bulkCreate(jsqtzjcZxjcs);
await DB.TzJsqtzjcZxjc.bulkCreate(jsqtzjcZxjcs);
let ret = await DB.TzJsqtzjc.create(req.body);
return res.sendData(ret);
} catch (error) {
......@@ -692,17 +692,17 @@ async function getJsqtzjcInfo(req, res, next) {
// element.fxcl = await DB.File.findAll({ where: { id: { [Op.in]: element.fxcl } } });
// newjsqtzjcrcjcs.push(element);
// }
// let jsqtzjcZxjcs = await DB.TzJsqtzjcZxjc.findAll({ where: { projectId: jsqtzjc.projectId }, raw: true });
// for (let index = 0; index < jsqtzjcZxjcs.length; index++) {
// const element = jsqtzjcZxjcs[index];
// // fileids.concat(element.fjcl || []);
// element.fjcl = await DB.File.findAll({ where: { id: { [Op.in]: element.fjcl } } });
// newjsqtzjcZxjcs.push(element);
// }
let jsqtzjcZxjcs = await DB.TzJsqtzjcZxjc.findAll({ where: { projectId: jsqtzjc.projectId }, raw: true });
for (let index = 0; index < jsqtzjcZxjcs.length; index++) {
const element = jsqtzjcZxjcs[index];
// fileids.concat(element.fjcl || []);
element.fjcl = await DB.File.findAll({ where: { id: { [Op.in]: element.fjcl } } });
newjsqtzjcZxjcs.push(element);
}
jsqtzjc.jsqtzjcTzfxs = newjsqtzjcTzfxs;
// jsqtzjc.jsqtzjcrcjcs = newjsqtzjcrcjcs;
// jsqtzjc.jsqtzjcZxjcs = newjsqtzjcZxjcs;
jsqtzjc.jsqtzjcZxjcs = newjsqtzjcZxjcs;
return res.sendData(jsqtzjc);
} catch (error) {
......@@ -751,23 +751,23 @@ async function updateJsqtzjc(req, res, next) {
// delete req.body.jsqtzjcrcjcs;
// let jsqtzjcZxjcs = req.body.jsqtzjcZxjcs || [];
// let ids2 = [], newArr2 = [], info2 = [];
// for (let index = 0; index < jsqtzjcZxjcs.length; index++) {
// let element = jsqtzjcZxjcs[index];
// element.projectId = req.body.projectId;
// element.fjcl = (element.fjcl || []).map(o => { return o && o.id || o });
// if (element.id) {
// ids2.push(element.id);
// info2.push(element);
// } else {
// newArr2.push(element);
// }
// }
// await DB.TzJsqtzjcZxjc.destroy({ where: { projectId: req.body.projectId, id: { [Op.notIn]: ids2 } } }); // 删除id不在传入id数组里面的(用户在界面删除的)
// await DB.TzJsqtzjcZxjc.bulkCreate(newArr2);//创建新的 没有id的
// await Promise.all(info2.map(item => { DB.TzJsqtzjcZxjc.update(item, { where: { id: item.id } }) }));
// delete req.body.jsqtzjcZxjcs;
let jsqtzjcZxjcs = req.body.jsqtzjcZxjcs || [];
let ids2 = [], newArr2 = [], info2 = [];
for (let index = 0; index < jsqtzjcZxjcs.length; index++) {
let element = jsqtzjcZxjcs[index];
element.projectId = req.body.projectId;
element.fjcl = (element.fjcl || []).map(o => { return o && o.id || o });
if (element.id) {
ids2.push(element.id);
info2.push(element);
} else {
newArr2.push(element);
}
}
await DB.TzJsqtzjcZxjc.destroy({ where: { projectId: req.body.projectId, id: { [Op.notIn]: ids2 } } }); // 删除id不在传入id数组里面的(用户在界面删除的)
await DB.TzJsqtzjcZxjc.bulkCreate(newArr2);//创建新的 没有id的
await Promise.all(info2.map(item => { DB.TzJsqtzjcZxjc.update(item, { where: { id: item.id } }) }));
delete req.body.jsqtzjcZxjcs;
await DB.TzJsqtzjc.update(req.body, { where: { id: req.body.id } });
return res.sendData({});
......
// const { DataTypes } = require('sequelize');
// const sequelize = require('../index');
// const moment = require('moment');
const { DataTypes } = require('sequelize');
const sequelize = require('../index');
const moment = require('moment');
// //投中管理- 建设期投资检查 ---日常检查 对投资目标偏差每半年进行一次系统盘点,上传分析材料
// const TzJsqtzjcZxjc = sequelize.define('TzJsqtzjcZxjc', {
// id: {
// type: DataTypes.INTEGER,
// primaryKey: true,
// autoIncrement: true
// },
// zxjcfl: {
// type: DataTypes.INTEGER,
// comment: "专项检查分类 1 能建投资检查、2 葛洲坝集团投资检查、3 公司投资检查、4 其他投资检查"
// },
// kssj: {
// type: DataTypes.DATE,
// comment: "开始时间",
// get() {
// const rawValue = this.getDataValue('kssj');
// return rawValue ? moment(rawValue).format('YYYY-MM-DD HH:mm:ss') : '';
// }
// },
// jssj: {
// type: DataTypes.DATE,
// comment: "结束时间",
// get() {
// const rawValue = this.getDataValue('jssj');
// return rawValue ? moment(rawValue).format('YYYY-MM-DD HH:mm:ss') : '';
// }
// },
// fjcl: {
// type: DataTypes.JSON,
// comment: "附件材料"
// },
//投中管理- 建设期投资检查 ---日常检查 对投资目标偏差每半年进行一次系统盘点,上传分析材料
const TzJsqtzjcZxjc = sequelize.define('TzJsqtzjcZxjc', {
id: {
type: DataTypes.INTEGER,
primaryKey: true,
autoIncrement: true
},
zxjcfl: {
type: DataTypes.INTEGER,
comment: "专项检查分类 1 能建投资检查、2 葛洲坝集团投资检查、3 公司投资检查、4 其他投资检查"
},
// kssj: {
// type: DataTypes.DATE,
// comment: "开始时间",
// get() {
// const rawValue = this.getDataValue('kssj');
// return rawValue ? moment(rawValue).format('YYYY-MM-DD HH:mm:ss') : '';
// }
// },
// jssj: {
// type: DataTypes.DATE,
// comment: "结束时间",
// get() {
// const rawValue = this.getDataValue('jssj');
// return rawValue ? moment(rawValue).format('YYYY-MM-DD HH:mm:ss') : '';
// }
// },
jcjg: {
type: DataTypes.TEXT,
comment: "检查结果"
},
zgcsqd: {
type: DataTypes.TEXT,
comment: "整改措施清单"
},
fjcl: {
type: DataTypes.JSON,
comment: "附件材料"
},
// 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_tz_jsqtzjcZxjc', // 指定表名(如果与模型名不同)
// timestamps: true, // 是否自动添加 createdAt 和 updatedAt 字段(覆盖全局设置)
// });
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_tz_jsqtzjcZxjc', // 指定表名(如果与模型名不同)
timestamps: true, // 是否自动添加 createdAt 和 updatedAt 字段(覆盖全局设置)
});
// // 同步模型到数据库(创建表)
// TzJsqtzjcZxjc.sync({
// // force: false,
// // force: true ,//会删除已存在表并重新创建
// alter: true
// })
// .then(() => {
// console.log('TzJsqtzjcZxjc 表同步成功');
// });
// 同步模型到数据库(创建表)
TzJsqtzjcZxjc.sync({
// force: false,
// force: true ,//会删除已存在表并重新创建
alter: true
})
.then(() => {
console.log('TzJsqtzjcZxjc 表同步成功');
});
// module.exports = TzJsqtzjcZxjc;
\ No newline at end of file
module.exports = TzJsqtzjcZxjc;
\ No newline at end of file
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