小程序启动充电接口
This commit is contained in:
parent
c845658b88
commit
f028580572
@ -1,5 +1,9 @@
|
||||
package com.xhpc.charging.station.service;
|
||||
|
||||
import com.xhpc.common.core.domain.R;
|
||||
import com.xhpc.common.core.web.domain.AjaxResult;
|
||||
import com.xhpc.common.domain.XhpcChargingPile;
|
||||
import com.xhpc.common.domain.XhpcTerminal;
|
||||
import com.xhpc.charging.station.mapper.XhpcChargingPileMapper;
|
||||
import com.xhpc.charging.station.mapper.XhpcTerminalMapper;
|
||||
import com.xhpc.common.api.PowerPileService;
|
||||
@ -74,6 +78,7 @@ public class XhpcChargingPileServiceImpl implements IXhpcChargingPileService {
|
||||
xhpcTerminal.setPileSerialNumber(serialNumber);
|
||||
xhpcTerminal.setWorkStatus(2);
|
||||
xhpcTerminal.setStatus(0);
|
||||
xhpcTerminal.setRateModelId(rateModelId);
|
||||
xhpcTerminalMapper.addXhpcTerminal(xhpcTerminal);
|
||||
}
|
||||
}
|
||||
@ -81,8 +86,9 @@ public class XhpcChargingPileServiceImpl implements IXhpcChargingPileService {
|
||||
//插入redis 桩的编号
|
||||
HashSet<String> noSet = new HashSet<>();
|
||||
noSet.add(serialNumber);
|
||||
powerPileService.addPileWhitelist(chargingStationId, noSet);
|
||||
|
||||
R r = powerPileService.addPileWhitelist(chargingStationId, noSet);
|
||||
System.out.println(">>>>>>"+r.getCode());
|
||||
System.out.println(">>>>>>"+r.getMsg());
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
@ -104,6 +110,7 @@ public class XhpcChargingPileServiceImpl implements IXhpcChargingPileService {
|
||||
xhpcChargingPileMapper.updateXhpcTerminal(chargingPileId);
|
||||
|
||||
String serialNumber = xhpcChargingPile.getSerialNumber();
|
||||
Long rateModelId = xhpcChargingPile.getRateModelId();
|
||||
Long chargingStationId = xhpcChargingPile.getChargingStationId();
|
||||
if (xhpcChargingPile.getGunNumber() > 0) {
|
||||
for (int i = 0; i < xhpcChargingPile.getGunNumber(); i++) {
|
||||
@ -115,6 +122,7 @@ public class XhpcChargingPileServiceImpl implements IXhpcChargingPileService {
|
||||
xhpcTerminal.setPileSerialNumber(serialNumber);
|
||||
xhpcTerminal.setWorkStatus(2);
|
||||
xhpcTerminal.setStatus(0);
|
||||
xhpcTerminal.setRateModelId(rateModelId);
|
||||
xhpcTerminalMapper.addXhpcTerminal(xhpcTerminal);
|
||||
}
|
||||
}
|
||||
|
||||
@ -505,7 +505,8 @@ public class XhpcChargingStationServiceImpl implements IXhpcChargingStationServi
|
||||
cacheRateModel.setTfPricesSeq(tfPricesSeq);
|
||||
|
||||
R r = powerPileService.setStationRateModel(chargingStationId, rateModelId, cacheRateModel);
|
||||
System.out.println(r.toString());
|
||||
System.out.println(r.getCode());
|
||||
System.out.println(r.getMsg());
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
@ -537,7 +538,6 @@ public class XhpcChargingStationServiceImpl implements IXhpcChargingStationServi
|
||||
|
||||
//费率时段,先反设置时段,在反默认时段
|
||||
List<Map<String, Object>> xhpcRateTimeTypeList = xhpcChargingStationMapper.getXhpcRateTimeTypeList(chargingStationId, 1);
|
||||
xhpcRateTimeTypeList.addAll(xhpcChargingStationMapper.getXhpcRateTimeTypeList(chargingStationId, 2));
|
||||
map.put("xhpcRateTimeList", xhpcRateTimeTypeList);
|
||||
if (type == 2) {
|
||||
//统计终端(充redis获取终端信息)
|
||||
|
||||
@ -240,11 +240,8 @@
|
||||
GROUP_CONCAT(DISTINCT xdbp.dict_value ORDER BY xdbp.create_time ASC separator ',' ) peripheryFacilitiesName
|
||||
from xhpc_charging_station as ct
|
||||
left join xhpc_operator as op on op.operator_id = ct.operator_id
|
||||
left join xhpc_dict_biz xdbs on xdbs.code = 'service_facilities' and FIND_IN_SET(xdbs.dict_key,ct.service_facilities)
|
||||
left join xhpc_dict_biz xdbp on xdbp.code = 'charging_periphery_facilities' and FIND_IN_SET(xdbp.dict_key,ct.periphery_facilities)
|
||||
where ct.charging_station_id = #{chargingStationId}
|
||||
and ct.del_flag = 0
|
||||
group by ct.charging_station_id
|
||||
</select>
|
||||
|
||||
<select id="getWXList" resultType="map">
|
||||
@ -759,31 +756,17 @@
|
||||
</select>
|
||||
|
||||
<select id="getXhpcRateTimeTypeList" resultType="java.util.Map">
|
||||
<if test="type ==1">
|
||||
select
|
||||
rt.start_time as startTime,
|
||||
replace(rt.end_time,'00:00:00','24:00:00') AS endTime,
|
||||
rt.rate_id as rateId,
|
||||
rt.rate_value as id,
|
||||
ra.name as rateName,
|
||||
ra.power_fee as powerFee,
|
||||
ra.service_fee as serviceFee
|
||||
from xhpc_rate_time as rt
|
||||
left join xhpc_rate as ra on ra.rate_id =rt.rate_id
|
||||
where rt.charging_station_id=#{chargingStationId} and rt.del_flag =0 and rt.type=1
|
||||
</if>
|
||||
<if test="type ==2">
|
||||
select
|
||||
rt.start_time as startTime,
|
||||
replace(rt.end_time,'00:00:00','24:00:00') AS endTime,
|
||||
rt.rate_id as rateId,
|
||||
rt.rate_value as id,
|
||||
ra.name as rateName
|
||||
from xhpc_rate_time as rt
|
||||
left join xhpc_rate as ra on ra.rate_id =rt.rate_id
|
||||
where rt.charging_station_id=#{chargingStationId} and rt.del_flag =0 and rt.type=2
|
||||
group by type
|
||||
</if>
|
||||
select rt.start_time as startTime,
|
||||
replace(rt.end_time, '00:00:00', '24:00:00') AS endTime,
|
||||
rt.rate_id as rateId,
|
||||
rt.rate_value as id,
|
||||
ra.name as rateName,
|
||||
ra.power_fee as powerFee,
|
||||
ra.service_fee as serviceFee
|
||||
from xhpc_rate_time as rt
|
||||
left join xhpc_rate as ra on ra.rate_id = rt.rate_id
|
||||
where rt.charging_station_id = #{chargingStationId}
|
||||
and rt.del_flag = 0
|
||||
</select>
|
||||
|
||||
<select id="getXhpcRateTimeOrderStatistics" resultType="java.util.Map">
|
||||
|
||||
@ -20,6 +20,7 @@
|
||||
<result property="updateTime" column="update_time"/>
|
||||
<result property="updateBy" column="update_by"/>
|
||||
<result property="remark" column="remark"/>
|
||||
<result property="rateModelId" column="rate_model_id"/>
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectXhpcTerminalVo">
|
||||
|
||||
@ -42,6 +42,9 @@ public class XhpcTerminal extends BaseEntity {
|
||||
/** 删除标志(0代表存在 2代表删除) */
|
||||
private Integer delFlag;
|
||||
|
||||
/** 费率模型id */
|
||||
private Long rateModelId;
|
||||
|
||||
public static long getSerialVersionUID() {
|
||||
|
||||
return serialVersionUID;
|
||||
@ -147,4 +150,14 @@ public class XhpcTerminal extends BaseEntity {
|
||||
this.delFlag = delFlag;
|
||||
}
|
||||
|
||||
public Long getRateModelId() {
|
||||
|
||||
return rateModelId;
|
||||
}
|
||||
|
||||
public void setRateModelId(Long rateModelId) {
|
||||
|
||||
this.rateModelId = rateModelId;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package com.xhpc.order.mapper;
|
||||
|
||||
import com.xhpc.common.domain.XhpcTerminal;
|
||||
import com.xhpc.order.domain.HxpcChargeOrder;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
@ -47,4 +48,7 @@ public interface HxpcChargeOrderMapper {
|
||||
* 获取终端信息
|
||||
*/
|
||||
XhpcTerminal getXhpcTerminalSerialNumber(@Param("serialNumber")String serialNumber);
|
||||
|
||||
//添加充电订单
|
||||
int addXhpcTerminalSerial(HxpcChargeOrder hxpcChargeOrder);
|
||||
}
|
||||
|
||||
@ -7,6 +7,7 @@ import com.xhpc.common.data.down.StartChargingData;
|
||||
import com.xhpc.common.data.redis.SeqUtil;
|
||||
import com.xhpc.common.domain.XhpcTerminal;
|
||||
import com.xhpc.order.domain.HxpcChargeOrder;
|
||||
import com.xhpc.order.domain.XhpcHistoryOrder;
|
||||
import com.xhpc.order.mapper.HxpcChargeOrderMapper;
|
||||
import com.xhpc.order.service.IHxpcChargeOrderService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@ -14,6 +15,8 @@ import org.springframework.stereotype.Service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Map;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* @author yuyang
|
||||
@ -40,59 +43,74 @@ public class HxpcChargeOrderServiceImpl implements IHxpcChargeOrderService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public AjaxResult startUp(Long userId,String serialNumber) {
|
||||
|
||||
public AjaxResult startUp(Long userId, String serialNumber) {
|
||||
String pattern = "^([0-9]{16})";
|
||||
Pattern compile = Pattern.compile(pattern);
|
||||
Matcher m = compile.matcher(serialNumber);
|
||||
if (serialNumber.length()!=16 || !m.matches()) {
|
||||
return AjaxResult.error(1104, "无效的终端编号");
|
||||
}
|
||||
//金额是否大于5元
|
||||
Map<String, Object> userMessage = hxpcChargeOrderMapper.getUserMessage(userId);
|
||||
BigDecimal a = new BigDecimal(5);
|
||||
if(userMessage ==null || userMessage.get("balance") ==null|| a.compareTo(new BigDecimal(userMessage.get("balance").toString())) == 1){
|
||||
return AjaxResult.error(1100,"金额小于5元,不能充电,请充值后再进行充电");
|
||||
if (userMessage == null || userMessage.get("balance") == null || a.compareTo(new BigDecimal(userMessage.get("balance").toString())) == 1) {
|
||||
return AjaxResult.error(1100, "金额小于5元,不能充电,请充值后再进行充电");
|
||||
}
|
||||
//是否有申请退款的订单,还未处理
|
||||
if( Integer.parseInt(userMessage.get("isRefundApplication").toString())!=0){
|
||||
return AjaxResult.error(1101,"你有申请退款订单在审核中,需要充电请取消申请退款");
|
||||
if (Integer.parseInt(userMessage.get("isRefundApplication").toString()) != 0) {
|
||||
return AjaxResult.error(1101, "你有申请退款订单在审核中,需要充电请取消申请退款");
|
||||
}
|
||||
//是否在充电中
|
||||
int i = hxpcChargeOrderMapper.countXhpcRealTimeOrder(userId);
|
||||
if(i>0){
|
||||
return AjaxResult.error(1102,"车辆正在充电,请查询车辆充电信息");
|
||||
if (i > 0) {
|
||||
return AjaxResult.error(1102, "车辆正在充电,请查询车辆充电信息");
|
||||
}
|
||||
//是否存在异常的订单
|
||||
int j = hxpcChargeOrderMapper.countXhpcChargeOrder(userId);
|
||||
if(j>0){
|
||||
return AjaxResult.error(1103,"你有异常订单未解决,请拨打客服电话进行解决");
|
||||
if (j > 0) {
|
||||
return AjaxResult.error(1103, "你有异常订单未解决,请拨打客服电话进行解决");
|
||||
}
|
||||
//终端状态是否空闲
|
||||
//是否插枪
|
||||
System.out.println("<<R>>"+powerPileService.terminalStatus(serialNumber));
|
||||
R r = powerPileService.terminalStatus(serialNumber);
|
||||
if(r.getCode() !=200){
|
||||
return AjaxResult.error(r.getMsg());
|
||||
}
|
||||
//终端信息
|
||||
XhpcTerminal xhpcTerminal = hxpcChargeOrderMapper.getXhpcTerminalSerialNumber(serialNumber);
|
||||
if(xhpcTerminal ==null || xhpcTerminal.getTerminalId()==null|| xhpcTerminal.getChargingPileId() ==null || xhpcTerminal.getPileSerialNumber()==null){
|
||||
return AjaxResult.error(1104,"无效的终端编号");
|
||||
if (xhpcTerminal == null || xhpcTerminal.getTerminalId() == null || xhpcTerminal.getChargingPileId() == null || xhpcTerminal.getPileSerialNumber() == null) {
|
||||
return AjaxResult.error(1104, "无效的终端编号");
|
||||
}
|
||||
//余额
|
||||
BigDecimal balance1 = new BigDecimal(userMessage.get("balance").toString()).multiply(new BigDecimal(100));
|
||||
String balance = userMessage.get("balance").toString();
|
||||
//启动充电
|
||||
StartChargingData startChargingData =new StartChargingData();
|
||||
StartChargingData startChargingData = new StartChargingData();
|
||||
//订单流水号
|
||||
startChargingData.setOrderNo(SeqUtil.seqDec("gun:" + serialNumber + ".seqdec"));
|
||||
String orderNo = SeqUtil.seqDec("gun:" + serialNumber + ".seqdec");
|
||||
startChargingData.setOrderNo(orderNo);
|
||||
startChargingData.setPileNo(xhpcTerminal.getPileSerialNumber());
|
||||
startChargingData.setGunId(xhpcTerminal.getSerialNumber());
|
||||
startChargingData.setBalance(Integer.valueOf(balance1.toString()));
|
||||
startChargingData.setBalance(Double.valueOf(balance).intValue());
|
||||
startChargingData.setVersion("0A");
|
||||
//R r = powerPileService.startCharging(startChargingData);
|
||||
R r1 = powerPileService.startCharging(startChargingData);
|
||||
System.out.println("<<<<<<<"+r1.getCode());
|
||||
System.out.println("<<<<<<<"+r1.getMsg());
|
||||
if(r1.getCode() !=200){
|
||||
return AjaxResult.error(r1.getMsg());
|
||||
}
|
||||
|
||||
//创建充电订单(充电启动soc初始值,结束是获取,并修改状态)
|
||||
HxpcChargeOrder hxpcChargeOrder = new HxpcChargeOrder();
|
||||
hxpcChargeOrder.setChargingStationId(xhpcTerminal.getChargingStationId());
|
||||
hxpcChargeOrder.setUserId(userId);
|
||||
hxpcChargeOrder.setTerminalId(xhpcTerminal.getTerminalId());
|
||||
hxpcChargeOrder.setSerialNumber(orderNo);
|
||||
hxpcChargeOrder.setSource(0);
|
||||
hxpcChargeOrder.setStatus(0);
|
||||
hxpcChargeOrder.setRateModelId(xhpcTerminal.getRateModelId());
|
||||
hxpcChargeOrderMapper.addXhpcTerminalSerial(hxpcChargeOrder);
|
||||
|
||||
|
||||
//创建充电订单
|
||||
HxpcChargeOrder hxpcChargeOrder =new HxpcChargeOrder();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return null;
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -34,12 +34,14 @@
|
||||
<result property="workStatus" column="work_status"/>
|
||||
<result property="status" column="status"/>
|
||||
<result property="delFlag" column="del_flag"/>
|
||||
<result property="createTime" column="create_time" />
|
||||
<result property="createBy" column="create_by" />
|
||||
<result property="updateTime" column="update_time" />
|
||||
<result property="updateBy" column="update_by" />
|
||||
<result property="remark" column="remark" />
|
||||
<result property="createTime" column="create_time"/>
|
||||
<result property="createBy" column="create_by"/>
|
||||
<result property="updateTime" column="update_time"/>
|
||||
<result property="updateBy" column="update_by"/>
|
||||
<result property="remark" column="remark"/>
|
||||
<result property="rateModelId" column="rate_model_id"/>
|
||||
</resultMap>
|
||||
|
||||
<select id="getHistotyChargeOrderMessage" resultType="map">
|
||||
select
|
||||
rto.real_time_order_id as realTimeOrderId,
|
||||
@ -84,6 +86,75 @@
|
||||
where serial_number=#{serialNumber} and del_flag=0 limit 1
|
||||
</select>
|
||||
|
||||
<insert id="addXhpcTerminalSerial" parameterType="com.xhpc.order.domain.HxpcChargeOrder" useGeneratedKeys="true"
|
||||
keyProperty="chargeOrderId">
|
||||
insert into xhpc_charge_order
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="null != chargingStationId ">
|
||||
charging_station_id,
|
||||
</if>
|
||||
<if test="null != userId ">
|
||||
user_id,
|
||||
</if>
|
||||
<if test="null != terminalId ">
|
||||
terminal_id,
|
||||
</if>
|
||||
<if test="null != internetSerialNumber ">
|
||||
internet_serial_number,
|
||||
</if>
|
||||
<if test="null != serialNumber ">
|
||||
serial_number,
|
||||
</if>
|
||||
<if test="null != startSoc ">
|
||||
start_soc,
|
||||
</if>
|
||||
<if test="null != source ">
|
||||
source,
|
||||
</if>
|
||||
<if test="null != status ">
|
||||
status,
|
||||
</if>
|
||||
<if test="null != delFlag ">
|
||||
del_flag,
|
||||
</if>
|
||||
<if test="null != rateModelId ">
|
||||
rate_model_id
|
||||
</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="null != chargingStationId ">
|
||||
#{chargingStationId},
|
||||
</if>
|
||||
<if test="null != userId ">
|
||||
#{userId},
|
||||
</if>
|
||||
<if test="null != terminalId ">
|
||||
#{terminalId},
|
||||
</if>
|
||||
<if test="null != internetSerialNumber ">
|
||||
#{internetSerialNumber},
|
||||
</if>
|
||||
<if test="null != serialNumber ">
|
||||
#{serialNumber},
|
||||
</if>
|
||||
<if test="null != startSoc ">
|
||||
#{startSoc},
|
||||
</if>
|
||||
<if test="null != source ">
|
||||
#{source},
|
||||
</if>
|
||||
<if test="null != status ">
|
||||
#{status},
|
||||
</if>
|
||||
<if test="null != delFlag ">
|
||||
#{delFlag},
|
||||
</if>
|
||||
<if test="null != rateModelId ">
|
||||
#{rateModelId}
|
||||
</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
|
||||
|
||||
<select id="getHistotyChargeOrderStatusList" resultType="map">
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user