bug修改

This commit is contained in:
haozq 2025-10-09 17:57:08 +08:00
parent 19962803e5
commit 51042138cf
9 changed files with 3716 additions and 28 deletions

View File

@ -28,7 +28,6 @@ public class ImageCaptionController extends BaseController {
@Autowired
private ImageCaptionService service;
@GetMapping("/list")
public TableDataInfo list(UserOperaVo vo)
{
@ -37,7 +36,6 @@ public class ImageCaptionController extends BaseController {
return getDataTable(list);
}
/**
* 确认数据
* @return
@ -64,6 +62,15 @@ public class ImageCaptionController extends BaseController {
public AjaxResult getSelected(UserOperaVo vo) {
return service.getSelected(vo);
}
/**
* 删除图片
* @return
*/
@PostMapping("/deleteFile")
public AjaxResult deleteFile(UserOperaVo vo) {
return service.deleteFile(vo);
}
/**
* 侧边栏历史对话
* @return

View File

@ -71,7 +71,7 @@ public class AlgorithmVo {
vo.setImageNum(length);
vo.setOperaType(operaType);
vo.setOperaId(operaId);
vo.setOperaId(userId);
vo.setUserId(userId);
vo.setCreateTime(createTime);
vo.setName(operaName);
}

View File

@ -30,6 +30,8 @@ public interface ImageCaptionMapper {
*/
void addUpLoadImage(@Param("list") List<SysFile> fileList, @Param("id") String id, @Param("createTime")String createTime, @Param("operaType")String operaType);
void addSureLoadImage(@Param("list") List<SysFile> fileList, @Param("id") String id, @Param("createTime")String createTime, @Param("operaType")String operaType);
/**
* 更新 数据
* @param vo
@ -107,4 +109,19 @@ public interface ImageCaptionMapper {
* @return
*/
List<UploadFileVo> getAllImageList(UserOperaVo vo);
/**
* 查询 图片数据
* @param vo
* @return
*/
List<UploadFileVo> getFileList(UserOperaVo vo);
void addSureFile(@Param("list") List<UploadFileVo> fileList);
/**
* 删除图片
* @param imageId
*/
void deleteFile(@Param("list") List<String> imageId);
}

View File

@ -70,4 +70,11 @@ public interface ImageCaptionService {
* @return
*/
List<UploadFileVo> getAllImagelist(UserOperaVo vo);
/**
* 删除图片
* @param vo
* @return
*/
AjaxResult deleteFile(UserOperaVo vo);
}

View File

@ -67,7 +67,7 @@ public class ImageCaptionServiceImpl implements ImageCaptionService {
//操作日期
List<SysFile> fileList=new ArrayList<>();
UserOperaVo userOperaVo=new UserOperaVo(userId,operaName,createTime,BJ_TYPE);
AjaxResult result= addOperaData(multipartFile,vo,userId,operaName,createTime,BJ_TYPE);
AjaxResult result= addOperaData(multipartFile,vo,userId,operaName,createTime,fileList,userOperaVo,BJ_TYPE);
if(result.isError()){
return result;
}
@ -75,8 +75,8 @@ public class ImageCaptionServiceImpl implements ImageCaptionService {
List<ImageRecognize> list= algorithmService.getImageList(fileList,operaName);
//更新标记的数量 和未标记的数量,同时更新 标记图片地址
updateImage(list,vo);
// 查询数据历史集合
List<UserOperaVo> hisImageList=getUploadFileList(userOperaVo);
// 查询数据历史集合
List<UserOperaVo> hisImageList=getUploadFileList(userOperaVo);
return AjaxResult.success(hisImageList);
}catch (Exception e){
log.error(e.getMessage(),e);
@ -103,7 +103,7 @@ public class ImageCaptionServiceImpl implements ImageCaptionService {
//操作日期
//文件路径
UserOperaVo userOperaVo=new UserOperaVo(userId,operaName,createTime,PG_TYPE);
AjaxResult result= addOperaData(multipartFile,vo,userId,operaName,createTime,PG_TYPE);
AjaxResult result= addOperaData(multipartFile,vo,userId,operaName,createTime,fileList,userOperaVo,PG_TYPE);
if(result.isError()){
return result;
}
@ -132,12 +132,10 @@ public class ImageCaptionServiceImpl implements ImageCaptionService {
* @param operaType
* @return
*/
public AjaxResult addOperaData(MultipartFile[] multipartFile, AlgorithmVo vo,String userId,String operaName,String createTime,String operaType) {
public AjaxResult addOperaData(MultipartFile[] multipartFile, AlgorithmVo vo,String userId,String operaName,String createTime, List<SysFile> fileList, UserOperaVo userOperaVo,String operaType) {
try{
//文件路径
String path="image/"+year+"/"+month+"/"+day+"/";
List<SysFile> fileList=new ArrayList<>();
UserOperaVo userOperaVo=new UserOperaVo(userId,operaName,createTime,BJ_TYPE);
if(StringUtils.isEmpty(vo.getId())){
Integer addOperaNum=mapper.addUserOperaVo(userOperaVo);
if(addOperaNum==null || addOperaNum==0){
@ -146,13 +144,13 @@ public class ImageCaptionServiceImpl implements ImageCaptionService {
}else{
userOperaVo.setId(vo.getId());
}
AlgorithmVo.addSource(vo,multipartFile.length,userOperaVo.getId(),createTime,BJ_TYPE,userId,operaName);
AlgorithmVo.addSource(vo,multipartFile.length,userOperaVo.getId(),createTime,operaType,userId,operaName);
//操作记录
Integer addedAlgorithmNum= mapper.addAlgorithm(vo);
if(addedAlgorithmNum==null || addedAlgorithmNum==0){
return AjaxResult.error("操作记录添加失败!");
}else{
AjaxResult result=ImageMultipartFile(multipartFile,path,createTime,userId,fileList,vo.getId(),BJ_TYPE);
AjaxResult result=ImageMultipartFile(multipartFile,path,createTime,userId,fileList,vo.getId(),operaType);
if(result.isError()){
return result;
}
@ -203,7 +201,13 @@ public class ImageCaptionServiceImpl implements ImageCaptionService {
//查询 每次历史的 图片集合
List<UploadFileVo> fileVoList=mapper.getImageListDetailsHistory(userOperaVo2);
for (UploadFileVo obj : fileVoList) {
String url=minioUtil.getFileUrl(obj.getBucketName(),obj.getBjFilePath(),60*60*7);
String url;
if(BJ_TYPE.equals(obj.getType())){
url=minioUtil.getFileUrl(obj.getBucketName(),obj.getBjFilePath(),60*60*7);
} else {
url=minioUtil.getFileUrl(obj.getBucketName(),obj.getFilePath(),60*60*7);
}
obj.setBjUrl(url);
}
userOperaVo2.setFileVoList(fileVoList);
@ -238,12 +242,16 @@ public class ImageCaptionServiceImpl implements ImageCaptionService {
// 转换为可读格式如KB/MB
String humanReadableSize = convertToHumanReadable(sizeInBytes);
SysFile sysFile=minioUtil.uploadFile(file,folderPath);
sysFile.setName(uuid+"."+suffix);
SysFile.addSource(sysFile,userId,originFileName,humanReadableSize);
fileList.add(sysFile);
}
if(fileList.size()!=multipartFile.length){
return AjaxResult.error("文件上传失败!");
}
if(PG_TYPE.equals(operaType)){
mapper.addSureLoadImage(fileList,id,createTime,operaType);
}
mapper.addUpLoadImage(fileList,id,createTime,operaType);
return AjaxResult.success("上传成功!");
}catch (Exception e){
@ -298,9 +306,18 @@ public class ImageCaptionServiceImpl implements ImageCaptionService {
public AjaxResult updateImageSure(UserOperaVo vo) {
try{
vo.setUserId(SecurityUtils.getUserId().toString());
vo.setIsSure("1");
mapper.updateAlgorithmSure(vo);
//跟新图片状态
mapper.updateImage(vo.getImageId());
if(StringUtils.isNotEmpty(vo.getImageId())){
mapper.updateImage(vo.getImageId());
}
//查询 历史确认的图片
List<UploadFileVo> fileList=mapper.getFileList(vo);
//添加图片到标记
mapper.addSureFile(fileList);
}catch (Exception e){
log.error(e.getMessage(),e);
}
@ -370,6 +387,22 @@ public class ImageCaptionServiceImpl implements ImageCaptionService {
return Collections.emptyList();
}
/**
* 删除图片
* @param vo
* @return
*/
@Override
public AjaxResult deleteFile(UserOperaVo vo) {
try{
mapper.deleteFile(vo.getImageId());
return AjaxResult.success("删除成功");
}catch (Exception e){
log.error(e.getMessage(),e);
}
return AjaxResult.error("删除失败");
}
// 辅助方法字节转可读格式
private String convertToHumanReadable(long bytes) {
if (bytes < 1024) return bytes + " B";

View File

@ -29,6 +29,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
#{item.name},0,#{createTime},#{operaType},#{item.bjFilePath},#{item.fileSize},#{item.createUser} )
</foreach>
</insert>
<insert id="addSureLoadImage">
insert into tb_sure_file(
id, algorithm_id,original_name,file_path,bucket_name,
file_name,is_active,create_time,file_type,bj_file_path,file_size,create_user
) values
<foreach collection="list" item="item" separator=",">
(#{item.id}, #{id},#{item.originName},#{item.url},#{item.bucketName},
#{item.name},0,#{createTime},#{operaType},#{item.bjFilePath},#{item.fileSize},#{item.createUser} )
</foreach>
</insert>
<insert id="addImageRecognize">
insert into tb_image_recognize(
image_id,
@ -43,6 +53,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
type
)values (#{imageId},#{contentImage},#{overallScore},#{clarity},#{cleanliness},#{compressMarks},#{impression},#{balance},#{detail},#{type})
</insert>
<update id="updateAlgorithm">
update tb_algorithm set bz_num=#{bzNum},wbz_num=#{wbzNum} where id=#{id}
</update>
@ -51,8 +62,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
update tb_upload_file set bj_file_path=#{imagePath} where id=#{imageId}
</update>
<update id="updateAlgorithmSure">
update tb_algorithm set is_sure=#{isSure}, sure_user=#{createUser} where oper_id=#{id}
update tb_algorithm set is_sure=#{isSure}, sure_user=#{userId} where oper_id=#{id}
</update>
<update id="updateImage">
update tb_upload_file set is_active=1
@ -61,6 +71,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
#{item}
</foreach>
</update>
<update id="deleteFile">
update tb_sure_file set is_active=1
where id in
<foreach collection="list" item="item" close=")" open="(" separator=",">
#{item}
</foreach>
</update>
<select id="getImageList" resultType="com.bonus.business.domain.UserOperaVo">
select tuo.id, tuo.type, tuo.oper_name operaName,
tuo.oper_time operaTime, tuo.user_id , tuo.oper_type
@ -93,7 +110,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
tir.cleanliness,tir.compress_marks compressMarks,tir.impression,
tir.balance,tir.detail,tir.type
from tb_upload_file file
left join tb_image_recognize tir on tir.image_id=file.id
left join tb_image_recognize tir on tir.image_id=file.id
WHERE file.algorithm_id=#{id}
</select>
@ -123,7 +140,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
tir.cleanliness,tir.compress_marks compressMarks,tir.impression,
tir.balance,tir.detail,tir.type
from tb_upload_file file
left join tb_image_recognize tir on tir.image_id=file.id
left join tb_image_recognize tir on tir.image_id=file.id
WHERE file.id in
<foreach collection="list" item="item" close=")" open="(" separator=",">
#{item}
@ -139,7 +156,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</select>
<!--查询图片-->
<select id="getAllImageList" resultType="com.bonus.file.vo.UploadFileVo">
select file.id imageId,
select file.id imageId,tuo.oper_name operaName,
file.algorithm_id algorithmId, file.original_name originalName,
file.file_path filePath,
file.bucket_name bucketName, file.file_name fileName,
@ -149,24 +166,53 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
tir.cleanliness,tir.compress_marks compressMarks,tir.impression,
tir.balance,tir.detail,tir.type,su.user_name userName
from tb_algorithm tam
left join tb_upload_file file on file.algorithm_id=tam.id
left join tb_user_oper tuo on tuo.id=tam.oper_id
left join tb_sure_file file on file.algorithm_id=tam.id
left join tb_image_recognize tir on tir.image_id=file.id
left join sys_user su on su.user_id=tam.sure_user
where file.type=#{operaType}
left join sys_user su on su.user_id=tam.sure_user
where tam.oper_type=#{operaType} and file.is_active='0'
<if test='createUser!=null and createUser!=""'>
and tam.user_id=#{createUser}
</if>
<!--查询确认的 和去确认不需要的-->
<if test='operaType==1 or operaType=="1"'>
and file.is_active='0' and tam.is_sure=1
</if>
<if test="operaTime!=null and operaTime!=''">
and DATE(tam.create_time) =#{operaTime}
</if>
<if test="userName!=null and userName!=''">
and su.user_name like concat('%',#{userName},'%')
</if>
<if test="operaName!=null and operaName!=''">
and tir.content_image like concat('%',#{operaName},'%')
</if>
</select>
<select id="getFileList" resultType="com.bonus.file.vo.UploadFileVo">
select file.id imageId,
file.algorithm_id algorithmId,
file.original_name originalName,
file.file_path filePath,
file.bucket_name bucketName,
file.file_name fileName,
file.is_active isActive,
file. update_time ,
file.create_time createTime,
file.file_type fileType,
file.bj_file_path bjFilePath,
file. file_size fileSize,
file.create_user createUser
from tb_upload_file file
left join tb_algorithm ta on ta.id=file.algorithm_id
WHERE file.is_active=0
and ta.oper_id=#{id}
</select>
<insert id="addSureFile">
insert into tb_sure_file(
id, algorithm_id,original_name,file_path,bucket_name,
file_name,is_active,create_time,file_type,bj_file_path,file_size,create_user
) values
<foreach collection="list" item="item" separator=",">
(#{item.imageId}, #{item.algorithmId},#{item.originalName},#{item.filePath},#{item.bucketName},
#{item.fileName},#{item.isActive},#{item.createTime},#{item.fileType},#{item.bjFilePath},#{item.fileSize},#{item.createUser} )
</foreach>
</insert>
</mapper>

View File

@ -290,13 +290,19 @@ public class MinioUtil {
ZipOutputStream zos = new ZipOutputStream(baos)) {
// 压缩每个文件
for (UploadFileVo objectName : objectNames) {
String filePath;
if("1".equals(objectName.getType())){
filePath = objectName.getBjFilePath();
}else{
filePath=objectName.getFilePath();
}
try (InputStream inputStream = minioClient.getObject(GetObjectArgs.builder()
.bucket(minioConfig.getBucketName())
.object(objectName.getBjFilePath())
.object(filePath)
.build())) {
// 添加 ZipEntry
zos.putNextEntry(new ZipEntry(objectName.getOriginalName()));
zos.putNextEntry(new ZipEntry(objectName.getFileName()));
byte[] buffer = new byte[1024];
int len;
while ((len = inputStream.read(buffer)) > 0) {

View File

@ -5,6 +5,8 @@ import lombok.Data;
@Data
public class UploadFileVo {
private String operaName;
private String imageId;
/**
* 图片名称
@ -93,5 +95,7 @@ public class UploadFileVo {
*/
private String userName;
private String createTime;
}

3568
sql/image_caption.sql Normal file

File diff suppressed because it is too large Load Diff