|
@@ -0,0 +1,90 @@
|
|
|
+package org.jeecg.modules.report.controller;
|
|
|
+
|
|
|
+import io.swagger.annotations.Api;
|
|
|
+import io.swagger.annotations.ApiImplicitParam;
|
|
|
+import io.swagger.annotations.ApiImplicitParams;
|
|
|
+import io.swagger.annotations.ApiModelProperty;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
|
|
+import org.apache.poi.ss.usermodel.Workbook;
|
|
|
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
|
|
+import org.jeecg.common.api.vo.Result;
|
|
|
+import org.jeecg.common.dto.report.CostAccountingReqDTO;
|
|
|
+import org.jeecg.common.dto.report.CostAccountingRespDTO;
|
|
|
+import org.jeecg.modules.report.service.ProReportService;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.core.io.FileSystemResource;
|
|
|
+import org.springframework.core.io.Resource;
|
|
|
+import org.springframework.web.bind.annotation.GetMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
+import java.io.File;
|
|
|
+import java.io.FileOutputStream;
|
|
|
+import java.io.IOException;
|
|
|
+import java.io.InputStream;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+@Api("报表")
|
|
|
+@RestController
|
|
|
+@RequestMapping("/report")
|
|
|
+@Slf4j
|
|
|
+public class ProReportController {
|
|
|
+ @Autowired
|
|
|
+ private ProReportService proReportService;
|
|
|
+
|
|
|
+
|
|
|
+ @RequestMapping("/export")
|
|
|
+ public void exportExcel() throws IOException {
|
|
|
+ Resource resource=new FileSystemResource("C:/Users/zs/Desktop/翠颠项目/项目/04项目管理软件—报表.xlsx");
|
|
|
+ String fileName = resource.getFilename();
|
|
|
+ String suffix = fileName.substring(fileName.lastIndexOf(".") + 1);
|
|
|
+ InputStream ins = resource.getInputStream();
|
|
|
+ Workbook wb = null;
|
|
|
+ if(suffix.equals("xlsx")) {
|
|
|
+ wb = new XSSFWorkbook(ins);
|
|
|
+ } else {
|
|
|
+ wb = new HSSFWorkbook(ins);
|
|
|
+ }
|
|
|
+
|
|
|
+ File file = new File("D:/", fileName);
|
|
|
+ wb.write(new FileOutputStream(file));
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiModelProperty("获取成本核算数据")
|
|
|
+ @ApiImplicitParams({
|
|
|
+ @ApiImplicitParam(name="id", value="id",required=true, dataType="String"),
|
|
|
+ @ApiImplicitParam(name="pkOrg", value="组织",required=true, dataType="String")
|
|
|
+ })
|
|
|
+ @GetMapping("/getCostAccountingData")
|
|
|
+ public Result<List<CostAccountingRespDTO> > getCostAccountingData(CostAccountingReqDTO reqDTO) {
|
|
|
+ Result<List<CostAccountingRespDTO>> result = new Result<>();
|
|
|
+ try {
|
|
|
+ List<CostAccountingRespDTO> respDTOS = proReportService.getCostAccountingData(reqDTO);
|
|
|
+ result.setResult(respDTOS);
|
|
|
+ result.setSuccess(true);
|
|
|
+ }catch (Exception e){
|
|
|
+ log.info(e.getMessage());
|
|
|
+ e.printStackTrace();
|
|
|
+ result.error500("警告:" + e.getMessage());
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ @ApiModelProperty("项目情况统计表")
|
|
|
+ @GetMapping("/getProStatistics")
|
|
|
+ public Result<List<CostAccountingRespDTO> > getProStatistics(CostAccountingReqDTO reqDTO) {
|
|
|
+ Result<List<CostAccountingRespDTO>> result = new Result<>();
|
|
|
+ try {
|
|
|
+ List<CostAccountingRespDTO> respDTOS = proReportService.getProStatistics(reqDTO);
|
|
|
+ result.setResult(respDTOS);
|
|
|
+ result.setSuccess(true);
|
|
|
+ }catch (Exception e){
|
|
|
+ log.info(e.getMessage());
|
|
|
+ e.printStackTrace();
|
|
|
+ result.error500("警告:" + e.getMessage());
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+}
|