generated from saidoyk/saidoyk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
upkproje
407 lines (314 loc) · 13.3 KB
/
upkproje
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
#MAİNCLASS
import java.util.Iterator;
import java.util.List;
import java.util.Scanner;
public class mainClass {
public static int item314amount = 0;
public static int item14127amount = 60;
public static int item019amount = 50;
public static int item2142amount = 80;
public static int item129amount = 0;
public static int item1118amount = 30;
public static int item11495amount = 120;
public static int item457amount = 0;
public static int item062amount = 50;
public static int item13122amount = 0;
public static int item048amount = 30;
public static int item118amount = 0;
public static int item1605amount = 30;
public static Item item457 = new Item("457", item457amount,20,2,2,1,1, new Item[]{});
public static Item item062r2 = new Item("062", item062amount,100,6,2,1,2, new Item[]{});
public static Item item1118 = new Item("1118", item1118amount,0,0,3,1,1, new Item[]{});
public static Item item129 = new Item("129", item129amount,100,8,4,40,1, new Item[]{});
public static Item item11495 = new Item("11495", item11495amount,0,0,1,50,1, new Item[]{item129,item1118});
public static Item item13122 = new Item("13122", item13122amount,70,3,1,40,1, new Item[]{item457,item062r2,item11495});
public static Item item048 = new Item("048", item048amount,0,0,3,30,1, new Item[]{});
public static Item item118 = new Item("118", item118amount,50,2,2,1,1, new Item[]{});
public static Item item062r4 = new Item("062", item062amount,100,6,2,1,4, new Item[]{});
public static Item item14127r4 = new Item("14127", item14127amount,0,0,2,50,4, new Item[]{});
public static Item item2142 = new Item("2142", item2142amount,0,0,2,100,1, new Item[]{});
public static Item item019 = new Item("019", item019amount,40,5,2,50,1, new Item[]{});
public static Item item14127r6 = new Item("14127", item14127amount,0,0,2,50,6, new Item[]{});
public static Item item314 = new Item("314", item314amount,50,5,1,50,1, new Item[]{item2142, item019, item14127r6});
public static Item item1605 = new Item("1605", item1605amount,0,0,1,1,1, new Item[]{item13122,item048,item118,item062r4,item14127r4,item314});
public mainClass() {
}
public static void main(String[] args) {
boolean test = true;
while (test) {
Scanner scanner = new Scanner(System.in);
System.out.println("1-print inventory \n" +
"2-order item \n"+
"3-show items \n"+
"0-exit \n");
int number = scanner.nextInt();
switch (number) {
case 1:
System.out.println("Inventory");
for(int i = 0;i<46;i++){ System.out.print("-"); }
System.out.println();
printInv(item1605);
break;
case 2:
//case2
Item item = null;
System.out.println("Select item number\n");
int orderNumber = scanner.nextInt();
boolean test2 = true;
switch (orderNumber) {
case 457:
item = item457;
break;
case 62:
//r sorcak
item = item062r2;
break;
case 129:
item = item129;
break;
case 1118:
item = item1118;
break;
case 11495:
item = item11495;
break;
case 13122:
item = item13122;
break;
case 48:
item = item048;
break;
case 118:
item = item118;
break;
case 14127:
//r
item = item14127r6;
break;
case 2142:
item = item2142;
break;
case 19:
item = item019;
break;
case 314:
item = item314;
break;
case 1605:
item = item1605;
break;
default:
System.out.println("item not found\n");
test2 = false;
break;
}
if(test2){
int[] grossReq = new int[10];
for(int i = 1;i<11;i++){
System.out.println("Select " + i + ". week Gross Requirements");
int orderGrossReq = scanner.nextInt();
grossReq[i-1]=orderGrossReq;
}
calculate(item, grossReq);
}
//#case2
break;
case 3:
printTree(item1605,1);
break;
case 0:
test = false;
break;
}
}
}
public static void calculate(Item item, int[] grossReq) {
int[] netreq = new int[10];
int[] scheduled = new int[10];
int[] amofhand = new int[10];
int[] plannedorder = new int[10];
int[] childgrossReq = new int[10];
amofhand[0] = item.getAmountOnHand();
if(item.getArrivalOnWeek()!=0)
scheduled[item.getArrivalOnWeek()-1]=item.getScheduledReceipt();
for(int j=1;j<10;j++){
if(amofhand[j-1]+scheduled[j-1] >= grossReq[j-1]) {
amofhand[j] = amofhand[j - 1]+scheduled[j-1] - grossReq[j - 1];
}else if(amofhand[j-1]+scheduled[j-1] < grossReq[j-1]) {
netreq[j-1] = grossReq[j - 1] - amofhand[j - 1]-scheduled[j-1] ;
plannedorder[j-1] = (int)(Math.ceil((float)netreq[j-1] / (float)item.getLotSizingRule())*item.getLotSizingRule());
amofhand[j] = amofhand[j]+ plannedorder[j-1] + scheduled[j-1] +amofhand[j-1]- grossReq[j - 1];
}
}
if(item.getChilds().length!=0){
for(int k = 0; k<item.getChilds().length;k++){
for(int i=0;i<plannedorder.length-1;i++){
childgrossReq[i]=plannedorder[i+1]*item.getChilds(k).getItemRequired();
}
calculate(item.getChilds(k),childgrossReq);
}
}
item.printTable(item,grossReq,amofhand,netreq,plannedorder);
item.setAmountOnHand(amofhand[9]);
}
public static void printTree(Item item,int j){
if(item.getItemRequired() != 1)
System.out.print("└──" + item.getItemId()+ "("+ item.getItemRequired() + " required)" +"\n");
else
System.out.print("└──" + item.getItemId() +"\n");
if(item.getChilds().length !=0) {
for(int i = 0; i<item.getChilds().length;i++){
System.out.printf("%-" + 5*j + "s","");
printTree(item.getChilds(i),j+1);
}
}
}
public static void printInv(Item item){
System.out.printf("%-20s","Item Id: " + item.getItemId());
System.out.printf("%-25s","│ Amount on Hand: " + item.getAmountOnHand());
System.out.println();
for(int i = 0;i<46;i++){ System.out.print("-"); }
System.out.println();
if(item.getChilds().length !=0) {
for(int i = 0; i<item.getChilds().length;i++){
printInv(item.getChilds(i));
}
}
}
}
---------------------------------------------------------------------------------------------
#İTEM
public class Item {
private String itemId;
private int amountOnHand;
private int scheduledReceipt;
private int arrivalOnWeek;
private int leadTime;
private int lotSizingRule;
private int itemRequired = 1;
private Item[] childs = null;
public Item( String itemId, int amountOnHand, int scheduledReceipt, int arrivalOnWeek, int leadTime, int lotSizingRule,int itemRequired, Item[] childs) {
this.itemId = itemId;
this.amountOnHand = amountOnHand;
this.scheduledReceipt = scheduledReceipt;
this.arrivalOnWeek = arrivalOnWeek;
this.leadTime = leadTime;
this.lotSizingRule = lotSizingRule;
this.itemRequired = itemRequired;
this.childs = childs;
}
public String getItemId() {
return itemId;
}
public void setItemId(String itemId) {
this.itemId = itemId;
}
public int getAmountOnHand() {
return amountOnHand;
}
public void setAmountOnHand(int amountOnHand) {
this.amountOnHand = amountOnHand;
}
public int getScheduledReceipt() {
return scheduledReceipt;
}
public void setScheduledReceipt(int scheduledReceipt) {
this.scheduledReceipt = scheduledReceipt;
}
public int getArrivalOnWeek() {
return arrivalOnWeek;
}
public void setArrivalOnWeek(int arrivalOnWeek) {
this.arrivalOnWeek = arrivalOnWeek;
}
public int getLeadTime() {
return leadTime;
}
public void setLeadTime(int leadTime) {
this.leadTime = leadTime;
}
public int getLotSizingRule() {
return lotSizingRule;
}
public void setLotSizingRule(int lotSizingRule) {
this.lotSizingRule = lotSizingRule;
}
public Item[] getChilds() {
return childs;
}
public Item getChilds(int i) {
return childs[i];
}
public void setChilds(Item[] childs) {
this.childs = childs;
}
public int getItemRequired() {
return itemRequired;
}
public void setItemRequired(int itemRequired) {
this.itemRequired = itemRequired;
}
public void printTable(Item item, int[] grossreq, int[] amofhand, int[] netreq, int[] plannedorder) {
String[][] table = {{"","Period", "1","2","3","4","5","6","7","8","9","10"},
{"itemid =" + item.getItemId(), "Gross Requirements", "","","","","","","","","",""},
{"", "Scheduled Receipts", "","","","","","","","","",""},
{"LT =" + item.getLeadTime(), "On hand From prior period", "","","","","","","","","",""},
{"", "Net Requirements", "","","","","","","","","",""},
{"Q =","Time-phased Net Requirements", "","","","","","","","","",""},
{"", "Planned Order releases", "","","","","","","","","",""},
{"", "Planned Order delivery", "","","","","","","","","",""},
};
if(item.getLotSizingRule()==1)
table[5][0] = "Q = L4L";
else
table[5][0] = "Q =" + item.getLotSizingRule();
if(arrivalOnWeek!=0)
table[2][item.arrivalOnWeek+1] = item.scheduledReceipt + "";
//grossreq print
for(int i = 0; i<grossreq.length; i++) {
table[1][i+2] = String.valueOf(grossreq[i]);
table[3][i+2] = String.valueOf(amofhand[i]);
table[4][i+2] = String.valueOf(netreq[i]);
if(i+2-item.getLeadTime() > 1) {
table[5][i + 2 - item.getLeadTime()] = String.valueOf(netreq[i]);
table[6][i + 2 - item.getLeadTime()] = String.valueOf(plannedorder[i]);
}
table[7][i+2] = String.valueOf(plannedorder[i]);
}
for(int j = 0;j<item.getLeadTime();j++){
table[5][table[1].length-1-j] = "0";
table[6][table[1].length-1-j] = "0";
}
//#grossreq print
for(int i = 0;i<105;i++){ System.out.print("-"); }
System.out.println("\n");
for(int i = 0; i<table.length; i++)
{
for(int j=0; j<table[i].length;j++){
if(j == 0) {
System.out.printf("%-15s", table[i][j]);
} else if(j==1){
System.out.printf("%-30s", table[i][j]);
} else {
System.out.printf("%-6s", table[i][j]);
}
}
System.out.println("\n");
}
for(int i = 0;i<105;i++){ System.out.print("-"); }
System.out.println("\n");
}
}
--------------------------------------------------------------------------------------
#İDEAPROJECT.İML
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>