feature:1.新增关联APP上传图片到机组接口
This commit is contained in:
parent
824a1e8492
commit
939aeaaabf
|
@ -26,4 +26,7 @@ public class AppImageResp extends ImageEntity {
|
||||||
|
|
||||||
@ApiModelProperty("上传用户")
|
@ApiModelProperty("上传用户")
|
||||||
private String uploadUser;
|
private String uploadUser;
|
||||||
|
|
||||||
|
@ApiModelProperty(name = "图像来源,枚举:ImageSourceEnum")
|
||||||
|
private String imageSource;
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,53 @@
|
||||||
|
package com.dite.znpt.domain.vo;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class AppImageToPartReq {
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "图片路径列表", required = true)
|
||||||
|
private List<String> imagePaths;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "部件id", required = true)
|
||||||
|
private String partId;
|
||||||
|
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
@ApiModelProperty("拍摄时间-起")
|
||||||
|
private LocalDateTime shootingTimeBegin;
|
||||||
|
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
@ApiModelProperty("拍摄时间-止")
|
||||||
|
private LocalDateTime shootingTimeEnd;
|
||||||
|
|
||||||
|
@ApiModelProperty("天气,枚举:WeatherEnum")
|
||||||
|
private String weather;
|
||||||
|
|
||||||
|
@ApiModelProperty("湿度(百分比)")
|
||||||
|
private Integer humidness;
|
||||||
|
|
||||||
|
@ApiModelProperty("温度-低")
|
||||||
|
private Double temperatureMin;
|
||||||
|
|
||||||
|
@ApiModelProperty("温度-高")
|
||||||
|
private Double temperatureMax;
|
||||||
|
|
||||||
|
@ApiModelProperty("风力等级")
|
||||||
|
private Integer windLevel;
|
||||||
|
|
||||||
|
@ApiModelProperty("拍摄方式,枚举ShootingMethodEnum")
|
||||||
|
private String shootingMethod;
|
||||||
|
|
||||||
|
@ApiModelProperty("拍摄距离")
|
||||||
|
private Integer shootingDistance;
|
||||||
|
|
||||||
|
@ApiModelProperty("采集员id")
|
||||||
|
private String collectorId;
|
||||||
|
|
||||||
|
@ApiModelProperty("采集员姓名")
|
||||||
|
private String collectorName;
|
||||||
|
}
|
|
@ -28,7 +28,7 @@ public class ImageCollectReq implements Serializable {
|
||||||
private LocalDateTime shootingTimeBegin;
|
private LocalDateTime shootingTimeBegin;
|
||||||
|
|
||||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
@ApiModelProperty("拍摄时间-讫")
|
@ApiModelProperty("拍摄时间-止")
|
||||||
private LocalDateTime shootingTimeEnd;
|
private LocalDateTime shootingTimeEnd;
|
||||||
|
|
||||||
@ApiModelProperty("天气,枚举:WeatherEnum")
|
@ApiModelProperty("天气,枚举:WeatherEnum")
|
||||||
|
|
|
@ -34,4 +34,12 @@ public interface ImageService extends IService<ImageEntity> {
|
||||||
* @return {@link List }<{@link AppImageResp }>
|
* @return {@link List }<{@link AppImageResp }>
|
||||||
*/
|
*/
|
||||||
List<AppImageResp> listAppUploadImages();
|
List<AppImageResp> listAppUploadImages();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 功能描述:链接APP上传的图像到部件
|
||||||
|
*
|
||||||
|
* @author cuizhibin
|
||||||
|
* @date 2025/06/06 09:44
|
||||||
|
**/
|
||||||
|
void linkAppImagesToPart(AppImageToPartReq partReq);
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,12 +4,14 @@ import cn.hutool.core.bean.BeanUtil;
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import cn.hutool.core.io.FileUtil;
|
import cn.hutool.core.io.FileUtil;
|
||||||
import cn.hutool.core.io.file.PathUtil;
|
import cn.hutool.core.io.file.PathUtil;
|
||||||
|
import cn.hutool.core.util.IdUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import cn.hutool.json.JSONObject;
|
import cn.hutool.json.JSONObject;
|
||||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.dite.znpt.constant.Message;
|
import com.dite.znpt.constant.Message;
|
||||||
import com.dite.znpt.domain.bo.PartFullInfoBo;
|
import com.dite.znpt.domain.bo.PartFullInfoBo;
|
||||||
|
import com.dite.znpt.domain.entity.ImageCollectEntity;
|
||||||
import com.dite.znpt.domain.entity.ImageEntity;
|
import com.dite.znpt.domain.entity.ImageEntity;
|
||||||
import com.dite.znpt.domain.entity.PartEntity;
|
import com.dite.znpt.domain.entity.PartEntity;
|
||||||
import com.dite.znpt.domain.page.PageDomain;
|
import com.dite.znpt.domain.page.PageDomain;
|
||||||
|
@ -25,6 +27,7 @@ import com.dite.znpt.service.ImageService;
|
||||||
import com.dite.znpt.service.PartService;
|
import com.dite.znpt.service.PartService;
|
||||||
import com.dite.znpt.util.EXIFUtil;
|
import com.dite.znpt.util.EXIFUtil;
|
||||||
import com.dite.znpt.util.PageUtil;
|
import com.dite.znpt.util.PageUtil;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
@ -55,6 +58,7 @@ import java.util.stream.Collectors;
|
||||||
* @date 2025/4/24/周四 13:23
|
* @date 2025/4/24/周四 13:23
|
||||||
* @description
|
* @description
|
||||||
*/
|
*/
|
||||||
|
@Slf4j
|
||||||
@Service
|
@Service
|
||||||
public class ImageServiceImpl extends ServiceImpl<ImageMapper, ImageEntity> implements ImageService {
|
public class ImageServiceImpl extends ServiceImpl<ImageMapper, ImageEntity> implements ImageService {
|
||||||
|
|
||||||
|
@ -345,10 +349,65 @@ public class ImageServiceImpl extends ServiceImpl<ImageMapper, ImageEntity> impl
|
||||||
resp.setAltitude(gps.get(2));
|
resp.setAltitude(gps.get(2));
|
||||||
}
|
}
|
||||||
resp.setUploadUser(split.get(4));
|
resp.setUploadUser(split.get(4));
|
||||||
resp.setImageType(split.get(2));
|
resp.setImageSource(split.get(2));
|
||||||
|
|
||||||
respList.add(resp);
|
respList.add(resp);
|
||||||
}
|
}
|
||||||
return respList;
|
return respList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 功能描述:链接APP上传的图像到部件
|
||||||
|
*
|
||||||
|
* @author cuizhibin
|
||||||
|
* @date 2025/06/06 09:44
|
||||||
|
**/
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public void linkAppImagesToPart(AppImageToPartReq partReq) {
|
||||||
|
PartEntity part = partService.getById(partReq.getPartId());
|
||||||
|
if (Objects.isNull(part)) {
|
||||||
|
throw new ServiceException(Message.PART_ID_IS_NOT_EXIST);
|
||||||
|
}
|
||||||
|
// 查询图片关联记录
|
||||||
|
List<ImageEntity> imageList = new ArrayList<>();
|
||||||
|
CollUtil.split(partReq.getImagePaths(), 1000).forEach(paths -> {
|
||||||
|
imageList.addAll(lambdaQuery().in(ImageEntity::getImagePath, paths).list());
|
||||||
|
});
|
||||||
|
partReq.getImagePaths().removeAll(imageList.stream().map(ImageEntity::getImagePath).toList());
|
||||||
|
|
||||||
|
String collectId = IdUtil.simpleUUID();
|
||||||
|
imageList.forEach(imageEntity -> {
|
||||||
|
imageEntity.setPartId(partReq.getPartId());
|
||||||
|
imageEntity.setCollectId(collectId);
|
||||||
|
});
|
||||||
|
baseMapper.updateById(imageList);
|
||||||
|
// 新增
|
||||||
|
List<ImageEntity> newImageList = new ArrayList<>();
|
||||||
|
partReq.getImagePaths().forEach(path -> {
|
||||||
|
ImageEntity imageEntity = new ImageEntity();
|
||||||
|
String absolutePath = permPath + StrUtil.removePrefix(path, "/static/image/");
|
||||||
|
try {
|
||||||
|
ImageReq imageReq = imageRespBuilder(absolutePath);
|
||||||
|
BeanUtil.copyProperties(imageReq, imageEntity);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.debug("读取文件信息失败:{}", path);
|
||||||
|
imageEntity.setImageName(FileUtil.getName(absolutePath));
|
||||||
|
BigDecimal imageSize = new BigDecimal(FileUtil.size(FileUtil.file(absolutePath))).divide(new BigDecimal(1024*1024), 4, RoundingMode.HALF_UP);
|
||||||
|
imageEntity.setImageSize(imageSize.toString().concat("M"));
|
||||||
|
}
|
||||||
|
if (StrUtil.isEmpty(imageEntity.getLongitude()) || imageEntity.getLongitude().equals("0.0")) {
|
||||||
|
List<String> split = StrUtil.split(path, StrUtil.SLASH, true, true);
|
||||||
|
List<String> gps = StrUtil.split(split.get(5), " ");
|
||||||
|
imageEntity.setLongitude(gps.get(0));
|
||||||
|
imageEntity.setLatitude(gps.get(1));
|
||||||
|
imageEntity.setAltitude(gps.get(2));
|
||||||
|
}
|
||||||
|
imageEntity.setImagePath(path);
|
||||||
|
imageEntity.setPartId(partReq.getPartId());
|
||||||
|
imageEntity.setCollectId(collectId);
|
||||||
|
newImageList.add(imageEntity);
|
||||||
|
});
|
||||||
|
imageCollectService.save(BeanUtil.copyProperties(partReq, ImageCollectEntity.class));
|
||||||
|
baseMapper.insert(newImageList);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,7 +51,6 @@ public class EXIFUtil {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
System.out.println("**********" + jsonObject.toString());
|
|
||||||
return jsonObject;
|
return jsonObject;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -143,12 +143,6 @@ public class CommonController {
|
||||||
return Result.ok(imageService.batchUploadCommonImage(imageSource, workReq, files));
|
return Result.ok(imageService.batchUploadCommonImage(imageSource, workReq, files));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation(value = "获取APP上传的图片列表", httpMethod = "POST")
|
|
||||||
@GetMapping("/list/app-upload-images")
|
|
||||||
public Result<List<AppImageResp>> listAppUploadImages() throws IOException {
|
|
||||||
return Result.ok(imageService.listAppUploadImages());
|
|
||||||
}
|
|
||||||
|
|
||||||
@ApiOperation(value = "查询菜单类型", httpMethod = "GET")
|
@ApiOperation(value = "查询菜单类型", httpMethod = "GET")
|
||||||
@GetMapping("/list/menu-type")
|
@GetMapping("/list/menu-type")
|
||||||
public Result listMenuType(){
|
public Result listMenuType(){
|
||||||
|
|
|
@ -13,6 +13,7 @@ import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
import java.io.IOException;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -76,4 +77,17 @@ public class ImageController {
|
||||||
imageService.delete(imageId);
|
imageService.delete(imageId);
|
||||||
return Result.ok();
|
return Result.ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "获取APP上传的图片列表", httpMethod = "POST")
|
||||||
|
@GetMapping("/list/app-upload-images")
|
||||||
|
public Result<List<AppImageResp>> listAppUploadImages() throws IOException {
|
||||||
|
return Result.ok(imageService.listAppUploadImages());
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "关联APP上传图片到机组", httpMethod = "POST")
|
||||||
|
@PostMapping("/linkAppImagesToPart")
|
||||||
|
public Result linkAppImagesToPart(@RequestBody AppImageToPartReq partReq) {
|
||||||
|
imageService.linkAppImagesToPart(partReq);
|
||||||
|
return Result.ok();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue