Merge branch 'open_gj' into 'master'
多个查询结果及询价单传给渤海 See merge request !204
This commit is contained in:
+83
-9
@@ -49,6 +49,7 @@ import org.springframework.web.multipart.commons.CommonsMultipartFile;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.*;
|
||||
import java.net.URL;
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
@@ -452,12 +453,25 @@ public class WeiXinEvaluationController {
|
||||
if(fjtUser!=null && fjtUser.getRole()==17) {
|
||||
System.out.println("渤海地址搜索 "+evaluation.getAddress());
|
||||
List<JSONObject> bhDists = BHBankUtils.getDistrictByBhbank(evaluation.getAddress());
|
||||
JSONObject o = null;
|
||||
if(bhDists.size()<1){
|
||||
bhDists = BHBankUtils.getDistrictByBhbank(district.getName());
|
||||
o = bhDists.get(0);
|
||||
}else if(bhDists.size()>1){
|
||||
int mod = Integer.MAX_VALUE;
|
||||
for(JSONObject jo : bhDists){
|
||||
double price = Double.valueOf((String)jo.get("price"));
|
||||
int bhprice = (int)price;
|
||||
int bhmod = Math.abs(bhprice - avgPrice);
|
||||
if(bhmod<mod){
|
||||
mod = bhmod;
|
||||
o = jo;
|
||||
}
|
||||
}
|
||||
}
|
||||
Map<String, String> bhMatchMap = new HashMap<String, String>();
|
||||
if(bhDists.size()==1){
|
||||
JSONObject o = bhDists.get(0);
|
||||
if(o != null){
|
||||
|
||||
String bhDistName = (String)o.get("name");
|
||||
String regionCode = String.valueOf((Long)o.get("country"));
|
||||
String bhRegion = BHBankUtils.regionCodeMap.get(regionCode);
|
||||
@@ -982,13 +996,14 @@ public class WeiXinEvaluationController {
|
||||
if(StringUtils.isNotBlank(model.getEvaluationId()) && StringUtils.isNotBlank(model.getEmail())){
|
||||
|
||||
UserTrades userTrade = userTradesService.findUserTradesByEvaluationId(model.getEvaluationId());
|
||||
|
||||
FjtEvaluation evaluation = fjtEvaluationService.findEvaluationById(Long.valueOf(model.getEvaluationId()));
|
||||
if(userTrade != null){
|
||||
userTrade.setSend(1);
|
||||
userTrade.setSendEmail(model.getEmail());
|
||||
userTradesService.update(userTrade);
|
||||
}else{
|
||||
FjtEvaluation evaluation = fjtEvaluationService.findEvaluationById(Long.valueOf(model.getEvaluationId()));
|
||||
|
||||
|
||||
userTrade = new UserTrades();
|
||||
userTrade.setUserId(evaluation.getUserId());
|
||||
userTrade.setCity(evaluation.getCity());
|
||||
@@ -1013,15 +1028,37 @@ public class WeiXinEvaluationController {
|
||||
try {
|
||||
String smsContent = "【房价网】微信询价报告发送 用户邮箱:"+model.getEmail();
|
||||
smsService.sendDingMsgByRobot(DD_ID, smsContent);
|
||||
|
||||
|
||||
} catch (SmsException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
sendToEmail(model.getFjtUrlKey(), model.getEvaluationId(), model.getEmail());
|
||||
|
||||
FjtUsers users = fjtUsersService.findById(evaluation.getUserId());
|
||||
if(users!=null && users.getRole()==17){
|
||||
|
||||
String converFileName = DateUtils.format(new Date(), "yyyy-MM-dd") +"_"+evaluation.getReportNum()+".pdf";
|
||||
String url = model.getFjtUrlKey() + "/evaluation/exportPdf?evaluationId="+model.getEvaluationId()+"&bkoffDownload=true&userId="+users.getId();
|
||||
String fontUrl = ActionContext.getContext().getServletContext().getRealPath("/") + "files" + File.separator + model.getEvaluationId() + File.separator;
|
||||
|
||||
System.out.println(fontUrl);
|
||||
try {
|
||||
createFile(fontUrl+converFileName);
|
||||
download(url, fontUrl, converFileName);
|
||||
List<File> uploadfiles = new ArrayList<File>();
|
||||
uploadfiles.add(new File(fontUrl+converFileName));
|
||||
if(uploadfiles.size()>0){
|
||||
BohaiEvaluationAudit boAudit = bohaiEvaluationAuditService.findByBohaiEvaluationAuditId(evaluation.getId());
|
||||
if(boAudit != null){
|
||||
UsersDetail usersDetail = usersDetailService.findById(users.getId());
|
||||
BHBankUtils.inquireUploadFiles2(usersDetail.getName(),boAudit.getQueryId(), 1, uploadfiles);
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
//处理异常信息
|
||||
}
|
||||
}
|
||||
}
|
||||
return jsonMmodel;
|
||||
}
|
||||
@@ -1307,8 +1344,45 @@ public class WeiXinEvaluationController {
|
||||
}
|
||||
}
|
||||
|
||||
public static void download(String url, String saveDir, String fileName) {
|
||||
|
||||
BufferedOutputStream bos = null;
|
||||
InputStream is = null;
|
||||
try {
|
||||
byte[] buff = new byte[8192];
|
||||
is = new URL(url).openStream();
|
||||
File file = new File(saveDir, fileName);
|
||||
file.getParentFile().mkdirs();
|
||||
bos = new BufferedOutputStream(new FileOutputStream(file));
|
||||
int count = 0;
|
||||
while ( (count = is.read(buff)) != -1) {
|
||||
bos.write(buff, 0, count);
|
||||
}
|
||||
}
|
||||
catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
finally {
|
||||
if (is != null) {
|
||||
try {
|
||||
is.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
if (bos != null) {
|
||||
try {
|
||||
bos.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
//将InputStream类型转化为File类型
|
||||
private static void inputStreamToFile(InputStream ins, File file) {
|
||||
private static void inputStreamToFile(InputStream ins, File file) {
|
||||
//将输出流转化为文件即可
|
||||
FileOutputStream os = null;
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user