Blame view

src/main/java/com/rnt/service/IRainQueryService.java 2.71 KB
e80df919   atao   init
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
  package com.rnt.service;
  
  import java.util.HashMap;
  import java.util.Map;
  
  import org.beetl.sql.core.kit.StringKit;
  
  import com.alibaba.fastjson.JSONObject;
  import com.jfinal.kit.Prop;
  import com.jfinal.kit.PropKit;
  import com.jfinal.log.Log;
  import com.rnt.model.park.IrainPknoRelation;
  import com.rnt.utils.HttpClientTutorial;
  import com.rnt.utils.MD5Utils;
  
  /**
   * 艾润费用查询service.<br/>
   * 
   * Copyright: Copyright (c) 2017  zteits
   * 
   * @ClassName: IRainQueryService.java
   * @Description: 
   * @version: v1.0.0
   * @author: wangfs
   * @date: 2017613   上午9:25:31 
   * Modification History:
   * Date             Author          Version            Description
   *---------------------------------------------------------*
   * 2017613      wangfs           v1.0.0               创建
   */
  public class IRainQueryService {
  	 private static final Log logger = Log.getLog(IRainQueryService.class);
  
  	 /**
  	  * 调用艾润查询费用接口.<br/>
  	  * @param carNum
  	  * @param parkCode
  	  * @return
  	  */
  	public String billQuery(String carNum,String parkCode) {
  		logger.info("开始调用查询费用接口,入参={carNum,parkCode}="+"{"+carNum+","+parkCode+"}");
  		//1.查询停车场关系映射表-获取艾润停车场查询费用编码 ztetis-park.irain_pkno_relation
  		StringBuffer sql = new StringBuffer("select a.irain_pkno1");
  		sql.append(" from irain_pkno_relation a");
  		sql.append(" where a.park_lotpkno = ?");
  		String rs  = "";
  		IrainPknoRelation irainPknoRelation = new IrainPknoRelation().findFirst(sql.toString(), parkCode);
  		if(irainPknoRelation != null && StringKit.isNotBlank(irainPknoRelation.getIrainPkno1())){
  			/****  以下为模拟入参    实际入参 由app提供-------------------------------------*/
  			Prop prop = PropKit.use("a_little_config.txt");
  		    Long time = System.currentTimeMillis();
  			String md5  = MD5Utils.enMD5(prop.get("irain.appid")+prop.get("irain.appsecret")+time);
  			Map<String, Object> params = new HashMap<>();
  			params.put("appid", prop.get("irain.appid"));
  			params.put("sign", md5);
  			params.put("timestamp", time);
  			params.put("vpl_number", carNum);
  			params.put("park_code", irainPknoRelation.getIrainPkno1());
  			
  			try {
  				logger.info("irain 查询停车费用入参:" + JSONObject.toJSONString(params));
  				 rs = HttpClientTutorial.httpPostRequest(prop.get("irain.url")+"/bill/Query", params);
  				logger.info("irain 查询停车费用返回:" + JSONObject.toJSONString(rs));
  			} catch (Exception e) {
  				logger.info("irain 查询停车费用出错:" + e);
  			}
  		}else{
  			logger.info("没有查询到艾润查询费用编码");
  		}
  		 
  		logger.info("结束调用查询费用接口,结果="+JSONObject.toJSONString(rs));
  		
  	
  		return JSONObject.toJSON(rs)+"";
  	}
  }