|
@@ -13,15 +13,19 @@ import cn.iocoder.yudao.module.pms.dal.mysql.IotInfoClassifyMapper;
|
|
|
import cn.iocoder.yudao.module.pms.dal.dataobject.IotTreeDO;
|
|
|
import cn.iocoder.yudao.module.pms.dal.mysql.IotTreeMapper;
|
|
|
import cn.iocoder.yudao.module.system.enums.ErrorCodeConstants;
|
|
|
+import cn.iocoder.yudao.module.system.service.dept.DeptService;
|
|
|
import com.google.common.collect.ImmutableMap;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
|
+import java.util.HashSet;
|
|
|
import java.util.List;
|
|
|
import java.util.Objects;
|
|
|
+import java.util.Set;
|
|
|
|
|
|
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
|
|
import static cn.iocoder.yudao.module.pms.enums.ErrorCodeConstant.IOT_DEVICE_NOT_EXISTS;
|
|
@@ -41,6 +45,8 @@ public class IotDeviceServiceImpl implements IotDeviceService {
|
|
|
private IotInfoClassifyMapper iotInfoClassifyMapper;
|
|
|
@Resource
|
|
|
private IotTreeMapper iotTreeMapper;
|
|
|
+ @Resource
|
|
|
+ private DeptService deptService;
|
|
|
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@@ -61,7 +67,7 @@ public class IotDeviceServiceImpl implements IotDeviceService {
|
|
|
iotTreeDO.setType("device");
|
|
|
iotTreeDO.setOriginId(iotDevice.getId());
|
|
|
iotTreeDO.setName(iotDevice.getDeviceName());
|
|
|
- List<IotTreeDO> iotTreeDOS = iotTreeMapper.selectListByOriginId(iotDevice.getOrgId(),"dept");
|
|
|
+ List<IotTreeDO> iotTreeDOS = iotTreeMapper.selectListByOriginId(iotDevice.getDeptId(),"dept");
|
|
|
if (CollUtil.isNotEmpty(iotTreeDOS)) {
|
|
|
iotTreeDO.setParentId(Objects.nonNull(iotTreeDOS.get(0)) ? iotTreeDOS.get(0).getId() : 0);
|
|
|
iotTreeMapper.insert(iotTreeDO);
|
|
@@ -110,7 +116,13 @@ public class IotDeviceServiceImpl implements IotDeviceService {
|
|
|
|
|
|
@Override
|
|
|
public PageResult<IotDeviceDO> getIotDevicePage(IotDevicePageReqVO pageReqVO) {
|
|
|
- return iotDeviceMapper.selectPage(pageReqVO);
|
|
|
+ Set<Long> ids = new HashSet<>();
|
|
|
+ if (Objects.nonNull(pageReqVO.getDeptId())) {
|
|
|
+ ids = deptService.getChildDeptIdListFromCache(pageReqVO.getDeptId());
|
|
|
+ ids.add(pageReqVO.getDeptId());
|
|
|
+ }
|
|
|
+
|
|
|
+ return iotDeviceMapper.selectPage(pageReqVO,ids);
|
|
|
}
|
|
|
|
|
|
}
|