首页改成流量统计,导出图片改为js
This commit is contained in:
@@ -1,9 +1,5 @@
|
||||
package com.nis.web.controller.dashboard;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.io.StringReader;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
@@ -11,18 +7,9 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.ServletOutputStream;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.batik.transcoder.SVGAbstractTranscoder;
|
||||
import org.apache.batik.transcoder.TranscoderException;
|
||||
import org.apache.batik.transcoder.TranscoderInput;
|
||||
import org.apache.batik.transcoder.TranscoderOutput;
|
||||
import org.apache.batik.transcoder.image.ImageTranscoder;
|
||||
import org.apache.batik.transcoder.image.JPEGTranscoder;
|
||||
import org.apache.batik.transcoder.image.PNGTranscoder;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
@@ -45,7 +32,6 @@ import com.nis.domain.SysDataDictionaryItem;
|
||||
import com.nis.domain.configuration.WebsiteDomainTopic;
|
||||
import com.nis.util.CodeDicUtils;
|
||||
import com.nis.util.Constants;
|
||||
import com.nis.util.DateUtils;
|
||||
import com.nis.util.DictUtils;
|
||||
import com.nis.util.StringUtil;
|
||||
import com.nis.util.httpclient.HttpClientUtil;
|
||||
@@ -791,78 +777,5 @@ public class DashboardController extends BaseController{
|
||||
|
||||
System.out.println(map2.get("c"));
|
||||
}
|
||||
/**
|
||||
* HighCharts导出图片
|
||||
* @param response
|
||||
* @param request
|
||||
* @param page
|
||||
* @throws ServletException, IOException
|
||||
*/
|
||||
@RequestMapping(value="saveAsImage")
|
||||
public void toSaveAsImage(HttpServletResponse response,HttpServletRequest request) throws ServletException, IOException{
|
||||
request.setCharacterEncoding("utf-8"); //设置UTF-8编码,解决乱码问题
|
||||
String type = request.getParameter("type");
|
||||
String svg = request.getParameter("svg");
|
||||
String filename = request.getParameter("filename");
|
||||
filename = filename==null?"chart":filename;
|
||||
ServletOutputStream out = response.getOutputStream();
|
||||
if (null != type && null != svg) {
|
||||
svg = svg.replaceAll(":rect", "rect");
|
||||
String ext = "";
|
||||
PNGTranscoder t = null;
|
||||
JPEGTranscoder t1=null;
|
||||
if (type.equals("image/png")) {
|
||||
ext = "png";
|
||||
t = new PNGTranscoder();
|
||||
t.addTranscodingHint( ImageTranscoder.KEY_BACKGROUND_COLOR, Color.black);
|
||||
} else if (type.equals("image/jpeg")) {
|
||||
ext = "jpg";
|
||||
t1 = new JPEGTranscoder();
|
||||
t1.addTranscodingHint( ImageTranscoder.KEY_BACKGROUND_COLOR, Color.black);
|
||||
} /*else if (type.equals("application/pdf")) {
|
||||
ext = "pdf";
|
||||
t = new PDFTranscoder();
|
||||
}*/ else if(type.equals("image/svg+xml"))
|
||||
ext = "svg";
|
||||
String dateTime = DateUtils.getDateTime();
|
||||
response.addHeader("Content-Disposition", "attachment; filename="+ filename+"-"+dateTime + "."+ext);
|
||||
response.addHeader("Content-Type", type);
|
||||
|
||||
if (null != t) {
|
||||
TranscoderInput input = new TranscoderInput(new StringReader(svg));
|
||||
TranscoderOutput output = new TranscoderOutput(out);
|
||||
|
||||
try {
|
||||
((SVGAbstractTranscoder) t).transcode(input, output);
|
||||
} catch (TranscoderException e) {
|
||||
out.print("Problem transcoding stream. See the web logs for more details.");
|
||||
e.printStackTrace();
|
||||
}
|
||||
} else if (null != t1) {
|
||||
TranscoderInput input = new TranscoderInput(new StringReader(svg));
|
||||
TranscoderOutput output = new TranscoderOutput(out);
|
||||
|
||||
try {
|
||||
((SVGAbstractTranscoder) t1).transcode(input, output);
|
||||
} catch (TranscoderException e) {
|
||||
out.print("Problem transcoding stream. See the web logs for more details.");
|
||||
e.printStackTrace();
|
||||
}
|
||||
} else if (ext.equals("svg")) {
|
||||
// out.print(svg);
|
||||
OutputStreamWriter writer = new OutputStreamWriter(out, "UTF-8");
|
||||
writer.append(svg);
|
||||
writer.close();
|
||||
} else
|
||||
out.print("Invalid type: " + type);
|
||||
} else {
|
||||
response.addHeader("Content-Type", "text/html");
|
||||
out.println("Usage:\n\tParameter [svg]: The DOM Element to be converted." +
|
||||
"\n\tParameter [type]: The destination MIME type for the elment to be transcoded.");
|
||||
}
|
||||
out.flush();
|
||||
out.close();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user