|
@@ -0,0 +1,85 @@
|
|
|
+package com.usky.dxtop.service.api;
|
|
|
+
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.usky.dxtop.common.exception.CustomException;
|
|
|
+import com.usky.dxtop.common.utils.http.HttpUtils;
|
|
|
+import com.usky.dxtop.service.vo.FpDoorVO;
|
|
|
+
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.function.Function;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 费浦api
|
|
|
+ * @author yq
|
|
|
+ * @date 2022/7/5 10:07
|
|
|
+ */
|
|
|
+public class FpApi {
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 路径
|
|
|
+ */
|
|
|
+ private static final String PATH = "http://10.208.2.158:7002/";
|
|
|
+ /**
|
|
|
+ * 获取门禁列表
|
|
|
+ */
|
|
|
+ public static final String DOOR_LIST_URL = String.format("%s%s",PATH,"getDoorList");
|
|
|
+ /**
|
|
|
+ * 设置权限
|
|
|
+ */
|
|
|
+ public static final String DEVICE_PERMISSION_OPERATE_URL = String.format("%s%s",PATH,"devicePermissionOperate");
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取门禁列表
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public List<FpDoorVO> getDoorList(){
|
|
|
+
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 设置门禁权限
|
|
|
+ * @param params
|
|
|
+ */
|
|
|
+ public void setDoorPermission(Map<String,Object> params){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 生成门禁参数
|
|
|
+ * @param userId
|
|
|
+ * @param list
|
|
|
+ * @param operateType
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public Map<String,Object> generateDoorPermissionParam(String userId,List<FpDoorVO> list,String operateType){
|
|
|
+ List<Map<String, Object>> deviceInfoList = list.stream().map(fpDoorVO -> {
|
|
|
+ Map<String, Object> deviceInfo = new HashMap<>();
|
|
|
+ deviceInfo.put("serialNumber", fpDoorVO.getDeviceId());
|
|
|
+ deviceInfo.put("doorID", fpDoorVO.getDoorId());
|
|
|
+ deviceInfo.put("deviceType", fpDoorVO.getDeviceType());
|
|
|
+ return deviceInfo;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ Map<String,Object> param = new HashMap<>();
|
|
|
+ param.put("userId",userId);
|
|
|
+ param.put("operateType",operateType);
|
|
|
+ param.put("deviceInfo",deviceInfoList);
|
|
|
+ return param;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public boolean commonResult(String url, String param, Function<JSONObject,Boolean> function){
|
|
|
+ String result = HttpUtils.sendPost(url, JSONObject.toJSONString(param), null);
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(result);
|
|
|
+ if ("1".equals(jsonObject.get("result").toString())) {
|
|
|
+ return function.apply(jsonObject);
|
|
|
+ } else {
|
|
|
+ throw new CustomException("接口异常"+jsonObject.get("msg"));
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|