|
|
@@ -52,6 +52,8 @@ const GandartConstKey = {
|
|
|
CompositeTaskListCache: 'lkIsCompositeTaskListCache',
|
|
|
CompositeMaterialCache: 'lkIsCompositeMaterialCache',
|
|
|
CompositeTaskMode: 'lkGandartCompositeTaskMode',
|
|
|
+ CompositeBatchEnable: 'lkIsCompositeBatchEnable',
|
|
|
+ CompositeBatchGroupCount: 'lkGandartCompositeBatchGroupCount',
|
|
|
};
|
|
|
|
|
|
let gandartToken = lk.getVal(GandartConstKey.Token, '');
|
|
|
@@ -246,6 +248,16 @@ function isTaskNameSearchMode() {
|
|
|
return enabled;
|
|
|
}
|
|
|
|
|
|
+function isCompositeBatchEnable() {
|
|
|
+ let enabled = lk.getVal(GandartConstKey.CompositeBatchEnable);
|
|
|
+ if (!lk.isEmpty(enabled)) {
|
|
|
+ enabled = JSON.parse(enabled);
|
|
|
+ } else {
|
|
|
+ enabled = true;
|
|
|
+ }
|
|
|
+ return enabled;
|
|
|
+}
|
|
|
+
|
|
|
function printMaterialGroupsInfo(materialGroups) {
|
|
|
let detailStr = '组合详情如下:\n';
|
|
|
for (let i = 0; i < materialGroups.length; i++) {
|
|
|
@@ -296,10 +308,6 @@ async function checkGetMaterialDetails(gUsedMaterialDetails, materialDict) {
|
|
|
return gUsedMaterialDetails;
|
|
|
}
|
|
|
|
|
|
-function calcBatComposite() {
|
|
|
-
|
|
|
-}
|
|
|
-
|
|
|
async function tryToExecCompositeTask(taskId, taskInfo = {}) {
|
|
|
if (getCompositeTaskMode() == 1) {
|
|
|
lk.log('开始极速模式执行合成任务');
|
|
|
@@ -384,17 +392,54 @@ function setCompositeTaskMateListForDisplay(validCompositeGroups) {
|
|
|
lk.setVal(GandartConstKey.CompositeTaskMateList, disText);
|
|
|
}
|
|
|
|
|
|
+function getBatchCompositeGroupCount() {
|
|
|
+ let numStr = lk.getVal(GandartConstKey.CompositeBatchGroupCount);
|
|
|
+ if (lk.isEmpty(numStr)) {
|
|
|
+ return 5;
|
|
|
+ }
|
|
|
+ return Number(numStr);
|
|
|
+}
|
|
|
+
|
|
|
async function doExecFinalComposite(taskId, taskInfo, finalGroups) {
|
|
|
let retOrderLst = [];
|
|
|
let retWillDelLst = [];
|
|
|
- for (let i = 0; i < finalGroups.length; i++) {
|
|
|
+ let batchGroupCnt = getBatchCompositeGroupCount();
|
|
|
+ let startIdx = 0;
|
|
|
+ // 检查是否进行多个批量合成
|
|
|
+ if (isCompositeBatchEnable() && finalGroups.length >= batchGroupCnt) {
|
|
|
+ let batchMaxNum = Math.floor(finalGroups.length / batchGroupCnt);
|
|
|
+ for (let i = 0; i < batchMaxNum; i++) {
|
|
|
+ let compositeList = [];
|
|
|
+ for (let j = 0; j < batchGroupCnt; j++) {
|
|
|
+ compositeList.push({
|
|
|
+ materialDetailList: finalGroups[startIdx]
|
|
|
+ });
|
|
|
+ startIdx += 1;
|
|
|
+ }
|
|
|
+ let ret = await confirmCompositeV2(taskId, taskInfo, compositeList);
|
|
|
+ if (ret) {
|
|
|
+ for (let idx = startIdx - batchMaxNum; idx < startIdx; idx++) {
|
|
|
+ retWillDelLst.push(idx);
|
|
|
+ }
|
|
|
+ retOrderLst.push(ret);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 剩下的进行单个合成
|
|
|
+ for (let i = startIdx; i < finalGroups.length; i++) {
|
|
|
let idx = i;
|
|
|
- let ret = await confirmCompositeV2(taskId, taskInfo, finalGroups[i]);
|
|
|
+ let compositeList = [
|
|
|
+ {
|
|
|
+ materialDetailList: finalGroups[i]
|
|
|
+ }
|
|
|
+ ];
|
|
|
+ let ret = await confirmCompositeV2(taskId, taskInfo, compositeList);
|
|
|
if (ret) {
|
|
|
retWillDelLst.push(idx);
|
|
|
retOrderLst.push(ret);
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
if (retOrderLst.length > 0) {
|
|
|
let successCnt = 0;
|
|
|
let noStockCnt = 0;
|
|
|
@@ -417,7 +462,7 @@ async function doExecFinalComposite(taskId, taskInfo, finalGroups) {
|
|
|
let usedGroups = [];
|
|
|
for (let i = retWillDelLst.length - 1; i >= 0; i--) {
|
|
|
let idx = retWillDelLst[i];
|
|
|
- lk.log(`[${id}]编号订单删除`);
|
|
|
+ lk.log(`编号[${id}]一组的材料合成合成销毁删除`);
|
|
|
usedGroups.push(finalGroups[idx]);
|
|
|
finalGroups.splice(idx, 1);
|
|
|
}
|
|
|
@@ -828,7 +873,7 @@ async function getDetailByCasting(castingId, collectionName, pageSize = 50, page
|
|
|
});
|
|
|
}
|
|
|
|
|
|
-async function confirmCompositeV2(taskId, taskInfo, materialDetailList) {
|
|
|
+async function confirmCompositeV2(taskId, taskInfo, compositeList) {
|
|
|
return new Promise((resolve, _reject) => {
|
|
|
try {
|
|
|
const headers = GCommonGandartHeads;
|
|
|
@@ -836,11 +881,7 @@ async function confirmCompositeV2(taskId, taskInfo, materialDetailList) {
|
|
|
headers['Content-Type'] = 'application/json';
|
|
|
let data = {
|
|
|
taskId: Number(taskId),
|
|
|
- compositeList: [
|
|
|
- {
|
|
|
- materialDetailList: materialDetailList
|
|
|
- }
|
|
|
- ],
|
|
|
+ compositeList: compositeList,
|
|
|
};
|
|
|
let body = JSON.stringify(data);
|
|
|
let url = {
|