Subversion Repositories SmartDukaan

Rev

Rev 10120 | Blame | Compare with Previous | Last modification | View Log | RSS feed

/**
 * 
 */
package in.shop2020.warehouse.handler;

import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import in.shop2020.warehouse.TransferLotStatus;
import in.shop2020.warehouse.domain.RemovalStockShipmentReference;
import in.shop2020.warehouse.domain.TransferLot;
import in.shop2020.warehouse.persistence.TransferLotMapper;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


/**
 * @author amar
 *
 */
@Service
public class TransferLotHandler {
    @Autowired
    private TransferLotMapper transferLotMapper;

        public long createTransferLot(TransferLot transferLot) {
                transferLotMapper.createTransferLot(transferLot);
                return transferLot.getId();
        }

        public TransferLot getTransferLot(long transferLotId) {
                return transferLotMapper.getTransferLot(transferLotId);
        }

        public List<TransferLot> getTransferLotsByDate(Date fromDate, Date toDate) {
                return transferLotMapper.getTransferLotsByDate(fromDate, toDate);
        }
        
        
        public Map<Long, Long> getItemsInTransferLot(long transferLotId) {
                Map<Integer, Integer> result = transferLotMapper.getItemsInTransferLot(transferLotId);
                Map<Long, Long> lotItems = new HashMap<Long, Long>();
                
                for(Integer itemId : result.keySet()){
                        Long count = Long.parseLong(((Object)((Map<String,Long>)(Object)result.get(itemId)).get("count")).toString());
                        lotItems.put(new Long(itemId), count);
                }
                return lotItems;
        }

        public void markTransferLotAsReceived(long id, String remoteTransferRefNumber) {
                transferLotMapper.markTransferLotAsReceived(id, remoteTransferRefNumber);
                
        }

        public List<Long> getAllowedDestinationWarehousesForTransfer(
                        long originWarehouseId) {
                return transferLotMapper.getAllowedDestinationWarehousesForTransfer(originWarehouseId);
        }

        public void updateTransferLotStatus(long id,
                        TransferLotStatus status) {
                transferLotMapper.updateTransferLotStatus(id, status);
        }

        public void markTransferLotAsReceivedPartial(long id, String remoteTransferRefNumber){
                transferLotMapper.markTransferLotAsReceivedPartial(id, remoteTransferRefNumber);
        }
        
        public RemovalStockShipmentReference getRemovalStockShipmentReferenceById(long id) {
                return transferLotMapper.getRemovalStockShipmentReferenceById(id);
        }
    
        public List<RemovalStockShipmentReference> getAllUnCompletedStockShipments(String source){
                return transferLotMapper.getAllUnCompletedStockShipments(source);
        }
        
        public void updateShipmentReferenceTransferLot(long id, long shipmentReference){
                transferLotMapper.updateShipmentReferenceTransferLot(id, shipmentReference);
        }
        
        public long createRemovalStockShipmentReference(RemovalStockShipmentReference removalStockShipmentReference){
                transferLotMapper.createRemovalStockShipmentReference(removalStockShipmentReference);
                return removalStockShipmentReference.getId();
        }
        
        public void updateStockShipment(long lineItemQuantity, long id){
                transferLotMapper.updateStockShipment(lineItemQuantity, id);
        }
        
        public void markStockShipmentComplete(long id){
                transferLotMapper.markStockShipmentComplete(id);
        }
        
}