372 lines
9.5 KiB
ObjectPascal
372 lines
9.5 KiB
ObjectPascal
unit uFrame_yandao;
|
||
|
||
interface
|
||
|
||
uses
|
||
System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
|
||
FMX.Types, FMX.Graphics, FMX.Controls, FMX.Forms, FMX.Dialogs, FMX.StdCtrls,
|
||
uFrameBase, System.ImageList, FMX.ImgList, FMX.ListBox, uksoap,System.StrUtils,
|
||
FMX.Controls.Presentation, FMX.Edit, FMX.Objects,uShowInfo,uTCPDevice,
|
||
FMX.ScrollBox, FMX.Memo, FMX.Memo.Types;
|
||
|
||
type
|
||
TFrame_yandao = class(TFrameBase)
|
||
Rectangle88: TRectangle;
|
||
Option1: TRectangle;
|
||
Glyph9: TGlyph;
|
||
OptionLabel1: TText;
|
||
Text19: TText;
|
||
Edit_KuangJi: TEdit;
|
||
Option2: TRectangle;
|
||
Glyph2: TGlyph;
|
||
OptionLabel3: TText;
|
||
Text6: TText;
|
||
Edit_ChengShi: TEdit;
|
||
TxtError: TText;
|
||
ImageList1: TImageList;
|
||
Rectangle1: TRectangle;
|
||
Glyph1: TGlyph;
|
||
Text1: TText;
|
||
Text2: TText;
|
||
Edit1: TEdit;
|
||
Button1: TButton;
|
||
Rectangle2: TRectangle;
|
||
Glyph3: TGlyph;
|
||
Text3: TText;
|
||
Text4: TText;
|
||
Memo1: TMemo;
|
||
Button2: TButton;
|
||
Text5: TText;
|
||
Text7: TText;
|
||
procedure Edit_ChengShiKeyDown(Sender: TObject; var Key: Word;
|
||
var KeyChar: Char; Shift: TShiftState);
|
||
procedure Edit_ChengShiClick(Sender: TObject);
|
||
procedure Edit_KuangJiExit(Sender: TObject);
|
||
procedure Button1Click(Sender: TObject);
|
||
procedure Button2Click(Sender: TObject);
|
||
procedure Memo1KeyDown(Sender: TObject; var Key: Word; var KeyChar: Char;
|
||
Shift: TShiftState);
|
||
private
|
||
procedure Check_tool_work(Value: string);
|
||
{ Private declarations }
|
||
public
|
||
function F2DCodeCreate():boolean; override; //連接读头
|
||
procedure FillDefaultValue(sPartnumValue,sDefaultTxt:string);override; //填写默认值
|
||
function DoExec():boolean;override; //判断输入是否有效,执行插入主表,或打开窗体
|
||
function CheckValid(var sTxt:string):boolean;override;
|
||
function GetFixture_Code():string;override; //返回治具ID
|
||
procedure Initialize(); override;//初始化
|
||
end;
|
||
|
||
//var
|
||
// Frame_Plasma: TFrame_Plasma;
|
||
|
||
implementation
|
||
|
||
{$R *.fmx}
|
||
uses uDM, uBlandConent, uPucFun, uCodeConent, uSafeLog;
|
||
{
|
||
285090
|
||
D3007585AG
|
||
}
|
||
|
||
function TFrame_yandao.F2DCodeCreate():boolean;
|
||
var
|
||
sDevName,sIp,sPort:string;
|
||
tmpValue:string;
|
||
// i:integer;
|
||
begin
|
||
Memo1.Lines.Clear;
|
||
Error(Memo1,TxtError,'');
|
||
|
||
if frmCodeConent=nil then
|
||
begin
|
||
try
|
||
frmCodeConent:= TfrmCodeConent.Create(nil);
|
||
with frmCodeConent do
|
||
try
|
||
ShowModal;
|
||
WorkLog.Debug('条码:'+F2DCodeValue);
|
||
Self.Memo1.Text:= (F2DCodeValue);
|
||
|
||
finally
|
||
Free;
|
||
frmCodeConent:= nil;
|
||
end;
|
||
|
||
if (Self.Memo1.Text<>'') then
|
||
Check_tool_work(Self.Memo1.Text);
|
||
except
|
||
WorkLog.Debug('条码1:error');
|
||
end;
|
||
end;
|
||
// exit;
|
||
//Rectangle001.Visible:=ksoap.P_LINE='油墨印刷機';
|
||
|
||
// if TCPDeviceNew=nil then
|
||
// TThread.CreateAnonymousThread(
|
||
// procedure
|
||
// var
|
||
// i:integer;
|
||
// begin
|
||
//
|
||
//
|
||
//
|
||
// i:= 0;
|
||
//
|
||
// while (TCPDeviceNew.F2DCodeValue='') and (i<1) do
|
||
// begin
|
||
// Sleep(1000);
|
||
// inc(i);
|
||
// TThread.Synchronize( nil,
|
||
// procedure
|
||
// begin
|
||
// Error(Memo1,TxtError,'ok,'+IntToStr(i));
|
||
// end
|
||
// );
|
||
// end;
|
||
//
|
||
// if TCPDeviceNew.F2DCodeValue<>'' then
|
||
// begin
|
||
// TThread.Synchronize( nil,
|
||
// procedure
|
||
// begin
|
||
// Memo1.Lines.Text:= TCPDeviceNew.F2DCodeValue;
|
||
// Check_tool_work(Memo1.Lines.Text);
|
||
// Error(Memo1,TxtError,'ok');
|
||
// end
|
||
// );
|
||
// end;
|
||
//
|
||
// end).Start;
|
||
Result:= True;
|
||
|
||
end;
|
||
|
||
function TFrame_yandao.GetFixture_Code():string; //返回治具ID
|
||
begin
|
||
Result:=Edit_KuangJi.Text; //烤箱編號
|
||
end;
|
||
|
||
procedure TFrame_yandao.Check_tool_work(Value: string); //原物料編號
|
||
var
|
||
sError,sMemo:string;
|
||
begin
|
||
sMemo:= Trim(Value);
|
||
sMemo:= sMemo.Replace('#13','');
|
||
//獲取治工具或者設備的狀態
|
||
if not Ksoap.Thread_Check_tool_or_equip_status_f(ksoap.P_Lot,ksoap.P_LINE_NUM,sMemo,ksoap.P_WORK_NUM,sError) then
|
||
begin
|
||
// ShowMainError('',sError,'');
|
||
Error(Memo1,TxtError,sError);
|
||
Exit;
|
||
end;
|
||
// TxtShowErrorInfo(TxtError,'原物料編號');
|
||
end;
|
||
|
||
procedure TFrame_yandao.Memo1KeyDown(Sender: TObject; var Key: Word;
|
||
var KeyChar: Char; Shift: TShiftState);
|
||
begin
|
||
inherited;
|
||
if Key=13 then
|
||
begin
|
||
Check_tool_work(Memo1.Lines.Text);
|
||
end;
|
||
end;
|
||
|
||
procedure TFrame_yandao.Button1Click(Sender: TObject);
|
||
begin
|
||
inherited;
|
||
Edit_KuangJi.Text:= '';
|
||
end;
|
||
|
||
procedure TFrame_yandao.Button2Click(Sender: TObject);
|
||
begin
|
||
inherited;
|
||
Memo1.Lines.Text:= '';
|
||
end;
|
||
|
||
function TFrame_yandao.CheckValid(var sTxt:string):boolean; //返回面次数据
|
||
var
|
||
iP_LINE_SPEED: Currency;
|
||
P_BKfile: Currency;
|
||
begin
|
||
Result:= False;
|
||
if Trim(Edit_KuangJi.Text)='' then
|
||
begin
|
||
Error(Edit_KuangJi,TxtError,'模具編號不能為空');
|
||
Exit;
|
||
end;
|
||
|
||
if Trim(Edit_ChengShi.Text)='' then
|
||
begin
|
||
Error(Edit_ChengShi,TxtError,'線速不能為空');
|
||
Exit;
|
||
end;
|
||
|
||
if Trim(Edit1.Text)='' then
|
||
begin
|
||
Error(Edit1,TxtError,'放料軸張力不能為空');
|
||
Exit;
|
||
end;
|
||
|
||
try
|
||
iP_LINE_SPEED:= StrToFloat(Edit_ChengShi.Text);
|
||
P_BKfile:= StrToFloat(Edit1.Text);
|
||
|
||
if (iP_Line_speed>30) or (iP_Line_speed<0) then
|
||
begin
|
||
Error(Edit_ChengShi,TxtError,'線速不能超过范围值');
|
||
Exit;
|
||
end;
|
||
|
||
if (P_BKfile>45) or (P_BKfile<15) then
|
||
begin
|
||
Error(Edit1,TxtError,'放料軸張力不能超过范围值');
|
||
Exit;
|
||
end;
|
||
|
||
except
|
||
Exit;
|
||
end;
|
||
Result:= True;
|
||
end;
|
||
|
||
procedure TFrame_yandao.FillDefaultValue(sPartnumValue,sDefaultTxt:string);
|
||
begin
|
||
with TStringList.Create do
|
||
try
|
||
// a:= TStringList.Create;
|
||
Delimiter:= ',';
|
||
DelimitedText:= sDefaultTxt;
|
||
if Count>1 then Edit_ChengShi.Text:=Strings[0];
|
||
if Count>24 then Edit1.Text:=Strings[24];
|
||
|
||
finally
|
||
Free;
|
||
end;
|
||
|
||
// Edit_KuangJi.Text:=sDefaultTxt;
|
||
// Edit_ChengShi.Text:=sDefaultTxt;
|
||
// Edit1.Text:=sDefaultTxt;
|
||
end;
|
||
|
||
function TFrame_yandao.DoExec():boolean;
|
||
var
|
||
LotNoRecord:TLotNoRecord;
|
||
vId:Integer;
|
||
sTxt:string;
|
||
sError:string;
|
||
vP_ID:Double;
|
||
|
||
|
||
|
||
begin
|
||
Result:=False;
|
||
|
||
if CheckValid(sTxt) then //上传数据
|
||
begin
|
||
LotNoRecord:=TLotNoRecord.Create('-1'); //初始化记录
|
||
LotNoRecord.P_LOT:=ksoap.P_Lot;
|
||
LotNoRecord.P_Enable:='Y';
|
||
LotNoRecord.P_ID:=0;
|
||
LotNoRecord.P_ORG_CODE:=ksoap.P_ORG_CODE; //廠區
|
||
LotNoRecord.P_NUM:=ksoap.P_WORK_NUM; //工號
|
||
LotNoRecord.P_PC:=ksoap.P_PC; //製程
|
||
LotNoRecord.P_LINE:=ksoap.P_LINE; //線別
|
||
LotNoRecord.P_LINE_NUM:=ksoap.P_LINE_NUM; //線別編號
|
||
|
||
LotNoRecord.P_TROLLEY_NUM:=Trim(Edit_KuangJi.Text); //模具編號
|
||
LotNoRecord.P_LINE_SPEED:=StrToInt(Edit_ChengShi.Text); //線速
|
||
LotNoRecord.P_BKfile:=(Edit1.Text); //放料軸張力
|
||
LotNoRecord.P_CREATION_DATE:=FormatDateTime('yyyymmdd hh:mm:ss',Now);
|
||
|
||
sError:='';
|
||
vP_ID:=Ksoap.Thread_cf_traceability_seq_f(ksoap.P_ORG_CODE,sError);
|
||
LotNoRecord.P_ID:=vP_ID;
|
||
if vP_ID=0 then
|
||
BEGIN
|
||
dm.InsertMain(vId,LotNoRecord,false);
|
||
Result:=true;
|
||
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);
|
||
Result:=true;
|
||
end
|
||
else
|
||
ShowError(sError);
|
||
end
|
||
else
|
||
begin
|
||
dm.InsertMain(vId,LotNoRecord,false);
|
||
dm.UpdateMainId(vId,vP_ID.ToString,True);
|
||
Result:=true;
|
||
end;
|
||
END;
|
||
end;
|
||
//打开窗体
|
||
if Result then
|
||
begin
|
||
// if TCPDeviceNew<>nil then
|
||
// begin
|
||
// TCPDeviceNew.Destroy;
|
||
// TCPDeviceNew:= nil;
|
||
// end;
|
||
|
||
// WorkLog.MessageInfo('frmBlandPrinterConent');
|
||
frmBlandConent:=TfrmBlandConent.Create(nil);
|
||
try
|
||
frmBlandConent.LotNoRecord:=LotNoRecord; //记录
|
||
frmBlandConent.vP_ID:=LotNoRecord.P_ID; //ID號,需與主檔的ID號相同
|
||
frmBlandConent.vId:=vId; //本地表记录ID
|
||
// frmListConent.Text6.Text:='更改烤架編號';
|
||
frmBlandConent.ShowModal;
|
||
finally
|
||
frmBlandConent.Free;
|
||
end;
|
||
Initialize();
|
||
end;
|
||
|
||
end;
|
||
|
||
|
||
procedure TFrame_yandao.Edit_ChengShiClick(Sender: TObject);
|
||
begin
|
||
inherited;
|
||
ShowTouchKeyBoard();
|
||
end;
|
||
|
||
procedure TFrame_yandao.Edit_ChengShiKeyDown(Sender: TObject; var Key: Word;
|
||
var KeyChar: Char; Shift: TShiftState);
|
||
begin
|
||
inherited;
|
||
NumbersOnly(Sender,Key,KeyChar,Shift);
|
||
end;
|
||
|
||
procedure TFrame_yandao.Edit_KuangJiExit(Sender: TObject);
|
||
var
|
||
KuangJi:string;
|
||
begin
|
||
inherited;
|
||
KuangJi:= Trim(Edit_KuangJi.Text);
|
||
if Pos(' ',KuangJi)>0 then
|
||
KuangJi:= LeftStr(KuangJi,Pos(' ',KuangJi));
|
||
Edit_KuangJi.Text:= Trim(KuangJi);
|
||
end;
|
||
|
||
procedure TFrame_yandao.Initialize(); //初始化
|
||
begin
|
||
inherited;
|
||
Edit_KuangJi.Text:= '';
|
||
Memo1.Lines.Clear;
|
||
end;
|
||
|
||
end.
|
||
|