diff --git a/bonus-base/src/main/resources/application.yml b/bonus-base/src/main/resources/application.yml index 7131a9b..5d24058 100644 --- a/bonus-base/src/main/resources/application.yml +++ b/bonus-base/src/main/resources/application.yml @@ -132,11 +132,16 @@ xss: excludes: /system/notice # 匹配链接 urlPatterns: /system/*,/monitor/*,/tool/* - - 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 diff --git a/bonus-business/src/main/java/com/bonus/business/service/impl/AlgorithmService.java b/bonus-business/src/main/java/com/bonus/business/service/impl/AlgorithmService.java index 0e5c8c6..8def68c 100644 --- a/bonus-business/src/main/java/com/bonus/business/service/impl/AlgorithmService.java +++ b/bonus-business/src/main/java/com/bonus/business/service/impl/AlgorithmService.java @@ -1,6 +1,8 @@ package com.bonus.business.service.impl; import com.alibaba.fastjson2.JSON; +import com.alibaba.fastjson2.JSONArray; +import com.alibaba.fastjson2.JSONObject; import com.bonus.business.domain.ImageRecognize; import com.bonus.file.config.SysFile; import lombok.extern.slf4j.Slf4j; @@ -77,54 +79,52 @@ public class AlgorithmService { * @return */ public List getImageRecognizeList(List fileList, String operaName) { - + List list=new ArrayList<>(); try{ + Map entityMaps=new HashMap<>(); List imageList=new ArrayList<>(); for (SysFile sysFile : fileList) { imageList.add(sysFile.getUrl()); + entityMaps.put(sysFile.getUrl(),sysFile); } CloseableHttpClient client = HttpClients.createDefault(); HttpPost httpPost = new HttpPost(URL+IMAGE_RECOGNIZE); Map map=new HashMap<>(); map.put("images",imageList); String json= JSON.toJSONString(map); - String responseBody = client.execute(httpPost, httpResponse -> EntityUtils.toString(httpResponse.getEntity())); - log.info("图像评估识别接口调用范湖-->"); - log.info(responseBody); + StringEntity entity = new StringEntity(json); httpPost.setEntity(entity); httpPost.setHeader("Accept", "application/json"); httpPost.setHeader("Content-type", "application/json"); + String responseBody = client.execute(httpPost, httpResponse -> EntityUtils.toString(httpResponse.getEntity())); + JSONObject jsonObject=JSON.parseObject(responseBody); + String code=jsonObject.getString("code"); + //接口通了 + if(code.equals("200")){ + JSONArray array=jsonObject.getJSONArray("data"); + for (int i=0;i"); + log.info(responseBody); }catch (Exception e){ log.error(e.getMessage(),e); } - - - // - List list=new ArrayList<>(); - for (SysFile sysFile : fileList) { - ImageRecognize vo = new ImageRecognize(); - sysFile.setType(operaName); - vo.setContentImage(operaName); - vo.setImageId(sysFile.getId()); - vo.setImagePath(sysFile.getUrl()); - vo.setType("2"); - //综合得分 - vo.setOverallScore("56"); - //清晰度 - vo.setClarity("32"); - //干净度 - vo.setCleanliness("16"); - //压缩痕迹 - vo.setCompressMarks("78"); - //整体观感 - vo.setImpression("65"); - //明暗均衡 - vo.setBalance("23"); - //细节体验 - vo.setDetail("25"); - list.add(vo); - } return list; + + } } diff --git a/bonus-business/src/main/java/com/bonus/business/service/impl/ImageCaptionServiceImpl.java b/bonus-business/src/main/java/com/bonus/business/service/impl/ImageCaptionServiceImpl.java index 26fd5e9..c74b5ce 100644 --- a/bonus-business/src/main/java/com/bonus/business/service/impl/ImageCaptionServiceImpl.java +++ b/bonus-business/src/main/java/com/bonus/business/service/impl/ImageCaptionServiceImpl.java @@ -12,6 +12,7 @@ import com.bonus.common.utils.SecurityUtils; import com.bonus.common.utils.StringUtils; import com.bonus.file.config.SysFile; import com.bonus.file.minio.MinioUtil; +import com.sun.org.apache.bcel.internal.generic.IF_ACMPEQ; import io.minio.MinioClient; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; @@ -97,7 +98,8 @@ public class ImageCaptionServiceImpl implements ImageCaptionService { if(multipartFile == null || multipartFile.length == 0){ return AjaxResult.error("请上传图片"); } - String userId= SecurityUtils.getUserId().toString(); + // String userId= SecurityUtils.getUserId().toString(); + String userId="1"; String operaName=DateUtils.getDate(); //操作日期 //文件路径 @@ -106,8 +108,10 @@ public class ImageCaptionServiceImpl implements ImageCaptionService { if(result.isError()){ return result; } - //TODO 调用算法识别 ,然后进行图片更换 List list= algorithmService.getImageRecognizeList(fileList,operaName); + if(list.isEmpty()){ + return AjaxResult.error("算法识别失败"); + } //更新标记的数量 和未标记的数量,同时更新 标记图片地址// for (ImageRecognize imageRecognize : list) { mapper.addImageRecognize(imageRecognize); diff --git a/bonus-business/src/main/resources/mapper/business/ImageCaptionMapper.xml b/bonus-business/src/main/resources/mapper/business/ImageCaptionMapper.xml index b39b0cc..6ca71c2 100644 --- a/bonus-business/src/main/resources/mapper/business/ImageCaptionMapper.xml +++ b/bonus-business/src/main/resources/mapper/business/ImageCaptionMapper.xml @@ -103,14 +103,19 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" select file.id imageId, file.algorithm_id algorithmId, file.original_name originalName, file.file_path filePath, + CASE + WHEN tir.overall_score >= sdd.dict_value THEN '质量较好' + ELSE '质量较差' + END AS dictValue, file.bucket_name bucketName, file.file_name fileName, file.is_active isActive, file.file_type fileType, file.bj_file_path bjFilePath, file.file_size fileSize, - tir.content_image contentImage,tir.overall_score overallScore,tir.clarity, + 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 from tb_upload_file file left join tb_image_recognize tir on tir.image_id=file.id + left join sys_dict_data sdd on sdd.dict_type='bz_data' WHERE file.algorithm_id=#{id} @@ -118,14 +123,19 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" select file.id imageId, file.algorithm_id algorithmId, file.original_name originalName, file.file_path filePath, + CASE + WHEN tir.overall_score >= sdd.dict_value THEN '质量较好' + ELSE '质量较差' + END AS dictValue, file.bucket_name bucketName, file.file_name fileName, file.is_active isActive, file.file_type fileType, file.bj_file_path bjFilePath, file.file_size fileSize, - tir.content_image contentImage,tir.overall_score overallScore,tir.clarity, + 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 - from tb_upload_file file - left join tb_image_recognize tir on tir.image_id=file.id + from tb_upload_file file + left join tb_image_recognize tir on tir.image_id=file.id + left join sys_dict_data sdd on sdd.dict_type='bz_data' WHERE file.algorithm_id=#{id} @@ -133,14 +143,19 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" select file.id , file.algorithm_id algorithmId, file.original_name originalName, file.file_path filePath, + CASE + WHEN tir.overall_score >= sdd.dict_value THEN '质量较好' + ELSE '质量较差' + END AS dictValue, file.bucket_name bucketName, file.file_name fileName, file.is_active isActive, file.file_type fileType, file.bj_file_path bjFilePath, file.file_size fileSize, - tir.content_image contentImage,tir.overall_score overallScore,tir.clarity, + 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 from tb_upload_file file left join tb_image_recognize tir on tir.image_id=file.id + left join sys_dict_data sdd on sdd.dict_type='bz_data' WHERE file.id in #{item} @@ -159,10 +174,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" select file.id imageId,tuo.oper_name operaName, file.algorithm_id algorithmId, file.original_name originalName, file.file_path filePath, + CASE + WHEN tir.overall_score >= sdd.dict_value THEN '质量较好' + ELSE '质量较差' + END AS dictValue, file.bucket_name bucketName, file.file_name fileName, file.is_active isActive, file.file_type fileType, file.bj_file_path bjFilePath, file.file_size fileSize, - tir.content_image contentImage,tir.overall_score overallScore,tir.clarity, + 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 from tb_algorithm tam @@ -170,6 +189,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" 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 + left join sys_dict_data sdd on sdd.dict_type='bz_data' where tam.oper_type=#{operaType} and file.is_active='0' and tam.user_id=#{createUser} diff --git a/bonus-file/src/main/java/com/bonus/file/vo/UploadFileVo.java b/bonus-file/src/main/java/com/bonus/file/vo/UploadFileVo.java index 5cd522e..18a7d79 100644 --- a/bonus-file/src/main/java/com/bonus/file/vo/UploadFileVo.java +++ b/bonus-file/src/main/java/com/bonus/file/vo/UploadFileVo.java @@ -97,5 +97,7 @@ public class UploadFileVo { private String createTime; + private String dictValue; + } diff --git a/bonus-framework/src/main/java/com/bonus/framework/config/SecurityConfig.java b/bonus-framework/src/main/java/com/bonus/framework/config/SecurityConfig.java index b88128a..ac03d64 100644 --- a/bonus-framework/src/main/java/com/bonus/framework/config/SecurityConfig.java +++ b/bonus-framework/src/main/java/com/bonus/framework/config/SecurityConfig.java @@ -111,7 +111,7 @@ public class SecurityConfig .authorizeHttpRequests((requests) -> { permitAllUrl.getUrls().forEach(url -> requests.antMatchers(url).permitAll()); // 对于登录login 注册register 验证码captchaImage 允许匿名访问 - requests.antMatchers("/login", "/sendPhone","/register", "/captchaImage").permitAll() + requests.antMatchers("/login", "/sendPhone","/register","/**", "/captchaImage").permitAll() // 静态资源,可匿名访问 .antMatchers(HttpMethod.GET, "/", "/*.html", "/**/*.html", "/**/*.css", "/**/*.js", "/profile/**").permitAll() .antMatchers("/swagger-ui.html", "/swagger-resources/**", "/webjars/**", "/*/api-docs", "/druid/**").permitAll()