|
@@ -737,6 +737,8 @@ class GljDao extends OprDao{
|
|
const allGLJs = await gljModel.find({repositoryId: gljLibId}, {ID: true, code: true}).lean();
|
|
const allGLJs = await gljModel.find({repositoryId: gljLibId}, {ID: true, code: true}).lean();
|
|
const codeMapping = {};
|
|
const codeMapping = {};
|
|
allGLJs.forEach(glj => codeMapping[glj.code] = glj);
|
|
allGLJs.forEach(glj => codeMapping[glj.code] = glj);
|
|
|
|
+ const updateGLJs = [];
|
|
|
|
+ //const forTest = [];
|
|
// 跳过列头
|
|
// 跳过列头
|
|
for (let row = 1; row < sheetData.length; row++) {
|
|
for (let row = 1; row < sheetData.length; row++) {
|
|
const rowData = sheetData[row];
|
|
const rowData = sheetData[row];
|
|
@@ -751,6 +753,11 @@ class GljDao extends OprDao{
|
|
if (!glj.component) {
|
|
if (!glj.component) {
|
|
glj.component = [];
|
|
glj.component = [];
|
|
}
|
|
}
|
|
|
|
+ const componentIsExist = glj.component.some(item => item.ID === component.ID);
|
|
|
|
+ if (componentIsExist) {
|
|
|
|
+ //forTest.push(code);
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
const componentGLJ = { ID: component.ID };
|
|
const componentGLJ = { ID: component.ID };
|
|
if (multiConsumeAmt.length) { // 多消耗量
|
|
if (multiConsumeAmt.length) { // 多消耗量
|
|
const consumeAmtProperty = {};
|
|
const consumeAmtProperty = {};
|
|
@@ -762,10 +769,15 @@ class GljDao extends OprDao{
|
|
componentGLJ.consumeAmt = +rowData[colMapping.consumeAmt]
|
|
componentGLJ.consumeAmt = +rowData[colMapping.consumeAmt]
|
|
}
|
|
}
|
|
glj.component.push(componentGLJ);
|
|
glj.component.push(componentGLJ);
|
|
|
|
+ if (updateGLJs.indexOf(glj) < 0) {
|
|
|
|
+ updateGLJs.push(glj);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
// 更新数据
|
|
// 更新数据
|
|
const tasks = [];
|
|
const tasks = [];
|
|
- allGLJs.filter(glj => glj.component && glj.component.length).forEach(glj => {
|
|
|
|
|
|
+ //console.log(`[new Set(forTest)]`);
|
|
|
|
+ //console.log([new Set(forTest)]);
|
|
|
|
+ updateGLJs.filter(glj => glj.component && glj.component.length).forEach(glj => {
|
|
tasks.push({
|
|
tasks.push({
|
|
updateOne: {
|
|
updateOne: {
|
|
filter: {
|
|
filter: {
|