@pksep/zod-shared 0.0.560 → 0.0.562

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.
Files changed (108) hide show
  1. package/dist/ai-mcp/index.d.ts +2 -0
  2. package/dist/{library → ai-mcp}/index.js +2 -5
  3. package/dist/ai-mcp/interfaces/ai-mcp.interface.d.ts +358 -0
  4. package/dist/ai-mcp/schemas/ai-mcp-entity-editor.schema.d.ts +130 -0
  5. package/dist/ai-mcp/schemas/ai-mcp-entity-editor.schema.js +118 -0
  6. package/dist/ai-mcp/schemas/ai-mcp-specification.schema.d.ts +123 -0
  7. package/dist/ai-mcp/schemas/ai-mcp-specification.schema.js +110 -0
  8. package/dist/ai-mcp/schemas/ai-mcp.schema.d.ts +384 -0
  9. package/dist/ai-mcp/schemas/ai-mcp.schema.js +210 -0
  10. package/dist/assemble/dto/get-assemble-operation-count.dto.d.ts +28 -0
  11. package/dist/assemble/dto/set-date-shipment.dto.d.ts +2 -2
  12. package/dist/assemble/interfaces/interfaces.d.ts +8 -0
  13. package/dist/assemble/schemas/assemble-coming.schema.d.ts +20 -0
  14. package/dist/assemble/schemas/assemble.schema.d.ts +20 -0
  15. package/dist/cbed/dto/up-create-cbed.dto.d.ts +3 -0
  16. package/dist/cbed/dto/up-create-cbed.dto.js +1 -0
  17. package/dist/deliveries/dto/create-deliveries.dto.d.ts +6 -6
  18. package/dist/detal/dto/archive-detal.dto.d.ts +17 -0
  19. package/dist/detal/dto/archive-detal.dto.js +10 -0
  20. package/dist/detal/dto/update-detal.dto.d.ts +342 -17
  21. package/dist/detal/dto/update-detal.dto.js +88 -27
  22. package/dist/detal/index.d.ts +1 -0
  23. package/dist/detal/index.js +1 -0
  24. package/dist/document/dto/entity-document-command.dto.d.ts +184 -0
  25. package/dist/document/dto/entity-document-command.dto.js +59 -0
  26. package/dist/document/index.d.ts +2 -0
  27. package/dist/document/index.js +2 -0
  28. package/dist/document/interfaces/entity-document.interface.d.ts +30 -0
  29. package/dist/excel-export/excel-export.dto.d.ts +2968 -0
  30. package/dist/excel-export/excel-export.dto.js +391 -0
  31. package/dist/excel-export/index.d.ts +1 -0
  32. package/dist/{issue → excel-export}/index.js +1 -5
  33. package/dist/index.d.ts +2 -0
  34. package/dist/index.js +2 -0
  35. package/dist/marks/type/type.d.ts +4 -4
  36. package/dist/material/dto/create-material.dto.d.ts +3 -0
  37. package/dist/material/dto/create-material.dto.js +2 -1
  38. package/dist/product/dto/up-create-product.dto.d.ts +3 -0
  39. package/dist/product/dto/up-create-product.dto.js +1 -0
  40. package/dist/production-tasks/dto/change-due-date.dto.d.ts +2 -2
  41. package/dist/production-tasks/dto/get-production-task-display-numbers.dto.d.ts +20 -0
  42. package/dist/production-tasks/dto/get-production-task-display-numbers.dto.js +11 -0
  43. package/dist/production-tasks/dto/plan-production-task.dto.d.ts +34 -0
  44. package/dist/production-tasks/dto/plan-production-task.dto.js +21 -2
  45. package/dist/production-tasks/dto/split-production-task.dto.d.ts +203 -0
  46. package/dist/production-tasks/dto/split-production-task.dto.js +71 -0
  47. package/dist/production-tasks/dto/update.dto.d.ts +2 -2
  48. package/dist/production-tasks/dto/workload-by-entity.dto.d.ts +2 -2
  49. package/dist/production-tasks/enums/production-tasks.d.ts +10 -0
  50. package/dist/production-tasks/enums/production-tasks.js +12 -1
  51. package/dist/production-tasks/index.d.ts +3 -0
  52. package/dist/production-tasks/index.js +3 -0
  53. package/dist/production-tasks/interfaces/production-tasks.d.ts +4 -0
  54. package/dist/production-tasks/methods/methods.d.ts +9 -0
  55. package/dist/production-tasks/methods/methods.js +16 -1
  56. package/dist/production-tasks/schemas/orders-summary-by-entity.schema.d.ts +55 -8
  57. package/dist/production-tasks/schemas/orders-summary-by-entity.schema.js +9 -0
  58. package/dist/production-tasks/schemas/production-task-subtask.schema.d.ts +81 -0
  59. package/dist/production-tasks/schemas/production-task.schema.d.ts +14 -0
  60. package/dist/production-tasks/schemas/production-task.schema.js +4 -0
  61. package/dist/specification/dto/mutate-specification.dto.d.ts +58 -0
  62. package/dist/specification/dto/mutate-specification.dto.js +65 -0
  63. package/dist/specification/index.d.ts +1 -0
  64. package/dist/specification/index.js +1 -0
  65. package/dist/specification/interface/interface.d.ts +17 -0
  66. package/dist/utils/methods/sequelize.d.ts +2 -0
  67. package/dist/utils/methods/sequelize.js +4 -1
  68. package/dist/utils/methods.js +30 -10
  69. package/dist/utils/tables-config/enum.d.ts +5 -0
  70. package/dist/utils/tables-config/enum.js +10 -0
  71. package/dist/utils/types/types.d.ts +10 -1
  72. package/dist/utils/validation/transform.d.ts +2 -0
  73. package/dist/utils/validation/transform.js +25 -1
  74. package/package.json +1 -1
  75. package/dist/issue/dto/up-create-issue.dto.d.ts +0 -49
  76. package/dist/issue/dto/up-create-issue.dto.js +0 -21
  77. package/dist/issue/index.d.ts +0 -5
  78. package/dist/issue/interfaces/interface.d.ts +0 -4
  79. package/dist/issue/schemas/issue-user-controller.schema.d.ts +0 -15
  80. package/dist/issue/schemas/issue-user-controller.schema.js +0 -9
  81. package/dist/issue/schemas/issue-user.schema.d.ts +0 -15
  82. package/dist/issue/schemas/issue-user.schema.js +0 -9
  83. package/dist/issue/schemas/issue.schema.d.ts +0 -51
  84. package/dist/issue/schemas/issue.schema.js +0 -21
  85. package/dist/library/dto/create-chapter.dto.d.ts +0 -12
  86. package/dist/library/dto/create-chapter.dto.js +0 -8
  87. package/dist/library/dto/create-link.dto.d.ts +0 -30
  88. package/dist/library/dto/create-link.dto.js +0 -14
  89. package/dist/library/index.d.ts +0 -5
  90. package/dist/library/interfaces/interface.d.ts +0 -3
  91. package/dist/library/schemas/links-user.schema.d.ts +0 -15
  92. package/dist/library/schemas/links-user.schema.js +0 -9
  93. package/dist/library/schemas/links.schema.d.ts +0 -30
  94. package/dist/library/schemas/links.schema.js +0 -14
  95. package/dist/production-tasks/dto/update-marks.dto.d.ts +0 -13
  96. package/dist/production-tasks/dto/update-marks.dto.js +0 -8
  97. package/dist/production-tasks/dto/update-responsible.dto.d.ts +0 -12
  98. package/dist/production-tasks/dto/update-responsible.dto.js +0 -8
  99. package/dist/production-tasks/dto/update-status.dto.d.ts +0 -13
  100. package/dist/production-tasks/dto/update-status.dto.js +0 -9
  101. package/dist/shipments/dto/change-date-urgency.dto.d.ts +0 -12
  102. package/dist/shipments/dto/change-date-urgency.dto.js +0 -8
  103. package/dist/tech-process/schemas/tech-process-with-options.schema.d.ts +0 -306
  104. package/dist/tech-process/schemas/tech-process-with-options.schema.js +0 -8
  105. package/dist/utils/interface/mat.interface.d.ts +0 -10
  106. /package/dist/{issue/interfaces/interface.js → ai-mcp/interfaces/ai-mcp.interface.js} +0 -0
  107. /package/dist/{library/interfaces/interface.js → document/interfaces/entity-document.interface.js} +0 -0
  108. /package/dist/{utils/interface/mat.interface.js → production-tasks/schemas/production-task-subtask.schema.js} +0 -0
@@ -0,0 +1,81 @@
1
+ import type { ModelAssemble } from '../../assemble';
2
+ import type { ModelCbed } from '../../cbed';
3
+ import type { ModelDetal } from '../../detal';
4
+ import type { ModelEquipment } from '../../equipment';
5
+ import type { ModelMetaloworking } from '../../metaloworking';
6
+ import type { ModelProduct } from '../../product';
7
+ import type { ModelUser } from '../../user';
8
+ import type { SplitProductionTaskDtoZodType } from '../dto/split-production-task.dto';
9
+ import type { ModelProductionOperationPos } from './production-operation-pos.schema';
10
+ import type { ModelProductionTask } from './production-task.schema';
11
+ export type ProductionTaskWorkingEntityZodType = (ModelCbed | ModelDetal | ModelProduct) & {
12
+ actual_shipment_id?: number | null;
13
+ isOrderedByStockOrder?: boolean;
14
+ };
15
+ export type ProductionTaskWorkingPositionSourceZodType = (Omit<ModelAssemble, 'cbed' | 'product'> & {
16
+ cbed?: ProductionTaskWorkingEntityZodType;
17
+ detal?: never;
18
+ product?: ProductionTaskWorkingEntityZodType;
19
+ }) | (Omit<ModelMetaloworking, 'detal' | 'id'> & {
20
+ cbed?: never;
21
+ id: number;
22
+ detal?: ProductionTaskWorkingEntityZodType;
23
+ product?: never;
24
+ });
25
+ export type ProductionTaskWorkingPositionZodType = ProductionTaskWorkingPositionSourceZodType & {
26
+ idx: number;
27
+ myQuantity: number;
28
+ entity?: ProductionTaskWorkingEntityZodType;
29
+ isOrderedByStockOrder?: boolean;
30
+ operationExecutionTime?: number;
31
+ };
32
+ export type ProductionTaskOperationPositionZodType = ModelProductionOperationPos & {
33
+ maxAvailable?: number;
34
+ countByProductionTask?: number;
35
+ };
36
+ export type ProductionTaskWithSubtasksZodType = Omit<ModelProductionTask, 'children' | 'id' | 'production_operation_pos'> & {
37
+ id: number;
38
+ workingPosition: ProductionTaskWorkingPositionZodType[];
39
+ production_operation_pos: ProductionTaskOperationPositionZodType[];
40
+ children: ProductionTaskWithSubtasksZodType[];
41
+ };
42
+ export type ProductionTaskHydratedSourceZodType = Omit<ModelProductionTask, 'id'> & {
43
+ id: number;
44
+ ass?: ProductionTaskWorkingPositionSourceZodType[];
45
+ metall?: ProductionTaskWorkingPositionSourceZodType[];
46
+ };
47
+ export type ProductionTaskListItemZodType = Omit<ModelProductionTask, 'id'> & {
48
+ id: number;
49
+ createdAt?: Date | string;
50
+ };
51
+ export type ProductionTaskByEntityZodType = Omit<ModelProductionTask, 'due_data' | 'id'> & {
52
+ id: number;
53
+ due_data: Date | string;
54
+ quantity: number;
55
+ plan_ready_time: Date | string | null;
56
+ entityPositionId: number | null;
57
+ productionOperationPosId: number | null;
58
+ transferableQuantity: number;
59
+ };
60
+ export type ProductionTaskDecompositionAssignmentZodType = {
61
+ operationPositionId: number;
62
+ userId: number | null;
63
+ equipmentId: number | null;
64
+ };
65
+ export type ProductionTaskDecompositionPositionZodType = ProductionTaskWorkingPositionZodType & {
66
+ productionOperationPosId: number;
67
+ decompositionOperationAssignments: Record<number, ProductionTaskDecompositionAssignmentZodType>;
68
+ maxAvailable: number;
69
+ isSelected?: boolean;
70
+ selectedUsers?: number[];
71
+ selectedEquipments?: number[];
72
+ responsibleUsers?: ModelUser[];
73
+ availableEquipment?: ModelEquipment[];
74
+ typeIzd?: string;
75
+ type_izd?: string;
76
+ countByProductionTask: number;
77
+ shipmentNeedsTotal: number;
78
+ shipmentDeficit: number;
79
+ freeQuantity: number;
80
+ };
81
+ export type ProductionTaskDecompositionResultZodType = SplitProductionTaskDtoZodType;
@@ -7,6 +7,10 @@ import { ModelMarks } from '../../marks';
7
7
  import { ModelProductionOperationPos } from './production-operation-pos.schema';
8
8
  export declare const ProductionTaskSchema: z.ZodObject<{
9
9
  id: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
10
+ parent_production_task_id: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
11
+ subtask_number: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
12
+ subtask_order: z.ZodDefault<z.ZodNumber>;
13
+ global_order_index: z.ZodNumber;
10
14
  due_data: z.ZodDate;
11
15
  working_type: z.ZodNativeEnum<typeof StockOrderType>;
12
16
  description: z.ZodOptional<z.ZodString>;
@@ -14,20 +18,30 @@ export declare const ProductionTaskSchema: z.ZodObject<{
14
18
  details_filters: z.ZodType<IDescriptionFilters, z.ZodTypeDef, IDescriptionFilters>;
15
19
  }, "strip", z.ZodTypeAny, {
16
20
  ban: boolean;
21
+ subtask_order: number;
22
+ global_order_index: number;
17
23
  due_data: Date;
18
24
  working_type: StockOrderType;
19
25
  details_filters: IDescriptionFilters;
20
26
  description?: string | undefined;
21
27
  id?: number | null | undefined;
28
+ parent_production_task_id?: number | null | undefined;
29
+ subtask_number?: number | null | undefined;
22
30
  }, {
31
+ global_order_index: number;
23
32
  due_data: Date;
24
33
  working_type: StockOrderType;
25
34
  details_filters: IDescriptionFilters;
26
35
  ban?: boolean | undefined;
27
36
  description?: string | undefined;
28
37
  id?: number | null | undefined;
38
+ parent_production_task_id?: number | null | undefined;
39
+ subtask_number?: number | null | undefined;
40
+ subtask_order?: number | undefined;
29
41
  }>;
30
42
  export type ModelProductionTask = z.infer<typeof ProductionTaskSchema> & {
43
+ parent?: ModelProductionTask | null;
44
+ children?: ModelProductionTask[];
31
45
  ass?: ModelAssemble[];
32
46
  metall?: ModelMetaloworking[];
33
47
  marks?: ModelMarks[];
@@ -5,6 +5,10 @@ const zod_1 = require("zod");
5
5
  const utils_1 = require("../../utils");
6
6
  exports.ProductionTaskSchema = zod_1.z.object({
7
7
  id: zod_1.z.number().nullish(),
8
+ parent_production_task_id: zod_1.z.number().int().nullish(),
9
+ subtask_number: zod_1.z.number().int().min(1).nullish(),
10
+ subtask_order: zod_1.z.number().int().nonnegative().default(0),
11
+ global_order_index: zod_1.z.number().int(),
8
12
  due_data: zod_1.z.date(),
9
13
  working_type: zod_1.z.nativeEnum(utils_1.StockOrderType),
10
14
  description: zod_1.z.string().optional(),
@@ -0,0 +1,58 @@
1
+ import { z } from 'zod';
2
+ import { IzdType, SpetificationEntityKeys } from '../../utils';
3
+ export declare const SpecificationParentTypeZod: z.ZodEnum<[IzdType.product, IzdType.cbed, IzdType.detal]>;
4
+ export declare const SpecificationSectionZod: z.ZodNativeEnum<typeof SpetificationEntityKeys>;
5
+ export declare const SpecificationMutationOperationZod: z.ZodEnum<["add", "update", "move", "remove"]>;
6
+ /**
7
+ * Единая команда точечного изменения спецификации.
8
+ * position задаётся в привычном пользователю формате: первый элемент имеет позицию 1.
9
+ */
10
+ export declare const MutateSpecificationDtoZod: z.ZodEffects<z.ZodObject<{
11
+ parentType: z.ZodEnum<[IzdType.product, IzdType.cbed, IzdType.detal]>;
12
+ parentId: z.ZodNumber;
13
+ section: z.ZodNativeEnum<typeof SpetificationEntityKeys>;
14
+ operation: z.ZodEnum<["add", "update", "move", "remove"]>;
15
+ itemId: z.ZodNumber;
16
+ quantity: z.ZodOptional<z.ZodNumber>;
17
+ measureId: z.ZodOptional<z.ZodNumber>;
18
+ position: z.ZodOptional<z.ZodNumber>;
19
+ }, "strip", z.ZodTypeAny, {
20
+ operation: "update" | "add" | "move" | "remove";
21
+ parentId: number;
22
+ parentType: IzdType.product | IzdType.cbed | IzdType.detal;
23
+ section: SpetificationEntityKeys;
24
+ itemId: number;
25
+ quantity?: number | undefined;
26
+ position?: number | undefined;
27
+ measureId?: number | undefined;
28
+ }, {
29
+ operation: "update" | "add" | "move" | "remove";
30
+ parentId: number;
31
+ parentType: IzdType.product | IzdType.cbed | IzdType.detal;
32
+ section: SpetificationEntityKeys;
33
+ itemId: number;
34
+ quantity?: number | undefined;
35
+ position?: number | undefined;
36
+ measureId?: number | undefined;
37
+ }>, {
38
+ operation: "update" | "add" | "move" | "remove";
39
+ parentId: number;
40
+ parentType: IzdType.product | IzdType.cbed | IzdType.detal;
41
+ section: SpetificationEntityKeys;
42
+ itemId: number;
43
+ quantity?: number | undefined;
44
+ position?: number | undefined;
45
+ measureId?: number | undefined;
46
+ }, {
47
+ operation: "update" | "add" | "move" | "remove";
48
+ parentId: number;
49
+ parentType: IzdType.product | IzdType.cbed | IzdType.detal;
50
+ section: SpetificationEntityKeys;
51
+ itemId: number;
52
+ quantity?: number | undefined;
53
+ position?: number | undefined;
54
+ measureId?: number | undefined;
55
+ }>;
56
+ export type SpecificationParentType = z.infer<typeof SpecificationParentTypeZod>;
57
+ export type SpecificationMutationOperation = z.infer<typeof SpecificationMutationOperationZod>;
58
+ export type MutateSpecificationDto = z.infer<typeof MutateSpecificationDtoZod>;
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MutateSpecificationDtoZod = exports.SpecificationMutationOperationZod = exports.SpecificationSectionZod = exports.SpecificationParentTypeZod = void 0;
4
+ const zod_1 = require("zod");
5
+ const utils_1 = require("../../utils");
6
+ exports.SpecificationParentTypeZod = zod_1.z.enum([
7
+ utils_1.IzdType.product,
8
+ utils_1.IzdType.cbed,
9
+ utils_1.IzdType.detal
10
+ ]);
11
+ exports.SpecificationSectionZod = zod_1.z.nativeEnum(utils_1.SpetificationEntityKeys);
12
+ exports.SpecificationMutationOperationZod = zod_1.z.enum([
13
+ 'add',
14
+ 'update',
15
+ 'move',
16
+ 'remove'
17
+ ]);
18
+ /**
19
+ * Единая команда точечного изменения спецификации.
20
+ * position задаётся в привычном пользователю формате: первый элемент имеет позицию 1.
21
+ */
22
+ exports.MutateSpecificationDtoZod = zod_1.z
23
+ .object({
24
+ parentType: exports.SpecificationParentTypeZod,
25
+ parentId: zod_1.z.coerce.number().int().min(1),
26
+ section: exports.SpecificationSectionZod,
27
+ operation: exports.SpecificationMutationOperationZod,
28
+ itemId: zod_1.z.coerce.number().int().min(1),
29
+ quantity: zod_1.z.coerce.number().min(0.000001).max(1000000).optional(),
30
+ measureId: zod_1.z.coerce.number().int().min(1).optional(),
31
+ position: zod_1.z.coerce.number().int().min(1).optional()
32
+ })
33
+ .superRefine((command, context) => {
34
+ if (command.parentType === utils_1.IzdType.detal &&
35
+ command.section !== utils_1.SpetificationEntityKeys.materialList) {
36
+ context.addIssue({
37
+ code: zod_1.z.ZodIssueCode.custom,
38
+ path: ['section'],
39
+ message: 'Спецификация детали поддерживает только список материалов'
40
+ });
41
+ }
42
+ if (command.operation === 'add' && command.quantity === undefined) {
43
+ context.addIssue({
44
+ code: zod_1.z.ZodIssueCode.custom,
45
+ path: ['quantity'],
46
+ message: 'Для добавления необходимо указать количество'
47
+ });
48
+ }
49
+ if (command.operation === 'move' && command.position === undefined) {
50
+ context.addIssue({
51
+ code: zod_1.z.ZodIssueCode.custom,
52
+ path: ['position'],
53
+ message: 'Для перемещения необходимо указать новую позицию'
54
+ });
55
+ }
56
+ if (command.operation === 'update' &&
57
+ command.quantity === undefined &&
58
+ command.measureId === undefined) {
59
+ context.addIssue({
60
+ code: zod_1.z.ZodIssueCode.custom,
61
+ path: ['operation'],
62
+ message: 'Для изменения необходимо указать количество или единицу измерения'
63
+ });
64
+ }
65
+ });
@@ -1,4 +1,5 @@
1
1
  export * from './dto/specification-attributes.dto';
2
+ export * from './dto/mutate-specification.dto';
2
3
  export * from './schema/attributes.schema';
3
4
  export * from './type/type';
4
5
  export * from './interface/interface';
@@ -15,6 +15,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./dto/specification-attributes.dto"), exports);
18
+ __exportStar(require("./dto/mutate-specification.dto"), exports);
18
19
  __exportStar(require("./schema/attributes.schema"), exports);
19
20
  __exportStar(require("./type/type"), exports);
20
21
  __exportStar(require("./interface/interface"), exports);
@@ -2,6 +2,9 @@ import { ActionEntityTypes } from '../../action';
2
2
  import { ModelCbed } from '../../cbed';
3
3
  import { ModelProduct } from '../../product';
4
4
  import { SpetificationEntityKeys } from '../../utils';
5
+ import { EntityCommonSpecificationArray, IzdType } from '../../utils';
6
+ import { Transaction } from 'sequelize';
7
+ import { MutateSpecificationDto } from '../dto/mutate-specification.dto';
5
8
  export interface ICheckIsComplitEntity {
6
9
  entity: ModelCbed | ModelProduct;
7
10
  childrensQuantityMap: Map<string, number>;
@@ -9,3 +12,17 @@ export interface ICheckIsComplitEntity {
9
12
  type: ActionEntityTypes;
10
13
  funcToGetEntity: (params: any) => Promise<any>;
11
14
  }
15
+ export interface ISpecificationMutationContext {
16
+ userId: number;
17
+ transactionArgument?: Transaction;
18
+ relativeActionId?: number;
19
+ }
20
+ export interface ISpecificationMutationResult {
21
+ parentType: IzdType.product | IzdType.cbed | IzdType.detal;
22
+ parentId: number;
23
+ section: SpetificationEntityKeys;
24
+ operation: MutateSpecificationDto['operation'];
25
+ itemId: number;
26
+ position: number | null;
27
+ specification: EntityCommonSpecificationArray;
28
+ }
@@ -17,3 +17,5 @@
17
17
  })
18
18
  */
19
19
  export declare const addFieldByCondition: (conditions: any, query: any) => any;
20
+ /** Экранирует пользовательский ввод и формирует шаблон поиска по части строки. */
21
+ export declare const toContainsSearchPattern: (value: string) => string;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.addFieldByCondition = void 0;
3
+ exports.toContainsSearchPattern = exports.addFieldByCondition = void 0;
4
4
  /**
5
5
  * Упрощает добавление поля в запрос sequelie
6
6
  * @param conditions
@@ -21,3 +21,6 @@ exports.addFieldByCondition = void 0;
21
21
  */
22
22
  const addFieldByCondition = (conditions, query) => conditions ? query : {};
23
23
  exports.addFieldByCondition = addFieldByCondition;
24
+ /** Экранирует пользовательский ввод и формирует шаблон поиска по части строки. */
25
+ const toContainsSearchPattern = (value) => `%${value.replace(/[\\%_]/g, '\\$&')}%`;
26
+ exports.toContainsSearchPattern = toContainsSearchPattern;
@@ -72,10 +72,8 @@ function getFieldsSpetification(list, subKey) {
72
72
  }
73
73
  }
74
74
  const calculateByMeasurementRate = (units_measurement, ezId) => {
75
- const unitsMeasurementMap = new Map(units_measurement.map(unit => [unit.unitTypeId, unit.convertRate]));
76
- if (!unitsMeasurementMap.has(ezId))
77
- return 0;
78
- const convertRate = ezId === 1 ? 1 : unitsMeasurementMap.get(ezId);
75
+ const unit = units_measurement.find(unit => unit.unitTypeId === ezId);
76
+ const convertRate = Number((unit === null || unit === void 0 ? void 0 : unit.convertRate) || 0);
79
77
  return convertRate;
80
78
  };
81
79
  exports.calculateByMeasurementRate = calculateByMeasurementRate;
@@ -792,16 +790,18 @@ const countChildrensRelative = (data) => {
792
790
  ? Math.ceil(detalMass / materialConverRate)
793
791
  : 0;
794
792
  const characteristicQuantity = characteristicValue || 0;
795
- // всегда добавляем материал, даже если количество = 0, чтобы не терять его в графе
793
+ // Для заготовки явно фиксируем ЕИ "шт", чтобы deep-дефицит пересчитывал норму тем же коэффициентом, что и карточка материала
796
794
  concatedMaterialLists.push({
797
795
  id: relative === null || relative === void 0 ? void 0 : relative.mat_zag,
798
- quantity: characteristicQuantity
796
+ quantity: characteristicQuantity,
797
+ measureId: 1
799
798
  });
800
799
  }
801
800
  }
802
801
  const materialMap = new Map();
803
802
  const materialsArray = concatedMaterialLists
804
803
  .map((listMaterialItem) => {
804
+ var _a;
805
805
  const foundedMaterials = materials.find(material => listMaterialItem.id === material.id);
806
806
  // если материал не найден, пропускаем
807
807
  if (!foundedMaterials) {
@@ -809,8 +809,14 @@ const countChildrensRelative = (data) => {
809
809
  }
810
810
  // проверяем: это реальный 0 или результат ошибки/расчета
811
811
  const isZeroQuantity = listMaterialItem.quantity === 0;
812
- //конвертируем потребность в ШТ
813
- const materialConverRate = (0, exports.calculateByMeasurementRate)(foundedMaterials.units_measurement, listMaterialItem.measureId);
812
+ const measureId = Number(listMaterialItem.measureId || 1);
813
+ const baseUnit = (_a = foundedMaterials.units_measurement) === null || _a === void 0 ? void 0 : _a.find(unit => unit.isBase);
814
+ const baseMeasureId = Number((baseUnit === null || baseUnit === void 0 ? void 0 : baseUnit.unitTypeId) || measureId);
815
+ // Конвертируем только явную ЕИ из спецификации; расчетные заготовки уже приходят в складских единицах
816
+ const materialConverRate = listMaterialItem.measureId
817
+ ? (0, exports.calculateByMeasurementRate)(foundedMaterials.units_measurement, measureId)
818
+ : 1;
819
+ const baseConvertRate = Number((baseUnit === null || baseUnit === void 0 ? void 0 : baseUnit.convertRate) || materialConverRate || 1);
814
820
  // если количество 0, не пересчитываем, иначе - считаем как раньше
815
821
  const specificationConvertedQuantity = isZeroQuantity
816
822
  ? 0
@@ -819,14 +825,28 @@ const countChildrensRelative = (data) => {
819
825
  : 0;
820
826
  return Object.assign(Object.assign(Object.assign({}, foundedMaterials), (0, sequelize_1.addFieldByCondition)(data.isNeedsTypes, {
821
827
  entity_type: enums_1.IzdType.material
822
- })), { measure_id: listMaterialItem.measureId, count_to_obj_not_converted: listMaterialItem.quantity, count_to_needs_not_converted: relativeNeeds * listMaterialItem.quantity, count_to_obj: specificationConvertedQuantity, count_to_needs: relativeNeeds * specificationConvertedQuantity, needs: relativeNeeds * specificationConvertedQuantity, parent_id: relative.id, parent_type: relativeType, parent_ava: relative === null || relative === void 0 ? void 0 : relative.ava_path, parent_designation: (relative === null || relative === void 0 ? void 0 : relative.designation) || '-', parent_name: (relative === null || relative === void 0 ? void 0 : relative.name) || '-' });
828
+ })), { measure_id: measureId, measureId, measureName: (0, edizm_1.returnEzName)(measureId), convertRate: materialConverRate, baseMeasureId, baseMeasureName: (0, edizm_1.returnEzName)(baseMeasureId), baseConvertRate, count_to_obj_not_converted: listMaterialItem.quantity, count_to_needs_not_converted: relativeNeeds * listMaterialItem.quantity, count_to_obj: specificationConvertedQuantity, count_to_needs: relativeNeeds * specificationConvertedQuantity, needs: relativeNeeds * specificationConvertedQuantity, parent_id: relative.id, parent_type: relativeType, parent_ava: relative === null || relative === void 0 ? void 0 : relative.ava_path, parent_designation: (relative === null || relative === void 0 ? void 0 : relative.designation) || '-', parent_name: (relative === null || relative === void 0 ? void 0 : relative.name) || '-' });
823
829
  })
824
830
  .filter(Boolean);
825
831
  materialsArray.forEach((currentMaterial) => {
826
832
  const materialKey = `${currentMaterial.parent_id}_${currentMaterial.parent_type}_${currentMaterial.id}`;
827
833
  if (materialMap.has(materialKey)) {
828
834
  const material = materialMap.get(materialKey);
829
- materialMap.set(materialKey, Object.assign(Object.assign({}, material), { needs: material.needs + currentMaterial.needs, count_to_obj: material.count_to_obj + currentMaterial.count_to_obj, count_to_needs: material.count_to_needs + currentMaterial.count_to_needs }));
835
+ const isSameMeasure = material.measure_id === currentMaterial.measure_id;
836
+ const isSameBaseMeasure = material.baseMeasureId === currentMaterial.baseMeasureId;
837
+ materialMap.set(materialKey, Object.assign(Object.assign({}, material), { needs: material.needs + currentMaterial.needs, count_to_obj: material.count_to_obj + currentMaterial.count_to_obj, count_to_needs: material.count_to_needs + currentMaterial.count_to_needs, count_to_obj_not_converted: isSameMeasure
838
+ ? material.count_to_obj_not_converted +
839
+ currentMaterial.count_to_obj_not_converted
840
+ : material.count_to_obj + currentMaterial.count_to_obj, count_to_needs_not_converted: isSameMeasure
841
+ ? material.count_to_needs_not_converted +
842
+ currentMaterial.count_to_needs_not_converted
843
+ : material.count_to_needs + currentMaterial.count_to_needs, measure_id: isSameMeasure ? material.measure_id : 1, measureId: isSameMeasure ? material.measureId : 1, measureName: isSameMeasure ? material.measureName : (0, edizm_1.returnEzName)(1), convertRate: isSameMeasure ? material.convertRate : 1, baseMeasureId: isSameBaseMeasure
844
+ ? material.baseMeasureId
845
+ : material.measureId, baseMeasureName: isSameBaseMeasure
846
+ ? material.baseMeasureName
847
+ : material.measureName, baseConvertRate: isSameBaseMeasure
848
+ ? material.baseConvertRate
849
+ : material.convertRate }));
830
850
  }
831
851
  else {
832
852
  materialMap.set(materialKey, currentMaterial);
@@ -13,6 +13,11 @@ export declare enum tablesEnumConfig {
13
13
  productionDelay = "productionDelay",
14
14
  startTimeDelay = "startTimeDelay",
15
15
  ordered = "ordered",
16
+ maxAvailable = "maxAvailable",
17
+ deficit = "deficit",
18
+ shipmentDeficit = "shipmentDeficit",
19
+ productionTaskDeficit = "productionTaskDeficit",
20
+ globalProductionTaskDeficit = "globalProductionTaskDeficit",
16
21
  deficitChildCreateTime = "deficitChildCreateTime",
17
22
  remainingByProductionTask = "remainingByProductionTask",
18
23
  dateByUrgency = "dateByUrgency",
@@ -29,6 +29,16 @@ var tablesEnumConfig;
29
29
  tablesEnumConfig["startTimeDelay"] = "startTimeDelay";
30
30
  // заказано
31
31
  tablesEnumConfig["ordered"] = "ordered";
32
+ // Доступно к планированию по ПЗ
33
+ tablesEnumConfig["maxAvailable"] = "maxAvailable";
34
+ // Дефицит
35
+ tablesEnumConfig["deficit"] = "deficit";
36
+ // Дефицит по заказам на отгрузку
37
+ tablesEnumConfig["shipmentDeficit"] = "shipmentDeficit";
38
+ // Дефицит по ПЗ
39
+ tablesEnumConfig["productionTaskDeficit"] = "productionTaskDeficit";
40
+ // Общий дефицит по ПЗ
41
+ tablesEnumConfig["globalProductionTaskDeficit"] = "globalProductionTaskDeficit";
32
42
  // Время изг. дефицитных Д/СБ
33
43
  tablesEnumConfig["deficitChildCreateTime"] = "deficitChildCreateTime";
34
44
  // Осталось сделать по ПЗ
@@ -3,7 +3,7 @@ import { ActionEntityTypes } from '../../action';
3
3
  import { ModelCbed } from '../../cbed';
4
4
  import { ModelDetal } from '../../detal';
5
5
  import { ModelMaterial } from '../../material';
6
- import { IzdType, ParentTypeEnum, QueueStatusEnum } from '../enums';
6
+ import { IzdType, ParentTypeEnum, QueueStatusEnum, StockOrderType } from '../enums';
7
7
  import { IParentTypeInterface } from '../interface/parent-type.interface';
8
8
  export type listKeys = 'cb' | 'det' | 'mat';
9
9
  export type IdsList = {
@@ -28,6 +28,9 @@ export type RelativesProductionTasksType = {
28
28
  relativeDesignation: string;
29
29
  equipmentId: number | null;
30
30
  userId: number | null;
31
+ operationId?: number | null;
32
+ productionEntityId?: number | null;
33
+ productionEntityType?: StockOrderType | null;
31
34
  relativeAttention: boolean;
32
35
  relativeDiscontinued: boolean;
33
36
  relativeDescription: string;
@@ -109,6 +112,12 @@ export type RecursiveGraphType = {
109
112
  needs?: number;
110
113
  parent_id?: number;
111
114
  measure_id?: number;
115
+ measureId?: number;
116
+ measureName?: string;
117
+ convertRate?: number;
118
+ baseMeasureId?: number;
119
+ baseMeasureName?: string;
120
+ baseConvertRate?: number;
112
121
  count_to_obj_not_converted?: number;
113
122
  count_to_needs_not_converted?: number;
114
123
  parent_type?: IzdType;
@@ -5,3 +5,5 @@
5
5
  * @returns
6
6
  */
7
7
  export declare const parseParamsOrBody: ({ value }: any, defaultValue?: any) => any;
8
+ export declare const parseJsonField: <T>(value: unknown, defaultValue: T) => unknown;
9
+ export declare const parseOptionalNullableInteger: (value: unknown) => unknown;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.parseParamsOrBody = void 0;
3
+ exports.parseOptionalNullableInteger = exports.parseJsonField = exports.parseParamsOrBody = void 0;
4
4
  /**
5
5
  * Парсим и возвращаем json при валидации контроллера
6
6
  * @param param0
@@ -17,3 +17,27 @@ const parseParamsOrBody = ({ value }, defaultValue) => {
17
17
  }
18
18
  };
19
19
  exports.parseParamsOrBody = parseParamsOrBody;
20
+ const parseJsonField = (value, defaultValue) => {
21
+ if (value === undefined || value === null || value === '') {
22
+ return defaultValue;
23
+ }
24
+ if (typeof value !== 'string')
25
+ return value;
26
+ try {
27
+ return JSON.parse(value);
28
+ }
29
+ catch (_a) {
30
+ return value;
31
+ }
32
+ };
33
+ exports.parseJsonField = parseJsonField;
34
+ const parseOptionalNullableInteger = (value) => {
35
+ if (value === undefined)
36
+ return undefined;
37
+ if (value === null || value === '' || value === 'null')
38
+ return null;
39
+ if (typeof value === 'string' && /^\d+$/.test(value))
40
+ return Number(value);
41
+ return value;
42
+ };
43
+ exports.parseOptionalNullableInteger = parseOptionalNullableInteger;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pksep/zod-shared",
3
- "version": "0.0.560",
3
+ "version": "0.0.562",
4
4
  "description": "Zod package for erp project. Contains dto, interfaces, schems, types, enum",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -1,49 +0,0 @@
1
- import { z } from 'zod';
2
- import { StatusIssue } from '../../utils';
3
- export declare const UpCreateIssueDtoZod: z.ZodObject<{
4
- description: z.ZodString;
5
- dateUse: z.ZodString;
6
- normTime: z.ZodString;
7
- sourse: z.ZodString;
8
- srok: z.ZodString;
9
- status: z.ZodNativeEnum<typeof StatusIssue>;
10
- controllerList: z.ZodString;
11
- executorList: z.ZodString;
12
- izdList: z.ZodString;
13
- shopNeeds: z.ZodString;
14
- fileArrModal: z.ZodString;
15
- srok_control: z.ZodString;
16
- id: z.ZodNumber;
17
- name: z.ZodString;
18
- }, "strip", z.ZodTypeAny, {
19
- status: StatusIssue;
20
- id: number;
21
- name: string;
22
- description: string;
23
- dateUse: string;
24
- normTime: string;
25
- sourse: string;
26
- srok: string;
27
- controllerList: string;
28
- executorList: string;
29
- srok_control: string;
30
- izdList: string;
31
- shopNeeds: string;
32
- fileArrModal: string;
33
- }, {
34
- status: StatusIssue;
35
- id: number;
36
- name: string;
37
- description: string;
38
- dateUse: string;
39
- normTime: string;
40
- sourse: string;
41
- srok: string;
42
- controllerList: string;
43
- executorList: string;
44
- srok_control: string;
45
- izdList: string;
46
- shopNeeds: string;
47
- fileArrModal: string;
48
- }>;
49
- export type UpCreateIssueDtoType = z.infer<typeof UpCreateIssueDtoZod>;
@@ -1,21 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.UpCreateIssueDtoZod = void 0;
4
- const zod_1 = require("zod");
5
- const utils_1 = require("../../utils");
6
- exports.UpCreateIssueDtoZod = zod_1.z.object({
7
- description: zod_1.z.string(),
8
- dateUse: zod_1.z.string(),
9
- normTime: zod_1.z.string(),
10
- sourse: zod_1.z.string(),
11
- srok: zod_1.z.string(),
12
- status: zod_1.z.nativeEnum(utils_1.StatusIssue),
13
- controllerList: zod_1.z.string(),
14
- executorList: zod_1.z.string(),
15
- izdList: zod_1.z.string(),
16
- shopNeeds: zod_1.z.string(),
17
- fileArrModal: zod_1.z.string(),
18
- srok_control: zod_1.z.string(),
19
- id: zod_1.z.number(),
20
- name: zod_1.z.string()
21
- });
@@ -1,5 +0,0 @@
1
- export * from './schemas/issue.schema';
2
- export * from './schemas/issue-user.schema';
3
- export * from './schemas/issue-user-controller.schema';
4
- export * from './interfaces/interface';
5
- export * from './dto/up-create-issue.dto';
@@ -1,4 +0,0 @@
1
- export interface IIssueCreationAttrs {
2
- name: string;
3
- instans: number;
4
- }
@@ -1,15 +0,0 @@
1
- import { z } from 'zod';
2
- export declare const issueUserControllerSchema: z.ZodObject<{
3
- id: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
4
- issueId: z.ZodNumber;
5
- userId: z.ZodNumber;
6
- }, "strip", z.ZodTypeAny, {
7
- userId: number;
8
- issueId: number;
9
- id?: number | null | undefined;
10
- }, {
11
- userId: number;
12
- issueId: number;
13
- id?: number | null | undefined;
14
- }>;
15
- export type ModelIssueUserController = z.infer<typeof issueUserControllerSchema>;
@@ -1,9 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.issueUserControllerSchema = void 0;
4
- const zod_1 = require("zod");
5
- exports.issueUserControllerSchema = zod_1.z.object({
6
- id: zod_1.z.number().nullish(),
7
- issueId: zod_1.z.number().int().positive(),
8
- userId: zod_1.z.number().int().positive()
9
- });