329 lines
8.8 KiB
ObjectPascal
329 lines
8.8 KiB
ObjectPascal
unit uBlandConent;
|
|
|
|
interface
|
|
|
|
uses
|
|
System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
|
|
FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, FMX.Objects,
|
|
System.ImageList, FMX.ImgList, FMX.Controls.Presentation, FMX.Edit,uTcpDevice,
|
|
FMX.Layouts, System.Rtti, FMX.Grid.Style, FMX.Memo, FMX.ScrollBox, FMX.Grid,
|
|
Winapi.Windows, uDM,uShowInfo, FMX.StdCtrls,uKsoap,uSafeLog,Winapi.ActiveX,
|
|
System.StrUtils, FMX.Memo.Types;
|
|
|
|
type
|
|
TfrmBlandConent = class(TForm)
|
|
Rectangle1: TRectangle;
|
|
Rectangle2: TRectangle;
|
|
Rectangle3: TRectangle;
|
|
TxtFactoryCode: TText;
|
|
Rectangle4: TRectangle;
|
|
Rectangle6: TRectangle;
|
|
Text2: TText;
|
|
ImageList1: TImageList;
|
|
Rectangle18: TRectangle;
|
|
Rectangle19: TRectangle;
|
|
Rectangle20: TRectangle;
|
|
Text7: TText;
|
|
Rectangle26: TRectangle;
|
|
Text17: TText;
|
|
Rectangle33: TRectangle;
|
|
Rectangle5: TRectangle;
|
|
Rectangle7: TRectangle;
|
|
Rectangle8: TRectangle;
|
|
Rectangle10: TRectangle;
|
|
Rectangle12: TRectangle;
|
|
Memo1: TMemo;
|
|
Text4: TText;
|
|
Text5: TText;
|
|
Rectangle15: TRectangle;
|
|
Rectangle16: TRectangle;
|
|
Rectangle17: TRectangle;
|
|
Rectangle22: TRectangle;
|
|
Text11: TText;
|
|
TxtEmpNo: TText;
|
|
Rectangle25: TRectangle;
|
|
Text12: TText;
|
|
TxtLotNo: TText;
|
|
Rectangle28: TRectangle;
|
|
Text13: TText;
|
|
TxtGoodsNo: TText;
|
|
Rectangle29: TRectangle;
|
|
Line1: TLine;
|
|
Rectangle30: TRectangle;
|
|
Line2: TLine;
|
|
Text14: TText;
|
|
TxtPc: TText;
|
|
Text18: TText;
|
|
TxtLine: TText;
|
|
Text20: TText;
|
|
TxtLineNum: TText;
|
|
Rectangle31: TRectangle;
|
|
Text22: TText;
|
|
TxtLotNum: TText;
|
|
Rectangle32: TRectangle;
|
|
Line3: TLine;
|
|
Rectangle35: TRectangle;
|
|
Text21: TText;
|
|
Text16: TText;
|
|
Glyph23: TGlyph;
|
|
Rectangle001: TRectangle;
|
|
Glyph1: TGlyph;
|
|
Text6: TText;
|
|
TxtPc11: TText;
|
|
EdtInput1: TEdit;
|
|
Rectangle23: TRectangle;
|
|
Text1: TText;
|
|
Text10: TText;
|
|
TxtError: TText;
|
|
Timer1: TTimer;
|
|
procedure Text16Click(Sender: TObject);
|
|
procedure FormCreate(Sender: TObject);
|
|
procedure FormDestroy(Sender: TObject);
|
|
procedure Text5Click(Sender: TObject);
|
|
procedure Rectangle20Click(Sender: TObject);
|
|
procedure FormClose(Sender: TObject; var Action: TCloseAction);
|
|
procedure Text1Click(Sender: TObject);
|
|
procedure Text17Click(Sender: TObject);
|
|
procedure Timer1Timer(Sender: TObject);
|
|
private
|
|
BarCodeDic:TStringList;
|
|
procedure F2DCodeWork(Sender: TObject;sValue: string);
|
|
procedure NumEnceWork(Avalue: string);
|
|
procedure RfidWork(Avalue: string);
|
|
procedure F2DCodeShowState(Avalue: string); //显示读头状态
|
|
procedure AddLog(sLog:string);
|
|
procedure ShowEndNum();
|
|
{ Private declarations }
|
|
public
|
|
iDetailCount:Integer;
|
|
iCount:Integer;
|
|
vP_ID:Double;
|
|
vId:integer;
|
|
F2DCode:array[0..9] of T2DCode;
|
|
Rfid:TRfid;
|
|
NumEnce:TNumEnce;
|
|
LotNoRecord:TLotNoRecord;
|
|
end;
|
|
|
|
{
|
|
不扫码生产界面
|
|
}
|
|
|
|
var
|
|
frmBlandConent: TfrmBlandConent;
|
|
|
|
implementation
|
|
|
|
{$R *.fmx}
|
|
|
|
uses uPucFun, uMain, uAlarmLed;
|
|
|
|
procedure TfrmBlandConent.NumEnceWork(Avalue: string);
|
|
begin
|
|
end;
|
|
|
|
procedure TfrmBlandConent.RfidWork(Avalue: string);
|
|
begin
|
|
end;
|
|
|
|
procedure TfrmBlandConent.ShowEndNum();
|
|
begin
|
|
end;
|
|
|
|
procedure TfrmBlandConent.AddLog(sLog:string);
|
|
begin
|
|
if Memo1.Lines.Count>100 then
|
|
Memo1.Lines.Delete(0);
|
|
Memo1.Lines.Add(FormatDateTime('yyyymmdd hh:mm:ss.zzz ',Now)+sLog);
|
|
Memo1.SelStart:=Length(Memo1.Text);
|
|
Memo1.SelLength:=0;
|
|
end;
|
|
|
|
procedure TfrmBlandConent.F2DCodeShowState(Avalue: string); //显示读头状态
|
|
begin
|
|
AddLog(Avalue);
|
|
end;
|
|
|
|
procedure TfrmBlandConent.F2DCodeWork(Sender:TObject;sValue: string); //读取条码
|
|
begin
|
|
end;
|
|
|
|
procedure TfrmBlandConent.FormClose(Sender: TObject; var Action: TCloseAction);
|
|
begin
|
|
//退出的时候
|
|
dm.InsertQtyTime(vId.ToString,'0',TxtLotNum.Text,'-1','-1','-1','-1');
|
|
end;
|
|
|
|
procedure TfrmBlandConent.FormCreate(Sender: TObject);
|
|
var
|
|
sDevName,sIp,sPort:string;
|
|
tmpValue:string;
|
|
i:integer;
|
|
begin
|
|
TxtFactoryCode.Text:= FactoryCode; //厂区
|
|
TxtEmpNo.Text:=ksoap.P_WORK_NUM; //工号
|
|
TxtLotNo.Text:=ksoap.P_Lot; //批号
|
|
TxtGoodsNo.Text:=ksoap.P_Goods_Num; //料号
|
|
TxtPc.Text:=ksoap.P_PC; //制程代码
|
|
TxtLine.Text:=ksoap.P_LINE; //制程名
|
|
TxtLineNum.Text:=ksoap.P_LINE_NUM; //线别
|
|
TxtLotNum.Text:=ksoap.P_Lot_Num.tostring;
|
|
ShowEndNum();
|
|
|
|
// TxtVerInfo.Text:=GetBuildInfo;
|
|
Memo1.Lines.Clear;
|
|
TxtShowErrorInfo(TxtError,'');
|
|
iCount:=0;
|
|
iDetailCount:=0;
|
|
BarCodeDic:=TStringList.Create;
|
|
BarCodeDic.Sorted:=true;
|
|
//Rectangle001.Visible:=ksoap.P_LINE='油墨印刷機';
|
|
|
|
//根据配置加载设备
|
|
for i := 1 to 9 do
|
|
begin
|
|
tmpValue:=dm.MemTableReadKeyValue('读头','tv_line_speed'+i.ToString);
|
|
if tmpValue<>'' then
|
|
begin
|
|
if CheckParameter(tmpValue,sDevName,sIp,sPort) then
|
|
begin
|
|
// if sameText(sDevName.ToLower,'keyence') then //2D读头
|
|
// begin
|
|
// F2DCode[i]:=T2DCode.Create(sIp,sPort.ToInteger);
|
|
// F2DCode[i].Num:=i;
|
|
// F2DCode[i].OnWork:=F2DCodeWork;
|
|
// F2DCode[i].OnShowState:=F2DCodeShowState;
|
|
// F2DCode[i].Connect;
|
|
// TThread.CreateThreadX<Integer>(
|
|
// procedure (Avalue:Integer)
|
|
// begin
|
|
// Sleep(1000);
|
|
// TThread.Synchronize( nil,
|
|
// procedure
|
|
// begin
|
|
// F2DCode[Avalue].Open;
|
|
// end
|
|
// );
|
|
// end,i
|
|
// ).Start;
|
|
// end;
|
|
|
|
if sameText(sDevName,'RFID') then //RFID
|
|
begin
|
|
Rfid:=TRfid.Create(sIp,sPort.ToInteger);
|
|
Rfid.OnWork:=RfidWork;
|
|
end;
|
|
|
|
if sameText(sDevName,'WJ95') then //采集器
|
|
begin
|
|
NumEnce:=TNumEnce.Create(sIp,sPort.ToInteger);
|
|
NumEnce.OnWork:=NumEnceWork;
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
end;
|
|
|
|
procedure TfrmBlandConent.FormDestroy(Sender: TObject);
|
|
var
|
|
i:integer;
|
|
begin
|
|
for i := 0 to 9 do
|
|
begin
|
|
if F2DCode[i]<>nil then
|
|
begin
|
|
F2DCode[i].Close;
|
|
Sleep(200);
|
|
FreeandNil(F2DCode[i]);
|
|
end;
|
|
end;
|
|
if Rfid<>nil then FreeandNil(Rfid);
|
|
if NumEnce<>nil then FreeandNil(NumEnce);
|
|
BarCodeDic.Free;
|
|
end;
|
|
|
|
procedure TfrmBlandConent.Rectangle20Click(Sender: TObject);
|
|
begin
|
|
if ShowInfoOKCancel('該批還沒有完成,真的要退出嗎?') then Close;
|
|
end;
|
|
|
|
procedure TfrmBlandConent.Text16Click(Sender: TObject);
|
|
begin
|
|
ShowTouchKeyBoard();
|
|
end;
|
|
|
|
procedure TfrmBlandConent.Text17Click(Sender: TObject);
|
|
begin
|
|
Close;
|
|
end;
|
|
|
|
procedure TfrmBlandConent.Text1Click(Sender: TObject);
|
|
var
|
|
sError:string;
|
|
begin
|
|
sError:='';
|
|
//更换烤箱号
|
|
if Text1.TextSettings.FontColor=TAlphaColorRec.Silver then Exit;
|
|
|
|
Text1.TextSettings.FontColor:=TAlphaColorRec.Silver;
|
|
try
|
|
if ShowInfoOKCancel(Format('確定要%s嗎?',[Text6.Text])) then
|
|
begin
|
|
if not Ksoap.Thread_Check_tool_or_equip_status_f(Ksoap.P_Lot,Ksoap.P_LINE_NUM,EdtInput1.Text,'-1',sError) then
|
|
begin
|
|
TxtShowErrorInfo(TxtError,sError);
|
|
Exit;
|
|
end;
|
|
|
|
vP_ID:=Ksoap.Thread_cf_traceability_seq_f(Ksoap.P_ORG_CODE,sError);
|
|
if vP_ID=0 then //取不到ID
|
|
begin
|
|
TxtShowErrorInfo(TxtError,sError);
|
|
Exit;
|
|
end;
|
|
dm.InsertQtyTime(vId.ToString,'0',iDetailCount.ToString,'-1','-1','-1','-1');
|
|
iDetailCount:=0;
|
|
|
|
LotNoRecord.P_ID:=vP_ID;
|
|
LotNoRecord.P_TROLLEY_NUM := EdtInput1.Text;
|
|
if vP_ID=0 then
|
|
BEGIN
|
|
dm.InsertMain(vId,LotNoRecord,false);
|
|
END
|
|
ELSE
|
|
BEGIN
|
|
//直接调用API,出错再保存本地
|
|
if not Ksoap.Thread_Insert_CM_WIP_PROCESS_LINE_HISTORY_NEW(LotNoRecord,sError) then //提交主表不成功
|
|
begin
|
|
if sError='連接數據庫服務器失败' then
|
|
begin
|
|
dm.InsertMain(vId,LotNoRecord,false);
|
|
end
|
|
else
|
|
ShowError(sError);
|
|
end
|
|
else
|
|
begin
|
|
dm.InsertMain(vId,LotNoRecord,false);
|
|
dm.UpdateMainId(vId,vP_ID.ToString,True);
|
|
end;
|
|
END;
|
|
end;
|
|
finally
|
|
Text1.TextSettings.FontColor:=TAlphaColorRec.White;
|
|
end;
|
|
end;
|
|
|
|
procedure TfrmBlandConent.Text5Click(Sender: TObject);
|
|
begin
|
|
MEMO1.Lines.Clear;
|
|
end;
|
|
|
|
procedure TfrmBlandConent.Timer1Timer(Sender: TObject);
|
|
begin
|
|
Text2.Text:= GetSysTimeByFormate;
|
|
end;
|
|
|
|
end.
|