Commit f420df40 authored by chase's avatar chase

fix bug

parent b0fb167b
...@@ -9,14 +9,18 @@ import org.apache.commons.collections.CollectionUtils; ...@@ -9,14 +9,18 @@ import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.poi.ss.usermodel.CellType; import org.apache.poi.ss.usermodel.CellType;
import org.apache.poi.ss.usermodel.DateUtil; import org.apache.poi.ss.usermodel.DateUtil;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.ss.usermodel.WorkbookFactory;
import org.apache.poi.xssf.usermodel.XSSFCell; import org.apache.poi.xssf.usermodel.XSSFCell;
import org.apache.poi.xssf.usermodel.XSSFRow; import org.apache.poi.xssf.usermodel.XSSFRow;
import org.apache.poi.xssf.usermodel.XSSFSheet; import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook; import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import pwc.taxtech.atms.common.POIUtil;
import pwc.taxtech.atms.common.PageResultVo; import pwc.taxtech.atms.common.PageResultVo;
import pwc.taxtech.atms.common.util.DateUtils; import pwc.taxtech.atms.common.util.DateUtils;
import pwc.taxtech.atms.constant.enums.FileUploadEnum; import pwc.taxtech.atms.constant.enums.FileUploadEnum;
...@@ -24,6 +28,7 @@ import pwc.taxtech.atms.dpo.OrgSelectDto; ...@@ -24,6 +28,7 @@ import pwc.taxtech.atms.dpo.OrgSelectDto;
import pwc.taxtech.atms.dto.TaxDocumentDto; import pwc.taxtech.atms.dto.TaxDocumentDto;
import pwc.taxtech.atms.entity.TaxDocument; import pwc.taxtech.atms.entity.TaxDocument;
import pwc.taxtech.atms.service.impl.DidiFileUploadService; import pwc.taxtech.atms.service.impl.DidiFileUploadService;
import pwc.taxtech.atms.service.impl.HttpFileService;
import pwc.taxtech.atms.service.impl.OrganizationServiceImpl; import pwc.taxtech.atms.service.impl.OrganizationServiceImpl;
import pwc.taxtech.atms.service.impl.TaxDocumentServiceImpl; import pwc.taxtech.atms.service.impl.TaxDocumentServiceImpl;
import pwc.taxtech.atms.thirdparty.ExcelUtil; import pwc.taxtech.atms.thirdparty.ExcelUtil;
...@@ -48,6 +53,8 @@ public class TaxDocumentController { ...@@ -48,6 +53,8 @@ public class TaxDocumentController {
private DidiFileUploadService didiFileUploadService; private DidiFileUploadService didiFileUploadService;
@Autowired @Autowired
private OrganizationServiceImpl organizationService; private OrganizationServiceImpl organizationService;
@Autowired
HttpFileService httpFileService;
@PostMapping("selectList") @PostMapping("selectList")
@ResponseBody @ResponseBody
public PageResultVo<TaxDocument> selectTaxDocumentList(@RequestBody TaxDocumentDto taxDocumentDto) { public PageResultVo<TaxDocument> selectTaxDocumentList(@RequestBody TaxDocumentDto taxDocumentDto) {
...@@ -394,4 +401,37 @@ public class TaxDocumentController { ...@@ -394,4 +401,37 @@ public class TaxDocumentController {
dataArray.add(sheetJson); dataArray.add(sheetJson);
} }
} }
@RequestMapping(value = "/convertExcel", method = RequestMethod.POST,
produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@ResponseBody
public void convertExcel(HttpServletResponse response,String url){
InputStream is = null;
Workbook tWorkbook = null;
Workbook workbook = new XSSFWorkbook();
OutputStream ouputStream = null;
try{
is = httpFileService.getUserTemplate(url);
tWorkbook = WorkbookFactory.create(is);
for(int i = 0;i<tWorkbook.getNumberOfSheets();i++){
POIUtil.cloneSheet(tWorkbook.getSheetAt(i), workbook.createSheet(tWorkbook.getSheetAt(i).getSheetName()));
}
response.setContentType("multipart/form-data");
ouputStream = response.getOutputStream();
tWorkbook.write(ouputStream);
}catch (Exception e){
e.printStackTrace();
}finally {
try {
if (ouputStream != null) {
ouputStream.close();
}
if(is!=null){
is.close();
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
} }
...@@ -52,51 +52,63 @@ public class KPSR extends FunctionBase implements FreeRefFunction { ...@@ -52,51 +52,63 @@ public class KPSR extends FunctionBase implements FreeRefFunction {
private double assembleData(String revenueTypeName, List<OutputInvoiceDataSourceDto> contain, Integer billType, Integer amountType, OperationEvaluationContext ec) { private double assembleData(String revenueTypeName, List<OutputInvoiceDataSourceDto> contain, Integer billType, Integer amountType, OperationEvaluationContext ec) {
String queryDate = formulaContext.getYear() + (formulaContext.getPeriod() < 10 ? ("0" + formulaContext.getPeriod()) : (formulaContext.getPeriod() + "")); String queryDate = formulaContext.getYear() + (formulaContext.getPeriod() < 10 ? ("0" + formulaContext.getPeriod()) : (formulaContext.getPeriod() + ""));
// RevenueTypeMappingExample typeMappingExample = new RevenueTypeMappingExample();
// typeMappingExample.createCriteria().andOrgIdEqualTo(formulaContext.getOrganizationId())
// .andRevenueTypeNameEqualTo(revenueTypeName).andStartDateLessThanOrEqualTo(queryDate)
// .andEndDateGreaterThanOrEqualTo(queryDate);
// List<RevenueTypeMapping> typeMappingList = SpringContextUtil.revenueTypeMappingMapper.selectByExample(typeMappingExample);
// if (CollectionUtils.isEmpty(typeMappingList)) {
// return 0.0;
// }
// List<String> revenueTypes = typeMappingList.stream() // List<String> revenueTypes = typeMappingList.stream()
// .map(o -> o.getRevenueTypeName()).collect(Collectors.toList()); // .map(o -> o.getRevenueTypeName()).collect(Collectors.toList());
RevenueConfigExample configExample = new RevenueConfigExample(); RevenueConfigExample configExample = new RevenueConfigExample();
configExample.createCriteria().andOrgIdEqualTo(formulaContext.getOrganizationId()).andStartDateLessThanOrEqualTo(queryDate) configExample.createCriteria().andOrgIdEqualTo(formulaContext.getOrganizationId()).andStartDateLessThanOrEqualTo(queryDate)
.andEndDateGreaterThanOrEqualTo(queryDate).andNameEqualTo(revenueTypeName); .andEndDateGreaterThanOrEqualTo(queryDate).andNameEqualTo(revenueTypeName).andStatusEqualTo(0);
List<RevenueConfig> configDatas = SpringContextUtil.revenueConfigMapper.selectByExample(configExample); List<RevenueConfig> configDatas = SpringContextUtil.revenueConfigMapper.selectByExample(configExample);
if (CollectionUtils.isEmpty(configDatas)) { if (CollectionUtils.isEmpty(configDatas)) {
return 0.0; return 0.0;
} }
RevenueTypeMappingExample typeMappingExample = new RevenueTypeMappingExample();
typeMappingExample.createCriteria().andOrgIdEqualTo(formulaContext.getOrganizationId())
.andRevenueTypeNameEqualTo(revenueTypeName).andStartDateLessThanOrEqualTo(queryDate)
.andEndDateGreaterThanOrEqualTo(queryDate).andStatusEqualTo(0);
List<RevenueTypeMapping> typeMappingList = SpringContextUtil.revenueTypeMappingMapper.selectByExample(typeMappingExample);
if (CollectionUtils.isEmpty(typeMappingList)) {
return 0.0;
}
List<Long> revenueTypeIds = configDatas.stream() List<Long> revenueTypeIds = configDatas.stream()
.map(o -> o.getId()).collect(Collectors.toList()); .map(o -> o.getId()).collect(Collectors.toList());
List<InvoiceRecord> billDetails = new ArrayList<>(); List<InvoiceRecord> billDetails = new ArrayList<>();
InvoiceRecordExample invoiceRecordExample = null;
InvoiceRecordExample invoiceRecordExample = new InvoiceRecordExample(); for(RevenueTypeMapping typeMapping:typeMappingList){
invoiceRecordExample.createCriteria().andRevenueCofIdIn(revenueTypeIds) invoiceRecordExample = new InvoiceRecordExample();
.andProjectIdEqualTo(formulaContext.getProjectId()) invoiceRecordExample.createCriteria().andRevenueCofIdIn(revenueTypeIds)
.andPeriodEqualTo(Integer.valueOf(queryDate)) .andProjectIdEqualTo(formulaContext.getProjectId())
.andInvoiceTypeEqualTo(InvoiceRecordEnum.InvoiceType.MAPPING.get(billType)); .andPeriodEqualTo(Integer.valueOf(queryDate))
List<InvoiceRecord> billDetails1 = SpringContextUtil.invoiceRecordMapper.selectByExample(invoiceRecordExample); .andTaxRateEqualTo(typeMapping.getTaxRate())
if(CollectionUtils.isNotEmpty(billDetails1)){ .andDepartmentEqualTo(typeMapping.getOuName())
Iterator<InvoiceRecord> iterator = billDetails1.iterator(); .andInvoiceTypeEqualTo(InvoiceRecordEnum.InvoiceType.MAPPING.get(billType));
while (iterator.hasNext()){ List<InvoiceRecord> billDetails1 = SpringContextUtil.invoiceRecordMapper.selectByExample(invoiceRecordExample);
if(iterator.next().getModifyRevenueCofId()!=null){ if(CollectionUtils.isNotEmpty(billDetails1)){
iterator.remove(); Iterator<InvoiceRecord> iterator = billDetails1.iterator();
while (iterator.hasNext()){
if(iterator.next().getModifyRevenueCofId()!=null){
iterator.remove();
}
} }
billDetails.addAll(billDetails1);
}
invoiceRecordExample = new InvoiceRecordExample();
invoiceRecordExample.createCriteria().andModifyRevenueCofIdIn(revenueTypeIds)
.andProjectIdEqualTo(formulaContext.getProjectId())
.andPeriodEqualTo(Integer.valueOf(queryDate))
.andTaxRateEqualTo(typeMapping.getTaxRate())
.andDepartmentEqualTo(typeMapping.getOuName())
.andInvoiceTypeEqualTo(InvoiceRecordEnum.InvoiceType.MAPPING.get(billType));
List<InvoiceRecord> billDetails2 = SpringContextUtil.invoiceRecordMapper.selectByExample(invoiceRecordExample);
if(CollectionUtils.isNotEmpty(billDetails2)){
billDetails.addAll(billDetails2);
} }
billDetails.addAll(billDetails1);
}
invoiceRecordExample = new InvoiceRecordExample();
invoiceRecordExample.createCriteria().andModifyRevenueCofIdIn(revenueTypeIds)
.andProjectIdEqualTo(formulaContext.getProjectId())
.andPeriodEqualTo(Integer.valueOf(queryDate))
.andInvoiceTypeEqualTo(InvoiceRecordEnum.InvoiceType.MAPPING.get(billType));
List<InvoiceRecord> billDetails2 = SpringContextUtil.invoiceRecordMapper.selectByExample(invoiceRecordExample);
if(CollectionUtils.isNotEmpty(billDetails2)){
billDetails.addAll(billDetails2);
} }
for (InvoiceRecord invoiceRecord : billDetails) { for (InvoiceRecord invoiceRecord : billDetails) {
OutputInvoiceDataSourceDto outputInvoiceDataSourceDto = new OutputInvoiceDataSourceDto(); OutputInvoiceDataSourceDto outputInvoiceDataSourceDto = new OutputInvoiceDataSourceDto();
outputInvoiceDataSourceDto.setAmount(FormulaHelper.roundValue(invoiceRecord.getInvoiceAmount(), outputInvoiceDataSourceDto.setAmount(FormulaHelper.roundValue(invoiceRecord.getInvoiceAmount(),
......
...@@ -1406,8 +1406,8 @@ taxDocumentManageModule.directive('filePreview', function () { ...@@ -1406,8 +1406,8 @@ taxDocumentManageModule.directive('filePreview', function () {
var fileType = fileName.split(".").pop(); var fileType = fileName.split(".").pop();
if (/xlsx|xls/i.test(fileType)) { if (/xlsx|xls/i.test(fileType)) {
$('#busy-indicator-container').show();
taxDocumentListService.viewExcelBySpread(filePositionUrl).then(function (reportSpread) { taxDocumentListService.viewExcelBySpread(fileType,filePositionUrl).then(function (reportSpread) {
var spreadCtrl = new GC.Spread.Sheets.Workbook(document.getElementById("excetlContainer")); var spreadCtrl = new GC.Spread.Sheets.Workbook(document.getElementById("excetlContainer"));
if (spreadCtrl) { if (spreadCtrl) {
spreadCtrl.destroy(); spreadCtrl.destroy();
...@@ -1416,10 +1416,11 @@ taxDocumentManageModule.directive('filePreview', function () { ...@@ -1416,10 +1416,11 @@ taxDocumentManageModule.directive('filePreview', function () {
if (!_.isEmpty(reportSpread)) { if (!_.isEmpty(reportSpread)) {
initSpreadExcel(reportSpread).then(function (spread) { initSpreadExcel(reportSpread).then(function (spread) {
/* return locateCell(spread, true);*/ /* return locateCell(spread, true);*/
$('#busy-indicator-container').hide();
}); });
} }
}, function (data) { }, function (data) {
$('#busy-indicator-container').hide();
$log.info(data); $log.info(data);
}); });
} }
...@@ -1441,49 +1442,49 @@ taxDocumentManageModule.directive('filePreview', function () { ...@@ -1441,49 +1442,49 @@ taxDocumentManageModule.directive('filePreview', function () {
var initSpreadExcel = function (reportSpread) { var initSpreadExcel = function (reportSpread) {
$("#filePreviewPop").modal("show"); $("#filePreviewPop").modal("show");
var spread = new GC.Spread.Sheets.Workbook(document.getElementById("excetlContainer")); var spread = new GC.Spread.Sheets.Workbook(document.getElementById("excetlContainer"));
spread.suspendPaint(); // spread.suspendPaint();
spread.fromJSON(reportSpread); spread.fromJSON(reportSpread);
spread.options.showVerticalScrollbar = true; // spread.options.showVerticalScrollbar = true;
spread.options.showHorizontalScrollbar = true; // spread.options.showHorizontalScrollbar = true;
spread.options.scrollbarMaxAlign = true; // spread.options.scrollbarMaxAlign = true;
spread.options.scrollbarShowMax = true; // spread.options.scrollbarShowMax = true;
spread.options.tabNavigationVisible = true; // spread.options.tabNavigationVisible = true;
if (constant.regesterInformation.active) { // if (constant.regesterInformation.active) {
spread.options.tabEditable = false; // spread.options.tabEditable = false;
spread.options.tabStripVisible = false; // spread.options.tabStripVisible = false;
spread.options.newTabVisible = false; // spread.options.newTabVisible = false;
} // }
spread.options.allowUndo = false; // spread.options.allowUndo = false;
spread.options.allowUserResize = false; // spread.options.allowUserResize = false;
spread.options.allowUserDragDrop = false; // spread.options.allowUserDragDrop = false;
spread.options.allowUserDragFill = false; // spread.options.allowUserDragFill = false;
spread.options.allowUserEditFormula = false; // spread.options.allowUserEditFormula = false;
spread.options.allowContextMenu = false; // spread.options.allowContextMenu = false;
//todo:注册之后这里去掉注释 // //todo:注册之后这里去掉注释
//var sheet = spread.getActiveSheet(); // //var sheet = spread.getActiveSheet();
//
var sheet; // var sheet;
if (constant.regesterInformation.active) { // if (constant.regesterInformation.active) {
sheet = spread.getActiveSheet(); // sheet = spread.getActiveSheet();
} else { // } else {
sheet = spread.getSheet(1); // sheet = spread.getSheet(1);
} // }
if (sheet != null) { // if (sheet != null) {
sheet.options.rowHeaderVisible = true; // sheet.options.rowHeaderVisible = true;
sheet.options.colHeaderVisible = true; // sheet.options.colHeaderVisible = true;
sheet.options.gridline.showVerticalGridline = true; // sheet.options.gridline.showVerticalGridline = true;
sheet.options.gridline.showHorizontalGridline = true; // sheet.options.gridline.showHorizontalGridline = true;
sheet.options.isProtected = true; // sheet.options.isProtected = true;
sheet.clearSelection(); // sheet.clearSelection();
}
// setColWidth(sheet);
// if(sheet.getRowCount() <= 38)
// scope.relation.addEbitRow(sheet)
// if (scope.templateId && scope.reportSource) {
// setData();
// } // }
sheet.setRowResizable(0, false, GC.Spread.Sheets.SheetArea.viewport); // // setColWidth(sheet);
spread.resumePaint(); // // if(sheet.getRowCount() <= 38)
// // scope.relation.addEbitRow(sheet)
// // if (scope.templateId && scope.reportSource) {
// // setData();
// // }
// sheet.setRowResizable(0, false, GC.Spread.Sheets.SheetArea.viewport);
// spread.resumePaint();
return $q.when(spread); return $q.when(spread);
}; };
......
...@@ -183,12 +183,17 @@ taxDocumentManageModule.factory('taxDocumentListService', ...@@ -183,12 +183,17 @@ taxDocumentManageModule.factory('taxDocumentListService',
return defer.promise; return defer.promise;
}, },
viewExcelBySpread:function (url) { viewExcelBySpread:function (fileType,url) {
var deferred = $q.defer(); var deferred = $q.defer();
var promise = deferred.promise; var promise = deferred.promise;
var xhr = new XMLHttpRequest(); var xhr = new XMLHttpRequest();
xhr.open('GET', url, true); // 也可以使用POST方式,根据接口 if("xls"==fileType){
xhr.open('POST', apiInterceptor.webApiHostUrl + '/taxDoc/convertExcel', true);
xhr.setRequestHeader("Authorization", apiInterceptor.tokenType + ' ' + apiInterceptor.apiToken());
}else{
xhr.open('GET', url, true);
}
xhr.responseType = "blob"; // 返回类型blob xhr.responseType = "blob"; // 返回类型blob
// 定义请求完成的处理函数,请求前也可以增加加载框/禁用下载按钮逻辑 // 定义请求完成的处理函数,请求前也可以增加加载框/禁用下载按钮逻辑
xhr.onload = function () { xhr.onload = function () {
...@@ -207,7 +212,9 @@ taxDocumentManageModule.factory('taxDocumentListService', ...@@ -207,7 +212,9 @@ taxDocumentManageModule.factory('taxDocumentListService',
} }
}; };
// 发送ajax请求 // 发送ajax请求
xhr.send(); var data=new FormData();
data.append("url",url);
xhr.send(data);
return promise; return promise;
} }
}; };
......
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