From 725eeb6f5f13e3f87f26d34632f916131379d5bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E7=A3=8A?= <寮犵@LAPTOP-O3DO03BA> Date: Fri, 15 Jun 2018 20:40:01 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BA=8C=E6=89=8B=E8=BD=A6=E8=BD=A6=E5=9E=8B?= =?UTF-8?q?=E5=BA=93=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- WebContent/WEB-INF/etc/a3web.xml | 4 +- .../awe/config/InitSecondHandCarConfig.java | 31 ++ .../awe/config/SecondHandCarProperties.java | 42 +++ .../QueryVehicleModeListAction.java | 308 +++++++++--------- .../lease/util/VehicleAppraisementUtil.java | 6 +- 5 files changed, 243 insertions(+), 148 deletions(-) create mode 100644 src/com/amarsoft/app/awe/config/InitSecondHandCarConfig.java create mode 100644 src/com/amarsoft/app/awe/config/SecondHandCarProperties.java diff --git a/WebContent/WEB-INF/etc/a3web.xml b/WebContent/WEB-INF/etc/a3web.xml index c44c01b79..9313faece 100644 --- a/WebContent/WEB-INF/etc/a3web.xml +++ b/WebContent/WEB-INF/etc/a3web.xml @@ -29,6 +29,8 @@ d:/tmp/als/Upload + + d:/tmp/InterFace fileTemplate @@ -89,7 +91,7 @@ - ee450692cbd24e8bacb27b6f46b4d752 + a6b83424b55410c36415178002f8415e http://api.che300.com/service/getCarBrandList http://api.che300.com/service/getCarSeriesList diff --git a/src/com/amarsoft/app/awe/config/InitSecondHandCarConfig.java b/src/com/amarsoft/app/awe/config/InitSecondHandCarConfig.java new file mode 100644 index 000000000..6950e4d3d --- /dev/null +++ b/src/com/amarsoft/app/awe/config/InitSecondHandCarConfig.java @@ -0,0 +1,31 @@ +package com.amarsoft.app.awe.config; + +import javax.servlet.http.HttpServlet; +import org.springframework.web.context.ContextLoader; +import org.springframework.web.context.WebApplicationContext; + +/** + * @author 张磊 + * @date 2018年6月14日 + */ +public class InitSecondHandCarConfig extends HttpServlet { + + private static final long serialVersionUID = 1L; + + public static final String PREFIX; + + public static final String TOKEN; + + public static final String OPER; + + public static final String VERSION; + + static { + WebApplicationContext wac = ContextLoader.getCurrentWebApplicationContext(); + SecondHandCarProperties secondHandCarProperties = wac.getBean("secondHandCarConfig",SecondHandCarProperties.class); + TOKEN = secondHandCarProperties.getToken(); + OPER = secondHandCarProperties.getOper(); + PREFIX = secondHandCarProperties.getPrefix(); + VERSION = secondHandCarProperties.getVersion(); + } +} diff --git a/src/com/amarsoft/app/awe/config/SecondHandCarProperties.java b/src/com/amarsoft/app/awe/config/SecondHandCarProperties.java new file mode 100644 index 000000000..3b42300a6 --- /dev/null +++ b/src/com/amarsoft/app/awe/config/SecondHandCarProperties.java @@ -0,0 +1,42 @@ +package com.amarsoft.app.awe.config; +/** + * 二手车配置文件类 + * @author 张磊 + * @date 2018年6月14日 + */ +public class SecondHandCarProperties { + + private String prefix; + + private String token; + + private String oper; + + private String version; + + public String getPrefix() { + return prefix; + } + public void setPrefix(String prefix) { + this.prefix = prefix; + } + public String getToken() { + return token; + } + public void setToken(String token) { + this.token = token; + } + public String getOper() { + return oper; + } + public void setOper(String oper) { + this.oper = oper; + } + public String getVersion() { + return version; + } + public void setVersion(String version) { + this.version = version; + } + +} diff --git a/src_tenwa/com/tenwa/lease/app/quartzmession/QueryVehicleModeListAction.java b/src_tenwa/com/tenwa/lease/app/quartzmession/QueryVehicleModeListAction.java index 311543e47..18ab75f86 100644 --- a/src_tenwa/com/tenwa/lease/app/quartzmession/QueryVehicleModeListAction.java +++ b/src_tenwa/com/tenwa/lease/app/quartzmession/QueryVehicleModeListAction.java @@ -3,19 +3,25 @@ package com.tenwa.lease.app.quartzmession; import java.util.HashMap; import java.util.List; import java.util.Map; + import jbo.com.tenwa.lease.carbrand.LB_CARDATA_BRAND; import jbo.com.tenwa.lease.carbrand.LB_CARDATA_MODEL; import jbo.com.tenwa.lease.carbrand.LB_CARDATA_SERIES; +import jbo.com.tenwa.lease.carbrand.LB_CARDATA_VERSION; + import org.quartz.Job; import org.quartz.JobExecutionContext; import org.quartz.JobExecutionException; + import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; +import com.amarsoft.app.awe.config.InitSecondHandCarConfig; import com.amarsoft.are.jbo.BizObject; import com.amarsoft.are.jbo.BizObjectManager; import com.amarsoft.are.jbo.JBOException; import com.amarsoft.are.jbo.JBOFactory; import com.amarsoft.are.jbo.JBOTransaction; +import com.tenwa.lease.util.VehicleAppraisementUtil; public class QueryVehicleModeListAction implements Job{ @@ -27,12 +33,25 @@ public class QueryVehicleModeListAction implements Job{ BizObjectManager bm1 = JBOFactory.getBizObjectManager(LB_CARDATA_BRAND.CLASS_NAME, tx); BizObjectManager bm2 = JBOFactory.getBizObjectManager(LB_CARDATA_SERIES.CLASS_NAME, tx); BizObjectManager bm3 = JBOFactory.getBizObjectManager(LB_CARDATA_MODEL.CLASS_NAME, tx); - //url未知 - /*String url = "http://api.che300.com/service/getCarModelList?token=8192047c7ab1a654eda8fbce470062f0&seriesId="; - String responseResult = VehicleAppraisementUtil.getResponseResult(url);*/ - String filePath = "D://che300yasuo.txt"; - //String readFile = ReadJSON.ReadFile(filePath); - JSONObject object = JSONObject.parseObject("此处待接口通了之后再导入接口返回的JSON字符串"); + BizObjectManager bm4 = JBOFactory.getBizObjectManager(LB_CARDATA_VERSION.CLASS_NAME, tx); + //接口url中的fromVersion参数 + String fromVersion = null; + //开关,作用是若判断为第一次调用接口,保存版本信息到Version表,而不是第一次调用时则将这个值变为true,则更新版本表 + boolean versionflag = false; + //查询二手车版本表,若为空则说明是第一次调用二手车车型库接口 + BizObject versionResult = bm4.createQuery("select O.currentversion,O.initialversion from O").getSingleResult(false); + if(versionResult == null){ + fromVersion = InitSecondHandCarConfig.VERSION; + }else{ + fromVersion = versionResult.getAttribute("currentversion").toString(); + versionflag = true; + } + String url = "http://"+InitSecondHandCarConfig.PREFIX+".che300.com/service/common/eval?fromVersion=" + +fromVersion+"&token="+InitSecondHandCarConfig.TOKEN+""; + String responseResult = VehicleAppraisementUtil.getResponseResult(url); + + //使用fastjson解析接口返回的json数据 + JSONObject object = JSONObject.parseObject(responseResult); JSONObject dataObject = (JSONObject) object.get("data"); @SuppressWarnings("rawtypes") List brandList = JSON.parseArray(JSON.toJSONString(dataObject.get("brand")), HashMap.class); @@ -47,146 +66,145 @@ public class QueryVehicleModeListAction implements Job{ List versionList = JSON.parseArray(JSON.toJSONString(dataObject.get("version")), HashMap.class); @SuppressWarnings("unchecked") Map map = versionList.get(0); - for(int i=0;i