fix(订单中心):机库查询设备任务等逻辑优化
This commit is contained in:
+7
-1
@@ -17,6 +17,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.io.IOException;
|
||||
@@ -75,7 +76,12 @@ public class ApiDeviceController {
|
||||
String property = MapUtil.getStrValue(param, "control");
|
||||
String value = MapUtil.getStrValue(param, "order_no");
|
||||
Assert.notNull(value,"任务编号不能为空");
|
||||
|
||||
String orderStatus = orderCenterService.getOrderStatusByOrderNo(value);
|
||||
if (!StringUtils.isEmpty(orderStatus)) {
|
||||
if (!orderStatus.equals("1")){
|
||||
return Result.succeed("设备已执行");
|
||||
}
|
||||
}
|
||||
try {
|
||||
if (ControlEnum.contains(ControlEnum.valueOf(property.toUpperCase()))) {
|
||||
jsonObject = gson.fromJson(controlMessageConstant.CONTROL_MESSAGE_MAP.get(property), JsonObject.class);
|
||||
|
||||
+5
@@ -4,6 +4,8 @@ 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;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
|
||||
@@ -20,4 +22,7 @@ public interface OrderCenterService {
|
||||
|
||||
@PostMapping("/status")
|
||||
Result updateOrderStatusDoing(@RequestBody String orderNo);
|
||||
|
||||
@GetMapping("/status/{orderNo}")
|
||||
String getOrderStatusByOrderNo(@PathVariable("orderNo") String orderNo);
|
||||
}
|
||||
|
||||
+5
@@ -26,6 +26,11 @@ public class OrderCenterServiceFallbackFactory implements FallbackFactory<OrderC
|
||||
public Result updateOrderStatusDoing(String orderNo) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getOrderStatusByOrderNo(String orderNo) {
|
||||
return "";
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
+27
-1
@@ -26,6 +26,7 @@ import io.swagger.v3.oas.annotations.enums.ParameterIn;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections4.MapUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.util.Assert;
|
||||
@@ -133,6 +134,7 @@ public class OrderController {
|
||||
public PageResult<Map> listInfoByUser(@RequestParam Map<String, Object> params) {
|
||||
LoginAppUser user = LoginUserContextHolder.getUser();
|
||||
params.put("userId", user.getId());
|
||||
String fileType = MapUtils.getString(params, "fileType");
|
||||
|
||||
PageResult<Order> result = orderService.findListByUser(params);
|
||||
if (result.getCount() > 0){
|
||||
@@ -144,7 +146,8 @@ public class OrderController {
|
||||
orderFileMap.put("time", sdf.format(order.getCreateTime()));
|
||||
orderFileMap.put("addr", tourismService.getTourismById(order.getTourismId()).getTourismAddress());
|
||||
orderFileMap.put("orderNo", order.getOrderNo());
|
||||
List<OrderFile> list = orderFileService.getOrderFileByOrderNo(order.getOrderNo());
|
||||
|
||||
List<OrderFile> list = orderFileService.getOrderFileByOrderNoAndFileType(order.getOrderNo(),fileType);
|
||||
List<Map<String,String>> resultList = new ArrayList<>();
|
||||
if (!list.isEmpty()){
|
||||
for (OrderFile orderFile : list){
|
||||
@@ -350,6 +353,21 @@ public class OrderController {
|
||||
return Result.failed("未查询到订单数据");
|
||||
}
|
||||
|
||||
@Operation(summary = "根据设备状态更新订单正在服务中状态")
|
||||
@AuditLog(operation = "'下发任务更新订单正在服务中状态:' + #orderNo")
|
||||
@PutMapping("/device/status")
|
||||
public Result<String> updateOrderStatusDoingFromDevice(@RequestBody Map payload) {
|
||||
Order order = orderService.getOrderByNumber(payload.get("orderNo").toString());
|
||||
Assert.notNull(order,"订单数据不能为空");
|
||||
if (order.getOrderStatus().equals(OrderStatus.PAID.getId())){
|
||||
order.setOrderStatus(OrderStatus.DOING.getId());
|
||||
if (orderService.updateOrder(order)){
|
||||
return Result.succeed("更新成功");
|
||||
}
|
||||
}
|
||||
return Result.failed("未查询到订单数据");
|
||||
}
|
||||
|
||||
@Operation(summary = "机库更新订单完成状态")
|
||||
@AuditLog(operation = "'机库更新订单完成状态:' + #payload")
|
||||
@PutMapping("/update")
|
||||
@@ -428,6 +446,14 @@ public class OrderController {
|
||||
return Result.succeed(order.getDeviceSn(),"获取成功");
|
||||
}
|
||||
|
||||
@Operation(summary = "获取订单状态")
|
||||
@GetMapping("/status/{orderNo}")
|
||||
public String getOrderStatusByOrderNo(@PathVariable("orderNo") String orderNo) {
|
||||
Order order = orderService.getOrderByNumber(orderNo);
|
||||
Assert.notNull(order,"订单数据不存在");
|
||||
return order.getOrderStatus().toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 将分的价格转换为元的str,方便前端显示
|
||||
* @param str
|
||||
|
||||
+2
-1
@@ -161,7 +161,8 @@ public class OrderFileController {
|
||||
}
|
||||
if (orderFileService.save(orderFile)){
|
||||
// 机库上报订单素材,更新订单状态为素材上传中,如果订单为设备执行中则更新,否则说明状态已更新
|
||||
if (order.getOrderStatus().equals(OrderStatus.DOING.getId())){
|
||||
if (order.getOrderStatus().equals(OrderStatus.DOING.getId())
|
||||
|| order.getOrderStatus().equals(OrderStatus.PAID.getId())) {
|
||||
order.setOrderStatus(OrderStatus.UPLOADING.getId());
|
||||
orderService.updateOrder(order);
|
||||
}
|
||||
|
||||
@@ -31,6 +31,8 @@ public interface OrderFileMapper extends SuperMapper<OrderFile> {
|
||||
int insertOrderFile(OrderFile orderFile);
|
||||
// 根据订单编号查询文件资源信息
|
||||
List<OrderFile> getOrderFileByOrderNo(@Param("orderNo") String orderNo);
|
||||
|
||||
List<OrderFile> getOrderFileByOrderNoAndFileType(@Param("orderNo") String orderNo, @Param("fileType") String contentType);
|
||||
// 文件ID查询文件
|
||||
OrderFile getFileByFileId(@Param("fileId") String fileId);
|
||||
// 查询所有处于排队状态的订单,用于后续按顺序处理(可根据业务需求添加排序等逻辑)
|
||||
|
||||
+7
@@ -44,6 +44,13 @@ public interface IOrderFileService extends ISuperService<OrderFile> {
|
||||
*/
|
||||
List<OrderFile> getOrderFileByOrderNo(String orderNo);
|
||||
|
||||
/**
|
||||
* 订单编号查询订单文件资源
|
||||
* @param orderNo
|
||||
* @return
|
||||
*/
|
||||
List<OrderFile> getOrderFileByOrderNoAndFileType(String orderNo,String contentType);
|
||||
|
||||
/**
|
||||
* 用户ID查询订单文件资源
|
||||
* @param userId
|
||||
|
||||
+6
@@ -56,6 +56,12 @@ public class OrderFileServiceImpl extends SuperServiceImpl<OrderFileMapper, Orde
|
||||
return baseMapper.getOrderFileByOrderNo(orderNo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<OrderFile> getOrderFileByOrderNoAndFileType(String orderNo, String fileType) {
|
||||
return baseMapper.getOrderFileByOrderNoAndFileType(orderNo, fileType);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<OrderFile> getOrderFileByUserId(Long userId) {
|
||||
return baseMapper.getOrderFilesByUserId(userId);
|
||||
|
||||
@@ -20,6 +20,10 @@
|
||||
SELECT * FROM order_files WHERE order_no = #{orderNo}
|
||||
</select>
|
||||
|
||||
<select id="getOrderFileByOrderNoAndFileType" resultType="com.central.order.model.OrderFile">
|
||||
SELECT * FROM order_files WHERE order_no = #{orderNo} and file_type = #{fileType}
|
||||
</select>
|
||||
|
||||
<select id="getFileByFileId" resultType="com.central.order.model.OrderFile">
|
||||
SELECT * FROM order_files WHERE file_id = #{fileId}
|
||||
</select>
|
||||
|
||||
+3
-2
@@ -34,6 +34,7 @@ public class OssTemplate implements InitializingBean {
|
||||
|
||||
private static final String DEF_CONTEXT_TYPE = "application/octet-stream";
|
||||
private static final String PATH_SPLIT = "/";
|
||||
private static final int DEFAULT_EXPIRE_TYPE = 60;
|
||||
|
||||
@Autowired
|
||||
private FileServerProperties fileProperties;
|
||||
@@ -145,7 +146,7 @@ public class OssTemplate implements InitializingBean {
|
||||
*/
|
||||
public String getViewUrl(String objectName,String style) {
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.add(Calendar.MINUTE, 7);
|
||||
cal.add(Calendar.MINUTE, DEFAULT_EXPIRE_TYPE);
|
||||
if (style == null) {
|
||||
style = "image/resize,m_fixed,w_100,h_90"; // 默认缩略图样式
|
||||
}
|
||||
@@ -163,7 +164,7 @@ public class OssTemplate implements InitializingBean {
|
||||
*/
|
||||
public String getViewUrl(String objectName) {
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.add(Calendar.MINUTE, 7);
|
||||
cal.add(Calendar.MINUTE, DEFAULT_EXPIRE_TYPE);
|
||||
URL url = ossClient.generatePresignedUrl(fileProperties.getOss().getBucketName(), objectName, cal.getTime());
|
||||
return url.toString();
|
||||
}
|
||||
|
||||
@@ -142,7 +142,8 @@ zlt:
|
||||
/api-order/update,
|
||||
/api-order/queue/first,
|
||||
/api-order/wechat/**,
|
||||
/api-order/home/carousel/app
|
||||
/api-order/home/carousel/app,
|
||||
/api-order/device/status
|
||||
auth:
|
||||
urlPermission:
|
||||
#是否开启url级别权限
|
||||
|
||||
@@ -260,6 +260,8 @@ const TableList: React.FC = () => {
|
||||
placeholder="输入设备编号"
|
||||
options={[
|
||||
{ label: '7CTDM6F00B744S', value: '7CTDM6F00B744S' },
|
||||
{ label: '8UUXN2A00A00LR', value: '8UUXN2A00A00LR' },
|
||||
{ label: '5YSZMBS0030BJ8', value: '5YSZMBS0030BJ8' },
|
||||
// 添加更多选项...
|
||||
]}
|
||||
/>
|
||||
|
||||
Reference in New Issue
Block a user