| Line 19... |
Line 19... |
| 19 |
import in.shop2020.thrift.clients.WarehouseClient;
|
19 |
import in.shop2020.thrift.clients.WarehouseClient;
|
| 20 |
import in.shop2020.warehouse.InventoryItem;
|
20 |
import in.shop2020.warehouse.InventoryItem;
|
| 21 |
import in.shop2020.warehouse.Scan;
|
21 |
import in.shop2020.warehouse.Scan;
|
| 22 |
import in.shop2020.warehouse.ScanType;
|
22 |
import in.shop2020.warehouse.ScanType;
|
| 23 |
import in.shop2020.warehouse.TransferLot;
|
23 |
import in.shop2020.warehouse.TransferLot;
|
| - |
|
24 |
import in.shop2020.warehouse.TransferLotStatus;
|
| 24 |
import in.shop2020.warehouse.WarehouseService;
|
25 |
import in.shop2020.warehouse.WarehouseService;
|
| 25 |
import in.shop2020.warehouse.WarehouseServiceException;
|
26 |
import in.shop2020.warehouse.WarehouseServiceException;
|
| 26 |
|
27 |
|
| 27 |
import java.io.BufferedInputStream;
|
28 |
import java.io.BufferedInputStream;
|
| 28 |
import java.io.ByteArrayOutputStream;
|
29 |
import java.io.ByteArrayOutputStream;
|
| Line 36... |
Line 37... |
| 36 |
import java.text.ParseException;
|
37 |
import java.text.ParseException;
|
| 37 |
import java.text.SimpleDateFormat;
|
38 |
import java.text.SimpleDateFormat;
|
| 38 |
import java.util.Calendar;
|
39 |
import java.util.Calendar;
|
| 39 |
import java.util.Date;
|
40 |
import java.util.Date;
|
| 40 |
import java.util.HashMap;
|
41 |
import java.util.HashMap;
|
| - |
|
42 |
import java.util.HashSet;
|
| 41 |
import java.util.Hashtable;
|
43 |
import java.util.Hashtable;
|
| 42 |
import java.util.List;
|
44 |
import java.util.List;
|
| 43 |
import java.util.Map;
|
45 |
import java.util.Map;
|
| 44 |
import java.util.Map.Entry;
|
46 |
import java.util.Map.Entry;
|
| 45 |
import java.util.Set;
|
47 |
import java.util.Set;
|
| Line 51... |
Line 53... |
| 51 |
import org.apache.poi.ss.usermodel.Row;
|
53 |
import org.apache.poi.ss.usermodel.Row;
|
| 52 |
import org.apache.poi.ss.usermodel.Sheet;
|
54 |
import org.apache.poi.ss.usermodel.Sheet;
|
| 53 |
import org.apache.poi.ss.usermodel.Workbook;
|
55 |
import org.apache.poi.ss.usermodel.Workbook;
|
| 54 |
import org.apache.thrift.TException;
|
56 |
import org.apache.thrift.TException;
|
| 55 |
import org.apache.thrift.transport.TTransportException;
|
57 |
import org.apache.thrift.transport.TTransportException;
|
| - |
|
58 |
import org.json.JSONObject;
|
| 56 |
import org.slf4j.Logger;
|
59 |
import org.slf4j.Logger;
|
| 57 |
import org.slf4j.LoggerFactory;
|
60 |
import org.slf4j.LoggerFactory;
|
| 58 |
|
61 |
|
| 59 |
public class TransferLotController extends BaseController{
|
62 |
public class TransferLotController extends BaseController{
|
| 60 |
|
63 |
|
| Line 73... |
Line 76... |
| 73 |
private Calendar transferLotFromDate;
|
76 |
private Calendar transferLotFromDate;
|
| 74 |
private Calendar transferLotToDate;
|
77 |
private Calendar transferLotToDate;
|
| 75 |
private Long originWarehouseId;
|
78 |
private Long originWarehouseId;
|
| 76 |
private List<LineItem> lineItems;
|
79 |
private List<LineItem> lineItems;
|
| 77 |
private Long destinationWarehouseId;
|
80 |
private Long destinationWarehouseId;
|
| - |
|
81 |
private String inventoryItemsString;
|
| - |
|
82 |
private JSONObject jsonTransferLotItemData = null;
|
| - |
|
83 |
private String inventoryItemsLength;
|
| - |
|
84 |
private String transferLotReceiveType;
|
| 78 |
|
85 |
|
| 79 |
private String output;
|
86 |
private String output;
|
| 80 |
private static Map<Long, Warehouse> warehouseMap;
|
87 |
private static Map<Long, Warehouse> warehouseMap;
|
| 81 |
|
88 |
|
| 82 |
private static SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
|
89 |
private static SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
|
| 83 |
|
90 |
|
| - |
|
91 |
private static long totalItemsSizeInTransferLot;
|
| - |
|
92 |
private static boolean isCompleteTransferAvailable = false;
|
| 84 |
private static Logger logger = LoggerFactory.getLogger(TransferLotController.class);
|
93 |
private static Logger logger = LoggerFactory.getLogger(TransferLotController.class);
|
| 85 |
|
94 |
|
| 86 |
static {
|
95 |
static {
|
| 87 |
warehouseMap = new HashMap<Long, Warehouse>();
|
96 |
warehouseMap = new HashMap<Long, Warehouse>();
|
| 88 |
InventoryClient inventoryServiceClient;
|
97 |
InventoryClient inventoryServiceClient;
|
| Line 255... |
Line 264... |
| 255 |
} catch (CatalogServiceException csex) {
|
264 |
} catch (CatalogServiceException csex) {
|
| 256 |
logger.error("Error in getting transfer lot items",csex);
|
265 |
logger.error("Error in getting transfer lot items",csex);
|
| 257 |
}
|
266 |
}
|
| 258 |
return OUTPUT;
|
267 |
return OUTPUT;
|
| 259 |
}
|
268 |
}
|
| - |
|
269 |
|
| - |
|
270 |
public String getTransferLotItemsForMarkReceive(){
|
| - |
|
271 |
try{
|
| - |
|
272 |
WarehouseService.Client warehouseClient = new WarehouseClient().getClient();
|
| - |
|
273 |
List<InventoryItem> inventoryItems = warehouseClient.getTransferLotItemsForMarkReceive(id, ScanType.WAREHOUSE_TRANSFER_OUT);
|
| - |
|
274 |
CatalogService.Client catalogClient = new CatalogClient().getClient();
|
| - |
|
275 |
Set<Long> itemIdSet = new HashSet<Long>();
|
| - |
|
276 |
Map<Long,Map<String,String>> itemDataMap = new HashMap<Long,Map<String,String>>();
|
| - |
|
277 |
Map<String,List<Map<String,String>>> jsonDataMap = new HashMap<String,List<Map<String,String>>>();
|
| - |
|
278 |
List<Map<String,String>> jsonDataList = new ArrayList<Map<String,String>>();
|
| - |
|
279 |
//long quantity = 0;
|
| - |
|
280 |
for(InventoryItem item : inventoryItems){
|
| - |
|
281 |
itemIdSet.add(item.getItemId());
|
| - |
|
282 |
}
|
| - |
|
283 |
for(Long id : itemIdSet){
|
| - |
|
284 |
Item catalogItem = catalogClient.getItem(id);
|
| - |
|
285 |
Map<String,String> itemdetailsMap = new HashMap<String,String>();
|
| - |
|
286 |
itemdetailsMap.put("Name", catalogItem.getBrand() + " " + catalogItem.getModelName() + " " + catalogItem.getModelNumber() + " " + catalogItem.getColor());
|
| - |
|
287 |
itemdetailsMap.put("Type", catalogItem.getType().name());
|
| - |
|
288 |
itemDataMap.put(id,itemdetailsMap);
|
| - |
|
289 |
}
|
| - |
|
290 |
for(InventoryItem item : inventoryItems){
|
| - |
|
291 |
Map<String,String> dataMap = new HashMap<String,String>();
|
| - |
|
292 |
ItemType type = ItemType.valueOf(itemDataMap.get(item.getItemId()).get("Type"));
|
| - |
|
293 |
dataMap.put("ItemId",item.getId()+"");
|
| - |
|
294 |
if(ItemType.SERIALIZED == type){
|
| - |
|
295 |
dataMap.put("ItemDetail",itemDataMap.get(item.getItemId()).get("Name") +"-"+ item.getSerialNumber()+"-Units("+item.getInitialQuantity()+")");
|
| - |
|
296 |
}
|
| - |
|
297 |
else{
|
| - |
|
298 |
dataMap.put("ItemDetail",itemDataMap.get(item.getItemId()).get("Name") +"-"+ item.getItemNumber()+"-Units("+item.getInitialQuantity()+")");
|
| - |
|
299 |
}
|
| - |
|
300 |
TransferLotStatus transferLotStatus = item.getTransferStatus();
|
| - |
|
301 |
if(TransferLotStatus.IN_TRANSIT == transferLotStatus){
|
| - |
|
302 |
dataMap.put("ItemStatus","Enabled");
|
| - |
|
303 |
}
|
| - |
|
304 |
else{
|
| - |
|
305 |
dataMap.put("ItemStatus","Disabled");
|
| - |
|
306 |
}
|
| - |
|
307 |
//quantity = quantity + item.getInitialQuantity();
|
| - |
|
308 |
jsonDataList.add(dataMap);
|
| - |
|
309 |
|
| - |
|
310 |
}
|
| - |
|
311 |
totalItemsSizeInTransferLot= inventoryItems.size();
|
| - |
|
312 |
jsonDataMap.put("TransferLotItemData", jsonDataList);
|
| - |
|
313 |
|
| - |
|
314 |
setJsonTransferLotItemData(new JSONObject(jsonDataMap));
|
| - |
|
315 |
|
| - |
|
316 |
} catch(Exception e){
|
| - |
|
317 |
logger.error("Error While getting Transfer Lot Items for Mark Receive",e);
|
| - |
|
318 |
}
|
| - |
|
319 |
return OUTPUT;
|
| - |
|
320 |
}
|
| 260 |
|
321 |
|
| 261 |
public String markTransferLotAsReceived() throws Exception {
|
322 |
public String markTransferLotAsReceived() throws Exception {
|
| 262 |
try{
|
323 |
try{
|
| 263 |
WarehouseService.Client warehouseClient = new WarehouseClient().getClient();
|
324 |
WarehouseService.Client warehouseClient = new WarehouseClient().getClient();
|
| 264 |
warehouseClient.markItemsAsReceivedForTransferLot(id);
|
325 |
warehouseClient.markItemsAsReceivedForTransferLot(id);
|
| Line 271... |
Line 332... |
| 271 |
throw new Exception("Error in marking transfer lot as received");
|
332 |
throw new Exception("Error in marking transfer lot as received");
|
| 272 |
}
|
333 |
}
|
| 273 |
return INDEX;
|
334 |
return INDEX;
|
| 274 |
}
|
335 |
}
|
| 275 |
|
336 |
|
| - |
|
337 |
public String markTransferLotAsReceivedPartial() throws Exception {
|
| - |
|
338 |
try{
|
| - |
|
339 |
WarehouseService.Client warehouseClient = new WarehouseClient().getClient();
|
| - |
|
340 |
TransferLot transferLot = warehouseClient.getTransferLot(id);
|
| - |
|
341 |
if(transferLot.getTransitCompletionReferenceNumber()!=null && !("").equalsIgnoreCase(transferLot.getTransitCompletionReferenceNumber())){
|
| - |
|
342 |
remoteTransferRefNumber = transferLot.getTransitCompletionReferenceNumber()+":"+remoteTransferRefNumber;
|
| - |
|
343 |
}
|
| - |
|
344 |
if("complete".equalsIgnoreCase(transferLotReceiveType)){
|
| - |
|
345 |
|
| - |
|
346 |
System.out.println("In Transfer Complete Block");
|
| - |
|
347 |
|
| - |
|
348 |
if (TransferLotStatus.IN_TRANSIT.equals(transferLot.getStatus())){
|
| - |
|
349 |
if(!warehouseClient.isAlive()){
|
| - |
|
350 |
warehouseClient = new WarehouseClient().getClient();
|
| - |
|
351 |
}
|
| - |
|
352 |
warehouseClient.markItemsAsReceivedForTransferLot(id);
|
| - |
|
353 |
warehouseClient.markTransferLotAsReceived(id, remoteTransferRefNumber);
|
| - |
|
354 |
}
|
| - |
|
355 |
if (TransferLotStatus.PARTIAL_TRANSFER.equals(transferLot.getStatus())){
|
| - |
|
356 |
String[] inventoryItemsArr = inventoryItemsString.split(",");
|
| - |
|
357 |
//System.out.println("inventoryItemsArr Length... "+inventoryItemsArr.length);
|
| - |
|
358 |
|
| - |
|
359 |
List<InventoryItem> inventoryItemList = new ArrayList<InventoryItem>();
|
| - |
|
360 |
for(String inventItemStr : inventoryItemsArr){
|
| - |
|
361 |
if(!warehouseClient.isAlive()){
|
| - |
|
362 |
warehouseClient = new WarehouseClient().getClient();
|
| - |
|
363 |
}
|
| - |
|
364 |
InventoryItem item = warehouseClient.getInventoryItemFromId(Long.parseLong(inventItemStr));
|
| - |
|
365 |
inventoryItemList.add(item);
|
| - |
|
366 |
}
|
| - |
|
367 |
if(!warehouseClient.isAlive()){
|
| - |
|
368 |
warehouseClient = new WarehouseClient().getClient();
|
| - |
|
369 |
}
|
| - |
|
370 |
warehouseClient.markItemsAsReceivedForTransferLotPartial(inventoryItemList,id);
|
| - |
|
371 |
warehouseClient.markTransferLotAsReceived(id, remoteTransferRefNumber);
|
| - |
|
372 |
}
|
| - |
|
373 |
}
|
| - |
|
374 |
else{
|
| - |
|
375 |
List<InventoryItem> inventoryItemsScannedIn = warehouseClient.getTransferLotItemsForMarkReceive(id,ScanType.WAREHOUSE_TRANSFER_IN);
|
| - |
|
376 |
System.out.println("totalItemsSizeInTransferLot....."+totalItemsSizeInTransferLot);
|
| - |
|
377 |
int totalItemsSizeScannedIn = inventoryItemsScannedIn.size();
|
| - |
|
378 |
int totalItemsSizeToBeScanIn = Integer.parseInt(inventoryItemsLength);
|
| - |
|
379 |
System.out.println("totalItemsSizeScannedIn....."+totalItemsSizeScannedIn);
|
| - |
|
380 |
System.out.println("totalItemsSizeToBeScanIn....."+totalItemsSizeToBeScanIn);
|
| - |
|
381 |
|
| - |
|
382 |
String[] inventoryItemsArr = inventoryItemsString.split(",");
|
| - |
|
383 |
System.out.println("inventoryItemsArr Length... "+inventoryItemsArr.length);
|
| - |
|
384 |
|
| - |
|
385 |
List<InventoryItem> inventoryItemList = new ArrayList<InventoryItem>();
|
| - |
|
386 |
for(String inventItemStr : inventoryItemsArr){
|
| - |
|
387 |
if(!warehouseClient.isAlive()){
|
| - |
|
388 |
warehouseClient = new WarehouseClient().getClient();
|
| - |
|
389 |
}
|
| - |
|
390 |
InventoryItem item = warehouseClient.getInventoryItemFromId(Long.parseLong(inventItemStr));
|
| - |
|
391 |
inventoryItemList.add(item);
|
| - |
|
392 |
}
|
| - |
|
393 |
if(totalItemsSizeToBeScanIn==totalItemsSizeInTransferLot){
|
| - |
|
394 |
System.out.println("Transfer Complete");
|
| - |
|
395 |
if(!warehouseClient.isAlive()){
|
| - |
|
396 |
warehouseClient = new WarehouseClient().getClient();
|
| - |
|
397 |
}
|
| - |
|
398 |
warehouseClient.markItemsAsReceivedForTransferLot(id);
|
| - |
|
399 |
warehouseClient.markTransferLotAsReceived(id, remoteTransferRefNumber);
|
| - |
|
400 |
}
|
| - |
|
401 |
if(totalItemsSizeInTransferLot== (totalItemsSizeScannedIn + totalItemsSizeToBeScanIn)){
|
| - |
|
402 |
System.out.println("Transfer Complete.... from Partial");
|
| - |
|
403 |
if(!warehouseClient.isAlive()){
|
| - |
|
404 |
warehouseClient = new WarehouseClient().getClient();
|
| - |
|
405 |
}
|
| - |
|
406 |
warehouseClient.markItemsAsReceivedForTransferLotPartial(inventoryItemList,id);
|
| - |
|
407 |
warehouseClient.markTransferLotAsReceived(id, remoteTransferRefNumber);
|
| - |
|
408 |
}
|
| - |
|
409 |
if(totalItemsSizeToBeScanIn<totalItemsSizeInTransferLot){
|
| - |
|
410 |
System.out.println("Items and Transfer Lot Partial");
|
| - |
|
411 |
if(!warehouseClient.isAlive()){
|
| - |
|
412 |
warehouseClient = new WarehouseClient().getClient();
|
| - |
|
413 |
}
|
| - |
|
414 |
warehouseClient.markItemsAsReceivedForTransferLotPartial(inventoryItemList,id);
|
| - |
|
415 |
warehouseClient.markTransferLotAsReceivedPartial(id, remoteTransferRefNumber);
|
| - |
|
416 |
}
|
| - |
|
417 |
}
|
| - |
|
418 |
|
| - |
|
419 |
} catch(Exception e){
|
| - |
|
420 |
logger.error("Error in marking transfer lot as received",e);
|
| - |
|
421 |
throw new Exception("Error in marking transfer lot as received");
|
| - |
|
422 |
}
|
| - |
|
423 |
return INDEX;
|
| - |
|
424 |
}
|
| - |
|
425 |
|
| 276 |
public void downloadFBASheet() {
|
426 |
public void downloadFBASheet() {
|
| 277 |
try {
|
427 |
try {
|
| 278 |
WarehouseService.Client warehouseClient = new WarehouseClient().getClient();
|
428 |
WarehouseService.Client warehouseClient = new WarehouseClient().getClient();
|
| 279 |
Map<Long, Long> transferLotItems = warehouseClient.getItemsInTransferLot(id);
|
429 |
Map<Long, Long> transferLotItems = warehouseClient.getItemsInTransferLot(id);
|
| 280 |
|
430 |
|
| Line 471... |
Line 621... |
| 471 |
}
|
621 |
}
|
| 472 |
|
622 |
|
| 473 |
public void setLineItems(List<LineItem> lineItems) {
|
623 |
public void setLineItems(List<LineItem> lineItems) {
|
| 474 |
this.lineItems = lineItems;
|
624 |
this.lineItems = lineItems;
|
| 475 |
}
|
625 |
}
|
| - |
|
626 |
|
| - |
|
627 |
public JSONObject getJsonTransferLotItemData() {
|
| - |
|
628 |
return jsonTransferLotItemData;
|
| 476 |
|
629 |
}
|
| - |
|
630 |
|
| - |
|
631 |
public void setJsonTransferLotItemData(JSONObject jsonTransferLotItemData) {
|
| - |
|
632 |
this.jsonTransferLotItemData = jsonTransferLotItemData;
|
| - |
|
633 |
}
|
| - |
|
634 |
|
| - |
|
635 |
public String getInventoryItemsString() {
|
| - |
|
636 |
return inventoryItemsString;
|
| - |
|
637 |
}
|
| - |
|
638 |
|
| - |
|
639 |
public void setInventoryItemsString(String inventoryItemsString) {
|
| - |
|
640 |
this.inventoryItemsString = inventoryItemsString;
|
| - |
|
641 |
}
|
| - |
|
642 |
|
| - |
|
643 |
public String getInventoryItemsLength() {
|
| - |
|
644 |
return inventoryItemsLength;
|
| - |
|
645 |
}
|
| - |
|
646 |
|
| - |
|
647 |
public void setInventoryItemsLength(String inventoryItemsLength) {
|
| - |
|
648 |
this.inventoryItemsLength = inventoryItemsLength;
|
| - |
|
649 |
}
|
| - |
|
650 |
|
| - |
|
651 |
public String getTransferLotReceiveType() {
|
| - |
|
652 |
return transferLotReceiveType;
|
| 477 |
|
653 |
}
|
| - |
|
654 |
|
| - |
|
655 |
public void setTransferLotReceiveType(String transferLotReceiveType) {
|
| - |
|
656 |
this.transferLotReceiveType = transferLotReceiveType;
|
| 478 |
|
657 |
}
|
| - |
|
658 |
|
| 479 |
}
|
659 |
}
|