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

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

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

/**
 * @author gaosheng
 * @date 2023/3/2
 */
public class MT752Creator extends AbsMTCreator {

    @Status("M")
    @TagName("20")
    @FieldDescription("DocumentaryCreditNumber")
    @TagRegex("16x")
    //20
    private String documentaryCreditNumber;

    @Status("M")
    @TagName("21")
    @FieldDescription("PresentingBanksReference")
    @TagRegex("16x")
    //21
    private String presentingBanksReference;

    @Status("M")
    @TagName("23")
    @FieldDescription("FurtherIdentification")
    @TagRegex("16x")
    //23
    private String furtherIdentification;

    @Status("M")
    @TagName("30")
    @FieldDescription("DateofAdviceofDiscrepancyorMailing")
    @TagRegex("6!n")
    //30
    private String dateofAdviceofDiscrepancyorMailing;

    @Status("O")
    @TagName("32B")
    @FieldDescription("TotalAmountAdvised")
    @TagRegex("3!a15d")
    //32B
    private DcDateCurAmtTagXXX totalAmountAdvised;

    @Status("O")
    @TagName("71D")
    @FieldDescription("ChargesDeducted")
    @TagRegex("6*35z")
    //71D
    private String chargesDeducted;

    @Status("O")
    @TagName("33a")
    @FieldDescription("NetAmount")
    @TagRegex({"6!n3!a15d","3!a15d"})
    //33a
    private DcDateCurAmtTagXXX netAmount;

    @Status("O")
    @TagName({"53A","53B","53D"})
    @FieldDescription("SendersCorrespondent")
    @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 sendersCorrespondent;

    @Status("O")
    @TagName({"54A","54B","54D"})
    @FieldDescription("ReceiversCorrespondent")
    @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 receiversCorrespondent;

    @Status("O")
    @TagName("72Z")
    @FieldDescription("SendertoReceiverInformation")
    @TagRegex("6*35z")
    //72Z
    private String sendertoReceiverInformation;

    @Status("O")
    @TagName("79Z")
    @FieldDescription("Narrative")
    @TagRegex("35*50z")
    //79Z
    private String narrative;

    public String getDocumentaryCreditNumber() {
        return documentaryCreditNumber;
    }

    public void setDocumentaryCreditNumber(String documentaryCreditNumber) {
        this.documentaryCreditNumber = documentaryCreditNumber;
    }

    public String getPresentingBanksReference() {
        return presentingBanksReference;
    }

    public void setPresentingBanksReference(String presentingBanksReference) {
        this.presentingBanksReference = presentingBanksReference;
    }

    public String getFurtherIdentification() {
        return furtherIdentification;
    }

    public void setFurtherIdentification(String furtherIdentification) {
        this.furtherIdentification = furtherIdentification;
    }

    public String getDateofAdviceofDiscrepancyorMailing() {
        return dateofAdviceofDiscrepancyorMailing;
    }

    public void setDateofAdviceofDiscrepancyorMailing(String dateofAdviceofDiscrepancyorMailing) {
        this.dateofAdviceofDiscrepancyorMailing = dateofAdviceofDiscrepancyorMailing;
    }

    public DcDateCurAmtTagXXX getTotalAmountAdvised() {
        return totalAmountAdvised;
    }

    public void setTotalAmountAdvised(DcDateCurAmtTagXXX totalAmountAdvised) {
        this.totalAmountAdvised = totalAmountAdvised;
    }

    public String getChargesDeducted() {
        return chargesDeducted;
    }

    public void setChargesDeducted(String chargesDeducted) {
        this.chargesDeducted = chargesDeducted;
    }

    public DcDateCurAmtTagXXX getNetAmount() {
        return netAmount;
    }

    public void setNetAmount(DcDateCurAmtTagXXX netAmount) {
        this.netAmount = netAmount;
    }

    public ActnoBicAdrTagXXX getSendersCorrespondent() {
        return sendersCorrespondent;
    }

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

    public ActnoBicAdrTagXXX getReceiversCorrespondent() {
        return receiversCorrespondent;
    }

    public void setReceiversCorrespondent(ActnoBicAdrTagXXX receiversCorrespondent) {
        this.receiversCorrespondent = receiversCorrespondent;
    }

    public String getSendertoReceiverInformation() {
        return sendertoReceiverInformation;
    }

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

    public String getNarrative() {
        return narrative;
    }

    public void setNarrative(String narrative) {
        this.narrative = narrative;
    }

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



    /**
     * 需要编写组装报文逻辑，调用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 Tag23Creator(this));
            tagCreateList.add(new Tag30Creator(this));
            tagCreateList.add(new Tag32BCreator(this));
            tagCreateList.add(new Tag71DCreator(this));
            tagCreateList.add(new Tag33aCreator(this));
            tagCreateList.add(new Tag53aCreator(this));
            tagCreateList.add(new Tag54aCreator(this));
            tagCreateList.add(new Tag72ZCreator(this));
            tagCreateList.add(new Tag79ZCreator(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;
    }
}
