public Map acceptPrintInfo(String printJson) {
Map result = new HashMap();
TranDataBO tranData=new TranDataBO();
RiskBO risk=new RiskBO();
CashValueBO cashValue=new CashValueBO();
AppntBO appnt=new AppntBO();
InsuredBO insured=new InsuredBO();
CompanyInfoBO companyInfo=new CompanyInfoBO();
JSONObject printInfo = JSONObject.fromObject(printJson);
tranData.setBizNo(printInfo.getString("bizNo"));
tranData.setComment(printInfo.getString("comment"));
tranData.setInsurancePlan(printInfo.getString("insurancePlan"));
tranData.setTotalPremiun(printInfo.getString("totalPremiun"));
tranData.setImage(printInfo.getString("image"));
tranData.setTemplateCode(printInfo.getString("templateCode"));
tranData.setClauseUrl(printInfo.getString("clauseUrl"));
tranData.setCValiDate(printInfo.getString("CValiDate"));
tranData.setInsurancePlanNo(printInfo.getString("insurancePlanNo"));
tranData.setPolSpec(printInfo.getString("polSpec"));
tranData.setContEndDate(printInfo.getString("contEndDate"));
JSONArray risksArray = printInfo.getJSONArray("risks");
/*---------------保險種類------------------------------*/
Iterator<JSONArray> risks = risksArray.iterator();
while (risks.hasNext()) {
JSONObject riskInfo = JSONObject.fromObject(risks.next());
risk.setRiskName(riskInfo.getString("riskName"));
risk.setPayMode(riskInfo.getString("payMode"));
risk.setInsuredAmount(riskInfo.getString("insuredAmount"));
risk.setPayPeriod(riskInfo.getString("payPeriod"));
risk.setRiskPeriod(riskInfo.getString("riskPeriod"));
risk.setPremiun(riskInfo.getString("premiun"));
JSONArray cashValuesArray = riskInfo.getJSONArray("cashValues");
Iterator<JSONArray> cashValues = cashValuesArray.iterator();
while (cashValues.hasNext()) {
JSONObject cashValueInfo = JSONObject.fromObject(cashValues.next());
cashValue.setCash(cashValueInfo.getString("cash"));
cashValue.setEnd(cashValueInfo.getString("end"));
}
}
/*---------------投保人信息------------------------------*/
JSONObject appntInfo=printInfo.getJSONObject("appnt");
appnt.setCertNo(appntInfo.getString("certNo"));
appnt.setCertType(appntInfo.getString("certType"));
appnt.setName(appntInfo.getString("name"));
appnt.setNo(appntInfo.getString("no"));
appnt.setSex(appntInfo.getString("sex"));
/*---------------被保人信息------------------------------*/
JSONArray insuredsArray = printInfo.getJSONArray("insureds");
Iterator<JSONArray> insureds= insuredsArray.iterator();
while (insureds.hasNext()) {
JSONObject insuredInfo = JSONObject.fromObject(insureds.next());
insured.setCertNo(insuredInfo.getString("certNo"));
insured.setCertType(insuredInfo.getString("certType"));
insured.setName(insuredInfo.getString("name"));
insured.setNo(insuredInfo.getString("no"));
insured.setSex(insuredInfo.getString("sex"));
}
/*---------------公司信息------------------------------*/
JSONObject company=printInfo.getJSONObject("companyInfo");
companyInfo.setName(company.getString("name"));
companyInfo.setPhone(company.getString("phone"));
companyInfo.setAddress(company.getString("address"));
companyInfo.setZipCode(company.getString("zipCode"));
companyInfo.setServiceOrganiza(company.getString("serviceOrganiza"));
companyInfo.setUrl(company.getString("url"));
return result;
}json
對應的json文件:app
{ "insurancePlan": "", "risks": [{ "riskName": "崑崙健康保險股份有限公司E順行航空意外傷害保險(2017版)", "payMode": "繳費方式", "cashValues": [{}], "insuredAmount": "1000000.00", "payPeriod": "2018-02-15", "riskPeriod": "2018-02-15", "premiun": "100.00" }], "appnt": { "sex": "男", "no": "0105836486", "name": "李彥祖", "certType": "身份證", "certNo": "1231231242321312" }, "totalPremiun": "陸拾萬元整", "image": "", "templateCode": "A168", "clauseUrl": "http://www.kunlunhealth.com/templet/default/ShowArticle_xxpl.jsp?id=4776", "CValiDate": "2018-02-08", "insurancePlanNo": "A168", "polSpec": "無", "insureds": [{ "sex": "男", "no": "0105836486", "name": "李彥祖", "certType": "身份證", "certNo": "12312312312423123" }, { "sex": "女", "no": "0105836485", "name": "韓雪", "certType": "身份證", "certNo": "12312312312" }], "contEndDate": "2018-02-15", "bizNo": "1708041358198180SW01", "comment": "備註", "companyInfo": { "phone": "(86)4008118899", "address": "北京市朝陽區建華南路6號院1號樓卓明大廈1層", "zipCode": "100022", "name": "崑崙健康北京分公司", "serviceOrganiza": "深圳衆誠泰保險經紀有限公司", "url": "www.kunlunhealth.com" } } |