面向對象劃分--ERP銷售訂單、生產工單、料號

erp中,在接單生產或者備庫生產中,生產工單和銷售訂單是有一一對應關係的。假設有一個需求,就是根據不同客戶,列印不同的標籤信息。也就是簡單的標籤系統,大概分析一下,需要哪些內容。
1、廠內料號的相關情況
2、工單上有這個料件的生產信息
3、由於生產的料件是要交到客戶手裏,爲方便客戶掃碼入庫,可能還有客戶的一些信息
在我思考後,參考之前的面向過程程序,一個客戶一段代碼,修改不方便。尤其是對每個客戶的差別部分,很容易修改出錯。
我的劃分爲:
料號、批號、訂單和工單。決定建立這4個類。
工單包含:料號和訂單。
批號:可以查到生產的相關具體信息。
料號:廠內的料號由於也是遵循一定的原則,每一碼都是有含義的。所以屬性裏面根據每一碼獲取不同的信息是可以的。由生產工單可以查到銷售訂單。所以客戶料號的信息我也是放到這裏的。所謂料號,就是包含廠內料號和客戶料號的信息。
type
TPartNumber = class
private
partnumber:string;
grade:string;
specification:string;
ta_oeb01:string;
ta_oeb02:string;
function getsize():string;
function getsizemm():string;
function gethanliang():STRING;
function getname():string;
public
function getclothtype():string;
function getfirstpart():string;
function getsecondpart():string;
function getlastpart():string;
function getleixing():string;
function getgrade():string;
constructor Create(part:string;pgrade:string;pspecification:string;
pta_oeb01:string;pta_oeb02:string);
property sizeinch:string read getsize;
property sizemm:string read getsizemm;
property name:string read getname;
property hanliang:string read gethanliang;
property leixing:string read getleixing;
property pgrade:string read getgrade;
function ishf():Boolean;

end;
訂單:就是客戶代碼,客戶名稱,客戶料號和品名的一些信息。有人會說,爲什麼料號裏面有,訂單這裏還有,是不是有問題。我的解釋是,兩個地方的客戶料號信息不同。比如,料號裏面,可以存儲的是,根據不同
客戶,廠內料號對應的客戶那邊的尺寸這些信息,訂單中的就是客戶料號的代碼和品名這些具體的。因爲廠裏的料號,可能根據不同的客戶,同一個料號,它的尺寸定義就是不同。可以把這個信息分開到料號中去。
type TCustOrder = class
private
m_custno:string;
m_custgrade:string;
m_custorder:string;
m_custpart:string;
function getcustno():string;
function getcustgrade():string;
function getcustorder():string;
function getcustpart():string;
public
constructor Create(pcustno:string;pcustgrade:string;pcustorder:string;pcustpart:string);
property custno:string read getcustno;
property custgrade:string read getcustgrade;
property custorder:string read getcustorder;
property custpart:string read getcustpart;
end;
工單:工單就很單純了,因爲很多信息都由料號和訂單做了。我們的設計界面就是,輸入生產工單,會去erp系統,查詢其他料號和訂單的信息。當然,在構造工單對象的時候,自然其他兩個對象也會構造好。
type TWorkOrder = class
private
wpartnumber:TPartNumber;
wcustorder:TCustOrder;
function getpartnumber():TPartNumber;
function getcustorder():TCustOrder;
public
constructor Create(gdcode:string);
property partnumber:TPartNumber read getpartnumber;
property custorder:TCustOrder read getcustorder;
end;
批號:一個生產工單,可以生產很多批次,每個批次都有檢驗信息和具體的特性。所以我們默認帶出最小批次的信息。比如:生產日期,取樣時間,等級這些信息。
我們輸入完工單,帶出訂單和料號信息後。默認是有一筆批號信息,每次從下拉框選擇不同批號,和批號相關的信息就會變動。但是工單這些信息不同重新計算。
type TLotNo = class
private
llotno:TStringList;
lmfgdae:string;
lexpdate:string;
lrc:string;
lrf:string;
lgt:string;
lclass:string;
lsampletime:string;
lselected:string;
function getmfgdate():string;
function getexpdate():string;
function getrc():string;
function getrf():string;
function getgt():string;
function getclass():string;
function getsampletime():string;
function getlotno():TStringList;
function getlselected():string;
procedure setlselected(pselected:string);
public
constructor Create(pworkorderno:string);
procedure setotherlot();
property lotno:TStringList read getlotno;
property mfgdate:string read getmfgdate;
property expdate:string read getexpdate;
property rc:string read getrc;
property rf:string read getrf;
property gt:string read getgt;
property lotclass:string read getclass;
property sampletime:string read getsampletime;
property selected:string read getlselected write setlselected;
end;

每個類的實現:
constructor TPartNumber.Create(part:string;pgrade:string;pspecification:string;
pta_oeb01:string;pta_oeb02:string);
begin
partnumber:=part;
grade:=pgrade;
specification:=pspecification;
ta_oeb01:=pta_oeb01;
ta_oeb02:=pta_oeb02;
end;
function TPartNumber.getsize():string;
var
l_str:string;
begin
l_str:=getfirstpart;
if (l_str=’Q’) or (l_str=’P’)then
IF COPY(partnumber,10,1)=’1’ THEN
Result:=’49.8’
ELSE
IF COPY(partnumber,10,1)=’5’ THEN
Result:=’42.8’
ELSE
Result:=’ ’
ELSE
if (l_str=’N’) or (l_str=’M’)then
Result:=minint(ta_oeb01,2)+’G*’+minint(ta_oeb02,2)
else
Result:=Copy(partnumber,14,3);
end;
function TPartNumber.getsizemm():string;
var
l_str:string;
begin
l_str:=getfirstpart;
IF (l_str=’R’) or (l_str=’B’)THEN
BEGIN
if STRTOINT(COPY(partnumber,14,3))=496 then
Result:=’1259’
else
if STRTOINT(COPY(partnumber,14,3))=495 then
Result:=’1258’
else
if STRTOINT(COPY(partnumber,14,3))=428 then
Result:=’1088’
else
if STRTOINT(COPY(partnumber,14,3))=438 then
Result:=’1113’
else
Result:= FLOATTOSTR((STRTOFLOAT(sizeinch)*25.4));
end

  else
     IF (l_str='N')or(l_str='M') THEN
         begin
              Result:=inttostr(Round(StrToFloat(ta_oeb01)*25.4))
              +'G*'
              +inttostr(Round(StrToFloat(ta_oeb02)*25.4));
         end;

end;
function TPartNumber.getname():string;
begin
Result:=partnumber;
end;
function TPartNumber.getleixing():string;
begin
Result:=Copy(partnumber,4,4);
end;
function TPartNumber.getgrade():string;
var
l_grade:string;
begin
l_grade:=TRIM(COPY(grade,1,POS(‘-‘,grade)-1));
l_grade:=Copy(l_grade,1,2) + ‘-’ + Copy(l_grade,3,Length(l_grade));
Result:=l_grade;
end;
function TpartNumber.ishf():Boolean;
var
l_second:string;
begin

l_second:=getsecondpart();
IF (l_second=’1’)OR (l_second=’M’)OR (l_second=’J’)
OR (l_second=’L’)
THEN
Result:=True
else
Result:=False;
end;

function TPartNumber.getclothtype():string;

begin
Result:=Copy(partnumber,4,4);
end;
function TPartNumber.getfirstpart():string;

begin
Result:=Copy(partnumber,1,1);
end;

function TPartNumber.getsecondpart():string;

begin
Result:=Copy(partnumber,2,1);
end;
function TPartNumber.getlastpart():string;

begin
Result:=COPY(partnumber,Length(partnumber),1);
end;
function TPartNumber.gethanliang():string;
var
ss:Double;
firstpart,resincontent:string;
BEGIN
firstpart:=getfirstpart();
IF (firstpart=’P’) or (firstpart=’Q’) THEN
BEGIN
resincontent:=copy(partnumber,6,3);
END;
IF (firstpart=’R’) OR (firstpart=’N’)
OR (firstpart=’B’) OR (firstpart=’M’) THEN
BEGIN
resincontent:=COPY(partnumber,8,3);
END;
ss:=strtofloat(resincontent)/10;
result:= formatFloat(‘0.0’, ss);

end;
constructor TCustOrder.Create(pcustno:string;pcustgrade:string;pcustorder:string;pcustpart:string);
begin
m_custno:=pcustno;
m_custgrade:=pcustgrade;
m_custorder:=pcustorder;
m_custpart:=pcustpart;
end;
function TCustOrder.getcustno():string;
begin
Result:=m_custno;
end;
function TCustOrder.getcustorder():string;
begin
Result:=m_custorder;
end;
function TCustOrder.getcustgrade():string;
begin
Result:=m_custgrade;
end;
function TCustOrder.getcustpart():string;
begin
Result:=m_custpart;
end;
constructor TWorkOrder.Create(gdcode:string);
var
str:string;
begin
if trim(gdcode)<>” then
begin
STR:=’SELECT SFB01,SFB05,SFB08,SFB13,IMA02,IMA021,TA_IMA01,TA_IMA02,a.TA_OEB01,a.TA_OEB02,IMA18, ’
+ ’ a.OEA10,a.OEA04,a.TA_OEB10,a.OEB11 FROM SFB_FILE,IMA_FILE ,(SELECT oeb01,oeb03,oea10,oea04,ta_oeb10, ’
+ ’ oeb11,TA_OEB01,TA_OEB02 FROM oea_file,oeb_file WHERE oea01=oeb01 AND oeaconf=”Y”) a ’
+ ’ where a.OEB01(+)=SFB22 AND a.OEB03(+)=SFB221 AND IMA01=SFB05 AND SFB01=”’+trim(gdcode)+””;
OPEN_SQL(Frm_DM.TEMP,STR);
IF Frm_DM.TEMP.RecordCount=0 THEN
BEGIN
SHOWMESSAGE(‘工單號輸入有誤!’);
EXIT ;
END
else
begin
wpartnumber:=TPartNumber.Create(TRIM(Frm_Dm.TEMP.FIELDBYNAME(‘SFB05’).ASSTRING),
TRIM(Frm_Dm.TEMP.FIELDBYNAME(‘IMA02’).ASSTRING),
TRIM(Frm_Dm.TEMP.FIELDBYNAME(‘IMA021’).ASSTRING),
TRIM(Frm_Dm.TEMP.FIELDBYNAME(‘TA_OEB01’).ASSTRING),
TRIM(Frm_Dm.TEMP.FIELDBYNAME(‘TA_OEB02’).ASSTRING));

       wcustorder:=TCustOrder.Create(TRIM(Frm_Dm.TEMP.FIELDBYNAME('OEA04').ASSTRING),
                                     TRIM(Frm_Dm.TEMP.FIELDBYNAME('TA_OEB10').ASSTRING),
                                     TRIM(Frm_Dm.TEMP.FIELDBYNAME('OEA10').ASSTRING),
                                     TRIM(Frm_Dm.TEMP.FIELDBYNAME('OEB11').ASSTRING));
    end;

end;

end;
function TWorkOrder.getpartnumber():TPartNumber;
begin
Result:=wpartnumber;
end;
function TWorkOrder.getcustorder():TCustOrder;
begin
Result:=wcustorder;
end;

constructor TLotNo.Create(pworkorderno:string);
var
lsqlstr:string;
begin
lsqlstr:=’SELECT TC_SIA02 FROM TC_SIA_FILE,SHB_FILE WHERE SHB01=TC_SIA01 ’
+ ’ AND TC_SIA02 IS NOT NULL and SHB05=”’+pworkorderno+”’ order by TC_SIA02 ‘;
OPEN_SQL(Frm_Dm.TEMP,lsqlstr);
if Frm_Dm.TEMP.RecordCount<>0 then
begin
llotno:=TStringList.Create;
WHILE NOT Frm_Dm.TEMP.Eof DO
BEGIN
llotno.add(Frm_Dm.TEMP.FIELDBYNAME(‘TC_SIA02’).ASSTRING);
Frm_Dm.TEMP.Next;
END;
end;
end;
function TLotNo.getlotno():TStringList;
begin
Result:=llotno;
end;
function TLotNo.getmfgdate():string;
begin
lmfgdae:=getdate(lselected);
Result:=lmfgdae;
end;
function TLotNo.getexpdate():string;
begin
lexpdate:=DATETOSTR(IncMonth(strtodate(lmfgdae),3));
Result:=lexpdate;
end;
function TLotNo.getrc():string;
begin
Result:=lrc;
end;
function TLotNo.getrf():string;
begin
Result:=lrf;
end;
function TLotNo.getgt():string;
begin
Result:=lgt;
end;
function TLotNo.getclass():string;
begin
Result:=lclass;
end;
function TLotNo.getsampletime():string;
begin
Result:=lsampletime;
end;
function TLotNo.getlselected():string;
begin
Result:=lselected;
end;
procedure TLotNo.setlselected(pselected:string);
begin
lselected:=pselected;
end;
procedure TLotNo.setotherlot();
VAR
str1:string;
begin
str1:=’SELECT * FROM TC_SIA_FILE WHERE 0=0 ’
+’ AND substr(TC_SIA02,1,9) =”’+copy(lselected,1,9)+””;
open_sql(Frm_DM.temp,str1);
lrc:=minint(FLOATTOSTR(roundto((Frm_DM.temp.FIELDBYNAME(‘tc_sia171’).ASFLOAT
+Frm_DM.temp.FIELDBYNAME(‘tc_sia173’).ASFLOAT
+Frm_DM.temp.FIELDBYNAME(‘tc_sia175’).ASFLOAT)/3,-1)),1);
lgt:=FLOATTOSTR(ceil((Frm_DM.temp.FIELDBYNAME(‘tc_sia192’).ASFLOAT+Frm_DM.temp.FIELDBYNAME(‘tc_sia193’).ASFLOAT+
Frm_DM.temp.FIELDBYNAME(‘tc_sia195’).ASFLOAT+Frm_DM.temp.FIELDBYNAME(‘tc_sia196’).ASFLOAT+
Frm_DM.temp.FIELDBYNAME(‘tc_sia199’).ASFLOAT)/5));
lrf:=Frm_DM.temp.FIELDBYNAME(‘tc_sia183’).ASSTRING;
if Frm_DM.temp.FIELDBYNAME(‘tc_sia24’).ASSTRING=’A’ then
lclass:=’A+’
else if Frm_DM.temp.FIELDBYNAME(‘tc_sia24’).ASSTRING=’B’ then
lclass:=’A’;
lsampletime:=Frm_DM.temp.FIELDBYNAME(‘tc_sia23’).ASSTRING;
end;

發佈了42 篇原創文章 · 獲贊 8 · 訪問量 6萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章