package com.lf.server.controller.data;
|
|
import com.lf.server.annotation.SysLog;
|
import com.lf.server.controller.all.BaseController;
|
import com.lf.server.controller.all.BaseQueryController;
|
import com.lf.server.entity.all.ResponseMsg;
|
import com.lf.server.entity.ctrl.CountEntity;
|
import com.lf.server.entity.sys.ReportEntity;
|
import com.lf.server.entity.sys.UserEntity;
|
import com.lf.server.helper.StringHelper;
|
import com.lf.server.service.all.UploadAttachService;
|
import com.lf.server.service.sys.ReportService;
|
import com.lf.server.service.sys.TokenService;
|
import io.swagger.annotations.Api;
|
import io.swagger.annotations.ApiImplicitParam;
|
import io.swagger.annotations.ApiImplicitParams;
|
import io.swagger.annotations.ApiOperation;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.web.bind.annotation.*;
|
|
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletResponse;
|
import java.util.List;
|
|
/**
|
* 数据统计
|
* @author WWW
|
*/
|
@Api(tags = "数据管理\\数据统计")
|
@RestController
|
@RequestMapping("/dataCount")
|
public class DataCountController extends BaseController {
|
@Autowired
|
ReportService reportService;
|
|
@Autowired
|
TokenService tokenService;
|
|
@Autowired
|
UploadAttachService uploadAttachService;
|
|
@SysLog()
|
@ApiOperation(value = "分页查询并返回记录数")
|
@ApiImplicitParams({
|
@ApiImplicitParam(name = "name", value = "名称", dataType = "String", paramType = "query", example = ""),
|
@ApiImplicitParam(name = "code", value = "编码", dataType = "String", paramType = "query", example = "countOperates"),
|
@ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "Integer", paramType = "query", example = "10"),
|
@ApiImplicitParam(name = "pageIndex", value = "分页数(从1开始)", dataType = "Integer", paramType = "query", example = "1")
|
})
|
@GetMapping(value = "/selectByPageAndCount")
|
public ResponseMsg<List<ReportEntity>> selectByPageAndCount(String name, String code, Integer pageSize, Integer pageIndex) {
|
try {
|
if (pageSize < 1 || pageIndex < 1) {
|
return fail("每页页数或分页数小于1", null);
|
}
|
|
int count = reportService.selectCount(name, code);
|
if (count == 0) {
|
return success(0, null);
|
}
|
|
List<ReportEntity> rs = reportService.selectByPage(name, code, pageSize, pageSize * (pageIndex - 1));
|
|
return success(count, rs);
|
} catch (Exception ex) {
|
return fail(ex, null);
|
}
|
}
|
|
@SysLog()
|
@ApiOperation(value = "查询数据量统计")
|
@GetMapping(value = "/selectCountSizes")
|
public ResponseMsg<Object> selectCountSizes() {
|
try {
|
List<CountEntity> list = reportService.countSizes();
|
|
return success(list);
|
} catch (Exception ex) {
|
return fail(ex, null);
|
}
|
}
|
|
@SysLog()
|
@ApiOperation(value = "按文件类型统计")
|
@GetMapping(value = "/countSizesByType")
|
public ResponseMsg<Object> countSizesByType() {
|
try {
|
List<CountEntity> list = reportService.countSizesByType();
|
|
return success(list);
|
} catch (Exception ex) {
|
return fail(ex, null);
|
}
|
}
|
|
@SysLog()
|
@ApiOperation(value = "查询服务调用量统计")
|
@GetMapping(value = "/selectCountServices")
|
public ResponseMsg<Object> selectCountServices() {
|
try {
|
List<CountEntity> list = reportService.countServices();
|
|
return success(list);
|
} catch (Exception ex) {
|
return fail(ex, null);
|
}
|
}
|
|
@SysLog()
|
@ApiOperation(value = "查询用户流量统计")
|
@GetMapping(value = "/selectCountOperates")
|
public ResponseMsg<Object> selectCountOperates() {
|
try {
|
List<CountEntity> list = reportService.countOperates();
|
|
return success(list);
|
} catch (Exception ex) {
|
return fail(ex, null);
|
}
|
}
|
|
@SysLog()
|
@ApiOperation(value = "按项目统计数据")
|
@GetMapping(value = "/countSizesByPrj")
|
public ResponseMsg<Object> countSizesByPrj() {
|
try {
|
List<CountEntity> list = reportService.countSizesByPrj();
|
|
return success(list);
|
} catch (Exception ex) {
|
return fail(ex, null);
|
}
|
}
|
|
@SysLog()
|
@ApiOperation(value = "按项目统计钻孔数据")
|
@GetMapping(value = "/countExplorationPoints")
|
public ResponseMsg<Object> countExplorationPoints() {
|
try {
|
List<CountEntity> list = reportService.countExplorationPoints();
|
|
return success(list);
|
} catch (Exception ex) {
|
return fail(ex, null);
|
}
|
}
|
|
@SysLog()
|
@ApiOperation(value = "下载报告")
|
@ApiImplicitParams({
|
@ApiImplicitParam(name = "id", value = "报告ID", dataType = "Integer", paramType = "query", example = "18")
|
})
|
@GetMapping(value = "/downloadReport")
|
public void downloadReport(Integer id, HttpServletRequest req, HttpServletResponse res) {
|
try {
|
if (null == id || id < 1) {
|
return;
|
}
|
|
ReportEntity re = reportService.selectById(id);
|
if (null == re || StringHelper.isEmpty(re.getGuid()) || StringHelper.isEmpty(re.getType()) || StringHelper.isEmpty(re.getCode())) {
|
return;
|
}
|
|
UserEntity ue = tokenService.getCurrentUser(req);
|
|
reportService.createReport(ue, re, res);
|
} catch (Exception ex) {
|
log.error(ex.getMessage(), ex);
|
}
|
}
|
}
|