From f27e0eae38502d40a187dedc3710ff4a291b05ed Mon Sep 17 00:00:00 2001
From: rk <94314517@qq.com>
Date: 星期五, 07 十一月 2025 13:49:56 +0800
Subject: [PATCH] 111

---
 server/web/src/main/java/com/doumee/jtt808/web/service/Jtt808Service.java |   84 ++++++++++++++++++++++++++++++++++++------
 1 files changed, 72 insertions(+), 12 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 fcee3c4..f4643c6 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,12 +27,15 @@
 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.apache.xpath.operations.Bool;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
@@ -55,6 +59,7 @@
 import java.util.concurrent.ConcurrentMap;
 
 @Service
+@Slf4j
 public class Jtt808Service {
     @Value("${tencent.map.remoteHost}")
     private String mapHost;
@@ -116,22 +121,27 @@
         gparam.setStatus(Constants.goodsorderStatus.pay);
         gparam.setType(Constants.ZERO);
         Goodsorder goodsorder =  goodsorderService.findOne(gparam);
-        this.backBike(goodsorder);
+        this.backBike(goodsorder,false);
     }
 
     /**
-     * 鑷姩杩樿溅
+     * 寮哄埗杩樿溅
      * @param id
      */
     @Transactional
     public void forceBack(String id){
         Goodsorder goodsorder =  goodsorderService.findById(id);
-        this.backBike(goodsorder);
+        this.backBike(goodsorder,true);
     }
 
 
+    /**
+     * 杩樿溅涓氬姟
+     * @param goodsorder
+     * @param isForce 寮哄埗杩樿溅 涓嶉獙璇佽溅杈嗗湴鐐�
+     */
     @Transactional(rollbackFor = {BusinessException.class})
-    public void backBike(Goodsorder goodsorder){
+    public void backBike(Goodsorder goodsorder, Boolean isForce){
         if(Objects.isNull(goodsorder)){
             throw new BusinessException(ResponseStatus.NO_UNCLOSEED_ORDER.getCode(),"鏃犻獞琛岃鍗曡褰�");
         }
@@ -147,10 +157,14 @@
                         &&Constants.equalsInteger(rides.getType(),Constants.ONE)){
                     //濡傛灉鏄數杞﹀苟涓旀槸楠戣涓� 杩涜鍏抽攣澶勭悊
                     Bikes  bike = getElecBikeByCode(rides.getBikeCode());
-                    //鏌ヨ鍋滆溅绔欑偣淇℃伅
-                    if(bike.getSiteId() ==null){
-                        throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(), "瀵逛笉璧凤紝璇锋寜瑕佹眰鍓嶅線鍋滆溅鐐瑰仠杞︼紒");
+                    //闈炲己鍒惰繕杞� 闇�瑕侀檺鍒跺湴鐐�
+                    if(!isForce){
+                        //鏌ヨ鍋滆溅绔欑偣淇℃伅
+                        if(bike.getSiteId() ==null){
+                            throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(), "瀵逛笉璧凤紝璇锋寜瑕佹眰鍓嶅線鍋滆溅鐐瑰仠杞︼紒");
+                        }
                     }
+
                     lockBikes(bike.getDeviceSn(),Constants.ONE);//鍙戣捣鍏抽攣鎸囦护璇锋眰
                     backIds.add(rides.getId());
                     rides.setStatus(Constants.MEMBER_RIDES_STATUS.BACK_CYCLING.getKey());//宸茶繕杞�
@@ -217,7 +231,7 @@
         APIResult<T0201_0500> data = result.block();
         if(!data.isSuccess()){
             //濡傛灉寮�閿佸け璐ワ紝鍒欒繑鍥炲紓甯�
-            throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "瀵逛笉璧凤紝"+(type ==0?"杞﹁締鍏抽攣":"杞﹁締寮�閿�")+"澶辫触锛岃绋嶅悗閲嶈瘯锛屾垨鑰呰仈绯诲洯鍖虹鐞嗕汉鍛橈紒");
+            throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "瀵逛笉璧凤紝"+(type ==0?"杞﹁締寮�閿�":"杞﹁締鍏抽攣")+"澶辫触锛岃绋嶅悗閲嶈瘯锛屾垨鑰呰仈绯诲洯鍖虹鐞嗕汉鍛橈紒");
         }
     }
 
@@ -407,9 +421,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 +650,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