|
|
@@ -4,13 +4,7 @@ import cn.hutool.json.JSONUtil;
|
|
|
import com.github.microservice.models.gateDoor.use.GateDoorUseParam;
|
|
|
import com.github.microservice.models.gateDoor.use.GateDoorUseResult;
|
|
|
import com.github.microservice.net.ResultContent;
|
|
|
-import com.zhongshu.card.client.model.devices.DeviceInfoStoreModel;
|
|
|
import com.zhongshu.card.client.model.devices.DeviceUseRecordModel;
|
|
|
-import com.zhongshu.card.client.model.org.UserCountSimpleModel;
|
|
|
-import com.zhongshu.card.client.model.school.CardInfoStoreModel;
|
|
|
-import com.zhongshu.card.client.type.DataState;
|
|
|
-import com.zhongshu.card.client.type.UserState;
|
|
|
-import com.zhongshu.card.client.type.school.CardState;
|
|
|
import com.zhongshu.card.client.utils.DateUtils;
|
|
|
import com.zhongshu.card.server.core.dao.devices.DeviceInfoDao;
|
|
|
import com.zhongshu.card.server.core.dao.devices.DevicePermissDao;
|
|
|
@@ -18,8 +12,7 @@ import com.zhongshu.card.server.core.dao.devices.DeviceUseRecordDao;
|
|
|
import com.zhongshu.card.server.core.dao.org.UserCountDao;
|
|
|
import com.zhongshu.card.server.core.dao.school.CardInfoDao;
|
|
|
import com.zhongshu.card.server.core.domain.devices.DeviceInfo;
|
|
|
-import com.zhongshu.card.server.core.domain.devices.DevicePermiss;
|
|
|
-import com.zhongshu.card.server.core.domain.devices.DeviceUseRecord;
|
|
|
+import com.zhongshu.card.server.core.domain.devices.DeviceUseRecords;
|
|
|
import com.zhongshu.card.server.core.domain.org.UserAccount;
|
|
|
import com.zhongshu.card.server.core.domain.school.CardInfo;
|
|
|
import com.zhongshu.card.server.core.service.base.SuperService;
|
|
|
@@ -77,12 +70,13 @@ public class DeviceUseRecordService extends SuperService {
|
|
|
String mqttDataId = param.getMqttDataId();
|
|
|
log.info("mqttDataId: {}", mqttDataId);
|
|
|
if (StringUtils.isNotEmpty(mqttDataId)) {
|
|
|
- DeviceUseRecord deviceUseRecord = init(mqttDataId);
|
|
|
+ DeviceUseRecords deviceUseRecord = init(mqttDataId);
|
|
|
if (ObjectUtils.isNotEmpty(deviceUseRecord)) {
|
|
|
BeanUtils.copyProperties(param, deviceUseRecord);
|
|
|
String deviceId = param.getDeviceId();
|
|
|
String cardNo = param.getCardNo();
|
|
|
String userId = param.getUserId();
|
|
|
+
|
|
|
String projectOid = "";
|
|
|
DeviceInfo deviceInfo = null;
|
|
|
if (StringUtils.isNotEmpty(deviceId)) {
|
|
|
@@ -169,8 +163,8 @@ public class DeviceUseRecordService extends SuperService {
|
|
|
return ResultContent.buildSuccess(JSONUtil.toJsonStr(result));
|
|
|
}
|
|
|
|
|
|
- public DeviceUseRecord init(String mqttDataId) {
|
|
|
- DeviceUseRecord entity = deviceUseRecordDao.init(mqttDataId, TokenUtil.create());
|
|
|
+ public DeviceUseRecords init(String mqttDataId) {
|
|
|
+ DeviceUseRecords entity = deviceUseRecordDao.init(mqttDataId, TokenUtil.create());
|
|
|
if (ObjectUtils.isNotEmpty(entity)) {
|
|
|
entity.setCreateTimeStr(DateUtils.paresTime(System.currentTimeMillis(), DateUtils.FORMAT_LONG));
|
|
|
return entity;
|
|
|
@@ -183,76 +177,75 @@ public class DeviceUseRecordService extends SuperService {
|
|
|
*
|
|
|
* @param entity
|
|
|
*/
|
|
|
- public void checkUseDeviceData(DeviceUseRecord entity) {
|
|
|
- // 主要是从设备、卡片等的基础信息验证
|
|
|
- if (ObjectUtils.isNotEmpty(entity)) {
|
|
|
- // 1. 检查设备
|
|
|
- if (ObjectUtils.isEmpty(entity.getDeviceInfo())) {
|
|
|
- entity.setIsPassed(Boolean.FALSE);
|
|
|
- entity.setMsg("设备信息未找到");
|
|
|
- return;
|
|
|
- }
|
|
|
- DeviceInfoStoreModel deviceInfo = entity.getDeviceInfo();
|
|
|
- if (deviceInfo.getState() == null || deviceInfo.getState() != DataState.Enable) {
|
|
|
- entity.setIsPassed(Boolean.FALSE);
|
|
|
- entity.setMsg("设备未启用");
|
|
|
- return;
|
|
|
- }
|
|
|
- //2. 验证用户信息
|
|
|
- UserCountSimpleModel userAccount = entity.getUserAccount();
|
|
|
- if (ObjectUtils.isEmpty(userAccount)) {
|
|
|
- entity.setIsPassed(Boolean.FALSE);
|
|
|
- entity.setMsg("用户信息未确定");
|
|
|
- return;
|
|
|
- }
|
|
|
- if (userAccount.getState() == null || userAccount.getState() != UserState.Normal) {
|
|
|
- entity.setIsPassed(Boolean.FALSE);
|
|
|
- entity.setMsg(String.format("用户已禁用"));
|
|
|
- return;
|
|
|
- }
|
|
|
- // 验证用户是否有设备申请权限
|
|
|
- if (deviceInfo.getIsOpenUse() == null || !deviceInfo.getIsOpenUse()) {
|
|
|
- DevicePermiss devicePermiss = devicePermissDao.findTopByUserIdAndDeviceIdAndProjectOid(entity.getUserId(), entity.getDeviceId(), entity.getProjectOid());
|
|
|
- if (ObjectUtils.isEmpty(devicePermiss)) {
|
|
|
- entity.setIsPassed(Boolean.FALSE);
|
|
|
- entity.setMsg("用户没有设备权限");
|
|
|
- return;
|
|
|
- }
|
|
|
- if (devicePermiss.getDataState() == null || devicePermiss.getDataState() != DataState.Enable) {
|
|
|
- entity.setIsPassed(Boolean.FALSE);
|
|
|
- entity.setMsg("用户权限未启用");
|
|
|
- return;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- Integer mode = entity.getMode();
|
|
|
- if (mode == null) {
|
|
|
- entity.setIsPassed(Boolean.FALSE);
|
|
|
- entity.setMsg("使用模式未确定");
|
|
|
- return;
|
|
|
- }
|
|
|
- if (mode == 0) {
|
|
|
- // 刷卡
|
|
|
- if (ObjectUtils.isEmpty(entity.getCardInfo())) {
|
|
|
- entity.setIsPassed(Boolean.FALSE);
|
|
|
- entity.setMsg("卡片未找到");
|
|
|
- return;
|
|
|
- }
|
|
|
- CardInfoStoreModel cardInfo = entity.getCardInfo();
|
|
|
- if (cardInfo.getIsCanceled() != null && cardInfo.getIsCanceled()) {
|
|
|
- entity.setIsPassed(Boolean.FALSE);
|
|
|
- entity.setMsg("卡片已作废");
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- if (cardInfo.getCardState() == null || cardInfo.getCardState() != CardState.Enable) {
|
|
|
- entity.setIsPassed(Boolean.FALSE);
|
|
|
- entity.setMsg(String.format("卡片%s", cardInfo.getCardState().getRemark()));
|
|
|
- return;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
+ public void checkUseDeviceData(DeviceUseRecords entity) {
|
|
|
+// // 主要是从设备、卡片等的基础信息验证
|
|
|
+// if (ObjectUtils.isNotEmpty(entity)) {
|
|
|
+// // 1. 检查设备
|
|
|
+// if (ObjectUtils.isEmpty(entity.getDeviceInfo())) {
|
|
|
+// entity.setIsPassed(Boolean.FALSE);
|
|
|
+// entity.setMsg("设备信息未找到");
|
|
|
+// return;
|
|
|
+// }
|
|
|
+// DeviceInfoStoreModel deviceInfo = entity.getDeviceInfo();
|
|
|
+// if (deviceInfo.getState() == null || deviceInfo.getState() != DataState.Enable) {
|
|
|
+// entity.setIsPassed(Boolean.FALSE);
|
|
|
+// entity.setMsg("设备未启用");
|
|
|
+// return;
|
|
|
+// }
|
|
|
+// //2. 验证用户信息
|
|
|
+// UserCountSimpleModel userAccount = entity.getUserAccount();
|
|
|
+// if (ObjectUtils.isEmpty(userAccount)) {
|
|
|
+// entity.setIsPassed(Boolean.FALSE);
|
|
|
+// entity.setMsg("用户信息未确定");
|
|
|
+// return;
|
|
|
+// }
|
|
|
+// if (userAccount.getState() == null || userAccount.getState() != UserState.Normal) {
|
|
|
+// entity.setIsPassed(Boolean.FALSE);
|
|
|
+// entity.setMsg(String.format("用户已禁用"));
|
|
|
+// return;
|
|
|
+// }
|
|
|
+// // 验证用户是否有设备申请权限
|
|
|
+// if (deviceInfo.getIsOpenUse() == null || !deviceInfo.getIsOpenUse()) {
|
|
|
+// DevicePermiss devicePermiss = devicePermissDao.findTopByUserIdAndDeviceIdAndProjectOid(entity.getUserId(), entity.getDeviceId(), entity.getProjectOid());
|
|
|
+// if (ObjectUtils.isEmpty(devicePermiss)) {
|
|
|
+// entity.setIsPassed(Boolean.FALSE);
|
|
|
+// entity.setMsg("用户没有设备权限");
|
|
|
+// return;
|
|
|
+// }
|
|
|
+// if (devicePermiss.getDataState() == null || devicePermiss.getDataState() != DataState.Enable) {
|
|
|
+// entity.setIsPassed(Boolean.FALSE);
|
|
|
+// entity.setMsg("用户权限未启用");
|
|
|
+// return;
|
|
|
+// }
|
|
|
+// }
|
|
|
+//
|
|
|
+// Integer mode = entity.getMode();
|
|
|
+// if (mode == null) {
|
|
|
+// entity.setIsPassed(Boolean.FALSE);
|
|
|
+// entity.setMsg("使用模式未确定");
|
|
|
+// return;
|
|
|
+// }
|
|
|
+// if (mode == 0) {
|
|
|
+// // 刷卡
|
|
|
+// if (ObjectUtils.isEmpty(entity.getCardInfo())) {
|
|
|
+// entity.setIsPassed(Boolean.FALSE);
|
|
|
+// entity.setMsg("卡片未找到");
|
|
|
+// return;
|
|
|
+// }
|
|
|
+// CardInfoStoreModel cardInfo = entity.getCardInfo();
|
|
|
+// if (cardInfo.getIsCanceled() != null && cardInfo.getIsCanceled()) {
|
|
|
+// entity.setIsPassed(Boolean.FALSE);
|
|
|
+// entity.setMsg("卡片已作废");
|
|
|
+// return;
|
|
|
+// }
|
|
|
+//
|
|
|
+// if (cardInfo.getCardState() == null || cardInfo.getCardState() != CardState.Enable) {
|
|
|
+// entity.setIsPassed(Boolean.FALSE);
|
|
|
+// entity.setMsg(String.format("卡片%s", cardInfo.getCardState().getRemark()));
|
|
|
+// return;
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -261,7 +254,7 @@ public class DeviceUseRecordService extends SuperService {
|
|
|
* @param entity
|
|
|
* @return
|
|
|
*/
|
|
|
- public DeviceUseRecordModel toModel(DeviceUseRecord entity) {
|
|
|
+ public DeviceUseRecordModel toModel(DeviceUseRecords entity) {
|
|
|
DeviceUseRecordModel model = null;
|
|
|
if (ObjectUtils.isNotEmpty(entity)) {
|
|
|
model = new DeviceUseRecordModel();
|