From 5c054fe0d3a6e73a71ab26f8e19ada1c0b757e6c Mon Sep 17 00:00:00 2001 From: jorgep Date: Mon, 11 Nov 2024 09:09:51 +0100 Subject: [PATCH 1/4] feat: refs #6869 add back --- .../vn/procedures/itemShelving_get.sql | 30 ----------- .../back/methods/item-shelving/getItems.js | 51 +++++++++++++++++++ modules/item/back/models/item-shelving.js | 1 + 3 files changed, 52 insertions(+), 30 deletions(-) delete mode 100644 db/routines/vn/procedures/itemShelving_get.sql create mode 100644 modules/item/back/methods/item-shelving/getItems.js diff --git a/db/routines/vn/procedures/itemShelving_get.sql b/db/routines/vn/procedures/itemShelving_get.sql deleted file mode 100644 index 07384b721..000000000 --- a/db/routines/vn/procedures/itemShelving_get.sql +++ /dev/null @@ -1,30 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemShelving_get`(IN vSelf VARCHAR(8)) -BEGIN -/** -* Lista artículos de itemshelving -* -* @param vSelf matrícula del carro -**/ - SELECT ish.itemFk item, - i.name, - i.longName, - i.size, - ish.visible, - ish.packing, - ish.grouping, - p.code, - ish.id, - s.priority, - ish.isChecked, - ic.url, - ish.available, - ish.buyFk - FROM itemShelving ish - JOIN item i ON i.id = ish.itemFk - JOIN shelving s ON vSelf = s.code COLLATE utf8_unicode_ci - LEFT JOIN parking p ON s.parkingFk = p.id - JOIN hedera.imageConfig ic - WHERE ish.shelvingFk COLLATE utf8_unicode_ci = vSelf; -END$$ -DELIMITER ; diff --git a/modules/item/back/methods/item-shelving/getItems.js b/modules/item/back/methods/item-shelving/getItems.js new file mode 100644 index 000000000..2fe50d785 --- /dev/null +++ b/modules/item/back/methods/item-shelving/getItems.js @@ -0,0 +1,51 @@ +module.exports = Self => { + Self.remoteMethod('getItems', { + description: 'shelving item list', + accessType: 'READ', + accepts: [{ + arg: 'code', + type: 'string', + required: true, + description: 'Shelving code' + }], + returns: { + type: 'object', + root: true + }, + http: { + path: `/getItems`, + verb: 'GET' + } + }); + + Self.getItems = async(code, options) => { + const models = Self.app.models; + const myOptions = {}; + if (typeof options == 'object') + Object.assign(myOptions, options); + + const shelving = await models.Shelving.findOne({ + fields: ['priority', 'parkingFk'], + include: { + relation: 'parking', + scope: {fields: ['code']} + }, + where: {code} + }, myOptions); + + const itemShelvings = await Self.find({ + fields: ['itemFk', 'visible', 'packing', 'grouping', 'isChecked', 'available', 'buyFk'], + include: { + relation: 'item', + scope: {fields: ['name', 'longName', 'size']} + }, + where: {shelvingFk: code} + }, myOptions); + return { + code: shelving.parking().code, + priority: shelving.priority, + itemShelvings, + }; + // Add image from hedera.imageConfig + }; +}; diff --git a/modules/item/back/models/item-shelving.js b/modules/item/back/models/item-shelving.js index be72dac37..ba6ab780d 100644 --- a/modules/item/back/models/item-shelving.js +++ b/modules/item/back/models/item-shelving.js @@ -5,4 +5,5 @@ module.exports = Self => { require('../methods/item-shelving/getAlternative')(Self); require('../methods/item-shelving/updateFromSale')(Self); require('../methods/item-shelving/getListItemNewer')(Self); + require('../methods/item-shelving/getItems')(Self); }; -- 2.40.1 From a41fc36f9092105384ccdd3bcf7f8adcc193d435 Mon Sep 17 00:00:00 2001 From: jorgep Date: Mon, 11 Nov 2024 13:02:09 +0100 Subject: [PATCH 2/4] feat: refs #6869 define model --- back/model-config.json | 3 ++ back/models/image-config.json | 22 ++++++++ .../back/methods/item-shelving/getItems.js | 51 ------------------- modules/item/back/models/item-shelving.js | 1 - modules/item/back/models/item-shelving.json | 3 ++ modules/shelving/back/models/shelving.json | 10 +++- 6 files changed, 36 insertions(+), 54 deletions(-) create mode 100644 back/models/image-config.json delete mode 100644 modules/item/back/methods/item-shelving/getItems.js diff --git a/back/model-config.json b/back/model-config.json index 5368769fd..73db0a31b 100644 --- a/back/model-config.json +++ b/back/model-config.json @@ -79,6 +79,9 @@ "ImageCollectionSize": { "dataSource": "vn" }, + "ImageConfig": { + "dataSource": "vn" + }, "ImageContainer": { "dataSource": "imageStorage" }, diff --git a/back/models/image-config.json b/back/models/image-config.json new file mode 100644 index 000000000..11f4c2284 --- /dev/null +++ b/back/models/image-config.json @@ -0,0 +1,22 @@ +{ + "name": "ImageConfig", + "base": "VnModel", + "options": { + "mysql": { + "table": "hedera.imageConfig" + } + }, + "properties": { + "url": { + "type": "string" + } + }, + "acls": [ + { + "accessType": "READ", + "principalType": "ROLE", + "principalId": "$authenticated", + "permission": "ALLOW" + } + ] +} \ No newline at end of file diff --git a/modules/item/back/methods/item-shelving/getItems.js b/modules/item/back/methods/item-shelving/getItems.js deleted file mode 100644 index 2fe50d785..000000000 --- a/modules/item/back/methods/item-shelving/getItems.js +++ /dev/null @@ -1,51 +0,0 @@ -module.exports = Self => { - Self.remoteMethod('getItems', { - description: 'shelving item list', - accessType: 'READ', - accepts: [{ - arg: 'code', - type: 'string', - required: true, - description: 'Shelving code' - }], - returns: { - type: 'object', - root: true - }, - http: { - path: `/getItems`, - verb: 'GET' - } - }); - - Self.getItems = async(code, options) => { - const models = Self.app.models; - const myOptions = {}; - if (typeof options == 'object') - Object.assign(myOptions, options); - - const shelving = await models.Shelving.findOne({ - fields: ['priority', 'parkingFk'], - include: { - relation: 'parking', - scope: {fields: ['code']} - }, - where: {code} - }, myOptions); - - const itemShelvings = await Self.find({ - fields: ['itemFk', 'visible', 'packing', 'grouping', 'isChecked', 'available', 'buyFk'], - include: { - relation: 'item', - scope: {fields: ['name', 'longName', 'size']} - }, - where: {shelvingFk: code} - }, myOptions); - return { - code: shelving.parking().code, - priority: shelving.priority, - itemShelvings, - }; - // Add image from hedera.imageConfig - }; -}; diff --git a/modules/item/back/models/item-shelving.js b/modules/item/back/models/item-shelving.js index ba6ab780d..be72dac37 100644 --- a/modules/item/back/models/item-shelving.js +++ b/modules/item/back/models/item-shelving.js @@ -5,5 +5,4 @@ module.exports = Self => { require('../methods/item-shelving/getAlternative')(Self); require('../methods/item-shelving/updateFromSale')(Self); require('../methods/item-shelving/getListItemNewer')(Self); - require('../methods/item-shelving/getItems')(Self); }; diff --git a/modules/item/back/models/item-shelving.json b/modules/item/back/models/item-shelving.json index 5df3b0703..b0e3f17fa 100644 --- a/modules/item/back/models/item-shelving.json +++ b/modules/item/back/models/item-shelving.json @@ -41,6 +41,9 @@ }, "available": { "type": "number" + }, + "buyFk": { + "type": "number" } }, "relations": { diff --git a/modules/shelving/back/models/shelving.json b/modules/shelving/back/models/shelving.json index 46fce31e8..f6df57d43 100644 --- a/modules/shelving/back/models/shelving.json +++ b/modules/shelving/back/models/shelving.json @@ -1,6 +1,6 @@ { "name": "Shelving", - "base": "VnModel", + "base": "VnModel", "mixins": { "Loggable": true }, @@ -44,6 +44,12 @@ "type": "belongsTo", "model": "Worker", "foreignKey": "id" + }, + "itemShelving": { + "type": "hasMany", + "model": "ItemShelving", + "foreignKey": "shelvingFk", + "primaryKey": "code" } } -} +} \ No newline at end of file -- 2.40.1 From 7a4455d6d01d2fe4a3157f94889e4b928edc807c Mon Sep 17 00:00:00 2001 From: sergiodt Date: Fri, 15 Nov 2024 08:12:16 +0100 Subject: [PATCH 3/4] feat: refs #6869 refs#6869 itemShelving_get --- .../vn/procedures/itemShelving_get.sql | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 db/routines/vn/procedures/itemShelving_get.sql diff --git a/db/routines/vn/procedures/itemShelving_get.sql b/db/routines/vn/procedures/itemShelving_get.sql new file mode 100644 index 000000000..07384b721 --- /dev/null +++ b/db/routines/vn/procedures/itemShelving_get.sql @@ -0,0 +1,30 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemShelving_get`(IN vSelf VARCHAR(8)) +BEGIN +/** +* Lista artículos de itemshelving +* +* @param vSelf matrícula del carro +**/ + SELECT ish.itemFk item, + i.name, + i.longName, + i.size, + ish.visible, + ish.packing, + ish.grouping, + p.code, + ish.id, + s.priority, + ish.isChecked, + ic.url, + ish.available, + ish.buyFk + FROM itemShelving ish + JOIN item i ON i.id = ish.itemFk + JOIN shelving s ON vSelf = s.code COLLATE utf8_unicode_ci + LEFT JOIN parking p ON s.parkingFk = p.id + JOIN hedera.imageConfig ic + WHERE ish.shelvingFk COLLATE utf8_unicode_ci = vSelf; +END$$ +DELIMITER ; -- 2.40.1 From dd637b9333ea75f966f8efb8e1823bae39de960a Mon Sep 17 00:00:00 2001 From: jorgep Date: Mon, 18 Nov 2024 10:34:23 +0100 Subject: [PATCH 4/4] fix: refs #6869 use id as primaryKey --- modules/shelving/back/models/shelving.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/modules/shelving/back/models/shelving.json b/modules/shelving/back/models/shelving.json index f6df57d43..84e260b9e 100644 --- a/modules/shelving/back/models/shelving.json +++ b/modules/shelving/back/models/shelving.json @@ -48,8 +48,7 @@ "itemShelving": { "type": "hasMany", "model": "ItemShelving", - "foreignKey": "shelvingFk", - "primaryKey": "code" + "foreignKey": "shelvingFk" } } } \ No newline at end of file -- 2.40.1