From 60025c612e4d068255d498ad69fb737ff27bf521 Mon Sep 17 00:00:00 2001 From: cuilei <ray_tsu1@163.com> Date: 星期四, 07 八月 2025 10:27:17 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/master' --- src/main/java/org/jeecg/modules/base/service/IUserFactoryService.java | 5 src/main/java/org/jeecg/modules/pms/service/impl/PmsProcessBillMaterialsDetailServiceImpl.java | 49 src/main/java/org/jeecg/modules/base/service/IFactoryService.java | 7 src/main/java/org/jeecg/modules/base/mapper/xml/FactoryMapper.xml | 18 src/main/java/org/jeecg/modules/mdc/service/impl/FactoryEquipmentServiceImpl.java | 87 src/main/java/org/jeecg/modules/base/mapper/UserFactoryMapper.java | 4 src/main/java/org/jeecg/modules/pms/mapper/PmsMaterialProcessMapper.java | 10 src/main/java/org/jeecg/modules/pms/controller/PmsProcessBillMaterialsController.java | 195 - src/main/java/org/jeecg/modules/pms/entity/PmsProcessBillMaterials.java | 24 src/main/java/org/jeecg/modules/system/service/impl/SysUserServiceImpl.java | 20 src/main/java/org/jeecg/modules/mdc/controller/MdcEfficiencyReportController.java | 70 src/main/java/org/jeecg/modules/mdc/dto/MdcEfficiencyDto.java | 12 src/main/java/org/jeecg/modules/sap/service/impl/OrderBomSyncImpl.java | 91 src/main/java/org/jeecg/modules/mdc/service/IMdcEquipmentService.java | 30 src/main/java/org/jeecg/modules/pms/mapper/xml/PmsProcessBillMaterialsMapper.xml | 13 src/main/java/org/jeecg/modules/sap/service/OrderProcessSync.java | 12 src/main/java/org/jeecg/modules/pms/entity/PmsMaterialProcess.java | 72 src/main/java/org/jeecg/modules/sap/dto/OrderBomDTO.java | 19 src/main/java/org/jeecg/modules/system/mapper/SysApiLogMapper.java | 17 src/main/java/org/jeecg/modules/base/service/impl/UserFactoryServiceImpl.java | 9 src/main/java/org/jeecg/modules/sap/FunctionConst.java | 12 src/main/java/org/jeecg/modules/sap/service/OrderBomSync.java | 12 src/main/java/org/jeecg/modules/pms/service/impl/PmsProcessBillMaterialsServiceImpl.java | 94 src/main/java/org/jeecg/modules/system/mapper/xml/SysApiLogMapper.xml | 2 src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentStatisticalInfoServiceImpl.java | 6 src/main/java/org/jeecg/modules/sap/service/impl/ProductionOrderSyncImpl.java | 230 + src/main/java/org/jeecg/modules/pms/service/IPmsMaterialProcessService.java | 25 src/main/java/org/jeecg/modules/sap/controller/SAPTestController.java | 63 src/main/java/org/jeecg/modules/mdc/mapper/MdcEquipmentMapper.java | 7 src/main/java/org/jeecg/modules/mdc/mapper/xml/FactoryEquipmentMapper.xml | 2 src/main/java/org/jeecg/modules/system/controller/SysApiLogController.java | 58 src/main/java/org/jeecg/common/aspect/ApiLogAspect.java | 152 + src/main/java/org/jeecg/modules/mdc/controller/MdcEquipmentController.java | 146 + src/main/java/org/jeecg/modules/pms/service/IPmsProcessBillMaterialsService.java | 28 src/main/java/org/jeecg/modules/system/mapper/xml/SysUserMapper.xml | 2 src/main/java/org/jeecg/modules/mes/mapper/xml/MesProductionOrderMapper.xml | 7 src/main/java/org/jeecg/modules/pms/entity/PmsProcessBillMaterialsDetail.java | 22 src/main/java/org/jeecg/modules/pms/controller/PmsMaterialProcessController.java | 189 - src/main/java/org/jeecg/common/aspect/annotation/ApiLog.java | 22 src/main/java/org/jeecg/modules/mes/entity/MesProductionOrder.java | 160 + src/main/java/org/jeecg/modules/pms/controller/PmsProcessBillMaterialsDetailController.java | 179 - src/main/java/org/jeecg/modules/mdc/model/FactoryTreeModel.java | 112 + src/main/java/org/jeecg/modules/mes/service/impl/MesProductionOrderServiceImpl.java | 58 src/main/java/org/jeecg/modules/pms/service/impl/PmsMaterialProcessServiceImpl.java | 73 src/main/java/org/jeecg/modules/mdc/entity/MdcEquipment.java | 2 src/main/java/org/jeecg/modules/sap/service/ProductionOrderSync.java | 4 src/main/java/org/jeecg/modules/mdc/entity/FactoryEquipment.java | 53 src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcEquipmentMapper.xml | 51 src/main/java/org/jeecg/modules/pms/mapper/xml/PmsMaterialProcessMapper.xml | 14 src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcEfficiencyReportMapper.xml | 12 src/main/java/org/jeecg/modules/mdc/service/impl/MdcEfficiencyReportServiceImpl.java | 782 ++++---- src/main/java/org/jeecg/modules/mes/job/ProductionOrderSyncUpdateJob.java | 173 + src/main/java/org/jeecg/modules/pms/service/IPmsProcessBillMaterialsDetailService.java | 21 src/main/java/org/jeecg/modules/sap/service/impl/OrderProcessSyncImpl.java | 93 src/main/java/org/jeecg/modules/system/service/impl/SysApiLogServiceImpl.java | 19 db/双林新火炬MES数据库设计.pdma.json | 882 ++++++++ src/main/java/org/jeecg/common/constant/ApiLogCategoryEnum.java | 21 src/main/java/org/jeecg/modules/mdc/service/MdcEfficiencyReportService.java | 14 src/main/java/org/jeecg/modules/mdc/dto/MdcEfficiencyResultDto.java | 32 src/main/java/org/jeecg/modules/mes/job/ProductionOrderSyncCreationJob.java | 173 + src/main/java/org/jeecg/modules/system/entity/SysApiLog.java | 86 src/main/java/org/jeecg/modules/sap/dto/OrderProcessDTO.java | 20 src/main/java/org/jeecg/modules/mdc/service/IFactoryEquipmentService.java | 30 src/main/java/org/jeecg/modules/system/service/ISysApiLogService.java | 14 src/main/java/org/jeecg/modules/base/mapper/FactoryMapper.java | 11 src/main/java/org/jeecg/modules/mdc/vo/MdcEquipmentProVo.java | 2 src/main/java/org/jeecg/modules/mdc/mapper/FactoryEquipmentMapper.java | 13 /dev/null | 53 src/main/java/org/jeecg/modules/mdc/util/FindsEquipmentFactoryUtil.java | 80 src/main/java/org/jeecg/modules/mes/service/IMesProductionOrderService.java | 29 src/main/java/org/jeecg/codegenerate/JeecgOneUtil.java | 8 src/main/java/org/jeecg/modules/mes/mapper/MesProductionOrderMapper.java | 13 src/main/java/org/jeecg/modules/base/mapper/xml/UserFactoryMapper.xml | 4 src/main/java/org/jeecg/modules/base/service/impl/FactoryServiceImpl.java | 17 src/main/java/org/jeecg/modules/pms/mapper/PmsProcessBillMaterialsMapper.java | 14 src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentServiceImpl.java | 315 ++- src/main/java/org/jeecg/modules/mdc/model/MdcEquipmentTree.java | 13 src/main/java/org/jeecg/modules/system/controller/SysUserController.java | 27 src/main/java/org/jeecg/modules/mes/controller/MesProductionOrderController.java | 191 - 79 files changed, 3,988 insertions(+), 1,723 deletions(-) diff --git "a/db/\345\217\214\346\236\227\346\226\260\347\201\253\347\202\254MES\346\225\260\346\215\256\345\272\223\350\256\276\350\256\241.pdma.json" "b/db/\345\217\214\346\236\227\346\226\260\347\201\253\347\202\254MES\346\225\260\346\215\256\345\272\223\350\256\276\350\256\241.pdma.json" index e3aa0fd..2308f0a 100644 --- "a/db/\345\217\214\346\236\227\346\226\260\347\201\253\347\202\254MES\346\225\260\346\215\256\345\272\223\350\256\276\350\256\241.pdma.json" +++ "b/db/\345\217\214\346\236\227\346\226\260\347\201\253\347\202\254MES\346\225\260\346\215\256\345\272\223\350\256\276\350\256\241.pdma.json" @@ -632,7 +632,7 @@ "#DDE5FF" ], "DDLToggleCase": "L", - "menuWidth": "293px" + "menuWidth": "364px" }, "entities": [ { @@ -10697,7 +10697,7 @@ }, { "defKey": "production_unit", - "defName": "浜у搧鍗曚綅", + "defName": "鍩烘湰璁¢噺鍗曚綅", "comment": "", "type": "", "len": "", @@ -10730,6 +10730,24 @@ "extProps": {}, "domain": "73FD2BAD-2358-4336-B96D-45DC897BD792", "id": "EA8BA140-CED8-4B45-8FCC-197817AA3590" + }, + { + "defKey": "order_status_name", + "defName": "璁㈠崟鐘舵�佹弿杩�", + "comment": "", + "type": "", + "len": "", + "scale": "", + "primaryKey": false, + "notNull": false, + "autoIncrement": false, + "defaultValue": "", + "hideInGraph": false, + "refDict": "", + "baseType": "FC9790A7-36B8-4A48-8F9A-BC1042BCFE64", + "extProps": {}, + "domain": "9092C4E0-1A54-4859-ABBB-5B62DBC27573", + "id": "F5A7DE2A-A683-4218-A1B5-9CDA18C273B7" }, { "defKey": "priority", @@ -10820,6 +10838,114 @@ "extProps": {}, "domain": "9092C4E0-1A54-4859-ABBB-5B62DBC27573", "id": "4BF071F1-4F69-4044-8C17-25D7B66404F7" + }, + { + "defKey": "dispatcher_code", + "defName": "璋冨害鍛樼紪鍙�", + "comment": "", + "type": "", + "len": "", + "scale": "", + "primaryKey": false, + "notNull": false, + "autoIncrement": false, + "defaultValue": "", + "hideInGraph": false, + "refDict": "", + "baseType": "FC9790A7-36B8-4A48-8F9A-BC1042BCFE64", + "extProps": {}, + "domain": "54611CCC-CA4B-42E1-9F32-4944C85B85A6", + "id": "09E4DA62-D2E3-4D82-9259-DCACA5C40FFD" + }, + { + "defKey": "dispatcher_name", + "defName": "璋冨害鍛樺悕绉�", + "comment": "", + "type": "", + "len": "", + "scale": "", + "primaryKey": false, + "notNull": false, + "autoIncrement": false, + "defaultValue": "", + "hideInGraph": false, + "refDict": "", + "baseType": "FC9790A7-36B8-4A48-8F9A-BC1042BCFE64", + "extProps": {}, + "domain": "9092C4E0-1A54-4859-ABBB-5B62DBC27573", + "id": "C700FB1A-B747-4E97-A7BE-0044C0B3B2EE" + }, + { + "defKey": "order_create_date", + "defName": "璁㈠崟鍒涘缓鏃ユ湡", + "comment": "", + "type": "", + "len": "", + "scale": "", + "primaryKey": false, + "notNull": false, + "autoIncrement": false, + "defaultValue": "", + "hideInGraph": false, + "refDict": "", + "baseType": "FC9790A7-36B8-4A48-8F9A-BC1042BCFE64", + "extProps": {}, + "domain": "54611CCC-CA4B-42E1-9F32-4944C85B85A6", + "id": "BD647EC3-B32A-460E-A6D9-A4A1D808F849" + }, + { + "defKey": "order_update_date", + "defName": "璁㈠崟鏇存柊鏃ユ湡", + "comment": "", + "type": "", + "len": "", + "scale": "", + "primaryKey": false, + "notNull": false, + "autoIncrement": false, + "defaultValue": "", + "hideInGraph": false, + "refDict": "", + "baseType": "FC9790A7-36B8-4A48-8F9A-BC1042BCFE64", + "extProps": {}, + "domain": "54611CCC-CA4B-42E1-9F32-4944C85B85A6", + "id": "E2F64B2D-D193-410E-83F5-7CA29FC2F1C7" + }, + { + "defKey": "order_update_time", + "defName": "璁㈠崟鏇存柊鏃堕棿", + "comment": "", + "type": "", + "len": "", + "scale": "", + "primaryKey": false, + "notNull": false, + "autoIncrement": false, + "defaultValue": "", + "hideInGraph": false, + "refDict": "", + "baseType": "FC9790A7-36B8-4A48-8F9A-BC1042BCFE64", + "extProps": {}, + "domain": "54611CCC-CA4B-42E1-9F32-4944C85B85A6", + "id": "99C90188-1886-45E3-8A66-062CF8672F15" + }, + { + "defKey": "order_update_user", + "defName": "璁㈠崟淇敼浜�", + "comment": "", + "type": "", + "len": "", + "scale": "", + "primaryKey": false, + "notNull": false, + "autoIncrement": false, + "defaultValue": "", + "hideInGraph": false, + "refDict": "", + "baseType": "FC9790A7-36B8-4A48-8F9A-BC1042BCFE64", + "extProps": {}, + "domain": "54611CCC-CA4B-42E1-9F32-4944C85B85A6", + "id": "57BE810E-5423-4B64-B5C4-914D4FC48965" }, { "defKey": "customer_order_model", @@ -11305,7 +11431,7 @@ { "defKey": "work_order_status", "defName": "宸ュ崟鐘舵��", - "comment": "鏂板缓銆佸彂甯冦�侀噸鍙戝竷", + "comment": "鏂板缓銆佸凡鍙戝竷銆侀噸鍙戝竷", "type": "", "len": "", "scale": "", @@ -12063,8 +12189,8 @@ "baseType": "89D69E81-EA34-42EE-9FA2-93B8BD27E098" }, { - "defKey": "del_flag", - "defName": "鍒犻櫎鏍囪", + "defKey": "order_id", + "defName": "鐢熶骇璁㈠崟ID", "comment": "", "type": "", "len": "", @@ -12075,10 +12201,10 @@ "defaultValue": "", "hideInGraph": false, "refDict": "", - "baseType": "1D764C4A-6F9F-421E-B11A-6F3E23B51811", + "baseType": "FC9790A7-36B8-4A48-8F9A-BC1042BCFE64", "extProps": {}, - "domain": "6BC8F04B-6CFA-4995-98D3-318F5CDD774E", - "id": "ABF02681-A2E7-4077-AEEF-7338AF47C4B8" + "domain": "16120F75-6AA7-4483-868D-F07F511BB081", + "id": "FE30BEF4-FD2C-477D-83B9-DAE0546C7D09" }, { "defKey": "material_number", @@ -12125,24 +12251,6 @@ "attr9": "", "id": "CADE8A93-4759-4DA5-8210-942102A9F18B", "baseType": "FC9790A7-36B8-4A48-8F9A-BC1042BCFE64" - }, - { - "defKey": "factory_id", - "defName": "浜х嚎ID(SAP宸ヤ綔涓績)", - "comment": "", - "type": "", - "len": "", - "scale": "", - "primaryKey": false, - "notNull": false, - "autoIncrement": false, - "defaultValue": "", - "hideInGraph": false, - "refDict": "", - "baseType": "FC9790A7-36B8-4A48-8F9A-BC1042BCFE64", - "extProps": {}, - "domain": "9092C4E0-1A54-4859-ABBB-5B62DBC27573", - "id": "F5683C11-B21C-44C4-AF88-2D9A92F7444F" }, { "defKey": "process_code", @@ -12444,24 +12552,6 @@ "baseType": "89D69E81-EA34-42EE-9FA2-93B8BD27E098" }, { - "defKey": "del_flag", - "defName": "鍒犻櫎鏍囪", - "comment": "", - "type": "", - "len": "", - "scale": "", - "primaryKey": false, - "notNull": false, - "autoIncrement": false, - "defaultValue": "", - "hideInGraph": false, - "refDict": "", - "baseType": "1D764C4A-6F9F-421E-B11A-6F3E23B51811", - "extProps": {}, - "domain": "6BC8F04B-6CFA-4995-98D3-318F5CDD774E", - "id": "B43CBCB3-5BC6-4411-9999-C50D2C6A8A5D" - }, - { "defKey": "order_id", "defName": "鐢熸垚璁㈠崟ID", "comment": "", @@ -12534,24 +12624,6 @@ "attr9": "", "id": "5428A165-EF43-40AF-B56F-9F75CBA47A0C", "baseType": "FC9790A7-36B8-4A48-8F9A-BC1042BCFE64" - }, - { - "defKey": "bill_materials_code", - "defName": "BOM浠g爜", - "comment": "", - "type": "", - "len": "", - "scale": "", - "primaryKey": false, - "notNull": false, - "autoIncrement": false, - "defaultValue": "", - "hideInGraph": false, - "refDict": "", - "baseType": "FC9790A7-36B8-4A48-8F9A-BC1042BCFE64", - "extProps": {}, - "domain": "BE09D493-E183-402D-ACC4-EEA21EB35B8E", - "id": "07D7B55E-B88D-4493-B916-987978EA20D1" }, { "defKey": "production_unit", @@ -60923,7 +60995,35 @@ "baseType": "FC9790A7-36B8-4A48-8F9A-BC1042BCFE64" }, { - "defKey": "usage_unit", + "defKey": "production_unit", + "defName": "鍩烘湰鍗曚綅", + "comment": "", + "type": "", + "len": "", + "scale": "", + "primaryKey": false, + "notNull": false, + "autoIncrement": false, + "defaultValue": "", + "hideInGraph": false, + "domain": "54611CCC-CA4B-42E1-9F32-4944C85B85A6", + "refDict": "", + "extProps": {}, + "notes": {}, + "attr1": "", + "attr2": "", + "attr3": "", + "attr4": "", + "attr5": "", + "attr6": "", + "attr7": "", + "attr8": "", + "attr9": "", + "id": "4F81E835-2971-44F0-872E-61BD47417674", + "baseType": "FC9790A7-36B8-4A48-8F9A-BC1042BCFE64" + }, + { + "defKey": "usage_quantity", "defName": "闇�姹傜敤閲�", "comment": "", "type": "", @@ -68317,6 +68417,658 @@ "correlations": [], "indexes": [], "type": "P" + }, + { + "id": "8C08DDB8-C3E9-4FBF-B4CE-EAB9BCFE1E38", + "env": { + "base": { + "nameSpace": "", + "codeRoot": "" + } + }, + "defKey": "sys_api_log", + "defName": "绯荤粺绗笁鏂归泦鎴愭帴鍙f棩蹇�", + "comment": "", + "properties": { + "partitioned by": "(date string)", + "row format delimited": "", + "fields terminated by ','": "", + "collection items terminated by '-'": "", + "map keys terminated by ':'": "", + "store as textfile;": "" + }, + "sysProps": { + "nameTemplate": "{defKey}[{defName}]" + }, + "notes": {}, + "headers": [ + { + "refKey": "hideInGraph", + "hideInGraph": true + }, + { + "refKey": "defKey", + "freeze": false, + "hideInGraph": false + }, + { + "refKey": "defName", + "freeze": false, + "hideInGraph": false + }, + { + "refKey": "primaryKey", + "freeze": false, + "hideInGraph": false + }, + { + "refKey": "notNull", + "freeze": false, + "hideInGraph": true + }, + { + "refKey": "autoIncrement", + "freeze": false, + "hideInGraph": true + }, + { + "refKey": "domain", + "freeze": false, + "hideInGraph": true + }, + { + "refKey": "type", + "freeze": false, + "hideInGraph": false + }, + { + "refKey": "len", + "freeze": false, + "hideInGraph": false + }, + { + "refKey": "scale", + "freeze": false, + "hideInGraph": false + }, + { + "refKey": "comment", + "freeze": false, + "hideInGraph": true + }, + { + "refKey": "refDict", + "freeze": false, + "hideInGraph": true + }, + { + "refKey": "defaultValue", + "freeze": false, + "hideInGraph": true + }, + { + "refKey": "isStandard", + "freeze": false, + "hideInGraph": false + }, + { + "refKey": "uiHint", + "freeze": false, + "hideInGraph": true + }, + { + "refKey": "extProps", + "freeze": false, + "hideInGraph": true + }, + { + "refKey": "attr1", + "freeze": false, + "hideInGraph": true + }, + { + "refKey": "attr2", + "freeze": false, + "hideInGraph": true + }, + { + "refKey": "attr3", + "freeze": false, + "hideInGraph": true + }, + { + "refKey": "attr4", + "freeze": false, + "hideInGraph": true + }, + { + "refKey": "attr5", + "freeze": false, + "hideInGraph": true + }, + { + "refKey": "attr6", + "freeze": false, + "hideInGraph": true + }, + { + "refKey": "attr7", + "freeze": false, + "hideInGraph": true + }, + { + "refKey": "attr8", + "freeze": false, + "hideInGraph": true + }, + { + "refKey": "attr9", + "freeze": false, + "hideInGraph": true + } + ], + "fields": [ + { + "defKey": "id", + "defName": "涓婚敭", + "comment": "", + "type": "", + "len": "", + "scale": "", + "primaryKey": true, + "notNull": true, + "autoIncrement": false, + "defaultValue": "", + "hideInGraph": false, + "refDict": "", + "baseType": "FC9790A7-36B8-4A48-8F9A-BC1042BCFE64", + "extProps": {}, + "domain": "16120F75-6AA7-4483-868D-F07F511BB081", + "id": "493A6ADA-F893-45D2-AC93-D3090DC02B0D" + }, + { + "defKey": "create_by", + "defName": "鍒涘缓浜�", + "comment": "", + "domain": "54611CCC-CA4B-42E1-9F32-4944C85B85A6", + "type": "", + "len": "", + "scale": "", + "primaryKey": false, + "notNull": false, + "autoIncrement": false, + "defaultValue": "", + "hideInGraph": true, + "refDict": "", + "uiHint": "", + "id": "C9EFA288-7FAB-408E-87FB-91A4C08BDF73", + "baseType": "FC9790A7-36B8-4A48-8F9A-BC1042BCFE64" + }, + { + "defKey": "create_time", + "defName": "鍒涘缓鏃堕棿", + "comment": "", + "domain": "7CFFA0D3-6A93-4DDC-BC10-DF21211064DC", + "type": "", + "len": "", + "scale": "", + "primaryKey": false, + "notNull": false, + "autoIncrement": false, + "defaultValue": "", + "hideInGraph": true, + "refDict": "", + "uiHint": "", + "id": "E239E79C-CBF1-42DA-907E-2FCADECD2C67", + "baseType": "89D69E81-EA34-42EE-9FA2-93B8BD27E098" + }, + { + "defKey": "api_category", + "defName": "API鍒嗙被", + "comment": "", + "type": "", + "len": "", + "scale": "", + "primaryKey": false, + "notNull": false, + "autoIncrement": false, + "defaultValue": "", + "hideInGraph": false, + "refDict": "", + "baseType": "FC9790A7-36B8-4A48-8F9A-BC1042BCFE64", + "extProps": {}, + "domain": "73FD2BAD-2358-4336-B96D-45DC897BD792", + "id": "F49D357B-7349-4B9D-9907-191F2F94DA3B" + }, + { + "defKey": "api_name", + "defName": "鎺ュ彛鍚嶇О", + "comment": "", + "type": "", + "len": "", + "scale": "", + "primaryKey": false, + "notNull": false, + "autoIncrement": false, + "defaultValue": "", + "hideInGraph": false, + "refDict": "", + "baseType": "FC9790A7-36B8-4A48-8F9A-BC1042BCFE64", + "extProps": {}, + "domain": "9092C4E0-1A54-4859-ABBB-5B62DBC27573", + "id": "66F55A69-EE62-442E-926D-97695E82BE19" + }, + { + "defKey": "request_time", + "defName": "璇锋眰鏃堕棿", + "comment": "", + "type": "", + "len": "", + "scale": "", + "primaryKey": false, + "notNull": false, + "autoIncrement": false, + "defaultValue": "", + "hideInGraph": false, + "refDict": "", + "baseType": "89D69E81-EA34-42EE-9FA2-93B8BD27E098", + "extProps": {}, + "domain": "7CFFA0D3-6A93-4DDC-BC10-DF21211064DC", + "id": "42B46C10-65A4-410E-A238-3A3F86018945" + }, + { + "defKey": "response_time", + "defName": "鍝嶅簲鏃堕棿", + "comment": "", + "type": "", + "len": "", + "scale": "", + "primaryKey": false, + "notNull": false, + "autoIncrement": false, + "defaultValue": "", + "hideInGraph": false, + "refDict": "", + "baseType": "89D69E81-EA34-42EE-9FA2-93B8BD27E098", + "extProps": {}, + "domain": "7CFFA0D3-6A93-4DDC-BC10-DF21211064DC", + "id": "628E5760-93A0-4779-85A9-C0231AD79EBC" + }, + { + "defKey": "request_method", + "defName": "璇锋眰鏂瑰紡", + "comment": "", + "type": "", + "len": "", + "scale": "", + "primaryKey": false, + "notNull": false, + "autoIncrement": false, + "defaultValue": "", + "hideInGraph": false, + "refDict": "", + "baseType": "FC9790A7-36B8-4A48-8F9A-BC1042BCFE64", + "extProps": {}, + "domain": "73FD2BAD-2358-4336-B96D-45DC897BD792", + "id": "AF639452-207A-474B-9C76-266BDD0F6BA5" + }, + { + "defKey": "request_url", + "defName": "璇锋眰URL", + "comment": "", + "type": "", + "len": "", + "scale": "", + "primaryKey": false, + "notNull": false, + "autoIncrement": false, + "defaultValue": "", + "hideInGraph": false, + "refDict": "", + "baseType": "B17BDED3-085F-40E1-9019-3B79CF2BF075", + "extProps": {}, + "domain": "13DE7063-440C-426F-B1DF-25EC824C6DB8", + "id": "A3AD6177-3EAE-4ADC-BC22-1B29AC035DD1" + }, + { + "defKey": "request_headers", + "defName": "璇锋眰澶�", + "comment": "", + "type": "", + "len": "", + "scale": "", + "primaryKey": false, + "notNull": false, + "autoIncrement": false, + "defaultValue": "", + "hideInGraph": false, + "refDict": "", + "baseType": "B17BDED3-085F-40E1-9019-3B79CF2BF075", + "extProps": {}, + "domain": "13DE7063-440C-426F-B1DF-25EC824C6DB8", + "id": "2BA704F8-36C4-4B4D-BF63-C721376D4B7E" + }, + { + "defKey": "request_body", + "defName": "璇锋眰浣�", + "comment": "", + "type": "", + "len": "", + "scale": "", + "primaryKey": false, + "notNull": false, + "autoIncrement": false, + "defaultValue": "", + "hideInGraph": false, + "refDict": "", + "baseType": "B17BDED3-085F-40E1-9019-3B79CF2BF075", + "extProps": {}, + "domain": "13DE7063-440C-426F-B1DF-25EC824C6DB8", + "id": "4DBE1100-12B3-4CFD-B0B1-4AFE5A9033AB" + }, + { + "defKey": "response_code", + "defName": "鍝嶅簲缂栫爜", + "comment": "", + "type": "", + "len": "", + "scale": "", + "primaryKey": false, + "notNull": false, + "autoIncrement": false, + "defaultValue": "", + "hideInGraph": false, + "refDict": "", + "baseType": "FC9790A7-36B8-4A48-8F9A-BC1042BCFE64", + "extProps": {}, + "domain": "54611CCC-CA4B-42E1-9F32-4944C85B85A6", + "id": "4CD23738-EE0F-4029-9465-9CDF3E7CD461" + }, + { + "defKey": "response_message", + "defName": "鍝嶅簲娑堟伅", + "comment": "", + "type": "", + "len": "", + "scale": "", + "primaryKey": false, + "notNull": false, + "autoIncrement": false, + "defaultValue": "", + "hideInGraph": false, + "refDict": "", + "baseType": "FC9790A7-36B8-4A48-8F9A-BC1042BCFE64", + "extProps": {}, + "domain": "9092C4E0-1A54-4859-ABBB-5B62DBC27573", + "id": "E872F6CA-7D7A-40F1-959D-FD35447BB5A1" + }, + { + "defKey": "response_body", + "defName": "鍝嶅簲浣�", + "comment": "", + "type": "", + "len": "", + "scale": "", + "primaryKey": false, + "notNull": false, + "autoIncrement": false, + "defaultValue": "", + "hideInGraph": false, + "refDict": "", + "baseType": "B17BDED3-085F-40E1-9019-3B79CF2BF075", + "extProps": {}, + "domain": "13DE7063-440C-426F-B1DF-25EC824C6DB8", + "id": "AC48A8A8-E320-4E79-AFA7-4FDB1059961F" + }, + { + "defKey": "request_status", + "defName": "鐘舵��", + "comment": "鎴愬姛銆佸け璐�", + "type": "", + "len": "", + "scale": "", + "primaryKey": false, + "notNull": false, + "autoIncrement": false, + "defaultValue": "", + "hideInGraph": false, + "refDict": "", + "baseType": "1D764C4A-6F9F-421E-B11A-6F3E23B51811", + "extProps": {}, + "domain": "6BC8F04B-6CFA-4995-98D3-318F5CDD774E", + "id": "4CCFBCCD-0681-4B6F-BAE8-624063397C72" + }, + { + "defKey": "method", + "defName": "璋冪敤鏂规硶", + "comment": "", + "type": "", + "len": "", + "scale": "", + "primaryKey": false, + "notNull": false, + "autoIncrement": false, + "defaultValue": "", + "hideInGraph": false, + "refDict": "", + "baseType": "FC9790A7-36B8-4A48-8F9A-BC1042BCFE64", + "extProps": {}, + "domain": "9092C4E0-1A54-4859-ABBB-5B62DBC27573", + "id": "112770C9-963A-40F4-BCDF-289177A84824" + } + ], + "correlations": [], + "indexes": [], + "type": "P" + }, + { + "id": "F7AF7249-4731-4AD6-8945-E47F8C9E475F", + "env": { + "base": { + "nameSpace": "", + "codeRoot": "" + } + }, + "defKey": "base_equipment_factory", + "defName": "璁惧浜х嚎鍏崇郴", + "comment": "", + "properties": { + "partitioned by": "(date string)", + "row format delimited": "", + "fields terminated by ','": "", + "collection items terminated by '-'": "", + "map keys terminated by ':'": "", + "store as textfile;": "" + }, + "sysProps": { + "nameTemplate": "{defKey}[{defName}]" + }, + "notes": {}, + "headers": [ + { + "refKey": "hideInGraph", + "hideInGraph": true + }, + { + "refKey": "defKey", + "freeze": false, + "hideInGraph": false + }, + { + "refKey": "defName", + "freeze": false, + "hideInGraph": false + }, + { + "refKey": "primaryKey", + "freeze": false, + "hideInGraph": false + }, + { + "refKey": "notNull", + "freeze": false, + "hideInGraph": true + }, + { + "refKey": "autoIncrement", + "freeze": false, + "hideInGraph": true + }, + { + "refKey": "domain", + "freeze": false, + "hideInGraph": true + }, + { + "refKey": "type", + "freeze": false, + "hideInGraph": false + }, + { + "refKey": "len", + "freeze": false, + "hideInGraph": false + }, + { + "refKey": "scale", + "freeze": false, + "hideInGraph": false + }, + { + "refKey": "comment", + "freeze": false, + "hideInGraph": true + }, + { + "refKey": "refDict", + "freeze": false, + "hideInGraph": true + }, + { + "refKey": "defaultValue", + "freeze": false, + "hideInGraph": true + }, + { + "refKey": "isStandard", + "freeze": false, + "hideInGraph": false + }, + { + "refKey": "uiHint", + "freeze": false, + "hideInGraph": true + }, + { + "refKey": "extProps", + "freeze": false, + "hideInGraph": true + }, + { + "refKey": "attr1", + "freeze": false, + "hideInGraph": true + }, + { + "refKey": "attr2", + "freeze": false, + "hideInGraph": true + }, + { + "refKey": "attr3", + "freeze": false, + "hideInGraph": true + }, + { + "refKey": "attr4", + "freeze": false, + "hideInGraph": true + }, + { + "refKey": "attr5", + "freeze": false, + "hideInGraph": true + }, + { + "refKey": "attr6", + "freeze": false, + "hideInGraph": true + }, + { + "refKey": "attr7", + "freeze": false, + "hideInGraph": true + }, + { + "refKey": "attr8", + "freeze": false, + "hideInGraph": true + }, + { + "refKey": "attr9", + "freeze": false, + "hideInGraph": true + } + ], + "fields": [ + { + "defKey": "id", + "defName": "涓婚敭", + "comment": "", + "type": "", + "len": "", + "scale": "", + "primaryKey": true, + "notNull": true, + "autoIncrement": false, + "defaultValue": "", + "hideInGraph": false, + "refDict": "", + "baseType": "FC9790A7-36B8-4A48-8F9A-BC1042BCFE64", + "extProps": {}, + "domain": "16120F75-6AA7-4483-868D-F07F511BB081", + "id": "44DE427C-593D-4B26-9234-439856496089" + }, + { + "defKey": "factory_id", + "defName": "浜х嚎ID", + "comment": "", + "type": "", + "len": "", + "scale": "", + "primaryKey": false, + "notNull": false, + "autoIncrement": false, + "defaultValue": "", + "hideInGraph": false, + "refDict": "", + "baseType": "FC9790A7-36B8-4A48-8F9A-BC1042BCFE64", + "extProps": {}, + "domain": "16120F75-6AA7-4483-868D-F07F511BB081", + "id": "0C707EE6-25FD-4491-BC85-E762CBF05A5B" + }, + { + "defKey": "equipment_id", + "defName": "璁惧ID", + "comment": "", + "type": "", + "len": "", + "scale": "", + "primaryKey": false, + "notNull": false, + "autoIncrement": false, + "defaultValue": "", + "hideInGraph": false, + "refDict": "", + "baseType": "FC9790A7-36B8-4A48-8F9A-BC1042BCFE64", + "extProps": {}, + "domain": "16120F75-6AA7-4483-868D-F07F511BB081", + "id": "30FD80BB-8064-4E71-9618-EE8129426849" + } + ], + "correlations": [], + "indexes": [], + "type": "P" } ], "views": [], @@ -69091,7 +69843,8 @@ "ED18EDD7-96F9-4CCA-93F0-633567955063", "ADF40C7F-5C97-4196-BCA7-E780FCC8E2FB", "27A01955-9C87-4E63-9A2A-8B489835879F", - "D36AAD93-CF06-45C1-8058-430304D98601" + "D36AAD93-CF06-45C1-8058-430304D98601", + "8C08DDB8-C3E9-4FBF-B4CE-EAB9BCFE1E38" ], "refViews": [], "refDiagrams": [], @@ -69226,6 +69979,7 @@ "refEntities": [ "79D31715-38CF-4C28-A802-227567445F5C", "8CC17A99-333B-48F4-ABCC-915B4FDF8856", + "F7AF7249-4731-4AD6-8945-E47F8C9E475F", "99C7AF61-E25B-445D-8B46-5BDE45A45605", "CDDBE073-093D-4D6A-AB29-0B3538417EBA", "0CE184D5-6F92-4384-AE88-96C81A581F9E", diff --git a/src/main/java/org/jeecg/codegenerate/JeecgOneUtil.java b/src/main/java/org/jeecg/codegenerate/JeecgOneUtil.java index 3fe39ee..d20e656 100644 --- a/src/main/java/org/jeecg/codegenerate/JeecgOneUtil.java +++ b/src/main/java/org/jeecg/codegenerate/JeecgOneUtil.java @@ -6,10 +6,10 @@ public class JeecgOneUtil { public static void main(String[] args) throws Exception { TableVo tableVo = new TableVo(); - tableVo.setTableName("lsw_material"); - tableVo.setEntityName("LswMaterial"); - tableVo.setEntityPackage("lsw"); - tableVo.setFtlDescription("绾胯竟搴撶墿鏂欎俊鎭�"); + tableVo.setTableName("sys_api_log"); + tableVo.setEntityName("SysApiLog"); + tableVo.setEntityPackage("system"); + tableVo.setFtlDescription("绯荤粺绗笁鏂归泦鎴愭帴鍙f棩蹇�"); new CodeGenerateOne(tableVo).generateCodeFile(null); } } diff --git a/src/main/java/org/jeecg/common/aspect/ApiLogAspect.java b/src/main/java/org/jeecg/common/aspect/ApiLogAspect.java new file mode 100644 index 0000000..9da336c --- /dev/null +++ b/src/main/java/org/jeecg/common/aspect/ApiLogAspect.java @@ -0,0 +1,152 @@ +package org.jeecg.common.aspect; + +import com.alibaba.fastjson.JSONObject; +import com.alibaba.fastjson.parser.Feature; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.sap.conn.jco.*; +import org.aspectj.lang.ProceedingJoinPoint; +import org.aspectj.lang.annotation.Around; +import org.aspectj.lang.annotation.Aspect; +import org.aspectj.lang.annotation.Pointcut; +import org.aspectj.lang.reflect.MethodSignature; +import org.jeecg.common.aspect.annotation.ApiLog; +import org.jeecg.common.constant.ApiLogCategoryEnum; +import org.jeecg.common.exception.JeecgBootException; +import org.jeecg.modules.mdc.util.ThrowableUtil; +import org.jeecg.modules.system.entity.SysApiLog; +import org.jeecg.modules.system.service.ISysApiLogService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import java.lang.reflect.Method; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.Map; + +@Aspect +@Component +public class ApiLogAspect { + @Autowired + private ISysApiLogService apiLogService; + @Autowired + private ObjectMapper objectMapper; + + @Pointcut("@annotation(org.jeecg.common.aspect.annotation.ApiLog)") + public void logPointCut() { + + } + + @Around("logPointCut()") + public Object around(ProceedingJoinPoint point) { + SysApiLog dto = new SysApiLog(); + dto.setRequestTime(new Date()); + //鎵ц鏂规硶 + Object result = null; + try { + result = point.proceed(); + //鎵ц鏃堕暱(姣) + dto.setResponseTime(new Date()); + //淇濆瓨鏃ュ織 + saveApiLog(dto, point, result); + } catch (Throwable e) { + //鎵ц鏃堕暱(姣) + dto.setResponseTime(new Date()); + //淇濆瓨鏃ュ織 + saveErrorLog(dto, point, e); + } + return result; + } + + private void saveApiLog(SysApiLog dto, ProceedingJoinPoint joinPoint, Object result) { + MethodSignature signature = (MethodSignature) joinPoint.getSignature(); + Method method = signature.getMethod(); + + ApiLog syslog = method.getAnnotation(ApiLog.class); + if (syslog != null) { + String apiName = syslog.apiName(); + ApiLogCategoryEnum apiCategory = syslog.apiCategory(); + //娉ㄨВ涓婄殑鎻忚堪,鎿嶄綔鏃ュ織鍐呭 + dto.setApiName(apiName); + dto.setApiCategory(apiCategory.name()); + switch (apiCategory) { + case SAP: + dto.setRequestMethod("RFC"); + if (result instanceof Map) { + Map<String, Object> map = (Map<String, Object>) result; + dto.setResponseCode(map.get("ztype").toString()); + dto.setResponseMessage(map.get("zmess").toString()); + dto.setRequestBody(map.get("importParameters").toString()); + dto.setResponseBody(parseSAPResponseResult(map.get("result"))); + } + break; + case WMS: + dto.setRequestMethod("Webservice"); + break; + case FEI_SHU: + dto.setRequestMethod("Http"); + break; + } + } + + //璇锋眰鐨勬柟娉曞悕 + String className = joinPoint.getTarget().getClass().getName(); + String methodName = signature.getName(); + dto.setMethod(className + "." + methodName + "()"); + dto.setRequestStatus(0); + apiLogService.save(dto); + } + + private void saveErrorLog(SysApiLog dto, ProceedingJoinPoint joinPoint, Throwable e) { + MethodSignature signature = (MethodSignature) joinPoint.getSignature(); + Method method = signature.getMethod(); + + ApiLog syslog = method.getAnnotation(ApiLog.class); + if (syslog != null) { + String apiName = syslog.apiName(); + ApiLogCategoryEnum apiCategory = syslog.apiCategory(); + //娉ㄨВ涓婄殑鎻忚堪,鎿嶄綔鏃ュ織鍐呭 + dto.setApiName(apiName); + dto.setApiCategory(apiCategory.name()); + switch (apiCategory) { + case SAP: + dto.setRequestMethod("RFC"); + break; + case WMS: + dto.setRequestMethod("Webservice"); + break; + case FEI_SHU: + dto.setRequestMethod("Http"); + break; + } + } + + //璇锋眰鐨勬柟娉曞悕 + String className = joinPoint.getTarget().getClass().getName(); + String methodName = signature.getName(); + dto.setMethod(className + "." + methodName + "()"); + dto.setRequestStatus(-1); + dto.setResponseCode("-1"); + dto.setResponseMessage("璇锋眰寮傚父锛岃鏌ョ湅鍝嶅簲浣擄紒"); + dto.setResponseBody(ThrowableUtil.getStackTrace(e)); + apiLogService.save(dto); + } + + private String parseSAPResponseResult(Object result) { + List<JSONObject> items = new ArrayList<>(); + if (result instanceof List) { + List<Object> list = (List<Object>) result; + try { + for (Object obj : list) { + String json = objectMapper.writeValueAsString(obj); + JSONObject item = JSONObject.parseObject(json, Feature.OrderedField); + items.add(item); + } + } catch (JsonProcessingException e) { + throw new JeecgBootException(e); + } + } + return items.toString(); + } +} diff --git a/src/main/java/org/jeecg/common/aspect/annotation/ApiLog.java b/src/main/java/org/jeecg/common/aspect/annotation/ApiLog.java new file mode 100644 index 0000000..c809029 --- /dev/null +++ b/src/main/java/org/jeecg/common/aspect/annotation/ApiLog.java @@ -0,0 +1,22 @@ +package org.jeecg.common.aspect.annotation; + +import org.jeecg.common.constant.ApiLogCategoryEnum; + +import java.lang.annotation.*; + +@Target(ElementType.METHOD) +@Retention(RetentionPolicy.RUNTIME) +@Documented +public @interface ApiLog { + /** + * API鍚嶇О + * @return + */ + String apiName() default ""; + + /** + * API鍒嗙被 + * @return + */ + ApiLogCategoryEnum apiCategory() default ApiLogCategoryEnum.SAP; +} diff --git a/src/main/java/org/jeecg/common/constant/ApiLogCategoryEnum.java b/src/main/java/org/jeecg/common/constant/ApiLogCategoryEnum.java new file mode 100644 index 0000000..28fa6ef --- /dev/null +++ b/src/main/java/org/jeecg/common/constant/ApiLogCategoryEnum.java @@ -0,0 +1,21 @@ +package org.jeecg.common.constant; + +/** + * 绗笁鏂归泦鎴愭帴鍙e鎺ョ被鍨� + */ +public enum ApiLogCategoryEnum { + SAP, //SAP鎺ュ彛瀵规帴 + WMS, //WMS鎺ュ彛瀵规帴 + FEI_SHU, //椋炰功鎺ュ彛瀵规帴 + ; + + public static ApiLogCategoryEnum getInstance(String code) { + ApiLogCategoryEnum[] values = ApiLogCategoryEnum.values(); + for (ApiLogCategoryEnum value : values) { + if (value.name().equals(code)) { + return value; + } + } + return null; + } +} diff --git a/src/main/java/org/jeecg/modules/base/mapper/FactoryMapper.java b/src/main/java/org/jeecg/modules/base/mapper/FactoryMapper.java index 893ab77..36d7a59 100644 --- a/src/main/java/org/jeecg/modules/base/mapper/FactoryMapper.java +++ b/src/main/java/org/jeecg/modules/base/mapper/FactoryMapper.java @@ -3,6 +3,7 @@ import java.util.List; import org.apache.ibatis.annotations.Param; +import org.apache.ibatis.annotations.Select; import org.jeecg.modules.base.entity.Factory; import com.baomidou.mybatisplus.core.mapper.BaseMapper; @@ -14,4 +15,14 @@ */ public interface FactoryMapper extends BaseMapper<Factory> { + /** + * 鏍规嵁id涓嬬骇浜х嚎 + */ + @Select("SELECT * FROM base_factory where del_flag ='0' AND parent_id = #{parentId,jdbcType=VARCHAR}") + List<Factory> queryFacByPid(@Param("parentId") String parentId); + + /** + * 閫掑綊鏌ヨ鎵�鏈夊瓙鑺傜偣 + */ + List<String> recursionChildren(@Param("factoryId") String factoryId); } diff --git a/src/main/java/org/jeecg/modules/base/mapper/UserFactoryMapper.java b/src/main/java/org/jeecg/modules/base/mapper/UserFactoryMapper.java index f1253a4..f897d00 100644 --- a/src/main/java/org/jeecg/modules/base/mapper/UserFactoryMapper.java +++ b/src/main/java/org/jeecg/modules/base/mapper/UserFactoryMapper.java @@ -14,4 +14,8 @@ */ public interface UserFactoryMapper extends BaseMapper<UserFactory> { + /** + * 鏍规嵁鎸囧畾鐢ㄦ埛id鏌ヨ浜х嚎id闆嗗悎 + */ + List<String> queryFactoryIdsByUserId(@Param("userId") String userId); } diff --git a/src/main/java/org/jeecg/modules/base/mapper/xml/FactoryMapper.xml b/src/main/java/org/jeecg/modules/base/mapper/xml/FactoryMapper.xml index 0832f10..b818615 100644 --- a/src/main/java/org/jeecg/modules/base/mapper/xml/FactoryMapper.xml +++ b/src/main/java/org/jeecg/modules/base/mapper/xml/FactoryMapper.xml @@ -2,4 +2,22 @@ <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <mapper namespace="org.jeecg.modules.base.mapper.FactoryMapper"> + <select id="recursionChildren" resultType="java.lang.String"> + WITH temp ( id ) AS ( + SELECT + id + FROM + base_factory + WHERE + id = #{ factoryId } UNION ALL + SELECT + a.id + FROM + base_factory a + INNER JOIN temp ON a.parent_id = temp.id + ) SELECT + * + FROM + temp + </select> </mapper> \ No newline at end of file diff --git a/src/main/java/org/jeecg/modules/base/mapper/xml/UserFactoryMapper.xml b/src/main/java/org/jeecg/modules/base/mapper/xml/UserFactoryMapper.xml index a1118b4..4dc2b30 100644 --- a/src/main/java/org/jeecg/modules/base/mapper/xml/UserFactoryMapper.xml +++ b/src/main/java/org/jeecg/modules/base/mapper/xml/UserFactoryMapper.xml @@ -2,4 +2,8 @@ <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <mapper namespace="org.jeecg.modules.base.mapper.UserFactoryMapper"> + <select id="queryFactoryIdsByUserId" resultType="java.lang.String"> + SELECT factory_id FROM base_user_factory WHERE user_id = #{userId} + </select> + </mapper> \ No newline at end of file diff --git a/src/main/java/org/jeecg/modules/base/service/IFactoryService.java b/src/main/java/org/jeecg/modules/base/service/IFactoryService.java index 5ac34ff..e89a234 100644 --- a/src/main/java/org/jeecg/modules/base/service/IFactoryService.java +++ b/src/main/java/org/jeecg/modules/base/service/IFactoryService.java @@ -38,4 +38,11 @@ * 鏌ヨ鎵�鏈塮actoryId淇℃伅,骞跺垎鑺傜偣杩涜鏄剧ず */ List<FactoryIdModel> queryFactoryIdTreeList(); + + /** + * 鑾峰彇涓嬬骇浜х嚎 + */ + List<Factory> queryFacByPid(String pid); + + List<String> recursionChildren(String factoryId); } diff --git a/src/main/java/org/jeecg/modules/base/service/IUserFactoryService.java b/src/main/java/org/jeecg/modules/base/service/IUserFactoryService.java index 9c3b490..0b47eed 100644 --- a/src/main/java/org/jeecg/modules/base/service/IUserFactoryService.java +++ b/src/main/java/org/jeecg/modules/base/service/IUserFactoryService.java @@ -18,4 +18,9 @@ * 鏍规嵁鎸囧畾鐢ㄦ埛id鏌ヨ浜х嚎淇℃伅 */ List<FactoryIdModel> queryFactoryIdsOfUser(String userId); + + /** + * 鏍规嵁鎸囧畾鐢ㄦ埛id鏌ヨ浜х嚎id闆嗗悎 + */ + List<String> queryFactoryIdsByUserId(String userId); } diff --git a/src/main/java/org/jeecg/modules/base/service/impl/FactoryServiceImpl.java b/src/main/java/org/jeecg/modules/base/service/impl/FactoryServiceImpl.java index b68cd8b..1464018 100644 --- a/src/main/java/org/jeecg/modules/base/service/impl/FactoryServiceImpl.java +++ b/src/main/java/org/jeecg/modules/base/service/impl/FactoryServiceImpl.java @@ -24,6 +24,7 @@ import javax.annotation.Resource; import java.util.ArrayList; +import java.util.Collections; import java.util.List; /** @@ -159,6 +160,22 @@ } /** + * 鏍规嵁id鏌ヨ涓嬬骇浜х嚎 + */ + @Override + public List<Factory> queryFacByPid(String pid) { + return this.baseMapper.queryFacByPid(pid); + } + + /** + * 閫掑綊鏌ヨ鎵�鏈夊瓙鑺傜偣id + */ + @Override + public List<String> recursionChildren(String factoryId) { + return this.baseMapper.recursionChildren(factoryId); + } + + /** * 鎵撳紑 鐖惰妭鐐� 鍙� 浠ヤ笂鐨刴dc鏍囪 * @param parentId */ diff --git a/src/main/java/org/jeecg/modules/base/service/impl/UserFactoryServiceImpl.java b/src/main/java/org/jeecg/modules/base/service/impl/UserFactoryServiceImpl.java index 38addc4..d05ba52 100644 --- a/src/main/java/org/jeecg/modules/base/service/impl/UserFactoryServiceImpl.java +++ b/src/main/java/org/jeecg/modules/base/service/impl/UserFactoryServiceImpl.java @@ -13,6 +13,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import java.util.ArrayList; +import java.util.Collections; import java.util.List; /** @@ -56,4 +57,12 @@ } return null; } + + /** + * 鏍规嵁鎸囧畾鐢ㄦ埛id鏌ヨ浜х嚎id闆嗗悎 + */ + @Override + public List<String> queryFactoryIdsByUserId(String userId) { + return this.baseMapper.queryFactoryIdsByUserId(userId); + } } diff --git a/src/main/java/org/jeecg/modules/mdc/controller/MdcEfficiencyReportController.java b/src/main/java/org/jeecg/modules/mdc/controller/MdcEfficiencyReportController.java index 732f2f3..e156aea 100644 --- a/src/main/java/org/jeecg/modules/mdc/controller/MdcEfficiencyReportController.java +++ b/src/main/java/org/jeecg/modules/mdc/controller/MdcEfficiencyReportController.java @@ -112,40 +112,40 @@ return Result.OK(result); } - @ApiOperation(value = "璁惧鏁堢巼鎶ヨ〃-缁煎悎鍒╃敤鐜囩粺璁″垎鏋�", notes = "璁惧鏁堢巼鎶ヨ〃-缁煎悎鍒╃敤鐜囩粺璁″垎鏋�") - @GetMapping("/comprehensiveRateAnalyze") - public Result<?> comprehensiveRateAnalyze(EquEffVo vo) { - LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal(); - String userId = user.getId(); - Map<String, Object> result = mdcEfficiencyReportService.comprehensiveRateAnalyze(userId, vo); - return Result.OK(result); - } - - @ApiOperation(value = "璁惧鏁堢巼鎶ヨ〃-鐝粍缁煎悎鍒╃敤鐜囩粺璁″垎鏋�", notes = "璁惧鏁堢巼鎶ヨ〃-缁煎悎鍒╃敤鐜囩粺璁″垎鏋�") - @GetMapping("/teamEfficiencyAnalyzeByMonth") - public Result<?> teamEfficiencyAnalyzeByMonth(EquEffVo equEffVo) { - LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal(); - String userId = user.getId(); - Map<String, Object> result = mdcEfficiencyReportService.teamEfficiencyAnalyzeByMonth(userId, equEffVo); - return Result.OK(result); - } - - @ApiOperation(value = "璁惧鏁堢巼鎶ヨ〃-閰嶉�佸皬缁勭淮搴﹀悇鐝粍鏈堣澶囧埄鐢ㄥ垎甯�", notes = "璁惧鏁堢巼鎶ヨ〃-閰嶉�佸皬缁勭淮搴﹀悇鐝粍鏈堣澶囧埄鐢ㄥ垎甯�") - @GetMapping("/teamEquipmentEfficiencyAnalyze") - public Result<?> teamEquipmentEfficiencyAnalyze(EquEffVo equEffVo) { - LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal(); - String userId = user.getId(); - Map<String, Object> result = mdcEfficiencyReportService.teamEquipmentEfficiencyAnalyze(userId, equEffVo); - return Result.OK(result); - } - - @ApiOperation(value = "璁惧鏁堢巼鎶ヨ〃-璁惧缁村害鍚勭彮缁勬湀璁惧鍒╃敤鍒嗗竷", notes = "璁惧鏁堢巼鎶ヨ〃-璁惧缁村害鍚勭彮缁勬湀璁惧鍒╃敤鍒嗗竷") - @GetMapping("/equipmentEfficiencyAnalyze") - public Result<?> equipmentEfficiencyAnalyze(EquEffVo equEffVo) { - LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal(); - String userId = user.getId(); - Map<String, Object> result = mdcEfficiencyReportService.equipmentEfficiencyAnalyze(userId, equEffVo); - return Result.OK(result); - } +// @ApiOperation(value = "璁惧鏁堢巼鎶ヨ〃-缁煎悎鍒╃敤鐜囩粺璁″垎鏋�", notes = "璁惧鏁堢巼鎶ヨ〃-缁煎悎鍒╃敤鐜囩粺璁″垎鏋�") +// @GetMapping("/comprehensiveRateAnalyze") +// public Result<?> comprehensiveRateAnalyze(EquEffVo vo) { +// LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal(); +// String userId = user.getId(); +// Map<String, Object> result = mdcEfficiencyReportService.comprehensiveRateAnalyze(userId, vo); +// return Result.OK(result); +// } +// +// @ApiOperation(value = "璁惧鏁堢巼鎶ヨ〃-鐝粍缁煎悎鍒╃敤鐜囩粺璁″垎鏋�", notes = "璁惧鏁堢巼鎶ヨ〃-缁煎悎鍒╃敤鐜囩粺璁″垎鏋�") +// @GetMapping("/teamEfficiencyAnalyzeByMonth") +// public Result<?> teamEfficiencyAnalyzeByMonth(EquEffVo equEffVo) { +// LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal(); +// String userId = user.getId(); +// Map<String, Object> result = mdcEfficiencyReportService.teamEfficiencyAnalyzeByMonth(userId, equEffVo); +// return Result.OK(result); +// } +// +// @ApiOperation(value = "璁惧鏁堢巼鎶ヨ〃-閰嶉�佸皬缁勭淮搴﹀悇鐝粍鏈堣澶囧埄鐢ㄥ垎甯�", notes = "璁惧鏁堢巼鎶ヨ〃-閰嶉�佸皬缁勭淮搴﹀悇鐝粍鏈堣澶囧埄鐢ㄥ垎甯�") +// @GetMapping("/teamEquipmentEfficiencyAnalyze") +// public Result<?> teamEquipmentEfficiencyAnalyze(EquEffVo equEffVo) { +// LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal(); +// String userId = user.getId(); +// Map<String, Object> result = mdcEfficiencyReportService.teamEquipmentEfficiencyAnalyze(userId, equEffVo); +// return Result.OK(result); +// } +// +// @ApiOperation(value = "璁惧鏁堢巼鎶ヨ〃-璁惧缁村害鍚勭彮缁勬湀璁惧鍒╃敤鍒嗗竷", notes = "璁惧鏁堢巼鎶ヨ〃-璁惧缁村害鍚勭彮缁勬湀璁惧鍒╃敤鍒嗗竷") +// @GetMapping("/equipmentEfficiencyAnalyze") +// public Result<?> equipmentEfficiencyAnalyze(EquEffVo equEffVo) { +// LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal(); +// String userId = user.getId(); +// Map<String, Object> result = mdcEfficiencyReportService.equipmentEfficiencyAnalyze(userId, equEffVo); +// return Result.OK(result); +// } } diff --git a/src/main/java/org/jeecg/modules/mdc/controller/MdcEquipmentController.java b/src/main/java/org/jeecg/modules/mdc/controller/MdcEquipmentController.java index 13fc9dd..7b72e9e 100644 --- a/src/main/java/org/jeecg/modules/mdc/controller/MdcEquipmentController.java +++ b/src/main/java/org/jeecg/modules/mdc/controller/MdcEquipmentController.java @@ -13,10 +13,12 @@ import org.jeecg.common.constant.CommonConstant; import org.jeecg.common.system.base.controller.JeecgController; import org.jeecg.common.system.vo.LoginUser; +import org.jeecg.modules.base.model.FactoryIdModel; import org.jeecg.modules.mdc.entity.MdcEquipment; import org.jeecg.modules.mdc.entity.MdcEquipmentMonitor; import org.jeecg.modules.mdc.model.MdcEquipmentTree; import org.jeecg.modules.mdc.model.ProductionIdModel; +import org.jeecg.modules.mdc.service.IFactoryEquipmentService; import org.jeecg.modules.mdc.service.IMdcEquipmentDepartService; import org.jeecg.modules.mdc.service.IMdcEquipmentService; import org.jeecg.modules.mdc.service.IMdcProductionEquipmentService; @@ -55,7 +57,10 @@ private IMdcEquipmentDepartService mdcEquipmentDepartService; @Resource - private IMdcProductionEquipmentService mdcProductionEquipmentService; + private IFactoryEquipmentService factoryEquipmentService; + +// @Resource +// private IMdcProductionEquipmentService mdcProductionEquipmentService; /** * 鍒嗛〉鍒楄〃鏌ヨ @@ -203,34 +208,34 @@ return Result.OK("鎵归噺绉婚櫎鎴愬姛锛�"); } - /** - * 鎵归噺绉婚櫎浜х嚎鍜岃澶囧叧绯� - */ - @AutoLog(value = "璁惧浜х嚎琛�-鎵归噺绉婚櫎浜х嚎鍜岃澶囧叧绯�") - @ApiOperation(value = "璁惧浜х嚎琛�-鎵归噺绉婚櫎浜х嚎鍜岃澶囧叧绯�", notes = "璁惧浜х嚎琛�-鎵归噺绉婚櫎浜х嚎鍜岃澶囧叧绯�") - @PostMapping(value = "/removeEquipmentsForProduction") - public Result<?> removeEquipmentsForProduction(@RequestParam(name = "productionId", required = true) String productionId, - @RequestParam(name = "equipmentIds", required = true) String equipmentIds) { - if (StringUtils.isNotBlank(productionId) && StringUtils.isNotBlank(equipmentIds)) { - List<String> equipmentIdList = Arrays.asList(equipmentIds.split(",")); - mdcEquipmentService.removeEquipmentsForProduction(productionId, equipmentIdList); - } - return Result.OK("鎵归噺绉婚櫎鎴愬姛锛�"); - } +// /** +// * 鎵归噺绉婚櫎浜х嚎鍜岃澶囧叧绯� +// */ +// @AutoLog(value = "璁惧浜х嚎琛�-鎵归噺绉婚櫎浜х嚎鍜岃澶囧叧绯�") +// @ApiOperation(value = "璁惧浜х嚎琛�-鎵归噺绉婚櫎浜х嚎鍜岃澶囧叧绯�", notes = "璁惧浜х嚎琛�-鎵归噺绉婚櫎浜х嚎鍜岃澶囧叧绯�") +// @PostMapping(value = "/removeEquipmentsForProduction") +// public Result<?> removeEquipmentsForProduction(@RequestParam(name = "productionId", required = true) String productionId, +// @RequestParam(name = "equipmentIds", required = true) String equipmentIds) { +// if (StringUtils.isNotBlank(productionId) && StringUtils.isNotBlank(equipmentIds)) { +// List<String> equipmentIdList = Arrays.asList(equipmentIds.split(",")); +// mdcEquipmentService.removeEquipmentsForProduction(productionId, equipmentIdList); +// } +// return Result.OK("鎵归噺绉婚櫎鎴愬姛锛�"); +// } - /** - * 绉婚櫎浜х嚎鍜岃澶囧叧绯� - */ - @AutoLog(value = "璁惧浜х嚎琛�-绉婚櫎浜х嚎鍜岃澶囧叧绯�") - @ApiOperation(value = "璁惧浜х嚎琛�-绉婚櫎浜х嚎鍜岃澶囧叧绯�", notes = "璁惧浜х嚎琛�-绉婚櫎浜х嚎鍜岃澶囧叧绯�") - @PostMapping(value = "/removeEquipmentForProduction") - public Result<?> removeEquipmentForProduction(@RequestParam(name = "productionId", required = true) String productionId, - @RequestParam(name = "equipmentId", required = true) String equipmentId) { - if (StringUtils.isNotBlank(productionId) && StringUtils.isNotBlank(equipmentId)) { - mdcEquipmentService.removeEquipmentForProduction(productionId, equipmentId); - } - return Result.OK("绉婚櫎鎴愬姛锛�"); - } +// /** +// * 绉婚櫎浜х嚎鍜岃澶囧叧绯� +// */ +// @AutoLog(value = "璁惧浜х嚎琛�-绉婚櫎浜х嚎鍜岃澶囧叧绯�") +// @ApiOperation(value = "璁惧浜х嚎琛�-绉婚櫎浜х嚎鍜岃澶囧叧绯�", notes = "璁惧浜х嚎琛�-绉婚櫎浜х嚎鍜岃澶囧叧绯�") +// @PostMapping(value = "/removeEquipmentForProduction") +// public Result<?> removeEquipmentForProduction(@RequestParam(name = "productionId", required = true) String productionId, +// @RequestParam(name = "equipmentId", required = true) String equipmentId) { +// if (StringUtils.isNotBlank(productionId) && StringUtils.isNotBlank(equipmentId)) { +// mdcEquipmentService.removeEquipmentForProduction(productionId, equipmentId); +// } +// return Result.OK("绉婚櫎鎴愬姛锛�"); +// } /** * 娣诲姞 @@ -244,7 +249,7 @@ public Result<MdcEquipment> add(@RequestBody MdcEquipment mdcEquipment) { Result<MdcEquipment> result = new Result<>(); String selectedDeparts = mdcEquipment.getSelectedDeparts(); - String selectedProduction = mdcEquipment.getSelectedProduction(); + String selectedProduction = mdcEquipment.getSelectedFactory(); mdcEquipment.setEquipmentStatus(CommonConstant.STATUS_NORMAL); try { mdcEquipmentService.saveMdcEquipment(mdcEquipment, selectedDeparts, selectedProduction); @@ -367,11 +372,11 @@ */ @AutoLog(value = "璁惧琛�-鏌ヨ鎸囧畾璁惧鍜屼骇绾垮叧鑱旂殑鏁版嵁") @ApiOperation(value = "璁惧琛�-鏌ヨ鎸囧畾璁惧鍜屼骇绾垮叧鑱旂殑鏁版嵁", notes = "璁惧琛�-鏌ヨ鎸囧畾璁惧鍜屼骇绾垮叧鑱旂殑鏁版嵁") - @GetMapping(value = "/equipmentProductionList") - public Result<List<ProductionIdModel>> getEquipmentProductionList(@RequestParam(name = "equipmentId", required = true) String equipmentId) { - Result<List<ProductionIdModel>> result = new Result<>(); + @GetMapping(value = "/equipmentFactoryList") + public Result<List<FactoryIdModel>> equipmentFactoryList(@RequestParam(name = "equipmentId", required = true) String equipmentId) { + Result<List<FactoryIdModel>> result = new Result<>(); try { - List<ProductionIdModel> proIdModelList = this.mdcProductionEquipmentService.queryProductionIdsOfEquipment(equipmentId); + List<FactoryIdModel> proIdModelList = this.factoryEquipmentService.queryFactoryIdsOfEquipment(equipmentId); if (proIdModelList != null && !proIdModelList.isEmpty()) { result.setSuccess(true); result.setMessage("鏌ユ壘鎴愬姛"); @@ -388,6 +393,33 @@ return result; } } + +// /** +// * 鏌ヨ鎸囧畾璁惧鍜屼骇绾垮叧鑱旂殑鏁版嵁 +// */ +// @AutoLog(value = "璁惧琛�-鏌ヨ鎸囧畾璁惧鍜屼骇绾垮叧鑱旂殑鏁版嵁") +// @ApiOperation(value = "璁惧琛�-鏌ヨ鎸囧畾璁惧鍜屼骇绾垮叧鑱旂殑鏁版嵁", notes = "璁惧琛�-鏌ヨ鎸囧畾璁惧鍜屼骇绾垮叧鑱旂殑鏁版嵁") +// @GetMapping(value = "/equipmentProductionList") +// public Result<List<ProductionIdModel>> getEquipmentProductionList(@RequestParam(name = "equipmentId", required = true) String equipmentId) { +// Result<List<ProductionIdModel>> result = new Result<>(); +// try { +// List<ProductionIdModel> proIdModelList = this.mdcProductionEquipmentService.queryProductionIdsOfEquipment(equipmentId); +// if (proIdModelList != null && !proIdModelList.isEmpty()) { +// result.setSuccess(true); +// result.setMessage("鏌ユ壘鎴愬姛"); +// result.setResult(proIdModelList); +// } else { +// result.setSuccess(false); +// result.setMessage("鏌ユ壘澶辫触"); +// } +// return result; +// } catch (Exception e) { +// log.error(e.getMessage(), e); +// result.setSuccess(false); +// result.setMessage("鏌ユ壘杩囩▼涓嚭鐜颁簡寮傚父: " + e.getMessage()); +// return result; +// } +// } /** * 鍔犺浇閮ㄩ棬璁惧鏍� @@ -416,6 +448,26 @@ @ApiOperation(value = "璁惧琛�-鍔犺浇浜х嚎璁惧鏍�", notes = "璁惧琛�-鍔犺浇浜х嚎璁惧鏍�") @GetMapping(value = "/queryTreeListByProduction") public Result<List<MdcEquipmentTree>> queryTreeListByProduction() { + Result<List<MdcEquipmentTree>> result = new Result<>(); + LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal(); + String userId = user.getId(); + try { + List<MdcEquipmentTree> mdcEquipmentTreeList = mdcEquipmentService.loadTreeListByProduction(userId); + result.setSuccess(true); + result.setResult(mdcEquipmentTreeList); + } catch (Exception e) { + log.error(e.getMessage(), e); + } + return result; + } + + /** + * 鍔犺浇浜х嚎璁惧鏍� + */ + @AutoLog(value = "璁惧琛�-鍔犺浇浜х嚎璁惧鏍�") + @ApiOperation(value = "璁惧琛�-鍔犺浇浜х嚎璁惧鏍�", notes = "璁惧琛�-鍔犺浇浜х嚎璁惧鏍�") + @GetMapping(value = "/queryTreeListByFactory") + public Result<List<MdcEquipmentTree>> queryTreeListByFactory() { Result<List<MdcEquipmentTree>> result = new Result<>(); LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal(); String userId = user.getId(); @@ -537,18 +589,18 @@ } - @AutoLog(value = "璁惧琛�-閫氳繃杞﹂棿ids鑾峰彇璁惧鏍�") - @ApiOperation(value = "璁惧琛�-閫氳繃杞﹂棿ids鑾峰彇璁惧鏍�", notes = "璁惧琛�-閫氳繃杞﹂棿ids鑾峰彇璁惧鏍�") - @GetMapping(value = "/loadTreeListByProductionIds") - public Result<?> loadTreeListByProductionIds(@RequestParam(name = "ids", required = true) String ids) { - Result<List<MdcEquipmentTree>> result = new Result<>(); - try { - List<MdcEquipmentTree> mdcEquipmentTreeList = mdcEquipmentService.loadTreeListByProductionIds(ids); - result.setSuccess(true); - result.setResult(mdcEquipmentTreeList); - } catch (Exception e) { - log.error(e.getMessage(), e); - } - return result; - } +// @AutoLog(value = "璁惧琛�-閫氳繃杞﹂棿ids鑾峰彇璁惧鏍�") +// @ApiOperation(value = "璁惧琛�-閫氳繃杞﹂棿ids鑾峰彇璁惧鏍�", notes = "璁惧琛�-閫氳繃杞﹂棿ids鑾峰彇璁惧鏍�") +// @GetMapping(value = "/loadTreeListByProductionIds") +// public Result<?> loadTreeListByProductionIds(@RequestParam(name = "ids", required = true) String ids) { +// Result<List<MdcEquipmentTree>> result = new Result<>(); +// try { +// List<MdcEquipmentTree> mdcEquipmentTreeList = mdcEquipmentService.loadTreeListByProductionIds(ids); +// result.setSuccess(true); +// result.setResult(mdcEquipmentTreeList); +// } catch (Exception e) { +// log.error(e.getMessage(), e); +// } +// return result; +// } } diff --git a/src/main/java/org/jeecg/modules/mdc/controller/MdcHomeController.java b/src/main/java/org/jeecg/modules/mdc/controller/MdcHomeController.java deleted file mode 100644 index a12f3d8..0000000 --- a/src/main/java/org/jeecg/modules/mdc/controller/MdcHomeController.java +++ /dev/null @@ -1,278 +0,0 @@ -package org.jeecg.modules.mdc.controller; - -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.baomidou.mybatisplus.core.toolkit.StringUtils; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import lombok.extern.slf4j.Slf4j; -import org.apache.shiro.SecurityUtils; -import org.jeecg.common.api.vo.Result; -import org.jeecg.common.constant.CommonConstant; -import org.jeecg.common.system.vo.LoginUser; -import org.jeecg.modules.mdc.constant.MdcConstant; -import org.jeecg.modules.mdc.dto.MdcEquipmentDto; -import org.jeecg.modules.mdc.entity.MdcEquipment; -import org.jeecg.modules.mdc.entity.MdcFeedback; -import org.jeecg.modules.mdc.entity.MdcOverallEquipmentEfficiency; -import org.jeecg.modules.mdc.service.IMdcHomeService; -import org.jeecg.modules.mdc.service.IMdcProductionService; -import org.jeecg.modules.mdc.vo.MdcCommonVo; -import org.jeecg.modules.mdc.vo.MdcHomeEfficiencyVo; -import org.jeecg.modules.mdc.entity.MdcProduction; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.Resource; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -/** - * @author Lius - * @Description: MDC棣栭〉鎺ュ彛 - * @date 2024/3/13 14:27 - */ -@Slf4j -@Api(tags = "MDC棣栭〉鎺ュ彛") -@RestController -@RequestMapping("/mdc/home") -public class MdcHomeController { - - @Resource - private IMdcProductionService mdcProductionService; - - @Resource - private IMdcHomeService mdcHomeService; - - @ApiOperation(value = "MDC棣栭〉鎺ュ彛-璁惧杩愯鐘舵�佺粺璁�", notes = "MDC棣栭〉鎺ュ彛-璁惧杩愯鐘舵�佺粺璁�") - @GetMapping("/equipmentStatusStatistics") - public Result<?> equipmentStatusStatistics(String productionCode) { - LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal(); - Integer userType = user.getUserType(); - String userId = user.getId(); - String key = ""; - if (StringUtils.isNotBlank(productionCode)) { - //鍘傚尯/宸ユ - MdcProduction mdcProduction = mdcProductionService.getOne(new LambdaQueryWrapper<MdcProduction>().eq(MdcProduction::getProductionCode, productionCode).eq(MdcProduction::getDelFlag, CommonConstant.DEL_FLAG_0.toString())); - key = mdcProduction.getId(); - } else { - //鍒ゆ柇鏄叕鍙哥骇杩樻槸鍘傚尯 - MdcProduction mdcProduction = mdcProductionService.getOne(new LambdaQueryWrapper<MdcProduction>().eq(MdcProduction::getParentId, "")); - if (userType.equals(MdcConstant.USER_TYPE_4)) { - //鍏徃 - key = mdcProduction.getId(); - } else if (userType.equals(MdcConstant.USER_TYPE_3)) { - //鍘傚尯 - key = mdcProductionService.findFirstProduction(userId, mdcProduction.getId()); - } else if (userType.equals(MdcConstant.USER_TYPE_2)) { - //宸ユ 鏌ヨ鐢ㄦ埛鎷ユ湁鐨勫伐娈垫潈闄� - key = mdcProductionService.findThreeProductionId(userId); - } - } - List<MdcCommonVo> resultMap = mdcHomeService.getEquipmentStatusStatistics(userId, key); - Map<String, Object> map = new HashMap<>(); - map.put("list", resultMap); - map.put("productionId", key); - return Result.OK(map); - } - - @ApiOperation(value = "MDC棣栭〉鎺ュ彛-璁惧鍒╃敤鐜囩粺璁�(鏄ㄦ棩)", notes = "MDC棣栭〉鎺ュ彛-璁惧杩愯鐘舵�佺粺璁�(鏄ㄦ棩)") - @GetMapping("/equipmentUtilizationStatistics") - public Result<?> equipmentUtilizationStatistics(String productionCode) { - LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal(); - Integer userType = user.getUserType(); - String userId = user.getId(); - String key = ""; - if (StringUtils.isNotBlank(productionCode)) { - //鍘傚尯 - MdcProduction mdcProduction = mdcProductionService.getOne(new LambdaQueryWrapper<MdcProduction>().eq(MdcProduction::getProductionCode, productionCode).eq(MdcProduction::getDelFlag, CommonConstant.DEL_FLAG_0.toString())); - key = mdcProduction.getId(); - } else { - //鍒ゆ柇鏄叕鍙哥骇杩樻槸鍘傚尯 - MdcProduction mdcProduction = mdcProductionService.getOne(new LambdaQueryWrapper<MdcProduction>().eq(MdcProduction::getParentId, "")); - if (userType.equals(MdcConstant.USER_TYPE_4)) { - //鍏徃 - key = mdcProduction.getId(); - } else if (userType.equals(MdcConstant.USER_TYPE_3)) { - //鍘傚尯 - key = mdcProductionService.findFirstProduction(userId, mdcProduction.getId()); - } - } - List<MdcCommonVo> result = mdcHomeService.getEquipmentUtilizationStatistics(userId, key); - return Result.OK(result); - } - - @ApiOperation(value = "MDC棣栭〉鎺ュ彛-璁惧OEE缁熻(涓婃湀)", notes = "MDC棣栭〉鎺ュ彛-璁惧OEE缁熻(涓婃湀)") - @GetMapping("/equipmentOEEStatistics") - public Result<?> equipmentOEEStatistics(String productionCode) { - LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal(); - Integer userType = user.getUserType(); - String userId = user.getId(); - String key = ""; - if (StringUtils.isNotBlank(productionCode)) { - //鍘傚尯 - MdcProduction mdcProduction = mdcProductionService.getOne(new LambdaQueryWrapper<MdcProduction>().eq(MdcProduction::getProductionCode, productionCode).eq(MdcProduction::getDelFlag, CommonConstant.DEL_FLAG_0.toString())); - key = mdcProduction.getId(); - } else { - //鍒ゆ柇鏄叕鍙哥骇杩樻槸鍘傚尯 - MdcProduction mdcProduction = mdcProductionService.getOne(new LambdaQueryWrapper<MdcProduction>().eq(MdcProduction::getParentId, "")); - if (userType.equals(MdcConstant.USER_TYPE_4)) { - //鍏徃 - key = mdcProduction.getId(); - } else if (userType.equals(MdcConstant.USER_TYPE_3)) { - //鍘傚尯 - key = mdcProductionService.findFirstProduction(userId, mdcProduction.getId()); - } - } - List<MdcCommonVo> result = mdcHomeService.getEquipmentOeeStatistics(userId, key); - return Result.OK(result); - } - - @ApiOperation(value = "MDC棣栭〉鎺ュ彛-璁惧OEE鍜屽埄鐢ㄧ巼缁熻鏌辩姸鍥�", notes = "MDC棣栭〉鎺ュ彛-璁惧OEE鍜屽埄鐢ㄧ巼缁熻鏌辩姸鍥�") - @GetMapping("/equipmentMonthStatistics") - public Result<?> equipmentMonthStatistics(String productionCode) { - LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal(); - Integer userType = user.getUserType(); - String userId = user.getId(); - String key = ""; - if (StringUtils.isNotBlank(productionCode)) { - //鍘傚尯 - MdcProduction mdcProduction = mdcProductionService.getOne(new LambdaQueryWrapper<MdcProduction>().eq(MdcProduction::getProductionCode, productionCode).eq(MdcProduction::getDelFlag, CommonConstant.DEL_FLAG_0.toString())); - key = mdcProduction.getId(); - } else { - //鍒ゆ柇鏄叕鍙哥骇杩樻槸鍘傚尯 - MdcProduction mdcProduction = mdcProductionService.getOne(new LambdaQueryWrapper<MdcProduction>().eq(MdcProduction::getParentId, "")); - if (userType.equals(MdcConstant.USER_TYPE_4)) { - //鍏徃 - key = mdcProduction.getId(); - } else if (userType.equals(MdcConstant.USER_TYPE_3)) { - //鍘傚尯 - key = mdcProductionService.findFirstProduction(userId, mdcProduction.getId()); - } - } - Map<String, Object> result = mdcHomeService.getEquipmentMonthStatistics(userId, key); - return Result.OK(result); - } - - @ApiOperation(value = "MDC棣栭〉鎺ュ彛-宸ユ绾у墠涓冨ぉ鍒╃敤鐜囨姌绾垮浘", notes = "MDC棣栭〉鎺ュ彛-宸ユ绾у墠涓冨ぉ鍒╃敤鐜囨姌绾垮浘") - @GetMapping("/equipmentDayUtilizationStatistics") - public Result<?> equipmentDayUtilizationStatistics(String productionCode) { - LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal(); - String userId = user.getId(); - String key = ""; - if (StringUtils.isNotBlank(productionCode)) { - //鍘傚尯 - MdcProduction mdcProduction = mdcProductionService.getOne(new LambdaQueryWrapper<MdcProduction>().eq(MdcProduction::getProductionCode, productionCode).eq(MdcProduction::getDelFlag, CommonConstant.DEL_FLAG_0.toString())); - key = mdcProduction.getId(); - } else { - //宸ユ 鏌ヨ鐢ㄦ埛鎷ユ湁鐨勫伐娈垫潈闄� - key = mdcProductionService.findThreeProductionId(userId); - } - Map<String, Object> result = mdcHomeService.getEquipmentDayUtilizationStatistics(userId, key); - return Result.OK(result); - } - - @ApiOperation(value = "MDC棣栭〉鎺ュ彛-涓婃湀鍚勮澶嘜EE缁熻", notes = "MDC棣栭〉鎺ュ彛-涓婃湀鍚勮澶嘜EE缁熻") - @GetMapping("/equipmentOEEMonthStatistics") - public Result<?> equipmentOEEMonthStatistics(String productionCode) { - LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal(); - String userId = user.getId(); - String key = ""; - if (StringUtils.isNotBlank(productionCode)) { - //鍘傚尯 - MdcProduction mdcProduction = mdcProductionService.getOne(new LambdaQueryWrapper<MdcProduction>().eq(MdcProduction::getProductionCode, productionCode).eq(MdcProduction::getDelFlag, CommonConstant.DEL_FLAG_0.toString())); - key = mdcProduction.getId(); - } else { - //宸ユ 鏌ヨ鐢ㄦ埛鎷ユ湁鐨勫伐娈垫潈闄� - key = mdcProductionService.findThreeProductionId(userId); - } - List<MdcOverallEquipmentEfficiency> result = mdcHomeService.getEquipmentOEEMonthStatistics(userId, key); - return Result.OK(result); - } - - @ApiOperation(value = "MDC棣栭〉鎺ュ彛-宸ユ绾ц澶囨晥鐜囩粺璁�", notes = "MDC棣栭〉鎺ュ彛-宸ユ绾ц澶囨晥鐜囩粺璁�") - @GetMapping("/equipmentEfficiencyStatistics") - public Result<?> equipmentEfficiencyStatistics(String productionCode) { - LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal(); - String userId = user.getId(); - String key = ""; - if (StringUtils.isNotBlank(productionCode)) { - //鍘傚尯 - MdcProduction mdcProduction = mdcProductionService.getOne(new LambdaQueryWrapper<MdcProduction>().eq(MdcProduction::getProductionCode, productionCode).eq(MdcProduction::getDelFlag, CommonConstant.DEL_FLAG_0.toString())); - key = mdcProduction.getId(); - } else { - //宸ユ 鏌ヨ鐢ㄦ埛鎷ユ湁鐨勫伐娈垫潈闄� - key = mdcProductionService.findThreeProductionId(userId); - } - MdcHomeEfficiencyVo result = mdcHomeService.getEquipmentEfficiencyStatistics(userId, key); - return Result.OK(result); - } - - @ApiOperation(value = "MDC棣栭〉鎺ュ彛-璁惧绾ц澶囨晥鐜囩粺璁�", notes = "MDC棣栭〉鎺ュ彛-璁惧绾ц澶囨晥鐜囩粺璁�") - @GetMapping("/equipmentLevelEfficiencyStatistics") - public Result<?> equipmentLevelEfficiencyStatistics(@RequestParam(name = "equipmentId", required = true) String equipmentId) { - MdcHomeEfficiencyVo result = mdcHomeService.getEquipmentLevelEfficiencyStatistics(equipmentId); - return Result.OK(result); - } - - @ApiOperation(value = "MDC棣栭〉鎺ュ彛-璁惧绾ф暣骞村害鍒╃敤鐜�", notes = "MDC棣栭〉鎺ュ彛-璁惧绾ф暣骞村害鍒╃敤鐜�") - @GetMapping("/equipmentAnnualEfficiencyStatistics") - public Result<?> equipmentAnnualEfficiencyStatistics(@RequestParam(name = "equipmentId", required = true) String equipmentId) { - Map<String, Object> result = mdcHomeService.getEquipmentAnnualEfficiencyStatistics(equipmentId); - return Result.OK(result); - } - - @ApiOperation(value = "MDC棣栭〉鎺ュ彛-璁惧绾ц澶囪缁嗕俊鎭�", notes = "MDC棣栭〉鎺ュ彛-璁惧绾ц澶囪缁嗕俊鎭�") - @GetMapping("/equipmentDetails") - public Result<?> equipmentDetails(@RequestParam(name = "equipmentId", required = true) String equipmentId) { - MdcEquipmentDto result = mdcHomeService.getEquipmentDetails(equipmentId); - return Result.OK(result); - } - - @ApiOperation(value = "MDC棣栭〉鎺ュ彛-璁惧绾ц澶囧垪琛�", notes = "MDC棣栭〉鎺ュ彛-璁惧绾ц澶囧垪琛�") - @GetMapping("/equipmentList") - public Result<?> equipmentList(String productionCode) { - LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal(); - String userId = user.getId(); - String key = ""; - if (StringUtils.isNotBlank(productionCode)) { - //鍘傚尯 - MdcProduction mdcProduction = mdcProductionService.getOne(new LambdaQueryWrapper<MdcProduction>().eq(MdcProduction::getProductionCode, productionCode).eq(MdcProduction::getDelFlag, CommonConstant.DEL_FLAG_0.toString())); - key = mdcProduction.getId(); - } else { - //宸ユ 鏌ヨ鐢ㄦ埛鎷ユ湁鐨勫伐娈垫潈闄� - key = mdcProductionService.findThreeProductionId(userId); - } - List<MdcEquipment> result = mdcHomeService.getEquipmentList(key); - return Result.OK(result); - } - - @ApiOperation(value = "MDC棣栭〉鎺ュ彛-闂鍒楄〃", notes = "MDC棣栭〉鎺ュ彛-闂鍒楄〃") - @GetMapping("/feedbackList") - public Result<?> feedbackList(String productionCode) { - LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal(); - Integer userType = user.getUserType(); - String userId = user.getId(); - String key = ""; - if (StringUtils.isNotBlank(productionCode)) { - //鍘傚尯 - MdcProduction mdcProduction = mdcProductionService.getOne(new LambdaQueryWrapper<MdcProduction>().eq(MdcProduction::getProductionCode, productionCode).eq(MdcProduction::getDelFlag, CommonConstant.DEL_FLAG_0.toString())); - key = mdcProduction.getId(); - } else { - //鍒ゆ柇鏄叕鍙哥骇杩樻槸鍘傚尯 - MdcProduction mdcProduction = mdcProductionService.getOne(new LambdaQueryWrapper<MdcProduction>().eq(MdcProduction::getParentId, "")); - if (userType.equals(MdcConstant.USER_TYPE_4)) { - //鍏徃 - key = mdcProduction.getId(); - } else if (userType.equals(MdcConstant.USER_TYPE_3)) { - //鍘傚尯 - key = mdcProductionService.findFirstProduction(userId, mdcProduction.getId()); - } - } - List<MdcFeedback> result = mdcHomeService.getFeedbackList(key); - return Result.OK(result); - } - -} diff --git a/src/main/java/org/jeecg/modules/mdc/controller/MdcProductionController.java b/src/main/java/org/jeecg/modules/mdc/controller/MdcProductionController.java deleted file mode 100644 index fdf674b..0000000 --- a/src/main/java/org/jeecg/modules/mdc/controller/MdcProductionController.java +++ /dev/null @@ -1,357 +0,0 @@ -package org.jeecg.modules.mdc.controller; - -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import com.baomidou.mybatisplus.core.metadata.IPage; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import lombok.extern.slf4j.Slf4j; -import org.apache.shiro.SecurityUtils; -import org.jeecg.common.api.vo.Result; -import org.jeecg.common.aspect.annotation.AutoLog; -import org.jeecg.common.constant.CommonConstant; -import org.jeecg.common.system.base.controller.JeecgController; -import org.jeecg.common.system.query.QueryGenerator; -import org.jeecg.common.system.vo.LoginUser; -import org.jeecg.common.util.oConvertUtils; -import org.jeecg.modules.mdc.entity.MdcProduction; -import org.jeecg.modules.mdc.model.MdcProductionTreeModel; -import org.jeecg.modules.mdc.model.ProductionIdModel; -import org.jeecg.modules.mdc.service.IMdcProductionService; -import org.jeecg.modules.mdc.vo.MdcProOptionsVo; -import org.springframework.cache.annotation.CacheEvict; -import org.springframework.web.bind.annotation.*; -import org.springframework.web.servlet.ModelAndView; - -import javax.annotation.Resource; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import java.util.Arrays; -import java.util.List; -import java.util.stream.Collectors; - -/** - * @Description: 浜х嚎琛� - * @Author: liuS - * @Date: 2023-03-23 - * @Version: V1.0 - */ -@Slf4j -@Api(tags = "浜х嚎琛�") -@RestController -@RequestMapping("/mdc/mdcProduction") -public class MdcProductionController extends JeecgController<MdcProduction, IMdcProductionService> { - @Resource - private IMdcProductionService mdcProductionService; - - /** - * 鍒嗛〉鍒楄〃鏌ヨ - * - * @param mdcProduction - * @param pageNo - * @param pageSize - * @param req - * @return - */ - @AutoLog(value = "浜х嚎琛�-鍒嗛〉鍒楄〃鏌ヨ") - @ApiOperation(value = "浜х嚎琛�-鍒嗛〉鍒楄〃鏌ヨ", notes = "浜х嚎琛�-鍒嗛〉鍒楄〃鏌ヨ") - @GetMapping(value = "/list") - public Result<?> queryPageList(MdcProduction mdcProduction, - @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, - @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize, - HttpServletRequest req) { - QueryWrapper<MdcProduction> queryWrapper = QueryGenerator.initQueryWrapper(mdcProduction, req.getParameterMap()); - Page<MdcProduction> page = new Page<MdcProduction>(pageNo, pageSize); - IPage<MdcProduction> pageList = mdcProductionService.page(page, queryWrapper); - return Result.OK(pageList); - } - - @AutoLog(value = "浜х嚎琛�-鏍戝舰鍒楄〃") - @ApiOperation(value = "浜х嚎琛�-鏍戝舰鍒楄〃", notes = "浜х嚎琛�-鏍戝舰鍒楄〃") - @GetMapping(value = "/queryTreeList") - public Result<List<MdcProductionTreeModel>> queryTreeList(@RequestParam(name = "ids", required = false) String ids) { - Result<List<MdcProductionTreeModel>> result = new Result<>(); - try { - if (oConvertUtils.isNotEmpty(ids)) { - List<MdcProductionTreeModel> productionList = mdcProductionService.queryTreeList(ids); - result.setResult(productionList); - } else { - List<MdcProductionTreeModel> list = mdcProductionService.queryTreeList(); - result.setResult(list); - } - result.setSuccess(true); - } catch (Exception e) { - log.error(e.getMessage(), e); - } - return result; - } - - @AutoLog(value = "浜х嚎琛�-鏍戝舰鍒楄〃(MDC)") - @ApiOperation(value = "浜х嚎琛�-鏍戝舰鍒楄〃(MDC)", notes = "浜х嚎琛�-鏍戝舰鍒楄〃(MDC)") - @GetMapping(value = "/queryTreeListByMdc") - public Result<List<MdcProductionTreeModel>> queryTreeListByMdc(@RequestParam(name = "ids", required = false) String ids) { - Result<List<MdcProductionTreeModel>> result = new Result<>(); - try { - if (oConvertUtils.isNotEmpty(ids)) { - List<MdcProductionTreeModel> productionList = mdcProductionService.queryTreeListByMdc(ids); - result.setResult(productionList); - } else { - List<MdcProductionTreeModel> list = mdcProductionService.queryTreeListByMdc(); - result.setResult(list); - } - result.setSuccess(true); - } catch (Exception e) { - log.error(e.getMessage(), e); - } - return result; - } - - @AutoLog(value = "浜х嚎琛�-鏍戝舰鍒楄〃(娣诲姞绯荤粺閰嶇疆)") - @ApiOperation(value = "浜х嚎琛�-鏍戝舰鍒楄〃(娣诲姞绯荤粺閰嶇疆)", notes = "浜х嚎琛�-鏍戝舰鍒楄〃(娣诲姞绯荤粺閰嶇疆)") - @GetMapping(value = "/queryTreeListByConfig") - public Result<List<MdcProductionTreeModel>> queryTreeListByConfig(@RequestParam(name = "ids", required = false) String ids) { - Result<List<MdcProductionTreeModel>> result = new Result<>(); - try { - if (oConvertUtils.isNotEmpty(ids)) { - List<MdcProductionTreeModel> productionList = mdcProductionService.queryTreeList(ids); - result.setResult(productionList); - } else { - List<MdcProductionTreeModel> list = mdcProductionService.queryTreeListByConfig(); - result.setResult(list); - } - result.setSuccess(true); - } catch (Exception e) { - log.error(e.getMessage(), e); - } - return result; - } - - @ApiOperation(value = "浜х嚎琛�-鏍规嵁鐢ㄦ埛id鑾峰彇浜х嚎涓嬫媺鏍戦�夐」", notes = "浜х嚎琛�-鏍规嵁鐢ㄦ埛id鑾峰彇浜х嚎涓嬫媺鏍戦�夐」") - @GetMapping(value = "/loadProductionTreeOptions") - public Result<List<ProductionIdModel>> loadProductionTreeOptions() { - Result<List<ProductionIdModel>> result = new Result<>(); - LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal(); - String userId = user.getId(); - try { - List<ProductionIdModel> list = mdcProductionService.loadProductionTreeOptions(userId); - result.setSuccess(true); - result.setResult(list); - } catch (Exception e) { - log.error(e.getMessage(), e); - } - return result; - } - - @AutoLog(value = "浜х嚎琛�-id闆嗗悎") - @ApiOperation(value = "浜х嚎琛�-id闆嗗悎", notes = "浜х嚎琛�-id闆嗗悎") - @GetMapping(value = "/queryTreeIdList") - public Result<List<String>> queryTreeIdList() { - Result<List<String>> result = new Result<>(); - try { - List<MdcProduction> productionList = mdcProductionService.list(new LambdaQueryWrapper<MdcProduction>().eq(MdcProduction::getDelFlag, CommonConstant.DEL_FLAG_0).orderByAsc(MdcProduction::getProductionOrder)); - List<String> ids = productionList.stream().map(MdcProduction::getId).collect(Collectors.toList()); - result.setSuccess(true); - result.setResult(ids); - } catch (Exception e) { - log.error(e.getMessage(), e); - } - return result; - } - - /** - * 娣诲姞 - * - * @param mdcProduction - * @return - */ - @AutoLog(value = "浜х嚎琛�-娣诲姞") - @ApiOperation(value = "浜х嚎琛�-娣诲姞", notes = "浜х嚎琛�-娣诲姞") - @PostMapping(value = "/add") - @CacheEvict(value = {"mdc:cache:production:alldata", "mdc:cache:production:allids"}, allEntries = true) - public Result<MdcProduction> add(@RequestBody MdcProduction mdcProduction) { - Result<MdcProduction> result = new Result<>(); - try { - mdcProductionService.saveProductionData(mdcProduction); - result.success("娣诲姞鎴愬姛锛�"); - } catch (Exception e) { - log.error(e.getMessage(), e); - result.error500("鎿嶄綔澶辫触"); - } - return result; - } - - /** - * 缂栬緫 - * - * @param mdcProduction - * @return - */ - @AutoLog(value = "浜х嚎琛�-缂栬緫") - @ApiOperation(value = "浜х嚎琛�-缂栬緫", notes = "浜х嚎琛�-缂栬緫") - @RequestMapping(value = "/edit", method = {RequestMethod.PUT, RequestMethod.POST}) - @CacheEvict(value = {"mdc:cache:production:alldata", "mdc:cache:production:allids"}, allEntries = true) - public Result<MdcProduction> edit(@RequestBody MdcProduction mdcProduction) { - Result<MdcProduction> result = new Result<>(); - MdcProduction mdcProductionEntity = mdcProductionService.getById(mdcProduction.getId()); - if (mdcProductionEntity == null) { - result.error500("鏈壘鍒板搴斿疄浣�"); - } else { - boolean ok = mdcProductionService.updateProductionDataById(mdcProduction); - if (ok) { - result.success("淇敼鎴愬姛!"); - } - } - return result; - } - - /** - * 閫氳繃id鍒犻櫎 - * - * @param id - * @return - */ - @AutoLog(value = "浜х嚎琛�-閫氳繃id鍒犻櫎") - @ApiOperation(value = "浜х嚎琛�-閫氳繃id鍒犻櫎", notes = "浜х嚎琛�-閫氳繃id鍒犻櫎") - @DeleteMapping(value = "/delete") - @CacheEvict(value = {"mdc:cache:production:alldata", "mdc:cache:production:allids"}, allEntries = true) - public Result<MdcProduction> delete(@RequestParam(name = "id", required = true) String id) { - Result<MdcProduction> result = new Result<>(); - MdcProduction mdcProduction = mdcProductionService.getById(id); - if (mdcProduction == null) { - result.error500("鏈壘鍒板搴斿疄浣�"); - } else { - boolean ok = mdcProductionService.delete(id); - if (ok) { - result.success("鍒犻櫎鎴愬姛!"); - } - } - return result; - } - - /** - * 鎵归噺鍒犻櫎 - * - * @param ids - * @return - */ - @AutoLog(value = "浜х嚎琛�-鎵归噺鍒犻櫎") - @ApiOperation(value = "浜х嚎琛�-鎵归噺鍒犻櫎", notes = "浜х嚎琛�-鎵归噺鍒犻櫎") - @DeleteMapping(value = "/deleteBatch") - @CacheEvict(value = {"mdc:cache:production:alldata", "mdc:cache:production:allids"}, allEntries = true) - public Result<MdcProduction> deleteBatch(@RequestParam(name = "ids", required = true) String ids) { - Result<MdcProduction> result = new Result<>(); - if (ids == null || "".equals(ids.trim())) { - result.error500("鍙傛暟涓嶈瘑鍒紒"); - } else { - this.mdcProductionService.deleteBatchWithChildren(Arrays.asList(ids.split(","))); - result.success("鍒犻櫎鎴愬姛!"); - } - return result; - } - - @AutoLog(value = "浜х嚎琛�-鏌ヨ鏍戝舰缁撴瀯鎵�鏈変骇绾垮悕绉�") - @ApiOperation(value = "浜х嚎琛�-鏌ヨ鏍戝舰缁撴瀯鎵�鏈変骇绾垮悕绉�", notes = "浜х嚎琛�-鏌ヨ鏍戝舰缁撴瀯鎵�鏈変骇绾垮悕绉�") - @GetMapping(value = "/queryIdTree") - public Result<List<ProductionIdModel>> queryIdTree() { - Result<List<ProductionIdModel>> result = new Result<>(); - try { - List<ProductionIdModel> list = mdcProductionService.queryProductionIdTreeList(); - result.setResult(list); - result.setSuccess(true); - } catch (Exception e) { - log.error(e.getMessage(), e); - } - return result; - } - - @AutoLog(value = "浜х嚎琛�-鏍规嵁鍏抽敭瀛楁ā绯婃悳绱㈢浉鍏充骇绾�") - @ApiOperation(value = "浜х嚎琛�-鏍规嵁鍏抽敭瀛楁ā绯婃悳绱㈢浉鍏充骇绾�", notes = "浜х嚎琛�-鏍规嵁鍏抽敭瀛楁ā绯婃悳绱㈢浉鍏充骇绾�") - @GetMapping(value = "/searchBy") - public Result<List<MdcProductionTreeModel>> searchBy(@RequestParam(name = "keyWord", required = true) String keyWord) { - Result<List<MdcProductionTreeModel>> result = new Result<>(); - List<MdcProductionTreeModel> treeList = mdcProductionService.searchByKeyWord(keyWord); - if (treeList == null || treeList.isEmpty()) { - result.setSuccess(false); - result.setMessage("鏈煡璇㈠尮閰嶆暟鎹紒"); - return result; - } - result.setResult(treeList); - return result; - } - - /** - * 閫氳繃id鏌ヨ - * - * @param id - * @return - */ - @AutoLog(value = "浜х嚎琛�-閫氳繃id鏌ヨ") - @ApiOperation(value = "浜х嚎琛�-閫氳繃id鏌ヨ", notes = "浜х嚎琛�-閫氳繃id鏌ヨ") - @GetMapping(value = "/queryById") - public Result<?> queryById(@RequestParam(name = "id", required = true) String id) { - MdcProduction mdcProduction = mdcProductionService.getById(id); - return Result.OK(mdcProduction); - } - - /** - * 瀵煎嚭excel - * - * @param request - * @param mdcProduction - */ - @AutoLog(value = "浜х嚎琛�-瀵煎嚭excel") - @ApiOperation(value = "浜х嚎琛�-瀵煎嚭excel", notes = "浜х嚎琛�-瀵煎嚭excel") - @RequestMapping(value = "/exportXls") - public ModelAndView exportXls(HttpServletRequest request, MdcProduction mdcProduction) { - return super.exportXls(request, mdcProduction, MdcProduction.class, "浜х嚎琛�"); - } - - /** - * 閫氳繃excel瀵煎叆鏁版嵁 - * - * @param request - * @param response - * @return - */ - @AutoLog(value = "浜х嚎琛�-閫氳繃excel瀵煎叆鏁版嵁") - @ApiOperation(value = "浜х嚎琛�-閫氳繃excel瀵煎叆鏁版嵁", notes = "浜х嚎琛�-閫氳繃excel瀵煎叆鏁版嵁") - @PostMapping(value = "/importExcel") - @CacheEvict(value = {"mdc:cache:production:alldata", "mdc:cache:production:allids"}, allEntries = true) - public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) { - return super.importExcel(request, response, MdcProduction.class); - } - - @ApiOperation(value = "浜х嚎琛�-鏍规嵁鐢ㄦ埛id鑾峰彇MDC浜х嚎(涓績)鎴栫彮缁勪笅鎷夐�夐」", notes = "浜х嚎琛�-鏍规嵁鐢ㄦ埛id鑾峰彇MDC浜х嚎(涓績)鎴栫彮缁勪笅鎷夐�夐」") - @GetMapping(value = "/loadProductionOptions") - public Result<?> loadProductionOptions(String productionId) { - Result<List<MdcProOptionsVo>> result = new Result<>(); - LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal(); - String userId = user.getId(); - try { - List<MdcProOptionsVo> list = mdcProductionService.loadProductionOptions(userId, productionId); - result.setSuccess(true); - result.setResult(list); - } catch (Exception e) { - log.error(e.getMessage(), e); - } - return result; - } - - @ApiOperation(value = "浜х嚎琛�-鏍规嵁鐝粍id鑾峰彇閰嶉�佺粍涓嬫媺閫夐」", notes = "浜х嚎琛�-鏍规嵁鐝粍id鑾峰彇閰嶉�佺粍涓嬫媺閫夐」") - @GetMapping(value = "/loadTeamOptions") - public Result<?> loadTeamOptions(@RequestParam(name = "productionId", required = true) String productionId) { - Result<List<MdcProOptionsVo>> result = new Result<>(); - LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal(); - String userId = user.getId(); - try { - List<MdcProOptionsVo> list = mdcProductionService.loadTeamOptions(userId, productionId); - result.setSuccess(true); - result.setResult(list); - } catch (Exception e) { - log.error(e.getMessage(), e); - } - return result; - } - -} diff --git a/src/main/java/org/jeecg/modules/mdc/dto/MdcEfficiencyDto.java b/src/main/java/org/jeecg/modules/mdc/dto/MdcEfficiencyDto.java index 1e6d764..e9afd9b 100644 --- a/src/main/java/org/jeecg/modules/mdc/dto/MdcEfficiencyDto.java +++ b/src/main/java/org/jeecg/modules/mdc/dto/MdcEfficiencyDto.java @@ -55,17 +55,5 @@ * 鍏虫満鏃堕暱 */ private BigDecimal closeLong; - /** - * 鏁呴殰鏃堕暱 - */ - private BigDecimal faultLong; - /** - * 鏁呴殰鐜� - */ - private BigDecimal faultRate; - /** - * 杩愯鏃堕暱(鍘婚櫎鏁呴殰鏃堕棿) - */ - private BigDecimal removeFaultRunLong; } diff --git a/src/main/java/org/jeecg/modules/mdc/dto/MdcEfficiencyResultDto.java b/src/main/java/org/jeecg/modules/mdc/dto/MdcEfficiencyResultDto.java index 2086182..0056c06 100644 --- a/src/main/java/org/jeecg/modules/mdc/dto/MdcEfficiencyResultDto.java +++ b/src/main/java/org/jeecg/modules/mdc/dto/MdcEfficiencyResultDto.java @@ -42,24 +42,24 @@ * 鍏虫満鏃堕暱 */ private BigDecimal closeLong = BigDecimal.ZERO; - /** - * 鏁呴殰鏃堕暱 - */ - private BigDecimal faultLong = BigDecimal.ZERO; - /** - * 鏁呴殰鐜� - */ - private BigDecimal faultRate = BigDecimal.ZERO; - /** - * 杩愯鏃堕暱(鍘婚櫎鏁呴殰鏃堕棿) - */ - private BigDecimal removeFaultRunLong = BigDecimal.ZERO; +// /** +// * 鏁呴殰鏃堕暱 +// */ +// private BigDecimal faultLong = BigDecimal.ZERO; +// /** +// * 鏁呴殰鐜� +// */ +// private BigDecimal faultRate = BigDecimal.ZERO; +// /** +// * 杩愯鏃堕暱(鍘婚櫎鏁呴殰鏃堕棿) +// */ +// private BigDecimal removeFaultRunLong = BigDecimal.ZERO; /** * 棰滆壊 */ private String color; - public MdcEfficiencyResultDto(String theDate, BigDecimal processLong, BigDecimal utilizationRate, BigDecimal startRate, BigDecimal openRate, BigDecimal openLong, BigDecimal waitLong, BigDecimal closeLong, BigDecimal faultLong, BigDecimal faultRate, BigDecimal removeFaultRunLong) { + public MdcEfficiencyResultDto(String theDate, BigDecimal processLong, BigDecimal utilizationRate, BigDecimal startRate, BigDecimal openRate, BigDecimal openLong, BigDecimal waitLong, BigDecimal closeLong) { this.theDate = theDate; this.processLong = processLong; this.utilizationRate = utilizationRate; @@ -68,9 +68,9 @@ this.openLong = openLong; this.waitLong = waitLong; this.closeLong = closeLong; - this.faultLong = faultLong; - this.faultRate = faultRate; - this.removeFaultRunLong = removeFaultRunLong; +// this.faultLong = faultLong; +// this.faultRate = faultRate; +// this.removeFaultRunLong = removeFaultRunLong; } public MdcEfficiencyResultDto() { diff --git a/src/main/java/org/jeecg/modules/mdc/entity/FactoryEquipment.java b/src/main/java/org/jeecg/modules/mdc/entity/FactoryEquipment.java new file mode 100644 index 0000000..7f3df6a --- /dev/null +++ b/src/main/java/org/jeecg/modules/mdc/entity/FactoryEquipment.java @@ -0,0 +1,53 @@ +package org.jeecg.modules.mdc.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import io.swagger.annotations.ApiModel; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +import java.io.Serializable; + +/** + * 浜х嚎璁惧 + * + * @author: LiuS + * @create: 2023-03-24 15:54 + */ +@Data +@TableName("base_equipment_factory") +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +@ApiModel(value = "base_equipment_factory瀵硅薄", description = "浜х嚎璁惧琛�") +public class FactoryEquipment implements Serializable { + + private static final long serialVersionUID = 1684188898785392096L; + + /** + * 涓婚敭id + */ + @TableId(type = IdType.ASSIGN_ID) + private String id; + /** + * 浜х嚎id + */ + private String factoryId; + /** + * 璁惧id + */ + private String equipmentId; + + public FactoryEquipment(String id, String factoryId, String equipmentId) { + super(); + this.id = id; + this.factoryId = factoryId; + this.equipmentId = equipmentId; + } + + public FactoryEquipment(String id, String factoryId) { + this.equipmentId = id; + this.factoryId = factoryId; + } +} diff --git a/src/main/java/org/jeecg/modules/mdc/entity/MdcEquipment.java b/src/main/java/org/jeecg/modules/mdc/entity/MdcEquipment.java index cacada2..8f7631e 100644 --- a/src/main/java/org/jeecg/modules/mdc/entity/MdcEquipment.java +++ b/src/main/java/org/jeecg/modules/mdc/entity/MdcEquipment.java @@ -172,7 +172,7 @@ @TableField(exist = false) @ApiModelProperty(value = "閫夋嫨鐨勪骇绾縤d闆嗗悎") - private String selectedProduction; + private String selectedFactory; // 鍏宠仈浜х嚎锛堥潪鏁版嵁搴撳瓧娈碉級 private transient String productionId; diff --git a/src/main/java/org/jeecg/modules/mdc/mapper/FactoryEquipmentMapper.java b/src/main/java/org/jeecg/modules/mdc/mapper/FactoryEquipmentMapper.java new file mode 100644 index 0000000..7e6ea01 --- /dev/null +++ b/src/main/java/org/jeecg/modules/mdc/mapper/FactoryEquipmentMapper.java @@ -0,0 +1,13 @@ +package org.jeecg.modules.mdc.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.jeecg.modules.mdc.entity.FactoryEquipment; + +/** + * 浜х嚎璁惧mapper鎺ュ彛 + * + * @author: LiuS + * @create: 2023-03-24 16:00 + */ +public interface FactoryEquipmentMapper extends BaseMapper<FactoryEquipment> { +} diff --git a/src/main/java/org/jeecg/modules/mdc/mapper/MdcEquipmentFaultInfoMapper.java b/src/main/java/org/jeecg/modules/mdc/mapper/MdcEquipmentFaultInfoMapper.java deleted file mode 100644 index 3aa3fd3..0000000 --- a/src/main/java/org/jeecg/modules/mdc/mapper/MdcEquipmentFaultInfoMapper.java +++ /dev/null @@ -1,22 +0,0 @@ -package org.jeecg.modules.mdc.mapper; - -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import org.apache.ibatis.annotations.Param; -import org.jeecg.modules.mdc.entity.MdcEquipmentFaultInfo; -import org.jeecg.modules.mdc.vo.EquFaultRecord; - -import java.util.List; - -/** - * @Description: 鏁呴殰鐜囪〃 - * @Author: jeecg-boot - * @Date: 2025-06-16 - * @Version: V1.0 - */ -public interface MdcEquipmentFaultInfoMapper extends BaseMapper<MdcEquipmentFaultInfo> { - - List<EquFaultRecord> findFaultRecord(@Param("equipmentIdList") List<String> equipmentIdList, @Param("startTime") String startTime, @Param("endTime") String endTime); - - String getMaxStaticsData(); - -} diff --git a/src/main/java/org/jeecg/modules/mdc/mapper/MdcEquipmentMapper.java b/src/main/java/org/jeecg/modules/mdc/mapper/MdcEquipmentMapper.java index 0a71450..dbc09ca 100644 --- a/src/main/java/org/jeecg/modules/mdc/mapper/MdcEquipmentMapper.java +++ b/src/main/java/org/jeecg/modules/mdc/mapper/MdcEquipmentMapper.java @@ -143,5 +143,10 @@ List<String> getEquIdsByProIds(@Param("proIds") List<String> proIds); - List<MdcEquipment> getEquipmentList(@Param("allProductionIds") List<String> allProductionIds); + List<MdcEquipment> getEquipmentList(@Param("allFactoryIds") List<String> allFactoryIds); + + List<MdcEquipment> queryByFactoryId(@Param("factoryId") String factoryId); + + List<String> queryIdsByFactorys(@Param("allFactoryIds") List<String> allFactoryIds); + } diff --git a/src/main/java/org/jeecg/modules/mdc/mapper/MdcProductionEquipmentMapper.java b/src/main/java/org/jeecg/modules/mdc/mapper/MdcProductionEquipmentMapper.java deleted file mode 100644 index f365f1a..0000000 --- a/src/main/java/org/jeecg/modules/mdc/mapper/MdcProductionEquipmentMapper.java +++ /dev/null @@ -1,13 +0,0 @@ -package org.jeecg.modules.mdc.mapper; - -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import org.jeecg.modules.mdc.entity.MdcProductionEquipment; - -/** - * 浜х嚎璁惧mapper鎺ュ彛 - * - * @author: LiuS - * @create: 2023-03-24 16:00 - */ -public interface MdcProductionEquipmentMapper extends BaseMapper<MdcProductionEquipment> { -} diff --git a/src/main/java/org/jeecg/modules/mdc/mapper/MdcProductionMapper.java b/src/main/java/org/jeecg/modules/mdc/mapper/MdcProductionMapper.java deleted file mode 100644 index 5b059de..0000000 --- a/src/main/java/org/jeecg/modules/mdc/mapper/MdcProductionMapper.java +++ /dev/null @@ -1,68 +0,0 @@ -package org.jeecg.modules.mdc.mapper; - -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import org.apache.ibatis.annotations.Param; -import org.apache.ibatis.annotations.Select; -import org.jeecg.modules.mdc.entity.MdcProduction; - -import java.util.List; - - -/** - * @Description: 浜х嚎琛� - * @Author: liuS - * @Date: 2023-03-23 - * @Version: V1.0 - */ -public interface MdcProductionMapper extends BaseMapper<MdcProduction> { - - /** - * 鏍规嵁id涓嬬骇浜х嚎 - */ - @Select("SELECT * FROM mdc_production where del_flag ='0' AND parent_id = #{parentId,jdbcType=VARCHAR}") - List<MdcProduction> queryProdByPid(@Param("parentId") String parentId); - - /** - * 閫掑綊鏌ヨ鎵�鏈夊瓙鑺傜偣 - */ - List<String> recursionChildren(@Param("productionId") String productionId); - - /** - * 涓�缁刬d閫掑綊鎵�鏈夊瓙鑺傜偣 - */ - List<String> recursionChildrenByList(@Param("productionIds") List<String> productionIds); - - /** - * 鏍规嵁鐢ㄦ埛id鍜岃溅闂磇d鑾峰彇鐢ㄦ埛鎷ユ湁鐨勮溅闂磇d - * @param userId - * @param productionId - * @return - */ - String findFirstProduction(@Param("userId") String userId, @Param("productionId") String productionId); - - /** - * 鏍规嵁鐢ㄦ埛id鏌ヨ鐢ㄦ埛宸ユ鏉冮檺 - * @param userId - * @return - */ - String findThreeProductionId(@Param("userId") String userId); - - /** - * 鏍规嵁鐢ㄦ埛id鏌ヨ鐢ㄦ埛鍏ㄩ儴杞﹂棿鏉冮檺 - * @param userId - * @return - */ - List<MdcProduction> findAllProductionId(@Param("userId") String userId); - - List<String> findChildren(@Param("mdcProductionIds") List<String> mdcProductionIds); - - List<MdcProduction> loadProductionOptions(@Param("userId") String userId, @Param("productionId") String productionId); - - List<String> findTeamValue(@Param("userId") String userId, @Param("productionList") List<String> productionList); - - List<String> findProIdsByUId(@Param("userId") String userId, @Param("allProductionIds") List<String> allProductionIds); - - List<String> findChildByProId(@Param("productionId") String productionId); - - String findProName(@Param("equipmentId") String equipmentId); -} diff --git a/src/main/java/org/jeecg/modules/mdc/mapper/MdcUserProductionMapper.java b/src/main/java/org/jeecg/modules/mdc/mapper/MdcUserProductionMapper.java deleted file mode 100644 index d7ca1c1..0000000 --- a/src/main/java/org/jeecg/modules/mdc/mapper/MdcUserProductionMapper.java +++ /dev/null @@ -1,59 +0,0 @@ -package org.jeecg.modules.mdc.mapper; - -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import org.apache.ibatis.annotations.Param; -import org.jeecg.modules.mdc.entity.MdcUserProduction; -import org.jeecg.modules.system.entity.SysUser; - -import java.util.List; - -/** - * 鐢ㄦ埛浜х嚎Mapper鎺ュ彛 - * - * @author: LiuS - * @create: 2023-03-24 15:43 - */ -public interface MdcUserProductionMapper extends BaseMapper<MdcUserProduction> { - - /** - * 鏍规嵁鎸囧畾鐢ㄦ埛id鏌ヨ浜х嚎id闆嗗悎 - */ - List<String> queryProductionIdsByUserId(@Param("userId") String userId); - - /** - * 鑾峰彇宸插垎閰嶇殑鐢ㄦ埛鍒楄〃 - * @param proId - * @return - */ - List<SysUser> getUserPermsByGroupId(@Param("proId") String proId); - - /** - * 鑾峰彇鏈垎閰嶇殑鐢ㄦ埛鍒楄〃 - * @param proId - * @return - */ - List<SysUser> getUserNonPermsByGroupId(@Param("proId") String proId); - - /** - * 鑾峰彇璁惧鏈垎閰嶇殑鐢ㄦ埛 - * @param proId - * @return - */ - List<SysUser> getUserNonPermsByDeviceId(String proId); - - - /** - * 鑾峰彇璁惧宸插垎閰嶇殑鐢ㄦ埛 - * @param deviceId - * @return - */ - List<SysUser> getUserPermsByDeviceId(String deviceId); - - /** - * 閫氳繃杞﹂棿id涓庡矖浣峣d绛涢�夌敤鎴� - * @param post - * @param proId - * @return - */ - List<SysUser> queryByPostAndProId(@Param("post") String post, @Param("proId") String proId); -} diff --git a/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcProductionEquipmentMapper.xml b/src/main/java/org/jeecg/modules/mdc/mapper/xml/FactoryEquipmentMapper.xml similarity index 66% rename from src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcProductionEquipmentMapper.xml rename to src/main/java/org/jeecg/modules/mdc/mapper/xml/FactoryEquipmentMapper.xml index 23c95bf..bad8d7f 100644 --- a/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcProductionEquipmentMapper.xml +++ b/src/main/java/org/jeecg/modules/mdc/mapper/xml/FactoryEquipmentMapper.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> -<mapper namespace="org.jeecg.modules.mdc.mapper.MdcProductionEquipmentMapper"> +<mapper namespace="org.jeecg.modules.mdc.mapper.FactoryEquipmentMapper"> </mapper> \ No newline at end of file diff --git a/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcEfficiencyReportMapper.xml b/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcEfficiencyReportMapper.xml index d611c14..d5a3d75 100644 --- a/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcEfficiencyReportMapper.xml +++ b/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcEfficiencyReportMapper.xml @@ -18,14 +18,10 @@ t1.open_long / 86400 openRate, t1.open_long openLong, t1.wait_long waitLong, - t1.close_long closeLong, - COALESCE(t3.fault_long, 0) faultLong, - COALESCE(t3.fault_rate, 0) faultRate, - COALESCE(t3.remove_fault_run_long, 0) removeFaultRunLong + t1.close_long closeLong FROM mdc_equipment t2 LEFT JOIN mdc_equipment_statistical_info t1 ON t1.equipment_id = t2.equipment_id - LEFT JOIN mdc_equipment_fault_info t3 ON t2.equipment_id = t3.equipment_id AND t1.the_date = t3.the_date WHERE t1.the_date <= #{ vo.endTime } AND t1.the_date >= #{ vo.startTime } @@ -69,14 +65,10 @@ t1.open_long / 86400 openRate, t1.open_long openLong, t1.wait_long waitLong, - t1.close_long closeLong, - COALESCE(t3.fault_long, 0) faultLong, - COALESCE(t3.fault_rate, 0) faultRate, - COALESCE(t3.remove_fault_run_long, 0) removeFaultRunLong + t1.close_long closeLong FROM mdc_equipment t2 LEFT JOIN mdc_equipment_statistical_info t1 ON t1.equipment_id = t2.equipment_id - LEFT JOIN mdc_equipment_fault_info t3 ON t2.equipment_id = t3.equipment_id AND t1.the_date = t3.the_date WHERE t1.the_date <= #{ vo.endTime } AND t1.the_date >= #{ vo.startTime } diff --git a/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcEquipmentFaultInfoMapper.xml b/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcEquipmentFaultInfoMapper.xml deleted file mode 100644 index 3136e97..0000000 --- a/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcEquipmentFaultInfoMapper.xml +++ /dev/null @@ -1,30 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> -<mapper namespace="org.jeecg.modules.mdc.mapper.MdcEquipmentFaultInfoMapper"> - - <select id="findFaultRecord" resultType="org.jeecg.modules.mdc.vo.EquFaultRecord"> - SELECT - t3.equipment_code equipmentId, - t1.fault_start_time startTime, - t2.actual_end_time endTime - FROM - eam_report_repair t1 - LEFT JOIN eam_repair_order t2 ON t2.report_id = t1.id - LEFT JOIN eam_equipment t3 ON t1.equipment_id = t3.id - WHERE - ( - ( t1.fault_start_time BETWEEN #{startTime} AND #{endTime} ) - OR ( t2.actual_end_time BETWEEN #{startTime} AND #{endTime} ) - OR ( t1.fault_start_time < #{startTime} AND t2.actual_end_time IS NULL ) - ) - AND t3.equipment_code IN - <foreach collection="equipmentIdList" item="id" index="index" open="(" close=")" separator=","> - #{ id } - </foreach> - AND t1.report_status != 'ABOLISH' - </select> - - <select id="getMaxStaticsData" resultType="java.lang.String"> - SELECT TOP 1 the_date FROM mdc_equipment_fault_info ORDER BY the_date DESC - </select> -</mapper> \ No newline at end of file diff --git a/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcEquipmentMapper.xml b/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcEquipmentMapper.xml index 4e876b7..f4dcaf8 100644 --- a/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcEquipmentMapper.xml +++ b/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcEquipmentMapper.xml @@ -12,7 +12,7 @@ <!--鏌ヨ璁惧鐨勬墍灞炰骇绾垮悕绉颁俊鎭�--> <select id="getProNamesByEquipmentIds" resultType="org.jeecg.modules.mdc.vo.MdcEquipmentProVo"> - SELECT p.production_name, pe.equipment_id FROM mdc_production_equipment pe, mdc_production p WHERE p.id = pe.production_id AND pe.equipment_id IN + SELECT f.factory_name, bef.equipment_id FROM base_equipment_factory bef, base_factory f WHERE f.id = bef.factory_id AND bef.equipment_id IN <foreach collection="equipmentIds" index="index" item="id" open="(" separator="," close=")"> #{id} </foreach> @@ -95,10 +95,10 @@ me.* FROM mdc_equipment me - LEFT JOIN mdc_production_equipment mpe ON me.id = mpe.equipment_id + LEFT JOIN base_equipment_factory mpe ON me.id = mpe.equipment_id WHERE - mpe.production_id IN - <foreach collection="allProductionIds" index="index" item="id" open="(" separator="," close=")"> + mpe.factory_id IN + <foreach collection="allFactoryIds" index="index" item="id" open="(" separator="," close=")"> #{id} </foreach> </select> @@ -181,14 +181,14 @@ SELECT mp.id, mp.parent_id, - mp.production_name, - mp.org_type, + mp.factory_name AS productionName, + mp.factory_category AS orgtype, me.equipment_id, me.equipment_name, me.equipment_type FROM - mdc_production_equipment mpe - LEFT JOIN mdc_production mp ON mpe.production_id = mp.id + base_equipment_factory mpe + LEFT JOIN base_factory mp ON mpe.factory_id = mp.id LEFT JOIN mdc_equipment me ON me.id = mpe.equipment_id <where> me.equipment_id IN @@ -196,7 +196,7 @@ #{id} </foreach> </where> - ORDER BY mp.production_order + ORDER BY mp.sorter </select> <!--鏍规嵁澶у睆杞﹂棿id鏌ヨ璁惧鍒楄〃--> @@ -221,8 +221,8 @@ t1.* FROM mdc_equipment t1 - LEFT JOIN mdc_production_equipment t2 ON t1.id = t2.equipment_id - LEFT JOIN mdc_production t3 ON t2.production_id = t3.id + LEFT JOIN base_equipment_factory t2 ON t1.id = t2.equipment_id + LEFT JOIN base_factory t3 ON t2.factory_id = t3.id <where> <if test="mdcEquipment.equipmentId != null and mdcEquipment.equipmentId != '' "> AND t1.equipment_id LIKE CONCAT(CONCAT('%',#{mdcEquipment.equipmentId}),'%') @@ -260,8 +260,8 @@ t1.* FROM mdc_equipment t1 - LEFT JOIN mdc_production_equipment t2 ON t1.id = t2.equipment_id - LEFT JOIN mdc_production t3 ON t2.production_id = t3.id + LEFT JOIN base_equipment_factory t2 ON t1.id = t2.equipment_id + LEFT JOIN base_factory t3 ON t2.production_id = t3.id <where> <if test="mdcEquipment.equipmentId != null and mdcEquipment.equipmentId != '' "> AND t1.equipment_id LIKE CONCAT(CONCAT('%',#{mdcEquipment.equipmentId}),'%') @@ -402,4 +402,29 @@ </where> </select> + <select id="queryByFactoryId" resultType="org.jeecg.modules.mdc.entity.MdcEquipment"> + SELECT + me.* + FROM + base_equipment_factory bef, + mdc_equipment me + WHERE + bef.equipment_id = me.id + AND bef.factory_id = #{ factoryId } + ORDER BY me.equipment_id + </select> + + <select id="queryIdsByFactorys" resultType="java.lang.String"> + SELECT + me.equipment_id + FROM + mdc_equipment me + LEFT JOIN base_equipment_factory bef ON me.id = bef.equipment_id + WHERE + bef.factory_id IN + <foreach collection="allFactoryIds" index="index" item="id" open="(" separator="," close=")"> + #{id} + </foreach> + </select> + </mapper> diff --git a/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcProductionMapper.xml b/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcProductionMapper.xml deleted file mode 100644 index 662a7d9..0000000 --- a/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcProductionMapper.xml +++ /dev/null @@ -1,204 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> -<mapper namespace="org.jeecg.modules.mdc.mapper.MdcProductionMapper"> - - <!--閫掑綊鏌ヨ鎵�鏈夊瓙鑺傜偣--> - <select id="recursionChildren" resultType="java.lang.String"> - WITH temp ( id ) AS ( - SELECT - id - FROM - mdc_production - WHERE - id = #{ productionId } UNION ALL - SELECT - a.id - FROM - mdc_production a - INNER JOIN temp ON a.parent_id = temp.id - ) SELECT - * - FROM - temp - </select> - - <!--鏍规嵁鐢ㄦ埛id鍜岃溅闂磇d鑾峰彇鐢ㄦ埛鎷ユ湁鐨勮溅闂磇d--> - <select id="findFirstProduction" resultType="java.lang.String"> - SELECT TOP 1 t2.id FROM mdc_user_production t1 LEFT JOIN mdc_production t2 ON t1.pro_id = t2.id WHERE t1.user_id = #{ userId } AND t2.parent_id = #{productionId} - </select> - - <!--鏍规嵁鐢ㄦ埛id鏌ヨ鐢ㄦ埛宸ユ鏉冮檺--> - <select id="findThreeProductionId" resultType="java.lang.String"> - SELECT TOP 1 t2.id id FROM mdc_user_production t1 LEFT JOIN mdc_production t2 ON t1.pro_id = t2.id WHERE t1.user_id = #{userId} AND t2.org_type = '3' - </select> - <select id="findAllProductionId" resultType="org.jeecg.modules.mdc.entity.MdcProduction"> - SELECT - t1.* - FROM - mdc_production t1 - LEFT JOIN mdc_user_production t2 ON t1.id = t2.pro_id - LEFT JOIN sys_user t3 on t3.ID=t2.user_id - WHERE - t3.id = #{userId} - AND t1.org_type = '3' - </select> - - <select id="recursionChildrenByList" resultType="java.lang.String"> - WITH temp (id) AS ( - -- 鍒濆鏌ヨ锛岃幏鍙栨寚瀹� id 鐨勮褰� - SELECT - id - FROM - mdc_production - WHERE - id IN - <foreach collection = "productionIds" item = "id" index = "index" open = "(" close = ")" separator = ","> - #{id} - </foreach> - UNION ALL - -- 閫掑綊鏌ヨ锛屾煡鎵惧瓙鑺傜偣 - SELECT - a.id - FROM - mdc_production a - INNER JOIN temp ON a.parent_id = temp.id - ) --- 鏈�缁堟煡璇紝浣跨敤 DISTINCT 鍘婚噸 - SELECT DISTINCT - id - FROM - temp; - </select> - - <select id="findChildren" resultType="java.lang.String"> - WITH temp ( id ) AS ( - SELECT - id - FROM - mdc_production - WHERE - id IN - <foreach collection="mdcProductionIds" item = "id" index = "index" open = "(" close = ")" separator = ","> - #{id} - </foreach> - AND mdc_flag = '1' UNION ALL - SELECT - a.id - FROM - mdc_production a - INNER JOIN temp ON a.parent_id = temp.id - WHERE - a.mdc_flag = '1' - ) SELECT - * - FROM - temp - </select> - - <select id="loadProductionOptions" resultType="org.jeecg.modules.mdc.entity.MdcProduction"> - SELECT - t1.* - FROM - mdc_production t1 - LEFT JOIN mdc_user_production t2 ON t1.id = t2.pro_id - WHERE - t2.user_id = #{userId} AND t1.mdc_flag = '1' - <choose> - <when test="productionId != null and productionId != ''"> - AND t1.org_type = '3' AND t1.parent_id = #{productionId} - </when> - <otherwise> - AND t1.org_type = '2' - </otherwise> - </choose> - ORDER BY t1.production_order - </select> - - <select id="findTeamValue" resultType="java.lang.String"> - SELECT DISTINCT - t1.team_code deamCode - FROM - mdc_equipment t1 - LEFT JOIN mdc_production_equipment t2 ON t1.id = t2.equipment_id - WHERE t2.production_id IN - <foreach collection="productionList" item = "productionId" index = "index" open = "(" close= ")" separator = ","> - #{productionId} - </foreach> - </select> - - <select id="findProIdsByUId" resultType="java.lang.String"> - SELECT - pro_id - FROM - mdc_user_production - WHERE - pro_id IN - <foreach collection="allProductionIds" item = "productionId" index = "index" open = "(" close= ")" separator = ","> - #{productionId} - </foreach> - AND user_id = #{userId} - </select> - - <select id="findChildByProId" resultType="java.lang.String"> - WITH temp ( id ) AS ( - SELECT - id - FROM - mdc_production - WHERE - id = #{ productionId } - AND mdc_flag = '1' UNION ALL - SELECT - a.id - FROM - mdc_production a - INNER JOIN temp ON a.parent_id = temp.id - WHERE - a.mdc_flag = '1' - ) SELECT - * - FROM - temp - </select> - - <select id="findProName" resultType="java.lang.String"> - WITH production_hierarchy AS ( - SELECT - t3.id, - t3.parent_id, - t3.production_name, - t3.org_type, - 0 AS level - FROM - mdc_equipment t1 - JOIN - mdc_production_equipment t2 ON t1.id = t2.equipment_id - JOIN - mdc_production t3 ON t2.production_id = t3.id - WHERE - t1.equipment_id = #{equipmentId} - - UNION ALL - SELECT - t4.id, - t4.parent_id, - t4.production_name, - t4.org_type, - ph.level + 1 - FROM - production_hierarchy ph - JOIN - mdc_production t4 ON ph.parent_id = t4.id - WHERE - ph.parent_id IS NOT NULL - ) - SELECT TOP 1 - production_name - FROM - production_hierarchy - WHERE - org_type = 2 - ORDER BY - level ASC - </select> -</mapper> diff --git a/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcUserProductionMapper.xml b/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcUserProductionMapper.xml deleted file mode 100644 index 750baa2..0000000 --- a/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcUserProductionMapper.xml +++ /dev/null @@ -1,61 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> -<mapper namespace="org.jeecg.modules.mdc.mapper.MdcUserProductionMapper"> - - <!--鏍规嵁鎸囧畾鐢ㄦ埛id鏌ヨ浜х嚎id闆嗗悎--> - <select id="queryProductionIdsByUserId" resultType="java.lang.String"> - SELECT pro_id FROM mdc_user_production WHERE user_id = #{userId} - </select> - <select id="getUserPermsByGroupId" resultType="org.jeecg.modules.system.entity.SysUser"> - select u.id - , u.username - , u.realname - , u.avatar - , u.phone - , u.email - from sys_user u - inner join - (select user_id from mdc_user_production where pro_id=#{proId}) p - on u.id=p.user_id - </select> - <select id="getUserNonPermsByGroupId" resultType="org.jeecg.modules.system.entity.SysUser"> - select u.id - , u.username - , u.realname - , u.avatar - , u.phone - , u.email - from sys_user u - where u.id not in (select user_id from mdc_user_production where pro_id=#{proId}) - </select> - <select id="getUserNonPermsByDeviceId" resultType="org.jeecg.modules.system.entity.SysUser"> - select u.id - , u.username - , u.realname - , u.avatar - , u.phone - , u.email - from sys_user u - where u.id not in (select user_id from nc_device_permission where device_id=#{deviceId}) - </select> - <select id="getUserPermsByDeviceId" resultType="org.jeecg.modules.system.entity.SysUser"> - select u.id - , u.username - , u.realname - , u.avatar - , u.phone - , u.email - from sys_user u - inner join - (select user_id from nc_device_permission where device_id=#{deviceId}) p - on u.id=p.user_id - </select> - <select id="queryByPostAndProId" resultType="org.jeecg.modules.system.entity.SysUser"> - select u.* - from sys_user u - inner join - (select user_id from mdc_user_production where pro_id=#{proId}) p - on u.id=p.user_id - where u.post = #{post} - </select> -</mapper> diff --git a/src/main/java/org/jeecg/modules/mdc/model/FactoryTreeModel.java b/src/main/java/org/jeecg/modules/mdc/model/FactoryTreeModel.java new file mode 100644 index 0000000..fce7e1a --- /dev/null +++ b/src/main/java/org/jeecg/modules/mdc/model/FactoryTreeModel.java @@ -0,0 +1,112 @@ +package org.jeecg.modules.mdc.model; + +import io.swagger.annotations.ApiModel; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; +import org.jeecg.modules.base.entity.Factory; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +/** + * @author: LiuS + * @create: 2023-03-23 14:16 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +@ApiModel(value = "浜х嚎琛ㄦ爲缁撴瀯鏁版嵁瀹炰綋", description = "浜х嚎琛�") +public class FactoryTreeModel implements Serializable { + + private static final long serialVersionUID = -1309711609760828658L; + + /** + * 瀵瑰簲MdcProduction涓殑id瀛楁,鍓嶇鏁版嵁鏍戜腑鐨刱ey + */ + private String key; + + /** + * 瀵瑰簲MdcProduction涓殑id瀛楁,鍓嶇鏁版嵁鏍戜腑鐨剉alue + */ + private String value; + + /** + * 瀵瑰簲depart_name瀛楁,鍓嶇鏁版嵁鏍戜腑鐨則itle + */ + private String title; + + private boolean isLeaf; + + /** + * 绫诲瀷 + */ + private Integer type; + //浠ヤ笅鎵�鏈夊瓧娈靛潎涓嶮dcProduction鐩稿悓 + + private String id; + + private String createBy; + + private Date createTime; + + private String updateBy; + + private Date updateTime; + + private Integer delFlag; + + private String factoryName; + + private String factoryCode; + + private String parentId; + + private String factoryStatus; + + private String factoryCategory; + + private Integer sorter; + + private String address; + + private String mdcFlag; + + private String remark; + + /** + * 浜х嚎璐熻矗浜篿ds + */ + private String directorUserIds; + + private List<FactoryTreeModel> children = new ArrayList<>(); + + public FactoryTreeModel() { + + } + + /** + * 灏哅dcProduction瀵硅薄杞崲鎴怣dcProductionTreeModel瀵硅薄 + * + * @param factory + */ + public FactoryTreeModel(Factory factory) { + this.key = factory.getId(); + this.value = factory.getId(); + this.title = factory.getFactoryName(); + this.id = factory.getId(); + this.parentId = factory.getParentId(); + this.factoryName = factory.getFactoryName(); + this.sorter = factory.getSorter(); + this.factoryCode = factory.getFactoryCode(); + this.address = factory.getAddress(); + this.delFlag = factory.getDelFlag(); + this.createBy = factory.getCreateBy(); + this.createTime = factory.getCreateTime(); + this.updateBy = factory.getUpdateBy(); + this.updateTime = factory.getUpdateTime(); + this.mdcFlag = factory.getMdcFlag(); + } +} diff --git a/src/main/java/org/jeecg/modules/mdc/model/MdcEquipmentTree.java b/src/main/java/org/jeecg/modules/mdc/model/MdcEquipmentTree.java index 1e2740f..c825cc7 100644 --- a/src/main/java/org/jeecg/modules/mdc/model/MdcEquipmentTree.java +++ b/src/main/java/org/jeecg/modules/mdc/model/MdcEquipmentTree.java @@ -122,5 +122,18 @@ return this; } + /** + * 灏唌dcProductionTreeModel鐨勯儴鍒嗘暟鎹斁鍦ㄨ瀵硅薄褰撲腑 + * @param treeModel + * @return + */ + public MdcEquipmentTree convertByFactory(FactoryTreeModel treeModel) { + this.key = treeModel.getId(); + this.value = treeModel.getId(); + this.title = treeModel.getFactoryName(); + this.type = treeModel.getType(); + return this; + } + } diff --git a/src/main/java/org/jeecg/modules/mdc/rule/OrgCodeProRule.java b/src/main/java/org/jeecg/modules/mdc/rule/OrgCodeProRule.java deleted file mode 100644 index b8cf69a..0000000 --- a/src/main/java/org/jeecg/modules/mdc/rule/OrgCodeProRule.java +++ /dev/null @@ -1,98 +0,0 @@ -package org.jeecg.modules.mdc.rule; - -import com.alibaba.fastjson.JSONObject; -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import io.netty.util.internal.StringUtil; -import org.jeecg.common.handler.IFillRuleHandler; -import org.jeecg.common.util.SpringContextUtils; -import org.jeecg.common.util.YouBianCodeUtil; -import org.jeecg.modules.mdc.entity.MdcProduction; -import org.jeecg.modules.mdc.service.IMdcProductionService; - -import java.util.ArrayList; -import java.util.List; - -/** - * @author: LiuS - * @create: 2023-07-04 16:15 - * @Description: 杞﹂棿鏈烘瀯缂栫爜鐢熸垚瑙勫垯 - */ -public class OrgCodeProRule implements IFillRuleHandler { - - @Override - public Object execute(JSONObject params, JSONObject formData) { - IMdcProductionService mdcProductionService = (IMdcProductionService) SpringContextUtils.getBean("mdcProductionServiceImpl"); - - LambdaQueryWrapper<MdcProduction> query = new LambdaQueryWrapper<MdcProduction>(); - LambdaQueryWrapper<MdcProduction> query1 = new LambdaQueryWrapper<MdcProduction>(); - // 鍒涘缓涓�涓狶ist闆嗗悎,瀛樺偍鏌ヨ杩斿洖鐨勬墍鏈塎dcProduction瀵硅薄 - List<MdcProduction> mdcProductionList = new ArrayList<>(); - String[] strArray = new String[2]; - //瀹氫箟杞﹂棿绫诲瀷 - String orgType = ""; - // 瀹氫箟鏂扮紪鐮佸瓧绗︿覆 - String newOrgCode = ""; - // 瀹氫箟鏃х紪鐮佸瓧绗︿覆 - String oldOrgCode = ""; - - String parentId = null; - if (formData != null && formData.size() > 0) { - Object obj = formData.get("parentId"); - if (obj != null) { - parentId = obj.toString(); - } - } else { - if (params != null) { - Object obj = params.get("parentId"); - if (obj != null) { - parentId = obj.toString(); - } - } - } - - //濡傛灉鏄渶楂樼骇,鍒欐煡璇㈠嚭鍚岀骇鐨刼rg_code, 璋冪敤宸ュ叿绫荤敓鎴愮紪鐮佸苟杩斿洖 - if (StringUtil.isNullOrEmpty(parentId)) { - // 绾垮垽鏂暟鎹簱涓殑琛ㄦ槸鍚︿负绌�,绌哄垯鐩存帴杩斿洖鍒濆缂栫爜 - query1.eq(MdcProduction::getParentId, "").or().isNull(MdcProduction::getParentId); - query1.orderByDesc(MdcProduction::getOrgCode); - mdcProductionList = mdcProductionService.list(query1); - if (mdcProductionList == null || mdcProductionList.size() == 0) { - strArray[0] = YouBianCodeUtil.getNextYouBianCode(null); - strArray[1] = "1"; - return strArray; - } else { - MdcProduction mdcProduction = mdcProductionList.get(0); - oldOrgCode = mdcProduction.getOrgCode(); - orgType = mdcProduction.getOrgType(); - newOrgCode = YouBianCodeUtil.getNextYouBianCode(oldOrgCode); - } - } else {//鍙嶄箣鍒欐煡璇㈠嚭鎵�鏈夊悓绾х殑杞﹂棿,鑾峰彇缁撴灉鍚庢湁涓ょ鎯呭喌,鏈夊悓绾у拰娌℃湁鍚岀骇 - // 灏佽鏌ヨ鍚岀骇鐨勬潯浠� - query.eq(MdcProduction::getParentId, parentId); - // 闄嶅簭鎺掑簭 - query.orderByDesc(MdcProduction::getOrgCode); - // 鏌ヨ鍑哄悓绾т骇绾跨殑闆嗗悎 - List<MdcProduction> parentList = mdcProductionService.list(query); - // 鏌ヨ鍑虹埗绾т骇绾� - MdcProduction production = mdcProductionService.getById(parentId); - // 鑾峰彇鐖剁骇浜х嚎鐨刢ode - String parentCode = production.getOrgCode(); - // 鏍规嵁鐖剁骇浜х嚎绫诲瀷绠楀嚭褰撳墠浜х嚎鐨勭被鍨� - orgType = String.valueOf(Integer.valueOf(production.getOrgType()) + 1); - // 澶勭悊鍚岀骇浜х嚎涓簄ull鐨勬儏鍐� - if (parentList == null || parentList.size() == 0) { - // 鐩存帴鐢熸垚褰撳墠鐨勪骇绾跨紪鐮佸苟杩斿洖 - newOrgCode = YouBianCodeUtil.getSubYouBianCode(parentCode, null); - } else { //澶勭悊鏈夊悓绾т骇绾跨殑鎯呭喌 - // 鑾峰彇鍚岀骇浜х嚎鐨勭紪鐮�,鍒╃敤宸ュ叿绫� - String subCode = parentList.get(0).getOrgCode(); - // 杩斿洖鐢熸垚鐨勫綋鍓嶄骇绾跨紪鐮� - newOrgCode = YouBianCodeUtil.getSubYouBianCode(parentCode, subCode); - } - } - // 杩斿洖鏈�缁堝皝瑁呬簡浜х嚎缂栫爜鍜屼骇绾跨被鍨嬬殑鏁扮粍 - strArray[0] = newOrgCode; - strArray[1] = orgType; - return strArray; - } -} diff --git a/src/main/java/org/jeecg/modules/mdc/service/IFactoryEquipmentService.java b/src/main/java/org/jeecg/modules/mdc/service/IFactoryEquipmentService.java new file mode 100644 index 0000000..2173a5a --- /dev/null +++ b/src/main/java/org/jeecg/modules/mdc/service/IFactoryEquipmentService.java @@ -0,0 +1,30 @@ +package org.jeecg.modules.mdc.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import org.jeecg.modules.base.model.FactoryIdModel; +import org.jeecg.modules.mdc.entity.MdcEquipment; +import org.jeecg.modules.mdc.entity.FactoryEquipment; + +import java.util.List; + +/** + * @author: LiuS + * @create: 2023-03-28 10:30 + */ +public interface IFactoryEquipmentService extends IService<FactoryEquipment> { + + /** + * 鏍规嵁鎸囧畾璁惧id鏌ヨ浜х嚎淇℃伅 + */ + List<FactoryIdModel> queryFactoryIdsOfEquipment(String equipmentId); + + /** + * 鏍规嵁鎸囧畾浜х嚎id鏌ヨ璁惧淇℃伅 + */ + List<MdcEquipment> queryEquipmentsOfFactory(String factoryId); + + /** + * 鏍规嵁鎸囧畾浜х嚎ids鏌ヨ璁惧淇℃伅 + */ + List<MdcEquipment> queryEquipmentsOfFactorys(List<String> factoryIds); +} diff --git a/src/main/java/org/jeecg/modules/mdc/service/IMdcEquipmentFaultInfoService.java b/src/main/java/org/jeecg/modules/mdc/service/IMdcEquipmentFaultInfoService.java deleted file mode 100644 index d8f63a3..0000000 --- a/src/main/java/org/jeecg/modules/mdc/service/IMdcEquipmentFaultInfoService.java +++ /dev/null @@ -1,19 +0,0 @@ -package org.jeecg.modules.mdc.service; - -import com.baomidou.mybatisplus.extension.service.IService; -import org.jeecg.modules.mdc.entity.MdcEquipmentFaultInfo; - -/** - * @Description: 鏁呴殰鐜囪〃 - * @Author: Lius - * @Date: 2025-06-16 - * @Version: V1.0 - */ -public interface IMdcEquipmentFaultInfoService extends IService<MdcEquipmentFaultInfo> { - - /** - * 缁熻鏁呴殰鏃堕暱锛岃绠楁晠闅滅巼 - * @param parameter - */ - void runningAllEquFaultStatistical(String parameter); -} diff --git a/src/main/java/org/jeecg/modules/mdc/service/IMdcEquipmentService.java b/src/main/java/org/jeecg/modules/mdc/service/IMdcEquipmentService.java index f3493f9..51f4341 100644 --- a/src/main/java/org/jeecg/modules/mdc/service/IMdcEquipmentService.java +++ b/src/main/java/org/jeecg/modules/mdc/service/IMdcEquipmentService.java @@ -88,15 +88,15 @@ */ void removeEquipmentsForDepart(String departId, List<String> equipmentIdList); - /** - * 绉婚櫎璁惧鍜屼骇绾垮叧绯� - */ - void removeEquipmentForProduction(String productionId, String equipmentId); +// /** +// * 绉婚櫎璁惧鍜屼骇绾垮叧绯� +// */ +// void removeEquipmentForProduction(String productionId, String equipmentId); - /** - * 鎵归噺绉婚櫎浜х嚎鍜岃澶囧叧绯� - */ - void removeEquipmentsForProduction(String productionId, List<String> equipmentIdList); +// /** +// * 鎵归噺绉婚櫎浜х嚎鍜岃澶囧叧绯� +// */ +// void removeEquipmentsForProduction(String productionId, List<String> equipmentIdList); /** * 鍔犺浇閮ㄩ棬璁惧鏍� @@ -192,13 +192,13 @@ */ List<MdcEquipment> exportXlsList(MdcEquipmentVo mdcEquipment); - /** - * 閫氳繃杞﹂棿ids鑾峰彇璁惧鏍� - * - * @param ids - * @return - */ - List<MdcEquipmentTree> loadTreeListByProductionIds(String ids); +// /** +// * 閫氳繃杞﹂棿ids鑾峰彇璁惧鏍� +// * +// * @param ids +// * @return +// */ +// List<MdcEquipmentTree> loadTreeListByProductionIds(String ids); /** * 鏌ヨ鍗曡〃鏁版嵁 diff --git a/src/main/java/org/jeecg/modules/mdc/service/IMdcHomeService.java b/src/main/java/org/jeecg/modules/mdc/service/IMdcHomeService.java deleted file mode 100644 index cadcb5a..0000000 --- a/src/main/java/org/jeecg/modules/mdc/service/IMdcHomeService.java +++ /dev/null @@ -1,75 +0,0 @@ -package org.jeecg.modules.mdc.service; - -import org.jeecg.modules.mdc.dto.MdcEquipmentDto; -import org.jeecg.modules.mdc.entity.MdcEquipment; -import org.jeecg.modules.mdc.entity.MdcFeedback; -import org.jeecg.modules.mdc.entity.MdcOverallEquipmentEfficiency; -import org.jeecg.modules.mdc.vo.MdcCommonVo; -import org.jeecg.modules.mdc.vo.MdcHomeEfficiencyVo; - -import java.util.List; -import java.util.Map; - -/** - * @author Lius - * @date 2024/3/14 9:51 - */ -public interface IMdcHomeService { - - /** - * 璁惧杩愯鐘舵�佺粺璁� - */ - List<MdcCommonVo> getEquipmentStatusStatistics(String userId, String key); - - /** - * 璁惧鍒╃敤鐜囩粺璁� - */ - List<MdcCommonVo> getEquipmentUtilizationStatistics(String userId, String key); - - /** - * 璁惧OEE缁熻 - */ - List<MdcCommonVo> getEquipmentOeeStatistics(String userId, String key); - - /** - * 璁惧OEE鍜屽埄鐢ㄧ巼缁熻鏌辩姸鍥� - */ - Map<String, Object> getEquipmentMonthStatistics(String userId, String key); - - /** - * 宸ユ绾у墠涓冨ぉ鍒╃敤鐜囨姌绾垮浘 - */ - Map<String, Object> getEquipmentDayUtilizationStatistics(String userId, String key); - - /** - * 鏌ヨ璁惧涓婃湀OEE - */ - List<MdcOverallEquipmentEfficiency> getEquipmentOEEMonthStatistics(String userId, String key); - - /** - * 宸ユ绾ц澶囨晥鐜� - */ - MdcHomeEfficiencyVo getEquipmentEfficiencyStatistics(String userId, String key); - - /** - * 璁惧绾ф晥鐜囩粺璁� - */ - MdcHomeEfficiencyVo getEquipmentLevelEfficiencyStatistics(String equipmentId); - - /** - * 璁惧绾ф暣骞村害鍒╃敤鐜囧拰OEE - */ - Map<String, Object> getEquipmentAnnualEfficiencyStatistics(String equipmentId); - - /** - * 鏍规嵁杞﹂棿id鑾峰彇璁惧鍒楄〃 - */ - List<MdcEquipment> getEquipmentList(String key); - - /** - * 鏌ヨ璁惧杩愯淇℃伅 - */ - MdcEquipmentDto getEquipmentDetails(String equipmentId); - - List<MdcFeedback> getFeedbackList(String key); -} diff --git a/src/main/java/org/jeecg/modules/mdc/service/IMdcProductionService.java b/src/main/java/org/jeecg/modules/mdc/service/IMdcProductionService.java deleted file mode 100644 index c89ed56..0000000 --- a/src/main/java/org/jeecg/modules/mdc/service/IMdcProductionService.java +++ /dev/null @@ -1,195 +0,0 @@ -package org.jeecg.modules.mdc.service; - -import com.baomidou.mybatisplus.extension.service.IService; -import org.jeecg.modules.mdc.entity.MdcProduction; -import org.jeecg.modules.mdc.model.MdcProductionTreeModel; -import org.jeecg.modules.mdc.model.ProductionIdModel; -import org.jeecg.modules.mdc.vo.MdcProOptionsVo; - -import java.util.List; -import java.util.Map; - -/** - * @Description: 浜х嚎琛� - * @Author: liuS - * @Date: 2023-03-23 - * @Version: V1.0 - */ -public interface IMdcProductionService extends IService<MdcProduction> { - - /** - * 鏌ヨ鎵�鏈変骇绾夸俊鎭紝骞跺垎鑺傜偣杩涜鏄剧ず - */ - List<MdcProductionTreeModel> queryTreeList(); - - /** - * 鏌ヨ鎵�鏈変骇绾夸俊鎭紝骞跺垎鑺傜偣杩涜鏄剧ず(娣诲姞绯荤粺閰嶇疆) - */ - List<MdcProductionTreeModel> queryTreeListByConfig(); - - /** - * 鏌ヨ鎵�鏈変骇绾夸俊鎭紝骞跺垎鑺傜偣杩涜鏄剧ず - */ - List<MdcProductionTreeModel> queryTreeList(String ids); - - /** - * 鏌ヨ鎵�鏈夐儴闂―epartId淇℃伅,骞跺垎鑺傜偣杩涜鏄剧ず - */ - List<ProductionIdModel> queryProductionIdTreeList(); - - /** - * 鏍规嵁鍏抽敭瀛楁悳绱㈢浉鍏崇殑浜х嚎鏁版嵁 - */ - List<MdcProductionTreeModel> searchByKeyWord(String keyWord); - - /** - * 淇濆瓨浜х嚎鏁版嵁 - */ - void saveProductionData(MdcProduction mdcProduction); - - /** - * 鏇存柊浜х嚎鏁版嵁 - */ - boolean updateProductionDataById(MdcProduction mdcProduction); - - /** - * 鏍规嵁浜х嚎id鍒犻櫎骞跺垹闄ゅ叾鍙兘瀛樺湪鐨勫瓙绾т骇绾� - */ - boolean delete(String id); - - /** - * 鏍规嵁浜х嚎id鎵归噺鍒犻櫎骞跺垹闄ゅ叾鍙兘瀛樺湪鐨勫瓙绾т骇绾� - */ - void deleteBatchWithChildren(List<String> ids); - - /** - * 鑾峰彇涓嬬骇浜х嚎 - */ - List<MdcProduction> queryProdByPid(String pid); - - /** - * 閫掑綊鏌ヨ鎵�鏈夊瓙鑺傜偣 - */ - List<MdcProduction> recursionChildrenByPid(String pid); - - /** - * 鏍规嵁鐢ㄦ埛id鑾峰彇浜х嚎涓嬫媺鏍戦�夐」 - */ - List<ProductionIdModel> loadProductionTreeOptions(String userId); - - /** - * 閫掑綊鏌ヨ鎵�鏈夊瓙鑺傜偣 - */ - List<String> recursionChildren(String productionId); - - /** - * 鏍规嵁鐢ㄦ埛id鍜岃溅闂磇d鑾峰彇鐢ㄦ埛鎷ユ湁鐨勮溅闂磇d - * - * @param userId - * @param productionId - * @return - */ - String findFirstProduction(String userId, String productionId); - - /** - * 鏍规嵁鐢ㄦ埛id鏌ヨ鐢ㄦ埛宸ユ鏉冮檺 - */ - String findThreeProductionId(String userId); - - /** - * 鏌ヨ鎵�鏈夌埗鑺傜偣鍜屾湰鑺傜偣鍚嶇О - * @param id - * @return - */ - List<String> findListParentTreeAll(String id); - - /** - * 鏌ヨ鎵�鏈夌埗鑺傜偣鍚嶇О - * @param parentId - * @param stringList - * @return - */ - List<String> findListParentTree(String parentId,List<String> stringList); - - /** - * 鑾峰彇鐢ㄦ埛鎵�鍦ㄧ殑閮ㄩ棬 - * @param userId - * @return - */ - Map<String, MdcProduction> getUserAssignedDepart(String userId); - - /** - * 閫氳繃涓�缁刬d鑾峰彇閮ㄩ棬 - * @param ids - * @return - */ - List<String> findAllProductionIds(List<String> ids); - - /** - * 鑾峰彇鏌愪釜鑺傜偣鎵�鏈変笂绾ц妭鐐圭殑id - * @param parentId 鐖惰妭鐐� id - * @param idList 鎺ユ敹缁撴灉闆� - * @return - */ - List<String> findParentIdsForProduction(String parentId, List<String> idList); - - /** - * 鏌ヨ鎵�鏈変骇绾夸俊鎭紝骞跺垎鑺傜偣杩涜鏄剧ず - */ - List<MdcProductionTreeModel> queryTreeListByMdc(String ids); - - /** - * 鏌ヨ鎵�鏈変骇绾夸俊鎭紝骞跺垎鑺傜偣杩涜鏄剧ず - */ - List<MdcProductionTreeModel> queryTreeListByMdc(); - - /** - * 鏌ヨ瀛愯妭鐐� - * @param mdcProductionIds - * @return - */ - List<String> findChildren(List<String> mdcProductionIds); - - /** - * 鏍规嵁鐢ㄦ埛id鑾峰彇浜х嚎(涓績)鎴栫彮缁勪笅鎷夐�夐」 - * @param userId - * @param productionId - * @return - */ - List<MdcProOptionsVo> loadProductionOptions(String userId, String productionId); - - List<MdcProduction> findMdcPros(String userId, String productionId); - - /** - * - * @param userId - * @param productionId - * @return - */ - List<MdcProOptionsVo> loadTeamOptions(String userId, String productionId); - - /** - * - * @param userId - * @param allProductionIds - * @return - */ - List<String> findProIdsByUId(String userId, List<String> allProductionIds); - - /** - * - * @param productionId - * @return - */ - List<String> findChildByProId(String productionId); - - - String findProName(String equipmentId); - - /** - * 鏍规嵁浜х嚎orgCode鏌ヨ浜х嚎 - * @param orgCode - * @return - */ - MdcProduction findByOrgCode(String orgCode); -} diff --git a/src/main/java/org/jeecg/modules/mdc/service/IMdcUserProductionService.java b/src/main/java/org/jeecg/modules/mdc/service/IMdcUserProductionService.java deleted file mode 100644 index 1d08264..0000000 --- a/src/main/java/org/jeecg/modules/mdc/service/IMdcUserProductionService.java +++ /dev/null @@ -1,78 +0,0 @@ -package org.jeecg.modules.mdc.service; - -import com.baomidou.mybatisplus.extension.service.IService; -import org.jeecg.modules.mdc.entity.MdcUserProduction; -import org.jeecg.modules.mdc.model.ProductionIdModel; -import org.jeecg.modules.system.entity.SysUser; - -import java.util.List; - -/** - * @Description: 鐢ㄦ埛浜х嚎琛� - * @author: LiuS - * @create: 2023-03-27 11:56 - */ -public interface IMdcUserProductionService extends IService<MdcUserProduction> { - - /** - * 鏍规嵁鎸囧畾鐢ㄦ埛id鏌ヨ浜х嚎淇℃伅 - */ - List<ProductionIdModel> queryProductionIdsOfUser(String userId); - - /** - * 鏍规嵁鎸囧畾鐢ㄦ埛id鏌ヨ浜х嚎id闆嗗悎 - */ - List<String> queryProductionIdsByUserId(String userId); - - /** - * 鏍规嵁涓�缁勮溅闂磇d鏌ヨ鐢ㄦ埛浜х嚎淇℃伅 - * @param productionIds - */ - List<MdcUserProduction> queryByProductionIds(List<String> productionIds); - - /** - * 鍒犻櫎涓�缁勫璞� - * @param mdcUserProductions - * @return - */ - boolean removeByCollection(List<MdcUserProduction> mdcUserProductions); - - /** - * 鑾峰彇宸插垎閰嶇殑鐢ㄦ埛鍒楄〃 - * @param proId - * @return - */ - List<SysUser> getUserPermsByGroupId(String proId); - - /** - * 鑾峰彇鏈垎閰嶇殑鐢ㄦ埛鍒楄〃 - * @param proId - * @return - */ - List<SysUser> getUserNonPermsByGroupId(String proId); - - /** - * 鑾峰彇鏈垎閰嶇殑鐢ㄦ埛 - * @param proId - * @return - */ - List<SysUser> getUserNonPermsByDeviceId(String proId); - - /** - * 鑾峰彇宸插垎閰嶇殑鐢ㄦ埛 - * @param proId - * @return - */ - List<SysUser> getUserPermsByDeviceId(String proId); - - /** - * 閫氳繃杞﹂棿id涓庡矖浣峣d绛涢�夌敤鎴� - * @param post - * @param proId - * @return - */ - List<SysUser> queryByPostAndProId(String post, String proId); - - - MdcUserProduction getByUserIdAndGroupId(String userId, String proId); -} diff --git a/src/main/java/org/jeecg/modules/mdc/service/MdcEfficiencyReportService.java b/src/main/java/org/jeecg/modules/mdc/service/MdcEfficiencyReportService.java index 8d05858..c0a7294 100644 --- a/src/main/java/org/jeecg/modules/mdc/service/MdcEfficiencyReportService.java +++ b/src/main/java/org/jeecg/modules/mdc/service/MdcEfficiencyReportService.java @@ -105,11 +105,11 @@ */ List<BigDecimal> getEfficiencyRate(String equipmentId, String date); - Map<String, Object> equipmentEfficiencyAnalyze(String userId, EquEffVo equEffVo); - - Map<String, Object> teamEquipmentEfficiencyAnalyze(String userId, EquEffVo equEffVo); - - Map<String, Object> teamEfficiencyAnalyzeByMonth(String userId, EquEffVo equEffVo); - - Map<String, Object> comprehensiveRateAnalyze(String userId, EquEffVo vo); +// Map<String, Object> equipmentEfficiencyAnalyze(String userId, EquEffVo equEffVo); +// +// Map<String, Object> teamEquipmentEfficiencyAnalyze(String userId, EquEffVo equEffVo); +// +// Map<String, Object> teamEfficiencyAnalyzeByMonth(String userId, EquEffVo equEffVo); +// +// Map<String, Object> comprehensiveRateAnalyze(String userId, EquEffVo vo); } diff --git a/src/main/java/org/jeecg/modules/mdc/service/impl/FactoryEquipmentServiceImpl.java b/src/main/java/org/jeecg/modules/mdc/service/impl/FactoryEquipmentServiceImpl.java new file mode 100644 index 0000000..46c2c99 --- /dev/null +++ b/src/main/java/org/jeecg/modules/mdc/service/impl/FactoryEquipmentServiceImpl.java @@ -0,0 +1,87 @@ +package org.jeecg.modules.mdc.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.jeecg.modules.base.entity.Factory; +import org.jeecg.modules.base.model.FactoryIdModel; +import org.jeecg.modules.base.service.IFactoryService; +import org.jeecg.modules.mdc.entity.MdcEquipment; +import org.jeecg.modules.mdc.entity.FactoryEquipment; +import org.jeecg.modules.mdc.mapper.FactoryEquipmentMapper; +import org.jeecg.modules.mdc.service.IMdcEquipmentService; +import org.jeecg.modules.mdc.service.IFactoryEquipmentService; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; + +/** + * @author: LiuS + * @create: 2023-03-28 10:31 + */ +@Service +public class FactoryEquipmentServiceImpl extends ServiceImpl<FactoryEquipmentMapper, FactoryEquipment> implements IFactoryEquipmentService { + + @Resource + private IFactoryService mdcFactoryService; + @Resource + private IMdcEquipmentService mdcEquipmentService; + + /** + * 鏍规嵁璁惧id鏌ヨ浜х嚎淇℃伅 + */ + @Override + public List<FactoryIdModel> queryFactoryIdsOfEquipment(String equipmentId) { + LambdaQueryWrapper<FactoryEquipment> queryEquipmentFac = new LambdaQueryWrapper<>(); + LambdaQueryWrapper<Factory> queryFac = new LambdaQueryWrapper<>(); + try { + queryEquipmentFac.eq(FactoryEquipment::getEquipmentId, equipmentId); + List<String> facIdList = new ArrayList<>(); + List<FactoryIdModel> facIdModelList = new ArrayList<>(); + List<FactoryEquipment> equipmentProList = this.list(queryEquipmentFac); + if (equipmentProList != null && !equipmentProList.isEmpty()) { + for (FactoryEquipment factoryEquipment : equipmentProList) { + facIdList.add(factoryEquipment.getFactoryId()); + } + queryFac.in(Factory::getId, facIdList); + List<Factory> proList = mdcFactoryService.list(queryFac); + if (proList != null && !proList.isEmpty()) { + for (Factory mdcFactory : proList) { + facIdModelList.add(new FactoryIdModel().convertByUserFactory(mdcFactory)); + } + } + return facIdModelList; + } + } catch (Exception e) { + e.fillInStackTrace(); + } + return null; + } + /** + * 鏍规嵁鎸囧畾浜х嚎id鏌ヨ璁惧淇℃伅 + */ + @Override + public List<MdcEquipment> queryEquipmentsOfFactory(String factoryId){ + List<String> equipmentIds = this.list(new LambdaQueryWrapper<FactoryEquipment>().eq(FactoryEquipment::getFactoryId, factoryId)) + .stream().map(FactoryEquipment::getEquipmentId).collect(Collectors.toList()); + if (!equipmentIds.isEmpty()) { + return mdcEquipmentService.list(new LambdaQueryWrapper<MdcEquipment>().in(MdcEquipment::getId, equipmentIds)); + } + return null; + } + + /** + * 鏍规嵁鎸囧畾浜х嚎ids鏌ヨ璁惧淇℃伅 + */ + @Override + public List<MdcEquipment> queryEquipmentsOfFactorys(List<String> factoryIds){ + List<String> equipmentIds = this.list(new LambdaQueryWrapper<FactoryEquipment>() + .in(FactoryEquipment::getFactoryId, factoryIds)).stream().map(FactoryEquipment::getEquipmentId).collect(Collectors.toList()); + if (!equipmentIds.isEmpty()) { + return mdcEquipmentService.list(new LambdaQueryWrapper<MdcEquipment>().in(MdcEquipment::getId, equipmentIds)); + } + return null; + } +} diff --git a/src/main/java/org/jeecg/modules/mdc/service/impl/IMdcHomeServiceImpl.java b/src/main/java/org/jeecg/modules/mdc/service/impl/IMdcHomeServiceImpl.java deleted file mode 100644 index eec242f..0000000 --- a/src/main/java/org/jeecg/modules/mdc/service/impl/IMdcHomeServiceImpl.java +++ /dev/null @@ -1,506 +0,0 @@ -package org.jeecg.modules.mdc.service.impl; - -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.baomidou.mybatisplus.core.toolkit.StringUtils; -import org.jeecg.common.system.vo.DictModel; -import org.jeecg.modules.mdc.constant.MdcConstant; -import org.jeecg.modules.mdc.dto.MdcEquipmentDto; -import org.jeecg.modules.mdc.entity.*; -import org.jeecg.modules.mdc.mapper.MdcHomeMapper; -import org.jeecg.modules.mdc.service.*; -import org.jeecg.modules.mdc.util.DateUtils; -import org.jeecg.modules.mdc.vo.*; -import org.jeecg.modules.system.service.ISysDictService; -import org.springframework.stereotype.Service; - -import javax.annotation.Resource; -import java.math.BigDecimal; -import java.math.RoundingMode; -import java.time.LocalDate; -import java.util.*; - -/** - * @author Lius - * @date 2024/3/14 9:52 - */ -@Service -public class IMdcHomeServiceImpl implements IMdcHomeService { - - @Resource - private IMdcEquipmentService mdcEquipmentService; - - @Resource - private IEquipmentService equipmentService; - - @Resource - private ISysDictService sysDictService; - - @Resource - private IEquipmentWorkLineService equipmentWorkLineService; - - @Resource - private MdcHomeMapper mdcHomeMapper; - - @Resource - private IMdcProductionService mdcProductionService; - - @Resource - private IEquipmentLogService equipmentLogService; - - @Resource - private IMdcFeedbackService mdcFeedbackService; - - /** - * 璁惧杩愯鐘舵�佺粺璁� - */ - @Override - public List<MdcCommonVo> getEquipmentStatusStatistics(String userId, String key) { - List<MdcCommonVo> result = new ArrayList<>(); - MdcCommonVo mdcCommonVo1 = new MdcCommonVo(); - mdcCommonVo1.setName("鍏虫満"); - mdcCommonVo1.setValue("0"); - result.add(mdcCommonVo1); - MdcCommonVo mdcCommonVo2 = new MdcCommonVo(); - mdcCommonVo2.setName("鎶ヨ"); - mdcCommonVo2.setValue("0"); - result.add(mdcCommonVo2); - MdcCommonVo mdcCommonVo3 = new MdcCommonVo(); - mdcCommonVo3.setName("寰呮満"); - mdcCommonVo3.setValue("0"); - result.add(mdcCommonVo3); - MdcCommonVo mdcCommonVo4 = new MdcCommonVo(); - mdcCommonVo4.setName("杩愯"); - mdcCommonVo4.setValue("0"); - result.add(mdcCommonVo4); - MdcEquipmentStatusVo mdcEquipmentStatusVo = new MdcEquipmentStatusVo(); - if (StringUtils.isBlank(key)) { - return result; - } - List<String> equipmentIdList = mdcEquipmentService.getEquipmentIdsProduction(userId, key); - if (equipmentIdList == null || equipmentIdList.isEmpty()) { - return result; - } -// List<EquipmentLog> logList = equipmentLogService.getEquipmentStatusList(equipmentIdList); - List<Equipment> equipmentList = equipmentService.list(new LambdaQueryWrapper<Equipment>().in(Equipment::getEquipmentid, equipmentIdList)); - if (equipmentList != null && !equipmentList.isEmpty()) { - for (Equipment equipment : equipmentList) { - if (equipment.getOporation() != null) { - switch (equipment.getOporation()) { - case 1: - case 2: - mdcEquipmentStatusVo.setWaitCount(mdcEquipmentStatusVo.getWaitCount() + 1); - break; - case 3: - mdcEquipmentStatusVo.setRunCount(mdcEquipmentStatusVo.getRunCount() + 1); - break; - case 22: - mdcEquipmentStatusVo.setAlarmCount(mdcEquipmentStatusVo.getAlarmCount() + 1); - break; - default: - mdcEquipmentStatusVo.setCloseCount(mdcEquipmentStatusVo.getCloseCount() + 1); - break; - } - } else { - mdcEquipmentStatusVo.setCloseCount(mdcEquipmentStatusVo.getCloseCount() + 1); - } - } - } - result.clear(); - MdcCommonVo mdcCommonVo5 = new MdcCommonVo(); - mdcCommonVo5.setName("鍏虫満"); - mdcCommonVo5.setValue(mdcEquipmentStatusVo.getCloseCount().toString()); - result.add(mdcCommonVo5); - MdcCommonVo mdcCommonVo6 = new MdcCommonVo(); - mdcCommonVo6.setName("鎶ヨ"); - mdcCommonVo6.setValue(mdcEquipmentStatusVo.getAlarmCount().toString()); - result.add(mdcCommonVo6); - MdcCommonVo mdcCommonVo7 = new MdcCommonVo(); - mdcCommonVo7.setName("寰呮満"); - mdcCommonVo7.setValue(mdcEquipmentStatusVo.getWaitCount().toString()); - result.add(mdcCommonVo7); - MdcCommonVo mdcCommonVo8 = new MdcCommonVo(); - mdcCommonVo8.setName("杩愯"); - mdcCommonVo8.setValue(mdcEquipmentStatusVo.getRunCount().toString()); - result.add(mdcCommonVo8); - return result; - } - - /** - * 璁惧鍒╃敤鐜囩粺璁� - */ - @Override - public List<MdcCommonVo> getEquipmentUtilizationStatistics(String userId, String key) { - List<MdcCommonVo> result = new ArrayList<>(); - //鑾峰彇鍏徃鎴栧巶鍖轰簩绾т俊鎭� - List<MdcProduction> mdcProductionList = mdcHomeMapper.getProductionByPid(userId, key); - if (mdcProductionList != null && !mdcProductionList.isEmpty()) { - for (MdcProduction mdcProduction : mdcProductionList) { - MdcCommonVo mdcCommonVo = new MdcCommonVo(); - mdcCommonVo.setName(mdcProduction.getProductionName()); - mdcCommonVo.setProductionCode(mdcProduction.getProductionCode()); - mdcCommonVo.setProductionId(mdcProduction.getId()); - //鑾峰彇姝ゅ眰绾т笅璁惧 - List<String> equipmentIdList = mdcEquipmentService.getEquipmentIdsProduction(userId, mdcProduction.getId()); - if (equipmentIdList == null || equipmentIdList.isEmpty()) { - mdcCommonVo.setValue("0"); - } else { - String date = DateUtils.format(DateUtils.toDate(LocalDate.now().plusDays(-1).toString(), DateUtils.STR_DATE), DateUtils.STRDATE); - BigDecimal processCount = mdcHomeMapper.getProcessCount(equipmentIdList, date); - if (processCount == null || processCount.compareTo(BigDecimal.ZERO) == 0) { - mdcCommonVo.setValue("0"); - } else { - mdcCommonVo.setValue(processCount.divide(new BigDecimal("86400").multiply(new BigDecimal(equipmentIdList.size())), 4, RoundingMode.HALF_UP).multiply(new BigDecimal("100")).setScale(2, RoundingMode.HALF_UP).toString()); - } - } - result.add(mdcCommonVo); - } - } - if (!result.isEmpty()) { - result.sort(Comparator.comparing(MdcCommonVo::getValue).reversed()); - } - return result; - } - - /** - * 璁惧OEE缁熻 - */ - @Override - public List<MdcCommonVo> getEquipmentOeeStatistics(String userId, String key) { - List<MdcCommonVo> result = new ArrayList<>(); - //鑾峰彇鍏徃鎴栧巶鍖轰簩绾т俊鎭� - List<MdcProduction> mdcProductionList = mdcHomeMapper.getProductionByPid(userId, key); - if (mdcProductionList != null && !mdcProductionList.isEmpty()) { - for (MdcProduction mdcProduction : mdcProductionList) { - MdcCommonVo mdcCommonVo = new MdcCommonVo(); - mdcCommonVo.setName(mdcProduction.getProductionName()); - mdcCommonVo.setProductionCode(mdcProduction.getProductionCode()); - mdcCommonVo.setProductionId(mdcProduction.getId()); - //鑾峰彇姝ゅ眰绾т笅璁惧 - List<String> equipmentIdList = mdcEquipmentService.getEquipmentIdsProduction(userId, mdcProduction.getId()); - if (equipmentIdList == null || equipmentIdList.isEmpty()) { - mdcCommonVo.setValue("0"); - } else { - String date = DateUtils.format(DateUtils.toDate(LocalDate.now().plusMonths(-1).toString(), DateUtils.STR_DATE), DateUtils.STR_YEAR_MONTH); - BigDecimal oee = mdcHomeMapper.getOeeByDate(equipmentIdList, date); - if (oee == null || oee.compareTo(BigDecimal.ZERO) == 0) { - mdcCommonVo.setValue("0"); - } else { - mdcCommonVo.setValue(oee.divide(new BigDecimal(equipmentIdList.size()), 4, RoundingMode.HALF_UP).multiply(new BigDecimal("100")).setScale(2, RoundingMode.HALF_UP).toString()); - } - } - result.add(mdcCommonVo); - } - } - return result; - } - - /** - * 璁惧OEE鍜屽埄鐢ㄧ巼缁熻鏌辩姸鍥� - */ - @Override - public Map<String, Object> getEquipmentMonthStatistics(String userId, String key) { - List<String> equipmentIdList = mdcEquipmentService.getEquipmentIdsProduction(userId, key); - Map<String, Object> result = new HashMap<>(); - Date end = DateUtils.toDate(LocalDate.now().plusMonths(-1).toString(), DateUtils.STR_DATE); - Date start = DateUtils.toDate(LocalDate.now().plusMonths(-12).toString(), DateUtils.STR_DATE); - List<String> monthBetween = DateUtils.getMonthBetween(start, end); - List<String> dateList = new ArrayList<>(); - List<MdcCommonVo> utilizationList = new ArrayList<>(); - List<MdcCommonVo> oeeList = new ArrayList<>(); - for (String month : monthBetween) { - //鏃ユ湡闆嗗悎 - String name = month.substring(month.lastIndexOf("-") + 1).replaceFirst("^0*", "") + "鏈�"; - dateList.add(name); - //鍒╃敤鐜囧拰oee - MdcCommonVo mdcCommonUtilizationVo = new MdcCommonVo(); - mdcCommonUtilizationVo.setName(name); - MdcCommonVo mdcCommonOeeVo = new MdcCommonVo(); - mdcCommonOeeVo.setName(name); - if (equipmentIdList == null || equipmentIdList.isEmpty()) { - mdcCommonUtilizationVo.setValue("0"); - mdcCommonOeeVo.setValue("0"); - } else { - //鍒╃敤鐜� - Map<String, Object> resultMap = mdcHomeMapper.getUtilizationByMonth(equipmentIdList, month.replace("-", "")); - if (resultMap != null && resultMap.get("processLong") != null) { - BigDecimal processLong = BigDecimal.valueOf((Double) resultMap.get("processLong")); - BigDecimal processDay = new BigDecimal((Integer) resultMap.get("processDay")); - if (processLong.compareTo(BigDecimal.ZERO) == 0) { - mdcCommonUtilizationVo.setValue("0"); - } else { - mdcCommonUtilizationVo.setValue(processLong.divide(processDay.multiply(new BigDecimal("86400")), 4, RoundingMode.HALF_UP).multiply(new BigDecimal("100")).setScale(2, RoundingMode.HALF_UP).toString()); - } - } else { - mdcCommonUtilizationVo.setValue("0"); - } - - //OEE - BigDecimal oee = mdcHomeMapper.getOeeByDate(equipmentIdList, month); - if (oee == null || oee.compareTo(BigDecimal.ZERO) == 0) { - mdcCommonOeeVo.setValue("0"); - } else { - mdcCommonOeeVo.setValue(oee.divide(new BigDecimal(equipmentIdList.size()), 4, RoundingMode.HALF_UP).multiply(new BigDecimal("100")).setScale(2, RoundingMode.HALF_UP).toString()); - } - } - utilizationList.add(mdcCommonUtilizationVo); - oeeList.add(mdcCommonOeeVo); - } - result.put("dateList", dateList); - result.put("utilizationList", utilizationList); - result.put("oeeList", oeeList); - return result; - } - - /** - * 宸ユ绾у墠涓冨ぉ鍒╃敤鐜囨姌绾垮浘 - */ - @Override - public Map<String, Object> getEquipmentDayUtilizationStatistics(String userId, String key) { - Map<String, Object> result = new HashMap<>(); - List<String> equipmentIdList = mdcEquipmentService.getEquipmentIdsProduction(userId, key); - //鑾峰彇鍓嶄竷澶╂棩鏈熼泦鍚� - String start = DateUtils.format(DateUtils.toDate(LocalDate.now().plusDays(-7).toString(), DateUtils.STR_DATE), DateUtils.STRDATE); - String end = DateUtils.format(DateUtils.toDate(LocalDate.now().plusDays(-1).toString(), DateUtils.STR_DATE), DateUtils.STRDATE); - if (equipmentIdList != null && !equipmentIdList.isEmpty()) { - List<MdcEquipment> mdcEquipmentList = mdcEquipmentService.list(new LambdaQueryWrapper<MdcEquipment>().in(MdcEquipment::getEquipmentId, equipmentIdList)); - result.put("mdcEquipmentList", mdcEquipmentList); - List<MdcEquipmentStatisticalInfo> mdcEquipmentStatisticalInfoList = mdcHomeMapper.getEquipmentSevenUtilizationStatistics(equipmentIdList, start, end); - List<EquipmentDayUtilizationVo> dataList = new ArrayList<>(); - if (mdcEquipmentStatisticalInfoList != null && !mdcEquipmentStatisticalInfoList.isEmpty()) { - for (MdcEquipmentStatisticalInfo mdcEquipmentStatisticalInfo : mdcEquipmentStatisticalInfoList) { - EquipmentDayUtilizationVo equipmentDayUtilizationVo = new EquipmentDayUtilizationVo(); - equipmentDayUtilizationVo.setEquipmentId(mdcEquipmentStatisticalInfo.getEquipmentId()); - equipmentDayUtilizationVo.setUtilizationRate(mdcEquipmentStatisticalInfo.getProcessLong().divide(new BigDecimal("864"), 4, RoundingMode.HALF_UP).divide(new BigDecimal(mdcEquipmentStatisticalInfoList.size()), 4, RoundingMode.HALF_UP).setScale(2, RoundingMode.HALF_UP)); - if (BigDecimal.ZERO.compareTo(mdcEquipmentStatisticalInfo.getOpenLong()) == -1) { - equipmentDayUtilizationVo.setOpenRate(mdcEquipmentStatisticalInfo.getProcessLong().divide(mdcEquipmentStatisticalInfo.getOpenLong(), 4, RoundingMode.HALF_UP).multiply(new BigDecimal("100")).setScale(2, RoundingMode.HALF_UP)); - equipmentDayUtilizationVo.setStartRate(mdcEquipmentStatisticalInfo.getOpenLong().divide(new BigDecimal("864"), 4, RoundingMode.HALF_UP).divide(new BigDecimal(mdcEquipmentStatisticalInfoList.size()), 4, RoundingMode.HALF_UP).setScale(2, RoundingMode.HALF_UP)); - } - dataList.add(equipmentDayUtilizationVo); - } - } - result.put("dataList", dataList); - } - /*List<String> dayBetween = DateUtils.getDatesStringList2(start, end); - List<String> dateList = new ArrayList<>(); - List<EquipmentDayUtilizationVo> dataList = new ArrayList<>(); - for (String date : dayBetween) { - EquipmentDayUtilizationVo equipmentDayUtilizationVo = new EquipmentDayUtilizationVo(); - String item = date.substring(4); - if (item.startsWith("0")) { - item = item.substring(1); - String sub = item.substring(1); - if (sub.startsWith("0")) { - item = item.substring(0, 1) + "鏈�" + sub.substring(1) + "鏃�"; - } else { - item = item.substring(0, 1) + "鏈�" + item.substring(1) + "鏃�"; - } - } else { - String sub = item.substring(2); - if (sub.startsWith("0")) { - item = item.substring(0, 2) + "鏈�" + sub.substring(2) + "鏃�"; - } else { - item = item.substring(0, 2) + "鏈�" + item.substring(2) + "鏃�"; - } - } - dateList.add(item); - equipmentDayUtilizationVo.setDate(item); - if (equipmentIdList != null && !equipmentIdList.isEmpty()) { - //鑾峰彇鍓嶄竷澶╁埄鐢ㄧ巼鏁版嵁 - List<MdcEquipmentStatisticalInfo> mdcEquipmentStatisticalInfos = mdcHomeMapper.getEquipmentDayUtilizationStatistics(equipmentIdList, dayBetween); - if (mdcEquipmentStatisticalInfos != null && !mdcEquipmentStatisticalInfos.isEmpty()) { - for (MdcEquipmentStatisticalInfo mdcEquipmentStatisticalInfo : mdcEquipmentStatisticalInfos) { - if (mdcEquipmentStatisticalInfo.getTheDate().equals(date)) { - equipmentDayUtilizationVo.setUtilizationRate(mdcEquipmentStatisticalInfo.getProcessLong().divide(new BigDecimal("864"), 4, RoundingMode.HALF_UP).divide(new BigDecimal(equipmentIdList.size()), 4, RoundingMode.HALF_UP).setScale(2, RoundingMode.HALF_UP)); - if (BigDecimal.ZERO.compareTo(mdcEquipmentStatisticalInfo.getOpenLong()) == -1) { - equipmentDayUtilizationVo.setOpenRate(mdcEquipmentStatisticalInfo.getProcessLong().divide(mdcEquipmentStatisticalInfo.getOpenLong(), 4, RoundingMode.HALF_UP).multiply(new BigDecimal("100")).setScale(2, RoundingMode.HALF_UP)); - equipmentDayUtilizationVo.setStartRate(mdcEquipmentStatisticalInfo.getOpenLong().divide(new BigDecimal("864"), 4, RoundingMode.HALF_UP).divide(new BigDecimal(equipmentIdList.size()), 4, RoundingMode.HALF_UP).setScale(2, RoundingMode.HALF_UP)); - } - } - } - } else { - dataList.add(equipmentDayUtilizationVo); - } - } else { - dataList.add(equipmentDayUtilizationVo); - } - } - result.put("dateList", dateList); - result.put("dataList", dataList);*/ - return result; - } - - /** - * 鏌ヨ璁惧涓婃湀OEE - */ - @Override - public List<MdcOverallEquipmentEfficiency> getEquipmentOEEMonthStatistics(String userId, String key) { - List<MdcOverallEquipmentEfficiency> result = new ArrayList<>(); - List<String> equipmentIdList = mdcEquipmentService.getEquipmentIdsProduction(userId, key); - if (equipmentIdList != null && !equipmentIdList.isEmpty()) { - String validDate = DateUtils.format(DateUtils.toDate(LocalDate.now().plusMonths(-1).toString(), DateUtils.STR_DATE), DateUtils.STR_YEAR_MONTH); - result = mdcHomeMapper.getEquipmentOEEMonthStatistics(validDate, equipmentIdList); - } - return result; - } - - /** - * 宸ユ绾ц澶囨晥鐜� - */ - @Override - public MdcHomeEfficiencyVo getEquipmentEfficiencyStatistics(String userId, String key) { - MdcHomeEfficiencyVo result = new MdcHomeEfficiencyVo(); - result.setProductionId(key); - MdcProduction mdcProduction = mdcProductionService.getById(key); - result.setProductionName(mdcProduction.getProductionName()); - List<String> equipmentIdList = mdcEquipmentService.getEquipmentIdsProduction(userId, key); - if (equipmentIdList != null && !equipmentIdList.isEmpty()) { - // 鑾峰彇鍒╃敤鐜囨暟鎹� - String date = DateUtils.format(DateUtils.toDate(LocalDate.now().plusDays(-1).toString(), DateUtils.STR_DATE), DateUtils.STRDATE); - MdcEquipmentStatisticalInfo mdcEquipmentStatisticalInfo = mdcHomeMapper.getUtilizationByDay(equipmentIdList, date); - if (mdcEquipmentStatisticalInfo != null) { - result.setUtilizationRate(mdcEquipmentStatisticalInfo.getProcessLong().divide(new BigDecimal("864"), 4, RoundingMode.HALF_UP).divide(new BigDecimal(equipmentIdList.size()), 4, RoundingMode.HALF_UP).setScale(2, RoundingMode.HALF_UP)); - if (BigDecimal.ZERO.compareTo(mdcEquipmentStatisticalInfo.getOpenLong()) == -1) { - result.setOpenRate(mdcEquipmentStatisticalInfo.getProcessLong().divide(mdcEquipmentStatisticalInfo.getOpenLong(), 4, RoundingMode.HALF_UP).multiply(new BigDecimal("100")).setScale(2, RoundingMode.HALF_UP)); - result.setStartRate(mdcEquipmentStatisticalInfo.getOpenLong().divide(new BigDecimal("864"), 4, RoundingMode.HALF_UP).divide(new BigDecimal(equipmentIdList.size()), 4, RoundingMode.HALF_UP).setScale(2, RoundingMode.HALF_UP)); - } - } - //鑾峰彇OEE鏁版嵁 - String month = DateUtils.format(DateUtils.toDate(LocalDate.now().plusMonths(-1).toString(), DateUtils.STR_DATE), DateUtils.STR_YEAR_MONTH); - BigDecimal oee = mdcHomeMapper.getOeeByDate(equipmentIdList, month); - if (oee == null || oee.compareTo(BigDecimal.ZERO) == 0) { - result.setOverallEquipmentEfficiency(BigDecimal.ZERO); - } else { - result.setOverallEquipmentEfficiency(oee.divide(new BigDecimal(equipmentIdList.size()), 4, RoundingMode.HALF_UP).multiply(new BigDecimal("100")).setScale(2, RoundingMode.HALF_UP)); - } - } - return result; - } - - /** - * 璁惧绾ф晥鐜囩粺璁� - */ - @Override - public MdcHomeEfficiencyVo getEquipmentLevelEfficiencyStatistics(String equipmentId) { - MdcEquipment mdcEquipment = mdcEquipmentService.getOne(new LambdaQueryWrapper<MdcEquipment>().eq(MdcEquipment::getEquipmentId, equipmentId)); - if (mdcEquipment == null) { - return null; - } - MdcHomeEfficiencyVo result = new MdcHomeEfficiencyVo(); - String date = DateUtils.format(DateUtils.toDate(LocalDate.now().plusDays(-1).toString(), DateUtils.STR_DATE), DateUtils.STRDATE); - MdcEquipmentStatisticalInfo mdcEquipmentStatisticalInfo = mdcHomeMapper.getUtilizationByDay(Arrays.asList(equipmentId.split(",")), date); - if (mdcEquipmentStatisticalInfo != null) { - result.setUtilizationRate(mdcEquipmentStatisticalInfo.getProcessLong().divide(new BigDecimal("864"), 4, RoundingMode.HALF_UP).setScale(2, RoundingMode.HALF_UP)); - if (BigDecimal.ZERO.compareTo(mdcEquipmentStatisticalInfo.getOpenLong()) == -1) { - result.setOpenRate(mdcEquipmentStatisticalInfo.getProcessLong().divide(mdcEquipmentStatisticalInfo.getOpenLong(), 4, RoundingMode.HALF_UP).multiply(new BigDecimal("100")).setScale(2, RoundingMode.HALF_UP)); - result.setStartRate(mdcEquipmentStatisticalInfo.getOpenLong().divide(new BigDecimal("864"), 4, RoundingMode.HALF_UP).setScale(2, RoundingMode.HALF_UP)); - } - } - //鑾峰彇OEE鏁版嵁 - String month = DateUtils.format(DateUtils.toDate(LocalDate.now().plusMonths(-1).toString(), DateUtils.STR_DATE), DateUtils.STR_YEAR_MONTH); - BigDecimal oee = mdcHomeMapper.getOeeByDate(Arrays.asList(equipmentId.split(",")), month); - if (oee == null || oee.compareTo(BigDecimal.ZERO) == 0) { - result.setOverallEquipmentEfficiency(BigDecimal.ZERO); - } else { - result.setOverallEquipmentEfficiency(oee.multiply(new BigDecimal("100")).setScale(2, RoundingMode.HALF_UP)); - } - return result; - } - - /** - * 璁惧绾ф暣骞村害鍒╃敤鐜� - */ - @Override - public Map<String, Object> getEquipmentAnnualEfficiencyStatistics(String equipmentId) { - MdcEquipment mdcEquipment = mdcEquipmentService.getOne(new LambdaQueryWrapper<MdcEquipment>().eq(MdcEquipment::getEquipmentId, equipmentId)); - if (mdcEquipment == null) { - return null; - } - Map<String, Object> result = new HashMap<>(); - Date end = DateUtils.toDate(LocalDate.now().plusMonths(-1).toString(), DateUtils.STR_DATE); - Date start = DateUtils.toDate(LocalDate.now().plusMonths(-12).toString(), DateUtils.STR_DATE); - List<String> monthBetween = DateUtils.getMonthBetween(start, end); - List<String> dateList = new ArrayList<>(); - List<MdcHomeEquipmentVo> dataList = new ArrayList<>(); - for (String month : monthBetween) { - String name = month.substring(month.lastIndexOf("-") + 1).replaceFirst("^0*", "") + "鏈�"; - dateList.add(name); - //鍒╃敤鐜囧拰oee - MdcHomeEquipmentVo mdcHomeEquipmentVo = new MdcHomeEquipmentVo(); - mdcHomeEquipmentVo.setMonth(name); - //鍒╃敤鐜� - Map<String, Object> resultMap = mdcHomeMapper.getUtilizationByMonth(Arrays.asList(equipmentId.split(",")), month.replace("-", "")); - if (resultMap != null && resultMap.get("processLong") != null) { - BigDecimal processLong = BigDecimal.valueOf((Double) resultMap.get("processLong")); - BigDecimal openLong = BigDecimal.valueOf((Double) resultMap.get("openLong")); - BigDecimal processDay = new BigDecimal((Integer) resultMap.get("processDay")); - if (BigDecimal.ZERO.compareTo(processLong) == -1) { - mdcHomeEquipmentVo.setUtilizationRate(processLong.divide(processDay.multiply(new BigDecimal("86400")), 4, RoundingMode.HALF_UP).multiply(new BigDecimal("100")).setScale(2, RoundingMode.HALF_UP)); - if (BigDecimal.ZERO.compareTo(openLong) == -1) { - mdcHomeEquipmentVo.setStartRate(openLong.divide(new BigDecimal("86400"), 4, RoundingMode.HALF_UP).setScale(2, RoundingMode.HALF_UP)); - mdcHomeEquipmentVo.setOpenRate(processDay.divide(openLong, 4, RoundingMode.HALF_UP).multiply(new BigDecimal("100")).setScale(2, RoundingMode.HALF_UP)); - } - } - } - - //OEE - BigDecimal oee = mdcHomeMapper.getOeeByDate(Arrays.asList(equipmentId.split(",")), month); - if (oee != null && !(oee.compareTo(BigDecimal.ZERO) == 0)) { - mdcHomeEquipmentVo.setOverallEquipmentEfficiency(oee.multiply(new BigDecimal("100")).setScale(2, RoundingMode.HALF_UP)); - } - dataList.add(mdcHomeEquipmentVo); - } - result.put("dateList", dateList); - result.put("dataList", dataList); - return result; - } - - /** - * 璁惧绾ц澶囧垪琛� - */ - @Override - public List<MdcEquipment> getEquipmentList(String key) { - return mdcHomeMapper.getEquipmentList(key); - } - - @Override - public MdcEquipmentDto getEquipmentDetails(String equipmentId) { - MdcEquipment mdcEquipment = mdcEquipmentService.getOne(new LambdaQueryWrapper<MdcEquipment>().eq(MdcEquipment::getEquipmentId, equipmentId)); - List<DictModel> dictModelList = sysDictService.queryEnableDictItemsByCode(MdcConstant.SERIA_TYPE); - if (dictModelList != null && !dictModelList.isEmpty()) { - for (DictModel dictModel : dictModelList) { - if (dictModel.getValue().equals(mdcEquipment.getDriveType())) { - return null; - } - } - } - String saveTableName = mdcEquipment.getSaveTableName(); - MdcEquipmentDto dto = equipmentWorkLineService.getMacingDataList(saveTableName); - if (dto != null) { - if ("LSV2".equals(mdcEquipment.getDriveType())) { - dto.setSpindlebeilv(dto.getSFeed()); - dto.setFeedbeilv(dto.getFFeed()); - dto.setRapidfeed(dto.getRapidfeed()); - dto.setNCVersion(dto.getNCVersion()); - dto.setTNCVersion(dto.getTNCVersion()); - dto.setOPTVersion(dto.getOPTVersion()); - dto.setPLCVersion(dto.getPLCVersion()); - } - // 鏌ヨ璁惧鐘舵�� - EquipmentLog equipmentLog = equipmentLogService.selectEquipmentOporation(mdcEquipment.getEquipmentId()); - Integer oporation = equipmentLog.getOporation(); - if (oporation == 22) { - dto.setALRMstate(equipmentLog.getAlarm()); - } else { - dto.setALRMstate("鏃�"); - } - } else { - return null; - } - return dto; - } - - @Override - public List<MdcFeedback> getFeedbackList(String key) { - return mdcFeedbackService.getFeedbackList(key); - } -} diff --git a/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEfficiencyReportServiceImpl.java b/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEfficiencyReportServiceImpl.java index 2a15529..5faa6b6 100644 --- a/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEfficiencyReportServiceImpl.java +++ b/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEfficiencyReportServiceImpl.java @@ -1,10 +1,13 @@ package org.jeecg.modules.mdc.service.impl; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import liquibase.pro.packaged.I; import org.apache.commons.lang3.StringUtils; import org.jeecg.common.constant.CommonConstant; import org.jeecg.common.exception.JeecgBootException; import org.jeecg.common.system.vo.DictModel; +import org.jeecg.modules.base.entity.Factory; +import org.jeecg.modules.base.service.IFactoryService; import org.jeecg.modules.mdc.dto.*; import org.jeecg.modules.mdc.entity.*; import org.jeecg.modules.mdc.mapper.MdcEfficiencyReportMapper; @@ -46,7 +49,10 @@ private ISysDepartService sysDepartService; @Resource - private IMdcProductionService mdcProductionService; + private IFactoryService factoryService; + +// @Resource +// private IMdcProductionService mdcProductionService; @Resource private IMdcShiftSubService mdcShiftSubService; @@ -192,12 +198,12 @@ mdcEfficiencyResultDto.setWaitLong(mdcEfficiencyResultDto.getWaitLong().divide(new BigDecimal(dates.size()), 0, RoundingMode.HALF_UP)); mdcEfficiencyResultDto1.setCloseLong(mdcEfficiencyResultDto.getCloseLong()); mdcEfficiencyResultDto.setCloseLong(mdcEfficiencyResultDto.getCloseLong().divide(new BigDecimal(dates.size()), 0, RoundingMode.HALF_UP)); - mdcEfficiencyResultDto1.setFaultLong(mdcEfficiencyResultDto.getFaultLong()); - mdcEfficiencyResultDto.setFaultLong(mdcEfficiencyResultDto.getFaultLong().divide(new BigDecimal(dates.size()), 0, RoundingMode.HALF_UP)); - mdcEfficiencyResultDto1.setFaultRate(mdcEfficiencyResultDto.getFaultRate()); - mdcEfficiencyResultDto.setFaultRate(mdcEfficiencyResultDto.getFaultRate().divide(new BigDecimal(dates.size()), 4, RoundingMode.HALF_UP)); - mdcEfficiencyResultDto1.setRemoveFaultRunLong(mdcEfficiencyResultDto.getRemoveFaultRunLong()); - mdcEfficiencyResultDto.setRemoveFaultRunLong(mdcEfficiencyResultDto.getRemoveFaultRunLong().divide(new BigDecimal(dates.size()), 0, RoundingMode.HALF_UP)); +// mdcEfficiencyResultDto1.setFaultLong(mdcEfficiencyResultDto.getFaultLong()); +// mdcEfficiencyResultDto.setFaultLong(mdcEfficiencyResultDto.getFaultLong().divide(new BigDecimal(dates.size()), 0, RoundingMode.HALF_UP)); +// mdcEfficiencyResultDto1.setFaultRate(mdcEfficiencyResultDto.getFaultRate()); +// mdcEfficiencyResultDto.setFaultRate(mdcEfficiencyResultDto.getFaultRate().divide(new BigDecimal(dates.size()), 4, RoundingMode.HALF_UP)); +// mdcEfficiencyResultDto1.setRemoveFaultRunLong(mdcEfficiencyResultDto.getRemoveFaultRunLong()); +// mdcEfficiencyResultDto.setRemoveFaultRunLong(mdcEfficiencyResultDto.getRemoveFaultRunLong().divide(new BigDecimal(dates.size()), 0, RoundingMode.HALF_UP)); long rate = mdcEfficiencyResultDto.getUtilizationRate().multiply(new BigDecimal("100")).longValue(); for (MdcUtilizationRate mdcUtilizationRate : mdcUtilizationRateList) { if (rate >= mdcUtilizationRate.getMinimumRange() && rate < mdcUtilizationRate.getMaximumRange()) { @@ -214,7 +220,7 @@ // 浜х嚎灞傜骇 List<MdcEquProDto> equipmentList = mdcEquipmentService.findEquProList(vo.getEquipmentIdList()); // 鏌ヨ鎵�鏈変骇绾夸俊鎭� - List<MdcProduction> productionList = mdcProductionService.list(new LambdaQueryWrapper<MdcProduction>().ne(MdcProduction::getDelFlag, CommonConstant.DEL_FLAG_1.toString()).orderByAsc(MdcProduction::getProductionOrder)); + List<Factory> factoryList = factoryService.list(new LambdaQueryWrapper<Factory>().ne(Factory::getDelFlag, CommonConstant.DEL_FLAG_1.toString()).orderByAsc(Factory::getSorter)); for (MdcEquProDto mdcEquProDto : equipmentList) { MdcEfficiencyListDto mdcEfficiencyListDto = new MdcEfficiencyListDto(); @@ -233,31 +239,31 @@ break; default: } - MdcProduction mdcProduction = productionList.stream().filter(production -> production.getId().equals(mdcEquProDto.getParentId())).findAny().orElse(null); - if (mdcProduction != null) { - switch (mdcProduction.getOrgType()) { + Factory baseFactory = factoryList.stream().filter(factory -> factory.getId().equals(mdcEquProDto.getParentId())).findAny().orElse(null); + if (baseFactory != null) { + switch (baseFactory.getFactoryCategory()) { case "1": - mdcEfficiencyListDto.setLevel1(mdcProduction.getProductionName()); + mdcEfficiencyListDto.setLevel1(baseFactory.getFactoryName()); break; case "2": - mdcEfficiencyListDto.setLevel2(mdcProduction.getProductionName()); + mdcEfficiencyListDto.setLevel2(baseFactory.getFactoryName()); break; case "3": - mdcEfficiencyListDto.setLevel3(mdcProduction.getProductionName()); + mdcEfficiencyListDto.setLevel3(baseFactory.getFactoryName()); break; default: } - if (StringUtils.isNotEmpty(mdcProduction.getParentId())) { - productionList.stream().filter(production -> production.getId().equals(mdcProduction.getParentId())).findAny().ifPresent(production1 -> { - switch (production1.getOrgType()) { + if (StringUtils.isNotEmpty(baseFactory.getParentId())) { + factoryList.stream().filter(factory -> factory.getId().equals(baseFactory.getParentId())).findAny().ifPresent(factory1 -> { + switch (factory1.getFactoryCategory()) { case "1": - mdcEfficiencyListDto.setLevel1(production1.getProductionName()); + mdcEfficiencyListDto.setLevel1(factory1.getFactoryName()); break; case "2": - mdcEfficiencyListDto.setLevel2(production1.getProductionName()); + mdcEfficiencyListDto.setLevel2(factory1.getFactoryName()); break; case "3": - mdcEfficiencyListDto.setLevel3(production1.getProductionName()); + mdcEfficiencyListDto.setLevel3(factory1.getFactoryName()); break; default: } @@ -286,12 +292,12 @@ mdcEfficiencyResultDto.setWaitLong(mdcEfficiencyResultDto.getWaitLong().divide(new BigDecimal(dates.size()), 0, RoundingMode.HALF_UP)); mdcEfficiencyResultDto1.setCloseLong(mdcEfficiencyResultDto.getCloseLong()); mdcEfficiencyResultDto.setCloseLong(mdcEfficiencyResultDto.getCloseLong().divide(new BigDecimal(dates.size()), 0, RoundingMode.HALF_UP)); - mdcEfficiencyResultDto1.setFaultLong(mdcEfficiencyResultDto.getFaultLong()); - mdcEfficiencyResultDto.setFaultLong(mdcEfficiencyResultDto.getFaultLong().divide(new BigDecimal(dates.size()), 0, RoundingMode.HALF_UP)); - mdcEfficiencyResultDto1.setFaultRate(mdcEfficiencyResultDto.getFaultRate()); - mdcEfficiencyResultDto.setFaultRate(mdcEfficiencyResultDto.getFaultRate().divide(new BigDecimal(dates.size()), 4, RoundingMode.HALF_UP)); - mdcEfficiencyResultDto1.setRemoveFaultRunLong(mdcEfficiencyResultDto.getRemoveFaultRunLong()); - mdcEfficiencyResultDto.setRemoveFaultRunLong(mdcEfficiencyResultDto.getRemoveFaultRunLong().divide(new BigDecimal(dates.size()), 0, RoundingMode.HALF_UP)); +// mdcEfficiencyResultDto1.setFaultLong(mdcEfficiencyResultDto.getFaultLong()); +// mdcEfficiencyResultDto.setFaultLong(mdcEfficiencyResultDto.getFaultLong().divide(new BigDecimal(dates.size()), 0, RoundingMode.HALF_UP)); +// mdcEfficiencyResultDto1.setFaultRate(mdcEfficiencyResultDto.getFaultRate()); +// mdcEfficiencyResultDto.setFaultRate(mdcEfficiencyResultDto.getFaultRate().divide(new BigDecimal(dates.size()), 4, RoundingMode.HALF_UP)); +// mdcEfficiencyResultDto1.setRemoveFaultRunLong(mdcEfficiencyResultDto.getRemoveFaultRunLong()); +// mdcEfficiencyResultDto.setRemoveFaultRunLong(mdcEfficiencyResultDto.getRemoveFaultRunLong().divide(new BigDecimal(dates.size()), 0, RoundingMode.HALF_UP)); long rate = mdcEfficiencyResultDto.getUtilizationRate().multiply(new BigDecimal("100")).longValue(); for (MdcUtilizationRate mdcUtilizationRate : mdcUtilizationRateList) { if (rate >= mdcUtilizationRate.getMinimumRange() && rate < mdcUtilizationRate.getMaximumRange()) { @@ -357,10 +363,7 @@ a.getOpenRate().add(b.getOpenRate()), a.getOpenLong().add(b.getOpenLong()), a.getWaitLong().add(b.getWaitLong()), - a.getCloseLong().add(b.getCloseLong()), - a.getFaultLong().add(b.getFaultLong()), - a.getFaultRate().add(b.getFaultRate()), - a.getRemoveFaultRunLong().add(b.getRemoveFaultRunLong()))).ifPresent(result::add); + a.getCloseLong().add(b.getCloseLong()))).ifPresent(result::add); }); for (MdcEfficiencyResultDto mdcEfficiencyResultDto : result) { mdcEfficiencyResultDto.setUtilizationRate(mdcEfficiencyResultDto.getUtilizationRate().divide(new BigDecimal(mdcEfficiencyList.size()), 4, RoundingMode.HALF_UP)); @@ -403,10 +406,7 @@ a.getOpenRate().add(b.getOpenRate()), a.getOpenLong().add(b.getOpenLong()), a.getWaitLong().add(b.getWaitLong()), - a.getCloseLong().add(b.getCloseLong()), - a.getFaultLong().add(b.getFaultLong()), - a.getFaultRate().add(b.getFaultRate()), - a.getRemoveFaultRunLong().add(b.getRemoveFaultRunLong()))).ifPresent(result::add); + a.getCloseLong().add(b.getCloseLong()))).ifPresent(result::add); }); for (MdcEfficiencyResultDto mdcEfficiencyResultDto : result) { mdcEfficiencyResultDto.setUtilizationRate(mdcEfficiencyResultDto.getUtilizationRate().divide(new BigDecimal(mdcEfficiencyList.size()), 4, RoundingMode.HALF_UP)); @@ -574,7 +574,7 @@ // 浜х嚎灞傜骇 List<MdcEquProDto> equipmentList = mdcEquipmentService.findEquProList(vo.getEquipmentIdList()); // 鏌ヨ鎵�鏈変骇绾夸俊鎭� - List<MdcProduction> productionList = mdcProductionService.list(new LambdaQueryWrapper<MdcProduction>().ne(MdcProduction::getDelFlag, CommonConstant.DEL_FLAG_1.toString()).orderByAsc(MdcProduction::getProductionOrder)); + List<Factory> factoryList = factoryService.list(new LambdaQueryWrapper<Factory>().ne(Factory::getDelFlag, CommonConstant.DEL_FLAG_1.toString()).orderByAsc(Factory::getSorter)); for (MdcEquProDto mdcEquProDto : equipmentList) { MdcEfficiencyListDto mdcEfficiencyListDto = new MdcEfficiencyListDto(); @@ -593,31 +593,31 @@ break; default: } - MdcProduction mdcProduction = productionList.stream().filter(production -> production.getId().equals(mdcEquProDto.getParentId())).findAny().orElse(null); - if (mdcProduction != null) { - switch (mdcProduction.getOrgType()) { + Factory baseFactory = factoryList.stream().filter(factory -> factory.getId().equals(mdcEquProDto.getParentId())).findAny().orElse(null); + if (baseFactory != null) { + switch (baseFactory.getFactoryCategory()) { case "1": - mdcEfficiencyListDto.setLevel1(mdcProduction.getProductionName()); + mdcEfficiencyListDto.setLevel1(baseFactory.getFactoryName()); break; case "2": - mdcEfficiencyListDto.setLevel2(mdcProduction.getProductionName()); + mdcEfficiencyListDto.setLevel2(baseFactory.getFactoryName()); break; case "3": - mdcEfficiencyListDto.setLevel3(mdcProduction.getProductionName()); + mdcEfficiencyListDto.setLevel3(baseFactory.getFactoryName()); break; default: } - if (StringUtils.isNotEmpty(mdcProduction.getParentId())) { - productionList.stream().filter(production -> production.getId().equals(mdcProduction.getParentId())).findAny().ifPresent(production1 -> { - switch (production1.getOrgType()) { + if (StringUtils.isNotEmpty(baseFactory.getParentId())) { + factoryList.stream().filter(factory -> factory.getId().equals(baseFactory.getParentId())).findAny().ifPresent(factory1 -> { + switch (factory1.getFactoryCategory()) { case "1": - mdcEfficiencyListDto.setLevel1(production1.getProductionName()); + mdcEfficiencyListDto.setLevel1(factory1.getFactoryName()); break; case "2": - mdcEfficiencyListDto.setLevel2(production1.getProductionName()); + mdcEfficiencyListDto.setLevel2(factory1.getFactoryName()); break; case "3": - mdcEfficiencyListDto.setLevel3(production1.getProductionName()); + mdcEfficiencyListDto.setLevel3(factory1.getFactoryName()); break; default: } @@ -710,10 +710,7 @@ a.getOpenRate().add(b.getOpenRate()), a.getOpenLong().add(b.getOpenLong()), a.getWaitLong().add(b.getWaitLong()), - a.getCloseLong().add(b.getCloseLong()), - a.getFaultLong().add(b.getFaultLong()), - a.getFaultRate().add(b.getFaultRate()), - a.getRemoveFaultRunLong().add(b.getRemoveFaultRunLong()))).ifPresent(result::add); + a.getCloseLong().add(b.getCloseLong()))).ifPresent(result::add); }); for (MdcEfficiencyResultDto mdcEfficiencyResultDto : result) { mdcEfficiencyResultDto.setUtilizationRate(mdcEfficiencyResultDto.getUtilizationRate().divide(new BigDecimal(mdcEfficiencyList.size()), 4, RoundingMode.HALF_UP)); @@ -723,9 +720,9 @@ mdcEfficiencyResultDto.setWaitLong(mdcEfficiencyResultDto.getWaitLong().divide(new BigDecimal(mdcEfficiencyList.size()), 0, RoundingMode.HALF_UP)); mdcEfficiencyResultDto.setOpenLong(mdcEfficiencyResultDto.getOpenLong().divide(new BigDecimal(mdcEfficiencyList.size()), 0, RoundingMode.HALF_UP)); mdcEfficiencyResultDto.setProcessLong(mdcEfficiencyResultDto.getProcessLong().divide(new BigDecimal(mdcEfficiencyList.size()), 0, RoundingMode.HALF_UP)); - mdcEfficiencyResultDto.setFaultLong(mdcEfficiencyResultDto.getFaultLong().divide(new BigDecimal(mdcEfficiencyList.size()), 0, RoundingMode.HALF_UP)); - mdcEfficiencyResultDto.setFaultRate(mdcEfficiencyResultDto.getFaultRate().divide(new BigDecimal(mdcEfficiencyList.size()), 4, RoundingMode.HALF_UP)); - mdcEfficiencyResultDto.setRemoveFaultRunLong(mdcEfficiencyResultDto.getRemoveFaultRunLong().divide(new BigDecimal(mdcEfficiencyList.size()), 0, RoundingMode.HALF_UP)); +// mdcEfficiencyResultDto.setFaultLong(mdcEfficiencyResultDto.getFaultLong().divide(new BigDecimal(mdcEfficiencyList.size()), 0, RoundingMode.HALF_UP)); +// mdcEfficiencyResultDto.setFaultRate(mdcEfficiencyResultDto.getFaultRate().divide(new BigDecimal(mdcEfficiencyList.size()), 4, RoundingMode.HALF_UP)); +// mdcEfficiencyResultDto.setRemoveFaultRunLong(mdcEfficiencyResultDto.getRemoveFaultRunLong().divide(new BigDecimal(mdcEfficiencyList.size()), 0, RoundingMode.HALF_UP)); long rate = mdcEfficiencyResultDto.getStartRate().multiply(new BigDecimal("100")).longValue(); for (MdcUtilizationRate mdcUtilizationRate : mdcUtilizationRateList) { if (rate >= mdcUtilizationRate.getMinimumRange() && rate < mdcUtilizationRate.getMaximumRange()) { @@ -760,16 +757,13 @@ a.getOpenRate().add(b.getOpenRate()), a.getOpenLong().add(b.getOpenLong()), a.getWaitLong().add(b.getWaitLong()), - a.getCloseLong().add(b.getCloseLong()), - a.getFaultLong().add(b.getFaultLong()), - a.getFaultRate().add(b.getFaultRate()), - a.getRemoveFaultRunLong().add(b.getRemoveFaultRunLong()))).ifPresent(result::add); + a.getCloseLong().add(b.getCloseLong()))).ifPresent(result::add); }); for (MdcEfficiencyResultDto mdcEfficiencyResultDto : result) { mdcEfficiencyResultDto.setUtilizationRate(mdcEfficiencyResultDto.getUtilizationRate().divide(new BigDecimal(mdcEfficiencyList.size()), 4, RoundingMode.HALF_UP)); mdcEfficiencyResultDto.setOpenRate(mdcEfficiencyResultDto.getOpenRate().divide(new BigDecimal(mdcEfficiencyList.size()), 4, RoundingMode.HALF_UP)); mdcEfficiencyResultDto.setStartRate(mdcEfficiencyResultDto.getStartRate().divide(new BigDecimal(mdcEfficiencyList.size()), 4, RoundingMode.HALF_UP)); - mdcEfficiencyResultDto.setFaultRate(mdcEfficiencyResultDto.getFaultRate().divide(new BigDecimal(mdcEfficiencyList.size()), 4, RoundingMode.HALF_UP)); +// mdcEfficiencyResultDto.setFaultRate(mdcEfficiencyResultDto.getFaultRate().divide(new BigDecimal(mdcEfficiencyList.size()), 4, RoundingMode.HALF_UP)); long rate = mdcEfficiencyResultDto.getStartRate().multiply(new BigDecimal("100")).longValue(); for (MdcUtilizationRate mdcUtilizationRate : mdcUtilizationRateList) { if (rate >= mdcUtilizationRate.getMinimumRange() && rate < mdcUtilizationRate.getMaximumRange()) { @@ -955,7 +949,7 @@ // 浜х嚎灞傜骇 List<MdcEquProDto> equipmentList = mdcEquipmentService.findEquProList(vo.getEquipmentIdList()); // 鏌ヨ鎵�鏈変骇绾夸俊鎭� - List<MdcProduction> productionList = mdcProductionService.list(new LambdaQueryWrapper<MdcProduction>().ne(MdcProduction::getDelFlag, CommonConstant.DEL_FLAG_1.toString()).orderByAsc(MdcProduction::getProductionOrder)); + List<Factory> factoryList = factoryService.list(new LambdaQueryWrapper<Factory>().ne(Factory::getDelFlag, CommonConstant.DEL_FLAG_1.toString()).orderByAsc(Factory::getSorter)); // 鐝鍚嶇О鏄剧ず澶勭悊 String shiftSubName = ""; @@ -996,31 +990,31 @@ break; default: } - MdcProduction mdcProduction = productionList.stream().filter(production -> production.getId().equals(mdcEquProDto.getParentId())).findAny().orElse(null); - if (mdcProduction != null) { - switch (mdcProduction.getOrgType()) { + Factory baseFactory = factoryList.stream().filter(factory -> factory.getId().equals(mdcEquProDto.getParentId())).findAny().orElse(null); + if (baseFactory != null) { + switch (baseFactory.getFactoryCategory()) { case "1": - mdcEfficiencyShiftListDto.setLevel1(mdcProduction.getProductionName()); + mdcEfficiencyShiftListDto.setLevel1(baseFactory.getFactoryName()); break; case "2": - mdcEfficiencyShiftListDto.setLevel2(mdcProduction.getProductionName()); + mdcEfficiencyShiftListDto.setLevel2(baseFactory.getFactoryName()); break; case "3": - mdcEfficiencyShiftListDto.setLevel3(mdcProduction.getProductionName()); + mdcEfficiencyShiftListDto.setLevel3(baseFactory.getFactoryName()); break; default: } - if (StringUtils.isNotEmpty(mdcProduction.getParentId())) { - productionList.stream().filter(production -> production.getId().equals(mdcProduction.getParentId())).findAny().ifPresent(production1 -> { - switch (production1.getOrgType()) { + if (StringUtils.isNotEmpty(baseFactory.getParentId())) { + factoryList.stream().filter(factory -> factory.getId().equals(baseFactory.getParentId())).findAny().ifPresent(factory1 -> { + switch (factory1.getFactoryCategory()) { case "1": - mdcEfficiencyShiftListDto.setLevel1(production1.getProductionName()); + mdcEfficiencyShiftListDto.setLevel1(factory1.getFactoryName()); break; case "2": - mdcEfficiencyShiftListDto.setLevel2(production1.getProductionName()); + mdcEfficiencyShiftListDto.setLevel2(factory1.getFactoryName()); break; case "3": - mdcEfficiencyShiftListDto.setLevel3(production1.getProductionName()); + mdcEfficiencyShiftListDto.setLevel3(factory1.getFactoryName()); break; default: } @@ -1767,316 +1761,316 @@ return mdcEfficiencyReportMapper.getEfficiencyRate(equipmentId, date); } - /** - * 鐝粍鍚勮澶囩患鍚堝埄鐢ㄧ巼 - * - * @param equEffVo - * @return - */ - @Override - public Map<String, Object> equipmentEfficiencyAnalyze(String userId, EquEffVo equEffVo) { - Map<String, Object> result = new HashMap<>(); - List<String> mdcProductionIds = new ArrayList<>(); - if (StringUtils.isBlank(equEffVo.getProductionIds())) { - mdcProductionIds.add(equEffVo.getProductionId()); - } else { - mdcProductionIds.addAll(Arrays.asList(equEffVo.getProductionIds().split(","))); - } - List<String> allProductionIds = mdcProductionService.findChildren(mdcProductionIds); - //鏁版嵁鏉冮檺杩囨护 - allProductionIds = mdcProductionService.findProIdsByUId(userId, allProductionIds); - List<MdcEquipment> equipmentList = mdcEquipmentService.findByProductionIds(allProductionIds); - if (equipmentList != null && !equipmentList.isEmpty()) { - List<String> equipmentIdList = equipmentList.stream().map(MdcEquipment::getEquipmentId).collect(Collectors.toList()); - List<EquipmentEfficiencyAnalyzeDto> dataList = mdcEfficiencyReportMapper.equipmentEfficiencyAnalyze(equipmentIdList, equEffVo.getMonth()); - result.put("dataList", dataList); - List<String> equipmentNameList = dataList.stream().map(EquipmentEfficiencyAnalyzeDto::getEquipmentId).collect(Collectors.toList()); - result.put("equipmentNameList", equipmentNameList); - } - return result; - } - - @Override - public Map<String, Object> teamEquipmentEfficiencyAnalyze(String userId, EquEffVo equEffVo) { - Map<String, Object> result = new HashMap<>(); - // 1. 澶勭悊鐢熶骇ID - List<String> mdcProductionIds = StringUtils.isBlank(equEffVo.getProductionIds()) - ? Collections.singletonList(equEffVo.getProductionId()) - : Arrays.asList(equEffVo.getProductionIds().split(",")); - - List<String> allProductionIds = mdcProductionService.findChildren(mdcProductionIds); - if (allProductionIds.isEmpty()) { - return result; // 鎻愬墠杩斿洖绌虹粨鏋� - } - //鏁版嵁鏉冮檺杩囨护 - allProductionIds = mdcProductionService.findProIdsByUId(userId, allProductionIds); - // 2. 鑾峰彇璁惧鍒楄〃 - List<MdcEquipment> equipmentList = StringUtils.isNotBlank(equEffVo.getTeamCodes()) - ? mdcEquipmentService.findByProIdsAndTeamCode(allProductionIds, Arrays.asList(equEffVo.getTeamCodes().split(","))) - : mdcEquipmentService.findByProductionIds(allProductionIds); - - if (equipmentList.isEmpty()) { - return result; - } - - // 3. 鏁版嵁澶勭悊 - List<String> equipmentIdList = equipmentList.stream() - .map(MdcEquipment::getEquipmentId) - .collect(Collectors.toList()); - - List<TeamEquEffDto> dataList = mdcEfficiencyReportMapper - .teamEquipmentEfficiencyAnalyze(equipmentIdList, equEffVo.getMonth()); - - if (dataList.isEmpty()) { - return result; - } - - // 4. 鍒嗙粍璁$畻骞冲潎鍊� - Map<String, TeamEquEffDto> grouped = dataList.stream() - .collect(Collectors.groupingBy( - TeamEquEffDto::getTeamCode, - Collectors.collectingAndThen( - Collectors.toList(), - this::calculateAverages // 鎻愬彇璁$畻鏂规硶 - ))); - - // 5. 瀛楀吀杞崲 - Map<String, String> dictMap = sysDictService.queryEnableDictItemsByCode(CommonConstant.DICT_MDC_STAFF_TEAM) - .stream() - .collect(Collectors.toMap(DictModel::getValue, DictModel::getText)); - - List<TeamEquEffDto> resultList = grouped.entrySet().stream() - .map(entry -> buildResultDto(entry, dictMap))// 鎻愬彇鏋勫缓鏂规硶 - .sorted(Comparator.comparing(TeamEquEffDto::getUtilizationRate).reversed()) - .collect(Collectors.toList()); - - result.put("dataList", resultList); - result.put("teamCodeList", resultList.stream() - .map(TeamEquEffDto::getTeamCode) - .collect(Collectors.toList())); - - return result; - - } - - @Override - public Map<String, Object> teamEfficiencyAnalyzeByMonth(String userId, EquEffVo equEffVo) { - Map<String, Object> result = new HashMap<>(); - - // 1. 鏃ユ湡澶勭悊 - LocalDate now = LocalDate.now(); - Date start = DateUtils.toDate(now.plusMonths(-6).toString(), DateUtils.STR_DATE); - Date end = DateUtils.toDate(now.plusMonths(-1).toString(), DateUtils.STR_DATE); - - List<String> monthBetween = DateUtils.getMonthBetween(start, end); - List<String> dateList = monthBetween.stream() - .map(date -> date.substring(date.lastIndexOf("-") + 1).replaceFirst("^0*", "") + "鏈�") - .collect(Collectors.toList()); - result.put("dateList", dateList); - - // 2. 鑾峰彇浜х嚎鏁版嵁 - List<MdcProduction> mdcProductions = mdcProductionService.findMdcPros(userId, equEffVo.getProductionId()); - - // 3. 鍒濆鍖栫粨鏋滈泦 - List<TeamEquEffMonthDto> utilizationRateList = new ArrayList<>(); - List<TeamEquEffMonthDto> shiftUtilizationRateList = new ArrayList<>(); - List<TeamEquEffMonthDto> amendUtilizationRateList = new ArrayList<>(); - - // 4. 澶勭悊姣忎釜浜х嚎 - mdcProductions.forEach(mdcProduction -> { - // 4.1 鑾峰彇涓嬬骇浜х嚎骞惰繃婊� - List<String> allProductionIds = mdcProductionService.recursionChildren(mdcProduction.getId()); - // 鏁版嵁鏉冮檺杩囨护 - allProductionIds = mdcProductionService.findProIdsByUId(userId, allProductionIds); - // 4.2 鑾峰彇璁惧鍒楄〃 - List<MdcEquipment> equipmentList = mdcEquipmentService.findByProductionIds(allProductionIds); - if (equipmentList == null || equipmentList.isEmpty()) { - return; - } - //鎻愬彇id闆嗗悎 - List<String> equipmentIdList = equipmentList.stream() - .map(MdcEquipment::getEquipmentId) - .collect(Collectors.toList()); - - TeamEquEffMonthDto urDto = new TeamEquEffMonthDto(); - TeamEquEffMonthDto surDto = new TeamEquEffMonthDto(); - TeamEquEffMonthDto aurDto = new TeamEquEffMonthDto(); - urDto.setProductionName(mdcProduction.getProductionName()); - surDto.setProductionName(mdcProduction.getProductionName()); - aurDto.setProductionName(mdcProduction.getProductionName()); - List<TeamEquEffMonthChildDto> urDataList = new ArrayList<>(); - List<TeamEquEffMonthChildDto> surDataList = new ArrayList<>(); - List<TeamEquEffMonthChildDto> aurDataList = new ArrayList<>(); - - monthBetween.forEach(date -> { - TeamEquEffMonthChildDto urCDto = new TeamEquEffMonthChildDto(); - TeamEquEffMonthChildDto surCDto = new TeamEquEffMonthChildDto(); - TeamEquEffMonthChildDto aurCDto = new TeamEquEffMonthChildDto(); - String month = date.substring(date.lastIndexOf("-") + 1).replaceFirst("^0*", "") + "鏈�"; - urCDto.setMonth(month); - surCDto.setMonth(month); - aurCDto.setMonth(month); - List<TeamEquEffDto> dataList = mdcEfficiencyReportMapper.teamEquipmentEfficiencyAnalyze(equipmentIdList, date.replaceAll("-", "")); - if (dataList != null && !dataList.isEmpty()) { - // 璁$畻骞冲潎鍊� - BigDecimal ur = dataList.stream() - .map(TeamEquEffDto::getUtilizationRate) - .reduce(BigDecimal.ZERO, BigDecimal::add) - .divide(BigDecimal.valueOf(dataList.size()), 2, RoundingMode.HALF_UP); - //鍒╃敤鐜� - urCDto.setUtilizationRate(ur); - //鐝鍒╃敤鐜� - BigDecimal sur = dataList.stream() - .map(TeamEquEffDto::getShiftUtilizationRate) - .reduce(BigDecimal.ZERO, BigDecimal::add) - .divide(BigDecimal.valueOf(dataList.size()), 2, RoundingMode.HALF_UP); - surCDto.setUtilizationRate(sur); - //鍘婚櫎鏁呴殰24灏忔椂鍒╃敤鐜� - BigDecimal aur = dataList.stream() - .map(TeamEquEffDto::getAmendUtilizationRate) - .reduce(BigDecimal.ZERO, BigDecimal::add) - .divide(BigDecimal.valueOf(dataList.size()), 2, RoundingMode.HALF_UP); - aurCDto.setUtilizationRate(aur); - } - urDataList.add(urCDto); - surDataList.add(surCDto); - aurDataList.add(aurCDto); - }); - urDto.setDataList(urDataList); - surDto.setDataList(surDataList); - aurDto.setDataList(aurDataList); - utilizationRateList.add(urDto); - shiftUtilizationRateList.add(surDto); - amendUtilizationRateList.add(aurDto); - }); - result.put("utilizationRateList", utilizationRateList); - result.put("shiftUtilizationRateList", shiftUtilizationRateList); - result.put("amendUtilizationRateList", amendUtilizationRateList); - return result; - } - - @Override - public Map<String, Object> comprehensiveRateAnalyze(String userId, EquEffVo vo) { - Map<String, Object> result = new HashMap<>(); - // 1. 鏃ユ湡澶勭悊 - LocalDate now = LocalDate.now(); - Date start = DateUtils.toDate(now.plusMonths(-12).toString(), DateUtils.STR_DATE); - Date end = DateUtils.toDate(now.plusMonths(-1).toString(), DateUtils.STR_DATE); - - List<String> monthBetween = DateUtils.getMonthBetween(start, end); - List<String> dateList = monthBetween.stream() - .map(date -> date.substring(date.lastIndexOf("-") + 1).replaceFirst("^0*", "") + "鏈�") - .collect(Collectors.toList()); - result.put("dateList", dateList); - - // 1. 澶勭悊鐢熶骇ID - List<String> mdcProductionIds = StringUtils.isBlank(vo.getProductionIds()) - ? Collections.singletonList(vo.getProductionId()) - : Arrays.asList(vo.getProductionIds().split(",")); - - List<String> allProductionIds = mdcProductionService.findChildren(mdcProductionIds); - if (allProductionIds.isEmpty()) { - return result; // 鎻愬墠杩斿洖绌虹粨鏋� - } - //鏁版嵁鏉冮檺杩囨护 - allProductionIds = mdcProductionService.findProIdsByUId(userId, allProductionIds); - // 2. 鑾峰彇璁惧鍒楄〃 - List<MdcEquipment> equipmentList = StringUtils.isNotBlank(vo.getEquipmentType()) - ? mdcEquipmentService.findByProIdsAndType(allProductionIds, Arrays.asList(vo.getEquipmentType().split(","))) - : mdcEquipmentService.findByProductionIds(allProductionIds); - - if (equipmentList.isEmpty()) { - return result; - } - - // 3. 鏁版嵁澶勭悊 - List<String> equipmentIdList = equipmentList.stream() - .map(MdcEquipment::getEquipmentId) - .collect(Collectors.toList()); - String startStr = monthBetween.get(0).replaceAll("-", ""); - String endStr = monthBetween.get(monthBetween.size() - 1).replaceAll("-", ""); - List<ComRateDto> comRateDtoList = mdcEfficiencyReportMapper.comprehensiveRateAnalyze(equipmentIdList, startStr, endStr); - if (comRateDtoList.isEmpty()) { - return result; // 鎻愬墠杩斿洖绌虹粨鏋� - } - List<ComRateDto> dataList = new ArrayList<>(); - Map<String, ComRateDto> map = comRateDtoList.stream().collect(Collectors.toMap(ComRateDto::getTheMonth, comRateDto -> comRateDto)); - monthBetween.forEach(date -> { - String d = date.replaceAll("-", ""); - String month = date.substring(date.lastIndexOf("-") + 1).replaceFirst("^0*", "") + "鏈�"; - if (map.containsKey(d)) { - ComRateDto comRateDto = map.get(d); - comRateDto.setTheMonth(month); - comRateDto.setUtilizationRate(comRateDto.getUtilizationRate().setScale(2, RoundingMode.HALF_UP)); - comRateDto.setShiftUtilizationRate(comRateDto.getShiftUtilizationRate() != null ? comRateDto.getShiftUtilizationRate().setScale(2, RoundingMode.HALF_UP) : BigDecimal.ZERO); - comRateDto.setAmendUtilizationRate(comRateDto.getAmendUtilizationRate().setScale(2, RoundingMode.HALF_UP)); - comRateDto.setProcessLong(comRateDto.getProcessLong().divide(new BigDecimal("3600"), 2, RoundingMode.HALF_UP)); - dataList.add(comRateDto); - } else { - ComRateDto comRateDto = new ComRateDto(); - comRateDto.setTheMonth(month); - dataList.add(comRateDto); - } - }); - result.put("dataList", dataList); - - if (StringUtils.isNotBlank(vo.getShiftId())) { - List<MdcShiftSub> shiftSubList = mdcShiftSubService.list(new LambdaQueryWrapper<MdcShiftSub>().eq(MdcShiftSub::getShiftId, vo.getShiftId())); - if (shiftSubList == null || shiftSubList.isEmpty()) { - return result; - } - List<String> shiftSubNameList = shiftSubList.stream().map(MdcShiftSub::getShiftSubName).collect(Collectors.toList()); - result.put("shiftSubList", shiftSubNameList); - - List<ComShiftRateDto> comShiftRateDtoList = mdcEfficiencyReportMapper.comprehensiveShiftRateAnalyze(equipmentIdList, startStr, endStr, vo.getShiftId()); - Map<String, List<ComShiftRateDto>> groupMap; - if (comShiftRateDtoList != null && !comShiftRateDtoList.isEmpty()) { - groupMap = comShiftRateDtoList.stream().collect(Collectors.groupingBy(ComShiftRateDto::getShiftSub)); - } else { - groupMap = new HashMap<>(); - } - List<ComShiftDto> shiftDataList = new ArrayList<>(); - shiftSubList.forEach(mdcShiftSub -> { - ComShiftDto comShiftDto = new ComShiftDto(); - comShiftDto.setShiftSubName(mdcShiftSub.getShiftSubName()); - if (groupMap.containsKey(mdcShiftSub.getId())) { - List<ComShiftRateDto> csrd = groupMap.get(mdcShiftSub.getId()); - Map<String, ComShiftRateDto> collect = csrd.stream().collect(Collectors.toMap(ComShiftRateDto::getTheMonth, comShiftRateDto -> comShiftRateDto)); - List<ComShiftChildDto> comShiftChildDtoList = new ArrayList<>(); - monthBetween.forEach(date -> { - String d = date.replaceAll("-", ""); - String month = date.substring(date.lastIndexOf("-") + 1).replaceFirst("^0*", "") + "鏈�"; - if (collect.containsKey(d)) { - ComShiftRateDto comShiftRateDto = collect.get(d); - ComShiftChildDto comShiftChildDto = new ComShiftChildDto(); - comShiftChildDto.setMonth(month); - comShiftChildDto.setUtilizationRate(comShiftRateDto.getUtilizationRate().setScale(2, RoundingMode.HALF_UP)); - comShiftChildDtoList.add(comShiftChildDto); - } else { - ComShiftChildDto comShiftChildDto = new ComShiftChildDto(); - comShiftChildDto.setMonth(month); - comShiftChildDtoList.add(comShiftChildDto); - } - }); - comShiftDto.setDataList(comShiftChildDtoList); - } else { - List<ComShiftChildDto> comShiftChildDtoList = new ArrayList<>(); - monthBetween.forEach(date -> { - String month = date.substring(date.lastIndexOf("-") + 1).replaceFirst("^0*", "") + "鏈�"; - ComShiftChildDto comShiftChildDto = new ComShiftChildDto(); - comShiftChildDto.setMonth(month); - comShiftChildDtoList.add(comShiftChildDto); - }); - comShiftDto.setDataList(comShiftChildDtoList); - } - shiftDataList.add(comShiftDto); - }); - - result.put("shiftDataList", shiftDataList); - } - - return result; - } +// /** +// * 鐝粍鍚勮澶囩患鍚堝埄鐢ㄧ巼 +// * +// * @param equEffVo +// * @return +// */ +// @Override +// public Map<String, Object> equipmentEfficiencyAnalyze(String userId, EquEffVo equEffVo) { +// Map<String, Object> result = new HashMap<>(); +// List<String> mdcProductionIds = new ArrayList<>(); +// if (StringUtils.isBlank(equEffVo.getProductionIds())) { +// mdcProductionIds.add(equEffVo.getProductionId()); +// } else { +// mdcProductionIds.addAll(Arrays.asList(equEffVo.getProductionIds().split(","))); +// } +// List<String> allProductionIds = mdcProductionService.findChildren(mdcProductionIds); +// //鏁版嵁鏉冮檺杩囨护 +// allProductionIds = mdcProductionService.findProIdsByUId(userId, allProductionIds); +// List<MdcEquipment> equipmentList = mdcEquipmentService.findByProductionIds(allProductionIds); +// if (equipmentList != null && !equipmentList.isEmpty()) { +// List<String> equipmentIdList = equipmentList.stream().map(MdcEquipment::getEquipmentId).collect(Collectors.toList()); +// List<EquipmentEfficiencyAnalyzeDto> dataList = mdcEfficiencyReportMapper.equipmentEfficiencyAnalyze(equipmentIdList, equEffVo.getMonth()); +// result.put("dataList", dataList); +// List<String> equipmentNameList = dataList.stream().map(EquipmentEfficiencyAnalyzeDto::getEquipmentId).collect(Collectors.toList()); +// result.put("equipmentNameList", equipmentNameList); +// } +// return result; +// } +// +// @Override +// public Map<String, Object> teamEquipmentEfficiencyAnalyze(String userId, EquEffVo equEffVo) { +// Map<String, Object> result = new HashMap<>(); +// // 1. 澶勭悊鐢熶骇ID +// List<String> mdcProductionIds = StringUtils.isBlank(equEffVo.getProductionIds()) +// ? Collections.singletonList(equEffVo.getProductionId()) +// : Arrays.asList(equEffVo.getProductionIds().split(",")); +// +// List<String> allProductionIds = mdcProductionService.findChildren(mdcProductionIds); +// if (allProductionIds.isEmpty()) { +// return result; // 鎻愬墠杩斿洖绌虹粨鏋� +// } +// //鏁版嵁鏉冮檺杩囨护 +// allProductionIds = mdcProductionService.findProIdsByUId(userId, allProductionIds); +// // 2. 鑾峰彇璁惧鍒楄〃 +// List<MdcEquipment> equipmentList = StringUtils.isNotBlank(equEffVo.getTeamCodes()) +// ? mdcEquipmentService.findByProIdsAndTeamCode(allProductionIds, Arrays.asList(equEffVo.getTeamCodes().split(","))) +// : mdcEquipmentService.findByProductionIds(allProductionIds); +// +// if (equipmentList.isEmpty()) { +// return result; +// } +// +// // 3. 鏁版嵁澶勭悊 +// List<String> equipmentIdList = equipmentList.stream() +// .map(MdcEquipment::getEquipmentId) +// .collect(Collectors.toList()); +// +// List<TeamEquEffDto> dataList = mdcEfficiencyReportMapper +// .teamEquipmentEfficiencyAnalyze(equipmentIdList, equEffVo.getMonth()); +// +// if (dataList.isEmpty()) { +// return result; +// } +// +// // 4. 鍒嗙粍璁$畻骞冲潎鍊� +// Map<String, TeamEquEffDto> grouped = dataList.stream() +// .collect(Collectors.groupingBy( +// TeamEquEffDto::getTeamCode, +// Collectors.collectingAndThen( +// Collectors.toList(), +// this::calculateAverages // 鎻愬彇璁$畻鏂规硶 +// ))); +// +// // 5. 瀛楀吀杞崲 +// Map<String, String> dictMap = sysDictService.queryEnableDictItemsByCode(CommonConstant.DICT_MDC_STAFF_TEAM) +// .stream() +// .collect(Collectors.toMap(DictModel::getValue, DictModel::getText)); +// +// List<TeamEquEffDto> resultList = grouped.entrySet().stream() +// .map(entry -> buildResultDto(entry, dictMap))// 鎻愬彇鏋勫缓鏂规硶 +// .sorted(Comparator.comparing(TeamEquEffDto::getUtilizationRate).reversed()) +// .collect(Collectors.toList()); +// +// result.put("dataList", resultList); +// result.put("teamCodeList", resultList.stream() +// .map(TeamEquEffDto::getTeamCode) +// .collect(Collectors.toList())); +// +// return result; +// +// } +// +// @Override +// public Map<String, Object> teamEfficiencyAnalyzeByMonth(String userId, EquEffVo equEffVo) { +// Map<String, Object> result = new HashMap<>(); +// +// // 1. 鏃ユ湡澶勭悊 +// LocalDate now = LocalDate.now(); +// Date start = DateUtils.toDate(now.plusMonths(-6).toString(), DateUtils.STR_DATE); +// Date end = DateUtils.toDate(now.plusMonths(-1).toString(), DateUtils.STR_DATE); +// +// List<String> monthBetween = DateUtils.getMonthBetween(start, end); +// List<String> dateList = monthBetween.stream() +// .map(date -> date.substring(date.lastIndexOf("-") + 1).replaceFirst("^0*", "") + "鏈�") +// .collect(Collectors.toList()); +// result.put("dateList", dateList); +// +// // 2. 鑾峰彇浜х嚎鏁版嵁 +// List<MdcProduction> mdcProductions = mdcProductionService.findMdcPros(userId, equEffVo.getProductionId()); +// +// // 3. 鍒濆鍖栫粨鏋滈泦 +// List<TeamEquEffMonthDto> utilizationRateList = new ArrayList<>(); +// List<TeamEquEffMonthDto> shiftUtilizationRateList = new ArrayList<>(); +// List<TeamEquEffMonthDto> amendUtilizationRateList = new ArrayList<>(); +// +// // 4. 澶勭悊姣忎釜浜х嚎 +// mdcProductions.forEach(mdcProduction -> { +// // 4.1 鑾峰彇涓嬬骇浜х嚎骞惰繃婊� +// List<String> allProductionIds = mdcProductionService.recursionChildren(mdcProduction.getId()); +// // 鏁版嵁鏉冮檺杩囨护 +// allProductionIds = mdcProductionService.findProIdsByUId(userId, allProductionIds); +// // 4.2 鑾峰彇璁惧鍒楄〃 +// List<MdcEquipment> equipmentList = mdcEquipmentService.findByProductionIds(allProductionIds); +// if (equipmentList == null || equipmentList.isEmpty()) { +// return; +// } +// //鎻愬彇id闆嗗悎 +// List<String> equipmentIdList = equipmentList.stream() +// .map(MdcEquipment::getEquipmentId) +// .collect(Collectors.toList()); +// +// TeamEquEffMonthDto urDto = new TeamEquEffMonthDto(); +// TeamEquEffMonthDto surDto = new TeamEquEffMonthDto(); +// TeamEquEffMonthDto aurDto = new TeamEquEffMonthDto(); +// urDto.setProductionName(mdcProduction.getProductionName()); +// surDto.setProductionName(mdcProduction.getProductionName()); +// aurDto.setProductionName(mdcProduction.getProductionName()); +// List<TeamEquEffMonthChildDto> urDataList = new ArrayList<>(); +// List<TeamEquEffMonthChildDto> surDataList = new ArrayList<>(); +// List<TeamEquEffMonthChildDto> aurDataList = new ArrayList<>(); +// +// monthBetween.forEach(date -> { +// TeamEquEffMonthChildDto urCDto = new TeamEquEffMonthChildDto(); +// TeamEquEffMonthChildDto surCDto = new TeamEquEffMonthChildDto(); +// TeamEquEffMonthChildDto aurCDto = new TeamEquEffMonthChildDto(); +// String month = date.substring(date.lastIndexOf("-") + 1).replaceFirst("^0*", "") + "鏈�"; +// urCDto.setMonth(month); +// surCDto.setMonth(month); +// aurCDto.setMonth(month); +// List<TeamEquEffDto> dataList = mdcEfficiencyReportMapper.teamEquipmentEfficiencyAnalyze(equipmentIdList, date.replaceAll("-", "")); +// if (dataList != null && !dataList.isEmpty()) { +// // 璁$畻骞冲潎鍊� +// BigDecimal ur = dataList.stream() +// .map(TeamEquEffDto::getUtilizationRate) +// .reduce(BigDecimal.ZERO, BigDecimal::add) +// .divide(BigDecimal.valueOf(dataList.size()), 2, RoundingMode.HALF_UP); +// //鍒╃敤鐜� +// urCDto.setUtilizationRate(ur); +// //鐝鍒╃敤鐜� +// BigDecimal sur = dataList.stream() +// .map(TeamEquEffDto::getShiftUtilizationRate) +// .reduce(BigDecimal.ZERO, BigDecimal::add) +// .divide(BigDecimal.valueOf(dataList.size()), 2, RoundingMode.HALF_UP); +// surCDto.setUtilizationRate(sur); +// //鍘婚櫎鏁呴殰24灏忔椂鍒╃敤鐜� +// BigDecimal aur = dataList.stream() +// .map(TeamEquEffDto::getAmendUtilizationRate) +// .reduce(BigDecimal.ZERO, BigDecimal::add) +// .divide(BigDecimal.valueOf(dataList.size()), 2, RoundingMode.HALF_UP); +// aurCDto.setUtilizationRate(aur); +// } +// urDataList.add(urCDto); +// surDataList.add(surCDto); +// aurDataList.add(aurCDto); +// }); +// urDto.setDataList(urDataList); +// surDto.setDataList(surDataList); +// aurDto.setDataList(aurDataList); +// utilizationRateList.add(urDto); +// shiftUtilizationRateList.add(surDto); +// amendUtilizationRateList.add(aurDto); +// }); +// result.put("utilizationRateList", utilizationRateList); +// result.put("shiftUtilizationRateList", shiftUtilizationRateList); +// result.put("amendUtilizationRateList", amendUtilizationRateList); +// return result; +// } +// +// @Override +// public Map<String, Object> comprehensiveRateAnalyze(String userId, EquEffVo vo) { +// Map<String, Object> result = new HashMap<>(); +// // 1. 鏃ユ湡澶勭悊 +// LocalDate now = LocalDate.now(); +// Date start = DateUtils.toDate(now.plusMonths(-12).toString(), DateUtils.STR_DATE); +// Date end = DateUtils.toDate(now.plusMonths(-1).toString(), DateUtils.STR_DATE); +// +// List<String> monthBetween = DateUtils.getMonthBetween(start, end); +// List<String> dateList = monthBetween.stream() +// .map(date -> date.substring(date.lastIndexOf("-") + 1).replaceFirst("^0*", "") + "鏈�") +// .collect(Collectors.toList()); +// result.put("dateList", dateList); +// +// // 1. 澶勭悊鐢熶骇ID +// List<String> mdcProductionIds = StringUtils.isBlank(vo.getProductionIds()) +// ? Collections.singletonList(vo.getProductionId()) +// : Arrays.asList(vo.getProductionIds().split(",")); +// +// List<String> allProductionIds = mdcProductionService.findChildren(mdcProductionIds); +// if (allProductionIds.isEmpty()) { +// return result; // 鎻愬墠杩斿洖绌虹粨鏋� +// } +// //鏁版嵁鏉冮檺杩囨护 +// allProductionIds = mdcProductionService.findProIdsByUId(userId, allProductionIds); +// // 2. 鑾峰彇璁惧鍒楄〃 +// List<MdcEquipment> equipmentList = StringUtils.isNotBlank(vo.getEquipmentType()) +// ? mdcEquipmentService.findByProIdsAndType(allProductionIds, Arrays.asList(vo.getEquipmentType().split(","))) +// : mdcEquipmentService.findByProductionIds(allProductionIds); +// +// if (equipmentList.isEmpty()) { +// return result; +// } +// +// // 3. 鏁版嵁澶勭悊 +// List<String> equipmentIdList = equipmentList.stream() +// .map(MdcEquipment::getEquipmentId) +// .collect(Collectors.toList()); +// String startStr = monthBetween.get(0).replaceAll("-", ""); +// String endStr = monthBetween.get(monthBetween.size() - 1).replaceAll("-", ""); +// List<ComRateDto> comRateDtoList = mdcEfficiencyReportMapper.comprehensiveRateAnalyze(equipmentIdList, startStr, endStr); +// if (comRateDtoList.isEmpty()) { +// return result; // 鎻愬墠杩斿洖绌虹粨鏋� +// } +// List<ComRateDto> dataList = new ArrayList<>(); +// Map<String, ComRateDto> map = comRateDtoList.stream().collect(Collectors.toMap(ComRateDto::getTheMonth, comRateDto -> comRateDto)); +// monthBetween.forEach(date -> { +// String d = date.replaceAll("-", ""); +// String month = date.substring(date.lastIndexOf("-") + 1).replaceFirst("^0*", "") + "鏈�"; +// if (map.containsKey(d)) { +// ComRateDto comRateDto = map.get(d); +// comRateDto.setTheMonth(month); +// comRateDto.setUtilizationRate(comRateDto.getUtilizationRate().setScale(2, RoundingMode.HALF_UP)); +// comRateDto.setShiftUtilizationRate(comRateDto.getShiftUtilizationRate() != null ? comRateDto.getShiftUtilizationRate().setScale(2, RoundingMode.HALF_UP) : BigDecimal.ZERO); +// comRateDto.setAmendUtilizationRate(comRateDto.getAmendUtilizationRate().setScale(2, RoundingMode.HALF_UP)); +// comRateDto.setProcessLong(comRateDto.getProcessLong().divide(new BigDecimal("3600"), 2, RoundingMode.HALF_UP)); +// dataList.add(comRateDto); +// } else { +// ComRateDto comRateDto = new ComRateDto(); +// comRateDto.setTheMonth(month); +// dataList.add(comRateDto); +// } +// }); +// result.put("dataList", dataList); +// +// if (StringUtils.isNotBlank(vo.getShiftId())) { +// List<MdcShiftSub> shiftSubList = mdcShiftSubService.list(new LambdaQueryWrapper<MdcShiftSub>().eq(MdcShiftSub::getShiftId, vo.getShiftId())); +// if (shiftSubList == null || shiftSubList.isEmpty()) { +// return result; +// } +// List<String> shiftSubNameList = shiftSubList.stream().map(MdcShiftSub::getShiftSubName).collect(Collectors.toList()); +// result.put("shiftSubList", shiftSubNameList); +// +// List<ComShiftRateDto> comShiftRateDtoList = mdcEfficiencyReportMapper.comprehensiveShiftRateAnalyze(equipmentIdList, startStr, endStr, vo.getShiftId()); +// Map<String, List<ComShiftRateDto>> groupMap; +// if (comShiftRateDtoList != null && !comShiftRateDtoList.isEmpty()) { +// groupMap = comShiftRateDtoList.stream().collect(Collectors.groupingBy(ComShiftRateDto::getShiftSub)); +// } else { +// groupMap = new HashMap<>(); +// } +// List<ComShiftDto> shiftDataList = new ArrayList<>(); +// shiftSubList.forEach(mdcShiftSub -> { +// ComShiftDto comShiftDto = new ComShiftDto(); +// comShiftDto.setShiftSubName(mdcShiftSub.getShiftSubName()); +// if (groupMap.containsKey(mdcShiftSub.getId())) { +// List<ComShiftRateDto> csrd = groupMap.get(mdcShiftSub.getId()); +// Map<String, ComShiftRateDto> collect = csrd.stream().collect(Collectors.toMap(ComShiftRateDto::getTheMonth, comShiftRateDto -> comShiftRateDto)); +// List<ComShiftChildDto> comShiftChildDtoList = new ArrayList<>(); +// monthBetween.forEach(date -> { +// String d = date.replaceAll("-", ""); +// String month = date.substring(date.lastIndexOf("-") + 1).replaceFirst("^0*", "") + "鏈�"; +// if (collect.containsKey(d)) { +// ComShiftRateDto comShiftRateDto = collect.get(d); +// ComShiftChildDto comShiftChildDto = new ComShiftChildDto(); +// comShiftChildDto.setMonth(month); +// comShiftChildDto.setUtilizationRate(comShiftRateDto.getUtilizationRate().setScale(2, RoundingMode.HALF_UP)); +// comShiftChildDtoList.add(comShiftChildDto); +// } else { +// ComShiftChildDto comShiftChildDto = new ComShiftChildDto(); +// comShiftChildDto.setMonth(month); +// comShiftChildDtoList.add(comShiftChildDto); +// } +// }); +// comShiftDto.setDataList(comShiftChildDtoList); +// } else { +// List<ComShiftChildDto> comShiftChildDtoList = new ArrayList<>(); +// monthBetween.forEach(date -> { +// String month = date.substring(date.lastIndexOf("-") + 1).replaceFirst("^0*", "") + "鏈�"; +// ComShiftChildDto comShiftChildDto = new ComShiftChildDto(); +// comShiftChildDto.setMonth(month); +// comShiftChildDtoList.add(comShiftChildDto); +// }); +// comShiftDto.setDataList(comShiftChildDtoList); +// } +// shiftDataList.add(comShiftDto); +// }); +// +// result.put("shiftDataList", shiftDataList); +// } +// +// return result; +// } // 鎻愬彇鐨勫钩鍧囧�艰绠楁柟娉� private TeamEquEffDto calculateAverages(List<TeamEquEffDto> items) { @@ -2170,9 +2164,9 @@ mdcEfficiencyResultDto.setOpenLong(efficiencyDto.getOpenLong()); mdcEfficiencyResultDto.setWaitLong(efficiencyDto.getWaitLong()); mdcEfficiencyResultDto.setCloseLong(efficiencyDto.getCloseLong()); - mdcEfficiencyResultDto.setFaultLong(efficiencyDto.getFaultLong()); - mdcEfficiencyResultDto.setFaultRate(efficiencyDto.getFaultRate()); - mdcEfficiencyResultDto.setRemoveFaultRunLong(efficiencyDto.getRemoveFaultRunLong()); +// mdcEfficiencyResultDto.setFaultLong(efficiencyDto.getFaultLong()); +// mdcEfficiencyResultDto.setFaultRate(efficiencyDto.getFaultRate()); +// mdcEfficiencyResultDto.setRemoveFaultRunLong(efficiencyDto.getRemoveFaultRunLong()); long rate = efficiencyDto.getUtilizationRate().multiply(new BigDecimal("100")).longValue(); for (MdcUtilizationRate mdcUtilizationRate : mdcUtilizationRateList) { if (rate >= mdcUtilizationRate.getMinimumRange() && rate < mdcUtilizationRate.getMaximumRange()) { @@ -2190,9 +2184,9 @@ mdcEfficiencyResultDto.setOpenLong(new BigDecimal("0")); mdcEfficiencyResultDto.setWaitLong(new BigDecimal("0")); mdcEfficiencyResultDto.setCloseLong(new BigDecimal("0")); - mdcEfficiencyResultDto.setFaultLong(new BigDecimal("0")); - mdcEfficiencyResultDto.setFaultRate(new BigDecimal("0")); - mdcEfficiencyResultDto.setRemoveFaultRunLong(new BigDecimal("0")); +// mdcEfficiencyResultDto.setFaultLong(new BigDecimal("0")); +// mdcEfficiencyResultDto.setFaultRate(new BigDecimal("0")); +// mdcEfficiencyResultDto.setRemoveFaultRunLong(new BigDecimal("0")); for (MdcUtilizationRate mdcUtilizationRate : mdcUtilizationRateList) { if (0 >= mdcUtilizationRate.getMinimumRange() && 0 < mdcUtilizationRate.getMaximumRange()) { mdcEfficiencyResultDto.setColor(mdcUtilizationRate.getRateParameterColor()); @@ -2208,9 +2202,9 @@ mdcEfficiencyResultDto.setOpenLong(new BigDecimal("0")); mdcEfficiencyResultDto.setWaitLong(new BigDecimal("0")); mdcEfficiencyResultDto.setCloseLong(new BigDecimal("0")); - mdcEfficiencyResultDto.setFaultLong(new BigDecimal("0")); - mdcEfficiencyResultDto.setFaultRate(new BigDecimal("0")); - mdcEfficiencyResultDto.setRemoveFaultRunLong(new BigDecimal("0")); +// mdcEfficiencyResultDto.setFaultLong(new BigDecimal("0")); +// mdcEfficiencyResultDto.setFaultRate(new BigDecimal("0")); +// mdcEfficiencyResultDto.setRemoveFaultRunLong(new BigDecimal("0")); for (MdcUtilizationRate mdcUtilizationRate : mdcUtilizationRateList) { if (0 >= mdcUtilizationRate.getMinimumRange() && 0 < mdcUtilizationRate.getMaximumRange()) { mdcEfficiencyResultDto.setColor(mdcUtilizationRate.getRateParameterColor()); @@ -2224,9 +2218,9 @@ efficiencyResultDto.setOpenLong(efficiencyResultDto.getOpenLong().add(mdcEfficiencyResultDto.getOpenLong())); efficiencyResultDto.setWaitLong(efficiencyResultDto.getWaitLong().add(mdcEfficiencyResultDto.getWaitLong())); efficiencyResultDto.setCloseLong(efficiencyResultDto.getCloseLong().add(mdcEfficiencyResultDto.getCloseLong())); - efficiencyResultDto.setFaultLong(efficiencyResultDto.getFaultLong().add(mdcEfficiencyResultDto.getFaultLong())); - efficiencyResultDto.setFaultRate(efficiencyResultDto.getFaultRate().add(mdcEfficiencyResultDto.getFaultRate())); - efficiencyResultDto.setRemoveFaultRunLong(efficiencyResultDto.getRemoveFaultRunLong().add(mdcEfficiencyResultDto.getRemoveFaultRunLong())); +// efficiencyResultDto.setFaultLong(efficiencyResultDto.getFaultLong().add(mdcEfficiencyResultDto.getFaultLong())); +// efficiencyResultDto.setFaultRate(efficiencyResultDto.getFaultRate().add(mdcEfficiencyResultDto.getFaultRate())); +// efficiencyResultDto.setRemoveFaultRunLong(efficiencyResultDto.getRemoveFaultRunLong().add(mdcEfficiencyResultDto.getRemoveFaultRunLong())); return mdcEfficiencyResultDto; } diff --git a/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentFaultInfoServiceImpl.java b/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentFaultInfoServiceImpl.java deleted file mode 100644 index fc76c70..0000000 --- a/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentFaultInfoServiceImpl.java +++ /dev/null @@ -1,380 +0,0 @@ -package org.jeecg.modules.mdc.service.impl; - -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import org.apache.commons.lang.StringUtils; -import org.jeecg.modules.mdc.entity.Equipment; -import org.jeecg.modules.mdc.entity.MdcEquipmentFaultInfo; -import org.jeecg.modules.mdc.entity.MdcEquipmentRunningSection; -import org.jeecg.modules.mdc.entity.MdcSystemParameters; -import org.jeecg.modules.mdc.mapper.MdcEquipmentFaultInfoMapper; -import org.jeecg.modules.mdc.service.IEquipmentService; -import org.jeecg.modules.mdc.service.IMdcEquipmentFaultInfoService; -import org.jeecg.modules.mdc.service.IMdcEquipmentRunningSectionService; -import org.jeecg.modules.mdc.service.IMdcSystemParametersService; -import org.jeecg.modules.mdc.util.DateUtils; -import org.jeecg.modules.mdc.vo.EquFaultRecord; -import org.jeecg.modules.mdc.vo.TimeInterval; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - -import javax.annotation.Resource; -import java.math.BigDecimal; -import java.math.RoundingMode; -import java.time.LocalDateTime; -import java.time.temporal.ChronoUnit; -import java.util.*; -import java.util.stream.Collectors; - -/** - * @Description: 鏁呴殰鐜囪〃 - * @Author: Lius - * @Date: 2025-06-16 - * @Version: V1.0 - */ -@Service -public class MdcEquipmentFaultInfoServiceImpl extends ServiceImpl<MdcEquipmentFaultInfoMapper, MdcEquipmentFaultInfo> implements IMdcEquipmentFaultInfoService { - - @Resource - private IEquipmentService equipmentService; - - @Resource - private IMdcSystemParametersService mdcSystemParametersService; - - @Resource - private IMdcEquipmentRunningSectionService mdcEquipmentRunningSectionService; - - @Override - @Transactional(rollbackFor = {Exception.class}) - public void runningAllEquFaultStatistical(String dateTime) { - Date initDate = null; - - if (StringUtils.isNotBlank(dateTime)) { - initDate = DateUtils.toDate(dateTime, DateUtils.STRDATE); - } else { - // 鍙栨渶鍚庣殑缁熻鏃堕棿 - String date = this.baseMapper.getMaxStaticsData(); - if (date != null) { - initDate = DateUtils.toDate(date, DateUtils.STRDATE); - } else { - // 鍒濇鍙栧�� 鍙栨渶鏃╂椂闂磋褰� - MdcEquipmentRunningSection equipmentRunningSection = mdcEquipmentRunningSectionService.getFirstRecord(); - if (equipmentRunningSection != null) { - initDate = equipmentRunningSection.getStartTime(); - } - } - } - Date endDate = DateUtils.addDays(DateUtils.getNow(), -1); - List<String> dateList = DateUtils.getDatesStringList2(initDate, endDate); - - if (dateList.isEmpty()) { - return; - } - try { - this.remove(new LambdaQueryWrapper<MdcEquipmentFaultInfo>().in(MdcEquipmentFaultInfo::getTheDate, dateList)); - } catch (Exception e) { - log.error("鍙傛暟鏍煎紡涓嶅", e); - } - - List<Equipment> equipmentList = equipmentService.list(); - if (equipmentList == null || equipmentList.isEmpty()) { - return; - } - - String planTime = "00:00:00"; - MdcSystemParameters mdcSystemParameters = mdcSystemParametersService.getOne(new LambdaQueryWrapper<MdcSystemParameters>().eq(MdcSystemParameters::getCode, "equip_log_statis_time")); - if (mdcSystemParameters != null) { - planTime = mdcSystemParameters.getValue(); - } - - List<String> equipmentIdList = equipmentList.stream().map(Equipment::getEquipmentid).collect(Collectors.toList()); - - for (String validDate : dateList) { - Map<String, MdcEquipmentFaultInfo> map = new HashMap<>(); - String finalValidDate = validDate; - equipmentList.forEach(equipment -> { - MdcEquipmentFaultInfo mdcEquipmentFaultInfo = new MdcEquipmentFaultInfo(equipment.getEquipmentid(), finalValidDate); - map.put(equipment.getEquipmentid(), mdcEquipmentFaultInfo); - }); - - String startTime = DateUtils.format(DateUtils.setTimeForDay(DateUtils.toDate(validDate, DateUtils.STRDATE), planTime), DateUtils.STR_DATE_TIME_SMALL); - Date start = DateUtils.toDate(startTime, DateUtils.STR_DATE_TIME_SMALL); - String endTime = DateUtils.format(DateUtils.addDays(DateUtils.toDate(startTime, DateUtils.STR_DATE_TIME_SMALL), 1), DateUtils.STR_DATE_TIME_SMALL); - Date end = DateUtils.toDate(endTime, DateUtils.STR_DATE_TIME_SMALL); - //鏌ヨ鏁呴殰璁板綍 - List<EquFaultRecord> equFaultRecordList = this.baseMapper.findFaultRecord(equipmentIdList, startTime, endTime); - if (equFaultRecordList != null && !equFaultRecordList.isEmpty()) { - // 淇暣鏃堕棿 - Map<String, List<EquFaultRecord>> equFaultRecordMap = equFaultRecordList.stream().collect(Collectors.groupingBy(EquFaultRecord::getEquipmentId)); - map.forEach((key, value1) -> { - MdcEquipmentFaultInfo equFaultRecords = value1; - if (equFaultRecordMap.containsKey(key)) { - List<EquFaultRecord> value = equFaultRecordMap.get(key); - long faultLong = calculateTotalFaultDuration(value, start, end); - equFaultRecords.setFaultLong((int) faultLong); - if (faultLong != 0) { - equFaultRecords.setFaultRate(new BigDecimal(faultLong).divide(new BigDecimal("864"), 2, RoundingMode.HALF_UP)); - } - // 璁$畻鍘婚櫎鏁呴殰鏃堕暱鐨勫姞宸ユ椂闂� - // step.1 鏌ヨ鍔犲伐鏃堕棿 - List<MdcEquipmentRunningSection> mdcEquipmentRunningSections = mdcEquipmentRunningSectionService.listEquipmentRunningSectionRun(key, start.getTime(), end.getTime()); - if (mdcEquipmentRunningSections != null && !mdcEquipmentRunningSections.isEmpty()) { - // 鏃堕棿淇 - if (mdcEquipmentRunningSections.get(0).getStartTime().before(start)) { - mdcEquipmentRunningSections.get(0).setStartTime(start); - } - if (mdcEquipmentRunningSections.size() > 1) { - if (mdcEquipmentRunningSections.get(mdcEquipmentRunningSections.size() - 1).getEndTime().after(end)) { - mdcEquipmentRunningSections.get(mdcEquipmentRunningSections.size() - 1).setEndTime(end); - } - } else { - if (mdcEquipmentRunningSections.get(0).getEndTime().after(end)) { - mdcEquipmentRunningSections.get(0).setEndTime(end); - } - } - List<MdcEquipmentRunningSection> collect = mdcEquipmentRunningSections.stream().filter(mdcEquipmentRunningSection -> mdcEquipmentRunningSection.getStatus() == 3).collect(Collectors.toList()); - if (!collect.isEmpty()) { - // step.2 璁$畻鍘婚櫎鏁呴殰鏃堕暱鐨勫姞宸ユ椂闂� - long processingTime = calculateProcessingTimeWithoutFaults(collect, value, start, end); - equFaultRecords.setRemoveFaultRunLong((int) processingTime); - if (faultLong != 0 && faultLong != 86400) { - // 璁$畻鍘婚櫎鏁呴殰鏃堕暱鐨勫埄鐢ㄧ巼 - BigDecimal removeFaultRate = new BigDecimal(processingTime).divide(new BigDecimal("864").subtract(new BigDecimal(faultLong)), 2, RoundingMode.HALF_UP); - equFaultRecords.setRemoveFaultRate(removeFaultRate); - } - } - } - } else { - List<MdcEquipmentRunningSection> mdcEquipmentRunningSections = mdcEquipmentRunningSectionService.listEquipmentRunningSectionRun(key, start.getTime(), end.getTime()); - if (mdcEquipmentRunningSections != null && !mdcEquipmentRunningSections.isEmpty()) { - // 鏃堕棿淇 - if (mdcEquipmentRunningSections.get(0).getStartTime().before(start)) { - mdcEquipmentRunningSections.get(0).setStartTime(start); - } - if (mdcEquipmentRunningSections.size() > 1) { - if (mdcEquipmentRunningSections.get(mdcEquipmentRunningSections.size() - 1).getEndTime().after(end)) { - mdcEquipmentRunningSections.get(mdcEquipmentRunningSections.size() - 1).setEndTime(end); - } - } else { - if (mdcEquipmentRunningSections.get(0).getEndTime().after(end)) { - mdcEquipmentRunningSections.get(0).setEndTime(end); - } - } - List<MdcEquipmentRunningSection> collect = mdcEquipmentRunningSections.stream().filter(mdcEquipmentRunningSection -> mdcEquipmentRunningSection.getStatus() == 3).collect(Collectors.toList()); - - if (!collect.isEmpty()) { - long totalProcessingTime = 0; - for (MdcEquipmentRunningSection mdcEquipmentRunningSection : collect) { - totalProcessingTime += ChronoUnit.SECONDS.between(DateUtils.convertToLocalDateTime(mdcEquipmentRunningSection.getStartTime()), DateUtils.convertToLocalDateTime(mdcEquipmentRunningSection.getEndTime())); - } - equFaultRecords.setRemoveFaultRunLong((int) totalProcessingTime); - // 璁$畻鍘婚櫎鏁呴殰鏃堕暱鐨勫埄鐢ㄧ巼 - BigDecimal removeFaultRate = new BigDecimal(totalProcessingTime).divide(new BigDecimal("864"), 2, RoundingMode.HALF_UP); - equFaultRecords.setRemoveFaultRate(removeFaultRate); - } - } - } - map.put(key, equFaultRecords); - }); - } else { - map.forEach((key, value1) -> { - MdcEquipmentFaultInfo equFaultRecords = value1; - List<MdcEquipmentRunningSection> mdcEquipmentRunningSections = mdcEquipmentRunningSectionService.listEquipmentRunningSectionRun(key, start.getTime(), end.getTime()); - if (mdcEquipmentRunningSections != null && !mdcEquipmentRunningSections.isEmpty()) { - // 鏃堕棿淇 - if (mdcEquipmentRunningSections.get(0).getStartTime().before(start)) { - mdcEquipmentRunningSections.get(0).setStartTime(start); - } - if (mdcEquipmentRunningSections.size() > 1) { - if (mdcEquipmentRunningSections.get(mdcEquipmentRunningSections.size() - 1).getEndTime().after(end)) { - mdcEquipmentRunningSections.get(mdcEquipmentRunningSections.size() - 1).setEndTime(end); - } - } else { - if (mdcEquipmentRunningSections.get(0).getEndTime().after(end)) { - mdcEquipmentRunningSections.get(0).setEndTime(end); - } - } - List<MdcEquipmentRunningSection> collect = mdcEquipmentRunningSections.stream().filter(mdcEquipmentRunningSection -> mdcEquipmentRunningSection.getStatus() == 3).collect(Collectors.toList()); - - if (!collect.isEmpty()) { - long totalProcessingTime = 0; - for (MdcEquipmentRunningSection mdcEquipmentRunningSection : collect) { - totalProcessingTime += ChronoUnit.SECONDS.between(DateUtils.convertToLocalDateTime(mdcEquipmentRunningSection.getStartTime()), DateUtils.convertToLocalDateTime(mdcEquipmentRunningSection.getEndTime())); - } - equFaultRecords.setRemoveFaultRunLong((int) totalProcessingTime); - // 璁$畻鍘婚櫎鏁呴殰鏃堕暱鐨勫埄鐢ㄧ巼 - BigDecimal removeFaultRate = new BigDecimal(totalProcessingTime).divide(new BigDecimal("864"), 2, RoundingMode.HALF_UP); - equFaultRecords.setRemoveFaultRate(removeFaultRate); - } - } - map.put(key, equFaultRecords); - }); - } - if (!map.isEmpty()) { - this.saveBatch(new ArrayList<>(map.values())); - } - } - } - - public static long calculateTotalFaultDuration(List<EquFaultRecord> records, Date startTime, Date endTime) { - LocalDateTime start = DateUtils.convertToLocalDateTime(startTime); - LocalDateTime end = DateUtils.convertToLocalDateTime(endTime); - - // 淇璁板綍鏃堕棿 - List<EquFaultRecord> correctedRecords = correctRecordTimes(records, start, end); - - // 鎸夊紑濮嬫椂闂存帓搴� - correctedRecords.sort(Comparator.comparing(EquFaultRecord::getStartTime)); - - // 鍚堝苟閲嶅彔鏃堕棿娈� - List<TimeInterval> mergedIntervals = mergeIntervals(correctedRecords); - - // 璁$畻鎬绘椂闀匡紙绉掞級 - return mergedIntervals.stream() - .mapToLong(interval -> ChronoUnit.SECONDS.between(interval.getStart(), interval.getEnd())) - .sum(); - } - - private static List<EquFaultRecord> correctRecordTimes(List<EquFaultRecord> records, LocalDateTime startTime, LocalDateTime endTime) { - return records.stream() - .map(record -> { - LocalDateTime recordStart = DateUtils.convertToLocalDateTime(record.getStartTime()); - LocalDateTime recordEnd = record.getEndTime() != null ? - DateUtils.convertToLocalDateTime(record.getEndTime()) : null; - - // 淇寮�濮嬫椂闂� - LocalDateTime correctedStart = recordStart.isBefore(startTime) ? - startTime : recordStart; - - // 淇缁撴潫鏃堕棿 - LocalDateTime correctedEnd = recordEnd == null || recordEnd.isAfter(endTime) ? - endTime : recordEnd; - - // 鍒涘缓淇鍚庣殑璁板綍 - return new EquFaultRecord( - record.getEquipmentId(), - DateUtils.convertToDate(correctedStart), - DateUtils.convertToDate(correctedEnd) - ); - }) - .collect(Collectors.toList()); - } - - private static List<TimeInterval> mergeIntervals(List<EquFaultRecord> records) { - List<TimeInterval> intervals = records.stream() - .map(record -> new TimeInterval( - DateUtils.convertToLocalDateTime(record.getStartTime()), - DateUtils.convertToLocalDateTime(record.getEndTime()))) - .collect(Collectors.toList()); - - if (intervals.isEmpty()) { - return Collections.emptyList(); - } - - List<TimeInterval> merged = new ArrayList<>(); - TimeInterval current = intervals.get(0); - - for (int i = 1; i < intervals.size(); i++) { - TimeInterval next = intervals.get(i); - if (next.getStart().isBefore(current.getEnd()) || next.getStart().equals(current.getEnd())) { - // 鏈夐噸鍙狅紝鍚堝苟鍖洪棿 - current.setEnd(current.getEnd().isAfter(next.getEnd()) ? current.getEnd() : next.getEnd()); - } else { - // 鏃犻噸鍙狅紝娣诲姞褰撳墠鍖洪棿骞舵洿鏂板綋鍓嶅尯闂� - merged.add(current); - current = next; - } - } - merged.add(current); // 娣诲姞鏈�鍚庝竴涓尯闂� - - return merged; - } - - // 璁$畻鍘婚櫎鏁呴殰鏃堕暱鍚庣殑鍔犲伐鏃堕棿 - private long calculateProcessingTimeWithoutFaults( - List<MdcEquipmentRunningSection> runningSections, - List<EquFaultRecord> faultRecords, - Date startTime, - Date endTime) { - - // 杞崲涓篖ocalDateTime杩涜澶勭悊 - LocalDateTime start = DateUtils.convertToLocalDateTime(startTime); - LocalDateTime end = DateUtils.convertToLocalDateTime(endTime); - - // 淇璁板綍鏃堕棿 - List<EquFaultRecord> correctedRecords = correctRecordTimes(faultRecords, start, end); - List<TimeInterval> mergedFaultIntervals = mergeIntervals(correctedRecords); - - long totalProcessingTime = 0; - - // 閬嶅巻姣忎釜鍔犲伐鍖洪棿锛屾帓闄ゆ晠闅滄椂闂� - for (MdcEquipmentRunningSection section : runningSections) { - LocalDateTime sectionStart = DateUtils.convertToLocalDateTime(section.getStartTime()); - LocalDateTime sectionEnd = DateUtils.convertToLocalDateTime(section.getEndTime()); - - // 鎺掗櫎鏁呴殰鏃堕棿鍚庣殑鏈夋晥鍔犲伐鏃堕棿 - List<TimeInterval> validIntervals = excludeFaultsFromSection( - new TimeInterval(sectionStart, sectionEnd), - mergedFaultIntervals); - - // 绱姞鏈夋晥鍔犲伐鏃堕棿锛堢锛� - for (TimeInterval interval : validIntervals) { - totalProcessingTime += ChronoUnit.SECONDS.between(interval.getStart(), interval.getEnd()); - } - } - - return totalProcessingTime; - } - - // 浠庤繍琛屽尯闂翠腑鎺掗櫎鏁呴殰鏃堕棿 - private List<TimeInterval> excludeFaultsFromSection( - TimeInterval section, - List<TimeInterval> faultIntervals) { - - List<TimeInterval> validIntervals = new ArrayList<>(); - validIntervals.add(section); - - // 閬嶅巻姣忎釜鏁呴殰鍖洪棿锛屼粠鏈夋晥鍖洪棿涓墸闄� - for (TimeInterval fault : faultIntervals) { - List<TimeInterval> newValidIntervals = new ArrayList<>(); - - for (TimeInterval valid : validIntervals) { - // 璁$畻鏈夋晥鍖洪棿涓庢晠闅滃尯闂寸殑浜ら泦 - if (isOverlapping(valid, fault)) { - // 鍒嗗壊鏈夋晥鍖洪棿 - splitInterval(valid, fault, newValidIntervals); - } else { - // 鏃犱氦闆嗭紝淇濈暀鍘熸湁鏁堝尯闂� - newValidIntervals.add(valid); - } - } - - validIntervals = newValidIntervals; - } - - return validIntervals; - } - - // 鍒ゆ柇涓や釜鏃堕棿鍖洪棿鏄惁閲嶅彔 - private boolean isOverlapping(TimeInterval a, TimeInterval b) { - return a.getStart().isBefore(b.getEnd()) && b.getStart().isBefore(a.getEnd()); - } - - // 鍒嗗壊鍖洪棿锛堟墸闄ら噸鍙犻儴鍒嗭級 - private void splitInterval( - TimeInterval valid, - TimeInterval fault, - List<TimeInterval> result) { - - // 閲嶅彔鍓嶇殑閮ㄥ垎 - if (valid.getStart().isBefore(fault.getStart())) { - result.add(new TimeInterval(valid.getStart(), fault.getStart())); - } - - // 閲嶅彔鍚庣殑閮ㄥ垎 - if (valid.getEnd().isAfter(fault.getEnd())) { - result.add(new TimeInterval(fault.getEnd(), valid.getEnd())); - } - } - -} diff --git a/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentServiceImpl.java b/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentServiceImpl.java index cda1062..753837f 100644 --- a/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentServiceImpl.java +++ b/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentServiceImpl.java @@ -15,24 +15,23 @@ import org.jeecg.common.system.api.ISysBaseAPI; import org.jeecg.common.system.vo.LoginUser; import org.jeecg.common.util.oConvertUtils; +import org.jeecg.modules.base.entity.Factory; +import org.jeecg.modules.base.service.IFactoryService; +import org.jeecg.modules.base.service.IUserFactoryService; +import org.jeecg.modules.base.service.impl.FactoryServiceImpl; import org.jeecg.modules.mdc.dto.MdcEquDepDto; import org.jeecg.modules.mdc.dto.MdcEquProDto; import org.jeecg.modules.mdc.dto.MdcEquipmentDetailedDto; import org.jeecg.modules.mdc.dto.MdcEquipmentDto; import org.jeecg.modules.mdc.entity.*; -import org.jeecg.modules.mdc.mapper.MdcEquipmentDepartMapper; -import org.jeecg.modules.mdc.mapper.MdcEquipmentMapper; -import org.jeecg.modules.mdc.mapper.MdcProductionEquipmentMapper; -import org.jeecg.modules.mdc.mapper.MdcTorqueConfigMapper; +import org.jeecg.modules.mdc.mapper.*; import org.jeecg.modules.mdc.model.MdcEquipmentTree; import org.jeecg.modules.mdc.service.*; -import org.jeecg.modules.mdc.util.DateUtils; -import org.jeecg.modules.mdc.util.DncCopyEquipment; -import org.jeecg.modules.mdc.util.FindsEquipmentDepartUtil; -import org.jeecg.modules.mdc.util.FindsEquipmentProductionUtil; +import org.jeecg.modules.mdc.util.*; import org.jeecg.modules.mdc.vo.*; import org.jeecg.modules.system.entity.*; import org.jeecg.modules.system.service.*; +import org.jeecg.modules.system.util.FindsFactorysChildrenUtil; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.cache.annotation.CacheEvict; @@ -60,15 +59,9 @@ @Resource private MdcEquipmentDepartMapper mdcEquipmentDepartMapper; @Resource - private MdcProductionEquipmentMapper mdcProductionEquipmentMapper; - @Resource private ISysUserDepartService sysUserDepartService; @Resource - private IMdcUserProductionService mdcUserProductionService; - @Resource private ISysDepartService sysDepartService; - @Resource - private IMdcProductionService mdcProductionService; @Resource private IEquipmentWorkLineService equipmentWorkLineService; @Resource @@ -91,6 +84,15 @@ @Autowired private IEquipmentService equipmentService; + @Autowired + private IFactoryService factoryService; + + @Autowired + private IUserFactoryService userFactoryService; + + @Autowired + private FactoryEquipmentMapper factoryEquipmentMapper; + @Override public Map<String, String> getDepNamesByEquipmentIds(List<String> equipmentIds) { @@ -104,7 +106,7 @@ public Map<String, String> getProNamesByEquipmentIds(List<String> equipmentIds) { List<MdcEquipmentProVo> list = this.baseMapper.getProNamesByEquipmentIds(equipmentIds); Map<String, String> res = new HashMap(5); - list.forEach(item -> res.merge(item.getEquipmentId(), item.getProductionName(), (a, b) -> a + "," + b)); + list.forEach(item -> res.merge(item.getEquipmentId(), item.getFactoryName(), (a, b) -> a + "," + b)); return res; } @@ -125,8 +127,8 @@ if (oConvertUtils.isNotEmpty(selectedProduction)) { String[] arr = selectedProduction.split(","); for (String productionId : arr) { - MdcProductionEquipment mdcProductionEquipment = new MdcProductionEquipment(mdcEquipment.getId(), productionId); - mdcProductionEquipmentMapper.insert(mdcProductionEquipment); + FactoryEquipment mdcProductionEquipment = new FactoryEquipment(mdcEquipment.getId(), productionId); + factoryEquipmentMapper.insert(mdcProductionEquipment); } } } @@ -152,17 +154,17 @@ } } //step.3 淇敼浜х嚎 - String productions = mdcEquipment.getSelectedProduction(); + String productions = mdcEquipment.getSelectedFactory(); String[] array = {}; if (oConvertUtils.isNotEmpty(productions)) { array = productions.split(","); } //鍏堝垹鍚庡姞 - mdcProductionEquipmentMapper.delete(new LambdaQueryWrapper<MdcProductionEquipment>().eq(MdcProductionEquipment::getEquipmentId, mdcEquipment.getId())); + factoryEquipmentMapper.delete(new LambdaQueryWrapper<FactoryEquipment>().eq(FactoryEquipment::getEquipmentId, mdcEquipment.getId())); if (oConvertUtils.isNotEmpty(productions)) { for (String productionId : array) { - MdcProductionEquipment productionEquipment = new MdcProductionEquipment(mdcEquipment.getId(), productionId); - mdcProductionEquipmentMapper.insert(productionEquipment); + FactoryEquipment productionEquipment = new FactoryEquipment(mdcEquipment.getId(), productionId); + factoryEquipmentMapper.insert(productionEquipment); } } } @@ -176,7 +178,7 @@ // 2. 鍒犻櫎璁惧閮ㄩ棬鍏崇郴 line += mdcEquipmentDepartMapper.delete(new LambdaQueryWrapper<MdcEquipmentDepart>().eq(MdcEquipmentDepart::getEquipmentId, id)); // 3. 鍒犻櫎璁惧浜х嚎鍏崇郴 - line += mdcProductionEquipmentMapper.delete(new LambdaQueryWrapper<MdcProductionEquipment>().eq(MdcProductionEquipment::getEquipmentId, id)); + line += factoryEquipmentMapper.delete(new LambdaQueryWrapper<FactoryEquipment>().eq(FactoryEquipment::getEquipmentId, id)); return line != 0; } @@ -189,7 +191,7 @@ // 2. 鍒犻櫎璁惧閮ㄩ棬鍏崇郴 line += mdcEquipmentDepartMapper.delete(new LambdaQueryWrapper<MdcEquipmentDepart>().in(MdcEquipmentDepart::getEquipmentId, equipmentIds)); // 3. 鍒犻櫎璁惧浜х嚎鍏崇郴 - line += mdcProductionEquipmentMapper.delete(new LambdaQueryWrapper<MdcProductionEquipment>().in(MdcProductionEquipment::getEquipmentId, equipmentIds)); + line += factoryEquipmentMapper.delete(new LambdaQueryWrapper<FactoryEquipment>().in(FactoryEquipment::getEquipmentId, equipmentIds)); return line != 0; } @@ -214,15 +216,15 @@ mdcEquipmentDepartMapper.delete(new LambdaQueryWrapper<MdcEquipmentDepart>().eq(MdcEquipmentDepart::getDepId, departId).in(MdcEquipmentDepart::getEquipmentId, equipmentIdList)); } - @Override - public void removeEquipmentForProduction(String productionId, String equipmentId) { - mdcProductionEquipmentMapper.delete(new LambdaQueryWrapper<MdcProductionEquipment>().eq(MdcProductionEquipment::getProductionId, productionId).eq(MdcProductionEquipment::getEquipmentId, equipmentId)); - } +// @Override +// public void removeEquipmentForProduction(String productionId, String equipmentId) { +// mdcProductionEquipmentMapper.delete(new LambdaQueryWrapper<MdcProductionEquipment>().eq(MdcProductionEquipment::getProductionId, productionId).eq(MdcProductionEquipment::getEquipmentId, equipmentId)); +// } - @Override - public void removeEquipmentsForProduction(String productionId, List<String> equipmentIdList) { - mdcProductionEquipmentMapper.delete(new LambdaQueryWrapper<MdcProductionEquipment>().eq(MdcProductionEquipment::getProductionId, productionId).in(MdcProductionEquipment::getEquipmentId, equipmentIdList)); - } +// @Override +// public void removeEquipmentsForProduction(String productionId, List<String> equipmentIdList) { +// mdcProductionEquipmentMapper.delete(new LambdaQueryWrapper<MdcProductionEquipment>().eq(MdcProductionEquipment::getProductionId, productionId).in(MdcProductionEquipment::getEquipmentId, equipmentIdList)); +// } @Override public List<MdcEquipmentTree> loadTreeListByDepart(String userId) { @@ -293,23 +295,84 @@ @Override public List<MdcEquipmentTree> loadTreeListByProduction(String userId) { //鑾峰彇鎵�鏈変骇绾挎暟鎹� - List<MdcProduction> productionList = mdcProductionService.list(new LambdaQueryWrapper<MdcProduction>().eq(MdcProduction::getDelFlag, CommonConstant.DEL_FLAG_0.toString()).eq(MdcProduction::getMdcFlag, CommonConstant.DEFAULT_1).orderByAsc(MdcProduction::getProductionOrder)); + List<Factory> factoryList = factoryService.list(new LambdaQueryWrapper<Factory>().eq(Factory::getDelFlag, CommonConstant.DEL_FLAG_0.toString()).orderByAsc(Factory::getSorter)); //鏍规嵁鐢ㄦ埛id鑾峰彇鎷ユ湁鐨勪骇绾夸俊鎭泦鍚� - List<String> productionIds = mdcUserProductionService.queryProductionIdsByUserId(userId); - List<String> allProductionIds = new ArrayList<>(); + List<String> factoryIds = userFactoryService.queryFactoryIdsByUserId(userId); + List<String> allFactoryIds = new ArrayList<>(); //鎵惧埌鎵�鏈変骇绾縤d鐨勪笂绾d - if (productionIds != null && !productionIds.isEmpty()) { - for (String productionId : productionIds) { - this.getAllProductionIds(productionList, productionId, allProductionIds); + if (factoryIds != null && !factoryIds.isEmpty()) { + for (String factoryId : factoryIds) { + this.getAllFactoryIds(factoryList, factoryId, allFactoryIds); } } //杩囨护浜х嚎鏁版嵁 - List<MdcProduction> list = productionList.stream().filter((MdcProduction mdcProduction) -> allProductionIds.contains(mdcProduction.getId())).collect(Collectors.toList()); + List<Factory> list = factoryList.stream().filter((Factory factory) -> allFactoryIds.contains(factory.getId())).collect(Collectors.toList()); //缁勮浜х嚎璁惧鏍� - List<MdcEquipmentTree> treeList = FindsEquipmentProductionUtil.wrapEquipmentProductionTreeList(list); + List<MdcEquipmentTree> treeList = FindsEquipmentFactoryUtil.wrapEquipmentFactoryTreeList(list); //濉厖璁惧鏁版嵁 - FillEquipmentByProduction(treeList); + FillEquipmentByFactory(treeList); + + +// //鑾峰彇鎵�鏈変骇绾挎暟鎹� +// List<MdcProduction> productionList = mdcProductionService.list(new LambdaQueryWrapper<MdcProduction>().eq(MdcProduction::getDelFlag, CommonConstant.DEL_FLAG_0.toString()).eq(MdcProduction::getMdcFlag, CommonConstant.DEFAULT_1).orderByAsc(MdcProduction::getProductionOrder)); +// //鏍规嵁鐢ㄦ埛id鑾峰彇鎷ユ湁鐨勪骇绾夸俊鎭泦鍚� +// List<String> productionIds = mdcUserProductionService.queryProductionIdsByUserId(userId); +// List<String> allProductionIds = new ArrayList<>(); +// //鎵惧埌鎵�鏈変骇绾縤d鐨勪笂绾d +// if (productionIds != null && !productionIds.isEmpty()) { +// for (String productionId : productionIds) { +// this.getAllProductionIds(productionList, productionId, allProductionIds); +// } +// } +// //杩囨护浜х嚎鏁版嵁 +// List<MdcProduction> list = productionList.stream().filter((MdcProduction mdcProduction) -> allProductionIds.contains(mdcProduction.getId())).collect(Collectors.toList()); +// //缁勮浜х嚎璁惧鏍� +// List<MdcEquipmentTree> treeList = FindsEquipmentProductionUtil.wrapEquipmentProductionTreeList(list); +// 濉厖璁惧鏁版嵁 +// FillEquipmentByProduction(treeList); return treeList; + } + + /** + * 浜х嚎璁惧鏍戝~鍏呰澶囨暟鎹� + */ + private void FillEquipmentByFactory(List<MdcEquipmentTree> treeList) { + for (MdcEquipmentTree mdcEquipmentTree : treeList) { + List<MdcEquipment> equipmentList = this.baseMapper.queryByFactoryId(mdcEquipmentTree.getKey()); + if (equipmentList != null && !equipmentList.isEmpty()) { + for (MdcEquipment mdcEquipment : equipmentList) { + MdcEquipmentTree tree = new MdcEquipmentTree().convert(mdcEquipment); + tree.setParentId(mdcEquipmentTree.getKey()); + tree.setEntity(mdcEquipment); + tree.setType(2); + mdcEquipmentTree.getChildren().add(tree); + } + mdcEquipmentTree.setLeaf(false); + } + if (!mdcEquipmentTree.getChildren().isEmpty()) { + FillEquipmentByFactory(mdcEquipmentTree.getChildren()); + } + } + } + + /** + * 鑾峰彇鎵�鏈夌殑浜х嚎id锛堝寘鍚墍鏈変笂绾э級 + */ + private void getAllFactoryIds(List<Factory> factoryList, String factoryId, List<String> allFactoryIds) { + if (!allFactoryIds.contains(factoryId)) { + allFactoryIds.add(factoryId); + } + for (Factory factory : factoryList) { + if (StringUtils.isEmpty(factory.getParentId())) { + continue; + } + if (factoryId.equals(factory.getId())) { + if (!allFactoryIds.contains(factory.getParentId())) { + allFactoryIds.add(factory.getParentId()); + getAllFactoryIds(factoryList, factory.getParentId(), allFactoryIds); + } + } + } } /** @@ -513,30 +576,74 @@ @Override public List<String> getEquipmentIdsProduction(String userId, String key) { //鑾峰彇鎵�鏈変骇绾挎暟鎹� - List<MdcProduction> productionList = mdcProductionService.list(new LambdaQueryWrapper<MdcProduction>().eq(MdcProduction::getDelFlag, CommonConstant.DEL_FLAG_0.toString()).orderByAsc(MdcProduction::getProductionOrder)); + List<Factory> factoryList = factoryService.list(new LambdaQueryWrapper<Factory>().eq(Factory::getDelFlag, CommonConstant.DEL_FLAG_0).orderByAsc(Factory::getSorter)); //鏍规嵁鐢ㄦ埛id鑾峰彇鎷ユ湁鐨勪骇绾夸俊鎭泦鍚� - List<String> productionIds = mdcUserProductionService.queryProductionIdsByUserId(userId); - List<String> allProductionIds = new ArrayList<>(); + List<String> factoryIds = userFactoryService.queryFactoryIdsByUserId(userId); + List<String> allFactoryIds = new ArrayList<>(); //鎵惧埌鎵�鏈変骇绾縤d鐨勪笂绾d - if (productionIds != null && !productionIds.isEmpty()) { - for (String productionId : productionIds) { - this.getAllProductionIds(productionList, productionId, allProductionIds); + if (factoryIds != null && !factoryIds.isEmpty()) { + for (String productionId : factoryIds) { + this.getAllFactoryIds(factoryList, productionId, allFactoryIds); } } //鏍规嵁浜х嚎闆嗗悎鏌ユ壘鎵�鏈夎澶噄d - if (allProductionIds.isEmpty()) { + if (allFactoryIds.isEmpty()) { return null; } - List<String> equipmentIds = this.baseMapper.queryIdsByProductions(allProductionIds); + List<String> equipmentIds = this.baseMapper.queryIdsByFactorys(allFactoryIds); if (StringUtils.isNotEmpty(key)) { //key涓嶄负绌猴紝鏌ヨ鎵�鏈変笅绾т骇绾縤d - List<String> partProduction = this.findAllProductions(key); - partProduction.add(key); + List<String> partFactory = this.findAllFactorys(key); + partFactory.add(key); //杩囨护鏃犳潈闄愪骇绾縤d - List<String> allProductionIdsByKey = partProduction.stream().filter(allProductionIds::contains).collect(Collectors.toList()); - equipmentIds = this.baseMapper.queryIdsByProductions(allProductionIdsByKey); + List<String> allFactoryIdsByKey = partFactory.stream().filter(allFactoryIds::contains).collect(Collectors.toList()); + equipmentIds = this.baseMapper.queryIdsByFactorys(allFactoryIdsByKey); } return equipmentIds; + + //鑾峰彇鎵�鏈変骇绾挎暟鎹� +// List<MdcProduction> productionList = mdcProductionService.list(new LambdaQueryWrapper<MdcProduction>().eq(MdcProduction::getDelFlag, CommonConstant.DEL_FLAG_0.toString()).orderByAsc(MdcProduction::getProductionOrder)); +// //鏍规嵁鐢ㄦ埛id鑾峰彇鎷ユ湁鐨勪骇绾夸俊鎭泦鍚� +// List<String> productionIds = mdcUserProductionService.queryProductionIdsByUserId(userId); +// List<String> allProductionIds = new ArrayList<>(); +// //鎵惧埌鎵�鏈変骇绾縤d鐨勪笂绾d +// if (productionIds != null && !productionIds.isEmpty()) { +// for (String productionId : productionIds) { +// this.getAllProductionIds(productionList, productionId, allProductionIds); +// } +// } +// //鏍规嵁浜х嚎闆嗗悎鏌ユ壘鎵�鏈夎澶噄d +// if (allProductionIds.isEmpty()) { +// return null; +// } +// List<String> equipmentIds = this.baseMapper.queryIdsByProductions(allProductionIds); +// if (StringUtils.isNotEmpty(key)) { +// //key涓嶄负绌猴紝鏌ヨ鎵�鏈変笅绾т骇绾縤d +// List<String> partProduction = this.findAllProductions(key); +// partProduction.add(key); +// //杩囨护鏃犳潈闄愪骇绾縤d +// List<String> allProductionIdsByKey = partProduction.stream().filter(allProductionIds::contains).collect(Collectors.toList()); +// equipmentIds = this.baseMapper.queryIdsByProductions(allProductionIdsByKey); +// } +// return equipmentIds; +// + } + + /** + * 鏍规嵁鐖剁骇id閫掑綊鏌ヨ鎵�鏈変笅绾d闆嗗悎 + */ + private List<String> findAllFactorys(String key) { + List<String> factoryIds = new ArrayList<>(); + List<Factory> factorys = factoryService.queryFacByPid(key); + if (factorys != null && !factorys.isEmpty()) { + List<String> ids = factorys.stream().map(Factory::getId).collect(Collectors.toList()); + factoryIds.addAll(ids); + for (Factory factory : factorys) { + List<String> allFactorys = findAllFactorys(factory.getId()); + factoryIds.addAll(allFactorys); + } + } + return factoryIds; } /** @@ -590,22 +697,22 @@ return this.baseMapper.selectPage(page, queryWrapper); } - /** - * 鏍规嵁鐖剁骇id閫掑綊鏌ヨ鎵�鏈変笅绾d闆嗗悎 - */ - private List<String> findAllProductions(String key) { - List<String> productions = new ArrayList<>(); - List<MdcProduction> mdcProductions = mdcProductionService.queryProdByPid(key); - if (mdcProductions != null && !mdcProductions.isEmpty()) { - List<String> ids = mdcProductions.stream().map(MdcProduction::getId).collect(Collectors.toList()); - productions.addAll(ids); - for (MdcProduction mdcProduction : mdcProductions) { - List<String> allProductions = findAllProductions(mdcProduction.getId()); - productions.addAll(allProductions); - } - } - return productions; - } +// /** +// * 鏍规嵁鐖剁骇id閫掑綊鏌ヨ鎵�鏈変笅绾d闆嗗悎 +// */ +// private List<String> findAllProductions(String key) { +// List<String> productions = new ArrayList<>(); +// List<MdcProduction> mdcProductions = mdcProductionService.queryProdByPid(key); +// if (mdcProductions != null && !mdcProductions.isEmpty()) { +// List<String> ids = mdcProductions.stream().map(MdcProduction::getId).collect(Collectors.toList()); +// productions.addAll(ids); +// for (MdcProduction mdcProduction : mdcProductions) { +// List<String> allProductions = findAllProductions(mdcProduction.getId()); +// productions.addAll(allProductions); +// } +// } +// return productions; +// } /** * 浜х嚎璁惧鏍戝~鍏呰澶囨暟鎹� @@ -730,7 +837,7 @@ public IPage<MdcEquipment> pageList(Page<MdcEquipment> page, MdcEquipmentVo mdcEquipment, HttpServletRequest req) { if (StringUtils.isNotBlank(mdcEquipment.getProductionName())) { // 閫掑綊鏌ヨ鎵�鏈夊瓙鑺傜偣 - List<String> productionIds = mdcProductionService.recursionChildren(mdcEquipment.getProductionName()); + List<String> productionIds = factoryService.recursionChildren(mdcEquipment.getProductionName()); mdcEquipment.setProductionIds(productionIds); } return this.baseMapper.pageList(page, mdcEquipment); @@ -806,38 +913,38 @@ public List<MdcEquipment> exportXlsList(MdcEquipmentVo mdcEquipment) { if (StringUtils.isNotBlank(mdcEquipment.getProductionName())) { // 閫掑綊鏌ヨ鎵�鏈夊瓙鑺傜偣 - List<String> productionIds = mdcProductionService.recursionChildren(mdcEquipment.getProductionName()); + List<String> productionIds = factoryService.recursionChildren(mdcEquipment.getProductionName()); mdcEquipment.setProductionIds(productionIds); } return this.baseMapper.exportXlsList(mdcEquipment); } - /** - * 閫氳繃杞﹂棿ids鑾峰彇璁惧鏍� - * - * @param ids - * @return - */ - @Override - public List<MdcEquipmentTree> loadTreeListByProductionIds(String ids) { - List<String> productionIds = Arrays.asList(ids.split(",")); - //鑾峰彇鎵�鏈変骇绾挎暟鎹� - List<MdcProduction> productionList = mdcProductionService.list(new LambdaQueryWrapper<MdcProduction>().eq(MdcProduction::getDelFlag, CommonConstant.DEL_FLAG_0.toString()).orderByAsc(MdcProduction::getProductionOrder)); - List<String> allProductionIds = new ArrayList<>(); - //鎵惧埌鎵�鏈変骇绾縤d鐨勪笂绾d - if (!productionIds.isEmpty()) { - for (String productionId : productionIds) { - this.getAllProductionIds(productionList, productionId, allProductionIds); - } - } - //杩囨护浜х嚎鏁版嵁 - List<MdcProduction> list = productionList.stream().filter((MdcProduction mdcProduction) -> allProductionIds.contains(mdcProduction.getId())).collect(Collectors.toList()); - //缁勮浜х嚎璁惧鏍� - List<MdcEquipmentTree> treeList = FindsEquipmentProductionUtil.wrapEquipmentProductionTreeList(list); - //濉厖璁惧鏁版嵁 - FillEquipmentByProduction(treeList); - return treeList; - } +// /** +// * 閫氳繃杞﹂棿ids鑾峰彇璁惧鏍� +// * +// * @param ids +// * @return +// */ +// @Override +// public List<MdcEquipmentTree> loadTreeListByProductionIds(String ids) { +// List<String> productionIds = Arrays.asList(ids.split(",")); +// //鑾峰彇鎵�鏈変骇绾挎暟鎹� +// List<MdcProduction> productionList = mdcProductionService.list(new LambdaQueryWrapper<MdcProduction>().eq(MdcProduction::getDelFlag, CommonConstant.DEL_FLAG_0.toString()).orderByAsc(MdcProduction::getProductionOrder)); +// List<String> allProductionIds = new ArrayList<>(); +// //鎵惧埌鎵�鏈変骇绾縤d鐨勪笂绾d +// if (!productionIds.isEmpty()) { +// for (String productionId : productionIds) { +// this.getAllProductionIds(productionList, productionId, allProductionIds); +// } +// } +// //杩囨护浜х嚎鏁版嵁 +// List<MdcProduction> list = productionList.stream().filter((MdcProduction mdcProduction) -> allProductionIds.contains(mdcProduction.getId())).collect(Collectors.toList()); +// //缁勮浜х嚎璁惧鏍� +// List<MdcEquipmentTree> treeList = FindsEquipmentProductionUtil.wrapEquipmentProductionTreeList(list); +// //濉厖璁惧鏁版嵁 +// FillEquipmentByProduction(treeList); +// return treeList; +// } /** * 鏌ヨ鍗曡〃鏁版嵁 @@ -948,21 +1055,21 @@ return this.baseMapper.selectList(new LambdaQueryWrapper<MdcEquipment>().in(MdcEquipment::getEquipmentId, Arrays.asList(user.getEquipmentIds().split(StringPool.COMMA)))); } //鑾峰彇鎵�鏈変骇绾挎暟鎹� - List<MdcProduction> productionList = mdcProductionService.list(new LambdaQueryWrapper<MdcProduction>().eq(MdcProduction::getDelFlag, CommonConstant.DEL_FLAG_0.toString()).orderByAsc(MdcProduction::getProductionOrder)); + List<Factory> factoryList = factoryService.list(new LambdaQueryWrapper<Factory>().eq(Factory::getDelFlag, CommonConstant.DEL_FLAG_0.toString()).orderByAsc(Factory::getSorter)); //鏍规嵁鐢ㄦ埛id鑾峰彇鎷ユ湁鐨勪骇绾夸俊鎭泦鍚� - List<String> productionIds = mdcUserProductionService.queryProductionIdsByUserId(userId); - List<String> allProductionIds = new ArrayList<>(); + List<String> factoryIds = userFactoryService.queryFactoryIdsByUserId(userId); + List<String> allFactoryIds = new ArrayList<>(); //鎵惧埌鎵�鏈変骇绾縤d鐨勪笂绾d - if (productionIds != null && !productionIds.isEmpty()) { - for (String productionId : productionIds) { - this.getAllProductionIds(productionList, productionId, allProductionIds); + if (factoryIds != null && !factoryIds.isEmpty()) { + for (String factoryId : factoryIds) { + this.getAllFactoryIds(factoryList, factoryId, allFactoryIds); } } //鏍规嵁浜х嚎闆嗗悎鏌ユ壘鎵�鏈夎澶噄d - if (allProductionIds.isEmpty()) { + if (allFactoryIds.isEmpty()) { return null; } - List<MdcEquipment> equipmentIds = this.baseMapper.getEquipmentList(allProductionIds); + List<MdcEquipment> equipmentIds = this.baseMapper.getEquipmentList(allFactoryIds); return equipmentIds; } diff --git a/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentStatisticalInfoServiceImpl.java b/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentStatisticalInfoServiceImpl.java index bd38a45..b38b863 100644 --- a/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentStatisticalInfoServiceImpl.java +++ b/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentStatisticalInfoServiceImpl.java @@ -37,8 +37,8 @@ @Resource private IMdcSystemParametersService mdcSystemParametersService; - @Resource - private IMdcEquipmentFaultInfoService mdcEquipmentFaultInfoService; +// @Resource +// private IMdcEquipmentFaultInfoService mdcEquipmentFaultInfoService; /** * 璁$畻璁惧鍗曟棩杩愯鏁版嵁 @@ -68,7 +68,7 @@ if (!result.isEmpty()) { this.saveBatch(result); } - mdcEquipmentFaultInfoService.runningAllEquFaultStatistical(dateTime); +// mdcEquipmentFaultInfoService.runningAllEquFaultStatistical(dateTime); } private List<MdcEquipmentStatisticalInfo> equipmentStatisticalProcess(Equipment equipment, String dateTime) { diff --git a/src/main/java/org/jeecg/modules/mdc/service/impl/MdcProductionEquipmentServiceImpl.java b/src/main/java/org/jeecg/modules/mdc/service/impl/MdcProductionEquipmentServiceImpl.java deleted file mode 100644 index a4aa655..0000000 --- a/src/main/java/org/jeecg/modules/mdc/service/impl/MdcProductionEquipmentServiceImpl.java +++ /dev/null @@ -1,87 +0,0 @@ -package org.jeecg.modules.mdc.service.impl; - -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import org.jeecg.modules.mdc.entity.MdcEquipment; -import org.jeecg.modules.mdc.mapper.MdcProductionEquipmentMapper; -import org.jeecg.modules.mdc.service.IMdcEquipmentService; -import org.jeecg.modules.mdc.service.IMdcProductionEquipmentService; -import org.jeecg.modules.mdc.entity.MdcProduction; -import org.jeecg.modules.mdc.entity.MdcProductionEquipment; -import org.jeecg.modules.mdc.model.ProductionIdModel; -import org.jeecg.modules.mdc.service.IMdcProductionService; -import org.springframework.stereotype.Service; - -import javax.annotation.Resource; -import java.util.ArrayList; -import java.util.List; -import java.util.stream.Collectors; - -/** - * @author: LiuS - * @create: 2023-03-28 10:31 - */ -@Service -public class MdcProductionEquipmentServiceImpl extends ServiceImpl<MdcProductionEquipmentMapper, MdcProductionEquipment> implements IMdcProductionEquipmentService { - - @Resource - private IMdcProductionService mdcProductionService; - @Resource - private IMdcEquipmentService mdcEquipmentService; - - /** - * 鏍规嵁璁惧id鏌ヨ浜х嚎淇℃伅 - */ - @Override - public List<ProductionIdModel> queryProductionIdsOfEquipment(String equipmentId) { - LambdaQueryWrapper<MdcProductionEquipment> queryEquipmentPro = new LambdaQueryWrapper<>(); - LambdaQueryWrapper<MdcProduction> queryPro = new LambdaQueryWrapper<>(); - try { - queryEquipmentPro.eq(MdcProductionEquipment::getEquipmentId, equipmentId); - List<String> proIdList = new ArrayList<>(); - List<ProductionIdModel> proIdModelList = new ArrayList<>(); - List<MdcProductionEquipment> equipmentProList = this.list(queryEquipmentPro); - if (equipmentProList != null && !equipmentProList.isEmpty()) { - for (MdcProductionEquipment productionEquipment : equipmentProList) { - proIdList.add(productionEquipment.getProductionId()); - } - queryPro.in(MdcProduction::getId, proIdList); - List<MdcProduction> proList = mdcProductionService.list(queryPro); - if (proList != null && !proList.isEmpty()) { - for (MdcProduction mdcProduction : proList) { - proIdModelList.add(new ProductionIdModel().convertByUserProduction(mdcProduction)); - } - } - return proIdModelList; - } - } catch (Exception e) { - e.fillInStackTrace(); - } - return null; - } - /** - * 鏍规嵁鎸囧畾浜х嚎id鏌ヨ璁惧淇℃伅 - */ - @Override - public List<MdcEquipment> queryEquipmentsOfProduction(String productionId){ - List<String> equipmentIds = this.list(new LambdaQueryWrapper<MdcProductionEquipment>().eq(MdcProductionEquipment::getProductionId, productionId)) - .stream().map(MdcProductionEquipment::getEquipmentId).collect(Collectors.toList()); - if (!equipmentIds.isEmpty()) { - return mdcEquipmentService.list(new LambdaQueryWrapper<MdcEquipment>().in(MdcEquipment::getId, equipmentIds)); - } - return null; - } - - /** - * 鏍规嵁鎸囧畾浜х嚎ids鏌ヨ璁惧淇℃伅 - */ - @Override - public List<MdcEquipment> queryEquipmentsOfProductions(List<String> productionIds){ - List<String> equipmentIds = this.list(new LambdaQueryWrapper<MdcProductionEquipment>() - .in(MdcProductionEquipment::getProductionId, productionIds)).stream().map(MdcProductionEquipment::getEquipmentId).collect(Collectors.toList()); - if (!equipmentIds.isEmpty()) { - return mdcEquipmentService.list(new LambdaQueryWrapper<MdcEquipment>().in(MdcEquipment::getId, equipmentIds)); - } - return null; - } -} diff --git a/src/main/java/org/jeecg/modules/mdc/service/impl/MdcProductionServiceImpl.java b/src/main/java/org/jeecg/modules/mdc/service/impl/MdcProductionServiceImpl.java deleted file mode 100644 index 3ba9d7c..0000000 --- a/src/main/java/org/jeecg/modules/mdc/service/impl/MdcProductionServiceImpl.java +++ /dev/null @@ -1,649 +0,0 @@ -package org.jeecg.modules.mdc.service.impl; - -import cn.hutool.core.collection.CollectionUtil; -import cn.hutool.core.util.StrUtil; -import com.alibaba.fastjson.JSONObject; -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; -import com.baomidou.mybatisplus.core.toolkit.IdWorker; -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import org.apache.commons.lang3.StringUtils; -import org.apache.shiro.SecurityUtils; -import org.jeecg.common.constant.CommonConstant; -import org.jeecg.common.constant.FillRuleConstant; -import org.jeecg.common.system.vo.DictModel; -import org.jeecg.common.system.vo.LoginUser; -import org.jeecg.common.util.FillRuleUtil; -import org.jeecg.common.util.oConvertUtils; -import org.jeecg.modules.mdc.entity.MdcProduction; -import org.jeecg.modules.mdc.entity.MdcProductionEquipment; -import org.jeecg.modules.mdc.entity.MdcUserProduction; -import org.jeecg.modules.mdc.mapper.MdcProductionEquipmentMapper; -import org.jeecg.modules.mdc.mapper.MdcProductionMapper; -import org.jeecg.modules.mdc.mapper.MdcUserProductionMapper; -import org.jeecg.modules.mdc.model.MdcProductionTreeModel; -import org.jeecg.modules.mdc.model.ProductionIdModel; -import org.jeecg.modules.mdc.service.IMdcProductionService; -import org.jeecg.modules.mdc.util.FindsProductionsChildrenUtil; -import org.jeecg.modules.mdc.vo.MdcProOptionsVo; -import org.jeecg.modules.system.entity.SysParams; -import org.jeecg.modules.system.entity.SysUser; -import org.jeecg.modules.system.mapper.SysUserMapper; -import org.jeecg.modules.system.service.ISysDictService; -import org.jeecg.modules.system.service.ISysParamsService; -import org.springframework.cache.annotation.Cacheable; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - -import javax.annotation.Resource; -import java.util.*; -import java.util.stream.Collectors; - -/** - * @Description: 浜х嚎琛� - * @Author: liuS - * @Date: 2023-03-23 - * @Version: V1.0 - */ -@Service -public class MdcProductionServiceImpl extends ServiceImpl<MdcProductionMapper, MdcProduction> implements IMdcProductionService { - - @Resource - private SysUserMapper sysUserMapper; - - @Resource - private MdcUserProductionMapper userProductionMapper; - - @Resource - private MdcProductionEquipmentMapper productionEquipmentMapper; - - @Resource - private ISysParamsService sysParamsService; - - @Resource - private ISysDictService sysDictService; - /** - * queryTreeList 瀵瑰簲 queryTreeList 鏌ヨ鎵�鏈夌殑浜х嚎鏁版嵁,浠ユ爲缁撴瀯褰㈠紡鍝嶅簲缁欏墠绔� - */ - @Override - @Cacheable(value = "mdc:cache:production:alldata") - public List<MdcProductionTreeModel> queryTreeList() { - LambdaQueryWrapper<MdcProduction> query = new LambdaQueryWrapper<MdcProduction>(); - query.eq(MdcProduction::getDelFlag, CommonConstant.DEL_FLAG_0.toString()); - query.orderByAsc(MdcProduction::getProductionOrder); - List<MdcProduction> list = this.list(query); - //璁剧疆鐢ㄦ埛id锛岃鍓嶅彴鏄剧ず - this.setUserIdsByProList(list); - //璋冪敤wrapTreeDataToTreeList鏂规硶鐢熸垚鏍戠姸鏁版嵁 - return FindsProductionsChildrenUtil.wrapTreeDataToTreeList(list); - } - - /** - * 鏌ヨ鎵�鏈変骇绾夸俊鎭紝骞跺垎鑺傜偣杩涜鏄剧ず(娣诲姞绯荤粺閰嶇疆) - */ - @Override - public List<MdcProductionTreeModel> queryTreeListByConfig(){ - SysParams sysParams = sysParamsService.getSysPramBySettingKey("dnc_production"); - LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal(); - LambdaQueryWrapper<MdcProduction> query = new LambdaQueryWrapper<MdcProduction>(); - if (sysParams == null) { - return null; - }else { - List<String> productionIds = new ArrayList<>(); - if (!("admin").equals(loginUser.getUsername())) { - //涓嶆槸瓒呯骇绠$悊鍛橈紝鑾峰彇鐢ㄦ埛鎷ユ湁鐨勪骇绾� - if (loginUser.getProductionIds() != null) { - if (loginUser.getProductionIds().contains(",")) { - productionIds = Arrays.asList(loginUser.getProductionIds().split(",")); - } else { - productionIds = Collections.singletonList(loginUser.getProductionIds()); - } - } - } - if (("0").equals(sysParams.getSettingValue())){ - query.eq(MdcProduction::getOrgType,"2"); - query.in(!productionIds.isEmpty(), MdcProduction::getId, productionIds); - query.eq(MdcProduction::getDelFlag, CommonConstant.DEL_FLAG_0.toString()); - query.orderByAsc(MdcProduction::getProductionOrder); - List<MdcProduction> list = this.list(query); - //璁剧疆鐢ㄦ埛id锛岃鍓嶅彴鏄剧ず - this.setUserIdsByProList(list); - //灏佽涓�绾ф爲 - List<MdcProductionTreeModel> listResult = new ArrayList<>(); - for (MdcProduction production : list) { - if (production.getDescription().isEmpty()){ - production.setDescription(""); - } - listResult.add(new MdcProductionTreeModel(production)); - } - //璋冪敤wrapTreeDataToTreeList鏂规硶鐢熸垚鏍戠姸鏁版嵁 - return listResult; - }else { - query.eq(MdcProduction::getDelFlag, CommonConstant.DEL_FLAG_0.toString()); - query.orderByAsc(MdcProduction::getProductionOrder); - List<MdcProduction> list = this.list(query); - //璁剧疆鐢ㄦ埛id锛岃鍓嶅彴鏄剧ず - this.setUserIdsByProList(list); - //璋冪敤wrapTreeDataToTreeList鏂规硶鐢熸垚鏍戠姸鏁版嵁 - return FindsProductionsChildrenUtil.wrapTreeDataToTreeList(list); - } - } - } - - /** - * queryTreeList 鏍规嵁浜х嚎id鏌ヨ,鍓嶇鍥炴樉璋冪敤 - */ - @Override - public List<MdcProductionTreeModel> queryTreeList(String ids) { - List<MdcProductionTreeModel> listResult = new ArrayList<>(); - LambdaQueryWrapper<MdcProduction> query = new LambdaQueryWrapper<MdcProduction>(); - query.eq(MdcProduction::getDelFlag, CommonConstant.DEL_FLAG_0.toString()); - if (oConvertUtils.isNotEmpty(ids)) { - query.in(true, MdcProduction::getId, ids.split(",")); - } - query.orderByAsc(MdcProduction::getProductionOrder); - List<MdcProduction> list = this.list(query); - for (MdcProduction production : list) { - if (production.getDescription().isEmpty()){ - production.setDescription(""); - } - listResult.add(new MdcProductionTreeModel(production)); - } - return listResult; - } - - @Override - @Cacheable(value = "mdc:cache:production:allids") - public List<ProductionIdModel> queryProductionIdTreeList() { - LambdaQueryWrapper<MdcProduction> query = new LambdaQueryWrapper<>(); - query.eq(MdcProduction::getDelFlag, CommonConstant.DEL_FLAG_0.toString()); - query.orderByAsc(MdcProduction::getProductionOrder); - List<MdcProduction> list = this.list(query); - //璋冪敤wrapTreeDataToTreeList鏂规硶鐢熸垚鏍戠姸鏁版嵁 - return FindsProductionsChildrenUtil.wrapTreeDataToProductionIdTreeList(list); - } - - /** - * 鏍规嵁鍏抽敭瀛楁悳绱㈢浉鍏崇殑閮ㄩ棬鏁版嵁 - */ - @Override - public List<MdcProductionTreeModel> searchByKeyWord(String keyWord) { - LambdaQueryWrapper<MdcProduction> query = new LambdaQueryWrapper<>(); - List<MdcProductionTreeModel> newList = new ArrayList<>(); - query.like(MdcProduction::getProductionName, keyWord); - MdcProductionTreeModel model = new MdcProductionTreeModel(); - List<MdcProduction> productionList = this.list(query); - if (!productionList.isEmpty()) { - for (MdcProduction mdcProduction : productionList) { - model = new MdcProductionTreeModel(mdcProduction); - model.setChildren(null); - newList.add(model); - } - return newList; - } - return Collections.emptyList(); - } - - /** - * saveProductionData 瀵瑰簲 add 淇濆瓨鐢ㄦ埛鍦ㄩ〉闈㈡坊鍔犵殑鏂扮殑浜х嚎瀵硅薄鏁版嵁 - */ - @Override - @Transactional(rollbackFor = Exception.class) - public void saveProductionData(MdcProduction mdcProduction) { - if (mdcProduction != null) { - if (mdcProduction.getParentId() == null) { - mdcProduction.setParentId(""); - } - mdcProduction.setId(IdWorker.getIdStr(mdcProduction)); - // 鍏堝垽鏂瀵硅薄鏈夋棤鐖剁骇ID,鏈夊垯鎰忓懗鐫�涓嶆槸鏈�楂樼骇,鍚﹀垯鎰忓懗鐫�鏄渶楂樼骇 - // 鑾峰彇鐖剁骇ID - String parentId = mdcProduction.getParentId(); - JSONObject formData = new JSONObject(); - formData.put("parentId",parentId); - String[] codeArray = (String[]) FillRuleUtil.executeRule(FillRuleConstant.PRODUCTION,formData); - mdcProduction.setOrgCode(codeArray[0]); - String orgType = codeArray[1]; - mdcProduction.setOrgType(String.valueOf(orgType)); - mdcProduction.setDelFlag(CommonConstant.DEL_FLAG_0.toString()); - this.save(mdcProduction); - - //澶勭悊瀛樺湪鐖跺瓙鍏崇郴 mdc鏍囪缁熶竴鐨勯棶棰� - //1.mdc鏍囪 涓� 1 寮�鍚� 鐖剁骇鑺傜偣瑕佺粺涓�寮�鍚� - //2.mdc鏍囪 涓� 0 鍏抽棴 瀛愮骇鑺傜偣瑕佺粺涓�鍏抽棴 鏂板鎿嶄綔 涓嶅瓨鍦ㄦ鎯呭喌 - if(StringUtils.isNotBlank(parentId) && CommonConstant.DEFAULT_1.equals(mdcProduction.getMdcFlag())){ - openParentMdcFlag(parentId); - } - } - } - - /** - * updateProductionDataById 瀵瑰簲 edit 鏍规嵁浜х嚎涓婚敭鏉ユ洿鏂板搴旂殑浜х嚎鏁版嵁 - */ - @Override - @Transactional(rollbackFor = Exception.class) - public boolean updateProductionDataById(MdcProduction mdcProduction) { - if (mdcProduction != null) { - this.updateById(mdcProduction); - - //澶勭悊瀛樺湪鐖跺瓙鍏崇郴 mdc鏍囪缁熶竴鐨勯棶棰� - //1.mdc鏍囪 涓� 1 寮�鍚� 鐖剁骇鑺傜偣瑕佺粺涓�寮�鍚� - //2.mdc鏍囪 涓� 0 鍏抽棴 瀛愮骇鑺傜偣瑕佺粺涓�鍏抽棴 - String parentId = mdcProduction.getParentId(); - if(StringUtils.isNotBlank(parentId) && CommonConstant.DEFAULT_1.equals(mdcProduction.getMdcFlag())){ - openParentMdcFlag(parentId); - } - if(CommonConstant.DEFAULT_0.equals(mdcProduction.getMdcFlag())){ - //鍏抽棴 - closeChildrenMdcFlag(mdcProduction.getId()); - } - return true; - } - return false; - } - - /** - * 鏍规嵁浜х嚎id鍒犻櫎骞跺垹闄ゅ叾鍙兘瀛樺湪鐨勫瓙绾т骇绾� - */ - @Override - @Transactional(rollbackFor = Exception.class) - public boolean delete(String id) { - List<String> idList = new ArrayList<>(); - idList.add(id); - this.checkChildrenExists(id, idList); - boolean result = this.removeByIds(idList); - //鏍规嵁浜х嚎id鍒犻櫎鐢ㄦ埛涓庝骇绾垮叧绯� - userProductionMapper.delete(new LambdaQueryWrapper<MdcUserProduction>().in(MdcUserProduction::getProId, idList)); - //鏍规嵁浜х嚎id鍒犻櫎浜х嚎涓庤澶囧叧绯� - productionEquipmentMapper.delete(new LambdaQueryWrapper<MdcProductionEquipment>().in(MdcProductionEquipment::getProductionId, idList)); - return result; - } - - /** - * 鏍规嵁浜х嚎id鎵归噺鍒犻櫎骞跺垹闄ゅ叾鍙兘瀛樺湪鐨勫瓙绾т骇绾� - */ - @Override - @Transactional(rollbackFor = Exception.class) - public void deleteBatchWithChildren(List<String> ids) { - List<String> idList = new ArrayList<>(); - for (String id : ids) { - idList.add(id); - this.checkChildrenExists(id, idList); - } - this.removeByIds(idList); - //鏍规嵁浜х嚎id鍒犻櫎鐢ㄦ埛涓庝骇绾垮叧绯� - userProductionMapper.delete(new LambdaQueryWrapper<MdcUserProduction>().in(MdcUserProduction::getProId, idList)); - //鏍规嵁浜х嚎id鍒犻櫎浜х嚎涓庤澶囧叧绯� - productionEquipmentMapper.delete(new LambdaQueryWrapper<MdcProductionEquipment>().in(MdcProductionEquipment::getProductionId, idList)); - } - - /** - * 鏍规嵁id鏌ヨ涓嬬骇浜х嚎 - */ - @Override - public List<MdcProduction> queryProdByPid(String pid) { - return this.baseMapper.queryProdByPid(pid); - } - - /** - * 閫掑綊鏌ヨ鎵�鏈夊瓙鑺傜偣 - */ - @Override - public List<MdcProduction> recursionChildrenByPid(String pid){ - List<String> ids=this.recursionChildren(pid); - return super.list(new LambdaQueryWrapper<MdcProduction>().eq(MdcProduction::getDelFlag, CommonConstant.DEL_FLAG_0.toString()).in(MdcProduction::getId, ids)); - } - - /** - * 鏍规嵁鐢ㄦ埛id鑾峰彇浜х嚎涓嬫媺鏍戦�夐」 - */ - @Override - public List<ProductionIdModel> loadProductionTreeOptions(String userId) { - //鑾峰彇鎵�鏈変骇绾挎暟鎹� - List<MdcProduction> productionList = this.baseMapper.selectList(new LambdaQueryWrapper<MdcProduction>().eq(MdcProduction::getDelFlag, CommonConstant.DEL_FLAG_0.toString()).orderByAsc(MdcProduction::getProductionOrder)); - //鏍规嵁鐢ㄦ埛id鑾峰彇鎷ユ湁鐨勪骇绾夸俊鎭泦鍚� - List<String> productionIds = userProductionMapper.queryProductionIdsByUserId(userId); - List<String> allProductionIds = new ArrayList<>(); - //鎵惧埌鎵�鏈変骇绾縤d鐨勪笂绾d - if (productionIds != null && !productionIds.isEmpty()) { - for (String productionId : productionIds) { - this.getAllProductionIds(productionList, productionId, allProductionIds); - } - } - //杩囨护浜х嚎鏁版嵁 - List<MdcProduction> list = productionList.stream().filter((MdcProduction mdcProduction) -> allProductionIds.contains(mdcProduction.getId())).collect(Collectors.toList()); - return FindsProductionsChildrenUtil.wrapTreeDataToProductionIdTreeList(list); - } - - /** - * 閫掑綊鏌ヨ鎵�鏈夊瓙鑺傜偣id - */ - @Override - public List<String> recursionChildren(String productionId) { - return this.baseMapper.recursionChildren(productionId); - } - - /** - * 鏍规嵁鐢ㄦ埛id鍜岃溅闂磇d鑾峰彇鐢ㄦ埛鎷ユ湁鐨勮溅闂磇d - * @param userId - * @param productionId - * @return - */ - @Override - public String findFirstProduction(String userId, String productionId) { - return this.baseMapper.findFirstProduction(userId, productionId); - } - - /** - * 鏍规嵁鐢ㄦ埛id鏌ヨ鐢ㄦ埛宸ユ鏉冮檺 - */ - @Override - public String findThreeProductionId(String userId) { - return this.baseMapper.findThreeProductionId(userId); - } - - /** - * delete 鏂规硶璋冪敤 閫掑綊鏌ユ壘瀛愰泦id - */ - private void checkChildrenExists(String id, List<String> idList) { - LambdaQueryWrapper<MdcProduction> query = new LambdaQueryWrapper<>(); - query.eq(MdcProduction::getParentId, id); - List<MdcProduction> productionList = this.list(query); - if (productionList != null && !productionList.isEmpty()) { - for (MdcProduction production : productionList) { - idList.add(production.getId()); - this.checkChildrenExists(production.getId(), idList); - } - } - } - - /** - * 鑾峰彇鎵�鏈夌殑浜х嚎id锛堝寘鍚墍鏈変笂绾э級 - */ - private void getAllProductionIds(List<MdcProduction> productionList, String productionId, List<String> allProductionIds) { - if (!allProductionIds.contains(productionId)) { - allProductionIds.add(productionId); - } - for (MdcProduction mdcProduction : productionList) { - if (StringUtils.isEmpty(mdcProduction.getParentId())) { - continue; - } - if (productionId.equals(mdcProduction.getId())) { - if (!allProductionIds.contains(mdcProduction.getParentId())) { - allProductionIds.add(mdcProduction.getParentId()); - getAllProductionIds(productionList, mdcProduction.getParentId(), allProductionIds); - } - } - } - } - - /** - * 閫氳繃浜х嚎闆嗗悎涓轰骇绾胯缃敤鎴穒d锛岀敤浜庡墠鍙板睍绀� - */ - private void setUserIdsByProList(List<MdcProduction> productionList) { - //鏌ヨ璐熻矗閮ㄩ棬涓嶄负绌虹殑鎯呭喌 - LambdaQueryWrapper<SysUser> query = new LambdaQueryWrapper<>(); - query.isNotNull(SysUser::getDepartIds); - List<SysUser> users = sysUserMapper.selectList(query); - Map<String, Object> map = new HashMap(5); - //鍏堝惊鐜竴閬嶆壘鍒颁笉鍚岀殑璐熻矗浜х嚎id - for (SysUser user : users) { - String productionIds = user.getProductionIds(); - if (StringUtils.isNotBlank(productionIds)) { - String[] productionIdArray = productionIds.split(","); - for (String productionId : productionIdArray) { - if (map.containsKey(productionId)) { - String userIds = map.get(productionId) + "," + user.getId(); - map.put(productionId, userIds); - } else { - map.put(productionId, user.getId()); - } - } - } - } - //寰幆浜х嚎闆嗗悎鎵惧埌浜х嚎id瀵瑰簲鐨勮礋璐g敤鎴� - for (MdcProduction mdcProduction : productionList) { - if (map.containsKey(mdcProduction.getId())) { - mdcProduction.setDirectorUserIds(map.get(mdcProduction.getId()).toString()); - } - } - } - - /** - * 鏌ヨ鎵�鏈夌埗鑺傜偣鍜屾湰鑺傜偣鍚嶇О - * @param id - * @return - */ - @Override - public List<String> findListParentTreeAll(String id){ - MdcProductionEquipment mdcProductionEquipment=productionEquipmentMapper.selectOne(new QueryWrapper<MdcProductionEquipment>().eq("equipment_id",id)); - if (mdcProductionEquipment==null) { - return null; - } - List<String> strings = new ArrayList<>(); - MdcProduction en=super.getById(mdcProductionEquipment.getProductionId()); - if (en == null) { - return null; - } - strings.add(en.getProductionName()); - if (StringUtils.isEmpty(en.getParentId())) { - return strings; - } else { - return findListParentTree(en.getParentId(),strings); - } - } - - // 鏌ヨ鎵�浠ョ埗鑺傜偣 - @Override - public List<String> findListParentTree(String parentId,List<String> stringList){ - if (StringUtils.isEmpty(parentId)) { - return null; - } - if (stringList == null || stringList.isEmpty()) { - stringList = new ArrayList<>(); - } - boolean p = true; - if (p) { - MdcProduction en = super.getById(parentId); - if (en != null) { - stringList.add(0,en.getProductionName()); - } - if (StringUtils.isNotBlank(en.getParentId())) { - parentId = en.getParentId(); - findListParentTree(parentId,stringList); - } else { - p = false; - return stringList; - } - } - return stringList; - } - - /** - * 鑾峰彇鐢ㄦ埛宸插垎閰嶇殑閮ㄩ棬鍒楄〃 - * @param userId - * @return - */ - @Override - public Map<String, MdcProduction> getUserAssignedDepart(String userId){ - if(StrUtil.isEmpty(userId)) - return null; - List<MdcProduction> userPermDepart = this.baseMapper.findAllProductionId(userId); - if(userPermDepart == null || userPermDepart.isEmpty()) - return null; - Map<String, MdcProduction> map = new HashMap<>(); - userPermDepart.forEach(item -> { - map.put(item.getId(), item); - }); - return map; - } - - /** - * 閫氳繃涓�缁刬d鑾峰彇閮ㄩ棬 - * @param ids - * @return - */ - @Override - public List<String> findAllProductionIds(List<String> ids){ - return this.baseMapper.recursionChildrenByList(ids); - } - - @Override - public List<String> findParentIdsForProduction(String parentId, List<String> idList) { - if (StringUtils.isEmpty(parentId)) { - return null; - } - if (idList == null || idList.isEmpty()) { - idList = new ArrayList<>(); - } - boolean p = true; - if (p) { - MdcProduction en = super.getById(parentId); - if (en != null) { - idList.add(0, en.getId()); - } - if (StringUtils.isNotBlank(en.getParentId())) { - parentId = en.getParentId(); - findParentIdsForProduction(parentId, idList); - } else { - p = false; - return idList; - } - } - return idList; - } - - @Override - public List<MdcProductionTreeModel> queryTreeListByMdc(String ids) { - List<MdcProductionTreeModel> listResult = new ArrayList<>(); - LambdaQueryWrapper<MdcProduction> query = new LambdaQueryWrapper<MdcProduction>(); - query.eq(MdcProduction::getDelFlag, CommonConstant.DEL_FLAG_0.toString()); - query.eq(MdcProduction::getMdcFlag, CommonConstant.DEFAULT_1); - if (oConvertUtils.isNotEmpty(ids)) { - query.in(true, MdcProduction::getId, ids.split(",")); - } - query.orderByAsc(MdcProduction::getProductionOrder); - List<MdcProduction> list = this.list(query); - for (MdcProduction production : list) { - if (production.getDescription().isEmpty()){ - production.setDescription(""); - } - listResult.add(new MdcProductionTreeModel(production)); - } - return listResult; - } - - @Override - public List<MdcProductionTreeModel> queryTreeListByMdc() { - LambdaQueryWrapper<MdcProduction> query = new LambdaQueryWrapper<MdcProduction>(); - query.eq(MdcProduction::getDelFlag, CommonConstant.DEL_FLAG_0.toString()); - query.eq(MdcProduction::getMdcFlag, CommonConstant.DEFAULT_1); - query.orderByAsc(MdcProduction::getProductionOrder); - List<MdcProduction> list = this.list(query); - //璁剧疆鐢ㄦ埛id锛岃鍓嶅彴鏄剧ず - this.setUserIdsByProList(list); - //璋冪敤wrapTreeDataToTreeList鏂规硶鐢熸垚鏍戠姸鏁版嵁 - return FindsProductionsChildrenUtil.wrapTreeDataToTreeList(list); - } - - @Override - public List<String> findChildren(List<String> mdcProductionIds) { - return this.baseMapper.findChildren(mdcProductionIds); - } - - /** - * 鏍规嵁鐢ㄦ埛id鑾峰彇浜х嚎(涓績)鎴栫彮缁勪笅鎷夐�夐」 - * @param userId - * @param productionId - * @return - */ - @Override - public List<MdcProOptionsVo> loadProductionOptions(String userId, String productionId) { - List<MdcProOptionsVo> result = new ArrayList<>(); - List<MdcProduction> mdcProductionList = this.baseMapper.loadProductionOptions(userId, productionId); - if (mdcProductionList != null && !mdcProductionList.isEmpty()) { - for (MdcProduction mdcProduction : mdcProductionList) { - MdcProOptionsVo vo = new MdcProOptionsVo().convert(mdcProduction); - result.add(vo); - } - } - return result; - } - - @Override - public List<MdcProduction> findMdcPros(String userId, String productionId) { - return this.baseMapper.loadProductionOptions(userId, productionId); - } - - @Override - public List<MdcProOptionsVo> loadTeamOptions(String userId, String productionId) { - List<MdcProOptionsVo> result = new ArrayList<>(); - List<String> productionList = this.findChildren(Arrays.asList(productionId.split(","))); - if (productionList != null && !productionList.isEmpty()) { - List<String> dictValues = this.baseMapper.findTeamValue(userId, productionList); - if (dictValues != null && !dictValues.isEmpty()) { - List<DictModel> dictModels = sysDictService.queryEnableDictItemsByCode(CommonConstant.DICT_MDC_STAFF_TEAM); - if (dictModels != null && !dictModels.isEmpty()) { - for (DictModel dictModel : dictModels) { - if (dictValues.contains(dictModel.getValue())) { - MdcProOptionsVo vo = new MdcProOptionsVo(); - vo.setKey(dictModel.getValue()); - vo.setValue(dictModel.getValue()); - vo.setTitle(dictModel.getText()); - result.add(vo); - } - } - } - } - } - return result; - } - - @Override - public List<String> findProIdsByUId(String userId, List<String> allProductionIds) { - return this.baseMapper.findProIdsByUId(userId, allProductionIds); - } - - /** - * 鎵撳紑 鐖惰妭鐐� 鍙� 浠ヤ笂鐨刴dc鏍囪 - * @param parentId - */ - private void openParentMdcFlag(String parentId) { - List<String> listParentTree = findParentIdsForProduction(parentId, new ArrayList<>()); - if (!CollectionUtil.isEmpty(listParentTree)) { - UpdateWrapper<MdcProduction> updateWrapper = new UpdateWrapper<>(); - updateWrapper.in("id", listParentTree); - updateWrapper.set("mdc_flag", "1"); - super.update(updateWrapper); - } - } - - /** - * 鍏抽棴鎵�鏈夊瓙鑺傜偣鐨刴dc鏍囪 - * @param productionId - */ - private void closeChildrenMdcFlag(String productionId) { - List<String> childrenList = recursionChildren(productionId); - if (!CollectionUtil.isEmpty(childrenList)) { - UpdateWrapper<MdcProduction> updateWrapper = new UpdateWrapper<>(); - updateWrapper.in("id", childrenList); - updateWrapper.set("mdc_flag", "0"); - super.update(updateWrapper); - } - } - - @Override - public List<String> findChildByProId(String productionId) { - return this.baseMapper.findChildByProId(productionId); - } - - @Override - public String findProName(String equipmentId) { - return this.baseMapper.findProName(equipmentId); - } - - @Override - public MdcProduction findByOrgCode(String orgCode){ - return this.baseMapper.selectOne(new LambdaQueryWrapper<MdcProduction>().eq(MdcProduction::getOrgCode, orgCode)); - } -} diff --git a/src/main/java/org/jeecg/modules/mdc/service/impl/MdcUserProductionServiceImpl.java b/src/main/java/org/jeecg/modules/mdc/service/impl/MdcUserProductionServiceImpl.java deleted file mode 100644 index 455999c..0000000 --- a/src/main/java/org/jeecg/modules/mdc/service/impl/MdcUserProductionServiceImpl.java +++ /dev/null @@ -1,152 +0,0 @@ -package org.jeecg.modules.mdc.service.impl; - -import cn.hutool.core.util.StrUtil; -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import org.jeecg.modules.mdc.entity.MdcProduction; -import org.jeecg.modules.mdc.entity.MdcUserProduction; -import org.jeecg.modules.mdc.mapper.MdcUserProductionMapper; -import org.jeecg.modules.mdc.model.ProductionIdModel; -import org.jeecg.modules.mdc.service.IMdcProductionService; -import org.jeecg.modules.mdc.service.IMdcUserProductionService; -import org.jeecg.modules.system.entity.SysUser; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - -import javax.annotation.Resource; -import java.util.ArrayList; -import java.util.List; - -/** - * @Description: 鐢ㄦ埛浜х嚎琛� - * @author: LiuS - * @create: 2023-03-27 11:58 - */ -@Service -public class MdcUserProductionServiceImpl extends ServiceImpl<MdcUserProductionMapper, MdcUserProduction> implements IMdcUserProductionService { - - @Resource - private IMdcProductionService mdcProductionService; - - /** - * 鏍规嵁鐢ㄦ埛id鏌ヨ浜х嚎淇℃伅 - */ - @Override - public List<ProductionIdModel> queryProductionIdsOfUser(String userId) { - LambdaQueryWrapper<MdcUserProduction> queryUserPro = new LambdaQueryWrapper<>(); - LambdaQueryWrapper<MdcProduction> queryPro = new LambdaQueryWrapper<>(); - try { - queryUserPro.eq(MdcUserProduction::getUserId, userId); - List<String> proIdList = new ArrayList<>(); - List<ProductionIdModel> proIdModelList = new ArrayList<>(); - List<MdcUserProduction> userProList = this.list(queryUserPro); - if (userProList != null && !userProList.isEmpty()) { - for (MdcUserProduction userProduction : userProList) { - proIdList.add(userProduction.getProId()); - } - queryPro.in(MdcProduction::getId, proIdList); - List<MdcProduction> proList = mdcProductionService.list(queryPro); - if (proList != null && !proList.isEmpty()) { - for (MdcProduction mdcProduction : proList) { - proIdModelList.add(new ProductionIdModel().convertByUserProduction(mdcProduction)); - } - } - return proIdModelList; - } - } catch (Exception e) { - e.fillInStackTrace(); - } - return null; - } - - /** - * 鏍规嵁鎸囧畾鐢ㄦ埛id鏌ヨ浜х嚎id闆嗗悎 - */ - @Override - public List<String> queryProductionIdsByUserId(String userId) { - return this.baseMapper.queryProductionIdsByUserId(userId); - } - - /** - * 鏍规嵁涓�缁勮溅闂磇d鏌ヨ鐢ㄦ埛浜х嚎淇℃伅 - * @param productionIds - */ - @Override - public List<MdcUserProduction> queryByProductionIds(List<String> productionIds){ - if (!productionIds.isEmpty()){ - return super.list(new LambdaQueryWrapper<MdcUserProduction>().in(MdcUserProduction::getProId, productionIds)); - } - return null; - } - - @Override - @Transactional(rollbackFor = {Exception.class}) - public boolean removeByCollection(List<MdcUserProduction> mdcUserProductions) { - if(mdcUserProductions == null || mdcUserProductions.isEmpty()) - return false; - if(mdcUserProductions.size() == 1){ - return super.removeById(mdcUserProductions.get(0).getId()); - } - List<String> ids = new ArrayList<>(); - mdcUserProductions.forEach(item -> { - ids.add(item.getId()); - }); - return super.removeByIds(ids); - } - - /** - * 鑾峰彇宸插垎閰嶇殑鐢ㄦ埛鍒楄〃 - * @param proId - * @return - */ - @Override - public List<SysUser> getUserPermsByGroupId(String proId){ - return super.getBaseMapper().getUserPermsByGroupId(proId); - } - - /** - * 鑾峰彇鏈垎閰嶇殑鐢ㄦ埛鍒楄〃 - * @param proId - * @return - */ - @Override - public List<SysUser> getUserNonPermsByGroupId(String proId){ - return super.getBaseMapper().getUserNonPermsByGroupId(proId); - } - - /** - * 鑾峰彇鏈垎閰嶇殑鐢ㄦ埛 - * @param proId - * @return - */ - @Override - public List<SysUser> getUserNonPermsByDeviceId(String proId){ - return super.getBaseMapper().getUserNonPermsByDeviceId(proId); - } - - @Override - public List<SysUser> getUserPermsByDeviceId(String proId) { - return super.getBaseMapper().getUserPermsByDeviceId(proId); - } - - /** - * 閫氳繃杞﹂棿id涓庡矖浣峣d绛涢�夌敤鎴� - * @param post - * @param proId - * @return - */ - @Override - public List<SysUser> queryByPostAndProId(String post, String proId){ - return super.getBaseMapper().queryByPostAndProId(post, proId); - } - - @Override - public MdcUserProduction getByUserIdAndGroupId(String userId, String proId){ - if(StrUtil.isEmpty(userId) || StrUtil.isEmpty(proId)) - return null; - List<MdcUserProduction> list = super.lambdaQuery().eq(MdcUserProduction::getUserId, userId).eq(MdcUserProduction::getProId, proId).list(); - if(list == null || list.isEmpty()) - return null; - return list.get(0); - } -} diff --git a/src/main/java/org/jeecg/modules/mdc/util/FindsEquipmentFactoryUtil.java b/src/main/java/org/jeecg/modules/mdc/util/FindsEquipmentFactoryUtil.java new file mode 100644 index 0000000..856e836 --- /dev/null +++ b/src/main/java/org/jeecg/modules/mdc/util/FindsEquipmentFactoryUtil.java @@ -0,0 +1,80 @@ +package org.jeecg.modules.mdc.util; + +import org.jeecg.common.util.oConvertUtils; +import org.jeecg.modules.base.entity.Factory; +import org.jeecg.modules.mdc.model.MdcEquipmentTree; +import org.jeecg.modules.mdc.model.FactoryTreeModel; +import org.jeecg.modules.mdc.model.MdcProductionTreeModel; + +import java.util.ArrayList; +import java.util.List; + +/** + * 浜х嚎璁惧鏍� + * @author: LiuS + * @create: 2023-04-03 15:59 + */ +public class FindsEquipmentFactoryUtil { + + /** + * 鑾峰彇 MdcEquipmentTree + */ + public static List<MdcEquipmentTree> wrapEquipmentFactoryTreeList(List<Factory> recordList) { + List<MdcEquipmentTree> idList = new ArrayList<>(); + List<FactoryTreeModel> records = new ArrayList<>(); + for (Factory factory : recordList) { + records.add(new FactoryTreeModel(factory)); + } + getChildren(records, idList); + setEmptyChildrenAsNull(idList); + return idList; + } + + /** + * 璇ユ柟娉曟槸鎵惧埌骞跺皝瑁呴《绾х埗绫荤殑鑺傜偣鍒癟reeList闆嗗悎 + */ + private static void getChildren(List<FactoryTreeModel> recordList, List<MdcEquipmentTree> idList) { + List<FactoryTreeModel> treeList = new ArrayList<>(); + for (FactoryTreeModel factoryTreeModel : recordList) { + if (oConvertUtils.isEmpty(factoryTreeModel.getParentId())) { + factoryTreeModel.setType(1); + treeList.add(factoryTreeModel); + idList.add(new MdcEquipmentTree().convertByFactory(factoryTreeModel)); + } + } + getGrandChildren(treeList, recordList, idList); + } + + /** + *璇ユ柟娉曟槸鎵惧埌椤剁骇鐖剁被涓嬬殑鎵�鏈夊瓙鑺傜偣闆嗗悎骞跺皝瑁呭埌TreeList闆嗗悎 + */ + private static void getGrandChildren(List<FactoryTreeModel> treeList, List<FactoryTreeModel> recordList, List<MdcEquipmentTree> idList) { + for (int i = 0; i < treeList.size(); i++) { + FactoryTreeModel model = treeList.get(i); + MdcEquipmentTree mdcEquipmentTree = idList.get(i); + for (int i1 = 0; i1 < recordList.size(); i1++) { + FactoryTreeModel m = recordList.get(i1); + if (m.getParentId() != null && m.getParentId().equals(model.getId())) { + model.getChildren().add(m); + m.setType(1); + mdcEquipmentTree.getChildren().add(new MdcEquipmentTree().convertByFactory(m)); + } + } + getGrandChildren(treeList.get(i).getChildren(), recordList, idList.get(i).getChildren()); + } + } + + /** + * 璇ユ柟娉曟槸灏嗗瓙鑺傜偣涓虹┖鐨凩ist闆嗗悎璁剧疆涓篘ull鍊� + */ + private static void setEmptyChildrenAsNull(List<MdcEquipmentTree> idList) { + for (MdcEquipmentTree mdcEquipmentTree : idList) { + if (mdcEquipmentTree.getChildren().isEmpty()) { + mdcEquipmentTree.setLeaf(true); + } else { + setEmptyChildrenAsNull(mdcEquipmentTree.getChildren()); + mdcEquipmentTree.setLeaf(false); + } + } + } +} diff --git a/src/main/java/org/jeecg/modules/mdc/vo/MdcEquipmentProVo.java b/src/main/java/org/jeecg/modules/mdc/vo/MdcEquipmentProVo.java index e303df6..7e9db44 100644 --- a/src/main/java/org/jeecg/modules/mdc/vo/MdcEquipmentProVo.java +++ b/src/main/java/org/jeecg/modules/mdc/vo/MdcEquipmentProVo.java @@ -9,5 +9,5 @@ @Data public class MdcEquipmentProVo { private String equipmentId; - private String productionName; + private String factoryName; } diff --git a/src/main/java/org/jeecg/modules/mes/controller/MesProductionOrderController.java b/src/main/java/org/jeecg/modules/mes/controller/MesProductionOrderController.java index 63d55ef..7003c7f 100644 --- a/src/main/java/org/jeecg/modules/mes/controller/MesProductionOrderController.java +++ b/src/main/java/org/jeecg/modules/mes/controller/MesProductionOrderController.java @@ -14,148 +14,71 @@ import org.jeecg.modules.mes.service.IMesProductionOrderService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; -import org.springframework.web.servlet.ModelAndView; import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import java.util.Arrays; /** -* @Description: SAP鐢熶骇璁㈠崟 -* @Author: jeecg-boot -* @Date: 2025-07-04 -* @Version: V1.0 -*/ -@Api(tags="SAP鐢熶骇璁㈠崟") + * @Description: SAP鐢熶骇璁㈠崟 + * @Author: jeecg-boot + * @Date: 2025-07-04 + * @Version: V1.0 + */ +@Api(tags = "SAP鐢熶骇璁㈠崟") @RestController -@RequestMapping("/mesproductionwork/mesProductionOrder") +@RequestMapping("/mes/productionOrder") @Slf4j public class MesProductionOrderController extends JeecgController<MesProductionOrder, IMesProductionOrderService> { - @Autowired - private IMesProductionOrderService mesProductionOrderService; + @Autowired + private IMesProductionOrderService mesProductionOrderService; - /** - * 鍒嗛〉鍒楄〃鏌ヨ - * - * @param mesProductionOrder - * @param pageNo - * @param pageSize - * @param req - * @return - */ - //@AutoLog(value = "SAP鐢熶骇璁㈠崟-鍒嗛〉鍒楄〃鏌ヨ") - @ApiOperation(value="SAP鐢熶骇璁㈠崟-鍒嗛〉鍒楄〃鏌ヨ", notes="SAP鐢熶骇璁㈠崟-鍒嗛〉鍒楄〃鏌ヨ") - @GetMapping(value = "/list") - public Result<IPage<MesProductionOrder>> queryPageList(MesProductionOrder mesProductionOrder, - @RequestParam(name="pageNo", defaultValue="1") Integer pageNo, - @RequestParam(name="pageSize", defaultValue="10") Integer pageSize, - HttpServletRequest req) { - QueryWrapper<MesProductionOrder> queryWrapper = QueryGenerator.initQueryWrapper(mesProductionOrder, req.getParameterMap()); - Page<MesProductionOrder> page = new Page<MesProductionOrder>(pageNo, pageSize); - IPage<MesProductionOrder> pageList = mesProductionOrderService.page(page, queryWrapper); - return Result.OK(pageList); - } + /** + * 鍒嗛〉鍒楄〃鏌ヨ + * + * @param mesProductionOrder + * @param pageNo + * @param pageSize + * @param req + * @return + */ + @ApiOperation(value = "SAP鐢熶骇璁㈠崟-鍒嗛〉鍒楄〃鏌ヨ", notes = "SAP鐢熶骇璁㈠崟-鍒嗛〉鍒楄〃鏌ヨ") + @GetMapping(value = "/list") + public Result<IPage<MesProductionOrder>> queryPageList(MesProductionOrder mesProductionOrder, + @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, + @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize, + HttpServletRequest req) { + QueryWrapper<MesProductionOrder> queryWrapper = QueryGenerator.initQueryWrapper(mesProductionOrder, req.getParameterMap()); + Page<MesProductionOrder> page = new Page<MesProductionOrder>(pageNo, pageSize); + IPage<MesProductionOrder> pageList = mesProductionOrderService.page(page, queryWrapper); + return Result.OK(pageList); + } - /** - * 娣诲姞 - * - * @param mesProductionOrder - * @return - */ - @AutoLog(value = "SAP鐢熶骇璁㈠崟-娣诲姞") - @ApiOperation(value="SAP鐢熶骇璁㈠崟-娣诲姞", notes="SAP鐢熶骇璁㈠崟-娣诲姞") - //@RequiresPermissions("org.jeecg.modules:mes_production_order:add") - @PostMapping(value = "/add") - public Result<String> add(@RequestBody MesProductionOrder mesProductionOrder) { - mesProductionOrderService.save(mesProductionOrder); - return Result.OK("娣诲姞鎴愬姛锛�"); - } + /** + * 缂栬緫 + * + * @param mesProductionOrder + * @return + */ + @AutoLog(value = "SAP鐢熶骇璁㈠崟-缂栬緫") + @ApiOperation(value = "SAP鐢熶骇璁㈠崟-缂栬緫", notes = "SAP鐢熶骇璁㈠崟-缂栬緫") + @RequestMapping(value = "/edit", method = {RequestMethod.PUT, RequestMethod.POST}) + public Result<String> edit(@RequestBody MesProductionOrder mesProductionOrder) { + mesProductionOrderService.updateById(mesProductionOrder); + return Result.OK("缂栬緫鎴愬姛!"); + } - /** - * 缂栬緫 - * - * @param mesProductionOrder - * @return - */ - @AutoLog(value = "SAP鐢熶骇璁㈠崟-缂栬緫") - @ApiOperation(value="SAP鐢熶骇璁㈠崟-缂栬緫", notes="SAP鐢熶骇璁㈠崟-缂栬緫") - //@RequiresPermissions("org.jeecg.modules:mes_production_order:edit") - @RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST}) - public Result<String> edit(@RequestBody MesProductionOrder mesProductionOrder) { - mesProductionOrderService.updateById(mesProductionOrder); - return Result.OK("缂栬緫鎴愬姛!"); - } - - /** - * 閫氳繃id鍒犻櫎 - * - * @param id - * @return - */ - @AutoLog(value = "SAP鐢熶骇璁㈠崟-閫氳繃id鍒犻櫎") - @ApiOperation(value="SAP鐢熶骇璁㈠崟-閫氳繃id鍒犻櫎", notes="SAP鐢熶骇璁㈠崟-閫氳繃id鍒犻櫎") - //@RequiresPermissions("org.jeecg.modules:mes_production_order:delete") - @DeleteMapping(value = "/delete") - public Result<String> delete(@RequestParam(name="id",required=true) String id) { - mesProductionOrderService.removeById(id); - return Result.OK("鍒犻櫎鎴愬姛!"); - } - - /** - * 鎵归噺鍒犻櫎 - * - * @param ids - * @return - */ - @AutoLog(value = "SAP鐢熶骇璁㈠崟-鎵归噺鍒犻櫎") - @ApiOperation(value="SAP鐢熶骇璁㈠崟-鎵归噺鍒犻櫎", notes="SAP鐢熶骇璁㈠崟-鎵归噺鍒犻櫎") - //@RequiresPermissions("org.jeecg.modules:mes_production_order:deleteBatch") - @DeleteMapping(value = "/deleteBatch") - public Result<String> deleteBatch(@RequestParam(name="ids",required=true) String ids) { - this.mesProductionOrderService.removeByIds(Arrays.asList(ids.split(","))); - return Result.OK("鎵归噺鍒犻櫎鎴愬姛!"); - } - - /** - * 閫氳繃id鏌ヨ - * - * @param id - * @return - */ - //@AutoLog(value = "SAP鐢熶骇璁㈠崟-閫氳繃id鏌ヨ") - @ApiOperation(value="SAP鐢熶骇璁㈠崟-閫氳繃id鏌ヨ", notes="SAP鐢熶骇璁㈠崟-閫氳繃id鏌ヨ") - @GetMapping(value = "/queryById") - public Result<MesProductionOrder> queryById(@RequestParam(name="id",required=true) String id) { - MesProductionOrder mesProductionOrder = mesProductionOrderService.getById(id); - if(mesProductionOrder==null) { - return Result.error("鏈壘鍒板搴旀暟鎹�"); - } - return Result.OK(mesProductionOrder); - } - - /** - * 瀵煎嚭excel - * - * @param request - * @param mesProductionOrder - */ - //@RequiresPermissions("org.jeecg.modules:mes_production_order:exportXls") - @RequestMapping(value = "/exportXls") - public ModelAndView exportXls(HttpServletRequest request, MesProductionOrder mesProductionOrder) { - return super.exportXls(request, mesProductionOrder, MesProductionOrder.class, "SAP鐢熶骇璁㈠崟"); - } - - /** - * 閫氳繃excel瀵煎叆鏁版嵁 - * - * @param request - * @param response - * @return - */ - //@RequiresPermissions("mes_production_order:importExcel") - @RequestMapping(value = "/importExcel", method = RequestMethod.POST) - public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) { - return super.importExcel(request, response, MesProductionOrder.class); - } - + /** + * 閫氳繃id鏌ヨ + * + * @param id + * @return + */ + @ApiOperation(value = "SAP鐢熶骇璁㈠崟-閫氳繃id鏌ヨ", notes = "SAP鐢熶骇璁㈠崟-閫氳繃id鏌ヨ") + @GetMapping(value = "/queryById") + public Result<MesProductionOrder> queryById(@RequestParam(name = "id", required = true) String id) { + MesProductionOrder mesProductionOrder = mesProductionOrderService.getById(id); + if (mesProductionOrder == null) { + return Result.error("鏈壘鍒板搴旀暟鎹�"); + } + return Result.OK(mesProductionOrder); + } } diff --git a/src/main/java/org/jeecg/modules/mes/entity/MesProductionOrder.java b/src/main/java/org/jeecg/modules/mes/entity/MesProductionOrder.java index 47573aa..2d2f5fa 100644 --- a/src/main/java/org/jeecg/modules/mes/entity/MesProductionOrder.java +++ b/src/main/java/org/jeecg/modules/mes/entity/MesProductionOrder.java @@ -2,7 +2,6 @@ import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableLogic; import com.baomidou.mybatisplus.annotation.TableName; import com.fasterxml.jackson.annotation.JsonFormat; import io.swagger.annotations.ApiModel; @@ -11,124 +10,165 @@ import lombok.EqualsAndHashCode; import lombok.experimental.Accessors; import org.jeecg.common.aspect.annotation.Dict; -import org.jeecgframework.poi.excel.annotation.Excel; +import org.jeecg.common.constant.CommonConstant; +import org.jeecg.common.util.DateUtils; +import org.jeecg.modules.sap.dto.ProductionOrderDTO; import org.springframework.format.annotation.DateTimeFormat; import java.io.Serializable; +import java.math.BigDecimal; import java.util.Date; /** * @Description: SAP鐢熶骇璁㈠崟 * @Author: jeecg-boot - * @Date: 2025-07-04 + * @Date: 2025-07-04 * @Version: V1.0 */ @Data @TableName("mes_production_order") @Accessors(chain = true) @EqualsAndHashCode(callSuper = false) -@ApiModel(value="mes_production_order瀵硅薄", description="SAP鐢熶骇璁㈠崟") +@ApiModel(value = "mes_production_order瀵硅薄", description = "SAP鐢熶骇璁㈠崟") public class MesProductionOrder implements Serializable { private static final long serialVersionUID = 1L; - /**涓婚敭*/ - @TableId(type = IdType.ASSIGN_ID) + /**涓婚敭*/ + @TableId(type = IdType.ASSIGN_ID) @ApiModelProperty(value = "涓婚敭") private String id; - /**鍒涘缓浜�*/ + /**鍒涘缓浜�*/ @ApiModelProperty(value = "鍒涘缓浜�") private String createBy; - /**鍒涘缓鏃ユ湡*/ - @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss") - @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss") + /**鍒涘缓鏃ユ湡*/ @ApiModelProperty(value = "鍒涘缓鏃ユ湡") private Date createTime; - /**鏇存柊浜�*/ + /**鏇存柊浜�*/ @ApiModelProperty(value = "鏇存柊浜�") private String updateBy; - /**鏇存柊鏃ユ湡*/ - @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss") - @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss") + /**鏇存柊鏃ユ湡*/ @ApiModelProperty(value = "鏇存柊鏃ユ湡") private Date updateTime; - /**鍒犻櫎鏍囪*/ - @Excel(name = "鍒犻櫎鏍囪", width = 15) + /**鍒犻櫎鏍囪*/ @ApiModelProperty(value = "鍒犻櫎鏍囪") - @TableLogic private Integer delFlag; - /**鐢熶骇璁㈠崟鍙�*/ - @Excel(name = "鐢熶骇璁㈠崟鍙�", width = 15) + /**鐢熶骇璁㈠崟鍙�*/ @ApiModelProperty(value = "鐢熶骇璁㈠崟鍙�") private String orderCode; - /**璁㈠崟绫诲瀷*/ - @Excel(name = "璁㈠崟绫诲瀷", width = 15) + /**璁㈠崟绫诲瀷*/ @ApiModelProperty(value = "璁㈠崟绫诲瀷") + @Dict(dicCode = "production_order_category") private String orderCategory; - /**鐗╂枡缂栧彿*/ - @Excel(name = "鐗╂枡缂栧彿", width = 15) + /**鐗╂枡缂栧彿*/ @ApiModelProperty(value = "鐗╂枡缂栧彿") private String materialNumber; - /**鐗╂枡鍚嶇О*/ - @Excel(name = "鐗╂枡鍚嶇О", width = 15) + /**鐗╂枡鍚嶇О*/ @ApiModelProperty(value = "鐗╂枡鍚嶇О") private String materialName; - /**璁″垝寮�濮嬫棩鏈�*/ - @Excel(name = "璁″垝寮�濮嬫棩鏈�", width = 20, format = "yyyy-MM-dd HH:mm:ss") - @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss") - @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss") + /**璁″垝寮�濮嬫棩鏈�*/ + @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd") + @DateTimeFormat(pattern = "yyyy-MM-dd") @ApiModelProperty(value = "璁″垝寮�濮嬫棩鏈�") private Date planStart; - /**璁″垝缁撴潫鏃ユ湡*/ - @Excel(name = "璁″垝缁撴潫鏃ユ湡", width = 20, format = "yyyy-MM-dd HH:mm:ss") - @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss") - @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss") + /**璁″垝缁撴潫鏃ユ湡*/ + @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd") + @DateTimeFormat(pattern = "yyyy-MM-dd") @ApiModelProperty(value = "璁″垝缁撴潫鏃ユ湡") private Date planEnd; - /**璁㈠崟鏁伴噺*/ - @Excel(name = "璁㈠崟鏁伴噺", width = 15) + /**璁㈠崟鏁伴噺*/ @ApiModelProperty(value = "璁㈠崟鏁伴噺") - private Double orderQuantity; - /**浜у搧鍗曚綅*/ - @Excel(name = "浜у搧鍗曚綅", width = 15, dicCode = "production_unit") - @Dict(dicCode = "production_unit") - @ApiModelProperty(value = "浜у搧鍗曚綅") + private BigDecimal orderQuantity; + /**鍩烘湰璁¢噺鍗曚綅*/ + @ApiModelProperty(value = "鍩烘湰璁¢噺鍗曚綅") private String productionUnit; - /**璁㈠崟鐘舵��*/ - @Excel(name = "璁㈠崟鐘舵��", width = 15, dicCode = "order_status") - @Dict(dicCode = "order_status") + /**璁㈠崟鐘舵��*/ @ApiModelProperty(value = "璁㈠崟鐘舵��") private String orderStatus; - /**浼樺厛绾�*/ - @Excel(name = "浼樺厛绾�", width = 15, dicCode = "priority") - @Dict(dicCode = "priority") + /**璁㈠崟鐘舵�佹弿杩�*/ + @ApiModelProperty(value = "璁㈠崟鐘舵�佹弿杩�") + private String orderStatusName; + /**浼樺厛绾�*/ @ApiModelProperty(value = "浼樺厛绾�") private String priority; - /**璁″垝宸ヨ壓璺嚎*/ - @Excel(name = "璁″垝宸ヨ壓璺嚎", width = 15) + /**璁″垝宸ヨ壓璺嚎*/ @ApiModelProperty(value = "璁″垝宸ヨ壓璺嚎") private String processRoute; - /**璁″垝鐗╂枡娓呭崟*/ - @Excel(name = "璁″垝鐗╂枡娓呭崟", width = 15) + /**璁″垝鐗╂枡娓呭崟*/ @ApiModelProperty(value = "璁″垝鐗╂枡娓呭崟") private String materialListCode; - /**宸ュ巶缂栫爜*/ - @Excel(name = "宸ュ巶缂栫爜", width = 15) + /**宸ュ巶缂栫爜*/ @ApiModelProperty(value = "宸ュ巶缂栫爜") private String factoryCode; - /**宸ュ巶鍚嶇О*/ - @Excel(name = "宸ュ巶鍚嶇О", width = 15) + /**宸ュ巶鍚嶇О*/ @ApiModelProperty(value = "宸ュ巶鍚嶇О") private String factoryName; - /**瀹㈡埛鍨嬪彿*/ - @Excel(name = "瀹㈡埛鍨嬪彿", width = 15) + /**璋冨害鍛樼紪鍙�*/ + @ApiModelProperty(value = "璋冨害鍛樼紪鍙�") + private String dispatcherCode; + /**璋冨害鍛樺悕绉�*/ + @ApiModelProperty(value = "璋冨害鍛樺悕绉�") + private String dispatcherName; + /**璁㈠崟鍒涘缓鏃ユ湡 yyyy-MM-dd*/ + @ApiModelProperty(value = "璁㈠崟鍒涘缓鏃ユ湡") + private String orderCreateDate; + /**璁㈠崟鏇存柊鏃ユ湡 yyyy-MM-dd*/ + @ApiModelProperty(value = "璁㈠崟鏇存柊鏃ユ湡") + private String orderUpdateDate; + /**璁㈠崟鏇存柊鏃堕棿 HH:mm:ss*/ + @ApiModelProperty(value = "璁㈠崟鏇存柊鏃堕棿") + private String orderUpdateTime; + /**璁㈠崟淇敼浜�*/ + @ApiModelProperty(value = "璁㈠崟淇敼浜�") + private String orderUpdateUser; + /**瀹㈡埛鍨嬪彿*/ @ApiModelProperty(value = "瀹㈡埛鍨嬪彿") private String customerOrderModel; - /**瀹㈡埛鍚嶇О*/ - @Excel(name = "瀹㈡埛鍚嶇О", width = 15) + /**瀹㈡埛鍚嶇О*/ @ApiModelProperty(value = "瀹㈡埛鍚嶇О") private String customer; - /**澶囨敞*/ - @Excel(name = "澶囨敞", width = 15) + /**澶囨敞*/ @ApiModelProperty(value = "澶囨敞") private String remark; + + public MesProductionOrder() { + } + + public MesProductionOrder(ProductionOrderDTO dto) { + this.orderCode = dto.getAUFNR(); + this.orderCategory = dto.getDAUAT(); + this.materialNumber = dto.getMATNR(); + this.materialName = dto.getMAKTX(); + this.planStart = DateUtils.str2Date(dto.getGSTRP(), DateUtils.date_sdf.get()); + this.planEnd = DateUtils.str2Date(dto.getGLTRP(), DateUtils.date_sdf.get()); + this.orderQuantity = new BigDecimal(dto.getGAMNG()); + this.productionUnit = dto.getGMEIN(); + this.orderStatus = dto.getTXT04(); + this.orderStatusName = dto.getTXT30(); + this.priority = dto.getAPRIO(); + this.processRoute = dto.getAUFPL(); + this.materialListCode = dto.getSTLNR(); + this.factoryCode = dto.getDWERK(); + this.factoryName = dto.getNAME1(); + this.dispatcherCode = dto.getFEVOR(); + this.dispatcherName = dto.getTXT(); + this.orderCreateDate = dto.getUDATE(); + this.orderUpdateDate = dto.getLAEDA(); + this.orderUpdateTime = dto.getTIMES(); + this.orderUpdateUser = dto.getUSNAM(); + this.delFlag = CommonConstant.DEL_FLAG_0; + } + + public void updateEntity(ProductionOrderDTO dto) { + this.orderCategory = dto.getDAUAT(); + this.planStart = DateUtils.str2Date(dto.getGSTRP(), DateUtils.date_sdf.get()); + this.planEnd = DateUtils.str2Date(dto.getGLTRP(), DateUtils.date_sdf.get()); + this.orderQuantity = new BigDecimal(dto.getGAMNG()); + this.orderStatus = dto.getTXT04(); + this.orderStatusName = dto.getTXT30(); + this.priority = dto.getAPRIO(); + this.orderCreateDate = dto.getUDATE(); + this.orderUpdateDate = dto.getLAEDA(); + this.orderUpdateTime = dto.getTIMES(); + this.orderUpdateUser = dto.getUSNAM(); + } } diff --git a/src/main/java/org/jeecg/modules/mes/job/ProductionOrderSyncCreationJob.java b/src/main/java/org/jeecg/modules/mes/job/ProductionOrderSyncCreationJob.java new file mode 100644 index 0000000..086a7b1 --- /dev/null +++ b/src/main/java/org/jeecg/modules/mes/job/ProductionOrderSyncCreationJob.java @@ -0,0 +1,173 @@ +package org.jeecg.modules.mes.job; + +import lombok.extern.slf4j.Slf4j; +import org.jeecg.modules.mdc.util.DateUtils; +import org.jeecg.modules.mdc.util.ThrowableUtil; +import org.jeecg.modules.mes.entity.MesProductionOrder; +import org.jeecg.modules.mes.service.IMesProductionOrderService; +import org.jeecg.modules.pms.service.IPmsMaterialProcessService; +import org.jeecg.modules.pms.service.IPmsProcessBillMaterialsService; +import org.jeecg.modules.quartz.entity.QuartzJob; +import org.jeecg.modules.quartz.entity.SysQuartzLog; +import org.jeecg.modules.quartz.service.IQuartzJobService; +import org.jeecg.modules.quartz.service.ISysQuartzLogService; +import org.jeecg.modules.sap.dto.OrderBomDTO; +import org.jeecg.modules.sap.dto.OrderProcessDTO; +import org.jeecg.modules.sap.dto.ProductionOrderDTO; +import org.jeecg.modules.sap.service.OrderBomSync; +import org.jeecg.modules.sap.service.OrderProcessSync; +import org.jeecg.modules.sap.service.ProductionOrderSync; +import org.quartz.Job; +import org.quartz.JobExecutionContext; +import org.quartz.JobExecutionException; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import java.time.LocalDateTime; +import java.util.Date; +import java.util.List; +import java.util.Map; + +@Component +@Slf4j +public class ProductionOrderSyncCreationJob implements Job { + //宸ュ巶缂栫爜(鏂扮伀鐐� 2301) + private static final String FACTORY_CODE = "2301"; + /** + * 璁㈠崟绫诲瀷 + * 鏍囧噯鐢熶骇璁㈠崟 Z001 + * 瀹㈤��杩斿伐鐢熶骇璁㈠崟 Z002 + * 鍛嗘粸澶勭悊杩斿伐鐢熶骇璁㈠崟 Z003 + * 璇曞埗鐢熶骇璁㈠崟(鏂扮伀鐐�) Z011 + * 鎷嗛浂鐢熶骇璁㈠崟(鏂扮伀鐐�) 2012 + */ + private static final String ORDER_TYPE_CODE = "Z001"; + /** + * 鐢熶骇璋冨害鍛� + * 001 涓�鍒嗗巶璋冨害鍛� + * 002 浜屽垎鍘傝皟搴﹀憳 + * 003 涓夊垎鍘傝皟搴﹀憳 + * 004 鍥涘垎鍘傝皟搴﹀憳 + * 005 ABS璋冨害鍛� + * 006 璋冭川璋冨害鍛� + * 007 浜斿垎鍘傝皟搴﹀憳 + * 008 璇曞埗杞﹂棿璋冨害鍛� + * 009 澶栭噰璋冨害鍛� + * 010 鍏巶璋冨害鍛� + * 012 鍏垎鍘傝皟搴﹀憳 + */ + private static final String PRODUCTION_MANAGER = "010"; + /** + * 鐢熶骇璁㈠崟鐘舵�侊紝瀹為檯涓婏紝鍙湁REL鐘舵�佺殑宸ュ崟鎵嶅彲浠ヨ繘琛屾搷浣� + * CRTD 鏂板缓 + * REL 涓嬭揪 + * TECO 鍏抽棴 + */ + private static final String ORDER_STATUS = "REL"; + + /** + * 璇锋眰鎴愬姛缂栫爜 + */ + private static final String SUCCESS_CODE = "S"; + + @Autowired + private ProductionOrderSync productionOrderSync; + @Autowired + private OrderBomSync orderBomSync; + @Autowired + private OrderProcessSync orderProcessSync; + @Autowired + private IMesProductionOrderService productionOrderService; + @Autowired + private IPmsProcessBillMaterialsService processBillMaterialsService; + @Autowired + private IPmsMaterialProcessService materialProcessService; + @Autowired + private ISysQuartzLogService sysQuartzLogService; + @Autowired + private IQuartzJobService quartzJobService; + + @Override + public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException { + //浠诲姟鏃ュ織 + SysQuartzLog quartzLog = new SysQuartzLog(); + quartzLog.setCreateTime(new Date()); + List<QuartzJob> byJobClassName = quartzJobService.findByJobClassName(this.getClass().getName()); + if (byJobClassName != null && !byJobClassName.isEmpty()) { + quartzLog.setJobId(byJobClassName.get(0).getId()); + } + long startTime = System.currentTimeMillis(); + //鑾峰彇涓婃鍚屾鏃堕棿 + String lastSyncDateLow = productionOrderService.getLastSyncCreateDate(); + String lastSyncDateHigh = null; + if(lastSyncDateLow != null) { + lastSyncDateHigh = DateUtils.format(new Date(), "yyyyMMdd"); + if(lastSyncDateLow.equals(lastSyncDateHigh)) { + lastSyncDateHigh = null; + } + } + try { + //璋冪敤SAP鎺ュ彛鑾峰彇鐢熶骇璁㈠崟 + Map<String, Object> productionOrderMap = productionOrderSync.syncProductionOrder(FACTORY_CODE, ORDER_TYPE_CODE, PRODUCTION_MANAGER, ORDER_STATUS, lastSyncDateLow, lastSyncDateHigh, null, null); + if (productionOrderMap == null || !SUCCESS_CODE.equals(productionOrderMap.get("ztype"))) { + log.error("鏈悓姝ュ埌璁㈠崟淇℃伅锛佹棩鏈燂細{}", LocalDateTime.now()); + return; + } + //璋冪敤鎴愬姛锛岃幏鍙栬繑鍥炴暟鎹� + Object result = productionOrderMap.get("result"); + boolean b = result instanceof List; + if(!b) { + log.error("杩斿洖绫诲瀷閿欒锛� class:{}", result == null ? null : result.getClass()); + return; + } + List<ProductionOrderDTO> productionOrderDTOList = (List<ProductionOrderDTO>) result; + Map<String, MesProductionOrder> orderMap = productionOrderService.saveOrUpdateProductionOrder(productionOrderDTOList); + String orderCodes = String.join(",", orderMap.keySet()); + //璁㈠崟BOM鍚屾 + Map<String, Object> orderBomMap = orderBomSync.syncOrderBom(FACTORY_CODE, orderCodes); + if (orderBomMap == null || !SUCCESS_CODE.equals(orderBomMap.get("ztype"))) { + log.error("鏈悓姝ュ埌璁㈠崟BOM淇℃伅锛佹棩鏈燂細{}", LocalDateTime.now()); + return; + } + //璋冪敤鎴愬姛锛岃幏鍙栬繑鍥炴暟鎹� + result = orderBomMap.get("result"); + b = result instanceof List; + if(!b) { + log.error("杩斿洖绫诲瀷閿欒锛� class:{}", result == null ? null : result.getClass()); + return; + } + List<OrderBomDTO> orderBomDTOList = (List<OrderBomDTO>) result; + b = processBillMaterialsService.saveOrUpdateOrderBom(orderMap, orderBomDTOList); + if(!b) { + log.error("淇濆瓨璁㈠崟BOM澶辫触锛屾棩鏈燂細{}", LocalDateTime.now()); + return; + } + //璁㈠崟宸ュ簭鍚屾 + Map<String, Object> orderProcessMap = orderProcessSync.syncOrderProcess(FACTORY_CODE, orderCodes); + if (orderBomMap == null || !SUCCESS_CODE.equals(orderProcessMap.get("ztype"))) { + log.error("鏈悓姝ュ埌璁㈠崟宸ュ簭淇℃伅锛佹棩鏈燂細{}", LocalDateTime.now()); + return; + } + //璋冪敤鎴愬姛锛岃幏鍙栬繑鍥炴暟鎹� + result = orderProcessMap.get("result"); + b = result instanceof List; + if(!b) { + log.error("杩斿洖绫诲瀷閿欒锛� class:{}", result == null ? null : result.getClass()); + return; + } + List<OrderProcessDTO> orderProcessDTOList = (List<OrderProcessDTO>) result; + b = materialProcessService.saveOrUpdateOrderProcess(orderMap, orderProcessDTOList); + if(!b) { + log.error("淇濆瓨璁㈠崟宸ュ簭澶辫触锛屾棩鏈燂細{}", LocalDateTime.now()); + } + quartzLog.setIsSuccess(0); + } catch (Exception e) { + log.error("瀹氭椂浠诲姟澶辫触锛寋}", e.getMessage(), e); + quartzLog.setIsSuccess(-1); + quartzLog.setExceptionDetail(ThrowableUtil.getStackTrace(e)); + } + long endTime = System.currentTimeMillis(); + quartzLog.setExecutionTime(Integer.parseInt(String.valueOf(endTime - startTime))); + sysQuartzLogService.save(quartzLog); + } +} diff --git a/src/main/java/org/jeecg/modules/mes/job/ProductionOrderSyncUpdateJob.java b/src/main/java/org/jeecg/modules/mes/job/ProductionOrderSyncUpdateJob.java new file mode 100644 index 0000000..93dd7ee --- /dev/null +++ b/src/main/java/org/jeecg/modules/mes/job/ProductionOrderSyncUpdateJob.java @@ -0,0 +1,173 @@ +package org.jeecg.modules.mes.job; + +import lombok.extern.slf4j.Slf4j; +import org.jeecg.modules.mdc.util.DateUtils; +import org.jeecg.modules.mdc.util.ThrowableUtil; +import org.jeecg.modules.mes.entity.MesProductionOrder; +import org.jeecg.modules.mes.service.IMesProductionOrderService; +import org.jeecg.modules.pms.service.IPmsMaterialProcessService; +import org.jeecg.modules.pms.service.IPmsProcessBillMaterialsService; +import org.jeecg.modules.quartz.entity.QuartzJob; +import org.jeecg.modules.quartz.entity.SysQuartzLog; +import org.jeecg.modules.quartz.service.IQuartzJobService; +import org.jeecg.modules.quartz.service.ISysQuartzLogService; +import org.jeecg.modules.sap.dto.OrderBomDTO; +import org.jeecg.modules.sap.dto.OrderProcessDTO; +import org.jeecg.modules.sap.dto.ProductionOrderDTO; +import org.jeecg.modules.sap.service.OrderBomSync; +import org.jeecg.modules.sap.service.OrderProcessSync; +import org.jeecg.modules.sap.service.ProductionOrderSync; +import org.quartz.Job; +import org.quartz.JobExecutionContext; +import org.quartz.JobExecutionException; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import java.time.LocalDateTime; +import java.util.Date; +import java.util.List; +import java.util.Map; + +@Component +@Slf4j +public class ProductionOrderSyncUpdateJob implements Job { + //宸ュ巶缂栫爜(鏂扮伀鐐� 2301) + private static final String FACTORY_CODE = "2301"; + /** + * 璁㈠崟绫诲瀷 + * 鏍囧噯鐢熶骇璁㈠崟 Z001 + * 瀹㈤��杩斿伐鐢熶骇璁㈠崟 Z002 + * 鍛嗘粸澶勭悊杩斿伐鐢熶骇璁㈠崟 Z003 + * 璇曞埗鐢熶骇璁㈠崟(鏂扮伀鐐�) Z011 + * 鎷嗛浂鐢熶骇璁㈠崟(鏂扮伀鐐�) 2012 + */ + private static final String ORDER_TYPE_CODE = "Z001"; + /** + * 鐢熶骇璋冨害鍛� + * 001 涓�鍒嗗巶璋冨害鍛� + * 002 浜屽垎鍘傝皟搴﹀憳 + * 003 涓夊垎鍘傝皟搴﹀憳 + * 004 鍥涘垎鍘傝皟搴﹀憳 + * 005 ABS璋冨害鍛� + * 006 璋冭川璋冨害鍛� + * 007 浜斿垎鍘傝皟搴﹀憳 + * 008 璇曞埗杞﹂棿璋冨害鍛� + * 009 澶栭噰璋冨害鍛� + * 010 鍏巶璋冨害鍛� + * 012 鍏垎鍘傝皟搴﹀憳 + */ + private static final String PRODUCTION_MANAGER = "010"; + /** + * 鐢熶骇璁㈠崟鐘舵�侊紝瀹為檯涓婏紝鍙湁REL鐘舵�佺殑宸ュ崟鎵嶅彲浠ヨ繘琛屾搷浣� + * CRTD 鏂板缓 + * REL 涓嬭揪 + * TECO 鍏抽棴 + */ + private static final String ORDER_STATUS = "REL"; + + /** + * 璇锋眰鎴愬姛缂栫爜 + */ + private static final String SUCCESS_CODE = "S"; + + @Autowired + private ProductionOrderSync productionOrderSync; + @Autowired + private OrderBomSync orderBomSync; + @Autowired + private OrderProcessSync orderProcessSync; + @Autowired + private IMesProductionOrderService productionOrderService; + @Autowired + private IPmsProcessBillMaterialsService processBillMaterialsService; + @Autowired + private IPmsMaterialProcessService materialProcessService; + @Autowired + private ISysQuartzLogService sysQuartzLogService; + @Autowired + private IQuartzJobService quartzJobService; + + @Override + public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException { + //浠诲姟鏃ュ織 + SysQuartzLog quartzLog = new SysQuartzLog(); + quartzLog.setCreateTime(new Date()); + List<QuartzJob> byJobClassName = quartzJobService.findByJobClassName(this.getClass().getName()); + if (byJobClassName != null && !byJobClassName.isEmpty()) { + quartzLog.setJobId(byJobClassName.get(0).getId()); + } + long startTime = System.currentTimeMillis(); + //鑾峰彇涓婃鍚屾鏃堕棿 + String lastSyncDateLow = productionOrderService.getLastSyncUpdateDate(); + String lastSyncDateHigh = null; + if (lastSyncDateLow != null) { + lastSyncDateHigh = DateUtils.format(new Date(), "yyyyMMdd"); + if (lastSyncDateLow.equals(lastSyncDateHigh)) { + lastSyncDateHigh = null; + } + } + try { + //璋冪敤SAP鎺ュ彛鑾峰彇鐢熶骇璁㈠崟 + Map<String, Object> productionOrderMap = productionOrderSync.syncProductionOrder(FACTORY_CODE, ORDER_TYPE_CODE, PRODUCTION_MANAGER, ORDER_STATUS, null, null, lastSyncDateLow, lastSyncDateHigh); + if (productionOrderMap == null || !SUCCESS_CODE.equals(productionOrderMap.get("ztype"))) { + log.error("鏈悓姝ュ埌璁㈠崟淇℃伅锛佹棩鏈燂細{}", LocalDateTime.now()); + return; + } + //璋冪敤鎴愬姛锛岃幏鍙栬繑鍥炴暟鎹� + Object result = productionOrderMap.get("result"); + boolean b = result instanceof List; + if (!b) { + log.error("杩斿洖绫诲瀷閿欒锛� class:{}", result == null ? null : result.getClass()); + return; + } + List<ProductionOrderDTO> productionOrderDTOList = (List<ProductionOrderDTO>) result; + Map<String, MesProductionOrder> orderMap = productionOrderService.saveOrUpdateProductionOrder(productionOrderDTOList); + String orderCodes = String.join(",", orderMap.keySet()); + //璁㈠崟BOM鍚屾 + Map<String, Object> orderBomMap = orderBomSync.syncOrderBom(FACTORY_CODE, orderCodes); + if (orderBomMap == null || !SUCCESS_CODE.equals(orderBomMap.get("ztype"))) { + log.error("鏈悓姝ュ埌璁㈠崟BOM淇℃伅锛佹棩鏈燂細{}", LocalDateTime.now()); + return; + } + //璋冪敤鎴愬姛锛岃幏鍙栬繑鍥炴暟鎹� + result = orderBomMap.get("result"); + b = result instanceof List; + if (!b) { + log.error("杩斿洖绫诲瀷閿欒锛� class:{}", result == null ? null : result.getClass()); + return; + } + List<OrderBomDTO> orderBomDTOList = (List<OrderBomDTO>) result; + b = processBillMaterialsService.saveOrUpdateOrderBom(orderMap, orderBomDTOList); + if (!b) { + log.error("淇濆瓨璁㈠崟BOM澶辫触锛屾棩鏈燂細{}", LocalDateTime.now()); + return; + } + //璁㈠崟宸ュ簭鍚屾 + Map<String, Object> orderProcessMap = orderProcessSync.syncOrderProcess(FACTORY_CODE, orderCodes); + if (orderBomMap == null || !SUCCESS_CODE.equals(orderProcessMap.get("ztype"))) { + log.error("鏈悓姝ュ埌璁㈠崟宸ュ簭淇℃伅锛佹棩鏈燂細{}", LocalDateTime.now()); + return; + } + //璋冪敤鎴愬姛锛岃幏鍙栬繑鍥炴暟鎹� + result = orderProcessMap.get("result"); + b = result instanceof List; + if (!b) { + log.error("杩斿洖绫诲瀷閿欒锛� class:{}", result == null ? null : result.getClass()); + return; + } + List<OrderProcessDTO> orderProcessDTOList = (List<OrderProcessDTO>) result; + b = materialProcessService.saveOrUpdateOrderProcess(orderMap, orderProcessDTOList); + if (!b) { + log.error("淇濆瓨璁㈠崟宸ュ簭澶辫触锛屾棩鏈燂細{}", LocalDateTime.now()); + } + quartzLog.setIsSuccess(0); + } catch (Exception e) { + log.error("瀹氭椂浠诲姟澶辫触锛寋}", e.getMessage(), e); + quartzLog.setIsSuccess(-1); + quartzLog.setExceptionDetail(ThrowableUtil.getStackTrace(e)); + } + long endTime = System.currentTimeMillis(); + quartzLog.setExecutionTime(Integer.parseInt(String.valueOf(endTime - startTime))); + sysQuartzLogService.save(quartzLog); + } +} diff --git a/src/main/java/org/jeecg/modules/mes/mapper/MesProductionOrderMapper.java b/src/main/java/org/jeecg/modules/mes/mapper/MesProductionOrderMapper.java index f2dbd11..385aa6c 100644 --- a/src/main/java/org/jeecg/modules/mes/mapper/MesProductionOrderMapper.java +++ b/src/main/java/org/jeecg/modules/mes/mapper/MesProductionOrderMapper.java @@ -3,6 +3,8 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; import org.jeecg.modules.mes.entity.MesProductionOrder; +import java.util.Date; + /** * @Description: SAP鐢熶骇璁㈠崟 * @Author: jeecg-boot @@ -11,4 +13,15 @@ */ public interface MesProductionOrderMapper extends BaseMapper<MesProductionOrder> { + /** + * 鑾峰彇鏈�鏂扮殑鍒涘缓鍚屾鏃ユ湡 + * @return + */ + String getLastSyncCreateDate(); + + /** + * 鑾峰彇鏈�鏂扮殑鍒涘缓鍚屾鏃ユ湡 + * @return + */ + String getLastSyncUpdateDate(); } diff --git a/src/main/java/org/jeecg/modules/mes/mapper/xml/MesProductionOrderMapper.xml b/src/main/java/org/jeecg/modules/mes/mapper/xml/MesProductionOrderMapper.xml index c026a36..c7ef219 100644 --- a/src/main/java/org/jeecg/modules/mes/mapper/xml/MesProductionOrderMapper.xml +++ b/src/main/java/org/jeecg/modules/mes/mapper/xml/MesProductionOrderMapper.xml @@ -2,4 +2,11 @@ <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <mapper namespace="org.jeecg.modules.mes.mapper.MesProductionOrderMapper"> + <select id="getLastSyncCreateDate" resultType="java.lang.String"> + select MAX(order_create_date) from mes_production_order + </select> + + <select id="getLastSyncUpdateDate" resultType="java.lang.String"> + select MAX(order_update_date) from mes_production_order + </select> </mapper> \ No newline at end of file diff --git a/src/main/java/org/jeecg/modules/mes/service/IMesProductionOrderService.java b/src/main/java/org/jeecg/modules/mes/service/IMesProductionOrderService.java index ff8affa..a64fe23 100644 --- a/src/main/java/org/jeecg/modules/mes/service/IMesProductionOrderService.java +++ b/src/main/java/org/jeecg/modules/mes/service/IMesProductionOrderService.java @@ -2,6 +2,10 @@ import com.baomidou.mybatisplus.extension.service.IService; import org.jeecg.modules.mes.entity.MesProductionOrder; +import org.jeecg.modules.sap.dto.ProductionOrderDTO; + +import java.util.List; +import java.util.Map; /** * @Description: SAP鐢熶骇璁㈠崟 @@ -11,4 +15,29 @@ */ public interface IMesProductionOrderService extends IService<MesProductionOrder> { + /** + * SAP鍚屾鏁版嵁淇濆瓨 + * @param productionOrderDTOList + * @return + */ + Map<String, MesProductionOrder> saveOrUpdateProductionOrder(List<ProductionOrderDTO> productionOrderDTOList); + + /** + * 鏍规嵁璁㈠崟鍙锋煡璇� + * @param orderCode + * @return + */ + MesProductionOrder getByOrderCode(String orderCode); + + /** + * 鑾峰彇涓婃鍚屾鍒涘缓鏃ユ湡鏈�鏂扮殑鏃ユ湡 + * @return + */ + String getLastSyncCreateDate(); + + /** + *鑾峰彇涓婃鍚屾鏇存柊鏃ユ湡鏈�鏂扮殑鏃ユ湡 + * @return + */ + String getLastSyncUpdateDate(); } diff --git a/src/main/java/org/jeecg/modules/mes/service/impl/MesProductionOrderServiceImpl.java b/src/main/java/org/jeecg/modules/mes/service/impl/MesProductionOrderServiceImpl.java index ed8e452..19c42ec 100644 --- a/src/main/java/org/jeecg/modules/mes/service/impl/MesProductionOrderServiceImpl.java +++ b/src/main/java/org/jeecg/modules/mes/service/impl/MesProductionOrderServiceImpl.java @@ -1,18 +1,74 @@ package org.jeecg.modules.mes.service.impl; +import cn.hutool.core.collection.CollectionUtil; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.jeecg.common.constant.CommonConstant; +import org.jeecg.modules.mdc.util.DateUtils; import org.jeecg.modules.mes.entity.MesProductionOrder; import org.jeecg.modules.mes.mapper.MesProductionOrderMapper; import org.jeecg.modules.mes.service.IMesProductionOrderService; +import org.jeecg.modules.sap.dto.ProductionOrderDTO; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.*; /** * @Description: SAP鐢熶骇璁㈠崟 * @Author: jeecg-boot - * @Date: 2025-07-04 + * @Date: 2025-07-04 * @Version: V1.0 */ @Service public class MesProductionOrderServiceImpl extends ServiceImpl<MesProductionOrderMapper, MesProductionOrder> implements IMesProductionOrderService { + @Override + @Transactional(rollbackFor = Exception.class) + public Map<String, MesProductionOrder> saveOrUpdateProductionOrder(List<ProductionOrderDTO> productionOrderDTOList) { + Map<String, MesProductionOrder> resultMap = new HashMap<>(); + for (ProductionOrderDTO productionOrderDTO : productionOrderDTOList) { + MesProductionOrder updated = getByOrderCode(productionOrderDTO.getAUFNR()); + if (updated == null) { + updated = new MesProductionOrder(productionOrderDTO); + resultMap.put(updated.getOrderCode(), updated); + this.getBaseMapper().insert(updated); + } else { + updated.updateEntity(productionOrderDTO); + resultMap.put(updated.getOrderCode(), updated); + this.getBaseMapper().updateById(updated); + } + } + return resultMap; + } + + @Override + public MesProductionOrder getByOrderCode(String orderCode) { + LambdaQueryWrapper<MesProductionOrder> queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(MesProductionOrder::getOrderCode, orderCode); + queryWrapper.eq(MesProductionOrder::getDelFlag, CommonConstant.DEL_FLAG_0); + List<MesProductionOrder> list = super.list(queryWrapper); + if (CollectionUtil.isNotEmpty(list)) { + return list.get(0); + } + return null; + } + + @Override + public String getLastSyncCreateDate() { + String lastSyncDate = this.getBaseMapper().getLastSyncCreateDate(); + if(lastSyncDate == null){ + return null; + } + return lastSyncDate.replaceAll("-", ""); + } + + @Override + public String getLastSyncUpdateDate() { + String lastSyncDate = this.getBaseMapper().getLastSyncUpdateDate(); + if(lastSyncDate == null){ + return null; + } + return lastSyncDate.replaceAll("-", ""); + } } diff --git a/src/main/java/org/jeecg/modules/pms/controller/PmsMaterialProcessController.java b/src/main/java/org/jeecg/modules/pms/controller/PmsMaterialProcessController.java index 2d51ada..b66c2e4 100644 --- a/src/main/java/org/jeecg/modules/pms/controller/PmsMaterialProcessController.java +++ b/src/main/java/org/jeecg/modules/pms/controller/PmsMaterialProcessController.java @@ -1,181 +1,50 @@ package org.jeecg.modules.pms.controller; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.extern.slf4j.Slf4j; import org.jeecg.common.api.vo.Result; -import org.jeecg.common.aspect.annotation.AutoLog; import org.jeecg.common.system.base.controller.JeecgController; -import org.jeecg.common.system.query.QueryGenerator; import org.jeecg.modules.pms.entity.PmsMaterialProcess; -import org.jeecg.modules.pms.entity.PmsProcessBillMaterialsDetail; import org.jeecg.modules.pms.service.IPmsMaterialProcessService; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.*; -import org.springframework.web.servlet.ModelAndView; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import java.util.Arrays; -import java.util.Map; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; /** -* @Description: 鐗╂枡宸ュ簭 -* @Author: jeecg-boot -* @Date: 2025-07-01 -* @Version: V1.0 -*/ -@Api(tags="鐗╂枡宸ュ簭") + * @Description: 鐗╂枡宸ュ簭 + * @Author: jeecg-boot + * @Date: 2025-07-01 + * @Version: V1.0 + */ +@Api(tags = "鐗╂枡宸ュ簭") @RestController -@RequestMapping("/pms/pmsMaterialProcess") +@RequestMapping("/pms/materialProcess") @Slf4j public class PmsMaterialProcessController extends JeecgController<PmsMaterialProcess, IPmsMaterialProcessService> { - @Autowired - private IPmsMaterialProcessService pmsMaterialProcessService; + @Autowired + private IPmsMaterialProcessService pmsMaterialProcessService; - /** - * 鍒嗛〉鍒楄〃鏌ヨ - * - * @param pmsMaterialProcess - * @param pageNo - * @param pageSize - * @param req - * @return - */ - //@AutoLog(value = "鐗╂枡宸ュ簭-鍒嗛〉鍒楄〃鏌ヨ") - @ApiOperation(value="鐗╂枡宸ュ簭-鍒嗛〉鍒楄〃鏌ヨ", notes="鐗╂枡宸ュ簭-鍒嗛〉鍒楄〃鏌ヨ") - @GetMapping(value = "/list") - public Result<IPage<PmsMaterialProcess>> queryPageList(PmsMaterialProcess pmsMaterialProcess, - @RequestParam(name="pageNo", defaultValue="1") Integer pageNo, - @RequestParam(name="pageSize", defaultValue="10") Integer pageSize, - HttpServletRequest req) { - QueryWrapper<PmsMaterialProcess> queryWrapper = QueryGenerator.initQueryWrapper(pmsMaterialProcess, req.getParameterMap()); - Page<PmsMaterialProcess> page = new Page<PmsMaterialProcess>(pageNo, pageSize); - IPage<PmsMaterialProcess> pageList = pmsMaterialProcessService.page(page, queryWrapper); - return Result.OK(pageList); - } - - /** - * 娣诲姞 - * - * @param pmsMaterialProcess - * @return - */ - @AutoLog(value = "鐗╂枡宸ュ簭-娣诲姞") - @ApiOperation(value="鐗╂枡宸ュ簭-娣诲姞", notes="鐗╂枡宸ュ簭-娣诲姞") - //@RequiresPermissions("org.jeecg.modules:pms_material_process:add") - @PostMapping(value = "/add") - public Result<String> add(@RequestBody PmsMaterialProcess pmsMaterialProcess) { - pmsMaterialProcessService.save(pmsMaterialProcess); - return Result.OK("娣诲姞鎴愬姛锛�"); - } - - /** - * 缂栬緫 - * - * @param pmsMaterialProcess - * @return - */ - /** - * 缂栬緫 - * 鏍规嵁ID鏇存柊鐗╂枡宸ュ簭淇℃伅 - * - * @param pmsMaterialProcess 鐗╂枡宸ュ簭瀹炰綋瀵硅薄锛堝寘鍚渶瑕佹洿鏂扮殑ID鍜屼慨鏀瑰悗鐨勫瓧娈靛�硷級 - * - 蹇呴』鍖呭惈鏈夋晥鐨勭墿鏂欏伐搴廔D - * - 浠呮洿鏂板疄浣撲腑闈炵┖鐨勫瓧娈� - * @return 杩斿洖缁熶竴鏍煎紡鐨勫搷搴旂粨鏋滐紝鍖呭惈鎿嶄綔鐘舵�佸拰鎻愮ず淇℃伅 - * @apiNote 璇ユ搷浣滈渶瑕佸疄浣撲腑鍖呭惈鏈夋晥ID锛屾墽琛屽熀浜庝富閿殑瀛楁绾ф洿鏂� - */ - @AutoLog(value = "鐗╂枡宸ュ簭-缂栬緫") - @ApiOperation(value="鐗╂枡宸ュ簭-缂栬緫", notes="鐗╂枡宸ュ簭-缂栬緫") - //@RequiresPermissions("org.jeecg.modules:pms_material_process:edit") - @RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST}) - public Result<String> edit(@RequestBody PmsMaterialProcess pmsMaterialProcess) { - pmsMaterialProcessService.updateById(pmsMaterialProcess); - return Result.OK("缂栬緫鎴愬姛!"); - } - /** - * 閫氳繃id鍒犻櫎 - * - * @param id - * @return - */ - @AutoLog(value = "鐗╂枡宸ュ簭-閫氳繃id鍒犻櫎") - @ApiOperation(value="鐗╂枡宸ュ簭-閫氳繃id鍒犻櫎", notes="鐗╂枡宸ュ簭-閫氳繃id鍒犻櫎") - //@RequiresPermissions("org.jeecg.modules:pms_material_process:delete") - @DeleteMapping(value = "/delete") - public Result<String> delete(@RequestParam(name="id",required=true) String id) { - pmsMaterialProcessService.removeById(id); - return Result.OK("鍒犻櫎鎴愬姛!"); - } - - /** - * 鎵归噺鍒犻櫎 - * - * @param ids - * @return - */ - @AutoLog(value = "鐗╂枡宸ュ簭-鎵归噺鍒犻櫎") - @ApiOperation(value="鐗╂枡宸ュ簭-鎵归噺鍒犻櫎", notes="鐗╂枡宸ュ簭-鎵归噺鍒犻櫎") - //@RequiresPermissions("org.jeecg.modules:pms_material_process:deleteBatch") - @DeleteMapping(value = "/deleteBatch") - public Result<String> deleteBatch(@RequestParam(name="ids",required=true) String ids) { - this.pmsMaterialProcessService.removeByIds(Arrays.asList(ids.split(","))); - return Result.OK("鎵归噺鍒犻櫎鎴愬姛!"); - } - - /** - * 閫氳繃id鏌ヨ - * - * @param id - * @return - */ - //@AutoLog(value = "鐗╂枡宸ュ簭-閫氳繃id鏌ヨ") - @ApiOperation(value="鐗╂枡宸ュ簭-閫氳繃id鏌ヨ", notes="鐗╂枡宸ュ簭-閫氳繃id鏌ヨ") - @GetMapping(value = "/queryById") - public Result<PmsMaterialProcess> queryById(@RequestParam(name="id",required=true) String id) { - PmsMaterialProcess pmsMaterialProcess = pmsMaterialProcessService.getById(id); - if(pmsMaterialProcess==null) { - return Result.error("鏈壘鍒板搴旀暟鎹�"); - } - return Result.OK(pmsMaterialProcess); - } - - /** - * 瀵煎嚭excel - * - * @param request - * @param pmsMaterialProcess - */ - //@RequiresPermissions("org.jeecg.modules:pms_material_process:exportXls") - @RequestMapping(value = "/exportXls") - public ModelAndView exportXls(HttpServletRequest request, PmsMaterialProcess pmsMaterialProcess) { - return super.exportXls(request, pmsMaterialProcess, PmsMaterialProcess.class, "鐗╂枡宸ュ簭"); - } - - /**1路3 - * 閫氳繃excel瀵煎叆鏁版嵁 - * - * @param request - * @param response - * @return - */ - //@RequiresPermissions("pms_material_process:importExcel") - @RequestMapping(value = "/importExcel", method = RequestMethod.POST) - public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) { - return super.importExcel(request, response, PmsMaterialProcess.class); - } - @GetMapping(value = "/searchlikeQuery") - public Result<?> searchlikeQuery(PmsMaterialProcess pmsMaterialProcess, - @RequestParam(name="pageNo", defaultValue="1") Integer pageNo, - @RequestParam(name="pageSize", defaultValue="10") Integer pageSize, - HttpServletRequest req){ - IPage<Map<String, Object>> pageList = pmsMaterialProcessService.getpmsMaterialProcessListData(pageNo,pageSize,req); - + /** + * 鍒嗛〉鍒楄〃鏌ヨ + * + * @param query + * @param pageNo + * @param pageSize + * @return + */ + //@AutoLog(value = "鐗╂枡宸ュ簭-鍒嗛〉鍒楄〃鏌ヨ") + @ApiOperation(value = "鐗╂枡宸ュ簭-鍒嗛〉鍒楄〃鏌ヨ", notes = "鐗╂枡宸ュ簭-鍒嗛〉鍒楄〃鏌ヨ") + @GetMapping(value = "/list") + public Result<IPage<PmsMaterialProcess>> queryPageList(PmsMaterialProcess query, + @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, + @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) { + Page<PmsMaterialProcess> page = new Page<PmsMaterialProcess>(pageNo, pageSize); + IPage<PmsMaterialProcess> pageList = pmsMaterialProcessService.queryPageList(page, query); return Result.OK(pageList); } - } diff --git a/src/main/java/org/jeecg/modules/pms/controller/PmsProcessBillMaterialsController.java b/src/main/java/org/jeecg/modules/pms/controller/PmsProcessBillMaterialsController.java index 1606554..67aa1ca 100644 --- a/src/main/java/org/jeecg/modules/pms/controller/PmsProcessBillMaterialsController.java +++ b/src/main/java/org/jeecg/modules/pms/controller/PmsProcessBillMaterialsController.java @@ -1,172 +1,67 @@ package org.jeecg.modules.pms.controller; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.extern.slf4j.Slf4j; import org.jeecg.common.api.vo.Result; -import org.jeecg.common.aspect.annotation.AutoLog; import org.jeecg.common.system.base.controller.JeecgController; -import org.jeecg.common.system.query.QueryGenerator; -import org.jeecg.modules.lsw.entity.LswMaterialInbound; import org.jeecg.modules.pms.entity.PmsProcessBillMaterials; import org.jeecg.modules.pms.service.IPmsProcessBillMaterialsService; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.*; -import org.springframework.web.servlet.ModelAndView; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import java.util.Arrays; -import java.util.Map; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; /** -* @Description: 璁㈠崟BOM -* @Author: jeecg-boot -* @Date: 2025-07-01 -* @Version: V1.0 -*/ -@Api(tags="璁㈠崟BOM") + * @Description: 璁㈠崟BOM + * @Author: jeecg-boot + * @Date: 2025-07-01 + * @Version: V1.0 + */ +@Api(tags = "璁㈠崟BOM") @RestController -@RequestMapping("/pmsprocessbillmaterials/pmsProcessBillMaterials") +@RequestMapping("/pms/processBillMaterials") @Slf4j public class PmsProcessBillMaterialsController extends JeecgController<PmsProcessBillMaterials, IPmsProcessBillMaterialsService> { - @Autowired - private IPmsProcessBillMaterialsService pmsProcessBillMaterialsService; + @Autowired + private IPmsProcessBillMaterialsService pmsProcessBillMaterialsService; - /** - * 鍒嗛〉鍒楄〃鏌ヨ - * - * @param pmsProcessBillMaterials - * @param pageNo - * @param pageSize - * @param req - * @return - */ - //@AutoLog(value = "璁㈠崟BOM-鍒嗛〉鍒楄〃鏌ヨ") - @ApiOperation(value="璁㈠崟BOM-鍒嗛〉鍒楄〃鏌ヨ", notes="璁㈠崟BOM-鍒嗛〉鍒楄〃鏌ヨ") - @GetMapping(value = "/list") - public Result<IPage<PmsProcessBillMaterials>> queryPageList(PmsProcessBillMaterials pmsProcessBillMaterials, - @RequestParam(name="pageNo", defaultValue="1") Integer pageNo, - @RequestParam(name="pageSize", defaultValue="10") Integer pageSize, - HttpServletRequest req) { - QueryWrapper<PmsProcessBillMaterials> queryWrapper = QueryGenerator.initQueryWrapper(pmsProcessBillMaterials, req.getParameterMap()); - Page<PmsProcessBillMaterials> page = new Page<PmsProcessBillMaterials>(pageNo, pageSize); - IPage<PmsProcessBillMaterials> pageList = pmsProcessBillMaterialsService.page(page, queryWrapper); - return Result.OK(pageList); - } - - /** - * 娣诲姞 - * - * @param pmsProcessBillMaterials - * @return - */ - @AutoLog(value = "璁㈠崟BOM-娣诲姞") - @ApiOperation(value="璁㈠崟BOM-娣诲姞", notes="璁㈠崟BOM-娣诲姞") - //@RequiresPermissions("org.jeecg.modules:pms_process_bill_materials:add") - @PostMapping(value = "/add") - public Result<String> add(@RequestBody PmsProcessBillMaterials pmsProcessBillMaterials) { - pmsProcessBillMaterialsService.save(pmsProcessBillMaterials); - return Result.OK("娣诲姞鎴愬姛锛�"); - } - - /** - * 缂栬緫 - * - * @param pmsProcessBillMaterials - * @return - */ - @AutoLog(value = "璁㈠崟BOM-缂栬緫") - @ApiOperation(value="璁㈠崟BOM-缂栬緫", notes="璁㈠崟BOM-缂栬緫") - //@RequiresPermissions("org.jeecg.modules:pms_process_bill_materials:edit") - @RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST}) - public Result<String> edit(@RequestBody PmsProcessBillMaterials pmsProcessBillMaterials) { - pmsProcessBillMaterialsService.updateById(pmsProcessBillMaterials); - return Result.OK("缂栬緫鎴愬姛!"); - } - - /** - * 閫氳繃id鍒犻櫎 - * - * @param id - * @return - */ - @AutoLog(value = "璁㈠崟BOM-閫氳繃id鍒犻櫎") - @ApiOperation(value="璁㈠崟BOM-閫氳繃id鍒犻櫎", notes="璁㈠崟BOM-閫氳繃id鍒犻櫎") - //@RequiresPermissions("org.jeecg.modules:pms_process_bill_materials:delete") - @DeleteMapping(value = "/delete") - public Result<String> delete(@RequestParam(name="id",required=true) String id) { - pmsProcessBillMaterialsService.removeById(id); - return Result.OK("鍒犻櫎鎴愬姛!"); - } - - /** - * 鎵归噺鍒犻櫎 - * - * @param ids - * @return - */ - @AutoLog(value = "璁㈠崟BOM-鎵归噺鍒犻櫎") - @ApiOperation(value="璁㈠崟BOM-鎵归噺鍒犻櫎", notes="璁㈠崟BOM-鎵归噺鍒犻櫎") - //@RequiresPermissions("org.jeecg.modules:pms_process_bill_materials:deleteBatch") - @DeleteMapping(value = "/deleteBatch") - public Result<String> deleteBatch(@RequestParam(name="ids",required=true) String ids) { - this.pmsProcessBillMaterialsService.removeByIds(Arrays.asList(ids.split(","))); - return Result.OK("鎵归噺鍒犻櫎鎴愬姛!"); - } - - /** - * 閫氳繃id鏌ヨ - * - * @param id - * @return - */ - //@AutoLog(value = "璁㈠崟BOM-閫氳繃id鏌ヨ") - @ApiOperation(value="璁㈠崟BOM-閫氳繃id鏌ヨ", notes="璁㈠崟BOM-閫氳繃id鏌ヨ") - @GetMapping(value = "/queryById") - public Result<PmsProcessBillMaterials> queryById(@RequestParam(name="id",required=true) String id) { - PmsProcessBillMaterials pmsProcessBillMaterials = pmsProcessBillMaterialsService.getById(id); - if(pmsProcessBillMaterials==null) { - return Result.error("鏈壘鍒板搴旀暟鎹�"); - } - return Result.OK(pmsProcessBillMaterials); - } - - /** - * 瀵煎嚭excel - * - * @param request - * @param pmsProcessBillMaterials - */ - //@RequiresPermissions("org.jeecg.modules:pms_process_bill_materials:exportXls") - @RequestMapping(value = "/exportXls") - public ModelAndView exportXls(HttpServletRequest request, PmsProcessBillMaterials pmsProcessBillMaterials) { - return super.exportXls(request, pmsProcessBillMaterials, PmsProcessBillMaterials.class, "璁㈠崟BOM"); - } - - /** - * 閫氳繃excel瀵煎叆鏁版嵁 - * - * @param request - * @param response - * @return - */ - //@RequiresPermissions("pms_process_bill_materials:importExcel") - @RequestMapping(value = "/importExcel", method = RequestMethod.POST) - public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) { - return super.importExcel(request, response, PmsProcessBillMaterials.class); - } - @GetMapping(value = "/searchlikeQuery") - public Result<?> searchlikeQuery(PmsProcessBillMaterials pmsProcessBillMaterials, - @RequestParam(name="pageNo", defaultValue="1") Integer pageNo, - @RequestParam(name="pageSize", defaultValue="10") Integer pageSize, - HttpServletRequest req){ - IPage<Map<String, Object>> pageList = pmsProcessBillMaterialsService.getpmsProcessBillMaterialsListData(pageNo,pageSize,req); - + /** + * 鍒嗛〉鍒楄〃鏌ヨ + * + * @param query + * @param pageNo + * @param pageSize + * @return + */ + @ApiOperation(value = "璁㈠崟BOM-鍒嗛〉鍒楄〃鏌ヨ", notes = "璁㈠崟BOM-鍒嗛〉鍒楄〃鏌ヨ") + @GetMapping(value = "/list") + public Result<IPage<PmsProcessBillMaterials>> queryPageList(PmsProcessBillMaterials query, + @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, + @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) { +// QueryWrapper<PmsProcessBillMaterials> queryWrapper = QueryGenerator.initQueryWrapper(pmsProcessBillMaterials, req.getParameterMap()); + Page<PmsProcessBillMaterials> page = new Page<PmsProcessBillMaterials>(pageNo, pageSize); + IPage<PmsProcessBillMaterials> pageList = pmsProcessBillMaterialsService.queryPageList(page, query); return Result.OK(pageList); } + /** + * 閫氳繃id鏌ヨ + * + * @param id + * @return + */ + //@AutoLog(value = "璁㈠崟BOM-閫氳繃id鏌ヨ") + @ApiOperation(value = "璁㈠崟BOM-閫氳繃id鏌ヨ", notes = "璁㈠崟BOM-閫氳繃id鏌ヨ") + @GetMapping(value = "/queryById") + public Result<PmsProcessBillMaterials> queryById(@RequestParam(name = "id", required = true) String id) { + PmsProcessBillMaterials pmsProcessBillMaterials = pmsProcessBillMaterialsService.getById(id); + if (pmsProcessBillMaterials == null) { + return Result.error("鏈壘鍒板搴旀暟鎹�"); + } + return Result.OK(pmsProcessBillMaterials); + } } diff --git a/src/main/java/org/jeecg/modules/pms/controller/PmsProcessBillMaterialsDetailController.java b/src/main/java/org/jeecg/modules/pms/controller/PmsProcessBillMaterialsDetailController.java index 8f93da4..583065a 100644 --- a/src/main/java/org/jeecg/modules/pms/controller/PmsProcessBillMaterialsDetailController.java +++ b/src/main/java/org/jeecg/modules/pms/controller/PmsProcessBillMaterialsDetailController.java @@ -1,182 +1,39 @@ package org.jeecg.modules.pms.controller; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import com.baomidou.mybatisplus.core.metadata.IPage; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.extern.slf4j.Slf4j; import org.jeecg.common.api.vo.Result; -import org.jeecg.common.aspect.annotation.AutoLog; import org.jeecg.common.system.base.controller.JeecgController; -import org.jeecg.common.system.query.QueryGenerator; -import org.jeecg.modules.pms.entity.PmsProcessBillMaterials; import org.jeecg.modules.pms.entity.PmsProcessBillMaterialsDetail; import org.jeecg.modules.pms.service.IPmsProcessBillMaterialsDetailService; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.*; -import org.springframework.web.servlet.ModelAndView; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import java.util.Arrays; -import java.util.Map; +import java.util.List; /** -* @Description: 鐗╂枡娓呭崟 -* @Author: jeecg-boot -* @Date: 2025-07-01 -* @Version: V1.0 -*/ -@Api(tags="鐗╂枡娓呭崟") + * @Description: 鐗╂枡娓呭崟 + * @Author: jeecg-boot + * @Date: 2025-07-01 + * @Version: V1.0 + */ +@Api(tags = "鐗╂枡娓呭崟") @RestController -@RequestMapping("/pms/pmsProcessBillMaterialsDetail") +@RequestMapping("/pms/processBillMaterialsDetail") @Slf4j public class PmsProcessBillMaterialsDetailController extends JeecgController<PmsProcessBillMaterialsDetail, IPmsProcessBillMaterialsDetailService> { - @Autowired - private IPmsProcessBillMaterialsDetailService pmsProcessBillMaterialsDetailService; + @Autowired + private IPmsProcessBillMaterialsDetailService pmsProcessBillMaterialsDetailService; - /** - * 鍒嗛〉鍒楄〃鏌ヨ - * - * @param pmsProcessBillMaterialsDetail - * @param pageNo - * @param pageSize - * @param req - * @return - */ - //@AutoLog(value = "鐗╂枡娓呭崟-鍒嗛〉鍒楄〃鏌ヨ") - @ApiOperation(value="鐗╂枡娓呭崟-鍒嗛〉鍒楄〃鏌ヨ", notes="鐗╂枡娓呭崟-鍒嗛〉鍒楄〃鏌ヨ") - @GetMapping(value = "/list") - public Result<IPage<PmsProcessBillMaterialsDetail>> queryPageList(PmsProcessBillMaterialsDetail pmsProcessBillMaterialsDetail, - @RequestParam(name="pageNo", defaultValue="1") Integer pageNo, - @RequestParam(name="pageSize", defaultValue="10") Integer pageSize, - HttpServletRequest req) { - QueryWrapper<PmsProcessBillMaterialsDetail> queryWrapper = QueryGenerator.initQueryWrapper(pmsProcessBillMaterialsDetail, req.getParameterMap()); - Page<PmsProcessBillMaterialsDetail> page = new Page<PmsProcessBillMaterialsDetail>(pageNo, pageSize); - IPage<PmsProcessBillMaterialsDetail> pageList = pmsProcessBillMaterialsDetailService.page(page, queryWrapper); - return Result.OK(pageList); - } - - /** - * 娣诲姞 - * - * @param pmsProcessBillMaterialsDetail - * @return - */ - @AutoLog(value = "鐗╂枡娓呭崟-娣诲姞") - @ApiOperation(value="鐗╂枡娓呭崟-娣诲姞", notes="鐗╂枡娓呭崟-娣诲姞") - //@RequiresPermissions("org.jeecg.modules:pms_process_bill_materials_detail:add") - @PostMapping(value = "/add") - public Result<String> add(@RequestBody PmsProcessBillMaterialsDetail pmsProcessBillMaterialsDetail) { - pmsProcessBillMaterialsDetailService.save(pmsProcessBillMaterialsDetail); - return Result.OK("娣诲姞鎴愬姛锛�"); - } - - /** - * 缂栬緫 - * - * @param pmsProcessBillMaterialsDetail - * @return - */ - @AutoLog(value = "鐗╂枡娓呭崟-缂栬緫") - @ApiOperation(value="鐗╂枡娓呭崟-缂栬緫", notes="鐗╂枡娓呭崟-缂栬緫") - //@RequiresPermissions("org.jeecg.modules:pms_process_bill_materials_detail:edit") - @RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST}) - public Result<String> edit(@RequestBody PmsProcessBillMaterialsDetail pmsProcessBillMaterialsDetail) { - pmsProcessBillMaterialsDetailService.updateById(pmsProcessBillMaterialsDetail); - return Result.OK("缂栬緫鎴愬姛!"); - } - - /** - * 閫氳繃id鍒犻櫎 - * - * @param id - * @return - */ - @AutoLog(value = "鐗╂枡娓呭崟-閫氳繃id鍒犻櫎") - @ApiOperation(value="鐗╂枡娓呭崟-閫氳繃id鍒犻櫎", notes="鐗╂枡娓呭崟-閫氳繃id鍒犻櫎") - //@RequiresPermissions("org.jeecg.modules:pms_process_bill_materials_detail:delete") - @DeleteMapping(value = "/delete") - public Result<String> delete(@RequestParam(name="id",required=true) String id) { - pmsProcessBillMaterialsDetailService.removeById(id); - return Result.OK("鍒犻櫎鎴愬姛!"); - } - - /** - * 鎵归噺鍒犻櫎 - * - * @param ids - * @return - */ - @AutoLog(value = "鐗╂枡娓呭崟-鎵归噺鍒犻櫎") - @ApiOperation(value="鐗╂枡娓呭崟-鎵归噺鍒犻櫎", notes="鐗╂枡娓呭崟-鎵归噺鍒犻櫎") - //@RequiresPermissions("org.jeecg.modules:pms_process_bill_materials_detail:deleteBatch") - @DeleteMapping(value = "/deleteBatch") - public Result<String> deleteBatch(@RequestParam(name="ids",required=true) String ids) { - this.pmsProcessBillMaterialsDetailService.removeByIds(Arrays.asList(ids.split(","))); - return Result.OK("鎵归噺鍒犻櫎鎴愬姛!"); - } - - /** - * 閫氳繃id鏌ヨ - * - * @param id - * @return - */ - //@AutoLog(value = "鐗╂枡娓呭崟-閫氳繃id鏌ヨ") - @ApiOperation(value="鐗╂枡娓呭崟-閫氳繃id鏌ヨ", notes="鐗╂枡娓呭崟-閫氳繃id鏌ヨ") - @GetMapping(value = "/queryById") - public Result<PmsProcessBillMaterialsDetail> queryById(@RequestParam(name="id",required=true) String id) { - PmsProcessBillMaterialsDetail pmsProcessBillMaterialsDetail = pmsProcessBillMaterialsDetailService.getById(id); - if(pmsProcessBillMaterialsDetail==null) { - return Result.error("鏈壘鍒板搴旀暟鎹�"); - } - return Result.OK(pmsProcessBillMaterialsDetail); - } - - /** - * 瀵煎嚭excel - * - * @param request - * @param pmsProcessBillMaterialsDetail - */ - //@RequiresPermissions("org.jeecg.modules:pms_process_bill_materials_detail:exportXls") - @RequestMapping(value = "/exportXls") - public ModelAndView exportXls(HttpServletRequest request, PmsProcessBillMaterialsDetail pmsProcessBillMaterialsDetail) { - return super.exportXls(request, pmsProcessBillMaterialsDetail, PmsProcessBillMaterialsDetail.class, "鐗╂枡娓呭崟"); - } - - /** - * 閫氳繃excel瀵煎叆鏁版嵁 - * - * @param request - * @param response - * @return - */ - //@RequiresPermissions("pms_process_bill_materials_detail:importExcel") - @RequestMapping(value = "/importExcel", method = RequestMethod.POST) - public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) { - return super.importExcel(request, response, PmsProcessBillMaterialsDetail.class); - } - @ApiOperation(value="鐗╂枡娓呭崟-閫氳繃鐢熶骇鐗╂枡ID鏌ヨ", notes="鐗╂枡娓呭崟-閫氳繃id鏌ヨ") + @ApiOperation(value = "鐗╂枡娓呭崟-閫氳繃鐢熶骇鐗╂枡ID鏌ヨ", notes = "鐗╂枡娓呭崟-閫氳繃id鏌ヨ") @GetMapping(value = "/queryByMaterialId") - public Result<PmsProcessBillMaterialsDetail> queryByMaterialId(@RequestParam(name="materialId",required=true) String materialId) { - PmsProcessBillMaterialsDetail pmsProcessBillMaterialsDetail = pmsProcessBillMaterialsDetailService.queryByMaterialId(materialId); - if(pmsProcessBillMaterialsDetail==null) { - return Result.error("鏈壘鍒板搴旀暟鎹�"); - } - return Result.OK(pmsProcessBillMaterialsDetail); - } - - @GetMapping(value = "/searchlikeQuery") - public Result<?> searchlikeQuery(PmsProcessBillMaterialsDetail pmsProcessBillMaterialsDetail, - @RequestParam(name="pageNo", defaultValue="1") Integer pageNo, - @RequestParam(name="pageSize", defaultValue="10") Integer pageSize, - HttpServletRequest req){ - IPage<Map<String, Object>> pageList = pmsProcessBillMaterialsDetailService.getpmsProcessBillMaterialsDetailListData(pageNo,pageSize,req); - - return Result.OK(pageList); + public Result<?> queryByMaterialId(@RequestParam(name = "materialId", required = true) String materialId) { + List<PmsProcessBillMaterialsDetail> list = pmsProcessBillMaterialsDetailService.queryByMaterialId(materialId); + return Result.OK(list); } } diff --git a/src/main/java/org/jeecg/modules/pms/entity/PmsMaterialProcess.java b/src/main/java/org/jeecg/modules/pms/entity/PmsMaterialProcess.java index 86974f7..aa2a315 100644 --- a/src/main/java/org/jeecg/modules/pms/entity/PmsMaterialProcess.java +++ b/src/main/java/org/jeecg/modules/pms/entity/PmsMaterialProcess.java @@ -1,8 +1,8 @@ package org.jeecg.modules.pms.entity; import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableLogic; import com.baomidou.mybatisplus.annotation.TableName; import com.fasterxml.jackson.annotation.JsonFormat; import io.swagger.annotations.ApiModel; @@ -10,8 +10,7 @@ import lombok.Data; import lombok.EqualsAndHashCode; import lombok.experimental.Accessors; -import org.jeecg.common.aspect.annotation.Dict; -import org.jeecgframework.poi.excel.annotation.Excel; +import org.jeecg.modules.sap.dto.OrderProcessDTO; import org.springframework.format.annotation.DateTimeFormat; import java.io.Serializable; @@ -20,65 +19,68 @@ /** * @Description: 鐗╂枡宸ュ簭 * @Author: jeecg-boot - * @Date: 2025-07-01 + * @Date: 2025-07-01 * @Version: V1.0 */ @Data @TableName("pms_material_process") @Accessors(chain = true) @EqualsAndHashCode(callSuper = false) -@ApiModel(value="pms_material_process瀵硅薄", description="鐗╂枡宸ュ簭") +@ApiModel(value = "pms_material_process瀵硅薄", description = "鐗╂枡宸ュ簭") public class PmsMaterialProcess implements Serializable { private static final long serialVersionUID = 1L; - /**涓婚敭*/ - @TableId(type = IdType.ASSIGN_ID) + /**涓婚敭*/ + @TableId(type = IdType.ASSIGN_ID) @ApiModelProperty(value = "涓婚敭") private String id; - /**鍒涘缓浜�*/ + /**鍒涘缓浜�*/ @ApiModelProperty(value = "鍒涘缓浜�") private String createBy; - /**鍒涘缓鏃ユ湡*/ - @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss") - @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss") + /**鍒涘缓鏃ユ湡*/ + @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss") + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") @ApiModelProperty(value = "鍒涘缓鏃ユ湡") private Date createTime; - /**鏇存柊浜�*/ + /**鏇存柊浜�*/ @ApiModelProperty(value = "鏇存柊浜�") private String updateBy; - /**鏇存柊鏃ユ湡*/ - @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss") - @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss") + /**鏇存柊鏃ユ湡*/ + @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss") + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") @ApiModelProperty(value = "鏇存柊鏃ユ湡") private Date updateTime; - /**鍒犻櫎鏍囪*/ - @Excel(name = "鍒犻櫎鏍囪", width = 15) - @ApiModelProperty(value = "鍒犻櫎鏍囪") - @TableLogic - private Integer delFlag; - /**鐗╂枡缂栫爜*/ - @Excel(name = "鐗╂枡缂栫爜", width = 15) + /**鐢熶骇璁㈠崟ID*/ + @ApiModelProperty(value = "鐢熶骇璁㈠崟ID") + private String orderId; + /**鐗╂枡缂栫爜*/ @ApiModelProperty(value = "鐗╂枡缂栫爜") private String materialNumber; - /**鐗╂枡鍚嶇О*/ - @Excel(name = "鐗╂枡鍚嶇О", width = 15) + /**鐗╂枡鍚嶇О*/ @ApiModelProperty(value = "鐗╂枡鍚嶇О") private String materialName; - /**浜х嚎ID(SAP宸ヤ綔涓績)*/ - @Excel(name = "浜х嚎ID(SAP宸ヤ綔涓績)", width = 15) - @ApiModelProperty(value = "浜х嚎ID(SAP宸ヤ綔涓績)") - @Dict(dictTable = "base_factory", dicCode = "id", dicText = "factory_name") - private String factoryId; - /**宸ュ簭鍙�*/ - @Excel(name = "宸ュ簭鍙�", width = 15) + /**宸ュ簭鍙�*/ @ApiModelProperty(value = "宸ュ簭鍙�") private String processCode; - /**宸ュ簭鍚嶇О*/ - @Excel(name = "宸ュ簭鍚嶇О", width = 15) + /**宸ュ簭鍚嶇О*/ @ApiModelProperty(value = "宸ュ簭鍚嶇О") private String processName; - /**鎺у埗鐮�*/ - @Excel(name = "鎺у埗鐮�", width = 15) + /**鎺у埗鐮�*/ @ApiModelProperty(value = "鎺у埗鐮�") private String controlCode; + /** 璁㈠崟鍙� */ + @ApiModelProperty(value = "璁㈠崟鍙�") + @TableField(exist = false) + private String orderCode; + + public PmsMaterialProcess(){} + + public PmsMaterialProcess(String orderId, String materialName, OrderProcessDTO dto) { + this.orderId = orderId; + this.materialNumber = dto.getMATNR(); + this.materialName = materialName; + this.processCode = dto.getVORNR(); + this.processName = dto.getLTXA1(); + this.controlCode = dto.getSTEUS(); + } } diff --git a/src/main/java/org/jeecg/modules/pms/entity/PmsProcessBillMaterials.java b/src/main/java/org/jeecg/modules/pms/entity/PmsProcessBillMaterials.java index 95ea7ca..dc82660 100644 --- a/src/main/java/org/jeecg/modules/pms/entity/PmsProcessBillMaterials.java +++ b/src/main/java/org/jeecg/modules/pms/entity/PmsProcessBillMaterials.java @@ -1,8 +1,8 @@ package org.jeecg.modules.pms.entity; import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableLogic; import com.baomidou.mybatisplus.annotation.TableName; import com.fasterxml.jackson.annotation.JsonFormat; import io.swagger.annotations.ApiModel; @@ -10,10 +10,10 @@ import lombok.Data; import lombok.EqualsAndHashCode; import lombok.experimental.Accessors; -import org.jeecgframework.poi.excel.annotation.Excel; import org.springframework.format.annotation.DateTimeFormat; import java.io.Serializable; +import java.math.BigDecimal; import java.util.Date; /** @@ -50,33 +50,23 @@ @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss") @ApiModelProperty(value = "鏇存柊鏃ユ湡") private Date updateTime; - /**鍒犻櫎鏍囪*/ - @Excel(name = "鍒犻櫎鏍囪", width = 15) - @ApiModelProperty(value = "鍒犻櫎鏍囪") - @TableLogic - private Integer delFlag; /**鐢熸垚璁㈠崟ID*/ - @Excel(name = "鐢熸垚璁㈠崟ID", width = 15) @ApiModelProperty(value = "鐢熸垚璁㈠崟ID") private String orderId; /**鐗╂枡缂栫爜*/ - @Excel(name = "鐗╂枡缂栫爜", width = 15) @ApiModelProperty(value = "鐗╂枡缂栫爜") private String materialNumber; /**鐗╂枡鍚嶇О*/ - @Excel(name = "鐗╂枡鍚嶇О", width = 15) @ApiModelProperty(value = "鐗╂枡鍚嶇О") private String materialName; - /**BOM浠g爜*/ - @Excel(name = "BOM浠g爜", width = 15) - @ApiModelProperty(value = "BOM浠g爜") - private String billMaterialsCode; /**鍩烘湰鍗曚綅*/ - @Excel(name = "鍩烘湰鍗曚綅", width = 15) @ApiModelProperty(value = "鍩烘湰鍗曚綅") private String productionUnit; /**璁㈠崟鏁伴噺*/ - @Excel(name = "璁㈠崟鏁伴噺", width = 15) @ApiModelProperty(value = "璁㈠崟鏁伴噺") - private Double productionQuantity; + private BigDecimal productionQuantity; + /** 璁㈠崟鍙� */ + @ApiModelProperty(value = "璁㈠崟鍙�") + @TableField(exist = false) + private String orderCode; } diff --git a/src/main/java/org/jeecg/modules/pms/entity/PmsProcessBillMaterialsDetail.java b/src/main/java/org/jeecg/modules/pms/entity/PmsProcessBillMaterialsDetail.java index 95dc6c7..b00dfef 100644 --- a/src/main/java/org/jeecg/modules/pms/entity/PmsProcessBillMaterialsDetail.java +++ b/src/main/java/org/jeecg/modules/pms/entity/PmsProcessBillMaterialsDetail.java @@ -10,10 +10,11 @@ import lombok.EqualsAndHashCode; import lombok.experimental.Accessors; import org.jeecg.common.aspect.annotation.Dict; -import org.jeecgframework.poi.excel.annotation.Excel; +import org.jeecg.modules.sap.dto.OrderBomDTO; import org.springframework.format.annotation.DateTimeFormat; import java.io.Serializable; +import java.math.BigDecimal; import java.util.Date; /** @@ -51,20 +52,29 @@ @ApiModelProperty(value = "鏇存柊鏃ユ湡") private Date updateTime; /**鐢熶骇鐗╂枡ID*/ - @Excel(name = "鐢熶骇鐗╂枡ID", width = 15) @ApiModelProperty(value = "鐢熶骇鐗╂枡ID") @Dict(dictTable = "pms_process_bill_materials", dicCode = "id", dicText = "material_number") private String materialId; /**鐗╂枡缂栫爜*/ - @Excel(name = "鐗╂枡缂栫爜", width = 15) @ApiModelProperty(value = "鐗╂枡缂栫爜") private String materialNumber; /**鐗╂枡鍚嶇О*/ - @Excel(name = "鐗╂枡鍚嶇О", width = 15) @ApiModelProperty(value = "鐗╂枡鍚嶇О") private String materialName; + /**鍩烘湰鍗曚綅*/ + @ApiModelProperty(value = "鍩烘湰鍗曚綅") + private String productionUnit; /**闇�姹傜敤閲�*/ - @Excel(name = "闇�姹傜敤閲�", width = 15) @ApiModelProperty(value = "闇�姹傜敤閲�") - private Double usageUnit; + private BigDecimal usageQuantity; + + public PmsProcessBillMaterialsDetail(){} + + public PmsProcessBillMaterialsDetail(String materialId, OrderBomDTO dto) { + this.materialId = materialId; + this.materialNumber = dto.getMATNR(); + this.materialName = dto.getMAKTX(); + this.productionUnit = dto.getMEINS(); + this.usageQuantity = new BigDecimal(dto.getBDMNG()); + } } diff --git a/src/main/java/org/jeecg/modules/pms/mapper/PmsMaterialProcessMapper.java b/src/main/java/org/jeecg/modules/pms/mapper/PmsMaterialProcessMapper.java index ce58f1c..77c3d8f 100644 --- a/src/main/java/org/jeecg/modules/pms/mapper/PmsMaterialProcessMapper.java +++ b/src/main/java/org/jeecg/modules/pms/mapper/PmsMaterialProcessMapper.java @@ -1,7 +1,9 @@ package org.jeecg.modules.pms.mapper; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import org.apache.ibatis.annotations.Param; import org.jeecg.modules.pms.entity.PmsMaterialProcess; @@ -14,5 +16,11 @@ * @Version: V1.0 */ public interface PmsMaterialProcessMapper extends BaseMapper<PmsMaterialProcess> { - IPage<Map<String, Object>> getpmsMaterialProcessListData(IPage<Map> pageData, @Param("params")Map<String, String> paramMap); + /** + * 鍒嗛〉鏌ヨ + * @param page + * @param queryWrapper + * @return + */ + IPage<PmsMaterialProcess> queryPageList(Page<PmsMaterialProcess> page, @Param("ew") QueryWrapper<PmsMaterialProcess> queryWrapper); } diff --git a/src/main/java/org/jeecg/modules/pms/mapper/PmsProcessBillMaterialsMapper.java b/src/main/java/org/jeecg/modules/pms/mapper/PmsProcessBillMaterialsMapper.java index 93f2716..bebddbe 100644 --- a/src/main/java/org/jeecg/modules/pms/mapper/PmsProcessBillMaterialsMapper.java +++ b/src/main/java/org/jeecg/modules/pms/mapper/PmsProcessBillMaterialsMapper.java @@ -1,18 +1,24 @@ package org.jeecg.modules.pms.mapper; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import org.apache.ibatis.annotations.Param; import org.jeecg.modules.pms.entity.PmsProcessBillMaterials; - -import java.util.Map; /** * @Description: 璁㈠崟BOM * @Author: jeecg-boot - * @Date: 2025-07-01 + * @Date: 2025-07-01 * @Version: V1.0 */ public interface PmsProcessBillMaterialsMapper extends BaseMapper<PmsProcessBillMaterials> { - IPage<Map<String, Object>> getpmsProcessBillMaterialsListData(IPage<Map> pageData, @Param("params")Map<String, String> paramMap); + /** + * 鍒嗛〉鏌ヨ + * @param page + * @param queryWrapper + * @return + */ + IPage<PmsProcessBillMaterials> queryPageList(Page<PmsProcessBillMaterials> page, @Param("ew") QueryWrapper<PmsProcessBillMaterials> queryWrapper); } diff --git a/src/main/java/org/jeecg/modules/pms/mapper/xml/PmsMaterialProcessMapper.xml b/src/main/java/org/jeecg/modules/pms/mapper/xml/PmsMaterialProcessMapper.xml index 925e4b8..c422823 100644 --- a/src/main/java/org/jeecg/modules/pms/mapper/xml/PmsMaterialProcessMapper.xml +++ b/src/main/java/org/jeecg/modules/pms/mapper/xml/PmsMaterialProcessMapper.xml @@ -1,13 +1,11 @@ <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <mapper namespace="org.jeecg.modules.pms.mapper.PmsMaterialProcessMapper"> - <select id="getpmsMaterialProcessListData" parameterType="Map" resultType="Map"> - select * from pms_material_process WHERE 1=1 - <if test="params.materialNumber != null and params.materialNumber != ''"> - AND material_number LIKE CONCAT('%', #{params.materialNumber}, '%') - </if> - <if test="params.materialName != null and params.materialName != ''"> - AND material_name LIKE CONCAT('%', #{params.materialName}, '%') - </if> + + <select id="queryPageList" resultType="org.jeecg.modules.pms.entity.PmsMaterialProcess"> + select pbm.*, po.order_code + from pms_material_process pbm + left join mes_production_order po on pbm.order_id = po.id + ${ew.customSqlSegment} </select> </mapper> \ No newline at end of file diff --git a/src/main/java/org/jeecg/modules/pms/mapper/xml/PmsProcessBillMaterialsMapper.xml b/src/main/java/org/jeecg/modules/pms/mapper/xml/PmsProcessBillMaterialsMapper.xml index fcfcf13..95eec7f 100644 --- a/src/main/java/org/jeecg/modules/pms/mapper/xml/PmsProcessBillMaterialsMapper.xml +++ b/src/main/java/org/jeecg/modules/pms/mapper/xml/PmsProcessBillMaterialsMapper.xml @@ -1,13 +1,10 @@ <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <mapper namespace="org.jeecg.modules.pms.mapper.PmsProcessBillMaterialsMapper"> - <select id="getpmsProcessBillMaterialsListData" parameterType="Map" resultType="Map"> - select * from pms_process_bill_materials WHERE 1=1 - <if test="params.materialNumber != null and params.materialNumber != ''"> - AND material_number LIKE CONCAT('%', #{params.materialNumber}, '%') - </if> - <if test="params.materialName != null and params.materialName != ''"> - AND material_name LIKE CONCAT('%', #{params.materialName}, '%') - </if> + <select id="queryPageList" resultType="org.jeecg.modules.pms.entity.PmsProcessBillMaterials"> + select pbm.*, po.order_code + from pms_process_bill_materials pbm + left join mes_production_order po on pbm.order_id = po.id + ${ew.customSqlSegment} </select> </mapper> \ No newline at end of file diff --git a/src/main/java/org/jeecg/modules/pms/service/IPmsMaterialProcessService.java b/src/main/java/org/jeecg/modules/pms/service/IPmsMaterialProcessService.java index 12c8cef..df9d5b7 100644 --- a/src/main/java/org/jeecg/modules/pms/service/IPmsMaterialProcessService.java +++ b/src/main/java/org/jeecg/modules/pms/service/IPmsMaterialProcessService.java @@ -1,10 +1,14 @@ package org.jeecg.modules.pms.service; import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.IService; +import org.jeecg.modules.mes.entity.MesProductionOrder; import org.jeecg.modules.pms.entity.PmsMaterialProcess; +import org.jeecg.modules.sap.dto.OrderProcessDTO; import javax.servlet.http.HttpServletRequest; +import java.util.List; import java.util.Map; /** @@ -14,5 +18,24 @@ * @Version: V1.0 */ public interface IPmsMaterialProcessService extends IService<PmsMaterialProcess> { - IPage<Map<String, Object>> getpmsMaterialProcessListData(Integer pageNo, Integer pageSize, HttpServletRequest req); + /** + * + * @param orderMap + * @param orderProcessDTOList + * @return + */ + boolean saveOrUpdateOrderProcess(Map<String, MesProductionOrder> orderMap, List<OrderProcessDTO> orderProcessDTOList); + /** + * 鍒犻櫎鍘熸湁鐨勬暟鎹� + * @param orderId + */ + void removeByOrderId(String orderId); + + /** + * 鍒嗛〉鏌ヨ + * @param page + * @param query + * @return + */ + IPage<PmsMaterialProcess> queryPageList(Page<PmsMaterialProcess> page, PmsMaterialProcess query); } diff --git a/src/main/java/org/jeecg/modules/pms/service/IPmsProcessBillMaterialsDetailService.java b/src/main/java/org/jeecg/modules/pms/service/IPmsProcessBillMaterialsDetailService.java index 3d0b428..4a5e867 100644 --- a/src/main/java/org/jeecg/modules/pms/service/IPmsProcessBillMaterialsDetailService.java +++ b/src/main/java/org/jeecg/modules/pms/service/IPmsProcessBillMaterialsDetailService.java @@ -1,11 +1,10 @@ package org.jeecg.modules.pms.service; -import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.service.IService; import org.jeecg.modules.pms.entity.PmsProcessBillMaterialsDetail; +import org.jeecg.modules.sap.dto.OrderBomDTO; -import javax.servlet.http.HttpServletRequest; -import java.util.Map; +import java.util.List; /** * @Description: 鐗╂枡娓呭崟 @@ -14,6 +13,18 @@ * @Version: V1.0 */ public interface IPmsProcessBillMaterialsDetailService extends IService<PmsProcessBillMaterialsDetail> { - PmsProcessBillMaterialsDetail queryByMaterialId(String materialId); - IPage<Map<String, Object>> getpmsProcessBillMaterialsDetailListData(Integer pageNo, Integer pageSize, HttpServletRequest req); + List<PmsProcessBillMaterialsDetail> queryByMaterialId(String materialId); + + /** + * 鍒犻櫎鍘熸湁鐨勬暟鎹� + * @param materialsId + */ + void removeByMaterialsId(String materialsId); + + /** + * 鎵归噺淇℃伅鐗╂枡娓呭崟鏄庣粏 + * @param materialsId + * @param collect + */ + void saveBatchDetail(String materialsId, List<OrderBomDTO> collect); } diff --git a/src/main/java/org/jeecg/modules/pms/service/IPmsProcessBillMaterialsService.java b/src/main/java/org/jeecg/modules/pms/service/IPmsProcessBillMaterialsService.java index cacfe51..8f4cfb3 100644 --- a/src/main/java/org/jeecg/modules/pms/service/IPmsProcessBillMaterialsService.java +++ b/src/main/java/org/jeecg/modules/pms/service/IPmsProcessBillMaterialsService.java @@ -1,10 +1,13 @@ package org.jeecg.modules.pms.service; import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.IService; +import org.jeecg.modules.mes.entity.MesProductionOrder; import org.jeecg.modules.pms.entity.PmsProcessBillMaterials; +import org.jeecg.modules.sap.dto.OrderBomDTO; -import javax.servlet.http.HttpServletRequest; +import java.util.List; import java.util.Map; /** @@ -14,5 +17,26 @@ * @Version: V1.0 */ public interface IPmsProcessBillMaterialsService extends IService<PmsProcessBillMaterials> { - IPage<Map<String, Object>> getpmsProcessBillMaterialsListData(Integer pageNo, Integer pageSize, HttpServletRequest req); + /** + * 鎵归噺淇濆瓨鎴栨洿鏂拌鍗旴OM鏁版嵁 + * @param orderMap + * @param orderBomDTOList + * @return + */ + boolean saveOrUpdateOrderBom(Map<String, MesProductionOrder> orderMap, List<OrderBomDTO> orderBomDTOList); + + /** + * 璁㈠崟鐗╂枡鏌ヨ + * @param orderId + * @return + */ + PmsProcessBillMaterials getByOrderId(String orderId); + + /** + * 鍒嗛〉鏌ヨ + * @param page + * @param query + * @return + */ + IPage<PmsProcessBillMaterials> queryPageList(Page<PmsProcessBillMaterials> page, PmsProcessBillMaterials query); } diff --git a/src/main/java/org/jeecg/modules/pms/service/impl/PmsMaterialProcessServiceImpl.java b/src/main/java/org/jeecg/modules/pms/service/impl/PmsMaterialProcessServiceImpl.java index 3629fc2..dfc6bee 100644 --- a/src/main/java/org/jeecg/modules/pms/service/impl/PmsMaterialProcessServiceImpl.java +++ b/src/main/java/org/jeecg/modules/pms/service/impl/PmsMaterialProcessServiceImpl.java @@ -1,43 +1,80 @@ package org.jeecg.modules.pms.service.impl; +import cn.hutool.core.collection.CollectionUtil; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang3.StringUtils; +import org.jeecg.modules.mes.entity.MesProductionOrder; import org.jeecg.modules.pms.entity.PmsMaterialProcess; import org.jeecg.modules.pms.mapper.PmsMaterialProcessMapper; import org.jeecg.modules.pms.service.IPmsMaterialProcessService; +import org.jeecg.modules.sap.dto.OrderProcessDTO; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; -import javax.servlet.http.HttpServletRequest; -import java.util.HashMap; +import java.util.List; import java.util.Map; +import java.util.stream.Collectors; /** * @Description: 鐗╂枡宸ュ簭 * @Author: jeecg-boot - * @Date: 2025-07-01 + * @Date: 2025-07-01 * @Version: V1.0 */ @Service public class PmsMaterialProcessServiceImpl extends ServiceImpl<PmsMaterialProcessMapper, PmsMaterialProcess> implements IPmsMaterialProcessService { @Override - public IPage<Map<String, Object>> getpmsMaterialProcessListData(Integer pageNo, Integer pageSize, HttpServletRequest req) { - IPage<Map> pageData = new Page<Map>(pageNo, pageSize); - Map<String, String> paramMap = new HashMap<String, String>(); - Map<String, String[]> parameterMap = req.getParameterMap(); - if (null != parameterMap) { - if (parameterMap.containsKey("materialNumber") && StringUtils.isNotBlank(parameterMap.get("materialNumber")[0])) { - paramMap.put("materialNumber", parameterMap.get("materialNumber")[0]); - } - if (parameterMap.containsKey("materialName") && StringUtils.isNotBlank(parameterMap.get("materialName")[0])) { - paramMap.put("materialName", parameterMap.get("materialName")[0].trim()); - } - if (parameterMap.containsKey("batchNumber") && StringUtils.isNotBlank(parameterMap.get("batchNumber")[0])) { - paramMap.put("batchNumber", parameterMap.get("batchNumber")[0].trim()); + @Transactional(rollbackFor = Exception.class) + public boolean saveOrUpdateOrderProcess(Map<String, MesProductionOrder> orderMap, List<OrderProcessDTO> orderProcessDTOList) { + for (Map.Entry<String, MesProductionOrder> entry : orderMap.entrySet()) { + MesProductionOrder order = entry.getValue(); + //鍒犻櫎鍘熸湁鐨勬暟鎹� + this.removeByOrderId(order.getId()); + //閲嶆柊鏂板宸ュ簭淇℃伅 + List<OrderProcessDTO> collect = orderProcessDTOList.stream().filter(orderProcessDTO -> entry.getKey().equals(orderProcessDTO.getAUFNR())).collect(Collectors.toList()); + if (CollectionUtil.isNotEmpty(collect)) { + List<PmsMaterialProcess> list = collect.stream().map(orderBomDTO -> new PmsMaterialProcess(order.getId(), order.getMaterialName(), orderBomDTO)).collect(Collectors.toList()); + super.saveBatch(list); } } - return super.getBaseMapper().getpmsMaterialProcessListData(pageData, paramMap); + return true; + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void removeByOrderId(String orderId) { + LambdaQueryWrapper<PmsMaterialProcess> queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(PmsMaterialProcess::getOrderId, orderId); + super.remove(queryWrapper); + } + + @Override + public IPage<PmsMaterialProcess> queryPageList(Page<PmsMaterialProcess> page, PmsMaterialProcess query) { + QueryWrapper<PmsMaterialProcess> queryWrapper = new QueryWrapper<>(); + queryWrapper.orderByDesc("pbm.create_time"); + if (query != null) { + //鐗╂枡缂栫爜 妯$硦鏌ヨ + if (org.apache.commons.lang3.StringUtils.isNotBlank(query.getMaterialNumber())) { + queryWrapper.like("pbm.material_number", query.getMaterialNumber()); + } + //鐗╂枡鍚嶇О 妯$硦鏌ヨ + if (org.apache.commons.lang3.StringUtils.isNotBlank(query.getMaterialName())) { + queryWrapper.like("pbm.material_name", query.getMaterialName()); + } + //宸ュ簭鍙� 妯$硦鏌ヨ + if (StringUtils.isNotBlank(query.getProcessCode())) { + queryWrapper.like("pbm.process_code", query.getProcessCode()); + } + //璁㈠崟鍙� 妯$硦鏌ヨ + if (StringUtils.isNotBlank(query.getOrderCode())) { + queryWrapper.like("po.order_code", query.getOrderCode()); + } + } + return this.getBaseMapper().queryPageList(page, queryWrapper); } } diff --git a/src/main/java/org/jeecg/modules/pms/service/impl/PmsProcessBillMaterialsDetailServiceImpl.java b/src/main/java/org/jeecg/modules/pms/service/impl/PmsProcessBillMaterialsDetailServiceImpl.java index 81fa739..d8480a8 100644 --- a/src/main/java/org/jeecg/modules/pms/service/impl/PmsProcessBillMaterialsDetailServiceImpl.java +++ b/src/main/java/org/jeecg/modules/pms/service/impl/PmsProcessBillMaterialsDetailServiceImpl.java @@ -1,48 +1,49 @@ package org.jeecg.modules.pms.service.impl; -import com.baomidou.mybatisplus.core.metadata.IPage; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import cn.hutool.core.collection.CollectionUtil; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import org.apache.commons.lang.StringUtils; import org.jeecg.modules.pms.entity.PmsProcessBillMaterialsDetail; import org.jeecg.modules.pms.mapper.PmsProcessBillMaterialsDetailMapper; import org.jeecg.modules.pms.service.IPmsProcessBillMaterialsDetailService; +import org.jeecg.modules.sap.dto.OrderBomDTO; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; -import javax.servlet.http.HttpServletRequest; -import java.util.HashMap; -import java.util.Map; +import java.util.List; +import java.util.stream.Collectors; /** * @Description: 鐗╂枡娓呭崟 * @Author: jeecg-boot - * @Date: 2025-07-01 + * @Date: 2025-07-01 * @Version: V1.0 */ @Service public class PmsProcessBillMaterialsDetailServiceImpl extends ServiceImpl<PmsProcessBillMaterialsDetailMapper, PmsProcessBillMaterialsDetail> implements IPmsProcessBillMaterialsDetailService { @Override - public PmsProcessBillMaterialsDetail queryByMaterialId(String materialId) { - return baseMapper.queryByMaterialId(materialId); + public List<PmsProcessBillMaterialsDetail> queryByMaterialId(String materialId) { + LambdaQueryWrapper<PmsProcessBillMaterialsDetail> queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(PmsProcessBillMaterialsDetail::getMaterialId, materialId); + return baseMapper.selectList(queryWrapper); } @Override - public IPage<Map<String, Object>> getpmsProcessBillMaterialsDetailListData(Integer pageNo, Integer pageSize, HttpServletRequest req) { - IPage<Map> pageData = new Page<Map>(pageNo, pageSize); - Map<String, String> paramMap = new HashMap<String, String>(); - Map<String, String[]> parameterMap = req.getParameterMap(); - if (null != parameterMap) { - if (parameterMap.containsKey("materialNumber") && StringUtils.isNotBlank(parameterMap.get("materialNumber")[0])) { - paramMap.put("materialNumber", parameterMap.get("materialNumber")[0]); - } - if (parameterMap.containsKey("materialName") && StringUtils.isNotBlank(parameterMap.get("materialName")[0])) { - paramMap.put("materialName", parameterMap.get("materialName")[0].trim()); - } - if (parameterMap.containsKey("batchNumber") && StringUtils.isNotBlank(parameterMap.get("batchNumber")[0])) { - paramMap.put("batchNumber", parameterMap.get("batchNumber")[0].trim()); - } + @Transactional(rollbackFor = Exception.class) + public void removeByMaterialsId(String materialsId) { + LambdaQueryWrapper<PmsProcessBillMaterialsDetail> queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(PmsProcessBillMaterialsDetail::getMaterialId, materialsId); + this.getBaseMapper().delete(queryWrapper); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void saveBatchDetail(String materialsId, List<OrderBomDTO> collect) { + if (CollectionUtil.isEmpty(collect)) { + return; } - return super.getBaseMapper().getpmsProcessBillMaterialsDetailListData(pageData, paramMap); + List<PmsProcessBillMaterialsDetail> list = collect.stream().map(orderBomDTO -> new PmsProcessBillMaterialsDetail(materialsId, orderBomDTO)).collect(Collectors.toList()); + super.saveBatch(list); } } diff --git a/src/main/java/org/jeecg/modules/pms/service/impl/PmsProcessBillMaterialsServiceImpl.java b/src/main/java/org/jeecg/modules/pms/service/impl/PmsProcessBillMaterialsServiceImpl.java index eda1def..ec90412 100644 --- a/src/main/java/org/jeecg/modules/pms/service/impl/PmsProcessBillMaterialsServiceImpl.java +++ b/src/main/java/org/jeecg/modules/pms/service/impl/PmsProcessBillMaterialsServiceImpl.java @@ -1,43 +1,101 @@ package org.jeecg.modules.pms.service.impl; +import cn.hutool.core.collection.CollectionUtil; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang3.StringUtils; +import org.jeecg.modules.mes.entity.MesProductionOrder; import org.jeecg.modules.pms.entity.PmsProcessBillMaterials; import org.jeecg.modules.pms.mapper.PmsProcessBillMaterialsMapper; +import org.jeecg.modules.pms.service.IPmsProcessBillMaterialsDetailService; import org.jeecg.modules.pms.service.IPmsProcessBillMaterialsService; +import org.jeecg.modules.sap.dto.OrderBomDTO; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; -import javax.servlet.http.HttpServletRequest; -import java.util.HashMap; +import java.util.List; import java.util.Map; +import java.util.stream.Collectors; /** * @Description: 璁㈠崟BOM * @Author: jeecg-boot - * @Date: 2025-07-01 + * @Date: 2025-07-01 * @Version: V1.0 */ @Service public class PmsProcessBillMaterialsServiceImpl extends ServiceImpl<PmsProcessBillMaterialsMapper, PmsProcessBillMaterials> implements IPmsProcessBillMaterialsService { + @Autowired + private IPmsProcessBillMaterialsDetailService processBillMaterialsDetailService; @Override - public IPage<Map<String, Object>> getpmsProcessBillMaterialsListData(Integer pageNo, Integer pageSize, HttpServletRequest req) { - IPage<Map> pageData = new Page<Map>(pageNo, pageSize); - Map<String, String> paramMap = new HashMap<String, String>(); - Map<String, String[]> parameterMap = req.getParameterMap(); - if (null != parameterMap) { - if (parameterMap.containsKey("materialNumber") && StringUtils.isNotBlank(parameterMap.get("materialNumber")[0])) { - paramMap.put("materialNumber", parameterMap.get("materialNumber")[0]); - } - if (parameterMap.containsKey("materialName") && StringUtils.isNotBlank(parameterMap.get("materialName")[0])) { - paramMap.put("materialName", parameterMap.get("materialName")[0].trim()); - } - if (parameterMap.containsKey("batchNumber") && StringUtils.isNotBlank(parameterMap.get("batchNumber")[0])) { - paramMap.put("batchNumber", parameterMap.get("batchNumber")[0].trim()); + @Transactional(rollbackFor = Exception.class) + public boolean saveOrUpdateOrderBom(Map<String, MesProductionOrder> orderMap, List<OrderBomDTO> orderBomDTOList) { + for (Map.Entry<String, MesProductionOrder> entry : orderMap.entrySet()) { + MesProductionOrder order = entry.getValue(); + PmsProcessBillMaterials materials = getByOrderId(order.getId()); + if (materials != null) { + //鏇存柊鐗╂枡鏁版嵁 + materials.setOrderId(order.getId()); + materials.setMaterialNumber(order.getMaterialNumber()); + materials.setMaterialName(order.getMaterialName()); + materials.setProductionUnit(order.getProductionUnit()); + materials.setProductionQuantity(order.getOrderQuantity()); + this.getBaseMapper().updateById(materials); + //鏇存柊鐗╂枡鏄庣粏鏁版嵁 + processBillMaterialsDetailService.removeByMaterialsId(materials.getId()); + //杩囨护鍑烘璁㈠崟鐨勭墿鏂欎俊鎭� + List<OrderBomDTO> collect = orderBomDTOList.stream().filter(orderBomDTO -> entry.getKey().equals(orderBomDTO.getAUFNR())).collect(Collectors.toList()); + processBillMaterialsDetailService.saveBatchDetail(materials.getId(), collect); + } else { + materials = new PmsProcessBillMaterials(); + materials.setOrderId(order.getId()); + materials.setMaterialNumber(order.getMaterialNumber()); + materials.setMaterialName(order.getMaterialName()); + materials.setProductionUnit(order.getProductionUnit()); + materials.setProductionQuantity(order.getOrderQuantity()); + this.getBaseMapper().insert(materials); + //杩囨护鍑烘璁㈠崟鐨勭墿鏂欎俊鎭� + List<OrderBomDTO> collect = orderBomDTOList.stream().filter(orderBomDTO -> entry.getKey().equals(orderBomDTO.getAUFNR())).collect(Collectors.toList()); + processBillMaterialsDetailService.saveBatchDetail(materials.getId(), collect); } } - return super.getBaseMapper().getpmsProcessBillMaterialsListData(pageData, paramMap); + return true; + } + + @Override + public PmsProcessBillMaterials getByOrderId(String orderId) { + LambdaQueryWrapper<PmsProcessBillMaterials> queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(PmsProcessBillMaterials::getOrderId, orderId); + List<PmsProcessBillMaterials> list = super.list(queryWrapper); + if (CollectionUtil.isNotEmpty(list)) { + return list.get(0); + } + return null; + } + + @Override + public IPage<PmsProcessBillMaterials> queryPageList(Page<PmsProcessBillMaterials> page, PmsProcessBillMaterials query) { + QueryWrapper<PmsProcessBillMaterials> queryWrapper = new QueryWrapper<>(); + queryWrapper.orderByDesc("pbm.create_time"); + if (query != null) { + //鐗╂枡缂栫爜 妯$硦鏌ヨ + if (StringUtils.isNotBlank(query.getMaterialNumber())) { + queryWrapper.like("pbm.material_number", query.getMaterialNumber()); + } + //鐗╂枡鍚嶇О 妯$硦鏌ヨ + if (StringUtils.isNotBlank(query.getMaterialName())) { + queryWrapper.like("pbm.material_name", query.getMaterialName()); + } + //璁㈠崟鍙� 妯$硦鏌ヨ + if (StringUtils.isNotBlank(query.getOrderCode())) { + queryWrapper.like("po.order_code", query.getOrderCode()); + } + } + return this.getBaseMapper().queryPageList(page, queryWrapper); } } diff --git a/src/main/java/org/jeecg/modules/sap/FunctionConst.java b/src/main/java/org/jeecg/modules/sap/FunctionConst.java index 3126ff1..68929c6 100644 --- a/src/main/java/org/jeecg/modules/sap/FunctionConst.java +++ b/src/main/java/org/jeecg/modules/sap/FunctionConst.java @@ -2,15 +2,15 @@ public class FunctionConst { //1.鐢熶骇璁㈠崟鍚屾鎺ュ彛 - public static String ZPPF_033_1 = "ZPPF_033_1"; + public static final String ZPPF_033_1 = "ZPPF_033_1"; //2.璁㈠崟BOM鍚屾鎺ュ彛 - public static String ZPPF_033_3 = "ZPPF_033_3"; + public static final String ZPPF_033_3 = "ZPPF_033_3"; //3.浜у搧宸ュ簭鍚屾鎺ュ彛 - public static String ZPPF_033_2 = "ZPPF_033_2"; + public static final String ZPPF_033_2 = "ZPPF_033_2"; //4.鐢熶骇璁㈠崟宸ュ簭鎶ュ伐鎺ュ彛銆佺敓浜ц鍗曞叆搴撱�佷笉鍚堟牸鍝佸鐞� - public static String ZMES_PRODORDCONF_CREATE_TT2301 = "ZMES_PRODORDCONF_CREATE_TT2301"; + public static final String ZMES_PRODORDCONF_CREATE_TT2301 = "ZMES_PRODORDCONF_CREATE_TT2301"; //5.鐢熶骇璁㈠崟鎶曟枡鎺ュ彛 - public static String ZMES_GOODSMVT_CREATE_2301 = "ZMES_GOODSMVT_CREATE_2301"; + public static final String ZMES_GOODSMVT_CREATE_2301 = "ZMES_GOODSMVT_CREATE_2301"; //6.鐢熶骇璁㈠崟鍏抽棴鎺ュ彛 - public static String ZPPF_019 = "ZPPF_019"; + public static final String ZPPF_019 = "ZPPF_019"; } diff --git a/src/main/java/org/jeecg/modules/sap/controller/SAPTestController.java b/src/main/java/org/jeecg/modules/sap/controller/SAPTestController.java index c51bd9c..02a0a63 100644 --- a/src/main/java/org/jeecg/modules/sap/controller/SAPTestController.java +++ b/src/main/java/org/jeecg/modules/sap/controller/SAPTestController.java @@ -4,34 +4,71 @@ import io.swagger.annotations.ApiOperation; import lombok.extern.slf4j.Slf4j; import org.jeecg.common.api.vo.Result; +import org.jeecg.modules.sap.service.OrderBomSync; +import org.jeecg.modules.sap.service.OrderProcessSync; import org.jeecg.modules.sap.service.ProductionOrderSync; -import org.jeecg.modules.sap.service.SAPService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; + +import java.util.Map; @Api(tags = "SAP闆嗘垚娴嬭瘯") @RestController @RequestMapping("/sap/client") @Slf4j public class SAPTestController { - @Autowired - private SAPService sapService; + //鏂扮伀鐐伐鍘傜紪鐮� + private static final String factoryCode = "2301"; + //鏍囧噯鐢熶骇璁㈠崟 + private static final String orderTypeCode1 = "Z001"; + //杩斿伐璁㈠崟 鏆傛椂涓嶇敤 + private static final String orderTypeCode2 = "Z002"; + //鍏垎鍘傝皟搴﹀憳 + // private static final String productionManager = "012"; + private static final String productionManager = "010"; + //鐢熶骇璁㈠崟鐘舵�� CRTD 鏂板缓锛孯EL 涓嬭揪锛孴ECO 鍏抽棴 瀹為檯涓婏紝鍙湁REL鐘舵�佺殑宸ュ崟鎵嶅彲浠ヨ繘琛屾搷浣� + private static final String orderStatus = "REL"; + + private static final String createTime = "20250508"; + private static final String updateTime = "20250101"; +// @Autowired +// private SAPService sapService; @Autowired private ProductionOrderSync productionOrderSync; + @Autowired + private OrderBomSync orderBomSync; + @Autowired + private OrderProcessSync orderProcessSync; - @ApiOperation(value = "SAP闆嗘垚娴嬭瘯-娴嬭瘯鎺ュ彛", notes = "SAP闆嗘垚娴嬭瘯-娴嬭瘯鎺ュ彛") - @GetMapping("/test") - public Result<?> test() { - String test = sapService.test(); - return Result.ok(test); +// @ApiOperation(value = "SAP闆嗘垚娴嬭瘯-娴嬭瘯鎺ュ彛", notes = "SAP闆嗘垚娴嬭瘯-娴嬭瘯鎺ュ彛") +// @GetMapping("/test") +// public Result<?> test() { +// String test = sapService.test(); +// return Result.ok(test); +// } + + @ApiOperation(value = "SAP闆嗘垚娴嬭瘯-鐢熶骇璁㈠崟鍚屾鎺ュ彛", notes = "SAP闆嗘垚娴嬭瘯-鐢熶骇璁㈠崟鍚屾鎺ュ彛") + @GetMapping("/syncProductionOrder") + public Result<?> syncProductionOrder() throws Exception { + Map<String, Object> resultMap = productionOrderSync.syncProductionOrder(factoryCode, orderTypeCode1, productionManager, orderStatus, null, null, null, null); + return Result.ok(resultMap); } - @ApiOperation(value = "SAP闆嗘垚娴嬭瘯-娴嬭瘯鎺ュ彛", notes = "SAP闆嗘垚娴嬭瘯-娴嬭瘯鎺ュ彛") - @GetMapping("/syncProductionOrder") - public Result<?> syncProductionOrder() { - productionOrderSync.syncProductionOrder(); - return Result.ok(); + @ApiOperation(value = "SAP闆嗘垚娴嬭瘯-璁㈠崟BOM鍚屾", notes = "SAP闆嗘垚娴嬭瘯-璁㈠崟BOM鍚屾") + @GetMapping("/syncOrderBom") + public Result<?> syncOrderBom() throws Exception { + String orderCode = "10706312,10706988,10708077,10708078,10708825,10711404,10711404,10711543"; + Map<String, Object> resultMap = orderBomSync.syncOrderBom(factoryCode, orderCode); + return Result.ok(resultMap); + } + + @ApiOperation(value = "SAP闆嗘垚娴嬭瘯-璁㈠崟宸ュ簭鍚屾", notes = "SAP闆嗘垚娴嬭瘯-璁㈠崟宸ュ簭鍚屾") + @GetMapping("/syncOrderProcess") + public Result<?> syncOrderProcess() throws Exception { + String orderCode = "10706312,10706988,10708077,10708078,10708825,10711404,10711404,10711543"; + Map<String, Object> resultMap = orderProcessSync.syncOrderProcess(factoryCode, orderCode); + return Result.ok(resultMap); } } diff --git a/src/main/java/org/jeecg/modules/sap/dto/OrderBomDTO.java b/src/main/java/org/jeecg/modules/sap/dto/OrderBomDTO.java new file mode 100644 index 0000000..7cb84b2 --- /dev/null +++ b/src/main/java/org/jeecg/modules/sap/dto/OrderBomDTO.java @@ -0,0 +1,19 @@ +package org.jeecg.modules.sap.dto; + +import lombok.Data; + +@Data +public class OrderBomDTO { + /** 璁㈠崟鍙� */ + private String AUFNR; + /** 鐗╂枡鍙� */ + private String MATNR; + /** 宸ュ巶缂栧彿 */ + private String WERKS; + /** 鐗╂枡鎻忚堪锛堢煭鏂囨湰锛� */ + private String MAKTX; + /** 闇�姹傞噺 */ + private String BDMNG; + /** 鍩烘湰璁¢噺鍗曚綅 */ + private String MEINS; +} diff --git a/src/main/java/org/jeecg/modules/sap/dto/OrderProcessDTO.java b/src/main/java/org/jeecg/modules/sap/dto/OrderProcessDTO.java new file mode 100644 index 0000000..a0b59a5 --- /dev/null +++ b/src/main/java/org/jeecg/modules/sap/dto/OrderProcessDTO.java @@ -0,0 +1,20 @@ +package org.jeecg.modules.sap.dto; + +import lombok.Data; + +@Data +public class OrderProcessDTO { + /** 璁㈠崟鍙� */ + private String AUFNR; + /** 鐗╂枡鍙� */ + private String MATNR; + /** 鎿嶄綔/娲诲姩缂栧彿 */ + private String VORNR; + /** 宸ュ簭鐭枃鏈� */ + private String LTXA1; + /** 宸ュ巶 */ + private String WERKS; + /** 鎺у埗鐮� */ + private String STEUS; + +} diff --git a/src/main/java/org/jeecg/modules/sap/service/OrderBomSync.java b/src/main/java/org/jeecg/modules/sap/service/OrderBomSync.java new file mode 100644 index 0000000..d2b7403 --- /dev/null +++ b/src/main/java/org/jeecg/modules/sap/service/OrderBomSync.java @@ -0,0 +1,12 @@ +package org.jeecg.modules.sap.service; + +import java.util.Map; + +public interface OrderBomSync { + /** + * 鍚屾璁㈠崟BOM鏁版嵁 + * @return + * @throws Exception + */ + Map<String, Object> syncOrderBom(String factoryCode, String orderCode) throws Exception; +} diff --git a/src/main/java/org/jeecg/modules/sap/service/OrderProcessSync.java b/src/main/java/org/jeecg/modules/sap/service/OrderProcessSync.java new file mode 100644 index 0000000..1741685 --- /dev/null +++ b/src/main/java/org/jeecg/modules/sap/service/OrderProcessSync.java @@ -0,0 +1,12 @@ +package org.jeecg.modules.sap.service; + +import java.util.Map; + +public interface OrderProcessSync { + /** + * 鍚屾璁㈠崟宸ュ簭鏁版嵁 + * @return + * @throws Exception + */ + Map<String, Object> syncOrderProcess(String factoryCode, String orderCode) throws Exception; +} diff --git a/src/main/java/org/jeecg/modules/sap/service/ProductionOrderSync.java b/src/main/java/org/jeecg/modules/sap/service/ProductionOrderSync.java index 8373a02..52995cb 100644 --- a/src/main/java/org/jeecg/modules/sap/service/ProductionOrderSync.java +++ b/src/main/java/org/jeecg/modules/sap/service/ProductionOrderSync.java @@ -1,8 +1,10 @@ package org.jeecg.modules.sap.service; +import java.util.Map; + public interface ProductionOrderSync { /** * 鍚屾鐢熸垚璁㈠崟 */ - void syncProductionOrder(); + Map<String, Object> syncProductionOrder(String factoryCode, String orderTypeCode, String productionManager, String orderStatus, String createTimeLow, String createTimeHigh, String updateTimeLow, String updateTimeHigh) throws Exception; } diff --git a/src/main/java/org/jeecg/modules/sap/service/SAPService.java b/src/main/java/org/jeecg/modules/sap/service/SAPService.java deleted file mode 100644 index d8bd863..0000000 --- a/src/main/java/org/jeecg/modules/sap/service/SAPService.java +++ /dev/null @@ -1,5 +0,0 @@ -package org.jeecg.modules.sap.service; - -public interface SAPService { - String test(); -} diff --git a/src/main/java/org/jeecg/modules/sap/service/impl/OrderBomSyncImpl.java b/src/main/java/org/jeecg/modules/sap/service/impl/OrderBomSyncImpl.java new file mode 100644 index 0000000..ce7531d --- /dev/null +++ b/src/main/java/org/jeecg/modules/sap/service/impl/OrderBomSyncImpl.java @@ -0,0 +1,91 @@ +package org.jeecg.modules.sap.service.impl; + +import com.alibaba.fastjson.JSONObject; +import com.sap.conn.jco.*; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import org.jeecg.common.aspect.annotation.ApiLog; +import org.jeecg.common.constant.ApiLogCategoryEnum; +import org.jeecg.config.sap.SapRfcConnectionManager; +import org.jeecg.modules.sap.FunctionConst; +import org.jeecg.modules.sap.dto.OrderBomDTO; +import org.jeecg.modules.sap.service.OrderBomSync; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +@Service +@Slf4j +public class OrderBomSyncImpl implements OrderBomSync { + @Autowired + private SapRfcConnectionManager connectionManager; + + @Override + @ApiLog(apiName = "璁㈠崟BOM鍚屾(ZPPF_033_3)", apiCategory = ApiLogCategoryEnum.SAP) + public Map<String, Object> syncOrderBom(String factoryCode, String orderCode) throws Exception { + Map<String, Object> resultMap = new HashMap<>(); + JCoDestination destination = connectionManager.getDestination(); + JCoRepository repository = destination.getRepository(); + JCoFunction function = repository.getFunction(FunctionConst.ZPPF_033_3); + if (function == null) { + throw new RuntimeException("RFC 鍑芥暟 ZPPF_033_3 鏈壘鍒帮紒"); + } + // 璁剧疆杈撳叆鍙傛暟 + List<JSONObject> items = new ArrayList<>(); + if(StringUtils.isNotBlank(factoryCode)){ + //鏂扮伀鐐� + JCoParameterList importParameterList = function.getImportParameterList(); + importParameterList.setValue("WERKS", factoryCode); + //缁勮璇锋眰鍙傛暟 + JSONObject item = new JSONObject(); + item.put("WERKS", factoryCode); + items.add(item); + } + if(StringUtils.isNotBlank(orderCode)) { + //鏂扮伀鐐� + JCoTable AUFNRTable = function.getTableParameterList().getTable("ZTAB_AUFNR"); + String[] split = orderCode.split(","); + for(String code : split){ + AUFNRTable.appendRow(); + AUFNRTable.setValue("AUFNR", code); + } + //缁勮璇锋眰鍙傛暟 + JSONObject item = new JSONObject(); + item.put("AUFNR", orderCode); + items.add(item); + } + // 鎵ц璋冪敤 + function.execute(destination); + //鑾峰彇杩斿洖缁撴灉 + String zmess = function.getExportParameterList().getValue("ZMESS").toString(); + String ztype = function.getExportParameterList().getValue("ZTYPE").toString();//S 鏍囪瘑 鎴愬姛 + // 鑾峰彇杈撳嚭鍙傛暟 + JCoTable outputTable = function.getTableParameterList().getTable("ZTAB_OUT"); + int numRows = outputTable.getNumRows(); + List<OrderBomDTO> resultList = new ArrayList<>(); + OrderBomDTO dto; + for (int i = 0; i < numRows; i++) { + outputTable.setRow(i); + dto = new OrderBomDTO(); + dto.setAUFNR(outputTable.getString("AUFNR")); + dto.setMATNR(outputTable.getString("MATNR")); + dto.setWERKS(outputTable.getString("WERKS")); + dto.setMAKTX(outputTable.getString("MAKTX")); + dto.setBDMNG(outputTable.getString("BDMNG")); + dto.setMEINS(outputTable.getString("MEINS")); + + //娣诲姞缁撴灉闆� + resultList.add(dto); + log.info(dto.toString()); + } + resultMap.put("zmess", zmess); + resultMap.put("ztype", ztype); + resultMap.put("importParameters", items); + resultMap.put("result", resultList); + return resultMap; + } +} diff --git a/src/main/java/org/jeecg/modules/sap/service/impl/OrderProcessSyncImpl.java b/src/main/java/org/jeecg/modules/sap/service/impl/OrderProcessSyncImpl.java new file mode 100644 index 0000000..2fdd666 --- /dev/null +++ b/src/main/java/org/jeecg/modules/sap/service/impl/OrderProcessSyncImpl.java @@ -0,0 +1,93 @@ +package org.jeecg.modules.sap.service.impl; + +import com.alibaba.fastjson.JSONObject; +import com.sap.conn.jco.*; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import org.jeecg.common.aspect.annotation.ApiLog; +import org.jeecg.common.constant.ApiLogCategoryEnum; +import org.jeecg.config.sap.SapRfcConnectionManager; +import org.jeecg.modules.sap.FunctionConst; +import org.jeecg.modules.sap.dto.OrderBomDTO; +import org.jeecg.modules.sap.dto.OrderProcessDTO; +import org.jeecg.modules.sap.service.OrderProcessSync; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.*; + +@Service +@Slf4j +public class OrderProcessSyncImpl implements OrderProcessSync { + @Autowired + private SapRfcConnectionManager connectionManager; + + @Override + @ApiLog(apiName = "浜у搧宸ヨ壓璺嚎鍚屾(ZPPF_033_2)", apiCategory = ApiLogCategoryEnum.SAP) + public Map<String, Object> syncOrderProcess(String factoryCode, String orderCode) throws Exception { + Map<String, Object> resultMap = new HashMap<>(); + JCoDestination destination = connectionManager.getDestination(); + JCoRepository repository = destination.getRepository(); + JCoFunction function = repository.getFunction(FunctionConst.ZPPF_033_2); + if (function == null) { + throw new RuntimeException("RFC 鍑芥暟 ZPPF_033_2 鏈壘鍒帮紒"); + } + // 璁剧疆杈撳叆鍙傛暟 + List<JSONObject> items = new ArrayList<>(); + if(StringUtils.isNotBlank(factoryCode)){ + //鏂扮伀鐐� + JCoTable WERKSTable = function.getTableParameterList().getTable("ZTAB_WERKS"); + String[] split = factoryCode.split(","); + for(String code : split){ + WERKSTable.appendRow(); + WERKSTable.setValue("WERKS", code); + } + //缁勮璇锋眰鍙傛暟 + JSONObject item = new JSONObject(); + item.put("WERKS", factoryCode); + items.add(item); + } + if(StringUtils.isNotBlank(orderCode)) { + //鏂扮伀鐐� + JCoTable AUFNRTable = function.getTableParameterList().getTable("ZTAB_AUFNR"); + String[] split = orderCode.split(","); + for(String code : split){ + AUFNRTable.appendRow(); + AUFNRTable.setValue("AUFNR", code); + } + //缁勮璇锋眰鍙傛暟 + JSONObject item = new JSONObject(); + item.put("AUFNR", orderCode); + items.add(item); + } + // 鎵ц璋冪敤 + function.execute(destination); + //鑾峰彇杩斿洖缁撴灉 + String zmess = function.getExportParameterList().getValue("ZMESS").toString(); + String ztype = function.getExportParameterList().getValue("ZTYPE").toString();//S 鏍囪瘑 鎴愬姛 + // 鑾峰彇杈撳嚭鍙傛暟 + JCoTable outputTable = function.getTableParameterList().getTable("ZTAB_OUT"); + int numRows = outputTable.getNumRows(); + List<OrderProcessDTO> resultList = new ArrayList<>(); + OrderProcessDTO dto; + for (int i = 0; i < numRows; i++) { + outputTable.setRow(i); + dto = new OrderProcessDTO(); + dto.setAUFNR(outputTable.getString("AUFNR")); + dto.setMATNR(outputTable.getString("MATNR")); + dto.setWERKS(outputTable.getString("WERKS")); + dto.setVORNR(outputTable.getString("VORNR")); + dto.setLTXA1(outputTable.getString("LTXA1")); + dto.setSTEUS(outputTable.getString("STEUS")); + + //娣诲姞缁撴灉闆� + resultList.add(dto); + log.info(dto.toString()); + } + resultMap.put("zmess", zmess); + resultMap.put("ztype", ztype); + resultMap.put("importParameters", items); + resultMap.put("result", resultList); + return resultMap; + } +} diff --git a/src/main/java/org/jeecg/modules/sap/service/impl/ProductionOrderSyncImpl.java b/src/main/java/org/jeecg/modules/sap/service/impl/ProductionOrderSyncImpl.java index ed2c10b..960a8c4 100644 --- a/src/main/java/org/jeecg/modules/sap/service/impl/ProductionOrderSyncImpl.java +++ b/src/main/java/org/jeecg/modules/sap/service/impl/ProductionOrderSyncImpl.java @@ -1,7 +1,14 @@ package org.jeecg.modules.sap.service.impl; -import com.sap.conn.jco.*; +import com.alibaba.fastjson.JSONObject; +import com.sap.conn.jco.JCoDestination; +import com.sap.conn.jco.JCoFunction; +import com.sap.conn.jco.JCoRepository; +import com.sap.conn.jco.JCoTable; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import org.jeecg.common.aspect.annotation.ApiLog; +import org.jeecg.common.constant.ApiLogCategoryEnum; import org.jeecg.config.sap.SapRfcConnectionManager; import org.jeecg.modules.sap.FunctionConst; import org.jeecg.modules.sap.dto.ProductionOrderDTO; @@ -10,7 +17,9 @@ import org.springframework.stereotype.Service; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; +import java.util.Map; /** * 鐢熸垚璁㈠崟鍚屾鏈嶅姟 @@ -18,98 +27,157 @@ @Service @Slf4j public class ProductionOrderSyncImpl implements ProductionOrderSync { - //鏂扮伀鐐伐鍘傜紪鐮� - private static final String factoryCode = "2301"; - //鏍囧噯鐢熶骇璁㈠崟 - private static final String orderTypeCode1 = "Z001"; - //杩斿伐璁㈠崟 鏆傛椂涓嶇敤 - private static final String orderTypeCode2 = "Z002"; - //鍏垎鍘傝皟搴﹀憳 -// private static final String productionManager = "012"; - private static final String productionManager = "010"; - //鐢熶骇璁㈠崟鐘舵�� CRTD 鏂板缓锛孯EL 涓嬭揪锛孴ECO 鍏抽棴 瀹為檯涓婏紝鍙湁REL鐘舵�佺殑宸ュ崟鎵嶅彲浠ヨ繘琛屾搷浣� - private static final String orderStatus = "REL"; @Autowired private SapRfcConnectionManager connectionManager; - @Override - public void syncProductionOrder() { + @ApiLog(apiName = "鐢熶骇璁㈠崟鍚屾(ZPPF_033_1)", apiCategory = ApiLogCategoryEnum.SAP) + public Map<String, Object> syncProductionOrder(String factoryCode, String orderTypeCode, String productionManager, String orderStatus, String createTimeLow, String createTimeHigh, String updateTimeLow, String updateTimeHigh) throws Exception { + Map<String, Object> resultMap = new HashMap<>(); JCoDestination destination = connectionManager.getDestination(); - try { - JCoRepository repository = destination.getRepository(); - JCoFunction function = repository.getFunction(FunctionConst.ZPPF_033_1); - if (function == null) { - throw new RuntimeException("RFC 鍑芥暟 ZPPF_033_1 鏈壘鍒帮紒"); - } - // 璁剧疆杈撳叆鍙傛暟 - //璁㈠崟鍙锋煡璇㈡潯浠� + JCoRepository repository = destination.getRepository(); + JCoFunction function = repository.getFunction(FunctionConst.ZPPF_033_1); + if (function == null) { + throw new RuntimeException("RFC 鍑芥暟 ZPPF_033_1 鏈壘鍒帮紒"); + } + // 璁剧疆杈撳叆鍙傛暟 + //璁㈠崟鍙锋煡璇㈡潯浠� // JCoTable AUFNRTable = function.getTableParameterList().getTable("ZTAB_AUFNR"); - //璁㈠崟绫诲瀷 鏍囧噯鐢熶骇璁㈠崟 + List<JSONObject> items = new ArrayList<>(); + //璁㈠崟绫诲瀷 鏍囧噯鐢熶骇璁㈠崟 + if(StringUtils.isNotBlank(orderTypeCode)){ JCoTable AUARTTable = function.getTableParameterList().getTable("ZTAB_AUART"); - AUARTTable.appendRow(); - AUARTTable.setValue("AUART", orderTypeCode1); - //鍏垎鍘傝皟搴� + String[] split = orderTypeCode.split(","); + for(String code : split){ + AUARTTable.appendRow(); + AUARTTable.setValue("AUART", code); + } + //缁勮璇锋眰鍙傛暟 + JSONObject item = new JSONObject(); + item.put("AUART", orderTypeCode); + items.add(item); + } + if(StringUtils.isNotBlank(productionManager)){ JCoTable FEVORTable = function.getTableParameterList().getTable("ZTAB_FEVOR"); - FEVORTable.appendRow(); - FEVORTable.setValue("FEVOR", productionManager); + String[] split = productionManager.split(","); + for(String code : split){ + FEVORTable.appendRow(); + FEVORTable.setValue("FEVOR", code); + } + //缁勮璇锋眰鍙傛暟 + JSONObject item = new JSONObject(); + item.put("FEVOR", productionManager); + items.add(item); + } + if(StringUtils.isNotBlank(factoryCode)){ //鏂扮伀鐐� JCoTable WERKSTable = function.getTableParameterList().getTable("ZTAB_WERKS"); - WERKSTable.appendRow(); - WERKSTable.setValue("WERKS", factoryCode); - //璁㈠崟鐘舵�� - JCoTable TXT04Table = function.getTableParameterList().getTable("ZTAB_TXT04"); - TXT04Table.appendRow(); - TXT04Table.setValue("TXT04", orderStatus); - // 鎵ц璋冪敤 - function.execute(destination); - //鑾峰彇杩斿洖缁撴灉 - String zmess = function.getExportParameterList().getValue("ZMESS").toString(); - String ztype = function.getExportParameterList().getValue("ZTYPE").toString();//S 鏍囪瘑 鎴愬姛 - if(!"S".equals(ztype)){ - log.error("鑾峰彇璁㈠崟淇℃伅澶辫触锛孼TYPE={}, ZMESS={}", ztype, zmess); - return; + String[] split = factoryCode.split(","); + for(String code : split){ + WERKSTable.appendRow(); + WERKSTable.setValue("WERKS", code); } - // 鑾峰彇杈撳嚭鍙傛暟 - JCoTable outputTable = function.getTableParameterList().getTable("ZTAB_OUT"); - int numRows = outputTable.getNumRows(); - List<ProductionOrderDTO> resultList = new ArrayList<>(); - ProductionOrderDTO dto; - for (int i = 0; i < numRows; i++) { - outputTable.setRow(i); - dto = new ProductionOrderDTO(); - dto.setKDPOS(outputTable.getString("KDPOS")); - dto.setCHARG(outputTable.getString("CHARG")); - dto.setMAKTX(outputTable.getString("MAKTX")); - dto.setMATNR(outputTable.getString("MATNR")); - dto.setKDAUF(outputTable.getString("KDAUF")); - dto.setAUFNR(outputTable.getString("AUFNR")); - dto.setDAUAT(outputTable.getString("DAUAT")); - dto.setGAMNG(outputTable.getString("GAMNG")); - dto.setGMEIN(outputTable.getString("GMEIN")); - dto.setAPRIO(outputTable.getString("APRIO")); - dto.setAUFPL(outputTable.getString("AUFPL")); - dto.setSTLNR(outputTable.getString("STLNR")); - dto.setDWERK(outputTable.getString("DWERK")); - dto.setNAME1(outputTable.getString("NAME1")); - dto.setFEVOR(outputTable.getString("FEVOR")); - dto.setTXT(outputTable.getString("TXT")); - dto.setUSNAM(outputTable.getString("USNAM")); - dto.setUDATE(outputTable.getString("UDATE")); - dto.setLAEDA(outputTable.getString("LAEDA")); - dto.setTIMES(outputTable.getString("TIMES")); - dto.setTXT04(outputTable.getString("TXT04")); - dto.setTXT30(outputTable.getString("TXT30")); - dto.setGSTRP(outputTable.getString("GSTRP")); - dto.setGLTRP(outputTable.getString("GLTRP")); - - //娣诲姞缁撴灉闆� - resultList.add(dto); - log.info(dto.toString()); - } - } catch (JCoException e) { - log.error(e.getMessage(), e); + //缁勮璇锋眰鍙傛暟 + JSONObject item = new JSONObject(); + item.put("WERKS", factoryCode); + items.add(item); } + if(StringUtils.isNotBlank(orderStatus)) { + //鏂扮伀鐐� + JCoTable TXT04Table = function.getTableParameterList().getTable("ZTAB_TXT04"); + String[] split = orderStatus.split(","); + for(String code : split){ + TXT04Table.appendRow(); + TXT04Table.setValue("TXT04", code); + } + //缁勮璇锋眰鍙傛暟 + JSONObject item = new JSONObject(); + item.put("TXT04", orderStatus); + items.add(item); + } + if(StringUtils.isNotBlank(createTimeLow)){ + JCoTable UDATETable = function.getTableParameterList().getTable("ZTAB_UDATE"); + UDATETable.appendRow(); + UDATETable.setValue("LOW", createTimeLow); + //缁勮璇锋眰鍙傛暟 + JSONObject item = new JSONObject(); + item.put("ZTAB_UDATE_LOW", createTimeLow); + items.add(item); + } + if(StringUtils.isNotBlank(createTimeHigh)){ + JCoTable UDATETable = function.getTableParameterList().getTable("ZTAB_UDATE"); + UDATETable.appendRow(); + UDATETable.setValue("HIGH", createTimeHigh); + //缁勮璇锋眰鍙傛暟 + JSONObject item = new JSONObject(); + item.put("ZTAB_UDATE_HIGH", createTimeHigh); + items.add(item); + } + if(StringUtils.isNotBlank(updateTimeLow)){ + JCoTable LAEDATable = function.getTableParameterList().getTable("ZTAB_LAEDA"); + LAEDATable.appendRow(); + LAEDATable.setValue("LOW", updateTimeLow); + //缁勮璇锋眰鍙傛暟 + JSONObject item = new JSONObject(); + item.put("ZTAB_LAEDA_LOW", updateTimeLow); + items.add(item); + } + if(StringUtils.isNotBlank(updateTimeHigh)){ + JCoTable LAEDATable = function.getTableParameterList().getTable("ZTAB_LAEDA"); + LAEDATable.appendRow(); + LAEDATable.setValue("HIGH", updateTimeLow); + //缁勮璇锋眰鍙傛暟 + JSONObject item = new JSONObject(); + item.put("ZTAB_LAEDA_HIGH", updateTimeLow); + items.add(item); + } + // 鎵ц璋冪敤 + function.execute(destination); + //鑾峰彇杩斿洖缁撴灉 + String zmess = function.getExportParameterList().getValue("ZMESS").toString(); + String ztype = function.getExportParameterList().getValue("ZTYPE").toString();//S 鏍囪瘑 鎴愬姛 + // 鑾峰彇杈撳嚭鍙傛暟 + JCoTable outputTable = function.getTableParameterList().getTable("ZTAB_OUT"); + int numRows = outputTable.getNumRows(); + List<ProductionOrderDTO> resultList = new ArrayList<>(); + ProductionOrderDTO dto; + for (int i = 0; i < numRows; i++) { + outputTable.setRow(i); + dto = new ProductionOrderDTO(); + dto.setKDPOS(outputTable.getString("KDPOS")); + dto.setCHARG(outputTable.getString("CHARG")); + dto.setMAKTX(outputTable.getString("MAKTX")); + dto.setMATNR(outputTable.getString("MATNR")); + dto.setKDAUF(outputTable.getString("KDAUF")); + dto.setAUFNR(outputTable.getString("AUFNR")); + dto.setDAUAT(outputTable.getString("DAUAT")); + dto.setGAMNG(outputTable.getString("GAMNG")); + dto.setGMEIN(outputTable.getString("GMEIN")); + dto.setAPRIO(outputTable.getString("APRIO")); + dto.setAUFPL(outputTable.getString("AUFPL")); + dto.setSTLNR(outputTable.getString("STLNR")); + dto.setDWERK(outputTable.getString("DWERK")); + dto.setNAME1(outputTable.getString("NAME1")); + dto.setFEVOR(outputTable.getString("FEVOR")); + dto.setTXT(outputTable.getString("TXT")); + dto.setUSNAM(outputTable.getString("USNAM")); + dto.setUDATE(outputTable.getString("UDATE")); + dto.setLAEDA(outputTable.getString("LAEDA")); + dto.setTIMES(outputTable.getString("TIMES")); + dto.setTXT04(outputTable.getString("TXT04")); + dto.setTXT30(outputTable.getString("TXT30")); + dto.setGSTRP(outputTable.getString("GSTRP")); + dto.setGLTRP(outputTable.getString("GLTRP")); + + //娣诲姞缁撴灉闆� + resultList.add(dto); + log.info(dto.toString()); + } + resultMap.put("zmess", zmess); + resultMap.put("ztype", ztype); + resultMap.put("importParameters", items); + resultMap.put("result", resultList); + return resultMap; } } diff --git a/src/main/java/org/jeecg/modules/sap/service/impl/SAPServiceImpl.java b/src/main/java/org/jeecg/modules/sap/service/impl/SAPServiceImpl.java deleted file mode 100644 index db1a753..0000000 --- a/src/main/java/org/jeecg/modules/sap/service/impl/SAPServiceImpl.java +++ /dev/null @@ -1,53 +0,0 @@ -package org.jeecg.modules.sap.service.impl; - -import com.sap.conn.jco.*; -import lombok.SneakyThrows; -import lombok.extern.slf4j.Slf4j; -import org.jeecg.config.sap.SapRfcConnectionManager; -import org.jeecg.modules.sap.service.SAPService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import java.util.Arrays; -import java.util.Collections; - -@Service -@Slf4j -public class SAPServiceImpl implements SAPService { - @Autowired - private SapRfcConnectionManager connectionManager; - - @Override - public String test() { - JCoDestination destination = connectionManager.getDestination(); - try { - JCoRepository repository = destination.getRepository(); - JCoFunction function = repository.getFunction("ZPPF_022"); - - if (function == null) { - throw new RuntimeException("RFC 鍑芥暟妯″潡 ZPPF_022 鏈壘鍒帮紒"); - } - - // 璁剧疆杈撳叆鍙傛暟 - JCoTable inputTable = function.getTableParameterList().getTable("ZTAB_WERKS"); - inputTable.appendRow(); - inputTable.setValue("WERKS", "2301"); //鍙傛暟鍚嶉渶涓� SAP 鍑芥暟瀹氫箟涓�鑷� - - // 鎵ц璋冪敤 - function.execute(destination); - - // 鑾峰彇杈撳嚭鍙傛暟 - JCoTable outputTable = function.getTableParameterList().getTable("ZTAB_AUFNR"); - int numRows = outputTable.getNumRows(); - for (int i = 0; i < numRows; i++) { - outputTable.setRow(i); - log.info("Row {} : {}", i, outputTable.getString("AUFNR")); - } - - return String.valueOf(numRows); - } catch (JCoException e) { - log.error(e.getMessage(), e); - } - return null; - } -} diff --git a/src/main/java/org/jeecg/modules/system/controller/SysApiLogController.java b/src/main/java/org/jeecg/modules/system/controller/SysApiLogController.java new file mode 100644 index 0000000..588d41d --- /dev/null +++ b/src/main/java/org/jeecg/modules/system/controller/SysApiLogController.java @@ -0,0 +1,58 @@ +package org.jeecg.modules.system.controller; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.extern.slf4j.Slf4j; +import org.jeecg.common.api.vo.Result; +import org.jeecg.common.aspect.annotation.AutoLog; +import org.jeecg.common.system.base.controller.JeecgController; +import org.jeecg.common.system.query.QueryGenerator; +import org.jeecg.modules.system.entity.SysApiLog; +import org.jeecg.modules.system.service.ISysApiLogService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +import javax.servlet.http.HttpServletRequest; + + /** + * @Description: 绯荤粺绗笁鏂归泦鎴愭帴鍙f棩蹇� + * @Author: jeecg-boot + * @Date: 2025-07-30 + * @Version: V1.0 + */ +@Slf4j +@Api(tags="绯荤粺绗笁鏂归泦鎴愭帴鍙f棩蹇�") +@RestController +@RequestMapping("/system/sysApiLog") +public class SysApiLogController extends JeecgController<SysApiLog, ISysApiLogService> { + @Autowired + private ISysApiLogService sysApiLogService; + + /** + * 鍒嗛〉鍒楄〃鏌ヨ + * + * @param sysApiLog + * @param pageNo + * @param pageSize + * @param req + * @return + */ + @AutoLog(value = "绯荤粺绗笁鏂归泦鎴愭帴鍙f棩蹇�-鍒嗛〉鍒楄〃鏌ヨ") + @ApiOperation(value="绯荤粺绗笁鏂归泦鎴愭帴鍙f棩蹇�-鍒嗛〉鍒楄〃鏌ヨ", notes="绯荤粺绗笁鏂归泦鎴愭帴鍙f棩蹇�-鍒嗛〉鍒楄〃鏌ヨ") + @GetMapping(value = "/list") + public Result<?> queryPageList(SysApiLog sysApiLog, + @RequestParam(name="pageNo", defaultValue="1") Integer pageNo, + @RequestParam(name="pageSize", defaultValue="10") Integer pageSize, + HttpServletRequest req) { + QueryWrapper<SysApiLog> queryWrapper = QueryGenerator.initQueryWrapper(sysApiLog, req.getParameterMap()); + Page<SysApiLog> page = new Page<SysApiLog>(pageNo, pageSize); + IPage<SysApiLog> pageList = sysApiLogService.page(page, queryWrapper); + return Result.OK(pageList); + } +} diff --git a/src/main/java/org/jeecg/modules/system/controller/SysUserController.java b/src/main/java/org/jeecg/modules/system/controller/SysUserController.java index ee03b35..d0ff657 100644 --- a/src/main/java/org/jeecg/modules/system/controller/SysUserController.java +++ b/src/main/java/org/jeecg/modules/system/controller/SysUserController.java @@ -12,7 +12,6 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; -import liquibase.pro.packaged.I; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang.StringUtils; import org.apache.shiro.SecurityUtils; @@ -31,8 +30,6 @@ import org.jeecg.modules.base.service.BaseCommonService; import org.jeecg.modules.base.service.IUserFactoryService; import org.jeecg.modules.base.service.IUserGroupService; -import org.jeecg.modules.mdc.model.ProductionIdModel; -import org.jeecg.modules.mdc.service.IMdcUserProductionService; import org.jeecg.modules.system.entity.*; import org.jeecg.modules.system.model.DepartIdModel; import org.jeecg.modules.base.model.FactoryIdModel; @@ -108,8 +105,8 @@ @Resource private IUserFactoryService userFactoryService; - @Resource - private IMdcUserProductionService userProductionService; +// @Resource +// private IMdcUserProductionService userProductionService; @Resource private IUserGroupService userGroupService; @@ -253,7 +250,7 @@ Result<SysUser> result = new Result<SysUser>(); String selectedRoles = jsonObject.getString("selectedroles"); String selectedDeparts = jsonObject.getString("selecteddeparts"); - String selectedProductions = jsonObject.getString("selectedProduction"); + String selectedProductions = jsonObject.getString("selectedFactorys"); try { SysUser user = JSON.parseObject(jsonObject.toJSONString(), SysUser.class); user.setCreateTime(new Date());//璁剧疆鍒涘缓鏃堕棿 @@ -295,7 +292,7 @@ user.setPassword(sysUser.getPassword()); String roles = jsonObject.getString("selectedroles"); String departs = jsonObject.getString("selecteddeparts"); - String productions = jsonObject.getString("selectedProduction"); + String productions = jsonObject.getString("selectedFactorys"); if (oConvertUtils.isEmpty(departs)) { //vue3.0鍓嶇鍙紶閫掍簡departIds departs = user.getDepartIds(); @@ -476,17 +473,17 @@ } - @AutoLog(value = "鐢ㄦ埛琛�-鏌ヨ鎸囧畾鐢ㄦ埛鍜屼骇绾垮叧鑱旂殑鏁版嵁") - @ApiOperation(value = "鐢ㄦ埛琛�-鏌ヨ鎸囧畾鐢ㄦ埛鍜屼骇绾垮叧鑱旂殑鏁版嵁", notes = "鐢ㄦ埛琛�-鏌ヨ鎸囧畾鐢ㄦ埛鍜屼骇绾垮叧鑱旂殑鏁版嵁") - @GetMapping(value = "/userProductionList") - public Result<List<ProductionIdModel>> getUserProductionsList(@RequestParam(name = "userId", required = true) String userId) { - Result<List<ProductionIdModel>> result = new Result<>(); + @AutoLog(value = "鐢ㄦ埛琛�-鏌ヨ鎸囧畾鐢ㄦ埛鍜屽伐鍘傚缓妯″叧鑱旂殑鏁版嵁") + @ApiOperation(value = "鐢ㄦ埛琛�-鏌ヨ鎸囧畾鐢ㄦ埛鍜屽伐鍘傚缓妯″叧鑱旂殑鏁版嵁", notes = "鐢ㄦ埛琛�-鏌ヨ鎸囧畾鐢ㄦ埛鍜屽伐鍘傚缓妯″叧鑱旂殑鏁版嵁") + @GetMapping(value = "/userFactorysList") + public Result<List<FactoryIdModel>> getUserFactorysList(@RequestParam(name = "userId", required = true) String userId) { + Result<List<FactoryIdModel>> result = new Result<>(); try { - List<ProductionIdModel> proIdModelList = this.userProductionService.queryProductionIdsOfUser(userId); - if (proIdModelList != null && !proIdModelList.isEmpty()) { + List<FactoryIdModel> facIdModelList = this.userFactoryService.queryFactoryIdsOfUser(userId); + if (facIdModelList != null && !facIdModelList.isEmpty()) { result.setSuccess(true); result.setMessage("鏌ユ壘鎴愬姛"); - result.setResult(proIdModelList); + result.setResult(facIdModelList); } else { result.setSuccess(false); result.setMessage("鏌ユ壘澶辫触"); diff --git a/src/main/java/org/jeecg/modules/system/entity/SysApiLog.java b/src/main/java/org/jeecg/modules/system/entity/SysApiLog.java new file mode 100644 index 0000000..ca78486 --- /dev/null +++ b/src/main/java/org/jeecg/modules/system/entity/SysApiLog.java @@ -0,0 +1,86 @@ +package org.jeecg.modules.system.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import com.fasterxml.jackson.annotation.JsonFormat; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; +import org.jeecg.common.aspect.annotation.Dict; +import org.springframework.format.annotation.DateTimeFormat; + +import java.io.Serializable; +import java.util.Date; +/** + * @Description: 绯荤粺绗笁鏂归泦鎴愭帴鍙f棩蹇� + * @Author: jeecg-boot + * @Date: 2025-07-30 + * @Version: V1.0 + */ +@Data +@TableName("sys_api_log") +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +@ApiModel(value="sys_api_log瀵硅薄", description="绯荤粺绗笁鏂归泦鎴愭帴鍙f棩蹇�") +public class SysApiLog implements Serializable { + + /**涓婚敭*/ + @TableId(type = IdType.ASSIGN_ID) + @ApiModelProperty(value = "涓婚敭") + private String id; + /**鍒涘缓浜�*/ + @ApiModelProperty(value = "鍒涘缓浜�") + private String createBy; + /**鍒涘缓鏃堕棿*/ + @ApiModelProperty(value = "鍒涘缓鏃堕棿") + @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss") + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Date createTime; + /**API鍒嗙被*/ + @ApiModelProperty(value = "API鍒嗙被") + @Dict(dicCode = "api_log_category") + private String apiCategory; + /**鎺ュ彛鍚嶇О*/ + @ApiModelProperty(value = "鎺ュ彛鍚嶇О") + private String apiName; + /**璇锋眰鏃堕棿*/ + @ApiModelProperty(value = "璇锋眰鏃堕棿") + @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss") + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Date requestTime; + /**鍝嶅簲鏃堕棿*/ + @ApiModelProperty(value = "鍝嶅簲鏃堕棿") + @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss") + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Date responseTime; + /**璇锋眰鏂瑰紡*/ + @ApiModelProperty(value = "璇锋眰鏂瑰紡") + private String requestMethod; + /**璇锋眰瀹屾垚URL*/ + @ApiModelProperty(value = "璇锋眰URL") + private String requestUrl; + /**璇锋眰澶�*/ + @ApiModelProperty(value = "璇锋眰澶�") + private String requestHeaders; + /**璇锋眰浣�*/ + @ApiModelProperty(value = "璇锋眰浣�") + private String requestBody; + /**鍝嶅簲缂栫爜*/ + @ApiModelProperty(value = "鍝嶅簲缂栫爜") + private String responseCode; + /**鍝嶅簲娑堟伅*/ + @ApiModelProperty(value = "鍝嶅簲娑堟伅") + private String responseMessage; + /**鍝嶅簲浣�*/ + @ApiModelProperty(value = "鍝嶅簲浣�") + private String responseBody; + /**鐘舵��;鎴愬姛銆佸け璐�*/ + @ApiModelProperty(value = "鐘舵��;鎴愬姛銆佸け璐�") + private Integer requestStatus; + /**璋冪敤鏂规硶*/ + @ApiModelProperty(value = "璋冪敤鏂规硶") + private String method; +} diff --git a/src/main/java/org/jeecg/modules/system/mapper/SysApiLogMapper.java b/src/main/java/org/jeecg/modules/system/mapper/SysApiLogMapper.java new file mode 100644 index 0000000..460c32d --- /dev/null +++ b/src/main/java/org/jeecg/modules/system/mapper/SysApiLogMapper.java @@ -0,0 +1,17 @@ +package org.jeecg.modules.system.mapper; + +import java.util.List; + +import org.apache.ibatis.annotations.Param; +import org.jeecg.modules.system.entity.SysApiLog; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; + +/** + * @Description: 绯荤粺绗笁鏂归泦鎴愭帴鍙f棩蹇� + * @Author: jeecg-boot + * @Date: 2025-07-30 + * @Version: V1.0 + */ +public interface SysApiLogMapper extends BaseMapper<SysApiLog> { + +} diff --git a/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcProductionEquipmentMapper.xml b/src/main/java/org/jeecg/modules/system/mapper/xml/SysApiLogMapper.xml similarity index 66% copy from src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcProductionEquipmentMapper.xml copy to src/main/java/org/jeecg/modules/system/mapper/xml/SysApiLogMapper.xml index 23c95bf..7fb8f4d 100644 --- a/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcProductionEquipmentMapper.xml +++ b/src/main/java/org/jeecg/modules/system/mapper/xml/SysApiLogMapper.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> -<mapper namespace="org.jeecg.modules.mdc.mapper.MdcProductionEquipmentMapper"> +<mapper namespace="org.jeecg.modules.system.mapper.SysApiLogMapper"> </mapper> \ No newline at end of file diff --git a/src/main/java/org/jeecg/modules/system/mapper/xml/SysUserMapper.xml b/src/main/java/org/jeecg/modules/system/mapper/xml/SysUserMapper.xml index f698980..3cd3bec 100644 --- a/src/main/java/org/jeecg/modules/system/mapper/xml/SysUserMapper.xml +++ b/src/main/java/org/jeecg/modules/system/mapper/xml/SysUserMapper.xml @@ -185,7 +185,7 @@ <!-- 鏌ヨ鐢ㄦ埛鐨勬墍灞炰骇绾垮悕绉颁俊鎭� --> <select id="getProNamesByUserIds" resultType="org.jeecg.modules.system.vo.MdcUserProVo"> - SELECT p.production_name, up.user_id FROM mdc_user_production up, mdc_production p WHERE p.id = up.pro_id AND up.user_id IN + SELECT p.factory_name productionName, up.user_id FROM base_user_factory up, base_factory p WHERE p.id = up.factory_id AND up.user_id IN <foreach collection="userIds" index="index" item="id" open="(" separator="," close=")"> #{id} </foreach> diff --git a/src/main/java/org/jeecg/modules/system/service/ISysApiLogService.java b/src/main/java/org/jeecg/modules/system/service/ISysApiLogService.java new file mode 100644 index 0000000..3905d43 --- /dev/null +++ b/src/main/java/org/jeecg/modules/system/service/ISysApiLogService.java @@ -0,0 +1,14 @@ +package org.jeecg.modules.system.service; + +import org.jeecg.modules.system.entity.SysApiLog; +import com.baomidou.mybatisplus.extension.service.IService; + +/** + * @Description: 绯荤粺绗笁鏂归泦鎴愭帴鍙f棩蹇� + * @Author: jeecg-boot + * @Date: 2025-07-30 + * @Version: V1.0 + */ +public interface ISysApiLogService extends IService<SysApiLog> { + +} diff --git a/src/main/java/org/jeecg/modules/system/service/impl/SysApiLogServiceImpl.java b/src/main/java/org/jeecg/modules/system/service/impl/SysApiLogServiceImpl.java new file mode 100644 index 0000000..ddef969 --- /dev/null +++ b/src/main/java/org/jeecg/modules/system/service/impl/SysApiLogServiceImpl.java @@ -0,0 +1,19 @@ +package org.jeecg.modules.system.service.impl; + +import org.jeecg.modules.system.entity.SysApiLog; +import org.jeecg.modules.system.mapper.SysApiLogMapper; +import org.jeecg.modules.system.service.ISysApiLogService; +import org.springframework.stereotype.Service; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; + +/** + * @Description: 绯荤粺绗笁鏂归泦鎴愭帴鍙f棩蹇� + * @Author: jeecg-boot + * @Date: 2025-07-30 + * @Version: V1.0 + */ +@Service +public class SysApiLogServiceImpl extends ServiceImpl<SysApiLogMapper, SysApiLog> implements ISysApiLogService { + +} diff --git a/src/main/java/org/jeecg/modules/system/service/impl/SysUserServiceImpl.java b/src/main/java/org/jeecg/modules/system/service/impl/SysUserServiceImpl.java index f00f3a7..1fd0c21 100644 --- a/src/main/java/org/jeecg/modules/system/service/impl/SysUserServiceImpl.java +++ b/src/main/java/org/jeecg/modules/system/service/impl/SysUserServiceImpl.java @@ -7,7 +7,6 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import lombok.extern.slf4j.Slf4j; -import org.apache.catalina.User; import org.apache.commons.lang3.StringUtils; import org.jeecg.common.api.vo.Result; import org.jeecg.common.constant.CacheConstant; @@ -24,8 +23,6 @@ import org.jeecg.modules.base.entity.UserFactory; import org.jeecg.modules.base.mapper.UserFactoryMapper; import org.jeecg.modules.base.service.BaseCommonService; -import org.jeecg.modules.mdc.entity.MdcUserProduction; -import org.jeecg.modules.mdc.mapper.MdcUserProductionMapper; import org.jeecg.modules.system.entity.*; import org.jeecg.modules.system.mapper.*; import org.jeecg.modules.system.model.SysUserSysDepartModel; @@ -85,8 +82,8 @@ SysRoleIndexMapper sysRoleIndexMapper; @Resource UserFactoryMapper userFactoryMapper; - @Resource - MdcUserProductionMapper mdcUserProductionMapper; +// @Resource +// MdcUserProductionMapper mdcUserProductionMapper; @Resource private ISysDictService sysDictService; @@ -522,7 +519,7 @@ // 2. 鍒犻櫎鐢ㄦ埛閮ㄩ棬鍏崇郴 line += sysUserDepartMapper.delete(new LambdaQueryWrapper<SysUserDepart>().in(SysUserDepart::getUserId, userIds)); // 3. 鍒犻櫎鐢ㄦ埛浜х嚎鍏崇郴 - line += mdcUserProductionMapper.delete(new LambdaQueryWrapper<MdcUserProduction>().in(MdcUserProduction::getUserId, userIds)); + line += userFactoryMapper.delete(new LambdaQueryWrapper<UserFactory>().in(UserFactory::getUserId, userIds)); //3. 鍒犻櫎鐢ㄦ埛瑙掕壊鍏崇郴 line += sysUserRoleMapper.delete(new LambdaQueryWrapper<SysUserRole>().in(SysUserRole::getUserId, userIds)); //4.鍚屾鍒犻櫎绗笁鏂笰pp鐨勭敤鎴� @@ -592,8 +589,8 @@ if (oConvertUtils.isNotEmpty(selectedProductions)) { arr = selectedProductions.split(","); for (String productionId : arr) { - MdcUserProduction mdcUserProduction = new MdcUserProduction(user.getId(), productionId); - mdcUserProductionMapper.insert(mdcUserProduction); + UserFactory mdcUserProduction = new UserFactory(productionId, user.getId()); + userFactoryMapper.insert(mdcUserProduction); } } //step.5 淇濆瓨璁惧鏉冮檺 @@ -661,13 +658,14 @@ array = productions.split(","); } //鍏堝垹鍚庡姞 - mdcUserProductionMapper.delete(new QueryWrapper<MdcUserProduction>().lambda().eq(MdcUserProduction::getUserId, user.getId())); + userFactoryMapper.delete(new QueryWrapper<UserFactory>().lambda().eq(UserFactory::getUserId, user.getId())); if (oConvertUtils.isNotEmpty(productions)) { for (String productionId : array) { - MdcUserProduction mdcUserProduction = new MdcUserProduction(user.getId(), productionId); - mdcUserProductionMapper.insert(mdcUserProduction); + UserFactory mdcUserProduction = new UserFactory(productionId, user.getId()); + userFactoryMapper.insert(mdcUserProduction); } } + //step.5 淇敼璁惧鏉冮檺 //鍏堝垹鍚庡姞 // dncDevicePermissionMapper.delete(new QueryWrapper<DncDevicePermission>().lambda().eq(DncDevicePermission::getUserId, user.getId())); -- Gitblit v1.9.3