增加异常订单功能
This commit is contained in:
+114
@@ -0,0 +1,114 @@
|
||||
package com.ruoyi.web.controller.monitor;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
import com.ruoyi.price.domain.PrcBillingTask;
|
||||
import com.ruoyi.price.enums.BillTaskSuccessStatus;
|
||||
import com.ruoyi.price.service.IPrcBillingTaskService;
|
||||
|
||||
/**
|
||||
* Monitor: failed / waiting prc_billing_task list and manual resync.
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/monitor/billingTask")
|
||||
public class BillingTaskMonitorController extends BaseController
|
||||
{
|
||||
@Autowired
|
||||
private IPrcBillingTaskService billingTaskService;
|
||||
|
||||
/** Default list = FAILED abnormal tasks. */
|
||||
@PreAuthorize("@ss.hasPermi('monitor:billingTask:list')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(PrcBillingTask query)
|
||||
{
|
||||
if (query.getSuccessStatus() == null || query.getSuccessStatus().isEmpty())
|
||||
{
|
||||
query.setSuccessStatus(BillTaskSuccessStatus.FAILED.getCode());
|
||||
}
|
||||
else if ("ALL".equalsIgnoreCase(query.getSuccessStatus()))
|
||||
{
|
||||
query.setSuccessStatus(null);
|
||||
}
|
||||
startPage();
|
||||
List<PrcBillingTask> list = billingTaskService.selectList(query);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
@PreAuthorize("@ss.hasPermi('monitor:billingTask:list')")
|
||||
@GetMapping("/{taskId}")
|
||||
public AjaxResult getInfo(@PathVariable("taskId") Long taskId)
|
||||
{
|
||||
return success(billingTaskService.getById(taskId));
|
||||
}
|
||||
|
||||
/** Manual resync one task (reset WAITING then process). */
|
||||
@PreAuthorize("@ss.hasPermi('monitor:billingTask:retry')")
|
||||
@Log(title = "billing task retry", businessType = BusinessType.UPDATE)
|
||||
@PostMapping("/retry/{taskId}")
|
||||
public AjaxResult retry(@PathVariable("taskId") Long taskId)
|
||||
{
|
||||
return success(billingTaskService.retryTask(taskId));
|
||||
}
|
||||
|
||||
/** Manual resync selected tasks. */
|
||||
@PreAuthorize("@ss.hasPermi('monitor:billingTask:retry')")
|
||||
@Log(title = "billing task batch retry", businessType = BusinessType.UPDATE)
|
||||
@PostMapping("/retry")
|
||||
public AjaxResult retryBatch(@RequestBody Long[] taskIds)
|
||||
{
|
||||
if (taskIds == null || taskIds.length == 0)
|
||||
{
|
||||
return error("taskIds required");
|
||||
}
|
||||
int ok = 0;
|
||||
int fail = 0;
|
||||
List<Map<String, Object>> details = new ArrayList<Map<String, Object>>();
|
||||
for (Long taskId : taskIds)
|
||||
{
|
||||
Map<String, Object> row = new HashMap<String, Object>();
|
||||
row.put("taskId", taskId);
|
||||
try
|
||||
{
|
||||
PrcBillingTask task = billingTaskService.retryTask(taskId);
|
||||
row.put("successStatus", task == null ? null : task.getSuccessStatus());
|
||||
row.put("errorMessage", task == null ? null : task.getErrorMessage());
|
||||
if (task != null && BillTaskSuccessStatus.SUCCESS.getCode().equals(task.getSuccessStatus()))
|
||||
{
|
||||
ok++;
|
||||
}
|
||||
else
|
||||
{
|
||||
fail++;
|
||||
}
|
||||
details.add(row);
|
||||
}
|
||||
catch (RuntimeException e)
|
||||
{
|
||||
fail++;
|
||||
row.put("successStatus", "ERROR");
|
||||
row.put("errorMessage", e.getMessage());
|
||||
details.add(row);
|
||||
}
|
||||
}
|
||||
Map<String, Object> data = new HashMap<String, Object>();
|
||||
data.put("ok", Integer.valueOf(ok));
|
||||
data.put("fail", Integer.valueOf(fail));
|
||||
data.put("details", details);
|
||||
return success(data);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user