|
@@ -0,0 +1,55 @@
|
|
|
+package cn.com.ctop.common.module.service.impl;
|
|
|
+
|
|
|
+import cn.com.ctop.common.module.service.IUReportExportService;
|
|
|
+import com.bstek.ureport.export.ExportConfigureImpl;
|
|
|
+import com.bstek.ureport.export.ExportManager;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.jeecg.common.util.DateUtils;
|
|
|
+import org.jeecg.common.util.SpringContextUtils;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.web.client.RestTemplate;
|
|
|
+
|
|
|
+import java.io.*;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+@Service
|
|
|
+@Slf4j
|
|
|
+public class UReportExportServiceImpl implements IUReportExportService {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ RestTemplate restTemplate;
|
|
|
+ private static final String outputDir=System.getProperty("user.dir")+File.separator + "uReport";
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void exportExcel(String fileName) {
|
|
|
+
|
|
|
+ String now= DateUtils.date2Str();
|
|
|
+ Map<String, Object> parameters=new HashMap<>();
|
|
|
+ parameters.put("start_date",now);
|
|
|
+ parameters.put("end_date",now);
|
|
|
+ parameters.put("stat_date,",now);
|
|
|
+ File file=new File(outputDir+File.separator);
|
|
|
+ OutputStream outputStream=null;
|
|
|
+ try {
|
|
|
+ outputStream=new FileOutputStream(file,true);
|
|
|
+ ExportConfigureImpl exportConfigure=new ExportConfigureImpl(fileName,parameters,outputStream);
|
|
|
+ getExportManager().exportExcel(exportConfigure);
|
|
|
+ } catch (FileNotFoundException e) {
|
|
|
+ log.error("定制化报表下载错误>>>UReportExportServiceImpl");
|
|
|
+ }finally {
|
|
|
+ if(outputStream!=null){
|
|
|
+ try {
|
|
|
+ outputStream.close();
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ private static ExportManager getExportManager(){
|
|
|
+ return (ExportManager)SpringContextUtils.getBean(ExportManager.BEAN_ID);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|