This commit is contained in:
闵炳辉 2024-07-11 17:36:24 +08:00
commit 2362e23863
15 changed files with 69 additions and 10 deletions

View File

@ -244,7 +244,12 @@ public class SysIotModelController {
return R.success(); return R.success();
} }
/** 根据设备类型查询物模型 */
@PostMapping("/getSysIotModelByType")
public R<List<SysIotModelVo>> getSysIotModelByType(@RequestBody SysIotModelDto sysIotModelDto) {
return R.success(sysIotModelService.getSysIotModelByType(sysIotModelDto.getObjectType()));
}
} }

View File

@ -24,5 +24,7 @@ public interface SysEquipmentMapper extends BaseMapper<SysEquipment> {
List<SysEquipmentExcel> queryInfoById (@Param("info") SysEquipmentDto sysEquipmentDto); List<SysEquipmentExcel> queryInfoById (@Param("info") SysEquipmentDto sysEquipmentDto);
Long queryParentEquipmentIdByName(@Param("name")String name); Long queryChildEquipmentCount(@Param("id")Long id);
} }

View File

@ -14,4 +14,6 @@ import org.apache.ibatis.annotations.Param;
public interface SysIotModelFieldMapper extends BaseMapperPlus<SysIotModelField, SysIotModelField> { public interface SysIotModelFieldMapper extends BaseMapperPlus<SysIotModelField, SysIotModelField> {
IPage<SysIotModelFieldVo> querySysIotModelFieldList(IPage<SysIotModelFieldVo> page, @Param("info") SysIotModelFieldDto sysIotModelFieldDto); IPage<SysIotModelFieldVo> querySysIotModelFieldList(IPage<SysIotModelFieldVo> page, @Param("info") SysIotModelFieldDto sysIotModelFieldDto);
Long querySysIotModelFieldByModelId(Long id);
} }

View File

@ -4,8 +4,7 @@ package com.das.modules.equipment.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.das.modules.equipment.domain.excel.SysIotModelFieldExcel; import com.das.modules.equipment.domain.excel.SysIotModelFieldExcel;
import com.das.modules.equipment.domain.excel.SysIotModelServiceExcel; import com.das.modules.equipment.domain.excel.SysIotModelServiceExcel;
import com.das.modules.equipment.domain.vo.SysIotModelFieldVo; import com.das.modules.equipment.domain.vo.SysIotModelVo;
import com.das.modules.equipment.domain.vo.SysIotModelServiceVo;
import com.das.modules.equipment.entity.SysIotModel; import com.das.modules.equipment.entity.SysIotModel;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
@ -20,4 +19,6 @@ public interface SysIotModelMapper extends BaseMapper<SysIotModel> {
Long queryIotModelIdByName(String name); Long queryIotModelIdByName(String name);
List<SysIotModelVo> getSysIotModelByType(Integer objectType);
} }

View File

@ -14,4 +14,7 @@ import org.apache.ibatis.annotations.Param;
public interface SysIotModelServiceMapper extends BaseMapperPlus<SysIotModelServices, SysIotModelServices> { public interface SysIotModelServiceMapper extends BaseMapperPlus<SysIotModelServices, SysIotModelServices> {
IPage<SysIotModelServiceVo> querySysIotModelServiceList(IPage<SysIotModelServiceVo> page, @Param("info") SysIotModelServiceDto sysIotModelServiceDto); IPage<SysIotModelServiceVo> querySysIotModelServiceList(IPage<SysIotModelServiceVo> page, @Param("info") SysIotModelServiceDto sysIotModelServiceDto);
Long querySysIotModelServiceByModelId (Long id);
} }

View File

@ -43,4 +43,6 @@ public interface SysIotModelService {
void importSysIotModel(String iotModelId, MultipartFile file) throws IOException; void importSysIotModel(String iotModelId, MultipartFile file) throws IOException;
List<SysIotModelVo> getSysIotModelByType(Integer objectType);
} }

View File

@ -81,6 +81,10 @@ public class SysEquipmentServiceImpl implements SysEquipmentService {
@Override @Override
public void deleteSysEquipment(SysEquipmentDto sysEquipmentDto) { public void deleteSysEquipment(SysEquipmentDto sysEquipmentDto) {
// 设备下面有子设备则不能删除
if (sysEquipmentMapper.queryChildEquipmentCount(sysEquipmentDto.getId()) > 0) {
throw new RuntimeException("该设备下有子设备,不能删除");
}
sysEquipmentMapper.deleteById(sysEquipmentDto.getId()); sysEquipmentMapper.deleteById(sysEquipmentDto.getId());
} }

View File

@ -94,21 +94,25 @@ public class SysIotModelServiceImpl implements SysIotModelService {
@Override @Override
public void deleteSysIotModel(SysIotModelDto sysIotModelDto) { public void deleteSysIotModel(SysIotModelDto sysIotModelDto) {
// 物模型下面有类型或者动作则不能删除
if ((sysIotModelServiceMapper.querySysIotModelServiceByModelId(sysIotModelDto.getId()) > 0) || (sysIotModelFieldMapper.querySysIotModelFieldByModelId(sysIotModelDto.getId()) > 0)){
throw new RuntimeException("该物模型下面有类型,不能删除");
}
sysIotModelMapper.deleteById(sysIotModelDto.getId()); sysIotModelMapper.deleteById(sysIotModelDto.getId());
// 删除绑定的物模型属性和动作
// sysIotModelFieldMapper.delete(new QueryWrapper<SysIotModelField>().eq("iot_model_id",sysIotModelDto.getId()));
// sysIotModelServiceMapper.delete(new QueryWrapper<SysIotModelServices>().eq("iot_model_id",sysIotModelDto.getId()));
} }
@Override @Override
public List<SysIotModelVo> querySysIotModel(SysIotModelDto sysIotModelDto) { public List<SysIotModelVo> querySysIotModel(SysIotModelDto sysIotModelDto) {
List<SysIotModelVo> sysIotModelVoList = new ArrayList<>(); List<SysIotModelVo> sysIotModelVoList = new ArrayList<>();
List<SysIotModel> sysIotModels; List<SysIotModel> sysIotModels;
QueryWrapper<SysIotModel> sysIotModelQueryWrapper = new QueryWrapper<>();
if (sysIotModelDto.getIotModelCode() == null && sysIotModelDto.getIotModelName() == null){ if (sysIotModelDto.getIotModelCode() == null && sysIotModelDto.getIotModelName() == null){
sysIotModels = sysIotModelMapper.selectList(null); sysIotModelQueryWrapper.orderByAsc("object_type");
sysIotModels = sysIotModelMapper.selectList(sysIotModelQueryWrapper);
} else { } else {
QueryWrapper<SysIotModel> sysIotModelQueryWrapper = new QueryWrapper<>();
sysIotModelQueryWrapper.like("iot_model_code",sysIotModelDto.getIotModelCode()).or().like("iot_model_name",sysIotModelDto.getIotModelName()); sysIotModelQueryWrapper.like("iot_model_code",sysIotModelDto.getIotModelCode()).or().like("iot_model_name",sysIotModelDto.getIotModelName());
sysIotModelQueryWrapper.orderByAsc("object_type");
sysIotModels = sysIotModelMapper.selectList(sysIotModelQueryWrapper); sysIotModels = sysIotModelMapper.selectList(sysIotModelQueryWrapper);
} }
for (SysIotModel item : sysIotModels){ for (SysIotModel item : sysIotModels){
@ -304,4 +308,10 @@ public class SysIotModelServiceImpl implements SysIotModelService {
} }
@Override
public List<SysIotModelVo> getSysIotModelByType(Integer objectType) {
List<SysIotModelVo> list = sysIotModelMapper.getSysIotModelByType(objectType);
return list;
}
} }

View File

@ -13,4 +13,6 @@ import org.apache.ibatis.annotations.Param;
public interface SysCommunicationLinkMapper extends BaseMapper<SysCommunicationLink> { public interface SysCommunicationLinkMapper extends BaseMapper<SysCommunicationLink> {
IPage<SysCommunicationLinkVo> querySysCommunicationLinkList(IPage<SysCommunicationLinkVo> page, @Param("info") SysCommunicationLinkDto sysCommunicationLinkDto); IPage<SysCommunicationLinkVo> querySysCommunicationLinkList(IPage<SysCommunicationLinkVo> page, @Param("info") SysCommunicationLinkDto sysCommunicationLinkDto);
Long querySysCommunicationLinkCount(@Param("nodeId") Long nodeId);
} }

View File

@ -89,6 +89,9 @@ public class SysNodeServiceImpl implements SysNodeService {
@Override @Override
public void deleteSysNode(Long id) { public void deleteSysNode(Long id) {
// 判断节点下是否有链路有就不能删除 // 判断节点下是否有链路有就不能删除
if (sysCommunicationLinkMapper.querySysCommunicationLinkCount(id) > 0) {
throw new RuntimeException("该节点下有链路,不能删除");
}
sysNodeMapper.deleteById(id); sysNodeMapper.deleteById(id);
} }

View File

@ -24,5 +24,10 @@
</where> </where>
</select> </select>
<select id="querySysCommunicationLinkCount" resultType="java.lang.Long">
select count(1) from sys_communicationlink sc where sc.node_id = #{nodeId}
</select>
</mapper> </mapper>

View File

@ -103,8 +103,8 @@
</where> </where>
</select> </select>
<select id="queryParentEquipmentIdByName" resultType="java.lang.Long"> <select id="queryChildEquipmentCount" resultType="java.lang.Long">
select id from sys_equipment where name = #{name} select count(1) from sys_equipment where parent_equipment_id = #{id}
</select> </select>

View File

@ -27,4 +27,9 @@
</where> </where>
</select> </select>
<select id="querySysIotModelFieldByModelId" resultType="java.lang.Long">
select count(1) from sys_iot_model_field where iot_model_id = #{id}
</select>
</mapper> </mapper>

View File

@ -19,6 +19,13 @@
<result property="porder" column="porder" jdbcType="INTEGER"/> <result property="porder" column="porder" jdbcType="INTEGER"/>
</resultMap> </resultMap>
<resultMap type="com.das.modules.equipment.domain.vo.SysIotModelVo" id="SysIotModelMap">
<result property="iotModelName" column="iot_model_name" jdbcType="VARCHAR"/>
<result property="id" column="id" jdbcType="BIGINT"/>
<result property="objectType" column="object_type" jdbcType="INTEGER"/>
<result property="iotModelCode" column="iot_model_code" jdbcType="VARCHAR"/>
</resultMap>
<select id="queryFieldByModelId" resultMap="SysIotModelFieldMap"> <select id="queryFieldByModelId" resultMap="SysIotModelFieldMap">
select simf.*,sim.iot_model_name as iotModelName from sys_iot_model_field simf left join sys_iot_model sim on simf.iot_model_id = sim.id select simf.*,sim.iot_model_name as iotModelName from sys_iot_model_field simf left join sys_iot_model sim on simf.iot_model_id = sim.id
where simf.iot_model_id = #{id} where simf.iot_model_id = #{id}
@ -32,4 +39,9 @@
<select id="queryIotModelIdByName" resultType="java.lang.Long"> <select id="queryIotModelIdByName" resultType="java.lang.Long">
select id from sys_iot_model where name = #{name} select id from sys_iot_model where name = #{name}
</select> </select>
<select id="getSysIotModelByType" resultMap="SysIotModelMap">
select * from sys_iot_model where object_type = #{objectType}
</select>
</mapper> </mapper>

View File

@ -27,4 +27,7 @@
</where> </where>
</select> </select>
<select id="querySysIotModelServiceByModelId" resultType="java.lang.Long">
select count(1) from sys_iot_model_service where iot_model_id = #{id}
</select>
</mapper> </mapper>