@pksep/zod-shared 0.0.553 → 0.0.555
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/index.d.ts +0 -1
- package/dist/index.js +0 -1
- package/dist/material/utils/workpiece-mass.js +13 -6
- package/dist/material/workpiece-mass.d.ts +45 -0
- package/dist/material/workpiece-mass.js +400 -0
- package/dist/production-tasks/index.d.ts +1 -0
- package/dist/production-tasks/index.js +1 -0
- package/dist/production-tasks/schemas/orders-summary-by-entity.schema.d.ts +307 -0
- package/dist/production-tasks/schemas/orders-summary-by-entity.schema.js +74 -0
- package/dist/utils/interface/status-flags.interface.d.ts +4 -0
- package/dist/utils/tables-config/tables-array.js +3 -3
- package/package.json +1 -1
- package/dist/issue/dto/up-create-issue.dto.d.ts +0 -49
- package/dist/issue/dto/up-create-issue.dto.js +0 -21
- package/dist/issue/index.d.ts +0 -5
- package/dist/issue/index.js +0 -21
- package/dist/issue/interfaces/interface.d.ts +0 -4
- package/dist/issue/schemas/issue-user-controller.schema.d.ts +0 -15
- package/dist/issue/schemas/issue-user-controller.schema.js +0 -9
- package/dist/issue/schemas/issue-user.schema.d.ts +0 -15
- package/dist/issue/schemas/issue-user.schema.js +0 -9
- package/dist/issue/schemas/issue.schema.d.ts +0 -51
- package/dist/issue/schemas/issue.schema.js +0 -21
- package/dist/library/dto/create-chapter.dto.d.ts +0 -12
- package/dist/library/dto/create-chapter.dto.js +0 -8
- package/dist/library/dto/create-link.dto.d.ts +0 -30
- package/dist/library/dto/create-link.dto.js +0 -14
- package/dist/library/index.d.ts +0 -5
- package/dist/library/index.js +0 -21
- package/dist/library/interfaces/interface.d.ts +0 -3
- package/dist/library/interfaces/interface.js +0 -2
- package/dist/library/schemas/links-user.schema.d.ts +0 -15
- package/dist/library/schemas/links-user.schema.js +0 -9
- package/dist/library/schemas/links.schema.d.ts +0 -30
- package/dist/library/schemas/links.schema.js +0 -14
- package/dist/planning/index.d.ts +0 -1
- package/dist/planning/index.js +0 -17
- package/dist/planning/types/planning.d.ts +0 -177
- package/dist/planning/types/planning.js +0 -25
- package/dist/production-tasks/dto/update-marks.dto.d.ts +0 -13
- package/dist/production-tasks/dto/update-marks.dto.js +0 -8
- package/dist/production-tasks/dto/update-responsible.dto.d.ts +0 -12
- package/dist/production-tasks/dto/update-responsible.dto.js +0 -8
- package/dist/production-tasks/dto/update-status.dto.d.ts +0 -13
- package/dist/production-tasks/dto/update-status.dto.js +0 -9
- package/dist/tech-process/schemas/tech-process-with-options.schema.d.ts +0 -306
- package/dist/tech-process/schemas/tech-process-with-options.schema.js +0 -8
- package/dist/utils/interface/mat.interface.d.ts +0 -10
- package/dist/utils/interface/mat.interface.js +0 -2
- /package/dist/{issue/interfaces/interface.js → utils/interface/status-flags.interface.js} +0 -0
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -173,17 +173,24 @@ exports.WORKPIECE_MASS_FORMULAS = [
|
|
|
173
173
|
]
|
|
174
174
|
}
|
|
175
175
|
];
|
|
176
|
+
const normalizeCharacteristicNumericValue = (value) => {
|
|
177
|
+
if (typeof value === 'number' && !Number.isNaN(value)) {
|
|
178
|
+
return value;
|
|
179
|
+
}
|
|
180
|
+
if (typeof value === 'string') {
|
|
181
|
+
const normalizedValue = Number(value);
|
|
182
|
+
return !Number.isNaN(normalizedValue) ? normalizedValue : null;
|
|
183
|
+
}
|
|
184
|
+
return null;
|
|
185
|
+
};
|
|
176
186
|
const getMaterialCharacteristicValue = (context, key) => {
|
|
177
187
|
var _a, _b;
|
|
178
188
|
const item = (_b = (_a = context.material) === null || _a === void 0 ? void 0 : _a.characteristics) === null || _b === void 0 ? void 0 : _b[key];
|
|
179
|
-
return
|
|
180
|
-
? item.znach
|
|
181
|
-
: null;
|
|
189
|
+
return normalizeCharacteristicNumericValue(item === null || item === void 0 ? void 0 : item.znach);
|
|
182
190
|
};
|
|
183
191
|
const getWorkpieceCharacteristicValue = (context, key) => {
|
|
184
192
|
var _a;
|
|
185
|
-
|
|
186
|
-
return typeof value === 'number' && !Number.isNaN(value) ? value : null;
|
|
193
|
+
return normalizeCharacteristicNumericValue((_a = context.workpieceCharacterization) === null || _a === void 0 ? void 0 : _a[key]);
|
|
187
194
|
};
|
|
188
195
|
/**
|
|
189
196
|
* Возвращаем первое осмысленное положительное значение.
|
|
@@ -216,7 +223,7 @@ const getPreparedWorkpieceValues = (context) => {
|
|
|
216
223
|
? pickPreparedCharacteristicValue(getMaterialCharacteristicValue(context, characteristicKey), getWorkpieceCharacteristicValue(context, characteristicKey))
|
|
217
224
|
: pickPreparedCharacteristicValue(getWorkpieceCharacteristicValue(context, characteristicKey), getMaterialCharacteristicValue(context, characteristicKey));
|
|
218
225
|
}
|
|
219
|
-
const density = getMaterialCharacteristicValue(context, 'density');
|
|
226
|
+
const density = pickPreparedCharacteristicValue(getWorkpieceCharacteristicValue(context, 'density'), getMaterialCharacteristicValue(context, 'density'));
|
|
220
227
|
if (density !== null)
|
|
221
228
|
result.density = density;
|
|
222
229
|
const mass = getWorkpieceCharacteristicValue(context, 'mass');
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { WorkpieceMassFormulaKey } from './enum/enum';
|
|
2
|
+
import type { ModelMaterial } from './schemas/material.schema';
|
|
3
|
+
import type { ModelTypeMaterial } from './schemas/type-material.schema';
|
|
4
|
+
export type TWorkpieceMassVariableKey = 'density' | 'length' | 'width' | 'height' | 'thickness' | 'wallThickness' | 'outsideDiameter' | 'areaCrossSectional' | 'acrossFlats' | 'massPerMeter';
|
|
5
|
+
export interface IWorkpieceMassFormulaVariable {
|
|
6
|
+
key: TWorkpieceMassVariableKey;
|
|
7
|
+
name: string;
|
|
8
|
+
source: 'material' | 'workpiece';
|
|
9
|
+
required: boolean;
|
|
10
|
+
}
|
|
11
|
+
export interface IWorkpieceMassFormula {
|
|
12
|
+
key: WorkpieceMassFormulaKey;
|
|
13
|
+
name: string;
|
|
14
|
+
description: string;
|
|
15
|
+
variables: IWorkpieceMassFormulaVariable[];
|
|
16
|
+
}
|
|
17
|
+
export type TResolvedWorkpieceMassVariables = Partial<Record<TWorkpieceMassVariableKey, number>>;
|
|
18
|
+
export interface ICalculateWorkpieceMassContext {
|
|
19
|
+
typeMaterial: ModelTypeMaterial;
|
|
20
|
+
material: ModelMaterial;
|
|
21
|
+
workpieceCharacterization?: Record<string, number | null | undefined>;
|
|
22
|
+
workpieceMassFormulaKey?: WorkpieceMassFormulaKey;
|
|
23
|
+
}
|
|
24
|
+
export interface ICalculateWorkpieceMassResult {
|
|
25
|
+
formulaKey: WorkpieceMassFormulaKey;
|
|
26
|
+
mass: number;
|
|
27
|
+
variables: TResolvedWorkpieceMassVariables;
|
|
28
|
+
}
|
|
29
|
+
type TPreparedWorkpieceValues = Partial<Record<TWorkpieceMassVariableKey | 'mass' | 'trash', number>>;
|
|
30
|
+
type TWorkpieceMassVariableResolver = (context: ICalculateWorkpieceMassContext, prepared: TPreparedWorkpieceValues) => number | null;
|
|
31
|
+
type TWorkpieceMassCalculator = (vars: TResolvedWorkpieceMassVariables) => number;
|
|
32
|
+
export declare const WORKPIECE_MASS_FORMULAS: IWorkpieceMassFormula[];
|
|
33
|
+
/**
|
|
34
|
+
* Реестр источников значений переменных.
|
|
35
|
+
* Здесь описано, откуда брать каждую переменную под расчет массы заготовки.
|
|
36
|
+
*/
|
|
37
|
+
export declare const WORKPIECE_MASS_VARIABLE_RESOLVERS: Record<TWorkpieceMassVariableKey, TWorkpieceMassVariableResolver>;
|
|
38
|
+
/**
|
|
39
|
+
* Реестр математических алгоритмов расчета.
|
|
40
|
+
* Здесь только математика, без поиска значений по моделям.
|
|
41
|
+
*/
|
|
42
|
+
export declare const WORKPIECE_MASS_CALCULATORS: Record<WorkpieceMassFormulaKey, TWorkpieceMassCalculator>;
|
|
43
|
+
export declare const resolveWorkpieceMassVariables: (context: ICalculateWorkpieceMassContext, variableKeys: TWorkpieceMassVariableKey[]) => TResolvedWorkpieceMassVariables;
|
|
44
|
+
export declare const calculateWorkpieceMassPreview: (context: ICalculateWorkpieceMassContext) => ICalculateWorkpieceMassResult | null;
|
|
45
|
+
export {};
|
|
@@ -0,0 +1,400 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.calculateWorkpieceMassPreview = exports.resolveWorkpieceMassVariables = exports.WORKPIECE_MASS_CALCULATORS = exports.WORKPIECE_MASS_VARIABLE_RESOLVERS = exports.WORKPIECE_MASS_FORMULAS = void 0;
|
|
4
|
+
const enum_1 = require("./enum/enum");
|
|
5
|
+
const utils_1 = require("../utils");
|
|
6
|
+
exports.WORKPIECE_MASS_FORMULAS = [
|
|
7
|
+
{
|
|
8
|
+
key: enum_1.WorkpieceMassFormulaKey.boundingBox,
|
|
9
|
+
name: 'Прямоугольная заготовка',
|
|
10
|
+
description: 'm = ρ * L * B * H',
|
|
11
|
+
variables: [
|
|
12
|
+
{
|
|
13
|
+
key: 'density',
|
|
14
|
+
name: 'Плотность',
|
|
15
|
+
source: 'material',
|
|
16
|
+
required: true
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
key: 'length',
|
|
20
|
+
name: 'Длина',
|
|
21
|
+
source: 'workpiece',
|
|
22
|
+
required: true
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
key: 'width',
|
|
26
|
+
name: 'Ширина',
|
|
27
|
+
source: 'workpiece',
|
|
28
|
+
required: true
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
key: 'height',
|
|
32
|
+
name: 'Высота',
|
|
33
|
+
source: 'workpiece',
|
|
34
|
+
required: true
|
|
35
|
+
}
|
|
36
|
+
]
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
key: enum_1.WorkpieceMassFormulaKey.rectangularSection,
|
|
40
|
+
name: 'Прямоугольное сечение',
|
|
41
|
+
description: 'm = ρ * L * B * t',
|
|
42
|
+
variables: [
|
|
43
|
+
{
|
|
44
|
+
key: 'density',
|
|
45
|
+
name: 'Плотность',
|
|
46
|
+
source: 'material',
|
|
47
|
+
required: true
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
key: 'length',
|
|
51
|
+
name: 'Длина',
|
|
52
|
+
source: 'workpiece',
|
|
53
|
+
required: true
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
key: 'width',
|
|
57
|
+
name: 'Ширина',
|
|
58
|
+
source: 'workpiece',
|
|
59
|
+
required: true
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
key: 'thickness',
|
|
63
|
+
name: 'Толщина',
|
|
64
|
+
source: 'material',
|
|
65
|
+
required: true
|
|
66
|
+
}
|
|
67
|
+
]
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
key: enum_1.WorkpieceMassFormulaKey.solidRoundSection,
|
|
71
|
+
name: 'Полнотелое круглое сечение',
|
|
72
|
+
description: 'm = ρ * π * D² / 4 * L',
|
|
73
|
+
variables: [
|
|
74
|
+
{
|
|
75
|
+
key: 'density',
|
|
76
|
+
name: 'Плотность',
|
|
77
|
+
source: 'material',
|
|
78
|
+
required: true
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
key: 'outsideDiameter',
|
|
82
|
+
name: 'Наружный диаметр',
|
|
83
|
+
source: 'material',
|
|
84
|
+
required: true
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
key: 'length',
|
|
88
|
+
name: 'Длина',
|
|
89
|
+
source: 'workpiece',
|
|
90
|
+
required: true
|
|
91
|
+
}
|
|
92
|
+
]
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
key: enum_1.WorkpieceMassFormulaKey.hollowRoundSection,
|
|
96
|
+
name: 'Полое круглое сечение',
|
|
97
|
+
description: 'm = ρ * π * t * (D - t) * L',
|
|
98
|
+
variables: [
|
|
99
|
+
{
|
|
100
|
+
key: 'density',
|
|
101
|
+
name: 'Плотность',
|
|
102
|
+
source: 'material',
|
|
103
|
+
required: true
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
key: 'outsideDiameter',
|
|
107
|
+
name: 'Наружный диаметр',
|
|
108
|
+
source: 'material',
|
|
109
|
+
required: true
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
key: 'wallThickness',
|
|
113
|
+
name: 'Толщина стенки',
|
|
114
|
+
source: 'material',
|
|
115
|
+
required: true
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
key: 'length',
|
|
119
|
+
name: 'Длина',
|
|
120
|
+
source: 'workpiece',
|
|
121
|
+
required: true
|
|
122
|
+
}
|
|
123
|
+
]
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
key: enum_1.WorkpieceMassFormulaKey.hollowProfileSection,
|
|
127
|
+
name: 'Полое профильное сечение',
|
|
128
|
+
description: 'm = ρ * (B * H - (B - 2t) * (H - 2t)) * L',
|
|
129
|
+
variables: [
|
|
130
|
+
{
|
|
131
|
+
key: 'density',
|
|
132
|
+
name: 'Плотность',
|
|
133
|
+
source: 'material',
|
|
134
|
+
required: true
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
key: 'width',
|
|
138
|
+
name: 'Ширина профиля',
|
|
139
|
+
source: 'material',
|
|
140
|
+
required: true
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
key: 'height',
|
|
144
|
+
name: 'Высота профиля',
|
|
145
|
+
source: 'material',
|
|
146
|
+
required: true
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
key: 'wallThickness',
|
|
150
|
+
name: 'Толщина стенки',
|
|
151
|
+
source: 'material',
|
|
152
|
+
required: true
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
key: 'length',
|
|
156
|
+
name: 'Длина',
|
|
157
|
+
source: 'workpiece',
|
|
158
|
+
required: true
|
|
159
|
+
}
|
|
160
|
+
]
|
|
161
|
+
},
|
|
162
|
+
{
|
|
163
|
+
key: enum_1.WorkpieceMassFormulaKey.hexSection,
|
|
164
|
+
name: 'Шестигранное сечение',
|
|
165
|
+
description: 'm = ρ * 0.866025 * S² * L',
|
|
166
|
+
variables: [
|
|
167
|
+
{
|
|
168
|
+
key: 'density',
|
|
169
|
+
name: 'Плотность',
|
|
170
|
+
source: 'material',
|
|
171
|
+
required: true
|
|
172
|
+
},
|
|
173
|
+
{
|
|
174
|
+
key: 'acrossFlats',
|
|
175
|
+
name: 'Размер под ключ',
|
|
176
|
+
source: 'material',
|
|
177
|
+
required: true
|
|
178
|
+
},
|
|
179
|
+
{
|
|
180
|
+
key: 'length',
|
|
181
|
+
name: 'Длина',
|
|
182
|
+
source: 'workpiece',
|
|
183
|
+
required: true
|
|
184
|
+
}
|
|
185
|
+
]
|
|
186
|
+
},
|
|
187
|
+
{
|
|
188
|
+
key: enum_1.WorkpieceMassFormulaKey.sectionArea,
|
|
189
|
+
name: 'По площади сечения',
|
|
190
|
+
description: 'm = ρ * A * L',
|
|
191
|
+
variables: [
|
|
192
|
+
{
|
|
193
|
+
key: 'density',
|
|
194
|
+
name: 'Плотность',
|
|
195
|
+
source: 'material',
|
|
196
|
+
required: true
|
|
197
|
+
},
|
|
198
|
+
{
|
|
199
|
+
key: 'areaCrossSectional',
|
|
200
|
+
name: 'Площадь поперечного сечения',
|
|
201
|
+
source: 'material',
|
|
202
|
+
required: true
|
|
203
|
+
},
|
|
204
|
+
{
|
|
205
|
+
key: 'length',
|
|
206
|
+
name: 'Длина',
|
|
207
|
+
source: 'workpiece',
|
|
208
|
+
required: true
|
|
209
|
+
}
|
|
210
|
+
]
|
|
211
|
+
},
|
|
212
|
+
{
|
|
213
|
+
key: enum_1.WorkpieceMassFormulaKey.linearMass,
|
|
214
|
+
name: 'По массе погонного метра',
|
|
215
|
+
description: 'm = q * L',
|
|
216
|
+
variables: [
|
|
217
|
+
{
|
|
218
|
+
key: 'massPerMeter',
|
|
219
|
+
name: 'Масса погонного метра',
|
|
220
|
+
source: 'material',
|
|
221
|
+
required: true
|
|
222
|
+
},
|
|
223
|
+
{
|
|
224
|
+
key: 'length',
|
|
225
|
+
name: 'Длина',
|
|
226
|
+
source: 'workpiece',
|
|
227
|
+
required: true
|
|
228
|
+
}
|
|
229
|
+
]
|
|
230
|
+
}
|
|
231
|
+
];
|
|
232
|
+
const getMaterialCharacteristicValue = (context, key) => {
|
|
233
|
+
var _a, _b;
|
|
234
|
+
const item = (_b = (_a = context.material) === null || _a === void 0 ? void 0 : _a.characteristics) === null || _b === void 0 ? void 0 : _b[key];
|
|
235
|
+
return typeof (item === null || item === void 0 ? void 0 : item.znach) === 'number' && !Number.isNaN(item.znach)
|
|
236
|
+
? item.znach
|
|
237
|
+
: null;
|
|
238
|
+
};
|
|
239
|
+
const getWorkpieceCharacteristicValue = (context, key) => {
|
|
240
|
+
var _a;
|
|
241
|
+
const value = (_a = context.workpieceCharacterization) === null || _a === void 0 ? void 0 : _a[key];
|
|
242
|
+
return typeof value === 'number' && !Number.isNaN(value) ? value : null;
|
|
243
|
+
};
|
|
244
|
+
const getPreparedWorkpieceValues = (context) => {
|
|
245
|
+
var _a, _b, _c, _d;
|
|
246
|
+
const result = {};
|
|
247
|
+
const typeMaterialCharacteristics = ((_a = context.typeMaterial) === null || _a === void 0 ? void 0 : _a.characteristics) || {};
|
|
248
|
+
for (const characteristicKey of Object.keys(typeMaterialCharacteristics)) {
|
|
249
|
+
const characteristicMode = (_b = typeMaterialCharacteristics[characteristicKey]) === null || _b === void 0 ? void 0 : _b.znach;
|
|
250
|
+
if (!characteristicMode)
|
|
251
|
+
continue;
|
|
252
|
+
result[characteristicKey] =
|
|
253
|
+
characteristicMode === utils_1.TypeMaterialCharZnachEnum.permanent
|
|
254
|
+
? ((_c = getMaterialCharacteristicValue(context, characteristicKey)) !== null && _c !== void 0 ? _c : undefined)
|
|
255
|
+
: ((_d = getWorkpieceCharacteristicValue(context, characteristicKey)) !== null && _d !== void 0 ? _d : undefined);
|
|
256
|
+
}
|
|
257
|
+
const density = getMaterialCharacteristicValue(context, 'density');
|
|
258
|
+
if (density !== null)
|
|
259
|
+
result.density = density;
|
|
260
|
+
const mass = getWorkpieceCharacteristicValue(context, 'mass');
|
|
261
|
+
if (mass !== null)
|
|
262
|
+
result.mass = mass;
|
|
263
|
+
const trash = getWorkpieceCharacteristicValue(context, 'trash');
|
|
264
|
+
if (trash !== null)
|
|
265
|
+
result.trash = trash;
|
|
266
|
+
return result;
|
|
267
|
+
};
|
|
268
|
+
const getPreparedValue = (prepared, key) => {
|
|
269
|
+
const value = prepared[key];
|
|
270
|
+
return typeof value === 'number' && !Number.isNaN(value) ? value : null;
|
|
271
|
+
};
|
|
272
|
+
/**
|
|
273
|
+
* Реестр источников значений переменных.
|
|
274
|
+
* Здесь описано, откуда брать каждую переменную под расчет массы заготовки.
|
|
275
|
+
*/
|
|
276
|
+
exports.WORKPIECE_MASS_VARIABLE_RESOLVERS = {
|
|
277
|
+
density: (context, prepared) => {
|
|
278
|
+
var _a;
|
|
279
|
+
return (_a = getPreparedValue(prepared, 'density')) !== null && _a !== void 0 ? _a : getMaterialCharacteristicValue(context, 'density');
|
|
280
|
+
},
|
|
281
|
+
length: (_context, prepared) => getPreparedValue(prepared, 'length'),
|
|
282
|
+
width: (_context, prepared) => getPreparedValue(prepared, 'width'),
|
|
283
|
+
height: (_context, prepared) => getPreparedValue(prepared, 'height'),
|
|
284
|
+
thickness: (_context, prepared) => getPreparedValue(prepared, 'thickness'),
|
|
285
|
+
wallThickness: (_context, prepared) => getPreparedValue(prepared, 'wallThickness'),
|
|
286
|
+
outsideDiameter: (_context, prepared) => getPreparedValue(prepared, 'outsideDiameter'),
|
|
287
|
+
areaCrossSectional: (_context, prepared) => getPreparedValue(prepared, 'areaCrossSectional'),
|
|
288
|
+
// TODO: добавить поле в model/type_material/material/workpiece_characterization
|
|
289
|
+
acrossFlats: (context, prepared) => {
|
|
290
|
+
var _a;
|
|
291
|
+
return (_a = getPreparedValue(prepared, 'acrossFlats')) !== null && _a !== void 0 ? _a : getMaterialCharacteristicValue(context, 'acrossFlats');
|
|
292
|
+
},
|
|
293
|
+
// TODO: добавить поле в material.characteristics или отдельную модель
|
|
294
|
+
massPerMeter: (context, prepared) => {
|
|
295
|
+
var _a;
|
|
296
|
+
return (_a = getPreparedValue(prepared, 'massPerMeter')) !== null && _a !== void 0 ? _a : getMaterialCharacteristicValue(context, 'massPerMeter');
|
|
297
|
+
}
|
|
298
|
+
};
|
|
299
|
+
const getRequiredVar = (vars, key) => {
|
|
300
|
+
const value = vars[key];
|
|
301
|
+
if (typeof value !== 'number' || Number.isNaN(value)) {
|
|
302
|
+
throw new Error(`Не заполнена переменная "${key}" для расчета массы заготовки`);
|
|
303
|
+
}
|
|
304
|
+
return value;
|
|
305
|
+
};
|
|
306
|
+
/**
|
|
307
|
+
* Реестр математических алгоритмов расчета.
|
|
308
|
+
* Здесь только математика, без поиска значений по моделям.
|
|
309
|
+
*/
|
|
310
|
+
exports.WORKPIECE_MASS_CALCULATORS = {
|
|
311
|
+
[enum_1.WorkpieceMassFormulaKey.boundingBox]: vars => {
|
|
312
|
+
const density = getRequiredVar(vars, 'density');
|
|
313
|
+
const length = getRequiredVar(vars, 'length');
|
|
314
|
+
const width = getRequiredVar(vars, 'width');
|
|
315
|
+
const height = getRequiredVar(vars, 'height');
|
|
316
|
+
return density * length * width * height;
|
|
317
|
+
},
|
|
318
|
+
[enum_1.WorkpieceMassFormulaKey.rectangularSection]: vars => {
|
|
319
|
+
const density = getRequiredVar(vars, 'density');
|
|
320
|
+
const length = getRequiredVar(vars, 'length');
|
|
321
|
+
const width = getRequiredVar(vars, 'width');
|
|
322
|
+
const thickness = getRequiredVar(vars, 'thickness');
|
|
323
|
+
return density * length * width * thickness;
|
|
324
|
+
},
|
|
325
|
+
[enum_1.WorkpieceMassFormulaKey.solidRoundSection]: vars => {
|
|
326
|
+
const density = getRequiredVar(vars, 'density');
|
|
327
|
+
const outsideDiameter = getRequiredVar(vars, 'outsideDiameter');
|
|
328
|
+
const length = getRequiredVar(vars, 'length');
|
|
329
|
+
return (density * Math.PI * Math.pow(outsideDiameter, 2) * length) / 4;
|
|
330
|
+
},
|
|
331
|
+
[enum_1.WorkpieceMassFormulaKey.hollowRoundSection]: vars => {
|
|
332
|
+
const density = getRequiredVar(vars, 'density');
|
|
333
|
+
const outsideDiameter = getRequiredVar(vars, 'outsideDiameter');
|
|
334
|
+
const wallThickness = getRequiredVar(vars, 'wallThickness');
|
|
335
|
+
const length = getRequiredVar(vars, 'length');
|
|
336
|
+
return (density *
|
|
337
|
+
Math.PI *
|
|
338
|
+
wallThickness *
|
|
339
|
+
(outsideDiameter - wallThickness) *
|
|
340
|
+
length);
|
|
341
|
+
},
|
|
342
|
+
[enum_1.WorkpieceMassFormulaKey.hollowProfileSection]: vars => {
|
|
343
|
+
const density = getRequiredVar(vars, 'density');
|
|
344
|
+
const width = getRequiredVar(vars, 'width');
|
|
345
|
+
const height = getRequiredVar(vars, 'height');
|
|
346
|
+
const wallThickness = getRequiredVar(vars, 'wallThickness');
|
|
347
|
+
const length = getRequiredVar(vars, 'length');
|
|
348
|
+
return (density *
|
|
349
|
+
(width * height -
|
|
350
|
+
(width - 2 * wallThickness) * (height - 2 * wallThickness)) *
|
|
351
|
+
length);
|
|
352
|
+
},
|
|
353
|
+
[enum_1.WorkpieceMassFormulaKey.hexSection]: vars => {
|
|
354
|
+
const density = getRequiredVar(vars, 'density');
|
|
355
|
+
const acrossFlats = getRequiredVar(vars, 'acrossFlats');
|
|
356
|
+
const length = getRequiredVar(vars, 'length');
|
|
357
|
+
return density * 0.866025 * Math.pow(acrossFlats, 2) * length;
|
|
358
|
+
},
|
|
359
|
+
[enum_1.WorkpieceMassFormulaKey.sectionArea]: vars => {
|
|
360
|
+
const density = getRequiredVar(vars, 'density');
|
|
361
|
+
const areaCrossSectional = getRequiredVar(vars, 'areaCrossSectional');
|
|
362
|
+
const length = getRequiredVar(vars, 'length');
|
|
363
|
+
return density * areaCrossSectional * length;
|
|
364
|
+
},
|
|
365
|
+
[enum_1.WorkpieceMassFormulaKey.linearMass]: vars => {
|
|
366
|
+
const massPerMeter = getRequiredVar(vars, 'massPerMeter');
|
|
367
|
+
const length = getRequiredVar(vars, 'length');
|
|
368
|
+
return massPerMeter * length;
|
|
369
|
+
}
|
|
370
|
+
};
|
|
371
|
+
const resolveWorkpieceMassVariables = (context, variableKeys) => {
|
|
372
|
+
var _a;
|
|
373
|
+
const prepared = getPreparedWorkpieceValues(context);
|
|
374
|
+
const result = {};
|
|
375
|
+
for (const key of variableKeys) {
|
|
376
|
+
result[key] =
|
|
377
|
+
(_a = exports.WORKPIECE_MASS_VARIABLE_RESOLVERS[key](context, prepared)) !== null && _a !== void 0 ? _a : undefined;
|
|
378
|
+
}
|
|
379
|
+
return result;
|
|
380
|
+
};
|
|
381
|
+
exports.resolveWorkpieceMassVariables = resolveWorkpieceMassVariables;
|
|
382
|
+
const calculateWorkpieceMassPreview = (context) => {
|
|
383
|
+
var _a;
|
|
384
|
+
const formulaKey = context.workpieceMassFormulaKey ||
|
|
385
|
+
((_a = context.typeMaterial) === null || _a === void 0 ? void 0 : _a.workpieceMassFormulaKey) ||
|
|
386
|
+
null;
|
|
387
|
+
if (!formulaKey)
|
|
388
|
+
return null;
|
|
389
|
+
const formula = exports.WORKPIECE_MASS_FORMULAS.find(currentFormula => currentFormula.key === formulaKey);
|
|
390
|
+
if (!formula) {
|
|
391
|
+
throw new Error(`Формула расчета массы заготовки "${formulaKey}" не найдена`);
|
|
392
|
+
}
|
|
393
|
+
const variables = (0, exports.resolveWorkpieceMassVariables)(context, formula.variables.map(variable => variable.key));
|
|
394
|
+
return {
|
|
395
|
+
formulaKey,
|
|
396
|
+
mass: exports.WORKPIECE_MASS_CALCULATORS[formulaKey](variables),
|
|
397
|
+
variables
|
|
398
|
+
};
|
|
399
|
+
};
|
|
400
|
+
exports.calculateWorkpieceMassPreview = calculateWorkpieceMassPreview;
|
|
@@ -25,6 +25,7 @@ export * from './dto/set-start-time.dto';
|
|
|
25
25
|
export * from './dto/workload-by-entity.dto';
|
|
26
26
|
export * from './dto/get-deficits-detal-by-production-task.dto';
|
|
27
27
|
export * from './schemas/production-operation-pos.schema';
|
|
28
|
+
export * from './schemas/orders-summary-by-entity.schema';
|
|
28
29
|
export * from './dto/create-operation-pos.dto';
|
|
29
30
|
export * from './methods/methods';
|
|
30
31
|
export * from './default-data/default-data';
|
|
@@ -41,6 +41,7 @@ __exportStar(require("./dto/set-start-time.dto"), exports);
|
|
|
41
41
|
__exportStar(require("./dto/workload-by-entity.dto"), exports);
|
|
42
42
|
__exportStar(require("./dto/get-deficits-detal-by-production-task.dto"), exports);
|
|
43
43
|
__exportStar(require("./schemas/production-operation-pos.schema"), exports);
|
|
44
|
+
__exportStar(require("./schemas/orders-summary-by-entity.schema"), exports);
|
|
44
45
|
__exportStar(require("./dto/create-operation-pos.dto"), exports);
|
|
45
46
|
__exportStar(require("./methods/methods"), exports);
|
|
46
47
|
__exportStar(require("./default-data/default-data"), exports);
|