drone-service/drone-fw/src/main/java/org/sxkj/fw/area/mapper/FwAreaDivideMapper.java
@@ -21,6 +21,7 @@ import org.sxkj.fw.area.entity.FwAreaDivideEntity; import org.sxkj.fw.area.vo.FwAreaDivideVO; import org.sxkj.fw.area.vo.FwAreaDivideStatisticsVO; import org.sxkj.fw.area.vo.FwDefenseSceneVO; import org.sxkj.fw.area.excel.FwAreaDivideExcel; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.conditions.Wrapper; @@ -55,6 +56,22 @@ List<FwAreaDivideVO> selectFwAreaDivideList(@Param("filterSelected") Integer filterSelected, @Param("sceneId") Long sceneId); /** * 根据设备ID获取区域 * * @param deviceIds * @return */ List<FwAreaDivideVO> selectFwAreaDivideListByDeviceIds(@Param("deviceIds") List<Long> deviceIds); /** * 根据区域ID获取场景 * * @param areaIds * @return */ List<FwDefenseSceneVO> selectFwDefenseSceneListByAreaIds(@Param("areaIds") List<Long> areaIds); /** * 统计分页 * * @param page drone-service/drone-fw/src/main/java/org/sxkj/fw/area/mapper/FwAreaDivideMapper.xml
@@ -182,6 +182,46 @@ </where> </select> <select id="selectFwAreaDivideListByDeviceIds" resultMap="fwAreaDivideResultMap"> select ad.id, ad.area_name, ad.device_ids from ja_fw_area_divide ad <where> ad.is_deleted = 0 and ad.device_ids is not null and ad.device_ids != '' <if test="deviceIds != null and deviceIds.size > 0"> and ( <foreach collection="deviceIds" item="deviceId" separator=" or "> find_in_set(#{deviceId}, replace(ad.device_ids, ' ', '')) </foreach> ) </if> </where> </select> <select id="selectFwDefenseSceneListByAreaIds" resultType="org.sxkj.fw.area.vo.FwDefenseSceneVO"> select ds.id, ds.scene_name as sceneName, ds.area_divide_ids as areaDivideIds from ja_fw_defense_scene ds <where> ds.is_deleted = 0 and ds.area_divide_ids is not null and ds.area_divide_ids != '' <if test="areaIds != null and areaIds.size > 0"> and ( <foreach collection="areaIds" item="areaId" separator=" or "> find_in_set(#{areaId}, replace(ds.area_divide_ids, ' ', '')) </foreach> ) </if> </where> </select> <select id="selectFwAreaDivideDetail" resultMap="fwAreaDivideResultMap"> select ad.id, drone-service/drone-fw/src/main/java/org/sxkj/fw/area/service/IFwAreaDivideService.java
@@ -26,6 +26,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage; import org.springblade.core.mp.base.BaseService; import java.util.List; import java.util.Map; /** * 区域划分表 服务类 @@ -53,6 +54,14 @@ List<FwAreaDivideVO> selectFwAreaDivideList(Integer filterSelected, Long sceneId); /** * 根据设备ID获取关联场景名称 * * @param deviceIds * @return */ Map<Long, String> selectSceneNameByDeviceIds(List<Long> deviceIds); /** * 统计分页 * * @param page drone-service/drone-fw/src/main/java/org/sxkj/fw/area/service/impl/FwAreaDivideServiceImpl.java
@@ -24,6 +24,7 @@ import org.sxkj.fw.area.entity.FwAreaDivideEntity; import org.sxkj.fw.area.vo.FwAreaDivideVO; import org.sxkj.fw.area.vo.FwAreaDivideStatisticsVO; import org.sxkj.fw.area.vo.FwDefenseSceneVO; import org.sxkj.fw.area.excel.FwAreaDivideExcel; import org.sxkj.fw.area.mapper.FwAreaDivideMapper; import org.sxkj.fw.area.service.IFwAreaDivideService; @@ -31,7 +32,12 @@ import com.baomidou.mybatisplus.core.conditions.Wrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import org.springblade.core.mp.base.BaseServiceImpl; import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; import java.util.Date; /** @@ -41,7 +47,8 @@ * @since 2026-01-07 */ @Service public class FwAreaDivideServiceImpl extends BaseServiceImpl<FwAreaDivideMapper, FwAreaDivideEntity> implements IFwAreaDivideService { public class FwAreaDivideServiceImpl extends BaseServiceImpl<FwAreaDivideMapper, FwAreaDivideEntity> implements IFwAreaDivideService { @Override public IPage<FwAreaDivideVO> selectFwAreaDividePage(IPage<FwAreaDivideVO> page, FwAreaDivideDTO fwAreaDivide) { @@ -54,12 +61,105 @@ } @Override public IPage<FwAreaDivideStatisticsVO> selectFwAreaDivideStatisticsPage(IPage<FwAreaDivideStatisticsVO> page, FwAreaDivideStatisticsDTO fwAreaDivideStatistics) { public Map<Long, String> selectSceneNameByDeviceIds(List<Long> deviceIds) { Map<Long, String> result = new HashMap<>(); if (deviceIds == null || deviceIds.isEmpty()) { return result; } Set<Long> deviceIdSet = new HashSet<>(); for (Long deviceId : deviceIds) { if (deviceId != null) { deviceIdSet.add(deviceId); } } if (deviceIdSet.isEmpty()) { return result; } List<FwAreaDivideVO> areaList = baseMapper.selectFwAreaDivideListByDeviceIds(new ArrayList<>(deviceIdSet)); if (areaList == null || areaList.isEmpty()) { for (Long deviceId : deviceIdSet) { result.put(deviceId, "/"); } return result; } Map<Long, Set<Long>> deviceAreaMap = new HashMap<>(); Set<Long> areaIdSet = new HashSet<>(); for (FwAreaDivideVO area : areaList) { if (area == null || area.getId() == null) { continue; } List<Long> areaDeviceIds = parseIdList(area.getDeviceIds()); if (areaDeviceIds.isEmpty()) { continue; } for (Long deviceId : areaDeviceIds) { if (!deviceIdSet.contains(deviceId)) { continue; } deviceAreaMap.computeIfAbsent(deviceId, key -> new HashSet<>()).add(area.getId()); } areaIdSet.add(area.getId()); } if (areaIdSet.isEmpty()) { for (Long deviceId : deviceIdSet) { result.put(deviceId, "/"); } return result; } List<FwDefenseSceneVO> sceneList = baseMapper.selectFwDefenseSceneListByAreaIds(new ArrayList<>(areaIdSet)); Map<Long, Set<String>> areaSceneNameMap = new HashMap<>(); if (sceneList != null && !sceneList.isEmpty()) { for (FwDefenseSceneVO scene : sceneList) { if (scene == null) { continue; } String sceneName = scene.getSceneName(); if (StringUtil.isBlank(sceneName)) { continue; } List<Long> areaIds = parseIdList(scene.getAreaDivideIds()); for (Long areaId : areaIds) { if (!areaIdSet.contains(areaId)) { continue; } areaSceneNameMap.computeIfAbsent(areaId, key -> new HashSet<>()).add(sceneName); } } } for (Long deviceId : deviceIdSet) { Set<Long> areaIds = deviceAreaMap.get(deviceId); if (areaIds == null || areaIds.isEmpty()) { result.put(deviceId, "/"); continue; } Set<String> sceneNames = new HashSet<>(); for (Long areaId : areaIds) { Set<String> names = areaSceneNameMap.get(areaId); if (names != null) { sceneNames.addAll(names); } } if (sceneNames.isEmpty()) { result.put(deviceId, "/"); } else { result.put(deviceId, String.join(",", sceneNames)); } } return result; } @Override public IPage<FwAreaDivideStatisticsVO> selectFwAreaDivideStatisticsPage(IPage<FwAreaDivideStatisticsVO> page, FwAreaDivideStatisticsDTO fwAreaDivideStatistics) { return page.setRecords(baseMapper.selectFwAreaDivideStatisticsPage(page, fwAreaDivideStatistics)); } @Override public FwAreaDivideStatisticsVO selectFwAreaDivideStatisticsDetail(FwAreaDivideStatisticsDTO fwAreaDivideStatistics) { public FwAreaDivideStatisticsVO selectFwAreaDivideStatisticsDetail( FwAreaDivideStatisticsDTO fwAreaDivideStatistics) { return baseMapper.selectFwAreaDivideStatisticsDetail(fwAreaDivideStatistics); } @@ -71,9 +171,10 @@ @Override public List<FwAreaDivideExcel> exportFwAreaDivide(Wrapper<FwAreaDivideEntity> queryWrapper) { List<FwAreaDivideExcel> fwAreaDivideList = baseMapper.exportFwAreaDivide(queryWrapper); //fwAreaDivideList.forEach(fwAreaDivide -> { // fwAreaDivide.setTypeName(DictCache.getValue(DictEnum.YES_NO, FwAreaDivide.getType())); //}); // fwAreaDivideList.forEach(fwAreaDivide -> { // fwAreaDivide.setTypeName(DictCache.getValue(DictEnum.YES_NO, // FwAreaDivide.getType())); // }); return fwAreaDivideList; } @@ -111,19 +212,19 @@ deptId = null; } } // String areaCode = fwAreaDivide.getAreaCode(); // if (StringUtil.isBlank(areaCode)) { // areaCode = HeaderUtils.getAreaCode(); // } // String areaCode = fwAreaDivide.getAreaCode(); // if (StringUtil.isBlank(areaCode)) { // areaCode = HeaderUtils.getAreaCode(); // } Date now = new Date(); fwAreaDivide.setCreateUser(userId); fwAreaDivide.setUpdateUser(userId); if (deptId != null) { fwAreaDivide.setCreateDept(deptId); } // if (StringUtil.isNotBlank(areaCode)) { // fwAreaDivide.setAreaCode(areaCode); // } // if (StringUtil.isNotBlank(areaCode)) { // fwAreaDivide.setAreaCode(areaCode); // } fwAreaDivide.setCreateTime(now); fwAreaDivide.setUpdateTime(now); } @@ -136,4 +237,26 @@ fwAreaDivide.setUpdateTime(new Date()); } private List<Long> parseIdList(String ids) { if (StringUtil.isBlank(ids)) { return new ArrayList<>(); } String[] idArray = ids.split(","); List<Long> idList = new ArrayList<>(idArray.length); for (String item : idArray) { if (item == null) { continue; } String value = item.trim(); if (StringUtil.isBlank(value)) { continue; } try { idList.add(Long.valueOf(value)); } catch (NumberFormatException ignored) { } } return idList; } } drone-service/drone-fw/src/main/java/org/sxkj/fw/device/controller/FwDeviceController.java
@@ -32,6 +32,7 @@ import org.springblade.core.tool.constant.BladeConstant; import org.springblade.core.tool.utils.DateUtil; import org.springblade.core.tool.utils.Func; import org.springblade.core.tool.utils.StringUtil; import org.springframework.web.bind.annotation.*; import org.sxkj.fw.common.GenericConverter; import org.sxkj.fw.common.IdParam; @@ -101,7 +102,20 @@ @ApiOperation(value = "分页", notes = "传入fwDevice") public R<IPage<FwDeviceVO>> page(FwDevicePageParam fwDevice, Query query) { IPage<FwDeviceEntity> pages = fwDeviceService.selectFwDevicePage(Condition.getPage(query), GenericConverter.convert(fwDevice, FwDeviceDTO.class)); return R.data(FwDeviceWrapper.build().pageVO(pages)); IPage<FwDeviceVO> result = FwDeviceWrapper.build().pageVO(pages); List<FwDeviceVO> records = result.getRecords(); if (records != null && !records.isEmpty()) { List<Long> deviceIds = records.stream() .map(FwDeviceVO::getId) .filter(id -> id != null) .collect(Collectors.toList()); Map<Long, String> sceneNameMap = fwDeviceService.selectSceneNameByDeviceIds(deviceIds); for (FwDeviceVO record : records) { String sceneName = sceneNameMap.get(record.getId()); record.setSceneName(StringUtil.isBlank(sceneName) ? "/" : sceneName); } } return R.data(result); } /** drone-service/drone-fw/src/main/java/org/sxkj/fw/device/service/IFwDeviceService.java
@@ -27,6 +27,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage; import org.springblade.core.mp.base.BaseService; import java.util.List; import java.util.Map; /** * 设备表 服务类 @@ -81,4 +82,12 @@ * @return */ IPage<CockpitFwDeviceVO> selectCockpitDevicePage(IPage<CockpitFwDeviceVO> page, FwDeviceDTO fwDevice); /** * 获取设备关联场景名称 * * @param deviceIds * @return */ Map<Long, String> selectSceneNameByDeviceIds(List<Long> deviceIds); } drone-service/drone-fw/src/main/java/org/sxkj/fw/device/service/impl/FwDeviceServiceImpl.java
@@ -25,11 +25,14 @@ import org.sxkj.fw.device.excel.FwDeviceExcel; import org.sxkj.fw.device.mapper.FwDeviceMapper; import org.sxkj.fw.device.service.IFwDeviceService; import org.sxkj.fw.area.service.IFwAreaDivideService; import org.springframework.stereotype.Service; import com.baomidou.mybatisplus.core.conditions.Wrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import org.springblade.core.mp.base.BaseServiceImpl; import java.util.List; import java.util.Map; import javax.annotation.Resource; /** * 设备表 服务实现类 @@ -39,6 +42,9 @@ */ @Service public class FwDeviceServiceImpl extends BaseServiceImpl<FwDeviceMapper, FwDeviceEntity> implements IFwDeviceService { @Resource private IFwAreaDivideService fwAreaDivideService; @Override public IPage<FwDeviceEntity> selectFwDevicePage(IPage<FwDeviceEntity> page, FwDeviceDTO fwDevice) { @@ -88,4 +94,9 @@ public AlarmStatisticsVO statisticalDeviceAtt() { return baseMapper.statisticalDeviceAtt(); } @Override public Map<Long, String> selectSceneNameByDeviceIds(List<Long> deviceIds) { return fwAreaDivideService.selectSceneNameByDeviceIds(deviceIds); } } drone-service/drone-fw/src/main/java/org/sxkj/fw/device/vo/FwDeviceVO.java
@@ -147,6 +147,9 @@ @ApiModelProperty(value = "设备sn") private String deviceSn; @ApiModelProperty(value = "场景名称") private String sceneName; @ApiModelProperty(value = "所属部门名称") public String getBelongDeptName() { if (belongDept == null) {