浏览代码

启动充电

skyline 2 年之前
父节点
当前提交
2a15597e12

+ 6 - 4
miniapp/src/main/java/com/kym/miniapp/controller/ChargerController.java

@@ -6,6 +6,7 @@ import com.kym.common.annotation.SysLog;
 import com.kym.service.admin.StationService;
 import com.kym.service.enplus.EnNotifyService;
 import com.kym.service.enplus.EnPlusService;
+import com.kym.service.miniapp.ChargeService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.format.annotation.DateTimeFormat;
 import org.springframework.web.bind.annotation.*;
@@ -27,6 +28,9 @@ public class ChargerController {
     @Autowired
     private EnPlusService enPlusService;
 
+    @Autowired
+    private ChargeService chargeService;
+
     @Autowired
     private EnNotifyService enNotifyService;
 
@@ -64,10 +68,8 @@ public class ChargerController {
 
     @SysLog("启动充电")
     @PostMapping("/startCharge")
-    R startCharge() {
-
-
-        return R.success();
+    R startCharge(@RequestBody String connectorId) {
+        return R.success(chargeService.startCharge(connectorId));
     }
 
     @SysLog("停止充电")

+ 10 - 0
service/src/main/java/com/kym/service/miniapp/ChargeService.java

@@ -0,0 +1,10 @@
+package com.kym.service.miniapp;
+
+/**
+ * @author skyline
+ * @description
+ * @date 2023-08-07 17:06
+ */
+public interface ChargeService {
+    String startCharge(String connectorId);
+}

+ 9 - 2
service/src/main/java/com/kym/service/miniapp/impl/ChargeServiceImpl.java

@@ -13,6 +13,7 @@ import com.kym.service.admin.EquipmentRelationService;
 import com.kym.service.enplus.EnPlusService;
 import com.kym.service.miniapp.AccountService;
 import com.kym.service.miniapp.ChargeOrderService;
+import com.kym.service.miniapp.ChargeService;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -27,7 +28,7 @@ import java.math.BigDecimal;
  * @date 2023-07-29 14:24
  */
 @Service
-public class ChargeServiceImpl {
+public class ChargeServiceImpl implements ChargeService {
     private static final Logger LOGGER = LoggerFactory.getLogger(ChargeServiceImpl.class);
 
 
@@ -52,7 +53,13 @@ public class ChargeServiceImpl {
     @Value("${en-plus.operator-id}")
     private String operatorId;
 
-    String startCharge(String connectorId) {
+    /**
+     * 启动充电
+     * @param connectorId
+     * @return
+     */
+    @Override
+    public String startCharge(String connectorId) {
         var userId = StpUtil.getSession().getLong("userId");
         if (connectorId.length() == 6) {
             // 查询EN+设备SN