| | |
| | | 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; |
| | | import com.heredata.hos.model.bucket.Bucket; |
| | | import com.supersavedriving.user.core.util.ToolUtil; |
| | | import com.supersavedriving.user.modular.system.dao.DriverMapper; |
| | | import com.supersavedriving.user.modular.system.model.*; |
| | |
| | | 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.NCOSSUtil; |
| | | 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; |
| | |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.io.File; |
| | | import java.io.InputStream; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | |
| | | @Autowired |
| | | private ITBranchOfficeAreaService branchOfficeAreaService; |
| | | |
| | | @Resource |
| | | private QianYunTongConfig qianYunTongConfig; |
| | | @Value("${qyt.admin_url}") |
| | | private String adminUrl; |
| | | |
| | | @Value("${filePath}") |
| | | private String filePath; |
| | | |
| | | |
| | | |
| | |
| | | } |
| | | 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; |
| | | } |
| | |
| | | //生成小程序二维码 |
| | | public String wechatMiniProgramORCode(Integer driverId) throws Exception{ |
| | | InputStream release = weChatUtil.getwxacodeunlimit("pages/index/index", "driverId=" + driverId, "release"); |
| | | // String s = OBSUtil.putObjectToBucket(release, "driver_" + driverId); |
| | | String pictureName = "driver_" + driverId + ".png"; |
| | | String bucketName = qianYunTongConfig.getBucketName(); |
| | | Bucket grjyTest = NCOSSUtil.getBucketInfo(bucketName); |
| | | if (null == grjyTest) { |
| | | //创建桶 |
| | | Boolean bucket = NCOSSUtil.createBucket(bucketName); |
| | | if (!bucket) { |
| | | throw new RuntimeException("创建存储桶失败"); |
| | | } |
| | | //设置桶策略 |
| | | String policyText = "{\"Version\":\"2025-06-23\",\"Statement\":[{\"Sid\":\"Stmt20250623\",\"Action\":[\"GetObject\"],\"Effect\":\"Allow\",\"Resource\":\"" + bucketName + "/*\",\"Principal\":\"*\"}]}"; |
| | | Boolean bucketPolicy = NCOSSUtil.setBucketPolicy(bucketName, policyText); |
| | | if (!bucketPolicy) { |
| | | throw new RuntimeException("设置桶策略失败"); |
| | | } |
| | | 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("上传图片异常"); |
| | | } |
| | | //上传对象 |
| | | String key = "imgs/daijia/driver/" + pictureName; |
| | | String object = NCOSSUtil.putObject(bucketName, key, release); |
| | | if (null == object) { |
| | | throw new RuntimeException("上传图片失败"); |
| | | } |
| | | |
| | | return "https://traffic.qytzt.cn/v1/AUTH_" + qianYunTongConfig.getAccount() + "/" + bucketName + "/" + key; |
| | | return execute.body(); |
| | | } |
| | | } |