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

📄 unit1.~pas

📁 读取网通或电信电话交换机(华为)数据给酒店管理数据库
💻 ~PAS
字号:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ComCtrls, ExtCtrls,inifiles, cxStyles, cxCustomData,
  cxGraphics, cxFilter, cxData, cxEdit, DB, cxDBData,
  cxGridCustomTableView, cxGridTableView, cxGridDBTableView, cxGridLevel,
  cxClasses, cxControls, cxGridCustomView, cxGrid, ADODB, DBTables;
type
  TForm1 = class(TForm)
    RICHEDIT1: TMemo;
    Edit1: TEdit;
    Timer1: TTimer;
    Label1: TLabel;
    pubqry: TADOQuery;
    ADOConnection1: TADOConnection;
    procedure Timer1Timer(Sender: TObject);
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;
  size:integer;
buf:pchar;
i,s_rec,d_rec:integer;
f:file;
filename,start_time,place,remark,time_long,time_num:string;
tel_type:string;
total_money,jg:double;
cou:integer;
t:tinifile;
implementation
{$R *.dfm}
uses un_utl;
procedure TForm1.Timer1Timer(Sender: TObject);
var
po,j:integer;
s,inifilename:string;
pay_mode,regis,dep,server_no,expense_type,currency:string;
rate,discount,service:double;
work_date:string;
begin
filename:='c:\centrex\bill\'+formatdatetime('yyyymmdd',date)+'.bil';
inifilename:='c:\centrex\bill\bill.ini';
if FileExists(filename) then
  if fileexists(inifilename) then
   begin
    TRY
      T := TINIFILE.Create(INIFILENAME);
      s_rec:= T.ReadINTEGER('rec',filename, -1);
    FINALLY   T.FREE;  END;
    if s_rec=-1 then s_rec:=0;
    end
  else
  TRY
    T := TINIFILE.Create(INIFILENAME);
    T.WriteINTEGER('rec',filename, -1);
    s_rec:=0;
  FINALLY   T.FREE;  END
else
 begin
  filename:='c:\centrex\bill\'+formatdatetime('yyyymmdd',date-1)+'.bil';
  TRY
    T := TINIFILE.Create(INIFILENAME);
    s_rec:= T.ReadINTEGER('rec',filename, -1);
  FINALLY   T.FREE;  END;
 end;
//filename:='d:\20040416.bil';
assignfile(f,filename);
reset(f,1);
try
size:=filesize(f);
getmem(buf,size+1);
blockread(f,buf^,size);
buf[size]:=#0;
finally
closefile(f);
end;
d_rec:=size div 118;
j:=s_rec;
if (s_rec<d_rec) then //y为文件的记录数
begin
for i:=1 to d_rec-j do//可能有多条记录未进行处理
begin
//取出长途标志,判断是否计费
//取出应答起始时间,主叫号,被叫号,费用
//话费类型
tel_type:=INTTOhex(ord(buf[67+s_rec*118]),2);
if tel_type='13' then
begin
jg:=0.1;
end
else
if tel_type='23' then
begin
jg:=0.05
end
else
 if tel_type='33' then
   begin
   jg:=0.07
   end
 else
  if tel_type='43' then
    begin
    jg:=0.8
    end
  else
   begin
s_rec:=s_rec+1;
  TRY
    T := TINIFILE.Create(INIFILENAME);
    T.WriteINTEGER('rec',filename, s_rec);
  FINALLY   T.FREE;
  END;
    continue;
   end;
//起始时间
start_time:='20'+INTTOSTR_REP(ord(buf[8+s_rec*118]),2)+'-'+INTTOSTR_REP(ord(buf[9+s_rec*118]),2)+'-'+
INTTOSTR_REP(ord(buf[10+s_rec*118]),2)+' '+INTTOSTR_REP(ord(buf[11+s_rec*118]),2)+':'+
INTTOSTR_REP(ord(buf[12+s_rec*118]),2)+':'+INTTOSTR_REP(ord(buf[13+s_rec*118]),2);

// 主叫号
place:=INTTOhex(ord(buf[50+s_rec*118]),2)+INTTOhex(ord(buf[51+s_rec*118]),2)+
       INTTOhex(ord(buf[52+s_rec*118]),2)+INTTOhex(ord(buf[53+s_rec*118]),2)+
       INTTOhex(ord(buf[54+s_rec*118]),2);
//       +INTTOhex(ord(buf[31+s_rec*118]),2)+
//       INTTOhex(ord(buf[32+s_rec*118]),2)+INTTOhex(ord(buf[33+s_rec*118]),2)+
//       INTTOhex(ord(buf[34+s_rec*118]),2)+INTTOhex(ord(buf[35+s_rec*118]),2);
po:=pos('F',place);
place:=copy(place,1,po-1);
if length(place)=3 then place:='0'+place;


//被叫号
remark:=inttohex(ord(buf[38+s_rec*118]),2)+inttohex(ord(buf[39+s_rec*118]),2)+
       inttohex(ord(buf[40+s_rec*118]),2)+inttohex(ord(buf[41+s_rec*118]),2)+
       inttohex(ord(buf[42+s_rec*118]),2)+inttohex(ord(buf[43+s_rec*118]),2)+
       inttohex(ord(buf[44+s_rec*118]),2)+inttohex(ord(buf[45+s_rec*118]),2)+
       inttohex(ord(buf[46+s_rec*118]),2)+inttohex(ord(buf[47+s_rec*118]),2);
po:=pos('F',remark);
remark:=copy(remark,1,po-1);
if (length(remark)=5) or (tel_type<>'13') then
begin
end
else
   begin
s_rec:=s_rec+1;
  TRY
    T := TINIFILE.Create(INIFILENAME);
    T.WriteINTEGER('rec',filename, s_rec);
  FINALLY   T.FREE;
  END;
    continue;
   end;
//计费次数
s:='$'+inttohex(ord(buf[88+s_rec*118]),2)+
               inttohex(ord(buf[87+s_rec*118]),2)+
               inttohex(ord(buf[86+s_rec*118]),2)+
               inttohex(ord(buf[85+s_rec*118]),2);
time_num:=inttostr(strtoint(s));
//时长
s:='$'+inttohex(ord(buf[23+s_rec*118]),2)+
               inttohex(ord(buf[22+s_rec*118]),2)+
               inttohex(ord(buf[21+s_rec*118]),2)+
               inttohex(ord(buf[20+s_rec*118]),2);
time_long:=inttostr(strtoint(s));
//费用
total_money:=jg*strtoint(time_num);
richedit1.Lines.Add(start_time+'      '+time_long+'      '+place+'               '+remark+'            '+time_num+'               '+floattostr(total_money));
richedit1.Invalidate ;
{//写入pub_total_account
 pubqry.close;
 pubqry.sql.clear;
 pubqry.sql.add('select max(registerno)  registerno from useroom where room='+''''+place+'''');
 pubqry.open;
 if not pubqry.eof then
   begin
    //取编号
    regis:=pubqry.fieldbyname('registerno').asstring;
    pubqry.close;
    pubqry.sql.clear;
    pubqry.sql.add('select cardno from register where registerno='+''''+regis+''''+' and '+'inno=0');
    pubqry.open;
    //取服务号
    server_no:=pubqry.fieldbyname('cardno').asstring;
    pubqry.close;
    pubqry.sql.clear;
    pubqry.sql.add('select dates from workinfo');
    pubqry.open;
    //取工作时间
    work_date:=formatdatetime('yyyy-mm-dd hh:mm:ss',pubqry.fieldbyname('dates').asdatetime);
    s:=	'insert into pub_total_account'+
	  ' values('+''''+server_no+''''+','+''''+start_time+''''+',null,'+''''+'客房部'+''''+','+
		''''+place+''''+','+''''+'电话费tel'+''''+','+''''+'RMB'+''''+','+
		'1'+','+floattostr(total_money)+','+'1'+','+'0,'+''''+'记帐'+''''+','+
		''''+remark+''''+','+'1,'+''''+work_date+''''+','+''''+'值'+''''+','+''''+'default'+''''+')';
    pubqry.close;
    pubqry.sql.clear;
    pubqry.sql.add(s);
    pubqry.execsql;
   end;
//}
  TRY
  s_rec:=s_rec+1;
    T := TINIFILE.Create(INIFILENAME);
    T.WriteINTEGER('rec',filename, s_rec);
  FINALLY   T.FREE;
  END;
  edit1.text:=inttostr(strtoint(edit1.Text)+1);
end;
end;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
edit1.text:='0';
end;

end.

⌨️ 快捷键说明

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