添加备注及图片宽高
This commit is contained in:
parent
755ad9f8d3
commit
1015b6b5bd
|
|
@ -1,5 +1,6 @@
|
|||
package com.bonus;
|
||||
|
||||
import com.bonus.common.utils.SecurityUtils;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
||||
|
|
@ -16,6 +17,9 @@ public class BonusApplication
|
|||
{
|
||||
public static void main(String[] args)
|
||||
{
|
||||
|
||||
String pwd = SecurityUtils.encryptPassword("Bonus@admin123!");
|
||||
System.err.println(pwd);
|
||||
// System.setProperty("spring.devtools.restart.enabled", "false");
|
||||
SpringApplication.run(BonusApplication.class, args);
|
||||
System.err.println("(♥◠‿◠)ノ゙ 江苏图片自动标注后台服务启动成功 ლ(´ڡ`ლ)゙ \n" +
|
||||
|
|
|
|||
|
|
@ -138,16 +138,16 @@ Sm4:
|
|||
KEY: 78d1295afa99449b99d6f83820e6965c
|
||||
IV: f555adf6c01d0ab0761e626a2dae34a2
|
||||
|
||||
#minio:
|
||||
# url: http://47.92.234.255:9090
|
||||
# endpoint: http://47.92.234.255:9090
|
||||
# accessKey: minio
|
||||
# secretKey: Bonus@admin123!
|
||||
# bucketName: image
|
||||
|
||||
minio:
|
||||
url: http://192.168.0.14:9090
|
||||
endpoint: http://192.168.0.14:9090
|
||||
url: http://47.92.234.255:9090
|
||||
endpoint: http://47.92.234.255:9090
|
||||
accessKey: minio
|
||||
secretKey: bonus@admin123
|
||||
secretKey: Bonus@admin123!
|
||||
bucketName: image
|
||||
|
||||
#minio:
|
||||
# url: http://192.168.0.14:9090
|
||||
# endpoint: http://192.168.0.14:9090
|
||||
# accessKey: minio
|
||||
# secretKey: bonus@admin123
|
||||
# bucketName: image
|
||||
|
|
|
|||
|
|
@ -43,6 +43,10 @@
|
|||
<artifactId>commons-compress</artifactId>
|
||||
<version>1.20</version> <!-- 使用最新的版本 -->
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.glassfish.jaxb</groupId>
|
||||
<artifactId>jaxb-runtime</artifactId>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
|
|
|
|||
|
|
@ -2,11 +2,17 @@ package com.bonus.business.domain;
|
|||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 算法信息类
|
||||
*/
|
||||
@Data
|
||||
public class AlgorithmVo {
|
||||
|
||||
|
||||
|
||||
private String remark;
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
|
|
@ -66,6 +72,8 @@ public class AlgorithmVo {
|
|||
|
||||
private int fileNum;
|
||||
|
||||
private List<String> hwData;
|
||||
|
||||
public static void addSource(AlgorithmVo vo, int length, String operaId, String createTime, String operaType, String userId, String operaName) {
|
||||
vo.setBzNum(0);
|
||||
vo.setWbzNum(0);
|
||||
|
|
|
|||
|
|
@ -4,6 +4,12 @@ import lombok.Data;
|
|||
|
||||
@Data
|
||||
public class ImageRecognize {
|
||||
|
||||
private String remark;
|
||||
|
||||
private String dataType;
|
||||
|
||||
private String jsonData;
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -7,6 +7,8 @@ import java.util.List;
|
|||
|
||||
@Data
|
||||
public class UserOperaVo {
|
||||
|
||||
private String remark;
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -28,9 +28,9 @@ public interface ImageCaptionMapper {
|
|||
* @param fileList
|
||||
* @param id
|
||||
*/
|
||||
void addUpLoadImage(@Param("list") List<SysFile> fileList, @Param("id") String id, @Param("createTime")String createTime, @Param("operaType")String operaType);
|
||||
void addUpLoadImage(@Param("list") List<SysFile> fileList, @Param("id") String id, @Param("createTime")String createTime, @Param("operaType")String operaType, @Param("remark")String remark);
|
||||
|
||||
void addSureLoadImage(@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("remark")String remark);
|
||||
|
||||
/**
|
||||
* 更新 数据
|
||||
|
|
|
|||
|
|
@ -58,10 +58,14 @@ public class AlgorithmService {
|
|||
JSONArray array=jsonObject.getJSONArray("data");
|
||||
for (int i=0;i<array.size();i++){
|
||||
ImageRecognize vo = new ImageRecognize();
|
||||
JSONArray detections=array.getJSONObject(i).getJSONArray("detections");
|
||||
String jsondata=JSON.toJSONString(detections);
|
||||
//获取路径及采集数据
|
||||
String path=array.getJSONObject(i).getString("image");
|
||||
String type=array.getJSONObject(i).getString("type");
|
||||
String imagePath=array.getJSONObject(i).getString("annotated_image_path");
|
||||
vo.setJsonData(jsondata);
|
||||
vo.setDataType("0");
|
||||
if(type==null || type.isEmpty()){
|
||||
//获取到图片地址
|
||||
SysFile sysFile=entityMaps.get(path);
|
||||
|
|
|
|||
|
|
@ -16,6 +16,8 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.*;
|
||||
import java.nio.file.Files;
|
||||
import java.util.ArrayList;
|
||||
|
|
@ -188,8 +190,21 @@ public class CompressUploaderService {
|
|||
long sizeInBytes = file.length();
|
||||
// 转换为可读格式(如KB/MB)
|
||||
String humanReadableSize = convertToHumanReadable(sizeInBytes);
|
||||
|
||||
//上传到minio
|
||||
SysFile sysFile=minioUtil.uploadFile(file,folderPath);
|
||||
BufferedImage image = ImageIO.read(file);
|
||||
if (image != null) {
|
||||
// 获取图片的宽度和高度
|
||||
int width = image.getWidth();
|
||||
int height = image.getHeight();
|
||||
sysFile.setWidth(width+"");
|
||||
sysFile.setHeight(height+"");
|
||||
System.out.println("Width: " + width + ", Height: " + height);
|
||||
} else {
|
||||
System.out.println("Image not loaded successfully.");
|
||||
}
|
||||
|
||||
sysFile.setName(uuid+"."+suffix);
|
||||
sysFile.setOriginName(originFileName);
|
||||
sysFile.setFileSize(humanReadableSize);
|
||||
|
|
|
|||
|
|
@ -19,10 +19,12 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipInputStream;
|
||||
import javax.imageio.ImageIO;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.PushBuilder;
|
||||
import java.util.ArrayList;
|
||||
|
|
@ -259,7 +261,7 @@ public class ImageCaptionServiceImpl implements ImageCaptionService {
|
|||
if(addedAlgorithmNum==null || addedAlgorithmNum==0){
|
||||
return AjaxResult.error("操作记录添加失败!");
|
||||
}else{
|
||||
AjaxResult result=ImageMultipartFile(multipartFile,path,createTime,userId,fileList,vo.getId(),operaType,isZip);
|
||||
AjaxResult result=ImageMultipartFile(multipartFile,path,createTime,userId,fileList,vo.getId(),operaType,isZip,vo.getRemark());
|
||||
if(result.isError()){
|
||||
return result;
|
||||
}
|
||||
|
|
@ -288,6 +290,7 @@ public class ImageCaptionServiceImpl implements ImageCaptionService {
|
|||
} else {
|
||||
typedCount++;
|
||||
}
|
||||
|
||||
//跟新图片地址
|
||||
mapper.updateImageAddress(imageRecognize);
|
||||
//添加记录
|
||||
|
|
@ -312,6 +315,8 @@ public class ImageCaptionServiceImpl implements ImageCaptionService {
|
|||
for (UploadFileVo obj : fileVoList) {
|
||||
String url;
|
||||
if(BJ_TYPE.equals(obj.getType())){
|
||||
String imageUrl=minioUtil.getFileUrl(obj.getBucketName(),obj.getFilePath(),60*60*7);
|
||||
obj.setImageUrl(imageUrl);
|
||||
url=minioUtil.getFileUrl(obj.getBucketName(),obj.getBjFilePath(),60*60*7);
|
||||
} else {
|
||||
url=minioUtil.getFileUrl(obj.getBucketName(),obj.getFilePath(),60*60*7);
|
||||
|
|
@ -340,7 +345,7 @@ public class ImageCaptionServiceImpl implements ImageCaptionService {
|
|||
* @param operaType
|
||||
* @return
|
||||
*/
|
||||
public AjaxResult ImageMultipartFile(MultipartFile[] multipartFile ,String path,String createTime,String userId,List<SysFile> fileList ,String id,String operaType,boolean isZip){
|
||||
public AjaxResult ImageMultipartFile(MultipartFile[] multipartFile ,String path,String createTime,String userId,List<SysFile> fileList ,String id,String operaType,boolean isZip,String remark){
|
||||
try{
|
||||
if(isZip){
|
||||
List<SysFile> list=compressUploaderService.uploadAndExtract(multipartFile[0],path);
|
||||
|
|
@ -359,6 +364,16 @@ public class ImageCaptionServiceImpl implements ImageCaptionService {
|
|||
// 转换为可读格式(如KB/MB)
|
||||
String humanReadableSize = convertToHumanReadable(sizeInBytes);
|
||||
SysFile sysFile=minioUtil.uploadFile(file,folderPath);
|
||||
BufferedImage img = ImageIO.read(file.getInputStream());
|
||||
if (img != null) {
|
||||
int width = img.getWidth();
|
||||
int height = img.getHeight();
|
||||
sysFile.setWidth(width+"");
|
||||
sysFile.setHeight(height+"");
|
||||
System.out.println("Width: " + width + ", Height: " + height);
|
||||
} else {
|
||||
System.out.println("Image not loaded successfully.");
|
||||
}
|
||||
sysFile.setName(uuid+"."+suffix);
|
||||
SysFile.addSource(sysFile,userId,originFileName,humanReadableSize);
|
||||
fileList.add(sysFile);
|
||||
|
|
@ -371,9 +386,9 @@ public class ImageCaptionServiceImpl implements ImageCaptionService {
|
|||
}
|
||||
|
||||
if(PG_TYPE.equals(operaType)){
|
||||
mapper.addSureLoadImage(fileList,id,createTime,operaType);
|
||||
mapper.addSureLoadImage(fileList,id,createTime,operaType,remark);
|
||||
}
|
||||
mapper.addUpLoadImage(fileList,id,createTime,operaType);
|
||||
mapper.addUpLoadImage(fileList,id,createTime,operaType,remark);
|
||||
return AjaxResult.success("上传成功!");
|
||||
}catch (Exception e){
|
||||
log.error(e.getMessage(),e);
|
||||
|
|
|
|||
|
|
@ -16,27 +16,27 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
</insert>
|
||||
<insert id="addAlgorithm" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into tb_algorithm(
|
||||
oper_id, name, create_time, bz_num, wbz_num, user_id,image_num, is_sure,oper_type
|
||||
)values (#{operaId},#{name},#{createTime},#{bzNum},#{wbzNum},#{userId},#{imageNum},#{isSure},#{operaType})
|
||||
oper_id, name, create_time, bz_num, wbz_num, user_id,image_num, is_sure,oper_type,remark
|
||||
)values (#{operaId},#{name},#{createTime},#{bzNum},#{wbzNum},#{userId},#{imageNum},#{isSure},#{operaType},#{remark})
|
||||
</insert>
|
||||
<insert id="addUpLoadImage">
|
||||
insert into tb_upload_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
|
||||
file_name,is_active,create_time,file_type,bj_file_path,file_size,create_user,remark,height,width
|
||||
) 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} )
|
||||
#{item.name},0,#{createTime},#{operaType},#{item.bjFilePath},#{item.fileSize},#{item.createUser},#{remark},#{item.height},#{item.width} )
|
||||
</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
|
||||
file_name,is_active,create_time,file_type,bj_file_path,file_size,create_user,remark,data_type,json_data,height,width
|
||||
) 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} )
|
||||
#{item.name},0,#{createTime},#{operaType},#{item.bjFilePath},#{item.fileSize},#{item.createUser},#{remark},#{item.dataType},#{item.jsonData},#{item.height},#{item.width} )
|
||||
</foreach>
|
||||
</insert>
|
||||
<insert id="addImageRecognize">
|
||||
|
|
@ -50,8 +50,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
impression,
|
||||
balance,
|
||||
detail,
|
||||
type
|
||||
)values (#{imageId},#{contentImage},#{overallScore},#{clarity},#{cleanliness},#{compressMarks},#{impression},#{balance},#{detail},#{type})
|
||||
type,json_data,data_type
|
||||
)values (#{imageId},#{contentImage},#{overallScore},#{clarity},#{cleanliness},#{compressMarks},#{impression},#{balance},#{detail},#{type},#{jsonData},#{dataType})
|
||||
</insert>
|
||||
|
||||
<update id="updateAlgorithm">
|
||||
|
|
@ -59,7 +59,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
</update>
|
||||
|
||||
<update id="updateImageAddress">
|
||||
update tb_upload_file set bj_file_path=#{imagePath} where id=#{imageId}
|
||||
update tb_upload_file set bj_file_path=#{imagePath},json_data=#{jsonData},data_type=#{dataType} where id=#{imageId}
|
||||
</update>
|
||||
<update id="updateAlgorithmSure">
|
||||
update tb_algorithm set is_sure=#{isSure}, sure_user=#{userId} where id=#{id}
|
||||
|
|
@ -95,7 +95,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<select id="getImageListHistory" resultType="com.bonus.business.domain.UserOperaVo">
|
||||
select tam.id, tam.oper_type, tam.name operaName,tam.oper_id operaId,
|
||||
tam.create_time operaTime, tam.user_id , tam.oper_type,
|
||||
tam.image_num imageNum ,tam.bz_num bzNum,tam.wbz_num wbzNum,tam.is_sure isSure
|
||||
tam.image_num imageNum ,tam.bz_num bzNum,tam.wbz_num wbzNum,tam.is_sure isSure,tam.remark
|
||||
from tb_algorithm tam
|
||||
where tam.oper_id=#{id}
|
||||
</select>
|
||||
|
|
@ -133,7 +133,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
file.bj_file_path bjFilePath, file.file_size fileSize,
|
||||
tir.content_image contentImage,ROUND(tir.overall_score, 2) overallScore,tir.clarity,
|
||||
tir.cleanliness,tir.compress_marks compressMarks,tir.impression,
|
||||
tir.balance,tir.detail,tir.type
|
||||
tir.balance,tir.detail,tir.type, file.remark,file.height,file.width,
|
||||
file.json_data jsonData ,file.data_type dataType
|
||||
from tb_upload_file file
|
||||
left join tb_image_recognize tir on tir.image_id=file.id
|
||||
left join da_ky_sys_dict_data sdd on sdd.dict_type='bz_data'
|
||||
|
|
@ -184,7 +185,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
file.bj_file_path bjFilePath, file.file_size fileSize,
|
||||
tir.content_image contentImage,ROUND(tir.overall_score, 2) overallScore,tir.clarity,
|
||||
tir.cleanliness,tir.compress_marks compressMarks,tir.impression,
|
||||
tir.balance,tir.detail,tir.type,su.user_name userName,file.create_time createTime
|
||||
tir.balance,tir.detail,tir.type,su.user_name userName,file.create_time createTime,
|
||||
file.remark,file.height,file.width,
|
||||
file.json_data jsonData ,file.data_type dataType
|
||||
from tb_algorithm tam
|
||||
left join tb_user_oper tuo on tuo.id=tam.oper_id
|
||||
left join tb_sure_file file on file.algorithm_id=tam.id
|
||||
|
|
@ -219,7 +222,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
file.file_type fileType,
|
||||
file.bj_file_path bjFilePath,
|
||||
file. file_size fileSize,
|
||||
file.create_user createUser
|
||||
file.create_user createUser,
|
||||
file.json_data jsonData,
|
||||
file.data_type dataType,
|
||||
file.remark remark,
|
||||
file.height, file.width
|
||||
from tb_upload_file file
|
||||
left join tb_algorithm ta on ta.id=file.algorithm_id
|
||||
WHERE file.is_active=0
|
||||
|
|
@ -229,11 +236,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<insert id="addSureFile">
|
||||
replace 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
|
||||
file_name,is_active,create_time,file_type,bj_file_path,file_size,create_user,json_data,data_type,remark,height,width
|
||||
) values
|
||||
<foreach collection="list" item="item" separator=",">
|
||||
(#{item.imageId}, #{item.algorithmId},#{item.originalName},#{item.filePath},#{item.bucketName},
|
||||
#{item.fileName},#{item.isActive},now(),#{item.fileType},#{item.bjFilePath},#{item.fileSize},#{item.createUser} )
|
||||
#{item.fileName},#{item.isActive},now(),#{item.fileType},#{item.bjFilePath},#{item.fileSize},#{item.createUser},#{item.jsonData} ,#{item.dataType} ,#{item.remark} ,#{item.height} ,#{item.width} )
|
||||
</foreach>
|
||||
</insert>
|
||||
</mapper>
|
||||
|
|
@ -15,6 +15,17 @@ import org.apache.commons.lang3.builder.ToStringStyle;
|
|||
@Builder
|
||||
public class SysFile
|
||||
{
|
||||
/**
|
||||
* 高度
|
||||
*/
|
||||
private String height;
|
||||
/**
|
||||
* 宽度
|
||||
*/
|
||||
private String width;
|
||||
|
||||
private String dataType;
|
||||
|
||||
private String id;
|
||||
/**
|
||||
* 文件名称
|
||||
|
|
@ -50,6 +61,8 @@ public class SysFile
|
|||
*/
|
||||
private String createUser;
|
||||
|
||||
private String jsonData;
|
||||
|
||||
/**
|
||||
* 添加属性
|
||||
* @param sysFile
|
||||
|
|
|
|||
|
|
@ -4,6 +4,20 @@ import lombok.Data;
|
|||
|
||||
@Data
|
||||
public class UploadFileVo {
|
||||
/**
|
||||
* 高度
|
||||
*/
|
||||
private String height;
|
||||
/**
|
||||
* 宽度
|
||||
*/
|
||||
private String width;
|
||||
|
||||
private String dataType;
|
||||
|
||||
private String jsonData;
|
||||
|
||||
private String remark;
|
||||
|
||||
private String operaName;
|
||||
|
||||
|
|
@ -33,6 +47,8 @@ public class UploadFileVo {
|
|||
* 标记文件地址
|
||||
*/
|
||||
private String bjFilePath;
|
||||
|
||||
private String imageUrl;
|
||||
/**
|
||||
* 标记图片地址
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -175,7 +175,6 @@ public class TokenService
|
|||
refreshToken(loginUser);
|
||||
// 绑定用户名与当前uuid,挤下线旧会话
|
||||
bindUserToken(loginUser.getUsername(), token);
|
||||
|
||||
Map<String, Object> claims = new HashMap<>();
|
||||
claims.put(Constants.LOGIN_USER_KEY, token);
|
||||
claims.put(Constants.JWT_USERNAME, loginUser.getUsername());
|
||||
|
|
@ -375,11 +374,12 @@ public class TokenService
|
|||
{
|
||||
String userTokenKey = getUserTokenKey(username);
|
||||
String oldUuid = redisCache.getCacheObject(userTokenKey);
|
||||
if (StringUtils.isNotEmpty(oldUuid) && !uuid.equals(oldUuid))
|
||||
{
|
||||
// 删除旧的 login_tokens:{oldUuid}
|
||||
String oldLoginKey = getTokenKey(oldUuid);
|
||||
redisCache.deleteObject(oldLoginKey);
|
||||
if(!"admin".equals(username)){
|
||||
if (StringUtils.isNotEmpty(oldUuid) && !uuid.equals(oldUuid)) {
|
||||
// 删除旧的 login_tokens:{oldUuid}
|
||||
String oldLoginKey = getTokenKey(oldUuid);
|
||||
redisCache.deleteObject(oldLoginKey);
|
||||
}
|
||||
}
|
||||
redisCache.setCacheObject(userTokenKey, uuid, expireTime, TimeUnit.MINUTES);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue