@things-factory/operato-pms 4.3.373 → 4.3.378
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/client/pages/dispatchment/dispatchment-list.js +17 -3
- package/client/pages/harvesting/harvesting-list.js +17 -3
- package/client/pages/loading/loading-list.js +17 -3
- package/config.development.js +48 -43
- package/dist-server/graphql/resolvers/daily-dispatch/daily-dispatch-query.js +24 -7
- package/dist-server/graphql/resolvers/daily-dispatch/daily-dispatch-query.js.map +1 -1
- package/dist-server/graphql/resolvers/daily-dispatch/generate-daily-dispatch.js +60 -4
- package/dist-server/graphql/resolvers/daily-dispatch/generate-daily-dispatch.js.map +1 -1
- package/dist-server/graphql/resolvers/daily-harvest/daily-harvest-query.js +24 -2
- package/dist-server/graphql/resolvers/daily-harvest/daily-harvest-query.js.map +1 -1
- package/dist-server/graphql/resolvers/daily-loading/daily-loading-query.js +24 -2
- package/dist-server/graphql/resolvers/daily-loading/daily-loading-query.js.map +1 -1
- package/dist-server/graphql/resolvers/daily-loading/generate-daily-loading.js +3 -2
- package/dist-server/graphql/resolvers/daily-loading/generate-daily-loading.js.map +1 -1
- package/dist-server/graphql/resolvers/report/daily-production-reports.js +59 -57
- package/dist-server/graphql/resolvers/report/daily-production-reports.js.map +1 -1
- package/dist-server/utils/transaction-util.js +68 -1
- package/dist-server/utils/transaction-util.js.map +1 -1
- package/package.json +41 -41
- package/server/graphql/resolvers/daily-dispatch/daily-dispatch-query.ts +25 -8
- package/server/graphql/resolvers/daily-dispatch/generate-daily-dispatch.ts +100 -16
- package/server/graphql/resolvers/daily-harvest/daily-harvest-query.ts +26 -0
- package/server/graphql/resolvers/daily-loading/daily-loading-query.ts +26 -0
- package/server/graphql/resolvers/daily-loading/generate-daily-loading.ts +64 -53
- package/server/utils/transaction-util.ts +95 -1
- package/translations/en.json +2 -0
- package/translations/ja.json +9 -9
- package/translations/ko.json +9 -9
- package/translations/zh.json +9 -9
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.dailyProductionReports = void 0;
|
|
4
|
+
const typeorm_1 = require("typeorm");
|
|
4
5
|
const entities_1 = require("../../../entities");
|
|
5
6
|
exports.dailyProductionReports = {
|
|
6
7
|
async dailyProductionReports(_, params, context) {
|
|
@@ -150,61 +151,62 @@ exports.dailyProductionReports = {
|
|
|
150
151
|
}
|
|
151
152
|
}
|
|
152
153
|
};
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
//
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
//
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
//
|
|
198
|
-
//
|
|
199
|
-
//
|
|
200
|
-
//
|
|
201
|
-
//
|
|
202
|
-
//
|
|
203
|
-
//
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
154
|
+
async function updateAllData() {
|
|
155
|
+
await (0, typeorm_1.getManager)().transaction(async (txMgr) => {
|
|
156
|
+
let data = await txMgr.query(`
|
|
157
|
+
SELECT * FROM (
|
|
158
|
+
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,
|
|
159
|
+
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,
|
|
160
|
+
dd.id as daily_dispatch_id
|
|
161
|
+
FROM daily_dispatch_details ddd
|
|
162
|
+
INNER JOIN daily_dispatches dd ON dd.id = ddd.daily_dispatch_id
|
|
163
|
+
WHERE dd.dispatch_at >='2023-07-01 00:00:00.000'
|
|
164
|
+
AND dd.deleted_at IS null
|
|
165
|
+
) src ORDER BY src.ramp_id, src.transaction_date
|
|
166
|
+
`);
|
|
167
|
+
// await data.forEach(async dt => {
|
|
168
|
+
for (let dtIdx = 0; dtIdx < data.length; dtIdx++) {
|
|
169
|
+
const dt = data[dtIdx];
|
|
170
|
+
let rampBlockHistory = await txMgr.query(`
|
|
171
|
+
SELECT * FROM (
|
|
172
|
+
SELECT *, ROW_NUMBER () OVER (PARTITION BY ramp_id, block_id ORDER BY transaction_date desc, transaction_type) AS rn FROM ramp_block_histories
|
|
173
|
+
WHERE ramp_id =$1 AND transaction_date <= $2
|
|
174
|
+
) foo WHERE rn = 1
|
|
175
|
+
`, [dt.ramp_id, dt.transaction_date]);
|
|
176
|
+
let totalRampWeight = rampBlockHistory.reduce((total, currentValue) => {
|
|
177
|
+
total += currentValue.previous_weight + currentValue.weight;
|
|
178
|
+
return total;
|
|
179
|
+
}, 0);
|
|
180
|
+
for (let index = 0; index < rampBlockHistory.length; index++) {
|
|
181
|
+
const dt2 = rampBlockHistory[index];
|
|
182
|
+
let currentRampBlockWeight = dt2.previous_weight + dt2.weight;
|
|
183
|
+
let percentage = parseFloat((currentRampBlockWeight / totalRampWeight).toFixed(4));
|
|
184
|
+
let weight = (-dt.dispatch_weight * percentage).toFixed(4);
|
|
185
|
+
// 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)
|
|
186
|
+
let processedData = await txMgr.query(`
|
|
187
|
+
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)
|
|
188
|
+
SELECT uuid_generate_v4() AS id, 'DISPATCH' AS transaction_type,
|
|
189
|
+
'0933baea-e099-494b-9791-3dfe805731f0' AS creator_id, '0933baea-e099-494b-9791-3dfe805731f0' AS updater_id,
|
|
190
|
+
$1 AS transaction_date, $2 AS created_at, $3 AS updated_at,
|
|
191
|
+
$4 AS domain_id, $5 AS ramp_id,
|
|
192
|
+
$6 AS weight,
|
|
193
|
+
$7 AS previous_weight,
|
|
194
|
+
$8 AS current_weight,
|
|
195
|
+
$9 AS block_id,
|
|
196
|
+
$10 AS daily_dispatch_id
|
|
197
|
+
`, [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]);
|
|
198
|
+
// await txMgr.query(`
|
|
199
|
+
// SELECT * FROM (
|
|
200
|
+
// SELECT *, ROW_NUMBER () OVER (PARTITION BY ramp_id, block_id ORDER BY transaction_date desc) AS rn FROM ramp_block_histories
|
|
201
|
+
// WHERE ramp_id =$1 AND transaction_date <= $2
|
|
202
|
+
// ) foo WHERE rn = 1
|
|
203
|
+
// `, [dt.ramp_id, dt.transaction_date]
|
|
204
|
+
// )
|
|
205
|
+
let x = dt2;
|
|
206
|
+
}
|
|
207
|
+
let x = rampBlockHistory;
|
|
208
|
+
}
|
|
209
|
+
;
|
|
210
|
+
});
|
|
211
|
+
}
|
|
210
212
|
//# sourceMappingURL=daily-production-reports.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"daily-production-reports.js","sourceRoot":"","sources":["../../../../server/graphql/resolvers/report/daily-production-reports.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"daily-production-reports.js","sourceRoot":"","sources":["../../../../server/graphql/resolvers/report/daily-production-reports.ts"],"names":[],"mappings":";;;AAAA,qCAAmD;AAInD,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,QAAQ,EAAE;gBACjC,MAAM,CAAC,QAAQ,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC;gBAChD,I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AG,GAAG,CAAC,MAAM,CAAA;gBAC7D,IAAI,UAAU,GAAG,UAAU,CAAC,CAAC,sBAAsB,GAAG,eAAe,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAA;gBAClF,IAAI,MAAM,GAAG,CAAC,CAAC,EAAE,CAAC,eAAe,GAAG,UAAU,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAA;gBAE1D,iKAAiK;gBACjK,IAAI,aAAa,GAAG,MAAM,KAAK,CAAC,KAAK,CAAC;;;;;;;;;;;OAWvC,EAAE,CAAC,EAAE,CAAC,gBAAgB,EAAE,GAAG,CAAC,UAAU,EAAE,GAAG,CAAC,UAAU,EAAE,EAAE,CAAC,SAAS,EAAE,EAAE,CAAC,OAAO,EAAE,UAAU,CAAC,MAAM,CAAC,EAAE,UAAU,CAAC,sBAAsB,CAAC,EAAE,UAAU,CAAC,sBAAsB,CAAC,GAAG,UAAU,CAAC,MAAM,CAAC,EAAE,GAAG,CAAC,QAAQ,EAAE,EAAE,CAAC,iBAAiB,CAAC,CAAC,CAAA;gBAEtO,sBAAsB;gBACtB,oBAAoB;gBACpB,oIAAoI;gBACpI,mDAAmD;gBACnD,uBAAuB;gBACvB,uCAAuC;gBACvC,IAAI;gBACJ,IAAI,CAAC,GAAG,GAAG,CAAA;aACZ;YAED,IAAI,CAAC,GAAG,gBAAgB,CAAA;SACzB;QAAA,CAAC;IAEJ,CAAC,CAAC,CAAA;AACJ,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.switchRampStatus = exports.generateTransactionHistory = void 0;
|
|
3
|
+
exports.switchRampStatus = exports.generateRampBlockHistories = exports.generateTransactionHistory = void 0;
|
|
4
4
|
const constants_1 = require("../constants");
|
|
5
5
|
const entities_1 = require("../entities");
|
|
6
6
|
const utils_1 = require("../utils");
|
|
@@ -37,6 +37,73 @@ async function generateTransactionHistory(block, domain, ramp, refActionID, refR
|
|
|
37
37
|
return recTransactionHistory;
|
|
38
38
|
}
|
|
39
39
|
exports.generateTransactionHistory = generateTransactionHistory;
|
|
40
|
+
/**
|
|
41
|
+
* @description It will insert new record into transaction table.
|
|
42
|
+
* seq will be calculated based on number of records for one specific plantation inventory
|
|
43
|
+
*/
|
|
44
|
+
async function generateRampBlockHistories(block, domain, ramp, transactionType, transactionDate, rampWeight, user, deletedAt, dailyDispatch, trxMgr) {
|
|
45
|
+
console.log(block, domain, ramp, user);
|
|
46
|
+
const rampBlockHistoryRepo = (trxMgr === null || trxMgr === void 0 ? void 0 : trxMgr.getRepository(entities_1.RampBlockHistory)) || (0, typeorm_1.getRepository)(entities_1.RampBlockHistory);
|
|
47
|
+
if (!(ramp === null || ramp === void 0 ? void 0 : ramp.id))
|
|
48
|
+
throw new Error(`Can't find a matching ramp.`);
|
|
49
|
+
const lastRampBlockHistory = await rampBlockHistoryRepo.findOne({
|
|
50
|
+
where: { domain, ramp, block },
|
|
51
|
+
order: { seq: 'DESC' }
|
|
52
|
+
});
|
|
53
|
+
let res;
|
|
54
|
+
if (!lastRampBlockHistory) {
|
|
55
|
+
res = await rampBlockHistoryRepo
|
|
56
|
+
.createQueryBuilder()
|
|
57
|
+
.insert()
|
|
58
|
+
.into(entities_1.RampBlockHistory)
|
|
59
|
+
.values([
|
|
60
|
+
{
|
|
61
|
+
transactionDate,
|
|
62
|
+
transactionType,
|
|
63
|
+
seq: 0,
|
|
64
|
+
domain,
|
|
65
|
+
block,
|
|
66
|
+
ramp,
|
|
67
|
+
weight: rampWeight,
|
|
68
|
+
previousWeight: 0,
|
|
69
|
+
currentWeight: rampWeight,
|
|
70
|
+
dailyDispatch,
|
|
71
|
+
deletedAt: deletedAt ? deletedAt : null,
|
|
72
|
+
creator: user,
|
|
73
|
+
updater: user
|
|
74
|
+
}
|
|
75
|
+
])
|
|
76
|
+
.returning('*')
|
|
77
|
+
.execute();
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
const previousWeight = lastRampBlockHistory.currentWeight;
|
|
81
|
+
res = await rampBlockHistoryRepo
|
|
82
|
+
.createQueryBuilder()
|
|
83
|
+
.insert()
|
|
84
|
+
.into(entities_1.RampBlockHistory)
|
|
85
|
+
.values([
|
|
86
|
+
{
|
|
87
|
+
domain,
|
|
88
|
+
block,
|
|
89
|
+
ramp,
|
|
90
|
+
transactionType,
|
|
91
|
+
transactionDate,
|
|
92
|
+
weight: rampWeight,
|
|
93
|
+
previousWeight,
|
|
94
|
+
currentWeight: parseFloat((previousWeight + rampWeight).toFixed(4)),
|
|
95
|
+
creator: user,
|
|
96
|
+
updater: user,
|
|
97
|
+
seq: () => `(select seq from ramp_block_histories where ramp_id = '${ramp.id}' and block_id = '${block.id}' and domain_id = '${domain.id}' order by seq desc limit 1) + 1`
|
|
98
|
+
}
|
|
99
|
+
])
|
|
100
|
+
.returning('*')
|
|
101
|
+
.execute();
|
|
102
|
+
}
|
|
103
|
+
let newRampBlockHistory = res.generatedMaps[0];
|
|
104
|
+
return newRampBlockHistory;
|
|
105
|
+
}
|
|
106
|
+
exports.generateRampBlockHistories = generateRampBlockHistories;
|
|
40
107
|
/**
|
|
41
108
|
* @description: Check ramp emptiness and update status of ramp
|
|
42
109
|
* @param domain
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transaction-util.js","sourceRoot":"","sources":["../../server/utils/transaction-util.ts"],"names":[],"mappings":";;;AAEA,4CAA8E;AAC9E,
|
|
1
|
+
{"version":3,"file":"transaction-util.js","sourceRoot":"","sources":["../../server/utils/transaction-util.ts"],"names":[],"mappings":";;;AAEA,4CAA8E;AAC9E,0CAQoB;AACpB,oCAAsC;AACtC,qCAAkE;AAElE;;;GAGG;AAEI,KAAK,UAAU,0BAA0B,CAC9C,KAAY,EACZ,MAAc,EACd,IAAU,EACV,WAAgB,EAChB,WAAmB,EACnB,eAAuB,EACvB,eAAuB,EACvB,YAAoB,EACpB,UAAkB,EAClB,IA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O,IACP,CAAA;KACH;SAAM,IAAI,OAAO,IAAI,IAAI,CAAC,MAAM,KAAK,uBAAW,CAAC,KAAK,EAAE;QACvD,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,iCACrB,IAAI,KACP,MAAM,EAAE,uBAAW,CAAC,MAAM,EAC1B,OAAO,IACP,CAAA;KACH;SAAM;QACL,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,iCACrB,IAAI,KACP,MAAM,EAAE,uBAAW,CAAC,MAAM,EAC1B,OAAO,IACP,CAAA;KACH;IAED,OAAO,IAAI,CAAA;AACb,CAAC;AApCD,4CAoCC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@things-factory/operato-pms",
|
|
3
|
-
"version": "4.3.
|
|
3
|
+
"version": "4.3.378",
|
|
4
4
|
"main": "dist-server/index.js",
|
|
5
5
|
"browser": "client/index.js",
|
|
6
6
|
"things-factory": true,
|
|
@@ -53,47 +53,47 @@
|
|
|
53
53
|
"@operato/scene-tab": "^0.1.8",
|
|
54
54
|
"@operato/scene-table": "^0.1.8",
|
|
55
55
|
"@operato/scene-wheel-sorter": "^0.1.8",
|
|
56
|
-
"@things-factory/apptool-ui": "^4.3.
|
|
57
|
-
"@things-factory/auth-ui": "^4.3.
|
|
58
|
-
"@things-factory/biz-base": "^4.3.
|
|
59
|
-
"@things-factory/board-service": "^4.3.
|
|
60
|
-
"@things-factory/board-ui": "^4.3.
|
|
61
|
-
"@things-factory/code-ui": "^4.3.
|
|
62
|
-
"@things-factory/context-ui": "^4.3.
|
|
63
|
-
"@things-factory/dashboard": "^4.3.
|
|
64
|
-
"@things-factory/document-template-ui": "^4.3.
|
|
65
|
-
"@things-factory/export-ui": "^4.3.
|
|
66
|
-
"@things-factory/export-ui-csv": "^4.3.
|
|
67
|
-
"@things-factory/export-ui-excel": "^4.3.
|
|
68
|
-
"@things-factory/fav-base": "^4.3.
|
|
69
|
-
"@things-factory/form-ui": "^4.3.
|
|
70
|
-
"@things-factory/grist-ui": "^4.3.
|
|
71
|
-
"@things-factory/help": "^4.3.
|
|
72
|
-
"@things-factory/i18n-base": "^4.3.
|
|
73
|
-
"@things-factory/import-ui": "^4.3.
|
|
74
|
-
"@things-factory/import-ui-excel": "^4.3.
|
|
75
|
-
"@things-factory/lite-menu": "^4.3.
|
|
76
|
-
"@things-factory/more-ui": "^4.3.
|
|
77
|
-
"@things-factory/notification": "^4.3.
|
|
78
|
-
"@things-factory/print-ui": "^4.3.
|
|
79
|
-
"@things-factory/resource-ui": "^4.3.
|
|
80
|
-
"@things-factory/scene-data-transform": "^4.3.
|
|
81
|
-
"@things-factory/scene-excel": "^4.3.
|
|
82
|
-
"@things-factory/scene-firebase": "^4.3.
|
|
83
|
-
"@things-factory/scene-form": "^4.3.
|
|
84
|
-
"@things-factory/scene-google-map": "^4.3.
|
|
85
|
-
"@things-factory/scene-graphql": "^4.3.
|
|
86
|
-
"@things-factory/scene-label": "^4.3.
|
|
87
|
-
"@things-factory/scene-marker": "^4.3.
|
|
88
|
-
"@things-factory/scene-mqtt": "^4.3.
|
|
89
|
-
"@things-factory/scene-restful": "^4.3.
|
|
90
|
-
"@things-factory/scene-visualizer": "^4.3.
|
|
91
|
-
"@things-factory/setting-ui": "^4.3.
|
|
92
|
-
"@things-factory/shell": "^4.3.
|
|
93
|
-
"@things-factory/system-ui": "^4.3.
|
|
56
|
+
"@things-factory/apptool-ui": "^4.3.378",
|
|
57
|
+
"@things-factory/auth-ui": "^4.3.378",
|
|
58
|
+
"@things-factory/biz-base": "^4.3.378",
|
|
59
|
+
"@things-factory/board-service": "^4.3.378",
|
|
60
|
+
"@things-factory/board-ui": "^4.3.378",
|
|
61
|
+
"@things-factory/code-ui": "^4.3.378",
|
|
62
|
+
"@things-factory/context-ui": "^4.3.378",
|
|
63
|
+
"@things-factory/dashboard": "^4.3.378",
|
|
64
|
+
"@things-factory/document-template-ui": "^4.3.378",
|
|
65
|
+
"@things-factory/export-ui": "^4.3.378",
|
|
66
|
+
"@things-factory/export-ui-csv": "^4.3.378",
|
|
67
|
+
"@things-factory/export-ui-excel": "^4.3.378",
|
|
68
|
+
"@things-factory/fav-base": "^4.3.378",
|
|
69
|
+
"@things-factory/form-ui": "^4.3.378",
|
|
70
|
+
"@things-factory/grist-ui": "^4.3.378",
|
|
71
|
+
"@things-factory/help": "^4.3.378",
|
|
72
|
+
"@things-factory/i18n-base": "^4.3.378",
|
|
73
|
+
"@things-factory/import-ui": "^4.3.378",
|
|
74
|
+
"@things-factory/import-ui-excel": "^4.3.378",
|
|
75
|
+
"@things-factory/lite-menu": "^4.3.378",
|
|
76
|
+
"@things-factory/more-ui": "^4.3.378",
|
|
77
|
+
"@things-factory/notification": "^4.3.378",
|
|
78
|
+
"@things-factory/print-ui": "^4.3.378",
|
|
79
|
+
"@things-factory/resource-ui": "^4.3.378",
|
|
80
|
+
"@things-factory/scene-data-transform": "^4.3.378",
|
|
81
|
+
"@things-factory/scene-excel": "^4.3.378",
|
|
82
|
+
"@things-factory/scene-firebase": "^4.3.378",
|
|
83
|
+
"@things-factory/scene-form": "^4.3.378",
|
|
84
|
+
"@things-factory/scene-google-map": "^4.3.378",
|
|
85
|
+
"@things-factory/scene-graphql": "^4.3.378",
|
|
86
|
+
"@things-factory/scene-label": "^4.3.378",
|
|
87
|
+
"@things-factory/scene-marker": "^4.3.378",
|
|
88
|
+
"@things-factory/scene-mqtt": "^4.3.378",
|
|
89
|
+
"@things-factory/scene-restful": "^4.3.378",
|
|
90
|
+
"@things-factory/scene-visualizer": "^4.3.378",
|
|
91
|
+
"@things-factory/setting-ui": "^4.3.378",
|
|
92
|
+
"@things-factory/shell": "^4.3.378",
|
|
93
|
+
"@things-factory/system-ui": "^4.3.378"
|
|
94
94
|
},
|
|
95
95
|
"devDependencies": {
|
|
96
|
-
"@things-factory/builder": "^4.3.
|
|
96
|
+
"@things-factory/builder": "^4.3.378"
|
|
97
97
|
},
|
|
98
|
-
"gitHead": "
|
|
98
|
+
"gitHead": "9de7af5e7b61574cdb4773876a41e1b9b77c1689"
|
|
99
99
|
}
|
|
@@ -27,10 +27,31 @@ export const Query = {
|
|
|
27
27
|
const { tx }: { tx: EntityManager } = context.state
|
|
28
28
|
|
|
29
29
|
try {
|
|
30
|
-
const
|
|
31
|
-
|
|
30
|
+
const fromDateParamIdx = params.filters.findIndex(param => param.name === 'fromDate')
|
|
31
|
+
if (fromDateParamIdx >= 0) {
|
|
32
|
+
let dispatchDateFrom = params.filters.find(param => param.name === 'fromDate')?.value
|
|
33
|
+
params.filters.splice(fromDateParamIdx, 1)
|
|
32
34
|
|
|
33
|
-
|
|
35
|
+
params.filters.push({
|
|
36
|
+
name: 'dispatchAt',
|
|
37
|
+
operator: 'gte',
|
|
38
|
+
value: dispatchDateFrom,
|
|
39
|
+
relation: false
|
|
40
|
+
})
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const toDateParamIdx = params.filters.findIndex(param => param.name === 'toDate')
|
|
44
|
+
if (toDateParamIdx >= 0) {
|
|
45
|
+
let dispatchDateTo = params.filters.find(param => param.name === 'toDate')?.value
|
|
46
|
+
params.filters.splice(toDateParamIdx, 1)
|
|
47
|
+
|
|
48
|
+
params.filters.push({
|
|
49
|
+
name: 'dispatchAt',
|
|
50
|
+
operator: 'lte',
|
|
51
|
+
value: dispatchDateTo,
|
|
52
|
+
relation: false
|
|
53
|
+
})
|
|
54
|
+
}
|
|
34
55
|
|
|
35
56
|
const queryBuilder = tx.getRepository(DailyDispatchEntity).createQueryBuilder()
|
|
36
57
|
buildQuery(queryBuilder, params, context)
|
|
@@ -46,14 +67,10 @@ export const Query = {
|
|
|
46
67
|
|
|
47
68
|
if (params.filters?.length > 0) {
|
|
48
69
|
queryBuilder.andWhere('DailyDispatch.deletedAt IS NULL')
|
|
49
|
-
}
|
|
50
|
-
else {
|
|
70
|
+
} else {
|
|
51
71
|
queryBuilder.where('DailyDispatch.deletedAt IS NULL')
|
|
52
72
|
}
|
|
53
73
|
|
|
54
|
-
if (dispatchAt)
|
|
55
|
-
queryBuilder.andWhere(`DailyDispatch.dispatchAt between :dispatchAt::timestamp and :dispatchAt::timestamp + interval '1 day' `, { dispatchAt })
|
|
56
|
-
|
|
57
74
|
const [items, total] = await queryBuilder.getManyAndCount()
|
|
58
75
|
|
|
59
76
|
return { items, total }
|
|
@@ -4,8 +4,16 @@ import { User } from '@things-factory/auth-base'
|
|
|
4
4
|
import { Domain } from '@things-factory/shell'
|
|
5
5
|
|
|
6
6
|
import { RECORD_STATUS, TRANSACTION_TYPE } from '../../../constants'
|
|
7
|
-
import {
|
|
8
|
-
|
|
7
|
+
import {
|
|
8
|
+
Block,
|
|
9
|
+
DailyDispatch,
|
|
10
|
+
DailyDispatchDetail,
|
|
11
|
+
Organization,
|
|
12
|
+
OrganizationStaff,
|
|
13
|
+
Ramp,
|
|
14
|
+
Truck
|
|
15
|
+
} from '../../../entities'
|
|
16
|
+
import { generateRampBlockHistories, generateTransactionHistory, NoGenerator } from '../../../utils'
|
|
9
17
|
|
|
10
18
|
export const generateDailyDispatch = {
|
|
11
19
|
async generateDailyDispatch(_: any, { dailyDispatch }, context: any) {
|
|
@@ -108,24 +116,100 @@ export async function generateDispatchTransaction(
|
|
|
108
116
|
user: User,
|
|
109
117
|
tx?: EntityManager
|
|
110
118
|
): Promise<void> {
|
|
111
|
-
|
|
112
|
-
dailyDispatchDetails.map(async record => {
|
|
113
|
-
const dispatchedTonnage: number = record.collectedRampWeight
|
|
114
|
-
const dispatchDate: string = newDailyDispatch.dispatchAt.toString().split('T')[0]
|
|
119
|
+
const blockRepo: Repository<Block> = tx?.getRepository(Block) || getRepository(Block)
|
|
115
120
|
|
|
116
|
-
|
|
117
|
-
|
|
121
|
+
for (let dailyDispatch of dailyDispatchDetails) {
|
|
122
|
+
const dispatchedTonnage: number = dailyDispatch.collectedRampWeight
|
|
123
|
+
const dispatchDate: string = newDailyDispatch.dispatchAt.toString().split('T')[0]
|
|
124
|
+
const ramp: Ramp = dailyDispatch.ramp
|
|
125
|
+
|
|
126
|
+
await generateTransactionHistory(
|
|
127
|
+
null,
|
|
128
|
+
domain,
|
|
129
|
+
dailyDispatch.ramp,
|
|
130
|
+
newDailyDispatch.id,
|
|
131
|
+
newDailyDispatch.name,
|
|
132
|
+
TRANSACTION_TYPE.DISPATCHMENT,
|
|
133
|
+
dispatchDate,
|
|
134
|
+
0,
|
|
135
|
+
-dispatchedTonnage,
|
|
136
|
+
user,
|
|
137
|
+
tx
|
|
138
|
+
)
|
|
139
|
+
|
|
140
|
+
let rampBlockHistory = await tx.query(
|
|
141
|
+
`
|
|
142
|
+
SELECT * FROM (
|
|
143
|
+
SELECT *, ROW_NUMBER () OVER (PARTITION BY ramp_id, block_id ORDER BY transaction_date desc, transaction_type) AS rn FROM ramp_block_histories
|
|
144
|
+
WHERE ramp_id =$1 AND transaction_date <= $2
|
|
145
|
+
) foo WHERE rn = 1
|
|
146
|
+
`,
|
|
147
|
+
[ramp.id, dispatchDate]
|
|
148
|
+
)
|
|
149
|
+
|
|
150
|
+
let totalRampWeight: number = rampBlockHistory.reduce((total, currentValue) => {
|
|
151
|
+
total += currentValue.previous_weight + currentValue.weight
|
|
152
|
+
return total
|
|
153
|
+
}, 0)
|
|
154
|
+
|
|
155
|
+
for (let index = 0; index < rampBlockHistory.length; index++) {
|
|
156
|
+
const dt2 = rampBlockHistory[index]
|
|
157
|
+
const block: Block = await blockRepo.findOne({ id: dt2.block_id })
|
|
158
|
+
|
|
159
|
+
let currentRampBlockWeight = dt2.previous_weight + dt2.weight
|
|
160
|
+
let percentage = parseFloat((currentRampBlockWeight / totalRampWeight).toFixed(4))
|
|
161
|
+
let weight = (-dispatchedTonnage * percentage).toFixed(4)
|
|
162
|
+
|
|
163
|
+
// // 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)
|
|
164
|
+
// let processedData = await tx.query(
|
|
165
|
+
// `
|
|
166
|
+
// insert into ramp_block_histories (id, seq, 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)
|
|
167
|
+
// SELECT uuid_generate_v4() AS id, (select seq from ramp_block_histories where ramp_id = '${ramp.id}' and domain_id = '${domain.id}' order by seq desc limit 1) + 1,'DISPATCH' AS transaction_type,
|
|
168
|
+
// '0933baea-e099-494b-9791-3dfe805731f0' AS creator_id, '0933baea-e099-494b-9791-3dfe805731f0' AS updater_id,
|
|
169
|
+
// $1 AS transaction_date, $2 AS created_at, $3 AS updated_at,
|
|
170
|
+
// $4 AS domain_id, $5 AS ramp_id,
|
|
171
|
+
// $6 AS weight,
|
|
172
|
+
// $7 AS previous_weight,
|
|
173
|
+
// $8 AS current_weight,
|
|
174
|
+
// $9 AS block_id,
|
|
175
|
+
// $10 AS daily_dispatch_id
|
|
176
|
+
// `,
|
|
177
|
+
// [
|
|
178
|
+
// dispatchDate,
|
|
179
|
+
// dt2.created_at,
|
|
180
|
+
// dt2.updated_at,
|
|
181
|
+
// domain.id,
|
|
182
|
+
// ramp.id,
|
|
183
|
+
// parseFloat(weight),
|
|
184
|
+
// parseFloat(currentRampBlockWeight),
|
|
185
|
+
// parseFloat(currentRampBlockWeight) + parseFloat(weight),
|
|
186
|
+
// dt2.block_id,
|
|
187
|
+
// newDailyDispatch.id
|
|
188
|
+
// ]
|
|
189
|
+
// )
|
|
190
|
+
|
|
191
|
+
await generateRampBlockHistories(
|
|
192
|
+
block,
|
|
118
193
|
domain,
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
newDailyDispatch.name,
|
|
122
|
-
TRANSACTION_TYPE.DISPATCHMENT,
|
|
194
|
+
ramp,
|
|
195
|
+
'DISPATCH',
|
|
123
196
|
dispatchDate,
|
|
124
|
-
|
|
125
|
-
-dispatchedTonnage,
|
|
197
|
+
parseFloat(weight),
|
|
126
198
|
user,
|
|
199
|
+
null,
|
|
200
|
+
newDailyDispatch,
|
|
127
201
|
tx
|
|
128
202
|
)
|
|
129
|
-
|
|
130
|
-
|
|
203
|
+
|
|
204
|
+
// await txMgr.query(`
|
|
205
|
+
// SELECT * FROM (
|
|
206
|
+
// SELECT *, ROW_NUMBER () OVER (PARTITION BY ramp_id, block_id ORDER BY transaction_date desc) AS rn FROM ramp_block_histories
|
|
207
|
+
// WHERE ramp_id =$1 AND transaction_date <= $2
|
|
208
|
+
// ) foo WHERE rn = 1
|
|
209
|
+
// `, [dt.ramp_id, dt.transaction_date]
|
|
210
|
+
// )
|
|
211
|
+
let x = dt2
|
|
212
|
+
}
|
|
213
|
+
let x = rampBlockHistory
|
|
214
|
+
}
|
|
131
215
|
}
|
|
@@ -27,6 +27,32 @@ export const Query = {
|
|
|
27
27
|
async dailyHarvests(_: any, params: ListParam, context: any) {
|
|
28
28
|
const { tx }: { tx: EntityManager } = context.state
|
|
29
29
|
|
|
30
|
+
const fromDateParamIdx = params.filters.findIndex(param => param.name === 'fromDate')
|
|
31
|
+
if (fromDateParamIdx >= 0) {
|
|
32
|
+
let harvestDateFrom = params.filters.find(param => param.name === 'fromDate')?.value
|
|
33
|
+
params.filters.splice(fromDateParamIdx, 1)
|
|
34
|
+
|
|
35
|
+
params.filters.push({
|
|
36
|
+
name: 'harvestDate',
|
|
37
|
+
operator: 'gte',
|
|
38
|
+
value: harvestDateFrom,
|
|
39
|
+
relation: false
|
|
40
|
+
})
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const toDateParamIdx = params.filters.findIndex(param => param.name === 'toDate')
|
|
44
|
+
if (toDateParamIdx >= 0) {
|
|
45
|
+
let harvestDateTo = params.filters.find(param => param.name === 'toDate')?.value
|
|
46
|
+
params.filters.splice(toDateParamIdx, 1)
|
|
47
|
+
|
|
48
|
+
params.filters.push({
|
|
49
|
+
name: 'harvestDate',
|
|
50
|
+
operator: 'lte',
|
|
51
|
+
value: harvestDateTo,
|
|
52
|
+
relation: false
|
|
53
|
+
})
|
|
54
|
+
}
|
|
55
|
+
|
|
30
56
|
const queryBuilder = tx.getRepository(DailyHarvestEntity).createQueryBuilder()
|
|
31
57
|
buildQuery(queryBuilder, params, context)
|
|
32
58
|
|
|
@@ -25,6 +25,32 @@ export const Query = {
|
|
|
25
25
|
async dailyLoadings(_: any, params: ListParam, context: any) {
|
|
26
26
|
const { tx }: { tx: EntityManager } = context.state
|
|
27
27
|
|
|
28
|
+
const fromDateParamIdx = params.filters.findIndex(param => param.name === 'fromDate')
|
|
29
|
+
if (fromDateParamIdx >= 0) {
|
|
30
|
+
let loadingDateFrom = params.filters.find(param => param.name === 'fromDate')?.value
|
|
31
|
+
params.filters.splice(fromDateParamIdx, 1)
|
|
32
|
+
|
|
33
|
+
params.filters.push({
|
|
34
|
+
name: 'loadingDate',
|
|
35
|
+
operator: 'gte',
|
|
36
|
+
value: loadingDateFrom,
|
|
37
|
+
relation: false
|
|
38
|
+
})
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const toDateParamIdx = params.filters.findIndex(param => param.name === 'toDate')
|
|
42
|
+
if (toDateParamIdx >= 0) {
|
|
43
|
+
let loadingDateTo = params.filters.find(param => param.name === 'toDate')?.value
|
|
44
|
+
params.filters.splice(toDateParamIdx, 1)
|
|
45
|
+
|
|
46
|
+
params.filters.push({
|
|
47
|
+
name: 'loadingDate',
|
|
48
|
+
operator: 'lte',
|
|
49
|
+
value: loadingDateTo,
|
|
50
|
+
relation: false
|
|
51
|
+
})
|
|
52
|
+
}
|
|
53
|
+
|
|
28
54
|
const queryBuilder = tx.getRepository(DailyLoadingEntity).createQueryBuilder()
|
|
29
55
|
buildQuery(queryBuilder, params, context)
|
|
30
56
|
|