From 1217faf11ee9af6c57eb395add653bbe33867754 Mon Sep 17 00:00:00 2001 From: zhanglei Date: Thu, 12 Jul 2018 16:11:15 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BA=AB=E4=BB=BD=E6=A0=A1=E9=AA=8C=E9=9C=80?= =?UTF-8?q?=E6=B1=82=E5=8F=98=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../LBIdentityCheck/LBCarIdentityCheck.jsp | 46 +++++ .../LBIdentityCheckResultTemp.jsp | 29 +++ .../validate/IdentityVerification.java | 168 +++++++++++++----- .../flow/project/validate/NciicClient.java | 9 +- .../flow/project/validate/SoapRequest.java | 56 +++--- 5 files changed, 225 insertions(+), 83 deletions(-) create mode 100644 WebContent/Tenwa/Lease/Flow/Comm/LBIdentityCheck/LBCarIdentityCheck.jsp create mode 100644 WebContent/Tenwa/Lease/Flow/Comm/LBIdentityCheck/LBIdentityCheckResultTemp.jsp diff --git a/WebContent/Tenwa/Lease/Flow/Comm/LBIdentityCheck/LBCarIdentityCheck.jsp b/WebContent/Tenwa/Lease/Flow/Comm/LBIdentityCheck/LBCarIdentityCheck.jsp new file mode 100644 index 000000000..2c1e4df0c --- /dev/null +++ b/WebContent/Tenwa/Lease/Flow/Comm/LBIdentityCheck/LBCarIdentityCheck.jsp @@ -0,0 +1,46 @@ +<%@ page contentType="text/html; charset=GBK"%> +<%@ include file="/Frame/resources/include/include_begin_list.jspf"%><% + /* + Author: undefined 2018-07-12 + Content: + History Log: + */ + String sFlowUnid = CurPage.getParameter("FlowUnid");//流程编号 + String orgName = CurUser.getOrgName(); + String userName = CurUser.getUserName(); + ASObjectModel doTemp = new ASObjectModel("VI_LB_IDENTITY_CHECK"); + ASObjectWindow dwTemp = new ASObjectWindow(CurPage,doTemp,request); + dwTemp.Style="1"; //--设置为Grid风格-- + dwTemp.ReadOnly = "1"; //只读模式 + dwTemp.setPageSize(10); + dwTemp.genHTMLObjectWindow(sFlowUnid); + + //0、是否展示 1、 权限控制 2、 展示类型 3、按钮显示名称 4、按钮解释文字 5、按钮触发事件代码 6、 7、 8、 9、图标,CSS层叠样式 10、风格 + String sButtons[][] = { + {"true","","Button","详情","详情","viewAndEdit()","","","","btn_icon_detail",""}, + {"true","","Button","身份校验","身份校验","identitycheck()","","","","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/Tenwa/Lease/Flow/Comm/LBIdentityCheck/LBIdentityCheckResultTemp.jsp b/WebContent/Tenwa/Lease/Flow/Comm/LBIdentityCheck/LBIdentityCheckResultTemp.jsp new file mode 100644 index 000000000..7b6e5cfe5 --- /dev/null +++ b/WebContent/Tenwa/Lease/Flow/Comm/LBIdentityCheck/LBIdentityCheckResultTemp.jsp @@ -0,0 +1,29 @@ +<%@ page contentType="text/html; charset=GBK"%> +<%@ include file="/Frame/resources/include/include_begin_list.jspf"%><% + /* + Author: undefined 2018-07-12 + Content: + History Log: + */ + String sFlowUnid = CurPage.getParameter("FlowUnid");//流程编号 + ASObjectModel doTemp = new ASObjectModel("LC_IDENTITY_CHECK_RESULT_TEMP"); + ASObjectWindow dwTemp = new ASObjectWindow(CurPage,doTemp,request); + dwTemp.Style="1"; //--设置为Grid风格-- + dwTemp.ReadOnly = "1"; //只读模式 + dwTemp.setPageSize(10); + dwTemp.genHTMLObjectWindow(sFlowUnid); + + //0、是否展示 1、 权限控制 2、 展示类型 3、按钮显示名称 4、按钮解释文字 5、按钮触发事件代码 6、 7、 8、 9、图标,CSS层叠样式 10、风格 + String sButtons[][] = { + {"true","","Button","返回","返回","goBack()","","","","btn_icon_back",""} + }; +%><%@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/src_tenwa/com/tenwa/lease/flow/project/validate/IdentityVerification.java b/src_tenwa/com/tenwa/lease/flow/project/validate/IdentityVerification.java index baf326271..3b43baa23 100644 --- a/src_tenwa/com/tenwa/lease/flow/project/validate/IdentityVerification.java +++ b/src_tenwa/com/tenwa/lease/flow/project/validate/IdentityVerification.java @@ -1,69 +1,149 @@ package com.tenwa.lease.flow.project.validate; +import java.text.SimpleDateFormat; +import java.util.Date; import java.util.List; + import org.dom4j.Document; import org.dom4j.DocumentHelper; import org.dom4j.Element; + import sun.misc.BASE64Decoder; +import jbo.app.tenwa.customer.CUSTOMER_FAMILY_TEMP; import jbo.app.tenwa.customer.CUSTOMER_PERSON_TEMP; +import jbo.com.tenwa.lease.comm.LB_GUARANTEE_UNIT_TEMP; +import jbo.com.tenwa.lease.comm.LC_IDENTITY_CHECK_RESULT_TEMP; + import com.amarsoft.are.jbo.BizObject; import com.amarsoft.are.jbo.BizObjectManager; import com.amarsoft.are.jbo.JBOFactory; import com.amarsoft.are.jbo.JBOTransaction; - +/** + * 身份证校验类 + * @author 张磊 + * 2018年7月12日 下午2:18:21 + */ public class IdentityVerification { - private String id; - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } + private String FlowUnid; + private String UserName; + private String OrgName; + public String getFlowUnid() { + return FlowUnid; + } + + public void setFlowUnid(String flowUnid) { + FlowUnid = flowUnid; + } + + public String getUserName() { + return UserName; + } + + public void setUserName(String userName) { + UserName = userName; + } + + public String getOrgName() { + return OrgName; + } + + public void setOrgName(String orgName) { + OrgName = orgName; + } + public String doIdentityVerification(JBOTransaction tx){ + System.err.println(UserName+"@"+OrgName+"@"+FlowUnid); try { BizObjectManager bom1 = JBOFactory.getBizObjectManager(CUSTOMER_PERSON_TEMP.CLASS_NAME,tx); - BizObject identityObject = bom1.createQuery("ID=:id").setParameter("id", id).getSingleResult(false); - //读取授权文件 - String license =ValidatePropertiesUtil.get("key"); - String decode = new String(new BASE64Decoder().decodeBuffer(license)); - String inConditions = SoapRequest.XMLConfiguration(identityObject.getAttribute("CERTID").getString(),identityObject.getAttribute("FULLNAME").getString()); - String result = NciicClient.executeClient("NciicServices",decode,inConditions); - Document document = DocumentHelper.parseText(result); - Element rootElement = document.getRootElement(); - String finalResult = ""; - StringBuffer sb = new StringBuffer(); - if("RESPONSE".equals(rootElement.getName())){ - Element rowElement = rootElement.element("ROWS").element("ROW"); - @SuppressWarnings("unchecked") - List elements = rowElement.elements(); - for(Element element:elements){ - sb.append(element.getText()+","); - } - String message = sb.toString().split(",")[1]; - finalResult = "验证失败:"+message; - }else if("ROWS".equals(rootElement.getName())){ - @SuppressWarnings("unchecked") - List itemElement = rootElement.element("ROW").element("OUTPUT").elements("ITEM"); - @SuppressWarnings("unchecked") - List resultElement1 = itemElement.get(0).elements(); - @SuppressWarnings("unchecked") - List resultElement2= itemElement.get(1).elements(); - if("errormesage".equals(resultElement1.get(0).getName())){ - finalResult = "错误信息:"+ resultElement1.get(0).getText()+",错误字段:" - + resultElement2.get(0).getText(); - }else if("gmsfhm".equals(resultElement1.get(0).getName())){ - finalResult = "身份证号码对比结果:"+ resultElement1.get(1).getText()+",姓名对比结果:" - + resultElement2.get(1).getText(); - } + BizObjectManager bom2 = JBOFactory.getBizObjectManager(CUSTOMER_FAMILY_TEMP.CLASS_NAME, tx); + BizObjectManager bom3 = JBOFactory.getBizObjectManager(LB_GUARANTEE_UNIT_TEMP.CLASS_NAME, tx); + BizObjectManager bom4 = JBOFactory.getBizObjectManager(LC_IDENTITY_CHECK_RESULT_TEMP.CLASS_NAME,tx); + BizObject queryResult = bom4.createQuery("select result from O where flowunid=:FLOWUNID").setParameter("FLOWUNID",FlowUnid).getSingleResult(false); + if(queryResult!=null){ + return "身份证校验已执行过,不可重复执行"; + }else{ + //查询借款人 + BizObject borrowerResult = bom1.createQuery("SELECT "+ + "fullname,"+ + "certid "+ + "FROM "+ + "O WHERE flowunid=:FLOWUNID "+ + "AND O.BALANCESHEET = '申请人' ").setParameter("FLOWUNID",FlowUnid).getSingleResult(false); + //查询共同借款人 + BizObject coborrowerResult = bom2.createQuery("SELECT "+ + "name,"+ + "certid "+ + "FROM "+ + "O WHERE flowunid=:FLOWUNID AND Partner_ = 'Y'").setParameter("FLOWUNID", FlowUnid).getSingleResult(false); + //查询担保人 + @SuppressWarnings("unchecked") + List guarantorResultList = bom3.createQuery("SELECT "+ + "fullname,"+ + "certid "+ + "FROM "+ + "O WHERE flowunid=:FLOWUNID " + ).setParameter("FLOWUNID",FlowUnid).getResultList(false); + //读取授权文件 + String license =ValidatePropertiesUtil.get("key"); + String decode = new String(new BASE64Decoder().decodeBuffer(license)); + //将申请人,共同申请人,担保人等信息传入该类构建xml入参参数 + String inConditions = SoapRequest.XMLConfiguration(borrowerResult,coborrowerResult,guarantorResultList); + String result = NciicClient.executeClient("NciicServices",decode,inConditions); + Document document = DocumentHelper.parseText(result); + Element rootElement = document.getRootElement(); + String finalResult = ""; + if("RESPONSE".equals(rootElement.getName())){ + Element rowElement = rootElement.element("ROWS").element("ROW"); + @SuppressWarnings("unchecked") + List elements = rowElement.elements(); + String errormessage = elements.get(1).getText(); + return "验证失败,错误原因:"+errormessage; + }else if("ROWS".equals(rootElement.getName())){ + @SuppressWarnings("unchecked") + List rowElement = rootElement.elements("ROW"); + for(int i=0;i inputElements = rowElement.get(i).element("INPUT").elements(); + String certid = inputElements.get(0).getText(); + String name = inputElements.get(1).getText(); + //向校验结果临时表存入数据 + resultObject.setAttributeValue("flowunid",FlowUnid); + resultObject.setAttributeValue("name",name); + resultObject.setAttributeValue("certid", certid); + resultObject.setAttributeValue("inputuserid",UserName); + resultObject.setAttributeValue("inputorgid", OrgName); + resultObject.setAttributeValue("inputtime", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date())); + //获取output中的所有item + @SuppressWarnings("unchecked") + List itemElements = rowElement.get(i).element("OUTPUT").elements("ITEM"); + //获取第一个item + @SuppressWarnings("unchecked") + List outputCertIdElements= itemElements.get(0).elements(); + //获取第二个item + @SuppressWarnings("unchecked") + List outputNameElements= itemElements.get(1).elements(); + //判断第一个item中的第一个表情元素的名字 + if("gmsfhm".equals(outputCertIdElements.get(0).getName())){ + String certIdResult = outputCertIdElements.get(1).getText(); + String nameResult = outputNameElements.get(1).getText(); + finalResult = "身份证校验结果:"+certIdResult+",姓名校验结果:"+nameResult; + resultObject.setAttributeValue("result",finalResult); + }else if("errormesage".equals(outputCertIdElements.get(0).getName())){ + String errorResult = outputCertIdElements.get(0).getText(); + finalResult = "错误原因为:"+errorResult; + resultObject.setAttributeValue("result", finalResult); + } + bom4.saveObject(resultObject); + } + } } - return finalResult; } catch (Exception e) { e.printStackTrace(); return "ERROR"; } + return "SUCCESS"; } } diff --git a/src_tenwa/com/tenwa/lease/flow/project/validate/NciicClient.java b/src_tenwa/com/tenwa/lease/flow/project/validate/NciicClient.java index cfcc9fa97..79dee5a11 100644 --- a/src_tenwa/com/tenwa/lease/flow/project/validate/NciicClient.java +++ b/src_tenwa/com/tenwa/lease/flow/project/validate/NciicClient.java @@ -27,17 +27,12 @@ public class NciicClient { public static void main(String[] args) throws MalformedURLException { try{ - - String IDNo = "140225199408171330"; - - String username = "张磊"; - - String license = ReadFile.ReadLine("D://app//license.txt"); + /*String license = ReadFile.ReadLine("D://app//license.txt"); System.out.println(license); String inConditions = SoapRequest.XMLConfiguration(IDNo, username); new NciicClient().executeClient("NciicServices", license , inConditions); - +*/ }catch(Exception e){ e.printStackTrace(); } diff --git a/src_tenwa/com/tenwa/lease/flow/project/validate/SoapRequest.java b/src_tenwa/com/tenwa/lease/flow/project/validate/SoapRequest.java index 2c250744f..1d24b4eb7 100644 --- a/src_tenwa/com/tenwa/lease/flow/project/validate/SoapRequest.java +++ b/src_tenwa/com/tenwa/lease/flow/project/validate/SoapRequest.java @@ -1,26 +1,12 @@ package com.tenwa.lease.flow.project.validate; +import java.util.List; +import com.amarsoft.are.jbo.BizObject; + public class SoapRequest { - public static String XMLConfiguration(String IDNo,String username) throws Exception { - //WebService接口地址? - //String wsdl = "https://ws.nciic.org.cn/nciic_ws/services/NciicServices"; - //int timeout = 10000; + public static String XMLConfiguration(BizObject biz1,BizObject biz2,List bizList) throws Exception { StringBuffer sb = new StringBuffer(""); - //拼接soap请求的xml - //sb.append(""); - /*sb.append(""); - sb.append(""); - sb.append(""); - sb.append(""); - sb.append("");*/ - //sb.append(""); sb.append(""); sb.append(""); @@ -30,24 +16,30 @@ public class SoapRequest { sb.append("公民身份号码"); sb.append("姓名"); sb.append(""); - sb.append(""); - //入参身份证号码 - sb.append(""+IDNo+""); - //入参姓名 - sb.append(""+username+""); + sb.append(""); + //入参申请人身份证号码 + sb.append(""+biz1.getAttribute("CERTID").getString()+""); + //入参申请人姓名 + sb.append(""+biz1.getAttribute("FULLNAME").getString()+""); sb.append(""); + sb.append(""); + //入参共同申请人身份证号码 + sb.append(""+biz2.getAttribute("certid").getString()+""); + //入参共同申请人姓名 + sb.append(""+biz2.getAttribute("name").getString()+""); + sb.append(""); + for(int i=0;i"); + //入参共同申请人身份证号码 + sb.append(""+bizList.get(i).getAttribute("CERTID").getString()+""); + //入参共同申请人姓名 + sb.append(""+bizList.get(i).getAttribute("FULLNAME").getString()+""); + sb.append(""); + } sb.append(""); - //sb.append("]]>"); - /* sb.append(""); - sb.append(""); - sb.append("");*/ - - //System.out.println(sb); - //HttpClient发送SOAP请求 System.out.println("HttpClient 发送SOAP请求"); - String xmldata = sb.toString(); - //System.out.println(xmldata); + System.out.println(xmldata); return xmldata; } }