parent
28781d2597
commit
26e9c2c121
@ -0,0 +1,520 @@ |
||||
package com.sinosoft.lis.httpservice.clm; |
||||
|
||||
import com.alibaba.fastjson.JSONArray; |
||||
import com.alibaba.fastjson.JSONObject; |
||||
import com.sinosoft.lis.db.*; |
||||
import com.sinosoft.lis.g_claim.LLClaimCalPortalBL; |
||||
import com.sinosoft.lis.httpservice.bl.callcenter.CallCenterService; |
||||
import com.sinosoft.lis.httpservice.core.bean.callcenter.request.CallCenterRequestHead; |
||||
import com.sinosoft.lis.i18n.I18nMessage; |
||||
import com.sinosoft.lis.pubfun.GlobalInput; |
||||
import com.sinosoft.lis.schema.*; |
||||
import com.sinosoft.lis.sql.repository.LLRegisterSQL; |
||||
import com.sinosoft.lis.httpservice.sql.clm.LLClaimCalApiSQL; |
||||
import com.sinosoft.lis.vschema.*; |
||||
import com.sinosoft.persistence.SQLProxy; |
||||
import com.sinosoft.utility.*; |
||||
import org.apache.commons.lang.StringUtils; |
||||
import org.slf4j.Logger; |
||||
import org.slf4j.LoggerFactory; |
||||
|
||||
/** |
||||
* 1000000250 - 理算对外API接口 |
||||
* <p> |
||||
* 仅传入赔案号(RgtNo),自动触发完整理算流程, |
||||
* 返回按 保单→险种→给付责任 三层结构的详细理算结果。 |
||||
* </p> |
||||
*/ |
||||
public class LLClaimCalApiBL implements CallCenterService<JSONObject> { |
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(LLClaimCalApiBL.class); |
||||
|
||||
public CErrors mErrors = new CErrors(); |
||||
private String result = "Y"; |
||||
private JSONObject mJsonObject = new JSONObject(); |
||||
|
||||
// 入参
|
||||
private String RgtNo = ""; |
||||
private String Operator = ""; |
||||
|
||||
// 从LLRegister查出的关键信息
|
||||
private String GrpRgtNo = ""; |
||||
private String CustomerNo = ""; |
||||
private String ClmState = ""; |
||||
private String CustomerName = ""; |
||||
private String MngCom = ""; |
||||
|
||||
// SQL接口
|
||||
private final LLClaimCalApiSQL tSQL = SQLProxy.getInstance(LLClaimCalApiSQL.class); |
||||
|
||||
@Override |
||||
public JSONObject submitData(CallCenterRequestHead head, JSONObject inputData) { |
||||
|
||||
if (head != null && StringUtils.isNotBlank(head.getOperator())) { |
||||
Operator = head.getOperator(); |
||||
} else { |
||||
Operator = "API"; |
||||
} |
||||
|
||||
// 数据获取
|
||||
if (!getInputData(inputData)) { |
||||
buildError("getInputData", new I18nMessage("获取数据失败!", "")); |
||||
result = "N"; |
||||
return null; |
||||
} |
||||
|
||||
// 数据校验
|
||||
if (!checkData()) { |
||||
result = "N"; |
||||
return null; |
||||
} |
||||
|
||||
// 数据处理:执行理算 + 组装结果
|
||||
if (!dealData()) { |
||||
result = "N"; |
||||
return null; |
||||
} |
||||
|
||||
result = "Y"; |
||||
return mJsonObject; |
||||
} |
||||
|
||||
/** |
||||
* 数据获取 |
||||
*/ |
||||
private boolean getInputData(JSONObject inputData) { |
||||
RgtNo = inputData.getString("RgtNo"); |
||||
if (StringUtils.isBlank(RgtNo)) { |
||||
buildError("getInputData", new I18nMessage("赔案号不能为空!", "")); |
||||
return false; |
||||
} |
||||
return true; |
||||
} |
||||
|
||||
/** |
||||
* 前置校验(与LLClaimCalCheckBL保持一致) |
||||
*/ |
||||
private boolean checkData() { |
||||
|
||||
// 1. 查询LLRegister获取ClmState
|
||||
String clmState = SQLProxy.getInstance(LLRegisterSQL.class).findClmStateByRgtNo(RgtNo); |
||||
if (StringUtils.isBlank(clmState)) { |
||||
buildError("checkData", new I18nMessage("未查询到立案信息,赔案号=" + RgtNo, "")); |
||||
return false; |
||||
} |
||||
|
||||
// 2. 校验ClmState必须为20或30
|
||||
if (!"20".equals(clmState) && !"30".equals(clmState)) { |
||||
buildError("checkData", new I18nMessage("案件状态不满足理算条件,当前状态=" + clmState + "(仅接受20-理算/30-审核)", "")); |
||||
return false; |
||||
} |
||||
ClmState = clmState; |
||||
|
||||
// 3. 校验工作流节点ActivityId(与LLClaimCalCheckBL.checkRegisterInfo一致)
|
||||
String activityId = "20".equals(ClmState) ? "1800501003" : "1800501005"; |
||||
String activityExists = tSQL.existsActivityByRgtNo(RgtNo, activityId); |
||||
if (StringUtils.isBlank(activityExists)) { |
||||
buildError("checkData", new I18nMessage("赔案号" + RgtNo + "不在正确的理算/审核工作流节点(ActivityId=" + activityId + "),无法理算", "")); |
||||
return false; |
||||
} |
||||
|
||||
// 4. 查询完整的LLRegister信息
|
||||
LLRegisterDB tLLRegisterDB = new LLRegisterDB(); |
||||
tLLRegisterDB.setRgtNo(RgtNo); |
||||
LLRegisterSet tLLRegisterSet = tLLRegisterDB.query(); |
||||
if (tLLRegisterSet == null || tLLRegisterSet.size() == 0) { |
||||
buildError("checkData", new I18nMessage("查询立案信息失败,赔案号=" + RgtNo, "")); |
||||
return false; |
||||
} |
||||
LLRegisterSchema tLLRegisterSchema = tLLRegisterSet.get(1); |
||||
GrpRgtNo = tLLRegisterSchema.getGrpRgtNo(); |
||||
CustomerNo = tLLRegisterSchema.getCustomerNo(); |
||||
CustomerName = tLLRegisterSchema.getCustomerName(); |
||||
MngCom = tLLRegisterSchema.getMngCom(); |
||||
|
||||
if (StringUtils.isBlank(GrpRgtNo)) { |
||||
buildError("checkData", new I18nMessage("未查询到团体立案信息,赔案号=" + RgtNo, "")); |
||||
return false; |
||||
} |
||||
|
||||
// 5. 校验LLGrpRegister存在
|
||||
LLGrpRegisterDB tLLGrpRegisterDB = new LLGrpRegisterDB(); |
||||
tLLGrpRegisterDB.setRgtNo(GrpRgtNo); |
||||
if (!tLLGrpRegisterDB.getInfo()) { |
||||
buildError("checkData", new I18nMessage("查询团体立案信息失败,团体赔案号=" + GrpRgtNo, "")); |
||||
return false; |
||||
} |
||||
|
||||
// 6. 校验LLCaseDuty存在记录(按RgtNo+CustomerNo,与LLClaimCalCheckBL.checkRegisterInfo一致)
|
||||
String caseDutyExists = tSQL.existsLLCaseDutyByRgtNoAndCustomerNo(RgtNo, CustomerNo); |
||||
if (StringUtils.isBlank(caseDutyExists)) { |
||||
buildError("checkData", new I18nMessage("该赔案下的事件没有与责任关联(LLCaseDuty无记录),无法进行理算", "")); |
||||
return false; |
||||
} |
||||
|
||||
return true; |
||||
} |
||||
|
||||
/** |
||||
* 业务处理:执行理算 + 组装返回结果 |
||||
*/ |
||||
private boolean dealData() { |
||||
|
||||
logger.debug("===== 理算API开始执行,赔案号:{} =====", RgtNo); |
||||
|
||||
// 幂等检查:如果已存在理算结果,记录日志提示(理算引擎会先删除旧数据再重算)
|
||||
String existingClaim = tSQL.existsLLClaimByClmNo(RgtNo); |
||||
if (StringUtils.isNotBlank(existingClaim)) { |
||||
logger.warn("赔案号{}已存在理算结果,本次将清空旧数据并重新理算", RgtNo); |
||||
} |
||||
|
||||
// ========== 第一步:构建理算入参 ==========
|
||||
GlobalInput tGI = new GlobalInput(); |
||||
tGI.Operator = Operator; |
||||
tGI.ManageCom = StringUtils.isNotBlank(MngCom) ? MngCom : ""; |
||||
tGI.ComCode = StringUtils.isNotBlank(MngCom) && MngCom.length() >= 6 ? MngCom.substring(0, 6) : ""; |
||||
|
||||
TransferData tTransferData = new TransferData(); |
||||
tTransferData.setNameAndValue("GrpRgtNo", GrpRgtNo); |
||||
tTransferData.setNameAndValue("RgtNo", RgtNo); |
||||
tTransferData.setNameAndValue("ClmState", ClmState); |
||||
|
||||
VData tVData = new VData(); |
||||
tVData.add(tGI); |
||||
tVData.add(tTransferData); |
||||
|
||||
// ========== 第二步:调用理算引擎 ==========
|
||||
LLClaimCalPortalBL tLLClaimCalPortalBL = new LLClaimCalPortalBL(); |
||||
if (!tLLClaimCalPortalBL.submitData(tVData, "P")) { |
||||
String errMsg = tLLClaimCalPortalBL.getErrors().getLastError(); |
||||
logger.debug("===== 理算API执行失败,赔案号:{},错误:{} =====", RgtNo, errMsg); |
||||
this.mErrors.copyAllErrors(tLLClaimCalPortalBL.getErrors()); |
||||
return false; |
||||
} |
||||
|
||||
logger.debug("===== 理算引擎执行成功,开始组装返回结果 ====="); |
||||
|
||||
// ========== 第三步:查询理算结果表,组装三层结构 ==========
|
||||
if (!buildResult()) { |
||||
return false; |
||||
} |
||||
|
||||
return true; |
||||
} |
||||
|
||||
/** |
||||
* 查询理算结果表,组装 保单→险种→给付责任 三层结构JSON |
||||
*/ |
||||
private boolean buildResult() { |
||||
|
||||
try { |
||||
// ---------- 案件汇总层:LLClaim ----------
|
||||
LLClaimDB tLLClaimDB = new LLClaimDB(); |
||||
tLLClaimDB.setClmNo(RgtNo); |
||||
LLClaimSet tLLClaimSet = tLLClaimDB.query(); |
||||
if (tLLClaimSet == null || tLLClaimSet.size() == 0) { |
||||
buildError("buildResult", new I18nMessage("理算完成但未查询到LLClaim结果数据", "")); |
||||
return false; |
||||
} |
||||
LLClaimSchema tLLClaimSchema = tLLClaimSet.get(1); |
||||
|
||||
mJsonObject.put("RgtNo", RgtNo); |
||||
mJsonObject.put("GrpRgtNo", GrpRgtNo); |
||||
mJsonObject.put("CustomerNo", CustomerNo); |
||||
mJsonObject.put("CustomerName", CustomerName != null ? CustomerName : ""); |
||||
mJsonObject.put("ClmState", ClmState); |
||||
mJsonObject.put("ClmStateDesc", getClmStateDesc(ClmState)); |
||||
mJsonObject.put("CaseNo", tLLClaimSchema.getCaseNo()); |
||||
mJsonObject.put("AccidentDate", ""); |
||||
mJsonObject.put("TotalStandPay", tLLClaimSchema.getStandPay()); |
||||
mJsonObject.put("TotalRealPay", tLLClaimSchema.getRealPay()); |
||||
mJsonObject.put("TotalDeclinePay", tLLClaimSchema.getDeclinePay()); |
||||
mJsonObject.put("GiveType", tLLClaimSchema.getGiveType()); |
||||
String giveTypeDesc = tLLClaimSchema.getGiveTypeDesc(); |
||||
if (StringUtils.isBlank(giveTypeDesc) && StringUtils.isNotBlank(tLLClaimSchema.getGiveType())) { |
||||
giveTypeDesc = nullToEmpty(tSQL.findGiveTypeDescByGiveType(tLLClaimSchema.getGiveType())); |
||||
} |
||||
mJsonObject.put("GiveTypeDesc", nullToEmpty(giveTypeDesc)); |
||||
|
||||
// 从LLCase获取事故日期
|
||||
LLCaseDB tLLCaseDB = new LLCaseDB(); |
||||
tLLCaseDB.setRgtNo(RgtNo); |
||||
tLLCaseDB.setCustomerNo(CustomerNo); |
||||
LLCaseSet tLLCaseSet = tLLCaseDB.query(); |
||||
if (tLLCaseSet != null && tLLCaseSet.size() > 0) { |
||||
mJsonObject.put("CaseNo", tLLCaseSet.get(1).getCaseNo()); |
||||
mJsonObject.put("AccidentDate", tLLCaseSet.get(1).getAccidentDate1()); |
||||
} |
||||
|
||||
// ---------- 保单/险种层:LLClaimPolicy ----------
|
||||
LLClaimPolicyDB tLLClaimPolicyDB = new LLClaimPolicyDB(); |
||||
tLLClaimPolicyDB.setClmNo(RgtNo); |
||||
LLClaimPolicySet tLLClaimPolicySet = tLLClaimPolicyDB.query(); |
||||
|
||||
JSONArray claimDetailsArray = new JSONArray(); |
||||
int totalPolicies = 0; |
||||
|
||||
if (tLLClaimPolicySet != null && tLLClaimPolicySet.size() > 0) { |
||||
totalPolicies = tLLClaimPolicySet.size(); |
||||
for (int i = 1; i <= tLLClaimPolicySet.size(); i++) { |
||||
LLClaimPolicySchema tPolicy = tLLClaimPolicySet.get(i); |
||||
JSONObject policyObj = new JSONObject(true); |
||||
policyObj.put("ContNo", nullToEmpty(tPolicy.getContNo())); |
||||
policyObj.put("GrpContNo", nullToEmpty(tPolicy.getGrpContNo())); |
||||
policyObj.put("PolNo", nullToEmpty(tPolicy.getPolNo())); |
||||
policyObj.put("InsuredNo", nullToEmpty(tPolicy.getInsuredNo())); |
||||
policyObj.put("InsuredName", nullToEmpty(tPolicy.getInsuredName())); |
||||
policyObj.put("RiskCode", nullToEmpty(tPolicy.getRiskCode())); |
||||
// 险种名称翻译
|
||||
String riskName = nullToEmpty(tSQL.findRiskNameByRiskCode(tPolicy.getRiskCode())); |
||||
policyObj.put("RiskName", riskName); |
||||
policyObj.put("RiskVer", nullToEmpty(tPolicy.getRiskVer())); |
||||
policyObj.put("KindCode", nullToEmpty(tPolicy.getKindCode())); |
||||
policyObj.put("PolState", nullToEmpty(tPolicy.getPolState())); |
||||
policyObj.put("PolStateDesc", "2".equals(tPolicy.getPolState()) ? "有效" : nullToEmpty(tPolicy.getPolState())); |
||||
policyObj.put("ClmState", nullToEmpty(tPolicy.getClmState())); |
||||
policyObj.put("StandPay", tPolicy.getStandPay()); |
||||
policyObj.put("RealPay", tPolicy.getRealPay()); |
||||
policyObj.put("GiveType", nullToEmpty(tPolicy.getGiveType())); |
||||
policyObj.put("GiveTypeDesc", nullToEmpty(tPolicy.getGiveTypeDesc())); |
||||
policyObj.put("GiveReason", nullToEmpty(tPolicy.getGiveReason())); |
||||
policyObj.put("PayType", nullToEmpty(tPolicy.getPayType())); |
||||
policyObj.put("PreGiveAmnt", tPolicy.getPreGiveAmnt()); |
||||
policyObj.put("SelfGiveAmnt", tPolicy.getSelfGiveAmnt()); |
||||
policyObj.put("RefuseAmnt", tPolicy.getRefuseAmnt()); |
||||
policyObj.put("ApproveAmnt", tPolicy.getApproveAmnt()); |
||||
policyObj.put("AgreeAmnt", tPolicy.getAgreeAmnt()); |
||||
|
||||
// ---------- 给付责任层:LLClaimDetail(按ClmNo+PolNo+RiskCode+RiskVer关联) ----------
|
||||
LLClaimDetailDB tLLClaimDetailDB = new LLClaimDetailDB(); |
||||
tLLClaimDetailDB.setClmNo(RgtNo); |
||||
tLLClaimDetailDB.setPolNo(tPolicy.getPolNo()); |
||||
LLClaimDetailSet tLLClaimDetailSet = tLLClaimDetailDB.query(); |
||||
|
||||
JSONArray dutyDetailsArray = new JSONArray(); |
||||
if (tLLClaimDetailSet != null && tLLClaimDetailSet.size() > 0) { |
||||
for (int j = 1; j <= tLLClaimDetailSet.size(); j++) { |
||||
LLClaimDetailSchema tDetail = tLLClaimDetailSet.get(j); |
||||
// 按RiskCode+RiskVer匹配,避免混淆不同版本的险种
|
||||
if (!nullToEmpty(tPolicy.getRiskCode()).equals(nullToEmpty(tDetail.getRiskCode())) |
||||
|| !nullToEmpty(tPolicy.getRiskVer()).equals(nullToEmpty(tDetail.getRiskVer()))) { |
||||
continue; |
||||
} |
||||
JSONObject dutyObj = new JSONObject(true); |
||||
dutyObj.put("CaseNo", nullToEmpty(tDetail.getCaseNo())); |
||||
dutyObj.put("CaseRelaNo", nullToEmpty(tDetail.getCaseRelaNo())); |
||||
dutyObj.put("DutyCode", nullToEmpty(tDetail.getDutyCode())); |
||||
dutyObj.put("GetDutyCode", nullToEmpty(tDetail.getGetDutyCode())); |
||||
dutyObj.put("GetDutyKind", nullToEmpty(tDetail.getGetDutyKind())); |
||||
// GetDutyKind描述翻译
|
||||
String getDutyKindDesc = nullToEmpty(tSQL.findCodeNameByCodeTypeAndCode("getdutykind", tDetail.getGetDutyKind())); |
||||
dutyObj.put("GetDutyKindDesc", getDutyKindDesc); |
||||
dutyObj.put("StatType", nullToEmpty(tDetail.getStatType())); |
||||
dutyObj.put("RgtNo", nullToEmpty(tDetail.getRgtNo())); |
||||
dutyObj.put("DeclineNo", nullToEmpty(tDetail.getDeclineNo())); |
||||
dutyObj.put("GrpContNo", nullToEmpty(tDetail.getGrpContNo())); |
||||
dutyObj.put("ContNo", nullToEmpty(tDetail.getContNo())); |
||||
dutyObj.put("RiskCode", nullToEmpty(tDetail.getRiskCode())); |
||||
dutyObj.put("RiskVer", nullToEmpty(tDetail.getRiskVer())); |
||||
dutyObj.put("Amnt", tDetail.getAmnt()); |
||||
dutyObj.put("TabFeeMoney", tDetail.getTabFeeMoney()); |
||||
dutyObj.put("ClaimMoney", tDetail.getClaimMoney()); |
||||
dutyObj.put("DeclineAmnt", tDetail.getDeclineAmnt()); |
||||
dutyObj.put("OverAmnt", tDetail.getOverAmnt()); |
||||
dutyObj.put("StandPay", tDetail.getStandPay()); |
||||
dutyObj.put("RealPay", tDetail.getRealPay()); |
||||
dutyObj.put("AdjReason", nullToEmpty(tDetail.getAdjReason())); |
||||
dutyObj.put("AdjRemark", nullToEmpty(tDetail.getAdjRemark())); |
||||
dutyObj.put("PreGiveAmnt", tDetail.getPreGiveAmnt()); |
||||
dutyObj.put("SelfGiveAmnt", tDetail.getSelfGiveAmnt()); |
||||
dutyObj.put("RefuseAmnt", tDetail.getRefuseAmnt()); |
||||
dutyObj.put("OtherAmnt", tDetail.getOtherAmnt()); |
||||
dutyObj.put("OutDutyAmnt", tDetail.getOutDutyAmnt()); |
||||
dutyObj.put("OutDutyRate", tDetail.getOutDutyRate()); |
||||
dutyObj.put("ApproveAmnt", tDetail.getApproveAmnt()); |
||||
dutyObj.put("ApproveCode", nullToEmpty(tDetail.getApproveCode())); |
||||
dutyObj.put("AgreeAmnt", tDetail.getAgreeAmnt()); |
||||
dutyObj.put("AgreeCode", nullToEmpty(tDetail.getAgreeCode())); |
||||
dutyObj.put("GiveType", nullToEmpty(tDetail.getGiveType())); |
||||
dutyObj.put("GiveTypeDesc", nullToEmpty(tDetail.getGiveTypeDesc())); |
||||
dutyObj.put("GiveReason", nullToEmpty(tDetail.getGiveReason())); |
||||
dutyObj.put("GiveReasonDesc", nullToEmpty(tDetail.getGiveReasonDesc())); |
||||
dutyObj.put("SpecialRemark", nullToEmpty(tDetail.getSpecialRemark())); |
||||
dutyObj.put("PrepayFlag", nullToEmpty(tDetail.getPrepayFlag())); |
||||
dutyObj.put("PrepaySum", tDetail.getPrepaySum()); |
||||
dutyObj.put("CustomerNo", nullToEmpty(tDetail.getCustomerNo())); |
||||
dutyObj.put("CasePolType", nullToEmpty(tDetail.getCasePolType())); |
||||
dutyDetailsArray.add(dutyObj); |
||||
} |
||||
} |
||||
policyObj.put("DutyDetails", dutyDetailsArray); |
||||
claimDetailsArray.add(policyObj); |
||||
} |
||||
} |
||||
|
||||
mJsonObject.put("TotalPolicies", totalPolicies); |
||||
mJsonObject.put("ClaimDetails", claimDetailsArray); |
||||
|
||||
// ---------- 责任费用明细:LLClaimDutyFee ----------
|
||||
LLClaimDutyFeeDB tLLClaimDutyFeeDB = new LLClaimDutyFeeDB(); |
||||
tLLClaimDutyFeeDB.setClmNo(RgtNo); |
||||
LLClaimDutyFeeSet tLLClaimDutyFeeSet = tLLClaimDutyFeeDB.query(); |
||||
|
||||
JSONArray dutyFeeArray = new JSONArray(); |
||||
if (tLLClaimDutyFeeSet != null && tLLClaimDutyFeeSet.size() > 0) { |
||||
for (int i = 1; i <= tLLClaimDutyFeeSet.size(); i++) { |
||||
LLClaimDutyFeeSchema tFee = tLLClaimDutyFeeSet.get(i); |
||||
JSONObject feeObj = new JSONObject(true); |
||||
feeObj.put("PolNo", nullToEmpty(tFee.getPolNo())); |
||||
feeObj.put("DutyCode", nullToEmpty(tFee.getDutyCode())); |
||||
feeObj.put("GetDutyType", nullToEmpty(tFee.getGetDutyType())); |
||||
feeObj.put("GetDutyCode", nullToEmpty(tFee.getGetDutyCode())); |
||||
feeObj.put("DutyFeeType", nullToEmpty(tFee.getDutyFeeType())); |
||||
feeObj.put("DutyFeeCode", nullToEmpty(tFee.getDutyFeeCode())); |
||||
feeObj.put("DutyFeeName", nullToEmpty(tFee.getDutyFeeName())); |
||||
feeObj.put("RiskCode", nullToEmpty(tFee.getRiskCode())); |
||||
feeObj.put("RiskVer", nullToEmpty(tFee.getRiskVer())); |
||||
feeObj.put("HosID", nullToEmpty(tFee.getHosID())); |
||||
feeObj.put("HosName", nullToEmpty(tFee.getHosName())); |
||||
feeObj.put("DayCount", tFee.getDayCount()); |
||||
feeObj.put("OriSum", tFee.getOriSum()); |
||||
feeObj.put("CalSum", tFee.getCalSum()); |
||||
feeObj.put("AdjSum", tFee.getAdjSum()); |
||||
feeObj.put("OutDutyAmnt", tFee.getOutDutyAmnt()); |
||||
feeObj.put("OutDutyRate", tFee.getOutDutyRate()); |
||||
feeObj.put("AdjReason", nullToEmpty(tFee.getAdjReason())); |
||||
feeObj.put("AdjRemark", nullToEmpty(tFee.getAdjRemark())); |
||||
dutyFeeArray.add(feeObj); |
||||
} |
||||
} |
||||
mJsonObject.put("DutyFeeDetails", dutyFeeArray); |
||||
|
||||
// ---------- 理赔类型汇总:LLClaimDutyKind ----------
|
||||
LLClaimDutyKindDB tLLClaimDutyKindDB = new LLClaimDutyKindDB(); |
||||
tLLClaimDutyKindDB.setClmNo(RgtNo); |
||||
LLClaimDutyKindSet tLLClaimDutyKindSet = tLLClaimDutyKindDB.query(); |
||||
|
||||
JSONArray dutyKindArray = new JSONArray(); |
||||
if (tLLClaimDutyKindSet != null && tLLClaimDutyKindSet.size() > 0) { |
||||
for (int i = 1; i <= tLLClaimDutyKindSet.size(); i++) { |
||||
LLClaimDutyKindSchema tDutyKind = tLLClaimDutyKindSet.get(i); |
||||
JSONObject dkObj = new JSONObject(true); |
||||
dkObj.put("GetDutyKind", nullToEmpty(tDutyKind.getGetDutyKind())); |
||||
String dutyKindDesc = nullToEmpty(tSQL.findCodeNameByCodeTypeAndCode("getdutykind", tDutyKind.getGetDutyKind())); |
||||
dkObj.put("GetDutyKindDesc", dutyKindDesc); |
||||
dkObj.put("ClaimMoney", tDutyKind.getClaimMoney()); |
||||
dkObj.put("StandPay", tDutyKind.getStandPay()); |
||||
dkObj.put("RealPay", tDutyKind.getRealPay()); |
||||
dkObj.put("SocPay", tDutyKind.getSocPay()); |
||||
dkObj.put("OthPay", tDutyKind.getOthPay()); |
||||
dkObj.put("DeclinePay", tDutyKind.getDeclinePay()); |
||||
dkObj.put("SelfAmnt", tDutyKind.getSelfAmnt()); |
||||
dutyKindArray.add(dkObj); |
||||
} |
||||
} |
||||
mJsonObject.put("DutyKindSummary", dutyKindArray); |
||||
|
||||
// ---------- 账户变动明细:LLInsureAccTrace ----------
|
||||
LLInsureAccTraceDB tLLInsureAccTraceDB = new LLInsureAccTraceDB(); |
||||
tLLInsureAccTraceDB.setClmNo(RgtNo); |
||||
LLInsureAccTraceSet tLLInsureAccTraceSet = tLLInsureAccTraceDB.query(); |
||||
|
||||
JSONArray accTraceArray = new JSONArray(); |
||||
if (tLLInsureAccTraceSet != null && tLLInsureAccTraceSet.size() > 0) { |
||||
for (int i = 1; i <= tLLInsureAccTraceSet.size(); i++) { |
||||
LLInsureAccTraceSchema tTrace = tLLInsureAccTraceSet.get(i); |
||||
JSONObject traceObj = new JSONObject(true); |
||||
traceObj.put("PolNo", nullToEmpty(tTrace.getPolNo())); |
||||
traceObj.put("ClmPolNo", nullToEmpty(tTrace.getClmPolNo())); |
||||
traceObj.put("ClmDutyCode", nullToEmpty(tTrace.getClmDutyCode())); |
||||
traceObj.put("ClmGetDutyKind", nullToEmpty(tTrace.getClmGetDutyKind())); |
||||
traceObj.put("ClmGetDutyCode", nullToEmpty(tTrace.getClmGetDutyCode())); |
||||
traceObj.put("GrpContNo", nullToEmpty(tTrace.getGrpContNo())); |
||||
traceObj.put("ContNo", nullToEmpty(tTrace.getContNo())); |
||||
traceObj.put("InsuAccNo", nullToEmpty(tTrace.getInsuAccNo())); |
||||
traceObj.put("RiskCode", nullToEmpty(tTrace.getRiskCode())); |
||||
traceObj.put("MoneyType", nullToEmpty(tTrace.getMoneyType())); |
||||
traceObj.put("Money", tTrace.getMoney()); |
||||
traceObj.put("AccAscription", nullToEmpty(tTrace.getAccAscription())); |
||||
accTraceArray.add(traceObj); |
||||
} |
||||
} |
||||
mJsonObject.put("AccountTraceDetails", accTraceArray); |
||||
|
||||
// ---------- 应付结算明细:LLBalance ----------
|
||||
LLBalanceDB tLLBalanceDB = new LLBalanceDB(); |
||||
tLLBalanceDB.setClmNo(RgtNo); |
||||
LLBalanceSet tLLBalanceSet = tLLBalanceDB.query(); |
||||
|
||||
JSONArray balanceArray = new JSONArray(); |
||||
if (tLLBalanceSet != null && tLLBalanceSet.size() > 0) { |
||||
for (int i = 1; i <= tLLBalanceSet.size(); i++) { |
||||
LLBalanceSchema tBalance = tLLBalanceSet.get(i); |
||||
JSONObject bObj = new JSONObject(true); |
||||
bObj.put("PolNo", nullToEmpty(tBalance.getPolNo())); |
||||
bObj.put("ContNo", nullToEmpty(tBalance.getContNo())); |
||||
bObj.put("GrpContNo", nullToEmpty(tBalance.getGrpContNo())); |
||||
bObj.put("DutyCode", nullToEmpty(tBalance.getDutyCode())); |
||||
bObj.put("GetDutyCode", nullToEmpty(tBalance.getGetDutyCode())); |
||||
bObj.put("GetDutyKind", nullToEmpty(tBalance.getGetDutyKind())); |
||||
bObj.put("RiskCode", nullToEmpty(tBalance.getRiskCode())); |
||||
bObj.put("RiskVersion", nullToEmpty(tBalance.getRiskVersion())); |
||||
bObj.put("Pay", tBalance.getPay()); |
||||
bObj.put("PayFlag", nullToEmpty(tBalance.getPayFlag())); |
||||
bObj.put("State", nullToEmpty(tBalance.getState())); |
||||
bObj.put("ManageCom", nullToEmpty(tBalance.getManageCom())); |
||||
balanceArray.add(bObj); |
||||
} |
||||
} |
||||
mJsonObject.put("BalanceDetails", balanceArray); |
||||
|
||||
} catch (Exception e) { |
||||
logger.error("理算结果组装异常", e); |
||||
buildError("buildResult", new I18nMessage("理算结果组装异常:" + e.getMessage(), "")); |
||||
return false; |
||||
} |
||||
|
||||
return true; |
||||
} |
||||
|
||||
/** |
||||
* 赔案状态描述 |
||||
*/ |
||||
private String getClmStateDesc(String clmState) { |
||||
if (clmState == null) return ""; |
||||
switch (clmState) { |
||||
case "10": return "报案"; |
||||
case "20": return "理算"; |
||||
case "30": return "审核"; |
||||
case "40": return "审批"; |
||||
case "50": return "结案"; |
||||
case "60": return "已结案"; |
||||
default: return clmState; |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
public boolean getResult() { |
||||
return "Y".equals(result); |
||||
} |
||||
|
||||
@Override |
||||
public CErrors getErrors() { |
||||
return mErrors; |
||||
} |
||||
|
||||
/** |
||||
* 空值转空字符串 |
||||
*/ |
||||
private String nullToEmpty(String value) { |
||||
return value != null ? value : ""; |
||||
} |
||||
|
||||
public void buildError(String functionName, I18nMessage errorMessage) { |
||||
CError tCError = new CError(); |
||||
tCError.moduleName = this.getClass().getSimpleName(); |
||||
tCError.functionName = functionName; |
||||
tCError.errorMessage(errorMessage); |
||||
mErrors.addOneError(tCError); |
||||
} |
||||
} |
||||
@ -0,0 +1,290 @@ |
||||
package com.sinosoft.lis.httpservice.nb; |
||||
|
||||
import com.alibaba.fastjson.JSONArray; |
||||
import com.alibaba.fastjson.JSONObject; |
||||
import com.sinosoft.lis.httpservice.bl.callcenter.CallCenterService; |
||||
import com.sinosoft.lis.httpservice.core.bean.callcenter.request.CallCenterRequestHead; |
||||
import com.sinosoft.lis.httpservice.sql.nb.LCMainInsuredQueryBLSQL; |
||||
import com.sinosoft.lis.i18n.I18nMessage; |
||||
import com.sinosoft.persistence.SQLProxy; |
||||
import com.sinosoft.utility.CError; |
||||
import com.sinosoft.utility.CErrors; |
||||
import com.sinosoft.utility.SSRS; |
||||
import org.apache.commons.lang.StringUtils; |
||||
import org.slf4j.Logger; |
||||
import org.slf4j.LoggerFactory; |
||||
|
||||
import java.util.LinkedHashMap; |
||||
|
||||
/** |
||||
* 1000000251 - 主被保人及连带被保人信息查询 |
||||
* <p> |
||||
* 支持通过主被保人的三要素(姓名+证件类型+证件号码)或客户号, |
||||
* 查询主被保人本人及所有连带被保人的详细信息。 |
||||
* 使用 lcinsured 表的 MainCustomerNo 字段关联连带被保人。 |
||||
* </p> |
||||
*/ |
||||
public class LCMainInsuredQueryBL implements CallCenterService<JSONObject> { |
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(LCMainInsuredQueryBL.class); |
||||
|
||||
private String result = "Y"; |
||||
public CErrors mErrors = new CErrors(); |
||||
|
||||
// 入参
|
||||
private String CustomerNo = ""; |
||||
private String Name = ""; |
||||
private String IDType = ""; |
||||
private String IDNo = ""; |
||||
|
||||
// 查询结果
|
||||
private JSONObject mJsonObject = new JSONObject(new LinkedHashMap<>()); |
||||
|
||||
@Override |
||||
public JSONObject submitData(CallCenterRequestHead head, JSONObject inputData) { |
||||
|
||||
// 数据获取
|
||||
if (!getInputData(inputData)) { |
||||
buildError("getInputData", new I18nMessage("获取数据失败!", "")); |
||||
result = "N"; |
||||
return null; |
||||
} |
||||
|
||||
// 数据校验
|
||||
if (!checkData()) { |
||||
result = "N"; |
||||
return null; |
||||
} |
||||
|
||||
// 数据处理
|
||||
if (!dealData()) { |
||||
result = "N"; |
||||
return null; |
||||
} |
||||
|
||||
result = "Y"; |
||||
return mJsonObject; |
||||
} |
||||
|
||||
/** |
||||
* 数据获取 |
||||
*/ |
||||
private boolean getInputData(JSONObject inputData) { |
||||
CustomerNo = inputData.getString("CustomerNo"); |
||||
Name = inputData.getString("Name"); |
||||
IDType = inputData.getString("IDType"); |
||||
IDNo = inputData.getString("IDNo"); |
||||
|
||||
if (StringUtils.isBlank(CustomerNo)) { |
||||
CustomerNo = ""; |
||||
} |
||||
if (StringUtils.isBlank(Name)) { |
||||
Name = ""; |
||||
} |
||||
if (StringUtils.isBlank(IDType)) { |
||||
IDType = ""; |
||||
} |
||||
if (StringUtils.isBlank(IDNo)) { |
||||
IDNo = ""; |
||||
} |
||||
|
||||
return true; |
||||
} |
||||
|
||||
/** |
||||
* 数据校验:客户号和三要素至少提供一组 |
||||
*/ |
||||
private boolean checkData() { |
||||
|
||||
boolean hasCustomerNo = StringUtils.isNotBlank(CustomerNo); |
||||
boolean hasThreeElements = StringUtils.isNotBlank(Name) |
||||
&& StringUtils.isNotBlank(IDType) |
||||
&& StringUtils.isNotBlank(IDNo); |
||||
|
||||
if (!hasCustomerNo && !hasThreeElements) { |
||||
buildError("checkData", new I18nMessage( |
||||
"查询条件不足:请提供客户号,或同时提供姓名+证件类型+证件号码!", "")); |
||||
return false; |
||||
} |
||||
|
||||
return true; |
||||
} |
||||
|
||||
/** |
||||
* 数据处理:定位主被保人 → 查询主被保人及连带被保人 |
||||
*/ |
||||
private boolean dealData() { |
||||
|
||||
LCMainInsuredQueryBLSQL sql = SQLProxy.getInstance(LCMainInsuredQueryBLSQL.class); |
||||
|
||||
String mainInsuredNo = ""; |
||||
|
||||
// ========== 第一步:定位主被保人客户号 ==========
|
||||
if (StringUtils.isNotBlank(CustomerNo)) { |
||||
// 方式一:通过客户号查询
|
||||
SSRS tSSRS = sql.findMainFlagByCustomerNo(CustomerNo); |
||||
if (tSSRS == null || tSSRS.getMaxRow() == 0) { |
||||
buildError("dealData", new I18nMessage("未查询到被保人信息,客户号=" + CustomerNo, "")); |
||||
return false; |
||||
} |
||||
String mainFlag = tSSRS.GetText(1, 1); |
||||
if ("1".equals(mainFlag)) { |
||||
// 本人就是主被保人
|
||||
mainInsuredNo = CustomerNo; |
||||
} else { |
||||
// 此人是连带被保人,需要查其MainCustomerNo
|
||||
mainInsuredNo = findMainCustomerNoByInsuredNo(CustomerNo); |
||||
if (StringUtils.isBlank(mainInsuredNo)) { |
||||
buildError("dealData", new I18nMessage("未查询到主被保人信息,客户号=" + CustomerNo, "")); |
||||
return false; |
||||
} |
||||
} |
||||
} else { |
||||
// 方式二:通过三要素查询
|
||||
SSRS tSSRS = sql.findMainFlagByThreeElements(Name, IDType, IDNo); |
||||
if (tSSRS == null || tSSRS.getMaxRow() == 0) { |
||||
buildError("dealData", new I18nMessage( |
||||
"未查询到匹配的被保人信息,姓名=" + Name + ",证件类型=" + IDType + ",证件号码=" + IDNo, "")); |
||||
return false; |
||||
} |
||||
String insuredNo = tSSRS.GetText(1, 1); |
||||
String mainFlag = tSSRS.GetText(1, 2); |
||||
if ("1".equals(mainFlag)) { |
||||
mainInsuredNo = insuredNo; |
||||
} else { |
||||
mainInsuredNo = findMainCustomerNoByInsuredNo(insuredNo); |
||||
if (StringUtils.isBlank(mainInsuredNo)) { |
||||
buildError("dealData", new I18nMessage("未查询到主被保人信息!", "")); |
||||
return false; |
||||
} |
||||
} |
||||
} |
||||
|
||||
logger.debug("定位到主被保人客户号: {}", mainInsuredNo); |
||||
|
||||
// ========== 第二步:查询主被保人及所有连带被保人 ==========
|
||||
SSRS tResultSSRS = sql.selectMainAndLinkedInsureds(mainInsuredNo); |
||||
if (tResultSSRS == null || tResultSSRS.getMaxRow() == 0) { |
||||
buildError("dealData", new I18nMessage("未查询到主被保人及连带被保人信息,主被保人客户号=" + mainInsuredNo, "")); |
||||
return false; |
||||
} |
||||
|
||||
// ========== 第三步:组装返回结果 ==========
|
||||
buildResult(tResultSSRS, mainInsuredNo); |
||||
|
||||
return true; |
||||
} |
||||
|
||||
/** |
||||
* 通过InsuredNo查询MainCustomerNo |
||||
*/ |
||||
private String findMainCustomerNoByInsuredNo(String insuredNo) { |
||||
LCMainInsuredQueryBLSQL sql = SQLProxy.getInstance(LCMainInsuredQueryBLSQL.class); |
||||
// 复用主查询,查该人自己的记录获取maincustomerno
|
||||
SSRS tSSRS = sql.selectMainAndLinkedInsureds(insuredNo); |
||||
if (tSSRS != null && tSSRS.getMaxRow() > 0) { |
||||
for (int i = 1; i <= tSSRS.getMaxRow(); i++) { |
||||
String tInsuredNo = tSSRS.GetText(i, 2); |
||||
if (insuredNo.equals(tInsuredNo)) { |
||||
return tSSRS.GetText(i, 13); // MainCustomerNo列
|
||||
} |
||||
} |
||||
} |
||||
return ""; |
||||
} |
||||
|
||||
/** |
||||
* 组装返回结果 |
||||
*/ |
||||
private void buildResult(SSRS tSSRS, String mainInsuredNo) { |
||||
|
||||
mJsonObject.put("MainInsuredNo", mainInsuredNo); |
||||
|
||||
JSONObject mainInsuredObj = null; |
||||
JSONArray linkedInsuredsArray = new JSONArray(); |
||||
int totalCount = 0; |
||||
|
||||
for (int i = 1; i <= tSSRS.getMaxRow(); i++) { |
||||
JSONObject personObj = new JSONObject(new LinkedHashMap<>()); |
||||
|
||||
String relationToMain = tSSRS.GetText(i, 6); |
||||
String insuredNo = tSSRS.GetText(i, 2); |
||||
|
||||
personObj.put("SequenceNo", tSSRS.GetText(i, 1)); |
||||
personObj.put("InsuredNo", insuredNo); |
||||
personObj.put("Name", tSSRS.GetText(i, 3)); |
||||
personObj.put("Birthday", tSSRS.GetText(i, 4)); |
||||
personObj.put("Sex", tSSRS.GetText(i, 5)); |
||||
personObj.put("RelationToMainInsured", relationToMain); |
||||
personObj.put("RelationToMainInsuredName", tSSRS.GetText(i, 7)); |
||||
personObj.put("RelationToAppnt", tSSRS.GetText(i, 8)); |
||||
personObj.put("RelationToAppntName", tSSRS.GetText(i, 9)); |
||||
personObj.put("IDTypeCode", tSSRS.GetText(i, 10)); |
||||
personObj.put("IDType", tSSRS.GetText(i, 11)); |
||||
personObj.put("IDNo", tSSRS.GetText(i, 12)); |
||||
personObj.put("MainCustomerNo", tSSRS.GetText(i, 13)); |
||||
personObj.put("Nationality", tSSRS.GetText(i, 14)); |
||||
personObj.put("NativePlace", tSSRS.GetText(i, 15)); |
||||
personObj.put("MarryCode", tSSRS.GetText(i, 16)); |
||||
personObj.put("MarryState", tSSRS.GetText(i, 17)); |
||||
personObj.put("Occupation", tSSRS.GetText(i, 18)); |
||||
personObj.put("OccupationName", tSSRS.GetText(i, 19)); |
||||
personObj.put("JobClass", tSSRS.GetText(i, 20)); |
||||
personObj.put("Mobile", tSSRS.GetText(i, 21)); |
||||
personObj.put("PostalAddress", tSSRS.GetText(i, 22)); |
||||
personObj.put("Email", tSSRS.GetText(i, 23)); |
||||
personObj.put("ZipCode", tSSRS.GetText(i, 24)); |
||||
personObj.put("ProvinceCode", tSSRS.GetText(i, 25)); |
||||
personObj.put("Province", tSSRS.GetText(i, 26)); |
||||
personObj.put("CityCode", tSSRS.GetText(i, 27)); |
||||
personObj.put("City", tSSRS.GetText(i, 28)); |
||||
personObj.put("CountyCode", tSSRS.GetText(i, 29)); |
||||
personObj.put("County", tSSRS.GetText(i, 30)); |
||||
personObj.put("Stature", tSSRS.GetText(i, 31)); |
||||
personObj.put("Avoirdupois", tSSRS.GetText(i, 32)); |
||||
personObj.put("InsuredIDDateType", "1".equals(tSSRS.GetText(i, 33)) ? "2" : "1"); |
||||
personObj.put("InsuredIDEndDate", tSSRS.GetText(i, 34)); |
||||
personObj.put("ContNo", tSSRS.GetText(i, 35)); |
||||
personObj.put("GrpContNo", tSSRS.GetText(i, 36)); |
||||
personObj.put("ContPlanCode", tSSRS.GetText(i, 37)); |
||||
personObj.put("InsuredStat", tSSRS.GetText(i, 38)); |
||||
personObj.put("GrpCustName", tSSRS.GetText(i, 39)); |
||||
personObj.put("CustomerGradeCode", tSSRS.GetText(i, 40)); |
||||
personObj.put("CustomerGrade", tSSRS.GetText(i, 41)); |
||||
personObj.put("IsMainInsured", "00".equals(relationToMain)); |
||||
|
||||
totalCount++; |
||||
|
||||
if ("00".equals(relationToMain)) { |
||||
// 主被保人
|
||||
mainInsuredObj = personObj; |
||||
} else { |
||||
// 连带被保人
|
||||
linkedInsuredsArray.add(personObj); |
||||
} |
||||
} |
||||
|
||||
mJsonObject.put("TotalCount", totalCount); |
||||
mJsonObject.put("LinkedCount", linkedInsuredsArray.size()); |
||||
mJsonObject.put("MainInsured", mainInsuredObj != null ? mainInsuredObj : new JSONObject()); |
||||
mJsonObject.put("LinkedInsureds", linkedInsuredsArray); |
||||
} |
||||
|
||||
@Override |
||||
public boolean getResult() { |
||||
return "Y".equals(result); |
||||
} |
||||
|
||||
@Override |
||||
public CErrors getErrors() { |
||||
return mErrors; |
||||
} |
||||
|
||||
public void buildError(String functionName, I18nMessage errorMessage) { |
||||
CError tCError = new CError(); |
||||
tCError.moduleName = this.getClass().getSimpleName(); |
||||
tCError.functionName = functionName; |
||||
tCError.errorMessage(errorMessage); |
||||
mErrors.addOneError(tCError); |
||||
} |
||||
} |
||||
@ -0,0 +1,57 @@ |
||||
package com.sinosoft.lis.httpservice.sql.clm; |
||||
|
||||
import com.sinosoft.persistence.Param; |
||||
import com.sinosoft.persistence.SQL; |
||||
|
||||
public interface LLClaimCalApiSQL { |
||||
|
||||
/** |
||||
* 校验赔案号是否处于指定的工作流节点(ActivityId) |
||||
* ClmState=20 -> ActivityId=1800501003(理算) |
||||
* ClmState=30 -> ActivityId=1800501005(审核) |
||||
*/ |
||||
@SQL("select 1 from lwmission where missionprop1 = '?rgtNo?' and processid = '0000018005' and activityid = '?activityId?' limit 1") |
||||
String existsActivityByRgtNo(@Param("rgtNo") String rgtNo, @Param("activityId") String activityId); |
||||
|
||||
/** |
||||
* 查询LDCode中的代码名称(用于翻译GetDutyKind等) |
||||
*/ |
||||
@SQL("select codename from ldcode where codetype='?codeType?' and code='?code?' limit 1") |
||||
String findCodeNameByCodeTypeAndCode(@Param("codeType") String codeType, @Param("code") String code); |
||||
|
||||
/** |
||||
* 查询险种名称 |
||||
*/ |
||||
@SQL("select riskname from lmriskapp where riskcode='?riskCode?' limit 1") |
||||
String findRiskNameByRiskCode(@Param("riskCode") String riskCode); |
||||
|
||||
/** |
||||
* 查询LLRegister的管理机构 |
||||
*/ |
||||
@SQL("select mngcom from llregister where rgtno='?rgtNo?' limit 1") |
||||
String findMngComByRgtNo(@Param("rgtNo") String rgtNo); |
||||
|
||||
/** |
||||
* 查询LLRegister的CustomerNo(用于后续校验) |
||||
*/ |
||||
@SQL("select customerno from llregister where rgtno='?rgtNo?' limit 1") |
||||
String findCustomerNoByRgtNo(@Param("rgtNo") String rgtNo); |
||||
|
||||
/** |
||||
* 按RgtNo+CustomerNo校验LLCaseDuty是否存在记录(与实际理算引擎一致) |
||||
*/ |
||||
@SQL("select 1 from llcaseduty where rgtno='?rgtNo?' and customerno='?customerNo?' limit 1") |
||||
String existsLLCaseDutyByRgtNoAndCustomerNo(@Param("rgtNo") String rgtNo, @Param("customerNo") String customerNo); |
||||
|
||||
/** |
||||
* 幂等检查:查询LLClaim是否已存在理算结果 |
||||
*/ |
||||
@SQL("select 1 from llclaim where clmno='?clmNo?' limit 1") |
||||
String existsLLClaimByClmNo(@Param("clmNo") String clmNo); |
||||
|
||||
/** |
||||
* 查询赔付结论描述(GiveType对应LDCode) |
||||
*/ |
||||
@SQL("select codename from ldcode where codetype='llgiveType' and code='?giveType?' limit 1") |
||||
String findGiveTypeDescByGiveType(@Param("giveType") String giveType); |
||||
} |
||||
@ -0,0 +1,91 @@ |
||||
package com.sinosoft.lis.httpservice.sql.nb; |
||||
|
||||
import com.sinosoft.persistence.Param; |
||||
import com.sinosoft.persistence.SQL; |
||||
import com.sinosoft.utility.SSRS; |
||||
|
||||
/** |
||||
* 主被保人及连带被保人查询SQL |
||||
*/ |
||||
public interface LCMainInsuredQueryBLSQL { |
||||
|
||||
/** |
||||
* 通过客户号查询主被保人标识 |
||||
* 返回: MainFlag - '1'表示该人本身就是主被保人, '0'表示是连带被保人 |
||||
*/ |
||||
@SQL(value = """ |
||||
select\s |
||||
CASE WHEN i.RelationToMainInsured = '00' THEN '1' ELSE '0' END as MainFlag |
||||
from lcinsured i |
||||
where i.InsuredNo = '?CustomerNo?' |
||||
limit 1 |
||||
""") |
||||
SSRS findMainFlagByCustomerNo(@Param("CustomerNo") String CustomerNo); |
||||
|
||||
/** |
||||
* 通过三要素(姓名+证件类型+证件号码)查询主被保人标识 |
||||
*/ |
||||
@SQL(value = """ |
||||
select\s |
||||
i.InsuredNo, |
||||
CASE WHEN i.RelationToMainInsured = '00' THEN '1' ELSE '0' END as MainFlag |
||||
from lcinsured i |
||||
where i.Name = '?Name?' and i.IDType = '?IDType?' and i.IDNo = '?IDNo?' |
||||
limit 1 |
||||
""") |
||||
SSRS findMainFlagByThreeElements(@Param("Name") String Name, @Param("IDType") String IDType, @Param("IDNo") String IDNo); |
||||
|
||||
/** |
||||
* 查询主被保人及所有连带被保人的详细信息 |
||||
* 条件:InsuredNo = MainInsuredNo(主被保人本人) OR MainCustomerNo = MainInsuredNo(连带被保人) |
||||
* 排序:主被保人排在第一位 |
||||
*/ |
||||
@SQL(value = """ |
||||
select\s |
||||
i.sequenceno, |
||||
i.insuredno, |
||||
i.name, |
||||
i.birthday, |
||||
i.sex, |
||||
i.relationtomaininsured, |
||||
(select d.codename from ldcode d where d.codetype='relation' and d.code=i.relationtomaininsured) as relationtomaininsuredname, |
||||
i.relationtoappnt, |
||||
(select d.codename from ldcode d where d.codetype='relation' and d.code=i.relationtoappnt) as relationtoappntname, |
||||
i.idtype, |
||||
(select d.codename from ldcode d where d.codetype='idtype' and d.code=i.idtype) as idtypename, |
||||
i.idno, |
||||
i.maincustomerno, |
||||
trim(i.nativeplace), |
||||
(select d.codename from ldcode d where d.codetype='nativeplace' and d.code=i.nativeplace) as nativeplacename, |
||||
i.marriage, |
||||
(select d.codename from ldcode d where d.codetype='marriage' and d.code=i.marriage) as marriagename, |
||||
i.occupationcode, |
||||
(select o.occupationname from ldoccupation o where o.occupationcode=i.occupationcode) as occupationname, |
||||
(select d.codename from ldcode d where d.codetype='occupationtype' and d.code=i.occupationtype) as jobclassname, |
||||
(select a.mobile1 from lccustomercontactinfo a where a.contno = i.ContNo and a.PolicyNo = i.GrpContNo and a.CustomerNo = i.InsuredNo) as mobile, |
||||
(select a.postaladdress from lccustomercontactinfo a where a.contno = i.ContNo and a.PolicyNo = i.GrpContNo and a.CustomerNo = i.InsuredNo) as postaladdress, |
||||
(select a.EMail1 from lccustomercontactinfo a where a.contno = i.ContNo and a.PolicyNo = i.GrpContNo and a.CustomerNo = i.InsuredNo) as email, |
||||
(select a.ZipCode from lccustomercontactinfo a where a.contno = i.ContNo and a.PolicyNo = i.GrpContNo and a.CustomerNo = i.InsuredNo) as zipcode, |
||||
(select a.Province from lccustomercontactinfo a where a.contno = i.ContNo and a.PolicyNo = i.GrpContNo and a.CustomerNo = i.InsuredNo) as provincecode, |
||||
(select (select PlaceName from ldaddress where placetype='01' and placecode=a.Province) from lccustomercontactinfo a where a.contno = i.ContNo and a.PolicyNo = i.GrpContNo and a.CustomerNo = i.InsuredNo) as provincename, |
||||
(select a.City from lccustomercontactinfo a where a.contno = i.ContNo and a.PolicyNo = i.GrpContNo and a.CustomerNo = i.InsuredNo) as citycode, |
||||
(select (select PlaceName from ldaddress where placetype='02' and placecode=a.City) from lccustomercontactinfo a where a.contno = i.ContNo and a.PolicyNo = i.GrpContNo and a.CustomerNo = i.InsuredNo) as cityname, |
||||
(select a.County from lccustomercontactinfo a where a.contno = i.ContNo and a.PolicyNo = i.GrpContNo and a.CustomerNo = i.InsuredNo) as countycode, |
||||
(select (select PlaceName from ldaddress where placetype='03' and placecode=a.County) from lccustomercontactinfo a where a.contno = i.ContNo and a.PolicyNo = i.GrpContNo and a.CustomerNo = i.InsuredNo) as countyname, |
||||
i.Stature, |
||||
i.Avoirdupois, |
||||
i.ISLONGVALID, |
||||
i.idexpdate, |
||||
i.contno, |
||||
i.grpcontno, |
||||
i.contplancode, |
||||
i.insuredstat, |
||||
(select grpname from ldperson where customerno=i.insuredno) as grpcustname, |
||||
(select per.vipvalue from ldperson per where per.customerno=i.insuredno) as customergradecode, |
||||
(select d.codename from ldcode d where d.codetype='vipvalue' and d.code in (select per.vipvalue from ldperson per where per.customerno=i.insuredno)) as customergrade |
||||
from lcinsured i |
||||
where (i.InsuredNo = '?MainInsuredNo?' or i.MainCustomerNo = '?MainInsuredNo?') |
||||
order by case when i.RelationToMainInsured = '00' then 0 else 1 end, i.sequenceno |
||||
""") |
||||
SSRS selectMainAndLinkedInsureds(@Param("MainInsuredNo") String MainInsuredNo); |
||||
} |
||||
Loading…
Reference in new issue