@things-factory/warehouse-base 8.0.3 → 8.0.6
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/tsconfig.tsbuildinfo +1 -1
- package/package.json +8 -8
- package/server/constants/index.ts +0 -5
- package/server/constants/inventory.ts +0 -67
- package/server/constants/location.ts +0 -14
- package/server/constants/pallet.ts +0 -10
- package/server/constants/rule-type.ts +0 -5
- package/server/constants/tote.ts +0 -5
- package/server/controllers/ecommerce/ecommerce-controller.ts +0 -108
- package/server/controllers/ecommerce/index.ts +0 -2
- package/server/controllers/ecommerce/sellercraft-controller.ts +0 -100
- package/server/controllers/index.ts +0 -2
- package/server/controllers/warehouse-controller.ts +0 -181
- package/server/index.ts +0 -9
- package/server/middlewares/index.ts +0 -0
- package/server/migrations/index.ts +0 -9
- package/server/service/index.ts +0 -80
- package/server/service/inventory/index.ts +0 -6
- package/server/service/inventory/inventory-mutation.ts +0 -530
- package/server/service/inventory/inventory-query.ts +0 -1263
- package/server/service/inventory/inventory-types.ts +0 -367
- package/server/service/inventory/inventory.ts +0 -408
- package/server/service/inventory-change/index.ts +0 -6
- package/server/service/inventory-change/inventory-change-mutation.ts +0 -969
- package/server/service/inventory-change/inventory-change-query.ts +0 -93
- package/server/service/inventory-change/inventory-change-types.ts +0 -36
- package/server/service/inventory-change/inventory-change.ts +0 -164
- package/server/service/inventory-history/index.ts +0 -6
- package/server/service/inventory-history/inventory-history-mutation.ts +0 -116
- package/server/service/inventory-history/inventory-history-query.ts +0 -1845
- package/server/service/inventory-history/inventory-history-types.ts +0 -444
- package/server/service/inventory-history/inventory-history.ts +0 -203
- package/server/service/inventory-item/index.ts +0 -6
- package/server/service/inventory-item/inventory-item-mutation.ts +0 -217
- package/server/service/inventory-item/inventory-item-query.ts +0 -226
- package/server/service/inventory-item/inventory-item-type.ts +0 -74
- package/server/service/inventory-item/inventory-item.ts +0 -105
- package/server/service/inventory-item-change/index.ts +0 -6
- package/server/service/inventory-item-change/inventory-item-change-mutation.ts +0 -119
- package/server/service/inventory-item-change/inventory-item-change-query.ts +0 -47
- package/server/service/inventory-item-change/inventory-item-change-type.ts +0 -68
- package/server/service/inventory-item-change/inventory-item-change.ts +0 -92
- package/server/service/inventory-product/index.ts +0 -6
- package/server/service/inventory-product/inventory-product-mutation.ts +0 -116
- package/server/service/inventory-product/inventory-product-query.ts +0 -47
- package/server/service/inventory-product/inventory-product-type.ts +0 -59
- package/server/service/inventory-product/inventory-product.ts +0 -88
- package/server/service/location/index.ts +0 -6
- package/server/service/location/location-mutation.ts +0 -134
- package/server/service/location/location-query.ts +0 -244
- package/server/service/location/location-types.ts +0 -173
- package/server/service/location/location.ts +0 -121
- package/server/service/movement/index.ts +0 -6
- package/server/service/movement/movement-mutation.ts +0 -60
- package/server/service/movement/movement-query.ts +0 -263
- package/server/service/movement/movement-types.ts +0 -74
- package/server/service/movement/movement.ts +0 -81
- package/server/service/pallet/index.ts +0 -6
- package/server/service/pallet/pallet-mutation.ts +0 -242
- package/server/service/pallet/pallet-query.ts +0 -106
- package/server/service/pallet/pallet-types.ts +0 -80
- package/server/service/pallet/pallet.ts +0 -92
- package/server/service/pallet-count/index.ts +0 -6
- package/server/service/pallet-count/pallet-count-mutation.ts +0 -151
- package/server/service/pallet-count/pallet-count-query.ts +0 -45
- package/server/service/pallet-count/pallet-count-types.ts +0 -36
- package/server/service/pallet-count/pallet-count.ts +0 -70
- package/server/service/pallet-history/index.ts +0 -6
- package/server/service/pallet-history/pallet-history-mutation.ts +0 -114
- package/server/service/pallet-history/pallet-history-query.ts +0 -48
- package/server/service/pallet-history/pallet-history-types.ts +0 -36
- package/server/service/pallet-history/pallet-history.ts +0 -89
- package/server/service/reduced-inventory-history/index.ts +0 -3
- package/server/service/reduced-inventory-history/reduced-inventory-history.ts +0 -92
- package/server/service/tote/index.ts +0 -6
- package/server/service/tote/tote-mutation.ts +0 -201
- package/server/service/tote/tote-query.ts +0 -106
- package/server/service/tote/tote-types.ts +0 -44
- package/server/service/tote/tote.ts +0 -77
- package/server/service/warehouse/index.ts +0 -6
- package/server/service/warehouse/warehouse-mutation.ts +0 -152
- package/server/service/warehouse/warehouse-query.ts +0 -58
- package/server/service/warehouse/warehouse-types.ts +0 -50
- package/server/service/warehouse/warehouse.ts +0 -95
- package/server/utils/datetime-util.ts +0 -54
- package/server/utils/index.ts +0 -3
- package/server/utils/inventory-no-generator.ts +0 -15
- package/server/utils/inventory-util.ts +0 -490
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
import { Arg, Ctx, Directive, Mutation, Resolver } from 'type-graphql'
|
|
2
|
-
import { Repository } from 'typeorm'
|
|
3
|
-
|
|
4
|
-
import { Location } from '../location/location'
|
|
5
|
-
import { Warehouse } from '../warehouse/warehouse'
|
|
6
|
-
import { LocationPatch, NewLocation } from './location-types'
|
|
7
|
-
|
|
8
|
-
@Resolver(Location)
|
|
9
|
-
export class LocationMutation {
|
|
10
|
-
@Directive('@privilege(category: "warehouse", privilege: "mutation")')
|
|
11
|
-
@Directive('@transaction')
|
|
12
|
-
@Mutation(returns => Location)
|
|
13
|
-
async createLocation(@Arg('location') location: NewLocation, @Ctx() context: ResolverContext): Promise<Location> {
|
|
14
|
-
return await createLocation(location, context)
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
@Directive('@privilege(category: "warehouse", privilege: "mutation")')
|
|
18
|
-
@Directive('@transaction')
|
|
19
|
-
@Mutation(returns => Location)
|
|
20
|
-
async updateLocation(
|
|
21
|
-
@Arg('id') id: string,
|
|
22
|
-
@Arg('patch') patch: LocationPatch,
|
|
23
|
-
@Ctx() context: ResolverContext
|
|
24
|
-
): Promise<Location> {
|
|
25
|
-
return await updateLocation(id, patch, context)
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
@Directive('@privilege(category: "warehouse", privilege: "mutation")')
|
|
29
|
-
@Directive('@transaction')
|
|
30
|
-
@Mutation(returns => [Location])
|
|
31
|
-
async updateMultipleLocation(
|
|
32
|
-
@Arg('patches', type => [LocationPatch]) patches: LocationPatch[],
|
|
33
|
-
@Ctx() context: ResolverContext
|
|
34
|
-
): Promise<Location[]> {
|
|
35
|
-
let results = []
|
|
36
|
-
const _createRecords = patches.filter((patch: any) => patch.cuFlag === '+')
|
|
37
|
-
const _updateRecords = patches.filter((patch: any) => patch.cuFlag.toUpperCase() === 'M')
|
|
38
|
-
|
|
39
|
-
if (_createRecords.length > 0) {
|
|
40
|
-
for (let i = 0; i < _createRecords.length; i++) {
|
|
41
|
-
const patch = _createRecords[i]
|
|
42
|
-
const result = await createLocation(patch as NewLocation, context)
|
|
43
|
-
results.push({ ...result, cuFlag: '+' })
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
if (_updateRecords.length > 0) {
|
|
48
|
-
for (let i = 0; i < _updateRecords.length; i++) {
|
|
49
|
-
const patch: LocationPatch = _updateRecords[i]
|
|
50
|
-
const result = await updateLocation(patch.id, patch, context)
|
|
51
|
-
results.push({ ...result, cuFlag: 'M' })
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
return results
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
@Directive('@privilege(category: "warehouse", privilege: "mutation")')
|
|
59
|
-
@Directive('@transaction')
|
|
60
|
-
@Mutation(returns => Boolean)
|
|
61
|
-
async deleteLocation(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<Boolean> {
|
|
62
|
-
return await deleteLocation(id, context)
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
@Directive('@privilege(category: "warehouse", privilege: "mutation")')
|
|
66
|
-
@Directive('@transaction')
|
|
67
|
-
@Mutation(returns => Boolean)
|
|
68
|
-
async deleteLocations(
|
|
69
|
-
@Arg('ids', type => [String]) ids: string[],
|
|
70
|
-
@Ctx() context: ResolverContext
|
|
71
|
-
): Promise<Boolean> {
|
|
72
|
-
return await deleteLocations(ids, context)
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
@Directive('@privilege(category: "warehouse", privilege: "mutation")')
|
|
76
|
-
@Directive('@transaction')
|
|
77
|
-
@Mutation(returns => Boolean)
|
|
78
|
-
async deleteAllLocations(@Arg('warehouseId') warehouseId: string, @Ctx() context: ResolverContext) {
|
|
79
|
-
const { tx } = context.state
|
|
80
|
-
|
|
81
|
-
await tx.getRepository(Location).delete({
|
|
82
|
-
warehouse: { id: warehouseId }
|
|
83
|
-
})
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
export async function createLocation(location: NewLocation, context: ResolverContext): Promise<Location> {
|
|
88
|
-
const { domain, user, tx } = context.state
|
|
89
|
-
|
|
90
|
-
const locationRepository: Repository<Location> = tx.getRepository(Location)
|
|
91
|
-
const warehouseRepository: Repository<Warehouse> = tx.getRepository(Warehouse)
|
|
92
|
-
|
|
93
|
-
return await locationRepository.save({
|
|
94
|
-
...location,
|
|
95
|
-
warehouse: await warehouseRepository.findOneBy({ id: location.warehouse.id }),
|
|
96
|
-
domain,
|
|
97
|
-
creator: user,
|
|
98
|
-
updater: user
|
|
99
|
-
})
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
export async function updateLocation(id: string, patch: LocationPatch, context: ResolverContext): Promise<Location> {
|
|
103
|
-
const { user, tx } = context.state
|
|
104
|
-
|
|
105
|
-
const locationRepository: Repository<Location> = tx.getRepository(Location)
|
|
106
|
-
const warehouseRepository: Repository<Warehouse> = tx.getRepository(Warehouse)
|
|
107
|
-
const location: Location = await locationRepository.findOneBy({ id })
|
|
108
|
-
|
|
109
|
-
if (patch.warehouse && patch.warehouse.id) {
|
|
110
|
-
patch.warehouse = await warehouseRepository.findOneBy({ id: patch.warehouse.id })
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
return await locationRepository.save({
|
|
114
|
-
...location,
|
|
115
|
-
...patch,
|
|
116
|
-
updater: user
|
|
117
|
-
})
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
export async function deleteLocation(id: string, context: ResolverContext) {
|
|
121
|
-
const { tx } = context.state
|
|
122
|
-
|
|
123
|
-
const repository: Repository<Location> = tx.getRepository(Location)
|
|
124
|
-
await repository.delete(id)
|
|
125
|
-
return true
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
export async function deleteLocations(ids: string[], context: ResolverContext) {
|
|
129
|
-
const { tx } = context.state
|
|
130
|
-
|
|
131
|
-
const repository: Repository<Location> = tx.getRepository(Location)
|
|
132
|
-
await repository.delete(ids)
|
|
133
|
-
return true
|
|
134
|
-
}
|
|
@@ -1,244 +0,0 @@
|
|
|
1
|
-
import { Arg, Args, Ctx, Directive, FieldResolver, Query, Resolver, Root } from 'type-graphql'
|
|
2
|
-
|
|
3
|
-
import { User } from '@things-factory/auth-base'
|
|
4
|
-
import { getPermittedBizplaceIds } from '@things-factory/biz-base'
|
|
5
|
-
import { buildQuery, Domain, getQueryBuilderFromListParams, getRepository, ListParam } from '@things-factory/shell'
|
|
6
|
-
|
|
7
|
-
import { INVENTORY_STATUS } from '../../constants/inventory'
|
|
8
|
-
import { Warehouse } from '../warehouse/warehouse'
|
|
9
|
-
import { Location } from './location'
|
|
10
|
-
import { LocationInventories, LocationList, LocationOccupancy } from './location-types'
|
|
11
|
-
|
|
12
|
-
@Resolver(Location)
|
|
13
|
-
export class LocationQuery {
|
|
14
|
-
@Directive('@privilege(category: "warehouse", privilege: "query", domainOwnerGranted: true)')
|
|
15
|
-
@Query(returns => LocationList)
|
|
16
|
-
async locations(@Args(type => ListParam) params: ListParam, @Ctx() context: ResolverContext): Promise<LocationList> {
|
|
17
|
-
const queryBuilder = getQueryBuilderFromListParams({
|
|
18
|
-
repository: getRepository(Location),
|
|
19
|
-
params,
|
|
20
|
-
domain: context.state.domain,
|
|
21
|
-
searchables: ['name', 'description']
|
|
22
|
-
})
|
|
23
|
-
|
|
24
|
-
const [items, total] = await queryBuilder.getManyAndCount()
|
|
25
|
-
|
|
26
|
-
return { items, total }
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* @description this resolver was specially made to return huge locations data
|
|
31
|
-
* without dropping off performance due to typegraphql limitations
|
|
32
|
-
* @returns pure location data only. there will be no other table joined to avoid
|
|
33
|
-
* ORM lagging issue (converting to object extremely withdraws the performance)
|
|
34
|
-
* */
|
|
35
|
-
@Directive('@privilege(category: "warehouse", privilege: "query", domainOwnerGranted: true)')
|
|
36
|
-
@Query(returns => LocationList)
|
|
37
|
-
async pureLocations(
|
|
38
|
-
@Args(type => ListParam) params: ListParam,
|
|
39
|
-
@Ctx() context: ResolverContext
|
|
40
|
-
): Promise<LocationList> {
|
|
41
|
-
const queryBuilder = getRepository(Location).createQueryBuilder('location')
|
|
42
|
-
buildQuery(queryBuilder, params, context)
|
|
43
|
-
const items = await queryBuilder.getRawMany()
|
|
44
|
-
const total = await queryBuilder.getCount()
|
|
45
|
-
|
|
46
|
-
return { items: items.map(item => new Location(item)), total }
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
@Directive('@privilege(category: "warehouse", privilege: "query", domainOwnerGranted: true)')
|
|
50
|
-
@Query(returns => LocationOccupancy)
|
|
51
|
-
async locationOccupancies(
|
|
52
|
-
@Arg('warehouse') warehouse: string,
|
|
53
|
-
@Arg('types', type => [String], { nullable: true }) types: string[],
|
|
54
|
-
@Ctx() context: ResolverContext
|
|
55
|
-
): Promise<LocationOccupancy> {
|
|
56
|
-
const { domain } = context.state
|
|
57
|
-
|
|
58
|
-
const foundWarehouse: Warehouse = await getRepository(Warehouse).findOne({
|
|
59
|
-
where: {
|
|
60
|
-
domain: { id: domain.id },
|
|
61
|
-
name: warehouse
|
|
62
|
-
},
|
|
63
|
-
relations: ['locations']
|
|
64
|
-
})
|
|
65
|
-
|
|
66
|
-
if (!foundWarehouse) throw new Error(`${warehouse} was not found!`)
|
|
67
|
-
|
|
68
|
-
const locations: Location[] =
|
|
69
|
-
types && types.length
|
|
70
|
-
? foundWarehouse?.locations?.filter((location: Location) => types.indexOf(location.type) !== -1)
|
|
71
|
-
: foundWarehouse?.locations
|
|
72
|
-
|
|
73
|
-
const total: number = locations.length
|
|
74
|
-
const occupied: number = locations.filter((location: Location) => location.status === 'OCCUPIED')?.length || 0
|
|
75
|
-
const empty: number = total - occupied
|
|
76
|
-
const percentage: number = occupied > 0 ? Math.round((occupied / total) * 100) : 0
|
|
77
|
-
|
|
78
|
-
return { total, occupied, empty, percentage }
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
@Directive('@privilege(category: "warehouse", privilege: "query", domainOwnerGranted: true)')
|
|
82
|
-
@Query(returns => Location)
|
|
83
|
-
async location(@Arg('name') name: string, @Ctx() context: ResolverContext): Promise<Location> {
|
|
84
|
-
const foundLocation: Location | null = await getRepository(Location).findOne({
|
|
85
|
-
where: { name },
|
|
86
|
-
relations: ['domain', 'warehouse', 'creator', 'updater']
|
|
87
|
-
})
|
|
88
|
-
if (!foundLocation) throw new Error(context.t('error.no_location_found'))
|
|
89
|
-
|
|
90
|
-
return foundLocation
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
@Directive('@privilege(category: "warehouse", privilege: "query", domainOwnerGranted: true)')
|
|
94
|
-
@Query(returns => Location)
|
|
95
|
-
async locationByName(@Arg('name') name: string, @Ctx() context: ResolverContext): Promise<Location> {
|
|
96
|
-
const { domain } = context.state
|
|
97
|
-
|
|
98
|
-
return await getRepository(Location).findOne({
|
|
99
|
-
where: {
|
|
100
|
-
domain: { id: domain.id },
|
|
101
|
-
name
|
|
102
|
-
},
|
|
103
|
-
relations: ['domain', 'warehouse', 'creator', 'updater']
|
|
104
|
-
})
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
@Directive('@privilege(category: "warehouse", privilege: "query", domainOwnerGranted: true)')
|
|
108
|
-
@Query(returns => LocationList)
|
|
109
|
-
async locationsByGroup(
|
|
110
|
-
@Args(type => ListParam) params: ListParam,
|
|
111
|
-
@Ctx() context: ResolverContext
|
|
112
|
-
): Promise<LocationList> {
|
|
113
|
-
const { domain } = context.state
|
|
114
|
-
const warehouseIdParam = params.filters.find(param => (param.name = 'warehouse_id'))
|
|
115
|
-
|
|
116
|
-
if (!warehouseIdParam.value) throw new Error(`invalid warehouse ID`)
|
|
117
|
-
|
|
118
|
-
const items = await getRepository(Location).query(`
|
|
119
|
-
SELECT CONCAT("zone",'-',"row",'-',"column") as name, "zone", "row", "column"
|
|
120
|
-
FROM locations WHERE domain_id = '${domain.id}'
|
|
121
|
-
AND warehouse_id = '${warehouseIdParam.value}'
|
|
122
|
-
GROUP BY "zone", "row", "column"
|
|
123
|
-
`)
|
|
124
|
-
|
|
125
|
-
let [{ total }] = await getRepository(Location).query(`
|
|
126
|
-
SELECT COUNT(DISTINCT("zone", "row", "column")) as total
|
|
127
|
-
FROM locations WHERE domain_id = '${domain.id}'
|
|
128
|
-
AND warehouse_id = '${warehouseIdParam.value}'
|
|
129
|
-
`)
|
|
130
|
-
|
|
131
|
-
total = parseInt(total)
|
|
132
|
-
|
|
133
|
-
return { items, total }
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
@Directive('@privilege(category: "warehouse", privilege: "query", domainOwnerGranted: true)')
|
|
137
|
-
@Query(returns => LocationInventories)
|
|
138
|
-
async locationWithInventories(
|
|
139
|
-
@Args(type => ListParam) params: ListParam,
|
|
140
|
-
@Ctx() context: ResolverContext
|
|
141
|
-
): Promise<LocationInventories> {
|
|
142
|
-
const { domain, user } = context.state
|
|
143
|
-
const bizplaceIds = await getPermittedBizplaceIds(domain, user)
|
|
144
|
-
const queryBuilder = getRepository(Location).createQueryBuilder()
|
|
145
|
-
|
|
146
|
-
const warehouseNames = params.filters.find(
|
|
147
|
-
x => x.name === 'warehouseNames' && x.operator.toLowerCase() === 'in'
|
|
148
|
-
)?.value
|
|
149
|
-
|
|
150
|
-
const locationTypes = params.filters.find(
|
|
151
|
-
x => x.name === 'locationTypes' && x.operator.toLowerCase() === 'in'
|
|
152
|
-
)?.value
|
|
153
|
-
|
|
154
|
-
params.filters = []
|
|
155
|
-
buildQuery(queryBuilder, params, context)
|
|
156
|
-
|
|
157
|
-
queryBuilder
|
|
158
|
-
.leftJoinAndSelect('Location.warehouse', 'Warehouse')
|
|
159
|
-
.leftJoinAndSelect(
|
|
160
|
-
'inventories',
|
|
161
|
-
'Inventory',
|
|
162
|
-
'Location.id = Inventory.location_id AND Inventory.status = :InvStatus',
|
|
163
|
-
{
|
|
164
|
-
InvStatus: INVENTORY_STATUS.STORED
|
|
165
|
-
}
|
|
166
|
-
)
|
|
167
|
-
.leftJoinAndSelect('Inventory.product', 'Product')
|
|
168
|
-
.leftJoinAndSelect('Inventory.bizplace', 'Bizplace', 'Bizplace.id IN (:...bizplaceIds)', {
|
|
169
|
-
bizplaceIds: [...new Set(bizplaceIds)]
|
|
170
|
-
})
|
|
171
|
-
.leftJoinAndSelect('Inventory.creator', 'Creator')
|
|
172
|
-
.leftJoinAndSelect('Inventory.updater', 'Updater')
|
|
173
|
-
.addSelect('SUM("Inventory"."qty") OVER(PARTITION BY "Location"."id")', 'accumulate_qty')
|
|
174
|
-
.where('Location.domain_id = :domainId', { domainId: domain.id })
|
|
175
|
-
|
|
176
|
-
if (warehouseNames) {
|
|
177
|
-
queryBuilder.andWhere('Warehouse.name IN (:...warehouseNames)', { warehouseNames: [...new Set(warehouseNames)] })
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
if (locationTypes) {
|
|
181
|
-
queryBuilder.andWhere('Location.type ILIKE ANY (ARRAY[:...locationTypes])', {
|
|
182
|
-
locationTypes: [...new Set(locationTypes)]
|
|
183
|
-
})
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
let items = await queryBuilder.getRawMany()
|
|
187
|
-
const total = await queryBuilder.getCount()
|
|
188
|
-
|
|
189
|
-
items = items.map(item => {
|
|
190
|
-
return {
|
|
191
|
-
id: item.Location_id,
|
|
192
|
-
name: item.Location_name,
|
|
193
|
-
bizplace: {
|
|
194
|
-
name: item.Bizplace_name || '',
|
|
195
|
-
description: item.Bizplace_description || ''
|
|
196
|
-
},
|
|
197
|
-
product: {
|
|
198
|
-
name: item.Product_name || '',
|
|
199
|
-
sku: item.Product_sku || '',
|
|
200
|
-
description: item.Product_description || ''
|
|
201
|
-
},
|
|
202
|
-
palletId: item.Inventory_pallet_id || '',
|
|
203
|
-
batchId: item.Inventory_batch_id || '',
|
|
204
|
-
qty: item.Inventory_qty || 0,
|
|
205
|
-
accumulatedQty: item.accumulate_qty || 0,
|
|
206
|
-
uomValue: item.Inventory_uom_value || 0.0,
|
|
207
|
-
uom: item.Inventory_uom || '',
|
|
208
|
-
packingType: item.Inventory_packing_type || '',
|
|
209
|
-
packingSize: item.Inventory_packing_size || 0.0,
|
|
210
|
-
expirationDate: item.Inventory_expiration_date
|
|
211
|
-
? new Date(item.Inventory_expiration_date).toISOString().split('T')[0].split('-').reverse().join('-')
|
|
212
|
-
: '',
|
|
213
|
-
warehouse: {
|
|
214
|
-
name: item.Warehouse_name,
|
|
215
|
-
description: item.Warehouse_description,
|
|
216
|
-
type: item.Warehouse_type
|
|
217
|
-
},
|
|
218
|
-
zone: item.Location_zone
|
|
219
|
-
}
|
|
220
|
-
})
|
|
221
|
-
|
|
222
|
-
return { items, total }
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
@FieldResolver(type => Domain)
|
|
226
|
-
async domain(@Root() location: Location) {
|
|
227
|
-
return await getRepository(Domain).findOneBy({ id: location.domain?.id })
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
@FieldResolver(type => User)
|
|
231
|
-
async updater(@Root() location: Location) {
|
|
232
|
-
return await getRepository(User).findOneBy({ id: location.updaterId })
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
@FieldResolver(type => User)
|
|
236
|
-
async creator(@Root() location: Location) {
|
|
237
|
-
return await getRepository(User).findOneBy({ id: location.creatorId })
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
@FieldResolver(type => Warehouse)
|
|
241
|
-
async warehouse(@Root() location: Location): Promise<Warehouse> {
|
|
242
|
-
return await getRepository(Warehouse).findOneBy({ id: location.warehouse?.id })
|
|
243
|
-
}
|
|
244
|
-
}
|
|
@@ -1,173 +0,0 @@
|
|
|
1
|
-
import { Field, Float, InputType, Int, ObjectType } from 'type-graphql'
|
|
2
|
-
|
|
3
|
-
import { Bizplace } from '@things-factory/biz-base'
|
|
4
|
-
import { Product } from '@things-factory/product-base'
|
|
5
|
-
import { ObjectRef } from '@things-factory/shell'
|
|
6
|
-
|
|
7
|
-
import { Warehouse } from '../warehouse/warehouse'
|
|
8
|
-
import { Location } from './location'
|
|
9
|
-
|
|
10
|
-
@ObjectType()
|
|
11
|
-
export class LocationInventory {
|
|
12
|
-
@Field({ nullable: true })
|
|
13
|
-
id?: string
|
|
14
|
-
|
|
15
|
-
@Field({ nullable: true })
|
|
16
|
-
name?: string
|
|
17
|
-
|
|
18
|
-
@Field(type => Bizplace, { nullable: true })
|
|
19
|
-
bizplace?: Bizplace
|
|
20
|
-
|
|
21
|
-
@Field({ nullable: true })
|
|
22
|
-
palletId?: string
|
|
23
|
-
|
|
24
|
-
@Field({ nullable: true })
|
|
25
|
-
batchId?: string
|
|
26
|
-
|
|
27
|
-
@Field(type => Int, { nullable: true })
|
|
28
|
-
qty?: number
|
|
29
|
-
|
|
30
|
-
@Field(type => Int, { nullable: true })
|
|
31
|
-
accumulatedQty?: number
|
|
32
|
-
|
|
33
|
-
@Field(type => Float, { nullable: true })
|
|
34
|
-
uomValue?: number
|
|
35
|
-
|
|
36
|
-
@Field({ nullable: true })
|
|
37
|
-
uom?: string
|
|
38
|
-
|
|
39
|
-
@Field({ nullable: true })
|
|
40
|
-
packingType?: string
|
|
41
|
-
|
|
42
|
-
@Field(type => Float, { nullable: true })
|
|
43
|
-
packingSize?: number
|
|
44
|
-
|
|
45
|
-
@Field({ nullable: true })
|
|
46
|
-
expirationDate?: string
|
|
47
|
-
|
|
48
|
-
@Field(type => Warehouse, { nullable: true })
|
|
49
|
-
warehouse?: Warehouse
|
|
50
|
-
|
|
51
|
-
@Field(type => Product, { nullable: true })
|
|
52
|
-
product?: Product
|
|
53
|
-
|
|
54
|
-
@Field({ nullable: true })
|
|
55
|
-
zone?: string
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
@ObjectType()
|
|
59
|
-
export class LocationInventories {
|
|
60
|
-
@Field(type => [LocationInventory], { nullable: true })
|
|
61
|
-
items?: LocationInventory[]
|
|
62
|
-
|
|
63
|
-
@Field(type => Int, { nullable: true })
|
|
64
|
-
total?: number
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
@ObjectType()
|
|
68
|
-
export class LocationList {
|
|
69
|
-
@Field(type => [Location], { nullable: true })
|
|
70
|
-
items?: Location[]
|
|
71
|
-
|
|
72
|
-
@Field(type => Int, { nullable: true })
|
|
73
|
-
total?: number
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
@ObjectType()
|
|
77
|
-
export class LocationOccupancy {
|
|
78
|
-
@Field(type => Int, { nullable: true })
|
|
79
|
-
total?: number
|
|
80
|
-
|
|
81
|
-
@Field(type => Int, { nullable: true })
|
|
82
|
-
occupied?: number
|
|
83
|
-
|
|
84
|
-
@Field(type => Int, { nullable: true })
|
|
85
|
-
empty?: number
|
|
86
|
-
|
|
87
|
-
@Field(type => Int, { nullable: true })
|
|
88
|
-
percentage?: number
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
@InputType()
|
|
92
|
-
export class LocationPatch {
|
|
93
|
-
@Field({ nullable: true })
|
|
94
|
-
id?: string
|
|
95
|
-
|
|
96
|
-
@Field(type => ObjectRef, { nullable: true })
|
|
97
|
-
warehouse?: ObjectRef
|
|
98
|
-
|
|
99
|
-
@Field({ nullable: true })
|
|
100
|
-
name?: string
|
|
101
|
-
|
|
102
|
-
@Field({ nullable: true })
|
|
103
|
-
description?: string
|
|
104
|
-
|
|
105
|
-
@Field({ nullable: true })
|
|
106
|
-
type?: string
|
|
107
|
-
|
|
108
|
-
@Field({ nullable: true })
|
|
109
|
-
zone?: string
|
|
110
|
-
|
|
111
|
-
@Field({ nullable: true })
|
|
112
|
-
firstDelimiter?: string
|
|
113
|
-
|
|
114
|
-
@Field({ nullable: true })
|
|
115
|
-
secondDelimiter?: string
|
|
116
|
-
|
|
117
|
-
@Field({ nullable: true })
|
|
118
|
-
thirdDelimiter?: string
|
|
119
|
-
|
|
120
|
-
@Field({ nullable: true })
|
|
121
|
-
row?: string
|
|
122
|
-
|
|
123
|
-
@Field({ nullable: true })
|
|
124
|
-
column?: string
|
|
125
|
-
|
|
126
|
-
@Field({ nullable: true })
|
|
127
|
-
shelf?: string
|
|
128
|
-
|
|
129
|
-
@Field({ nullable: true })
|
|
130
|
-
status?: string
|
|
131
|
-
|
|
132
|
-
@Field({ nullable: true })
|
|
133
|
-
cuFlag?: string
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
@InputType()
|
|
137
|
-
export class NewLocation {
|
|
138
|
-
@Field(type => ObjectRef, { nullable: true })
|
|
139
|
-
warehouse?: ObjectRef
|
|
140
|
-
|
|
141
|
-
@Field()
|
|
142
|
-
name: string
|
|
143
|
-
|
|
144
|
-
@Field({ nullable: true })
|
|
145
|
-
description?: string
|
|
146
|
-
|
|
147
|
-
@Field({ nullable: true })
|
|
148
|
-
type?: string
|
|
149
|
-
|
|
150
|
-
@Field()
|
|
151
|
-
zone: string
|
|
152
|
-
|
|
153
|
-
@Field({ nullable: true })
|
|
154
|
-
firstDelimiter?: string
|
|
155
|
-
|
|
156
|
-
@Field({ nullable: true })
|
|
157
|
-
secondDelimiter?: string
|
|
158
|
-
|
|
159
|
-
@Field({ nullable: true })
|
|
160
|
-
thirdDelimiter?: string
|
|
161
|
-
|
|
162
|
-
@Field()
|
|
163
|
-
row: string
|
|
164
|
-
|
|
165
|
-
@Field()
|
|
166
|
-
column: string
|
|
167
|
-
|
|
168
|
-
@Field()
|
|
169
|
-
shelf: string
|
|
170
|
-
|
|
171
|
-
@Field()
|
|
172
|
-
status: string
|
|
173
|
-
}
|
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
import { Field, ID, ObjectType } from 'type-graphql'
|
|
2
|
-
import {
|
|
3
|
-
Column,
|
|
4
|
-
CreateDateColumn,
|
|
5
|
-
Entity,
|
|
6
|
-
Index,
|
|
7
|
-
ManyToOne,
|
|
8
|
-
PrimaryGeneratedColumn,
|
|
9
|
-
RelationId,
|
|
10
|
-
UpdateDateColumn
|
|
11
|
-
} from 'typeorm'
|
|
12
|
-
|
|
13
|
-
import { User } from '@things-factory/auth-base'
|
|
14
|
-
import { Domain } from '@things-factory/shell'
|
|
15
|
-
|
|
16
|
-
import { Warehouse } from '../warehouse/warehouse'
|
|
17
|
-
|
|
18
|
-
@Entity()
|
|
19
|
-
@Index('ix_location_0', (location: Location) => [location.domain, location.name], { unique: true })
|
|
20
|
-
@Index('ix_location_1', (location: Location) => [location.id], { unique: true })
|
|
21
|
-
@Index('ix_location_2', (location: Location) => [location.domain])
|
|
22
|
-
@Index('ix_location_3', (location: Location) => [location.domain, location.name, location.type])
|
|
23
|
-
@ObjectType()
|
|
24
|
-
export class Location {
|
|
25
|
-
@PrimaryGeneratedColumn('uuid')
|
|
26
|
-
@Field(type => ID)
|
|
27
|
-
readonly id: string
|
|
28
|
-
|
|
29
|
-
@ManyToOne(type => Domain)
|
|
30
|
-
@Field(type => Domain)
|
|
31
|
-
domain: Domain
|
|
32
|
-
|
|
33
|
-
@RelationId((location: Location) => location.domain)
|
|
34
|
-
domainId: string
|
|
35
|
-
|
|
36
|
-
@ManyToOne(type => Warehouse, warehouse => warehouse.locations, {
|
|
37
|
-
nullable: false
|
|
38
|
-
})
|
|
39
|
-
@Field(type => Warehouse, { nullable: true })
|
|
40
|
-
warehouse: Warehouse
|
|
41
|
-
|
|
42
|
-
@RelationId((location: Location) => location.warehouse)
|
|
43
|
-
warehouseId: string
|
|
44
|
-
|
|
45
|
-
@Column({ nullable: true })
|
|
46
|
-
@Field({ nullable: true })
|
|
47
|
-
name: string
|
|
48
|
-
|
|
49
|
-
@Column({
|
|
50
|
-
nullable: true
|
|
51
|
-
})
|
|
52
|
-
@Field({ nullable: true })
|
|
53
|
-
description: string
|
|
54
|
-
|
|
55
|
-
@Column({
|
|
56
|
-
nullable: true
|
|
57
|
-
})
|
|
58
|
-
@Field({ nullable: true })
|
|
59
|
-
type: string
|
|
60
|
-
|
|
61
|
-
@Column()
|
|
62
|
-
@Field()
|
|
63
|
-
zone: string
|
|
64
|
-
|
|
65
|
-
@Column()
|
|
66
|
-
@Field()
|
|
67
|
-
row: string
|
|
68
|
-
|
|
69
|
-
@Column()
|
|
70
|
-
@Field()
|
|
71
|
-
column: string
|
|
72
|
-
|
|
73
|
-
@Column()
|
|
74
|
-
@Field()
|
|
75
|
-
shelf: string
|
|
76
|
-
|
|
77
|
-
@Column({ type: 'text', comment: 'occupied, hold, empty' })
|
|
78
|
-
@Field()
|
|
79
|
-
status: string
|
|
80
|
-
|
|
81
|
-
@ManyToOne(type => User, {
|
|
82
|
-
nullable: true
|
|
83
|
-
})
|
|
84
|
-
@Field({ nullable: true })
|
|
85
|
-
creator: User
|
|
86
|
-
|
|
87
|
-
@RelationId((location: Location) => location.creator)
|
|
88
|
-
creatorId: string
|
|
89
|
-
|
|
90
|
-
@ManyToOne(type => User, {
|
|
91
|
-
nullable: true
|
|
92
|
-
})
|
|
93
|
-
@Field({ nullable: true })
|
|
94
|
-
updater: User
|
|
95
|
-
|
|
96
|
-
@RelationId((location: Location) => location.updater)
|
|
97
|
-
updaterId: string
|
|
98
|
-
|
|
99
|
-
@CreateDateColumn()
|
|
100
|
-
@Field({ nullable: true })
|
|
101
|
-
createdAt: Date
|
|
102
|
-
|
|
103
|
-
@UpdateDateColumn()
|
|
104
|
-
@Field({ nullable: true })
|
|
105
|
-
updatedAt: Date
|
|
106
|
-
|
|
107
|
-
constructor(obj?) {
|
|
108
|
-
if (obj) {
|
|
109
|
-
this.id = obj.location_id
|
|
110
|
-
this.name = obj.location_name
|
|
111
|
-
this.description = obj.location_description
|
|
112
|
-
this.type = obj.location_type
|
|
113
|
-
this.zone = obj.location_zone
|
|
114
|
-
this.row = obj.location_row
|
|
115
|
-
this.column = obj.location_column
|
|
116
|
-
this.shelf = obj.location_shelf
|
|
117
|
-
this.status = obj.location_status
|
|
118
|
-
this.updatedAt = obj.location_updated_at
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
}
|