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