From 4ea19eb1bbbd5e50749ba77bbe22102a02503d24 Mon Sep 17 00:00:00 2001 From: gaojuan Date: Mon, 29 Nov 2021 17:08:56 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=9A=E4=B8=AA=E6=9F=A5=E8=AF=A2=E7=BB=93?= =?UTF-8?q?=E6=9E=9C=E5=8F=8A=E8=AF=A2=E4=BB=B7=E5=8D=95=E4=BC=A0=E7=BB=99?= =?UTF-8?q?=E6=B8=A4=E6=B5=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../weixin/WeiXinEvaluationController.java | 92 +++++++++++++++++-- 1 file changed, 83 insertions(+), 9 deletions(-) diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/weixin/WeiXinEvaluationController.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/weixin/WeiXinEvaluationController.java index 5b70348d4..144d17ea1 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/weixin/WeiXinEvaluationController.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/weixin/WeiXinEvaluationController.java @@ -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 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 bhMatchMap = new HashMap(); - 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 uploadfiles = new ArrayList(); + 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 {