修改附加费
This commit is contained in:
@@ -85,6 +85,15 @@ public interface IPrcPriceSetService
|
||||
/** submit async save, return taskId immediately */
|
||||
public String submitSaveAsync(PrcPriceSet set);
|
||||
|
||||
/**
|
||||
* Submit async batch write of detail surcharge snapshots (product-level pick can hit many rows).
|
||||
* @return taskId for polling getSaveTask
|
||||
*/
|
||||
public String submitDetailSurchargeAsync(List<PrcPriceSetDetail> details);
|
||||
|
||||
/** Sync batch update of detail surcharge snapshots */
|
||||
public int batchUpdateDetailSurcharges(List<PrcPriceSetDetail> details);
|
||||
|
||||
/** poll async save progress */
|
||||
public PrcPriceSetSaveTask getSaveTask(String taskId);
|
||||
}
|
||||
|
||||
+33
@@ -125,6 +125,39 @@ public class PrcPriceSetServiceImpl implements IPrcPriceSetService
|
||||
return taskId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String submitDetailSurchargeAsync(List<PrcPriceSetDetail> details)
|
||||
{
|
||||
String taskId = IdUtils.fastSimpleUUID();
|
||||
saveAsyncRunner.put(taskId, PrcPriceSetSaveTask.STATUS_PENDING, 0, "queued", null, null);
|
||||
saveAsyncRunner.runSurchargeBatch(taskId, details);
|
||||
return taskId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int batchUpdateDetailSurcharges(List<PrcPriceSetDetail> details)
|
||||
{
|
||||
if (details == null || details.isEmpty())
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
int rows = 0;
|
||||
for (PrcPriceSetDetail detail : details)
|
||||
{
|
||||
if (detail == null || detail.getPsdId() == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
// Always replace snapshot for this batch API (null would skip in updateDetail)
|
||||
if (detail.getSurcharges() == null)
|
||||
{
|
||||
detail.setSurcharges(new ArrayList<PrcPriceSetVersionSurcharge>());
|
||||
}
|
||||
rows += updateDetail(detail);
|
||||
}
|
||||
return rows;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PrcPriceSetSaveTask getSaveTask(String taskId)
|
||||
{
|
||||
|
||||
+25
@@ -1,5 +1,6 @@
|
||||
package com.ruoyi.price.task;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@@ -9,6 +10,7 @@ import org.springframework.stereotype.Component;
|
||||
import com.ruoyi.common.core.redis.RedisCache;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.price.domain.PrcPriceSet;
|
||||
import com.ruoyi.price.domain.PrcPriceSetDetail;
|
||||
import com.ruoyi.price.domain.PrcPriceSetSaveTask;
|
||||
import com.ruoyi.price.service.IPrcPriceSetService;
|
||||
|
||||
@@ -51,6 +53,29 @@ public class PrcPriceSetSaveAsyncRunner
|
||||
}
|
||||
}
|
||||
|
||||
/** Background write of detail surcharge snapshots for many rows. */
|
||||
@Async("threadPoolTaskExecutor")
|
||||
public void runSurchargeBatch(String taskId, List<PrcPriceSetDetail> details)
|
||||
{
|
||||
try
|
||||
{
|
||||
put(taskId, PrcPriceSetSaveTask.STATUS_RUNNING, 10, "saving surcharges", null, null);
|
||||
int rows = priceSetService.batchUpdateDetailSurcharges(details);
|
||||
put(taskId, PrcPriceSetSaveTask.STATUS_SUCCESS, 100, "done", null, null);
|
||||
log.info("async surcharge batch done, taskId={}, rows={}", taskId, rows);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
log.error("async surcharge batch failed, taskId={}", taskId, e);
|
||||
String msg = e.getMessage();
|
||||
if (StringUtils.isEmpty(msg))
|
||||
{
|
||||
msg = e.getClass().getSimpleName();
|
||||
}
|
||||
put(taskId, PrcPriceSetSaveTask.STATUS_FAIL, 100, "failed", null, msg);
|
||||
}
|
||||
}
|
||||
|
||||
public void put(String taskId, String status, int percent, String message, Long priceSetId, String error)
|
||||
{
|
||||
PrcPriceSetSaveTask task = new PrcPriceSetSaveTask();
|
||||
|
||||
Reference in New Issue
Block a user