unit Main;
interface
uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ExtCtrls, bsSkinData, BusinessSkinForm, bsSkinCtrls, DMClient,
  ImgList, StdCtrls, ActnList, cxControls, cxPC, cxContainer, cxEdit,
  cxTextEdit, cxMaskEdit, cxDropDownEdit, cxCalendar, cxMemo, TeeProcs,
  TeEngine, Chart, DbChart, Series,DBClient,DB,Excel2000,ExcelXP,comobj,
  ComCtrls;
const
  //请重新生成模块的GUID,按Ctrl+Shift+G可生成新的GUID,替换完后请删除该行注释
  MODULEGUID = '{F267339A-58A9-444B-AD93-7C8020E5C779}';
  //请更改模块对应的业务ID,可以先从“系统业务管理”模块中定义业务,然后将业务ID赋值给FLOWID常量,设定完后请删除该行注释
  FLOWID = '102';
  ME_COUNT=150;//MaskEdit
  TE_COUNT=75;//TextEdit
  MEW_COUNT=26;
  MEC_COUNT=9;
type
  TFm_Main = class(TForm)
    BSF_Main: TbsBusinessSkinForm;
    SD_Form: TbsSkinData;
    CSS_Form: TbsCompressedStoredSkin;
    CSS_Dialog: TbsCompressedStoredSkin;
    SD_Dialog: TbsSkinData;
    Timer_StateCheck: TTimer;
    IL_SystemConfig: TImageList;
    AL_Main: TActionList;
    IL_Menu: TImageList;
    IL_Button: TImageList;
    Panel_BackGround: TbsSkinPanel;
    cxPC: TcxPageControl;
    Panel1: TPanel;
    TS_ProduceMain: TcxTabSheet;
    TS_Info: TcxTabSheet;
    Dedit_date: TcxDateEdit;
    BTN_Pre: TbsSkinSpeedButton;
    Btn_Next: TbsSkinSpeedButton;
    Btn_Now: TbsSkinSpeedButton;
    Memo_NotePad: TcxMemo;
    Label74: TLabel;
    ME1: TcxMaskEdit;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    Label5: TLabel;
    Label6: TLabel;
    Label7: TLabel;
    Label8: TLabel;
    ME2: TcxMaskEdit;
    Label9: TLabel;
    Label10: TLabel;
    ME3: TcxMaskEdit;
    ME4: TcxMaskEdit;
    Label11: TLabel;
    Label12: TLabel;
    ME5: TcxMaskEdit;
    ME6: TcxMaskEdit;
    Label13: TLabel;
    Label14: TLabel;
    ME7: TcxMaskEdit;
    ME8: TcxMaskEdit;
    ME9: TcxMaskEdit;
    ME10: TcxMaskEdit;
    ME11: TcxMaskEdit;
    ME12: TcxMaskEdit;
    ME13: TcxMaskEdit;
    ME14: TcxMaskEdit;
    Label15: TLabel;
    Label16: TLabel;
    Label17: TLabel;
    Label18: TLabel;
    Label19: TLabel;
    Label20: TLabel;
    Label21: TLabel;
    Label22: TLabel;
    ME15: TcxMaskEdit;
    ME16: TcxMaskEdit;
    Label23: TLabel;
    ME17: TcxMaskEdit;
    ME18: TcxMaskEdit;
    ME19: TcxMaskEdit;
    ME20: TcxMaskEdit;
    ME21: TcxMaskEdit;
    ME22: TcxMaskEdit;
    ME23: TcxMaskEdit;
    Label24: TLabel;
    Label25: TLabel;
    Label26: TLabel;
    Label27: TLabel;
    Label28: TLabel;
    Label29: TLabel;
    Label30: TLabel;
    ME24: TcxMaskEdit;
    ME25: TcxMaskEdit;
    ME26: TcxMaskEdit;
    ME27: TcxMaskEdit;
    ME28: TcxMaskEdit;
    ME29: TcxMaskEdit;
    ME30: TcxMaskEdit;
    ME31: TcxMaskEdit;
    ME32: TcxMaskEdit;
    ME33: TcxMaskEdit;
    ME34: TcxMaskEdit;
    ME35: TcxMaskEdit;
    ME36: TcxMaskEdit;
    ME37: TcxMaskEdit;
    ME38: TcxMaskEdit;
    ME39: TcxMaskEdit;
    ME40: TcxMaskEdit;
    ME41: TcxMaskEdit;
    ME42: TcxMaskEdit;
    ME43: TcxMaskEdit;
    ME44: TcxMaskEdit;
    ME45: TcxMaskEdit;
    ME46: TcxMaskEdit;
    ME47: TcxMaskEdit;
    ME48: TcxMaskEdit;
    ME49: TcxMaskEdit;
    ME50: TcxMaskEdit;
    ME51: TcxMaskEdit;
    ME52: TcxMaskEdit;
    ME53: TcxMaskEdit;
    ME54: TcxMaskEdit;
    ME55: TcxMaskEdit;
    ME56: TcxMaskEdit;
    ME57: TcxMaskEdit;
    ME58: TcxMaskEdit;
    ME59: TcxMaskEdit;
    ME60: TcxMaskEdit;
    ME61: TcxMaskEdit;
    ME62: TcxMaskEdit;
    ME63: TcxMaskEdit;
    ME64: TcxMaskEdit;
    ME65: TcxMaskEdit;
    ME66: TcxMaskEdit;
    ME67: TcxMaskEdit;
    ME68: TcxMaskEdit;
    ME69: TcxMaskEdit;
    ME70: TcxMaskEdit;
    ME71: TcxMaskEdit;
    ME72: TcxMaskEdit;
    ME73: TcxMaskEdit;
    ME74: TcxMaskEdit;
    ME75: TcxMaskEdit;
    ME76: TcxMaskEdit;
    ME77: TcxMaskEdit;
    ME78: TcxMaskEdit;
    ME79: TcxMaskEdit;
    ME80: TcxMaskEdit;
    ME81: TcxMaskEdit;
    ME82: TcxMaskEdit;
    ME83: TcxMaskEdit;
    ME84: TcxMaskEdit;
    ME85: TcxMaskEdit;
    ME86: TcxMaskEdit;
    ME87: TcxMaskEdit;
    ME88: TcxMaskEdit;
    ME89: TcxMaskEdit;
    ME90: TcxMaskEdit;
    ME91: TcxMaskEdit;
    ME92: TcxMaskEdit;
    ME93: TcxMaskEdit;
    ME94: TcxMaskEdit;
    ME95: TcxMaskEdit;
    ME96: TcxMaskEdit;
    ME97: TcxMaskEdit;
    ME98: TcxMaskEdit;
    ME99: TcxMaskEdit;
    ME100: TcxMaskEdit;
    ME101: TcxMaskEdit;
    ME102: TcxMaskEdit;
    ME103: TcxMaskEdit;
    ME104: TcxMaskEdit;
    ME105: TcxMaskEdit;
    ME106: TcxMaskEdit;
    ME107: TcxMaskEdit;
    ME108: TcxMaskEdit;
    ME109: TcxMaskEdit;
    ME110: TcxMaskEdit;
    ME111: TcxMaskEdit;
    ME112: TcxMaskEdit;
    ME113: TcxMaskEdit;
    ME114: TcxMaskEdit;
    ME115: TcxMaskEdit;
    ME116: TcxMaskEdit;
    ME117: TcxMaskEdit;
    ME118: TcxMaskEdit;
    ME119: TcxMaskEdit;
    ME120: TcxMaskEdit;
    ME121: TcxMaskEdit;
    ME122: TcxMaskEdit;
    ME123: TcxMaskEdit;
    ME124: TcxMaskEdit;
    ME125: TcxMaskEdit;
    ME126: TcxMaskEdit;
    ME127: TcxMaskEdit;
    ME128: TcxMaskEdit;
    ME129: TcxMaskEdit;
    ME130: TcxMaskEdit;
    ME131: TcxMaskEdit;
    ME132: TcxMaskEdit;
    ME133: TcxMaskEdit;
    ME134: TcxMaskEdit;
    ME135: TcxMaskEdit;
    ME136: TcxMaskEdit;
    ME137: TcxMaskEdit;
    ME138: TcxMaskEdit;
    ME139: TcxMaskEdit;
    ME140: TcxMaskEdit;
    ME141: TcxMaskEdit;
    ME142: TcxMaskEdit;
    ME143: TcxMaskEdit;
    ME144: TcxMaskEdit;
    Label31: TLabel;
    Label32: TLabel;
    Label33: TLabel;
    Label34: TLabel;
    Label35: TLabel;
    Label36: TLabel;
    Label37: TLabel;
    Label38: TLabel;
    Label39: TLabel;
    Label40: TLabel;
    Label41: TLabel;
    Label42: TLabel;
    Label43: TLabel;
    Label44: TLabel;
    Label45: TLabel;
    Label46: TLabel;
    Label47: TLabel;
    Label48: TLabel;
    Label49: TLabel;
    Label50: TLabel;
    TE1: TcxTextEdit;
    TE2: TcxTextEdit;
    TE3: TcxTextEdit;
    TE4: TcxTextEdit;
    TE5: TcxTextEdit;
    TE6: TcxTextEdit;
    TE7: TcxTextEdit;
    TE8: TcxTextEdit;
    TE9: TcxTextEdit;
    TE10: TcxTextEdit;
    TE11: TcxTextEdit;
    TE12: TcxTextEdit;
    TE13: TcxTextEdit;
    TE14: TcxTextEdit;
    TE15: TcxTextEdit;
    TE16: TcxTextEdit;
    TE17: TcxTextEdit;
    TE18: TcxTextEdit;
    TE19: TcxTextEdit;
    TE20: TcxTextEdit;
    TE21: TcxTextEdit;
    TE22: TcxTextEdit;
    TE23: TcxTextEdit;
    TE24: TcxTextEdit;
    TE25: TcxTextEdit;
    TE26: TcxTextEdit;
    TE27: TcxTextEdit;
    TE28: TcxTextEdit;
    TE29: TcxTextEdit;
    TE30: TcxTextEdit;
    TE31: TcxTextEdit;
    TE32: TcxTextEdit;
    TE33: TcxTextEdit;
    TE34: TcxTextEdit;
    TE35: TcxTextEdit;
    TE36: TcxTextEdit;
    TE37: TcxTextEdit;
    TE38: TcxTextEdit;
    TE39: TcxTextEdit;
    TE40: TcxTextEdit;
    TE41: TcxTextEdit;
    TE42: TcxTextEdit;
    TE43: TcxTextEdit;
    TE44: TcxTextEdit;
    TE45: TcxTextEdit;
    TE46: TcxTextEdit;
    TE47: TcxTextEdit;
    TE48: TcxTextEdit;
    TE49: TcxTextEdit;
    TE50: TcxTextEdit;
    TE51: TcxTextEdit;
    TE52: TcxTextEdit;
    TE53: TcxTextEdit;
    TE54: TcxTextEdit;
    TE55: TcxTextEdit;
    TE56: TcxTextEdit;
    TE57: TcxTextEdit;
    TE58: TcxTextEdit;
    TE59: TcxTextEdit;
    TE60: TcxTextEdit;
    TE61: TcxTextEdit;
    TE62: TcxTextEdit;
    TE63: TcxTextEdit;
    TE64: TcxTextEdit;
    TE65: TcxTextEdit;
    TE66: TcxTextEdit;
    TE67: TcxTextEdit;
    TE68: TcxTextEdit;
    TE69: TcxTextEdit;
    TE70: TcxTextEdit;
    TE71: TcxTextEdit;
    TE72: TcxTextEdit;
    TE73: TcxTextEdit;
    TE74: TcxTextEdit;
    TE75: TcxTextEdit;
    Label54: TLabel;
    Label55: TLabel;
    Label56: TLabel;
    Label57: TLabel;
    Label58: TLabel;
    Label59: TLabel;
    Label60: TLabel;
    Label61: TLabel;
    Label62: TLabel;
    Label63: TLabel;
    Label64: TLabel;
    Label65: TLabel;
    Label66: TLabel;
    MEW1: TcxMaskEdit;
    MEW2: TcxMaskEdit;
    MEW3: TcxMaskEdit;
    MEW4: TcxMaskEdit;
    MEW5: TcxMaskEdit;
    MEW6: TcxMaskEdit;
    MEW7: TcxMaskEdit;
    MEW8: TcxMaskEdit;
    MEW9: TcxMaskEdit;
    MEW10: TcxMaskEdit;
    Mew11: TcxMaskEdit;
    mew12: TcxMaskEdit;
    MEW13: TcxMaskEdit;
    MEW14: TcxMaskEdit;
    MEW15: TcxMaskEdit;
    MEW16: TcxMaskEdit;
    Label67: TLabel;
    Label68: TLabel;
    Label69: TLabel;
    MEW17: TcxMaskEdit;
    MEW18: TcxMaskEdit;
    MEW19: TcxMaskEdit;
    MEW20: TcxMaskEdit;
    MEW21: TcxMaskEdit;
    MEW22: TcxMaskEdit;
    MEW23: TcxMaskEdit;
    MEW24: TcxMaskEdit;
    MEW25: TcxMaskEdit;
    MEW26: TcxMaskEdit;
    Label70: TLabel;
    Label75: TLabel;
    Label77: TLabel;
    Label78: TLabel;
    Label79: TLabel;
    Label71: TLabel;
    Label72: TLabel;
    Label73: TLabel;
    Label76: TLabel;
    MEC1: TcxMaskEdit;
    MEC2: TcxMaskEdit;
    MEC3: TcxMaskEdit;
    MEC4: TcxMaskEdit;
    MEC5: TcxMaskEdit;
    MEC6: TcxMaskEdit;
    MEC7: TcxMaskEdit;
    MEC8: TcxMaskEdit;
    MEC9: TcxMaskEdit;
    bsSkinSpeedButton1: TbsSkinSpeedButton;
    TS_Pic: TcxTabSheet;
    Label51: TLabel;
    ME145: TcxMaskEdit;
    ME146: TcxMaskEdit;
    ME147: TcxMaskEdit;
    ME148: TcxMaskEdit;
    ME149: TcxMaskEdit;
    ME150: TcxMaskEdit;
    Action_SaveRepInfo: TAction;
    Action_SaveNotPad: TAction;
    Action_Pre: TAction;
    Action_Next: TAction;
    Action_Now: TAction;
    Label52: TLabel;
    Label_FillDate: TLabel;
    Label80: TLabel;
    Label_FillWatcher: TLabel;
    Panel18: TPanel;
    bsSkinSpeedButton3: TbsSkinSpeedButton;
    Action_Calc: TAction;
    btn_Calc: TbsSkinSpeedButton;
    chtMain: TChart;
    Series1: TLineSeries;
    Action_print: TAction;
    bsSkinSpeedButton2: TbsSkinSpeedButton;
    Panel_Print: TPanel;
    ProB_Print: TProgressBar;
    procedure MEW17DblClick(Sender: TObject);
    procedure MEW4DblClick(Sender: TObject);
    procedure Action_printExecute(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
    procedure MEW26DblClick(Sender: TObject);
    procedure MEW13DblClick(Sender: TObject);
    procedure Action_CalcExecute(Sender: TObject);
    procedure Label2Click(Sender: TObject);
    procedure Label2MouseEnter(Sender: TObject);
    procedure Label2MouseLeave(Sender: TObject);
    procedure ME150DblClick(Sender: TObject);
    procedure ME149DblClick(Sender: TObject);
    procedure ME148DblClick(Sender: TObject);
    procedure ME147DblClick(Sender: TObject);
    procedure ME146DblClick(Sender: TObject);
    procedure ME145DblClick(Sender: TObject);
    procedure Action_NowExecute(Sender: TObject);
    procedure Action_NextExecute(Sender: TObject);
    procedure Action_PreExecute(Sender: TObject);
    procedure Action_SaveNotPadExecute(Sender: TObject);
    procedure Action_SaveRepInfoExecute(Sender: TObject);
    procedure Timer_StateCheckTimer(Sender: TObject);
    procedure FormShow(Sender: TObject);
  private
    { Private declarations }
    function FetchDataFromRecord(pTableName,pFieldName:string;pIndex:Integer):string;
    function CheckHave(var pID:string;pDate:string):Boolean;//检查该日有没有日报
    function IsNull(pSoureStr,RecStr:string):string;//
    function Devide(Num1,Num2:string):Real;
    function GetValueList(DivStr,pSource:string;pIndex:Integer):string;//发电机运行记录里 取某一列(某一个测点)
    //在发电机运行记录里取出一条记录(某一时刻的所有的数据)
    procedure GetSourceStrByID(pID,pTableName,pFieldName:string;var ResultStr:string);
    procedure DisplayEnginePowerQty;//加载4个机组24小时发电量
    function CalcSubStr(pStr:string):Real;//垒加1*2*2*2*1*2*3*2*12*(24小时)
    function CalcMonthPowerQty(pTableName,pFieldName:string):Real;//计算某个机组月发电量
    function CalcYearPowerQty(pTableName,pFieldName:string):Real;//计算某个机组年发电量
   
    function CalcDay(pstr,pCompName:string):Real;//在值长日志里的一个字段中截取一个控件里的值
    function CalcDayuse(pCompName:string):Real;//合计一个机组某一天的煤,油,水
    function CalcMonthUse(pCompName:string):Real;//合计一个机组某一月的煤,油,水
    function FetchCoalInfo(pCompName:string):Real;//获取存煤信息
    procedure FetchNotPad;//获取生产概叙
    procedure DrowPic;//绘制曲线图
    //计算24个时间段里机组的发电量
    procedure GetPowerInfo(var pStr:string;pTableName,pHead:string;pIndex:Integer);
    //计算凌河日来水量
    function CalcLinHDayUse(pCompName:string):Real;
    //计算凌河月来水量
    function CalcLinHMonthUse(pCompName:string):Real;
    //按班次计算日来水量
    function CalcWaterDayUseByClass(pCompName:string):Real;
    //按天计算日来水量
    function CalcWaterDayUseByDay(pCompName:string):Real;
    //按班次计算月来水量
    function CalcWaterMonthUseByClass(pCompName:string):Real;
    //按天计算月来水量
    function CalcWaterMonthUseByDay(pCompName:string):Real;
    //取厂用电量
    function FetchFacUsePowerQty(pTable,pHead:string;pIndex:Integer):Real;
    //取值长日报里上一天的数据
    function FetchLastDayData(pFieldName,pCompName:string):Real;
  public
    mBPSID: OleVariant;
    mMsgPanel, mUserNamePanel, mUserIDPanel, mConfigPanel, mIPPanel: TbsSkinStatusPanel;
    mCurRecordID: OleVariant;
    mDM: TDM;
    mTargetRecordID, mTargetTableName: OleVariant;
    { Public declarations }
    procedure ShowConfigMsg(Sender: TObject);
    procedure ClearData;
    function CheckStatus:Boolean;
    function GetStatus(var pStatusStr:string;phead:string;pcount:Integer):Boolean;
    procedure SetStatus(pStatusStr:string);
    procedure ShowRepInfo(pID:string);
    procedure PrintLogInfo;//打印
  end;
var
  Fm_Main: TFm_Main;
implementation
uses IBPSKernel30, ProcedureLibrary, UntChart;
{$R *.dfm}
{ TFm_Main }
procedure TFm_Main.Action_CalcExecute(Sender: TObject);
begin
  Btn_Calc.Enabled:=False;
  DisplayEnginePowerQty;//加载4个机组24小时发电量
  Label2.OnClick(Sender);//统计四个机组每小时的实际完成发电量
  ME145.OnDblClick(Sender);//统计24小时计划发电量
  ME146.OnDblClick(Sender);//统计24小时四个机组实际完成发电量
  ME147.OnDblClick(Sender);//统计#1 24小时实际完成发电量
  ME148.OnDblClick(Sender);//统计#2 24小时实际完成发电量
  ME149.OnDblClick(Sender);//统计#3 24小时实际完成发电量
  ME150.OnDblClick(Sender);//统计#4 24小时实际完成发电量
  TE1.Text:=ME147.Text;//
  TE16.Text:=ME148.Text;
  TE31.Text:=ME149.Text;
  TE46.Text:=ME150.Text;
  TE61.Text:=ME146.Text;
  TE2.Text:=FloatToStr(CalcMonthPowerQty(mBPSID+'_PRODUCE.T_FIRSTElECREC','ONEDATA'));//#1机月发电量
  TE17.Text:=FloatToStr(CalcMonthPowerQty(mBPSID+'_PRODUCE.T_FIRSTElECREC','TWODATA'));//#2机月发电量
  TE32.Text:=FloatToStr(CalcMonthPowerQty(mBPSID+'_PRODUCE.T_SECElECREC','ONEDATA'));//#3机月发电量
  TE47.Text:=FloatToStr(CalcMonthPowerQty(mBPSID+'_PRODUCE.T_SECElECREC','TWODATA'));//#4机月发电量
  TE62.Text:=FloatToStr(StrToFloat(IsNull(TE2.Text,'0'))+StrToFloat(IsNull(TE17.Text,'0'))+
             StrToFloat(IsNull(TE32.Text,'0'))+StrToFloat(IsNull(TE47.Text,'0')));//
  TE3.Text:=FloatToStr(CalcYearPowerQty(mBPSID+'_PRODUCE.T_FIRSTElECREC','ONEDATA'));//#1机年发电量
  TE18.Text:=FloatToStr(CalcYearPowerQty(mBPSID+'_PRODUCE.T_FIRSTElECREC','TWODATA'));//#2机年发电量
  TE33.Text:=FloatToStr(CalcYearPowerQty(mBPSID+'_PRODUCE.T_SECElECREC','ONEDATA'));//#1机年发电量
  TE48.Text:=FloatToStr(CalcYearPowerQty(mBPSID+'_PRODUCE.T_SECElECREC','TWODATA'));//#2机年发电量
  TE63.Text:=FloatToStr(StrToFloat(IsNull(TE3.Text,'0'))+StrToFloat(IsNull(TE18.Text,'0'))+
             StrToFloat(IsNull(TE33.Text,'0'))+StrToFloat(IsNull(TE48.Text,'0')));//
  TE5.Text:=FloatToStr(CalcDayuse('ME32')); //#1机组日用煤
  TE20.Text:=FloatToStr(CalcDayuse('ME33'));//#2机组日用煤
  TE35.Text:=FloatToStr(CalcDayuse('ME34'));//#3机组日用煤
  TE50.Text:=FloatToStr(CalcDayuse('ME35'));//#4机组日用煤
  TE65.Text:=FloatToStr(CalcDayuse('ME32')+CalcDayuse('ME33')+
                        CalcDayuse('ME34')+CalcDayuse('ME35'));//四个机组日用煤汇总
  TE6.Text:=FloatToStr(CalcMonthuse('ME32')); //#1机组月用煤
  TE21.Text:=FloatToStr(CalcMonthuse('ME33'));//#2机组月用煤
  TE36.Text:=FloatToStr(CalcMonthuse('ME34'));//#3机组月用煤
  TE51.Text:=FloatToStr(CalcMonthuse('ME35'));//#4机组月用煤
  TE66.Text:=FloatToStr(CalcMonthuse('ME32')+CalcMonthuse('ME33')+
                        CalcMonthuse('ME34')+CalcMonthuse('ME35'));//四个机组月用煤汇总
  TE7.Text:=FloatToStr(CalcDayuse('ME60')); //#1机组日用油
  TE22.Text:=FloatToStr(CalcDayuse('ME61'));//#2机组日用油
  TE37.Text:=FloatToStr(CalcDayuse('ME62'));//#3机组日用油
  TE52.Text:=FloatToStr(CalcDayuse('ME63'));//#4机组日用油
  TE67.Text:=FloatToStr(CalcDayuse('ME61')+CalcDayuse('ME62')+
                        CalcDayuse('ME60')+CalcDayuse('ME63'));//四个机组日用油汇总
  TE8.Text:=FloatToStr(CalcMonthuse('ME60')); //#1机组月用油
  TE23.Text:=FloatToStr(CalcMonthuse('ME61'));//#2机组月用油
  TE38.Text:=FloatToStr(CalcMonthuse('ME62'));//#3机组月用油
  TE53.Text:=FloatToStr(CalcMonthuse('ME63'));//#4机组月用油
  TE68.Text:=FloatToStr(CalcMonthuse('ME61')+CalcMonthuse('ME62')+
                        CalcMonthuse('ME60')+CalcMonthuse('ME63'));//四个机组月用油汇总
  TE69.Text:=FloatToStr(Calcdayuse('ME51'));//四个机组日用水量合计
  TE70.Text:=FloatToStr(CalcMonthuse('ME51'));//四个机组月用水量合计
  TE13.Text:=FloatToStr(FetchFacUsePowerQty(mBPSID+'_PRODUCE.T_FIRSTElECREC','FIR',15));//1#机组厂用电量
  TE28.Text:=FloatToStr(FetchFacUsePowerQty(mBPSID+'_PRODUCE.T_FIRSTElECREC','SEC',15));//2#机组厂用电量
  TE43.Text:=FloatToStr(FetchFacUsePowerQty(mBPSID+'_PRODUCE.T_SECElECREC','THREE',15));//3#机组厂用电量
  TE58.Text:=FloatToStr(FetchFacUsePowerQty(mBPSID+'_PRODUCE.T_SECElECREC','FOUR',15));//4#机组厂用电量
  TE73.Text:=FloatToStr(StrToFloat(IsNull(TE13.Text,'0'))+StrToFloat(IsNull(TE28.Text,'0'))+
             StrToFloat(IsNull(TE58.Text,'0'))+StrToFloat(IsNull(TE73.Text,'0')));//合计厂用电量
  TE4.Text:=FloatToStr(Devide(TE13.Text,TE1.Text));//#1机组厂用率
  TE19.Text:=FloatToStr(Devide(TE28.Text,TE16.Text));//#2机组厂用率
  TE34.Text:=FloatToStr(Devide(TE43.Text,TE31.Text));//#3机组厂用率
  TE49.Text:=FloatToStr(Devide(TE58.Text,TE56.Text));//#4机组厂用率
  TE14.Text:=FloatToStr(FetchLastDayData('ProduceInfo','TE14')+24);//#1机组月累计运行小时
  TE29.Text:=FloatToStr(FetchLastDayData('ProduceInfo','TE29')+24);//#2机组月累计运行小时
  TE44.Text:=FloatToStr(FetchLastDayData('ProduceInfo','TE44')+24);//#3机组月累计运行小时
  TE59.Text:=FloatToStr(FetchLastDayData('ProduceInfo','TE59')+24);//#4机组月累计运行小时
  TE74.Text:=FloatToStr(StrToFloat(IsNull(TE14.Text,'0'))+StrToFloat(IsNull(TE29.Text,'0'))+
                        StrToFloat(IsNull(TE44.Text,'0'))+StrToFloat(IsNull(TE59.Text,'0')));//合计月累计运行小时
  TE15.Text:=FloatToStr(FetchLastDayData('ProduceInfo','TE15')+24);//#1机组年累计运行小时
  TE30.Text:=FloatToStr(FetchLastDayData('ProduceInfo','TE30')+24);//#2机组年累计运行小时
  TE45.Text:=FloatToStr(FetchLastDayData('ProduceInfo','TE45')+24);//#3机组年累计运行小时
  TE60.Text:=FloatToStr(FetchLastDayData('ProduceInfo','TE60')+24);//#4机组年累计运行小时
  TE75.Text:=FloatToStr(StrToFloat(IsNull(TE15.Text,'0'))+StrToFloat(IsNull(TE30.Text,'0'))+
                        StrToFloat(IsNull(TE45.Text,'0'))+StrToFloat(IsNull(TE60.Text,'0')));//合计年累计运行小时
  TE11.Text:=FloatToStr(StrToFloat(IsNull(TE1.Text,'0'))/24);//#1机组平均负荷
  TE26.Text:=FloatToStr(StrToFloat(IsNull(TE16.Text,'0'))/24);//#2机组平均负荷
  TE41.Text:=FloatToStr(StrToFloat(IsNull(TE31.Text,'0'))/24);//#3机组平均负荷
  TE56.Text:=FloatToStr(StrToFloat(IsNull(TE46.Text,'0'))/24);//#4机组平均负荷
  TE71.Text:=FloatToStr(StrToFloat(IsNull(TE61.Text,'0'))/24);//合计
  TE12.Text:=FloatToStr(StrToFloat(IsNull(TE11.Text,'0'))/150);//#1机组负荷率
  TE27.Text:=FloatToStr(StrToFloat(IsNull(TE26.Text,'0'))/150);//#1机组负荷率
  TE42.Text:=FloatToStr(StrToFloat(IsNull(TE41.Text,'0'))/150);//#1机组负荷率
  TE57.Text:=FloatToStr(StrToFloat(IsNull(TE56.Text,'0'))/150);//#1机组负荷率
//************************************用水情况统计******************************
  MEW1.Text:=FloatToStr(CalcLinHDayUse('ME54'));//凌河#2管日来水量
  //MEW14.Text:=FloatToStr(CalcLinHMonthUse('ME54'));//凌河#2管月来水量(方法一:累计)
  MEW14.Text:=FloatToStr(FetchLastDayData('WaterInfo','MEW14')+
                         StrToFloat(IsNull(MEW1.Text,'0')));//凌河#2管月来水量(方法一:取上一天的值长日报数据)
  MEW2.Text:=FloatToStr(CalcDayUse('ME39'));//艾友#1管日来水量
  //MEW15.Text:=FloatToStr(CalcMonthUse('ME39'));//艾友#1管月来水量 (方法一:累计)
  MEW15.Text:=FloatToStr(FetchLastDayData('WaterInfo','MEW15')+
                         StrToFloat(IsNull(MEW2.Text,'0')));
  MEW3.Text:=FloatToStr(CalcWaterDayUseByDay('TE26'));//汤头河日来水量
  //MEW16.Text:=FloatToStr(CalcWaterMonthUseByDay('TE26'));//汤头河月来水量(方法一:累计)
  MEW16.Text:=FloatToStr(FetchLastDayData('WaterInfo','MEW16')+
                        StrToFloat(IsNull(MEW3.Text,'0')));//汤头河月来水量(方法二:上一天的数据)
  //合计
  MEW4.OnDblClick(Sender);
  MEW17.OnDblClick(Sender);
  {MEW4.Text:=FloatToStr(StrToFloat(IsNull(MEW1.Text,'0'))+StrToFloat(IsNull(MEW2.Text,'0')));//合计
  MEW17.Text:=FloatToStr(StrToFloat(IsNull(MEW14.Text,'0'))+StrToFloat(IsNull(MEW15.Text,'0')));//合计}
  MEW5.Text:=FloatToStr(CalcWaterDayUseByClass('TE27'));//伊玛日来水量
  //MEW17.Text:=FloatToStr(CalcWaterMonthUseByClass('TE27'));//伊玛月来水量 (方法一:累计)
  MEW18.Text:=FloatToStr(FetchLastDayData('WaterInfo','MEW18')+
                         StrToFloat(IsNull(MEW5.Text,'0')));//伊玛月来水量 (方法二:取上一天的值长日报数据)
  MEW6.Text:=FloatToStr(CalcWaterDayUseByDay('TE29'));//二道河子日来水量
  //MEW18.Text:=FloatToStr(CalcWaterMonthUseByDay('TE29'));//二道河子月来水量 (方法一:累计)
  MEW19.Text:=FloatToStr(FetchLastDayData('WaterInfo','MEW19')+
                         StrToFloat(IsNull(MEW6.Text,'0')));//二道河子月来水量  (方法二:上一天的数据)
  MEW7.Text:=FloatToStr(CalcWaterDayUseByDay('TE22'));//二井日来水量
  //MEW19.Text:=FloatToStr(CalcWaterMonthUseByDay('TE22'));//二井月来水量(方法一:累计)
  MEW20.Text:=FloatToStr(FetchLastDayData('WaterInfo','MEW20')+
                         StrToFloat(IsNull(MEW7.Text,'0')));//二井月来水量(方法二:取上一天的数据)
  MEW8.Text:=FloatToStr(CalcWaterDayUseByDay('TE25'));//三矿日来水量
  //MEW20.Text:=FloatToStr(CalcWaterMonthUseByDay('TE25'));//三矿月来水量(方法一:累计)
  MEW21.Text:=FloatToStr(FetchLastDayData('WaterInfo','MEW21')+
                         StrToFloat(IsNull(MEW8.Text,'0')));//三矿月来水量(方法二:上一天的数据)
  MEW9.Text:=FloatToStr(CalcWaterDayUseByDay('TE19'));//艾友村日来水量
  //MEW21.Text:=FloatToStr(CalcWaterMonthUseByDay('TE19'));//艾友村月来水量(方法一:累计)
  MEW22.Text:=FloatToStr(FetchLastDayData('WaterInfo','MEW22')+
                         StrToFloat(IsNull(MEW9.Text,'0')));//艾友村月来水量(方法二:上一天的数据)
  MEW10.Text:=FloatToStr(CalcWaterDayUseByDay('TE28'));//大成日来水量
  //MEW22.Text:=FloatToStr(CalcWaterMonthUseByDay('TE28'));//大成月来水量(方法一:累计)
  MEW23.Text:=FloatToStr(FetchLastDayData('WaterInfo','MEW23')+
                        StrToFloat(IsNull(MEW10.Text,'0')));//大成月来水量(方法二:上一天的数据)
  MEW11.Text:=FloatToStr(CalcWaterDayUseByClass('TE20'));//乌龙日来水量
  //MEW23.Text:=FloatToStr(CalcWaterMonthUseByClass('TE20'));//乌龙月来水量(方法一:累计)
  MEW24.Text:=FloatToStr(FetchLastDayData('WaterInfo','MEW24')+
                        StrToFloat(IsNull(MEW11.Text,'0')));//乌龙月来水量(方法二:上一天的数据)
  MEW12.Text:=FloatToStr(CalcWaterDayUseByClass('TE30'));//靖伟日来水量
  //MEW24.Text:=FloatToStr(CalcWaterMonthUseByClass('TE30'));//靖伟月来水量(方法一:累计)
  MEW25.Text:=FloatToStr(FetchLastDayData('WaterInfo','MEW25')+
                        StrToFloat(IsNull(MEW12.Text,'0')));//靖伟月来水量(方法二:上一天的数据)
  //合计
  MEW13.OnDblClick(Sender);
  MEW26.OnDblClick(Sender);
  MEC1.Text:=FloatToStr(FetchCoalInfo('ME23')+FetchCoalInfo('ME24'));//#1煤斗存煤
  MEC2.Text:=FloatToStr(FetchCoalInfo('ME25')+FetchCoalInfo('ME26'));//#2煤斗存煤
  MEC3.Text:=FloatToStr(FetchCoalInfo('ME27')+FetchCoalInfo('ME28'));//#3煤斗存煤
  MEC4.Text:=FloatToStr(FetchCoalInfo('ME29')+FetchCoalInfo('ME30'));//#4煤斗存煤
  MEC5.Text:=FloatToStr(FetchCoalInfo('ME19'));//#1仓洞存煤
  MEC6.Text:=FloatToStr(FetchCoalInfo('ME20'));//#2仓洞存煤
  MEC7.Text:=FloatToStr(FetchCoalInfo('ME17'));//汽车沟存煤
  MEC8.Text:=FloatToStr(FetchCoalInfo('ME18'));//火车沟存煤
  MEC9.Text:=FloatToStr(FetchCoalInfo('ME21'));//厂内重车(车数)
  FetchNotPad;//取得生产概叙
  DrowPic;//画图
  Label_FillDate.Caption:=FormatDateTime('YYYY-MM-DD HH:MM:SS',Now);
  Label_FillWatcher.Caption:=mUserNamePanel.Caption;
  Btn_Calc.Enabled:=True;
end;
procedure TFm_Main.Action_NextExecute(Sender: TObject);
var
  lID,lDate:string;
begin
  Dedit_date.Date:=Dedit_date.Date+1;
  lDate:=FormatDateTime('YYYY-MM-DD',Dedit_date.Date);
  if CheckHave(lID,lDate) then
  begin
   ShowRepInfo(lID);
  end
  else
  begin
    ClearData;
    ShowMessage('没有符合条件的数据');
  end;
end;
procedure TFm_Main.Action_NowExecute(Sender: TObject);
var
  lID,lDate:string;
begin
  Dedit_date.Date:=Now-1;
  lDate:=FormatDateTime('YYYY-MM-DD',Dedit_date.Date);
  if CheckHave(lID,lDate) then
  begin
   ShowRepInfo(lID);
  end
  else
  begin
    ClearData;
    ShowMessage('没有符合条件的数据');
  end;
end;
procedure TFm_Main.Action_PreExecute(Sender: TObject);
var
  lID,lDate:string;
begin
  Dedit_date.Date:=Dedit_date.Date-1;
  lDate:=FormatDateTime('YYYY-MM-DD',Dedit_date.Date);
  if CheckHave(lID,lDate) then
  begin
   ShowRepInfo(lID);
  end
  else
  begin
    ClearData;
    ShowMessage('没有符合条件的数据');
  end;
end;
procedure TFm_Main.Action_printExecute(Sender: TObject);
begin
  cxPC.ActivePageIndex:=1;
  Action_print.Enabled:=False;
  Panel_Print.Visible:=True;
  Panel_Print.Caption:='正在打印 请等待...........';
  Panel_Print.Repaint;
  try
    PrintLogInfo;
  except
  end;
  Panel_Print.Visible:=False;
  Action_print.Enabled:=True;
end;
procedure TFm_Main.Action_SaveNotPadExecute(Sender: TObject);
var
  lSQLText:string;
  lRC:OleVariant;
  lDate,lID:string;
begin
  lDate:=FormatDateTime('YYYY-MM-DD',Dedit_date.Date);
  if CheckHave(lID,lDate) then
  begin
    if MessageBox(Handle,'确认修改今天的日报?','提示',MB_YESNO)=mrNo then
      Exit;
    lRC:=mDM.mSystemWS.UpDateRecord(mBPSID,'PRODUCE','T_WatchLeaderRep',lID,
                                    'Producesummary'+#13#10+
                                    'RepDate'+#13#10+
                                    'FillDate'+#13#10+
                                    'RepWatcher',
                                    ReplaceString(0,Memo_NotePad.Text)+#13#10+
                                    lDate+#13#10+
                                    FormatDateTime('YYYY-MM-DD HH:MM:SS',Now)+#13#10+
                                    mUserNamePanel.Caption,
                                    mUserIDPanel.Caption,
                                    mUserNamePanel.Caption,
                                    mIPPanel.Caption);
    if Pos('Error',lRC)<>0 then
      ShowMessage('数据保存失败'#13#10'请联系管理员')
    else
      ShowMessage('数据保存成功')
  end
  else
  begin
    lRC:=mDM.mSystemWS.InsertRecord(mBPSID,'PRODUCE','T_WatchLeaderRep',
                                    'Producesummary'+#13#10+
                                    'RepDate'+#13#10+
                                    'FillDate'+#13#10+
                                    'RepWatcher',
                                    ReplaceString(2,Memo_NotePad.Text)+#13#10+
                                    lDate+#13#10+
                                    FormatDateTime('YYYY-MM-DD HH:MM:SS',Now)+#13#10+
                                    mUserNamePanel.Caption,'0',
                                    mUserIDPanel.Caption,
                                    mUserNamePanel.Caption,
                                    mIPPanel.Caption);
    if Pos('Error',lRC)<>0 then
      ShowMessage('数据保存失败'#13#10'请联系管理员')
    else
      ShowMessage('数据保存成功')
  end;
end;
procedure TFm_Main.Action_SaveRepInfoExecute(Sender: TObject);
var
  lSQLText:string;
  lRC:OleVariant;
  lPowerInfo,lProduceInfo,lWaterInfo,lCoalInfo,lDate,lID:string;
begin
  if not CheckStatus then
    Exit;
  lDate:=FormatDateTime('YYYY-MM-DD',Dedit_date.Date);
  GetStatus(lPowerInfo,'ME',150);
  GetStatus(lProduceInfo,'TE',79);
  GetStatus(lWaterInfo,'MEW',26);
  GetStatus(lCoalInfo,'MEC',9);
  if CheckHave(lID,lDate) then
  begin
    if MessageBox(Handle,'确认修改今天的日报?','提示',MB_YESNO)=mrNo then
      Exit;   
    lRC:=mDM.mSystemWS.UpDateRecord(mBPSID,'PRODUCE','T_WatchLeaderRep',lID,
                                    'PowerInfo'+#13#10+
                                    'ProduceInfo'+#13#10+
                                    'WaterInfo'+#13#10+
                                    'CoalInfo'+#13#10+
                                    'Producesummary'+#13#10+
                                    'RepDate'+#13#10+
                                    'FillDate'+#13#10+
                                    'RepWatcher',
                                    lPowerInfo+#13#10+
                                    lProduceInfo+#13#10+
                                    lWaterInfo+#13#10+
                                    lCoalInfo+#13#10+
                                    ReplaceString(0,Memo_NotePad.Text)+#13#10+
                                    lDate+#13#10+
                                    FormatDateTime('YYYY-MM-DD HH:MM:SS',Now)+#13#10+
                                    mUserNamePanel.Caption,
                                    mUserIDPanel.Caption,
                                    mUserNamePanel.Caption,
                                    mIPPanel.Caption);
    if Pos('Error',lRC)<>0 then
      ShowMessage('数据保存失败'#13#10'请联系管理员')
    else
      DrowPic;
      Label_FillWatcher.Caption:=mUserNamePanel.Caption;
      ShowMessage('数据保存成功');
  end
  else
  begin
    lRC:=mDM.mSystemWS.InsertRecord(mBPSID,'PRODUCE','T_WatchLeaderRep',
                                    'PowerInfo'+#13#10+
                                    'ProduceInfo'+#13#10+
                                    'WaterInfo'+#13#10+
                                    'CoalInfo'+#13#10+
                                    'Producesummary'+#13#10+
                                    'RepDate'+#13#10+
                                    'FillDate'+#13#10+
                                    'RepWatcher',
                                    lPowerInfo+#13#10+
                                    lProduceInfo+#13#10+
                                    lWaterInfo+#13#10+
                                    lCoalInfo+#13#10+
                                    ReplaceString(2,Memo_NotePad.Text)+#13#10+
                                    lDate+#13#10+
                                    FormatDateTime('YYYY-MM-DD HH:MM:SS',Now)+#13#10+
                                    mUserNamePanel.Caption,'0',
                                    mUserIDPanel.Caption,
                                    mUserNamePanel.Caption,
                                    mIPPanel.Caption);
    if Pos('Error',lRC)<>0 then
      ShowMessage('数据保存失败'#13#10'请联系管理员')
    else
      ShowMessage('数据保存成功');
  end;
end;
function TFm_Main.CalcDay(pstr, pCompName: string): Real;
var
  lData,lTempStr:string;
begin
  lTempStr:=Copy(pStr,Pos(pCompName,pStr),MaxInt);
  DevideString(lTempStr,'*',lData,lTempStr);
  DevideString(lTempStr,'*',lData,lTempStr);
  try
    Result:=StrToFloat(IsNull(lData,'0'));
  except
  end;
end;
function TFm_Main.CalcDayuse(pCompName: string): Real;
var
  lSQLText:string;
  lRC:OleVariant;
  TempResult:Real;
begin
  lSQLText:='select handOverLog from '+mBPSID+'_PRODUCE.T_ADMINISTERLOG where '+
            'SubStr(CarryOnTime,1,10)='''+FormatDateTime('YYYY-MM-DD',Dedit_date.Date)+'''';
  lRC:=mDM.mSystemWS.GetDataSet(lSQLText);
  if pos('Error',lRC)=0 then
  begin
    with mDM.CDS_Common do
    begin
      mDM.CDS_Common.XMLData:=lRC;
      First;
      while Not Eof  do
      begin
        TempResult:=TempResult+CalcDay(FieldByName('handOverLog').AsString,pCompName);
        Next;
      end;
    end;
  end;
  Result:=TempResult;
end;
function TFm_Main.CalcLinHDayUse(pCompName: string): Real;
var
  lSQLText:string;
  lRC:OleVariant;
  lData1,lData2:Real;
begin
  //取上一班后夜班的数据
  lSQLText:='select handOverLog from '+mBPSID+'_PRODUCE.T_ADMINISTERLOG where '+
            'LOGDATE = '+IntToStr(Trunc(Dedit_date.Date-1))+' and spell=''AFTERNIGHT''';
  lRC:=mDM.mSystemWS.GetDataSet(lSQLText);
  if Pos('Error',lRC)=0 then
  begin
    mDM.CDS_Common.XMLData:=lRC;
    lData1:=CalcDay(mDM.CDS_Common.FieldByName('handOverLog').AsString,pCompName);
  end;
  //取最后一班的数据
  lSQLText:='select handOverLog from '+mBPSID+'_PRODUCE.T_ADMINISTERLOG where '+
            'LOGDATE = '+IntToStr(Trunc(Dedit_date.Date))+' and spell=''AFTERNIGHT''';
  lRC:=mDM.mSystemWS.GetDataSet(lSQLText);
  if Pos('Error',lRC)=0 then
  begin
    mDM.CDS_Common.XMLData:=lRC;
    lData2:=CalcDay(mDM.CDS_Common.FieldByName('handOverLog').AsString,pCompName);
  end;
  Result:=lData2-lData1;
end;
function TFm_Main.CalcLinHMonthUse(pCompName: string): Real;
var
  lSQLText:string;
  lRC:OleVariant;
  lData1,lData2,TempResult:Real;
begin
  lSQLText:='select handOverLog from '+mBPSID+'_PRODUCE.T_ADMINISTERLOG where '+
            'SubStr(CarryOnTime,1,7)='''+
            FormatDateTime('YYYY-MM',Dedit_date.Date)+''' and logDate<= '''+IntToStr(Trunc(Dedit_date.Date))+
            ''' order by ID';
  lRC:=mDM.mSystemWS.GetDataSet(lSQLText);
  if pos('Error',lRC)=0 then
  begin
    with mDM.CDS_Common do
    begin
      mDM.CDS_Common.XMLData:=lRC;
      First;
      lData1:=CalcDay(FieldByName('handOverLog').AsString,pCompName);
      Last;
      lData2:=CalcDay(FieldByName('handOverLog').AsString,pCompName);
    end;
  end;
  Result:=lData2-lData1;
end;
function TFm_Main.CalcMonthPowerQty(pTableName,pFieldName:string):Real;
var
  TempStr,lSQLText:string;
  lRC:OleVariant;
begin
  lSQLText:='select '+pFieldName+' from '+pTableName+
            ' where SubStr(DAYCARRAYTIME,1,7)='''+
            FormatDateTime('YYYY-MM',Now)+'''';
  lRC:=mDM.mSystemWS.GetDataSet(lSQLText);
  if Pos('Error',lRC)=0 then
  begin
    with mDM.CDS_Common do
    begin
      mDM.CDS_Common.XMLData:=lRC;
      First;
      while Not Eof  do
      begin
        TempStr:=GetValueList( '@',FieldByName(pFieldName).AsString,1);//取第一列
        Result:=Result+CalcSubStr(TempStr);
        Next;
      end;
    end;
  end;
end;
function TFm_Main.CalcMonthUse(pCompName: string): Real;
var
  lSQLText:string;
  lRC:OleVariant;
  TempResult:Real;
begin
  lSQLText:='select handOverLog from '+mBPSID+'_PRODUCE.T_ADMINISTERLOG where '+
            'SubStr(CarryOnTime,1,7)='''+FormatDateTime('YYYY-MM',Dedit_date.Date)+'''';
  lRC:=mDM.mSystemWS.GetDataSet(lSQLText);
  if pos('Error',lRC)=0 then
  begin
    with mDM.CDS_Common do
    begin
      mDM.CDS_Common.XMLData:=lRC;
      First;
      while Not Eof  do
      begin
        TempResult:=TempResult+CalcDay(FieldByName('handOverLog').AsString,pCompName);
        Next;
      end;
    end;
  end;
  Result:=TempResult;
end;
function TFm_Main.CalcSubStr(pStr: string): Real;
var
  lData:string;
  i:Integer;
  TempResult:Real;
begin
  for I := 1 to 24 do
  begin
    DevideString(pStr,'*',lData,pStr);
    TempResult:=TempResult+StrToFloat(IsNull(lData,'0'));
  end;
  Result:=TempResult;
end;
function TFm_Main.CalcWaterDayUseByClass(pCompName: string): Real;
var
  lSQLText:string;
  lRC:OleVariant;
  lTempResult,lData1,lData2:Real;
begin
  lSQLText:='select handOverLog from '+mBPSID+'_PRODUCE.T_ChemMonisterLOG where '+
            'LOGDATE = '+IntToStr(Trunc(Dedit_date.Date));
  lRC:=mDM.mSystemWS.GetDataSet(lSQLText);
  if Pos('Error',lRC)=0 then
  begin
    mDM.CDS_Common.XMLData:=lRC;
    mDM.CDS_Common.First;
    while not mDM.CDS_Common.Eof do
    begin
      lTempResult:=lTempResult+CalcDay(mDM.CDS_Common.FieldByName('handOverLog').AsString,pCompName);
      mDM.CDS_Common.Next;
    end;
  end;
  Result:=lTempResult;
end;
function TFm_Main.CalcWaterDayUseByDay(pCompName: string): Real;
var
  lSQLText:string;
  lRC:OleVariant;
  lTempResult,lData1,lData2:Real;
begin
  lSQLText:='select handOverLog from '+mBPSID+'_PRODUCE.T_ChemMonisterLOG where '+
            'LOGDATE = '+IntToStr(Trunc(Dedit_date.Date))+' and spell=''DAY''';
  lRC:=mDM.mSystemWS.GetDataSet(lSQLText);
  if Pos('Error',lRC)=0 then
  begin
    mDM.CDS_Common.XMLData:=lRC;
    lTempResult:=CalcDay(mDM.CDS_Common.FieldByName('handOverLog').AsString,pCompName);
  end;
  Result:=lTempResult;
end;
function TFm_Main.CalcWaterMonthUseByClass(pCompName: string): Real;
var
  lSQLText:string;
  lRC:OleVariant;
  lTempResult,lData1,lData2:Real;
begin
  lSQLText:='select handOverLog from '+mBPSID+'_PRODUCE.T_ChemMonisterLOG where '+
            'SubStr(CarryOnTime,1,7)='''+FormatDateTime('YYYY-MM',Dedit_date.Date)+'''';
  lRC:=mDM.mSystemWS.GetDataSet(lSQLText);
  if Pos('Error',lRC)=0 then
  begin
    mDM.CDS_Common.XMLData:=lRC;
    mDM.CDS_Common.First;
    while not mDM.CDS_Common.Eof do
    begin
      lTempResult:=lTempResult+CalcDay(mDM.CDS_Common.FieldByName('handOverLog').AsString,pCompName);
      mDM.CDS_Common.Next;
    end;
  end;
  Result:=lTempResult;
end;
function TFm_Main.CalcWaterMonthUseByDay(pCompName: string): Real;
var
  lSQLText:string;
  lRC:OleVariant;
  lTempResult,lData1,lData2:Real;
begin
  lSQLText:='select handOverLog from '+mBPSID+'_PRODUCE.T_ChemMonisterLOG where '+
            'SubStr(CarryOnTime,1,7)='''+FormatDateTime('YYYY-MM',Dedit_date.Date)+
            ''' and spell=''DAY''';
  lRC:=mDM.mSystemWS.GetDataSet(lSQLText);
  if Pos('Error',lRC)=0 then
  begin
    mDM.CDS_Common.XMLData:=lRC;
    mDM.CDS_Common.First;
    while not mDM.CDS_Common.Eof do
    begin
      lTempResult:=lTempResult+CalcDay(mDM.CDS_Common.FieldByName('handOverLog').AsString,pCompName);
      mDM.CDS_Common.Next;
    end;
  end;
  Result:=lTempResult;
end;
function TFm_Main.CalcYearPowerQty(pTableName, pFieldName: string): Real;
var
  TempStr,lSQLText:string;
  lRC:OleVariant;
begin
  lSQLText:='select '+pFieldName+' from '+pTableName+
            ' where SubStr(DAYCARRAYTIME,1,4)='''+
            FormatDateTime('YYYY',Now)+'''';
  lRC:=mDM.mSystemWS.GetDataSet(lSQLText);
  if Pos('Error',lRC)=0 then
  begin
    with mDM.CDS_Common do
    begin
      mDM.CDS_Common.XMLData:=lRC;
      First;
      while Not Eof  do
      begin
        TempStr:=GetValueList( '@',FieldByName(pFieldName).AsString,1);//取第一列
        Result:=Result+CalcSubStr(TempStr);
        Next;
      end;
    end;
  end;
end;
function TFm_Main.CheckHave(var pID:string;pDate: string): Boolean;
var
  lSQLText:string;
  lRC:OleVariant;
begin
  Result:=False;
  lSQLText:='select ID from '+mBPSID+'_PRODUCE.T_WatchLeaderRep where RepDate='''+
            pDate+'''';
  lRC:=mDM.mSystemWS.GetDataSet(lSQLText);
  if Pos('Error',lRC)=0 then
  begin
    mDM.CDS_Common.XMLData:=lRC;
    if mDM.CDS_Common.RecordCount<>0 then
    begin
      Result:=True;
      pID:=mDM.CDS_Common.FieldByName('ID').AsString;
    end;
  end;
end;
function TFm_Main.CheckStatus:Boolean;
var
  i, j: Integer;
  lMaskEdit: TcxMaskEdit;
  lTextEdit: TcxTextEdit;
begin
  Result:=False;
  j := 0;
  for i := 1 to ME_COUNT do
  begin
    lMaskEdit := FindComponent('ME'+IntToStr(i)) as TcxMaskEdit;
    if lMaskEdit <> nil then
    begin
      lMaskEdit.Style.Color := clWindow;
      if (Trim(lMaskEdit.Text) = '')and(lMaskEdit.Hint<>'1') then
      begin
        lMaskEdit.Style.Color := clRed;
        j := j + 1;
      end;
    end;
  end;
  if j > 0 then
  begin
    ShowMessage('红色为必填参数');
    Exit;
  end;
  j := 0;
  for i := 1 to MEW_COUNT do
  begin
    lMaskEdit := FindComponent('MEW'+IntToStr(i)) as TcxMaskEdit;
    if lMaskEdit <> nil then
    begin
      lMaskEdit.Style.Color := clWindow;
      if (Trim(lMaskEdit.Text) = '')and(lMaskEdit.Hint<>'1') then
      begin
        lMaskEdit.Style.Color := clRed;
        j := j + 1;
      end;
    end;
  end;
  if j > 0 then
  begin
    ShowMessage('红色为必填参数');
    Exit;
  end;
  j := 0;
  for i := 1 to MEC_COUNT do
  begin
    lMaskEdit := FindComponent('MEC'+IntToStr(i)) as TcxMaskEdit;
    if lMaskEdit <> nil then
    begin
      lMaskEdit.Style.Color := clWindow;
      if (Trim(lMaskEdit.Text) = '')and(lMaskEdit.Hint<>'1') then
      begin
        lMaskEdit.Style.Color := clRed;
        j := j + 1;
      end;
    end;
  end;
  if j > 0 then
  begin
    ShowMessage('红色为必填参数');
    Exit;
  end;
  j := 0;
  for i := 1 to TE_COUNT do
  begin
    lTextEdit := FindComponent('TE'+IntToStr(i)) as TcxTextEdit;
    if lTextEdit <> nil then
    begin
      lTextEdit.Style.Color := clWindow;
      if (Trim(lTextEdit.Text) = '')and(lTextEdit.Hint<>'1') then
      begin
        lTextEdit.Style.Color := clRed;
        j := j + 1;
      end;
    end;
  end;
  if j > 0 then
  begin
    ShowMessage('红色为必填参数');
    Exit;
  end;
 
  Result:=True;
end;
procedure TFm_Main.ClearData;
var
  i, j: Integer;
  lcxTextEdit: TcxTextEdit;
  lMaskEdit: TcxMaskEdit;
begin
  Label_FillDate.Caption:='';
  Label_FillWatcher.Caption:='';
  for i := 1 to TE_COUNT do
  begin
    lcxTextEdit := FindComponent('TE'+IntToStr(i)) as TcxTextEdit;
    if lcxTextEdit <> nil then
    begin
      lcxTextEdit.Text := '';
    end;
  end;
  for i := 1 to ME_COUNT do
  begin
    lMaskEdit := FindComponent('ME'+IntToStr(i)) as TcxMaskEdit;
    if lMaskEdit <> nil then
    begin
      lMaskEdit.Text := '';
    end;
  end;
  for i := 1 to MEW_COUNT do
  begin
    lMaskEdit := FindComponent('MEW'+IntToStr(i)) as TcxMaskEdit;
    if lMaskEdit <> nil then
    begin
      lMaskEdit.Text := '';
    end;
  end;
 
  for i := 1 to MEC_COUNT do
  begin
    lMaskEdit := FindComponent('MEC'+IntToStr(i)) as TcxMaskEdit;
    if lMaskEdit <> nil then
    begin
      lMaskEdit.Text := '';
    end;
  end;
  Memo_NotePad.Lines.Clear;
end;
function TFm_Main.Devide(Num1, Num2: string): Real;
var
  lNum1,lNum2:Real;
begin
  try
    lNum1:=StrToFloat(Num1);
  except
    lNum1:=0;
  end;
  try
    lNum2:=StrToFloat(Num2);
  except
    lNum2:=0;
  end;
  if (lNum1=0)or (lNum2=0) then
  begin
    Result:=0;
  end
  else
  begin
    Result:=lNum1/lNum2
  end;
end;
procedure TFm_Main.DisplayEnginePowerQty;
var
  lSQLText:string;
  lRC:OleVariant;
  lData,lSourceStr:string;
  j,i:Integer;
  lTextEdit: TcxCustomTextEdit;
begin
  //显示#1机组发电量
  {lSQLText:='select ID from '+mBPSID+'_PRODUCE.T_FIRSTElECREC where '+
            'LOGDATE = '+IntToStr(Trunc(Dedit_date.Date));
  lRC:=mDM.mSystemWS.GetDataSet(lSQlText);
  if Pos('Error',lRC)=0 then
  begin
    mDM.CDS_Common.XMLData:=lRC;
    GetSourceStrByID(mDM.CDS_Common.FieldByName('ID').AsString,mBPSID+
                 '_PRODUCE.T_FIRSTElECREC','ONEDATA',lSourceStr);
    lSourceStr:=GetValueList(lSourceStr,5);//
    DevideString(lSourceStr,'*',lData,lSourceStr);
    DevideString(lSourceStr,'*',lData,lSourceStr);
    j:=1;
    GetPowerInfo(lSourceStr,'T_FIRSTElECREC','FIR',5);
    for i := 49 to 72 do
    begin
      DevideString(lSourceStr,'*',lData,lSourceStr);
      lTextEdit := FindComponent('ME'+IntToStr(i)) as TcxCustomTextEdit;
      if lTextEdit <> nil then
      begin
        lTextEdit.Text := IsNull(lData,'0');
      end;
    end;
  end;}
  GetPowerInfo(lSourceStr,'T_FIRSTElECREC','FIR',5);
  DevideString(lSourceStr,'*',lData,lSourceStr);
  for i := 49 to 72 do
  begin
    DevideString(lSourceStr,'*',lData,lSourceStr);
    lTextEdit := FindComponent('ME'+IntToStr(i)) as TcxCustomTextEdit;
    if lTextEdit <> nil then
    begin
      lTextEdit.Text := IsNull(lData,'0');
    end;
  end;
  //显示#2机组发电量
  GetPowerInfo(lSourceStr,'T_FIRSTElECREC','SEC',5);
  DevideString(lSourceStr,'*',lData,lSourceStr);
  for i := 73 to 96 do
  begin
    DevideString(lSourceStr,'*',lData,lSourceStr);
    lTextEdit := FindComponent('ME'+IntToStr(i)) as TcxCustomTextEdit;
    if lTextEdit <> nil then
    begin
      lTextEdit.Text := IsNull(lData,'0');
    end;
  end;
  {lSQLText:='select ID from '+mBPSID+'_PRODUCE.T_FIRSTElECREC where '+
            'subStr(DAYCARRAYTIME,1,10)='''+FormatDateTime('YYYY-MM-DD',Dedit_date.Date)+'''';
  lRC:=mDM.mSystemWS.GetDataSet(lSQlText);
  if Pos('Error',lRC)=0 then
  begin
    mDM.CDS_Common.XMLData:=lRC;
    GetSourceStrByID(mDM.CDS_Common.FieldByName('ID').AsString,mBPSID+
                 '_PRODUCE.T_FIRSTElECREC','TWODATA',lSourceStr);
    lSourceStr:=GetValueList( '@',lSourceStr,1);
    for i := 73 to 96 do
    begin
      DevideString(lSourceStr,'*',lData,lSourceStr);
      lTextEdit := FindComponent('ME'+IntToStr(i)) as TcxCustomTextEdit;
      if lTextEdit <> nil then
      begin
        lTextEdit.Text := IsNull(lData,'0');
      end;
    end;
  end;}
  //显示#3机组发电量
  GetPowerInfo(lSourceStr,'T_SECElECREC','THREE',5);
  DevideString(lSourceStr,'*',lData,lSourceStr);
  for i := 97 to 120 do
  begin
    DevideString(lSourceStr,'*',lData,lSourceStr);
    lTextEdit := FindComponent('ME'+IntToStr(i)) as TcxCustomTextEdit;
    if lTextEdit <> nil then
    begin
      lTextEdit.Text := IsNull(lData,'0');
    end;
  end;
  {lSQLText:='select ID from '+mBPSID+'_PRODUCE.T_SECElECREC where '+
            'subStr(DAYCARRAYTIME,1,10)='''+FormatDateTime('YYYY-MM-DD',Dedit_date.Date)+'''';
  lRC:=mDM.mSystemWS.GetDataSet(lSQlText);
  if Pos('Error',lRC)=0 then
  begin
    mDM.CDS_Common.XMLData:=lRC;
    GetSourceStrByID(mDM.CDS_Common.FieldByName('ID').AsString,mBPSID+
                 '_PRODUCE.T_SECElECREC','ONEDATA',lSourceStr);
    lSourceStr:=GetValueList( '@',lSourceStr,1);
    for i := 97 to 120 do
    begin
      DevideString(lSourceStr,'*',lData,lSourceStr);
      lTextEdit := FindComponent('ME'+IntToStr(i)) as TcxCustomTextEdit;
      if lTextEdit <> nil then
      begin
        lTextEdit.Text := IsNull(lData,'0');
      end;
    end;
  end;}
  //显示#4机组发电量
  GetPowerInfo(lSourceStr,'T_SECElECREC','FOUR',5);
  DevideString(lSourceStr,'*',lData,lSourceStr);
  for i := 121 to 144 do
  begin
    DevideString(lSourceStr,'*',lData,lSourceStr);
    lTextEdit := FindComponent('ME'+IntToStr(i)) as TcxCustomTextEdit;
    if lTextEdit <> nil then
    begin
      lTextEdit.Text := IsNull(lData,'0');
    end;
  end;
  {lSQLText:='select ID from '+mBPSID+'_PRODUCE.T_SECElECREC where '+
            'subStr(DAYCARRAYTIME,1,10)='''+FormatDateTime('YYYY-MM-DD',Dedit_date.Date)+'''';
  lRC:=mDM.mSystemWS.GetDataSet(lSQlText);
  if Pos('Error',lRC)=0 then
  begin
    mDM.CDS_Common.XMLData:=lRC;
    GetSourceStrByID(mDM.CDS_Common.FieldByName('ID').AsString,mBPSID+
                 '_PRODUCE.T_SECElECREC','TWODATA',lSourceStr);
    lSourceStr:=GetValueList( '@',lSourceStr,1);
    for i := 121 to 144 do
    begin
      DevideString(lSourceStr,'*',lData,lSourceStr);
      lTextEdit := FindComponent('ME'+IntToStr(i)) as TcxCustomTextEdit;
      if lTextEdit <> nil then
      begin
        lTextEdit.Text := IsNull(lData,'0');
      end;
    end;
  end;}
end;
procedure TFm_Main.DrowPic;
var
  lObjectName:string;
  j,i:Integer;
  lTextEdit: TcxCustomTextEdit;
  lArrFieldName:array[0..23] of string;
  lSQLText:widestring;
begin
  lObjectName:='pkind';
  //setlength(lArrFieldName,23);
  for I := 0 to 23 do
  begin
    lArrFieldName[i]:='时刻'+IntToStr(i+1);
  end;
  lSQLText:='select distinct ''#1机组'' pkind,';
  j:=1;
  for I := 49 to 72 do
  begin
    lTextEdit := FindComponent('ME'+IntToStr(i)) as TcxCustomTextEdit;
    lSQLText:=lSQLText+IsNull(lTextEdit.Text,'0')+' 时刻'+IntToStr(j)+', ';
    j:=j+1;
  end;
  lSQLText:=lSQLText+' ''机组'' as pKind1 from '+mBPSID+'_PRODUCE.t_watchleaderrep ';
  lSQLText:=lSQLText+' union all ';
                                     
  lSQLText:=lSQLText+'select distinct ''#2机组'' pkind,';
  j:=1;
  for I := 73 to 96 do
  begin
    lTextEdit := FindComponent('ME'+IntToStr(i)) as TcxCustomTextEdit;
    lSQLText:=lSQLText+IsNull(lTextEdit.Text,'0')+' 时刻'+IntToStr(j)+', ';
    j:=j+1;
  end;
  lSQLText:=lSQLText+' ''机组'' as pKind1 from '+mBPSID+'_PRODUCE.t_watchleaderrep ';
  lSQLText:=lSQLText+' union all ';
  lSQLText:=lSQLText+'select distinct ''#3机组'' pkind,';
  j:=1;
  for I := 97 to 120 do
  begin
    lTextEdit := FindComponent('ME'+IntToStr(i)) as TcxCustomTextEdit;
    lSQLText:=lSQLText+IsNull(lTextEdit.Text,'0')+' 时刻'+IntToStr(j)+', ';
    j:=j+1;
  end;
  lSQLText:=lSQLText+' ''机组'' as pKind1 from '+mBPSID+'_PRODUCE.t_watchleaderrep ';
  lSQLText:=lSQLText+' union all ';
  lSQLText:=lSQLText+'select distinct ''#4机组'' pkind,';
  j:=1;
  for I := 121 to 144 do
  begin
    lTextEdit := FindComponent('ME'+IntToStr(i)) as TcxCustomTextEdit;
    lSQLText:=lSQLText+IsNull(lTextEdit.Text,'0')+' 时刻'+IntToStr(j)+', ';
    j:=j+1;
  end;
  lSQLText:=lSQLText+' ''机组'' as pKind1 from '+mBPSID+'_PRODUCE.t_watchleaderrep ';
  {lSQLText:=lSQLText+' union all ';
  lSQLText:=lSQLText+'select distinct ''合计'' pkind,';
  j:=1;
  for I := 25 to 48 do
  begin
    lTextEdit := FindComponent('ME'+IntToStr(i)) as TcxCustomTextEdit;
    lSQLText:=lSQLText+IsNull(lTextEdit.Text,'0')+' 时刻'+IntToStr(j)+', ';
    j:=j+1;
  end;
  lSQLText:=lSQLText+' ''机组'' as pKind1 from '+mBPSID+'_PRODUCE.t_watchleaderrep ';}
 
  mDM.CDS_DrowPic.XMLData:=mDM.mSystemWS.GetDataSet(lSQLText);
  gFillChartArrTotal(mDM.CDS_DrowPic,lObjectName,lArrFieldName);
  gDrawLineSeries(chtMain,Fm_Main);
  //lArrFieldName := nil;
end;
function TFm_Main.FetchCoalInfo(pCompName: string): Real;
var
  lSQLText:string;
  lRC:OleVariant;
  TempResult:Real;
begin
  lSQLText:='select handOverLog from '+mBPSID+'_PRODUCE.T_ADMINISTERLOG where '+
            'LogDate='+IntToStr(Trunc(Dedit_date.Date))+' and spell=''BEFORENIGHT''';
  lRC:=mDM.mSystemWS.GetDataSet(lSQLText);
  if pos('Error',lRC)=0 then
  begin
    with mDM.CDS_Common do
    begin
      XMLData:=lRC;
      TempResult:=CalcDay(FieldByName('handOverLog').AsString,pCompName);
    end;
  end;
  Result:=TempResult;
end;
function TFm_Main.FetchDataFromRecord(pTableName, pFieldName: string;
  pIndex: Integer): string;
var
  lSQLText:string;
  lRC:OleVariant;
  lCalc1,lCalc2,lTempData,lPreData,lData,lSourceStr:string;
  j,i:Integer;
begin
  lSQLText:='select '+pFieldName+' from '+pTableName+' where '+
            'LOGDATE = '+IntToStr(Trunc(Dedit_date.Date));
  lRC:=mDM.mSystemWS.GetDataSet(lSQlText);
  if Pos('Error',lRC)=0 then
  begin
    mDM.CDS_Common.XMLData :=lRC;
    lSourceStr:=mDM.CDS_Common.FieldByName(pFieldName).AsString;
    lSourceStr:=GetValueList( '@',lSourceStr,pIndex);
    DevideString(lSourceStr,'*',lPreData,lSourceStr);
    if lSourceStr='' then
      lPreData:='0'
    else
      DevideString(lSourceStr,'*',lPreData,lSourceStr);
  end;
end;
function TFm_Main.FetchFacUsePowerQty(pTable,pHead:string;pIndex:Integer): Real;
var
  lData1,lData2:String;
begin
  lData1:=FetchDataFromRecord(pTable,pHead+'1',pIndex);
  lData1:=FetchDataFromRecord(pTable,pHead+'24',pIndex);
  Result:=StrToFloat(IsNull(lData2,'0'))-StrToFloat(IsNull(lData1,'0'));
end;
function TFm_Main.FetchLastDayData(pFieldName, pCompName: string):Real;
var
  lTempStr,lSQLText:string;
  lRC:OleVariant;
begin
  lSQLText:='select '+pFieldName+' from '+mBPSID+'_PRODUCE.T_WatchLeaderRep '+
            'WHERE RepDate='''+FormatDateTime('YYYY-MM-DD',Dedit_date.Date-1)+'''';
  lRC:=mDM.mSystemWS.GetDataSet(lSQLText);
  if Pos('Error',lRC)=0 then
  begin
    mDM.CDS_Common.XMLData:=lRC;
    lTempStr:=FloatToStr(CalcDay(mDM.CDS_Common.FieldByName(pFieldName).AsString,pCompName));
  end;
  Result:=StrToFloat(IsNull(lTempStr,'0'));
end;
procedure TFm_Main.FetchNotPad;
var
  lSQLText:string;
  lRC:OleVariant;
  Tempstr:string;
begin
  lSQLText:='select NotePad from '+mBPSID+'_PRODUCE.T_ADMINISTERLOG where '+
            'LogDate='+IntToStr(Trunc(Dedit_date.Date));
  lRC:=mDM.mSystemWS.GetDataSet(lSQLText);
  if pos('Error',lRC)=0 then
  begin
    with mDM.CDS_Common do
    begin
      XMLData:=lRC;
      First;
      TempStr:='生产概叙'+#13#10+
'==============================================================================='+
'===============================================================================';
      while not Eof  do
      begin
        TempStr:=TempStr+#13#10+
                 ReplaceString(1,FieldByName('NotePad').AsString);
        Next;
      end;
    end;
  end;
  lSQLText:='select TaskPad,FlawPad from '+mBPSID+'_PRODUCE.T_ADMINISTERLOG where '+
            'LogDate='+IntToStr(Trunc(Dedit_date.Date))+' and spell=''BEFORENIGHT''';
  lRC:=mDM.mSystemWS.GetDataSet(lSQLText);
  if Pos('Error',lRC)=0 then
  begin
    mDM.CDS_Common.XMLData:=lRC;
    TempStr:=TempStr+#13#10+'设备作业情况'+#13#10+
'==============================================================================='+
'===============================================================================';
    TempStr:=TempStr+#13#10+ReplaceString(1,mDM.CDS_Common.FieldByName('TaskPad').AsString);
    TempStr:=TempStr+#13#10+'设备缺陷情况'+#13#10+
'==============================================================================='+
'===============================================================================';
    TempStr:=TempStr+#13#10+ReplaceString(1,mDM.CDS_Common.FieldByName('FlawPad').AsString);
  end;
  Memo_NotePad.Text:=TempStr;
end;
procedure TFm_Main.FormDestroy(Sender: TObject);
begin
  mDM.Free;
end;
procedure TFm_Main.FormShow(Sender: TObject);
var
  lDate,lID:string;
begin
  mDM := TDM.Create(Self);
  mDM.mBPSID := mBPSID;
  mDM.Initialize;
  cxPC.ActivePageIndex:=1;
  lDate:=FormatDateTime('YYYY-MM-DD',Now-1);
  Dedit_date.Date:=Now-1;
  if CheckHave(lID,lDate) then
  begin
   ShowRepInfo(lID);
  end;
  Timer_StateCheck.Enabled := true;
end;
procedure TFm_Main.GetPowerInfo(var pStr: string;pTableName,pHead:string;pIndex:Integer);
var
  lSQLText:string;
  lRC:OleVariant;
  lCalc1,lCalc2,lTempData,lPreData,lData,lSourceStr:string;
  j,i:Integer;
begin
//取前一天第24时的数据
  lSQLText:='select '+pHead+'24DATA from '+mBPSID+'_PRODUCE.'+pTableName+' where '+
            'LOGDATE = '+IntToStr(Trunc(Dedit_date.Date-1));
  lRC:=mDM.mSystemWS.GetDataSet(lSQlText);
  if Pos('Error',lRC)=0 then
  begin
    //取前一天24的pIndex列的数据(返回值类似 Col2*6211.67000)
    mDM.CDS_Common.XMLData :=lRC;
    lSourceStr:=mDM.CDS_Common.FieldByName(pHead+'24DATA').AsString;
    lSourceStr:=GetValueList( '@',lSourceStr,pIndex);
    DevideString(lSourceStr,'*',lPreData,lSourceStr);
    if lSourceStr='' then
      lPreData:='0'
    else
      DevideString(lSourceStr,'*',lPreData,lSourceStr);
  end;
//取24时的数据
  for i := 1 to 24 do
  begin
    lSQLText:='select '+pHead+IntToStr(i)+'DATA from '+mBPSID+'_PRODUCE.'+pTableName+' where '+
              'LOGDATE = '+IntToStr(Trunc(Dedit_date.Date));
    lRC:=mDM.mSystemWS.GetDataSet(lSQlText);
    if Pos('Error',lRC)=0 then
    begin
      //取每一时刻的pIndex列的数据(返回值类似 Col2*6211.67000)
      mDM.CDS_Common.XMLData :=lRC;
      lSourceStr:=mDM.CDS_Common.FieldByName(pHead+IntToStr(i)+'DATA').AsString;
      lSourceStr:=GetValueList( '@',lSourceStr,pIndex);
      DevideString(lSourceStr,'*',lTempData,lSourceStr);
      if lSourceStr='' then
        lTempData:='0'
      else
        lTempData:=lSourceStr;
      if i=1 then
        lData:=lTempData
      else
        lData:=lData+'*'+lTempData;
    end;
  end;
  lData:=lPreData+'*'+lData;//存储了25个时刻的瞬时值
  while Pos('*',lData)<>0 do
  begin
    DevideString(lData,'*',lCalc1,lData);
    DevideString(lData,'*',lCalc2,lData);
    pStr:=pStr+'*'+FloatToStr(StrToFloat(IsNull(lCalc2,'0'))-StrToFloat(IsNull(lCalc1,'0')));
  end;
end;
procedure TFm_Main.GetSourceStrByID(pID,pTableName, pFieldName: string;
  var ResultStr: string);
var
  lSQLText:string;
  lRC:OleVariant;
begin
  lSQLText:='select '+pFieldName+' from '+pTableName+' where ID='+IsNull(pID,'-9999');
  lRC:=mDM.mSystemWS.GetDataSet(lSQLText);
  if Pos('Error',lRC)=0 then
  begin
    mDM.CDS_Common.XMLData:=lRC;
    ResultStr:=mDM.CDS_Common.FieldByName(pFieldName).AsString;
  end;
end;
function TFm_Main.GetStatus(var pStatusStr: string; phead: string;
  Pcount: Integer): Boolean;
var
  i, j: Integer;
  lTextEdit: TcxCustomTextEdit;
begin
  for i := 1 to pcount do
  begin
    lTextEdit := FindComponent(phead+IntToStr(i)) as TcxCustomTextEdit;
    if lTextEdit <> nil then
    begin
      if pStatusStr <> ''then
      begin
        pStatusStr := pStatusStr + '*';
      end;
      pStatusStr := pStatusStr + lTextEdit.Name + '*' + lTextEdit.Text;
    end;
  end;
end;
function TFm_Main.GetValueList(DivStr,pSource: string; pIndex: Integer): string;
var
  i:Integer;
  ResultSource,lSource:string;
begin
  lSource:=pSource;
  for I := 1 to pIndex+1 do
  begin
    DevideString(lSource,DivStr,ResultSource,lSource);
  end;
  Result:=ResultSource;
end;
function TFm_Main.IsNull(pSoureStr, RecStr:string): string;
begin
  if pSoureStr='' then
    Result:=RecStr
  else
    Result:=pSoureStr;
end;
procedure TFm_Main.Label2Click(Sender: TObject);
var
  FillNum,BegNum,i,j:Integer;
  TempResult:Real;
  lFillEdit,lTextEdit: TcxCustomTextEdit;
begin
  for i := 25 to 48 do
  begin
    TempResult:=0;
    FillNum:=i;
    BegNum:=i;
    lFillEdit := FindComponent('ME'+IntToStr(i)) as TcxCustomTextEdit;
    for j := 1 to 4 do
    begin
      BegNum:=BegNum+24;
      lTextEdit := FindComponent('ME'+IntToStr(BegNum)) as TcxCustomTextEdit;
      TempResult:=TempResult+StrToFloat(IsNull(lTextEdit.Text,'0'));
    end;
    lFillEdit.Text:=FloatToStr(TempResult);
  end;
end;
procedure TFm_Main.Label2MouseEnter(Sender: TObject);
begin
  Label2.Cursor:=crHandPoint;
  Label2.Font.Color:=clRed;
end;
procedure TFm_Main.Label2MouseLeave(Sender: TObject);
begin
  Label2.Cursor:=crDefault;
  Label2.Font.Color:=clblack;
end;
procedure TFm_Main.ME145DblClick(Sender: TObject);
var
  i:Integer;
  TempResult:Real;
  lTextEdit: TcxCustomTextEdit;
begin
  for i := 1 to 24 do
  begin
    lTextEdit := FindComponent('ME'+IntToStr(i)) as TcxCustomTextEdit;
    TempResult:=TempResult+StrToFloat(IsNull(lTextEdit.Text,'0'));
  end;
  ME145.Text:=FloatToStr(TempResult);
end;
procedure TFm_Main.ME146DblClick(Sender: TObject);
var
  i:Integer;
  TempResult:Real;
  lTextEdit: TcxCustomTextEdit;
begin
  for i := 25 to 48 do
  begin
    lTextEdit := FindComponent('ME'+IntToStr(i)) as TcxCustomTextEdit;
    TempResult:=TempResult+StrToFloat(IsNull(lTextEdit.Text,'0'));
  end;
  ME146.Text:=FloatToStr(TempResult);
end;
procedure TFm_Main.ME147DblClick(Sender: TObject);
var
  i:Integer;
  TempResult:Real;
  lTextEdit: TcxCustomTextEdit;
begin
  for i := 49 to 72 do
  begin
    lTextEdit := FindComponent('ME'+IntToStr(i)) as TcxCustomTextEdit;
    TempResult:=TempResult+StrToFloat(IsNull(lTextEdit.Text,'0'));
  end;
  ME147.Text:=FloatToStr(TempResult);
end;
procedure TFm_Main.ME148DblClick(Sender: TObject);
var
  i:Integer;
  TempResult:Real;
  lTextEdit: TcxCustomTextEdit;
begin
  for i := 73 to 96 do
  begin
    lTextEdit := FindComponent('ME'+IntToStr(i)) as TcxCustomTextEdit;
    TempResult:=TempResult+StrToFloat(IsNull(lTextEdit.Text,'0'));
  end;
  ME148.Text:=FloatToStr(TempResult);
end;
procedure TFm_Main.ME149DblClick(Sender: TObject);
var
  i:Integer;
  TempResult:Real;
  lTextEdit: TcxCustomTextEdit;
begin
  for i := 97 to 120 do
  begin
    lTextEdit := FindComponent('ME'+IntToStr(i)) as TcxCustomTextEdit;
    TempResult:=TempResult+StrToFloat(IsNull(lTextEdit.Text,'0'));
  end;
  ME149.Text:=FloatToStr(TempResult);
end;
procedure TFm_Main.ME150DblClick(Sender: TObject);
var
  i:Integer;
  TempResult:Real;
  lTextEdit: TcxCustomTextEdit;
begin
  for i := 121 to 144 do
  begin
    lTextEdit := FindComponent('ME'+IntToStr(i)) as TcxCustomTextEdit;
    TempResult:=TempResult+StrToFloat(IsNull(lTextEdit.Text,'0'));
  end;
  ME150.Text:=FloatToStr(TempResult);
end;
procedure TFm_Main.MEW13DblClick(Sender: TObject);
var
  i:Integer;
  TempResult:Real;
  lTextEdit: TcxCustomTextEdit;
begin
  for i := 5 to 12 do
  begin
    lTextEdit := FindComponent('MEW'+IntToStr(i)) as TcxCustomTextEdit;
    TempResult:=TempResult+StrToFloat(IsNull(lTextEdit.Text,'0'));
  end;
  MEW13.Text:=FloatToStr(TempResult);
end;
procedure TFm_Main.MEW17DblClick(Sender: TObject);
var
  i:Integer;
  TempResult:Real;
  lTextEdit: TcxCustomTextEdit;
begin
  for i := 14 to 16 do
  begin
    lTextEdit := FindComponent('MEW'+IntToStr(i)) as TcxCustomTextEdit;
    TempResult:=TempResult+StrToFloat(IsNull(lTextEdit.Text,'0'));
  end;
  MEW17.Text:=FloatToStr(TempResult);
end;
procedure TFm_Main.MEW26DblClick(Sender: TObject);
var
  i:Integer;
  TempResult:Real;
  lTextEdit: TcxCustomTextEdit;
begin
  for i := 18 to 25 do
  begin
    lTextEdit := FindComponent('MEW'+IntToStr(i)) as TcxCustomTextEdit;
    TempResult:=TempResult+StrToFloat(IsNull(lTextEdit.Text,'0'));
  end;
  MEW26.Text:=FloatToStr(TempResult);
end;
procedure TFm_Main.MEW4DblClick(Sender: TObject);
var
  i:Integer;
  TempResult:Real;
  lTextEdit: TcxCustomTextEdit;
begin
  for i := 1 to 3 do
  begin
    lTextEdit := FindComponent('MEW'+IntToStr(i)) as TcxCustomTextEdit;
    TempResult:=TempResult+StrToFloat(IsNull(lTextEdit.Text,'0'));
  end;
  MEW4.Text:=FloatToStr(TempResult);
end;
procedure TFm_Main.PrintLogInfo;
var
  TempStr,printTitle:string;
  eclApp,WorkBook,Range :Variant;
  i,j,k,recountcount,recountcount1:integer;
  lComponentName: String;
  lTextEdit: TcxCustomTextEdit;
  lHeight,lWidth:OleVariant;
begin
  //设置打印标题名称
  ProB_Print.Position:=0;
  printTitle:=FormatDateTime('YYYY-MM-DD',Dedit_date.Date)+'日 阜新金山热电厂值长日报表';
  if not CheckStatus then
    Exit;
  //创建OLE应用 ,添加新工作簿
  try
    eclApp := CreateOleObject('Excel.Application');
    WorkBook:=CreateOleobject('Excel.Sheet');
    Workbook := eclApp.Workbooks.Add(-4167);
  except
    ShowMessage('您尚未安装Excel!');
  end;
  for i:=1 to 3 do
  begin
    eclApp.worksheets.add;
  end;
  ProB_Print.Position:=1;
  //设置标题
  try
    EclApp.worksheets[1].PageSetup.PaperSize:=xlPaperA3;
  except
  end;
  EclApp.worksheets[1].PageSetup.Orientation := xlLandscape;
  EclApp.ActiveWindow.Zoom:=75;
  ProB_Print.Position:=5;
  eclApp.Caption := printTitle;
  eclApp.worksheets[1].name:= printTitle;
  eclApp.worksheets[1].Rows[1].RowHeight := 20; // 第一行标题高度为20高度
  range:=eclApp.worksheets[1].range[eclApp.worksheets[1].cells[1,1],
         eclApp.worksheets[1].cells[1,54]];
  range.merge;
  eclApp.worksheets[1].Cells[1,1].Value := printTitle;
  Range.HorizontalAlignment := xlCenter;
  Range.VerticalAlignment := xlCenter;
  Range.Font.size := 18;
  Range.Font.Bold:=True;
  Range.Font.UnderLine:=True;
  ProB_Print.Position:=10;
  //初始化工作区表格列宽
  eclApp.worksheets[1].Columns[1].ColumnWidth := 1.5;
  for i := 2 to 52 do
  begin
    eclApp.worksheets[1].Columns[i].ColumnWidth := 3.4;
  end;
  eclApp.worksheets[1].Columns[53].ColumnWidth := 8.5;
  eclApp.worksheets[1].Columns[54].ColumnWidth := 1;
  ProB_Print.Position:=15;
  //写填报日期
  range:=eclApp.worksheets[1].range[eclApp.worksheets[1].cells[2,2],
                                    eclApp.worksheets[1].cells[2,9]];
  range.merge;
  Range.Font.size:=10;
  eclApp.worksheets[1].Cells[2,2].Value :='填报日期:'+Label_FillDate.Caption;
  Range.HorizontalAlignment := xlLeft;
  Range.VerticalAlignment := xlCenter;
  ProB_Print.Position:=20;
  //写填报值长
  range:=eclApp.worksheets[1].range[eclApp.worksheets[1].cells[2,48],
                                    eclApp.worksheets[1].cells[2,53]];
  range.merge;
  Range.Font.size:=10;
  eclApp.worksheets[1].Cells[2,48].Value :='填报值长: '+Label_FillWatcher.Caption;
  Range.HorizontalAlignment := xlLeft;
  Range.VerticalAlignment := xlCenter;
  ProB_Print.Position:=25;
  //设置发电信息表头
  for I := 3 to 9 do
  begin
    range:=eclApp.worksheets[1].range[eclApp.worksheets[1].cells[i,2],
                                      eclApp.worksheets[1].cells[i,4]];
    range.merge;
    Range.Font.Bold:=True;
    Range.Font.size:=9;
    case i of
      3: TempStr:='时     间';
      4: TempStr:='发电计划';
      5: TempStr:='实际完成合计';
      6: TempStr:='#1实际完成';
      7: TempStr:='#2实际完成';
      8: TempStr:='#3实际完成';
      9: TempStr:='#4实际完成';
    end;
    eclApp.worksheets[1].Cells[i,2].Value :=TempStr;
    Range.HorizontalAlignment := xlCenter;
    Range.VerticalAlignment := xlCenter;
  end;
  ProB_Print.Position:=30;
  //设置单元格的边框线 1-左    2-右   3-顶    4-底   5-斜( \ )     6-斜( / )
  eclApp.ActiveSheet.Range['B3:BA56'].Borders[1].Weight := 2;
  eclApp.ActiveSheet.Range['B3:BA56'].Borders[2].Weight := 2;
  eclApp.ActiveSheet.Range['B3:BA56'].Borders[3].Weight := 2;
  eclApp.ActiveSheet.Range['B3:BA56'].Borders[4].Weight := 2;
  //设置发电信息的外边框线
  eclApp.ActiveSheet.Range['B3:BA3'].Borders[3].Weight := 3;
  eclApp.ActiveSheet.Range['B3:B9'].Borders[1].Weight := 3;
  eclApp.ActiveSheet.Range['B9:BA9'].Borders[4].Weight := 3;
  eclApp.ActiveSheet.Range['BA3:BA9'].Borders[2].Weight := 3;
ProB_Print.Position:=35;
//***************************初始化并填写发电信息*******************************
  //格式化小计一列
  range:=eclApp.worksheets[1].range[eclApp.worksheets[1].cells[3,53],
                                    eclApp.worksheets[1].cells[9,53]];
  Range.Font.Bold:=True;
  Range.HorizontalAlignment := xlCenter;
  Range.VerticalAlignment := xlCenter;
ProB_Print.Position:=36;
  //初始化并填写时间行
  k:=1;
  for i := 5 to 52 do//24小时列头
  begin
    if odd(i) then
    begin
      j:=i;
      range:=eclApp.worksheets[1].range[eclApp.worksheets[1].cells[3,j],
                                        eclApp.worksheets[1].cells[3,j+1]];
      range.merge;
      Range.Font.Bold:=True;
      eclApp.worksheets[1].Cells[3,j].Value :=IntToStr(k);
      Range.HorizontalAlignment := xlCenter;
      Range.VerticalAlignment := xlCenter;
      k:=k+1;
    end;
  end;
  EclApp.worksheets[1].Cells[3,53].Value :='小计';
ProB_Print.Position:=37;
  //初始化并填写发电计划
  k:=1;
  for i := 5 to 52 do
  begin
    lTextEdit := FindComponent('ME'+IntToStr(k)) as TcxCustomTextEdit;
    if lTextEdit <> nil then
    begin
      TempStr :=lTextEdit.Text;
    end
    else
      TempStr:=' ';
    if odd(i) then
    begin
      j:=i;
      range:=eclApp.worksheets[1].range[eclApp.worksheets[1].cells[4,j],
                                        eclApp.worksheets[1].cells[4,j+1]];
      range.merge;
      eclApp.worksheets[1].Cells[4,j].Value:=TempStr;
      Range.HorizontalAlignment := xlCenter;
      Range.VerticalAlignment := xlCenter;
      k:=k+1;
    end;
  end;
  eclApp.worksheets[1].Cells[4,53].Value:=ME145.Text;
ProB_Print.Position:=38;
  //初始化并填写完成合计
  k:=25;
  for i := 5 to 52 do
  begin
    lTextEdit := FindComponent('ME'+IntToStr(k)) as TcxCustomTextEdit;
    if lTextEdit <> nil then
    begin
      TempStr :=lTextEdit.Text;
    end
    else
      TempStr:=' ';
    if odd(i) then
    begin
      j:=i;
      range:=eclApp.worksheets[1].range[eclApp.worksheets[1].cells[5,j],
                                        eclApp.worksheets[1].cells[5,j+1]];
      range.merge;
      Range.Font.Color:=clRed;
      eclApp.worksheets[1].Cells[5,j].Value:=TempStr;
      Range.HorizontalAlignment := xlCenter;
      Range.VerticalAlignment := xlCenter;
      k:=k+1;
    end;
  end;
  EclApp.worksheets[1].Cells[5,53].Value:=ME146.Text;
ProB_Print.Position:=39;
  //初始化并填写#1机组完成
  k:=49;
  for i := 5 to 52 do
  begin
    lTextEdit := FindComponent('ME'+IntToStr(k)) as TcxCustomTextEdit;
    if lTextEdit <> nil then
    begin
      TempStr :=lTextEdit.Text;
    end
    else
      TempStr:=' ';
    if odd(i) then
    begin
      j:=i;
      range:=eclApp.worksheets[1].range[eclApp.worksheets[1].cells[6,j],
                                        eclApp.worksheets[1].cells[6,j+1]];
      range.merge;
      Range.Font.Color:=clBlue;
      eclApp.worksheets[1].Cells[6,j].Value:=TempStr;
      Range.HorizontalAlignment := xlCenter;
      Range.VerticalAlignment := xlCenter;
      k:=k+1;
    end;
  end;
  EclApp.worksheets[1].Cells[6,53].Value:=ME147.Text;
ProB_Print.Position:=40;
  //初始化并填写#2机组完成
  k:=73;
  for i := 5 to 52 do
  begin
    lTextEdit := FindComponent('ME'+IntToStr(k)) as TcxCustomTextEdit;
    if lTextEdit <> nil then
    begin
      TempStr :=lTextEdit.Text;
    end
    else
      TempStr:=' ';
    if odd(i) then
    begin
      j:=i;
      range:=eclApp.worksheets[1].range[eclApp.worksheets[1].cells[7,j],
                                        eclApp.worksheets[1].cells[7,j+1]];
      range.merge;
      Range.Font.Color:=clFuchsia;
      eclApp.worksheets[1].Cells[7,j].Value:=TempStr;
      Range.HorizontalAlignment := xlCenter;
      Range.VerticalAlignment := xlCenter;
      k:=k+1;
    end;
  end;
  EclApp.worksheets[1].Cells[7,53].Value:=ME148.Text;
ProB_Print.Position:=40;
  //初始化并填写#3机组完成
  k:=97;
  for i := 5 to 52 do
  begin
    lTextEdit := FindComponent('ME'+IntToStr(k)) as TcxCustomTextEdit;
    if lTextEdit <> nil then
    begin
      TempStr :=lTextEdit.Text;
    end
    else
      TempStr:=' ';
    if odd(i) then
    begin
      j:=i;
      range:=eclApp.worksheets[1].range[eclApp.worksheets[1].cells[8,j],
                                        eclApp.worksheets[1].cells[8,j+1]];
      range.merge;
      Range.Font.Color:=clLime;
      eclApp.worksheets[1].Cells[8,j].Value:=TempStr;
      Range.HorizontalAlignment := xlCenter;
      Range.VerticalAlignment := xlCenter;
      k:=k+1;
    end;
  end;
  EclApp.worksheets[1].Cells[8,53].Value:=ME149.Text;
ProB_Print.Position:=42;
  //初始化并填写#4机组完成
  k:=121;
  for i := 5 to 52 do
  begin
    lTextEdit := FindComponent('ME'+IntToStr(k)) as TcxCustomTextEdit;
    if lTextEdit <> nil then
    begin
      TempStr :=lTextEdit.Text;
    end
    else
      TempStr:=' ';
    if odd(i) then
    begin
      j:=i;
      range:=eclApp.worksheets[1].range[eclApp.worksheets[1].cells[9,j],
                                        eclApp.worksheets[1].cells[9,j+1]];
      range.merge;
      Range.Font.Color:=clAqua;
      eclApp.worksheets[1].Cells[9,j].Value:=TempStr;
      Range.HorizontalAlignment := xlCenter;
      Range.VerticalAlignment := xlCenter;
      k:=k+1;
    end;
  end;
  EclApp.worksheets[1].Cells[9,53].Value:=ME150.Text;
//********************填写 主要生产指标完成情况 信息****************************
ProB_Print.Position:=44;
  //设置标题
  range:=eclApp.worksheets[1].range[eclApp.worksheets[1].cells[10,2],
                                    eclApp.worksheets[1].cells[10,53]];
  range.merge;
  Range.Font.Bold:=True;
  Range.Font.size:=10;
  EclApp.worksheets[1].Cells[10,2].Value:='主要生产指标完成情况';
  Range.HorizontalAlignment := xlCenter;
  Range.VerticalAlignment := xlCenter;
ProB_Print.Position:=46;
  //设置主要生产指标完成情况外边框线 1-左    2-右   3-顶    4-底   5-斜( \ )     6-斜( / )
  eclApp.ActiveSheet.Range['B11:BA11'].Borders[3].Weight := 3;
  eclApp.ActiveSheet.Range['B11:B17'].Borders[1].Weight := 3;
  eclApp.ActiveSheet.Range['B17:BA17'].Borders[4].Weight := 3;
  eclApp.ActiveSheet.Range['BA11:BA17'].Borders[2].Weight := 3;
ProB_Print.Position:=48;
  //设置表头
  range:=eclApp.worksheets[1].range[eclApp.worksheets[1].cells[11,2],
                                    eclApp.worksheets[1].cells[12,4]];
  range.merge;
  Range.Font.Bold:=True;
  Range.Font.size:=10;
  EclApp.worksheets[1].Cells[11,2].Value:='      项目'+#13#10+'机组';
  EclApp.ActiveSheet.Range['B11:D12'].Borders[5].Weight := 1;
  //行标题1
ProB_Print.Position:=50;
  range:=eclApp.worksheets[1].range[eclApp.worksheets[1].cells[13,2],
                                    eclApp.worksheets[1].cells[13,4]];
  range.merge;
  Range.Font.Bold:=True;
  EclApp.worksheets[1].Cells[13,2].Value:='#1机组';
  Range.HorizontalAlignment := xlCenter;
  Range.VerticalAlignment := xlCenter;
ProB_Print.Position:=51;
  //行标题2
  range:=eclApp.worksheets[1].range[eclApp.worksheets[1].cells[14,2],
                                    eclApp.worksheets[1].cells[14,4]];
  Range.Font.Bold:=True;
  range.merge;
  EclApp.worksheets[1].Cells[14,2].Value:='#2机组';
  Range.HorizontalAlignment := xlCenter;
  Range.VerticalAlignment := xlCenter;
ProB_Print.Position:=52;
  //行标题3
  range:=eclApp.worksheets[1].range[eclApp.worksheets[1].cells[15,2],
                                    eclApp.worksheets[1].cells[15,4]];
  Range.Font.Bold:=True;
  range.merge;
  EclApp.worksheets[1].Cells[15,2].Value:='#3机组';
  Range.HorizontalAlignment := xlCenter;
  Range.VerticalAlignment := xlCenter;
ProB_Print.Position:=53;
  //行标题4
  range:=eclApp.worksheets[1].range[eclApp.worksheets[1].cells[16,2],
                                    eclApp.worksheets[1].cells[16,4]];
  Range.Font.Bold:=True;
  range.merge;
  EclApp.worksheets[1].Cells[16,2].Value:='#4机组';
  Range.HorizontalAlignment := xlCenter;
  Range.VerticalAlignment := xlCenter;
ProB_Print.Position:=54;
  //行标题5
  range:=eclApp.worksheets[1].range[eclApp.worksheets[1].cells[17,2],
                                    eclApp.worksheets[1].cells[17,4]];
  Range.Font.Bold:=True;
  range.merge;
  EclApp.worksheets[1].Cells[17,2].Value:='合计';
  Range.HorizontalAlignment := xlCenter;
  Range.VerticalAlignment := xlCenter;
ProB_Print.Position:=55;
  //初始化 日发电量列标题
  range:=eclApp.worksheets[1].range[eclApp.worksheets[1].cells[11,5],
                                    eclApp.worksheets[1].cells[12,8]];
  range.merge;
  Range.Font.Bold:=True;
  EclApp.worksheets[1].Cells[11,5].Value:='日发电量'+#13#10+'(MWH)';
  Range.HorizontalAlignment := xlCenter;
  Range.VerticalAlignment := xlCenter;
ProB_Print.Position:=56;
  //填写日发电量信息
  k:=1;
  for i := 1 to 5 do
  begin
    lTextEdit := FindComponent('TE'+IntToStr(k)) as TcxCustomTextEdit;
    if lTextEdit <> nil then
    begin
      TempStr :=lTextEdit.Text;
    end
    else
      TempStr:=' ';
    range:=eclApp.worksheets[1].range[eclApp.worksheets[1].cells[i+12,5],
                                      eclApp.worksheets[1].cells[i+12,8]];
    range.merge;
    EclApp.worksheets[1].Cells[i+12,5].Value:=TempStr;
    Range.HorizontalAlignment := xlCenter;
    Range.VerticalAlignment := xlCenter;
    k:=k+15;
  end;
ProB_Print.Position:=57;
  //初始化 月发电量列标题
  range:=eclApp.worksheets[1].range[eclApp.worksheets[1].cells[11,9],
                                    eclApp.worksheets[1].cells[12,12]];
  range.merge;
  Range.Font.Bold:=True;
  EclApp.worksheets[1].Cells[11,9].Value:='月发电量'+#13#10+'(MWH)';
  Range.HorizontalAlignment := xlCenter;
  Range.VerticalAlignment := xlCenter;
ProB_Print.Position:=58;
  //填写月发电量信息
  k:=2;
  for i := 1 to 5 do
  begin
    lTextEdit := FindComponent('TE'+IntToStr(k)) as TcxCustomTextEdit;
    if lTextEdit <> nil then
    begin
      TempStr :=lTextEdit.Text;
    end
    else
      TempStr:=' ';
    range:=eclApp.worksheets[1].range[eclApp.worksheets[1].cells[i+12,9],
                                      eclApp.worksheets[1].cells[i+12,12]];
    range.merge;
    EclApp.worksheets[1].Cells[i+12,9].Value:=TempStr;
    Range.HorizontalAlignment := xlCenter;
    Range.VerticalAlignment := xlCenter;
    k:=k+15;
  end;
ProB_Print.Position:=59;
  //初始化 年发电量列标题
  range:=eclApp.worksheets[1].range[eclApp.worksheets[1].cells[11,13],
                                    eclApp.worksheets[1].cells[12,17]];
  range.merge;
  Range.Font.Bold:=True;
  EclApp.worksheets[1].Cells[11,13].Value:='年发电量'+#13#10+'(MWH)';
  Range.HorizontalAlignment := xlCenter;
  Range.VerticalAlignment := xlCenter;
ProB_Print.Position:=60;
  //填写年发电量信息
  k:=3;
  for i := 1 to 5 do
  begin
    lTextEdit := FindComponent('TE'+IntToStr(k)) as TcxCustomTextEdit;
    if lTextEdit <> nil then
    begin
      TempStr :=lTextEdit.Text;
    end
    else
      TempStr:=' ';
    range:=eclApp.worksheets[1].range[eclApp.worksheets[1].cells[i+12,13],
                                      eclApp.worksheets[1].cells[i+12,17]];
    range.merge;
    EclApp.worksheets[1].Cells[i+12,13].Value:=TempStr;
    Range.HorizontalAlignment := xlCenter;
    Range.VerticalAlignment := xlCenter;
    k:=k+15;
  end;
ProB_Print.Position:=61;
  //初始化 厂用率列标题
  range:=eclApp.worksheets[1].range[eclApp.worksheets[1].cells[11,18],
                                    eclApp.worksheets[1].cells[12,20]];
  range.merge;
  Range.Font.Bold:=True;
  EclApp.worksheets[1].Cells[11,18].Value:='厂用率'+#13#10+'(%)';
  Range.HorizontalAlignment := xlCenter;
  Range.VerticalAlignment := xlCenter;
ProB_Print.Position:=62;
  //填写厂用率信息
  k:=4;
  for i := 1 to 5 do
  begin
    lTextEdit := FindComponent('TE'+IntToStr(k)) as TcxCustomTextEdit;
    if lTextEdit <> nil then
    begin
      TempStr :=lTextEdit.Text;
    end
    else
      TempStr:=' ';
    range:=eclApp.worksheets[1].range[eclApp.worksheets[1].cells[i+12,18],
                                      eclApp.worksheets[1].cells[i+12,20]];
    range.merge;
    EclApp.worksheets[1].Cells[i+12,18].Value:=TempStr;
    Range.HorizontalAlignment := xlCenter;
    Range.VerticalAlignment := xlCenter;
    k:=k+15;
  end;
ProB_Print.Position:=63;
  //初始化 日用煤列标题
  range:=eclApp.worksheets[1].range[eclApp.worksheets[1].cells[11,21],
                                    eclApp.worksheets[1].cells[12,23]];
  range.merge;
  Range.Font.Bold:=True;
  EclApp.worksheets[1].Cells[11,21].Value:='日用煤'+#13#10+'(T)';
  Range.HorizontalAlignment := xlCenter;
  Range.VerticalAlignment := xlCenter;
ProB_Print.Position:=64;
  //填写日用煤信息
  k:=5;
  for i := 1 to 5 do
  begin
    lTextEdit := FindComponent('TE'+IntToStr(k)) as TcxCustomTextEdit;
    if lTextEdit <> nil then
    begin
      TempStr :=lTextEdit.Text;
    end
    else
      TempStr:=' ';
    range:=eclApp.worksheets[1].range[eclApp.worksheets[1].cells[i+12,21],
                                      eclApp.worksheets[1].cells[i+12,23]];
    range.merge;
    EclApp.worksheets[1].Cells[i+12,21].Value:=TempStr;
    Range.HorizontalAlignment := xlCenter;
    Range.VerticalAlignment := xlCenter;
    k:=k+15;
  end;
ProB_Print.Position:=66;
  //初始化 月用煤列标题
  range:=eclApp.worksheets[1].range[eclApp.worksheets[1].cells[11,24],
                                    eclApp.worksheets[1].cells[12,27]];
  range.merge;
  Range.Font.Bold:=True;
  EclApp.worksheets[1].Cells[11,24].Value:='月用煤'+#13#10+'(T)';
  Range.HorizontalAlignment := xlCenter;
  Range.VerticalAlignment := xlCenter;
ProB_Print.Position:=67;
  //填写月用煤信息
  k:=6;
  for i := 1 to 5 do
  begin
    lTextEdit := FindComponent('TE'+IntToStr(k)) as TcxCustomTextEdit;
    if lTextEdit <> nil then
    begin
      TempStr :=lTextEdit.Text;
    end
    else
      TempStr:=' ';
    range:=eclApp.worksheets[1].range[eclApp.worksheets[1].cells[i+12,24],
                                      eclApp.worksheets[1].cells[i+12,27]];
    range.merge;
    EclApp.worksheets[1].Cells[i+12,24].Value:=TempStr;
    Range.HorizontalAlignment := xlCenter;
    Range.VerticalAlignment := xlCenter;
    k:=k+15;
  end;
ProB_Print.Position:=68;
  //初始化 日用油列标题
  range:=eclApp.worksheets[1].range[eclApp.worksheets[1].cells[11,28],
                                    eclApp.worksheets[1].cells[12,30]];
  range.merge;
  Range.Font.Bold:=True;
  EclApp.worksheets[1].Cells[11,28].Value:='日用油'+#13#10+'(T)';
  Range.HorizontalAlignment := xlCenter;
  Range.VerticalAlignment := xlCenter;
ProB_Print.Position:=69;
  //填写日用油信息
  k:=7;
  for i := 1 to 5 do
  begin
    lTextEdit := FindComponent('TE'+IntToStr(k)) as TcxCustomTextEdit;
    if lTextEdit <> nil then
    begin
      TempStr :=lTextEdit.Text;
    end
    else
      TempStr:=' ';
    range:=eclApp.worksheets[1].range[eclApp.worksheets[1].cells[i+12,28],
                                      eclApp.worksheets[1].cells[i+12,30]];
    range.merge;
    EclApp.worksheets[1].Cells[i+12,28].Value:=TempStr;
    Range.HorizontalAlignment := xlCenter;
    Range.VerticalAlignment := xlCenter;
    k:=k+15;
  end;
ProB_Print.Position:=70;
  //初始化 月用油列标题
  range:=eclApp.worksheets[1].range[eclApp.worksheets[1].cells[11,31],
                                    eclApp.worksheets[1].cells[12,33]];
  range.merge;
  Range.Font.Bold:=True;
  EclApp.worksheets[1].Cells[11,31].Value:='月用油'+#13#10+'(T)';
  Range.HorizontalAlignment := xlCenter;
  Range.VerticalAlignment := xlCenter;
ProB_Print.Position:=71;
  //填写月用油信息
  k:=8;
  for i := 1 to 5 do
  begin
    lTextEdit := FindComponent('TE'+IntToStr(k)) as TcxCustomTextEdit;
    if lTextEdit <> nil then
    begin
      TempStr :=lTextEdit.Text;
    end
    else
      TempStr:=' ';
    range:=eclApp.worksheets[1].range[eclApp.worksheets[1].cells[i+12,31],
                                      eclApp.worksheets[1].cells[i+12,33]];
    range.merge;
    EclApp.worksheets[1].Cells[i+12,31].Value:=TempStr;
    Range.HorizontalAlignment := xlCenter;
    Range.VerticalAlignment := xlCenter;
    k:=k+15;
  end;
ProB_Print.Position:=72;
  //初始化 日补水列标题
  range:=eclApp.worksheets[1].range[eclApp.worksheets[1].cells[11,34],
                                    eclApp.worksheets[1].cells[12,36]];
  range.merge;
  Range.Font.Bold:=True;
  EclApp.worksheets[1].Cells[11,34].Value:='日补水'+#13#10+'(T)';
  Range.HorizontalAlignment := xlCenter;
  Range.VerticalAlignment := xlCenter;
ProB_Print.Position:=73;
  //填写日补水信息
  k:=9;
  for i := 1 to 5 do
  begin
    lTextEdit := FindComponent('TE'+IntToStr(k)) as TcxCustomTextEdit;
    if lTextEdit <> nil then
    begin
      TempStr :=lTextEdit.Text;
    end
    else
      TempStr:=' ';
    range:=eclApp.worksheets[1].range[eclApp.worksheets[1].cells[i+12,34],
                                      eclApp.worksheets[1].cells[i+12,36]];
    range.merge;
    EclApp.worksheets[1].Cells[i+12,34].Value:=TempStr;
    Range.HorizontalAlignment := xlCenter;
    Range.VerticalAlignment := xlCenter;
    k:=k+15;
  end;
  //初始化 月补水列标题
ProB_Print.Position:=74;
  range:=eclApp.worksheets[1].range[eclApp.worksheets[1].cells[11,37],
                                    eclApp.worksheets[1].cells[12,39]];
  range.merge;
  Range.Font.Bold:=True;
  EclApp.worksheets[1].Cells[11,37].Value:='月补水'+#13#10+'(T)';
  Range.HorizontalAlignment := xlCenter;
  Range.VerticalAlignment := xlCenter;
ProB_Print.Position:=75;
  //填写月补水信息
  k:=10;
  for i := 1 to 5 do
  begin
    lTextEdit := FindComponent('TE'+IntToStr(k)) as TcxCustomTextEdit;
    if lTextEdit <> nil then
    begin
      TempStr :=lTextEdit.Text;
    end
    else
      TempStr:=' ';
    range:=eclApp.worksheets[1].range[eclApp.worksheets[1].cells[i+12,37],
                                      eclApp.worksheets[1].cells[i+12,39]];
    range.merge;
    EclApp.worksheets[1].Cells[i+12,37].Value:=TempStr;
    Range.HorizontalAlignment := xlCenter;
    Range.VerticalAlignment := xlCenter;
    k:=k+15;
  end;
ProB_Print.Position:=76;
  //初始化 平均负荷列标题
  range:=eclApp.worksheets[1].range[eclApp.worksheets[1].cells[11,40],
                                    eclApp.worksheets[1].cells[12,42]];
  range.merge;
  Range.Font.Bold:=True;
  EclApp.worksheets[1].Cells[11,40].Value:='平均负荷'+#13#10+'(EW)';
  Range.HorizontalAlignment := xlCenter;
  Range.VerticalAlignment := xlCenter;
  //填写平均负荷信息
ProB_Print.Position:=77;
  k:=11;
  for i := 1 to 5 do
  begin
    lTextEdit := FindComponent('TE'+IntToStr(k)) as TcxCustomTextEdit;
    if lTextEdit <> nil then
    begin
      TempStr :=lTextEdit.Text;
    end
    else
      TempStr:=' ';
    range:=eclApp.worksheets[1].range[eclApp.worksheets[1].cells[i+12,40],
                                      eclApp.worksheets[1].cells[i+12,42]];
    range.merge;
    EclApp.worksheets[1].Cells[i+12,40].Value:=TempStr;
    Range.HorizontalAlignment := xlCenter;
    Range.VerticalAlignment := xlCenter;
    k:=k+15;
  end;
  //初始化 负荷率列标题
ProB_Print.Position:=78;
  range:=eclApp.worksheets[1].range[eclApp.worksheets[1].cells[11,43],
                                    eclApp.worksheets[1].cells[12,45]];
  range.merge;
  Range.Font.Bold:=True;
  EclApp.worksheets[1].Cells[11,43].Value:='负荷率'+#13#10+'(%)';
  Range.HorizontalAlignment := xlCenter;
  Range.VerticalAlignment := xlCenter;
  //填写平均负荷信息
ProB_Print.Position:=79;
  k:=12;
  for i := 1 to 5 do
  begin
    lTextEdit := FindComponent('TE'+IntToStr(k)) as TcxCustomTextEdit;
    if lTextEdit <> nil then
    begin
      TempStr :=lTextEdit.Text;
    end
    else
      TempStr:=' ';
    range:=eclApp.worksheets[1].range[eclApp.worksheets[1].cells[i+12,43],
                                      eclApp.worksheets[1].cells[i+12,45]];
    range.merge;
    EclApp.worksheets[1].Cells[i+12,43].Value:=TempStr;
    Range.HorizontalAlignment := xlCenter;
    Range.VerticalAlignment := xlCenter;
    k:=k+15;
  end;
  //初始化 厂用电量列标题
ProB_Print.Position:=80;
  range:=eclApp.worksheets[1].range[eclApp.worksheets[1].cells[11,46],
                                    eclApp.worksheets[1].cells[12,48]];
  range.merge;
  Range.Font.Bold:=True;
  EclApp.worksheets[1].Cells[11,46].Value:='厂用电量'+#13#10+'(MWH)';
  Range.HorizontalAlignment := xlCenter;
  Range.VerticalAlignment := xlCenter;
  //填写厂用电量信息
ProB_Print.Position:=81;
  k:=13;
  for i := 1 to 5 do
  begin
    lTextEdit := FindComponent('TE'+IntToStr(k)) as TcxCustomTextEdit;
    if lTextEdit <> nil then
    begin
      TempStr :=lTextEdit.Text;
    end
    else
      TempStr:=' ';
    range:=eclApp.worksheets[1].range[eclApp.worksheets[1].cells[i+12,46],
                                      eclApp.worksheets[1].cells[i+12,48]];
    range.merge;
    EclApp.worksheets[1].Cells[i+12,46].Value:=TempStr;
    Range.HorizontalAlignment := xlCenter;
    Range.VerticalAlignment := xlCenter;
    k:=k+15;
  end;
  //初始化 月累计运行小时列标题
ProB_Print.Position:=82;
  range:=eclApp.worksheets[1].range[eclApp.worksheets[1].cells[11,49],
                                    eclApp.worksheets[1].cells[12,51]];
  range.merge;
  Range.Font.Bold:=True;
  EclApp.worksheets[1].Cells[11,49].Value:='月累计运行'+#13#10+'小时(MWH)';
  Range.HorizontalAlignment := xlCenter;
  Range.VerticalAlignment := xlCenter;
  //填写月累计运行小时信息
ProB_Print.Position:=83;
  k:=14;
  for i := 1 to 5 do
  begin
    lTextEdit := FindComponent('TE'+IntToStr(k)) as TcxCustomTextEdit;
    if lTextEdit <> nil then
    begin
      TempStr :=lTextEdit.Text;
    end
    else
      TempStr:=' ';
    range:=eclApp.worksheets[1].range[eclApp.worksheets[1].cells[i+12,49],
                                      eclApp.worksheets[1].cells[i+12,51]];
    range.merge;
    EclApp.worksheets[1].Cells[i+12,49].Value:=TempStr;
    Range.HorizontalAlignment := xlCenter;
    Range.VerticalAlignment := xlCenter;
    k:=k+15;
  end;
  //初始化 年累计运行小时列标题
  range:=eclApp.worksheets[1].range[eclApp.worksheets[1].cells[11,52],
                                    eclApp.worksheets[1].cells[12,53]];
  range.merge;
  Range.Font.Bold:=True;
  EclApp.worksheets[1].Cells[11,52].Value:='年累计运行'+#13#10+'小时(MWH)';
  Range.HorizontalAlignment := xlCenter;
  Range.VerticalAlignment := xlCenter;
  //填写年累计运行小时信息
ProB_Print.Position:=84;
  k:=15;
  for i := 1 to 5 do
  begin
    lTextEdit := FindComponent('TE'+IntToStr(k)) as TcxCustomTextEdit;
    if lTextEdit <> nil then
    begin
      TempStr :=lTextEdit.Text;
    end
    else
      TempStr:=' ';
    range:=eclApp.worksheets[1].range[eclApp.worksheets[1].cells[i+12,52],
                                      eclApp.worksheets[1].cells[i+12,53]];
    range.merge;
    EclApp.worksheets[1].Cells[i+12,52].Value:=TempStr;
    Range.HorizontalAlignment := xlCenter;
    Range.VerticalAlignment := xlCenter;
    k:=k+15;
  end;
//***********************初始化用水情况和后夜班交班存煤情况表头*****************
  //设置用水情况和后夜班交班存煤情况外边框线 1-左 2-右 3-顶 4-底 5-斜( \ ) 6-斜( / )
ProB_Print.Position:=85;
  eclApp.ActiveSheet.Range['B18:BA18'].Borders[3].Weight := 3;
  eclApp.ActiveSheet.Range['B18:B21'].Borders[1].Weight := 3;
  eclApp.ActiveSheet.Range['B21:BA21'].Borders[4].Weight := 3;
  eclApp.ActiveSheet.Range['BA18:BA21'].Borders[2].Weight := 3;
  //初始化用水情况
  range:=eclApp.worksheets[1].range[eclApp.worksheets[1].cells[18,2],
                                    eclApp.worksheets[1].cells[19,4]];
  range.merge;
  Range.Font.Bold:=True;
  EclApp.worksheets[1].Cells[18,2].Value:='用水情况';
  Range.HorizontalAlignment := xlCenter;
  Range.VerticalAlignment := xlCenter;
  //初始化日用水行
  range:=eclApp.worksheets[1].range[eclApp.worksheets[1].cells[20,2],
                                    eclApp.worksheets[1].cells[20,4]];
  range.merge;
  Range.Font.Bold:=True;
  EclApp.worksheets[1].Cells[20,2].Value:='日用水量';
  Range.HorizontalAlignment := xlCenter;
  Range.VerticalAlignment := xlCenter;
  //初始化月用水行
ProB_Print.Position:=86;
  range:=eclApp.worksheets[1].range[eclApp.worksheets[1].cells[21,2],
                                    eclApp.worksheets[1].cells[21,4]];
  range.merge;
  Range.Font.Bold:=True;
  EclApp.worksheets[1].Cells[21,2].Value:='月用水量';
  Range.HorizontalAlignment := xlCenter;
  Range.VerticalAlignment := xlCenter;
  //初始化凌河#2管
ProB_Print.Position:=87;
  range:=eclApp.worksheets[1].range[eclApp.worksheets[1].cells[18,5],
                                    eclApp.worksheets[1].cells[19,6]];
  range.merge;
  Range.Font.Bold:=True;
  EclApp.worksheets[1].Cells[18,5].Value:='凌河'+#13#10+'#2管';
  Range.HorizontalAlignment := xlCenter;
  Range.VerticalAlignment := xlCenter;
  //初始化艾友#1管
  range:=eclApp.worksheets[1].range[eclApp.worksheets[1].cells[18,7],
                                    eclApp.worksheets[1].cells[19,8]];
  range.merge;
  Range.Font.Bold:=True;
  EclApp.worksheets[1].Cells[18,7].Value:='艾友'+#13#10+'#1管';
  Range.HorizontalAlignment := xlCenter;
  Range.VerticalAlignment := xlCenter;
 
  //初始化汤头河
ProB_Print.Position:=88;
  range:=eclApp.worksheets[1].range[eclApp.worksheets[1].cells[18,9],
                                    eclApp.worksheets[1].cells[19,10]];
  range.merge;
  Range.Font.Bold:=True;
  EclApp.worksheets[1].Cells[18,9].Value:='汤头河';
  Range.HorizontalAlignment := xlCenter;
  Range.VerticalAlignment := xlCenter;
  //初始化合计
  range:=eclApp.worksheets[1].range[eclApp.worksheets[1].cells[18,11],
                                    eclApp.worksheets[1].cells[19,12]];
  range.merge;
  Range.Font.Bold:=True;
  EclApp.worksheets[1].Cells[18,11].Value:='合计';
  Range.HorizontalAlignment := xlCenter;
  Range.VerticalAlignment := xlCenter;
  //初始原水
  range:=eclApp.worksheets[1].range[eclApp.worksheets[1].cells[18,13],
                                    eclApp.worksheets[1].cells[18,30]];
  range.merge;
  Range.Font.Bold:=True;
  EclApp.worksheets[1].Cells[18,13].Value:='原水';
  Range.HorizontalAlignment := xlCenter;
  Range.VerticalAlignment := xlCenter;
  //初始伊玛
ProB_Print.Position:=89;
  range:=eclApp.worksheets[1].range[eclApp.worksheets[1].cells[19,13],
                                    eclApp.worksheets[1].cells[19,14]];
  range.merge;
  Range.Font.Bold:=True;
  EclApp.worksheets[1].Cells[19,13].Value:='伊玛';
  Range.HorizontalAlignment := xlCenter;
  Range.VerticalAlignment := xlCenter;
  //初始二道河子
  range:=eclApp.worksheets[1].range[eclApp.worksheets[1].cells[19,15],
                                    eclApp.worksheets[1].cells[19,16]];
  range.merge;
  Range.Font.Bold:=True;
  EclApp.worksheets[1].Cells[19,15].Value:='二道河子';
  Range.HorizontalAlignment := xlCenter;
  Range.VerticalAlignment := xlCenter;
  //初始二井
  range:=eclApp.worksheets[1].range[eclApp.worksheets[1].cells[19,17],
                                    eclApp.worksheets[1].cells[19,18]];
  range.merge;
  Range.Font.Bold:=True;
  EclApp.worksheets[1].Cells[19,17].Value:='二井';
  Range.HorizontalAlignment := xlCenter;
  Range.VerticalAlignment := xlCenter;
  //初始三矿
ProB_Print.Position:=90;
  range:=eclApp.worksheets[1].range[eclApp.worksheets[1].cells[19,19],
                                    eclApp.worksheets[1].cells[19,20]];
  range.merge;
  Range.Font.Bold:=True;
  EclApp.worksheets[1].Cells[19,19].Value:='三矿';
  Range.HorizontalAlignment := xlCenter;
  Range.VerticalAlignment := xlCenter;
  //初始艾友村 
  range:=eclApp.worksheets[1].range[eclApp.worksheets[1].cells[19,21],
                                    eclApp.worksheets[1].cells[19,22]];
  range.merge;
  Range.Font.Bold:=True;
  EclApp.worksheets[1].Cells[19,21].Value:='艾友村';
  Range.HorizontalAlignment := xlCenter;
  Range.VerticalAlignment := xlCenter;
  //初始大成
  range:=eclApp.worksheets[1].range[eclApp.worksheets[1].cells[19,23],
                                    eclApp.worksheets[1].cells[19,24]];
  range.merge;
  Range.Font.Bold:=True;
  EclApp.worksheets[1].Cells[19,23].Value:='大成';
  Range.HorizontalAlignment := xlCenter;
  Range.VerticalAlignment := xlCenter;
  //初始乌龙
  range:=eclApp.worksheets[1].range[eclApp.worksheets[1].cells[19,25],
                                    eclApp.worksheets[1].cells[19,26]];
  range.merge;
  Range.Font.Bold:=True;
  EclApp.worksheets[1].Cells[19,25].Value:='乌龙';
  Range.HorizontalAlignment := xlCenter;
  Range.VerticalAlignment := xlCenter;
  //初始靖伟
  range:=eclApp.worksheets[1].range[eclApp.worksheets[1].cells[19,27],
                                    eclApp.worksheets[1].cells[19,28]];
  range.merge;
  Range.Font.Bold:=True;
  EclApp.worksheets[1].Cells[19,27].Value:='靖伟';
  Range.HorizontalAlignment := xlCenter;
  Range.VerticalAlignment := xlCenter;
ProB_Print.Position:=91;
  {range:=eclApp.worksheets[1].range[eclApp.worksheets[1].cells[19,29],
                                    eclApp.worksheets[1].cells[19,30]];
  range.merge;
  Range.Font.Bold:=True;
  EclApp.worksheets[1].Cells[19,29].Value:='汤头河';
  Range.HorizontalAlignment := xlCenter;
  Range.VerticalAlignment := xlCenter;}
  //初始合计
  range:=eclApp.worksheets[1].range[eclApp.worksheets[1].cells[19,29],
                                    eclApp.worksheets[1].cells[19,30]];
  range.merge;
  Range.Font.Bold:=True;
  EclApp.worksheets[1].Cells[19,29].Value:='合计';
  Range.HorizontalAlignment := xlCenter;
  Range.VerticalAlignment := xlCenter;
  //初始后夜班交班存煤情况
ProB_Print.Position:=92;
  range:=eclApp.worksheets[1].range[eclApp.worksheets[1].cells[18,31],
                                    eclApp.worksheets[1].cells[18,53]];
  range.merge;
  Range.Font.Bold:=True;
  EclApp.worksheets[1].Cells[18,31].Value:='后夜班交班存煤情况';
  Range.HorizontalAlignment := xlCenter;
  Range.VerticalAlignment := xlCenter;
  //初始后#1炉煤斗存煤(T)
  range:=eclApp.worksheets[1].range[eclApp.worksheets[1].cells[19,31],
                                    eclApp.worksheets[1].cells[20,33]];
  range.merge;
  Range.Font.Bold:=True;
  EclApp.worksheets[1].Cells[19,31].Value:='#1炉煤斗'+#13#10+'存煤(T)';
  Range.HorizontalAlignment := xlCenter;
  Range.VerticalAlignment := xlCenter;
  //初始后#2炉煤斗存煤(T)
  range:=eclApp.worksheets[1].range[eclApp.worksheets[1].cells[19,34],
                                    eclApp.worksheets[1].cells[20,36]];
  range.merge;
  Range.Font.Bold:=True;
  EclApp.worksheets[1].Cells[19,34].Value:='#2炉煤斗'+#13#10+'存煤(T)';
  Range.HorizontalAlignment := xlCenter;
  Range.VerticalAlignment := xlCenter;
  //初始后#3炉煤斗存煤(T)
  range:=eclApp.worksheets[1].range[eclApp.worksheets[1].cells[19,37],
                                    eclApp.worksheets[1].cells[20,39]];
  range.merge;
  Range.Font.Bold:=True;
  EclApp.worksheets[1].Cells[19,37].Value:='#3炉煤斗'+#13#10+'存煤(T)';
  Range.HorizontalAlignment := xlCenter;
  Range.VerticalAlignment := xlCenter;
  //初始后#4炉煤斗存煤(T)
  range:=eclApp.worksheets[1].range[eclApp.worksheets[1].cells[19,40],
                                    eclApp.worksheets[1].cells[20,42]];
  range.merge;
  Range.Font.Bold:=True;
  EclApp.worksheets[1].Cells[19,40].Value:='#4炉煤斗'+#13#10+'存煤(T)';
  Range.HorizontalAlignment := xlCenter;
  Range.VerticalAlignment := xlCenter;
  //初始#1筒仓存煤(T)
ProB_Print.Position:=93;
  range:=eclApp.worksheets[1].range[eclApp.worksheets[1].cells[19,43],
                                    eclApp.worksheets[1].cells[20,44]];
  range.merge;
  Range.Font.Bold:=True;
  EclApp.worksheets[1].Cells[19,43].Value:='1筒仓'+#13#10+'存煤(T)';
  Range.HorizontalAlignment := xlCenter;
  Range.VerticalAlignment := xlCenter;
  //初始#2筒仓存煤(T)
  range:=eclApp.worksheets[1].range[eclApp.worksheets[1].cells[19,45],
                                    eclApp.worksheets[1].cells[20,46]];
  range.merge;
  Range.Font.Bold:=True;
  EclApp.worksheets[1].Cells[19,45].Value:='2筒仓'+#13#10+'存煤(T)';
  Range.HorizontalAlignment := xlCenter;
  Range.VerticalAlignment := xlCenter;
  //初始汽车煤沟存煤(T)
  range:=eclApp.worksheets[1].range[eclApp.worksheets[1].cells[19,47],
                                    eclApp.worksheets[1].cells[20,49]];
  range.merge;
  Range.Font.Bold:=True;
  EclApp.worksheets[1].Cells[19,47].Value:='汽车煤沟'+#13#10+'存煤(T)';
  Range.HorizontalAlignment := xlCenter;
  Range.VerticalAlignment := xlCenter;
  //初始火车煤沟存煤(T)
  range:=eclApp.worksheets[1].range[eclApp.worksheets[1].cells[19,50],
                                    eclApp.worksheets[1].cells[20,52]];
  range.merge;
  Range.Font.Bold:=True;
  EclApp.worksheets[1].Cells[19,50].Value:='火车煤沟'+#13#10+'存煤(T)';
  Range.HorizontalAlignment := xlCenter;
  Range.VerticalAlignment := xlCenter;
  //初始厂内重车(节)
ProB_Print.Position:=94;
  range:=eclApp.worksheets[1].range[eclApp.worksheets[1].cells[19,53],
                                    eclApp.worksheets[1].cells[20,53]];
  range.merge;
  Range.Font.Bold:=True;
  EclApp.worksheets[1].Cells[19,53].Value:='厂内重'+#13#10+'车(节)';
  Range.HorizontalAlignment := xlCenter;
  Range.VerticalAlignment := xlCenter;
//*********************************填写日用水情况信息*****************************
  //初始化并填日用水情况
  k:=1;
  for i := 5 to 30 do
  begin
    lTextEdit := FindComponent('MEW'+IntToStr(k)) as TcxCustomTextEdit;
    if lTextEdit <> nil then
    begin
      TempStr :=lTextEdit.Text;
    end
    else
      TempStr:=' ';
    if odd(i) then
    begin
      j:=i;
      range:=eclApp.worksheets[1].range[eclApp.worksheets[1].cells[20,j],
                                        eclApp.worksheets[1].cells[20,j+1]];
      range.merge;
      eclApp.worksheets[1].Cells[20,j].Value:=TempStr;
      Range.HorizontalAlignment := xlCenter;
      Range.VerticalAlignment := xlCenter;
      k:=k+1;
    end;
  end;
ProB_Print.Position:=95;
  //初始化并填月用水情况
  k:=14;
  for i := 5 to 30 do
  begin
    lTextEdit := FindComponent('MEW'+IntToStr(k)) as TcxCustomTextEdit;
    if lTextEdit <> nil then
    begin
      TempStr :=lTextEdit.Text;
    end
    else
      TempStr:=' ';
    if odd(i) then
    begin
      j:=i;
      range:=eclApp.worksheets[1].range[eclApp.worksheets[1].cells[21,j],
                                        eclApp.worksheets[1].cells[21,j+1]];
      range.merge;
      eclApp.worksheets[1].Cells[21,j].Value:=TempStr;
      Range.HorizontalAlignment := xlCenter;
      Range.VerticalAlignment := xlCenter;
      k:=k+1;
    end;
  end;
  //填写#1炉煤斗存煤信息
  range:=eclApp.worksheets[1].range[eclApp.worksheets[1].cells[21,31],
                                    eclApp.worksheets[1].cells[21,33]];
  range.merge;
  EclApp.worksheets[1].Cells[21,31].Value:=MEC1.Text;
  Range.HorizontalAlignment := xlCenter;
  Range.VerticalAlignment := xlCenter;
  //填写#2炉煤斗存煤信息
  range:=eclApp.worksheets[1].range[eclApp.worksheets[1].cells[21,34],
                                    eclApp.worksheets[1].cells[21,36]];
  range.merge;
  EclApp.worksheets[1].Cells[21,34].Value:=MEC2.Text;
  Range.HorizontalAlignment := xlCenter;
  Range.VerticalAlignment := xlCenter;
  //填写#3炉煤斗存煤信息
  range:=eclApp.worksheets[1].range[eclApp.worksheets[1].cells[21,37],
                                    eclApp.worksheets[1].cells[21,39]];
  range.merge;
  EclApp.worksheets[1].Cells[21,37].Value:=MEC3.Text;
  Range.HorizontalAlignment := xlCenter;
  Range.VerticalAlignment := xlCenter;
  //填写#4炉煤斗存煤信息
  range:=eclApp.worksheets[1].range[eclApp.worksheets[1].cells[21,40],
                                    eclApp.worksheets[1].cells[21,42]];
  range.merge;
  EclApp.worksheets[1].Cells[21,40].Value:=MEC4.Text;
  Range.HorizontalAlignment := xlCenter;
  Range.VerticalAlignment := xlCenter;
  //填写#1筒仓存煤(T)信息
  range:=eclApp.worksheets[1].range[eclApp.worksheets[1].cells[21,43],
                                    eclApp.worksheets[1].cells[21,44]];
  range.merge;
  EclApp.worksheets[1].Cells[21,43].Value:=MEC5.Text;
  Range.HorizontalAlignment := xlCenter;
  Range.VerticalAlignment := xlCenter;
  //填写#2筒仓存煤(T)信息
ProB_Print.Position:=96;
  range:=eclApp.worksheets[1].range[eclApp.worksheets[1].cells[21,45],
                                    eclApp.worksheets[1].cells[21,46]];
  range.merge;
  EclApp.worksheets[1].Cells[21,45].Value:=MEC6.Text;
  Range.HorizontalAlignment := xlCenter;
  Range.VerticalAlignment := xlCenter;
  //填写汽车煤沟存煤(T)信息
  range:=eclApp.worksheets[1].range[eclApp.worksheets[1].cells[21,47],
                                    eclApp.worksheets[1].cells[21,49]];
  range.merge;
  EclApp.worksheets[1].Cells[21,47].Value:=MEC7.Text;
  Range.HorizontalAlignment := xlCenter;
  Range.VerticalAlignment := xlCenter;
  //填写火车煤沟存煤(T)信息
ProB_Print.Position:=97;
  range:=eclApp.worksheets[1].range[eclApp.worksheets[1].cells[21,50],
                                    eclApp.worksheets[1].cells[21,52]];
  range.merge;
  EclApp.worksheets[1].Cells[21,50].Value:=MEC8.Text;
  Range.HorizontalAlignment := xlCenter;
  Range.VerticalAlignment := xlCenter;
  //填写厂内重车(节)信息
  range:=eclApp.worksheets[1].range[eclApp.worksheets[1].cells[21,53],
                                    eclApp.worksheets[1].cells[21,53]];
  range.merge;
  EclApp.worksheets[1].Cells[21,53].Value:=MEC9.Text;
  Range.HorizontalAlignment := xlCenter;
  Range.VerticalAlignment := xlCenter;
  //填写图片
ProB_Print.Position:=98;
  range:=eclApp.worksheets[1].range[eclApp.worksheets[1].cells[22,2],
                                    eclApp.worksheets[1].cells[56,26]];
  range.merge;
  chtMain.CopyToClipboardBitmap;
  EclApp.worksheets[1].Cells[22,2].PasteSpecial;
  lWidth:=range.Width;
  lHeight:=range.Height;
  EclApp.worksheets[1].Pictures[1].ShapeRange.LockAspectRatio:=False;
  EclApp.worksheets[1].Pictures[1].ShapeRange.width:=lWidth;
  EclApp.worksheets[1].Pictures[1].ShapeRange.Height:=lHeight;
  //填写生产概叙
ProB_Print.Position:=99;
  range:=eclApp.worksheets[1].range[eclApp.worksheets[1].cells[22,27],
                                    eclApp.worksheets[1].cells[56,53]];
  range.merge;
  EclApp.worksheets[1].Cells[22,27].Value:=Memo_NotePad.Text;
  Range.HorizontalAlignment := xlLeft;
  Range.VerticalAlignment := xlTop;
  ProB_Print.Position:=100;
  //页面设置
  EclApp.ActiveWindow.View := xlPageBreakPreview;
  EclApp.worksheets[1].VPageBreaks[1].DragOff(xlToRight,1);
  EclApp.worksheets[1].HPageBreaks[1].DragOff(xlDown,1);
  //EclApp.worksheets[1].VPageBreaks(1).DragOff( Direction:=xlToRight, RegionIndex:=1
  //EclApp.worksheets[1].HPageBreaks(1).DragOff Direction:=xlDown, RegionIndex:=1
  EclApp.Visible:=True;
end;
procedure TFm_Main.SetStatus(pStatusStr: string);
var
  lComponentName, lStatus: String;
  lTextEdit: TcxCustomTextEdit;
begin
  while Trim(pStatusStr) <> '' do
  begin
    if (Pos('ME',pStatusStr)=0)and(Pos('TE',pStatusStr)=0)and
       (Pos('MEC',pStatusStr)=0)and(Pos('MEW',pStatusStr)=0) then
    Break;
    DevideString(pStatusStr,'*',lComponentName,pStatusStr);
    if Pos('*',pStatusStr)<>0 then
      DevideString(pStatusStr,'*',lStatus,pStatusStr)
    else
      lStatus:=pStatusStr;
    lTextEdit := FindComponent(lComponentName) as TcxCustomTextEdit;
    if lTextEdit <> nil then
    begin
      lTextEdit.Text := lStatus;
    end;
  end;
end;
procedure TFm_Main.ShowConfigMsg(Sender: TObject);
var
  lRC : OleVariant;
begin
  if ConfigFlowStep(Application.Handle,MODULEGUID,(Sender as TComponent).Name,mBPSID,
                    mDM.mSystemWS,IL_SystemConfig,lRC,
                    mUserIDPanel.Caption,
                    mUserNamePanel.Caption,
                    mIPPanel.Caption) = mrOk then
    mMsgPanel.Caption := '配置已改变!'
  else
    mMsgPanel.Caption := '配置未改变!';
end;
procedure TFm_Main.ShowRepInfo(pID:string);
var
  lSQLText:string;
  lRC:OleVariant;
begin
  lSQLText:='select * from '+mBPSID+'_PRODUCE.T_WatchLeaderRep where ID='+pID;
  lRC:=mDM.mSystemWS.GetDataSet(lSQLText);
  if Pos('Error',lRC)=0 then
  begin
    mDM.CDS_Common.XMLData:=lRC;
    SetStatus(mDM.CDS_Common.FieldByName('PowerInfo').AsString);
    SetStatus(mDM.CDS_Common.FieldByName('ProduceInfo').AsString);
    SetStatus(mDM.CDS_Common.FieldByName('WaterInfo').AsString);
    SetStatus(mDM.CDS_Common.FieldByName('CoalInfo').AsString);
    Memo_NotePad.Lines.Text := ReplaceString(1,mDM.CDS_Common.FieldByName('Producesummary').AsString);
    Label_FillDate.Caption:=mDM.CDS_Common.FieldByName('FillDate').AsString;
    Label_FillWatcher.Caption:=mDM.CDS_Common.FieldByName('RepWatcher').AsString;
    DrowPic;//画图
  end;
end;
procedure TFm_Main.Timer_StateCheckTimer(Sender: TObject);
var
  lTargetRecordID, lTargetTableName: OleVariant;
  lUserID, lUserName, lCurRecordID, lCurTableName: OleVariant;
  i: Integer;
begin
  Timer_StateCheck.Enabled := false;
  try
    Timer_StateCheck.Tag := Timer_StateCheck.Tag + 1;
    //更新各个Action的状态
    for i := 0 to AL_Main.ActionCount - 1 do
    begin
      AL_Main.Actions[i].Update;
    end;
  except
  end;
  Timer_StateCheck.Enabled := true;
end;
{
  if mConfigPanel.Caption = '0' then
  begin
    if CheckConfig(mDM.mSystemWS,mBPSID,mUserIDPanel.Caption,FLOWID,'','',MODULEGUID,(Sender as TComponent).Name,mMsgPanel) = 0 then
      Exit;
  end
  else
  begin
    ShowConfigMsg(Sender);
  end;
}
{未统计:平均负荷,负荷率,月累计运行小时,年累计运行小时}
end.