| | |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ycl.platform.domain.entity.Platform; |
| | | import com.ycl.platform.domain.form.PlatformForm; |
| | | import com.ycl.platform.domain.query.DashboardQuery; |
| | | import com.ycl.platform.domain.query.PlatformQuery; |
| | | import com.ycl.platform.domain.vo.PlatformVO; |
| | | import com.ycl.platform.mapper.PlatformMapper; |
| | |
| | | import com.ycl.system.service.ISysDictTypeService; |
| | | import com.ycl.system.service.impl.SysDictDataServiceImpl; |
| | | import com.ycl.system.service.impl.SysDictTypeServiceImpl; |
| | | import enumeration.general.AreaDeptEnum; |
| | | import org.ehcache.core.util.CollectionUtil; |
| | | import org.springframework.stereotype.Service; |
| | | import lombok.RequiredArgsConstructor; |
| | |
| | | import org.springframework.util.CollectionUtils; |
| | | import org.springframework.util.StringUtils; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.io.IOException; |
| | | import java.net.InetAddress; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | |
| | | .collect(Collectors.toList()); |
| | | return Result.ok().data(vos); |
| | | } |
| | | |
| | | @Override |
| | | public Map<String, Map<String, Object>> dashboard(DashboardQuery dashboardQuery) { |
| | | //先默认所有区县平台在线,初始化map数据 |
| | | Map<String, Map<String, Object>> resultMap = new HashMap<>(); |
| | | for (AreaDeptEnum value : AreaDeptEnum.values()) { |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("platformOnline",Boolean.TRUE); |
| | | resultMap.put(value.getName(),map); |
| | | } |
| | | //平台在线状态 默认在线,如果一个不在线改为false。 |
| | | List<Platform> platformList = new LambdaQueryChainWrapper<>(platformMapper) |
| | | .isNotNull(Platform::getPlatformIP) |
| | | .list(); |
| | | Boolean reachable = Boolean.FALSE; |
| | | try { |
| | | for (Platform platform : platformList) { |
| | | reachable = InetAddress.getByName(platform.getPlatformIP()).isReachable(3000); |
| | | //不在线 |
| | | if(!reachable) { |
| | | //获取平台管理的区域编码集合 |
| | | List<String> areaCodes = Arrays.asList(com.ycl.utils.StringUtils.split(platform.getArea(), ",")); |
| | | resultMap.forEach((deptName, map) -> { |
| | | if(areaCodes.contains(AreaDeptEnum.fromName(deptName).getCode())){ |
| | | map.put("platformOnline",Boolean.FALSE); |
| | | } |
| | | }); |
| | | } |
| | | } |
| | | } catch (Exception e) { |
| | | log.error("检查平台连通性时发生错误", e); |
| | | } |
| | | return resultMap; |
| | | } |
| | | } |