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

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.AbsMTCreator;
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.mt7xx.tag.tag730.*;
import com.brilliance.isc.swift.objmtconvert.result.MtResult;
import java.util.ArrayList;
import java.util.List;

/**
 * @author wuzhe
 * @date 2023/2/28
 */

public class MT730Creator extends AbsMTCreator {
    @Status("M")
    @TagName("20")
    @FieldDescription("Sender's Reference")
    @TagRegex("16x")
    //20
    private String senderReference;
    @Status("M")
    @TagName("21")
    @FieldDescription("Receiver's Reference")
    @TagRegex("16x")
    //21
    private String receiverReference;
    @Status("O")
    @TagName("25")
    @FieldDescription("Account Identification")
    @TagRegex("35x")
    //25
    private String accountIdentification;
    @Status("M")
    @TagName("30")
    @FieldDescription("Date of Message Being Acknowledged")
    @TagRegex("6!n")
    //30
    private String dateofMessageBeingAcknowledged;
    @Status("O")
    @TagName({"32B","32D"})
    @FieldDescription("Amount of Charges")
    @TagRegex({"3!a15d","6!n3!a15d"})
    //32a
    private DcDateCurAmtTagXXX amountofCharges;
    @Status("O")
    @TagName({"57A","57D"})
    @FieldDescription("Account With Bank")
    @TagRegex({"[/1!a][/34x]<crlf>4!a2!a2!c[3!c]","[/1!a][/34x]<crlf>4*35x"})
    //57a
    private ActnoBicAdrTagXXX accountWithBank;
    @Status("O")
    @TagName("71D")
    @FieldDescription("Charges")
    @TagRegex("6*35z")
    //71D
    private ActnoBicAdrTagXXX charges;
    @Status("O")
    @TagName("72Z")
    @FieldDescription("Sender to Receiver Information")
    @TagRegex("6*35z")
    //72Z
    private ActnoBicAdrTagXXX sendertoReceiverInformation;
    @Status("O")
    @TagName("79Z")
    @FieldDescription("Narrative")
    @TagRegex("35*50z")
    //79Z
    private String narrative;

    //20
    public String getSenderReference() {
        return senderReference;
    }

    public void setSenderReference(String senderReference) {
        this.senderReference = senderReference;
    }

    //21
    public String getReceiverReference() {
        return receiverReference;
    }

    public void setReceiverReference(String receiverReference) {
        this.receiverReference = receiverReference;
    }

    //25
    public String getAccountIdentification() {
        return accountIdentification;
    }

    public void setAccountIdentification(String accountIdentification) {
        this.accountIdentification = accountIdentification;
    }

    //30
    public String getDateofMessageBeingAcknowledged() {
        return dateofMessageBeingAcknowledged;
    }

    public void setDateofMessageBeingAcknowledged(String dateofMessageBeingAcknowledged) {
        this.dateofMessageBeingAcknowledged = dateofMessageBeingAcknowledged;
    }

    //32a
    public DcDateCurAmtTagXXX getAmountofCharges() {
        return amountofCharges;
    }

    public void setAmountofCharges(DcDateCurAmtTagXXX amountofCharges) {
        this.amountofCharges = amountofCharges;
    }

    //57a
    public ActnoBicAdrTagXXX getAccountWithBank() {
        return accountWithBank;
    }

    public void setAccountWithBank(ActnoBicAdrTagXXX accountWithBank) {
        this.accountWithBank = accountWithBank;
    }

    //71D
    public ActnoBicAdrTagXXX getCharges() {
        return charges;
    }

    public void setCharges(ActnoBicAdrTagXXX charges) {
        this.charges = charges;
    }

    //72Z
    public ActnoBicAdrTagXXX getSendertoReceiverInformation() {
        return sendertoReceiverInformation;
    }

    public void setSendertoReceiverInformation(ActnoBicAdrTagXXX sendertoReceiverInformation) {
        this.sendertoReceiverInformation = sendertoReceiverInformation;
    }

    //79Z
    public String getNarrative() {
        return narrative;
    }

    public void setNarrative(String narrative) {
        this.narrative = narrative;
    }


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

    public MT730Creator() {
        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 Tag25Creator(this));
            tagCreateList.add(new Tag30Creator(this));
            tagCreateList.add(new Tag32aCreator(this));
            tagCreateList.add(new Tag57aCreator(this));
            tagCreateList.add(new Tag71DCreator(this));
            tagCreateList.add(new Tag72ZCreator(this));
            tagCreateList.add(new Tag79ZCreator(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;
    }

}

