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

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

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

public class MT110AbsCreator extends AbsMTCreator {
    @Status("M")
    @TagName("21")
    @FieldDescription("Cheque Number")
    @TagRegex("16x")
    //21
    private String chequeNumber;
    @Status("M")
    @TagName("30")
    @FieldDescription("Date of Issue")
    @TagRegex("6!n")
    //30
    private String dateofIssue;
    @Status("M")
    @TagName({"32A","32B"})
    @FieldDescription("Amount")
    @TagRegex({"6!n3!a15d","3!a15d"})
    //32a
    private DcDateCurAmtTagXXX Amount32a;
    @Status("O")
    @TagName({"50A","50F","50K"})
    @FieldDescription("Payer")
    @TagRegex({"[/34x]<crlf>4!a2!a2!c[3!c]","35x<crlf>4*(1!n/33x)","[/34x]<crlf>4*35x"})
    //50a
    private ActnoBicAdrTagXXX payer50a;
    @Status("O")
    @TagName({"52A","52B","52D"})
    @FieldDescription("Drawer Bank")
    @TagRegex({"[/1!a][/34x]<crlf>4!a2!a2!c[3!c]","[/1!a][/34x]<crlf>[35x]","[/1!a][/34x]<crlf>4*35x"})
    //52a
    private ActnoBicAdrTagXXX drawerBank52a;
    @Status("M")
    @TagName({"59","59F"})
    @FieldDescription("Payee")
    @TagRegex({"[/34x]<crlf>4*35x","[/34x]<crlf>4*(1!n/33x)"})
    //59a
    private ActnoBicAdrTagXXX payee59a;

    public String getChequeNumber() {
        return chequeNumber;
    }

    public void setChequeNumber(String chequeNumber) {
        this.chequeNumber = chequeNumber;
    }

    public String getDateofIssue() {
        return dateofIssue;
    }

    public void setDateofIssue(String dateofIssue) {
        this.dateofIssue = dateofIssue;
    }

    public DcDateCurAmtTagXXX getAmount32a() {
        return Amount32a;
    }

    public void setAmount32a(DcDateCurAmtTagXXX amount32a) {
        Amount32a = amount32a;
    }

    public ActnoBicAdrTagXXX getPayer50a() {
        return payer50a;
    }

    public void setPayer50a(ActnoBicAdrTagXXX payer50a) {
        this.payer50a = payer50a;
    }

    public ActnoBicAdrTagXXX getDrawerBank52a() {
        return drawerBank52a;
    }

    public void setDrawerBank52a(ActnoBicAdrTagXXX drawerBank52a) {
        this.drawerBank52a = drawerBank52a;
    }

    public ActnoBicAdrTagXXX getPayee59a() {
        return payee59a;
    }

    public void setPayee59a(ActnoBicAdrTagXXX payee59a) {
        this.payee59a = payee59a;
    }

    public MT110AbsCreator(String jsonData) throws Exception {
        super(jsonData);
    }

    public MT110AbsCreator() {
        super();
    }

    /**
     * 需要编写组装报文逻辑，调用set方法即可
     *
     * @return
     */
    public void pack() {
     //   MtResult mtResult = new MtResult();
        List<AbsTagCreate> tagCreateList=new ArrayList<>();
        try {
            tagCreateList.add(new Tag21Creator(this));
            tagCreateList.add(new Tag30Creator(this));
            tagCreateList.add(new Tag32aCreator(this));
            tagCreateList.add(new Tag50aCreator(this));
            tagCreateList.add(new Tag52aCreator(this));
            tagCreateList.add(new Tag59aCreator(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;
    }
}
