@things-factory/operato-hub 4.3.47 → 4.3.49
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-server/graphql/resolvers/synchronization/create-dat-shipments.js +58 -0
- package/dist-server/graphql/resolvers/synchronization/create-dat-shipments.js.map +1 -0
- package/dist-server/graphql/resolvers/synchronization/index.js +2 -1
- package/dist-server/graphql/resolvers/synchronization/index.js.map +1 -1
- package/dist-server/graphql/types/synchronization/index.js +1 -0
- package/dist-server/graphql/types/synchronization/index.js.map +1 -1
- package/package.json +6 -6
- package/server/graphql/resolvers/synchronization/create-dat-shipments.ts +63 -0
- package/server/graphql/resolvers/synchronization/index.ts +3 -1
- package/server/graphql/types/synchronization/index.ts +1 -0
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createDatShipments = void 0;
|
|
4
|
+
const typeorm_1 = require("typeorm");
|
|
5
|
+
const env_1 = require("@things-factory/env");
|
|
6
|
+
const integration_sftp_1 = require("@things-factory/integration-sftp");
|
|
7
|
+
const sales_base_1 = require("@things-factory/sales-base");
|
|
8
|
+
const shell_1 = require("@things-factory/shell");
|
|
9
|
+
const biz_base_1 = require("@things-factory/biz-base");
|
|
10
|
+
exports.createDatShipments = {
|
|
11
|
+
async createDatShipments(_, {}, context) {
|
|
12
|
+
try {
|
|
13
|
+
await (0, typeorm_1.getConnection)().transaction(async (tx) => {
|
|
14
|
+
const currentTime = new Date();
|
|
15
|
+
const batchSize = 80;
|
|
16
|
+
let sftps = await tx.getRepository(integration_sftp_1.Sftp).find({
|
|
17
|
+
where: { status: 'ACTIVE' },
|
|
18
|
+
relations: ['domain', 'fulfillmentCenter']
|
|
19
|
+
});
|
|
20
|
+
for (let sftp of sftps) {
|
|
21
|
+
let warehouseDomain = await tx.getRepository(shell_1.Domain).findOne({
|
|
22
|
+
where: { subdomain: sftp.fulfillmentCenter.centerId }
|
|
23
|
+
});
|
|
24
|
+
let bizplace = await tx.getRepository(biz_base_1.Bizplace).findOne({
|
|
25
|
+
where: { domain: sftp.domain }
|
|
26
|
+
});
|
|
27
|
+
let releaseGoods = await tx.getRepository(sales_base_1.ReleaseGood).find({
|
|
28
|
+
where: {
|
|
29
|
+
domain: warehouseDomain,
|
|
30
|
+
bizplace: bizplace,
|
|
31
|
+
status: 'DONE',
|
|
32
|
+
updatedAt: (0, typeorm_1.MoreThan)(sftp.lastTimeSync)
|
|
33
|
+
},
|
|
34
|
+
relations: ['orderInventories', 'orderInventories.product']
|
|
35
|
+
});
|
|
36
|
+
while (releaseGoods.length > 0) {
|
|
37
|
+
let releaseGoodBatch = releaseGoods.splice(0, releaseGoods.length >= batchSize ? batchSize : releaseGoods.length);
|
|
38
|
+
const responseFileTypes = JSON.parse(sftp.responseFileTypes);
|
|
39
|
+
if (releaseGoodBatch.length > 0) {
|
|
40
|
+
if (responseFileTypes.enableShipment) {
|
|
41
|
+
let shipmentResult = await integration_sftp_1.SftpAPI.createShipment(sftp, {
|
|
42
|
+
releaseGoods: releaseGoodBatch,
|
|
43
|
+
sftp: sftp
|
|
44
|
+
});
|
|
45
|
+
shipmentResult.lastTimeSync = currentTime;
|
|
46
|
+
sftp = await tx.getRepository(integration_sftp_1.Sftp).save(shipmentResult);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
catch (e) {
|
|
54
|
+
env_1.logger.error(`createDatShipment: ${e}`);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
//# sourceMappingURL=create-dat-shipments.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-dat-shipments.js","sourceRoot":"","sources":["../../../../server/graphql/resolvers/synchronization/create-dat-shipments.ts"],"names":[],"mappings":";;;AAAA,qCAAiD;AACjD,6CAA4C;AAC5C,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AAC;qBAC5D,CAAC,CAAA;oBAEF,OAAO,YAAY,CAAC,MAAM,GAAG,CAAC,EAAE;wBAC9B,IAAI,gBAAgB,GAAG,YAAY,CAAC,MAAM,CACxC,CAAC,EACD,YAAY,CAAC,MAAM,IAAI,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,YAAY,CAAC,MAAM,CACnE,CAAA;wBAED,MAAM,iBAAiB,GAAQ,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAA;wBAEjE,IAAI,gBAAgB,CAAC,MAAM,GAAG,CAAC,EAAE;4BAC/B,IAAI,iBAAiB,CAAC,cAAc,EAAE;gCACpC,IAAI,cAAc,GAAS,MAAM,0BAAO,CAAC,cAAc,CAAC,IAAI,EAAE;oCAC5D,YAAY,EAAE,gBAAgB;oCAC9B,IAAI,EAAE,IAAI;iCACX,CAAC,CAAA;gCACF,cAAc,CAAC,YAAY,GAAG,WAAW,CAAA;gCACzC,IAAI,GAAG,MAAM,EAAE,CAAC,aAAa,CAAC,uBAAI,CAAC,CAAC,IAAI,CAAC,cAAc,CAAC,CAAA;6BACzD;yBACF;qBACF;iBACF;YACH,CAAC,CAAC,CAAA;SACH;QAAC,OAAO,CAAC,EAAE;YACV,YAAM,CAAC,KAAK,CAAC,sBAAsB,CAAC,EAAE,CAAC,CAAA;SACxC;IACH,CAAC;CACF,CAAA"}
|
|
@@ -9,6 +9,7 @@ const sync_all_products_to_sellercraft_1 = require("./sync-all-products-to-selle
|
|
|
9
9
|
const sync_products_from_account_1 = require("./sync-products-from-account");
|
|
10
10
|
const sync_products_to_account_1 = require("./sync-products-to-account");
|
|
11
11
|
const sync_products_to_sellercraft_1 = require("./sync-products-to-sellercraft");
|
|
12
|
+
const create_dat_shipments_1 = require("./create-dat-shipments");
|
|
12
13
|
exports.Query = Object.assign(Object.assign(Object.assign({}, fetch_sync_products_1.fetchSyncProductsResolver), fetch_sync_purchase_orders_1.fetchSyncPurchaseOrdersResolver), fetch_sync_invoices_1.fetchSyncInvoicesResolver);
|
|
13
|
-
exports.Mutation = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, sync_products_to_sellercraft_1.syncProductsToSellercraftResolver), sync_products_from_account_1.syncProductsFromAccountResolver), sync_products_to_account_1.syncProductsToAccountResolver), sync_all_products_to_sellercraft_1.syncAllProductsToSellercraftResolver), sellercraft_pack_marketplace_order_1.sellercraftPackMarketplaceOrderResolver);
|
|
14
|
+
exports.Mutation = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, sync_products_to_sellercraft_1.syncProductsToSellercraftResolver), sync_products_from_account_1.syncProductsFromAccountResolver), sync_products_to_account_1.syncProductsToAccountResolver), sync_all_products_to_sellercraft_1.syncAllProductsToSellercraftResolver), sellercraft_pack_marketplace_order_1.sellercraftPackMarketplaceOrderResolver), create_dat_shipments_1.createDatShipments);
|
|
14
15
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../server/graphql/resolvers/synchronization/index.ts"],"names":[],"mappings":";;;AAAA,+DAAiE;AACjE,+DAAiE;AACjE,6EAA8E;AAC9E,6FAA8F;AAC9F,yFAAyF;AACzF,6EAA8E;AAC9E,yEAA0E;AAC1E,iFAAkF;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../server/graphql/resolvers/synchronization/index.ts"],"names":[],"mappings":";;;AAAA,+DAAiE;AACjE,+DAAiE;AACjE,6EAA8E;AAC9E,6FAA8F;AAC9F,yFAAyF;AACzF,6EAA8E;AAC9E,yEAA0E;AAC1E,iFAAkF;AAClF,iEAA2D;AAE9C,QAAA,KAAK,iDACb,+CAAyB,GACzB,4DAA+B,GAC/B,+CAAyB,EAC7B;AAEY,QAAA,QAAQ,2FAChB,gEAAiC,GACjC,4DAA+B,GAC/B,wDAA6B,GAC7B,uEAAoC,GACpC,4EAAuC,GACvC,yCAAkB,EACtB"}
|
|
@@ -18,6 +18,7 @@ exports.Mutation = `
|
|
|
18
18
|
syncProductsToAccount(accountId: String!, bizplaceId: String!): Boolean @transaction
|
|
19
19
|
syncAllProductsToSellercraft: Boolean @transaction
|
|
20
20
|
sellercraftPackMarketplaceOrder: Boolean @transaction
|
|
21
|
+
createDatShipments: Boolean @transaction
|
|
21
22
|
`;
|
|
22
23
|
exports.Types = [
|
|
23
24
|
sync_product_set_1.SyncProductSet,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../server/graphql/types/synchronization/index.ts"],"names":[],"mappings":";;;AAAA,2DAAqD;AACrD,yDAAoE;AACpE,2DAAqD;AACrD,yDAAmD;AACnD,yEAAkE;AAClE,uEAAiF;AAEpE,QAAA,KAAK,GAAiB;;;;CAIlC,CAAA;AAEY,QAAA,QAAQ,GAAiB
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../server/graphql/types/synchronization/index.ts"],"names":[],"mappings":";;;AAAA,2DAAqD;AACrD,yDAAoE;AACpE,2DAAqD;AACrD,yDAAmD;AACnD,yEAAkE;AAClE,uEAAiF;AAEpE,QAAA,KAAK,GAAiB;;;;CAIlC,CAAA;AAEY,QAAA,QAAQ,GAAiB;;;;;;;CAOrC,CAAA;AAEY,QAAA,KAAK,GAAG;IACnB,iCAAc;IACd,mCAAe;IACf,8CAAoB;IACpB,gDAAqB;IACrB,GAAG,+BAAM;IACT,iCAAc;IACd,mCAAe;IACf,GAAG,wBAAM;CACV,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@things-factory/operato-hub",
|
|
3
|
-
"version": "4.3.
|
|
3
|
+
"version": "4.3.49",
|
|
4
4
|
"main": "dist-server/index.js",
|
|
5
5
|
"browser": "client/index.js",
|
|
6
6
|
"things-factory": true,
|
|
@@ -83,14 +83,14 @@
|
|
|
83
83
|
"@things-factory/integration-marketplace": "^4.3.47",
|
|
84
84
|
"@things-factory/integration-pos": "^4.3.47",
|
|
85
85
|
"@things-factory/integration-sellercraft": "^4.3.47",
|
|
86
|
-
"@things-factory/integration-sftp": "^4.3.
|
|
86
|
+
"@things-factory/integration-sftp": "^4.3.49",
|
|
87
87
|
"@things-factory/lite-menu": "^4.3.47",
|
|
88
88
|
"@things-factory/more-ui": "^4.3.47",
|
|
89
89
|
"@things-factory/notification": "^4.3.47",
|
|
90
90
|
"@things-factory/pdf": "^4.3.47",
|
|
91
91
|
"@things-factory/product-ui": "^4.3.47",
|
|
92
92
|
"@things-factory/resource-ui": "^4.3.47",
|
|
93
|
-
"@things-factory/sales-base": "^4.3.
|
|
93
|
+
"@things-factory/sales-base": "^4.3.49",
|
|
94
94
|
"@things-factory/scene-data-transform": "^4.3.47",
|
|
95
95
|
"@things-factory/scene-excel": "^4.3.47",
|
|
96
96
|
"@things-factory/scene-firebase": "^4.3.47",
|
|
@@ -105,8 +105,8 @@
|
|
|
105
105
|
"@things-factory/setting-ui": "^4.3.47",
|
|
106
106
|
"@things-factory/shell": "^4.3.47",
|
|
107
107
|
"@things-factory/system-ui": "^4.3.47",
|
|
108
|
-
"@things-factory/warehouse-base": "^4.3.
|
|
109
|
-
"@things-factory/worksheet-base": "^4.3.
|
|
108
|
+
"@things-factory/warehouse-base": "^4.3.49",
|
|
109
|
+
"@things-factory/worksheet-base": "^4.3.49",
|
|
110
110
|
"koa2-swagger-ui": "^5.0.2",
|
|
111
111
|
"swagger-jsdoc": "^5.0.0",
|
|
112
112
|
"yamljs": "^0.3.0"
|
|
@@ -117,5 +117,5 @@
|
|
|
117
117
|
"resolutions": {
|
|
118
118
|
"core-js": "^3.16.0"
|
|
119
119
|
},
|
|
120
|
-
"gitHead": "
|
|
120
|
+
"gitHead": "92f35aea7d93a7b25fb8c669e638372ffadc7202"
|
|
121
121
|
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { getConnection, MoreThan } from 'typeorm'
|
|
2
|
+
import { logger } from '@things-factory/env'
|
|
3
|
+
import { Sftp, SftpAPI } from '@things-factory/integration-sftp'
|
|
4
|
+
import { ReleaseGood } from '@things-factory/sales-base'
|
|
5
|
+
import { Domain } from '@things-factory/shell'
|
|
6
|
+
import { Bizplace } from '@things-factory/biz-base'
|
|
7
|
+
|
|
8
|
+
export const createDatShipments = {
|
|
9
|
+
async createDatShipments(_: void, {}, context: any): Promise<void> {
|
|
10
|
+
try {
|
|
11
|
+
await getConnection().transaction(async tx => {
|
|
12
|
+
const currentTime = new Date()
|
|
13
|
+
const batchSize = 80
|
|
14
|
+
let sftps: Sftp[] = await tx.getRepository(Sftp).find({
|
|
15
|
+
where: { status: 'ACTIVE' },
|
|
16
|
+
relations: ['domain', 'fulfillmentCenter']
|
|
17
|
+
})
|
|
18
|
+
|
|
19
|
+
for (let sftp of sftps) {
|
|
20
|
+
let warehouseDomain: Domain = await tx.getRepository(Domain).findOne({
|
|
21
|
+
where: { subdomain: sftp.fulfillmentCenter.centerId }
|
|
22
|
+
})
|
|
23
|
+
|
|
24
|
+
let bizplace: Bizplace = await tx.getRepository(Bizplace).findOne({
|
|
25
|
+
where: { domain: sftp.domain }
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
let releaseGoods: ReleaseGood[] = await tx.getRepository(ReleaseGood).find({
|
|
29
|
+
where: {
|
|
30
|
+
domain: warehouseDomain,
|
|
31
|
+
bizplace: bizplace,
|
|
32
|
+
status: 'DONE',
|
|
33
|
+
updatedAt: MoreThan(sftp.lastTimeSync)
|
|
34
|
+
},
|
|
35
|
+
relations: ['orderInventories', 'orderInventories.product']
|
|
36
|
+
})
|
|
37
|
+
|
|
38
|
+
while (releaseGoods.length > 0) {
|
|
39
|
+
let releaseGoodBatch = releaseGoods.splice(
|
|
40
|
+
0,
|
|
41
|
+
releaseGoods.length >= batchSize ? batchSize : releaseGoods.length
|
|
42
|
+
)
|
|
43
|
+
|
|
44
|
+
const responseFileTypes: any = JSON.parse(sftp.responseFileTypes)
|
|
45
|
+
|
|
46
|
+
if (releaseGoodBatch.length > 0) {
|
|
47
|
+
if (responseFileTypes.enableShipment) {
|
|
48
|
+
let shipmentResult: Sftp = await SftpAPI.createShipment(sftp, {
|
|
49
|
+
releaseGoods: releaseGoodBatch,
|
|
50
|
+
sftp: sftp
|
|
51
|
+
})
|
|
52
|
+
shipmentResult.lastTimeSync = currentTime
|
|
53
|
+
sftp = await tx.getRepository(Sftp).save(shipmentResult)
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
})
|
|
59
|
+
} catch (e) {
|
|
60
|
+
logger.error(`createDatShipment: ${e}`)
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
@@ -6,6 +6,7 @@ import { syncAllProductsToSellercraftResolver } from './sync-all-products-to-sel
|
|
|
6
6
|
import { syncProductsFromAccountResolver } from './sync-products-from-account'
|
|
7
7
|
import { syncProductsToAccountResolver } from './sync-products-to-account'
|
|
8
8
|
import { syncProductsToSellercraftResolver } from './sync-products-to-sellercraft'
|
|
9
|
+
import { createDatShipments } from './create-dat-shipments'
|
|
9
10
|
|
|
10
11
|
export const Query = {
|
|
11
12
|
...fetchSyncProductsResolver,
|
|
@@ -18,5 +19,6 @@ export const Mutation = {
|
|
|
18
19
|
...syncProductsFromAccountResolver,
|
|
19
20
|
...syncProductsToAccountResolver,
|
|
20
21
|
...syncAllProductsToSellercraftResolver,
|
|
21
|
-
...sellercraftPackMarketplaceOrderResolver
|
|
22
|
+
...sellercraftPackMarketplaceOrderResolver,
|
|
23
|
+
...createDatShipments
|
|
22
24
|
}
|
|
@@ -17,6 +17,7 @@ export const Mutation = /* GraphQL */ `
|
|
|
17
17
|
syncProductsToAccount(accountId: String!, bizplaceId: String!): Boolean @transaction
|
|
18
18
|
syncAllProductsToSellercraft: Boolean @transaction
|
|
19
19
|
sellercraftPackMarketplaceOrder: Boolean @transaction
|
|
20
|
+
createDatShipments: Boolean @transaction
|
|
20
21
|
`
|
|
21
22
|
|
|
22
23
|
export const Types = [
|