java 数据生成 图片
package cn.luxin.托尔斯泰;import java.util.List;/*** @ClassName: ChildrenInfo* @Description:* @Author* @Date 2019/5/16 15:37* @Version V1.0**/
public class ChildrenInfo {//人或公司idprivate String id;//名称private String name;//H 人 C公司private String type;//金额private String amount;//占比private String percent;//股东类型private String sh_type;//子节点private List children;//private String regCapital;//父节点名称private String parentName;public String getId() {return id;}public void setId(String id) {this.id = id;}public String getName() {return name;}public void setName(String name) {this.name = name;}public String getType() {return type;}public void setType(String type) {this.type = type;}public String getAmount() {return amount;}public void setAmount(String amount) {this.amount = amount;}public String getPercent() {return percent;}public void setPercent(String percent) {this.percent = percent;}public String getSh_type() {return sh_type;}public void setSh_type(String sh_type) {this.sh_type = sh_type;}public List getChildren() {return children;}public void setChildren(List children) {this.children = children;}public String getRegCapital() {return regCapital;}public void setRegCapital(String regCapital) {this.regCapital = regCapital;}public String getParentName() {return parentName;}public void setParentName(String parentName) {this.parentName = parentName;}
}
package cn.luxin.托尔斯泰;import java.util.List;/*** 结构体信息* @ClassName: StructureInfo* @Description:* @Author* @Date 2019/5/16 15:24* @Version V1.0**/ public class StructureInfo {//公司idprivate String id;//公司名private String name;//H 人 C公司private String type;//金额private String amount;//占比private String percent;//股东类型private String sh_type;//子节点private Listchildren;//X轴private int X;//X轴private int Y;public String getId() {return id;}public void setId(String id) {this.id = id;}public String getName() {return name;}public void setName(String name) {this.name = name;}public String getType() {return type;}public void setType(String type) {this.type = type;}public String getAmount() {return amount;}public void setAmount(String amount) {this.amount = amount;}public String getPercent() {return percent;}public void setPercent(String percent) {this.percent = percent;}public String getSh_type() {return sh_type;}public void setSh_type(String sh_type) {this.sh_type = sh_type;}public List getChildren() {return children;}public void setChildren(List children) {this.children = children;}public int getX() {return X;}public void setX(int x) {X = x;}public int getY() {return Y;}public void setY(int y) {Y = y;} }
package cn.luxin;import club.newepoch.utils.JsonUtils; import cn.luxin.托尔斯泰.StructureInfo; import com.alibaba.fastjson.JSONObject; import com.sun.image.codec.jpeg.JPEGCodec; import com.sun.image.codec.jpeg.JPEGImageEncoder;import java.awt.*; import java.awt.image.BufferedImage; import java.io.BufferedOutputStream; import java.io.FileOutputStream; import java.util.ArrayList; import java.util.List; import java.util.Map;/*** 数据转换图片** @ClassName: PictureGeneration* @Description:* @Author* @Date 2019/5/16 21:01* @Version V1.0**/ public class PictureGeneration {//用于接受最大的Y轴数值int YTotal = 0;/*** 生成图片** @param cellsValue 表格里面的值*/public String myGraphicsGeneration(String cellsValue) {//初始化ListallChildNodes = new ArrayList <>();// 字体大小int fontTitileSize = 15;// 图片宽度int imageWidth = 900;// 图片高度int imageHeight = cellsValue.length() / 15 + 300;//生成空图片BufferedImage image = new BufferedImage(imageWidth, imageHeight, BufferedImage.TYPE_INT_RGB);//初始化绘画工具到空图片上Graphics graphics = image.getGraphics();//绘制背景颜色 graphics.setColor(Color.WHITE);//填充矩形graphics.fillRect(0, 0, imageWidth, imageHeight);graphics.setColor(new Color(0, 0, 0));//设置字体Font font = new Font("微软雅黑", Font.BOLD, fontTitileSize);graphics.setFont(font);//写入内容int x = 30;int y = 60;List
package cn.luxin;import club.newepoch.persistent.db.exception.ActiveRecordException; import org.eclipse.jdt.internal.compiler.batch.Main;import java.io.IOException;public class TYCInterfaceController {public static void main(String[] args) {try {new TYCInterfaceService().enterpriseInformationFile();} catch (IOException e) {e.printStackTrace();} catch (ActiveRecordException e) {e.printStackTrace();}}}
package cn.luxin;import club.newepoch.persistent.db.exception.ActiveRecordException; import club.newepoch.utils.StringUtils; import org.apache.poi.hssf.usermodel.HSSFCellStyle; import org.apache.poi.xssf.usermodel.*; import java.awt.*; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Date;/*** 天眼查接口Service** @ClassName: TYCInterfaceService* @Description:* @Author 李宏凯* @Date 2019/5/15 14:15* @Version V1.0**/ public class TYCInterfaceService {/*** 获取企业基本信息并且生成文件** @param ctl* @return*/ // public boolean getBusinessInfo(QhyfController ctl) throws IOException { // String result = ""; // boolean basicFileInfo = false; // try { // Listparams = new ArrayList // String id = ctl.getPara("id"); // if (StringUtils.notBlank(id)) { // params.add(new BasicNameValuePair("id", id)); // } // String name = ctl.getPara("name"); // if (StringUtils.notBlank(name)) { // params.add(new BasicNameValuePair("name", name)); // } // Date startTime = new Date(); // String str = EntityUtils.toString(new UrlEncodedFormEntity(params, Consts.UTF_8)); // String token = "21416d43-62b5-4522-9d6b-1072ff89bc54"; // String url = "http://open.api.tianyancha.com/services/v4/open/"; // String interfaceName = "baseinfo"; // // 根据地址获取请求 // HttpGet request = new HttpGet(url + interfaceName + "?" + str);//这里发送get请求 // // 获取当前客户端对象 // request.setHeader("Authorization", token); // HttpClient httpClient = new DefaultHttpClient(); // // 通过请求对象获取响应对象 // HttpResponse response = httpClient.execute(request); // // 判断网络连接状态码是否正常(0--200都数正常) // if (response.getStatusLine().getStatusCode() >= 0 && response.getStatusLine().getStatusCode() <= HttpStatus.SC_OK) { // result = EntityUtils.toString(response.getEntity(), "utf-8"); // } // updateTycHistory(response, startTime, interfaceName, url); // JSONObject results = JSONObject.fromObject(result); // if (!results.get("error_code").equals("0")) { // //AssertUtils.isTrue(false, results.get("reason").toString()); // } // // 企业基本信息文件生成 // //basicFileInfo = enterpriseInformationFile(ctl, results, id, token); // } catch (Exception e) { // e.printStackTrace(); // } // return basicFileInfo; // }/*** 企业基本信息文件生成*/public void enterpriseInformationFile(/*, JSONObject flieInfo, String id, String token*/) throws IOException, ActiveRecordException {/*//公司名称Object name = flieInfo.getJSONObject("result").get("name");//统一社会信用代码Object creditCode = flieInfo.getJSONObject("result").get("creditCode");//核准日期Object approvedTime = flieInfo.getJSONObject("result").get("approvedTime");*/Object name = "某某供应商";Object creditCode = "TYSHXYDM";Object approvedTime = "2019-05-05";//数据抓取时间Date date = new Date();SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");String dataCaptureTime = sdf.format(date);//股权结构图//String structureChartJosnInfo = getMessageByUrlToken(ctl, id, token);String jsonStr = "{\"error_code\":0, " +"\"reason\":\"ok\"," +"\"result\":{" +" \"path\":[" +" {" +" \"type\":\"name\"," +" \"value\":\"李彦宏\"," +" \"id\":\"1984012283\"," +" \"cid\":\"22822\" " +" }," +" {" +" \"type\":\"percent\"," +" \"value\":\"99.50%\"" +" }," +" {" +" \"type\":\"name\"," +" \"value\":\"北京百度网讯科技有限公司\"" +" }" +" ]," +" \"structure\":{" +" \"id\":\"22822\"," +" \"name\":\"北京百度网讯科技有限公司\"," +" \"type\":\"C\"," +" \"amount\":\"216042.36\"," +" \"percent\":\"99.50%\"," +" \"sh_type\":null," +" \"children\":[" +" {" +" \"id\":\"1984012283\"," +" \"name\":\"李彦宏1\"," +" \"type\":\"H\"," +" \"amount\":\"216042.36\"," +" \"percent\":\"99.50%\"," +" \"sh_type\":\"工商股东\"," +" \"children\":[ " +" {" +" \"id\":\"1984012283\"," +" \"name\":\"李彦宏2\"," +" \"type\":\"H\"," +" \"amount\":\"216042.36\"," +" \"percent\":\"99.50%\"," +" \"sh_type\":\"工商股东\"," +" \"children\":["+" {" +" \"id\":\"1984012283\"," +" \"name\":\"李彦宏3\"," +" \"type\":\"H\"," +" \"amount\":\"216042.36\"," +" \"percent\":\"99.50%\"," +" \"sh_type\":\"工商股东\"," +" \"children\":[ ]," +" \"regCapital\":null," +" \"parentName\":\"children\"," +" \"actualHolding\":true" +" }," +" {" +" \"id\":\"1839080315\"," +" \"name\":\"向海龙1\"," +" \"type\":\"H\"," +" \"amount\":\"1085.64\"," +" \"percent\":\"0.50%\"," +" \"sh_type\":\"工商股东\"," +" \"children\":[" +" {" +" \"id\":\"1839080315\"," +" \"name\":\"向海龙1\"," +" \"type\":\"H\"," +" \"amount\":\"1085.64\"," +" \"percent\":\"0.50%\"," +" \"sh_type\":\"工商股东\"," +" \"children\":[]," +" \"regCapital\":null," +" \"parentName\":\"children\"," +" \"actualHolding\":false" +" }" +" ]," +" \"regCapital\":null," +" \"parentName\":\"children\"," +" \"actualHolding\":false" +" }," +" {" +" \"id\":\"1984012283\"," +" \"name\":\"李彦宏4\"," +" \"type\":\"H\"," +" \"amount\":\"216042.36\"," +" \"percent\":\"99.50%\"," +" \"sh_type\":\"工商股东\"," +" \"children\":[ ]," +" \"regCapital\":null," +" \"parentName\":\"children\"," +" \"actualHolding\":true" +" }" +" ]," +" \"regCapital\":null," +" \"parentName\":\"children\"," +" \"actualHolding\":true" +" }" +" ]," +" \"regCapital\":null," +" \"parentName\":\"children\"," +" \"actualHolding\":true" +" }," +" {" +" \"id\":\"1984012283\"," +" \"name\":\"李彦宏5\"," +" \"type\":\"H\"," +" \"amount\":\"216042.36\"," +" \"percent\":\"99.50%\"," +" \"sh_type\":\"工商股东\"," +" \"children\":[ ]," +" \"regCapital\":null," +" \"parentName\":\"children\"," +" \"actualHolding\":true" +" }," +" ]," +" \"regCapital\":\"217128\"," +" \"parentName\":\"structure\"," +" \"actualHolding\":true" +" }"+" }" +"}";//图片生成PictureGeneration pictureGeneration = new PictureGeneration();pictureGeneration.myGraphicsGeneration(jsonStr);// 设置导出时间SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");String exportTime = sd.format(new Date());// 创建表头XSSFWorkbook workbook = new XSSFWorkbook();String savePath = "D:\\uploadTest\\";File save = new File(savePath);if (!save.exists() && !save.isDirectory()) {save.mkdirs();}String fileName = "某某供应商信息.xlsx";savePath = savePath + File.separator + fileName;FileOutputStream fout = new FileOutputStream(savePath);// 创建检测结果sheetXSSFSheet sheetPay = workbook.createSheet("供应商信息");sheetPay.createFreezePane(0, 1, 0, 1);// 设置付款单信息筛选 // CellRangeAddress payChoose = CellRangeAddress.valueOf("B1:V1"); // sheetPay.setAutoFilter(payChoose);XSSFRow headPayRow = sheetPay.createRow(0);// 设置付款单sheet行高sheetPay.setDefaultRowHeightInPoints(3 * 10);// 定义付款单sheet表头String[] headPayArr = {"公司名称", "统一社会信用代码", "核准日期", "数据抓取时间", "股权结构图"};// 单元格XSSFCell headPayCell = null;XSSFCellStyle style = workbook.createCellStyle();// 表头样式设置 style.setBorderBottom(XSSFCellStyle.BORDER_THIN);style.setBorderLeft(XSSFCellStyle.BORDER_THIN);style.setBorderTop(XSSFCellStyle.BORDER_THIN);style.setBorderRight(XSSFCellStyle.BORDER_THIN);// 设置背景色style.setFillForegroundColor(new XSSFColor(new Color(216, 216, 216)));style.setAlignment(HSSFCellStyle.ALIGN_CENTER); // 水平居中style.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);//垂直居中 style.setFillPattern(XSSFCellStyle.SOLID_FOREGROUND);// 设置表头字体XSSFFont headFont = workbook.createFont();// 字体样式headFont.setFontName("宋体");// 字体大小headFont.setFontHeightInPoints((short) 9);// 加粗headFont.setBold(true);style.setFont(headFont);// 列宽设置sheetPay.setColumnWidth(0, 2 * 256);// 公司名称sheetPay.setColumnWidth(1, 10 * 256);// 统一社会信用代码sheetPay.setColumnWidth(2, 15 * 256);// 核准日期sheetPay.setColumnWidth(3, 10 * 256);// 数据抓取时间sheetPay.setColumnWidth(4, 40 * 256);// 股权结构图// 写入付款通知书表头for (int i = 0; i < headPayArr.length; i++) {sheetPay.autoSizeColumn(i + 1);headPayCell = headPayRow.createCell(i + 1);headPayCell.setCellValue(headPayArr[i]);headPayCell.setCellStyle(style);}// 设置单元格样式XSSFCellStyle cellStyle = workbook.createCellStyle();// 边框 cellStyle.setBorderBottom(XSSFCellStyle.BORDER_THIN);cellStyle.setBorderLeft(XSSFCellStyle.BORDER_THIN);cellStyle.setBorderTop(XSSFCellStyle.BORDER_THIN);cellStyle.setBorderRight(XSSFCellStyle.BORDER_THIN);// 内容换行cellStyle.setWrapText(true);// 垂直居中 cellStyle.setVerticalAlignment(XSSFCellStyle.VERTICAL_CENTER);// 设置单元格字体XSSFFont font = workbook.createFont();// 字体样式font.setFontName("微软雅黑");// 字体大小font.setFontHeightInPoints((short) 9);cellStyle.setFont(font);// 加粗XSSFCell cellPay = null;XSSFRow rowPay = null;// 对各元素设值rowPay = sheetPay.createRow( 1);cellPay = rowPay.createCell(1);cellPay.setCellValue(name.toString());cellPay.setCellStyle(cellStyle);cellPay = rowPay.createCell(2);cellPay.setCellValue(creditCode.toString());cellPay.setCellStyle(cellStyle);cellPay = rowPay.createCell(3);cellPay.setCellValue(approvedTime.toString());cellPay.setCellStyle(cellStyle);cellPay = rowPay.createCell(4);cellPay.setCellValue(dataCaptureTime);cellPay.setCellStyle(cellStyle);cellPay = rowPay.createCell(5);cellPay.setCellStyle(cellStyle);// 保存到文件 workbook.write(fout);fout.close();// 保存文件信息到文件表String fileUuid = StringUtils.randomUuid();File file = new File(savePath); // FileInfo UpFileInfo = this.getFileInfoByUuid(fileUuid); // this.upload2cloud(UpFileInfo, true); // FileInfo fileInfo = new FileInfo(); // fileInfo.setFile(file); // fileInfo.setOriginalFileName(fileName); // SysFile saveFile = SysFileUtils.fileInfo2SysFile(fileInfo, null); // saveFile.set("uuid", fileUuid); // boolean isTrue = saveFile.save(); // if (isTrue) { // // 保存成功 // // 文件上传云端 // FileInfo UpFileInfo = this.getFileInfoByUuid(fileUuid); // this.upload2cloud(UpFileInfo, true); // // 更新绿城付款单数据表对应导出状态为已导出 // return fileUuid; // } else { // return null; // } }/*** 获取股权结构图数据** @param* @return*/ // public String getMessageByUrlToken( String id, String token) { // String result = ""; // JSONObject results = null; // try { // List(); params = new ArrayList // if (StringUtils.notBlank(id)) { // params.add(new BasicNameValuePair("id", id)); // } // Date startTime = new Date(); // String str = EntityUtils.toString(new UrlEncodedFormEntity(params, Consts.UTF_8)); // String url = "http://open.api.tianyancha.com/services/v4/open/"; // String interfaceName = "equityRatio"; // // 根据地址获取请求 // HttpGet request = new HttpGet(url + interfaceName + "?" + str); // // 获取当前客户端对象 // request.setHeader("Authorization", token); // HttpClient httpClient = new DefaultHttpClient(); // // 通过请求对象获取响应对象 // HttpResponse response = httpClient.execute(request); // // 判断网络连接状态码是否正常(0--200都数正常) // if (response.getStatusLine().getStatusCode() >= 0 && response.getStatusLine().getStatusCode() <= HttpStatus.SC_OK) { // result = EntityUtils.toString(response.getEntity(), "utf-8"); // } // updateTycHistory(response, startTime, interfaceName, url); // // if (!results.get("error_code").equals("0")) { // //AssertUtils.isTrue(false, results.get("reason").toString()); // } // } catch (Exception e) { // e.printStackTrace(); // } // return result; // }/*** 保存天眼查接口履历** @throws Exception*/ // public void updateTycHistory(HttpResponse response, Date startTime, String interfaceName, String url) throws Exception { // // 设置接口信息 // ApiCallInfo apiCallInfo = new ApiCallInfo(Thread.currentThread().getStackTrace()[2].getMethodName()); // if (response.getStatusLine().getStatusCode() >= 0 && response.getStatusLine().getStatusCode() <= HttpStatus.SC_OK) { // // 是否调用成功 // apiCallInfo.setCalled(true); // apiCallInfo.setResult(response); // } else { // // 是否调用成功 // apiCallInfo.setCalled(false); // // 设置返回信息 // apiCallInfo.setError(response.toString()); // } // // 接口名称 // apiCallInfo.setApi(interfaceName); // // 接口名称 // apiCallInfo.setSendApi(url + interfaceName); // // 履历接口调用类名 // apiCallInfo.setLocation(Thread.currentThread().getStackTrace()[2].getClassName()); // // 调用开始时间 // // apiCallInfo.setStartTime(startTime); // // 调用结束时间 // apiCallInfo.setEndTime(new Date()); // // 调用者 // apiCallInfo.setCallUser(BlConstant.FIELD_DB_CURRENT_SYSTEM_USER_ID); // // 保存风报接口调用履历 // IApiCallResultHandle callResult = new ApiCallResult2DbHandleImpl(); // callResult.handle(apiCallInfo, "biz_tyc_api_history"); // } }();
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> 4.0.0 com.qhyf qhyf 1.0.80-beta Qhyf-WEB http://ISCWX.newepoch.club 1.7.7 1.1.3 1.5.13-release 1.0.63-qhyf 1.3.46-release 1.2.41-release 1.0.71 0.0.3 1.0.19 0.0.122 0.0.70-SNAPSHOT 2.2.1 tommylee@leebing.com leebing NewEpoch@intasect newepoch@intasect.com.cn com.github.junrar junrar 0.7 org.apache.commons commons-pool2 2.4.2 redis.clients jedis 2.7.2 com.aliyun.oss aliyun-sdk-oss ${aliyun-version} org.docx4j docx4j 3.2.2 org.slf4j slf4j-log4j12 org.apache.poi poi-scratchpad org.apache.poi poi com.hynnet jacob 1.18 com.itextpdf itextpdf 5.5.9 club.newepoch BaseProject ${nebase.version} javax.servlet servlet-api org.docx4j docx4j 3.2.2 org.slf4j slf4j-log4j12 org.apache.poi poi 3.9 org.apache.poi poi-scratchpad 3.9 org.apache.poi poi-ooxml 3.9 club.newepoch iwx ${iwx.version} club.newepoch iweb ${iweb.version} club.newepoch.cordys CordysClient ${cordysclient.version} club.newepoch NeNio ${nenio.version} com.jfinal jetty-server 8.1.8 compile org.eclipse.jetty jetty-jsp 8.1.8.v20121106 provided com.github.jknack handlebars 2.2.2 com.jfinal cos 26Dec2008 junit junit 3.8.1 test commons-logging commons-logging 1.1.3 club.newepoch NewEpochMQ 1.0.9-release club.newepoch.Notify Notify-impl-nemq 0.0.3 club.newepoch SpringAmqpImpl 1.0.4-release club.newepoch IJfinal ${ijfinal-version} club.newepoch NewEpochDB net.sf.ehcache ehcache-core club.newepoch NewEpochDB ${nedb.version} club.newepoch NeNio com.alibaba druid 1.0.14 org.beetl beetl-core 2.2.3 commons-logging commons-logging 1.1.3 org.slf4j slf4j-api ${slf4j.version} org.slf4j jcl-over-slf4j ${slf4j.version} test org.slf4j jcl-over-slf4j ${slf4j.version} test ch.qos.logback logback-classic ${logback.version} ch.qos.logback logback-core ${logback.version} mysql mysql-connector-java 5.1.36 net.sf.ehcache ehcache-core 2.6.6 org.apache.ant ant 1.9.6 com.sun.media jai_codec 1.1.2 com.lowagie itext 2.0.7 javax.media jai_core 1.1.3 club.newepoch NewEpochCodeGenerator ${codeGenerator.version} com.aliyun.oss aliyun-sdk-oss ${aliyun-version} jaxen jaxen 1.1.6 com.aliyun aliyun-java-sdk-core 3.2.8 com.aliyun aliyun-java-sdk-dysmsapi 1.0.0 club.newepoch ijfinal-ext 0.0.3 org.apache.pdfbox pdfbox 2.0.13 com.google.zxing core 3.2.1 commons-discovery commons-discovery 0.2 org.apache.axis axis 1.4 javax.xml.rpc javax.xml.rpc-api 1.1.1 wsdl4j wsdl4j 1.5.1 javax.activation activation 1.1.1 javax.xml.soap saaj-api 1.3 javax.activation activation com.qhyf axis 0.0.1 com.qhyf myencrypt 0.0.1 com.qhyf xfire 0.0.1 club.newepoch.finance FinanceHttpApi 2.6-SNAPSHOT ${project.basedir}/src/main/java ${project.basedir}/src/test/java ${project.basedir}/src/main/resources false **/*.java ${project.basedir}/src/test/java false **/*.java ${project.basedir}/target maven-war-plugin ${basedir}/src/main/webapp ${basedir}/src/main/webapp false org.apache.maven.plugins maven-compiler-plugin 2.5 1.8 1.8 intasect intasect http://nemq.newepoch.club:7001/content/groups/intasect/ true true intasect intasect http://nemq.newepoch.club:7001/content/groups/intasect/ true false
转载于:https://www.cnblogs.com/xiaowoniulx/p/10931447.html
本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!
