Commit 5b70eab3 by 杨伟程

关联工具类更新

parents 5e70e13b d9920102
Showing with 767 additions and 17 deletions
package com.makeit.controller.sys;
import com.makeit.common.response.ApiResponseEntity;
import com.makeit.common.response.ApiResponseUtils;
import com.makeit.module.system.dto.ChinaAreaDTO;
import com.makeit.module.system.entity.ChinaArea;
import com.makeit.module.system.service.ChinaAreaService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* <p>
* 省市区表 前端控制器
* </p>
*
* @author ywc
* @since 2021-06-09
*/
@Api(tags = "租户端-省市区")
@RestController
@RequestMapping("/sys/china-area")
public class SaasChinaAreaController {
@Autowired
private ChinaAreaService chinaAreaService;
@ApiOperation(value = "列表", notes = "列表")
@PostMapping("list")
public ApiResponseEntity<List<ChinaArea>> list(@RequestBody ChinaAreaDTO dto) {
return ApiResponseUtils.success(chinaAreaService.list(dto));
}
@ApiOperation(value = "树形列表", notes = "树形列表")
@PostMapping("tree")
public ApiResponseEntity<List<ChinaArea>> tree(@RequestBody ChinaAreaDTO dto) {
List<ChinaArea> list = chinaAreaService.tree(dto);
return ApiResponseUtils.success(list);
}
@ApiOperation(value = "树形列表-有深度", notes = "树形列表-有深度")
@PostMapping("treeDepth")
public ApiResponseEntity<List<ChinaArea>> treeDepth(@RequestBody ChinaAreaDTO dto) {
if (dto.getDepth() == null) {
dto.setDepth(1);
}
List<ChinaArea> list = chinaAreaService.tree(dto);
return ApiResponseUtils.success(list);
}
}
......@@ -33,8 +33,8 @@ public class PushCallback implements MqttCallback {
// 收到消息并设置返回字符串格式
String payload = new String(message.getPayload(), "UTF-8");
//logger.info("接收消息主题:{}, 接收消息QoS:{}", topic, message.getQos());
//logger.info("接收消息内容:payload格式:{}", payload);
logger.info("接收消息主题:{}, 接收消息QoS:{}", topic, message.getQos());
logger.info("接收消息内容:payload格式:{}", payload);
// 解析数据
DeviceInfo device = JSON.parseObject(payload, DeviceInfo.class);
......
package com.makeit.module.controller.space;
import com.makeit.common.response.ApiResponseEntity;
import com.makeit.common.response.ApiResponseUtils;
import com.makeit.dto.platform.space.PlatBedPanoramaDTO;
import com.makeit.dto.platform.space.PlatRoomPanoramaDTO;
import com.makeit.service.platform.space.PlatRoomDynamicService;
import com.makeit.vo.platform.space.PlatBedPanoramaVO;
import com.makeit.vo.platform.space.PlatRoomPanoramaVO;
import com.makeit.vo.platform.space.PlatSpaceAndRoomVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* Controller
*
* @author zm
* @version 2023/9/8
*/
@Api(tags = "房态管理")
@RestController
@RequestMapping("/plat/room/dynamic")
public class PlatRoomDynamicController {
@Autowired
private PlatRoomDynamicService platRoomDynamicService;
@ApiOperation("房间全景")
@PostMapping("roomPanorama")
public ApiResponseEntity<List<PlatRoomPanoramaVO>> roomPanorama(@RequestBody PlatRoomPanoramaDTO dto) {
List<PlatRoomPanoramaVO> data = platRoomDynamicService.roomPanorama(dto);
return ApiResponseUtils.success(data);
}
@ApiOperation("床位全景")
@PostMapping("bedPanorama")
public ApiResponseEntity<List<PlatBedPanoramaVO>> bedPanorama(@RequestBody PlatBedPanoramaDTO dto) {
List<PlatBedPanoramaVO> data = platRoomDynamicService.bedPanorama(dto);
return ApiResponseUtils.success(data);
}
@ApiOperation("房间全景-下拉空间树")
@PostMapping("roomPanoramaTree")
public ApiResponseEntity<List<PlatSpaceAndRoomVO>> roomPanoramaTree() {
List<PlatSpaceAndRoomVO> data = platRoomDynamicService.roomPanoramaTree();
return ApiResponseUtils.success(data);
}
@ApiOperation("床位全景-下拉空间树")
@PostMapping("bedPanoramaTree")
public ApiResponseEntity<List<PlatSpaceAndRoomVO>> bedPanoramaTree() {
List<PlatSpaceAndRoomVO> data = platRoomDynamicService.bedPanoramaTree();
return ApiResponseUtils.success(data);
}
}
package com.makeit.dto.platform.space;
import com.makeit.enums.platform.space.PlatBedStatusEnum;
import com.makeit.enums.platform.space.PlatSpaceEnum;
import com.makeit.global.validator.DictEnum;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* Controller
*
* @author zm
* @version 2023/9/8
*/
@Data
@ApiModel("PlatBedPanoramaDTO参数")
public class PlatBedPanoramaDTO {
@ApiModelProperty("空间/房间id")
private String id;
@ApiModelProperty("类型 1-空间 2-房间")
private String type;
@DictEnum(em = PlatBedStatusEnum.BedStatusEnum.class, message = "状态可选值为{m}")
@ApiModelProperty("状态 1-空闲 2-已入住")
private String status;
}
package com.makeit.dto.platform.space;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* Controller
*
* @author zm
* @version 2023/9/8
*/
@Data
@ApiModel("PlatRoomPanoramaDTO参数")
public class PlatRoomPanoramaDTO {
@ApiModelProperty("空间id")
private String id;
}
package com.makeit.enums.platform.space;
import com.makeit.enums.BaseEnum;
import com.makeit.utils.sys.SysDictUtil;
/**
* Controller
*
* @author zm
* @version 2023/9/8
*/
public class PlatBedPanoramaSpaceType {
public enum BedPanoramaSpaceType implements BaseEnum {
SPACE("bedPanorama.space.type.space"),
ROOM("bedPanorama.space.type.room");
private String code;
BedPanoramaSpaceType(String code) {
this.code = code;
}
@Override
public String getValue() {
return SysDictUtil.getValue(code);
}
}
}
package com.makeit.enums.platform.space;
import com.makeit.enums.BaseEnum;
import com.makeit.utils.sys.SysDictUtil;
/**
* Controller
*
* @author zm
* @version 2023/9/8
*/
public class PlatBedStatusEnum {
public enum BedStatusEnum implements BaseEnum {
//SPARE 空闲
//NOT_FULL 未住满
//FULL 已住满
SPARE("room.status.spare"),
CHECKED_IN("bed.status.CheckedIn");
private String code;
BedStatusEnum(String code) {
this.code = code;
}
@Override
public String getValue() {
return SysDictUtil.getValue(code);
}
}
}
package com.makeit.enums.platform.space;
import com.makeit.enums.BaseEnum;
import com.makeit.utils.sys.SysDictUtil;
/**
* Controller
*
* @author zm
* @version 2023/9/8
*/
public class PlatRoomStatusEnum {
public enum RoomStatusEnum implements BaseEnum {
//SPARE 空闲
//NOT_FULL 未住满
//FULL 已住满
SPARE("room.status.spare"),
NOT_FULL("room.status.notFull"),
FULL("room.status.full");
private String code;
RoomStatusEnum(String code) {
this.code = code;
}
@Override
public String getValue() {
return SysDictUtil.getValue(code);
}
}
}
package com.makeit.mapper.platform.space;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.makeit.dto.platform.space.PlatBedPanoramaDTO;
import com.makeit.entity.platform.space.PlatBed;
import com.makeit.vo.platform.space.PlatBedPanoramaVO;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* @Author:lzy
......@@ -9,4 +14,7 @@ import com.makeit.entity.platform.space.PlatBed;
* @Describe:
*/
public interface PlatBedMapper extends BaseMapper<PlatBed> {
List<PlatBedPanoramaVO> selectBySpaceIdAndStatus(@Param("dto") PlatBedPanoramaDTO dto);
List<PlatBedPanoramaVO> selectByRoomIdAndStatus(@Param("dto")PlatBedPanoramaDTO dto);
}
package com.makeit.mapper.platform.space;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.makeit.dto.platform.space.PlatSpaceQueryDTO;
import com.makeit.entity.platform.space.PlatRoom;
import com.makeit.vo.platform.space.PlatRoomVO;
import com.makeit.vo.platform.space.PlatSpaceAndRoomVO;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* @Author:lzy
......@@ -9,4 +15,5 @@ import com.makeit.entity.platform.space.PlatRoom;
* @Describe:
*/
public interface PlatRoomMapper extends BaseMapper<PlatRoom> {
List<PlatSpaceAndRoomVO> spaceAndRoomList();
}
package com.makeit.mapper.platform.space;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.makeit.dto.platform.space.PlatSpaceQueryDTO;
import com.makeit.entity.platform.space.PlatSpace;
import com.makeit.vo.platform.space.PlatSpaceAndRoomVO;
import java.util.List;
/**
* @Author:lzy
......@@ -9,4 +13,6 @@ import com.makeit.entity.platform.space.PlatSpace;
* @Describe:
*/
public interface PlatSpaceMapper extends BaseMapper<PlatSpace> {
List<PlatSpaceAndRoomVO> spaceListExcludeLast();
}
......@@ -787,8 +787,8 @@ public class PlatUserServiceImpl extends ServiceImpl<PlatUserMapper, PlatUser>
user.setAccount(dto.getMobile());
PlatOrg platOrg = platOrgService.getById(dto.getId());
user.setOrgPath(platOrg.getPath()+","+platOrg.getId());
fillOrgPath(dto, user);
save(user);
dto.setId(user.getId());
setRoleList(dto);
......@@ -796,6 +796,13 @@ public class PlatUserServiceImpl extends ServiceImpl<PlatUserMapper, PlatUser>
return user.getId();
}
private void fillOrgPath(PlatPersonDTOVO dto, PlatUser user) {
PlatOrg platOrg = platOrgService.getById(dto.getId());
if(platOrg!=null) {
user.setOrgPath(platOrg.getPath() + "," + platOrg.getId());
}
}
@Transactional
@Override
......@@ -807,8 +814,8 @@ public class PlatUserServiceImpl extends ServiceImpl<PlatUserMapper, PlatUser>
setPassword(user);
PlatOrg platOrg = platOrgService.getById(dto.getId());
user.setOrgPath(platOrg.getPath()+","+platOrg.getId());
fillOrgPath(dto, user);
updateById(user);
setRoleList(dto);
}
......
......@@ -8,6 +8,7 @@ import com.makeit.dto.platform.device.PlatDeviceDTO;
import com.makeit.dto.platform.space.*;
import com.makeit.entity.platform.space.PlatBed;
import com.makeit.entity.platform.space.PlatRoom;
import com.makeit.vo.platform.space.PlatBedPanoramaVO;
import java.util.List;
......@@ -53,4 +54,7 @@ public interface PlatBedService extends IService<PlatBed> {
void changeStatus(StatusDTO dto);
List<PlatBedPanoramaVO> selectBySpaceIdAndStatus(PlatBedPanoramaDTO dto);
List<PlatBedPanoramaVO> selectByRoomIdAndStatus(PlatBedPanoramaDTO dto);
}
package com.makeit.service.platform.space;
import com.makeit.dto.platform.space.PlatBedPanoramaDTO;
import com.makeit.dto.platform.space.PlatRoomPanoramaDTO;
import com.makeit.vo.platform.space.PlatBedPanoramaVO;
import com.makeit.vo.platform.space.PlatRoomPanoramaVO;
import com.makeit.vo.platform.space.PlatSpaceAndRoomVO;
import java.util.List;
/**
* Controller
*
* @author zm
* @version 2023/9/8
*/
public interface PlatRoomDynamicService {
List<PlatRoomPanoramaVO> roomPanorama(PlatRoomPanoramaDTO dto);
List<PlatBedPanoramaVO> bedPanorama(PlatBedPanoramaDTO dto);
List<PlatSpaceAndRoomVO> roomPanoramaTree();
List<PlatSpaceAndRoomVO> bedPanoramaTree();
}
......@@ -6,7 +6,9 @@ import com.makeit.common.page.PageVO;
import com.makeit.dto.platform.elder.PlatElderQueryDTO;
import com.makeit.dto.platform.space.PlatRoomDTO;
import com.makeit.dto.platform.space.PlatRoomQueryDTO;
import com.makeit.dto.platform.space.PlatSpaceQueryDTO;
import com.makeit.entity.platform.space.PlatRoom;
import com.makeit.vo.platform.space.PlatSpaceAndRoomVO;
import java.util.List;
......@@ -57,4 +59,6 @@ public interface PlatRoomService extends IService<PlatRoom> {
* @return
*/
PageVO<PlatRoom> page(PageReqDTO<PlatRoomQueryDTO> page);
List<PlatSpaceAndRoomVO> spaceAndRoomList();
}
......@@ -5,6 +5,7 @@ import com.makeit.dto.platform.space.PlatSpaceAddDTO;
import com.makeit.dto.platform.space.PlatSpaceQueryDTO;
import com.makeit.dto.platform.space.PlatSpaceVO;
import com.makeit.entity.platform.space.PlatSpace;
import com.makeit.vo.platform.space.PlatSpaceAndRoomVO;
import java.util.List;
......@@ -46,4 +47,6 @@ public interface PlatSpaceService extends IService<PlatSpace> {
* @return
*/
PlatSpaceAddDTO view(String id);
List<PlatSpaceAndRoomVO> spaceListExcludeLast();
}
......@@ -22,6 +22,7 @@ import com.makeit.service.platform.space.PlatBedService;
import com.makeit.service.platform.space.PlatRoomBedDeviceService;
import com.makeit.utils.data.convert.BeanDtoVoUtils;
import com.makeit.utils.data.convert.PageUtil;
import com.makeit.vo.platform.space.PlatBedPanoramaVO;
import jodd.util.StringUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
......@@ -146,5 +147,15 @@ public class PlatBedServiceImpl extends ServiceImpl<PlatBedMapper, PlatBed> impl
updateById(bed);
}
@Override
public List<PlatBedPanoramaVO> selectBySpaceIdAndStatus(PlatBedPanoramaDTO dto) {
return baseMapper.selectBySpaceIdAndStatus(dto);
}
@Override
public List<PlatBedPanoramaVO> selectByRoomIdAndStatus(PlatBedPanoramaDTO dto) {
return baseMapper.selectByRoomIdAndStatus(dto);
}
}
package com.makeit.service.platform.space.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.makeit.dto.platform.space.PlatBedPanoramaDTO;
import com.makeit.dto.platform.space.PlatRoomPanoramaDTO;
import com.makeit.entity.platform.space.PlatBed;
import com.makeit.entity.platform.space.PlatRoom;
import com.makeit.entity.platform.space.PlatSpace;
import com.makeit.enums.platform.space.PlatBedPanoramaSpaceType;
import com.makeit.enums.platform.space.PlatRoomStatusEnum;
import com.makeit.mapper.platform.space.PlatBedMapper;
import com.makeit.mapper.platform.space.PlatRoomMapper;
import com.makeit.mapper.platform.space.PlatSpaceMapper;
import com.makeit.service.platform.space.PlatBedService;
import com.makeit.service.platform.space.PlatRoomDynamicService;
import com.makeit.service.platform.space.PlatRoomService;
import com.makeit.service.platform.space.PlatSpaceService;
import com.makeit.vo.platform.space.PlatBedPanoramaVO;
import com.makeit.vo.platform.space.PlatRoomPanoramaVO;
import com.makeit.vo.platform.space.PlatRoomVO;
import com.makeit.vo.platform.space.PlatSpaceAndRoomVO;
import jodd.util.StringUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* Controller
*
* @author zm
* @version 2023/9/8
*/
@Service
public class PlatRoomDynamicServiceImpl implements PlatRoomDynamicService {
@Autowired
private PlatSpaceService platSpaceService;
@Autowired
private PlatRoomService platRoomService;
@Autowired
private PlatBedService platBedService;
@Override
public List<PlatRoomPanoramaVO> roomPanorama(PlatRoomPanoramaDTO dto) {
List<PlatRoomPanoramaVO> list = new ArrayList<>();
//获取下级空间
List<PlatSpace> spaces = platSpaceService.list(new QueryWrapper<PlatSpace>().lambda()
.eq(PlatSpace::getParentId,dto.getId()));
if(!spaces.isEmpty()){
List<String> spaceIds = spaces.stream().map(PlatSpace::getId).collect(Collectors.toList());
//空间下的房间
List<PlatRoom> rooms = platRoomService.list(new QueryWrapper<PlatRoom>().lambda()
.in(PlatRoom::getSpaceId,spaceIds));
List<String> roomIds = rooms.stream().map(PlatRoom::getId).collect(Collectors.toList());
List<PlatBed> beds = platBedService.list(new QueryWrapper<PlatBed>().lambda()
.in(PlatBed::getRoomId,roomIds));
Map<String,List<PlatBed>> bedMap = beds.stream().collect(Collectors.groupingBy(PlatBed::getRoomId));
for(PlatSpace space : spaces){
PlatRoomPanoramaVO platRoomPanoramaVO = new PlatRoomPanoramaVO();
platRoomPanoramaVO.setSpaceName(space.getName());
platRoomPanoramaVO.setSpaceId(dto.getId());
List<PlatRoomVO> roomVOList = new ArrayList<>();
for(PlatRoom room : rooms){
PlatRoomVO vo = convertToVO(room,bedMap);
roomVOList.add(vo);
}
platRoomPanoramaVO.setList(roomVOList);
list.add(platRoomPanoramaVO);
}
}
return list;
}
private PlatRoomVO convertToVO(PlatRoom room, Map<String, List<PlatBed>> bedMap) {
PlatRoomVO vo = new PlatRoomVO();
vo.setBedNumber(room.getBedNumber());
vo.setRoomName(room.getName());
vo.setRoomId(room.getId());
if(bedMap.get(room.getId())!=null){
vo.setUsedTotal(bedMap.get(room.getId()).size());
}else {
vo.setUsedTotal(0);
}
if(vo.getUsedTotal()==0){
vo.setRoomStatus(PlatRoomStatusEnum.RoomStatusEnum.SPARE.getValue());
}else if(vo.getUsedTotal() < vo.getBedNumber()){
vo.setRoomStatus(PlatRoomStatusEnum.RoomStatusEnum.NOT_FULL.getValue());
}else {
vo.setRoomStatus(PlatRoomStatusEnum.RoomStatusEnum.FULL.getValue());
}
return vo;
}
@Override
public List<PlatBedPanoramaVO> bedPanorama(PlatBedPanoramaDTO dto) {
List<PlatBedPanoramaVO> list = new ArrayList<>();
if(PlatBedPanoramaSpaceType.BedPanoramaSpaceType.SPACE.getValue().equals(dto.getType())){
list = platBedService.selectBySpaceIdAndStatus(dto);
}else if(PlatBedPanoramaSpaceType.BedPanoramaSpaceType.ROOM.getValue().equals(dto.getType())){
list = platBedService.selectByRoomIdAndStatus(dto);
}
List<PlatSpace> spaces = platSpaceService.list();
Map<String,String> spaceNameMap = spaces.stream().collect(Collectors.toMap(PlatSpace::getId,PlatSpace::getName));
list.forEach(vo->{
String spacePathName = "";
if(StringUtil.isNotEmpty(vo.getSpacePath())){
List<String> spaceIds = Arrays.asList(vo.getSpacePath().split(","));
for(String spaceId : spaceIds){
if(spaceNameMap.get(spaceId)!=null && StringUtil.isNotEmpty(spaceNameMap.get(spaceId))){
spacePathName = "".equals(spacePathName) ? spaceNameMap.get(spaceId) : spacePathName + "-" + spaceNameMap.get(spaceId);
}
}
}
if(StringUtil.isNotEmpty(vo.getRoomName())){
spacePathName = "".equals(spacePathName) ? vo.getRoomName() : spacePathName + "-" + vo.getRoomName();
}
if(StringUtil.isNotEmpty(vo.getBedName())){
spacePathName = "".equals(spacePathName) ? vo.getBedName() : spacePathName + "-" + vo.getBedName();
}
vo.setSpacePathName(spacePathName);
});
return list;
}
@Override
public List<PlatSpaceAndRoomVO> roomPanoramaTree() {
//获取房间前两级空间
List<PlatSpaceAndRoomVO> list = platSpaceService.spaceListExcludeLast();
//父级
List<PlatSpaceAndRoomVO> listParent = list.stream().filter(item-> StringUtil.isEmpty(item.getParentId())).collect(Collectors.toList());
//子集
List<PlatSpaceAndRoomVO> listChild = list.stream().filter(item->item.getParentId() != null).collect(Collectors.toList());
Map<String,List<PlatSpaceAndRoomVO>> map = listChild.stream().collect(Collectors.groupingBy(PlatSpaceAndRoomVO::getParentId));
List<PlatSpaceAndRoomVO> data = new ArrayList<>();
for(PlatSpaceAndRoomVO space:listParent){
space = child(space,map);
data.add(space);
}
return data;
}
@Override
public List<PlatSpaceAndRoomVO> bedPanoramaTree() {
//获取空间及房间
List<PlatSpaceAndRoomVO> list = platRoomService.spaceAndRoomList();
//父级
List<PlatSpaceAndRoomVO> listParent = list.stream().filter(item-> StringUtil.isEmpty(item.getParentId())).collect(Collectors.toList());
//子集
List<PlatSpaceAndRoomVO> listChild = list.stream().filter(item->item.getParentId() != null).collect(Collectors.toList());
Map<String,List<PlatSpaceAndRoomVO>> map = listChild.stream().collect(Collectors.groupingBy(PlatSpaceAndRoomVO::getParentId));
List<PlatSpaceAndRoomVO> data = new ArrayList<>();
for(PlatSpaceAndRoomVO space:listParent){
space = child(space,map);
data.add(space);
}
return data;
}
private PlatSpaceAndRoomVO child(PlatSpaceAndRoomVO vo,Map<String,List<PlatSpaceAndRoomVO>> map){
if(!map.containsKey(vo.getId())){
return vo;
}
List<PlatSpaceAndRoomVO> list = map.get(vo.getId());
List<PlatSpaceAndRoomVO> listChild = new ArrayList<>();
for(PlatSpaceAndRoomVO item:list){
this.child(item,map);
listChild.add(item);
}
vo.setChild(listChild);
return vo;
}
}
......@@ -17,6 +17,7 @@ import com.makeit.service.platform.space.PlatBedService;
import com.makeit.service.platform.space.PlatRoomService;
import com.makeit.utils.data.convert.BeanDtoVoUtils;
import com.makeit.utils.data.convert.PageUtil;
import com.makeit.vo.platform.space.PlatSpaceAndRoomVO;
import jodd.util.StringUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
......@@ -123,5 +124,10 @@ public class PlatRoomServiceImpl extends ServiceImpl<PlatRoomMapper, PlatRoom> i
return PageUtil.toPageVO(pages.getRecords(), pages);
}
@Override
public List<PlatSpaceAndRoomVO> spaceAndRoomList() {
return baseMapper.spaceAndRoomList();
}
}
......@@ -13,6 +13,7 @@ import com.makeit.mapper.platform.space.PlatSpaceMapper;
import com.makeit.service.platform.space.PlatRoomService;
import com.makeit.service.platform.space.PlatSpaceService;
import com.makeit.utils.data.convert.BeanDtoVoUtils;
import com.makeit.vo.platform.space.PlatSpaceAndRoomVO;
import jodd.util.StringUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
......@@ -124,6 +125,11 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace
return data;
}
@Override
public List<PlatSpaceAndRoomVO> spaceListExcludeLast() {
return baseMapper.spaceListExcludeLast();
}
private PlatSpaceVO child(PlatSpaceVO vo,Map<String,List<PlatSpace>> map){
if(!map.containsKey(vo.getId())){
......
......@@ -8,6 +8,8 @@ import com.makeit.enums.CommonEnum;
import com.makeit.global.aspect.tenant.TenantIdIgnore;
import com.makeit.module.iot.service.IotOrgService;
import com.makeit.module.iot.vo.DeviceInstanceEntity;
import com.makeit.module.system.service.SysDictionaryCategoryService;
import com.makeit.module.system.vo.DictionaryVo;
import com.makeit.service.platform.device.PlatDeviceService;
import com.makeit.service.saas.PlatTenantService;
import lombok.extern.slf4j.Slf4j;
......@@ -35,6 +37,8 @@ public class IotSyncTask {
private PlatTenantService platTenantService;
@Autowired
private PlatDeviceService platDeviceService;
@Autowired
private SysDictionaryCategoryService sysDictionaryCategoryService;
/**
* 一小时同步一次
......@@ -47,14 +51,18 @@ public class IotSyncTask {
log.info("开始执行同步设备信息接口");
LambdaQueryWrapper<PlatTenant> tenantLambdaQueryWrapper = new LambdaQueryWrapper<PlatTenant>().eq(PlatTenant::getStatus, CommonEnum.YES.getValue());
List<PlatTenant> platTenants = platTenantService.list(tenantLambdaQueryWrapper);
List<DictionaryVo> dictionaryVos = sysDictionaryCategoryService.getByCategoryCode("device.category");
Map<String, String> dicNameIdMap = dictionaryVos.stream().collect(Collectors.toMap(DictionaryVo::getName, DictionaryVo::getValue, (v1, v2) -> v1));
for (PlatTenant platTenant : platTenants) {
String iotOrgId = platTenant.getIotOrgId();
if(StringUtils.isBlank(iotOrgId)){
if (StringUtils.isBlank(iotOrgId)) {
continue;
}
//查询iot设备
List<DeviceInstanceEntity> iotDeviceList = iotOrgService.getOrgDevice(iotOrgId);
if(CollectionUtils.isEmpty(iotDeviceList)){
if (CollectionUtils.isEmpty(iotDeviceList)) {
continue;
}
//查询平台设备
......@@ -63,7 +71,7 @@ public class IotSyncTask {
.in(PlatDevice::getOriDeviceId, iotDeviceIdSet);
List<PlatDevice> deviceList = platDeviceService.list(deviceLambdaQueryWrapper);
//更新平台设备
Collection<PlatDevice> platDevices = convertToPlatDevice(iotDeviceList, deviceList,platTenant.getId());
Collection<PlatDevice> platDevices = convertToPlatDevice(iotDeviceList, deviceList, platTenant.getId(), dicNameIdMap);
platDeviceService.saveOrUpdateBatch(platDevices);
}
......@@ -80,28 +88,28 @@ public class IotSyncTask {
}
private Collection<PlatDevice> convertToPlatDevice(List<DeviceInstanceEntity> iotDeviceList, List<PlatDevice> deviceList,String tenantId){
private Collection<PlatDevice> convertToPlatDevice(List<DeviceInstanceEntity> iotDeviceList, List<PlatDevice> deviceList, String tenantId, Map<String, String> dicNameIdMap) {
Map<String, PlatDevice> deviceMap = deviceList.stream().collect(Collectors.toMap(PlatDevice::getOriDeviceId, v -> v, (a, b) -> a));
iotDeviceList.forEach(iotDevice->{
iotDeviceList.forEach(iotDevice -> {
PlatDevice platDevice = deviceMap.get(iotDevice.getId());
if(platDevice==null){
platDevice=new PlatDevice();
if (platDevice == null) {
platDevice = new PlatDevice();
platDevice.setTenantId(tenantId);
deviceMap.put(iotDevice.getId(),platDevice);
deviceMap.put(iotDevice.getId(), platDevice);
}
platDevice.setOriDeviceId(iotDevice.getId());
platDevice.setName(iotDevice.getName());
platDevice.setProductName(iotDevice.getProductName());
platDevice.setProductId(iotDevice.getProductId());
LocalDateTime registryTime = LocalDateTime.ofEpochSecond(iotDevice.getRegistryTime()/1000, 0, ZoneOffset.ofHours(8));
LocalDateTime registryTime = LocalDateTime.ofEpochSecond(iotDevice.getRegistryTime() / 1000, 0, ZoneOffset.ofHours(8));
platDevice.setRegistrationDate(registryTime);
platDevice.setDescription(iotDevice.getDescribe());
String state = iotDevice.getState();
platDevice.setStatus(StringUtils.equals("online",state)?CommonEnum.YES.getValue() : CommonEnum.NO.getValue());
platDevice.setStatus(StringUtils.equals("online", state) ? CommonEnum.YES.getValue() : CommonEnum.NO.getValue());
//todo 根据类型名称来匹配
// platDevice.setCategory();
platDevice.setCategory(dicNameIdMap.get(iotDevice.getProductName()));
// platDevice.setFirmwareVersion();
// platDevice.setLastOnlineData();
// platDevice.setOrgId();
......
......@@ -40,6 +40,8 @@ public class PlatPersonDTOVO extends BaseIdDTO {
@ApiModelProperty(value = "手机号")
private String mobile;
private String email;
@NotBlank(message = "状态不能为空")
@Pattern(regexp = "0|1", message = "状态可选值为 0禁用 1启用")
@ApiModelProperty(value = "状态 0禁用 1启用")
......
package com.makeit.vo.platform.space;
import com.makeit.common.dto.BaseIdDTO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* Controller
*
* @author zm
* @version 2023/9/8
*/
@Data
@ApiModel("PlatBedPanoramaVO参数")
public class PlatBedPanoramaVO extends BaseIdDTO {
@ApiModelProperty("空间全路径id")
private String spacePath;
@ApiModelProperty("全路径名称")
private String spacePathName;
@ApiModelProperty("房间名称")
private String roomName;
@ApiModelProperty("床位名称")
private String bedName;
@ApiModelProperty("是否空闲 1 是 0 否")
private String status;
@ApiModelProperty("长者id")
private String elderId;
@ApiModelProperty("长者姓名")
private String elderName;
}
package com.makeit.vo.platform.space;
import com.makeit.common.dto.BaseIdDTO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
/**
* Controller
*
* @author zm
* @version 2023/9/6
*/
@Data
@ApiModel("PlatRoomPanoramaVO参数")
public class PlatRoomPanoramaVO{
@ApiModelProperty("空间名称")
private String spaceName;
@ApiModelProperty("空间id")
private String spaceId;
private List<PlatRoomVO> list;
}
package com.makeit.vo.platform.space;
import com.makeit.common.dto.BaseIdDTO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* Controller
*
* @author zm
* @version 2023/9/8
*/
@Data
@ApiModel("PlatRoomVO参数")
public class PlatRoomVO {
@ApiModelProperty("房间名称")
private String roomName;
@ApiModelProperty("房间床位总数")
private Integer bedNumber;
@ApiModelProperty("房间id")
private String roomId;
@ApiModelProperty("房间床位使用数")
private Integer usedTotal;
@ApiModelProperty("状态")
private String roomStatus;
}
package com.makeit.vo.platform.space;
import com.makeit.common.dto.BaseIdDTO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
/**
* Controller
*
* @author zm
* @version 2023/9/6
*/
@Data
@ApiModel("PlatSpaceVO参数")
public class PlatSpaceAndRoomVO extends BaseIdDTO {
@ApiModelProperty("名称")
private String name;
@ApiModelProperty("父级Id")
private String parentId;
@ApiModelProperty("类型 0-空间 1-房间")
private String type;
@ApiModelProperty("子集")
private List<PlatSpaceAndRoomVO> child;
}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.makeit.mapper.platform.space.PlatBedMapper">
<select id="selectBySpaceIdAndStatus" resultType="com.makeit.vo.platform.space.PlatBedPanoramaVO">
SELECT pb.id,pb.`status`,pb.name bedName ,pm.`name` roomName,pm.space_path,pe.name as elderName,pe.id as elderId
FROM `plat_bed` pb
LEFT JOIN plat_room pm on pb.room_id = pm.id
LEFT JOIN plat_elder pe on pe.bed_id = pb.id
<where>
pb.del_flag = 0
<if test="dto.id != null and dto.id != ''">
AND FIND_IN_SET(#{dto.id},pm.space_path)
</if>
<if test="dto.status != null and dto.status != ''">
AND pb.statue = #{dto.status}
</if>
</where>
</select>
<select id="selectByRoomIdAndStatus" resultType="com.makeit.vo.platform.space.PlatBedPanoramaVO">
SELECT pb.id,pb.`status`,pb.name bedName ,pm.`name` roomName,pm.space_path,pe.name as elderName,pe.id as elderId
FROM `plat_bed` pb
LEFT JOIN plat_room pm on pb.room_id = pm.id
LEFT JOIN plat_elder pe on pe.bed_id = pb.id
<where>
pb.del_flag = 0
AND pm.id = #{dto.id}
<if test="dto.status != null and dto.status != ''">
AND pb.statue = #{dto.status}
</if>
</where>
</select>
</mapper>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<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,'0' as type FROM plat_space ps
WHERE ps.del_flag = 0
UNION
SELECT pr.id,pr.`name`,pr.space_id as parentId,'1' as type FROM plat_room pr
WHERE pr.del_flag = 0
</select>
</mapper>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<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
</select>
</mapper>
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