diff --git a/lib/EmergencyService/zdxtEmergencyBootStart/src/main/resources/templates/project/code/statisticsEnterprise/statisticsEnterprise.html b/lib/EmergencyService/zdxtEmergencyBootStart/src/main/resources/templates/project/code/statisticsEnterprise/statisticsEnterprise.html index 82688a2c..563b0b70 100644 --- a/lib/EmergencyService/zdxtEmergencyBootStart/src/main/resources/templates/project/code/statisticsEnterprise/statisticsEnterprise.html +++ b/lib/EmergencyService/zdxtEmergencyBootStart/src/main/resources/templates/project/code/statisticsEnterprise/statisticsEnterprise.html @@ -188,11 +188,11 @@ var prefix = ctx + "code/statisticsEnterprise"; /*var myChart = echarts.init(document.getElementById('container'));*/ var myChart = echarts.init(document.getElementById('echartEnterprise')); - var detailsStatus=false - var detailsId="" - var pickQY="" - var pickJD="" - var pickQY1="" + var detailsStatus=false; + var detailsId=""; + var pickQY=""; + var pickJD=""; + var pickQY1=""; window.onload = function () { $("#quarter2").hide(); $("#month2").hide(); @@ -247,7 +247,7 @@ { title : '详情', formatter:function (value,row,index) { - console.log(row) + console.log(row); if(row.totalNumber == 0){ return "详情"; }else{ @@ -298,14 +298,14 @@ document.getElementById(`${prefix}-tab${num}`).classList.add('active'); } function searchE(){ - console.log(detailsStatus) - console.log(detailsId) + console.log(detailsStatus); + console.log(detailsId); if(!detailsStatus){ eTable1(); closeE(); frag1(); }else{ - console.log(detailsId=='bootstrap-table1') + console.log(detailsId=='bootstrap-table1'); if(detailsId=='bootstrap-table1'){ openDetailsQY(pickQY) }else{ @@ -315,7 +315,7 @@ } function restE(){ $('form').eq(0).trigger("reset"); - closeDetails() + closeDetails(); searchE(); addressMake(); frag1(); @@ -508,7 +508,7 @@ { title:'详情', formatter:function (value,row,index) { - console.log(row) + console.log(row); if(row.totalNumber == 0){ return "详情"; }else{ @@ -589,7 +589,7 @@ console.log(qy); var currentId=$('form').eq(0).attr('id'); var params = $.common.formToJSON(currentId); - console.log(params) + console.log(params); params.qy=qy; $.ajax({ url:prefix+'/QYDetails', @@ -699,7 +699,7 @@ console.log(jd); var currentId=$('form').eq(0).attr('id'); var params = $.common.formToJSON(currentId); - console.log(params) + console.log(params); params.qy=qy; params.jd=jd; $.ajax({ @@ -802,7 +802,7 @@ $('#qy').prop('disabled',false); $('#jd').prop('disabled',false); $('#bootstrap-table-details').bootstrapTable('destroy'); - detailsStatus=false + detailsStatus=false; if(detailsId=='bootstrap-table1'){ //关闭前区域列表 $('#closeButtonDQY').hide(); @@ -810,7 +810,7 @@ pickQY=""; }else{ $('#bootstrap-table, .fixed-table-pagination').show(); - $('#closeButton').show() + $('#closeButton').show(); $('#closeButtonDJD').hide(); pickQY=""; pickJD=""; @@ -821,31 +821,34 @@ function downloadI1(){ var currentId=$('form').eq(0).attr('id'); var params = $.common.formToJSON(currentId); - $.ajax({ - type: "POST", - data: JSON.stringify(params), - contentType: 'application/json', - //设置响应类型 - xhrFields: {responseType: "blob"}, - url: prefix+"/export1", - success: function (result) { - const link = document.createElement('a'); - let blob = new Blob([result], {type: 'application/vnd.ms-excel'}); - link.style.display = 'none'; - link.href = URL.createObjectURL(blob); - link.setAttribute('download', "企业数量统计.xls"); - document.body.appendChild(link); - link.click(); - document.body.removeChild(link) - } - }) + // $.ajax({ + // type: "POST", + // data: JSON.stringify(params), + // contentType: 'application/json', + // //设置响应类型 + // xhrFields: {responseType: "text"}, + // url: prefix+"/export1", + // success: function (result) { + // const link = document.createElement('a'); + // let blob = new Blob([result], {type: 'application/vnd.ms-excel'}); + // link.style.display = 'none'; + // link.href = URL.createObjectURL(blob); + // link.setAttribute('download', "企业数量统计.xls"); + // document.body.appendChild(link); + // link.click(); + // document.body.removeChild(link) + // } + // }) + // window.open(prefix+"/export1", "parent"); + window.location.href = prefix+"/export1"; + } function downloadI2(){ $.ajax({ type: "POST", contentType: 'application/json', //设置响应类型 - xhrFields: {responseType: "blob"}, + xhrFields: {responseType: "text"}, url: prefix+"/export2", success: function (result) { const link = document.createElement('a'); diff --git a/lib/EmergencyService/zdxtLawEnforcementCodeService/src/main/java/com/zdxt/code/controller/StatisticsEnterpriseController.java b/lib/EmergencyService/zdxtLawEnforcementCodeService/src/main/java/com/zdxt/code/controller/StatisticsEnterpriseController.java index eeffb227..33352a5a 100644 --- a/lib/EmergencyService/zdxtLawEnforcementCodeService/src/main/java/com/zdxt/code/controller/StatisticsEnterpriseController.java +++ b/lib/EmergencyService/zdxtLawEnforcementCodeService/src/main/java/com/zdxt/code/controller/StatisticsEnterpriseController.java @@ -216,9 +216,9 @@ public class StatisticsEnterpriseController extends BaseController { return false; } - @PostMapping("/export1") + @GetMapping("/export1") @ResponseBody - public void export1(HttpServletResponse httpServletResponse,@RequestBody SearchType searchType) throws IOException { + public void export1(HttpServletResponse httpServletResponse,SearchType searchType) throws IOException { /*if(searchType.getJd()!=null&&!"".equals(searchType.getJd())){ searchType.setJd(iDictDataService.selectDictLabel(searchType.getQy(), searchType.getJd())); } diff --git a/lib/EmergencyService/zdxtLawEnforcementCodeService/src/main/java/com/zdxt/code/service/impl/StatisticsEnterpriseServiceImpl.java b/lib/EmergencyService/zdxtLawEnforcementCodeService/src/main/java/com/zdxt/code/service/impl/StatisticsEnterpriseServiceImpl.java index 40e7d94b..c1ef1e0f 100644 --- a/lib/EmergencyService/zdxtLawEnforcementCodeService/src/main/java/com/zdxt/code/service/impl/StatisticsEnterpriseServiceImpl.java +++ b/lib/EmergencyService/zdxtLawEnforcementCodeService/src/main/java/com/zdxt/code/service/impl/StatisticsEnterpriseServiceImpl.java @@ -1,5 +1,6 @@ package com.zdxt.code.service.impl; +import cn.hutool.core.date.DateTime; import com.zdxt.auth.project.system.dict.mapper.DictDataMapper; import com.zdxt.auth.project.system.dict.service.IDictDataService; import com.zdxt.code.domain.EnterpriseInformation; @@ -14,6 +15,7 @@ import org.apache.poi.ss.usermodel.*; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import javax.servlet.ServletOutputStream; import javax.servlet.http.HttpServletResponse; import java.io.IOException; import java.util.ArrayList; @@ -313,9 +315,11 @@ public class StatisticsEnterpriseServiceImpl implements StatisticsEnterpriseServ //设置流格式 response.setCharacterEncoding("UTF-8"); response.setContentType("application/vnd.ms-excel"); - response.setHeader("Content-disposition", "attachment;filename=" + fileName); + response.addHeader("Content-Disposition","attachment;filename=" + fileName); + //创建一个输出流 + ServletOutputStream outputStream = response.getOutputStream(); + workbook.write(outputStream); response.flushBuffer(); - workbook.write(response.getOutputStream()); workbook.close(); } private List jdListByJD(SearchType searchType){