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

📄 htdlexecdtrwbyfz.java

📁 以前做的一个j2ee的项目
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
package gov.gdlt.ssgly.taxcore.taxblh.htdl;

import java.lang.Thread;
import gov.gdlt.ssgly.taxcore.taxdao.htdl.HTDLdtrwlbDAO;
import gov.gdlt.ssgly.taxcore.taxevent.htdl.IHTDLcall;
import gov.gdlt.ssgly.taxcore.taxevent.htdl.HTDLreturnVO;
import gov.gdlt.ssgly.taxcore.comm.log.LogWritter;
import gov.gdlt.ssgly.taxcore.taxdao.htdl.HTDLybsdsrwDAO;
import gov.gdlt.ssgly.taxcore.comm.config.ApplicationContext;
import gov.gdlt.ssgly.taxcore.taxdao.htdl.HTDLzxlogDAO;
import java.util.ArrayList;
import java.sql.SQLException;
import gov.gdlt.ssgly.taxcore.taxevent.htdl.HTDLdtrwVO;
import gov.gdlt.ssgly.taxcore.taxevent.htdl.HTDLzxqkVO;


/**
 *
 * <p>Title: 执行当天任务别表中的指定分组中的任务</p>
 *
 * <p>Description: 广东地税税收管理员工作平台</p>
 *
 * <p>Copyright: Copyright (c) 2005 广东省地方税务局,广州市地方税务局</p>
 *
 * <p>Company: 广州地税</p>
 *
 * @author 肖雪莲
 * 2005-9-19 加入传参数的功能
 * @version 1.0
 */

public class HTDLexecDtrwByFz extends Thread {
    public static final String HTDL_SXLX_PROC = "0";
    public static final String HTDL_SXLX_JAVA = "1";
    private String fz; //分组信息

    public HTDLexecDtrwByFz(String fzxx) {
        this.fz = fzxx;
    }

    //调用ibatis执行指定的procName名字的存储过程,该存储过程具有如下的统一接口:
    //具有两个OUT参数,类型为varchar.
    //2005-9-19 by xxl
    //加入csl,用于实现传参数的调用形式
    public HTDLreturnVO executeProc(String procName, String csl) throws
            Exception {
        HTDLreturnVO procRetVO = new HTDLreturnVO();
        procRetVO.setProcName(procName);
        procRetVO.setCsl(csl);

        try {
            HTDLdtrwlbDAO dtrwlbDAO = new HTDLdtrwlbDAO();
            dtrwlbDAO.execDtrw(procRetVO);
            if (procRetVO.getStatus() == null) {
                procRetVO.setStatus("0"); //未提供结果并且没有出现异常时,默认为成功
                procRetVO.setDetail("接口未提供结果描述!");
            }
        } catch (Exception e) {
            LogWritter.sysDebug(e.toString() + " in " +
                                HTDLexecDtrw.class.getName());
            if (procRetVO.getStatus() == null) {
                procRetVO.setStatus("-1"); //出现异常时候,调用程序把执行结果设为失败
            }
            procRetVO.setDetail("调用出现异常:" + e.toString());
//            throw new Exception(e.toString());
        }
        return procRetVO;
    }

    //执行指定类名的功能,该类必须实现接口IHTDLcall
    //2005-9-19 by xxl
    //加入csl,用于实现传参数的调用形式
    public HTDLreturnVO executeJavaClass(String taskClassName, String csl) throws
            Exception {

        HTDLreturnVO retVO = new HTDLreturnVO();
        try {
            Object taskObject = Class.forName(taskClassName).newInstance();
            if (taskObject instanceof IHTDLcall) {
                IHTDLcall htdlCall = (IHTDLcall) taskObject;
                retVO = htdlCall.execute(csl);
                if (retVO.getStatus() == null) {
                    retVO.setStatus("0"); //未提供结果并且没有出现异常时,默认为成功
                    retVO.setDetail("接口未提供结果描述!");
                }
            } else { //提供的调用接口没有实现规定的IHTDLcall接口
                retVO.setStatus("-1");
                retVO.setDetail(taskClassName + "没有实现HTDLcall接口,无法统一调用!");
            }
        } catch (Exception e) {
            e.printStackTrace();
//            throw new Exception(HTDLexecDtrw.class.getName() + "执行" + className +"类时出错:" + e.toString());
            if (retVO.getStatus() == null) {
                retVO.setStatus("-1"); //出现异常时候,调用程序把执行结果设为失败
            }
            retVO.setDetail("调用出现异常:" + e.getMessage());
        }
        return retVO;
    }

//执行属于指定分组中的任务,按照优先级由高到低顺序执行
    public void executeDtrwByFz() {
        int count = 0;

        try {
            //根据fzxx参数,取得属于该分组的所有任务
//            LogWritter.sysDebug(HTDLexecDtrw.class.getName() + "开始获取属于" + this.fz +
//                                "分组的任务!");

            HTDLdtrwlbDAO dtrwDAO = new HTDLdtrwlbDAO();
            HTDLreturnVO retVO = new HTDLreturnVO();
            HTDLybsdsrwDAO ybsrwDAO = new HTDLybsdsrwDAO();
            java.sql.Timestamp dtBefore;
            java.sql.Timestamp dtAfter;

            ArrayList dtrwList = (ArrayList) dtrwDAO.selectDtrwByFz(this.fz);
            for (int i = 0; i < dtrwList.size(); i++) {
                HTDLdtrwVO dtrwVO = (HTDLdtrwVO) dtrwList.get(i);
                String rwxh = dtrwVO.getRw_xh();
                LogWritter.sysDebug(HTDLexecDtrw.class.getName() + "开始执行" +
                                    dtrwVO.getRw_xh() + "号任务:" + dtrwVO.getDyjk());
                dtBefore = new java.sql.Timestamp(System.currentTimeMillis());
                //执行任务
                //更新任务状态为执行中("1")
                dtrwDAO.updateZt("1", rwxh);

                //插日志Log,提示任务执行中
                HTDLzxlogDAO zxlogDAO = new HTDLzxlogDAO();
                HTDLzxqkVO zxqkVO = new HTDLzxqkVO();
                zxqkVO.setLrry_dm(dtrwVO.getLrry_dm());
                zxqkVO.setRw_xh(dtrwVO.getRw_xh()); //任务序号
                zxqkVO.setRw_mc(dtrwVO.getRw_mc());
                zxqkVO.setBlh_mc(dtrwVO.getBlh_mc()); //业务逻辑名称
                zxqkVO.setBczx_qssj(dtBefore);
//             zxqkVO.setBczx_zzsj(dtAfter);
                zxqkVO.setZxjg("1"); //执行结果
                zxqkVO.setJgms("执行参数:" + dtrwVO.getCsl()); //结果描述
                String log_xh = zxlogDAO.insertNewLog(zxqkVO);

                if (HTDL_SXLX_PROC.equals(dtrwVO.getSx_lx())) { //该任务是存储过程
                    retVO = executeProc(dtrwVO.getDyjk(), dtrwVO.getCsl());
                } else if (HTDL_SXLX_JAVA.equals(dtrwVO.getSx_lx())) { //该任务是Java类
                    retVO = executeJavaClass(dtrwVO.getDyjk(), dtrwVO.getCsl());
                } else {
                    retVO.setStatus("-1");
                    retVO.setDetail("未知的实现类型");
                }
                dtAfter = new java.sql.Timestamp(System.currentTimeMillis());
                LogWritter.sysDebug("执行结果--状态:" + retVO.getStatus() + "描述:" +
                                    retVO.getDetail());
                if (retVO.getDetail() == null) {
                    retVO.setDetail("未提供执行结果的描述");
                }
                //往DB写执行日志
//                HTDLzxlogDAO zxlogDAO = new HTDLzxlogDAO();
//                zxlogDAO.setLrry_dm(dtrwVO.getLrry_dm()); //录入人员代码
//                zxlogDAO.setRw_xh(dtrwVO.getRw_xh()); //任务序号
//                zxlogDAO.setRw_mc(dtrwVO.getRw_mc());
//                zxlogDAO.setBlh_mc(dtrwVO.getBlh_mc()); //业务逻辑名称
//                zxlogDAO.setBczx_qssj(dtBefore);
//                zxlogDAO.setBczx_zzsj(dtAfter);
//                zxlogDAO.setZxjg(retVO.getStatus()); //执行结果
//                zxlogDAO.setJgms("执行参数:" + dtrwVO.getCsl() + ".结果:" +
//                                 retVO.getDetail()); //结果描述
//
//                zxlogDAO.saveZxlog(); //insert into db

                //更新日志
                zxqkVO.setLog_xh(log_xh);
                zxqkVO.setBczx_zzsj(dtAfter);
                zxqkVO.setZxjg(retVO.getStatus()); //执行结果
                zxqkVO.setJgms("执行参数:" + dtrwVO.getCsl() + ".结果:" + retVO.getDetail()); //结果描述
                zxlogDAO.updateZxlog(zxqkVO);

                //如果执行成功的话,更新已部署任务列表中相应的上次成功执行时间 mod
                if (retVO.getStatus().equals("0")) {
                    ybsrwDAO.updateSccg_sj(rwxh, dtAfter);
                }
                //更新“当天任务列表”中该任务的当前状态为“执行完毕(2)”mod
                dtrwDAO.updateZt("2", rwxh);
                LogWritter.sysDebug("任务:" + dtrwVO.getRw_xh() +
                                    dtrwVO.getBlh_mc() + "执行完毕!");
            }
        } catch (SQLException e) {
            e.printStackTrace();
            LogWritter.sysError(e.toString());
        } catch (Exception e) {
            e.printStackTrace();
            LogWritter.sysError(e.toString());

⌨️ 快捷键说明

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