| 4500 |
mandeep.dh |
1 |
<?xml version="1.0" encoding="UTF-8"?>
|
|
|
2 |
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
3 |
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
|
|
4 |
|
|
|
5 |
<mapper namespace="in.shop2020.warehouse.persistence.ScanMapper">
|
|
|
6 |
<resultMap type="scan" id="scanResult">
|
|
|
7 |
<id property="id" column="id"/>
|
|
|
8 |
</resultMap>
|
|
|
9 |
|
|
|
10 |
<insert id="insert" parameterType="scan" useGeneratedKeys="true" keyProperty="id">
|
|
|
11 |
INSERT INTO scanNew
|
| 7410 |
amar.kumar |
12 |
(inventoryItemId, warehouseId, type, scannedAt, quantity, orderId, transferLotId, remarks)
|
| 4500 |
mandeep.dh |
13 |
VALUES
|
| 7410 |
amar.kumar |
14 |
(#{inventoryItemId}, #{warehouseId}, #{type}, NOW(), #{quantity}, #{orderId}, #{transferLotId}, #{remarks})
|
| 4500 |
mandeep.dh |
15 |
</insert>
|
|
|
16 |
|
|
|
17 |
<select id="get" parameterType="map" resultType="scan">
|
|
|
18 |
SELECT *
|
|
|
19 |
FROM scanNew
|
|
|
20 |
WHERE inventoryItemId = #{inventoryItemId}
|
|
|
21 |
<if test="scanType != null">
|
|
|
22 |
AND type = #{scanType}
|
|
|
23 |
</if>
|
|
|
24 |
ORDER BY scannedAt
|
|
|
25 |
</select>
|
| 5361 |
mandeep.dh |
26 |
|
|
|
27 |
<select id="getScansFromOrderId" parameterType="java.lang.Long" resultType="scan">
|
|
|
28 |
SELECT *
|
|
|
29 |
FROM scanNew
|
|
|
30 |
WHERE orderId = #{orderId}
|
|
|
31 |
ORDER BY scannedAt
|
|
|
32 |
</select>
|
| 5372 |
mandeep.dh |
33 |
|
| 7199 |
amar.kumar |
34 |
<select id="getScansForOrderAndItem" parameterType="map" resultType="scan">
|
|
|
35 |
SELECT s.id as id, s.inventoryItemId as inventoryItemId, s.warehouseId as warehouseId, s.type as type,
|
|
|
36 |
s.scannedAt as scannedAt, s.quantity as quantity, s.orderId as orderId
|
|
|
37 |
FROM scanNew s
|
|
|
38 |
JOIN inventoryItem i
|
|
|
39 |
ON (s.inventoryItemId = i.id)
|
|
|
40 |
WHERE i.itemId = #{itemId}
|
|
|
41 |
AND s.orderId = #{orderId}
|
|
|
42 |
ORDER BY scannedAt
|
|
|
43 |
</select>
|
|
|
44 |
|
|
|
45 |
|
| 5372 |
mandeep.dh |
46 |
<select id="getPurchaseScans" parameterType="map" resultType="detailedPurchaseScan">
|
| 5395 |
mandeep.dh |
47 |
SELECT p.purchaseOrder_id AS purchaseOrderId, 1000 * UNIX_TIMESTAMP(po.createdAt) AS poCreatedAt, s.name AS supplierName,
|
| 6494 |
amar.kumar |
48 |
GROUP_CONCAT(DISTINCT(p.invoiceNumber)) AS invoiceNumbers, GROUP_CONCAT(DISTINCT(inv.receivedFrom)) AS receivedBy, i.itemId,
|
| 8580 |
amar.kumar |
49 |
brand, modelName, modelNumber, color, unitPrice, SUM(initialQuantity) AS quantity, 1000 * UNIX_TIMESTAMP(receivedOn) as purchasedAt,
|
|
|
50 |
p.id as purchaseId, nlc, po.warehouseId
|
| 5372 |
mandeep.dh |
51 |
FROM purchase p
|
|
|
52 |
JOIN purchaseorder po
|
|
|
53 |
ON (po.id = p.purchaseOrder_id)
|
|
|
54 |
JOIN inventoryItem i
|
|
|
55 |
ON (p.id = i.purchaseId)
|
|
|
56 |
JOIN lineitem l
|
|
|
57 |
ON (l.itemId = i.itemId AND l.purchaseOrder_id = po.id)
|
|
|
58 |
JOIN supplier s
|
|
|
59 |
ON (s.id = po.supplierId)
|
| 6494 |
amar.kumar |
60 |
JOIN invoice inv
|
| 7453 |
amar.kumar |
61 |
ON (inv.invoiceNumber = p.invoiceNumber AND inv.supplierId = po.supplierId)
|
| 5372 |
mandeep.dh |
62 |
WHERE po.createdAt BETWEEN #{startDate} AND #{endDate}
|
| 6364 |
rajveer |
63 |
AND lastScanType != 'DOA_REPLACED'
|
| 6362 |
rajveer |
64 |
GROUP BY p.purchaseOrder_id, p.id, i.itemId
|
|
|
65 |
ORDER BY p.purchaseOrder_id, p.id, i.itemId
|
| 5372 |
mandeep.dh |
66 |
</select>
|
| 5496 |
mandeep.dh |
67 |
|
| 7210 |
amar.kumar |
68 |
<select id="getPurchaseScansByGrnDate" parameterType="map" resultType="detailedPurchaseScan">
|
|
|
69 |
SELECT p.purchaseOrder_id AS purchaseOrderId, 1000 * UNIX_TIMESTAMP(po.createdAt) AS poCreatedAt, s.name AS supplierName,
|
|
|
70 |
p.invoiceNumber AS invoiceNumbers, inv.receivedFrom AS receivedBy, i.itemId,brand, modelName, modelNumber, color,
|
| 8580 |
amar.kumar |
71 |
unitPrice, SUM(initialQuantity) AS quantity, 1000 * UNIX_TIMESTAMP(receivedOn) as purchasedAt, p.id as purchaseId,
|
|
|
72 |
nlc, po.warehouseId
|
| 7210 |
amar.kumar |
73 |
FROM purchase p
|
|
|
74 |
JOIN purchaseorder po
|
|
|
75 |
ON (po.id = p.purchaseOrder_id)
|
|
|
76 |
JOIN inventoryItem i
|
|
|
77 |
ON (p.id = i.purchaseId)
|
|
|
78 |
JOIN lineitem l
|
|
|
79 |
ON (l.itemId = i.itemId AND l.purchaseOrder_id = po.id)
|
|
|
80 |
JOIN supplier s
|
|
|
81 |
ON (s.id = po.supplierId)
|
|
|
82 |
JOIN invoice inv
|
| 7224 |
amar.kumar |
83 |
ON (inv.invoiceNumber = p.invoiceNumber AND inv.supplierId = po.supplierId)
|
| 7216 |
amar.kumar |
84 |
WHERE p.receivedOn BETWEEN #{startDate} AND #{endDate}
|
|
|
85 |
AND inv.date < #{endDate}
|
| 7224 |
amar.kumar |
86 |
AND inv.date > ADDDATE(#{startDate},-1)
|
| 7210 |
amar.kumar |
87 |
AND lastScanType != 'DOA_REPLACED'
|
| 7224 |
amar.kumar |
88 |
GROUP BY p.purchaseOrder_id, p.id, i.itemId
|
|
|
89 |
ORDER BY p.purchaseOrder_id, p.id, i.itemId
|
| 7210 |
amar.kumar |
90 |
</select>
|
|
|
91 |
|
| 5496 |
mandeep.dh |
92 |
<select id="fetchMismatchScansPerInvoiceNumber" parameterType="java.util.Date" resultType="invoiceScan" >
|
|
|
93 |
SELECT i.invoiceNumber, i.numItems, sum(initialQuantity) as scannedQuantity, i.date, s.name as supplierName
|
|
|
94 |
FROM invoice i
|
|
|
95 |
JOIN supplier s
|
| 7090 |
amar.kumar |
96 |
ON (i.supplierId = s.id)
|
| 5496 |
mandeep.dh |
97 |
LEFT JOIN purchase p
|
|
|
98 |
ON (p.invoiceNumber = i.invoiceNumber)
|
| 7089 |
amar.kumar |
99 |
LEFT JOIN inventoryItem ii
|
|
|
100 |
ON (ii.purchaseId = p.id)
|
|
|
101 |
JOIN scanNew sn
|
|
|
102 |
ON (sn.inventoryItemId = ii.id)
|
| 5496 |
mandeep.dh |
103 |
WHERE i.date = #{date}
|
| 7089 |
amar.kumar |
104 |
AND sn.scannedAt between #{date} and ADDDATE(#{date},1)
|
|
|
105 |
AND sn.type = 'PURCHASE'
|
|
|
106 |
AND s.id !=1
|
| 5496 |
mandeep.dh |
107 |
GROUP BY i.invoiceNumber, i.numItems
|
|
|
108 |
HAVING SUM(initialQuantity) != i.numItems
|
|
|
109 |
</select>
|
| 5372 |
mandeep.dh |
110 |
|
| 5711 |
mandeep.dh |
111 |
<select id="getInventoryAge" resultType="inventoryAge">
|
|
|
112 |
SELECT t.itemId, brand, modelName, modelNumber, color,
|
|
|
113 |
SUM((age < 1) * currentQuantity) AS freshCount,
|
| 5768 |
mandeep.dh |
114 |
SUM((age >= 1 and age < 2) * currentQuantity) AS oneToTwoCount,
|
|
|
115 |
SUM((age >= 2 and age < 3) * currentQuantity) AS twoToThreeCount,
|
|
|
116 |
SUM((age >= 3 and age < 4) * currentQuantity) AS threeToFourCount,
|
|
|
117 |
SUM((age >= 4) * currentQuantity) as fourPlusCount,
|
|
|
118 |
SUM((age >= 1) * currentQuantity) as onePlusCount,
|
|
|
119 |
SUM((age >= 1) * unitPrice) as onePlusCost,
|
|
|
120 |
SUM(currentQuantity) as zeroPlusCount,
|
|
|
121 |
SUM(l.unitPrice) as zeroPlusCost,
|
|
|
122 |
l.productGroup as category
|
| 5711 |
mandeep.dh |
123 |
FROM (SELECT ii.id, ii.itemId, ii.currentQuantity, ii.purchaseId,
|
| 7838 |
amar.kumar |
124 |
DATEDIFF(now(), MIN(s.scannedAt)) / 7 as age
|
| 5711 |
mandeep.dh |
125 |
FROM inventoryItem ii
|
|
|
126 |
JOIN scanNew s
|
|
|
127 |
ON (s.inventoryItemId = ii.id)
|
|
|
128 |
WHERE ii.lastScanType IN ('PURCHASE', 'SALE_RET')
|
| 7802 |
amar.kumar |
129 |
AND ii.physicalWarehouseId !=16
|
| 5711 |
mandeep.dh |
130 |
GROUP BY ii.id, ii.itemId, ii.currentQuantity) t
|
|
|
131 |
JOIN purchase p
|
|
|
132 |
ON (p.id = t.purchaseId)
|
|
|
133 |
JOIN lineitem l
|
|
|
134 |
ON (l.purchaseOrder_id = p.purchaseOrder_id AND l.itemId = t.itemId)
|
|
|
135 |
GROUP BY t.itemId
|
|
|
136 |
HAVING SUM(currentQuantity) != 0
|
|
|
137 |
</select>
|
| 6322 |
amar.kumar |
138 |
|
| 7089 |
amar.kumar |
139 |
<!--select id="inventoryAgeOnePlus" resultType="detailedInventoryAge">
|
|
|
140 |
SELECT t.itemId, brand, modelName, modelNumber, color, scannedAt, i.warehouseId
|
|
|
141 |
SUM((age >= 1) * currentQuantity) AS onePlusCount,
|
|
|
142 |
SUM((age >= 1) * unitPrice) as onePlusCost,
|
|
|
143 |
l.productGroup as category
|
|
|
144 |
FROM (SELECT ii.id, ii.itemId, ii.currentQuantity, ii.purchaseId, MIN(s.scannedAt)
|
|
|
145 |
DATEDIFF(now(), MAX(s.scannedAt)) / 7 as age
|
|
|
146 |
FROM inventoryItem ii
|
|
|
147 |
JOIN scanNew s
|
|
|
148 |
ON (s.inventoryItemId = ii.id)
|
|
|
149 |
WHERE ii.lastScanType IN ('PURCHASE', 'SALE_RET')
|
|
|
150 |
GROUP BY ii.id, ii.itemId, ii.currentQuantity) t
|
|
|
151 |
JOIN purchase p
|
|
|
152 |
ON (p.id = t.purchaseId)
|
|
|
153 |
JOIN lineitem l
|
|
|
154 |
ON (l.purchaseOrder_id = p.purchaseOrder_id AND l.itemId = t.itemId)
|
|
|
155 |
GROUP BY t.itemId, i.warehouseId
|
|
|
156 |
HAVING SUM(currentQuantity) != 0
|
|
|
157 |
</select-->
|
|
|
158 |
|
|
|
159 |
|
|
|
160 |
|
| 6322 |
amar.kumar |
161 |
<select id = "getScansForItem" parameterType = "map" resultType = "scan">
|
|
|
162 |
SELECT s.id, s.inventoryItemId, s.warehouseId, s.type, s.scannedAt,
|
|
|
163 |
s.quantity, s.orderId from scanNew s JOIN inventoryItem i
|
|
|
164 |
ON
|
|
|
165 |
s.inventoryItemId = i.id
|
|
|
166 |
AND
|
| 6414 |
amar.kumar |
167 |
i.itemId = #{itemId}
|
| 6322 |
amar.kumar |
168 |
AND
|
|
|
169 |
s.scannedAt BETWEEN #{fromDate} AND #{toDate};
|
|
|
170 |
</select>
|
|
|
171 |
|
| 6558 |
amar.kumar |
172 |
<insert id="genericScan" parameterType="scan" useGeneratedKeys="true" keyProperty="id">
|
| 6467 |
amar.kumar |
173 |
INSERT INTO scanNew
|
| 7410 |
amar.kumar |
174 |
(inventoryItemId, warehouseId, type, scannedAt, quantity, orderId, transferLotId, remarks)
|
| 6467 |
amar.kumar |
175 |
VALUES
|
| 7410 |
amar.kumar |
176 |
(#{inventoryItemId}, #{warehouseId}, #{type}, NOW(), #{quantity}, #{orderId}, #{transferLotId}, #{remarks})
|
| 6467 |
amar.kumar |
177 |
</insert>
|
|
|
178 |
|
| 6558 |
amar.kumar |
179 |
<select id = "getCurrentSerializedInventoryByScans" resultType = "inventoryAvailability">
|
|
|
180 |
SELECT x.itemId, ci.brand, ci.model_name as modelName,
|
| 6630 |
amar.kumar |
181 |
ci.model_number as modelNumber, ci.color as color, (x.inx-if(y.outx is null,0,y.outx)) as quantity
|
| 6558 |
amar.kumar |
182 |
from
|
|
|
183 |
(select i.itemId, count(*) as inx from scanNew s
|
|
|
184 |
JOIN inventoryItem i ON (i.id = s.inventoryItemId)
|
|
|
185 |
JOIN catalog.item c ON i.itemId = c.id
|
| 7678 |
amar.kumar |
186 |
where s.type in ('PURCHASE','SALE_RET', 'MARKED_GOOD','WAREHOUSE_TRANSFER_IN') and c.type = 'SERIALIZED'
|
| 7676 |
amar.kumar |
187 |
and i.physicalWarehouseId = #{physicalWarehouseId}
|
| 6558 |
amar.kumar |
188 |
group by i.itemId ) as x
|
| 6630 |
amar.kumar |
189 |
LEFT JOIN
|
| 6558 |
amar.kumar |
190 |
(select i.itemId, count(*) as outx from scanNew s
|
|
|
191 |
JOIN inventoryItem i on i.id = s.inventoryItemId
|
|
|
192 |
JOIN catalog.item c ON i.itemId = c.id
|
| 7678 |
amar.kumar |
193 |
where s.type in ('SALE','LOST_IN_WAREHOUSE','PURCHASE_RETURN','MARKED_USED','MARKED_BAD','WAREHOUSE_TRANSFER_OUT') and c.type = 'SERIALIZED'
|
| 7676 |
amar.kumar |
194 |
and i.physicalWarehouseId = #{physicalWarehouseId}
|
| 6558 |
amar.kumar |
195 |
group by i.itemId) as y
|
|
|
196 |
ON x.itemId = y.itemId
|
|
|
197 |
JOIN catalog.item ci ON ci.id = x.itemId
|
| 6630 |
amar.kumar |
198 |
where ci.type = 'SERIALIZED' having quantity>0
|
| 6558 |
amar.kumar |
199 |
</select>
|
| 6762 |
amar.kumar |
200 |
|
|
|
201 |
<select id = "getHistoricSerializedInventoryByScans" resultType = "inventoryAvailability" parameterType = "date">
|
|
|
202 |
SELECT x.itemId, ci.brand, ci.model_name as modelName,
|
|
|
203 |
ci.model_number as modelNumber, ci.color as color, (x.inx-if(y.outx is null,0,y.outx)) as quantity
|
|
|
204 |
from
|
|
|
205 |
(select i.itemId, count(*) as inx from scanNew s
|
|
|
206 |
JOIN inventoryItem i ON (i.id = s.inventoryItemId)
|
|
|
207 |
JOIN catalog.item c ON i.itemId = c.id
|
| 7678 |
amar.kumar |
208 |
where s.type in ('PURCHASE','SALE_RET', 'MARKED_GOOD','WAREHOUSE_TRANSFER_IN') and c.type = 'SERIALIZED'
|
| 6762 |
amar.kumar |
209 |
and s.scannedAt < #{date}
|
|
|
210 |
group by i.itemId ) as x
|
|
|
211 |
LEFT JOIN
|
|
|
212 |
(select i.itemId, count(*) as outx from scanNew s
|
|
|
213 |
JOIN inventoryItem i on i.id = s.inventoryItemId
|
|
|
214 |
JOIN catalog.item c ON i.itemId = c.id
|
| 7678 |
amar.kumar |
215 |
where s.type in ('SALE','LOST_IN_WAREHOUSE','PURCHASE_RETURN','MARKED_USED','MARKED_BAD','WAREHOUSE_TRANSFER_OUT') and c.type = 'SERIALIZED'
|
| 6762 |
amar.kumar |
216 |
and s.scannedAt < #{date}
|
|
|
217 |
group by i.itemId) as y
|
|
|
218 |
ON x.itemId = y.itemId
|
|
|
219 |
JOIN catalog.item ci ON ci.id = x.itemId
|
|
|
220 |
where ci.type = 'SERIALIZED' having quantity>0
|
|
|
221 |
</select>
|
|
|
222 |
|
| 6558 |
amar.kumar |
223 |
|
| 6630 |
amar.kumar |
224 |
<select id = "getCurrentNonSerializedInventoryByScans" resultType = "inventoryAvailability">
|
|
|
225 |
SELECT x.itemId, ci.brand, ci.model_name as modelName,
|
|
|
226 |
ci.model_number as modelNumber, ci.color as color, (x.inx-if(y.outx is null,0,y.outx)) as quantity
|
|
|
227 |
from
|
|
|
228 |
(select i.itemId, sum(quantity) as inx from scanNew s
|
|
|
229 |
JOIN inventoryItem i ON (i.id = s.inventoryItemId)
|
|
|
230 |
JOIN catalog.item c ON i.itemId = c.id
|
| 7678 |
amar.kumar |
231 |
where s.type in ('PURCHASE','SALE_RET', 'MARKED_GOOD','WAREHOUSE_TRANSFER_IN') and c.type = 'NON_SERIALIZED'
|
| 7676 |
amar.kumar |
232 |
and i.physicalWarehouseId = #{physicalWarehouseId}
|
| 6630 |
amar.kumar |
233 |
group by i.itemId ) as x
|
|
|
234 |
LEFT JOIN
|
|
|
235 |
(select i.itemId, sum(quantity) as outx from scanNew s
|
|
|
236 |
JOIN inventoryItem i on i.id = s.inventoryItemId
|
|
|
237 |
JOIN catalog.item c ON i.itemId = c.id
|
| 7678 |
amar.kumar |
238 |
where s.type in ('SALE','LOST_IN_WAREHOUSE','PURCHASE_RETURN','MARKED_USED','MARKED_BAD','WAREHOUSE_TRANSFER_OUT') and c.type = 'NON_SERIALIZED'
|
| 7676 |
amar.kumar |
239 |
and i.physicalWarehouseId = #{physicalWarehouseId}
|
| 6630 |
amar.kumar |
240 |
group by i.itemId) as y
|
|
|
241 |
ON x.itemId = y.itemId
|
|
|
242 |
JOIN catalog.item ci ON ci.id = x.itemId
|
|
|
243 |
where ci.type = 'NON_SERIALIZED' having quantity>0
|
|
|
244 |
</select>
|
| 6762 |
amar.kumar |
245 |
|
|
|
246 |
<select id = "getHistoricNonSerializedInventoryByScans" resultType = "inventoryAvailability" parameterType = "date">
|
|
|
247 |
SELECT x.itemId, ci.brand, ci.model_name as modelName,
|
|
|
248 |
ci.model_number as modelNumber, ci.color as color, (x.inx-if(y.outx is null,0,y.outx)) as quantity
|
|
|
249 |
from
|
| 7410 |
amar.kumar |
250 |
(SELECT i.itemId, sum(quantity) as inx from scanNew s
|
| 6762 |
amar.kumar |
251 |
JOIN inventoryItem i ON (i.id = s.inventoryItemId)
|
|
|
252 |
JOIN catalog.item c ON i.itemId = c.id
|
| 7678 |
amar.kumar |
253 |
where s.type in ('PURCHASE','SALE_RET', 'MARKED_GOOD','WAREHOUSE_TRANSFER_IN') and c.type = 'NON_SERIALIZED'
|
| 6762 |
amar.kumar |
254 |
and s.scannedAt < #{date}
|
|
|
255 |
group by i.itemId ) as x
|
|
|
256 |
LEFT JOIN
|
| 7410 |
amar.kumar |
257 |
(SELECT i.itemId, sum(quantity) as outx from scanNew s
|
| 6762 |
amar.kumar |
258 |
JOIN inventoryItem i on i.id = s.inventoryItemId
|
|
|
259 |
JOIN catalog.item c ON i.itemId = c.id
|
| 7678 |
amar.kumar |
260 |
where s.type in ('SALE','LOST_IN_WAREHOUSE','PURCHASE_RETURN','MARKED_USED','MARKED_BAD','WAREHOUSE_TRANSFER_OUT') and c.type = 'NON_SERIALIZED'
|
| 6762 |
amar.kumar |
261 |
and s.scannedAt < #{date}
|
|
|
262 |
group by i.itemId) as y
|
|
|
263 |
ON x.itemId = y.itemId
|
|
|
264 |
JOIN catalog.item ci ON ci.id = x.itemId
|
|
|
265 |
where ci.type = 'NON_SERIALIZED' having quantity>0
|
|
|
266 |
</select>
|
|
|
267 |
|
| 6880 |
amar.kumar |
268 |
<select id = "getMovementSerializedInventoryByScans" resultType = "inventoryMovement" parameterType = "map">
|
| 7410 |
amar.kumar |
269 |
SELECT itemId, brand, model_name as modelName, model_number as modelNumber, color, s.type, count(*) as quantity
|
| 6762 |
amar.kumar |
270 |
FROM inventoryItem i JOIN scanNew s ON i.id = s.inventoryItemId
|
|
|
271 |
LEFT JOIN catalog.item c ON i.itemId = c.id
|
| 6963 |
amar.kumar |
272 |
where s.scannedAt between #{startDate} and #{endDate} and c.type = 'SERIALIZED'
|
|
|
273 |
and i.currentWarehouseId not in (1,2,6,9)
|
| 6762 |
amar.kumar |
274 |
group by itemId, s.type
|
|
|
275 |
</select>
|
|
|
276 |
|
|
|
277 |
<select id = "getMovementNonSerializedInventoryByScans" resultType = "inventoryMovement" parameterType = "map">
|
| 7410 |
amar.kumar |
278 |
SELECT itemId, brand, model_name as modelName, model_number as modelNumber, color, s.type, sum(quantity) as quantity
|
| 6762 |
amar.kumar |
279 |
FROM inventoryItem i JOIN scanNew s ON i.id = s.inventoryItemId
|
|
|
280 |
LEFT JOIN catalog.item c ON i.itemId = c.id
|
| 6963 |
amar.kumar |
281 |
where s.scannedAt between #{startDate} and #{endDate} and c.type = 'NON_SERIALIZED'
|
|
|
282 |
and i.currentWarehouseId not in (1,2,6,9)
|
| 6762 |
amar.kumar |
283 |
group by itemId, s.type
|
| 6880 |
amar.kumar |
284 |
</select>
|
| 7216 |
amar.kumar |
285 |
|
|
|
286 |
<select id = "getCompleteMovementSerializedInventoryByScans" resultType = "inventoryMovement" parameterType = "map">
|
| 7410 |
amar.kumar |
287 |
SELECT itemId, brand, model_name as modelName, model_number as modelNumber, color, s.type, count(*) as quantity
|
| 7216 |
amar.kumar |
288 |
FROM inventoryItem i JOIN scanNew s ON i.id = s.inventoryItemId
|
|
|
289 |
LEFT JOIN catalog.item c ON i.itemId = c.id
|
|
|
290 |
where s.scannedAt between #{startDate} and #{endDate} and c.type = 'SERIALIZED'
|
|
|
291 |
group by itemId, s.type
|
|
|
292 |
</select>
|
|
|
293 |
|
|
|
294 |
<select id = "getCompleteMovementNonSerializedInventoryByScans" resultType = "inventoryMovement" parameterType = "map">
|
| 7410 |
amar.kumar |
295 |
SELECT itemId, brand, model_name as modelName, model_number as modelNumber, color, s.type, sum(quantity) as quantity
|
| 7216 |
amar.kumar |
296 |
FROM inventoryItem i JOIN scanNew s ON i.id = s.inventoryItemId
|
|
|
297 |
LEFT JOIN catalog.item c ON i.itemId = c.id
|
|
|
298 |
where s.scannedAt between #{startDate} and #{endDate} and c.type = 'NON_SERIALIZED'
|
|
|
299 |
group by itemId, s.type
|
|
|
300 |
</select>
|
| 6630 |
amar.kumar |
301 |
|
| 7410 |
amar.kumar |
302 |
<select id = "getTransferrableWarehousesFromWarehouse" resultType = "java.lang.Long" parameterType = "java.lang.Long">
|
|
|
303 |
SELECT toWarehouseId
|
|
|
304 |
FROM possibleWarehouseMovement
|
|
|
305 |
WHERE fromWarehouseId = #{warehouseId}
|
|
|
306 |
</select>
|
|
|
307 |
|
| 7957 |
amar.kumar |
308 |
<select id = "getHistoricBadInventoryByScans" resultType = "inventoryAvailability" parameterType = "date">
|
|
|
309 |
SELECT x.itemId, ci.brand, ci.model_name as modelName, ci.model_number as modelNumber,
|
|
|
310 |
ci.color as color, (x.inx-if(y.outx is null,0,y.outx)) as quantity
|
|
|
311 |
FROM
|
|
|
312 |
(SELECT i.itemId, count(*) as inx FROM scanNew s JOIN inventoryItem i ON
|
|
|
313 |
(i.id = s.inventoryItemId) JOIN catalog.item c ON i.itemId = c.id
|
|
|
314 |
where s.type in ('DOA_IN', 'SALE_RET_UNUSABLE') and
|
|
|
315 |
s.scannedAt < #{date} group by i.itemId ) as x
|
|
|
316 |
LEFT JOIN
|
|
|
317 |
(SELECT i.itemId, count(*) as outx FROM scanNew s JOIN inventoryItem i ON
|
|
|
318 |
i.id = s.inventoryItemId JOIN catalog.item c ON i.itemId = c.id WHERE
|
|
|
319 |
s.type in ('DOA_OUT') and s.scannedAt < #{date} group by i.itemId) as y
|
|
|
320 |
ON x.itemId = y.itemId
|
|
|
321 |
JOIN catalog.item ci ON ci.id = x.itemId
|
|
|
322 |
having quantity>0;
|
|
|
323 |
</select>
|
| 7410 |
amar.kumar |
324 |
|
|
|
325 |
<select id = "getScansForTransferLot" resultType = "scan" parameterType = "java.lang.Long">
|
|
|
326 |
SELECT *
|
|
|
327 |
FROM scanNew
|
|
|
328 |
WHERE transferLotId = #{id}
|
|
|
329 |
AND type = 'WAREHOUSE_TRANSFER_OUT'
|
|
|
330 |
</select>
|
|
|
331 |
|
| 4500 |
mandeep.dh |
332 |
</mapper>
|