| 4500 |
mandeep.dh |
1 |
/**
|
|
|
2 |
*
|
|
|
3 |
*/
|
|
|
4 |
package in.shop2020.warehouse.handler;
|
|
|
5 |
|
| 8689 |
amar.kumar |
6 |
import in.shop2020.model.v1.inventory.InventoryService;
|
|
|
7 |
import in.shop2020.model.v1.inventory.InventoryServiceException;
|
|
|
8 |
import in.shop2020.model.v1.inventory.Warehouse;
|
|
|
9 |
import in.shop2020.thrift.clients.InventoryClient;
|
| 7613 |
amar.kumar |
10 |
import in.shop2020.warehouse.InTransitInventory;
|
| 5185 |
mandeep.dh |
11 |
import in.shop2020.warehouse.ScanType;
|
| 4500 |
mandeep.dh |
12 |
import in.shop2020.warehouse.domain.InventoryItem;
|
|
|
13 |
import in.shop2020.warehouse.persistence.InventoryItemMapper;
|
|
|
14 |
|
| 7613 |
amar.kumar |
15 |
import java.util.ArrayList;
|
| 10215 |
amar.kumar |
16 |
import java.util.Date;
|
| 10864 |
manish.sha |
17 |
import java.util.HashMap;
|
| 10215 |
amar.kumar |
18 |
import java.util.HashSet;
|
| 5185 |
mandeep.dh |
19 |
import java.util.List;
|
| 6484 |
amar.kumar |
20 |
import java.util.Map;
|
| 10215 |
amar.kumar |
21 |
import java.util.Set;
|
| 5185 |
mandeep.dh |
22 |
|
| 10864 |
manish.sha |
23 |
import org.apache.ibatis.annotations.Param;
|
| 8689 |
amar.kumar |
24 |
import org.apache.thrift.TException;
|
|
|
25 |
import org.apache.thrift.transport.TTransportException;
|
| 4500 |
mandeep.dh |
26 |
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
27 |
import org.springframework.stereotype.Service;
|
|
|
28 |
|
| 5530 |
mandeep.dh |
29 |
import com.mysql.jdbc.StringUtils;
|
|
|
30 |
|
| 4500 |
mandeep.dh |
31 |
/**
|
|
|
32 |
* @author mandeep
|
|
|
33 |
*
|
|
|
34 |
*/
|
|
|
35 |
@Service
|
|
|
36 |
public class InventoryItemHandler {
|
|
|
37 |
@Autowired
|
|
|
38 |
private InventoryItemMapper inventoryItemMapper;
|
|
|
39 |
|
|
|
40 |
/**
|
|
|
41 |
* @param inventoryItem
|
|
|
42 |
*/
|
| 5110 |
mandeep.dh |
43 |
public InventoryItem insertInventoryItem(InventoryItem inventoryItem) {
|
| 4500 |
mandeep.dh |
44 |
inventoryItemMapper.insertInventoryItem(inventoryItem);
|
| 5110 |
mandeep.dh |
45 |
return inventoryItem;
|
| 4500 |
mandeep.dh |
46 |
}
|
|
|
47 |
|
|
|
48 |
/**
|
|
|
49 |
* @param inventoryItemId
|
|
|
50 |
* @return
|
|
|
51 |
*/
|
|
|
52 |
public InventoryItem getInventoryItem(long inventoryItemId) {
|
|
|
53 |
return inventoryItemMapper.getInventoryItem(inventoryItemId);
|
|
|
54 |
}
|
|
|
55 |
|
|
|
56 |
/**
|
|
|
57 |
* @param serialNumber
|
|
|
58 |
* @return
|
|
|
59 |
*/
|
|
|
60 |
public InventoryItem getInventoryItem(String serialNumber) {
|
|
|
61 |
return inventoryItemMapper.getInventoryItemFromSerialNumber(serialNumber);
|
|
|
62 |
}
|
| 5185 |
mandeep.dh |
63 |
|
|
|
64 |
public List<InventoryItem> getInventoryItemFromLastScanType(ScanType scanType) {
|
|
|
65 |
return inventoryItemMapper.getInventoryItemsFromLastScanType(scanType);
|
|
|
66 |
}
|
|
|
67 |
|
|
|
68 |
/**
|
|
|
69 |
* @param inventoryItemId
|
|
|
70 |
* @return
|
|
|
71 |
*/
|
|
|
72 |
public InventoryItem getInventoryItemFromId(long inventoryItemId) {
|
|
|
73 |
return inventoryItemMapper.getInventoryItemsFromId(inventoryItemId);
|
|
|
74 |
}
|
|
|
75 |
|
|
|
76 |
/**
|
|
|
77 |
* @param inventoryItem
|
|
|
78 |
*/
|
|
|
79 |
public void update(InventoryItem inventoryItem) {
|
|
|
80 |
inventoryItemMapper.update(inventoryItem);
|
|
|
81 |
}
|
| 5361 |
mandeep.dh |
82 |
|
|
|
83 |
/**
|
|
|
84 |
* @param itemId
|
|
|
85 |
* @param warehouseId
|
|
|
86 |
* @return
|
|
|
87 |
*/
|
| 8565 |
amar.kumar |
88 |
public InventoryItem getInventoryItem(String itemNumber, long itemId, long warehouseId, long billingWarehouseId) {
|
| 5530 |
mandeep.dh |
89 |
if (StringUtils.isNullOrEmpty(itemNumber)) {
|
|
|
90 |
itemNumber = null;
|
|
|
91 |
}
|
|
|
92 |
|
| 8565 |
amar.kumar |
93 |
return inventoryItemMapper.getNonSerializedInventoryItem(itemNumber, itemId, warehouseId, billingWarehouseId);
|
| 5361 |
mandeep.dh |
94 |
}
|
| 6467 |
amar.kumar |
95 |
|
| 7957 |
amar.kumar |
96 |
public Long getCurrentQuantityForNonSerializedItem(long itemId, long warehouseId, long physicalWarehouseId) {
|
|
|
97 |
return inventoryItemMapper.getCurrentQuantityForNonSerializedItem(itemId, warehouseId, physicalWarehouseId);
|
| 6467 |
amar.kumar |
98 |
}
|
|
|
99 |
|
|
|
100 |
public void markPurchaseReturnIdForItem(long id, long currentQuantity, long purchaseReturnId) {
|
|
|
101 |
inventoryItemMapper.markPurchaseReturnIdForItem(id, currentQuantity, purchaseReturnId);
|
|
|
102 |
|
|
|
103 |
}
|
| 10864 |
manish.sha |
104 |
|
|
|
105 |
public void markPurchaseReturnIdForBadItem(long id, long currentQuantity, long purchaseReturnId) {
|
|
|
106 |
inventoryItemMapper.markPurchaseReturnIdForBadItem(id, currentQuantity, purchaseReturnId);
|
|
|
107 |
}
|
| 6467 |
amar.kumar |
108 |
|
| 8689 |
amar.kumar |
109 |
public List<InventoryItem> getCurrentNonSerializedItemsByItemId(long itemId, long warehouseId) throws InventoryServiceException, TException {
|
|
|
110 |
InventoryService.Client inventoryClient = new InventoryClient().getClient();
|
|
|
111 |
Warehouse warehouse = inventoryClient.getWarehouse(warehouseId);
|
|
|
112 |
return inventoryItemMapper.getCurrentNonSerializedItemsByItemId(itemId, warehouseId, warehouse.getBillingWarehouseId());
|
| 6467 |
amar.kumar |
113 |
}
|
| 6484 |
amar.kumar |
114 |
|
| 10864 |
manish.sha |
115 |
public List<InventoryItem> getNonSerializedItemsForBadInventory(long itemId, long currentWarehouseId, long physicalWarehouseId){
|
|
|
116 |
return inventoryItemMapper.getNonSerializedItemsForBadInventory(itemId, currentWarehouseId, physicalWarehouseId);
|
|
|
117 |
}
|
|
|
118 |
|
| 6484 |
amar.kumar |
119 |
public List<Map<String, Integer>> getCurrentSerializedInventory() {
|
|
|
120 |
return inventoryItemMapper.getCurrentSerializedInventory();
|
|
|
121 |
}
|
|
|
122 |
|
|
|
123 |
public List<Map<String, Integer>> getCurrentNonSerializedInventory() {
|
|
|
124 |
return inventoryItemMapper.getCurrentNonSerializedInventory();
|
|
|
125 |
}
|
| 6558 |
amar.kumar |
126 |
|
|
|
127 |
public void markItemAsLost(long id, long currentQuantity) {
|
|
|
128 |
inventoryItemMapper.markItemAsLost(id, currentQuantity);
|
|
|
129 |
|
|
|
130 |
}
|
| 7410 |
amar.kumar |
131 |
|
|
|
132 |
/*public void markTransferLotAsRecieved(long id) {
|
|
|
133 |
inventoryItemMapper.markTransferLotAsRecieved(id);
|
|
|
134 |
}*/
|
|
|
135 |
|
|
|
136 |
public List<InventoryItem> getInventoryItemsForTransferLot(long id) {
|
|
|
137 |
return inventoryItemMapper.getInventoryItemsForTransferLot(id);
|
|
|
138 |
}
|
|
|
139 |
|
|
|
140 |
/*public InventoryItem getNonSeralizedInventoryItemForPhysicalWarehouse(
|
|
|
141 |
String itemNumber, long itemId, long physicalWarehouseId) {
|
|
|
142 |
return inventoryItemMapper.getNonSeralizedInventoryItemForPhysicalWarehouse(itemNumber, itemId, physicalWarehouseId);
|
|
|
143 |
}*/
|
|
|
144 |
|
|
|
145 |
public long getCurrentQuantityForNonSerializedItemInPhysicalWarehouse(
|
|
|
146 |
long itemId, long physicalWarehouseId) {
|
|
|
147 |
return inventoryItemMapper.getCurrentQuantityForNonSerializedItemInPhysicalWarehouse(itemId, physicalWarehouseId);
|
|
|
148 |
}
|
|
|
149 |
|
|
|
150 |
public List<InventoryItem> getCurrentNonSerializedItemsByItemIdInPhysicalWarehouse(
|
|
|
151 |
long itemId, long physicalWarehouseId) {
|
|
|
152 |
return inventoryItemMapper.getCurrentNonSerializedItemsByItemIdInPhysicalWarehouse(itemId, physicalWarehouseId);
|
|
|
153 |
}
|
| 7574 |
amar.kumar |
154 |
|
|
|
155 |
public long getCurrentQuantityForNonSerializedInTransitItemInPhysicalWarehouse(
|
|
|
156 |
long itemId, long physicalWarehouseId) {
|
|
|
157 |
return inventoryItemMapper.getCurrentQuantityForNonSerializedInTransitItemInPhysicalWarehouse(
|
|
|
158 |
itemId, physicalWarehouseId);
|
|
|
159 |
}
|
| 7613 |
amar.kumar |
160 |
|
|
|
161 |
public List<InTransitInventory> getInTransitInventory(long originWarehouseId) {
|
|
|
162 |
List<InTransitInventory> t_InTransitInventories = new ArrayList<InTransitInventory>();
|
|
|
163 |
for(in.shop2020.warehouse.domain.InTransitInventory intransitInventory :inventoryItemMapper.getInTransitInventory(originWarehouseId)) {
|
|
|
164 |
t_InTransitInventories.add(intransitInventory.toThriftObject());
|
|
|
165 |
}
|
|
|
166 |
return t_InTransitInventories;
|
|
|
167 |
}
|
| 9129 |
amar.kumar |
168 |
|
|
|
169 |
public List<InventoryItem> getCurrentInTransitInventoryInPhysicalWarehouse(
|
|
|
170 |
long itemId, long originWarehouseId) {
|
|
|
171 |
return inventoryItemMapper.getCurrentInTransitInventoryInPhysicalWarehouse(itemId, originWarehouseId);
|
|
|
172 |
}
|
| 6484 |
amar.kumar |
173 |
|
| 10120 |
manish.sha |
174 |
public List<InventoryItem> getTransferLotItemsForMarkReceive(
|
|
|
175 |
long transferLotId, ScanType scanType) {
|
|
|
176 |
return inventoryItemMapper.getTransferLotItemsForMarkReceive(transferLotId,scanType);
|
|
|
177 |
}
|
| 10215 |
amar.kumar |
178 |
|
|
|
179 |
public List<Long> getEmptyGrnsByDate(Date startDate, Date endDate) {
|
|
|
180 |
List<Long> allGrns = inventoryItemMapper.getAllGrnsByDate(startDate, endDate);
|
|
|
181 |
List<Long> nonEmptyGrns = inventoryItemMapper.getNonEmptyGrnsByDate(startDate, endDate);
|
|
|
182 |
|
|
|
183 |
List<Long> emptyGrnsList = new ArrayList<Long>(10);
|
|
|
184 |
|
|
|
185 |
Set<Long> emptyGrns = new HashSet<Long>();
|
|
|
186 |
emptyGrns.addAll(allGrns);
|
|
|
187 |
emptyGrns.removeAll(nonEmptyGrns);
|
|
|
188 |
|
|
|
189 |
emptyGrnsList.addAll(emptyGrns);
|
|
|
190 |
return emptyGrnsList;
|
|
|
191 |
}
|
| 10407 |
amar.kumar |
192 |
|
|
|
193 |
public InventoryItem getSellableBadNonSerializedItem(long itemId, String itemNumber, long physicalWarehouseId) {
|
|
|
194 |
return inventoryItemMapper.getSellableBadNonSerializedItem(itemId, itemNumber, physicalWarehouseId);
|
|
|
195 |
|
|
|
196 |
}
|
| 10120 |
manish.sha |
197 |
|
| 10689 |
manish.sha |
198 |
public List<InventoryItem> getInventoryItemScannedInForPO(long itemId, List<Long> purchaseIds) {
|
|
|
199 |
return inventoryItemMapper.getInventoryItemScannedInForPO(itemId, purchaseIds);
|
|
|
200 |
}
|
|
|
201 |
|
| 10864 |
manish.sha |
202 |
public Long getCurrentBadQuantityForItem( long itemId, long currentWarehouseId, long physicalWarehouseId){
|
|
|
203 |
return inventoryItemMapper.getCurrentBadQuantityForItem(itemId, currentWarehouseId, physicalWarehouseId);
|
|
|
204 |
}
|
|
|
205 |
|
| 11751 |
manish.sha |
206 |
public Map<Long, Long> getItemsInPurchaseReturn(long purchaseReturnId, ScanType type){
|
|
|
207 |
Map<Integer, Integer> result = inventoryItemMapper.getItemsInPurchaseReturn(purchaseReturnId, type);
|
| 10864 |
manish.sha |
208 |
Map<Long, Long> purchaseReturnItems = new HashMap<Long, Long>();
|
|
|
209 |
|
|
|
210 |
for(Integer itemId : result.keySet()){
|
|
|
211 |
Long count = Long.parseLong(((Object)((Map<String,Long>)(Object)result.get(itemId)).get("count")).toString());
|
|
|
212 |
purchaseReturnItems.put(new Long(itemId), count);
|
|
|
213 |
}
|
|
|
214 |
return purchaseReturnItems;
|
|
|
215 |
}
|
| 4500 |
mandeep.dh |
216 |
}
|