| | |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.Synchronized; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.http.MediaType; |
| | | import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.imageio.ImageIO; |
| | | import javax.imageio.stream.ImageOutputStream; |
| | | import java.awt.*; |
| | | import java.awt.image.BufferedImage; |
| | | import java.io.*; |
| | | import java.text.SimpleDateFormat; |
| | | import java.time.LocalDate; |
| | | import java.time.LocalDateTime; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.util.Date; |
| | | import java.util.concurrent.CompletableFuture; |
| | | import java.util.concurrent.atomic.AtomicReference; |
| | | |
| | | |
| | | /** |
| | |
| | | @ApiImplicitParam(value = "文件", name = "file", dataType = "MultipartFile", required = true) |
| | | }) |
| | | public CompletableFuture<R<String>> pic(@RequestParam("file") MultipartFile file, String longitude, String latitude) { |
| | | System.out.println("文件上传加水印=====>"+longitude+"====>"+latitude); |
| | | // 参数校验 |
| | | if (file == null || file.isEmpty()) { |
| | | return CompletableFuture.completedFuture(R.fail("文件不能为空")); |
| | | } |
| | | |
| | | Result<String> datas = new Result<>(); |
| | | |
| | | if (longitude == null || longitude.isEmpty() || latitude == null || latitude.isEmpty()) { |
| | | return CompletableFuture.completedFuture(R.fail("经纬度参数不能为空")); |
| | | datas.setDatas("地址获取失败"); |
| | | } |
| | | |
| | | return CompletableFuture.supplyAsync(() -> { |
| | |
| | | // 获取地址信息 |
| | | Result<String> addressResult = GaoDeMapUtil.getAddress(longitude, latitude); |
| | | if (addressResult == null || addressResult.getDatas() == null) { |
| | | return R.fail("无法获取地址信息"); |
| | | datas.setDatas("地址获取失败"); |
| | | }else { |
| | | datas.setDatas(addressResult.getDatas()); |
| | | } |
| | | |
| | | // 获取当前时间 |
| | |
| | | log.info("===========" + dateWatermark); |
| | | |
| | | // 给图片加水印 |
| | | MultipartFile watermarkFile = FileImageWatermarkUtils.markWithContent(file, dateWatermark, addressResult.getDatas()); |
| | | MultipartFile watermarkFile = FileImageWatermarkUtils.markWithContent(file, dateWatermark, datas.getDatas()); |
| | | log.info("水印添加成功"); |
| | | |
| | | // 上传到腾讯云COS |