Commit 09a1339c by zhouhaibao

[+]订单模块提交

1 parent c5a0b639
......@@ -33,6 +33,12 @@ public class ChargingOrder {
private Integer spearId;
/**
* 枪id
*/
@Column(name = "account_Id")
private Integer accountId;
/**
* 车位号
*/
@Column(name = "park_space_num")
......@@ -86,7 +92,7 @@ public class ChargingOrder {
/**
* 充电状态 1.待结算 2.已结算
*/
@Column(name = "order_status")
@Column(name = "settlement_flag")
private Byte settlementFlag;
public Byte getSettlementFlag() {
......@@ -360,4 +366,12 @@ public class ChargingOrder {
public void setCreatedTime(Date createdTime) {
this.createdTime = createdTime;
}
public Integer getAccountId() {
return accountId;
}
public void setAccountId(Integer accountId) {
this.accountId = accountId;
}
}
\ No newline at end of file
package cn.com.glsx.evbusiness.modules.mapper;
import cn.com.glsx.evbusiness.modules.entity.ChargingOrder;
import cn.com.glsx.evbusiness.modules.entity.User;
import cn.com.glsx.evbusiness.modules.model.ocpp16.order.OrderSearch;
import com.glsx.plat.mybatis.mapper.CommonBaseMapper;
import java.util.List;
......
......@@ -17,15 +17,15 @@ public class OrderCreateBO {
private Integer accountId;
private Integer orderSource;
private Byte orderSource;
private String parkSpaceNum;
private Integer executeType;
private Byte executeType;
private Date chargStarttime;
private Date chargeEndttime;
private Integer endType;
private Byte endType;
}
......@@ -9,7 +9,6 @@ import com.github.pagehelper.PageInfo;
import com.glsx.plat.core.annotation.ResponseResultBody;
import com.glsx.plat.core.web.R;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.parameters.RequestBody;
import io.swagger.v3.oas.annotations.tags.Tag;
import javax.validation.constraints.NotNull;
import lombok.extern.slf4j.Slf4j;
......@@ -18,6 +17,7 @@ import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.RequestBody;
@Slf4j
@Tag(name = "订单相关接口")
......@@ -50,7 +50,7 @@ public class OrderController {
@Operation(summary = "停止充电", description = "停止充电")
@PostMapping("/closePile")
public R<Boolean> closePile(@RequestBody ClosePileBO closePileBO) {
public R<Boolean> closePile(@RequestBody ClosePileBO closePileBO) {
return R.ok().data(orderService.closePile(closePileBO));
}
}
......@@ -13,7 +13,9 @@ import cn.com.glsx.evbusiness.modules.model.ocpp16.RealTimeUploadData;
import cn.com.glsx.evbusiness.modules.model.ocpp16.order.ClosePileBO;
import cn.com.glsx.evbusiness.modules.model.ocpp16.order.OrderCreateBO;
import cn.com.glsx.evbusiness.modules.model.ocpp16.order.OrderSearch;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.nacos.common.utils.UuidUtils;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.glsx.plat.core.web.Result;
import com.glsx.plat.exception.BusinessException;
......@@ -51,13 +53,17 @@ public class OrderService {
// 1.判断用户是否存在未支付的订单
// 2.创建订单号,交易流水号
String orderCode = UuidUtils.generateUuid();
String orderCode = "32010200000000111511161555350263";
// 3.启动充电桩
StartBo startBo = new StartBo();
startBo.setTransactionSerialNumber(orderCode);
startBo.setPileId(orderCreateBO.getPileId());
startBo.setGunNumber(orderCreateBO.getGunNumber());
Result<Boolean> start = pileControlFeignClient.start(startBo);
startBo.setAccountBalance(2000.00);
startBo.setPhysicalCardNumber("00000000D14B0A54");
startBo.setLogicalCardNumber("00000000D14B0A54");
insertOrder(orderCreateBO, orderCode);
Result<Boolean> start = pileControlFeignClient.start(JSONObject.toJSONString(startBo));
if (start.getData()) {
// 4.创建待支付的订单
insertOrder(orderCreateBO, orderCode);
......@@ -81,7 +87,7 @@ public class OrderService {
startBo.setTransactionSerialNumber(orderCode);
startBo.setPileId(orderCreateBO.getPileId());
startBo.setGunNumber(orderCreateBO.getGunNumber());
Result<Boolean> start = pileControlFeignClient.start(startBo);
Result<Boolean> start = pileControlFeignClient.pileStart(JSONObject.toJSONString(startBo));
if (start.getData()) {
// 4.创建待支付的订单
insertOrder(orderCreateBO, orderCode);
......@@ -111,7 +117,7 @@ public class OrderService {
EndBo endBo = new EndBo();
endBo.setPileId(closePileBO.getPileId());
endBo.setGunNumber(closePileBO.getGunNumber());
Result<Boolean> end = pileControlFeignClient.end(endBo);
Result<Boolean> end = pileControlFeignClient.end(JSONObject.toJSONString(endBo));
Boolean data = end.getData();
if (data) {
// 更新订单为待结算
......@@ -177,7 +183,8 @@ public class OrderService {
*/
@Async
public void addOrderMonitorInfo(RealTimeUploadData data) {
ChargingOrderMonitorinfo chargingOrderMonitorinfo = new ChargingOrderMonitorinfo(data.getTransactionSerialNumber());
ChargingOrderMonitorinfo chargingOrderMonitorinfo = new ChargingOrderMonitorinfo(
data.getTransactionSerialNumber());
chargingOrderMonitorinfo.setAccTime(Short.toUnsignedInt(data.getAccumulatedChargingTime()));
chargingOrderMonitorinfo.setChargedAmount(data.getChargingMoney());
chargingOrderMonitorinfo.setCurrent(data.getOutputCurrent());
......@@ -215,8 +222,8 @@ public class OrderService {
* @return
*/
public PageInfo<ChargingOrder> search(OrderSearch orderSearch) {
PageHelper.startPage(orderSearch.getPageNumber(), orderSearch.getPageSize());
List<ChargingOrder> chargingOrderList = chargingOrderMapper.selectList(orderSearch);
List<ChargingOrder> list = new ArrayList<>(chargingOrderList.size());
return new PageInfo<>(list);
return new PageInfo<>(chargingOrderList);
}
}
......@@ -25,4 +25,7 @@ spring.cloud.nacos.config.shared-configs[0].refresh=true
spring.cloud.nacos.config.shared-configs[1].group=${spring.cloud.nacos.config.group}
spring.cloud.nacos.config.shared-configs[1].data-id=platform-share-dev.properties
spring.cloud.nacos.config.shared-configs[1].refresh=true
\ No newline at end of file
spring.cloud.nacos.config.shared-configs[1].refresh=true
feign.compression.request.min-request-size=4096
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.com.glsx.evbusiness.modules.mapper.ChargingOrderMapper">
<resultMap id="BaseResultMap" type="cn.com.glsx.evbusiness.modules.entity.ChargingOrder">
<!--
WARNING - @mbg.generated
-->
<id column="id" jdbcType="INTEGER" property="id" />
<result column="order_code" jdbcType="VARCHAR" property="orderCode" />
<result column="order_status" jdbcType="TINYINT" property="orderStatus" />
<result column="order_source" jdbcType="TINYINT" property="orderSource" />
<result column="spear_id" jdbcType="INTEGER" property="spearId" />
<result column="park_space_num" jdbcType="VARCHAR" property="parkSpaceNum" />
<result column="execute_type" jdbcType="TINYINT" property="executeType" />
<result column="order_amount" jdbcType="DOUBLE" property="orderAmount" />
<result column="car_number" jdbcType="VARCHAR" property="carNumber" />
<result column="charg_endtime" jdbcType="TIMESTAMP" property="chargEndtime" />
<result column="charg_starttime" jdbcType="TIMESTAMP" property="chargStarttime" />
<result column="end_type" jdbcType="TINYINT" property="endType" />
<result column="total_degrees" jdbcType="REAL" property="totalDegrees" />
<result column="created_time" jdbcType="TIMESTAMP" property="createdTime" />
<id column="id" jdbcType="INTEGER" property="id"/>
<result column="order_code" jdbcType="VARCHAR" property="orderCode"/>
<result column="order_status" jdbcType="TINYINT" property="orderStatus"/>
<result column="order_source" jdbcType="TINYINT" property="orderSource"/>
<result column="spear_id" jdbcType="INTEGER" property="spearId"/>
<result column="park_space_num" jdbcType="VARCHAR" property="parkSpaceNum"/>
<result column="execute_type" jdbcType="TINYINT" property="executeType"/>
<result column="order_amount" jdbcType="DOUBLE" property="orderAmount"/>
<result column="car_number" jdbcType="VARCHAR" property="carNumber"/>
<result column="charg_endtime" jdbcType="TIMESTAMP" property="chargEndtime"/>
<result column="charg_starttime" jdbcType="TIMESTAMP" property="chargStarttime"/>
<result column="end_type" jdbcType="TINYINT" property="endType"/>
<result column="total_degrees" jdbcType="REAL" property="totalDegrees"/>
<result column="created_time" jdbcType="TIMESTAMP" property="createdTime"/>
</resultMap>
<sql id="Base_Column_List">
<!--
WARNING - @mbg.generated
-->
id, order_code, order_status, order_source, spear_id, park_space_num, execute_type,
order_amount, car_number, charg_endtime, charg_starttime, end_type, total_degrees,
id, order_code, order_status, order_source, spear_id, park_space_num, execute_type,
order_amount, car_number, charg_endtime, charg_starttime, end_type, total_degrees,
created_time
</sql>
<select id="selectList" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from charging_order
<where>
<if test="orderSearch.orderStatus != null">
and order_status=#{orderSearch.orderStatus}
</if>
</where>
</select>
<select id="findByOrderCode" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from charging_order
where order_code=#{orderCode}
</select>
</mapper>
\ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!