parent
b524929d7e
commit
2c1088a431
@ -0,0 +1,88 @@
|
|||||||
|
package cn.estsh.i3plus.core.apiservice.controller.busi;
|
||||||
|
|
||||||
|
import cn.estsh.i3plus.core.api.iservice.busi.*;
|
||||||
|
import cn.estsh.i3plus.platform.common.tool.TimeTool;
|
||||||
|
import cn.estsh.i3plus.platform.common.util.PlatformConstWords;
|
||||||
|
import cn.estsh.i3plus.pojo.base.enumutil.ResourceEnumUtil;
|
||||||
|
import cn.estsh.impp.framework.base.controller.CoreBaseController;
|
||||||
|
import cn.estsh.impp.framework.boot.exception.ImppBusiException;
|
||||||
|
import cn.estsh.impp.framework.boot.exception.ImppExceptionBuilder;
|
||||||
|
import cn.estsh.impp.framework.boot.util.ImppRedis;
|
||||||
|
import cn.estsh.impp.framework.boot.util.ResultBean;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.Calendar;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description :
|
||||||
|
* @Reference :
|
||||||
|
* @Author : yunhao
|
||||||
|
* @CreateDate : 2018-12-10 17:04
|
||||||
|
* @Modify:
|
||||||
|
**/
|
||||||
|
@RestController
|
||||||
|
@Api(description = "Dashboard服务")
|
||||||
|
@RequestMapping(PlatformConstWords.BASE_URL + "/dashboard")
|
||||||
|
public class SysDashboardController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ISysUserService sysUserService;
|
||||||
|
@Autowired
|
||||||
|
private ISysOrganizeService sysOrganizeService;
|
||||||
|
@Autowired
|
||||||
|
private ISysDepartmentService sysDepartmentService;
|
||||||
|
@Autowired
|
||||||
|
private ISysMessageService sysMessageService;
|
||||||
|
@Autowired
|
||||||
|
private ISysLogOperateService sysLogOperateService;
|
||||||
|
@Autowired
|
||||||
|
private ISysLogSystemService sysLogSystemService;
|
||||||
|
// @Autowired
|
||||||
|
// private EurekaServerContext eurekaServerContext;
|
||||||
|
@Resource(name="redisRes")
|
||||||
|
private ImppRedis redisRes;
|
||||||
|
|
||||||
|
|
||||||
|
@GetMapping("/get")
|
||||||
|
@ApiOperation(value = "获取dashboard数据")
|
||||||
|
public ResultBean getDashboardData(){
|
||||||
|
try {
|
||||||
|
Map<String,Object> dashboardData = (Map<String, Object>) redisRes.getObject(PlatformConstWords.DASHBOARD_REDIS_KEY);
|
||||||
|
if(dashboardData == null){
|
||||||
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
|
||||||
|
Calendar cal = Calendar.getInstance();
|
||||||
|
cal.setTime(new Date());
|
||||||
|
|
||||||
|
String startTime = sdf.format(new Date());
|
||||||
|
cal.add(Calendar.MINUTE,10);
|
||||||
|
String endTime = sdf.format(cal.getTime());
|
||||||
|
|
||||||
|
dashboardData = new HashMap<>();
|
||||||
|
dashboardData.put("userNum",sysUserService.getSysUserCount());
|
||||||
|
dashboardData.put("orgNum",sysOrganizeService.getSysOrganizeCount());
|
||||||
|
dashboardData.put("deptNum",sysDepartmentService.getSysDepartmentCount());
|
||||||
|
dashboardData.put("logOperate",sysLogOperateService.findNewSysLogOperate(10));
|
||||||
|
dashboardData.put("",sysLogSystemService.queryAvgExecuteTime(startTime,endTime));
|
||||||
|
|
||||||
|
redisRes.putHashMap(PlatformConstWords.DASHBOARD_REDIS_KEY,dashboardData,1000*60);
|
||||||
|
}
|
||||||
|
return ResultBean.success("添加成功").setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode()).setResultMap(dashboardData);
|
||||||
|
} catch (
|
||||||
|
ImppBusiException busExcep) {
|
||||||
|
return ResultBean.fail(busExcep);
|
||||||
|
} catch (Exception e) {
|
||||||
|
return ImppExceptionBuilder.newInstance().buildExceptionResult(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,28 @@
|
|||||||
|
package cn.estsh.i3plus.core.apiservice.dao;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import org.bson.Document;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description : 操作日志
|
||||||
|
* @Reference :
|
||||||
|
* @Author : yunhao
|
||||||
|
* @CreateDate : 2018-12-11 13:22
|
||||||
|
* @Modify:
|
||||||
|
**/
|
||||||
|
public interface ISysLogSystemDao {
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询时间段内平均请求耗时
|
||||||
|
* @param startTime
|
||||||
|
* @param endTime
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@ApiOperation(value = "查询时间段内平均请求耗时")
|
||||||
|
Map<String,Object> querySysLogOperateAvgExecuteTime(String startTime, String endTime);
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,35 @@
|
|||||||
|
package cn.estsh.i3plus.core.apiservice.serviceimpl.busi;
|
||||||
|
|
||||||
|
import cn.estsh.i3plus.core.api.iservice.busi.ISysMessageService;
|
||||||
|
import cn.estsh.impp.framework.boot.util.ImppRedis;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.beans.Transient;
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description :
|
||||||
|
* @Reference :
|
||||||
|
* @Author : yunhao
|
||||||
|
* @CreateDate : 2018-12-12 22:06
|
||||||
|
* @Modify:
|
||||||
|
**/
|
||||||
|
public class TestRedis extends TestBase {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ISysMessageService sysMessageService;
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testReids(){
|
||||||
|
// // 放入缓存
|
||||||
|
// HashMap<String,String> resource = new HashMap<String,String>();
|
||||||
|
// resource.put("test","test110");
|
||||||
|
// redisRes.putHashMap("junit3",resource,1000 * 60);
|
||||||
|
// System.out.println(redisRes.getHashMap("junit3"));
|
||||||
|
// System.out.println(redisRes.commit());
|
||||||
|
// System.out.println(redisRes.getHashMap("junit3"));
|
||||||
|
sysMessageService.insertRedis();
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue