fix 下载文件

master
luoyang 6 years ago
parent 378235e4cf
commit 09c7357fb7

@ -609,6 +609,7 @@ public class TradeLogServiceImpl implements TradeLogService {
// File jasperFile = trans_flow.getFile(); // File jasperFile = trans_flow.getFile();
JSONObject transFlow = listPartnerTransFlow(query, partner); JSONObject transFlow = listPartnerTransFlow(query, partner);
JSONObject analysis = transFlow.getJSONObject("analysis"); JSONObject analysis = transFlow.getJSONObject("analysis");
JSONObject client = clientManager.getClientInfo(Integer.parseInt(query.getClient_ids()[0]));
if (!transFlow.getJSONArray("data").isEmpty()) { if (!transFlow.getJSONArray("data").isEmpty()) {
try { try {
List<JSONObject> dataList = (List<JSONObject>) transFlow.get("data"); List<JSONObject> dataList = (List<JSONObject>) transFlow.get("data");
@ -621,9 +622,9 @@ public class TradeLogServiceImpl implements TradeLogService {
: DateFormatUtils.format(new Date(), "dd/MM/yyyy")); : DateFormatUtils.format(new Date(), "dd/MM/yyyy"));
parmerters.put("dateRange", (StringUtils.isNotBlank(parmerters.getString("dateFrom")) ? parmerters.getString("dateFrom") : "") + "~" parmerters.put("dateRange", (StringUtils.isNotBlank(parmerters.getString("dateFrom")) ? parmerters.getString("dateFrom") : "") + "~"
+ parmerters.getString("dateTo")); + parmerters.getString("dateTo"));
parmerters.put("partnerCode", partner.getString("client_moniker")); parmerters.put("partnerCode", client.getString("client_moniker"));
parmerters.put("clientName", partner.getJSONObject("client").getString("company_name")); parmerters.put("clientName", client.getString("company_name"));
parmerters.put("clientAddress", partner.getJSONObject("client").getString("address")); parmerters.put("clientAddress", client.getString("address"));
parmerters.put("balance", analysis.getDoubleValue("balance")); parmerters.put("balance", analysis.getDoubleValue("balance"));
parmerters.put("logo", logo.getInputStream()); parmerters.put("logo", logo.getInputStream());
parmerters.put("actual_fee", takeDecimalOrDefault(analysis, "actual_fee", BigDecimal.ZERO)); parmerters.put("actual_fee", takeDecimalOrDefault(analysis, "actual_fee", BigDecimal.ZERO));
@ -645,7 +646,7 @@ public class TradeLogServiceImpl implements TradeLogService {
}); });
JRDataSource jrDataSource = new JRBeanCollectionDataSource(dataList); JRDataSource jrDataSource = new JRBeanCollectionDataSource(dataList);
response.setContentType("application/pdf"); response.setContentType("application/pdf");
String fileName = partner.getString("client_moniker") + "_" + parmerters.getString("dateRange").replaceAll("/", ""); String fileName = client.getString("client_moniker") + "_" + parmerters.getString("dateRange").replaceAll("/", "");
response.setHeader("Content-Disposition", "attachment;fileName=" + fileName + ".pdf"); response.setHeader("Content-Disposition", "attachment;fileName=" + fileName + ".pdf");
OutputStream outs = response.getOutputStream(); OutputStream outs = response.getOutputStream();
byte[] bytes = JasperRunManager.runReportToPdf(trans_flow.getInputStream(), parmerters, jrDataSource); byte[] bytes = JasperRunManager.runReportToPdf(trans_flow.getInputStream(), parmerters, jrDataSource);
@ -676,6 +677,7 @@ public class TradeLogServiceImpl implements TradeLogService {
public void exportExcel(TradeLogQuery query, JSONObject partner, HttpServletResponse response) throws Exception { public void exportExcel(TradeLogQuery query, JSONObject partner, HttpServletResponse response) throws Exception {
logger.debug("excel The method======= exportExcel() start......................."); logger.debug("excel The method======= exportExcel() start.......................");
JSONObject transFlow = listPartnerTransFlow(query, partner); JSONObject transFlow = listPartnerTransFlow(query, partner);
JSONObject client = clientManager.getClientInfo(Integer.parseInt(query.getClient_ids()[0]));
// JSONObject analysis = transFlow.getJSONObject("analysis"); // JSONObject analysis = transFlow.getJSONObject("analysis");
if (transFlow.getJSONArray("data").size() > 0) { if (transFlow.getJSONArray("data").size() > 0) {
try { try {
@ -701,7 +703,7 @@ public class TradeLogServiceImpl implements TradeLogService {
JSONObject parmerters = new JSONObject(); JSONObject parmerters = new JSONObject();
parmerters.put("dateFrom", StringUtils.isNotBlank(query.getDatefrom()) ? query.getDatefrom() : ""); parmerters.put("dateFrom", StringUtils.isNotBlank(query.getDatefrom()) ? query.getDatefrom() : "");
parmerters.put("dateTo", StringUtils.isNotBlank(query.getDateto()) ? query.getDateto() : DateFormatUtils.format(new Date(), "yyyyMMdd")); parmerters.put("dateTo", StringUtils.isNotBlank(query.getDateto()) ? query.getDateto() : DateFormatUtils.format(new Date(), "yyyyMMdd"));
parmerters.put("partnerCode", partner.getString("client_moniker")); parmerters.put("partnerCode", client.getString("client_moniker"));
// parmerters.put("actual_fee", analysis.containsKey("actual_fee") ? // parmerters.put("actual_fee", analysis.containsKey("actual_fee") ?
// analysis.getBigDecimal("actual_fee") : 0); // analysis.getBigDecimal("actual_fee") : 0);
JRDataSource jrDataSource = new JRBeanCollectionDataSource(dataList); JRDataSource jrDataSource = new JRBeanCollectionDataSource(dataList);
@ -758,6 +760,7 @@ public class TradeLogServiceImpl implements TradeLogService {
public void exportExcelNew(TradeLogQuery query, JSONObject partner, HttpServletResponse response) throws Exception { public void exportExcelNew(TradeLogQuery query, JSONObject partner, HttpServletResponse response) throws Exception {
logger.debug("excel The method======= exportExcelNew() start......................."); logger.debug("excel The method======= exportExcelNew() start.......................");
JSONObject transFlow = listPartnerTransFlow(query, partner); JSONObject transFlow = listPartnerTransFlow(query, partner);
JSONObject client = clientManager.getClientInfo(Integer.parseInt(query.getClient_ids()[0]));
if (transFlow.getJSONArray("data").size() > 0) { if (transFlow.getJSONArray("data").size() > 0) {
List<JSONObject> dataList = (List<JSONObject>) transFlow.get("data"); List<JSONObject> dataList = (List<JSONObject>) transFlow.get("data");
HSSFWorkbook workbook = new HSSFWorkbook(); HSSFWorkbook workbook = new HSSFWorkbook();
@ -849,7 +852,7 @@ public class TradeLogServiceImpl implements TradeLogService {
JSONObject parmerters = new JSONObject(); JSONObject parmerters = new JSONObject();
parmerters.put("dateFrom", StringUtils.isNotBlank(query.getDatefrom()) ? query.getDatefrom() : ""); parmerters.put("dateFrom", StringUtils.isNotBlank(query.getDatefrom()) ? query.getDatefrom() : "");
parmerters.put("dateTo", StringUtils.isNotBlank(query.getDateto()) ? query.getDateto() : DateFormatUtils.format(new Date(), "yyyyMMdd")); parmerters.put("dateTo", StringUtils.isNotBlank(query.getDateto()) ? query.getDateto() : DateFormatUtils.format(new Date(), "yyyyMMdd"));
parmerters.put("partnerCode", partner.getString("client_moniker")); parmerters.put("partnerCode", client.getString("client_moniker"));
response.setContentType("application/vnd.ms-excel"); response.setContentType("application/vnd.ms-excel");
String fileName = StringUtils.isEmpty(parmerters.getString("dateFrom")) ? parmerters.getString("dateTo") String fileName = StringUtils.isEmpty(parmerters.getString("dateFrom")) ? parmerters.getString("dateTo")
: (parmerters.getString("dateFrom") + "~" + parmerters.getString("dateTo")); : (parmerters.getString("dateFrom") + "~" + parmerters.getString("dateTo"));

@ -20,23 +20,23 @@
<p>{{surcharge.balance|currency:'AUD'}}</p> <p>{{surcharge.balance|currency:'AUD'}}</p>
</div> </div>
</div> </div>
<div class="form-group" ng-if="partner.surcharge_mode=='distributed'"> <!--<div class="form-group" ng-if="partner.surcharge_mode=='distributed'">-->
<label class="control-label col-xs-4 col-sm-3">允许手续费账户欠款</label> <!--<label class="control-label col-xs-4 col-sm-3">允许手续费账户欠款</label>-->
<div class="col-sm-6"> <!--<div class="col-sm-6">-->
<input type="checkbox" ng-model="partner.allow_surcharge_credit" bs-switch <!--<input type="checkbox" ng-model="partner.allow_surcharge_credit" bs-switch-->
switch-change="allowSurchargeCredit(partner.allow_surcharge_credit)" switch-readonly="true"> <!--switch-change="allowSurchargeCredit(partner.allow_surcharge_credit)" switch-readonly="true">-->
</div> <!--</div>-->
</div> <!--</div>-->
<div class="form-group"> <!--<div class="form-group">-->
<label class="control-label col-xs-4 col-sm-3" style="padding-top:0px">Surcharge Mode:</label> <!--<label class="control-label col-xs-4 col-sm-3" style="padding-top:0px">Surcharge Mode:</label>-->
<div class="col-xs-8 col-sm-6"> <!--<div class="col-xs-8 col-sm-6">-->
<span class="control-label" ng-bind="partner.surcharge_mode"></span> <!--<span class="control-label" ng-bind="partner.surcharge_mode"></span>-->
<p class="text-info"> <!--<p class="text-info">-->
<i class="fa fa-info"></i>启用到收支分离(distributed)模式,将使消费者支付手续费模式失效 <!--<i class="fa fa-info"></i>启用到收支分离(distributed)模式,将使消费者支付手续费模式失效-->
</p> <!--</p>-->
</div> <!--</div>-->
</div> <!--</div>-->
</div> </div>
<div class="col-sm-4" style="text-align: center" ng-if="code_url"> <div class="col-sm-4" style="text-align: center" ng-if="code_url">

Loading…
Cancel
Save