Commit f6e2174c authored by neo's avatar neo

[dev] bugfix and download report sheet impl

parent 5f760aa4
...@@ -367,6 +367,13 @@ ...@@ -367,6 +367,13 @@
<artifactId>activiti-rest</artifactId> <artifactId>activiti-rest</artifactId>
<version>${activiti.version}</version> <version>${activiti.version}</version>
</dependency> </dependency>
<!-- https://mvnrepository.com/artifact/com.grapecity.documents/gcexcel -->
<dependency>
<groupId>com.grapecity.documents</groupId>
<artifactId>gcexcel</artifactId>
<version>2.0.0</version>
</dependency>
</dependencies> </dependencies>
<profiles> <profiles>
......
...@@ -3,6 +3,7 @@ package pwc.taxtech.atms.controller; ...@@ -3,6 +3,7 @@ package pwc.taxtech.atms.controller;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import pwc.taxtech.atms.constant.enums.EnumServiceType; import pwc.taxtech.atms.constant.enums.EnumServiceType;
import pwc.taxtech.atms.dpo.ReportDto; import pwc.taxtech.atms.dpo.ReportDto;
...@@ -21,6 +22,11 @@ public class ReportController { ...@@ -21,6 +22,11 @@ public class ReportController {
@Autowired @Autowired
ReportServiceImpl reportService; ReportServiceImpl reportService;
@RequestMapping(value = "export", method = RequestMethod.POST)
public ResponseEntity getExportFile(ReportExportDto report) {
return ResponseEntity.ok(reportService.export(report.getReportData(), "~"));
}
@RequestMapping(value = "template/{projectId}/{serviceType}/{period}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE) @RequestMapping(value = "template/{projectId}/{serviceType}/{period}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public OperationResultDto<List<ReportDto>> getTemplate(@PathVariable String projectId, @PathVariable int serviceType, @PathVariable Integer period) { public OperationResultDto<List<ReportDto>> getTemplate(@PathVariable String projectId, @PathVariable int serviceType, @PathVariable Integer period) {
return reportService.getReportTemplate(projectId, EnumServiceType.getEnumByCode(serviceType), period); return reportService.getReportTemplate(projectId, EnumServiceType.getEnumByCode(serviceType), period);
...@@ -128,7 +134,9 @@ public class ReportController { ...@@ -128,7 +134,9 @@ public class ReportController {
} }
@RequestMapping(value = "hasManualDataSource/{projectId}/{period}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE) @RequestMapping(value = "hasManualDataSource/{projectId}/{period}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public Boolean hasManualDataSource(@PathVariable String projectId, @PathVariable Integer period) { public Boolean hasManualDataSource(@PathVariable String projectId, @PathVariable Integer period) {
return reportService.hasManualDataSource(projectId,period); return reportService.hasManualDataSource(projectId, period);
} }
} }
\ No newline at end of file
package pwc.taxtech.atms.dto.vatdto;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Getter;
import lombok.Setter;
@Setter
@Getter
public class ReportExportDto {
@JsonProperty("ReportType")
private String reportType;
@JsonProperty("ReportData")
private String reportData;
}
...@@ -2,6 +2,7 @@ package pwc.taxtech.atms.vat.service.impl; ...@@ -2,6 +2,7 @@ package pwc.taxtech.atms.vat.service.impl;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.grapecity.documents.excel.Workbook;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.reflections.util.Utils; import org.reflections.util.Utils;
import org.slf4j.Logger; import org.slf4j.Logger;
...@@ -27,6 +28,10 @@ import pwc.taxtech.atms.vat.dpo.InputVATInvoiceItemExtendDto; ...@@ -27,6 +28,10 @@ import pwc.taxtech.atms.vat.dpo.InputVATInvoiceItemExtendDto;
import pwc.taxtech.atms.vat.entity.*; import pwc.taxtech.atms.vat.entity.*;
import pwc.taxtech.atms.vat.service.impl.report.functions.FormulaHelper; import pwc.taxtech.atms.vat.service.impl.report.functions.FormulaHelper;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.*; import java.util.*;
import java.util.regex.Matcher; import java.util.regex.Matcher;
...@@ -1220,4 +1225,17 @@ public class ReportServiceImpl { ...@@ -1220,4 +1225,17 @@ public class ReportServiceImpl {
public Boolean hasManualDataSource(String projectId, Integer period) { public Boolean hasManualDataSource(String projectId, Integer period) {
return periodReportMapper.hasManualDataSource(projectId, period) > 0; return periodReportMapper.hasManualDataSource(projectId, period) > 0;
} }
public String export(String reportData, String serverPath) {
String filePath = String.format("GeneratedReports\tt_{0}.xlsx", UUID.randomUUID().toString());
String fullFilePath = combine(serverPath, filePath);
Workbook workbook = new Workbook();
workbook.fromJson(reportData);
workbook.save(fullFilePath);
return filePath;
}
private String combine(String parent, String child) {
return String.format("%s" + File.separator + "%s", parent, child);
}
} }
...@@ -1016,17 +1016,17 @@ ...@@ -1016,17 +1016,17 @@
function exportSpread(exportReportData) { function exportSpread(exportReportData) {
$scope.exportReportData = exportReportData; $scope.exportReportData = exportReportData;
$timeout(function () { $timeout(function () {
var mainSpread = new GcSpread.Sheets.Spread(document.getElementById("export"), {sheetCount: 1}); var mainSpread = new GC.Spread.Sheets.Workbook(document.getElementById("export"), {sheetCount: 1});
mainSpread.isPaintSuspended(true); mainSpread.isPaintSuspended(true);
mainSpread.sheets.pop(); mainSpread.sheets.pop();
for (var index = 0; index < $scope.spreads.length; index++) { for (var index = 0; index < $scope.spreads.length; index++) {
var currentSheet = $scope.spreads[index].getActiveSheet(); var currentSheet = $scope.spreads[index].getActiveSheet();
currentSheet.setIsProtected(false); currentSheet.options.isProtected=false;
for (var rowIndex = 0; rowIndex < currentSheet.getRowCount(); rowIndex++) { for (var rowIndex = 0; rowIndex < currentSheet.getRowCount(); rowIndex++) {
for (var columnIndex = 0; columnIndex < currentSheet.getColumnCount(); columnIndex++) { for (var columnIndex = 0; columnIndex < currentSheet.getColumnCount(); columnIndex++) {
var cellStyle = currentSheet.getActualStyle(rowIndex, columnIndex, GcSpread.Sheets.SheetArea.viewport, true); var cellStyle = currentSheet.getActualStyle(rowIndex, columnIndex, GC.Spread.Sheets.SheetArea.viewport, true);
currentSheet.setStyle(rowIndex, columnIndex, cellStyle, GcSpread.Sheets.SheetArea.viewport); currentSheet.setStyle(rowIndex, columnIndex, cellStyle, GC.Spread.Sheets.SheetArea.viewport);
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment