Commit ea37bf56 by 朱淼

fixbug

parent 76f759b4
...@@ -97,7 +97,7 @@ public class PlatSpaceController { ...@@ -97,7 +97,7 @@ public class PlatSpaceController {
@ApiOperation(value = "导出模板") @ApiOperation(value = "导出模板")
@PostMapping("/exportTemplate") @PostMapping("/exportTemplate")
public void exportTemplate(HttpServletResponse response) { public void exportTemplate(HttpServletResponse response) {
ExcelUtil.exportTemplate(response, "空间导入模板" + FileSuffixEnum.EXCEL.getSuffix(), PlatSpaceImportDTO.class); ExcelUtil.exportTemplate(response, "空间导入模板" + FileSuffixEnum.EXCEL.getSuffix(), "空间导入模板", PlatSpaceImportDTO.class);
} }
......
...@@ -4,6 +4,8 @@ import io.swagger.annotations.ApiModel; ...@@ -4,6 +4,8 @@ import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import java.util.List;
/** /**
* Controller * Controller
* *
...@@ -15,4 +17,7 @@ import lombok.Data; ...@@ -15,4 +17,7 @@ import lombok.Data;
public class PlatOrgDTO { public class PlatOrgDTO {
@ApiModelProperty(value = "类型 1-居家 2-机构") @ApiModelProperty(value = "类型 1-居家 2-机构")
private String type; private String type;
@ApiModelProperty(value = "组织ids")
private List<String> orgIds;
} }
...@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; ...@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.makeit.dto.platform.space.PlatRegionSettingDTO; import com.makeit.dto.platform.space.PlatRegionSettingDTO;
import com.makeit.dto.platform.space.PlatRegionSettingLocateDTO; import com.makeit.dto.platform.space.PlatRegionSettingLocateDTO;
import com.makeit.dto.platform.space.PlatRegionSettingQueryDTO; import com.makeit.dto.platform.space.PlatRegionSettingQueryDTO;
import com.makeit.dto.wechat.device.PlatDeviceAttrWechatDTO;
import com.makeit.entity.platform.device.PlatDevice; import com.makeit.entity.platform.device.PlatDevice;
import com.makeit.entity.platform.device.PlatDeviceOther; import com.makeit.entity.platform.device.PlatDeviceOther;
import com.makeit.entity.platform.space.PlatRegionSetting; import com.makeit.entity.platform.space.PlatRegionSetting;
...@@ -66,7 +67,7 @@ public class PlatRegionSettingServiceImpl extends ServiceImpl<PlatRegionSettingM ...@@ -66,7 +67,7 @@ public class PlatRegionSettingServiceImpl extends ServiceImpl<PlatRegionSettingM
.in(PlatDeviceOther::getDeviceId,listDeviceId)); .in(PlatDeviceOther::getDeviceId,listDeviceId));
} }
Map<String,String> map = platDeviceOthers.stream().collect(Collectors.toMap(PlatDeviceOther::getDeviceId,PlatDeviceOther::getInstallation)); Map<String,String> map = platDeviceOthers.stream().collect(Collectors.toMap(PlatDeviceOther::getDeviceId,PlatDeviceOther::getAttribute));
List<PlatRegionSetting> list = new ArrayList<>(); List<PlatRegionSetting> list = new ArrayList<>();
listDeviceId.forEach(item->{ listDeviceId.forEach(item->{
...@@ -74,7 +75,9 @@ public class PlatRegionSettingServiceImpl extends ServiceImpl<PlatRegionSettingM ...@@ -74,7 +75,9 @@ public class PlatRegionSettingServiceImpl extends ServiceImpl<PlatRegionSettingM
platRegionSetting.setDeviceId(item); platRegionSetting.setDeviceId(item);
platRegionSetting.setRoomId(roomId); platRegionSetting.setRoomId(roomId);
if(map.get(item)!=null){ if(map.get(item)!=null){
platRegionSetting.setInstallType(map.get(item)); String attribute = map.get(item);
PlatDeviceAttrWechatDTO deviceAttrWechatDTO = JsonUtil.toObj(attribute,PlatDeviceAttrWechatDTO.class);
platRegionSetting.setInstallType(deviceAttrWechatDTO.getRadarMount()+"");
} }
list.add(platRegionSetting); list.add(platRegionSetting);
}); });
......
...@@ -387,6 +387,7 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace ...@@ -387,6 +387,7 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace
List<PlatRoom> rooms = platRoomService.list(); List<PlatRoom> rooms = platRoomService.list();
Map<String,List<PlatRoom>> roomMap = rooms.stream().collect(Collectors.groupingBy(PlatRoom::getSpaceId)); Map<String,List<PlatRoom>> roomMap = rooms.stream().collect(Collectors.groupingBy(PlatRoom::getSpaceId));
List<String> lastSpaceIds = rooms.stream().filter(t->StringUtil.isNotEmpty(t.getSpaceId())).map(PlatRoom::getSpaceId).collect(Collectors.toList());
List<PlatSpaceImportDTO> list = ExcelUtil.importExcel(null, 3, excelFile, PlatSpaceImportDTO.class); List<PlatSpaceImportDTO> list = ExcelUtil.importExcel(null, 3, excelFile, PlatSpaceImportDTO.class);
...@@ -454,6 +455,7 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace ...@@ -454,6 +455,7 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace
if (errorVoList.isEmpty()) { if (errorVoList.isEmpty()) {
for (int i = 0; i < list.size(); i++) { for (int i = 0; i < list.size(); i++) {
boolean flag = false;
PlatSpaceImportDTO item = list.get(i); PlatSpaceImportDTO item = list.get(i);
...@@ -474,10 +476,19 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace ...@@ -474,10 +476,19 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace
spacePath = firstId; spacePath = firstId;
} }
if(lastSpaceIds.contains(firstId)){
flag = true;
}
//第二层级 //第二层级
String secondId = null; String secondId = null;
if (StringUtil.isNotEmpty(item.getBuilding())) { if (StringUtil.isNotEmpty(item.getBuilding())) {
if(flag){
errorVoList.add(new ExcelErrorVo(i + 3, excelField.get(0), "该空间下存在房间,不允许添加下级空间"));
successCount--;
errorCount++;
continue;
}
String secondKey = firstId + "-" + item.getBuilding(); String secondKey = firstId + "-" + item.getBuilding();
if (!childrenIdMap.containsKey(secondKey)) { if (!childrenIdMap.containsKey(secondKey)) {
PlatSpace platSpace = new PlatSpace(); PlatSpace platSpace = new PlatSpace();
...@@ -493,12 +504,20 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace ...@@ -493,12 +504,20 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace
secondId = childrenIdMap.get(secondKey); secondId = childrenIdMap.get(secondKey);
} }
spacePath = spacePath + "," + secondId; spacePath = spacePath + "," + secondId;
if(lastSpaceIds.contains(secondId)){
flag = true;
}
} }
//第三级 //第三级
String threeId = null; String threeId = null;
if (StringUtil.isNotEmpty(item.getUnit())) { if (StringUtil.isNotEmpty(item.getUnit())) {
if(flag){
errorVoList.add(new ExcelErrorVo(i + 3, excelField.get(1), "该空间下存在房间,不允许添加下级空间"));
successCount--;
errorCount++;
continue;
}
String threeKey = secondId + "-" + item.getUnit(); String threeKey = secondId + "-" + item.getUnit();
if (!childrenIdMap.containsKey(threeKey)) { if (!childrenIdMap.containsKey(threeKey)) {
PlatSpace platSpace = new PlatSpace(); PlatSpace platSpace = new PlatSpace();
...@@ -514,12 +533,20 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace ...@@ -514,12 +533,20 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace
threeId = childrenIdMap.get(threeKey); threeId = childrenIdMap.get(threeKey);
} }
spacePath = spacePath + "," + threeId; spacePath = spacePath + "," + threeId;
if(lastSpaceIds.contains(secondId)){
flag = true;
}
} }
//第四级 //第四级
String fourId = null; String fourId = null;
if (StringUtil.isNotEmpty(item.getFloor())) { if (StringUtil.isNotEmpty(item.getFloor())) {
if(flag){
errorVoList.add(new ExcelErrorVo(i + 3, excelField.get(2), "该空间下存在房间,不允许添加下级空间"));
successCount--;
errorCount++;
continue;
}
String fourKey = threeId + "-" + item.getFloor(); String fourKey = threeId + "-" + item.getFloor();
if (!childrenIdMap.containsKey(fourKey)) { if (!childrenIdMap.containsKey(fourKey)) {
PlatSpace platSpace = new PlatSpace(); PlatSpace platSpace = new PlatSpace();
...@@ -540,7 +567,12 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace ...@@ -540,7 +567,12 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace
//房间 //房间
PlatRoomDTO platRoomDTO = new PlatRoomDTO(); PlatRoomDTO platRoomDTO = new PlatRoomDTO();
platRoomDTO.setName(item.getRoomName()); platRoomDTO.setName(item.getRoomName());
platRoomDTO.setBedNumber(item.getBedNumber()); if(item.getBedNumber()!=null){
platRoomDTO.setBedNumber(item.getBedNumber());
}else {
platRoomDTO.setBedNumber(0);
}
String spaceId = null; String spaceId = null;
int j = 0; int j = 0;
if (fourId != null){ if (fourId != null){
......
...@@ -169,17 +169,20 @@ public class WorkStationServiceImpl implements WorkStationService { ...@@ -169,17 +169,20 @@ public class WorkStationServiceImpl implements WorkStationService {
public PageVO<WorkStationInstitutionRoomVO> institutionPage(PageReqDTO<WorkStationQueryDTO> page) { public PageVO<WorkStationInstitutionRoomVO> institutionPage(PageReqDTO<WorkStationQueryDTO> page) {
WorkStationQueryDTO dto = page.getData(); WorkStationQueryDTO dto = page.getData();
List<PlatSpace> spaces = new ArrayList<>(); List<PlatSpace> spaces = new ArrayList<>();
//获取该账号的权限组织 if(dto.getOrgIds().isEmpty()){
List<PlatOrg> orgs = belongToScopeList(PlatOrgEnum.OrgTypeEnum.INSTITUTION.getValue()); //获取该账号的权限组织
if (orgs.isEmpty()) { List<PlatOrg> orgs = belongToScopeList(PlatOrgEnum.OrgTypeEnum.INSTITUTION.getValue());
return new PageVO<>(); if (orgs.isEmpty()) {
return new PageVO<>();
}
List<String> orgIds = orgs.stream().map(PlatOrg::getId).collect(Collectors.toList());
dto.setOrgIds(orgIds);
} }
List<String> orgIds = orgs.stream().map(PlatOrg::getId).collect(Collectors.toList());
dto.setOrgIds(orgIds);
if (dto.getSpaceIds().isEmpty()) { if (dto.getSpaceIds().isEmpty()) {
spaces = platSpaceService.list(new QueryWrapper<PlatSpace>().lambda() spaces = platSpaceService.list(new QueryWrapper<PlatSpace>().lambda()
.in(PlatSpace::getOrgId, orgIds)); .in(PlatSpace::getOrgId, dto.getOrgIds()));
if (spaces.isEmpty()) { if (spaces.isEmpty()) {
return new PageVO<>(); return new PageVO<>();
} }
...@@ -463,17 +466,20 @@ public class WorkStationServiceImpl implements WorkStationService { ...@@ -463,17 +466,20 @@ public class WorkStationServiceImpl implements WorkStationService {
public PageVO<WorkStationHomeBedVO> homePage(PageReqDTO<WorkStationQueryDTO> page) { public PageVO<WorkStationHomeBedVO> homePage(PageReqDTO<WorkStationQueryDTO> page) {
WorkStationQueryDTO dto = page.getData(); WorkStationQueryDTO dto = page.getData();
List<PlatSpace> spaces = new ArrayList<>(); List<PlatSpace> spaces = new ArrayList<>();
//获取该账号的权限组织 if(dto.getOrgIds().isEmpty()){
List<PlatOrg> orgs = belongToScopeList(PlatOrgEnum.OrgTypeEnum.HOME.getValue()); //获取该账号的权限组织
if (orgs.isEmpty()) { List<PlatOrg> orgs = belongToScopeList(PlatOrgEnum.OrgTypeEnum.HOME.getValue());
return new PageVO<>(); if (orgs.isEmpty()) {
return new PageVO<>();
}
List<String> orgIds = orgs.stream().map(PlatOrg::getId).collect(Collectors.toList());
dto.setOrgIds(orgIds);
} }
List<String> orgIds = orgs.stream().map(PlatOrg::getId).collect(Collectors.toList());
dto.setOrgIds(orgIds);
if (dto.getSpaceIds().isEmpty()) { if (dto.getSpaceIds().isEmpty()) {
spaces = platSpaceService.list(new QueryWrapper<PlatSpace>().lambda() spaces = platSpaceService.list(new QueryWrapper<PlatSpace>().lambda()
.in(PlatSpace::getOrgId, orgIds)); .in(PlatSpace::getOrgId, dto.getOrgIds()));
if (spaces.isEmpty()) { if (spaces.isEmpty()) {
return new PageVO<>(); return new PageVO<>();
} }
...@@ -550,6 +556,10 @@ public class WorkStationServiceImpl implements WorkStationService { ...@@ -550,6 +556,10 @@ public class WorkStationServiceImpl implements WorkStationService {
} }
List<String> orgIds = orgs.stream().map(PlatOrg::getId).collect(Collectors.toList()); List<String> orgIds = orgs.stream().map(PlatOrg::getId).collect(Collectors.toList());
if(!dto.getOrgIds().isEmpty()){
orgIds = dto.getOrgIds();
}
List<PlatSpace> list = platSpaceService.list(new QueryWrapper<PlatSpace>().lambda() List<PlatSpace> list = platSpaceService.list(new QueryWrapper<PlatSpace>().lambda()
.in(PlatSpace::getOrgId, orgIds)); .in(PlatSpace::getOrgId, orgIds));
......
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