workOrderScheduling.ts 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. import service from '/@/utils/request';
  2. import { withAidopTenantParams } from './aidopTenant';
  3. export interface Paged<T> {
  4. total: number;
  5. page: number;
  6. pageSize: number;
  7. list: T[];
  8. }
  9. export interface WorkOrderSchedulingRow {
  10. id: number;
  11. priority?: string | null;
  12. workOrd?: string | null;
  13. lotSerial?: string | null;
  14. issueSite?: string | null;
  15. itemNum?: string | null;
  16. descr?: string | null;
  17. descr1?: string | null;
  18. qtyOrded?: number | null;
  19. locationStock?: number | null;
  20. qtyCompleted?: number | null;
  21. planDate?: string | null;
  22. prodDate?: string | null;
  23. status?: string | null;
  24. domain?: string | null;
  25. urgent?: number | null;
  26. }
  27. /** 生成生产排程计划 */
  28. export function productionSchedule(domain: string) {
  29. return service
  30. .post('/api/Production/scheduling/generate', null, { params: { domain }, timeout: 300000 })
  31. .then((r) => r.data);
  32. }
  33. /** 同步物料需求 */
  34. export function syncMaterialRequirement(domain: string) {
  35. return service
  36. .post('/api/WorkOrder/material-requirement/generate', null, { params: { domain } })
  37. .then((r) => r.data);
  38. }
  39. /** 优先级调整保存并重做资源检查 */
  40. export async function replenishmentWorkOrdCheckChangePriority(params: {
  41. workord: string;
  42. qty: string | number;
  43. instockdate: string;
  44. priority: string;
  45. domain: string;
  46. userAccount: string;
  47. lotSerial: string;
  48. }): Promise<void> {
  49. const res = await service.post('/api/Production/scheduling/update-priority-and-recheck', {
  50. workord: params.workord,
  51. qty: String(params.qty ?? ''),
  52. instockdate: params.instockdate ?? '',
  53. priority: params.priority ?? '',
  54. domain: params.domain,
  55. userAccount: params.userAccount,
  56. lotSerial: params.lotSerial ?? '',
  57. });
  58. const data = res.data as { message?: string } | undefined;
  59. const msg = String(data?.message ?? '').trim().toLowerCase();
  60. if (msg && msg !== 'ok') throw new Error(`接口返回异常:${data?.message}`);
  61. }
  62. export function fetchWorkOrderSchedulingList(params: Record<string, unknown>) {
  63. return service.get<Paged<WorkOrderSchedulingRow>>('/api/Production/scheduling/list', { params: withAidopTenantParams(params) }).then((r) => r.data);
  64. }
  65. export function closeWorkOrders(ids: string) {
  66. return service.post('/api/Production/scheduling/close', { ids }).then((r) => r.data);
  67. }
  68. export function saveWorkOrderScheduling(body: {
  69. workOrd: string;
  70. domain: string;
  71. qtyOrded?: number | null;
  72. priority?: string | null;
  73. lotSerial?: string | null;
  74. urgent?: number | null;
  75. }) {
  76. return service.post('/api/Production/scheduling/save', body).then((r) => r.data);
  77. }
  78. export function patchWorkOrderStatus(body: { id: number; domain: string; status: string }) {
  79. return service.post('/api/Production/scheduling/status', body).then((r) => r.data);
  80. }
  81. export function syncWorkRouting(body: { workOrd: string; domain: string }) {
  82. return service.post('/api/Production/scheduling/sync-routing', body).then((r) => r.data);
  83. }
  84. export function setWorkOrderUrgent(body: { workOrd: string; domain: string; urgent: number }) {
  85. return service.post('/api/Production/scheduling/urgent', body).then((r) => r.data);
  86. }
  87. export function fetchSchedulingEditPreview(workOrd: string, domain: string) {
  88. return service
  89. .get<{
  90. workOrd: string;
  91. itemNum: string;
  92. qtyOrded: number;
  93. priority: string;
  94. lotSerial: string;
  95. urgent: number;
  96. ordDate?: string | null;
  97. }>('/api/Production/scheduling/edit-preview', { params: { workOrd, domain } })
  98. .then((r) => r.data);
  99. }
  100. export function fetchSchedulingView(workOrd: string, domain: string) {
  101. return service
  102. .get<{
  103. master: Record<string, unknown>;
  104. routings: unknown[];
  105. details: unknown[];
  106. }>('/api/Production/scheduling/view', { params: { workOrd, domain } })
  107. .then((r) => r.data);
  108. }
  109. export function fetchSchedulingMaterials(workOrd: string, domain: string) {
  110. return service
  111. .get<{ list: unknown[] }>('/api/Production/scheduling/materials', { params: { workOrd, domain } })
  112. .then((r) => r.data);
  113. }
  114. export function fetchSchedulingRoutings(workOrd: string, domain: string) {
  115. return service
  116. .get<{ list: unknown[] }>('/api/Production/scheduling/routings', { params: { workOrd, domain } })
  117. .then((r) => r.data);
  118. }
  119. export function fetchSchedulingTrace(workOrd: string, domain: string) {
  120. return service.get<Record<string, unknown>>('/api/Production/scheduling/trace', { params: { workOrd, domain } }).then((r) => r.data);
  121. }