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

📄 remoteindyserver.java~3~

📁 大量java源程序
💻 JAVA~3~
📖 第 1 页 / 共 2 页
字号:
           boolean isinsert=false;
           for(int i=0;i<rec.size();i++)
             {  String tid=((record)rec.get(i)).taskID;
                boolean compare=false;
                 if(a.compareTo(tid)==0)
                 {  compare=true;
                 }
              if(compare)
                 {isinsert=true;
                   locate=i;
                   break ;
                 }
             }
             if(isinsert)
             {  (((record)rec.get(locate)).nextID).add(b);
                (((record)rec.get(locate)).rel).add(relation);
                 Integer lagge=new Integer(lag);
                (((record)rec.get(locate)).lag).add(lagge);

             }
              else
              {      record c=new record();
                     c.taskID=a;
                     c.nextID.add(b);
                     c.rel.add(relation);
                    Integer lagge=new Integer(lag);
                     c.lag.add(lagge);
                     c.indu=indu;
                     rec.add(c);
                }
          }
           rs.close();
           String query2="update toop set isnew=false where taskID in"+
           "(select taskID from toop where indu=newdu and isnew=true)";
           stmt.executeUpdate(query2);
       }catch(Exception ex)
        {  ex.printStackTrace();
        }
        finally {
        try {
          // Always close properly

          if (stmt != null) {
            stmt.close();
          }
          if (con != null) {
            // Put the connection back into the pool
              con.close();
          }
          if(rs!=null)
          {//rs.close();
          }
        }
        catch (Exception ex) {
          // Ignore any errors here
              ex.printStackTrace();
                              }
            }
       record copy[]=new record[rec.size()];
       for(int i=0;i<rec.size();i++)
       { copy[i]=(record)rec.get(i); }
       re=copy;
       return re;
   }

 ////////////////////////////////////////////////////////////////
 private void insert(record[] re)
 {   for(int i=0;i<re.length;i++)
     { array.add(re[i]);
     }
 }
////////////////////////////////////////////////////////////////
 private void delete(List nextid)
 {     Connection con=null;//联结对象
       ResultSet rs=null;  //纪录集对象
       PreparedStatement stmt = null;
  try{//连接数据库
         Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
         con=DriverManager.getConnection("jdbc:odbc:MyAccessDataSource1");
          String[] nid=new String[nextid.size()];
         for(int i=0;i<nextid.size();i++)
         { nid[i]=(String)(nextid.get(i));
         }

     try {
     String query="update toop set newdu=newdu+1 "+"where taskID=?";
         stmt = con.prepareStatement(query );
         for(int i=0;i<nid.length;i++)
          {  stmt.setString(1,nid[i]);
             stmt.executeUpdate();
           }
            }
      catch (SQLException ex) {
              ex.printStackTrace();
                              }
       }
       catch(Exception ex)
          {  ex.printStackTrace();
          }
    finally {
        try {
          // Always close properly
          if (stmt != null) {
            stmt.close();
          }
          if (con != null) {
            // Put the connection back into the pool
              con.close();
          }
        }
        catch (Exception ex) {
          // Ignore any errors here
                 ex.printStackTrace();
                            }
      }
   }
 /////////////////////////////////////////////////////////////////
  private void  schedul(List list)
    {  Connection con=null;//联结对象
       PreparedStatement stmt = null;
       ResultSet rs=null;  //纪录集对象
       record wleeyou=new record();
   try{//连接数据库
         Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
         con=DriverManager.getConnection("jdbc:odbc:MyAccessDataSource1");
         Date es=Date.valueOf("2001-01-01");
         Date ef=Date.valueOf("2001-01-01");
         Date nextes=Date.valueOf("2001-01-01");
         boolean ismodify;
         int gongqi=1 ;
         while(list.size()!=0)
         {  wleeyou=(record)list.get(0);
            list.remove(0);
              try {
 String query="select sgongqi,es,ef from wang where taskID=?";
         stmt = con.prepareStatement(query );
         stmt.setString(1,wleeyou.taskID);
         rs=stmt.executeQuery()   ;
         rs.next();
         es=rs.getDate("es");
         ef=rs.getDate("ef");
         gongqi=rs.getInt("sgongqi");
         rs.close();
            }
      catch (SQLException ex) {
              ex.printStackTrace();
                              }
         if(wleeyou.indu!=0)
         {//indu not equal 0
           ef=CalenCompute(es,gongqi);
     String updatees="update wang set ef=? where taskID=? ";
      stmt = con.prepareStatement(updatees);
                  stmt.setDate(1,ef);
                  stmt.setString(2,wleeyou.taskID);
                  stmt.executeUpdate();
         }
         nextes=CalenCompute(ef,1);
         if((wleeyou.nextID).size()!=0)
           {//根据后续代码取出:already,es
              for(int i=0;i<(wleeyou.nextID).size();i++)
              {   String next="select already,es from wang where taskID=?";
                  stmt = con.prepareStatement(next);
                  String nextide= (String)(wleeyou.nextID).get(i);
                  stmt.setString(1,nextide);
                  rs=stmt.executeQuery();
             if( rs.next())
              {       ismodify=rs.getBoolean("already");
                    Date nes=Date.valueOf("2001-01-01");
                    nes=rs.getDate("es");
                    Integer lag=(Integer)wleeyou.lag.get(i);
                   int lagge=lag.intValue();
                    rs.close();
                    Date newes=CalenCompute(nextes,lagge);
                  if(!ismodify)
                   { //has modifide and need compare nes to nextes
                    if (newes.after(nes))
                    {String writeback="update wang set es=? where taskID=?";
                  stmt = con.prepareStatement(writeback);
                  stmt.setDate(1,newes);
                  stmt.setString(2,nextide);
                  stmt.executeUpdate();
                    }

                   }
                   else
                   {//将算出的开工日期写回数据库并设already为false
String writeback1="update wang set es=?,already=? where taskID=?";
   stmt = con.prepareStatement(writeback1);
                  stmt.setDate(1,newes);
                  stmt.setBoolean(2,false);
                  stmt.setString(3,nextide);
                  stmt.executeUpdate();
                   }
          //if end
           }
              }
           }

         }

 String setall="update wang set already=true";
     stmt=con.prepareStatement(setall);
     stmt.executeUpdate();

    }catch(Exception ex)
    {  ex.printStackTrace();
    }
    finally {
        try {
          // Always close properly

          if (stmt != null) {
            stmt.close();
          }
          if (con != null) {
            // Put the connection back into the pool
              con.close();
          }
        }
        catch (Exception ex) {
            ex.printStackTrace();
                             }
        }

    }


 //////////////////////////////////////////////////////////////////
    public java.sql.Date CalenCompute(java.sql.Date date,int add)
  {java.util.Calendar d=java.util.Calendar.getInstance();
   java.util.Date dat=Date.valueOf(date.toString());
   d.setTime(dat);
   d.add(java.util.Calendar.DATE,add);
   int year=d.get(d.YEAR);
   int month=d.get(d.MONTH)+1;
   int day=d.get(d.DATE);
   String time=String.valueOf(year)+"-"+String.valueOf(month)
   +"-"+String.valueOf(day);
   java.sql.Date sqldate=Date.valueOf(time);
   return sqldate;
  }

}

⌨️ 快捷键说明

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