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.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.mt2xx.mt2XXAbsCreator.MT203AbsCreator;
import com.brilliance.isc.swift.objmtconvert.model.mt2xx.tag.tag203.Tag72Creator;
import com.brilliance.isc.swift.objmtconvert.model.mt2xx.tag.tag203.*;
import com.brilliance.isc.swift.objmtconvert.result.MtResult;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;

/**
 * @author huangmengyuan
 * @create 2023/2/27
 */
public class MT203Creator extends AbsMTCreator {
    @Status("M")
    @TagName("19")
    @FieldDescription("Sum of Amounts")
    @TagRegex("17d")
    //19
    private BigDecimal sumofAmounts;
    @Status("M")
    @TagName("30")
    @FieldDescription("Value Date")
    @TagRegex("6!n")
    //30
    private String valueDate;
    @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"})
    //52a
    private ActnoBicAdrTagXXX actnoBicAdr52a;
    @Status("O")
    @TagName({"53A","53B","53D"})
    @FieldDescription("Sender's Correspondent")
    @TagRegex({"[/1!a][/34x]<crlf>4!a2!a2!c[3!c]","[/1!a][/34x]<crlf>[35x]","[/1!a][/34x]<crlf>4*35x"})
    //53a
    private ActnoBicAdrTagXXX actnoBicAdr53a;
    @Status("O")
    @TagName({"54A","54B","54D"})
    @FieldDescription("Sender's Correspondent")
    @TagRegex({"[/1!a][/34x]<crlf>4!a2!a2!c[3!c]","[/1!a][/34x]<crlf>[35x]","[/1!a][/34x]<crlf>4*35x"})
    //54a
    private ActnoBicAdrTagXXX actnoBicAdr54a;
    @Status("O")
    @TagName("72")
    @FieldDescription("Sender to Receiver Information")
    @TagRegex("6*35x")
    //72
    private String sendertoReceiverInformation;
    //循环域
    private List<MT203AbsCreator> cycleDomain;

    public BigDecimal getSumofAmounts() {
        return sumofAmounts;
    }

    public void setSumofAmounts(BigDecimal sumofAmounts) {
        this.sumofAmounts = sumofAmounts;
    }

    public String getValueDate() {
        return valueDate;
    }

    public void setValueDate(String valueDate) {
        this.valueDate = valueDate;
    }

    public ActnoBicAdrTagXXX getActnoBicAdr52a() {
        return actnoBicAdr52a;
    }

    public void setActnoBicAdr52a(ActnoBicAdrTagXXX actnoBicAdr52a) {
        this.actnoBicAdr52a = actnoBicAdr52a;
    }

    public ActnoBicAdrTagXXX getActnoBicAdr53a() {
        return actnoBicAdr53a;
    }

    public void setActnoBicAdr53a(ActnoBicAdrTagXXX actnoBicAdr53a) {
        this.actnoBicAdr53a = actnoBicAdr53a;
    }

    public ActnoBicAdrTagXXX getActnoBicAdr54a() {
        return actnoBicAdr54a;
    }

    public void setActnoBicAdr54a(ActnoBicAdrTagXXX actnoBicAdr54a) {
        this.actnoBicAdr54a = actnoBicAdr54a;
    }

    public String getSendertoReceiverInformation() {
        return sendertoReceiverInformation;
    }

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

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

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

    public MT203Creator() {
        super();
    }

//    public MT203Creator(String jsonData) throws Exception {
//        super(jsonData);
//    }

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

    @Override
    public void pack() {
       // MtResult mtResult = new MtResult();
        List<AbsTagCreate> tagCreateList=new ArrayList<>();
        try{
            tagCreateList.add(new Tag19Creator(this));
            tagCreateList.add(new Tag30Creator(this));
            tagCreateList.add(new Tag52aCreator(this));
            tagCreateList.add(new Tag53aCreator(this));
            tagCreateList.add(new Tag54aCreator(this));
            tagCreateList.add(new Tag72Creator(this));
            tagCreateList.add(new TagCycleCreator(this));

            dealTags(tagCreateList);

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