diff --git a/WebContent/Tenwa/Lease/Flow/Comm/LBTelOnline/LbTelOnlinList.jsp b/WebContent/Tenwa/Lease/Flow/Comm/LBTelOnline/LbTelOnlinList.jsp index c278bb213..a2f4f011c 100644 --- a/WebContent/Tenwa/Lease/Flow/Comm/LBTelOnline/LbTelOnlinList.jsp +++ b/WebContent/Tenwa/Lease/Flow/Comm/LBTelOnline/LbTelOnlinList.jsp @@ -8,6 +8,7 @@ //初始话手机在线时长查询 String ProjectId = CurPage.getParameter("ProjectId"); + String flowunid = CurPage.getParameter("ObjectNo"); ASObjectModel doTemp = new ASObjectModel("LbTelOnlinList"); ASObjectWindow dwTemp = new ASObjectWindow(CurPage,doTemp,request); dwTemp.Style="1"; //--设置为Grid风格-- @@ -17,24 +18,29 @@ //0、是否展示 1、 权限控制 2、 展示类型 3、按钮显示名称 4、按钮解释文字 5、按钮触发事件代码 6、 7、 8、 9、图标,CSS层叠样式 10、风格 String sButtons[][] = { -// {"true","All","Button","新增","新增","newRecord()","","","","btn_icon_add",""}, -// {"true","","Button","详情","详情","viewAndEdit()","","","","btn_icon_detail",""}, -// {"true","","Button","删除","删除","if(confirm('确实要删除吗?'))as_delete(0,'alert(getRowCount(0))')","","","","btn_icon_delete",""}, + {"true","","Button","校验手机号在线时长","调用查询接口","checkPhoneNumberOnLine()","","","","btn_icon_detail",""}, + {"true","All","Button","重发","选择需要重新查询的某条数据","retry()","","","","btn_icon_detail",""}, }; %><%@include file="/Frame/resources/include/ui/include_list.jspf"%> <%@ include file="/Frame/resources/include/include_end.jspf"%> \ No newline at end of file diff --git a/WebContent/WEB-INF/etc/jbo/jbo_lease.xml b/WebContent/WEB-INF/etc/jbo/jbo_lease.xml index 978e92126..897a370f8 100644 --- a/WebContent/WEB-INF/etc/jbo/jbo_lease.xml +++ b/WebContent/WEB-INF/etc/jbo/jbo_lease.xml @@ -4227,6 +4227,7 @@ + diff --git a/config/telonline.properties b/config/telonline.properties new file mode 100644 index 000000000..022918c88 --- /dev/null +++ b/config/telonline.properties @@ -0,0 +1,11 @@ +#娴嬭瘯璇锋眰鍦板潃 +com.tenwa.jianghd.url1=https +com.tenwa.jianghd.url2=apitest.tongdun.cn +com.tenwa.jianghd.url3=/bodyguard/apply/v4.3 + +com.tenwa.jianghd.partner_code=apgj +com.tenwa.jianghd.partner_key=3a7be6a6d73c48b18f083ddf8d399538 +com.tenwa.jianghd.app_name=apgj_web + +com.tenwa.jianghd.biz_code=OnLine +com.tenwa.jianghd.encode=UTF-8 \ No newline at end of file diff --git a/src_tenwa/com/tenwa/lease/flow/project/validate/OnlineClient.java b/src_tenwa/com/tenwa/lease/flow/project/validate/OnlineClient.java index 8ed698f28..81555ea45 100644 --- a/src_tenwa/com/tenwa/lease/flow/project/validate/OnlineClient.java +++ b/src_tenwa/com/tenwa/lease/flow/project/validate/OnlineClient.java @@ -8,6 +8,8 @@ import java.util.ArrayList; import java.util.List; import java.util.Map; +import jbo.com.tenwa.lease.comm.LB_TELONLINE; + import org.apache.http.HttpEntity; import org.apache.http.NameValuePair; import org.apache.http.client.ClientProtocolException; @@ -20,6 +22,10 @@ import org.apache.http.impl.client.HttpClients; import org.apache.http.message.BasicNameValuePair; import org.apache.http.util.EntityUtils; +import com.alibaba.fastjson.JSON; +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.comm.util.jboutil.DataOperatorUtil; @@ -27,49 +33,70 @@ import com.tenwa.comm.util.jboutil.DataOperatorUtil; public class OnlineClient { - private static String partner_code = "apgj"; - private static String URI_SEND_SMS = "https://apitest.tongdun.cn/bodyguard/apply/v4.3"; - private static String ENCODING = "UTF-8"; - private static String partner_key = "3a7be6a6d73c48b18f083ddf8d399538"; - private static String app_name = "apgj_web"; - private static String biz_code = "OnLine"; + private static String partner_code = TelOnLineConfigure.get("com.tenwa.jianghd.partner_code"); + private static String url1 = TelOnLineConfigure.get("com.tenwa.jianghd.url1"); + private static String url2 = TelOnLineConfigure.get("com.tenwa.jianghd.url2"); + private static String url3 = TelOnLineConfigure.get("com.tenwa.jianghd.url3"); +// private static String URI_SEND_SMS = "https://apitest.tongdun.cn/bodyguard/apply/v4.3"; + private static String ENCODING =TelOnLineConfigure.get("com.tenwa.jianghd.encode"); + private static String partner_key = TelOnLineConfigure.get("com.tenwa.jianghd.partner_key"); + private static String app_name =TelOnLineConfigure.get("com.tenwa.jianghd.app_name"); + private static String biz_code = TelOnLineConfigure.get("com.tenwa.jianghd.biz_code"); private String flowunid; + private String projectId; + + private String onLineId; public static void main(String[] org0) throws ClientProtocolException, IOException, URISyntaxException{ - CloseableHttpClient httpclient = HttpClients.createDefault(); - HttpPost httpPost = new HttpPost(getUri()); - List nvps = new ArrayList (); - - nvps.add(new BasicNameValuePair("account_mobile", "18721658364")); - nvps.add(new BasicNameValuePair("biz_code", biz_code)); - httpPost.setEntity(new UrlEncodedFormEntity(nvps)); - - CloseableHttpResponse response2 = httpclient.execute(httpPost); - - try { - System.out.println(response2.getStatusLine().getStatusCode()); - HttpEntity entity2 = response2.getEntity(); - String ss = EntityUtils.toString(entity2); - System.out.println(ss); - EntityUtils.consume(entity2); - } finally { - response2.close(); - } + + System.out.println(partner_code+","+url1); +// +// CloseableHttpClient httpclient = HttpClients.createDefault(); +// +// HttpPost httpPost = new HttpPost(getUri()); +// List nvps = new ArrayList (); +// //WF2018081112414717786099 +// nvps.add(new BasicNameValuePair("account_mobile", "13000000000")); +// nvps.add(new BasicNameValuePair("biz_code", biz_code)); +//// nvps.add(new BasicNameValuePair("id", "WF2018081112414717786099")); +//// nvps.add(new BasicNameValuePair("invoke_type", "RETRY")); +// httpPost.setEntity(new UrlEncodedFormEntity(nvps)); +// +// CloseableHttpResponse response2 = httpclient.execute(httpPost); +// +// try { +// System.out.println(response2.getStatusLine().getStatusCode()); +// HttpEntity entity2 = response2.getEntity(); +// String ss = EntityUtils.toString(entity2); +// Map mapTypes = JSON.parseObject(ss); +// System.out.println(mapTypes); +// EntityUtils.consume(entity2); +// } finally { +// response2.close(); +// } } public static URI getUri() throws URISyntaxException{ - URI uri = URIUtils.createURI("https", "apitest.tongdun.cn", -1, "/bodyguard/apply/v4.3", - "partner_code=apgj&partner_key=3a7be6a6d73c48b18f083ddf8d399538&app_name=apgj_web", null); + URI uri = URIUtils.createURI(url1, url2, -1, url3, + "partner_code="+partner_code+"&partner_key="+partner_key+"&app_name="+app_name, null); return uri; } - public String postOnLine(String phone) throws URISyntaxException, ClientProtocolException, IOException{ + + public String postOnLine(String phone,String nextService,String onLineId) throws Exception{ CloseableHttpClient httpclient = HttpClients.createDefault(); HttpPost httpPost = new HttpPost(getUri()); List nvps = new ArrayList (); - nvps.add(new BasicNameValuePair("account_mobile", phone)); nvps.add(new BasicNameValuePair("biz_code", biz_code)); - httpPost.setEntity(new UrlEncodedFormEntity(nvps)); + //重试 + if("RETRY".equals(nextService)){ + nvps.add(new BasicNameValuePair("invoke_type", nextService)); + nvps.add(new BasicNameValuePair("id", onLineId));//进件id + }else{ + //首发 + nvps.add(new BasicNameValuePair("account_mobile", phone)); + } + httpPost.setEntity(new UrlEncodedFormEntity(nvps,ENCODING)); CloseableHttpResponse response2 = httpclient.execute(httpPost); try { @@ -77,17 +104,63 @@ public class OnlineClient { System.out.println(statusCode); if(statusCode==200){ HttpEntity entity2 = response2.getEntity(); - String ss = EntityUtils.toString(entity2); - System.out.println(ss); - return ss; + String str = EntityUtils.toString(entity2); + System.out.println(str); + return str; }else{ - return "请求数据失败。"; + throw new Exception("请求数据失败"); } // EntityUtils.consume(entity2); } finally { response2.close(); } } + //单条重发 + public String getTelOnLineReTry(JBOTransaction tx){ + try { + String jsonStr = postOnLine("","RETRY",onLineId); + Map mapTypes = JSON.parseObject(jsonStr); + boolean success = (boolean)(mapTypes.get("success")); + if(success){ + String onLineId = mapTypes.get("id").toString(); + String result_desc = mapTypes.get("result_desc").toString(); + Map MobileDuration = JSON.parseObject(JSON.parseObject(JSON.parseObject(result_desc).get("AUTHENTICATION_INFOQUERY").toString()).get("MobileDuration").toString()); + Object mobile_online_time_info = ""; + Object mobile_online_time_consistence = ""; + if(MobileDuration.get("error_info")==null){ + mobile_online_time_info = MobileDuration.get("mobile_online_time_info"); + mobile_online_time_consistence = MobileDuration.get("mobile_online_time_consistence"); + } + //失败特有的参数 + Object nextService = mapTypes.get("nextService"); + Object reason_code = mapTypes.get("reason_code"); + Object reason_desc = mapTypes.get("reason_desc"); + //更新需要重发的数据 + JBOFactory.getBizObjectManager(LB_TELONLINE.CLASS_NAME, tx).createQuery("update O set success='"+success+"',result_desc='"+result_desc+"'," + + "mobile_online_time_info='"+mobile_online_time_info+"',mobile_online_time_consistence='"+mobile_online_time_consistence+"'," + + "nextService='"+nextService+"',reason_code='"+reason_code+"',reason_desc='"+reason_desc+"' where online_id=:id") + .setParameter("id", onLineId).executeUpdate(); + }else{ + Object reason_code = mapTypes.get("reason_code"); + Object reason_desc = mapTypes.get("reason_desc"); + //更新需要重发的数据 + JBOFactory.getBizObjectManager(LB_TELONLINE.CLASS_NAME, tx).createQuery("update O set success='"+success+"'" + + ",reason_code='"+reason_code+"',reason_desc='"+reason_desc+"' where online_id=:id") + .setParameter("id", onLineId).executeUpdate(); + } + tx.commit(); + } catch (Exception e) { + e.printStackTrace(); + try { + tx.rollback(); + } catch (JBOException e1) { + e1.printStackTrace(); + } + return "调用数据失败"; + } + return "true"; + } + //业务申请流程中获取包括 承租人,共同申请人,担保人的手机号 public String getTelOnLine(JBOTransaction tx){ String sql = "select certid,FULLNAME as name,MOBILE as phone,'assuror' as custtype,'担保人' as typename from LB_GUARANTEE_UNIT_TEMP where flowunid='"+flowunid+"' and CERTTYPE='Ind01' " @@ -97,15 +170,54 @@ public class OnlineClient { List> ds = DataOperatorUtil.getDataBySql(tx, sql, null); if(ds.size()>0){ for (int i = 0; i < ds.size(); i++) { - String name = ds.get(i).get("NAME"); - String phone = ds.get(i).get("PHONE"); - String jsonStr = postOnLine(phone); - + String certid = ds.get(i).get("certid"); + String name = ds.get(i).get("name"); + String phone = ds.get(i).get("phone"); + BizObjectManager ltbom = JBOFactory.getBizObjectManager(LB_TELONLINE.CLASS_NAME, tx); + BizObject lton = ltbom.createQuery("PERSON_ID=:PERSON_ID").setParameter(LB_TELONLINE.PERSON_ID, certid).getSingleResult(true); + Map mapTypes =null; + //1.不存在则新增 + if(lton==null){ + String jsonStr = postOnLine(phone,"",""); + mapTypes = JSON.parseObject(jsonStr); + lton = ltbom.newObject(); + lton.setAttributeValue(LB_TELONLINE.PROJECT_ID, projectId); + lton.setAttributeValue(LB_TELONLINE.PERSON_ID, certid); + lton.setAttributeValue(LB_TELONLINE.USER_NAME, name); + lton.setAttributeValue(LB_TELONLINE.TELEPHONE, phone); + }else{ + //2.存在则重发 + String jsonStr = postOnLine(phone,lton.getAttribute(LB_TELONLINE.nextService).getString(),lton.getAttribute(LB_TELONLINE.online_id).getString()); + mapTypes = JSON.parseObject(jsonStr); + } + //2.1并根据响应回来的结果更新数据 + lton.setAttributeValue(LB_TELONLINE.success, mapTypes.get("success")); + if("true".equals(mapTypes.get("success").toString())){ + lton.setAttributeValue(LB_TELONLINE.online_id, mapTypes.get("id")); + lton.setAttributeValue(LB_TELONLINE.result_desc, mapTypes.get("result_desc")); + String result_desc = mapTypes.get("result_desc").toString(); + Map MobileDuration = JSON.parseObject(JSON.parseObject(JSON.parseObject(result_desc).get("AUTHENTICATION_INFOQUERY").toString()).get("MobileDuration").toString()); + if(MobileDuration.get("error_info")==null){ + lton.setAttributeValue(LB_TELONLINE.mobile_online_time_info, MobileDuration.get("mobile_online_time_info")); + lton.setAttributeValue(LB_TELONLINE.mobile_online_time_consistence, MobileDuration.get("mobile_online_time_consistence")); + } + //失败特有的参数 + lton.setAttributeValue(LB_TELONLINE.nextService, mapTypes.get("nextService")); + } + lton.setAttributeValue(LB_TELONLINE.reason_code, mapTypes.get("reason_code")); + lton.setAttributeValue(LB_TELONLINE.reason_desc, mapTypes.get("reason_desc")); + ltbom.saveObject(lton); } + tx.commit(); } - } catch (Exception e) { + try { + tx.rollback(); + } catch (JBOException e1) { + e1.printStackTrace(); + } e.printStackTrace(); + return e.getMessage(); } return "true"; } @@ -118,6 +230,18 @@ public class OnlineClient { public void setFlowunid(String flowunid) { this.flowunid = flowunid; } + public String getProjectId() { + return projectId; + } + public void setProjectId(String projectId) { + this.projectId = projectId; + } + public String getOnLineId() { + return onLineId; + } + public void setOnLineId(String onLineId) { + this.onLineId = onLineId; + } diff --git a/src_tenwa/com/tenwa/lease/flow/project/validate/TelOnLineConfigure.java b/src_tenwa/com/tenwa/lease/flow/project/validate/TelOnLineConfigure.java new file mode 100644 index 000000000..24ccda912 --- /dev/null +++ b/src_tenwa/com/tenwa/lease/flow/project/validate/TelOnLineConfigure.java @@ -0,0 +1,40 @@ +package com.tenwa.lease.flow.project.validate; + +import java.io.IOException; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Properties; +import java.util.concurrent.ConcurrentHashMap; + +import com.amarsoft.are.ARE; + +public class TelOnLineConfigure { + private static Map attributes; + + public static void load() { + attributes = new ConcurrentHashMap(); + Properties prop = new Properties(); + try { + prop.load(TelOnLineConfigure.class.getResourceAsStream("/telonline.properties")); + for(Entry entry : prop.entrySet()) { + if(entry.getKey() == null || entry.getValue() == null) { + continue; + } + attributes.put(entry.getKey().toString(), entry.getValue().toString()); + } + } catch (IOException e) { + e.printStackTrace(); + ARE.getLog().error("init GPSConfigure info failed"); + } + ARE.getLog().info("init GPSConfigure info success"); + } + + public static void destroy() { + if(attributes != null) attributes.clear(); + } + + public static String get(String propName) { + if(attributes == null) load(); + return attributes.get(propName); + } +}