package com.brilliance.isc.common.outlen;

import com.brilliance.isc.common.context.SettleContext;
import com.brilliance.isc.common.register.document.IDocumentRegister;
import com.brilliance.isc.common.trndoc.service.TrndocService;
import com.brilliance.isc.common.trndoc.vo.TrndocVo;
import com.brilliance.isc.vo.collection.BcdBizInfoVo;
import com.brilliance.isc.vo.lc.BrdBizInfoVo;
import com.brilliance.isc.vo.lg.GcdBizInfoVo;
import com.brilliance.mda.runtime.mda.util.MdaUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class OutlenDocumentRegister implements IDocumentRegister {
    @Autowired
    private TrndocService trndocService;
    @Override
    public void registerDocument(TrndocVo trndoc) {
        String frame = SettleContext.getTransName();
        if (MdaUtils.compareTo(frame, "GITCRQ") == 0||MdaUtils.compareTo(frame, "GITPCR") == 0){
            GcdBizInfoVo gcdBizInfoVo = (GcdBizInfoVo) trndoc.getRec();
            if(MdaUtils.compareTo(gcdBizInfoVo.getSzflg(),"1")==0&&MdaUtils.compareTo(gcdBizInfoVo.getActtyp(),"JW")==0){
                trndocService.defDocEot(trndoc, "TRN", "APL2", "\\LENTXML1", "LET", 1, "", "\\GIDGRP\\REC", "对外付款/承兑通知书", "APL", "");
            }
            else if((MdaUtils.compareTo(gcdBizInfoVo.getSzflg(),"1")==0&&MdaUtils.compareTo(gcdBizInfoVo.getActtyp(),"JN")==0)||MdaUtils.compareTo(gcdBizInfoVo.getSzflg(),"2")==0){
                trndocService.defDocEot(trndoc, "TRN", "APL2", "\\LENTXML2", "LET", 1, "", "\\GIDGRP\\REC", "境内付款/承兑通知书", "APL", "");
            }

        } else if(MdaUtils.compareTo(frame, "LITDCK") == 0 || MdaUtils.compareTo(frame, "LITDCK1") == 0 || MdaUtils.compareTo(frame, "BRTDCK") == 0) {
            BrdBizInfoVo brdBizInfoVo = (BrdBizInfoVo) trndoc.getRec();
            if(MdaUtils.compareTo(brdBizInfoVo.getSzflg(),"1")==0){
                trndocService.defDocEot(trndoc, "TRN", "APL2", "\\LENTXML1", "LET", 1, "", "\\LIDGRP\\REC", "对外付款/承兑通知书", "APL", "");
            }
            else if(MdaUtils.compareTo(brdBizInfoVo.getSzflg(),"2")==0){
                trndocService.defDocEot(trndoc, "TRN", "APL2", "\\LENTXML2", "LET", 1, "", "\\LIDGRP\\REC", "境内付款/承兑通知书", "APL", "");
            }
        } else if (MdaUtils.compareTo(frame, "BCTDAV") == 0 || MdaUtils.compareTo(frame, "BCTDAV1") == 0 || MdaUtils.compareTo(frame, "BCTAME") == 0 || MdaUtils.compareTo(frame, "BCTAME1") == 0) {
            BcdBizInfoVo bcdBizInfoVo = (BcdBizInfoVo) trndoc.getRec();
            if(MdaUtils.compareTo(bcdBizInfoVo.getSzflg(),"1")==0){
                trndocService.defDocEot(trndoc, "TRN", "DRE2", "\\LENTXML1", "LET", 1, "", "\\BCDGRP\\REC", "对外付款/承兑通知书", "DRE", "");
            }
            else if(MdaUtils.compareTo(bcdBizInfoVo.getSzflg(),"2")==0){
                trndocService.defDocEot(trndoc, "TRN", "DRE2", "\\LENTXML2", "LET", 1, "", "\\BCDGRP\\REC", "境内付款/承兑通知书", "DRE", "");
            }
        }
    }

}
