|
@@ -2,14 +2,26 @@ package com.css.simulation.resource.scene.service;
|
|
|
|
|
|
import api.common.pojo.common.PageVO;
|
|
|
import api.common.pojo.common.ResponseBodyVO;
|
|
|
-import api.common.pojo.vo.system.SystemServerVO;
|
|
|
+import api.common.pojo.po.home.SystemServerPO;
|
|
|
+import api.common.pojo.vo.home.AccessVO;
|
|
|
+import api.common.pojo.vo.home.HardwareVO;
|
|
|
+import api.common.pojo.vo.home.ServiceVO;
|
|
|
+import api.common.pojo.vo.home.SystemServerVO;
|
|
|
+import api.common.util.TimeUtil;
|
|
|
+import com.css.simulation.resource.feign.MyOauthServerService;
|
|
|
+import com.css.simulation.resource.project.mapper.SimulationProjectMapper;
|
|
|
+import com.css.simulation.resource.scene.mapper.SystemAccessMapper;
|
|
|
import com.css.simulation.resource.scene.mapper.SystemServerMapper;
|
|
|
+import com.css.simulation.resource.system.mapper.UserMapper;
|
|
|
import com.github.pagehelper.PageHelper;
|
|
|
import com.github.pagehelper.PageInfo;
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
|
|
|
@Service
|
|
|
public class HomePageService {
|
|
@@ -17,12 +29,80 @@ public class HomePageService {
|
|
|
@Autowired
|
|
|
SystemServerMapper systemServerMapper;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ SystemAccessMapper systemAccessMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ UserMapper userMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ MyOauthServerService myOauthServerService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private SimulationProjectMapper simulationProjectMapper;
|
|
|
|
|
|
- public ResponseBodyVO<PageInfo<SystemServerVO>> selectServerList(PageVO pageVO) {
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ public ResponseBodyVO<HardwareVO> selectHardware() {
|
|
|
+
|
|
|
+
|
|
|
+ List<SystemServerPO> systemServerPOList = systemServerMapper.selectAll();
|
|
|
+ int weightSum = systemServerPOList.stream().mapToInt(SystemServerPO::getWeight).sum(); // 权重之和
|
|
|
+ HardwareVO build = HardwareVO.builder()
|
|
|
+ .serverNumber(systemServerPOList.size())
|
|
|
+ .memoryUsage(systemServerPOList.stream().mapToInt(po -> po.getMemoryUsage() * po.getWeight() / weightSum).sum() + "")
|
|
|
+ .diskUsage(systemServerPOList.stream().mapToInt(po -> po.getDiskUsage() * po.getWeight() / weightSum) + "")
|
|
|
+ .cpuUsage(systemServerPOList.stream().mapToInt(po -> po.getCpuUsage() * po.getWeight() / weightSum) + "")
|
|
|
+ .gpuUsage(systemServerPOList.stream().mapToInt(po -> po.getGpuUsage() * po.getWeight() / weightSum) + "")
|
|
|
+ .build();
|
|
|
+
|
|
|
+ return new ResponseBodyVO<>(ResponseBodyVO.Response.SUCCESS, build);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public ResponseBodyVO<ServiceVO> selectService() {
|
|
|
+
|
|
|
+ ServiceVO build = ServiceVO.builder()
|
|
|
+ .userNumber(userMapper.selectCount())
|
|
|
+ .onlineNumber(myOauthServerService.online().getInfo())
|
|
|
+ .simulationNodeNumber(1)
|
|
|
+ .simulationLicenseNumber(1)
|
|
|
+ .dynamicsLicenseNumber(1)
|
|
|
+ .build();
|
|
|
+
|
|
|
+ return new ResponseBodyVO<>(ResponseBodyVO.Response.SUCCESS, build);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public ResponseBodyVO<List<AccessVO>> selectAccess() {
|
|
|
+ List<AccessVO> list = new ArrayList<>();
|
|
|
+ for (int i = 6; i > -1; i--) {
|
|
|
+ AccessVO vo = new AccessVO();
|
|
|
+ Map<String, Object> params = TimeUtil.getPastTime(i);
|
|
|
+ Integer num = systemAccessMapper.selectPastAccess(params);
|
|
|
+ vo.setToDate(params.get("toDate").toString());
|
|
|
+ vo.setNum(num);
|
|
|
+ list.add(vo);
|
|
|
+ }
|
|
|
+ return new ResponseBodyVO<>(ResponseBodyVO.Response.SUCCESS, list);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ public ResponseBodyVO<PageInfo<SystemServerVO>> selectServer(PageVO pageVO) {
|
|
|
|
|
|
PageHelper.startPage(pageVO.getCurrentPage(), pageVO.getPageSize());
|
|
|
- List<SystemServerVO> systemServerPOList = systemServerMapper.selectAll();
|
|
|
+ List<SystemServerPO> systemServerPOList = systemServerMapper.selectAll();
|
|
|
+ List<SystemServerVO> systemServerVOList = new ArrayList<>();
|
|
|
+ systemServerPOList.forEach(po -> {
|
|
|
+ SystemServerVO vo = new SystemServerVO();
|
|
|
+ BeanUtils.copyProperties(po, vo);
|
|
|
+ systemServerVOList.add(vo);
|
|
|
+ });
|
|
|
|
|
|
- return new ResponseBodyVO<>(ResponseBodyVO.Response.SUCCESS, new PageInfo<>(systemServerPOList));
|
|
|
+ return new ResponseBodyVO<>(ResponseBodyVO.Response.SUCCESS, new PageInfo<>(systemServerVOList));
|
|
|
}
|
|
|
+
|
|
|
}
|