|
|
@@ -4,7 +4,10 @@ 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;
|
|
|
@@ -20,6 +23,8 @@ import com.zhongshu.card.server.core.domain.devices.DeviceUseRecord;
|
|
|
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;
|
|
|
+import com.zhongshu.card.server.core.service.projectAbout.CardInfoServiceImpl;
|
|
|
+import com.zhongshu.card.server.core.service.user.UserAccountServiceImpl;
|
|
|
import com.zhongshu.card.server.core.util.BeanUtils;
|
|
|
import com.zhongshu.card.server.core.util.TokenUtil;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
@@ -51,6 +56,15 @@ public class DeviceUseRecordService extends SuperService {
|
|
|
@Autowired
|
|
|
private UserCountDao userCountDao;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private UserAccountServiceImpl userAccountService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private CardInfoServiceImpl cardInfoService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private DeviceInfoServiceImpl deviceInfoService;
|
|
|
+
|
|
|
/**
|
|
|
* 设备使用日志 (物联网来的数据)
|
|
|
*
|
|
|
@@ -61,6 +75,7 @@ public class DeviceUseRecordService extends SuperService {
|
|
|
// 返回数据
|
|
|
GateDoorUseResult result = new GateDoorUseResult();
|
|
|
String mqttDataId = param.getMqttDataId();
|
|
|
+ log.info("mqttDataId: {}", mqttDataId);
|
|
|
if (StringUtils.isNotEmpty(mqttDataId)) {
|
|
|
DeviceUseRecord deviceUseRecord = init(mqttDataId);
|
|
|
if (ObjectUtils.isNotEmpty(deviceUseRecord)) {
|
|
|
@@ -79,11 +94,10 @@ public class DeviceUseRecordService extends SuperService {
|
|
|
deviceUseRecord.setDeviceId(deviceId);
|
|
|
if (ObjectUtils.isNotEmpty(deviceInfo)) {
|
|
|
// 设备信息
|
|
|
- deviceUseRecord.setDeviceInfo(deviceInfo);
|
|
|
+ deviceUseRecord.setDeviceInfo(deviceInfoService.toStoreModel(deviceInfo));
|
|
|
deviceUseRecord.setDeviceType(deviceInfo.getDeviceType());
|
|
|
deviceUseRecord.setGateWayId(deviceInfo.getGateWayId());
|
|
|
|
|
|
- deviceUseRecord.setBeLongOrganization(deviceInfo.getOrganization());
|
|
|
deviceUseRecord.setBeLongOid(deviceInfo.getBeLongOid());
|
|
|
deviceUseRecord.setBeLongName(deviceInfo.getBeLongName());
|
|
|
}
|
|
|
@@ -99,14 +113,15 @@ public class DeviceUseRecordService extends SuperService {
|
|
|
deviceUseRecord.setCardNo(cardNo);
|
|
|
if (ObjectUtils.isNotEmpty(cardInfo)) {
|
|
|
// 卡片信息
|
|
|
- deviceUseRecord.setCardInfo(cardInfo);
|
|
|
+ deviceUseRecord.setCardInfo(cardInfoService.toStoreModel(cardInfo));
|
|
|
}
|
|
|
+
|
|
|
UserAccount userAccount = null;
|
|
|
if (StringUtils.isNotEmpty(userId)) {
|
|
|
userAccount = userCountDao.findTopByUserId(userId);
|
|
|
}
|
|
|
deviceUseRecord.setUserId(userId);
|
|
|
- deviceUseRecord.setUserAccount(userAccount);
|
|
|
+ deviceUseRecord.setUserAccount(userAccountService.toSimpleModel(userAccount));
|
|
|
|
|
|
if (StringUtils.isNotEmpty(param.getTime())) {
|
|
|
deviceUseRecord.setTimestamp(DateUtils.timeToLong(param.getTime(), DateUtils.FORMAT_LONG));
|
|
|
@@ -177,14 +192,14 @@ public class DeviceUseRecordService extends SuperService {
|
|
|
entity.setMsg("设备信息未找到");
|
|
|
return;
|
|
|
}
|
|
|
- DeviceInfo deviceInfo = entity.getDeviceInfo();
|
|
|
+ DeviceInfoStoreModel deviceInfo = entity.getDeviceInfo();
|
|
|
if (deviceInfo.getState() == null || deviceInfo.getState() != DataState.Enable) {
|
|
|
entity.setIsPassed(Boolean.FALSE);
|
|
|
entity.setMsg("设备未启用");
|
|
|
return;
|
|
|
}
|
|
|
//2. 验证用户信息
|
|
|
- UserAccount userAccount = entity.getUserAccount();
|
|
|
+ UserCountSimpleModel userAccount = entity.getUserAccount();
|
|
|
if (ObjectUtils.isEmpty(userAccount)) {
|
|
|
entity.setIsPassed(Boolean.FALSE);
|
|
|
entity.setMsg("用户信息未确定");
|
|
|
@@ -223,7 +238,7 @@ public class DeviceUseRecordService extends SuperService {
|
|
|
entity.setMsg("卡片未找到");
|
|
|
return;
|
|
|
}
|
|
|
- CardInfo cardInfo = entity.getCardInfo();
|
|
|
+ CardInfoStoreModel cardInfo = entity.getCardInfo();
|
|
|
if (cardInfo.getIsCanceled() != null && cardInfo.getIsCanceled()) {
|
|
|
entity.setIsPassed(Boolean.FALSE);
|
|
|
entity.setMsg("卡片已作废");
|