Commit 68f705b9 authored by Ken you's avatar Ken you

fix vat cash flow view---Ken

parent 59e0d05f
......@@ -397,6 +397,32 @@
<version>3.2.6</version>
</dependency>
<!--CXF END-->
<!-- https://mvnrepository.com/artifact/org.jxls/jxls -->
<dependency>
<groupId>org.jxls</groupId>
<artifactId>jxls</artifactId>
<version>2.4.5</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.jxls/jxls-poi -->
<dependency>
<groupId>org.jxls</groupId>
<artifactId>jxls-poi</artifactId>
<version>1.0.15</version>
</dependency>
<!-- https://mvnrepository.com/artifact/net.sf.jxls/jxls-core -->
<dependency>
<groupId>net.sf.jxls</groupId>
<artifactId>jxls-core</artifactId>
<version>1.0.6</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.projectlombok/lombok -->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.0</version>
<scope>provided</scope>
</dependency>
</dependencies>
<profiles>
......@@ -468,6 +494,14 @@
</includes>
<targetPath>${basedir}/target/classes/userTemplate</targetPath>
</resource>
<resource>
<directory>src/main/resources/vat_excel_template</directory>
<includes>
<include>**/*.xls</include>
<include>**/*.xlsx</include>
</includes>
<targetPath>${basedir}/target/classes/vat_excel_template</targetPath>
</resource>
</resources>
<plugins>
<plugin>
......
package pwc.taxtech.atms.common;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import javax.servlet.http.HttpServletResponse;
import java.io.ByteArrayOutputStream;
import java.io.OutputStream;
import java.net.URLEncoder;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
@Component
public class ResponseMessageBuilder {
private final Logger logger = LoggerFactory.getLogger(this.getClass());
public HttpServletResponse getDownloadTmpResponseMessage(HttpServletResponse response, OutputStream outputStream, String fileName) throws Exception {
fileName = fileName + DateTimeFormatter.ofPattern("yyyyMMddHHmmssSSS").format(LocalDateTime.now()) + ".xlsx";
response.setContentType("application/octet-stream;charset=UTF-8");
response.setHeader("Access-Control-Expose-Headers", "x-file-name");
response.addHeader("Content-Disposition", "attachment; filename=" + fileName);
try (OutputStream responseOutputStream = response.getOutputStream()) {
response.setHeader("x-file-name", URLEncoder.encode(fileName, "UTF-8"));
ByteArrayOutputStream byteArrayOutputStream = (ByteArrayOutputStream) outputStream;
responseOutputStream.write(byteArrayOutputStream.toByteArray());
} catch (Exception e) {
logger.error("Error write data to response output stream");
e.printStackTrace();
throw new Exception(e.getMessage());
}
return response;
}
}
......@@ -55,6 +55,13 @@ public class DataPreviewController extends BaseController {
return dataPreviewSerivceImpl.getBSDataForDisplay(param);
}
@RequestMapping(value = "exportCFData/get", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public void downloadCFQueryData(@RequestBody CashFlowParam param, HttpServletResponse response) {
logger.debug("enter downloadCFQueryData");
String fileName="testFile";
dataPreviewSerivceImpl.exportCashFlowList(response, param, fileName);
}
@RequestMapping(value = "exportTBData/get", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public void downloadTBQueryData(@RequestBody TrialBalanceParam paras, HttpServletResponse response) {
response.setContentType("application/vnd.ms-excel;charset=utf-8");
......
package pwc.taxtech.atms.dto.vatdto.excelheader;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
public class CashFlowHeader {
private String companyNameCn;
private String companyNameEn;
private Integer periodStart;
private Integer periodEnd;
private String ledgerName;
private String ledgerCurrencyCode;
private String status;
}
......@@ -6,6 +6,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.client.RestTemplate;
import pwc.taxtech.atms.common.AtmsApiSettings;
import pwc.taxtech.atms.common.AuthUserHelper;
import pwc.taxtech.atms.common.ResponseMessageBuilder;
import pwc.taxtech.atms.common.util.BeanUtil;
public class BaseService {
......@@ -23,5 +24,9 @@ public class BaseService {
protected BeanUtil beanUtil;
@Autowired
protected RestTemplate restTemplate;
@Autowired
protected CommonDocumentHelper commonDocumentHelper;
@Autowired
protected ResponseMessageBuilder responseMessageBuilder;
}
package pwc.taxtech.atms.service.impl;
import org.jxls.common.Context;
import org.jxls.expression.JexlExpressionEvaluator;
import org.jxls.transform.Transformer;
import org.jxls.util.JxlsHelper;
import org.nutz.lang.Lang;
import org.nutz.lang.Streams;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Component
public class CommonDocumentHelper {
private static final Logger logger = LoggerFactory.getLogger(CommonDocumentHelper.class);
public void toXlsxFileUsingJxls(List<?> list, String excelTemplatePathInClassPath, String outputFilePath) {
//InputStream is = Streams.fileIn(excelTemplatePathInClassPath);
InputStream is = this.getClass().getResourceAsStream(excelTemplatePathInClassPath);
OutputStream os = Streams.fileOut(outputFilePath);
Context context = new Context();
context.putVar("list", list);
context.putVar("REPORT_DATE", new Date());
JxlsHelper jxlsHelper = JxlsHelper.getInstance();
Transformer transformer = jxlsHelper.createTransformer(is, os);
JexlExpressionEvaluator evaluator = (JexlExpressionEvaluator) transformer.getTransformationConfig()
.getExpressionEvaluator();
// evaluator.getJexlEngine().setSilent(true); // 设置静默模式,不报警告
Map<String, Object> funcs = new HashMap<String, Object>();
funcs.put("myutils", new JxlsUtils());
evaluator.getJexlEngine().setFunctions(funcs);
// jxlsHelper.setUseFastFormulaProcessor(false); //与统计函数有关
try {
jxlsHelper.processTemplate(context, transformer);
} catch (IOException e) {
logger.error("error when calling processTemplate:" + e, e);
throw Lang.wrapThrow(e);
} finally {
Streams.safeClose(is);
Streams.safeClose(os);
}
}
public OutputStream toXlsxFileUsingJxls(Object header, List<?> list, String excelTemplatePathInClassPath) {
//InputStream is = Streams.fileIn(excelTemplatePathInClassPath);
InputStream is = this.getClass().getResourceAsStream(excelTemplatePathInClassPath);
OutputStream os = new ByteArrayOutputStream();
Context context = new Context();
context.putVar("header", header);
context.putVar("list", list);
context.putVar("REPORT_DATE", new Date());
JxlsHelper jxlsHelper = JxlsHelper.getInstance();
Transformer transformer = jxlsHelper.createTransformer(is, os);
JexlExpressionEvaluator evaluator = (JexlExpressionEvaluator) transformer.getTransformationConfig()
.getExpressionEvaluator();
// evaluator.getJexlEngine().setSilent(true); // 设置静默模式,不报警告
Map<String, Object> funcs = new HashMap<String, Object>();
funcs.put("myutils", new JxlsUtils());
evaluator.getJexlEngine().setFunctions(funcs);
// jxlsHelper.setUseFastFormulaProcessor(false); //与统计函数有关
try {
jxlsHelper.processTemplate(context, transformer);
} catch (IOException e) {
logger.error("error when calling processTemplate:" + e, e);
throw Lang.wrapThrow(e);
} finally {
Streams.safeClose(is);
Streams.safeClose(os);
}
return os;
}
}
package pwc.taxtech.atms.service.impl;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.google.common.collect.Lists;
import org.springframework.stereotype.Service;
import pwc.taxtech.atms.dao.OrganizationMapper;
import pwc.taxtech.atms.dto.vatdto.*;
import pwc.taxtech.atms.dto.vatdto.dd.*;
import pwc.taxtech.atms.dto.vatdto.dd.TrialBalanceDto;
import pwc.taxtech.atms.dto.vatdto.excelheader.CashFlowHeader;
import pwc.taxtech.atms.entity.Organization;
import pwc.taxtech.atms.thirdparty.ExcelUtil;
import pwc.taxtech.atms.vat.dao.*;
import pwc.taxtech.atms.vat.dpo.*;
......@@ -14,11 +18,9 @@ import pwc.taxtech.atms.vat.dpo.TrialBalanceCondition;
import pwc.taxtech.atms.vat.entity.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
/**
* @Auther: Gary J Li
......@@ -42,6 +44,8 @@ public class DataPreviewSerivceImpl extends BaseService {
@Resource
private CashFlowMapper cashFlowMapper;
@Resource
private OrganizationMapper organizationMapper;
public PageInfo<TrialBalanceDto> getTBDataForDisplay(TrialBalanceParam param) {
......@@ -85,6 +89,30 @@ public class DataPreviewSerivceImpl extends BaseService {
}
public PageInfo<CashFlowDto> getCFDataForDisplay(CashFlowParam param) {
CashFlowCondition condition = new CashFlowCondition();
beanUtil.copyProperties(param, condition);
//Integer totalCount=cashFlowMapper.selectCountByCondition(condition);
List<CashFlowDto> cashFlowDtos = Lists.newArrayList();
Page page = PageHelper.startPage(param.getPageInfo().getPageIndex(), param.getPageInfo().getPageSize());
List<CashFlow> cashFlows = cashFlowMapper.selectByCondition(condition);
//使用page的getTotal()
Long total = page.getTotal();
cashFlows.forEach(cf -> {
CashFlowDto cashFlowDto = new CashFlowDto();
beanUtil.copyProperties(cf, cashFlowDto);
cashFlowDtos.add(cashFlowDto);
});
PageInfo<CashFlowDto> pageInfo=new PageInfo<>(cashFlowDtos);
pageInfo.setTotal(total);
pageInfo.setPageNum(param.getPageInfo().getPageIndex());
return pageInfo;
}
public HttpServletResponse exportCashFlowList(HttpServletResponse response, CashFlowParam param, String fileName) {
//Boolean isEn = StringUtils.equals(language, "en-us");
logger.debug("start export input invoice list to excel");
//String excelTemplatePathInClassPath = "/vat_excel_template/cash_flow"+(isEn?"":"_cn") + ".xlsx";
String excelTemplatePathInClassPath = "/vat_excel_template/cash_flow.xlsx";
CashFlowCondition condition = new CashFlowCondition();
beanUtil.copyProperties(param, condition);
PageHelper.startPage(param.getPageInfo().getPageIndex(), param.getPageInfo().getPageSize());
......@@ -95,7 +123,25 @@ public class DataPreviewSerivceImpl extends BaseService {
beanUtil.copyProperties(cf, cashFlowDto);
cashFlowDtos.add(cashFlowDto);
});
return new PageInfo<>(cashFlowDtos);
CashFlowHeader cashFlowHeader=new CashFlowHeader();
if(cashFlowDtos.size()>0){
Organization org = organizationMapper.selectByPrimaryKey(param.getOrgId());
cashFlowHeader.setCompanyNameCn(org.getName());
cashFlowHeader.setPeriodStart(param.getPeriodStart());
cashFlowHeader.setPeriodEnd(param.getPeriodEnd());
cashFlowHeader.setLedgerName(cashFlowDtos.get(0).getLedgerName());
cashFlowHeader.setLedgerCurrencyCode(cashFlowDtos.get(0).getLedgerCurrencyCode());
cashFlowHeader.setStatus(cashFlowDtos.get(0).getStatus());
}
OutputStream outputStream = commonDocumentHelper.toXlsxFileUsingJxls(cashFlowHeader, cashFlowDtos, excelTemplatePathInClassPath);
try {
return responseMessageBuilder.getDownloadTmpResponseMessage(response, outputStream, fileName);
} catch (Exception e) {
e.printStackTrace();
logger.error(e.getMessage());
}
return null;
}
public PageInfo<JournalEntryDto> getJEDataForDisplay(JournalEntryParam param) {
......
package pwc.taxtech.atms.service.impl;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
import java.util.TimeZone;
public class JxlsUtils {
public String formatDate(Date date, String pattern) {
if (null == date)
return "";
SimpleDateFormat sdf = new SimpleDateFormat(pattern, Locale.US);
sdf.setTimeZone(TimeZone.getTimeZone("Asia/Shanghai"));
try {
return sdf.format(date);
} catch (Exception e) {
return "<Invalid date pattern:" + pattern + ">";
}
}
}
......@@ -17,7 +17,7 @@
<plugins>
<plugin interceptor="com.github.pagehelper.PageInterceptor">
<!-- 4.0.0以后版本可以不设置该参数 -->
<property name="diaect" value="oracle"/>
<property name="helperDialect" value="mysql"/>
<!--
该参数默认为false
设置为true时,会将RowBounds第一个参数offset当成pageNum页码使用
......
package pwc.taxtech.atms.vat.dao;
import java.util.List;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.session.RowBounds;
......@@ -9,6 +8,8 @@ import pwc.taxtech.atms.vat.dpo.CashFlowCondition;
import pwc.taxtech.atms.vat.entity.CashFlow;
import pwc.taxtech.atms.vat.entity.CashFlowExample;
import java.util.List;
@Mapper
public interface CashFlowMapper extends MyVatMapper {
/**
......@@ -109,5 +110,7 @@ public interface CashFlowMapper extends MyVatMapper {
List<CashFlow> selectByCondition(@Param("cfCondition") CashFlowCondition condition);
Integer selectCountByCondition(@Param("cfCondition") CashFlowCondition condition);
int insertBatch(List<CashFlow> cfs);
}
\ No newline at end of file
......@@ -35,6 +35,13 @@
where
<include refid="QueryCondition"/>
</select>
<select id="selectCountByCondition" parameterType="pwc.taxtech.atms.vat.dpo.CashFlowCondition" resultType="Integer">
select
count(*)
from cash_flow
where
<include refid="QueryCondition"/>
</select>
<insert id="insertBatch" parameterType="java.util.List">
insert into cash_flow
......
......@@ -928,7 +928,7 @@ constant.outputTaxRate = ['17%', '13%', '11%', '6%', '5%', '3%', '1.5%', '0%', '
constant.AccountMappingProcessKey = {UnSelected: 'UnSelected', Submit: 'Submit', Undo: 'Undo'}
constant.pagesize = 100;
constant.pagesize = 50;
constant.ErpCheckType = {
CustomInvoice_DuplicatePayNum: 20
......
webservices.factory('vatPreviewService', ['$http', 'apiConfig', function ($http, apiConfig) {
webservices.factory('vatPreviewService', ['$http', 'apiConfig','FileSaver', function ($http, apiConfig,FileSaver) {
'use strict';
return {
sample: function () {
......@@ -189,8 +189,14 @@
getCFDataForDisplay: function (queryParams) {
return $http.post('/dataPreview/getCFDataForDisplay', queryParams, apiConfig.createVat());
},
initExportCFData: function (queryParams) {
return $http.post('/dataPreview/exportCFData/get', queryParams, apiConfig.create({ responseType: 'arraybuffer' }));
//服务器导出
initExportCFData: function (queryParm, fileName) {
var thisConfig = apiConfig.create();
thisConfig.responseType = "arraybuffer";
return $http.post('/dataPreview/exportCFData/get', queryParm, thisConfig).then(function (response) {
var data = new Blob([response.data], {type: response.headers('Content-Type')});
FileSaver.saveAs(data, fileName + '.xlsx');
});
},
getPLDataForDisplay: function (queryParams) {
return $http.post('/dataPreview/getPLDataForDisplay', queryParams, apiConfig.createVat());
......
<div class="vat-preview-cash-flow" id="mainPreviewDiv">
<div class="top-area-wrapper" style="margin-top: 10px">
<span translate="ImportCFStatusGridSourceDDTitle" class="text-bold"></span> &nbsp;&nbsp;|&nbsp;&nbsp;<span class="text-bold" translate="InvoiceQJ"></span>
<span translate="CashFlowDDTitle" class="text-bold"></span> &nbsp;&nbsp;|&nbsp;&nbsp;<span class="text-bold" translate="InvoiceQJ"></span>
<input type="text" class="form-control input-width-middle" style="position: relative; top: -30px; left: 130px;" id="input-invoice-period-picker" />
<span ng-click="downloadInputInvoice()" style="position: relative; top: -13px; left: 95%;"><i class="fa fa-file-excel-o" aria-hidden="true"></i>{{'ExportBtn' | translate}}</span>
<span ng-click="downloadCashFlow()" style="position: relative; top: -13px; left: 95%;"><i class="fa fa-file-excel-o" aria-hidden="true"></i>{{'ExportBtn' | translate}}</span>
</div>
<div style="margin-bottom: 10px;margin-left: 20px;margin-top: 10px;">
......@@ -11,26 +11,8 @@
是否关账:<span class="numAmount">{{ledgerStatusFirst}}</span>
</div>
<!-- <div id="filterCriteriaDiv" style="max-width:98%;margin-bottom:2px;" ng-show="criteriaList.length>0">
<span class="text-bold margin-left20" translate="FilterCriteriaTags"></span>:
<span class="tag label label-default" ng-repeat="criteria in criteriaListFirstRow">
<span title="{{criteria.fullName}}">
{{criteria.name}}
</span>
<a><i class="remove glyphicon glyphicon-remove-sign glyphicon-white" ng-click="doDataFilter(criteria.propertyName)"></i></a>
</span>
<span ng-if="criteriaList.length>6"><br /></span>
<span ng-if="criteriaList.length>6" style="margin-left: 81px; margin-top: 19px; display: inline-block;"></span>
<span ng-if="criteriaList.length>6" class="tag label label-default" ng-repeat="criteria in criteriaListSecondRow">
<span title="{{criteria.fullName}}">
{{criteria.name}}
</span>
<a><i class="remove glyphicon glyphicon-remove-sign glyphicon-white" ng-click="doDataFilter(criteria.propertyName)"></i></a>
</span>
</div> -->
<div id="mainAreaDiv" class="main-area">
<div class="inputInvoiceGrid" ui-grid-expandable ui-grid="gridOptions">
<div class="inputInvoiceGrid" ui-grid="gridOptions">
<div class="watermark" ng-show="!gridOptions.data.length"><span translate="NoDataAvailable"></span></div>
</div>
<div class="pagination-container">
......
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