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

📄 innercode.java

📁 一套完整的工商12315的源程序jsp部分在12315里,后台JAVA部分在gs12315src里,没有打包数据库.
💻 JAVA
字号:

package com.gs.util;

import java.util.*;
import java.sql.*;
import com.gs.util.*;
import com.gs.component.approve.util.*;

public class InnerCode {
    //内部编号
    private String innerCode;
    //管辖单位 = 行政区划 + 派出机构代码
    private String gxdw;
    //主体分类(01-内资;02-私营;04-外资;09-个体;。。。)
    private String ztfl;

    public InnerCode() {
    }

    public InnerCode(String gxdw,String ztfl) {
        this.gxdw = gxdw;
        this.ztfl = ztfl;
    }

    /**
     * 获得内部编号
     * @param	String djjg:登记机关(6位)
     * @param   String pcjg: 派出机构(3位)
     * @param	String ztfl:主体分类(01-内资;02-私营;04-外资;09-个体;。。。)
     * @return  String 内部编号(在国家工商局标准中称之为“主体身份代码”)
     * @exception AppException
     */
    public String getInnerCode(String djjg,String pcjg,String ztfl) throws AppException{
         String innerCode = "";
         String currentDate="";
         String seqNo="";

         Calendar al=Calendar.getInstance();

         //得到当前日期的字符串:yyyymmdd
         currentDate = PubFunc.getYear(al) + PubFunc.getMonth(al) + PubFunc.getDay(al);
         Debug.print("current date is:"+currentDate);

         innerCode = djjg + pcjg + ztfl + currentDate ;

         try {
             //根据序列号产生器得到顺序号
             seqNo = getSeqNo();

         }
         catch (AppException ae) {
             throw new AppException(
               "InnerCode.getSeqNo(): Exception " +
               ae.getMessage());
         }

         //seqNo ="004";
         innerCode = innerCode + seqNo ;

         //加权值
         int[] wi ={8,4,2,1,6,3,7,9,10,5,8,4,2,1,6,3,7,9,10,5,8,4,2,1};
         //校验码字符值
         String ai[] ={"1","0","X","9","8","7","6","5","4","3","2"};
         int []in =new int[25];
         int sum = 0;
         
         for (int loop = 0;loop < 23; loop ++) {
             in[loop] = (new Integer(innerCode.substring(loop,loop + 1))).intValue();
             sum = sum + wi[loop] * in[loop];
         }         
         //对11取模
         int mod = sum % 11;

         //得到内部序号
         innerCode = innerCode + ai[mod];
         return innerCode;
    }

    /**
     * 根据序列号产生器得到顺序号
     * @return   String 顺序码
     * @exception AppException
     * CREATE SEQUENCE "GS"."INNERCODE_SEQ" INCREMENT BY 1 START WITH 1
     * MAXVALUE 9999 MINVALUE 0 CYCLE
     * NOCACHE NOORDER
     */
    public String getSeqNo() throws AppException{
        String seqNo = "";
        Connection conn = null;
        Statement stmt = null;
        ResultSet resu = null;
        String sql = null;
        int intSeqNo=0;
        try{
            conn = Common.getConnection();
            stmt = conn.createStatement();

            sql = "select INNERCODE_SEQ.NEXTVAL seq from DUAL";
            Debug.println("[InnerCode-->getSeqNo]获得顺序码列表:" + sql);
            resu = stmt.executeQuery(sql);
            if(resu.next()){
                 seqNo = resu.getString("seq") ;
            }
            else {
                  seqNo = "0";
            }

        } catch(Exception e){
            throw new AppException(
                "InnerCode.getSeqNo(): Exception " + e.getMessage());
        } finally{
            try{
                resu.close();
            } catch(Exception e){
            }
            try{
                stmt.close();
            } catch(Exception e){
            }
            try{
                conn.close();
            } catch(Exception e){
            }
        }


         //返回四位顺序码
         seqNo = "0000"+seqNo.trim();
         Debug.print("0000seqNo="+seqNo);

         seqNo = seqNo.substring(seqNo.length() - 4);
         Debug.print("seqNo="+seqNo);
         return seqNo;
    }



    /**
     * 获得内部编号中顺序码
     * @param	String innerCode19:内部编号中的前19位
     * @return   String 顺序码
     * @exception AppException
     * CREATE SEQUENCE "GS"."INNERCODE_SEQ" INCREMENT BY 1 START WITH 1
     * MAXVALUE 9999 MINVALUE 0 CYCLE
     * NOCACHE NOORDER
     */
    /*
    public String getSeqNo(String innerCode19) throws AppException{
        String seqNo = "";
        Connection conn = null;
        Statement stmt = null;
        ResultSet resu = null;
        String sql = null;
        try{
            conn = Common.getConnection();
            stmt = conn.createStatement();

            sql = "select max(field003),count(*) from " +
                DBUtil.GSGSJIN_BASIS + " where substr(field003,1,19) ='" + innerCode19 + "'";
            Debug.println("[InnerCode-->getSeqNo]获得顺序码(" + innerCode19 + ")列表:" + sql);
            resu = stmt.executeQuery(sql);
            if(resu.next()){
                  if (resu.getInt(1) == 0)
                      seqNo = "0000";
                  else
                      seqNo = (resu.getString(0)).substring(20,4);
            }
            else {
                  seqNo = "0000";
            }

        } catch(Exception e){
            throw new AppException(
                "EnterpriseDAO.getBusinessItem(String bid): Exception " +
                e.getMessage());
        } finally{
            try{
                resu.close();
            } catch(Exception e){
            }
            try{
                stmt.close();
            } catch(Exception e){
            }
            try{
                conn.close();
            } catch(Exception e){
            }
        }
         //最大的顺序码加一
         seqNo = (new Integer((new Integer(seqNo)).intValue() + 1)).toString();
         //返回四位顺序码
         seqNo = "0000"+seqNo.trim();
         Debug.print("0000seqNo="+seqNo);
         seqNo = seqNo.substring(seqNo.length() - 4);
         Debug.print("seqNo="+seqNo);
         return seqNo;
    }
    */
}

⌨️ 快捷键说明

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