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

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

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

/**
 * @author gechengyang
 * @date 2023/2/17
 */
public class MT103Creator extends AbsMTCreator {

    //参照官方文档定义报文第四栏位的属性
    @Status("M")
    @TagName("20")
    @FieldDescription("Sender's Reference")
    @TagRegex("16x")
    //20
    public String sendersReference;
    @Status("O")
    @TagName("13C")
    @FieldDescription("Time Indication")
    @TagRegex("/8c/4!n1!x4!n")
    //13C
    public List<String> timeIndication;
    @Status("M")
    @TagName("23B")
    @FieldDescription("Bank Operation Code")
    @TagRegex("4!c")
    //23B
    public String bankOperationCode;
    @Status("O")
    @TagName("23E")
    @FieldDescription("Instruction Code")
    @TagRegex("4!c[/30x]")
    //23E
    public List<String> instructionCode;
    @Status("O")
    @TagName("26T")
    @FieldDescription("Transaction Type Code")
    @TagRegex("3!c")
    //26T
    public String transactionTypeCode;
    @Status("M")
    @TagName("32A")
    @FieldDescription("Value Date/Currency/Interbank Settled Amount")
    @TagRegex("6!n3!a15d")
    //32A
    public DcDateCurAmtTagXXX valueDateCurrencyInterbankSettledAmount;
    @Status("O")
    @TagName("33B")
    @FieldDescription("Currency/Instructed Amount")
    @TagRegex("3!a15d")
    //33B
    public DcDateCurAmtTagXXX currencyInstructedAmount;
    @Status("O")
    @TagName("36")
    @FieldDescription("Exchange Rate")
    @TagRegex("12d")
    //36
    public String exchangeRate;
    @Status("M")
    @TagName({"50A","50F","50K"})
    @FieldDescription("Ordering Customer")
    @TagRegex({"[/34x]<crlf>4!a2!a2!c[3!c]","35x<crlf>4*(1!n/33x)","[/34x]<crlf>4*35x"})
    //50a
    public ActnoBicAdrTagXXX orderingCustomer;
    @Status("O")
    @TagName("51A")
    @FieldDescription("Sending Institution")
    @TagRegex("[/1!a][/34x]<crlf>4!a2!a2!c[3!c]")
    //51A
    public ActnoBicAdrTagXXX sendingInstitution;
    @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
    public ActnoBicAdrTagXXX orderingInstitution;
    @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
    public ActnoBicAdrTagXXX sendersCorrespondent;
    @Status("O")
    @TagName({"54A","54B","54D"})
    @FieldDescription("Receiver'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
    public ActnoBicAdrTagXXX receiversCorrespondent;
    @Status("O")
    @TagName({"55A","55B","55D"})
    @FieldDescription("Third Reimbursement Institution")
    @TagRegex({"[/1!a][/34x]<crlf>4!a2!a2!c[3!c]","[/1!a][/34x]<crlf>[35x]","[/1!a][/34x]<crlf>4*35x"})
    //55a
    public ActnoBicAdrTagXXX thirdReimbursementInstitution;
    @Status("O")
    @TagName({"56A","56C","56D"})
    @FieldDescription("Intermediary Institution")
    @TagRegex({"[/1!a][/34x]<crlf>4!a2!a2!c[3!c]","/34x","[/1!a][/34x]<crlf>4*35x"})
    //56a
    public ActnoBicAdrTagXXX intermediaryInstitution;
    @Status("O")
    @TagName({"57A","57B","57C","57D"})
    @FieldDescription("Account With Institution")
    @TagRegex({"[/1!a][/34x]<crlf>4!a2!a2!c[3!c]","[/1!a][/34x]<crlf>[35x]","/34x","[/1!a][/34x]<crlf>4*35x"})
    //57a
    public ActnoBicAdrTagXXX accountWithInstitution;
    @Status("M")
    @TagName({"59","59A","59F"})
    @FieldDescription("Beneficiary Customer")
    @TagRegex({"[/34x]<crlf>4*35x","[/34x]<crlf>4!a2!a2!c[3!c]","[/34x]<crlf>4*(1!n/33x)"})
    //59a
    public ActnoBicAdrTagXXX beneficiaryCustomer;
    @Status("O")
    @TagName({"70"})
    @FieldDescription("Remittance Information")
    @TagRegex({"4*35x"})
    //70
    public String remittanceInformation;
    @Status("M")
    @TagName({"71A"})
    @FieldDescription("Details of Charges")
    @TagRegex({"3!a"})
    //71A
    public String detailsofCharges;
    @Status("O")
    @TagName({"71F"})
    @FieldDescription("Sender's Charges")
    @TagRegex({"3!a15d"})
    //71F
    public List<String> sendersCharges;
    @Status("O")
    @TagName({"71G"})
    @FieldDescription("Receiver's Charges")
    @TagRegex({"3!a15d"})
    //71G
    public String receiversCharges;
    @Status("O")
    @TagName({"72"})
    @FieldDescription("Sender to Receiver Information")
    @TagRegex({"6*35x"})
    //72
    public  String sendertoReceiverInformation;
    @Status("O")
    @TagName({"77B"})
    @FieldDescription("Regulatory Reporting")
    @TagRegex({"3*35x"})
    //77B
    public  String regulatoryReporting;

    public String getSendersReference() {
        return sendersReference;
    }

    public void setSendersReference(String sendersReference) {
        this.sendersReference = sendersReference;
    }

    public List<String> getTimeIndication() {
        return timeIndication;
    }

    public void setTimeIndication(List<String> timeIndication) {
        this.timeIndication = timeIndication;
    }

    public String getBankOperationCode() {
        return bankOperationCode;
    }

    public void setBankOperationCode(String bankOperationCode) {
        this.bankOperationCode = bankOperationCode;
    }

    public List<String> getInstructionCode() {
        return instructionCode;
    }

    public void setInstructionCode(List<String> instructionCode) {
        this.instructionCode = instructionCode;
    }

    public String getTransactionTypeCode() {
        return transactionTypeCode;
    }

    public void setTransactionTypeCode(String transactionTypeCode) {
        this.transactionTypeCode = transactionTypeCode;
    }

    public DcDateCurAmtTagXXX getValueDateCurrencyInterbankSettledAmount() {
        return valueDateCurrencyInterbankSettledAmount;
    }

    public void setValueDateCurrencyInterbankSettledAmount(DcDateCurAmtTagXXX valueDateCurrencyInterbankSettledAmount) {
        this.valueDateCurrencyInterbankSettledAmount = valueDateCurrencyInterbankSettledAmount;
    }

    public DcDateCurAmtTagXXX getCurrencyInstructedAmount() {
        return currencyInstructedAmount;
    }

    public void setCurrencyInstructedAmount(DcDateCurAmtTagXXX currencyInstructedAmount) {
        this.currencyInstructedAmount = currencyInstructedAmount;
    }

    public String getExchangeRate() {
        return exchangeRate;
    }

    public void setExchangeRate(String exchangeRate) {
        this.exchangeRate = exchangeRate;
    }

    public ActnoBicAdrTagXXX getOrderingCustomer() {
        return orderingCustomer;
    }

    public void setOrderingCustomer(ActnoBicAdrTagXXX orderingCustomer) {
        this.orderingCustomer = orderingCustomer;
    }

    public ActnoBicAdrTagXXX getSendingInstitution() {
        return sendingInstitution;
    }

    public void setSendingInstitution(ActnoBicAdrTagXXX sendingInstitution) {
        this.sendingInstitution = sendingInstitution;
    }

    public ActnoBicAdrTagXXX getOrderingInstitution() {
        return orderingInstitution;
    }

    public void setOrderingInstitution(ActnoBicAdrTagXXX orderingInstitution) {
        this.orderingInstitution = orderingInstitution;
    }

    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 ActnoBicAdrTagXXX getThirdReimbursementInstitution() {
        return thirdReimbursementInstitution;
    }

    public void setThirdReimbursementInstitution(ActnoBicAdrTagXXX thirdReimbursementInstitution) {
        this.thirdReimbursementInstitution = thirdReimbursementInstitution;
    }

    public ActnoBicAdrTagXXX getIntermediaryInstitution() {
        return intermediaryInstitution;
    }

    public void setIntermediaryInstitution(ActnoBicAdrTagXXX intermediaryInstitution) {
        this.intermediaryInstitution = intermediaryInstitution;
    }

    public ActnoBicAdrTagXXX getAccountWithInstitution() {
        return accountWithInstitution;
    }

    public void setAccountWithInstitution(ActnoBicAdrTagXXX accountWithInstitution) {
        this.accountWithInstitution = accountWithInstitution;
    }

    public ActnoBicAdrTagXXX getBeneficiaryCustomer() {
        return beneficiaryCustomer;
    }

    public void setBeneficiaryCustomer(ActnoBicAdrTagXXX beneficiaryCustomer) {
        this.beneficiaryCustomer = beneficiaryCustomer;
    }

    public String getRemittanceInformation() {
        return remittanceInformation;
    }

    public void setRemittanceInformation(String remittanceInformation) {
        this.remittanceInformation = remittanceInformation;
    }

    public String getDetailsofCharges() {
        return detailsofCharges;
    }

    public void setDetailsofCharges(String detailsofCharges) {
        this.detailsofCharges = detailsofCharges;
    }

    public List<String> getSendersCharges() {
        return sendersCharges;
    }

    public void setSendersCharges(List<String> sendersCharges) {
        this.sendersCharges = sendersCharges;
    }

    public String getReceiversCharges() {
        return receiversCharges;
    }

    public void setReceiversCharges(String receiversCharges) {
        this.receiversCharges = receiversCharges;
    }

    public String getSendertoReceiverInformation() {
        return sendertoReceiverInformation;
    }

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

    public String getRegulatoryReporting() {
        return regulatoryReporting;
    }

    public void setRegulatoryReporting(String regulatoryReporting) {
        this.regulatoryReporting = regulatoryReporting;
    }

    public MT103Creator(String msgType) throws Exception {
        super(msgType);
    }

    /**
     * 需要编写组装报文逻辑，调用set方法即可
     *
     * @return
     */
    @Override
    public void pack() {
       // MtResult mtResult = new MtResult();
        List<AbsTagCreate> tagCreateList=new ArrayList<>();
        try {
            tagCreateList.add(new Tag20Creator(this));
            tagCreateList.add(new Tag13CCreator(this));
            tagCreateList.add(new Tag23BCreator(this));
            tagCreateList.add(new Tag23ECreator(this));
            tagCreateList.add(new Tag26TCreator(this));
            tagCreateList.add(new Tag32ACreator(this));
            tagCreateList.add(new Tag33BCreator(this));
            tagCreateList.add(new Tag36Creator(this));
            tagCreateList.add(new Tag50aCreator(this));
            tagCreateList.add(new Tag51ACreator(this));
            tagCreateList.add(new Tag52aCreator(this));
            tagCreateList.add(new Tag53aCreator(this));
            tagCreateList.add(new Tag54aCreator(this));
            tagCreateList.add(new Tag55aCreator(this));
            tagCreateList.add(new Tag56aCreator(this));
            tagCreateList.add(new Tag57aCreator(this));
            tagCreateList.add(new Tag59aCreator(this));
            tagCreateList.add(new Tag70Creator(this));
            tagCreateList.add(new Tag71ACreator(this));
            tagCreateList.add(new Tag71FCreator(this));
            tagCreateList.add(new Tag71GCreator(this));
            tagCreateList.add(new Tag72Creator(this));
            tagCreateList.add(new Tag77BCreator(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;
    }
}
