|
@@ -2,16 +2,15 @@ package com.css.simulation.resource.scene.service;
|
|
|
|
|
|
import api.common.pojo.common.PageVO;
|
|
|
import api.common.pojo.common.ResponseBodyVO;
|
|
|
-import api.common.pojo.po.home.SystemAccessPO;
|
|
|
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.StringUtil;
|
|
|
+import api.common.util.ObjectUtil;
|
|
|
import api.common.util.TimeUtil;
|
|
|
import com.css.simulation.resource.feign.OauthClientService;
|
|
|
-import com.css.simulation.resource.scene.mapper.SystemAccessMapper;
|
|
|
+import com.css.simulation.resource.log.mapper.LogMapper;
|
|
|
import com.css.simulation.resource.scene.mapper.SystemServerMapper;
|
|
|
import com.css.simulation.resource.system.mapper.UserMapper;
|
|
|
import com.github.pagehelper.PageHelper;
|
|
@@ -19,23 +18,24 @@ import com.github.pagehelper.PageInfo;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import javax.annotation.Resource;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
@Service
|
|
|
public class HomePageService {
|
|
|
|
|
|
- @Autowired
|
|
|
+ @Resource
|
|
|
SystemServerMapper systemServerMapper;
|
|
|
|
|
|
- @Autowired
|
|
|
- SystemAccessMapper systemAccessMapper;
|
|
|
-
|
|
|
@Autowired
|
|
|
UserMapper userMapper;
|
|
|
|
|
|
@Autowired
|
|
|
+ LogMapper logMapper;
|
|
|
+
|
|
|
+ @Resource
|
|
|
OauthClientService oauthClientService;
|
|
|
|
|
|
|
|
@@ -82,20 +82,23 @@ public class HomePageService {
|
|
|
|
|
|
|
|
|
public ResponseBodyVO<List<AccessVO>> selectAccess() {
|
|
|
-
|
|
|
- SystemAccessPO systemAccessPO = SystemAccessPO.builder()
|
|
|
- .id(StringUtil.getRandomUUID())
|
|
|
- .accessTime(TimeUtil.getNowForMysql())
|
|
|
- .build();
|
|
|
- systemAccessMapper.insert(systemAccessPO);
|
|
|
-
|
|
|
List<AccessVO> list = new ArrayList<>();
|
|
|
- for (int i = 6; i > -1; i--) {
|
|
|
+ String dateBegin = TimeUtil.getMinusDaysStr(6);
|
|
|
+ List<AccessVO> listVo = logMapper.getAccessCount(dateBegin);
|
|
|
+ boolean notNull = ObjectUtil.isNotNull(listVo);
|
|
|
+ for (int i = 6; i >= 0; i--) {
|
|
|
+ String date = TimeUtil.getMinusDaysStr(i);
|
|
|
+ if(notNull){
|
|
|
+ List<AccessVO> collect = listVo.stream().filter(v -> date.equals(v.getToDate())).collect(Collectors.toList());
|
|
|
+ if(ObjectUtil.isNotNull(collect)){
|
|
|
+ AccessVO vo = collect.get(0);
|
|
|
+ list.add(vo);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }
|
|
|
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);
|
|
|
+ vo.setToDate(date);
|
|
|
+ vo.setNum(0);
|
|
|
list.add(vo);
|
|
|
}
|
|
|
return new ResponseBodyVO<>(ResponseBodyVO.Response.SUCCESS, list);
|