|
@@ -70,6 +70,7 @@ module.exports = app => {
|
|
|
tmp.tender_id = tenderId;
|
|
|
delete tmp.id;
|
|
|
delete tmp.pid;
|
|
|
+ tmp.id = this.uuid.v4();
|
|
|
insertData.push(tmp);
|
|
|
}
|
|
|
const operate = await transaction.insert(this.tableName, insertData);
|
|
@@ -180,7 +181,9 @@ module.exports = app => {
|
|
|
const [sql, sqlParam] = this.sqlBuilder.build(this.tableName);
|
|
|
const data = await this.db.query(sql, sqlParam);
|
|
|
|
|
|
- return data;
|
|
|
+ return this._.sortBy(data, function (d) {
|
|
|
+ return nodesIds.indexOf(d.ledger_id);
|
|
|
+ });
|
|
|
}
|
|
|
/**
|
|
|
* 根据主键id获取数据
|
|
@@ -624,6 +627,7 @@ module.exports = app => {
|
|
|
this.cache.set(cacheKey, maxId, 'EX', this.ctx.app.config.cacheTime);
|
|
|
}
|
|
|
|
|
|
+ data.id = this.uuid.v4();
|
|
|
data.tender_id = tenderId;
|
|
|
data.ledger_id = maxId + 1;
|
|
|
data.ledger_pid = selectData.ledger_pid;
|
|
@@ -661,6 +665,7 @@ module.exports = app => {
|
|
|
}
|
|
|
this.cache.set(cacheKey, maxId + 1, 'EX', this.ctx.app.config.cacheTime);
|
|
|
|
|
|
+ data.id = this.uuid.v4();
|
|
|
data.tender_id = tenderId;
|
|
|
data.ledger_id = maxId + 1;
|
|
|
data.ledger_pid = pid;
|
|
@@ -804,6 +809,7 @@ module.exports = app => {
|
|
|
this.cache.set(cacheKey, maxId, 'EX', this.ctx.app.config.cacheTime);
|
|
|
}
|
|
|
|
|
|
+ data.id = this.uuid.v4();
|
|
|
data.tender_id = tenderId;
|
|
|
data.ledger_id = maxId + 1;
|
|
|
data.ledger_pid = selectData.ledger_id;
|
|
@@ -1516,8 +1522,10 @@ module.exports = app => {
|
|
|
// 选中节点的所有后兄弟节点,order+粘贴节点个数
|
|
|
await this._updateSelectNextsOrder(selectData, copyNodes.length);
|
|
|
// 数据库创建新增节点数据
|
|
|
- for (const node of copyNodes) {
|
|
|
- const datas = await this.getDataByFullPath(tenderId, node.full_path + '%');
|
|
|
+ for (let iNode = 0; iNode < copyNodes.length; iNode++) {
|
|
|
+ const node = copyNodes[iNode];
|
|
|
+ let datas = await this.getDataByFullPath(tenderId, node.full_path + '%');
|
|
|
+ datas = this._.sortBy(datas, 'level');
|
|
|
|
|
|
const cacheKey = keyPre + this.ctx.tender.id;
|
|
|
let maxId = parseInt(await this.cache.get(cacheKey));
|
|
@@ -1534,7 +1542,8 @@ module.exports = app => {
|
|
|
const idChange = {
|
|
|
org: data.id,
|
|
|
};
|
|
|
- delete data.id;
|
|
|
+ data.id = this.uuid.v4();
|
|
|
+ idChange.new = data.id;
|
|
|
data.tender_id = this.ctx.tender.id;
|
|
|
if (!data.is_leaf) {
|
|
|
for (const children of datas) {
|
|
@@ -1548,18 +1557,17 @@ module.exports = app => {
|
|
|
}
|
|
|
data.ledger_id = newId;
|
|
|
data.full_path = data.full_path.replace(orgParentPath, newParentPath);
|
|
|
- if (data.ledger_pid === copyNodes[0].ledger_pid) {
|
|
|
+ if (data.ledger_pid === node.ledger_pid) {
|
|
|
data.ledger_pid = selectData.ledger_pid;
|
|
|
- data.order = selectData.order + index + 1;
|
|
|
+ data.order = selectData.order + iNode + 1;
|
|
|
}
|
|
|
data.level = data.level + selectData.level - copyNodes[0].level;
|
|
|
- const newData = await this.transaction.insert(this.tableName, data);
|
|
|
if (data.is_leaf) {
|
|
|
- idChange.new = newData.insertId;
|
|
|
leafBillsId.push(idChange);
|
|
|
}
|
|
|
- newIds.push(newData.insertId);
|
|
|
+ newIds.push(data.id);
|
|
|
}
|
|
|
+ const newData = await this.transaction.insert(this.tableName, datas);
|
|
|
for (const id of leafBillsId) {
|
|
|
await this.ctx.service.pos.copyBillsPosData(id.org, id.new, this.transaction);
|
|
|
}
|
|
@@ -1809,6 +1817,7 @@ module.exports = app => {
|
|
|
for (let i = 0, iLen = data.length; i < iLen; i++) {
|
|
|
// 合并新增数据
|
|
|
const qd = {
|
|
|
+ id: this.uuid.v4(),
|
|
|
tender_id: tenderId,
|
|
|
ledger_id: maxId + i + 1,
|
|
|
ledger_pid: selectData.ledger_id,
|
|
@@ -1822,8 +1831,7 @@ module.exports = app => {
|
|
|
};
|
|
|
qd.full_path = selectData.full_path + '.' + qd.ledger_id;
|
|
|
const insertResult = await this.transaction.insert(this.tableName, qd);
|
|
|
- qd.id = insertResult.insertId;
|
|
|
- newIds.push(insertResult.insertId);
|
|
|
+ newIds.push(qd.id);
|
|
|
if (data[i].pos.length > 0) {
|
|
|
await this.ctx.service.pos.insertLedgerPosData(this.transaction, tenderId, qd, data[i].pos);
|
|
|
await this._calcNode(qd, this.transaction);
|
|
@@ -1882,6 +1890,7 @@ module.exports = app => {
|
|
|
for (let i = 0, iLen = data.length; i < iLen; i++) {
|
|
|
// 合并新增数据
|
|
|
const qd = {
|
|
|
+ id: this.uuid.v4(),
|
|
|
tender_id: tenderId,
|
|
|
ledger_id: maxId + i + 1,
|
|
|
ledger_pid: parentData.ledger_id,
|
|
@@ -1895,8 +1904,7 @@ module.exports = app => {
|
|
|
};
|
|
|
qd.full_path = parentData.full_path + '.' + qd.ledger_id;
|
|
|
const insertResult = await this.transaction.insert(this.tableName, qd);
|
|
|
- qd.id = insertResult.insertId;
|
|
|
- newIds.push(insertResult.insertId);
|
|
|
+ newIds.push(qd.id);
|
|
|
if (data[i].pos.length > 0) {
|
|
|
await this.ctx.service.pos.insertLedgerPosData(this.transaction, tenderId, qd, data[i].pos);
|
|
|
await this._calcNode(qd, this.transaction);
|
|
@@ -1975,6 +1983,7 @@ module.exports = app => {
|
|
|
|
|
|
async _importCacheTreeNode(transaction, node) {
|
|
|
const data = {
|
|
|
+ id: this.uuid.v4(),
|
|
|
tender_id: this.ctx.tender.id,
|
|
|
ledger_id: node.ledger_id,
|
|
|
ledger_pid: node.ledger_pid,
|
|
@@ -1997,7 +2006,7 @@ module.exports = app => {
|
|
|
drawing_code: node.drawing_code,
|
|
|
};
|
|
|
const result = await transaction.insert(this.tableName, data);
|
|
|
- data.id = result.insertId;
|
|
|
+ //data.id = result.insertId;
|
|
|
if (node.children && node.children.length > 0) {
|
|
|
for (const child of node.children) {
|
|
|
await this._importCacheTreeNode(transaction, child);
|
|
@@ -2007,7 +2016,8 @@ module.exports = app => {
|
|
|
}
|
|
|
if (node.pos && node.pos.length > 0) {
|
|
|
for (const p of node.pos) {
|
|
|
- p.lid = result.insertId;
|
|
|
+ //p.lid = result.insertId;
|
|
|
+ p.lid = node.id;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -2016,6 +2026,7 @@ module.exports = app => {
|
|
|
const datas = [];
|
|
|
for (const node of nodes) {
|
|
|
datas.push({
|
|
|
+ id: this.uuid.v4(),
|
|
|
tender_id: this.ctx.tender.id,
|
|
|
ledger_id: node.ledger_id,
|
|
|
ledger_pid: node.ledger_pid,
|