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.MT201AbsCreator;
import com.brilliance.isc.swift.objmtconvert.model.mt2xx.tag.tag201.*;
import com.brilliance.isc.swift.objmtconvert.result.MtResult;

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

/**
 * @Description：MT201Creator
 * @Author：夏猛
 * @CreateTime：2023/2/24 10:46
 **/
public class MT201Creator extends AbsMTCreator {

    //19
    @Status("M")
    @TagName("19")
    @FieldDescription("Sum of Amounts")
    @TagRegex("17d")
    private BigDecimal sumofAmounts;

    //30
    @Status("M")
    @TagName("30")
    @FieldDescription("Value Date")
    @TagRegex("6!n")
    private String valueDate;

    //53B
    @Status("O")
    @TagName("53B")
    @FieldDescription("Sender's Correspondent")
    @TagRegex("[/1!a][/34x]<crlf>[35x]")
    private ActnoBicAdrTagXXX sendersCorrespondent;

    //72
    @Status("O")
    @TagName("72")
    @FieldDescription("Sender to Receiver Information")
    @TagRegex("6*35x")
    private String sendertoReceiverInformationA;

    //循环集合
    private List<MT201AbsCreator> 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 getSendersCorrespondent() {
        return sendersCorrespondent;
    }

    public void setSendersCorrespondent(ActnoBicAdrTagXXX sendersCorrespondent) {
        this.sendersCorrespondent = sendersCorrespondent;
    }

    public String getSendertoReceiverInformationA() {
        return sendertoReceiverInformationA;
    }

    public void setSendertoReceiverInformationA(String sendertoReceiverInformationA) {
        this.sendertoReceiverInformationA = sendertoReceiverInformationA;
    }

    public List getCycleDomain() {
        return cycleDomain;
    }

    public void setCycleDomain(List cycleDomain) {
        this.cycleDomain = cycleDomain;
    }
    public void setCycleDomain(LinkedList cycleDomain) {
        this.cycleDomain = cycleDomain;
    }

    public MT201Creator() {
        super();
    }

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

    /**
     * 需要编写组装报文逻辑，调用set方法即可
     *
     * @return
     */
    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 Tag53BCreator(this));
            tagCreateList.add(new TagA72Creator(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;
    }

    public MtResult unpack() {
        return null;
    }
}