Commit adbd94d4 by 杨伟程
parents cb681ce1 22ff5980
Showing with 258 additions and 35 deletions
package com.makeit.module.iot.service;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.makeit.module.iot.util.HttpRequest;
import com.makeit.module.iot.vo.DeviceInstanceEntity;
import com.makeit.module.iot.vo.ResponseMessage;
import com.makeit.utils.data.convert.JsonUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;
import java.io.IOException;
import java.util.List;
import java.util.Map;
/**
* iot产品设备相关接口
*/
@Component
@Slf4j
public class IotDevicePropertiesOperateService extends IotCommonService {
public static final String DEVICE_PREFIX_URL = "/device-instance/";
/**
* 把设备写入属性
*/
@Async
public List<DeviceInstanceEntity> deviceWrite(String deviceId, Integer radarMount, Integer radarMode, Integer radarHight) {
String url = iotUrl + DEVICE_PREFIX_URL + deviceId + "/property";
// 条件可以自己改
Map<String, Object> map = Maps.newHashMap();
if (radarMount != null) {
map.put("radarMount", radarMount);
}
if (radarMode != null) {
map.put("radarMode", radarMode);
}
if (radarHight != null) {
map.put("radarHight", radarHight);
}
String body = JsonUtil.toJson(map);
HttpRequest request = buildRequest(url, body);
try {
ResponseMessage responseMessage = sendPut(url, request);
log.error("写入设备属性信息:{}", responseMessage.getMessage());
} catch (IOException e) {
log.error("调用:{}接口异常:{}", url, e.getMessage());
}
return Lists.newArrayList();
}
}
......@@ -38,6 +38,8 @@ public class IotProductDeviceService extends IotCommonService {
public static final String DEVICE_PREFIX_URL = "/device-instance/";
public static final String REPORT_PROPERTY = "reportProperty";
/**
* 获取设备信息
*/
......@@ -94,7 +96,7 @@ public class IotProductDeviceService extends IotCommonService {
//TODO ywc 下面几个使用时还要不要根据状态的过滤
public DeviceInfoContentBreathe getLastDeviceLogBreathe(String deviceId, Integer ignoreDuration) {//秒
DeviceOperationLogEntity deviceOperationLogEntity = getLastDeviceLogByType(deviceId, "reportProperty");
DeviceOperationLogEntity deviceOperationLogEntity = getLastDeviceLogByType(deviceId, REPORT_PROPERTY);
if (deviceOperationLogEntity == null) {
return null;
}
......@@ -111,7 +113,7 @@ public class IotProductDeviceService extends IotCommonService {
}
public DeviceInfoContentSpace getLastDeviceLogSpace(String deviceId, Integer ignoreDuration) {//秒
DeviceOperationLogEntity deviceOperationLogEntity = getLastDeviceLogByType(deviceId, "reportProperty");
DeviceOperationLogEntity deviceOperationLogEntity = getLastDeviceLogByType(deviceId, REPORT_PROPERTY);
if (deviceOperationLogEntity == null) {
return null;
}
......@@ -130,7 +132,7 @@ public class IotProductDeviceService extends IotCommonService {
public List<DeviceInfoContentBreathe> getDeviceLogByTimeRangeBreathe(String deviceId, int pageSize, LocalDateTime startTime, LocalDateTime endTime) {
DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
List<DeviceOperationLogEntity> deviceOperationLogEntityList = getDeviceLogByTimeRange(deviceId, "reportProperty", pageSize, dateTimeFormatter.format(startTime), dateTimeFormatter.format(endTime));
List<DeviceOperationLogEntity> deviceOperationLogEntityList = getDeviceLogByTimeRange(deviceId, REPORT_PROPERTY, pageSize, dateTimeFormatter.format(startTime), dateTimeFormatter.format(endTime));
List<DeviceInfoContentBreathe> deviceInfoContentBreatheList = StreamUtil.map(deviceOperationLogEntityList, e -> JsonUtil.toObj((String) e.getContent(), DeviceInfoContentBreathe.class));
......@@ -140,7 +142,7 @@ public class IotProductDeviceService extends IotCommonService {
public List<DeviceInfoContentSpace> getDeviceLogByTimeRangeSpace(String deviceId, int pageSize, LocalDateTime startTime, LocalDateTime endTime) {
DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
List<DeviceOperationLogEntity> deviceOperationLogEntityList = getDeviceLogByTimeRange(deviceId, "reportProperty", pageSize, dateTimeFormatter.format(startTime), dateTimeFormatter.format(endTime));
List<DeviceOperationLogEntity> deviceOperationLogEntityList = getDeviceLogByTimeRange(deviceId, REPORT_PROPERTY, pageSize, dateTimeFormatter.format(startTime), dateTimeFormatter.format(endTime));
List<DeviceInfoContentSpace> deviceInfoContentSpaceList = StreamUtil.map(deviceOperationLogEntityList, e -> JsonUtil.toObj((String) e.getContent(), DeviceInfoContentSpace.class));
......@@ -150,7 +152,7 @@ public class IotProductDeviceService extends IotCommonService {
public List<DeviceInfoContentFall> getDeviceLogByTimeRangeFall(String deviceId, int pageSize, LocalDateTime startTime, LocalDateTime endTime) {
DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
List<DeviceOperationLogEntity> deviceOperationLogEntityList = getDeviceLogByTimeRange(deviceId, "reportProperty", pageSize, dateTimeFormatter.format(startTime), dateTimeFormatter.format(endTime));
List<DeviceOperationLogEntity> deviceOperationLogEntityList = getDeviceLogByTimeRange(deviceId, REPORT_PROPERTY, pageSize, dateTimeFormatter.format(startTime), dateTimeFormatter.format(endTime));
List<DeviceInfoContentFall> deviceInfoContentFallList = StreamUtil.map(deviceOperationLogEntityList, e -> JsonUtil.toObj((String) e.getContent(), DeviceInfoContentFall.class));
......@@ -237,7 +239,7 @@ public class IotProductDeviceService extends IotCommonService {
Term term3 = Term.builder()
.column("type")
.termType("eq")
.type(Term.Type.or)
.type(Term.Type.and)
.value(typeValue)
.terms(Lists.newArrayList())
.options(Lists.newArrayList())
......
......@@ -52,11 +52,18 @@ public class PlatRegionSettingController {
return ApiResponseUtils.success();
}
@ApiOperation("定位")
@ApiOperation("定位(时间范围内定位)")
@PostMapping("locate")
public ApiResponseEntity<List<PlatElderCoordinateVO>> locate(@RequestBody PlatRegionSettingLocateDTO dto) {
List<PlatElderCoordinateVO> list = platRegionSettingService.locate(dto);
return ApiResponseUtils.success(list);
}
@ApiOperation("实时定位")
@PostMapping("nowDataLocate")
public ApiResponseEntity<PlatElderCoordinateVO> nowDataLocate(@RequestBody PlatRegionSettingLocateDTO dto) {
PlatElderCoordinateVO vo = platRegionSettingService.nowDataLocate(dto);
return ApiResponseUtils.success(vo);
}
}
......@@ -7,6 +7,7 @@ import com.makeit.common.page.PageVO;
import com.makeit.common.response.ApiResponseEntity;
import com.makeit.common.response.ApiResponseUtils;
import com.makeit.dto.platform.device.PlatDeviceQueryDTO;
import com.makeit.dto.wechat.device.PlatDeviceAttrWechatDTO;
import com.makeit.dto.wechat.device.PlatDeviceEditWechatDTO;
import com.makeit.dto.wechat.device.PlatDeviceSetupDTO;
import com.makeit.service.platform.device.PlatDeviceService;
......@@ -64,5 +65,12 @@ public class PlatDeviceWechatController {
return ApiResponseUtils.success();
}
@ApiOperation("编辑设备属性")
@PostMapping("editDeviceProperties")
public ApiResponseEntity<?> editDeviceProperties(@RequestBody PlatDeviceAttrWechatDTO dto) {
platDeviceService.editDeviceProperties(dto);
return ApiResponseUtils.success();
}
}
......@@ -53,10 +53,17 @@ public class PlatRegionSettingWechatController {
return ApiResponseUtils.success();
}
@ApiOperation("定位")
@ApiOperation("定位(时间范围内定位)")
@PostMapping("locate")
public ApiResponseEntity<List<PlatElderCoordinateVO>> locate(@RequestBody PlatRegionSettingLocateDTO dto) {
List<PlatElderCoordinateVO> list = platRegionSettingService.locate(dto);
return ApiResponseUtils.success(list);
}
@ApiOperation("实时定位")
@PostMapping("nowDataLocate")
public ApiResponseEntity<PlatElderCoordinateVO> nowDataLocate(@RequestBody PlatRegionSettingLocateDTO dto) {
PlatElderCoordinateVO vo = platRegionSettingService.nowDataLocate(dto);
return ApiResponseUtils.success(vo);
}
}
package com.makeit.dto.wechat.device;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* <p>
* 设备
* </p>
*
* @author eugene young
* @since 2023-09-05
*/
@Data
@ApiModel(value = "PlatDeviceAttrWechatDTO对象", description = "设备属性")
public class PlatDeviceAttrWechatDTO {
@ApiModelProperty(value = "设备id")
private String deviceId;
@ApiModelProperty(value = "雷达安装方式 雷达安装方式")
private Integer radarMount;
@ApiModelProperty(value = "雷达功能模式 默认侧装轨迹\n" +
"侧装下\n" +
"0为存在模式,1为轨迹模式;\n" +
"顶装下\n" +
"0为存在模式,1为区块模式;")
private Integer radarMode;
@ApiModelProperty(value = "\"最小值\":200,\"最大值\":380,\"步\n" +
"进\":1,\"单位\":\"cm\"")
private Integer radarHight;
}
......@@ -15,7 +15,7 @@ import java.util.List;
* @Describe:
*/
public interface PlatRoomMapper extends BaseMapper<PlatRoom> {
List<PlatSpaceAndRoomVO> spaceAndRoomList();
List<PlatSpaceAndRoomVO> spaceAndRoomList(@Param("orgIds")List<String> orgIds);
List<WorkStationInstitutionRoomVO> workStationList(@Param("dto") WorkStationQueryDTO dto);
}
......@@ -15,7 +15,7 @@ import java.util.List;
*/
public interface PlatSpaceMapper extends BaseMapper<PlatSpace> {
List<PlatSpaceAndRoomVO> spaceListExcludeLast();
List<PlatSpaceAndRoomVO> spaceListExcludeLast(@Param("orgIds") List<String> orgIds);
List<PlatSpace> listChild(@Param("spaceIds") List<String> spaceIds);
}
......@@ -10,7 +10,6 @@ import com.makeit.common.entity.BaseEntity;
import com.makeit.common.page.PageReqDTO;
import com.makeit.common.page.PageVO;
import com.makeit.entity.platform.auth.PlatOrg;
import com.makeit.entity.platform.auth.PlatRole;
import com.makeit.entity.platform.auth.PlatRoleOrg;
import com.makeit.entity.platform.auth.PlatUserRole;
import com.makeit.entity.platform.space.PlatSpace;
......@@ -46,7 +45,6 @@ import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.Set;
import java.util.function.Function;
import java.util.stream.Collectors;
......@@ -436,8 +434,9 @@ public class PlatOrgServiceImpl extends ServiceImpl<PlatOrgMapper, PlatOrg>
if (CollectionUtils.isEmpty(roleOrgList)) {
return new HashSet<>();
}
List<PlatRole> roleList = platRoleService.listByIds(roleOrgList.stream().map(PlatRoleOrg::getRoleId).collect(Collectors.toList()));
return roleList.stream().flatMap(vo -> Stream.of(Optional.ofNullable(vo.getDataScope()).orElse(new String()) .split(","))).collect(Collectors.toSet());
return roleOrgList.stream().map(PlatRoleOrg::getOrgId).collect(Collectors.toSet());
// List<PlatRole> roleList = platRoleService.listByIds(roleOrgList.stream().map(PlatRoleOrg::getRoleId).collect(Collectors.toList()));
// return roleList.stream().flatMap(vo -> Stream.of(Optional.ofNullable(vo.getDataScope()).orElse(new String()) .split(","))).collect(Collectors.toSet());
}
/**
* 租户权限的组织树
......
......@@ -7,6 +7,7 @@ import com.makeit.dto.platform.device.PlatDeviceDetailDTO;
import com.makeit.dto.platform.device.PlatDeviceEditDTO;
import com.makeit.dto.platform.device.PlatDeviceQueryDTO;
import com.makeit.dto.saas.device.PlatDeviceEditSaasDTO;
import com.makeit.dto.wechat.device.PlatDeviceAttrWechatDTO;
import com.makeit.dto.wechat.device.PlatDeviceEditWechatDTO;
import com.makeit.dto.wechat.device.PlatDeviceSetupDTO;
import com.makeit.entity.platform.device.PlatDevice;
......@@ -52,4 +53,6 @@ public interface PlatDeviceService extends IService<PlatDevice> {
PlatDeviceDetailDTO getDetailDTO(String deviceId);
void saasEdit(PlatDeviceEditSaasDTO dto);
void editDeviceProperties(PlatDeviceAttrWechatDTO dto);
}
......@@ -12,6 +12,7 @@ import com.makeit.dto.platform.device.PlatDeviceDetailDTO;
import com.makeit.dto.platform.device.PlatDeviceEditDTO;
import com.makeit.dto.platform.device.PlatDeviceQueryDTO;
import com.makeit.dto.saas.device.PlatDeviceEditSaasDTO;
import com.makeit.dto.wechat.device.PlatDeviceAttrWechatDTO;
import com.makeit.dto.wechat.device.PlatDeviceEditWechatDTO;
import com.makeit.dto.wechat.device.PlatDeviceSetupDTO;
import com.makeit.entity.platform.auth.PlatOrg;
......@@ -20,6 +21,7 @@ import com.makeit.entity.platform.device.PlatDeviceOther;
import com.makeit.enums.CodeMessageEnum;
import com.makeit.exception.BusinessException;
import com.makeit.mapper.platform.device.PlatDeviceMapper;
import com.makeit.module.iot.service.IotDevicePropertiesOperateService;
import com.makeit.service.platform.auth.PlatOrgService;
import com.makeit.service.platform.device.PlatDeviceOtherService;
import com.makeit.service.platform.device.PlatDeviceService;
......@@ -56,6 +58,8 @@ public class PlatDeviceServiceImpl extends ServiceImpl<PlatDeviceMapper, PlatDev
private PlatOrgService platOrgService;
@Autowired
private DeviceCacheUtil deviceCacheUtil;
@Autowired
private IotDevicePropertiesOperateService devicePropertiesOperateService;
@Override
public PageVO<PlatDeviceListVO> page(PageReqDTO<PlatDeviceQueryDTO> pageReqDTO) {
......@@ -256,4 +260,9 @@ public class PlatDeviceServiceImpl extends ServiceImpl<PlatDeviceMapper, PlatDev
.orderByDesc(BaseEntity::getUpdateDate);
}
@Override
public void editDeviceProperties(PlatDeviceAttrWechatDTO dto) {
devicePropertiesOperateService.deviceWrite(dto.getDeviceId(),dto.getRadarMount(),dto.getRadarMode(),dto.getRadarHight());
}
}
......@@ -46,4 +46,6 @@ public interface PlatRegionSettingService extends IService<PlatRegionSetting> {
void batchEdit(List<PlatRegionSettingDTO> dtos);
List<PlatElderCoordinateVO> locate(PlatRegionSettingLocateDTO dto);
PlatElderCoordinateVO nowDataLocate(PlatRegionSettingLocateDTO dto);
}
......@@ -60,7 +60,7 @@ public interface PlatRoomService extends IService<PlatRoom> {
*/
PageVO<PlatRoom> page(PageReqDTO<PlatRoomQueryDTO> page);
List<PlatSpaceAndRoomVO> spaceAndRoomList();
List<PlatSpaceAndRoomVO> spaceAndRoomList(List<String> orgIds);
List<WorkStationInstitutionRoomVO> workStationList(WorkStationQueryDTO dto);
}
......@@ -52,7 +52,7 @@ public interface PlatSpaceService extends IService<PlatSpace> {
*/
PlatSpaceAddDTO view(String id);
List<PlatSpaceAndRoomVO> spaceListExcludeLast();
List<PlatSpaceAndRoomVO> spaceListExcludeLast(List<String> orgIds);
/**
* 空间树 到 床位
......
......@@ -20,6 +20,7 @@ import com.makeit.service.platform.device.PlatDeviceService;
import com.makeit.service.platform.space.PlatRegionSettingService;
import com.makeit.utils.data.convert.BeanDtoVoUtils;
import com.makeit.utils.data.convert.JsonUtil;
import com.makeit.utils.data.validate.CollectionUtils;
import com.makeit.vo.platform.elder.realtime.PlatElderCoordinateVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
......@@ -27,10 +28,7 @@ import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
......@@ -166,7 +164,7 @@ public class PlatRegionSettingServiceImpl extends ServiceImpl<PlatRegionSettingM
@Override
public List<PlatElderCoordinateVO> locate(PlatRegionSettingLocateDTO dto) {
List<PlatElderCoordinateVO> vos = new ArrayList<>();
List<DeviceOperationLogEntity> list = iotProductDeviceService.getDeviceLogByTimeRange(dto.getDeviceId(), "reportProperty", 10, dto.getStartTime(), dto.getEndTime());
List<DeviceOperationLogEntity> list = iotProductDeviceService.getDeviceLogByTimeRange(dto.getDeviceId(), "reportProperty", 100, dto.getStartTime(), dto.getEndTime());
for(DeviceOperationLogEntity log : list){
DeviceInfoContentSpace space = JsonUtil.toObj((String) log.getContent(), DeviceInfoContentSpace.class);
if(space.getProperties()!=null){
......@@ -179,4 +177,18 @@ public class PlatRegionSettingServiceImpl extends ServiceImpl<PlatRegionSettingM
}
return vos;
}
@Override
public PlatElderCoordinateVO nowDataLocate(PlatRegionSettingLocateDTO dto) {
PlatElderCoordinateVO vo = new PlatElderCoordinateVO();
DeviceInfoContentSpace space = iotProductDeviceService.getLastDeviceLogSpace(dto.getDeviceId(), 10);
if(space == null){
return null;
}
if(space.getProperties()!=null){
vo.setX(new BigDecimal(space.getProperties().getDistance()).multiply(new BigDecimal(Math.cos(space.getProperties().getAngle()) + "")).setScale(2, RoundingMode.HALF_UP));
vo.setY(new BigDecimal(space.getProperties().getDistance()).multiply(new BigDecimal(Math.sin(space.getProperties().getAngle()) + "")).setScale(2, RoundingMode.HALF_UP));
}
return vo;
}
}
......@@ -13,14 +13,14 @@ import com.makeit.dto.platform.space.PlatSpaceDeviceQueryDTO;
import com.makeit.dto.platform.space.PlatUnbindingDeviceDTO;
import com.makeit.entity.platform.device.PlatDevice;
import com.makeit.entity.platform.space.PlatBed;
import com.makeit.entity.platform.space.PlatRoom;
import com.makeit.entity.platform.space.PlatRoomBedDevice;
import com.makeit.entity.platform.space.PlatSpace;
import com.makeit.enums.CommonEnum;
import com.makeit.enums.platform.device.PlatDeviceEnum;
import com.makeit.mapper.platform.space.PlatRoomBedDeviceMapper;
import com.makeit.service.platform.device.PlatDeviceService;
import com.makeit.service.platform.space.PlatBedService;
import com.makeit.service.platform.space.PlatRegionSettingService;
import com.makeit.service.platform.space.PlatRoomBedDeviceService;
import com.makeit.service.platform.space.*;
import com.makeit.utils.data.convert.BeanDtoVoUtils;
import com.makeit.utils.data.convert.PageUtil;
import com.makeit.utils.data.convert.StreamUtil;
......@@ -50,6 +50,10 @@ public class PlatRoomBedDeviceServiceImpl extends ServiceImpl<PlatRoomBedDeviceM
private PlatBedService platBedService;
@Autowired
private PlatRegionSettingService platRegionSettingService;
@Autowired
private PlatRoomService platRoomService;
@Autowired
private PlatSpaceService platSpaceService;
@Override
@Transactional(rollbackFor = Exception.class)
......@@ -84,12 +88,19 @@ public class PlatRoomBedDeviceServiceImpl extends ServiceImpl<PlatRoomBedDeviceM
if (StringUtil.isNotEmpty(dto.getRoomId())) {
queryWrapper1.ne(PlatRoomBedDevice::getRoomId, dto.getRoomId());
}
if (CommonEnum.NO.getValue().equals(dto.getIsRoom())) {
if (CommonEnum.YES.getValue().equals(dto.getIsRoom())) {
queryWrapper1.isNull(PlatRoomBedDevice::getBedId);
}
List<PlatRoomBedDevice> list = list(queryWrapper1);
List<String> listEquipmentIds = list.stream().map(item -> item.getDeviceId()).collect(Collectors.toList());
String orgId = null;
if(StringUtil.isNotEmpty(dto.getRoomId())){
PlatRoom platRoom = platRoomService.getById(dto.getRoomId());
PlatSpace platSpace = platSpaceService.getById(platRoom.getSpaceId());
orgId = platSpace.getOrgId();
}
Page<PlatDevice> p = PageUtil.toMpPage(pageReqDTO);
LambdaQueryWrapper<PlatDevice> queryWrapper = new LambdaQueryWrapper<>();
......@@ -99,6 +110,7 @@ public class PlatRoomBedDeviceServiceImpl extends ServiceImpl<PlatRoomBedDeviceM
queryWrapper.like(StringUtil.isNotEmpty(dto.getName()), PlatDevice::getName, dto.getName());
queryWrapper.like(StringUtil.isNotEmpty(dto.getProductName()), PlatDevice::getProductName, dto.getProductName());
queryWrapper.eq(StringUtil.isNotEmpty(dto.getStatus()), PlatDevice::getStatus, dto.getStatus());
queryWrapper.eq(StringUtil.isNotEmpty(orgId),PlatDevice::getOrgId,orgId);
Page<PlatDevice> pages = platDeviceService.page(p, queryWrapper);
List<PlatDeviceDTO> listRecord = BeanDtoVoUtils.listVo(pages.getRecords(), PlatDeviceDTO.class);
......
......@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.makeit.dto.platform.elder.PlatElderQueryDTO;
import com.makeit.dto.platform.space.PlatBedPanoramaDTO;
import com.makeit.dto.platform.space.PlatRoomPanoramaDTO;
import com.makeit.entity.platform.auth.PlatOrg;
import com.makeit.entity.platform.elder.PlatElder;
import com.makeit.entity.platform.space.PlatBed;
import com.makeit.entity.platform.space.PlatRoom;
......@@ -12,6 +13,7 @@ import com.makeit.entity.platform.space.PlatSpace;
import com.makeit.enums.platform.space.PlatBedPanoramaSpaceType;
import com.makeit.enums.platform.space.PlatBedStatusEnum;
import com.makeit.enums.platform.space.PlatRoomStatusEnum;
import com.makeit.service.platform.auth.PlatOrgService;
import com.makeit.service.platform.elder.PlatElderService;
import com.makeit.service.platform.space.*;
import com.makeit.utils.data.convert.BeanDtoVoUtils;
......@@ -44,6 +46,8 @@ public class PlatRoomDynamicServiceImpl implements PlatRoomDynamicService {
private PlatElderService platElderService;
@Autowired
private PlatRoomBedDeviceService platRoomBedDeviceService;
@Autowired
private PlatOrgService platOrgService;
@Override
......@@ -130,8 +134,14 @@ public class PlatRoomDynamicServiceImpl implements PlatRoomDynamicService {
@Override
public List<PlatSpaceAndRoomVO> roomPanoramaTree() {
//查询用户权限组织id
List<PlatOrg> orgs = platOrgService.belongToScopeList(new PlatOrg());
if(orgs.isEmpty()){
return new ArrayList<>();
}
List<String> orgIds = orgs.stream().map(PlatOrg::getId).collect(Collectors.toList());
//获取房间前两级空间
List<PlatSpaceAndRoomVO> list = platSpaceService.spaceListExcludeLast();
List<PlatSpaceAndRoomVO> list = platSpaceService.spaceListExcludeLast(orgIds);
//父级
List<PlatSpaceAndRoomVO> listParent = list.stream().filter(item-> StringUtil.isEmpty(item.getParentId())).collect(Collectors.toList());
......@@ -149,8 +159,14 @@ public class PlatRoomDynamicServiceImpl implements PlatRoomDynamicService {
@Override
public List<PlatSpaceAndRoomVO> bedPanoramaTree() {
//查询用户权限组织id
List<PlatOrg> orgs = platOrgService.belongToScopeList(new PlatOrg());
if(orgs.isEmpty()){
return new ArrayList<>();
}
List<String> orgIds = orgs.stream().map(PlatOrg::getId).collect(Collectors.toList());
//获取空间及房间
List<PlatSpaceAndRoomVO> list = platRoomService.spaceAndRoomList();
List<PlatSpaceAndRoomVO> list = platRoomService.spaceAndRoomList(orgIds);
//父级
List<PlatSpaceAndRoomVO> listParent = list.stream().filter(item-> StringUtil.isEmpty(item.getParentId())).collect(Collectors.toList());
......
......@@ -12,6 +12,7 @@ import com.makeit.dto.platform.workstation.WorkStationQueryDTO;
import com.makeit.entity.platform.space.PlatBed;
import com.makeit.entity.platform.space.PlatRoom;
import com.makeit.enums.CodeMessageEnum;
import com.makeit.enums.CommonEnum;
import com.makeit.exception.BusinessException;
import com.makeit.mapper.platform.space.PlatRoomMapper;
import com.makeit.service.platform.space.PlatBedService;
......@@ -97,6 +98,7 @@ public class PlatRoomServiceImpl extends ServiceImpl<PlatRoomMapper, PlatRoom> i
LambdaQueryWrapper<PlatBed> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.in(PlatBed::getRoomId, ids);
queryWrapper.eq(PlatBed::getStatus, CommonEnum.NO.getValue());
if (platBedService.count(queryWrapper) > 0) {
throw new BusinessException(CodeMessageEnum.PLATFORM_ERROR_ROOM_EXIT_BAD);
}
......@@ -145,8 +147,8 @@ public class PlatRoomServiceImpl extends ServiceImpl<PlatRoomMapper, PlatRoom> i
}
@Override
public List<PlatSpaceAndRoomVO> spaceAndRoomList() {
return baseMapper.spaceAndRoomList();
public List<PlatSpaceAndRoomVO> spaceAndRoomList(List<String> orgIds) {
return baseMapper.spaceAndRoomList(orgIds);
}
@Override
......
......@@ -128,9 +128,15 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace
@Override
public List<PlatSpaceVO> tree(PlatSpaceQueryDTO dto) {
//查询用户权限组织id
List<PlatOrg> orgs = platOrgService.belongToScopeList(new PlatOrg());
if(orgs.isEmpty()){
return new ArrayList<>();
}
List<String> orgIds = orgs.stream().map(PlatOrg::getId).collect(Collectors.toList());
LambdaQueryWrapper<PlatSpace> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.like(StringUtil.isNotEmpty(dto.getName()),PlatSpace::getName,dto.getName());
queryWrapper.in(PlatSpace::getOrgId, orgIds);
List<PlatSpace> list = this.list(queryWrapper);
//父级
......@@ -157,8 +163,8 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace
}
@Override
public List<PlatSpaceAndRoomVO> spaceListExcludeLast() {
return baseMapper.spaceListExcludeLast();
public List<PlatSpaceAndRoomVO> spaceListExcludeLast(List<String> orgIds) {
return baseMapper.spaceListExcludeLast(orgIds);
}
@Override
......
......@@ -70,6 +70,16 @@ public class WorkStationServiceImpl implements WorkStationService {
List<String> orgIds = orgs.stream().map(PlatOrg::getId).collect(Collectors.toList());
dto.setOrgIds(orgIds);
}else {
//根据类型过滤数据
List<PlatOrg> platOrgs = platOrgService.list(new QueryWrapper<PlatOrg>().lambda()
.in(PlatOrg::getId, dto.getOrgIds())
.eq(PlatOrg::getType, PlatOrgEnum.OrgTypeEnum.INSTITUTION.getValue()));
if(platOrgs.isEmpty()){
return vo;
}
List<String> orgIdList = platOrgs.stream().map(PlatOrg::getId).collect(Collectors.toList());
dto.setOrgIds(orgIdList);
}
//待处理告警
long unHandledNumber = platAlarmRecordService.count(new QueryWrapper<PlatAlarmRecord>().lambda()
......@@ -259,6 +269,16 @@ public class WorkStationServiceImpl implements WorkStationService {
List<String> orgIds = orgs.stream().map(PlatOrg::getId).collect(Collectors.toList());
dto.setOrgIds(orgIds);
}else {
//根据类型过滤数据
List<PlatOrg> platOrgs = platOrgService.list(new QueryWrapper<PlatOrg>().lambda()
.in(PlatOrg::getId, dto.getOrgIds())
.eq(PlatOrg::getType, PlatOrgEnum.OrgTypeEnum.HOME.getValue()));
if(platOrgs.isEmpty()){
return vo;
}
List<String> orgIdList = platOrgs.stream().map(PlatOrg::getId).collect(Collectors.toList());
dto.setOrgIds(orgIdList);
}
//长者数
long elderNumber = platElderService.count(new QueryWrapper<PlatElder>().lambda()
......
......@@ -5,10 +5,28 @@
<mapper namespace="com.makeit.mapper.platform.space.PlatRoomMapper">
<select id="spaceAndRoomList" resultType="com.makeit.vo.platform.space.PlatSpaceAndRoomVO">
SELECT ps.id,ps.`name`,ps.parent_id as parentId,'1' as type FROM plat_space ps
WHERE ps.del_flag = 0
<where>
ps.del_flag = 0
<if test="orgIds != null and orgIds.size()>0 ">
AND ps.org_id IN
<foreach collection="orgIds" item="item" separator="," open="(" close=")" index="">
#{item}
</foreach>
</if>
</where>
UNION
SELECT pr.id,pr.`name`,pr.space_id as parentId,'2' as type FROM plat_room pr
WHERE pr.del_flag = 0
LEFT JOIN plat_space p ON p.id = pr.space_id
<where>
pr.del_flag = 0
<if test="orgIds != null and orgIds.size()>0 ">
AND p.org_id IN
<foreach collection="orgIds" item="item" separator="," open="(" close=")" index="">
#{item}
</foreach>
</if>
</where>
</select>
<select id="workStationList" resultType="com.makeit.vo.platform.workstation.WorkStationInstitutionRoomVO">
......
......@@ -5,7 +5,16 @@
<mapper namespace="com.makeit.mapper.platform.space.PlatSpaceMapper">
<select id="spaceListExcludeLast" resultType="com.makeit.vo.platform.space.PlatSpaceAndRoomVO">
SELECT ps.id,ps.`name`,ps.parent_id as parentId FROM plat_space ps
WHERE ps.id in (SELECT parent_id FROM `plat_space` WHERE del_flag =0) and ps.del_flag = 0
<where>
ps.id in (SELECT parent_id FROM `plat_space` WHERE del_flag =0) and ps.del_flag = 0
<if test="orgIds != null and orgIds.size() > 0 ">
AND ps.org_id in
<foreach collection="orgIds" item="item" separator="," open="(" close=")" index="">
#{item}
</foreach>
</if>
</where>
</select>
<select id="listChild" resultType="com.makeit.entity.platform.space.PlatSpace">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment