Commit 44ea6641d4d03318ef974dd97efa89e6df702348
1 parent
80db26ae
提交
Showing
3 changed files
with
143 additions
and
14 deletions
src/main/java/com/rnt/service/IRainQueryService.java
| @@ -5,6 +5,7 @@ import java.util.Map; | @@ -5,6 +5,7 @@ import java.util.Map; | ||
| 5 | 5 | ||
| 6 | import org.beetl.sql.core.kit.StringKit; | 6 | import org.beetl.sql.core.kit.StringKit; |
| 7 | 7 | ||
| 8 | +import com.alibaba.fastjson.JSON; | ||
| 8 | import com.alibaba.fastjson.JSONObject; | 9 | import com.alibaba.fastjson.JSONObject; |
| 9 | import com.jfinal.kit.Prop; | 10 | import com.jfinal.kit.Prop; |
| 10 | import com.jfinal.kit.PropKit; | 11 | import com.jfinal.kit.PropKit; |
| @@ -12,6 +13,7 @@ import com.jfinal.log.Log; | @@ -12,6 +13,7 @@ import com.jfinal.log.Log; | ||
| 12 | import com.rnt.model.park.IrainPknoRelation; | 13 | import com.rnt.model.park.IrainPknoRelation; |
| 13 | import com.rnt.utils.HttpClientTutorial; | 14 | import com.rnt.utils.HttpClientTutorial; |
| 14 | import com.rnt.utils.MD5Utils; | 15 | import com.rnt.utils.MD5Utils; |
| 16 | +import com.zteits.clouds.api.dto.park.param.RoadsideRequest; | ||
| 15 | 17 | ||
| 16 | /** | 18 | /** |
| 17 | * 艾润费用查询service.<br/> | 19 | * 艾润费用查询service.<br/> |
| @@ -37,14 +39,16 @@ public class IRainQueryService { | @@ -37,14 +39,16 @@ public class IRainQueryService { | ||
| 37 | * @param parkCode | 39 | * @param parkCode |
| 38 | * @return | 40 | * @return |
| 39 | */ | 41 | */ |
| 40 | - public String billQuery(String carNum,String parkCode) { | ||
| 41 | - logger.info("开始调用查询费用接口,入参={carNum,parkCode}="+"{"+carNum+","+parkCode+"}"); | 42 | + public Map<String, String> billQuery(String carNum,String parkCode) { |
| 43 | + logger.info("---begin调用艾润查询费用接口,入参={carNum,parkCode}="+"{"+carNum+","+parkCode+"}"); | ||
| 42 | //1.查询停车场关系映射表-获取艾润停车场查询费用编码 ztetis-park.irain_pkno_relation | 44 | //1.查询停车场关系映射表-获取艾润停车场查询费用编码 ztetis-park.irain_pkno_relation |
| 43 | StringBuffer sql = new StringBuffer("select a.irain_pkno1"); | 45 | StringBuffer sql = new StringBuffer("select a.irain_pkno1"); |
| 44 | sql.append(" from irain_pkno_relation a"); | 46 | sql.append(" from irain_pkno_relation a"); |
| 45 | sql.append(" where a.park_lotpkno = ?"); | 47 | sql.append(" where a.park_lotpkno = ?"); |
| 46 | String rs = ""; | 48 | String rs = ""; |
| 49 | + Map<String, String> map = new HashMap<String, String>(); | ||
| 47 | IrainPknoRelation irainPknoRelation = new IrainPknoRelation().findFirst(sql.toString(), parkCode); | 50 | IrainPknoRelation irainPknoRelation = new IrainPknoRelation().findFirst(sql.toString(), parkCode); |
| 51 | + logger.info("获取查询费用编码数据结果="+JSONObject.toJSON(irainPknoRelation)); | ||
| 48 | if(irainPknoRelation != null && StringKit.isNotBlank(irainPknoRelation.getIrainPkno1())){ | 52 | if(irainPknoRelation != null && StringKit.isNotBlank(irainPknoRelation.getIrainPkno1())){ |
| 49 | /**** 以下为模拟入参 实际入参 由app提供-------------------------------------*/ | 53 | /**** 以下为模拟入参 实际入参 由app提供-------------------------------------*/ |
| 50 | Prop prop = PropKit.use("a_little_config.txt"); | 54 | Prop prop = PropKit.use("a_little_config.txt"); |
| @@ -61,6 +65,12 @@ public class IRainQueryService { | @@ -61,6 +65,12 @@ public class IRainQueryService { | ||
| 61 | logger.info("irain 查询停车费用入参:" + JSONObject.toJSONString(params)); | 65 | logger.info("irain 查询停车费用入参:" + JSONObject.toJSONString(params)); |
| 62 | rs = HttpClientTutorial.httpPostRequest(prop.get("irain.url")+"/bill/Query", params); | 66 | rs = HttpClientTutorial.httpPostRequest(prop.get("irain.url")+"/bill/Query", params); |
| 63 | logger.info("irain 查询停车费用返回:" + JSONObject.toJSONString(rs)); | 67 | logger.info("irain 查询停车费用返回:" + JSONObject.toJSONString(rs)); |
| 68 | + if (StringKit.isNotBlank(rs) && !"NO_PARK_RECORD".equals(JSONObject.parseObject(rs).get("code"))) { | ||
| 69 | + map = this.jsonToMapForIrunResult(rs); | ||
| 70 | + }else{ | ||
| 71 | + logger.info("调用艾润费用查询接口:无停车记录"); | ||
| 72 | + } | ||
| 73 | + | ||
| 64 | } catch (Exception e) { | 74 | } catch (Exception e) { |
| 65 | logger.info("irain 查询停车费用出错:" + e); | 75 | logger.info("irain 查询停车费用出错:" + e); |
| 66 | } | 76 | } |
| @@ -68,30 +78,125 @@ public class IRainQueryService { | @@ -68,30 +78,125 @@ public class IRainQueryService { | ||
| 68 | logger.info("没有查询到艾润查询费用编码"); | 78 | logger.info("没有查询到艾润查询费用编码"); |
| 69 | } | 79 | } |
| 70 | 80 | ||
| 71 | - logger.info("结束调用查询费用接口,结果="+JSONObject.toJSONString(rs)); | 81 | + logger.info("---end调用艾润查询费用接口,结果="+JSONObject.toJSON(map)); |
| 72 | 82 | ||
| 73 | 83 | ||
| 74 | - return JSONObject.toJSON(rs)+""; | 84 | + return map; |
| 75 | } | 85 | } |
| 76 | 86 | ||
| 77 | - public static void main(String[] args) { | 87 | + /** |
| 88 | + * 青岛路侧费用查询接口.<br/> | ||
| 89 | + * @param recordId | ||
| 90 | + * @return | ||
| 91 | + */ | ||
| 92 | + public static Map<String, String> queryBillRoadside(String recordId){ | ||
| 93 | + logger.info("---begin调用青岛路侧费用查询接口,入参={recordId}="+"{"+recordId+"}"); | ||
| 78 | Prop prop = PropKit.use("a_little_config.txt"); | 94 | Prop prop = PropKit.use("a_little_config.txt"); |
| 79 | - String rs = ""; | 95 | + Map<String, Object> params = new HashMap<>(); |
| 96 | + Long time = System.currentTimeMillis(); | ||
| 97 | + params.put("orderCode", recordId); | ||
| 98 | + params.put("timestamp",time); | ||
| 99 | + Map<String, String> rsMap = new HashMap<String, String>(); | ||
| 100 | + try{ | ||
| 101 | + String qingdaors = HttpClientTutorial.httpPostRequest(prop.get("qindao.url")+"", JSONObject.toJSONString(params)); | ||
| 102 | + logger.info("青岛路侧查询停车费用返回:" + JSONObject.toJSONString(qingdaors)); | ||
| 103 | + RoadsideRequest roadsideRequest = JSONObject.parseObject(qingdaors,RoadsideRequest.class); | ||
| 104 | + logger.info("青岛路侧返回JSON转换对象结果"+JSONObject.toJSON(roadsideRequest)); | ||
| 105 | + if(roadsideRequest != null){ | ||
| 106 | + rsMap.put("record_id", roadsideRequest.getOrderCode()); | ||
| 107 | + // 出场时间 | ||
| 108 | + rsMap.put("park_out_time", roadsideRequest.getOuttime()); | ||
| 109 | + //入场时间 | ||
| 110 | + rsMap.put("park_in_time", roadsideRequest.getIntime()); | ||
| 111 | + //总费用 | ||
| 112 | + rsMap.put("order_total_fee", roadsideRequest.getOrderPay() != null ? roadsideRequest.getOrderPay().toString() :"1"); | ||
| 113 | + //已付费用 | ||
| 114 | + rsMap.put("order_payed_fee", "0"); | ||
| 115 | + //未支付费用(本次应付金额) | ||
| 116 | + rsMap.put("order_not_pay_fee", roadsideRequest.getOrderPay() != null ? roadsideRequest.getOrderPay().toString() :"1"); | ||
| 117 | + //停车时长 单位:秒 | ||
| 118 | + rsMap.put("parking_duration",roadsideRequest.getStaytime() != null ? String.valueOf(roadsideRequest.getStaytime()) :"1"); | ||
| 119 | + //停车场名车 | ||
| 120 | + rsMap.put("park_name", roadsideRequest.getParkName()); | ||
| 121 | + } | ||
| 122 | + | ||
| 123 | + }catch (Exception e) { | ||
| 124 | + e.printStackTrace(); | ||
| 125 | + } | ||
| 126 | + logger.info("---end调用青岛路侧费用查询接口,结果="+JSONObject.toJSON(rsMap)); | ||
| 127 | + return rsMap; | ||
| 128 | + } | ||
| 129 | + | ||
| 130 | + | ||
| 131 | + /** | ||
| 132 | + * 获取查询费用返回结果.<br/> | ||
| 133 | + * | ||
| 134 | + * @param json | ||
| 135 | + * @return | ||
| 136 | + */ | ||
| 137 | + private static Map<String, String> jsonToMapForIrunResult(String json) { | ||
| 138 | + | ||
| 139 | + JSONObject jsobj = JSONObject.parseObject(json); | ||
| 140 | + Map<String, String> map = new HashMap<String, String>(); | ||
| 141 | + if (jsobj != null) { | ||
| 142 | + if (!jsobj.get("status").toString().equals("0")) { | ||
| 143 | + JSONObject data = (JSONObject)jsobj.get("data"); | ||
| 144 | + // 出场时间对象 | ||
| 145 | + JSONObject parkOutObject = (JSONObject)data.get("out"); | ||
| 146 | + //停车记录id | ||
| 147 | + map.put("record_id", data.getString("id")); | ||
| 148 | + // 出场时间 | ||
| 149 | + map.put("park_out_time", parkOutObject.getString("time")); | ||
| 150 | + if (data.get("park") != null) { | ||
| 151 | + map.put("park_name", JSONObject.parseObject(data.get("park").toString()).get("name") + ""); | ||
| 152 | + map.put("park_address", JSONObject.parseObject(data.get("park").toString()).get("address") + ""); | ||
| 153 | + } | ||
| 154 | + | ||
| 155 | + //入场时间 | ||
| 156 | + if (data.get("in") != null) { | ||
| 157 | + map.put("park_in_time", JSONObject.parseObject(data.get("in").toString()).getString("time")); | ||
| 158 | + } | ||
| 159 | + //总费用 | ||
| 160 | + map.put("order_total_fee", JSONObject.parseObject(data.get("charge").toString()).getString("due")); | ||
| 161 | + //已付费用 | ||
| 162 | + map.put("order_payed_fee", JSONObject.parseObject(data.get("charge").toString()).getString("paid")); | ||
| 163 | + //未支付费用(本次应付金额) | ||
| 164 | + map.put("order_not_pay_fee", JSONObject.parseObject(data.get("charge").toString()).getString("unpaid")); | ||
| 165 | + //停车时长 单位:秒 | ||
| 166 | + map.put("parking_duration", | ||
| 167 | + JSONObject.parseObject(data.get("charge").toString()).getString("duration")); | ||
| 168 | + } | ||
| 169 | + } | ||
| 170 | + return map; | ||
| 171 | + } | ||
| 172 | + | ||
| 173 | + public static void main(String[] args) { | ||
| 174 | + /**Map<String, String> map = new HashMap<String, String>(); | ||
| 175 | + Prop prop = PropKit.use("a_little_config.txt"); | ||
| 80 | Long time = System.currentTimeMillis(); | 176 | Long time = System.currentTimeMillis(); |
| 81 | String md5 = MD5Utils.enMD5(prop.get("irain.appid")+prop.get("irain.appsecret")+time); | 177 | String md5 = MD5Utils.enMD5(prop.get("irain.appid")+prop.get("irain.appsecret")+time); |
| 82 | Map<String, Object> params = new HashMap<>(); | 178 | Map<String, Object> params = new HashMap<>(); |
| 83 | params.put("appid", prop.get("irain.appid")); | 179 | params.put("appid", prop.get("irain.appid")); |
| 84 | params.put("sign", md5); | 180 | params.put("sign", md5); |
| 85 | params.put("timestamp", time); | 181 | params.put("timestamp", time); |
| 86 | - params.put("vpl_number", "苏B1B566"); | 182 | + params.put("vpl_number", "苏BV291U"); |
| 87 | params.put("park_code", "734861a1e8656ffa51bdd90829941ca9"); | 183 | params.put("park_code", "734861a1e8656ffa51bdd90829941ca9"); |
| 88 | - | 184 | + String rs = ""; |
| 89 | try { | 185 | try { |
| 90 | logger.info("irain 查询停车费用入参:" + JSONObject.toJSONString(params)); | 186 | logger.info("irain 查询停车费用入参:" + JSONObject.toJSONString(params)); |
| 91 | rs = HttpClientTutorial.httpPostRequest(prop.get("irain.url")+"/bill/Query", params); | 187 | rs = HttpClientTutorial.httpPostRequest(prop.get("irain.url")+"/bill/Query", params); |
| 92 | logger.info("irain 查询停车费用返回:" + JSONObject.toJSONString(rs)); | 188 | logger.info("irain 查询停车费用返回:" + JSONObject.toJSONString(rs)); |
| 189 | + if (StringKit.isNotBlank(rs) && !"NO_PARK_RECORD".equals(JSONObject.parseObject(rs).get("code"))) { | ||
| 190 | + System.out.println(rs); | ||
| 191 | + map = jsonToMapForIrunResult(rs); | ||
| 192 | + System.out.println("------"+JSONObject.toJSON(map)); | ||
| 193 | + }else{ | ||
| 194 | + logger.info("调用艾润费用查询接口:无停车记录"); | ||
| 195 | + } | ||
| 196 | + | ||
| 93 | } catch (Exception e) { | 197 | } catch (Exception e) { |
| 94 | logger.info("irain 查询停车费用出错:" + e); | 198 | logger.info("irain 查询停车费用出错:" + e); |
| 95 | - } | 199 | + }*/ |
| 200 | + queryBillRoadside("101332467802357239808"); | ||
| 96 | } | 201 | } |
| 97 | } | 202 | } |
src/main/java/com/rnt/utils/HttpClientTutorial.java
| @@ -95,6 +95,18 @@ public class HttpClientTutorial { | @@ -95,6 +95,18 @@ public class HttpClientTutorial { | ||
| 95 | return getResult(httpPost); | 95 | return getResult(httpPost); |
| 96 | } | 96 | } |
| 97 | 97 | ||
| 98 | + public static String httpPostRequest(String url, String jsonParam) throws UnsupportedEncodingException { | ||
| 99 | + HttpPost httpPost = new HttpPost(url); | ||
| 100 | + if (null != jsonParam) { | ||
| 101 | + //解决中文乱码问题 | ||
| 102 | + StringEntity entity = new StringEntity(jsonParam, "utf-8"); | ||
| 103 | + entity.setContentEncoding("UTF-8"); | ||
| 104 | + entity.setContentType("application/json"); | ||
| 105 | + httpPost.setEntity(entity); | ||
| 106 | + } | ||
| 107 | + return getResult(httpPost); | ||
| 108 | + } | ||
| 109 | + | ||
| 98 | public static String httpPostRequest(String url, JSONObject jsonParam) throws UnsupportedEncodingException { | 110 | public static String httpPostRequest(String url, JSONObject jsonParam) throws UnsupportedEncodingException { |
| 99 | HttpPost httpPost = new HttpPost(url); | 111 | HttpPost httpPost = new HttpPost(url); |
| 100 | if (null != jsonParam) { | 112 | if (null != jsonParam) { |
src/main/resources/a_little_config.txt
| @@ -3,11 +3,14 @@ devMode = true | @@ -3,11 +3,14 @@ devMode = true | ||
| 3 | 3 | ||
| 4 | ######## park库 | 4 | ######## park库 |
| 5 | 5 | ||
| 6 | -park.druid.url=jdbc:mysql://10.117.185.28:3306/zt_park?useUnicode=true&characterEncoding=UTF-8&allowMultiQueries=true | 6 | +#park.druid.url=jdbc:mysql://10.117.185.28:3306/zt_park?useUnicode=true&characterEncoding=UTF-8&allowMultiQueries=true |
| 7 | +#park.druid.username=park | ||
| 8 | +#park.druid.password=MySQL5.7;123 | ||
| 9 | + | ||
| 10 | +park.druid.url=jdbc:mysql://120.26.116.79:13306/zt_park?useUnicode=true&characterEncoding=UTF-8&allowMultiQueries=true | ||
| 7 | park.druid.username=park | 11 | park.druid.username=park |
| 8 | park.druid.password=MySQL5.7;123 | 12 | park.druid.password=MySQL5.7;123 |
| 9 | 13 | ||
| 10 | - | ||
| 11 | park.druid.initialSize=1 | 14 | park.druid.initialSize=1 |
| 12 | park.druid.minIdle=1 | 15 | park.druid.minIdle=1 |
| 13 | park.druid.maxActive=20 | 16 | park.druid.maxActive=20 |
| @@ -21,7 +24,11 @@ park.druid.testOnReturn=false | @@ -21,7 +24,11 @@ park.druid.testOnReturn=false | ||
| 21 | park.druid.testOnWhileIdle=true | 24 | park.druid.testOnWhileIdle=true |
| 22 | 25 | ||
| 23 | ####### zf库 | 26 | ####### zf库 |
| 24 | -zf.druid.url=jdbc:mysql://10.117.185.28:3306/zt_order?useUnicode=true&characterEncoding=UTF-8&allowMultiQueries=true | 27 | +#zf.druid.url=jdbc:mysql://10.117.185.28:3306/zt_order?useUnicode=true&characterEncoding=UTF-8&allowMultiQueries=true |
| 28 | +#zf.druid.username=order | ||
| 29 | +#zf.druid.password=MySQL5.7;123 | ||
| 30 | + | ||
| 31 | +zf.druid.url=jdbc:mysql://120.26.116.79:13306/zt_order?useUnicode=true&characterEncoding=UTF-8&allowMultiQueries=true | ||
| 25 | zf.druid.username=order | 32 | zf.druid.username=order |
| 26 | zf.druid.password=MySQL5.7;123 | 33 | zf.druid.password=MySQL5.7;123 |
| 27 | 34 | ||
| @@ -57,9 +64,11 @@ appSecret=fc468de39e6fcf181982483331d08fbd | @@ -57,9 +64,11 @@ appSecret=fc468de39e6fcf181982483331d08fbd | ||
| 57 | 64 | ||
| 58 | 65 | ||
| 59 | 66 | ||
| 60 | -app.host=http://wxgzh.rnting.com/rnt-wx | ||
| 61 | -app.staticHost=http://wxgzh.rnting.com/rnt-wx/static | 67 | +#app.host=http://wxgzh.rnting.com/rnt-wx |
| 68 | +#app.staticHost=http://wxgzh.rnting.com/rnt-wx/static | ||
| 62 | 69 | ||
| 70 | +app.host=http://localhost:8080 | ||
| 71 | +app.staticHost=http://localhost:8080/static | ||
| 63 | 72 | ||
| 64 | #weixin pay | 73 | #weixin pay |
| 65 | #是否支持信用卡支付 | 74 | #是否支持信用卡支付 |
| @@ -79,6 +88,9 @@ irain.appsecret=rrr6uz3aqvutpsq2lsna0k18cea4mabw | @@ -79,6 +88,9 @@ irain.appsecret=rrr6uz3aqvutpsq2lsna0k18cea4mabw | ||
| 79 | irain.aes=avakrky0gk1m7n00 | 88 | irain.aes=avakrky0gk1m7n00 |
| 80 | irain.park_code=734861a1e8656ffa51bdd90829941ca9 | 89 | irain.park_code=734861a1e8656ffa51bdd90829941ca9 |
| 81 | 90 | ||
| 91 | +#青岛路侧费用查询url | ||
| 92 | +qindao.url=http://zteits.gnway.cc:8088/RNT-ATMS-ADAPTER/pay/doPayAdvice | ||
| 93 | + | ||
| 82 | 94 | ||
| 83 | #dubbo | 95 | #dubbo |
| 84 | dubbo.application.name=rnt-wx | 96 | dubbo.application.name=rnt-wx |