MrShi
2025-09-15 856f526f823f5dad88c28657d82f971ff66afb1e
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);
//    }
}