Commit 0c246e9a by chentian

代码优化

parent 6a25b961
#云天励飞(方正国际接口对接.pdf)
imageIp=http://26.3.12.56
imageUrl=http://26.3.12.56:8083
#4.2.1根据id获取图片信息(根据(imageid)获取完整的图片(image)信息)
imageByIdUrl=/api/intellif/image/
#4.2.2获取指定id的人脸信息(根据(faceid)获取完整的人脸小图(face)信息)
faceByIdUrl=/api/intellif/face/
#4.2.3根据小图获取大图信息(根据人脸编号(faceid)获取人脸所在的大图(image)的信息)
imageByFaceIdUrl=/api/intellif/image/face/
#4.2.4根据小图获取大图信息,返回人脸小图在大图中的位置(类似接口 4.2.3,差别在于多返回了 face 在 image 中的位置信息)
imageAndLocationByFaceIdUrl=/api/intellif/image/face/json/
#4.2.5根据大图获取小图(根据大图 id 获取所有小图信息,这里的 id 来自上传图片接口返回的 id)
imageByBigImageIdUrl=/api/intellif/face/image/
#4.1.1 图片文件传输方式地址 true-进行人脸检测 false-不进行人脸检测 0-检索上传 1-布控上传 2-红名单上传
imageIdsByUploadImageUrl =/api/intellif/image/upload/true?type=0
package com.founder.ytlf;
package com.founder.imageapi;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
......
package com.founder.ytlf.controller;
package com.founder.imageapi.controller;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.founder.commonutils.peopleEntity.FaceSearchParam;
import com.founder.commonutils.publicEntity.MapRestResult;
import com.founder.commonutils.util.HttpClient;
import com.founder.commonutils.util.TokenUtils;
import com.founder.servicebase.logs.OperLog;
import com.founder.servicebase.logs.OperationType;
import com.founder.ytlf.service.YtlfService;
import com.founder.imageapi.service.ImageService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
/**
* <p>
* 云天接口管理 前端控制器
* 第三方图像接口管理 前端控制器
* </p>
*
* @author yangyang
* @since 2021-03-18
*/
@Api(description = "云天接口管理")
@Api(description = "第三方图像接口管理-云天励飞")
@RestController
@RequestMapping("/ytlf")
public class YtlfController {
@RequestMapping("/image")
@Component
public class ImageController {
@Autowired
private YtlfService ytlfService;
private ImageService imageService;
@Value("${image_url}")
private String image_url;
@GetMapping("/getvalue")
public MapRestResult getvalue() {
//获取token
//案件查询(存储reids)
return MapRestResult.build(202,"测试",image_url);
}
//获取token
@OperLog(message = "token获取",operation = OperationType.QUERY)
@ApiOperation(value = "token获取")
@PostMapping("/token")
......@@ -47,135 +52,13 @@ public class YtlfController {
return MapRestResult.build(202,"成功获取token信息",accessToken);
}
@OperLog(message = "根据id获取图片信息",operation = OperationType.QUERY)
@ApiOperation(value = "根据id获取图片信息")
@GetMapping("/getPicById/{id}")
public MapRestResult getPicById_yunTian(@PathVariable String id){
try {
String ytToken = TokenUtils.getYtgsToken();
//url应该写在配置文件中
String url = "http://26.3.12.56:8083/api/intellif/image/" + id;
CloseableHttpClient httpClient = HttpClients.createDefault();
String auth = "Bearer " + ytToken;
String result = "";
Map<String,String> header = new HashMap<>();
header.put("Authorization",auth);
try {
result = HttpClient.doGet(url,header,null);
} catch (Exception e) {
e.printStackTrace();
}
//JSONObject jsonObject = JSONArray.parseObject(result);
return MapRestResult.build(200,"查询结果为",result);
} catch (Exception e) {
e.printStackTrace();
}
return MapRestResult.build(500,"请求失败",null);
}
@OperLog(message = "获取指定id的人脸信息",operation = OperationType.QUERY)
@ApiOperation(value = "获取指定id的人脸信息")
@GetMapping("/getFaceByFaceId/{FaceId}")
public MapRestResult getFaceByFaceId(@PathVariable Long FaceId){
try{
String accessToken = TokenUtils.getYtgsToken();
String url = "http://26.3.12.56:8083/api/intellif/face/"+FaceId;
String Authorization = "Bearer "+accessToken;
Map header = new HashMap<String,String>();
header.put("Authorization",Authorization);
String result = null;
try {
result = HttpClient.doGet(url,header,null);
}catch (Exception e){
e.printStackTrace();
}
JSONObject jsonObject = JSONArray.parseObject(result);
return MapRestResult.build(200,"成功获取指定id的人脸信息",jsonObject);
}catch (Exception e){
e.printStackTrace();
}
return MapRestResult.build(500,"请求失败",null);
}
@OperLog(message = "根据小图获取大图信息",operation = OperationType.QUERY)
@ApiOperation(value = "根据小图获取大图信息")
@GetMapping("/getImageByFaceId/{FaceId}")
public MapRestResult getImageByFaceId(@PathVariable Long FaceId){
try{
String accessToken = TokenUtils.getYtgsToken();
String url = "http://26.3.12.56:8083/api/intellif/image/face/"+FaceId;
String Authorization = "Bearer "+accessToken;
Map header = new HashMap<String,String>();
header.put("Authorization",Authorization);
String result = null;
try {
result = HttpClient.doGet(url,header,null);
}catch (Exception e){
e.printStackTrace();
}
JSONObject jsonObject = JSONArray.parseObject(result);
return MapRestResult.build(200,"成功根据小图获取大图信息",jsonObject);
}catch (Exception e){
e.printStackTrace();
}
return MapRestResult.build(500,"请求失败",null);
}
@OperLog(message = "根据小图获取大图信息,返回人脸小图在大图中的位置",operation = OperationType.QUERY)
@ApiOperation(value = "根据小图获取大图信息,返回人脸小图在大图中的位置")
@GetMapping("/getImageAndLocationByFaceId/{FaceId}")
public MapRestResult getImageAndLocationByFaceId(@PathVariable Long FaceId){
try{
String accessToken = TokenUtils.getYtgsToken();
String url = "http://26.3.12.56:8083/api/intellif/image/face/json/"+FaceId;
String Authorization = "Bearer "+accessToken;
Map header = new HashMap<String,String>();
header.put("Authorization",Authorization);
String result = null;
try {
result = HttpClient.doGet(url,header,null);
}catch (Exception e){
e.printStackTrace();
}
JSONObject jsonObject = JSONArray.parseObject(result);
return MapRestResult.build(200,"成功根据小图获取大图信息,返回人脸小图在大图中的位置",jsonObject);
}catch (Exception e){
e.printStackTrace();
}
return MapRestResult.build(500,"请求失败",null);
}
@OperLog(message = "根据大图id获取所有小图信息,这里的id来自上传图片接口返回的id",operation = OperationType.QUERY)
@ApiOperation(value = "根据大图id获取所有小图信息,这里的id来自上传图片接口返回的id")
@GetMapping("/getImageByBigImageId/{BigImageId}")
public MapRestResult getImageByBigImageId(@PathVariable Long BigImageId){
try{
String accessToken = TokenUtils.getYtgsToken();
String url = "http://26.3.12.56:8083/api/intellif/face/image/"+BigImageId;
String Authorization = "Bearer "+accessToken;
Map header = new HashMap<String,String>();
header.put("Authorization",Authorization);
String result = null;
try {
result = HttpClient.doGet(url,header,null);
}catch (Exception e){
e.printStackTrace();
}
JSONObject jsonObject = JSONArray.parseObject(result);
return MapRestResult.build(200,"成功根据大图id获取所有小图信息,这里的id来自上传图片接口返回的id",jsonObject);
}catch (Exception e){
e.printStackTrace();
}
return MapRestResult.build(500,"请求失败",null);
}
// 人脸动态检索接口接口
@OperLog(message = "人脸动态检索接口",operation = OperationType.QUERY)
@ApiOperation(value = "人脸动态检索接口")
@PostMapping(value = "/getFaceImageByUploadImage",consumes = "multipart/*",headers = "content-type=multipart/form-data")
public MapRestResult getFaceIdsByUploadImage(@RequestParam(value = "files",required = true) MultipartFile[] files, FaceSearchParam faceSearchParam) {
long startTime=new Date().getTime();
MapRestResult result=ytlfService.getFaceImageByUploadImage(files,faceSearchParam);
MapRestResult result=imageService.getFaceImageByUploadImage(files,faceSearchParam);
long endTime=new Date().getTime();
long timeDiffer=endTime-startTime;
System.out.println("人脸检索**请求时长**********"+timeDiffer+"毫秒");
......
package com.founder.ytlf.mapper;
package com.founder.imageapi.mapper;
import com.founder.commonutils.peopleEntity.Camera;
import org.apache.ibatis.annotations.Mapper;
......@@ -7,9 +7,8 @@ import org.springframework.stereotype.Component;
import java.util.List;
@Component
@Mapper
public interface CameraInfoDao {
public interface CameraInfoMapper {
List<Camera> getCameraInfoByIds(@Param(value = "cameraIds") String cameraIds);
}
package com.founder.imageapi.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.founder.commonutils.asjEntity.TbXwAsjbz;
import org.apache.ibatis.annotations.Mapper;
/**
* <p>
* 案事件标注Mapper 接口
* </p>
*
* @author yangyang
* @since 2021-03-05
*/
@Mapper
public interface TbStAsjBzMapper extends BaseMapper<TbXwAsjbz> {
}
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.founder.ytlf.mapper.CameraInfoDao">
<mapper namespace="com.founder.imageapi.mapper.CameraInfoMapper">
<select id="getCameraInfoByIds" parameterType="java.lang.String" resultType="com.founder.commonutils.peopleEntity.Camera">
select
......
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.founder.imageapi.mapper.TbStAsjBzMapper">
</mapper>
package com.founder.ytlf.service;
package com.founder.imageapi.service;
import com.founder.commonutils.peopleEntity.FaceSearchParam;
import com.founder.commonutils.publicEntity.MapRestResult;
......@@ -12,7 +12,12 @@ import org.springframework.web.multipart.MultipartFile;
* @author yangyang
* @since 2021-03-19
*/
public interface YtlfService {
public interface ImageService {
MapRestResult getFaceImageByUploadImage(MultipartFile[] files, FaceSearchParam faceSearchParam);
MapRestResult getImageById(Long id);
MapRestResult getFaceById(Long id);
MapRestResult getImageByFaceId(Long faceId);
/* MapRestResult getImageAndLocationByFaceId(Long faceId);*/
/* MapRestResult getImageByBigImageId(Long bigImageId);*/
}
package com.founder.ytlf.service.impl;
package com.founder.imageapi.service.impl;
import com.founder.commonutils.peopleEntity.Camera;
import com.founder.commonutils.util.DataUtil;
import com.founder.ytlf.mapper.CameraInfoDao;
import com.founder.imageapi.mapper.CameraInfoMapper;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
......@@ -16,7 +16,7 @@ import java.util.*;
@Component
public class CommonService {
@Autowired
private CameraInfoDao cameraInfoDao;
private CameraInfoMapper cameraInfoDao;
public Map<String, Object> getCameraInfoByIds(String cameraId) {
Map<String, Object> returnMap = new HashMap<>();
......
......@@ -10,17 +10,9 @@ spring.cloud.nacos.config.namespace=052aa986-5c18-4013-a91a-583dc01aaf8b
#prod
#spring.cloud.nacos.config.namespace=1ffd9d32-3f03-4eb8-bf12-98b1ce397390
#spring.cloud.nacos.config.ext-config[0].data-id=eduport.properties
#spring.cloud.nacos.config.ext-config[0].data-id=image.properties
# 开启动态刷新配置,否则配置文件修改,工程无法感知
#spring.cloud.nacos.config.ext-config[0].refresh=true
#############################云天接口访问地址开始#############################################
#4.4.1 图片文件传输方式地址 true-进行人脸检测 false-不进行人脸检测 0-检索上传 1-布控上传 2-红名单上传
ImageIdsByUploadImageUrl = http://26.3.12.56:8083/api/intellif/image/upload/true?type=0
#根据大图 id 获取所有小图信息,这里的 id 来自上传图片接口返回的 id
FaceIdByIdUrl = http://26.3.12.56:8083/api/intellif/face/image/
#4.2.4 根据小图获取大图,返回人脸小图在大图中的位置
FaceBigByIdUrl=http://26.3.12.56:8083/api/intellif/image/face/json/
#############################云天接口访问地址结束##############################################
\ No newline at end of file
spring.cloud.nacos.config.shared-dataids=image.properties
spring.cloud.nacos.config.refreshable-dataids=image.properties
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment