|
|
|
@ -2,73 +2,32 @@ package org.dromara.sample.manage.service.impl; |
|
|
|
|
|
|
|
import cn.hutool.core.collection.ListUtil; |
|
|
|
import cn.hutool.core.lang.Dict; |
|
|
|
import cn.hutool.core.stream.StreamUtil; |
|
|
|
import cn.hutool.core.util.ObjectUtil; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|
|
|
import com.fasterxml.jackson.databind.JsonNode; |
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.apache.ibatis.executor.BatchResult; |
|
|
|
import org.dromara.common.core.constant.Constants; |
|
|
|
import org.dromara.common.core.exception.ServiceException; |
|
|
|
import org.dromara.common.redis.utils.RedisOpsUtils; |
|
|
|
import org.dromara.common.redis.utils.RedisUtils; |
|
|
|
import org.dromara.common.satoken.utils.LoginHelper; |
|
|
|
import org.dromara.common.sdk.cloudapi.device.*; |
|
|
|
import org.dromara.common.sdk.cloudapi.firmware.*; |
|
|
|
import org.dromara.common.sdk.cloudapi.firmware.api.AbstractFirmwareService; |
|
|
|
import org.dromara.common.sdk.cloudapi.property.api.AbstractPropertyService; |
|
|
|
import org.dromara.common.sdk.cloudapi.tsa.DeviceIconUrl; |
|
|
|
import org.dromara.common.sdk.cloudapi.tsa.TopologyDeviceModel; |
|
|
|
import org.dromara.common.sdk.common.*; |
|
|
|
import org.dromara.common.sdk.config.version.GatewayManager; |
|
|
|
import org.dromara.common.sdk.exception.CloudSDKException; |
|
|
|
import org.dromara.common.sdk.mqtt.IMqttTopicService; |
|
|
|
import org.dromara.common.sdk.mqtt.MqttGatewayPublish; |
|
|
|
import org.dromara.common.sdk.mqtt.events.EventsSubscribe; |
|
|
|
import org.dromara.common.sdk.mqtt.osd.OsdSubscribe; |
|
|
|
import org.dromara.common.sdk.mqtt.property.PropertySetReplyResultEnum; |
|
|
|
import org.dromara.common.sdk.mqtt.property.PropertySetSubscribe; |
|
|
|
import org.dromara.common.sdk.mqtt.requests.RequestsSubscribe; |
|
|
|
import org.dromara.common.sdk.mqtt.services.ServicesReplyData; |
|
|
|
import org.dromara.common.sdk.mqtt.services.ServicesSubscribe; |
|
|
|
import org.dromara.common.sdk.mqtt.services.TopicServicesResponse; |
|
|
|
import org.dromara.common.sdk.mqtt.state.StateSubscribe; |
|
|
|
import org.dromara.common.sdk.mqtt.status.StatusSubscribe; |
|
|
|
import org.dromara.common.tenant.helper.TenantHelper; |
|
|
|
import org.dromara.common.websocket.dto.BizCodeEnum; |
|
|
|
import org.dromara.sample.common.error.CommonErrorEnum; |
|
|
|
import org.dromara.sample.component.mqtt.model.EventsReceiver; |
|
|
|
import org.dromara.sample.control.model.enums.DroneAuthorityEnum; |
|
|
|
import org.dromara.sample.feign.RemoteSystemFeign; |
|
|
|
import org.dromara.sample.manage.mapper.IDeviceMapper; |
|
|
|
import org.dromara.sample.manage.mapper.IDeviceProMapper; |
|
|
|
import org.dromara.sample.manage.mapper.IDeviceProUserMapper; |
|
|
|
import org.dromara.sample.manage.mapper.IDeviceQrtzMapper; |
|
|
|
import org.dromara.sample.manage.model.dto.*; |
|
|
|
import org.dromara.sample.manage.model.entity.DeviceEntity; |
|
|
|
import org.dromara.sample.manage.model.entity.DeviceProEntity; |
|
|
|
import org.dromara.sample.manage.model.entity.DeviceProUserEntity; |
|
|
|
import org.dromara.sample.manage.model.entity.DeviceQrtzDateEntity; |
|
|
|
import org.dromara.sample.manage.model.enums.DeviceFirmwareStatusEnum; |
|
|
|
import org.dromara.sample.manage.model.enums.PropertySetFieldEnum; |
|
|
|
import org.dromara.sample.manage.model.enums.UserTypeEnum; |
|
|
|
import org.dromara.sample.manage.model.param.DeviceQueryParam; |
|
|
|
import org.dromara.sample.manage.model.receiver.BasicDeviceProperty; |
|
|
|
import org.dromara.sample.manage.service.*; |
|
|
|
import org.dromara.sample.websocket.service.IWebSocketMessageService; |
|
|
|
import org.dromara.system.api.domain.vo.RemoteUserVo; |
|
|
|
import org.dromara.system.api.model.LoginUser; |
|
|
|
import org.springframework.beans.BeanUtils; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.scheduling.annotation.Async; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
import org.springframework.util.CollectionUtils; |
|
|
|
import org.springframework.util.StringUtils; |
|
|
|
|
|
|
|
import java.time.LocalDateTime; |
|
|
|
import java.util.*; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
@ -91,6 +50,9 @@ public class DeviceProServiceImpl implements IDeviceProService { |
|
|
|
@Autowired |
|
|
|
private IDeviceProUserMapper deviceProUserMapper; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
RemoteSystemFeign remoteSystemFeign; |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
public PaginationData<DeviceProEntity> listDeviceProEntityMap(Page page, DeviceProDTO deviceProDTO) { |
|
|
|
@ -128,8 +90,7 @@ public class DeviceProServiceImpl implements IDeviceProService { |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public Boolean updateDeviceProUser(List<DeviceProUserEntity> userEntity,Integer proId) { |
|
|
|
public Boolean updateDeviceProUser(List<DeviceProUserEntity> userEntity, Integer proId) { |
|
|
|
try { |
|
|
|
List<DeviceProUserEntity> proUserEntityList = deviceProUserMapper.selectList(new LambdaQueryWrapper<DeviceProUserEntity>().eq(DeviceProUserEntity::getDeviceProId, proId)); |
|
|
|
|
|
|
|
@ -153,6 +114,48 @@ public class DeviceProServiceImpl implements IDeviceProService { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public Boolean updateDeviceProUserNew(List<Map<String, Object>> userEntity, Integer proId) { |
|
|
|
try { |
|
|
|
List<Map<String, Object>> resultList = remoteSystemFeign.listTargetTypeByUser(userEntity); |
|
|
|
|
|
|
|
//构建DeviceProUserEntity集合
|
|
|
|
List<DeviceProUserEntity> userEntityList = new ArrayList<>(); |
|
|
|
|
|
|
|
resultList.forEach(resultMap -> { |
|
|
|
DeviceProUserEntity deviceProUserEntity = new DeviceProUserEntity(); |
|
|
|
deviceProUserEntity.setDeviceProId(proId); |
|
|
|
deviceProUserEntity.setUserId(Long.valueOf(resultMap.get("userId") + "")); |
|
|
|
deviceProUserEntity.setUserName(resultMap.get("userName") + ""); |
|
|
|
deviceProUserEntity.setNickName(resultMap.get("nickName") + ""); |
|
|
|
|
|
|
|
userEntityList.add(deviceProUserEntity); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
List<DeviceProUserEntity> proUserEntityList = deviceProUserMapper.selectList(new LambdaQueryWrapper<DeviceProUserEntity>().eq(DeviceProUserEntity::getDeviceProId, proId)); |
|
|
|
|
|
|
|
List<DeviceProUserEntity> different = userEntityList.stream() |
|
|
|
.filter(user -> proUserEntityList.stream().noneMatch(u -> u.getUserId().equals(user.getUserId()))) |
|
|
|
.toList(); |
|
|
|
|
|
|
|
|
|
|
|
if (ObjectUtil.isNotEmpty(different)){ |
|
|
|
//添加新的项目组成员
|
|
|
|
deviceProUserMapper.insert(different); |
|
|
|
} |
|
|
|
|
|
|
|
//更新设备组redis缓存
|
|
|
|
Boolean flag = updateDeviceProCache("update",null); |
|
|
|
|
|
|
|
return true; |
|
|
|
} catch (ServiceException e) { |
|
|
|
log.error(e.getMessage(),e); |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 更新设备组人员缓存 |
|
|
|
* @return |
|
|
|
@ -364,6 +367,7 @@ public class DeviceProServiceImpl implements IDeviceProService { |
|
|
|
return this.updateDeviceProCache("init",null); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
public Boolean saveAndUpdate(DeviceProEntity entity) { |
|
|
|
boolean flag = true; |
|
|
|
|