|
@ -4,11 +4,11 @@ import com.alibaba.fastjson.JSON; |
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
import com.epmet.commons.tools.exception.EpmetErrorCode; |
|
|
import com.epmet.commons.tools.exception.EpmetErrorCode; |
|
|
import com.epmet.commons.tools.exception.EpmetException; |
|
|
import com.epmet.commons.tools.exception.EpmetException; |
|
|
import com.epmet.commons.tools.exception.RenException; |
|
|
|
|
|
import com.epmet.commons.tools.utils.ConvertUtils; |
|
|
import com.epmet.commons.tools.utils.ConvertUtils; |
|
|
import com.epmet.commons.tools.utils.HttpClientManager; |
|
|
import com.epmet.commons.tools.utils.HttpClientManager; |
|
|
import com.epmet.commons.tools.utils.Result; |
|
|
import com.epmet.commons.tools.utils.Result; |
|
|
import com.epmet.plugin.power.config.HikCloudProperties; |
|
|
import com.epmet.plugin.power.config.HikCloudProperties; |
|
|
|
|
|
import com.epmet.plugin.power.dto.hik.form.HikPersonFormDTO; |
|
|
import org.slf4j.Logger; |
|
|
import org.slf4j.Logger; |
|
|
import org.slf4j.LoggerFactory; |
|
|
import org.slf4j.LoggerFactory; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
@ -32,6 +32,7 @@ public class HkDeviceUtil { |
|
|
|
|
|
|
|
|
private final String GET_ACCESS_TOKEN = "/oauth/token"; |
|
|
private final String GET_ACCESS_TOKEN = "/oauth/token"; |
|
|
private final String GET_DEVICES = "/api/v1/estate/devices"; |
|
|
private final String GET_DEVICES = "/api/v1/estate/devices"; |
|
|
|
|
|
private final String SEND_PERSON = "/api/v1/estate/system/person"; |
|
|
|
|
|
|
|
|
private final String GRANT_TYPE = "client_credentials"; |
|
|
private final String GRANT_TYPE = "client_credentials"; |
|
|
|
|
|
|
|
@ -62,25 +63,43 @@ public class HkDeviceUtil { |
|
|
} |
|
|
} |
|
|
return toResult.get("access_token").toString(); |
|
|
return toResult.get("access_token").toString(); |
|
|
} |
|
|
} |
|
|
//
|
|
|
|
|
|
// public String getDevices() {
|
|
|
/** |
|
|
// String url = hikCloudProperties.getUrl().concat(GET_DEVICES);
|
|
|
* 下发人员 |
|
|
// Map<String, Object> paramsMap = new HashMap<>(8);
|
|
|
* |
|
|
// paramsMap.put("deviceId", hikCloudProperties.getClient());
|
|
|
* @param token |
|
|
//
|
|
|
* @return java.lang.String 人员ID |
|
|
//
|
|
|
* @author zhy |
|
|
// String data = HttpClientManager.getInstance().sendGet(ThirdApiConstant.THIRD_PAUSER_SAVEUSER, JSON.toJSONString(dto)).getData();
|
|
|
* @date 2022/5/23 10:08 |
|
|
// JSONObject toResult = JSON.parseObject(data);
|
|
|
*/ |
|
|
// Result result = ConvertUtils.mapToEntity(toResult, Result.class);
|
|
|
public String sendPerson(String token) { |
|
|
// if (null != toResult.get("code")) {
|
|
|
String url = hikCloudProperties.getUrl().concat(SEND_PERSON); |
|
|
// result.setCode(((Integer) toResult.get("code")).intValue());
|
|
|
Map<String, String> paramsMap = new HashMap<>(4); |
|
|
// }
|
|
|
paramsMap.put("Authorization", token); |
|
|
// if (!result.success()) {
|
|
|
|
|
|
// throw new RenException(PublicUserLoginConstant.SAVE_USER_EXCEPTION);
|
|
|
HikPersonFormDTO dto = new HikPersonFormDTO(); |
|
|
// }
|
|
|
dto.setPersonName("张三"); |
|
|
// Object RegisterResult = result.getData();
|
|
|
dto.setGender(1); |
|
|
// JSONObject jsonObject = JSON.parseObject(RegisterResult.toString());
|
|
|
dto.setCredentialType(1); |
|
|
// SaveUserResultDTO resultDTO = ConvertUtils.mapToEntity(jsonObject, SaveUserResultDTO.class);
|
|
|
dto.setCredentialNumber("350781196403072329"); |
|
|
//
|
|
|
dto.setMobile("17890987654"); |
|
|
// }
|
|
|
dto.setFaceUrl("https://ai-security-protection.oss-cn-qingdao.aliyuncs.com/test/20220501/b714a5d77e46449980ad7d6dcf3d3aab.jpg"); |
|
|
|
|
|
String data = HttpClientManager.getInstance().sendPostByJSONAndHeader(url, JSON.toJSONString(dto), paramsMap).getData(); |
|
|
|
|
|
|
|
|
|
|
|
if (null == data) { |
|
|
|
|
|
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "人员信息下发失败"); |
|
|
|
|
|
} |
|
|
|
|
|
JSONObject toResult = JSON.parseObject(data); |
|
|
|
|
|
Result result = ConvertUtils.mapToEntity(toResult, Result.class); |
|
|
|
|
|
if (null != toResult.get("code")) { |
|
|
|
|
|
result.setCode(((Integer) toResult.get("code")).intValue()); |
|
|
|
|
|
} |
|
|
|
|
|
if (!result.success()) { |
|
|
|
|
|
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "人员信息下发失败"); |
|
|
|
|
|
} |
|
|
|
|
|
Object RegisterResult = result.getData(); |
|
|
|
|
|
JSONObject jsonObject = JSON.parseObject(RegisterResult.toString()); |
|
|
|
|
|
return "11111111111111111"; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|