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