未启动的三方订单记录
This commit is contained in:
parent
a420cdc845
commit
2cdf2498be
@ -8,11 +8,10 @@ import com.xhpc.evcs.dto.CommonRequest;
|
|||||||
import com.xhpc.evcs.dto.CommonResponse;
|
import com.xhpc.evcs.dto.CommonResponse;
|
||||||
import com.xhpc.evcs.dto.EquipChargeStatus;
|
import com.xhpc.evcs.dto.EquipChargeStatus;
|
||||||
import com.xhpc.evcs.encryption.EvcsConst;
|
import com.xhpc.evcs.encryption.EvcsConst;
|
||||||
import com.xhpc.evcs.http.ServerInternalException;
|
|
||||||
import com.xhpc.evcs.jpa.OrderMappingRepository;
|
import com.xhpc.evcs.jpa.OrderMappingRepository;
|
||||||
import com.xhpc.evcs.jpa.XhpcHistoryOrderRepository;
|
import com.xhpc.evcs.jpa.XhpcHistoryOrderRepository;
|
||||||
import com.xhpc.evcs.utils.JSONUtil;
|
import com.xhpc.evcs.utils.JSONUtil;
|
||||||
import com.xhpc.pp.utils.HexUtils;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
@ -25,6 +24,7 @@ import static com.xhpc.common.data.redis.StaticBeanUtil.REDIS;
|
|||||||
import static com.xhpc.evcs.notification.NotificationEquipChargeStatusTask.calculateEm;
|
import static com.xhpc.evcs.notification.NotificationEquipChargeStatusTask.calculateEm;
|
||||||
import static com.xhpc.evcs.utils.DateUtil.orderNo2DateStr;
|
import static com.xhpc.evcs.utils.DateUtil.orderNo2DateStr;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
@RestController()
|
@RestController()
|
||||||
public class QueryEquipChargeStatusController {
|
public class QueryEquipChargeStatusController {
|
||||||
|
|
||||||
@ -42,10 +42,14 @@ public class QueryEquipChargeStatusController {
|
|||||||
ChargeInfoRequest chargeInfoRequest = JSONUtil.readParams(data, ChargeInfoRequest.class);
|
ChargeInfoRequest chargeInfoRequest = JSONUtil.readParams(data, ChargeInfoRequest.class);
|
||||||
String startChargeSeq = chargeInfoRequest.getStartChargeSeq();
|
String startChargeSeq = chargeInfoRequest.getStartChargeSeq();
|
||||||
equipChargeStatus.setStartChargeSeq(startChargeSeq);
|
equipChargeStatus.setStartChargeSeq(startChargeSeq);
|
||||||
|
CommonResponse response = new CommonResponse();
|
||||||
//充电订单状态
|
//充电订单状态
|
||||||
EtOrderMapping etOrderMapping = orderMappingRepository.findByEvcsOrderNo(startChargeSeq).orElse(null);
|
EtOrderMapping etOrderMapping = orderMappingRepository.findByEvcsOrderNo(startChargeSeq).orElse(null);
|
||||||
if (etOrderMapping == null) {
|
if (etOrderMapping == null) {
|
||||||
throw new ServerInternalException("未查询到该订单编号数据");
|
response.setRet(EvcsConst.RET_FAIL);
|
||||||
|
response.setMsg("Order not found/started");
|
||||||
|
log.error("3rdpty order[{}] not found", startChargeSeq);
|
||||||
|
return response;
|
||||||
}
|
}
|
||||||
String internalOrderNum = etOrderMapping.getXhOrderNo();
|
String internalOrderNum = etOrderMapping.getXhOrderNo();
|
||||||
Map<String, Object> cacheOrder = REDIS.getCacheMap("order:" + internalOrderNum);
|
Map<String, Object> cacheOrder = REDIS.getCacheMap("order:" + internalOrderNum);
|
||||||
@ -94,13 +98,11 @@ public class QueryEquipChargeStatusController {
|
|||||||
}
|
}
|
||||||
equipChargeStatus.setConnectorStatus(connectorStatus);
|
equipChargeStatus.setConnectorStatus(connectorStatus);
|
||||||
//A相电流
|
//A相电流
|
||||||
String current = (String) cacheGunData.get("current");
|
Double current = (Double) cacheGunData.get("current");
|
||||||
Double currentA = HexUtils.reverseHexInt(current) / 10.0;
|
equipChargeStatus.setCurrentA(current);
|
||||||
equipChargeStatus.setCurrentA(currentA);
|
|
||||||
//A相电压
|
//A相电压
|
||||||
String voltage = (String) cacheGunData.get("voltage");
|
Double voltage = (Double) cacheGunData.get("voltage");
|
||||||
Double voltageA = HexUtils.reverseHexInt(voltage) / 10.0;
|
equipChargeStatus.setVoltageA(voltage);
|
||||||
equipChargeStatus.setVoltageA(voltageA);
|
|
||||||
//电池剩余电量
|
//电池剩余电量
|
||||||
Integer endSoc = (Integer) cacheOrder.get("endSoc");
|
Integer endSoc = (Integer) cacheOrder.get("endSoc");
|
||||||
Double soc = Double.valueOf(endSoc == null ? 0 : endSoc);
|
Double soc = Double.valueOf(endSoc == null ? 0 : endSoc);
|
||||||
@ -125,7 +127,6 @@ public class QueryEquipChargeStatusController {
|
|||||||
final Long rateModelId = REDIS.getCacheMapValue("pile:".concat(connectorId.substring(0, 14)), "rateModelId");
|
final Long rateModelId = REDIS.getCacheMapValue("pile:".concat(connectorId.substring(0, 14)), "rateModelId");
|
||||||
final CacheRateModel cacheRateModel = REDIS.getCacheObject("rateModel:" + rateModelId);
|
final CacheRateModel cacheRateModel = REDIS.getCacheObject("rateModel:" + rateModelId);
|
||||||
calculateEm(equipChargeStatus, cacheRateModel);
|
calculateEm(equipChargeStatus, cacheRateModel);
|
||||||
CommonResponse response = new CommonResponse();
|
|
||||||
response.setRet(EvcsConst.RET_SUCC);
|
response.setRet(EvcsConst.RET_SUCC);
|
||||||
response.setData(JSONUtil.toJSONString(equipChargeStatus));
|
response.setData(JSONUtil.toJSONString(equipChargeStatus));
|
||||||
response.setMsg("success");
|
response.setMsg("success");
|
||||||
|
|||||||
@ -2,7 +2,7 @@ package com.xhpc.evcs.api;
|
|||||||
|
|
||||||
import com.xhpc.common.api.PileOrderService;
|
import com.xhpc.common.api.PileOrderService;
|
||||||
import com.xhpc.common.core.domain.R;
|
import com.xhpc.common.core.domain.R;
|
||||||
import com.xhpc.evcs.domain.AuthSecretToken;
|
import com.xhpc.common.core.utils.DateUtils;
|
||||||
import com.xhpc.evcs.domain.EtOrderMapping;
|
import com.xhpc.evcs.domain.EtOrderMapping;
|
||||||
import com.xhpc.evcs.dto.CommonRequest;
|
import com.xhpc.evcs.dto.CommonRequest;
|
||||||
import com.xhpc.evcs.dto.CommonResponse;
|
import com.xhpc.evcs.dto.CommonResponse;
|
||||||
@ -11,17 +11,21 @@ import com.xhpc.evcs.dto.StartChargeResponse;
|
|||||||
import com.xhpc.evcs.encryption.EvcsConst;
|
import com.xhpc.evcs.encryption.EvcsConst;
|
||||||
import com.xhpc.evcs.jpa.AuthSecretTokenRepository;
|
import com.xhpc.evcs.jpa.AuthSecretTokenRepository;
|
||||||
import com.xhpc.evcs.jpa.OrderMappingRepository;
|
import com.xhpc.evcs.jpa.OrderMappingRepository;
|
||||||
|
import com.xhpc.evcs.jpa.XhpcHistoryOrderRepository;
|
||||||
|
import com.xhpc.evcs.jpa.XhpcTerminalRepository;
|
||||||
import com.xhpc.evcs.utils.JSONUtil;
|
import com.xhpc.evcs.utils.JSONUtil;
|
||||||
|
import com.xhpc.order.domain.XhpcHistoryOrder;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Optional;
|
|
||||||
|
|
||||||
import static com.xhpc.common.data.redis.StaticBeanUtil.REDIS;
|
import static com.xhpc.common.data.redis.StaticBeanUtil.REDIS;
|
||||||
|
import static com.xhpc.common.data.redis.StaticBeanUtil.genOrder;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
public class QueryStartChargeController {
|
public class QueryStartChargeController {
|
||||||
@ -31,6 +35,10 @@ public class QueryStartChargeController {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private OrderMappingRepository etOrderMappingRepo;
|
private OrderMappingRepository etOrderMappingRepo;
|
||||||
@Autowired
|
@Autowired
|
||||||
|
private XhpcHistoryOrderRepository xhpcHistoryOrderRepository;
|
||||||
|
@Autowired
|
||||||
|
private XhpcTerminalRepository xhpcTerminalRepository;
|
||||||
|
@Autowired
|
||||||
private PileOrderService pileOrderService;
|
private PileOrderService pileOrderService;
|
||||||
|
|
||||||
@PostMapping(value = "/v1/query_start_charge")
|
@PostMapping(value = "/v1/query_start_charge")
|
||||||
@ -40,32 +48,27 @@ public class QueryStartChargeController {
|
|||||||
StartChargeResponse startChargeResponse = new StartChargeResponse();
|
StartChargeResponse startChargeResponse = new StartChargeResponse();
|
||||||
StartChargeRequest startChargeRequest = JSONUtil.readParams(commonRequest.getData(), StartChargeRequest.class);
|
StartChargeRequest startChargeRequest = JSONUtil.readParams(commonRequest.getData(), StartChargeRequest.class);
|
||||||
String startChargeSeq = startChargeRequest.getStartChargeSeq();
|
String startChargeSeq = startChargeRequest.getStartChargeSeq();
|
||||||
String connectorID = startChargeRequest.getConnectorId();
|
String connectorId = startChargeRequest.getConnectorId();
|
||||||
String operatorId = startChargeSeq.substring(0, 9);
|
Map<String, Object> cacheGun = REDIS.getCacheMap("gun:".concat(connectorId));
|
||||||
Optional<AuthSecretToken> authSecretTokenIn =
|
|
||||||
authSecretTokenRepository.findByOperatorId3irdptyAndSecretTokenType(operatorId, "IN");
|
|
||||||
if (!authSecretTokenIn.isPresent()) {
|
|
||||||
startChargeResponse.setSuccStat(1);
|
|
||||||
startChargeResponse.setFailReason(3);
|
|
||||||
startChargeResponse.setStartChargeSeqStat(5);
|
|
||||||
resp.setMsg("This 3rd has no token");
|
|
||||||
} else {
|
|
||||||
Map<String, Object> cacheGun = REDIS.getCacheMap("gun:".concat(connectorID));
|
|
||||||
String terminalStatus = (String) cacheGun.get("vehicleGunStatus");
|
String terminalStatus = (String) cacheGun.get("vehicleGunStatus");
|
||||||
String status = (String) cacheGun.get("status");
|
String status = (String) cacheGun.get("status");
|
||||||
|
EtOrderMapping etOrderMapping = new EtOrderMapping();
|
||||||
|
etOrderMapping.setEvcsOrderNo(startChargeSeq);
|
||||||
if (!"空闲".equals(status)) {
|
if (!"空闲".equals(status)) {
|
||||||
resp.setMsg("终端状态异常:[".concat(status == null ? "未注册" : status).concat("]"));
|
resp.setMsg("终端状态异常:[".concat(status == null ? "未注册" : status).concat("]"));
|
||||||
resp.setRet("500");
|
resp.setRet("500");
|
||||||
|
emptyHorder(startChargeSeq, connectorId, etOrderMapping);
|
||||||
} else if ("否".equals(terminalStatus)) {
|
} else if ("否".equals(terminalStatus)) {
|
||||||
resp.setMsg("未插枪");
|
resp.setMsg("未插枪");
|
||||||
resp.setRet("500");
|
resp.setRet("500");
|
||||||
|
emptyHorder(startChargeSeq, connectorId, etOrderMapping);
|
||||||
} else {
|
} else {
|
||||||
String plateNum = startChargeRequest.getPlateNum();
|
String plateNum = startChargeRequest.getPlateNum();
|
||||||
plateNum = plateNum == null ? startChargeRequest.getPlateNum2() : plateNum;
|
plateNum = plateNum == null ? startChargeRequest.getPlateNum2() : plateNum;
|
||||||
R res = pileOrderService.pileStartUpBy3rd(startChargeSeq, startChargeRequest.getDriverId(),
|
R res = pileOrderService.pileStartUpBy3rd(startChargeSeq, startChargeRequest.getDriverId(),
|
||||||
startChargeRequest.getChargingAmt(), plateNum, -1, connectorID);
|
startChargeRequest.getChargingAmt(), plateNum, -1, connectorId);
|
||||||
startChargeResponse.setStartChargeSeq(startChargeSeq);
|
startChargeResponse.setStartChargeSeq(startChargeSeq);
|
||||||
startChargeResponse.setConnectorID(connectorID);
|
startChargeResponse.setConnectorID(connectorId);
|
||||||
if (res.getCode() != 200) {
|
if (res.getCode() != 200) {
|
||||||
if (res.getCode() != 500) {
|
if (res.getCode() != 500) {
|
||||||
startChargeResponse.setFailReason(res.getCode());
|
startChargeResponse.setFailReason(res.getCode());
|
||||||
@ -75,29 +78,22 @@ public class QueryStartChargeController {
|
|||||||
startChargeResponse.setSuccStat(1);
|
startChargeResponse.setSuccStat(1);
|
||||||
startChargeResponse.setStartChargeSeqStat(4);
|
startChargeResponse.setStartChargeSeqStat(4);
|
||||||
} else {
|
} else {
|
||||||
Map<String, Object> etOrderData = (Map<String, Object>) res.getData();
|
|
||||||
EtOrderMapping etOrderMapping = new EtOrderMapping();
|
|
||||||
etOrderMapping.setEvcsOrderNo(startChargeSeq);
|
|
||||||
etOrderMapping.setXhOrderNo(String.valueOf(etOrderData.get("orderNo")));
|
|
||||||
etOrderMappingRepo.save(etOrderMapping);
|
|
||||||
startChargeResponse.setStartChargeSeqStat(1);
|
startChargeResponse.setStartChargeSeqStat(1);
|
||||||
startChargeResponse.setSuccStat(0);
|
startChargeResponse.setSuccStat(0);
|
||||||
startChargeResponse.setFailReason(0);
|
startChargeResponse.setFailReason(0);
|
||||||
//insert a gunStatusData to redis
|
}
|
||||||
|
Map<String, Object> etOrderData = (Map<String, Object>) res.getData();
|
||||||
|
etOrderMapping.setXhOrderNo(String.valueOf(etOrderData.get("orderNo")));
|
||||||
Map<String, Object> pushOrder = new HashMap<>();
|
Map<String, Object> pushOrder = new HashMap<>();
|
||||||
//1 means starting.
|
|
||||||
pushOrder.put("startChargeSeqStat", 1);
|
pushOrder.put("startChargeSeqStat", 1);
|
||||||
String orderNo = String.valueOf(etOrderData.get("orderNo"));
|
String orderNo = String.valueOf(etOrderData.get("orderNo"));
|
||||||
pushOrder.put("internetSerialNumber", startChargeRequest.getStartChargeSeq());
|
pushOrder.put("internetSerialNumber", startChargeRequest.getStartChargeSeq());
|
||||||
pushOrder.put("connectorID", connectorID);
|
pushOrder.put("connectorID", connectorId);
|
||||||
pushOrder.put("startTime", etOrderData.get("startTime"));
|
pushOrder.put("startTime", etOrderData.get("startTime"));
|
||||||
//0 means needs to be notified.
|
|
||||||
pushOrder.put("startChargeNotificationStat", 0);
|
pushOrder.put("startChargeNotificationStat", 0);
|
||||||
//0 means needs to be notified.
|
|
||||||
pushOrder.put("chargeOrderInfoNotificationStat", 0);
|
pushOrder.put("chargeOrderInfoNotificationStat", 0);
|
||||||
pushOrder.put("operatorId3rdpty", startChargeSeq.substring(0, 9));
|
pushOrder.put("operatorId3rdpty", startChargeSeq.substring(0, 9));
|
||||||
REDIS.setCacheMap("pushOrder:".concat(orderNo), pushOrder);
|
REDIS.setCacheMap("pushOrder:".concat(orderNo), pushOrder);
|
||||||
}
|
|
||||||
if (res.getCode() != 200) {
|
if (res.getCode() != 200) {
|
||||||
resp.setRet(EvcsConst.RET_FAIL);
|
resp.setRet(EvcsConst.RET_FAIL);
|
||||||
} else {
|
} else {
|
||||||
@ -105,8 +101,28 @@ public class QueryStartChargeController {
|
|||||||
}
|
}
|
||||||
resp.setMsg(res.getMsg());
|
resp.setMsg(res.getMsg());
|
||||||
}
|
}
|
||||||
}
|
etOrderMappingRepo.save(etOrderMapping);
|
||||||
resp.setData(JSONUtil.toJSONString(startChargeResponse));
|
resp.setData(JSONUtil.toJSONString(startChargeResponse));
|
||||||
return resp;
|
return resp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void emptyHorder(String startChargeSeq, String connectorId, EtOrderMapping etOrderMapping) {
|
||||||
|
|
||||||
|
XhpcHistoryOrder emptyHorder = new XhpcHistoryOrder();
|
||||||
|
Date now = DateUtils.getNowDate();
|
||||||
|
emptyHorder.setStartTime(now);
|
||||||
|
emptyHorder.setEndTime(now);
|
||||||
|
emptyHorder.setCreateTime(now);
|
||||||
|
emptyHorder.setUpdateTime(now);
|
||||||
|
String sn = genOrder(connectorId);
|
||||||
|
etOrderMapping.setXhOrderNo(sn);
|
||||||
|
emptyHorder.setSerialNumber(sn);
|
||||||
|
emptyHorder.setOperatorId3rdptyEvcs(startChargeSeq.substring(0, 9));
|
||||||
|
emptyHorder.setType(1);
|
||||||
|
emptyHorder.setChargingStationId(REDIS.getCacheMapValue("pile:".concat(connectorId.substring(0, 14)), "stationId"));
|
||||||
|
emptyHorder.setTerminalId(xhpcTerminalRepository.findOneBySerialNumber(connectorId).get().getTerminalId());
|
||||||
|
xhpcHistoryOrderRepository.save(emptyHorder);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -37,8 +37,8 @@ import static com.xhpc.evcs.config.EvcsFilter.encryptReqOut;
|
|||||||
@Slf4j
|
@Slf4j
|
||||||
public class CoreDispatcher {
|
public class CoreDispatcher {
|
||||||
|
|
||||||
@Value("${xhpc.evcs.oklog:false}")
|
@Value("${xhpc.evcs.oklog2:false}")
|
||||||
private boolean oklog;
|
private boolean oklog2;
|
||||||
@Autowired
|
@Autowired
|
||||||
private AuthSecretTokenRepository authSecretTokenRepository;
|
private AuthSecretTokenRepository authSecretTokenRepository;
|
||||||
public static final okhttp3.MediaType JSON = okhttp3.MediaType.parse("application/json; charset=utf-8");
|
public static final okhttp3.MediaType JSON = okhttp3.MediaType.parse("application/json; charset=utf-8");
|
||||||
@ -52,7 +52,7 @@ public class CoreDispatcher {
|
|||||||
}
|
}
|
||||||
okhttp3.RequestBody body = null;
|
okhttp3.RequestBody body = null;
|
||||||
OkHttpClient.Builder builder = new OkHttpClient.Builder();
|
OkHttpClient.Builder builder = new OkHttpClient.Builder();
|
||||||
if (oklog) {
|
if (oklog2) {
|
||||||
HttpLoggingInterceptor logging = new HttpLoggingInterceptor();
|
HttpLoggingInterceptor logging = new HttpLoggingInterceptor();
|
||||||
logging.setLevel(HttpLoggingInterceptor.Level.BODY);
|
logging.setLevel(HttpLoggingInterceptor.Level.BODY);
|
||||||
builder.addInterceptor(logging);
|
builder.addInterceptor(logging);
|
||||||
|
|||||||
@ -11,7 +11,6 @@ import com.xhpc.evcs.jpa.OrderMappingRepository;
|
|||||||
import com.xhpc.evcs.jpa.StatisticTimeIntervalRepository;
|
import com.xhpc.evcs.jpa.StatisticTimeIntervalRepository;
|
||||||
import com.xhpc.evcs.utils.DateUtil;
|
import com.xhpc.evcs.utils.DateUtil;
|
||||||
import com.xhpc.evcs.utils.JSONUtil;
|
import com.xhpc.evcs.utils.JSONUtil;
|
||||||
import com.xhpc.pp.utils.HexUtils;
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@ -69,10 +68,8 @@ public class NotificationEquipChargeStatusTask extends CoreDispatcher {
|
|||||||
equipChargeStatus.setStartChargeSeqStat(2);
|
equipChargeStatus.setStartChargeSeqStat(2);
|
||||||
equipChargeStatus.setConnectorID(orderkey.substring(6, 22));
|
equipChargeStatus.setConnectorID(orderkey.substring(6, 22));
|
||||||
equipChargeStatus.setConnectorStatus(3);
|
equipChargeStatus.setConnectorStatus(3);
|
||||||
String current = REDIS.getCacheMapValue(gunkey, "current");
|
equipChargeStatus.setCurrentA(REDIS.getCacheMapValue(gunkey, "current"));
|
||||||
equipChargeStatus.setCurrentA(HexUtils.reverseHexInt(current == null ? "9600" : current) / 10.0);
|
equipChargeStatus.setVoltageA(REDIS.getCacheMapValue(gunkey, "voltage"));
|
||||||
String voltage = REDIS.getCacheMapValue(gunkey, "voltage");
|
|
||||||
equipChargeStatus.setVoltageA(HexUtils.reverseHexInt(voltage == null ? "D80E" : voltage) / 10.0);
|
|
||||||
Integer soc = REDIS.getCacheMapValue(orderkey, "endSoc");
|
Integer soc = REDIS.getCacheMapValue(orderkey, "endSoc");
|
||||||
equipChargeStatus.setSoc(soc == null ? 0.0 : Double.valueOf(soc.toString()));
|
equipChargeStatus.setSoc(soc == null ? 0.0 : Double.valueOf(soc.toString()));
|
||||||
CacheRealtimeData lord = REDIS.getCacheObject(orderkey.concat(".lord"));
|
CacheRealtimeData lord = REDIS.getCacheObject(orderkey.concat(".lord"));
|
||||||
|
|||||||
@ -59,7 +59,7 @@
|
|||||||
</appender>
|
</appender>
|
||||||
|
|
||||||
<!-- 系统模块日志级别控制 -->
|
<!-- 系统模块日志级别控制 -->
|
||||||
<logger name="com.xhpc" level="debug"/>
|
<logger name="com.xhpc" level="info"/>
|
||||||
<!-- Spring日志级别控制 -->
|
<!-- Spring日志级别控制 -->
|
||||||
<logger name="org.springframework" level="info"/>
|
<logger name="org.springframework" level="info"/>
|
||||||
<!-- nacos -->
|
<!-- nacos -->
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
package com.xhpc.common.data.redis;
|
package com.xhpc.common.data.redis;
|
||||||
|
|
||||||
|
import cn.hutool.core.date.DateUtil;
|
||||||
import com.xhpc.common.api.PileOrderService;
|
import com.xhpc.common.api.PileOrderService;
|
||||||
import com.xhpc.common.redis.service.RedisService;
|
import com.xhpc.common.redis.service.RedisService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@ -7,6 +8,8 @@ import org.springframework.data.redis.support.atomic.RedisAtomicLong;
|
|||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import javax.annotation.PostConstruct;
|
import javax.annotation.PostConstruct;
|
||||||
|
import java.util.Calendar;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
public class StaticBeanUtil {
|
public class StaticBeanUtil {
|
||||||
@ -60,4 +63,13 @@ public class StaticBeanUtil {
|
|||||||
return upperCode;
|
return upperCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String genOrder(String terminalSerialNumber) {
|
||||||
|
|
||||||
|
Date date = Calendar.getInstance().getTime();
|
||||||
|
String format = DateUtil.format(date, "yyMMddHHmmss");
|
||||||
|
//自增
|
||||||
|
String orderNo = terminalSerialNumber + format + seqDec("gun:" + terminalSerialNumber + ".seqdec");
|
||||||
|
return orderNo;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -27,6 +27,8 @@ import java.util.*;
|
|||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
import static com.xhpc.common.data.redis.StaticBeanUtil.genOrder;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author yuyang
|
* @author yuyang
|
||||||
* @date 2021/8/4 9:54
|
* @date 2021/8/4 9:54
|
||||||
@ -78,11 +80,12 @@ public class XhpcChargeOrderServiceImpl implements IXhpcChargeOrderService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
public AjaxResult startUp(Long userId, String serialNumber,Integer type) {
|
public AjaxResult startUp(Long userId, String terminalSerialNumber, Integer type) {
|
||||||
|
|
||||||
String pattern = "^([0-9]{16})";
|
String pattern = "^([0-9]{16})";
|
||||||
Pattern compile = Pattern.compile(pattern);
|
Pattern compile = Pattern.compile(pattern);
|
||||||
Matcher m = compile.matcher(serialNumber);
|
Matcher m = compile.matcher(terminalSerialNumber);
|
||||||
if (serialNumber.length()!=16 || !m.matches()) {
|
if (terminalSerialNumber.length() != 16 || !m.matches()) {
|
||||||
return AjaxResult.error(1104, "无效的终端编号");
|
return AjaxResult.error(1104, "无效的终端编号");
|
||||||
}
|
}
|
||||||
//查看充电用户金额是否大于5元
|
//查看充电用户金额是否大于5元
|
||||||
@ -108,9 +111,9 @@ public class XhpcChargeOrderServiceImpl implements IXhpcChargeOrderService {
|
|||||||
}
|
}
|
||||||
//终端状态是否空闲
|
//终端状态是否空闲
|
||||||
//是否插枪
|
//是否插枪
|
||||||
Map<String, Object> cacheMap = REDIS.getCacheMap("gun:" + serialNumber);
|
Map<String, Object> cacheMap = REDIS.getCacheMap("gun:" + terminalSerialNumber);
|
||||||
logger.info("<<<<<<<<<<<<<<<<<<<<<<<<cacheMap>>>>>>>>>>>>>>>>>");
|
logger.info("<<<<<<<<<<<<<<<<<<<<<<<<cacheMap>>>>>>>>>>>>>>>>>");
|
||||||
logger.info("<<<<<<<<<<<<<<<<<<<<<<<<cacheMap>>>>>>>>>>>>>>>>>"+serialNumber);
|
logger.info("<<<<<<<<<<<<<<<<<<<<<<<<cacheMap>>>>>>>>>>>>>>>>>" + terminalSerialNumber);
|
||||||
logger.info("<<<<<<<<<<<<<<<<<<<<<<<<cacheMap>>>>>>>>>>>>>>>>>" + cacheMap.toString());
|
logger.info("<<<<<<<<<<<<<<<<<<<<<<<<cacheMap>>>>>>>>>>>>>>>>>" + cacheMap.toString());
|
||||||
logger.info("<<<<<<<<<<<<<<<<<<<<<<<<cacheMap>>>>>>>>>>>>>>>>>");
|
logger.info("<<<<<<<<<<<<<<<<<<<<<<<<cacheMap>>>>>>>>>>>>>>>>>");
|
||||||
|
|
||||||
@ -137,7 +140,7 @@ public class XhpcChargeOrderServiceImpl implements IXhpcChargeOrderService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//终端信息
|
//终端信息
|
||||||
XhpcTerminal xhpcTerminal = xhpcChargeOrderMapper.getXhpcTerminalSerialNumber(serialNumber);
|
XhpcTerminal xhpcTerminal = xhpcChargeOrderMapper.getXhpcTerminalSerialNumber(terminalSerialNumber);
|
||||||
if (xhpcTerminal == null || xhpcTerminal.getTerminalId() == null || xhpcTerminal.getChargingPileId() == null || xhpcTerminal.getPileSerialNumber() == null) {
|
if (xhpcTerminal == null || xhpcTerminal.getTerminalId() == null || xhpcTerminal.getChargingPileId() == null || xhpcTerminal.getPileSerialNumber() == null) {
|
||||||
return AjaxResult.error(1104, "无效的终端编号");
|
return AjaxResult.error(1104, "无效的终端编号");
|
||||||
}
|
}
|
||||||
@ -152,10 +155,7 @@ public class XhpcChargeOrderServiceImpl implements IXhpcChargeOrderService {
|
|||||||
//启动充电
|
//启动充电
|
||||||
StartChargingData startChargingData = new StartChargingData();
|
StartChargingData startChargingData = new StartChargingData();
|
||||||
//订单流水号 终端号+年月日时分秒+自增4位 共32位
|
//订单流水号 终端号+年月日时分秒+自增4位 共32位
|
||||||
Date date = Calendar.getInstance().getTime();
|
String orderNo = genOrder(terminalSerialNumber);
|
||||||
String format = DateUtil.format(date, "yyMMddHHmmss");
|
|
||||||
//自增
|
|
||||||
String orderNo = serialNumber + format + StaticBeanUtil.seqDec("gun:" + serialNumber + ".seqdec");
|
|
||||||
|
|
||||||
startChargingData.setOrderNo(orderNo);
|
startChargingData.setOrderNo(orderNo);
|
||||||
if(userMessage.get("phone") !=null){
|
if(userMessage.get("phone") !=null){
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user