diff --git a/myJavaScript.js b/myJavaScript.js new file mode 100644 index 0000000..3cf09f4 --- /dev/null +++ b/myJavaScript.js @@ -0,0 +1,37 @@ +async function longStringSplit(string) { + let strExcerpt = string.replaceAll("'", "''"); + let uuid = getCurrentDateTime() + " " + generateUUID(); + let i = 1; + while (strExcerpt.length > 0) { + let res = await $.post(`/api/esb/oa/execute?eventkey=LongStringSplit¶ms={"uuid":"${uuid}","excerpt":"${strExcerpt.slice(0, 500)}","order":${i},"maxRunNum":3}`); + strExcerpt = strExcerpt.slice(500); + i++; + if (JSON.parse(res).flag == 0) { + alert("LongStringSplit接口有误,请联系管理员!"); + return null; + } + } + return uuid; +} + +function generateUUID() { + return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) { + const r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8); + return v.toString(16); + }); +} + +function getCurrentDateTime() { + const now = new Date(); + const pad = num => String(num).padStart(2, '0'); + const formattedDateTime = `${now.getFullYear()}-${pad(now.getMonth() + 1)}-${pad(now.getDate())} ${pad(now.getHours())}:${pad(now.getMinutes())}:${pad(now.getSeconds())}`; + return formattedDateTime; +} + +function detailresFromESBFormat(str, attr_name) { + let res = []; + JSON.parse(str)[attr_name].forEach(res_i => { + res.push(JSON.parse(res_i)); + }); + return res; +} \ No newline at end of file