添加设备管理功能以及任务分发功能
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
package com.ruoyi.web.controller.af;
|
||||
|
||||
import java.util.List;
|
||||
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.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.system.domain.af.AfDevice;
|
||||
import com.ruoyi.system.service.af.IAfDeviceService;
|
||||
|
||||
/**
|
||||
* 自动充值设备控制器
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/af/device")
|
||||
public class AfDeviceController extends BaseController
|
||||
{
|
||||
@Autowired
|
||||
private IAfDeviceService deviceService;
|
||||
|
||||
/**
|
||||
* 查询设备列表。
|
||||
*
|
||||
* @param device 查询条件
|
||||
* @return 分页结果
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('af:device:list')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(AfDevice device)
|
||||
{
|
||||
startPage();
|
||||
List<AfDevice> list = deviceService.selectAfDeviceList(device);
|
||||
return getDataTable(list);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,107 @@
|
||||
package com.ruoyi.web.controller.af;
|
||||
|
||||
import java.util.Map;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
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.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.core.text.Convert;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.system.service.af.IAfDeviceService;
|
||||
import com.ruoyi.system.service.af.IAfTaskService;
|
||||
|
||||
/**
|
||||
* 自动充值移动端接口控制器
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/af/mobile")
|
||||
public class AfMobileController extends BaseController
|
||||
{
|
||||
@Autowired
|
||||
private IAfDeviceService deviceService;
|
||||
|
||||
@Autowired
|
||||
private IAfTaskService taskService;
|
||||
|
||||
/**
|
||||
* 移动端自动注册账号设备绑定。
|
||||
*
|
||||
* @param body 请求体
|
||||
* @return 注册结果
|
||||
*/
|
||||
@PostMapping("/device/register")
|
||||
public AjaxResult registerDevice(@RequestBody Map<String, Object> body)
|
||||
{
|
||||
String userName = resolveUserName(body);
|
||||
String deviceCode = Convert.toStr(body.get("deviceCode"));
|
||||
return success(deviceService.registerOrUpdateDevice(userName, deviceCode, userName));
|
||||
}
|
||||
|
||||
/**
|
||||
* 移动端上报设备心跳。
|
||||
*
|
||||
* @param body 请求体
|
||||
* @return 心跳结果
|
||||
*/
|
||||
@PostMapping("/device/heartbeat")
|
||||
public AjaxResult heartbeat(@RequestBody Map<String, Object> body)
|
||||
{
|
||||
String userName = resolveUserName(body);
|
||||
String deviceCode = Convert.toStr(body.get("deviceCode"));
|
||||
String taskStatus = Convert.toStr(body.get("taskStatus"));
|
||||
Long currentTaskId = Convert.toLong(body.get("currentTaskId"));
|
||||
return success(deviceService.heartbeat(userName, deviceCode, taskStatus, currentTaskId, userName));
|
||||
}
|
||||
|
||||
/**
|
||||
* 移动端拉取任务。
|
||||
*
|
||||
* @param deviceCode 设备编码
|
||||
* @return 任务载荷
|
||||
*/
|
||||
@GetMapping("/task/pull")
|
||||
public AjaxResult pullTask(String deviceCode)
|
||||
{
|
||||
String userName = getUsername();
|
||||
return success(taskService.pullTask(userName, deviceCode));
|
||||
}
|
||||
|
||||
/**
|
||||
* 移动端确认接收任务。
|
||||
*
|
||||
* @param body 请求体
|
||||
* @return 处理结果
|
||||
*/
|
||||
@PostMapping("/task/receive")
|
||||
public AjaxResult receiveTask(@RequestBody Map<String, Object> body)
|
||||
{
|
||||
Long taskId = Convert.toLong(body.get("taskId"));
|
||||
String userName = resolveUserName(body);
|
||||
String deviceCode = Convert.toStr(body.get("deviceCode"));
|
||||
taskService.receiveTask(taskId, userName, deviceCode, userName);
|
||||
return success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 解析当前请求中的账号名。
|
||||
*
|
||||
* @param body 请求体
|
||||
* @return 账号名
|
||||
*/
|
||||
private String resolveUserName(Map<String, Object> body)
|
||||
{
|
||||
String loginUserName = getUsername();
|
||||
if (StringUtils.isNotEmpty(loginUserName))
|
||||
{
|
||||
return loginUserName;
|
||||
}
|
||||
String requestUserName = Convert.toStr(body.get("userName"));
|
||||
return requestUserName;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,124 @@
|
||||
package com.ruoyi.web.controller.af;
|
||||
|
||||
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.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.common.core.text.Convert;
|
||||
import com.ruoyi.system.domain.af.AfOrder;
|
||||
import com.ruoyi.system.service.af.IAfDispatchService;
|
||||
import com.ruoyi.system.service.af.IAfOrderService;
|
||||
|
||||
/**
|
||||
* 自动充值订单控制器
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/af/order")
|
||||
public class AfOrderController extends BaseController
|
||||
{
|
||||
@Autowired
|
||||
private IAfOrderService orderService;
|
||||
|
||||
@Autowired
|
||||
private IAfDispatchService dispatchService;
|
||||
|
||||
/**
|
||||
* 查询订单列表。
|
||||
*
|
||||
* @param order 查询条件
|
||||
* @return 分页结果
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('af:order:list')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(AfOrder order)
|
||||
{
|
||||
startPage();
|
||||
List<AfOrder> list = orderService.selectAfOrderList(order);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询订单详情。
|
||||
*
|
||||
* @param orderId 订单ID
|
||||
* @return 详情
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('af:order:query')")
|
||||
@GetMapping("/{orderId}")
|
||||
public AjaxResult getInfo(@PathVariable Long orderId)
|
||||
{
|
||||
return success(orderService.selectAfOrderById(orderId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 手动分发订单。
|
||||
*
|
||||
* @param body 请求体
|
||||
* @return 分发结果
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('af:order:dispatch')")
|
||||
@PostMapping("/dispatch/manual")
|
||||
public AjaxResult manualDispatch(@RequestBody Map<String, Object> body)
|
||||
{
|
||||
Long orderId = Convert.toLong(body.get("orderId"));
|
||||
Long deviceId = Convert.toLong(body.get("deviceId"));
|
||||
return success(dispatchService.manualDispatch(orderId, deviceId, getUsername()));
|
||||
}
|
||||
|
||||
/**
|
||||
* 手动触发一轮自动分发。
|
||||
*
|
||||
* @param body 请求体
|
||||
* @return 触发结果
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('af:order:dispatch')")
|
||||
@PostMapping("/dispatch/auto")
|
||||
public AjaxResult autoDispatch(@RequestBody(required = false) Map<String, Object> body)
|
||||
{
|
||||
Integer limit = body == null ? null : Convert.toInt(body.get("limit"));
|
||||
int dispatchedCount = dispatchService.autoDispatch(limit, getUsername());
|
||||
AjaxResult result = success();
|
||||
result.put("dispatchedCount", dispatchedCount);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 取消订单。
|
||||
*
|
||||
* @param body 请求体
|
||||
* @return 处理结果
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('af:order:cancel')")
|
||||
@PostMapping("/cancel")
|
||||
public AjaxResult cancel(@RequestBody Map<String, Object> body)
|
||||
{
|
||||
Long orderId = Convert.toLong(body.get("orderId"));
|
||||
String failReason = Convert.toStr(body.get("failReason"));
|
||||
return toAjax(orderService.cancelOrder(orderId, failReason, getUsername()));
|
||||
}
|
||||
|
||||
/**
|
||||
* 重试订单。
|
||||
*
|
||||
* @param body 请求体
|
||||
* @return 处理结果
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('af:order:retry')")
|
||||
@PostMapping("/retry")
|
||||
public AjaxResult retry(@RequestBody Map<String, Object> body)
|
||||
{
|
||||
Long orderId = Convert.toLong(body.get("orderId"));
|
||||
return toAjax(orderService.retryOrder(orderId, getUsername()));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
package com.ruoyi.web.controller.af;
|
||||
|
||||
import java.util.List;
|
||||
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.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.system.domain.af.AfDispatchTask;
|
||||
import com.ruoyi.system.domain.af.AfTaskStepLog;
|
||||
import com.ruoyi.system.service.af.IAfTaskService;
|
||||
|
||||
/**
|
||||
* 自动充值任务控制器
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/af/task")
|
||||
public class AfTaskController extends BaseController
|
||||
{
|
||||
@Autowired
|
||||
private IAfTaskService taskService;
|
||||
|
||||
/**
|
||||
* 查询任务列表。
|
||||
*
|
||||
* @param task 查询条件
|
||||
* @return 分页结果
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('af:task:list')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(AfDispatchTask task)
|
||||
{
|
||||
startPage();
|
||||
List<AfDispatchTask> list = taskService.selectAfDispatchTaskList(task);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询任务详情。
|
||||
*
|
||||
* @param taskId 任务ID
|
||||
* @return 详情
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('af:task:query')")
|
||||
@GetMapping("/{taskId}")
|
||||
public AjaxResult getInfo(@PathVariable Long taskId)
|
||||
{
|
||||
return success(taskService.selectAfDispatchTaskById(taskId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询任务步骤日志。
|
||||
*
|
||||
* @param taskId 任务ID
|
||||
* @return 日志列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('af:task:logs')")
|
||||
@GetMapping("/{taskId}/logs")
|
||||
public AjaxResult logs(@PathVariable Long taskId)
|
||||
{
|
||||
List<AfTaskStepLog> logs = taskService.selectTaskStepLogs(taskId);
|
||||
return success(logs);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user