| 5185 |
mandeep.dh |
1 |
/**
|
|
|
2 |
*
|
|
|
3 |
*/
|
|
|
4 |
package in.shop2020.inventory.controllers;
|
|
|
5 |
|
| 5945 |
mandeep.dh |
6 |
import in.shop2020.model.v1.inventory.Warehouse;
|
| 5185 |
mandeep.dh |
7 |
import in.shop2020.thrift.clients.CatalogClient;
|
| 5945 |
mandeep.dh |
8 |
import in.shop2020.thrift.clients.InventoryClient;
|
| 5185 |
mandeep.dh |
9 |
import in.shop2020.thrift.clients.PurchaseClient;
|
|
|
10 |
import in.shop2020.thrift.clients.WarehouseClient;
|
|
|
11 |
import in.shop2020.utils.ModelUtils;
|
|
|
12 |
import in.shop2020.warehouse.InventoryItem;
|
| 10489 |
amar.kumar |
13 |
import in.shop2020.warehouse.Scan;
|
| 5185 |
mandeep.dh |
14 |
import in.shop2020.warehouse.ScanType;
|
|
|
15 |
import in.shop2020.warehouse.WarehouseService.Client;
|
|
|
16 |
|
| 9429 |
amar.kumar |
17 |
import java.util.ArrayList;
|
| 10489 |
amar.kumar |
18 |
import java.util.Date;
|
| 5185 |
mandeep.dh |
19 |
import java.util.List;
|
|
|
20 |
|
|
|
21 |
import org.apache.commons.logging.Log;
|
|
|
22 |
import org.apache.commons.logging.LogFactory;
|
|
|
23 |
|
|
|
24 |
/**
|
|
|
25 |
* @author mandeep
|
|
|
26 |
*
|
|
|
27 |
*/
|
|
|
28 |
public class DoaOutController extends BaseController {
|
|
|
29 |
private Log logger = LogFactory.getLog(DoaOutController.class);
|
|
|
30 |
private String id;
|
|
|
31 |
List<InventoryItem> inventoryItems;
|
|
|
32 |
|
|
|
33 |
public String index() {
|
|
|
34 |
try {
|
| 9452 |
amar.kumar |
35 |
//List<InventoryItem> tobeRemovedInventoryItems = new ArrayList<InventoryItem>();
|
| 5185 |
mandeep.dh |
36 |
Client warehouseClient = new WarehouseClient().getClient();
|
|
|
37 |
inventoryItems = warehouseClient
|
|
|
38 |
.getInventoryItemsFromLastScanType(ScanType.DOA_OUT);
|
| 9452 |
amar.kumar |
39 |
/* for(InventoryItem inventoryItem:inventoryItems) {
|
| 9428 |
amar.kumar |
40 |
if(inventoryItem.getId()<59078 ||
|
|
|
41 |
inventoryItem.getCurrentWarehouseId() == 1 ||
|
| 9429 |
amar.kumar |
42 |
inventoryItem.getCurrentWarehouseId() == 9) {//removing doa_in entries before 2013 and all hotspot entries
|
|
|
43 |
tobeRemovedInventoryItems.add(inventoryItem);
|
| 9428 |
amar.kumar |
44 |
}
|
|
|
45 |
}
|
| 9429 |
amar.kumar |
46 |
for(InventoryItem inventoryItem:tobeRemovedInventoryItems) {
|
|
|
47 |
inventoryItems.remove(inventoryItem);
|
| 9452 |
amar.kumar |
48 |
}*/
|
| 5185 |
mandeep.dh |
49 |
} catch (Exception e) {
|
|
|
50 |
logger.error("Could not fetch inventory items", e);
|
|
|
51 |
}
|
|
|
52 |
|
|
|
53 |
return INDEX;
|
|
|
54 |
}
|
|
|
55 |
|
|
|
56 |
public String update() {
|
|
|
57 |
try {
|
|
|
58 |
Client warehouseClient = new WarehouseClient().getClient();
|
|
|
59 |
InventoryItem inventoryItem = warehouseClient.getInventoryItemFromId(Long.valueOf(id));
|
| 5945 |
mandeep.dh |
60 |
in.shop2020.model.v1.inventory.InventoryService.Client catalogClient = new InventoryClient().getClient();
|
| 5185 |
mandeep.dh |
61 |
Warehouse warehouse = catalogClient.getWarehouse(inventoryItem.getCurrentWarehouseId());
|
| 9572 |
amar.kumar |
62 |
warehouseClient.scan(inventoryItem, ScanType.DOA_REPLACED, 1, warehouse.getBillingWarehouseId(), 0);
|
| 5185 |
mandeep.dh |
63 |
in.shop2020.purchase.PurchaseService.Client purchaseClient = new PurchaseClient().getClient();
|
|
|
64 |
purchaseClient.unFulfillPO(inventoryItem.getPurchaseId(), inventoryItem.getItemId(), 1);
|
|
|
65 |
} catch (Exception e) {
|
|
|
66 |
logger.error("Could not fetch inventory items", e);
|
|
|
67 |
}
|
|
|
68 |
|
|
|
69 |
return index();
|
|
|
70 |
}
|
| 10308 |
amar.kumar |
71 |
|
|
|
72 |
public String doaReject() {
|
|
|
73 |
try {
|
|
|
74 |
Client warehouseClient = new WarehouseClient().getClient();
|
|
|
75 |
InventoryItem inventoryItem = warehouseClient.getInventoryItemFromId(Long.valueOf(id));
|
|
|
76 |
in.shop2020.model.v1.inventory.InventoryService.Client catalogClient = new InventoryClient().getClient();
|
|
|
77 |
Warehouse warehouse = catalogClient.getWarehouse(inventoryItem.getCurrentWarehouseId());
|
|
|
78 |
warehouseClient.scan(inventoryItem, ScanType.DOA_REJECTED, 1, warehouse.getBillingWarehouseId(), 0);
|
|
|
79 |
} catch (Exception e) {
|
|
|
80 |
logger.error("Could not fetch inventory items", e);
|
|
|
81 |
}
|
| 5235 |
mandeep.dh |
82 |
|
| 10308 |
amar.kumar |
83 |
return index();
|
|
|
84 |
}
|
| 10489 |
amar.kumar |
85 |
|
|
|
86 |
public String closeDOAByCreditNote() {
|
|
|
87 |
try {
|
|
|
88 |
Client warehouseClient = new WarehouseClient().getClient();
|
|
|
89 |
InventoryItem inventoryItem = warehouseClient.getInventoryItemFromId(Long.valueOf(id));
|
|
|
90 |
in.shop2020.model.v1.inventory.InventoryService.Client catalogClient = new InventoryClient().getClient();
|
|
|
91 |
Warehouse warehouse = catalogClient.getWarehouse(inventoryItem.getCurrentWarehouseId());
|
|
|
92 |
|
|
|
93 |
Scan scan = new Scan();
|
|
|
94 |
scan.setInventoryItemId(Long.parseLong(id));
|
|
|
95 |
scan.setScannedAt((new Date()).getTime());
|
|
|
96 |
scan.setType(ScanType.DOA_CLOSED_BY_CREDIT_NOTE);
|
|
|
97 |
scan.setQuantity(1);
|
|
|
98 |
scan.setWarehouseId(inventoryItem.getCurrentWarehouseId());
|
|
|
99 |
warehouseClient.genericScan(inventoryItem, scan);
|
|
|
100 |
} catch (Exception e) {
|
|
|
101 |
logger.error("Could not fetch inventory items", e);
|
|
|
102 |
}
|
| 10308 |
amar.kumar |
103 |
|
| 10489 |
amar.kumar |
104 |
return index();
|
|
|
105 |
}
|
|
|
106 |
|
| 5235 |
mandeep.dh |
107 |
public String getPONumber(long purchaseId) {
|
|
|
108 |
try {
|
|
|
109 |
in.shop2020.purchase.PurchaseService.Client purchaseClient = new PurchaseClient().getClient();
|
|
|
110 |
return purchaseClient.getPurchaseOrderForPurchase(purchaseId).getPoNumber();
|
|
|
111 |
} catch (Exception e) {
|
|
|
112 |
return "N/A";
|
|
|
113 |
}
|
|
|
114 |
}
|
|
|
115 |
|
| 5185 |
mandeep.dh |
116 |
public String getWarehouseDisplayName(long warehouseId) {
|
|
|
117 |
try {
|
| 5945 |
mandeep.dh |
118 |
in.shop2020.model.v1.inventory.InventoryService.Client catalogClient = new InventoryClient().getClient();
|
| 5185 |
mandeep.dh |
119 |
return catalogClient.getWarehouse(warehouseId).getDisplayName();
|
|
|
120 |
} catch (Exception e) {
|
|
|
121 |
return "N/A";
|
|
|
122 |
}
|
|
|
123 |
}
|
|
|
124 |
|
|
|
125 |
public String getModelName(long itemId) {
|
|
|
126 |
try {
|
| 5945 |
mandeep.dh |
127 |
in.shop2020.model.v1.catalog.CatalogService.Client catalogClient = new CatalogClient()
|
| 5185 |
mandeep.dh |
128 |
.getClient();
|
|
|
129 |
return ModelUtils.extractProductNameFromItem(catalogClient
|
|
|
130 |
.getItem(itemId));
|
|
|
131 |
} catch (Exception e) {
|
|
|
132 |
return "N/A";
|
|
|
133 |
}
|
|
|
134 |
}
|
|
|
135 |
|
|
|
136 |
public String getId() {
|
|
|
137 |
return id;
|
|
|
138 |
}
|
|
|
139 |
|
|
|
140 |
public void setId(String id) {
|
|
|
141 |
this.id = id;
|
|
|
142 |
}
|
|
|
143 |
|
|
|
144 |
public List<InventoryItem> getInventoryItems() {
|
|
|
145 |
return inventoryItems;
|
|
|
146 |
}
|
|
|
147 |
|
|
|
148 |
public void setInventoryItems(List<InventoryItem> inventoryItems) {
|
|
|
149 |
this.inventoryItems = inventoryItems;
|
|
|
150 |
}
|
|
|
151 |
|
|
|
152 |
}
|