DLCB解决问题的思路

需求描述:新增一个客户信用等级申请时需要根据客户类型选择一个评级模板,如果某一客户类型对应了多个模板,则应该根据不同的条件在下拉框中只显示一个可选选项。比如,个人客户要根据是否是农户来选择是显示个人信用等级评估模板还是农户信用等级评估模板。

1.在对应页面中找到下拉框生成语句:

<select name="ModelNo" class="right">
<% 
                        if (sModelType.equals("010")||sModelType.equals("012") || sModelType.equals("015"))    out.print(HTMLControls.generateDropDownSelect(Sqlca,"select ModelNo,ModelName from EVALUATE_CATALOG where ModelType='"+sModelType+"' and ModelNo = '"+sDefaultModelNo+"'  order by ModelNo ",1,2,sDefaultModelNo));
                        else    out.print(HTMLControls.generateDropDownSelect(Sqlca,"select ModelNo,ModelName from EVALUATE_CATALOG where ModelType='"+sModelType+"' order by ModelNo ",1,2,sDefaultModelNo));
%>
                    </select>

010,012,015模板类型都对应了多个模板,因此要附一个默认模板值,通过代码

String sSql = "select RelativeCode from CODE_LIBRARY where CodeNo='EvaluateModelType' and ItemNo='"+sModelType+"'";
    ASResultSet rs   = Sqlca.getASResultSet(sSql);
    if(rs.next()){
        sModelTypeAttributes = rs.getString("RelativeCode");
    }
    else{
        throw new Exception("模型类型 ["+sModelType+"] 没有定义。请和系统管理员联系!");
    }
    rs.getStatement().close();

    /* 等级评估变量说明
    sModelTypeAttributes    模型相关的参数定义串
    sAccountMonthSelectSQL  
    sAccountMonthExplanation 对于会计月份的补充说明
    sDefaultModelNoSQL        取得对应类型的查询语句
    */
    sAccountMonthInputType = StringFunction.getProfileString(sModelTypeAttributes,"AccountMonthInputType");
    sAccountMonthSelectSQL = StringFunction.getProfileString(sModelTypeAttributes,"AccountMonthSelectSQL");    
    sAccountMonthExplanation = StringFunction.getProfileString(sModelTypeAttributes,"AccountMonthExplanation");
    sDefaultModelNoSQL = StringFunction.getProfileString(sModelTypeAttributes,"DefaultModelNoSQL");

    //将对应的参数转换为当前实际数据
    sAccountMonthSelectSQL = StringFunction.replace(sAccountMonthSelectSQL,"#ObjectType",sObjectType);
    sAccountMonthSelectSQL = StringFunction.replace(sAccountMonthSelectSQL,"#ObjectNo",sObjectNo);
    sAccountMonthSelectSQL = StringFunction.replace(sAccountMonthSelectSQL,"#ModelType",sModelType);
    sDefaultModelNoSQL = StringFunction.replace(sDefaultModelNoSQL,"#ObjectType",sObjectType);
    sDefaultModelNoSQL = StringFunction.replace(sDefaultModelNoSQL,"#ObjectNo",sObjectNo);
    sDefaultModelNoSQL = StringFunction.replace(sDefaultModelNoSQL,"#ModelType",sModelType);

发现这个默认值是配在CODE中的RELATIVECODE字段中的,对于对公客户,在客户详情中有一个“信用等级评估模板”字段可以保存默认值,但在对私客户详情中没有,这是可以在对私客户详情中添加一个不可见字段,(当然要修改INT_INFO表添加一个字段),并且在保存详情是,校验“是否是农户”来设置这个新加字段的值,

sPeasantFlag = getItemValue(0,getRow(),"PeasantFlag");
            if(sCreditBelong == null || sCreditBelong == ""){
               setItemValue(0,getRow(),"CreditBelong","501");
            }
            if(sPeasantFlag == "1")
            {
                 setItemValue(0,getRow(),"CreditBelong","502");
            }

经验教训:看代码要仔细,不能似懂非懂。抓住一条线,延伸开来才能收获更多的知识。

原文地址:https://www.cnblogs.com/liuping/p/2811826.html