TRX 1 vuosi sitten
vanhempi
commit
bd714d62fe

+ 0 - 3
FullCardClient/src/main/java/com/zhongshu/card/client/model/org/UserCountSimpleModel.java

@@ -1,9 +1,6 @@
 package com.zhongshu.card.client.model.org;
 
-import com.zhongshu.card.client.model.base.SuperModel;
-import com.zhongshu.card.client.type.CertificateType;
 import com.zhongshu.card.client.type.Sex;
-import com.zhongshu.card.client.type.UserLoginType;
 import com.zhongshu.card.client.type.UserState;
 import io.swagger.v3.oas.annotations.media.Schema;
 import lombok.AllArgsConstructor;

+ 0 - 3
FullCardClient/src/main/java/com/zhongshu/card/client/model/school/CardInfoStoreModel.java

@@ -1,8 +1,5 @@
 package com.zhongshu.card.client.model.school;
 
-import com.zhongshu.card.client.model.base.SuperModel;
-import com.zhongshu.card.client.model.org.OrganizationUserModel;
-import com.zhongshu.card.client.model.org.UserCountModel;
 import com.zhongshu.card.client.type.school.CardState;
 import com.zhongshu.card.client.type.school.CardType;
 import io.swagger.v3.oas.annotations.media.Schema;

+ 4 - 9
FullCardServer/src/main/java/com/zhongshu/card/server/core/dao/devices/DeviceUseRecordDao.java

@@ -1,13 +1,8 @@
 package com.zhongshu.card.server.core.dao.devices;
 
 import com.github.microservice.components.data.mongo.mongo.dao.MongoDao;
-import com.zhongshu.card.server.core.dao.devices.extend.DeviceInfoDaoExtend;
 import com.zhongshu.card.server.core.dao.devices.extend.DeviceUseRecordDaoExtend;
-import com.zhongshu.card.server.core.domain.devices.DeviceInfo;
-import com.zhongshu.card.server.core.domain.devices.DeviceUseRecord;
-import com.zhongshu.card.server.core.domain.payment.ExpenseFlow;
-
-import java.util.List;
+import com.zhongshu.card.server.core.domain.devices.DeviceUseRecords;
 
 /**
  * 设备使用记录Dao
@@ -15,10 +10,10 @@ import java.util.List;
  * @author TRX
  * @date 2024/3/21
  */
-public interface DeviceUseRecordDao extends MongoDao<DeviceUseRecord>, DeviceUseRecordDaoExtend {
+public interface DeviceUseRecordDao extends MongoDao<DeviceUseRecords>, DeviceUseRecordDaoExtend {
 
-    DeviceUseRecord findTopById(String id);
+    DeviceUseRecords findTopById(String id);
 
-    DeviceUseRecord findTopByMqttDataId(String mqttDataId);
+    DeviceUseRecords findTopByMqttDataId(String mqttDataId);
 
 }

+ 3 - 6
FullCardServer/src/main/java/com/zhongshu/card/server/core/dao/devices/extend/DeviceUseRecordDaoExtend.java

@@ -1,10 +1,7 @@
 package com.zhongshu.card.server.core.dao.devices.extend;
 
-import com.zhongshu.card.client.model.devices.DeviceInfoSearch;
 import com.zhongshu.card.client.model.devices.DeviceUseRecordSearch;
-import com.zhongshu.card.server.core.domain.devices.DeviceInfo;
-import com.zhongshu.card.server.core.domain.devices.DeviceUseRecord;
-import com.zhongshu.card.server.core.domain.payment.ExpenseFlow;
+import com.zhongshu.card.server.core.domain.devices.DeviceUseRecords;
 import org.springframework.data.domain.Page;
 import org.springframework.data.domain.Pageable;
 
@@ -17,8 +14,8 @@ import org.springframework.data.domain.Pageable;
  */
 public interface DeviceUseRecordDaoExtend {
 
-    Page<DeviceUseRecord> page(Pageable pageable, DeviceUseRecordSearch param);
+    Page<DeviceUseRecords> page(Pageable pageable, DeviceUseRecordSearch param);
 
-    DeviceUseRecord init(String mqttDataId, String token);
+    DeviceUseRecords init(String mqttDataId, String token);
 
 }

+ 6 - 12
FullCardServer/src/main/java/com/zhongshu/card/server/core/dao/devices/impl/DeviceUseRecordDaoImpl.java

@@ -1,16 +1,10 @@
 package com.zhongshu.card.server.core.dao.devices.impl;
 
 import com.github.microservice.components.data.mongo.mongo.helper.DBHelper;
-import com.zhongshu.card.client.model.devices.DeviceInfoSearch;
 import com.zhongshu.card.client.model.devices.DeviceUseRecordSearch;
 import com.zhongshu.card.server.core.dao.BaseImpl;
-import com.zhongshu.card.server.core.dao.devices.extend.DeviceInfoDaoExtend;
 import com.zhongshu.card.server.core.dao.devices.extend.DeviceUseRecordDaoExtend;
-import com.zhongshu.card.server.core.domain.devices.DeviceInfo;
-import com.zhongshu.card.server.core.domain.devices.DeviceUseRecord;
-import com.zhongshu.card.server.core.domain.payment.ExpenseFlow;
-import com.zhongshu.card.server.core.domain.school.Area;
-import com.zhongshu.card.server.core.util.CommonUtil;
+import com.zhongshu.card.server.core.domain.devices.DeviceUseRecords;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -43,7 +37,7 @@ public class DeviceUseRecordDaoImpl extends BaseImpl implements DeviceUseRecordD
     private DBHelper dbHelper;
 
     @Override
-    public Page<DeviceUseRecord> page(Pageable pageable, DeviceUseRecordSearch param) {
+    public Page<DeviceUseRecords> page(Pageable pageable, DeviceUseRecordSearch param) {
         Criteria criteria = buildCriteriaNotOid(param);
 
         // 所属项目
@@ -68,11 +62,11 @@ public class DeviceUseRecordDaoImpl extends BaseImpl implements DeviceUseRecordD
         Sort sort = buildSort(param);
         Query query = Query.query(criteria);
         query.with(sort);
-        return dbHelper.pages(query, pageable, DeviceUseRecord.class);
+        return dbHelper.pages(query, pageable, DeviceUseRecords.class);
     }
 
-    public DeviceUseRecord init(String mqttDataId, String token) {
-        DeviceUseRecord doc = null;
+    public DeviceUseRecords init(String mqttDataId, String token) {
+        DeviceUseRecords doc = null;
         try {
             Query query = Query.query(Criteria.where("mqttDataId").is(mqttDataId).and("token").isNull());
             Update update = new Update()
@@ -81,7 +75,7 @@ public class DeviceUseRecordDaoImpl extends BaseImpl implements DeviceUseRecordD
             FindAndModifyOptions options = new FindAndModifyOptions().upsert(true)
                     .returnNew(true);
             doc = mongoTemplate.findAndModify(query, update, options,
-                    DeviceUseRecord.class);
+                    DeviceUseRecords.class);
         } catch (Exception e) {
             log.error("init {}", e.getMessage());
         }

+ 9 - 11
FullCardServer/src/main/java/com/zhongshu/card/server/core/domain/devices/DeviceUseRecord.java → FullCardServer/src/main/java/com/zhongshu/card/server/core/domain/devices/DeviceUseRecords.java

@@ -1,24 +1,16 @@
 package com.zhongshu.card.server.core.domain.devices;
 
 import com.fasterxml.jackson.annotation.JsonProperty;
-import com.github.microservice.components.data.mongo.mongo.domain.SuperEntity;
 import com.github.microservice.models.type.DeviceType;
-import com.zhongshu.card.client.model.devices.DeviceInfoModel;
 import com.zhongshu.card.client.model.devices.DeviceInfoStoreModel;
 import com.zhongshu.card.client.model.org.UserCountSimpleModel;
-import com.zhongshu.card.client.model.school.CardInfoModel;
-import com.zhongshu.card.client.model.school.CardInfoSimpleModel;
 import com.zhongshu.card.client.model.school.CardInfoStoreModel;
 import com.zhongshu.card.server.core.domain.base.SuperMain;
-import com.zhongshu.card.server.core.domain.org.Organization;
-import com.zhongshu.card.server.core.domain.org.UserAccount;
-import com.zhongshu.card.server.core.domain.school.CardInfo;
 import io.swagger.v3.oas.annotations.media.Schema;
 import lombok.AllArgsConstructor;
 import lombok.Data;
 import lombok.NoArgsConstructor;
 import org.springframework.data.mongodb.core.index.Indexed;
-import org.springframework.data.mongodb.core.mapping.DBRef;
 import org.springframework.data.mongodb.core.mapping.Document;
 
 import java.util.Date;
@@ -33,12 +25,15 @@ import java.util.Date;
 @Document
 @NoArgsConstructor
 @AllArgsConstructor
-public class DeviceUseRecord extends SuperMain {
+public class DeviceUseRecords extends SuperMain {
 
     @Indexed(unique = true, sparse = true)
     @Schema(description = "mqtt推送生成的业务数据ID")
     private String mqttDataId;
 
+    @Schema(description = "token")
+    private String token;
+
     //----------------------------设备信息start ---------------------
     @Schema(description = "设备ID")
     private String deviceId;
@@ -52,10 +47,10 @@ public class DeviceUseRecord extends SuperMain {
     @Schema(description = "网关ID")
     private String gateWayId;
 
-    @Schema(description = "所属机构oid")
+    @Schema(description = "设备所属机构oid")
     private String beLongOid;
 
-    @Schema(description = "所属机构name")
+    @Schema(description = "设备所属机构name")
     private String beLongName;
 
     //----------------------卡片信息 start-------------------
@@ -82,6 +77,9 @@ public class DeviceUseRecord extends SuperMain {
     @Schema(description = "时间")
     private Long timestamp;
 
+    @Schema(description = "人脸内容")
+    private String pic;
+
     //-----------------------验证是否通过
 
     @Schema(description = "创建时间,可阅读的")

+ 75 - 82
FullCardServer/src/main/java/com/zhongshu/card/server/core/service/devices/DeviceUseRecordService.java

@@ -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();