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