|
@@ -1,14 +1,11 @@
|
|
|
package org.dromara.backstage.business.lock;
|
|
package org.dromara.backstage.business.lock;
|
|
|
-import java.util.Date;
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.collection.CollectionUtil;
|
|
import cn.hutool.core.collection.CollectionUtil;
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
-import cn.hutool.core.lang.TypeReference;
|
|
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
import cn.hutool.core.util.RandomUtil;
|
|
import cn.hutool.core.util.RandomUtil;
|
|
|
import cn.hutool.json.JSONArray;
|
|
import cn.hutool.json.JSONArray;
|
|
|
import cn.hutool.json.JSONObject;
|
|
import cn.hutool.json.JSONObject;
|
|
|
-import cn.hutool.json.JSONString;
|
|
|
|
|
import cn.hutool.json.JSONUtil;
|
|
import cn.hutool.json.JSONUtil;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
@@ -17,7 +14,6 @@ import org.dromara.backstage.basics.domain.vo.PtRoomVo;
|
|
|
import org.dromara.backstage.basics.service.IPtRoomService;
|
|
import org.dromara.backstage.basics.service.IPtRoomService;
|
|
|
import org.dromara.backstage.domain.bo.lock.RoomCardBo;
|
|
import org.dromara.backstage.domain.bo.lock.RoomCardBo;
|
|
|
import org.dromara.backstage.util.LockUtils;
|
|
import org.dromara.backstage.util.LockUtils;
|
|
|
-import org.dromara.backstage.util.SignatureUtil;
|
|
|
|
|
import org.dromara.common.core.constant.DefaultConstants;
|
|
import org.dromara.common.core.constant.DefaultConstants;
|
|
|
import org.dromara.common.core.constant.LockConstants;
|
|
import org.dromara.common.core.constant.LockConstants;
|
|
|
import org.dromara.common.core.domain.R;
|
|
import org.dromara.common.core.domain.R;
|
|
@@ -30,6 +26,7 @@ import org.springframework.stereotype.Service;
|
|
|
import java.util.HashMap;
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
|
|
|
+import java.util.concurrent.atomic.AtomicReference;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* @ClassName LockBusiness
|
|
* @ClassName LockBusiness
|
|
@@ -59,7 +56,7 @@ public class LockBusiness {
|
|
|
* @return 发卡数据
|
|
* @return 发卡数据
|
|
|
*/
|
|
*/
|
|
|
public R<String> getWriteCardData(RoomCardBo bo) {
|
|
public R<String> getWriteCardData(RoomCardBo bo) {
|
|
|
- log.debug("发卡入参:{}, {}", JSONUtil.toJsonStr(bo),bo.getCardType());
|
|
|
|
|
|
|
+ log.debug("发卡入参:{}, {}", JSONUtil.toJsonStr(bo), bo.getCardType());
|
|
|
Integer cardType = bo.getCardType();
|
|
Integer cardType = bo.getCardType();
|
|
|
String cardData = "";
|
|
String cardData = "";
|
|
|
Map<String, Object> formMap;
|
|
Map<String, Object> formMap;
|
|
@@ -90,6 +87,7 @@ public class LockBusiness {
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 远程开门
|
|
* 远程开门
|
|
|
|
|
+ *
|
|
|
* @param lockId 门锁Id
|
|
* @param lockId 门锁Id
|
|
|
* @return 开门结果
|
|
* @return 开门结果
|
|
|
*/
|
|
*/
|
|
@@ -127,6 +125,7 @@ public class LockBusiness {
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 查询门锁电量并保持至数据库
|
|
* 查询门锁电量并保持至数据库
|
|
|
|
|
+ *
|
|
|
* @param areaId 指定区域
|
|
* @param areaId 指定区域
|
|
|
* @return 查询结果
|
|
* @return 查询结果
|
|
|
*/
|
|
*/
|
|
@@ -138,6 +137,7 @@ public class LockBusiness {
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 查询门锁电量并保持至数据库
|
|
* 查询门锁电量并保持至数据库
|
|
|
|
|
+ *
|
|
|
* @return 查询结果
|
|
* @return 查询结果
|
|
|
*/
|
|
*/
|
|
|
public Boolean syncLockPower() {
|
|
public Boolean syncLockPower() {
|
|
@@ -146,54 +146,96 @@ public class LockBusiness {
|
|
|
return true;
|
|
return true;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public void queryOpenDoorRecord(String lockId) {
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 同步所有房间的开门记录
|
|
|
|
|
+ *
|
|
|
|
|
+ * @return 同步记录数
|
|
|
|
|
+ */
|
|
|
|
|
+ public Integer queryOpenDoorRecord() {
|
|
|
|
|
+ AtomicReference<Integer> openDoorRecord = new AtomicReference<>(0);
|
|
|
|
|
+ List<PtRoomVo> roomVos = roomService.queryHotelRoomList();
|
|
|
|
|
+ if (CollectionUtil.isNotEmpty(roomVos)) {
|
|
|
|
|
+ roomVos.parallelStream().forEach(p -> {
|
|
|
|
|
+ String lockId = p.getLockId();
|
|
|
|
|
+ openDoorRecord.updateAndGet(v -> v + this.queryOpenDoorRecord(lockId));
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ return openDoorRecord.get();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 同步处理开门记录(指定门锁)
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param lockId 门锁Id
|
|
|
|
|
+ */
|
|
|
|
|
+ public Integer queryOpenDoorRecord(String lockId) {
|
|
|
Map<String, Object> formMap = new HashMap<>();
|
|
Map<String, Object> formMap = new HashMap<>();
|
|
|
formMap.put("KEYLOCKID", lockId);
|
|
formMap.put("KEYLOCKID", lockId);
|
|
|
formMap.put("CARDPSWBIT", "1");
|
|
formMap.put("CARDPSWBIT", "1");
|
|
|
formMap.put("OPERATETYPE", "2");
|
|
formMap.put("OPERATETYPE", "2");
|
|
|
- formMap.put("PAGENO","1");
|
|
|
|
|
|
|
+ formMap.put("PAGENO", "1");
|
|
|
|
|
|
|
|
String result = lockUtils.sendPost(formMap, "operateLockRecord");
|
|
String result = lockUtils.sendPost(formMap, "operateLockRecord");
|
|
|
String flag = JSONUtil.parseObj(result).getStr("result");
|
|
String flag = JSONUtil.parseObj(result).getStr("result");
|
|
|
|
|
+ Integer syncCount = 0;
|
|
|
if (ObjectUtil.equals(flag, "0")) {
|
|
if (ObjectUtil.equals(flag, "0")) {
|
|
|
int totalPage = JSONUtil.parseObj(result).getInt("totalPage");
|
|
int totalPage = JSONUtil.parseObj(result).getInt("totalPage");
|
|
|
for (int i = 0; i < totalPage; i++) {
|
|
for (int i = 0; i < totalPage; i++) {
|
|
|
- queryOpenDoorRecord(lockId, i + 1);
|
|
|
|
|
|
|
+ syncCount += queryOpenDoorRecord(lockId, i + 1);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- }
|
|
|
|
|
|
|
+ return syncCount;
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- public void queryOpenDoorRecord(String lockId,int pageNo) {
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 同步处理开门记录(指定门锁与页码)
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param lockId 门锁Id
|
|
|
|
|
+ * @param pageNo 页码
|
|
|
|
|
+ * @return 记录条数
|
|
|
|
|
+ */
|
|
|
|
|
+ public Integer queryOpenDoorRecord(String lockId, int pageNo) {
|
|
|
Map<String, Object> formMap = new HashMap<>();
|
|
Map<String, Object> formMap = new HashMap<>();
|
|
|
formMap.put("KEYLOCKID", lockId);
|
|
formMap.put("KEYLOCKID", lockId);
|
|
|
formMap.put("CARDPSWBIT", "1");
|
|
formMap.put("CARDPSWBIT", "1");
|
|
|
formMap.put("OPERATETYPE", "2");
|
|
formMap.put("OPERATETYPE", "2");
|
|
|
- formMap.put("PAGENO",pageNo);
|
|
|
|
|
|
|
+ formMap.put("PAGENO", pageNo);
|
|
|
|
|
|
|
|
|
|
+ AtomicReference<Integer> syncCount = new AtomicReference<>(0);
|
|
|
String result = lockUtils.sendPost(formMap, "operateLockRecord");
|
|
String result = lockUtils.sendPost(formMap, "operateLockRecord");
|
|
|
String flag = JSONUtil.parseObj(result).getStr("result");
|
|
String flag = JSONUtil.parseObj(result).getStr("result");
|
|
|
if (ObjectUtil.equals(flag, "0")) {
|
|
if (ObjectUtil.equals(flag, "0")) {
|
|
|
JSONArray pageData = JSONUtil.parseObj(result).getJSONArray("pageData");
|
|
JSONArray pageData = JSONUtil.parseObj(result).getJSONArray("pageData");
|
|
|
- pageData.parallelStream().forEach(p->{
|
|
|
|
|
|
|
+ pageData.parallelStream().forEach(p -> {
|
|
|
JSONObject record = JSONUtil.parseObj(p);
|
|
JSONObject record = JSONUtil.parseObj(p);
|
|
|
RemoteDoorOpenBo remoteBo = new RemoteDoorOpenBo();
|
|
RemoteDoorOpenBo remoteBo = new RemoteDoorOpenBo();
|
|
|
remoteBo.setRoomCode("A604");
|
|
remoteBo.setRoomCode("A604");
|
|
|
remoteBo.setRoomName("A604");
|
|
remoteBo.setRoomName("A604");
|
|
|
remoteBo.setOpenDoorMode(record.getStr("openWay"));
|
|
remoteBo.setOpenDoorMode(record.getStr("openWay"));
|
|
|
- remoteBo.setOpenTime(DateUtil.parse(record.getStr("operateTime"),DefaultConstants.DATE_TIME_FORMAT));
|
|
|
|
|
|
|
+ remoteBo.setOpenTime(DateUtil.parse(record.getStr("operateTime"), DefaultConstants.DATE_TIME_FORMAT));
|
|
|
remoteBo.setOpenResult(record.getStr("openResult"));
|
|
remoteBo.setOpenResult(record.getStr("openResult"));
|
|
|
- if(ObjectUtil.isNotEmpty(record.get("cardId"))) {
|
|
|
|
|
|
|
+ if (ObjectUtil.isNotEmpty(record.get("cardId"))) {
|
|
|
remoteBo.setFactoryId(record.getStr("cardId"));
|
|
remoteBo.setFactoryId(record.getStr("cardId"));
|
|
|
} else {
|
|
} else {
|
|
|
remoteBo.setFactoryId("");
|
|
remoteBo.setFactoryId("");
|
|
|
}
|
|
}
|
|
|
remoteBo.setOpenDoorUser(0L);
|
|
remoteBo.setOpenDoorUser(0L);
|
|
|
- remoteOpenDoorService.insertOpenDoorByBo(remoteBo);
|
|
|
|
|
|
|
+ try {
|
|
|
|
|
+ int iCount = remoteOpenDoorService.insertOpenDoorByBo(remoteBo);
|
|
|
|
|
+ if (iCount > 0) {
|
|
|
|
|
+ syncCount.getAndSet(syncCount.get() + 1);
|
|
|
|
|
+ }
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ log.error("[同步开门记录异常]-[{}]", record, e);
|
|
|
|
|
+ }
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
|
|
+ return syncCount.get();
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 门锁电量入库
|
|
* 门锁电量入库
|
|
|
|
|
+ *
|
|
|
* @param roomVos 门锁列表
|
|
* @param roomVos 门锁列表
|
|
|
*/
|
|
*/
|
|
|
private void insertLockPower(List<PtRoomVo> roomVos) {
|
|
private void insertLockPower(List<PtRoomVo> roomVos) {
|