diff --git a/evcs-modules/evcs-common/src/main/java/com/xhpc/evcs/dto/StartChargeRequest.java b/evcs-modules/evcs-common/src/main/java/com/xhpc/evcs/dto/StartChargeRequest.java new file mode 100644 index 00000000..cf065ca4 --- /dev/null +++ b/evcs-modules/evcs-common/src/main/java/com/xhpc/evcs/dto/StartChargeRequest.java @@ -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; + +} diff --git a/evcs-modules/evcs-common/src/main/java/com/xhpc/evcs/dto/StartChargeResponse.java b/evcs-modules/evcs-common/src/main/java/com/xhpc/evcs/dto/StartChargeResponse.java new file mode 100644 index 00000000..483880a2 --- /dev/null +++ b/evcs-modules/evcs-common/src/main/java/com/xhpc/evcs/dto/StartChargeResponse.java @@ -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; +} diff --git a/evcs-modules/evcs-core/src/main/java/com/xhpc/evcs/api/CoreDispatcher.java b/evcs-modules/evcs-core/src/main/java/com/xhpc/evcs/api/CoreDispatcher.java index 08d2440e..dfff51eb 100644 --- a/evcs-modules/evcs-core/src/main/java/com/xhpc/evcs/api/CoreDispatcher.java +++ b/evcs-modules/evcs-core/src/main/java/com/xhpc/evcs/api/CoreDispatcher.java @@ -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(); diff --git a/evcs-modules/evcs-core/src/main/java/com/xhpc/evcs/api/QueryStartChargeController.java b/evcs-modules/evcs-core/src/main/java/com/xhpc/evcs/api/QueryStartChargeController.java new file mode 100644 index 00000000..f03aad8c --- /dev/null +++ b/evcs-modules/evcs-core/src/main/java/com/xhpc/evcs/api/QueryStartChargeController.java @@ -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 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 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; + } +} diff --git a/evcs-modules/evcs-core/src/main/java/com/xhpc/evcs/notification/NotificationChargeOrderInfo4BonusTask.java b/evcs-modules/evcs-core/src/main/java/com/xhpc/evcs/notification/NotificationChargeOrderInfo4BonusTask.java index 4845608e..34875c15 100644 --- a/evcs-modules/evcs-core/src/main/java/com/xhpc/evcs/notification/NotificationChargeOrderInfo4BonusTask.java +++ b/evcs-modules/evcs-core/src/main/java/com/xhpc/evcs/notification/NotificationChargeOrderInfo4BonusTask.java @@ -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 example = Example.of(om); etOrderMapping = orderMappingRepository.findOne(example).orElse(null); if (etOrderMapping == null) { diff --git a/evcs-modules/evcs-core/src/main/java/com/xhpc/evcs/notification/NotificationStartChargeResultTask.java b/evcs-modules/evcs-core/src/main/java/com/xhpc/evcs/notification/NotificationStartChargeResultTask.java new file mode 100644 index 00000000..73e8226e --- /dev/null +++ b/evcs-modules/evcs-core/src/main/java/com/xhpc/evcs/notification/NotificationStartChargeResultTask.java @@ -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. + +} diff --git a/evcs-modules/evcs-core/src/main/java/com/xhpc/evcs/notification/NotificationStationStatusTask.java b/evcs-modules/evcs-core/src/main/java/com/xhpc/evcs/notification/NotificationStationStatusTask.java index 49c955c5..e0e757d8 100644 --- a/evcs-modules/evcs-core/src/main/java/com/xhpc/evcs/notification/NotificationStationStatusTask.java +++ b/evcs-modules/evcs-core/src/main/java/com/xhpc/evcs/notification/NotificationStationStatusTask.java @@ -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; } diff --git a/xhpc-modules/xhpc-common/src/main/java/com/xhpc/common/api/PileOrderService.java b/xhpc-modules/xhpc-common/src/main/java/com/xhpc/common/api/PileOrderService.java index 03ce6c5c..0adb8c16 100644 --- a/xhpc-modules/xhpc-common/src/main/java/com/xhpc/common/api/PileOrderService.java +++ b/xhpc-modules/xhpc-common/src/main/java/com/xhpc/common/api/PileOrderService.java @@ -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); } diff --git a/xhpc-modules/xhpc-common/src/main/java/com/xhpc/common/api/factory/PileOrderFallbackFactory.java b/xhpc-modules/xhpc-common/src/main/java/com/xhpc/common/api/factory/PileOrderFallbackFactory.java index 12f23893..b9c99658 100644 --- a/xhpc-modules/xhpc-common/src/main/java/com/xhpc/common/api/factory/PileOrderFallbackFactory.java +++ b/xhpc-modules/xhpc-common/src/main/java/com/xhpc/common/api/factory/PileOrderFallbackFactory.java @@ -50,6 +50,12 @@ public class PileOrderFallbackFactory implements FallbackFactory>>>>>>>>>>>>>>>>"); logger.info("<<<<<<<<<<发送时间<<<<<<<<<<<<<<"+ DateUtil.format(Calendar.getInstance().getTime(), "yyyy-MM-dd HH:mm:ss")+">>>>>>>>>>>>>>>>>"); } - - } diff --git a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/api/XhpcPileOrderController.java b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/api/XhpcPileOrderController.java index 909702b3..eb851ddf 100644 --- a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/api/XhpcPileOrderController.java +++ b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/api/XhpcPileOrderController.java @@ -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); +} } diff --git a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/mapper/XhpcChargeOrderMapper.java b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/mapper/XhpcChargeOrderMapper.java index 2aeb0250..c213d7d1 100644 --- a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/mapper/XhpcChargeOrderMapper.java +++ b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/mapper/XhpcChargeOrderMapper.java @@ -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 getXhpcChargingPile(@Param("terminalId")Long terminalId); + Map 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 getXhpcChargeOrderStatus(@Param("status")Integer status,@Param("source")Integer source); + List 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); } diff --git a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/IXhpcChargeOrderService.java b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/IXhpcChargeOrderService.java index 7a3bb429..ec0561eb 100644 --- a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/IXhpcChargeOrderService.java +++ b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/IXhpcChargeOrderService.java @@ -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 getXhpcChargeOrderStatus(Integer status,Integer source); -} + R startUpBy3rd(String internetSerialNumber, String driverId, Integer chargingAmt, String plateNum, Integer status, String connectorId); +} \ No newline at end of file diff --git a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/impl/XhpcChargeOrderServiceImpl.java b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/impl/XhpcChargeOrderServiceImpl.java index 411d34ac..1d163c4b 100644 --- a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/impl/XhpcChargeOrderServiceImpl.java +++ b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/impl/XhpcChargeOrderServiceImpl.java @@ -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 cacheMap = REDIS.getCacheMap("gun:" + connectorId); + logger.info("<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>"); + logger.info("<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>" + connectorId); + logger.info("<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>" + cacheMap.toString()); + logger.info("<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>"); + + 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 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("<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>:" + soc); + logger.info("<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>:" + 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; + } + } } diff --git a/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcChargeOrderMapper.xml b/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcChargeOrderMapper.xml index 123adef6..a6ff1a47 100644 --- a/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcChargeOrderMapper.xml +++ b/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcChargeOrderMapper.xml @@ -474,14 +474,42 @@ + + + + insert into xhpc_charge_order + (internet_serial_number, + serial_num, + driverId, + chargingAmt, + + plateNum, + + status,source) + values + (#{internetSerialNumber}, + #{serialNum}, + #{driverId}, + #{chargingAmt}, + + #{plateNum}, + + #{status},1) + +