|
@@ -47,6 +47,7 @@ import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import jodd.introspector.MapperFunction;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
@@ -71,6 +72,7 @@ import static com.xy.utils.PlusBeans.*;
|
|
|
* @author lijin
|
|
|
* @since 2022-12-23
|
|
|
*/
|
|
|
+@Slf4j
|
|
|
@Service
|
|
|
@RequiredArgsConstructor
|
|
|
@Api(tags = "设备-信息")
|
|
@@ -669,7 +671,7 @@ public class DeviceInfoServiceImpl extends ServiceImpl<DeviceInfoMapper, DeviceI
|
|
|
@Override
|
|
|
@ApiOperation("小程序-商户设备首页列表")
|
|
|
public R<List<DeviceInfoDto.MercHomeListVO>> mercHomeList(DeviceInfoDto.MercHomeQueryDTO dto) {
|
|
|
-
|
|
|
+ String searchKey = dto.getSearchKey();
|
|
|
Long mercId = dto.getMercId();
|
|
|
String deviceName = dto.getDeviceName();
|
|
|
Long deviceId = dto.getDeviceId();
|
|
@@ -679,6 +681,23 @@ public class DeviceInfoServiceImpl extends ServiceImpl<DeviceInfoMapper, DeviceI
|
|
|
} else {
|
|
|
dto.setActiveState("1");
|
|
|
}
|
|
|
+ List<Long> searchDeviceIds = new ArrayList<>();
|
|
|
+ if (StrUtil.isNotEmpty(searchKey)) {
|
|
|
+ //名称或者编号搜索设备
|
|
|
+ List<DeviceInfo> list = list(Wrappers.<DeviceInfo>lambdaQuery()
|
|
|
+ .eq(DeviceInfo::getMercId, mercId)
|
|
|
+ .and(wrapper -> wrapper
|
|
|
+ .eq(DeviceInfo::getDeviceId, searchKey)
|
|
|
+ .or()
|
|
|
+ .likeRight(DeviceInfo::getDeviceName, searchKey)
|
|
|
+ )
|
|
|
+ );
|
|
|
+ if (CollUtil.isEmpty(list)) {
|
|
|
+ return R.ok(new ArrayList<>());
|
|
|
+ }
|
|
|
+ searchDeviceIds = list.stream().map(DeviceInfo::getDeviceId).collect(Collectors.toList());
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
List<Long> myDeviceIds = dto.getDeviceIdList();
|
|
|
|
|
@@ -687,27 +706,51 @@ public class DeviceInfoServiceImpl extends ServiceImpl<DeviceInfoMapper, DeviceI
|
|
|
Integer deviceType = dto.getDeviceType();
|
|
|
//条件查询 在线状态,运营状态,设备类型,
|
|
|
List<Long> deviceIdList = new ArrayList<>();
|
|
|
- if (deviceId != null && myDeviceIds.contains(deviceId)) {
|
|
|
+ if (deviceId != null && myDeviceIds.indexOf(deviceId) > 0) {
|
|
|
deviceIdList.add(deviceId);
|
|
|
}
|
|
|
- if (CollUtil.isNotEmpty(myDeviceIds)) {
|
|
|
+
|
|
|
+ if (CollUtil.isNotEmpty(myDeviceIds) && deviceId == null) {
|
|
|
deviceIdList.addAll(myDeviceIds);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ if (CollUtil.isNotEmpty(deviceIdList)) {
|
|
|
+ dto.setDeviceIdList(deviceIdList);
|
|
|
+ List<Long> queryDeviceIds = new ArrayList<>();
|
|
|
+ if (CollUtil.isNotEmpty(searchDeviceIds)) {
|
|
|
+ for (Long id : searchDeviceIds) {
|
|
|
+ int index = deviceIdList.indexOf(id);
|
|
|
+ if (index > 0) {
|
|
|
+ queryDeviceIds.add(id);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //无符合权限的搜索设备,返空
|
|
|
+ if (CollUtil.isEmpty(queryDeviceIds)) {
|
|
|
+ return R.ok(new ArrayList<>());
|
|
|
+ } else {
|
|
|
+ deviceIdList = queryDeviceIds;
|
|
|
+ dto.setDeviceIdList(queryDeviceIds);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ } else {
|
|
|
+ return R.ok(new ArrayList<>());
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
if (onlineStatus != null) {
|
|
|
List<DeviceStatus> deviceStatusList = deviceStatusService.list(Wrappers.<DeviceStatus>lambdaQuery()
|
|
|
- .eq(onlineStatus != null, DeviceStatus::getNetState, onlineStatus)
|
|
|
+ .eq(DeviceStatus::getNetState, onlineStatus)
|
|
|
.in(CollUtil.isNotEmpty(myDeviceIds), DeviceStatus::getDeviceId, deviceIdList)
|
|
|
);
|
|
|
if (CollUtil.isNotEmpty(deviceStatusList)) {
|
|
|
List<Long> dbDeviceIdList = deviceStatusList.stream().map(DeviceStatus::getDeviceId).collect(Collectors.toList());
|
|
|
- deviceIdList.addAll(dbDeviceIdList);
|
|
|
+ deviceIdList = dbDeviceIdList;
|
|
|
+ } else {
|
|
|
+ return R.ok(new ArrayList<>());
|
|
|
}
|
|
|
}
|
|
|
- if (CollUtil.isNotEmpty(deviceIdList)) {
|
|
|
- dto.setDeviceIdList(deviceIdList);
|
|
|
- }
|
|
|
-
|
|
|
|
|
|
List<DeviceInfoDto.MercHomeCountVO> list = this.baseMapper.merHomeCountList(dto);
|
|
|
if (CollUtil.isEmpty(list)) {
|
|
@@ -805,6 +848,7 @@ public class DeviceInfoServiceImpl extends ServiceImpl<DeviceInfoMapper, DeviceI
|
|
|
if (deviceStatus != null) {
|
|
|
Integer deviceStateL = deviceStatus.getLockStateL();
|
|
|
Integer deviceStateR = deviceStatus.getLockStateR();
|
|
|
+ device.setTempValue(deviceStatus.getTempValue());
|
|
|
device.setDeviceStateL(deviceStateL);
|
|
|
device.setDeviceStateR(deviceStateR);
|
|
|
DeviceLockState deviceLockStateL = DeviceLockState.getEnumByCode(deviceStateL);
|