From db0aaa2033a43c016ca165513faaee993117ecf8 Mon Sep 17 00:00:00 2001 From: Pu Zhibing <393733352@qq.com> Date: 星期五, 22 八月 2025 12:14:14 +0800 Subject: [PATCH] 修改bug --- user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/impl/DriverServiceImpl.java | 32 +++++++++++++++++++++++++------- 1 files changed, 25 insertions(+), 7 deletions(-) diff --git a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/impl/DriverServiceImpl.java b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/impl/DriverServiceImpl.java index 5967e85..90d3568 100644 --- a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/impl/DriverServiceImpl.java +++ b/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; @@ -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(); } } -- Gitblit v1.7.1