package com.brilliance.isc.json2mx.pacs00200110;

import com.brilliance.isc.swift.objmtconvert.ext.XmlDate;
import com.brilliance.isc.swift.objmtconvert.manager.CreatorManager;
import com.brilliance.isc.swift.objmtconvert.model.mx.common.*;
import com.brilliance.isc.swift.objmtconvert.model.mx.pacs00200110.MXPacs00200110Creator;
import com.brilliance.isc.swift.objmtconvert.result.MxResult;
import org.junit.Test;

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

/**
 * @author zh
 * @create 2023-04-23-14:55
 * pacs00200110(MT199,MT299)
 */
public class Pacs00200110Test {

    @Test
    public void test_Pacs002() {
        MXPacs00200110Creator mxPacs00200110Creator = new MXPacs00200110Creator("pacs.002.001.10");

        mxPacs00200110Creator.setSenderBic("PSBCCNBJ");

        mxPacs00200110Creator.setSenderNm("zs");

        mxPacs00200110Creator.setReceiverBic("PSBCCNBJ");

        mxPacs00200110Creator.setReceiverNm("lisi");

//        bizMsgIdr为系统自动生成，如果需要手动给值也可
//        String bizMsgIdr = "1111111";
//        mxPacs00900108COVCreator.setBizMsgIdr(bizMsgIdr);
        mxPacs00200110Creator.setMsgDefIdr("swift.cbprplus.02");

        mxPacs00200110Creator.setBizSvc("dadad");

        mxPacs00200110Creator.setCreDt(new XmlDate());
        mxPacs00200110Creator.setCreDt(new XmlDate());

        mxPacs00200110Creator.setMsgId("sldks");

        mxPacs00200110Creator.setCreDtTm(new XmlDate());

        mxPacs00200110Creator.setOrgnlMsgId("dlahaj");

        mxPacs00200110Creator.setOrgnlMsgNmId("dasdasds");

        mxPacs00200110Creator.setOrgnlCreDtTm(new XmlDate());

        mxPacs00200110Creator.setOrgnlInstrId("znamhdasd");

        mxPacs00200110Creator.setOrgnlEndToEndId("ddadkama");

        mxPacs00200110Creator.setOrgnlTxId("ddada");

        mxPacs00200110Creator.setOrgnlUETR("8a562c67-ca16-48ba-b074-65581be6f001");

        mxPacs00200110Creator.setTxSts("ACCC");

        Party pty = new Party();
        pty.setNm("tianqi");
        PstlAdr pstlAdr = new PstlAdr();
        pstlAdr.setCtry("CN");
        pstlAdr.setBldgNb("111");
        pstlAdr.setBldgNm("ti mi");
        pstlAdr.setDept("xiao shan");
        pstlAdr.setCtrySubDvsn("tiger");
        pstlAdr.setDstrctNm("zzz");
        pstlAdr.setFlr("2");
        pstlAdr.setPstBx("40000");
        pstlAdr.setPstCd("103");
        pstlAdr.setRoom("103");
        pstlAdr.setStrtNm("xiao li Street");
        pstlAdr.setTwnLctnNm("xiao xiao");
        pstlAdr.setTwnNm("xiao xiao");
        pty.setPstlAdr(pstlAdr);
        IdentificationPty identificationPty = new IdentificationPty();
        OrgId orgId = new OrgId();
        identificationPty.setOrgId(orgId);
        orgId.setLei("11111111111111111111");
        orgId.setAnyBIC("PSBCCNBJ");
        List<Othr> othrList = new ArrayList<>();
        Othr othr = new Othr();
        othr.setId("adadsds");
        othrList.add(othr);
        orgId.setOthr(othrList);
        pty.setId(identificationPty);
        mxPacs00200110Creator.setOrgtr(pty);

        Rsn rsn = new Rsn();
        rsn.setCd("AC01");
        mxPacs00200110Creator.setRsn(rsn);

        List<String> addtlInfList = new ArrayList<>();
        addtlInfList.add("111");
        addtlInfList.add("222");
        mxPacs00200110Creator.setAddtlInf(addtlInfList);

        Dt fctvIntrBkSttlmDt = new Dt();
        fctvIntrBkSttlmDt.setDt(new Date());
        mxPacs00200110Creator.setFctvIntrBkSttlmDt(fctvIntrBkSttlmDt);

        mxPacs00200110Creator.setClrSysRef("wesssd");

        MxResult result = (MxResult) CreatorManager.pack(mxPacs00200110Creator);
        if (result.isSuccess())
            System.out.println(result.getMessage());
        else {
            System.out.println(result.getErrorInf());
        }
    }

    @Test
    public void test_Pacs002_2(){
        MXPacs00200110Creator mxPacs00200110Creator = new MXPacs00200110Creator("pacs.002.001.10");

        mxPacs00200110Creator.setSenderBic("HELSFIHHXXX");

        mxPacs00200110Creator.setReceiverBic("NDEAFIHHXXX");

        mxPacs00200110Creator.setBizMsgIdr("pacs2bizmsgidr01");

        mxPacs00200110Creator.setMsgDefIdr("pacs.009.001.08");

        mxPacs00200110Creator.setBizSvc("swift.cbprplus.02");

        mxPacs00200110Creator.setCreDt(new XmlDate());

        mxPacs00200110Creator.setMsgId("pacs2bizmsgidr01");

        mxPacs00200110Creator.setCreDtTm(new XmlDate());

        mxPacs00200110Creator.setOrgnlMsgId("pacs9bizmsgidr02");

        mxPacs00200110Creator.setOrgnlMsgNmId("pacs.009.001.08");

        mxPacs00200110Creator.setOrgnlInstrId("pacs9bizmsgidr02");

        mxPacs00200110Creator.setOrgnlEndToEndId("pacs009EndToEndId-001");

        mxPacs00200110Creator.setOrgnlUETR("dab3b64f-092b-4839-b7e9-8f438af50961");

        mxPacs00200110Creator.setTxSts("RJCT");

        Rsn rsn = new Rsn();
        rsn.setCd("AC12");
        mxPacs00200110Creator.setRsn(rsn);

        MxResult result = (MxResult) CreatorManager.pack(mxPacs00200110Creator);
        if (result.isSuccess())
            System.out.println(result.getMessage());
        else {
            System.out.println(result.getErrorInf());
        }
    }


}
