2025-07-31 11:07:51 +08:00
|
|
|
package com.zhgd.mqtt.server;
|
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
2025-08-12 09:41:20 +08:00
|
|
|
import com.zhgd.xmgl.modules.worker.service.IUfaceDevService;
|
2025-07-31 11:07:51 +08:00
|
|
|
import com.zhgd.xmgl.modules.worker.service.IWorkerAttendanceService;
|
|
|
|
|
import com.zhgd.xmgl.modules.xz.service.IXzHikvisionSyncService;
|
|
|
|
|
import net.sf.jsqlparser.statement.select.PlainSelect;
|
|
|
|
|
import org.springframework.messaging.Message;
|
|
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
|
|
|
|
|
@Component
|
|
|
|
|
public class DispatchHandler {
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
private IXzHikvisionSyncService xzHikvisionSyncService;
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
private IWorkerAttendanceService workerAttendanceService;
|
|
|
|
|
|
2025-08-12 09:41:20 +08:00
|
|
|
@Resource
|
|
|
|
|
private IUfaceDevService ufaceDevService;
|
|
|
|
|
|
2025-07-31 11:07:51 +08:00
|
|
|
public void message(String topic, Object payLoad) {
|
|
|
|
|
// 下发人脸返回
|
|
|
|
|
if (topic.contains("mqtt/face/") && topic.contains("/Ack")) {
|
|
|
|
|
JSONObject jsonObject = JSONObject.parseObject(payLoad.toString());
|
|
|
|
|
if (jsonObject.getString("code").equals("200")) {
|
|
|
|
|
JSONArray jsonArray = jsonObject.getJSONObject("info").getJSONArray("AddSucInfo");
|
|
|
|
|
xzHikvisionSyncService.mqttAck(topic.split("/")[2], jsonArray, 1);
|
|
|
|
|
JSONArray errorArray = jsonObject.getJSONObject("info").getJSONArray("AddErrInfo");
|
|
|
|
|
xzHikvisionSyncService.mqttAck(topic.split("/")[2], errorArray, 0);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// 人脸识别推送
|
|
|
|
|
if (topic.contains("mqtt/face/") && topic.contains("/Rec")) {
|
|
|
|
|
JSONObject jsonObject = JSONObject.parseObject(payLoad.toString());
|
|
|
|
|
workerAttendanceService.mqttRec(topic.split("/")[2], jsonObject);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//正赢人脸下发返回
|
|
|
|
|
if (topic.equals("face/createFace/response")) {
|
|
|
|
|
JSONObject jsonObject = JSONObject.parseObject(payLoad.toString());
|
|
|
|
|
if (jsonObject.getString("code").equals("0")) {
|
|
|
|
|
xzHikvisionSyncService.zyMqttAck(jsonObject.getString("sn"), jsonObject.getString("pers_id"), 1);
|
|
|
|
|
} else {
|
|
|
|
|
xzHikvisionSyncService.zyMqttAck(jsonObject.getString("sn"), jsonObject.getString("pers_id"), 0);
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-08-27 15:19:43 +08:00
|
|
|
//正赢删除人脸下发返回
|
|
|
|
|
if (topic.equals("face/deleteFace/response")) {
|
|
|
|
|
JSONObject jsonObject = JSONObject.parseObject(payLoad.toString());
|
|
|
|
|
if (jsonObject.getString("code").equals("0")) {
|
|
|
|
|
xzHikvisionSyncService.zyDelMqttAck(jsonObject.getString("sn"), jsonObject.getString("pers_id"));
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-07-31 11:07:51 +08:00
|
|
|
// 正赢人脸识别推送
|
|
|
|
|
if (topic.equals("face/response")) {
|
|
|
|
|
JSONObject jsonObject = JSONObject.parseObject(payLoad.toString());
|
|
|
|
|
JSONObject body = jsonObject.getJSONObject("body");
|
|
|
|
|
workerAttendanceService.zyMqttRec(body);
|
|
|
|
|
}
|
2025-08-12 09:41:20 +08:00
|
|
|
// 正赢人脸设备心跳推送
|
|
|
|
|
if (topic.equals("heartbeat/response")) {
|
|
|
|
|
JSONObject jsonObject = JSONObject.parseObject(payLoad.toString());
|
2025-08-12 10:55:57 +08:00
|
|
|
ufaceDevService.online(jsonObject.getString("sn"));
|
2025-08-12 09:41:20 +08:00
|
|
|
}
|
|
|
|
|
|
2025-07-31 11:07:51 +08:00
|
|
|
}
|
|
|
|
|
}
|