15 changed files with 645 additions and 22 deletions
@ -0,0 +1,94 @@
|
||||
package com.mh.web.controller.space; |
||||
|
||||
import com.mh.common.annotation.Log; |
||||
import com.mh.common.core.controller.BaseController; |
||||
import com.mh.common.core.domain.AjaxResult; |
||||
import com.mh.common.core.domain.entity.CollectionParamsManage; |
||||
import com.mh.common.core.domain.entity.CpmSpaceRelation; |
||||
import com.mh.common.core.page.TableDataInfo; |
||||
import com.mh.common.enums.BusinessType; |
||||
import com.mh.system.service.space.ICpmSpaceRelationService; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.security.access.prepost.PreAuthorize; |
||||
import org.springframework.validation.annotation.Validated; |
||||
import org.springframework.web.bind.annotation.*; |
||||
|
||||
import java.util.List; |
||||
|
||||
/** |
||||
* @author LJF |
||||
* @version 1.0 |
||||
* @project EEMCS |
||||
* @description 采集参数和区域、楼栋、楼层、房间关联控制类 |
||||
* @date 2025-02-20 15:13:10 |
||||
*/ |
||||
@RestController |
||||
@RequestMapping("/space/relation") |
||||
public class CpmSpaceRelationController extends BaseController { |
||||
|
||||
private final ICpmSpaceRelationService cpmSpaceRelationService; |
||||
|
||||
@Autowired |
||||
public CpmSpaceRelationController(ICpmSpaceRelationService cpmSpaceRelationService) { |
||||
this.cpmSpaceRelationService = cpmSpaceRelationService; |
||||
} |
||||
|
||||
/** |
||||
* 获取采集参数、区域等关联管理列表内容数据 |
||||
*/ |
||||
@PreAuthorize("@ss.hasPermi('system:cpmSpaceRelation:list')") |
||||
@GetMapping("/list") |
||||
public TableDataInfo list(CpmSpaceRelation cpmSpaceRelation) |
||||
{ |
||||
startPage(); |
||||
List<CollectionParamsManage> list = cpmSpaceRelationService.selectCpmSpaceRelationList(cpmSpaceRelation); |
||||
return getDataTable(list); |
||||
} |
||||
|
||||
/** |
||||
* 根据区域管理id获取详细信息 |
||||
*/ |
||||
@PreAuthorize("@ss.hasPermi('system:cpmSpaceRelation:query')") |
||||
@GetMapping(value = "/{cpmSpaceRelationId}") |
||||
public AjaxResult getInfo(@PathVariable String cpmSpaceRelationId) |
||||
{ |
||||
return success(cpmSpaceRelationService.selectCpmSpaceRelationById(cpmSpaceRelationId)); |
||||
} |
||||
|
||||
/** |
||||
* 新增采集参数、区域等关联管理 |
||||
*/ |
||||
@PreAuthorize("@ss.hasPermi('system:cpmSpaceRelation:add')") |
||||
@Log(title = "采集参数、区域等关联管理", businessType = BusinessType.INSERT) |
||||
@PostMapping |
||||
public AjaxResult add(@Validated @RequestBody CpmSpaceRelation CpmSpaceRelation) |
||||
{ |
||||
CpmSpaceRelation.setCreateBy(getUsername()); |
||||
return toAjax(cpmSpaceRelationService.insertCpmSpaceRelation(CpmSpaceRelation)); |
||||
} |
||||
|
||||
/** |
||||
* 修改采集参数、区域等关联管理 |
||||
*/ |
||||
@PreAuthorize("@ss.hasPermi('system:cpmSpaceRelation:edit')") |
||||
@Log(title = "采集参数、区域等关联管理", businessType = BusinessType.UPDATE) |
||||
@PutMapping |
||||
public AjaxResult edit(@Validated @RequestBody CpmSpaceRelation CpmSpaceRelation) |
||||
{ |
||||
CpmSpaceRelation.setUpdateBy(getUsername()); |
||||
return toAjax(cpmSpaceRelationService.updateCpmSpaceRelation(CpmSpaceRelation)); |
||||
} |
||||
|
||||
/** |
||||
* 删除采集参数、区域等关联管理 |
||||
*/ |
||||
@PreAuthorize("@ss.hasPermi('system:cpmSpaceRelation:remove')") |
||||
@Log(title = "采集参数、区域等关联管理", businessType = BusinessType.DELETE) |
||||
@DeleteMapping("/{cpmSpaceRelationIds}") |
||||
public AjaxResult remove(@PathVariable String[] cpmSpaceRelationIds) |
||||
{ |
||||
return toAjax(cpmSpaceRelationService.deleteCpmSpaceRelationByIds(cpmSpaceRelationIds)); |
||||
} |
||||
|
||||
|
||||
} |
@ -0,0 +1,43 @@
|
||||
package com.mh.web.controller.space; |
||||
|
||||
import com.mh.common.annotation.Log; |
||||
import com.mh.common.core.controller.BaseController; |
||||
import com.mh.common.core.domain.AjaxResult; |
||||
import com.mh.common.core.domain.entity.CpmSpaceRelation; |
||||
import com.mh.common.core.domain.entity.HouseInfo; |
||||
import com.mh.common.enums.BusinessType; |
||||
import com.mh.system.service.space.IHouseInfoService; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.validation.annotation.Validated; |
||||
import org.springframework.web.bind.annotation.*; |
||||
|
||||
/** |
||||
* @author LJF |
||||
* @version 1.0 |
||||
* @project EEMCS |
||||
* @description 空间区域管理 |
||||
* @date 2025-02-20 08:34:51 |
||||
*/ |
||||
@RestController |
||||
@RequestMapping("/space") |
||||
public class SpaceController extends BaseController { |
||||
|
||||
private final IHouseInfoService houseInfoService; |
||||
|
||||
@Autowired |
||||
public SpaceController(IHouseInfoService houseInfoService) { |
||||
this.houseInfoService = houseInfoService; |
||||
} |
||||
|
||||
@GetMapping("/tree") |
||||
public AjaxResult tree() { |
||||
return AjaxResult.success(houseInfoService.buildTree()); |
||||
} |
||||
|
||||
@Log(title = "采集参数和区域、楼栋、楼层、房间的关联表", businessType = BusinessType.INSERT) |
||||
@PostMapping("/relation") |
||||
public AjaxResult relation(@Validated @RequestBody CpmSpaceRelation cpmSpaceRelation) { |
||||
cpmSpaceRelation.setCreateBy(getUsername()); |
||||
return AjaxResult.success(); |
||||
} |
||||
} |
@ -0,0 +1,98 @@
|
||||
package com.mh.common.core.domain; |
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore; |
||||
import com.fasterxml.jackson.annotation.JsonInclude; |
||||
import com.mh.common.constant.UserConstants; |
||||
import com.mh.common.core.domain.entity.SysDept; |
||||
import com.mh.common.core.domain.entity.SysMenu; |
||||
import com.mh.common.utils.StringUtils; |
||||
|
||||
import java.io.Serializable; |
||||
import java.util.List; |
||||
import java.util.stream.Collectors; |
||||
|
||||
/** |
||||
* Treeselect树结构实体类 |
||||
* |
||||
* @author mh |
||||
*/ |
||||
public class SpaceTreeSelect implements Serializable |
||||
{ |
||||
private static final long serialVersionUID = 1L; |
||||
|
||||
/** 节点ID */ |
||||
private String id; |
||||
|
||||
/** 节点名称 */ |
||||
private String label; |
||||
|
||||
/** 节点禁用 */ |
||||
private boolean disabled = false; |
||||
|
||||
/** 子节点 */ |
||||
@JsonInclude(JsonInclude.Include.NON_EMPTY) |
||||
private List<SpaceTreeSelect> children; |
||||
|
||||
// 用于构建关系的临时字段(不序列化)
|
||||
@JsonIgnore |
||||
private String parentId; |
||||
|
||||
public SpaceTreeSelect() |
||||
{ |
||||
|
||||
} |
||||
|
||||
public SpaceTreeSelect(String id, String houseName, boolean b, String floorId) { |
||||
this.id = id; |
||||
this.label = houseName; |
||||
this.disabled = b; |
||||
this.parentId = floorId; |
||||
} |
||||
|
||||
public String getId() { |
||||
return id; |
||||
} |
||||
|
||||
public void setId(String id) { |
||||
this.id = id; |
||||
} |
||||
|
||||
public String getParentId() { |
||||
return parentId; |
||||
} |
||||
|
||||
public void setParentId(String parentId) { |
||||
this.parentId = parentId; |
||||
} |
||||
|
||||
public String getLabel() |
||||
{ |
||||
return label; |
||||
} |
||||
|
||||
public void setLabel(String label) |
||||
{ |
||||
this.label = label; |
||||
} |
||||
|
||||
public boolean isDisabled() |
||||
{ |
||||
return disabled; |
||||
} |
||||
|
||||
public void setDisabled(boolean disabled) |
||||
{ |
||||
this.disabled = disabled; |
||||
} |
||||
|
||||
public List<SpaceTreeSelect> getChildren() |
||||
{ |
||||
return children; |
||||
} |
||||
|
||||
public void setChildren(List<SpaceTreeSelect> children) |
||||
{ |
||||
this.children = children; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,85 @@
|
||||
package com.mh.common.core.domain.entity; |
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType; |
||||
import com.baomidou.mybatisplus.annotation.TableField; |
||||
import com.baomidou.mybatisplus.annotation.TableId; |
||||
import com.baomidou.mybatisplus.annotation.TableName; |
||||
import com.fasterxml.jackson.annotation.JsonInclude; |
||||
import com.mh.common.core.domain.BaseEntity; |
||||
import lombok.Getter; |
||||
import lombok.Setter; |
||||
import org.apache.commons.lang3.builder.ToStringBuilder; |
||||
|
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* @author LJF |
||||
* @version 1.0 |
||||
* @project EEMCS |
||||
* @description 采集参数和区域、楼栋、楼层、房间的关联表 |
||||
* @date 2025-02-20 14:44:35 |
||||
*/ |
||||
@Setter |
||||
@Getter |
||||
@TableName("cpm_space_relation") |
||||
public class CpmSpaceRelation extends BaseEntity { |
||||
|
||||
private static final long serialVersionUID = 1L; |
||||
|
||||
@TableId(value = "id", type = IdType.ASSIGN_UUID) |
||||
private String id; |
||||
|
||||
/** |
||||
* 采集参数id |
||||
*/ |
||||
private String cpmId; |
||||
|
||||
/** |
||||
* 区域id |
||||
*/ |
||||
private String areaId; |
||||
|
||||
/** |
||||
* 楼栋id |
||||
*/ |
||||
private String buildingId; |
||||
|
||||
/** |
||||
* 楼层id |
||||
*/ |
||||
private String floorId; |
||||
|
||||
/** |
||||
* 房间id |
||||
*/ |
||||
private String houseId; |
||||
|
||||
/** |
||||
* 过滤掉BaseENtity的searchValue,param,remark |
||||
*/ |
||||
@TableField(exist = false) |
||||
private String remark; |
||||
|
||||
@TableField(exist = false) |
||||
private String searchValue; |
||||
|
||||
/** 请求参数 */ |
||||
@TableField(exist = false) |
||||
@JsonInclude(JsonInclude.Include.NON_EMPTY) |
||||
private Map<String, Object> params; |
||||
|
||||
@Override |
||||
public String toString() { |
||||
return new ToStringBuilder(this) |
||||
.append("id", id) |
||||
.append("cpmId", cpmId) |
||||
.append("areaId", areaId) |
||||
.append("buildingId", buildingId) |
||||
.append("floorId", floorId) |
||||
.append("houseId", houseId) |
||||
.append("remark", remark) |
||||
.append("searchValue", searchValue) |
||||
.append("params", params) |
||||
.toString(); |
||||
} |
||||
} |
@ -0,0 +1,16 @@
|
||||
package com.mh.system.mapper.space; |
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
import com.mh.common.core.domain.entity.CpmSpaceRelation; |
||||
import org.apache.ibatis.annotations.Mapper; |
||||
|
||||
/** |
||||
* @author LJF |
||||
* @version 1.0 |
||||
* @project EEMCS |
||||
* @description 参数区域关联表管理 |
||||
* @date 2025-02-20 15:33:31 |
||||
*/ |
||||
@Mapper |
||||
public interface CpmSpaceRelationMapper extends BaseMapper<CpmSpaceRelation> { |
||||
} |
@ -0,0 +1,28 @@
|
||||
package com.mh.system.service.space; |
||||
|
||||
import com.mh.common.core.domain.SpaceTreeSelect; |
||||
import com.mh.common.core.domain.entity.CollectionParamsManage; |
||||
import com.mh.common.core.domain.entity.CpmSpaceRelation; |
||||
|
||||
import java.util.List; |
||||
|
||||
/** |
||||
* @author LJF |
||||
* @version 1.0 |
||||
* @project EEMCS |
||||
* @description 区域、楼栋、楼层、房间跟采集参数关联管理 |
||||
* @date 2025-02-19 16:37:19 |
||||
*/ |
||||
public interface ICpmSpaceRelationService { |
||||
|
||||
List<CollectionParamsManage> selectCpmSpaceRelationList(CpmSpaceRelation cpmSpaceRelation); |
||||
|
||||
CpmSpaceRelation selectCpmSpaceRelationById(String cpmSpaceRelationId); |
||||
|
||||
int insertCpmSpaceRelation(CpmSpaceRelation cpmSpaceRelation); |
||||
|
||||
int updateCpmSpaceRelation(CpmSpaceRelation cpmSpaceRelation); |
||||
|
||||
int deleteCpmSpaceRelationByIds(String[] buildingIds); |
||||
|
||||
} |
@ -0,0 +1,78 @@
|
||||
package com.mh.system.service.space.impl; |
||||
|
||||
import com.mh.common.core.domain.entity.CollectionParamsManage; |
||||
import com.mh.common.core.domain.entity.CpmSpaceRelation; |
||||
import com.mh.common.utils.StringUtils; |
||||
import com.mh.system.mapper.device.CollectionParamsManageMapper; |
||||
import com.mh.system.mapper.space.CpmSpaceRelationMapper; |
||||
import com.mh.system.service.space.ICpmSpaceRelationService; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.stereotype.Service; |
||||
|
||||
import java.util.List; |
||||
|
||||
/** |
||||
* @author LJF |
||||
* @version 1.0 |
||||
* @project EEMCS |
||||
* @description 区域、楼栋、楼层、房间跟采集参数关联管理 |
||||
* @date 2025-02-19 16:37:19 |
||||
*/ |
||||
@Service |
||||
public class CpmSpaceRelationServiceImpl implements ICpmSpaceRelationService { |
||||
|
||||
private final CpmSpaceRelationMapper cpmSpaceRelationMapper; |
||||
|
||||
private final CollectionParamsManageMapper collectionParamsManageMapper; |
||||
|
||||
@Autowired |
||||
public CpmSpaceRelationServiceImpl(CpmSpaceRelationMapper cpmSpaceRelationMapper, CollectionParamsManageMapper collectionParamsManageMapper) { |
||||
this.cpmSpaceRelationMapper = cpmSpaceRelationMapper; |
||||
this.collectionParamsManageMapper = collectionParamsManageMapper; |
||||
} |
||||
|
||||
@Override |
||||
public List<CollectionParamsManage> selectCpmSpaceRelationList(CpmSpaceRelation cpmSpaceRelation) { |
||||
// 判断房间号id是否为空
|
||||
if (cpmSpaceRelation == null) { |
||||
return List.of(); |
||||
} |
||||
if (!StringUtils.isEmpty(cpmSpaceRelation.getHouseId())) { |
||||
return collectionParamsManageMapper.selectByHouseId(cpmSpaceRelation.getHouseId()); |
||||
} else if (!StringUtils.isEmpty(cpmSpaceRelation.getFloorId() )) { |
||||
return collectionParamsManageMapper.selectByFloorId(cpmSpaceRelation.getFloorId()); |
||||
} else if (!StringUtils.isEmpty(cpmSpaceRelation.getBuildingId() )) { |
||||
return collectionParamsManageMapper.selectByBuildingId(cpmSpaceRelation.getBuildingId()); |
||||
} else if (!StringUtils.isEmpty(cpmSpaceRelation.getAreaId() )) { |
||||
return collectionParamsManageMapper.selectByAreaId(cpmSpaceRelation.getAreaId()); |
||||
} else { |
||||
return List.of(); |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
public CpmSpaceRelation selectCpmSpaceRelationById(String cpmSpaceRelationId) { |
||||
return cpmSpaceRelationMapper.selectById(cpmSpaceRelationId); |
||||
} |
||||
|
||||
@Override |
||||
public int insertCpmSpaceRelation(CpmSpaceRelation cpmSpaceRelation) { |
||||
return cpmSpaceRelationMapper.insert(cpmSpaceRelation); |
||||
} |
||||
|
||||
@Override |
||||
public int updateCpmSpaceRelation(CpmSpaceRelation cpmSpaceRelation) { |
||||
return cpmSpaceRelationMapper.updateById(cpmSpaceRelation); |
||||
} |
||||
|
||||
@Override |
||||
public int deleteCpmSpaceRelationByIds(String[] buildingIds) { |
||||
if (buildingIds != null && buildingIds.length > 0) { |
||||
for (String buildingId : buildingIds) { |
||||
cpmSpaceRelationMapper.deleteById(buildingId); |
||||
} |
||||
return buildingIds.length; |
||||
} |
||||
return 0; |
||||
} |
||||
} |
Loading…
Reference in new issue