const fs = require('fs'); const path = require('path'); function main() { const dst = JSON.parse(fs.readFileSync(path.resolve(__dirname, '../public/demodata/stationList.json'))); const src = JSON.parse(fs.readFileSync(path.resolve(__dirname, '../public/data/overviewImageEntity.json'))); const smap = src.result.records.reduce((total, cur) => { total[cur.stcd] = { x: parseInt(cur.x), y: parseInt(cur.y) }; return total }, {}); const sqls = []; dst.data.map(o => { const xy = smap[o.hpCode]; if (xy) { o.ghtX = xy.x; o.ghtY = xy.y; sqls.push(`UPDATE ZHZMKZ.V2_STATION set GHT_X = ${xy.x} and GHT_Y = ${xy.y} WHERE HP_CODE = '${o.hpCode}'`); }; }); // fs.writeFileSync(path.resolve(__dirname, '../public/demodata/stationList.json'), JSON.stringify(dst)) fs.writeFileSync(path.resolve(__dirname, '../public/demodata/stationList.sql'), sqls.join('\r\n')); } main();