fix[订单模块]:排队,oss路径,自动任务,订单状态等逻辑
This commit is contained in:
+11
@@ -3,6 +3,7 @@ package com.central.device.controller;
|
||||
import com.alibaba.nacos.shaded.com.google.gson.Gson;
|
||||
import com.alibaba.nacos.shaded.com.google.gson.JsonObject;
|
||||
import com.central.common.model.Result;
|
||||
import com.central.device.feign.OrderCenterService;
|
||||
import com.central.device.message.ControlEnum;
|
||||
import com.central.device.message.ControlMessageConstant;
|
||||
import com.central.device.util.MapUtil;
|
||||
@@ -38,6 +39,9 @@ public class ApiDeviceController {
|
||||
private RequestUtils requestUtils;
|
||||
|
||||
private ControlMessageConstant controlMessageConstant = new ControlMessageConstant();
|
||||
|
||||
@Autowired
|
||||
private OrderCenterService orderCenterService;
|
||||
/**
|
||||
* 获取设备属性
|
||||
*/
|
||||
@@ -66,6 +70,13 @@ public class ApiDeviceController {
|
||||
JsonObject jsonObject;
|
||||
String property = MapUtil.getStrValue(param, "control");
|
||||
String value = MapUtil.getStrValue(param, "order_no");
|
||||
if (value == null || "".equals(value)) {
|
||||
return Result.succeed("暂未开放控制权限");
|
||||
}
|
||||
Result res = orderCenterService.getOrderExecStatus(value);
|
||||
if (res.getResp_code() != null && res.getResp_code() == 0){
|
||||
return Result.succeed("任务正在执行中");
|
||||
}
|
||||
try {
|
||||
if (ControlEnum.contains(ControlEnum.valueOf(property.toUpperCase()))) {
|
||||
jsonObject = gson.fromJson(controlMessageConstant.CONTROL_MESSAGE_MAP.get(property), JsonObject.class);
|
||||
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
package com.central.device.feign;
|
||||
|
||||
import com.central.common.constant.ServiceNameConstants;
|
||||
import com.central.common.model.Result;
|
||||
import com.central.device.feign.fallback.OrderCenterServiceFallbackFactory;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
|
||||
/**
|
||||
* user-center模块远程调用
|
||||
*
|
||||
* @author lsl
|
||||
* @version 1.0
|
||||
* @description user-center模块远程调用
|
||||
* @create 2025/1/13
|
||||
**/
|
||||
@FeignClient(name = ServiceNameConstants.ORDER_SERVICE, fallbackFactory = OrderCenterServiceFallbackFactory.class, dismiss404 = true)
|
||||
public interface OrderCenterService {
|
||||
|
||||
@GetMapping("/status/{orderNo}")
|
||||
Result getOrderExecStatus(@PathVariable("orderNo") String orderNo);
|
||||
}
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
package com.central.device.feign.fallback;
|
||||
|
||||
import com.central.common.model.Result;
|
||||
import com.central.device.feign.OrderCenterService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.cloud.openfeign.FallbackFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* 文件中心调用失败回调
|
||||
*
|
||||
* @author lsl
|
||||
* @version 1.0
|
||||
* @description 用户中心调用失败回调
|
||||
* @create 2025/1/17 11:33
|
||||
**/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class OrderCenterServiceFallbackFactory implements FallbackFactory<OrderCenterService> {
|
||||
|
||||
|
||||
@Override
|
||||
public OrderCenterService create(Throwable cause) {
|
||||
return new OrderCenterService() {
|
||||
|
||||
@Override
|
||||
public Result getOrderExecStatus(String orderNo) {
|
||||
return Result.failed(orderNo);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user