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

📄 rwgljhmxmbean.java

📁 以前做的一个j2ee的项目
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
        cfzqList.add(new SelectItem("09", "每旬"));
        cfzqList.add(new SelectItem("10", "每月"));
        cfzqList.add(new SelectItem("30", "每季"));
        cfzqList.add(new SelectItem("60", "每半年"));
        cfzqList.add(new SelectItem("90", "每年"));
        if (jhmxVO.getJh_xh() == null) {
            jhmxVO.setCfzq_lx("0");
        }
        //获取特殊信息
        this.getViewSpecial();
        LogWritter.sysDebug("finish get all");
    }

    private void getViewSpecial(){
        LogWritter.sysDebug("begin get special");
        if (jhmxVO.getRwlx_dm().equals("01")){
            //specialData使用说明:
            //   specialString1:纳税人内部码
            //   specialString3:纳税人从哪个类移出(编号--机构或人员的代码)
            //   specialString4:操作员选择的移入类的编号(机构或人员的代码)
            specialData=new RWGLspecialDataVO();
            if (jh_xh==null) {
                //对于新建任务的情况,置空字符串
                specialData.setSpecialString1("");
                specialData.setSpecialString3("");
                specialData.setSpecialString4("");
            }
            //取纳税人内部码
            String tempS=rwmxVO.getProperty("nsrnbm");
            if (tempS==null) tempS="";
            specialData.setSpecialString1(tempS);
            //取移出类
            tempS=rwmxVO.getProperty("from");
            if (tempS==null) tempS="";
            specialData.setSpecialString3(tempS);
            //取移入类
            tempS=rwmxVO.getProperty("to");
            if (tempS==null) tempS="";
            specialData.setSpecialString4(tempS);
        }
    }

    public String save() throws Exception {
        LogWritter.sysDebug("begin save");
        RWGLaprwjhReqEvent reqmx = new RWGLaprwjhReqEvent();
        //获取任务类型
        if (jhmxVO.getRwlx_dm()==null || jhmxVO.getRwlx_dm().equals("")){
            String rwlxS = WebUtil.getParameterFromContextMap(
                    "rwlx");
            LogWritter.sysDebug("rwlxS='"+rwlxS+"'");
            if (rwlxS != null && !rwlxS.equals("")) jhmxVO.setRwlx_dm(rwlxS);
            else throw new TaxBaseBizException("YCRWGL10001");
        }
        //获取任务小类
        if (jhmxVO.getRwxl_dm()==null || jhmxVO.getRwxl_dm().equals("")){
            String rwxlS = WebUtil.getParameterFromContextMap(
                    "rwxl");
            LogWritter.sysDebug("rwxlS='"+rwxlS+"'");
            if (rwxlS != null && !rwxlS.equals("")) jhmxVO.setRwxl_dm(rwxlS);
            else throw new TaxBaseBizException("YCRWGL10001");
        }
        //对保存的数据进行处理
        if (jhmxVO.getCfzq_lx().equals("0")){
            LogWritter.sysDebug("cfzq='0',now set to null");
            jhmxVO.setCfzq_lx("");
        }
        if (jhmxVO.getCbbm_dm().equals("0")){
            LogWritter.sysDebug("cbbm='0',now set to null");
            jhmxVO.setCbbm_dm("");
        }
        if (jhmxVO.getCbry_dm().equals("0")){
            LogWritter.sysDebug("cbry='0',now set to null");
            jhmxVO.setCbry_dm("");
        }
        if (jhmxVO.getCbbm_dm().equals("") && jhmxVO.getCbry_dm().equals(""))
            throw new TaxBaseBizException("YCRWGL21001");
        jhmxVO.setJhxdry_dm(swry_dm);
        String ydqdsj=WebUtil.getParameterFromContextMap("start_date3");
        LogWritter.sysDebug("ydqdsj="+ydqdsj);
        if (jhmxVO.getYdqd_sj()==null) jhmxVO.setYdqd_sj(Timestamp.valueOf(ydqdsj+":00"));
        //获取特殊数据
        try {
            this.saveSpecial();
        } catch (Exception ex) {ex.printStackTrace();
        }
        jhmxVO.setRwmxxx(rwmxVO.getRwmxxx());
        //设定RequestEvent内容
        reqmx.setJhrwVO(jhmxVO);
        reqmx.setStartNow(startNow);
        if (jhmxVO.getJh_xh()!=null){
            LogWritter.sysDebug("准备保存计划内容,计划序号:"+jh_xh);
            reqmx.setDealMethod("saveJhap");
            reqmx.setJh_xh(jh_xh);
        }else{
            LogWritter.sysDebug("准备创建新计划,保存计划内容");
            reqmx.setDealMethod("newJhap");
        }
        reqmx.setSwry_dm(swry_dm);
        //调用代理方法
        ISsglyService service = new SsglyDelegate();
        ResponseEvent resp = null;
        try {
            resp = service.invokeTask(reqmx);
        } catch (Exception e) {
            e.printStackTrace();
        }
        //处理ResponseEvent
        RWGLaprwjhResEvent ssglyRes = (RWGLaprwjhResEvent) resp;
        if (!ssglyRes.getRepCode().equals("0")) {
            throw new TaxBaseSystemException("保存失败!");
         }
        return "success";
    }

    private void saveSpecial()throws Exception{
        if (jhmxVO.getRwlx_dm().equals("01")){
            //对于分户任务,处理特殊内容
            //获取纳税人的内部码
            String nsrnbm=WebUtil.getParameterFromContextMap("nsrnbm");
            if (nsrnbm!=null && !nsrnbm.equals("")) {
                rwmxVO.setProperty("nsrnbm", nsrnbm);
                try {
                    jhmxVO.setNsrnbm(new BigDecimal(nsrnbm));
                }
                catch (NumberFormatException e) {}
            }
            else throw new TaxBaseBizException("YCRWGL21101");
            //获取纳税人移出信息
            String from_dm=WebUtil.getParameterFromContextMap("from_dm");
            if (from_dm!=null && !from_dm.equals("")) rwmxVO.setProperty("from",from_dm);
            else throw new TaxBaseBizException("YCRWGL21102");
            //获取纳税人移入信息
            String to_dm=WebUtil.getParameterFromContextMap("to_flmc");
            if (to_dm!=null && !to_dm.equals("")) rwmxVO.setProperty("to",to_dm);

        }else{
            //获取纳税人列表的信息
            String[] temp = this.getParametersFromContextMap("nsrnbm"); //调整了WebUtil的方法,获取多个参数
            String nsrList = "";
            if (temp != null) {
                LogWritter.sysDebug("got " + temp.length + " rows of nsr data.");
                for (int i = 0; i < temp.length; i++) {
                    if (temp[i] == null || temp[i].equals("") || temp[i].length() < 3) continue;
                        //对于分类的序号,暂时采用“fl%%%%%%%”的方式输入
                        if (temp[i].substring(0, 2).equals("fl")){
                            nsrList = nsrList + "flxh=" + temp[i].substring(2) +
                                      ";;";
                        }
                        else {
                            nsrList = nsrList + "nsrnbm=" + temp[i] + ";;";
                        }
                }
            } else LogWritter.sysDebug("本任务不包含纳税人信息");
            //写入任务明细信息
            rwmxVO.setRwmxxx(rwmxVO.getRwmxxx() + nsrList);
            if (rwmxVO.getNsrList().size()==1 && rwmxVO.getFl_xh()==null){
                String nsrnbm=(String)rwmxVO.getNsrList().get(0);
                LogWritter.sysDebug("任务包含一个纳税人:"+nsrnbm);
                try {jhmxVO.setNsrnbm(new BigDecimal(nsrnbm));}
                catch (NumberFormatException e){}
            }else{
                LogWritter.sysDebug("任务包含多个纳税人或不包含纳税人,仅保存任务明细信息,不额外保存纳税人内部码");
            }
        }
        rwmxVO.setFileList(saveFile());
    }

    public static String[] getParametersFromContextMap(String paramName) {
        FacesContext context = FacesContext.getCurrentInstance();
        ExternalContext ec = context.getExternalContext();
        Map parameterMap = ec.getRequestParameterValuesMap();
        return (String[]) parameterMap.get(paramName);
    }

    public String start () {
        startNow=true;
        String result="fail";
        try {
            result=this.save();
        } catch (Exception ex) {
            ex.printStackTrace();
        }
        return result;
    }

    public ArrayList saveFile() throws IOException, Exception {
        ArrayList resultList = new ArrayList();
        java.sql.Connection cnn = null;
        Statement stmt = null;

        try {
            cnn = JDBCLocator.getInstance().getJDBCConnection();
            cnn.setAutoCommit(false);
            stmt = cnn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,
                                       ResultSet.CONCUR_UPDATABLE);
            String result = null;
            if (myFile1 != null) {
                result = saveFileData(myFile1, stmt);
                if (result == null) {
                    cnn.rollback();
                    resultList.clear();
                    return resultList;
                } else
                    resultList.add(result);
            }
            if (myFile2 != null) {
                result = saveFileData(myFile2, stmt);
                if (result == null) {
                    cnn.rollback();
                    resultList.clear();
                    return resultList;
                } else
                    resultList.add(result);

            }
            if (myFile3 != null) {
                result = saveFileData(myFile3, stmt);
                if (result == null) {
                    cnn.rollback();
                    resultList.clear();
                    return resultList;
                } else
                    resultList.add(result);

            }
            if (myFile4 != null) {
                result = saveFileData(myFile4, stmt);
                if (result == null) {
                    cnn.rollback();
                    resultList.clear();
                    return resultList;
                } else
                    resultList.add(result);

            }
            if (myFile5 != null) {
                result = saveFileData(myFile5, stmt);
                if (result == null) {
                    cnn.rollback();
                    resultList.clear();
                    return resultList;
                } else
                    resultList.add(result);
            }
            if (myFile5 != null) {
                result = saveFileData(myFile5, stmt);
                if (result == null) {
                    cnn.rollback();
                    resultList.clear();
                    return resultList;
                } else
                    resultList.add(result);
            }
            if (myFile6 != null) {
                result = saveFileData(myFile6, stmt);
                if (result == null) {
                    cnn.rollback();
                    resultList.clear();
                    return resultList;
                } else
                    resultList.add(result);
            }
            if (myFile7 != null) {
                result = saveFileData(myFile7, stmt);
                if (result == null) {
                    cnn.rollback();
                    resultList.clear();
                    return resultList;
                } else
                    resultList.add(result);
            }
            if (myFile8 != null) {
                result = saveFileData(myFile8, stmt);
                if (result == null) {
                    cnn.rollback();
                    resultList.clear();
                    return resultList;
                } else
                    resultList.add(result);
            }
            if (myFile9 != null) {
                result = saveFileData(myFile9, stmt);
                if (result == null) {
                    cnn.rollback();
                    resultList.clear();
                    return resultList;
                } else
                    resultList.add(result);
            }
            if (myFile10 != null) {
                result = saveFileData(myFile10, stmt);
                if (result == null) {
                    cnn.rollback();
                    resultList.clear();
                    return resultList;
                } else
                    resultList.add(result);
            }
            cnn.commit();

        } catch (Exception e) {
            cnn.rollback();
            e.printStackTrace();
        } finally {
            cnn.close();
            stmt.close();
        }

        return resultList;
    }

    public String saveFileData(UploadedFile uploaderFile,
                               Statement stmt) {
        String result = null;

        try {
            String fileName = uploaderFile.getName();
            int ipos = fileName.lastIndexOf("\\");

            if (ipos <= 0) {
                fileName = "";
            } else {
                fileName = fileName.substring(ipos + 1);
            }
            ipos=fileName.lastIndexOf(".");
            String fileExt = fileName.substring(ipos + 1);
            fileName=fileName.substring(0, ipos);

            String url = "";
            InputStream fileStream = uploaderFile.getInputStream();
            String sql =
                    "select Sq_Gzda_Fileurl.Nextval as url from dual";
            ResultSet rs = stmt.executeQuery(sql);
            if (rs.next()) {
                url = rs.getString("url"); //获取Sq_Gzda_Fileurl 的sequences
            }
            sql =
                    "select * from t_gzda_filemanagerabstr t where code='FGX' order by leve";
            rs.close();
            rs = stmt.executeQuery(sql);
            float beginLeve = 0, endLeve = 0;
            if (rs == null) {
                return result;
            }
            rs.first();
            beginLeve = rs.getFloat("leve");
            rs.last();
            endLeve = rs.getFloat("leve");
            //插入主表语句
            sql = "Insert into t_gzda_filemanagerabstr (code,name,operid,filetype,type,url,filestatue,createdate,leve,tranno,title)";
            /*sql = sql + " values('" + "FGX" + "','" + fileName + "','" +
                  rs.getString("operid") + "','" +
                  rs.getString("filetype") + "','" +
                  rs.getString("type") +
                  "','" + url + "','" +
                  rs.getString("filestatue") + "',sysdate," +
                  String.valueOf((beginLeve + endLeve) / 2) + ",'" +
                  url + "','" + fileName + "')";*/
            sql = "Insert into t_gzda_filemanagerabstr (code,name,operid,filetype,type,url,filestatue,createdate,leve,tranno,title)";
            sql += " values('" + "FGX" + "','" + fileName + "','" +
                  rs.getString("operid") + "','1','" +
                  fileExt + "','" + url + "','" +
                  rs.getString("filestatue") + "',sysdate," +
                  String.valueOf((beginLeve + endLeve) / 2) + ",'" +
                  url + "','" + fileName + "')";

            stmt.executeQuery(sql); //工作档案主表插入
            rs.close();
            //插入文件流到数据库中
            sql = "delete from t_gzda_filemanagerdetail where url='" + url +
                  "'"; //delete
            stmt.executeUpdate(sql);
            sql =
                    "insert into  t_gzda_filemanagerdetail(url,filedoc) values ('" +
                    url + "',EMPTY_BLOB())";
            stmt.executeUpdate(sql);
            sql = "select filedoc from t_gzda_filemanagerdetail where url='" +
                  url + "' FOR UPDATE ";
            ResultSet rsDetail = stmt.executeQuery(sql);
            if (rsDetail.next()) {
                //oracle.sql.BLOB blob = (oracle.sql.BLOB) rsDetail.getBlob(1);
                weblogic.jdbc.vendor.oracle.OracleThinBlob blob = (weblogic.
                        jdbc.vendor.oracle.OracleThinBlob) rsDetail.getBlob(1);
                BufferedOutputStream fileout = new BufferedOutputStream(blob.
                        getBinaryOutputStream());
                BufferedInputStream filein = new BufferedInputStream(fileStream);
                int c;
                while ((c = filein.read()) != -1) {
                    fileout.write(c);
                }
                //   blob.close();
                fileout.close();
                filein.close();
                fileStream.close();
                result = url;
            }
            rsDetail.close();
        } catch (Exception e) {
            e.printStackTrace();
        }

        return result;
    }

}

⌨️ 快捷键说明

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