Commit 5198016b208c814a7aff443a35cfb556c0e7db62
1 parent
d46c5802
Exists in
master
and in
1 other branch
update build message
Showing
3 changed files
with
140 additions
and
43 deletions
Show diff stats
ais-structure/src/modules/customer/postCustomer.ctrl.js
@@ -36,7 +36,8 @@ exports.postCustomer = async function (req, res, next){ | @@ -36,7 +36,8 @@ exports.postCustomer = async function (req, res, next){ | ||
36 | if(resultObj.resultCode.startsWith("40")) | 36 | if(resultObj.resultCode.startsWith("40")) |
37 | { | 37 | { |
38 | if(resultObj.resultCode != "40401") | 38 | if(resultObj.resultCode != "40401") |
39 | - resultObj.resultCode = "50000"; | 39 | + resultObj.resultCode = "50000"; |
40 | + | ||
40 | 41 | ||
41 | } | 42 | } |
42 | 43 |
ais-structure/src/modules/helper/connection.js
@@ -7,21 +7,22 @@ var messageSOAP = require('../helper/messageSOAP.js'); | @@ -7,21 +7,22 @@ var messageSOAP = require('../helper/messageSOAP.js'); | ||
7 | var connection = []; | 7 | var connection = []; |
8 | 8 | ||
9 | 9 | ||
10 | -connection.requestSoapToSPW = async function (soap,cmd,myMethod) { | 10 | +connection.requestSoapToSACF = async function (soap,cmd,myMethod) { |
11 | 11 | ||
12 | var params = { | 12 | var params = { |
13 | - url : cfg.service.SPW[myMethod+"_"+cmd+"_URL"], | 13 | + url : cfg.service.SACF[myMethod+"_"+cmd+"_URL"], |
14 | body : messageSOAP.objectToSOAP(soap,cmd), | 14 | body : messageSOAP.objectToSOAP(soap,cmd), |
15 | method : myMethod | 15 | method : myMethod |
16 | } | 16 | } |
17 | 17 | ||
18 | - return asyncRequest(params,cmd,cfg.service.SPW.Name); | 18 | + return asyncRequest(params,cmd,cfg.service.SACF.Name); |
19 | }; | 19 | }; |
20 | connection.requestJsonToD01 = async function (obj,cmd,myMethod) { | 20 | connection.requestJsonToD01 = async function (obj,cmd,myMethod) { |
21 | 21 | ||
22 | + var service = cfg.service.D01; | ||
22 | // JSON.stringify(json) | 23 | // JSON.stringify(json) |
23 | var params = { | 24 | var params = { |
24 | - url : cfg.service.D01[myMethod+"_"+cmd+"_URL"], | 25 | + url : service[myMethod+"_"+cmd+"_URL"], |
25 | body : obj, | 26 | body : obj, |
26 | method : myMethod | 27 | method : myMethod |
27 | } | 28 | } |
@@ -32,7 +33,7 @@ connection.requestJsonToD01 = async function (obj,cmd,myMethod) { | @@ -32,7 +33,7 @@ connection.requestJsonToD01 = async function (obj,cmd,myMethod) { | ||
32 | 33 | ||
33 | if(params.method == "GET") | 34 | if(params.method == "GET") |
34 | { | 35 | { |
35 | - var genUrl = getUrl(params); | 36 | + var genUrl = getUrl(params,service[myMethod+"_Limit"]); |
36 | // genUrl.push(genUrl[0].replace("8080","8081")); | 37 | // genUrl.push(genUrl[0].replace("8080","8081")); |
37 | if(genUrl.length > 1) | 38 | if(genUrl.length > 1) |
38 | { | 39 | { |
@@ -109,15 +110,17 @@ connection.requestJsonToD01 = async function (obj,cmd,myMethod) { | @@ -109,15 +110,17 @@ connection.requestJsonToD01 = async function (obj,cmd,myMethod) { | ||
109 | params.body = JSON.stringify(params.body); | 110 | params.body = JSON.stringify(params.body); |
110 | 111 | ||
111 | var resultRes = await asyncRequest(params,cmd,cfg.service.D01.Name); | 112 | var resultRes = await asyncRequest(params,cmd,cfg.service.D01.Name); |
112 | - resultRes.body = JSON.parse(resultRes.body) | 113 | + |
114 | + result.response = JSON.parse(resultRes.body); | ||
115 | + // resultRes.body = JSON.parse(resultRes.body); | ||
113 | 116 | ||
114 | - if(resultRes.body.resultCode === "20000"){ | ||
115 | - result.response.resultCode = resultRes.body.resultCode; | ||
116 | - result.response.developerMessage = "Success"; | ||
117 | - } else { | ||
118 | - result.response.resultCode = "50000"; | ||
119 | - result.response.developerMessage = "System error"; | ||
120 | - } | 117 | + // if(resultRes.body.resultCode === "20000"){ |
118 | + // result.response.resultCode = resultRes.body.resultCode; | ||
119 | + // result.response.developerMessage = "Success"; | ||
120 | + // } else { | ||
121 | + // result.response.resultCode = "50000"; | ||
122 | + // result.response.developerMessage = "System error"; | ||
123 | + // } | ||
121 | } | 124 | } |
122 | 125 | ||
123 | // console.log(result); | 126 | // console.log(result); |
@@ -176,15 +179,23 @@ function asyncRequest (params = {},cmd,node) { | @@ -176,15 +179,23 @@ function asyncRequest (params = {},cmd,node) { | ||
176 | }); | 179 | }); |
177 | }; | 180 | }; |
178 | 181 | ||
179 | -function getUrl(params) | 182 | +function getUrl(params,limit) |
180 | { | 183 | { |
181 | var returnData = []; | 184 | var returnData = []; |
182 | var url = params.url; | 185 | var url = params.url; |
183 | var fields = ""; | 186 | var fields = ""; |
184 | - var filter = ""; | ||
185 | - | 187 | + var filter = { |
188 | + base : "", | ||
189 | + multi : [] | ||
190 | + }; | ||
191 | + | ||
186 | 192 | ||
187 | params.body = {}; | 193 | params.body = {}; |
194 | + params.body.a = "aaa"; | ||
195 | + params.body.b = "bbb"; | ||
196 | + params.body.papa = []; | ||
197 | + params.body.papa.push("1"); | ||
198 | + params.body.papa.push("2"); | ||
188 | params.body.commandId = []; | 199 | params.body.commandId = []; |
189 | params.body.commandId.push("1"); | 200 | params.body.commandId.push("1"); |
190 | params.body.commandId.push("2"); | 201 | params.body.commandId.push("2"); |
@@ -193,7 +204,10 @@ function getUrl(params) | @@ -193,7 +204,10 @@ function getUrl(params) | ||
193 | params.body.commandId.push("5"); | 204 | params.body.commandId.push("5"); |
194 | params.body.commandId.push("6"); | 205 | params.body.commandId.push("6"); |
195 | params.body.commandId.push("7"); | 206 | params.body.commandId.push("7"); |
196 | - params.body.commandId.push("8"); | 207 | + params.body.commandId.push("8"); |
208 | + params.body.c = "ccc"; | ||
209 | + | ||
210 | + params.body.fields = "a,b,c,d"; | ||
197 | // console.log(params.body); | 211 | // console.log(params.body); |
198 | if(params.body) | 212 | if(params.body) |
199 | { | 213 | { |
@@ -207,35 +221,67 @@ function getUrl(params) | @@ -207,35 +221,67 @@ function getUrl(params) | ||
207 | 221 | ||
208 | first = false; | 222 | first = false; |
209 | } | 223 | } |
224 | + | ||
225 | + if(first) | ||
226 | + fields = "?limit="+limit; | ||
227 | + else | ||
228 | + fields = "&limit="+limit; | ||
210 | 229 | ||
211 | } | 230 | } |
212 | 231 | ||
213 | - if(filter != "") | 232 | + if(filter.multi.length > 0) |
214 | { | 233 | { |
215 | - var maxFilterLength = cfg.Uri_length - url.length - fields.length + "?filter=(&)".length; | 234 | + //have multi |
216 | 235 | ||
217 | - if(maxFilterLength > filter.length) | ||
218 | - { | ||
219 | - returnData.push(url+"?filter=(&"+filter+")"+fields); | 236 | + var careData = filter.multi[0]; |
237 | + // console.log(freeSpace); | ||
220 | 238 | ||
221 | - }else | 239 | + for(var i=0;i<filter.multi.length;i++) |
222 | { | 240 | { |
223 | - // while(maxFilterLength < filter.length) | ||
224 | - // { | ||
225 | - | ||
226 | - // returnData.push(url+"?filter=(&"+filter+")"+fields); | ||
227 | - // } | 241 | + if(filter.multi[i].length > careData.length) |
242 | + { | ||
243 | + filter.base = filter.base+"(|"+careData.data+")"; | ||
244 | + careData = filter.multi[i]; | ||
245 | + | ||
246 | + } | ||
247 | + | ||
228 | 248 | ||
229 | } | 249 | } |
250 | + | ||
251 | + | ||
252 | + var myUrl = url+"?filter=("+filter.base+")"+fields; | ||
253 | + var freeSpace = cfg.Uri_length - myUrl.length; | ||
230 | 254 | ||
231 | - } | ||
232 | - | ||
233 | 255 | ||
256 | + var arr = careData.data.split(")("); | ||
257 | + | ||
258 | + for(var j=0;j<arr.length;j++) | ||
259 | + { | ||
260 | + if(j==0) | ||
261 | + arr[j] = arr[j].substring(1); | ||
262 | + if(j==arr.length-1) | ||
263 | + arr[j] = arr[j].substring(0,arr[j].length-1); | ||
264 | + | ||
265 | + arr[j] = "("+arr[j]+")"; | ||
266 | + // returnData.push(url+"?filter=("+newBasefilter+"(|"+arr[j]+")"+fields); | ||
267 | + } | ||
268 | + | ||
269 | + returnData = arrayUrl(returnData,url,filter.base,fields,freeSpace,arr); | ||
270 | + | ||
271 | + | ||
272 | + | ||
273 | + }else | ||
274 | + { | ||
275 | + var myUrl = url+"?filter=("+filter.base+")"+fields; | ||
276 | + returnData.push(myUrl); | ||
277 | + } | ||
234 | 278 | ||
235 | // console.log(url); | 279 | // console.log(url); |
236 | - console.log(filter); | 280 | + // console.log(filter); |
237 | // console.log(fields); | 281 | // console.log(fields); |
238 | 282 | ||
283 | + console.log(returnData); | ||
284 | + | ||
239 | return returnData; | 285 | return returnData; |
240 | } | 286 | } |
241 | 287 | ||
@@ -253,20 +299,70 @@ function getFields(fields,first) | @@ -253,20 +299,70 @@ function getFields(fields,first) | ||
253 | return returnData; | 299 | return returnData; |
254 | } | 300 | } |
255 | 301 | ||
256 | -function getfilter(filter,key,newfilter) | 302 | +function getfilter(filter,key,data) |
257 | { | 303 | { |
258 | - var returnData = ""; | ||
259 | - console.log(key); | ||
260 | - console.log(newfilter); | ||
261 | - if(!Array.isArray(newfilter)) | ||
262 | - { | ||
263 | - returnData += filter+"("+key+"="+newfilter+")"; | 304 | + |
305 | + // console.log(key); | ||
306 | + // console.log(newfilter); | ||
307 | + if(!Array.isArray(data)) | ||
308 | + { | ||
309 | + | ||
310 | + // var newfilter = { | ||
311 | + // data : "("+key+"="+data+")", | ||
312 | + // type : "single", | ||
313 | + // length : ("("+key+"="+data+")").length | ||
314 | + // }; | ||
315 | + | ||
316 | + if(filter.base != "") | ||
317 | + filter.base = filter.base+"("+key+"="+data+")"; | ||
318 | + else | ||
319 | + filter.base = "&"+filter.base+"("+key+"="+data+")"; | ||
264 | }else | 320 | }else |
265 | { | 321 | { |
266 | - for(var i=0;i<newfilter.length;i++) | ||
267 | - returnData += filter+"("+key+"="+newfilter[i]+")"; | 322 | + var line = ""; |
323 | + for(var i=0;i<data.length;i++) | ||
324 | + { | ||
325 | + line += "("+key+"="+data[i]+")"; | ||
326 | + } | ||
327 | + | ||
328 | + var newfilter = { | ||
329 | + data : line, | ||
330 | + length : line.length | ||
331 | + }; | ||
268 | } | 332 | } |
269 | - return returnData; | 333 | + |
334 | + if(newfilter) | ||
335 | + filter.multi.push(newfilter); | ||
336 | + return filter; | ||
337 | +} | ||
338 | + | ||
339 | +function arrayUrl(arrUrl,url,filter,fields,freeSpace,arrData) | ||
340 | +{ | ||
341 | + var loopUrl = ""; | ||
342 | + var loopSpace = freeSpace; | ||
343 | + for(var i=0;i<arrData.length;i++) | ||
344 | + { | ||
345 | + if(loopSpace > (arrData[i].length+3)) | ||
346 | + { | ||
347 | + loopUrl = loopUrl + arrData[i]; | ||
348 | + loopSpace = loopSpace - arrData[i].length; | ||
349 | + }else | ||
350 | + { | ||
351 | + if(loopUrl != "") | ||
352 | + { | ||
353 | + arrUrl.push(url+"?filter=("+filter+"(|"+loopUrl+")"+fields); | ||
354 | + | ||
355 | + loopUrl = arrData[i]; | ||
356 | + loopSpace = freeSpace - arrData[i].length; | ||
357 | + } | ||
358 | + | ||
359 | + } | ||
360 | + | ||
361 | + } | ||
362 | + | ||
363 | + if(loopUrl != "") | ||
364 | + arrUrl.push(url+"?filter=("+filter+"(|"+loopUrl+")"+fields); | ||
365 | + return arrUrl; | ||
270 | } | 366 | } |
271 | 367 | ||
272 | module.exports = connection; | 368 | module.exports = connection; |
273 | \ No newline at end of file | 369 | \ No newline at end of file |
ais-structure/src/modules/helper/responseMsg.js
@@ -43,7 +43,7 @@ responseMsg.direct = function (req,cmd,result,data) | @@ -43,7 +43,7 @@ responseMsg.direct = function (req,cmd,result,data) | ||
43 | { | 43 | { |
44 | var response = { | 44 | var response = { |
45 | resultCode : result.resultCode, | 45 | resultCode : result.resultCode, |
46 | - developerMessage : result.developerMessage | 46 | + developerMessage : result.resultDescription |
47 | }; | 47 | }; |
48 | 48 | ||
49 | 49 |