拆分后台大厅汇总服务
This commit is contained in:
@@ -18,7 +18,6 @@ import {
|
|||||||
listWorkOrders,
|
listWorkOrders,
|
||||||
listWorkProductRules,
|
listWorkProductRules,
|
||||||
listWorkProductRuleMappings,
|
listWorkProductRuleMappings,
|
||||||
listWorkerUsers,
|
|
||||||
updateWorkOrder,
|
updateWorkOrder,
|
||||||
type WorkOrderRow,
|
type WorkOrderRow,
|
||||||
} from '../../repositories/worker-platform/index.js'
|
} from '../../repositories/worker-platform/index.js'
|
||||||
@@ -30,13 +29,11 @@ import { nowIso } from '../../utils/time.js'
|
|||||||
import { safeParseJson } from '../admin/admin-query-utils.js'
|
import { safeParseJson } from '../admin/admin-query-utils.js'
|
||||||
import { getWorkerFinanceConfig } from './worker-finance-config-service.js'
|
import { getWorkerFinanceConfig } from './worker-finance-config-service.js'
|
||||||
import { getWorkerProductMatchConfig } from './worker-product-match-config-service.js'
|
import { getWorkerProductMatchConfig } from './worker-product-match-config-service.js'
|
||||||
import { getWorkerHallConfig, saveWorkerHallConfig } from './worker-hall-config-service.js'
|
|
||||||
import {
|
import {
|
||||||
createWorkOrderMaterialAdminNotification,
|
createWorkOrderMaterialAdminNotification,
|
||||||
resolveAdminNotificationEntity,
|
resolveAdminNotificationEntity,
|
||||||
} from '../admin/admin-notification-service.js'
|
} from '../admin/admin-notification-service.js'
|
||||||
import {
|
import {
|
||||||
publishWorkerHallRealtimeRefresh,
|
|
||||||
publishWorkerWalletRealtimeChange,
|
publishWorkerWalletRealtimeChange,
|
||||||
publishWorkOrderRealtimeChange,
|
publishWorkOrderRealtimeChange,
|
||||||
} from '../realtime/realtime-event-service.js'
|
} from '../realtime/realtime-event-service.js'
|
||||||
@@ -577,55 +574,11 @@ export async function cancelAdminWorkOrder(
|
|||||||
return { order: mapWorkOrderAdmin(updated), action }
|
return { order: mapWorkOrderAdmin(updated), action }
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getAdminWorkerPlatformSummary() {
|
export {
|
||||||
const hallConfig = getWorkerHallConfig()
|
getAdminWorkerHallConfig,
|
||||||
const [pendingWorkers, pendingMaterial, openOrders, inProgressOrders] = await Promise.all([
|
getAdminWorkerPlatformSummary,
|
||||||
listWorkerUsers({ page: 1, pageSize: 1, status: 'pending_review' }),
|
saveAdminWorkerHallConfig,
|
||||||
listWorkOrders({ page: 1, pageSize: 1, statuses: [WORK_ORDER_STATUS.PENDING_MATERIAL] }),
|
} from './admin-worker-platform-summary-service.js'
|
||||||
listWorkOrders({
|
|
||||||
page: 1,
|
|
||||||
pageSize: 1,
|
|
||||||
statuses: [WORK_ORDER_STATUS.OPEN],
|
|
||||||
excludeFilledSharing: true,
|
|
||||||
}),
|
|
||||||
listWorkOrders({
|
|
||||||
page: 1,
|
|
||||||
pageSize: 1,
|
|
||||||
statuses: [WORK_ORDER_STATUS.IN_PROGRESS],
|
|
||||||
useOperationalStatus: true,
|
|
||||||
}),
|
|
||||||
])
|
|
||||||
return {
|
|
||||||
pendingWorkerCount: pendingWorkers.total,
|
|
||||||
pendingMaterialCount: pendingMaterial.total,
|
|
||||||
openOrderCount: Math.min(openOrders.total, hallConfig.maxVisibleOrders),
|
|
||||||
queuedHallOrderCount: Math.max(0, openOrders.total - hallConfig.maxVisibleOrders),
|
|
||||||
hallMaxVisibleOrders: hallConfig.maxVisibleOrders,
|
|
||||||
inProgressOrderCount: inProgressOrders.total,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function getAdminWorkerHallConfig() {
|
|
||||||
const config = getWorkerHallConfig()
|
|
||||||
const openOrders = await listWorkOrders({
|
|
||||||
page: 1,
|
|
||||||
pageSize: 1,
|
|
||||||
statuses: [WORK_ORDER_STATUS.OPEN],
|
|
||||||
excludeFilledSharing: true,
|
|
||||||
})
|
|
||||||
return {
|
|
||||||
...config,
|
|
||||||
visibleOrderCount: Math.min(openOrders.total, config.maxVisibleOrders),
|
|
||||||
queuedOrderCount: Math.max(0, openOrders.total - config.maxVisibleOrders),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function saveAdminWorkerHallConfig(rawValue: unknown) {
|
|
||||||
await saveWorkerHallConfig(rawValue)
|
|
||||||
const config = await getAdminWorkerHallConfig()
|
|
||||||
publishWorkerHallRealtimeRefresh()
|
|
||||||
return config
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function syncWorkerOrdersForSourceOrder(
|
export async function syncWorkerOrdersForSourceOrder(
|
||||||
order: OrderRow,
|
order: OrderRow,
|
||||||
|
|||||||
@@ -0,0 +1,54 @@
|
|||||||
|
import { WORK_ORDER_STATUS } from '../../domain/work-order-status.js'
|
||||||
|
import { listWorkOrders, listWorkerUsers } from '../../repositories/worker-platform/index.js'
|
||||||
|
import { publishWorkerHallRealtimeRefresh } from '../realtime/realtime-event-service.js'
|
||||||
|
import { getWorkerHallConfig, saveWorkerHallConfig } from './worker-hall-config-service.js'
|
||||||
|
|
||||||
|
export async function getAdminWorkerPlatformSummary() {
|
||||||
|
const hallConfig = getWorkerHallConfig()
|
||||||
|
const [pendingWorkers, pendingMaterial, openOrders, inProgressOrders] = await Promise.all([
|
||||||
|
listWorkerUsers({ page: 1, pageSize: 1, status: 'pending_review' }),
|
||||||
|
listWorkOrders({ page: 1, pageSize: 1, statuses: [WORK_ORDER_STATUS.PENDING_MATERIAL] }),
|
||||||
|
listWorkOrders({
|
||||||
|
page: 1,
|
||||||
|
pageSize: 1,
|
||||||
|
statuses: [WORK_ORDER_STATUS.OPEN],
|
||||||
|
excludeFilledSharing: true,
|
||||||
|
}),
|
||||||
|
listWorkOrders({
|
||||||
|
page: 1,
|
||||||
|
pageSize: 1,
|
||||||
|
statuses: [WORK_ORDER_STATUS.IN_PROGRESS],
|
||||||
|
useOperationalStatus: true,
|
||||||
|
}),
|
||||||
|
])
|
||||||
|
return {
|
||||||
|
pendingWorkerCount: pendingWorkers.total,
|
||||||
|
pendingMaterialCount: pendingMaterial.total,
|
||||||
|
openOrderCount: Math.min(openOrders.total, hallConfig.maxVisibleOrders),
|
||||||
|
queuedHallOrderCount: Math.max(0, openOrders.total - hallConfig.maxVisibleOrders),
|
||||||
|
hallMaxVisibleOrders: hallConfig.maxVisibleOrders,
|
||||||
|
inProgressOrderCount: inProgressOrders.total,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function getAdminWorkerHallConfig() {
|
||||||
|
const config = getWorkerHallConfig()
|
||||||
|
const openOrders = await listWorkOrders({
|
||||||
|
page: 1,
|
||||||
|
pageSize: 1,
|
||||||
|
statuses: [WORK_ORDER_STATUS.OPEN],
|
||||||
|
excludeFilledSharing: true,
|
||||||
|
})
|
||||||
|
return {
|
||||||
|
...config,
|
||||||
|
visibleOrderCount: Math.min(openOrders.total, config.maxVisibleOrders),
|
||||||
|
queuedOrderCount: Math.max(0, openOrders.total - config.maxVisibleOrders),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function saveAdminWorkerHallConfig(rawValue: unknown) {
|
||||||
|
await saveWorkerHallConfig(rawValue)
|
||||||
|
const config = await getAdminWorkerHallConfig()
|
||||||
|
publishWorkerHallRealtimeRefresh()
|
||||||
|
return config
|
||||||
|
}
|
||||||
@@ -33,6 +33,7 @@ export * from './admin-work-order-realtime-service.js'
|
|||||||
export * from './admin-work-order-material-service.js'
|
export * from './admin-work-order-material-service.js'
|
||||||
export * from './admin-mock-work-order-service.js'
|
export * from './admin-mock-work-order-service.js'
|
||||||
export * from './admin-work-order-management-service.js'
|
export * from './admin-work-order-management-service.js'
|
||||||
|
export * from './admin-worker-platform-summary-service.js'
|
||||||
export {
|
export {
|
||||||
acceptAdminWorkOrder,
|
acceptAdminWorkOrder,
|
||||||
acceptAdminWorkOrderShare,
|
acceptAdminWorkOrderShare,
|
||||||
|
|||||||
Reference in New Issue
Block a user