|  |  | @ -2,12 +2,14 @@ package com.glxp.api.util; | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | import cn.hutool.json.JSONUtil; |  |  |  | import cn.hutool.json.JSONUtil; | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.alibaba.fastjson.JSON; |  |  |  | import com.alibaba.fastjson.JSON; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | import lombok.extern.slf4j.Slf4j; | 
			
		
	
		
		
			
				
					
					|  |  |  | import net.sf.jasperreports.engine.*; |  |  |  | import net.sf.jasperreports.engine.*; | 
			
		
	
		
		
			
				
					
					|  |  |  | import net.sf.jasperreports.engine.export.ooxml.JRDocxExporter; |  |  |  | import net.sf.jasperreports.engine.export.ooxml.JRDocxExporter; | 
			
		
	
		
		
			
				
					
					|  |  |  | import net.sf.jasperreports.engine.query.JsonQueryExecuterFactory; |  |  |  | import net.sf.jasperreports.engine.query.JsonQueryExecuterFactory; | 
			
		
	
		
		
			
				
					
					|  |  |  | import net.sf.jasperreports.engine.util.JRLoader; |  |  |  | import net.sf.jasperreports.engine.util.JRLoader; | 
			
		
	
		
		
			
				
					
					|  |  |  | import net.sf.jasperreports.export.SimpleExporterInput; |  |  |  | import net.sf.jasperreports.export.SimpleExporterInput; | 
			
		
	
		
		
			
				
					
					|  |  |  | import net.sf.jasperreports.export.SimpleOutputStreamExporterOutput; |  |  |  | import net.sf.jasperreports.export.SimpleOutputStreamExporterOutput; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | import org.apache.commons.lang3.exception.ExceptionUtils; | 
			
		
	
		
		
			
				
					
					|  |  |  | import org.slf4j.Logger; |  |  |  | import org.slf4j.Logger; | 
			
		
	
		
		
			
				
					
					|  |  |  | import org.slf4j.LoggerFactory; |  |  |  | import org.slf4j.LoggerFactory; | 
			
		
	
		
		
			
				
					
					|  |  |  | import org.springframework.stereotype.Component; |  |  |  | import org.springframework.stereotype.Component; | 
			
		
	
	
		
		
			
				
					|  |  | @ -27,6 +29,7 @@ import java.util.Map; | 
			
		
	
		
		
			
				
					
					|  |  |  |  * @author chenqf |  |  |  |  * @author chenqf | 
			
		
	
		
		
			
				
					
					|  |  |  |  * @date 2021-11-10 22:23 |  |  |  |  * @date 2021-11-10 22:23 | 
			
		
	
		
		
			
				
					
					|  |  |  |  */ |  |  |  |  */ | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | @Slf4j | 
			
		
	
		
		
			
				
					
					|  |  |  | @Component |  |  |  | @Component | 
			
		
	
		
		
			
				
					
					|  |  |  | public class JasperUtils { |  |  |  | public class JasperUtils { | 
			
		
	
		
		
			
				
					
					|  |  |  |     private static Logger logger = LoggerFactory.getLogger(JasperUtils.class); |  |  |  |     private static Logger logger = LoggerFactory.getLogger(JasperUtils.class); | 
			
		
	
	
		
		
			
				
					|  |  | @ -43,7 +46,7 @@ public class JasperUtils { | 
			
		
	
		
		
			
				
					
					|  |  |  |     public static void jasperReport(HttpServletRequest request, HttpServletResponse response, Map<String, Object> data, String jasperResource, String type) throws IOException, JRException { |  |  |  |     public static void jasperReport(HttpServletRequest request, HttpServletResponse response, Map<String, Object> data, String jasperResource, String type) throws IOException, JRException { | 
			
		
	
		
		
			
				
					
					|  |  |  |         try { |  |  |  |         try { | 
			
		
	
		
		
			
				
					
					|  |  |  |             HashMap<String, Object> map = new HashMap<String, Object>(); |  |  |  |             HashMap<String, Object> map = new HashMap<String, Object>(); | 
			
		
	
		
		
			
				
					
					|  |  |  |             logger.error(JSON.toJSONString(data)); |  |  |  |             log.error(JSON.toJSONString(data)); | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |             InputStream is = new ByteArrayInputStream(JSONUtil.toJsonStr(data).getBytes(StandardCharsets.UTF_8)); |  |  |  |             InputStream is = new ByteArrayInputStream(JSONUtil.toJsonStr(data).getBytes(StandardCharsets.UTF_8)); | 
			
		
	
		
		
			
				
					
					|  |  |  |             map.put("JSON_INPUT_STREAM", is); //填充报表数据
 |  |  |  |             map.put("JSON_INPUT_STREAM", is); //填充报表数据
 | 
			
		
	
		
		
			
				
					
					|  |  |  |             map.put(JsonQueryExecuterFactory.JSON_LOCALE, Locale.ENGLISH); |  |  |  |             map.put(JsonQueryExecuterFactory.JSON_LOCALE, Locale.ENGLISH); | 
			
		
	
	
		
		
			
				
					|  |  | @ -68,14 +71,14 @@ public class JasperUtils { | 
			
		
	
		
		
			
				
					
					|  |  |  |                 os.close(); |  |  |  |                 os.close(); | 
			
		
	
		
		
			
				
					
					|  |  |  |             } |  |  |  |             } | 
			
		
	
		
		
			
				
					
					|  |  |  |         } catch (Exception e) { |  |  |  |         } catch (Exception e) { | 
			
		
	
		
		
			
				
					
					|  |  |  |             e.printStackTrace(); |  |  |  |             log.error(ExceptionUtils.getStackTrace(e)); | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |         } |  |  |  |         } | 
			
		
	
		
		
			
				
					
					|  |  |  |     } |  |  |  |     } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |     public static void jasperReport(HttpServletRequest request, HttpServletResponse response, String data, String jasperResource, String type) throws IOException, JRException { |  |  |  |     public static void jasperReport(HttpServletRequest request, HttpServletResponse response, String data, String jasperResource, String type) throws IOException, JRException { | 
			
		
	
		
		
			
				
					
					|  |  |  |         try { |  |  |  |         try { | 
			
		
	
		
		
			
				
					
					|  |  |  |             HashMap<String, Object> map = new HashMap<String, Object>(); |  |  |  |             HashMap<String, Object> map = new HashMap<String, Object>(); | 
			
		
	
		
		
			
				
					
					|  |  |  |             logger.error(JSON.toJSONString(data)); |  |  |  |             log.error(JSON.toJSONString(data)); | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |             InputStream is = new ByteArrayInputStream(data.getBytes("UTF-8")); |  |  |  |             InputStream is = new ByteArrayInputStream(data.getBytes("UTF-8")); | 
			
		
	
		
		
			
				
					
					|  |  |  |             map.put("JSON_INPUT_STREAM", is); //填充报表数据
 |  |  |  |             map.put("JSON_INPUT_STREAM", is); //填充报表数据
 | 
			
		
	
		
		
			
				
					
					|  |  |  |             map.put(JsonQueryExecuterFactory.JSON_LOCALE, Locale.ENGLISH); |  |  |  |             map.put(JsonQueryExecuterFactory.JSON_LOCALE, Locale.ENGLISH); | 
			
		
	
	
		
		
			
				
					|  |  | @ -100,8 +103,7 @@ public class JasperUtils { | 
			
		
	
		
		
			
				
					
					|  |  |  |                 os.close(); |  |  |  |                 os.close(); | 
			
		
	
		
		
			
				
					
					|  |  |  |             } |  |  |  |             } | 
			
		
	
		
		
			
				
					
					|  |  |  |         } catch (Exception e) { |  |  |  |         } catch (Exception e) { | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  |             log.error(ExceptionUtils.getStackTrace(e)); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |             e.printStackTrace(); |  |  |  |  | 
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |         } |  |  |  |         } | 
			
		
	
		
		
			
				
					
					|  |  |  |     } |  |  |  |     } | 
			
		
	
	
		
		
			
				
					|  |  | @ -128,9 +130,7 @@ public class JasperUtils { | 
			
		
	
		
		
			
				
					
					|  |  |  |             JasperExportManager.exportReportToPdfFile(jasperPrint, filePath); |  |  |  |             JasperExportManager.exportReportToPdfFile(jasperPrint, filePath); | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |         } catch (Exception e) { |  |  |  |         } catch (Exception e) { | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  |             log.error(ExceptionUtils.getStackTrace(e)); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |             e.printStackTrace(); |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  |  | 
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |         } |  |  |  |         } | 
			
		
	
		
		
			
				
					
					|  |  |  |     } |  |  |  |     } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
	
		
		
			
				
					|  |  | 
 |