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

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

/**
 * @author hedonghao
 * @date 2023/2/24
 */
public class MT972Creator 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 accIdentifi;
    @Status("M")
    @TagName("28C")
    @FieldDescription("Statement Number/Sequence Number")
    @TagRegex("5n[/5n]")
    //28C
    private String statSeqNumber;
    @Status("M")
    @TagName({"60F","60M"})
    @FieldDescription("Opening Balance")
    @TagRegex({"1!a6!n3!a15d","1!a6!n3!a15d"})
    //60a
    private DcDateCurAmtTagXXX dcDateCurAmtTag60a;

    @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({"62F","62M"})
    @FieldDescription("Closing Balance")
    @TagRegex({"1!a6!n3!a15d","1!a6!n3!a15d"})
    //62a
    private DcDateCurAmtTagXXX dcDateCurAmtTag62a;
    @Status("O")
    @TagName("64")
    @FieldDescription("Closing Available Balance")
    @TagRegex("1!a6!n3!a15d")
    //64
    private DcDateCurAmtTagXXX dcDateCurAmtTag64;
   /* //25
    public String accountIc;
    //62F
    public String finalCloBaln;*/


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

    public MT972Creator() {
        super();
    }

    public String getTranReferenceNum() {
        return tranReferenceNum;
    }

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

    public String getAccIdentifi() {
        return accIdentifi;
    }

    public void setAccIdentifi(String accIdentifi) {
        this.accIdentifi = accIdentifi;
    }

    public String getStatSeqNumber() {
        return statSeqNumber;
    }

    public void setStatSeqNumber(String statSeqNumber) {
        this.statSeqNumber = statSeqNumber;
    }

    public DcDateCurAmtTagXXX getDcDateCurAmtTag60a() {
        return dcDateCurAmtTag60a;
    }

    public void setDcDateCurAmtTag60a(DcDateCurAmtTagXXX dcDateCurAmtTag60a) {
        this.dcDateCurAmtTag60a = dcDateCurAmtTag60a;
    }

    public List getStatLine() {
        return statLine;
    }

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

    public DcDateCurAmtTagXXX getDcDateCurAmtTag62a() {
        return dcDateCurAmtTag62a;
    }

    public void setDcDateCurAmtTag62a(DcDateCurAmtTagXXX dcDateCurAmtTag62a) {
        this.dcDateCurAmtTag62a = dcDateCurAmtTag62a;
    }

    public DcDateCurAmtTagXXX getDcDateCurAmtTag64() {
        return dcDateCurAmtTag64;
    }

    public void setDcDateCurAmtTag64(DcDateCurAmtTagXXX dcDateCurAmtTag64) {
        this.dcDateCurAmtTag64 = dcDateCurAmtTag64;
    }

    /**
     * 需要编写组装报文逻辑，调用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;
    }


}
