working
This commit is contained in:
parent
782b648f57
commit
c51cc41e22
@ -0,0 +1,33 @@
|
||||
package com.xhpc.evcs.dto;
|
||||
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonAutoDetect;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.ANY, getterVisibility = JsonAutoDetect.Visibility.NONE,
|
||||
setterVisibility = JsonAutoDetect.Visibility.NONE, creatorVisibility = JsonAutoDetect.Visibility.NONE)
|
||||
public class StartChargeRequest {
|
||||
|
||||
@JsonProperty("StartChargeSeq")
|
||||
String startChargeSeq;
|
||||
|
||||
@JsonProperty("ConnectorId")
|
||||
String connectorId;
|
||||
|
||||
@JsonProperty("QRCode")
|
||||
String qRCode;
|
||||
|
||||
@JsonProperty("PlateNum")
|
||||
String plateNum;
|
||||
|
||||
@JsonProperty("ChargingAmt")
|
||||
Integer chargingAmt;
|
||||
|
||||
@JsonProperty("driverId")
|
||||
String driverId;
|
||||
|
||||
}
|
||||
@ -0,0 +1,29 @@
|
||||
package com.xhpc.evcs.dto;
|
||||
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonAutoDetect;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.ANY, getterVisibility = JsonAutoDetect.Visibility.NONE,
|
||||
setterVisibility = JsonAutoDetect.Visibility.NONE, creatorVisibility = JsonAutoDetect.Visibility.NONE)
|
||||
public class StartChargeResponse {
|
||||
|
||||
@JsonProperty("StartChargeSeq")
|
||||
String startChargeSeq;
|
||||
|
||||
@JsonProperty("StartChargeStat")
|
||||
Integer startChargeSeqStat;
|
||||
|
||||
@JsonProperty("connectorID")
|
||||
String connectorID;
|
||||
|
||||
@JsonProperty("SuccStat")
|
||||
Integer succStat;
|
||||
|
||||
@JsonProperty("FailReason")
|
||||
Integer failReason;
|
||||
}
|
||||
@ -57,7 +57,7 @@ public class CoreDispatcher {
|
||||
.readTimeout(10, TimeUnit.SECONDS)
|
||||
.writeTimeout(10, TimeUnit.SECONDS);
|
||||
Calendar cal = Calendar.getInstance();
|
||||
String bearer = null;
|
||||
String bearerToken = null;
|
||||
AuthSecretToken authSecretTokenOut = getAuthSecretTokenOut(operatorId3irdpty, operatorID);
|
||||
if (authSecretTokenOut == null) {
|
||||
String error = String.format("secret/token not found for [%s/%s](opId3pt/opId)", operatorId3irdpty, operatorID);
|
||||
@ -67,7 +67,7 @@ public class CoreDispatcher {
|
||||
if (object.getClass().getSimpleName().equals("CommonRequest")) {
|
||||
CommonRequest commonRequest = (CommonRequest) object;
|
||||
Date tokenExpiry = authSecretTokenOut.getTokenExpiry();
|
||||
String oData = commonRequest.getData();
|
||||
String originalData = commonRequest.getData();
|
||||
String tData;
|
||||
if (tokenExpiry == null || tokenExpiry.before(cal.getTime())) {
|
||||
TokenRequest tokenRequest = new TokenRequest();
|
||||
@ -95,8 +95,8 @@ public class CoreDispatcher {
|
||||
authSecretTokenRepository.save(authSecretTokenOut);
|
||||
}
|
||||
}
|
||||
bearer = authSecretTokenOut.getToken();
|
||||
commonRequest.setData(oData);
|
||||
bearerToken = authSecretTokenOut.getToken();
|
||||
commonRequest.setData(originalData);
|
||||
tData = JSONUtil.toJSONString(commonRequest);
|
||||
if (authSecretTokenOut.isEncrypt()) {
|
||||
tData = encryptReqOut(authSecretTokenOut.getDataSecret(), authSecretTokenOut.getDataSecretIV(),
|
||||
@ -111,7 +111,7 @@ public class CoreDispatcher {
|
||||
}
|
||||
final Request.Builder req = new Request.Builder()
|
||||
.url(authSecretTokenOut.getUrlPrefix() + url)
|
||||
.header("Authorization", "Bearer " + bearer);
|
||||
.header("Authorization", "Bearer " + bearerToken);
|
||||
Request request;
|
||||
assert body != null;
|
||||
// if (body==null) request = req.get().build();
|
||||
|
||||
@ -0,0 +1,69 @@
|
||||
package com.xhpc.evcs.api;
|
||||
|
||||
import com.xhpc.common.api.PileOrderService;
|
||||
import com.xhpc.common.core.domain.R;
|
||||
import com.xhpc.evcs.domain.AuthSecretToken;
|
||||
import com.xhpc.evcs.dto.CommonResponse;
|
||||
import com.xhpc.evcs.dto.StartChargeRequest;
|
||||
import com.xhpc.evcs.dto.StartChargeResponse;
|
||||
import com.xhpc.evcs.jpa.AuthSecretTokenRepository;
|
||||
import com.xhpc.evcs.utils.JSONUtil;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
import static com.xhpc.common.data.redis.StaticBeanUtil.REDIS;
|
||||
|
||||
@Controller
|
||||
public class QueryStartChargeController {
|
||||
|
||||
@Autowired
|
||||
AuthSecretTokenRepository authSecretTokenRepository;
|
||||
@Autowired
|
||||
private PileOrderService pileOrderService;
|
||||
|
||||
@PostMapping(value = "/v1/query_start_charge")
|
||||
public CommonResponse queryStartCharge(@RequestBody StartChargeRequest startChargeRequest) throws Exception {
|
||||
|
||||
CommonResponse resp = new CommonResponse();
|
||||
StartChargeResponse startChargeResponse = new StartChargeResponse();
|
||||
String startChargeSeq = startChargeRequest.getStartChargeSeq();
|
||||
String connectorID = startChargeRequest.getConnectorId();
|
||||
String operatorId = startChargeSeq.substring(0, 9);
|
||||
//Checking the operator whether it has its token.
|
||||
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 {
|
||||
//todo invoke a order making interface(finished);
|
||||
R res = pileOrderService.pileStartUpBy3rd(startChargeSeq, startChargeRequest.getDriverId(), startChargeRequest.getChargingAmt(), startChargeRequest.getPlateNum(), 0, connectorID);
|
||||
startChargeResponse.setStartChargeSeq(startChargeSeq);
|
||||
startChargeResponse.setConnectorID(connectorID);
|
||||
if (res.getCode() != 200) {
|
||||
startChargeResponse.setSuccStat(1);
|
||||
startChargeResponse.setFailReason(0);
|
||||
startChargeResponse.setStartChargeSeqStat(5);
|
||||
} else {
|
||||
startChargeResponse.setStartChargeSeqStat(2);
|
||||
startChargeResponse.setSuccStat(0);
|
||||
startChargeResponse.setFailReason(0);
|
||||
//insert a gunStatusData to redis
|
||||
Map<String, Object> gunStatus = new HashMap<>();
|
||||
//0 means charging.
|
||||
gunStatus.put("status", 0);
|
||||
gunStatus.put("orderNo", (String) res.getData());
|
||||
REDIS.setCacheMap("gunStatus:", gunStatus);
|
||||
}
|
||||
}
|
||||
resp.setData(JSONUtil.toJSONString(startChargeResponse));
|
||||
return resp;
|
||||
}
|
||||
}
|
||||
@ -94,14 +94,14 @@ public class NotificationChargeOrderInfo4BonusTask extends CoreDispatcher {
|
||||
static EtOrderMapping saveOrderMapping(String xhOrderNo, String internetSerialNumber,
|
||||
OrderMappingRepository orderMappingRepository) {
|
||||
|
||||
EtOrderMapping om = new EtOrderMapping();
|
||||
om.setXhOrderNo(xhOrderNo);
|
||||
EtOrderMapping etOrderMapping;
|
||||
if (internetSerialNumber != null) {
|
||||
etOrderMapping = new EtOrderMapping();
|
||||
etOrderMapping.setXhOrderNo(xhOrderNo);
|
||||
etOrderMapping.setEvcsOrderNo(internetSerialNumber);
|
||||
} else {
|
||||
EtOrderMapping om = new EtOrderMapping();
|
||||
om.setXhOrderNo(xhOrderNo);
|
||||
Example<EtOrderMapping> example = Example.of(om);
|
||||
etOrderMapping = orderMappingRepository.findOne(example).orElse(null);
|
||||
if (etOrderMapping == null) {
|
||||
|
||||
@ -0,0 +1,13 @@
|
||||
package com.xhpc.evcs.notification;
|
||||
|
||||
import com.xhpc.evcs.api.CoreDispatcher;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
|
||||
@Component
|
||||
public class NotificationStartChargeResultTask extends CoreDispatcher {
|
||||
|
||||
//todo invoke the pile service, and then waiting for its response to judge whether the
|
||||
//todo pile is running actually.
|
||||
|
||||
}
|
||||
@ -96,7 +96,6 @@ public class NotificationStationStatusTask extends CoreDispatcher {
|
||||
throw new RuntimeException(String.format("push CD notification connector[%s] failed: %s",
|
||||
connectorStatusInfo.getConnectorID(), responseBody));
|
||||
}
|
||||
//todo if token is invalid then retry?
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
@ -58,11 +58,14 @@ public interface PileOrderService {
|
||||
|
||||
/**
|
||||
* 订单异常回调接口
|
||||
* @param orderNo 订单号
|
||||
*
|
||||
* @param orderNo 订单号
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/chargeOrder/abnormalOrder")
|
||||
R abnormalOrder(@RequestParam(value = "orderNo") String orderNo);
|
||||
|
||||
|
||||
@GetMapping(value = "/chargeOrder/pileStartUpBy3rd")
|
||||
R pileStartUpBy3rd(@RequestParam(value = "internetSerialNumber") String internetSerialNumber, @RequestParam(value = "driverId") String driverId, @RequestParam(value = "chargingAmt") Integer chargingAmt, @RequestParam(value = "plateNum", required = false) String plateNum, @RequestParam(value = "status") Integer status, @RequestParam(value = "connectorId") String connectorId);
|
||||
}
|
||||
|
||||
@ -50,6 +50,12 @@ public class PileOrderFallbackFactory implements FallbackFactory<PileOrderServic
|
||||
|
||||
return R.fail("订单异常回调接口失败:" + cause.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public R pileStartUpBy3rd(String internetSerialNumber, String driverId, Integer chargingAmt, String plateNum, Integer status, String connectorId) {
|
||||
|
||||
return R.fail("通过第三方创建充电订单失败:" + cause.getMessage());
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@ -18,6 +18,7 @@ public class StartChargingData {
|
||||
private String version = "0A"; //协议版本号(0A)
|
||||
private Integer soc;
|
||||
|
||||
|
||||
public String getOrderNo() {
|
||||
|
||||
return orderNo;
|
||||
|
||||
@ -161,6 +161,4 @@ public class XhpcChargeOrderController extends BaseController {
|
||||
logger.info("<<<<<<<<<<发送数据<<<<<<<<<<<<<<"+ json.toString()+">>>>>>>>>>>>>>>>>");
|
||||
logger.info("<<<<<<<<<<发送时间<<<<<<<<<<<<<<"+ DateUtil.format(Calendar.getInstance().getTime(), "yyyy-MM-dd HH:mm:ss")+">>>>>>>>>>>>>>>>>");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -1,10 +1,8 @@
|
||||
package com.xhpc.order.api;
|
||||
|
||||
import cn.hutool.core.date.DateTime;
|
||||
import cn.hutool.core.date.DateUnit;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.xhpc.common.api.SmsService;
|
||||
import com.xhpc.common.api.WebSocketService;
|
||||
import com.xhpc.common.core.domain.R;
|
||||
import com.xhpc.common.core.web.controller.BaseController;
|
||||
@ -17,7 +15,6 @@ import com.xhpc.order.domain.XhpcHistoryOrder;
|
||||
import com.xhpc.order.service.IXhpcChargeOrderService;
|
||||
import com.xhpc.order.service.IXhpcHistoryOrderService;
|
||||
import com.xhpc.order.service.IXhpcRealTimeOrderService;
|
||||
import org.checkerframework.checker.units.qual.A;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@ -28,10 +25,10 @@ import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@RestController
|
||||
public class XhpcPileOrderController extends BaseController {
|
||||
@ -445,11 +442,8 @@ public class XhpcPileOrderController extends BaseController {
|
||||
//
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
String stw ="91510105MA6DFCTD5U";
|
||||
System.out.println(stw.substring(8, stw.length() - 1));
|
||||
}
|
||||
|
||||
@GetMapping(value = "/chargeOrder/pileStartUpBy3rd")
|
||||
public R pileStartUpBy3rd(@RequestParam(value = "internetSerialNumber") String internetSerialNumber, @RequestParam(value = "driverId") String driverId, @RequestParam(value = "chargingAmt") Integer chargingAmt, @RequestParam(value = "plateNum", required = false) String plateNum, @RequestParam(value = "status") Integer status, @RequestParam(value = "connectorId") String connectorId) {
|
||||
return xhpcChargeOrderService.startUpBy3rd(internetSerialNumber, driverId, chargingAmt, plateNum, status, connectorId);
|
||||
}
|
||||
}
|
||||
|
||||
@ -4,6 +4,7 @@ import com.xhpc.common.domain.XhpcRate;
|
||||
import com.xhpc.common.domain.XhpcTerminal;
|
||||
import com.xhpc.order.domain.XhpcChargeOrder;
|
||||
import com.xhpc.order.domain.XhpcOrderRedisRecord;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
@ -15,6 +16,7 @@ import java.util.Map;
|
||||
* @author yuyang
|
||||
* @date 2021/8/4 9:55
|
||||
*/
|
||||
@Mapper
|
||||
public interface XhpcChargeOrderMapper {
|
||||
|
||||
|
||||
@ -147,14 +149,32 @@ public interface XhpcChargeOrderMapper {
|
||||
* @param terminalId
|
||||
* @return
|
||||
*/
|
||||
Map<String,Object> getXhpcChargingPile(@Param("terminalId")Long terminalId);
|
||||
Map<String, Object> getXhpcChargingPile(@Param("terminalId") Long terminalId);
|
||||
|
||||
|
||||
/**
|
||||
* 获取一次订单
|
||||
* @param status -1准备充电 0开始充电 1自动结算,2异常,3平台结算
|
||||
* @param source 0C端用户 1流量用户
|
||||
*
|
||||
* @param status -1准备充电 0开始充电 1自动结算,2异常,3平台结算
|
||||
* @param source 0C端用户 1流量用户
|
||||
* @return
|
||||
*/
|
||||
List<XhpcChargeOrder> getXhpcChargeOrderStatus(@Param("status")Integer status,@Param("source")Integer source);
|
||||
List<XhpcChargeOrder> getXhpcChargeOrderStatus(@Param("status") Integer status, @Param("source") Integer source);
|
||||
|
||||
/**
|
||||
* insert a row by 3rd.
|
||||
*
|
||||
* @param internetSerialNumber
|
||||
* @param driverId
|
||||
* @param chargingAmt
|
||||
* @param plateNum
|
||||
* @param status
|
||||
* @return
|
||||
*/
|
||||
int addBy3rd(@Param(value = "internetSerialNumber") String internetSerialNumber,
|
||||
@Param(value = "serialNum") String serialNum,
|
||||
@Param(value = "driverId") String driverId,
|
||||
@Param(value = "chargingAmt") Integer chargingAmt,
|
||||
@Param(value = "plateNum") String plateNum,
|
||||
@Param(value = "status") Integer status);
|
||||
}
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
package com.xhpc.order.service;
|
||||
|
||||
import com.xhpc.common.core.domain.R;
|
||||
import com.xhpc.common.core.web.domain.AjaxResult;
|
||||
import com.xhpc.common.domain.XhpcRate;
|
||||
import com.xhpc.order.domain.XhpcChargeOrder;
|
||||
@ -152,4 +153,5 @@ public interface IXhpcChargeOrderService {
|
||||
*/
|
||||
List<XhpcChargeOrder> getXhpcChargeOrderStatus(Integer status,Integer source);
|
||||
|
||||
}
|
||||
R startUpBy3rd(String internetSerialNumber, String driverId, Integer chargingAmt, String plateNum, Integer status, String connectorId);
|
||||
}
|
||||
@ -339,5 +339,204 @@ public class XhpcChargeOrderServiceImpl implements IXhpcChargeOrderService {
|
||||
return xhpcChargeOrderMapper.getXhpcChargeOrderStatus(status, source);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public R startUpBy3rd(String internetSerialNumber, String driverId, Integer chargingAmt, String plateNum, Integer status, String connectorId) {
|
||||
|
||||
R r = new R();
|
||||
String day = internetSerialNumber.substring(9, internetSerialNumber.length() - 4);
|
||||
if (!isValidDate(day)) {
|
||||
r.setCode(500);
|
||||
return r;
|
||||
}
|
||||
|
||||
if (driverId.length() != 11) {
|
||||
r.setCode(500);
|
||||
return r;
|
||||
}
|
||||
|
||||
if (chargingAmt == 0) chargingAmt = 500;
|
||||
|
||||
StartChargingData startChargingData = new StartChargingData();
|
||||
|
||||
startChargingData.setBalance(chargingAmt);
|
||||
|
||||
startChargingData.setGunId(connectorId);
|
||||
|
||||
startChargingData.setTel(driverId);
|
||||
|
||||
startChargingData.setPileNo(connectorId.substring(0, connectorId.length() - 3));
|
||||
|
||||
//终端状态是否空闲
|
||||
//是否插枪
|
||||
Map<String, Object> cacheMap = REDIS.getCacheMap("gun:" + connectorId);
|
||||
logger.info("<<<<<<<<<<<<<<<<<<<<<<<<cacheMap>>>>>>>>>>>>>>>>>");
|
||||
logger.info("<<<<<<<<<<<<<<<<<<<<<<<<cacheMap>>>>>>>>>>>>>>>>>" + connectorId);
|
||||
logger.info("<<<<<<<<<<<<<<<<<<<<<<<<cacheMap>>>>>>>>>>>>>>>>>" + cacheMap.toString());
|
||||
logger.info("<<<<<<<<<<<<<<<<<<<<<<<<cacheMap>>>>>>>>>>>>>>>>>");
|
||||
|
||||
if (cacheMap == null) {
|
||||
r.setCode(500);
|
||||
return r;
|
||||
} else {
|
||||
if (cacheMap.get("status") == null) {
|
||||
r.setCode(500);
|
||||
return r;
|
||||
} else {
|
||||
String statusCache = cacheMap.get("status").toString();
|
||||
//不同的状态
|
||||
if ("离线".equals(statusCache) || "故障".equals(statusCache) || "充电".equals(statusCache)) {
|
||||
r.setCode(500);
|
||||
return r;
|
||||
}
|
||||
}
|
||||
if (cacheMap.get("vehicleGunStatus") == null) {
|
||||
r.setCode(500);
|
||||
return r;
|
||||
} else {
|
||||
String vehicleGunStatus = cacheMap.get("vehicleGunStatus").toString();
|
||||
if (!"是".equals(vehicleGunStatus)) {
|
||||
r.setCode(500);
|
||||
return r;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//终端信息
|
||||
XhpcTerminal xhpcTerminal = xhpcChargeOrderMapper.getXhpcTerminalSerialNumber(connectorId);
|
||||
if (xhpcTerminal == null || xhpcTerminal.getTerminalId() == null || xhpcTerminal.getChargingPileId() == null || xhpcTerminal.getPileSerialNumber() == null) {
|
||||
r.setCode(500);
|
||||
return r;
|
||||
}
|
||||
|
||||
//获取桩信息
|
||||
Map<String, Object> xhpcChargingPileById =
|
||||
xhpcChargeOrderMapper.getXhpcChargingPileById(xhpcTerminal.getChargingPileId());
|
||||
|
||||
//启动充电
|
||||
//订单流水号 终端号+年月日时分秒+自增4位 共32位
|
||||
Date date = Calendar.getInstance().getTime();
|
||||
String format = DateUtil.format(date, "yyMMddHHmmss");
|
||||
//自增
|
||||
String orderNo = connectorId + format + StaticBeanUtil.seqDec("gun:" + connectorId + ".seqdec");
|
||||
|
||||
startChargingData.setOrderNo(orderNo);
|
||||
startChargingData.setPileNo(xhpcTerminal.getPileSerialNumber());
|
||||
startChargingData.setGunId(xhpcTerminal.getSerialNumber().substring(14));
|
||||
if (xhpcChargingPileById.get("communicationProtocolVersion") != null && !"".equals(xhpcChargingPileById.get("communicationProtocolVersion").toString())) {
|
||||
startChargingData.setVersion(xhpcChargingPileById.get("communicationProtocolVersion").toString());
|
||||
} else {
|
||||
startChargingData.setVersion("0A");
|
||||
}
|
||||
|
||||
|
||||
//平台
|
||||
String soc = redisService.getCacheObject("global:SOC");
|
||||
|
||||
|
||||
startChargingData.setSoc(Integer.parseInt(soc));
|
||||
logger.info("<<<<<<<<<<<<<<<<<<<<<<<<number>>>>>>>>>>>>>>>>>:" + soc);
|
||||
logger.info("<<<<<<<<<<<<<<<<<<<<<<<<Soc>>>>>>>>>>>>>>>>>:" + startChargingData.getSoc());
|
||||
|
||||
R r1 = powerPileService.startCharging(startChargingData);
|
||||
logger.info("<<<<<<<<<<<<<<<<<<<<<<<<充电返回>>>>>>>>>>>>>>>>>");
|
||||
logger.info("<<<<<<<<<<<<<<<<<<<<<<<<" + r1.getCode() + ">>>>>>>>>>>>>>>>>");
|
||||
logger.info("<<<<<<<<<<<<<<<<<<<<<<<<" + r1.getMsg() + ">>>>>>>>>>>>>>>>>");
|
||||
if (r1.getCode() != 200) {
|
||||
r1.setCode(500);
|
||||
return r1;
|
||||
}
|
||||
int res = xhpcChargeOrderMapper.addBy3rd(internetSerialNumber, orderNo, driverId, chargingAmt, plateNum, status);
|
||||
System.out.println(res);
|
||||
if (res != 0) {
|
||||
r.setCode(200);
|
||||
r.setData(orderNo);
|
||||
} else {
|
||||
r.setCode(500);
|
||||
}
|
||||
return r;
|
||||
|
||||
}
|
||||
|
||||
public static boolean isValidDate(String str) {
|
||||
try {
|
||||
if (0 != str.length()) {
|
||||
if (str.length() == 14) {
|
||||
// 闰年标志
|
||||
boolean isLeapYear = false;
|
||||
String year = str.substring(0, 4);
|
||||
String month = str.substring(4, 6);
|
||||
String day = str.substring(6, 8);
|
||||
String hour = str.substring(8, 10);
|
||||
String minute = str.substring(10, 12);
|
||||
String second = str.substring(12, 14);
|
||||
int intYear = Integer.parseInt(year);
|
||||
// 判断年份是否合法
|
||||
if (intYear < 1900 || intYear > 2200) {
|
||||
return false;
|
||||
}
|
||||
// 判断是否为闰年
|
||||
if (intYear % 4 == 0 && intYear % 100 != 0 || intYear % 400 == 0) {
|
||||
isLeapYear = true;
|
||||
}
|
||||
// 判断月份
|
||||
// 1.判断月份
|
||||
if (month.startsWith("0")) {
|
||||
String unitMonth = month.substring(1, 2);
|
||||
int intUnitMonth = Integer.parseInt(unitMonth);
|
||||
if (intUnitMonth == 0) {
|
||||
return false;
|
||||
}
|
||||
if (intUnitMonth == 2) {
|
||||
// 获取2月的天数
|
||||
int intDay4February = Integer.parseInt(day);
|
||||
if (isLeapYear) {
|
||||
if (intDay4February > 29) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if (intDay4February > 28) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// 2.判断非0打头的月份是否合法
|
||||
int intMonth = Integer.parseInt(month);
|
||||
if (intMonth != 10 && intMonth != 11 && intMonth != 12) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// 判断日期
|
||||
// 1.判断日期
|
||||
if (day.startsWith("0")) {
|
||||
String unit4Day = day.substring(1, 2);
|
||||
int intUnit4Day = Integer.parseInt(unit4Day);
|
||||
if (intUnit4Day == 0) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
// 2.判断非0打头的日期是否合法
|
||||
int intDay = Integer.parseInt(day);
|
||||
if (intDay < 10 || intDay > 31) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// 判断时间
|
||||
int intHour = Integer.parseInt(hour);
|
||||
int intMinute = Integer.parseInt(minute);
|
||||
int intSecond = Integer.parseInt(second);
|
||||
return intHour >= 0 && intHour <= 23 && intMinute >= 0 && intMinute <= 59 && intSecond >= 0 && intSecond <= 59;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -474,14 +474,42 @@
|
||||
</select>
|
||||
|
||||
<select id="getXhpcChargingPile" resultType="map">
|
||||
select
|
||||
charging_pile_id as chargingPileId,
|
||||
IFNULL(type,'1') as type
|
||||
from xhpc_charging_pile where charging_pile_id =(select charging_pile_id from xhpc_terminal where terminal_id=#{terminalId})
|
||||
select charging_pile_id as chargingPileId,
|
||||
IFNULL(type, '1') as type
|
||||
from xhpc_charging_pile
|
||||
where charging_pile_id = (select charging_pile_id from xhpc_terminal where terminal_id = #{terminalId})
|
||||
</select>
|
||||
|
||||
<select id="getXhpcChargeOrderStatus" resultMap="XhpcChargeOrderResult">
|
||||
select * from xhpc_charge_order where del_flag=0 and status=#{status} and source=#{source} and datediff(now(),create_time)>1
|
||||
select *
|
||||
from xhpc_charge_order
|
||||
where del_flag = 0
|
||||
and status = #{status}
|
||||
and source = #{source}
|
||||
and datediff(now(), create_time) > 1
|
||||
</select>
|
||||
|
||||
|
||||
<insert id="addBy3rd">
|
||||
|
||||
insert into xhpc_charge_order
|
||||
(internet_serial_number,
|
||||
serial_num,
|
||||
driverId,
|
||||
chargingAmt,
|
||||
<if test="plateNum != null and plateNum != ''">
|
||||
plateNum,
|
||||
</if>
|
||||
status,source)
|
||||
values
|
||||
(#{internetSerialNumber},
|
||||
#{serialNum},
|
||||
#{driverId},
|
||||
#{chargingAmt},
|
||||
<if test="plateNum != null and plateNum != ''">
|
||||
#{plateNum},
|
||||
</if>
|
||||
#{status},1)
|
||||
</insert>
|
||||
|
||||
</mapper>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user