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

📄 u_main.pas

📁 语音坐席,支持录音及语音回访,和自动催款
💻 PAS
📖 第 1 页 / 共 4 页
字号:

     AIniFile.Free;
end;

//根据信息 内通的到 超级连接
Function  TMCTIForm.GetHttp(Info:String):String;
Begin
     QPub.Close;
     QPub.SQL.Clear;
     QPub.SQL.Add('Select Http From 资料库 Where 咨询内容='+QuotedStr(Info));
     QPub.Open;

     Result:=QPub.FieldByName('Http').AsString;
     QPub.Close;
End;

Procedure TMCTIForm.GetList;
Begin
     If Not CSSZ.Query1.Active Then CSSZ.Query1.Open;

     DBComboBoxEh1.Items.Assign(CSSZ.DBMemo9.Lines);
     DBComboBoxEh3.Items.Assign(CSSZ.DBMemo1.Lines);
     DBComboBoxEh4.Items.Assign(CSSZ.DBMemo2.Lines);
     DBComboBoxEh5.Items.Assign(CSSZ.DBMemo3.Lines);
     CheckListBox1.Items.Assign(CSSZ.DBMemo3.Lines);
     DBComboBoxEh6.Items.Assign(CSSZ.DBMemo4.Lines);
     //DBComboBoxEh7.Items.Assign(CSSZ.DBMemo5.Lines);
     DBComboBoxEh8.Items.Assign(CSSZ.DBMemo6.Lines);
     DBComboBoxEh9.Items.Assign(CSSZ.DBMemo8.Lines);
     DBComboBoxEh10.Items.Assign(CSSZ.DBMemo7.Lines);
     DBComboBoxEh12.Items.Assign(CSSZ.DBMemo14.Lines);

     If DBComboBoxEh2.Text='数字' Then
     Begin
          DBComboBoxEh4.Items.Assign(CSSZ.DBMemo12.Lines);
          DBComboBoxEh6.Items.Assign(CSSZ.DBMemo13.Lines);
     End
     Else If DBComboBoxEh2.Text='宽带' Then
     Begin
          DBComboBoxEh4.Items.Assign(CSSZ.DBMemo10.Lines);
          DBComboBoxEh6.Items.Assign(CSSZ.DBMemo11.Lines);
     End
     Else
     Begin
          DBComboBoxEh4.Items.Assign(CSSZ.DBMemo2.Lines);
          DBComboBoxEh6.Items.Assign(CSSZ.DBMemo4.Lines);
     End;
     
     DBComboBoxEh7.Items.Clear;
     QPub.Close;
     QPub.SQL.Clear;
     QPub.SQL.Add('Select 咨询内容 From 资料库 Order By 序号');
     QPub.Open;
     While Not QPub.Eof Do
     Begin
          DBComboBoxEh7.Items.Add(QPub.FieldByName('咨询内容').AsString);
          QPub.Next;
     End;

     CZY.Items.Clear;
     QPub.Close;
     QPub.SQL.Clear;
     QPub.SQL.Add('Select * From CZY');
     QPub.Open;
     While Not QPub.Eof Do
     Begin
          CZY.Items.Add(QPub.FieldByName('YHMC').AsString);
          QPub.Next;
     End;
     QPub.Close;
End;

procedure TMCTIForm.FormShow(Sender: TObject);
Var I:Byte;
    SLT: SYSTEMTIME;
    iYear,iMonth,iDay,iHour,iMinute,iSecond,iMSec:Word;
    dDateTime:TDateTime;
begin
     StringGrid1.Cells[0,0]:='序号';
     StringGrid1.Cells[1,0]:='电话';

     dDateTime:=CSSZ.SysDateTime;
     DecodeDate(dDateTime,iYear,iMonth,iDay);
     DecodeTime(dDateTime,iHour,iMinute,iSecond,iMSec);
     SLT.wYear:=iYear;
     SLT.wMonth:=iMonth;
     SLT.wDay:=iDay;
     SLT.wHour:=iHour;
     SLT.wMinute:=iMinute;
     SLT.wSecond:=iSecond;
     SetLocalTime(SLT);

     MsgTime:=Now;
     
     Randomize;
     For I:=1 To 16 Do Workers[I].State:=0;
     ScrollBox1.DoubleBuffered:=True;

     GetList;

     ReSetMenu(MainMenu1,CZYQX);
     N14.Caption:='操作员:'+CZYXM;


     DBComboBoxEh4.Enabled:=(Pos('故障现象',CZYQX)>0);
     DBDateTimeEditEh3.Enabled:=(Pos('派工时间',CZYQX)>0);
     DBDateTimeEditEh2.Enabled:=(Pos('完工时间',CZYQX)>0);
     DBDateTimeEditEh1.Enabled:=(Pos('预约时间',CZYQX)>0);
     DBComboBoxEh5.Enabled:=(Pos('维修/安装人',CZYQX)>0);
     DBComboBoxEh12.Enabled:=(Pos('监控判断结果',CZYQX)>0);
     DBComboBoxEh11.Enabled:=(Pos('CM在线',CZYQX)>0);
     DBEditEh7.Enabled:=(Pos('设备信噪比',CZYQX)>0);
     DBEditEh9.Enabled:=(Pos('端口利用率',CZYQX)>0);
     DBComboBoxEh6.Enabled:=(Pos('维修结果及原因',CZYQX)>0);
     DBEditEh10.Enabled:=(Pos('故障备注',CZYQX)>0);
     DBComboBoxEh10.Enabled:=(Pos('回访结果',CZYQX)>0);

     //I:=NetMap1.AddLayerFromTable('SL3000.LF','');
     //NetMap1.SetLayerLabeled(I,True);
     //NetMap1.AddLayerFromTable('SL3000.Map_TL','');
     //NetMap1.ShowAllMap;
     NetMap1.CurrentTool:=PanTool;
end;

//显示作息状态
procedure TMCTIForm.PaintBox1Paint(Sender: TObject);
Var I:Byte;
    W:Integer;
    Stemp:String;
    ARect:TRect;
begin
     PaintBox1.Canvas.Pen.Style:=psClear;
     If Timer1.Enabled Then
        PaintBox1.Canvas.Brush.Color:=clWindow
     Else
         PaintBox1.Canvas.Brush.Color:=clYellow;

     PaintBox1.Canvas.Brush.Style:=bsSolid;
     PaintBox1.Canvas.FillRect(PaintBox1.ClientRect);

     ARect:=PaintBox1.ClientRect;
     ARect.Left:=PaintBox1.Width-105;
     PaintBox1.Canvas.Brush.Color:=clInfoBK;
     PaintBox1.Canvas.FillRect(ARect);

     For I:=1 To WorkerNum Do
     Begin
          W:=Round(((PaintBox1.Width-100)/WorkerNum)*(I-1)+(PaintBox1.Width-100)/WorkerNum/2-16);
          ImageList1.Draw(PaintBox1.Canvas,W,2,Workers[I].State);
          If Workers[I].Selected Then ImageList1.Draw(PaintBox1.Canvas,W,20,4);

          Stemp:=Workers[I].Name;
          PaintBox1.Canvas.Brush.Style:=bsClear;
          W:=Round((PaintBox1.Width-100)/WorkerNum*(I-1)+((PaintBox1.Width-100)/WorkerNum-PaintBox1.Canvas.TextWidth(Stemp))/2);
          PaintBox1.Canvas.TextOut(W,38,Stemp);
     End;

     //外线状态
     For I:=0 To 7 Do
     Begin
          If ChannelS[I].chState=0 Then
             ImageList1.Draw(PaintBox1.Canvas,PaintBox1.Width-110+I*12,2,8)
          Else If ChannelS[I].chState=2 Then
               ImageList1.Draw(PaintBox1.Canvas,PaintBox1.Width-110+I*12,0,10)
          Else
              ImageList1.Draw(PaintBox1.Canvas,PaintBox1.Width-110+I*12,2,7);
          PaintBox1.Canvas.TextOut(PaintBox1.Width-98+I*12,38,IntToStr(I));
     End;
end;

//单击选择作息
procedure TMCTIForm.PaintBox1MouseDown(Sender: TObject;
  Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
Var I:Byte;
begin
     For I:=1 To WorkerNum Do Workers[I].Selected:=((X>(I-1)*((PaintBox1.Width-100)/WorkerNum)) AND (X<I*((PaintBox1.Width-100)/WorkerNum)));
     PaintBox1.Repaint;
end;

Function GetComputerUserName:AnsiString;
var CNameBuffer   :   PChar;
    fl_loaded   :   Boolean;
    CLen   :   ^DWord;
begin
     GetMem(CNameBuffer,255);
     New(CLen);
     CLen^:=255;
     fl_loaded:=GetComputerName(CNameBuffer,CLen^);
     if fl_loaded then
        Result:=StrPas(CNameBuffer)
     else
         Result:='Unkown';
     FreeMem(CNameBuffer,255);
     Dispose(CLen);
end;   

//心跳
procedure TMCTIForm.Timer1Timer(Sender: TObject);
Var I,J,N:Integer;
    CName:String;
    W:Boolean;
begin
     Label37.Caption:=FormatDateTime('HH:MM:SS',Now);
     
     //读数据库得到状态
     CName:=GetComputerUserName;
     QueryBD.Close;
     While QueryBD.SQL.Count>1 Do QueryBD.SQL.Delete(1);
     QueryBD.Open;

     While Not QueryBD.Eof Do
     Begin
          I:=QueryBD.FieldByName('chIndex').AsInteger;

          ChannelS[I].chIndex:=I;
          ChannelS[I].chOK:=(QueryBD.FieldByName('chOK').AsString='1');
          ChannelS[I].chOL:=(QueryBD.FieldByName('chOL').AsString='1');
          ChannelS[I].chState:=QueryBD.FieldByName('chState').AsInteger;
          ChannelS[I].chType:=QueryBD.FieldByName('chType').AsInteger;
          ChannelS[I].ComputerName:=QueryBD.FieldByName('ComputerName').AsString;
          ChannelS[I].wfState:=QueryBD.FieldByName('wfState').AsInteger;
          ChannelS[I].NewSN:=QueryBD.FieldByName('NewSN').AsInteger;

          StringGrid1.Cells[0,I+1]:=IntToStr(I);
          StringGrid1.Cells[1,I+1]:=QueryBD.FieldByName('Phone').AsString;

          //消息
          If QueryBD.FieldByName('MSGTIME').AsDateTime>MsgTime Then
          Begin
               StatusBar1.Panels[1].Text:=QueryBD.FieldByName('COMPUTERNAME').AsString+':'+QueryBD.FieldByName('Msg').AsString;
               MsgTime:=QueryBD.FieldByName('MSGTIME').AsDateTime;

               W:=True;
               For N:=1 To 6 Do
               Begin
                    FlashWindow(Handle,W);
                    W:=Not W;
               End;
          End;

          //更新我的状态
          If ChannelS[I].ComputerName=CName Then
          Begin
               QueryBD.Edit;
               If SPB_BUSY.Down Then
                  QueryBD.FieldByName('Busy').AsString:='1'
               Else
                   QueryBD.FieldByName('Busy').AsString:='0';

               QueryBD.FieldByName('CaoZY').AsString:=CZYXM;
               If UserMsg<>'' Then
               Begin
                    QueryBD.FieldByName('MSG').AsString:=UserMsg;
                    QueryBD.FieldByName('MSGTIME').AsDateTime:=Now;
                    UserMsg:='';
               End;
               QueryBD.FieldByName('LastTime').AsInteger:=GetTickCount;
               QueryBD.FieldByName('toCH').AsInteger:=-1;
               If SPB_MOVE.Down Then
               For J:=1 To WorkerNum Do
               If Workers[J].Selected Then
               Begin
                    QueryBD.FieldByName('toCH').AsInteger:=Workers[J].ID;
                    Break;
               End;
               QueryBD.Post;
               QueryBD.ApplyUpdates;
               QueryBD.CommitUpdates;
          End;

          QueryBD.Next;
     End;
     PaintBox1.Repaint;

     WorkerNum:=0;
     For I:=0 To 15 Do
     If ChannelS[I].chType=2 Then
     With ChannelS[I] Do
     Begin
          Inc(WorkerNum);
          Workers[WorkerNum].ID:=ChannelS[I].chIndex;
          Workers[WorkerNum].Name:=ComputerName;

          If Not chOL Then
             Workers[WorkerNum].State:=0
          Else
          Begin
               If Not chOK Then
                  Workers[WorkerNum].State:=3
               Else If chState=0 Then
                    Workers[WorkerNum].State:=1
               Else
                   Workers[WorkerNum].State:=2;
          End;

          If ComputerName=CName Then
          Begin
               If wfState=30 Then
               If NewSN>0 Then
               If LastOpened<>NewSN Then
               If ((Not Query1.Active) OR (Query1.FieldByName('序号').AsInteger<>Channels[I].NewSN)) Then
               Begin
                    Query1.Close;
                    While Query1.SQL.Count>1 Do Query1.SQL.Delete(1);
                    Query1.SQL.Add('Where 序号='+IntToStr(Channels[I].NewSN));
                    Query1.Open;

                    If Query1.FieldByName('序号').AsInteger=Channels[I].NewSN Then
                    Begin
                         Query1.Edit;
                         If DBComboBoxEh1.Items.Count>0 Then
                            Query1.FieldByName('服务类型').AsString:=DBComboBoxEh1.Items[0];
                         Query1.FieldByName('业务类型').AsString:='模拟';
                         Query1.FieldByName('接待员').AsString:=CZYXM;
                         Query1.Post;
                    End;

                    LastOpened:=NewSN;

                    //是否当天第二次
                    If CheckRepeat Then
                    Begin
                         Application.MessageBox('今天已经有过一次服务记录,请察看历史信息!','提示',MB_OK+MB_ICONINFORMATION);

                         Query1.Close;
                         Query1.SQL.Clear;
                         Query1.SQL.Add('Select * From 服务单');
                         Query1.SQL.Add('Where 1>0');
                         Query1.SQL.Add('And 电话='+QuotedStr(DH));
                         Query1.SQL.Add('And To_Char(时间,''YYYY-MM-DD'')=To_Char(SysDate,''YYYY-MM-DD'')');
                         //Query1.SQL.Add('And 序号<>'+Query1.FieldByName('序号').AsString);
                         Query1.Open;

                         Query1.First;
                    End;
               End;
          End;
     End;
end;

//服务器返回各坐席状态
procedure TMCTIForm.Query1AfterPost(DataSet: TDataSet);
begin
     Query1.ApplyUpdates;
     Query1.CommitUpdates;
end;

procedure TMCTIForm.SpeedButton1Click(Sender: TObject);
begin
     Query1.Post;
end;

procedure TMCTIForm.SPB_RECORDClick(Sender: TObject);
begin
     Query1.Close;
     While Query1.SQL.Count>1 Do Query1.SQL.Delete(1);
     Query1.SQL.Add('Where SysDate-时间<3');
     Query1.SQL.Add('Order By 序号');
     Query1.Open;
end;

procedure TMCTIForm.Query1BeforePost(DataSet: TDataSet);
begin
     If Pos('修改业务信息',CZYQX)<=0 Then
     Begin
          Abort;
          Query1.Cancel;
     End;

     If Query1.FieldByName('接待员').IsNull Then
     Begin
          //接待人及接待时间
          Query1.FieldByName('接待员').AsString:=CZYXM;
     End;

     If Not Query1.FieldByName('维修员').IsNull Then
     If Query1.FieldByName('派工人').IsNull Then
     Begin
          //派工人 派工时间
          Query1.FieldByName('派工人').AsString:=CZYXM;
          //Query1.FieldByName('派单时间').AsDateTime:=CSSZ.SysDateTime;
     End;

     If Not Query1.FieldByName('回访结果').IsNull Then
     If Query1.FieldByName('回访人员').IsNull Then
     Begin
          //回访人员 回访时间
          Query1.FieldByName('回访人员').AsString:=CZYXM;
          Query1.FieldByName('回访时间').AsDateTime:=CSSZ.SysDateTime;
     End;

     If Not Query1.FieldByName('监控判断结果').IsNull Then
     If Query1.FieldByName('初步判断人').IsNull Then
     Begin
          //回访人员 回访时间
          Query1.FieldByName('初步判断人').AsString:=CZYXM;
          Query1.FieldByName('监控判断时间').AsDateTime:=CSSZ.SysDateTime;
     End;

     If Query1.FieldByName('维修用时').IsNull Then
     If Not Query1.FieldByName('修好日期').IsNull Then
     Begin
          QPub.Close;
          QPub.SQL.Clear;
          QPub.SQL.Add('Update 服务单 Set 维修用时=(修好日期-派单时间)*24*60 Where 序号='+Query1.FieldByName('序号').AsString);
          QPub.ExecSQL;
     End;
end;

//自动保存
procedure TMCTIForm.Query1BeforeClose(DataSet: TDataSet);
begin
     If Query1.State=dsEdit Then Query1.Post;
end;

//播放指定的声音文件
Procedure TMCTIForm.SoundPlay;
Var FullName:String;
Begin
     If Not Query1.Active Then Exit;
     If Query1.FieldByName('序号').IsNull Then Exit;
     If Query1.FieldByName('序号').AsInteger<=0 Then Exit;


     {Query2.Close;
     While Query2.SQL.Count>1 Do Query2.SQL.Delete(1);
     Query2.SQL.Add('Where 序号='+Query1.FieldByName('序号').AsString);
     Query2.Open;

     If Query2.FieldByName('录音').IsNull Then
     Begin
          Application.MessageBox('无录音数据,无法播放!','提示',MB_OK+MB_ICONSTOP);
          Query2.Close;
          Exit;
     End;

     FullName:=ExtractFilePath(Application.ExeName)+'TEMP.WAV';
     Query2BDEDesigner2.SaveToFile(FullName);}
     
     FullName:='Z:\'+FormatFloat('00000000',Query1.FieldByName('序号').AsInteger)+'.wav';
     If FileExists(FullName) Then
     Begin
          //sndPlaySound(PChar(FullName), SND_NODEFAULT Or SND_ASYNC);
          ShellExecute(Handle,PChar('open'),PChar(FullName),Nil,Nil,1);
     End
     Else
         Application.MessageBox('找不到指定的文件!','提示',MB_OK+MB_ICONINFORMATION);
End;

//通过播放一个短声音来停止播放录音
Procedure TMCTIForm.SoundStop;
Var FullName:String;
Begin
     FullName:=ExtractFilePath(Application.ExeName)+'notify.wav';
     If FileExists(FullName) Then
        sndPlaySound(PChar(FullName), SND_NODEFAULT Or SND_ASYNC)
     Else
         Application.MessageBox('找不到指定的声音文件 notify.wav !','提示',MB_OK+MB_ICONSTOP);
End;

procedure TMCTIForm.SPB_PLAYClick(Sender: TObject);
begin
     SoundPlay;
end;
procedure TMCTIForm.SPB_StopClick(Sender: TObject);
begin
     SoundStop;

⌨️ 快捷键说明

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