增加异常订单功能
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);
|
||||
}
|
||||
}
|
||||
+10
@@ -1,5 +1,6 @@
|
||||
package com.ruoyi.price.service;
|
||||
|
||||
import java.util.List;
|
||||
import com.ruoyi.price.domain.PrcBillingTask;
|
||||
import com.ruoyi.price.domain.vo.BillingTaskSubmitRequest;
|
||||
|
||||
@@ -12,4 +13,13 @@ public interface IPrcBillingTaskService
|
||||
void processTask(Long taskId);
|
||||
|
||||
PrcBillingTask getById(Long taskId);
|
||||
|
||||
/** Admin list (failed / waiting / filter). */
|
||||
List<PrcBillingTask> selectList(PrcBillingTask query);
|
||||
|
||||
/**
|
||||
* Manual resync: reset to WAITING then process again.
|
||||
* @return task after retry
|
||||
*/
|
||||
PrcBillingTask retryTask(Long taskId);
|
||||
}
|
||||
|
||||
+36
@@ -2,6 +2,7 @@ package com.ruoyi.price.service.impl;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@@ -255,6 +256,41 @@ public class PrcBillingTaskServiceImpl implements IPrcBillingTaskService
|
||||
return billingTaskMapper.selectPrcBillingTaskById(taskId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PrcBillingTask> selectList(PrcBillingTask query)
|
||||
{
|
||||
return billingTaskMapper.selectPrcBillingTaskList(query);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PrcBillingTask retryTask(Long taskId)
|
||||
{
|
||||
if (taskId == null)
|
||||
{
|
||||
throw new ServiceException("taskId required");
|
||||
}
|
||||
PrcBillingTask task = billingTaskMapper.selectPrcBillingTaskById(taskId);
|
||||
if (task == null)
|
||||
{
|
||||
throw new ServiceException("billing task not found");
|
||||
}
|
||||
String st = task.getSuccessStatus();
|
||||
if (BillTaskSuccessStatus.SUCCESS.getCode().equals(st))
|
||||
{
|
||||
throw new ServiceException("SUCCESS task cannot retry");
|
||||
}
|
||||
// Reset to WAITING so UI reflects re-queue; then sync process (admin expects immediate result).
|
||||
PrcBillingTask reset = new PrcBillingTask();
|
||||
reset.setTaskId(taskId);
|
||||
reset.setSuccessStatus(BillTaskSuccessStatus.WAITING.getCode());
|
||||
reset.setBillId(null);
|
||||
reset.setErrorMessage(null);
|
||||
billingTaskMapper.updateBillingResult(reset);
|
||||
|
||||
processTask(taskId);
|
||||
return billingTaskMapper.selectPrcBillingTaskById(taskId);
|
||||
}
|
||||
|
||||
private BillTaskType resolveAutoType(String transferNo, String trackingNo, String orderNo)
|
||||
{
|
||||
PrcOrderBill existed = null;
|
||||
|
||||
@@ -35,13 +35,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<include refid="selectPrcBillingTaskVo"/>
|
||||
<where>
|
||||
<if test="transferNo != null and transferNo != ''">
|
||||
AND transfer_no = #{transferNo}
|
||||
AND transfer_no like concat('%', #{transferNo}, '%')
|
||||
</if>
|
||||
<if test="trackingNo != null and trackingNo != ''">
|
||||
AND tracking_no = #{trackingNo}
|
||||
AND tracking_no like concat('%', #{trackingNo}, '%')
|
||||
</if>
|
||||
<if test="orderNo != null and orderNo != ''">
|
||||
AND order_no = #{orderNo}
|
||||
AND order_no like concat('%', #{orderNo}, '%')
|
||||
</if>
|
||||
<if test="billType != null and billType != ''">
|
||||
AND bill_type = #{billType}
|
||||
@@ -49,6 +49,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="successStatus != null and successStatus != ''">
|
||||
AND success_status = #{successStatus}
|
||||
</if>
|
||||
<if test="params.beginTime != null and params.beginTime != ''">
|
||||
AND create_time >= #{params.beginTime}
|
||||
</if>
|
||||
<if test="params.endTime != null and params.endTime != ''">
|
||||
AND create_time <= #{params.endTime}
|
||||
</if>
|
||||
</where>
|
||||
order by task_id desc
|
||||
</select>
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
-- Billing task abnormal list under system monitor (parent_id = 2)
|
||||
SET NAMES utf8mb4;
|
||||
|
||||
INSERT INTO sys_menu (menu_id, menu_name, parent_id, order_num, path, component, query, route_name, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, remark)
|
||||
SELECT 2322, N'计费任务异常', 2, 8, 'billingTask', 'monitor/billingTask/index', '', 'BillingTaskMonitor', 1, 0, 'C', '0', '0', 'monitor:billingTask:list', 'bug', 'admin', sysdate(), N'prc_billing_task异常订单,支持手工重新同步'
|
||||
FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM sys_menu WHERE menu_id = 2322 OR perms = 'monitor:billingTask:list');
|
||||
|
||||
INSERT INTO sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time)
|
||||
SELECT 2323, N'查询', 2322, 1, '', NULL, 1, 0, 'F', '0', '0', 'monitor:billingTask:list', '#', 'admin', sysdate()
|
||||
FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM sys_menu WHERE menu_id = 2323);
|
||||
|
||||
INSERT INTO sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, remark)
|
||||
SELECT 2324, N'重新同步', 2322, 2, '', NULL, 1, 0, 'F', '0', '0', 'monitor:billingTask:retry', '#', 'admin', sysdate(), N'手工重试计费任务'
|
||||
FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM sys_menu WHERE menu_id = 2324 OR perms = 'monitor:billingTask:retry');
|
||||
|
||||
INSERT INTO sys_role_menu (role_id, menu_id)
|
||||
SELECT 1, m.menu_id FROM (SELECT 2322 AS menu_id UNION SELECT 2323 UNION SELECT 2324) m
|
||||
WHERE NOT EXISTS (SELECT 1 FROM sys_role_menu rm WHERE rm.role_id = 1 AND rm.menu_id = m.menu_id);
|
||||
Reference in New Issue
Block a user