From 856f526f823f5dad88c28657d82f971ff66afb1e Mon Sep 17 00:00:00 2001
From: MrShi <1878285526@qq.com>
Date: 星期一, 15 九月 2025 13:37:01 +0800
Subject: [PATCH] 优化

---
 server/web/src/main/java/com/doumee/jtt808/web/service/Jtt808Service.java |   58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 54 insertions(+), 4 deletions(-)

diff --git a/server/web/src/main/java/com/doumee/jtt808/web/service/Jtt808Service.java b/server/web/src/main/java/com/doumee/jtt808/web/service/Jtt808Service.java
index d66257d..273a168 100644
--- a/server/web/src/main/java/com/doumee/jtt808/web/service/Jtt808Service.java
+++ b/server/web/src/main/java/com/doumee/jtt808/web/service/Jtt808Service.java
@@ -3,6 +3,7 @@
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.alibaba.fastjson.TypeReference;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.doumee.biz.system.SystemDictDataBiz;
@@ -26,10 +27,12 @@
 import com.doumee.dao.business.web.request.LocaltionDTO;
 import com.doumee.dao.business.web.request.OpenElecBikeRequest;
 import com.doumee.dao.business.web.response.MemberRidesDetailResponse;
+import com.doumee.dao.business.web.response.UserResponse;
 import com.doumee.jtt808.web.endpoint.MessageManager;
 import com.doumee.service.business.GoodsorderService;
 import com.doumee.service.business.PricingRuleService;
 import com.github.yulichang.wrapper.MPJLambdaWrapper;
+import lombok.extern.slf4j.Slf4j;
 import me.chanjar.weixin.common.error.WxErrorException;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.BeanUtils;
@@ -55,6 +58,7 @@
 import java.util.concurrent.ConcurrentMap;
 
 @Service
+@Slf4j
 public class Jtt808Service {
     @Value("${tencent.map.remoteHost}")
     private String mapHost;
@@ -407,9 +411,13 @@
         }
         Bikes bike = bikesMapper.selectOne(new QueryWrapper<Bikes>().lambda().eq(Bikes::getCode,openElecBikeRequest.getCode()).eq(Bikes::getIsdeleted,Constants.ZERO)
                 .eq(Bikes::getType,Constants.ONE).last(" limit 1 "));
+
         if(bike == null && StringUtils.isBlank(bike.getParamId())){
             //濡傛灉杞﹁締绫诲瀷鏄┖
             throw  new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), " 璇ヨ溅鍨嬫殏鏃朵笉鑳藉�熻溅鎿嶄綔鍝︼紝璇锋洿鎹㈠叾浠栬溅鍨嬮噸璇曪紒");
+        }
+        if(!Constants.equalsInteger(bike.getBikeStatus(),Constants.ONE)){
+            throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"璇ヨ溅杈嗙姸鎬佸紓甯革紝涓嶆敮鎸佸嚭鍊燂紝璇峰皾璇曟洿鎹㈠叾浠栬溅杈嗭紒");
         }
         if(!Constants.equalsInteger(bike.getStatus(),Constants.ZERO)){
             throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"瀵逛笉璧凤紝璇ヨ溅杈嗗凡琚攣瀹氬�熺敤锛岃灏濊瘯鏇存崲鍏朵粬杞﹁締锛�");
@@ -632,11 +640,53 @@
         }
     }
 
+    public String updateLockStatusBatch(UserResponse user, List<String> idList, Integer lockStatus) {
+        if(idList ==null && idList.size()==0){
+            throw  new BusinessException(ResponseStatus.BAD_REQUEST);
+        }
+        String message = "";
+        int sNum =0,eNum=0,ingNum=0;
+        lockStatus = lockStatus==0?0:1;
+        List<Bikes> bikesList = bikesMapper.selectList(new LambdaQueryWrapper<Bikes>()
+                .eq(Bikes::getType,Constants.ONE)
+                .in(Bikes::getIsdeleted,Constants.ZERO)
+                .in(Bikes::getId,idList)
+        );
+        for(Bikes bike: bikesList){
+            if(Constants.equalsInteger(bike.getStatus(),Constants.ONE)){
+                //鍑哄�熶腑
+                ingNum++;
+                continue;
+            }
+            boolean r = true;
+            try {
+                this.lockBikes(bike.getDeviceSn(),lockStatus==0?1:0);
+            }catch (Exception e){
+                log.error(e.getMessage());
+                r =false;
+                eNum++;
+            }
+            if(r){
+                bikesMapper.update(null,new UpdateWrapper<Bikes>().lambda()
+                        .set(Bikes::getEditDate,new Date())
+                        .set(Bikes::getEditor,user.getId())
+                        .set(Bikes::getLockStatus,lockStatus)
+                        .set(Bikes::getIsdeleted,Constants.ZERO)
+                        .eq(Bikes::getType,Constants.ONE )
+                        .eq(Bikes::getId,bike.getId()));
+                sNum++;
+            }
+        }
+       message="鎴愬姛鎿嶄綔["+sNum+"]杈嗙數杞�";
+        if(ingNum>0){
+            message = message+"锛孾"+ingNum+"]杈嗙數杞︽鍑哄�熶腑";
+        }
+        if(eNum>0){
+            message = message+"锛孾"+eNum+"]杈嗙數杞﹁繙绋嬫搷浣滃け璐�";
+        }
+        return message;
+    }
 
-
-//    public void test(double lat,double lng){
-//        this.getBackSiteByPostion(lat,lng);
-//    }
 
 
 }

--
Gitblit v1.9.3