ForeverSmiYngEcologyKit/myJavaScript.js

37 lines
1.3 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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&params={"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;
}