279 lines
9.0 KiB
ObjectPascal
279 lines
9.0 KiB
ObjectPascal
unit uFrame_Dyp_Setup;
|
|
|
|
interface
|
|
|
|
uses
|
|
System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
|
|
FMX.Types, FMX.Graphics, FMX.Controls, FMX.Forms, FMX.Dialogs, FMX.StdCtrls,
|
|
System.ImageList, FMX.ImgList, FMX.Controls.Presentation, FMX.Edit,
|
|
FMX.Objects,uFrameBase,uShowInfo,uKsoap,uPucFun, FMX.Memo.Types,
|
|
FMX.ScrollBox, FMX.Memo, DateUtils, FMX.ListBox;
|
|
|
|
type
|
|
TFrame_Dyp_Setup = class(TFrameBase)
|
|
Rectangle88: TRectangle;
|
|
Option1: TRectangle;
|
|
Glyph9: TGlyph;
|
|
OptionLabel1: TText;
|
|
Text19: TText;
|
|
Edit_CaiZhi: TEdit;
|
|
Option2: TRectangle;
|
|
Glyph2: TGlyph;
|
|
OptionLabel3: TText;
|
|
Text6: TText;
|
|
Edit_banhou: TEdit;
|
|
Option3: TRectangle;
|
|
Glyph3: TGlyph;
|
|
OptionLabel5: TText;
|
|
Text23: TText;
|
|
Edit_jiexi: TEdit;
|
|
Option4: TRectangle;
|
|
Glyph12: TGlyph;
|
|
OptionLabel7: TText;
|
|
Text28: TText;
|
|
Edit_xiankuang: TEdit;
|
|
Option7: TRectangle;
|
|
Glyph13: TGlyph;
|
|
OptionLabel9: TText;
|
|
Text30: TText;
|
|
Edit_rongchadada: TEdit;
|
|
ImageList1: TImageList;
|
|
Option6: TRectangle;
|
|
Glyph1: TGlyph;
|
|
Text1: TText;
|
|
Text2: TText;
|
|
Edit_rongchaxiao: TEdit;
|
|
Option5: TRectangle;
|
|
Glyph4: TGlyph;
|
|
Text3: TText;
|
|
Text4: TText;
|
|
Edit_jianju: TEdit;
|
|
TxtError: TText;
|
|
Timer1: TTimer;
|
|
OpenDialog1: TOpenDialog;
|
|
Memo1: TMemo;
|
|
ComboBoxP_PC: TComboBox;
|
|
procedure Edit_CaiZhiClick(Sender: TObject);
|
|
procedure Timer1Timer(Sender: TObject);
|
|
private
|
|
iLine: integer;
|
|
{ Private declarations }
|
|
public
|
|
procedure FillDefaultValue(sPartnumValue,sDefaultTxt:string);override; //填写默认值
|
|
function DoExec():boolean;override; //判断输入是否有效,执行插入主表,或打开窗体
|
|
function CheckValid(var sTxt:string):boolean;override;
|
|
end;
|
|
|
|
implementation
|
|
|
|
{$R *.fmx}
|
|
|
|
uses uDM, json_webservice, uSafeLog;
|
|
|
|
function TFrame_Dyp_Setup.CheckValid(var sTxt:string):boolean; //返回面次数据
|
|
var
|
|
aa:Extended;
|
|
begin
|
|
Result:=false;
|
|
if not GetRadioTxt(sTxt) then //没有选择,提示出错信息
|
|
begin
|
|
ErrorLayout(GridLayout,TxtError,'请选择TOP面/BOT面');
|
|
Exit;
|
|
end;
|
|
if Trim(Edit_CaiZhi.Text)='' then begin Error(Edit_CaiZhi,TxtError,'材質輸入不能為空');Exit;end;
|
|
if Trim(Edit_banhou.Text)='' then begin Error(Edit_banhou,TxtError,'板厚輸入不能為空');Exit;end;
|
|
if Trim(Edit_jiexi.Text)='' then begin Error(Edit_jiexi,TxtError,'解析度輸入不能為空');Exit;end;
|
|
if Trim(Edit_xiankuang.Text)='' then begin Error(Edit_xiankuang,TxtError,'最小线宽輸入不能為空');Exit;end;
|
|
// if Trim(Edit_jianju.Text)='' then begin Error(Edit_jianju,TxtError,'最小间距輸入不能為空');Exit;end;
|
|
// if Trim(Edit_rongchaxiao.Text)='' then begin Error(Edit_rongchaxiao,TxtError,'线宽容差最小值輸入不能為空');Exit;end;
|
|
// if Trim(Edit_rongchadada.Text)='' then begin Error(Edit_rongchadada,TxtError,'线宽容差最大值輸入不能為空');Exit;end;
|
|
|
|
if not TryStrToFloat(Edit_banhou.Text,aa) then begin Error(Edit_banhou,TxtError,'板厚輸入類型錯誤,請重新輸入。');Exit;end;
|
|
if not TryStrToFloat(Edit_jiexi.Text,aa) then begin Error(Edit_jiexi,TxtError,'解析度輸入類型錯誤,請重新輸入。');Exit;end;
|
|
if not TryStrToFloat(Edit_xiankuang.Text,aa) then begin Error(Edit_xiankuang,TxtError,'最小线宽輸入類型錯誤,請重新輸入。');Exit;end;
|
|
// if not TryStrToFloat(Edit_jianju.Text,aa) then begin Error(Edit_jianju,TxtError,'最小间距輸入類型錯誤,請重新輸入。');Exit;end;
|
|
// if not TryStrToFloat(Edit_rongchaxiao.Text,aa) then begin Error(Edit_rongchaxiao,TxtError,'线宽容差最小值輸入類型錯誤,請重新輸入。');Exit;end;
|
|
// if not TryStrToFloat(Edit_rongchadada.Text,aa) then begin Error(Edit_rongchadada,TxtError,'线宽容差最大值輸入類型錯誤,請重新輸入。');Exit;end;
|
|
Result:=true;
|
|
if Result then Error(Edit_CaiZhi,TxtError,'');
|
|
end;
|
|
|
|
procedure TFrame_Dyp_Setup.FillDefaultValue(sPartnumValue,sDefaultTxt:string);
|
|
var
|
|
tmpList:TStrings;
|
|
i: integer;
|
|
begin
|
|
ComboBoxP_PC.Items.Clear;
|
|
WorkLog.MessageInfo('FillDefaultValue');
|
|
|
|
// KJSon.REST_pro_List('', 1, sDefaultTxt);
|
|
|
|
if KJSon. FList_pro_process.Count>0 then
|
|
begin
|
|
for I := 0 to KJSon. FList_pro_process.Count - 1 do
|
|
begin
|
|
ComboBoxP_PC.Items.Add(KJSon. REST_Value(KJSon. FList_pro_process.Strings[i], 'name'));
|
|
end;
|
|
end;
|
|
|
|
if sDefaultTxt='' then Exit;
|
|
tmpList:=TStringList.Create;
|
|
try
|
|
tmpList.DelimitedText:=sDefaultTxt;
|
|
if tmpList.Count>32 then
|
|
begin
|
|
Edit_CaiZhi.Text:=tmpList.Strings[32];
|
|
Edit_banhou.Text:=tmpList.Strings[0];
|
|
Edit_jiexi.Text:=tmpList.Strings[3];
|
|
Edit_xiankuang.Text:=tmpList.Strings[4];
|
|
// Edit_jianju.Text:=tmpList.Strings[5];
|
|
// Edit_rongchaxiao.Text:=tmpList.Strings[20];
|
|
// Edit_rongchadada.Text:=tmpList.Strings[21];
|
|
end;
|
|
|
|
{tmpList.DelimitedText:=sPartnumValue;
|
|
if tmpList.Count>5 then //这里根据料号返回信息填写缺省值
|
|
Edit_banhou.Text:=tmpList.Strings[5];}
|
|
|
|
finally
|
|
tmpList.Free;
|
|
end;
|
|
end;
|
|
|
|
|
|
function GetLatestFileInDir(const DirPath: string): string;
|
|
var
|
|
SearchRec: TSearchRec;
|
|
LatestTime: TDateTime;
|
|
CurrentTime: TDateTime;
|
|
begin
|
|
Result := '';
|
|
LatestTime := MinDateTime; // 初始化为最小日期
|
|
if FindFirst(IncludeTrailingPathDelimiter(DirPath) + 'bx-*.txt', faAnyFile, SearchRec) = 0 then
|
|
begin
|
|
repeat
|
|
if (SearchRec.Name <> '.') and (SearchRec.Name <> '..') then
|
|
begin
|
|
CurrentTime := FileDateToDateTime(SearchRec.Time);
|
|
if CompareDateTime(CurrentTime, LatestTime) > 0 then
|
|
begin
|
|
LatestTime := CurrentTime;
|
|
Result := IncludeTrailingPathDelimiter(DirPath) + SearchRec.Name;
|
|
end;
|
|
end;
|
|
until FindNext(SearchRec) <> 0;
|
|
FindClose(SearchRec);
|
|
end;
|
|
end;
|
|
|
|
procedure TFrame_Dyp_Setup.Timer1Timer(Sender: TObject);
|
|
var
|
|
sFPhat: String;
|
|
i: Integer;
|
|
tmpList:TStrings;
|
|
begin
|
|
inherited;
|
|
// if (ComboBoxP_PC.Items.Count=0) then
|
|
|
|
WorkLog.MessageInfo('FillDefaultValue1');
|
|
// if (ComboBoxP_PC.Items.Count=0) and (KJSon. FList_pro_process.Count>0) then
|
|
// FillDefaultValue('','');
|
|
|
|
|
|
sFPhat:= GetLatestFileInDir(dm.MemTableReadKeyValue('tv_DirData','locad_dir')); //本地文件目录
|
|
if FileExists(sFPhat) then
|
|
begin
|
|
tmpList:= TStringList.Create;
|
|
with tmpList do
|
|
try
|
|
LoadFromFile(sFPhat);
|
|
i := Count;
|
|
if i>iLine then
|
|
begin
|
|
// if OpenDialog1.Execute then
|
|
Memo1.BeginUpdate;
|
|
try
|
|
Memo1.Lines.Assign(tmpList); // 关键修改:将当前TStringList内容复制到Memo
|
|
finally
|
|
Memo1.EndUpdate;
|
|
end;
|
|
iLine := Memo1.Lines.Count;
|
|
end;
|
|
finally
|
|
Free;
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
function TFrame_Dyp_Setup.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_LOT_TYPE:='正常板';
|
|
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_DIE_NAME:=Edit_CaiZhi.Text; //材質
|
|
LotNoRecord.P_LINE_SPEED:=StrToFloat(Edit_banhou.Text); //板厚
|
|
LotNoRecord.P_ELE_CUR_DENSITY:=StrToFloat(Edit_jiexi.Text); //解析度
|
|
LotNoRecord.P_ELE_AREA1:=StrToFloat(Edit_xiankuang.Text); //最小線寬
|
|
LotNoRecord.P_SIDE:=sTxt; //面次
|
|
// LotNoRecord.P_PRODUCT_PRESSURE:=StrToFloat(Edit_rongchadada.Text); //線寬容差最大值
|
|
// LotNoRecord.P_COM_TEMPERATURE:=StrToFloat(Edit_rongchaxiao.Text); //線寬容差最小值
|
|
// LotNoRecord.P_ELE_AREA2:=StrToFloat(Edit_jianju.Text); //最小間距
|
|
LotNoRecord.P_CREATION_DATE:=FormatDateTime('yyyymmdd hh:mm:ss',Now);
|
|
|
|
sError:='';
|
|
// vP_ID:=KJSon.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,true);
|
|
ShowInfoOK('連接數據庫服務器失敗數據暫存本地,正在生產中...');
|
|
Result:=true;
|
|
END
|
|
ELSE
|
|
BEGIN
|
|
//直接调用API,出错再保存本地
|
|
if not KJSon.Thread_Insert_CM_WIP_PROCESS_LINE_HISTORY_NEW(LotNoRecord,sError) then //提交主表不成功
|
|
begin
|
|
if sError='連接數據庫服務器失败' then
|
|
begin
|
|
dm.InsertMain(vId,LotNoRecord,true);
|
|
ShowInfoOK('連接數據庫服務器失敗數據暫存本地,正在生產中...');
|
|
Result:=true;
|
|
end
|
|
else
|
|
ShowError(sError);
|
|
end
|
|
else
|
|
begin
|
|
ShowInfoOK('上傳成功,正在生產中...');
|
|
Result:=true;
|
|
end;
|
|
END;
|
|
end;
|
|
end;
|
|
|
|
|
|
procedure TFrame_Dyp_Setup.Edit_CaiZhiClick(Sender: TObject);
|
|
begin
|
|
inherited;
|
|
ShowTouchKeyBoard();
|
|
end;
|
|
|
|
end.
|