package com.brilliance.isc.common.transaction.newcheck.setmod;

import com.brilliance.isc.bo.Bnm;
import com.brilliance.isc.common.context.SettleContext;
import com.brilliance.isc.common.setgll.vo.SetgllVo;
import com.brilliance.isc.common.transaction.newcheck.AbstractModuleValidator;
import com.brilliance.isc.common.transaction.newcheck.ValidResult;
import com.brilliance.isc.common.transaction.newcheck.Validate;
import com.brilliance.isc.common.util.StringUtils;
import com.brilliance.isc.mda.dao.BnmMapper;
import com.brilliance.isc.mda.dao.BnnMapper;
import com.brilliance.isc.vo.BnmVo;
import com.brilliance.isc.vo.CipmodVo;
import com.brilliance.mda.runtime.mda.util.MdaUtils;
import com.brilliance.mda.runtime.mda.util.Strings;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import java.math.BigDecimal;
import java.util.List;

@Component
public class CipmodValidator extends AbstractModuleValidator<CipmodVo> {

    @Autowired
    private BnnMapper bnnMapper;

    @Autowired
    private BnmMapper bnmMapper;

    @Override
    @PostConstruct
    public void register() {
        super.register();
    }

    /**
     *   source:cipmod.0000.script
     */
    @Validate(path="setmod.setglg.setgll.%s.sespay.cipmod.skrdz2")
    public ValidResult checkSkrdz2N1000(CipmodVo cipmod){
        //!收款人地址2cips取70个位汉字占一位
        SetgllVo setgllVo = getSetgll();
        if (!MdaUtils.isEmpty(cipmod.getSkrdz2()) && "CIU".equals(setgllVo.getSftmt())) {
            return this.validateAddress(cipmod.getSkrdz2());
        }
        return null;
    }

    /**
     *   source:cipmod.0001.script
     */
    @Validate(path="setmod.setglg.setgll.%s.sespay.cipmod.skrdz3")
    public ValidResult checkSkrdz3N1000(CipmodVo cipmod){
        //!收款人地址3cips取70个位汉字占一位
        SetgllVo setgllVo = getSetgll();
        if (!MdaUtils.isEmpty(cipmod.getSkrdz3()) && "CIU".equals(setgllVo.getSftmt())) {
            return this.validateAddress(cipmod.getSkrdz3());
        }
        return null;
    }

    /**
     *   source:cipmod.0002.script
     */
    @Validate(path="setmod.setglg.setgll.%s.sespay.cipmod.skrdz4")
    public ValidResult checkSkrdz4N1000(CipmodVo cipmod){
        //!收款人地址4cips取70个位汉字占一位
        SetgllVo setgllVo = getSetgll();
        if (!MdaUtils.isEmpty(cipmod.getSkrdz4()) && "CIU".equals(setgllVo.getSftmt())) {
            return this.validateAddress(cipmod.getSkrdz4());
        }
        return null;
    }

    /**
     *   source:cipmod.0003.script
     */
    @Validate(path="setmod.setglg.setgll.%s.sespay.cipmod.skrdz5")
    public ValidResult checkSkrdz5N1000(CipmodVo cipmod){
        //!收款人地址5cips取70个位汉字占一位
        SetgllVo setgllVo = getSetgll();
        if (!MdaUtils.isEmpty(cipmod.getSkrdz5()) && "CIU".equals(setgllVo.getSftmt())) {
            return this.validateAddress(cipmod.getSkrdz5());
        }
        return null;
    }

    /**
     *   source:cipmod.0004.script
     */
    @Validate(path="setmod.setglg.setgll.%s.sespay.cipmod.skrdz6")
    public ValidResult checkSkrdz6N1000(CipmodVo cipmod){
        //!收款人地址6cips取70个位汉字占一位
        SetgllVo setgllVo = getSetgll();
        if (!MdaUtils.isEmpty(cipmod.getSkrdz6()) && "CIU".equals(setgllVo.getSftmt())) {
            return this.validateAddress(cipmod.getSkrdz6());
        }
        return null;
    }

    /**
     *   source:cipmod.0005.script
     */
    @Validate(path="setmod.setglg.setgll.%s.sespay.cipmod.skrdz7")
    public ValidResult checkSkrdz7N1000(CipmodVo cipmod){
        //!收款人地址7cips取70个位汉字占一位
        SetgllVo setgllVo = getSetgll();
        if (!MdaUtils.isEmpty(cipmod.getSkrdz7()) && "CIU".equals(setgllVo.getSftmt())) {
            return this.validateAddress(cipmod.getSkrdz7());
        }
        return null;
    }

    /**
     *   source:cipmod.0006.script
     */
    @Validate(path="setmod.setglg.setgll.%s.sespay.cipmod.fkrdz6")
    public ValidResult checkFkrdz6N1000(CipmodVo cipmod){
        //!付款人地址6cips取70个位汉字占一位
        SetgllVo setgllVo = getSetgll();
        if (!MdaUtils.isEmpty(cipmod.getFkrdz6()) && "CIU".equals(setgllVo.getSftmt())) {
            return this.validateAddress(cipmod.getFkrdz6());
        }
        return null;
    }

    /**
     *   source:cipmod.0007.script
     */
    @Validate(path="setmod.setglg.setgll.%s.sespay.cipmod.fkrdz7")
    public ValidResult checkFkrdz7N1000(CipmodVo cipmod){
        //!付款人地址7cips取70个位汉字占一位
        SetgllVo setgllVo = getSetgll();
        if (!MdaUtils.isEmpty(cipmod.getFkrdz7()) && "CIU".equals(setgllVo.getSftmt())) {
            return this.validateAddress(cipmod.getFkrdz7());
        }
        return null;
    }

    /**
     *   source:cipmod.0008.script
     */
    @Validate(path="setmod.setglg.setgll.%s.sespay.cipmod.fkrdz2")
    public ValidResult checkFkrdz2N1000(CipmodVo cipmod){
        //!付款人地址2cips取70个位汉字占一位
        SetgllVo setgllVo = getSetgll();
        if (!MdaUtils.isEmpty(cipmod.getFkrdz2()) && "CIU".equals(setgllVo.getSftmt())) {
            return this.validateAddress(cipmod.getFkrdz2());
        }
        return null;
    }

    /**
     *   source:cipmod.0009.script
     */
    @Validate(path="setmod.setglg.setgll.%s.sespay.cipmod.fkrdz3")
    public ValidResult checkFkrdz3N1000(CipmodVo cipmod){
        //!付款人地址3cips取70个位汉字占一位
        SetgllVo setgllVo = getSetgll();
        if (!MdaUtils.isEmpty(cipmod.getFkrdz3()) && "CIU".equals(setgllVo.getSftmt())) {
            return this.validateAddress(cipmod.getFkrdz3());
        }
        return null;
    }

    /**
     *   source:cipmod.0010.script
     */
    @Validate(path="setmod.setglg.setgll.%s.sespay.cipmod.fkrdz4")
    public ValidResult checkFkrdz4N1000(CipmodVo cipmod){
        //!付款人地址4cips取70个位汉字占一位
        SetgllVo setgllVo = getSetgll();
        if (!MdaUtils.isEmpty(cipmod.getFkrdz4()) && "CIU".equals(setgllVo.getSftmt())) {
            return this.validateAddress(cipmod.getFkrdz4());
        }
        return null;
    }

    /**
     *   source:cipmod.0011.script
     */
    @Validate(path="setmod.setglg.setgll.%s.sespay.cipmod.fkrdz5")
    public ValidResult checkFkrdz5N1000(CipmodVo cipmod){
        //!付款人地址5cips取70个位汉字占一位
        SetgllVo setgllVo = getSetgll();
        if (!MdaUtils.isEmpty(cipmod.getFkrdz5()) && "CIU".equals(setgllVo.getSftmt())) {
            return this.validateAddress(cipmod.getFkrdz5());
        }
        return null;
    }

    /**
     *   source:cipmod.0012.script
     */
    @Validate(path="setmod.setglg.setgll.%s.sespay.cipmod.fuynh2")
    public ValidResult checkFuynh2N1000(CipmodVo cipmod){
        SetgllVo setgllVo = getSetgll();
        if (!MdaUtils.isEmpty(cipmod.getFuynh2()) && ("CIU".equals(setgllVo.getSftmt()) || "CIV".equals(setgllVo.getSftmt()))) {
            return this.validateMark(cipmod.getFuynh2());
        }
        return null;
    }

    /**
     *   source:cipmod.0013.script
     */
    @Validate(path="setmod.setglg.setgll.%s.sespay.cipmod.fuynh3")
    public ValidResult checkFuynh3N1000(CipmodVo cipmod){
        SetgllVo setgllVo = getSetgll();
        if (!MdaUtils.isEmpty(cipmod.getFuynh3()) && ("CIU".equals(setgllVo.getSftmt()) || "CIV".equals(setgllVo.getSftmt()))) {
            return this.validateMark(cipmod.getFuynh3());
        }
        return null;
    }

    /**
     *   source:cipmod.0014.script
     */
    @Validate(path="setmod.setglg.setgll.%s.sespay.cipmod.fuynh4")
    public ValidResult checkFuynh4N1000(CipmodVo cipmod){
        SetgllVo setgllVo = getSetgll();
        if (!MdaUtils.isEmpty(cipmod.getFuynh4()) && ("CIU".equals(setgllVo.getSftmt()) || "CIV".equals(setgllVo.getSftmt()))) {
            return this.validateMark(cipmod.getFuynh4());
        }
        return null;
    }

    /**
     *   source:cipmod.0019.script
     */
    @Validate(path="setmod.setglg.setgll.%s.sespay.cipmod.recsehbch")
    public ValidResult checkRecsehbchN1000(CipmodVo cipmod){
        //!对收款人直参、间参关系进行判断
        SetgllVo setgllVo = getSetgll();
        if ("CIU".equals(setgllVo.getSftmt()) || "CIV".equals(setgllVo.getSftmt())) {
            if (StringUtils.isNotEmpty(cipmod.getReconebch()) && StringUtils.isNotEmpty(cipmod.getRecsehbch())) {
                int count = bnnMapper.countBnn(cipmod.getRecsehbch(), cipmod.getReconebch());
                if (count <= 0) {
                    return ValidResult.build(false, "收款直接参与者行号与收款间接参与者行号不满足关系，请重新输入！");
                }
            }
        }
        return null;
    }

    /**
     *   source:cipmod.0023.script
     */
    @Validate(path="setmod.setglg.setgll.%s.sespay.cipmod.stasehbch")
    public ValidResult checkStasehbchN1000(CipmodVo cipmod){
        //!对付款人直参、间参关系进行判断
        SetgllVo setgllVo = getSetgll();
        if ("CIU".equals(setgllVo.getSftmt()) || "CIV".equals(setgllVo.getSftmt())) {
            if (StringUtils.isNotEmpty(cipmod.getStaonebch()) && StringUtils.isNotEmpty(cipmod.getStasehbch())) {
                int count = bnnMapper.countBnn(cipmod.getStasehbch(), cipmod.getStaonebch());
                if (count <= 0) {
                    return ValidResult.build(false, "付款直接参与行行号与付款间接参与行行号不满足关系，请重新输入！");
                }
            }
        }
        return null;
    }

    /**
     *   source:cipmod.0024.script
     */
    @Validate(path="setmod.setglg.setgll.%s.sespay.cipmod.zjg1mc")
    public ValidResult checkZjg1mcN1000(CipmodVo cipmod){
        //中介机构1的名称
        SetgllVo setgllVo = getSetgll();
        if ("CIU".equals(setgllVo.getSftmt()) || "CIV".equals(setgllVo.getSftmt())) {
            if (!MdaUtils.isEmpty(cipmod.getZjg1mc())) {
                String errorMsg = this.checkcipsname(cipmod.getZjg1mc(), 120);
                if (StringUtils.isNotEmpty(errorMsg)) {
                    return ValidResult.build(false, errorMsg);
                }
                errorMsg = this.filtmarks1(cipmod.getZjg1mc());
                if (StringUtils.isNotEmpty(errorMsg)) {
                    return ValidResult.build(false, errorMsg);
                }
            }
        }
        return null;
    }

    /**
     *   source:cipmod.0025.script
     */
    @Validate(path="setmod.setglg.setgll.%s.sespay.cipmod.zjg2mc")
    public ValidResult checkZjg2mcN1000(CipmodVo cipmod){
        //中介机构2的名称
        SetgllVo setgllVo = getSetgll();
        if ("CIU".equals(setgllVo.getSftmt()) || "CIV".equals(setgllVo.getSftmt())) {
            if (!MdaUtils.isEmpty(cipmod.getZjg1mc())) {
                String errorMsg = this.checkcipsname(cipmod.getZjg2mc(), 120);
                if (StringUtils.isNotEmpty(errorMsg)) {
                    return ValidResult.build(false, errorMsg);
                }
                errorMsg = this.filtmarks1(cipmod.getZjg2mc());
                if (StringUtils.isNotEmpty(errorMsg)) {
                    return ValidResult.build(false, errorMsg);
                }
            }
        }
        return null;
    }

    /**
     *   source:cipmod.0026.script
     */
    @Validate(path="setmod.setglg.setgll.%s.sespay.cipmod.cfkkhm")
    public ValidResult checkCfkkhmN1000(CipmodVo cipmod){
        SetgllVo setgllVo = getSetgll();
        if ("CIV".equals(setgllVo.getSftmt()) && "X".equalsIgnoreCase(cipmod.getCovflg())) {
            if (!MdaUtils.isEmpty(cipmod.getCfkkhm())) {
                String errorMsg = this.checkcipsname(cipmod.getCfkkhm(), 140);
                if (StringUtils.isNotEmpty(errorMsg)) {
                    return ValidResult.build(false, errorMsg);
                }
                errorMsg = this.filtmarks1(cipmod.getCfkkhm());
                if (StringUtils.isNotEmpty(errorMsg)) {
                    return ValidResult.build(false, errorMsg);
                }
            }
            if(!MdaUtils.isEmpty(cipmod.getCfkfzh()) && MdaUtils.isEmpty(cipmod.getCfkkhm())) {
                if((MdaUtils.isEmpty(cipmod.getCfkkhh()) && MdaUtils.isEmpty(cipmod.getCfkfzh())) || (!MdaUtils.isEmpty(cipmod.getCfkkhh()) && !MdaUtils.isEmpty(cipmod.getCfkfzh()))) {
                    return errorMandatory();
                }
            }
        }
        return null;
    }

    /**
     *   source:cipmod.0027.script
     */
    @Validate(path="setmod.setglg.setgll.%s.sespay.cipmod.cskkhm")
    public ValidResult checkCskkhmN1000(CipmodVo cipmod){
        SetgllVo setgllVo = getSetgll();
        if ("CIV".equals(setgllVo.getSftmt()) && "X".equalsIgnoreCase(cipmod.getCovflg())) {
            if (!MdaUtils.isEmpty(cipmod.getCskkhm())) {
                String errorMsg = this.checkcipsname(cipmod.getCskkhm(), 140);
                if (StringUtils.isNotEmpty(errorMsg)) {
                    return ValidResult.build(false, errorMsg);
                }
                errorMsg = this.filtmarks1(cipmod.getCskkhm());
                if (StringUtils.isNotEmpty(errorMsg)) {
                    return ValidResult.build(false, errorMsg);
                }
            }
            if(!MdaUtils.isEmpty(cipmod.getCskfzh()) && MdaUtils.isEmpty(cipmod.getCskkhm())) {
                if((MdaUtils.isEmpty(cipmod.getCskkhh()) && MdaUtils.isEmpty(cipmod.getCskfzh())) || (!MdaUtils.isEmpty(cipmod.getCskkhh()) && !MdaUtils.isEmpty(cipmod.getCskfzh()))) {
                    return errorMandatory();
                }
            }
        }
        return null;
    }

    /**
     *   source:cipmod.0028.script
     */
    @Validate(path="setmod.setglg.setgll.%s.sespay.cipmod.cfkrmc")
    public ValidResult checkCfkrmcN1000(CipmodVo cipmod){
        SetgllVo setgllVo = getSetgll();
        if ("CIV".equals(setgllVo.getSftmt()) && "X".equalsIgnoreCase(cipmod.getCovflg())) {
            if( MdaUtils.isEmpty(cipmod.getCfkrmc()) && MdaUtils.isEmpty(cipmod.getCfkdz1())
                    && MdaUtils.isEmpty(cipmod.getCfkdz2()) && MdaUtils.isEmpty(cipmod.getCfkdz3())
                    && MdaUtils.isEmpty(cipmod.getCfkdz4()) && MdaUtils.isEmpty(cipmod.getCfkdz5())
                    && MdaUtils.isEmpty(cipmod.getCfkdz6()) && MdaUtils.isEmpty(cipmod.getCfkdz7())) {
               return ValidResult.build(false, "付款人名称和付款人地址至少输入一项");
            }
            if (!MdaUtils.isEmpty(cipmod.getCfkrmc())) {
                String errorMsg = this.checkcipsname(cipmod.getCfkrmc(), 120);
                if (StringUtils.isNotEmpty(errorMsg)) {
                    return ValidResult.build(false, errorMsg);
                }
                errorMsg = this.filtmarks1(cipmod.getCfkrmc());
                if (StringUtils.isNotEmpty(errorMsg)) {
                    return ValidResult.build(false, errorMsg);
                }
            }
        }
        return null;
    }

    /**
     *   source:cipmod.0029.script
     */
    @Validate(path="setmod.setglg.setgll.%s.sespay.cipmod.cfkdz1")
    public ValidResult checkCfkdz1N1000(CipmodVo cipmod){
        SetgllVo setgllVo = getSetgll();
        if ("CIV".equals(setgllVo.getSftmt()) && "X".equalsIgnoreCase(cipmod.getCovflg())) {
            if(!MdaUtils.isEmpty(cipmod.getCfkdz1())) {
                String errorMsg = this.filterCNYCIPS(cipmod.getCfkdz1(), 70);
                if (StringUtils.isNotEmpty(errorMsg)) {
                    return ValidResult.build(false, errorMsg);
                }
                errorMsg = this.filtmarks1(cipmod.getCfkdz1());
                if (StringUtils.isNotEmpty(errorMsg)) {
                    return ValidResult.build(false, errorMsg);
                }
            }
            String errorMsg = this.checkcipsadd(cipmod.getCfkdz1(), cipmod.getCfkdz2(), cipmod.getCfkdz3(), cipmod.getCfkdz4(), cipmod.getCfkdz5(), cipmod.getCfkdz6(), cipmod.getCfkdz7(), 140);
            if (StringUtils.isNotEmpty(errorMsg)) {
                return ValidResult.build(false, errorMsg);
            }
            if(MdaUtils.isEmpty(cipmod.getCfkdz1())
                    && (!MdaUtils.isEmpty(cipmod.getCfkdz2()) || !MdaUtils.isEmpty(cipmod.getCfkdz3()) || !MdaUtils.isEmpty(cipmod.getCfkdz4()) || !MdaUtils.isEmpty(cipmod.getCfkdz5()) || !MdaUtils.isEmpty(cipmod.getCfkdz6()) || !MdaUtils.isEmpty(cipmod.getCfkdz7()))) {
                return ValidResult.build(false, "请按顺序先输入COV付款人地址1");
            }
        }
        return null;
    }

    /**
     *   source:cipmod.0030.script
     */
    @Validate(path="setmod.setglg.setgll.%s.sespay.cipmod.cfkdz2")
    public ValidResult checkCfkdz2N1000(CipmodVo cipmod){
        SetgllVo setgllVo = getSetgll();
        if ("CIV".equals(setgllVo.getSftmt()) && "X".equalsIgnoreCase(cipmod.getCovflg())) {
            if(!MdaUtils.isEmpty(cipmod.getCfkdz2())) {
                String errorMsg = this.filterCNYCIPS(cipmod.getCfkdz2(), 70);
                if (StringUtils.isNotEmpty(errorMsg)) {
                    return ValidResult.build(false, errorMsg);
                }
                errorMsg = this.filtmarks1(cipmod.getCfkdz2());
                if (StringUtils.isNotEmpty(errorMsg)) {
                    return ValidResult.build(false, errorMsg);
                }
            }
        }
        return null;
    }

    /**
     *   source:cipmod.0031.script
     */
    @Validate(path="setmod.setglg.setgll.%s.sespay.cipmod.cfkdz3")
    public ValidResult checkCfkdz3N1000(CipmodVo cipmod){
        SetgllVo setgllVo = getSetgll();
        if ("CIV".equals(setgllVo.getSftmt()) && "X".equalsIgnoreCase(cipmod.getCovflg())) {
            if(!MdaUtils.isEmpty(cipmod.getCfkdz3())) {
                String errorMsg = this.filterCNYCIPS(cipmod.getCfkdz3(), 70);
                if (StringUtils.isNotEmpty(errorMsg)) {
                    return ValidResult.build(false, errorMsg);
                }
                errorMsg = this.filtmarks1(cipmod.getCfkdz3());
                if (StringUtils.isNotEmpty(errorMsg)) {
                    return ValidResult.build(false, errorMsg);
                }
            }
        }
        return null;
    }

    /**
     *   source:cipmod.0032.script
     */
    @Validate(path="setmod.setglg.setgll.%s.sespay.cipmod.cfkdz4")
    public ValidResult checkCfkdz4N1000(CipmodVo cipmod){
        SetgllVo setgllVo = getSetgll();
        if ("CIV".equals(setgllVo.getSftmt()) && "X".equalsIgnoreCase(cipmod.getCovflg())) {
            if(!MdaUtils.isEmpty(cipmod.getCfkdz4())) {
                String errorMsg = this.filterCNYCIPS(cipmod.getCfkdz4(), 70);
                if (StringUtils.isNotEmpty(errorMsg)) {
                    return ValidResult.build(false, errorMsg);
                }
                errorMsg = this.filtmarks1(cipmod.getCfkdz4());
                if (StringUtils.isNotEmpty(errorMsg)) {
                    return ValidResult.build(false, errorMsg);
                }
            }
        }
        return null;
    }

    /**
     *   source:cipmod.0033.script
     */
    @Validate(path="setmod.setglg.setgll.%s.sespay.cipmod.cfkdz5")
    public ValidResult checkCfkdz5N1000(CipmodVo cipmod){
        SetgllVo setgllVo = getSetgll();
        if ("CIV".equals(setgllVo.getSftmt()) && "X".equalsIgnoreCase(cipmod.getCovflg())) {
            if(!MdaUtils.isEmpty(cipmod.getCfkdz5())) {
                String errorMsg = this.filterCNYCIPS(cipmod.getCfkdz5(), 70);
                if (StringUtils.isNotEmpty(errorMsg)) {
                    return ValidResult.build(false, errorMsg);
                }
                errorMsg = this.filtmarks1(cipmod.getCfkdz5());
                if (StringUtils.isNotEmpty(errorMsg)) {
                    return ValidResult.build(false, errorMsg);
                }
            }
        }
        return null;
    }

    /**
     *   source:cipmod.0034.script
     */
    @Validate(path="setmod.setglg.setgll.%s.sespay.cipmod.cfkdz6")
    public ValidResult checkCfkdz6N1000(CipmodVo cipmod){
        SetgllVo setgllVo = getSetgll();
        if ("CIV".equals(setgllVo.getSftmt()) && "X".equalsIgnoreCase(cipmod.getCovflg())) {
            if(!MdaUtils.isEmpty(cipmod.getCfkdz6())) {
                String errorMsg = this.filterCNYCIPS(cipmod.getCfkdz6(), 70);
                if (StringUtils.isNotEmpty(errorMsg)) {
                    return ValidResult.build(false, errorMsg);
                }
                errorMsg = this.filtmarks1(cipmod.getCfkdz6());
                if (StringUtils.isNotEmpty(errorMsg)) {
                    return ValidResult.build(false, errorMsg);
                }
            }
        }
        return null;
    }

    /**
     *   source:cipmod.0035.script
     */
    @Validate(path="setmod.setglg.setgll.%s.sespay.cipmod.cfkdz7")
    public ValidResult checkCfkdz7N1000(CipmodVo cipmod){
        SetgllVo setgllVo = getSetgll();
        if ("CIV".equals(setgllVo.getSftmt()) && "X".equalsIgnoreCase(cipmod.getCovflg())) {
            if(!MdaUtils.isEmpty(cipmod.getCfkdz7())) {
                String errorMsg = this.filterCNYCIPS(cipmod.getCfkdz7(), 70);
                if (StringUtils.isNotEmpty(errorMsg)) {
                    return ValidResult.build(false, errorMsg);
                }
                errorMsg = this.filtmarks1(cipmod.getCfkdz7());
                if (StringUtils.isNotEmpty(errorMsg)) {
                    return ValidResult.build(false, errorMsg);
                }
            }
        }
        return null;
    }

    /**
     *   source:cipmod.0036.script
     */
    @Validate(path="setmod.setglg.setgll.%s.sespay.cipmod.cskdz1")
    public ValidResult checkCskdz1N1000(CipmodVo cipmod){
        SetgllVo setgllVo = getSetgll();
        if ("CIV".equals(setgllVo.getSftmt()) && "X".equalsIgnoreCase(cipmod.getCovflg())) {
            if(!MdaUtils.isEmpty(cipmod.getCskdz1())) {
                String errorMsg = this.filterCNYCIPS(cipmod.getCskdz1(), 70);
                if (StringUtils.isNotEmpty(errorMsg)) {
                    return ValidResult.build(false, errorMsg);
                }
                errorMsg = this.filtmarks1(cipmod.getCskdz1());
                if (StringUtils.isNotEmpty(errorMsg)) {
                    return ValidResult.build(false, errorMsg);
                }
            }
            String errorMsg = this.checkcipsadd(cipmod.getCskdz1(), cipmod.getCskdz2(), cipmod.getCskdz3(), cipmod.getCskdz4(), cipmod.getCskdz5(), cipmod.getCskdz6(), cipmod.getCskdz7(), 140);
            if (StringUtils.isNotEmpty(errorMsg)) {
                return ValidResult.build(false, errorMsg);
            }
            if(MdaUtils.isEmpty(cipmod.getCskdz1())
                    && (!MdaUtils.isEmpty(cipmod.getCskdz2()) || !MdaUtils.isEmpty(cipmod.getCskdz3()) || !MdaUtils.isEmpty(cipmod.getCskdz4()) || !MdaUtils.isEmpty(cipmod.getCskdz5()) || !MdaUtils.isEmpty(cipmod.getCskdz6()) || !MdaUtils.isEmpty(cipmod.getCskdz7()))) {
                return ValidResult.build(false, "请按顺序先输入COV收款人地址1");
            }
        }
        return null;
    }

    /**
     *   source:cipmod.0037.script
     */
    @Validate(path="setmod.setglg.setgll.%s.sespay.cipmod.cskdz2")
    public ValidResult checkCskdz2N1000(CipmodVo cipmod){
        SetgllVo setgllVo = getSetgll();
        if ("CIV".equals(setgllVo.getSftmt()) && "X".equalsIgnoreCase(cipmod.getCovflg())) {
            if(!MdaUtils.isEmpty(cipmod.getCskdz2())) {
                String errorMsg = this.filterCNYCIPS(cipmod.getCskdz2(), 70);
                if (StringUtils.isNotEmpty(errorMsg)) {
                    return ValidResult.build(false, errorMsg);
                }
                errorMsg = this.filtmarks1(cipmod.getCskdz2());
                if (StringUtils.isNotEmpty(errorMsg)) {
                    return ValidResult.build(false, errorMsg);
                }
            }
        }
        return null;
    }

    /**
     *   source:cipmod.0038.script
     */
    @Validate(path="setmod.setglg.setgll.%s.sespay.cipmod.cskdz3")
    public ValidResult checkCskdz3N1000(CipmodVo cipmod){
        SetgllVo setgllVo = getSetgll();
        if ("CIV".equals(setgllVo.getSftmt()) && "X".equalsIgnoreCase(cipmod.getCovflg())) {
            if(!MdaUtils.isEmpty(cipmod.getCskdz3())) {
                String errorMsg = this.filterCNYCIPS(cipmod.getCskdz3(), 70);
                if (StringUtils.isNotEmpty(errorMsg)) {
                    return ValidResult.build(false, errorMsg);
                }
                errorMsg = this.filtmarks1(cipmod.getCskdz3());
                if (StringUtils.isNotEmpty(errorMsg)) {
                    return ValidResult.build(false, errorMsg);
                }
            }
        }
        return null;
    }

    /**
     *   source:cipmod.0039.script
     */
    @Validate(path="setmod.setglg.setgll.%s.sespay.cipmod.cskdz4")
    public ValidResult checkCskdz4N1000(CipmodVo cipmod){
        SetgllVo setgllVo = getSetgll();
        if ("CIV".equals(setgllVo.getSftmt()) && "X".equalsIgnoreCase(cipmod.getCovflg())) {
            if(!MdaUtils.isEmpty(cipmod.getCskdz4())) {
                String errorMsg = this.filterCNYCIPS(cipmod.getCskdz4(), 70);
                if (StringUtils.isNotEmpty(errorMsg)) {
                    return ValidResult.build(false, errorMsg);
                }
                errorMsg = this.filtmarks1(cipmod.getCskdz4());
                if (StringUtils.isNotEmpty(errorMsg)) {
                    return ValidResult.build(false, errorMsg);
                }
            }
        }
        return null;
    }

    /**
     *   source:cipmod.0040.script
     */
    @Validate(path="setmod.setglg.setgll.%s.sespay.cipmod.cskdz5")
    public ValidResult checkCskdz5N1000(CipmodVo cipmod){
        SetgllVo setgllVo = getSetgll();
        if ("CIV".equals(setgllVo.getSftmt()) && "X".equalsIgnoreCase(cipmod.getCovflg())) {
            if(!MdaUtils.isEmpty(cipmod.getCskdz5())) {
                String errorMsg = this.filterCNYCIPS(cipmod.getCskdz5(), 70);
                if (StringUtils.isNotEmpty(errorMsg)) {
                    return ValidResult.build(false, errorMsg);
                }
                errorMsg = this.filtmarks1(cipmod.getCskdz5());
                if (StringUtils.isNotEmpty(errorMsg)) {
                    return ValidResult.build(false, errorMsg);
                }
            }
        }
        return null;
    }

    /**
     *   source:cipmod.0041.script
     */
    @Validate(path="setmod.setglg.setgll.%s.sespay.cipmod.cskdz6")
    public ValidResult checkCskdz6N1000(CipmodVo cipmod){
        SetgllVo setgllVo = getSetgll();
        if ("CIV".equals(setgllVo.getSftmt()) && "X".equalsIgnoreCase(cipmod.getCovflg())) {
            if(!MdaUtils.isEmpty(cipmod.getCskdz6())) {
                String errorMsg = this.filterCNYCIPS(cipmod.getCskdz6(), 70);
                if (StringUtils.isNotEmpty(errorMsg)) {
                    return ValidResult.build(false, errorMsg);
                }
                errorMsg = this.filtmarks1(cipmod.getCskdz6());
                if (StringUtils.isNotEmpty(errorMsg)) {
                    return ValidResult.build(false, errorMsg);
                }
            }
        }
        return null;
    }

    /**
     *   source:cipmod.0042.script
     */
    @Validate(path="setmod.setglg.setgll.%s.sespay.cipmod.cskdz7")
    public ValidResult checkCskdz7N1000(CipmodVo cipmod){
        SetgllVo setgllVo = getSetgll();
        if ("CIV".equals(setgllVo.getSftmt()) && "X".equalsIgnoreCase(cipmod.getCovflg())) {
            if(!MdaUtils.isEmpty(cipmod.getCskdz7())) {
                String errorMsg = this.filterCNYCIPS(cipmod.getCskdz7(), 70);
                if (StringUtils.isNotEmpty(errorMsg)) {
                    return ValidResult.build(false, errorMsg);
                }
                errorMsg = this.filtmarks1(cipmod.getCskdz7());
                if (StringUtils.isNotEmpty(errorMsg)) {
                    return ValidResult.build(false, errorMsg);
                }
            }
        }
        return null;
    }

    /**
     *   source:cipmod.0043.script
     */
    @Validate(path="setmod.setglg.setgll.%s.sespay.cipmod.czj1mc")
    public ValidResult checkCzj1mcN1000(CipmodVo cipmod){
        SetgllVo setgllVo = getSetgll();
        if ("CIV".equals(setgllVo.getSftmt()) && "X".equalsIgnoreCase(cipmod.getCovflg())) {
            if(!MdaUtils.isEmpty(cipmod.getCzj1mc())) {
                String errorMsg = this.checkcipsname(cipmod.getCzj1mc(), 120);
                if (StringUtils.isNotEmpty(errorMsg)) {
                    return ValidResult.build(false, errorMsg);
                }
                errorMsg = this.filtmarks1(cipmod.getCzj1mc());
                if (StringUtils.isNotEmpty(errorMsg)) {
                    return ValidResult.build(false, errorMsg);
                }
            }
        }
        return null;
    }

    /**
     *   source:cipmod.0044.script
     */
    @Validate(path="setmod.setglg.setgll.%s.sespay.cipmod.covfuy")
    public ValidResult checkCovfuyN1000(CipmodVo cipmod){
        SetgllVo setgllVo = getSetgll();
        if ("CIV".equals(setgllVo.getSftmt()) && "X".equalsIgnoreCase(cipmod.getCovflg())) {
            if(!MdaUtils.isEmpty(cipmod.getCovfuy())) {
                String errorMsg = this.filterCNYCIPS(cipmod.getCovfuy(), 140);
                if (StringUtils.isNotEmpty(errorMsg)) {
                    return ValidResult.build(false, errorMsg);
                }
                errorMsg = this.filtmarks1(cipmod.getCovfuy());
                if (StringUtils.isNotEmpty(errorMsg)) {
                    return ValidResult.build(false, errorMsg);
                }
            }
            String errorMsg = this.checkcommet(cipmod.getCovfuy(), cipmod.getCovfy2(), cipmod.getCovfy3(), cipmod.getCovfy4(), 210);
            if (StringUtils.isNotEmpty(errorMsg)) {
                return ValidResult.build(false, errorMsg);
            }
            if(MdaUtils.isEmpty(cipmod.getCovfuy())
                    && (!MdaUtils.isEmpty(cipmod.getCovfy2())
                    || !MdaUtils.isEmpty(cipmod.getCovfy3())
                    || !MdaUtils.isEmpty(cipmod.getCovfy4()))) {
                return ValidResult.build(false, "请按顺序先输入COV附言1");
            }
        }
        return null;
    }

    /**
     *   source:cipmod.0046.script
     */
    @Validate(path="setmod.setglg.setgll.%s.sespay.cipmod.covfy2")
    public ValidResult checkCovfy2N1000(CipmodVo cipmod){
        SetgllVo setgllVo = getSetgll();
        if ("CIV".equals(setgllVo.getSftmt()) && "X".equalsIgnoreCase(cipmod.getCovflg())) {
            if (!MdaUtils.isEmpty(cipmod.getCovfy2())) {
                String errorMsg = this.filterCNYCIPS(cipmod.getCovfy2(), 140);
                if (StringUtils.isNotEmpty(errorMsg)) {
                    return ValidResult.build(false, errorMsg);
                }
                errorMsg = this.filtmarks1(cipmod.getCovfy2());
                if (StringUtils.isNotEmpty(errorMsg)) {
                    return ValidResult.build(false, errorMsg);
                }
            }
        }
        return null;
    }

    /**
     *   source:cipmod.0045.script
     */
    @Validate(path="setmod.setglg.setgll.%s.sespay.cipmod.covfy3")
    public ValidResult checkCovfy3N1000(CipmodVo cipmod){
        SetgllVo setgllVo = getSetgll();
        if ("CIV".equals(setgllVo.getSftmt()) && "X".equalsIgnoreCase(cipmod.getCovflg())) {
            if (!MdaUtils.isEmpty(cipmod.getCovfy3())) {
                String errorMsg = this.filterCNYCIPS(cipmod.getCovfy3(), 140);
                if (StringUtils.isNotEmpty(errorMsg)) {
                    return ValidResult.build(false, errorMsg);
                }
                errorMsg = this.filtmarks1(cipmod.getCovfy3());
                if (StringUtils.isNotEmpty(errorMsg)) {
                    return ValidResult.build(false, errorMsg);
                }
            }
        }
        return null;
    }

    /**
     *   source:cipmod.0047.script
     */
    @Validate(path="setmod.setglg.setgll.%s.sespay.cipmod.covfy4")
    public ValidResult checkCovfy4N1000(CipmodVo cipmod){
        SetgllVo setgllVo = getSetgll();
        if ("CIV".equals(setgllVo.getSftmt()) && "X".equalsIgnoreCase(cipmod.getCovflg())) {
            if (!MdaUtils.isEmpty(cipmod.getCovfy4())) {
                String errorMsg = this.filterCNYCIPS(cipmod.getCovfy4(), 140);
                if (StringUtils.isNotEmpty(errorMsg)) {
                    return ValidResult.build(false, errorMsg);
                }
                errorMsg = this.filtmarks1(cipmod.getCovfy4());
                if (StringUtils.isNotEmpty(errorMsg)) {
                    return ValidResult.build(false, errorMsg);
                }
            }
        }
        return null;
    }

    /**
     *   source:cipmod.0049.script
     */
    @Validate(path="setmod.setglg.setgll.%s.sespay.cipmod.pyebchkey")
    public ValidResult checkPyebchkeyN1000(CipmodVo cipmod){
        SetgllVo setgllVo = getSetgll();
        if ("CIV".equals(setgllVo.getSftmt()) || "CIU".equals(setgllVo.getSftmt())) {
            if(MdaUtils.isEmpty(cipmod.getSkfyzh())) {
                if(MdaUtils.isEmpty(cipmod.getPyebchkey()) && MdaUtils.isEmpty(cipmod.getPyebchnam())) {
                    return ValidResult.build(false, "开户行行号和开户行名称至少填一项");
                }
            }
        }
        return null;
    }

    /**
     *   source:cipmod.0050.script
     */
    @Validate(path="setmod.setglg.setgll.%s.sespay.cipmod.cskrmc")
    public ValidResult checkCskrmcN1000(CipmodVo cipmod){
        SetgllVo setgllVo = getSetgll();
        if ("CIV".equals(setgllVo.getSftmt()) && "X".equalsIgnoreCase(cipmod.getCovflg())) {
            if(MdaUtils.isEmpty(cipmod.getCskrmc())
                    && MdaUtils.isEmpty(cipmod.getCskdz1())
                    && MdaUtils.isEmpty(cipmod.getCskdz2())
                    && MdaUtils.isEmpty(cipmod.getCskdz3())
                    && MdaUtils.isEmpty(cipmod.getCskdz4())
                    && MdaUtils.isEmpty(cipmod.getCskdz5())
                    && MdaUtils.isEmpty(cipmod.getCskdz6())
                    && MdaUtils.isEmpty(cipmod.getCskdz7())) {
                return ValidResult.build(false, "收款人名称和收款人地址至少填一项");
            }
            if (!MdaUtils.isEmpty(cipmod.getCskrmc())) {
                String errorMsg = this.checkcipsname(cipmod.getCskrmc(), 120);
                if (StringUtils.isNotEmpty(errorMsg)) {
                    return ValidResult.build(false, errorMsg);
                }
                errorMsg = this.filtmarks1(cipmod.getCskrmc());
                if (StringUtils.isNotEmpty(errorMsg)) {
                    return ValidResult.build(false, errorMsg);
                }
            }
        }
        return null;
    }

    /**
     *   source:cipmod.0054.script
     */
    @Validate(path="setmod.setglg.setgll.%s.sespay.cipmod.cskrzh")
    public ValidResult checkCskrzhN1000(CipmodVo cipmod){
        SetgllVo setgllVo = getSetgll();
        if ("CIV".equals(setgllVo.getSftmt()) && "X".equalsIgnoreCase(cipmod.getCovflg())) {
            List<Bnm> bnmList = bnmMapper.getBnmByKjcyhh(cipmod.getCskkhh());
            if (bnmList != null && bnmList.size() > 0) {
                Bnm bnm = bnmList.get(0);
                String jinwbs = bnm.getJinwbs();
                if(MdaUtils.compareTo(jinwbs,"DMPT") == 0
                        && MdaUtils.isEmpty(cipmod.getCskrzh())
                        && MdaUtils.isEmpty(cipmod.getCskrmc())) {
                    return ValidResult.build(false, "收款人账号和收款人名称两者至少填一项");
                }
            }
        }
        return null;
    }

    /**
     *   source:cipmod.0067.script
     */
    @Validate(path="setmod.setglg.setgll.%s.sespay.cipmod.fkkhmc")
    public ValidResult checkFkkhmcN1000(CipmodVo cipmod){
        SetgllVo setgllVo = getSetgll();
        if ("CIV".equals(setgllVo.getSftmt())) {
            if (StringUtils.isNotEmpty(cipmod.getFkkhmc())) {
                String errorMsg = this.checkcipsname(cipmod.getFkkhmc(), 120);
                if (StringUtils.isNotEmpty(errorMsg)) {
                    return ValidResult.build(false, errorMsg);
                }
            }
        }
        return null;
    }

    /**
     *   source:cipmod.0068.script
     */
    @Validate(path="setmod.setglg.setgll.%s.sespay.cipmod.skkhhm")
    public ValidResult checkSkkhhmN1000(CipmodVo cipmod){
        SetgllVo setgllVo = getSetgll();
        if ("CIV".equals(setgllVo.getSftmt())) {
            if (StringUtils.isNotEmpty(cipmod.getSkkhhm())) {
                String errorMsg = this.checkcipsname(cipmod.getSkkhhm(), 120);
                if (StringUtils.isNotEmpty(errorMsg)) {
                    return ValidResult.build(false, errorMsg);
                }
                errorMsg = this.filtmarks1(cipmod.getSkkhhm());
                if (StringUtils.isNotEmpty(errorMsg)) {
                    return ValidResult.build(false, errorMsg);
                }
            }
        }
        return null;
    }

    /**
     *   source:cipmod.0069.script
     */
    @Validate(path="setmod.setglg.setgll.%s.sespay.cipmod.fkhdzh")
    public ValidResult checkFkhdzhN1000(CipmodVo cipmod){
        SetgllVo setgllVo = getSetgll();
        if ("CIV".equals(setgllVo.getSftmt())) {
            if (StringUtils.isNotEmpty(cipmod.getFkhdzh())) {
                String errorMsg = this.filterCNYCIPS(cipmod.getFkhdzh(), 70);
                if (StringUtils.isNotEmpty(errorMsg)) {
                    return ValidResult.build(false, errorMsg);
                }
                errorMsg = this.filtmarks1(cipmod.getFkhdzh());
                if (StringUtils.isNotEmpty(errorMsg)) {
                    return ValidResult.build(false, errorMsg);
                }
            }
        }
        return null;
    }

    /**
     *   source:cipmod.0070.script
     */
    @Validate(path="setmod.setglg.setgll.%s.sespay.cipmod.skkhdz")
    public ValidResult checkSkkhdzN1000(CipmodVo cipmod){
        SetgllVo setgllVo = getSetgll();
        if ("CIV".equals(setgllVo.getSftmt())) {
            if (StringUtils.isNotEmpty(cipmod.getSkkhdz())) {
                String errorMsg = this.filterCNYCIPS(cipmod.getSkkhdz(), 70);
                if (StringUtils.isNotEmpty(errorMsg)) {
                    return ValidResult.build(false, errorMsg);
                }
                errorMsg = this.filtmarks1(cipmod.getSkkhdz());
                if (StringUtils.isNotEmpty(errorMsg)) {
                    return ValidResult.build(false, errorMsg);
                }
            }
        }
        return null;
    }

    /**
     *   source:cipmod.0071.script
     */
    @Validate(path="setmod.setglg.setgll.%s.sespay.cipmod.skkhhh")
    public ValidResult checkSkkhhhN1000(CipmodVo cipmod){
        SetgllVo setgllVo = getSetgll();
        if ("CIV".equals(setgllVo.getSftmt())) {
            if ("CPTOPN".equals(SettleContext.getTransName())) {
                return null;
            }
            if( MdaUtils.isEmpty(cipmod.getSkkhhh())
                    && MdaUtils.isEmpty(cipmod.getSkkhhm())
                    && MdaUtils.isEmpty(cipmod.getSkkhdz())) {
                return ValidResult.build(false, "收款行行号，名称和地址至少填一项");
            }
        }
        return null;
    }

    /**
     *   source:cipmod.0073.script
     */
    @Validate(path="setmod.setglg.setgll.%s.sespay.cipmod.feiyon")
    public ValidResult checkFeiyonN1000(CipmodVo cipmod){
        SetgllVo setgllVo = getSetgll();
        if ("CIU".equals(setgllVo.getSftmt())) {
            if (StringUtils.isNotEmpty(cipmod.getFufeih()) && cipmod.getFeiyon().compareTo(BigDecimal.ZERO) == 0) {
                return ValidResult.build(false, "请输入费用");
            }
        }
        return null;
    }

    /**
     *   source:cipmod.0074.script
     */
    @Validate(path="setmod.setglg.setgll.%s.sespay.cipmod.fufeih")
    public ValidResult checkFufeihN1000(CipmodVo cipmod){
        SetgllVo setgllVo = getSetgll();
        if ("CIU".equals(setgllVo.getSftmt())) {
            if (StringUtils.isEmpty(cipmod.getFufeih())
                    && cipmod.getFeiyon().compareTo(BigDecimal.ZERO) > 0) {
                return ValidResult.build(false, "请输入付费行");
            }
        }
        return null;
    }

    /**
     *   source:cipmod.0075.script
     */
    @Validate(path="setmod.setglg.setgll.%s.sespay.cipmod.feiyn2")
    public ValidResult checkFeiyn2N1000(CipmodVo cipmod){
        SetgllVo setgllVo = getSetgll();
        if ("CIU".equals(setgllVo.getSftmt())) {
            if (StringUtils.isNotEmpty(cipmod.getFfeih2()) && cipmod.getFeiyn2().compareTo(BigDecimal.ZERO) == 0) {
                return ValidResult.build(false, "请输入费用");
            }
        }
        return null;
    }

    /**
     *   source:cipmod.0076.script
     */
    @Validate(path="setmod.setglg.setgll.%s.sespay.cipmod.ffeih2")
    public ValidResult checkFfeih2N1000(CipmodVo cipmod){
        SetgllVo setgllVo = getSetgll();
        if ("CIU".equals(setgllVo.getSftmt())) {
            if (StringUtils.isEmpty(cipmod.getFfeih2())
                    && cipmod.getFeiyn2().compareTo(BigDecimal.ZERO) > 0) {
                return ValidResult.build(false, "请输入付费行");
            }
        }
        return null;
    }

    /**
     *   source:cipmod.0079.script
     */
    @Validate(path="setmod.setglg.setgll.%s.sespay.cipmod.fkrkhh")
    public ValidResult checkFkrkhhN1000(CipmodVo cipmod){
        SetgllVo setgllVo = getSetgll();
        if ("CIU".equals(setgllVo.getSftmt()) || "CIV".equals(setgllVo.getSftmt())) {
            if(MdaUtils.isEmpty(cipmod.getFkfyzh())
                    && MdaUtils.isEmpty(cipmod.getFkrkhh())
                    && MdaUtils.isEmpty(cipmod.getFukrhm())) {
                return ValidResult.build(false, "开户行行号和开户行名称至少填一项");
            }
        }
        return null;
    }

    /**
     *   source:cipmod.0082.script
     */
    @Validate(path="setmod.setglg.setgll.%s.sespay.cipmod.feecod")
    public ValidResult checkFeecodN1000(CipmodVo cipmod){
        SetgllVo setgllVo = getSetgll();
        if ("CIU".equals(setgllVo.getSftmt())) {
            if (StringUtils.isEmpty(cipmod.getFeecod())) {
                return errorMandatory();
            }
        }
        return null;
    }

    /**
     *   source:cipmod.0085.script
     */
    @Validate(path="setmod.setglg.setgll.%s.sespay.cipmod.recsehbchnam")
    public ValidResult checkRecsehbchnamN1000(CipmodVo cipmod){
        SetgllVo setgllVo = getSetgll();
        if ("CIV".equals(setgllVo.getSftmt()) || "CIU".equals(setgllVo.getSftmt())) {
            if (!MdaUtils.isEmpty(cipmod.getRecsehbchnam())) {
                BnmVo bnmVo = new BnmVo();
                bnmVo.setCyzgbs("IDPT");
                bnmVo.setBchname(cipmod.getRecsehbchnam());
                bnmVo.setBch(cipmod.getRecsehbch());
                List<Bnm> bnmList = bnmMapper.getCyhhCyzwmc(bnmVo);
                if (bnmList == null || bnmList.size() == 0) {
                    return ValidResult.build(false, "收款间接参与者名称错误，请重新输入");
                } else {
                    Bnm bnm = bnmList.get(0);
                    if (!bnm.getKjcyhh().equals(cipmod.getRecsehbch())) {
                        return ValidResult.build(false, "收款间接参与者行号错误，请重新输入");
                    }
                    if (!bnm.getCyzwmc().equals(cipmod.getRecsehbchnam())) {
                        return ValidResult.build(false, "收款间接参与者名称错误，请重新输入");
                    }
                }
            }
        }
        return null;
    }

    /**
     *   source:cipmod.0087.script
     */
    @Validate(path="setmod.setglg.setgll.%s.sespay.cipmod.stasehbchnam")
    public ValidResult checkStasehbchnamN1000(CipmodVo cipmod){
        SetgllVo setgllVo = getSetgll();
        if ("CIV".equals(setgllVo.getSftmt()) || "CIU".equals(setgllVo.getSftmt())) {
            if (!MdaUtils.isEmpty(cipmod.getStasehbchnam())) {
                BnmVo bnmVo = new BnmVo();
                bnmVo.setCyzgbs("IDPT");
                bnmVo.setBchname(cipmod.getStasehbchnam());
                bnmVo.setBch(cipmod.getStasehbch());
                List<Bnm> bnmList = bnmMapper.getCyhhCyzwmc(bnmVo);
                if (bnmList == null || bnmList.size() == 0) {
                    return ValidResult.build(false, "付款间接参与者名称错误，请重新输入");
                } else {
                    Bnm bnm = bnmList.get(0);
                    if (!bnm.getKjcyhh().equals(cipmod.getStasehbch())) {
                        return ValidResult.build(false, "付款间接参与者行号错误，请重新输入");
                    }
                    if (!bnm.getCyzwmc().equals(cipmod.getStasehbchnam())) {
                        return ValidResult.build(false, "付款间接参与者名称错误，请重新输入");
                    }
                }
            }
        }
        return null;
    }

    /**
     *   source:cipmod.0089.script
     */
    @Validate(path="setmod.setglg.setgll.%s.sespay.cipmod.zjg1hh")
    public ValidResult checkZjg1hhN1000(CipmodVo cipmod){
        SetgllVo setgllVo = getSetgll();
        if ("CIV".equals(setgllVo.getSftmt()) || "CIU".equals(setgllVo.getSftmt())) {
            String errorMsg = this.filtmarks1(cipmod.getZjg1hh());
            if (StringUtils.isNotEmpty(errorMsg)) {
                return ValidResult.build(false, errorMsg);
            }
        }
        return null;
    }

    /**
     *   source:cipmod.0090.script
     */
    @Validate(path="setmod.setglg.setgll.%s.sespay.cipmod.zjg2hh")
    public ValidResult checkZjg2hhN1000(CipmodVo cipmod){
        SetgllVo setgllVo = getSetgll();
        if ("CIV".equals(setgllVo.getSftmt()) || "CIU".equals(setgllVo.getSftmt())) {
            String errorMsg = this.filtmarks1(cipmod.getZjg2hh());
            if (StringUtils.isNotEmpty(errorMsg)) {
                return ValidResult.build(false, errorMsg);
            }
        }
        return null;
    }

    /**
     *   source:cipmod.0091.script
     */
    @Validate(path="setmod.setglg.setgll.%s.sespay.cipmod.pyebchnam")
    public ValidResult checkPyebchnamN1000(CipmodVo cipmod){
        SetgllVo setgllVo = getSetgll();
        if ("CIV".equals(setgllVo.getSftmt()) || "CIU".equals(setgllVo.getSftmt())) {
            String errorMsg = this.filterCNYCIPS(cipmod.getPyebchnam(), 140);
            if (StringUtils.isNotEmpty(errorMsg)) {
                return ValidResult.build(false, errorMsg);
            }
            errorMsg = this.filtmarks1(cipmod.getPyebchnam());
            if (StringUtils.isNotEmpty(errorMsg)) {
                return ValidResult.build(false, errorMsg);
            }
            if ("CIU".equals(setgllVo.getSftmt())) {
                int flg = 0;
                if((MdaUtils.isEmpty(cipmod.getPyebchkey()) && MdaUtils.isEmpty(cipmod.getSkfyzh())) || (!MdaUtils.isEmpty(cipmod.getPyebchkey()) && ! MdaUtils.isEmpty(cipmod.getSkfyzh()))) {
                    flg = 1;
                }
                if(!MdaUtils.isEmpty(cipmod.getSkfyzh()) && MdaUtils.isEmpty(cipmod.getPyebchnam()) && flg == 0 ) {
                    return errorMandatory();
                }
            }
        }
        return null;
    }

    /**
     *   source:cipmod.0092.script
     */
    @Validate(path="setmod.setglg.setgll.%s.sespay.cipmod.czjjg1")
    public ValidResult checkCzjjg1N1000(CipmodVo cipmod){
        SetgllVo setgllVo = getSetgll();
        if ("CIV".equals(setgllVo.getSftmt()) && "X".equalsIgnoreCase(cipmod.getCovflg())) {
            String errorMsg = this.filtmarks1(cipmod.getCzjjg1());
            if (StringUtils.isNotEmpty(errorMsg)) {
                return ValidResult.build(false, errorMsg);
            }
        }
        return null;
    }

    /**
     *   source:cipmod.0093.script
     */
    @Validate(path="setmod.setglg.setgll.%s.sespay.cipmod.fuyns1")
    public ValidResult checkFuyns1N1000(CipmodVo cipmod){
        //CIPS要求：不允许有特殊字符，输入附言有先后顺序
        SetgllVo setgllVo = getSetgll();
        if ("CIV".equals(setgllVo.getSftmt()) || "CIU".equals(setgllVo.getSftmt())) {
            if( MdaUtils.isEmpty(cipmod.getFuyns1())
                    && (!MdaUtils.isEmpty(cipmod.getFuyns2())
                    || !MdaUtils.isEmpty(cipmod.getFuyns3())
                    || ! MdaUtils.isEmpty(cipmod.getFuyns4()))) {
                return ValidResult.build(false, "请按顺序先输入致收款人银行附言1栏位");
            }
            String errorMsg = this.filtmarks1(cipmod.getFuyns1());
            if (StringUtils.isNotEmpty(errorMsg)) {
                return ValidResult.build(false, errorMsg);
            }
            if (filtmarks(errorMsg)) {
                return ValidResult.build(false, "此栏位不能出现半角:,不能以-,.。，．开始");
            }
        }
        return null;
    }

    /**
     *   source:cipmod.0098.script
     */
    @Validate(path="setmod.setglg.setgll.%s.sespay.cipmod.fuyns2")
    public ValidResult checkFuyns2N1000(CipmodVo cipmod){
        //CIPS要求：不允许有特殊字符
        SetgllVo setgllVo = getSetgll();
        if ("CIV".equals(setgllVo.getSftmt()) || "CIU".equals(setgllVo.getSftmt())) {
            String errorMsg = this.filtmarks1(cipmod.getFuyns2());
            if (StringUtils.isNotEmpty(errorMsg)) {
                return ValidResult.build(false, errorMsg);
            }
            if (filtmarks(errorMsg)) {
                return ValidResult.build(false, "此栏位不能出现半角:,不能以-,.。，．开始");
            }
        }
        return null;
    }

    /**
     *   source:cipmod.0099.script
     */
    @Validate(path="setmod.setglg.setgll.%s.sespay.cipmod.fuyns3")
    public ValidResult checkFuyns3N1000(CipmodVo cipmod){
        //CIPS要求：不允许有特殊字符
        SetgllVo setgllVo = getSetgll();
        if ("CIV".equals(setgllVo.getSftmt()) || "CIU".equals(setgllVo.getSftmt())) {
            String errorMsg = this.filtmarks1(cipmod.getFuyns3());
            if (StringUtils.isNotEmpty(errorMsg)) {
                return ValidResult.build(false, errorMsg);
            }
            if (filtmarks(errorMsg)) {
                return ValidResult.build(false, "此栏位不能出现半角:,不能以-,.。，．开始");
            }
        }
        return null;
    }

    /**
     *   source:cipmod.0100.script
     */
    @Validate(path="setmod.setglg.setgll.%s.sespay.cipmod.fuyns4")
    public ValidResult checkFuyns4N1000(CipmodVo cipmod){
        //CIPS要求：不允许有特殊字符
        SetgllVo setgllVo = getSetgll();
        if ("CIV".equals(setgllVo.getSftmt()) || "CIU".equals(setgllVo.getSftmt())) {
            String errorMsg = this.filtmarks1(cipmod.getFuyns4());
            if (StringUtils.isNotEmpty(errorMsg)) {
                return ValidResult.build(false, errorMsg);
            }
            if (filtmarks(errorMsg)) {
                return ValidResult.build(false, "此栏位不能出现半角:,不能以-,.。，．开始");
            }
        }
        return null;
    }

    @Validate(path="setmod.setglg.setgll.%s.sespay.cipmod.commen")
    public ValidResult checkCommen(CipmodVo cipmod){
        SetgllVo setgllVo = getSetgll();
        if ("CIV".equals(setgllVo.getSftmt()) || "CIU".equals(setgllVo.getSftmt())) {
            if (StringUtils.isNotEmpty(cipmod.getCommen())) {
                String lineBefore = Strings.getLine(cipmod.getCommen(), 1);
                if(MdaUtils.isEmpty(lineBefore)) {
                    return ValidResult.build(false, "此栏位不能以回车换行开始");
                } else {
                    if (this.filtmarks(cipmod.getCommen())) {
                        return ValidResult.build(false, "此栏位不能出现半角:,不能以-,.。，．开始");
                    }
                }
                int length = this.chineseFldLength(cipmod.getCommen());
                if (length > 140) {
                    return ValidResult.build(false, Strings.getText("长度不能超过$1", 140));
                }
                String errorMsg = this.filtmarks1(cipmod.getCommen());
                if (StringUtils.isNotEmpty(errorMsg)) {
                    return ValidResult.build(false, errorMsg);
                }
            }
        }
        return null;
    }

    /**
     * 获取父模型
     * @return
     */
    private SetgllVo getSetgll() {
        return (SetgllVo)getParent();
    }

    /**
     * 校验cips付款人收款人地址的公共方法
     * @param address
     * @return
     */
    private ValidResult validateAddress(String address) {
        String errorMsg = this.filterCNYCIPS(address, 70);
        if (StringUtils.isNotEmpty(errorMsg)) {
            return ValidResult.build(false, errorMsg);
        }
        errorMsg = this.filtmarks1(address);
        if (StringUtils.isNotEmpty(errorMsg)) {
            return ValidResult.build(false, errorMsg);
        }
        return null;
    }

    /**
     * 校验cips附言公共方法
     * @param marks
     * @return
     */
    private ValidResult validateMark(String marks) {
        String errorMsg = this.filterCNYCIPS(marks, 140);
        if (StringUtils.isNotEmpty(errorMsg)) {
            return ValidResult.build(false, errorMsg);
        }
        errorMsg = this.filtmarks1(marks);
        if (StringUtils.isNotEmpty(errorMsg)) {
            return ValidResult.build(false, errorMsg);
        }
        return null;
    }

    /**
     *   source:trnmod.0161.script
     */
    public String filterCNYCIPS(String argTxt, int argNum) {
        //特殊标点符号过滤
        if(this.filtmarks(argTxt)) {
            return "此栏位不能出现半角:,不能以-,.。，．开始";
        }
        //长度限制过滤
        int length = chineseFldLength(argTxt);
        if(length > argNum) {
            return Strings.getText("长度不能超过$1", argNum);
        }
        return "";
    }
    /**
     *   source:trnmod.0164.script
     */
    public String checkcipsname(String argTxt, int argNum) {
        //特殊标点符号过滤
        if(this.filtmarks(argTxt)) {
            return "此栏位不能出现半角:,不能以-,.。，．开始";
        }
        //长度限制过滤
        int length = Strings.len(argTxt);
        if(MdaUtils.compareTo(length, argNum) > 0) {
            return Strings.getText("输入不能超过$1个汉字或$2个字符", argNum/2, argNum);
        }
        return "";
    }

    /**
     *   source:trnmod.0157.script
     */
    public boolean filtmarks(String strtxt) {
        //!人民币跨境过滤标点符号函数
        //!==================================================
        //!返回值：过滤成功与否
        //!变量:   过滤栏位内容
        //!==================================================
        //不能包含:
        //不能以-,.。，．开头
        if (StringUtils.isEmpty(strtxt)) {
            return false;
        }
        if (strtxt.contains(":")) {
            return true;
        }
        String[] marks = {"-",",",".","，","。","．"};
        for (String m : marks) {
            if (strtxt.startsWith(m)) {
                return true;
            }
        }
        return false;
    }

    /**
     *   source:trnmod.0150.script
     */
    public int chineseFldLength(String txt) {
        //!判断字符串长度（含中文）函数
        //!一个汉字当作一个字符来计算
        //!=========================================
        //!返回值：实际字符长度
        //!变量：   txt     待判断的字符串
        //!           number  小数部分数字
        //!=========================================
        //计算规则:UTF-8的长度和GBK计算长度的差异来进行计算
        if (StringUtils.isEmpty(txt)) {
            return 0;
        }
        return txt.trim().length();
    }

    /**
     *   source:cipmod.0088.script
     */
    public String filtmarks1(String strtxt) {
        //!cips特殊符号校验<>'R0000220
        //!==================================================
        //!返回值：过滤成功与否 不能包含 <'>&"
        //!变量:   过滤栏位内容
        //!==================================================
        if (StringUtils.isEmpty(strtxt)) {
            return "";
        }
        boolean flag = false;
        String[] marks = {"<", "'", ">", "&", "\""};
        for (String m : marks) {
            if (strtxt.contains(m)) {
                flag = true;
                break;
            }
        }
        if (flag) {
            return "此栏位不允许输入<,>,&,'和\"";
        }
        return "";
    }

    /**
     *   source:trnmod.0162.script
     */
    public String checkcipsadd(String argTxt,String argTxt2,String argTxt3,String argTxt4,String argTxt5,String argTxt6,String argTxt7,int argNum) {
        //长度判断
        String allargTxt = argTxt + argTxt2 + argTxt3 + argTxt4 + argTxt5 + argTxt6 + argTxt7;
        int length = Strings.len(allargTxt);
        if (length > argNum) {
            return Strings.getText("此系列地址输入长度超过了$1个字符或$2个汉字", argNum, argNum/2);
        }
        return "";
    }

    /**
     *   source:trnmod.0163.script
     */
    public String checkcommet(String argtext,String argtext2,String argtext3,String argtext4,int argNum) {
        //长度判断
        String allargTxt = argtext + argtext2 + argtext3 + argtext4;
        //  $lenth = chineseFldLength( $allargTxt )
        int length = Strings.len(allargTxt);
        if(length > argNum) {
            return Strings.getText("此系列附言输入长度超过了$1个字符或$2个汉字", argNum, argNum/2);
        }
        return "";
    }
}
