@things-factory/operato-pms 6.1.83 → 6.1.85
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 +34 -34
- package/server/constants/block.ts +0 -4
- package/server/constants/index.ts +0 -8
- package/server/constants/inventory.ts +0 -9
- package/server/constants/master.ts +0 -9
- package/server/constants/organization.ts +0 -5
- package/server/constants/ramp.ts +0 -9
- package/server/constants/record.ts +0 -4
- package/server/constants/template.ts +0 -3
- package/server/constants/transaction.ts +0 -9
- package/server/controllers/index.ts +0 -1
- package/server/controllers/render-dispatchment.ts +0 -53
- package/server/entities/block-detail.ts +0 -59
- package/server/entities/block.ts +0 -49
- package/server/entities/daily-block-detail.ts +0 -54
- package/server/entities/daily-dispatch-detail.ts +0 -64
- package/server/entities/daily-dispatch.ts +0 -90
- package/server/entities/daily-harvest-detail.ts +0 -56
- package/server/entities/daily-harvest.ts +0 -89
- package/server/entities/daily-loading-detail.ts +0 -68
- package/server/entities/daily-loading-ramp.ts +0 -56
- package/server/entities/daily-loading.ts +0 -70
- package/server/entities/index.ts +0 -57
- package/server/entities/organization-staff.ts +0 -60
- package/server/entities/organization.ts +0 -43
- package/server/entities/plantation-inventory.ts +0 -56
- package/server/entities/plantation-setting.ts +0 -60
- package/server/entities/ramp.ts +0 -47
- package/server/entities/record-transaction.ts +0 -76
- package/server/entities/truck.ts +0 -58
- package/server/graphql/index.ts +0 -9
- package/server/graphql/resolvers/block/block-query.ts +0 -36
- package/server/graphql/resolvers/block/delete-blocks.ts +0 -39
- package/server/graphql/resolvers/block/index.ts +0 -11
- package/server/graphql/resolvers/block/update-multiple-block.ts +0 -69
- package/server/graphql/resolvers/block-detail/block-detail-query.ts +0 -55
- package/server/graphql/resolvers/block-detail/delete-block-details.ts +0 -20
- package/server/graphql/resolvers/block-detail/index.ts +0 -12
- package/server/graphql/resolvers/block-detail/update-multiple-block-detail.ts +0 -55
- package/server/graphql/resolvers/daily-block-detail/create-daily-block-detail.ts +0 -14
- package/server/graphql/resolvers/daily-block-detail/daily-block-detail-query.ts +0 -36
- package/server/graphql/resolvers/daily-block-detail/delete-daily-block-detail.ts +0 -14
- package/server/graphql/resolvers/daily-block-detail/delete-daily-block-details.ts +0 -17
- package/server/graphql/resolvers/daily-block-detail/index.ts +0 -18
- package/server/graphql/resolvers/daily-block-detail/update-daily-block-detail.ts +0 -17
- package/server/graphql/resolvers/daily-block-detail/update-multiple-daily-block-detail.ts +0 -44
- package/server/graphql/resolvers/daily-dispatch/daily-dispatch-query.ts +0 -48
- package/server/graphql/resolvers/daily-dispatch/delete-daily-dispatch.ts +0 -34
- package/server/graphql/resolvers/daily-dispatch/generate-daily-dispatch.ts +0 -131
- package/server/graphql/resolvers/daily-dispatch/index.ts +0 -14
- package/server/graphql/resolvers/daily-dispatch/update-daily-dispatch.ts +0 -36
- package/server/graphql/resolvers/daily-dispatch-detail/daily-dispatch-detail-query.ts +0 -37
- package/server/graphql/resolvers/daily-dispatch-detail/index.ts +0 -6
- package/server/graphql/resolvers/daily-harvest/daily-harvest-query.ts +0 -46
- package/server/graphql/resolvers/daily-harvest/delete-daily-harvest.ts +0 -65
- package/server/graphql/resolvers/daily-harvest/generate-daily-harvest.ts +0 -205
- package/server/graphql/resolvers/daily-harvest/index.ts +0 -14
- package/server/graphql/resolvers/daily-harvest/update-daily-harvest.ts +0 -153
- package/server/graphql/resolvers/daily-harvest-detail/daily-harvest-detail-query.ts +0 -35
- package/server/graphql/resolvers/daily-harvest-detail/index.ts +0 -6
- package/server/graphql/resolvers/daily-loading/daily-loading-query.ts +0 -43
- package/server/graphql/resolvers/daily-loading/delete-daily-loading.ts +0 -38
- package/server/graphql/resolvers/daily-loading/generate-daily-loading.ts +0 -149
- package/server/graphql/resolvers/daily-loading/index.ts +0 -14
- package/server/graphql/resolvers/daily-loading/update-daily-loading.ts +0 -154
- package/server/graphql/resolvers/daily-loading-detail/daily-loading-detail-query.ts +0 -35
- package/server/graphql/resolvers/daily-loading-detail/index.ts +0 -6
- package/server/graphql/resolvers/daily-loading-ramp/daily-loading-ramp-query.ts +0 -34
- package/server/graphql/resolvers/daily-loading-ramp/delete-daily-loading-ramp.ts +0 -15
- package/server/graphql/resolvers/daily-loading-ramp/index.ts +0 -12
- package/server/graphql/resolvers/daily-loading-ramp/update-daily-loading-ramp.ts +0 -18
- package/server/graphql/resolvers/dashboard/dashboard-query.ts +0 -245
- package/server/graphql/resolvers/dashboard/index.ts +0 -5
- package/server/graphql/resolvers/index.ts +0 -20
- package/server/graphql/resolvers/organization/delete-organizations.ts +0 -40
- package/server/graphql/resolvers/organization/index.ts +0 -11
- package/server/graphql/resolvers/organization/organization-query.ts +0 -35
- package/server/graphql/resolvers/organization/update-multiple-organization.ts +0 -48
- package/server/graphql/resolvers/organization-staff/delete-organization-staffs.ts +0 -20
- package/server/graphql/resolvers/organization-staff/index.ts +0 -12
- package/server/graphql/resolvers/organization-staff/organization-staff-query.ts +0 -43
- package/server/graphql/resolvers/organization-staff/update-multiple-organization-staff.ts +0 -60
- package/server/graphql/resolvers/plantation-inventory/index.ts +0 -6
- package/server/graphql/resolvers/plantation-inventory/plantation-inventory-query.ts +0 -43
- package/server/graphql/resolvers/plantation-setting/create-plantation-setting.ts +0 -16
- package/server/graphql/resolvers/plantation-setting/delete-plantation-setting.ts +0 -13
- package/server/graphql/resolvers/plantation-setting/delete-plantation-settings.ts +0 -18
- package/server/graphql/resolvers/plantation-setting/index.ts +0 -19
- package/server/graphql/resolvers/plantation-setting/plantation-setting-query.ts +0 -38
- package/server/graphql/resolvers/plantation-setting/update-multiple-plantation-setting.ts +0 -46
- package/server/graphql/resolvers/plantation-setting/update-plantation-setting.ts +0 -20
- package/server/graphql/resolvers/ramp/delete-ramps.ts +0 -24
- package/server/graphql/resolvers/ramp/index.ts +0 -12
- package/server/graphql/resolvers/ramp/ramp-query.ts +0 -34
- package/server/graphql/resolvers/ramp/update-multiple-ramp.ts +0 -61
- package/server/graphql/resolvers/record-transaction/index.ts +0 -6
- package/server/graphql/resolvers/record-transaction/record-transaction-query.ts +0 -34
- package/server/graphql/resolvers/report/daily-ffb-dispatch-production-reports.ts +0 -149
- package/server/graphql/resolvers/report/daily-production-reports.ts +0 -167
- package/server/graphql/resolvers/report/daily-staff-harvest-reports.ts +0 -84
- package/server/graphql/resolvers/report/index.ts +0 -22
- package/server/graphql/resolvers/report/monthly-block-dispatch-reports.ts +0 -122
- package/server/graphql/resolvers/report/monthly-dispatch-summary-reports.ts +0 -114
- package/server/graphql/resolvers/report/monthly-ffb-sale-reports.ts +0 -111
- package/server/graphql/resolvers/report/monthly-production-reports.ts +0 -117
- package/server/graphql/resolvers/report/yearly-production-reports.ts +0 -101
- package/server/graphql/resolvers/truck/delete-trucks.ts +0 -21
- package/server/graphql/resolvers/truck/index.ts +0 -12
- package/server/graphql/resolvers/truck/truck-query.ts +0 -50
- package/server/graphql/resolvers/truck/update-multiple-truck.ts +0 -55
- package/server/graphql/types/block/block-list.ts +0 -8
- package/server/graphql/types/block/block-patch.ts +0 -13
- package/server/graphql/types/block/block.ts +0 -18
- package/server/graphql/types/block/index.ts +0 -18
- package/server/graphql/types/block/new-block.ts +0 -8
- package/server/graphql/types/block-detail/block-detail-list.ts +0 -8
- package/server/graphql/types/block-detail/block-detail-patch.ts +0 -16
- package/server/graphql/types/block-detail/block-detail.ts +0 -21
- package/server/graphql/types/block-detail/index.ts +0 -18
- package/server/graphql/types/block-detail/new-block-detail.ts +0 -13
- package/server/graphql/types/daily-block-detail/daily-block-detail-list.ts +0 -8
- package/server/graphql/types/daily-block-detail/daily-block-detail-patch.ts +0 -10
- package/server/graphql/types/daily-block-detail/daily-block-detail.ts +0 -18
- package/server/graphql/types/daily-block-detail/index.ts +0 -21
- package/server/graphql/types/daily-block-detail/new-daily-block-detail.ts +0 -8
- package/server/graphql/types/daily-dispatch/daily-dispatch-list.ts +0 -8
- package/server/graphql/types/daily-dispatch/daily-dispatch-patch.ts +0 -22
- package/server/graphql/types/daily-dispatch/daily-dispatch.ts +0 -27
- package/server/graphql/types/daily-dispatch/index.ts +0 -24
- package/server/graphql/types/daily-dispatch/new-daily-dispatch.ts +0 -20
- package/server/graphql/types/daily-dispatch-detail/daily-dispatch-detail-list.ts +0 -8
- package/server/graphql/types/daily-dispatch-detail/daily-dispatch-detail-patch.ts +0 -16
- package/server/graphql/types/daily-dispatch-detail/daily-dispatch-detail.ts +0 -21
- package/server/graphql/types/daily-dispatch-detail/index.ts +0 -14
- package/server/graphql/types/daily-dispatch-detail/new-daily-dispatch-detail.ts +0 -12
- package/server/graphql/types/daily-harvest/daily-harvest-list.ts +0 -8
- package/server/graphql/types/daily-harvest/daily-harvest-patch.ts +0 -17
- package/server/graphql/types/daily-harvest/daily-harvest.ts +0 -27
- package/server/graphql/types/daily-harvest/index.ts +0 -19
- package/server/graphql/types/daily-harvest/new-daily-harvest.ts +0 -15
- package/server/graphql/types/daily-harvest-detail/daily-harvest-detail-list.ts +0 -8
- package/server/graphql/types/daily-harvest-detail/daily-harvest-detail-patch.ts +0 -11
- package/server/graphql/types/daily-harvest-detail/daily-harvest-detail.ts +0 -20
- package/server/graphql/types/daily-harvest-detail/index.ts +0 -14
- package/server/graphql/types/daily-harvest-detail/new-daily-harvest-detail.ts +0 -10
- package/server/graphql/types/daily-loading/daily-loading-list.ts +0 -8
- package/server/graphql/types/daily-loading/daily-loading-patch.ts +0 -8
- package/server/graphql/types/daily-loading/daily-loading.ts +0 -21
- package/server/graphql/types/daily-loading/index.ts +0 -19
- package/server/graphql/types/daily-loading/new-daily-loading.ts +0 -8
- package/server/graphql/types/daily-loading-detail/daily-loading-detail-list.ts +0 -8
- package/server/graphql/types/daily-loading-detail/daily-loading-detail-patch.ts +0 -14
- package/server/graphql/types/daily-loading-detail/daily-loading-detail.ts +0 -23
- package/server/graphql/types/daily-loading-detail/index.ts +0 -14
- package/server/graphql/types/daily-loading-detail/new-daily-loading-detail.ts +0 -13
- package/server/graphql/types/daily-loading-ramp/daily-loading-ramp-list.ts +0 -8
- package/server/graphql/types/daily-loading-ramp/daily-loading-ramp-patch.ts +0 -13
- package/server/graphql/types/daily-loading-ramp/daily-loading-ramp.ts +0 -17
- package/server/graphql/types/daily-loading-ramp/index.ts +0 -18
- package/server/graphql/types/daily-loading-ramp/new-daily-loading-ramp.ts +0 -11
- package/server/graphql/types/dashboard/bunches-count.ts +0 -9
- package/server/graphql/types/dashboard/index.ts +0 -17
- package/server/graphql/types/dashboard/productions-overview.ts +0 -9
- package/server/graphql/types/dashboard/tonnage-bunches-inventories.ts +0 -8
- package/server/graphql/types/dashboard/tonnage-production.ts +0 -11
- package/server/graphql/types/dashboard/yield-production.ts +0 -11
- package/server/graphql/types/index.ts +0 -20
- package/server/graphql/types/organization/index.ts +0 -18
- package/server/graphql/types/organization/new-organization.ts +0 -9
- package/server/graphql/types/organization/organization-list.ts +0 -8
- package/server/graphql/types/organization/organization-patch.ts +0 -11
- package/server/graphql/types/organization/organization.ts +0 -16
- package/server/graphql/types/organization-staff/index.ts +0 -19
- package/server/graphql/types/organization-staff/new-organization-staff.ts +0 -8
- package/server/graphql/types/organization-staff/organization-staff-list.ts +0 -8
- package/server/graphql/types/organization-staff/organization-staff-patch.ts +0 -15
- package/server/graphql/types/organization-staff/organization-staff.ts +0 -21
- package/server/graphql/types/plantation-inventory/index.ts +0 -14
- package/server/graphql/types/plantation-inventory/new-plantation-inventory.ts +0 -8
- package/server/graphql/types/plantation-inventory/plantation-inventory-list.ts +0 -8
- package/server/graphql/types/plantation-inventory/plantation-inventory-patch.ts +0 -10
- package/server/graphql/types/plantation-inventory/plantation-inventory.ts +0 -22
- package/server/graphql/types/plantation-setting/index.ts +0 -21
- package/server/graphql/types/plantation-setting/new-plantation-setting.ts +0 -10
- package/server/graphql/types/plantation-setting/plantation-setting-list.ts +0 -8
- package/server/graphql/types/plantation-setting/plantation-setting-patch.ts +0 -12
- package/server/graphql/types/plantation-setting/plantation-setting.ts +0 -16
- package/server/graphql/types/ramp/index.ts +0 -18
- package/server/graphql/types/ramp/new-ramp.ts +0 -8
- package/server/graphql/types/ramp/ramp-list.ts +0 -8
- package/server/graphql/types/ramp/ramp-patch.ts +0 -12
- package/server/graphql/types/ramp/ramp.ts +0 -17
- package/server/graphql/types/record-transaction/index.ts +0 -14
- package/server/graphql/types/record-transaction/new-record-transaction.ts +0 -8
- package/server/graphql/types/record-transaction/record-transaction-list.ts +0 -8
- package/server/graphql/types/record-transaction/record-transaction-patch.ts +0 -10
- package/server/graphql/types/record-transaction/record-transaction.ts +0 -24
- package/server/graphql/types/report/daily-ffb-dispatch-production-report-list.ts +0 -8
- package/server/graphql/types/report/daily-ffb-dispatch-production-report.ts +0 -9
- package/server/graphql/types/report/daily-production-report-list.ts +0 -8
- package/server/graphql/types/report/daily-production-report.ts +0 -23
- package/server/graphql/types/report/daily-staff-harvest-report-list.ts +0 -8
- package/server/graphql/types/report/daily-staff-harvest-report.ts +0 -10
- package/server/graphql/types/report/index.ts +0 -62
- package/server/graphql/types/report/monthly-block-dispatch-report-list.ts +0 -7
- package/server/graphql/types/report/monthly-block-dispatch-report.ts +0 -13
- package/server/graphql/types/report/monthly-dispatch-summary-report-list.ts +0 -7
- package/server/graphql/types/report/monthly-dispatch-summary-report.ts +0 -19
- package/server/graphql/types/report/monthly-ffb-sale-report-list.ts +0 -7
- package/server/graphql/types/report/monthly-ffb-sale-report.ts +0 -18
- package/server/graphql/types/report/monthly-production-report-list.ts +0 -8
- package/server/graphql/types/report/monthly-production-report.ts +0 -25
- package/server/graphql/types/report/yearly-production-report-list.ts +0 -8
- package/server/graphql/types/report/yearly-production-report.ts +0 -18
- package/server/graphql/types/truck/index.ts +0 -18
- package/server/graphql/types/truck/new-truck.ts +0 -8
- package/server/graphql/types/truck/truck-list.ts +0 -8
- package/server/graphql/types/truck/truck-patch.ts +0 -11
- package/server/graphql/types/truck/truck.ts +0 -16
- package/server/index.ts +0 -6
- package/server/middlewares/index.ts +0 -3
- package/server/migrations/index.ts +0 -9
- package/server/routes.ts +0 -7
- package/server/utils/core-values.ts +0 -98
- package/server/utils/datetime-util.ts +0 -39
- package/server/utils/index.ts +0 -4
- package/server/utils/no-generator.ts +0 -64
- package/server/utils/transaction-util.ts +0 -101
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { EntityManager } from 'typeorm'
|
|
2
|
-
|
|
3
|
-
import { Domain } from '@things-factory/shell'
|
|
4
|
-
|
|
5
|
-
import { DailyLoadingRamp } from '../../../entities'
|
|
6
|
-
|
|
7
|
-
export const deleteDailyLoadingRamp = {
|
|
8
|
-
async deleteDailyLoadingRamp(_: any, { name }, context: ResolverContext) {
|
|
9
|
-
const { domain, tx } = context.state
|
|
10
|
-
|
|
11
|
-
await tx.getRepository(DailyLoadingRamp).delete({ domain, name })
|
|
12
|
-
|
|
13
|
-
return true
|
|
14
|
-
}
|
|
15
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { Query } from './daily-loading-ramp-query'
|
|
2
|
-
|
|
3
|
-
import { updateDailyLoadingRamp } from './update-daily-loading-ramp'
|
|
4
|
-
import { deleteDailyLoadingRamp } from './delete-daily-loading-ramp'
|
|
5
|
-
|
|
6
|
-
export const DailyLoadingRampResolver = {
|
|
7
|
-
Query,
|
|
8
|
-
Mutation: {
|
|
9
|
-
...updateDailyLoadingRamp,
|
|
10
|
-
...deleteDailyLoadingRamp
|
|
11
|
-
}
|
|
12
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { DailyLoadingRamp } from '../../../entities'
|
|
2
|
-
|
|
3
|
-
export const updateDailyLoadingRamp = {
|
|
4
|
-
async updateDailyLoadingRamp(_: any, { name, patch }, context: ResolverContext) {
|
|
5
|
-
const { domain, tx, user } = context.state
|
|
6
|
-
|
|
7
|
-
const repository = tx.getRepository(DailyLoadingRamp)
|
|
8
|
-
const dailyLoadingRamp = await repository.findOne({
|
|
9
|
-
where: { domain: { id: domain.id }, name }
|
|
10
|
-
})
|
|
11
|
-
|
|
12
|
-
return await repository.save({
|
|
13
|
-
...dailyLoadingRamp,
|
|
14
|
-
...patch,
|
|
15
|
-
updater: user
|
|
16
|
-
})
|
|
17
|
-
}
|
|
18
|
-
}
|
|
@@ -1,245 +0,0 @@
|
|
|
1
|
-
import { EntityManager } from 'typeorm'
|
|
2
|
-
|
|
3
|
-
// import { buildQuery, ListParam } from '@things-factory/shell'
|
|
4
|
-
|
|
5
|
-
export const Query = {
|
|
6
|
-
/**
|
|
7
|
-
* @param blockId: id of the block
|
|
8
|
-
* @param yearAndMonth: the format will be something like 202001; combination of year 2020 and month 01
|
|
9
|
-
* @returns tonnage data with its sorted date
|
|
10
|
-
*/
|
|
11
|
-
async monthlyTonnageProductions(_: any, { blockId, yearAndMonth }, context: ResolverContext) {
|
|
12
|
-
try {
|
|
13
|
-
const { tx } = context.state
|
|
14
|
-
|
|
15
|
-
const year = parseInt(yearAndMonth.substring(0, 4))
|
|
16
|
-
const month = parseInt(yearAndMonth.substring(4))
|
|
17
|
-
|
|
18
|
-
let data: any[] = await getDailyProductionData(blockId, year, month, tx)
|
|
19
|
-
let result = []
|
|
20
|
-
|
|
21
|
-
result = data.map(itm => {
|
|
22
|
-
return {
|
|
23
|
-
...itm,
|
|
24
|
-
blockId,
|
|
25
|
-
tonnage: itm.todayWeightCollected,
|
|
26
|
-
year: itm.dateDay.getFullYear(),
|
|
27
|
-
month: itm.dateDay.getMonth(),
|
|
28
|
-
date: itm.dateDay.toLocaleString('default', { day: '2-digit', month: 'short' })
|
|
29
|
-
}
|
|
30
|
-
})
|
|
31
|
-
|
|
32
|
-
return result
|
|
33
|
-
} catch (ex) {}
|
|
34
|
-
},
|
|
35
|
-
|
|
36
|
-
async monthlyYields(_: any, { blockId, yearAndMonth }, context: ResolverContext) {
|
|
37
|
-
try {
|
|
38
|
-
const { tx } = context.state
|
|
39
|
-
|
|
40
|
-
const year = parseInt(yearAndMonth.substring(0, 4))
|
|
41
|
-
const month = parseInt(yearAndMonth.substring(4))
|
|
42
|
-
|
|
43
|
-
let data: any[] = await getDailyProductionData(blockId, year, month, tx)
|
|
44
|
-
let result = []
|
|
45
|
-
|
|
46
|
-
result = data.map(itm => {
|
|
47
|
-
return {
|
|
48
|
-
...itm,
|
|
49
|
-
blockId,
|
|
50
|
-
yield: (itm.todayHectareCover != 0 ? itm.todayWeightCollected / itm.todayHectareCover : 0).toFixed(4),
|
|
51
|
-
year: itm.dateDay.getFullYear(),
|
|
52
|
-
month: itm.dateDay.getMonth(),
|
|
53
|
-
date: itm.dateDay.toLocaleString('default', { day: '2-digit', month: 'short' })
|
|
54
|
-
}
|
|
55
|
-
})
|
|
56
|
-
|
|
57
|
-
return result
|
|
58
|
-
} catch (ex) {}
|
|
59
|
-
},
|
|
60
|
-
|
|
61
|
-
async weeklyBunchesCount(_: any, { targetDate }, context: ResolverContext) {
|
|
62
|
-
if (!targetDate || targetDate == '') targetDate = new Date()
|
|
63
|
-
|
|
64
|
-
let bunchesCount = []
|
|
65
|
-
|
|
66
|
-
for (let i = 0; i < 7; i++) {
|
|
67
|
-
bunchesCount.push({
|
|
68
|
-
date: new Date(targetDate).toLocaleString('default', { day: '2-digit', month: 'short' }),
|
|
69
|
-
harvestedCount: 0,
|
|
70
|
-
collectedCount: 0
|
|
71
|
-
// harvestedCount: Math.floor(Math.random() * 1000) + 500,
|
|
72
|
-
// collectedCount: Math.floor(Math.random() * 500) + 50
|
|
73
|
-
})
|
|
74
|
-
targetDate.setDate(targetDate.getDate() - 1)
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
return bunchesCount.reverse()
|
|
78
|
-
},
|
|
79
|
-
|
|
80
|
-
async tonnageAndBunchesInventories(_: any, { something }, context: ResolverContext) {
|
|
81
|
-
return {
|
|
82
|
-
bunches: 0,
|
|
83
|
-
tonnage: 0
|
|
84
|
-
// bunches: Math.floor(Math.random() * 10000) + 500,
|
|
85
|
-
// tonnage: Math.floor(Math.random() * 10000) + 500
|
|
86
|
-
}
|
|
87
|
-
},
|
|
88
|
-
|
|
89
|
-
async productionsOverview(_: any, { something }, context: ResolverContext) {
|
|
90
|
-
return {
|
|
91
|
-
averageBunchWeight: 0,
|
|
92
|
-
bunchesCount: 0,
|
|
93
|
-
tonnageWeighed: 0
|
|
94
|
-
// averageBunchWeight: Math.floor(Math.random() * 150) + 70,
|
|
95
|
-
// bunchesCount: Math.floor(Math.random() * 10000) + 500,
|
|
96
|
-
// tonnageWeighed: Math.floor(Math.random() * 10000) + 500
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
export async function getDailyProductionData(
|
|
102
|
-
blockId: String,
|
|
103
|
-
year: number,
|
|
104
|
-
month: number,
|
|
105
|
-
tx: EntityManager
|
|
106
|
-
): Promise<any> {
|
|
107
|
-
await tx.query(`
|
|
108
|
-
CREATE TEMP TABLE temp_blocks on commit drop AS (
|
|
109
|
-
WITH RECURSIVE b AS (
|
|
110
|
-
SELECT b.id AS block_id, * FROM blocks b
|
|
111
|
-
WHERE b.deleted_at IS null
|
|
112
|
-
UNION ALL
|
|
113
|
-
SELECT b.id AS block_id, cb.* FROM blocks cb
|
|
114
|
-
INNER JOIN b ON b.id = cb.parent_block_id
|
|
115
|
-
WHERE cb.deleted_at IS null
|
|
116
|
-
)
|
|
117
|
-
SELECT block_id, id, name FROM b
|
|
118
|
-
${blockId != 'all-blocks' && blockId != '' ? `WHERE block_id = '${blockId}' or id = '${blockId}'` : ``}
|
|
119
|
-
GROUP BY block_id, id, name
|
|
120
|
-
ORDER BY block_id, id, name
|
|
121
|
-
);
|
|
122
|
-
`)
|
|
123
|
-
|
|
124
|
-
let fromDate = new Date(year, month - 1, 1)
|
|
125
|
-
let toDate = new Date(year, month, 1)
|
|
126
|
-
toDate.setDate(toDate.getDate() - 1)
|
|
127
|
-
|
|
128
|
-
let fromDateString = [fromDate.getFullYear().toString(), String(fromDate.getMonth() + 1).padStart(2, '0'), '01'].join(
|
|
129
|
-
'-'
|
|
130
|
-
)
|
|
131
|
-
|
|
132
|
-
let toDateString = [
|
|
133
|
-
toDate.getFullYear().toString(),
|
|
134
|
-
String(toDate.getMonth() + 1).padStart(2, '0'),
|
|
135
|
-
String(toDate.getDate()).padStart(2, '0')
|
|
136
|
-
].join('-')
|
|
137
|
-
|
|
138
|
-
await tx.query(
|
|
139
|
-
`
|
|
140
|
-
CREATE TEMP TABLE temp_records on commit drop AS (
|
|
141
|
-
select blk.block_id, coalesce(sum(field_bunches),0) AS today_field_bunches,
|
|
142
|
-
round(coalesce(sum(ramp_weight),0)::numeric,4) AS today_ramp_weight,
|
|
143
|
-
sum(case when transaction_type = 'HARVEST' OR transaction_type = 'BUNCHES_ADJUSTMENT' then field_bunches else 0 end) as today_bunch_harvest,
|
|
144
|
-
sum(case when transaction_type = 'LOADING' OR transaction_type = 'LOADING_ADJUSTMENT' then -field_bunches else 0 end) as today_bunch_collected,
|
|
145
|
-
round(sum(case when transaction_type = 'LOADING' OR transaction_type = 'LOADING_ADJUSTMENT' then ramp_weight else 0 end)::numeric,4) as today_ramp_weight_collected,
|
|
146
|
-
round(sum(case when transaction_type = 'DISPATCHMENT' OR transaction_type = 'DISPATCHMENT_ADJUSTMENT' then -ramp_weight else 0 end)::numeric,4) as today_weight_dispatch,
|
|
147
|
-
transaction_date
|
|
148
|
-
from record_transactions t2
|
|
149
|
-
inner join temp_blocks blk on blk.id = t2.block_id
|
|
150
|
-
where transaction_date <= $1
|
|
151
|
-
group by blk.block_id, transaction_date
|
|
152
|
-
)
|
|
153
|
-
`,
|
|
154
|
-
[toDateString]
|
|
155
|
-
)
|
|
156
|
-
|
|
157
|
-
await tx.query(
|
|
158
|
-
`
|
|
159
|
-
create temp table temp_daily_production_data on commit drop as (
|
|
160
|
-
select *,
|
|
161
|
-
prev_bunch_bal_in_field + today_bunch_harvest as today_bunch_in_field,
|
|
162
|
-
prev_bunch_bal_in_field + today_bunch_harvest - today_bunch_collected as today_bunch_bal_in_field,
|
|
163
|
-
prev_weight_bal_in_ramp + today_ramp_weight_collected - today_weight_dispatch as today_weight_bal_in_ramp FROM (
|
|
164
|
-
select md.dateDay as date_day,
|
|
165
|
-
coalesce(
|
|
166
|
-
(
|
|
167
|
-
select sum(today_field_bunches) from temp_records t2
|
|
168
|
-
where transaction_date::timestamp < md.dateDay
|
|
169
|
-
)
|
|
170
|
-
, 0) as prev_bunch_bal_in_field,
|
|
171
|
-
coalesce(
|
|
172
|
-
(
|
|
173
|
-
select sum(today_ramp_weight) from temp_records t2
|
|
174
|
-
where transaction_date::timestamp < md.dateDay
|
|
175
|
-
)
|
|
176
|
-
, 0) as prev_weight_bal_in_ramp,
|
|
177
|
-
coalesce(today_bunch_harvest, 0) as today_bunch_harvest,
|
|
178
|
-
coalesce(sum(today_bunch_harvest) over (order by dateDay asc rows between unbounded preceding and current row), 0) as to_date_bunch_harvest,
|
|
179
|
-
coalesce(today_bunch_collected, 0) as today_bunch_collected,
|
|
180
|
-
coalesce(sum(today_bunch_collected) over (order by dateDay asc rows between unbounded preceding and current row), 0) as to_date_bunch_collected,
|
|
181
|
-
coalesce(today_ramp_weight_collected, 0) as today_ramp_weight_collected,
|
|
182
|
-
coalesce(sum(today_ramp_weight_collected) over (order by dateDay asc rows between unbounded preceding and current row), 0) as to_date_ramp_weight_collected,
|
|
183
|
-
coalesce(today_weight_dispatch, 0) as today_weight_dispatch,
|
|
184
|
-
coalesce(sum(today_weight_dispatch) over (order by dateDay asc rows between unbounded preceding and current row), 0) as to_date_weight_dispatch,
|
|
185
|
-
coalesce(tot.today_out_turn, 0) as today_out_turn,
|
|
186
|
-
coalesce(sum(tot.today_out_turn) over (order by dateDay asc rows between unbounded preceding and current row), 0) as to_date_out_turn,
|
|
187
|
-
${
|
|
188
|
-
blockId != 'all-blocks' && blockId != '' ? `(select name from blocks b2 WHERE id = '${blockId}')` : `''`
|
|
189
|
-
} as block,
|
|
190
|
-
coalesce(thr.today_harvesting_round, 0) as today_harvesting_round,
|
|
191
|
-
coalesce(thr.today_hectare_cover, 0) as today_hectare_cover
|
|
192
|
-
from
|
|
193
|
-
(select generate_series((date '${fromDateString}')::timestamp, (date '${toDateString}')::timestamp, interval '1 day')::date as dateDay) as md
|
|
194
|
-
left join (
|
|
195
|
-
select * from temp_records trx
|
|
196
|
-
where transaction_date between $1 and $2
|
|
197
|
-
order by transaction_date
|
|
198
|
-
) as dt on dt.transaction_date::date = md.dateDay
|
|
199
|
-
LEFT JOIN (
|
|
200
|
-
select sum(harvesting_round) AS today_harvesting_round, sum(coverage) AS today_hectare_cover, harvest_date
|
|
201
|
-
from daily_harvests dh
|
|
202
|
-
inner join temp_blocks blk on blk.id = dh.block_id
|
|
203
|
-
where harvest_date between $1 and $2
|
|
204
|
-
group by blk.block_id, harvest_date
|
|
205
|
-
) as thr ON thr.harvest_date::date = md.dateDay
|
|
206
|
-
LEFT JOIN (
|
|
207
|
-
select count(*) AS today_out_turn, dh.harvest_date
|
|
208
|
-
from daily_harvest_details dhd
|
|
209
|
-
inner join daily_harvests dh on dh.id = dhd.daily_harvest_id
|
|
210
|
-
inner join temp_blocks blk on blk.id = dh.block_id
|
|
211
|
-
where dh.harvest_date between $1 and $2
|
|
212
|
-
GROUP BY blk.block_id, dh.harvest_date
|
|
213
|
-
) as tot ON tot.harvest_date::date = md.dateDay
|
|
214
|
-
) dt
|
|
215
|
-
)`,
|
|
216
|
-
[fromDateString, toDateString]
|
|
217
|
-
)
|
|
218
|
-
|
|
219
|
-
const result: any = await tx.query(`
|
|
220
|
-
select * from temp_daily_production_data dt
|
|
221
|
-
`)
|
|
222
|
-
|
|
223
|
-
return result.map(itm => {
|
|
224
|
-
return {
|
|
225
|
-
block: itm.block,
|
|
226
|
-
dateDay: itm.date_day,
|
|
227
|
-
diffInBunches: parseFloat(itm.diff_in_bunches).toFixed(1),
|
|
228
|
-
prevBunchBalInField: parseFloat(itm.prev_bunch_bal_in_field).toFixed(1),
|
|
229
|
-
prevWeightBalInRamp: parseFloat(itm.prev_weight_bal_in_ramp).toFixed(4),
|
|
230
|
-
toDateBunchHarvest: parseFloat(itm.to_date_bunch_harvest).toFixed(1),
|
|
231
|
-
toDateOutTurn: itm.to_date_out_turn,
|
|
232
|
-
toDateWeightDispatch: parseFloat(itm.to_date_weight_dispatch).toFixed(4),
|
|
233
|
-
todayBunchBalInField: parseFloat(itm.today_bunch_bal_in_field).toFixed(1),
|
|
234
|
-
todayBunchCollected: parseFloat(itm.today_bunch_collected).toFixed(1),
|
|
235
|
-
todayBunchHarvest: parseFloat(itm.today_bunch_harvest).toFixed(1),
|
|
236
|
-
todayBunchInField: parseFloat(itm.today_bunch_in_field).toFixed(1),
|
|
237
|
-
todayHarvestingRound: itm.today_harvesting_round,
|
|
238
|
-
todayHectareCover: parseFloat(itm.today_hectare_cover).toFixed(4),
|
|
239
|
-
todayOutTurn: itm.today_out_turn,
|
|
240
|
-
todayWeightCollected: parseFloat(itm.today_ramp_weight_collected).toFixed(4),
|
|
241
|
-
todayWeightBalInRamp: parseFloat(itm.today_weight_bal_in_ramp).toFixed(4),
|
|
242
|
-
todayWeightDispatch: parseFloat(itm.today_weight_dispatch).toFixed(4)
|
|
243
|
-
}
|
|
244
|
-
})
|
|
245
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
export * from './block-detail'
|
|
2
|
-
export * from './block'
|
|
3
|
-
export * from './daily-block-detail'
|
|
4
|
-
export * from './daily-dispatch-detail'
|
|
5
|
-
export * from './daily-dispatch'
|
|
6
|
-
export * from './daily-harvest-detail'
|
|
7
|
-
export * from './daily-harvest'
|
|
8
|
-
export * from './daily-loading-detail'
|
|
9
|
-
export * from './daily-loading-ramp'
|
|
10
|
-
export * from './daily-loading'
|
|
11
|
-
export * from './dashboard'
|
|
12
|
-
export * from './organization-staff'
|
|
13
|
-
export * from './organization'
|
|
14
|
-
export * from './plantation-inventory'
|
|
15
|
-
export * from './plantation-setting'
|
|
16
|
-
export * from './ramp'
|
|
17
|
-
export * from './record-transaction'
|
|
18
|
-
export * from './report'
|
|
19
|
-
|
|
20
|
-
export * from './truck'
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { In, IsNull } from 'typeorm'
|
|
2
|
-
|
|
3
|
-
import { Organization, OrganizationStaff } from '../../../entities'
|
|
4
|
-
|
|
5
|
-
export const deleteOrganizations = {
|
|
6
|
-
async deleteOrganizations(_: any, { ids }, context: ResolverContext) {
|
|
7
|
-
try {
|
|
8
|
-
const { tx, domain } = context.state
|
|
9
|
-
|
|
10
|
-
const organization = await tx.getRepository(Organization).find({ where: { id: In(ids), deletedAt: IsNull() } })
|
|
11
|
-
|
|
12
|
-
await tx.getRepository(Organization).update(
|
|
13
|
-
{
|
|
14
|
-
domain: { id: domain.id },
|
|
15
|
-
id: In(ids)
|
|
16
|
-
},
|
|
17
|
-
{
|
|
18
|
-
deletedAt: new Date()
|
|
19
|
-
}
|
|
20
|
-
)
|
|
21
|
-
|
|
22
|
-
await Promise.all(
|
|
23
|
-
organization.map(async org => {
|
|
24
|
-
await tx.getRepository(OrganizationStaff).update(
|
|
25
|
-
{
|
|
26
|
-
domain: { id: domain.id },
|
|
27
|
-
organization: { id: org.id }
|
|
28
|
-
},
|
|
29
|
-
{
|
|
30
|
-
deletedAt: new Date()
|
|
31
|
-
}
|
|
32
|
-
)
|
|
33
|
-
})
|
|
34
|
-
)
|
|
35
|
-
return true
|
|
36
|
-
} catch (error) {
|
|
37
|
-
throw error
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { Query } from './organization-query'
|
|
2
|
-
import { updateMultipleOrganizationResolver } from './update-multiple-organization'
|
|
3
|
-
import { deleteOrganizations } from './delete-organizations'
|
|
4
|
-
|
|
5
|
-
export const OrganizationResolver = {
|
|
6
|
-
Query,
|
|
7
|
-
Mutation: {
|
|
8
|
-
...updateMultipleOrganizationResolver,
|
|
9
|
-
...deleteOrganizations
|
|
10
|
-
}
|
|
11
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { IsNull } from 'typeorm'
|
|
2
|
-
|
|
3
|
-
import { buildQuery, ListParam } from '@things-factory/shell'
|
|
4
|
-
|
|
5
|
-
import { Organization as OrganizationEntity } from '../../../entities'
|
|
6
|
-
|
|
7
|
-
export const Query = {
|
|
8
|
-
async organization(_: any, { name }, context: ResolverContext) {
|
|
9
|
-
const { tx, domain } = context.state
|
|
10
|
-
|
|
11
|
-
return await tx.getRepository(OrganizationEntity).findOne({
|
|
12
|
-
where: { domain: { id: domain.id }, name, deletedAt: IsNull() },
|
|
13
|
-
relations: ['domain', 'creator', 'updater']
|
|
14
|
-
})
|
|
15
|
-
},
|
|
16
|
-
|
|
17
|
-
async organizations(_: any, params: ListParam, context: ResolverContext) {
|
|
18
|
-
const { tx } = context.state
|
|
19
|
-
|
|
20
|
-
const queryBuilder = tx.getRepository(OrganizationEntity).createQueryBuilder()
|
|
21
|
-
buildQuery(queryBuilder, params, context)
|
|
22
|
-
|
|
23
|
-
queryBuilder
|
|
24
|
-
.leftJoinAndSelect('Organization.domain', 'Domain')
|
|
25
|
-
.leftJoinAndSelect('Organization.creator', 'Creator')
|
|
26
|
-
.leftJoinAndSelect('Organization.updater', 'Updater')
|
|
27
|
-
|
|
28
|
-
if (params.filters?.length > 0) queryBuilder.andWhere('Organization.deletedAt IS NULL')
|
|
29
|
-
else queryBuilder.where('Organization.deletedAt IS NULL')
|
|
30
|
-
|
|
31
|
-
const [items, total] = await queryBuilder.getManyAndCount()
|
|
32
|
-
|
|
33
|
-
return { items, total }
|
|
34
|
-
}
|
|
35
|
-
}
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { ORGANIZATION_STATUS } from '../../../constants'
|
|
2
|
-
import { Organization } from '../../../entities'
|
|
3
|
-
|
|
4
|
-
export const updateMultipleOrganizationResolver = {
|
|
5
|
-
updateMultipleOrganization
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export async function updateMultipleOrganization(_: any, { patches }, context: ResolverContext) {
|
|
9
|
-
const { tx, domain, user } = context.state
|
|
10
|
-
|
|
11
|
-
let results = []
|
|
12
|
-
const _createRecords = patches.filter((patch: any) => patch.cuFlag.toUpperCase() === '+')
|
|
13
|
-
const _updateRecords = patches.filter((patch: any) => patch.cuFlag.toUpperCase() === 'M')
|
|
14
|
-
const organizationRepo = tx.getRepository(Organization)
|
|
15
|
-
|
|
16
|
-
if (_createRecords.length > 0) {
|
|
17
|
-
for (let i = 0; i < _createRecords.length; i++) {
|
|
18
|
-
const newRecord = _createRecords[i]
|
|
19
|
-
|
|
20
|
-
const result = await organizationRepo.save({
|
|
21
|
-
...newRecord,
|
|
22
|
-
domain,
|
|
23
|
-
status: ORGANIZATION_STATUS.ACTIVE,
|
|
24
|
-
creator: user,
|
|
25
|
-
updater: user
|
|
26
|
-
})
|
|
27
|
-
|
|
28
|
-
results.push({ ...result, cuFlag: '+' })
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
if (_updateRecords.length > 0) {
|
|
33
|
-
for (let i = 0; i < _updateRecords.length; i++) {
|
|
34
|
-
const newRecord = _updateRecords[i]
|
|
35
|
-
const organization = await organizationRepo.findOneBy({ id: newRecord.id })
|
|
36
|
-
|
|
37
|
-
const result = await organizationRepo.save({
|
|
38
|
-
...organization,
|
|
39
|
-
...newRecord,
|
|
40
|
-
updater: user
|
|
41
|
-
})
|
|
42
|
-
|
|
43
|
-
results.push({ ...result, cuFlag: 'M' })
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
return results
|
|
48
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { In } from 'typeorm'
|
|
2
|
-
|
|
3
|
-
import { OrganizationStaff } from '../../../entities'
|
|
4
|
-
|
|
5
|
-
export const deleteOrganizationStaffs = {
|
|
6
|
-
async deleteOrganizationStaffs(_: any, { ids }, context: ResolverContext) {
|
|
7
|
-
const { tx, domain } = context.state
|
|
8
|
-
await tx.getRepository(OrganizationStaff).update(
|
|
9
|
-
{
|
|
10
|
-
domain: { id: domain.id },
|
|
11
|
-
id: In(ids)
|
|
12
|
-
},
|
|
13
|
-
{
|
|
14
|
-
deletedAt: new Date()
|
|
15
|
-
}
|
|
16
|
-
)
|
|
17
|
-
|
|
18
|
-
return true
|
|
19
|
-
}
|
|
20
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { Query } from './organization-staff-query'
|
|
2
|
-
|
|
3
|
-
import { updateMultipleOrganizationStaffResolver } from './update-multiple-organization-staff'
|
|
4
|
-
import { deleteOrganizationStaffs } from './delete-organization-staffs'
|
|
5
|
-
|
|
6
|
-
export const OrganizationStaffResolver = {
|
|
7
|
-
Query,
|
|
8
|
-
Mutation: {
|
|
9
|
-
...updateMultipleOrganizationStaffResolver,
|
|
10
|
-
...deleteOrganizationStaffs
|
|
11
|
-
}
|
|
12
|
-
}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { IsNull } from 'typeorm'
|
|
2
|
-
|
|
3
|
-
import { buildQuery, ListParam } from '@things-factory/shell'
|
|
4
|
-
|
|
5
|
-
import { OrganizationStaff as OrganizationStaffEntity } from '../../../entities'
|
|
6
|
-
|
|
7
|
-
export const Query = {
|
|
8
|
-
async organizationStaff(_: any, { name }, context: ResolverContext) {
|
|
9
|
-
const { tx, domain } = context.state
|
|
10
|
-
|
|
11
|
-
return await tx.getRepository(OrganizationStaffEntity).findOne({
|
|
12
|
-
where: { domain: { id: domain.id }, name, deletedAt: IsNull() },
|
|
13
|
-
relations: ['domain', 'organization', 'creator', 'updater']
|
|
14
|
-
})
|
|
15
|
-
},
|
|
16
|
-
|
|
17
|
-
async organizationStaffs(_: any, params: ListParam, context: ResolverContext) {
|
|
18
|
-
const { tx } = context.state
|
|
19
|
-
|
|
20
|
-
const queryBuilder = await tx.getRepository(OrganizationStaffEntity).createQueryBuilder()
|
|
21
|
-
buildQuery(queryBuilder, params, context)
|
|
22
|
-
|
|
23
|
-
queryBuilder
|
|
24
|
-
.leftJoinAndSelect('OrganizationStaff.domain', 'Domain')
|
|
25
|
-
.leftJoinAndSelect('OrganizationStaff.organization', 'Organization')
|
|
26
|
-
.leftJoinAndSelect('OrganizationStaff.creator', 'Creator')
|
|
27
|
-
.leftJoinAndSelect('OrganizationStaff.updater', 'Updater')
|
|
28
|
-
|
|
29
|
-
if (params.filters?.length > 0) queryBuilder.andWhere('OrganizationStaff.deletedAt IS NULL')
|
|
30
|
-
else queryBuilder.where('OrganizationStaff.deletedAt IS NULL')
|
|
31
|
-
|
|
32
|
-
let [items, total] = await queryBuilder.getManyAndCount()
|
|
33
|
-
|
|
34
|
-
items = items.map(item => {
|
|
35
|
-
return {
|
|
36
|
-
...item,
|
|
37
|
-
organizationName: item.organization?.name
|
|
38
|
-
}
|
|
39
|
-
})
|
|
40
|
-
|
|
41
|
-
return { items, total }
|
|
42
|
-
}
|
|
43
|
-
}
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import { ORGANIZATION_STAFF_STATUS } from '../../../constants'
|
|
2
|
-
import { Organization, OrganizationStaff } from '../../../entities'
|
|
3
|
-
|
|
4
|
-
export const updateMultipleOrganizationStaffResolver = {
|
|
5
|
-
updateMultipleOrganizationStaff
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export async function updateMultipleOrganizationStaff(_: any, { patches }, context: ResolverContext) {
|
|
9
|
-
const { tx, domain, user } = context.state
|
|
10
|
-
|
|
11
|
-
let results = []
|
|
12
|
-
const _createRecords = patches.filter((patch: any) => patch.cuFlag.toUpperCase() === '+')
|
|
13
|
-
const _updateRecords = patches.filter((patch: any) => patch.cuFlag.toUpperCase() === 'M')
|
|
14
|
-
const organizationStaffRepo = tx.getRepository(OrganizationStaff)
|
|
15
|
-
|
|
16
|
-
if (_createRecords.length > 0) {
|
|
17
|
-
for (let i = 0; i < _createRecords.length; i++) {
|
|
18
|
-
const newRecord = _createRecords[i]
|
|
19
|
-
|
|
20
|
-
const organization = await tx.getRepository(Organization).findOneOrFail({
|
|
21
|
-
where: { id: newRecord?.organization?.id }
|
|
22
|
-
})
|
|
23
|
-
|
|
24
|
-
const result = await organizationStaffRepo.save({
|
|
25
|
-
...newRecord,
|
|
26
|
-
organization,
|
|
27
|
-
domain,
|
|
28
|
-
status: ORGANIZATION_STAFF_STATUS.ACTIVE,
|
|
29
|
-
creator: user,
|
|
30
|
-
updater: user
|
|
31
|
-
})
|
|
32
|
-
|
|
33
|
-
results.push({ ...result, cuFlag: '+' })
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
if (_updateRecords.length > 0) {
|
|
38
|
-
for (let i = 0; i < _updateRecords.length; i++) {
|
|
39
|
-
let newRecord = _updateRecords[i]
|
|
40
|
-
const organizationStaff = await organizationStaffRepo.findOneBy({ id: newRecord.id })
|
|
41
|
-
|
|
42
|
-
if (newRecord?.organization?.id) {
|
|
43
|
-
const organization = await tx.getRepository(Organization).findOneOrFail({
|
|
44
|
-
where: { id: newRecord?.organization?.id }
|
|
45
|
-
})
|
|
46
|
-
newRecord = { ...newRecord, organization }
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
const result = await organizationStaffRepo.save({
|
|
50
|
-
...organizationStaff,
|
|
51
|
-
...newRecord,
|
|
52
|
-
updater: user
|
|
53
|
-
})
|
|
54
|
-
|
|
55
|
-
results.push({ ...result, cuFlag: 'M' })
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
return results
|
|
60
|
-
}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { buildQuery, ListParam } from '@things-factory/shell'
|
|
2
|
-
|
|
3
|
-
import { Block as BlockEntity, PlantationInventory as PlantationInventoryEntity } from '../../../entities'
|
|
4
|
-
|
|
5
|
-
export const Query = {
|
|
6
|
-
async plantationInventory(_: any, { blockId, type }, context: ResolverContext) {
|
|
7
|
-
const { tx, domain } = context.state
|
|
8
|
-
|
|
9
|
-
return await tx.getRepository(PlantationInventoryEntity).findOne({
|
|
10
|
-
where: {
|
|
11
|
-
domain: { id: domain.id },
|
|
12
|
-
block: { id: (await tx.getRepository(BlockEntity).findOne({ where: { id: blockId } })).id },
|
|
13
|
-
type
|
|
14
|
-
},
|
|
15
|
-
relations: ['domain', 'block', 'ramp', 'creator', 'updater']
|
|
16
|
-
})
|
|
17
|
-
},
|
|
18
|
-
|
|
19
|
-
async plantationInventories(_: any, params: ListParam, context: ResolverContext) {
|
|
20
|
-
const { tx } = context.state
|
|
21
|
-
|
|
22
|
-
const queryBuilder = tx.getRepository(PlantationInventoryEntity).createQueryBuilder()
|
|
23
|
-
buildQuery(queryBuilder, params, context)
|
|
24
|
-
|
|
25
|
-
let [items, total] = await queryBuilder
|
|
26
|
-
.leftJoinAndSelect('PlantationInventory.domain', 'Domain')
|
|
27
|
-
.leftJoinAndSelect('PlantationInventory.block', 'Block')
|
|
28
|
-
.leftJoinAndSelect('PlantationInventory.ramp', 'Ramp')
|
|
29
|
-
.leftJoinAndSelect('PlantationInventory.creator', 'Creator')
|
|
30
|
-
.leftJoinAndSelect('PlantationInventory.updater', 'Updater')
|
|
31
|
-
.getManyAndCount()
|
|
32
|
-
|
|
33
|
-
items = items.map((item: PlantationInventoryEntity) => {
|
|
34
|
-
return {
|
|
35
|
-
...item,
|
|
36
|
-
rampName: item?.ramp ? item.ramp.name : null,
|
|
37
|
-
rampId: item?.ramp ? item.ramp.id : null
|
|
38
|
-
}
|
|
39
|
-
})
|
|
40
|
-
|
|
41
|
-
return { items, total }
|
|
42
|
-
}
|
|
43
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { getRepository } from '@things-factory/shell'
|
|
2
|
-
|
|
3
|
-
import { PlantationSetting } from '../../../entities'
|
|
4
|
-
|
|
5
|
-
export const createPlantationSetting = {
|
|
6
|
-
async createPlantationSetting(_: any, { plantationSetting }, context: ResolverContext) {
|
|
7
|
-
const { domain, user } = context.state
|
|
8
|
-
|
|
9
|
-
return await getRepository(PlantationSetting).save({
|
|
10
|
-
...plantationSetting,
|
|
11
|
-
domain,
|
|
12
|
-
creator: user,
|
|
13
|
-
updater: user
|
|
14
|
-
})
|
|
15
|
-
}
|
|
16
|
-
}
|