订单改版
This commit is contained in:
parent
f44d78c94c
commit
805be30f64
@ -1,19 +1,24 @@
|
||||
package com.evotech.hd.cloud.controller.order;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.evotech.hd.cloud.entity.vo.NativePayVO;
|
||||
import com.evotech.hd.cloud.service.OrderService;
|
||||
import com.evotech.hd.common.core.Dto.Result;
|
||||
import com.evotech.hd.common.core.Dto.order.OrderListVo;
|
||||
import com.evotech.hd.common.core.entity.cloud.OrderSwapBatteryStep;
|
||||
import com.evotech.hd.common.core.entity.cloud.request.BatterySwapResponse;
|
||||
import com.evotech.hd.common.core.entity.cloud.request.PageListSwapOrderRequest;
|
||||
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
||||
import com.github.xiaoymin.knife4j.annotations.ApiSupport;
|
||||
import io.swagger.v3.oas.annotations.Hidden;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import org.springdoc.core.annotations.ParameterObject;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Tag(name = "换电订单")
|
||||
@ApiSupport(order = 22)
|
||||
@ -32,85 +37,85 @@ public class OrderSwapBatteryController {
|
||||
return orderService.pageList(plsor);
|
||||
}
|
||||
|
||||
// @Operation(summary = "查询公司订单")
|
||||
// @GetMapping("/listcompanyorder")
|
||||
// @ApiOperationSupport(order = 8)
|
||||
// @Hidden
|
||||
// @Deprecated
|
||||
// public Result<List<OrderSwapBattery>> listByCompany(@ParameterObject PageListSwapOrderRequest plsor) {
|
||||
// return orderSwapBatteryService.listByCompany(plsor);
|
||||
// }
|
||||
//
|
||||
// @Operation(summary = "查询换电步骤")
|
||||
// @GetMapping("/step/list")
|
||||
// @ApiOperationSupport(order = 9)
|
||||
// public Result<List<OrderSwapBatteryStep>> listStep(@NotBlank String orderNo) {
|
||||
// return orderSwapBatteryService.listStep(orderNo);
|
||||
// }
|
||||
//
|
||||
// @Operation(summary = "费用计算")
|
||||
// @PostMapping({"/cost"})
|
||||
// @ApiOperationSupport(order = 9)
|
||||
// public Result<String> calculateCost(@NotBlank @RequestParam OrderSwapBattery osb) {
|
||||
// return orderSwapBatteryService.calculateCost(osb);
|
||||
// }
|
||||
//
|
||||
//
|
||||
// @Operation(summary = "个人账户余额支付")
|
||||
// @PostMapping({"/wallet/pay"})
|
||||
// @ApiOperationSupport(order = 11)
|
||||
// public Result<String> walletPay(@RequestParam String orderNo, String wuid, String uname) {
|
||||
// return orderSwapBatteryService.walletPay(orderNo, wuid, uname);
|
||||
// }
|
||||
//
|
||||
//
|
||||
// @Operation(summary = "公司订单余额支付")
|
||||
// @PostMapping({"/companywallet/pay"})
|
||||
// @ApiOperationSupport(order = 12)
|
||||
// public Result<String> companyWalletPay(@RequestParam String orderNo, String wuid, String uname) {
|
||||
// // TODO
|
||||
// return null;
|
||||
// }
|
||||
//
|
||||
//
|
||||
// @Operation(summary = "公司订单扫码支付")
|
||||
// @PostMapping({"/wechat/nativepay"})
|
||||
// @ApiOperationSupport(order = 13)
|
||||
// public Result<String> companyNativePay(@RequestBody NativePayVO prePay) {
|
||||
// return orderSwapBatteryService.companyNativePay(prePay);
|
||||
// }
|
||||
//
|
||||
// @Operation(summary = "扫码支付订单查询状态")
|
||||
// @GetMapping("/paystatus/query")
|
||||
// @ApiOperationSupport(order = 14)
|
||||
// public Result<String> orderQuery(String outTradeNo) {
|
||||
// return orderSwapBatteryService.orderQuery(outTradeNo);
|
||||
// }
|
||||
//
|
||||
// @Operation(summary = "站端取消订单")
|
||||
// @PostMapping("/pre/cancelOrder")
|
||||
// @ApiOperationSupport(order = 15)
|
||||
// public Result<Integer> cancelOrder(@NotNull String orderNo) {
|
||||
// return orderSwapBatteryService.cancelOrder(orderNo, null);
|
||||
// }
|
||||
// @Operation(summary = "开始换电")
|
||||
// @PostMapping("/startSwap")
|
||||
// @ApiOperationSupport(order = 16)
|
||||
// public Result<Boolean> startSwap(@RequestParam String wuid,String orderId) {
|
||||
// return orderSwapBatteryService.startSwap(wuid,orderId);
|
||||
// }
|
||||
// @Operation(summary = "获取开始换电回复")
|
||||
// @PostMapping("/getStartSwap")
|
||||
// @ApiOperationSupport(order = 17)
|
||||
// public Result<BatterySwapResponse> getStartSwap(@RequestParam String wuid, String orderId) {
|
||||
// return orderSwapBatteryService.getStartSwap(wuid,orderId);
|
||||
// }
|
||||
//
|
||||
// @Operation(summary = "未完成订单查询:plateNum")
|
||||
// @GetMapping("/checkList")
|
||||
// @ApiOperationSupport(order = 18)
|
||||
// public Result<Integer> checkList(@ParameterObject PageListSwapOrderRequest plsor) {
|
||||
// return orderSwapBatteryService.checkList(plsor);
|
||||
// }
|
||||
@Operation(summary = "查询公司订单")
|
||||
@GetMapping("/listcompanyorder")
|
||||
@ApiOperationSupport(order = 8)
|
||||
@Hidden
|
||||
@Deprecated
|
||||
public Result<List<OrderSwapBattery>> listByCompany(@ParameterObject PageListSwapOrderRequest plsor) {
|
||||
return orderSwapBatteryService.listByCompany(plsor);
|
||||
}
|
||||
|
||||
@Operation(summary = "查询换电步骤")
|
||||
@GetMapping("/step/list")
|
||||
@ApiOperationSupport(order = 9)
|
||||
public Result<List<OrderSwapBatteryStep>> listStep(@NotBlank String orderNo) {
|
||||
return orderSwapBatteryService.listStep(orderNo);
|
||||
}
|
||||
|
||||
@Operation(summary = "费用计算")
|
||||
@PostMapping({"/cost"})
|
||||
@ApiOperationSupport(order = 9)
|
||||
public Result<String> calculateCost(@NotBlank @RequestParam OrderSwapBattery osb) {
|
||||
return orderSwapBatteryService.calculateCost(osb);
|
||||
}
|
||||
|
||||
|
||||
@Operation(summary = "个人账户余额支付")
|
||||
@PostMapping({"/wallet/pay"})
|
||||
@ApiOperationSupport(order = 11)
|
||||
public Result<String> walletPay(@RequestParam String orderNo, String wuid, String uname) {
|
||||
return orderSwapBatteryService.walletPay(orderNo, wuid, uname);
|
||||
}
|
||||
|
||||
|
||||
@Operation(summary = "公司订单余额支付")
|
||||
@PostMapping({"/companywallet/pay"})
|
||||
@ApiOperationSupport(order = 12)
|
||||
public Result<String> companyWalletPay(@RequestParam String orderNo, String wuid, String uname) {
|
||||
// TODO
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@Operation(summary = "公司订单扫码支付")
|
||||
@PostMapping({"/wechat/nativepay"})
|
||||
@ApiOperationSupport(order = 13)
|
||||
public Result<String> companyNativePay(@RequestBody NativePayVO prePay) {
|
||||
return orderSwapBatteryService.companyNativePay(prePay);
|
||||
}
|
||||
|
||||
@Operation(summary = "扫码支付订单查询状态")
|
||||
@GetMapping("/paystatus/query")
|
||||
@ApiOperationSupport(order = 14)
|
||||
public Result<String> orderQuery(String outTradeNo) {
|
||||
return orderSwapBatteryService.orderQuery(outTradeNo);
|
||||
}
|
||||
|
||||
@Operation(summary = "站端取消订单")
|
||||
@PostMapping("/pre/cancelOrder")
|
||||
@ApiOperationSupport(order = 15)
|
||||
public Result<Integer> cancelOrder(@NotNull String orderNo) {
|
||||
return orderSwapBatteryService.cancelOrder(orderNo, null);
|
||||
}
|
||||
@Operation(summary = "开始换电")
|
||||
@PostMapping("/startSwap")
|
||||
@ApiOperationSupport(order = 16)
|
||||
public Result<Boolean> startSwap(@RequestParam String wuid,String orderId) {
|
||||
return orderService.startSwap(wuid,orderId);
|
||||
}
|
||||
@Operation(summary = "获取开始换电回复")
|
||||
@PostMapping("/getStartSwap")
|
||||
@ApiOperationSupport(order = 17)
|
||||
public Result<BatterySwapResponse> getStartSwap(@RequestParam String wuid, String orderId) {
|
||||
return orderSwapBatteryService.getStartSwap(wuid,orderId);
|
||||
}
|
||||
|
||||
@Operation(summary = "未完成订单查询:plateNum")
|
||||
@GetMapping("/checkList")
|
||||
@ApiOperationSupport(order = 18)
|
||||
public Result<Integer> checkList(@ParameterObject PageListSwapOrderRequest plsor) {
|
||||
return orderSwapBatteryService.checkList(plsor);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -30,7 +30,7 @@ public class BaseOrder extends IdEntity {
|
||||
private Integer orderAmount;
|
||||
|
||||
/***
|
||||
* 订单状态, 具体参考 HDConstant.OrderConstant.ORDER_STATUS_*
|
||||
* 订单状态, 具体参考 OrderStatusEnums //HDConstant.OrderConstant.ORDER_STATUS_*
|
||||
*/
|
||||
private Integer status;
|
||||
/***
|
||||
@ -44,9 +44,9 @@ public class BaseOrder extends IdEntity {
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private Date payTime;
|
||||
/***
|
||||
* 支付人的wuId
|
||||
* 支付人的微信ID
|
||||
*/
|
||||
private String wuId;
|
||||
private String payWechatId;
|
||||
|
||||
/***
|
||||
* 第三方返回的唯一订单标识
|
||||
|
||||
@ -25,9 +25,9 @@ public class Order extends BaseOrder{
|
||||
private Integer orderPreId;
|
||||
|
||||
/***
|
||||
* 预约用户ID
|
||||
* 预约用户的微信ID
|
||||
*/
|
||||
private Integer preUid;
|
||||
private String preWechatId;
|
||||
|
||||
/***
|
||||
* 预约用户名称
|
||||
|
||||
@ -15,10 +15,13 @@ import java.io.Serializable;
|
||||
@Data
|
||||
public class MqttResponse<T> implements Serializable {
|
||||
|
||||
|
||||
private Integer code;
|
||||
|
||||
private String msg;
|
||||
|
||||
private String dataId;
|
||||
|
||||
private T data;
|
||||
|
||||
|
||||
@ -28,9 +31,21 @@ public class MqttResponse<T> implements Serializable {
|
||||
|
||||
static final Integer PARAMS_ERROR = 2;
|
||||
|
||||
public static final Integer PUBLIC_SUCCESS = SUCCESS;
|
||||
public static final Integer PUBLIC_ERROR = ERROR;
|
||||
|
||||
/***
|
||||
* 默认新创建的对象直接为错误
|
||||
*/
|
||||
public MqttResponse() {
|
||||
}
|
||||
|
||||
public MqttResponse<T> createError(String dataId) {
|
||||
this.code=ERROR;
|
||||
this.dataId = dataId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public MqttResponse<T> success(T data){
|
||||
this.code=SUCCESS;
|
||||
this.msg="成功";
|
||||
|
||||
@ -2,16 +2,27 @@ package com.evotech.hd.cloud.mqtt.message.dto.newer.req.battery;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
@Data
|
||||
public class BatteryData {
|
||||
|
||||
private String batCode;
|
||||
|
||||
@Schema(description = "生产日期", example = "yyyyMMdd")
|
||||
@Schema(description = "生产日期", example = "yyyy-MM-dd")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd")
|
||||
private String productionDate;
|
||||
|
||||
@Schema(description = "注册时间", example = "yyyyMMdd")
|
||||
@Schema(description = "注册时间", example = "yyyy-MM-dd")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd")
|
||||
private String registrationDate;
|
||||
|
||||
public BatteryData() {
|
||||
}
|
||||
|
||||
public BatteryData(String batCode, String productionDate, String registrationDate) {
|
||||
this.batCode = batCode;
|
||||
this.productionDate = productionDate;
|
||||
this.registrationDate = registrationDate;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,49 +1,27 @@
|
||||
package com.evotech.hd.cloud.mqtt.message.handle;
|
||||
|
||||
import cn.hutool.core.date.DatePattern;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.json.JSONConfig;
|
||||
import cn.hutool.json.JSONObject;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.evotech.hd.cloud.dao.BatteryStationDcDao;
|
||||
import com.evotech.hd.cloud.dao.OrderSwapBatteryPreDao;
|
||||
import com.evotech.hd.cloud.dao.VehicleWechatUserRelationDao;
|
||||
import com.evotech.hd.cloud.mqtt.enums.MqttMessageTypeEnum;
|
||||
import com.evotech.hd.cloud.mqtt.enums.RequestFunctionTypesEnum;
|
||||
import com.evotech.hd.cloud.mqtt.message.MessageTopic;
|
||||
import com.evotech.hd.cloud.mqtt.message.MqttMessageHeader;
|
||||
import com.evotech.hd.cloud.mqtt.message.dto.newer.req.battery.BatteryData;
|
||||
import com.evotech.hd.cloud.mqtt.message.dto.newer.req.battery.BatteryInfoReq;
|
||||
import com.evotech.hd.cloud.mqtt.message.dto.newer.req.battery.BatteryInfoResponse;
|
||||
import com.evotech.hd.cloud.mqtt.message.dto.newer.req.carinfo.CarInfoReq;
|
||||
import com.evotech.hd.cloud.mqtt.message.dto.newer.req.carinfo.CarInfoResponse;
|
||||
import com.evotech.hd.cloud.mqtt.message.dto.newer.req.carinfo.VehicleData;
|
||||
import com.evotech.hd.cloud.mqtt.message.dto.newer.req.order.*;
|
||||
import com.evotech.hd.cloud.mqtt.message.processor.strategy.MqttStrategyExchangeProcessor;
|
||||
import com.evotech.hd.cloud.service.WechatUserService;
|
||||
import com.evotech.hd.cloud.utils.CommonUtil;
|
||||
import com.evotech.hd.common.core.entity.Result;
|
||||
import com.evotech.hd.common.core.entity.cloud.BatteryStationDc;
|
||||
import com.evotech.hd.common.core.entity.cloud.OrderSwapBatteryPre;
|
||||
import com.evotech.hd.common.core.entity.cloud.VehicleWechatUserRelation;
|
||||
import com.evotech.hd.common.core.entity.cloud.request.BatterySwapResponse;
|
||||
import com.evotech.hd.common.core.entity.wechat.WechatUser;
|
||||
import com.evotech.hd.common.redis.utils.RedisUtil;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Stream;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* request消息 处理
|
||||
@ -74,27 +52,27 @@ public class RequestMessageService {
|
||||
@Async("taskExecutor")
|
||||
public void request(MessageTopic topic, MqttMessageHeader header, JSONObject dataBody) {
|
||||
switch (Objects.requireNonNull(RequestFunctionTypesEnum.getFunctionType(header.getFunction()))) {
|
||||
case FUN_CARINFO:
|
||||
CarInfoReq carInfoReq = JSONUtil.toBean(dataBody, CarInfoReq.class);
|
||||
handleCarInfo(topic, header, carInfoReq);
|
||||
break;
|
||||
case FUN_BATTERYINFO:
|
||||
BatteryInfoReq batteryInfoReq = JSONUtil.toBean(dataBody, BatteryInfoReq.class);
|
||||
handleBatteryInfo(topic, header, batteryInfoReq);
|
||||
break;
|
||||
case FUN_PREORDER:
|
||||
OrderSwapBatteryPre orderSwapBatteryPre = JSONUtil.toBean(dataBody, OrderSwapBatteryPre.class);
|
||||
handlOrderSwapBatteryPre(topic,header,orderSwapBatteryPre);
|
||||
break;
|
||||
case FUN_ORDERBYPLATENUM:
|
||||
OrderByPlateNumReq orderByPlateNumReq = JSONUtil.toBean(dataBody, OrderByPlateNumReq.class);
|
||||
handleOrderByPlateNum(topic, header, orderByPlateNumReq);
|
||||
break;
|
||||
// case FUN_CARINFO:
|
||||
// CarInfoReq carInfoReq = JSONUtil.toBean(dataBody, CarInfoReq.class);
|
||||
// handleCarInfo(topic, header, carInfoReq);
|
||||
// break;
|
||||
// case FUN_BATTERYINFO:
|
||||
// BatteryInfoReq batteryInfoReq = JSONUtil.toBean(dataBody, BatteryInfoReq.class);
|
||||
// handleBatteryInfo(topic, header, batteryInfoReq);
|
||||
// break;
|
||||
// case FUN_PREORDER:
|
||||
// OrderSwapBatteryPre orderSwapBatteryPre = JSONUtil.toBean(dataBody, OrderSwapBatteryPre.class);
|
||||
// handlOrderSwapBatteryPre(topic,header,orderSwapBatteryPre);
|
||||
// break;
|
||||
// case FUN_ORDERBYPLATENUM:
|
||||
// OrderByPlateNumReq orderByPlateNumReq = JSONUtil.toBean(dataBody, OrderByPlateNumReq.class);
|
||||
// handleOrderByPlateNum(topic, header, orderByPlateNumReq);
|
||||
// break;
|
||||
// case FUN_CANCELORDER:
|
||||
// CancelOrderReq cancelOrder = JSONUtil.toBean(dataBody, CancelOrderReq.class);
|
||||
// handlOrderCancel(topic,header,cancelOrder);
|
||||
// break;
|
||||
case FUN_STARTSWAP:
|
||||
case FUN_STARTSWAP: //没搞明白干啥用了, 暂时不动
|
||||
BatterySwapResponse battery = JSONUtil.toBean(dataBody, BatterySwapResponse.class);
|
||||
handlStartSwap(topic,header,battery);
|
||||
break;
|
||||
@ -164,48 +142,48 @@ public class RequestMessageService {
|
||||
// messageUtilService.publishAESMessage(topic, header, JSONUtil.parseObj(response, new JSONConfig().setDateFormat(DatePattern.NORM_DATETIME_PATTERN)));
|
||||
// }
|
||||
|
||||
/**
|
||||
* 站端添加预约单
|
||||
* @param topic
|
||||
* @param header
|
||||
* @param orderSwapBatteryPre
|
||||
*/
|
||||
private void handlOrderSwapBatteryPre(MessageTopic topic, MqttMessageHeader header, OrderSwapBatteryPre orderSwapBatteryPre) {
|
||||
OrdeSwapBatteryPreRespose response = new OrdeSwapBatteryPreRespose();
|
||||
Date d = new Date();
|
||||
// 1. 基础字段校验
|
||||
if (validateRequiredFields(orderSwapBatteryPre)) {
|
||||
// 返回错误消息
|
||||
response.setStationPreOrderId(orderSwapBatteryPre.getSourceId());
|
||||
response.setMsg("预约信息不完整");
|
||||
response.setCode(0);
|
||||
}else {
|
||||
//添加预约单
|
||||
WechatUser wechatUser =wechatUserService.selectUcode(orderSwapBatteryPre.getPhone(),orderSwapBatteryPre.getUname());
|
||||
//查询用户编码
|
||||
orderSwapBatteryPre.setUcode(wechatUser.getWuid());
|
||||
orderSwapBatteryPre.setSource(3);
|
||||
Result<Integer> integerResult = orderSwapBatteryService.addPre(orderSwapBatteryPre);
|
||||
//添加失败情况
|
||||
if (integerResult.getStatus()==0){
|
||||
response.setStationPreOrderId(orderSwapBatteryPre.getSourceId());
|
||||
//返回失败状态
|
||||
response.setMsg(integerResult.getMsg());
|
||||
response.setCode(0);
|
||||
}else{
|
||||
response.setStationPreOrderId(orderSwapBatteryPre.getSourceId());
|
||||
response.setCode(1);
|
||||
response.setMsg("OK");
|
||||
}
|
||||
}
|
||||
// 发送
|
||||
topic.setDataDirection("M2S");
|
||||
topic.setMessageType(MqttMessageTypeEnum.RESPONSE.getType());
|
||||
header.setFunction(RequestFunctionTypesEnum.FUN_PREORDER.getReFunction());
|
||||
header.setTimeStamp(DateUtil.format(d, DatePattern.NORM_DATETIME_FORMATTER));
|
||||
log.info("\r\n=====>>>站端添加预约单--MQTT发送到消息主题:{},头部信息:{},message:{}", topic,header, JSONUtil.parseObj(response, new JSONConfig().setDateFormat(DatePattern.NORM_DATETIME_PATTERN)));
|
||||
messageUtilService.publishAESMessage(topic, header, JSONUtil.parseObj(response, new JSONConfig().setDateFormat(DatePattern.NORM_DATETIME_PATTERN)));
|
||||
}
|
||||
// /**
|
||||
// * 站端添加预约单
|
||||
// * @param topic
|
||||
// * @param header
|
||||
// * @param orderSwapBatteryPre
|
||||
// */
|
||||
// private void handlOrderSwapBatteryPre(MessageTopic topic, MqttMessageHeader header, OrderSwapBatteryPre orderSwapBatteryPre) {
|
||||
// OrdeSwapBatteryPreRespose response = new OrdeSwapBatteryPreRespose();
|
||||
// Date d = new Date();
|
||||
// // 1. 基础字段校验
|
||||
// if (validateRequiredFields(orderSwapBatteryPre)) {
|
||||
// // 返回错误消息
|
||||
// response.setStationPreOrderId(orderSwapBatteryPre.getSourceId());
|
||||
// response.setMsg("预约信息不完整");
|
||||
// response.setCode(0);
|
||||
// }else {
|
||||
// //添加预约单
|
||||
// WechatUser wechatUser =wechatUserService.selectUcode(orderSwapBatteryPre.getPhone(),orderSwapBatteryPre.getUname());
|
||||
// //查询用户编码
|
||||
// orderSwapBatteryPre.setUcode(wechatUser.getWuid());
|
||||
// orderSwapBatteryPre.setSource(3);
|
||||
// Result<Integer> integerResult = orderSwapBatteryService.addPre(orderSwapBatteryPre);
|
||||
// //添加失败情况
|
||||
// if (integerResult.getStatus()==0){
|
||||
// response.setStationPreOrderId(orderSwapBatteryPre.getSourceId());
|
||||
// //返回失败状态
|
||||
// response.setMsg(integerResult.getMsg());
|
||||
// response.setCode(0);
|
||||
// }else{
|
||||
// response.setStationPreOrderId(orderSwapBatteryPre.getSourceId());
|
||||
// response.setCode(1);
|
||||
// response.setMsg("OK");
|
||||
// }
|
||||
// }
|
||||
// // 发送
|
||||
// topic.setDataDirection("M2S");
|
||||
// topic.setMessageType(MqttMessageTypeEnum.RESPONSE.getType());
|
||||
// header.setFunction(RequestFunctionTypesEnum.FUN_PREORDER.getReFunction());
|
||||
// header.setTimeStamp(DateUtil.format(d, DatePattern.NORM_DATETIME_FORMATTER));
|
||||
// log.info("\r\n=====>>>站端添加预约单--MQTT发送到消息主题:{},头部信息:{},message:{}", topic,header, JSONUtil.parseObj(response, new JSONConfig().setDateFormat(DatePattern.NORM_DATETIME_PATTERN)));
|
||||
// messageUtilService.publishAESMessage(topic, header, JSONUtil.parseObj(response, new JSONConfig().setDateFormat(DatePattern.NORM_DATETIME_PATTERN)));
|
||||
// }
|
||||
|
||||
/**
|
||||
* OrderByPlateNum请求处理
|
||||
@ -213,156 +191,156 @@ public class RequestMessageService {
|
||||
* @param header
|
||||
* @param orderByPlateNumReq
|
||||
*/
|
||||
private void handleOrderByPlateNum(MessageTopic topic, MqttMessageHeader header, OrderByPlateNumReq orderByPlateNumReq) {
|
||||
OrderByPlateNumResponse response = new OrderByPlateNumResponse();
|
||||
Date d = new Date();
|
||||
// 查预约
|
||||
OrderSwapBatteryPre osbp = orderSwapBatteryPreDao.selectOne(new QueryWrapper<OrderSwapBatteryPre>()
|
||||
.eq("plate_num", orderByPlateNumReq.getPlateNum())
|
||||
.eq("station_code", orderByPlateNumReq.getStationCode())
|
||||
.eq("status", 1)
|
||||
.eq("swap_day", DateUtil.format(d, DatePattern.PURE_DATE_FORMATTER))
|
||||
.last("limit 1"));
|
||||
if (osbp == null) {
|
||||
response.setOrderRequestId(orderByPlateNumReq.getOrderRequestId());
|
||||
response.setCode(0);
|
||||
response.setMsg("车辆未预约,请扫码进入");
|
||||
} else {
|
||||
OrderSwapBattery osb = orderSwapBatteryDao.selectOne(new QueryWrapper<OrderSwapBattery>()
|
||||
.eq("plate_num", orderByPlateNumReq.getPlateNum())
|
||||
.eq("station_code", orderByPlateNumReq.getStationCode())
|
||||
.eq("order_pre_id", osbp.getPkId())
|
||||
.eq("status", 1));
|
||||
if (osb == null) {
|
||||
// 生成订单
|
||||
osb = new OrderSwapBattery();
|
||||
osb.setOrderNo(CommonUtil.swapBatteryOrderNo(orderByPlateNumReq.getStationCode()));
|
||||
osb.setOrderPreId(osbp.getPkId());
|
||||
osb.setOrderPrePhone(osbp.getPhone());
|
||||
osb.setOrderPreUid(osbp.getUcode());
|
||||
osb.setOrderPreUname(osbp.getUname());
|
||||
osb.setPlateNum(osbp.getPlateNum());
|
||||
osb.setOrderTime(d);
|
||||
osb.setOrderType(1);
|
||||
osb.setStatus(1);
|
||||
osb.setStationCode(osbp.getStationCode());
|
||||
osb.setStationName(osbp.getStationName());
|
||||
// TODO 查询换电站信息,拿到计费方式,放到订单信息中
|
||||
|
||||
|
||||
// // 加上费用标准 - 移到订单服务中了
|
||||
// osb = orderBasicFeeComponent.orderBasicFee(osb);
|
||||
log.info("\r\n=====>>>生成订单信息--MQTT发送到消息主题:{},订单编码:{}", topic,CommonUtil.swapBatteryOrderNo(orderByPlateNumReq.getStationCode()));
|
||||
orderSwapBatteryService.add(osb);
|
||||
}
|
||||
//走到此处, 证明上面逻辑没有问题, 需要删除预约单过期标识
|
||||
redisUtil.del("preorder:expire:"+osbp.getPkId());
|
||||
// 返回数据
|
||||
OrderData od = new OrderData();
|
||||
BeanUtils.copyProperties(osb, od);
|
||||
response.setOrderRequestId(orderByPlateNumReq.getOrderRequestId());
|
||||
response.setCode(1);
|
||||
response.setMsg("OK");
|
||||
response.setOrderData(od);
|
||||
}
|
||||
// 发送
|
||||
topic.setDataDirection("M2S");
|
||||
topic.setMessageType(MqttMessageTypeEnum.RESPONSE.getType());
|
||||
header.setFunction(RequestFunctionTypesEnum.FUN_ORDERBYPLATENUM.getReFunction());
|
||||
header.setTimeStamp(DateUtil.format(d, DatePattern.NORM_DATETIME_FORMATTER));
|
||||
log.info("\r\n=====>>>站端用车牌号查询订单--MQTT发送到消息主题:{},头部信息:{},message:{}", topic,header, JSONUtil.parseObj(response, new JSONConfig().setDateFormat(DatePattern.NORM_DATETIME_PATTERN)));
|
||||
messageUtilService.publishAESMessage(topic, header, JSONUtil.parseObj(response, new JSONConfig().setDateFormat(DatePattern.NORM_DATETIME_PATTERN)));
|
||||
}
|
||||
// private void handleOrderByPlateNum(MessageTopic topic, MqttMessageHeader header, OrderByPlateNumReq orderByPlateNumReq) {
|
||||
// OrderByPlateNumResponse response = new OrderByPlateNumResponse();
|
||||
// Date d = new Date();
|
||||
// // 查预约
|
||||
// OrderSwapBatteryPre osbp = orderSwapBatteryPreDao.selectOne(new QueryWrapper<OrderSwapBatteryPre>()
|
||||
// .eq("plate_num", orderByPlateNumReq.getPlateNum())
|
||||
// .eq("station_code", orderByPlateNumReq.getStationCode())
|
||||
// .eq("status", 1)
|
||||
// .eq("swap_day", DateUtil.format(d, DatePattern.PURE_DATE_FORMATTER))
|
||||
// .last("limit 1"));
|
||||
// if (osbp == null) {
|
||||
// response.setOrderRequestId(orderByPlateNumReq.getOrderRequestId());
|
||||
// response.setCode(0);
|
||||
// response.setMsg("车辆未预约,请扫码进入");
|
||||
// } else {
|
||||
// OrderSwapBattery osb = orderSwapBatteryDao.selectOne(new QueryWrapper<OrderSwapBattery>()
|
||||
// .eq("plate_num", orderByPlateNumReq.getPlateNum())
|
||||
// .eq("station_code", orderByPlateNumReq.getStationCode())
|
||||
// .eq("order_pre_id", osbp.getPkId())
|
||||
// .eq("status", 1));
|
||||
// if (osb == null) {
|
||||
// // 生成订单
|
||||
// osb = new OrderSwapBattery();
|
||||
// osb.setOrderNo(CommonUtil.swapBatteryOrderNo(orderByPlateNumReq.getStationCode()));
|
||||
// osb.setOrderPreId(osbp.getPkId());
|
||||
// osb.setOrderPrePhone(osbp.getPhone());
|
||||
// osb.setOrderPreUid(osbp.getUcode());
|
||||
// osb.setOrderPreUname(osbp.getUname());
|
||||
// osb.setPlateNum(osbp.getPlateNum());
|
||||
// osb.setOrderTime(d);
|
||||
// osb.setOrderType(1);
|
||||
// osb.setStatus(1);
|
||||
// osb.setStationCode(osbp.getStationCode());
|
||||
// osb.setStationName(osbp.getStationName());
|
||||
// // TODO 查询换电站信息,拿到计费方式,放到订单信息中
|
||||
//
|
||||
//
|
||||
//// // 加上费用标准 - 移到订单服务中了
|
||||
//// osb = orderBasicFeeComponent.orderBasicFee(osb);
|
||||
// log.info("\r\n=====>>>生成订单信息--MQTT发送到消息主题:{},订单编码:{}", topic,CommonUtil.swapBatteryOrderNo(orderByPlateNumReq.getStationCode()));
|
||||
// orderSwapBatteryService.add(osb);
|
||||
// }
|
||||
// //走到此处, 证明上面逻辑没有问题, 需要删除预约单过期标识
|
||||
// redisUtil.del("preorder:expire:"+osbp.getPkId());
|
||||
// // 返回数据
|
||||
// OrderData od = new OrderData();
|
||||
// BeanUtils.copyProperties(osb, od);
|
||||
// response.setOrderRequestId(orderByPlateNumReq.getOrderRequestId());
|
||||
// response.setCode(1);
|
||||
// response.setMsg("OK");
|
||||
// response.setOrderData(od);
|
||||
// }
|
||||
// // 发送
|
||||
// topic.setDataDirection("M2S");
|
||||
// topic.setMessageType(MqttMessageTypeEnum.RESPONSE.getType());
|
||||
// header.setFunction(RequestFunctionTypesEnum.FUN_ORDERBYPLATENUM.getReFunction());
|
||||
// header.setTimeStamp(DateUtil.format(d, DatePattern.NORM_DATETIME_FORMATTER));
|
||||
// log.info("\r\n=====>>>站端用车牌号查询订单--MQTT发送到消息主题:{},头部信息:{},message:{}", topic,header, JSONUtil.parseObj(response, new JSONConfig().setDateFormat(DatePattern.NORM_DATETIME_PATTERN)));
|
||||
// messageUtilService.publishAESMessage(topic, header, JSONUtil.parseObj(response, new JSONConfig().setDateFormat(DatePattern.NORM_DATETIME_PATTERN)));
|
||||
// }
|
||||
|
||||
/**
|
||||
* BatteryInfo请求处理
|
||||
* @param topic
|
||||
* @param header
|
||||
* @param batteryInfoReq
|
||||
*/
|
||||
private void handleBatteryInfo(MessageTopic topic, MqttMessageHeader header, BatteryInfoReq batteryInfoReq) {
|
||||
String batCode = batteryInfoReq.getBatCode();
|
||||
int pageNo = 0;
|
||||
int pageSize = 500;
|
||||
Page<BatteryStationDc> page = new Page<BatteryStationDc>(pageNo, pageSize);
|
||||
do {
|
||||
pageNo += 1;
|
||||
page = new Page<BatteryStationDc>(pageNo, pageSize);
|
||||
page = batteryStationDcDao.selectPage(page, new QueryWrapper<BatteryStationDc>().eq(StringUtils.hasText(batCode), "bat_code", batCode));
|
||||
BatteryInfoResponse response = new BatteryInfoResponse();
|
||||
response.setBatteryInfoRequestId(batteryInfoReq.getBatteryInfoRequestId());
|
||||
response.setPageNo(Integer.valueOf(page.getCurrent() + ""));
|
||||
response.setPageSize(Integer.valueOf(page.getSize() + ""));
|
||||
response.setTotal(Integer.valueOf(page.getTotal() + ""));
|
||||
response.setIsOver(page.getCurrent() < page.getPages()? 0 : 1);
|
||||
List<BatteryData> list = new ArrayList<BatteryData>();
|
||||
if (page.getCurrent() > 0) {
|
||||
list = page.getRecords().stream().map(i -> {
|
||||
BatteryData bd = new BatteryData();
|
||||
BeanUtils.copyProperties(i, bd);
|
||||
return bd;
|
||||
}).toList();
|
||||
response.setBatteryData(list);
|
||||
}
|
||||
topic.setDataDirection("M2S");
|
||||
topic.setMessageType(MqttMessageTypeEnum.RESPONSE.getType());
|
||||
header.setFunction(RequestFunctionTypesEnum.FUN_BATTERYINFO.getReFunction());
|
||||
header.setTimeStamp(DateUtil.format(new Date(), DatePattern.NORM_DATETIME_FORMATTER));
|
||||
log.info("\r\n=====>>>站端请求电池数据--MQTT发送到消息主题:{},头部信息:{},message:{}", topic,header, JSONUtil.parseObj(response, new JSONConfig().setDateFormat(DatePattern.NORM_DATETIME_PATTERN)));
|
||||
messageUtilService.publishAESMessage(topic, header, JSONUtil.parseObj(response, new JSONConfig().setDateFormat(DatePattern.NORM_DATETIME_PATTERN)));
|
||||
} while (page.getCurrent() < page.getPages());
|
||||
|
||||
}
|
||||
// /**
|
||||
// * BatteryInfo请求处理
|
||||
// * @param topic
|
||||
// * @param header
|
||||
// * @param batteryInfoReq
|
||||
// */
|
||||
// private void handleBatteryInfo(MessageTopic topic, MqttMessageHeader header, BatteryInfoReq batteryInfoReq) {
|
||||
// String batCode = batteryInfoReq.getBatCode();
|
||||
// int pageNo = 0;
|
||||
// int pageSize = 500;
|
||||
// Page<BatteryStationDc> page = new Page<BatteryStationDc>(pageNo, pageSize);
|
||||
// do {
|
||||
// pageNo += 1;
|
||||
// page = new Page<BatteryStationDc>(pageNo, pageSize);
|
||||
// page = batteryStationDcDao.selectPage(page, new QueryWrapper<BatteryStationDc>().eq(StringUtils.hasText(batCode), "bat_code", batCode));
|
||||
// BatteryInfoResponse response = new BatteryInfoResponse();
|
||||
// response.setBatteryInfoRequestId(batteryInfoReq.getBatteryInfoRequestId());
|
||||
// response.setPageNo(Integer.valueOf(page.getCurrent() + ""));
|
||||
// response.setPageSize(Integer.valueOf(page.getSize() + ""));
|
||||
// response.setTotal(Integer.valueOf(page.getTotal() + ""));
|
||||
// response.setIsOver(page.getCurrent() < page.getPages()? 0 : 1);
|
||||
// List<BatteryData> list = new ArrayList<BatteryData>();
|
||||
// if (page.getCurrent() > 0) {
|
||||
// list = page.getRecords().stream().map(i -> {
|
||||
// BatteryData bd = new BatteryData();
|
||||
// BeanUtils.copyProperties(i, bd);
|
||||
// return bd;
|
||||
// }).toList();
|
||||
// response.setBatteryData(list);
|
||||
// }
|
||||
// topic.setDataDirection("M2S");
|
||||
// topic.setMessageType(MqttMessageTypeEnum.RESPONSE.getType());
|
||||
// header.setFunction(RequestFunctionTypesEnum.FUN_BATTERYINFO.getReFunction());
|
||||
// header.setTimeStamp(DateUtil.format(new Date(), DatePattern.NORM_DATETIME_FORMATTER));
|
||||
// log.info("\r\n=====>>>站端请求电池数据--MQTT发送到消息主题:{},头部信息:{},message:{}", topic,header, JSONUtil.parseObj(response, new JSONConfig().setDateFormat(DatePattern.NORM_DATETIME_PATTERN)));
|
||||
// messageUtilService.publishAESMessage(topic, header, JSONUtil.parseObj(response, new JSONConfig().setDateFormat(DatePattern.NORM_DATETIME_PATTERN)));
|
||||
// } while (page.getCurrent() < page.getPages());
|
||||
//
|
||||
// }
|
||||
|
||||
/**
|
||||
* CarInfo请求处理
|
||||
* @param topic
|
||||
* @param header
|
||||
* @param carInfoReq
|
||||
*/
|
||||
private void handleCarInfo(MessageTopic topic, MqttMessageHeader header, CarInfoReq carInfoReq) {
|
||||
String plateNum = carInfoReq.getPlateNum();
|
||||
int pageNo = 0;
|
||||
int pageSize = 500;
|
||||
Page<VehicleWechatUserRelation> page = new Page<VehicleWechatUserRelation>(pageNo, pageSize);
|
||||
do {
|
||||
pageNo += 1;
|
||||
page = new Page<VehicleWechatUserRelation>(pageNo, pageSize);
|
||||
page = vehicleWechatUserRelationDao.selectPage(page, new QueryWrapper<VehicleWechatUserRelation>()
|
||||
.eq(StringUtils.hasText(plateNum), "plate_num", plateNum));
|
||||
CarInfoResponse response = new CarInfoResponse();
|
||||
response.setCarInfoRequestId(carInfoReq.getCarInfoRequestId());
|
||||
response.setPageNo(Integer.valueOf(page.getCurrent() + ""));
|
||||
response.setPageSize(Integer.valueOf(page.getSize() + ""));
|
||||
response.setTotal(Integer.valueOf(page.getTotal() + ""));
|
||||
response.setIsOver(page.getCurrent() < page.getPages()? 0 : 1);
|
||||
List<VehicleData> list = new ArrayList<VehicleData>();
|
||||
if (page.getCurrent() > 0) {
|
||||
list = page.getRecords().stream().map(i -> {
|
||||
VehicleData vd = new VehicleData();
|
||||
BeanUtils.copyProperties(i, vd);
|
||||
return vd;
|
||||
}).toList();
|
||||
response.setVehicleData(list);
|
||||
}
|
||||
topic.setDataDirection("M2S");
|
||||
topic.setMessageType(MqttMessageTypeEnum.RESPONSE.getType());
|
||||
header.setFunction(RequestFunctionTypesEnum.FUN_CARINFO.getReFunction());
|
||||
header.setTimeStamp(DateUtil.format(new Date(), DatePattern.NORM_DATETIME_FORMATTER));
|
||||
log.info("\r\n=====>>>站端请求用户车辆数据--MQTT发送到消息主题:{},头部信息:{},message:{}", topic,header, JSONUtil.parseObj(response, new JSONConfig().setDateFormat(DatePattern.NORM_DATETIME_PATTERN)));
|
||||
messageUtilService.publishAESMessage(topic, header, JSONUtil.parseObj(response, new JSONConfig().setDateFormat(DatePattern.NORM_DATETIME_PATTERN)));
|
||||
} while (page.getCurrent() < page.getPages());
|
||||
}
|
||||
private boolean validateRequiredFields(OrderSwapBatteryPre order) {
|
||||
return Stream.of(
|
||||
order.getPlateNum(),
|
||||
order.getPhone(),
|
||||
order.getStationCode(),
|
||||
order.getStationName(),
|
||||
order.getUname(),
|
||||
order.getSwapDay(),
|
||||
order.getSwapDuration(),
|
||||
order.getReservationTime()
|
||||
).anyMatch(StrUtil::isBlankIfStr);
|
||||
}
|
||||
// /**
|
||||
// * CarInfo请求处理
|
||||
// * @param topic
|
||||
// * @param header
|
||||
// * @param carInfoReq
|
||||
// */
|
||||
// private void handleCarInfo(MessageTopic topic, MqttMessageHeader header, CarInfoReq carInfoReq) {
|
||||
// String plateNum = carInfoReq.getPlateNum();
|
||||
// int pageNo = 0;
|
||||
// int pageSize = 500;
|
||||
// Page<VehicleWechatUserRelation> page = new Page<VehicleWechatUserRelation>(pageNo, pageSize);
|
||||
// do {
|
||||
// pageNo += 1;
|
||||
// page = new Page<VehicleWechatUserRelation>(pageNo, pageSize);
|
||||
// page = vehicleWechatUserRelationDao.selectPage(page, new QueryWrapper<VehicleWechatUserRelation>()
|
||||
// .eq(StringUtils.hasText(plateNum), "plate_num", plateNum));
|
||||
// CarInfoResponse response = new CarInfoResponse();
|
||||
// response.setCarInfoRequestId(carInfoReq.getCarInfoRequestId());
|
||||
// response.setPageNo(Integer.valueOf(page.getCurrent() + ""));
|
||||
// response.setPageSize(Integer.valueOf(page.getSize() + ""));
|
||||
// response.setTotal(Integer.valueOf(page.getTotal() + ""));
|
||||
// response.setIsOver(page.getCurrent() < page.getPages()? 0 : 1);
|
||||
// List<VehicleData> list = new ArrayList<VehicleData>();
|
||||
// if (page.getCurrent() > 0) {
|
||||
// list = page.getRecords().stream().map(i -> {
|
||||
// VehicleData vd = new VehicleData();
|
||||
// BeanUtils.copyProperties(i, vd);
|
||||
// return vd;
|
||||
// }).toList();
|
||||
// response.setVehicleData(list);
|
||||
// }
|
||||
// topic.setDataDirection("M2S");
|
||||
// topic.setMessageType(MqttMessageTypeEnum.RESPONSE.getType());
|
||||
// header.setFunction(RequestFunctionTypesEnum.FUN_CARINFO.getReFunction());
|
||||
// header.setTimeStamp(DateUtil.format(new Date(), DatePattern.NORM_DATETIME_FORMATTER));
|
||||
// log.info("\r\n=====>>>站端请求用户车辆数据--MQTT发送到消息主题:{},头部信息:{},message:{}", topic,header, JSONUtil.parseObj(response, new JSONConfig().setDateFormat(DatePattern.NORM_DATETIME_PATTERN)));
|
||||
// messageUtilService.publishAESMessage(topic, header, JSONUtil.parseObj(response, new JSONConfig().setDateFormat(DatePattern.NORM_DATETIME_PATTERN)));
|
||||
// } while (page.getCurrent() < page.getPages());
|
||||
// }
|
||||
// private boolean validateRequiredFields(OrderSwapBatteryPre order) {
|
||||
// return Stream.of(
|
||||
// order.getPlateNum(),
|
||||
// order.getPhone(),
|
||||
// order.getStationCode(),
|
||||
// order.getStationName(),
|
||||
// order.getUname(),
|
||||
// order.getSwapDay(),
|
||||
// order.getSwapDuration(),
|
||||
// order.getReservationTime()
|
||||
// ).anyMatch(StrUtil::isBlankIfStr);
|
||||
// }
|
||||
}
|
||||
|
||||
@ -5,8 +5,6 @@ import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.json.JSONConfig;
|
||||
import cn.hutool.json.JSONObject;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.evotech.hd.cloud.mqtt.enums.MqttMessageTypeEnum;
|
||||
import com.evotech.hd.cloud.mqtt.enums.RequestFunctionTypesEnum;
|
||||
import com.evotech.hd.cloud.mqtt.message.MessageTopic;
|
||||
import com.evotech.hd.cloud.mqtt.message.MqttMessageHeader;
|
||||
import com.evotech.hd.cloud.mqtt.message.dto.newer.req.MqttResponse;
|
||||
@ -37,17 +35,17 @@ public interface MqttStrategyExchangeProcessor {
|
||||
|
||||
void exchange(MessageTopic topic, MqttMessageHeader header, JSONObject dataBody);
|
||||
|
||||
default void sendAESMessage(MessageTopic topic, MqttMessageHeader header, RequestFunctionTypesEnum typesEnum, MqttResponse response){
|
||||
|
||||
default void sendAESMessage(MessageTopic topic, MqttMessageHeader header, MqttResponse response){
|
||||
MessageUtilService messageUtilService = SpringUtil.getBean(MessageUtilService.class);
|
||||
// 发送
|
||||
topic.setDataDirection("M2S");
|
||||
topic.setMessageType(MqttMessageTypeEnum.RESPONSE.getType());
|
||||
header.setFunction(typesEnum.getReFunction());
|
||||
header.setTimeStamp(DateUtil.format(new Date(), DatePattern.NORM_DATETIME_FORMATTER));
|
||||
logger.info("\r\n=====>>>站端取消订单--MQTT发送到消息主题:{},头部信息:{},message:{}", topic,header, JSONUtil.parseObj(response, new JSONConfig().setDateFormat(DatePattern.NORM_DATETIME_PATTERN)));
|
||||
logger.info("\r\n=====>>>服务器回复站端消息--MQTT发送到消息主题:{},头部信息:{},message:{}", topic,header, JSONUtil.parseObj(response, new JSONConfig().setDateFormat(DatePattern.NORM_DATETIME_PATTERN)));
|
||||
messageUtilService.publishAESMessage(topic, header, JSONUtil.parseObj(response, new JSONConfig().setDateFormat(DatePattern.NORM_DATETIME_PATTERN)));
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
* 存储到mongoDB中
|
||||
* @param database
|
||||
|
||||
@ -0,0 +1,285 @@
|
||||
package com.evotech.hd.cloud.mqtt.message.processor.strategy.impl.event;
|
||||
|
||||
import cn.hutool.json.JSONObject;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.evotech.hd.cloud.entity.order.Order;
|
||||
import com.evotech.hd.cloud.entity.order.OrderDetail;
|
||||
import com.evotech.hd.cloud.mqtt.enums.EventFunctionTypesEnum;
|
||||
import com.evotech.hd.cloud.mqtt.message.MessageTopic;
|
||||
import com.evotech.hd.cloud.mqtt.message.MqttMessageHeader;
|
||||
import com.evotech.hd.cloud.mqtt.message.dto.newer.confirm.SwapCompleteConfirm;
|
||||
import com.evotech.hd.cloud.mqtt.message.dto.newer.event.SwapComplete;
|
||||
import com.evotech.hd.cloud.mqtt.message.dto.newer.req.MqttResponse;
|
||||
import com.evotech.hd.cloud.mqtt.message.dto.newer.state.OrderStatus;
|
||||
import com.evotech.hd.cloud.mqtt.message.dto.newer.state.OrderStatusData;
|
||||
import com.evotech.hd.cloud.service.BatteryStationDcService;
|
||||
import com.evotech.hd.cloud.service.OrderDetailService;
|
||||
import com.evotech.hd.cloud.service.OrderService;
|
||||
import com.evotech.hd.common.core.entity.cloud.BatteryStationDc;
|
||||
import com.evotech.hd.common.core.entity.cloud.BatteryTrace;
|
||||
import com.evotech.hd.common.core.entity.cloud.OrderSwapBatteryStep;
|
||||
import com.evotech.hd.common.core.entity.cloud.VehicleInfo;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 站端请求电池数据
|
||||
*
|
||||
* @ClassName:MqttRequestBatteryInfoExchangeProcessorImpl
|
||||
* @date: 2025年05月19日 17:41
|
||||
* @author: andy.shi
|
||||
* @contact: 17330188597
|
||||
* @remark: 开发人员联系方式 1042025947@qq.com/微信同步
|
||||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
public class MqttEventSwapCompleteExchangeProcessorImpl implements MqttStrategyEventExchangeProcessor {
|
||||
|
||||
@Resource
|
||||
OrderService orderService;
|
||||
@Resource
|
||||
OrderDetailService orderDetailService;
|
||||
|
||||
@Override
|
||||
public boolean accept(String functionName) {
|
||||
return EventFunctionTypesEnum.FUN_ORDEREVENT.getFunction().equals(functionName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exchange(MessageTopic topic, MqttMessageHeader header, JSONObject dataBody) {
|
||||
SwapComplete orderStatus = JSONUtil.toBean(dataBody, SwapComplete.class);
|
||||
OrderStatusData statusData = JSONUtil.toBean(dataBody.getJSONObject("statusData"), OrderStatusData.class);
|
||||
|
||||
MqttResponse<SwapCompleteConfirm> response = new MqttResponse();
|
||||
SwapCompleteConfirm swapRecordConfirm = new SwapCompleteConfirm();
|
||||
try {
|
||||
// 订单状态更新处理
|
||||
handleOrderStatus(orderStatus, statusData);
|
||||
response.setCode(MqttResponse.PUBLIC_SUCCESS);
|
||||
swapRecordConfirm.setAckStatus(MqttResponse.PUBLIC_SUCCESS);
|
||||
swapRecordConfirm.setOrderNo(orderStatus.getOrderNo());
|
||||
} catch (Exception e) {
|
||||
log.error("更新订单信息出现错误: {}", e.getMessage());
|
||||
response.setCode(MqttResponse.PUBLIC_ERROR);
|
||||
response.setMsg(orderStatus.getOrderNo());
|
||||
swapRecordConfirm.setAckStatus(MqttResponse.PUBLIC_ERROR);
|
||||
swapRecordConfirm.setOrderNo(orderStatus.getOrderNo());
|
||||
swapRecordConfirm.setError(e.getMessage());
|
||||
}
|
||||
response.setData(swapRecordConfirm);
|
||||
sendAESMessage(topic, header, EventFunctionTypesEnum.FUN_ORDEREVENT, response);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 订单最终状态的更新
|
||||
* @param orderStatus
|
||||
* @param statusData
|
||||
*/
|
||||
private void handleOrderStatus(SwapComplete orderStatus, OrderStatusData statusData) {
|
||||
// 换电步骤添加最后一条
|
||||
if (orderStatus.getStatus() == 3){
|
||||
Order order = alterOrderStatus(orderStatus, statusData);
|
||||
OrderSwapBatteryStep step = new OrderSwapBatteryStep();
|
||||
step.setOrderNo(orderStatus.getOrderNo());
|
||||
step.setStep(8);
|
||||
step.setStepTime(orderStatus.getStatusTime());
|
||||
step.setCtime(new Date());
|
||||
step.setCreater("SYS");
|
||||
step.setStepName(hdStepDictComponent.hdStepDictName(step.getStep()));
|
||||
orderSwapBatteryStepDao.insert(step);
|
||||
// 修改车上电池编码
|
||||
VehicleInfo vi = new VehicleInfo();
|
||||
vi.setBatCode(statusData.getRentBatCode());
|
||||
vi.setBatSoc(statusData.getRentBatSoc());
|
||||
vehicleInfoDao.update(vi, new QueryWrapper<VehicleInfo>().eq("plate_num", osb.getPlateNum()));
|
||||
// 修改2块电池的信息
|
||||
BatteryStationDc dc1 = new BatteryStationDc();
|
||||
BatteryStationDc dc2 = new BatteryStationDc();
|
||||
dc1.setStatus(1);
|
||||
dc1.setSourceFrom(1);
|
||||
dc1.setPointType(2);
|
||||
dc1.setPointCode(osb.getPlateNum());
|
||||
dc1.setPointName(osb.getPlateNum());
|
||||
dc1.setSoc(statusData.getRentBatSoc());
|
||||
dc1.setDccNo(0);
|
||||
batteryStationDcDao.update(dc1, new QueryWrapper<BatteryStationDc>().eq("bat_code", statusData.getRentBatCode()));
|
||||
dc2.setStatus(2);
|
||||
dc2.setSourceFrom(1);
|
||||
dc2.setPointType(1);
|
||||
dc2.setPointCode(osb.getStationCode());
|
||||
dc2.setPointName(osb.getStationName());
|
||||
dc2.setSoc(statusData.getReturnBatSoc());
|
||||
dc2.setDccNo(statusData.getReturnBatNo());
|
||||
batteryStationDcDao.update(dc2, new QueryWrapper<BatteryStationDc>().eq("bat_code", statusData.getReturnBatCode()));
|
||||
// 添加2块电池的溯源记录
|
||||
addBatteryTrace(orderStatus, statusData, osb);
|
||||
//计算费用方式
|
||||
log.info("\r\n=====>>>订单状态更新处理订单状态开始结算:{},{}",orderStatus.getOrderNo(),orderStatus.getStatus() );
|
||||
//费用结算
|
||||
orderSwapBatteryService.calculateCost1(orderStatus.getOrderNo(), statusData);
|
||||
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 修改订单状态方法
|
||||
*
|
||||
* @param orderStatus
|
||||
* @param statusData
|
||||
* @return
|
||||
*/
|
||||
private Order alterOrderStatus(SwapComplete orderStatus, OrderStatusData statusData) {
|
||||
Order order = orderService.getOne(new LambdaQueryWrapper<Order>().eq(Order::getOrderNo, orderStatus.getOrderNo()));
|
||||
if(ObjectUtils.isEmpty(order)){
|
||||
throw new RuntimeException("未找到订单信息");
|
||||
}
|
||||
//更新订单状态
|
||||
order.setStatus(orderStatus.getStatus());
|
||||
if (orderStatus.getStatus() == 3 || orderStatus.getStatus() == 5) {
|
||||
//如果订单是完成. 查询订单详情
|
||||
OrderDetail orderDetail = orderDetailService.getOne(new LambdaQueryWrapper<OrderDetail>().eq(OrderDetail::getOrderId, order.getPkId()));
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// /***
|
||||
// * 计费类型, 具体参考 HDConstant.OrderConstant.FEE_TYPE_*
|
||||
// */
|
||||
// private Integer feeType;
|
||||
// /***
|
||||
// * 订单金额 (此金额是当前订单的金额, 不包含基础服务费, 所以不是订单总额)
|
||||
// */
|
||||
// private Integer orderFee;
|
||||
// /***
|
||||
// * 服务费
|
||||
// */
|
||||
// private Integer serviceFee;
|
||||
// /***
|
||||
// * 单价(分)
|
||||
// */
|
||||
// private Integer unitPrice;
|
||||
// /***
|
||||
// * 服务开始时间
|
||||
// */
|
||||
// private Date serviceTimeBegin;
|
||||
// /***
|
||||
// * 服务结束时间
|
||||
// */
|
||||
// private Date serviceTimeEnd;
|
||||
// /***
|
||||
// * 订单开始时间
|
||||
// */
|
||||
// private Date orderTimeBegin;
|
||||
// /***
|
||||
// * 订单结束时间
|
||||
// */
|
||||
// private Date orderTimeEnd;
|
||||
// /***
|
||||
// * 费用标准详情
|
||||
// */
|
||||
// private String feeStandard;
|
||||
// /***
|
||||
// * 耗电量; 如果是soc结算 则是soc的差值, ODO则是里程
|
||||
// */
|
||||
// private Double electricityQuantity;
|
||||
//
|
||||
// /***
|
||||
// * 开始充电的电量
|
||||
// */
|
||||
// private Double electStart;
|
||||
// /***
|
||||
// * 结束充电的电量
|
||||
// */
|
||||
// private Double electEnd;
|
||||
// /***
|
||||
// * 租借电池包仓位
|
||||
// */
|
||||
// private String rentBatNo;
|
||||
// /***
|
||||
// * 租借电池包编码
|
||||
// */
|
||||
// private String rentBatCode;
|
||||
// /***
|
||||
// * 租借电池包SOC
|
||||
// */
|
||||
// private Double rentBatSOC;
|
||||
// /***
|
||||
// * 归还电池包仓位
|
||||
// */
|
||||
// private String returnBatNo;
|
||||
// /***
|
||||
// * 归还电池包编码
|
||||
// */
|
||||
// private String returnBatCode;
|
||||
// /***
|
||||
// * 归还电池包SOC
|
||||
// */
|
||||
// private Double returnBatSOC;
|
||||
// /***
|
||||
// * 换电模式 HDConstant.OrderConstant.CHANGE_MODE_*
|
||||
// */
|
||||
// private Integer changeMode;
|
||||
// /***
|
||||
// * 换电车道 HDConstant.OrderConstant.CHANGE_LANE_*
|
||||
// */
|
||||
// private Integer changeLane;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
order.setServiceTimeEnd(orderStatus.getStatusTime());
|
||||
BeanUtils.copyProperties(statusData, osb);
|
||||
}
|
||||
// order.setUptime(null);
|
||||
orderService.updateById(order);
|
||||
return order;
|
||||
}
|
||||
/**
|
||||
* 添加电池轨迹记录
|
||||
*
|
||||
* @param orderStatus
|
||||
* @param statusData
|
||||
* @param osb
|
||||
*/
|
||||
private void addBatteryTrace(SwapComplete orderStatus, OrderStatusData statusData, OrderSwapBattery osb) {
|
||||
BatteryTrace bt1 = new BatteryTrace();
|
||||
bt1.setOrderNo(orderStatus.getOrderNo());
|
||||
bt1.setBatCode(statusData.getRentBatCode());
|
||||
bt1.setSoc(statusData.getRentBatSoc());
|
||||
bt1.setBeginTime(orderStatus.getStatusTime());
|
||||
bt1.setPointType(2);
|
||||
bt1.setPointCode(osb.getPlateNum());
|
||||
bt1.setPointName(osb.getPlateNum());
|
||||
bt1.setCreater("SYS");
|
||||
BatteryTrace bt2 = new BatteryTrace();
|
||||
BeanUtils.copyProperties(bt1, bt2);
|
||||
bt2.setBatCode(statusData.getReturnBatCode());
|
||||
bt2.setSoc(statusData.getRentBatSoc());
|
||||
bt2.setPointType(1);
|
||||
bt2.setPointCode(osb.getStationCode());
|
||||
bt2.setPointName(osb.getStationName());
|
||||
batteryStationDcService.addTrace(bt1);
|
||||
batteryStationDcService.addTrace(bt2);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,31 @@
|
||||
package com.evotech.hd.cloud.mqtt.message.processor.strategy.impl.event;
|
||||
|
||||
import cn.hutool.core.date.DatePattern;
|
||||
import cn.hutool.json.JSONConfig;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.evotech.hd.cloud.mqtt.enums.EventFunctionTypesEnum;
|
||||
import com.evotech.hd.cloud.mqtt.enums.MqttMessageTypeEnum;
|
||||
import com.evotech.hd.cloud.mqtt.message.MessageTopic;
|
||||
import com.evotech.hd.cloud.mqtt.message.MqttMessageHeader;
|
||||
import com.evotech.hd.cloud.mqtt.message.dto.newer.req.MqttResponse;
|
||||
import com.evotech.hd.cloud.mqtt.message.processor.strategy.MqttStrategyExchangeProcessor;
|
||||
|
||||
/**
|
||||
* 接口
|
||||
*
|
||||
* @ClassName:MqttStrategyequestExchangeProcessor
|
||||
* @date: 2025年06月19日 16:29
|
||||
* @author: andy.shi
|
||||
* @contact: 17330188597
|
||||
* @remark: 开发人员联系方式 1042025947@qq.com/微信同步
|
||||
*/
|
||||
public interface MqttStrategyEventExchangeProcessor extends MqttStrategyExchangeProcessor {
|
||||
|
||||
|
||||
default void sendAESMessage(MessageTopic topic, MqttMessageHeader header, EventFunctionTypesEnum typesEnum, MqttResponse response){
|
||||
topic.setMessageType(MqttMessageTypeEnum.CONFIRM.getType());
|
||||
header.setFunction(typesEnum.getReFunction());
|
||||
logger.info("\r\n=====>>>回复站端的EVENT消息--MQTT发送到消息主题:{},头部信息:{},message:{}", topic,header, JSONUtil.parseObj(response, new JSONConfig().setDateFormat(DatePattern.NORM_DATETIME_PATTERN)));
|
||||
sendAESMessage(topic, header, response);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,67 @@
|
||||
package com.evotech.hd.cloud.mqtt.message.processor.strategy.impl.request;
|
||||
|
||||
import cn.hutool.json.JSONObject;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.evotech.hd.cloud.mqtt.enums.RequestFunctionTypesEnum;
|
||||
import com.evotech.hd.cloud.mqtt.message.MessageTopic;
|
||||
import com.evotech.hd.cloud.mqtt.message.MqttMessageHeader;
|
||||
import com.evotech.hd.cloud.mqtt.message.dto.newer.req.MqttResponse;
|
||||
import com.evotech.hd.cloud.mqtt.message.dto.newer.req.battery.BatteryData;
|
||||
import com.evotech.hd.cloud.mqtt.message.dto.newer.req.battery.BatteryInfoReq;
|
||||
import com.evotech.hd.cloud.service.BatteryStationDcService;
|
||||
import com.evotech.hd.common.core.constant.HDConstant;
|
||||
import com.evotech.hd.common.core.entity.cloud.BatteryStationDc;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 站端请求电池数据
|
||||
*
|
||||
* @ClassName:MqttRequestBatteryInfoExchangeProcessorImpl
|
||||
* @date: 2025年05月19日 17:41
|
||||
* @author: andy.shi
|
||||
* @contact: 17330188597
|
||||
* @remark: 开发人员联系方式 1042025947@qq.com/微信同步
|
||||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
public class MqttRequestBatteryInfoExchangeProcessorImpl implements MqttStrategyRequestExchangeProcessor {
|
||||
|
||||
@Resource
|
||||
BatteryStationDcService batteryStationDcService;
|
||||
|
||||
@Override
|
||||
public boolean accept(String functionName) {
|
||||
return RequestFunctionTypesEnum.FUN_BATTERYINFO.getFunction().equals(functionName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exchange(MessageTopic topic, MqttMessageHeader header, JSONObject dataBody) {
|
||||
BatteryInfoReq batteryInfoReq = JSONUtil.toBean(dataBody, BatteryInfoReq.class);
|
||||
String batCode = batteryInfoReq.getBatCode();
|
||||
//直接默认为错误
|
||||
MqttResponse<List<BatteryData>> response = new MqttResponse<List<BatteryData>>().createError(batteryInfoReq.getBatteryInfoRequestId());
|
||||
|
||||
List<BatteryStationDc> list = Collections.emptyList();
|
||||
if(org.apache.commons.lang3.StringUtils.isNotEmpty(batCode)){
|
||||
list.addAll(batteryStationDcService.list(new LambdaQueryWrapper<BatteryStationDc>().eq(BatteryStationDc::getBatCode, batCode).eq(BatteryStationDc::getDelFlag, HDConstant.DELETE_NO)));
|
||||
}else{
|
||||
//如果没有电池编号, 则以当前站的电池数据为准
|
||||
list.addAll(batteryStationDcService.listByStationCode(topic.getStationCode()));
|
||||
}
|
||||
if(com.evotech.hd.common.core.utils.Collections.isNotEmpty(list)){
|
||||
response.setCode(MqttResponse.PUBLIC_SUCCESS);
|
||||
response.setData(list.stream().map(x -> new BatteryData(x.getBatCode(), x.getProductionDate(), x.getRegistrationDate())).collect(Collectors.toList()));
|
||||
}else {
|
||||
response.setMsg("未查询到电池信息");
|
||||
}
|
||||
sendAESMessage(topic, header, RequestFunctionTypesEnum.FUN_BATTERYINFO, response);
|
||||
}
|
||||
|
||||
}
|
||||
@ -6,7 +6,6 @@ import com.evotech.hd.cloud.mqtt.enums.RequestFunctionTypesEnum;
|
||||
import com.evotech.hd.cloud.mqtt.message.MessageTopic;
|
||||
import com.evotech.hd.cloud.mqtt.message.MqttMessageHeader;
|
||||
import com.evotech.hd.cloud.mqtt.message.dto.newer.req.MqttResponse;
|
||||
import com.evotech.hd.cloud.mqtt.message.processor.strategy.MqttStrategyExchangeProcessor;
|
||||
import com.evotech.hd.cloud.service.OrderService;
|
||||
import com.evotech.hd.common.core.Dto.Result;
|
||||
import com.evotech.hd.common.core.utils.Collections;
|
||||
@ -16,7 +15,6 @@ import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* 取消订单请求类
|
||||
*
|
||||
* @ClassName:MqttRequestCancelOrderExchangeProcessorImpl
|
||||
* @date: 2025年05月19日 14:51
|
||||
* @author: andy.shi
|
||||
@ -24,7 +22,7 @@ import org.springframework.util.Assert;
|
||||
* @remark: 开发人员联系方式 1042025947@qq.com/微信同步
|
||||
*/
|
||||
@Service
|
||||
public class MqttRequestCancelOrderExchangeProcessorImpl implements MqttStrategyExchangeProcessor {
|
||||
public class MqttRequestCancelOrderExchangeProcessorImpl implements MqttStrategyRequestExchangeProcessor {
|
||||
@Resource
|
||||
OrderService orderService;
|
||||
|
||||
|
||||
@ -0,0 +1,71 @@
|
||||
package com.evotech.hd.cloud.mqtt.message.processor.strategy.impl.request;
|
||||
|
||||
import cn.hutool.json.JSONObject;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.evotech.hd.cloud.dao.VehicleWechatUserRelationDao;
|
||||
import com.evotech.hd.cloud.mqtt.enums.RequestFunctionTypesEnum;
|
||||
import com.evotech.hd.cloud.mqtt.message.MessageTopic;
|
||||
import com.evotech.hd.cloud.mqtt.message.MqttMessageHeader;
|
||||
import com.evotech.hd.cloud.mqtt.message.dto.newer.req.MqttResponse;
|
||||
import com.evotech.hd.cloud.mqtt.message.dto.newer.req.carinfo.CarInfoReq;
|
||||
import com.evotech.hd.cloud.mqtt.message.dto.newer.req.carinfo.VehicleData;
|
||||
import com.evotech.hd.common.core.entity.cloud.VehicleWechatUserRelation;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 站端请求车辆信息
|
||||
* @ClassName:MqttRequestCarInfoExchangeProcessorImpl
|
||||
* @date: 2025年06月19日 11:21
|
||||
* @author: andy.shi
|
||||
* @contact: 17330188597
|
||||
* @remark: 开发人员联系方式 1042025947@qq.com/微信同步
|
||||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
public class MqttRequestCarInfoExchangeProcessorImpl implements MqttStrategyRequestExchangeProcessor {
|
||||
|
||||
@Resource
|
||||
private VehicleWechatUserRelationDao vehicleWechatUserRelationDao;
|
||||
|
||||
@Override
|
||||
public boolean accept(String functionName) {
|
||||
return RequestFunctionTypesEnum.FUN_CARINFO.getFunction().equals(functionName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exchange(MessageTopic topic, MqttMessageHeader header, JSONObject dataBody) {
|
||||
CarInfoReq carInfoReq = JSONUtil.toBean(dataBody, CarInfoReq.class);
|
||||
//直接默认为错误
|
||||
MqttResponse<List<VehicleData>> response = new MqttResponse<List<VehicleData>>().createError(carInfoReq.getCarInfoRequestId());
|
||||
String plateNum = carInfoReq.getPlateNum();
|
||||
if(StringUtils.isEmpty(plateNum)){
|
||||
response.setMsg("没有车牌号参数");
|
||||
}else{
|
||||
List<VehicleWechatUserRelation> list = vehicleWechatUserRelationDao.selectList(new LambdaQueryWrapper<VehicleWechatUserRelation>().eq( VehicleWechatUserRelation::getPlateNum, plateNum));
|
||||
if(com.evotech.hd.common.core.utils.Collections.isNotEmpty(list)){
|
||||
response.setCode(MqttResponse.PUBLIC_SUCCESS);
|
||||
response.setData(list.stream().map(x->convertVehicleData(x)).collect(Collectors.toList()));
|
||||
}else {
|
||||
response.setMsg("未查询到车辆信息");
|
||||
}
|
||||
}
|
||||
sendAESMessage(topic, header, RequestFunctionTypesEnum.FUN_CARINFO, response);
|
||||
}
|
||||
|
||||
|
||||
public static VehicleData convertVehicleData(VehicleWechatUserRelation data){
|
||||
VehicleData vd = new VehicleData();
|
||||
BeanUtils.copyProperties(data, vd);
|
||||
return vd;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -1,23 +1,22 @@
|
||||
package com.evotech.hd.cloud.mqtt.message.processor.strategy.impl.request;
|
||||
|
||||
import cn.hutool.core.date.DatePattern;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.json.JSONConfig;
|
||||
import cn.hutool.json.JSONObject;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.evotech.hd.cloud.mqtt.enums.MqttMessageTypeEnum;
|
||||
import com.evotech.hd.cloud.mqtt.enums.RequestFunctionTypesEnum;
|
||||
import com.evotech.hd.cloud.mqtt.message.MessageTopic;
|
||||
import com.evotech.hd.cloud.mqtt.message.MqttMessageHeader;
|
||||
import com.evotech.hd.cloud.mqtt.message.dto.newer.req.order.OrdeSwapBatteryPreRespose;
|
||||
import com.evotech.hd.cloud.mqtt.message.dto.newer.req.MqttResponse;
|
||||
import com.evotech.hd.cloud.mqtt.message.processor.strategy.MqttStrategyExchangeProcessor;
|
||||
import com.evotech.hd.common.core.entity.Result;
|
||||
import com.evotech.hd.cloud.service.OrderSwapBatteryPreService;
|
||||
import com.evotech.hd.cloud.service.WechatUserService;
|
||||
import com.evotech.hd.common.core.Dto.Result;
|
||||
import com.evotech.hd.common.core.entity.cloud.OrderSwapBatteryPre;
|
||||
import com.evotech.hd.common.core.entity.wechat.WechatUser;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
/**
|
||||
@ -30,7 +29,12 @@ import java.util.stream.Stream;
|
||||
* @remark: 开发人员联系方式 1042025947@qq.com/微信同步
|
||||
*/
|
||||
@Service
|
||||
public class MqttRequestPreOrderExchangeProcessorImpl implements MqttStrategyExchangeProcessor {
|
||||
public class MqttRequestPreOrderExchangeProcessorImpl implements MqttStrategyRequestExchangeProcessor {
|
||||
|
||||
@Resource
|
||||
WechatUserService wechatUserService;
|
||||
@Resource
|
||||
OrderSwapBatteryPreService orderSwapBatteryPreService;
|
||||
@Override
|
||||
public boolean accept(String functionName) {
|
||||
return RequestFunctionTypesEnum.FUN_PREORDER.getFunction().equals(functionName);
|
||||
@ -39,40 +43,38 @@ public class MqttRequestPreOrderExchangeProcessorImpl implements MqttStrategyExc
|
||||
@Override
|
||||
public void exchange(MessageTopic topic, MqttMessageHeader header, JSONObject dataBody) {
|
||||
OrderSwapBatteryPre orderSwapBatteryPre = JSONUtil.toBean(dataBody, OrderSwapBatteryPre.class);
|
||||
OrdeSwapBatteryPreRespose response = new OrdeSwapBatteryPreRespose();
|
||||
Date d = new Date();
|
||||
MqttResponse response = new MqttResponse().createError(orderSwapBatteryPre.getSourceId());
|
||||
// 1. 基础字段校验
|
||||
if (validateRequiredFields(orderSwapBatteryPre)) {
|
||||
// 返回错误消息
|
||||
response.setStationPreOrderId(orderSwapBatteryPre.getSourceId());
|
||||
response.setMsg("预约信息不完整");
|
||||
response.setCode(0);
|
||||
}else {
|
||||
//添加预约单
|
||||
WechatUser wechatUser =wechatUserService.selectUcode(orderSwapBatteryPre.getPhone(),orderSwapBatteryPre.getUname());
|
||||
//查询用户编码
|
||||
orderSwapBatteryPre.setUcode(wechatUser.getWuid());
|
||||
orderSwapBatteryPre.setSource(3);
|
||||
Result<Integer> integerResult = orderSwapBatteryService.addPre(orderSwapBatteryPre);
|
||||
//添加失败情况
|
||||
if (integerResult.getStatus()==0){
|
||||
response.setStationPreOrderId(orderSwapBatteryPre.getSourceId());
|
||||
//返回失败状态
|
||||
response.setMsg(integerResult.getMsg());
|
||||
response.setCode(0);
|
||||
if(ObjectUtils.isEmpty(wechatUser)){
|
||||
response.setMsg("未找到预约人信息");
|
||||
}else{
|
||||
response.setStationPreOrderId(orderSwapBatteryPre.getSourceId());
|
||||
response.setCode(1);
|
||||
response.setMsg("OK");
|
||||
// 创建预约单信息
|
||||
orderSwapBatteryPre.setUcode(wechatUser.getWuid());
|
||||
orderSwapBatteryPre.setSource(3);
|
||||
Result<Boolean> integerResult = orderSwapBatteryPreService.addOrderSwapBatteryPre(orderSwapBatteryPre);
|
||||
//检查结果
|
||||
if (integerResult.getData()){
|
||||
//返回成功
|
||||
response.setCode(MqttResponse.PUBLIC_SUCCESS);
|
||||
}else{
|
||||
response.setMsg(integerResult.getMsg());
|
||||
}
|
||||
}
|
||||
}
|
||||
sendAESMessage(topic, header, RequestFunctionTypesEnum.FUN_PREORDER, response);
|
||||
|
||||
// 发送
|
||||
topic.setDataDirection("M2S");
|
||||
topic.setMessageType(MqttMessageTypeEnum.RESPONSE.getType());
|
||||
header.setFunction(RequestFunctionTypesEnum.FUN_PREORDER.getReFunction());
|
||||
header.setTimeStamp(DateUtil.format(d, DatePattern.NORM_DATETIME_FORMATTER));
|
||||
log.info("\r\n=====>>>站端添加预约单--MQTT发送到消息主题:{},头部信息:{},message:{}", topic,header, JSONUtil.parseObj(response, new JSONConfig().setDateFormat(DatePattern.NORM_DATETIME_PATTERN)));
|
||||
messageUtilService.publishAESMessage(topic, header, JSONUtil.parseObj(response, new JSONConfig().setDateFormat(DatePattern.NORM_DATETIME_PATTERN)));
|
||||
// topic.setDataDirection("M2S");
|
||||
// topic.setMessageType(MqttMessageTypeEnum.RESPONSE.getType());
|
||||
// header.setFunction(RequestFunctionTypesEnum.FUN_PREORDER.getReFunction());
|
||||
// header.setTimeStamp(DateUtil.format(d, DatePattern.NORM_DATETIME_FORMATTER));
|
||||
// log.info("\r\n=====>>>站端添加预约单--MQTT发送到消息主题:{},头部信息:{},message:{}", topic,header, JSONUtil.parseObj(response, new JSONConfig().setDateFormat(DatePattern.NORM_DATETIME_PATTERN)));
|
||||
// messageUtilService.publishAESMessage(topic, header, JSONUtil.parseObj(response, new JSONConfig().setDateFormat(DatePattern.NORM_DATETIME_PATTERN)));
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -27,7 +27,7 @@ import org.springframework.util.Assert;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
public class MqttRequestPushCarInfoExchangeProcessorImpl implements MqttStrategyExchangeProcessor {
|
||||
public class MqttRequestPushCarInfoExchangeProcessorImpl implements MqttStrategyRequestExchangeProcessor {
|
||||
|
||||
@Resource
|
||||
VehicleService vehicleService;
|
||||
|
||||
@ -0,0 +1,95 @@
|
||||
package com.evotech.hd.cloud.mqtt.message.processor.strategy.impl.request;
|
||||
|
||||
import cn.hutool.core.date.DatePattern;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.json.JSONObject;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.evotech.hd.cloud.entity.order.Order;
|
||||
import com.evotech.hd.cloud.mqtt.enums.RequestFunctionTypesEnum;
|
||||
import com.evotech.hd.cloud.mqtt.message.MessageTopic;
|
||||
import com.evotech.hd.cloud.mqtt.message.MqttMessageHeader;
|
||||
import com.evotech.hd.cloud.mqtt.message.dto.newer.req.MqttResponse;
|
||||
import com.evotech.hd.cloud.mqtt.message.dto.newer.req.order.OrderByPlateNumReq;
|
||||
import com.evotech.hd.cloud.mqtt.message.dto.newer.req.order.OrderData;
|
||||
import com.evotech.hd.cloud.service.OrderService;
|
||||
import com.evotech.hd.cloud.service.OrderSwapBatteryPreService;
|
||||
import com.evotech.hd.common.core.Dto.Result;
|
||||
import com.evotech.hd.common.core.entity.cloud.OrderSwapBatteryPre;
|
||||
import com.evotech.hd.common.core.enums.CodeMsg;
|
||||
import com.evotech.hd.common.core.enums.OrderStatusEnums;
|
||||
import com.evotech.hd.common.redis.utils.RedisServiceUtils;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 站端根据车牌号查询订单
|
||||
*
|
||||
* @ClassName:MqttRequestQueryOrderExchangeProcessorImpl
|
||||
* @date: 2025年05月19日 17:41
|
||||
* @author: andy.shi
|
||||
* @contact: 17330188597
|
||||
* @remark: 开发人员联系方式 1042025947@qq.com/微信同步
|
||||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
public class MqttRequestQueryOrderExchangeProcessorImpl implements MqttStrategyRequestExchangeProcessor {
|
||||
|
||||
@Resource
|
||||
OrderService orderService;
|
||||
@Resource
|
||||
OrderSwapBatteryPreService OrderSwapBatteryPreService;
|
||||
|
||||
@Override
|
||||
public boolean accept(String functionName) {
|
||||
return RequestFunctionTypesEnum.FUN_ORDERBYPLATENUM.getFunction().equals(functionName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exchange(MessageTopic topic, MqttMessageHeader header, JSONObject dataBody) {
|
||||
OrderByPlateNumReq orderByPlateNumReq = JSONUtil.toBean(dataBody, OrderByPlateNumReq.class);
|
||||
//直接默认为错误
|
||||
MqttResponse<OrderData> response = new MqttResponse<OrderData>().createError(orderByPlateNumReq.getOrderRequestId());
|
||||
// 查预约
|
||||
OrderSwapBatteryPre orderSwapBatteryPre = OrderSwapBatteryPreService.getOne(new LambdaQueryWrapper<OrderSwapBatteryPre>()
|
||||
.eq(OrderSwapBatteryPre::getPlateNum, orderByPlateNumReq.getPlateNum())
|
||||
.eq(OrderSwapBatteryPre::getStationCode, orderByPlateNumReq.getStationCode())
|
||||
.eq(OrderSwapBatteryPre::getStatus, 1)
|
||||
.eq(OrderSwapBatteryPre::getSwapDay, DateUtil.format(new Date(), DatePattern.PURE_DATE_FORMATTER))
|
||||
.last("limit 1"));
|
||||
if (ObjectUtils.isEmpty(orderSwapBatteryPre)) {
|
||||
response.setMsg("车辆未预约,请扫码进入");
|
||||
} else {
|
||||
Order order = orderService.getOne(new LambdaQueryWrapper<Order>()
|
||||
.eq(Order::getPlateNum, orderSwapBatteryPre.getPlateNum())
|
||||
.eq(Order::getStationCode, orderSwapBatteryPre.getStationCode())
|
||||
.eq(Order::getOrderPreId, orderSwapBatteryPre.getPkId())
|
||||
.eq(Order::getStatus, OrderStatusEnums.CREATE.getCode()));
|
||||
if (order == null) {
|
||||
Result<Order> result = orderService.addOrderByPre(orderSwapBatteryPre);
|
||||
//如果不等于成功
|
||||
if(!CodeMsg.SUCCESS.getCode().equals(result.getCode())){
|
||||
response.setMsg(result.getMsg());
|
||||
}else{
|
||||
order = result.getData();
|
||||
response.setCode(MqttResponse.PUBLIC_SUCCESS);
|
||||
}
|
||||
}
|
||||
|
||||
//走到此处, 证明上面逻辑没有问题, 需要删除预约单过期标识
|
||||
RedisServiceUtils.del("preorder:expire:"+orderSwapBatteryPre.getPkId());
|
||||
// 返回数据
|
||||
OrderData od = new OrderData();
|
||||
BeanUtils.copyProperties(order, od);
|
||||
response.setData(od);
|
||||
|
||||
}
|
||||
sendAESMessage(topic, header, RequestFunctionTypesEnum.FUN_ORDERBYPLATENUM, response);
|
||||
}
|
||||
|
||||
}
|
||||
@ -6,7 +6,6 @@ import com.evotech.hd.cloud.mqtt.enums.RequestFunctionTypesEnum;
|
||||
import com.evotech.hd.cloud.mqtt.message.MessageTopic;
|
||||
import com.evotech.hd.cloud.mqtt.message.MqttMessageHeader;
|
||||
import com.evotech.hd.cloud.mqtt.message.dto.newer.req.MqttResponse;
|
||||
import com.evotech.hd.cloud.mqtt.message.processor.strategy.MqttStrategyExchangeProcessor;
|
||||
import com.evotech.hd.cloud.service.BatteryStationCdStrategyService;
|
||||
import com.evotech.hd.common.core.entity.cloud.BatteryStationCdStrategy;
|
||||
import jakarta.annotation.Resource;
|
||||
@ -26,7 +25,7 @@ import java.util.List;
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class MqttRequestStrategyExchangeProcessorImpl implements MqttStrategyExchangeProcessor {
|
||||
public class MqttRequestStrategyExchangeProcessorImpl implements MqttStrategyRequestExchangeProcessor {
|
||||
@Resource
|
||||
BatteryStationCdStrategyService batteryStationCdStrategyService;
|
||||
|
||||
|
||||
@ -0,0 +1,32 @@
|
||||
package com.evotech.hd.cloud.mqtt.message.processor.strategy.impl.request;
|
||||
|
||||
import cn.hutool.core.date.DatePattern;
|
||||
import cn.hutool.json.JSONConfig;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.evotech.hd.cloud.mqtt.enums.MqttMessageTypeEnum;
|
||||
import com.evotech.hd.cloud.mqtt.enums.RequestFunctionTypesEnum;
|
||||
import com.evotech.hd.cloud.mqtt.message.MessageTopic;
|
||||
import com.evotech.hd.cloud.mqtt.message.MqttMessageHeader;
|
||||
import com.evotech.hd.cloud.mqtt.message.dto.newer.req.MqttResponse;
|
||||
import com.evotech.hd.cloud.mqtt.message.processor.strategy.MqttStrategyExchangeProcessor;
|
||||
|
||||
/**
|
||||
* 接口
|
||||
*
|
||||
* @ClassName:MqttStrategyequestExchangeProcessor
|
||||
* @date: 2025年06月19日 16:29
|
||||
* @author: andy.shi
|
||||
* @contact: 17330188597
|
||||
* @remark: 开发人员联系方式 1042025947@qq.com/微信同步
|
||||
*/
|
||||
public interface MqttStrategyRequestExchangeProcessor extends MqttStrategyExchangeProcessor {
|
||||
|
||||
|
||||
|
||||
default void sendAESMessage(MessageTopic topic, MqttMessageHeader header, RequestFunctionTypesEnum typesEnum, MqttResponse response){
|
||||
topic.setMessageType(MqttMessageTypeEnum.RESPONSE.getType());
|
||||
header.setFunction(typesEnum.getReFunction());
|
||||
logger.info("\r\n=====>>>回复站端的REQUEST消息--MQTT发送到消息主题:{},头部信息:{},message:{}", topic,header, JSONUtil.parseObj(response, new JSONConfig().setDateFormat(DatePattern.NORM_DATETIME_PATTERN)));
|
||||
sendAESMessage(topic, header, response);
|
||||
}
|
||||
}
|
||||
@ -1,13 +1,14 @@
|
||||
package com.evotech.hd.cloud.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.evotech.hd.cloud.entity.request.PageListBatteryStationDcRequest;
|
||||
import com.evotech.hd.common.core.entity.Result;
|
||||
import com.evotech.hd.common.core.entity.cloud.BatteryStationDc;
|
||||
import com.evotech.hd.common.core.entity.cloud.BatteryTrace;
|
||||
|
||||
public interface BatteryStationDcService {
|
||||
import java.util.List;
|
||||
|
||||
public interface BatteryStationDcService extends IService<BatteryStationDc> {
|
||||
|
||||
public Result<Integer> add(BatteryStationDc bsdc);
|
||||
|
||||
@ -22,4 +23,6 @@ public interface BatteryStationDcService {
|
||||
public Result<Integer> addTrace(BatteryTrace bt);
|
||||
|
||||
public Result<Integer> deleteTrace(Integer id);
|
||||
|
||||
public List<BatteryStationDc> listByStationCode(String stationCode);
|
||||
}
|
||||
|
||||
@ -0,0 +1,16 @@
|
||||
package com.evotech.hd.cloud.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.evotech.hd.cloud.entity.order.OrderDetail;
|
||||
|
||||
/**
|
||||
* 接口
|
||||
*
|
||||
* @ClassName:OrderDetailService
|
||||
* @date: 2025年06月19日 17:24
|
||||
* @author: andy.shi
|
||||
* @contact: 17330188597
|
||||
* @remark: 开发人员联系方式 1042025947@qq.com/微信同步
|
||||
*/
|
||||
public interface OrderDetailService extends IService<OrderDetail> {
|
||||
}
|
||||
@ -1,11 +1,12 @@
|
||||
package com.evotech.hd.cloud.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.evotech.hd.cloud.entity.order.Order;
|
||||
import com.evotech.hd.common.core.Dto.Result;
|
||||
import com.evotech.hd.common.core.Dto.order.OrderListVo;
|
||||
import com.evotech.hd.common.core.entity.cloud.OrderSwapBatteryPre;
|
||||
import com.evotech.hd.common.core.entity.cloud.request.PageListSwapOrderRequest;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
|
||||
/**
|
||||
* 订单接口
|
||||
@ -34,4 +35,11 @@ public interface OrderService extends IService<Order> {
|
||||
* 更改订单状态信息
|
||||
*/
|
||||
public Result<Boolean> updateStatus(String orderNo, Integer status);
|
||||
|
||||
public Result<Order> addOrderByPre(OrderSwapBatteryPre orderSwapBatteryPre);
|
||||
|
||||
/***
|
||||
* 开始换电
|
||||
*/
|
||||
public Result<Boolean> startSwap(String wuid, String orderId);
|
||||
}
|
||||
|
||||
@ -1,5 +1,9 @@
|
||||
package com.evotech.hd.cloud.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.evotech.hd.common.core.Dto.Result;
|
||||
import com.evotech.hd.common.core.entity.cloud.OrderSwapBatteryPre;
|
||||
|
||||
/**
|
||||
* 预约单接口
|
||||
*
|
||||
@ -9,7 +13,9 @@ package com.evotech.hd.cloud.service;
|
||||
* @contact: 17330188597
|
||||
* @remark: 开发人员联系方式 1042025947@qq.com/微信同步
|
||||
*/
|
||||
public interface OrderSwapBatteryPreService {
|
||||
public interface OrderSwapBatteryPreService extends IService<OrderSwapBatteryPre> {
|
||||
|
||||
public Boolean addPreByPlateNum(String plateNum, String stationCode);
|
||||
|
||||
public Result<Boolean> addOrderSwapBatteryPre(OrderSwapBatteryPre orderSwapBatteryPre);
|
||||
}
|
||||
|
||||
@ -1,63 +1,62 @@
|
||||
//package com.evotech.hd.cloud.service;
|
||||
//
|
||||
//import com.evotech.hd.cloud.entity.vo.NativePayVO;
|
||||
//import com.evotech.hd.cloud.mqtt.message.dto.newer.state.OrderStatusData;
|
||||
//import com.evotech.hd.common.core.entity.Result;
|
||||
//import com.evotech.hd.common.core.entity.cloud.OrderSwapBattery;
|
||||
//import com.evotech.hd.common.core.entity.cloud.OrderSwapBatteryPre;
|
||||
//import com.evotech.hd.common.core.entity.cloud.OrderSwapBatteryStep;
|
||||
//import com.evotech.hd.common.core.entity.cloud.request.BatterySwapResponse;
|
||||
//import com.evotech.hd.common.core.entity.cloud.request.PageListSwapOrderPreRequest;
|
||||
//import com.evotech.hd.common.core.entity.cloud.request.PageListSwapOrderRequest;
|
||||
//
|
||||
//import java.text.ParseException;
|
||||
//import java.util.List;
|
||||
//
|
||||
//public interface OrderSwapBatteryService {
|
||||
//
|
||||
// public Result<Integer> addPre(OrderSwapBatteryPre osbp);
|
||||
//
|
||||
// public Result<Integer> cancelPre(Integer id, Integer status);
|
||||
//
|
||||
// public Result<List<OrderSwapBatteryPre>> listPre(PageListSwapOrderPreRequest plsopr) throws ParseException;
|
||||
//
|
||||
package com.evotech.hd.cloud.service;
|
||||
|
||||
import com.evotech.hd.cloud.entity.vo.NativePayVO;
|
||||
import com.evotech.hd.cloud.mqtt.message.dto.newer.state.OrderStatusData;
|
||||
import com.evotech.hd.common.core.entity.Result;
|
||||
import com.evotech.hd.common.core.entity.cloud.OrderSwapBatteryPre;
|
||||
import com.evotech.hd.common.core.entity.cloud.OrderSwapBatteryStep;
|
||||
import com.evotech.hd.common.core.entity.cloud.request.BatterySwapResponse;
|
||||
import com.evotech.hd.common.core.entity.cloud.request.PageListSwapOrderPreRequest;
|
||||
import com.evotech.hd.common.core.entity.cloud.request.PageListSwapOrderRequest;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.util.List;
|
||||
|
||||
public interface OrderSwapBatteryService {
|
||||
|
||||
public Result<Integer> addPre(OrderSwapBatteryPre osbp);
|
||||
|
||||
public Result<Integer> cancelPre(Integer id, Integer status);
|
||||
|
||||
public Result<List<OrderSwapBatteryPre>> listPre(PageListSwapOrderPreRequest plsopr) throws ParseException;
|
||||
|
||||
// public Result<Integer> add(OrderSwapBattery osb);
|
||||
//
|
||||
// public Result<Integer> delete(Integer id);
|
||||
//
|
||||
|
||||
public Result<Integer> delete(Integer id);
|
||||
|
||||
// public Result<Integer> update(OrderSwapBattery osb);
|
||||
//
|
||||
|
||||
// public Result<List<OrderSwapBattery>> list(PageListSwapOrderRequest plsor);
|
||||
//
|
||||
|
||||
// public Result<List<OrderSwapBattery>> listByCompany(PageListSwapOrderRequest plsor);
|
||||
//
|
||||
// public Result<List<OrderSwapBatteryStep>> listStep(String orderNo);
|
||||
//
|
||||
// public Result<String> calculateCost1(String orderNo, OrderStatusData statusData);
|
||||
//
|
||||
|
||||
public Result<List<OrderSwapBatteryStep>> listStep(String orderNo);
|
||||
|
||||
public Result<String> calculateCost1(String orderNo, OrderStatusData statusData);
|
||||
|
||||
// public Result<String> calculateCost(OrderSwapBattery osb);
|
||||
//
|
||||
// public Result<String> walletPay(String orderNo, String wuid, String uname);
|
||||
//
|
||||
// public Result<String> companyNativePay(NativePayVO prePay);
|
||||
//
|
||||
// public Result<String> orderQuery(String outTradeNo);
|
||||
//
|
||||
//
|
||||
// public Result<Integer> cancelOrder(String orderNo, Integer status);
|
||||
//
|
||||
// public Result<Integer> markOrderAsExpired(Integer pkId);
|
||||
//
|
||||
// public Result<Boolean> startSwap(String wuid,String orderId);
|
||||
//
|
||||
// public Result<BatterySwapResponse> getStartSwap(String wuid, String orderId);
|
||||
//
|
||||
// public Result<Integer> checkList(PageListSwapOrderRequest plsor);
|
||||
//
|
||||
//
|
||||
// public Boolean addPreByPlateNum(String plateNum, String stationCode);
|
||||
//
|
||||
// public List<OrderSwapBatteryPre> findOrderSwapBatteryPreList(String stationCode);
|
||||
//
|
||||
// Boolean clearOrderSwapBatteryPre(List<Integer> ids);
|
||||
//}
|
||||
|
||||
public Result<String> walletPay(String orderNo, String wuid, String uname);
|
||||
|
||||
public Result<String> companyNativePay(NativePayVO prePay);
|
||||
|
||||
public Result<String> orderQuery(String outTradeNo);
|
||||
|
||||
|
||||
public Result<Integer> cancelOrder(String orderNo, Integer status);
|
||||
|
||||
public Result<Integer> markOrderAsExpired(Integer pkId);
|
||||
|
||||
public Result<Boolean> startSwap(String wuid,String orderId);
|
||||
|
||||
public Result<BatterySwapResponse> getStartSwap(String wuid, String orderId);
|
||||
|
||||
public Result<Integer> checkList(PageListSwapOrderRequest plsor);
|
||||
|
||||
|
||||
public Boolean addPreByPlateNum(String plateNum, String stationCode);
|
||||
|
||||
public List<OrderSwapBatteryPre> findOrderSwapBatteryPreList(String stationCode);
|
||||
|
||||
Boolean clearOrderSwapBatteryPre(List<Integer> ids);
|
||||
}
|
||||
|
||||
@ -1,14 +1,8 @@
|
||||
package com.evotech.hd.cloud.service.impl;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.evotech.hd.cloud.dao.BatteryStationDcDao;
|
||||
import com.evotech.hd.cloud.dao.BatteryTraceDao;
|
||||
import com.evotech.hd.cloud.entity.request.PageListBatteryStationDcRequest;
|
||||
@ -17,12 +11,17 @@ import com.evotech.hd.common.core.entity.Result;
|
||||
import com.evotech.hd.common.core.entity.cloud.BatteryStationDc;
|
||||
import com.evotech.hd.common.core.entity.cloud.BatteryTrace;
|
||||
import com.evotech.hd.common.core.enums.CodeMsg;
|
||||
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@Service
|
||||
public class BatteryStationDcServiceImpl implements BatteryStationDcService {
|
||||
public class BatteryStationDcServiceImpl extends ServiceImpl<BatteryStationDcDao, BatteryStationDc> implements BatteryStationDcService {
|
||||
|
||||
@Resource
|
||||
private BatteryStationDcDao batteryStationDcDao;
|
||||
@ -113,4 +112,9 @@ public class BatteryStationDcServiceImpl implements BatteryStationDcService {
|
||||
return new Result<Integer>().error("删除追溯失败!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BatteryStationDc> listByStationCode(String stationCode) {
|
||||
return getBaseMapper().getDcByStationCode(stationCode);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,26 @@
|
||||
package com.evotech.hd.cloud.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.evotech.hd.cloud.dao.OrderDetailDao;
|
||||
import com.evotech.hd.cloud.entity.order.OrderDetail;
|
||||
import com.evotech.hd.cloud.service.OrderDetailService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* 订单详情实现类
|
||||
*
|
||||
* @ClassName:OrderDetailServiceImpl
|
||||
* @date: 2025年05月16日 13:58
|
||||
* @author: andy.shi
|
||||
* @contact: 17330188597
|
||||
* @remark: 开发人员联系方式 1042025947@qq.com/微信同步
|
||||
*/
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
public class OrderDetailServiceImpl extends ServiceImpl<OrderDetailDao, OrderDetail> implements OrderDetailService {
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -1,19 +1,32 @@
|
||||
package com.evotech.hd.cloud.service.impl;
|
||||
|
||||
import cn.hutool.core.date.DatePattern;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.json.JSONConfig;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.evotech.hd.cloud.dao.OrderDao;
|
||||
import com.evotech.hd.cloud.dao.OrderDetailDao;
|
||||
import com.evotech.hd.cloud.entity.order.Order;
|
||||
import com.evotech.hd.cloud.entity.order.OrderDetail;
|
||||
import com.evotech.hd.cloud.mqtt.enums.MqttMessageTypeEnum;
|
||||
import com.evotech.hd.cloud.mqtt.enums.RequestFunctionTypesEnum;
|
||||
import com.evotech.hd.cloud.mqtt.message.MessageTopic;
|
||||
import com.evotech.hd.cloud.mqtt.message.MqttMessageHeader;
|
||||
import com.evotech.hd.cloud.mqtt.message.dto.newer.req.battery.BatterySwapReq;
|
||||
import com.evotech.hd.cloud.service.OrderService;
|
||||
import com.evotech.hd.cloud.utils.CommonUtil;
|
||||
import com.evotech.hd.cloud.utils.components.SwapOrderBasicFeeComponent;
|
||||
import com.evotech.hd.common.core.Dto.Result;
|
||||
import com.evotech.hd.common.core.Dto.order.OrderListVo;
|
||||
import com.evotech.hd.common.core.constant.HDConstant;
|
||||
import com.evotech.hd.common.core.entity.cloud.OrderSwapBatteryPre;
|
||||
import com.evotech.hd.common.core.entity.cloud.request.PageListSwapOrderRequest;
|
||||
import com.evotech.hd.common.core.enums.OrderStatusEnums;
|
||||
import com.evotech.hd.common.web.util.EnumUtils;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
@ -35,12 +48,14 @@ import java.util.function.Function;
|
||||
*/
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
public class OrderServiceImpl extends BaseServiceImpl<OrderDao, Order, OrderListVo> implements OrderService {
|
||||
@Resource
|
||||
private OrderDetailDao orderDetailDao;
|
||||
@Resource
|
||||
private SwapOrderBasicFeeComponent orderBasicFeeComponent;
|
||||
|
||||
|
||||
@Override
|
||||
public Result<Page<OrderListVo>> pageList(PageListSwapOrderRequest plsor) {
|
||||
|
||||
@ -120,6 +135,71 @@ public class OrderServiceImpl extends BaseServiceImpl<OrderDao, Order, OrderList
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result<Order> addOrderByPre(OrderSwapBatteryPre orderSwapBatteryPre) {
|
||||
// 生成订单
|
||||
Order order = new Order();
|
||||
order.setOrderNo(CommonUtil.swapBatteryOrderNo(orderSwapBatteryPre.getStationCode()));
|
||||
order.setOrderPreId(orderSwapBatteryPre.getPkId());
|
||||
// order.setP(osbp.getPhone());
|
||||
order.setPreWechatId(orderSwapBatteryPre.getUcode());
|
||||
order.setPreName(orderSwapBatteryPre.getUname());
|
||||
order.setPlateNum(orderSwapBatteryPre.getPlateNum());
|
||||
order.setOrderTime(new Date());
|
||||
order.setOrderType(HDConstant.OrderConstant.ORDER_TYPE_SWAP);
|
||||
order.setStatus(OrderStatusEnums.CREATE.getCode());
|
||||
order.setStationCode(orderSwapBatteryPre.getStationCode());
|
||||
order.setStationName(orderSwapBatteryPre.getStationName());
|
||||
// TODO 查询换电站信息,拿到计费方式,计费信息在充电结束时, 计算
|
||||
// osb = orderBasicFeeComponent.orderBasicFee(osb);
|
||||
return (save(order) ? new Result<Order>().success(order) : new Result<Order>().error("订单生成异常",null));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result<Boolean> startSwap(String wuid, String orderId) {
|
||||
if (StringUtils.isBlank(wuid) || StringUtils.isBlank(orderId)) {
|
||||
log.warn("换电请求参数无效, wuid: {}, orderId: {}", wuid, orderId);
|
||||
return new Result<Boolean>().error("换电请求参数无效");
|
||||
}
|
||||
|
||||
// 获取用户订单
|
||||
Order order= getBaseMapper().selectById(orderId);
|
||||
if (ObjectUtils.isEmpty(order)) {
|
||||
log.warn("未找到符合条件的订单, 用户ID: {}, 订单id: {}", wuid, orderId);
|
||||
return new Result<Boolean>().error("未找到符合条件的订单");
|
||||
}
|
||||
|
||||
try {
|
||||
log.info("开始处理换电请求, 订单编号: {}, 用户ID: {}", order.getOrderNo(), wuid);
|
||||
// 构建换电请求消息
|
||||
BatterySwapReq batterySwapReq = new BatterySwapReq();
|
||||
batterySwapReq.setOrderNo(order.getOrderNo());
|
||||
batterySwapReq.setMsg("换电开始");
|
||||
|
||||
// 设置消息主题和头部信息
|
||||
MessageTopic topic = new MessageTopic();
|
||||
topic.setDataDirection("M2S");
|
||||
topic.setMessageType(MqttMessageTypeEnum.REQUEST.getType());
|
||||
|
||||
MqttMessageHeader header = new MqttMessageHeader();
|
||||
header.setFunction(RequestFunctionTypesEnum.FUN_STARTSWAP.getFunction());
|
||||
header.setTimeStamp(DateUtil.format(new Date(), DatePattern.NORM_DATETIME_FORMATTER));
|
||||
|
||||
// 发送消息给站端
|
||||
messageUtilService.publishAESMessage(topic, header, JSONUtil.parseObj(batterySwapReq, new JSONConfig().setDateFormat(DatePattern.NORM_DATETIME_PATTERN)));
|
||||
|
||||
log.info("换电开始消息发送成功, 订单编号: {}", order.getOrderNo());
|
||||
return new Result<Boolean>().success(true);
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("处理换电请求时发生异常, 订单编号: {}, 用户ID: {}", order.getOrderNo(), wuid, e);
|
||||
return new Result<Boolean>().error("系统处理换电请求时发生异常");
|
||||
}
|
||||
|
||||
return Result<Boolean>().success(true);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -5,10 +5,19 @@ import cn.hutool.core.date.DateUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.evotech.hd.cloud.dao.BatteryStationDao;
|
||||
import com.evotech.hd.cloud.dao.OrderDao;
|
||||
import com.evotech.hd.cloud.dao.OrderSwapBatteryPreDao;
|
||||
import com.evotech.hd.cloud.dao.VehicleInfoDao;
|
||||
import com.evotech.hd.cloud.entity.order.Order;
|
||||
import com.evotech.hd.cloud.service.OrderSwapBatteryPreService;
|
||||
import com.evotech.hd.cloud.utils.CloudTemplateMessageUtils;
|
||||
import com.evotech.hd.common.core.Dto.Result;
|
||||
import com.evotech.hd.common.core.dao.wechat.WechatUserDao;
|
||||
import com.evotech.hd.common.core.entity.cloud.BatteryStation;
|
||||
import com.evotech.hd.common.core.entity.cloud.OrderSwapBatteryPre;
|
||||
import com.evotech.hd.common.core.entity.cloud.VehicleInfo;
|
||||
import com.evotech.hd.common.core.entity.wechat.WechatUser;
|
||||
import com.evotech.hd.common.redis.utils.RedisServiceUtils;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
@ -28,11 +37,18 @@ import java.util.Date;
|
||||
@Service
|
||||
public class OrderSwapBatteryPreServiceImpl extends ServiceImpl<OrderSwapBatteryPreDao, OrderSwapBatteryPre> implements OrderSwapBatteryPreService {
|
||||
|
||||
@Resource
|
||||
BatteryStationDao batteryStationDao;
|
||||
@Resource
|
||||
BatteryStationDao batteryStationDao;
|
||||
@Resource
|
||||
private VehicleInfoDao vehicleInfoDao;
|
||||
@Resource
|
||||
private WechatUserDao wechatUserDao;
|
||||
@Resource
|
||||
private OrderDao orderDao;
|
||||
|
||||
@Override
|
||||
public Boolean addPreByPlateNum(String plateNum, String stationCode) {
|
||||
|
||||
@Override
|
||||
public Boolean addPreByPlateNum(String plateNum, String stationCode) {
|
||||
BatteryStation batteryStation = batteryStationDao.selectOne(new LambdaQueryWrapper<BatteryStation>().eq(BatteryStation::getCode, stationCode).select(BatteryStation::getCode, BatteryStation::getName), false);
|
||||
// 3. 添加预约
|
||||
Date day = new Date();
|
||||
@ -54,19 +70,64 @@ public class OrderSwapBatteryPreServiceImpl extends ServiceImpl<OrderSwapBattery
|
||||
osbp.setCtime(day);
|
||||
getBaseMapper().insert(osbp);
|
||||
//特殊渠道反推的数据, 不需要发送通知
|
||||
// if (n == 1) {
|
||||
// // 计算过期时间(预约时间后30分钟)
|
||||
// Date expireTime = DateUtil.offsetMinute(osbp.getReservationTime(), 90);
|
||||
// // 将预约单ID和过期时间存入Redis,设置过期时间为预约时间后30分钟
|
||||
// String redisKey = "preorder:expire:" + osbp.getPkId();
|
||||
// redisUtil.set(redisKey, expireTime);
|
||||
// // 发送服务号消息,没有消息队列,先用接口吧
|
||||
// templateMessageService.preOrderMessageSend(osbp);
|
||||
// return true;
|
||||
// }
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result<Boolean> addOrderSwapBatteryPre(OrderSwapBatteryPre orderSwapBatteryPre) {
|
||||
// 1. 检查车辆
|
||||
VehicleInfo vehicleInfo = vehicleInfoDao.selectOne(new LambdaQueryWrapper<VehicleInfo>()
|
||||
.eq(VehicleInfo::getPlateNum, orderSwapBatteryPre.getPlateNum())
|
||||
.select(VehicleInfo::getOwnerType));
|
||||
if (vehicleInfo == null) {
|
||||
return new Result<Boolean>().error("未找到车辆信息", false);
|
||||
}
|
||||
|
||||
// 2. 检查预约人
|
||||
if (!wechatUserDao.exists(new LambdaQueryWrapper<WechatUser>().ne(WechatUser::getPhoneNumber, " ").isNotNull(WechatUser::getPhoneNumber).eq(WechatUser::getWuid, orderSwapBatteryPre.getUcode()))) {
|
||||
return new Result<Boolean>().error("用户认证信息不全!", false);
|
||||
}
|
||||
//判断换电站是否运营 status 不等于 1 则证明换电站未运营
|
||||
if (batteryStationDao.exists(new LambdaQueryWrapper<BatteryStation>().eq(BatteryStation::getCode, orderSwapBatteryPre.getStationCode()).ne(BatteryStation::getStatus, 1))) {
|
||||
return new Result<Boolean>().error("该换电站未运营!", false);
|
||||
}
|
||||
//判断这个车是不是企业用车 类型为空, 或者 类型为1 是个人用车
|
||||
if (vehicleInfo.getOwnerType() == null || vehicleInfo.getOwnerType() == 1) {
|
||||
try {
|
||||
Long unpaidOrderCount = orderDao.selectCount(new LambdaQueryWrapper<Order>()
|
||||
.eq(Order::getPreWechatId, orderSwapBatteryPre.getUcode())
|
||||
.eq(Order::getStatus, 6)
|
||||
.eq(Order::getPreName, orderSwapBatteryPre.getUname())
|
||||
);
|
||||
log.info("检查用户未支付订单,用户编码:{},未支付订单数:{}", orderSwapBatteryPre.getUcode(), unpaidOrderCount);
|
||||
if (unpaidOrderCount >= 3) {
|
||||
return new Result<Boolean>().error("您有3笔及以上未支付的订单,请先支付!", false);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("检查未支付订单异常,用户编码:{},错误信息:{}", orderSwapBatteryPre.getUcode(), e.getMessage());
|
||||
return new Result<Boolean>().error("系统异常,请稍后重试", false);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
// 是否需要验证人和车绑定关系
|
||||
|
||||
// 是否需要验证公司和车的绑定关系
|
||||
|
||||
// 3. 添加预约
|
||||
Date d = new Date();
|
||||
orderSwapBatteryPre.setStatus(1);
|
||||
orderSwapBatteryPre.setReservationTime(orderSwapBatteryPre.getReservationTime() == null ? d : orderSwapBatteryPre.getReservationTime());
|
||||
orderSwapBatteryPre.setCtime(d);
|
||||
if (getBaseMapper().insert(orderSwapBatteryPre) == 1) {
|
||||
// 计算过期时间(预约时间后30分钟)
|
||||
Date expireTime = DateUtil.offsetMinute(orderSwapBatteryPre.getReservationTime(), 90);
|
||||
// 将预约单ID和过期时间存入Redis,设置过期时间为预约时间后30分钟
|
||||
String redisKey = "preorder:expire:" + orderSwapBatteryPre.getPkId();
|
||||
RedisServiceUtils.set(redisKey, expireTime);
|
||||
// 发送服务号消息,没有消息队列,先用接口吧
|
||||
CloudTemplateMessageUtils.sendPreOrderMessage(orderSwapBatteryPre);
|
||||
return new Result<Boolean>().success(true);
|
||||
}
|
||||
return new Result<Boolean>().error("添加预约换电订单出错!", false);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,200 +1,174 @@
|
||||
//package com.evotech.hd.cloud.service.impl;
|
||||
//
|
||||
//import cn.hutool.core.date.DatePattern;
|
||||
//import cn.hutool.core.date.DateUtil;
|
||||
//import cn.hutool.core.util.ObjectUtil;
|
||||
//import cn.hutool.core.util.StrUtil;
|
||||
//import cn.hutool.json.JSONConfig;
|
||||
//import cn.hutool.json.JSONUtil;
|
||||
//import com.alibaba.fastjson.JSON;
|
||||
//import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
//import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
//import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||
//import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
//import com.evotech.hd.cloud.dao.*;
|
||||
//import com.evotech.hd.cloud.entity.vo.NativePayVO;
|
||||
//import com.evotech.hd.cloud.mqtt.enums.MqttMessageTypeEnum;
|
||||
//import com.evotech.hd.cloud.mqtt.enums.RequestFunctionTypesEnum;
|
||||
//import com.evotech.hd.cloud.mqtt.message.MessageTopic;
|
||||
//import com.evotech.hd.cloud.mqtt.message.MqttMessageHeader;
|
||||
//import com.evotech.hd.cloud.mqtt.message.dto.newer.req.battery.BatterySwapReq;
|
||||
//import com.evotech.hd.cloud.mqtt.message.dto.newer.state.OrderStatusData;
|
||||
//import com.evotech.hd.cloud.mqtt.message.handle.MessageUtilService;
|
||||
//import com.evotech.hd.cloud.service.OrderSwapBatteryService;
|
||||
//import com.evotech.hd.cloud.service.TaxPointService;
|
||||
//import com.evotech.hd.cloud.service.TradeService;
|
||||
//import com.evotech.hd.cloud.service.WalletAccountService;
|
||||
//import com.evotech.hd.cloud.service.newthread.GZHTemplateMessageService;
|
||||
//import com.evotech.hd.cloud.service.rpc.WechatService;
|
||||
//import com.evotech.hd.cloud.utils.components.SwapOrderBasicFeeComponent;
|
||||
//import com.evotech.hd.common.core.dao.cloud.OrderSwapBatteryDao;
|
||||
//import com.evotech.hd.common.core.dao.wechat.WechatUserDao;
|
||||
//import com.evotech.hd.common.core.entity.Result;
|
||||
//import com.evotech.hd.common.core.entity.cloud.*;
|
||||
//import com.evotech.hd.common.core.entity.cloud.request.BatterySwapResponse;
|
||||
//import com.evotech.hd.common.core.entity.cloud.request.PageListSwapOrderPreRequest;
|
||||
//import com.evotech.hd.common.core.entity.cloud.request.PageListSwapOrderRequest;
|
||||
//import com.evotech.hd.common.core.entity.wechat.WechatUser;
|
||||
//import com.evotech.hd.common.core.enums.CodeMsg;
|
||||
//import com.evotech.hd.common.core.enums.OrderStatusEnums;
|
||||
//import com.evotech.hd.common.core.enums.PayTypeEnums;
|
||||
//import com.evotech.hd.common.core.enums.TradeTypeEnums;
|
||||
//import com.evotech.hd.common.core.utils.CommonUtil;
|
||||
//import com.evotech.hd.common.redis.utils.RedisUtil;
|
||||
//import jakarta.annotation.Resource;
|
||||
//import lombok.extern.slf4j.Slf4j;
|
||||
//import org.springframework.stereotype.Service;
|
||||
//import org.springframework.transaction.annotation.Transactional;
|
||||
//import org.springframework.util.StringUtils;
|
||||
//
|
||||
//import java.math.BigDecimal;
|
||||
//import java.math.RoundingMode;
|
||||
//import java.text.ParseException;
|
||||
//import java.util.ArrayList;
|
||||
//import java.util.Arrays;
|
||||
//import java.util.Date;
|
||||
//import java.util.List;
|
||||
//
|
||||
//@Slf4j
|
||||
//@Service
|
||||
//public class OrderSwapBatteryServiceImpl implements OrderSwapBatteryService {
|
||||
//
|
||||
// @Resource
|
||||
// private OrderSwapBatteryDao orderSwapBatteryDao;
|
||||
// @Resource
|
||||
// private OrderSwapBatteryPreDao orderSwapBatteryPreDao;
|
||||
// @Resource
|
||||
// private OrderSwapBatteryStepDao orderSwapBatteryStepDao;
|
||||
// @Resource
|
||||
// private VehicleInfoDao vehicleInfoDao;
|
||||
// @Resource
|
||||
// private WechatUserDao wechatUserDao;
|
||||
// @Resource
|
||||
// private SwapOrderBasicFeeComponent orderBasicFeeComponent;
|
||||
// @Resource
|
||||
// private GZHTemplateMessageService templateMessageService;
|
||||
// @Resource
|
||||
// private WalletAccountDao walletAccountDao;
|
||||
// @Resource
|
||||
// private WalletAccountService walletAccountService;
|
||||
// @Resource
|
||||
// private TradeService tradeService;
|
||||
// @Resource
|
||||
// private WechatService wechatService;
|
||||
// @Resource
|
||||
// private MessageUtilService messageUtilService;
|
||||
// @Resource
|
||||
// private RedisUtil redisUtil;
|
||||
// @Resource
|
||||
// private BatteryStationDao batteryStationDao;
|
||||
// @Resource
|
||||
// private GZHTemplateMessageService gzhTemplateMessageService;
|
||||
// @Resource
|
||||
// TaxPointService taxPointService;
|
||||
//
|
||||
// @Override
|
||||
// public Result<Integer> addPre(OrderSwapBatteryPre osbp) {
|
||||
// // 1. 检查车辆
|
||||
// LambdaQueryWrapper<VehicleInfo> vehicleQuery = new LambdaQueryWrapper<VehicleInfo>()
|
||||
// .eq(VehicleInfo::getPlateNum, osbp.getPlateNum())
|
||||
// .select(VehicleInfo::getOwnerType);
|
||||
//
|
||||
// VehicleInfo vehicleInfo = vehicleInfoDao.selectOne(vehicleQuery);
|
||||
// if (vehicleInfo == null) {
|
||||
// return new Result<Integer>().error("未找到车辆信息");
|
||||
// }
|
||||
//
|
||||
// // 2. 检查预约人
|
||||
// boolean b2 = wechatUserDao.exists(new QueryWrapper<WechatUser>()
|
||||
// .ne("phone_number", " ")
|
||||
// .isNotNull("phone_number")
|
||||
// .eq("wuid", osbp.getUcode())
|
||||
// );
|
||||
// if (!b2) {
|
||||
// return new Result<Integer>().error("用户认证信息不全!");
|
||||
// }
|
||||
// //判断换电站是否运营
|
||||
// boolean b3 = batteryStationDao.exists(new QueryWrapper<BatteryStation>()
|
||||
// .eq("code", osbp.getStationCode())
|
||||
// .eq("status", 1));
|
||||
// if (!b3){
|
||||
// return new Result<Integer>().error("该换电站未运营!");
|
||||
// }
|
||||
// //判断这个车是不是企业用车
|
||||
// if (vehicleInfo.getOwnerType() != null && vehicleInfo.getOwnerType()==1 ){
|
||||
// try {
|
||||
// Long unpaidOrderCount = orderSwapBatteryDao.selectCount(new LambdaQueryWrapper<OrderSwapBattery>()
|
||||
// .eq(OrderSwapBattery::getOrderPreUid, osbp.getUcode())
|
||||
// .eq(OrderSwapBattery::getStatus, 6)
|
||||
// .eq(OrderSwapBattery::getOrderPreUname, osbp.getUname())
|
||||
// );
|
||||
//
|
||||
// log.info("检查用户未支付订单,用户编码:{},未支付订单数:{}", osbp.getUcode(), unpaidOrderCount);
|
||||
// if (unpaidOrderCount >= 3) {
|
||||
// return new Result<Integer>().error("您有3笔及以上未支付的订单,请先支付!");
|
||||
// }
|
||||
// } catch (Exception e) {
|
||||
// log.error("检查未支付订单异常,用户编码:{},错误信息:{}",
|
||||
// osbp.getUcode(), e.getMessage());
|
||||
// return new Result<Integer>().error("系统异常,请稍后重试");
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// // 是否需要验证人和车绑定关系
|
||||
//
|
||||
// // 是否需要验证公司和车的绑定关系
|
||||
//
|
||||
// // 3. 添加预约
|
||||
// Date d = new Date();
|
||||
// osbp.setStatus(1);
|
||||
// osbp.setReservationTime(osbp.getReservationTime() == null ? d : osbp.getReservationTime());
|
||||
// osbp.setCtime(d);
|
||||
// int n = orderSwapBatteryPreDao.insert(osbp);
|
||||
// if (n == 1) {
|
||||
// // 计算过期时间(预约时间后30分钟)
|
||||
// Date expireTime = DateUtil.offsetMinute(osbp.getReservationTime(), 90);
|
||||
// // 将预约单ID和过期时间存入Redis,设置过期时间为预约时间后30分钟
|
||||
// String redisKey = "preorder:expire:" + osbp.getPkId();
|
||||
// redisUtil.set(redisKey, expireTime);
|
||||
// // 发送服务号消息,没有消息队列,先用接口吧
|
||||
// templateMessageService.preOrderMessageSend(osbp);
|
||||
// return new Result<Integer>().success(n);
|
||||
// }
|
||||
// return new Result<Integer>().error("添加预约换电订单出错!");
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public Result<Integer> cancelPre(Integer id, Integer status) {
|
||||
// OrderSwapBatteryPre osbp = new OrderSwapBatteryPre();
|
||||
// osbp.setPkId(id);
|
||||
// osbp.setStatus(status != null? status : 3);
|
||||
// osbp.setUptime(null);
|
||||
// int n = orderSwapBatteryPreDao.updateById(osbp);
|
||||
// if (n == 1) {
|
||||
// return new Result<Integer>().success(n);
|
||||
// }
|
||||
// return new Result<Integer>().error("取消预约换电订单失败!");
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public Result<List<OrderSwapBatteryPre>> listPre(PageListSwapOrderPreRequest plsopr) throws ParseException {
|
||||
// Page<OrderSwapBatteryPre> page = new Page<OrderSwapBatteryPre>(plsopr.getPageNo(), plsopr.getPageSize());
|
||||
// page = orderSwapBatteryPreDao.selectPage(page, new LambdaQueryWrapper<OrderSwapBatteryPre>()
|
||||
// .eq(StringUtils.hasText(plsopr.getUcode()), OrderSwapBatteryPre::getUcode, plsopr.getUcode())
|
||||
// .eq(plsopr.getStatus() != null, OrderSwapBatteryPre::getStatus, plsopr.getStatus())
|
||||
// .eq(StringUtils.hasText(plsopr.getPlateNum()), OrderSwapBatteryPre::getPlateNum, plsopr.getPlateNum())
|
||||
// .eq(StringUtils.hasText(plsopr.getStationCode()), OrderSwapBatteryPre::getStationCode, plsopr.getStationCode())
|
||||
//// .apply(StringUtils.hasText(plsopr.getSwapDayBegin()), "DATE_FORMAT(swap_day,'%Y-%m-%d') >={0}", DateFormatUtils.format(DateUtils.parseDate(plsopr.getSwapDayBegin(),"yyyyMMdd","yyyy-MM-dd"), "yyyy-MM-dd"))
|
||||
//// .apply(StringUtils.hasText(plsopr.getSwapDayEnd()), "DATE_FORMAT(swap_day,'%Y-%m-%d') <={0}", DateFormatUtils.format(DateUtils.parseDate(plsopr.getSwapDayEnd(),"yyyyMMdd","yyyy-MM-dd"), "yyyy-MM-dd"))
|
||||
// .ge(StringUtils.hasText(plsopr.getSwapDayBegin()), OrderSwapBatteryPre::getSwapDay, plsopr.getSwapDayBegin())
|
||||
// .le(StringUtils.hasText(plsopr.getSwapDayEnd()), OrderSwapBatteryPre::getSwapDay, plsopr.getSwapDayEnd())
|
||||
// .orderByDesc(OrderSwapBatteryPre::getPkId));
|
||||
// if (page.getRecords().isEmpty()) {
|
||||
// return new Result<List<OrderSwapBatteryPre>>().error(CodeMsg.DATABASE_RESULT_NULL);
|
||||
// }
|
||||
// return new Result<List<OrderSwapBatteryPre>>().success(page);
|
||||
// }
|
||||
//
|
||||
package com.evotech.hd.cloud.service.impl;
|
||||
|
||||
import cn.hutool.core.date.DatePattern;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.evotech.hd.cloud.dao.*;
|
||||
import com.evotech.hd.cloud.entity.order.Order;
|
||||
import com.evotech.hd.cloud.entity.vo.NativePayVO;
|
||||
import com.evotech.hd.cloud.mqtt.message.dto.newer.state.OrderStatusData;
|
||||
import com.evotech.hd.cloud.mqtt.message.handle.MessageUtilService;
|
||||
import com.evotech.hd.cloud.service.OrderSwapBatteryService;
|
||||
import com.evotech.hd.cloud.service.TaxPointService;
|
||||
import com.evotech.hd.cloud.service.TradeService;
|
||||
import com.evotech.hd.cloud.service.WalletAccountService;
|
||||
import com.evotech.hd.cloud.service.newthread.GZHTemplateMessageService;
|
||||
import com.evotech.hd.cloud.service.rpc.WechatService;
|
||||
import com.evotech.hd.cloud.utils.components.SwapOrderBasicFeeComponent;
|
||||
import com.evotech.hd.common.core.dao.wechat.WechatUserDao;
|
||||
import com.evotech.hd.common.core.entity.Result;
|
||||
import com.evotech.hd.common.core.entity.cloud.BatteryStation;
|
||||
import com.evotech.hd.common.core.entity.cloud.OrderSwapBatteryPre;
|
||||
import com.evotech.hd.common.core.entity.cloud.OrderSwapBatteryStep;
|
||||
import com.evotech.hd.common.core.entity.cloud.VehicleInfo;
|
||||
import com.evotech.hd.common.core.entity.cloud.request.BatterySwapResponse;
|
||||
import com.evotech.hd.common.core.entity.cloud.request.PageListSwapOrderPreRequest;
|
||||
import com.evotech.hd.common.core.entity.cloud.request.PageListSwapOrderRequest;
|
||||
import com.evotech.hd.common.core.entity.wechat.WechatUser;
|
||||
import com.evotech.hd.common.core.enums.CodeMsg;
|
||||
import com.evotech.hd.common.redis.utils.RedisServiceUtils;
|
||||
import com.evotech.hd.common.redis.utils.RedisUtil;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
public class OrderSwapBatteryServiceImpl implements OrderSwapBatteryService {
|
||||
|
||||
@Resource
|
||||
private OrderDao orderDao;
|
||||
@Resource
|
||||
private OrderSwapBatteryPreDao orderSwapBatteryPreDao;
|
||||
@Resource
|
||||
private OrderSwapBatteryStepDao orderSwapBatteryStepDao;
|
||||
@Resource
|
||||
private VehicleInfoDao vehicleInfoDao;
|
||||
@Resource
|
||||
private WechatUserDao wechatUserDao;
|
||||
@Resource
|
||||
private SwapOrderBasicFeeComponent orderBasicFeeComponent;
|
||||
@Resource
|
||||
private GZHTemplateMessageService templateMessageService;
|
||||
@Resource
|
||||
private WalletAccountDao walletAccountDao;
|
||||
@Resource
|
||||
private WalletAccountService walletAccountService;
|
||||
@Resource
|
||||
private TradeService tradeService;
|
||||
@Resource
|
||||
private WechatService wechatService;
|
||||
@Resource
|
||||
private MessageUtilService messageUtilService;
|
||||
@Resource
|
||||
private RedisUtil redisUtil;
|
||||
@Resource
|
||||
private BatteryStationDao batteryStationDao;
|
||||
@Resource
|
||||
private GZHTemplateMessageService gzhTemplateMessageService;
|
||||
@Resource
|
||||
TaxPointService taxPointService;
|
||||
|
||||
@Override
|
||||
public Result<Integer> addPre(OrderSwapBatteryPre osbp) {
|
||||
// 1. 检查车辆
|
||||
VehicleInfo vehicleInfo = vehicleInfoDao.selectOne(new LambdaQueryWrapper<VehicleInfo>()
|
||||
.eq(VehicleInfo::getPlateNum, osbp.getPlateNum())
|
||||
.select(VehicleInfo::getOwnerType));
|
||||
if (vehicleInfo == null) {
|
||||
return new Result<Integer>().error("未找到车辆信息");
|
||||
}
|
||||
|
||||
// 2. 检查预约人
|
||||
if (!wechatUserDao.exists(new LambdaQueryWrapper<WechatUser>().ne(WechatUser::getPhoneNumber, " ").isNotNull(WechatUser::getPhoneNumber).eq(WechatUser::getWuid, osbp.getUcode()))) {
|
||||
return new Result<Integer>().error("用户认证信息不全!");
|
||||
}
|
||||
//判断换电站是否运营 status 不等于 1 则证明换电站未运营
|
||||
if (batteryStationDao.exists(new LambdaQueryWrapper<BatteryStation>().eq(BatteryStation::getCode, osbp.getStationCode()).ne(BatteryStation::getStatus, 1))){
|
||||
return new Result<Integer>().error("该换电站未运营!");
|
||||
}
|
||||
//判断这个车是不是企业用车 类型为空, 或者 类型为1 是个人用车
|
||||
if (vehicleInfo.getOwnerType() == null || vehicleInfo.getOwnerType()==1 ){
|
||||
try {
|
||||
Long unpaidOrderCount = orderDao.selectCount(new LambdaQueryWrapper<Order>()
|
||||
.eq(Order::getPreWechatId, osbp.getUcode())
|
||||
.eq(Order::getStatus, 6)
|
||||
.eq(Order::getPreName, osbp.getUname())
|
||||
);
|
||||
log.info("检查用户未支付订单,用户编码:{},未支付订单数:{}", osbp.getUcode(), unpaidOrderCount);
|
||||
if (unpaidOrderCount >= 3) {
|
||||
return new Result<Integer>().error("您有3笔及以上未支付的订单,请先支付!");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("检查未支付订单异常,用户编码:{},错误信息:{}", osbp.getUcode(), e.getMessage());
|
||||
return new Result<Integer>().error("系统异常,请稍后重试");
|
||||
}
|
||||
}
|
||||
|
||||
// 是否需要验证人和车绑定关系
|
||||
|
||||
// 是否需要验证公司和车的绑定关系
|
||||
|
||||
// 3. 添加预约
|
||||
Date d = new Date();
|
||||
osbp.setStatus(1);
|
||||
osbp.setReservationTime(osbp.getReservationTime() == null ? d : osbp.getReservationTime());
|
||||
osbp.setCtime(d);
|
||||
if (orderSwapBatteryPreDao.insert(osbp) == 1) {
|
||||
// 计算过期时间(预约时间后30分钟)
|
||||
Date expireTime = DateUtil.offsetMinute(osbp.getReservationTime(), 90);
|
||||
// 将预约单ID和过期时间存入Redis,设置过期时间为预约时间后30分钟
|
||||
String redisKey = "preorder:expire:" + osbp.getPkId();
|
||||
RedisServiceUtils.set(redisKey, expireTime);
|
||||
// 发送服务号消息,没有消息队列,先用接口吧
|
||||
templateMessageService.preOrderMessageSend(osbp);
|
||||
return new Result<Integer>().success();
|
||||
}
|
||||
return new Result<Integer>().error("添加预约换电订单出错!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result<Integer> cancelPre(Integer id, Integer status) {
|
||||
OrderSwapBatteryPre osbp = new OrderSwapBatteryPre();
|
||||
osbp.setPkId(id);
|
||||
osbp.setStatus(status != null? status : 3);
|
||||
osbp.setUptime(null);
|
||||
int n = orderSwapBatteryPreDao.updateById(osbp);
|
||||
if (n == 1) {
|
||||
return new Result<Integer>().success(n);
|
||||
}
|
||||
return new Result<Integer>().error("取消预约换电订单失败!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result<List<OrderSwapBatteryPre>> listPre(PageListSwapOrderPreRequest plsopr) throws ParseException {
|
||||
Page<OrderSwapBatteryPre> page = new Page<OrderSwapBatteryPre>(plsopr.getPageNo(), plsopr.getPageSize());
|
||||
page = orderSwapBatteryPreDao.selectPage(page, new LambdaQueryWrapper<OrderSwapBatteryPre>()
|
||||
.eq(StringUtils.hasText(plsopr.getUcode()), OrderSwapBatteryPre::getUcode, plsopr.getUcode())
|
||||
.eq(plsopr.getStatus() != null, OrderSwapBatteryPre::getStatus, plsopr.getStatus())
|
||||
.eq(StringUtils.hasText(plsopr.getPlateNum()), OrderSwapBatteryPre::getPlateNum, plsopr.getPlateNum())
|
||||
.eq(StringUtils.hasText(plsopr.getStationCode()), OrderSwapBatteryPre::getStationCode, plsopr.getStationCode())
|
||||
// .apply(StringUtils.hasText(plsopr.getSwapDayBegin()), "DATE_FORMAT(swap_day,'%Y-%m-%d') >={0}", DateFormatUtils.format(DateUtils.parseDate(plsopr.getSwapDayBegin(),"yyyyMMdd","yyyy-MM-dd"), "yyyy-MM-dd"))
|
||||
// .apply(StringUtils.hasText(plsopr.getSwapDayEnd()), "DATE_FORMAT(swap_day,'%Y-%m-%d') <={0}", DateFormatUtils.format(DateUtils.parseDate(plsopr.getSwapDayEnd(),"yyyyMMdd","yyyy-MM-dd"), "yyyy-MM-dd"))
|
||||
.ge(StringUtils.hasText(plsopr.getSwapDayBegin()), OrderSwapBatteryPre::getSwapDay, plsopr.getSwapDayBegin())
|
||||
.le(StringUtils.hasText(plsopr.getSwapDayEnd()), OrderSwapBatteryPre::getSwapDay, plsopr.getSwapDayEnd())
|
||||
.orderByDesc(OrderSwapBatteryPre::getPkId));
|
||||
if (page.getRecords().isEmpty()) {
|
||||
return new Result<List<OrderSwapBatteryPre>>().error(CodeMsg.DATABASE_RESULT_NULL);
|
||||
}
|
||||
return new Result<List<OrderSwapBatteryPre>>().success(page);
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public Result<Integer> add(OrderSwapBattery osb) {
|
||||
//
|
||||
@ -207,9 +181,9 @@
|
||||
// }
|
||||
// return new Result<Integer>().error("添加换电订单出错!");
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public Result<Integer> delete(Integer id) {
|
||||
|
||||
@Override
|
||||
public Result<Integer> delete(Integer id) {
|
||||
// OrderSwapBattery osb = new OrderSwapBattery();
|
||||
// osb.setPkId(id);
|
||||
// osb.setDelFlag(1);
|
||||
@ -217,9 +191,9 @@
|
||||
// if (n == 1) {
|
||||
// return new Result<Integer>().success(n);
|
||||
// }
|
||||
// throw new RuntimeException("删除换电订单出错!");
|
||||
// }
|
||||
//
|
||||
throw new RuntimeException("删除换电订单出错!");
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public Result<Integer> update(OrderSwapBattery osb) {
|
||||
// osb.setUptime(null);
|
||||
@ -229,7 +203,7 @@
|
||||
// }
|
||||
// return new Result<Integer>().error("更新换电订单失败!");
|
||||
// }
|
||||
//
|
||||
|
||||
// @Override
|
||||
// public Result<List<OrderSwapBattery>> list(PageListSwapOrderRequest plsor) {
|
||||
// Page<OrderSwapBattery> page = new Page<OrderSwapBattery>(plsor.getPageNo(), plsor.getPageSize());
|
||||
@ -275,7 +249,7 @@
|
||||
//
|
||||
// return new Result<List<OrderSwapBattery>>().success(page);
|
||||
// }
|
||||
//
|
||||
|
||||
// @Override
|
||||
// public Result<List<OrderSwapBattery>> listByCompany(PageListSwapOrderRequest plsor) {
|
||||
// if (!StringUtils.hasText(plsor.getCcode())) {
|
||||
@ -302,19 +276,19 @@
|
||||
// }
|
||||
// return new Result<List<OrderSwapBattery>>().success(page);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public Result<List<OrderSwapBatteryStep>> listStep(String orderNo) {
|
||||
// List<OrderSwapBatteryStep> list = orderSwapBatteryStepDao.selectList(new QueryWrapper<OrderSwapBatteryStep>()
|
||||
// .eq("order_no", orderNo));
|
||||
// if (list.isEmpty()) {
|
||||
// return new Result<List<OrderSwapBatteryStep>>().error(CodeMsg.DATABASE_RESULT_NULL);
|
||||
// }
|
||||
// return new Result<List<OrderSwapBatteryStep>>().success(list);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public Result<String> calculateCost1(String orderNo, OrderStatusData statusData) {
|
||||
|
||||
@Override
|
||||
public Result<List<OrderSwapBatteryStep>> listStep(String orderNo) {
|
||||
List<OrderSwapBatteryStep> list = orderSwapBatteryStepDao.selectList(new QueryWrapper<OrderSwapBatteryStep>()
|
||||
.eq("order_no", orderNo));
|
||||
if (list.isEmpty()) {
|
||||
return new Result<List<OrderSwapBatteryStep>>().error(CodeMsg.DATABASE_RESULT_NULL);
|
||||
}
|
||||
return new Result<List<OrderSwapBatteryStep>>().success(list);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result<String> calculateCost1(String orderNo, OrderStatusData statusData) {
|
||||
// OrderSwapBattery order = orderSwapBatteryDao.selectOne(new QueryWrapper<OrderSwapBattery>().eq("order_no", orderNo));
|
||||
// log.info("订单号:{}", JSONUtil.parseObj(order));
|
||||
// if (order == null) {
|
||||
@ -361,10 +335,11 @@
|
||||
// log.info("订单费用计算完成:{}", JSONUtil.parseObj(order));
|
||||
// gzhTemplateMessageService.orderMessageSend2(order.getPkId(),2);
|
||||
// return new Result<String>().success(fee);
|
||||
// }
|
||||
//
|
||||
//
|
||||
//
|
||||
return new Result<String>().success("1");
|
||||
}
|
||||
|
||||
|
||||
|
||||
// @Override
|
||||
// public Result<String> calculateCost(OrderSwapBattery order) {
|
||||
// // 2. 检查数据
|
||||
@ -405,11 +380,11 @@
|
||||
// orderSwapBatteryDao.updateById(order);
|
||||
// return new Result<String>().success(fee);
|
||||
// }
|
||||
//
|
||||
//
|
||||
// @Override
|
||||
// @Transactional
|
||||
// public Result<String> walletPay(String orderNo, String wuid, String uname) {
|
||||
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public Result<String> walletPay(String orderNo, String wuid, String uname) {
|
||||
// // 订单
|
||||
// OrderSwapBattery order = orderSwapBatteryDao
|
||||
// .selectOne(new QueryWrapper<OrderSwapBattery>().eq("order_no", orderNo));
|
||||
@ -487,22 +462,22 @@
|
||||
// } catch (Exception e) {
|
||||
// log.error("余额支付=====生成税点信息异常,订单信息{}; 异常信息{}", JSON.toJSONString(order), e.getMessage());
|
||||
// }
|
||||
//
|
||||
// return new Result<String>().success("OK");
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public Result<String> companyNativePay(NativePayVO prePay) {
|
||||
// return wechatService.wechatNativePay(prePay);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public Result<String> orderQuery(String outTradeNo) {
|
||||
// return wechatService.orderQuery(2, outTradeNo);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public Result<Integer> cancelOrder(String orderNo, Integer status) {
|
||||
|
||||
return new Result<String>().success("OK");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result<String> companyNativePay(NativePayVO prePay) {
|
||||
return wechatService.wechatNativePay(prePay);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result<String> orderQuery(String outTradeNo) {
|
||||
return wechatService.orderQuery(2, outTradeNo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result<Integer> cancelOrder(String orderNo, Integer status) {
|
||||
// //根据订单编码查询此订单
|
||||
// OrderSwapBattery order = orderSwapBatteryDao.selectOne(new QueryWrapper<OrderSwapBattery>().eq("order_no", orderNo));
|
||||
// // 1. 查看订单是否存在
|
||||
@ -524,24 +499,24 @@
|
||||
// }else{
|
||||
// return new Result<Integer>().error("取消换电订单失败");
|
||||
// }
|
||||
//
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public Result<Integer> markOrderAsExpired(Integer pkId) {
|
||||
// OrderSwapBatteryPre orderSwapBatteryPre = orderSwapBatteryPreDao.selectById(pkId);
|
||||
// orderSwapBatteryPre.setStatus(3);
|
||||
// int re = orderSwapBatteryPreDao.updateById(orderSwapBatteryPre);
|
||||
// if (re==1){
|
||||
// return new Result<Integer>().success(re);
|
||||
// }
|
||||
// else{
|
||||
// return new Result<Integer>().error("换电预约订单失败");
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public Result<Boolean> startSwap(String wuid, String orderId) {
|
||||
return new Result<Integer>().success(1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result<Integer> markOrderAsExpired(Integer pkId) {
|
||||
OrderSwapBatteryPre orderSwapBatteryPre = orderSwapBatteryPreDao.selectById(pkId);
|
||||
orderSwapBatteryPre.setStatus(3);
|
||||
int re = orderSwapBatteryPreDao.updateById(orderSwapBatteryPre);
|
||||
if (re==1){
|
||||
return new Result<Integer>().success(re);
|
||||
}
|
||||
else{
|
||||
return new Result<Integer>().error("换电预约订单失败");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result<Boolean> startSwap(String wuid, String orderId) {
|
||||
// if (StrUtil.isBlank(wuid) || StrUtil.isBlank(orderId)) {
|
||||
// log.warn("换电请求参数无效, wuid: {}, orderId: {}", wuid, orderId);
|
||||
// return new Result<Boolean>().error("换电请求参数无效");
|
||||
@ -582,17 +557,19 @@
|
||||
// log.error("处理换电请求时发生异常, 订单编号: {}, 用户ID: {}", orderSwap.getOrderNo(), wuid, e);
|
||||
// return new Result<Boolean>().error("系统处理换电请求时发生异常");
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public Result<BatterySwapResponse> getStartSwap(String wuid, String orderId) {
|
||||
// // 参数校验
|
||||
// if (StrUtil.isBlank(wuid) || StrUtil.isBlank(orderId)) {
|
||||
// log.warn("获取换电状态参数无效, wuid: {}, orderId: {}", wuid, orderId);
|
||||
// return new Result<BatterySwapResponse>().error("参数无效");
|
||||
// }
|
||||
//
|
||||
// // 获取用户订单
|
||||
|
||||
return new Result<Boolean>().success(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result<BatterySwapResponse> getStartSwap(String wuid, String orderId) {
|
||||
// 参数校验
|
||||
if (StrUtil.isBlank(wuid) || StrUtil.isBlank(orderId)) {
|
||||
log.warn("获取换电状态参数无效, wuid: {}, orderId: {}", wuid, orderId);
|
||||
return new Result<BatterySwapResponse>().error("参数无效");
|
||||
}
|
||||
return new Result<BatterySwapResponse>().error("参数无效");
|
||||
// 获取用户订单
|
||||
// OrderSwapBattery orderSwap = orderSwapBatteryDao.selectById(orderId);
|
||||
// if (orderSwap == null) {
|
||||
// log.warn("未找到符合条件的订单, 用户ID: {}, 订单id: {}", wuid, orderId);
|
||||
@ -626,12 +603,12 @@
|
||||
// log.error("获取换电状态时发生异常, 订单编号: {}", orderSwap.getOrderNo(), e);
|
||||
// return new Result<BatterySwapResponse>().error("系统获取换电状态时发生异常");
|
||||
// }
|
||||
// }
|
||||
//
|
||||
//
|
||||
// @Override
|
||||
// public Result<Integer> checkList(PageListSwapOrderRequest plsor) {
|
||||
//
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Result<Integer> checkList(PageListSwapOrderRequest plsor) {
|
||||
|
||||
// Page<OrderSwapBattery> page = new Page<OrderSwapBattery>(plsor.getPageNo(), plsor.getPageSize());
|
||||
// List<Integer> statusList = new ArrayList<Integer>();
|
||||
// String strs= "1,2,3,4,5,6";
|
||||
@ -654,78 +631,78 @@
|
||||
// if (!page.getRecords().isEmpty()) {
|
||||
// return new Result<Integer>().error("该车辆有未结算的订单,请确认后重试!");
|
||||
// }
|
||||
//
|
||||
//
|
||||
// /*Page<OrderSwapBatteryPre> page1 = new Page<OrderSwapBatteryPre>(plsor.getPageNo(), plsor.getPageSize());
|
||||
// page1 = orderSwapBatteryPreDao.selectPage(page1, new QueryWrapper<OrderSwapBatteryPre>()
|
||||
// .eq(StringUtils.hasText("1"), "status", "1")
|
||||
// .eq(StringUtils.hasText(plsor.getPlateNum()), "plate_num", plsor.getPlateNum())
|
||||
// .orderByDesc("pk_id"));
|
||||
// if (!page1.getRecords().isEmpty()) {
|
||||
// return new Result<Integer>().error("该车辆有预约成功的订单,请处理后重试!");
|
||||
// }*/
|
||||
//
|
||||
//
|
||||
// return new Result<Integer>().success(0);
|
||||
// }
|
||||
//
|
||||
//
|
||||
// @Override
|
||||
// public Boolean addPreByPlateNum(String PlateNum, String stationCode) {
|
||||
// BatteryStation batteryStation = batteryStationDao.selectOne(new LambdaQueryWrapper<BatteryStation>().eq(BatteryStation::getCode, stationCode).select(BatteryStation::getCode, BatteryStation::getName), false);
|
||||
// // 3. 添加预约
|
||||
// Date day = new Date();
|
||||
// OrderSwapBatteryPre osbp = new OrderSwapBatteryPre();
|
||||
// osbp.setSource(3);
|
||||
// osbp.setSourceId(batteryStation.getCode());
|
||||
// osbp.setUcode("hp_station_push");
|
||||
// osbp.setUname("慧鹏站端推送");
|
||||
// osbp.setPhone("12332112345");
|
||||
// osbp.setPlateNum(PlateNum);
|
||||
// osbp.setStationCode(batteryStation.getCode());
|
||||
// osbp.setStationName(batteryStation.getName());
|
||||
// osbp.setSwapDay(DateUtil.format(day, DatePattern.PURE_DATE_FORMATTER));
|
||||
// osbp.setSwapDuration("6:00-20:00");
|
||||
// osbp.setStatus(1);
|
||||
// osbp.setCtime(osbp.getReservationTime());
|
||||
// osbp.setCreater("TEST");
|
||||
// osbp.setReservationTime(osbp.getReservationTime() == null ? day : osbp.getReservationTime());
|
||||
// osbp.setCtime(day);
|
||||
// int n = orderSwapBatteryPreDao.insert(osbp);
|
||||
// //特殊渠道反推的数据, 不需要发送通知
|
||||
//// if (n == 1) {
|
||||
//// // 计算过期时间(预约时间后30分钟)
|
||||
//// Date expireTime = DateUtil.offsetMinute(osbp.getReservationTime(), 90);
|
||||
//// // 将预约单ID和过期时间存入Redis,设置过期时间为预约时间后30分钟
|
||||
//// String redisKey = "preorder:expire:" + osbp.getPkId();
|
||||
//// redisUtil.set(redisKey, expireTime);
|
||||
//// // 发送服务号消息,没有消息队列,先用接口吧
|
||||
//// templateMessageService.preOrderMessageSend(osbp);
|
||||
//// return true;
|
||||
//// }
|
||||
// return true;
|
||||
//
|
||||
//
|
||||
//
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public List<OrderSwapBatteryPre> findOrderSwapBatteryPreList(String stationCode) {
|
||||
// return orderSwapBatteryPreDao.selectList(new LambdaQueryWrapper<OrderSwapBatteryPre>()
|
||||
// .eq(OrderSwapBatteryPre::getStationCode, stationCode)
|
||||
//// .ne(OrderSwapBatteryPre::getUcode,"hp_station_push")
|
||||
// .eq(OrderSwapBatteryPre::getStatus, 1)
|
||||
// .select(OrderSwapBatteryPre::getUcode,OrderSwapBatteryPre::getPkId,OrderSwapBatteryPre::getPlateNum)
|
||||
// );
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public Boolean clearOrderSwapBatteryPre(List<Integer> ids) {
|
||||
//
|
||||
// return orderSwapBatteryPreDao.update(new UpdateWrapper<OrderSwapBatteryPre>()
|
||||
// .in("pk_id", ids)
|
||||
// .set("status", 3) //直接取消
|
||||
// ) > 0;
|
||||
// }
|
||||
//
|
||||
//}
|
||||
|
||||
|
||||
/*Page<OrderSwapBatteryPre> page1 = new Page<OrderSwapBatteryPre>(plsor.getPageNo(), plsor.getPageSize());
|
||||
page1 = orderSwapBatteryPreDao.selectPage(page1, new QueryWrapper<OrderSwapBatteryPre>()
|
||||
.eq(StringUtils.hasText("1"), "status", "1")
|
||||
.eq(StringUtils.hasText(plsor.getPlateNum()), "plate_num", plsor.getPlateNum())
|
||||
.orderByDesc("pk_id"));
|
||||
if (!page1.getRecords().isEmpty()) {
|
||||
return new Result<Integer>().error("该车辆有预约成功的订单,请处理后重试!");
|
||||
}*/
|
||||
|
||||
|
||||
return new Result<Integer>().success(0);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Boolean addPreByPlateNum(String PlateNum, String stationCode) {
|
||||
BatteryStation batteryStation = batteryStationDao.selectOne(new LambdaQueryWrapper<BatteryStation>().eq(BatteryStation::getCode, stationCode).select(BatteryStation::getCode, BatteryStation::getName), false);
|
||||
// 3. 添加预约
|
||||
Date day = new Date();
|
||||
OrderSwapBatteryPre osbp = new OrderSwapBatteryPre();
|
||||
osbp.setSource(3);
|
||||
osbp.setSourceId(batteryStation.getCode());
|
||||
osbp.setUcode("hp_station_push");
|
||||
osbp.setUname("慧鹏站端推送");
|
||||
osbp.setPhone("12332112345");
|
||||
osbp.setPlateNum(PlateNum);
|
||||
osbp.setStationCode(batteryStation.getCode());
|
||||
osbp.setStationName(batteryStation.getName());
|
||||
osbp.setSwapDay(DateUtil.format(day, DatePattern.PURE_DATE_FORMATTER));
|
||||
osbp.setSwapDuration("6:00-20:00");
|
||||
osbp.setStatus(1);
|
||||
osbp.setCtime(osbp.getReservationTime());
|
||||
osbp.setCreater("TEST");
|
||||
osbp.setReservationTime(osbp.getReservationTime() == null ? day : osbp.getReservationTime());
|
||||
osbp.setCtime(day);
|
||||
int n = orderSwapBatteryPreDao.insert(osbp);
|
||||
//特殊渠道反推的数据, 不需要发送通知
|
||||
// if (n == 1) {
|
||||
// // 计算过期时间(预约时间后30分钟)
|
||||
// Date expireTime = DateUtil.offsetMinute(osbp.getReservationTime(), 90);
|
||||
// // 将预约单ID和过期时间存入Redis,设置过期时间为预约时间后30分钟
|
||||
// String redisKey = "preorder:expire:" + osbp.getPkId();
|
||||
// redisUtil.set(redisKey, expireTime);
|
||||
// // 发送服务号消息,没有消息队列,先用接口吧
|
||||
// templateMessageService.preOrderMessageSend(osbp);
|
||||
// return true;
|
||||
// }
|
||||
return true;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<OrderSwapBatteryPre> findOrderSwapBatteryPreList(String stationCode) {
|
||||
return orderSwapBatteryPreDao.selectList(new LambdaQueryWrapper<OrderSwapBatteryPre>()
|
||||
.eq(OrderSwapBatteryPre::getStationCode, stationCode)
|
||||
// .ne(OrderSwapBatteryPre::getUcode,"hp_station_push")
|
||||
.eq(OrderSwapBatteryPre::getStatus, 1)
|
||||
.select(OrderSwapBatteryPre::getUcode,OrderSwapBatteryPre::getPkId,OrderSwapBatteryPre::getPlateNum)
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean clearOrderSwapBatteryPre(List<Integer> ids) {
|
||||
|
||||
return orderSwapBatteryPreDao.update(new UpdateWrapper<OrderSwapBatteryPre>()
|
||||
.in("pk_id", ids)
|
||||
.set("status", 3) //直接取消
|
||||
) > 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,36 @@
|
||||
package com.evotech.hd.cloud.utils;
|
||||
|
||||
import com.evotech.hd.cloud.service.newthread.GZHTemplateMessageService;
|
||||
import com.evotech.hd.common.core.entity.cloud.OrderSwapBatteryPre;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* 类
|
||||
*
|
||||
* @ClassName:CloudTemplateMessageUtils
|
||||
* @date: 2025年06月18日 11:11
|
||||
* @author: andy.shi
|
||||
* @contact: 17330188597
|
||||
* @remark: 开发人员联系方式 1042025947@qq.com/微信同步
|
||||
*/
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
public class CloudTemplateMessageUtils {
|
||||
|
||||
private static GZHTemplateMessageService templateMessageService;
|
||||
|
||||
@Autowired
|
||||
public CloudTemplateMessageUtils(GZHTemplateMessageService templateMessageService){
|
||||
this.templateMessageService = templateMessageService;
|
||||
}
|
||||
|
||||
|
||||
public static void sendPreOrderMessage(OrderSwapBatteryPre orderSwapBatteryPre){
|
||||
templateMessageService.preOrderMessageSend(orderSwapBatteryPre);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -30,12 +30,9 @@
|
||||
</sql>
|
||||
|
||||
<select id="getDcByStationCode" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
yt_t_battery_station_dc
|
||||
select dc.* from yt_t_battery_station_dc dc left join yt_t_battery_station_dcc dcc on dcc.dcc_no = dc.dcc_no
|
||||
WHERE
|
||||
point_code = #{stationCode}
|
||||
dcc.station_code = #{stationCode}
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user