temp存放

This commit is contained in:
沈健
2021-04-08 19:01:40 +08:00
parent 85ba3ac4aa
commit 7df12d494e
7 changed files with 245 additions and 120 deletions
+11
View File
@@ -147,5 +147,16 @@
<version>1.0.0</version> <version>1.0.0</version>
<classifier>jdk18</classifier> <classifier>jdk18</classifier>
</dependency> </dependency>
<dependency>
<groupId>org.xhtmlrenderer</groupId>
<artifactId>core-renderer</artifactId>
<version>R8</version>
</dependency>
<dependency>
<groupId>org.sothis</groupId>
<artifactId>sothis-core</artifactId>
<version>0.1.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
</dependencies> </dependencies>
</project> </project>
@@ -1,6 +1,5 @@
package com.fangjia.open.controllers.weixin; package com.fangjia.open.controllers.weixin;
import com.fangjia.core.util.BeanUtils;
import com.fangjia.core.util.DataUtil; import com.fangjia.core.util.DataUtil;
import com.fangjia.core.util.GeocodeUtils; import com.fangjia.core.util.GeocodeUtils;
import com.fangjia.dal.QueryParam; import com.fangjia.dal.QueryParam;
@@ -8,23 +7,30 @@ import com.fangjia.dal.SdQuery;
import com.fangjia.dal.SrQuery; import com.fangjia.dal.SrQuery;
import com.fangjia.dal.seaweed.model.District; import com.fangjia.dal.seaweed.model.District;
import com.fangjia.open.compatible.model.JsonModel; import com.fangjia.open.compatible.model.JsonModel;
import com.fangjia.open.controllers.PropertyController;
import com.fangjia.open.model.BaseModel; import com.fangjia.open.model.BaseModel;
import com.fangjia.open.model.weixin.EvaluationModel; import com.fangjia.open.model.weixin.EvaluationModel;
import com.fangjia.open.model.weixin.PropertyEvaluationModel; import com.fangjia.open.model.weixin.PropertyEvaluationModel;
import com.fangjia.service.api.AutoCompleteBo; import com.fangjia.service.api.AutoCompleteBo;
import com.fangjia.service.datastore.DistrictService; import com.fangjia.service.datastore.DistrictService;
import com.lowagie.text.pdf.BaseFont;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.apache.lucene.index.Term; import org.apache.lucene.index.Term;
import org.apache.lucene.search.BooleanClause; import org.apache.lucene.search.BooleanClause;
import org.apache.lucene.search.BooleanQuery; import org.apache.lucene.search.BooleanQuery;
import org.apache.lucene.search.TermQuery; import org.apache.lucene.search.TermQuery;
import org.sothis.web.mvc.ActionContext;
import org.sothis.web.mvc.annotation.Param; import org.sothis.web.mvc.annotation.Param;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.xhtmlrenderer.pdf.ITextFontResolver;
import org.xhtmlrenderer.pdf.ITextRenderer;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@@ -52,6 +58,34 @@ public class CcbRentController {
return result; return result;
} }
public void downloadAction(HttpServletResponse response, HttpServletRequest request) throws IOException {
response.setHeader("Content-disposition", "attachment; filename=temp.pdf");
response.setContentType("application/pdf;charset=UTF-8");
response.setCharacterEncoding("UTF-8");
OutputStream os = null;
try {
os = response.getOutputStream();
ITextRenderer renderer = new ITextRenderer(35, 20);
ITextFontResolver fontResolver = renderer.getFontResolver();
String url = "http://localhost:8080/open/ccbRent/detail";
renderer.setDocument(url);
String fontUrl = ActionContext.getContext().getServletContext().getRealPath("/") + "fonts" + File.separator + "simsun.ttc";
fontResolver.addFont(fontUrl, BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED);
renderer.layout();
renderer.createPDF(os, true);
renderer.finishPDF();
System.out.println();
os.flush();
os.close();
} catch (Exception e) {
e.printStackTrace();
} finally {
if (os != null) {
os.close();
}
}
}
/** /**
* 方法同DistrictController#suggestAction * 方法同DistrictController#suggestAction
*/ */
@@ -1,22 +1,26 @@
<#ftl attributes={"content_type":"text/html; charset=UTF-8"}> <#ftl attributes={"content_type":"text/html; charset=UTF-8"}>
<#compress> <#compress>
<!DOCTYPE html> <!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/html"> <html>
<head> <head>
<meta charset="utf-8"> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="referrer" content="no-referrer"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
<title>租金报告中心</title> <title>租金报告中心</title>
<meta name="viewport" content="initial-scale=1, maximum-scale=1"> <meta name="viewport" content="initial-scale=1, maximum-scale=1"/>
<link rel="shortcut icon" href="/favicon.ico"> <link rel="shortcut icon" href="/favicon.ico"/>
<meta name="apple-mobile-web-app-capable" content="yes"> <meta name="apple-mobile-web-app-capable" content="yes"/>
<meta name="apple-mobile-web-app-status-bar-style" content="black"> <meta name="apple-mobile-web-app-status-bar-style" content="black"/>
<link rel="stylesheet" href="http://g.alicdn.com/msui/sm/0.6.2/css/sm.css"> <link rel="stylesheet" href="http://g.alicdn.com/msui/sm/0.6.2/css/sm.css"/>
<link rel="stylesheet" href="../static/style/wx.css"> <link rel="stylesheet" href="../static/style/wx.css"/>
<style type="text/css"> <style type="text/css">
body { body {
overflow: hidden; overflow: hidden;
overflow-y: scroll; overflow-y: scroll;
background: #f8f8f8;
/** 特别注意,否则中文不生效 **/
font-family: SimSun;
} }
.main { .main {
margin: 4px 8px 4px 8px; margin: 4px 8px 4px 8px;
@@ -76,12 +80,12 @@
<div> <div>
<div class="title1">2 评估时间</div> <div class="title1">2 评估时间</div>
<div class="p"> <div class="p">
<span name="cal_date"></span><br> <span name="cal_date"></span><br/>
评估结果<br> 评估结果<br/>
楼盘名称:<span name="name"></span><br> 楼盘名称:<span name="name"></span><br/>
楼盘地址:<span name="address"></span><br> 楼盘地址:<span name="address"></span><br/>
租金估值(RMB):<span name="totalPrice"></span>元/月<br> 租金估值(RMB):<span name="totalPrice"></span>元/月<br/>
大写(人民币):<span name="totalPriceUpper"></span><br> 大写(人民币):<span name="totalPriceUpper"></span><br/>
</div> </div>
</div> </div>
<div> <div>
@@ -91,15 +95,15 @@
<div> <div>
<div class="title1">4 房产状况</div> <div class="title1">4 房产状况</div>
<div class="p"> <div class="p">
详细地址:<span name="address"></span><br> 详细地址:<span name="address"></span><br/>
楼盘名称:<span name="name"></span><br> 楼盘名称:<span name="name"></span><br/>
室号:<span name="room"></span><br> 室号:<span name="room"></span><br/>
朝向:<span name="direction"></span><br> 朝向:<span name="direction"></span><br/>
建筑面积:<span name="size"></span>平米<br> 建筑面积:<span name="size"></span>平米<br/>
所在楼层:<span name="floor"></span> 层 <span name="height"></span>总层数<br> 所在楼层:<span name="floor"></span> 层 <span name="height"></span>总层数<br/>
电梯配套:<span name="hasLift"></span><br> 电梯配套:<span name="hasLift"></span><br/>
装修情况:<span name="fitment"></span><br> 装修情况:<span name="fitment"></span><br/>
建筑年代:<span name="buildYear"></span><br> 建筑年代:<span name="buildYear"></span><br/>
</div> </div>
</div> </div>
<div> <div>
@@ -199,30 +203,68 @@
<script type='text/javascript' src='http://g.alicdn.com/sj/lib/zepto/zepto.js' charset='utf-8'></script> <script type='text/javascript' src='http://g.alicdn.com/sj/lib/zepto/zepto.js' charset='utf-8'></script>
<script type='text/javascript' src='http://g.alicdn.com/msui/sm/0.6.2/js/sm.js' charset='utf-8'></script> <script type='text/javascript' src='http://g.alicdn.com/msui/sm/0.6.2/js/sm.js' charset='utf-8'></script>
<script type="text/javascript" src="http://cdn.hcharts.cn/highcharts/highcharts.js"></script> <!-- 暂时注释 -->
<#-- <script type="text/javascript" src="http://cdn.hcharts.cn/highcharts/highcharts.js"></script>-->
<script type='text/javascript' src='../static/js/wx.js' charset='utf-8'></script> <script type='text/javascript' src='../static/js/wx.js' charset='utf-8'></script>
<script type="text/javascript" src="../static/js/trend-charts.js"></script> <script type="text/javascript" src="../static/js/trend-charts.js"></script>
<script src="https://html2canvas.hertzen.com/dist/html2canvas.js"></script>
<!-- 2.3.1 -->
<script src="../static/js/jspdf.umd.js"></script>
<#-- <script src="../static/js/SourceHanSans-normal.js"></script>-->
<script src="../static/js/simsun-normal.js"></script>
<#-- <script type="text/javascript">-->
<#-- $("#download").bind('click', function(){-->
<#-- window.location.href = "download"-->
<#-- // 打印所有可用的字体-->
<#-- // jspdf.html(document.body, {-->
<#-- // callback: function (doc) {-->
<#-- // doc.save("租金报告.pdf");-->
<#-- // },-->
<#-- // x: 10,-->
<#-- // y: 10-->
<#-- // });-->
<#-- // jspdf.html("test测试", {-->
<#-- // callback: function (doc) {-->
<#-- // doc.save("租金报告.pdf");-->
<#-- // },-->
<#-- // x: 10,-->
<#-- // y: 10-->
<#-- // });-->
<#-- });-->
<#-- $(function () {-->
<#-- $('span[name="name"]').text('场中小区');-->
<#-- });-->
<#-- </script>-->
<script type="text/javascript"> <script type="text/javascript">
$("#download").bind("click", function(){ debugger
window.jsPDF = window.jspdf.jsPDF
var jspdf = new jsPDF();
// jspdf.addFileToVFS('SourceHanSans-Normal.ttf',normalChinese);
// jspdf.addFont('SourceHanSans-Normal.ttf', 'SourceHanSans-Normal', 'normal');
jspdf.setFont('simsun');
// jspdf.setFont('SourceHanSans-Light');
console.log(jspdf.getFontList());
$("#download").bind('click', function(){
//window.location.href = "download"
// 打印所有可用的字体
// jspdf.html(document.body, {
// callback: function (doc) {
// doc.save("租金报告.pdf");
// },
// x: 10,
// y: 10
// });
jspdf.html("test测试", {
callback: function (doc) {
doc.save("租金报告.pdf");
},
x: 10,
y: 10
});
}); });
function init() { function init() {
// 后台传参过来用 // 后台传参过来用
<#--let params = {-->
<#-- 'city': '${cityName}',-->
<#-- 'district': '${district}',-->
<#-- 'name': '${name}',-->
<#-- 'address': '${address}',-->
<#-- 'size': '${size}',-->
<#-- 'floor': '${floor}',-->
<#-- 'height': '${height}',-->
<#-- 'room': '${room}',-->
<#-- 'hall': '${hall}',-->
<#-- 'toilet': '${toilet}',-->
<#-- 'direction': <#if direction??>${direction}<#else>''</#if>,-->
<#-- 'fitment': <#if fitment??>${fitment}<#else>''</#if>-->
<#--};-->
let params = { let params = {
'city': sessionStorage.city, 'city': sessionStorage.city,
'district': sessionStorage.district, 'district': sessionStorage.district,
@@ -275,7 +317,6 @@
charts.xData = result.trends.times; // 横坐标值 charts.xData = result.trends.times; // 横坐标值
createChartNow('districtRentTrendsChart', charts, true); createChartNow('districtRentTrendsChart', charts, true);
} }
// 房产状况 // 房产状况
$('span[name="room"]').text(result.room) $('span[name="room"]').text(result.room)
$('span[name="direction"]').text(result.direction) $('span[name="direction"]').text(result.direction)
@@ -421,14 +462,14 @@
if(this.series.name.indexOf('成交量') > -1) { if(this.series.name.indexOf('成交量') > -1) {
return Highcharts.dateFormat('%Y年%m月', this.x) +" 成交: <span style='color:#F50;font-weight: bold;'>"+ this.y +'</span>套'; return Highcharts.dateFormat('%Y年%m月', this.x) +" 成交: <span style='color:#F50;font-weight: bold;'>"+ this.y +'</span>套';
}else { }else {
return Highcharts.dateFormat('%Y-%m-%d', this.x) +'<br>'+ this.series.name+ ": <span style='color:#F50;font-weight: bold;'>"+ this.y +'</span>元/平米'; return Highcharts.dateFormat('%Y-%m-%d', this.x) +'<br/>'+ this.series.name+ ": <span style='color:#F50;font-weight: bold;'>"+ this.y +'</span>元/平米';
} }
} }
} }
}); });
}; };
$(function () { $(function () {
init(); //init();
}); });
</script> </script>
</body> </body>
@@ -1,72 +1,13 @@
<#ftl attributes={"content_type":"text/html; charset=UTF-8"}> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<#compress> <html xmlns="http://www.w3.org/1999/xhtml">
<!DOCTYPE html> <head>
<html> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<head> <meta name="referrer" content="no-referrer"/>
<meta charset="utf-8"> <style type="text/css" mce_bogus="1">
<meta http-equiv="X-UA-Compatible" content="IE=edge"> body {font-family: SimSun;}
<title>租金报告中心</title> </style>
<meta name="viewport" content="initial-scale=1, maximum-scale=1"> </head>
<link rel="shortcut icon" href="/favicon.ico"> <body>
<meta name="apple-mobile-web-app-capable" content="yes"> 测试2223test
<meta name="apple-mobile-web-app-status-bar-style" content="black"> </body>
</html>
<link rel="stylesheet" href="http://g.alicdn.com/msui/sm/0.6.2/css/sm.css">
<link rel="stylesheet" href="../static/style/wx.css">
</head>
<body>
<div class="page-group">
<div class="page page-current">
<div class="content">
<div class="list-block" style="margin-bottom:60px;">
<a href="javascript:void(0)" onclick="javascript:history.back(-1);" class="button_12 blue blue_borderbottom radius4"><返回</a>
<ul>
<li>
<div class="item-content">
<div class="item-inner">
<div class="item-title label">您评估的地址:</div>
<div class="item-input">
<input type="text" disabled id="districtSearch" name="name" value="${lender}">
</div>
</div>
</div>
</li>
<li>
<div class="item-content">
<div class="item-inner">
<div class="item-title label">租金:</div>
<div class="item-input">
<input type="text" name="mount" disabled name="evaluation.mount" value="${dealPrice}元/月">
</div>
</div>
</div>
</li>
</ul>
</div>
<div class="content-block">
<p><a id="evaluateBtn" class="button button-big button-fill">查看租金报告</a></p>
</div>
</div>
</div>
</div>
<script type='text/javascript' src='http://g.alicdn.com/sj/lib/zepto/zepto.js' charset='utf-8'></script>
<script type='text/javascript' src='http://g.alicdn.com/msui/sm/0.6.2/js/sm.js' charset='utf-8'></script>
<script type='text/javascript' src='../static/js/wx.js' charset='utf-8'></script>
<script type="text/javascript">
$("#evaluateBtn").on('click', function(){
window.location.href = "detail"
});
function init() {
};
$(function () {
init();
});
</script>
</body>
</html>
</#compress>
@@ -0,0 +1,72 @@
<#ftl attributes={"content_type":"text/html; charset=UTF-8"}>
<#compress>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>租金报告中心</title>
<meta name="viewport" content="initial-scale=1, maximum-scale=1">
<link rel="shortcut icon" href="/favicon.ico">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<link rel="stylesheet" href="http://g.alicdn.com/msui/sm/0.6.2/css/sm.css">
<link rel="stylesheet" href="../static/style/wx.css">
</head>
<body>
<div class="page-group">
<div class="page page-current">
<div class="content">
<div class="list-block" style="margin-bottom:60px;">
<a href="javascript:void(0)" onclick="javascript:history.back(-1);" class="button_12 blue blue_borderbottom radius4"><返回</a>
<ul>
<li>
<div class="item-content">
<div class="item-inner">
<div class="item-title label">您评估的地址:</div>
<div class="item-input">
<input type="text" disabled id="districtSearch" name="name" value="${lender}">
</div>
</div>
</div>
</li>
<li>
<div class="item-content">
<div class="item-inner">
<div class="item-title label">租金:</div>
<div class="item-input">
<input type="text" name="mount" disabled name="evaluation.mount" value="${dealPrice}元/月">
</div>
</div>
</div>
</li>
</ul>
</div>
<div class="content-block">
<p><a id="evaluateBtn" class="button button-big button-fill">查看租金报告</a></p>
</div>
</div>
</div>
</div>
<script type='text/javascript' src='http://g.alicdn.com/sj/lib/zepto/zepto.js' charset='utf-8'></script>
<script type='text/javascript' src='http://g.alicdn.com/msui/sm/0.6.2/js/sm.js' charset='utf-8'></script>
<script type='text/javascript' src='../static/js/wx.js' charset='utf-8'></script>
<script type="text/javascript">
$("#evaluateBtn").on('click', function(){
window.location.href = "detail"
});
function init() {
};
$(function () {
init();
});
</script>
</body>
</html>
</#compress>
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long