Pu Zhibing
7 天以前 db0aaa2033a43c016ca165513faaee993117ecf8
user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/impl/DriverServiceImpl.java
@@ -1,5 +1,9 @@
package com.supersavedriving.user.modular.system.service.impl;
import cn.hutool.core.io.FileUtil;
import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpResponse;
import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
@@ -11,12 +15,13 @@
import com.supersavedriving.user.modular.system.util.RedisUtil;
import com.supersavedriving.user.modular.system.util.ResultUtil;
import com.supersavedriving.user.modular.system.util.UUIDUtil;
import com.supersavedriving.user.modular.system.util.huawei.OBSUtil;
import com.supersavedriving.user.modular.system.util.mongodb.model.Location;
import com.supersavedriving.user.modular.system.util.qianyuntong.QianYunTongConfig;
import com.supersavedriving.user.modular.system.util.weChat.WeChatUtil;
import com.supersavedriving.user.modular.system.warpper.DriverRegisterWarpper;
import com.supersavedriving.user.modular.system.warpper.NearbyDriverWarpper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.geo.Circle;
import org.springframework.data.geo.Distance;
import org.springframework.data.geo.Metrics;
@@ -26,12 +31,11 @@
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.io.File;
import java.io.InputStream;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.stream.Collectors;
/**
@@ -68,6 +72,12 @@
    @Autowired
    private ITBranchOfficeAreaService branchOfficeAreaService;
    @Value("${qyt.admin_url}")
    private String adminUrl;
    @Value("${filePath}")
    private String filePath;
@@ -102,7 +112,7 @@
        }
        List<DriverWork> driverWorks = driverWorkService.selectList(new EntityWrapper<DriverWork>().in("driverId", collect).eq("status", 1));
        for (DriverWork driverWork : driverWorks) {
            String value = redisUtil.getValue("DRIVER" + driverWork.getDriverId());
            String value = redisUtil.getValue("daijia:DRIVER" + driverWork.getDriverId());
            if(ToolUtil.isEmpty(value)){
                continue;
            }
@@ -250,7 +260,15 @@
    //生成小程序二维码
    public String wechatMiniProgramORCode(Integer driverId) throws Exception{
        InputStream release = weChatUtil.getwxacodeunlimit("pages/index/index", "driverId=" + driverId, "release");
        String s = OBSUtil.putObjectToBucket(release, "driver_" + driverId);
        return s;
        String pictureName = "driver_" + driverId + ".png";
        File file = FileUtil.writeFromStream(release, new File(filePath + pictureName));
        HttpRequest post = HttpUtil.createPost(adminUrl + "/upload/image");
        HttpRequest form = post.form("file", file);
        HttpResponse execute = form.execute();
        int status = execute.getStatus();
        if(200 != status){
            throw new RuntimeException("上传图片异常");
        }
        return execute.body();
    }
}