@things-factory/operato-pms 4.3.359 → 4.3.371

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,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.RecordTransaction = exports.Ramp = exports.PlantationInventory = exports.Organization = exports.OrganizationStaff = exports.DailyLoading = exports.DailyLoadingRamp = exports.DailyLoadingDetail = exports.DailyHarvest = exports.DailyHarvestDetail = exports.DailyDispatch = exports.DailyDispatchDetail = exports.DailyBlockDetail = exports.Block = exports.BlockDetail = exports.PlantationSetting = exports.Truck = exports.entities = void 0;
3
+ exports.RecordTransaction = exports.RampBlockHistory = exports.Ramp = exports.PlantationInventory = exports.Organization = exports.OrganizationStaff = exports.DailyLoading = exports.DailyLoadingRamp = exports.DailyLoadingDetail = exports.DailyHarvest = exports.DailyHarvestDetail = exports.DailyDispatch = exports.DailyDispatchDetail = exports.DailyBlockDetail = exports.Block = exports.BlockDetail = exports.PlantationSetting = exports.Truck = exports.entities = void 0;
4
4
  const truck_1 = require("./truck");
5
5
  Object.defineProperty(exports, "Truck", { enumerable: true, get: function () { return truck_1.Truck; } });
6
6
  const plantation_setting_1 = require("./plantation-setting");
@@ -33,6 +33,8 @@ const plantation_inventory_1 = require("./plantation-inventory");
33
33
  Object.defineProperty(exports, "PlantationInventory", { enumerable: true, get: function () { return plantation_inventory_1.PlantationInventory; } });
34
34
  const ramp_1 = require("./ramp");
35
35
  Object.defineProperty(exports, "Ramp", { enumerable: true, get: function () { return ramp_1.Ramp; } });
36
+ const ramp_block_history_1 = require("./ramp-block-history");
37
+ Object.defineProperty(exports, "RampBlockHistory", { enumerable: true, get: function () { return ramp_block_history_1.RampBlockHistory; } });
36
38
  const record_transaction_1 = require("./record-transaction");
37
39
  Object.defineProperty(exports, "RecordTransaction", { enumerable: true, get: function () { return record_transaction_1.RecordTransaction; } });
38
40
  exports.entities = [
@@ -52,6 +54,7 @@ exports.entities = [
52
54
  organization_1.Organization,
53
55
  plantation_inventory_1.PlantationInventory,
54
56
  ramp_1.Ramp,
57
+ ramp_block_history_1.RampBlockHistory,
55
58
  record_transaction_1.RecordTransaction
56
59
  ];
57
60
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../server/entities/index.ts"],"names":[],"mappings":";;;AAAA,mCAA+B;AAuC9B,sFAvCQ,aAAK,OAuCR;AAtCN,6DAAwD;AAuCvD,kGAvCQ,sCAAiB,OAuCR;AAtClB,iDAA4C;AAuC1C,4FAvCO,0BAAW,OAuCP;AAtCb,mCAA+B;AAuC7B,sFAvCO,aAAK,OAuCP;AAtCP,6DAAuD;AAuCrD,iGAvCO,qCAAgB,OAuCP;AAtClB,mEAA6D;AAuC3D,oGAvCO,2CAAmB,OAuCP;AAtCrB,qDAAgD;AAuC9C,8FAvCO,8BAAa,OAuCP;AAtCf,iEAA2D;AAuCzD,mGAvCO,yCAAkB,OAuCP;AAtCpB,mDAA8C;AAuC5C,6FAvCO,4BAAY,OAuCP;AAtCd,iEAA2D;AAuCzD,mGAvCO,yCAAkB,OAuCP;AAtCpB,6DAAuD;AAuCrD,iGAvCO,qCAAgB,OAuCP;AAtClB,mDAA8C;AAuC5C,6FAvCO,4BAAY,OAuCP;AAtCd,6DAAwD;AAuCtD,kGAvCO,sCAAiB,OAuCP;AAtCnB,iDAA6C;AAuC3C,6FAvCO,2BAAY,OAuCP;AAtCd,iEAA4D;AAuC1D,oGAvCO,0CAAmB,OAuCP;AAtCrB,iCAA6B;AAuC3B,qFAvCO,WAAI,OAuCP;AAtCN,6DAAwD;AAuCtD,kGAvCO,sCAAiB,OAuCP;AArCN,QAAA,QAAQ,GAAG;IACvB,aAAK;IACL,sCAAiB;IAChB,0BAAW;IACX,aAAK;IACL,qCAAgB;IAChB,2CAAmB;IACnB,8BAAa;IACb,yCAAkB;IAClB,4BAAY;IACZ,yCAAkB;IAClB,q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ACjB,2BAAY;IACZ,0CAAmB;IACnB,WAAI;IACJ,qCAAgB;IAChB,sCAAiB;CAClB,CAAA"}
@@ -0,0 +1,93 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ var _a, _b, _c;
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ exports.RampBlockHistory = void 0;
14
+ const auth_base_1 = require("@things-factory/auth-base");
15
+ const shell_1 = require("@things-factory/shell");
16
+ const typeorm_1 = require("typeorm");
17
+ const entities_1 = require("../entities");
18
+ let RampBlockHistory = class RampBlockHistory {
19
+ };
20
+ __decorate([
21
+ (0, typeorm_1.PrimaryGeneratedColumn)('uuid'),
22
+ __metadata("design:type", String)
23
+ ], RampBlockHistory.prototype, "id", void 0);
24
+ __decorate([
25
+ (0, typeorm_1.Column)({ nullable: true }),
26
+ __metadata("design:type", Number)
27
+ ], RampBlockHistory.prototype, "seq", void 0);
28
+ __decorate([
29
+ (0, typeorm_1.ManyToOne)(type => shell_1.Domain),
30
+ __metadata("design:type", typeof (_a = typeof shell_1.Domain !== "undefined" && shell_1.Domain) === "function" ? _a : Object)
31
+ ], RampBlockHistory.prototype, "domain", void 0);
32
+ __decorate([
33
+ (0, typeorm_1.ManyToOne)(type => entities_1.Block, { nullable: true }),
34
+ __metadata("design:type", entities_1.Block)
35
+ ], RampBlockHistory.prototype, "block", void 0);
36
+ __decorate([
37
+ (0, typeorm_1.ManyToOne)(type => entities_1.Ramp, { nullable: true }),
38
+ __metadata("design:type", entities_1.Ramp)
39
+ ], RampBlockHistory.prototype, "ramp", void 0);
40
+ __decorate([
41
+ (0, typeorm_1.ManyToOne)(type => entities_1.DailyDispatch, { nullable: true }),
42
+ __metadata("design:type", entities_1.DailyDispatch)
43
+ ], RampBlockHistory.prototype, "dailyDispatch", void 0);
44
+ __decorate([
45
+ (0, typeorm_1.Column)({ type: 'float', default: 0 }),
46
+ __metadata("design:type", Number)
47
+ ], RampBlockHistory.prototype, "weight", void 0);
48
+ __decorate([
49
+ (0, typeorm_1.Column)({ type: 'float', default: 0 }),
50
+ __metadata("design:type", Number)
51
+ ], RampBlockHistory.prototype, "previousWeight", void 0);
52
+ __decorate([
53
+ (0, typeorm_1.Column)({ type: 'float', default: 0 }),
54
+ __metadata("design:type", Number)
55
+ ], RampBlockHistory.prototype, "currentWeight", void 0);
56
+ __decorate([
57
+ (0, typeorm_1.Column)(),
58
+ __metadata("design:type", String)
59
+ ], RampBlockHistory.prototype, "transactionType", void 0);
60
+ __decorate([
61
+ (0, typeorm_1.Column)(),
62
+ __metadata("design:type", String)
63
+ ], RampBlockHistory.prototype, "transactionDate", void 0);
64
+ __decorate([
65
+ (0, typeorm_1.Column)({ nullable: true }),
66
+ __metadata("design:type", Date)
67
+ ], RampBlockHistory.prototype, "deletedAt", void 0);
68
+ __decorate([
69
+ (0, typeorm_1.CreateDateColumn)(),
70
+ __metadata("design:type", Date)
71
+ ], RampBlockHistory.prototype, "createdAt", void 0);
72
+ __decorate([
73
+ (0, typeorm_1.UpdateDateColumn)(),
74
+ __metadata("design:type", Date)
75
+ ], RampBlockHistory.prototype, "updatedAt", void 0);
76
+ __decorate([
77
+ (0, typeorm_1.ManyToOne)(type => auth_base_1.User, {
78
+ nullable: true
79
+ }),
80
+ __metadata("design:type", typeof (_b = typeof auth_base_1.User !== "undefined" && auth_base_1.User) === "function" ? _b : Object)
81
+ ], RampBlockHistory.prototype, "creator", void 0);
82
+ __decorate([
83
+ (0, typeorm_1.ManyToOne)(type => auth_base_1.User, {
84
+ nullable: true
85
+ }),
86
+ __metadata("design:type", typeof (_c = typeof auth_base_1.User !== "undefined" && auth_base_1.User) === "function" ? _c : Object)
87
+ ], RampBlockHistory.prototype, "updater", void 0);
88
+ RampBlockHistory = __decorate([
89
+ (0, typeorm_1.Entity)(),
90
+ (0, typeorm_1.Index)('ix_ramp_block_history_0', (rampBlockHistory) => [rampBlockHistory.id], { unique: true })
91
+ ], RampBlockHistory);
92
+ exports.RampBlockHistory = RampBlockHistory;
93
+ //# sourceMappingURL=ramp-block-history.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ramp-block-history.js","sourceRoot":"","sources":["../../server/entities/ramp-block-history.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,yDAAgD;AAChD,iDAA8C;AAC9C,qCAAsH;AACtH,0CAA6E;AAQtE,IAAM,gBAAgB,GAAtB,MAAM,gBAAgB;CAyD5B,CAAA;AAxDC;IAAC,IAAA,gCAAsB,EAAC,MAAM,CAAC;;4CACrB;AAEV;IAAC,IAAA,gBAAM,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;6CAChB;AAEX;IAAC,IAAA,mBAAS,EAAC,IAAI,CAAC,EAAE,CAAC,cAAM,CAAC;kDAClB,cAAM,oBAAN,cAAM;gDAAA;AAEd;IAAC,IAAA,mBAAS,EAAC,IAAI,CAAC,EAAE,CAAC,gBAAK,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;8BACtC,gBAAK;+CAAA;AAEZ;IAAC,IAAA,mBAAS,EAAC,IAAI,CAAC,EAAE,CAAC,eAAI,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;8BACtC,eAAI;8CAAA;AAEV;IAAC,IAAA,mBAAS,EAAC,IAAI,CAAC,EAAE,CAAC,wBAAa,EAAE,EAAE,QAAQ,EAAE,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select blk.block_id, coalesce(sum(field_bunches),0) AS today_field_bunches,
44
- round(coalesce(sum(ramp_weight),0)::numeric,4) AS today_ramp_weight,
45
- sum(case when transaction_type = 'HARVEST' OR transaction_type = 'BUNCHES_ADJUSTMENT' then field_bunches else 0 end) as today_bunch_harvest,
46
- sum(case when transaction_type = 'LOADING' OR transaction_type = 'LOADING_ADJUSTMENT' then -field_bunches else 0 end) as today_bunch_collected,
47
- round(sum(case when transaction_type = 'LOADING' OR transaction_type = 'LOADING_ADJUSTMENT' then ramp_weight else 0 end)::numeric,4) as today_ramp_weight_collected,
48
- round(sum(case when transaction_type = 'DISPATCHMENT' OR transaction_type = 'DISPATCHMENT_ADJUSTMENT' then -ramp_weight else 0 end)::numeric,4) as today_weight_dispatch,
49
- transaction_date
50
- from record_transactions t2
51
- inner join temp_blocks blk on blk.id = t2.block_id
52
- where transaction_date <= $1
53
- group by blk.block_id, transaction_date
43
+ SELECT *,
44
+ COALESCE(-(SELECT sum(weight) FROM ramp_block_histories rbh WHERE rbh.block_id = src.block_id AND rbh.transaction_date = src.transaction_date AND rbh.transaction_type='DISPATCH'),0) AS today_weight_dispatch
45
+ FROM (
46
+ select blk.block_id, coalesce(sum(field_bunches),0) AS today_field_bunches,
47
+ round(coalesce(sum(ramp_weight),0)::numeric,4) AS today_ramp_weight,
48
+ sum(case when transaction_type = 'HARVEST' then field_bunches else 0 end) as today_bunch_harvest,
49
+ sum(case when transaction_type = 'LOADING' then -field_bunches else 0 end) as today_bunch_collected,
50
+ round(sum(case when transaction_type = 'LOADING' then ramp_weight else 0 end)::numeric,4) as today_ramp_weight_collected,
51
+ --round(sum(case when transaction_type = 'DISPATCHMENT' then -ramp_weight else 0 end)::numeric,4) as today_weight_dispatch,
52
+ transaction_date
53
+ from record_transactions t2
54
+ inner join temp_blocks blk on blk.id = t2.block_id
55
+ where transaction_date <= $1
56
+ group by blk.block_id, transaction_date
57
+ ) src
54
58
  )
55
59
  `, [toDateString]);
56
60
  await tx.query(`
@@ -138,6 +142,7 @@ exports.dailyProductionReports = {
138
142
  todayWeightDispatch: parseFloat(itm.today_weight_dispatch).toFixed(4)
139
143
  };
140
144
  });
145
+ // updateAllData()
141
146
  return { items, total: total[0].count };
142
147
  }
143
148
  catch (error) {
@@ -145,4 +150,60 @@ exports.dailyProductionReports = {
145
150
  }
146
151
  }
147
152
  };
153
+ // async function updateAllData() {
154
+ // await getManager().transaction(async txMgr => {
155
+ // let data = await txMgr.query(`
156
+ // SELECT * FROM (
157
+ // SELECT uuid_generate_v4() AS id, DATE(dd.dispatch_at)::varchar AS transaction_date, 'DISPATCH' AS transaction_type, dd.dispatch_at AS created_at, dd.dispatch_at AS updated_at,
158
+ // ddd.collected_ramp_weight AS dispatch_weight, '980f20a0-747c-4d04-a870-97a09f6ba807' AS domain_id, ddd.ramp_id, '0933baea-e099-494b-9791-3dfe805731f0' AS creator_id, '0933baea-e099-494b-9791-3dfe805731f0' AS updater_id,
159
+ // dd.id as daily_dispatch_id
160
+ // FROM daily_dispatch_details ddd
161
+ // INNER JOIN daily_dispatches dd ON dd.id = ddd.daily_dispatch_id
162
+ // WHERE dd.dispatch_at >='2023-07-01 00:00:00.000'
163
+ // ) src ORDER BY src.ramp_id, src.transaction_date
164
+ // `)
165
+ // // await data.forEach(async dt => {
166
+ // for (let dtIdx = 0; dtIdx < data.length; dtIdx++) {
167
+ // const dt = data[dtIdx];
168
+ // let rampBlockHistory = await txMgr.query(`
169
+ // SELECT * FROM (
170
+ // SELECT *, ROW_NUMBER () OVER (PARTITION BY ramp_id, block_id ORDER BY transaction_date desc, transaction_type) AS rn FROM ramp_block_histories
171
+ // WHERE ramp_id =$1 AND transaction_date <= $2
172
+ // ) foo WHERE rn = 1
173
+ // `, [dt.ramp_id, dt.transaction_date])
174
+ // let totalRampWeight: number = rampBlockHistory.reduce((total, currentValue) => {
175
+ // total += currentValue.previous_weight + currentValue.weight
176
+ // return total
177
+ // }, 0)
178
+ // for (let index = 0; index < rampBlockHistory.length; index++) {
179
+ // const dt2 = rampBlockHistory[index];
180
+ // let currentRampBlockWeight = dt2.previous_weight + dt2.weight
181
+ // let percentage = parseFloat((currentRampBlockWeight / totalRampWeight).toFixed(4))
182
+ // let weight = (-dt.dispatch_weight * percentage).toFixed(4)
183
+ // // insert into ramp_block_histories (id,transaction_type, creator_id, updater_id, transaction_date, created_at, updated_at, weight, domain_id, block_id, ramp_id)
184
+ // let processedData = await txMgr.query(`
185
+ // insert into ramp_block_histories (id, transaction_type, creator_id, updater_id, transaction_date, created_at, updated_at, domain_id, ramp_id, weight, previous_weight, current_weight, block_id, daily_dispatch_id)
186
+ // SELECT uuid_generate_v4() AS id, 'DISPATCH' AS transaction_type,
187
+ // '0933baea-e099-494b-9791-3dfe805731f0' AS creator_id, '0933baea-e099-494b-9791-3dfe805731f0' AS updater_id,
188
+ // $1 AS transaction_date, $2 AS created_at, $3 AS updated_at,
189
+ // $4 AS domain_id, $5 AS ramp_id,
190
+ // $6 AS weight,
191
+ // $7 AS previous_weight,
192
+ // $8 AS current_weight,
193
+ // $9 AS block_id,
194
+ // $10 AS daily_dispatch_id
195
+ // `, [dt.transaction_date, dt2.created_at, dt2.updated_at, dt.domain_id, dt.ramp_id, parseFloat(weight), parseFloat(currentRampBlockWeight), parseFloat(currentRampBlockWeight) + parseFloat(weight), dt2.block_id, dt.daily_dispatch_id])
196
+ // // await txMgr.query(`
197
+ // // SELECT * FROM (
198
+ // // SELECT *, ROW_NUMBER () OVER (PARTITION BY ramp_id, block_id ORDER BY transaction_date desc) AS rn FROM ramp_block_histories
199
+ // // WHERE ramp_id =$1 AND transaction_date <= $2
200
+ // // ) foo WHERE rn = 1
201
+ // // `, [dt.ramp_id, dt.transaction_date]
202
+ // // )
203
+ // let x = dt2
204
+ // }
205
+ // let x = rampBlockHistory
206
+ // };
207
+ // })
208
+ // }
148
209
  //# sourceMappingURL=daily-production-reports.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"daily-production-reports.js","sourceRoot":"","sources":["../../../../server/gra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AAC,CAAA;YAEF,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,EAAE,CAAA;SACxC;QAAC,OAAO,KAAK,EAAE;YACd,MAAM,KAAK,CAAA;SACZ;IACH,CAAC;CACF,CAAA"}
1
+ {"version":3,"file":"daily-production-reports.js","sourceRoot":"","sources":["../../../../server/graphql/resolvers/report/daily-production-reports.ts"],"names":[],"mappings":";;;AAIA,gDAAyC;AAE5B,QAAA,sBAAsB,GAAG;IACpC,KAAK,CAAC,sBAAsB,CAAC,CAAM,EAAE,MAAiB,EAAE,OAAY;QAClE,IAAI;YACF,MAAM,EAAE,EAAE,EAAE,GAA0B,OAAO,CAAC,KAAK,CAAA;YAEnD,IAAI,IAAI,GAAG,QAAQ,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,IAAI,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;YACzF,IAAI,KAAK,GAAG,QAAQ,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,IAAI,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;YAE1F,IAAI,QAAQ,GAAG,IAAI,IAAI,CAAC,IAAI,EAAE,KAAK,GAAG,CAAC,EAAE,CAAC,CAAC,CAAA;YAC3C,IAAI,MAAM,GAAG,IAAI,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC,CAAA;YACrC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC,CAAA;YAEpC,IAAI,cAAc,GAAG;gBACnB,QAAQ,CAAC,WAAW,EAAE,CAAC,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ET,OAAO;AACP,IAAI"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@things-factory/operato-pms",
3
- "version": "4.3.359",
3
+ "version": "4.3.371",
4
4
  "main": "dist-server/index.js",
5
5
  "browser": "client/index.js",
6
6
  "things-factory": true,
@@ -95,5 +95,5 @@
95
95
  "devDependencies": {
96
96
  "@things-factory/builder": "^4.3.281"
97
97
  },
98
- "gitHead": "eee64e58c1eae1ce3bbb02b1413f7fee09578498"
98
+ "gitHead": "d3c96359338ba21bb981114bc03bd1cbde82efd4"
99
99
  }
@@ -14,11 +14,12 @@ import { OrganizationStaff } from './organization-staff'
14
14
  import { Organization } from './organization'
15
15
  import { PlantationInventory } from './plantation-inventory'
16
16
  import { Ramp } from './ramp'
17
+ import { RampBlockHistory } from './ramp-block-history'
17
18
  import { RecordTransaction } from './record-transaction'
18
19
 
19
20
  export const entities = [
20
- Truck,
21
- PlantationSetting,
21
+ Truck,
22
+ PlantationSetting,
22
23
  BlockDetail,
23
24
  Block,
24
25
  DailyBlockDetail,
@@ -33,12 +34,13 @@ export const entities = [
33
34
  Organization,
34
35
  PlantationInventory,
35
36
  Ramp,
37
+ RampBlockHistory,
36
38
  RecordTransaction
37
39
  ]
38
40
 
39
41
  export {
40
- Truck,
41
- PlantationSetting,
42
+ Truck,
43
+ PlantationSetting,
42
44
  BlockDetail,
43
45
  Block,
44
46
  DailyBlockDetail,
@@ -53,5 +55,6 @@ export {
53
55
  Organization,
54
56
  PlantationInventory,
55
57
  Ramp,
58
+ RampBlockHistory,
56
59
  RecordTransaction
57
60
  }
@@ -0,0 +1,69 @@
1
+ import { User } from '@things-factory/auth-base'
2
+ import { Domain } from '@things-factory/shell'
3
+ import { Column, CreateDateColumn, Entity, Index, ManyToOne, PrimaryGeneratedColumn, UpdateDateColumn } from 'typeorm'
4
+ import { Block, Ramp, PlantationInventory, DailyDispatch } from '../entities'
5
+
6
+ @Entity()
7
+ @Index(
8
+ 'ix_ramp_block_history_0',
9
+ (rampBlockHistory: RampBlockHistory) => [rampBlockHistory.id],
10
+ { unique: true }
11
+ )
12
+ export class RampBlockHistory {
13
+ @PrimaryGeneratedColumn('uuid')
14
+ id: string
15
+
16
+ @Column({ nullable: true })
17
+ seq: number
18
+
19
+ @ManyToOne(type => Domain)
20
+ domain: Domain
21
+
22
+ @ManyToOne(type => Block, { nullable: true })
23
+ block: Block
24
+
25
+ @ManyToOne(type => Ramp, { nullable: true })
26
+ ramp: Ramp
27
+
28
+ @ManyToOne(type => DailyDispatch, { nullable: true })
29
+ dailyDispatch: DailyDispatch
30
+
31
+ @Column({ type: 'float', default: 0 })
32
+ weight: number
33
+
34
+ @Column({ type: 'float', default: 0 })
35
+ previousWeight: number
36
+
37
+ @Column({ type: 'float', default: 0 })
38
+ currentWeight: number
39
+
40
+ /**
41
+ * transactionType
42
+ * LOADING
43
+ * DISPATCH
44
+ */
45
+ @Column()
46
+ transactionType: string
47
+
48
+ @Column()
49
+ transactionDate: string
50
+
51
+ @Column({ nullable: true })
52
+ deletedAt: Date
53
+
54
+ @CreateDateColumn()
55
+ createdAt: Date
56
+
57
+ @UpdateDateColumn()
58
+ updatedAt: Date
59
+
60
+ @ManyToOne(type => User, {
61
+ nullable: true
62
+ })
63
+ creator: User
64
+
65
+ @ManyToOne(type => User, {
66
+ nullable: true
67
+ })
68
+ updater: User
69
+ }
@@ -1,4 +1,4 @@
1
- import { EntityManager } from 'typeorm'
1
+ import { EntityManager, getManager } from 'typeorm'
2
2
 
3
3
  import { ListParam } from '@things-factory/shell'
4
4
 
@@ -50,17 +50,21 @@ export const dailyProductionReports = {
50
50
 
51
51
  await tx.query(`
52
52
  CREATE TEMP TABLE temp_records on commit drop AS (
53
- select blk.block_id, coalesce(sum(field_bunches),0) AS today_field_bunches,
54
- round(coalesce(sum(ramp_weight),0)::numeric,4) AS today_ramp_weight,
55
- sum(case when transaction_type = 'HARVEST' OR transaction_type = 'BUNCHES_ADJUSTMENT' then field_bunches else 0 end) as today_bunch_harvest,
56
- sum(case when transaction_type = 'LOADING' OR transaction_type = 'LOADING_ADJUSTMENT' then -field_bunches else 0 end) as today_bunch_collected,
57
- round(sum(case when transaction_type = 'LOADING' OR transaction_type = 'LOADING_ADJUSTMENT' then ramp_weight else 0 end)::numeric,4) as today_ramp_weight_collected,
58
- round(sum(case when transaction_type = 'DISPATCHMENT' OR transaction_type = 'DISPATCHMENT_ADJUSTMENT' then -ramp_weight else 0 end)::numeric,4) as today_weight_dispatch,
59
- transaction_date
60
- from record_transactions t2
61
- inner join temp_blocks blk on blk.id = t2.block_id
62
- where transaction_date <= $1
63
- group by blk.block_id, transaction_date
53
+ SELECT *,
54
+ COALESCE(-(SELECT sum(weight) FROM ramp_block_histories rbh WHERE rbh.block_id = src.block_id AND rbh.transaction_date = src.transaction_date AND rbh.transaction_type='DISPATCH'),0) AS today_weight_dispatch
55
+ FROM (
56
+ select blk.block_id, coalesce(sum(field_bunches),0) AS today_field_bunches,
57
+ round(coalesce(sum(ramp_weight),0)::numeric,4) AS today_ramp_weight,
58
+ sum(case when transaction_type = 'HARVEST' then field_bunches else 0 end) as today_bunch_harvest,
59
+ sum(case when transaction_type = 'LOADING' then -field_bunches else 0 end) as today_bunch_collected,
60
+ round(sum(case when transaction_type = 'LOADING' then ramp_weight else 0 end)::numeric,4) as today_ramp_weight_collected,
61
+ --round(sum(case when transaction_type = 'DISPATCHMENT' then -ramp_weight else 0 end)::numeric,4) as today_weight_dispatch,
62
+ transaction_date
63
+ from record_transactions t2
64
+ inner join temp_blocks blk on blk.id = t2.block_id
65
+ where transaction_date <= $1
66
+ group by blk.block_id, transaction_date
67
+ ) src
64
68
  )
65
69
  `,
66
70
  [toDateString]
@@ -157,10 +161,77 @@ export const dailyProductionReports = {
157
161
  todayWeightDispatch: parseFloat(itm.today_weight_dispatch).toFixed(4)
158
162
  }
159
163
  })
160
-
164
+ // updateAllData()
161
165
  return { items, total: total[0].count }
162
166
  } catch (error) {
163
167
  throw error
164
168
  }
165
169
  }
166
170
  }
171
+
172
+
173
+ // async function updateAllData() {
174
+ // await getManager().transaction(async txMgr => {
175
+ // let data = await txMgr.query(`
176
+ // SELECT * FROM (
177
+ // SELECT uuid_generate_v4() AS id, DATE(dd.dispatch_at)::varchar AS transaction_date, 'DISPATCH' AS transaction_type, dd.dispatch_at AS created_at, dd.dispatch_at AS updated_at,
178
+ // ddd.collected_ramp_weight AS dispatch_weight, '980f20a0-747c-4d04-a870-97a09f6ba807' AS domain_id, ddd.ramp_id, '0933baea-e099-494b-9791-3dfe805731f0' AS creator_id, '0933baea-e099-494b-9791-3dfe805731f0' AS updater_id,
179
+ // dd.id as daily_dispatch_id
180
+ // FROM daily_dispatch_details ddd
181
+ // INNER JOIN daily_dispatches dd ON dd.id = ddd.daily_dispatch_id
182
+ // WHERE dd.dispatch_at >='2023-07-01 00:00:00.000'
183
+ // ) src ORDER BY src.ramp_id, src.transaction_date
184
+ // `)
185
+
186
+ // // await data.forEach(async dt => {
187
+ // for (let dtIdx = 0; dtIdx < data.length; dtIdx++) {
188
+ // const dt = data[dtIdx];
189
+
190
+ // let rampBlockHistory = await txMgr.query(`
191
+ // SELECT * FROM (
192
+ // SELECT *, ROW_NUMBER () OVER (PARTITION BY ramp_id, block_id ORDER BY transaction_date desc, transaction_type) AS rn FROM ramp_block_histories
193
+ // WHERE ramp_id =$1 AND transaction_date <= $2
194
+ // ) foo WHERE rn = 1
195
+ // `, [dt.ramp_id, dt.transaction_date])
196
+
197
+ // let totalRampWeight: number = rampBlockHistory.reduce((total, currentValue) => {
198
+ // total += currentValue.previous_weight + currentValue.weight
199
+ // return total
200
+ // }, 0)
201
+
202
+ // for (let index = 0; index < rampBlockHistory.length; index++) {
203
+ // const dt2 = rampBlockHistory[index];
204
+
205
+ // let currentRampBlockWeight = dt2.previous_weight + dt2.weight
206
+ // let percentage = parseFloat((currentRampBlockWeight / totalRampWeight).toFixed(4))
207
+ // let weight = (-dt.dispatch_weight * percentage).toFixed(4)
208
+
209
+ // // insert into ramp_block_histories (id,transaction_type, creator_id, updater_id, transaction_date, created_at, updated_at, weight, domain_id, block_id, ramp_id)
210
+ // let processedData = await txMgr.query(`
211
+ // insert into ramp_block_histories (id, transaction_type, creator_id, updater_id, transaction_date, created_at, updated_at, domain_id, ramp_id, weight, previous_weight, current_weight, block_id, daily_dispatch_id)
212
+ // SELECT uuid_generate_v4() AS id, 'DISPATCH' AS transaction_type,
213
+ // '0933baea-e099-494b-9791-3dfe805731f0' AS creator_id, '0933baea-e099-494b-9791-3dfe805731f0' AS updater_id,
214
+ // $1 AS transaction_date, $2 AS created_at, $3 AS updated_at,
215
+ // $4 AS domain_id, $5 AS ramp_id,
216
+ // $6 AS weight,
217
+ // $7 AS previous_weight,
218
+ // $8 AS current_weight,
219
+ // $9 AS block_id,
220
+ // $10 AS daily_dispatch_id
221
+ // `, [dt.transaction_date, dt2.created_at, dt2.updated_at, dt.domain_id, dt.ramp_id, parseFloat(weight), parseFloat(currentRampBlockWeight), parseFloat(currentRampBlockWeight) + parseFloat(weight), dt2.block_id, dt.daily_dispatch_id])
222
+
223
+ // // await txMgr.query(`
224
+ // // SELECT * FROM (
225
+ // // SELECT *, ROW_NUMBER () OVER (PARTITION BY ramp_id, block_id ORDER BY transaction_date desc) AS rn FROM ramp_block_histories
226
+ // // WHERE ramp_id =$1 AND transaction_date <= $2
227
+ // // ) foo WHERE rn = 1
228
+ // // `, [dt.ramp_id, dt.transaction_date]
229
+ // // )
230
+ // let x = dt2
231
+ // }
232
+
233
+ // let x = rampBlockHistory
234
+ // };
235
+
236
+ // })
237
+ // }
@@ -1,81 +0,0 @@
1
- module.exports = {
2
- useVirtualHostBasedDomain: false,
3
- fallbackRoute: '/',
4
- subdomainOffset: 2,
5
- port: 1400,
6
- inspect: '9330',
7
- ormconfig: {
8
- name: 'default',
9
- type: 'postgres',
10
- database: 'pms',
11
- username: 'postgres',
12
- password: 'hatio',
13
- host: 'localhost',
14
- port: 15432,
15
- synchronize: true,
16
- logging: true
17
- },
18
- password: {
19
- lowerCase: true,
20
- upperCase: false,
21
- digit: false,
22
- specialCharacter: false,
23
- allowRepeat: true,
24
- useTightPattern: false,
25
- useLoosePattern: true,
26
- tightCharacterLength: 4,
27
- looseCharacterLength: 4,
28
- history: 2
29
- },
30
- uploads: 'uploads',
31
- attachmentsPath: 'attachments',
32
- SECRET: '0xD58F835B69D207A76CC5F84a70a1D0d4C79dfC95',
33
- logger: {
34
- file: {
35
- filename: 'logs/application-%DATE%.log',
36
- datePattern: 'YYYY-MM-DD-HH',
37
- zippedArchive: true,
38
- maxSize: '200m',
39
- maxFiles: '1m',
40
- level: 'info'
41
- }
42
- },
43
- // email: {
44
- // host: 'smtp.office365.com',
45
- // port: 587,
46
- // secure: false, // true for 465, false for other ports
47
- // auth: {
48
- // user: 'no-reply@hatiolab.com', // generated ethereal user
49
- // pass: 'h@ti0LAB1008' // generated ethereal password
50
- // },
51
- // secureConnection: false,
52
- // tls: {
53
- // ciphers: 'SSLv3'
54
- // }
55
- // },
56
- // sender: 'no-reply@hatiolab.com',
57
- // notification: {
58
- // fcm: {
59
- // serviceAccount: {
60
- // project_id: 'operato',
61
- // private_key:
62
- // '-----BEGIN PRIVATE KEY-----\nMIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQDYNOfyNjPMSeG9\nzU1qs0cpVK5cVfadcUaw5g+hkQZMOMlAA7uqW2eX4vkayj7MzbYUayH+sei8044Q\nJIyl6f26dNX1VT3UgTmSmCS0v48EBEZHCgusrUGFjduLRN6OS6uvrXW1xKA18k9q\nai1C2EHCXF2AE4PTvf239RC1UIOnVePcMtT7rMTdHRO4s8OKVuSDbzIt8k1cV3Zt\nES0YsJlkELqBisYpV//2/ZSILTt39J9JzrVef03X9kkoo9p+YnNyy6tWsfQPfgJO\nybiRGBNxiyJ/E2pxRo/WqU0go9OzYJlGaSUrUx09heNiRD1b0MAOmyPDJz/6AaTk\nkU/A+kLzAgMBAAECggEADQ5s2gtR53VSujk1V/Xe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exvaBh21K6W3inmRW4\nLlkVYJaBJ20OwokXg5aXjBiHxqmk7VLAuFbkpb5LOKH2xPILRQ0OEkn51yVymS3T\n9lLpHOFTQXt5tF2/F7NW7kaQJNlLr/h5jPi3O9XHeFmuaN2z150ZB6zzgjeGKzr8\ni+1fgTsRfDtNw8xkSH9qL1Y=\n-----END PRIVATE KEY-----\n',
63
- // client_email: 'firebase-adminsdk-xmm2e@operato.iam.gserviceaccount.com'
64
- // },
65
- // appConfig: {
66
- // apiKey: 'AIzaSyDdTM2BTLHSt2LNS0G5QB8G0i4KBXFiG7U',
67
- // projectId: 'operato',
68
- // messagingSenderId: 79537064975,
69
- // appId: '1:79537064975:web:32f53119e9c8c6ee2a277a'
70
- // },
71
- // serverKey:
72
- // 'AAAAEoTHTA8:APA91bGwt-4HT82Dfwf_VwbQaKT0_qHd0Y3tuW41udjWz5Lz0Ko0mEMD6WbHHSILvQpa6yuoGGKCMsrU7VW2qWRrUm3CYpyG9oSwshNm1tIhljAnOuUfwHCoawbVLwf9qlWpHt4dwCoc'
73
- // },
74
- // vapidKey: {
75
- // subject: 'mailto:heartyoh@hatiolab.com',
76
- // publicKey: 'BAkVkITsCXBIsYL1yeaBmx5_dn57we-ZXMjirPPHzC2dan82cdEnAio_53PQ-1_w3ykWCBPrrFAWQ_d9N4cFF0o',
77
- // privateKey: '4pmlt3Wk019u7nqU3Q_oGZE6LbUDjjf8DpmAcn9-iss'
78
- // }
79
- // },
80
- reportApiUrl: 'http://localhost:8888/rest/report/show_html'
81
- }