|
@@ -49,36 +49,44 @@ public class Device2UseUsableService {
|
|
|
* @param visitorMain
|
|
* @param visitorMain
|
|
|
* @return
|
|
* @return
|
|
|
*/
|
|
*/
|
|
|
- public ResultContent addByVisitorData(VisitorMain visitorMain) {
|
|
|
|
|
|
|
+ public ResultContent addByVisitorData(VisitorMain visitorMain, boolean isDayLastTime) {
|
|
|
if (ObjectUtils.isEmpty(visitorMain)) {
|
|
if (ObjectUtils.isEmpty(visitorMain)) {
|
|
|
return ResultContent.buildFail("访客数据为空");
|
|
return ResultContent.buildFail("访客数据为空");
|
|
|
}
|
|
}
|
|
|
- Device2UseUsable entity = new Device2UseUsable();
|
|
|
|
|
- entity.setFromDataId(visitorMain.getId());
|
|
|
|
|
- entity.setServiceBeanName(CommonUtil.getCollectionName(VisitorMainService.class));
|
|
|
|
|
- entity.setTempType(DevicePermissFromType.Visitor);
|
|
|
|
|
|
|
+ String fromDataId = visitorMain.getId();
|
|
|
|
|
+ Device2UseUsable entity = device2UseUsableDao.findToByFromDataId(fromDataId);
|
|
|
|
|
+ if (ObjectUtils.isEmpty(entity)) {
|
|
|
|
|
+ entity = new Device2UseUsable();
|
|
|
|
|
+ entity.setFromDataId(visitorMain.getId());
|
|
|
|
|
+ entity.setServiceBeanName(CommonUtil.getCollectionName(VisitorMainService.class));
|
|
|
|
|
+ entity.setTempType(DevicePermissFromType.Visitor);
|
|
|
|
|
|
|
|
- List<String> useDataIds = new ArrayList<>();
|
|
|
|
|
- useDataIds.add(visitorMain.getTempUserId());
|
|
|
|
|
- if (StringUtils.isNotEmpty(visitorMain.getApplyUserId())) {
|
|
|
|
|
- useDataIds.add(visitorMain.getApplyUserId());
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ List<String> useDataIds = new ArrayList<>();
|
|
|
|
|
+ useDataIds.add(visitorMain.getTempUserId());
|
|
|
|
|
+ if (StringUtils.isNotEmpty(visitorMain.getApplyUserId())) {
|
|
|
|
|
+ useDataIds.add(visitorMain.getApplyUserId());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ entity.setUseDataIds(useDataIds);
|
|
|
|
|
+ entity.setStartTime(visitorMain.getPerStartTime());
|
|
|
|
|
|
|
|
- entity.setUseDataIds(useDataIds);
|
|
|
|
|
- entity.setStartTime(visitorMain.getPerStartTime());
|
|
|
|
|
- entity.setEndTime(visitorMain.getPerEndTime());
|
|
|
|
|
- entity.setTtl(new Date(visitorMain.getPerEndTime()));
|
|
|
|
|
- List<String> deviceIds = visitorMain.getDeviceIds();
|
|
|
|
|
- if (ObjectUtils.isEmpty(deviceIds)) {
|
|
|
|
|
- List<VisitorSettingDevice> list = visitorSettingDeviceDao.findBySceneComponentId(visitorMain.getSceneComponentId());
|
|
|
|
|
- if (ObjectUtils.isNotEmpty(list)) {
|
|
|
|
|
- deviceIds = list.stream().map(VisitorSettingDevice::getDeviceId).collect(Collectors.toList());
|
|
|
|
|
|
|
+ List<String> deviceIds = visitorMain.getDeviceIds();
|
|
|
|
|
+ if (ObjectUtils.isEmpty(deviceIds)) {
|
|
|
|
|
+ List<VisitorSettingDevice> list = visitorSettingDeviceDao.findBySceneComponentId(visitorMain.getSceneComponentId());
|
|
|
|
|
+ if (ObjectUtils.isNotEmpty(list)) {
|
|
|
|
|
+ deviceIds = list.stream().map(VisitorSettingDevice::getDeviceId).collect(Collectors.toList());
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
+ entity.setDeviceIds(deviceIds);
|
|
|
|
|
+ entity.setProjectOid(visitorMain.getProjectOid());
|
|
|
|
|
+ entity.setOid(visitorMain.getOid());
|
|
|
}
|
|
}
|
|
|
- entity.setDeviceIds(deviceIds);
|
|
|
|
|
- entity.setProjectOid(visitorMain.getProjectOid());
|
|
|
|
|
- entity.setOid(visitorMain.getOid());
|
|
|
|
|
-
|
|
|
|
|
|
|
+ Long endTime = visitorMain.getEndTime();
|
|
|
|
|
+ if (isDayLastTime) {
|
|
|
|
|
+ endTime = visitorMain.getPerEndTime();
|
|
|
|
|
+ }
|
|
|
|
|
+ entity.setEndTime(endTime);
|
|
|
|
|
+ entity.setTtl(new Date(endTime));
|
|
|
device2UseUsableDao.save(entity);
|
|
device2UseUsableDao.save(entity);
|
|
|
return ResultContent.buildSuccess();
|
|
return ResultContent.buildSuccess();
|
|
|
}
|
|
}
|