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

📄 unt_project.pas

📁 煤矿行业采掘接替计划自动生成系统
💻 PAS
📖 第 1 页 / 共 4 页
字号:
          append;
          FieldByName('SGD_Id').AsInteger:=Worker[i].SGD_Id;
          FieldByname('SGDT_N').AsString:=Worker[i].SGDT_Name;
          FieldByName('SGD_Name').AsString:=Worker[i].SGD_Name;
          
          FieldByName('Shaft_Id').AsInteger:=1;
          post;
        end;
    end;
  //读取“回采接替f”表中的数据
  with Data_Frm.MineRelay_AdoTab do
    begin
      if not active then open;
      setlength(MPro,recordcount+1);
      first;
      i:=1;
      while not eof do
        begin
          MPro[i].f_Sequence:=FieldByName('Sequence').AsInteger;
          MPro[i].f_FaceId:=FieldByName('Face_Lane').AsInteger;
          MPro[i].f_AreaId:=FieldByName('Area').AsInteger;
          MPro[i].WorkGroup_Id:=FieldByName('WorkGroup').AsInteger;
          MPro[i].B_Date:=FieldByName('Begin_Date').AsDateTime;
          MPro[i].E_Date:=FieldByName('End_Date').AsDateTime;
          MPro[i].WorkDay:=FieldByName('TaskTime').AsInteger;
          MPro[i].DrillTaskCount:=0;
          MPro[i].Task_Id:=-1;
          MPro[i].Task_Name:='';
          MPro[i].TaskT_Id:=-1;
          MPro[i].TaskT_Name:='';
          next;
          i:=i+1;
        end;

    end;
  with Data_Frm.Face_AdoTab do //确定MPro数组中的回采面名称及其回采工艺,从现在数据库中的“回采面f”表
    begin
      if not active then open;
      first;
      while not eof do
        begin
          for i:=1 to High(MPro) do
            begin
              if MPro[i].f_FaceId=FieldByName('Face_Id').AsInteger then
                begin
                  MPro[i].f_FaceName:=FieldByName('Name').AsString;
                  MPro[i].TechnicType_Id:=FieldByName('Technic_Type').AsInteger;
                  MPro[i].Dis:=FieldByName('Push_Length').AsInteger-FieldByName('Finish_Length').AsInteger;
                  MPro[i].TaskT_Id:=5;//采区工序名称表中的回采对应的工序类型编号为5
                  MPro[i].TaskT_Name:=DrillT[MPro[i].TaskT_Id].DrillT;
                  break;
                end;
            end;
          next;
        end;
    end;
  with Data_frm.MineTech_AdoTab do //确定回采工艺名称:1:炮采;2:普采;3:综采;4:综放,从现在数据库中的“回采工艺f”表
    begin
      if not active then open;
      first;
      while not eof do
        begin
          for i:=1 to High(MPro) do
            begin
              if MPro[i].TechnicType_Id=FieldByName('MineType_Id').AsInteger then
                begin
                  MPro[i].TechnicType_Name:=FieldByName('Mine_TypeName').AsString;
                  //break;
                end;
            end;
          next;
        end;
    end;
  with Data_Frm.Area_AdoTab do  //确定MPro数组中的现有数据库中的采区编号及名称
    begin
      if not active then open;
      first;
      while not eof do
        begin
          for i:=1 to High(MPro) do
            begin
              if MPro[i].f_AreaId=FieldByName('Area_Id').AsInteger then
                begin
                  MPro[i].f_AreaName:=FieldByName('Area_Name').AsString;
                  //break;
                end;
            end;
          next;
        end;
    end;
  with Frm_Data.ADOT_Area do    //确定原数据库中的采区编号及名称
    begin
      if not active then open;
      first;
      str:='';
      while not eof do
        begin
          str:=FieldByName('Area_Name').AsString;
          for i:=1 to High(MPro) do
            begin
              if MPro[i].f_AreaName=str then
                begin
                  MPro[i].Area_Name:=str;//要保证CAD图中的采区名称要与通过界面输入确定的采区名称相同
                  MPro[i].Area_Id:=FieldByName('Area_Id').AsInteger;
                end;
            end;
          next;
        end;
    end;
  with Data_Frm.Worker_AdoTab do  //确定MPro数组中的采煤队名称
    begin
      if not active then open;
      first;
      while not eof do
        begin
          for i:=1 to High(MPro) do
            begin
              if MPro[i].WorkGroup_Id=FieldByName('WorkGroup_Id').AsInteger then
                begin
                  MPro[i].WorkGroup_Name:=FieldByName('WorkGroup_Name').AsString;
                  //break;
                end;
            end;
          next;
        end;
    end;

  //确定接替回采面在原数据库中的“工序”表中的对应的Task_Id号,
  //以通过Task_Id建立与“巷道回采面子表”的连接,
  //也就是与CAD图纸中的坐标建立联系,由于从CAD图形中得到的原“工序”表中的
  //回采面可能少于从界面输入得到的回采面,所以MPro数组中有一些元素的值在
  //“工序”表中找不到。
  str:='';
  for i:=1 to High(MPro) do
    begin
      str:=MPro[i].f_FaceName;
      str:=str+'回采';
      for j:=1 to High(DynTask) do
        begin
          if DynTask[j].Task_Name=str then
            begin
              MPro[i].Task_Id:=DynTask[j].Task_Id;
              MPro[i].Task_Name:=DynTask[j].Task_Name;
              break;
            end;
        end;
    end;

  //-----------------------------test--------------------

   //for i:=1 to High(MPro) do
    // begin
      // showmessage(MPro[i].Task_Name);
     //end;
   //exit;
  //--------------------------test----------------------

  //确定每个接替回采面对应的掘进工序,主要依据原数据库中的“工序”表中
  //首先确定在“工序”表中每个回采工作面对应的掘进工序数目
  str:='';
  for i:=1 to High(MPro) do
    begin
      if MPro[i].Task_Id=-1 then continue;
      str:=MPro[i].f_FaceName;
      if str='' then continue;
      str11:=str+'风巷';
      str22:=str+'机巷';
      str33:=str+'开切眼';
      //str44:=str+'安装调试';
      str1:='';
      m:=0;
      for j:=1 to High(DynTask) do
        begin
          str1:=DynTask[j].Task_Name;
          if(str1=str11)or(str1=str22)or(str1=str33)then  //if (Pos(str,str1)>0)and(Pos('回采',str1)<=0) then
            begin
              m:=m+1;
            end;
        end;
      MPro[i].DrillTaskCount:=m;
      Setlength(MPro[i].DrillPro,MPro[i].DrillTaskCount+1);
    end;
  str:='';
  for i:=1 to High(MPro) do
    begin
      if MPro[i].Task_Id=-1 then continue;
      str:=MPro[i].f_FaceName;
      str11:=str+'风巷';
      str22:=str+'机巷';
      str33:=str+'开切眼';
      if str='' then continue;
      str1:='';
      t:=High(MPro[i].DrillPro); //标志回采面对应的掘进工序的序号,由于读取“工序”表中的记录时,是从后向前的,所以为了使得MPro[i].DrillPro数组中的数据顺序与“工序”表中的一致,所以t从最高序号(High(MPro[i].DrillPro))开始
      for j:=High(DynTask) downto 1 do
        begin
          str1:=DynTask[j].Task_Name;
          //if Pos(str,str1)<=0 then continue;
          //if Pos('回采',str1)>0 then continue;//排除回采工序
          if not((str1=str11)or(str1=str22)or(str1=str33)) then continue;
          MPro[i].DrillPro[t].Task_Id:=DynTask[j].Task_Id;
          MPro[i].DrillPro[t].Task_Name:=DynTask[j].Task_Name;
          MPro[i].DrillPro[t].TaskT_Id:=DynTask[j].TaskT_Id;
          MPro[i].DrillPro[t].Find:=false;
          t:=t-1;
        end;
    end;
  //确定掘进工序的工期和掘进长度,从现在数据库中的“巷道f”表
  with Data_Frm.Lane_AdoTab do
    begin
      if not active then open;
      first;
      str1:='';
      str_property:='';
      while not eof do
        begin
          str_property:=FieldByName('Property').AsString;
          str1:=FieldByName('Name').AsString;
          for i:=1 to High(MPro) do
            begin
              if MPro[i].Task_Id=-1 then continue;
              str:='';
              for j:=1 to High(MPro[i].DrillPro) do
                begin
                  str:=MPro[i].DrillPro[j].Task_Name;
                  if (str=str1)and(str_property='回采巷道')then
                    begin
                      MPro[i].DrillPro[j].Face_Lane:=FieldByName('Lane_Id').AsInteger;
                      MPro[i].DrillPro[j].WorkDay:=FieldByName('TaskTime').AsInteger;
                      MPro[i].DrillPro[j].Dis:=round(FieldByName('WorkQuantity').AsFloat);
                      break;
                    end;
                end;
            end;
          next;
        end;
    end;

  //确定掘进工序的掘进队编号及名称  (省略)
  


  //确定掘进工序的开、完工时间,从现在数据库中的“掘进接替f”表
  with Data_Frm.DrillRelay_AdoTab do
    begin
      if not active then open;
      first;
      //str1:='';
      //str_property:='';
      while not eof do
        begin
          //str_property:=FieldByName('Property').AsString;
          //str1:=FieldByName('Name').AsString;
          LaneId:=FieldByName('Face_Lane').AsInteger;
          for i:=1 to High(MPro) do
            begin
              if MPro[i].Task_Id=-1 then continue;
              //str:='';

              for j:=1 to High(MPro[i].DrillPro) do
                begin
                  //str:=MPro[i].DrillPro[j].Task_Name;
                  if MPro[i].DrillPro[j].Face_Lane=LaneId then //if (str=str1)and(str_property='回采巷道')then
                    begin
                      MPro[i].DrillPro[j].B_Date:=FieldByName('Begin_Date').AsDateTime;
                      MPro[i].DrillPro[j].E_Date:=FieldByName('End_Date').AsDateTime;
                      MPro[i].DrillPro[j].Find:=true;
                      break;
                    end;
                end;
            end;
          next;
        end;
    end;
  {//处理安装调试的开、完工时间
  for i:=1 to High(MPro) do
    begin
      if MPro[i].Task_Id=-1 then continue;
      for j:=1 to High(MPro[i].DrillPro) do
        begin
          if MPro[i].DrillPro[j].TaskT_Id=4 then //TaskT_Id=4代表工序是安装调试工序
            begin
              MPro[i].DrillPro[j].B_Date:=MPro[i].B_Date;
              MPro[i].DrillPro[j].E_Date:=MPro[i].B_Date;
              MPro[i].DrillPro[j].Find:=true;
              break;
            end;
        end;
    end; }


  //----------------------test
  {for i:=1 to High(MPro) do
    begin
      if MPro[i].Task_Id=-1 then continue;
      for j:=1 to High(MPro[i].DrillPro) do
        begin
          if not MPro[i].DrillPro[j].Find then
            begin
              showmessage('"'+MPro[i].DrillPro[j].Task_Name+'" 的开、完工时间没有指定!');
            end;
        end;
    end;
  exit; }


  //--------------------------test



  {//为了简化动态演示,这里,MPro数组中的所有掘进工序的开、完工时间都根据掘进提前天数来指定
  for i:=1 to High(MPro) do
    begin
      if MPro[i].Task_Id=-1 then continue;
      AheadDays:=0;
      for j:=1 to High(DrillAhead) do
        begin
          if DrillAhead[j].MineT_Id=MPro[i].TechnicType_Id then
            begin
              AheadDays:=DrillAhead[j].AheadDay;
              break;
            end;
        end;
      if AheadDays=0 then AheadDays:=30;//如果没有找到相应的提前天数,指定其为30天
      MPro[i].DrillPro[1].E_Date:=MPro[i].E_Date-AheadDays;
      MPro[i].DrillPro[1].B_Date:=MPro[i].DrillPro[1].E_Date-MPro[i].DrillPro[1].WorkDay;
      for j:=2 to High(MPro[i].DrillPro) do
        begin
          MPro[i].DrillPro[j].B_Date:=MPro[i].DrillPro[j-1].E_Date+1;//这里指定掘进队搬家转到另一个工作面的时间为1天
          MPro[i].DrillPro[j].E_Date:=MPro[i].DrillPro[j].B_Date+MPro[i].DrillPro[j].WorkDay;
        end;
    end; }

  //把CAD图纸处理出来的采掘工序相关的计划导入到原数据库中的“采掘计划”表中
  with Frm_Data.ADOT_MDPlan do
    begin
      if not active then open;
      if recordcount>0 then
        begin
          first;
          while not eof do
            begin
              delete;
            end;
        end;
      for i:=1 to High(MPro) do
        begin
          if MPro[i].Task_Id=-1 then continue;
          append;
          FieldByName('Area_Id').AsInteger:=MPro[i].Area_Id;
          FieldByName('Task_Id').AsInteger:=MPro[i].Task_Id;
          FieldByName('WorkDay').AsInteger:=MPro[i].WorkDay;
          FieldByName('B_Date').AsDateTime:=MPro[i].B_Date;
          FieldByName('E_Date').AsDateTime:=MPro[i].E_Date;
          //FieldByName('SGD_Id').AsInteger:=MPro[i].SGD_Id;
          FieldByName('Dis').AsFloat:=MPro[i].Dis;
          post;
          for j:=1 to High(MPro[i].DrillPro) do
            begin
              append;
              FieldByName('Area_Id').AsInteger:=MPro[i].Area_Id;
              FieldByName('Task_Id').AsInteger:=MPro[i].DrillPro[j].Task_Id;
              FieldByName('WorkDay').AsInteger:=MPro[i].DrillPro[j].WorkDay;
              FieldByName('B_Date').AsDateTime:=MPro[i].DrillPro[j].B_Date;
              FieldByName('E_Date').AsDateTime:=MPro[i].DrillPro[j].E_Date;
              FieldByName('Dis').AsFloat:=MPro[i].DrillPro[j].Dis;
              //--------------------------------------------------------
              //FieldByName('SGD_Id').AsInteger:=MPro[i].DrillPro[j]
              //-------------------------------------------------------
              post;
            end;
        end;
    end;
end;

function TFrm_Project.CalDis(p1, p2: TPoint2):single;
var
m:single;
begin
m:=sqrt(sqr(p1.x-p2.x)+sqr(p1.y-p2.y));
result:=m;
end;

end.

⌨️ 快捷键说明

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