|
|
@ -11,10 +11,8 @@ import com.epmet.commons.tools.utils.ConvertUtils; |
|
|
|
import com.epmet.commons.tools.utils.HttpClientManager; |
|
|
|
import com.epmet.plugin.commons.redis.RedisKeys; |
|
|
|
import com.epmet.plugin.power.config.DhCloudProperties; |
|
|
|
import com.epmet.plugin.power.dto.visit.form.DhAuthFormDTO; |
|
|
|
import com.epmet.plugin.power.dto.visit.form.DhPersonCardFormDTO; |
|
|
|
import com.epmet.plugin.power.dto.visit.form.DhPersonFormDTO; |
|
|
|
import com.epmet.plugin.power.dto.visit.form.DhPersonImgFormDTO; |
|
|
|
import com.epmet.plugin.power.dto.visit.DhTokenDTO; |
|
|
|
import com.epmet.plugin.power.dto.visit.form.*; |
|
|
|
import com.epmet.plugin.power.dto.visit.result.DhChannelResultDTO; |
|
|
|
import net.coobird.thumbnailator.Thumbnails; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
@ -54,9 +52,13 @@ public class DhDeviceUtil { |
|
|
|
private final String GET_PERSON_IDENTITY = "/CardSolution/card/person/personidentity"; |
|
|
|
private final String GET_DOOR_PLAN = "/CardSolution/card/accessControl/timeQuantum/1/page"; |
|
|
|
private final String GET_DOOR_CHANNEL = "/CardSolution/card/accessControl/channel/bycondition/combined"; |
|
|
|
private final String ADD_PERSON = " /CardSolution/card/person"; |
|
|
|
private final String ADD_PERSON = "/CardSolution/card/person"; |
|
|
|
private final String LIST_PERSON = "/CardSolution/card/person/bycondition/combined"; |
|
|
|
private final String DEL_PERSON = "/CardSolution/card/person/delete"; |
|
|
|
private final String ADD_PERSON_IMG = "/CardSolution/common/saveMobileBase64ImageToByte"; |
|
|
|
private final String ADD_AUTH = "/CardSolution/card/accessControl/doorAuthority/update"; |
|
|
|
private final String LIST_CARD = "/CardSolution/card/card/bycondition/combined"; |
|
|
|
private final String DEL_CARD = "/CardSolution/card/card/returnByNumber/"; |
|
|
|
private final String OPEN_CARD = "/CardSolution/card/card/open/batch"; |
|
|
|
|
|
|
|
/** |
|
|
@ -75,10 +77,13 @@ public class DhDeviceUtil { |
|
|
|
} |
|
|
|
|
|
|
|
String url = dhCloudProperties.getUrl().concat(GET_PUBLIC_KEY); |
|
|
|
Map<String, Object> paramsMap = new HashMap<>(4); |
|
|
|
paramsMap.put("loginName", dhCloudProperties.getLoginName()); |
|
|
|
Map<String, String> paramsMap = new HashMap<>(4); |
|
|
|
|
|
|
|
DhPublicKeyFormDTO dto = new DhPublicKeyFormDTO(); |
|
|
|
dto.setLoginName(dhCloudProperties.getLoginName()); |
|
|
|
|
|
|
|
String data = HttpClientManager.getInstance().sendPostByJSONAndHeader(url, JSON.toJSONString(dto), paramsMap).getData(); |
|
|
|
|
|
|
|
String data = HttpClientManager.getInstance().sendPost(url, paramsMap).getData(); |
|
|
|
if (null == data) { |
|
|
|
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "publicKey获取失败"); |
|
|
|
} |
|
|
@ -87,10 +92,10 @@ public class DhDeviceUtil { |
|
|
|
if (!toResult.containsKey("publicKey")) { |
|
|
|
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "publicKey获取失败"); |
|
|
|
} |
|
|
|
String accessToken = toResult.get("publicKey").toString(); |
|
|
|
String publicKey = toResult.get("publicKey").toString(); |
|
|
|
|
|
|
|
redisUtils.set(key, accessToken, RedisUtils.MINUTE_THIRTY_EXPIRE); |
|
|
|
return accessToken; |
|
|
|
redisUtils.set(key, publicKey, RedisUtils.MINUTE_THIRTY_EXPIRE); |
|
|
|
return publicKey; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
@ -101,19 +106,28 @@ public class DhDeviceUtil { |
|
|
|
* @author zhy |
|
|
|
* @date 2022/5/20 16:40 |
|
|
|
*/ |
|
|
|
public DhToken getLoginPass(String publicKey) { |
|
|
|
public DhTokenDTO getLoginPass(String publicKey) { |
|
|
|
String key = RedisKeys.getDhToken(); |
|
|
|
Object obj = redisUtils.get(key); |
|
|
|
if (null != obj) { |
|
|
|
return (DhToken) obj; |
|
|
|
return (DhTokenDTO) obj; |
|
|
|
} |
|
|
|
|
|
|
|
String url = dhCloudProperties.getUrl().concat(GET_LOGIN_PASS); |
|
|
|
Map<String, Object> paramsMap = new HashMap<>(8); |
|
|
|
paramsMap.put("loginName", dhCloudProperties.getLoginName()); |
|
|
|
paramsMap.put("loginPass", publicKey); |
|
|
|
Map<String, String> paramsMap = new HashMap<>(4); |
|
|
|
|
|
|
|
DhLoginPassFormDTO dto = new DhLoginPassFormDTO(); |
|
|
|
dto.setLoginName(dhCloudProperties.getLoginName()); |
|
|
|
String pwd; |
|
|
|
try { |
|
|
|
pwd = RSAUtils.getPwdByRsa(publicKey, dhCloudProperties.getLoginPass()); |
|
|
|
} catch (Exception e) { |
|
|
|
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "loginPass加密失败"); |
|
|
|
} |
|
|
|
dto.setLoginPass(pwd); |
|
|
|
|
|
|
|
String data = HttpClientManager.getInstance().sendPostByJSONAndHeader(url, JSON.toJSONString(dto), paramsMap).getData(); |
|
|
|
|
|
|
|
String data = HttpClientManager.getInstance().sendPost(url, paramsMap).getData(); |
|
|
|
if (null == data) { |
|
|
|
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "loginPass获取失败"); |
|
|
|
} |
|
|
@ -122,7 +136,7 @@ public class DhDeviceUtil { |
|
|
|
if (!toResult.containsKey("token")) { |
|
|
|
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "loginPass获取失败"); |
|
|
|
} |
|
|
|
DhToken token = new DhToken(); |
|
|
|
DhTokenDTO token = new DhTokenDTO(); |
|
|
|
token.setId(toResult.get("id").toString()); |
|
|
|
token.setLoginName(toResult.get("loginName").toString()); |
|
|
|
token.setPublicKey(toResult.get("publicKey").toString()); |
|
|
@ -132,7 +146,7 @@ public class DhDeviceUtil { |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 查询部门列表 |
|
|
|
* 新增部门 |
|
|
|
* |
|
|
|
* @param |
|
|
|
* @return java.lang.String |
|
|
@ -144,9 +158,12 @@ public class DhDeviceUtil { |
|
|
|
String urlParam = getDhUrlParams(); |
|
|
|
url = url + urlParam; |
|
|
|
|
|
|
|
Map<String, String> paramsMap = new HashMap<>(4); |
|
|
|
Map<String, Object> paramsMap = new HashMap<>(4); |
|
|
|
// DhDeptFormDTO dto = new DhDeptFormDTO();
|
|
|
|
// dto.setName("访客部门");
|
|
|
|
// dto.setParentId(1L);
|
|
|
|
|
|
|
|
String data = HttpClientManager.getInstance().sendPostByJSONAndHeader(url, StringUtils.EMPTY, paramsMap).getData(); |
|
|
|
String data = HttpClientManager.getInstance().sendGet(url, paramsMap).getData(); |
|
|
|
|
|
|
|
if (null == data) { |
|
|
|
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "查询部门列表失败"); |
|
|
@ -158,15 +175,154 @@ public class DhDeviceUtil { |
|
|
|
} |
|
|
|
if (!result.getSuccess()) { |
|
|
|
logger.info(result.getErrMsg()); |
|
|
|
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "查询部门列表失败"); |
|
|
|
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "查询部门列表失败!" + result.getErrMsg()); |
|
|
|
} |
|
|
|
Object registerResult = result.getData(); |
|
|
|
|
|
|
|
JSONArray jsonArray = JSON.parseArray(registerResult.toString()); |
|
|
|
JSONObject jsonObject = jsonArray.getJSONObject(0); |
|
|
|
if (null != jsonObject) { |
|
|
|
return Long.parseLong(jsonObject.get("deptId").toString()); |
|
|
|
for (int i = 0; i < jsonArray.size(); i++) { |
|
|
|
if ("临时人员".equals(jsonArray.getJSONObject(i).get("name").toString())) { |
|
|
|
return Long.parseLong(jsonArray.getJSONObject(i).get("id").toString()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return null; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 人员预处理 |
|
|
|
* |
|
|
|
* @param |
|
|
|
* @return java.lang.String |
|
|
|
* @author zhy |
|
|
|
* @date 2022/5/23 10:08 |
|
|
|
*/ |
|
|
|
public void personHandle(String code) { |
|
|
|
String url = dhCloudProperties.getUrl().concat(LIST_PERSON); |
|
|
|
String urlParam = getDhUrlParams(); |
|
|
|
url = url + urlParam; |
|
|
|
|
|
|
|
Map<String, String> paramsMap = new HashMap<>(4); |
|
|
|
DhPersonPageFormDTO dto = new DhPersonPageFormDTO(); |
|
|
|
dto.setPageNum(1); |
|
|
|
dto.setPageSize(100); |
|
|
|
dto.setCode(code); |
|
|
|
|
|
|
|
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); |
|
|
|
DhResult result = ConvertUtils.mapToEntity(toResult, DhResult.class); |
|
|
|
if (null != toResult.get("success")) { |
|
|
|
result.setCode(200); |
|
|
|
} |
|
|
|
if (!result.getSuccess()) { |
|
|
|
logger.info(result.getErrMsg()); |
|
|
|
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "查询人员列表失败!" + result.getErrMsg()); |
|
|
|
} |
|
|
|
Object registerResult = result.getData(); |
|
|
|
|
|
|
|
JSONObject jsonObject = JSON.parseObject(registerResult.toString()); |
|
|
|
|
|
|
|
List<Integer> ids = new ArrayList<>(); |
|
|
|
JSONArray jsonArray = JSON.parseArray(jsonObject.get("pageData").toString()); |
|
|
|
for (int i = 0; i < jsonArray.size(); i++) { |
|
|
|
ids.add(Integer.parseInt(jsonArray.getJSONObject(i).get("id").toString())); |
|
|
|
} |
|
|
|
if (!ids.isEmpty()) { |
|
|
|
DhPersonDelFormDTO del = new DhPersonDelFormDTO(); |
|
|
|
del.setPersonIds(ids); |
|
|
|
delPerson(del); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 卡片预处理 |
|
|
|
* |
|
|
|
* @param |
|
|
|
* @return java.lang.String |
|
|
|
* @author zhy |
|
|
|
* @date 2022/5/23 10:08 |
|
|
|
*/ |
|
|
|
public void cardHandle(String code) { |
|
|
|
String url = dhCloudProperties.getUrl().concat(LIST_CARD); |
|
|
|
String urlParam = getDhUrlParams(); |
|
|
|
url = url + urlParam; |
|
|
|
|
|
|
|
Map<String, String> paramsMap = new HashMap<>(4); |
|
|
|
DhCardPageFormDTO dto = new DhCardPageFormDTO(); |
|
|
|
dto.setPageNum(1); |
|
|
|
dto.setPageSize(100); |
|
|
|
dto.setPersonCode(code); |
|
|
|
|
|
|
|
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); |
|
|
|
DhResult result = ConvertUtils.mapToEntity(toResult, DhResult.class); |
|
|
|
if (null != toResult.get("success")) { |
|
|
|
result.setCode(200); |
|
|
|
} |
|
|
|
if (!result.getSuccess()) { |
|
|
|
logger.info(result.getErrMsg()); |
|
|
|
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "查询卡片列表失败!" + result.getErrMsg()); |
|
|
|
} |
|
|
|
Object registerResult = result.getData(); |
|
|
|
|
|
|
|
JSONObject jsonObject = JSON.parseObject(registerResult.toString()); |
|
|
|
|
|
|
|
JSONArray jsonArray = JSON.parseArray(jsonObject.get("pageData").toString()); |
|
|
|
for (int i = 0; i < jsonArray.size(); i++) { |
|
|
|
delCard(jsonArray.getJSONObject(i).get("cardNumber").toString()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 删除人员 |
|
|
|
* |
|
|
|
* @param |
|
|
|
* @return java.lang.String |
|
|
|
* @author zhy |
|
|
|
* @date 2022/5/23 10:08 |
|
|
|
*/ |
|
|
|
public void delPerson(DhPersonDelFormDTO dto) { |
|
|
|
String url = dhCloudProperties.getUrl().concat(DEL_PERSON); |
|
|
|
String urlParam = getDhUrlParams(); |
|
|
|
url = url + urlParam; |
|
|
|
|
|
|
|
Map<String, String> paramsMap = new HashMap<>(4); |
|
|
|
|
|
|
|
String data = HttpClientManager.getInstance().sendPostByJSONAndHeader(url, JSON.toJSONString(dto), paramsMap).getData(); |
|
|
|
if (null == data) { |
|
|
|
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "删除人员失败"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 退卡 |
|
|
|
* |
|
|
|
* @param |
|
|
|
* @return java.lang.String |
|
|
|
* @author zhy |
|
|
|
* @date 2022/5/23 10:08 |
|
|
|
*/ |
|
|
|
public void delCard(String cardNum) { |
|
|
|
String url = dhCloudProperties.getUrl().concat(DEL_CARD); |
|
|
|
url = url + cardNum; |
|
|
|
String urlParam = getDhUrlParams(); |
|
|
|
url = url + urlParam; |
|
|
|
|
|
|
|
Map<String, String> paramsMap = new HashMap<>(4); |
|
|
|
|
|
|
|
String data = HttpClientManager.getInstance().sendPostByJSONAndHeader(url, StringUtils.EMPTY, paramsMap).getData(); |
|
|
|
if (null == data) { |
|
|
|
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "删除卡片失败"); |
|
|
|
} |
|
|
|
return 0L; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
@ -182,9 +338,14 @@ public class DhDeviceUtil { |
|
|
|
String urlParam = getDhUrlParams(); |
|
|
|
url = url + urlParam; |
|
|
|
|
|
|
|
Map<String, String> paramsMap = new HashMap<>(4); |
|
|
|
Map<String, Object> paramsMap = new HashMap<>(4); |
|
|
|
// DhIdentityFormDTO dto = new DhIdentityFormDTO();
|
|
|
|
// dto.setName("访客");
|
|
|
|
// dto.setSubsidyAmount(0D);
|
|
|
|
// dto.setIsCashRecharge(1);
|
|
|
|
// dto.setIsMachineRecharge(1);
|
|
|
|
|
|
|
|
String data = HttpClientManager.getInstance().sendPostByJSONAndHeader(url, StringUtils.EMPTY, paramsMap).getData(); |
|
|
|
String data = HttpClientManager.getInstance().sendGet(url, paramsMap).getData(); |
|
|
|
|
|
|
|
if (null == data) { |
|
|
|
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "获取身份列表失败"); |
|
|
@ -196,33 +357,39 @@ public class DhDeviceUtil { |
|
|
|
} |
|
|
|
if (!result.getSuccess()) { |
|
|
|
logger.info(result.getErrMsg()); |
|
|
|
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "获取身份列表失败"); |
|
|
|
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "获取身份列表失败!" + result.getErrMsg()); |
|
|
|
} |
|
|
|
Object registerResult = result.getData(); |
|
|
|
JSONArray jsonArray = JSON.parseArray(registerResult.toString()); |
|
|
|
JSONObject jsonObject = jsonArray.getJSONObject(0); |
|
|
|
if (null != jsonObject) { |
|
|
|
return jsonObject.get("id").toString(); |
|
|
|
for (int i = 0; i < jsonArray.size(); i++) { |
|
|
|
if ("默认身份".equals(jsonArray.getJSONObject(i).get("name").toString())) { |
|
|
|
return jsonArray.getJSONObject(i).get("id").toString(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return ""; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 查询开门计划 |
|
|
|
* 获取开门计划 |
|
|
|
* |
|
|
|
* @param |
|
|
|
* @return java.lang.String |
|
|
|
* @author zhy |
|
|
|
* @date 2022/5/23 11:04 |
|
|
|
*/ |
|
|
|
public String getPlan() { |
|
|
|
public Long getPlan() { |
|
|
|
String url = dhCloudProperties.getUrl().concat(GET_DOOR_PLAN); |
|
|
|
String urlParam = getDhUrlParams(); |
|
|
|
url = url + urlParam; |
|
|
|
|
|
|
|
Map<String, String> paramsMap = new HashMap<>(4); |
|
|
|
DhPlanPageFormDTO dto = new DhPlanPageFormDTO(); |
|
|
|
dto.setPageNum(1); |
|
|
|
dto.setPageSize(100); |
|
|
|
dto.setSingleCondition("默认"); |
|
|
|
|
|
|
|
String data = HttpClientManager.getInstance().sendPostByJSONAndHeader(url, StringUtils.EMPTY, paramsMap).getData(); |
|
|
|
String data = HttpClientManager.getInstance().sendPostByJSONAndHeader(url, JSON.toJSONString(dto), paramsMap).getData(); |
|
|
|
|
|
|
|
if (null == data) { |
|
|
|
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "查询开门计划失败"); |
|
|
@ -234,15 +401,19 @@ public class DhDeviceUtil { |
|
|
|
} |
|
|
|
if (!result.getSuccess()) { |
|
|
|
logger.info(result.getErrMsg()); |
|
|
|
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "查询开门计划失败"); |
|
|
|
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "查询开门计划失败!" + result.getErrMsg()); |
|
|
|
} |
|
|
|
Object registerResult = result.getData(); |
|
|
|
JSONArray jsonArray = JSON.parseArray(registerResult.toString()); |
|
|
|
JSONObject jsonObject = jsonArray.getJSONObject(0); |
|
|
|
if (null != jsonObject) { |
|
|
|
return jsonObject.get("id").toString(); |
|
|
|
|
|
|
|
JSONObject jsonObject = JSON.parseObject(registerResult.toString()); |
|
|
|
|
|
|
|
JSONArray jsonArray = JSON.parseArray(jsonObject.get("pageData").toString()); |
|
|
|
|
|
|
|
if (jsonArray.size() > 0) { |
|
|
|
return Long.parseLong(jsonArray.getJSONObject(0).get("id").toString()); |
|
|
|
} |
|
|
|
return ""; |
|
|
|
|
|
|
|
return null; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
@ -259,8 +430,11 @@ public class DhDeviceUtil { |
|
|
|
url = url + urlParam; |
|
|
|
|
|
|
|
Map<String, String> paramsMap = new HashMap<>(4); |
|
|
|
DhChannelPageFormDTO dto = new DhChannelPageFormDTO(); |
|
|
|
dto.setPageSize(100); |
|
|
|
dto.setPageSize(1); |
|
|
|
|
|
|
|
String data = HttpClientManager.getInstance().sendPostByJSONAndHeader(url, StringUtils.EMPTY, paramsMap).getData(); |
|
|
|
String data = HttpClientManager.getInstance().sendPostByJSONAndHeader(url, JSON.toJSONString(dto), paramsMap).getData(); |
|
|
|
|
|
|
|
if (null == data) { |
|
|
|
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "查询通道列表失败"); |
|
|
@ -272,17 +446,20 @@ public class DhDeviceUtil { |
|
|
|
} |
|
|
|
if (!result.getSuccess()) { |
|
|
|
logger.info(result.getErrMsg()); |
|
|
|
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "查询通道列表失败"); |
|
|
|
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "查询通道列表失败!" + result.getErrMsg()); |
|
|
|
} |
|
|
|
Object registerResult = result.getData(); |
|
|
|
JSONArray jsonArray = JSON.parseArray(registerResult.toString()); |
|
|
|
List<DhChannelResultDTO> list = new ArrayList<>(); |
|
|
|
|
|
|
|
JSONObject jsonObject = JSON.parseObject(registerResult.toString()); |
|
|
|
|
|
|
|
JSONArray jsonArray = JSON.parseArray(jsonObject.get("pageData").toString()); |
|
|
|
|
|
|
|
List<DhChannelResultDTO> list = new ArrayList<>(); |
|
|
|
for (int i = 0; i < jsonArray.size(); i++) { |
|
|
|
JSONObject jsonObject = jsonArray.getJSONObject(0); |
|
|
|
JSONObject jsonItem = jsonArray.getJSONObject(0); |
|
|
|
DhChannelResultDTO channel = new DhChannelResultDTO(); |
|
|
|
channel.setPrivilegeType("1"); |
|
|
|
channel.setResouceCode(jsonObject.get("channelCode").toString()); |
|
|
|
channel.setResouceCode(jsonItem.get("channelCode").toString()); |
|
|
|
list.add(channel); |
|
|
|
} |
|
|
|
|
|
|
@ -298,17 +475,20 @@ public class DhDeviceUtil { |
|
|
|
* @date 2022/5/23 11:04 |
|
|
|
*/ |
|
|
|
public Long addPerson(DhPersonFormDTO dto) { |
|
|
|
// 数据预处理
|
|
|
|
dataHandle(dto.getCode()); |
|
|
|
|
|
|
|
String url = dhCloudProperties.getUrl().concat(ADD_PERSON); |
|
|
|
String urlParam = getDhUrlParams(); |
|
|
|
url = url + urlParam; |
|
|
|
|
|
|
|
Long deptId = getDept(); |
|
|
|
if (0L == deptId) { |
|
|
|
return null; |
|
|
|
if (null == deptId) { |
|
|
|
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "查询临时人员部门失败"); |
|
|
|
} |
|
|
|
String identity = getIdentity(); |
|
|
|
if (StringUtils.isBlank(identity)) { |
|
|
|
return null; |
|
|
|
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "获取身份失败"); |
|
|
|
} |
|
|
|
dto.setDeptId(deptId); |
|
|
|
dto.setPersonIdentityId(identity); |
|
|
@ -327,12 +507,11 @@ public class DhDeviceUtil { |
|
|
|
} |
|
|
|
if (!result.getSuccess()) { |
|
|
|
logger.info(result.getErrMsg()); |
|
|
|
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "新增人员失败"); |
|
|
|
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "新增人员失败!" + result.getErrMsg()); |
|
|
|
} |
|
|
|
Object registerResult = result.getData(); |
|
|
|
JSONObject jsonObject = JSON.parseObject(registerResult.toString()); |
|
|
|
if (null != jsonObject) { |
|
|
|
return Long.parseLong(jsonObject.toString()); |
|
|
|
if (null != registerResult) { |
|
|
|
return Long.parseLong(registerResult.toString()); |
|
|
|
} |
|
|
|
return null; |
|
|
|
} |
|
|
@ -368,14 +547,10 @@ public class DhDeviceUtil { |
|
|
|
} |
|
|
|
if (!result.getSuccess()) { |
|
|
|
logger.info(result.getErrMsg()); |
|
|
|
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "下发人员头像失败"); |
|
|
|
} |
|
|
|
Object registerResult = result.getData(); |
|
|
|
JSONObject jsonObject = JSON.parseObject(registerResult.toString()); |
|
|
|
if (null != jsonObject) { |
|
|
|
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "下发人员头像失败!" + result.getErrMsg()); |
|
|
|
} else { |
|
|
|
return "success"; |
|
|
|
} |
|
|
|
return ""; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
@ -389,8 +564,10 @@ public class DhDeviceUtil { |
|
|
|
public String addPersonCard(DhPersonFormDTO dto) { |
|
|
|
Long personId = addPerson(dto); |
|
|
|
if (personId == null) { |
|
|
|
return "添加人员信息失败"; |
|
|
|
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "添加人员信息失败"); |
|
|
|
} |
|
|
|
DhPersonCardListFormDTO cardListFormDTO = new DhPersonCardListFormDTO(); |
|
|
|
List<DhPersonCardFormDTO> cardList = new ArrayList<>(); |
|
|
|
DhPersonCardFormDTO cardFormDTO = new DhPersonCardFormDTO(); |
|
|
|
String url = dhCloudProperties.getUrl().concat(OPEN_CARD); |
|
|
|
String urlParam = getDhUrlParams(); |
|
|
@ -412,10 +589,12 @@ public class DhDeviceUtil { |
|
|
|
} |
|
|
|
cardFormDTO.setCardPassword(pwd); |
|
|
|
cardFormDTO.setSubSystems("1"); |
|
|
|
cardList.add(cardFormDTO); |
|
|
|
cardListFormDTO.setObjectList(cardList); |
|
|
|
|
|
|
|
Map<String, String> paramsMap = new HashMap<>(4); |
|
|
|
|
|
|
|
String data = HttpClientManager.getInstance().sendPostByJSONAndHeader(url, JSON.toJSONString(cardFormDTO), paramsMap).getData(); |
|
|
|
String data = HttpClientManager.getInstance().sendPostByJSONAndHeader(url, JSON.toJSONString(cardListFormDTO), paramsMap).getData(); |
|
|
|
|
|
|
|
if (null == data) { |
|
|
|
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "人员开卡失败"); |
|
|
@ -427,14 +606,10 @@ public class DhDeviceUtil { |
|
|
|
} |
|
|
|
if (!result.getSuccess()) { |
|
|
|
logger.info(result.getErrMsg()); |
|
|
|
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "人员开卡失败"); |
|
|
|
} |
|
|
|
Object registerResult = result.getData(); |
|
|
|
JSONObject jsonObject = JSON.parseObject(registerResult.toString()); |
|
|
|
if (null != jsonObject) { |
|
|
|
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "人员开卡失败!" + result.getErrMsg()); |
|
|
|
} else { |
|
|
|
return cardFormDTO.getCardNumber(); |
|
|
|
} |
|
|
|
return ""; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
@ -447,27 +622,29 @@ public class DhDeviceUtil { |
|
|
|
*/ |
|
|
|
public String addPersonAuth(DhPersonFormDTO dto, String imgUrl) { |
|
|
|
String personCard = addPersonCard(dto); |
|
|
|
List<DhChannelResultDTO> channel = getChannel(); |
|
|
|
String plan = getPlan(); |
|
|
|
|
|
|
|
if (StringUtils.isBlank(personCard)) { |
|
|
|
return "开卡失败"; |
|
|
|
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "开卡失败"); |
|
|
|
} else if (StringUtils.isNotBlank(imgUrl)) { |
|
|
|
addPersonImg(dto, imgUrl); |
|
|
|
} |
|
|
|
|
|
|
|
List<DhChannelResultDTO> channel = getChannel(); |
|
|
|
if (channel.isEmpty()) { |
|
|
|
return "获取通道失败"; |
|
|
|
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "获取通道失败"); |
|
|
|
} |
|
|
|
if (StringUtils.isBlank(plan)) { |
|
|
|
return "获取开门计划失败"; |
|
|
|
|
|
|
|
Long plan = getPlan(); |
|
|
|
if (plan == null) { |
|
|
|
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "获取开门计划失败"); |
|
|
|
} |
|
|
|
|
|
|
|
DhAuthFormDTO authFormDTO = new DhAuthFormDTO(); |
|
|
|
String url = dhCloudProperties.getUrl().concat(ADD_AUTH); |
|
|
|
String urlParam = getDhUrlParams(); |
|
|
|
url = url + urlParam; |
|
|
|
|
|
|
|
authFormDTO.setCardNumber(personCard); |
|
|
|
authFormDTO.setTimeQuantumId(plan); |
|
|
|
authFormDTO.setTimeQuantumId(plan.toString()); |
|
|
|
authFormDTO.setCardPrivilegeDetails(channel); |
|
|
|
|
|
|
|
Map<String, String> paramsMap = new HashMap<>(4); |
|
|
@ -484,14 +661,10 @@ public class DhDeviceUtil { |
|
|
|
} |
|
|
|
if (!result.getSuccess()) { |
|
|
|
logger.info(result.getErrMsg()); |
|
|
|
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "下发人员权限失败"); |
|
|
|
} |
|
|
|
Object registerResult = result.getData(); |
|
|
|
JSONObject jsonObject = JSON.parseObject(registerResult.toString()); |
|
|
|
if (null != jsonObject) { |
|
|
|
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "下发人员权限失败!" + result.getErrMsg()); |
|
|
|
} else { |
|
|
|
return "success"; |
|
|
|
} |
|
|
|
return ""; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
@ -503,7 +676,7 @@ public class DhDeviceUtil { |
|
|
|
* @date 2022/7/28 16:09 |
|
|
|
*/ |
|
|
|
private String getDhUrlParams() { |
|
|
|
DhToken token = getLoginPass(getPublicKey()); |
|
|
|
DhTokenDTO token = getLoginPass(getPublicKey()); |
|
|
|
return "?userId=" + token.getId() + "&username=" + token.getLoginName() + "&token=" + token.getToken(); |
|
|
|
} |
|
|
|
|
|
|
@ -585,5 +758,19 @@ public class DhDeviceUtil { |
|
|
|
return sb.toString().toUpperCase(); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 退卡,然后删除人员 |
|
|
|
* |
|
|
|
* @param code |
|
|
|
* @return void |
|
|
|
* @author zhy |
|
|
|
* @date 2022/8/3 10:48 |
|
|
|
*/ |
|
|
|
public void dataHandle(String code) { |
|
|
|
// 先退卡
|
|
|
|
cardHandle(code); |
|
|
|
// 再删人员
|
|
|
|
personHandle(code); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|