| | |
| | | import org.sxkj.fw.area.vo.FwAreaDivideVO; |
| | | import org.sxkj.fw.area.vo.FwDefenseSceneVO; |
| | | import org.sxkj.fw.device.entity.FwDeviceEntity; |
| | | import org.sxkj.fw.device.mapper.FwDeviceMapper; |
| | | import org.sxkj.fw.device.service.IFwDeviceService; |
| | | import org.sxkj.system.cache.SysCache; |
| | | |
| | |
| | | public class FwAreaDivideServiceImpl extends BaseServiceImpl<FwAreaDivideMapper, FwAreaDivideEntity> implements IFwAreaDivideService { |
| | | |
| | | private final IFwAreaDivideExtService fwAreaDivideExtService; |
| | | private final FwDeviceMapper fwDeviceMapper; |
| | | |
| | | @Override |
| | | public IPage<FwAreaDivideVO> selectFwAreaDividePage(IPage<FwAreaDivideVO> page, FwAreaDivideDTO fwAreaDivide) { |
| | |
| | | } |
| | | |
| | | @Override |
| | | public String selectAreaNameByDeviceId(Long deviceId) { |
| | | if (deviceId == null) { |
| | | return ""; |
| | | } |
| | | List<FwAreaDivideVO> areaList = baseMapper.selectFwAreaDivideListByDeviceIds(Collections.singletonList(deviceId)); |
| | | if (areaList == null || areaList.isEmpty()) { |
| | | return ""; |
| | | } |
| | | Set<String> areaNameSet = new LinkedHashSet<>(); |
| | | for (FwAreaDivideVO area : areaList) { |
| | | if (area == null || StringUtil.isBlank(area.getAreaName())) { |
| | | continue; |
| | | } |
| | | areaNameSet.add(area.getAreaName().trim()); |
| | | } |
| | | if (areaNameSet.isEmpty()) { |
| | | return ""; |
| | | } |
| | | return String.join(",", areaNameSet); |
| | | } |
| | | |
| | | @Override |
| | | public IPage<FwAreaDivideStatisticsVO> selectFwAreaDivideStatisticsPage(IPage<FwAreaDivideStatisticsVO> page, |
| | | FwAreaDivideStatisticsDTO fwAreaDivideStatistics) { |
| | | if (!AuthUtil.isAdministrator()) { |
| | |
| | | // 判断区域是否绑定到场景中 |
| | | boolean isBindScene = baseMapper.checkAreaBindScene(fwAreaDivide.getId()); |
| | | if (isBindScene) { |
| | | IFwDeviceService fwDeviceService = SpringUtil.getBean(IFwDeviceService.class); |
| | | // 启用新增的设备 |
| | | if (!addedDeviceIds.isEmpty()) { |
| | | fwDeviceService.update(Wrappers.<FwDeviceEntity>lambdaUpdate() |
| | | .set(FwDeviceEntity::getIsEnabled, 1) |
| | | .in(FwDeviceEntity::getId, addedDeviceIds)); |
| | | List<Long> addedIds = parseIdList(String.join(",", addedDeviceIds)); |
| | | fwDeviceMapper.batchUpdateIsEnabled(addedIds, 1); |
| | | } |
| | | // 禁用删除的设备 |
| | | if (!removedDeviceIds.isEmpty()) { |
| | | fwDeviceService.update(Wrappers.<FwDeviceEntity>lambdaUpdate() |
| | | .set(FwDeviceEntity::getIsEnabled, 0) |
| | | .in(FwDeviceEntity::getId, removedDeviceIds)); |
| | | List<Long> removedIds = parseIdList(String.join(",", removedDeviceIds)); |
| | | fwDeviceMapper.batchUpdateIsEnabled(removedIds, 0); |
| | | } |
| | | } |
| | | } |
| | |
| | | for (Long deviceId : deviceIds) { |
| | | FwDeviceEntity device = new FwDeviceEntity(); |
| | | device.setId(deviceId); |
| | | device.setIsEnabled(false); |
| | | device.setIsEnabled(0); |
| | | fwDeviceService.updateById(device); |
| | | } |
| | | } |