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

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.mt9xx.tag.tag970.*;
import com.brilliance.isc.swift.objmtconvert.result.MtResult;

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

/**
 * @author hedonghao
 * @date 2023/2/24
 */
public class MT970Creator extends AbsMTCreator {
    @Status("M")
    @TagName("20")
    @FieldDescription("Transaction Reference Number")
    @TagRegex("16x")
    //20
    private String tranReferenceNum;
    @Status("M")
    @TagName("25")
    @FieldDescription("Account Identification")
    @TagRegex("35x")
    //25
    private String accountIc;
    @Status("M")
    @TagName("28C")
    @FieldDescription("Statement Number/Sequence Number")
    @TagRegex("5n[/5n]")
    //28C
    private String statNumSeqNum;

    @Status("M")
    @TagName({"60F","60M"})
    @FieldDescription("Opening Balance")
    @TagRegex({"1!a6!n3!a15d","1!a6!n3!a15d"})
    //60a
    private DcDateCurAmtTagXXX dateCurAmtTag60a;
    @Status("O")
    @TagName("61")
    @FieldDescription("Statement Line")
    @TagRegex("6!n[4!n]2a[1!a]15d1!a3!c16x[//16x]<crlf>[34x]")
    //61
    private List statLine;
    @Status("M")
    @TagName({"60F","60M"})
    @FieldDescription("Closing Balance")
    @TagRegex({"1!a6!n3!a15d","1!a6!n3!a15d"})
    //62a
    private DcDateCurAmtTagXXX dateCurAmtTag62a;
    @Status("O")
    @TagName("64")
    @FieldDescription("Closing Available Balance")
    @TagRegex("1!a6!n3!a15d")
    //64
    private DcDateCurAmtTagXXX dateCurAmtTag64;

    public String getAccountIc() {
        return accountIc;
    }

    public void setAccountIc(String accountIc) {
        this.accountIc = accountIc;
    }

    public String getStatNumSeqNum() {
        return statNumSeqNum;
    }

    public void setStatNumSeqNum(String statNumSeqNum) {
        this.statNumSeqNum = statNumSeqNum;
    }

    public DcDateCurAmtTagXXX getDateCurAmtTag60a() {
        return dateCurAmtTag60a;
    }

    public void setDateCurAmtTag60a(DcDateCurAmtTagXXX dateCurAmtTag60a) {
        this.dateCurAmtTag60a = dateCurAmtTag60a;
    }

    public DcDateCurAmtTagXXX getDateCurAmtTag62a() {
        return dateCurAmtTag62a;
    }

    public void setDateCurAmtTag62a(DcDateCurAmtTagXXX dateCurAmtTag62a) {
        this.dateCurAmtTag62a = dateCurAmtTag62a;
    }

    public DcDateCurAmtTagXXX getDateCurAmtTag64() {
        return dateCurAmtTag64;
    }

    public void setDateCurAmtTag64(DcDateCurAmtTagXXX dateCurAmtTag64) {
        this.dateCurAmtTag64 = dateCurAmtTag64;
    }

    public List getStatLine() {
        return statLine;
    }

    public void setStatLine(List statLine) {
        this.statLine = statLine;
    }


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

    public MT970Creator() {
    }

    public String getTranReferenceNum() {
        return tranReferenceNum;
    }

    public void setTranReferenceNum(String tranReferenceNum) {
        this.tranReferenceNum = tranReferenceNum;
    }

    /**
     * 需要编写组装报文逻辑，调用set方法即可
     *
     * @return
     */
    public void pack() {
        //  MtResult mtResult = new MtResult();
        List<AbsTagCreate> tagCreateList=new ArrayList<>();
        try {
            tagCreateList.add(new Tag20Creator(this));
            tagCreateList.add(new Tag25Creator(this));
            tagCreateList.add(new Tag28CCreator(this));
            tagCreateList.add(new Tag60aCreator(this));
            tagCreateList.add(new Tag61Creator(this));
            tagCreateList.add(new Tag62aCreator(this));
            tagCreateList.add(new Tag64Creator(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;
    }


}
