@things-factory/worksheet-base 4.1.40 → 4.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist-server/controllers/inbound/unloading-worksheet-controller.js +2 -0
- package/dist-server/controllers/inbound/unloading-worksheet-controller.js.map +1 -1
- package/dist-server/controllers/outbound/packing-worksheet-controller.js +166 -8
- package/dist-server/controllers/outbound/packing-worksheet-controller.js.map +1 -1
- package/dist-server/controllers/outbound/picking-worksheet-controller.js +22 -22
- package/dist-server/controllers/outbound/picking-worksheet-controller.js.map +1 -1
- package/dist-server/controllers/outbound/sorting-worksheet-controller.js +110 -3
- package/dist-server/controllers/outbound/sorting-worksheet-controller.js.map +1 -1
- package/dist-server/controllers/render-grn.js +2 -1
- package/dist-server/controllers/render-grn.js.map +1 -1
- package/dist-server/controllers/render-orientage-do.js +0 -31
- package/dist-server/controllers/render-orientage-do.js.map +1 -1
- package/dist-server/controllers/render-orientage-grn.js +1 -21
- package/dist-server/controllers/render-orientage-grn.js.map +1 -1
- package/dist-server/controllers/render-ro-do.js +2 -1
- package/dist-server/controllers/render-ro-do.js.map +1 -1
- package/dist-server/controllers/worksheet-controller.js +2 -1
- package/dist-server/controllers/worksheet-controller.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/find-release-orders-by-task-no.js +30 -1
- package/dist-server/graphql/resolvers/worksheet/find-release-orders-by-task-no.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/inventories-by-pallet.js +3 -0
- package/dist-server/graphql/resolvers/worksheet/inventories-by-pallet.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/packing/index.js +2 -1
- package/dist-server/graphql/resolvers/worksheet/packing/index.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/packing/packing.js +4 -4
- package/dist-server/graphql/resolvers/worksheet/packing/packing.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/packing/scan-product-packing.js +4 -4
- package/dist-server/graphql/resolvers/worksheet/packing/scan-product-packing.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/packing/undo-serial-number-packing.js +15 -0
- package/dist-server/graphql/resolvers/worksheet/packing/undo-serial-number-packing.js.map +1 -0
- package/dist-server/graphql/resolvers/worksheet/packing-worksheet.js +152 -133
- package/dist-server/graphql/resolvers/worksheet/packing-worksheet.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/picking/assign-picking-worker.js +3 -2
- package/dist-server/graphql/resolvers/worksheet/picking/assign-picking-worker.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/picking/picking-assignment-status-by-user.js +3 -3
- package/dist-server/graphql/resolvers/worksheet/picking/picking-assignment-status-by-user.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/sorting/scan-product-sorting.js +4 -4
- package/dist-server/graphql/resolvers/worksheet/sorting/scan-product-sorting.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/sorting/sorting-product.js +4 -4
- package/dist-server/graphql/resolvers/worksheet/sorting/sorting-product.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/sorting-worksheet.js +6 -0
- package/dist-server/graphql/resolvers/worksheet/sorting-worksheet.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet-detail/generate-batch-picking-worksheet-details-by-bulk.js +4 -5
- package/dist-server/graphql/resolvers/worksheet-detail/generate-batch-picking-worksheet-details-by-bulk.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet-detail/generate-picking-worksheet-details.js +4 -2
- package/dist-server/graphql/resolvers/worksheet-detail/generate-picking-worksheet-details.js.map +1 -1
- package/dist-server/graphql/types/worksheet/find-release-orders-by-task-no.js +11 -0
- package/dist-server/graphql/types/worksheet/find-release-orders-by-task-no.js.map +1 -0
- package/dist-server/graphql/types/worksheet/index.js +13 -2
- package/dist-server/graphql/types/worksheet/index.js.map +1 -1
- package/dist-server/graphql/types/worksheet/worksheet-detail-info.js +2 -0
- package/dist-server/graphql/types/worksheet/worksheet-detail-info.js.map +1 -1
- package/dist-server/graphql/types/worksheet-detail/index.js +0 -2
- package/dist-server/graphql/types/worksheet-detail/index.js.map +1 -1
- package/dist-server/utils/inventory-util.js +14 -25
- package/dist-server/utils/inventory-util.js.map +1 -1
- package/package.json +9 -9
- package/server/controllers/inbound/unloading-worksheet-controller.ts +2 -0
- package/server/controllers/outbound/packing-worksheet-controller.ts +217 -11
- package/server/controllers/outbound/picking-worksheet-controller.ts +23 -24
- package/server/controllers/outbound/sorting-worksheet-controller.ts +149 -4
- package/server/controllers/render-grn.ts +5 -5
- package/server/controllers/render-orientage-do.ts +12 -61
- package/server/controllers/render-orientage-grn.ts +13 -44
- package/server/controllers/render-ro-do.ts +34 -33
- package/server/controllers/worksheet-controller.ts +2 -1
- package/server/graphql/resolvers/worksheet/find-release-orders-by-task-no.ts +35 -2
- package/server/graphql/resolvers/worksheet/inventories-by-pallet.ts +2 -0
- package/server/graphql/resolvers/worksheet/packing/index.ts +3 -1
- package/server/graphql/resolvers/worksheet/packing/packing.ts +5 -4
- package/server/graphql/resolvers/worksheet/packing/scan-product-packing.ts +9 -4
- package/server/graphql/resolvers/worksheet/packing/undo-serial-number-packing.ts +24 -0
- package/server/graphql/resolvers/worksheet/packing-worksheet.ts +166 -144
- package/server/graphql/resolvers/worksheet/picking/assign-picking-worker.ts +3 -2
- package/server/graphql/resolvers/worksheet/picking/picking-assignment-status-by-user.ts +4 -4
- package/server/graphql/resolvers/worksheet/sorting/scan-product-sorting.ts +5 -4
- package/server/graphql/resolvers/worksheet/sorting/sorting-product.ts +5 -4
- package/server/graphql/resolvers/worksheet/sorting-worksheet.ts +6 -0
- package/server/graphql/resolvers/worksheet-detail/generate-batch-picking-worksheet-details-by-bulk.ts +10 -12
- package/server/graphql/resolvers/worksheet-detail/generate-picking-worksheet-details.ts +4 -2
- package/server/graphql/types/worksheet/find-release-orders-by-task-no.ts +8 -0
- package/server/graphql/types/worksheet/index.ts +13 -2
- package/server/graphql/types/worksheet/worksheet-detail-info.ts +2 -0
- package/server/graphql/types/worksheet-detail/index.ts +0 -2
- package/server/utils/inventory-util.ts +15 -23
|
@@ -20,164 +20,186 @@ import { fetchExecutingWorksheet } from '../../../utils'
|
|
|
20
20
|
|
|
21
21
|
export const packingWorksheetResolver = {
|
|
22
22
|
async packingWorksheet(_: any, { releaseGoodNo }, context: any) {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
// Find Release Order based on Bin
|
|
33
|
-
if (!releaseGood) {
|
|
34
|
-
const binLocation: Location = await tx.getRepository(Location).findOne({
|
|
35
|
-
where: { domain, name: releaseGoodNo }
|
|
23
|
+
try {
|
|
24
|
+
const { tx, domain, user }: { tx: EntityManager; domain: Domain; user: User } = context.state
|
|
25
|
+
let releaseGood: ReleaseGood = await tx.getRepository(ReleaseGood).findOne({
|
|
26
|
+
where: {
|
|
27
|
+
domain,
|
|
28
|
+
name: releaseGoodNo
|
|
29
|
+
},
|
|
30
|
+
relations: ['bizplace', 'bizplace.domain']
|
|
36
31
|
})
|
|
37
32
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
.
|
|
41
|
-
|
|
42
|
-
.innerJoinAndSelect('releaseGood.bizplace', 'bizplace')
|
|
43
|
-
.innerJoinAndSelect('bizplace.domain', 'domain')
|
|
44
|
-
.where('orderInventory.domain_id = :domainId', { domainId: domain.id })
|
|
45
|
-
.andWhere('orderInventory.status IN (:...orderInventoryStatus)', {
|
|
46
|
-
orderInventoryStatus: [ORDER_INVENTORY_STATUS.PACKING, ORDER_INVENTORY_STATUS.PACKED]
|
|
33
|
+
// Find Release Order based on Bin
|
|
34
|
+
if (!releaseGood) {
|
|
35
|
+
const binLocation: Location = await tx.getRepository(Location).findOne({
|
|
36
|
+
where: { domain, name: releaseGoodNo }
|
|
47
37
|
})
|
|
48
|
-
.andWhere('orderInventory.bin_location_id = :locationId', { locationId: binLocation.id })
|
|
49
|
-
.andWhere('releaseGood.status = :status', { status: ORDER_STATUS.PACKING })
|
|
50
38
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
39
|
+
if (binLocation) {
|
|
40
|
+
const qb: SelectQueryBuilder<OrderInventory> = tx
|
|
41
|
+
.getRepository(OrderInventory)
|
|
42
|
+
.createQueryBuilder('orderInventory')
|
|
43
|
+
|
|
44
|
+
qb.innerJoinAndSelect('orderInventory.releaseGood', 'releaseGood')
|
|
45
|
+
.innerJoinAndSelect('releaseGood.bizplace', 'bizplace')
|
|
46
|
+
.innerJoinAndSelect('bizplace.domain', 'domain')
|
|
47
|
+
.innerJoinAndSelect(
|
|
48
|
+
'worksheets',
|
|
49
|
+
'ws',
|
|
50
|
+
`orderInventory.release_good_id = ws.release_good_id AND ws.type = 'PACKING' AND ws.status = 'EXECUTING'`
|
|
51
|
+
)
|
|
52
|
+
.where('orderInventory.domain_id = :domainId', { domainId: domain.id })
|
|
53
|
+
.andWhere('orderInventory.status IN (:...orderInventoryStatus)', {
|
|
54
|
+
orderInventoryStatus: [
|
|
55
|
+
ORDER_INVENTORY_STATUS.READY_TO_PACK,
|
|
56
|
+
ORDER_INVENTORY_STATUS.PACKING,
|
|
57
|
+
ORDER_INVENTORY_STATUS.PACKED
|
|
58
|
+
]
|
|
59
|
+
})
|
|
60
|
+
.andWhere('orderInventory.bin_location_id = :locationId', { locationId: binLocation.id })
|
|
61
|
+
.andWhere('releaseGood.status IN (:...status)', {
|
|
62
|
+
status: [ORDER_STATUS.READY_TO_PACK, ORDER_STATUS.PACKING]
|
|
63
|
+
})
|
|
64
|
+
|
|
65
|
+
const orderInventoryByBin = await qb.getOne()
|
|
66
|
+
if (orderInventoryByBin?.releaseGood) {
|
|
67
|
+
releaseGoodNo = orderInventoryByBin.releaseGood.name
|
|
68
|
+
releaseGood = orderInventoryByBin.releaseGood
|
|
69
|
+
} else {
|
|
70
|
+
throw new Error(`Bin do not have any existing order.`)
|
|
71
|
+
}
|
|
72
|
+
}
|
|
55
73
|
}
|
|
56
|
-
}
|
|
57
74
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
const worksheet: Worksheet = await fetchExecutingWorksheet(
|
|
61
|
-
domain,
|
|
62
|
-
releaseGood.bizplace,
|
|
63
|
-
[
|
|
64
|
-
'bizplace',
|
|
65
|
-
'bizplace.domain',
|
|
66
|
-
'releaseGood',
|
|
67
|
-
'releaseGood.domain',
|
|
68
|
-
'worksheetDetails',
|
|
69
|
-
'worksheetDetails.targetInventory',
|
|
70
|
-
'worksheetDetails.targetInventory.binLocation',
|
|
71
|
-
'worksheetDetails.targetInventory.inventory',
|
|
72
|
-
'worksheetDetails.targetInventory.inventory.location',
|
|
73
|
-
'worksheetDetails.targetInventory.inventory.product',
|
|
74
|
-
'worksheetDetails.targetInventory.inventory.product.productDetails',
|
|
75
|
-
'worksheetDetails.toLocation'
|
|
76
|
-
],
|
|
77
|
-
WORKSHEET_TYPE.PACKING,
|
|
78
|
-
releaseGood
|
|
79
|
-
)
|
|
80
|
-
|
|
81
|
-
let marketplaceOrder: MarketplaceOrder
|
|
82
|
-
let marketplaceOrderItems: MarketplaceOrderItem[] = []
|
|
83
|
-
let marketplaceStore
|
|
84
|
-
let trackingNo: string
|
|
85
|
-
let shippingProvider: string
|
|
86
|
-
let marketplaceStatus: string
|
|
87
|
-
|
|
88
|
-
if (releaseGood.type === 'b2c') {
|
|
89
|
-
const sellercraft: Sellercraft = await tx.getRepository(Sellercraft).findOne({
|
|
90
|
-
domain: worksheet.bizplace.domain,
|
|
91
|
-
status: SellercraftStatus.ACTIVE
|
|
92
|
-
})
|
|
75
|
+
if (!releaseGood) throw new Error(`Release good do not exist.`)
|
|
93
76
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
77
|
+
const worksheet: Worksheet = await fetchExecutingWorksheet(
|
|
78
|
+
domain,
|
|
79
|
+
releaseGood.bizplace,
|
|
80
|
+
[
|
|
81
|
+
'bizplace',
|
|
82
|
+
'bizplace.domain',
|
|
83
|
+
'releaseGood',
|
|
84
|
+
'releaseGood.domain',
|
|
85
|
+
'worksheetDetails',
|
|
86
|
+
'worksheetDetails.targetInventory',
|
|
87
|
+
'worksheetDetails.targetInventory.binLocation',
|
|
88
|
+
'worksheetDetails.targetInventory.inventory',
|
|
89
|
+
'worksheetDetails.targetInventory.inventory.location',
|
|
90
|
+
'worksheetDetails.targetInventory.inventory.product',
|
|
91
|
+
'worksheetDetails.targetInventory.inventory.product.productDetails',
|
|
92
|
+
'worksheetDetails.toLocation'
|
|
93
|
+
],
|
|
94
|
+
WORKSHEET_TYPE.PACKING,
|
|
95
|
+
releaseGood
|
|
96
|
+
)
|
|
97
|
+
|
|
98
|
+
let marketplaceOrder: MarketplaceOrder
|
|
99
|
+
let marketplaceOrderItems: MarketplaceOrderItem[] = []
|
|
100
|
+
let marketplaceStore
|
|
101
|
+
let trackingNo: string
|
|
102
|
+
let shippingProvider: string
|
|
103
|
+
let marketplaceStatus: string
|
|
104
|
+
|
|
105
|
+
if (releaseGood.type === 'b2c') {
|
|
106
|
+
const sellercraft: Sellercraft = await tx.getRepository(Sellercraft).findOne({
|
|
107
|
+
domain: worksheet.bizplace.domain,
|
|
108
|
+
status: SellercraftStatus.ACTIVE
|
|
112
109
|
})
|
|
113
110
|
|
|
114
|
-
if (
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
})
|
|
111
|
+
if (sellercraft) {
|
|
112
|
+
if (!releaseGood?.airwayBill) {
|
|
113
|
+
const sellercraftCtrl: SellercraftController = new SellercraftController(tx, domain, user)
|
|
114
|
+
releaseGood = await sellercraftCtrl.fetchOrderDocument(sellercraft, releaseGood)
|
|
115
|
+
}
|
|
116
|
+
trackingNo = releaseGood?.trackingNo
|
|
117
|
+
shippingProvider = releaseGood?.transporter
|
|
118
|
+
marketplaceStatus = releaseGood?.marketplaceOrderStatus
|
|
123
119
|
} else {
|
|
124
|
-
|
|
125
|
-
where: {
|
|
120
|
+
marketplaceOrder = await tx.getRepository(MarketplaceOrder).findOne({
|
|
121
|
+
where: { orderNo: releaseGood.refNo },
|
|
122
|
+
relations: [
|
|
123
|
+
'domain',
|
|
124
|
+
'marketplaceStore',
|
|
125
|
+
'marketplaceOrderItems',
|
|
126
|
+
'marketplaceOrderItems.marketplaceOrderShippingItems',
|
|
127
|
+
'marketplaceOrderItems.marketplaceOrderShippingItems.marketplaceOrderShipping'
|
|
128
|
+
]
|
|
126
129
|
})
|
|
127
|
-
}
|
|
128
130
|
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
131
|
+
if (!marketplaceOrder) {
|
|
132
|
+
throw new Error('Failed to retrieve ecommerce information, kindly contact our support team for this issue.')
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
let marketplaceOrderShipping: MarketplaceOrderShipping
|
|
136
|
+
if (marketplaceOrder.isSplitted) {
|
|
137
|
+
marketplaceOrderShipping = await tx.getRepository(MarketplaceOrderShipping).findOne({
|
|
138
|
+
where: { subOrderNoRef: worksheet.releaseGood.refNo2 }
|
|
139
|
+
})
|
|
140
|
+
} else {
|
|
141
|
+
marketplaceOrderShipping = await tx.getRepository(MarketplaceOrderShipping).findOne({
|
|
142
|
+
where: { orderNoRef: worksheet.releaseGood.refNo }
|
|
143
|
+
})
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
trackingNo = marketplaceOrderShipping.ownTrackingNo
|
|
147
|
+
? marketplaceOrderShipping.ownTrackingNo
|
|
148
|
+
: marketplaceOrderShipping.trackingNo
|
|
149
|
+
shippingProvider = marketplaceOrderShipping.ownTransporter
|
|
150
|
+
? marketplaceOrderShipping.ownTransporter
|
|
151
|
+
: marketplaceOrderShipping.transporter
|
|
152
|
+
|
|
153
|
+
marketplaceStore = marketplaceOrder?.marketplaceStore
|
|
154
|
+
marketplaceStatus = marketplaceOrder?.status
|
|
155
|
+
}
|
|
138
156
|
}
|
|
139
|
-
}
|
|
140
157
|
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
158
|
+
return {
|
|
159
|
+
worksheetInfo: {
|
|
160
|
+
releaseGood,
|
|
161
|
+
bizplaceName: releaseGood.bizplace.name,
|
|
162
|
+
refNo: releaseGood.refNo,
|
|
163
|
+
refNo2: releaseGood.refNo2,
|
|
164
|
+
refNo3: releaseGood.refNo3,
|
|
165
|
+
partnerDomainId: releaseGood.bizplace?.domain.id,
|
|
166
|
+
startedAt: worksheet.startedAt,
|
|
167
|
+
shippingProvider: shippingProvider ? shippingProvider : '',
|
|
168
|
+
trackingNo: trackingNo ? trackingNo : '',
|
|
169
|
+
airwayBill: releaseGood?.airwayBill,
|
|
170
|
+
invoice: releaseGood?.invoice,
|
|
171
|
+
platform: marketplaceOrder ? marketplaceOrder.marketplaceStore.platform : 'operato',
|
|
172
|
+
marketplaceStoreId: marketplaceOrder ? marketplaceOrder.marketplaceStore.id : '',
|
|
173
|
+
marketplaceStatus: marketplaceStatus ? marketplaceStatus : '',
|
|
174
|
+
marketplaceOrder: marketplaceOrder ? marketplaceOrder : ''
|
|
175
|
+
},
|
|
176
|
+
worksheetDetailInfos: worksheet.worksheetDetails.map(async (packingWSD: WorksheetDetail) => {
|
|
177
|
+
const targetInventory: OrderInventory = packingWSD.targetInventory
|
|
178
|
+
const inventory: Inventory = targetInventory.inventory
|
|
179
|
+
return {
|
|
180
|
+
name: packingWSD.name,
|
|
181
|
+
palletId: inventory.palletId,
|
|
182
|
+
cartonId: inventory.cartonId,
|
|
183
|
+
batchId: inventory.batchId,
|
|
184
|
+
batchIdRef: inventory.batchIdRef,
|
|
185
|
+
product: inventory.product,
|
|
186
|
+
sku: inventory.product.sku,
|
|
187
|
+
releaseQty: targetInventory.releaseQty,
|
|
188
|
+
packedQty: targetInventory.packedQty,
|
|
189
|
+
status: packingWSD.status,
|
|
190
|
+
description: packingWSD.description,
|
|
191
|
+
targetName: targetInventory.name,
|
|
192
|
+
packingType: inventory.packingType,
|
|
193
|
+
packingSize: inventory.packingSize,
|
|
194
|
+
binLocation: targetInventory?.binLocation,
|
|
195
|
+
location: inventory.location,
|
|
196
|
+
relatedOrderInv: targetInventory
|
|
197
|
+
}
|
|
198
|
+
})
|
|
199
|
+
}
|
|
200
|
+
} catch (error) {
|
|
201
|
+
console.error(error)
|
|
202
|
+
throw error
|
|
181
203
|
}
|
|
182
204
|
}
|
|
183
205
|
}
|
|
@@ -20,8 +20,9 @@ export const assignPickingWorkerResolver = {
|
|
|
20
20
|
await Promise.all(worksheetId.map(async (worksheetId)=>{
|
|
21
21
|
const worksheet: Worksheet = await tx.getRepository(Worksheet).findOne({
|
|
22
22
|
id: worksheetId,
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
},{where: [{
|
|
24
|
+
type:WORKSHEET_TYPE.BATCH_PICKING
|
|
25
|
+
},{type:WORKSHEET_TYPE.PICKING}]})
|
|
25
26
|
|
|
26
27
|
if (!worksheet) throw new Error('failed to find target picking worksheet')
|
|
27
28
|
if (worksheet.status !== WORKSHEET_STATUS.DEACTIVATED)
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { getDomainUsers, User } from '@things-factory/auth-base'
|
|
2
|
-
import { Bizplace } from '@things-factory/biz-base'
|
|
3
2
|
import { Domain } from '@things-factory/shell'
|
|
4
3
|
import { FindManyOptions, getRepository, ILike, In } from 'typeorm'
|
|
5
4
|
import { WORKSHEET_STATUS, WORKSHEET_TYPE } from '../../../../constants'
|
|
@@ -19,6 +18,7 @@ export const pickingAssignmentStatusByUsersResolver = {
|
|
|
19
18
|
const domainUserIds: string[] = domainUsers
|
|
20
19
|
.filter((user: User) => user.userType === 'user')
|
|
21
20
|
.map((user: User) => user.id)
|
|
21
|
+
|
|
22
22
|
const findOneOption: FindManyOptions<User> = { where: { id: In(domainUserIds) } }
|
|
23
23
|
if (name) findOneOption.where.name = ILike(`%${name}%`)
|
|
24
24
|
if (email) findOneOption.where.email = ILike(`%${email}%`)
|
|
@@ -27,10 +27,10 @@ export const pickingAssignmentStatusByUsersResolver = {
|
|
|
27
27
|
|
|
28
28
|
const assignedPickingWorksheets: Worksheet[] = await getRepository(Worksheet).find({
|
|
29
29
|
where: {
|
|
30
|
-
|
|
31
|
-
type: WORKSHEET_TYPE.PICKING,
|
|
30
|
+
type: In([WORKSHEET_TYPE.PICKING, WORKSHEET_TYPE.BATCH_PICKING]),
|
|
32
31
|
status: In([WORKSHEET_STATUS.DEACTIVATED, WORKSHEET_STATUS.EXECUTING]),
|
|
33
|
-
assignee: In(users.map((u: User) => u.id))
|
|
32
|
+
assignee: In(users.map((u: User) => u.id)),
|
|
33
|
+
domain
|
|
34
34
|
},
|
|
35
35
|
relations: ['assignee']
|
|
36
36
|
})
|
|
@@ -4,9 +4,9 @@ import { EntityManager } from 'typeorm'
|
|
|
4
4
|
import { SortingWorksheetController } from '../../../../controllers'
|
|
5
5
|
|
|
6
6
|
export const scanProductSortingResolver = {
|
|
7
|
-
async scanProductSorting(_: any, { taskNo, releaseGoodNo, productBarcode }, context: any) {
|
|
7
|
+
async scanProductSorting(_: any, { taskNo, releaseGoodNo, productBarcode, serialNumber }, context: any) {
|
|
8
8
|
const { tx, domain, user }: { tx: EntityManager; domain: Domain; user: User } = context.state
|
|
9
|
-
await scanProductSorting(tx, domain, user, taskNo, releaseGoodNo, productBarcode)
|
|
9
|
+
await scanProductSorting(tx, domain, user, taskNo, releaseGoodNo, productBarcode, serialNumber)
|
|
10
10
|
}
|
|
11
11
|
}
|
|
12
12
|
|
|
@@ -16,8 +16,9 @@ export async function scanProductSorting(
|
|
|
16
16
|
user: User,
|
|
17
17
|
taskNo: string,
|
|
18
18
|
releaseGoodNo: string,
|
|
19
|
-
productBarcode?: string
|
|
19
|
+
productBarcode?: string,
|
|
20
|
+
serialNumber?: string
|
|
20
21
|
) {
|
|
21
22
|
const worksheetController: SortingWorksheetController = new SortingWorksheetController(tx, domain, user)
|
|
22
|
-
await worksheetController.scanProductSorting(taskNo, releaseGoodNo, productBarcode)
|
|
23
|
+
await worksheetController.scanProductSorting(taskNo, releaseGoodNo, productBarcode, serialNumber)
|
|
23
24
|
}
|
|
@@ -4,9 +4,9 @@ import { EntityManager } from 'typeorm'
|
|
|
4
4
|
import { SortingWorksheetController } from '../../../../controllers'
|
|
5
5
|
|
|
6
6
|
export const sortingProductResolver = {
|
|
7
|
-
async sortingProduct(_: any, { taskNo, releaseGoodNo, productId, sortingQty }, context: any) {
|
|
7
|
+
async sortingProduct(_: any, { taskNo, releaseGoodNo, productId, sortingQty, serialNumber }, context: any) {
|
|
8
8
|
const { tx, domain, user }: { tx: EntityManager; domain: Domain; user: User } = context.state
|
|
9
|
-
await sortingProduct(tx, domain, user, taskNo, releaseGoodNo, productId, sortingQty)
|
|
9
|
+
await sortingProduct(tx, domain, user, taskNo, releaseGoodNo, productId, sortingQty, serialNumber)
|
|
10
10
|
}
|
|
11
11
|
}
|
|
12
12
|
|
|
@@ -17,8 +17,9 @@ export async function sortingProduct(
|
|
|
17
17
|
taskNo: string,
|
|
18
18
|
releaseGoodNo: string,
|
|
19
19
|
productId: string,
|
|
20
|
-
sortingQty: number
|
|
20
|
+
sortingQty: number,
|
|
21
|
+
serialNumber?: string
|
|
21
22
|
) {
|
|
22
23
|
const worksheetController: SortingWorksheetController = new SortingWorksheetController(tx, domain, user)
|
|
23
|
-
await worksheetController.sortingProduct(taskNo, releaseGoodNo, productId, sortingQty)
|
|
24
|
+
await worksheetController.sortingProduct(taskNo, releaseGoodNo, productId, sortingQty, serialNumber)
|
|
24
25
|
}
|
|
@@ -26,22 +26,26 @@ export const sortingWorksheetResolver = {
|
|
|
26
26
|
const qb: SelectQueryBuilder<OrderInventory> = getRepository(OrderInventory).createQueryBuilder('OI')
|
|
27
27
|
qb.select('SUM(OI.releaseQty)', 'releaseQty')
|
|
28
28
|
.addSelect('SUM(OI.sortedQty)', 'sortedQty')
|
|
29
|
+
.addSelect(`string_agg(CONCAT(BIN.name, '(', OI.releaseQty, ')' ), ' ')`, 'binRemarks')
|
|
29
30
|
.addSelect('PROD.id', 'productId')
|
|
30
31
|
.addSelect('PROD.name', 'productName')
|
|
31
32
|
.addSelect('PROD.sku', 'productSku')
|
|
32
33
|
.addSelect('PROD.description', 'productDescription')
|
|
34
|
+
.addSelect('PROD.isRequireSerialNumberScanningOutbound', 'isRequireSerialNumberScanningOutbound')
|
|
33
35
|
.addSelect('OI.batch_id', 'batchId')
|
|
34
36
|
.addSelect('OI.packing_type', 'packingType')
|
|
35
37
|
.addSelect('OI.packing_size', 'packingSize')
|
|
36
38
|
.addSelect('INV.expiration_date', 'expirationDate')
|
|
37
39
|
.leftJoin('OI.product', 'PROD')
|
|
38
40
|
.leftJoin('OI.inventory', 'INV')
|
|
41
|
+
.leftJoin('OI.binLocation', 'BIN')
|
|
39
42
|
.where('OI.release_good_id = :releaseGoodId', { releaseGoodId: releaseGood?.id })
|
|
40
43
|
.andWhere('OI.status <> :releaseGoodStatus', { releaseGoodStatus: ORDER_INVENTORY_STATUS.COMPLETE_SPLIT })
|
|
41
44
|
.groupBy('PROD.id')
|
|
42
45
|
.addGroupBy('PROD.name')
|
|
43
46
|
.addGroupBy('PROD.sku')
|
|
44
47
|
.addGroupBy('PROD.description')
|
|
48
|
+
.addGroupBy('PROD.isRequireSerialNumberScanningOutbound')
|
|
45
49
|
.addGroupBy('INV.expiration_date')
|
|
46
50
|
.addGroupBy('OI.batch_id')
|
|
47
51
|
.addGroupBy('OI.packing_type')
|
|
@@ -67,12 +71,14 @@ export const sortingWorksheetResolver = {
|
|
|
67
71
|
productSku: item?.productSku,
|
|
68
72
|
productName: item?.productName,
|
|
69
73
|
productDescription: item?.productDescription,
|
|
74
|
+
isRequireSerialNumberScanningOutbound: item?.isRequireSerialNumberScanningOutbound,
|
|
70
75
|
releaseQty: item.releaseQty,
|
|
71
76
|
sortedQty: item.sortedQty,
|
|
72
77
|
status: item.status,
|
|
73
78
|
expirationDate: item?.expirationDate,
|
|
74
79
|
packingType: item?.packingType,
|
|
75
80
|
packingSize: item?.packingSize,
|
|
81
|
+
binRemarks: item?.binRemarks,
|
|
76
82
|
releaseGood
|
|
77
83
|
}
|
|
78
84
|
})
|
|
@@ -1,20 +1,19 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
import {
|
|
1
|
+
import { EntityManager, getRepository } from 'typeorm'
|
|
2
|
+
|
|
3
|
+
import { User } from '@things-factory/auth-base'
|
|
4
|
+
import { ORDER_INVENTORY_STATUS, ORDER_TYPES, OrderInventory, OrderNoGenerator } from '@things-factory/sales-base'
|
|
4
5
|
import { Setting } from '@things-factory/setting-base'
|
|
5
|
-
import {
|
|
6
|
+
import { Domain } from '@things-factory/shell'
|
|
7
|
+
import { Inventory } from '@things-factory/warehouse-base'
|
|
8
|
+
|
|
6
9
|
import { WORKSHEET_STATUS, WORKSHEET_TYPE } from '../../../constants'
|
|
7
10
|
import { Worksheet, WorksheetDetail } from '../../../entities'
|
|
8
|
-
import {
|
|
9
|
-
import { User } from '@things-factory/auth-base'
|
|
10
|
-
import { Domain } from '@things-factory/shell'
|
|
11
|
-
import { generateBatchPickingWorksheetDetailsResolver } from './generate-batch-picking-worksheet-details'
|
|
12
|
-
import orderBy from 'lodash/orderBy'
|
|
11
|
+
import { inventoriesByStrategy, WorksheetNoGenerator } from '../../../utils'
|
|
13
12
|
|
|
14
13
|
export const generateBatchPickingWorksheetDetailsByBulkResolver = {
|
|
15
14
|
async generateBatchPickingWorksheetDetailsByBulk(
|
|
16
15
|
_: any,
|
|
17
|
-
{ worksheetId, bizplaceId, selectedItems
|
|
16
|
+
{ worksheetId, bizplaceId, selectedItems },
|
|
18
17
|
context: any
|
|
19
18
|
): Promise<Boolean> {
|
|
20
19
|
const { tx, user, domain }: { tx: EntityManager; user: User; domain: Domain } = context.state
|
|
@@ -50,7 +49,7 @@ export const generateBatchPickingWorksheetDetailsByBulkResolver = {
|
|
|
50
49
|
})
|
|
51
50
|
|
|
52
51
|
await Promise.all(
|
|
53
|
-
selectedItems.map(async (oi: OrderInventory) => {
|
|
52
|
+
selectedItems.map(async (oi: OrderInventory & { pickingStrategy: string }) => {
|
|
54
53
|
try {
|
|
55
54
|
let pOrderInventories = tx.getRepository(OrderInventory).find({
|
|
56
55
|
where: {
|
|
@@ -72,7 +71,6 @@ export const generateBatchPickingWorksheetDetailsByBulkResolver = {
|
|
|
72
71
|
...oi,
|
|
73
72
|
worksheetId: worksheet.id,
|
|
74
73
|
bizplaceId,
|
|
75
|
-
pickingStrategy,
|
|
76
74
|
locationSortingRules: inventoryAssignmentSetting ? JSON.parse(inventoryAssignmentSetting.value) : false
|
|
77
75
|
},
|
|
78
76
|
domain,
|
|
@@ -20,7 +20,7 @@ import { WorksheetNoGenerator } from '../../../utils'
|
|
|
20
20
|
export const generatePickingWorksheetDetailsResolver = {
|
|
21
21
|
async generatePickingWorksheetDetails(
|
|
22
22
|
_: any,
|
|
23
|
-
{ bizplaceId, selectedItems,
|
|
23
|
+
{ bizplaceId, selectedItems, worksheetNo, locationSortingRules },
|
|
24
24
|
context: any
|
|
25
25
|
): Promise<Boolean> {
|
|
26
26
|
const { tx, user, domain }: { tx: EntityManager; user: User; domain: Domain } = context.state
|
|
@@ -54,7 +54,6 @@ export const generatePickingWorksheetDetailsResolver = {
|
|
|
54
54
|
bizplaceId,
|
|
55
55
|
worksheetId,
|
|
56
56
|
selectedItems,
|
|
57
|
-
pickingStrategy,
|
|
58
57
|
locationSortingRules,
|
|
59
58
|
tx
|
|
60
59
|
)
|
|
@@ -162,6 +161,9 @@ function _composeWorksheetDetails(
|
|
|
162
161
|
|
|
163
162
|
while (compReleaseQty < record.releaseQty) {
|
|
164
163
|
const inv = inventories[idx]
|
|
164
|
+
|
|
165
|
+
if (!inv) break
|
|
166
|
+
|
|
165
167
|
let releaseQty: number = 0
|
|
166
168
|
let releaseUomValue: number = 0
|
|
167
169
|
|
|
@@ -22,6 +22,7 @@ import { WorksheetInfo } from './worksheet-info'
|
|
|
22
22
|
import { WorksheetList } from './worksheet-list'
|
|
23
23
|
import { WorksheetPatch } from './worksheet-patch'
|
|
24
24
|
import { WorksheetWithPagination } from './worksheet-with-pagination'
|
|
25
|
+
import { FindReleaseOrdersByTaskNo } from './find-release-orders-by-task-no'
|
|
25
26
|
|
|
26
27
|
export const Mutation = /* GraphQL */ `
|
|
27
28
|
createWorksheet (
|
|
@@ -164,6 +165,11 @@ export const Mutation = /* GraphQL */ `
|
|
|
164
165
|
worksheetNo: [String!]!
|
|
165
166
|
): [Worksheet] @privilege(category: "worksheet_control", privilege: "mutation") @transaction
|
|
166
167
|
|
|
168
|
+
undoSerialNumberPacking (
|
|
169
|
+
worksheetDetailName: String!
|
|
170
|
+
inventoryItemId: String!
|
|
171
|
+
): Boolean @privilege(category: "worksheet_execute", privilege: "mutation") @transaction
|
|
172
|
+
|
|
167
173
|
activateBatchPicking (
|
|
168
174
|
worksheetNo: String!
|
|
169
175
|
): Worksheet @privilege(category: "worksheet_control", privilege: "mutation") @transaction
|
|
@@ -323,22 +329,26 @@ export const Mutation = /* GraphQL */ `
|
|
|
323
329
|
releaseGoodNo: String!
|
|
324
330
|
productId: String!
|
|
325
331
|
sortingQty: Float!
|
|
332
|
+
serialNumber: String
|
|
326
333
|
): Boolean @privilege(category: "worksheet_execute", privilege: "mutation") @transaction
|
|
327
334
|
|
|
328
335
|
scanProductSorting (
|
|
329
336
|
taskNo: String!
|
|
330
337
|
releaseGoodNo: String!
|
|
331
338
|
productBarcode: String!
|
|
339
|
+
serialNumber: String
|
|
332
340
|
): Boolean @privilege(category: "worksheet_execute", privilege: "mutation") @transaction
|
|
333
341
|
|
|
334
342
|
packing (
|
|
335
343
|
worksheetDetailName: String!
|
|
336
344
|
releaseQty: Int!
|
|
345
|
+
serialNumber: String
|
|
337
346
|
): Boolean @privilege(category: "worksheet_execute", privilege: "mutation") @transaction
|
|
338
347
|
|
|
339
348
|
scanProductPacking (
|
|
340
349
|
worksheetDetailName: String!
|
|
341
350
|
productBarcode: String!
|
|
351
|
+
serialNumber: String
|
|
342
352
|
): Boolean @privilege(category: "worksheet_execute", privilege: "mutation") @transaction
|
|
343
353
|
|
|
344
354
|
batchPicking (
|
|
@@ -679,7 +689,7 @@ export const Query = /* GraphQL */ `
|
|
|
679
689
|
|
|
680
690
|
recommendPutawayLocation(worksheetDetailName: String!, optCnt: Int): [Location] @privilege(category: "worksheet", privilege: "query")
|
|
681
691
|
|
|
682
|
-
findReleaseOrdersByTaskNo(taskNo: String!):
|
|
692
|
+
findReleaseOrdersByTaskNo(taskNo: String!): FindReleaseOrdersByTaskNo @privilege(category: "worksheet", privilege: "query") @transaction
|
|
683
693
|
`
|
|
684
694
|
|
|
685
695
|
export const Types = /* GraphQL */ [
|
|
@@ -706,5 +716,6 @@ export const Types = /* GraphQL */ [
|
|
|
706
716
|
ProductApproval,
|
|
707
717
|
WorksheetWithPagination,
|
|
708
718
|
PickingAssignmentStatus,
|
|
709
|
-
MyPickingAssignmentStatus
|
|
719
|
+
MyPickingAssignmentStatus,
|
|
720
|
+
FindReleaseOrdersByTaskNo
|
|
710
721
|
]
|
|
@@ -41,13 +41,11 @@ export const Mutation = /* GraphQL */ `
|
|
|
41
41
|
bizplaceId: String
|
|
42
42
|
locationSortingRules: [Sorting]
|
|
43
43
|
selectedItems: [OrderInventoryPatch]!
|
|
44
|
-
pickingStrategy: String!
|
|
45
44
|
): Boolean @transaction
|
|
46
45
|
|
|
47
46
|
generatePickingWorksheetDetails(
|
|
48
47
|
bizplaceId: String!
|
|
49
48
|
selectedItems: [OrderInventoryPatch]!
|
|
50
|
-
pickingStrategy: String!
|
|
51
49
|
worksheetNo: String!
|
|
52
50
|
locationSortingRules: [Sorting]
|
|
53
51
|
): Boolean @transaction
|