Compare commits
1 Commits
Author | SHA1 | Date |
---|---|---|
Javi Gallego | 327406a955 |
|
@ -0,0 +1,25 @@
|
||||||
|
{
|
||||||
|
// Use IntelliSense to learn about possible Node.js debug attributes.
|
||||||
|
// Hover to view descriptions of existing attributes.
|
||||||
|
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||||
|
"version": "0.2.0",
|
||||||
|
"configurations": [
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
"type": "node",
|
||||||
|
"request": "launch",
|
||||||
|
"name": "Iniciar programa",
|
||||||
|
"program": "${file}",
|
||||||
|
"outFiles": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "node",
|
||||||
|
"request": "attach",
|
||||||
|
"name": "Asociar al puerto",
|
||||||
|
"address": "localhost",
|
||||||
|
"port": 5858,
|
||||||
|
"outFiles": []
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
|
@ -0,0 +1,12 @@
|
||||||
|
var db = require('node-mysql');
|
||||||
|
var config = require('./config.json');
|
||||||
|
|
||||||
|
var vnConn = new db.DB({
|
||||||
|
host : config.mySqlHost,
|
||||||
|
user : config.mySqlUser,
|
||||||
|
password : config.mySqlPass,
|
||||||
|
port: config.mySqlPort,
|
||||||
|
database : config.mySqlDatabase
|
||||||
|
});
|
||||||
|
|
||||||
|
exports.vnConn = vnConn;
|
|
@ -0,0 +1,22 @@
|
||||||
|
var connection = require('./connection');
|
||||||
|
var queries = require('./queries');
|
||||||
|
|
||||||
|
function objectToTable(supplyResponse){
|
||||||
|
|
||||||
|
connection.vnConn.connect(function(conn, cb) {
|
||||||
|
var sql = queries.getInsertSupply();
|
||||||
|
var insertRows = queries.getValuesSupply(supplyResponse);
|
||||||
|
|
||||||
|
conn.query(sql,[insertRows],
|
||||||
|
function(res, rows, fields) {
|
||||||
|
console.log(rows);
|
||||||
|
cb();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}, function(err){
|
||||||
|
console.log('ao');
|
||||||
|
console.log(err.message);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
exports.objectToTable = objectToTable;
|
|
@ -7,6 +7,7 @@
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"fecha": "^2.3.0",
|
"fecha": "^2.3.0",
|
||||||
"jsdom": "^9.12.0",
|
"jsdom": "^9.12.0",
|
||||||
|
"node-mysql": "^0.4.2",
|
||||||
"soap": "^0.19.0",
|
"soap": "^0.19.0",
|
||||||
"xml2js": "^0.4.17"
|
"xml2js": "^0.4.17"
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,43 @@
|
||||||
|
|
||||||
|
function getInsertSupply(){
|
||||||
|
var sql = `INSERT INTO edi.supplyResponse( \
|
||||||
|
marketPlace, \
|
||||||
|
imageReference, \
|
||||||
|
supplierParty, \
|
||||||
|
productVnhCode, \
|
||||||
|
productDescription, \
|
||||||
|
quantity, \
|
||||||
|
incrementalOrderableQuantity, \
|
||||||
|
chargeAmount, \
|
||||||
|
unitCode, \
|
||||||
|
packageQuantity, \
|
||||||
|
earliestDespatch, \
|
||||||
|
latestDelivery, \
|
||||||
|
) VALUES ?`;
|
||||||
|
return sql;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getValuesSupply(supplyResponse){
|
||||||
|
var insertRows = [];
|
||||||
|
for (let aux of supplyResponse.Body.SupplyResponseDetails.SupplyTradeLineItem){
|
||||||
|
insertRows.push(
|
||||||
|
[
|
||||||
|
aux.ID._,
|
||||||
|
aux.TradingTerms.MarketPlace.ID._,
|
||||||
|
aux.SupplierParty.PrimaryID._ ,
|
||||||
|
aux.Product.IndustryAssignedID._,
|
||||||
|
aux.Product.DescriptionText._,
|
||||||
|
aux.Quantity._,
|
||||||
|
aux.IncrementalOrderableQuantity._,
|
||||||
|
aux.Price.ChargeAmount._,
|
||||||
|
aux.Quantity.$.unitCode,
|
||||||
|
aux.Packing.Package.Quantity._,
|
||||||
|
aux.Delivery[0].LatestDeliveryDateTime,
|
||||||
|
aux.Delivery[0].LatestDeliveryDateTime
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
return insertRows;
|
||||||
|
}
|
||||||
|
|
||||||
|
exports.getInsertSupply = getInsertSupply;
|
||||||
|
exports.getValuesSupply = getValuesSupply;
|
|
@ -1,8 +1,9 @@
|
||||||
var querystring = require("querystring");
|
|
||||||
var xml2js = require('xml2js');
|
var xml2js = require('xml2js');
|
||||||
var soap = require('soap');
|
|
||||||
var IOXml = require('./IOXml');
|
var IOXml = require('./IOXml');
|
||||||
var config = require('./config.json');
|
var config = require('./config.json');
|
||||||
|
var soap = require('soap');
|
||||||
|
var objectToTable = require('./objectToTable');
|
||||||
|
|
||||||
function soapClient(xmlFile){
|
function soapClient(xmlFile){
|
||||||
var url = 'http://services2-acc.floraholland.com/CommercialCustomer/CommercialCustomer_1p5.svc?wsdl';
|
var url = 'http://services2-acc.floraholland.com/CommercialCustomer/CommercialCustomer_1p5.svc?wsdl';
|
||||||
|
@ -38,20 +39,17 @@ function soapClient(xmlFile){
|
||||||
depth:null,
|
depth:null,
|
||||||
colors:true
|
colors:true
|
||||||
});
|
});
|
||||||
console.log('GetSupply');
|
|
||||||
console.log(result);
|
|
||||||
console.log(result.SupplyRequest);
|
|
||||||
client.GetSupply(result.SupplyRequest,function(err, supply) {
|
client.GetSupply(result.SupplyRequest,function(err, supply) {
|
||||||
console.log('last request: ', client.lastRequest)
|
objectToTable.objectToTable(supply);
|
||||||
if (err) {
|
if (err) {
|
||||||
console.log(err.message);
|
console.log(err.message);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var builder = new xml2js.Builder();
|
/* var builder = new xml2js.Builder();
|
||||||
var fileContent = builder.buildObject(supply);
|
var fileContent = builder.buildObject(supply);
|
||||||
IOXml.setXml('/xml_buyer/supplyresponse_getall.xml',fileContent,function(){
|
IOXml.setXml('/xml_buyer/supplyresponse_getall.xml',fileContent,function(){
|
||||||
console.log('archivo creado');
|
console.log('archivo creado');
|
||||||
});
|
});*/
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue