修改场站信息

This commit is contained in:
yuyang 2021-08-05 16:17:04 +08:00
parent 475ee06f7a
commit ad7df151e1
12 changed files with 247 additions and 17 deletions

View File

@ -76,4 +76,12 @@ public interface XhpcChargingPileMapper {
* @return
*/
int getXhpcChargingPileSerialNumberCount(@Param("serialNumber")String serialNumber);
/**
* 删除终端
* @param chargingPileId
* @return
*/
int updateXhpcTerminal(@Param("chargingPileId")Long chargingPileId);
}

View File

@ -1,6 +1,5 @@
package com.xhpc.charging.station.service;
import com.xhpc.common.api.dto.ChargingPileDto;
import com.xhpc.common.core.web.domain.AjaxResult;
import com.xhpc.common.domain.XhpcChargingPile;
import com.xhpc.common.domain.XhpcTerminal;
@ -68,7 +67,8 @@ public class XhpcChargingPileServiceImpl implements IXhpcChargingPileService{
xhpcTerminal.setChargingStationId(chargingStationId);
xhpcTerminal.setChargingPileId(chargingPileId);
xhpcTerminal.setName(serialNumber + "-" + (i));
xhpcTerminal.setPileSerialNumber(serialNumber+ "0" + i);
xhpcTerminal.setSerialNumber(serialNumber+ "0" + i);
xhpcTerminal.setPileSerialNumber(serialNumber);
xhpcTerminal.setWorkStatus(2);
xhpcTerminal.setStatus(0);
xhpcTerminalMapper.addXhpcTerminal(xhpcTerminal);
@ -96,6 +96,30 @@ public class XhpcChargingPileServiceImpl implements IXhpcChargingPileService{
return AjaxResult.error("桩编号不能编辑");
}
if(!xhpcChargingPile.getGunNumber().equals(xhpc.getGunNumber())){
//删除之前的终端
xhpcChargingPileMapper.updateXhpcTerminal(chargingPileId);
String serialNumber = xhpcChargingPile.getSerialNumber();
Long chargingStationId = xhpcChargingPile.getChargingStationId();
if(xhpcChargingPile.getGunNumber()>0){
for (int i = 0; i < xhpcChargingPile.getGunNumber(); i++) {
XhpcTerminal xhpcTerminal =new XhpcTerminal();
xhpcTerminal.setChargingStationId(chargingStationId);
xhpcTerminal.setChargingPileId(chargingPileId);
xhpcTerminal.setName(serialNumber + "-" + (i));
xhpcTerminal.setSerialNumber(serialNumber+ "0" + i);
xhpcTerminal.setPileSerialNumber(serialNumber);
xhpcTerminal.setWorkStatus(2);
xhpcTerminal.setStatus(0);
xhpcTerminalMapper.addXhpcTerminal(xhpcTerminal);
}
}
//插入redis 桩的编号
HashSet<String> noSet = new HashSet<>();
noSet.add(serialNumber);
powerPileService.addPileWhitelist(chargingStationId, noSet);
}
xhpcChargingPileMapper.updaeXhpcChargingPile(xhpcChargingPile);
return AjaxResult.success();
}

View File

@ -66,16 +66,19 @@ public class XhpcTerminalServiceImpl implements IXhpcTerminalService{
public AjaxResult selectXhpcTerminalPileMessage(Long terminalId) {
Map<String, Object> map = xhpcTerminalMapper.selectXhpcTerminalPileMessage(terminalId);
Long chargingStationId =Long.parseLong(map.get("chargingStationId").toString());
String gunNumber = map.get("serialNumber").toString();
//费率时段,先反设置时段在反默认时段
List<Map<String, Object>> xhpcRateTimeTypeList = xhpcTerminalMapper.getXhpcRateTimeTypeList(chargingStationId, 1);
xhpcRateTimeTypeList.addAll(xhpcTerminalMapper.getXhpcRateTimeTypeList(chargingStationId, 2));
map.put("rateTimeList",xhpcRateTimeTypeList);
if(map !=null && map.get("chargingStationId") !=null && map.get("serialNumber") !=null){
Long chargingStationId =Long.parseLong(map.get("chargingStationId").toString());
String gunNumber = map.get("serialNumber").toString();
//费率时段,先反设置时段在反默认时段
List<Map<String, Object>> xhpcRateTimeTypeList = xhpcTerminalMapper.getXhpcRateTimeTypeList(chargingStationId, 1);
xhpcRateTimeTypeList.addAll(xhpcTerminalMapper.getXhpcRateTimeTypeList(chargingStationId, 2));
map.put("rateTimeList",xhpcRateTimeTypeList);
//统计终端充redis获取终端信息
map.putAll(xhpcTerminalMapper.getXhpcRateTimeOrderStatistics(chargingStationId,gunNumber));
return AjaxResult.success(map);
//统计终端充redis获取终端信息
map.putAll(xhpcTerminalMapper.getXhpcRateTimeOrderStatistics(chargingStationId,gunNumber));
return AjaxResult.success(map);
}
return AjaxResult.error("无效终端");
}
@Override

View File

@ -41,6 +41,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
select
cp.charging_pile_id as chargingPileId,
cp.charging_station_id as chargingStationId,
cp.name as chargingPileName,
st.name as chargingStationName,
cp.serial_number as serialNumber,
cp.brand_model as brandModel,
@ -311,4 +312,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="getXhpcChargingPileSerialNumberCount" resultType="int">
select count(charging_pile_id) from xhpc_charging_pile where serial_number=#{serialNumber}
</select>
<update id="updateXhpcTerminal">
update xhpc_terminal set del_flag = 2 where charging_pile_id = #{chargingPileId}
</update>
</mapper>

View File

@ -195,6 +195,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
ct.parking_instructions as parkingInstructions,
ct.business_instructions as businessInstructions,
ct.reminder_instructions as reminderInstructions,
ct.client_visible as clientVisible,
ct.img_id as imgId
from xhpc_charging_station as ct
left join xhpc_operator as op on op.operator_id = ct.operator_id
@ -429,7 +430,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
update_by,
</if>
<if test="null != remark and '' != remark">
remark
remark,
</if>
<if test="null != stationType">
station_type
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
@ -506,7 +510,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
#{updateBy},
</if>
<if test="null != remark and '' != remark">
#{remark}
#{remark},
</if>
<if test="null != stationType">
#{stationType}
</if>
</trim>
</insert>
@ -707,7 +714,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
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.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

View File

@ -33,7 +33,7 @@ public class SeqUtil {
return upperCode;
}
public synchronized static String seqDec(String key, int len) {
public synchronized static String seqDec(String key) {
String upperCode = "";
RedisAtomicLong counter = new RedisAtomicLong(key, REDIS.redisTemplate.getConnectionFactory());

View File

@ -1,4 +1,4 @@
package com.xhpc.order;
package com.xhpc;
import com.xhpc.common.security.annotation.EnableCustomConfig;
import com.xhpc.common.security.annotation.EnableRyFeignClients;

View File

@ -31,6 +31,24 @@ public class HxpcChargeOrderController extends BaseController {
return iHxpcChargeOrderService.getHistotyChargeOrderMessage(userId);
}
/**
* 异常订单
*/
@GetMapping("/getHistotyChargeOrderStatusList")
public AjaxResult getHistotyChargeOrderStatusList(@RequestParam Long userId)
{
return iHxpcChargeOrderService.getHistotyChargeOrderStatusList(userId);
}
/**
* 启动充电
*/
@GetMapping("/startUp")
public AjaxResult startUp(@RequestParam Long userId,@RequestParam String serialNumber){
return iHxpcChargeOrderService.startUp(userId, serialNumber);
}
}

View File

@ -1,8 +1,9 @@
package com.xhpc.order.mapper;
import com.xhpc.common.core.web.domain.AjaxResult;
import com.xhpc.common.domain.XhpcTerminal;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
/**
@ -17,4 +18,33 @@ public interface HxpcChargeOrderMapper {
* @return
*/
Map<String,Object> getHistotyChargeOrderMessage(@Param("userId") Long userId);
/**
* 异常订单
* @param userId
* @return
*/
List<Map<String,Object>> getHistotyChargeOrderStatusList(@Param("userId")Long userId);
/**
* 获取用户信息
*/
Map<String,Object> getUserMessage(@Param("userId")Long userId);
/**
* 判断用户是否在充电中
*/
int countXhpcRealTimeOrder(@Param("userId")Long userId);
/**
* 判断用户是否有异常订单未处理
*/
int countXhpcChargeOrder(@Param("userId")Long userId);
/**
* 获取终端信息
*/
XhpcTerminal getXhpcTerminalSerialNumber(@Param("serialNumber")String serialNumber);
}

View File

@ -15,4 +15,17 @@ public interface IHxpcChargeOrderService {
*/
AjaxResult getHistotyChargeOrderMessage(Long userId);
/**
* 异常订单
* @param userId
* @return
*/
AjaxResult getHistotyChargeOrderStatusList(Long userId);
/**
* 启动充电
* @param userId
* @return
*/
AjaxResult startUp(Long userId,String serialNumber);
}

View File

@ -1,11 +1,20 @@
package com.xhpc.order.service.impl;
import com.xhpc.common.api.PowerPileService;
import com.xhpc.common.core.domain.R;
import com.xhpc.common.core.web.domain.AjaxResult;
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.mapper.HxpcChargeOrderMapper;
import com.xhpc.order.service.IHxpcChargeOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.util.Map;
/**
* @author yuyang
* @date 2021/8/4 9:54
@ -15,6 +24,8 @@ public class HxpcChargeOrderServiceImpl implements IHxpcChargeOrderService {
@Autowired
private HxpcChargeOrderMapper hxpcChargeOrderMapper;
@Autowired
private PowerPileService powerPileService;
@Override
public AjaxResult getHistotyChargeOrderMessage(Long userId) {
@ -22,4 +33,66 @@ public class HxpcChargeOrderServiceImpl implements IHxpcChargeOrderService {
return AjaxResult.success(hxpcChargeOrderMapper.getHistotyChargeOrderMessage(userId));
}
@Override
public AjaxResult getHistotyChargeOrderStatusList(Long userId) {
return null;
}
@Override
public AjaxResult startUp(Long userId,String serialNumber) {
//金额是否大于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( Integer.parseInt(userMessage.get("isRefundApplication").toString())!=0){
return AjaxResult.error(1101,"你有申请退款订单在审核中,需要充电请取消申请退款");
}
//是否在充电中
int i = hxpcChargeOrderMapper.countXhpcRealTimeOrder(userId);
if(i>0){
return AjaxResult.error(1102,"车辆正在充电,请查询车辆充电信息");
}
//是否存在异常的订单
int j = hxpcChargeOrderMapper.countXhpcChargeOrder(userId);
if(j>0){
return AjaxResult.error(1103,"你有异常订单未解决,请拨打客服电话进行解决");
}
//终端状态是否空闲
//是否插枪
System.out.println("<<R>>"+powerPileService.terminalStatus(serialNumber));
//终端信息
XhpcTerminal xhpcTerminal = hxpcChargeOrderMapper.getXhpcTerminalSerialNumber(serialNumber);
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));
//启动充电
StartChargingData startChargingData =new StartChargingData();
//订单流水号
startChargingData.setOrderNo(SeqUtil.seqDec("gun:" + serialNumber + ".seqdec"));
startChargingData.setPileNo(xhpcTerminal.getPileSerialNumber());
startChargingData.setGunId(xhpcTerminal.getSerialNumber());
startChargingData.setBalance(Integer.valueOf(balance1.toString()));
startChargingData.setVersion("0A");
//R r = powerPileService.startCharging(startChargingData);
//创建充电订单
HxpcChargeOrder hxpcChargeOrder =new HxpcChargeOrder();
return null;
}
}

View File

@ -23,6 +23,23 @@
<result column="rate_model_id" property="rateModelId"/>
</resultMap>
<resultMap id="BaseResultMap" type="com.xhpc.common.domain.XhpcTerminal">
<result property="terminalId" column="terminal_id"/>
<result property="chargingPileId" column="charging_pile_id"/>
<result property="chargingStationId" column="charging_station_id"/>
<result property="name" column="name"/>
<result property="serialNumber" column="serial_number"/>
<result property="pileSerialNumber" column="pile_serial_number"/>
<result property="gunStatus" column="gun_status"/>
<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" />
</resultMap>
<select id="getHistotyChargeOrderMessage" resultType="map">
select
rto.real_time_order_id as realTimeOrderId,
@ -43,4 +60,34 @@
where rto.charging_order_id =(select charge_order_id from xhpc_charge_order where status =0 and source = 0 ORDER BY create_time desc LIMIT 1)
and rto.user_id=#{userId}
</select>
<select id="getUserMessage" resultType="map">
select
app_user_id as appUserId,
balance as balance,
is_refund_application as isRefundApplication
from xhpc_app_user
where del_flag=0
</select>
<select id="countXhpcRealTimeOrder" resultType="int">
select count(real_time_order_id) from xhpc_real_time_order where user_id =#{userId} and type =2 order by create_time desc LIMIT 1
</select>
<select id="countXhpcChargeOrder" resultType="int">
select count(charge_order_id) from xhpc_charge_order where user_id =#{userId} and status =2 and del_flag =0
</select>
<select id="getXhpcTerminalSerialNumber" resultMap="BaseResultMap">
select
*
from xhpc_terminal
where serial_number=#{serialNumber} and del_flag=0 limit 1
</select>
<select id="getHistotyChargeOrderStatusList" resultType="map">
</select>
</mapper>