添加第三方接口
This commit is contained in:
parent
509bf73962
commit
ef985589d5
|
|
@ -132,11 +132,16 @@ xss:
|
||||||
excludes: /system/notice
|
excludes: /system/notice
|
||||||
# 匹配链接
|
# 匹配链接
|
||||||
urlPatterns: /system/*,/monitor/*,/tool/*
|
urlPatterns: /system/*,/monitor/*,/tool/*
|
||||||
|
|
||||||
|
|
||||||
minio:
|
minio:
|
||||||
url: http://192.168.0.14:9090
|
url: http://47.92.234.255:9090
|
||||||
endpoint: http://192.168.0.14:9090
|
endpoint: http://47.92.234.255:9090
|
||||||
accessKey: minio
|
accessKey: minio
|
||||||
secretKey: bonus@admin123
|
secretKey: Bonus@admin123!
|
||||||
bucketName: image
|
bucketName: image
|
||||||
|
|
||||||
|
#minio:
|
||||||
|
# url: http://192.168.0.14:9090
|
||||||
|
# endpoint: http://192.168.0.14:9090
|
||||||
|
# accessKey: minio
|
||||||
|
# secretKey: bonus@admin123
|
||||||
|
# bucketName: image
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
package com.bonus.business.service.impl;
|
package com.bonus.business.service.impl;
|
||||||
|
|
||||||
import com.alibaba.fastjson2.JSON;
|
import com.alibaba.fastjson2.JSON;
|
||||||
|
import com.alibaba.fastjson2.JSONArray;
|
||||||
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
import com.bonus.business.domain.ImageRecognize;
|
import com.bonus.business.domain.ImageRecognize;
|
||||||
import com.bonus.file.config.SysFile;
|
import com.bonus.file.config.SysFile;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
@ -77,54 +79,52 @@ public class AlgorithmService {
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public List<ImageRecognize> getImageRecognizeList(List<SysFile> fileList, String operaName) {
|
public List<ImageRecognize> getImageRecognizeList(List<SysFile> fileList, String operaName) {
|
||||||
|
List<ImageRecognize> list=new ArrayList<>();
|
||||||
try{
|
try{
|
||||||
|
Map<String,SysFile> entityMaps=new HashMap<>();
|
||||||
List<String> imageList=new ArrayList<>();
|
List<String> imageList=new ArrayList<>();
|
||||||
for (SysFile sysFile : fileList) {
|
for (SysFile sysFile : fileList) {
|
||||||
imageList.add(sysFile.getUrl());
|
imageList.add(sysFile.getUrl());
|
||||||
|
entityMaps.put(sysFile.getUrl(),sysFile);
|
||||||
}
|
}
|
||||||
CloseableHttpClient client = HttpClients.createDefault();
|
CloseableHttpClient client = HttpClients.createDefault();
|
||||||
HttpPost httpPost = new HttpPost(URL+IMAGE_RECOGNIZE);
|
HttpPost httpPost = new HttpPost(URL+IMAGE_RECOGNIZE);
|
||||||
Map<String ,Object> map=new HashMap<>();
|
Map<String ,Object> map=new HashMap<>();
|
||||||
map.put("images",imageList);
|
map.put("images",imageList);
|
||||||
String json= JSON.toJSONString(map);
|
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);
|
StringEntity entity = new StringEntity(json);
|
||||||
httpPost.setEntity(entity);
|
httpPost.setEntity(entity);
|
||||||
httpPost.setHeader("Accept", "application/json");
|
httpPost.setHeader("Accept", "application/json");
|
||||||
httpPost.setHeader("Content-type", "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<array.size();i++){
|
||||||
|
ImageRecognize vo = new ImageRecognize();
|
||||||
|
//获取路径及采集数据
|
||||||
|
String path=array.getJSONObject(i).getString("path");
|
||||||
|
String score=array.getJSONObject(i).getString("score");
|
||||||
|
SysFile sysFile=entityMaps.get(path);
|
||||||
|
//综合得分
|
||||||
|
vo.setOverallScore(score);
|
||||||
|
sysFile.setType(operaName);
|
||||||
|
vo.setContentImage(operaName);
|
||||||
|
vo.setImageId(sysFile.getId());
|
||||||
|
vo.setImagePath(sysFile.getUrl());
|
||||||
|
list.add(vo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
log.info("图像评估识别接口调用范湖-->");
|
||||||
|
log.info(responseBody);
|
||||||
}catch (Exception e){
|
}catch (Exception e){
|
||||||
log.error(e.getMessage(),e);
|
log.error(e.getMessage(),e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//
|
|
||||||
List<ImageRecognize> 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;
|
return list;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,7 @@ import com.bonus.common.utils.SecurityUtils;
|
||||||
import com.bonus.common.utils.StringUtils;
|
import com.bonus.common.utils.StringUtils;
|
||||||
import com.bonus.file.config.SysFile;
|
import com.bonus.file.config.SysFile;
|
||||||
import com.bonus.file.minio.MinioUtil;
|
import com.bonus.file.minio.MinioUtil;
|
||||||
|
import com.sun.org.apache.bcel.internal.generic.IF_ACMPEQ;
|
||||||
import io.minio.MinioClient;
|
import io.minio.MinioClient;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
|
@ -97,7 +98,8 @@ public class ImageCaptionServiceImpl implements ImageCaptionService {
|
||||||
if(multipartFile == null || multipartFile.length == 0){
|
if(multipartFile == null || multipartFile.length == 0){
|
||||||
return AjaxResult.error("请上传图片");
|
return AjaxResult.error("请上传图片");
|
||||||
}
|
}
|
||||||
String userId= SecurityUtils.getUserId().toString();
|
// String userId= SecurityUtils.getUserId().toString();
|
||||||
|
String userId="1";
|
||||||
String operaName=DateUtils.getDate();
|
String operaName=DateUtils.getDate();
|
||||||
//操作日期
|
//操作日期
|
||||||
//文件路径
|
//文件路径
|
||||||
|
|
@ -106,8 +108,10 @@ public class ImageCaptionServiceImpl implements ImageCaptionService {
|
||||||
if(result.isError()){
|
if(result.isError()){
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
//TODO 调用算法识别 ,然后进行图片更换
|
|
||||||
List<ImageRecognize> list= algorithmService.getImageRecognizeList(fileList,operaName);
|
List<ImageRecognize> list= algorithmService.getImageRecognizeList(fileList,operaName);
|
||||||
|
if(list.isEmpty()){
|
||||||
|
return AjaxResult.error("算法识别失败");
|
||||||
|
}
|
||||||
//更新标记的数量 和未标记的数量,同时更新 标记图片地址//
|
//更新标记的数量 和未标记的数量,同时更新 标记图片地址//
|
||||||
for (ImageRecognize imageRecognize : list) {
|
for (ImageRecognize imageRecognize : list) {
|
||||||
mapper.addImageRecognize(imageRecognize);
|
mapper.addImageRecognize(imageRecognize);
|
||||||
|
|
|
||||||
|
|
@ -103,14 +103,19 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
select file.id imageId,
|
select file.id imageId,
|
||||||
file.algorithm_id algorithmId, file.original_name originalName,
|
file.algorithm_id algorithmId, file.original_name originalName,
|
||||||
file.file_path filePath,
|
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.bucket_name bucketName, file.file_name fileName,
|
||||||
file.is_active isActive, file.file_type fileType,
|
file.is_active isActive, file.file_type fileType,
|
||||||
file.bj_file_path bjFilePath, file.file_size fileSize,
|
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.cleanliness,tir.compress_marks compressMarks,tir.impression,
|
||||||
tir.balance,tir.detail,tir.type
|
tir.balance,tir.detail,tir.type
|
||||||
from tb_upload_file file
|
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
|
||||||
|
left join sys_dict_data sdd on sdd.dict_type='bz_data'
|
||||||
WHERE file.algorithm_id=#{id}
|
WHERE file.algorithm_id=#{id}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
|
@ -118,14 +123,19 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
select file.id imageId,
|
select file.id imageId,
|
||||||
file.algorithm_id algorithmId, file.original_name originalName,
|
file.algorithm_id algorithmId, file.original_name originalName,
|
||||||
file.file_path filePath,
|
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.bucket_name bucketName, file.file_name fileName,
|
||||||
file.is_active isActive, file.file_type fileType,
|
file.is_active isActive, file.file_type fileType,
|
||||||
file.bj_file_path bjFilePath, file.file_size fileSize,
|
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.cleanliness,tir.compress_marks compressMarks,tir.impression,
|
||||||
tir.balance,tir.detail,tir.type
|
tir.balance,tir.detail,tir.type
|
||||||
from tb_upload_file file
|
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
|
||||||
|
left join sys_dict_data sdd on sdd.dict_type='bz_data'
|
||||||
WHERE file.algorithm_id=#{id}
|
WHERE file.algorithm_id=#{id}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
|
@ -133,14 +143,19 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
select file.id ,
|
select file.id ,
|
||||||
file.algorithm_id algorithmId, file.original_name originalName,
|
file.algorithm_id algorithmId, file.original_name originalName,
|
||||||
file.file_path filePath,
|
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.bucket_name bucketName, file.file_name fileName,
|
||||||
file.is_active isActive, file.file_type fileType,
|
file.is_active isActive, file.file_type fileType,
|
||||||
file.bj_file_path bjFilePath, file.file_size fileSize,
|
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.cleanliness,tir.compress_marks compressMarks,tir.impression,
|
||||||
tir.balance,tir.detail,tir.type
|
tir.balance,tir.detail,tir.type
|
||||||
from tb_upload_file file
|
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
|
||||||
|
left join sys_dict_data sdd on sdd.dict_type='bz_data'
|
||||||
WHERE file.id in
|
WHERE file.id in
|
||||||
<foreach collection="list" item="item" close=")" open="(" separator=",">
|
<foreach collection="list" item="item" close=")" open="(" separator=",">
|
||||||
#{item}
|
#{item}
|
||||||
|
|
@ -159,10 +174,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
select file.id imageId,tuo.oper_name operaName,
|
select file.id imageId,tuo.oper_name operaName,
|
||||||
file.algorithm_id algorithmId, file.original_name originalName,
|
file.algorithm_id algorithmId, file.original_name originalName,
|
||||||
file.file_path filePath,
|
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.bucket_name bucketName, file.file_name fileName,
|
||||||
file.is_active isActive, file.file_type fileType,
|
file.is_active isActive, file.file_type fileType,
|
||||||
file.bj_file_path bjFilePath, file.file_size fileSize,
|
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.cleanliness,tir.compress_marks compressMarks,tir.impression,
|
||||||
tir.balance,tir.detail,tir.type,su.user_name userName
|
tir.balance,tir.detail,tir.type,su.user_name userName
|
||||||
from tb_algorithm tam
|
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_sure_file file on file.algorithm_id=tam.id
|
||||||
left join tb_image_recognize tir on tir.image_id=file.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_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'
|
where tam.oper_type=#{operaType} and file.is_active='0'
|
||||||
<if test='createUser!=null and createUser!=""'>
|
<if test='createUser!=null and createUser!=""'>
|
||||||
and tam.user_id=#{createUser}
|
and tam.user_id=#{createUser}
|
||||||
|
|
|
||||||
|
|
@ -97,5 +97,7 @@ public class UploadFileVo {
|
||||||
|
|
||||||
private String createTime;
|
private String createTime;
|
||||||
|
|
||||||
|
private String dictValue;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -111,7 +111,7 @@ public class SecurityConfig
|
||||||
.authorizeHttpRequests((requests) -> {
|
.authorizeHttpRequests((requests) -> {
|
||||||
permitAllUrl.getUrls().forEach(url -> requests.antMatchers(url).permitAll());
|
permitAllUrl.getUrls().forEach(url -> requests.antMatchers(url).permitAll());
|
||||||
// 对于登录login 注册register 验证码captchaImage 允许匿名访问
|
// 对于登录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(HttpMethod.GET, "/", "/*.html", "/**/*.html", "/**/*.css", "/**/*.js", "/profile/**").permitAll()
|
||||||
.antMatchers("/swagger-ui.html", "/swagger-resources/**", "/webjars/**", "/*/api-docs", "/druid/**").permitAll()
|
.antMatchers("/swagger-ui.html", "/swagger-resources/**", "/webjars/**", "/*/api-docs", "/druid/**").permitAll()
|
||||||
|
|
|
||||||
Reference in New Issue