package com.brilliance.isc.swift.fremsg.document;

import com.brilliance.mda.runtime.mda.util.Strings;
import com.brilliance.isc.bo.Bch;
import com.brilliance.isc.common.context.SettleContext;
import com.brilliance.isc.common.trndoc.vo.DoceotVo;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.Map;

@Component
public class TemplateHeadAndFoot {
    public static final String CR = "\n";

    public Map<String, Object> printApllHeader(DoceotVo doceotVo) {
        HashMap map = new HashMap();
        String branch = "";
        String address = "";
        String swiftbic = "";
        String tel = "";
        String fax = "";
        Bch bch = SettleContext.getUserSession().getBch();
        if ( bch != null) {
            branch = bch.getNamen();
            address = bch.getAdren() + " " + bch.getAdren2();
            if (Strings.pos(branch, "CHINA EVERBRIGHT BANK") != 0) {
                branch = Strings.mid(branch, 23);
            }
            swiftbic = bch.getSwfcod();
            tel = bch.getTel();
            fax = bch.getFax();
        }
        map.put("branch", branch);
        map.put("address", address);
        map.put("swiftbic", swiftbic);
        map.put("tel", tel);
        map.put("fax", fax);
        return map;
    }

    public Map<String, Object> printApllFooter(DoceotVo doceotVo) {
        HashMap map = new HashMap();
        //修改面函机构，xxf改<------------------------------------------------------
        //----英文取分行的名称--------------------
        Bch bch = SettleContext.getUserSession().getBch();
        String XML14 = "";
        if (bch != null) {
            XML14 = Strings.trim(bch.getNamen())
                    + " " + bch.getAdren()
                    + " " + bch.getAdren2()
                    + "     SWIFT:"
                    + Strings.trim(bch.getSwfcod());
        }
        map.put("XML14", XML14);
        return map;
    }
}
