Archived
2
This commit is contained in:
VLE2FE 2020-08-16 20:01:18 +02:00
parent 11be1f6f5b
commit c6f5186f7e

View File

@ -9,8 +9,8 @@ const _ = require('lodash');
const stages = {
materials: true,
samples: true,
dpt: true
samples: false,
dpt: false
}
const docs = [
@ -30,8 +30,8 @@ const docs = [
const errors = [];
const nmDocs = 'C:\\Users\\vle2fe\\Documents\\Data\\All_200807\\nmDocs'; // NormMaster Documents
const dptFiles = 'C:\\Users\\vle2fe\\Documents\\Data\\All_200807\\DPT'; // Spectrum files
// const host = 'http://localhost:3000';
const host = 'https://definma-api.apps.de1.bosch-iot-cloud.com';
const host = 'http://localhost:3000';
// const host = 'https://definma-api.apps.de1.bosch-iot-cloud.com';
const requiredProperties = ['samplenumber','materialnumber','materialname','supplier','reinforcementmaterial','material','granulate/part','color','charge/batch','comments'];
dict = { // dictionary
'Granulat': 'granulate',
@ -62,7 +62,7 @@ async function main() {
for (let i in docs) {
await importCsv(docs[i]);
await allMaterials();
await saveMaterials();
// await saveMaterials();
}
fs.writeFileSync('./data_import/numberToColor.json', JSON.stringify(numberToColor));
}
@ -651,6 +651,9 @@ async function allMaterials() {
// process all samples
for (let index in data) {
let sample = data[index];
if (sample['materialname'].replace(/\s+/g, '') === 'Latamid66H2G30') {
console.log(sample);
}
if (sample['supplier'] === '') { // empty supplier fields
sample['supplier'] = 'unknown';
}
@ -676,7 +679,7 @@ async function allMaterials() {
}
}
else { // new material
console.info(`MATERIAL LOAD ${index}/${data.length} ${sample['materialname']}`);
// console.info(`MATERIAL LOAD ${index}/${data.length} ${sample['materialname']}`);
materials[sample['materialname']] = {
name: trim(sample['materialname']),
supplier: trim(sample['supplier']),