| | |
| | | package com.supersavedriving.user.modular.api; |
| | | |
| | | 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.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.heredata.hos.model.bucket.Bucket; |
| | | import com.sun.xml.internal.bind.v2.TODO; |
| | | import com.supersavedriving.user.core.common.annotion.ServiceLog; |
| | | import com.supersavedriving.user.core.util.ToolUtil; |
| | | import com.supersavedriving.user.modular.system.model.*; |
| | | import com.supersavedriving.user.modular.system.service.*; |
| | | import com.supersavedriving.user.modular.system.util.*; |
| | | import com.supersavedriving.user.modular.system.util.GaoDe.MapUtil; |
| | | import com.supersavedriving.user.modular.system.util.GaoDe.model.District; |
| | | import com.supersavedriving.user.modular.system.util.MallBook.model.InterfaceResponse; |
| | | import com.supersavedriving.user.modular.system.util.MallBook.util.RSASignature; |
| | | import com.supersavedriving.user.modular.system.util.huawei.OBSUtil; |
| | | 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.qianyuntong.SMSUtil; |
| | | import com.supersavedriving.user.modular.system.util.qianyuntong.model.SendSmsRequest; |
| | |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.File; |
| | | import java.io.InputStream; |
| | | import java.io.PrintWriter; |
| | | import java.util.Date; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | |
| | | private TCheckCarActivityService checkCarActivityService; |
| | | @Autowired |
| | | private ITBranchOfficeAreaService branchOfficeAreaService; |
| | | |
| | | @Resource |
| | | private QianYunTongConfig qianYunTongConfig; |
| | | |
| | | @Value("${qyt.admin_url}") |
| | | private String adminUrl; |
| | | |
| | | @Value("${filePath}") |
| | | private String filePath; |
| | | |
| | | |
| | | |
| | |
| | | BeanUtils.copyProperties(appUser, userInfoWarpper); |
| | | |
| | | District geocode = MapUtil.geocode(lon, lat); |
| | | TBranchOfficeArea branchOfficeArea = branchOfficeAreaService.selectOne(new EntityWrapper<TBranchOfficeArea>().eq("areaCode", geocode.getDistrictCode()) |
| | | .last("LIMIT 1")); |
| | | if(null == branchOfficeArea){ |
| | | if(null != geocode){ |
| | | TBranchOfficeArea branchOfficeArea = branchOfficeAreaService.selectOne(new EntityWrapper<TBranchOfficeArea>().eq("areaCode", geocode.getDistrictCode()) |
| | | .last("LIMIT 1")); |
| | | if(null == branchOfficeArea){ |
| | | SystemConfig systemConfig = systemConfigService.selectOne(new EntityWrapper<SystemConfig>().eq("type", 7)); |
| | | if(null != systemConfig){ |
| | | JSONObject jsonObject = JSON.parseObject(systemConfig.getContent()); |
| | | userInfoWarpper.setServiceCell(jsonObject.getString("num1")); |
| | | } |
| | | }else{ |
| | | SystemConfig systemConfig = systemConfigService.selectOne(new EntityWrapper<SystemConfig>().eq("type", 8).eq("companyId", branchOfficeArea.getBranchOfficeId())); |
| | | if(null != systemConfig){ |
| | | JSONObject jsonObject = JSON.parseObject(systemConfig.getContent()); |
| | | userInfoWarpper.setServiceCell(jsonObject.getString("num2")); |
| | | } |
| | | } |
| | | }else{ |
| | | SystemConfig systemConfig = systemConfigService.selectOne(new EntityWrapper<SystemConfig>().eq("type", 7)); |
| | | if(null != systemConfig){ |
| | | JSONObject jsonObject = JSON.parseObject(systemConfig.getContent()); |
| | | userInfoWarpper.setServiceCell(jsonObject.getString("num1")); |
| | | } |
| | | }else{ |
| | | SystemConfig systemConfig = systemConfigService.selectOne(new EntityWrapper<SystemConfig>().eq("type", 8).eq("companyId", branchOfficeArea.getBranchOfficeId())); |
| | | if(null != systemConfig){ |
| | | JSONObject jsonObject = JSON.parseObject(systemConfig.getContent()); |
| | | userInfoWarpper.setServiceCell(jsonObject.getString("num2")); |
| | | } |
| | | } |
| | | |
| | | return ResponseWarpper.success(userInfoWarpper); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | |
| | | InputStream inputStream = file.getInputStream(); |
| | | String name = file.getOriginalFilename(); |
| | | name = UUIDUtil.getRandomCode() + name.substring(name.lastIndexOf(".")); |
| | | QianYunTongConfig qianYunTongConfig1 = qianYunTongConfig.getQianYunTongConfig(); |
| | | String bucketName = qianYunTongConfig1.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 file1 = FileUtil.writeFromStream(inputStream, new File(filePath + name)); |
| | | HttpRequest post = HttpUtil.createPost(adminUrl + "/upload/image"); |
| | | HttpRequest form = post.form("file", file1); |
| | | HttpResponse execute = form.execute(); |
| | | int status = execute.getStatus(); |
| | | if(200 != status){ |
| | | throw new RuntimeException("上传图片异常"); |
| | | } |
| | | //上传对象 |
| | | String key = "imgs/daijia/user/" + name; |
| | | String object = NCOSSUtil.putObject(bucketName, key, inputStream); |
| | | if (null == object) { |
| | | throw new RuntimeException("上传图片失败"); |
| | | } |
| | | return ResponseWarpper.success("https://traffic.qytzt.cn/v1/AUTH_" + qianYunTongConfig1.getAccount() + "/" + bucketName + "/" + key); |
| | | return ResponseWarpper.success(execute.body()); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | return new ResponseWarpper(500, e.getMessage()); |