新增VIN码充电
This commit is contained in:
parent
c2ba419b7d
commit
d2e4df685b
@ -50,6 +50,7 @@ public class XhpcPileEditionServiceImpl extends BaseService implements IXhpcPil
|
|||||||
List<Map<String, Object>> list =new ArrayList<>();
|
List<Map<String, Object>> list =new ArrayList<>();
|
||||||
if(UserTypeUtil.SYS_USER_TYPE_FOUR.equals(sysUser.getUserType())){
|
if(UserTypeUtil.SYS_USER_TYPE_FOUR.equals(sysUser.getUserType())){
|
||||||
//运维人员权限
|
//运维人员权限
|
||||||
|
list = xhpcPileEditionMapper.list(chargingStationId,chargingPileIds,sysUserId,3,tenantId);
|
||||||
}else{
|
}else{
|
||||||
if(!UserTypeUtil.SYS_USER_TYPE_ADMIN.equals(sysUser.getUserId())){
|
if(!UserTypeUtil.SYS_USER_TYPE_ADMIN.equals(sysUser.getUserId())){
|
||||||
// startPage();
|
// startPage();
|
||||||
|
|||||||
@ -27,8 +27,8 @@
|
|||||||
xpe.direct_number as directNumber,
|
xpe.direct_number as directNumber,
|
||||||
xpe.communication_number as communicationNumber,
|
xpe.communication_number as communicationNumber,
|
||||||
xpe.status as status,
|
xpe.status as status,
|
||||||
|
xpe.create_time as createTime,
|
||||||
(SELECT concat(replace(group_concat(name),',','号桩,'),'号桩') FROM xhpc_charging_pile where find_in_set(charging_pile_id,xpe.charging_pile_ids)) as chargingPileName
|
(SELECT concat(replace(group_concat(name),',','号桩,'),'号桩') FROM xhpc_charging_pile where find_in_set(charging_pile_id,xpe.charging_pile_ids)) as chargingPileName
|
||||||
|
|
||||||
from xhpc_pile_edition as xpe
|
from xhpc_pile_edition as xpe
|
||||||
left join xhpc_charging_station xcs on xpe.charging_station_id = xcs.charging_station_id
|
left join xhpc_charging_station xcs on xpe.charging_station_id = xcs.charging_station_id
|
||||||
where xpe.del_flag=0
|
where xpe.del_flag=0
|
||||||
@ -44,6 +44,9 @@
|
|||||||
<if test="type ==2">
|
<if test="type ==2">
|
||||||
and xpe.charging_station_id in(select charging_station_id from xhpc_user_privilege where user_id=#{logOperatorId})
|
and xpe.charging_station_id in(select charging_station_id from xhpc_user_privilege where user_id=#{logOperatorId})
|
||||||
</if>
|
</if>
|
||||||
|
<if test="type ==3">
|
||||||
|
and find_in_set (xpe.charging_station_id,(select station_ids from xhpc_work_user where work_user_id=#{logOperatorId}))
|
||||||
|
</if>
|
||||||
<if test="tenantId !=null and tenantId !=''">
|
<if test="tenantId !=null and tenantId !=''">
|
||||||
and xpe.tenant_id=#{tenantId}
|
and xpe.tenant_id=#{tenantId}
|
||||||
</if>
|
</if>
|
||||||
|
|||||||
@ -73,4 +73,14 @@ public interface PileOrderService {
|
|||||||
@RequestParam(value = "plateNum", required = false) String plateNum,
|
@RequestParam(value = "plateNum", required = false) String plateNum,
|
||||||
@RequestParam(value = "status") Integer status,
|
@RequestParam(value = "status") Integer status,
|
||||||
@RequestParam(value = "connectorId") String connectorId);
|
@RequestParam(value = "connectorId") String connectorId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* VIN启动
|
||||||
|
* @param serialNumber
|
||||||
|
* @param vinNumber
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@GetMapping("/chargeOrder/pileVin")
|
||||||
|
R pileVin(@RequestParam(value = "serialNumber") String serialNumber,@RequestParam String vinNumber);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -56,6 +56,11 @@ public class PileOrderFallbackFactory implements FallbackFactory<PileOrderServic
|
|||||||
|
|
||||||
return R.fail("互联网订单启动失败:" + cause.getMessage());
|
return R.fail("互联网订单启动失败:" + cause.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public R pileVin(String serialNumber, String vinNumber) {
|
||||||
|
return R.fail("VIN码启动失败:" + cause.getMessage());
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -185,7 +185,12 @@ public class XhpcChargeOrderController extends BaseController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@GetMapping("/pileVin")
|
||||||
|
public R pileVin(String serialNumber,String vinNumber)
|
||||||
|
{
|
||||||
|
logger.info("<<<<<<<<<<VIN码启动前判断<<<<<<<<<<<<<<serialNumber>>>>>>>>"+serialNumber+">>>vinNumber>>>"+vinNumber+">>>");
|
||||||
|
return iXhpcChargeOrderService.pileVin(serialNumber,vinNumber);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -171,4 +171,5 @@ public interface IXhpcChargeOrderService {
|
|||||||
|
|
||||||
R cardStartup(Long userId,String serialNumber,Integer userType,String tenantId, Integer type, String grantOperator,String rateModelId);
|
R cardStartup(Long userId,String serialNumber,Integer userType,String tenantId, Integer type, String grantOperator,String rateModelId);
|
||||||
|
|
||||||
|
R pileVin(String serialNumber,String vinNumber);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -861,6 +861,197 @@ public class XhpcChargeOrderServiceImpl extends BaseService implements IXhpcChar
|
|||||||
return R.fail(Constants.INTERNAL_ERROR);
|
return R.fail(Constants.INTERNAL_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public R pileVin(String serialNumber, String vinNumber) {
|
||||||
|
|
||||||
|
try{
|
||||||
|
|
||||||
|
//Vin码表获取 用户id,用户类型
|
||||||
|
Long userId = 1L;
|
||||||
|
Integer userType = 0;
|
||||||
|
XhpcTerminal xhpcTerminal = xhpcChargeOrderMapper.getXhpcTerminalSerialNumber(serialNumber,null);
|
||||||
|
String tenantId = xhpcTerminal.getTenantId();
|
||||||
|
long l1 = System.currentTimeMillis();
|
||||||
|
logger.info("<<<<<<<"+serialNumber+"开始启动充电获取用户时间>>>>>:"+l1);
|
||||||
|
R user = userTypeService.getUser(null, userId, userType, vinNumber,tenantId);
|
||||||
|
long l2 = System.currentTimeMillis();
|
||||||
|
logger.info("<<<<<<<"+serialNumber+"结束启动充电获取用户时间>>>>>:"+l2);
|
||||||
|
logger.info("<<<<<<<"+serialNumber+"启动充电时间差>>>>>:"+(l2-l1));
|
||||||
|
|
||||||
|
Map<String, Object> userMessage = (Map<String, Object>)user.getData();
|
||||||
|
if(UserTypeUtil.USER_TYPE !=userType){
|
||||||
|
if(Integer.valueOf(userMessage.get("number").toString())==0){
|
||||||
|
return R.fail(UserTypeUtil.LOGIN_TYPE, "此账号不能在该场站充电,请使用手机号登录");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
String pattern = "^([0-9]{16})";
|
||||||
|
Pattern compile = Pattern.compile(pattern);
|
||||||
|
Matcher m = compile.matcher(serialNumber);
|
||||||
|
if (serialNumber.length() != 16 || !m.matches()) {
|
||||||
|
return R.fail(1104, "无效的终端编号");
|
||||||
|
}
|
||||||
|
//终端信息
|
||||||
|
if (xhpcTerminal == null || xhpcTerminal.getTerminalId() == null || xhpcTerminal.getChargingPileId() == null || xhpcTerminal.getPileSerialNumber() == null) {
|
||||||
|
String pilePrompt = redisService.getCacheObject("pilePrompt:"+tenantId);
|
||||||
|
if(!"".equals(pilePrompt) && pilePrompt !=null){
|
||||||
|
return R.fail(1104, pilePrompt);
|
||||||
|
}
|
||||||
|
return R.fail(1104, "因限电该桩已停用,请选择其他桩进行充电");
|
||||||
|
}
|
||||||
|
//查看充电用户金额是否大于5元
|
||||||
|
//Map<String, Object> userMessage = xhpcChargeOrderMapper.getUserMessage(userId);
|
||||||
|
BigDecimal a = new BigDecimal(5);
|
||||||
|
if (userMessage == null || userMessage.get("balance") == null || a.compareTo(new BigDecimal(userMessage.get("balance").toString())) == 1) {
|
||||||
|
return R.fail(1100, "金额小于5元,不能充电,请充值后再进行充电");
|
||||||
|
}
|
||||||
|
//充电用户是否存在异常的订单
|
||||||
|
int j = xhpcChargeOrderMapper.countXhpcChargeOrder(userId,userType,tenantId);
|
||||||
|
if (j > 0) {
|
||||||
|
return R.fail(1103, "你有异常订单未解决,请拨打客服电话进行解决");
|
||||||
|
}
|
||||||
|
//查看充电用户是否有申请退款的订单,还未处理
|
||||||
|
if (Integer.parseInt(userMessage.get("isRefundApplication").toString()) != 0) {
|
||||||
|
return R.fail(1101, "你有申请退款订单在审核中,需要充电请取消申请退款");
|
||||||
|
}
|
||||||
|
//充电用户是否在充电中
|
||||||
|
String i = xhpcChargeOrderMapper.countXhpcRealTimeOrder(userId,userType,tenantId);
|
||||||
|
if (!"".equals(i) && i!=null) {
|
||||||
|
return R.fail(1102, "车辆正在充电,请查询车辆充电信息");
|
||||||
|
}
|
||||||
|
//终端状态是否空闲
|
||||||
|
//是否插枪
|
||||||
|
Map<String, Object> cacheMap = REDIS.getCacheMap("gun:" + serialNumber);
|
||||||
|
logger.info("<<<<<<<<<<<<<<<<<<<<<<<<cacheMap>>>>>>>>>>>>>>>>>");
|
||||||
|
logger.info("<<<<<<<<<<<<<<<<<<<<<<<<cacheMap>>>>>>>>>>>>>>>>>" + serialNumber);
|
||||||
|
logger.info("<<<<<<<<<<<<<<<<<<<<<<<<cacheMap>>>>>>>>>>>>>>>>>" + cacheMap.toString());
|
||||||
|
logger.info("<<<<<<<<<<<<<<<<<<<<<<<<cacheMap>>>>>>>>>>>>>>>>>");
|
||||||
|
|
||||||
|
if(cacheMap==null){
|
||||||
|
return R.fail(1105, "未注册的终端,请选择其他终端充电");
|
||||||
|
}else{
|
||||||
|
if(cacheMap.get("status") ==null){
|
||||||
|
return R.fail(1106, "未知的终端状态,请选择其他终端充电");
|
||||||
|
}else{
|
||||||
|
String status = cacheMap.get("status").toString();
|
||||||
|
//不同的状态
|
||||||
|
if("离线".equals(status)||"故障".equals(status) ||"充电".equals(status)){
|
||||||
|
return R.fail(1107, "此终端"+status+"中,请选择其他终端充电");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(cacheMap.get("vehicleGunStatus") ==null){
|
||||||
|
return R.fail(1108, "未知的枪状态,请选择其他终端充电");
|
||||||
|
}else{
|
||||||
|
String vehicleGunStatus = cacheMap.get("vehicleGunStatus").toString();
|
||||||
|
if(!"是".equals(vehicleGunStatus)){
|
||||||
|
return R.fail(1109, "请插好充电枪");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
logger.info("<<<<<<<<<<<<<<<<<<<<<<<<终端编号>>>>"+serialNumber+">>>>>>>>>>>>>"+tenantId);
|
||||||
|
|
||||||
|
logger.info("<<<<<<<<<<<<<<<<<<<<<<<<终端编号>>>>>>>>>>>>>>>>");
|
||||||
|
//余额
|
||||||
|
String balance = new BigDecimal(userMessage.get("balance").toString()).multiply(new BigDecimal(100)).toString();
|
||||||
|
//获取桩信息
|
||||||
|
Map<String, Object> xhpcChargingPileById =xhpcChargeOrderMapper.getXhpcChargingPileById(xhpcTerminal.getChargingPileId(),tenantId);
|
||||||
|
//启动充电
|
||||||
|
StartChargingData startChargingData = new StartChargingData();
|
||||||
|
//订单流水号 终端号+年月日时分秒+自增4位 共32位
|
||||||
|
String orderNo = genOrder(serialNumber);
|
||||||
|
|
||||||
|
startChargingData.setOrderNo(orderNo);
|
||||||
|
if(userMessage.get("phone") !=null){
|
||||||
|
startChargingData.setTel(userMessage.get("phone").toString());
|
||||||
|
}
|
||||||
|
startChargingData.setPileNo(xhpcTerminal.getPileSerialNumber());
|
||||||
|
startChargingData.setGunId(xhpcTerminal.getSerialNumber().substring(14));
|
||||||
|
startChargingData.setBalance(Double.valueOf(balance).intValue());
|
||||||
|
if(xhpcChargingPileById.get("communicationProtocolVersion")!=null && !"".equals(xhpcChargingPileById.get("communicationProtocolVersion").toString())){
|
||||||
|
startChargingData.setVersion(xhpcChargingPileById.get("communicationProtocolVersion").toString());
|
||||||
|
}else{
|
||||||
|
startChargingData.setVersion("0A");
|
||||||
|
}
|
||||||
|
//用户、桩、平台(最小的)
|
||||||
|
int number =0;
|
||||||
|
if(!"".equals(userMessage.get("socUser")) && userMessage.get("socUser") !=null && userMessage.get("socProtect") !=null && !"0".equals(userMessage.get("socProtect").toString())){
|
||||||
|
number =Integer.parseInt(userMessage.get("socUser").toString());
|
||||||
|
}
|
||||||
|
//平台
|
||||||
|
String soc = redisService.getCacheObject("global:"+tenantId+":SOC");
|
||||||
|
if(!"".equals(soc) && soc!=null){
|
||||||
|
if(number!=0){
|
||||||
|
if(Integer.parseInt(soc)-number<0){
|
||||||
|
number=Integer.parseInt(soc);
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
number=Integer.parseInt(soc);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Map<String, Object> operatorMessage = xhpcChargeOrderMapper.getOperatorMessage(xhpcTerminal.getChargingStationId());
|
||||||
|
if(operatorMessage !=null && operatorMessage.get("soc") !=null && !"".equals(operatorMessage.get("soc"))){
|
||||||
|
if(number!=0){
|
||||||
|
if(Integer.parseInt(operatorMessage.get("soc").toString())-number<0){
|
||||||
|
number=Integer.parseInt(operatorMessage.get("soc").toString());
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
number=Integer.parseInt(operatorMessage.get("soc").toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(number !=0){
|
||||||
|
startChargingData.setSoc(number);
|
||||||
|
}
|
||||||
|
logger.info("<<<<<<<<<<<<<<<<<<<<<<<<number>>>>>>>>>>>>>>>>>:"+number);
|
||||||
|
logger.info("<<<<<<<<<<<<<<<<<<<<<<<<Soc>>>>>>>>>>>>>>>>>:"+startChargingData.getSoc());
|
||||||
|
//创建充电订单(充电启动soc初始值,结束是获取,并修改状态)
|
||||||
|
XhpcChargeOrder xhpcChargeOrder = new XhpcChargeOrder();
|
||||||
|
xhpcChargeOrder.setChargingStationId(xhpcTerminal.getChargingStationId());
|
||||||
|
xhpcChargeOrder.setUserId(userId);
|
||||||
|
xhpcChargeOrder.setTerminalId(xhpcTerminal.getTerminalId());
|
||||||
|
xhpcChargeOrder.setGunId(xhpcTerminal.getSerialNumber());
|
||||||
|
xhpcChargeOrder.setSerialNumber(orderNo);
|
||||||
|
xhpcChargeOrder.setSource(userType);
|
||||||
|
xhpcChargeOrder.setStatus(-1);
|
||||||
|
xhpcChargeOrder.setTenantId(tenantId);
|
||||||
|
if (xhpcChargingPileById != null && xhpcChargingPileById.get("power") != null) {
|
||||||
|
xhpcChargeOrder.setPower(xhpcChargingPileById.get("power").toString());
|
||||||
|
}
|
||||||
|
xhpcChargeOrder.setChargingMode("VIN码");
|
||||||
|
xhpcChargeOrder.setCreateTime(Calendar.getInstance().getTime());
|
||||||
|
xhpcChargeOrder.setType("91");
|
||||||
|
xhpcChargeOrderMapper.addXhpcChargeOrder(xhpcChargeOrder);
|
||||||
|
|
||||||
|
executorService.execute(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
R r1 = powerPileService.startCharging(startChargingData);
|
||||||
|
logger.info("<<<<<<<<<<<<<<<<<<<<<<<<充电返回>>>>>>>>>>>>>>>>>");
|
||||||
|
logger.info("<<<<<<<<<<<<<<<<<<<<<<<<" + r1.getCode() + ">>>>>>>>>>>>>>>>>");
|
||||||
|
logger.info("<<<<<<<<<<<<<<<<<<<<<<<<" + r1.getMsg() + ">>>>>>>>>>>>>>>>>");
|
||||||
|
logger.info("<<<<<<<<<<<<<<<<<<<<<<<<" + r1.getData() + ">>>>>>>>>>>>>>>>>");
|
||||||
|
if(r1.getCode() == 200){
|
||||||
|
try{
|
||||||
|
xhpcChargeOrder.setRateModelId(Long.valueOf(r1.getData().toString()));
|
||||||
|
xhpcChargeOrderMapper.updateXhpcChargeOrder(xhpcChargeOrder);
|
||||||
|
//插一帧实时数据
|
||||||
|
extracted(xhpcChargeOrder);
|
||||||
|
}catch (Exception e){
|
||||||
|
e.printStackTrace();
|
||||||
|
logger.error("update order[{}] failed.", orderNo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
logger.info("<<<<<<<<<1111<<<<<<<<<<<<<<<C端订单号>>>>>>>>>>>>>>>>>:" + orderNo+"用户id:"+userId);
|
||||||
|
logger.info("<<<<<<<<<2222<<<<<<<<<<<<<<<C端订单号>>>>>>>>>>>>>>>>>:" + orderNo+"用户id:"+userId);
|
||||||
|
logger.info("<<<<<<<<<3333<<<<<<<<<<<<<<<C端订单号>>>>>>>>>>>>>>>>>:" + orderNo+"用户id:"+userId);
|
||||||
|
logger.info("<<<<<<<<<4444<<<<<<<<<<<<<<<C端订单号>>>>>>>>>>>>>>>>>:" + orderNo+"用户id:"+userId);
|
||||||
|
return R.ok();
|
||||||
|
}catch (Exception e){
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return R.fail(Constants.INTERNAL_ERROR);
|
||||||
|
}
|
||||||
|
|
||||||
public static boolean isValidDate(String str) {
|
public static boolean isValidDate(String str) {
|
||||||
try {
|
try {
|
||||||
if (0 != str.length()) {
|
if (0 != str.length()) {
|
||||||
|
|||||||
@ -1426,13 +1426,22 @@
|
|||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="getChargingStationEmptyOrder" resultType="map">
|
<select id="getChargingStationEmptyOrder" resultType="map">
|
||||||
|
|
||||||
SELECT
|
SELECT
|
||||||
|
xcs.`name` name,
|
||||||
|
IFNULL(us.totalOrder,0) totalOrder,
|
||||||
|
IFNULL(us.emptyorder,0) emptyorder,
|
||||||
|
IFNULL(us.emptyOrderRate,0) emptyOrderRate
|
||||||
|
from xhpc_charging_station xcs
|
||||||
|
LEFT JOIN(
|
||||||
|
SELECT
|
||||||
|
xcs.charging_station_id,
|
||||||
COUNT(xh.history_order_id) totalOrder,
|
COUNT(xh.history_order_id) totalOrder,
|
||||||
xcs.`name` name,
|
xcs.`name` name,
|
||||||
IFNULL(ut.empty,0) emptyorder,
|
IFNULL(ut.empty,0) emptyorder,
|
||||||
concat(format(ifnull(empty/COUNT(xh.history_order_id)*100,0), 2),'%') emptyOrderRate
|
concat(format(ifnull(empty/COUNT(xh.history_order_id)*100,0), 2),'%') emptyOrderRate
|
||||||
FROM `xhpc_history_order` as xh
|
FROM xhpc_charging_station xcs
|
||||||
LEFT JOIN xhpc_charging_station xcs on xcs.charging_station_id =xh.charging_station_id
|
LEFT JOIN xhpc_history_order xh on xcs.charging_station_id =xh.charging_station_id
|
||||||
LEFT join (SELECT COUNT(xh.history_order_id) empty,xh.charging_station_id
|
LEFT join (SELECT COUNT(xh.history_order_id) empty,xh.charging_station_id
|
||||||
FROM `xhpc_history_order` as xh
|
FROM `xhpc_history_order` as xh
|
||||||
where xh.end_time >=#{beginOfDay} and xh.end_time <= #{endOfDay}
|
where xh.end_time >=#{beginOfDay} and xh.end_time <= #{endOfDay}
|
||||||
@ -1460,7 +1469,8 @@
|
|||||||
<if test="status==3">
|
<if test="status==3">
|
||||||
and find_in_set (xh.charging_station_id,(select station_ids from xhpc_work_user where work_user_id=#{logOperatorId}))
|
and find_in_set (xh.charging_station_id,(select station_ids from xhpc_work_user where work_user_id=#{logOperatorId}))
|
||||||
</if>
|
</if>
|
||||||
GROUP BY xh.charging_station_id
|
GROUP BY xcs.charging_station_id) us on us.charging_station_id = xcs.charging_station_id
|
||||||
|
GROUP BY xcs.charging_station_id
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="getTerminalEmptyOrder" resultType="map">
|
<select id="getTerminalEmptyOrder" resultType="map">
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user