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.mt9XXAbsCreator.MT942AbsCreator;
import com.brilliance.isc.swift.objmtconvert.model.mt9xx.tag.tag942.*;
import com.brilliance.isc.swift.objmtconvert.result.MtResult;
import java.util.ArrayList;
import java.util.List;

/**
 * @author hedonghao
 * @date 2023/2/24
 */
public class MT942Creator extends AbsMTCreator {
    @Status("M")
    @TagName("20")
    @FieldDescription("Transaction Reference Number")
    @TagRegex("16x")
    //20
    private String tranReferenceNum;
    @Status("O")
    @TagName("21")
    @FieldDescription("Related Reference")
    @TagRegex("16x")
    //21
    private String relatedReferen;
    @Status("M")
    @TagName({"25","25P"})
    @FieldDescription("Account Identification")
    @TagRegex({"35x","35x<crlf>4!a2!a2!c[3!c]"})
    //25a
    private ActnoBicAdrTagXXX accountIdentification;
    @Status("M")
    @TagName("28C")
    @FieldDescription("Statement Number/Sequence Number")
    @TagRegex("5n[/5n]")
    //28C
    private String stattNumSeqNum;
    @Status("M")
    @TagName("34F")
    @FieldDescription("Debit/(Debit and Credit) Floor Limit Indicator")
    @TagRegex("3!a[1!a]15d")
    //34F
    private DcDateCurAmtTagXXX debitDebitandCreditFloorLimitIndicator;
    @Status("O")
    @TagName("34F")
    @FieldDescription("Credit Floor Limit Indicator")
    @TagRegex("3!a[1!a]15d")
    //34F
    private DcDateCurAmtTagXXX creditFloorLimitIndicator;
    @Status("M")
    @TagName("13D")
    @FieldDescription("Date/Time Indication")
    @TagRegex("6!n4!n1!x4!n")
    //13D
    private String dateIndication;
    //循环
    private List<MT942AbsCreator> cycleDomain;
    @Status("O")
    @TagName("90D")
    @FieldDescription("Number and Sum of Entries")
    @TagRegex("5n3!a15d")
    //90D
    private DcDateCurAmtTagXXX numberandSumofEntries90D;
    @Status("O")
    @TagName("90C")
    @FieldDescription("Number and Sum of Entries")
    @TagRegex("5n3!a15d")
    //90C
    private DcDateCurAmtTagXXX numberandSumofEntries90C;
    @Status("O")
    @TagName("86")
    @FieldDescription("Information to Account Owner")
    @TagRegex("6*65x")
    //86
    private String infoAccontOwner;


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


    public MT942Creator() {
        super();
    }

    public String getTranReferenceNum() {
        return tranReferenceNum;
    }

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

    public String getRelatedReferen() {
        return relatedReferen;
    }

    public void setRelatedReferen(String relatedReferen) {
        this.relatedReferen = relatedReferen;
    }

    public ActnoBicAdrTagXXX getAccountIdentification() {
        return accountIdentification;
    }

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

    public List<MT942AbsCreator> getCycleDomain() {
        return cycleDomain;
    }

    public void setCycleDomain(List<MT942AbsCreator> cycleDomain) {
        this.cycleDomain = cycleDomain;
    }

    public String getStattNumSeqNum() {
        return stattNumSeqNum;
    }

    public void setStattNumSeqNum(String stattNumSeqNum) {
        this.stattNumSeqNum = stattNumSeqNum;
    }

    public String getDateIndication() {
        return dateIndication;
    }

    public void setDateIndication(String dateIndication) {
        this.dateIndication = dateIndication;
    }

    public DcDateCurAmtTagXXX getDebitDebitandCreditFloorLimitIndicator() {
        return debitDebitandCreditFloorLimitIndicator;
    }

    public void setDebitDebitandCreditFloorLimitIndicator(DcDateCurAmtTagXXX debitDebitandCreditFloorLimitIndicator) {
        this.debitDebitandCreditFloorLimitIndicator = debitDebitandCreditFloorLimitIndicator;
    }

    public DcDateCurAmtTagXXX getCreditFloorLimitIndicator() {
        return creditFloorLimitIndicator;
    }

    public void setCreditFloorLimitIndicator(DcDateCurAmtTagXXX creditFloorLimitIndicator) {
        this.creditFloorLimitIndicator = creditFloorLimitIndicator;
    }

    public DcDateCurAmtTagXXX getNumberandSumofEntries90D() {
        return numberandSumofEntries90D;
    }

    public void setNumberandSumofEntries90D(DcDateCurAmtTagXXX numberandSumofEntries90D) {
        this.numberandSumofEntries90D = numberandSumofEntries90D;
    }

    public DcDateCurAmtTagXXX getNumberandSumofEntries90C() {
        return numberandSumofEntries90C;
    }

    public void setNumberandSumofEntries90C(DcDateCurAmtTagXXX numberandSumofEntries90C) {
        this.numberandSumofEntries90C = numberandSumofEntries90C;
    }

    public String getInfoAccontOwner() {
        return infoAccontOwner;
    }

    public void setInfoAccontOwner(String infoAccontOwner) {
        this.infoAccontOwner = infoAccontOwner;
    }

    /**
     * 需要编写组装报文逻辑，调用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 Tag25aCreator(this));
            tagCreateList.add(new Tag28Creator(this));
            tagCreateList.add(new Tag34FCDreator(this));
            tagCreateList.add(new Tag34FCCreator(this));
            tagCreateList.add(new Tag13DCreator(this));
            tagCreateList.add(new TagCycleCreator(this));
            tagCreateList.add(new Tag90DCreator(this));
            tagCreateList.add(new Tag90CCreator(this));
            tagCreateList.add(new Tag86Creator(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;
    }


}
