From 87d2deb228cffda7dd04a98ac0b5b2f7514285c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B2=88=E5=81=A5?= Date: Sat, 8 May 2021 10:33:05 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E5=BB=BA=E8=A1=8C=E4=BC=B0=E5=80=BC?= =?UTF-8?q?=E6=96=B9=E6=B3=95=E6=8A=BD=E7=A6=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controllers/weixin/CcbRentController.java | 96 ++++++++++++++++++- .../src/main/webapp/ccbRent/index.ftl | 2 +- 2 files changed, 94 insertions(+), 4 deletions(-) diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/weixin/CcbRentController.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/weixin/CcbRentController.java index 3e97020e7..8b74e93ef 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/weixin/CcbRentController.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/weixin/CcbRentController.java @@ -10,9 +10,12 @@ import com.fangjia.dal.mongo.model.RentDealPrice; import com.fangjia.dal.seawater.model.Seawater; import com.fangjia.dal.seaweed.model.District; import com.fangjia.open.compatible.model.JsonModel; +import com.fangjia.open.controllers.PropertyController; import com.fangjia.open.dto.DistrictHouseDtao; import com.fangjia.open.interceptors.AuthenticationBean; import com.fangjia.open.model.BaseModel; +import com.fangjia.open.model.BasicModel; +import com.fangjia.open.model.RestfulModelAndView; import com.fangjia.open.model.weixin.EvaluationModel; import com.fangjia.open.model.weixin.PropertyEvaluationModel; import com.fangjia.open.util.LineChartsUtils; @@ -30,7 +33,6 @@ import org.apache.batik.transcoder.Transcoder; import org.apache.batik.transcoder.TranscoderException; import org.apache.batik.transcoder.TranscoderInput; import org.apache.batik.transcoder.TranscoderOutput; -import org.apache.batik.transcoder.image.JPEGTranscoder; import org.apache.batik.transcoder.image.PNGTranscoder; import org.apache.commons.lang.StringUtils; import org.apache.lucene.index.Term; @@ -46,7 +48,6 @@ import org.sothis.web.mvc.annotation.Param; import org.xhtmlrenderer.pdf.ITextFontResolver; import org.xhtmlrenderer.pdf.ITextRenderer; -import javax.servlet.ServletOutputStream; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.*; @@ -87,7 +88,96 @@ public class CcbRentController { return result; } - public Object downloadPageAction(PropertyEvaluationModel result, HttpServletRequest request, @Param(name = "city") String city, @Param(name = "district") String districtStr, + public Object evaluateRentAction(com.fangjia.open.model.PropertyEvaluationModel model, HttpServletRequest request)throws NumberFormatException, IllegalAccessException { + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); + if (StringUtils.isBlank(model.getCity()) || StringUtils.isBlank(model.getName()) + || StringUtils.isBlank(model.getDistrict()) || model.getSize() <= 0) { + mav.setModel(BasicModel.buildBadRequestModel("参数非法:城市,区域,小区名,面积(size)为必填项")); + return mav; + } + if (model.getCity().endsWith("市")) { + model.setCity(model.getCity().replaceAll("市$", "")); + } + if (StringUtils.isNotBlank(request.getParameter("calDate"))) { + Date calDate = null; + try { + calDate = org.apache.commons.lang.time.DateUtils.parseDate(request.getParameter("calDate"), new String[] { "yyyy-MM-dd" }); + } catch (ParseException e) { + + } + if (calDate == null) { + mav.setModel(BasicModel.buildBadRequestModel("calDate:数据类型不合法")); + return mav; + } else { + model.setCalDate(calDate); + } + } + /* 先到CPDB库中查找小区 */ + District district = districtService.findByNameAndAlias(model.getCity(), model.getDistrict(), model.getName(), + "district"); + if (district == null) { + mav.setModel(BasicModel.buildBadRequestModel("该小区不存在")); + return mav; + } + model.setName(district.getName()); + + + if (model.getMaxFloor() != null && (model.getMaxFloor() <= 0 || model.getMaxFloor() > 59)) { + mav.setModel(BasicModel.buildBadRequestModel("maxFloor取值非法,正确范围[1,60)")); + return mav; + } + + if (model.getFloor() != null && (model.getFloor() <= 0 || model.getFloor() > 59)) { + mav.setModel(BasicModel.buildBadRequestModel("floor取值非法,正确范围[1,60)")); + return mav; + } + if (model.getMaxFloor() != null && model.getFloor() != null && model.getFloor() > model.getMaxFloor()) { + mav.setModel(BasicModel.buildBadRequestModel("所在楼层不能大于总楼层")); + return mav; + } + + model.setRegion(district.getRegion()); + model.setDistrictName(district.getName()); + if (StringUtils.isBlank(model.getPropertyType())) { + if (district.getEstateType2() != null && district.getEstateType2().contains("别墅")) { + model.setPropertyType("1"); + } + } + + if (model.getCalDate() != null) { + if (new Date().before(model.getCalDate())) { + model.setCalDate(DateUtil.getFirstDayOfWeek(new Date())); + } else { + model.setCalDate(DateUtil.getFirstDayOfWeek(model.getCalDate())); + } + } else { + model.setCalDate(DateUtil.getFirstDayOfWeek(new Date())); + } + + Evaluation evaluation = buildEvaluation(model, request); + evaluation.setSource("api_property_evaluate_rent"); + evaluation = evaluationService.evaluateRent(district, evaluation, model.getCalDate()); + + + if (evaluation.getTotalPrice() != null && evaluation.getTotalPrice() != 0) { + Map districtPriceMap = new HashMap(); + districtPriceMap.put("city", district.getCity()); + districtPriceMap.put("district", district.getRegion()); + districtPriceMap.put("name", district.getName()); + districtPriceMap.put("address", district.getAddress()); + districtPriceMap.put("totalPrice", evaluation.getTotalPrice()); + districtPriceMap.put("cal_date", model.getCalDate()); + mav.setModel(BasicModel.buildOKModel().setResult(districtPriceMap)); + return mav; + } else { + + mav.setModel(BasicModel.buildOKModel().setMsg("暂时不支持该小区的租金估价").markNoData()); + return mav; + } + } + + public Object downloadPageAction(PropertyEvaluationModel result, HttpServletRequest request, @Param(name = "city") String city, @Param(name = "district") String districtStr, @Param(name = "name") String name, @Param(name = "address") String address, @Param(name = "size") Double size, @Param(name = "floor") Integer floor, @Param(name = "height") Integer height, @Param(name = "room") Integer room, @Param(name = "hall") Integer hall, @Param(name = "toilet") Integer toilet, @Param(name = "direction") String direction, @Param(name = "fitment") String fitment, @Param(name = "chartImgUrl") String chartImgUrl) { diff --git a/projects/fangjia-open/src/main/webapp/ccbRent/index.ftl b/projects/fangjia-open/src/main/webapp/ccbRent/index.ftl index 8633e3e89..60f3ac58f 100644 --- a/projects/fangjia-open/src/main/webapp/ccbRent/index.ftl +++ b/projects/fangjia-open/src/main/webapp/ccbRent/index.ftl @@ -260,7 +260,7 @@ $("#evaluateBtn").prop("disabled", true) $.ajax({ // 娉ㄦ剰闇�瑕佸姞.. - url: '../property/evaluateRent', + url: '../ccbRent/evaluateRent', data:$("#evaluateForm").serialize(), dataType:"json", type:"post", From 8cb7bd78121ab82e13bb8cb495b65e5fd73d7777 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B2=88=E5=81=A5?= Date: Sat, 8 May 2021 13:46:19 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E8=AF=84=E4=BC=B0=E6=96=B9=E6=B3=95http?= =?UTF-8?q?=E8=AF=B7=E6=B1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controllers/weixin/CcbRentController.java | 106 ++++-------------- 1 file changed, 19 insertions(+), 87 deletions(-) diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/weixin/CcbRentController.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/weixin/CcbRentController.java index 8b74e93ef..c1a70df97 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/weixin/CcbRentController.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/weixin/CcbRentController.java @@ -9,13 +9,11 @@ import com.fangjia.dal.mongo.model.Evaluation; import com.fangjia.dal.mongo.model.RentDealPrice; import com.fangjia.dal.seawater.model.Seawater; import com.fangjia.dal.seaweed.model.District; +import com.fangjia.open.APIConstant; import com.fangjia.open.compatible.model.JsonModel; -import com.fangjia.open.controllers.PropertyController; import com.fangjia.open.dto.DistrictHouseDtao; import com.fangjia.open.interceptors.AuthenticationBean; import com.fangjia.open.model.BaseModel; -import com.fangjia.open.model.BasicModel; -import com.fangjia.open.model.RestfulModelAndView; import com.fangjia.open.model.weixin.EvaluationModel; import com.fangjia.open.model.weixin.PropertyEvaluationModel; import com.fangjia.open.util.LineChartsUtils; @@ -51,6 +49,7 @@ import org.xhtmlrenderer.pdf.ITextRenderer; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.*; +import java.lang.reflect.InvocationTargetException; import java.text.ParseException; import java.util.*; @@ -89,92 +88,25 @@ public class CcbRentController { } public Object evaluateRentAction(com.fangjia.open.model.PropertyEvaluationModel model, HttpServletRequest request)throws NumberFormatException, IllegalAccessException { - RestfulModelAndView mav = new RestfulModelAndView(); - mav.setViewType("rest"); - if (StringUtils.isBlank(model.getCity()) || StringUtils.isBlank(model.getName()) - || StringUtils.isBlank(model.getDistrict()) || model.getSize() <= 0) { - mav.setModel(BasicModel.buildBadRequestModel("参数非法:城市,区域,小区名,面积(size)为必填项")); - return mav; - } - if (model.getCity().endsWith("市")) { - model.setCity(model.getCity().replaceAll("市$", "")); - } - if (StringUtils.isNotBlank(request.getParameter("calDate"))) { - Date calDate = null; - try { - calDate = org.apache.commons.lang.time.DateUtils.parseDate(request.getParameter("calDate"), new String[] { "yyyy-MM-dd" }); - } catch (ParseException e) { + String result = null; + HttpRequest httpRequest = new HttpRequest(); + try { + Map headers = new HashMap(); - } - if (calDate == null) { - mav.setModel(BasicModel.buildBadRequestModel("calDate:数据类型不合法")); - return mav; - } else { - model.setCalDate(calDate); - } - } - /* 先到CPDB库中查找小区 */ - District district = districtService.findByNameAndAlias(model.getCity(), model.getDistrict(), model.getName(), - "district"); - if (district == null) { - mav.setModel(BasicModel.buildBadRequestModel("该小区不存在")); - return mav; - } - model.setName(district.getName()); - - - if (model.getMaxFloor() != null && (model.getMaxFloor() <= 0 || model.getMaxFloor() > 59)) { - mav.setModel(BasicModel.buildBadRequestModel("maxFloor取值非法,正确范围[1,60)")); - return mav; - } - - if (model.getFloor() != null && (model.getFloor() <= 0 || model.getFloor() > 59)) { - mav.setModel(BasicModel.buildBadRequestModel("floor取值非法,正确范围[1,60)")); - return mav; - } - if (model.getMaxFloor() != null && model.getFloor() != null && model.getFloor() > model.getMaxFloor()) { - mav.setModel(BasicModel.buildBadRequestModel("所在楼层不能大于总楼层")); - return mav; - } - - model.setRegion(district.getRegion()); - model.setDistrictName(district.getName()); - if (StringUtils.isBlank(model.getPropertyType())) { - if (district.getEstateType2() != null && district.getEstateType2().contains("别墅")) { - model.setPropertyType("1"); - } - } - - if (model.getCalDate() != null) { - if (new Date().before(model.getCalDate())) { - model.setCalDate(DateUtil.getFirstDayOfWeek(new Date())); - } else { - model.setCalDate(DateUtil.getFirstDayOfWeek(model.getCalDate())); - } - } else { - model.setCalDate(DateUtil.getFirstDayOfWeek(new Date())); - } - - Evaluation evaluation = buildEvaluation(model, request); - evaluation.setSource("api_property_evaluate_rent"); - evaluation = evaluationService.evaluateRent(district, evaluation, model.getCalDate()); - - - if (evaluation.getTotalPrice() != null && evaluation.getTotalPrice() != 0) { - Map districtPriceMap = new HashMap(); - districtPriceMap.put("city", district.getCity()); - districtPriceMap.put("district", district.getRegion()); - districtPriceMap.put("name", district.getName()); - districtPriceMap.put("address", district.getAddress()); - districtPriceMap.put("totalPrice", evaluation.getTotalPrice()); - districtPriceMap.put("cal_date", model.getCalDate()); - mav.setModel(BasicModel.buildOKModel().setResult(districtPriceMap)); - return mav; - } else { - - mav.setModel(BasicModel.buildOKModel().setMsg("暂时不支持该小区的租金估价").markNoData()); - return mav; + final String path = "http://" + request.getServerName() + ":" + request.getServerPort() + request.getContextPath(); + String url = path + "/property/evaluateRent?token=" + APIConstant.SUPER_USER_TOKEN + "&__refresh_cache=1"; + Map params = new HashMap(); + params = org.apache.commons.beanutils.BeanUtils.describe(model); + //params.put("request", JsonUtils.httpParameterToJSONObject(request)); + result = httpRequest.post(url, params, headers,"UTF-8"); + } catch (HttpRequestException e) { + e.printStackTrace(); + } catch (NoSuchMethodException e) { + e.printStackTrace(); + } catch (InvocationTargetException e) { + e.printStackTrace(); } + return result; } public Object downloadPageAction(PropertyEvaluationModel result, HttpServletRequest request, @Param(name = "city") String city, @Param(name = "district") String districtStr,