From ef7e7b111eca7b3c8ecfb2df20c6650d603d8bc3 Mon Sep 17 00:00:00 2001 From: yuyang <2265829957@qq.com> Date: Thu, 25 Nov 2021 16:08:23 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0PC=E7=AB=AF=E5=81=9C=E6=AD=A2?= =?UTF-8?q?=E5=85=85=E7=94=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mapper/XhpcChargingPileMapper.xml | 1 + .../resources/mapper/XhpcTerminalMapper.xml | 1 + .../XhpcHistoryOrderController.java | 8 ++-- .../XhpcStopChargingOrderController.java | 42 ++++++++++++++++--- .../service/IXhpcChargeOrderService.java | 5 +++ .../impl/XhpcChargeOrderServiceImpl.java | 5 +++ 6 files changed, 52 insertions(+), 10 deletions(-) diff --git a/xhpc-modules/xhpc-charging-station/src/main/resources/mapper/XhpcChargingPileMapper.xml b/xhpc-modules/xhpc-charging-station/src/main/resources/mapper/XhpcChargingPileMapper.xml index 4c69ff66..02d99531 100644 --- a/xhpc-modules/xhpc-charging-station/src/main/resources/mapper/XhpcChargingPileMapper.xml +++ b/xhpc-modules/xhpc-charging-station/src/main/resources/mapper/XhpcChargingPileMapper.xml @@ -400,6 +400,7 @@ select te.terminal_id as terminalId, + te.charging_pile_id as chargingPileId, te.charging_station_id as chargingStationId, te.name as terminalName, ct.name as chargingStationName, diff --git a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/controller/XhpcHistoryOrderController.java b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/controller/XhpcHistoryOrderController.java index fa89d32f..b26e0227 100644 --- a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/controller/XhpcHistoryOrderController.java +++ b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/controller/XhpcHistoryOrderController.java @@ -115,7 +115,7 @@ public class XhpcHistoryOrderController extends BaseController { * 终端统计 */ @GetMapping("/test3") - @Scheduled(cron = "0 0/8 * * * ?") + @Scheduled(cron = "0 0/2 * * * ?") public void test3(){ logger.info(">>>>>>>>>>>>>>>>>>>>>>>终端统计定时任务>>>>>>>>>>>>>>>>>>>>>"); logger.info(">>>>>>>>>>>>>>>>>>>>>>>终端统计定时任务>>>>>>>>>>>>>>>>>>>>>"); @@ -126,7 +126,7 @@ public class XhpcHistoryOrderController extends BaseController { * 场站统计 */ @GetMapping("/test2") - @Scheduled(cron = "0 0/7 * * * ?") + @Scheduled(cron = "0 0/2 * * * ?") public void test2(){ logger.info(">>>>>>>>>>>>>>>>>>>>>>>场站统计定时任务>>>>>>>>>>>>>>>>>>>>>"); logger.info(">>>>>>>>>>>>>>>>>>>>>>>场站统计定时任务>>>>>>>>>>>>>>>>>>>>>"); @@ -138,7 +138,7 @@ public class XhpcHistoryOrderController extends BaseController { * 日期统计 */ @GetMapping("/test1") - @Scheduled(cron = "0 0/6 * * * ?") + @Scheduled(cron = "0 0/2 * * * ?") public void test1(){ add(1000,1); } @@ -434,7 +434,7 @@ public class XhpcHistoryOrderController extends BaseController { * 小时统计 */ @GetMapping("/test") - @Scheduled(cron = "0 0/5 * * * ?") + @Scheduled(cron = "0 0/2 * * * ?") public void test(){ logger.info(">>>>>>>>>>>>>>>>>>>>>>>小时统计定时任务>>>>>>>>>>>>>>>>>>>>>"); logger.info(">>>>>>>>>>>>>>>>>>>>>>>小时统计定时任务>>>>>>>>>>>>>>>>>>>>>"); diff --git a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/controller/XhpcStopChargingOrderController.java b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/controller/XhpcStopChargingOrderController.java index d4f67235..ede6c055 100644 --- a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/controller/XhpcStopChargingOrderController.java +++ b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/controller/XhpcStopChargingOrderController.java @@ -1,9 +1,13 @@ package com.xhpc.order.controller; +import com.xhpc.common.api.PowerPileService; +import com.xhpc.common.core.domain.R; import com.xhpc.common.core.web.controller.BaseController; import com.xhpc.common.core.web.domain.AjaxResult; import com.xhpc.common.core.web.page.TableDataInfo; +import com.xhpc.common.redis.service.RedisService; import com.xhpc.order.api.XhpcChargeOrderController; +import com.xhpc.order.service.IXhpcChargeOrderService; import com.xhpc.order.service.IXhpcStopChargingOrderService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.scheduling.annotation.Scheduled; @@ -12,6 +16,8 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; +import java.util.Map; + /** * program: ruoyi @@ -26,7 +32,13 @@ public class XhpcStopChargingOrderController extends BaseController { private IXhpcStopChargingOrderService iXhpcStopChargingOrderService; @Autowired - private XhpcChargeOrderController xhpcChargeOrderController; + private RedisService redisService; + + @Autowired + private PowerPileService powerPileService; + + @Autowired + private IXhpcChargeOrderService xhpcChargeOrderService; @GetMapping("/list") public TableDataInfo list(Long userId, Long chargingStationId, Long terminalId){ @@ -36,14 +48,32 @@ public class XhpcStopChargingOrderController extends BaseController { /** * 停止充电 - * @param userId - * @param terminalSerialNumber 终端编码 - * @param chargingOrderId 充电id + * @param serialNumber 终端编号 * @return */ @GetMapping("/stopUp") - public AjaxResult stopUp(@RequestParam Long userId, @RequestParam String terminalSerialNumber, @RequestParam Long chargingOrderId){ + public AjaxResult stopUp(@RequestParam String serialNumber,@RequestParam Long chargingPileId){ + //查询缓存是否该终端在充电 + Map cacheMap = redisService.getCacheMap("gun:" + serialNumber); - return xhpcChargeOrderController.stopUp(userId, terminalSerialNumber, chargingOrderId); + if(cacheMap!=null){ + if(cacheMap.get("orderkey") !=null){ + String orderkey = cacheMap.get("orderkey").toString().substring(6); + + Map xhpcChargingPileById = xhpcChargeOrderService.getXhpcChargingPileById(chargingPileId); + String version ="0A"; + if(xhpcChargingPileById.get("communicationProtocolVersion")!=null && !"".equals(xhpcChargingPileById.get("communicationProtocolVersion").toString())){ + version=xhpcChargingPileById.get("communicationProtocolVersion").toString(); + } + R r = powerPileService.stopCharging(orderkey, orderkey.substring(0,14), orderkey.substring(0,16), version); + + if(r.getCode()==200){ + return AjaxResult.success("停止充电命令已下发"); + }else{ + return AjaxResult.success(r.getMsg()); + } + } + } + return AjaxResult.success("无车辆充电"); } } 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 3bd77fdc..63b345b5 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 @@ -5,6 +5,7 @@ import com.xhpc.common.core.web.domain.AjaxResult; import com.xhpc.common.domain.XhpcRate; import com.xhpc.order.domain.XhpcChargeOrder; import com.xhpc.order.domain.XhpcOrderRedisRecord; +import org.apache.ibatis.annotations.Param; import java.math.BigDecimal; import java.util.Date; @@ -153,10 +154,14 @@ public interface IXhpcChargeOrderService { */ List getXhpcChargeOrderStatus(Integer status,Integer source); + R startUpBy3rd(String internetSerialNumber, String driverId, Integer chargingAmt, String plateNum, Integer status, String connectorId); /** * 标记异常大于创建4小时,标记为异常 */ void updateStatus(); + + //获取桩信息 + Map getXhpcChargingPileById(Long chargingPileId); } \ 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 b04bd91b..5b16dff0 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 @@ -512,6 +512,11 @@ public class XhpcChargeOrderServiceImpl implements IXhpcChargeOrderService { xhpcChargeOrderMapper.updateStatus(); } + @Override + public Map getXhpcChargingPileById(Long chargingPileId) { + return xhpcChargeOrderMapper.getXhpcChargingPileById(chargingPileId); + } + public static boolean isValidDate(String str) { try { if (0 != str.length()) {