houzhongjian
2024-11-06 1f7276770b69e5c8b3c10d70a57b7de18003f5a0
Merge remote-tracking branch 'origin/master'
已添加67个文件
已重命名1个文件
已删除6个文件
已修改57个文件
15213 ■■■■ 文件已修改
iailab-framework/iailab-common-excel/src/main/java/com/iailab/framework/excel/core/handler/SelectSheetWriteHandler.java 77 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-framework/iailab-common-excel/src/main/java/com/iailab/framework/excel/core/util/ExcelUtils.java 15 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-framework/iailab-common-mq/src/main/java/com/iailab/framework/mq/common/RoutingConstant.java 13 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-data/iailab-module-data-api/src/main/java/com/iailab/module/data/api/plan/PlanItemApi.java 34 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-data/iailab-module-data-api/src/main/java/com/iailab/module/data/api/plan/dto/ApiPlanDataDTO.java 22 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-data/iailab-module-data-api/src/main/java/com/iailab/module/data/common/ApiDataQueryDTO.java 44 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-data/iailab-module-data-api/src/main/java/com/iailab/module/data/common/ApiDataValueDTO.java 22 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-data/iailab-module-data-api/src/main/java/com/iailab/module/data/enums/ErrorCodeConstants.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-data/iailab-module-data-biz/db/mysql/tenant.sql 48 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/api/controller/admin/ApiDataController.java 156 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/api/controller/admin/ApiIndItemController.java 63 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/api/plan/PlanItemApiImpl.java 47 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/common/dto/ChannelSourceDTO.java 18 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/common/service/ChannelSourceService.java 88 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/http/collector/ihdb/HttpCollectorForIhd.java 75 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/http/controller/admin/HttpTagController.java 80 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/http/entity/HttpTagEntity.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/http/service/HttpTagService.java 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/http/service/impl/HttpTagServiceImpl.java 60 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/http/vo/HttpTagRespVO.java 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/kio/controller/admin/ChannelKioTagController.java 78 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/kio/entity/ChannelKioTagEntity.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/kio/service/ChannelKioTagService.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/kio/service/impl/ChannelKioDeviceServiceImpl.java 5 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/kio/service/impl/ChannelKioTagServiceImpl.java 52 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/kio/vo/KioTagPageReqVO.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/kio/vo/KioTagRespVO.java 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/modbus/controller/admin/ChannelModbusTagController.java 78 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/modbus/entity/ChannelModBusTagEntity.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/modbus/service/ChannelModbusTagService.java 13 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/modbus/service/impl/ChannelModbusTagServiceImpl.java 53 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/modbus/vo/ModBusTagExportExcelVO.java 28 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/modbus/vo/ModBusTagImportExcelVO.java 31 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/modbus/vo/ModBusTagPageReqVO.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/modbus/vo/ModBusTagRespVO.java 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/opcda/controller/admin/ChannelOPCDATagController.java 96 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/opcda/entity/ChannelOPCDATagEntity.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/opcda/service/ChannelOPCDADeviceService.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/opcda/service/ChannelOPCDATagService.java 7 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/opcda/service/impl/ChannelOPCDADeviceServiceImpl.java 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/opcda/service/impl/ChannelOPCDATagServiceImpl.java 54 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/opcda/vo/OpcDaTagExportExcelVO.java 51 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/opcda/vo/OpcDaTagImportExcelVO.java 53 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/opcda/vo/OpcDaTagRespVO.java 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/opcua/controller/admin/ChannelOPCUATagController.java 91 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/opcua/entity/ChannelOPCUATagEntity.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/opcua/service/ChannelOPCUATagService.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/opcua/service/impl/ChannelOPCUATagServiceImpl.java 54 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/opcua/vo/OpcUaTagExportExcelVO.java 59 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/opcua/vo/OpcUaTagImportExcelVO.java 61 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/opcua/vo/OpcUaTagPageReqVO.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/opcua/vo/OpcUaTagRespVO.java 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/tag/vo/TagExportExcelVO.java 55 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/tag/vo/TagImportExcelVO.java 56 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/tag/vo/TagImportRespVO.java 26 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/enums/IncreaseCodeEnum.java 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/utils/ApiSecurityUtils.java 7 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/utils/DateUtils.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/item/service/impl/IndItemServiceImpl.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/task/DevCameraDahuaTask.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/task/PointCollectTaskNet60.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/utils/ScheduleJob.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/plan/category/controller/admin/PlanItemCategoryController.java 88 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/plan/category/controller/package-info.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/plan/category/dao/PlanItemCategoryDao.java 26 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/plan/category/entity/PlanItemCategoryEntity.java 65 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/plan/category/package-info.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/plan/category/service/PlanItemCategoryService.java 28 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/plan/category/service/impl/PlanItemCategoryServiceImpl.java 90 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/plan/category/vo/PlanItemCategoryReqVO.java 18 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/plan/category/vo/PlanItemCategoryRespVO.java 44 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/plan/category/vo/PlanItemCategorySaveReqVO.java 34 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/plan/data/controller/admin/PlanDataSetController.java 85 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/plan/data/controller/package-info.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/plan/data/dao/PlanDataSetDao.java 25 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/plan/data/entity/PlanDataSetEntity.java 73 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/plan/data/package-info.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/plan/data/service/PlanDataSetService.java 29 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/plan/data/service/impl/PlanDataSetServiceImpl.java 60 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/plan/data/vo/PlanDataSetPageReqVO.java 22 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/plan/data/vo/PlanDataSetRespVO.java 50 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/plan/data/vo/PlanDataSetSaveReqVO.java 34 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/plan/item/collection/PlanItemCollector.java 103 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/plan/item/controller/admin/PlanItemController.java 101 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/plan/item/controller/package-info.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/plan/item/dao/PlanItemDao.java 37 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/plan/item/entity/PlanItemEntity.java 80 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/plan/item/package-info.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/plan/item/service/PlanItemService.java 35 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/plan/item/service/impl/PlanItemServiceImpl.java 80 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/plan/item/vo/PlanItemDataVO.java 18 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/plan/item/vo/PlanItemPageReqVO.java 28 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/plan/item/vo/PlanItemRespVO.java 65 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/plan/item/vo/PlanItemSaveReqVO.java 42 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/plan/item/vo/PlanItemValueExportVO.java 27 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/plan/item/vo/PlanItemValueVO.java 23 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/plan/package-info.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/common/IncreaseCodeEnum.java 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/common/PointTypeEnum.java 42 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/controller/admin/DaPointController.java 36 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/dao/DaPointDao.java 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/dto/DaPointDTO.java 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/service/DaMathPointService.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/service/DaPointService.java 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/service/impl/DaMathPointServiceImpl.java 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/service/impl/DaPointServiceImpl.java 142 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/vo/DaPointExcelVO.java 22 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/vo/PointImportExcelVO.java 23 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-data/iailab-module-data-biz/src/main/resources/mapper/plan/PlanItemDao.xml 19 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-data/iailab-module-data-biz/src/main/resources/mapper/point/DaPointDao.xml 71 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-model/.flattened-pom.xml 23 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-model/iailab-module-model-api/.flattened-pom.xml 38 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-model/iailab-module-model-biz/.flattened-pom.xml 179 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-model/iailab-module-model-biz/db/mysql.sql 42 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-model/iailab-module-model-biz/pom.xml 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mpk/controller/admin/ChartController.java 70 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mpk/controller/admin/ChartParamController.java 71 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mpk/dao/ChartDao.java 17 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mpk/dao/ChartParamDao.java 17 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mpk/dto/ChartDTO.java 47 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mpk/dto/ChartParamDTO.java 56 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mpk/entity/ChartEntity.java 45 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mpk/entity/ChartParamEntity.java 60 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mpk/service/ChartParamService.java 29 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mpk/service/ChartService.java 25 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mpk/service/impl/ChartParamServiceImpl.java 74 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mpk/service/impl/ChartServiceImpl.java 74 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-model/iailab-module-model-biz/src/main/java/iail/mdk/model/common/Environment.java 26 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-model/iailab-module-model-biz/src/main/resources/application.yml 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-model/iailab-module-model-biz/src/main/resources/template/cpp.vm 7 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
logs/log-debug.2024-09-30.log 10518 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-framework/iailab-common-excel/src/main/java/com/iailab/framework/excel/core/handler/SelectSheetWriteHandler.java
@@ -7,24 +7,21 @@
import cn.hutool.core.util.StrUtil;
import cn.hutool.extra.spring.SpringUtil;
import cn.hutool.poi.excel.ExcelUtil;
import com.iailab.framework.common.core.KeyValue;
import com.iailab.framework.dict.core.DictFrameworkUtils;
import com.iailab.framework.excel.core.annotations.ExcelColumnSelect;
import com.iailab.framework.excel.core.function.ExcelColumnSelectFunction;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.write.handler.SheetWriteHandler;
import com.alibaba.excel.write.metadata.holder.WriteSheetHolder;
import com.alibaba.excel.write.metadata.holder.WriteWorkbookHolder;
import com.iailab.framework.common.core.KeyValue;
import com.iailab.framework.dict.core.DictFrameworkUtils;
import com.iailab.framework.excel.core.annotations.ExcelColumnSelect;
import com.iailab.framework.excel.core.function.ExcelColumnSelectFunction;
import lombok.extern.slf4j.Slf4j;
import org.apache.poi.hssf.usermodel.HSSFDataValidation;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.ss.util.CellRangeAddressList;
import java.lang.reflect.Field;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
import static com.iailab.framework.common.util.collection.CollectionUtils.convertList;
@@ -38,7 +35,6 @@
    /**
     * 数据起始行从 0 开始
     *
     * 约定:本项目第一行有标题所以从 1 开始如果您的 Excel 有多行标题请自行更改
     */
    public static final int FIRST_ROW = 1;
@@ -54,22 +50,29 @@
     */
    private final Map<Integer, List<String>> selectMap = new HashMap<>();
    public SelectSheetWriteHandler(Class<?> head) {
    private static Boolean ifSetSelect;
    public SelectSheetWriteHandler(Class<?> head, Boolean selectFlag) {
        ifSetSelect = selectFlag;
        // 加载下拉数据获取接口
        Map<String, ExcelColumnSelectFunction> beansMap = SpringUtil.getBeanFactory().getBeansOfType(ExcelColumnSelectFunction.class);
        if (MapUtil.isEmpty(beansMap)) {
            return;
        }
        List<Field> fields = new ArrayList<>();
        for (Class<?> c = head; c != null; c = c.getSuperclass()) {
            Collections.addAll(fields, c.getDeclaredFields());
        }
        // 解析下拉数据
        int colIndex = 0;
        for (Field field : head.getDeclaredFields()) {
        for (Field field : fields) {
            if (field.isAnnotationPresent(ExcelColumnSelect.class)) {
                ExcelProperty excelProperty = field.getAnnotation(ExcelProperty.class);
                if (excelProperty != null && excelProperty.index() != -1) {
                    colIndex = excelProperty.index();
                    getSelectDataList(excelProperty.index(), field);
                }else{
                    getSelectDataList(colIndex, field);
                }
                getSelectDataList(colIndex, field);
            }
            colIndex++;
        }
@@ -106,27 +109,45 @@
        if (CollUtil.isEmpty(selectMap)) {
            return;
        }
        // 1. 获取相应操作对象
        DataValidationHelper helper = writeSheetHolder.getSheet().getDataValidationHelper(); // 需要设置下拉框的 sheet 页的数据验证助手
        Workbook workbook = writeWorkbookHolder.getWorkbook(); // 获得工作簿
        List<KeyValue<Integer, List<String>>> keyValues = convertList(selectMap.entrySet(), entry -> new KeyValue<>(entry.getKey(), entry.getValue()));
        keyValues.sort(Comparator.comparing(item -> item.getValue().size())); // 升序不然创建下拉会报错
        // 2. 创建数据字典的 sheet 页
        Sheet dictSheet = workbook.createSheet(DICT_SHEET_NAME);
        for (KeyValue<Integer, List<String>> keyValue : keyValues) {
            int rowLength = keyValue.getValue().size();
            // 2.1 设置字典 sheet 页的值,每一列一个字典项
            for (int i = 0; i < rowLength; i++) {
                Row row = dictSheet.getRow(i);
                if (row == null) {
                    row = dictSheet.createRow(i);
        if (ifSetSelect){
            for (KeyValue<Integer, List<String>> keyValue : keyValues) {
                /*起始行、终止行、起始列、终止列  起始行为1即表示表头不设置**/
                CellRangeAddressList addressList = new CellRangeAddressList(FIRST_ROW, LAST_ROW, keyValue.getKey(), keyValue.getKey());
                /*设置下拉框数据**/
                DataValidationConstraint constraint = helper.createExplicitListConstraint(keyValue.getValue().toArray(new String[0]));
                DataValidation dataValidation = helper.createValidation(constraint, addressList);
                if (dataValidation instanceof HSSFDataValidation) {
                    dataValidation.setSuppressDropDownArrow(false);
                } else {
                    dataValidation.setSuppressDropDownArrow(true);
                    dataValidation.setShowErrorBox(true);
                }
                row.createCell(keyValue.getKey()).setCellValue(keyValue.getValue().get(i));
                // 2.2 阻止输入非下拉框的值
                dataValidation.setErrorStyle(DataValidation.ErrorStyle.STOP);
                dataValidation.createErrorBox("提示", "此值不存在于下拉选择中!");
                writeSheetHolder.getSheet().addValidationData(dataValidation);
            }
            // 2.2 设置单元格下拉选择
            setColumnSelect(writeSheetHolder, workbook, helper, keyValue);
        }else{
            // 2. 创建数据字典的 sheet 页
            Sheet dictSheet = workbook.createSheet(DICT_SHEET_NAME);
            for (KeyValue<Integer, List<String>> keyValue : keyValues) {
                int rowLength = keyValue.getValue().size();
                // 2.1 设置字典 sheet 页的值,每一列一部字典项
                for (int i = 0; i < rowLength; i++) {
                    Row row = dictSheet.getRow(i);
                    if (row == null) {
                        row = dictSheet.createRow(i);
                    }
                    row.createCell(keyValue.getKey()).setCellValue(keyValue.getValue().get(i));
                }
                // 2.2 设置单元格下拉选择
                setColumnSelect(writeSheetHolder, workbook, helper, keyValue);
            }
        }
    }
iailab-framework/iailab-common-excel/src/main/java/com/iailab/framework/excel/core/util/ExcelUtils.java
@@ -36,7 +36,7 @@
        EasyExcel.write(response.getOutputStream(), head)
                .autoCloseStream(false) // 不要自动关闭,交给 Servlet 自己处理
                .registerWriteHandler(new LongestMatchColumnWidthStyleStrategy()) // 基于 column 长度,自动适配。最大 255 宽度
                .registerWriteHandler(new SelectSheetWriteHandler(head)) // 基于固定 sheet 实现下拉框
                .registerWriteHandler(new SelectSheetWriteHandler(head,false)) // 基于固定 sheet 实现下拉框
                .registerConverter(new LongStringConverter()) // 避免 Long 类型丢失精度
                .sheet(sheetName).doWrite(data);
        // 设置 header 和 contentType。写在最后的原因是,避免报错时,响应 contentType 已经被修改了
@@ -50,4 +50,17 @@
                .doReadAllSync();
    }
    public static <T> void write(HttpServletResponse response, String filename, String sheetName,
                                 Class<T> head, List<T> data, boolean selectFlag) throws IOException {
        // 输出 Excel
        EasyExcel.write(response.getOutputStream(), head)
                .autoCloseStream(false) // 不要自动关闭,交给 Servlet 自己处理
                .registerWriteHandler(new LongestMatchColumnWidthStyleStrategy()) // 基于 column 长度,自动适配。最大 255 宽度
                .registerWriteHandler(new SelectSheetWriteHandler(head,selectFlag)) // 基于固定 sheet 实现下拉框
                .registerConverter(new LongStringConverter()) // 避免 Long 类型丢失精度
                .sheet(sheetName).doWrite(data);
        // 设置 header 和 contentType。写在最后的原因是,避免报错时,响应 contentType 已经被修改了
        response.addHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(filename, StandardCharsets.UTF_8.name()));
        response.setContentType("application/vnd.ms-excel;charset=UTF-8");
    }
}
iailab-framework/iailab-common-mq/src/main/java/com/iailab/framework/mq/common/RoutingConstant.java
对比新文件
@@ -0,0 +1,13 @@
package com.iailab.framework.mq.common;
/**
 *
 *
 * @author PanZhibao
 * @Description
 * @createTime 2024年11月05日
 */
public interface RoutingConstant {
    String Iailab_Data_PointCollectFinish = "Iailab.Data.PointCollectFinish";
}
iailab-module-data/iailab-module-data-api/src/main/java/com/iailab/module/data/api/plan/PlanItemApi.java
对比新文件
@@ -0,0 +1,34 @@
package com.iailab.module.data.api.plan;
import com.iailab.module.data.api.plan.dto.ApiPlanDataDTO;
import com.iailab.module.data.common.ApiDataQueryDTO;
import com.iailab.module.data.common.ApiDataValueDTO;
import com.iailab.module.data.enums.ApiConstants;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import java.util.LinkedHashMap;
import java.util.List;
/**
 * @author PanZhibao
 * @Description
 * @createTime 2024年11月03日
 */
@FeignClient(name = ApiConstants.NAME)
@Tag(name = "计划数据")
public interface PlanItemApi {
    String PREFIX = ApiConstants.PREFIX + "/plan-item";
    @PostMapping(PREFIX + "/query-plan/history-value")
    @Operation(summary = "查询计划历史值")
    List<ApiDataValueDTO> queryPlanItemHistoryValue(@RequestBody ApiDataQueryDTO dto);
    @PostMapping(PREFIX + "/query-plans/record-value")
    @Operation(summary = "查询计划记录")
    LinkedHashMap<String, List<ApiPlanDataDTO>> queryPlanItemRecordValue(@RequestBody ApiDataQueryDTO dto);
}
iailab-module-data/iailab-module-data-api/src/main/java/com/iailab/module/data/api/plan/dto/ApiPlanDataDTO.java
对比新文件
@@ -0,0 +1,22 @@
package com.iailab.module.data.api.plan.dto;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.Data;
import java.io.Serializable;
/**
 * @author PanZhibao
 * @Description
 * @createTime 2024年11月04日
 */
@Data
@Tag(name = "计划值")
public class ApiPlanDataDTO implements Serializable {
    private static final long serialVersionUID = 1L;
    private String startTime;
    private String endTime;
}
iailab-module-data/iailab-module-data-api/src/main/java/com/iailab/module/data/common/ApiDataQueryDTO.java
对比新文件
@@ -0,0 +1,44 @@
package com.iailab.module.data.common;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.Data;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
/**
 * @author PanZhibao
 * @Description
 * @createTime 2024年11月03日
 */
@Data
@Tag(name = "值查询")
public class ApiDataQueryDTO implements Serializable {
    private static final long serialVersionUID = 1L;
    @Schema(description = "itemNo")
    @NotNull(message="itemNo不能为空")
    private String itemNo;
    @Schema(description = "itemNo")
    @NotNull(message="itemNo不能为空")
    private List<String> itemNos;
    @Schema(description = "粒度")
    @NotNull(message="粒度不能为空")
    private Integer granularity;
    @Schema(description = "开始时间")
    @NotNull(message="start不能为空")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date start;
    @Schema(description = "结束时间")
    @NotNull(message="end不能为空")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date end;
}
iailab-module-data/iailab-module-data-api/src/main/java/com/iailab/module/data/common/ApiDataValueDTO.java
对比新文件
@@ -0,0 +1,22 @@
package com.iailab.module.data.common;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
 * @author PanZhibao
 * @Description
 * @createTime 2024年11月03日
 */
@Data
@Tag(name = "值结果")
public class ApiDataValueDTO implements Serializable {
    private static final long serialVersionUID = 1L;
    private Date dataTime;
    private double dataValue;
}
iailab-module-data/iailab-module-data-api/src/main/java/com/iailab/module/data/enums/ErrorCodeConstants.java
@@ -7,4 +7,9 @@
    ErrorCode POINT_IMPORT_LIST_IS_EMPTY = new ErrorCode(1_001_001_001, "导入测点数据不能为空!");
    ErrorCode POINT_NOT_EXISTS = new ErrorCode(1_002_001_000, "测点配置不存在");
    ErrorCode POINT_EXISTS = new ErrorCode(1_002_002_000, "测点配置已经存在");
    ErrorCode TAG_IMPORT_LIST_IS_EMPTY = new ErrorCode(2_001_001_001, "导入Tag数据不能为空!");
    ErrorCode TAG_EXISTS = new ErrorCode(2_002_002_001, "Tag已经存在");
}
iailab-module-data/iailab-module-data-biz/db/mysql/tenant.sql
@@ -340,4 +340,50 @@
                                  PRIMARY KEY (`id`) USING BTREE,
                                  KEY `idx_item_no` (`item_no`) USING BTREE,
                                  KEY `idx_data_time` (`data_time`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=DYNAMIC COMMENT='指标值表';
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=DYNAMIC COMMENT='指标值表';
-- 计划数据------------
CREATE TABLE t_plan_data_set(
                               `id` VARCHAR(36) NOT NULL  COMMENT 'ID' ,
                               `name` VARCHAR(30) NOT NULL   COMMENT '名称' ,
                               `data_source` VARCHAR(64) NOT NULL   COMMENT '数据源ID',
                               `query_sql` VARCHAR(300) NOT NULL   COMMENT '查询语句',
                               `remark` VARCHAR(100)   COMMENT '备注',
                               `sort` int   COMMENT '排序',
                               `creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '创建者',
                               `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
                               `updater` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '更新者',
                               `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
                               PRIMARY KEY (id) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT = '计划数据集';
CREATE TABLE t_plan_item_category(
                                    `id` VARCHAR(36) NOT NULL  COMMENT 'ID' ,
                                    `label` VARCHAR(20)   COMMENT '标签' ,
                                    `pid` VARCHAR(36)   COMMENT '父ID',
                                    `sort` int   COMMENT '排序',
                                    `creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '创建者',
                                    `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
                                    `updater` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '更新者',
                                    `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
                                    PRIMARY KEY (id) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT = '计划数据分类';
CREATE TABLE t_plan_item(
                           `id` VARCHAR(36) NOT NULL  COMMENT 'ID' ,
                           `item_no` VARCHAR(36)   COMMENT '指标编码' ,
                           `item_name` VARCHAR(36)   COMMENT '指标名称' ,
                           `item_category` VARCHAR(36)   COMMENT '指标分类',
                           `time_granularity` VARCHAR(10)   COMMENT '时间粒度',
                           `data_set` VARCHAR(64)   COMMENT '数据集',
                           `remark` VARCHAR(255)   COMMENT '备注' ,
                           `status` tinyint NOT NULL DEFAULT 0 COMMENT '状态(0正常 1停用)',
                           `creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '创建者',
                           `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
                           `updater` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '更新者',
                           `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
                           PRIMARY KEY (id) USING BTREE,
                           UNIQUE INDEX `uk_item_no` (`item_no`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT = '计划数据项';
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/api/controller/admin/ApiDataController.java
@@ -2,24 +2,40 @@
import com.iailab.framework.common.pojo.CommonResult;
import com.iailab.framework.common.util.date.DateUtils;
import com.iailab.framework.common.util.object.ConvertUtils;
import com.iailab.framework.excel.core.util.ExcelUtils;
import com.iailab.framework.tenant.core.context.TenantContextHolder;
import com.iailab.module.data.api.dto.IndexQueryDTO;
import com.iailab.module.data.api.dto.echarts.BarLineDTO;
import com.iailab.module.data.api.dto.echarts.SeriesItem;
import com.iailab.module.data.api.ind.dto.ApiIndItemQueryDTO;
import com.iailab.module.data.api.ind.dto.ApiIndItemValueDTO;
import com.iailab.module.data.api.plan.PlanItemApi;
import com.iailab.module.data.api.plan.dto.ApiPlanDataDTO;
import com.iailab.module.data.api.point.DataPointApi;
import com.iailab.module.data.api.point.dto.ApiPointValueDTO;
import com.iailab.module.data.api.point.dto.ApiPointValueQueryDTO;
import com.iailab.module.data.api.point.dto.ApiPointsValueQueryDTO;
import com.iailab.module.data.common.ApiDataQueryDTO;
import com.iailab.module.data.common.ApiDataValueDTO;
import com.iailab.module.data.ind.collection.IndItemCollector;
import com.iailab.module.data.ind.item.vo.IndItemValueVO;
import com.iailab.module.data.plan.item.entity.PlanItemEntity;
import com.iailab.module.data.plan.item.vo.PlanItemValueExportVO;
import com.iailab.module.data.point.common.PointDataTypeEnum;
import com.iailab.module.data.point.dto.DaPointDTO;
import com.iailab.module.data.point.service.DaPointService;
import com.iailab.module.data.api.dto.DeviceValueDTO;
import com.iailab.module.data.api.utils.ApiSecurityUtils;
import com.iailab.module.data.common.utils.ApiSecurityUtils;
import com.iailab.module.data.plan.item.service.PlanItemService;
import com.iailab.module.data.point.vo.DaPointExcelVO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import javax.annotation.Resource;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.*;
@@ -27,6 +43,7 @@
import javax.annotation.security.PermitAll;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.math.BigDecimal;
import java.util.*;
import java.util.stream.Collectors;
@@ -52,6 +69,15 @@
    @Autowired
    private DataPointApi dataPointApi;
    @Autowired
    private PlanItemApi planItemApi;
    @Autowired
    private IndItemCollector indItemCollector;
    @Autowired
    private PlanItemService planItemService;
    @PermitAll
    @PostMapping("/query-points/history-value")
@@ -175,4 +201,132 @@
        }
        return CommonResult;
    }
    @PermitAll
    @PostMapping("/query-plan/history-value")
    @Operation(summary = "查询单个计划历史值")
    public CommonResult<List<ApiDataValueDTO>> queryPlanItemHistoryValue(HttpServletResponse response, HttpServletRequest
            request, @RequestBody ApiDataQueryDTO dto) {
        List<ApiDataValueDTO> result = new ArrayList<>();
        try {
            apiSecurityUtils.validate(request);
            result = planItemApi.queryPlanItemHistoryValue(dto);
            return new CommonResult<List<ApiDataValueDTO>>().setData(result);
        } catch (Exception ex) {
            return new CommonResult<List<ApiDataValueDTO>>().setMsg(ex.getMessage());
        }
    }
    @PermitAll
    @PostMapping("/query-plan/record-value")
    @Operation(summary = "查询单个计划历史值")
    public CommonResult<LinkedHashMap<String, List<ApiPlanDataDTO>>> queryPlanItemRecordValue(HttpServletResponse response, HttpServletRequest
            request, @RequestBody ApiDataQueryDTO dto) {
        LinkedHashMap<String, List<ApiPlanDataDTO>> result = new LinkedHashMap<>();
        try {
            apiSecurityUtils.validate(request);
            result = planItemApi.queryPlanItemRecordValue(dto);
            return new CommonResult<LinkedHashMap<String, List<ApiPlanDataDTO>>>().setData(result);
        } catch (Exception ex) {
            return new CommonResult<LinkedHashMap<String, List<ApiPlanDataDTO>>>().setMsg(ex.getMessage());
        }
    }
    @PostMapping("/query-plans/chart")
    public CommonResult<BarLineDTO> queryPlansChart(HttpServletResponse response, HttpServletRequest
            request, @RequestBody ApiDataQueryDTO dto) {
        BarLineDTO CommonResult = new BarLineDTO();
        try {
            apiSecurityUtils.validate(request);
            List<String> legend = new ArrayList<>();
            List<SeriesItem> series = new ArrayList<>();
            Calendar calendar = Calendar.getInstance();
            calendar.set(Calendar.MILLISECOND, 0);
            calendar.set(Calendar.SECOND, 0);
            Date endDate = dto.getEnd() == null ? DateUtils.addDateHours(calendar.getTime(), 2) : dto.getEnd();
            Date startDate = dto.getStart() == null ? calendar.getTime() : dto.getStart();
            List<String> categories = DateUtils.getTimeScale(startDate, endDate, dto.getGranularity() == null ? 60 : dto.getGranularity());
            if (CollectionUtils.isEmpty(dto.getItemNos())) {
                return new CommonResult<BarLineDTO>().setData(CommonResult);
            }
            List<PlanItemEntity> planItemList = new ArrayList<>();
            dto.getItemNos().forEach(item -> {
                planItemList.add(planItemService.getInfoByNo(item));
            });
            planItemList.forEach(item -> {
                legend.add(item.getItemName());
                SeriesItem seriesItem = new SeriesItem();
                seriesItem.setName(item.getItemName());
                ApiDataQueryDTO queryDto = new ApiDataQueryDTO();
                queryDto.setItemNo(item.getItemNo());
                queryDto.setStart(startDate);
                queryDto.setEnd(endDate);
                List<ApiDataValueDTO> list = planItemApi.queryPlanItemHistoryValue(queryDto);
                List<Object[]> sData = list.stream().map(dataItem -> {
                    Object[] valueArray = new Object[]{DateUtils.format(dataItem.getDataTime(), DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND),
                            dataItem.getDataValue()};
                    return valueArray;
                }).collect(Collectors.toList());
                seriesItem.setData(sData);
                series.add(seriesItem);
            });
            CommonResult.setLegend(legend);
            CommonResult.setCategories(categories);
            CommonResult.setSeries(series);
        } catch (Exception ex) {
            ex.printStackTrace();
        }
        return new CommonResult<BarLineDTO>().setData(CommonResult);
    }
    @PostMapping("/export-plan/history-value")
    @Operation(summary = "导出计划数据")
    public void exportPlanHistoryValue(HttpServletResponse response, HttpServletRequest
            request, @RequestBody ApiDataQueryDTO dto) throws IOException {
        //apiSecurityUtils.validate(request);
        Calendar calendar = Calendar.getInstance();
        calendar.set(Calendar.MILLISECOND, 0);
        calendar.set(Calendar.SECOND, 0);
        Date endDate = dto.getEnd() == null ? DateUtils.addDateHours(calendar.getTime(), 2) : dto.getEnd();
        Date startDate = dto.getStart() == null ? calendar.getTime() : dto.getStart();
        ApiDataQueryDTO queryDto = new ApiDataQueryDTO();
        queryDto.setItemNo(dto.getItemNo());
        queryDto.setStart(startDate);
        queryDto.setEnd(endDate);
        List<ApiDataValueDTO> list = planItemApi.queryPlanItemHistoryValue(queryDto);
        List<PlanItemValueExportVO> exportList = list.stream().map(item -> {
            PlanItemValueExportVO exportVO = new PlanItemValueExportVO();
            exportVO.setDataTime(DateUtils.format(item.getDataTime(), DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND));
            exportVO.setDataValue(new BigDecimal(item.getDataValue()).setScale(0, BigDecimal.ROUND_HALF_UP).toString());
            return exportVO;
        }).collect(Collectors.toList());
        ExcelUtils.write(response, "计划数据.xls", "计划数据", PlanItemValueExportVO.class, exportList);
    }
    @PermitAll
    @GetMapping("/query-ind/default-value")
    @Operation(summary = "查询指标默认值")
    public CommonResult<List<ApiIndItemValueDTO>> queryIndItemDefaultValue(@RequestParam String itemNo) {
        TenantContextHolder.setTenantId(161L);
        List<IndItemValueVO> list = indItemCollector.queryValue(itemNo);
        List<ApiIndItemValueDTO> dtoList = new ArrayList<>();
        list.forEach(item -> {
            ApiIndItemValueDTO dto = new ApiIndItemValueDTO();
            dto.setDataTime(item.getDataTime());
            dto.setDataValue(item.getDataValue().doubleValue());
            dtoList.add(dto);
        });
        return success(dtoList);
    }
    @PermitAll
    @GetMapping("/query-ind/history-value")
    @Operation(summary = "查询指标历史值")
    public CommonResult<List<ApiIndItemValueDTO>> queryIndItemHistoryValue(@RequestParam ApiIndItemQueryDTO dto) {
        List<IndItemValueVO> list = indItemCollector.queryValue(dto.getItemNo(), dto.getStart(), dto.getEnd());
        return success(ConvertUtils.sourceToTarget(list, ApiIndItemValueDTO.class));
    }
}
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/api/controller/admin/ApiIndItemController.java
文件已删除
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/api/plan/PlanItemApiImpl.java
对比新文件
@@ -0,0 +1,47 @@
package com.iailab.module.data.api.plan;
import com.iailab.framework.common.util.object.ConvertUtils;
import com.iailab.module.data.api.plan.dto.ApiPlanDataDTO;
import com.iailab.module.data.common.ApiDataQueryDTO;
import com.iailab.module.data.common.ApiDataValueDTO;
import com.iailab.module.data.plan.item.collection.PlanItemCollector;
import com.iailab.module.data.plan.item.vo.PlanItemDataVO;
import com.iailab.module.data.plan.item.vo.PlanItemValueVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.CollectionUtils;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RestController;
import java.util.LinkedHashMap;
import java.util.List;
/**
 * @author PanZhibao
 * @Description
 * @createTime 2024年11月03日
 */
@RestController // 提供 RESTful API 接口,给 Feign 调用
@Validated
public class PlanItemApiImpl implements PlanItemApi {
    @Autowired
    private PlanItemCollector planItemCollector;
    public List<ApiDataValueDTO> queryPlanItemHistoryValue(ApiDataQueryDTO dto) {
        List<PlanItemValueVO> list = planItemCollector.queryValue(dto.getItemNo(), dto.getStart(), dto.getEnd());
        return ConvertUtils.sourceToTarget(list, ApiDataValueDTO.class);
    }
    public LinkedHashMap<String, List<ApiPlanDataDTO>> queryPlanItemRecordValue(ApiDataQueryDTO dto) {
        LinkedHashMap<String, List<ApiPlanDataDTO>> result = new LinkedHashMap<>();
        if (CollectionUtils.isEmpty(dto.getItemNos())) {
            return result;
        }
        dto.getItemNos().forEach(item -> {
            List<PlanItemDataVO> list = planItemCollector.getSourceValue(item, dto.getStart(), dto.getEnd());
            result.put(item, ConvertUtils.sourceToTarget(list, ApiPlanDataDTO.class));
        });
        return result;
    }
}
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/common/dto/ChannelSourceDTO.java
对比新文件
@@ -0,0 +1,18 @@
package com.iailab.module.data.channel.common.dto;
import lombok.Data;
/**
 * @author PanZhibao
 * @Description
 * @createTime 2024年10月31日
 */
@Data
public class ChannelSourceDTO {
    private String sourceType;
    private String sourceName;
    private String sourceId;
}
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/common/service/ChannelSourceService.java
对比新文件
@@ -0,0 +1,88 @@
package com.iailab.module.data.channel.common.service;
import com.iailab.module.data.channel.http.entity.HttpApiEntity;
import com.iailab.module.data.channel.http.service.HttpApiService;
import com.iailab.module.data.channel.kio.entity.ChannelKioDeviceEntity;
import com.iailab.module.data.channel.kio.service.ChannelKioDeviceService;
import com.iailab.module.data.channel.modbus.dto.ChannelModBusDeviceDTO;
import com.iailab.module.data.channel.modbus.entity.ChannelModBusDeviceEntity;
import com.iailab.module.data.channel.modbus.service.ChannelModbusDeviceService;
import com.iailab.module.data.channel.opcda.dto.ChannelOPCDADeviceDTO;
import com.iailab.module.data.channel.opcda.entity.ChannelOPCDADeviceEntity;
import com.iailab.module.data.channel.opcda.service.ChannelOPCDADeviceService;
import com.iailab.module.data.channel.opcua.dto.ChannelOPCUADeviceDTO;
import com.iailab.module.data.channel.opcua.entity.ChannelOPCUADeviceEntity;
import com.iailab.module.data.channel.opcua.service.ChannelOPCUADeviceService;
import com.iailab.module.data.common.enums.DataSourceType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
 * @author PanZhibao
 * @Description
 * @createTime 2024年10月31日
 */
@Component
public class ChannelSourceService {
    @Autowired
    private ChannelOPCDADeviceService channelOPCDADeviceService;
    @Autowired
    private ChannelOPCUADeviceService channelOPCUADeviceService;
    @Autowired
    private ChannelModbusDeviceService channelModbusDeviceService;
    @Autowired
    private ChannelKioDeviceService channelKioDeviceService;
    @Autowired
    private HttpApiService httpApiService;
    public Map<String, Map<String, String>> getSourcesId() {
        Map<String, Map<String, String>> result = new HashMap<>();
        Map<String, String> opcdaMap = new HashMap<>();
        List<ChannelOPCDADeviceEntity> opcdaList = channelOPCDADeviceService.list(new HashMap<>());
        opcdaList.forEach(opcda -> {
            opcdaMap.put(opcda.getServerName(), opcda.getId());
        });
        result.put(DataSourceType.OPCDA.getCode(), opcdaMap);
        Map<String, String> opcuaMap = new HashMap<>();
        List<ChannelOPCUADeviceEntity> opcuaList = channelOPCUADeviceService.list(new HashMap<>());
        opcuaList.forEach(opcUa -> {
            opcuaMap.put(opcUa.getServerName(), opcUa.getId());
        });
        result.put(DataSourceType.OPCUA.getCode(), opcuaMap);
        Map<String, String> modbusMap = new HashMap<>();
        List<ChannelModBusDeviceEntity> modbusList = channelModbusDeviceService.list(new HashMap<>());
        modbusList.forEach(modbus -> {
            modbusMap.put(modbus.getName(), modbus.getId());
        });
        result.put(DataSourceType.ModBus.getCode(), modbusMap);
        Map<String, String> kioMap = new HashMap<>();
        List<ChannelKioDeviceEntity> kioList = channelKioDeviceService.list(new HashMap<>());
        kioList.forEach(kio -> {
            kioMap.put(kio.getInstanceName(), kio.getId());
        });
        result.put(DataSourceType.KIO.getCode(), kioMap);
        Map<String, String> httpMap = new HashMap<>();
        List<HttpApiEntity> httpList = httpApiService.list();
        httpList.forEach(http -> {
            httpMap.put(http.getCode(), http.getId());
        });
        result.put(DataSourceType.HTTP.getCode(), httpMap);
        return result;
    }
}
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/http/collector/ihdb/HttpCollectorForIhd.java
@@ -3,20 +3,31 @@
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.google.gson.Gson;
import com.iailab.framework.common.constant.CommonConstant;
import com.iailab.module.data.channel.http.entity.HttpApiEntity;
import com.iailab.module.data.channel.http.entity.HttpTagEntity;
import com.iailab.module.data.channel.http.service.HttpApiService;
import com.iailab.module.data.channel.http.service.HttpTagService;
import com.iailab.module.data.common.enums.DataSourceType;
import com.iailab.module.data.common.utils.DateUtils;
import com.iailab.module.data.common.utils.HttpRequest;
import com.iailab.module.data.common.utils.TagUtils;
import com.iailab.module.data.influxdb.pojo.InfluxPointValueBoolPOJO;
import com.iailab.module.data.influxdb.pojo.InfluxPointValueDigPOJO;
import com.iailab.module.data.influxdb.pojo.InfluxPointValueSimPOJO;
import com.iailab.module.data.influxdb.pojo.InfluxPointValueStrPOJO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.BoundHashOperations;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.*;
import java.util.concurrent.TimeUnit;
/**
 * iHyperDB采集
@@ -32,6 +43,12 @@
    @Autowired
    private HttpApiService httpApiService;
    @Autowired
    private RedisTemplate redisTemplate;
    @Autowired
    private HttpTagService httpTagService;
    private static final String STA_TRUE = "true";
@@ -74,6 +91,64 @@
        return value;
    }
    public Map<String, Object> getLastValues(List<String> tagNames) {
        Map<String, Object> result = new HashMap<>();
        try {
            if (CollectionUtils.isEmpty(tagNames)) {
                return result;
            }
            List<String> noCacheTagNames = new ArrayList<>();//未缓存的tag
            for (int i = 0; i < tagNames.size(); i++) {
                //先查缓存
                BoundHashOperations<String, String, Object> ops = redisTemplate.boundHashOps(tagNames.get(i));
                if (ops.get("value") != null) {
                    BigDecimal value = new BigDecimal(ops.get("value").toString());
                    result.put(tagNames.get(i), value.setScale(3, RoundingMode.HALF_UP));
                } else {
                    noCacheTagNames.add(tagNames.get(i));
                }
            }
            if (CollectionUtils.isEmpty(noCacheTagNames)) {
                log.info("全部读取缓存");
                return result;
            }
            log.info("查询未缓存的数据");
            Gson gson = new Gson();
            String tagSb = gson.toJson(noCacheTagNames);
            log.info("body=====" + tagSb);
            String currentDate = DateUtils.format(new Date(), "yyyyMMddHHmm00");
            String responseStr = "";
            responseStr = HttpRequest.sendPost("http://172.16.59.105:9082/api/IHD/getPointslast" + "/" + currentDate, tagSb);
            JSONObject responseObj = JSON.parseObject(responseStr);
            if (STA_TRUE.equals(responseObj.get("isSuccess").toString())) {
                JSONArray tagValueList = responseObj.getJSONArray("data");
                if (!CollectionUtils.isEmpty(tagValueList)) {
                    for (int i = 0; i < tagValueList.size(); i++) {
                        JSONObject item = tagValueList.getJSONObject(i);
                        if (item.get("value") != null) {
                            //存缓存
                            BoundHashOperations<String, String, Object> ops = redisTemplate.boundHashOps(item.get("tagname").toString());
                            ops.put("value", item.get("value").toString());
                            //设置过期时间
                            redisTemplate.expire(item.get("tagname").toString(), 10, TimeUnit.SECONDS);
                            //把查询到的数据插入结果集
                            BigDecimal value = new BigDecimal(item.get("value").toString());
                            result.put(item.get("tagname").toString(), value.setScale(3, RoundingMode.HALF_UP));
                        } else {
                            result.put(item.get("tagname").toString(), CommonConstant.BAD_VALUE);
                        }
                    }
                }
            }
        } catch (Exception ex) {
            log.info("getCurrentValue异常");
            ex.printStackTrace();
            throw ex;
        }
        return result;
    }
    public Map<String, Object> getTagValues(List<Object[]> params) {
        if (CollectionUtils.isEmpty(params)) {
            return new HashMap<>();
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/http/controller/admin/HttpTagController.java
@@ -1,21 +1,35 @@
package com.iailab.module.data.channel.http.controller.admin;
import com.iailab.framework.apilog.core.annotation.ApiAccessLog;
import com.iailab.framework.common.pojo.CommonResult;
import com.iailab.framework.common.pojo.PageParam;
import com.iailab.framework.common.pojo.PageResult;
import com.iailab.framework.common.util.object.BeanUtils;
import com.iailab.framework.common.util.object.ConvertUtils;
import com.iailab.framework.excel.core.util.ExcelUtils;
import com.iailab.module.data.channel.http.collector.ihdb.HttpCollectorForIhd;
import com.iailab.module.data.channel.http.entity.HttpTagEntity;
import com.iailab.module.data.channel.http.service.HttpTagService;
import com.iailab.module.data.channel.http.vo.HttpTagPageReqVO;
import com.iailab.module.data.channel.http.vo.HttpTagRespVO;
import com.iailab.module.data.channel.tag.vo.TagExportExcelVO;
import com.iailab.module.data.channel.tag.vo.TagImportExcelVO;
import com.iailab.module.data.channel.tag.vo.TagImportRespVO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.util.Date;
import java.util.List;
import java.util.UUID;
import java.io.IOException;
import java.util.*;
import java.util.stream.Collectors;
import static com.iailab.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
import static com.iailab.framework.common.pojo.CommonResult.success;
@@ -31,11 +45,30 @@
    @Resource
    private HttpTagService tagService;
    @Resource
    private HttpCollectorForIhd httpCollectorForIhd;
    @PreAuthorize("@ss.hasPermission('data:channel-http:query')")
    @GetMapping("page")
    public CommonResult<PageResult<HttpTagRespVO>> page(@Valid HttpTagPageReqVO reqVO) {
        PageResult<HttpTagEntity> page = tagService.queryPage(reqVO);
        return success(BeanUtils.toBean(page, HttpTagRespVO.class));
        PageResult<HttpTagRespVO> pageResultVO = new PageResult<>();
        List<String> tagNames = page.getList().stream()
                .map(HttpTagEntity::getTagName)
                .collect(Collectors.toList());
        Map<String, Object> dataMap = httpCollectorForIhd.getLastValues(tagNames);
        List<HttpTagRespVO> vos = page.getList().stream().map(entity -> {
            HttpTagRespVO vo = BeanUtils.toBean(entity,HttpTagRespVO.class);
            vo.setDataValue(Double.parseDouble(dataMap.get(entity.getTagName()).toString()));
            return vo;
        }).collect(Collectors.toList());
        pageResultVO.setList(vos);
        return success(pageResultVO);
    }
    @PreAuthorize("@ss.hasPermission('data:channel-http:query')")
@@ -75,4 +108,41 @@
        tagService.delete(id);
        return success(true);
    }
    @GetMapping("/export")
    @Operation(summary = "导出modbus tag列表")
    @PreAuthorize("@ss.hasPermission('data:channel-http-tag:export')")
    @ApiAccessLog(operateType = EXPORT)
    public void exportPointList(@Validated HttpTagPageReqVO reqVO, HttpServletResponse response) throws IOException {
        reqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
        PageResult<HttpTagEntity> page = tagService.queryPage(reqVO);
        List<TagExportExcelVO> list = ConvertUtils.sourceToTarget(page.getList(), TagExportExcelVO.class);
        ExcelUtils.write(response, "tag列表.xls", "数据", TagExportExcelVO.class, list, true);
    }
    @GetMapping("/get-import-template")
    @Operation(summary = "获得tag导入模板")
    public void importTemplate(HttpServletResponse response) throws IOException {
        // 手动创建导出 demo
        List<TagImportExcelVO> list = Collections.singletonList(
                TagImportExcelVO.builder().tagName("Tag名称").tagDesc("Tag描述").dataType("String").enabled(1)
                        .build()
        );
        // 输出
        ExcelUtils.write(response, "tag导入模板.xls", "tag列表", TagImportExcelVO.class, list,true);
    }
    @PostMapping("/import")
    @Operation(summary = "导入tag")
    @Parameters({
            @Parameter(name = "file", description = "Excel 文件", required = true),
            @Parameter(name = "updateSupport", description = "是否支持更新,默认为 false", example = "true")
    })
    @PreAuthorize("@ss.hasPermission('data:channel-http-tag:import')")
    public CommonResult<TagImportRespVO> importExcel(@RequestParam("file") MultipartFile file,
                                                     @RequestParam(value = "updateSupport", required = false, defaultValue = "false") Boolean updateSupport,
                                                     @RequestParam("device") String device) throws Exception {
        List<TagImportExcelVO> list = ExcelUtils.read(file, TagImportExcelVO.class);
        return success(tagService.importHttpTagList(list, updateSupport, device));
    }
}
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/http/entity/HttpTagEntity.java
@@ -49,7 +49,7 @@
    /**
     * 是否启用
     */
    private Boolean enabled;
    private Integer enabled;
    /**
     * 创建时间
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/http/service/HttpTagService.java
@@ -3,6 +3,8 @@
import com.iailab.framework.common.pojo.PageResult;
import com.iailab.module.data.channel.http.entity.HttpTagEntity;
import com.iailab.module.data.channel.http.vo.HttpTagPageReqVO;
import com.iailab.module.data.channel.tag.vo.TagImportExcelVO;
import com.iailab.module.data.channel.tag.vo.TagImportRespVO;
import java.util.List;
import java.util.Map;
@@ -23,4 +25,8 @@
    List<HttpTagEntity> selectList(Map<String, Object> params);
    List<HttpTagEntity> getApiId(String code);
    List<HttpTagEntity> getInfoByTagNoAndSourceId(String sourceId, String tagNo);
    TagImportRespVO importHttpTagList(List<TagImportExcelVO> importTags, boolean isUpdateSupport, String apiId);
}
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/http/service/impl/HttpTagServiceImpl.java
@@ -1,20 +1,28 @@
package com.iailab.module.data.channel.http.service.impl;
import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.iailab.framework.common.pojo.PageResult;
import com.iailab.framework.common.util.object.BeanUtils;
import com.iailab.framework.common.util.object.ConvertUtils;
import com.iailab.module.data.channel.http.dao.HttpTagDao;
import com.iailab.module.data.channel.http.entity.HttpApiEntity;
import com.iailab.module.data.channel.http.entity.HttpTagEntity;
import com.iailab.module.data.channel.http.service.HttpApiService;
import com.iailab.module.data.channel.http.service.HttpTagService;
import com.iailab.module.data.channel.http.vo.HttpTagPageReqVO;
import com.iailab.module.data.channel.tag.vo.TagImportExcelVO;
import com.iailab.module.data.channel.tag.vo.TagImportRespVO;
import com.iailab.module.data.common.enums.CommonConstant;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
import java.util.*;
import static com.iailab.framework.common.exception.util.ServiceExceptionUtil.exception;
import static com.iailab.module.data.enums.ErrorCodeConstants.*;
@Slf4j
@Service
@@ -73,4 +81,52 @@
                .orderByDesc("create_time"));
    }
    @Override
    public List<HttpTagEntity> getInfoByTagNoAndSourceId(String sourceId, String tagName) {
        return httpTagDao.selectList(new QueryWrapper<HttpTagEntity>()
        .eq("api_id",sourceId)
        .eq("tag_name",tagName)
        );
    }
    @Override
    public TagImportRespVO importHttpTagList(List<TagImportExcelVO> importTags, boolean isUpdateSupport, String apiId) {
        // 1.1 参数校验
        if (CollUtil.isEmpty(importTags)) {
            throw exception(TAG_IMPORT_LIST_IS_EMPTY);
        }
        // 2. 遍历,逐个创建 or 更新
        TagImportRespVO respVO = TagImportRespVO.builder().createTagNames(new ArrayList<>())
                .updateTagNames(new ArrayList<>()).failureTagNames(new LinkedHashMap<>()).build();
        importTags.forEach(importTag -> {
            // 判断如果不存在,再进行插入
            HttpTagEntity existTag = httpTagDao.selectOne(new QueryWrapper<HttpTagEntity>()
                    .eq("api_id", apiId)
                    .eq("tag_name",importTag.getTagName()));
            if (existTag == null) {
                HttpTagEntity httpTagEntity = ConvertUtils.sourceToTarget(importTag, HttpTagEntity.class);
                httpTagEntity.setId(UUID.randomUUID().toString());
                httpTagEntity.setEnabled(CommonConstant.IS_ENABLE);
                httpTagEntity.setApiId(apiId);
                httpTagEntity.setCreateTime(new Date());
                httpTagDao.insert(httpTagEntity);
                respVO.getCreateTagNames().add(httpTagEntity.getTagName());
                return;
            }
            // 如果存在,判断是否允许更新
            if (!isUpdateSupport) {
                respVO.getFailureTagNames().put(importTag.getTagName(), TAG_EXISTS.getMsg());
                return;
            }
            HttpTagEntity updateTag = BeanUtils.toBean(importTag, HttpTagEntity.class);
            updateTag.setId(existTag.getId());
            baseMapper.updateById(updateTag);
            respVO.getUpdateTagNames().add(importTag.getTagName());
        });
        return respVO;
    }
}
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/http/vo/HttpTagRespVO.java
@@ -39,7 +39,11 @@
    @Schema(description = "是否启用", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
    @ExcelProperty("是否启用")
    private Boolean enabled;
    private Integer enabled;
    @Schema(description = "数据值", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
    @ExcelProperty("数据值")
    private Double dataValue;
    @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
    @ExcelProperty("创建时间")
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/kio/controller/admin/ChannelKioTagController.java
@@ -1,21 +1,41 @@
package com.iailab.module.data.channel.kio.controller.admin;
import com.iailab.framework.apilog.core.annotation.ApiAccessLog;
import com.iailab.framework.common.pojo.CommonResult;
import com.iailab.framework.common.pojo.PageParam;
import com.iailab.framework.common.pojo.PageResult;
import com.iailab.framework.common.util.object.BeanUtils;
import com.iailab.framework.common.util.object.ConvertUtils;
import com.iailab.framework.excel.core.util.ExcelUtils;
import com.iailab.module.data.channel.kio.collector.KingIOCollector;
import com.iailab.framework.common.util.object.ConvertUtils;
import com.iailab.framework.excel.core.util.ExcelUtils;
import com.iailab.module.data.channel.kio.entity.ChannelKioTagEntity;
import com.iailab.module.data.channel.kio.service.ChannelKioTagService;
import com.iailab.module.data.channel.kio.vo.KioTagPageReqVO;
import com.iailab.module.data.channel.kio.vo.KioTagRespVO;
import com.iailab.module.data.channel.tag.vo.TagExportExcelVO;
import com.iailab.module.data.channel.tag.vo.TagImportExcelVO;
import com.iailab.module.data.channel.tag.vo.TagImportRespVO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.io.IOException;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import java.util.UUID;
import java.util.stream.Collectors;
import static com.iailab.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
import static com.iailab.framework.common.pojo.CommonResult.success;
/**
@@ -27,14 +47,34 @@
    @Resource
    private ChannelKioTagService channelKioTagService;
    @Resource
    private KingIOCollector kingIOCollector;
    /**
     * 分页查询tag
     * */
    @PreAuthorize("@ss.hasPermission('data:channel-kio:query')")
    @GetMapping("page")
    public CommonResult<PageResult<KioTagRespVO>> page(@Valid KioTagPageReqVO reqVO){
        PageResult<ChannelKioTagEntity> page = channelKioTagService.queryPage(reqVO);
        return success(BeanUtils.toBean(page, KioTagRespVO.class));
        PageResult<KioTagRespVO> pageResultVO = new PageResult<>();
        pageResultVO.setTotal(page.getTotal());
        List<KioTagRespVO> vos = page.getList().stream().map(entity -> {
            KioTagRespVO vo = BeanUtils.toBean(entity,KioTagRespVO.class);
            try {
                vo.setDataValue(Double.parseDouble(kingIOCollector.getTagValue(reqVO.getDeviceId(), entity.getTagName())));
            }catch (Exception e){
                e.printStackTrace();
            }
            return vo;
        }).collect(Collectors.toList());
        pageResultVO.setList(vos);
        return success(pageResultVO);
    }
    @PreAuthorize("@ss.hasPermission('data:channel-kio:query')")
@@ -70,4 +110,40 @@
        return success(true);
    }
    @GetMapping("/export")
    @Operation(summary = "导出modbus tag列表")
    @PreAuthorize("@ss.hasPermission('data:channel-kio-tag:export')")
    @ApiAccessLog(operateType = EXPORT)
    public void exportPointList(@Validated KioTagPageReqVO reqVO, HttpServletResponse response) throws IOException {
        reqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
        PageResult<ChannelKioTagEntity> page = channelKioTagService.queryPage(reqVO);
        List<TagExportExcelVO> list = ConvertUtils.sourceToTarget(page.getList(), TagExportExcelVO.class);
        ExcelUtils.write(response, "tag列表.xls", "数据", TagExportExcelVO.class, list, true);
    }
    @GetMapping("/get-import-template")
    @Operation(summary = "获得tag导入模板")
    public void importTemplate(HttpServletResponse response) throws IOException {
        // 手动创建导出 demo
        List<TagImportExcelVO> list = Collections.singletonList(
                TagImportExcelVO.builder().tagName("Tag名称").tagDesc("Tag描述").dataType("String").enabled(1)
                        .build()
        );
        // 输出
        ExcelUtils.write(response, "tag导入模板.xls", "tag列表", TagImportExcelVO.class, list,true);
    }
    @PostMapping("/import")
    @Operation(summary = "导入tag")
    @Parameters({
            @Parameter(name = "file", description = "Excel 文件", required = true),
            @Parameter(name = "updateSupport", description = "是否支持更新,默认为 false", example = "true")
    })
    @PreAuthorize("@ss.hasPermission('data:channel-kio-tag:import')")
    public CommonResult<TagImportRespVO> importExcel(@RequestParam("file") MultipartFile file,
                                                     @RequestParam(value = "updateSupport", required = false, defaultValue = "false") Boolean updateSupport,
                                                     @RequestParam("device") String device) throws Exception {
        List<TagImportExcelVO> list = ExcelUtils.read(file, TagImportExcelVO.class);
        return success(channelKioTagService.importKioTagList(list, updateSupport, device));
    }
}
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/kio/entity/ChannelKioTagEntity.java
@@ -50,7 +50,7 @@
    /**
     * 是否可以tag
     */
    private Boolean enabled;
    private Integer enabled;
    /**
     * 关联设备
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/kio/service/ChannelKioTagService.java
@@ -3,6 +3,8 @@
import com.iailab.framework.common.pojo.PageResult;
import com.iailab.module.data.channel.kio.entity.ChannelKioTagEntity;
import com.iailab.module.data.channel.kio.vo.KioTagPageReqVO;
import com.iailab.module.data.channel.tag.vo.TagImportExcelVO;
import com.iailab.module.data.channel.tag.vo.TagImportRespVO;
import java.util.List;
@@ -28,4 +30,7 @@
    ChannelKioTagEntity getByTagName(String tagName);
    void deleteByDeviceName(String name);
    TagImportRespVO importKioTagList(List<TagImportExcelVO> importTags, boolean isUpdateSupport, String device);
}
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/kio/service/impl/ChannelKioDeviceServiceImpl.java
@@ -64,6 +64,9 @@
    @Override
    public List<ChannelKioDeviceEntity> list(Map<String, Object> params) {
        return channelKioDeviceDao.selectList(new QueryWrapper<ChannelKioDeviceEntity>().orderByAsc("instance_name"));
        QueryWrapper<ChannelKioDeviceEntity> queryWrapper = new QueryWrapper<>();
        queryWrapper.orderByAsc("instance_name");
        return channelKioDeviceDao.selectList(queryWrapper);
    }
}
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/kio/service/impl/ChannelKioTagServiceImpl.java
@@ -1,18 +1,26 @@
package com.iailab.module.data.channel.kio.service.impl;
import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.iailab.framework.common.pojo.PageResult;
import com.iailab.framework.common.util.object.BeanUtils;
import com.iailab.framework.common.util.object.ConvertUtils;
import com.iailab.module.data.channel.kio.dao.ChannelKioTagDao;
import com.iailab.module.data.channel.kio.entity.ChannelKioTagEntity;
import com.iailab.module.data.channel.kio.service.ChannelKioTagService;
import com.iailab.module.data.channel.kio.vo.KioTagPageReqVO;
import com.iailab.module.data.channel.tag.vo.TagImportExcelVO;
import com.iailab.module.data.channel.tag.vo.TagImportRespVO;
import com.iailab.module.data.common.enums.CommonConstant;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
import java.util.*;
import static com.iailab.framework.common.exception.util.ServiceExceptionUtil.exception;
import static com.iailab.module.data.enums.ErrorCodeConstants.*;
/**
 * @author lirm
@@ -71,4 +79,44 @@
    public void deleteByDeviceName(String name) {
        channelKioTagDao.delete(new QueryWrapper<ChannelKioTagEntity>().eq("device",name));
    }
    @Override
    public TagImportRespVO importKioTagList(List<TagImportExcelVO> importTags, boolean isUpdateSupport, String device) {
        // 1.1 参数校验
        if (CollUtil.isEmpty(importTags)) {
            throw exception(TAG_IMPORT_LIST_IS_EMPTY);
        }
        // 2. 遍历,逐个创建 or 更新
        TagImportRespVO respVO = TagImportRespVO.builder().createTagNames(new ArrayList<>())
                .updateTagNames(new ArrayList<>()).failureTagNames(new LinkedHashMap<>()).build();
        importTags.forEach(importTag -> {
            // 判断如果不存在,再进行插入
            ChannelKioTagEntity existTag = channelKioTagDao.selectOne(new QueryWrapper<ChannelKioTagEntity>()
                    .eq("device", device)
                    .eq("tag_name",importTag.getTagName()));
            if (existTag == null) {
                ChannelKioTagEntity channelKioTagEntity = ConvertUtils.sourceToTarget(importTag, ChannelKioTagEntity.class);
                channelKioTagEntity.setId(UUID.randomUUID().toString());
                channelKioTagEntity.setEnabled(CommonConstant.IS_ENABLE);
                channelKioTagEntity.setDevice(device);
                channelKioTagEntity.setCreateTime(new Date());
                channelKioTagDao.insert(channelKioTagEntity);
                respVO.getCreateTagNames().add(channelKioTagEntity.getTagName());
                return;
            }
            // 如果存在,判断是否允许更新
            if (!isUpdateSupport) {
                respVO.getFailureTagNames().put(importTag.getTagName(), TAG_EXISTS.getMsg());
                return;
            }
            ChannelKioTagEntity updateTag = BeanUtils.toBean(importTag, ChannelKioTagEntity.class);
            updateTag.setId(existTag.getId());
            baseMapper.updateById(updateTag);
            respVO.getUpdateTagNames().add(importTag.getTagName());
        });
        return respVO;
    }
}
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/kio/vo/KioTagPageReqVO.java
@@ -20,4 +20,6 @@
    private String tagName;
    private String device;
    private String deviceId;
}
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/kio/vo/KioTagRespVO.java
@@ -37,10 +37,14 @@
    @ExcelProperty("测点描述")
    private String tagDesc;
    @Schema(description = "是否可以tag", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
    @ExcelProperty("是否可以tag")
    @Schema(description = "是否启用", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
    @ExcelProperty("是否启用")
    private Boolean enabled;
    @Schema(description = "数据值", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
    @ExcelProperty("数据值")
    private Double dataValue;
    @Schema(description = "关联设备", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
    @ExcelProperty("关联设备")
    private String device;
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/modbus/controller/admin/ChannelModbusTagController.java
@@ -1,20 +1,41 @@
package com.iailab.module.data.channel.modbus.controller.admin;
import com.iailab.framework.apilog.core.annotation.ApiAccessLog;
import com.iailab.framework.common.pojo.CommonResult;
import com.iailab.framework.common.pojo.PageParam;
import com.iailab.framework.common.pojo.PageResult;
import com.iailab.framework.common.util.object.BeanUtils;
import com.iailab.framework.common.util.object.ConvertUtils;
import com.iailab.framework.excel.core.util.ExcelUtils;
import com.iailab.module.data.channel.modbus.collector.ModBusCollector;
import com.iailab.module.data.channel.modbus.entity.ChannelModBusTagEntity;
import com.iailab.module.data.channel.modbus.entity.ChannelModBusTagEntity;
import com.iailab.module.data.channel.modbus.service.ChannelModbusTagService;
import com.iailab.module.data.channel.modbus.vo.ModBusTagExportExcelVO;
import com.iailab.module.data.channel.modbus.vo.ModBusTagImportExcelVO;
import com.iailab.module.data.channel.modbus.vo.ModBusTagPageReqVO;
import com.iailab.module.data.channel.modbus.vo.ModBusTagRespVO;
import com.iailab.module.data.channel.tag.vo.TagImportRespVO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.util.ArrayList;
import java.io.IOException;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import java.util.UUID;
import java.util.stream.Collectors;
import static com.iailab.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
import static com.iailab.framework.common.pojo.CommonResult.success;
/**
@@ -28,13 +49,26 @@
    @Resource
    private ChannelModbusTagService channelModbusTagService;
    @Resource
    private ModBusCollector modBusCollector;
    @GetMapping("/page")
    public CommonResult<PageResult<ModBusTagRespVO>> list(@Valid ModBusTagPageReqVO reqVO) {
        PageResult<ChannelModBusTagEntity> page = channelModbusTagService.queryPage(reqVO);
        PageResult<ModBusTagRespVO> pageResultVO = new PageResult<>();
        pageResultVO.setTotal(page.getTotal());
        return success(BeanUtils.toBean(page, ModBusTagRespVO.class));
        List<ModBusTagRespVO> vos = page.getList().stream().map(entity -> {
            ModBusTagRespVO vo = BeanUtils.toBean(entity,ModBusTagRespVO.class);
            vo.setDataValue(modBusCollector.getTagValue(entity.getDevice(),entity.getTagName()));
            return vo;
        }).collect(Collectors.toList());
        pageResultVO.setList(vos);
        return success(pageResultVO);
    }
    /**
     * 根据id查询设备详情
     *
@@ -82,4 +116,44 @@
        channelModbusTagService.delete(id);
        return success(true);
    }
    @GetMapping("/export")
    @Operation(summary = "导出modbus tag列表")
    @PreAuthorize("@ss.hasPermission('data:channel-modbus-tag:export')")
    @ApiAccessLog(operateType = EXPORT)
    public void exportPointList(@Validated ModBusTagPageReqVO reqVO, HttpServletResponse response) throws IOException {
        reqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
        PageResult<ChannelModBusTagEntity> page = channelModbusTagService.queryPage(reqVO);
        List<ModBusTagExportExcelVO> list = ConvertUtils.sourceToTarget(page.getList(), ModBusTagExportExcelVO.class);
        ExcelUtils.write(response, "tag列表.xls", "数据", ModBusTagExportExcelVO.class, list, true);
    }
    @GetMapping("/get-import-template")
    @Operation(summary = "获得tag导入模板")
    public void importTemplate(HttpServletResponse response) throws IOException {
        // 手动创建导出 demo
        List<ModBusTagImportExcelVO> list = Collections.singletonList(
                ModBusTagImportExcelVO.builder().tagName("Tag名称").tagDesc("Tag描述").dataType("String").
                        address("123").format("1").samplingRate(1000).enabled(1)
                        .build()
        );
        // 输出
        ExcelUtils.write(response, "tag导入模板.xls", "tag列表", ModBusTagImportExcelVO.class, list,true);
    }
    @PostMapping("/import")
    @Operation(summary = "导入tag")
    @Parameters({
            @Parameter(name = "file", description = "Excel 文件", required = true),
            @Parameter(name = "updateSupport", description = "是否支持更新,默认为 false", example = "true")
    })
    @PreAuthorize("@ss.hasPermission('data:channel-modbus-tag:import')")
    public CommonResult<TagImportRespVO> importExcel(@RequestParam("file") MultipartFile file,
                                                     @RequestParam(value = "updateSupport", required = false, defaultValue = "false") Boolean updateSupport,
                                                     @RequestParam("device") String device) throws Exception {
        List<ModBusTagImportExcelVO> list = ExcelUtils.read(file, ModBusTagImportExcelVO.class);
        return success(channelModbusTagService.importModBusTagList(list, updateSupport,device));
    }
}
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/modbus/entity/ChannelModBusTagEntity.java
@@ -39,7 +39,7 @@
    /**
     * 是否启用
     */
    private Boolean enabled;
    private Integer enabled;
    /**
     * 大小端
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/modbus/service/ChannelModbusTagService.java
@@ -3,7 +3,9 @@
import com.iailab.framework.common.pojo.PageResult;
import com.iailab.module.data.channel.modbus.dto.ChannelModbusTagDTO;
import com.iailab.module.data.channel.modbus.entity.ChannelModBusTagEntity;
import com.iailab.module.data.channel.modbus.vo.ModBusTagImportExcelVO;
import com.iailab.module.data.channel.modbus.vo.ModBusTagPageReqVO;
import com.iailab.module.data.channel.tag.vo.TagImportRespVO;
import java.util.List;
@@ -18,7 +20,7 @@
     *
     * @param reqVO
     */
    PageResult queryPage(ModBusTagPageReqVO reqVO);
    PageResult<ChannelModBusTagEntity> queryPage(ModBusTagPageReqVO reqVO);
    
    /**
     * 查询tag详情
@@ -70,12 +72,5 @@
     */
    void deleteByDeviceName(String name);
//    /**
//     * 导入Tag
//     *
//     * @param device
//     * @param file
//     * @throws Exception
//     */
//    void importTag(String device, MultipartFile file) throws Exception;
    TagImportRespVO importModBusTagList(List<ModBusTagImportExcelVO> importTags, boolean isUpdateSupport, String device);
}
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/modbus/service/impl/ChannelModbusTagServiceImpl.java
@@ -1,21 +1,28 @@
package com.iailab.module.data.channel.modbus.service.impl;
import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.iailab.framework.common.pojo.PageResult;
import com.iailab.framework.common.util.object.BeanUtils;
import com.iailab.framework.common.util.object.ConvertUtils;
import com.iailab.module.data.channel.modbus.dao.ChannelModBusTagDao;
import com.iailab.module.data.channel.modbus.dto.ChannelModbusTagDTO;
import com.iailab.module.data.channel.modbus.entity.ChannelModBusTagEntity;
import com.iailab.module.data.channel.modbus.service.ChannelModbusTagService;
import com.iailab.module.data.channel.modbus.vo.ModBusTagImportExcelVO;
import com.iailab.module.data.channel.modbus.vo.ModBusTagPageReqVO;
import com.iailab.module.data.channel.tag.vo.TagImportRespVO;
import com.iailab.module.data.common.enums.CommonConstant;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
import java.util.*;
import static com.iailab.framework.common.exception.util.ServiceExceptionUtil.exception;
import static com.iailab.module.data.enums.ErrorCodeConstants.*;
/**
 * @author lirm
@@ -82,4 +89,46 @@
        baseMapper.delete(new QueryWrapper<ChannelModBusTagEntity>().eq("device", name));
    }
    @Override
    public TagImportRespVO importModBusTagList(List<ModBusTagImportExcelVO> importTags, boolean isUpdateSupport, String device) {
        // 1.1 参数校验
        if (CollUtil.isEmpty(importTags)) {
            throw exception(TAG_IMPORT_LIST_IS_EMPTY);
        }
        // 2. 遍历,逐个创建 or 更新
        TagImportRespVO respVO = TagImportRespVO.builder().createTagNames(new ArrayList<>())
                .updateTagNames(new ArrayList<>()).failureTagNames(new LinkedHashMap<>()).build();
        importTags.forEach(importTag -> {
            // 判断如果不存在,再进行插入
            ChannelModBusTagEntity existTag = channelModBusTagDao.selectOne(new QueryWrapper<ChannelModBusTagEntity>()
                    .eq("device", device)
                    .eq("tag_name",importTag.getTagName()));
            if (existTag == null) {
                ChannelModBusTagEntity channelModBusTagEntity = ConvertUtils.sourceToTarget(importTag, ChannelModBusTagEntity.class);
                channelModBusTagEntity.setId(UUID.randomUUID().toString());
                channelModBusTagEntity.setEnabled(CommonConstant.IS_ENABLE);
                channelModBusTagEntity.setDevice(device);
                channelModBusTagEntity.setCreateTime(new Date());
                channelModBusTagDao.insert(channelModBusTagEntity);
                respVO.getCreateTagNames().add(channelModBusTagEntity.getTagName());
                return;
            }
            // 如果存在,判断是否允许更新
            if (!isUpdateSupport) {
                respVO.getFailureTagNames().put(importTag.getTagName(), TAG_EXISTS.getMsg());
                return;
            }
            ChannelModBusTagEntity updateTag = BeanUtils.toBean(importTag, ChannelModBusTagEntity.class);
            updateTag.setId(existTag.getId());
            baseMapper.updateById(updateTag);
            respVO.getUpdateTagNames().add(importTag.getTagName());
        });
        return respVO;
    }
}
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/modbus/vo/ModBusTagExportExcelVO.java
对比新文件
@@ -0,0 +1,28 @@
package com.iailab.module.data.channel.modbus.vo;
import com.alibaba.excel.annotation.ExcelProperty;
import com.iailab.module.data.channel.tag.vo.TagExportExcelVO;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
/**
 * @author PanZhibao
 * @Description
 * @createTime 2024年08月22日
 */
@Schema(description = "导出 - ModBusTag信息")
@Data
public class ModBusTagExportExcelVO extends TagExportExcelVO {
    @Schema(description = "地址")
    @ExcelProperty(value = "地址",index = 3)
    private String address;
    @Schema(description = "大小端")
    @ExcelProperty(value = "大小端",index = 4)
    private String format;
    @Schema(description = "采集频率")
    @ExcelProperty(value = "采集频率",index = 5)
    private Integer samplingRate;
}
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/modbus/vo/ModBusTagImportExcelVO.java
对比新文件
@@ -0,0 +1,31 @@
package com.iailab.module.data.channel.modbus.vo;
import com.alibaba.excel.annotation.ExcelProperty;
import com.iailab.module.data.channel.tag.vo.TagImportExcelVO;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import lombok.experimental.SuperBuilder;
/**
 * 用户 Excel 导入 VO
 * @author Jay
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
@Accessors(chain = false) // 设置 chain = false,避免用户导入有问题
@SuperBuilder
public class ModBusTagImportExcelVO extends TagImportExcelVO {
    @ExcelProperty(value = "地址", index = 3)
    private String address;
    @ExcelProperty(value = "大小端", index = 4)
    private String format;
    @ExcelProperty(value = "采集频率", index = 5)
    private Integer samplingRate;
}
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/modbus/vo/ModBusTagPageReqVO.java
@@ -24,4 +24,6 @@
    private String tagDesc;
    private String device;
    private String deviceId;
}
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/modbus/vo/ModBusTagRespVO.java
@@ -31,7 +31,11 @@
    @Schema(description = "是否启用", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
    @ExcelProperty("是否启用")
    private Boolean enabled;
    private Integer enabled;
    @Schema(description = "数据值", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
    @ExcelProperty("数据值")
    private Double dataValue;
    @Schema(description = "大小端", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
    @ExcelProperty("大小端")
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/opcda/controller/admin/ChannelOPCDATagController.java
@@ -1,22 +1,45 @@
package com.iailab.module.data.channel.opcda.controller.admin;
import com.iailab.framework.apilog.core.annotation.ApiAccessLog;
import com.iailab.framework.common.pojo.CommonResult;
import com.iailab.framework.common.pojo.PageParam;
import com.iailab.framework.common.pojo.PageResult;
import com.iailab.framework.common.util.object.BeanUtils;
import com.iailab.module.data.channel.opcda.collector.OpcDACollector;
import com.iailab.module.data.channel.opcda.entity.ChannelOPCDADeviceEntity;
import com.iailab.framework.common.util.object.ConvertUtils;
import com.iailab.framework.excel.core.util.ExcelUtils;
import com.iailab.module.data.channel.opcda.entity.ChannelOPCDATagEntity;
import com.iailab.module.data.channel.opcda.service.ChannelOPCDADeviceService;
import com.iailab.module.data.channel.opcda.service.ChannelOPCDATagService;
import com.iailab.module.data.channel.opcda.vo.OpcDaTagExportExcelVO;
import com.iailab.module.data.channel.opcda.vo.OpcDaTagImportExcelVO;
import com.iailab.module.data.channel.opcda.vo.OpcDaTagPageReqVO;
import com.iailab.module.data.channel.opcda.vo.OpcDaTagRespVO;
import com.iailab.module.data.common.enums.DataSourceType;
import com.iailab.module.data.channel.tag.vo.TagImportRespVO;
import com.iailab.module.data.common.exception.RRException;
import com.iailab.module.data.common.utils.TagUtils;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.util.ArrayList;
import java.io.IOException;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import java.util.UUID;
import java.util.stream.Collectors;
import static com.iailab.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
import static com.iailab.framework.common.pojo.CommonResult.success;
/**
@@ -31,21 +54,44 @@
    @Autowired
    private ChannelOPCDATagService channelOPCDATagService;
    @PreAuthorize("@ss.hasPermission('data:channel-opcua:query')")
    @Autowired
    private OpcDACollector opcDACollector;
    @Autowired
    private ChannelOPCDADeviceService channelOPCDADeviceService;
    @PreAuthorize("@ss.hasPermission('data:channel-opcda:query')")
    @GetMapping("page")
    public CommonResult<PageResult<OpcDaTagRespVO>> list(@Valid OpcDaTagPageReqVO reqVO) {
        PageResult<ChannelOPCDATagEntity> page = channelOPCDATagService.queryPage(reqVO);
        return success(BeanUtils.toBean(page, OpcDaTagRespVO.class));
        PageResult<OpcDaTagRespVO> pageResultVO = new PageResult<>();
        pageResultVO.setTotal(page.getTotal());
        List<OpcDaTagRespVO> vos = page.getList().stream().map(entity -> {
            OpcDaTagRespVO vo = BeanUtils.toBean(entity,OpcDaTagRespVO.class);
            List<String[]> tags = new ArrayList<>();
            String[] array  = {reqVO.getServerId(),entity.getTagName()};
            tags.add(array);
            ChannelOPCDADeviceEntity OPCDADevice = channelOPCDADeviceService.info(reqVO.getServerId());
            vo.setDataValue(Double.parseDouble(opcDACollector.getTagValues(tags).get(TagUtils.genTagId(DataSourceType.OPCDA.getCode(), OPCDADevice.getServerName(),entity.getTagName())).toString()));
            return vo;
        }).collect(Collectors.toList());
        pageResultVO.setList(vos);
        return success(pageResultVO);
    }
    @PreAuthorize("@ss.hasPermission('data:channel-opcua:query')")
    @PreAuthorize("@ss.hasPermission('data:channel-opcda:query')")
    @GetMapping("/info/{id}")
    public CommonResult<ChannelOPCDATagEntity> info(@PathVariable("id") String id) {
        ChannelOPCDATagEntity info = channelOPCDATagService.info(id);
        return success(info);
    }
    @PreAuthorize("@ss.hasPermission('data:channel-opcua:create')")
    @PreAuthorize("@ss.hasPermission('data:channel-opcda:create')")
    @PostMapping("/create")
    public CommonResult<Boolean> create(@RequestBody ChannelOPCDATagEntity channelOPCDATagEntity) {
        String id = UUID.randomUUID().toString();
@@ -55,7 +101,7 @@
        return success(true);
    }
    @PreAuthorize("@ss.hasPermission('data:channel-opcua:update')")
    @PreAuthorize("@ss.hasPermission('data:channel-opcda:update')")
    @PutMapping("/update")
    public CommonResult<Boolean> update(@RequestBody ChannelOPCDATagEntity channelOPCDATagEntity) {
        channelOPCDATagEntity.setUpdateTime(new Date());
@@ -63,7 +109,7 @@
        return success(true);
    }
    @PreAuthorize("@ss.hasPermission('data:channel-opcua:delete')")
    @PreAuthorize("@ss.hasPermission('data:channel-opcda:delete')")
    @DeleteMapping("/delete")
    public CommonResult<Boolean> delete(@RequestParam("id") String id) {
        channelOPCDATagService.delete(id);
@@ -82,4 +128,42 @@
        }
        return success("上传成功");
    }
    @GetMapping("/export")
    @Operation(summary = "导出modbus tag列表")
    @PreAuthorize("@ss.hasPermission('data:channel-opcda-tag:export')")
    @ApiAccessLog(operateType = EXPORT)
    public void exportPointList(@Validated OpcDaTagPageReqVO reqVO, HttpServletResponse response) throws IOException {
        reqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
        PageResult<ChannelOPCDATagEntity> page = channelOPCDATagService.queryPage(reqVO);
        List<OpcDaTagExportExcelVO> list = ConvertUtils.sourceToTarget(page.getList(), OpcDaTagExportExcelVO.class);
        ExcelUtils.write(response, "tag列表.xls", "数据", OpcDaTagExportExcelVO.class, list, true);
    }
    @GetMapping("/get-import-template")
    @Operation(summary = "获得tag导入模板")
    public void importTemplate(HttpServletResponse response) throws IOException {
        // 手动创建导出 demo
        List<OpcDaTagImportExcelVO> list = Collections.singletonList(
                OpcDaTagImportExcelVO.builder().tagName("Tag名称").dataType("String").enabled(1)
                        .build()
        );
        // 输出
        ExcelUtils.write(response, "tag导入模板.xls", "tag列表", OpcDaTagImportExcelVO.class, list,true);
    }
    @PostMapping("/import")
    @Operation(summary = "导入tag")
    @Parameters({
            @Parameter(name = "file", description = "Excel 文件", required = true),
            @Parameter(name = "updateSupport", description = "是否支持更新,默认为 false", example = "true")
    })
    @PreAuthorize("@ss.hasPermission('data:channel-opcda-tag:import')")
    public CommonResult<TagImportRespVO> importExcel(@RequestParam("file") MultipartFile file,
                                                     @RequestParam(value = "updateSupport", required = false, defaultValue = "false") Boolean updateSupport,
                                                     @RequestParam("device") String device) throws Exception {
        List<OpcDaTagImportExcelVO> list = ExcelUtils.read(file, OpcDaTagImportExcelVO.class);
        return success(channelOPCDATagService.importOpcDaTagList(list, updateSupport,device));
    }
}
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/opcda/entity/ChannelOPCDATagEntity.java
@@ -42,7 +42,7 @@
    /**
     * 是否可以tag,如果为false,即使定义了但是runtime不会读取该数据
     */
    private Boolean enabled;
    private Integer enabled;
    /**
     * itemId
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/opcda/service/ChannelOPCDADeviceService.java
@@ -18,6 +18,8 @@
    List<ChannelOPCDADeviceDTO> selectAll();
    List<ChannelOPCDADeviceEntity> list(Map<String, Object> params);
    PageResult<ChannelOPCDADeviceEntity> queryPage(OpcDaDevicePageReqVO reqVO);
    ChannelOPCDADeviceEntity info(String id);
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/opcda/service/ChannelOPCDATagService.java
@@ -3,12 +3,12 @@
import com.iailab.framework.common.pojo.PageResult;
import com.iailab.module.data.channel.opcda.dto.ChannelOPCDATagDTO;
import com.iailab.module.data.channel.opcda.entity.ChannelOPCDATagEntity;
import com.iailab.module.data.channel.opcda.vo.OpcDaTagImportExcelVO;
import com.iailab.module.data.channel.opcda.vo.OpcDaTagPageReqVO;
import com.iailab.module.data.common.utils.PageUtils;
import com.iailab.module.data.channel.tag.vo.TagImportRespVO;
import org.springframework.web.multipart.MultipartFile;
import java.util.List;
import java.util.Map;
/**
 * @author lirm
@@ -36,4 +36,7 @@
    void update(ChannelOPCDATagEntity channelOPCDATagEntity);
    void delete(String id);
    TagImportRespVO importOpcDaTagList(List<OpcDaTagImportExcelVO> importTags, boolean isUpdateSupport, String serverId);
}
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/opcda/service/impl/ChannelOPCDADeviceServiceImpl.java
@@ -40,6 +40,13 @@
    }
    @Override
    public List<ChannelOPCDADeviceEntity> list(Map<String, Object> params) {
        QueryWrapper<ChannelOPCDADeviceEntity> queryWrapper = new QueryWrapper<>();
        queryWrapper.orderByDesc("create_time");
        return channelOPCDADeviceDao.selectList(queryWrapper);
    }
    @Override
    public ChannelOPCDADeviceEntity info(String id) {
        return channelOPCDADeviceDao.selectById(id);
    }
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/opcda/service/impl/ChannelOPCDATagServiceImpl.java
@@ -1,16 +1,21 @@
package com.iailab.module.data.channel.opcda.service.impl;
import cn.hutool.core.collection.CollUtil;
import com.baomidou.dynamic.datasource.annotation.DSTransactional;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.iailab.framework.common.pojo.PageResult;
import com.iailab.framework.common.util.object.BeanUtils;
import com.iailab.framework.common.util.object.ConvertUtils;
import com.iailab.module.data.channel.opcda.dao.ChannelOPCDATagDao;
import com.iailab.module.data.channel.opcda.dto.ChannelOPCDATagDTO;
import com.iailab.module.data.channel.opcda.entity.ChannelOPCDATagEntity;
import com.iailab.module.data.channel.opcda.service.ChannelOPCDATagService;
import com.iailab.module.data.channel.opcda.vo.OpcDaTagImportExcelVO;
import com.iailab.module.data.channel.opcda.vo.OpcDaTagPageReqVO;
import com.iailab.module.data.channel.tag.vo.TagImportRespVO;
import com.iailab.module.data.common.enums.CommonConstant;
import lombok.extern.slf4j.Slf4j;
import org.apache.poi.ss.usermodel.CellType;
import org.apache.poi.xssf.usermodel.XSSFRow;
@@ -23,9 +28,10 @@
import javax.annotation.Resource;
import java.io.File;
import java.io.FileInputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import java.util.*;
import static com.iailab.framework.common.exception.util.ServiceExceptionUtil.exception;
import static com.iailab.module.data.enums.ErrorCodeConstants.*;
/**
 * @author lirm
@@ -116,7 +122,7 @@
                tagEntity.setTagName(row.getCell(1).getStringCellValue());
                tagEntity.setDataType(row.getCell(2).getStringCellValue());
                tagEntity.setItemId(row.getCell(3).getStringCellValue());
                tagEntity.setEnabled(true);
                tagEntity.setEnabled(CommonConstant.IS_ENABLE);
                tagEntity.setServerId(serverId);
                dangerList.add(tagEntity);
            }
@@ -138,4 +144,44 @@
        }
    }
    @Override
    public TagImportRespVO importOpcDaTagList(List<OpcDaTagImportExcelVO> importTags, boolean isUpdateSupport, String serverId) {
        // 1.1 参数校验
        if (CollUtil.isEmpty(importTags)) {
            throw exception(TAG_IMPORT_LIST_IS_EMPTY);
        }
        // 2. 遍历,逐个创建 or 更新
        TagImportRespVO respVO = TagImportRespVO.builder().createTagNames(new ArrayList<>())
                .updateTagNames(new ArrayList<>()).failureTagNames(new LinkedHashMap<>()).build();
        importTags.forEach(importTag -> {
            // 判断如果不存在,再进行插入
            ChannelOPCDATagEntity existTag = channelOPCDATagDao.selectOne(new QueryWrapper<ChannelOPCDATagEntity>()
                    .eq("server_id", serverId)
                    .eq("tag_name",importTag.getTagName()));
            if (existTag == null) {
                ChannelOPCDATagEntity channelOPCDATagEntity = ConvertUtils.sourceToTarget(importTag, ChannelOPCDATagEntity.class);
                channelOPCDATagEntity.setId(UUID.randomUUID().toString());
                channelOPCDATagEntity.setEnabled(CommonConstant.IS_ENABLE);
                channelOPCDATagEntity.setServerId(serverId);
                channelOPCDATagEntity.setCreateTime(new Date());
                channelOPCDATagDao.insert(channelOPCDATagEntity);
                respVO.getCreateTagNames().add(channelOPCDATagEntity.getTagName());
                return;
            }
            // 如果存在,判断是否允许更新
            if (!isUpdateSupport) {
                respVO.getFailureTagNames().put(importTag.getTagName(), TAG_EXISTS.getMsg());
                return;
            }
            ChannelOPCDATagEntity updateTag = BeanUtils.toBean(importTag, ChannelOPCDATagEntity.class);
            updateTag.setId(existTag.getId());
            baseMapper.updateById(updateTag);
            respVO.getUpdateTagNames().add(importTag.getTagName());
        });
        return respVO;
    }
}
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/opcda/vo/OpcDaTagExportExcelVO.java
对比新文件
@@ -0,0 +1,51 @@
package com.iailab.module.data.channel.opcda.vo;
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import com.alibaba.excel.annotation.ExcelProperty;
import com.iailab.framework.excel.core.annotations.DictFormat;
import com.iailab.framework.excel.core.annotations.ExcelColumnSelect;
import com.iailab.framework.excel.core.convert.DictConvert;
import com.iailab.framework.excel.core.function.ExcelColumnSelectFunction;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import org.springframework.stereotype.Component;
import java.util.List;
/**
 * @author PanZhibao
 * @Description
 * @createTime 2024年08月22日
 */
@Schema(description = "导出 - Tag信息")
@Data
@ExcelIgnoreUnannotated
@Component
public class OpcDaTagExportExcelVO implements ExcelColumnSelectFunction {
    @Schema(description = "Tag名称")
    @ExcelProperty(value = "Tag名称")
    private String tagName;
    @Schema(description = "数据类型")
    @ExcelProperty(value = "数据类型", converter = DictConvert.class)
    @ExcelColumnSelect(dictType = "tag_data_type")
    @DictFormat("tag_data_type")
    private String dataType;
    @Schema(description = "是否启用")
    @ExcelProperty(value = "是否启用", converter = DictConvert.class)
    @ExcelColumnSelect(dictType = "com_is_int")
    @DictFormat("com_is_int")
    private Integer enabled;
    @Override
    public String getName() {
        return null;
    }
    @Override
    public List<String> getOptions() {
        return null;
    }
}
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/opcda/vo/OpcDaTagImportExcelVO.java
对比新文件
@@ -0,0 +1,53 @@
package com.iailab.module.data.channel.opcda.vo;
import com.alibaba.excel.annotation.ExcelProperty;
import com.iailab.framework.excel.core.annotations.DictFormat;
import com.iailab.framework.excel.core.annotations.ExcelColumnSelect;
import com.iailab.framework.excel.core.convert.DictConvert;
import com.iailab.framework.excel.core.function.ExcelColumnSelectFunction;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import lombok.experimental.SuperBuilder;
import org.springframework.stereotype.Component;
import java.util.List;
/**
 * 用户 Excel 导入 VO
 * @author Jay
 */
@Data
@SuperBuilder
@AllArgsConstructor
@NoArgsConstructor
@Accessors(chain = false) // 设置 chain = false,避免用户导入有问题
@Component
public class OpcDaTagImportExcelVO implements ExcelColumnSelectFunction {
    @ExcelProperty(value = "Tag名称")
    private String tagName;
    @ExcelProperty(value = "数据类型")
    @ExcelColumnSelect(dictType = "tag_data_type")
    @DictFormat("tag_data_type")
    private String dataType;
    @Schema(description = "是否启用")
    @ExcelProperty(value = "是否启用", converter = DictConvert.class)
    @ExcelColumnSelect(dictType = "com_is_int")
    @DictFormat("com_is_int")
    private Integer enabled;
    @Override
    public String getName() {
        return null;
    }
    @Override
    public List<String> getOptions() {
        return null;
    }
}
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/opcda/vo/OpcDaTagRespVO.java
@@ -35,7 +35,11 @@
    @Schema(description = "是否启用", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
    @ExcelProperty("是否启用")
    private Boolean enabled;
    private Integer enabled;
    @Schema(description = "数据值", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
    @ExcelProperty("数据值")
    private Double dataValue;
    @Schema(description = "itemID", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
    @ExcelProperty("itemID")
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/opcua/controller/admin/ChannelOPCUATagController.java
@@ -1,20 +1,41 @@
package com.iailab.module.data.channel.opcua.controller.admin;
import com.iailab.framework.apilog.core.annotation.ApiAccessLog;
import com.iailab.framework.common.pojo.CommonResult;
import com.iailab.framework.common.pojo.PageParam;
import com.iailab.framework.common.pojo.PageResult;
import com.iailab.framework.common.util.object.BeanUtils;
import com.iailab.framework.common.util.object.ConvertUtils;
import com.iailab.framework.excel.core.util.ExcelUtils;
import com.iailab.module.data.channel.opcua.collector.OpcUaCollector;
import com.iailab.framework.common.util.object.ConvertUtils;
import com.iailab.framework.excel.core.util.ExcelUtils;
import com.iailab.module.data.channel.opcua.entity.ChannelOPCUATagEntity;
import com.iailab.module.data.channel.opcua.service.ChannelOPCUATagService;
import com.iailab.module.data.channel.opcua.vo.OpcUaTagExportExcelVO;
import com.iailab.module.data.channel.opcua.vo.OpcUaTagImportExcelVO;
import com.iailab.module.data.channel.opcua.vo.OpcUaTagPageReqVO;
import com.iailab.module.data.channel.opcua.vo.OpcUaTagRespVO;
import com.iailab.module.data.channel.tag.vo.TagImportRespVO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.io.IOException;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import java.util.UUID;
import java.util.stream.Collectors;
import static com.iailab.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
import static com.iailab.framework.common.pojo.CommonResult.success;
/**
@@ -29,11 +50,31 @@
    @Resource
    private ChannelOPCUATagService channelOpcuaTagService;
    @Resource
    private OpcUaCollector opcUaCollector;
    @PreAuthorize("@ss.hasPermission('data:channel-opcua:query')")
    @GetMapping("page")
    public CommonResult<PageResult<OpcUaTagRespVO>> list(@Valid OpcUaTagPageReqVO reqVO) {
        PageResult<ChannelOPCUATagEntity> page = channelOpcuaTagService.queryPage(reqVO);
        return success(BeanUtils.toBean(page, OpcUaTagRespVO.class));
        PageResult<OpcUaTagRespVO> pageResultVO = new PageResult<>();
        pageResultVO.setTotal(page.getTotal());
        List<OpcUaTagRespVO> vos = page.getList().stream().map(entity -> {
            OpcUaTagRespVO vo = BeanUtils.toBean(entity,OpcUaTagRespVO.class);
            try{
                vo.setDataValue( Double.parseDouble(opcUaCollector.getTagValue(reqVO.getDeviceId(),entity.getTagName())));
            }catch (Exception e){
                e.printStackTrace();
            }
            return vo;
        }).collect(Collectors.toList());
        pageResultVO.setList(vos);
        return success(pageResultVO);
    }
    @PreAuthorize("@ss.hasPermission('data:channel-opcua:query')")
@@ -68,16 +109,40 @@
        return success(true);
    }
//    @PostMapping("/import/{device}")
//    public R importTag(@PathVariable("device") String device, @RequestParam("file") MultipartFile file) {
//        try {
//            if (file.isEmpty()) {
//                throw new RRException("上传文件不能为空");
//            }
//            channelOpcuaTagService.importTag(device, file);
//        } catch (Exception ex) {
//            return R.error(ex.getMessage());
//        }
//        return R.ok();
//    }
    @GetMapping("/export")
    @Operation(summary = "导出modbus tag列表")
    @PreAuthorize("@ss.hasPermission('data:channel-opcua-tag:export')")
    @ApiAccessLog(operateType = EXPORT)
    public void exportPointList(@Validated OpcUaTagPageReqVO reqVO, HttpServletResponse response) throws IOException {
        reqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
        PageResult<ChannelOPCUATagEntity> page = channelOpcuaTagService.queryPage(reqVO);
        List<OpcUaTagExportExcelVO> list = ConvertUtils.sourceToTarget(page.getList(), OpcUaTagExportExcelVO.class);
        ExcelUtils.write(response, "tag列表.xls", "数据", OpcUaTagExportExcelVO.class, list, true);
    }
    @GetMapping("/get-import-template")
    @Operation(summary = "获得tag导入模板")
    public void importTemplate(HttpServletResponse response) throws IOException {
        // 手动创建导出 demo
        List<OpcUaTagImportExcelVO> list = Collections.singletonList(
                OpcUaTagImportExcelVO.builder().tagName("Tag名称").dataType("String").address("123").samplingRate(1000).enabled(1)
                        .build()
        );
        // 输出
        ExcelUtils.write(response, "tag导入模板.xls", "tag列表", OpcUaTagImportExcelVO.class, list,true);
    }
    @PostMapping("/import")
    @Operation(summary = "导入tag")
    @Parameters({
            @Parameter(name = "file", description = "Excel 文件", required = true),
            @Parameter(name = "updateSupport", description = "是否支持更新,默认为 false", example = "true")
    })
    @PreAuthorize("@ss.hasPermission('data:channel-opcua-tag:import')")
    public CommonResult<TagImportRespVO> importExcel(@RequestParam("file") MultipartFile file,
                                                     @RequestParam(value = "updateSupport", required = false, defaultValue = "false") Boolean updateSupport,
                                                     @RequestParam("device") String device) throws Exception {
        List<OpcUaTagImportExcelVO> list = ExcelUtils.read(file, OpcUaTagImportExcelVO.class);
        return success(channelOpcuaTagService.importOpcUaTagList(list, updateSupport,device));
    }
}
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/opcua/entity/ChannelOPCUATagEntity.java
@@ -38,7 +38,7 @@
    /**
     * 是否可以tag,如果为false,即使定义了但是runtime不会读取该数据
     */
    private Boolean enabled;
    private Integer enabled;
    /**
     * 关联设备
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/opcua/service/ChannelOPCUATagService.java
@@ -3,7 +3,9 @@
import com.iailab.framework.common.pojo.PageResult;
import com.iailab.module.data.channel.opcua.dto.ChannelOPCUATagDTO;
import com.iailab.module.data.channel.opcua.entity.ChannelOPCUATagEntity;
import com.iailab.module.data.channel.opcua.vo.OpcUaTagImportExcelVO;
import com.iailab.module.data.channel.opcua.vo.OpcUaTagPageReqVO;
import com.iailab.module.data.channel.tag.vo.TagImportRespVO;
import org.springframework.web.multipart.MultipartFile;
import java.util.List;
@@ -34,4 +36,6 @@
    void importTag(String device, MultipartFile file) throws Exception;
    TagImportRespVO importOpcUaTagList(List<OpcUaTagImportExcelVO> importTags, boolean isUpdateSupport, String device);
}
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/opcua/service/impl/ChannelOPCUATagServiceImpl.java
@@ -1,16 +1,21 @@
package com.iailab.module.data.channel.opcua.service.impl;
import cn.hutool.core.collection.CollUtil;
import com.baomidou.dynamic.datasource.annotation.DSTransactional;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.iailab.framework.common.pojo.PageResult;
import com.iailab.framework.common.util.object.BeanUtils;
import com.iailab.framework.common.util.object.ConvertUtils;
import com.iailab.module.data.channel.opcua.dao.ChannelOPCUATagDao;
import com.iailab.module.data.channel.opcua.dto.ChannelOPCUATagDTO;
import com.iailab.module.data.channel.opcua.entity.ChannelOPCUATagEntity;
import com.iailab.module.data.channel.opcua.service.ChannelOPCUATagService;
import com.iailab.module.data.channel.opcua.vo.OpcUaTagImportExcelVO;
import com.iailab.module.data.channel.opcua.vo.OpcUaTagPageReqVO;
import com.iailab.module.data.channel.tag.vo.TagImportRespVO;
import com.iailab.module.data.common.enums.CommonConstant;
import lombok.extern.slf4j.Slf4j;
import org.apache.poi.ss.usermodel.CellType;
import org.apache.poi.xssf.usermodel.XSSFRow;
@@ -23,9 +28,10 @@
import javax.annotation.Resource;
import java.io.File;
import java.io.FileInputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import java.util.*;
import static com.iailab.framework.common.exception.util.ServiceExceptionUtil.exception;
import static com.iailab.module.data.enums.ErrorCodeConstants.*;
/**
 * @author lirm
@@ -122,7 +128,7 @@
                }else if(row.getCell(3).getStringCellValue().equals("3")){
                    tagEntity.setAddress(String.format("4%04d",Integer.parseInt(row.getCell(4).getStringCellValue())));
                }
                tagEntity.setEnabled(true);
                tagEntity.setEnabled(1);
                tagEntity.setDevice(device);
                tagEntity.setSamplingRate(1);
                dangerList.add(tagEntity);
@@ -144,4 +150,44 @@
            throw ex;
        }
    }
    @Override
    public TagImportRespVO importOpcUaTagList(List<OpcUaTagImportExcelVO> importTags, boolean isUpdateSupport, String device) {
        // 1.1 参数校验
        if (CollUtil.isEmpty(importTags)) {
            throw exception(TAG_IMPORT_LIST_IS_EMPTY);
        }
        // 2. 遍历,逐个创建 or 更新
        TagImportRespVO respVO = TagImportRespVO.builder().createTagNames(new ArrayList<>())
                .updateTagNames(new ArrayList<>()).failureTagNames(new LinkedHashMap<>()).build();
        importTags.forEach(importTag -> {
            // 判断如果不存在,再进行插入
            ChannelOPCUATagEntity existTag = channelOPCUATagDao.selectOne(new QueryWrapper<ChannelOPCUATagEntity>()
                    .eq("device", device)
                    .eq("tag_name",importTag.getTagName()));
            if (existTag == null) {
                ChannelOPCUATagEntity channelOpCuaTagEntity = ConvertUtils.sourceToTarget(importTag, ChannelOPCUATagEntity.class);
                channelOpCuaTagEntity.setId(UUID.randomUUID().toString());
                channelOpCuaTagEntity.setEnabled(CommonConstant.IS_ENABLE);
                channelOpCuaTagEntity.setDevice(device);
                channelOpCuaTagEntity.setCreateTime(new Date());
                channelOPCUATagDao.insert(channelOpCuaTagEntity);
                respVO.getCreateTagNames().add(channelOpCuaTagEntity.getTagName());
                return;
            }
            // 如果存在,判断是否允许更新
            if (!isUpdateSupport) {
                respVO.getFailureTagNames().put(importTag.getTagName(), TAG_EXISTS.getMsg());
                return;
            }
            ChannelOPCUATagEntity updateTag = BeanUtils.toBean(importTag, ChannelOPCUATagEntity.class);
            updateTag.setId(existTag.getId());
            baseMapper.updateById(updateTag);
            respVO.getUpdateTagNames().add(importTag.getTagName());
        });
        return respVO;
    }
}
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/opcua/vo/OpcUaTagExportExcelVO.java
对比新文件
@@ -0,0 +1,59 @@
package com.iailab.module.data.channel.opcua.vo;
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import com.alibaba.excel.annotation.ExcelProperty;
import com.iailab.framework.excel.core.annotations.DictFormat;
import com.iailab.framework.excel.core.annotations.ExcelColumnSelect;
import com.iailab.framework.excel.core.convert.DictConvert;
import com.iailab.framework.excel.core.function.ExcelColumnSelectFunction;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import org.springframework.stereotype.Component;
import java.util.List;
/**
 * @author PanZhibao
 * @Description
 * @createTime 2024年08月22日
 */
@Schema(description = "导出 - Tag信息")
@Data
@ExcelIgnoreUnannotated
@Component
public class OpcUaTagExportExcelVO implements ExcelColumnSelectFunction {
    @Schema(description = "Tag名称")
    @ExcelProperty(value = "Tag名称")
    private String tagName;
    @Schema(description = "数据类型")
    @ExcelProperty(value = "数据类型", converter = DictConvert.class)
    @ExcelColumnSelect(dictType = "tag_data_type")
    @DictFormat("tag_data_type")
    private String dataType;
    @Schema(description = "地址")
    @ExcelProperty(value = "地址")
    private String address;
    @Schema(description = "采集频率")
    @ExcelProperty(value = "采集频率")
    private Integer samplingRate;
    @Schema(description = "是否启用")
    @ExcelProperty(value = "是否启用", converter = DictConvert.class)
    @ExcelColumnSelect(dictType = "com_is_int")
    @DictFormat("com_is_int")
    private Integer enabled;
    @Override
    public String getName() {
        return null;
    }
    @Override
    public List<String> getOptions() {
        return null;
    }
}
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/opcua/vo/OpcUaTagImportExcelVO.java
对比新文件
@@ -0,0 +1,61 @@
package com.iailab.module.data.channel.opcua.vo;
import com.alibaba.excel.annotation.ExcelProperty;
import com.iailab.framework.excel.core.annotations.DictFormat;
import com.iailab.framework.excel.core.annotations.ExcelColumnSelect;
import com.iailab.framework.excel.core.convert.DictConvert;
import com.iailab.framework.excel.core.function.ExcelColumnSelectFunction;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import lombok.experimental.SuperBuilder;
import org.springframework.stereotype.Component;
import java.util.List;
/**
 * 用户 Excel 导入 VO
 * @author Jay
 */
@Data
@SuperBuilder
@AllArgsConstructor
@NoArgsConstructor
@Accessors(chain = false) // 设置 chain = false,避免用户导入有问题
@Component
public class OpcUaTagImportExcelVO implements ExcelColumnSelectFunction {
    @ExcelProperty(value = "Tag名称")
    private String tagName;
    @ExcelProperty(value = "数据类型")
    @ExcelColumnSelect(dictType = "tag_data_type")
    @DictFormat("tag_data_type")
    private String dataType;
    @Schema(description = "地址")
    @ExcelProperty(value = "地址")
    private String address;
    @Schema(description = "采集频率")
    @ExcelProperty(value = "采集频率")
    private Integer samplingRate;
    @Schema(description = "是否启用")
    @ExcelProperty(value = "是否启用", converter = DictConvert.class)
    @ExcelColumnSelect(dictType = "com_is_int")
    @DictFormat("com_is_int")
    private Integer enabled;
    @Override
    public String getName() {
        return null;
    }
    @Override
    public List<String> getOptions() {
        return null;
    }
}
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/opcua/vo/OpcUaTagPageReqVO.java
@@ -20,4 +20,6 @@
    private String tagName;
    private String device;
    private String deviceId;
}
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/opcua/vo/OpcUaTagRespVO.java
@@ -31,7 +31,11 @@
    @Schema(description = "是否启用", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
    @ExcelProperty("是否启用")
    private Boolean enabled;
    private Integer enabled;
    @Schema(description = "数据值", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
    @ExcelProperty("数据值")
    private Double dataValue;
    @Schema(description = "关联设备", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
    @ExcelProperty("关联设备")
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/tag/vo/TagExportExcelVO.java
对比新文件
@@ -0,0 +1,55 @@
package com.iailab.module.data.channel.tag.vo;
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import com.alibaba.excel.annotation.ExcelProperty;
import com.iailab.framework.excel.core.annotations.DictFormat;
import com.iailab.framework.excel.core.annotations.ExcelColumnSelect;
import com.iailab.framework.excel.core.convert.DictConvert;
import com.iailab.framework.excel.core.function.ExcelColumnSelectFunction;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import org.springframework.stereotype.Component;
import java.util.List;
/**
 * @author PanZhibao
 * @Description
 * @createTime 2024年08月22日
 */
@Schema(description = "导出 - Tag信息")
@Data
@ExcelIgnoreUnannotated
@Component
public class TagExportExcelVO implements ExcelColumnSelectFunction {
    @Schema(description = "Tag名称")
    @ExcelProperty(value = "Tag名称", index = 0)
    private String tagName;
    @Schema(description = "Tag描述")
    @ExcelProperty(value = "Tag描述", index = 1)
    private String tagDesc;
    @Schema(description = "数据类型")
    @ExcelProperty(value = "数据类型", index = 2, converter = DictConvert.class)
    @ExcelColumnSelect(dictType = "tag_data_type")
    @DictFormat("tag_data_type")
    private String dataType;
    @Schema(description = "是否启用")
    @ExcelProperty(value = "是否启用", converter = DictConvert.class)
    @ExcelColumnSelect(dictType = "com_is_int")
    @DictFormat("com_is_int")
    private Integer enabled;
    @Override
    public String getName() {
        return null;
    }
    @Override
    public List<String> getOptions() {
        return null;
    }
}
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/tag/vo/TagImportExcelVO.java
对比新文件
@@ -0,0 +1,56 @@
package com.iailab.module.data.channel.tag.vo;
import com.alibaba.excel.annotation.ExcelProperty;
import com.iailab.framework.excel.core.annotations.DictFormat;
import com.iailab.framework.excel.core.annotations.ExcelColumnSelect;
import com.iailab.framework.excel.core.convert.DictConvert;
import com.iailab.framework.excel.core.function.ExcelColumnSelectFunction;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import lombok.experimental.SuperBuilder;
import org.springframework.stereotype.Component;
import java.util.List;
/**
 * 用户 Excel 导入 VO
 * @author Jay
 */
@Data
@SuperBuilder
@AllArgsConstructor
@NoArgsConstructor
@Accessors(chain = false) // 设置 chain = false,避免用户导入有问题
@Component
public class TagImportExcelVO  implements ExcelColumnSelectFunction {
    @ExcelProperty(value = "Tag名称", index = 0)
    private String tagName;
    @ExcelProperty(value = "Tag描述", index = 1)
    private String tagDesc;
    @ExcelProperty(value = "数据类型", index = 2)
    @ExcelColumnSelect(dictType = "tag_data_type")
    @DictFormat("tag_data_type")
    private String dataType;
    @Schema(description = "是否启用")
    @ExcelProperty(value = "是否启用", converter = DictConvert.class)
    @ExcelColumnSelect(dictType = "com_is_int")
    @DictFormat("com_is_int")
    private Integer enabled;
    @Override
    public String getName() {
        return null;
    }
    @Override
    public List<String> getOptions() {
        return null;
    }
}
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/tag/vo/TagImportRespVO.java
对比新文件
@@ -0,0 +1,26 @@
package com.iailab.module.data.channel.tag.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Builder;
import lombok.Data;
import java.util.List;
import java.util.Map;
/**
 * @author Jay
 */
@Schema(description = "管理后台 - 用户导入 Response VO")
@Data
@Builder
public class TagImportRespVO {
    @Schema(description = "创建成功的Tag名称数组", requiredMode = Schema.RequiredMode.REQUIRED)
    private List<String> createTagNames;
    @Schema(description = "更新成功的Tag名称数组", requiredMode = Schema.RequiredMode.REQUIRED)
    private List<String> updateTagNames;
    @Schema(description = "导入失败的Tag集合,key 为Tag名称,value 为失败原因", requiredMode = Schema.RequiredMode.REQUIRED)
    private Map<String, String> failureTagNames;
}
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/enums/IncreaseCodeEnum.java
对比新文件
@@ -0,0 +1,11 @@
package com.iailab.module.data.common.enums;
/**
 * 编号自增主键
 *
 * @author PanZhibao
 * @date 2021年05月24日 9:41
 */
public enum IncreaseCodeEnum {
    POINT_M, POINT_C, POINT_F, IND_A, IND_D, IND_C, PLAN;
}
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/utils/ApiSecurityUtils.java
文件名从 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/api/utils/ApiSecurityUtils.java 修改
@@ -1,19 +1,14 @@
package com.iailab.module.data.api.utils;
package com.iailab.module.data.common.utils;
import com.iailab.framework.common.constant.Constant;
import com.iailab.framework.common.pojo.CommonResult;
import com.iailab.framework.security.core.LoginUser;
import com.iailab.framework.security.core.util.SecurityFrameworkUtils;
import com.iailab.framework.tenant.core.context.TenantContextHolder;
import com.iailab.module.system.api.user.AdminUserApi;
import com.iailab.module.system.api.user.dto.AdminUserRespDTO;
import org.apache.commons.lang3.StringUtils;
import javax.annotation.Resource;
import org.springframework.stereotype.Component;
import org.springframework.util.ObjectUtils;
import javax.servlet.http.HttpServletRequest;
import java.util.regex.Pattern;
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/utils/DateUtils.java
@@ -31,6 +31,8 @@
    public final static String DATE_PATTERN = "yyyy-MM-dd";
    /** 时间格式(yyyy-MM-dd HH:mm:ss) */
    public final static String DATE_TIME_PATTERN = "yyyy-MM-dd HH:mm:ss";
    /** 时间格式(yyyyMMddHHmmss) */
    public final static String DATE_NUMBER_PATTERN = "yyyyMMddHHmmss";
    /**
     * 日期格式化 日期格式为:yyyy-MM-dd
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/item/service/impl/IndItemServiceImpl.java
@@ -16,7 +16,7 @@
import com.iailab.module.data.ind.item.vo.IndItemPageReqVO;
import com.iailab.module.data.ind.item.vo.IndItemRespVO;
import com.iailab.module.data.ind.item.vo.IndItemSaveReqVO;
import com.iailab.module.data.point.common.IncreaseCodeEnum;
import com.iailab.module.data.common.enums.IncreaseCodeEnum;
import com.iailab.module.data.point.service.DaSequenceNumService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/task/DevCameraDahuaTask.java
@@ -74,6 +74,7 @@
                }
            }
            logger.info("devCameraDahuaTask定时任务执行完成:" + LocalDateTime.now());
        } catch (Exception ex) {
            ex.printStackTrace();
            logger.info("devCameraDahuaTask定时任务失败时间:" + LocalDateTime.now());
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/task/PointCollectTaskNet60.java
@@ -23,7 +23,7 @@
public class PointCollectTaskNet60 implements ITask {
    private final Logger logger = LoggerFactory.getLogger(getClass());
    private static final String NET = "1min";
    private static final String NET = "NET60";
    @Resource
    private PointCollector pointCollector;
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/utils/ScheduleJob.java
@@ -74,7 +74,7 @@
        }finally {
            //获取spring bean
            ScheduleJobLogService scheduleJobLogService = SpringContextUtils.getBean(ScheduleJobLogService.class);
            scheduleJobLogService.insert(log);
            //scheduleJobLogService.insert(log);
        }
    }
}
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/plan/category/controller/admin/PlanItemCategoryController.java
对比新文件
@@ -0,0 +1,88 @@
package com.iailab.module.data.plan.category.controller.admin;
import com.iailab.framework.common.pojo.CommonResult;
import com.iailab.framework.common.util.object.BeanUtils;
import com.iailab.module.data.plan.category.entity.PlanItemCategoryEntity;
import com.iailab.module.data.plan.category.service.PlanItemCategoryService;
import com.iailab.module.data.plan.category.vo.PlanItemCategoryReqVO;
import com.iailab.module.data.plan.category.vo.PlanItemCategoryRespVO;
import com.iailab.module.data.plan.category.vo.PlanItemCategorySaveReqVO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import java.util.Comparator;
import java.util.List;
import static com.iailab.framework.common.pojo.CommonResult.success;
/**
 * @author PanZhibao
 * @Description
 * @createTime 2024年11月01日
 */
@Tag(name = "数据平台 - 计划分类")
@RestController
@RequestMapping("/data/plan/category")
@Validated
public class PlanItemCategoryController {
    @Autowired
    private PlanItemCategoryService indItemCategoryService;
    @GetMapping("/list")
    @Operation(summary = "获取计划分类列表", description = "用于【计划分类】界面")
    @PreAuthorize("@ss.hasPermission('data:plan-item-category:query')")
    public CommonResult<List<PlanItemCategoryRespVO>> getList(PlanItemCategoryReqVO reqVO) {
        List<PlanItemCategoryEntity> list = indItemCategoryService.getList(reqVO);
        list.sort(Comparator.comparing(PlanItemCategoryEntity::getSort));
        return success(BeanUtils.toBean(list, PlanItemCategoryRespVO.class));
    }
    @GetMapping("/list-all-simple")
    @Operation(summary = "获取计划分类列表", description = "用于【计划分类】界面")
    @PreAuthorize("@ss.hasPermission('data:plan-item-category:query')")
    public CommonResult<List<PlanItemCategoryRespVO>> getList() {
        List<PlanItemCategoryEntity> list = indItemCategoryService.getSimpleList();
        list.sort(Comparator.comparing(PlanItemCategoryEntity::getSort));
        return success(BeanUtils.toBean(list, PlanItemCategoryRespVO.class));
    }
    @PostMapping("/create")
    @Operation(summary = "创建计划分类")
    @PreAuthorize("@ss.hasPermission('data:plan-item-category:create')")
    public CommonResult<Boolean> create(@Valid @RequestBody PlanItemCategorySaveReqVO createReqVO) {
        indItemCategoryService.create(createReqVO);
        return success(true);
    }
    @PutMapping("/update")
    @Operation(summary = "修改计划分类")
    @PreAuthorize("@ss.hasPermission('data:plan-item-category:update')")
    public CommonResult<Boolean> update(@Valid @RequestBody PlanItemCategorySaveReqVO updateReqVO) {
        indItemCategoryService.update(updateReqVO);
        return success(true);
    }
    @DeleteMapping("/delete")
    @Operation(summary = "删除计划分类")
    @Parameter(name = "id", description = "计划分类编号", required= true, example = "1024")
    @PreAuthorize("@ss.hasPermission('data:plan-item-category:delete')")
    public CommonResult<Boolean> delete(@RequestParam("id") String id) {
        indItemCategoryService.delete(id);
        return success(true);
    }
    @GetMapping("/get")
    @Operation(summary = "获取计划分类信息")
    @PreAuthorize("@ss.hasPermission('data:plan-item-category:query')")
    public CommonResult<PlanItemCategoryRespVO> get(String id) {
        PlanItemCategoryEntity entity = indItemCategoryService.get(id);
        return success(BeanUtils.toBean(entity, PlanItemCategoryRespVO.class));
    }
}
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/plan/category/controller/package-info.java
对比新文件
@@ -0,0 +1 @@
package com.iailab.module.data.plan.category.controller;
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/plan/category/dao/PlanItemCategoryDao.java
对比新文件
@@ -0,0 +1,26 @@
package com.iailab.module.data.plan.category.dao;
import com.iailab.framework.mybatis.core.mapper.BaseMapperX;
import com.iailab.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.iailab.framework.tenant.core.db.dynamic.TenantDS;
import com.iailab.module.data.plan.category.entity.PlanItemCategoryEntity;
import com.iailab.module.data.plan.category.vo.PlanItemCategoryReqVO;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
/**
 * @author PanZhibao
 * @Description
 * @createTime 2024年11月01日
 */
@TenantDS
@Mapper
public interface PlanItemCategoryDao extends BaseMapperX<PlanItemCategoryEntity> {
    default List<PlanItemCategoryEntity> selectList(PlanItemCategoryReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<PlanItemCategoryEntity>()
                .likeIfPresent(PlanItemCategoryEntity::getLabel, reqVO.getLabel()));
    }
}
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/plan/category/entity/PlanItemCategoryEntity.java
对比新文件
@@ -0,0 +1,65 @@
package com.iailab.module.data.plan.category.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
 * @author PanZhibao
 * @Description
 * @createTime 2024年11月01日
 */
@Data
@TableName("t_plan_item_category")
public class PlanItemCategoryEntity implements Serializable {
    private static final long serialVersionUID = 1L;
    public static final String ID_ROOT = "0";
    /**
     * 主键
     */
    @Schema(description = "主键")
    @TableId(value = "id",type = IdType.INPUT)
    private String id;
    /**
     * 标签
     */
    private String label;
    /**
     * 父ID
     */
    private String pid;
    /**
     * 排序
     */
    private Integer sort;
    /**
     * 创建者
     */
    private String creator;
    /**
     * 创建时间
     */
    private Date createTime;
    /**
     * 更新者
     */
    private String updater;
    /**
     * 更新时间
     */
    private Date updateTime;
}
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/plan/category/package-info.java
对比新文件
@@ -0,0 +1 @@
package com.iailab.module.data.plan.category;
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/plan/category/service/PlanItemCategoryService.java
对比新文件
@@ -0,0 +1,28 @@
package com.iailab.module.data.plan.category.service;
import com.iailab.module.data.plan.category.entity.PlanItemCategoryEntity;
import com.iailab.module.data.plan.category.vo.PlanItemCategoryReqVO;
import com.iailab.module.data.plan.category.vo.PlanItemCategorySaveReqVO;
import java.util.List;
/**
 * @author PanZhibao
 * @Description
 * @createTime 2024年11月01日
 */
public interface PlanItemCategoryService {
    List<PlanItemCategoryEntity> getList(PlanItemCategoryReqVO reqVO);
    List<PlanItemCategoryEntity> getSimpleList();
    void create(PlanItemCategorySaveReqVO createReqVO);
    void update(PlanItemCategorySaveReqVO updateReqVO);
    PlanItemCategoryEntity get(String id);
    void delete(String id);
}
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/plan/category/service/impl/PlanItemCategoryServiceImpl.java
对比新文件
@@ -0,0 +1,90 @@
package com.iailab.module.data.plan.category.service.impl;
import com.iailab.framework.common.util.object.BeanUtils;
import com.iailab.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.iailab.module.data.plan.category.dao.PlanItemCategoryDao;
import com.iailab.module.data.plan.category.entity.PlanItemCategoryEntity;
import com.iailab.module.data.plan.category.service.PlanItemCategoryService;
import com.iailab.module.data.plan.category.vo.PlanItemCategoryReqVO;
import com.iailab.module.data.plan.category.vo.PlanItemCategorySaveReqVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
import java.util.UUID;
import static com.iailab.framework.common.exception.util.ServiceExceptionUtil.exception;
import static com.iailab.module.data.plan.category.entity.PlanItemCategoryEntity.ID_ROOT;
import static com.iailab.module.system.enums.ErrorCodeConstants.MENU_PARENT_ERROR;
import static com.iailab.module.system.enums.ErrorCodeConstants.MENU_PARENT_NOT_EXISTS;
/**
 * @author PanZhibao
 * @Description
 * @createTime 2024年11月01日
 */
@Service
@Slf4j
public class PlanItemCategoryServiceImpl implements PlanItemCategoryService {
    @Resource
    private PlanItemCategoryDao planItemCategoryDao;
    @Override
    public List<PlanItemCategoryEntity> getList(PlanItemCategoryReqVO reqVO) {
        return planItemCategoryDao.selectList(reqVO);
    }
    @Override
    public List<PlanItemCategoryEntity> getSimpleList() {
        return planItemCategoryDao.selectList(new LambdaQueryWrapperX<PlanItemCategoryEntity>());
    }
    @Override
    public void create(PlanItemCategorySaveReqVO createReqVO) {
        // 校验父菜单存在
        validateParentMenu(createReqVO.getPid(), null);
        // 插入数据库
        PlanItemCategoryEntity entity = BeanUtils.toBean(createReqVO, PlanItemCategoryEntity.class);
        entity.setId(UUID.randomUUID().toString());
        entity.setCreateTime(new Date());
        planItemCategoryDao.insert(entity);
    }
    @Override
    public void update(PlanItemCategorySaveReqVO updateReqVO) {
        // 校验父菜单存在
        validateParentMenu(updateReqVO.getPid(), null);
        PlanItemCategoryEntity entity = BeanUtils.toBean(updateReqVO, PlanItemCategoryEntity.class);
        entity.setUpdateTime(new Date());
        planItemCategoryDao.updateById(entity);
    }
    @Override
    public PlanItemCategoryEntity get(String id) {
        return planItemCategoryDao.selectById(id);
    }
    @Override
    public void delete(String id) {
        planItemCategoryDao.deleteById(id);
    }
    private void validateParentMenu(String parentId, String childId) {
        if (parentId == null || ID_ROOT.equals(parentId)) {
            return;
        }
        // 不能设置自己为父菜单
        if (parentId.equals(childId)) {
            throw exception(MENU_PARENT_ERROR);
        }
        PlanItemCategoryEntity category = planItemCategoryDao.selectById(parentId);
        // 父菜单不存在
        if (category == null) {
            throw exception(MENU_PARENT_NOT_EXISTS);
        }
    }
}
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/plan/category/vo/PlanItemCategoryReqVO.java
对比新文件
@@ -0,0 +1,18 @@
package com.iailab.module.data.plan.category.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.ToString;
/**
 * @author PanZhibao
 * @Description
 * @createTime 2024年11月01日
 */
@Schema(description = "数据服务 - 计划分类分页 Request VO")
@Data
@ToString(callSuper = true)
public class PlanItemCategoryReqVO {
    private String label;
}
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/plan/category/vo/PlanItemCategoryRespVO.java
对比新文件
@@ -0,0 +1,44 @@
package com.iailab.module.data.plan.category.vo;
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import com.alibaba.excel.annotation.ExcelProperty;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.util.Date;
/**
 * @author PanZhibao
 * @Description
 * @createTime 2024年09月10日
 */
@Schema(description = "数据平台 - 指标分类 Response VO")
@Data
@ExcelIgnoreUnannotated
public class PlanItemCategoryRespVO {
    @Schema(description = "指标分类ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
    @ExcelProperty("指标分类ID")
    private String id;
    @Schema(description = "标签", example = "")
    private String label;
    @Schema(description = "父ID", example = "")
    private String pid;
    @Schema(description = "排序", example = "")
    private Integer sort;
    @Schema(description = "创建者", example = "")
    private String creator;
    @Schema(description = "创建时间", example = "")
    private Date createTime;
    @Schema(description = "更新者", example = "")
    private String updater;
    @Schema(description = "更新时间", example = "")
    private Date updateTime;
}
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/plan/category/vo/PlanItemCategorySaveReqVO.java
对比新文件
@@ -0,0 +1,34 @@
package com.iailab.module.data.plan.category.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
/**
 * @author PanZhibao
 * @Description
 * @createTime 2024年09月10日
 */
@Schema(description = "数据平台 - 指标分类创建/修改 Request VO")
@Data
public class PlanItemCategorySaveReqVO {
    @Schema(description = "ID", example = "1024")
    private String id;
    @Schema(description = "标签", requiredMode = Schema.RequiredMode.REQUIRED, example = "平台")
    @NotBlank(message = "标签")
    @Size(max = 50, message = "标签长度不能超过20个字符")
    private String label;
    @Schema(description = "父菜单 ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
    @NotNull(message = "父菜单 ID 不能为空")
    private String pid;
    @Schema(description = "显示顺序", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
    @NotNull(message = "显示顺序不能为空")
    private Integer sort;
}
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/plan/data/controller/admin/PlanDataSetController.java
对比新文件
@@ -0,0 +1,85 @@
package com.iailab.module.data.plan.data.controller.admin;
import com.iailab.framework.common.pojo.CommonResult;
import com.iailab.framework.common.pojo.PageResult;
import com.iailab.framework.common.util.object.BeanUtils;
import com.iailab.module.data.plan.data.entity.PlanDataSetEntity;
import com.iailab.module.data.plan.data.service.PlanDataSetService;
import com.iailab.module.data.plan.data.vo.PlanDataSetPageReqVO;
import com.iailab.module.data.plan.data.vo.PlanDataSetRespVO;
import com.iailab.module.data.plan.data.vo.PlanDataSetSaveReqVO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import java.util.List;
import static com.iailab.framework.common.pojo.CommonResult.success;
/**
 * @author PanZhibao
 * @Description
 * @createTime 2024年11月01日
 */
@Tag(name = "数据平台 - 计划数据集")
@RestController
@RequestMapping("/data/plan/data-set")
@Validated
public class PlanDataSetController {
    @Autowired
    private PlanDataSetService indDataSetService;
    @GetMapping("/page")
    @Operation(summary = "获取计划数据集列表", description = "用于【计划数据集】界面")
    @PreAuthorize("@ss.hasPermission('data:plan-data-set:query')")
    public CommonResult<PageResult<PlanDataSetRespVO>> page(PlanDataSetPageReqVO reqVO) {
        PageResult<PlanDataSetEntity> page = indDataSetService.page(reqVO);
        return success(BeanUtils.toBean(page, PlanDataSetRespVO.class));
    }
    @PostMapping("/create")
    @Operation(summary = "创建计划数据集")
    @PreAuthorize("@ss.hasPermission('data:plan-data-set:create')")
    public CommonResult<Boolean> create(@Valid @RequestBody PlanDataSetSaveReqVO createReqVO) {
        indDataSetService.create(createReqVO);
        return success(true);
    }
    @PutMapping("/update")
    @Operation(summary = "修改计划数据集")
    @PreAuthorize("@ss.hasPermission('data:plan-data-set:update')")
    public CommonResult<Boolean> update(@Valid @RequestBody PlanDataSetSaveReqVO updateReqVO) {
        indDataSetService.update(updateReqVO);
        return success(true);
    }
    @DeleteMapping("/delete")
    @Operation(summary = "删除计划数据集")
    @Parameter(name = "id", description = "计划数据集编号", required= true, example = "1024")
    @PreAuthorize("@ss.hasPermission('data:plan-data-set:delete')")
    public CommonResult<Boolean> delete(@RequestParam("id") String id) {
        indDataSetService.delete(id);
        return success(true);
    }
    @GetMapping("/get")
    @Operation(summary = "获取计划数据集信息")
    @PreAuthorize("@ss.hasPermission('data:plan-data-set:query')")
    public CommonResult<PlanDataSetRespVO> get(String id) {
        PlanDataSetEntity entity = indDataSetService.get(id);
        return success(BeanUtils.toBean(entity, PlanDataSetRespVO.class));
    }
    @GetMapping("/list-all-simple")
    @Operation(summary = "获取计划数据集列表", description = "用于【计划数据集】界面")
    @PreAuthorize("@ss.hasPermission('data:plan-data-set:query')")
    public CommonResult<List<PlanDataSetRespVO>> list(PlanDataSetPageReqVO reqVO) {
        List<PlanDataSetEntity> list = indDataSetService.list(reqVO);
        return success(BeanUtils.toBean(list, PlanDataSetRespVO.class));
    }
}
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/plan/data/controller/package-info.java
对比新文件
@@ -0,0 +1 @@
package com.iailab.module.data.plan.data.controller;
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/plan/data/dao/PlanDataSetDao.java
对比新文件
@@ -0,0 +1,25 @@
package com.iailab.module.data.plan.data.dao;
import com.iailab.framework.common.pojo.PageResult;
import com.iailab.framework.mybatis.core.mapper.BaseMapperX;
import com.iailab.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.iailab.framework.tenant.core.db.dynamic.TenantDS;
import com.iailab.module.data.plan.data.entity.PlanDataSetEntity;
import com.iailab.module.data.plan.data.vo.PlanDataSetPageReqVO;
import org.apache.ibatis.annotations.Mapper;
/**
 * @author PanZhibao
 * @Description
 * @createTime 2024年09月10日
 */
@TenantDS
@Mapper
public interface PlanDataSetDao extends BaseMapperX<PlanDataSetEntity>  {
    default PageResult<PlanDataSetEntity> selectPage(PlanDataSetPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<PlanDataSetEntity>()
                .likeIfPresent(PlanDataSetEntity::getName, reqVO.getName())
                .orderByDesc(PlanDataSetEntity::getCreateTime));
    }
}
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/plan/data/entity/PlanDataSetEntity.java
对比新文件
@@ -0,0 +1,73 @@
package com.iailab.module.data.plan.data.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
 * 指标数据集
 *
 * @author PanZhibao
 * @Description
 * @createTime 2024年09月10日
 */
@Data
@TableName("t_plan_data_set")
public class PlanDataSetEntity implements Serializable {
    private static final long serialVersionUID = 1L;
    /**
     * 主键
     */
    @TableId(value = "id",type = IdType.INPUT)
    private String id;
    /**
     * 名称
     */
    private String name;
    /**
     * 数据源
     */
    private String dataSource;
    /**
     * 查询语句
     */
    private String querySql;
    /**
     * 备注
     */
    private String remark;
    /**
     * 排序
     */
    private Integer sort;
    /**
     * 创建者
     */
    private String creator;
    /**
     * 创建时间
     */
    private Date createTime;
    /**
     * 更新者
     */
    private String updater;
    /**
     * 更新时间
     */
    private Date updateTime;
}
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/plan/data/package-info.java
对比新文件
@@ -0,0 +1 @@
package com.iailab.module.data.plan.data;
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/plan/data/service/PlanDataSetService.java
对比新文件
@@ -0,0 +1,29 @@
package com.iailab.module.data.plan.data.service;
import com.iailab.framework.common.pojo.PageResult;
import com.iailab.framework.common.service.BaseService;
import com.iailab.module.data.plan.data.entity.PlanDataSetEntity;
import com.iailab.module.data.plan.data.vo.PlanDataSetPageReqVO;
import com.iailab.module.data.plan.data.vo.PlanDataSetSaveReqVO;
import java.util.List;
/**
 * @author PanZhibao
 * @Description
 * @createTime 2024年11月01日
 */
public interface PlanDataSetService extends BaseService<PlanDataSetEntity> {
    PageResult<PlanDataSetEntity> page(PlanDataSetPageReqVO reqVO);
    void create(PlanDataSetSaveReqVO reqVO);
    void update(PlanDataSetSaveReqVO reqVO);
    PlanDataSetEntity get(String id);
    void delete(String id);
    List<PlanDataSetEntity> list(PlanDataSetPageReqVO reqVO);
}
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/plan/data/service/impl/PlanDataSetServiceImpl.java
对比新文件
@@ -0,0 +1,60 @@
package com.iailab.module.data.plan.data.service.impl;
import com.iailab.framework.common.pojo.PageResult;
import com.iailab.framework.common.service.impl.BaseServiceImpl;
import com.iailab.framework.common.util.object.BeanUtils;
import com.iailab.module.data.plan.data.dao.PlanDataSetDao;
import com.iailab.module.data.plan.data.entity.PlanDataSetEntity;
import com.iailab.module.data.plan.data.service.PlanDataSetService;
import com.iailab.module.data.plan.data.vo.PlanDataSetPageReqVO;
import com.iailab.module.data.plan.data.vo.PlanDataSetSaveReqVO;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List;
import java.util.UUID;
/**
 * @author PanZhibao
 * @Description
 * @createTime 2024年11月01日
 */
@Service
public class PlanDataSetServiceImpl extends BaseServiceImpl<PlanDataSetDao, PlanDataSetEntity> implements PlanDataSetService {
    @Override
    public PageResult<PlanDataSetEntity> page(PlanDataSetPageReqVO reqVO) {
        return baseDao.selectPage(reqVO);
    }
    @Override
    public List<PlanDataSetEntity> list(PlanDataSetPageReqVO reqVO) {
        return baseDao.selectList();
    }
    @Override
    public void create(PlanDataSetSaveReqVO createReqVO) {
        PlanDataSetEntity entity = BeanUtils.toBean(createReqVO, PlanDataSetEntity.class);
        entity.setId(UUID.randomUUID().toString());
        entity.setCreateTime(new Date());
        baseDao.insert(entity);
    }
    @Override
    public void update(PlanDataSetSaveReqVO updateReqVO) {
        PlanDataSetEntity entity = BeanUtils.toBean(updateReqVO, PlanDataSetEntity.class);
        entity.setUpdateTime(new Date());
        baseDao.updateById(entity);
    }
    @Override
    public PlanDataSetEntity get(String id) {
        return baseDao.selectById(id);
    }
    @Override
    public void delete(String id) {
        baseDao.deleteById(id);
    }
}
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/plan/data/vo/PlanDataSetPageReqVO.java
对比新文件
@@ -0,0 +1,22 @@
package com.iailab.module.data.plan.data.vo;
import com.iailab.framework.common.pojo.PageParam;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
/**
 * @author PanZhibao
 * @Description
 * @createTime 2024年09月10日
 */
@Schema(description = "模型服务 - 计划数据集分页 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class PlanDataSetPageReqVO extends PageParam {
    @Schema(description = "名称,模糊匹配", example = "")
    private String name;
}
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/plan/data/vo/PlanDataSetRespVO.java
对比新文件
@@ -0,0 +1,50 @@
package com.iailab.module.data.plan.data.vo;
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import com.alibaba.excel.annotation.ExcelProperty;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.util.Date;
/**
 * @author PanZhibao
 * @Description
 * @createTime 2024年09月10日
 */
@Schema(description = "数据平台 - 计划数据集 Response VO")
@Data
@ExcelIgnoreUnannotated
public class PlanDataSetRespVO {
    @Schema(description = "ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
    @ExcelProperty("ID")
    private String id;
    @Schema(description = "名称", example = "")
    private String name;
    @Schema(description = "数据源", example = "")
    private String dataSource;
    @Schema(description = "查询语句", example = "")
    private String querySql;
    @Schema(description = "备注", example = "")
    private String remark;
    @Schema(description = "排序", example = "")
    private Integer sort;
    @Schema(description = "创建者", example = "")
    private String creator;
    @Schema(description = "创建时间", example = "")
    private Date createTime;
    @Schema(description = "更新者", example = "")
    private String updater;
    @Schema(description = "更新时间", example = "")
    private Date updateTime;
}
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/plan/data/vo/PlanDataSetSaveReqVO.java
对比新文件
@@ -0,0 +1,34 @@
package com.iailab.module.data.plan.data.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import javax.validation.constraints.NotNull;
/**
 * @author PanZhibao
 * @Description
 * @createTime 2024年09月10日
 */
@Schema(description = "数据平台 - 计划数据集创建/修改 Request VO")
@Data
public class PlanDataSetSaveReqVO {
    @Schema(description = "ID")
    private String id;
    @Schema(description = "名称", requiredMode = Schema.RequiredMode.REQUIRED)
    @NotNull(message = "名称不能为空")
    private String name;
    @Schema(description = "数据源", requiredMode = Schema.RequiredMode.REQUIRED)
    @NotNull(message = "数据源不能为空")
    private String dataSource;
    @Schema(description = "查询语句", requiredMode = Schema.RequiredMode.REQUIRED)
    @NotNull(message = "查询语句不能为空")
    private String querySql;
    @Schema(description = "备注")
    private String remark;
}
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/plan/item/collection/PlanItemCollector.java
对比新文件
@@ -0,0 +1,103 @@
package com.iailab.module.data.plan.item.collection;
import com.iailab.framework.tenant.core.context.DataContextHolder;
import com.iailab.module.data.common.utils.DateUtils;
import com.iailab.module.data.plan.data.entity.PlanDataSetEntity;
import com.iailab.module.data.plan.data.service.PlanDataSetService;
import com.iailab.module.data.plan.item.entity.PlanItemEntity;
import com.iailab.module.data.plan.item.service.PlanItemService;
import com.iailab.module.data.plan.item.vo.PlanItemDataVO;
import com.iailab.module.data.plan.item.vo.PlanItemValueVO;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
import java.util.*;
/**
 * @author PanZhibao
 * @Description
 * @createTime 2024年11月02日
 */
@Slf4j
@Component
public class PlanItemCollector {
    @Autowired
    private PlanItemService planItemService;
    @Autowired
    private PlanDataSetService planDataSetService;
    public List<PlanItemValueVO> queryValue(String itemNo, Date startTime, Date endTime) {
        List<PlanItemValueVO> result = new ArrayList<>();
        PlanItemEntity itemEntity = planItemService.getInfoByNo(itemNo);
        PlanDataSetEntity dataSet = planDataSetService.get(itemEntity.getDataSet());
        if (dataSet == null) {
            log.warn("数据集不能为空");
            return null;
        }
        if (StringUtils.isEmpty(dataSet.getDataSource())) {
            log.warn("数据源不能为空");
            return null;
        }
        Map<String, Object> params = getSqlParams(dataSet, startTime, endTime);
        DataContextHolder.setDataSourceId(Long.valueOf(dataSet.getDataSource()));
        List<PlanItemDataVO> dataList = planItemService.getSourceValue(params);
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(startTime);
        int dataLength = (int) ((endTime.getTime() - startTime.getTime()) / (1000 * 60)) + 1;
        for (int i = 0; i < dataLength; i++) {
            PlanItemValueVO itemValue = new PlanItemValueVO();
            Date dataTime = calendar.getTime();
            itemValue.setDataTime(dataTime);
            itemValue.setDataValue(0d);
            if (!CollectionUtils.isEmpty(dataList)) {
                dataList.forEach(item -> {
                    Date s = DateUtils.parse(item.getStartTime(), DateUtils.DATE_NUMBER_PATTERN);
                    Date e = DateUtils.parse(item.getEndTime(), DateUtils.DATE_NUMBER_PATTERN);
                    if ((dataTime.after(s) && dataTime.before(e))
                            || dataTime.equals(s) || dataTime.equals(e)) {
                        itemValue.setDataValue(1d);
                    }
                });
            }
            calendar.add(Calendar.MINUTE, 1);
            result.add(itemValue);
        }
        return result;
    }
    public List<PlanItemDataVO> getSourceValue(String itemNo, Date startTime, Date endTime) {
        PlanItemEntity itemEntity = planItemService.getInfoByNo(itemNo);
        PlanDataSetEntity dataSet = planDataSetService.get(itemEntity.getDataSet());
        if (dataSet == null) {
            log.warn("数据集不能为空");
            return null;
        }
        if (StringUtils.isEmpty(dataSet.getDataSource())) {
            log.warn("数据源不能为空");
            return null;
        }
        Map<String, Object> params = getSqlParams(dataSet, startTime, endTime);
        return planItemService.getSourceValue(params);
    }
    private Map<String, Object> getSqlParams(PlanDataSetEntity dataSet, Date startTime, Date endTime) {
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("selectSql", " plan_t.start_time, plan_t.end_time");
        params.put("viewSql", dataSet.getQuerySql());
        StringBuilder whereSql = new StringBuilder();
        String startStr = DateUtils.format(startTime, DateUtils.DATE_NUMBER_PATTERN);
        String endStr = DateUtils.format(endTime, DateUtils.DATE_NUMBER_PATTERN);
        whereSql.append(" plan_t.start_time <= ")
                .append(endStr)
                .append(" and plan_t.end_time >= ")
                .append(startStr);
        params.put("whereSql", whereSql.toString());
        return params;
    }
}
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/plan/item/controller/admin/PlanItemController.java
对比新文件
@@ -0,0 +1,101 @@
package com.iailab.module.data.plan.item.controller.admin;
import com.iailab.framework.apilog.core.annotation.ApiAccessLog;
import com.iailab.framework.common.pojo.CommonResult;
import com.iailab.framework.common.pojo.PageResult;
import com.iailab.framework.common.util.object.BeanUtils;
import com.iailab.framework.common.util.object.ConvertUtils;
import com.iailab.framework.excel.core.util.ExcelUtils;
import com.iailab.module.data.api.dto.ApiPointValueQueryDTO;
import com.iailab.module.data.plan.item.entity.PlanItemEntity;
import com.iailab.module.data.plan.item.service.PlanItemService;
import com.iailab.module.data.plan.item.vo.PlanItemPageReqVO;
import com.iailab.module.data.plan.item.vo.PlanItemRespVO;
import com.iailab.module.data.plan.item.vo.PlanItemSaveReqVO;
import com.iailab.module.data.point.vo.PointValueExportVO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.io.IOException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import static com.iailab.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
import static com.iailab.framework.common.pojo.CommonResult.success;
/**
 * @author PanZhibao
 * @Description
 * @createTime 2024年11月01日
 */
@Tag(name = "数据平台 - 计划数据项")
@RestController
@RequestMapping("/data/plan-item")
@Validated
public class PlanItemController {
    @Autowired
    private PlanItemService planItemService;
    @GetMapping("/page")
    @Operation(summary = "获取计划项列表", description = "用于【计划项】界面")
    @PreAuthorize("@ss.hasPermission('data:plan-item:query')")
    public CommonResult<PageResult<PlanItemRespVO>> page(PlanItemPageReqVO reqVO) {
        PageResult<PlanItemEntity> page = planItemService.page(reqVO);
        PageResult<PlanItemRespVO> result = BeanUtils.toBean(page, PlanItemRespVO.class);
        return success(result);
    }
    @PostMapping("/create")
    @Operation(summary = "创建计划项")
    @PreAuthorize("@ss.hasPermission('data:plan-item:create')")
    public CommonResult<Boolean> create(@Valid @RequestBody PlanItemSaveReqVO createReqVO) {
        planItemService.create(createReqVO);
        return success(true);
    }
    @PutMapping("/update")
    @Operation(summary = "修改计划项")
    @PreAuthorize("@ss.hasPermission('data:plan-item:update')")
    public CommonResult<Boolean> update(@Valid @RequestBody PlanItemSaveReqVO updateReqVO) {
        planItemService.update(updateReqVO);
        return success(true);
    }
    @DeleteMapping("/delete")
    @Operation(summary = "删除计划项")
    @Parameter(name = "id", description = "计划项编号", required= true, example = "1024")
    @PreAuthorize("@ss.hasPermission('data:plan-item:delete')")
    public CommonResult<Boolean> delete(@RequestParam("id") String id) {
        planItemService.delete(id);
        return success(true);
    }
    @GetMapping("/get")
    @Operation(summary = "获取计划项信息")
    @PreAuthorize("@ss.hasPermission('data:plan-item:query')")
    public CommonResult<PlanItemRespVO> get(@RequestParam("id") String id) {
        PlanItemEntity entity = planItemService.get(id);
        PlanItemRespVO respVO = BeanUtils.toBean(entity, PlanItemRespVO.class);
        return success(respVO);
    }
    @GetMapping("/list")
    @Operation(summary = "获取计划项列表", description = "用于【计划项】界面")
    @PreAuthorize("@ss.hasPermission('data:plan-item:query')")
    public CommonResult<List<PlanItemRespVO>> getList(PlanItemPageReqVO reqVO) {
        List<PlanItemEntity> list = planItemService.list();
        return success(ConvertUtils.sourceToTarget(list, PlanItemRespVO.class));
    }
}
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/plan/item/controller/package-info.java
对比新文件
@@ -0,0 +1 @@
package com.iailab.module.data.plan.item.controller;
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/plan/item/dao/PlanItemDao.java
对比新文件
@@ -0,0 +1,37 @@
package com.iailab.module.data.plan.item.dao;
import com.iailab.framework.common.pojo.PageResult;
import com.iailab.framework.mybatis.core.mapper.BaseMapperX;
import com.iailab.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.iailab.framework.tenant.core.aop.TenantIgnore;
import com.iailab.framework.tenant.core.db.dynamic.DataDS;
import com.iailab.framework.tenant.core.db.dynamic.TenantDS;
import com.iailab.module.data.plan.item.entity.PlanItemEntity;
import com.iailab.module.data.plan.item.vo.PlanItemDataVO;
import com.iailab.module.data.plan.item.vo.PlanItemPageReqVO;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
import java.util.Map;
/**
 * @author PanZhibao
 * @Description
 * @createTime 2024年11月01日
 */
@TenantDS
@Mapper
public interface PlanItemDao extends BaseMapperX<PlanItemEntity> {
    @DataDS
    @TenantIgnore
    List<PlanItemDataVO> getSourceValue(Map<String, Object> params);
    default PageResult<PlanItemEntity> selectPage(PlanItemPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<PlanItemEntity>()
                .likeIfPresent(PlanItemEntity::getItemNo, reqVO.getItemNo())
                .likeIfPresent(PlanItemEntity::getItemName, reqVO.getItemName())
                .eqIfPresent(PlanItemEntity::getItemCategory, reqVO.getItemCategory())
                .orderByDesc(PlanItemEntity::getCreateTime));
    }
}
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/plan/item/entity/PlanItemEntity.java
对比新文件
@@ -0,0 +1,80 @@
package com.iailab.module.data.plan.item.entity;
import com.baomidou.mybatisplus.annotation.*;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
 * @author PanZhibao
 * @Description
 * @createTime 2024年11月01日
 */
@Data
@TableName("t_plan_item")
public class PlanItemEntity implements Serializable {
    private static final long serialVersionUID = 1L;
    /**
     * 主键
     */
    @TableId(value = "id",type = IdType.INPUT)
    private String id;
    /**
     * 指标编码
     */
    private String itemNo;
    /**
     * 指标名称
     */
    private String itemName;
    /**
     * 指标分类
     */
    private String itemCategory;
    /**
     * 时间粒度
     */
    @TableField(updateStrategy = FieldStrategy.ALWAYS)
    private String timeGranularity;
    /**
     * 数据集
     */
    private String dataSet;
    /**
     * 备注
     */
    private String remark;
    /**
     * 状态
     */
    private Integer status;
    /**
     * 创建者
     */
    private String creator;
    /**
     * 创建时间
     */
    private Date createTime;
    /**
     * 更新者
     */
    private String updater;
    /**
     * 更新时间
     */
    private Date updateTime;
}
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/plan/item/package-info.java
对比新文件
@@ -0,0 +1 @@
package com.iailab.module.data.plan.item;
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/plan/item/service/PlanItemService.java
对比新文件
@@ -0,0 +1,35 @@
package com.iailab.module.data.plan.item.service;
import com.iailab.framework.common.pojo.PageResult;
import com.iailab.framework.common.service.BaseService;
import com.iailab.module.data.plan.item.entity.PlanItemEntity;
import com.iailab.module.data.plan.item.vo.PlanItemDataVO;
import com.iailab.module.data.plan.item.vo.PlanItemPageReqVO;
import com.iailab.module.data.plan.item.vo.PlanItemSaveReqVO;
import java.util.List;
import java.util.Map;
/**
 * @author PanZhibao
 * @Description
 * @createTime 2024年11月01日
 */
public interface PlanItemService extends BaseService<PlanItemEntity> {
    PageResult<PlanItemEntity> page(PlanItemPageReqVO reqVO);
    List<PlanItemEntity> list();
    void create(PlanItemSaveReqVO createReqVO);
    void update(PlanItemSaveReqVO updateReqVO);
    PlanItemEntity get(String id);
    PlanItemEntity getInfoByNo(String no);
    void delete(String id);
    List<PlanItemDataVO> getSourceValue(Map<String, Object> params);
}
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/plan/item/service/impl/PlanItemServiceImpl.java
对比新文件
@@ -0,0 +1,80 @@
package com.iailab.module.data.plan.item.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.iailab.framework.common.pojo.PageResult;
import com.iailab.framework.common.service.impl.BaseServiceImpl;
import com.iailab.framework.common.util.object.BeanUtils;
import com.iailab.module.data.plan.item.dao.PlanItemDao;
import com.iailab.module.data.plan.item.entity.PlanItemEntity;
import com.iailab.module.data.plan.item.service.PlanItemService;
import com.iailab.module.data.plan.item.vo.PlanItemDataVO;
import com.iailab.module.data.plan.item.vo.PlanItemPageReqVO;
import com.iailab.module.data.plan.item.vo.PlanItemSaveReqVO;
import com.iailab.module.data.common.enums.IncreaseCodeEnum;
import com.iailab.module.data.point.service.DaSequenceNumService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.*;
/**
 * @author PanZhibao
 * @Description
 * @createTime 2024年11月01日
 */
@Service
public class PlanItemServiceImpl extends BaseServiceImpl<PlanItemDao, PlanItemEntity> implements PlanItemService {
    @Autowired
    private DaSequenceNumService daSequenceNumService;
    @Override
    public PageResult<PlanItemEntity> page(PlanItemPageReqVO reqVO) {
        return baseDao.selectPage(reqVO);
    }
    @Override
    public List<PlanItemEntity> list() {
        QueryWrapper<PlanItemEntity> queryWrapper = new QueryWrapper<>();
        queryWrapper.orderByDesc("create_time");
        return baseDao.selectList(queryWrapper);
    }
    @Override
    public void create(PlanItemSaveReqVO createReqVO) {
        PlanItemEntity entity = BeanUtils.toBean(createReqVO, PlanItemEntity.class);
        entity.setId(UUID.randomUUID().toString());
        entity.setItemNo(daSequenceNumService.getAndIncreaseByCode(IncreaseCodeEnum.PLAN.name()));
        entity.setCreateTime(new Date());
        baseDao.insert(entity);
    }
    @Override
    public void update(PlanItemSaveReqVO updateReqVO) {
        PlanItemEntity entity = BeanUtils.toBean(updateReqVO, PlanItemEntity.class);
        entity.setUpdateTime(new Date());
        baseDao.updateById(entity);
    }
    @Override
    public PlanItemEntity get(String id) {
        return baseDao.selectById(id);
    }
    @Override
    public PlanItemEntity getInfoByNo(String no) {
        QueryWrapper<PlanItemEntity> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("item_no", no);
        return baseDao.selectOne(queryWrapper);
    }
    @Override
    public void delete(String id) {
        baseDao.deleteById(id);
    }
    @Override
    public List<PlanItemDataVO> getSourceValue(Map<String, Object> params) {
        return baseDao.getSourceValue(params);
    }
}
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/plan/item/vo/PlanItemDataVO.java
对比新文件
@@ -0,0 +1,18 @@
package com.iailab.module.data.plan.item.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
/**
 * @author PanZhibao
 * @Description
 * @createTime 2024年11月02日
 */
@Schema(description = "数据平台 - ")
@Data
public class PlanItemDataVO {
    private String startTime;
    private String endTime;
}
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/plan/item/vo/PlanItemPageReqVO.java
对比新文件
@@ -0,0 +1,28 @@
package com.iailab.module.data.plan.item.vo;
import com.iailab.framework.common.pojo.PageParam;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
/**
 * @author PanZhibao
 * @Description
 * @createTime 2024年09月11日
 */
@Schema(description = "数据平台 - 指标项分页 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class PlanItemPageReqVO extends PageParam {
    @Schema(description = "指标编码", example = "")
    private String itemNo;
    @Schema(description = "指标名称", example = "")
    private String itemName;
    @Schema(description = "指标分类", example = "")
    private String itemCategory;
}
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/plan/item/vo/PlanItemRespVO.java
对比新文件
@@ -0,0 +1,65 @@
package com.iailab.module.data.plan.item.vo;
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import com.alibaba.excel.annotation.ExcelProperty;
import com.iailab.module.data.ind.item.vo.IndItemAtomVO;
import com.iailab.module.data.ind.item.vo.IndItemCalVO;
import com.iailab.module.data.ind.item.vo.IndItemDerVO;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.util.Date;
/**
 * @author PanZhibao
 * @Description
 * @createTime 2024年09月11日
 */
@Schema(description = "数据平台 - 指标项 Response VO")
@Data
@ExcelIgnoreUnannotated
public class PlanItemRespVO {
    @Schema(description = "ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
    @ExcelProperty("ID")
    private String id;
    @Schema(description = "指标编码", example = "")
    private String itemNo;
    @Schema(description = "指标名称", example = "")
    private String itemName;
    @Schema(description = "指标类型", example = "")
    private String itemType;
    @Schema(description = "指标分类", example = "")
    private String itemCategory;
    @Schema(description = "指标分类", example = "")
    private String itemCategoryName;
    @Schema(description = "时间粒度", example = "")
    private String timeGranularity;
    @Schema(description = "数据集", example = "")
    private String dataSet;
    @Schema(description = "备注", example = "")
    private String remark;
    @Schema(description = "状态", example = "")
    private Integer status;
    @Schema(description = "创建者", example = "")
    private String creator;
    @Schema(description = "创建时间", example = "")
    private Date createTime;
    @Schema(description = "更新者", example = "")
    private String updater;
    @Schema(description = "更新时间", example = "")
    private Date updateTime;
}
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/plan/item/vo/PlanItemSaveReqVO.java
对比新文件
@@ -0,0 +1,42 @@
package com.iailab.module.data.plan.item.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import javax.validation.constraints.NotNull;
/**
 * @author PanZhibao
 * @Description
 * @createTime 2024年09月11日
 */
@Schema(description = "数据平台 - 指标项创建/修改 Request VO")
@Data
public class PlanItemSaveReqVO {
    @Schema(description = "ID")
    private String id;
    @Schema(description = "编码")
    private String itemNo;
    @Schema(description = "名称", requiredMode = Schema.RequiredMode.REQUIRED)
    @NotNull(message = "名称不能为空")
    private String itemName;
    @Schema(description = "指标分类", requiredMode = Schema.RequiredMode.REQUIRED)
    @NotNull(message = "指标分类不能为空")
    private String itemCategory;
    @Schema(description = "时间粒度")
    private String timeGranularity;
    @Schema(description = "数据集")
    private String dataSet;
    @Schema(description = "备注")
    private String remark;
    @Schema(description = "状态(0正常 1停用)")
    private Integer status;
}
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/plan/item/vo/PlanItemValueExportVO.java
对比新文件
@@ -0,0 +1,27 @@
package com.iailab.module.data.plan.item.vo;
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import com.alibaba.excel.annotation.ExcelProperty;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.util.Date;
/**
 * @author PanZhibao
 * @Description
 * @createTime 2024年11月04日
 */
@Schema(description = "导出 - 测点数据 Response VO")
@Data
@ExcelIgnoreUnannotated
public class PlanItemValueExportVO {
    @Schema(description = "采集值")
    @ExcelProperty("采集值")
    private String dataValue;
    @Schema(description = "采集时间")
    @ExcelProperty("采集时间")
    private String dataTime;
}
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/plan/item/vo/PlanItemValueVO.java
对比新文件
@@ -0,0 +1,23 @@
package com.iailab.module.data.plan.item.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.math.BigDecimal;
import java.util.Date;
/**
 * @author PanZhibao
 * @Description
 * @createTime 2024年10月04日
 */
@Schema(description = "数据平台 - ")
@Data
public class PlanItemValueVO {
    private String itemNo;
    private Date dataTime;
    private double dataValue;
}
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/plan/package-info.java
对比新文件
@@ -0,0 +1 @@
package com.iailab.module.data.plan;
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/common/IncreaseCodeEnum.java
文件已删除
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/common/PointTypeEnum.java
@@ -1,37 +1,33 @@
package com.iailab.module.data.point.common;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
 * @author PanZhibao
 * @date 2021年04月25日 11:41
 */
@Getter
@AllArgsConstructor
public enum PointTypeEnum {
    MEASURE_POINT("MEASURE", "MEASURE"),
    CALCULATE_POINT("CALCULATE", "CALCULATE"),
    CONSTANT("CONSTANT", "CONSTANT");
    MEASURE_POINT("MEASURE", "测量点"),
    CALCULATE_POINT("CALCULATE", "计算点"),
    CONSTANT("CONSTANT", "常量点");
    private String code;
    private String name;
    private String desc;
    PointTypeEnum(String code, String name){
        this.code = code;
        this.name = name;
    }
    public static PointTypeEnum getEumByCode(String code) {
        if (code == null) {
            return null;
        }
    public String getCode() {
        return code;
    }
    public void setCode(String code) {
        this.code = code;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
        for (PointTypeEnum statusEnum : PointTypeEnum.values()) {
            if (statusEnum.getCode().equals(code)) {
                return statusEnum;
            }
        }
        return null;
    }
}
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/controller/admin/DaPointController.java
@@ -8,6 +8,8 @@
import com.iailab.framework.common.util.object.ConvertUtils;
import com.iailab.framework.excel.core.util.ExcelUtils;
import com.iailab.module.data.api.dto.ApiPointValueQueryDTO;
import com.iailab.module.data.channel.common.service.ChannelSourceService;
import com.iailab.module.data.common.enums.DataSourceType;
import com.iailab.module.data.influxdb.service.InfluxDBService;
import com.iailab.module.data.point.dto.DaPointDTO;
import com.iailab.module.data.point.entity.DaPointEntity;
@@ -55,7 +57,7 @@
    @PreAuthorize("@ss.hasPermission('data:point:query')")
    @GetMapping("page")
    public CommonResult<PageResult<DaPointDTO>> page(@Valid DaPointPageReqVO reqVO){
    public CommonResult<PageResult<DaPointDTO>> page(@Valid DaPointPageReqVO reqVO) {
        PageResult<DaPointDTO> page = daPointService.queryPage(reqVO);
        return success(page);
    }
@@ -70,14 +72,14 @@
    @PreAuthorize("@ss.hasPermission('data:point:query')")
    @GetMapping("/info/{id}")
    public CommonResult<DaPointDTO> info(@PathVariable("id") String id){
        DaPointDTO info= daPointService.info(id);
    public CommonResult<DaPointDTO> info(@PathVariable("id") String id) {
        DaPointDTO info = daPointService.info(id);
        return success(info);
    }
    @PreAuthorize("@ss.hasPermission('data:point:create')")
    @PostMapping("create")
    public CommonResult<Boolean> create(@RequestBody DaPointDTO daPointDTO){
    public CommonResult<Boolean> create(@RequestBody DaPointDTO daPointDTO) {
        String id = UUID.randomUUID().toString();
        daPointDTO.setId(id);
        daPointService.add(daPointDTO);
@@ -100,7 +102,7 @@
    @PreAuthorize("@ss.hasPermission('data:point:query')")
    @GetMapping("pointNo")
    public CommonResult<List<DaPointDTO>> getpoint(@RequestParam Map<String, Object> params){
    public CommonResult<List<DaPointDTO>> getPoint(@RequestParam Map<String, Object> params) {
        List<DaPointDTO> list = daPointService.list(params);
        return new CommonResult<List<DaPointDTO>>().setData(list);
@@ -129,11 +131,16 @@
    @PreAuthorize("@ss.hasPermission('data:point:export')")
    @ApiAccessLog(operateType = EXPORT)
    public void exportPointList(@Validated DaPointPageReqVO exportReqVO,
                               HttpServletResponse response) throws IOException {
                                HttpServletResponse response) throws IOException {
        exportReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
        List<DaPointEntity> list = daPointService.queryExcelList(exportReqVO).getList();
        List<DaPointExcelVO> daPointExcelVOlist = ConvertUtils.sourceToTarget(list,DaPointExcelVO.class);
        ExcelUtils.write(response, "测点列表.xls", "数据", DaPointExcelVO.class, daPointExcelVOlist);
        List<DaPointExcelVO> dataList = new ArrayList<>();
        List<DaPointDTO> measurePointList = daPointService.getMeasurePoint(exportReqVO);
        dataList.addAll(ConvertUtils.sourceToTarget(measurePointList, DaPointExcelVO.class));
        List<DaPointDTO> mathPointList = daPointService.getMathPoint(exportReqVO);
        dataList.addAll(ConvertUtils.sourceToTarget(mathPointList, DaPointExcelVO.class));
        List<DaPointDTO> constantPointList = daPointService.getConstantPoint(exportReqVO);
        dataList.addAll(ConvertUtils.sourceToTarget(constantPointList, DaPointExcelVO.class));
        ExcelUtils.write(response, "测点列表.xls", "测点列表", DaPointExcelVO.class, dataList);
    }
    @GetMapping("/exportValue")
@@ -149,16 +156,16 @@
        List<String> pointNos = new ArrayList<>();
        pointNos.add(pointNo);
        queryDto.setPointNos(pointNos);
        try{
        try {
            if (start == null) {
                queryDto.setStart(new Date());
            }else{
            } else {
                queryDto.setStart(formatter.parse(start));
            }
            if (end == null) {
                queryDto.setEnd(new Date());
            }else{
            } else {
                queryDto.setStart(formatter.parse(end));
            }
        } catch (ParseException e) {
@@ -175,11 +182,12 @@
        List<PointImportExcelVO> list = Arrays.asList(
                PointImportExcelVO.builder().pointName("测点1").pointType("MEASURE").dataType("float").valueType("SIMULATE")
                        .storeType(null).unit("t(非必填)").unittransfactor(new BigDecimal(1)).defaultValue(new BigDecimal(0)).maxValue(new BigDecimal(10000000.000000)).minValue(new BigDecimal(0))
                        .minfreqid("NET10").remark("备注(非必填)").sourceType("HTTP").sourceId("b9d0f670-2135-458f-9494-0cda4f35ec09").tagNo("SARD1200G00102RC001")
                        .minfreqid("1min").remark("备注(非必填)").sourceType(DataSourceType.HTTP.getCode())
                        .sourceName("").tagNo("SARD1200G00102RC001")
                        .build()
        );
        // 输出
        ExcelUtils.write(response, "测点导入模板.xls", "测点列表", PointImportExcelVO.class, list);
        ExcelUtils.write(response, "测点导入模板.xlsx", "测点列表", PointImportExcelVO.class, list);
    }
    @PostMapping("/import")
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/dao/DaPointDao.java
@@ -27,6 +27,8 @@
    IPage<DaPointDTO> getPageList(IPage<DaPointEntity> page, @Param("params") DaPointPageReqVO reqVO);
    List<DaPointDTO> getList(DaPointPageReqVO reqVO);
    List<DaPointDTO> getConstantPoint(Map<String, Object> params);
    List<DaPointDTO> getMeasurePoint(Map<String, Object> params);
@@ -35,13 +37,9 @@
    default IPage<DaPointDTO> selectPageList(DaPointPageReqVO reqVO) {
        return getPageList(getPage(reqVO), reqVO);
    };
    default PageResult<DaPointEntity> selectExcelList(DaPointPageReqVO reqVO) {
        return selectPage(reqVO,new QueryWrapper<>());
    }
    default DaPointEntity selectByPointName(String pointName){
    default DaPointEntity selectByPointName(String pointName) {
        return selectOne("point_name", pointName);
    };
    }
}
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/dto/DaPointDTO.java
@@ -47,9 +47,6 @@
    @DictFormat("data_type")
    private String dataTypeName;
    @Schema(description = "值类型", required = true)
    private String valueType;
    @Schema(description = "存储类型", required = true)
    private String storeType;
@@ -101,8 +98,12 @@
    @Schema(description = "测点Tag", required = true)
    private String tagNo;
    @Schema(description = "平滑尺度")
    private Integer dimension;
    @Schema(description = "值类型")
    private String valueType;
    @Schema(description = "计算公式", required = true)
    private String expression;
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/service/DaMathPointService.java
@@ -13,6 +13,8 @@
    void add(DaMathPointDTO dto, String pointId);
    void add(String expression, String pointId);
    DaMathPointDTO getByPoint(String pointId);
    void update(DaMathPointDTO dto);
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/service/DaPointService.java
@@ -57,5 +57,11 @@
    PointImportRespVO importPointList(List<PointImportExcelVO> importPoints, boolean isUpdateSupport);
    PageResult<DaPointEntity> queryExcelList(DaPointPageReqVO exportReqVO);
    List<DaPointDTO> getList(DaPointPageReqVO exportReqVO);
    List<DaPointDTO> getConstantPoint(DaPointPageReqVO reqVO);
    List<DaPointDTO> getMeasurePoint(DaPointPageReqVO reqVO);
    List<DaPointDTO> getMathPoint(DaPointPageReqVO reqVO);
}
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/service/impl/DaMathPointServiceImpl.java
@@ -10,6 +10,7 @@
import org.springframework.stereotype.Service;
import java.util.Arrays;
import java.util.UUID;
/**
 * @author PanZhibao
@@ -27,6 +28,15 @@
    }
    @Override
    public void add(String expression, String pointId) {
        DaMathPointEntity entity = new DaMathPointEntity();
        entity.setId(UUID.randomUUID().toString());
        entity.setPointId(pointId);
        entity.setExpression(expression);
        baseDao.insert(entity);
    }
    @Override
    public DaMathPointDTO getByPoint(String pointId) {
        QueryWrapper<DaMathPointEntity> wrapper = new QueryWrapper<>();
        wrapper.eq("point_id", pointId);
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/service/impl/DaPointServiceImpl.java
@@ -1,22 +1,18 @@
package com.iailab.module.data.point.service.impl;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSONArray;
import com.baomidou.dynamic.datasource.annotation.DSTransactional;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.google.common.annotations.VisibleForTesting;
import com.iailab.framework.common.exception.ServiceException;
import com.iailab.framework.common.pojo.PageResult;
import com.iailab.framework.common.util.object.BeanUtils;
import com.iailab.framework.common.util.object.ConvertUtils;
import com.iailab.framework.datapermission.core.util.DataPermissionUtils;
import com.iailab.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.iailab.module.data.channel.common.service.ChannelSourceService;
import com.iailab.module.data.common.enums.CommonConstant;
import com.iailab.module.data.common.enums.IsEnableEnum;
import com.iailab.module.data.point.common.IncreaseCodeEnum;
import com.iailab.module.data.common.enums.IncreaseCodeEnum;
import com.iailab.module.data.point.common.PointTypeEnum;
import com.iailab.module.data.point.dao.DaPointDao;
import com.iailab.module.data.point.dto.DaMeasurePointDTO;
@@ -31,14 +27,11 @@
import com.iailab.module.infra.api.config.ConfigApi;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import javax.annotation.Resource;
import java.util.*;
import com.iailab.module.data.enums.ErrorCodeConstants;
import static com.iailab.framework.common.exception.util.ServiceExceptionUtil.exception;
import static com.iailab.module.data.enums.ErrorCodeConstants.*;
@@ -65,6 +58,9 @@
    @Resource
    private ConfigApi configApi;
    @Resource
    private ChannelSourceService channelSourceService;
    @Override
    public PageResult<DaPointDTO> queryPage(DaPointPageReqVO reqVO) {
@@ -109,11 +105,17 @@
        if (params.get("pointNos") != null) {
            pointNos = JSONArray.parseArray(JSONArray.toJSONString(params.get("pointNos")), String.class);
        }
        List<String> pointTypes = new ArrayList<>();
        if (params.get("pointTypes") != null) {
            pointTypes = Arrays.asList(params.get("pointTypes").toString().split(","));
        }
        Object pointNoLike = params.get("pointNoLike");
        QueryWrapper<DaPointEntity> queryWrapper = new QueryWrapper();
        queryWrapper.eq(!ObjectUtils.isEmpty(pointType), "point_type", pointType);
        queryWrapper.in(pointNos.size() != 0,"point_no", pointNos);
        queryWrapper.like(!ObjectUtils.isEmpty(pointNoLike), "point_no", pointNoLike);
        queryWrapper.in(pointTypes.size() != 0,"point_type", pointTypes);
        List<DaPointEntity> list = daPointDao.selectList(queryWrapper);
        return ConvertUtils.sourceToTarget(list, DaPointDTO.class);
    }
@@ -123,18 +125,24 @@
    public void add(DaPointDTO dataPoint) {
        DaPointEntity daPointEntity = ConvertUtils.sourceToTarget(dataPoint, DaPointEntity.class);
        daPointEntity.setId(UUID.randomUUID().toString());
        if (PointTypeEnum.MEASURE_POINT.getName().equals(dataPoint.getPointType())) {
            DaMeasurePointDTO measurePoint = new DaMeasurePointDTO();
            measurePoint.setSourceType(dataPoint.getSourceOption().get(0));
            measurePoint.setSourceId(dataPoint.getSourceOption().get(1));
            measurePoint.setTagNo(dataPoint.getSourceOption().get(2));
            daMeasurePointService.add(measurePoint, daPointEntity.getId());
            daPointEntity.setPointNo(daSequenceNumService.getAndIncreaseByCode(IncreaseCodeEnum.POINT_M.name()));
        } else if (PointTypeEnum.CALCULATE_POINT.getName().equals(dataPoint.getPointType())) {
            daMathPointService.add(dataPoint.getMathPoint(), daPointEntity.getId());
            daPointEntity.setPointNo(daSequenceNumService.getAndIncreaseByCode(IncreaseCodeEnum.POINT_C.name()));
        } else if (PointTypeEnum.CONSTANT.getName().equals(dataPoint.getPointType())) {
            daPointEntity.setPointNo(daSequenceNumService.getAndIncreaseByCode(IncreaseCodeEnum.POINT_F.name()));
        switch (PointTypeEnum.getEumByCode(dataPoint.getPointType())) {
            case MEASURE_POINT:
                DaMeasurePointDTO measurePoint = new DaMeasurePointDTO();
                measurePoint.setSourceType(dataPoint.getSourceOption().get(0));
                measurePoint.setSourceId(dataPoint.getSourceOption().get(1));
                measurePoint.setTagNo(dataPoint.getSourceOption().get(2));
                daMeasurePointService.add(measurePoint, daPointEntity.getId());
                daPointEntity.setPointNo(daSequenceNumService.getAndIncreaseByCode(IncreaseCodeEnum.POINT_M.name()));
                break;
            case CALCULATE_POINT:
                daMathPointService.add(dataPoint.getMathPoint(), daPointEntity.getId());
                daPointEntity.setPointNo(daSequenceNumService.getAndIncreaseByCode(IncreaseCodeEnum.POINT_C.name()));
                break;
            case CONSTANT:
                daPointEntity.setPointNo(daSequenceNumService.getAndIncreaseByCode(IncreaseCodeEnum.POINT_F.name()));
                break;
            default:
                break;
        }
        daPointEntity.setIsEnable(CommonConstant.IS_ENABLE);
        daPointEntity.setCreateTime(new Date());
@@ -147,14 +155,19 @@
        DaPointEntity daPointEntity = ConvertUtils.sourceToTarget(dataPoint, DaPointEntity.class);
        daPointEntity.setUpdateTime(new Date());
        daPointDao.updateById(daPointEntity);
        if (PointTypeEnum.MEASURE_POINT.getName().equals(dataPoint.getPointType())) {
            DaMeasurePointDTO measurePoint = dataPoint.getMeasurePoint();
            measurePoint.setSourceType(dataPoint.getSourceOption().get(0));
            measurePoint.setSourceId(dataPoint.getSourceOption().get(1));
            measurePoint.setTagNo(dataPoint.getSourceOption().get(2));
            daMeasurePointService.update(measurePoint);
        } else if (PointTypeEnum.CALCULATE_POINT.getName().equals(dataPoint.getPointType())) {
            daMathPointService.update(dataPoint.getMathPoint());
        switch (PointTypeEnum.getEumByCode(dataPoint.getPointType())) {
            case MEASURE_POINT:
                DaMeasurePointDTO measurePoint = dataPoint.getMeasurePoint();
                measurePoint.setSourceType(dataPoint.getSourceOption().get(0));
                measurePoint.setSourceId(dataPoint.getSourceOption().get(1));
                measurePoint.setTagNo(dataPoint.getSourceOption().get(2));
                daMeasurePointService.update(measurePoint);
                break;
            case CALCULATE_POINT:
                daMathPointService.update(dataPoint.getMathPoint());
                break;
            default:
                break;
        }
    }
@@ -164,6 +177,15 @@
        daPointDao.deleteBatchIds(Arrays.asList(id));
        daMeasurePointService.deleteByPoint(id);
        daMathPointService.deleteByPoint(id);
    }
    @Override
    public List<DaPointDTO> getConstantPoint(DaPointPageReqVO reqVO) {
        Map<String, Object> params = new HashMap<>();
        params.put("pointType", PointTypeEnum.CONSTANT.getCode());
        params.put("pointNo", reqVO.getPointNo());
        params.put("pointName", reqVO.getPointName());
        return daPointDao.getConstantPoint(params);
    }
    @Override
@@ -182,6 +204,16 @@
        params.put("isEnable", CommonConstant.IS_ENABLE);
        params.put("pointNos", pointNos);
        return daPointDao.getConstantPoint(params);
    }
    @Override
    public List<DaPointDTO> getMeasurePoint(DaPointPageReqVO reqVO) {
        Map<String, Object> params = new HashMap<>();
        params.put("pointType", PointTypeEnum.MEASURE_POINT.getCode());
        params.put("pointNo", reqVO.getPointNo());
        params.put("pointName", reqVO.getPointName());
        params.put("sourceName", reqVO.getSourceName());
        return daPointDao.getMeasurePoint(params);
    }
    @Override
@@ -212,6 +244,15 @@
            return null;
        }
        return list.get(0);
    }
    @Override
    public List<DaPointDTO> getMathPoint(DaPointPageReqVO reqVO) {
        Map<String, Object> params = new HashMap<>();
        params.put("pointType", PointTypeEnum.CALCULATE_POINT.getCode());
        params.put("pointNo", reqVO.getPointNo());
        params.put("pointName", reqVO.getPointName());
        return daPointDao.getMathPoint(params);
    }
    @Override
@@ -264,7 +305,8 @@
        if (CollUtil.isEmpty(importPoints)) {
            throw exception(POINT_IMPORT_LIST_IS_EMPTY);
        }
        Map<String, Map<String, String>> sourcesIdMap = channelSourceService.getSourcesId();
        // 2. 遍历,逐个创建 or 更新
        PointImportRespVO respVO = PointImportRespVO.builder().createPointnames(new ArrayList<>())
                .updatePointnames(new ArrayList<>()).failurePointnames(new LinkedHashMap<>()).build();
@@ -273,20 +315,33 @@
            // 判断如果不存在,再进行插入
            DaPointEntity existPoint = baseMapper.selectByPointName(importPoint.getPointName());
            if (existPoint == null) {
                DaPointEntity daPointEntity = ConvertUtils.sourceToTarget(importPoint, DaPointEntity.class);
                daPointEntity.setId(UUID.randomUUID().toString());
                DaMeasurePointDTO measurePoint = new DaMeasurePointDTO();
                measurePoint.setSourceType(importPoint.getSourceType());
                measurePoint.setSourceId(importPoint.getSourceId());
                measurePoint.setTagNo(importPoint.getTagNo());
                daPointEntity.setPointNo(daSequenceNumService.getAndIncreaseByCode(IncreaseCodeEnum.POINT_M.name()));
                daPointEntity.setIsEnable(CommonConstant.IS_ENABLE);
                daPointEntity.setCreateTime(new Date());
                switch (PointTypeEnum.getEumByCode(daPointEntity.getPointType())) {
                    case MEASURE_POINT:
                        DaMeasurePointDTO measurePoint = new DaMeasurePointDTO();
                        measurePoint.setSourceType(importPoint.getSourceType());
                        measurePoint.setSourceId(sourcesIdMap.get(importPoint.getSourceType()).get(importPoint.getSourceName()));
                        measurePoint.setTagNo(importPoint.getTagNo());
                        measurePoint.setValueType(importPoint.getValueType());
                        measurePoint.setDimension(importPoint.getDimension());
                        daMeasurePointService.add(measurePoint, daPointEntity.getId());
                        daPointEntity.setPointNo(daSequenceNumService.getAndIncreaseByCode(IncreaseCodeEnum.POINT_M.name()));
                        break;
                    case CALCULATE_POINT:
                        daMathPointService.add(importPoint.getExpression(), daPointEntity.getId());
                        daPointEntity.setPointNo(daSequenceNumService.getAndIncreaseByCode(IncreaseCodeEnum.POINT_C.name()));
                        break;
                    case CONSTANT:
                        daPointEntity.setPointNo(daSequenceNumService.getAndIncreaseByCode(IncreaseCodeEnum.POINT_F.name()));
                        break;
                    default:
                        break;
                }
                daMeasurePointService.add(measurePoint, daPointEntity.getId());
                daPointDao.insert(daPointEntity);
                respVO.getCreatePointnames().add(importPoint.getPointName());
                return;
            }
@@ -302,19 +357,20 @@
            baseMapper.updateById(updatePoint);
            DaMeasurePointEntity measurePoint = new DaMeasurePointEntity();
            measurePoint.setSourceType(importPoint.getSourceType());
            measurePoint.setSourceId(importPoint.getSourceId());
            measurePoint.setSourceId(sourcesIdMap.get(importPoint.getSourceType()).get(importPoint.getSourceName()));
            measurePoint.setTagNo(importPoint.getTagNo());
            daMeasurePointService.update(measurePoint, new QueryWrapper<DaMeasurePointEntity>().eq("point_id",updatePoint.getId()));
            respVO.getUpdatePointnames().add(importPoint.getPointName());
        });
        return respVO;
    }
    @Override
    public PageResult<DaPointEntity> queryExcelList(DaPointPageReqVO exportReqVO) {
        return daPointDao.selectExcelList(exportReqVO);
    public List<DaPointDTO> getList(DaPointPageReqVO exportReqVO) {
        return daPointDao.getList(exportReqVO);
    }
    @Override
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/vo/DaPointExcelVO.java
@@ -29,10 +29,6 @@
    @ExcelProperty("数据类型")
    private String dataType;
    @Schema(description = "值类型")
    @ExcelProperty("值类型")
    private String valueType;
    @Schema(description = "存储类型")
    @ExcelProperty("存储类型")
    private String storeType;
@@ -69,11 +65,23 @@
    @ExcelProperty("数据源类型")
    private String sourceType;
    @Schema(description = "数据源ID")
    @ExcelProperty("数据源ID")
    private String sourceId;
    @Schema(description = "数据源名称")
    @ExcelProperty("数据源名称")
    private String sourceName;
    @Schema(description = "测点Tag")
    @ExcelProperty("测点Tag")
    private String tagNo;
    @Schema(description = "平滑尺度")
    @ExcelProperty("平滑尺度")
    private Integer dimension;
    @Schema(description = "值类型")
    @ExcelProperty("值类型")
    private String valueType;
    @Schema(description = "计算公式")
    @ExcelProperty("计算公式")
    private String expression;
}
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/vo/PointImportExcelVO.java
@@ -1,9 +1,6 @@
package com.iailab.module.data.point.vo;
import com.alibaba.excel.annotation.ExcelProperty;
import com.iailab.framework.excel.core.annotations.DictFormat;
import com.iailab.framework.excel.core.convert.DictConvert;
import com.iailab.module.system.enums.DictTypeConstants;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Builder;
@@ -23,6 +20,9 @@
@Accessors(chain = false) // 设置 chain = false,避免用户导入有问题
public class PointImportExcelVO {
    @ExcelProperty("测点编码")
    private String pointNo;
    @ExcelProperty("测点名称")
    private String pointName;
@@ -31,9 +31,6 @@
    @ExcelProperty("数据类型")
    private String dataType;
    @ExcelProperty("值类型")
    private String valueType;
    @ExcelProperty("存储类型")
    private String storeType;
@@ -56,16 +53,26 @@
    @ExcelProperty("采集频率")
    private String minfreqid;
    @Schema(description = "备注")
    @ExcelProperty("备注")
    private String remark;
    @ExcelProperty("数据源类型")
    private String sourceType;
    @ExcelProperty("数据源ID")
    private String sourceId;
    @ExcelProperty("数据源名称")
    private String sourceName;
    @ExcelProperty("测点Tag")
    private String tagNo;
    @ExcelProperty("平滑尺度")
    private Integer dimension;
    @ExcelProperty("值类型")
    private String valueType;
    @ExcelProperty("计算公式")
    private String expression;
}
iailab-module-data/iailab-module-data-biz/src/main/resources/mapper/plan/PlanItemDao.xml
对比新文件
@@ -0,0 +1,19 @@
<?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="com.iailab.module.data.plan.item.dao.PlanItemDao">
    <select id="getSourceValue" parameterType="map" resultType="com.iailab.module.data.plan.item.vo.PlanItemDataVO">
        select
        ${selectSql}
        from (
        ${viewSql}
        ) plan_t
        <where>
            <if test="whereSql != null and whereSql != ''">
                and ${whereSql}
            </if>
        </where>
    </select>
</mapper>
iailab-module-data/iailab-module-data-biz/src/main/resources/mapper/point/DaPointDao.xml
@@ -68,6 +68,71 @@
        order by t1.create_time desc
    </select>
    <select id="getList" resultType="com.iailab.module.data.point.dto.DaPointDTO">
        select
        t1.id,
        t1.point_no,
        t1.point_name,
        t1.point_type ,
        t1.data_type,
        t1.unit,
        t1.unittransfactor,
        t1.default_value,
        t1.max_value,
        t1.min_value,
        t1.minfreqid,
        t1.remark,
        t1.is_enable,
        t1.creator,
        t1.create_time,
        t1.updater,
        t1.update_time,
        t2.source_type,
        t3.source_name,
        t2.tag_no,
        t2.dimension,
        t2.value_type
        from t_da_point t1
        left join t_da_measure_point t2 on t2.point_id = t1.id
        left join (
        select id source_id,server_name source_name
        from t_channel_opcua_device
        union
        select id source_id, name source_name
        from t_channel_modbus_device
        union
        select id source_id, code source_name
        from t_http_api
        union
        select id source_id, instance_name source_name
        from t_channel_kio_device
        ) t3 on t3.source_id = t2.source_id
        <where>
            <if test="pointNo != null and pointNo != ''">
                and t1.point_no like concat('%', #{pointNo}, '%')
            </if>
            <if test="pointName != null and pointName != ''">
                and t1.point_name like concat('%', #{pointName}, '%')
            </if>
            <if test="pointType != null and pointType != ''">
                and t1.point_type = #{pointType}
            </if>
            <if test="dataType != null and dataType != ''">
                and t1.data_type = #{dataType}
            </if>
            <if test="sourceName != null and sourceName != ''">
                and t3.source_name like concat('%', #{sourceName}, '%')
            </if>
            <if test="tagNo != null and tagNo != ''">
                and t2.tag_no like concat('%', #{tagNo}, '%')
            </if>
            <if test="isEnable != null ">
                and t1.is_enable = #{isEnable}
            </if>
        </where>
        order by t1.create_time desc
    </select>
    <select id="getConstantPoint" resultType="com.iailab.module.data.point.dto.DaPointDTO">
        SELECT
        t1.point_no,
@@ -75,7 +140,8 @@
        t1.default_value,
        t1.point_type,
        t1.store_type,
        t1.data_type
        t1.data_type,
        t1.minfreqid
        FROM t_da_point t1
        <where>
            t1.point_type =  #{pointType}
@@ -105,6 +171,7 @@
        t1.unittransfactor,
        t1.max_value,
        t1.min_value,
        t1.minfreqid,
        t2.source_type,
        t2.source_id,
        t3.source_name,
@@ -145,6 +212,7 @@
            </if>
        </where>
    </select>
    <select id="getMathPoint" resultType="com.iailab.module.data.point.dto.DaPointDTO">
        SELECT
        t1.point_no,
@@ -153,6 +221,7 @@
        t1.point_type,
        t1.data_type,
        t1.store_type,
        t1.minfreqid,
        t2.expression
        FROM t_da_point t1
        LEFT JOIN t_da_math_point t2 ON t2.point_id = t1.id
iailab-module-model/.flattened-pom.xml
文件已删除
iailab-module-model/iailab-module-model-api/.flattened-pom.xml
文件已删除
iailab-module-model/iailab-module-model-biz/.flattened-pom.xml
文件已删除
iailab-module-model/iailab-module-model-biz/db/mysql.sql
@@ -419,7 +419,7 @@
-- config
INSERT INTO `iailab_plat_system`.`infra_config` (`id`, `category`, `type`, `name`, `config_key`, `value`, `visible`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (13, 'model', 2, 'model文件备份路径', 'mpkBakFilePath', 'C:\\DLUT\\mpkBakFile', b'1', 'model文件备份路径', '1', '2024-09-12 11:10:25', '1', '2024-09-12 11:10:25', b'0');
--INSERT INTO `iailab_plat_system`.`infra_config` (`id`, `category`, `type`, `name`, `config_key`, `value`, `visible`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (13, 'model', 2, 'model文件备份路径', 'mpkBakFilePath', 'C:\\DLUT\\mpkBakFile', b'1', 'model文件备份路径', '1', '2024-09-12 11:10:25', '1', '2024-09-12 11:10:25', b'0');
-- dist
INSERT INTO `iailab_plat_system`.`system_dict_type` (`id`, `name`, `type`, `status`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `deleted_time`) VALUES (618, '模型方法', 'model_method', 0, '', '1', '2024-09-09 16:11:55', '1', '2024-09-09 16:11:55', b'0', '1970-01-01 00:00:00');
@@ -628,4 +628,42 @@
                                    `name` varchar(36) NOT NULL COMMENT '名称',
                                    `sort` integer DEFAULT NULL COMMENT '排序',
                                    PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '模型文件分组' ROW_FORMAT = Dynamic;
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '模型文件分组' ROW_FORMAT = Dynamic;
alter table t_mm_predict_model add column `mpkprojectid` varchar(36) DEFAULT NULL;
-- chart 图表配置
-- menu
INSERT INTO `iailab_plat_system`.`system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `app_id`, `tenant_id`) VALUES (1803317368435416399, '图表管理', '', 1, 40, 1803317368415416363, 'chart', 'fa:align-left', '', '', 0, b'1', b'1', b'1', '1', '2024-11-05 11:57:25', '1', '2024-11-05 11:57:49', b'0', 0, 1);
INSERT INTO `iailab_plat_system`.`system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `app_id`, `tenant_id`) VALUES (1803317368435416400, '图表配置', '', 2, 1, 1803317368435416399, 'chartParam', 'fa-solid:cogs', 'model/chart/index', 'ChartParam', 0, b'1', b'1', b'1', '1', '2024-11-05 12:01:59', '1', '2024-11-06 08:45:17', b'0', 0, 1);
INSERT INTO `iailab_plat_system`.`system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `app_id`, `tenant_id`) VALUES (1803317368435416401, '查询', 'model:chart:query', 3, 1, 1803317368435416400, '', '', '', '', 0, b'1', b'1', b'1', '1', '2024-11-05 15:36:48', '1', '2024-11-05 15:36:48', b'0', NULL, 1);
INSERT INTO `iailab_plat_system`.`system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `app_id`, `tenant_id`) VALUES (1803317368435416402, '新增', 'model:chart:create', 3, 2, 1803317368435416400, '', '', '', '', 0, b'1', b'1', b'1', '1', '2024-11-05 15:37:03', '1', '2024-11-05 15:37:03', b'0', NULL, 1);
INSERT INTO `iailab_plat_system`.`system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `app_id`, `tenant_id`) VALUES (1803317368435416403, '修改', 'model:chart:update', 3, 3, 1803317368435416400, '', '', '', '', 0, b'1', b'1', b'1', '1', '2024-11-05 15:37:20', '1', '2024-11-05 15:37:20', b'0', NULL, 1);
INSERT INTO `iailab_plat_system`.`system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `app_id`, `tenant_id`) VALUES (1803317368435416404, '删除', 'model:chart:delete', 3, 4, 1803317368435416400, '', '', '', '', 0, b'1', b'1', b'1', '1', '2024-11-05 15:37:38', '1', '2024-11-05 15:37:38', b'0', NULL, 1);
-- table
CREATE TABLE `t_chart` (
                           `id` varchar(36) NOT NULL,
                           `chart_name` varchar(100) DEFAULT NULL COMMENT '图表名称',
                           `chart_code` varchar(100) DEFAULT NULL COMMENT '图表编码',
                           `create_time` timestamp NULL DEFAULT NULL COMMENT '创建时间',
                           `update_time` timestamp NULL DEFAULT NULL COMMENT '修改时间',
                           PRIMARY KEY (`id`),
                           UNIQUE KEY `uk_chart_code` (`chart_code`),
                           KEY `index_id` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='图表配置';
CREATE TABLE `t_chart_param` (
                                 `id` varchar(36) NOT NULL,
                                 `chart_id` varchar(36) NOT NULL COMMENT '图表id',
                                 `param_name` varchar(255) DEFAULT NULL COMMENT '参数名称',
                                 `param_code` varchar(100) DEFAULT NULL COMMENT '参数编码',
                                 `param_value` varchar(1000) DEFAULT NULL COMMENT '参数值',
                                 `remark` varchar(255) DEFAULT NULL COMMENT '备注',
                                 `create_time` timestamp NULL DEFAULT NULL COMMENT '创建时间',
                                 `update_time` timestamp NULL DEFAULT NULL COMMENT '修改时间',
                                 PRIMARY KEY (`id`,`chart_id`) USING BTREE,
                                 KEY `index_chart_id` (`chart_id`),
                                 CONSTRAINT `chart_id` FOREIGN KEY (`chart_id`) REFERENCES `t_chart` (`id`) ON DELETE CASCADE ON UPDATE RESTRICT
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='图表参数配置';
iailab-module-model/iailab-module-model-biz/pom.xml
@@ -15,7 +15,6 @@
        <maven.compiler.source>8</maven.compiler.source>
        <maven.compiler.target>8</maven.compiler.target>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <mdk.version>MDK.taisteel.202308231710</mdk.version>
        <easypoi.version>4.1.0</easypoi.version>
        <commons.io.version>2.11.0</commons.io.version>
        <velocity.version>1.7</velocity.version>
@@ -123,11 +122,6 @@
            <groupId>com.iail</groupId>
            <artifactId>IAILMDK</artifactId>
            <version>0.94.9</version>
        </dependency>
        <dependency>
            <groupId>com.iail</groupId>
            <artifactId>MDK</artifactId>
            <version>${mdk.version}</version>
        </dependency>
        <!-- MPK -->
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mpk/controller/admin/ChartController.java
对比新文件
@@ -0,0 +1,70 @@
package com.iailab.module.model.mpk.controller.admin;
import com.iailab.framework.common.page.PageData;
import com.iailab.framework.common.pojo.CommonResult;
import com.iailab.module.model.mpk.dto.ChartDTO;
import com.iailab.module.model.mpk.dto.ChartParamDTO;
import com.iailab.module.model.mpk.entity.ChartEntity;
import com.iailab.module.model.mpk.entity.ChartParamEntity;
import com.iailab.module.model.mpk.service.ChartService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import java.util.Map;
import static com.iailab.framework.common.pojo.CommonResult.success;
/**
 * @description:
 * @author: dzd
 * @date: 2024/11/5 11:43
 **/
@Tag(name = "图表参数")
@RestController
@RequestMapping("/model/chart")
public class ChartController {
    @Autowired
    private ChartService chartService;
    @GetMapping("page")
    @Operation(summary = "分页")
    @PreAuthorize("@ss.hasPermission('model:chart:query')")
    public CommonResult<PageData<ChartDTO>> page(@RequestParam Map<String, Object> params) {
        PageData<ChartDTO> page = chartService.page(params);
        return success(page);
    }
    @GetMapping("/get")
    @Operation(summary = "获得详情")
    public CommonResult<ChartEntity> get(@RequestParam("id") String id) {
        ChartEntity data = chartService.get(id);
        return success(data);
    }
    @PostMapping("/create")
    @Operation(summary = "创建")
    @PreAuthorize("@ss.hasPermission('model:chart:create')")
    public CommonResult<Boolean> save(@RequestBody ChartEntity entity) {
        chartService.create(entity);
        return success(true);
    }
    @PutMapping("/update")
    @Operation(summary = "更新")
    @PreAuthorize("@ss.hasPermission('model:chart:update')")
    public CommonResult<Boolean> update(@RequestBody ChartEntity entity) {
        chartService.update(entity);
        return success(true);
    }
    @DeleteMapping("/delete")
    @PreAuthorize("@ss.hasPermission('model:chart:delete')")
    public CommonResult<Boolean> delete(@RequestParam("id") String id) {
        chartService.delete(id);
        return success(true);
    }
}
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mpk/controller/admin/ChartParamController.java
对比新文件
@@ -0,0 +1,71 @@
package com.iailab.module.model.mpk.controller.admin;
import com.iailab.framework.common.page.PageData;
import com.iailab.framework.common.pojo.CommonResult;
import com.iailab.framework.common.pojo.PageResult;
import com.iailab.framework.common.util.object.BeanUtils;
import com.iailab.module.model.mpk.dto.ChartParamDTO;
import com.iailab.module.model.mpk.dto.MpkFileDTO;
import com.iailab.module.model.mpk.entity.ChartParamEntity;
import com.iailab.module.model.mpk.entity.IconEntity;
import com.iailab.module.model.mpk.service.ChartParamService;
import com.iailab.module.model.mpk.vo.IconPageReqVO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import java.util.List;
import java.util.Map;
import static com.iailab.framework.common.pojo.CommonResult.success;
/**
 * @description:
 * @author: dzd
 * @date: 2024/11/5 11:43
 **/
@Tag(name = "图表参数")
@RestController
@RequestMapping("/model/chart/param")
public class ChartParamController {
    @Autowired
    private ChartParamService chartParamService;
    @GetMapping("page")
    @Operation(summary = "分页")
    public CommonResult<PageData<ChartParamDTO>> page(@RequestParam Map<String, Object> params) {
        PageData<ChartParamDTO> page = chartParamService.page(params);
        return success(page);
    }
    @GetMapping("/get")
    @Operation(summary = "获得详情")
    public CommonResult<ChartParamEntity> get(@RequestParam("id") String id) {
        ChartParamEntity data = chartParamService.get(id);
        return success(data);
    }
    @PostMapping("/create")
    @Operation(summary = "创建")
    public CommonResult<Boolean> save(@RequestBody ChartParamEntity entity) {
        chartParamService.create(entity);
        return success(true);
    }
    @PutMapping("/update")
    @Operation(summary = "更新")
    public CommonResult<Boolean> update(@RequestBody ChartParamEntity entity) {
        chartParamService.update(entity);
        return success(true);
    }
    @DeleteMapping("/delete")
    public CommonResult<Boolean> delete(@RequestParam("id") String id) {
        chartParamService.delete(id);
        return success(true);
    }
}
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mpk/dao/ChartDao.java
对比新文件
@@ -0,0 +1,17 @@
package com.iailab.module.model.mpk.dao;
import com.iailab.framework.common.dao.BaseDao;
import com.iailab.framework.tenant.core.db.dynamic.TenantDS;
import com.iailab.module.model.mpk.entity.ChartEntity;
import org.apache.ibatis.annotations.Mapper;
/**
 * @description:
 * @author: dzd
 * @date: 2024/11/5 11:19
 **/
@TenantDS
@Mapper
public interface ChartDao extends BaseDao<ChartEntity> {
}
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mpk/dao/ChartParamDao.java
对比新文件
@@ -0,0 +1,17 @@
package com.iailab.module.model.mpk.dao;
import com.iailab.framework.common.dao.BaseDao;
import com.iailab.framework.tenant.core.db.dynamic.TenantDS;
import com.iailab.module.model.mpk.entity.ChartParamEntity;
import org.apache.ibatis.annotations.Mapper;
/**
 * @description:
 * @author: dzd
 * @date: 2024/11/5 11:19
 **/
@TenantDS
@Mapper
public interface ChartParamDao extends BaseDao<ChartParamEntity> {
}
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mpk/dto/ChartDTO.java
对比新文件
@@ -0,0 +1,47 @@
package com.iailab.module.model.mpk.dto;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
/**
 * @description: 图表参数
 * @author: dzd
 * @date: 2024/11/5 11:17
 **/
@Data
public class ChartDTO implements Serializable {
    private static final long serialVersionUID = 1L;
    /**
     * id
     */
    @TableId
    private String id;
    /**
     * 图表名称
     */
    private String chartName;
    /**
     * 图表编码
     */
    private String chartCode;
    /**
     * 创建时间
     */
    private Date createTime;
    /**
     * 修改时间
     */
    private Date updateTime;
    private List<ChartParamDTO> chartParams;
}
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mpk/dto/ChartParamDTO.java
对比新文件
@@ -0,0 +1,56 @@
package com.iailab.module.model.mpk.dto;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
 * @description: 图表参数
 * @author: dzd
 * @date: 2024/11/5 11:17
 **/
@Data
public class ChartParamDTO implements Serializable {
    private static final long serialVersionUID = 1L;
    /**
     * id
     */
    private String id;
    /**
     * 图表id
     */
    private String chartId;
    /**
     * 参数名称
     */
    private String paramName;
    /**
     * 参数编码
     */
    private String paramCode;
    /**
     * 参数值
     */
    private String paramValue;
    /**
     * 备注
     */
    private String remark;
    /**
     * 创建时间
     */
    private Date createTime;
    /**
     * 修改时间
     */
    private Date updateTime;
}
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mpk/entity/ChartEntity.java
对比新文件
@@ -0,0 +1,45 @@
package com.iailab.module.model.mpk.entity;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
 * @description: 图表参数
 * @author: dzd
 * @date: 2024/11/5 11:17
 **/
@Data
@TableName("t_chart")
public class ChartEntity implements Serializable {
    private static final long serialVersionUID = 1L;
    /**
     * id
     */
    @TableId
    private String id;
    /**
     * 图表名称
     */
    private String chartName;
    /**
     * 图表编码
     */
    private String chartCode;
    /**
     * 创建时间
     */
    private Date createTime;
    /**
     * 修改时间
     */
    private Date updateTime;
}
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mpk/entity/ChartParamEntity.java
对比新文件
@@ -0,0 +1,60 @@
package com.iailab.module.model.mpk.entity;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
 * @description: 图表参数
 * @author: dzd
 * @date: 2024/11/5 11:17
 **/
@Data
@TableName("t_chart_param")
public class ChartParamEntity implements Serializable {
    private static final long serialVersionUID = 1L;
    /**
     * id
     */
    @TableId
    private String id;
    /**
     * 图表id
     */
    private String chartId;
    /**
     * 参数名称
     */
    private String paramName;
    /**
     * 参数编码
     */
    private String paramCode;
    /**
     * 参数值
     */
    private String paramValue;
    /**
     * 备注
     */
    private String remark;
    /**
     * 创建时间
     */
    private Date createTime;
    /**
     * 修改时间
     */
    private Date updateTime;
}
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mpk/service/ChartParamService.java
对比新文件
@@ -0,0 +1,29 @@
package com.iailab.module.model.mpk.service;
import com.iailab.framework.common.page.PageData;
import com.iailab.framework.common.pojo.PageResult;
import com.iailab.module.model.mpk.dto.ChartParamDTO;
import com.iailab.module.model.mpk.entity.ChartParamEntity;
import com.iailab.module.model.mpk.entity.IconEntity;
import com.iailab.module.model.mpk.vo.IconPageReqVO;
import java.util.List;
import java.util.Map;
/**
 * @description:
 * @author: dzd
 * @date: 2024/11/5 11:20
 **/
public interface ChartParamService {
    PageData<ChartParamDTO> page(Map<String, Object> params);
    void create(ChartParamEntity entity);
    void update(ChartParamEntity entity);
    ChartParamEntity get(String id);
    void delete(String id);
}
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mpk/service/ChartService.java
对比新文件
@@ -0,0 +1,25 @@
package com.iailab.module.model.mpk.service;
import com.iailab.framework.common.page.PageData;
import com.iailab.module.model.mpk.dto.ChartDTO;
import com.iailab.module.model.mpk.entity.ChartEntity;
import java.util.Map;
/**
 * @description:
 * @author: dzd
 * @date: 2024/11/5 11:20
 **/
public interface ChartService {
    PageData<ChartDTO> page(Map<String, Object> params);
    void create(ChartEntity entity);
    void update(ChartEntity entity);
    ChartEntity get(String id);
    void delete(String id);
}
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mpk/service/impl/ChartParamServiceImpl.java
对比新文件
@@ -0,0 +1,74 @@
package com.iailab.module.model.mpk.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.iailab.framework.common.page.PageData;
import com.iailab.framework.common.service.impl.BaseServiceImpl;
import com.iailab.module.model.mpk.dao.ChartParamDao;
import com.iailab.module.model.mpk.dto.ChartParamDTO;
import com.iailab.module.model.mpk.entity.ChartEntity;
import com.iailab.module.model.mpk.entity.ChartParamEntity;
import com.iailab.module.model.mpk.service.ChartParamService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.Map;
import java.util.UUID;
/**
 * @description:
 * @author: dzd
 * @date: 2024/11/5 11:21
 **/
@Slf4j
@Service
public class ChartParamServiceImpl extends BaseServiceImpl<ChartParamDao, ChartParamEntity> implements ChartParamService {
    @Override
    public PageData<ChartParamDTO> page(Map<String, Object> params) {
        IPage<ChartParamEntity> page = baseDao.selectPage(
                getPage(params, "create_time", false),
                getWrapper(params)
        );
        return getPageData(page, ChartParamDTO.class);
    }
    @Override
    public void create(ChartParamEntity entity) {
        entity.setId(UUID.randomUUID().toString());
        entity.setCreateTime(new Date());
        baseDao.insert(entity);
    }
    @Override
    public void update(ChartParamEntity entity) {
        entity.setUpdateTime(new Date());
        baseDao.updateById(entity);
    }
    @Override
    public ChartParamEntity get(String id) {
        return baseDao.selectById(id);
    }
    @Override
    public void delete(String id) {
        baseDao.deleteById(id);
    }
    private QueryWrapper<ChartParamEntity> getWrapper(Map<String, Object> params) {
        String paramName = (String) params.get("paramName");
        String paramCode = (String) params.get("paramCode");
        String chartId = (String) params.get("chartId");
        QueryWrapper<ChartParamEntity> wrapper = new QueryWrapper<>();
        wrapper.like(StringUtils.isNotBlank(paramName), "param_name", paramName)
                .like(StringUtils.isNotBlank(paramCode), "param_code", paramCode)
                .eq(StringUtils.isNotBlank(chartId), "chart_id", chartId);
        return wrapper;
    }
}
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mpk/service/impl/ChartServiceImpl.java
对比新文件
@@ -0,0 +1,74 @@
package com.iailab.module.model.mpk.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.iailab.framework.common.page.PageData;
import com.iailab.framework.common.service.impl.BaseServiceImpl;
import com.iailab.module.model.mpk.dao.ChartDao;
import com.iailab.module.model.mpk.dao.ChartParamDao;
import com.iailab.module.model.mpk.dto.ChartDTO;
import com.iailab.module.model.mpk.dto.ChartParamDTO;
import com.iailab.module.model.mpk.entity.ChartEntity;
import com.iailab.module.model.mpk.entity.ChartParamEntity;
import com.iailab.module.model.mpk.service.ChartParamService;
import com.iailab.module.model.mpk.service.ChartService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.Map;
import java.util.UUID;
/**
 * @description:
 * @author: dzd
 * @date: 2024/11/5 11:21
 **/
@Slf4j
@Service
public class ChartServiceImpl extends BaseServiceImpl<ChartDao, ChartEntity> implements ChartService {
    @Override
    public PageData<ChartDTO> page(Map<String, Object> params) {
        IPage<ChartEntity> page = baseDao.selectPage(
                getPage(params, "create_time", false),
                getWrapper(params)
        );
        return getPageData(page, ChartDTO.class);
    }
    @Override
    public void create(ChartEntity entity) {
        entity.setId(UUID.randomUUID().toString());
        entity.setCreateTime(new Date());
        baseDao.insert(entity);
    }
    @Override
    public void update(ChartEntity entity) {
        entity.setUpdateTime(new Date());
        baseDao.updateById(entity);
    }
    @Override
    public ChartEntity get(String id) {
        return baseDao.selectById(id);
    }
    @Override
    public void delete(String id) {
        baseDao.deleteById(id);
    }
    private QueryWrapper<ChartEntity> getWrapper(Map<String, Object> params) {
        String chartName = (String) params.get("chartName");
        String chartCode = (String) params.get("chartCode");
        QueryWrapper<ChartEntity> wrapper = new QueryWrapper<>();
        wrapper.like(StringUtils.isNotBlank(chartName), "chart_name", chartName)
                .like(StringUtils.isNotBlank(chartCode), "chart_code", chartCode);
        return wrapper;
    }
}
iailab-module-model/iailab-module-model-biz/src/main/java/iail/mdk/model/common/Environment.java
对比新文件
@@ -0,0 +1,26 @@
package iail.mdk.model.common;
public class Environment {
    public Environment() {
    }
    private native int jniInit();
    private native int jniIsInit();
    private native int jniRelease();
    private native int statusCode();
    public int init() {
        return this.jniInit();
    }
    public int isInit() {
        return this.jniIsInit();
    }
    public int release() {
        return this.jniRelease();
    }
}
iailab-module-model/iailab-module-model-biz/src/main/resources/application.yml
@@ -215,6 +215,8 @@
      - t_mpk_icon
      - t_mpk_file_menu
      - t_mpk_file_group
      - t_chart_param
      - t_chart
  app:
    app-key: model
    app-secret: 85b0df7edc3df3611913df34ed695011
iailab-module-model/iailab-module-model-biz/src/main/resources/template/cpp.vm
@@ -106,7 +106,12 @@
        delete[] pArg;
        pArg = nullptr;
        delete pArg;*/
        delete pArg;
        Py_DECREF(pReturn);
        Py_DECREF(pFunc);
        Py_DECREF(pModule);
        Py_CLEAR(pModule);*/
        return result;
    }
logs/log-debug.2024-09-30.log
文件已删除