融合通信

ds-hefei
luyya 2026-03-25 14:04:26 +08:00
parent 3456c73183
commit 12c4aa5d3d
5 changed files with 26 additions and 16 deletions

View File

@ -13,6 +13,7 @@ import org.dromara.system.domain.bo.MapPolygonBo;
import org.dromara.system.domain.bo.MapPolygonDeviceBo;
import org.dromara.system.domain.vo.MapPolygonDeviceVo;
import org.dromara.system.domain.vo.MapPolygonVo;
import org.dromara.system.domain.vo.TDeviceVo;
import org.dromara.system.service.IMapPolygonDeviceService;
import org.dromara.system.service.IMapPolygonService;
import org.springframework.validation.annotation.Validated;
@ -89,9 +90,10 @@ public class MapPolygonController extends BaseController {
/**
*
*/
@GetMapping("/deviceList/{polygonId}")
public R<List<MapPolygonDeviceVo>> getDeviceList(@PathVariable Integer polygonId) {
return R.ok(mapPolygonDeviceService.queryDeviceListByPolygonId(polygonId));
@GetMapping("/deviceList")
public TableDataInfo<TDeviceVo> getDeviceList(MapPolygonDeviceBo bo, PageQuery pageQuery) {
return mapPolygonDeviceService.queryDeviceListByPolygonId(bo,pageQuery);
}
/**
@ -116,9 +118,9 @@ public class MapPolygonController extends BaseController {
/**
*
*/
@DeleteMapping("/device/{ids}")
public R<Void> removeDevice(@PathVariable Long[] ids) {
return toAjax(mapPolygonDeviceService.deleteWithValidByIds(List.of(ids), true));
@DeleteMapping("/device/{ids}/{polygonId}")
public R<Void> removeDevice(@PathVariable String[] ids,@PathVariable Integer polygonId) {
return toAjax(mapPolygonDeviceService.deleteByPolygonIdAndDeviceCodes(polygonId, List.of(ids)));
}
/**

View File

@ -40,4 +40,6 @@ public interface TDeviceMapper extends BaseMapperPlus<TDevice, TDeviceVo> {
int insertOrUpdateByCodeAndType(TDevice device);
Page<TDeviceVo> getPageOnBindDeviceList(@Param("page") Page<TDevice> page, @Param("polygonId") Integer polygonId);
}

View File

@ -3,8 +3,10 @@ package org.dromara.system.service;
import org.dromara.common.mybatis.core.page.PageQuery;
import org.dromara.common.mybatis.core.page.TableDataInfo;
import org.dromara.system.domain.TDevice;
import org.dromara.system.domain.bo.MapPolygonDeviceBo;
import org.dromara.system.domain.vo.MapPolygonDeviceVo;
import org.dromara.system.domain.vo.TDeviceVo;
import java.util.Collection;
import java.util.List;
@ -47,7 +49,7 @@ public interface IMapPolygonDeviceService {
* @param polygonId ID
* @return
*/
List<MapPolygonDeviceVo> queryDeviceListByPolygonId(Integer polygonId);
TableDataInfo<TDeviceVo> queryDeviceListByPolygonId(MapPolygonDeviceBo bo, PageQuery pageQuery);
/**
*
@ -89,7 +91,7 @@ public interface IMapPolygonDeviceService {
* @param isValid
* @return
*/
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
Boolean deleteWithValidByIds(Collection<Long> ids,Long polygonId, Boolean isValid);
/**
* ID

View File

@ -3,6 +3,7 @@ package org.dromara.system.service.impl;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@ -16,6 +17,7 @@ import org.dromara.system.domain.MapPolygonDevice;
import org.dromara.system.domain.TDevice;
import org.dromara.system.domain.bo.MapPolygonDeviceBo;
import org.dromara.system.domain.vo.MapPolygonDeviceVo;
import org.dromara.system.domain.vo.TDeviceVo;
import org.dromara.system.mapper.MapPolygonDeviceMapper;
import org.dromara.system.mapper.MapPolygonMapper;
import org.dromara.system.mapper.TDeviceMapper;
@ -68,11 +70,10 @@ public class MapPolygonDeviceServiceImpl implements IMapPolygonDeviceService {
}
@Override
public List<MapPolygonDeviceVo> queryDeviceListByPolygonId(Integer polygonId) {
List<MapPolygonDeviceVo> list = baseMapper.selectDeviceListByPolygonId(polygonId);
// 填充设备类型名称
fillDeviceTypeName(list);
return list;
@DS("slave")
public TableDataInfo<TDeviceVo> queryDeviceListByPolygonId(MapPolygonDeviceBo bo, PageQuery pageQuery) {
Page<TDeviceVo> list = tDeviceMapper.getPageOnBindDeviceList(pageQuery.build(), bo.getPolygonId());
return TableDataInfo.build(list);
}
@Override
@ -126,7 +127,6 @@ public class MapPolygonDeviceServiceImpl implements IMapPolygonDeviceService {
list.add(binding);
}
baseMapper.deleteByPolygonId(polygonId);
// 批量插入
return baseMapper.insertBatch(list);
}
@ -160,11 +160,11 @@ public class MapPolygonDeviceServiceImpl implements IMapPolygonDeviceService {
}
@Override
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
public Boolean deleteWithValidByIds(Collection<Long> ids,Long polygonId, Boolean isValid) {
if (isValid) {
// 进行有效性校验
for (Long id : ids) {
MapPolygonDeviceVo vo = queryById(id);
MapPolygonDeviceVo vo = queryById(polygonId);
if (vo == null) {
throw new RuntimeException("绑定关系不存在");
}

View File

@ -53,4 +53,8 @@
update_time = values(update_time)
</insert>
<select id="getPageOnBindDeviceList" resultMap="DevicetResult">
select d.* from t_device d left join map_polygon_device md on d.device_code = md.device_code where md.polygon_id = #{polygonId}
</select>
</mapper>