⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 wdscconstant.java

📁 以前做的一个j2ee的项目
💻 JAVA
字号:
package gov.gdlt.ssgly.taxcore.taxblh.wdsc;

import gov.gdlt.ssgly.taxcore.comm.servicelocator.JDBCLocator;
import java.sql.*;
import java.util.*;
import gov.gdlt.ssgly.taxcore.taxdao.wdsc.WDSCwdmbzbDAO;
import gov.gdlt.ssgly.taxcore.taxevent.wdsc.WDSCmbwhVO;

public class WDSCconstant {
    public WDSCconstant() throws Exception {
        initDateTime();
        initWdscConstant();
    }

    //在模板维护时添加到
    public WDSCconstant(Vector vVo) throws Exception {
        sysZb = vVo;
    }

    private Vector sysZb = null;
    public static void main(String[] args) throws Exception {
        WDSCconstant wdscconstantblh = new WDSCconstant();
        wdscconstantblh.initDateTime();
    }

    //系统变量
    public static boolean boolMultiThread = false;//是否多线程
    public static boolean boolBatchProcess = false;//是否成批处理删除和插入操作


    //系统关键字
    public static String flagLeft = "{", flagRight = "}"; //指标标识关键字
    public static String loopLeft = "[loop]", loopRight = "[/loop]"; //模板循环关键字
    public static String sumLeft = "[sum]", sumRight = "[/sum]"; //模板求和关键字
    public static String sysflag = "sys:"; //是否取系统信息关键字
    public static String SUM = "SUM:";
    //public static String NO_RESULT = "NO_RESULT";

    public static String USER_WDLX = "USER_WDLX"; //用户文档类型关键字
    public static String NSRNBM = "nsrnbm"; //纳税人内部码关键字
    public static String WDSCSJ = "WDSCSJ"; //文档模板上的生成日戳,系统自动添加将文档开始生成的时间

    //系统指标
    public static String KEY_SYS_YEAR = "SYS_YEAR";//当前年
    public static String KEY_SYS_MONTH = "SYS_MONTH";//当前月
    public static String KEY_SYS_DAY = "SYS_DAY";//当前日

    public static String KEY_SYS_LAST_YEAR = "SYS_LAST_YEAR";//上一年
    public static String KEY_SYS_LAST_MONTH = "SYS_LAST_MONTH";//上一月
    public static String KEY_SYS_LAST_DAY = "SYS_LAST_DAY";//上一天

    public static String KEY_SYS_NEXT_YEAR = "SYS_NEXT_YEAR";//下一年
    public static String KEY_SYS_NEXT_MONTH = "SYS_NEXT_MONTH";//下一月
    public static String KEY_SYS_NEXT_DAY = "SYS_NEXT_DAY";//下一日

    public static String KEY_SYS_COUNT = "SYS_COUNT";//计数器
    public static String KEY_SYS_WSH = "SYS_WSH";//文书号

    //对指标操作
    public static String OPER_TYPE_SUM = "OPER_TYPE_SUM";//求和

    public void initWdscConstant () {
        sysZb = new Vector();
        addZb(this.KEY_SYS_YEAR, this.SYS_YEAR);
        addZb(this.KEY_SYS_MONTH, this.SYS_MONTH);
        addZb(this.KEY_SYS_DAY, this.SYS_DAY);

        addZb(this.KEY_SYS_LAST_YEAR, this.SYS_LAST_YEAR);
        addZb(this.KEY_SYS_LAST_MONTH, this.SYS_LAST_MONTH);
        addZb(this.KEY_SYS_LAST_DAY, this.SYS_LAST_DAY);

        addZb(this.KEY_SYS_NEXT_YEAR, this.SYS_NEXT_YEAR);
        addZb(this.KEY_SYS_NEXT_MONTH, this.SYS_NEXT_MONTH);
        addZb(this.KEY_SYS_NEXT_DAY, this.SYS_NEXT_DAY);

        addZb(this.KEY_SYS_WSH, null);
    }

    //文档生成中系统系统参数
    public String SYS_YEAR = "";
    public String SYS_MONTH = "";
    public String SYS_DAY = "";

    public String SYS_LAST_YEAR = "";
    public String SYS_LAST_MONTH = "";
    public String SYS_LAST_DAY = "";

    public String SYS_NEXT_YEAR = "";
    public String SYS_NEXT_MONTH = "";
    public String SYS_NEXT_DAY = "";

    public String SYS_COUNT = "";

    //function
    public String getSysWsh() throws SQLException {
        String wsh = "";
        String sql = "SELECT db_ssgly.SQ_SSGLY_WSH.nextval FROM dual";
        Connection conn = null;
        try {
            conn = JDBCLocator.getInstance().getJDBCConnection();
            Statement stmt = conn.createStatement();
            ResultSet rs = stmt.executeQuery(sql);
            if (rs.next()) {
                wsh = rs.getString(1);
            } else {
                System.out.println("取文书号失败!");
            }
        } catch (Exception e) {
            System.out.println("取文书号失败!");
        } finally {
            if (conn != null) conn.close();
        }
        return wsh;
    }

    private void initDateTime() throws Exception {
        java.util.Calendar cal_curr = java.util.Calendar.getInstance();

        try {
            //2005-11-23
            String datetime = getDateTime(cal_curr);
            this.SYS_YEAR = datetime.substring(0, 4);
            this.SYS_MONTH = datetime.substring(5, 7);
            this.SYS_DAY = datetime.substring(8, 10);

            cal_curr = java.util.Calendar.getInstance();
            cal_curr.add(Calendar.YEAR, -1);
            //cal_curr.roll(Calendar.YEAR, false);
            datetime = getDateTime(cal_curr);
            this.SYS_LAST_YEAR = datetime.substring(0, 4);

            cal_curr.add(Calendar.MONTH, -1);
            //cal_curr.roll(Calendar.MONTH, false);
            datetime = getDateTime(cal_curr);
            this.SYS_LAST_MONTH = datetime.substring(5, 7);

            cal_curr.add(Calendar.DATE, -1);
            //cal_curr.roll(Calendar.DATE, false);
            datetime = getDateTime(cal_curr);
            this.SYS_LAST_DAY = datetime.substring(8, 10);

            cal_curr = java.util.Calendar.getInstance();
            cal_curr.add(Calendar.YEAR, 1);
            //cal_curr.roll(Calendar.YEAR, true);
            datetime = getDateTime(cal_curr);
            this.SYS_NEXT_YEAR = datetime.substring(0, 4);

            cal_curr.add(Calendar.MONTH, 1);
            //cal_curr.roll(Calendar.MONTH, true);
            datetime = getDateTime(cal_curr);
            this.SYS_NEXT_MONTH = datetime.substring(5, 7);

            cal_curr.add(Calendar.DATE, 1);
            //cal_curr.roll(Calendar.DATE, true);
            datetime = getDateTime(cal_curr);
            this.SYS_NEXT_DAY = datetime.substring(8, 10);
        } catch (Exception e) {
            throw new Exception("初始化系统时间失败," + e.getMessage());
        }
    }

    private String getDateTime(Calendar cal) throws Exception {
        //java.util.Calendar cal = java.util.Calendar.getInstance();
        //cal.setTime(new Date());
        String year = null, month = null, day = null, hour = "", minute = "",
                second = "";
        int h, m, s;
        try {
            year = String.valueOf(cal.get(cal.YEAR));
            month = String.valueOf(cal.get(cal.MONTH) + 1);
            if (Integer.parseInt(month) <= 9) {
                month = "0" + month;
            }
            day = String.valueOf(cal.get(cal.DATE));
            if (Integer.parseInt(day) <= 9) {
                day = "0" + day;
            }

            h = cal.get(cal.HOUR_OF_DAY);
            m = cal.get(cal.MINUTE);
            s = cal.get(cal.SECOND);
            hour = String.valueOf(h);
            minute = String.valueOf(m);
            second = String.valueOf(s);

            if (h <= 9) {
                hour = "0" + hour;
            }
            if (m <= 9) {
                minute = "0" + minute;
            }
            if (s <= 9) {
                second = "0" + second;
            }
        } catch (Exception e) {
            e.printStackTrace();
            throw new Exception(e.getMessage());
        }
        return year + "-" + month + "-" + day + " " + hour + ":" + minute + ":" +
                second;
    }

    private void addZb(String key, String result) {
        WDSCwdmbzbDAO wdzb = new WDSCwdmbzbDAO();
        wdzb.setZB_DM(key);
        Vector tempV = new Vector();
        tempV.add(result);
        wdzb.setZB_NR(tempV);
        if (sysZb == null) sysZb = new Vector();
        sysZb.add(wdzb);
    }
    ///////////////////////
    //在纳税人指标值中添加系统指标和指标对应的值
    public Vector addSysZb(Vector vZb) {
        if (vZb == null) return sysZb;
        int len = sysZb.size();
        for (int i=0; i<len; i++) {
            vZb.add(sysZb.get(i));
        }
        return vZb;
    }

    public Vector addSysZbToVo(Vector v) {
        WDSCmbwhVO mbwhVo = null;
        if (v == null) v = sysZb;
        mbwhVo = new WDSCmbwhVO();
        mbwhVo.setZbdm(this.KEY_SYS_LAST_YEAR);
        mbwhVo.setZbmc("系统指标:上一年年份");
        v.add(mbwhVo);
        mbwhVo = new WDSCmbwhVO();
        mbwhVo.setZbdm(this.KEY_SYS_YEAR);
        mbwhVo.setZbmc("系统指标:当前年年份");
        v.add(mbwhVo);
        mbwhVo = new WDSCmbwhVO();
        mbwhVo.setZbdm(this.KEY_SYS_NEXT_YEAR);
        mbwhVo.setZbmc("系统指标:下一年年份");
        v.add(mbwhVo);

        mbwhVo = new WDSCmbwhVO();
        mbwhVo.setZbdm(this.KEY_SYS_LAST_MONTH);
        mbwhVo.setZbmc("系统指标:上一月月份");
        v.add(mbwhVo);
        mbwhVo = new WDSCmbwhVO();
        mbwhVo.setZbdm(this.KEY_SYS_MONTH);
        mbwhVo.setZbmc("系统指标:当前月月份");
        v.add(mbwhVo);
        mbwhVo = new WDSCmbwhVO();
        mbwhVo.setZbdm(this.KEY_SYS_NEXT_MONTH);
        mbwhVo.setZbmc("系统指标:下一月月份");
        v.add(mbwhVo);

        mbwhVo = new WDSCmbwhVO();
        mbwhVo.setZbdm(this.KEY_SYS_LAST_DAY);
        mbwhVo.setZbmc("系统指标:上一日日期");
        v.add(mbwhVo);
        mbwhVo = new WDSCmbwhVO();
        mbwhVo.setZbdm(this.KEY_SYS_DAY);
        mbwhVo.setZbmc("系统指标:当前日日期");
        v.add(mbwhVo);
        mbwhVo = new WDSCmbwhVO();
        mbwhVo.setZbdm(this.KEY_SYS_NEXT_DAY);
        mbwhVo.setZbmc("系统指标:下一日日期");
        v.add(mbwhVo);

        mbwhVo = new WDSCmbwhVO();
        mbwhVo.setZbdm(this.KEY_SYS_WSH);
        mbwhVo.setZbmc("系统指标:获得一个文书号");
        v.add(mbwhVo);

        this.setSysZb(v);
        return v;
    }


    public Vector getSysZb() {
        return sysZb;
    }

    public void setSysZb(Vector sysZb) {
        this.sysZb = sysZb;
    }

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -