http协议设备注册接口允许照片和压缩包为空
This commit is contained in:
parent
5d03d332be
commit
7a60125f71
|
@ -350,9 +350,11 @@ public class HttpApiController {
|
||||||
// puser.setActive_end_time(0);
|
// puser.setActive_end_time(0);
|
||||||
|
|
||||||
puser.setLast_update_stamp(p.getLastUpdateTime().getTime());
|
puser.setLast_update_stamp(p.getLastUpdateTime().getTime());
|
||||||
puser.setFace_pic_download_url(globalValue.getMinioEndpoint()+"/"
|
if(p.getOrgImage()!=null && p.getOrgImage().length()>0){
|
||||||
+ globalValue.getMinioBucketName()+"/"
|
puser.setFace_pic_download_url(globalValue.getMinioEndpoint()+"/"
|
||||||
+ p.getOrgImage());
|
+ globalValue.getMinioBucketName()+"/"
|
||||||
|
+ p.getOrgImage());
|
||||||
|
}
|
||||||
puser.setFace_pic_base64("");
|
puser.setFace_pic_base64("");
|
||||||
|
|
||||||
|
|
||||||
|
@ -846,7 +848,7 @@ public class HttpApiController {
|
||||||
@ApiImplicitParam(name = "timestamp", value = "timestamp", paramType = "query", dataType = "String", required = true),
|
@ApiImplicitParam(name = "timestamp", value = "timestamp", paramType = "query", dataType = "String", required = true),
|
||||||
@ApiImplicitParam(name = "sign", value = "sign", paramType = "query", dataType = "String", required = true),
|
@ApiImplicitParam(name = "sign", value = "sign", paramType = "query", dataType = "String", required = true),
|
||||||
})
|
})
|
||||||
public R addPerson(@RequestParam("jsonString") String jsonString, @RequestParam("orgImage") MultipartFile orgImage, @RequestParam("sourceFile") MultipartFile sourceFile,@RequestParam("thdFeature") String thdFeature) {
|
public R addPerson(@RequestParam("jsonString") String jsonString, @RequestParam(value="orgImage",required = false) MultipartFile orgImage, @RequestParam(value="sourceFile",required = false) MultipartFile sourceFile,@RequestParam("thdFeature") String thdFeature) {
|
||||||
JSONObject jsonContent = JSONObject.parseObject(jsonString);
|
JSONObject jsonContent = JSONObject.parseObject(jsonString);
|
||||||
String sn = jsonContent.getString("dev_id");
|
String sn = jsonContent.getString("dev_id");
|
||||||
String appKey = jsonContent.getString("appKey");
|
String appKey = jsonContent.getString("appKey");
|
||||||
|
@ -871,7 +873,9 @@ public class HttpApiController {
|
||||||
|
|
||||||
TenPersonEntity tenPerson = JSONObject.toJavaObject(personJson,TenPersonEntity.class);
|
TenPersonEntity tenPerson = JSONObject.toJavaObject(personJson,TenPersonEntity.class);
|
||||||
|
|
||||||
tenPerson.setThdFeature(thdFeature);
|
if(thdFeature!=null && thdFeature.length()>0){
|
||||||
|
tenPerson.setThdFeature(thdFeature);
|
||||||
|
}
|
||||||
|
|
||||||
if(tenPerson.getIdCard()!=null){
|
if(tenPerson.getIdCard()!=null){
|
||||||
if(tenPerson.getIdCard().length() == 15){
|
if(tenPerson.getIdCard().length() == 15){
|
||||||
|
@ -939,68 +943,75 @@ public class HttpApiController {
|
||||||
|
|
||||||
tenPerson.setCellId(deviceEntity.getCellId());
|
tenPerson.setCellId(deviceEntity.getCellId());
|
||||||
|
|
||||||
if (orgImage.isEmpty() || orgImage.getSize() == 0 || sourceFile.isEmpty() || sourceFile.getSize() == 0) {
|
// if (orgImage.isEmpty() || orgImage.getSize() == 0 || sourceFile.isEmpty() || sourceFile.getSize() == 0) {
|
||||||
return R.error("文件不能为空");
|
// return R.error("文件不能为空");
|
||||||
}
|
// }
|
||||||
try {
|
if (orgImage!=null && orgImage.getSize() != 0) {
|
||||||
//保存原始图片
|
try {
|
||||||
String userFileUrl = globalValue.getImagesDir() + "/" +
|
//保存原始图片
|
||||||
tenPerson.getCellId().toString() + "/" +
|
String userFileUrl = globalValue.getImagesDir() + "/" +
|
||||||
tenPerson.getPersonId().toString() + "/";
|
tenPerson.getCellId().toString() + "/" +
|
||||||
String orgImageFileName = userFileUrl + "o_" + UUIDUtil.uuid() + ".jpg";
|
tenPerson.getPersonId().toString() + "/";
|
||||||
|
String orgImageFileName = userFileUrl + "o_" + UUIDUtil.uuid() + ".jpg";
|
||||||
|
|
||||||
InputStream inputStream = orgImage.getInputStream();
|
InputStream inputStream = orgImage.getInputStream();
|
||||||
PutObjectOptions putObjectOptions = new PutObjectOptions(inputStream.available(), -1);
|
PutObjectOptions putObjectOptions = new PutObjectOptions(inputStream.available(), -1);
|
||||||
putObjectOptions.setContentType(orgImage.getContentType());
|
putObjectOptions.setContentType(orgImage.getContentType());
|
||||||
minioClient.putObject(
|
|
||||||
minioConfig.getBucketName(), orgImageFileName, inputStream, putObjectOptions);
|
|
||||||
inputStream.close();
|
|
||||||
|
|
||||||
tenPerson.setOrgImage(orgImageFileName);
|
|
||||||
tenPerson.setFaceImage(orgImageFileName);
|
|
||||||
|
|
||||||
} catch (Exception e) {
|
|
||||||
return R.error(e.getMessage());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
try {
|
|
||||||
//保存sourceFiile
|
|
||||||
String userFileUrl = globalValue.getImagesDir() + "/" +
|
|
||||||
tenPerson.getCellId().toString() + "/" +
|
|
||||||
tenPerson.getPersonId().toString() + "/";
|
|
||||||
String sourceFileName = userFileUrl + "p_" + UUIDUtil.uuid() + ".zip";
|
|
||||||
|
|
||||||
InputStream inputStream = sourceFile.getInputStream();
|
|
||||||
PutObjectOptions putObjectOptions = new PutObjectOptions(inputStream.available(), -1);
|
|
||||||
putObjectOptions.setContentType(sourceFile.getContentType());
|
|
||||||
minioClient.putObject(
|
|
||||||
minioConfig.getBucketName(), sourceFileName, inputStream, putObjectOptions);
|
|
||||||
inputStream.close();
|
|
||||||
|
|
||||||
tenPerson.setSourceFile(sourceFileName);
|
|
||||||
|
|
||||||
String tempUnzipFilePath = globalValue.getStaticLocations()+ File.separator+globalValue.getTempDir();
|
|
||||||
|
|
||||||
//解压文件,获取gif文件,保存到文件服务器,添加到人员字段face_model字段
|
|
||||||
String gifStr = UploadZipUtil.unZipGifFromSourceFile(sourceFile,tempUnzipFilePath);
|
|
||||||
File gifFile = new File(gifStr);
|
|
||||||
if (gifStr.length()>0) {
|
|
||||||
InputStream gifInputStream = new FileInputStream(new File(gifStr));
|
|
||||||
PutObjectOptions gifputObjectOptions = new PutObjectOptions(gifInputStream.available(), -1);
|
|
||||||
gifputObjectOptions.setContentType("image/gif");
|
|
||||||
String gifFileName = userFileUrl + "g_" + UUIDUtil.uuid() + ".gif";
|
|
||||||
minioClient.putObject(
|
minioClient.putObject(
|
||||||
minioConfig.getBucketName(), gifFileName, gifInputStream, gifputObjectOptions);
|
minioConfig.getBucketName(), orgImageFileName, inputStream, putObjectOptions);
|
||||||
gifInputStream.close();
|
inputStream.close();
|
||||||
tenPerson.setFaceModel(gifFileName);
|
|
||||||
File dirFile = gifFile.getParentFile();
|
tenPerson.setOrgImage(orgImageFileName);
|
||||||
gifFile.delete();
|
tenPerson.setFaceImage(orgImageFileName);
|
||||||
dirFile.delete();
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
return R.error(e.getMessage());
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
|
||||||
return R.error(e.getMessage());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (sourceFile!=null && sourceFile.getSize() != 0) {
|
||||||
|
try {
|
||||||
|
//保存sourceFiile
|
||||||
|
String userFileUrl = globalValue.getImagesDir() + "/" +
|
||||||
|
tenPerson.getCellId().toString() + "/" +
|
||||||
|
tenPerson.getPersonId().toString() + "/";
|
||||||
|
String sourceFileName = userFileUrl + "p_" + UUIDUtil.uuid() + ".zip";
|
||||||
|
|
||||||
|
InputStream inputStream = sourceFile.getInputStream();
|
||||||
|
PutObjectOptions putObjectOptions = new PutObjectOptions(inputStream.available(), -1);
|
||||||
|
putObjectOptions.setContentType(sourceFile.getContentType());
|
||||||
|
minioClient.putObject(
|
||||||
|
minioConfig.getBucketName(), sourceFileName, inputStream, putObjectOptions);
|
||||||
|
inputStream.close();
|
||||||
|
|
||||||
|
tenPerson.setSourceFile(sourceFileName);
|
||||||
|
|
||||||
|
String tempUnzipFilePath = globalValue.getStaticLocations()+ File.separator+globalValue.getTempDir();
|
||||||
|
|
||||||
|
//解压文件,获取gif文件,保存到文件服务器,添加到人员字段face_model字段
|
||||||
|
String gifStr = UploadZipUtil.unZipGifFromSourceFile(sourceFile,tempUnzipFilePath);
|
||||||
|
File gifFile = new File(gifStr);
|
||||||
|
if (gifStr.length()>0) {
|
||||||
|
InputStream gifInputStream = new FileInputStream(new File(gifStr));
|
||||||
|
PutObjectOptions gifputObjectOptions = new PutObjectOptions(gifInputStream.available(), -1);
|
||||||
|
gifputObjectOptions.setContentType("image/gif");
|
||||||
|
String gifFileName = userFileUrl + "g_" + UUIDUtil.uuid() + ".gif";
|
||||||
|
minioClient.putObject(
|
||||||
|
minioConfig.getBucketName(), gifFileName, gifInputStream, gifputObjectOptions);
|
||||||
|
gifInputStream.close();
|
||||||
|
tenPerson.setFaceModel(gifFileName);
|
||||||
|
File dirFile = gifFile.getParentFile();
|
||||||
|
gifFile.delete();
|
||||||
|
dirFile.delete();
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
return R.error(e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//处理类型:
|
//处理类型:
|
||||||
//1. 不是固定类型,给一个默认的家属类型
|
//1. 不是固定类型,给一个默认的家属类型
|
||||||
if(tenPerson.getPersonType()>10000){
|
if(tenPerson.getPersonType()>10000){
|
||||||
|
@ -1304,7 +1315,9 @@ public class HttpApiController {
|
||||||
//----------------------------------------以下业务-----------------------------------------------------
|
//----------------------------------------以下业务-----------------------------------------------------
|
||||||
JSONObject personJson = jsonContent.getJSONObject("data");
|
JSONObject personJson = jsonContent.getJSONObject("data");
|
||||||
TenPersonEntity tenPerson = JSONObject.toJavaObject(personJson,TenPersonEntity.class);
|
TenPersonEntity tenPerson = JSONObject.toJavaObject(personJson,TenPersonEntity.class);
|
||||||
tenPerson.setThdFeature(thdFeature);
|
if(thdFeature!=null && thdFeature.length()>0){
|
||||||
|
tenPerson.setThdFeature(thdFeature);
|
||||||
|
}
|
||||||
tenPerson.setPersonId(personJson.getLong("uid"));
|
tenPerson.setPersonId(personJson.getLong("uid"));
|
||||||
|
|
||||||
if(tenPerson.getIdCard()!=null){
|
if(tenPerson.getIdCard()!=null){
|
||||||
|
|
Loading…
Reference in New Issue