bug修复

This commit is contained in:
GUO 2024-05-04 00:42:15 +08:00
parent cc17336afe
commit 50ee219c44
2 changed files with 57 additions and 18 deletions

View File

@ -645,7 +645,7 @@ public class HikvisionCall {
String svrIndex = null; String svrIndex = null;
String platePicUrl = null; String platePicUrl = null;
WorkerInfo workerInfo = workerInfoMapper.selectById(1765673550491725825L); WorkerInfo workerInfo = workerInfoMapper.selectById(1765673550491725825L);
getWorkerInfo(workerInfo, project); getWorkerInfoByPersonId(workerInfo, project);
return null; return null;
} }
@ -768,6 +768,12 @@ public class HikvisionCall {
} }
public void addWorkerFromHttp(WorkerInfo workerInfo, Project project) throws Exception { public void addWorkerFromHttp(WorkerInfo workerInfo, Project project) throws Exception {
// JSONObject wiJo = getWorkerInfoByCertificateNo(workerInfo, project);
// if (wiJo != null) {
// WorkerInfo deleteWorker = BeanUtil.toBean(workerInfo, WorkerInfo.class);
// deleteWorker.setId(wiJo.getLong("personId"));
// deleteWorkerFromHttp(deleteWorker, project);
// }
String rs = doAddWorkerFromHttp(workerInfo, project); String rs = doAddWorkerFromHttp(workerInfo, project);
sendNoticeForWorker("添加人员到海康isc", rs, workerInfo, 1, 1); sendNoticeForWorker("添加人员到海康isc", rs, workerInfo, 1, 1);
} }
@ -820,7 +826,7 @@ public class HikvisionCall {
if (project == null || !Objects.equals(project.getSyncHikvision(), 1)) { if (project == null || !Objects.equals(project.getSyncHikvision(), 1)) {
return; return;
} }
JSONObject wiJo = getWorkerInfo(workerInfo, project); JSONObject wiJo = getWorkerInfoByPersonId(workerInfo, project);
if (wiJo != null) { if (wiJo != null) {
editWorkerFromHttp(workerInfo, project); editWorkerFromHttp(workerInfo, project);
@ -881,8 +887,16 @@ public class HikvisionCall {
title += "成功"; title += "成功";
setSuccessByNow(carInfo.getProjectSn(), carInfo.getId(), type, operate, ThreadLocalUtil.getNotNull().getDate("now"), null); setSuccessByNow(carInfo.getProjectSn(), carInfo.getId(), type, operate, ThreadLocalUtil.getNotNull().getDate("now"), null);
} else { } else {
msg = "同步失败,车牌号码:" + carInfo.getCarNumber() + "。失败原因:" + rs; JSONObject jo = JSONObject.parseObject(rs);
title += "失败"; String code = jo.getString("code");
if (Objects.equals(code, "0x00072202")) {
msg = "同步成功,车牌号码:" + carInfo.getCarNumber();
title += "成功";
setSuccessByNow(carInfo.getProjectSn(), carInfo.getId(), type, operate, ThreadLocalUtil.getNotNull().getDate("now"), null);
} else {
msg = "同步失败,车牌号码:" + carInfo.getCarNumber() + "。失败原因:下发异常";
title += "失败";
}
} }
noticeService.addUserNotice(SecurityUtils.getUser().getUserId(), msg, title, "24"); noticeService.addUserNotice(SecurityUtils.getUser().getUserId(), msg, title, "24");
} }
@ -1038,7 +1052,7 @@ public class HikvisionCall {
* @param workerInfo * @param workerInfo
* @param project * @param project
*/ */
private void editWorkerFace(WorkerInfo workerInfo, Project project) throws Exception { public void editWorkerFace(WorkerInfo workerInfo, Project project) throws Exception {
ArrayList<String> workerFaceIds = getWorkerFaceIds(workerInfo, project); ArrayList<String> workerFaceIds = getWorkerFaceIds(workerInfo, project);
if (CollUtil.isNotEmpty(workerFaceIds)) { if (CollUtil.isNotEmpty(workerFaceIds)) {
String workerFaceId = workerFaceIds.get(0); String workerFaceId = workerFaceIds.get(0);
@ -1086,7 +1100,7 @@ public class HikvisionCall {
return rs; return rs;
} }
private void deleteWorkerFace(WorkerInfo workerInfo, Project project) throws Exception { public void deleteWorkerFace(WorkerInfo workerInfo, Project project) throws Exception {
ArrayList<String> workerFaceIds = getWorkerFaceIds(workerInfo, project); ArrayList<String> workerFaceIds = getWorkerFaceIds(workerInfo, project);
if (CollUtil.isNotEmpty(workerFaceIds)) { if (CollUtil.isNotEmpty(workerFaceIds)) {
for (String workerFaceId : workerFaceIds) { for (String workerFaceId : workerFaceIds) {
@ -1121,7 +1135,7 @@ public class HikvisionCall {
* @return * @return
*/ */
private ArrayList<String> getWorkerFaceIds(WorkerInfo workerInfo, Project project) throws Exception { private ArrayList<String> getWorkerFaceIds(WorkerInfo workerInfo, Project project) throws Exception {
JSONObject joData = getWorkerInfo(workerInfo, project); JSONObject joData = getWorkerInfoByPersonId(workerInfo, project);
ArrayList<String> ids = new ArrayList<>(); ArrayList<String> ids = new ArrayList<>();
if (joData != null) { if (joData != null) {
JSONArray ppJa = joData.getJSONArray("personPhoto"); JSONArray ppJa = joData.getJSONArray("personPhoto");
@ -1142,7 +1156,7 @@ public class HikvisionCall {
* @param project * @param project
* @return * @return
*/ */
private JSONObject getWorkerInfo(WorkerInfo workerInfo, Project project) throws Exception { private JSONObject getWorkerInfoByPersonId(WorkerInfo workerInfo, Project project) throws Exception {
final String ARTEMIS_PATH = "/artemis"; final String ARTEMIS_PATH = "/artemis";
final String path = ARTEMIS_PATH + "/api/resource/v1/person/condition/personInfo"; final String path = ARTEMIS_PATH + "/api/resource/v1/person/condition/personInfo";
String host = "https://" + project.getArtemisConfigHost(); String host = "https://" + project.getArtemisConfigHost();
@ -1151,14 +1165,39 @@ public class HikvisionCall {
jo.put("paramValue", Arrays.asList(String.valueOf(workerInfo.getId()))); jo.put("paramValue", Arrays.asList(String.valueOf(workerInfo.getId())));
String rs = HikvisionUtil.doPost(host, path, jo.toJSONString(), null, project.getArtemisConfigAppKey(), project.getArtemisConfigAppSecret()); String rs = HikvisionUtil.doPost(host, path, jo.toJSONString(), null, project.getArtemisConfigAppKey(), project.getArtemisConfigAppSecret());
JSONObject joData = HikvisionUtil.getJSONObjectData(rs); JSONObject joData = HikvisionUtil.getJSONObjectData(rs);
if (joData != null) { Integer total = joData.getInteger("total");
Integer total = joData.getInteger("total"); if (Objects.equals(total, 1)) {
if (Objects.equals(total, 1)) { JSONArray jsonArray = joData.getJSONArray("list");
JSONArray jsonArray = joData.getJSONArray("list"); for (int i = 0; i < jsonArray.size(); i++) {
for (int i = 0; i < jsonArray.size(); i++) { JSONObject jsonObject = jsonArray.getJSONObject(i);
JSONObject jsonObject = jsonArray.getJSONObject(i); return jsonObject;
return jsonObject; }
} }
return null;
}
/**
* 获取单个劳务人员信息根据人员身份证
*
* @param workerInfo
* @param project
* @return
*/
private JSONObject getWorkerInfoByCertificateNo(WorkerInfo workerInfo, Project project) throws Exception {
final String ARTEMIS_PATH = "/artemis";
final String path = ARTEMIS_PATH + "/api/resource/v1/person/condition/personInfo";
String host = "https://" + project.getArtemisConfigHost();
JSONObject jo = new JSONObject();
jo.put("paramName", "certificateNo");
jo.put("paramValue", Arrays.asList(String.valueOf(workerInfo.getIdCard())));
String rs = HikvisionUtil.doPost(host, path, jo.toJSONString(), null, project.getArtemisConfigAppKey(), project.getArtemisConfigAppSecret());
JSONObject joData = HikvisionUtil.getJSONObjectData(rs);
Integer total = joData.getInteger("total");
if (Objects.equals(total, 1)) {
JSONArray jsonArray = joData.getJSONArray("list");
for (int i = 0; i < jsonArray.size(); i++) {
JSONObject jsonObject = jsonArray.getJSONObject(i);
return jsonObject;
} }
} }
return null; return null;

View File

@ -226,9 +226,9 @@ public class XzHikvisionSyncServiceImpl extends ServiceImpl<XzHikvisionSyncMappe
if (xzHikvisionSync.getOperate() == 1) { if (xzHikvisionSync.getOperate() == 1) {
hikvisionCall.addWorkerFace(workerInfo, p); hikvisionCall.addWorkerFace(workerInfo, p);
} else if (xzHikvisionSync.getOperate() == 2) { } else if (xzHikvisionSync.getOperate() == 2) {
hikvisionCall.editWorkerFromHttp(workerInfo, p); hikvisionCall.editWorkerFace(workerInfo, p);
} else if (xzHikvisionSync.getOperate() == 3) { } else if (xzHikvisionSync.getOperate() == 3) {
hikvisionCall.deleteWorkerFromHttp(workerInfo, p); hikvisionCall.deleteWorkerFace(workerInfo, p);
} }
} else if (xzHikvisionSync.getType() == 3) { } else if (xzHikvisionSync.getType() == 3) {
StringBuilder sucSb = new StringBuilder(); StringBuilder sucSb = new StringBuilder();