身份校验需求变更

This commit is contained in:
zhanglei 2018-07-12 16:11:15 +08:00
parent 40158bdf2e
commit 1217faf11e
5 changed files with 225 additions and 83 deletions

View File

@ -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"%>
<script type="text/javascript">
function identitycheck(){
var flowunid = "<%=sFlowUnid%>";
var username = "<%=userName%>";
var orgname = "<%=orgName%>";
alert(flowunid+"@"+username+"@"+orgname);
var result =
RunJavaMethodTrans("com.tenwa.lease.flow.project.validate.IdentityVerification","doIdentityVerification","FlowUnid="+flowunid+",UserName="+username+",OrgName="+orgname);
if(result == 'ERROR'){
alert("调用数据失败");
}else if(result == 'SUCCESS'){
reloadSelf();
}else{
alert(result);
}
}
function viewAndEdit(){
var sUrl = "/Tenwa/Lease/Flow/Comm/LBIdentityCheck/LBIdentityCheckResultTemp.jsp";
var sparam="FlowUnid="+'<%=sFlowUnid%>';
AsControl.OpenView(sUrl,sparam,"_self","");
}
</script>
<%@ include file="/Frame/resources/include/include_end.jspf"%>

View File

@ -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"%>
<script type="text/javascript">
function goBack(){
//要跳转的url
var url="/Tenwa/Lease/Flow/Comm/LBIdentityCheck/LBCarIdentityCheck.jsp";
var sparam="FlowUnid="+'<%=sFlowUnid%>';
AsControl.OpenView(url,sparam,"_self","");
}
</script>
<%@ include file="/Frame/resources/include/include_end.jspf"%>

View File

@ -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<Element> 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<Element> itemElement = rootElement.element("ROW").element("OUTPUT").elements("ITEM");
@SuppressWarnings("unchecked")
List <Element>resultElement1 = itemElement.get(0).elements();
@SuppressWarnings("unchecked")
List <Element>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<BizObject> 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<Element> elements = rowElement.elements();
String errormessage = elements.get(1).getText();
return "验证失败,错误原因:"+errormessage;
}else if("ROWS".equals(rootElement.getName())){
@SuppressWarnings("unchecked")
List<Element> rowElement = rootElement.elements("ROW");
for(int i=0;i<rowElement.size();i++){
BizObject resultObject = bom4.newObject();
@SuppressWarnings("unchecked")
List<Element> 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<Element> itemElements = rowElement.get(i).element("OUTPUT").elements("ITEM");
//获取第一个item
@SuppressWarnings("unchecked")
List<Element> outputCertIdElements= itemElements.get(0).elements();
//获取第二个item
@SuppressWarnings("unchecked")
List<Element> 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";
}
}

View File

@ -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();
}

View File

@ -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<BizObject> bizList) throws Exception {
StringBuffer sb = new StringBuffer("");
//拼接soap请求的xml
//sb.append("<![CDATA[");
//sb.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
/*sb.append("<soapenv:Envelope "
+ "xmlns:nci='https://api.nciic.org.cn/NciicServices' "
+ "xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/'>");
sb.append("<soapenv:Header>");
sb.append("<soapenv:Body>");
sb.append("<nci:nciicCompare>");
sb.append("<nci:inLicense><![CDATA[");
//入参授权文件
sb.append(inLicense);
sb.append("]]></nci:inLicense>");*/
//sb.append("<![CDATA[");
sb.append("<?xml version='1.0' encoding='UTF-8'?>");
sb.append("<ROWS>");
sb.append("<INFO>");
@ -30,24 +16,30 @@ public class SoapRequest {
sb.append("<GMSFHM>公民身份号码</GMSFHM>");
sb.append("<XM>姓名</XM>");
sb.append("</ROW>");
sb.append("<ROW FSD='000000' YWLX='身份认证'>");
//入参身份证号码
sb.append("<GMSFHM>"+IDNo+"</GMSFHM>");
//入参姓名
sb.append("<XM>"+username+"</XM>");
sb.append("<ROW FSD='000001' YWLX='安鹏国际'>");
//入参申请人身份证号码
sb.append("<GMSFHM>"+biz1.getAttribute("CERTID").getString()+"</GMSFHM>");
//入参申请人姓名
sb.append("<XM>"+biz1.getAttribute("FULLNAME").getString()+"</XM>");
sb.append("</ROW>");
sb.append("<ROW FSD='000001' YWLX='安鹏国际'>");
//入参共同申请人身份证号码
sb.append("<GMSFHM>"+biz2.getAttribute("certid").getString()+"</GMSFHM>");
//入参共同申请人姓名
sb.append("<XM>"+biz2.getAttribute("name").getString()+"</XM>");
sb.append("</ROW>");
for(int i=0;i<bizList.size();i++){
sb.append("<ROW FSD='000001' YWLX='安鹏国际'>");
//入参共同申请人身份证号码
sb.append("<GMSFHM>"+bizList.get(i).getAttribute("CERTID").getString()+"</GMSFHM>");
//入参共同申请人姓名
sb.append("<XM>"+bizList.get(i).getAttribute("FULLNAME").getString()+"</XM>");
sb.append("</ROW>");
}
sb.append("</ROWS>");
//sb.append("]]>");
/* sb.append("</nci:nciicCompare>");
sb.append("</soapenv:Body>");
sb.append("</soapenv:Envelope>");*/
//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;
}
}