@molochko-dev/data 1.4.106 → 1.4.107

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.
@@ -1,3 +1,3 @@
1
1
  import { BaseAnimal } from '../types';
2
- import { EVENT_TYPES_ENUM } from '../enums';
2
+ import { EVENT_TYPES_ENUM } from '../event';
3
3
  export declare function filter<T extends BaseAnimal>(animals: T[], eventType: EVENT_TYPES_ENUM): T[];
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.filter = void 0;
4
4
  const enums_1 = require("../enums");
5
5
  const date_1 = require("../helpers/date");
6
+ const event_1 = require("../event");
6
7
  /*
7
8
 
8
9
  const filtered = filter(animals, eventType)
@@ -72,6 +73,7 @@ class AnimalEventFilter {
72
73
  });
73
74
  return result;
74
75
  }
76
+ // TODO удалить
75
77
  otelFilter(animals) {
76
78
  const result = animals.filter((animal) => {
77
79
  const genderOk = this.genderFilter(animal, enums_1.ANIMAL_GENDER_ENUM.cow);
@@ -83,6 +85,17 @@ class AnimalEventFilter {
83
85
  });
84
86
  return result;
85
87
  }
88
+ calvingFilter(animals) {
89
+ const result = animals.filter((animal) => {
90
+ const genderOk = this.genderFilter(animal, enums_1.ANIMAL_GENDER_ENUM.cow);
91
+ const statusOk = this.statusFilter(animal, [this.status.DRY, this.status.PREGNANT]);
92
+ const ageOk = this.ageFilter(animal, this.defaultCowAge);
93
+ if (genderOk && statusOk && ageOk) {
94
+ return animal;
95
+ }
96
+ });
97
+ return result;
98
+ }
86
99
  recheckFilter(animals) {
87
100
  const result = animals.filter((animal) => {
88
101
  const genderOk = this.genderFilter(animal, enums_1.ANIMAL_GENDER_ENUM.cow);
@@ -90,7 +103,7 @@ class AnimalEventFilter {
90
103
  let availableStatus = [this.status.BRED, this.status.PREGNANT, this.status.DRY];
91
104
  if (animal.animalEventRelation) {
92
105
  const previousRechecks = animal.animalEventRelation.filter((row) => {
93
- return row.eventDetail.type === enums_1.EVENT_TYPES_ENUM.recheck;
106
+ return row.eventDetail.type === event_1.EVENT_TYPES_ENUM.recheck;
94
107
  });
95
108
  if (previousRechecks.length == 0) {
96
109
  availableStatus = [this.status.BRED];
@@ -128,30 +141,30 @@ class AnimalEventFilter {
128
141
  }
129
142
  filter(animals, eventType) {
130
143
  switch (eventType) {
131
- case enums_1.EVENT_TYPES_ENUM.abort:
144
+ case event_1.EVENT_TYPES_ENUM.abort:
132
145
  return this.abortFilter(animals);
133
- case enums_1.EVENT_TYPES_ENUM.neosem:
146
+ case event_1.EVENT_TYPES_ENUM.neosem:
134
147
  return this.neosemFilter(animals);
135
- case enums_1.EVENT_TYPES_ENUM.insemenation:
148
+ case event_1.EVENT_TYPES_ENUM.insemenation:
136
149
  return this.insemenationFilter(animals);
137
- case enums_1.EVENT_TYPES_ENUM.otel:
138
- return this.otelFilter(animals);
139
- case enums_1.EVENT_TYPES_ENUM.recheck:
150
+ case event_1.EVENT_TYPES_ENUM.calving:
151
+ return this.calvingFilter(animals);
152
+ case event_1.EVENT_TYPES_ENUM.recheck:
140
153
  return this.recheckFilter(animals);
141
- case enums_1.EVENT_TYPES_ENUM.suhostoi:
154
+ case event_1.EVENT_TYPES_ENUM.suhostoi:
142
155
  return this.suhostoiFilter(animals);
143
- case enums_1.EVENT_TYPES_ENUM.pozSuhostoi:
156
+ case event_1.EVENT_TYPES_ENUM.pozSuhostoi:
144
157
  return this.pozSuhostoiFilter(animals);
145
- case enums_1.EVENT_TYPES_ENUM.perevod:
158
+ case event_1.EVENT_TYPES_ENUM.perevod:
146
159
  return this.perevodFilter(animals);
147
- case enums_1.EVENT_TYPES_ENUM.transferOut:
160
+ case event_1.EVENT_TYPES_ENUM.transferOut:
148
161
  return this.transferOutFilter(animals);
149
- case enums_1.EVENT_TYPES_ENUM.treatment:
162
+ case event_1.EVENT_TYPES_ENUM.treatment:
150
163
  return this.treatmentFilter(animals);
151
- case (enums_1.EVENT_TYPES_ENUM.ves,
152
- enums_1.EVENT_TYPES_ENUM.rost,
153
- enums_1.EVENT_TYPES_ENUM.upitannost,
154
- enums_1.EVENT_TYPES_ENUM.ohota):
164
+ case (event_1.EVENT_TYPES_ENUM.ves,
165
+ event_1.EVENT_TYPES_ENUM.rost,
166
+ event_1.EVENT_TYPES_ENUM.upitannost,
167
+ event_1.EVENT_TYPES_ENUM.ohota):
155
168
  return this.weightFilter(animals);
156
169
  default:
157
170
  return animals;
@@ -78,9 +78,9 @@ export declare enum MEDMETHOD_ENUM {
78
78
  }
79
79
  export declare enum EVENT_TYPES_ENUM {
80
80
  otel = "otel",
81
+ calving = "calving",
81
82
  recheck = "recheck",
82
83
  ohota = "ohota",
83
- osemenenie = "osemenenie",
84
84
  insemenation = "insemenation",
85
85
  stelnaya = "stelnaya",
86
86
  yalovaya = "yalovaya",
@@ -87,11 +87,13 @@ var MEDMETHOD_ENUM;
87
87
  })(MEDMETHOD_ENUM = exports.MEDMETHOD_ENUM || (exports.MEDMETHOD_ENUM = {}));
88
88
  var EVENT_TYPES_ENUM;
89
89
  (function (EVENT_TYPES_ENUM) {
90
+ // TODO otel - удалить
90
91
  EVENT_TYPES_ENUM["otel"] = "otel";
92
+ EVENT_TYPES_ENUM["calving"] = "calving";
91
93
  EVENT_TYPES_ENUM["recheck"] = "recheck";
92
94
  EVENT_TYPES_ENUM["ohota"] = "ohota";
93
95
  // TODO osemenenie - удалить
94
- EVENT_TYPES_ENUM["osemenenie"] = "osemenenie";
96
+ // osemenenie = 'osemenenie', // ОСЕМЕНЕНИЕ *
95
97
  EVENT_TYPES_ENUM["insemenation"] = "insemenation";
96
98
  EVENT_TYPES_ENUM["stelnaya"] = "stelnaya";
97
99
  EVENT_TYPES_ENUM["yalovaya"] = "yalovaya";
package/dist/types.d.ts CHANGED
@@ -1,4 +1,5 @@
1
- import { USER_PERMISSION_ENUM, USER_PERMISSION_METHOD_ENUM, EVENT_TYPES_ENUM, ANIMAL_GENDER_ENUM, COW_STATUS, BULL_STATUS } from './enums';
1
+ import { USER_PERMISSION_ENUM, USER_PERMISSION_METHOD_ENUM, ANIMAL_GENDER_ENUM, COW_STATUS, BULL_STATUS } from './enums';
2
+ import { EVENT_TYPES_ENUM } from "./event";
2
3
  export interface EnumItem {
3
4
  readonly id: string;
4
5
  readonly label: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@molochko-dev/data",
3
- "version": "1.4.106",
3
+ "version": "1.4.107",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "typings/index.d.ts",
@@ -1,7 +1,7 @@
1
1
  import { AnimalStatus, BaseAnimal } from '../types';
2
- import { ANIMAL_GENDER_ENUM, COW_STATUS, EVENT_TYPES_ENUM } from '../enums';
2
+ import { ANIMAL_GENDER_ENUM, COW_STATUS } from '../enums';
3
3
  import { getMonthFromDate } from '../helpers/date';
4
-
4
+ import { EVENT_TYPES_ENUM } from '../event'
5
5
  /*
6
6
 
7
7
  const filtered = filter(animals, eventType)
@@ -89,7 +89,7 @@ class AnimalEventFilter {
89
89
 
90
90
  return result;
91
91
  }
92
-
92
+ // TODO удалить
93
93
  otelFilter<T extends BaseAnimal>(animals: T[]): T[] {
94
94
  const result = animals.filter((animal) => {
95
95
  const genderOk = this.genderFilter(animal, ANIMAL_GENDER_ENUM.cow);
@@ -103,6 +103,19 @@ class AnimalEventFilter {
103
103
  return result;
104
104
  }
105
105
 
106
+ calvingFilter<T extends BaseAnimal>(animals: T[]): T[] {
107
+ const result = animals.filter((animal) => {
108
+ const genderOk = this.genderFilter(animal, ANIMAL_GENDER_ENUM.cow);
109
+ const statusOk = this.statusFilter(animal, [this.status.DRY, this.status.PREGNANT]);
110
+ const ageOk = this.ageFilter(animal, this.defaultCowAge);
111
+
112
+ if (genderOk && statusOk && ageOk) {
113
+ return animal;
114
+ }
115
+ });
116
+ return result;
117
+ }
118
+
106
119
  recheckFilter<T extends BaseAnimal>(animals: T[]): T[] {
107
120
  const result = animals.filter((animal) => {
108
121
  const genderOk = this.genderFilter(animal, ANIMAL_GENDER_ENUM.cow);
@@ -163,8 +176,8 @@ class AnimalEventFilter {
163
176
  return this.neosemFilter(animals);
164
177
  case EVENT_TYPES_ENUM.insemenation:
165
178
  return this.insemenationFilter(animals);
166
- case EVENT_TYPES_ENUM.otel:
167
- return this.otelFilter(animals);
179
+ case EVENT_TYPES_ENUM.calving:
180
+ return this.calvingFilter(animals);
168
181
  case EVENT_TYPES_ENUM.recheck:
169
182
  return this.recheckFilter(animals);
170
183
  case EVENT_TYPES_ENUM.suhostoi:
@@ -86,11 +86,13 @@ export enum MEDMETHOD_ENUM {
86
86
  }
87
87
 
88
88
  export enum EVENT_TYPES_ENUM {
89
+ // TODO otel - удалить
89
90
  otel = 'otel', // ОТЕЛ ----- addTocalendar
91
+ calving = 'calving', // ОТЕЛ ----- addTocalendar
90
92
  recheck = 'recheck', // ПЕРЕПРОВЕРИТЬ * ----- addTocalendar
91
93
  ohota = 'ohota', // ОХОТА ----- addTocalendar
92
94
  // TODO osemenenie - удалить
93
- osemenenie = 'osemenenie', // ОСЕМЕНЕНИЕ *
95
+ // osemenenie = 'osemenenie', // ОСЕМЕНЕНИЕ *
94
96
  insemenation = 'insemenation', // ОСЕМЕНЕНИЕ *
95
97
  stelnaya = 'stelnaya', // СТЕЛЬНАЯ
96
98
  yalovaya = 'yalovaya', // ЯЛОВАЯ (НЕ СТЕЛЬНАЯ) ----- addTocalendar
package/src/types.ts CHANGED
@@ -1,12 +1,13 @@
1
1
  import {
2
2
  USER_PERMISSION_ENUM,
3
3
  USER_PERMISSION_METHOD_ENUM,
4
- EVENT_TYPES_ENUM,
5
4
  ANIMAL_GENDER_ENUM,
6
5
  COW_STATUS,
7
6
  BULL_STATUS,
8
7
  } from './enums';
9
8
 
9
+ import { EVENT_TYPES_ENUM} from "./event";
10
+
10
11
  export interface EnumItem {
11
12
  readonly id: string;
12
13
  readonly label: string;