package com.brilliance.isc.swift.objmtconvert.model.mt2xx;

import com.brilliance.isc.swift.objmtconvert.annotation.FieldDescription;
import com.brilliance.isc.swift.objmtconvert.annotation.Status;
import com.brilliance.isc.swift.objmtconvert.annotation.TagName;
import com.brilliance.isc.swift.objmtconvert.annotation.TagRegex;
import com.brilliance.isc.swift.objmtconvert.model.AbsTagCreate;
import com.brilliance.isc.swift.objmtconvert.model.commontag.ActnoBicAdrTagXXX;
import com.brilliance.isc.swift.objmtconvert.model.commontag.DcDateCurAmtTagXXX;
import com.brilliance.isc.swift.objmtconvert.model.mt2xx.tag.tag205common.*;
import com.brilliance.isc.swift.objmtconvert.model.mt2xx.tag.tag205cov.*;
import com.brilliance.isc.swift.objmtconvert.result.MtResult;

import java.util.ArrayList;
import java.util.List;

/**
 * @Description：
 * @Author：夏猛
 * @CreateTime：2023/2/27 16:43
 **/
public class MT205COVCreator extends MT205Creator{

    //50a
    @Status("M")
    @TagName({"50A","50F","50K"})
    @FieldDescription("Ordering Customer")
    @TagRegex({"[/34x]<crlf>4!a2!a2!c[3!c]","35x<crlf>4*(1!n/33x)","[/34x]<crlf>4*35x"})
    private ActnoBicAdrTagXXX orderingCustomer;

    //52a
    @Status("O")
    @TagName({"52A","52D"})
    @FieldDescription("Ordering Institution")
    @TagRegex({"[/1!a][/34x]<crlf>4!a2!a2!c[3!c]","[/1!a][/34x]<crlf>4*35x"})
    private ActnoBicAdrTagXXX orderingInstitutionB;

    //56a
    @Status("O")
    @TagName({"56A","56C","56D"})
    @FieldDescription("Intermediary Institution")
    @TagRegex({"[/1!a][/34x]<crlf>4!a2!a2!c[3!c]","/34x","[/1!a][/34x]<crlf>4*35x"})
    private ActnoBicAdrTagXXX intermediaryInstitution;

    //57a
    @Status("O")
    @TagName({"57A","57B","57C","57D"})
    @FieldDescription("Account With Institution")
    @TagRegex({"[/1!a][/34x]<crlf>4!a2!a2!c[3!c]","[/1!a][/34x]<crlf>[35x]","/34x","[/1!a][/34x]<crlf>4*35x"})
    private ActnoBicAdrTagXXX accountWithInstitutionB;

    //59a
    @Status("M")
    @TagName({"59","59A","59F"})
    @FieldDescription("Beneficiary Customer")
    @TagRegex({"[/34x]<crlf>4*35x\",[/34x]<crlf>4!a2!a2!c[3!c]","35x<crlf>4*(1!n/33x)"})
    private ActnoBicAdrTagXXX beneficiaryCustomer;

    //70
    @Status("O")
    @TagName("70")
    @FieldDescription("Remittance Information")
    @TagRegex("4*35x")
    private String remittanceInformation;

    //72
    @Status("O")
    @TagName("72")
    @FieldDescription("Sender to Receiver Information")
    @TagRegex("6*35x")
    private String sendertoReceiverInformationB;

    //33B
    @Status("O")
    @TagName("33B")
    @FieldDescription("Currency/Instructed Amount")
    @TagRegex("3!a15d")
    private DcDateCurAmtTagXXX currencyInstructedAmount;

    public ActnoBicAdrTagXXX getOrderingCustomer() {
        return orderingCustomer;
    }

    public void setOrderingCustomer(ActnoBicAdrTagXXX orderingCustomer) {
        this.orderingCustomer = orderingCustomer;
    }


    public ActnoBicAdrTagXXX getIntermediaryInstitution() {
        return intermediaryInstitution;
    }

    public void setIntermediaryInstitution(ActnoBicAdrTagXXX intermediaryInstitution) {
        this.intermediaryInstitution = intermediaryInstitution;
    }

    public ActnoBicAdrTagXXX getOrderingInstitutionB() {
        return orderingInstitutionB;
    }

    public void setOrderingInstitutionB(ActnoBicAdrTagXXX orderingInstitutionB) {
        this.orderingInstitutionB = orderingInstitutionB;
    }

    public ActnoBicAdrTagXXX getAccountWithInstitutionB() {
        return accountWithInstitutionB;
    }

    public void setAccountWithInstitutionB(ActnoBicAdrTagXXX accountWithInstitutionB) {
        this.accountWithInstitutionB = accountWithInstitutionB;
    }

    public ActnoBicAdrTagXXX getBeneficiaryCustomer() {
        return beneficiaryCustomer;
    }

    public void setBeneficiaryCustomer(ActnoBicAdrTagXXX beneficiaryCustomer) {
        this.beneficiaryCustomer = beneficiaryCustomer;
    }

    public String getRemittanceInformation() {
        return remittanceInformation;
    }

    public void setRemittanceInformation(String remittanceInformation) {
        this.remittanceInformation = remittanceInformation;
    }

    public String getSendertoReceiverInformationB() {
        return sendertoReceiverInformationB;
    }

    public void setSendertoReceiverInformationB(String sendertoReceiverInformationB) {
        this.sendertoReceiverInformationB = sendertoReceiverInformationB;
    }

    public DcDateCurAmtTagXXX getCurrencyInstructedAmount() {
        return currencyInstructedAmount;
    }

    public void setCurrencyInstructedAmount(DcDateCurAmtTagXXX currencyInstructedAmount) {
        this.currencyInstructedAmount = currencyInstructedAmount;
    }

    public MT205COVCreator(String msgType) {
        super(msgType);
    }

    public MT205COVCreator() {
        super();
    }

    /**
     * 需要编写组装报文逻辑，调用set方法即可
     *
     * @return
     */
    public void pack() {
        //MtResult mtResult = new MtResult();
        List<AbsTagCreate> tagCreateList=new ArrayList<>();
        try {
            tagCreateList.add(new Tag20Creator(this));
            tagCreateList.add(new Tag21Creator(this));
            tagCreateList.add(new Tag13CCreator(this));
            tagCreateList.add(new Tag32ACreator(this));
            tagCreateList.add(new Tag52aCreator(this));
            tagCreateList.add(new Tag53aCreator(this));
            tagCreateList.add(new Tag56aCreator(this));
            tagCreateList.add(new Tag57aCreator(this));
            tagCreateList.add(new Tag58aCreator(this));
            tagCreateList.add(new Tag72Creator(this));

            tagCreateList.add(new TagB50aCreator(this));
            tagCreateList.add(new TagB52aCreator(this));
            tagCreateList.add(new TagB56aCreator(this));
            tagCreateList.add(new TagB57aCreator(this));
            tagCreateList.add(new TagB59aCreator(this));
            tagCreateList.add(new TagB70Creator(this));
            tagCreateList.add(new TagB72Creator(this));
            tagCreateList.add(new TagB33BCreator(this));

            dealTags(tagCreateList);

            mtResult.setMessage(abstractMT.message());
        } catch (Exception e) {
            e.printStackTrace();
            mtResult.setSuccess(false);
            mtResult.addDescription(e.getLocalizedMessage());
        }

       // return mtResult;
    }

    public MtResult unpack() {
        return null;
    }

}