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

📄 unt_project.pas

📁 煤矿行业采掘接替计划自动生成系统
💻 PAS
📖 第 1 页 / 共 4 页
字号:
unit Unt_Project;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, Unt_CBase, StdCtrls, Buttons, ExtCtrls, Grids, DBCtrls, DB,
  ADODB;

type
  TDrillProject=record
    Task_Id:integer;
    Task_Name:string;
    TaskT_Id:integer;
    TaskT_Name:string;
    WorkDay:integer;
    Dis:integer;//掘进长度
    SGD_Id:integer;
    B_Date:TDate;
    E_Date:TDate;
    Face_Lane:integer;
    Find:boolean;
  end;
  TMineProject=record
    f_Sequence:integer;//f代表formal,表示现在数据库中的“回采接替f”表中的字段
    f_FaceId:integer;
    f_FaceName:string;
    f_AreaId:integer;
    f_AreaName:string;
    
    Area_Id:integer;
    Area_Name:string;
    Task_Id:integer;
    Task_Name:string;
    TaskT_Id:integer;
    TaskT_Name:string;
    WorkGroup_Id:integer;
    WorkGroup_Name:string;
    TechnicType_Id:integer;
    TechnicType_Name:string;
    Dis:integer;//回采面当前的推进长度
    WorkDay:integer;
    B_Date:TDate;
    E_Date:TDate;
    SGD_Id:integer;
    Q:single;
    DrillTaskCount:integer;
    DrillPro:array of TDrillProject;
  end;
  TTask=record
    Task_Id:integer;
    TaskT_Id:integer;
    Task_Name:string;
    //TaskT_Name:string;
  end;
  TArea=record
    Area_Id:integer;
    Area_Name:string;
  end;
  TDrillTaskType=record
    Id:integer;
    Name:string;
    DrillT:string;
  end;
  TWorker=record
    SGD_Id:integer;
    SGD_Name:string;
    SGDT_Name:string;
  end;
  TDrillAheadTime=record  //掘进提前天数,从“接替间隔f”表和“回采工艺f”表中读取相关信息
    MineT_Id:integer;
    MineT_Name:string;
    AheadDay:integer;
    FixPrepareDay:integer;
  end;
  TPoint2=record
    x:single;
    y:single;
    z:single;
  end;
  TFrm_Project = class(TFrm_CBase)
    Ds_Level: TDataSource;
    ADOQ_Other: TADOQuery;
    ADOQ_DSGD: TADOQuery;
    Ds_Other: TDataSource;
    Ds_Graph: TDataSource;
    ADOQ_MDPlan: TADOQuery;
    DS_MDPlan: TDataSource;
    GroupBox2: TGroupBox;
    RGP_ProMod: TRadioGroup;
    GroupBox4: TGroupBox;
    CbxYear: TComboBox;
    CbxQuarter: TComboBox;
    CbxMonth: TComboBox;
    RBtnY: TRadioButton;
    RBtnQ: TRadioButton;
    RBtnM: TRadioButton;
    RBtnA: TRadioButton;
    Panel1: TPanel;
    Btn_SimShow: TBitBtn;
    SGrid_MD: TStringGrid;
    Panel5: TPanel;
    Label1: TLabel;
    Label44: TLabel;
    Label36: TLabel;
    Btn_Con: TBitBtn;
    Btn_Add: TBitBtn;
    DBLookupComboBox1: TDBLookupComboBox;
    Btn_Del: TBitBtn;
    Edt_Int: TEdit;
    Tim_DyShow: TTimer;
    //procedure Cbx_SimSelClick(Sender: TObject);
    procedure RBtnYClick(Sender: TObject);
    procedure Btn_SimShowClick(Sender: TObject);
    //procedure BitBtn31Click(Sender: TObject);
    procedure DBLookupComboBox1Click(Sender: TObject);
    procedure Btn_AddClick(Sender: TObject);
    procedure Btn_DelClick(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure Tim_DyShowTimer(Sender: TObject);
    procedure Btn_ExitClick(Sender: TObject);
  private
    { Private declarations }
  public
    Is_DynS_Init:boolean;  //是否已经获取动态演示的数据
    SS_Date,ES_Date,NS_Date:TDatetime;
    MLayer,MLineT,MHindle:string;
    Mine_Dir1,Min_Dir2:Double;
    MPro:array of TMineProject; //用于存储依据现在数据库产生的采掘计划,以便以后导入到原数据库中的“采掘计划”表中
    DynTask:array of TTask;//从“工序”表中读取并暂存通过图形辨识所得到的工序信息
    Area:array of TArea;//从“采区”表中读取并暂存通过图形辨识所得到的采区信息
    Worker:array of TWorker;//从“施工队”表中读取并暂存原数据库系统的施工队信息
    DrillT:array of TDrillTaskType;//从“采区工序名称”表中读取并暂存原数据库系统施工队信息
    DrillAhead:array of TDrillAheadTime;//从“接替间隔f”表中读取,掘进完成的提前天数
    //以下变量是为计算CAD图形中的风巷、机巷、工作面及切眼的距离
    Task_Id1,TaskT_Id1:integer;
    WorkDay1:integer;
    HandleStr1,HandleStr2:string;
    Point1,Point2:TPoint2;
    P_Id1,P_Id2:integer;
    Dis1,GraphDis1,GraphDis2:single;
    UnitDis:single;
    function CalDis(p1,p2:TPoint2):single;
    procedure DynamicShowInit; //动态演示前新旧数据库的初始化准备工作
    { Public declarations }
  end;

var
  Frm_Project: TFrm_Project;

implementation
  Uses Unt_data,Unt_CAD_Pro_Tool,Unt_Simulate,Unt_ReadGra,Data_Unt;
{$R *.dfm}

{procedure TFrm_Project.Cbx_SimSelClick(Sender: TObject);
begin
  inherited;
  with ADOQ_Other,DBLK_SimSel do
  begin
    ListField:='';
    KeyField:='';
    if Cbx_SimSel.ItemIndex=0 then
    begin
      close;
      sql.Clear;
      sql.Add('select Level_Id,Level_name from 水平 ');
      ExecSQL;Open;
      ListField:='Level_name';
      KeyField:='Level_Id';
    end;
    if Cbx_SimSel.ItemIndex=1 then
    begin
      close;
      sql.Clear;
      sql.Add('select Area_Id,Area_Name from 采区 ');
      ExecSQL;Open;
      ListField:='Area_Name';
      KeyField:='Area_Id';
    end;
    if Cbx_SimSel.ItemIndex=2 then
    begin
      close;
      sql.Clear;
      sql.Add('select SGD_Id,SGD_Name ');
      sql.Add('from 施工队 ');
      sql.Add('where SGDT_N like '+''''+'%采煤%'+'''');
      ExecSQL;Open;
      ListField:='SGD_Name';
      KeyField:='SGD_Id';
    end;
    if Cbx_SimSel.ItemIndex=3 then
    begin
      close;
      sql.Clear;
      sql.Add('select SGD_Id,SGD_Name ');
      sql.Add('from 施工队 ');
      sql.Add('where (SGDT_N like '+''''+'%开拓%'+''''+')or(SGDT_N like '+''''+'%掘进%'+''''+') ');
      ExecSQL;Open;
      ListField:='SGD_Name';
      KeyField:='SGD_Id';
    end;
  end
end;}

procedure TFrm_Project.RBtnYClick(Sender: TObject);
begin
  inherited;
  CbxYear.Visible:=false;
  CbxQuarter.Visible:=false;
  CbxMonth.Visible:=false;
  if RBtnY.Checked then CbxYear.Visible:=true;
  if RBtnQ.Checked then
  begin
    CbxYear.Visible:=true;
    CbxQuarter.Visible:=true;
  end;
  if RBtnM.Checked then
  begin
    CbxYear.Visible:=true;
    CbxMonth.Visible:=true;
  end;
end;

procedure TFrm_Project.Btn_SimShowClick(Sender: TObject);
var S_Date1,E_Date1:TDateTime;
    yy,mm,Id,Days:integer;
begin
   //------------------------------------------------------------------
  //首先判断是否已经安排了采掘计划,
  //并且是否已经把所安排的采掘计划按照动态演示要求的数据格式写入数据表中
  //--------------------------------------------------------------------

  //动态演示前对新旧数据库中的数据进行统一协调
  DynamicShowInit;

  Is_DynS_Init:=false;
  {根据计划输出条件查找计划期内的接替情况}
  with SGrid_MD do
  begin
   colcount:=8;
   rowcount:=2;
   Cells[0,0]:='编号';           Cells[0,1]:=' ';
   Cells[1,0]:='工序';           Cells[1,1]:=' ';
   Cells[2,0]:='采区';           Cells[2,1]:=' ';
   Cells[3,0]:='总工期';         Cells[3,1]:=' ';
   Cells[4,0]:='开工时间';       Cells[4,1]:=' ';
   Cells[5,0]:='完工时间';       Cells[5,1]:=' ';
   //Cells[6,0]:='工作队';         Cells[6,1]:=' ';
   //Cells[7,0]:='本期推进距离';   Cells[7,1]:=' ';

   {//Cells[7,0]:='本期工资';       Cells[7,1]:=' ';
   //Cells[8,0]:='本期材料消耗';   Cells[8,1]:=' ';
   //Cells[9,0]:='本期电费';       Cells[9,1]:=' ';
   //Cells[10,0]:='本期设备费用';  Cells[10,1]:=' ';
   //Cells[11,0]:='本期产煤量';    Cells[11,1]:=' ';
   if (RBtnA.Checked)and(RGP_ProMod.ItemIndex=0)and(Cbx_SimSel.ItemIndex=-1)
   then begin
         colcount:=colcount+1;
         Cells[13,0]:='前置工序';Cells[13,1]:=' ';
        end;}

  end;
//找到采掘计划表中采掘任务最早开始的时间和最晚结束的时间,
//暂时先分别赋值给SS_Date和ES_Date,若用户要求演示总计划,那么演示时间的跨度
//就是在SS_Date到ES_Date之间。
  with ADOQ_MDPlan do
  begin
   close;
   sql.Clear;
   sql.Add('select Min(B_Date) as MinT,Max(E_Date) as MaxT from 采掘计划 ');
   ExecSQL;Open;
   SS_Date:=fieldbyname('MinT').AsDateTime-1;
   ES_Date:=fieldbyname('MaxT').AsDateTime+1;
  end;
  if RBtnY.Checked then //如果为年度
  begin
    SS_Date:=strtodate(CbxYear.Text+'-1-1');
    ES_Date:=strtodate(CbxYear.Text+'-12-31');
  end;
  if RBtnQ.Checked then //如果为季度
  begin
    mm:=strtoint(CbxQuarter.Text);
    SS_Date:=strtodate(CbxYear.Text+'-'+inttostr((mm-1)*3+1)+'-1');
    case mm of
     1,4:ES_Date:=strtodate(CbxYear.Text+'-'+inttostr(mm*3)+'-31');
     2,3:ES_Date:=strtodate(CbxYear.Text+'-'+inttostr(mm*3)+'-30');
    end;
  end;
  if RBtnM.Checked then //月度
  begin
   yy:=strtoint(CbxYear.Text);
   mm:=strtoint(CbxMonth.Text);
   SS_Date:=strtodate(CbxYear.Text+'-'+inttostr(mm)+'-1');
   ES_Date:=strtodate(CbxYear.Text+'-'+inttostr(mm)+'-'+inttostr(get_Year_days(yy,mm)));
  end;

  //得到符合条件的采掘计划
  with ADOQ_MDPlan do
  begin
    close;
    sql.Clear;
    sql.Add('select 采掘计划.Area_Id,采区.Area_Name,');
    sql.Add('工序.Task_Id,工序.TaskT_Id,采区工序名称.TaskT,采区工序名称.TaskN_Id,工序.Task_Name,采掘计划.WorkDay,采掘计划.B_Date,');
    sql.Add('采掘计划.E_Date,采掘计划.Dis');
    //sql.Add('采掘计划.Salary/采掘计划.Workday as SaV,采掘计划.Material/采掘计划.Workday as MaV,');
    //sql.Add('采掘计划.Electricity/采掘计划.Workday as ElV,采掘计划.Equipment/采掘计划.Workday as EqV,');
    //sql.Add('采掘计划.Q/采掘计划.Workday as QV,采掘计划.Dis/采掘计划.Workday as FiV ');
    sql.Add('from 采区,工序,采掘计划,采区工序名称 ');
    sql.Add('where (采区.Area_Id=采掘计划.Area_Id)and(工序.Task_Id=采掘计划.Task_Id)');
    //sql.Add('and(施工队.SGD_Id=采掘计划.SGD_Id)');
    sql.Add('and(工序.TaskT_Id=采区工序名称.TaskN_Id)');
      //工序水平
    if RGP_ProMod.ItemIndex=1 then //代表列出的是回采计划
      sql.Add('and(采掘计划.Task_Id in (select Task_Id from 工序 where 工序.TaskT_Id=5))');
    if RGP_ProMod.ItemIndex=2 then //代表列出的是掘进计划
      sql.Add('and(采掘计划.Task_Id in (select Task_Id from 工序 where (工序.TaskT_Id<4)and(工序.TaskT_Id>0)))');
    {if Cbx_SimSel.ItemIndex=0 then //水平
     sql.Add('and(采掘计划.Task_Id in (select Task_Id from 工序采区 where 工序采区.Level_Id=:r1))');//水平
    if Cbx_SimSel.ItemIndex=1 then sql.Add('and(采掘计划.Area_Id=:r2)'); //采区
    if (Cbx_SimSel.ItemIndex=2)or(Cbx_SimSel.ItemIndex=3)//采煤队和掘进队
     then sql.Add('and(采掘计划.SGD_Id=:r3)');}

    sql.Add('and(((采掘计划.B_Date>:v1)and(采掘计划.E_Date<:v2))');//本年开始结束生产
    sql.Add('or((采掘计划.B_Date<:v3)and(采掘计划.E_Date>:v4))');//本年前开始
    sql.Add('or((采掘计划.B_Date<:v5)and(采掘计划.E_Date>:v6)))');//本年后结束
    //sql.Add('order by IId ');  //有何用意?--使得先开始的工序排在表的前面

    {if Cbx_SimSel.ItemIndex=0 then
     parameters.ParamByName('r1').Value:=ADOQ_Other.fieldbyname('Level_Id').AsInteger;//水平
    if Cbx_SimSel.ItemIndex=1 then
     parameters.ParamByName('r2').Value:=ADOQ_Other.fieldbyname('Area_Id').AsInteger;//采区
    if (Cbx_SimSel.ItemIndex=2)or(Cbx_SimSel.ItemIndex=3) then
     parameters.ParamByName('r3').Value:=ADOQ_Other.fieldbyname('SGD_Id').AsInteger;//采掘队}

    parameters.ParamByName('v1').Value:=SS_Date;
    parameters.ParamByName('v2').Value:=ES_Date;
    parameters.ParamByName('v3').Value:=SS_Date;
    parameters.ParamByName('v4').Value:=SS_Date;
    parameters.ParamByName('v5').Value:=ES_Date;
    parameters.ParamByName('v6').Value:=ES_Date;
    ExecSQL;Open;
    //分别处理和显示符合条件的采掘任务
    for Id:=0 to recordcount-1 do //ADOQ_MDPlan
    begin
     S_Date1:=SS_Date;   E_Date1:=ES_Date; //S_Date1和E_Date1是为计算该任务的工期天数
     //如果该任务是在SS_Date时间以后开始的,则S_Date1赋值为该任务的开始时间
     if S_Date1<fieldbyname('B_Date').AsDateTime
      then S_Date1:=fieldbyname('B_Date').AsDateTime;
     //如果该任务是在ES_Date时间以前结束的,则E_Date1赋值为该任务的结束时间 
     if E_Date1>fieldbyname('E_Date').AsDateTime
      then E_Date1:=fieldbyname('E_Date').AsDateTime;
     Days:=trunc(E_Date1-S_Date1); //该任务的工期天数
     if Id>0 then SGrid_MD.rowcount:=SGrid_MD.rowcount+1;
     SGrid_MD.Cells[0,Id+1]:=inttostr(Id+1);
     SGrid_MD.Cells[1,Id+1]:=fieldbyname('Task_Name').AsString;
     SGrid_MD.Cells[2,Id+1]:=fieldbyname('Area_Name').AsString;
     SGrid_MD.Cells[3,Id+1]:=inttostr(fieldbyname('Workday').AsInteger);
     SGrid_MD.Cells[4,Id+1]:=Datetostr(fieldbyname('B_Date').AsDateTime);
     SGrid_MD.Cells[5,Id+1]:=Datetostr(fieldbyname('E_Date').AsDateTime);
     //SGrid_MD.Cells[6,Id+1]:=fieldbyname('SGD_Name').AsString;
     //SGrid_MD.Cells[7,Id+1]:=floattostr(fieldbyname('FiV').AsFloat*Days); //本期推进长度
     
     {SGrid_MD.Cells[8,Id+1]:=floattostr(fieldbyname('MaV').AsFloat*Days); //本期材料消耗
     SGrid_MD.Cells[9,Id+1]:=floattostr(fieldbyname('ElV').AsFloat*Days); //本期电费
     SGrid_MD.Cells[10,Id+1]:=floattostr(fieldbyname('EqV').AsFloat*Days); //本期设备费
     SGrid_MD.Cells[11,Id+1]:=floattostr(fieldbyname('QV').AsFloat*Days);  //本期产量
     SGrid_MD.Cells[12,Id+1]:=floattostr(fieldbyname('FiV').AsFloat*Days); //}
     {if (RBtnA.Checked)and(RGP_ProMod.ItemIndex=0)and(Cbx_SimSel.ItemIndex=-1)
     then SGrid_MD.Cells[13,Id+1]:=fieldbyname('ProTId').AsString;}
     next;
    end;
  end;
  Btn_Add.Enabled:=true;  //激活“进行仿真”按钮
  Btn_Del.Enabled:=true;  //激活“调整仿真速度”按钮
end;

{procedure TFrm_Project.BitBtn31Click(Sender: TObject);
var yy,mm,dd:word;
    Id:integer;
    StrDate,PreTask:string;
begin
  Project:=TProject.Create;
  with Project,ADOQ_DSGD do
  begin
    if Link_Project then exit;
    ProjectApp.visible:=false;
    close;

⌨️ 快捷键说明

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