|
@@ -0,0 +1,94 @@
|
|
|
+package com.yx.face.service.impl;
|
|
|
+
|
|
|
+import com.alibaba.excel.util.StringUtils;
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.yx.face.boot.uitls.DateUtils;
|
|
|
+import com.yx.face.boot.uitls.OkHttpUtils;
|
|
|
+import com.yx.face.dao.FaceDeviceDao;
|
|
|
+import com.yx.face.model.dto.BiJieGADto;
|
|
|
+import com.yx.face.model.entity.FaceDevice;
|
|
|
+import com.yx.face.model.entity.FaceLog;
|
|
|
+import com.yx.face.service.PushToThirdPartyService;
|
|
|
+import com.yx.face.utils.Sm4Util;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+import javax.annotation.Resource;
|
|
|
+import java.util.Objects;
|
|
|
+
|
|
|
+
|
|
|
+/**
|
|
|
+ * @description: 发送给第三方
|
|
|
+ * @date: 2024/12/11 >
|
|
|
+ * @author: LSH
|
|
|
+ */
|
|
|
+
|
|
|
+@Service
|
|
|
+@Slf4j
|
|
|
+public class PushToThirdPartyServiceImpl implements PushToThirdPartyService {
|
|
|
+
|
|
|
+ //毕节公安
|
|
|
+ @Value("${push-to-third-party.bijiega-url}")
|
|
|
+ private String biJieGAUrl;
|
|
|
+ //毕节公安
|
|
|
+ @Value("${push-to-third-party.bijiega-key}")
|
|
|
+ private String biJieSm4Key;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private FaceDeviceDao faceDeviceDao;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void sendToOther(Integer adminId, FaceLog faceLog, String photo) {
|
|
|
+ try {
|
|
|
+ if (83 == adminId) {
|
|
|
+ this.sendToBiJie(faceLog, photo);
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("推送到第三方异常:" + e.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 推送毕节闸机数据到毕节公安
|
|
|
+ * @param faceLog
|
|
|
+ * @param photo
|
|
|
+ */
|
|
|
+ private void sendToBiJie(FaceLog faceLog, String photo) {
|
|
|
+
|
|
|
+ FaceDevice faceDevice = faceDeviceDao.getFaceDeviceBySn(faceLog.getDeviceSn());
|
|
|
+ BiJieGADto biJieDto = new BiJieGADto();
|
|
|
+
|
|
|
+ biJieDto.setId(faceLog.getId().toString());
|
|
|
+ biJieDto.setName(StringUtils.isEmpty(faceLog.getName()) ? "未记录" : faceLog.getName());
|
|
|
+ biJieDto.setZjhm(faceLog.getCardid());
|
|
|
+ biJieDto.setZjlx(faceLog.getSfzCardType());
|
|
|
+ if (Objects.nonNull(faceDevice) && !StringUtils.isEmpty(faceDevice.getName())) {
|
|
|
+ biJieDto.setZjmc(faceDevice.getName());
|
|
|
+ }
|
|
|
+ biJieDto.setZjdz(faceLog.getDeviceSn());
|
|
|
+ biJieDto.setTgtime(faceLog.getFaceTime());
|
|
|
+ biJieDto.setZjbh(faceLog.getDeviceSn());
|
|
|
+ biJieDto.setTstime(DateUtils.dateTimeNow());
|
|
|
+ String bijieData = JSON.toJSONString(biJieDto);
|
|
|
+ log.info("推送给毕节公安数据:" + bijieData);
|
|
|
+ biJieDto.setImage(photo);
|
|
|
+ bijieData = JSON.toJSONString(biJieDto);
|
|
|
+ String encStr = Sm4Util.encryptByHexKey(bijieData, biJieSm4Key);
|
|
|
+ JSONObject jsonObject = new JSONObject();
|
|
|
+ jsonObject.put("data", encStr);
|
|
|
+ String body = JSON.toJSONString(jsonObject);
|
|
|
+
|
|
|
+ String result = OkHttpUtils.builder().url(biJieGAUrl).localPost(body).sync();
|
|
|
+ log.info("推送到毕节公安响应结果:{}",result);
|
|
|
+ if (!"5".equals(result)){
|
|
|
+ throw new RuntimeException("推送到毕节公安异常:" + result);
|
|
|
+ }else {
|
|
|
+ log.info("推送到毕节公安,姓名:{},身份证:{}", faceLog.getName(), faceLog.getCardid());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+}
|
|
|
+
|