Commit 9e20505d authored by Memorydoc's avatar Memorydoc

#

parent 2fcfd9ca
......@@ -9,11 +9,16 @@ package pwc.taxtech.atms.common.util;
**/
import com.google.common.collect.Lists;
import org.apache.poi.ss.usermodel.Workbook;
import org.activiti.engine.ProcessEngine;
import org.activiti.engine.ProcessEngineConfiguration;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.xssf.streaming.SXSSFSheet;
import org.nutz.http.Http;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import sun.misc.BASE64Encoder;
import javax.servlet.ServletContext;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
......@@ -69,7 +74,7 @@ public class FileExcelUtil {
* @param path
* @throws IOException
*/
public static File craeteZipPath(String path) throws IOException {
public static File createZip(String path) throws IOException {
ZipOutputStream zipOutputStream = null;
File file = new File(path + DateUtils.nowDateFormat() + ".zip");
zipOutputStream = new ZipOutputStream(new BufferedOutputStream(new FileOutputStream(file)));
......@@ -102,7 +107,6 @@ public class FileExcelUtil {
}
/**
* 设置下载excel的响应头信息
*
......@@ -158,7 +162,7 @@ public class FileExcelUtil {
* @param workbook
* @time 2018年6月25日11:47:07
*/
private void downloadExcel(HttpServletRequest request, HttpServletResponse response, String fileName, Workbook workbook) {
public static void downloadExcel(HttpServletRequest request, HttpServletResponse response, String fileName, Workbook workbook) {
//一个流两个头
//设置下载excel的头信息
FileExcelUtil.setExcelHeadInfo(response, request, fileName);
......@@ -191,23 +195,20 @@ public class FileExcelUtil {
* 生成excel到指定路径
*
* @param wb
* @Param path 文件路径,包括zip文件夹路径
* @throws Exception
* @Param path 文件路径,包括zip文件夹路径
*/
public static File generateExcelToPath(Workbook wb, String path) throws Exception {
/* String[] pathArr = path.split("\\\\");
String zipDir = pathArr[0];
FileExcelUtil.createFile(zipDir);*/
File file = new File(path);
public static File generateExcelToPath(Workbook wb, String fileNamet) throws Exception {
File file = new File(fileNamet);
FileOutputStream fos = null;
try {
fos = new FileOutputStream(file);
wb.write(fos);
return file;
}catch (Exception e ){
return file;
} catch (Exception e) {
e.printStackTrace();
return null;
}finally {
return null;
} finally {
if (fos != null) {
fos.flush();
fos.close();
......@@ -225,18 +226,18 @@ public class FileExcelUtil {
* @param response
* @param zipName 下载的zip名
* @param files 要打包的批量文件
* @param zipPath 生成的zip路径
* @param zipDir 存放zip文件的文件夹路径
* @throws Exception
*/
public static synchronized void downloadZip(HttpServletRequest request, HttpServletResponse response, String zipName, List<File> files, String zipPath) throws Exception {
public static synchronized void downloadZip(HttpServletRequest request, HttpServletResponse response, String zipName, List<File> files, String zipDir) throws Exception {
//ZIPPATH = this.getClass().getResource("/").getPath().substring(1) + "zipDir";
FileExcelUtil.createFile(zipDir);// 先生成存放zip文件的文件夹
String zipPath = zipDir + "/" + Math.random() + ".zip";
File srcfile[] = new File[files.size()];
File zip = new File(zipPath);
for (int i = 0; i < files.size(); i++) {
srcfile[i] = files.get(i);
}
//生成.zip文件;
//File zip = craeteZipPath(zipPath);
FileInputStream inStream = null;
ServletOutputStream os = null;
try {
......@@ -310,4 +311,65 @@ public class FileExcelUtil {
// 目录此时为空,可以删除
return dir.delete();
}
/**
* 删除列
* @param sheet
* @param columnToDelete
* @param cols 制定哪些行不进行列偏移
*/
public static void deleteColumn(Sheet sheet, int columnToDelete, List<Integer> cols) {
for (int rId = 0; rId <= sheet.getLastRowNum(); rId++) {
Row row = sheet.getRow(rId);
for (int cID = columnToDelete; cID <= row.getLastCellNum(); cID++) {
Cell cOld = row.getCell(cID);
if (cOld != null) {
row.removeCell(cOld);
}
Cell cNext = row.getCell(cID + 1);
if (cNext != null) {
Cell cNew = row.createCell(cID, cNext.getCellTypeEnum());
if(cols.contains(cID))
continue;
cloneCell(cNew, cNext);
//Set the column width only on the first row.
//Other wise the second row will overwrite the original column width set previously.
if (rId == 0) {
sheet.setColumnWidth(cID, sheet.getColumnWidth(cID + 1));
}
}
}
}
}
/**
* 右边列左移
* @param cNew
* @param cOld
*/
public static void cloneCell(Cell cNew, Cell cOld) {
try{
cNew.setCellComment(cOld.getCellComment());
cNew.setCellStyle(cOld.getCellStyle());
String stringCellValue = cOld.getStringCellValue();
if("".equals(stringCellValue))
return;
if (CellType.BOOLEAN == cNew.getCellTypeEnum()) {
cNew.setCellValue(cOld.getBooleanCellValue());
} else if (CellType.NUMERIC == cNew.getCellTypeEnum()) {
cNew.setCellValue(cOld.getNumericCellValue());
} else if (CellType.STRING == cNew.getCellTypeEnum()) {
cNew.setCellValue(cOld.getStringCellValue());
} else if (CellType.ERROR == cNew.getCellTypeEnum()) {
cNew.setCellValue(cOld.getErrorCellValue());
} else if (CellType.FORMULA == cNew.getCellTypeEnum()) {
cNew.setCellValue(cOld.getCellFormula());
}
}catch (Exception e){
logger.warn("数据转换异常", e.getMessage());
}
}
}
\ No newline at end of file
......@@ -170,7 +170,7 @@ public class ReportController {
resultDto.setResult(false);
return resultDto;
}*/
operationResultDto = reportService.getCellData(Long.parseLong(requestParameterDto.getReportId()), requestParameterDto.getOrgId(), requestParameterDto.getPeriod());
operationResultDto = reportService.getCellData(requestParameterDto.getReportId(), requestParameterDto.getOrgId(), requestParameterDto.getPeriod());
return operationResultDto;
}
......@@ -352,7 +352,8 @@ public class ReportController {
}catch (Exception e){
return operationResultDto.error();
}
return operationResultDto.success();
operationResultDto.setResultMsg("success");
return operationResultDto;
}
/**
* 批量导出利润表
......@@ -360,9 +361,8 @@ public class ReportController {
@RequestMapping("manyExport")
public OperationResultDto manyExport(@RequestBody RequestParameterDto requestParameterDto, HttpServletResponse response, HttpServletRequest request) throws Exception {
OperationResultDto operationResultDto = new OperationResultDto();
String zipName = "利润表";
try {
reportService.manyExport(requestParameterDto, zipName,request, response);
reportService.manyExport(requestParameterDto,request, response);
} catch (Exception e) {
e.printStackTrace();
operationResultDto.error(e.getMessage());
......
......@@ -365,7 +365,9 @@ public class TemplateController extends BaseController {
} else {
templates = templateService.getPeriodTemplates(templateId, period, projectId);
}
if(templates.size() == 0){
templates = templateService.getTemplates(templateId);
}
MyAsserts.assertNotEmpty(templates, new NotFoundException());
PeriodTemplate template = templates.get(0);
String templatePath = template.getPath();
......
......@@ -13,7 +13,7 @@ import java.io.Serializable;
public class RequestParameterDto implements Serializable {
private String jsonString;//excel传过来的数据 已经被序列化成字符串了
private Integer specialConsiderations;
private String specialConsiderations;
private String ebitRate;
public String orgId;
......@@ -30,11 +30,11 @@ public class RequestParameterDto implements Serializable {
this.jsonString = jsonString;
}
public Integer getSpecialConsiderations() {
public String getSpecialConsiderations() {
return specialConsiderations;
}
public void setSpecialConsiderations(Integer specialConsiderations) {
public void setSpecialConsiderations(String specialConsiderations) {
this.specialConsiderations = specialConsiderations;
}
......
This diff is collapsed.
......@@ -81,6 +81,7 @@ grunt.initConfig({
},
contentCss: {
src: ["Content/bootstrap.css",
"Content/bootstrap-select.min.css",
"Content/bootstrap-switch/bootstrap3/bootstrap-switch.css",
"Content/dx.common.css",
"Content/dx.light.css",
......@@ -209,6 +210,7 @@ grunt.initConfig({
"Scripts/bootstrap-multiselect.js",
"Scripts/bootstrap-datepicker/bootstrap-datepicker.js",
"Scripts/locales/bootstrap-datepicker.zh-CN.min.js",
"Scripts/bootstrap-select.min.js",
"Scripts/respond.js"],
dest: '<%= pkg.bundleTemp %>/bootstrap.js'
},
......
This diff is collapsed.
......@@ -13,7 +13,7 @@
<div class="form-group" ng-style="setButtonWrapStyle()" style="width:100%;">
<div class="import-wrapper" style="margin-left: 17px;">
<div class="row" style="margin-top: 10px;">
<div class="col-sm-7">
<div class="col-sm-6" style="padding-left: 0px!important;">
<span class="text-bold" translate="SelectedImportType"></span>:
<div class="dropdown" style="margin-left:10px">
<button class="btn btn-default dropdown-toggle" type="button" id="dropdownMenu2"
......@@ -36,7 +36,7 @@
<i class="fa fa-calendar imp-subheader red-color" style="width:20px;"></i>
</div>
</div>
<div class="col-sm-5" style="width:60%;padding-left: 0px;">
<div class="col-sm-5 rightNav" style="width:46%;padding-left: 0px; left: 20%;">
<button type="button"
ngf-select="" type="file" ng-model="importExcelFile" ngf-drag-over-class="'dragover'" accept=".xls,.xlsx" ngf-multiple="false"
ngf-allow-dir="false" class="btn btn-vat-third" >
......
......@@ -334,4 +334,10 @@
span{
white-space: nowrap;
}
}
@media screen and (max-width: 1400px) {
.rightNav{
left: 8%!important;
width: 40% !important;
}
}
\ No newline at end of file
......@@ -6,7 +6,7 @@
return {
restrict: 'E',
template: '<div class="report" style="height: 100%;"></div>',
template: '<div class="report" style="height: 100%;width: 100%;"></div>',
replace: true,
scope: {
templateId: '=',
......@@ -74,15 +74,15 @@
}
};*/
scope.$watchGroup(['relation.period', 'relation.orgId', 'relation.data'], function (newValue, oldValue) {
/* scope.$watchGroup(['relation.period', 'relation.orgId', 'relation.data'], function (newValue, oldValue) {
if (scope.relation.orgId != null && scope.relation.period != null) {
/* setTimeout(function () {
/!* setTimeout(function () {
if ((scope.relation.broadcast && scope.relation.broadcast == true) || scope.spread != undefined) {
loadSheet(scope.templateId, false)
} else {
loadSheet(scope.templateId, true);
}
}, 200);*/
}, 200);*!/
loadSheet(scope.templateId);
}
});
......@@ -91,11 +91,11 @@
// loadSheet(scope.templateId, false)
loadSheet(scope.templateId)
}
});
});*/
var loadSheet = function (templateId) {
var loadSheet = function (templateId ) {
//var prokjectId = vatSessionService.project.id;
//var period = vatSessionService.month;
/* if (!init) {
......@@ -140,6 +140,15 @@
});
}*/
var setColWidth = function(sheet){
for(var i = 0; i < sheet.getColumnCount(); i++){
if(i ==0){
sheet.setColumnWidth(0, 360)
continue
}
sheet.setColumnWidth(i, 180);
}
}
var initSpreadExcel = function (reportSpread) {
var spread = getSpreadControl();
......@@ -182,11 +191,13 @@
sheet.clearSelection();
}
scope.spread = spread;
setColWidth(sheet);
if(sheet.getRowCount() <= 38)
addEbitRow(sheet)
if (scope.templateId && scope.reportSource) {
setData(true);
setData();
}
sheet.setRowResizable(0,false,GC.Spread.Sheets.SheetArea.viewport);
spread.resumePaint();
return $q.when(spread);
};
......@@ -194,7 +205,7 @@
var addEbitRow = function (sheet) {
if (sheet == undefined || sheet == null)
sheet = scope.spread.getActiveSheet();
//sheet.setColumnWidth(0, 2)
//添加单元格
if (sheet.getRowCount() > 43)
return;
......@@ -307,6 +318,16 @@
scope.relation.loadEbitCell(sheet);
return;
}*/
if(upload){ //上传上来的文件也要动态添加行
addEbitRow(sheet);
scope.relation.loadEbitCell(sheet);
lockCell(scope.spread);
setColWidth(sheet);
scope.spread.resumePaint();
return
}else{
scope.relation.loadEbitCell(sheet);
}
if (angular.isArray(scope.reportSource)) {
//spreadJsTipService.initialize(sheet);
......@@ -316,14 +337,6 @@
}*/
scope.spread.suspendPaint();
if(upload){
scope.relation.loadEbitCell(sheet);
lockCell(scope.spread);
scope.spread.resumePaint();
return
}else{
scope.relation.loadEbitCell(sheet);
}
/* if (scope.reportSource.length == 0 && scope.relation.emptyData && scope.relation.emptyData == true) {
_init(scope.templateId, true);///如果没有数据,需要重新加载
lockCell(scope.spread);
......@@ -331,7 +344,6 @@
}
*/
scope.reportSource.forEach(function (data) {
scope.relation.emptyData == true;
//fix bug11737 导出需要显示千分位
// 避免直接使用data.value = parseFloat(data.value)导致非数字型value无法显示
data.value = PWC.tryParseStringToNum(data.value);
......@@ -359,7 +371,9 @@
}
};
scope.relation.setData = setData;
scope.relation.setData = setData;//绑定单元格数据设置
scope.relation.loadSheet = loadSheet;//绑定单元格加载
(function initialize() {
loadSheet(scope.templateId);
})();
......
<div class="vat-report-view">
<div class="vat-report-view" style="overflow-y: scroll">
<!--Report SpreadJS-->
<div class="row" style=" height: 53px; background: #ccc;">
<div class="col-sm-7" style=" margin-top: 10px;">
<div class="col-sm-7 navLeft " style=" margin-top: 10px;">
<div class="col-sm-8">
<span class="text-bold" translate="SelectedOrganization" style=" top: -7px; display: inline!important; position: relative; ">:</span>
<span class="text-bold" translate="SelectedOrganization"></span><span>:</span>
<!-- <div id="dx-select-industry" class="tab-content-select industry " style=" display: inline-block;"
dx-select-box="dataSourceIndustryList" dx-item-alias="itemObj">
<div data-options="dxTemplate: { name: 'orgList' }" class="dx-item-content dx-list-item-content"
......@@ -11,18 +11,29 @@
{{itemObj.code}}-{{itemObj.name}}
</div>
</div>-->
<div dx-tag-box="selectOrgOptions" style="width: 287px;display: inline-block"></div>
<!-- <div dx-tag-box="selectOrgOptions" style="width: 287px;display: inline-block"></div>-->
<!--data-max-options 可以选择几个值-->
<select class="selectpicker show-tick dropup" multiple data-live-search="true"
data-width="50%" data-max-options="1"
data-size="10"
data-style="btn-primary" id ="orgList"
data-header="机构列表"
data-content = "true"
data-none-selected-text = "选择机构"
data-dropdown-align-right = "auto"
data-none-results-text ="没有匹配的机构">
</select>
</div>
<div class="col-sm-4" class="dateClass">
<span class="text-bold" translate="InvoiceQJ">:</span>
<div class="col-sm-4 col-sm-pull-3 datePull" >
<span class="text-bold" translate="InvoiceQJ"></span>:
<div style=" display: inline-block;">
<input type="text" id="ebitDatepacker" class="datepicker" style="width:120px;height: 34px;"
readonly="readonly"/>
<i class="fa fa-calendar vat-subheader red-color" style="width:20px;"></i>
<i class="fa fa-calendar vat-subheader red-color" style="width:20px;position: relative;left: -23px;"></i>
</div>
</div>
</div>
<div class="col-sm-5" class="bar-export navRight" style=" margin-top: 20px;width: 30%;; float: right;">
<div class="col-sm-5 bar-export navRight" style=" margin-top: 20px;width: 30%; float: right;">
<span ngf-select="" ngf-change="upload($files)" accept=".xls,.xlsx" ngf-multiple="false"
ngf-allow-dir="false" class="" ><i class="fa fa-file">&nbsp;{{'uploadProfileTable' | translate}}</i></span>
<span ng-click="saveAndRefresh()"><i class="fa fa-refresh"></i>&nbsp;{{'saveAndRefresh' | translate}}</span>
......
......@@ -112,7 +112,20 @@
@media screen and (max-width:1400px) {
.navRight{
width: 40%!important;
width: 33%!important;
}
.navLeft{
width: 60%!important;
}
.datePull{
right: 8.33333333%!important;
}
}
@media screen and (min-width:1400px) {
.navRight{
right: -8%!important;
}
}
\ No newline at end of file
webservices.factory('vatReportService', ['$q', '$log', '$http', '$translate', 'apiConfig', 'enums', 'SweetAlert', 'vatOperationLogService',
'vatSessionService','FileSaver',
'vatSessionService', 'FileSaver',
function ($q, $log, $http, $translate, apiConfig, enums, SweetAlert, vatOperationLogService, vatSessionService, FileSaver) {
'use strict';
$log.debug('vatReportService.ctor()...');
......@@ -64,18 +64,21 @@
var param = {
reportId: reportId,
period: period,
orgId : orgId
orgId: orgId
}
param = JSON.stringify(param);
return $http.post('/Report/reportEbitData',param, apiConfig.createVat({ contentType:"application/json"}));
} ,
manyExport : function(param){
return $http.post('/Report/manyExport', param, apiConfig.createVat({responseType: 'arraybuffer'})).then(function (response) {
return $http.post('/Report/reportEbitData', param, apiConfig.createVat({contentType: "application/json"}));
},
manyExport: function (param) {
var toParam = JSON.stringify(param);
return $http.post('/Report/manyExport', toParam, apiConfig.createVat({responseType: 'arraybuffer'})).then(function (response) {
var a = document.createElement('a');
var blob = new Blob([response.data], {'type':"application/octet-stream" });
var data = new Blob([response.data], {type: response.headers('Content-Type')});
//FileSaver.saveAs(data, '利润表.zip');
a.href = URL.createObjectURL(blob);
a.download = "利润表.zip";
a.href = URL.createObjectURL(data);
a.download = param.period + "-汇总利润表.xlsx";
a.click();
});
}
......@@ -83,11 +86,11 @@
saveAndRefresh: function (orgId, period, specialConsiderations, ebitRate) {
var paramObj = {
orgId: orgId,
period : period,
specialConsiderations : specialConsiderations,
ebitRate : ebitRate
period: period,
specialConsiderations: specialConsiderations,
ebitRate: ebitRate
};
return $http.post('/Report/saveAndRefresh', paramObj , apiConfig.createVat());
return $http.post('/Report/saveAndRefresh', paramObj, apiConfig.createVat());
},
calculateKeyValue: function (projectId, period) {
return $http.post('/Report/calculateKeyValue/' + projectId + '/' + period, {}, apiConfig.createVat({ignoreLoadingBar: true}));
......@@ -256,7 +259,7 @@
saveEbitModule: function () {
},
downLoadAttach : function(id){
downLoadAttach: function (id) {
return $http.get('/Report/downLoadAttach?id=' + id, apiConfig.createVat());
}
};
......
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