多个查询结果及询价单传给渤海
This commit is contained in:
+79
-5
@@ -49,6 +49,7 @@ import org.springframework.web.multipart.commons.CommonsMultipartFile;
|
|||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
|
import java.net.URL;
|
||||||
import java.text.DecimalFormat;
|
import java.text.DecimalFormat;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
@@ -452,12 +453,25 @@ public class WeiXinEvaluationController {
|
|||||||
if(fjtUser!=null && fjtUser.getRole()==17) {
|
if(fjtUser!=null && fjtUser.getRole()==17) {
|
||||||
System.out.println("渤海地址搜索 "+evaluation.getAddress());
|
System.out.println("渤海地址搜索 "+evaluation.getAddress());
|
||||||
List<JSONObject> bhDists = BHBankUtils.getDistrictByBhbank(evaluation.getAddress());
|
List<JSONObject> bhDists = BHBankUtils.getDistrictByBhbank(evaluation.getAddress());
|
||||||
|
JSONObject o = null;
|
||||||
if(bhDists.size()<1){
|
if(bhDists.size()<1){
|
||||||
bhDists = BHBankUtils.getDistrictByBhbank(district.getName());
|
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>();
|
Map<String, String> bhMatchMap = new HashMap<String, String>();
|
||||||
if(bhDists.size()==1){
|
if(o != null){
|
||||||
JSONObject o = bhDists.get(0);
|
|
||||||
String bhDistName = (String)o.get("name");
|
String bhDistName = (String)o.get("name");
|
||||||
String regionCode = String.valueOf((Long)o.get("country"));
|
String regionCode = String.valueOf((Long)o.get("country"));
|
||||||
String bhRegion = BHBankUtils.regionCodeMap.get(regionCode);
|
String bhRegion = BHBankUtils.regionCodeMap.get(regionCode);
|
||||||
@@ -982,12 +996,13 @@ public class WeiXinEvaluationController {
|
|||||||
if(StringUtils.isNotBlank(model.getEvaluationId()) && StringUtils.isNotBlank(model.getEmail())){
|
if(StringUtils.isNotBlank(model.getEvaluationId()) && StringUtils.isNotBlank(model.getEmail())){
|
||||||
|
|
||||||
UserTrades userTrade = userTradesService.findUserTradesByEvaluationId(model.getEvaluationId());
|
UserTrades userTrade = userTradesService.findUserTradesByEvaluationId(model.getEvaluationId());
|
||||||
|
|
||||||
|
FjtEvaluation evaluation = fjtEvaluationService.findEvaluationById(Long.valueOf(model.getEvaluationId()));
|
||||||
if(userTrade != null){
|
if(userTrade != null){
|
||||||
userTrade.setSend(1);
|
userTrade.setSend(1);
|
||||||
userTrade.setSendEmail(model.getEmail());
|
userTrade.setSendEmail(model.getEmail());
|
||||||
userTradesService.update(userTrade);
|
userTradesService.update(userTrade);
|
||||||
}else{
|
}else{
|
||||||
FjtEvaluation evaluation = fjtEvaluationService.findEvaluationById(Long.valueOf(model.getEvaluationId()));
|
|
||||||
|
|
||||||
userTrade = new UserTrades();
|
userTrade = new UserTrades();
|
||||||
userTrade.setUserId(evaluation.getUserId());
|
userTrade.setUserId(evaluation.getUserId());
|
||||||
@@ -1019,9 +1034,31 @@ public class WeiXinEvaluationController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
sendToEmail(model.getFjtUrlKey(), model.getEvaluationId(), model.getEmail());
|
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;
|
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类型
|
//将InputStream类型转化为File类型
|
||||||
private static void inputStreamToFile(InputStream ins, File file) {
|
private static void inputStreamToFile(InputStream ins, File file) {
|
||||||
//将输出流转化为文件即可
|
//将输出流转化为文件即可
|
||||||
FileOutputStream os = null;
|
FileOutputStream os = null;
|
||||||
try {
|
try {
|
||||||
|
|||||||
Reference in New Issue
Block a user