skyline 2 سال پیش
والد
کامیت
c0dab5fa73

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

@@ -76,7 +76,7 @@ public class ChargerController {
 
     @SysLog("启动充电")
     @GetMapping("/startCharge")
-    R<String> startCharge(@RequestParam("connectorId") String connectorId, @RequestParam("stationId") String stationId) {
+    R startCharge(@RequestParam("connectorId") String connectorId, @RequestParam("stationId") String stationId) {
         return R.success(chargeService.queryStartCharge(connectorId, stationId));
     }
 

+ 1 - 1
service/src/main/java/com/kym/service/enplus/impl/EnPlusServiceImpl.java

@@ -89,7 +89,7 @@ public class EnPlusServiceImpl implements EnPlusService {
         if (0 == response.getRet()) {
             return response;
         } else {
-            LOGGER.error("接口数据异常:url:{},/n params:{},token:{},返回信息:{}", url, params, token, response);
+            LOGGER.error("接口数据异常:url:{}\n params:{}\ntoken:{}\n返回信息:{}", url, params, token, response);
             throw new BusinessException(ResponseEnum.EN_PLUS_API_EXCEPTION);
         }
     }

+ 3 - 1
service/src/main/java/com/kym/service/miniapp/ChargeService.java

@@ -3,6 +3,8 @@ package com.kym.service.miniapp;
 import com.kym.entity.enplus.response.EnBusinessPolicy;
 import com.kym.entity.miniapp.ChargeOrder;
 
+import java.util.Map;
+
 /**
  * @author skyline
  * @description
@@ -10,7 +12,7 @@ import com.kym.entity.miniapp.ChargeOrder;
  */
 public interface ChargeService {
 
-    String queryStartCharge(String connectorId, String stationId);
+    Map queryStartCharge(String connectorId, String stationId);
 
     ChargeOrder queryEquipChargeStatus(String startChargeSeq);
 

+ 5 - 4
service/src/main/java/com/kym/service/miniapp/impl/ChargeServiceImpl.java

@@ -18,6 +18,8 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 
+import java.util.Map;
+
 /**
  * @author skyline
  * @description 充电
@@ -53,7 +55,7 @@ public class ChargeServiceImpl implements ChargeService {
      * @return
      */
     @Override
-    public String queryStartCharge(String connectorId, String stationId) {
+    public Map queryStartCharge(String connectorId, String stationId) {
         var userId = StpUtil.getSession().getLong("userId");
         if (connectorId.length() == 6) {
             // 查询EN+设备SN
@@ -108,8 +110,7 @@ public class ChargeServiceImpl implements ChargeService {
                 order.setConnectorId(connectorId);
                 order.setChargeStatus(startCharge.getIntValue("StartChargeSeqStat"));
                 chargeOrderService.save(order);
-                // TODO: 2023-08-07 包装成自己的数据
-                return startChargeSeq;
+                return Map.of("startChargeSeq", startChargeSeq);
             } else {
                 // 启动充电失败
                 LOGGER.error("设备启动充电失败:{}", startCharge);
@@ -128,7 +129,7 @@ public class ChargeServiceImpl implements ChargeService {
                 case 1 -> // 设备未插枪
                         throw new BusinessException(ResponseEnum.EN_PLUS_EQUIP_NOT_CONNECTED);
                 case 2 -> // 设备检测失败
-                        throw new BusinessException(ResponseEnum.EN_PLUS_EQUIP_AUTH_FAIL);
+                        throw new BusinessException(ResponseEnum.EN_PLUS_EQUIP_CHECK_FAIL);
             }
             throw new BusinessException(ResponseEnum.EN_PLUS_EQUIP_AUTH_FAIL);
         }

+ 19 - 1
service/src/main/java/com/kym/service/miniapp/impl/CollectServiceImpl.java

@@ -37,7 +37,25 @@ public class CollectServiceImpl extends ServiceImpl<CollectMapper, Collect> impl
     @Override
     public void updateCollect(String stationId, Integer status) {
         var userId = StpUtil.getLoginIdAsLong();
-        lambdaUpdate().set(Collect::getStatus,status).eq(Collect::getUserId, userId).eq(Collect::getStationId, stationId).update();
+
+        switch (status) {
+            case 1 -> // 收藏
+            {
+                var collect = new Collect();
+                collect.setUserId(userId);
+                collect.setStationId(stationId);
+                collect.setStatus(status);
+                var exist = lambdaQuery().eq(Collect::getUserId, userId).eq(Collect::getStationId, stationId).exists();
+                if (!exist) {
+                    save(collect);
+                } else {
+                    lambdaUpdate().set(Collect::getStatus, status).eq(Collect::getUserId, userId).eq(Collect::getStationId, stationId).update();
+                }
+            }
+            case 0 -> // 取消收藏
+                    lambdaUpdate().set(Collect::getStatus, status).eq(Collect::getUserId, userId).eq(Collect::getStationId, stationId).update();
+        }
+
     }
 
     /**