2020-08-04 14:26:26 +08:00

1204 lines
51 KiB
Java
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package com.tenwa.httpclient.pypafhtml;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.google.common.collect.Lists;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
public class PyHtmlContent {
/**
* 统计时间段1-近1年、2-近2年、3-近5年、4-历史
* 数据库表名和列字段对应关系
*/
public enum JudicialXZCountTypeEnums{
taxPunishCount("taxPunishCount","税务处罚事件数量"),
marketPunishCount("marketPunishCount","市场监管处罚事件数量"),
customsPunishCount("customsPunishCount","海关处罚事件数量"),
environmentPunishCount("environmentPunishCount","环保处罚事件数量"),
otherPunishCount("otherPunishCount","其他行政处罚事件数量"),
punishTotalCount("punishTotalCount","(行政处罚事件)合计");
private String code; //类型
private String desc; //描述
private JudicialXZCountTypeEnums(String code, String desc){
this.code=code;
this.desc=desc;
}
public String getDesc() {
return desc;
}
public String getCode() {
return this.code;
}
/**
* 根据code 数据库表名的列字段
* @param code
* @return
*/
public static String getValueData(String code){
for(JudicialXZCountTypeEnums data : JudicialXZCountTypeEnums.values()){
if(data.getCode().toLowerCase().equals(code.toLowerCase())){
return data.getDesc();
}
}
return null;
}
}
/**
* 统计时间段1-近1年、2-近2年、3-近5年、4-历史
* 数据库表名和列字段对应关系
*/
public enum JudicialSFCountTypeEnums{
civilCaseCount("civilCaseCount","民事案件被告风险事件数量"),
criminalCaseCount("criminalCaseCount","刑事案件被告风险事件数量"),
judicialCount("judicialCount","司法被执行人风险事件数量"),
endCaseCount("endCaseCount","终本案件风险事件数量"),
breakFaithCount("breakFaithCount","失信被执行人风险事件数量"),
judicialTotalCount("judicialTotalCount","(司法涉诉风险事件)合计");
private String code; //类型
private String desc; //描述
private JudicialSFCountTypeEnums(String code, String desc){
this.code=code;
this.desc=desc;
}
public String getDesc() {
return desc;
}
public String getCode() {
return this.code;
}
/**
* 根据code 数据库表名的列字段
* @param code
* @return
*/
public static String getValueData(String code){
for(JudicialSFCountTypeEnums data : JudicialSFCountTypeEnums.values()){
if(data.getCode().toLowerCase().equals(code.toLowerCase())){
return data.getDesc();
}
}
return null;
}
}
/**
* 统计时间段1-近1年、2-近2年、3-近5年、4-历史
* 数据库表名和列字段对应关系
*/
public enum JudicialRiskTimeLengthEnums{
Length_1("1","oneYearCount"),
Length_2("2","twoYearCount"),
Length_3("3","fiveYearCount"),
Length_4("4","historyYearCount");
private String code; //类型
private String desc; //描述
private JudicialRiskTimeLengthEnums(String code, String desc){
this.code=code;
this.desc=desc;
}
public String getDesc() {
return desc;
}
public String getCode() {
return this.code;
}
/**
* 根据code 数据库表名的列字段
* @param code
* @return
*/
public static String getValueData(String code){
for(JudicialRiskTimeLengthEnums data : JudicialRiskTimeLengthEnums.values()){
if(data.getCode().toLowerCase().equals(code.toLowerCase())){
return data.getDesc();
}
}
return null;
}
}
/**
* 1正常在用 2: 停机 3未启用 4已销号 6预销号该值可能为空
* 数据库表名和列字段对应关系
*/
public enum MobileStsEnums{
Sts_1("1","正常在用"),
Sts_2("2","停机"),
Sts_3("3","未启用"),
Sts_4("4","已销号"),
Sts_6("6","预销号该值可能为空");
private String code; //类型
private String desc; //描述
private MobileStsEnums(String code, String desc){
this.code=code;
this.desc=desc;
}
public String getDesc() {
return desc;
}
public String getCode() {
return this.code;
}
/**
* 根据code 数据库表名的列字段
* @param code
* @return
*/
public static String getValueData(String code){
for(MobileStsEnums data : MobileStsEnums.values()){
if(data.getCode().toLowerCase().equals(code.toLowerCase())){
return data.getDesc();
}
}
return null;
}
}
//1不足3个月 23-6个月 36-12个月 412-24个月 524个月
/**
* 数据库表名和列字段对应关系
*/
public enum MobileTimeLengthEnums{
Length_1("1","不足3个月"),
Length_2("2","3-6个月"),
Length_3("3","6-12个月"),
Length_4("4","12-24个月"),
Length_5("5","24个月");
private String code; //类型
private String desc; //描述
private MobileTimeLengthEnums(String code, String desc){
this.code=code;
this.desc=desc;
}
public String getDesc() {
return desc;
}
public String getCode() {
return this.code;
}
/**
* 根据code 数据库表名的列字段
* @param code
* @return
*/
public static String getValueData(String code){
for(MobileTimeLengthEnums data : MobileTimeLengthEnums.values()){
if(data.getCode().toLowerCase().equals(code.toLowerCase())){
return data.getDesc();
}
}
return null;
}
}
/**
* 数据库表名和列字段对应关系
*/
public enum MobileOperatorEnums{
DX("1","中国电信"),
YD("2","中国移动"),
LT("3","中国联通");
private String code; //类型
private String desc; //描述
private MobileOperatorEnums(String code, String desc){
this.code=code;
this.desc=desc;
}
public String getDesc() {
return desc;
}
public String getCode() {
return this.code;
}
/**
* 根据code 数据库表名的列字段
* @param code
* @return
*/
public static String getValueData(String code){
for(MobileOperatorEnums data : MobileOperatorEnums.values()){
if(data.getCode().toLowerCase().equals(code.toLowerCase())){
return data.getDesc();
}
}
return null;
}
}
/**
* 数据库表名和列字段对应关系
*/
public enum PafEnums{
personAntiFraudDescInfo("personAntiFraudDescInfo","欺诈风险汇总", PyHtmlContent.personAntiFraudDescInfo),
personAntiFraudScoreInfo("personAntiFraudScoreInfo","欺诈风险指数", PyHtmlContent.personAntiFraudScoreInfo),
personBaseInfo("personBaseInfo","身份信息校验", PyHtmlContent.personBaseInfo),
policeCheckInfo("policeCheckInfo","身份认证结果", PyHtmlContent.policeCheckInfo),
mobileCheckInfo("mobileCheckInfo","手机号信息校验", PyHtmlContent.mobileCheckInfo),
mobileStatusInfo("mobileStatusInfo","手机号码时长", PyHtmlContent.mobileStatusInfo),
personRiskRosterInfo("personRiskRosterInfo","命中名单", PyHtmlContent.personRiskRosterInfo),
personJudicialSFRiskInfo("personJudicialSFRiskInfo","司法查询", PyHtmlContent.personJudicialSFRiskInfo),
personJudicialXZRiskInfo("personJudicialXZRiskInfo","行政查询", PyHtmlContent.personJudicialXZRiskInfo);
private String code; //类型
private String htmlContent; //类型
private String desc; //描述
private PafEnums(String code, String desc, String htmlContent){
this.code=code;
this.desc=desc;
this.htmlContent=htmlContent;
}
public String getDesc() {
return desc;
}
public String getHtmlContent() {
return htmlContent;
}
public String getCode() {
return this.code;
}
/**
* 根据code 数据库表名的列字段
* @param code
* @return
*/
public static String getValueData(String code){
for(PafEnums data : PafEnums.values()){
if(data.getCode().toLowerCase().equals(code.toLowerCase())){
return data.getHtmlContent();
}
}
return null;
}
}
/**
* 数据库表名和列字段对应关系
*/
public enum PersonAntiFraudDescInfoEnums{
antiFraudScore("antiFraudScore","欺诈风险指数"),
antiFraudScoreRiskLevel("antiFraudScoreRiskLevel","欺诈风险指数风险等级"),
policeCheckRiskLevel("policeCheckRiskLevel","身份认证结果风险等级"),
policeCheckDesc("policeCheckDesc","身份认证结果"),
mobileCheckRiskLevel("mobileCheckRiskLevel","手机号码核查结果风险等级"),
mobileCheckDesc("mobileCheckDesc","手机号码核查结果"),
mobileStatusRiskLevel("mobileStatusRiskLevel","手机号码状态及在网时长结果风险等级"),
mobileStatusDesc("mobileStatusDesc","手机号码状态及在网时长结果"),
riskRosterRiskLevel("riskRosterRiskLevel","风险名单结果风险等级"),
riskRosterDesc("riskRosterDesc","风险名单结果"),
judicialRiskLevel("judicialRiskLevel","司法风险结果风险等级"),
judicialRiskDesc("judicialRiskDesc","司法风险结果");
private String code; //类型
private String desc; //描述
private PersonAntiFraudDescInfoEnums(String code, String desc){
this.code=code;
this.desc=desc;
}
public String getDesc() {
return desc;
}
public String getCode() {
return this.code;
}
/**
* 根据code 数据库表名的列字段
* @param code
* @return
*/
public static String getValueData(String code){
for(PersonAntiFraudDescInfoEnums data : PersonAntiFraudDescInfoEnums.values()){
if(data.getCode().toLowerCase().equals(code.toLowerCase())){
return data.getDesc();
}
}
return null;
}
}
/**
* 数据库表名和列字段对应关系
*/
public enum RiskType{
risk_000("000","未命中风险名单"),
risk_101("101","疑似欺诈风险"),
risk_102("102","疑似营销套利"),
risk_201("201","疑似身份造假"),
risk_202("202","疑似资料造假"),
risk_203("203","疑似盗号风险"),
risk_301("301","刑事被告"),
risk_302("302","民事被告"),
risk_303("303","司法被执行人"),
risk_304("304","终本案件人员"),
risk_305("305","司法失信人员"),
risk_306("306","行政处罚人员"),
risk_999("999","其他风险");
private String code; //类型
private String desc; //描述
private RiskType(String code, String desc){
this.code=code;
this.desc=desc;
}
public String getDesc() {
return desc;
}
public String getCode() {
return this.code;
}
/**
* 根据code 数据库表名的列字段
* @param code
* @return
*/
public static String getValueData(String code){
for(RiskType data : RiskType.values()){
if(data.getCode().toLowerCase().equals(code.toLowerCase())){
return data.getDesc();
}
}
return "未命中风险名单";
}
}
/**
* 内容开始部分
* @param obj
* @return
*/
public static String createBodyHead(JSONObject obj) throws ParseException {
StringBuilder sb = new StringBuilder();
String bodyTitle = title;
bodyTitle = bodyTitle.replace("reportID", obj.getString("reportID"));
sb.append(bodyTitle);
String bodyQueryConditions = queryConditions;
JSONObject queryConditionsObj = obj.getJSONObject("queryConditionsObj");
bodyQueryConditions = bodyQueryConditions.replace("name", queryConditionsObj.getString("name"));
bodyQueryConditions = bodyQueryConditions.replace("documentNo", queryConditionsObj.getString("documentNo"));
bodyQueryConditions = bodyQueryConditions.replace("unitName", obj.getString("unitName"));
bodyQueryConditions = bodyQueryConditions.replace("queryUserID", obj.getString("queryUserID"));
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
Date birDate = sdf.parse(obj.getString("receiveTime").substring(0, 8));
SimpleDateFormat sdfRes = new SimpleDateFormat("yyyy年MM月dd日");
String birStr = sdfRes.format(birDate);
bodyQueryConditions = bodyQueryConditions.replace("receiveTime", birStr);
sb.append(bodyQueryConditions);
String bodyBContentPafQuery = bodyContentPafQuery;
bodyBContentPafQuery = bodyBContentPafQuery.replace("phone", queryConditionsObj.getString("phone"));
sb.append(bodyBContentPafQuery);
return sb.toString();
}
public static String title = " reportID" +
"</td> \n" +
" </tr> \n" +
" </tbody>\n" +
" </table> </td> \n" +
" </tr> \n" ;
public static String queryConditions =
" <tr> \n" +
" <td> \n" +
" <table class=\"list\"> \n" +
" <tbody>\n" +
" <tr> \n" +
" <td class=\"field\" width=\"14%\">姓名</td> \n" +
" <td width=\"36%\">name</td> \n" +
// " <td width=\"36%\">熊海</td> \n" +
" <td class=\"field\" width=\"14%\">查询时间</td> \n" +
" <td width=\"36%\">receiveTime</td> \n" +
// " <td width=\"36%\">2020年07月28日</td> \n" +
" </tr> \n" +
" <tr> \n" +
" <td class=\"field\">证件号码</td> \n" +
" <td>documentNo</td> \n" +
// " <td>360123*********978</td> \n" +
" <td class=\"field\">操作员</td> \n" +
" <td>queryUserID</td> \n" +
// " <td>apwsqueryn</td> \n" +
" </tr> \n" +
" <tr> \n" +
" <td class=\"field\">查询机构</td> \n" +
" <td colspan=\"3\">unitName</td> \n" +
// " <td colspan=\"3\">安鹏融资租赁(天津)有限公司</td> \n" +
" </tr> \n" +
" </tbody>\n" +
" </table> </td> \n" +
" </tr> \n" ;
//反欺诈附件条件
public static String bodyContentPafQuery =
" <tr> \n" +
" <td> \n" +
" <table class=\"section-title border\" style=\"margin-top: 30px; \"> \n" +
" <tbody>\n" +
" <tr> \n" +
" <td class=\"pole\"><img src=\"image/image_list.png\" /></td> \n" +
" <td>反欺诈分析附加条件</td> \n" +
" </tr> \n" +
" </tbody>\n" +
" </table> </td> \n" +
" </tr> \n" +
" <tr> \n" +
" <td> \n" +
" <table class=\"list\"> \n" +
" <tbody>\n" +
" <tr> \n" +
" <td class=\"field\" width=\"14%\" align=\"left\">手机号码</td> \n" +
" <td width=\"86%\">phone</td> \n" +
" </tr> \n" +
" </tbody>\n" +
" </table> </td> \n" +
" </tr> \n" ;
public static String contentError = "<tr><td class=\"error-msg\">errorMessage</td> </tr>";
public static String contentEmpty = "<tr><tr> <td class=\"no-result-msg\">errorMessage</td> </tr>";
/**
* 反欺诈信息汇总
* @param obj
* @return
*/
private static String createBaseContent(String key, String content, JSONObject obj) throws ParseException {
String bodyContentError = contentError;
String bodyContentEmpty = contentEmpty;
String bodyContent = content;
String subContent = "";
String jsonKey = key;
if("personJudicialSFRiskInfo".equals(key) || "personJudicialXZRiskInfo".equals(key)){
jsonKey = "personJudicialRiskInfo";
}
JSONObject keyObj = obj.getJSONObject(jsonKey);
String errorMessage = "";
if(keyObj.containsKey("errorMessage")){
errorMessage = keyObj.getString("errorMessage");
}
if("3".equals(keyObj.getString("treatResult"))){//系统错误,默认包含细节
if(null == errorMessage || "".equals(errorMessage)){
errorMessage = "系统错误。";
}
bodyContentError = bodyContentError.replace("errorMessage", errorMessage);
subContent = bodyContentError;
}else{//如果包含细节
subContent = createBodyContentDes(key, obj);
}
if(null == subContent || "".equals(subContent.toString())){
subContent = bodyContentEmpty.replace("errorMessage", "根据已提供的查询条件,未能在系统中查得相关信息。");
}
bodyContent = bodyContent.replace("subContent", subContent);
return bodyContent;
}
/**
*
* @param obj
* @return
*/
public static String createBodyContent(JSONObject obj) throws ParseException {
StringBuilder sb = new StringBuilder();
for(PafEnums pe : PafEnums.values()){
String jsonKey = pe.getCode();
if("personJudicialSFRiskInfo".equals(pe.getCode()) || "personJudicialXZRiskInfo".equals(pe.getCode())){
jsonKey = "personJudicialRiskInfo";
}
JSONObject keyObj = obj.getJSONObject(jsonKey);
String treatResult = keyObj.getString("treatResult");
//是否包含细节内容
boolean addContentB = false;
List<String> resKeyArr =
Lists.newArrayList("subReportType", "subReportTypeCost", "treatResult", "treatErrorCode", "errorMessage");
for(String keyRes : keyObj.keySet()){
if(!resKeyArr.contains(keyRes) || "3".equals(treatResult)){
addContentB = true;
}
}
if(addContentB){
String content = createBaseContent(pe.getCode(), pe.getHtmlContent(), obj);
sb.append(content);
}
}
return sb.toString();
}
/**
* 反欺诈信息汇总
* @param obj
* @return
*/
private static String createPafDescContent(String key, JSONObject obj){
String bodyPersonAntiFraudDescInfoContent = personAntiFraudDescInfoContent;
JSONObject subObj = obj.getJSONObject(key);
// TODO: 2020/7/29 增加判断空 antiFraudScore
String antiFraudScore = subObj.getString("antiFraudScore");
bodyPersonAntiFraudDescInfoContent = bodyPersonAntiFraudDescInfoContent.replace("antiFraudScore", subObj.getString("antiFraudScore"));
StringBuilder sbContent = new StringBuilder();
for(PersonAntiFraudDescInfoEnums pe : PersonAntiFraudDescInfoEnums.values()){
if(null != subObj.getString(pe.getCode())
&& !"".equals(subObj.getString(pe.getCode()))){
String subContent = personAntiFraudDescInfoContentItem;
String imgStatus = "image_success";
// TODO: 2020/7/29 如果包含 不正常 高风险 则改为 imgage_error
String result = subObj.getString(pe.getCode());
if("antiFraudScore".equals(pe.getCode())) {
if(Integer.parseInt(result) > 500){
imgStatus = "image_error";
}
}else if("policeCheckDesc".equals(pe.getCode())){
String resPre = subObj.getString("policeCheckRiskLevel");
if(resPre.contains("高风险")){
imgStatus = "image_error";
}else if(resPre.contains("中风险")){
imgStatus = "image_warn";
}
}else if("mobileCheckDesc".equals(pe.getCode())){
String resPre = subObj.getString("mobileCheckRiskLevel");
if(resPre.contains("高风险")){
imgStatus = "image_error";
}else if(resPre.contains("中风险")){
imgStatus = "image_warn";
}
}else if("mobileStatusDesc".equals(pe.getCode())){
String resPre = subObj.getString("mobileStatusRiskLevel");
if(resPre.contains("高风险")){
imgStatus = "image_error";
}else if(resPre.contains("中风险")){
imgStatus = "image_warn";
}
}else if("judicialRiskDesc".equals(pe.getCode())){
String resPre = subObj.getString("judicialRiskLevel");
if(resPre.contains("高风险")){
imgStatus = "image_error";
}else if(resPre.contains("中风险")){
imgStatus = "image_warn";
}
}else if("riskRosterDesc".equals(pe.getCode())){
if(!"未命中风险名单".equals(result)){
imgStatus = "image_error";
}
}
if(result.contains("高风险")){
imgStatus = "image_error";
}
String pafDesc = pe.getDesc() + "" + subObj.getString(pe.getCode());
subContent = subContent.replace("image_status", imgStatus);
subContent = subContent.replace("pafDesc", pafDesc);
sbContent.append(subContent);
}
}
bodyPersonAntiFraudDescInfoContent = bodyPersonAntiFraudDescInfoContent.replace("contentItem", sbContent.toString());
return bodyPersonAntiFraudDescInfoContent;
}
//反欺诈分析综述
public static String personAntiFraudDescInfoContentItem =
" <div> <img src=\"image/image_status.png\" width=\"13\" height=\"13\" /> pafDesc </div> ";
//反欺诈分析综述
public static String personAntiFraudDescInfoContent =
" <tr> \n" +
" <td class=\"field text-center\"> 欺诈风险指数为 <span style=\"color:red;font-size:22px;background: #ccc\">antiFraudScore</span> 分 </td> \n" +
" </tr> \n" +
" <tr> \n" +
" <td> contentItem </td> \n" +
" </tr> \n" ;
//反欺诈分析综述
public static String personAntiFraudDescInfo =
" <tr> \n" +
" <td> \n" +
" <table class=\"section-title border\" style=\"margin-top: 30px; \"> \n" +
" <tbody>\n" +
" <tr> \n" +
" <td class=\"pole\"><img src=\"image/image_list.png\" /></td> \n" +
" <td>反欺诈分析综述</td> \n" +
" </tr> \n" +
" </tbody>\n" +
" </table> </td> \n" +
" </tr> \n" +
" <tr> \n" +
" <td> \n" +
" <table class=\"list\"> \n" +
" <tbody> subContent </tbody>\n" +
" </table> </td> \n" +
" </tr> \n" ;
/**
* 反欺诈指数
* @param obj
* @return
*/
private static String createPersonAntiFraudScoreInfoContent(String key, JSONObject obj){
String bodyPersonAntiFraudScoreInfoContent = personAntiFraudScoreInfoContent;
JSONObject subObj = obj.getJSONObject(key);
bodyPersonAntiFraudScoreInfoContent = bodyPersonAntiFraudScoreInfoContent.replace("riskScore", subObj.getString("riskScore"));
bodyPersonAntiFraudScoreInfoContent = bodyPersonAntiFraudScoreInfoContent.replace("riskLevel", subObj.getString("riskLevel"));
bodyPersonAntiFraudScoreInfoContent = bodyPersonAntiFraudScoreInfoContent.replace("hitTypes", subObj.getString("hitTypes"));
return bodyPersonAntiFraudScoreInfoContent;
}
//反欺诈分析指数
public static String personAntiFraudScoreInfoContent =
"<tr> <td class=\"field text-center\"> 欺诈风险指数为 <span style=\"color:red;font-size:22px;background: #ccc\">riskScore</span> 分 </td> </tr> \n" +
"<tr><td class=\"field text-center\">欺诈风险等级为 <span style=\"color:red;font-size:22px;background: #ccc\">riskLevel</span> </td> </tr> \n" +
"<tr><td class=\"field text-center\"> 欺诈风险标签为 <span style=\"color:red;font-size:22px;background: #ccc\">hitTypes</span> </td> </tr> \n" ;
//反欺诈分析指数【图片删掉】
public static String personAntiFraudScoreInfo =
" <tr> \n" +
" <td> \n" +
" <table class=\"section-title border\" style=\"margin-top: 30px; \"> \n" +
" <tbody>\n" +
" <tr> \n" +
" <td class=\"pole\"><img src=\"image/image_list.png\" /></td> \n" +
" <td>欺诈风险指数</td> \n" +
" </tr> \n" +
" </tbody>\n" +
" </table> </td> \n" +
" </tr> \n" +
" <tr> \n" +
" <td> \n" +
" <table width=\"100%\" cellspacing=\"0\" cellpadding=\"0\" border=\"0\"> \n" +
" <tbody>\n" +
" subContent </tbody>\n" +
" </table> </td> \n" +
" </tr> \n" ;
/**
* 证件号码校验信息
* @param obj
* @return
*/
private static String createPersonBaseInfoContent(String key, JSONObject obj) throws ParseException {
String bodyPersonBaseInfoContent = personBaseInfoContent;
JSONObject subObj = obj.getJSONObject(key);
bodyPersonBaseInfoContent = bodyPersonBaseInfoContent.replace("docNo", subObj.getString("docNo"));
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
Date birDate = sdf.parse(subObj.getString("birthday"));
SimpleDateFormat sdfRes = new SimpleDateFormat("yyyy年MM月dd日");
String birStr = sdfRes.format(birDate);
bodyPersonBaseInfoContent = bodyPersonBaseInfoContent.replace("birthday", birStr);
String genderId = subObj.getString("genderID");
if("1".equals(genderId)){
genderId = "";
}else if("2".equals(genderId)){
genderId = "";
}else if("3".equals(genderId)){
genderId = "不详";
}
bodyPersonBaseInfoContent = bodyPersonBaseInfoContent.replace("genderID", genderId);
bodyPersonBaseInfoContent = bodyPersonBaseInfoContent.replace("age", subObj.getString("age"));
bodyPersonBaseInfoContent = bodyPersonBaseInfoContent.replace("originalAddress", subObj.getString("originalAddress"));
bodyPersonBaseInfoContent = bodyPersonBaseInfoContent.replace("verifyResult", "1".equals(subObj.getString("verifyResult")) ? "通过" : "未通过");
return bodyPersonBaseInfoContent;
}
//证件号码校验信息
public static String personBaseInfoContent =
" <tr> \n" +
" <td class=\"field\" width=\"14%\">证件号码</td> \n" +
" <td width=\"36%\">docNo</td> \n" +
" <td class=\"field\" width=\"14%\">出生日期</td> \n" +
" <td width=\"36%\">birthday</td> \n" +
" </tr> \n" +
" <tr> \n" +
" <td class=\"field\">性别</td> \n" +
" <td>genderID</td> \n" +
" <td class=\"field\">年龄</td> \n" +
" <td>age</td> \n" +
" </tr> \n" +
" <tr> \n" +
" <td class=\"field\">原始发证地区</td> \n" +
" <td colspan=\"3\">originalAddress</td> \n" +
" </tr> \n" +
" <tr> \n" +
" <td class=\"field\">证件校验结果</td> \n" +
" <td colspan=\"3\"> verifyResult </td> \n" +
" </tr> \n" ;
//证件号码校验信息
public static String personBaseInfo =
" <tr> \n" +
" <td> \n" +
" <table class=\"section-title border\" style=\"margin-top: 30px; \"> \n" +
" <tbody>\n" +
" <tr> \n" +
" <td class=\"pole\"><img src=\"image/image_list.png\" /></td> \n" +
" <td>证件号码校验信息</td> \n" +
" </tr> \n" +
" </tbody>\n" +
" </table> </td> \n" +
" </tr> \n" +
" <tr> \n" +
" <td> \n" +
" <!--查得-->\n" +
" <table class=\"list\"> \n" +
" <!--查得--> \n" +
" <tbody>\n" +
" subContent </tbody>\n" +
" </table> </td> \n" +
" </tr> \n";
/**
* 证件号码校验信息
* @param obj
* @return
*/
private static String createPoliceCheckInfoContent(String key, JSONObject obj){
StringBuilder sb = new StringBuilder();
JSONObject arrObj = obj.getJSONObject(key);
JSONArray subArr = arrObj.getJSONArray("item");
for(int i = 0; i < subArr.size(); i++){
JSONObject subObj = subArr.getJSONObject(i);
String bodyPoliceCheckInfoContent = policeCheckInfoContent;
bodyPoliceCheckInfoContent = bodyPoliceCheckInfoContent.replace("result",
"1".equals(subObj.getString("result")) ? "一致" : "不一致");
sb.append(bodyPoliceCheckInfoContent);
}
return sb.toString();
}
//证件号码认证结果
public static String policeCheckInfoContent =
" <tr> \n" +
" <td width=\"20%\" class=\"field\">身份认证结果</td> \n" +
" <td width=\"80%\"> <span class=\"green\">result</span> </td> \n" +
" </tr> \n" ;
//证件号码认证结果
public static String policeCheckInfo =
" <tr> \n" +
" <td> \n" +
" <table class=\"section-title border\" style=\"margin-top: 30px; \"> \n" +
" <tbody>\n" +
" <tr> \n" +
" <td class=\"pole\"><img src=\"image/image_list.png\" /></td> \n" +
" <td>身份认证</td> \n" +
" </tr> \n" +
" </tbody>\n" +
" </table> </td> \n" +
" </tr> \n" +
" <tr> \n" +
" <td> \n" +
" <table class=\"list\"> \n" +
" <tbody>\n" +
" subContent </tbody>\n" +
" </table> </td> \n" +
" </tr> \n";
/**
* 手机号码校验信息结果
* @param obj
* @return
*/
private static String createMobileCheckInfoContent(String key, JSONObject obj){
StringBuilder sb = new StringBuilder();
JSONObject arrObj = obj.getJSONObject(key);
JSONArray subArr = arrObj.getJSONArray("item");
for(int i = 0; i < subArr.size(); i++){
JSONObject subObj = subArr.getJSONObject(i);
String bodyMobileCheckInfoContent = mobileCheckInfoContent;
bodyMobileCheckInfoContent = bodyMobileCheckInfoContent.replace("checkResult", subObj.getString("checkResult"));
bodyMobileCheckInfoContent = bodyMobileCheckInfoContent.replace("areaInfo", subObj.getString("areaInfo"));
bodyMobileCheckInfoContent = bodyMobileCheckInfoContent.replace("operator", MobileOperatorEnums.getValueData(subObj.getString("operator")));
sb.append(bodyMobileCheckInfoContent);
}
return sb.toString();
}
//手机号码校验信息结果
public static String mobileCheckInfoContent =
" <tr> \n" +
" <td width=\"20%\" class=\"field\">运营商名称</td> \n" +
" <td width=\"80%\">operator</td> \n" +
" </tr> \n" +
" <tr> \n" +
" <td class=\"field\">手机号码归属地</td> \n" +
" <td>areaInfo</td> \n" +
" </tr> \n" +
" <tr> \n" +
" <td class=\"field\">手机认证结果</td> \n" +
" <td> <span style=\"color:green\">checkResult</span> </td> \n" +
" </tr> \n" ;
//手机号码校验信息结果
public static String mobileCheckInfo =
" <tr> \n" +
" <td> \n" +
" <table class=\"section-title border\" style=\"margin-top: 30px; \"> \n" +
" <tbody>\n" +
" <tr> \n" +
" <td class=\"pole\"><img src=\"image/image_list.png\" /></td> \n" +
" <td>手机认证</td> \n" +
" </tr> \n" +
" </tbody>\n" +
" </table> </td> \n" +
" </tr> \n" +
" <tr> \n" +
" <td> \n" +
" <table class=\"list\"> \n" +
" <tbody>\n" +
" subContent </tbody>\n" +
" </table> </td> \n" +
" </tr> \n";
/**
* 手机号码在线时长
* @param obj
* @return
*/
private static String createMobileStatusInfoContent(String key, JSONObject obj){
StringBuilder sb = new StringBuilder();
JSONObject arrObj = obj.getJSONObject(key);
JSONArray subArr = arrObj.getJSONArray("item");
for(int i = 0; i < subArr.size(); i++){
JSONObject subObj = subArr.getJSONObject(i);
String bodyMobileStatusInfoContent = mobileStatusInfoContent;
bodyMobileStatusInfoContent = bodyMobileStatusInfoContent.replace("timeLength", MobileTimeLengthEnums.getValueData(subObj.getString("timeLength")));
bodyMobileStatusInfoContent = bodyMobileStatusInfoContent.replace("phoneStatus", MobileStsEnums.getValueData(subObj.getString("phoneStatus")));
sb.append(bodyMobileStatusInfoContent);
}
return sb.toString();
}
//手机号码在线时长
public static String mobileStatusInfoContent =
" <tr> \n" +
" <td width=\"20%\" class=\"field\">手机号码状态</td> \n" +
" <td width=\"80%\">phoneStatus</td> \n" +
" </tr> \n" +
" <tr> \n" +
" <td class=\"field\">手机号码在网时长</td> \n" +
" <td>timeLength</td> \n" +
" </tr> \n" ;
//手机号码在线时长
public static String mobileStatusInfo =
" <tr> \n" +
" <td> \n" +
" <table class=\"section-title border\" style=\"margin-top: 30px; \"> \n" +
" <tbody>\n" +
" <tr> \n" +
" <td class=\"pole\"><img src=\"image/image_list.png\" /></td> \n" +
" <td>手机号码状态时长</td> \n" +
" </tr> \n" +
" </tbody>\n" +
" </table> </td> \n" +
" </tr> \n" +
" <tr> \n" +
" <td> \n" +
" <table class=\"list\"> \n" +
" <tbody>\n" +
" subContent </tbody>\n" +
" </table> </td> \n" +
" </tr> \n";
/**
* 风险名单命中结果
* @param obj
* @return
*/
private static String createPersonRiskRosterInfoContent(String key, JSONObject obj){
String bodyPersonRiskRosterInfoContent = personRiskRosterInfoContent;
JSONObject subObj = obj.getJSONObject(key);
StringBuilder sb = new StringBuilder();
// TODO: 2020/7/29 判断为空
String[] riskTypes = subObj.getString("riskTypes").split(",");
for(String riskType : riskTypes){
sb.append(RiskType.getValueData(riskType) + ", ");
}
String risk = sb.toString();
risk = risk.substring(0, risk.length() - 2);
bodyPersonRiskRosterInfoContent = bodyPersonRiskRosterInfoContent.replace("riskTypes", risk);
return bodyPersonRiskRosterInfoContent;
}
//风险名单命中结果
public static String personRiskRosterInfoContent =
" <tr> \n" +
" <td width=\"20%\" class=\"field text-center\">命中风险类型</td> \n" +
" <td width=\"80%\">riskTypes</td> \n" +
" </tr> \n" ;
//风险名单命中结果
public static String personRiskRosterInfo =
" <tr> \n" +
" <td> \n" +
" <table class=\"section-title border\" style=\"margin-top: 30px; \"> \n" +
" <tbody>\n" +
" <tr> \n" +
" <td class=\"pole\"><img src=\"image/image_list.png\" /></td> \n" +
" <td>风险名单</td> \n" +
" </tr> \n" +
" </tbody>\n" +
" </table> </td> \n" +
" </tr> \n" +
" <tr> \n" +
" <td> \n" +
" <table class=\"list\"> \n" +
" <tbody>\n" +
" subContent </tbody>\n" +
" </table> </td> \n" +
" </tr> \n";
/**
* 风险名单命中结果
* @param obj
* @return
*/
private static String createPersonJudicialSFRiskInfoContent(String key, JSONObject obj){
String bodyPersonJudicialRiskInfoContentSFItem = personJudicialRiskInfoContent;
String tail = "";
//obj转换
JSONObject resObj = new JSONObject();
JSONObject civilCaseCount = new JSONObject();
JSONObject criminalCaseCount = new JSONObject();
JSONObject judicialCount = new JSONObject();
JSONObject endCaseCount = new JSONObject();
JSONObject breakFaithCount = new JSONObject();
JSONObject judicialTotalCount = new JSONObject();
resObj.put("civilCaseCount", civilCaseCount);
resObj.put("criminalCaseCount", criminalCaseCount);
resObj.put("judicialCount", judicialCount);
resObj.put("endCaseCount", endCaseCount);
resObj.put("breakFaithCount", breakFaithCount);
resObj.put("judicialTotalCount", judicialTotalCount);
JSONObject subObj = obj.getJSONObject("personJudicialRiskInfo");
JSONArray subArr = subObj.getJSONArray("item");
for(int i = 0; i < subArr.size(); i++){
JSONObject subJson = subArr.getJSONObject(i);
String resKey = JudicialRiskTimeLengthEnums.getValueData(subJson.getString("timePeriod"));
for(String subKey : subJson.keySet()){
for(String resSubKey : resObj.keySet()){
if(subKey.equals(resSubKey)){
JSONObject resSubObj = resObj.getJSONObject(resSubKey);
resSubObj.put(resKey, subJson.getString(subKey));
}
}
}
}
StringBuilder sb = new StringBuilder();
//循环
for(String resKey : resObj.keySet()){
JSONObject resJson = resObj.getJSONObject(resKey);
String content = personJudicialRiskInfoContentSFItem;
content = content.replace("judicialSFType", JudicialSFCountTypeEnums.getValueData(resKey));
for(JudicialRiskTimeLengthEnums je : JudicialRiskTimeLengthEnums.values()){
content = content.replace(je.getDesc(), resJson.getString(je.getDesc()));
}
if("judicialTotalCount".equals(resKey)){//合计放在末尾
tail = content;
}else {
sb.append(content);
}
}
return bodyPersonJudicialRiskInfoContentSFItem + sb.toString() + tail;
}
/**
* 风险名单命中结果
* @param obj
* @return
*/
private static String createPersonJudicialXZRiskInfoContent(String key, JSONObject obj){
String bodyPersonJudicialRiskInfoContentXZItem = personJudicialRiskInfoContent;
String tail = "";
//obj转换
JSONObject resObj = new JSONObject();
JSONObject taxPunishCount = new JSONObject();
JSONObject marketPunishCount = new JSONObject();
JSONObject customsPunishCount = new JSONObject();
JSONObject environmentPunishCount = new JSONObject();
JSONObject otherPunishCount = new JSONObject();
JSONObject punishTotalCount = new JSONObject();
resObj.put("taxPunishCount", taxPunishCount);
resObj.put("marketPunishCount", marketPunishCount);
resObj.put("customsPunishCount", customsPunishCount);
resObj.put("environmentPunishCount", environmentPunishCount);
resObj.put("otherPunishCount", otherPunishCount);
resObj.put("punishTotalCount", punishTotalCount);
JSONObject subObj = obj.getJSONObject("personJudicialRiskInfo");
JSONArray subArr = subObj.getJSONArray("item");
for(int i = 0; i < subArr.size(); i++){
JSONObject subJson = subArr.getJSONObject(i);
String resKey = JudicialRiskTimeLengthEnums.getValueData(subJson.getString("timePeriod"));
for(String subKey : subJson.keySet()){
for(String resSubKey : resObj.keySet()){
if(subKey.equals(resSubKey)){
JSONObject resSubObj = resObj.getJSONObject(resSubKey);
resSubObj.put(resKey, subJson.getString(subKey));
}
}
}
}
StringBuilder sb = new StringBuilder();
System.out.println("resObj="+resObj.toJSONString());
//循环
for(String resKey : resObj.keySet()){
JSONObject resJson = resObj.getJSONObject(resKey);
String content = personJudicialRiskInfoContentXZItem;
content = content.replace("judicialXZType", JudicialXZCountTypeEnums.getValueData(resKey));
for(JudicialRiskTimeLengthEnums je : JudicialRiskTimeLengthEnums.values()){
content = content.replace(je.getDesc(), resJson.getString(je.getDesc()));
}
if("punishTotalCount".equals(resKey)){//合计放在末尾
tail = content;
}else {
sb.append(content);
}
}
return bodyPersonJudicialRiskInfoContentXZItem + sb.toString() + tail;
}
/**
* 内容生成
* @param key
* @param obj
* @return
*/
private static String createBodyContentDes(String key, JSONObject obj) throws ParseException {
if("personAntiFraudDescInfo".equals(key)){
return createPafDescContent(key, obj);
}else if("personAntiFraudScoreInfo".equals(key)){
return createPersonAntiFraudScoreInfoContent(key, obj);
}else if("personBaseInfo".equals(key)){//证件号码校验信息
return createPersonBaseInfoContent(key, obj);
}else if("policeCheckInfo".equals(key)){
return createPoliceCheckInfoContent(key, obj);
}else if("mobileCheckInfo".equals(key)){
return createMobileCheckInfoContent(key, obj);
}else if("mobileStatusInfo".equals(key)){
return createMobileStatusInfoContent(key, obj);
}else if("personRiskRosterInfo".equals(key)){
return createPersonRiskRosterInfoContent(key, obj);
}else if("personJudicialSFRiskInfo".equals(key)){
return createPersonJudicialSFRiskInfoContent(key, obj);
}else if("personJudicialXZRiskInfo".equals(key)){
return createPersonJudicialXZRiskInfoContent(key, obj);
}
return null;
}
public static String personJudicialRiskInfoContentSFItem =
" <tr> \n" +
" <td align=\"center\">judicialSFType</td> \n" +
" <td align=\"center\">oneYearCount</td> \n" +
" <td align=\"center\">twoYearCount</td> \n" +
" <td align=\"center\">fiveYearCount</td> \n" +
" <td align=\"center\">historyYearCount</td> \n" +
" </tr> \n";
public static String personJudicialRiskInfoContentXZItem =
" <tr> \n" +
" <td align=\"center\">judicialXZType</td> \n" +
" <td align=\"center\">oneYearCount</td> \n" +
" <td align=\"center\">twoYearCount</td> \n" +
" <td align=\"center\">fiveYearCount</td> \n" +
" <td align=\"center\">historyYearCount</td> \n" +
" </tr> \n";
public static String personJudicialRiskInfoContent =
" <tr> \n" +
" <th class=\"field text-center\" width=\"40%\">风险类型</th> \n" +
" <th class=\"field text-center\" width=\"15%\">近1年</th> \n" +
" <th class=\"field text-center\" width=\"15%\">近2年</th> \n" +
" <th class=\"field text-center\" width=\"15%\">近5年</th> \n" +
" <th class=\"field text-center\" width=\"15%\">历史</th> \n" +
" </tr> \n" ;
public static String personJudicialSFRiskInfo =
" <tr> \n" +
" <td> \n" +
" <table class=\"section-title border\" style=\"margin-top: 30px; \"> \n" +
" <tbody>\n" +
" <tr> \n" +
" <td class=\"pole\"><img src=\"image/image_list.png\" /></td> \n" +
" <td>司法风险汇总</td> \n" +
" </tr> \n" +
" </tbody>\n" +
" </table> </td> \n" +
" </tr> \n" +
" <tr> \n" +
" <td> \n" +
" <table class=\"section-title-black\" style=\"margin-top: 10px; \"> \n" +
" <tbody>\n" +
" <tr> \n" +
" <td>司法涉诉</td> \n" +
" </tr> \n" +
" </tbody>\n" +
" </table> </td> \n" +
" </tr> \n" +
" <tr> \n" +
" <td> \n" +
" <table class=\"list\"> \n" +
" <tbody>\n" +
" subContent </tbody>\n" +
" </table> </td> \n" +
" </tr> \n" ;
public static String personJudicialXZRiskInfo =
" <tr> \n" +
" <td> \n" +
" <table class=\"section-title-black\" style=\"margin-top: 10px; \"> \n" +
" <tbody>\n" +
" <tr> \n" +
" <td>行政处罚</td> \n" +
" </tr> \n" +
" </tbody>\n" +
" </table> </td> \n" +
" </tr> \n" +
" <tr> \n" +
" <td> \n" +
" <table class=\"list\"> \n" +
" <tbody>\n" +
" subContent </tbody>\n" +
" </table> </td> \n" +
" </tr> ";
}