1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
| static void ImportTBInvent(Args _args)
{
……
try
{
numImported = 0;
lineNo = 1;
axInventJournalTable = new AxInventJournalTable(); axInventJournalTable.parmJournalNameId("Mov_Inventory_Adjust");//Mov_Inventory_Adjust
axInventJournalTable.parmDescription("TB Invent 20190831");
axInventJournalTable.save();
_journalId = axInventJournalTable.inventJournalTable().JournalId;
record = csvFile.read();
ttsbegin;
while (csvFile.status() == IO_Status::Ok)
{
record = csvFile.read();
lineNo = lineNo +1;
if (!record) break;
if (!InventTable::find(conPeek(record,1),false))
{
info(strfmt("line No -- %1 -- has non existed itemNum, not imported",lineNo));
continue;
} else
{
axInventJournalTrans = new AxInventJournalTrans();
axInventJournalTrans.parmJournalId(_journalId);
axInventJournalTrans.parmTransDate(str2Date("2019/8/31",321));
axInventJournalTrans.parmItemId(conPeek(record,1));
inventDim.clear();
inventDim.InventSiteId = conPeek(record,2);
inventDim.InventLocationId = conPeek(record,3);
inventDim.wMSLocationId = conPeek(record,4);
if (InventTable::find(conPeek(record,1)).DimGroupId == "rev")
{
if (strLRtrim(conPeek(record,5)) != "")
{
inventDim.InventColorId = conPeek(record,5);
inventColor = InventColor::find(conPeek(record,5),conPeek(record,1));
if (!inventColor)
{
info(strfmt("line No -- %1 --, version is not exists, %2 not imported",lineNo,conPeek(record,1)));
continue;
}
} else
{
info(strfmt("line No -- %1 -- has no version, not imported",lineNo));
continue;
}
}
_inventDimId = InventDim::findOrCreate(inventDim).inventDimId;
axInventJournalTrans.parmInventDimId(_inventDimId);
axInventJournalTrans.parmQty(str2num(conPeek(record,6)));
axInventJournalTrans.parmCostAmount(str2num(conPeek(record,9))); axInventJournalTrans.parmCostPrice(round(axInventJournalTrans.parmCostAmount()/axInventJournalTrans.parmQty(),0.0001));
axInventJournalTrans.parmLedgerAccountIdOffset("9999");
axInventJournalTrans.save();
numImported = numImported + 1;
}
} //while
……
//序列号
while (csvFile2.status() == IO_Status::Ok)
{
record = csvFile2.read();
lineNo = lineNo +1;
if (!record) break;
// ttsBegin;
if ((InventTable::find(conPeek(record,1),false)) && (InventTable::find(conPeek(record,1)).CIG_SerialControl == NoYes::Yes))
{
_itemId = conPeek(record,1);
inventDim.clear();
inventDim.InventSiteId = conPeek(record,3);
inventDim.InventLocationId = conPeek(record,4);
inventDim.wMSLocationId = conPeek(record,5);
inventDim.InventColorId = conPeek(record,6);
_inventDimId = InventDim::findOrCreate(inventDim).inventDimId;
cig_inventTransSerial.clear();
cig_inventTransSerial.ItemId = _itemId;
select firstonly inventJournalTrans where
inventJournalTrans.JournalId == _journalId
&& inventJournalTrans.ItemId == _itemId
&& inventJournalTrans.InventDimId == _inventDimId;
cig_inventTransSerial.InventTransId = inventJournalTrans.InventTransId;
//cig_inventTransSerial.Qty =
cig_inventTransSerial.InventStatus = CIG_InventStatus::Registered;
cig_inventTransSerial.inventSerialId = conPeek(record,2);
cig_inventTransSerial.TransType = InventTransType::InventTransaction;
cig_inventTransSerial.TransRefId = _journalId;
cig_inventTransSerial.DocumentId = _journalId;
cig_inventTransSerial.inventDimId = InventDim::inventDimIdBlank();
cig_inventTransSerial.initValue();
cig_inventTransSerial.insert();
cig_serialTable.clear();
cig_serialTable.InventSerialId = conPeek(record,2);
cig_serialTable.DateCode = conPeek(record,7);
cig_serialTable.InventSerialIdCustomer = conPeek(record,8);
cig_serialTable.initValue();
cig_serialTable.insert();
numImported = numImported + 1;
}
// ttsCommit;
} //while
ttsCommit;
info(strfmt("%1 records imported",numImported));
}
……
}
|