人员下发修改-添加图片删除
This commit is contained in:
parent
53881f266b
commit
f10573b5fd
|
|
@ -163,8 +163,10 @@ public class IntelligentLibraryUtil {
|
|||
public static String queryPersonImage(PersonImageVo param){
|
||||
try {
|
||||
DigestAuthClient client = new DigestAuthClient(DIGEST_USER, md5(DIGEST_PWD));
|
||||
String url = BASE_URL + "/label/slice/" + param.getSlice_index(); // 构造请求URL
|
||||
return client.get(url); // 使用DigestAuthClient发送GET请求
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
String jsonBody = mapper.writeValueAsString(param);
|
||||
// 将参数转换为JSON字符串
|
||||
return client.post(BASE_URL + "/label/slice", jsonBody); // 使用DigestAuthClient发送POST请求
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return "Error: " + e.getMessage(); // 捕获异常并返回错误信息
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
package com.bonus.business.service.impl;
|
||||
|
||||
import cn.hutool.json.JSONArray;
|
||||
import cn.hutool.json.JSONObject;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.alibaba.fastjson2.JSONArray;
|
||||
import com.bonus.business.mapper.PersonFaceMapper;
|
||||
import com.bonus.business.mapper.RobotMapper;
|
||||
import com.bonus.business.robot.util.IntelligentLibraryUtil;
|
||||
|
|
@ -121,6 +121,7 @@ public class PersonFaceServiceImpl implements IPersonFaceService {
|
|||
String result = IntelligentLibraryUtil.addPerson(personVo);
|
||||
JSONObject entries = JSONUtil.parseObj(result);
|
||||
if (entries.getInt("code") == 0) {
|
||||
//添加成功,获取到index
|
||||
JSONObject datas = entries.getJSONObject("datas");
|
||||
personVo.setIndex(datas.getInt("label_index"));
|
||||
} else if (entries.getInt("code") == 7) {
|
||||
|
|
@ -129,21 +130,44 @@ public class PersonFaceServiceImpl implements IPersonFaceService {
|
|||
String result2 = IntelligentLibraryUtil.updatePerson(vo);
|
||||
JSONObject entries2 = JSONUtil.parseObj(result2);
|
||||
if (entries2.getInt("code") == 0) {
|
||||
|
||||
//修改成功,无需其他操作
|
||||
} else {
|
||||
//修改失败,添加错误信息
|
||||
sb.append(personVo.getName()).append(":").append(entries.getStr("message")).append("\n");
|
||||
}
|
||||
} else {
|
||||
//添加失败,添加错误信息
|
||||
sb.append(personVo.getName()).append(":").append(entries.getStr("message")).append("\n");
|
||||
}
|
||||
//调用添加照片
|
||||
if (personVo.getIndex() > 0) {
|
||||
//先查询图片数量
|
||||
PersonImageVo personImageVo = new PersonImageVo();
|
||||
personImageVo.setGroupname("robotV1");
|
||||
personImageVo.setLabel_index(personVo.getIndex());
|
||||
personImageVo.setImagePath(personVo.getImage());
|
||||
String result3 = IntelligentLibraryUtil.addPersonImage(personImageVo);
|
||||
personImageVo.setRows(4);
|
||||
//根据index查询图片
|
||||
String result3 = IntelligentLibraryUtil.queryPersonImage(personImageVo);
|
||||
JSONObject entries3 = JSONUtil.parseObj(result3);
|
||||
if (entries3.getInt("code") == 0) {
|
||||
Integer total = entries3.getInt("total");
|
||||
//如果图片满了,就全部删除
|
||||
if(total>=4){
|
||||
JSONArray datas = entries3.getJSONArray("datas");
|
||||
for (int i = 0; i < total; i++) {
|
||||
personImageVo.setImage_id(datas.getJSONObject(i).getInt("index"));
|
||||
String result4 = IntelligentLibraryUtil.removePersonImage(personImageVo);
|
||||
JSONObject entries4 = JSONUtil.parseObj(result4);
|
||||
if (entries4.getInt("code") == 0) {
|
||||
//删除成功
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//添加图片
|
||||
personImageVo.setImagePath(personVo.getImage());
|
||||
String result5 = IntelligentLibraryUtil.addPersonImage(personImageVo);
|
||||
JSONObject entries5 = JSONUtil.parseObj(result3);
|
||||
if (entries3.getInt("code") == 0) {
|
||||
m++;
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Reference in New Issue