package com.engine.kq.wfset.auto;

import com.engine.kq.cmd.hrmAttProcSet.KqTempletEnum;
import com.engine.kq.log.KQLog;
import com.engine.kq.wfset.attendance.domain.HrmAttProcAction;
import com.engine.kq.wfset.attendance.domain.HrmAttProcRelation;
import com.engine.kq.wfset.attendance.domain.HrmAttProcSet;
import com.engine.kq.wfset.attendance.manager.HrmAttProcActionManagerE9;
import com.engine.kq.wfset.attendance.manager.HrmAttProcRelationManager;
import com.engine.kq.wfset.attendance.manager.HrmAttProcSetManager;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import org.apache.commons.lang.StringEscapeUtils;
import weaver.common.StringUtil;
import weaver.conn.ConnectionPool;
import weaver.conn.RecordSet;
import weaver.conn.RecordSetTrans;
import weaver.general.BaseBean;
import weaver.general.TimeUtil;
import weaver.general.Util;
import weaver.hrm.User;
import weaver.hrm.moduledetach.ManageDetachComInfo;
import weaver.monitor.cache.CacheFactory;
import weaver.systeminfo.SystemEnv;
import weaver.systeminfo.label.LabelComInfo;
import weaver.workflow.action.WorkflowActionManager;
import weaver.workflow.form.FormManager;
import weaver.workflow.workflow.BillComInfo;
import weaver.workflow.workflow.WorkflowBillComInfo;

public class AutoInitWFSet {

  private User user;
  private boolean log;
  private boolean isdetail;
  private KQLog kqLog = new KQLog();

  public AutoInitWFSet() {
    this.log = true;
    this.isdetail = false;
  }

  public void InitWFSet(String symbol){
    RecordSet rs = new RecordSet();
    String wfSql = "select * from kq_wf_init where 1=1 and (cancelled is null or  cancelled <> '1') ";
    rs.executeQuery(wfSql);

    if(user == null){
      user = new User(1);
    }
//    Map<String,String> wfType = new HashMap<>();
//    Map<String,String> formNameLabels = new HashMap<>();

    while(rs.next()){
//    变更流程类型，0表示请假，1表示出差，2表示公出，3表示加班，4表示异常，5表示排班，6表示销假，7表示补卡
      String wftype = rs.getString("wftype");
      String usedetail = rs.getString("usedetail");
      if("1".equalsIgnoreCase(usedetail)){
        setIsdetail(true);
      }
      String wfname = SystemEnv.getHtmlLabelNames(rs.getString("wfnamelabel"), user.getLanguage());
      wfname = symbol+wfname;

      wfname = wfname.replaceAll("<","＜").replaceAll(">","＞");
      wfname = Util.toHtmlForSplitPage(wfname);
      int formid = 0;
      try {
        //先创建表单
        formid = InitForm(wftype,wfname);
        if(formid == 0){
          break;
        }
        //再创建流程
        Map<String,Object> wfMap = InitWorkflow(formid,wftype,wfname);
        //再把考勤流程设置基本信息和字段信息保存
        InitSet(formid,wftype,wfname,wfMap,usedetail);
      }catch (Exception e){
        rs.writeLog("wftype:"+wftype+":创建失败");
        e.printStackTrace();
        rs.writeLog(e.getMessage());
      }
    }
  }

  /**
   * 一建初始化，初始化考勤流程
   * @param wftype 0表示请假，1表示出差，2表示公出，3表示加班，4表示异常，5表示排班，6表示销假，7表示补卡
   * @param wfname
   * @throws Exception
   */
  public boolean initWfForKQ(int wftype,String wfname,String usedetail) {
    boolean isInit = true;
    try{
      wfname = wfname.replaceAll("<","＜").replaceAll(">","＞");
      wfname = Util.toHtmlForSplitPage(wfname);
      int formid = 0;
      //先创建表单
      formid = InitForm(wftype+"",wfname);
      if(formid == 0){
        return false;
      }
      //再创建流程
      Map<String,Object> wfMap = InitWorkflow(formid,wftype+"",wfname);
      //再把考勤流程设置基本信息和字段信息保存
      InitSet(formid,wftype+"",wfname,wfMap,usedetail);
    }catch (Exception e){
      isInit = false;
      new BaseBean().writeLog("wftype:"+wftype+":创建失败");
      e.printStackTrace();
    }

    return isInit;
  }

  public int InitForm(String wfType,String wfname) throws Exception{

    int formid = 0;
    //同名校验 通过
    if(!homonymyCheck(wfname)){
      RecordSet rs = new RecordSet();
      RecordSetTrans rst = new RecordSetTrans();
      FormManager formManager = new FormManager();
      ManageDetachComInfo manageDetachComInfo = new ManageDetachComInfo();
      LabelComInfo labelComInfo = new LabelComInfo();
      BillComInfo billComInfo = new BillComInfo();

      int subcompanyid = -1;
      int subCompanyId3 = -1;

      String formtable_main = "";
      String formtable_main_mx = "";

      formid = formManager.getNewFormId();
      formtable_main = "formtable_main_"+Math.abs(formid);
      formtable_main_mx = formtable_main+"_dt1";

      rst.setChecksql(false);
      rst.setAutoCommit(false);
      try{
        //1、先获取到表单的namelabelid
        int namelabelid = -1;
        if((rs.getDBType()).equalsIgnoreCase("sqlserver")){
          rst.executeSql("select indexid from HtmlLabelInfo "+
              " where labelname='"+StringEscapeUtils.escapeSql(wfname)+"' collate Chinese_PRC_CS_AI "+
              " and languageid="+Util.getIntValue(""+user.getLanguage(),7));
        }else {
          rst.executeSql("select indexid from HtmlLabelInfo "+
              " where labelname='"+StringEscapeUtils.escapeSql(wfname)+"' "+
              " and languageid="+Util.getIntValue(""+user.getLanguage(),7));
        }
        if(rst.next()){
          namelabelid = rst.getInt("indexid");//如果表单名称在标签库中存在，取得标签id
        }else{
          namelabelid = formManager.getNewIndexId(rst);//生成新的标签id
          if(namelabelid!=-1){//更新标签库
            rst.executeSql("delete from HtmlLabelIndex where id="+namelabelid);
            rst.executeSql("delete from HtmlLabelInfo where indexid="+namelabelid);
            rst.executeSql(" insert into HtmlLabelIndex(id,indexdesc)  values("+namelabelid+",'"+StringEscapeUtils.escapeSql(wfname)+"')");
            rst.executeSql(" insert into HtmlLabelInfo(INDEXID,labelname, LANGUAGEID)  values("+namelabelid+",'"+StringEscapeUtils.escapeSql(wfname)+"',7)");
            rst.executeSql(" insert into HtmlLabelInfo(INDEXID,labelname, LANGUAGEID)  values("+namelabelid+",'"+StringEscapeUtils.escapeSql(wfname)+"',8)");
            rst.executeSql(" insert into HtmlLabelInfo(INDEXID,labelname, LANGUAGEID)  values("+namelabelid+",'"+StringEscapeUtils.escapeSql(wfname)+"',9)");

            logAutoInit("insert into kq_autoinit_log(wftype,inittype,initids,initcolumn) values("+wfType+",'HtmlLabelIndex',"+namelabelid+",'id')");
            logAutoInit("insert into kq_autoinit_log(wftype,inittype,initids,initcolumn) values("+wfType+",'HtmlLabelInfo',"+namelabelid+",'indexid')");
          }
        }

        //2、获取分权分部。如果页面没有，则首先从分权设置的默认机构取得，如果默认机构没有设置则取所有分部中id最小的那个分部。
        subcompanyid = Util.getIntValue(manageDetachComInfo.getWfdftsubcomid(), -1);
        subCompanyId3 = Util.getIntValue(manageDetachComInfo.getWfdftsubcomid(), -1);
        if(subcompanyid==-1){
          rst.executeSql("select min(id) as id from HrmSubCompany");
          if(rst.next()){
            subcompanyid = rst.getInt("id");
          }
        }
        if(subCompanyId3==-1){
          rst.executeSql("select min(id) as id from HrmSubCompany");
          if(rst.next()){
            subCompanyId3 = rst.getInt("id");
          }
        }
        rst.executeSql("insert into workflow_bill(id,namelabel,tablename,detailkeyfield,formdes,subcompanyid,subCompanyId3) "+
            " values("+formid+","+namelabelid+",'"+StringEscapeUtils.escapeSql(formtable_main)+"','mainid','',"+subcompanyid+","+subCompanyId3+")");
        if(rs.getDBType().equalsIgnoreCase("oracle")){//创建表单主表，明细表的创建在新建字段的时候如果有明细字段则创建明细表
          rs.executeSql("create table " + formtable_main + "(id integer primary key not null, requestId integer)");
          if(isdetail) {
            //如果是明细表，oracle情况下还需要创建下序列和触发器
            String appendSql = "";
            rs.executeSql("create sequence "+formtable_main+"_Id start with 1 increment by 1  maxvalue 9223372036854775807 nocycle nocache ");
            rs.setChecksql(false);
            rs.executeSql("create or replace trigger "+formtable_main+"_ID_TR before insert on "+formtable_main+" for each row begin select "+formtable_main+"_Id.nextval into :new.id from dual; end;");
          }
        }else if((rs.getDBType()).equalsIgnoreCase("mysql")){
          rs.executeSql("create table " + formtable_main + "(id int AUTO_INCREMENT primary key  , requestId int)");
        }
        else if((rs.getDBType()).equalsIgnoreCase("postgresql")){
          rs.executeSql("create table " + formtable_main + "(id serial primary key  , requestId int)");
        }
        else{
          rs.executeSql("create table " + formtable_main + "(id int IDENTITY(1,1) primary key  , requestId int)");
        }
        logAutoInit("insert into kq_autoinit_log(wftype,inittype,initids,initcolumn) values("+wfType+",'workflow_bill',"+formid+",'id')");
        logAutoInit("insert into kq_autoinit_log(wftype,inittype,initids,initcolumn) values("+wfType+",'formtable_main','"+formtable_main+"','id')");
        logAutoInit("insert into kq_autoinit_log(wftype,inittype,initids,initcolumn) values("+wfType+",'formtable_main','"+formtable_main_mx+"','id')");

        //创建主表的sql
        List<String> tableCreateSql_array = new ArrayList<String>();
//        创建明细表的sql
        List<String> detailtable_array = new ArrayList<String>();
        //创建表索引的sql
        List<String> tableCreateIndexSql_array = new ArrayList<String>();
        //创建表字段的sql
        List<String> tableFieldInitSql_array = new ArrayList<String>();

//    变更流程类型，0表示请假，1表示出差，2表示公出，3表示加班，4表示异常，5表示排班，6表示销假
//    考勤流程数据库字段对应    180表示请假，181表示出差，182表示公出，45表示加班，0表示异常，5表示排班，6表示销假
        //0表示请假
        if("0".equals(wfType)){
          initWfType0(formid,formtable_main,formtable_main_mx,tableCreateSql_array,detailtable_array,tableCreateIndexSql_array,tableFieldInitSql_array);
        }
        //1表示出差
        if("1".equals(wfType)){
          initWfType1(formid,formtable_main,formtable_main_mx,tableCreateSql_array,detailtable_array,tableCreateIndexSql_array,tableFieldInitSql_array);
        }
        //2表示公出
        if("2".equals(wfType)){
          initWfType2(formid,formtable_main,formtable_main_mx,tableCreateSql_array,detailtable_array,tableCreateIndexSql_array,tableFieldInitSql_array);
        }
        //3表示加班
        if("3".equals(wfType)){
          initWfType3(formid,formtable_main,formtable_main_mx,tableCreateSql_array,detailtable_array,tableCreateIndexSql_array,tableFieldInitSql_array);
        }
        //4表示异常
        if("4".equals(wfType)){
          initWfType4(formid,formtable_main,formtable_main_mx,tableCreateSql_array,detailtable_array,tableCreateIndexSql_array,tableFieldInitSql_array);
        }
        //5表示排班
        if("5".equals(wfType)){
          initWfType5(formid,formtable_main,formtable_main_mx,tableCreateSql_array,detailtable_array,tableCreateIndexSql_array,tableFieldInitSql_array);
        }
        //6表示销假
        if("6".equals(wfType)){
          initWfType6(formid,formtable_main,formtable_main_mx,tableCreateSql_array,detailtable_array,tableCreateIndexSql_array,tableFieldInitSql_array);
        }
        //7表示补卡
        if("7".equals(wfType)){
          initWfType7(formid,formtable_main,formtable_main_mx,tableCreateSql_array,detailtable_array,tableCreateIndexSql_array,tableFieldInitSql_array);
        }
        //8表示考勤变更流程
        if("8".equals(wfType)){
          initWfType8(formid,formtable_main,formtable_main_mx,tableCreateSql_array,detailtable_array,tableCreateIndexSql_array,tableFieldInitSql_array);
        }

        //添加主表字段、建明细表
        for(int tempi=0;tempi<tableCreateSql_array.size();tempi++){
          String tableCreateSql = tableCreateSql_array.get(tempi);
          rst.executeSql(tableCreateSql);
          //rs.writeLog("tableCreateSql: " + tableCreateSql);
        }
        //建索引
        for(int tempi=0;tempi<tableCreateIndexSql_array.size();tempi++){
          String tableCreateIndexSql = tableCreateIndexSql_array.get(tempi);
          rst.executeSql(tableCreateIndexSql);
          //rs.writeLog("tableCreateIndexSql: " + tableCreateIndexSql);
        }
        //建明细表外键mainid的索引，并且插入明细表主表关系表关系记录
        for(int tempi=0;tempi<detailtable_array.size();tempi++){
          String detailtable = detailtable_array.get(tempi);//明细表名称
          //插入表单明细表信息workflow_billdetailtable
          rst.executeSql("INSERT INTO workflow_billdetailtable(billid,tablename,orderid) values("+formid+",'"+StringEscapeUtils.escapeSql(detailtable)+"',"+(tempi+1)+")");

          logAutoInit("insert into kq_autoinit_log(wftype,inittype,initids,initcolumn) values("+wfType+",'workflow_billdetailtable',"+formid+",'billid')");
          //rs.writeLog("INSERT INTO workflow_billdetailtable(billid,tablename,orderid) values("+formid+",'"+StringEscapeUtils.escapeSql(detailtable)+"',"+(tempi+1)+")");
        }
        //初始化明细表字段信息
        for(int tempi=0;tempi<tableFieldInitSql_array.size();tempi++){
          String tableFieldInitSql = tableFieldInitSql_array.get(tempi);
          //new BaseBean().writeLog(tableFieldInitSql);
          rst.executeSql(tableFieldInitSql);
          //rs.writeLog("tableFieldInitSql: " + tableFieldInitSql);
        }

        if(!tableFieldInitSql_array.isEmpty()){
          logAutoInit("insert into kq_autoinit_log(wftype,inittype,initids,initcolumn) values("+wfType+",'workflow_billfield',"+formid+",'billid')");
        }


        if("7".equals(wfType)){
          //补卡流程的补卡类型是需要单独处理的
          rst.executeSql("select id from workflow_billfield where detailtable = '"+formtable_main_mx+"' and fieldname = 'detail_signtype' and billid = "+formid);
          if(rst.next()){
            int fieldid = rst.getInt("id");
            rst.executeSql("INSERT INTO workflow_SelectItem\n" +
                " (fieldid,isbill,selectvalue,selectname,listorder,isdefault,docPath,docCategory,isAccordToSubCom,childitemid,cancel,pubid)\n" +
                " VALUES\n" +
                " ("+fieldid+",1,0,'"+SystemEnv.getHtmlLabelName(21974, user.getLanguage())+"',0,'n',NULL,NULL,'0',NULL,'0',NULL)");
            rst.executeSql("INSERT INTO workflow_SelectItem\n" +
                " (fieldid,isbill,selectvalue,selectname,listorder,isdefault,docPath,docCategory,isAccordToSubCom,childitemid,cancel,pubid)\n" +
                " VALUES\n" +
                " ("+fieldid+",1,1,'"+SystemEnv.getHtmlLabelName(21975, user.getLanguage())+"',1,'y',NULL,NULL,'0',NULL,'0',NULL)");

            //rst.writeLog("INSERT INTO workflow_SelectItem\n" +
//                " (fieldid,isbill,selectvalue,selectname,listorder,isdefault,docPath,docCategory,isAccordToSubCom,childitemid,cancel,pubid)\n" +
//                " VALUES\n" +
//                " ("+fieldid+",1,0,'关联调休',0,'n',NULL,NULL,'0',NULL,'0',NULL)");
            //rst.writeLog("INSERT INTO workflow_SelectItem\n" +
//                " (fieldid,isbill,selectvalue,selectname,listorder,isdefault,docPath,docCategory,isAccordToSubCom,childitemid,cancel,pubid)\n" +
//                " VALUES\n" +
//                " ("+fieldid+",1,1,'不关联调休',1,'y',NULL,NULL,'0',NULL,'0',NULL)");
            logAutoInit("insert into kq_autoinit_log(wftype,inittype,initids,initcolumn) values("+wfType+",'workflow_SelectItem',"+fieldid+",'fieldid')");
          }

        }

        if("8".equals(wfType)){
          //考勤变更流程的补变更类型是需要单独处理的
          rst.executeSql("select id from workflow_billfield where fieldname = 'changetype' and billid = "+formid);
          if(rst.next()){
            int fieldid = rst.getInt("id");
            rst.executeSql("INSERT INTO workflow_SelectItem\n" +
                " (fieldid,isbill,selectvalue,selectname,listorder,isdefault,docPath,docCategory,isAccordToSubCom,childitemid,cancel,pubid)\n" +
                " VALUES\n" +
                " ("+fieldid+",1,0,'"+SystemEnv.getHtmlLabelName(25484, user.getLanguage())+"',0,'y',NULL,NULL,'0',NULL,'0',NULL)");
            rst.executeSql("INSERT INTO workflow_SelectItem\n" +
                " (fieldid,isbill,selectvalue,selectname,listorder,isdefault,docPath,docCategory,isAccordToSubCom,childitemid,cancel,pubid)\n" +
                " VALUES\n" +
                " ("+fieldid+",1,1,'"+SystemEnv.getHtmlLabelName(16210, user.getLanguage())+"',1,'n',NULL,NULL,'0',NULL,'0',NULL)");

            logAutoInit("insert into kq_autoinit_log(wftype,inittype,initids,initcolumn) values("+wfType+",'workflow_SelectItem',"+fieldid+",'fieldid')");
          }

        }

        if("3".equals(wfType)){
          //加班流程的加班类型类型是需要单独处理的
          if(isdetail) {
            rst.executeSql("select id from workflow_billfield where detailtable = '"+formtable_main_mx+"' and fieldname = 'detail_overtime_type' and billid = "+formid);
            if(rst.next()){
              int fieldid = rst.getInt("id");
              rst.executeSql("INSERT INTO workflow_SelectItem\n" +
                  " (fieldid,isbill,selectvalue,selectname,listorder,isdefault,docPath,docCategory,isAccordToSubCom,childitemid,cancel,pubid)\n" +
                  " VALUES\n" +
                  " ("+fieldid+",1,0,'"+SystemEnv.getHtmlLabelName(125804, user.getLanguage())+"',0,'y',NULL,NULL,'0',NULL,'0',NULL)");
              rst.executeSql("INSERT INTO workflow_SelectItem\n" +
                  " (fieldid,isbill,selectvalue,selectname,listorder,isdefault,docPath,docCategory,isAccordToSubCom,childitemid,cancel,pubid)\n" +
                  " VALUES\n" +
                  " ("+fieldid+",1,1,'"+SystemEnv.getHtmlLabelName(125805, user.getLanguage())+"',1,'n',NULL,NULL,'0',NULL,'0',NULL)");

              logAutoInit("insert into kq_autoinit_log(wftype,inittype,initids,initcolumn) values("+wfType+",'workflow_SelectItem',"+fieldid+",'fieldid')");
            }
          }else{
            rst.executeSql("select id from workflow_billfield where fieldname = 'overtime_type' and billid = "+formid);
            if(rst.next()){
              int fieldid = rst.getInt("id");
              rst.executeSql("INSERT INTO workflow_SelectItem\n" +
                  " (fieldid,isbill,selectvalue,selectname,listorder,isdefault,docPath,docCategory,isAccordToSubCom,childitemid,cancel,pubid)\n" +
                  " VALUES\n" +
                  " ("+fieldid+",1,0,'"+SystemEnv.getHtmlLabelName(125804, user.getLanguage())+"',0,'y',NULL,NULL,'0',NULL,'0',NULL)");
              rst.executeSql("INSERT INTO workflow_SelectItem\n" +
                  " (fieldid,isbill,selectvalue,selectname,listorder,isdefault,docPath,docCategory,isAccordToSubCom,childitemid,cancel,pubid)\n" +
                  " VALUES\n" +
                  " ("+fieldid+",1,1,'"+SystemEnv.getHtmlLabelName(125805, user.getLanguage())+"',1,'n',NULL,NULL,'0',NULL,'0',NULL)");

              logAutoInit("insert into kq_autoinit_log(wftype,inittype,initids,initcolumn) values("+wfType+",'workflow_SelectItem',"+fieldid+",'fieldid')");
            }
          }

        }

//        if(!(rs.getDBType()).equalsIgnoreCase("oracle")){//因为在sql里面detailtable的默认值NULL，显示排序的时候按照detailtable排序，当detailtable有空值和null时，排序会乱
//          rs.executeSql("update workflow_billfield set detailtable = '' where detailtable is null");
//        }
        labelComInfo.addLabeInfoCache(""+namelabelid);//往缓存中添加表单名称的标签
        billComInfo.addBillCache(""+formid);
        WorkflowBillComInfo workflowBillComInfo=new WorkflowBillComInfo();
        workflowBillComInfo.addWorkflowBillCache(String.valueOf(formid));

        //最后肯定是要提交事务的
        rst.commit();
        rst.setChecksql(true);
      }catch (Exception e){
        try{
          rst.rollback();
          rst.setChecksql(true);
        }catch(Exception ex1){}
        new BaseBean().writeLog(e);
        throw new Exception("表单创建失败");
      }

    }else {
      new BaseBean().writeLog("重名:"+wfname);
      throw new Exception(SystemEnv.getHtmlLabelName(83791,user.getLanguage()));
    }
    return formid;
  }

  /**
   * 请假流程的表结构创建
   * @param formid
   * @param formtable_main
   * @param formtable_main_mx
   * @param tableCreateSql_array
   * @param detailtable_array
   * @param tableCreateIndexSql_array
   * @param tableFieldInitSql_array
   */
  private void initWfType0(int formid,String formtable_main, String formtable_main_mx,List<String> tableCreateSql_array,List<String> detailtable_array,List<String> tableCreateIndexSql_array,List<String> tableFieldInitSql_array) {

    RecordSet rs = new RecordSet();
    if(isdetail){
      detailtable_array.add(formtable_main_mx);
    }
    if(rs.getDBType().equalsIgnoreCase("oracle")){
      if(isdetail) {
        tableCreateSql_array.add("create table " + formtable_main_mx
            + " (id integer primary key not null, mainid integer, " +
            "detail_resourceId int, detail_departmentId int, detail_newLeaveType int, detail_fromDate char(10),"
            +
            "detail_fromTime char(8), detail_toDate char(10), detail_toTime char(8), detail_duration decimal(15,2), detail_vacationInfo varchar2(500))");
        tableCreateIndexSql_array.add("create sequence "+formtable_main_mx+"_ID minvalue 1 maxvalue 9223372036854775807 start with 1 increment by 1 nocache ");

        tableCreateIndexSql_array.add("create or replace trigger " + formtable_main_mx + "_ID_TR " +
            " before insert on " + formtable_main_mx + " for each row " +
            " begin " +
            "   select " + formtable_main_mx + "_ID.nextval into :new.id from dual; " +
            " end;");
        tableCreateIndexSql_array.add(
            "create index idx_" + formtable_main_mx + " on " + formtable_main_mx
                + " (detail_resourceId)");

        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'detail_resourceId',413,'int','3',1,1,'"+formtable_main_mx+"','1',0,1.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'detail_departmentId',124,'int','3',4,1,'"+formtable_main_mx+"','1',0,2.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'detail_newLeaveType',1881,'int','3',34,1,'"+formtable_main_mx+"','1',0,3.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'detail_fromDate',740,'char(10)','3',2,1,'"+formtable_main_mx+"','1',0,4.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'detail_fromTime',742,'char(8)','3',19,1,'"+formtable_main_mx+"','1',0,5.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'detail_toDate',741,'char(10)','3',2,1,'"+formtable_main_mx+"','1',0,6.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'detail_toTime',743,'char(8)','3',19,1,'"+formtable_main_mx+"','1',0,7.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'detail_duration',21551,'decimal(15,2)','1',3,1,'"+formtable_main_mx+"','1',0,8.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'detail_vacationInfo',390297,'varchar(500)','2',1,1,'"+formtable_main_mx+"','1',4,9.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");

      }else{
        tableCreateSql_array.add("alter table "+formtable_main+" add resourceId int");
        tableCreateSql_array.add("alter table "+formtable_main+" add departmentId int");
        tableCreateSql_array.add("alter table "+formtable_main+" add newLeaveType int");
        tableCreateSql_array.add("alter table "+formtable_main+" add fromDate char(10)");
        tableCreateSql_array.add("alter table "+formtable_main+" add fromTime char(8)");
        tableCreateSql_array.add("alter table "+formtable_main+" add toDate char(10)");
        tableCreateSql_array.add("alter table "+formtable_main+" add toTime char(8)");
        tableCreateSql_array.add("alter table "+formtable_main+" add duration decimal(15,2)");
        tableCreateSql_array.add("alter table "+formtable_main+" add vacationInfo varchar(500)");

        tableCreateIndexSql_array.add("create sequence "+formtable_main+"_ID minvalue 1 maxvalue 9223372036854775807 start with 1 increment by 1 nocache ");

        tableCreateIndexSql_array.add("create or replace trigger "+formtable_main+"_ID_TR " +
            " before insert on "+formtable_main+" for each row " +
            " begin " +
            "   select "+formtable_main+"_ID.nextval into :new.id from dual; " +
            " end;");
        tableCreateIndexSql_array.add("create index idx_"+formtable_main+" on "+formtable_main+" (resourceId)");

        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'resourceId',413,'int','3',1,0,'','1',0,1.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'departmentId',124,'int','3',4,0,'','1',0,2.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'newLeaveType',1881,'int','3',34,0,'','1',0,3.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'fromDate',740,'char(10)','3',2,0,'','1',0,4.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'fromTime',742,'char(8)','3',19,0,'','1',0,5.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'toDate',741,'char(10)','3',2,0,'','1',0,6.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'toTime',743,'char(8)','3',19,0,'','1',0,7.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'duration',21551,'decimal(15,2)','1',3,0,'','1',0,8.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'vacationInfo',390297,'varchar(500)','2',1,0,'','1',4,9.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");
      }
      logAutoInit("insert into kq_autoinit_log(wftype,inittype,initids,initcolumn) values(0,'sequence','"+formtable_main+"_ID','id')");
      logAutoInit("insert into kq_autoinit_log(wftype,inittype,initids,initcolumn) values(0,'sequence','"+formtable_main_mx+"_ID','id')");

    }else if((rs.getDBType()).equalsIgnoreCase("mysql")){
      if(isdetail) {
        tableCreateSql_array.add("create table "+formtable_main_mx+" (id int AUTO_INCREMENT primary key not null, mainid integer, "+
                "detail_resourceId int, detail_departmentId int, detail_newLeaveType int, detail_fromDate char(10),"+
                "detail_fromTime char(8), detail_toDate char(10), detail_toTime char(8), detail_duration decimal(15,2), detail_vacationInfo varchar(500))");
        tableCreateIndexSql_array.add("create index idx_"+formtable_main_mx+" on "+formtable_main_mx+" (detail_resourceId)");

        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
                "values("+formid+",'detail_resourceId',413,'int','3',1,1,'"+formtable_main_mx+"','1',0,1.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
                "values("+formid+",'detail_departmentId',124,'int','3',4,1,'"+formtable_main_mx+"','1',0,2.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
                "values("+formid+",'detail_newLeaveType',1881,'int','3',34,1,'"+formtable_main_mx+"','1',0,3.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
                "values("+formid+",'detail_fromDate',740,'char(10)','3',2,1,'"+formtable_main_mx+"','1',0,4.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
                "values("+formid+",'detail_fromTime',742,'char(8)','3',19,1,'"+formtable_main_mx+"','1',0,5.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
                "values("+formid+",'detail_toDate',741,'char(10)','3',2,1,'"+formtable_main_mx+"','1',0,6.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
                "values("+formid+",'detail_toTime',743,'char(8)','3',19,1,'"+formtable_main_mx+"','1',0,7.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
                "values("+formid+",'detail_duration',21551,'decimal(15,2)','1',3,1,'"+formtable_main_mx+"','1',0,8.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
                "values("+formid+",'detail_vacationInfo',390297,'varchar(500)','2',1,1,'"+formtable_main_mx+"','1',4,9.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");

      }
      else{
        tableCreateSql_array.add("alter table "+formtable_main+" add resourceId int");
        tableCreateSql_array.add("alter table "+formtable_main+" add departmentId int");
        tableCreateSql_array.add("alter table "+formtable_main+" add newLeaveType int");
        tableCreateSql_array.add("alter table "+formtable_main+" add fromDate char(10)");
        tableCreateSql_array.add("alter table "+formtable_main+" add fromTime char(8)");
        tableCreateSql_array.add("alter table "+formtable_main+" add toDate char(10)");
        tableCreateSql_array.add("alter table "+formtable_main+" add toTime char(8)");
        tableCreateSql_array.add("alter table "+formtable_main+" add duration decimal(15,2)");
        tableCreateSql_array.add("alter table "+formtable_main+" add vacationInfo varchar(500)");

        tableCreateIndexSql_array.add("create index idx_"+formtable_main+" on "+formtable_main+" (resourceId)");

        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
                "values("+formid+",'resourceId',413,'int','3',1,0,'','1',0,1.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
                "values("+formid+",'departmentId',124,'int','3',4,0,'','1',0,2.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
                "values("+formid+",'newLeaveType',1881,'int','3',34,0,'','1',0,3.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
                "values("+formid+",'fromDate',740,'char(10)','3',2,0,'','1',0,4.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
                "values("+formid+",'fromTime',742,'char(8)','3',19,0,'','1',0,5.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
                "values("+formid+",'toDate',741,'char(10)','3',2,0,'','1',0,6.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
                "values("+formid+",'toTime',743,'char(8)','3',19,0,'','1',0,7.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
                "values("+formid+",'duration',21551,'decimal(15,2)','1',3,0,'','1',0,8.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
                "values("+formid+",'vacationInfo',390297,'varchar(500)','2',1,0,'','1',4,9.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");

      }

    }
    else if((rs.getDBType()).equalsIgnoreCase("postgresql")){
      if(isdetail) {
        tableCreateSql_array.add("create table "+formtable_main_mx+" (id serial primary key not null, mainid integer, "+
                "detail_resourceId int, detail_departmentId int, detail_newLeaveType int, detail_fromDate char(10),"+
                "detail_fromTime char(8), detail_toDate char(10), detail_toTime char(8), detail_duration decimal(15,2), detail_vacationInfo varchar(500))");
        //tableCreateIndexSql_array.add("create unique  index idx_"+formtable_main_mx+" on "+formtable_main_mx+" (detail_resourceId)");

        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
                "values("+formid+",'detail_resourceId',413,'int','3',1,1,'"+formtable_main_mx+"','1',0,1.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
                "values("+formid+",'detail_departmentId',124,'int','3',4,1,'"+formtable_main_mx+"','1',0,2.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
                "values("+formid+",'detail_newLeaveType',1881,'int','3',34,1,'"+formtable_main_mx+"','1',0,3.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
                "values("+formid+",'detail_fromDate',740,'char(10)','3',2,1,'"+formtable_main_mx+"','1',0,4.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
                "values("+formid+",'detail_fromTime',742,'char(8)','3',19,1,'"+formtable_main_mx+"','1',0,5.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
                "values("+formid+",'detail_toDate',741,'char(10)','3',2,1,'"+formtable_main_mx+"','1',0,6.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
                "values("+formid+",'detail_toTime',743,'char(8)','3',19,1,'"+formtable_main_mx+"','1',0,7.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
                "values("+formid+",'detail_duration',21551,'decimal(15,2)','1',3,1,'"+formtable_main_mx+"','1',0,8.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
                "values("+formid+",'detail_vacationInfo',390297,'varchar(500)','2',1,1,'"+formtable_main_mx+"','1',4,9.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");

      }
      else{
        tableCreateSql_array.add("alter table "+formtable_main+" add resourceId int");
        tableCreateSql_array.add("alter table "+formtable_main+" add departmentId int");
        tableCreateSql_array.add("alter table "+formtable_main+" add newLeaveType int");
        tableCreateSql_array.add("alter table "+formtable_main+" add fromDate char(10)");
        tableCreateSql_array.add("alter table "+formtable_main+" add fromTime char(8)");
        tableCreateSql_array.add("alter table "+formtable_main+" add toDate char(10)");
        tableCreateSql_array.add("alter table "+formtable_main+" add toTime char(8)");
        tableCreateSql_array.add("alter table "+formtable_main+" add duration decimal(15,2)");
        tableCreateSql_array.add("alter table "+formtable_main+" add vacationInfo varchar(500)");

        tableCreateIndexSql_array.add("create index idx_"+formtable_main+" on "+formtable_main+" (resourceId)");

        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
                "values("+formid+",'resourceId',413,'int','3',1,0,'','1',0,1.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
                "values("+formid+",'departmentId',124,'int','3',4,0,'','1',0,2.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
                "values("+formid+",'newLeaveType',1881,'int','3',34,0,'','1',0,3.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
                "values("+formid+",'fromDate',740,'char(10)','3',2,0,'','1',0,4.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
                "values("+formid+",'fromTime',742,'char(8)','3',19,0,'','1',0,5.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
                "values("+formid+",'toDate',741,'char(10)','3',2,0,'','1',0,6.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
                "values("+formid+",'toTime',743,'char(8)','3',19,0,'','1',0,7.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
                "values("+formid+",'duration',21551,'decimal(15,2)','1',3,0,'','1',0,8.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
                "values("+formid+",'vacationInfo',390297,'varchar(500)','2',1,0,'','1',4,9.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");

      }

    }

    else{
      if(isdetail) {

        tableCreateSql_array.add("create table "+formtable_main_mx+" (id int IDENTITY(1,1) primary key not null, mainid integer, "+
            "detail_resourceId int, detail_departmentId int, detail_newLeaveType int, detail_fromDate char(10),"+
            "detail_fromTime char(8), detail_toDate char(10), detail_toTime char(8), detail_duration decimal(15,2), detail_vacationInfo varchar(500))");
        tableCreateIndexSql_array.add("create index idx_"+formtable_main_mx+" on "+formtable_main_mx+" (detail_resourceId)");

        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'detail_resourceId',413,'int','3',1,1,'"+formtable_main_mx+"','1',0,1.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'detail_departmentId',124,'int','3',4,1,'"+formtable_main_mx+"','1',0,2.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'detail_newLeaveType',1881,'int','3',34,1,'"+formtable_main_mx+"','1',0,3.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'detail_fromDate',740,'char(10)','3',2,1,'"+formtable_main_mx+"','1',0,4.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'detail_fromTime',742,'char(8)','3',19,1,'"+formtable_main_mx+"','1',0,5.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'detail_toDate',741,'char(10)','3',2,1,'"+formtable_main_mx+"','1',0,6.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'detail_toTime',743,'char(8)','3',19,1,'"+formtable_main_mx+"','1',0,7.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'detail_duration',21551,'decimal(15,2)','1',3,1,'"+formtable_main_mx+"','1',0,8.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'detail_vacationInfo',390297,'varchar(500)','2',1,1,'"+formtable_main_mx+"','1',4,9.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");

      }else{

        tableCreateSql_array.add("alter table "+formtable_main+" add resourceId int");
        tableCreateSql_array.add("alter table "+formtable_main+" add departmentId int");
        tableCreateSql_array.add("alter table "+formtable_main+" add newLeaveType int");
        tableCreateSql_array.add("alter table "+formtable_main+" add fromDate char(10)");
        tableCreateSql_array.add("alter table "+formtable_main+" add fromTime char(8)");
        tableCreateSql_array.add("alter table "+formtable_main+" add toDate char(10)");
        tableCreateSql_array.add("alter table "+formtable_main+" add toTime char(8)");
        tableCreateSql_array.add("alter table "+formtable_main+" add duration decimal(15,2)");
        tableCreateSql_array.add("alter table "+formtable_main+" add vacationInfo varchar(500)");

        tableCreateIndexSql_array.add("create index idx_"+formtable_main+" on "+formtable_main+" (resourceId)");

        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'resourceId',413,'int','3',1,0,'','1',0,1.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'departmentId',124,'int','3',4,0,'','1',0,2.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'newLeaveType',1881,'int','3',34,0,'','1',0,3.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'fromDate',740,'char(10)','3',2,0,'','1',0,4.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'fromTime',742,'char(8)','3',19,0,'','1',0,5.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'toDate',741,'char(10)','3',2,0,'','1',0,6.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'toTime',743,'char(8)','3',19,0,'','1',0,7.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'duration',21551,'decimal(15,2)','1',3,0,'','1',0,8.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'vacationInfo',390297,'varchar(500)','2',1,0,'','1',4,9.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");

      }
    }

  }

  /**
   * 出差流程的表结构创建
   * @param formid
   * @param formtable_main
   * @param formtable_main_mx
   * @param tableCreateSql_array
   * @param detailtable_array
   * @param tableCreateIndexSql_array
   * @param tableFieldInitSql_array
   */
  private void initWfType1(int formid,String formtable_main, String formtable_main_mx,List<String> tableCreateSql_array,List<String> detailtable_array,List<String> tableCreateIndexSql_array,List<String> tableFieldInitSql_array) {

    RecordSet rs = new RecordSet();

    if(isdetail) {
      detailtable_array.add(formtable_main_mx);
    }
    if(rs.getDBType().equalsIgnoreCase("oracle")){

      if(isdetail) {
        tableCreateSql_array.add("create table "+formtable_main_mx+" (id integer primary key not null, mainid integer, "+
            "detail_resourceId int, detail_departmentId int, detail_fromDate char(10),"+
            "detail_fromTime char(8), detail_toDate char(10), detail_toTime char(8), detail_duration decimal(15,2), detail_companion clob)");

        tableCreateIndexSql_array.add("create sequence "+formtable_main_mx+"_ID minvalue 1 maxvalue 9223372036854775807 start with 1 increment by 1 nocache ");

        tableCreateIndexSql_array.add("create or replace trigger "+formtable_main_mx+"_ID_TR " +
            " before insert on "+formtable_main_mx+" for each row " +
            " begin " +
            "   select "+formtable_main_mx+"_ID.nextval into :new.id from dual; " +
            " end;");
        tableCreateIndexSql_array.add("create index idx_"+formtable_main_mx+" on "+formtable_main_mx+" (detail_resourceId)");


        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'detail_resourceId',413,'int','3',1,1,'"+formtable_main_mx+"','1',0,1.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'detail_departmentId',124,'int','3',4,1,'"+formtable_main_mx+"','1',0,2.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'detail_fromDate',740,'char(10)','3',2,1,'"+formtable_main_mx+"','1',0,4.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'detail_fromTime',742,'char(8)','3',19,1,'"+formtable_main_mx+"','1',0,5.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'detail_toDate',741,'char(10)','3',2,1,'"+formtable_main_mx+"','1',0,6.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'detail_toTime',743,'char(8)','3',19,1,'"+formtable_main_mx+"','1',0,7.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'detail_duration','21551','decimal(15,2)','1',3,1,'"+formtable_main_mx+"','1',0,8.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'detail_companion','27209','clob','3',17,1,'"+formtable_main_mx+"','1',0,9.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");

      }else{

        tableCreateSql_array.add("alter table "+formtable_main+" add resourceId int");
        tableCreateSql_array.add("alter table "+formtable_main+" add departmentId int");
        tableCreateSql_array.add("alter table "+formtable_main+" add fromDate char(10)");
        tableCreateSql_array.add("alter table "+formtable_main+" add fromTime char(8)");
        tableCreateSql_array.add("alter table "+formtable_main+" add toDate char(10)");
        tableCreateSql_array.add("alter table "+formtable_main+" add toTime char(8)");
        tableCreateSql_array.add("alter table "+formtable_main+" add duration decimal(15,2)");
        tableCreateSql_array.add("alter table "+formtable_main+" add companion clob");
        if("jc".equalsIgnoreCase(rs.getOrgindbtype()) || "st".equalsIgnoreCase(rs.getOrgindbtype()) || "gs".equalsIgnoreCase(rs.getOrgindbtype())){
          tableCreateIndexSql_array.add("create sequence "+formtable_main+"_ID increment by 1 start with 1 MINVALUE 1 maxvalue 9223372036854775807  NOCYCLE ");
        }else{
          tableCreateIndexSql_array.add("create sequence "+formtable_main+"_ID increment by 1 start with 1 MINVALUE 1 maxvalue 9999999999999999999999999999 NOCYCLE ");
        }

        tableCreateIndexSql_array.add("create or replace trigger "+formtable_main+"_ID_TR " +
            " before insert on "+formtable_main+" for each row " +
            " begin " +
            "   select "+formtable_main+"_ID.nextval into :new.id from dual; " +
            " end;");

        tableCreateIndexSql_array.add("create index idx_"+formtable_main+" on "+formtable_main+" (resourceId)");

        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'resourceId',413,'int','3',1,0,'','1',0,1.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'departmentId',124,'int','3',4,0,'','1',0,2.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'fromDate',740,'char(10)','3',2,0,'','1',0,4.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'fromTime',742,'char(8)','3',19,0,'','1',0,5.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'toDate',741,'char(10)','3',2,0,'','1',0,6.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'toTime',743,'char(8)','3',19,0,'','1',0,7.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'duration',21551,'decimal(15,2)','1',3,0,'','1',4,8.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'companion',27209,'clob','3',17,0,'','1',4,9.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");

      }

      logAutoInit("insert into kq_autoinit_log(wftype,inittype,initids,initcolumn) values(1,'sequence','"+formtable_main+"_ID','id')");
      logAutoInit("insert into kq_autoinit_log(wftype,inittype,initids,initcolumn) values(1,'sequence','"+formtable_main_mx+"_ID','id')");

    }else if((rs.getDBType()).equalsIgnoreCase("mysql")){
      if(isdetail) {
        tableCreateSql_array.add("create table "+formtable_main_mx+" (id int AUTO_INCREMENT primary key not null, mainid integer, "+
            "detail_resourceId int, detail_departmentId int, detail_fromDate char(10),"+
            "detail_fromTime char(8), detail_toDate char(10), detail_toTime char(8), detail_duration decimal(15,2), detail_companion text)");

        tableCreateIndexSql_array.add("create index idx_"+formtable_main_mx+" on "+formtable_main_mx+" (detail_resourceId)");

        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'detail_resourceId',413,'int','3',1,1,'"+formtable_main_mx+"','1',0,1.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'detail_departmentId',124,'int','3',4,1,'"+formtable_main_mx+"','1',0,2.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'detail_fromDate',740,'char(10)','3',2,1,'"+formtable_main_mx+"','1',0,4.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'detail_fromTime',742,'char(8)','3',19,1,'"+formtable_main_mx+"','1',0,5.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'detail_toDate',741,'char(10)','3',2,1,'"+formtable_main_mx+"','1',0,6.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'detail_toTime',743,'char(8)','3',19,1,'"+formtable_main_mx+"','1',0,7.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'detail_duration','21551','decimal(15,2)','1',3,1,'"+formtable_main_mx+"','1',0,8.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'detail_companion','27209','text','3',17,1,'"+formtable_main_mx+"','1',0,9.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");

      }
      else{

        tableCreateSql_array.add("alter table "+formtable_main+" add resourceId int");
        tableCreateSql_array.add("alter table "+formtable_main+" add departmentId int");
        tableCreateSql_array.add("alter table "+formtable_main+" add fromDate char(10)");
        tableCreateSql_array.add("alter table "+formtable_main+" add fromTime char(8)");
        tableCreateSql_array.add("alter table "+formtable_main+" add toDate char(10)");
        tableCreateSql_array.add("alter table "+formtable_main+" add toTime char(8)");
        tableCreateSql_array.add("alter table "+formtable_main+" add duration decimal(15,2)");
        tableCreateSql_array.add("alter table "+formtable_main+" add companion text");

        tableCreateIndexSql_array.add("create unique  index idx_"+formtable_main+" on "+formtable_main+" (resourceId)");

        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'resourceId',413,'int','3',1,0,'','1',0,1.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'departmentId',124,'int','3',4,0,'','1',0,2.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'fromDate',740,'char(10)','3',2,0,'','1',0,4.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'fromTime',742,'char(8)','3',19,0,'','1',0,5.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'toDate',741,'char(10)','3',2,0,'','1',0,6.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'toTime',743,'char(8)','3',19,0,'','1',0,7.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'duration',21551,'decimal(15,2)','1',3,0,'','1',0,8.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'companion',27209,'text','3',17,0,'','1',4,9.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");

      }

    }
    else if((rs.getDBType()).equalsIgnoreCase("postgresql")){
      if(isdetail) {
        tableCreateSql_array.add("create table "+formtable_main_mx+" (id serial primary key not null, mainid integer, "+
                "detail_resourceId int, detail_departmentId int, detail_fromDate char(10),"+
                "detail_fromTime char(8), detail_toDate char(10), detail_toTime char(8), detail_duration decimal(15,2), detail_companion text)");

        tableCreateIndexSql_array.add("create   index idx_"+formtable_main_mx+" on "+formtable_main_mx+" (detail_resourceId)");

        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
                "values("+formid+",'detail_resourceId',413,'int','3',1,1,'"+formtable_main_mx+"','1',0,1.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
                "values("+formid+",'detail_departmentId',124,'int','3',4,1,'"+formtable_main_mx+"','1',0,2.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
                "values("+formid+",'detail_fromDate',740,'char(10)','3',2,1,'"+formtable_main_mx+"','1',0,4.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
                "values("+formid+",'detail_fromTime',742,'char(8)','3',19,1,'"+formtable_main_mx+"','1',0,5.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
                "values("+formid+",'detail_toDate',741,'char(10)','3',2,1,'"+formtable_main_mx+"','1',0,6.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
                "values("+formid+",'detail_toTime',743,'char(8)','3',19,1,'"+formtable_main_mx+"','1',0,7.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
                "values("+formid+",'detail_duration','21551','decimal(15,2)','1',3,1,'"+formtable_main_mx+"','1',0,8.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
                "values("+formid+",'detail_companion','27209','text','3',17,1,'"+formtable_main_mx+"','1',0,9.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");

      }
      else{

        tableCreateSql_array.add("alter table "+formtable_main+" add resourceId int");
        tableCreateSql_array.add("alter table "+formtable_main+" add departmentId int");
        tableCreateSql_array.add("alter table "+formtable_main+" add fromDate char(10)");
        tableCreateSql_array.add("alter table "+formtable_main+" add fromTime char(8)");
        tableCreateSql_array.add("alter table "+formtable_main+" add toDate char(10)");
        tableCreateSql_array.add("alter table "+formtable_main+" add toTime char(8)");
        tableCreateSql_array.add("alter table "+formtable_main+" add duration decimal(15,2)");
        tableCreateSql_array.add("alter table "+formtable_main+" add companion text");

        tableCreateIndexSql_array.add("create    index idx_"+formtable_main+" on "+formtable_main+" (resourceId)");

        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
                "values("+formid+",'resourceId',413,'int','3',1,0,'','1',0,1.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
                "values("+formid+",'departmentId',124,'int','3',4,0,'','1',0,2.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
                "values("+formid+",'fromDate',740,'char(10)','3',2,0,'','1',0,4.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
                "values("+formid+",'fromTime',742,'char(8)','3',19,0,'','1',0,5.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
                "values("+formid+",'toDate',741,'char(10)','3',2,0,'','1',0,6.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
                "values("+formid+",'toTime',743,'char(8)','3',19,0,'','1',0,7.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
                "values("+formid+",'duration',21551,'decimal(15,2)','1',3,0,'','1',0,8.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
                "values("+formid+",'companion',27209,'text','3',17,0,'','1',4,9.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");

      }

    }
    else{
      if(isdetail) {
        tableCreateSql_array.add("create table "+formtable_main_mx+" (id int IDENTITY(1,1) primary key not null, mainid integer, "+
            "detail_resourceId int, detail_departmentId int, detail_fromDate char(10),"+
            "detail_fromTime char(8), detail_toDate char(10), detail_toTime char(8), detail_duration decimal(15,2), detail_companion text)");

        tableCreateIndexSql_array.add("create index idx_"+formtable_main_mx+" on "+formtable_main_mx+" (detail_resourceId)");

        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'detail_resourceId',413,'int','3',1,1,'"+formtable_main_mx+"','1',0,1.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'detail_departmentId',124,'int','3',4,1,'"+formtable_main_mx+"','1',0,2.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'detail_fromDate',740,'char(10)','3',2,1,'"+formtable_main_mx+"','1',0,4.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'detail_fromTime',742,'char(8)','3',19,1,'"+formtable_main_mx+"','1',0,5.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'detail_toDate',741,'char(10)','3',2,1,'"+formtable_main_mx+"','1',0,6.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'detail_toTime',743,'char(8)','3',19,1,'"+formtable_main_mx+"','1',0,7.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'detail_duration','21551','decimal(15,2)','1',3,1,'"+formtable_main_mx+"','1',0,8.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'detail_companion','27209','text','3',17,1,'"+formtable_main_mx+"','1',0,9.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");

      }else{
        tableCreateSql_array.add("alter table "+formtable_main+" add resourceId int");
        tableCreateSql_array.add("alter table "+formtable_main+" add departmentId int");
        tableCreateSql_array.add("alter table "+formtable_main+" add fromDate char(10)");
        tableCreateSql_array.add("alter table "+formtable_main+" add fromTime char(8)");
        tableCreateSql_array.add("alter table "+formtable_main+" add toDate char(10)");
        tableCreateSql_array.add("alter table "+formtable_main+" add toTime char(8)");
        tableCreateSql_array.add("alter table "+formtable_main+" add duration decimal(15,2)");
        tableCreateSql_array.add("alter table "+formtable_main+" add companion text");

        tableCreateIndexSql_array.add("create index idx_"+formtable_main+" on "+formtable_main+" (resourceId)");

        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'resourceId',413,'int','3',1,0,'','1',0,1.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'departmentId',124,'int','3',4,0,'','1',0,2.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'fromDate',740,'char(10)','3',2,0,'','1',0,4.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'fromTime',742,'char(8)','3',19,0,'','1',0,5.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'toDate',741,'char(10)','3',2,0,'','1',0,6.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'toTime',743,'char(8)','3',19,0,'','1',0,7.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'duration',21551,'decimal(15,2)','1',3,0,'','1',0,8.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'companion',27209,'text','3',17,0,'','1',4,9.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");
      }

    }

  }

  /**
   * 公出流程表结构
   * @param formid
   * @param formtable_main
   * @param formtable_main_mx
   * @param tableCreateSql_array
   * @param detailtable_array
   * @param tableCreateIndexSql_array
   * @param tableFieldInitSql_array
   */
  private void initWfType2(int formid,String formtable_main, String formtable_main_mx,List<String> tableCreateSql_array,List<String> detailtable_array,List<String> tableCreateIndexSql_array,List<String> tableFieldInitSql_array) {

    RecordSet rs = new RecordSet();

    if(isdetail) {
      detailtable_array.add(formtable_main_mx);
    }
    if(rs.getDBType().equalsIgnoreCase("oracle")){
      if(isdetail) {
        tableCreateSql_array.add("create table "+formtable_main_mx+" (id integer primary key not null, mainid integer, "+
            "detail_resourceId int, detail_departmentId int, detail_fromDate char(10),"+
            "detail_fromTime char(8), detail_toDate char(10), detail_toTime char(8), detail_duration decimal(15,2))");

        tableCreateIndexSql_array.add("create sequence "+formtable_main_mx+"_ID minvalue 1 maxvalue 9223372036854775807 start with 1 increment by 1 nocache ");

        tableCreateIndexSql_array.add("create or replace trigger "+formtable_main_mx+"_ID_TR " +
            " before insert on "+formtable_main_mx+" for each row " +
            " begin " +
            "   select "+formtable_main_mx+"_ID.nextval into :new.id from dual; " +
            " end;");
        tableCreateIndexSql_array.add("create index idx_"+formtable_main_mx+" on "+formtable_main_mx+" (detail_resourceId)");

        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'detail_resourceId',413,'int','3',1,1,'"+formtable_main_mx+"','1',0,1.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'detail_departmentId',124,'int','3',4,1,'"+formtable_main_mx+"','1',0,2.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'detail_fromDate',740,'char(10)','3',2,1,'"+formtable_main_mx+"','1',0,4.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'detail_fromTime',742,'char(8)','3',19,1,'"+formtable_main_mx+"','1',0,5.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'detail_toDate',741,'char(10)','3',2,1,'"+formtable_main_mx+"','1',0,6.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'detail_toTime',743,'char(8)','3',19,1,'"+formtable_main_mx+"','1',0,7.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'detail_duration','21551','decimal(15,2)','1',3,1,'"+formtable_main_mx+"','1',0,8.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");

      }else{

        tableCreateSql_array.add("alter table "+formtable_main+" add resourceId int");
        tableCreateSql_array.add("alter table "+formtable_main+" add departmentId int");
        tableCreateSql_array.add("alter table "+formtable_main+" add fromDate char(10)");
        tableCreateSql_array.add("alter table "+formtable_main+" add fromTime char(8)");
        tableCreateSql_array.add("alter table "+formtable_main+" add toDate char(10)");
        tableCreateSql_array.add("alter table "+formtable_main+" add toTime char(8)");
        tableCreateSql_array.add("alter table "+formtable_main+" add duration decimal(15,2)");

        if("jc".equalsIgnoreCase(rs.getOrgindbtype()) || "st".equalsIgnoreCase(rs.getOrgindbtype()) || "gs".equalsIgnoreCase(rs.getOrgindbtype())){
          tableCreateIndexSql_array.add("create sequence "+formtable_main+"_ID increment by 1 start with 1 MINVALUE 1 maxvalue 9223372036854775807 NOCYCLE ");
        }else{
          tableCreateIndexSql_array.add("create sequence "+formtable_main+"_ID increment by 1 start with 1 MINVALUE 1 maxvalue 9999999999999999999999999999 NOCYCLE ");
        }

        logAutoInit("insert into kq_autoinit_log(wftype,inittype,initids,initcolumn) values(2,'sequence','"+formtable_main+"_ID','id')");
        logAutoInit("insert into kq_autoinit_log(wftype,inittype,initids,initcolumn) values(2,'sequence','"+formtable_main_mx+"_ID','id')");

        tableCreateIndexSql_array.add("create or replace trigger "+formtable_main+"_ID_TR " +
            " before insert on "+formtable_main+" for each row " +
            " begin " +
            "   select "+formtable_main+"_ID.nextval into :new.id from dual; " +
            " end;");

        tableCreateIndexSql_array.add("create index idx_"+formtable_main+" on "+formtable_main+" (resourceId)");

        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'resourceId',413,'int','3',1,0,'','1',0,1.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'departmentId',124,'int','3',4,0,'','1',0,2.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'fromDate',740,'char(10)','3',2,0,'','1',0,4.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'fromTime',742,'char(8)','3',19,0,'','1',0,5.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'toDate',741,'char(10)','3',2,0,'','1',0,6.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'toTime',743,'char(8)','3',19,0,'','1',0,7.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'duration',21551,'decimal(15,2)','1',3,0,'','1',4,8.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");
      }

    }else if((rs.getDBType()).equalsIgnoreCase("mysql")){

      if(isdetail) {
        tableCreateSql_array.add("create table "+formtable_main_mx+" (id int AUTO_INCREMENT primary key not null, mainid integer, "+
            "detail_resourceId int, detail_departmentId int, detail_fromDate char(10),"+
            "detail_fromTime char(8), detail_toDate char(10), detail_toTime char(8), detail_duration decimal(15,2))");
        tableCreateIndexSql_array.add("create index idx_"+formtable_main_mx+" on "+formtable_main_mx+" (detail_resourceId)");

        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'detail_resourceId',413,'int','3',1,1,'"+formtable_main_mx+"','1',0,1.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'detail_departmentId',124,'int','3',4,1,'"+formtable_main_mx+"','1',0,2.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'detail_fromDate',740,'char(10)','3',2,1,'"+formtable_main_mx+"','1',0,4.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'detail_fromTime',742,'char(8)','3',19,1,'"+formtable_main_mx+"','1',0,5.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'detail_toDate',741,'char(10)','3',2,1,'"+formtable_main_mx+"','1',0,6.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'detail_toTime',743,'char(8)','3',19,1,'"+formtable_main_mx+"','1',0,7.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'detail_duration','21551','decimal(15,2)','1',3,1,'"+formtable_main_mx+"','1',0,8.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");

      }else{

        tableCreateSql_array.add("alter table "+formtable_main+" add resourceId int");
        tableCreateSql_array.add("alter table "+formtable_main+" add departmentId int");
        tableCreateSql_array.add("alter table "+formtable_main+" add fromDate char(10)");
        tableCreateSql_array.add("alter table "+formtable_main+" add fromTime char(8)");
        tableCreateSql_array.add("alter table "+formtable_main+" add toDate char(10)");
        tableCreateSql_array.add("alter table "+formtable_main+" add toTime char(8)");
        tableCreateSql_array.add("alter table "+formtable_main+" add duration decimal(15,2)");

        tableCreateIndexSql_array.add("create index idx_"+formtable_main+" on "+formtable_main+" (resourceId)");

        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'resourceId',413,'int','3',1,0,'','1',0,1.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'departmentId',124,'int','3',4,0,'','1',0,2.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'fromDate',740,'char(10)','3',2,0,'','1',0,4.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'fromTime',742,'char(8)','3',19,0,'','1',0,5.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'toDate',741,'char(10)','3',2,0,'','1',0,6.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'toTime',743,'char(8)','3',19,0,'','1',0,7.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'duration',21551,'decimal(15,2)','1',3,0,'','1',0,8.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");
      }
    }
    else if((rs.getDBType()).equalsIgnoreCase("postgresql")){

      if(isdetail) {
        tableCreateSql_array.add("create table "+formtable_main_mx+" (id serial primary key not null, mainid integer, "+
                "detail_resourceId int, detail_departmentId int, detail_fromDate char(10),"+
                "detail_fromTime char(8), detail_toDate char(10), detail_toTime char(8), detail_duration decimal(15,2))");
        //tableCreateIndexSql_array.add("create unique  index idx_"+formtable_main_mx+" on "+formtable_main_mx+" (detail_resourceId)");

        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
                "values("+formid+",'detail_resourceId',413,'int','3',1,1,'"+formtable_main_mx+"','1',0,1.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
                "values("+formid+",'detail_departmentId',124,'int','3',4,1,'"+formtable_main_mx+"','1',0,2.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
                "values("+formid+",'detail_fromDate',740,'char(10)','3',2,1,'"+formtable_main_mx+"','1',0,4.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
                "values("+formid+",'detail_fromTime',742,'char(8)','3',19,1,'"+formtable_main_mx+"','1',0,5.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
                "values("+formid+",'detail_toDate',741,'char(10)','3',2,1,'"+formtable_main_mx+"','1',0,6.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
                "values("+formid+",'detail_toTime',743,'char(8)','3',19,1,'"+formtable_main_mx+"','1',0,7.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
                "values("+formid+",'detail_duration','21551','decimal(15,2)','1',3,1,'"+formtable_main_mx+"','1',0,8.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");

      }else{

        tableCreateSql_array.add("alter table "+formtable_main+" add resourceId int");
        tableCreateSql_array.add("alter table "+formtable_main+" add departmentId int");
        tableCreateSql_array.add("alter table "+formtable_main+" add fromDate char(10)");
        tableCreateSql_array.add("alter table "+formtable_main+" add fromTime char(8)");
        tableCreateSql_array.add("alter table "+formtable_main+" add toDate char(10)");
        tableCreateSql_array.add("alter table "+formtable_main+" add toTime char(8)");
        tableCreateSql_array.add("alter table "+formtable_main+" add duration decimal(15,2)");

        tableCreateIndexSql_array.add("create unique  index idx_"+formtable_main+" on "+formtable_main+" (resourceId)");

        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
                "values("+formid+",'resourceId',413,'int','3',1,0,'','1',0,1.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
                "values("+formid+",'departmentId',124,'int','3',4,0,'','1',0,2.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
                "values("+formid+",'fromDate',740,'char(10)','3',2,0,'','1',0,4.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
                "values("+formid+",'fromTime',742,'char(8)','3',19,0,'','1',0,5.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
                "values("+formid+",'toDate',741,'char(10)','3',2,0,'','1',0,6.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
                "values("+formid+",'toTime',743,'char(8)','3',19,0,'','1',0,7.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
                "values("+formid+",'duration',21551,'decimal(15,2)','1',3,0,'','1',0,8.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");
      }
    }
    else{
      if(isdetail) {
        tableCreateSql_array.add("create table "+formtable_main_mx+" (id int IDENTITY(1,1) primary key not null, mainid integer, "+
            "detail_resourceId int, detail_departmentId int, detail_fromDate char(10),"+
            "detail_fromTime char(8), detail_toDate char(10), detail_toTime char(8), detail_duration decimal(15,2))");

        tableCreateIndexSql_array.add("create index idx_"+formtable_main_mx+" on "+formtable_main_mx+" (detail_resourceId)");

        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'detail_resourceId',413,'int','3',1,1,'"+formtable_main_mx+"','1',0,1.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'detail_departmentId',124,'int','3',4,1,'"+formtable_main_mx+"','1',0,2.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'detail_fromDate',740,'char(10)','3',2,1,'"+formtable_main_mx+"','1',0,4.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'detail_fromTime',742,'char(8)','3',19,1,'"+formtable_main_mx+"','1',0,5.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'detail_toDate',741,'char(10)','3',2,1,'"+formtable_main_mx+"','1',0,6.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'detail_toTime',743,'char(8)','3',19,1,'"+formtable_main_mx+"','1',0,7.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'detail_duration','21551','decimal(15,2)','1',3,1,'"+formtable_main_mx+"','1',0,8.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");

      }else{
        tableCreateSql_array.add("alter table "+formtable_main+" add resourceId int");
        tableCreateSql_array.add("alter table "+formtable_main+" add departmentId int");
        tableCreateSql_array.add("alter table "+formtable_main+" add fromDate char(10)");
        tableCreateSql_array.add("alter table "+formtable_main+" add fromTime char(8)");
        tableCreateSql_array.add("alter table "+formtable_main+" add toDate char(10)");
        tableCreateSql_array.add("alter table "+formtable_main+" add toTime char(8)");
        tableCreateSql_array.add("alter table "+formtable_main+" add duration decimal(15,2)");

        tableCreateIndexSql_array.add("create index idx_"+formtable_main+" on "+formtable_main+" (resourceId)");

        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'resourceId',413,'int','3',1,0,'','1',0,1.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'departmentId',124,'int','3',4,0,'','1',0,2.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'fromDate',740,'char(10)','3',2,0,'','1',0,4.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'fromTime',742,'char(8)','3',19,0,'','1',0,5.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'toDate',741,'char(10)','3',2,0,'','1',0,6.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'toTime',743,'char(8)','3',19,0,'','1',0,7.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'duration',21551,'decimal(15,2)','1',3,0,'','1',0,8.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");

      }
    }

  }

  /**
   * 加班流程表结构
   * @param formid
   * @param formtable_main
   * @param formtable_main_mx
   * @param tableCreateSql_array
   * @param detailtable_array
   * @param tableCreateIndexSql_array
   * @param tableFieldInitSql_array
   */
  private void initWfType3(int formid,String formtable_main, String formtable_main_mx,List<String> tableCreateSql_array,List<String> detailtable_array,List<String> tableCreateIndexSql_array,List<String> tableFieldInitSql_array) {

    RecordSet rs = new RecordSet();

    if(isdetail) {
      detailtable_array.add(formtable_main_mx);
    }
    if(rs.getDBType().equalsIgnoreCase("oracle")){
      if(isdetail) {

        tableCreateSql_array.add("create table "+formtable_main_mx+" (id integer primary key not null, mainid integer, "+
            "detail_resourceId int, detail_departmentId int, detail_fromDate char(10),"+
            "detail_fromTime char(8), detail_toDate char(10), detail_toTime char(8), detail_overtime_type int, detail_duration decimal(15,2))");
        tableCreateIndexSql_array.add("create sequence "+formtable_main_mx+"_ID minvalue 1 maxvalue 9223372036854775807 start with 1 increment by 1 nocache ");

        tableCreateIndexSql_array.add("create or replace trigger "+formtable_main_mx+"_ID_TR " +
            " before insert on "+formtable_main_mx+" for each row " +
            " begin " +
            "   select "+formtable_main_mx+"_ID.nextval into :new.id from dual; " +
            " end;");
        tableCreateIndexSql_array.add("create index idx_"+formtable_main_mx+" on "+formtable_main_mx+" (detail_resourceId)");

        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'detail_resourceId',413,'int','3',1,1,'"+formtable_main_mx+"','1',0,1.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'detail_departmentId',124,'int','3',4,1,'"+formtable_main_mx+"','1',0,2.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'detail_fromDate',740,'char(10)','3',2,1,'"+formtable_main_mx+"','1',0,4.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'detail_fromTime',742,'char(8)','3',19,1,'"+formtable_main_mx+"','1',0,5.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'detail_toDate',741,'char(10)','3',2,1,'"+formtable_main_mx+"','1',0,6.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'detail_toTime',743,'char(8)','3',19,1,'"+formtable_main_mx+"','1',0,7.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'detail_overtime_type',525492,'int','5',1,1,'"+formtable_main_mx+"','1',0,7.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'detail_duration',21551,'decimal(15,2)','1',3,1,'"+formtable_main_mx+"','1',0,7.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");

      }else{
        tableCreateSql_array.add("alter table "+formtable_main+" add resourceId int");
        tableCreateSql_array.add("alter table "+formtable_main+" add departmentId int");
        tableCreateSql_array.add("alter table "+formtable_main+" add fromDate char(10)");
        tableCreateSql_array.add("alter table "+formtable_main+" add fromTime char(8)");
        tableCreateSql_array.add("alter table "+formtable_main+" add toDate char(10)");
        tableCreateSql_array.add("alter table "+formtable_main+" add toTime char(8)");
        tableCreateSql_array.add("alter table "+formtable_main+" add overtime_type char(8)");
        tableCreateSql_array.add("alter table "+formtable_main+" add duration decimal(15,2)");

        if("jc".equalsIgnoreCase(rs.getOrgindbtype()) || "st".equalsIgnoreCase(rs.getOrgindbtype()) || "gs".equalsIgnoreCase(rs.getOrgindbtype())){
          tableCreateIndexSql_array.add("create sequence "+formtable_main+"_ID increment by 1 start with 1 MINVALUE 1 maxvalue 9223372036854775807 NOCYCLE ");
        }else{
          tableCreateIndexSql_array.add("create sequence "+formtable_main+"_ID increment by 1 start with 1 MINVALUE 1 maxvalue 9999999999999999999999999999 NOCYCLE ");
        }

        logAutoInit("insert into kq_autoinit_log(wftype,inittype,initids,initcolumn) values(3,'sequence','"+formtable_main+"_ID','id')");
        logAutoInit("insert into kq_autoinit_log(wftype,inittype,initids,initcolumn) values(3,'sequence','"+formtable_main_mx+"_ID','id')");

        tableCreateIndexSql_array.add("create or replace trigger "+formtable_main+"_ID_TR " +
            " before insert on "+formtable_main+" for each row " +
            " begin " +
            "   select "+formtable_main+"_ID.nextval into :new.id from dual; " +
            " end;");

        tableCreateIndexSql_array.add("create index idx_"+formtable_main+" on "+formtable_main+" (resourceId)");

        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'resourceId',413,'int','3',1,0,'','1',0,1.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'departmentId',124,'int','3',4,0,'','1',0,2.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'fromDate',740,'char(10)','3',2,0,'','1',0,4.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'fromTime',742,'char(8)','3',19,0,'','1',0,5.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'toDate',741,'char(10)','3',2,0,'','1',0,6.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'toTime',743,'char(8)','3',19,0,'','1',0,7.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'overtime_type',525492,'int','5',1,0,'','1',0,7.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'duration',21551,'decimal(15,2)','1',3,0,'','1',0,7.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");


      }
    }else if((rs.getDBType()).equalsIgnoreCase("mysql")){
      if(isdetail) {
        tableCreateSql_array.add("create table "+formtable_main_mx+" (id int AUTO_INCREMENT primary key not null, mainid integer, "+
            "detail_resourceId int, detail_departmentId int, detail_fromDate char(10),"+
            "detail_fromTime char(8), detail_toDate char(10), detail_toTime char(8), detail_overtime_type int, detail_duration decimal(15,2))");
        tableCreateIndexSql_array.add("create index idx_"+formtable_main_mx+" on "+formtable_main_mx+" (detail_resourceId)");

        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'detail_resourceId',413,'int','3',1,1,'"+formtable_main_mx+"','1',0,1.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'detail_departmentId',124,'int','3',4,1,'"+formtable_main_mx+"','1',0,2.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'detail_fromDate',740,'char(10)','3',2,1,'"+formtable_main_mx+"','1',0,4.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'detail_fromTime',742,'char(8)','3',19,1,'"+formtable_main_mx+"','1',0,5.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'detail_toDate',741,'char(10)','3',2,1,'"+formtable_main_mx+"','1',0,6.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'detail_toTime',743,'char(8)','3',19,1,'"+formtable_main_mx+"','1',0,7.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'detail_overtime_type',525492,'int','5',1,1,'"+formtable_main_mx+"','1',0,7.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'detail_duration',21551,'decimal(15,2)','1',3,1,'"+formtable_main_mx+"','1',0,7.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");

      }else{

        tableCreateSql_array.add("alter table "+formtable_main+" add resourceId int");
        tableCreateSql_array.add("alter table "+formtable_main+" add departmentId int");
        tableCreateSql_array.add("alter table "+formtable_main+" add fromDate char(10)");
        tableCreateSql_array.add("alter table "+formtable_main+" add fromTime char(8)");
        tableCreateSql_array.add("alter table "+formtable_main+" add toDate char(10)");
        tableCreateSql_array.add("alter table "+formtable_main+" add toTime char(8)");
        tableCreateSql_array.add("alter table "+formtable_main+" add overtime_type char(8)");
        tableCreateSql_array.add("alter table "+formtable_main+" add duration decimal(15,2)");

        tableCreateIndexSql_array.add("create index idx_"+formtable_main+" on "+formtable_main+" (resourceId)");


        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'resourceId',413,'int','3',1,0,'','1',0,1.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'departmentId',124,'int','3',4,0,'','1',0,2.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'fromDate',740,'char(10)','3',2,0,'','1',0,4.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'fromTime',742,'char(8)','3',19,0,'','1',0,5.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'toDate',741,'char(10)','3',2,0,'','1',0,6.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'toTime',743,'char(8)','3',19,0,'','1',0,7.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'overtime_type',525492,'int','5',1,0,'','1',0,7.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'duration',21551,'decimal(15,2)','1',3,0,'','1',0,7.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");
      }

    }
    else if((rs.getDBType()).equalsIgnoreCase("mysql")){
      if(isdetail) {
        tableCreateSql_array.add("create table "+formtable_main_mx+" (id serial primary key not null, mainid integer, "+
                "detail_resourceId int, detail_departmentId int, detail_fromDate char(10),"+
                "detail_fromTime char(8), detail_toDate char(10), detail_toTime char(8), detail_overtime_type int, detail_duration decimal(15,2))");
        tableCreateIndexSql_array.add("create unique  index idx_"+formtable_main_mx+" on "+formtable_main_mx+" (detail_resourceId)");

        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
                "values("+formid+",'detail_resourceId',413,'int','3',1,1,'"+formtable_main_mx+"','1',0,1.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
                "values("+formid+",'detail_departmentId',124,'int','3',4,1,'"+formtable_main_mx+"','1',0,2.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
                "values("+formid+",'detail_fromDate',740,'char(10)','3',2,1,'"+formtable_main_mx+"','1',0,4.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
                "values("+formid+",'detail_fromTime',742,'char(8)','3',19,1,'"+formtable_main_mx+"','1',0,5.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
                "values("+formid+",'detail_toDate',741,'char(10)','3',2,1,'"+formtable_main_mx+"','1',0,6.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
                "values("+formid+",'detail_toTime',743,'char(8)','3',19,1,'"+formtable_main_mx+"','1',0,7.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
                "values("+formid+",'detail_overtime_type',525492,'int','5',1,1,'"+formtable_main_mx+"','1',0,7.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
                "values("+formid+",'detail_duration',21551,'decimal(15,2)','1',3,1,'"+formtable_main_mx+"','1',0,7.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");

      }else{

        tableCreateSql_array.add("alter table "+formtable_main+" add resourceId int");
        tableCreateSql_array.add("alter table "+formtable_main+" add departmentId int");
        tableCreateSql_array.add("alter table "+formtable_main+" add fromDate char(10)");
        tableCreateSql_array.add("alter table "+formtable_main+" add fromTime char(8)");
        tableCreateSql_array.add("alter table "+formtable_main+" add toDate char(10)");
        tableCreateSql_array.add("alter table "+formtable_main+" add toTime char(8)");
        tableCreateSql_array.add("alter table "+formtable_main+" add overtime_type char(8)");
        tableCreateSql_array.add("alter table "+formtable_main+" add duration decimal(15,2)");

        tableCreateIndexSql_array.add("create unique  index idx_"+formtable_main+" on "+formtable_main+" (resourceId)");


        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
                "values("+formid+",'resourceId',413,'int','3',1,0,'','1',0,1.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
                "values("+formid+",'departmentId',124,'int','3',4,0,'','1',0,2.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
                "values("+formid+",'fromDate',740,'char(10)','3',2,0,'','1',0,4.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
                "values("+formid+",'fromTime',742,'char(8)','3',19,0,'','1',0,5.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
                "values("+formid+",'toDate',741,'char(10)','3',2,0,'','1',0,6.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
                "values("+formid+",'toTime',743,'char(8)','3',19,0,'','1',0,7.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
                "values("+formid+",'overtime_type',525492,'int','5',1,0,'','1',0,7.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
                "values("+formid+",'duration',21551,'decimal(15,2)','1',3,0,'','1',0,7.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");
      }

    }

    else{
      if(isdetail) {
        tableCreateSql_array.add("create table "+formtable_main_mx+" (id int IDENTITY(1,1) primary key not null, mainid integer, "+
            "detail_resourceId int, detail_departmentId int, detail_fromDate char(10),"+
            "detail_fromTime char(8), detail_toDate char(10), detail_toTime char(8), detail_overtime_type int, detail_duration decimal(15,2))");
        tableCreateIndexSql_array.add("create index idx_"+formtable_main_mx+" on "+formtable_main_mx+" (detail_resourceId)");

        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'detail_resourceId',413,'int','3',1,1,'"+formtable_main_mx+"','1',0,1.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'detail_departmentId',124,'int','3',4,1,'"+formtable_main_mx+"','1',0,2.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'detail_fromDate',740,'char(10)','3',2,1,'"+formtable_main_mx+"','1',0,4.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'detail_fromTime',742,'char(8)','3',19,1,'"+formtable_main_mx+"','1',0,5.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'detail_toDate',741,'char(10)','3',2,1,'"+formtable_main_mx+"','1',0,6.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'detail_toTime',743,'char(8)','3',19,1,'"+formtable_main_mx+"','1',0,7.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'detail_overtime_type',525492,'int','5',1,1,'"+formtable_main_mx+"','1',0,7.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'detail_duration',21551,'decimal(15,2)','1',3,1,'"+formtable_main_mx+"','1',0,7.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");

      }else{

        tableCreateSql_array.add("alter table "+formtable_main+" add resourceId int");
        tableCreateSql_array.add("alter table "+formtable_main+" add departmentId int");
        tableCreateSql_array.add("alter table "+formtable_main+" add fromDate char(10)");
        tableCreateSql_array.add("alter table "+formtable_main+" add fromTime char(8)");
        tableCreateSql_array.add("alter table "+formtable_main+" add toDate char(10)");
        tableCreateSql_array.add("alter table "+formtable_main+" add toTime char(8)");
        tableCreateSql_array.add("alter table "+formtable_main+" add overtime_type char(8)");
        tableCreateSql_array.add("alter table "+formtable_main+" add duration decimal(15,2)");

        tableCreateIndexSql_array.add("create index idx_"+formtable_main+" on "+formtable_main+" (resourceId)");

        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'resourceId',413,'int','3',1,0,'','1',0,1.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'departmentId',124,'int','3',4,0,'','1',0,2.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'fromDate',740,'char(10)','3',2,0,'','1',0,4.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'fromTime',742,'char(8)','3',19,0,'','1',0,5.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'toDate',741,'char(10)','3',2,0,'','1',0,6.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'toTime',743,'char(8)','3',19,0,'','1',0,7.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'overtime_type',525492,'int','5',1,0,'','1',0,7.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'duration',21551,'decimal(15,2)','1',3,0,'','1',0,7.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");

      }
    }

  }

  /**
   * 异常流程
   * @param formid
   * @param formtable_main
   * @param formtable_main_mx
   * @param tableCreateSql_array
   * @param detailtable_array
   * @param tableCreateIndexSql_array
   * @param tableFieldInitSql_array
   */
  private void initWfType4(int formid,String formtable_main, String formtable_main_mx,List<String> tableCreateSql_array,List<String> detailtable_array,List<String> tableCreateIndexSql_array,List<String> tableFieldInitSql_array) {

    RecordSet rs = new RecordSet();

    if(isdetail) {
      detailtable_array.add(formtable_main_mx);
    }

    if(rs.getDBType().equalsIgnoreCase("oracle")){
      if(isdetail) {

        tableCreateSql_array.add("create table "+formtable_main_mx+" (id integer primary key not null, mainid integer, "+
            "detail_resourceId int, detail_departmentId int, detail_fromDate char(10),"+
            "detail_fromTime char(8), detail_toDate char(10), detail_toTime char(8))");
        tableCreateIndexSql_array.add("create sequence "+formtable_main_mx+"_ID minvalue 1 maxvalue 9223372036854775807 start with 1 increment by 1 nocache ");

        tableCreateIndexSql_array.add("create or replace trigger "+formtable_main_mx+"_ID_TR " +
            " before insert on "+formtable_main_mx+" for each row " +
            " begin " +
            "   select "+formtable_main_mx+"_ID.nextval into :new.id from dual; " +
            " end;");
        tableCreateIndexSql_array.add("create index idx_"+formtable_main_mx+" on "+formtable_main_mx+" (detail_resourceId)");

        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'detail_resourceId',413,'int','3',1,1,'"+formtable_main_mx+"','1',0,1.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'detail_departmentId',124,'int','3',4,1,'"+formtable_main_mx+"','1',0,2.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'detail_fromDate',740,'char(10)','3',2,1,'"+formtable_main_mx+"','1',0,4.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'detail_fromTime',742,'char(8)','3',19,1,'"+formtable_main_mx+"','1',0,5.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'detail_toDate',741,'char(10)','3',2,1,'"+formtable_main_mx+"','1',0,6.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'detail_toTime',743,'char(8)','3',19,1,'"+formtable_main_mx+"','1',0,7.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");

      }else{

        tableCreateSql_array.add("alter table "+formtable_main+" add resourceId int");
        tableCreateSql_array.add("alter table "+formtable_main+" add departmentId int");
        tableCreateSql_array.add("alter table "+formtable_main+" add fromDate char(10)");
        tableCreateSql_array.add("alter table "+formtable_main+" add fromTime char(8)");
        tableCreateSql_array.add("alter table "+formtable_main+" add toDate char(10)");
        tableCreateSql_array.add("alter table "+formtable_main+" add toTime char(8)");

        if("jc".equalsIgnoreCase(rs.getOrgindbtype()) || "st".equalsIgnoreCase(rs.getOrgindbtype()) || "gs".equalsIgnoreCase(rs.getOrgindbtype())){
          tableCreateIndexSql_array.add("create sequence "+formtable_main+"_ID increment by 1 start with 1 MINVALUE 1 maxvalue 9223372036854775807 NOCYCLE ");
        }else{
          tableCreateIndexSql_array.add("create sequence "+formtable_main+"_ID increment by 1 start with 1 MINVALUE 1 maxvalue 9999999999999999999999999999 NOCYCLE ");
        }

        logAutoInit("insert into kq_autoinit_log(wftype,inittype,initids,initcolumn) values(4,'sequence','"+formtable_main+"_ID','id')");
        logAutoInit("insert into kq_autoinit_log(wftype,inittype,initids,initcolumn) values(4,'sequence','"+formtable_main_mx+"_ID','id')");

        tableCreateIndexSql_array.add("create or replace trigger "+formtable_main+"_ID_TR " +
            " before insert on "+formtable_main+" for each row " +
            " begin " +
            "   select "+formtable_main+"_ID.nextval into :new.id from dual; " +
            " end;");

        tableCreateIndexSql_array.add("create index idx_"+formtable_main+" on "+formtable_main+" (resourceId)");

        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'resourceId',413,'int','3',1,0,'','1',0,1.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'departmentId',124,'int','3',4,0,'','1',0,2.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'fromDate',740,'char(10)','3',2,0,'','1',0,4.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'fromTime',742,'char(8)','3',19,0,'','1',0,5.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'toDate',741,'char(10)','3',2,0,'','1',0,6.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'toTime',743,'char(8)','3',19,0,'','1',0,7.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");

      }
    }else if((rs.getDBType()).equalsIgnoreCase("mysql")){
      if(isdetail) {
        tableCreateSql_array.add("create table "+formtable_main_mx+" (id int AUTO_INCREMENT primary key not null, mainid integer, "+
            "detail_resourceId int, detail_departmentId int, detail_fromDate char(10),"+
            "detail_fromTime char(8), detail_toDate char(10), detail_toTime char(8))");
        tableCreateIndexSql_array.add("create index idx_"+formtable_main_mx+" on "+formtable_main_mx+" (detail_resourceId)");

        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'detail_resourceId',413,'int','3',1,1,'"+formtable_main_mx+"','1',0,1.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'detail_departmentId',124,'int','3',4,1,'"+formtable_main_mx+"','1',0,2.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'detail_fromDate',740,'char(10)','3',2,1,'"+formtable_main_mx+"','1',0,4.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'detail_fromTime',742,'char(8)','3',19,1,'"+formtable_main_mx+"','1',0,5.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'detail_toDate',741,'char(10)','3',2,1,'"+formtable_main_mx+"','1',0,6.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'detail_toTime',743,'char(8)','3',19,1,'"+formtable_main_mx+"','1',0,7.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");

      }else{

        tableCreateSql_array.add("alter table "+formtable_main+" add resourceId int");
        tableCreateSql_array.add("alter table "+formtable_main+" add departmentId int");
        tableCreateSql_array.add("alter table "+formtable_main+" add fromDate char(10)");
        tableCreateSql_array.add("alter table "+formtable_main+" add fromTime char(8)");
        tableCreateSql_array.add("alter table "+formtable_main+" add toDate char(10)");
        tableCreateSql_array.add("alter table "+formtable_main+" add toTime char(8)");

        tableCreateIndexSql_array.add("create index idx_"+formtable_main+" on "+formtable_main+" (resourceId)");

        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'resourceId',413,'int','3',1,0,'','1',0,1.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'departmentId',124,'int','3',4,0,'','1',0,2.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'fromDate',740,'char(10)','3',2,0,'','1',0,4.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'fromTime',742,'char(8)','3',19,0,'','1',0,5.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'toDate',741,'char(10)','3',2,0,'','1',0,6.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'toTime',743,'char(8)','3',19,0,'','1',0,7.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");

      }

    }
    else if((rs.getDBType()).equalsIgnoreCase("postgresql")){
      if(isdetail) {
        tableCreateSql_array.add("create table "+formtable_main_mx+" (id serial primary key not null, mainid integer, "+
                "detail_resourceId int, detail_departmentId int, detail_fromDate char(10),"+
                "detail_fromTime char(8), detail_toDate char(10), detail_toTime char(8))");
      //  tableCreateIndexSql_array.add("create unique  index idx_"+formtable_main_mx+" on "+formtable_main_mx+" (detail_resourceId)");

        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
                "values("+formid+",'detail_resourceId',413,'int','3',1,1,'"+formtable_main_mx+"','1',0,1.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
                "values("+formid+",'detail_departmentId',124,'int','3',4,1,'"+formtable_main_mx+"','1',0,2.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
                "values("+formid+",'detail_fromDate',740,'char(10)','3',2,1,'"+formtable_main_mx+"','1',0,4.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
                "values("+formid+",'detail_fromTime',742,'char(8)','3',19,1,'"+formtable_main_mx+"','1',0,5.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
                "values("+formid+",'detail_toDate',741,'char(10)','3',2,1,'"+formtable_main_mx+"','1',0,6.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
                "values("+formid+",'detail_toTime',743,'char(8)','3',19,1,'"+formtable_main_mx+"','1',0,7.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");

      }else{

        tableCreateSql_array.add("alter table "+formtable_main+" add resourceId int");
        tableCreateSql_array.add("alter table "+formtable_main+" add departmentId int");
        tableCreateSql_array.add("alter table "+formtable_main+" add fromDate char(10)");
        tableCreateSql_array.add("alter table "+formtable_main+" add fromTime char(8)");
        tableCreateSql_array.add("alter table "+formtable_main+" add toDate char(10)");
        tableCreateSql_array.add("alter table "+formtable_main+" add toTime char(8)");

        tableCreateIndexSql_array.add("create unique  index idx_"+formtable_main+" on "+formtable_main+" (resourceId)");

        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
                "values("+formid+",'resourceId',413,'int','3',1,0,'','1',0,1.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
                "values("+formid+",'departmentId',124,'int','3',4,0,'','1',0,2.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
                "values("+formid+",'fromDate',740,'char(10)','3',2,0,'','1',0,4.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
                "values("+formid+",'fromTime',742,'char(8)','3',19,0,'','1',0,5.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
                "values("+formid+",'toDate',741,'char(10)','3',2,0,'','1',0,6.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
                "values("+formid+",'toTime',743,'char(8)','3',19,0,'','1',0,7.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");

      }

    }

    else{
      if(isdetail) {

        tableCreateSql_array.add("create table "+formtable_main_mx+" (id int IDENTITY(1,1) primary key not null, mainid integer, "+
            "detail_resourceId int, detail_departmentId int, detail_fromDate char(10),"+
            "detail_fromTime char(8), detail_toDate char(10), detail_toTime char(8))");
        tableCreateIndexSql_array.add("create index idx_"+formtable_main_mx+" on "+formtable_main_mx+" (detail_resourceId)");

        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'detail_resourceId',413,'int','3',1,1,'"+formtable_main_mx+"','1',0,1.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'detail_departmentId',124,'int','3',4,1,'"+formtable_main_mx+"','1',0,2.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'detail_fromDate',740,'char(10)','3',2,1,'"+formtable_main_mx+"','1',0,4.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'detail_fromTime',742,'char(8)','3',19,1,'"+formtable_main_mx+"','1',0,5.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'detail_toDate',741,'char(10)','3',2,1,'"+formtable_main_mx+"','1',0,6.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'detail_toTime',743,'char(8)','3',19,1,'"+formtable_main_mx+"','1',0,7.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
      }else{

        tableCreateSql_array.add("alter table "+formtable_main+" add resourceId int");
        tableCreateSql_array.add("alter table "+formtable_main+" add departmentId int");
        tableCreateSql_array.add("alter table "+formtable_main+" add fromDate char(10)");
        tableCreateSql_array.add("alter table "+formtable_main+" add fromTime char(8)");
        tableCreateSql_array.add("alter table "+formtable_main+" add toDate char(10)");
        tableCreateSql_array.add("alter table "+formtable_main+" add toTime char(8)");

        tableCreateIndexSql_array.add("create index idx_"+formtable_main+" on "+formtable_main+" (resourceId)");

        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'resourceId',413,'int','3',1,0,'','1',0,1.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'departmentId',124,'int','3',4,0,'','1',0,2.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'fromDate',740,'char(10)','3',2,0,'','1',0,4.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'fromTime',742,'char(8)','3',19,0,'','1',0,5.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'toDate',741,'char(10)','3',2,0,'','1',0,6.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");
        tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
            "values("+formid+",'toTime',743,'char(8)','3',19,0,'','1',0,7.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");

      }
    }

  }

  /**
   * 排班流程
   * 现在只有明细
   * @param formid
   * @param formtable_main
   * @param formtable_main_mx
   * @param tableCreateSql_array
   * @param detailtable_array
   * @param tableCreateIndexSql_array
   * @param tableFieldInitSql_array
   */
  private void initWfType5(int formid,String formtable_main, String formtable_main_mx,List<String> tableCreateSql_array,List<String> detailtable_array,List<String> tableCreateIndexSql_array,List<String> tableFieldInitSql_array) {

    RecordSet rs = new RecordSet();

    detailtable_array.add(formtable_main_mx);
    if(rs.getDBType().equalsIgnoreCase("oracle")){
      tableCreateSql_array.add("create table "+formtable_main_mx+" (id integer primary key not null, mainid integer, "+
          "detail_resourceId int, detail_fromDate char(10), detail_toDate char(10),"+
          "detail_shift int)");
      tableCreateIndexSql_array.add("create sequence "+formtable_main_mx+"_ID minvalue 1 maxvalue 9223372036854775807 start with 1 increment by 1 nocache ");

      logAutoInit("insert into kq_autoinit_log(wftype,inittype,initids,initcolumn) values(5,'sequence','"+formtable_main+"_ID','id')");
      logAutoInit("insert into kq_autoinit_log(wftype,inittype,initids,initcolumn) values(5,'sequence','"+formtable_main_mx+"_ID','id')");

      tableCreateIndexSql_array.add("create or replace trigger "+formtable_main_mx+"_ID_TR " +
          " before insert on "+formtable_main_mx+" for each row " +
          " begin " +
          "   select "+formtable_main_mx+"_ID.nextval into :new.id from dual; " +
          " end;");
      tableCreateIndexSql_array.add("create index idx_"+formtable_main_mx+" on "+formtable_main_mx+" (detail_resourceId)");

      tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
          "values("+formid+",'detail_resourceId',125839,'int','3',1,1,'"+formtable_main_mx+"','1',0,1.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
      tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
          "values("+formid+",'detail_fromDate',740,'char(10)','3',2,1,'"+formtable_main_mx+"','1',0,2.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
      tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
          "values("+formid+",'detail_toDate',741,'char(10)','3',2,1,'"+formtable_main_mx+"','1',0,3.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
      tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
          "values("+formid+",'detail_shift',390738,'int','3',388,1,'"+formtable_main_mx+"','1',0,4.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");

    }else if((rs.getDBType()).equalsIgnoreCase("mysql")){

      tableCreateSql_array.add("create table "+formtable_main_mx+" (id int AUTO_INCREMENT primary key not null, mainid integer, "+
          "detail_resourceId int, detail_fromDate char(10),"+
          "detail_toDate char(10), detail_shift int)");
      tableCreateIndexSql_array.add("create index idx_"+formtable_main_mx+" on "+formtable_main_mx+" (detail_resourceId)");

      tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
          "values("+formid+",'detail_resourceId',125839,'int','3',1,1,'"+formtable_main_mx+"','1',0,1.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
      tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
          "values("+formid+",'detail_fromDate',740,'char(10)','3',2,1,'"+formtable_main_mx+"','1',0,2.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
      tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
          "values("+formid+",'detail_toDate',741,'char(10)','3',2,1,'"+formtable_main_mx+"','1',0,3.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
      tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
          "values("+formid+",'detail_shift',390738,'int','3',388,1,'"+formtable_main_mx+"','1',0,4.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");

    }
    else if((rs.getDBType()).equalsIgnoreCase("postgresql")){

      tableCreateSql_array.add("create table "+formtable_main_mx+" (id serial primary key not null, mainid integer, "+
              "detail_resourceId int, detail_fromDate char(10),"+
              "detail_toDate char(10), detail_shift int)");
    //  tableCreateIndexSql_array.add("create unique  index idx_"+formtable_main_mx+" on "+formtable_main_mx+" (detail_resourceId)");

      tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
              "values("+formid+",'detail_resourceId',125839,'int','3',1,1,'"+formtable_main_mx+"','1',0,1.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
      tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
              "values("+formid+",'detail_fromDate',740,'char(10)','3',2,1,'"+formtable_main_mx+"','1',0,2.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
      tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
              "values("+formid+",'detail_toDate',741,'char(10)','3',2,1,'"+formtable_main_mx+"','1',0,3.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
      tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
              "values("+formid+",'detail_shift',390738,'int','3',388,1,'"+formtable_main_mx+"','1',0,4.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");

    }
    else{

      tableCreateSql_array.add("create table "+formtable_main_mx+" (id int IDENTITY(1,1) primary key not null, mainid integer, "+
          "detail_resourceId int, detail_fromDate char(10),"+
          "detail_toDate char(10), detail_shift int)");
      tableCreateIndexSql_array.add("create index idx_"+formtable_main_mx+" on "+formtable_main_mx+" (detail_resourceId)");

      tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
          "values("+formid+",'detail_resourceId',125839,'int','3',1,1,'"+formtable_main_mx+"','1',0,1.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
      tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
          "values("+formid+",'detail_fromDate',740,'char(10)','3',2,1,'"+formtable_main_mx+"','1',0,2.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
      tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
          "values("+formid+",'detail_toDate',741,'char(10)','3',2,1,'"+formtable_main_mx+"','1',0,3.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
      tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
          "values("+formid+",'detail_shift',390738,'int','3',388,1,'"+formtable_main_mx+"','1',0,4.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");

    }

  }

  /**
   * 销假流程
   * @param formid
   * @param formtable_main
   * @param formtable_main_mx
   * @param tableCreateSql_array
   * @param detailtable_array
   * @param tableCreateIndexSql_array
   * @param tableFieldInitSql_array
   */
  private void initWfType6(int formid,String formtable_main, String formtable_main_mx,List<String> tableCreateSql_array,List<String> detailtable_array,List<String> tableCreateIndexSql_array,List<String> tableFieldInitSql_array) {

    RecordSet rs = new RecordSet();

    detailtable_array.add(formtable_main_mx);

    if(rs.getDBType().equalsIgnoreCase("oracle")){
      tableCreateSql_array.add("alter table "+formtable_main+" add resourceId int");
      tableCreateSql_array.add("alter table "+formtable_main+" add leaverequestid int");

      tableCreateSql_array.add("create table "+formtable_main_mx+" (id integer primary key not null, mainid integer, "+
          "detail_leavefromDate char(10), detail_leavefromTime char(8),detail_leavetoDate char(10),"+
          "detail_leavetoTime char(8), detail_newLeaveType int, detail_leaveduration decimal(15,2), "
          + "detail_fromDate char(10), detail_fromTime char(8),detail_toDate char(10),detail_toTime char(8), "
          + "detail_duration decimal(15,2))");
      tableCreateIndexSql_array.add("create sequence "+formtable_main_mx+"_ID minvalue 1 maxvalue 9223372036854775807 start with 1 increment by 1 nocache ");

      logAutoInit("insert into kq_autoinit_log(wftype,inittype,initids,initcolumn) values(6,'sequence','"+formtable_main+"_ID','id')");
      logAutoInit("insert into kq_autoinit_log(wftype,inittype,initids,initcolumn) values(6,'sequence','"+formtable_main_mx+"_ID','id')");

      tableCreateIndexSql_array.add("create or replace trigger "+formtable_main+"_ID_TR " +
          " before insert on "+formtable_main+" for each row " +
          " begin " +
          "   select "+formtable_main+"_ID.nextval into :new.id from dual; " +
          " end;");

      tableCreateIndexSql_array.add("create index idx_"+formtable_main+" on "+formtable_main+" (resourceId)");

      tableCreateIndexSql_array.add("create or replace trigger "+formtable_main_mx+"_ID_TR " +
          " before insert on "+formtable_main_mx+" for each row " +
          " begin " +
          "   select "+formtable_main_mx+"_ID.nextval into :new.id from dual; " +
          " end;");

      tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
          "values("+formid+",'resourceId',389034,'int','3',1,0,'','1',0,1.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");
      tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
          "values("+formid+",'leaverequestid',83393,'int','3',16,0,'','1',0,1.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");

      tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
          "values("+formid+",'detail_leavefromDate',30547,'char(10)','3',2,1,'"+formtable_main_mx+"','1',0,1.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
      tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
          "values("+formid+",'detail_leavefromTime',30548,'char(8)','3',19,1,'"+formtable_main_mx+"','1',0,2.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
      tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
          "values("+formid+",'detail_leavetoDate',30549,'char(10)','3',2,1,'"+formtable_main_mx+"','1',0,3.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
      tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
          "values("+formid+",'detail_leavetoTime',30550,'char(8)','3',19,1,'"+formtable_main_mx+"','1',0,4.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
      tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
          "values("+formid+",'detail_newLeaveType',1881,'int','3',34,1,'"+formtable_main_mx+"','1',0,5.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
      tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
          "values("+formid+",'detail_leaveduration',500672,'decimal(15,2)','1',3,1,'"+formtable_main_mx+"','1',0,6.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
      tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
          "values("+formid+",'detail_fromDate',389035,'char(10)','3',2,1,'"+formtable_main_mx+"','1',0,7.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
      tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
          "values("+formid+",'detail_fromTime',389036,'char(8)','3',19,1,'"+formtable_main_mx+"','1',0,8.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
      tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
          "values("+formid+",'detail_toDate',389037,'char(10)','3',2,1,'"+formtable_main_mx+"','1',0,9.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
      tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
          "values("+formid+",'detail_toTime',389038,'char(8)','3',19,1,'"+formtable_main_mx+"','1',0,10.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
      tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
          "values("+formid+",'detail_duration',389039,'decimal(15,2)','1',3,1,'"+formtable_main_mx+"','1',0,11.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");

    }else if((rs.getDBType()).equalsIgnoreCase("mysql")){
      tableCreateSql_array.add("alter table "+formtable_main+" add resourceId int");
      tableCreateSql_array.add("alter table "+formtable_main+" add leaverequestid int");

      tableCreateIndexSql_array.add("create index idx_"+formtable_main+" on "+formtable_main+" (resourceId)");

      tableCreateSql_array.add("create table "+formtable_main_mx+" (id int AUTO_INCREMENT primary key not null, mainid integer, "+
          "detail_leavefromDate char(10), detail_leavefromTime char(8),detail_leavetoDate char(10),"+
          "detail_leavetoTime char(8), detail_newLeaveType int, detail_leaveduration decimal(15,2), "
          + "detail_fromDate char(10), detail_fromTime char(8),detail_toDate char(10),detail_toTime char(8), "
          + "detail_duration decimal(15,2))");

      tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
          "values("+formid+",'resourceId',389034,'int','3',1,0,'','1',0,1.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");
      tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
          "values("+formid+",'leaverequestid',83393,'int','3',16,0,'','1',0,1.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");

      tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
          "values("+formid+",'detail_leavefromDate',30547,'char(10)','3',2,1,'"+formtable_main_mx+"','1',0,1.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
      tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
          "values("+formid+",'detail_leavefromTime',30548,'char(8)','3',19,1,'"+formtable_main_mx+"','1',0,2.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
      tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
          "values("+formid+",'detail_leavetoDate',30549,'char(10)','3',2,1,'"+formtable_main_mx+"','1',0,3.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
      tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
          "values("+formid+",'detail_leavetoTime',30550,'char(8)','3',19,1,'"+formtable_main_mx+"','1',0,4.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
      tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
          "values("+formid+",'detail_newLeaveType',1881,'int','3',34,1,'"+formtable_main_mx+"','1',0,5.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
      tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
          "values("+formid+",'detail_leaveduration',500672,'decimal(15,2)','1',3,1,'"+formtable_main_mx+"','1',0,6.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
      tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
          "values("+formid+",'detail_fromDate',389035,'char(10)','3',2,1,'"+formtable_main_mx+"','1',0,7.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
      tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
          "values("+formid+",'detail_fromTime',389036,'char(8)','3',19,1,'"+formtable_main_mx+"','1',0,8.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
      tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
          "values("+formid+",'detail_toDate',389037,'char(10)','3',2,1,'"+formtable_main_mx+"','1',0,9.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
      tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
          "values("+formid+",'detail_toTime',389038,'char(8)','3',19,1,'"+formtable_main_mx+"','1',0,10.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
      tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
          "values("+formid+",'detail_duration',389039,'decimal(15,2)','1',3,1,'"+formtable_main_mx+"','1',0,11.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");

    }
    else if((rs.getDBType()).equalsIgnoreCase("postgresql")){
      tableCreateSql_array.add("alter table "+formtable_main+" add resourceId int");
      tableCreateSql_array.add("alter table "+formtable_main+" add leaverequestid int");

      tableCreateIndexSql_array.add("create  unique  index idx_"+formtable_main+" on "+formtable_main+" (resourceId)");

      tableCreateSql_array.add("create table "+formtable_main_mx+" (id serial primary key not null, mainid integer, "+
              "detail_leavefromDate char(10), detail_leavefromTime char(8),detail_leavetoDate char(10),"+
              "detail_leavetoTime char(8), detail_newLeaveType int, detail_leaveduration decimal(15,2), "
              + "detail_fromDate char(10), detail_fromTime char(8),detail_toDate char(10),detail_toTime char(8), "
              + "detail_duration decimal(15,2))");

      tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
              "values("+formid+",'resourceId',389034,'int','3',1,0,'','1',0,1.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");
      tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
              "values("+formid+",'leaverequestid',83393,'int','3',16,0,'','1',0,1.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");

      tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
              "values("+formid+",'detail_leavefromDate',30547,'char(10)','3',2,1,'"+formtable_main_mx+"','1',0,1.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
      tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
              "values("+formid+",'detail_leavefromTime',30548,'char(8)','3',19,1,'"+formtable_main_mx+"','1',0,2.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
      tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
              "values("+formid+",'detail_leavetoDate',30549,'char(10)','3',2,1,'"+formtable_main_mx+"','1',0,3.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
      tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
              "values("+formid+",'detail_leavetoTime',30550,'char(8)','3',19,1,'"+formtable_main_mx+"','1',0,4.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
      tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
              "values("+formid+",'detail_newLeaveType',1881,'int','3',34,1,'"+formtable_main_mx+"','1',0,5.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
      tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
              "values("+formid+",'detail_leaveduration',500672,'decimal(15,2)','1',3,1,'"+formtable_main_mx+"','1',0,6.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
      tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
              "values("+formid+",'detail_fromDate',389035,'char(10)','3',2,1,'"+formtable_main_mx+"','1',0,7.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
      tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
              "values("+formid+",'detail_fromTime',389036,'char(8)','3',19,1,'"+formtable_main_mx+"','1',0,8.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
      tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
              "values("+formid+",'detail_toDate',389037,'char(10)','3',2,1,'"+formtable_main_mx+"','1',0,9.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
      tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
              "values("+formid+",'detail_toTime',389038,'char(8)','3',19,1,'"+formtable_main_mx+"','1',0,10.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
      tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
              "values("+formid+",'detail_duration',389039,'decimal(15,2)','1',3,1,'"+formtable_main_mx+"','1',0,11.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");

    }
    else{
      tableCreateSql_array.add("alter table "+formtable_main+" add resourceId int");
      tableCreateSql_array.add("alter table "+formtable_main+" add leaverequestid int");

      tableCreateIndexSql_array.add("create index idx_"+formtable_main+" on "+formtable_main+" (resourceId)");

      tableCreateSql_array.add("create table "+formtable_main_mx+" (id int IDENTITY(1,1) primary key not null, mainid integer, "+
          "detail_leavefromDate char(10), detail_leavefromTime char(8),detail_leavetoDate char(10),"+
          "detail_leavetoTime char(8), detail_newLeaveType int, detail_leaveduration decimal(15,2), "
          + "detail_fromDate char(10), detail_fromTime char(8),detail_toDate char(10),detail_toTime char(8), "
          + "detail_duration decimal(15,2))");

      tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
          "values("+formid+",'resourceId',389034,'int','3',1,0,'','1',0,1.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");
      tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
          "values("+formid+",'leaverequestid',83393,'int','3',16,0,'','1',0,1.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");

      tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
          "values("+formid+",'detail_leavefromDate',30547,'char(10)','3',2,1,'"+formtable_main_mx+"','1',0,1.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
      tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
          "values("+formid+",'detail_leavefromTime',30548,'char(8)','3',19,1,'"+formtable_main_mx+"','1',0,2.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
      tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
          "values("+formid+",'detail_leavetoDate',30549,'char(10)','3',2,1,'"+formtable_main_mx+"','1',0,3.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
      tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
          "values("+formid+",'detail_leavetoTime',30550,'char(8)','3',19,1,'"+formtable_main_mx+"','1',0,4.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
      tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
          "values("+formid+",'detail_newLeaveType',1881,'int','3',34,1,'"+formtable_main_mx+"','1',0,5.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
      tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
          "values("+formid+",'detail_leaveduration',500672,'decimal(15,2)','1',3,1,'"+formtable_main_mx+"','1',0,6.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
      tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
          "values("+formid+",'detail_fromDate',389035,'char(10)','3',2,1,'"+formtable_main_mx+"','1',0,7.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
      tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
          "values("+formid+",'detail_fromTime',389036,'char(8)','3',19,1,'"+formtable_main_mx+"','1',0,8.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
      tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
          "values("+formid+",'detail_toDate',389037,'char(10)','3',2,1,'"+formtable_main_mx+"','1',0,9.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
      tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
          "values("+formid+",'detail_toTime',389038,'char(8)','3',19,1,'"+formtable_main_mx+"','1',0,10.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
      tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
          "values("+formid+",'detail_duration',389039,'decimal(15,2)','1',3,1,'"+formtable_main_mx+"','1',0,11.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");

    }

  }

  /**
   * 补卡流程
   * @param formid
   * @param formtable_main
   * @param formtable_main_mx
   * @param tableCreateSql_array
   * @param detailtable_array
   * @param tableCreateIndexSql_array
   * @param tableFieldInitSql_array
   */
  private void initWfType7(int formid,String formtable_main, String formtable_main_mx,List<String> tableCreateSql_array,List<String> detailtable_array,List<String> tableCreateIndexSql_array,List<String> tableFieldInitSql_array) {

    RecordSet rs = new RecordSet();

    detailtable_array.add(formtable_main_mx);
    if(rs.getDBType().equalsIgnoreCase("oracle")){
      tableCreateSql_array.add("alter table "+formtable_main+" add resourceId int");
      tableCreateSql_array.add("alter table "+formtable_main+" add fromDate char(10)");
      tableCreateSql_array.add("alter table "+formtable_main+" add toDate char(10)");

      tableCreateSql_array.add("create table "+formtable_main_mx+" (id integer primary key not null, mainid integer, "+
          "detail_signdate char(10),detail_scheduletime varchar2(100),detail_atteStatus varchar2(100),detail_signtype int,"+
          "detail_signtime char(8))");
      tableCreateIndexSql_array.add("create sequence "+formtable_main_mx+"_ID minvalue 1 maxvalue 9223372036854775807 start with 1 increment by 1 nocache ");

      logAutoInit("insert into kq_autoinit_log(wftype,inittype,initids,initcolumn) values(7,'sequence','"+formtable_main+"_ID','id')");
      logAutoInit("insert into kq_autoinit_log(wftype,inittype,initids,initcolumn) values(7,'sequence','"+formtable_main_mx+"_ID','id')");

      tableCreateIndexSql_array.add("create or replace trigger "+formtable_main+"_ID_TR " +
          " before insert on "+formtable_main+" for each row " +
          " begin " +
          "   select "+formtable_main+"_ID.nextval into :new.id from dual; " +
          " end;");

      tableCreateIndexSql_array.add("create index idx_"+formtable_main+" on "+formtable_main+" (resourceId)");

      tableCreateIndexSql_array.add("create or replace trigger "+formtable_main_mx+"_ID_TR " +
          " before insert on "+formtable_main_mx+" for each row " +
          " begin " +
          "   select "+formtable_main_mx+"_ID.nextval into :new.id from dual; " +
          " end;");
      tableCreateIndexSql_array.add("create index idx_"+formtable_main_mx+" on "+formtable_main_mx+" (detail_signdate)");

      tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
          "values("+formid+",'resourceId',1867,'int','3',1,0,'','1',0,1.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");
      tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
          "values("+formid+",'fromDate',740,'char(10)','3',2,0,'','1',0,2.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");
      tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
          "values("+formid+",'toDate',741,'char(10)','3',2,0,'','1',0,4.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");

      tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
          "values("+formid+",'detail_signdate',382262,'char(10)','3',2,1,'"+formtable_main_mx+"','1',0,6.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
      tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
          "values("+formid+",'detail_scheduletime',125821,'varchar2(100)','1',1,1,'"+formtable_main_mx+"','1',0,3.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
      tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
          "values("+formid+",'detail_atteStatus',25005,'varchar2(100)','1',1,1,'"+formtable_main_mx+"','1',0,4.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
      tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
          "values("+formid+",'detail_signtype',382261,'int','5',1,1,'"+formtable_main_mx+"','1',0,5.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
      tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
          "values("+formid+",'detail_signtime',382263,'char(8)','3',19,1,'"+formtable_main_mx+"','1',4,7.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");

    }else if((rs.getDBType()).equalsIgnoreCase("mysql")){
      tableCreateSql_array.add("alter table "+formtable_main+" add resourceId int");
      tableCreateSql_array.add("alter table "+formtable_main+" add fromDate char(10)");
      tableCreateSql_array.add("alter table "+formtable_main+" add toDate char(10)");

      tableCreateIndexSql_array.add("create index idx_"+formtable_main+" on "+formtable_main+" (resourceId)");

      tableCreateSql_array.add("create table "+formtable_main_mx+" (id int AUTO_INCREMENT primary key not null, mainid integer, "+
          "detail_signdate char(10), detail_scheduletime varchar(100),detail_atteStatus varchar(100),detail_signtype int,"+
          "detail_signtime char(8))");
      tableCreateIndexSql_array.add("create index idx_"+formtable_main_mx+" on "+formtable_main_mx+" (detail_signdate)");

      tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
          "values("+formid+",'resourceId',1867,'int','3',1,0,'','1',0,1.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");
      tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
          "values("+formid+",'fromDate',740,'char(10)','3',2,0,'','1',0,2.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");
      tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
          "values("+formid+",'toDate',741,'char(10)','3',2,0,'','1',0,4.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");

      tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
          "values("+formid+",'detail_signdate',382262,'char(10)','3',2,1,'"+formtable_main_mx+"','1',0,6.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
      tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
          "values("+formid+",'detail_scheduletime',125821,'varchar(100)','1',1,1,'"+formtable_main_mx+"','1',0,3.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
      tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
          "values("+formid+",'detail_atteStatus',25005,'varchar(100)','1',1,1,'"+formtable_main_mx+"','1',0,4.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
      tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
          "values("+formid+",'detail_signtype',382261,'int','5',1,1,'"+formtable_main_mx+"','1',0,5.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
     tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
          "values("+formid+",'detail_signtime',382263,'char(8)','3',19,1,'"+formtable_main_mx+"','1',4,7.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");

    }
    else if((rs.getDBType()).equalsIgnoreCase("postgresql")){
      tableCreateSql_array.add("alter table "+formtable_main+" add resourceId int");
      tableCreateSql_array.add("alter table "+formtable_main+" add fromDate char(10)");
      tableCreateSql_array.add("alter table "+formtable_main+" add toDate char(10)");

      tableCreateIndexSql_array.add("create unique  index idx_"+formtable_main+" on "+formtable_main+" (resourceId)");

      tableCreateSql_array.add("create table "+formtable_main_mx+" (id serial primary key not null, mainid integer, "+
              "detail_signdate char(10), detail_scheduletime char(100),detail_atteStatus char(100),detail_signtype int,"+
              "detail_signtime char(8))");
      tableCreateIndexSql_array.add("create index idx_"+formtable_main_mx+" on "+formtable_main_mx+" (detail_signdate)");

      tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
              "values("+formid+",'resourceId',1867,'int','3',1,0,'','1',0,1.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");
      tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
              "values("+formid+",'fromDate',740,'char(10)','3',2,0,'','1',0,2.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");
      tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
              "values("+formid+",'toDate',741,'char(10)','3',2,0,'','1',0,4.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");

      tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
              "values("+formid+",'detail_signdate',382262,'char(10)','3',2,1,'"+formtable_main_mx+"','1',0,6.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
      tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
              "values("+formid+",'detail_scheduletime',125821,'char(100)','1',1,1,'"+formtable_main_mx+"','1',0,3.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
      tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
              "values("+formid+",'detail_atteStatus',25005,'char(100)','1',1,1,'"+formtable_main_mx+"','1',0,4.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
      tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
              "values("+formid+",'detail_signtype',382261,'int','5',1,1,'"+formtable_main_mx+"','1',0,5.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
      tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
              "values("+formid+",'detail_signtime',382263,'char(8)','3',19,1,'"+formtable_main_mx+"','1',4,7.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");

    }
    else{
      tableCreateSql_array.add("alter table "+formtable_main+" add resourceId int");
      tableCreateSql_array.add("alter table "+formtable_main+" add fromDate char(10)");
      tableCreateSql_array.add("alter table "+formtable_main+" add toDate char(10)");

      tableCreateSql_array.add("create table "+formtable_main_mx+" (id int IDENTITY(1,1) primary key not null, mainid integer, "+
          "detail_signdate char(10), detail_scheduletime varchar(100),detail_atteStatus varchar(100),detail_signtype int,"+
          "detail_signtime char(8))");


      tableCreateIndexSql_array.add("create index idx_"+formtable_main+" on "+formtable_main+" (resourceId)");
      tableCreateIndexSql_array.add("create index idx_"+formtable_main_mx+" on "+formtable_main_mx+" (detail_signdate)");

      tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
          "values("+formid+",'resourceId',1867,'int','3',1,0,'','1',0,1.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");
      tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
          "values("+formid+",'fromDate',740,'char(10)','3',2,0,'','1',0,2.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");
      tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
          "values("+formid+",'toDate',741,'char(10)','3',2,0,'','1',0,4.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");

      tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
          "values("+formid+",'detail_signdate',382262,'char(10)','3',2,1,'"+formtable_main_mx+"','1',0,6.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
      tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
          "values("+formid+",'detail_scheduletime',125821,'varchar(100)','1',1,1,'"+formtable_main_mx+"','1',0,3.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
      tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
          "values("+formid+",'detail_atteStatus',25005,'varchar(100)','1',1,1,'"+formtable_main_mx+"','1',0,4.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
      tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
          "values("+formid+",'detail_signtype',382261,'int','5',1,1,'"+formtable_main_mx+"','1',0,5.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
     tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
          "values("+formid+",'detail_signtime',382263,'char(8)','3',19,1,'"+formtable_main_mx+"','1',4,7.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");

    }

  }


  /**
   * 考勤变更流程
   * @param formid
   * @param formtable_main
   * @param formtable_main_mx
   * @param tableCreateSql_array
   * @param detailtable_array
   * @param tableCreateIndexSql_array
   * @param tableFieldInitSql_array
   */
  private void initWfType8(int formid,String formtable_main, String formtable_main_mx,List<String> tableCreateSql_array,List<String> detailtable_array,List<String> tableCreateIndexSql_array,List<String> tableFieldInitSql_array) {

    RecordSet rs = new RecordSet();

    detailtable_array.add(formtable_main_mx);

    if(rs.getDBType().equalsIgnoreCase("oracle")){
      tableCreateSql_array.add("alter table "+formtable_main+" add resourceId int");
      tableCreateSql_array.add("alter table "+formtable_main+" add changerequestid int");
      tableCreateSql_array.add("alter table "+formtable_main+" add changetype int");

      tableCreateSql_array.add("create table "+formtable_main_mx+" (id integer primary key not null, mainid integer, "+
          "detail_attendancefromDate char(10), detail_attendancefromTime char(8),detail_attendancetoDate char(10),"+
          "detail_attendancetoTime char(8), detail_attendanceduration decimal(15,2), "
          + "detail_changefromDate char(10), detail_changefromTime char(8),detail_changetoDate char(10),detail_changetoTime char(8), "
          + "detail_changeduration decimal(15,2))");
      tableCreateIndexSql_array.add("create sequence "+formtable_main_mx+"_ID minvalue 1 maxvalue 9223372036854775807 start with 1 increment by 1 nocache ");

      logAutoInit("insert into kq_autoinit_log(wftype,inittype,initids,initcolumn) values(7,'sequence','"+formtable_main+"_ID','id')");
      logAutoInit("insert into kq_autoinit_log(wftype,inittype,initids,initcolumn) values(7,'sequence','"+formtable_main_mx+"_ID','id')");

      tableCreateIndexSql_array.add("create or replace trigger "+formtable_main+"_ID_TR " +
          " before insert on "+formtable_main+" for each row " +
          " begin " +
          "   select "+formtable_main+"_ID.nextval into :new.id from dual; " +
          " end;");

      tableCreateIndexSql_array.add("create index idx_"+formtable_main+" on "+formtable_main+" (resourceId)");

      tableCreateIndexSql_array.add("create or replace trigger "+formtable_main_mx+"_ID_TR " +
          " before insert on "+formtable_main_mx+" for each row " +
          " begin " +
          "   select "+formtable_main_mx+"_ID.nextval into :new.id from dual; " +
          " end;");

      tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
          "values("+formid+",'resourceId',513403,'int','3',1,0,'','1',0,1.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");
      tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
          "values("+formid+",'changerequestid',503981,'int','3',16,0,'','1',0,1.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");
      tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
          "values("+formid+",'changetype',513404,'int','5',1,0,'','1',0,1.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");

      tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
          "values("+formid+",'detail_attendancefromDate',513405,'char(10)','3',2,1,'"+formtable_main_mx+"','1',0,1.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
      tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
          "values("+formid+",'detail_attendancefromTime',513406,'char(8)','3',19,1,'"+formtable_main_mx+"','1',0,2.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
      tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
          "values("+formid+",'detail_attendancetoDate',513407,'char(10)','3',2,1,'"+formtable_main_mx+"','1',0,3.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
      tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
          "values("+formid+",'detail_attendancetoTime',513408,'char(8)','3',19,1,'"+formtable_main_mx+"','1',0,4.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
      tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
          "values("+formid+",'detail_attendanceduration',513409,'decimal(15,2)','1',3,1,'"+formtable_main_mx+"','1',0,5.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
      tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
          "values("+formid+",'detail_changefromDate',513410,'char(10)','3',2,1,'"+formtable_main_mx+"','1',0,6.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
      tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
          "values("+formid+",'detail_changefromTime',513411,'char(8)','3',19,1,'"+formtable_main_mx+"','1',0,7.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
      tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
          "values("+formid+",'detail_changetoDate',513412,'char(10)','3',2,1,'"+formtable_main_mx+"','1',0,8.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
      tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
          "values("+formid+",'detail_changetoTime',513413,'char(8)','3',19,1,'"+formtable_main_mx+"','1',0,9.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
      tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
          "values("+formid+",'detail_changeduration',513414,'decimal(15,2)','1',3,1,'"+formtable_main_mx+"','1',0,10.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");

    }else if((rs.getDBType()).equalsIgnoreCase("mysql")){
      tableCreateSql_array.add("alter table "+formtable_main+" add resourceId int");
      tableCreateSql_array.add("alter table "+formtable_main+" add changerequestid int");
      tableCreateSql_array.add("alter table "+formtable_main+" add changetype int");

      tableCreateIndexSql_array.add("create index idx_"+formtable_main+" on "+formtable_main+" (resourceId)");

      tableCreateSql_array.add("create table "+formtable_main_mx+" (id int AUTO_INCREMENT primary key not null, mainid integer, "+
          "detail_attendancefromDate char(10), detail_attendancefromTime char(8),detail_attendancetoDate char(10),"+
          "detail_attendancetoTime char(8), detail_attendanceduration decimal(15,2), "
          + "detail_changefromDate char(10), detail_changefromTime char(8),detail_changetoDate char(10),detail_changetoTime char(8), "
          + "detail_changeduration decimal(15,2))");

      tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
          "values("+formid+",'resourceId',513403,'int','3',1,0,'','1',0,1.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");
      tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
          "values("+formid+",'changerequestid',503981,'int','3',16,0,'','1',0,1.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");
      tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
          "values("+formid+",'changetype',513404,'int','5',1,0,'','1',0,1.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");

      tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
          "values("+formid+",'detail_attendancefromDate',513405,'char(10)','3',2,1,'"+formtable_main_mx+"','1',0,1.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
      tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
          "values("+formid+",'detail_attendancefromTime',513406,'char(8)','3',19,1,'"+formtable_main_mx+"','1',0,2.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
      tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
          "values("+formid+",'detail_attendancetoDate',513407,'char(10)','3',2,1,'"+formtable_main_mx+"','1',0,3.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
      tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
          "values("+formid+",'detail_attendancetoTime',513408,'char(8)','3',19,1,'"+formtable_main_mx+"','1',0,4.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
      tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
          "values("+formid+",'detail_attendanceduration',513409,'decimal(15,2)','1',3,1,'"+formtable_main_mx+"','1',0,5.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
      tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
          "values("+formid+",'detail_changefromDate',513410,'char(10)','3',2,1,'"+formtable_main_mx+"','1',0,6.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
      tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
          "values("+formid+",'detail_changefromTime',513411,'char(8)','3',19,1,'"+formtable_main_mx+"','1',0,7.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
      tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
          "values("+formid+",'detail_changetoDate',513412,'char(10)','3',2,1,'"+formtable_main_mx+"','1',0,8.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
      tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
          "values("+formid+",'detail_changetoTime',513413,'char(8)','3',19,1,'"+formtable_main_mx+"','1',0,9.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
      tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
          "values("+formid+",'detail_changeduration',513414,'decimal(15,2)','1',3,1,'"+formtable_main_mx+"','1',0,10.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");

    }
    else if((rs.getDBType()).equalsIgnoreCase("postgresql")){
      tableCreateSql_array.add("alter table "+formtable_main+" add resourceId int");
      tableCreateSql_array.add("alter table "+formtable_main+" add changerequestid int");
      tableCreateSql_array.add("alter table "+formtable_main+" add changetype int");

      tableCreateIndexSql_array.add("create   index idx_"+formtable_main+" on "+formtable_main+" (resourceId)");

      tableCreateSql_array.add("create table "+formtable_main_mx+" (id serial primary key not null, mainid integer, "+
              "detail_attendancefromDate char(10), detail_attendancefromTime char(8),detail_attendancetoDate char(10),"+
              "detail_attendancetoTime char(8), detail_attendanceduration decimal(15,2), "
              + "detail_changefromDate char(10), detail_changefromTime char(8),detail_changetoDate char(10),detail_changetoTime char(8), "
              + "detail_changeduration decimal(15,2))");

      tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
              "values("+formid+",'resourceId',513403,'int','3',1,0,'','1',0,1.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");
      tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
              "values("+formid+",'changerequestid',503981,'int','3',16,0,'','1',0,1.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");
      tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
              "values("+formid+",'changetype',513404,'int','5',1,0,'','1',0,1.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");

      tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
              "values("+formid+",'detail_attendancefromDate',513405,'char(10)','3',2,1,'"+formtable_main_mx+"','1',0,1.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
      tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
              "values("+formid+",'detail_attendancefromTime',513406,'char(8)','3',19,1,'"+formtable_main_mx+"','1',0,2.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
      tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
              "values("+formid+",'detail_attendancetoDate',513407,'char(10)','3',2,1,'"+formtable_main_mx+"','1',0,3.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
      tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
              "values("+formid+",'detail_attendancetoTime',513408,'char(8)','3',19,1,'"+formtable_main_mx+"','1',0,4.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
      tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
              "values("+formid+",'detail_attendanceduration',513409,'decimal(15,2)','1',3,1,'"+formtable_main_mx+"','1',0,5.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
      tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
              "values("+formid+",'detail_changefromDate',513410,'char(10)','3',2,1,'"+formtable_main_mx+"','1',0,6.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
      tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
              "values("+formid+",'detail_changefromTime',513411,'char(8)','3',19,1,'"+formtable_main_mx+"','1',0,7.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
      tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
              "values("+formid+",'detail_changetoDate',513412,'char(10)','3',2,1,'"+formtable_main_mx+"','1',0,8.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
      tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
              "values("+formid+",'detail_changetoTime',513413,'char(8)','3',19,1,'"+formtable_main_mx+"','1',0,9.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
      tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
              "values("+formid+",'detail_changeduration',513414,'decimal(15,2)','1',3,1,'"+formtable_main_mx+"','1',0,10.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");

    }
    else{
      tableCreateSql_array.add("alter table "+formtable_main+" add resourceId int");
      tableCreateSql_array.add("alter table "+formtable_main+" add changerequestid int");
      tableCreateSql_array.add("alter table "+formtable_main+" add changetype int");

      tableCreateIndexSql_array.add("create index idx_"+formtable_main+" on "+formtable_main+" (resourceId)");

      tableCreateSql_array.add("create table "+formtable_main_mx+" (id int IDENTITY(1,1) primary key not null, mainid integer, "+
          "detail_attendancefromDate char(10), detail_attendancefromTime char(8),detail_attendancetoDate char(10),"+
          "detail_attendancetoTime char(8), detail_attendanceduration decimal(15,2), "
          + "detail_changefromDate char(10), detail_changefromTime char(8),detail_changetoDate char(10),detail_changetoTime char(8), "
          + "detail_changeduration decimal(15,2))");

      tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
          "values("+formid+",'resourceId',513403,'int','3',1,0,'','1',0,1.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");
      tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
          "values("+formid+",'changerequestid',503981,'int','3',16,0,'','1',0,1.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");
      tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
          "values("+formid+",'changetype',513404,'int','5',1,0,'','1',0,1.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)");

      tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
          "values("+formid+",'detail_attendancefromDate',513405,'char(10)','3',2,1,'"+formtable_main_mx+"','1',0,1.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
      tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
          "values("+formid+",'detail_attendancefromTime',513406,'char(8)','3',19,1,'"+formtable_main_mx+"','1',0,2.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
      tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
          "values("+formid+",'detail_attendancetoDate',513407,'char(10)','3',2,1,'"+formtable_main_mx+"','1',0,3.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
      tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
          "values("+formid+",'detail_attendancetoTime',513408,'char(8)','3',19,1,'"+formtable_main_mx+"','1',0,4.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
      tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
          "values("+formid+",'detail_attendanceduration',513409,'decimal(15,2)','1',3,1,'"+formtable_main_mx+"','1',0,5.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
      tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
          "values("+formid+",'detail_changefromDate',513410,'char(10)','3',2,1,'"+formtable_main_mx+"','1',0,6.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
      tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
          "values("+formid+",'detail_changefromTime',513411,'char(8)','3',19,1,'"+formtable_main_mx+"','1',0,7.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
      tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
          "values("+formid+",'detail_changetoDate',513412,'char(10)','3',2,1,'"+formtable_main_mx+"','1',0,8.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
      tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
          "values("+formid+",'detail_changetoTime',513413,'char(8)','3',19,1,'"+formtable_main_mx+"','1',0,9.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");
      tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+
          "values("+formid+",'detail_changeduration',513414,'decimal(15,2)','1',3,1,'"+formtable_main_mx+"','1',0,10.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)");

    }

  }

  public Map<String,Object> InitWorkflow(int formid,String wfType,String wfname) throws Exception{
    Map<String,Object> wfMap = new HashMap<>();
    int wfid = 0;
    String[] _workflow_nodeId_array = new String[]{
        "0",//创建
        "0",//审批
        "0"//归档
    };
    RecordSet rs = new RecordSet();
    RecordSetTrans rst = new RecordSetTrans();
    try {
      ManageDetachComInfo manageDetachComInfo = new ManageDetachComInfo();

      int subcompanyid = -1;
      int wfTypeid = 1;//系统默认工作流
      String sql = "";

      //获取分权分部。如果页面没有，则首先从分权设置的默认机构取得，如果默认机构没有设置则取所有分部中id最小的那个分部。
      subcompanyid = Util.getIntValue(manageDetachComInfo.getWfdftsubcomid(), -1);

      HashMap<String, String> wfBillfield_hm = new HashMap<String, String>();
      rs.executeSql("select id, fieldname from workflow_billfield where billid = "+formid);
      while(rs.next()){
        wfBillfield_hm.put(Util.null2String(rs.getString("fieldname")).trim(), rs.getString("id"));
      }
      String _guid1 = UUID.randomUUID().toString();

      //新建流程
      String inserSql_workflow_base =
          "insert into workflow_base\n" +
              "  (workflowname, workflowdesc,\n" +
              "  workflowtype, securelevel, formid,\n" +
              "  userid, isbill, iscust,\n" +
              "  helpdocid, isvalid, needmark,\n" +
              "  messagetype, multisubmit, defaultname,\n" +
              "  docpath, subcompanyid, mailmessagetype,\n" +
              "  docrightbyoperator, doccategory, istemplate,\n" +
              "  templateid, catelogtype, selectedcatelog,\n" +
              "  docrightbyhrmresource, needaffirmance, isremarks,\n" +
              "  isannexupload, annexdoccategory, isshowonreportinput,\n" +
              "  titlefieldid, keywordfieldid, isshowchart,\n" +
              "  orderbytype, istridiffworkflow, ismodifylog,\n" +
              "  ifversion, wfdocpath, wfdocowner,\n" +
              "  isedit, editor, editdate,\n" +
              "  edittime, showdelbuttonbyreject, wfdocownertype,\n" +
              "  wfdocownerfieldid, issignview, showuploadtab,\n" +
              "  issigndoc, showdoctab, issignworkflow,\n" +
              "  showworkflowtab, candelacc, isforwardrights,\n" +
              "  isimportwf, isrejectremind, ischangrejectnode,\n" +
              "  newdocpath, keepsign, seccategoryid,\n" +
              "  custompage, isselectrejectnode, forbidattdownload,\n" +
              "  isimportdetail, specialapproval, frequency,\n" +
              "  cycle, nosynfields, isneeddelacc,\n" +
              "  sapsource, isfnacontrol, fnanodeid,\n" +
              "  fnadepartmentid, smsalertstype, issavecheckform,\n" +
              "  archivenomsgalert, archivenomailalert, isfnabudgetwf,\n" +
              "  forwardreceivedef, fieldnotimport, isworkflowdoc,\n" +
              "  version, activeversionid, versiondescription,\n" +
              "  versioncreater, dsporder, isfree,\n" +
              "  chatstype, chatsalerttype,\n" +
              "  notremindifarchived, officaltype, custompage4emoble,\n" +
              "  isupdatetitle, isshared, isoverrb,\n" +
              "  isoveriv \n" +
              " )values( \n" +
              "  '"+StringEscapeUtils.escapeSql(_guid1)+"', '',\n" +
              "  "+wfTypeid+", '', "+formid+",\n" +
              "  NULL, '1', 0,\n" +
              "  0, '1', '',\n" +
              "  0, 0, 1,\n" +
              "  '', "+subcompanyid+", 0,\n" +
              "  0, ',,', '0',\n" +
              "  0, 0, 0,\n" +
              "  0, '', '',\n" +
              "  '', ',,', '',\n" +
              "  NULL, NULL, '',\n" +
              "  '1', NULL, '',\n" +
              "  NULL, '', '',\n" +
              "  NULL, NULL, NULL,\n" +
              "  NULL, '1', 0,\n" +
              "  0, 0, '',\n" +
              "  '', '', '',\n" +
              "  '', '', '0',\n" +
              "  '', '', '',\n" +
              "  '', NULL, NULL,\n" +
              "  '', '', 0,\n" +
              "  '', '', 0,\n" +
              "  '', '', '0',\n" +
              "  '', NULL, NULL,\n" +
              "  NULL, '0', '',\n" +
              "  '', '', NULL,\n" +
              "  '', '', 0,\n" +
              "  NULL, NULL, NULL,\n" +
              "  NULL, 0, '0',\n" +
              "  0, 0,\n" +
              "  0, NULL, NULL,\n" +
              "  1, '0', '0',\n" +
              "  '0' \n" +
              " )";

      String[] _workflow_nodeName_array = new String[]{
          "创建",
          "审批",
          "归档"
      };
      String[] inserSql_workflow_nodebase_array = new String[]{
          "INSERT INTO workflow_nodebase (nodename,isstart,isreject,isreopen,isend,drawxpos,drawypos,totalgroups,nodeattribute,passnum,IsFreeNode,floworder,Signtype,operators_1,requestid,startnodeid,operators)\n" +
              " VALUES ('"+StringEscapeUtils.escapeSql(_guid1)+"','1','0','0','0',-1,-1,0,'0',0,'',NULL,NULL,NULL,NULL,NULL,NULL)",
          "INSERT INTO workflow_nodebase (nodename,isstart,isreject,isreopen,isend,drawxpos,drawypos,totalgroups,nodeattribute,passnum,IsFreeNode,floworder,Signtype,operators_1,requestid,startnodeid,operators)\n" +
              " VALUES ('"+StringEscapeUtils.escapeSql(_guid1)+"','0','1','1','0',-1,-1,0,'0',0,'',NULL,NULL,NULL,NULL,NULL,NULL)",
          "INSERT INTO workflow_nodebase (nodename,isstart,isreject,isreopen,isend,drawxpos,drawypos,totalgroups,nodeattribute,passnum,IsFreeNode,floworder,Signtype,operators_1,requestid,startnodeid,operators)\n" +
              " VALUES ('"+StringEscapeUtils.escapeSql(_guid1)+"','0','0','0','1',-1,-1,0,'0',0,'',NULL,NULL,NULL,NULL,NULL,NULL)"
      };

      String[] inserSql_workflow_flownode_array = new String[]{
          "INSERT INTO workflow_flownode (workflowid, nodeid, nodetype, viewnodeids, "+
              " viewtypeall, viewdescall, showtype, IsPendingForward, IsSubmitedOpinion, "+
              " isfeedback, nodeorder, isRemarkLocation)\n" +
              " VALUES (666666workflowid999999, 666666nodeid666666, '0', '-1', "+
              " '1', '1', '0', '1', '1', "+
              " '1', 1, 0)",

          "INSERT INTO workflow_flownode (workflowid, nodeid, nodetype, viewnodeids, "+
              " viewtypeall, viewdescall, showtype, IsPendingForward, IsSubmitedOpinion, "+
              " isfeedback, nodeorder, isRemarkLocation)\n" +
              " VALUES (666666workflowid999999, 666666nodeid666666, '1', '-1', "+
              " '1', '1', '0', '1', '1', "+
              " '1', 2, 0)",

          "INSERT INTO workflow_flownode (workflowid, nodeid, nodetype, viewnodeids, "+
              " viewtypeall, viewdescall, showtype, IsPendingForward, IsSubmitedOpinion, "+
              " isfeedback, nodeorder, isRemarkLocation)\n" +
              " VALUES (666666workflowid999999, 666666nodeid666666, '3', '-1', "+
              " '1', '1', '0', '1', '1', "+
              " '1', 3, 0)"
      };

      HashMap<String, String> workflow_nodeform_fieldEditType_hm = new HashMap<String, String>();
      initFieldEditType(workflow_nodeform_fieldEditType_hm,wfType);

      rst.setAutoCommit(false);

      rst.executeSql(inserSql_workflow_base);
      //rst.writeLog("inserSql_workflow_base:"+inserSql_workflow_base);
      rst.executeSql("select max(id) maxId from workflow_base where workflowname = '"+StringEscapeUtils.escapeSql(_guid1)+"'");
      if(rst.next()){
        wfid = rst.getInt("maxId");
        logAutoInit("insert into kq_autoinit_log(wftype,inittype,initids,initcolumn) values("+wfType+",'workflow_base',"+wfid+",'id')");
        rst.executeSql("update workflow_base set workflowname = '"+StringEscapeUtils.escapeSql(wfname)+"' where id = "+wfid);
        //rst.writeLog("update workflow_base set workflowname = '"+StringEscapeUtils.escapeSql(wfname)+"' where id = "+wfid);

        rst.executeSql("insert into workflow_versioninfo (wfid, wfversionid) values ("+wfid+", "+wfid+")");
        //rst.writeLog("insert into workflow_versioninfo (wfid, wfversionid) values ("+wfid+", "+wfid+")");
        logAutoInit("insert into kq_autoinit_log(wftype,inittype,initids,initcolumn) values("+wfType+",'workflow_versioninfo',"+wfid+",'wfid')");

        for(int i=0;i<_workflow_nodeName_array.length;i++){
          String inserSql_workflow_nodeName = _workflow_nodeName_array[i];
          String inserSql_workflow_nodebase = inserSql_workflow_nodebase_array[i];
          String inserSql_workflow_flownode = inserSql_workflow_flownode_array[i];

          rst.executeSql(inserSql_workflow_nodebase);
          //rst.writeLog("inserSql_workflow_nodebase:"+inserSql_workflow_nodebase);

          rst.executeSql("select max(id) maxId from workflow_nodebase where nodename = '"+StringEscapeUtils.escapeSql(_guid1)+"'");
          if(rst.next()){
            int _nodeId = rst.getInt("maxId");
            _workflow_nodeId_array[i] = _nodeId+"";

            rst.executeSql("update workflow_nodebase set nodename = '"+StringEscapeUtils.escapeSql(inserSql_workflow_nodeName)+"' where id = "+_nodeId);
            //rst.writeLog("update workflow_nodebase set nodename = '"+StringEscapeUtils.escapeSql(inserSql_workflow_nodeName)+"' where id = "+_nodeId);

            logAutoInit("insert into kq_autoinit_log(wftype,inittype,initids,initcolumn) values("+wfType+",'workflow_nodebase',"+_nodeId+",'id')");

            inserSql_workflow_flownode = inserSql_workflow_flownode
                .replaceAll("666666workflowid999999", wfid+"")
                .replaceAll("666666nodeid666666", _nodeId+"");

            rst.executeSql(inserSql_workflow_flownode);
            //rst.writeLog("inserSql_workflow_flownode:"+inserSql_workflow_flownode);
            logAutoInit("insert into kq_autoinit_log(wftype,inittype,initids,initcolumn) values("+wfType+",'workflow_flownode',"+wfid+",'workflowid')");
          }
        }


        String inserSql_workflow_nodelink = "INSERT INTO workflow_nodelink (workflowid, nodeid, linkname, destnodeid, directionfrom, directionto, "+
            " nodepasstime, startDirection, endDirection, linkorder )\n" +
            " VALUES ("+wfid+", "+Util.getIntValue(_workflow_nodeId_array[0])+", '"+weaver.systeminfo.SystemEnv.getHtmlLabelName(383043,weaver.general.ThreadVarLanguage.getLang())+"', "+Util.getIntValue(_workflow_nodeId_array[1])+", -1, -1, "+
            " '-1', -1, -1, 1 )";
        rst.executeSql(inserSql_workflow_nodelink);
        //rst.writeLog("inserSql_workflow_nodelink:"+inserSql_workflow_nodelink);
        logAutoInit("insert into kq_autoinit_log(wftype,inittype,initids,initcolumn) values("+wfType+",'workflow_nodelink',"+wfid+",'workflowid')");

        inserSql_workflow_nodelink = "INSERT INTO workflow_nodelink (workflowid, nodeid, linkname, destnodeid, directionfrom, directionto, "+
            " nodepasstime, startDirection, endDirection, linkorder )\n" +
            " VALUES ("+wfid+", "+Util.getIntValue(_workflow_nodeId_array[1])+", '"+weaver.systeminfo.SystemEnv.getHtmlLabelName(142,weaver.general.ThreadVarLanguage.getLang())+"', "+Util.getIntValue(_workflow_nodeId_array[2])+", -1, -1, "+
            " '-1', -1, -1, 2 )";
        rst.executeSql(inserSql_workflow_nodelink);
        //rst.writeLog("inserSql_workflow_nodelink:"+inserSql_workflow_nodelink);

        List<String> _insert_sql_workflow_nodeform_list = new ArrayList<String>();
        for(int i=0;i<_workflow_nodeId_array.length;i++){
          int inserSql_workflow_nodeId = Util.getIntValue(_workflow_nodeId_array[i]);
          if(inserSql_workflow_nodeId > 0){
            String sql_workflow_billfield = "select id, fieldname, dsporder from workflow_billfield where billid = "+formid+" order by dsporder";
            rst.executeSql(sql_workflow_billfield);
            while(rst.next()){
              int _fieldId = rst.getInt("id");
              String _fieldname = Util.null2String(rst.getString("fieldname")).trim();
              double _dsporder = Util.getDoubleValue(rst.getString("dsporder"), 0);

              int isview = Util.getIntValue(workflow_nodeform_fieldEditType_hm.get(_fieldname+"_isview"), 1);
              int isedit = Util.getIntValue(workflow_nodeform_fieldEditType_hm.get(_fieldname+"_isedit"), 1);
              int ismandatory = Util.getIntValue(workflow_nodeform_fieldEditType_hm.get(_fieldname+"_ismandatory"), 0);
              _insert_sql_workflow_nodeform_list.add("insert into workflow_nodeform (nodeid, fieldid, isview, isedit, ismandatory, orderid) "+
                  " values ("+inserSql_workflow_nodeId+", "+_fieldId+", '"+isview+"', '"+isedit+"', '"+ismandatory+"', "+_dsporder+")");
              logAutoInit("insert into kq_autoinit_log(wftype,inittype,initids,initcolumn) values("+wfType+",'workflow_nodeform',"+inserSql_workflow_nodeId+",'nodeid')");
            }
          }
        }

        for(int i=0;i<_insert_sql_workflow_nodeform_list.size();i++){
          rst.executeSql(_insert_sql_workflow_nodeform_list.get(i));
          //rst.writeLog("_insert_sql_workflow_nodeform_list:"+_insert_sql_workflow_nodeform_list.get(i));
        }
      }

      rst.commit();
      //更新缓存
      String tables[] = {"workflow_nodebase"};
      CacheFactory.getInstance().removeCache(tables);

    }catch (Exception e){
      try{
        rst.rollback();
        rst.setChecksql(true);
      }catch(Exception ex1){}
      new BaseBean().writeLog(e);
      throw new Exception("流程创建失败");
    }

    wfMap.put("wfid", wfid);
    wfMap.put("_workflow_nodeId_array", _workflow_nodeId_array);
    return wfMap;
  }

  /**
   * 初始化字段属性，可编辑还是必填
   * @param workflow_nodeform_fieldEditType_hm
   * @param wfType
   */
  private void initFieldEditType(HashMap<String,String> workflow_nodeform_fieldEditType_hm,String wfType) {

//    变更流程类型，0表示请假，1表示出差，2表示公出，3表示加班，4表示异常，5表示排班，6表示销假
    //0表示请假
    if("0".equals(wfType)){
      initFieldEditType0(workflow_nodeform_fieldEditType_hm);
    }
    //1表示出差
    if("1".equals(wfType)){
      initFieldEditType1(workflow_nodeform_fieldEditType_hm);
    }
    //2表示公出
    if("2".equals(wfType)){
      initFieldEditType2(workflow_nodeform_fieldEditType_hm);
    }
    //3表示加班
    if("3".equals(wfType)){
      initFieldEditType3(workflow_nodeform_fieldEditType_hm);
    }
    //4表示异常
    if("4".equals(wfType)){
      initFieldEditType4(workflow_nodeform_fieldEditType_hm);
    }
    //5表示排班
    if("5".equals(wfType)){
      initFieldEditType5(workflow_nodeform_fieldEditType_hm);
    }
    //6表示销假
    if("6".equals(wfType)){
      initFieldEditType6(workflow_nodeform_fieldEditType_hm);
    }
  }

  /**
   * 初始化请假的流程字段属性
   * @param workflow_nodeform_fieldEditType_hm
   */
  private void initFieldEditType0(HashMap<String,String> workflow_nodeform_fieldEditType_hm) {
    workflow_nodeform_fieldEditType_hm.put("resourceId"+"_isedit", "1");
    workflow_nodeform_fieldEditType_hm.put("departmentId"+"_isedit", "1");
    workflow_nodeform_fieldEditType_hm.put("newLeaveType"+"_isedit", "1");
    workflow_nodeform_fieldEditType_hm.put("fromDate"+"_isedit", "1");
    workflow_nodeform_fieldEditType_hm.put("fromTime"+"_isedit", "1");
    workflow_nodeform_fieldEditType_hm.put("toDate"+"_isedit", "1");
    workflow_nodeform_fieldEditType_hm.put("toTime"+"_isedit", "1");
    workflow_nodeform_fieldEditType_hm.put("duration"+"_isedit", "1");
    workflow_nodeform_fieldEditType_hm.put("vacationInfo"+"_isedit", "1");
    workflow_nodeform_fieldEditType_hm.put("detail_resourceId"+"_isedit", "1");
    workflow_nodeform_fieldEditType_hm.put("detail_departmentId"+"_isedit", "1");
    workflow_nodeform_fieldEditType_hm.put("detail_newLeaveType"+"_isedit", "1");
    workflow_nodeform_fieldEditType_hm.put("detail_fromDate"+"_isedit", "1");
    workflow_nodeform_fieldEditType_hm.put("detail_fromTime"+"_isedit", "1");
    workflow_nodeform_fieldEditType_hm.put("detail_toDate"+"_isedit", "1");
    workflow_nodeform_fieldEditType_hm.put("detail_toTime"+"_isedit", "1");
    workflow_nodeform_fieldEditType_hm.put("detail_duration"+"_isedit", "1");
    workflow_nodeform_fieldEditType_hm.put("detail_vacationInfo"+"_isedit", "1");

    workflow_nodeform_fieldEditType_hm.put("resourceId"+"_ismandatory", "1");
    workflow_nodeform_fieldEditType_hm.put("departmentId"+"_ismandatory", "1");
    workflow_nodeform_fieldEditType_hm.put("newLeaveType"+"_ismandatory", "1");
    workflow_nodeform_fieldEditType_hm.put("fromDate"+"_ismandatory", "1");
    workflow_nodeform_fieldEditType_hm.put("fromTime"+"_ismandatory", "1");
    workflow_nodeform_fieldEditType_hm.put("toDate"+"_ismandatory", "1");
    workflow_nodeform_fieldEditType_hm.put("toTime"+"_ismandatory", "1");
    workflow_nodeform_fieldEditType_hm.put("duration"+"_ismandatory", "1");
    workflow_nodeform_fieldEditType_hm.put("vacationInfo"+"_ismandatory", "1");
    workflow_nodeform_fieldEditType_hm.put("detail_resourceId"+"_ismandatory", "1");
    workflow_nodeform_fieldEditType_hm.put("detail_departmentId"+"_ismandatory", "1");
    workflow_nodeform_fieldEditType_hm.put("detail_newLeaveType"+"_ismandatory", "1");
    workflow_nodeform_fieldEditType_hm.put("detail_fromDate"+"_ismandatory", "1");
    workflow_nodeform_fieldEditType_hm.put("detail_fromTime"+"_ismandatory", "1");
    workflow_nodeform_fieldEditType_hm.put("detail_toDate"+"_ismandatory", "1");
    workflow_nodeform_fieldEditType_hm.put("detail_toTime"+"_ismandatory", "1");
    workflow_nodeform_fieldEditType_hm.put("detail_duration"+"_ismandatory", "1");
    workflow_nodeform_fieldEditType_hm.put("detail_vacationInfo"+"_ismandatory", "1");
  }

  /**
   * 初始化出差的流程字段属性
   * @param workflow_nodeform_fieldEditType_hm
   */
  private void initFieldEditType1(HashMap<String,String> workflow_nodeform_fieldEditType_hm) {

    workflow_nodeform_fieldEditType_hm.put("resourceId"+"_isedit", "1");
    workflow_nodeform_fieldEditType_hm.put("departmentId"+"_isedit", "1");
    workflow_nodeform_fieldEditType_hm.put("fromDate"+"_isedit", "1");
    workflow_nodeform_fieldEditType_hm.put("fromTime"+"_isedit", "1");
    workflow_nodeform_fieldEditType_hm.put("toDate"+"_isedit", "1");
    workflow_nodeform_fieldEditType_hm.put("toTime"+"_isedit", "1");
    workflow_nodeform_fieldEditType_hm.put("detail_resourceId"+"_isedit", "1");
    workflow_nodeform_fieldEditType_hm.put("detail_departmentId"+"_isedit", "1");
    workflow_nodeform_fieldEditType_hm.put("detail_fromDate"+"_isedit", "1");
    workflow_nodeform_fieldEditType_hm.put("detail_fromTime"+"_isedit", "1");
    workflow_nodeform_fieldEditType_hm.put("detail_toDate"+"_isedit", "1");
    workflow_nodeform_fieldEditType_hm.put("detail_toTime"+"_isedit", "1");

    workflow_nodeform_fieldEditType_hm.put("resourceId"+"_ismandatory", "1");
    workflow_nodeform_fieldEditType_hm.put("departmentId"+"_ismandatory", "1");
    workflow_nodeform_fieldEditType_hm.put("fromDate"+"_ismandatory", "1");
    workflow_nodeform_fieldEditType_hm.put("fromTime"+"_ismandatory", "1");
    workflow_nodeform_fieldEditType_hm.put("toDate"+"_ismandatory", "1");
    workflow_nodeform_fieldEditType_hm.put("toTime"+"_ismandatory", "1");
    workflow_nodeform_fieldEditType_hm.put("detail_resourceId"+"_ismandatory", "1");
    workflow_nodeform_fieldEditType_hm.put("detail_departmentId"+"_ismandatory", "1");
    workflow_nodeform_fieldEditType_hm.put("detail_fromDate"+"_ismandatory", "1");
    workflow_nodeform_fieldEditType_hm.put("detail_fromTime"+"_ismandatory", "1");
    workflow_nodeform_fieldEditType_hm.put("detail_toDate"+"_ismandatory", "1");
    workflow_nodeform_fieldEditType_hm.put("detail_toTime"+"_ismandatory", "1");

  }

  /**
   * 初始化公出的流程字段属性
   * @param workflow_nodeform_fieldEditType_hm
   */
  private void initFieldEditType2(HashMap<String,String> workflow_nodeform_fieldEditType_hm) {

    workflow_nodeform_fieldEditType_hm.put("resourceId"+"_isedit", "1");
    workflow_nodeform_fieldEditType_hm.put("departmentId"+"_isedit", "1");
    workflow_nodeform_fieldEditType_hm.put("fromDate"+"_isedit", "1");
    workflow_nodeform_fieldEditType_hm.put("fromTime"+"_isedit", "1");
    workflow_nodeform_fieldEditType_hm.put("toDate"+"_isedit", "1");
    workflow_nodeform_fieldEditType_hm.put("toTime"+"_isedit", "1");
    workflow_nodeform_fieldEditType_hm.put("detail_resourceId"+"_isedit", "1");
    workflow_nodeform_fieldEditType_hm.put("detail_departmentId"+"_isedit", "1");
    workflow_nodeform_fieldEditType_hm.put("detail_fromDate"+"_isedit", "1");
    workflow_nodeform_fieldEditType_hm.put("detail_fromTime"+"_isedit", "1");
    workflow_nodeform_fieldEditType_hm.put("detail_toDate"+"_isedit", "1");
    workflow_nodeform_fieldEditType_hm.put("detail_toTime"+"_isedit", "1");

    workflow_nodeform_fieldEditType_hm.put("resourceId"+"_ismandatory", "1");
    workflow_nodeform_fieldEditType_hm.put("departmentId"+"_ismandatory", "1");
    workflow_nodeform_fieldEditType_hm.put("fromDate"+"_ismandatory", "1");
    workflow_nodeform_fieldEditType_hm.put("fromTime"+"_ismandatory", "1");
    workflow_nodeform_fieldEditType_hm.put("toDate"+"_ismandatory", "1");
    workflow_nodeform_fieldEditType_hm.put("toTime"+"_ismandatory", "1");
    workflow_nodeform_fieldEditType_hm.put("detail_resourceId"+"_ismandatory", "1");
    workflow_nodeform_fieldEditType_hm.put("detail_departmentId"+"_ismandatory", "1");
    workflow_nodeform_fieldEditType_hm.put("detail_fromDate"+"_ismandatory", "1");
    workflow_nodeform_fieldEditType_hm.put("detail_fromTime"+"_ismandatory", "1");
    workflow_nodeform_fieldEditType_hm.put("detail_toDate"+"_ismandatory", "1");
    workflow_nodeform_fieldEditType_hm.put("detail_toTime"+"_ismandatory", "1");
  }

  /**
   * 初始化加班的流程字段属性
   * @param workflow_nodeform_fieldEditType_hm
   */
  private void initFieldEditType3(HashMap<String,String> workflow_nodeform_fieldEditType_hm) {

    workflow_nodeform_fieldEditType_hm.put("resourceId"+"_isedit", "1");
    workflow_nodeform_fieldEditType_hm.put("departmentId"+"_isedit", "1");
    workflow_nodeform_fieldEditType_hm.put("fromDate"+"_isedit", "1");
    workflow_nodeform_fieldEditType_hm.put("fromTime"+"_isedit", "1");
    workflow_nodeform_fieldEditType_hm.put("toDate"+"_isedit", "1");
    workflow_nodeform_fieldEditType_hm.put("toTime"+"_isedit", "1");
    workflow_nodeform_fieldEditType_hm.put("duration"+"_isedit", "1");
    workflow_nodeform_fieldEditType_hm.put("detail_duration"+"_isedit", "1");
    workflow_nodeform_fieldEditType_hm.put("detail_resourceId"+"_isedit", "1");
    workflow_nodeform_fieldEditType_hm.put("detail_departmentId"+"_isedit", "1");
    workflow_nodeform_fieldEditType_hm.put("detail_fromDate"+"_isedit", "1");
    workflow_nodeform_fieldEditType_hm.put("detail_fromTime"+"_isedit", "1");
    workflow_nodeform_fieldEditType_hm.put("detail_toDate"+"_isedit", "1");
    workflow_nodeform_fieldEditType_hm.put("detail_toTime"+"_isedit", "1");

    workflow_nodeform_fieldEditType_hm.put("resourceId"+"_ismandatory", "1");
    workflow_nodeform_fieldEditType_hm.put("departmentId"+"_ismandatory", "1");
    workflow_nodeform_fieldEditType_hm.put("fromDate"+"_ismandatory", "1");
    workflow_nodeform_fieldEditType_hm.put("fromTime"+"_ismandatory", "1");
    workflow_nodeform_fieldEditType_hm.put("toDate"+"_ismandatory", "1");
    workflow_nodeform_fieldEditType_hm.put("toTime"+"_ismandatory", "1");
    workflow_nodeform_fieldEditType_hm.put("duration"+"_ismandatory", "1");
    workflow_nodeform_fieldEditType_hm.put("detail_duration"+"_ismandatory", "1");
    workflow_nodeform_fieldEditType_hm.put("detail_resourceId"+"_ismandatory", "1");
    workflow_nodeform_fieldEditType_hm.put("detail_departmentId"+"_ismandatory", "1");
    workflow_nodeform_fieldEditType_hm.put("detail_fromDate"+"_ismandatory", "1");
    workflow_nodeform_fieldEditType_hm.put("detail_fromTime"+"_ismandatory", "1");
    workflow_nodeform_fieldEditType_hm.put("detail_toDate"+"_ismandatory", "1");
    workflow_nodeform_fieldEditType_hm.put("detail_toTime"+"_ismandatory", "1");
  }

  /**
   * 初始化异常的流程字段属性
   * @param workflow_nodeform_fieldEditType_hm
   */
  private void initFieldEditType4(HashMap<String,String> workflow_nodeform_fieldEditType_hm) {

    workflow_nodeform_fieldEditType_hm.put("resourceId"+"_isedit", "1");
    workflow_nodeform_fieldEditType_hm.put("departmentId"+"_isedit", "1");
    workflow_nodeform_fieldEditType_hm.put("fromDate"+"_isedit", "1");
    workflow_nodeform_fieldEditType_hm.put("fromTime"+"_isedit", "1");
    workflow_nodeform_fieldEditType_hm.put("toDate"+"_isedit", "1");
    workflow_nodeform_fieldEditType_hm.put("toTime"+"_isedit", "1");
    workflow_nodeform_fieldEditType_hm.put("detail_resourceId"+"_isedit", "1");
    workflow_nodeform_fieldEditType_hm.put("detail_departmentId"+"_isedit", "1");
    workflow_nodeform_fieldEditType_hm.put("detail_fromDate"+"_isedit", "1");
    workflow_nodeform_fieldEditType_hm.put("detail_fromTime"+"_isedit", "1");
    workflow_nodeform_fieldEditType_hm.put("detail_toDate"+"_isedit", "1");
    workflow_nodeform_fieldEditType_hm.put("detail_toTime"+"_isedit", "1");

    workflow_nodeform_fieldEditType_hm.put("resourceId"+"_ismandatory", "1");
    workflow_nodeform_fieldEditType_hm.put("departmentId"+"_ismandatory", "1");
    workflow_nodeform_fieldEditType_hm.put("fromDate"+"_ismandatory", "1");
    workflow_nodeform_fieldEditType_hm.put("fromTime"+"_ismandatory", "1");
    workflow_nodeform_fieldEditType_hm.put("toDate"+"_ismandatory", "1");
    workflow_nodeform_fieldEditType_hm.put("toTime"+"_ismandatory", "1");
    workflow_nodeform_fieldEditType_hm.put("detail_resourceId"+"_ismandatory", "1");
    workflow_nodeform_fieldEditType_hm.put("detail_departmentId"+"_ismandatory", "1");
    workflow_nodeform_fieldEditType_hm.put("detail_fromDate"+"_ismandatory", "1");
    workflow_nodeform_fieldEditType_hm.put("detail_fromTime"+"_ismandatory", "1");
    workflow_nodeform_fieldEditType_hm.put("detail_toDate"+"_ismandatory", "1");
    workflow_nodeform_fieldEditType_hm.put("detail_toTime"+"_ismandatory", "1");
  }

  /**
   * 初始化排班的流程字段属性
   * @param workflow_nodeform_fieldEditType_hm
   */
  private void initFieldEditType5(HashMap<String,String> workflow_nodeform_fieldEditType_hm) {

    workflow_nodeform_fieldEditType_hm.put("resourceId"+"_isedit", "1");
    workflow_nodeform_fieldEditType_hm.put("scheduleResourceId"+"_isedit", "1");
    workflow_nodeform_fieldEditType_hm.put("fromDate"+"_isedit", "1");
    workflow_nodeform_fieldEditType_hm.put("toDate"+"_isedit", "1");
    workflow_nodeform_fieldEditType_hm.put("newShift"+"_isedit", "1");
    workflow_nodeform_fieldEditType_hm.put("detail_resourceId"+"_isedit", "1");
    workflow_nodeform_fieldEditType_hm.put("detail_scheduleResourceId"+"_isedit", "1");
    workflow_nodeform_fieldEditType_hm.put("detail_fromDate"+"_isedit", "1");
    workflow_nodeform_fieldEditType_hm.put("detail_toDate"+"_isedit", "1");
    workflow_nodeform_fieldEditType_hm.put("detail_newShift"+"_isedit", "1");

    workflow_nodeform_fieldEditType_hm.put("resourceId"+"_ismandatory", "1");
    workflow_nodeform_fieldEditType_hm.put("scheduleResourceId"+"_ismandatory", "1");
    workflow_nodeform_fieldEditType_hm.put("fromDate"+"_ismandatory", "1");
    workflow_nodeform_fieldEditType_hm.put("toDate"+"_ismandatory", "1");
    workflow_nodeform_fieldEditType_hm.put("newShift"+"_ismandatory", "1");
    workflow_nodeform_fieldEditType_hm.put("detail_resourceId"+"_ismandatory", "1");
    workflow_nodeform_fieldEditType_hm.put("detail_scheduleResourceId"+"_ismandatory", "1");
    workflow_nodeform_fieldEditType_hm.put("detail_fromDate"+"_ismandatory", "1");
    workflow_nodeform_fieldEditType_hm.put("detail_toDate"+"_ismandatory", "1");
    workflow_nodeform_fieldEditType_hm.put("detail_newShift"+"_ismandatory", "1");

  }

  /**
   * 初始化销假的流程字段属性
   * @param workflow_nodeform_fieldEditType_hm
   */
  private void initFieldEditType6(HashMap<String,String> workflow_nodeform_fieldEditType_hm) {

    workflow_nodeform_fieldEditType_hm.put("resourceId"+"_isedit", "1");
    workflow_nodeform_fieldEditType_hm.put("leaverequestid"+"_isedit", "1");
    workflow_nodeform_fieldEditType_hm.put("detail_leavefromDate"+"_isedit", "1");
    workflow_nodeform_fieldEditType_hm.put("detail_leavefromTime"+"_isedit", "1");
    workflow_nodeform_fieldEditType_hm.put("detail_leavetoDate"+"_isedit", "1");
    workflow_nodeform_fieldEditType_hm.put("detail_leavetoTime"+"_isedit", "1");
    workflow_nodeform_fieldEditType_hm.put("detail_newLeaveType"+"_isedit", "1");
    workflow_nodeform_fieldEditType_hm.put("detail_leaveduration"+"_isedit", "1");
    workflow_nodeform_fieldEditType_hm.put("detail_fromDate"+"_isedit", "1");
    workflow_nodeform_fieldEditType_hm.put("detail_fromTime"+"_isedit", "1");
    workflow_nodeform_fieldEditType_hm.put("detail_toDate"+"_isedit", "1");
    workflow_nodeform_fieldEditType_hm.put("detail_toTime"+"_isedit", "1");
    workflow_nodeform_fieldEditType_hm.put("detail_duration"+"_isedit", "1");

    workflow_nodeform_fieldEditType_hm.put("resourceId"+"_ismandatory", "1");
    workflow_nodeform_fieldEditType_hm.put("leaverequestid"+"_ismandatory", "1");
    workflow_nodeform_fieldEditType_hm.put("detail_leavefromDate"+"_ismandatory", "1");
    workflow_nodeform_fieldEditType_hm.put("detail_leavefromTime"+"_ismandatory", "1");
    workflow_nodeform_fieldEditType_hm.put("detail_leavetoDate"+"_ismandatory", "1");
    workflow_nodeform_fieldEditType_hm.put("detail_leavetoTime"+"_ismandatory", "1");
    workflow_nodeform_fieldEditType_hm.put("detail_newLeaveType"+"_ismandatory", "1");
    workflow_nodeform_fieldEditType_hm.put("detail_leaveduration"+"_ismandatory", "1");
    workflow_nodeform_fieldEditType_hm.put("detail_fromDate"+"_ismandatory", "1");
    workflow_nodeform_fieldEditType_hm.put("detail_fromTime"+"_ismandatory", "1");
    workflow_nodeform_fieldEditType_hm.put("detail_toDate"+"_ismandatory", "1");
    workflow_nodeform_fieldEditType_hm.put("detail_toTime"+"_ismandatory", "1");
    workflow_nodeform_fieldEditType_hm.put("detail_duration"+"_ismandatory", "1");

  }

  public void InitSet(int formid,String wfType,String wfname,Map<String,Object> wfMap,String usedetail) throws Exception{

    long id = 0L;
    //初始化考勤流程基本信息
    id = initBaseSet(formid,wfType,wfname,wfMap,usedetail);
    logAutoInit("insert into kq_autoinit_log(wftype,inittype,initids,initcolumn) values("+wfType+",'kq_att_proc_set',"+id+",'id')");

    //初始化考勤流程字段对应
    initWfFields(id,formid,wfType,wfname,wfMap,usedetail);
    logAutoInit("insert into kq_autoinit_log(wftype,inittype,initids,initcolumn) values("+wfType+",'kq_att_proc_relation',"+id+",'field001')");
    //初始化考勤流程动作设置
    initAction(id,formid,wfType,wfname,wfMap);
    logAutoInit("insert into kq_autoinit_log(wftype,inittype,initids,initcolumn) values("+wfType+",'kq_att_proc_action',"+id+",'field001')");
  }

  /**
   * 初始化考勤流程基本信息
   * @param formid
   * @param wfType
   * @param wfname
   */
  public long initBaseSet(int formid,String wfType,String wfname,Map<String,Object> wfMap,String usedetail) throws Exception{

    long id = 0l;
    int wfid = (int)wfMap.get("wfid");
    ManageDetachComInfo manageDetachComInfo = new ManageDetachComInfo();
    HrmAttProcSetManager attProcSetManager = new HrmAttProcSetManager();

    int subcompanyid = -1;
    //获取分权分部。如果页面没有，则首先从分权设置的默认机构取得，如果默认机构没有设置则取所有分部中id最小的那个分部。
    subcompanyid = Util.getIntValue(manageDetachComInfo.getWfdftsubcomid(), -1);

    HrmAttProcSet bean = new HrmAttProcSet(true);
    bean.setField001(wfid);
    bean.setField002(formid);
    bean.setField003(0);
    bean.setField004(subcompanyid);
    bean.setField005(1);
    bean.setField006(Util.getIntValue(wfType));
    bean.setField007(0);
    bean.setField008(TimeUtil.getCurrentDateString());
    bean.setField009(TimeUtil.getCurrentDateString());
    bean.setUsedetail(Util.getIntValue(usedetail,0));
    String custompage = "";
    String custompage4Emoble = "";
    String templetroute = "";
    switch (bean.getField006()){
      case 0 :
        custompage = KqTempletEnum.LEAVE.getTempletfile();
        custompage4Emoble = KqTempletEnum.LEAVE.getTempletmobilefile();
        templetroute = KqTempletEnum.LEAVE.getTempletroute();
        break;
      case 1 :
        custompage = KqTempletEnum.EVECTION.getTempletfile();
        custompage4Emoble = KqTempletEnum.EVECTION.getTempletmobilefile();
        templetroute = KqTempletEnum.EVECTION.getTempletroute();
        break;
      case 2 :
        custompage = KqTempletEnum.OUT.getTempletfile();
        custompage4Emoble = KqTempletEnum.OUT.getTempletmobilefile();
        templetroute = KqTempletEnum.OUT.getTempletroute();
        break;
      case 3 :
        custompage = KqTempletEnum.OVERTIME.getTempletfile();
        custompage4Emoble = KqTempletEnum.OVERTIME.getTempletmobilefile();
        templetroute = KqTempletEnum.OVERTIME.getTempletroute();
        break;
      case 4 :
        custompage = KqTempletEnum.OTHER.getTempletfile();
        custompage4Emoble = KqTempletEnum.OTHER.getTempletmobilefile();
        templetroute = KqTempletEnum.OTHER.getTempletroute();
        break;
      case 5 :
        custompage = KqTempletEnum.SHIFT.getTempletfile();
        custompage4Emoble = KqTempletEnum.SHIFT.getTempletmobilefile();
        templetroute = KqTempletEnum.SHIFT.getTempletroute();
        break;
      case 6 :
        custompage = KqTempletEnum.LEAVEBACK.getTempletfile();
        custompage4Emoble = KqTempletEnum.LEAVEBACK.getTempletmobilefile();
        templetroute = KqTempletEnum.LEAVEBACK.getTempletroute();
        break;
      case 7 :
        custompage = KqTempletEnum.Card.getTempletfile();
        custompage4Emoble = KqTempletEnum.Card.getTempletmobilefile();
        templetroute = KqTempletEnum.Card.getTempletroute();
        break;
      case 8 :
        custompage = KqTempletEnum.PROCESSCHANGE.getTempletfile();
        custompage4Emoble = KqTempletEnum.PROCESSCHANGE.getTempletmobilefile();
        templetroute = KqTempletEnum.PROCESSCHANGE.getTempletroute();
        break;
      default:
        break;
    }
    bean.setTempletfile(custompage);
    bean.setTempletmobilefile(custompage4Emoble);
    bean.setTempletroute(templetroute);
    String tablename = "formtable_main_"+Math.abs(formid);
    bean.setTablename(tablename);
    if("1".equalsIgnoreCase(usedetail)){
      String detailname = tablename+"_dt1";
      bean.setDetailtablename(detailname);
    }
    id = attProcSetManager.save(bean);
    attProcSetManager.welcomeToSet(wfid, Util.getIntValue(wfType));

    return id;
  }

  /**
   * 初始化考勤流程字段对应
   * @param id
   * @param formid
   * @param wfType
   * @param wfname
   */
  public void initWfFields(long id,int formid,String wfType,String wfname,Map<String,Object> wfMap,String usedetail)  throws Exception{

    if (id > 0) {
      RecordSet rs = new RecordSet();
      RecordSet rs1 = new RecordSet();
      RecordSet rs2 = new RecordSet();
      HrmAttProcRelationManager attProcRelationManager = new HrmAttProcRelationManager();

//    考勤流程数据库字段对应    180表示请假，181表示出差，182表示公出，45表示加班，0表示异常，5表示排班，6表示销假
      String fieldType = "";
      switch (wfType){
        case "0" :
          fieldType = "180";
          break;
        case "1" :
          fieldType = "181";
          break;
        case "2" :
          fieldType = "182";
          break;
        case "3" :
          fieldType = "45";
          break;
        case "4" :
          fieldType = "0";
          break;
        case "5" :
          fieldType = "5";
          break;
        case "6" :
          fieldType = "6";
          break;
        case "7" :
          fieldType = "7";
          break;
        case "8" :
          fieldType = "8";
          break;
        default:
          break;
      }

      String wfFiledsSql = "select * from kq_att_proc_fields where field001="+fieldType;
      String wfBillFieldSql = "select * from workflow_billfield where billid="+formid+" and viewtype= 0";
      String wfBillFieldDetailSql = "select * from workflow_billfield where billid="+formid+" and viewtype= 1";

      Map<String,Object> wfBillFieldMap = new HashMap<>();
      Map<String,Object> wfBillFieldDetailMap = new HashMap<>();

      rs.execute(wfBillFieldSql);
      while(rs.next()){
        wfBillFieldMap.put(rs.getString("fieldname"), rs.getString("id"));
      }

      rs1.execute(wfBillFieldDetailSql);
      while(rs1.next()){
        wfBillFieldDetailMap.put(rs1.getString("fieldname"), rs1.getString("id"));
      }

      rs2.execute(wfFiledsSql);
      while(rs2.next()){
        String fid = rs2.getString("id");
        String fieldname = rs2.getString("field002");
        HrmAttProcRelation bean = new HrmAttProcRelation();
        bean.setField001((int)id);
        bean.setField002(Util.getIntValue(fid));
        if(fieldType.equalsIgnoreCase("5") || fieldType.equalsIgnoreCase("6") || fieldType.equalsIgnoreCase("7") || fieldType.equalsIgnoreCase("8")){
          if(fieldname.startsWith("detail_")){
            bean.setField003(Util.getIntValue(Util.null2String(wfBillFieldDetailMap.get(fieldname)), 0));//因为是自己去创建的，已经规定数据库里workflow_billfield的字段名和hrm_att_proc_fields里的字段名是一致的
          }else{
            bean.setField003(Util.getIntValue(Util.null2String(wfBillFieldMap.get(fieldname)), 0));//因为是自己去创建的，已经规定数据库里workflow_billfield的字段名和hrm_att_proc_fields里的字段名是一致的
          }
        }else{
          if("1".equalsIgnoreCase(usedetail)){
            if(fieldname.startsWith("detail_")){
              bean.setField003(Util.getIntValue(Util.null2String(wfBillFieldDetailMap.get(fieldname)), 0));//因为是自己去创建的，已经规定数据库里workflow_billfield的字段名和hrm_att_proc_fields里的字段名是一致的
            }else{
              continue;
            }
          }else{
            if(!fieldname.startsWith("detail_")){
              bean.setField003(Util.getIntValue(Util.null2String(wfBillFieldMap.get(fieldname)), 0));//因为是自己去创建的，已经规定数据库里workflow_billfield的字段名和hrm_att_proc_fields里的字段名是一致的
            }else{
              continue;
            }
          }
        }

        bean.setField004(fieldname);
        attProcRelationManager.insert(bean);
      }
    }else {
      return ;
    }

  }

  /**
   * 初始化考勤流程动作设置
   * @param id
   * @param formid
   * @param wfType
   * @param wfname
   */
  public void initAction(long id,int formid,String wfType,String wfname,Map<String,Object> wfMap)  throws Exception{

    // action名称，labelname，不知道默认0，节点类型，退回时不触发，顺序
    String[][] actions = null;
    //请假 需要 配置action
    if("0".equals(wfType)){
      actions = new String[][]{{"KqReleaseVacationAction","82824"},{"KqFreezeVacationAction","1232"},{"KqDeductionVacationAction","82823"},{"KqSplitAction","81543"}};
      doInitAction(wfType,actions,id,wfMap);
    }else if("3".equals(wfType)){
      actions = new String[][]{{"KqPaidLeaveAction","126739"},{"KqSplitAction","81543"}};
      doInitAction(wfType,actions,id,wfMap);
    }else{
      actions = new String[][]{{"KqSplitAction","81543"}};
      doInitAction(wfType,actions,id,wfMap);
    }
  }

  /**
   * 考勤流程action保存
   * @param wfType
   * @param actions
   * @param id
   * @param wfMap
   */
  private void doInitAction(String wfType,String[][] actions,long id,Map<String,Object> wfMap){

    if(actions == null) {
      return;
    }

    HrmAttProcActionManagerE9 hrmAttProcActionManagerE9 = new HrmAttProcActionManagerE9();
    WorkflowActionManager workflowActionManager = new WorkflowActionManager();
    // [0] 创建 [1] 审批 [2] 归档
    String[] _workflow_nodeId_array = (String[])wfMap.get("_workflow_nodeId_array");
    int wfid = (int)wfMap.get("wfid");

    for(int i = 0; i < actions.length ; i ++){
      int preoperator = 0;
      String[] actionA = actions[i];
      HrmAttProcAction bean = new HrmAttProcAction();
      String actioname = actionA[0];
      bean.setField001(id);
      bean.setField002(actioname);
      bean.setField003(actionA[1]);
      bean.setField004(0);
      String nodeId = "";
//        setField005  0出口附加规则，1节点后附加操作，2节点前附加操作
      if(actioname.equalsIgnoreCase("KqSplitAction") ||
          actioname.equalsIgnoreCase("KqDeductionVacationAction") ||
          actioname.equalsIgnoreCase("KqPaidLeaveAction")){
        //归档节点前
        nodeId = _workflow_nodeId_array[2];
        bean.setField005(2);
        bean.setField006(nodeId);
      }
      if(actioname.equalsIgnoreCase("KqFreezeVacationAction")){
        //创建节点后
        nodeId = _workflow_nodeId_array[0];
        bean.setField005(1);
        bean.setField006(nodeId);
      }
      if(actioname.equalsIgnoreCase("KqReleaseVacationAction")){
        //创建节点前
        nodeId = _workflow_nodeId_array[0];
        bean.setField005(2);
        bean.setField006(nodeId);
      }
      bean.setField007(0);
      bean.setField008(1);
      hrmAttProcActionManagerE9.insert(bean);

      if(bean.getField005() == 2){
        preoperator = 1;
      }

      String field003Name = SystemEnv.getHtmlLabelNames(bean.getField003(),7);
      workflowActionManager.setActionid(0);
      workflowActionManager.setActionname(field003Name);
      workflowActionManager.setWorkflowid(wfid);
      workflowActionManager.setNodeid(StringUtil.parseToInt(nodeId));
      workflowActionManager.setNodelinkid(0);
      workflowActionManager.setIspreoperator(preoperator);
      workflowActionManager.setActionorder(1);
      workflowActionManager.setInterfaceid(bean.getField002());
      workflowActionManager.setInterfacetype(3);
      workflowActionManager.setIsused(1);
      workflowActionManager.doSaveWsAction();
      logAutoInit("insert into kq_autoinit_log(wftype,inittype,initids,initcolumn) values("+wfType+",'workflowactionset',"+wfid+",'workflowid')");
    }
  }


  /**
   * 表单名称同名验证
   */
  public boolean homonymyCheck(String wfname){
    RecordSet rs = new RecordSet();

    boolean issamename = false;
    rs.executeSql("select namelabel from workflow_bill");
    while(rs.next()){//新表单名和单据名
      int namelabel = Util
          .getIntValue(Util.null2String(rs.getString("namelabel")),0);
      if(namelabel!=0){
        if(wfname.equals(SystemEnv.getHtmlLabelName(namelabel,user.getLanguage()))){
          issamename = true;
          break;
        }
      }
    }
    if(!issamename){
      rs.executeSql("select 1 from workflow_formbase where formname = '"+ StringEscapeUtils
          .escapeSql(wfname)+"'");
      if(rs.next()){//旧表单名
        issamename = true;
      }
    }
    return issamename;
  }

  public User getUser() {
    return user;
  }

  public void setUser(User user) {
    this.user = user;
  }

  public void cleanAutoInit(String wfType){
    RecordSet rs = new RecordSet();
    RecordSet rs1 = new RecordSet();
    String clearSql = "select inittype,initids,initcolumn from kq_autoinit_log where wftype=? group by inittype,initids,initcolumn";
    rs.executeQuery(clearSql,wfType);

    while (rs.next()){
      String inittype = rs.getString("inittype");
      String initids = rs.getString("initids");
      String initcolumn = rs.getString("initcolumn");

      //如果是表结构。需要drop
      if("formtable_main".equalsIgnoreCase(inittype)){
        String dropTableSql = "drop table "+initids;
        rs1.executeSql(dropTableSql);
      }else if("sequence".equalsIgnoreCase(inittype)){
        String dropSequenceSql = "drop sequence "+initids;
        rs1.executeSql(dropSequenceSql);
      }else {
        String deleteTableSql = "delete from "+inittype+" where "+initcolumn+" in ("+initids+")";
        rs1.executeSql(deleteTableSql);
      }
    }

    cleanSelf(wfType);
  }

  /**
   * 清除日志表
   */
  private void cleanSelf(String wfType) {
    RecordSet rs = new RecordSet();
    String cleanSql = "delete from kq_autoinit_log where wftype=? ";
    rs.executeUpdate(cleanSql,wfType);
  }
  /**
   * 把初始化的表单和流程数据清除
   */
  public void cleanAutoInit(){
    RecordSet rs = new RecordSet();
    RecordSet rs1 = new RecordSet();
    String clearSql = "select inittype,initids,initcolumn from kq_autoinit_log group by inittype,initids,initcolumn";
    rs.executeSql(clearSql);

    while (rs.next()){
      String inittype = rs.getString("inittype");
      String initids = rs.getString("initids");
      String initcolumn = rs.getString("initcolumn");

      //如果是表结构。需要drop
      if("formtable_main".equalsIgnoreCase(inittype)){
        String dropTableSql = "drop table "+initids;
        rs1.executeSql(dropTableSql);
      }else if("sequence".equalsIgnoreCase(inittype)){
        String dropSequenceSql = "drop sequence "+initids;
        rs1.executeSql(dropSequenceSql);
      }else {
        String deleteTableSql = "delete from "+inittype+" where "+initcolumn+" in ("+initids+")";
        rs1.executeSql(deleteTableSql);
      }
    }

    cleanSelf();
  }
  /**
   * 清除日志表
   */
  private void cleanSelf() {
    RecordSet rs = new RecordSet();
    String cleanSql = "delete from kq_autoinit_log";
    rs.execute(cleanSql);
  }

  /**
   * 记录考勤流程相关的数据以便以后删除
   * @param logInfo
   */
  private void logAutoInit(String logInfo){
    if(this.log){
      RecordSet rs = new RecordSet();
      rs.executeSql(logInfo);
    }
  }

  public boolean isLog() {
    return log;
  }

  public void setLog(boolean log) {
    this.log = log;
  }

  public boolean isIsdetail() {
    return isdetail;
  }

  public void setIsdetail(boolean isdetail) {
    this.isdetail = isdetail;
  }
}
