From a6de490948278991e47952e90671ddba4555e9a2 Mon Sep 17 00:00:00 2001 From: houzhongjian <houzhongyi@126.com> Date: 星期二, 23 七月 2024 11:22:33 +0800 Subject: [PATCH] 1、update framework 2、转移数据平台和模型管理代码 --- iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/dao/StModelSettingDao.java | 24 iailab-module-data/iailab-module-data-biz/src/main/resources/mapper/ind/IndItemDao.xml | 74 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/common/IndItemTypeEnum.java | 37 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/dao/PrdPlanYearDao.java | 15 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/handler/ModelHandler.java | 360 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/annotation/DataFilter.java | 37 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/aspect/DictAspect.java | 166 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/framework/security/config/SecurityConfiguration.java | 48 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/service/impl/StModelSettingServiceImpl.java | 79 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/collection/handler/CalculateHandle.java | 157 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/modbus/entity/ChannelModBusTagEntity.java | 78 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/entity/DeviceEvaluateIndexEntity.java | 32 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/dto/StModelOutDTO.java | 40 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/AnyProc4Task.java | 83 iailab-framework/iailab-common-mybatis/src/main/java/com/iailab/framework/mybatis/interceptor/DataFilterInterceptor.java | 89 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/kio/dto/KIOWriteIntDTO.java | 17 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/enums/CommonConstant.java | 561 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/dto/DaPointMeasureDTO.java | 23 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/DeviceRunStateService.java | 19 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/gateway/controller/ApiServerController.java | 94 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/controller/PageCharsController.java | 36 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/any/service/impl/AnyProcCardServiceImpl.java | 38 iailab-module-data/iailab-module-data-api/src/main/java/com/iailab/module/data/dto/FileDto.java | 18 iailab-module-model/iailab-module-model-api/src/main/java/com/iailab/dto/FeignWashToWashDTO.java | 67 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/opcua/service/impl/ChannelOPCUATagServiceImpl.java | 193 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/annotation/DataFilter.java | 37 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/indexdata/common/IndexDataConstant.java | 79 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/service/impl/StModelRunlogServiceImpl.java | 118 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/impl/DeviceInfoServiceImpl.java | 140 iailab-module-model/iailab-module-model-biz/src/main/resources/mapper/mcs/StModelOutDao.xml | 20 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/controller/package-info.java | 1 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/WatchDogZX1Task.java | 41 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/gateway/service/impl/ApiGroupServiceImpl.java | 77 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/entity/StModelRunlogEntity.java | 44 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/service/impl/IndItemCalServiceImpl.java | 98 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dao/DeviceIndexDao.java | 15 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/common/PointTypeEnum.java | 37 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/SyncPrdTimeDayTask.java | 38 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/entity/PrdCurrentPerformanceEntity.java | 29 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/service/PageCharsService.java | 9 iailab-module-model/iailab-module-model-biz/src/main/resources/mapper/device/DeviceAbnormalHistoryDao.xml | 12 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/dto/StModelRequestLogDTO.java | 37 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/dto/vue/CascaderOptionDTO.java | 22 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/http/dto/HttpTagDTO.java | 17 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/dto/ScheduleJobLogDTO.java | 53 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/kio/service/impl/ChannelKioTagServiceImpl.java | 106 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/api/controller/DataController.java | 282 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/any/controller/AnyProcReportController.java | 81 iailab-module-model/iailab-module-model-biz/src/main/resources/mapper/report/DeviceHealthReportDataDao.xml | 12 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/config/MybatisPlusConfig.java | 42 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/sample/entity/DataEntity.java | 12 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/gateway/entity/ApiServerEntity.java | 32 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/http/dao/FxjyTagDao.java | 14 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/gateway/controller/ApiGroupController.java | 94 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/param/dto/ResultPointAndTrendDataDTO.java | 38 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/http/dto/TagCurrentSaleJsonDto.java | 92 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/entity/PrdDayDutyEntity.java | 39 iailab-module-model/iailab-module-model-biz/src/main/resources/mapper/report/AnyProcReportDetDao.xml | 12 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/http/controller/package-info.java | 1 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/dao/StModelParamDao.java | 24 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/service/impl/ScheduleJobServiceImpl.java | 131 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/entity/StModelRequestLogEntity.java | 51 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/controller/DeviceHealthStateController.java | 157 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/utils/MD5Util.java | 29 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/any/entity/AnyProcCardEntity.java | 39 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/interceptor/DataScope.java | 36 iailab-module-data/iailab-module-data-biz/src/main/resources/mapper/da/DaPointDao.xml | 167 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/dao/PrdPlanMonDao.java | 16 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/dto/IndexQueryDTO.java | 20 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/dto/StModelSettingDTO.java | 36 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/sample/constructor/SampleInfoConstructor.java | 172 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/dao/ScheduleJobLogDao.java | 26 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/dto/StorageDayDTO.java | 31 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/tag/dto/TagValueDTO.java | 25 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/service/ScheduleJobService.java | 64 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/DeviceIndexService.java | 20 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/interceptor/DataScope.java | 36 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/impl/DeviceStatNewnessServiceImpl.java | 119 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/kio/dto/KIOWriteBooleanDTO.java | 17 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/cons/entity/ConsDayDataEntity.java | 127 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/service/ScheduleJobLogService.java | 28 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/http/collector/HttpCollectorForZxzk.java | 136 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/tag/dto/TagValueQueryDTO.java | 17 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/exception/RRExceptionHandler.java | 56 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/indexdata/controller/package-info.java | 1 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/entity/DeviceHealthAlarmEntity.java | 31 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/http/service/impl/HttpTokenServiceImpl.java | 79 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/controller/ScheduleJobController.java | 115 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/entity/DaPointEntity.java | 113 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/entity/DeviceHealthReportDataEntity.java | 33 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/excel/StModelRunlogExcel.java | 28 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/quality/dto/QualityQualityTrendDayDTO.java | 38 iailab-module-data/iailab-module-data-api/src/main/java/com/iailab/module/data/dto/FeignFileSaveDto.java | 24 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/init/JobCommandLineRunner.java | 54 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/gateway/dao/ApiInfoDao.java | 23 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/collection/utils/IndSqlUtils.java | 89 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/enums/JsErrorCode.java | 10 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/gateway/vo/SysGatewayRoute.java | 56 iailab-module-model/iailab-module-model-biz/src/main/resources/mapper/device/DeviceStatUsageDao.xml | 13 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/dao/ScheduleJobDao.java | 32 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/indexdata/controller/admin/IndexDataItemController.java | 93 iailab-module-system/iailab-module-system-api/src/main/java/com/iailab/module/system/api/permission/dto/RoleDTO.java | 64 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/modbus/collector/ModBusCollector.java | 135 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/excel/DeviceHealthStateExcel.java | 33 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/utils/Constant.java | 119 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/dto/PrdCurrentPerformanceDTO.java | 35 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/gateway/entity/ApiAuthorizedEntity.java | 39 iailab-module-data/iailab-module-data-api/src/main/java/com/iailab/module/package-info.java | 1 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/utils/HttpRequest.java | 235 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/kio/dto/KIOWriteDTO.java | 19 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/http/service/impl/FxjyTagServiceImpl.java | 238 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/any/service/AnySugLibService.java | 15 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/entity/StModelEntity.java | 118 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/modbus/service/ChannelModbusTagService.java | 81 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/knowledge/entity/KnowledgePathEntity.java | 36 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/WatchControllerOn3Task.java | 50 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/websocket/config/WebSocketConfig.java | 18 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/exception/RRException.java | 53 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/knowledge/dto/KnowledgeDetDTO.java | 66 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/opcua/dao/ChannelOPCUADeviceDao.java | 19 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/service/impl/DaPointValueServiceImpl.java | 59 iailab-module-model/iailab-module-model-biz/src/main/resources/application-dev.yml | 91 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/DeviceHealthReportService.java | 25 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/DeviceAccountService.java | 21 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/modbus/entity/ChannelModBusDeviceEntity.java | 85 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/service/impl/StorageDayServiceImpl.java | 76 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/dto/ScheduleJobDTO.java | 62 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/service/impl/DaPointServiceImpl.java | 257 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/service/impl/PrdDayDutyServiceImpl.java | 84 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/any/dto/AnyProcParamDTO.java | 29 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/kio/collector/KingIOClient.java | 224 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/entity/StorageDayEntity.java | 36 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/oss/controller/OssFileController.java | 123 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/dao/StModelRunlogDao.java | 37 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/kio/dto/ChannelKioDeviceDTO.java | 45 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/entity/DeviceAbnormalHistoryEntity.java | 36 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/controller/DeviceFaultController.java | 110 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/dto/StModelParamDTO.java | 46 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dao/DeviceHealthEvaluateDao.java | 14 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/kio/dto/ChannelKioTagDTO.java | 50 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/dao/ScheduleJobDao.java | 29 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/impl/DeviceHealthEvaluateServiceImpl.java | 142 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/SyncPrdDayProdTask.java | 36 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/event/ws/EventWebSocketClient.java | 82 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/dto/vue/CascaderOptionDTO.java | 22 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/excel/DeviceInfoExcel.java | 45 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/knowledge/service/impl/KnowledgePathServiceImpl.java | 136 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/impl/DeviceEvaluateIndexServiceImpl.java | 54 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/impl/DeviceHealthAlarmServiceImpl.java | 55 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/entity/DeviceStatCountEntity.java | 45 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/impl/DeviceMainServiceImpl.java | 67 iailab-module-model/iailab-module-model-biz/src/main/resources/application-prod.yml | 82 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/entity/StModelSettingEntity.java | 46 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/framework/filter/MyHttpServletRequestWrapper.java | 74 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/modbus/dto/ChannelModbusTagDTO.java | 58 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/entity/PrdDayProdEntity.java | 33 iailab-module-model/iailab-module-model-biz/src/main/resources/mapper/device/DeviceInfoDao.xml | 34 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/event/ws/ReconnectThreadEnum.java | 34 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/framework/rpc/package-info.java | 4 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dao/DeviceAccountDao.java | 27 iailab-framework/iailab-common-mybatis/src/main/java/com/iailab/framework/common/page/PageData.java | 43 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/gateway/controller/ApiAuthorizedController.java | 86 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/DataWebApplication.java | 14 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dao/DeviceStatUsageDao.java | 19 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/DeviceStatNewnessService.java | 21 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/indexdata/dao/IndexDataItemDao.java | 14 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/event/service/impl/EventInfoServiceImpl.java | 43 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/WatchControllerOn5Task.java | 50 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/entity/StModelDocEntity.java | 83 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/service/IndexEvaluateSystemService.java | 35 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/api/dto/ApiExportValueDTO.java | 24 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/common/IndTimeRangeEnum.java | 42 iailab-module-data/iailab-module-data-api/src/main/java/com/iailab/module/data/dto/AlarmTaskDto.java | 58 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/utils/DateUtils.java | 302 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/DeviceHealthStateService.java | 19 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/entity/ModelEntity.java | 122 iailab-framework/iailab-common/src/main/java/com/iailab/framework/common/annotation/BpmStatus.java | 25 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/entity/DeviceMainEntity.java | 42 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/opcua/service/ChannelOPCUATagService.java | 70 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/impl/DeviceAccountHistoryServiceImpl.java | 32 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/oss/service/impl/OssFileServiceImpl.java | 108 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/entity/ScheduleJobEntity.java | 61 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/knowledge/dao/KnowledgeDetDao.java | 14 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/gateway/dao/ApiAuthorizedDao.java | 27 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/collection/handler/MeasureHandle.java | 235 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/entity/DeviceFaultEntity.java | 55 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/cons/service/ConsDayDataService.java | 14 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/dao/PrdDayDutyDao.java | 14 iailab-module-model/iailab-module-model-api/pom.xml | 48 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/service/DaMathPointService.java | 23 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/ModelXLThickenerTask.java | 180 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/framework/package-info.java | 6 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/impl/DeviceHealthReportServiceImpl.java | 167 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/influxdb/service/impl/InfluxDBServiceImpl.java | 336 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/any/dto/AnyTrendResultDTO.java | 47 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/opcua/controller/admin/ChannelOPCUADeviceController.java | 108 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/gateway/vo/SysGatewayApi.java | 23 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/param/dto/PointDataValueDTO.java | 28 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/dto/PrdPlanYearDTO.java | 37 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/collection/PointCollector.java | 137 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/service/StorageDayService.java | 14 iailab-module-model/iailab-module-model-biz/src/main/resources/mapper/mcs/StModelParamDao.xml | 14 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/dto/PrdDayDutyDTO.java | 40 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/controller/DeviceInfoController.java | 211 iailab-cloud/iailab-xxl-job/src/main/resources/i18n/message_zh_CN.properties | 494 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/http/dto/TokenJsonDto.java | 17 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/SyncPrdCurrentSaleTask.java | 36 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/kio/service/impl/ChannelKioDeviceServiceImpl.java | 83 docker-compose.yml | 93 iailab-module-data/iailab-module-data-biz/src/main/resources/application-dev.yml | 82 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/service/StModelSettingService.java | 24 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/service/impl/PrdPlanMonServiceImpl.java | 187 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/opcua/entity/ChannelOPCUADeviceEntity.java | 77 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/dto/IndexQueryDTO.java | 15 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/watch/WatchDog.java | 107 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/oss/dto/OssFileDTO.java | 48 iailab-module-model/iailab-module-model-biz/src/main/resources/mapper/mcs/StModelRunlogDao.xml | 70 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/any/service/AnyProcReportService.java | 31 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/FakeDataTask.java | 103 iailab-module-data/iailab-module-data-biz/src/main/resources/logback-spring.xml | 76 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dto/DeviceEvaluateIndexDTO.java | 30 iailab-module-model/iailab-module-model-biz/src/main/resources/mapper/device/DeviceStatCountDao.xml | 6 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/enums/CommonConstant.java | 433 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/framework/rpc/config/RpcConfiguration.java | 14 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/WatchControllerOn7Task.java | 50 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/annotation/SysLog.java | 16 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/service/DaMeasurePointService.java | 23 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/influxdb/pojo/InfluxTagValuePOJO.java | 26 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/common/IncreaseCodeEnum.java | 11 iailab-module-model/iailab-module-model-biz/src/main/resources/mapper/job/ScheduleJobLogDao.xml | 7 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/utils/Constant.java | 119 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/impl/DeviceFaultServiceImpl.java | 47 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/any/service/AnyProcReportDetService.java | 24 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/controller/admin/IndItemCalController.java | 9 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/collection/IndItemCollector.java | 85 iailab-module-model/iailab-module-model-biz/src/test/java/com/iailab/OadpTagCollectorTest.java | 43 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/dao/IndItemAtomDao.java | 14 iailab-module-data/iailab-module-data-api/src/main/java/com/iailab/module/data/dto/FeignHttpApiDTO.java | 32 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/AnyProc1Task.java | 80 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/service/impl/PrdDayProdServiceImpl.java | 299 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dao/DeviceHealthReportDao.java | 18 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/framework/filter/MyFilter.java | 31 iailab-module-model/iailab-module-model-biz/src/main/resources/mapper/device/DeviceHealthAlarmDao.xml | 36 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/xss/XssFilter.java | 29 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/DeviceInfoService.java | 33 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/gateway/service/ApiGroupService.java | 29 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/indexdata/entity/IndexDataValueEntity.java | 121 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/entity/DeviceInfoEntity.java | 46 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/init/JobCommandLineRunner.java | 47 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dao/DeviceAccountHistoryDao.java | 16 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/enums/DataTypeEnum.java | 24 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/common/IndtimeGranularityEnum.java | 37 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/opcua/dto/ChannelOPCUATagDTO.java | 52 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/influxdb/pojo/InfluxPointValuePOJO.java | 25 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/xss/SQLFilter.java | 42 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/dao/StModelOutDao.java | 22 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/opcua/service/impl/ChannelOPCUADeviceServiceImpl.java | 114 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/dto/PageCharsDTO.java | 43 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/DeviceAbnormalHistoryService.java | 21 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/enums/SourceTypeEnum.java | 24 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/http/service/HttpApiService.java | 21 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/dto/IndexStatisticDTO.java | 15 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/SyncPrdPlanTask.java | 38 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/dao/PrdTimeDayDao.java | 14 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/any/dao/AnyProcParamDao.java | 14 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/service/impl/PageCharsServiceImpl.java | 295 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/param/dto/PageParamDTO.java | 20 iailab-module-model/iailab-module-model-api/src/main/java/com/iailab/api/IFeignProddispApi.java | 94 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dao/DeviceInfoDao.java | 23 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/indexdata/common/IndexDataBc.java | 10 iailab-cloud/iailab-xxl-job/.gitignore | 7 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/cons/dto/ConsDayDataDTO.java | 83 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/controller/ScheduleJobLogController.java | 63 iailab-module-model/iailab-module-model-api/src/main/java/com/iailab/dto/FeignRunTimeDTO.java | 57 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/opcua/dao/ChannelOPCUATagDao.java | 17 iailab-framework/iailab-common-mybatis/src/main/java/com/iailab/framework/common/service/impl/CrudServiceImpl.java | 80 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/param/controller/PageParamController.java | 180 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/service/StModelDocService.java | 20 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/utils/ScheduleUtils.java | 162 iailab-module-model/iailab-module-model-api/src/main/java/com/iailab/dto/FeignPowerConsumeDTO.java | 72 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/xss/HTMLFilter.java | 530 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/collection/handler/AtomItemHandle.java | 91 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/quality/service/QualityQualityTrendDayService.java | 33 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/http/service/impl/HttpApiServiceImpl.java | 57 iailab-module-data/iailab-module-data-biz/src/main/resources/mapper/job/ScheduleJobDao.xml | 14 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/any/dto/AnyAllEvaluationDTO.java | 33 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/excel/DeviceAbnormalHistoryExcel.java | 25 iailab-module-data/iailab-module-data-api/src/main/java/com/iailab/module/data/dto/ApiDataPointDTO.java | 26 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/dao/PrdCurrentSaleDao.java | 15 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/config/SwaggerConfig.java | 69 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/any/entity/AnySugLibEntity.java | 33 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/any/entity/AnyProcParamEntity.java | 34 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/exception/RRException.java | 53 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/task/HttpCollectDeviceTask.java | 42 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/knowledge/dto/KnowledgePathDTO.java | 34 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/framework/rpc/config/RpcConfiguration.java | 14 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/knowledge/service/KnowledgeDetService.java | 26 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/utils/ExcelUtil.java | 140 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/service/impl/DaSequenceNumServiceImpl.java | 32 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dao/DeviceStatCountDao.java | 16 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dto/DeviceListJsonDto.java | 12 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/service/impl/IndItemServiceImpl.java | 208 iailab-framework/iailab-common/src/main/java/com/iailab/framework/common/constant/CacheConstant.java | 108 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/entity/IndItemAtomEntity.java | 26 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/modbus/dao/ChannelModBusDeviceDao.java | 18 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/knowledge/controller/KnowledgePathController.java | 107 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/indexdata/controller/admin/IndexDataClockController.java | 109 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/controller/admin/StModelController.java | 250 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/config/ScheduleConfig.java | 58 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/any/service/impl/AnySugLibServiceImpl.java | 30 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/dto/PrdDayProdDTO.java | 37 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/utils/R.java | 64 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/controller/admin/IndItemAtomController.java | 9 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/service/DaSequenceNumService.java | 14 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/ModelSeparationTask.java | 209 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/gateway/entity/ApiInfoEntity.java | 36 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/service/StModelOutService.java | 25 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/param/dto/PageParamResultValueDTO.java | 21 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/excel/DeviceRunStateExcel.java | 29 iailab-framework/iailab-common/src/main/java/com/iailab/framework/common/validation/group/Group.java | 22 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/dto/DaPointDTO.java | 115 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/dto/echarts/BarLineDTO.java | 27 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dto/DeviceRunStateDTO.java | 41 iailab-module-data/iailab-module-data-api/src/main/java/com/iailab/module/data/dto/FeignWritePointValueDTO.java | 24 iailab-module-data/iailab-module-data-biz/src/main/resources/application-prod.yml | 67 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/sample/dto/ColumnItemPort.java | 20 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/event/dto/EventInfoDTO.java | 70 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/kio/dao/ChannelKioDeviceDao.java | 14 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/utils/JavaScriptHandler.java | 27 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/http/entity/FxjyTagEntity.java | 53 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/controller/DeviceAccountController.java | 120 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/impl/DeviceStatUsageServiceImpl.java | 178 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/enums/ModelResultEnum.java | 39 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/service/impl/DaMathPointServiceImpl.java | 54 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/entity/IndItemEntity.java | 96 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/annotation/LogOperation.java | 24 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/entity/ScheduleJobLogEntity.java | 62 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/ITask.java | 25 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/http/dao/HttpTokenDao.java | 10 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/ModelXLFilterTask.java | 184 iailab-module-data/iailab-module-data-biz/src/main/resources/mapper/job/ScheduleJobLogDao.xml | 7 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/entity/DeviceIndexEntity.java | 28 iailab-module-data/iailab-module-data-biz/src/main/resources/banner.txt | 8 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/websocket/api/dto/ApiMsgDTO.java | 48 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/http/controller/admin/HttpApiController.java | 82 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dao/DeviceAbnormalHistoryDao.java | 23 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/service/PrdDayDutyService.java | 14 iailab-module-model/pom.xml | 25 iailab-module-model/iailab-module-model-api/src/main/java/com/iailab/dto/FeignWashProdVolumeDTO.java | 98 iailab-module-data/iailab-module-data-biz/src/test/java/com/iailab/InfluxDBTest.java | 68 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/api/ApiModelController.java | 167 iailab-framework/iailab-common/src/main/java/com/iailab/framework/common/validation/group/AddGroup.java | 19 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/indexdata/common/IndexDataUtils.java | 768 iailab-module-model/iailab-module-model-biz/src/main/resources/mapper/report/AnyProcReportDao.xml | 12 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/service/DaPointService.java | 53 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/task/HttpCollectHealthStateTask.java | 47 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/package-info.java | 1 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/framework/filter/RequestReadUtils.java | 27 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/enums/IsEnableEnum.java | 21 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/any/dao/AnySugLibDao.java | 14 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/controller/DeviceHealthEvaluateController.java | 98 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/service/impl/PrdTimeDayServiceImpl.java | 76 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dto/DeviceHealthAlarmDTO.java | 34 iailab-module-model/iailab-module-model-api/src/main/java/com/iailab/dto/FeignWarehousePositionDTO.java | 58 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/entity/DeviceRunStateEntity.java | 44 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/kio/controller/package-info.java | 1 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/dto/RunSetDTO.java | 22 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/dto/IndItemAtomDTO.java | 26 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/utils/ScheduleJob.java | 79 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/cons/dao/ConsDayDataDao.java | 14 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/entity/DeviceAccountHistoryEntity.java | 80 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dto/DeviceCurrentRateDTO.java | 26 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/framework/rpc/package-info.java | 4 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/utils/HttpContextUtils.java | 24 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/modbus/service/ChannelModbusDeviceService.java | 60 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/any/dto/AnyProcReportDTO.java | 38 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/WatchControllerOn1Task.java | 47 iailab-module-system/iailab-module-system-api/src/main/java/com/iailab/module/system/api/params/ParamsApi.java | 21 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/kio/entity/ChannelKioDeviceEntity.java | 65 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/utils/ScheduleJob.java | 78 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/DeviceHealthAlarmService.java | 19 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/indexdata/controller/admin/IndexDataValueController.java | 34 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/service/impl/PrdCurrentSaleServiceImpl.java | 342 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/service/StModelResultService.java | 48 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/dto/DaPointWriteValueDTO.java | 19 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/indexdata/service/impl/IndexDataItemServiceImpl.java | 86 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/AnyProc7Task.java | 83 iailab-module-model/iailab-module-model-api/src/main/java/com/iailab/api/IFeignModelApi.java | 44 iailab-module-model/iailab-module-model-api/src/main/java/com/iailab/dto/FeignMcMzDTO.java | 39 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/entity/DeviceHealthReportEntity.java | 37 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/excel/DeviceAccountHistoryExcel.java | 35 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/influxdb/pojo/InfluxTagValueStrPOJO.java | 17 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/WatchDogZX2Task.java | 41 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/service/impl/IndItemAtomServiceImpl.java | 96 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/config/ScheduleConfig.java | 58 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/any/dao/AnyProcCardDao.java | 14 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/http/dto/TagCurrentPerformanceJsonDto.java | 50 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/entity/DaSequenceNumEntity.java | 30 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/dto/StModelDocDTO.java | 85 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/http/entity/XSTTagEntity.java | 68 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/enums/CdbmEnum.java | 79 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/entity/DeviceHealthStateEntity.java | 52 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/dao/IndexEvaluateSystemDao.java | 14 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/http/entity/HttpTagEntity.java | 58 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/indexdata/service/IndexDataClockService.java | 31 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/http/service/HttpTokenService.java | 21 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/ModelStorageReliabilityTask.java | 49 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/dto/DaMathPointDTO.java | 34 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/framework/security/core/package-info.java | 4 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/influxdb/pojo/InfluxTagValueIntPOJO.java | 19 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/quality/entity/QualityQualityTrendDayEntity.java | 34 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/any/service/impl/AnyProcReportDetServiceImpl.java | 64 iailab-module-model/iailab-module-model-biz/src/main/resources/mapper/device/DeviceHealthStateDao.xml | 34 iailab-module-data/iailab-module-data-api/src/main/java/com/iailab/module/data/dto/FeignFileQueryDto.java | 19 iailab-module-data/iailab-module-data-biz/src/main/resources/mapper/http/HttpTagDao.xml | 15 iailab-module-infra/iailab-module-infra-api/src/main/java/com/iailab/module/infra/api/config/ConfigApi.java | 17 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/entity/DaMeasurePointEntity.java | 52 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/knowledge/entity/KnowledgeDetEntity.java | 82 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/task/HttpCollectUserTask.java | 46 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/DeviceHealthAlarmDetailService.java | 13 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/enums/DatabaseType.java | 9 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/websocket/config/ServerEncoder.java | 50 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/common/IndTimeRangeConst.java | 28 iailab-cloud/iailab-gateway/src/main/resources/application-local.yaml | 13 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/http/dao/XSTTagDao.java | 11 iailab-framework/iailab-common/src/main/java/com/iailab/framework/common/enums/ErrorCode.java | 46 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/any/entity/AnyProcReportEntity.java | 36 iailab-module-model/iailab-module-model-biz/src/main/resources/banner.txt | 8 iailab-module-model/iailab-module-model-api/src/main/java/com/iailab/dto/FeignConsumeTargetDTO.java | 58 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/feign/FeignModelImpl.java | 82 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/WatchControllerOn4Task.java | 49 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/service/StModelParamService.java | 24 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/utils/PythonUtil.java | 49 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/sample/dto/DataValue.java | 18 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/SyncDeviceInfoTask.java | 36 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/modbus/controller/admin/ChannelModbusTagController.java | 100 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/impl/DeviceHealthAlarmDetailServiceImpl.java | 19 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/controller/IndexEvaluateSystemController.java | 128 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/api/dto/ApiPointValueQueryDTO.java | 33 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/ModelShallowTask.java | 183 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/oss/dao/OssFileDao.java | 14 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/service/impl/ScheduleJobServiceImpl.java | 132 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/DeviceHealthReportDataService.java | 23 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/service/PrdTimeDayService.java | 14 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/DeviceAccountHistoryService.java | 15 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/DeviceEvaluateIndexService.java | 19 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/opcua/service/ChannelOPCUADeviceService.java | 60 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/entity/DeviceHealthEvaluateEntity.java | 57 iailab-module-model/iailab-module-model-biz/pom.xml | 192 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/modbus/service/impl/ChannelModbusDeviceServiceImpl.java | 121 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/gateway/service/ApiInfoService.java | 30 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/api/controller/TokenController.java | 52 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/utils/UnzipUtils.java | 103 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/sample/constructor/SampleDataConstructor.java | 293 iailab-framework/iailab-common/src/main/java/com/iailab/framework/common/annotation/AutoDict.java | 20 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/dto/StModelDTO.java | 94 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/event/dao/EventInfoDao.java | 14 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/utils/ExcelUtil.java | 140 iailab-module-data/iailab-module-data-api/src/main/java/com/iailab/module/data/dto/ApiDataDTO.java | 18 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dao/DeviceMainDao.java | 14 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/http/service/HttpTagService.java | 32 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/entity/StModelParamEntity.java | 55 iailab-framework/iailab-common/src/main/java/com/iailab/framework/common/constant/CommonConstant.java | 400 iailab-framework/iailab-common-mybatis/src/main/java/com/iailab/framework/common/entity/BaseEntity.java | 41 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/dao/ScheduleJobLogDao.java | 23 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/ModelQCThickenerTask.java | 181 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/any/service/impl/AnyProcReportServiceImpl.java | 216 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/influxdb/pojo/InfluxPointValueSimPOJO.java | 18 iailab-framework/iailab-common/src/main/java/com/iailab/framework/common/exception/ExceptionUtils.java | 53 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/indexdata/dao/IndexDataClockDao.java | 14 iailab-module-model/iailab-module-model-biz/src/main/resources/mapper/device/DeviceFaultDao.xml | 6 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/controller/admin/StModelRunlogController.java | 116 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/ModelServiceApplication.java | 25 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/DeviceFaultService.java | 17 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/service/impl/StModelRequestLogServiceImpl.java | 55 iailab-cloud/iailab-xxl-job/src/main/resources/templates/help.ftl | 180 iailab-framework/iailab-common-mybatis/src/main/java/com/iailab/framework/common/service/BaseService.java | 116 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/impl/DeviceStatCountServiceImpl.java | 66 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/command/PyCommand.java | 31 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/influxdb/pojo/InfluxTagValueBoolPOJO.java | 17 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/dto/ScheduleJobLogDTO.java | 53 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/sample/dto/SampleData.java | 13 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/kio/entity/ChannelKioTagEntity.java | 74 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/indexdata/service/IndexDataValueService.java | 18 iailab-module-data/iailab-module-data-api/src/main/java/com/iailab/module/data/dto/FeignResultDTO.java | 22 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/interceptor/DataFilterInterceptor.java | 89 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dao/DeviceHealthAlarmDao.java | 16 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/DeviceMainService.java | 16 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/influxdb/common/utils/TagValueUtils.java | 126 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/annotation/LogOperation.java | 24 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/dto/DaPointValueDTO.java | 32 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/tag/controller/TagController.java | 173 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/opcua/entity/ChannelOPCUATagEntity.java | 70 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/opcua/collector/OpcUaUtils.java | 262 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/opcua/controller/package-info.java | 1 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/modbus/collector/ModbusUtils.java | 229 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/dto/IndexEvaluateSystemDTO.java | 59 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/utils/HttpsRequest.java | 322 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/commons/HealthLevelEnum.java | 33 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/MigrationTableDataTask.java | 67 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/service/impl/StModelDocServiceImpl.java | 40 iailab-module-system/iailab-module-system-biz/src/main/java/com/iailab/module/system/service/params/ParamsServiceImpl.java | 160 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/utils/CommonUtils.java | 61 iailab-module-model/iailab-module-model-biz/src/main/resources/mapper/knowledge/KnowledgePathDao.xml | 29 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/DeviceHealthTask.java | 380 iailab-module-data/iailab-module-data-biz/src/main/resources/application-test.yml | 65 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/indexdata/dao/IndexDataValueDao.java | 17 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/excel/DeviceFaultExcel.java | 43 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/ModelWarehouseTask.java | 181 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/controller/admin/StModelDocController.java | 51 iailab-module-system/iailab-module-system-biz/src/main/java/com/iailab/module/system/service/params/ParamsService.java | 50 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/any/dao/AnyProcReportDetDao.java | 18 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/controller/DeviceStatNewnessController.java | 56 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/AnyProc5Task.java | 77 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/controller/DeviceHealthReportController.java | 54 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/quality/dao/QualityQualityTrendDayDao.java | 16 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/indexdata/service/impl/IndexDataValueServiceImpl.java | 55 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/influxdb/service/InfluxDBService.java | 44 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/service/StModelRunlogService.java | 33 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/http/dto/TagYearPeiJsonDto.java | 45 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dto/DeviceAbnormalHistoryDTO.java | 35 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/api/dto/ApiTagValueQueryDTO.java | 40 iailab-module-model/iailab-module-model-biz/src/main/resources/mapper/mcs/StModelResultDao.xml | 142 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/any/dto/AnyStoreReliabilityDTO.java | 23 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/service/impl/PrdPlanYearServiceImpl.java | 136 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/dto/IndItemDTO.java | 63 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/task/PointCollectTaskNetKIO10.java | 44 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/watch/WatchConstant.java | 167 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/indexdata/entity/IndexDataItemEntity.java | 184 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/http/dao/EleLowTagDao.java | 14 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/service/impl/StModelResultServiceImpl.java | 238 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/http/collector/HttpCollectorForUser.java | 85 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/indexdata/service/IndexDataItemService.java | 31 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/task/HttpCollectRunStateTask.java | 47 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/dao/DaSequenceNumDao.java | 14 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/dto/IndItemValueDTO.java | 29 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/gateway/service/ApiAppService.java | 29 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/task/HttpTokenTask.java | 40 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/dao/StModelDao.java | 16 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/dto/echarts/BarLineDTO.java | 27 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/any/entity/AnyProcReportDetEntity.java | 35 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/opcua/collector/OpcUaCollector.java | 117 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/service/PrdPlanMonService.java | 35 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/AnyProc3Task.java | 83 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/dao/IndItemDao.java | 25 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/SyncPrdDayDutyTask.java | 37 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/modbus/controller/admin/ChannelModbusDeviceController.java | 84 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/aspect/DictAspect.java | 152 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/aspect/SysLogAspect.java | 37 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/entity/DaPointValueEntity.java | 44 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dto/DeviceStatCountDTO.java | 43 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/sample/dto/SampleInfo.java | 19 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/dao/DaPointDao.java | 28 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/task/PointCollectTaskNet30.java | 43 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/any/service/impl/AnyProcParamServiceImpl.java | 31 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/utils/HttpRequest.java | 122 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/utils/MatlabUtil.java | 38 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/dto/RelationNodeDTO.java | 23 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/excel/DeviceAccountExcel.java | 47 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/dao/StModelRequestLogDao.java | 14 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/param/service/impl/PageParamServiceImpl.java | 42 iailab-module-data/iailab-module-data-biz/src/main/resources/mapper/gateway/ApiInfoDao.xml | 37 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/commons/HealthIndexTypeEnum.java | 35 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/entity/ScheduleJobLogEntity.java | 62 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/modbus/dto/ChannelModBusDeviceDTO.java | 83 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/kio/service/ChannelKioDeviceService.java | 29 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/gateway/service/ApiServerService.java | 28 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/event/entity/EventInfoEntity.java | 72 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/influxdb/common/config/InfluxDBInstance.java | 46 iailab-module-model/iailab-module-model-api/src/main/java/com/iailab/dto/FeignWarehouseItemDTO.java | 43 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/utils/Conversion.java | 31 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/entity/PrdPlanMonEntity.java | 33 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/kio/service/ChannelKioTagService.java | 33 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/indexdata/common/ClockSuffix.java | 10 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/dto/echarts/SeriesItem.java | 18 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/service/PrdDayProdService.java | 35 iailab-module-model/iailab-module-model-biz/src/main/resources/mapper/device/DeviceStatNewnessDao.xml | 24 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/modbus/service/impl/ChannelModbusTagServiceImpl.java | 206 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/package-info.java | 0 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/service/impl/DaMeasurePointServiceImpl.java | 56 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dao/DeviceHealthAlarmDetailDao.java | 14 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/impl/DeviceRunStateServiceImpl.java | 44 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/kio/controller/admin/ChannelKioTagController.java | 82 iailab-framework/iailab-common/src/main/java/com/iailab/framework/common/annotation/BpmProcess.java | 25 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/gateway/dao/ApiServerDao.java | 17 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/tag/dto/TagDTO.java | 56 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/dto/IndItemCalDTO.java | 23 iailab-module-data/iailab-module-data-biz/src/main/resources/mapper/ind/IndItemValueDao.xml | 21 iailab-module-data/iailab-module-data-biz/src/main/resources/application-uat.yml | 42 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/dao/DaMeasurePointDao.java | 14 iailab-framework/iailab-common/src/main/java/com/iailab/framework/common/constant/GlobalConstants.java | 29 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/controller/DeviceAccountHistoryController.java | 97 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/entity/DaMathPointEntity.java | 37 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/knowledge/controller/KnowledgeDetController.java | 92 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/influxdb/pojo/InfluxPointValueDigPOJO.java | 17 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/event/ws/EventWsBean.java | 24 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/gateway/service/impl/ApiInfoServiceImpl.java | 83 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/entity/PrdCurrentSaleEntity.java | 38 iailab-module-model/iailab-module-model-biz/src/main/resources/mapper/mcs/StModelDao.xml | 6 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/framework/security/core/package-info.java | 4 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/ModelControlReliabilityTask.java | 70 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/SyncConsDayDataTask.java | 36 iailab-framework/iailab-common/src/main/java/com/iailab/framework/common/annotation/Dict.java | 32 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/ModelBlowerTask.java | 202 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/utils/ScheduleUtils.java | 161 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/service/impl/StModelParamServiceImpl.java | 54 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/any/service/AnyProcCardService.java | 17 iailab-framework/iailab-common/src/main/java/com/iailab/framework/common/constant/Constant.java | 146 iailab-module-model/iailab-module-model-api/src/main/java/com/iailab/dto/FeignHourVolumeDTO.java | 64 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/enums/RowAction.java | 15 iailab-module-data/iailab-module-data-api/src/main/java/com/iailab/module/data/dto/FeignOrderTaskDTO.java | 140 iailab-module-data/iailab-module-data-api/src/main/java/com/iailab/module/data/dto/ApiPointValueQueryDTO.java | 32 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/enums/CommonDict.java | 13 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/influxdb/pojo/InfluxPointValueStrPOJO.java | 18 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/dao/IndItemCalDao.java | 14 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/influxdb/common/enums/DataMeasurement.java | 19 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/service/impl/StModelServiceImpl.java | 202 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/controller/DeviceHealthAlarmController.java | 52 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/utils/Query.java | 69 iailab-module-data/iailab-module-data-biz/src/main/resources/导入模板/OpcUa.xlsx | 0 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/entity/ScheduleJobEntity.java | 61 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/controller/DeviceRunStateController.java | 113 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/http/controller/admin/HttpTokenController.java | 96 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/any/dao/AnyProcReportDao.java | 18 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/service/ScheduleJobService.java | 63 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/service/impl/StModelOutServiceImpl.java | 67 iailab-framework/iailab-common-mybatis/src/main/java/com/iailab/framework/mybatis/core/enums/DbTypeEnum.java | 84 iailab-module-data/iailab-module-data-api/src/main/java/com/iailab/module/data/dto/FeignFixDetDTO.java | 9 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/dao/StModelResultDao.java | 44 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/common/PointDataTypeEnum.java | 34 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/enums/PostalStatus.java | 23 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/api/utils/ApiSecurityUtils.java | 81 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dao/DeviceRunStateDao.java | 23 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/service/impl/PrdCurrentPerformanceServiceImpl.java | 152 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/service/impl/IndItemValueServiceImpl.java | 82 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/SyncQualityTrendDayTask.java | 36 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/dao/StorageDayDao.java | 14 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/impl/DeviceHealthReportDataServiceImpl.java | 68 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/http/controller/admin/HttpTagController.java | 103 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/dto/PrdPlanMonDTO.java | 37 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/any/dto/AnyProcCardDTO.java | 36 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/service/impl/ScheduleJobLogServiceImpl.java | 57 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/task/PointCollectTaskNet10.java | 44 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/enums/SuperAdminEnum.java | 30 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/cons/service/impl/ConsDayDataServiceImpl.java | 80 iailab-framework/iailab-common/src/main/java/com/iailab/framework/common/annotation/UserRealName.java | 30 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/quality/service/impl/QualityQualityTrendDayServiceImpl.java | 291 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/dto/IndexStatisticDTO.java | 16 iailab-module-model/iailab-module-model-biz/src/test/java/com/iailab/InfluxDBTest.java | 68 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/controller/package-info.java | 1 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/http/entity/EleLowTagEntity.java | 58 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/api/dto/DeviceValueDTO.java | 25 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/enums/IsEnableEnum.java | 21 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/http/service/impl/HttpTagServiceImpl.java | 304 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dto/DeviceMainDTO.java | 49 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/entity/StModelOutEntity.java | 58 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/http/dao/HttpTagDao.java | 19 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/any/dto/AnySugLibDTO.java | 30 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/enums/DataTypeEnum.java | 22 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/dto/PrdCurrentSaleDTO.java | 40 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/websocket/server/WebSocketServer.java | 76 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/gateway/controller/ApiAppController.java | 118 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dto/DeviceAccountDTO.java | 70 iailab-cloud/iailab-xxl-job/src/main/resources/templates/common/common.macro.ftl | 2 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/param/entity/PageParamEntity.java | 62 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/kio/dao/ChannelKioTagDao.java | 14 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/impl/DeviceAccountServiceImpl.java | 122 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/enums/TagValueTypeConstant.java | 35 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/utils/DcsUtils.java | 52 iailab-framework/iailab-common-biz-data-permission/src/test/java/com/iailab/framework/datapermission/core/db/DataPermissionRuleHandlerTest.java | 540 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/entity/DeviceAccountEntity.java | 82 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/indexdata/service/impl/IndexDataClockServiceImpl.java | 87 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/enums/ModelTypeEnum.java | 21 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/influxdb/common/utils/PointValueUtils.java | 37 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/framework/filter/RewriteRequestFilter.java | 30 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dao/DeviceHealthStateDao.java | 23 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/enums/RequestMethodType.java | 18 iailab-module-model/iailab-module-model-biz/src/main/resources/mapper/report/DeviceHealthReportDao.xml | 12 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/interceptor/DataFilterInterceptor.java | 89 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/influxdb/pojo/InfluxPointValueBoolPOJO.java | 17 iailab-module-model/iailab-module-model-biz/src/main/resources/mapper/device/DeviceRunStateDao.xml | 33 iailab-module-model/iailab-module-model-biz/src/main/resources/mapper/device/DeviceAccountHistoryDao.xml | 19 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/dao/PrdCurrentPerformanceDao.java | 15 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/entity/PrdTimeDayEntity.java | 38 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/impl/DeviceAbnormalHistoryServiceImpl.java | 57 iailab-module-data/iailab-module-data-biz/src/test/java/com/iailab/OadpTagCollectorTest.java | 43 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/WatchControllerOn2Task.java | 49 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dao/DeviceEvaluateIndexDao.java | 14 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/controller/StoreDependableAnalysisController.java | 48 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/dao/DaMathPointDao.java | 14 iailab-framework/iailab-common-mybatis/src/main/java/com/iailab/framework/common/service/CrudService.java | 35 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dto/DeviceHealthReportDTO.java | 46 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/kio/collector/KingIOCollector.java | 129 iailab-module-data/iailab-module-data-biz/src/main/resources/application.yml | 166 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/service/impl/IndexEvaluateSystemServiceImpl.java | 169 iailab-cloud/iailab-xxl-job/src/main/resources/application-local.yaml | 16 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/impl/DeviceIndexServiceImpl.java | 49 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/oss/service/OssFileService.java | 33 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/AnyProc6Task.java | 78 iailab-module-data/iailab-module-data-biz/src/main/resources/导入模板/ModBus.xlsx | 0 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/oss/entity/OssFileEntity.java | 56 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/modbus/controller/package-info.java | 1 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/utils/SSLClient.java | 45 iailab-module-model/iailab-module-model-biz/src/main/resources/application-uat.yml | 42 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/gateway/service/impl/ApiAppServiceImpl.java | 81 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/AnyProc2Task.java | 80 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/entity/PrdPlanYearEntity.java | 36 iailab-module-model/iailab-module-model-biz/src/main/resources/logback-spring.xml | 86 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/WatchControllerOn6Task.java | 50 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/dto/RelationLineDTO.java | 27 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dto/DeviceHealthAlarmDetailDTO.java | 23 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/tag/dto/TagOptionDTO.java | 22 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/DeviceStatUsageService.java | 19 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/command/MLCommand.java | 41 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/utils/MapUtils.java | 18 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/influxdb/pojo/InfluxTagValueFloatPOJO.java | 17 iailab-framework/iailab-common/src/main/java/com/iailab/framework/common/validation/group/DefaultGroup.java | 19 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/dao/StModelDocDao.java | 16 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/any/dto/AnyProcReportDetDTO.java | 32 iailab-module-model/iailab-module-model-biz/src/main/resources/mapper/device/DeviceAccountDao.xml | 19 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/common/StoreTypeEnum.java | 33 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/DeviceHealthEvaluateService.java | 37 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/DeviceStatCountService.java | 21 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dto/DeviceIndexDTO.java | 26 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/gateway/service/impl/ApiServerServiceImpl.java | 115 iailab-framework/iailab-common/src/main/java/com/iailab/framework/common/util/object/ConvertUtils.java | 79 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/kio/dto/KIOWriteFloatDTO.java | 17 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/common/ItemTypeEnum.java | 24 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/any/service/AnyProcParamService.java | 17 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/task/ITask.java | 25 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/sample/constructor/SampleConstructor.java | 42 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/enums/DataSourceType.java | 35 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/task/PointCollectTaskNet60.java | 44 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/gateway/dao/ApiGroupDao.java | 14 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/service/StModelRequestLogService.java | 20 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/param/dao/PageParamDao.java | 9 iailab-module-model/iailab-module-model-biz/src/main/resources/application-local.yml | 164 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/collection/handler/ConstantHandle.java | 56 iailab-module-model/iailab-module-model-api/src/main/java/com/iailab/dto/FeignWarehouseStockDTO.java | 83 iailab-framework/iailab-common-mybatis/src/main/java/com/iailab/framework/common/package-info.java | 1 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/gateway/service/ApiAuthorizedService.java | 32 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/http/dto/TagJsonDto.java | 34 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/controller/admin/ScheduleJobController.java | 117 iailab-module-infra/iailab-module-infra-biz/src/main/java/com/iailab/module/infra/api/config/ConfigApiImpl.java | 71 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/service/IndItemAtomService.java | 36 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/kio/dto/KIOWriteObjDTO.java | 20 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dto/DeviceHealthReportDataDTO.java | 34 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/indexdata/entity/IndexDataClockEntity.java | 85 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/controller/admin/DaPointController.java | 131 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/entity/DeviceStatUsageEntity.java | 51 iailab-framework/iailab-common/src/main/java/com/iailab/framework/common/util/spring/SpringContextUtils.java | 55 iailab-module-data/iailab-module-data-api/src/main/java/com/iailab/module/data/enums/ApiConstants.java | 23 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/utils/SSLClient.java | 45 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/framework/interceptor/CommonData.java | 47 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/dao/IndItemValueDao.java | 23 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/controller/admin/ScheduleJobLogController.java | 62 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/knowledge/dao/KnowledgePathDao.java | 19 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/any/controller/AnyProcCardController.java | 34 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/http/collector/HttpCollectorForSD.java | 187 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/config/MybatisPlusConfig.java | 43 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/enums/DataAshType.java | 30 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dto/DeviceFaultDTO.java | 50 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/controller/DeviceAbnormalHistoryController.java | 151 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dao/DeviceFaultDao.java | 16 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/task/TestTask.java | 22 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/entity/IndexEvaluateSystemEntity.java | 53 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/task/HttpCollectTemperatureTask.java | 47 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/controller/package-info.java | 1 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/service/IndItemValueService.java | 26 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dto/DeviceAccountHistoryDTO.java | 68 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/common/PointDataTypeUtils.java | 25 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dto/DeviceHealthEvaluateDTO.java | 41 iailab-module-model/iailab-module-model-biz/src/main/resources/application-test.yml | 65 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/collection/handler/CalItemHandle.java | 156 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/service/PrdPlanYearService.java | 35 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/sample/dto/ColumnItem.java | 48 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/knowledge/service/KnowledgePathService.java | 31 iailab-module-model/iailab-module-model-biz/src/main/resources/application.yml | 156 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/any/controller/AnyController.java | 195 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/event/service/EventInfoService.java | 19 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/service/StModelService.java | 46 iailab-framework/iailab-common-mybatis/src/main/java/com/iailab/framework/mybatis/interceptor/DataScope.java | 36 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/constant/BusinessConstant.java | 171 iailab-framework/iailab-common-mybatis/src/main/java/com/iailab/framework/common/service/impl/BaseServiceImpl.java | 219 iailab-module-data/iailab-module-data-biz/src/main/resources/mapper/gateway/ApiAuthorizedDao.xml | 60 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/utils/HttpsRequest.java | 426 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/utils/ScriptEngineConfiguration.java | 20 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dto/DeviceStatNewnessDTO.java | 63 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/param/service/PageParmService.java | 15 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/entity/DeviceStatNewnessEntity.java | 65 iailab-framework/iailab-common/src/main/java/com/iailab/framework/common/annotation/AutoUser.java | 20 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/opcua/collector/RSACertHelper.java | 101 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/dto/ScheduleJobDTO.java | 63 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/impl/DeviceHealthStateServiceImpl.java | 61 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/http/dto/TagCommonCurrentDto.java | 16 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/gateway/dao/ApiAppDao.java | 17 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/http/dto/TagPrdTimeDistJsonDto.java | 41 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/service/PrdCurrentSaleService.java | 34 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/opcua/collector/KeyStoreLoader.java | 58 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/knowledge/service/impl/KnowledgeDetServiceImpl.java | 108 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/service/PrdCurrentPerformanceService.java | 30 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/entity/IndItemValueEntity.java | 29 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dao/DeviceStatNewnessDao.java | 20 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/xss/XssHttpServletRequestWrapper.java | 139 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/task/PointCollectTaskNetKIO60.java | 44 iailab-module-data/iailab-module-data-api/src/main/java/com/iailab/module/data/dto/FeignQueryPointDTO.java | 37 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/framework/package-info.java | 6 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/controller/admin/StModelRequestLogController.java | 46 iailab-module-data/iailab-module-data-api/src/main/java/com/iailab/module/data/dto/ApiIndValueDTO.java | 23 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/feign/FeignDataImpl.java | 192 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/entity/IndItemCalEntity.java | 23 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/enums/HttpMethodEnum.java | 21 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/utils/TagUtils.java | 15 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/gateway/controller/ApiInfoController.java | 98 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/gateway/entity/ApiGroupEntity.java | 23 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/service/impl/ScheduleJobLogServiceImpl.java | 54 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/gateway/form/AppLoginForm.java | 14 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/dao/PrdDayProdDao.java | 16 iailab-module-model/iailab-module-model-biz/src/main/resources/mapper/job/ScheduleJobDao.xml | 14 iailab-framework/iailab-common/src/main/java/com/iailab/framework/common/validation/group/UpdateGroup.java | 19 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/ModelAllEvaluationTask.java | 48 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/enums/WatchDogStsEnum.java | 21 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dto/DeviceHealthStateDTO.java | 47 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/service/IndItemCalService.java | 31 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/service/DaPointValueService.java | 20 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/utils/PageUtils.java | 117 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/opcua/controller/admin/ChannelOPCUATagController.java | 102 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dao/DeviceHealthReportDataDao.java | 18 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dto/DeviceInfoDTO.java | 54 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/framework/security/config/SecurityConfiguration.java | 48 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/dto/echarts/SeriesItem.java | 18 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/entity/DeviceFaultHistoryEntity.java | 56 iailab-module-model/iailab-module-model-api/src/main/java/com/iailab/dto/FeignWashTransferInDTO.java | 97 iailab-module-data/iailab-module-data-biz/src/main/resources/application-local.yml | 170 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/SyncDeviceStatUsageTask.java | 35 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/controller/admin/IndItemController.java | 112 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/service/ScheduleJobLogService.java | 31 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/collection/utils/GenInfluxPointValueUtils.java | 72 iailab-framework/iailab-common/src/main/java/com/iailab/framework/common/annotation/AutoBpm.java | 16 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/SyncPrdStorageDayTask.java | 36 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/opcua/dto/ChannelOPCUADeviceDTO.java | 76 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/service/IndItemService.java | 43 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/http/dto/TagAffectDetailsJsonDto.java | 38 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/utils/ExcelUtils.java | 77 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/http/entity/HttpTokenEntity.java | 35 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/SyncPrdPerformanceTask.java | 36 iailab-module-model/iailab-module-model-biz/src/main/resources/mapper/mcs/StModelSettingDao.xml | 14 iailab-module-data/iailab-module-data-api/src/main/java/com/iailab/module/data/api/IFeignDataApi.java | 63 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/http/dao/HttpApiDao.java | 10 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/http/entity/HttpApiEntity.java | 33 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/dto/StModelResultDTO.java | 56 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/http/service/impl/HttpTagCollector.java | 44 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/framework/interceptor/WebMvcConfig.java | 22 iailab-framework/iailab-common-mybatis/src/main/java/com/iailab/framework/common/dao/BaseDao.java | 21 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/gateway/service/impl/ApiAuthorizedServiceImpl.java | 131 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/dao/DaPointValueDao.java | 14 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/IAILModel.java | 147 iailab-framework/iailab-common-biz-data-permission/src/main/java/com/iailab/framework/datapermission/core/db/DataPermissionRuleHandler.java | 57 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/kio/controller/admin/ChannelKioDeviceController.java | 86 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/dto/StModelRunlogDTO.java | 46 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/modbus/dao/ChannelModBusTagDao.java | 21 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/entity/DeviceHealthAlarmDetailEntity.java | 24 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/gateway/entity/ApiAppEntity.java | 38 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/dto/DaMeasurePointDTO.java | 42 864 files changed, 53,285 insertions(+), 338 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..22eea13 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,93 @@ +version: '1.0' +services: + #项目名称,用docker-compose做管理时,每个项目用这里配置的名称进行单独管理 + ## mysql + mysql-db: + # 指定容器的名称 + container_name: mysql + # 指定镜像和版本 + image: mysql:8.0 + ports: + - "3306:3306" + restart: always + environment: + # 配置root密码 + MYSQL_ROOT_PASSWORD: 123456 + volumes: + # 挂载数据目录 + - "/sda2/mysql/data:/var/lib/mysql" + # 挂载配置文件目录 + - "/sda2/mysql/conf:/etc/mysql/conf.d" + ## redis + redis: + image: redis:latest + container_name: redis + restart: always + ports: + - 6379:6379 + volumes: + - ./redis-data:/data:rw + ## nacos + nacos: + # 根据需要修改版本 + image: nacos/nacos-server:2.3.2 + container_name: nacos-standalone + restart: always + environment: + - PREFER_HOST_MODE=hostname + - MODE=standalone + volumes: + - ./nacos/logs/:/home/nacos/logs + - ./nacos/data/:/home/nacos/data + ports: + - "8848:8848" + depends_on: + - mysql + healthcheck: + test: ["CMD","curl","-f","http://localhost:8848/nacos"] + interval: 10s + timeout: 30s + retries: 3 + ## xxl-job + xxl-job: + # 根据需要修改版本 + image: xxl-job:latest + container_name: xxl-job + restart: always + volumes: + - /sda2/iailab/iailab-platform/xxl-job/logs/:/data/applogs + ports: + - "9090:9090" + depends_on: + - mysql +# gateway: +# #镜像名,拉取镜像时也是用这个名字作为地址 +# image: ic-gateway +# container_name: ic-gateway +# #打包路径,即docker build的路径 +# build: ./api/gateway/ +# restart: always +# #环境变量 +# environment: +# CONFIG_SERVER: 172.19.188.43:8848 #配置中心地址 +# #挂载目录 +# volumes: +# - /etc/localtime:/etc/localtime:ro #时间同步 +# - ./api/gateway-lib:/home/beex-gateway/lib +# - ./api/gateway/:/home/beex-gateway +# - ./logs:/logs +# #开放端口 +# ports: +# - "9990:9000" +# - "9777:8777" +# networks: +# - 246-multi-tenant +# depends_on: +# nacos: +# condition: service_healthy +# healthcheck: +# test: ["CMD","curl","-S","http://localhost:9000/doc.html#/beex-api-gateway/authenticate-controller/authenticateUsingGET"] +# interval: 20s +# timeout: 30s +# retries: 3 +# start_period: 20s \ No newline at end of file diff --git a/iailab-cloud/iailab-gateway/src/main/resources/application-local.yaml b/iailab-cloud/iailab-gateway/src/main/resources/application-local.yaml new file mode 100644 index 0000000..c9c6e4a --- /dev/null +++ b/iailab-cloud/iailab-gateway/src/main/resources/application-local.yaml @@ -0,0 +1,13 @@ +--- #################### 注册中心 + 配置中心相关配置 #################### +spring: + cloud: + nacos: + server-addr: 127.0.0.1:8848 # Nacos 服务器地址 + username: nacos + password: nacos + discovery: # 【配置中心】配置项 + namespace: a7112341-c9e2-4177-bc5b-0d2e8cf0b3bb # 命名空间。这里使用 dev 开发环境 + group: DEFAULT_GROUP # 使用的 Nacos 配置分组,默认为 DEFAULT_GROUP + config: # 【注册中心】配置项 + namespace: a7112341-c9e2-4177-bc5b-0d2e8cf0b3bb # 命名空间。这里使用 dev 开发环境 + group: DEFAULT_GROUP # 使用的 Nacos 配置分组,默认为 DEFAULT_GROUP \ No newline at end of file diff --git a/iailab-cloud/iailab-xxl-job/.gitignore b/iailab-cloud/iailab-xxl-job/.gitignore new file mode 100644 index 0000000..52c1b00 --- /dev/null +++ b/iailab-cloud/iailab-xxl-job/.gitignore @@ -0,0 +1,7 @@ +.idea +.classpath +.project +*.iml +target/ +.DS_Store +.gitattributes diff --git a/iailab-cloud/iailab-xxl-job/src/main/resources/application-local.yaml b/iailab-cloud/iailab-xxl-job/src/main/resources/application-local.yaml new file mode 100644 index 0000000..dd84d4d --- /dev/null +++ b/iailab-cloud/iailab-xxl-job/src/main/resources/application-local.yaml @@ -0,0 +1,16 @@ +--- #################### 注册中心 + 配置中心相关配置 #################### +spring: + cloud: + nacos: + server-addr: @nacos.server@ # Nacos 服务器地址 + username: @nacos.username@ + password: @nacos.password@ + discovery: # 【配置中心】配置项 + namespace: @nacos.namespace@ # 命名空间。这里使用 dev 开发环境 + group: DEFAULT_GROUP # 使用的 Nacos 配置分组,默认为 DEFAULT_GROUP + metadata: + version: @nacos.metadata.version@ # 服务实例的版本号,可用于灰度发布 + management.context-path: ${server.servlet.context-path}/actuator + config: # 【注册中心】配置项 + namespace: @nacos.namespace@ # 命名空间。这里使用 dev 开发环境 + group: DEFAULT_GROUP # 使用的 Nacos 配置分组,默认为 DEFAULT_GROUP diff --git a/iailab-cloud/iailab-xxl-job/src/main/resources/i18n/message_zh_CN.properties b/iailab-cloud/iailab-xxl-job/src/main/resources/i18n/message_zh_CN.properties index ccc4112..8b5c291 100644 --- a/iailab-cloud/iailab-xxl-job/src/main/resources/i18n/message_zh_CN.properties +++ b/iailab-cloud/iailab-xxl-job/src/main/resources/i18n/message_zh_CN.properties @@ -1,276 +1,276 @@ -admin_name=任务调度中心 -admin_name_full=分布式任务调度平台XXL-JOB +admin_name=\u4EFB\u52A1\u8C03\u5EA6\u4E2D\u5FC3 +admin_name_full=\u5206\u5E03\u5F0F\u4EFB\u52A1\u8C03\u5EA6\u5E73\u53F0XXL-JOB admin_version=2.4.2-SNAPSHOT admin_i18n= ## system -system_tips=系统提示 -system_ok=确定 -system_close=关闭 -system_save=保存 -system_cancel=取消 -system_search=搜索 -system_status=状态 -system_opt=操作 -system_please_input=请输入 -system_please_choose=请选择 -system_success=成功 -system_fail=失败 -system_add_suc=新增成功 -system_add_fail=新增失败 -system_update_suc=更新成功 -system_update_fail=更新失败 -system_all=全部 -system_api_error=接口异常 -system_show=查看 -system_empty=无 -system_opt_suc=操作成功 -system_opt_fail=操作失败 -system_opt_edit=编辑 -system_opt_del=删除 -system_opt_copy=复制 -system_unvalid=非法 -system_not_found=不存在 -system_nav=导航 -system_digits=整数 -system_lengh_limit=长度限制 -system_permission_limit=权限拦截 -system_welcome=欢迎 +system_tips=\u7CFB\u7EDF\u63D0\u793A +system_ok=\u786E\u5B9A +system_close=\u5173\u95ED +system_save=\u4FDD\u5B58 +system_cancel=\u53D6\u6D88 +system_search=\u641C\u7D22 +system_status=\u72B6\u6001 +system_opt=\u64CD\u4F5C +system_please_input=\u8BF7\u8F93\u5165 +system_please_choose=\u8BF7\u9009\u62E9 +system_success=\u6210\u529F +system_fail=\u5931\u8D25 +system_add_suc=\u65B0\u589E\u6210\u529F +system_add_fail=\u65B0\u589E\u5931\u8D25 +system_update_suc=\u66F4\u65B0\u6210\u529F +system_update_fail=\u66F4\u65B0\u5931\u8D25 +system_all=\u5168\u90E8 +system_api_error=\u63A5\u53E3\u5F02\u5E38 +system_show=\u67E5\u770B +system_empty=\u65E0 +system_opt_suc=\u64CD\u4F5C\u6210\u529F +system_opt_fail=\u64CD\u4F5C\u5931\u8D25 +system_opt_edit=\u7F16\u8F91 +system_opt_del=\u5220\u9664 +system_opt_copy=\u590D\u5236 +system_unvalid=\u975E\u6CD5 +system_not_found=\u4E0D\u5B58\u5728 +system_nav=\u5BFC\u822A +system_digits=\u6574\u6570 +system_lengh_limit=\u957F\u5EA6\u9650\u5236 +system_permission_limit=\u6743\u9650\u62E6\u622A +system_welcome=\u6B22\u8FCE ## daterangepicker -daterangepicker_ranges_recent_hour=最近一小时 -daterangepicker_ranges_today=今日 -daterangepicker_ranges_yesterday=昨日 -daterangepicker_ranges_this_month=本月 -daterangepicker_ranges_last_month=上个月 -daterangepicker_ranges_recent_week=最近一周 -daterangepicker_ranges_recent_month=最近一月 -daterangepicker_custom_name=自定义 -daterangepicker_custom_starttime=起始时间 -daterangepicker_custom_endtime=结束时间 -daterangepicker_custom_daysofweek=日,一,二,三,四,五,六 -daterangepicker_custom_monthnames=一月,二月,三月,四月,五月,六月,七月,八月,九月,十月,十一月,十二月 +daterangepicker_ranges_recent_hour=\u6700\u8FD1\u4E00\u5C0F\u65F6 +daterangepicker_ranges_today=\u4ECA\u65E5 +daterangepicker_ranges_yesterday=\u6628\u65E5 +daterangepicker_ranges_this_month=\u672C\u6708 +daterangepicker_ranges_last_month=\u4E0A\u4E2A\u6708 +daterangepicker_ranges_recent_week=\u6700\u8FD1\u4E00\u5468 +daterangepicker_ranges_recent_month=\u6700\u8FD1\u4E00\u6708 +daterangepicker_custom_name=\u81EA\u5B9A\u4E49 +daterangepicker_custom_starttime=\u8D77\u59CB\u65F6\u95F4 +daterangepicker_custom_endtime=\u7ED3\u675F\u65F6\u95F4 +daterangepicker_custom_daysofweek=\u65E5,\u4E00,\u4E8C,\u4E09,\u56DB,\u4E94,\u516D +daterangepicker_custom_monthnames=\u4E00\u6708,\u4E8C\u6708,\u4E09\u6708,\u56DB\u6708,\u4E94\u6708,\u516D\u6708,\u4E03\u6708,\u516B\u6708,\u4E5D\u6708,\u5341\u6708,\u5341\u4E00\u6708,\u5341\u4E8C\u6708 ## dataTable -dataTable_sProcessing=处理中... -dataTable_sLengthMenu=每页 _MENU_ 条记录 -dataTable_sZeroRecords=没有匹配结果 -dataTable_sInfo=第 _PAGE_ 页 ( 总共 _PAGES_ 页,_TOTAL_ 条记录 ) -dataTable_sInfoEmpty=无记录 -dataTable_sInfoFiltered=(由 _MAX_ 项结果过滤) -dataTable_sSearch=搜索 -dataTable_sEmptyTable=表中数据为空 -dataTable_sLoadingRecords=载入中... -dataTable_sFirst=首页 -dataTable_sPrevious=上页 -dataTable_sNext=下页 -dataTable_sLast=末页 -dataTable_sSortAscending=: 以升序排列此列 -dataTable_sSortDescending=: 以降序排列此列 +dataTable_sProcessing=\u5904\u7406\u4E2D... +dataTable_sLengthMenu=\u6BCF\u9875 _MENU_ \u6761\u8BB0\u5F55 +dataTable_sZeroRecords=\u6CA1\u6709\u5339\u914D\u7ED3\u679C +dataTable_sInfo=\u7B2C _PAGE_ \u9875 ( \u603B\u5171 _PAGES_ \u9875\uFF0C_TOTAL_ \u6761\u8BB0\u5F55 ) +dataTable_sInfoEmpty=\u65E0\u8BB0\u5F55 +dataTable_sInfoFiltered=(\u7531 _MAX_ \u9879\u7ED3\u679C\u8FC7\u6EE4) +dataTable_sSearch=\u641C\u7D22 +dataTable_sEmptyTable=\u8868\u4E2D\u6570\u636E\u4E3A\u7A7A +dataTable_sLoadingRecords=\u8F7D\u5165\u4E2D... +dataTable_sFirst=\u9996\u9875 +dataTable_sPrevious=\u4E0A\u9875 +dataTable_sNext=\u4E0B\u9875 +dataTable_sLast=\u672B\u9875 +dataTable_sSortAscending=: \u4EE5\u5347\u5E8F\u6392\u5217\u6B64\u5217 +dataTable_sSortDescending=: \u4EE5\u964D\u5E8F\u6392\u5217\u6B64\u5217 ## login -login_btn=登录 -login_remember_me=记住密码 -login_username_placeholder=请输入登录账号 -login_password_placeholder=请输入登录密码 -login_username_empty=请输入登录账号 -login_username_lt_4=登录账号不应低于4位 -login_password_empty=请输入登录密码 -login_password_lt_4=登录密码不应低于4位 -login_success=登录成功 -login_fail=登录失败 -login_param_empty=账号或密码为空 -login_param_unvalid=账号或密码错误 +login_btn=\u767B\u5F55 +login_remember_me=\u8BB0\u4F4F\u5BC6\u7801 +login_username_placeholder=\u8BF7\u8F93\u5165\u767B\u5F55\u8D26\u53F7 +login_password_placeholder=\u8BF7\u8F93\u5165\u767B\u5F55\u5BC6\u7801 +login_username_empty=\u8BF7\u8F93\u5165\u767B\u5F55\u8D26\u53F7 +login_username_lt_4=\u767B\u5F55\u8D26\u53F7\u4E0D\u5E94\u4F4E\u4E8E4\u4F4D +login_password_empty=\u8BF7\u8F93\u5165\u767B\u5F55\u5BC6\u7801 +login_password_lt_4=\u767B\u5F55\u5BC6\u7801\u4E0D\u5E94\u4F4E\u4E8E4\u4F4D +login_success=\u767B\u5F55\u6210\u529F +login_fail=\u767B\u5F55\u5931\u8D25 +login_param_empty=\u8D26\u53F7\u6216\u5BC6\u7801\u4E3A\u7A7A +login_param_unvalid=\u8D26\u53F7\u6216\u5BC6\u7801\u9519\u8BEF ## logout -logout_btn=注销 -logout_confirm=确认注销登录? -logout_success=注销成功 -logout_fail=注销失败 +logout_btn=\u6CE8\u9500 +logout_confirm=\u786E\u8BA4\u6CE8\u9500\u767B\u5F55? +logout_success=\u6CE8\u9500\u6210\u529F +logout_fail=\u6CE8\u9500\u5931\u8D25 ## change pwd -change_pwd=修改密码 -change_pwd_suc_to_logout=修改密码成功,即将注销登陆 -change_pwd_field_newpwd=新密码 +change_pwd=\u4FEE\u6539\u5BC6\u7801 +change_pwd_suc_to_logout=\u4FEE\u6539\u5BC6\u7801\u6210\u529F\uFF0C\u5373\u5C06\u6CE8\u9500\u767B\u9646 +change_pwd_field_newpwd=\u65B0\u5BC6\u7801 ## dashboard -job_dashboard_name=运行报表 -job_dashboard_job_num=任务数量 -job_dashboard_job_num_tip=调度中心运行的任务数量 -job_dashboard_trigger_num=调度次数 -job_dashboard_trigger_num_tip=调度中心触发的调度次数 -job_dashboard_jobgroup_num=执行器数量 -job_dashboard_jobgroup_num_tip=调度中心在线的执行器机器数量 -job_dashboard_report=调度报表 -job_dashboard_report_loaddata_fail=调度报表数据加载异常 -job_dashboard_date_report=日期分布图 -job_dashboard_rate_report=成功比例图 +job_dashboard_name=\u8FD0\u884C\u62A5\u8868 +job_dashboard_job_num=\u4EFB\u52A1\u6570\u91CF +job_dashboard_job_num_tip=\u8C03\u5EA6\u4E2D\u5FC3\u8FD0\u884C\u7684\u4EFB\u52A1\u6570\u91CF +job_dashboard_trigger_num=\u8C03\u5EA6\u6B21\u6570 +job_dashboard_trigger_num_tip=\u8C03\u5EA6\u4E2D\u5FC3\u89E6\u53D1\u7684\u8C03\u5EA6\u6B21\u6570 +job_dashboard_jobgroup_num=\u6267\u884C\u5668\u6570\u91CF +job_dashboard_jobgroup_num_tip=\u8C03\u5EA6\u4E2D\u5FC3\u5728\u7EBF\u7684\u6267\u884C\u5668\u673A\u5668\u6570\u91CF +job_dashboard_report=\u8C03\u5EA6\u62A5\u8868 +job_dashboard_report_loaddata_fail=\u8C03\u5EA6\u62A5\u8868\u6570\u636E\u52A0\u8F7D\u5F02\u5E38 +job_dashboard_date_report=\u65E5\u671F\u5206\u5E03\u56FE +job_dashboard_rate_report=\u6210\u529F\u6BD4\u4F8B\u56FE ## job info -jobinfo_name=任务管理 -jobinfo_job=任务 -jobinfo_field_add=新增 -jobinfo_field_update=更新任务 -jobinfo_field_id=任务ID -jobinfo_field_jobgroup=执行器 -jobinfo_field_jobdesc=任务描述 -jobinfo_field_gluetype=运行模式 -jobinfo_field_executorparam=任务参数 -jobinfo_field_author=负责人 -jobinfo_field_timeout=任务超时时间 -jobinfo_field_alarmemail=报警邮件 -jobinfo_field_alarmemail_placeholder=请输入报警邮件,多个邮件地址则逗号分隔 -jobinfo_field_executorRouteStrategy=路由策略 -jobinfo_field_childJobId=子任务ID -jobinfo_field_childJobId_placeholder=请输入子任务的任务ID,如存在多个则逗号分隔 -jobinfo_field_executorBlockStrategy=阻塞处理策略 -jobinfo_field_executorFailRetryCount=失败重试次数 -jobinfo_field_executorFailRetryCount_placeholder=失败重试次数,大于零时生效 -jobinfo_script_location=脚本位置 -jobinfo_shard_index=分片序号 -jobinfo_shard_total=分片总数 -jobinfo_opt_stop=停止 -jobinfo_opt_start=启动 -jobinfo_opt_log=查询日志 -jobinfo_opt_run=执行一次 -jobinfo_opt_run_tips=请输入本次执行的机器地址,为空则从执行器获取 -jobinfo_opt_registryinfo=注册节点 -jobinfo_opt_next_time=下次执行时间 -jobinfo_glue_remark=源码备注 -jobinfo_glue_remark_limit=源码备注长度限制为4~100 -jobinfo_glue_rollback=版本回溯 -jobinfo_glue_jobid_unvalid=任务ID非法 -jobinfo_glue_gluetype_unvalid=该任务非GLUE模式 -jobinfo_field_executorTimeout_placeholder=任务超时时间,单位秒,大于零时生效 -schedule_type=调度类型 -schedule_type_none=无 +jobinfo_name=\u4EFB\u52A1\u7BA1\u7406 +jobinfo_job=\u4EFB\u52A1 +jobinfo_field_add=\u65B0\u589E +jobinfo_field_update=\u66F4\u65B0\u4EFB\u52A1 +jobinfo_field_id=\u4EFB\u52A1ID +jobinfo_field_jobgroup=\u6267\u884C\u5668 +jobinfo_field_jobdesc=\u4EFB\u52A1\u63CF\u8FF0 +jobinfo_field_gluetype=\u8FD0\u884C\u6A21\u5F0F +jobinfo_field_executorparam=\u4EFB\u52A1\u53C2\u6570 +jobinfo_field_author=\u8D1F\u8D23\u4EBA +jobinfo_field_timeout=\u4EFB\u52A1\u8D85\u65F6\u65F6\u95F4 +jobinfo_field_alarmemail=\u62A5\u8B66\u90AE\u4EF6 +jobinfo_field_alarmemail_placeholder=\u8BF7\u8F93\u5165\u62A5\u8B66\u90AE\u4EF6\uFF0C\u591A\u4E2A\u90AE\u4EF6\u5730\u5740\u5219\u9017\u53F7\u5206\u9694 +jobinfo_field_executorRouteStrategy=\u8DEF\u7531\u7B56\u7565 +jobinfo_field_childJobId=\u5B50\u4EFB\u52A1ID +jobinfo_field_childJobId_placeholder=\u8BF7\u8F93\u5165\u5B50\u4EFB\u52A1\u7684\u4EFB\u52A1ID,\u5982\u5B58\u5728\u591A\u4E2A\u5219\u9017\u53F7\u5206\u9694 +jobinfo_field_executorBlockStrategy=\u963B\u585E\u5904\u7406\u7B56\u7565 +jobinfo_field_executorFailRetryCount=\u5931\u8D25\u91CD\u8BD5\u6B21\u6570 +jobinfo_field_executorFailRetryCount_placeholder=\u5931\u8D25\u91CD\u8BD5\u6B21\u6570\uFF0C\u5927\u4E8E\u96F6\u65F6\u751F\u6548 +jobinfo_script_location=\u811A\u672C\u4F4D\u7F6E +jobinfo_shard_index=\u5206\u7247\u5E8F\u53F7 +jobinfo_shard_total=\u5206\u7247\u603B\u6570 +jobinfo_opt_stop=\u505C\u6B62 +jobinfo_opt_start=\u542F\u52A8 +jobinfo_opt_log=\u67E5\u8BE2\u65E5\u5FD7 +jobinfo_opt_run=\u6267\u884C\u4E00\u6B21 +jobinfo_opt_run_tips=\u8BF7\u8F93\u5165\u672C\u6B21\u6267\u884C\u7684\u673A\u5668\u5730\u5740\uFF0C\u4E3A\u7A7A\u5219\u4ECE\u6267\u884C\u5668\u83B7\u53D6 +jobinfo_opt_registryinfo=\u6CE8\u518C\u8282\u70B9 +jobinfo_opt_next_time=\u4E0B\u6B21\u6267\u884C\u65F6\u95F4 +jobinfo_glue_remark=\u6E90\u7801\u5907\u6CE8 +jobinfo_glue_remark_limit=\u6E90\u7801\u5907\u6CE8\u957F\u5EA6\u9650\u5236\u4E3A4~100 +jobinfo_glue_rollback=\u7248\u672C\u56DE\u6EAF +jobinfo_glue_jobid_unvalid=\u4EFB\u52A1ID\u975E\u6CD5 +jobinfo_glue_gluetype_unvalid=\u8BE5\u4EFB\u52A1\u975EGLUE\u6A21\u5F0F +jobinfo_field_executorTimeout_placeholder=\u4EFB\u52A1\u8D85\u65F6\u65F6\u95F4\uFF0C\u5355\u4F4D\u79D2\uFF0C\u5927\u4E8E\u96F6\u65F6\u751F\u6548 +schedule_type=\u8C03\u5EA6\u7C7B\u578B +schedule_type_none=\u65E0 schedule_type_cron=CRON -schedule_type_fix_rate=固定速度 -schedule_type_fix_delay=固定延迟 -schedule_type_none_limit_start=当前调度类型禁止启动 -misfire_strategy=调度过期策略 -misfire_strategy_do_nothing=忽略 -misfire_strategy_fire_once_now=立即执行一次 -jobinfo_conf_base=基础配置 -jobinfo_conf_schedule=调度配置 -jobinfo_conf_job=任务配置 -jobinfo_conf_advanced=高级配置 +schedule_type_fix_rate=\u56FA\u5B9A\u901F\u5EA6 +schedule_type_fix_delay=\u56FA\u5B9A\u5EF6\u8FDF +schedule_type_none_limit_start=\u5F53\u524D\u8C03\u5EA6\u7C7B\u578B\u7981\u6B62\u542F\u52A8 +misfire_strategy=\u8C03\u5EA6\u8FC7\u671F\u7B56\u7565 +misfire_strategy_do_nothing=\u5FFD\u7565 +misfire_strategy_fire_once_now=\u7ACB\u5373\u6267\u884C\u4E00\u6B21 +jobinfo_conf_base=\u57FA\u7840\u914D\u7F6E +jobinfo_conf_schedule=\u8C03\u5EA6\u914D\u7F6E +jobinfo_conf_job=\u4EFB\u52A1\u914D\u7F6E +jobinfo_conf_advanced=\u9AD8\u7EA7\u914D\u7F6E ## job log -joblog_name=调度日志 -joblog_status=状态 -joblog_status_all=全部 -joblog_status_suc=成功 -joblog_status_fail=失败 -joblog_status_running=进行中 -joblog_field_triggerTime=调度时间 -joblog_field_triggerCode=调度结果 -joblog_field_triggerMsg=调度备注 -joblog_field_handleTime=执行时间 -joblog_field_handleCode=执行结果 -joblog_field_handleMsg=执行备注 -joblog_field_executorAddress=执行器地址 -joblog_clean=清理 -joblog_clean_log=日志清理 -joblog_clean_type=清理方式 -joblog_clean_type_1=清理一个月之前日志数据 -joblog_clean_type_2=清理三个月之前日志数据 -joblog_clean_type_3=清理六个月之前日志数据 -joblog_clean_type_4=清理一年之前日志数据 -joblog_clean_type_5=清理一千条以前日志数据 -joblog_clean_type_6=清理一万条以前日志数据 -joblog_clean_type_7=清理三万条以前日志数据 -joblog_clean_type_8=清理十万条以前日志数据 -joblog_clean_type_9=清理所有日志数据 -joblog_clean_type_unvalid=清理类型参数异常 -joblog_handleCode_200=成功 -joblog_handleCode_500=失败 -joblog_handleCode_502=失败(超时) -joblog_kill_log=终止任务 -joblog_kill_log_limit=调度失败,无法终止日志 -joblog_kill_log_byman=人为操作,主动终止 -joblog_lost_fail=任务结果丢失,标记失败 -joblog_rolling_log=执行日志 -joblog_rolling_log_refresh=刷新 -joblog_rolling_log_triggerfail=任务发起调度失败,无法查看执行日志 -joblog_rolling_log_failoften=终止请求Rolling日志,请求失败次数超上限,可刷新页面重新加载日志 -joblog_logid_unvalid=日志ID非法 +joblog_name=\u8C03\u5EA6\u65E5\u5FD7 +joblog_status=\u72B6\u6001 +joblog_status_all=\u5168\u90E8 +joblog_status_suc=\u6210\u529F +joblog_status_fail=\u5931\u8D25 +joblog_status_running=\u8FDB\u884C\u4E2D +joblog_field_triggerTime=\u8C03\u5EA6\u65F6\u95F4 +joblog_field_triggerCode=\u8C03\u5EA6\u7ED3\u679C +joblog_field_triggerMsg=\u8C03\u5EA6\u5907\u6CE8 +joblog_field_handleTime=\u6267\u884C\u65F6\u95F4 +joblog_field_handleCode=\u6267\u884C\u7ED3\u679C +joblog_field_handleMsg=\u6267\u884C\u5907\u6CE8 +joblog_field_executorAddress=\u6267\u884C\u5668\u5730\u5740 +joblog_clean=\u6E05\u7406 +joblog_clean_log=\u65E5\u5FD7\u6E05\u7406 +joblog_clean_type=\u6E05\u7406\u65B9\u5F0F +joblog_clean_type_1=\u6E05\u7406\u4E00\u4E2A\u6708\u4E4B\u524D\u65E5\u5FD7\u6570\u636E +joblog_clean_type_2=\u6E05\u7406\u4E09\u4E2A\u6708\u4E4B\u524D\u65E5\u5FD7\u6570\u636E +joblog_clean_type_3=\u6E05\u7406\u516D\u4E2A\u6708\u4E4B\u524D\u65E5\u5FD7\u6570\u636E +joblog_clean_type_4=\u6E05\u7406\u4E00\u5E74\u4E4B\u524D\u65E5\u5FD7\u6570\u636E +joblog_clean_type_5=\u6E05\u7406\u4E00\u5343\u6761\u4EE5\u524D\u65E5\u5FD7\u6570\u636E +joblog_clean_type_6=\u6E05\u7406\u4E00\u4E07\u6761\u4EE5\u524D\u65E5\u5FD7\u6570\u636E +joblog_clean_type_7=\u6E05\u7406\u4E09\u4E07\u6761\u4EE5\u524D\u65E5\u5FD7\u6570\u636E +joblog_clean_type_8=\u6E05\u7406\u5341\u4E07\u6761\u4EE5\u524D\u65E5\u5FD7\u6570\u636E +joblog_clean_type_9=\u6E05\u7406\u6240\u6709\u65E5\u5FD7\u6570\u636E +joblog_clean_type_unvalid=\u6E05\u7406\u7C7B\u578B\u53C2\u6570\u5F02\u5E38 +joblog_handleCode_200=\u6210\u529F +joblog_handleCode_500=\u5931\u8D25 +joblog_handleCode_502=\u5931\u8D25(\u8D85\u65F6) +joblog_kill_log=\u7EC8\u6B62\u4EFB\u52A1 +joblog_kill_log_limit=\u8C03\u5EA6\u5931\u8D25\uFF0C\u65E0\u6CD5\u7EC8\u6B62\u65E5\u5FD7 +joblog_kill_log_byman=\u4EBA\u4E3A\u64CD\u4F5C\uFF0C\u4E3B\u52A8\u7EC8\u6B62 +joblog_lost_fail=\u4EFB\u52A1\u7ED3\u679C\u4E22\u5931\uFF0C\u6807\u8BB0\u5931\u8D25 +joblog_rolling_log=\u6267\u884C\u65E5\u5FD7 +joblog_rolling_log_refresh=\u5237\u65B0 +joblog_rolling_log_triggerfail=\u4EFB\u52A1\u53D1\u8D77\u8C03\u5EA6\u5931\u8D25\uFF0C\u65E0\u6CD5\u67E5\u770B\u6267\u884C\u65E5\u5FD7 +joblog_rolling_log_failoften=\u7EC8\u6B62\u8BF7\u6C42Rolling\u65E5\u5FD7,\u8BF7\u6C42\u5931\u8D25\u6B21\u6570\u8D85\u4E0A\u9650,\u53EF\u5237\u65B0\u9875\u9762\u91CD\u65B0\u52A0\u8F7D\u65E5\u5FD7 +joblog_logid_unvalid=\u65E5\u5FD7ID\u975E\u6CD5 ## job group -jobgroup_name=执行器管理 -jobgroup_list=执行器列表 -jobgroup_add=新增执行器 -jobgroup_edit=编辑执行器 -jobgroup_del=删除执行器 -jobgroup_field_title=名称 -jobgroup_field_addressType=注册方式 -jobgroup_field_addressType_0=自动注册 -jobgroup_field_addressType_1=手动录入 -jobgroup_field_addressType_limit=手动录入注册方式,机器地址不可为空 -jobgroup_field_registryList=机器地址 -jobgroup_field_registryList_unvalid=机器地址格式非法 -jobgroup_field_registryList_placeholder=请输入执行器地址列表,多地址逗号分隔 -jobgroup_field_appname_limit=限制以小写字母开头,由小写字母、数字和中划线组成 -jobgroup_field_appname_length=AppName长度限制为4~64 -jobgroup_field_title_length=名称长度限制为4~12 -jobgroup_field_order_digits=请输入整数 -jobgroup_field_orderrange=取值范围为1~1000 -jobgroup_del_limit_0=拒绝删除,该执行器使用中 -jobgroup_del_limit_1=拒绝删除, 系统至少保留一个执行器 -jobgroup_empty=不存在有效执行器,请联系管理员 +jobgroup_name=\u6267\u884C\u5668\u7BA1\u7406 +jobgroup_list=\u6267\u884C\u5668\u5217\u8868 +jobgroup_add=\u65B0\u589E\u6267\u884C\u5668 +jobgroup_edit=\u7F16\u8F91\u6267\u884C\u5668 +jobgroup_del=\u5220\u9664\u6267\u884C\u5668 +jobgroup_field_title=\u540D\u79F0 +jobgroup_field_addressType=\u6CE8\u518C\u65B9\u5F0F +jobgroup_field_addressType_0=\u81EA\u52A8\u6CE8\u518C +jobgroup_field_addressType_1=\u624B\u52A8\u5F55\u5165 +jobgroup_field_addressType_limit=\u624B\u52A8\u5F55\u5165\u6CE8\u518C\u65B9\u5F0F\uFF0C\u673A\u5668\u5730\u5740\u4E0D\u53EF\u4E3A\u7A7A +jobgroup_field_registryList=\u673A\u5668\u5730\u5740 +jobgroup_field_registryList_unvalid=\u673A\u5668\u5730\u5740\u683C\u5F0F\u975E\u6CD5 +jobgroup_field_registryList_placeholder=\u8BF7\u8F93\u5165\u6267\u884C\u5668\u5730\u5740\u5217\u8868\uFF0C\u591A\u5730\u5740\u9017\u53F7\u5206\u9694 +jobgroup_field_appname_limit=\u9650\u5236\u4EE5\u5C0F\u5199\u5B57\u6BCD\u5F00\u5934\uFF0C\u7531\u5C0F\u5199\u5B57\u6BCD\u3001\u6570\u5B57\u548C\u4E2D\u5212\u7EBF\u7EC4\u6210 +jobgroup_field_appname_length=AppName\u957F\u5EA6\u9650\u5236\u4E3A4~64 +jobgroup_field_title_length=\u540D\u79F0\u957F\u5EA6\u9650\u5236\u4E3A4~12 +jobgroup_field_order_digits=\u8BF7\u8F93\u5165\u6574\u6570 +jobgroup_field_orderrange=\u53D6\u503C\u8303\u56F4\u4E3A1~1000 +jobgroup_del_limit_0=\u62D2\u7EDD\u5220\u9664\uFF0C\u8BE5\u6267\u884C\u5668\u4F7F\u7528\u4E2D +jobgroup_del_limit_1=\u62D2\u7EDD\u5220\u9664, \u7CFB\u7EDF\u81F3\u5C11\u4FDD\u7559\u4E00\u4E2A\u6267\u884C\u5668 +jobgroup_empty=\u4E0D\u5B58\u5728\u6709\u6548\u6267\u884C\u5668,\u8BF7\u8054\u7CFB\u7BA1\u7406\u5458 ## job conf -jobconf_block_SERIAL_EXECUTION=单机串行 -jobconf_block_DISCARD_LATER=丢弃后续调度 -jobconf_block_COVER_EARLY=覆盖之前调度 -jobconf_route_first=第一个 -jobconf_route_last=最后一个 -jobconf_route_round=轮询 -jobconf_route_random=随机 -jobconf_route_consistenthash=一致性HASH -jobconf_route_lfu=最不经常使用 -jobconf_route_lru=最近最久未使用 -jobconf_route_failover=故障转移 -jobconf_route_busyover=忙碌转移 -jobconf_route_shard=分片广播 -jobconf_idleBeat=空闲检测 -jobconf_beat=心跳检测 -jobconf_monitor=任务调度中心监控报警 -jobconf_monitor_detail=监控告警明细 -jobconf_monitor_alarm_title=告警类型 -jobconf_monitor_alarm_type=调度失败 -jobconf_monitor_alarm_content=告警内容 -jobconf_trigger_admin_adress=调度机器 -jobconf_trigger_exe_regtype=执行器-注册方式 -jobconf_trigger_exe_regaddress=执行器-地址列表 -jobconf_trigger_address_empty=调度失败:执行器地址为空 -jobconf_trigger_run=触发调度 -jobconf_trigger_child_run=触发子任务 -jobconf_callback_child_msg1={0}/{1} [任务ID={2}], 触发{3}, 触发备注: {4} <br> -jobconf_callback_child_msg2={0}/{1} [任务ID={2}], 触发失败, 触发备注: 任务ID格式错误 <br> -jobconf_trigger_type=任务触发类型 -jobconf_trigger_type_cron=Cron触发 -jobconf_trigger_type_manual=手动触发 -jobconf_trigger_type_parent=父任务触发 -jobconf_trigger_type_api=API触发 -jobconf_trigger_type_retry=失败重试触发 -jobconf_trigger_type_misfire=调度过期补偿 +jobconf_block_SERIAL_EXECUTION=\u5355\u673A\u4E32\u884C +jobconf_block_DISCARD_LATER=\u4E22\u5F03\u540E\u7EED\u8C03\u5EA6 +jobconf_block_COVER_EARLY=\u8986\u76D6\u4E4B\u524D\u8C03\u5EA6 +jobconf_route_first=\u7B2C\u4E00\u4E2A +jobconf_route_last=\u6700\u540E\u4E00\u4E2A +jobconf_route_round=\u8F6E\u8BE2 +jobconf_route_random=\u968F\u673A +jobconf_route_consistenthash=\u4E00\u81F4\u6027HASH +jobconf_route_lfu=\u6700\u4E0D\u7ECF\u5E38\u4F7F\u7528 +jobconf_route_lru=\u6700\u8FD1\u6700\u4E45\u672A\u4F7F\u7528 +jobconf_route_failover=\u6545\u969C\u8F6C\u79FB +jobconf_route_busyover=\u5FD9\u788C\u8F6C\u79FB +jobconf_route_shard=\u5206\u7247\u5E7F\u64AD +jobconf_idleBeat=\u7A7A\u95F2\u68C0\u6D4B +jobconf_beat=\u5FC3\u8DF3\u68C0\u6D4B +jobconf_monitor=\u4EFB\u52A1\u8C03\u5EA6\u4E2D\u5FC3\u76D1\u63A7\u62A5\u8B66 +jobconf_monitor_detail=\u76D1\u63A7\u544A\u8B66\u660E\u7EC6 +jobconf_monitor_alarm_title=\u544A\u8B66\u7C7B\u578B +jobconf_monitor_alarm_type=\u8C03\u5EA6\u5931\u8D25 +jobconf_monitor_alarm_content=\u544A\u8B66\u5185\u5BB9 +jobconf_trigger_admin_adress=\u8C03\u5EA6\u673A\u5668 +jobconf_trigger_exe_regtype=\u6267\u884C\u5668-\u6CE8\u518C\u65B9\u5F0F +jobconf_trigger_exe_regaddress=\u6267\u884C\u5668-\u5730\u5740\u5217\u8868 +jobconf_trigger_address_empty=\u8C03\u5EA6\u5931\u8D25\uFF1A\u6267\u884C\u5668\u5730\u5740\u4E3A\u7A7A +jobconf_trigger_run=\u89E6\u53D1\u8C03\u5EA6 +jobconf_trigger_child_run=\u89E6\u53D1\u5B50\u4EFB\u52A1 +jobconf_callback_child_msg1={0}/{1} [\u4EFB\u52A1ID={2}], \u89E6\u53D1{3}, \u89E6\u53D1\u5907\u6CE8: {4} <br> +jobconf_callback_child_msg2={0}/{1} [\u4EFB\u52A1ID={2}], \u89E6\u53D1\u5931\u8D25, \u89E6\u53D1\u5907\u6CE8: \u4EFB\u52A1ID\u683C\u5F0F\u9519\u8BEF <br> +jobconf_trigger_type=\u4EFB\u52A1\u89E6\u53D1\u7C7B\u578B +jobconf_trigger_type_cron=Cron\u89E6\u53D1 +jobconf_trigger_type_manual=\u624B\u52A8\u89E6\u53D1 +jobconf_trigger_type_parent=\u7236\u4EFB\u52A1\u89E6\u53D1 +jobconf_trigger_type_api=API\u89E6\u53D1 +jobconf_trigger_type_retry=\u5931\u8D25\u91CD\u8BD5\u89E6\u53D1 +jobconf_trigger_type_misfire=\u8C03\u5EA6\u8FC7\u671F\u8865\u507F ## user -user_manage=用户管理 -user_username=账号 -user_password=密码 -user_role=角色 -user_role_admin=管理员 -user_role_normal=普通用户 -user_permission=权限 -user_add=新增用户 -user_update=更新用户 -user_username_repeat=账号重复 -user_username_valid=限制以小写字母开头,由小写字母、数字组成 -user_password_update_placeholder=请输入新密码,为空则不更新密码 -user_update_loginuser_limit=禁止操作当前登录账号 +user_manage=\u7528\u6237\u7BA1\u7406 +user_username=\u8D26\u53F7 +user_password=\u5BC6\u7801 +user_role=\u89D2\u8272 +user_role_admin=\u7BA1\u7406\u5458 +user_role_normal=\u666E\u901A\u7528\u6237 +user_permission=\u6743\u9650 +user_add=\u65B0\u589E\u7528\u6237 +user_update=\u66F4\u65B0\u7528\u6237 +user_username_repeat=\u8D26\u53F7\u91CD\u590D +user_username_valid=\u9650\u5236\u4EE5\u5C0F\u5199\u5B57\u6BCD\u5F00\u5934\uFF0C\u7531\u5C0F\u5199\u5B57\u6BCD\u3001\u6570\u5B57\u7EC4\u6210 +user_password_update_placeholder=\u8BF7\u8F93\u5165\u65B0\u5BC6\u7801\uFF0C\u4E3A\u7A7A\u5219\u4E0D\u66F4\u65B0\u5BC6\u7801 +user_update_loginuser_limit=\u7981\u6B62\u64CD\u4F5C\u5F53\u524D\u767B\u5F55\u8D26\u53F7 ## help -job_help=使用教程 -job_help_document=官方文档 \ No newline at end of file +job_help=\u4F7F\u7528\u6559\u7A0B +job_help_document=\u5B98\u65B9\u6587\u6863 \ No newline at end of file diff --git a/iailab-cloud/iailab-xxl-job/src/main/resources/templates/common/common.macro.ftl b/iailab-cloud/iailab-xxl-job/src/main/resources/templates/common/common.macro.ftl index 21e9d3e..d3938fa 100644 --- a/iailab-cloud/iailab-xxl-job/src/main/resources/templates/common/common.macro.ftl +++ b/iailab-cloud/iailab-xxl-job/src/main/resources/templates/common/common.macro.ftl @@ -141,7 +141,7 @@ <li class="nav-click <#if pageName == "jobgroup">active</#if>" ><a href="${request.contextPath}/jobgroup"><i class="fa fa-circle-o text-red"></i><span>${I18n.jobgroup_name}</span></a></li> <li class="nav-click <#if pageName == "user">active</#if>" ><a href="${request.contextPath}/user"><i class="fa fa-circle-o text-purple"></i><span>${I18n.user_manage}</span></a></li> </#if> - <li class="nav-click <#if pageName == "help">active</#if>" ><a href="${request.contextPath}/help"><i class="fa fa-circle-o text-gray"></i><span>${I18n.job_help}</span></a></li> +<#-- <li class="nav-click <#if pageName == "help">active</#if>" ><a href="${request.contextPath}/help"><i class="fa fa-circle-o text-gray"></i><span>${I18n.job_help}</span></a></li>--> </ul> </section> <!-- /.sidebar --> diff --git a/iailab-cloud/iailab-xxl-job/src/main/resources/templates/help.ftl b/iailab-cloud/iailab-xxl-job/src/main/resources/templates/help.ftl index d7d69ca..613edcc 100644 --- a/iailab-cloud/iailab-xxl-job/src/main/resources/templates/help.ftl +++ b/iailab-cloud/iailab-xxl-job/src/main/resources/templates/help.ftl @@ -1,94 +1,94 @@ -<#--<!DOCTYPE html>--> -<#--<html>--> -<#--<head>--> -<#-- <#import "./common/common.macro.ftl" as netCommon>--> -<#-- <@netCommon.commonStyle />--> -<#-- <title>${I18n.admin_name}</title>--> -<#--</head>--> -<#--<body class="hold-transition skin-blue sidebar-mini <#if cookieMap?exists && cookieMap["xxljob_adminlte_settings"]?exists && "off" == cookieMap["xxljob_adminlte_settings"].value >sidebar-collapse</#if> ">--> -<#--<div class="wrapper">--> -<#-- <!-- header –>--> -<#-- <@netCommon.commonHeader />--> -<#-- <!-- left –>--> -<#-- <@netCommon.commonLeft "help" />--> -<#-- --> -<#-- <!-- Content Wrapper. Contains page content –>--> -<#-- <div class="content-wrapper">--> -<#-- <!-- Content Header (Page header) –>--> -<#-- <section class="content-header">--> -<#-- <h1>${I18n.job_help}</h1>--> -<#-- </section>--> +<!DOCTYPE html> +<html> +<head> + <#import "./common/common.macro.ftl" as netCommon> + <@netCommon.commonStyle /> + <title>${I18n.admin_name}</title> +</head> +<body class="hold-transition skin-blue sidebar-mini <#if cookieMap?exists && cookieMap["xxljob_adminlte_settings"]?exists && "off" == cookieMap["xxljob_adminlte_settings"].value >sidebar-collapse</#if> "> +<div class="wrapper"> + <!-- header --> + <@netCommon.commonHeader /> + <!-- left --> + <@netCommon.commonLeft "help" /> -<#-- <!-- Main content –>--> -<#-- <section class="content">--> -<#-- <div class="callout callout-info">--> -<#-- <h4>${I18n.admin_name_full}</h4>--> -<#-- <br>--> -<#-- <p>--> -<#-- <a target="_blank" href="https://github.com/xuxueli/xxl-job">Github</a> --> -<#-- <iframe src="https://ghbtns.com/github-btn.html?user=xuxueli&repo=xxl-job&type=star&count=true" frameborder="0" scrolling="0" width="170px" height="20px" style="margin-bottom:-5px;"></iframe> --> -<#-- <br><br>--> -<#-- <a target="_blank" href="https://www.xuxueli.com/xxl-job/">${I18n.job_help_document}</a>--> -<#-- <br><br>--> + <!-- Content Wrapper. Contains page content --> + <div class="content-wrapper"> + <!-- Content Header (Page header) --> + <section class="content-header"> + <h1>${I18n.job_help}</h1> + </section> -<#-- </p>--> -<#-- <p></p>--> -<#-- </div>--> -<#-- </section>--> -<#-- <!-- /.content –>--> -<#-- </div>--> -<#-- <!-- /.content-wrapper –>--> -<#-- --> -<#-- <!-- footer –>--> -<#-- <@netCommon.commonFooter />--> -<#--</div>--> -<#--<@netCommon.commonScript />--> -<#--</body>--> -<#--</html>--> -<#--<!DOCTYPE html>--> -<#--<html>--> -<#--<head>--> -<#-- <#import "./common/common.macro.ftl" as netCommon>--> -<#-- <@netCommon.commonStyle />--> -<#-- <title>${I18n.admin_name}</title>--> -<#--</head>--> -<#--<body class="hold-transition skin-blue sidebar-mini <#if cookieMap?exists && cookieMap["xxljob_adminlte_settings"]?exists && "off" == cookieMap["xxljob_adminlte_settings"].value >sidebar-collapse</#if> ">--> -<#--<div class="wrapper">--> -<#-- <!-- header –>--> -<#-- <@netCommon.commonHeader />--> -<#-- <!-- left –>--> -<#-- <@netCommon.commonLeft "help" />--> -<#-- --> -<#-- <!-- Content Wrapper. Contains page content –>--> -<#-- <div class="content-wrapper">--> -<#-- <!-- Content Header (Page header) –>--> -<#-- <section class="content-header">--> -<#-- <h1>${I18n.job_help}</h1>--> -<#-- </section>--> + <!-- Main content --> + <section class="content"> + <div class="callout callout-info"> + <h4>${I18n.admin_name_full}</h4> + <br> + <p> + <a target="_blank" href="https://github.com/xuxueli/xxl-job">Github</a> + <iframe src="https://ghbtns.com/github-btn.html?user=xuxueli&repo=xxl-job&type=star&count=true" frameborder="0" scrolling="0" width="170px" height="20px" style="margin-bottom:-5px;"></iframe> + <br><br> + <a target="_blank" href="https://www.xuxueli.com/xxl-job/">${I18n.job_help_document}</a> + <br><br> -<#-- <!-- Main content –>--> -<#-- <section class="content">--> -<#-- <div class="callout callout-info">--> -<#-- <h4>${I18n.admin_name_full}</h4>--> -<#-- <br>--> -<#-- <p>--> -<#-- <a target="_blank" href="https://github.com/xuxueli/xxl-job">Github</a> --> -<#-- <iframe src="https://ghbtns.com/github-btn.html?user=xuxueli&repo=xxl-job&type=star&count=true" frameborder="0" scrolling="0" width="170px" height="20px" style="margin-bottom:-5px;"></iframe> --> -<#-- <br><br>--> -<#-- <a target="_blank" href="https://www.xuxueli.com/xxl-job/">${I18n.job_help_document}</a>--> -<#-- <br><br>--> + </p> + <p></p> + </div> + </section> + <!-- /.content --> + </div> + <!-- /.content-wrapper --> -<#-- </p>--> -<#-- <p></p>--> -<#-- </div>--> -<#-- </section>--> -<#-- <!-- /.content –>--> -<#-- </div>--> -<#-- <!-- /.content-wrapper –>--> -<#-- --> -<#-- <!-- footer –>--> -<#-- <@netCommon.commonFooter />--> -<#--</div>--> -<#--<@netCommon.commonScript />--> -<#--</body>--> -<#--</html>--> + <!-- footer --> + <@netCommon.commonFooter /> +</div> +<@netCommon.commonScript /> +</body> +</html> +<!DOCTYPE html> +<html> +<head> + <#import "./common/common.macro.ftl" as netCommon> + <@netCommon.commonStyle /> + <title>${I18n.admin_name}</title> +</head> +<body class="hold-transition skin-blue sidebar-mini <#if cookieMap?exists && cookieMap["xxljob_adminlte_settings"]?exists && "off" == cookieMap["xxljob_adminlte_settings"].value >sidebar-collapse</#if> "> +<div class="wrapper"> + <!-- header --> + <@netCommon.commonHeader /> + <!-- left --> + <@netCommon.commonLeft "help" /> + + <!-- Content Wrapper. Contains page content --> + <div class="content-wrapper"> + <!-- Content Header (Page header) --> + <section class="content-header"> + <h1>${I18n.job_help}</h1> + </section> + + <!-- Main content --> + <section class="content"> + <div class="callout callout-info"> + <h4>${I18n.admin_name_full}</h4> + <br> + <p> + <a target="_blank" href="https://github.com/xuxueli/xxl-job">Github</a> + <iframe src="https://ghbtns.com/github-btn.html?user=xuxueli&repo=xxl-job&type=star&count=true" frameborder="0" scrolling="0" width="170px" height="20px" style="margin-bottom:-5px;"></iframe> + <br><br> + <a target="_blank" href="https://www.xuxueli.com/xxl-job/">${I18n.job_help_document}</a> + <br><br> + + </p> + <p></p> + </div> + </section> + <!-- /.content --> + </div> + <!-- /.content-wrapper --> + + <!-- footer --> + <@netCommon.commonFooter /> +</div> +<@netCommon.commonScript /> +</body> +</html> diff --git a/iailab-framework/iailab-common-biz-data-permission/src/main/java/com/iailab/framework/datapermission/core/db/DataPermissionRuleHandler.java b/iailab-framework/iailab-common-biz-data-permission/src/main/java/com/iailab/framework/datapermission/core/db/DataPermissionRuleHandler.java new file mode 100644 index 0000000..503c821 --- /dev/null +++ b/iailab-framework/iailab-common-biz-data-permission/src/main/java/com/iailab/framework/datapermission/core/db/DataPermissionRuleHandler.java @@ -0,0 +1,57 @@ +package com.iailab.framework.datapermission.core.db; + +import cn.hutool.core.collection.CollUtil; +import com.baomidou.mybatisplus.extension.plugins.handler.MultiDataPermissionHandler; +import com.iailab.framework.datapermission.core.rule.DataPermissionRule; +import com.iailab.framework.datapermission.core.rule.DataPermissionRuleFactory; +import com.iailab.framework.mybatis.core.util.MyBatisUtils; +import lombok.RequiredArgsConstructor; +import net.sf.jsqlparser.expression.Expression; +import net.sf.jsqlparser.expression.operators.conditional.AndExpression; +import net.sf.jsqlparser.schema.Table; + +import java.util.List; + +/** + * 基于 {@link DataPermissionRule} 的数据权限处理器 + * + * 它的底层,是基于 MyBatis Plus 的 <a href="https://baomidou.com/plugins/data-permission/">数据权限插件</a> + * 核心原理:它会在 SQL 执行前拦截 SQL 语句,并根据用户权限动态添加权限相关的 SQL 片段。这样,只有用户有权限访问的数据才会被查询出来 + * + * @author 芋道源码 + */ +@RequiredArgsConstructor +public class DataPermissionRuleHandler implements MultiDataPermissionHandler { + + private final DataPermissionRuleFactory ruleFactory; + + @Override + public Expression getSqlSegment(Table table, Expression where, String mappedStatementId) { + // 获得 Mapper 对应的数据权限的规则 + List<DataPermissionRule> rules = ruleFactory.getDataPermissionRule(mappedStatementId); + if (CollUtil.isEmpty(rules)) { + return null; + } + + // 生成条件 + Expression allExpression = null; + for (DataPermissionRule rule : rules) { + // 判断表名是否匹配 + String tableName = MyBatisUtils.getTableName(table); + if (!rule.getTableNames().contains(tableName)) { + continue; + } + + // 单条规则的条件 + Expression oneExpress = rule.getExpression(tableName, table.getAlias()); + if (oneExpress == null) { + continue; + } + // 拼接到 allExpression 中 + allExpression = allExpression == null ? oneExpress + : new AndExpression(allExpression, oneExpress); + } + return allExpression; + } + +} diff --git a/iailab-framework/iailab-common-biz-data-permission/src/test/java/com/iailab/framework/datapermission/core/db/DataPermissionRuleHandlerTest.java b/iailab-framework/iailab-common-biz-data-permission/src/test/java/com/iailab/framework/datapermission/core/db/DataPermissionRuleHandlerTest.java new file mode 100644 index 0000000..9a37e09 --- /dev/null +++ b/iailab-framework/iailab-common-biz-data-permission/src/test/java/com/iailab/framework/datapermission/core/db/DataPermissionRuleHandlerTest.java @@ -0,0 +1,540 @@ +package com.iailab.framework.datapermission.core.db; + +import com.baomidou.mybatisplus.extension.plugins.inner.DataPermissionInterceptor; +import com.iailab.framework.datapermission.core.rule.DataPermissionRule; +import com.iailab.framework.datapermission.core.rule.DataPermissionRuleFactory; +import com.iailab.framework.mybatis.core.util.MyBatisUtils; +import com.iailab.framework.test.core.ut.BaseMockitoUnitTest; +import net.sf.jsqlparser.expression.Alias; +import net.sf.jsqlparser.expression.Expression; +import net.sf.jsqlparser.expression.LongValue; +import net.sf.jsqlparser.expression.Parenthesis; +import net.sf.jsqlparser.expression.operators.relational.EqualsTo; +import net.sf.jsqlparser.expression.operators.relational.ExpressionList; +import net.sf.jsqlparser.expression.operators.relational.InExpression; +import net.sf.jsqlparser.schema.Column; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.mockito.InjectMocks; +import org.mockito.Mock; + +import java.util.Arrays; +import java.util.Set; + +import static com.iailab.framework.common.util.collection.SetUtils.asSet; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.when; + +/** + * {@link DataPermissionRuleHandler} 的单元测试 + * 主要复用了 MyBatis Plus 的 TenantLineInnerInterceptorTest 的单元测试 + * 不过它的单元测试不是很规范,考虑到是复用的,所以暂时不进行修改~ + * + * @author 芋道源码 + */ +public class DataPermissionRuleHandlerTest extends BaseMockitoUnitTest { + + @InjectMocks + private DataPermissionRuleHandler handler; + + @Mock + private DataPermissionRuleFactory ruleFactory; + + private DataPermissionInterceptor interceptor; + + @BeforeEach + public void setUp() { + interceptor = new DataPermissionInterceptor(handler); + + // 租户的数据权限规则 + DataPermissionRule tenantRule = new DataPermissionRule() { + + private static final String COLUMN = "tenant_id"; + + @Override + public Set<String> getTableNames() { + return asSet("entity", "entity1", "entity2", "entity3", "t1", "t2", "sys_dict_item", // 支持 MyBatis Plus 的单元测试 + "t_user", "t_role"); // 满足自己的单元测试 + } + + @Override + public Expression getExpression(String tableName, Alias tableAlias) { + Column column = MyBatisUtils.buildColumn(tableName, tableAlias, COLUMN); + LongValue value = new LongValue(1L); + return new EqualsTo(column, value); + } + + }; + // 部门的数据权限规则 + DataPermissionRule deptRule = new DataPermissionRule() { + + private static final String COLUMN = "dept_id"; + + @Override + public Set<String> getTableNames() { + return asSet("t_user"); // 满足自己的单元测试 + } + + @Override + public Expression getExpression(String tableName, Alias tableAlias) { + Column column = MyBatisUtils.buildColumn(tableName, tableAlias, COLUMN); + ExpressionList<LongValue> values = new ExpressionList<>(new LongValue(10L), + new LongValue(20L)); + return new InExpression(column, new Parenthesis((values))); + } + + }; + // 设置到上下文 + when(ruleFactory.getDataPermissionRule(any())).thenReturn(Arrays.asList(tenantRule, deptRule)); + } + + @Test + void delete() { + assertSql("delete from entity where id = ?", + "DELETE FROM entity WHERE id = ? AND entity.tenant_id = 1"); + } + + @Test + void update() { + assertSql("update entity set name = ? where id = ?", + "UPDATE entity SET name = ? WHERE id = ? AND entity.tenant_id = 1"); + } + + @Test + void selectSingle() { + // 单表 + assertSql("select * from entity where id = ?", + "SELECT * FROM entity WHERE id = ? AND entity.tenant_id = 1"); + + assertSql("select * from entity where id = ? or name = ?", + "SELECT * FROM entity WHERE (id = ? OR name = ?) AND entity.tenant_id = 1"); + + assertSql("SELECT * FROM entity WHERE (id = ? OR name = ?)", + "SELECT * FROM entity WHERE (id = ? OR name = ?) AND entity.tenant_id = 1"); + + /* not */ + assertSql("SELECT * FROM entity WHERE not (id = ? OR name = ?)", + "SELECT * FROM entity WHERE NOT (id = ? OR name = ?) AND entity.tenant_id = 1"); + } + + @Test + void selectSubSelectIn() { + /* in */ + assertSql("SELECT * FROM entity e WHERE e.id IN (select e1.id from entity1 e1 where e1.id = ?)", + "SELECT * FROM entity e WHERE e.id IN (SELECT e1.id FROM entity1 e1 WHERE e1.id = ? AND e1.tenant_id = 1) AND e.tenant_id = 1"); + // 在最前 + assertSql("SELECT * FROM entity e WHERE e.id IN " + + "(select e1.id from entity1 e1 where e1.id = ?) and e.id = ?", + "SELECT * FROM entity e WHERE e.id IN " + + "(SELECT e1.id FROM entity1 e1 WHERE e1.id = ? AND e1.tenant_id = 1) AND e.id = ? AND e.tenant_id = 1"); + // 在最后 + assertSql("SELECT * FROM entity e WHERE e.id = ? and e.id IN " + + "(select e1.id from entity1 e1 where e1.id = ?)", + "SELECT * FROM entity e WHERE e.id = ? AND e.id IN " + + "(SELECT e1.id FROM entity1 e1 WHERE e1.id = ? AND e1.tenant_id = 1) AND e.tenant_id = 1"); + // 在中间 + assertSql("SELECT * FROM entity e WHERE e.id = ? and e.id IN " + + "(select e1.id from entity1 e1 where e1.id = ?) and e.id = ?", + "SELECT * FROM entity e WHERE e.id = ? AND e.id IN " + + "(SELECT e1.id FROM entity1 e1 WHERE e1.id = ? AND e1.tenant_id = 1) AND e.id = ? AND e.tenant_id = 1"); + } + + @Test + void selectSubSelectEq() { + /* = */ + assertSql("SELECT * FROM entity e WHERE e.id = (select e1.id from entity1 e1 where e1.id = ?)", + "SELECT * FROM entity e WHERE e.id = (SELECT e1.id FROM entity1 e1 WHERE e1.id = ? AND e1.tenant_id = 1) AND e.tenant_id = 1"); + } + + @Test + void selectSubSelectInnerNotEq() { + /* inner not = */ + assertSql("SELECT * FROM entity e WHERE not (e.id = (select e1.id from entity1 e1 where e1.id = ?))", + "SELECT * FROM entity e WHERE NOT (e.id = (SELECT e1.id FROM entity1 e1 WHERE e1.id = ? AND e1.tenant_id = 1)) AND e.tenant_id = 1"); + + assertSql("SELECT * FROM entity e WHERE not (e.id = (select e1.id from entity1 e1 where e1.id = ?) and e.id = ?)", + "SELECT * FROM entity e WHERE NOT (e.id = (SELECT e1.id FROM entity1 e1 WHERE e1.id = ? AND e1.tenant_id = 1) AND e.id = ?) AND e.tenant_id = 1"); + } + + @Test + void selectSubSelectExists() { + /* EXISTS */ + assertSql("SELECT * FROM entity e WHERE EXISTS (select e1.id from entity1 e1 where e1.id = ?)", + "SELECT * FROM entity e WHERE EXISTS (SELECT e1.id FROM entity1 e1 WHERE e1.id = ? AND e1.tenant_id = 1) AND e.tenant_id = 1"); + + + /* NOT EXISTS */ + assertSql("SELECT * FROM entity e WHERE NOT EXISTS (select e1.id from entity1 e1 where e1.id = ?)", + "SELECT * FROM entity e WHERE NOT EXISTS (SELECT e1.id FROM entity1 e1 WHERE e1.id = ? AND e1.tenant_id = 1) AND e.tenant_id = 1"); + } + + @Test + void selectSubSelect() { + /* >= */ + assertSql("SELECT * FROM entity e WHERE e.id >= (select e1.id from entity1 e1 where e1.id = ?)", + "SELECT * FROM entity e WHERE e.id >= (SELECT e1.id FROM entity1 e1 WHERE e1.id = ? AND e1.tenant_id = 1) AND e.tenant_id = 1"); + + + /* <= */ + assertSql("SELECT * FROM entity e WHERE e.id <= (select e1.id from entity1 e1 where e1.id = ?)", + "SELECT * FROM entity e WHERE e.id <= (SELECT e1.id FROM entity1 e1 WHERE e1.id = ? AND e1.tenant_id = 1) AND e.tenant_id = 1"); + + + /* <> */ + assertSql("SELECT * FROM entity e WHERE e.id <> (select e1.id from entity1 e1 where e1.id = ?)", + "SELECT * FROM entity e WHERE e.id <> (SELECT e1.id FROM entity1 e1 WHERE e1.id = ? AND e1.tenant_id = 1) AND e.tenant_id = 1"); + } + + @Test + void selectFromSelect() { + assertSql("SELECT * FROM (select e.id from entity e WHERE e.id = (select e1.id from entity1 e1 where e1.id = ?))", + "SELECT * FROM (SELECT e.id FROM entity e WHERE e.id = (SELECT e1.id FROM entity1 e1 WHERE e1.id = ? AND e1.tenant_id = 1) AND e.tenant_id = 1)"); + } + + @Test + void selectBodySubSelect() { + assertSql("select t1.col1,(select t2.col2 from t2 t2 where t1.col1=t2.col1) from t1 t1", + "SELECT t1.col1, (SELECT t2.col2 FROM t2 t2 WHERE t1.col1 = t2.col1 AND t2.tenant_id = 1) FROM t1 t1 WHERE t1.tenant_id = 1"); + } + + @Test + void selectLeftJoin() { + // left join + assertSql("SELECT * FROM entity e " + + "left join entity1 e1 on e1.id = e.id " + + "WHERE e.id = ? OR e.name = ?", + "SELECT * FROM entity e " + + "LEFT JOIN entity1 e1 ON e1.id = e.id AND e1.tenant_id = 1 " + + "WHERE (e.id = ? OR e.name = ?) AND e.tenant_id = 1"); + + assertSql("SELECT * FROM entity e " + + "left join entity1 e1 on e1.id = e.id " + + "WHERE (e.id = ? OR e.name = ?)", + "SELECT * FROM entity e " + + "LEFT JOIN entity1 e1 ON e1.id = e.id AND e1.tenant_id = 1 " + + "WHERE (e.id = ? OR e.name = ?) AND e.tenant_id = 1"); + + assertSql("SELECT * FROM entity e " + + "left join entity1 e1 on e1.id = e.id " + + "left join entity2 e2 on e1.id = e2.id", + "SELECT * FROM entity e " + + "LEFT JOIN entity1 e1 ON e1.id = e.id AND e1.tenant_id = 1 " + + "LEFT JOIN entity2 e2 ON e1.id = e2.id AND e2.tenant_id = 1 " + + "WHERE e.tenant_id = 1"); + } + + @Test + void selectRightJoin() { + // right join + assertSql("SELECT * FROM entity e " + + "right join entity1 e1 on e1.id = e.id", + "SELECT * FROM entity e " + + "RIGHT JOIN entity1 e1 ON e1.id = e.id AND e.tenant_id = 1 " + + "WHERE e1.tenant_id = 1"); + + assertSql("SELECT * FROM with_as_1 e " + + "right join entity1 e1 on e1.id = e.id", + "SELECT * FROM with_as_1 e " + + "RIGHT JOIN entity1 e1 ON e1.id = e.id " + + "WHERE e1.tenant_id = 1"); + + assertSql("SELECT * FROM entity e " + + "right join entity1 e1 on e1.id = e.id " + + "WHERE e.id = ? OR e.name = ?", + "SELECT * FROM entity e " + + "RIGHT JOIN entity1 e1 ON e1.id = e.id AND e.tenant_id = 1 " + + "WHERE (e.id = ? OR e.name = ?) AND e1.tenant_id = 1"); + + assertSql("SELECT * FROM entity e " + + "right join entity1 e1 on e1.id = e.id " + + "right join entity2 e2 on e1.id = e2.id ", + "SELECT * FROM entity e " + + "RIGHT JOIN entity1 e1 ON e1.id = e.id AND e.tenant_id = 1 " + + "RIGHT JOIN entity2 e2 ON e1.id = e2.id AND e1.tenant_id = 1 " + + "WHERE e2.tenant_id = 1"); + } + + @Test + void selectMixJoin() { + assertSql("SELECT * FROM entity e " + + "right join entity1 e1 on e1.id = e.id " + + "left join entity2 e2 on e1.id = e2.id", + "SELECT * FROM entity e " + + "RIGHT JOIN entity1 e1 ON e1.id = e.id AND e.tenant_id = 1 " + + "LEFT JOIN entity2 e2 ON e1.id = e2.id AND e2.tenant_id = 1 " + + "WHERE e1.tenant_id = 1"); + + assertSql("SELECT * FROM entity e " + + "left join entity1 e1 on e1.id = e.id " + + "right join entity2 e2 on e1.id = e2.id", + "SELECT * FROM entity e " + + "LEFT JOIN entity1 e1 ON e1.id = e.id AND e1.tenant_id = 1 " + + "RIGHT JOIN entity2 e2 ON e1.id = e2.id AND e.tenant_id = 1 " + + "WHERE e2.tenant_id = 1"); + + assertSql("SELECT * FROM entity e " + + "left join entity1 e1 on e1.id = e.id " + + "inner join entity2 e2 on e1.id = e2.id", + "SELECT * FROM entity e " + + "LEFT JOIN entity1 e1 ON e1.id = e.id AND e1.tenant_id = 1 " + + "INNER JOIN entity2 e2 ON e1.id = e2.id AND e.tenant_id = 1 AND e2.tenant_id = 1"); + } + + + @Test + void selectJoinSubSelect() { + assertSql("select * from (select * from entity) e1 " + + "left join entity2 e2 on e1.id = e2.id", + "SELECT * FROM (SELECT * FROM entity WHERE entity.tenant_id = 1) e1 " + + "LEFT JOIN entity2 e2 ON e1.id = e2.id AND e2.tenant_id = 1"); + + assertSql("select * from entity1 e1 " + + "left join (select * from entity2) e2 " + + "on e1.id = e2.id", + "SELECT * FROM entity1 e1 " + + "LEFT JOIN (SELECT * FROM entity2 WHERE entity2.tenant_id = 1) e2 " + + "ON e1.id = e2.id " + + "WHERE e1.tenant_id = 1"); + } + + @Test + void selectSubJoin() { + + assertSql("select * FROM " + + "(entity1 e1 right JOIN entity2 e2 ON e1.id = e2.id)", + "SELECT * FROM " + + "(entity1 e1 RIGHT JOIN entity2 e2 ON e1.id = e2.id AND e1.tenant_id = 1) " + + "WHERE e2.tenant_id = 1"); + + assertSql("select * FROM " + + "(entity1 e1 LEFT JOIN entity2 e2 ON e1.id = e2.id)", + "SELECT * FROM " + + "(entity1 e1 LEFT JOIN entity2 e2 ON e1.id = e2.id AND e2.tenant_id = 1) " + + "WHERE e1.tenant_id = 1"); + + + assertSql("select * FROM " + + "(entity1 e1 LEFT JOIN entity2 e2 ON e1.id = e2.id) " + + "right join entity3 e3 on e1.id = e3.id", + "SELECT * FROM " + + "(entity1 e1 LEFT JOIN entity2 e2 ON e1.id = e2.id AND e2.tenant_id = 1) " + + "RIGHT JOIN entity3 e3 ON e1.id = e3.id AND e1.tenant_id = 1 " + + "WHERE e3.tenant_id = 1"); + + + assertSql("select * FROM entity e " + + "LEFT JOIN (entity1 e1 right join entity2 e2 ON e1.id = e2.id) " + + "on e.id = e2.id", + "SELECT * FROM entity e " + + "LEFT JOIN (entity1 e1 RIGHT JOIN entity2 e2 ON e1.id = e2.id AND e1.tenant_id = 1) " + + "ON e.id = e2.id AND e2.tenant_id = 1 " + + "WHERE e.tenant_id = 1"); + + assertSql("select * FROM entity e " + + "LEFT JOIN (entity1 e1 left join entity2 e2 ON e1.id = e2.id) " + + "on e.id = e2.id", + "SELECT * FROM entity e " + + "LEFT JOIN (entity1 e1 LEFT JOIN entity2 e2 ON e1.id = e2.id AND e2.tenant_id = 1) " + + "ON e.id = e2.id AND e1.tenant_id = 1 " + + "WHERE e.tenant_id = 1"); + + assertSql("select * FROM entity e " + + "RIGHT JOIN (entity1 e1 left join entity2 e2 ON e1.id = e2.id) " + + "on e.id = e2.id", + "SELECT * FROM entity e " + + "RIGHT JOIN (entity1 e1 LEFT JOIN entity2 e2 ON e1.id = e2.id AND e2.tenant_id = 1) " + + "ON e.id = e2.id AND e.tenant_id = 1 " + + "WHERE e1.tenant_id = 1"); + } + + + @Test + void selectLeftJoinMultipleTrailingOn() { + // 多个 on 尾缀的 + assertSql("SELECT * FROM entity e " + + "LEFT JOIN entity1 e1 " + + "LEFT JOIN entity2 e2 ON e2.id = e1.id " + + "ON e1.id = e.id " + + "WHERE (e.id = ? OR e.NAME = ?)", + "SELECT * FROM entity e " + + "LEFT JOIN entity1 e1 " + + "LEFT JOIN entity2 e2 ON e2.id = e1.id AND e2.tenant_id = 1 " + + "ON e1.id = e.id AND e1.tenant_id = 1 " + + "WHERE (e.id = ? OR e.NAME = ?) AND e.tenant_id = 1"); + + assertSql("SELECT * FROM entity e " + + "LEFT JOIN entity1 e1 " + + "LEFT JOIN with_as_A e2 ON e2.id = e1.id " + + "ON e1.id = e.id " + + "WHERE (e.id = ? OR e.NAME = ?)", + "SELECT * FROM entity e " + + "LEFT JOIN entity1 e1 " + + "LEFT JOIN with_as_A e2 ON e2.id = e1.id " + + "ON e1.id = e.id AND e1.tenant_id = 1 " + + "WHERE (e.id = ? OR e.NAME = ?) AND e.tenant_id = 1"); + } + + @Test + void selectInnerJoin() { + // inner join + assertSql("SELECT * FROM entity e " + + "inner join entity1 e1 on e1.id = e.id " + + "WHERE e.id = ? OR e.name = ?", + "SELECT * FROM entity e " + + "INNER JOIN entity1 e1 ON e1.id = e.id AND e.tenant_id = 1 AND e1.tenant_id = 1 " + + "WHERE e.id = ? OR e.name = ?"); + + assertSql("SELECT * FROM entity e " + + "inner join entity1 e1 on e1.id = e.id " + + "WHERE (e.id = ? OR e.name = ?)", + "SELECT * FROM entity e " + + "INNER JOIN entity1 e1 ON e1.id = e.id AND e.tenant_id = 1 AND e1.tenant_id = 1 " + + "WHERE (e.id = ? OR e.name = ?)"); + + // 隐式内连接 + assertSql("SELECT * FROM entity,entity1 " + + "WHERE entity.id = entity1.id", + "SELECT * FROM entity, entity1 " + + "WHERE entity.id = entity1.id AND entity.tenant_id = 1 AND entity1.tenant_id = 1"); + + // 隐式内连接 + assertSql("SELECT * FROM entity a, with_as_entity1 b " + + "WHERE a.id = b.id", + "SELECT * FROM entity a, with_as_entity1 b " + + "WHERE a.id = b.id AND a.tenant_id = 1"); + + assertSql("SELECT * FROM with_as_entity a, with_as_entity1 b " + + "WHERE a.id = b.id", + "SELECT * FROM with_as_entity a, with_as_entity1 b " + + "WHERE a.id = b.id"); + + // SubJoin with 隐式内连接 + assertSql("SELECT * FROM (entity,entity1) " + + "WHERE entity.id = entity1.id", + "SELECT * FROM (entity, entity1) " + + "WHERE entity.id = entity1.id " + + "AND entity.tenant_id = 1 AND entity1.tenant_id = 1"); + + assertSql("SELECT * FROM ((entity,entity1),entity2) " + + "WHERE entity.id = entity1.id and entity.id = entity2.id", + "SELECT * FROM ((entity, entity1), entity2) " + + "WHERE entity.id = entity1.id AND entity.id = entity2.id " + + "AND entity.tenant_id = 1 AND entity1.tenant_id = 1 AND entity2.tenant_id = 1"); + + assertSql("SELECT * FROM (entity,(entity1,entity2)) " + + "WHERE entity.id = entity1.id and entity.id = entity2.id", + "SELECT * FROM (entity, (entity1, entity2)) " + + "WHERE entity.id = entity1.id AND entity.id = entity2.id " + + "AND entity.tenant_id = 1 AND entity1.tenant_id = 1 AND entity2.tenant_id = 1"); + + // 沙雕的括号写法 + assertSql("SELECT * FROM (((entity,entity1))) " + + "WHERE entity.id = entity1.id", + "SELECT * FROM (((entity, entity1))) " + + "WHERE entity.id = entity1.id " + + "AND entity.tenant_id = 1 AND entity1.tenant_id = 1"); + + } + + + @Test + void selectWithAs() { + assertSql("with with_as_A as (select * from entity) select * from with_as_A", + "WITH with_as_A AS (SELECT * FROM entity WHERE entity.tenant_id = 1) SELECT * FROM with_as_A"); + } + + + @Test + void selectIgnoreTable() { + assertSql(" SELECT dict.dict_code, item.item_text AS \"text\", item.item_value AS \"value\" FROM sys_dict_item item INNER JOIN sys_dict dict ON dict.id = item.dict_id WHERE dict.dict_code IN (1, 2, 3) AND item.item_value IN (1, 2, 3)", + "SELECT dict.dict_code, item.item_text AS \"text\", item.item_value AS \"value\" FROM sys_dict_item item INNER JOIN sys_dict dict ON dict.id = item.dict_id AND item.tenant_id = 1 WHERE dict.dict_code IN (1, 2, 3) AND item.item_value IN (1, 2, 3)"); + } + + private void assertSql(String sql, String targetSql) { + assertEquals(targetSql, interceptor.parserSingle(sql, null)); + } + + // ========== 额外的测试 ========== + + @Test + public void testSelectSingle() { + // 单表 + assertSql("select * from t_user where id = ?", + "SELECT * FROM t_user WHERE id = ? AND t_user.tenant_id = 1 AND t_user.dept_id IN (10, 20)"); + + assertSql("select * from t_user where id = ? or name = ?", + "SELECT * FROM t_user WHERE (id = ? OR name = ?) AND t_user.tenant_id = 1 AND t_user.dept_id IN (10, 20)"); + + assertSql("SELECT * FROM t_user WHERE (id = ? OR name = ?)", + "SELECT * FROM t_user WHERE (id = ? OR name = ?) AND t_user.tenant_id = 1 AND t_user.dept_id IN (10, 20)"); + + /* not */ + assertSql("SELECT * FROM t_user WHERE not (id = ? OR name = ?)", + "SELECT * FROM t_user WHERE NOT (id = ? OR name = ?) AND t_user.tenant_id = 1 AND t_user.dept_id IN (10, 20)"); + } + + @Test + public void testSelectLeftJoin() { + // left join + assertSql("SELECT * FROM t_user e " + + "left join t_role e1 on e1.id = e.id " + + "WHERE e.id = ? OR e.name = ?", + "SELECT * FROM t_user e " + + "LEFT JOIN t_role e1 ON e1.id = e.id AND e1.tenant_id = 1 " + + "WHERE (e.id = ? OR e.name = ?) AND e.tenant_id = 1 AND e.dept_id IN (10, 20)"); + + // 条件 e.id = ? OR e.name = ? 带括号 + assertSql("SELECT * FROM t_user e " + + "left join t_role e1 on e1.id = e.id " + + "WHERE (e.id = ? OR e.name = ?)", + "SELECT * FROM t_user e " + + "LEFT JOIN t_role e1 ON e1.id = e.id AND e1.tenant_id = 1 " + + "WHERE (e.id = ? OR e.name = ?) AND e.tenant_id = 1 AND e.dept_id IN (10, 20)"); + } + + @Test + public void testSelectRightJoin() { + // right join + assertSql("SELECT * FROM t_user e " + + "right join t_role e1 on e1.id = e.id " + + "WHERE e.id = ? OR e.name = ?", + "SELECT * FROM t_user e " + + "RIGHT JOIN t_role e1 ON e1.id = e.id AND e.tenant_id = 1 AND e.dept_id IN (10, 20) " + + "WHERE (e.id = ? OR e.name = ?) AND e1.tenant_id = 1"); + + // 条件 e.id = ? OR e.name = ? 带括号 + assertSql("SELECT * FROM t_user e " + + "right join t_role e1 on e1.id = e.id " + + "WHERE (e.id = ? OR e.name = ?)", + "SELECT * FROM t_user e " + + "RIGHT JOIN t_role e1 ON e1.id = e.id AND e.tenant_id = 1 AND e.dept_id IN (10, 20) " + + "WHERE (e.id = ? OR e.name = ?) AND e1.tenant_id = 1"); + } + + @Test + public void testSelectInnerJoin() { + // inner join + assertSql("SELECT * FROM t_user e " + + "inner join entity1 e1 on e1.id = e.id " + + "WHERE e.id = ? OR e.name = ?", + "SELECT * FROM t_user e " + + "INNER JOIN entity1 e1 ON e1.id = e.id AND e.tenant_id = 1 AND e.dept_id IN (10, 20) AND e1.tenant_id = 1 " + + "WHERE e.id = ? OR e.name = ?"); + + // 条件 e.id = ? OR e.name = ? 带括号 + assertSql("SELECT * FROM t_user e " + + "inner join entity1 e1 on e1.id = e.id " + + "WHERE (e.id = ? OR e.name = ?)", + "SELECT * FROM t_user e " + + "INNER JOIN entity1 e1 ON e1.id = e.id AND e.tenant_id = 1 AND e.dept_id IN (10, 20) AND e1.tenant_id = 1 " + + "WHERE (e.id = ? OR e.name = ?)"); + + // 没有 On 的 inner join + assertSql("SELECT * FROM entity,entity1 " + + "WHERE entity.id = entity1.id", + "SELECT * FROM entity, entity1 " + + "WHERE entity.id = entity1.id AND entity.tenant_id = 1 AND entity1.tenant_id = 1"); + } + +} diff --git a/iailab-framework/iailab-common-mybatis/src/main/java/com/iailab/framework/common/dao/BaseDao.java b/iailab-framework/iailab-common-mybatis/src/main/java/com/iailab/framework/common/dao/BaseDao.java new file mode 100644 index 0000000..0cdb369 --- /dev/null +++ b/iailab-framework/iailab-common-mybatis/src/main/java/com/iailab/framework/common/dao/BaseDao.java @@ -0,0 +1,21 @@ +/** + * Copyright (c) 2018 人人开源 All rights reserved. + * + * https://www.renren.io + * + * 版权所有,侵权必究! + */ + +package com.iailab.framework.common.dao; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; + +/** + * 基础Dao + * + * @author Mark sunlightcs@gmail.com + * @since 1.0.0 + */ +public interface BaseDao<T> extends BaseMapper<T> { + +} diff --git a/iailab-framework/iailab-common-mybatis/src/main/java/com/iailab/framework/common/entity/BaseEntity.java b/iailab-framework/iailab-common-mybatis/src/main/java/com/iailab/framework/common/entity/BaseEntity.java new file mode 100644 index 0000000..1a740ce --- /dev/null +++ b/iailab-framework/iailab-common-mybatis/src/main/java/com/iailab/framework/common/entity/BaseEntity.java @@ -0,0 +1,41 @@ +/** + * Copyright (c) 2018 人人开源 All rights reserved. + * + * https://www.renren.io + * + * 版权所有,侵权必究! + */ + +package com.iailab.framework.common.entity; + +import com.baomidou.mybatisplus.annotation.FieldFill; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; + +/** + * 基础实体类,所有实体都需要继承 + * + * @author Mark sunlightcs@gmail.com + */ +@Data +public abstract class BaseEntity implements Serializable { + /** + * id + */ + @TableId + private Long id; + /** + * 创建者 + */ + @TableField(fill = FieldFill.INSERT) + private Long creator; + /** + * 创建时间 + */ + @TableField(fill = FieldFill.INSERT) + private Date createDate; +} \ No newline at end of file diff --git a/iailab-framework/iailab-common-mybatis/src/main/java/com/iailab/framework/common/package-info.java b/iailab-framework/iailab-common-mybatis/src/main/java/com/iailab/framework/common/package-info.java new file mode 100644 index 0000000..44e33fb --- /dev/null +++ b/iailab-framework/iailab-common-mybatis/src/main/java/com/iailab/framework/common/package-info.java @@ -0,0 +1 @@ +package com.iailab.framework.common; \ No newline at end of file diff --git a/iailab-framework/iailab-common-mybatis/src/main/java/com/iailab/framework/common/page/PageData.java b/iailab-framework/iailab-common-mybatis/src/main/java/com/iailab/framework/common/page/PageData.java new file mode 100644 index 0000000..64c0822 --- /dev/null +++ b/iailab-framework/iailab-common-mybatis/src/main/java/com/iailab/framework/common/page/PageData.java @@ -0,0 +1,43 @@ +/** + * Copyright (c) 2018 人人开源 All rights reserved. + * + * https://www.renren.io + * + * 版权所有,侵权必究! + */ + +package com.iailab.framework.common.page; + +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.tags.Tag; +import lombok.Data; + +import java.io.Serializable; +import java.util.List; + +/** + * 分页工具类 + * + * @author Mark sunlightcs@gmail.com + */ +@Data +@Tag(name = "分页数据") +public class PageData<T> implements Serializable { + private static final long serialVersionUID = 1L; + + @Schema(description = "总记录数") + private int total; + + @Schema(description = "列表数据") + private List<T> list; + + /** + * 分页 + * @param list 列表数据 + * @param total 总记录数 + */ + public PageData(List<T> list, long total) { + this.list = list; + this.total = (int)total; + } +} \ No newline at end of file diff --git a/iailab-framework/iailab-common-mybatis/src/main/java/com/iailab/framework/common/service/BaseService.java b/iailab-framework/iailab-common-mybatis/src/main/java/com/iailab/framework/common/service/BaseService.java new file mode 100644 index 0000000..686441d --- /dev/null +++ b/iailab-framework/iailab-common-mybatis/src/main/java/com/iailab/framework/common/service/BaseService.java @@ -0,0 +1,116 @@ +/** + * Copyright (c) 2018 人人开源 All rights reserved. + * + * https://www.renren.io + * + * 版权所有,侵权必究! + */ + +package com.iailab.framework.common.service; + +import com.baomidou.mybatisplus.core.conditions.Wrapper; + +import java.io.Serializable; +import java.util.Collection; + +/** + * 基础服务接口,所有Service接口都要继承 + * + * @author Mark sunlightcs@gmail.com + */ +public interface BaseService<T> { + Class<T> currentModelClass(); + + /** + * <p> + * 插入一条记录(选择字段,策略插入) + * </p> + * + * @param entity 实体对象 + */ + boolean insert(T entity); + + /** + * <p> + * 插入(批量),该方法不支持 Oracle、SQL Server + * </p> + * + * @param entityList 实体对象集合 + */ + boolean insertBatch(Collection<T> entityList); + + /** + * <p> + * 插入(批量),该方法不支持 Oracle、SQL Server + * </p> + * + * @param entityList 实体对象集合 + * @param batchSize 插入批次数量 + */ + boolean insertBatch(Collection<T> entityList, int batchSize); + + /** + * <p> + * 根据 ID 选择修改 + * </p> + * + * @param entity 实体对象 + */ + boolean updateById(T entity); + + /** + * <p> + * 根据 whereEntity 条件,更新记录 + * </p> + * + * @param entity 实体对象 + * @param updateWrapper 实体对象封装操作类 {@link com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper} + */ + boolean update(T entity, Wrapper<T> updateWrapper); + + /** + * <p> + * 根据ID 批量更新 + * </p> + * + * @param entityList 实体对象集合 + */ + boolean updateBatchById(Collection<T> entityList); + + /** + * <p> + * 根据ID 批量更新 + * </p> + * + * @param entityList 实体对象集合 + * @param batchSize 更新批次数量 + */ + boolean updateBatchById(Collection<T> entityList, int batchSize); + + /** + * <p> + * 根据 ID 查询 + * </p> + * + * @param id 主键ID + */ + T selectById(Serializable id); + + /** + * <p> + * 根据 ID 删除 + * </p> + * + * @param id 主键ID + */ + boolean deleteById(Serializable id); + + /** + * <p> + * 删除(根据ID 批量删除) + * </p> + * + * @param idList 主键ID列表 + */ + boolean deleteBatchIds(Collection<? extends Serializable> idList); +} \ No newline at end of file diff --git a/iailab-framework/iailab-common-mybatis/src/main/java/com/iailab/framework/common/service/CrudService.java b/iailab-framework/iailab-common-mybatis/src/main/java/com/iailab/framework/common/service/CrudService.java new file mode 100644 index 0000000..c8c78cb --- /dev/null +++ b/iailab-framework/iailab-common-mybatis/src/main/java/com/iailab/framework/common/service/CrudService.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2018 人人开源 All rights reserved. + * <p> + * https://www.renren.io + * <p> + * 版权所有,侵权必究! + */ + +package com.iailab.framework.common.service; + +import com.iailab.framework.common.page.PageData; + +import java.util.List; +import java.util.Map; + +/** + * CRUD基础服务接口 + * + * @author Mark sunlightcs@gmail.com + */ +public interface CrudService<T, D> extends BaseService<T> { + + PageData<D> page(Map<String, Object> params); + + List<D> list(Map<String, Object> params); + + D get(Long id); + + void save(D dto); + + void update(D dto); + + void delete(Long[] ids); + +} \ No newline at end of file diff --git a/iailab-framework/iailab-common-mybatis/src/main/java/com/iailab/framework/common/service/impl/BaseServiceImpl.java b/iailab-framework/iailab-common-mybatis/src/main/java/com/iailab/framework/common/service/impl/BaseServiceImpl.java new file mode 100644 index 0000000..51254d7 --- /dev/null +++ b/iailab-framework/iailab-common-mybatis/src/main/java/com/iailab/framework/common/service/impl/BaseServiceImpl.java @@ -0,0 +1,219 @@ +/** + * Copyright (c) 2018 人人开源 All rights reserved. + * + * https://www.renren.io + * + * 版权所有,侵权必究! + */ + +package com.iailab.framework.common.service.impl; + +import com.baomidou.mybatisplus.core.conditions.Wrapper; +import com.baomidou.mybatisplus.core.enums.SqlMethod; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.core.metadata.OrderItem; +import com.baomidou.mybatisplus.core.toolkit.Constants; +import com.baomidou.mybatisplus.core.toolkit.ReflectionKit; +import com.baomidou.mybatisplus.core.toolkit.StringUtils; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.toolkit.SqlHelper; +import com.iailab.framework.common.constant.Constant; +import com.iailab.framework.common.page.PageData; +import com.iailab.framework.common.service.BaseService; +import com.iailab.framework.common.util.object.BeanUtils; +import org.apache.ibatis.binding.MapperMethod; +import org.apache.ibatis.logging.Log; +import org.apache.ibatis.logging.LogFactory; +import org.apache.ibatis.session.SqlSession; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.transaction.annotation.Transactional; + +import java.io.Serializable; +import java.util.Collection; +import java.util.List; +import java.util.Map; +import java.util.function.BiConsumer; + +/** + * 基础服务类,所有Service都要继承 + * + * @author Mark sunlightcs@gmail.com + */ +public abstract class BaseServiceImpl<M extends BaseMapper<T>, T> implements BaseService<T> { + @Autowired + protected M baseDao; + protected Log log = LogFactory.getLog(getClass()); + + /** + * 获取分页对象 + * @param params 分页查询参数 + * @param defaultOrderField 默认排序字段 + * @param isAsc 排序方式 + */ + protected IPage<T> getPage(Map<String, Object> params, String defaultOrderField, boolean isAsc) { + //分页参数 + long curPage = 1; + long limit = 10; + + if(params.get(Constant.PAGE) != null){ + curPage = Long.parseLong((String)params.get(Constant.PAGE)); + } + if(params.get(Constant.LIMIT) != null){ + limit = Long.parseLong((String)params.get(Constant.LIMIT)); + } + + //分页对象 + Page<T> page = new Page<>(curPage, limit); + + //分页参数 + params.put(Constant.PAGE, page); + + //排序字段 + String orderField = (String)params.get(Constant.ORDER_FIELD); + String order = (String)params.get(Constant.ORDER); + + //前端字段排序 + if(StringUtils.isNotBlank(orderField) && StringUtils.isNotBlank(order)){ + if(Constant.ASC.equalsIgnoreCase(order)) { + return page.addOrder(OrderItem.asc(orderField)); + }else { + return page.addOrder(OrderItem.desc(orderField)); + } + } + + //没有排序字段,则不排序 + if(StringUtils.isBlank(defaultOrderField)){ + return page; + } + + //默认排序 + if(isAsc) { + page.addOrder(OrderItem.asc(defaultOrderField)); + }else { + page.addOrder(OrderItem.desc(defaultOrderField)); + } + + return page; + } + + protected <T> PageData<T> getPageData(List<?> list, long total, Class<T> target){ + List<T> targetList = BeanUtils.toBean(list, target); + + return new PageData<>(targetList, total); + } + + protected <T> PageData<T> getPageData(IPage page, Class<T> target){ + return getPageData(page.getRecords(), page.getTotal(), target); + } + + protected void paramsToLike(Map<String, Object> params, String... likes){ + for (String like : likes){ + String val = (String)params.get(like); + if (StringUtils.isNotBlank(val)){ + params.put(like, "%" + val + "%"); + }else { + params.put(like, null); + } + } + } + + /** + * <p> + * 判断数据库操作是否成功 + * </p> + * <p> + * 注意!! 该方法为 Integer 判断,不可传入 int 基本类型 + * </p> + * + * @param result 数据库操作返回影响条数 + * @return boolean + */ + protected static boolean retBool(Integer result) { + return SqlHelper.retBool(result); + } + + protected Class<M> currentMapperClass() { + return (Class<M>) ReflectionKit.getSuperClassGenericType(this.getClass(), BaseServiceImpl.class, 0); + } + + @Override + public Class<T> currentModelClass() { + return (Class<T>)ReflectionKit.getSuperClassGenericType(this.getClass(), BaseServiceImpl.class, 1); + } + + protected String getSqlStatement(SqlMethod sqlMethod) { + return SqlHelper.getSqlStatement(this.currentMapperClass(), sqlMethod); + } + + @Override + public boolean insert(T entity) { + return BaseServiceImpl.retBool(baseDao.insert(entity)); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public boolean insertBatch(Collection<T> entityList) { + return insertBatch(entityList, 100); + } + + /** + * 批量插入 + */ + @Override + @Transactional(rollbackFor = Exception.class) + public boolean insertBatch(Collection<T> entityList, int batchSize) { + String sqlStatement = getSqlStatement(SqlMethod.INSERT_ONE); + return executeBatch(entityList, batchSize, (sqlSession, entity) -> sqlSession.insert(sqlStatement, entity)); + } + + /** + * 执行批量操作 + */ + protected <E> boolean executeBatch(Collection<E> list, int batchSize, BiConsumer<SqlSession, E> consumer) { + return SqlHelper.executeBatch(this.currentModelClass(), this.log, list, batchSize, consumer); + } + + + @Override + public boolean updateById(T entity) { + return BaseServiceImpl.retBool(baseDao.updateById(entity)); + } + + @Override + public boolean update(T entity, Wrapper<T> updateWrapper) { + return BaseServiceImpl.retBool(baseDao.update(entity, updateWrapper)); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public boolean updateBatchById(Collection<T> entityList) { + return updateBatchById(entityList, 30); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public boolean updateBatchById(Collection<T> entityList, int batchSize) { + String sqlStatement = getSqlStatement(SqlMethod.UPDATE_BY_ID); + return executeBatch(entityList, batchSize, (sqlSession, entity) -> { + MapperMethod.ParamMap<T> param = new MapperMethod.ParamMap<>(); + param.put(Constants.ENTITY, entity); + sqlSession.update(sqlStatement, param); + }); + } + + @Override + public T selectById(Serializable id) { + return baseDao.selectById(id); + } + + @Override + public boolean deleteById(Serializable id) { + return SqlHelper.retBool(baseDao.deleteById(id)); + } + + @Override + public boolean deleteBatchIds(Collection<? extends Serializable> idList) { + return SqlHelper.retBool(baseDao.deleteBatchIds(idList)); + } +} \ No newline at end of file diff --git a/iailab-framework/iailab-common-mybatis/src/main/java/com/iailab/framework/common/service/impl/CrudServiceImpl.java b/iailab-framework/iailab-common-mybatis/src/main/java/com/iailab/framework/common/service/impl/CrudServiceImpl.java new file mode 100644 index 0000000..6b12a43 --- /dev/null +++ b/iailab-framework/iailab-common-mybatis/src/main/java/com/iailab/framework/common/service/impl/CrudServiceImpl.java @@ -0,0 +1,80 @@ +/** + * Copyright (c) 2018 人人开源 All rights reserved. + * <p> + * https://www.renren.io + * <p> + * 版权所有,侵权必究! + */ + +package com.iailab.framework.common.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.core.toolkit.ReflectionKit; +import com.iailab.framework.common.page.PageData; +import com.iailab.framework.common.service.CrudService; +import com.iailab.framework.common.util.object.ConvertUtils; +import org.springframework.beans.BeanUtils; + +import java.util.Arrays; +import java.util.List; +import java.util.Map; + +/** + * CRUD基础服务类 + * + * @author Mark sunlightcs@gmail.com + */ +public abstract class CrudServiceImpl<M extends BaseMapper<T>, T, D> extends BaseServiceImpl<M, T> implements CrudService<T, D> { + + protected Class<D> currentDtoClass() { + return (Class<D>)ReflectionKit.getSuperClassGenericType(getClass(), CrudServiceImpl.class, 2); + } + + @Override + public PageData<D> page(Map<String, Object> params) { + IPage<T> page = baseDao.selectPage( + getPage(params, null, false), + getWrapper(params) + ); + + return getPageData(page, currentDtoClass()); + } + + @Override + public List<D> list(Map<String, Object> params) { + List<T> entityList = baseDao.selectList(getWrapper(params)); + + return ConvertUtils.sourceToTarget(entityList, currentDtoClass()); + } + + public abstract QueryWrapper<T> getWrapper(Map<String, Object> params); + + @Override + public D get(Long id) { + T entity = baseDao.selectById(id); + + return ConvertUtils.sourceToTarget(entity, currentDtoClass()); + } + + @Override + public void save(D dto) { + T entity = ConvertUtils.sourceToTarget(dto, currentModelClass()); + insert(entity); + + //copy主键值到dto + BeanUtils.copyProperties(entity, dto); + } + + @Override + public void update(D dto) { + T entity = ConvertUtils.sourceToTarget(dto, currentModelClass()); + updateById(entity); + } + + @Override + public void delete(Long[] ids) { + baseDao.deleteBatchIds(Arrays.asList(ids)); + } +} \ No newline at end of file diff --git a/iailab-framework/iailab-common-mybatis/src/main/java/com/iailab/framework/mybatis/core/enums/DbTypeEnum.java b/iailab-framework/iailab-common-mybatis/src/main/java/com/iailab/framework/mybatis/core/enums/DbTypeEnum.java new file mode 100644 index 0000000..644d1e3 --- /dev/null +++ b/iailab-framework/iailab-common-mybatis/src/main/java/com/iailab/framework/mybatis/core/enums/DbTypeEnum.java @@ -0,0 +1,84 @@ +package com.iailab.framework.mybatis.core.enums; + +import cn.hutool.core.util.StrUtil; +import com.baomidou.mybatisplus.annotation.DbType; +import lombok.AllArgsConstructor; +import lombok.Getter; + +import java.util.Arrays; +import java.util.Map; +import java.util.Optional; +import java.util.function.Function; +import java.util.stream.Collectors; + +/** + * 针对 MyBatis Plus 的 {@link DbType} 增强,补充更多信息 + */ +@Getter +@AllArgsConstructor +public enum DbTypeEnum { + + /** + * MySQL + */ + MY_SQL( DbType.MYSQL, "MySQL", "FIND_IN_SET('#{value}', #{column}) <> 0"), + + /** + * Oracle + */ + ORACLE(DbType.ORACLE, "Oracle", "FIND_IN_SET('#{value}', #{column}) <> 0"), + + /** + * PostgreSQL + * + * 华为 openGauss 使用 ProductName 与 PostgreSQL 相同 + */ + POSTGRE_SQL(DbType.POSTGRE_SQL,"PostgreSQL", "POSITION('#{value}' IN #{column}) <> 0"), + + /** + * SQL Server + */ + SQL_SERVER(DbType.SQL_SERVER, "Microsoft SQL Server", "CHARINDEX(',' + #{value} + ',', ',' + #{column} + ',') <> 0"), + + /** + * 达梦 + */ + DM(DbType.DM, "DM DBMS", "FIND_IN_SET('#{value}', #{column}) <> 0"), + + /** + * 人大金仓 + */ + KINGBASE_ES(DbType.KINGBASE_ES, "KingbaseES", "POSITION('#{value}' IN #{column}) <> 0"), + ; + + public static final Map<String, DbTypeEnum> MAP_BY_NAME = Arrays.stream(values()) + .collect(Collectors.toMap(DbTypeEnum::getProductName, Function.identity())); + + public static final Map<DbType, DbTypeEnum> MAP_BY_MP = Arrays.stream(values()) + .collect(Collectors.toMap(DbTypeEnum::getMpDbType, Function.identity())); + + /** + * MyBatis Plus 类型 + */ + private final DbType mpDbType; + /** + * 数据库产品名 + */ + private final String productName; + /** + * SQL FIND_IN_SET 模板 + */ + private final String findInSetTemplate; + + public static DbType find(String databaseProductName) { + if (StrUtil.isBlank(databaseProductName)) { + return null; + } + return MAP_BY_NAME.get(databaseProductName).getMpDbType(); + } + + public static String getFindInSetTemplate(DbType dbType) { + return Optional.of(MAP_BY_MP.get(dbType).getFindInSetTemplate()) + .orElseThrow(() -> new IllegalArgumentException("FIND_IN_SET not supported")); + } +} diff --git a/iailab-framework/iailab-common-mybatis/src/main/java/com/iailab/framework/mybatis/interceptor/DataFilterInterceptor.java b/iailab-framework/iailab-common-mybatis/src/main/java/com/iailab/framework/mybatis/interceptor/DataFilterInterceptor.java new file mode 100644 index 0000000..8cf8a98 --- /dev/null +++ b/iailab-framework/iailab-common-mybatis/src/main/java/com/iailab/framework/mybatis/interceptor/DataFilterInterceptor.java @@ -0,0 +1,89 @@ +/** + * Copyright (c) 2018 人人开源 All rights reserved. + * + * https://www.renren.io + * + * 版权所有,侵权必究! + */ + +package com.iailab.framework.mybatis.interceptor; + +import cn.hutool.core.util.StrUtil; +import com.baomidou.mybatisplus.core.toolkit.PluginUtils; +import com.baomidou.mybatisplus.extension.plugins.inner.InnerInterceptor; +import net.sf.jsqlparser.JSQLParserException; +import net.sf.jsqlparser.expression.Expression; +import net.sf.jsqlparser.expression.StringValue; +import net.sf.jsqlparser.expression.operators.conditional.AndExpression; +import net.sf.jsqlparser.parser.CCJSqlParserUtil; +import net.sf.jsqlparser.statement.select.PlainSelect; +import net.sf.jsqlparser.statement.select.Select; +import org.apache.ibatis.executor.Executor; +import org.apache.ibatis.mapping.BoundSql; +import org.apache.ibatis.mapping.MappedStatement; +import org.apache.ibatis.session.ResultHandler; +import org.apache.ibatis.session.RowBounds; + +import java.util.Map; + +/** + * 数据过滤 + * + * @author Mark sunlightcs@gmail.com + */ +public class DataFilterInterceptor implements InnerInterceptor { + + @Override + public void beforeQuery(Executor executor, MappedStatement ms, Object parameter, RowBounds rowBounds, ResultHandler resultHandler, BoundSql boundSql) { + DataScope scope = getDataScope(parameter); + // 不进行数据过滤 + if(scope == null || StrUtil.isBlank(scope.getSqlFilter())){ + return; + } + + // 拼接新SQL + String buildSql = getSelect(boundSql.getSql(), scope); + + // 重写SQL + PluginUtils.mpBoundSql(boundSql).sql(buildSql); + } + + private DataScope getDataScope(Object parameter){ + if (parameter == null){ + return null; + } + + // 判断参数里是否有DataScope对象 + if (parameter instanceof Map) { + Map<?, ?> parameterMap = (Map<?, ?>) parameter; + for (Map.Entry entry : parameterMap.entrySet()) { + if (entry.getValue() != null && entry.getValue() instanceof DataScope) { + return (DataScope) entry.getValue(); + } + } + } else if (parameter instanceof DataScope) { + return (DataScope) parameter; + } + + return null; + } + + private String getSelect(String buildSql, DataScope scope){ + try { + Select select = (Select) CCJSqlParserUtil.parse(buildSql); + PlainSelect plainSelect = (PlainSelect) select.getSelectBody(); + + Expression expression = plainSelect.getWhere(); + if(expression == null){ + plainSelect.setWhere(new StringValue(scope.getSqlFilter())); + }else{ + AndExpression andExpression = new AndExpression(expression, new StringValue(scope.getSqlFilter())); + plainSelect.setWhere(andExpression); + } + + return select.toString().replaceAll("'", ""); + }catch (JSQLParserException e){ + return buildSql; + } + } +} \ No newline at end of file diff --git a/iailab-framework/iailab-common-mybatis/src/main/java/com/iailab/framework/mybatis/interceptor/DataScope.java b/iailab-framework/iailab-common-mybatis/src/main/java/com/iailab/framework/mybatis/interceptor/DataScope.java new file mode 100644 index 0000000..e9f2dcc --- /dev/null +++ b/iailab-framework/iailab-common-mybatis/src/main/java/com/iailab/framework/mybatis/interceptor/DataScope.java @@ -0,0 +1,36 @@ +/** + * Copyright (c) 2018 人人开源 All rights reserved. + * + * https://www.renren.io + * + * 版权所有,侵权必究! + */ + +package com.iailab.framework.mybatis.interceptor; + +/** + * 数据范围 + * + * @author Mark sunlightcs@gmail.com + * @since 1.0.0 + */ +public class DataScope { + private String sqlFilter; + + public DataScope(String sqlFilter) { + this.sqlFilter = sqlFilter; + } + + public String getSqlFilter() { + return sqlFilter; + } + + public void setSqlFilter(String sqlFilter) { + this.sqlFilter = sqlFilter; + } + + @Override + public String toString() { + return this.sqlFilter; + } +} \ No newline at end of file diff --git a/iailab-framework/iailab-common/src/main/java/com/iailab/framework/common/annotation/AutoBpm.java b/iailab-framework/iailab-common/src/main/java/com/iailab/framework/common/annotation/AutoBpm.java new file mode 100644 index 0000000..33abe2f --- /dev/null +++ b/iailab-framework/iailab-common/src/main/java/com/iailab/framework/common/annotation/AutoBpm.java @@ -0,0 +1,16 @@ +package com.iailab.framework.common.annotation; + +import java.lang.annotation.*; + +/** + * 业务流程 + * + * @author PanZhibao + * @Description + * @createTime 2022年12月20日 16:10:00 + */ +@Target(ElementType.METHOD) +@Retention(RetentionPolicy.RUNTIME) +@Documented +public @interface AutoBpm { +} diff --git a/iailab-framework/iailab-common/src/main/java/com/iailab/framework/common/annotation/AutoDict.java b/iailab-framework/iailab-common/src/main/java/com/iailab/framework/common/annotation/AutoDict.java new file mode 100644 index 0000000..7205fb9 --- /dev/null +++ b/iailab-framework/iailab-common/src/main/java/com/iailab/framework/common/annotation/AutoDict.java @@ -0,0 +1,20 @@ +package com.iailab.framework.common.annotation; + +import java.lang.annotation.*; + +/** + * @author PanZhibao + * @Description + * @createTime 2022年05月21日 10:59:00 + */ +@Target(ElementType.METHOD) +@Retention(RetentionPolicy.RUNTIME) +@Documented +public @interface AutoDict { + + /** + * 暂时无用 + * @return + */ + String value() default ""; +} diff --git a/iailab-framework/iailab-common/src/main/java/com/iailab/framework/common/annotation/AutoUser.java b/iailab-framework/iailab-common/src/main/java/com/iailab/framework/common/annotation/AutoUser.java new file mode 100644 index 0000000..c1c0a36 --- /dev/null +++ b/iailab-framework/iailab-common/src/main/java/com/iailab/framework/common/annotation/AutoUser.java @@ -0,0 +1,20 @@ +package com.iailab.framework.common.annotation; + +import java.lang.annotation.*; + +/** + * @author PanZhibao + * @Description + * @createTime 2023年06月07日 11:35:00 + */ +@Target(ElementType.METHOD) +@Retention(RetentionPolicy.RUNTIME) +@Documented +public @interface AutoUser { + + /** + * 暂时无用 + * @return + */ + String value() default ""; +} diff --git a/iailab-framework/iailab-common/src/main/java/com/iailab/framework/common/annotation/BpmProcess.java b/iailab-framework/iailab-common/src/main/java/com/iailab/framework/common/annotation/BpmProcess.java new file mode 100644 index 0000000..8453bef --- /dev/null +++ b/iailab-framework/iailab-common/src/main/java/com/iailab/framework/common/annotation/BpmProcess.java @@ -0,0 +1,25 @@ +package com.iailab.framework.common.annotation; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * 业务流程ID + * + * @author PanZhibao + * @Description + * @createTime 2022年12月20日 16:17:00 + */ +@Target(ElementType.FIELD) +@Retention(RetentionPolicy.RUNTIME) +public @interface BpmProcess { + + /** + * 业务ID + * + * @return + */ + String businessKey(); +} diff --git a/iailab-framework/iailab-common/src/main/java/com/iailab/framework/common/annotation/BpmStatus.java b/iailab-framework/iailab-common/src/main/java/com/iailab/framework/common/annotation/BpmStatus.java new file mode 100644 index 0000000..213f0a7 --- /dev/null +++ b/iailab-framework/iailab-common/src/main/java/com/iailab/framework/common/annotation/BpmStatus.java @@ -0,0 +1,25 @@ +package com.iailab.framework.common.annotation; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * 业务流程状态 + * + * @author PanZhibao + * @Description + * @createTime 2022年12月20日 16:14:00 + */ +@Target(ElementType.FIELD) +@Retention(RetentionPolicy.RUNTIME) +public @interface BpmStatus { + + /** + * 业务ID + * + * @return + */ + String businessKey(); +} diff --git a/iailab-framework/iailab-common/src/main/java/com/iailab/framework/common/annotation/Dict.java b/iailab-framework/iailab-common/src/main/java/com/iailab/framework/common/annotation/Dict.java new file mode 100644 index 0000000..dd01bb5 --- /dev/null +++ b/iailab-framework/iailab-common/src/main/java/com/iailab/framework/common/annotation/Dict.java @@ -0,0 +1,32 @@ +package com.iailab.framework.common.annotation; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * 字典注解 + * + * @author PanZhibao + * @Description + * @createTime 2022年05月20日 17:36:00 + */ +@Target(ElementType.FIELD) +@Retention(RetentionPolicy.RUNTIME) +public @interface Dict { + + /** + * 数据code + * + * @return + */ + String dicCode(); + + /** + * 数据itemValue + * + * @return + */ + String itemValue(); +} diff --git a/iailab-framework/iailab-common/src/main/java/com/iailab/framework/common/annotation/UserRealName.java b/iailab-framework/iailab-common/src/main/java/com/iailab/framework/common/annotation/UserRealName.java new file mode 100644 index 0000000..a142543 --- /dev/null +++ b/iailab-framework/iailab-common/src/main/java/com/iailab/framework/common/annotation/UserRealName.java @@ -0,0 +1,30 @@ +package com.iailab.framework.common.annotation; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * @author PanZhibao + * @Description + * @createTime 2023年06月07日 11:37:00 + */ +@Target(ElementType.FIELD) +@Retention(RetentionPolicy.RUNTIME) +public @interface UserRealName { + + /** + * 用户ID + * + * @return + */ + String userid() default ""; + + /** + * 用户账号 + * + * @return + */ + String username() default ""; +} diff --git a/iailab-framework/iailab-common/src/main/java/com/iailab/framework/common/constant/CacheConstant.java b/iailab-framework/iailab-common/src/main/java/com/iailab/framework/common/constant/CacheConstant.java new file mode 100644 index 0000000..36e9ba2 --- /dev/null +++ b/iailab-framework/iailab-common/src/main/java/com/iailab/framework/common/constant/CacheConstant.java @@ -0,0 +1,108 @@ +package com.iailab.framework.common.constant; + +/** + * @author: huangxutao + * @date: 2019-06-14 + * @description: 缓存常量 + */ +public interface CacheConstant { + + /** + * 字典信息缓存(含禁用的字典项) + */ + public static final String SYS_DICT_CACHE = "sys:cache:dict"; + + /** + * 字典信息缓存 status为有效的 + */ + public static final String SYS_ENABLE_DICT_CACHE = "sys:cache:dictEnable"; + /** + * 表字典信息缓存 + */ + public static final String SYS_DICT_TABLE_CACHE = "sys:cache:dictTable"; + public static final String SYS_DICT_TABLE_BY_KEYS_CACHE = SYS_DICT_TABLE_CACHE + "ByKeys"; + + /** + * 数据权限配置缓存 + */ + public static final String SYS_DATA_PERMISSIONS_CACHE = "sys:cache:permission:datarules"; + + /** + * 缓存用户信息 + */ + public static final String SYS_USERS_CACHE = "sys:cache:user"; + + /** + * 全部部门信息缓存 + */ + public static final String SYS_DEPARTS_CACHE = "sys:cache:depart:alldata"; + + + /** + * 全部部门ids缓存 + */ + public static final String SYS_DEPART_IDS_CACHE = "sys:cache:depart:allids"; + + + /** + * 测试缓存key + */ + public static final String TEST_DEMO_CACHE = "test:demo"; + + /** + * 字典信息缓存 + */ + public static final String SYS_DYNAMICDB_CACHE = "sys:cache:dbconnect:dynamic:"; + + /** + * gateway路由缓存 + */ + public static final String GATEWAY_ROUTES = "sys:cache:cloud:gateway_routes"; + + + /** + * gatewayAPI缓存 + */ + public static final String GATEWAY_APIS = "sys:cache:cloud:gateway_apis"; + + /** + * gateway路由 reload key + */ + public static final String ROUTE_JVM_RELOAD_TOPIC = "gateway_jvm_route_reload_topic"; + + /** + * TODO 冗余代码 待删除 + *插件商城排行榜 + */ + public static final String PLUGIN_MALL_RANKING = "pluginMall::rankingList"; + /** + * TODO 冗余代码 待删除 + *插件商城排行榜 + */ + public static final String PLUGIN_MALL_PAGE_LIST = "pluginMall::queryPageList"; + + + /** + * online列表页配置信息缓存key + */ + public static final String ONLINE_LIST = "sys:cache:online:list"; + + /** + * online表单页配置信息缓存key + */ + public static final String ONLINE_FORM = "sys:cache:online:form"; + + /** + * online报表 + */ + public static final String ONLINE_RP = "sys:cache:online:rp"; + + /** + * online图表 + */ + public static final String ONLINE_GRAPH = "sys:cache:online:graph"; + /** + * 拖拽页面信息缓存 + */ + public static final String DRAG_PAGE_CACHE = "drag:cache:param"; +} diff --git a/iailab-framework/iailab-common/src/main/java/com/iailab/framework/common/constant/CommonConstant.java b/iailab-framework/iailab-common/src/main/java/com/iailab/framework/common/constant/CommonConstant.java new file mode 100644 index 0000000..5d54a3c --- /dev/null +++ b/iailab-framework/iailab-common/src/main/java/com/iailab/framework/common/constant/CommonConstant.java @@ -0,0 +1,400 @@ +package com.iailab.framework.common.constant; + +/** + * @Description: 通用常量 + */ +public interface CommonConstant { + + /** + * 正常状态 + */ + public static final Integer STATUS_NORMAL = 0; + + /** + * 禁用状态 + */ + public static final Integer STATUS_DISABLE = -1; + + /** + * 删除标志 + */ + public static final Integer DEL_FLAG_1 = 1; + + /** + * 未删除 + */ + public static final Integer DEL_FLAG_0 = 0; + + /** + * 未提交 + */ + public static final Integer SUBMINT_STATUS_0 = 0; + + /** + * 系统日志类型: 登录 + */ + public static final int LOG_TYPE_1 = 1; + + /** + * 系统日志类型: 操作 + */ + public static final int LOG_TYPE_2 = 2; + + /** + * 操作日志类型: 查询 + */ + public static final int OPERATE_TYPE_1 = 1; + + /** + * 操作日志类型: 添加 + */ + public static final int OPERATE_TYPE_2 = 2; + + /** + * 操作日志类型: 更新 + */ + public static final int OPERATE_TYPE_3 = 3; + + /** + * 操作日志类型: 删除 + */ + public static final int OPERATE_TYPE_4 = 4; + + /** + * 操作日志类型: 倒入 + */ + public static final int OPERATE_TYPE_5 = 5; + + /** + * 操作日志类型: 导出 + */ + public static final int OPERATE_TYPE_6 = 6; + + /** + * 提交 + */ + public static final int SUBMIT_FLAG_1 = 1; + + /** + * 提交 + */ + public static final int SUBMIT_FLAG_0 = 0; + + /** + * 启用 + */ + public static final int IS_ENABLE = 1; + + /** + * 常量点类型 + */ + public static final String POINT_TYPE_NAME_CONSTANT = "CONSTANT"; + + + /** {@code 500 Server Error} (HTTP/1.0 - RFC 1945) */ + public static final Integer SC_INTERNAL_SERVER_ERROR_500 = 500; + /** {@code 200 OK} (HTTP/1.0 - RFC 1945) */ + public static final Integer SC_OK_200 = 200; + + /**访问权限认证未通过 510*/ + public static final Integer SC_JEECG_NO_AUTHZ=510; + + /** 登录用户Shiro权限缓存KEY前缀 */ + public static String PREFIX_USER_SHIRO_CACHE = "shiro:cache:org.jeecg.config.shiro.ShiroRealm.authorizationCache:"; + /** 登录用户Token令牌缓存KEY前缀 */ + public static final String PREFIX_USER_TOKEN = "prefix_user_token_"; +// /** Token缓存时间:3600秒即一小时 */ +// public static final int TOKEN_EXPIRE_TIME = 3600; + + /** 登录二维码 */ + public static final String LOGIN_QRCODE_PRE = "QRCODELOGIN:"; + public static final String LOGIN_QRCODE = "LQ:"; + /** 登录二维码token */ + public static final String LOGIN_QRCODE_TOKEN = "LQT:"; + + + /** + * 0:一级菜单 + */ + public static final Integer MENU_TYPE_0 = 0; + /** + * 1:子菜单 + */ + public static final Integer MENU_TYPE_1 = 1; + /** + * 2:按钮权限 + */ + public static final Integer MENU_TYPE_2 = 2; + + /**通告对象类型(USER:指定用户,ALL:全体用户)*/ + public static final String MSG_TYPE_UESR = "USER"; + public static final String MSG_TYPE_ALL = "ALL"; + + /**发布状态(0未发布,1已发布,2已撤销)*/ + public static final String NO_SEND = "0"; + public static final String HAS_SEND = "1"; + public static final String HAS_CANCLE = "2"; + + /**阅读状态(0未读,1已读)*/ + public static final String HAS_READ_FLAG = "1"; + public static final String NO_READ_FLAG = "0"; + + /**优先级(L低,M中,H高)*/ + public static final String PRIORITY_L = "L"; + public static final String PRIORITY_M = "M"; + public static final String PRIORITY_H = "H"; + + /** + * 短信模板方式 0 .登录模板、1.注册模板、2.忘记密码模板 + */ + public static final String SMS_TPL_TYPE_0 = "0"; + public static final String SMS_TPL_TYPE_1 = "1"; + public static final String SMS_TPL_TYPE_2 = "2"; + + /** + * 状态(0无效1有效) + */ + public static final String STATUS_0 = "0"; + public static final String STATUS_1 = "1"; + + /** + * 同步工作流引擎1同步0不同步 + */ + public static final Integer ACT_SYNC_1 = 1; + public static final Integer ACT_SYNC_0 = 0; + + /** + * 消息类型1:通知公告2:系统消息 + */ + public static final String MSG_CATEGORY_1 = "1"; + public static final String MSG_CATEGORY_2 = "2"; + + /** + * 是否配置菜单的数据权限 1是0否 + */ + public static final Integer RULE_FLAG_0 = 0; + public static final Integer RULE_FLAG_1 = 1; + + /** + * 是否用户已被冻结 1正常(解冻) 2冻结 + */ + public static final Integer USER_UNFREEZE = 1; + public static final Integer USER_FREEZE = 2; + + /**字典翻译文本后缀*/ + public static final String DICT_TEXT_SUFFIX = "_dictText"; + + /** + * 表单设计器主表类型 + */ + public static final Integer DESIGN_FORM_TYPE_MAIN = 1; + + /** + * 表单设计器子表表类型 + */ + public static final Integer DESIGN_FORM_TYPE_SUB = 2; + + /** + * 表单设计器URL授权通过 + */ + public static final Integer DESIGN_FORM_URL_STATUS_PASSED = 1; + + /** + * 表单设计器URL授权未通过 + */ + public static final Integer DESIGN_FORM_URL_STATUS_NOT_PASSED = 2; + + /** + * 表单设计器新增 Flag + */ + public static final String DESIGN_FORM_URL_TYPE_ADD = "add"; + /** + * 表单设计器修改 Flag + */ + public static final String DESIGN_FORM_URL_TYPE_EDIT = "edit"; + /** + * 表单设计器详情 Flag + */ + public static final String DESIGN_FORM_URL_TYPE_DETAIL = "detail"; + /** + * 表单设计器复用数据 Flag + */ + public static final String DESIGN_FORM_URL_TYPE_REUSE = "reuse"; + /** + * 表单设计器编辑 Flag (已弃用) + */ + public static final String DESIGN_FORM_URL_TYPE_VIEW = "view"; + + /** + * online参数值设置(是:Y, 否:N) + */ + public static final String ONLINE_PARAM_VAL_IS_TURE = "Y"; + public static final String ONLINE_PARAM_VAL_IS_FALSE = "N"; + + /** + * 文件上传类型(本地:local,Minio:minio,阿里云:alioss) + */ + public static final String UPLOAD_TYPE_LOCAL = "local"; + public static final String UPLOAD_TYPE_MINIO = "minio"; + public static final String UPLOAD_TYPE_OSS = "alioss"; + + /** + * 文档上传自定义桶名称 + */ + public static final String UPLOAD_CUSTOM_BUCKET = "eoafile"; + /** + * 文档上传自定义路径 + */ + public static final String UPLOAD_CUSTOM_PATH = "eoafile"; + /** + * 文件外链接有效天数 + */ + public static final Integer UPLOAD_EFFECTIVE_DAYS = 1; + + /** + * 员工身份 (1:普通员工 2:上级) + */ + public static final Integer USER_IDENTITY_1 = 1; + public static final Integer USER_IDENTITY_2 = 2; + + /** sys_user 表 username 唯一键索引 */ + public static final String SQL_INDEX_UNIQ_SYS_USER_USERNAME = "uniq_sys_user_username"; + /** sys_user 表 work_no 唯一键索引 */ + public static final String SQL_INDEX_UNIQ_SYS_USER_WORK_NO = "uniq_sys_user_work_no"; + /** sys_user 表 phone 唯一键索引 */ + public static final String SQL_INDEX_UNIQ_SYS_USER_PHONE = "uniq_sys_user_phone"; + /** 达梦数据库升提示。违反表[SYS_USER]唯一性约束 */ + public static final String SQL_INDEX_UNIQ_SYS_USER = "唯一性约束"; + + /** sys_user 表 email 唯一键索引 */ + public static final String SQL_INDEX_UNIQ_SYS_USER_EMAIL = "uniq_sys_user_email"; + /** sys_quartz_job 表 job_class_name 唯一键索引 */ + public static final String SQL_INDEX_UNIQ_JOB_CLASS_NAME = "uniq_job_class_name"; + /** sys_position 表 code 唯一键索引 */ + public static final String SQL_INDEX_UNIQ_CODE = "uniq_code"; + /** sys_role 表 code 唯一键索引 */ + public static final String SQL_INDEX_UNIQ_SYS_ROLE_CODE = "uniq_sys_role_role_code"; + /** sys_depart 表 code 唯一键索引 */ + public static final String SQL_INDEX_UNIQ_DEPART_ORG_CODE = "uniq_depart_org_code"; + /** sys_category 表 code 唯一键索引 */ + public static final String SQL_INDEX_UNIQ_CATEGORY_CODE = "idx_sc_code"; + /** + * 在线聊天 是否为默认分组 + */ + public static final String IM_DEFAULT_GROUP = "1"; + /** + * 在线聊天 图片文件保存路径 + */ + public static final String IM_UPLOAD_CUSTOM_PATH = "imfile"; + /** + * 在线聊天 用户状态 + */ + public static final String IM_STATUS_ONLINE = "online"; + + /** + * 在线聊天 SOCKET消息类型 + */ + public static final String IM_SOCKET_TYPE = "chatMessage"; + + /** + * 在线聊天 是否开启默认添加好友 1是 0否 + */ + public static final String IM_DEFAULT_ADD_FRIEND = "1"; + + /** + * 在线聊天 用户好友缓存前缀 + */ + public static final String IM_PREFIX_USER_FRIEND_CACHE = "sys:cache:im:im_prefix_user_friend_"; + + /** + * 考勤补卡业务状态 (1:同意 2:不同意) + */ + public static final String SIGN_PATCH_BIZ_STATUS_1 = "1"; + public static final String SIGN_PATCH_BIZ_STATUS_2 = "2"; + + /** + * 公文文档上传自定义路径 + */ + public static final String UPLOAD_CUSTOM_PATH_OFFICIAL = "officialdoc"; + /** + * 公文文档下载自定义路径 + */ + public static final String DOWNLOAD_CUSTOM_PATH_OFFICIAL = "officaldown"; + + /** + * WPS存储值类别(1 code文号 2 text(WPS模板还是公文发文模板)) + */ + public static final String WPS_TYPE_1="1"; + public static final String WPS_TYPE_2="2"; + + + public final static String X_ACCESS_TOKEN = "X-Access-Token"; + public final static String X_SIGN = "X-Sign"; + public final static String X_TIMESTAMP = "X-TIMESTAMP"; + public final static String TOKEN_IS_INVALID_MSG = "Token失效,请重新登录!"; + + /** + * 多租户 请求头 + */ + public final static String TENANT_ID = "tenant-id"; + + /** + * 微服务读取配置文件属性 服务地址 + */ + public final static String CLOUD_SERVER_KEY = "spring.cloud.nacos.discovery.server-addr"; + + /** + * 第三方登录 验证密码/创建用户 都需要设置一个操作码 防止被恶意调用 + */ + public final static String THIRD_LOGIN_CODE = "third_login_code"; + + /** + * 第三方APP同步方向:本地 --> 第三方APP + */ + String THIRD_SYNC_TO_APP = "SYNC_TO_APP"; + /** + * 第三方APP同步方向:第三方APP --> 本地 + */ + String THIRD_SYNC_TO_LOCAL = "SYNC_TO_LOCAL"; + + /** 系统通告消息状态:0=未发布 */ + String ANNOUNCEMENT_SEND_STATUS_0 = "0"; + /** 系统通告消息状态:1=已发布 */ + String ANNOUNCEMENT_SEND_STATUS_1 = "1"; + /** 系统通告消息状态:2=已撤销 */ + String ANNOUNCEMENT_SEND_STATUS_2 = "2"; + + /**ONLINE 报表权限用 从request中获取地址栏后的参数*/ + String ONL_REP_URL_PARAM_STR="onlRepUrlParamStr"; + + /**POST请求*/ + String HTTP_POST = "POST"; + + /**PUT请求*/ + String HTTP_PUT = "PUT"; + + /**PATCH请求*/ + String HTTP_PATCH = "PATCH"; + + /**未知的*/ + String UNKNOWN = "unknown"; + + /**字符串http*/ + String STR_HTTP = "http"; + + /**String 类型的空值*/ + String STRING_NULL = "null"; + + /**java.util.Date 包*/ + String JAVA_UTIL_DATE = "java.util.Date"; + + /**.do*/ + String SPOT_DO = ".do"; + + + /**前端vue版本标识*/ + String VERSION="X-Version"; + + /**前端vue版本*/ + String VERSION_VUE3="vue3"; +} diff --git a/iailab-framework/iailab-common/src/main/java/com/iailab/framework/common/constant/Constant.java b/iailab-framework/iailab-common/src/main/java/com/iailab/framework/common/constant/Constant.java new file mode 100644 index 0000000..dde94aa --- /dev/null +++ b/iailab-framework/iailab-common/src/main/java/com/iailab/framework/common/constant/Constant.java @@ -0,0 +1,146 @@ +/** + * Copyright (c) 2018 人人开源 All rights reserved. + * + * https://www.renren.io + * + * 版权所有,侵权必究! + */ + +package com.iailab.framework.common.constant; + +/** + * 常量 + * + * @author Mark sunlightcs@gmail.com + */ +public interface Constant { + /** + * 成功 + */ + int SUCCESS = 1; + /** + * 失败 + */ + int FAIL = 0; + /** + * 菜单根节点标识 + */ + Long MENU_ROOT = 0L; + /** + * 部门根节点标识 + */ + Long DEPT_ROOT = 0L; + /** + * 升序 + */ + String ASC = "asc"; + /** + * 降序 + */ + String DESC = "desc"; + /** + * 创建时间字段名 + */ + String CREATE_DATE = "create_date"; + + String CREATE_TIME = "create_time"; + + /** + * 数据权限过滤 + */ + String SQL_FILTER = "sqlFilter"; + /** + * 当前页码 + */ + String PAGE = "page"; + /** + * 每页显示记录数 + */ + String LIMIT = "limit"; + /** + * 排序字段 + */ + String ORDER_FIELD = "orderField"; + /** + * 排序方式 + */ + String ORDER = "order"; + /** + * token header + */ + String TOKEN_HEADER = "token"; + + /** + * 云存储配置KEY + */ + String CLOUD_STORAGE_CONFIG_KEY = "CLOUD_STORAGE_CONFIG_KEY"; + + Integer DEL_FLAG_0 = 0; + + enum EnableStatus { + DISABLED(0), + NORMAL(1); + + private int value; + + private EnableStatus(int value) { + this.value = value; + } + + public int getValue() { + return this.value; + } + } + + /** + * 定时任务状态 + */ + enum ScheduleStatus { + /** + * 暂停 + */ + PAUSE(0), + /** + * 正常 + */ + NORMAL(1); + + private int value; + + ScheduleStatus(int value) { + this.value = value; + } + + public int getValue() { + return value; + } + } + + /** + * 云服务商 + */ + enum CloudService { + /** + * 七牛云 + */ + QINIU(1), + /** + * 阿里云 + */ + ALIYUN(2), + /** + * 腾讯云 + */ + QCLOUD(3); + + private int value; + + CloudService(int value) { + this.value = value; + } + + public int getValue() { + return value; + } + } +} \ No newline at end of file diff --git a/iailab-framework/iailab-common/src/main/java/com/iailab/framework/common/constant/GlobalConstants.java b/iailab-framework/iailab-common/src/main/java/com/iailab/framework/common/constant/GlobalConstants.java new file mode 100644 index 0000000..52bdc03 --- /dev/null +++ b/iailab-framework/iailab-common/src/main/java/com/iailab/framework/common/constant/GlobalConstants.java @@ -0,0 +1,29 @@ +package com.iailab.framework.common.constant; + +/** +* @Description: GlobalConstants +* @author: scott +* @date: 2020/01/01 16:01 +*/ +public class GlobalConstants { + + /** + * 业务处理器beanName传递参数 + */ + public static final String HANDLER_NAME = "handlerName"; + + /** + * 路由刷新触发器 + */ + public static final String LODER_ROUDER_HANDLER = "loderRouderHandler"; + + /** + * API刷新触发器 + */ + public static final String LODER_API_HANDLER = "loderApiHandler"; + + /** + * redis消息通道名称 + */ + public static final String REDIS_TOPIC_NAME="redis_topic"; +} diff --git a/iailab-framework/iailab-common/src/main/java/com/iailab/framework/common/enums/ErrorCode.java b/iailab-framework/iailab-common/src/main/java/com/iailab/framework/common/enums/ErrorCode.java new file mode 100644 index 0000000..6228b18 --- /dev/null +++ b/iailab-framework/iailab-common/src/main/java/com/iailab/framework/common/enums/ErrorCode.java @@ -0,0 +1,46 @@ +/** + * Copyright (c) 2018 人人开源 All rights reserved. + * + * https://www.renren.io + * + * 版权所有,侵权必究! + */ + +package com.iailab.framework.common.enums; + +/** + * 错误编码,由5位数字组成,前2位为模块编码,后3位为业务编码 + * <p> + * 如:10001(10代表系统模块,001代表业务代码) + * </p> + * + * @author Mark sunlightcs@gmail.com + * @since 1.0.0 + */ +public interface ErrorCode { + int INTERNAL_SERVER_ERROR = 500; + int UNAUTHORIZED = 401; + + int NOT_NULL = 10001; + int DB_RECORD_EXISTS = 10002; + int PARAMS_GET_ERROR = 10003; + int ACCOUNT_PASSWORD_ERROR = 10004; + int ACCOUNT_DISABLE = 10005; + int IDENTIFIER_NOT_NULL = 10006; + int CAPTCHA_ERROR = 10007; + int SUB_MENU_EXIST = 10008; + int PASSWORD_ERROR = 10009; + int SUPERIOR_DEPT_ERROR = 10011; + int SUPERIOR_MENU_ERROR = 10012; + int DATA_SCOPE_PARAMS_ERROR = 10013; + int DEPT_SUB_DELETE_ERROR = 10014; + int DEPT_USER_DELETE_ERROR = 10015; + int UPLOAD_FILE_EMPTY = 10019; + int TOKEN_NOT_EMPTY = 10020; + int TOKEN_INVALID = 10021; + int ACCOUNT_LOCK = 10022; + int OSS_UPLOAD_FILE_ERROR = 10024; + int REDIS_ERROR = 10027; + int JOB_ERROR = 10028; + int INVALID_SYMBOL = 10029; +} diff --git a/iailab-framework/iailab-common/src/main/java/com/iailab/framework/common/exception/ExceptionUtils.java b/iailab-framework/iailab-common/src/main/java/com/iailab/framework/common/exception/ExceptionUtils.java new file mode 100644 index 0000000..b4bd8e0 --- /dev/null +++ b/iailab-framework/iailab-common/src/main/java/com/iailab/framework/common/exception/ExceptionUtils.java @@ -0,0 +1,53 @@ +/** + * Copyright (c) 2018 人人开源 All rights reserved. + * + * https://www.renren.io + * + * 版权所有,侵权必究! + */ + +package com.iailab.framework.common.exception; + +import java.io.IOException; +import java.io.PrintWriter; +import java.io.StringWriter; + +/** + * Exception工具类 + * + * @author Mark sunlightcs@gmail.com + */ +public class ExceptionUtils { + + /** + * 获取异常信息 + * @param ex 异常 + * @return 返回异常信息 + */ + public static String getErrorStackTrace(Exception ex){ + StringWriter sw = null; + PrintWriter pw = null; + try { + sw = new StringWriter(); + pw = new PrintWriter(sw, true); + ex.printStackTrace(pw); + }finally { + try { + if(pw != null) { + pw.close(); + } + } catch (Exception e) { + + } + try { + if(sw != null) { + sw.close(); + } + } catch (IOException e) { + + } + } + + return sw.toString(); + } +} \ No newline at end of file diff --git a/iailab-framework/iailab-common/src/main/java/com/iailab/framework/common/util/object/ConvertUtils.java b/iailab-framework/iailab-common/src/main/java/com/iailab/framework/common/util/object/ConvertUtils.java new file mode 100644 index 0000000..4faad98 --- /dev/null +++ b/iailab-framework/iailab-common/src/main/java/com/iailab/framework/common/util/object/ConvertUtils.java @@ -0,0 +1,79 @@ +/** + * Copyright (c) 2018 人人开源 All rights reserved. + * + * https://www.renren.io + * + * 版权所有,侵权必究! + */ + +package com.iailab.framework.common.util.object; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.BeanUtils; + +import java.lang.reflect.Field; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.List; + +/** + * 转换工具类 + * + * @author Mark sunlightcs@gmail.com + */ +public class ConvertUtils { + private static Logger logger = LoggerFactory.getLogger(ConvertUtils.class); + + public static <T> T sourceToTarget(Object source, Class<T> target){ + if(source == null){ + return null; + } + T targetObject = null; + try { + targetObject = target.newInstance(); + BeanUtils.copyProperties(source, targetObject); + } catch (Exception e) { + logger.error("convert error ", e); + } + + return targetObject; + } + + public static <T> List<T> sourceToTarget(Collection<?> sourceList, Class<T> target){ + if(sourceList == null){ + return null; + } + + List targetList = new ArrayList<>(sourceList.size()); + try { + for(Object source : sourceList){ + T targetObject = target.newInstance(); + BeanUtils.copyProperties(source, targetObject); + targetList.add(targetObject); + } + }catch (Exception e){ + logger.error("convert error ", e); + } + + return targetList; + } + /** + * 获取类的所有属性,包括父类 + * + * @param object + * @return + */ + public static Field[] getAllFields(Object object) { + Class<?> clazz = object.getClass(); + List<Field> fieldList = new ArrayList<>(); + while (clazz != null) { + fieldList.addAll(new ArrayList<>(Arrays.asList(clazz.getDeclaredFields()))); + clazz = clazz.getSuperclass(); + } + Field[] fields = new Field[fieldList.size()]; + fieldList.toArray(fields); + return fields; + } +} \ No newline at end of file diff --git a/iailab-framework/iailab-common/src/main/java/com/iailab/framework/common/util/spring/SpringContextUtils.java b/iailab-framework/iailab-common/src/main/java/com/iailab/framework/common/util/spring/SpringContextUtils.java new file mode 100644 index 0000000..1cc4391 --- /dev/null +++ b/iailab-framework/iailab-common/src/main/java/com/iailab/framework/common/util/spring/SpringContextUtils.java @@ -0,0 +1,55 @@ +/** + * Copyright (c) 2018 人人开源 All rights reserved. + * + * https://www.renren.io + * + * 版权所有,侵权必究! + */ + +package com.iailab.framework.common.util.spring; + +import org.springframework.beans.BeansException; +import org.springframework.context.ApplicationContext; +import org.springframework.context.ApplicationContextAware; +import org.springframework.stereotype.Component; + +/** + * Spring Context 工具类 + * + * @author Mark sunlightcs@gmail.com + */ +@Component +public class SpringContextUtils implements ApplicationContextAware { + public static ApplicationContext applicationContext; + + @Override + public void setApplicationContext(ApplicationContext applicationContext) + throws BeansException { + SpringContextUtils.applicationContext = applicationContext; + } + + public static Object getBean(String name) { + return applicationContext.getBean(name); + } + + public static <T> T getBean(Class<T> requiredType) { + return applicationContext.getBean(requiredType); + } + + public static <T> T getBean(String name, Class<T> requiredType) { + return applicationContext.getBean(name, requiredType); + } + + public static boolean containsBean(String name) { + return applicationContext.containsBean(name); + } + + public static boolean isSingleton(String name) { + return applicationContext.isSingleton(name); + } + + public static Class<? extends Object> getType(String name) { + return applicationContext.getType(name); + } + +} \ No newline at end of file diff --git a/iailab-framework/iailab-common/src/main/java/com/iailab/framework/common/validation/group/AddGroup.java b/iailab-framework/iailab-common/src/main/java/com/iailab/framework/common/validation/group/AddGroup.java new file mode 100644 index 0000000..a453fff --- /dev/null +++ b/iailab-framework/iailab-common/src/main/java/com/iailab/framework/common/validation/group/AddGroup.java @@ -0,0 +1,19 @@ +/** + * Copyright (c) 2018 人人开源 All rights reserved. + * + * https://www.renren.io + * + * 版权所有,侵权必究! + */ + +package com.iailab.framework.common.validation.group; + +/** + * 新增 Group + * + * @author Mark sunlightcs@gmail.com + * @since 1.0.0 + */ +public interface AddGroup { + +} diff --git a/iailab-framework/iailab-common/src/main/java/com/iailab/framework/common/validation/group/DefaultGroup.java b/iailab-framework/iailab-common/src/main/java/com/iailab/framework/common/validation/group/DefaultGroup.java new file mode 100644 index 0000000..895e477 --- /dev/null +++ b/iailab-framework/iailab-common/src/main/java/com/iailab/framework/common/validation/group/DefaultGroup.java @@ -0,0 +1,19 @@ +/** + * Copyright (c) 2018 人人开源 All rights reserved. + * + * https://www.renren.io + * + * 版权所有,侵权必究! + */ + +package com.iailab.framework.common.validation.group; + +/** + * 默认 Group + * + * @author Mark sunlightcs@gmail.com + * @since 1.0.0 + */ +public interface DefaultGroup { + +} diff --git a/iailab-framework/iailab-common/src/main/java/com/iailab/framework/common/validation/group/Group.java b/iailab-framework/iailab-common/src/main/java/com/iailab/framework/common/validation/group/Group.java new file mode 100644 index 0000000..ac31f90 --- /dev/null +++ b/iailab-framework/iailab-common/src/main/java/com/iailab/framework/common/validation/group/Group.java @@ -0,0 +1,22 @@ +/** + * Copyright (c) 2018 人人开源 All rights reserved. + * + * https://www.renren.io + * + * 版权所有,侵权必究! + */ + +package com.iailab.framework.common.validation.group; + +import javax.validation.GroupSequence; + +/** + * 定义校验顺序,如果AddGroup组失败,则UpdateGroup组不会再校验 + * + * @author Mark sunlightcs@gmail.com + * @since 1.0.0 + */ +@GroupSequence({AddGroup.class, UpdateGroup.class}) +public interface Group { + +} diff --git a/iailab-framework/iailab-common/src/main/java/com/iailab/framework/common/validation/group/UpdateGroup.java b/iailab-framework/iailab-common/src/main/java/com/iailab/framework/common/validation/group/UpdateGroup.java new file mode 100644 index 0000000..2ab7e74 --- /dev/null +++ b/iailab-framework/iailab-common/src/main/java/com/iailab/framework/common/validation/group/UpdateGroup.java @@ -0,0 +1,19 @@ +/** + * Copyright (c) 2018 人人开源 All rights reserved. + * + * https://www.renren.io + * + * 版权所有,侵权必究! + */ + +package com.iailab.framework.common.validation.group; + +/** + * 修改 Group + * + * @author Mark sunlightcs@gmail.com + * @since 1.0.0 + */ +public interface UpdateGroup { + +} diff --git a/iailab-module-data/iailab-module-data-api/src/main/java/com/iailab/module/data/api/IFeignDataApi.java b/iailab-module-data/iailab-module-data-api/src/main/java/com/iailab/module/data/api/IFeignDataApi.java new file mode 100644 index 0000000..b109cf3 --- /dev/null +++ b/iailab-module-data/iailab-module-data-api/src/main/java/com/iailab/module/data/api/IFeignDataApi.java @@ -0,0 +1,63 @@ +package com.iailab.module.data.api; + +import com.iailab.module.data.dto.*; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.web.bind.annotation.*; + +import java.util.List; +import java.util.Map; + +/** + * @author DongYukun + * @Description + * @createTime 2024年03月01日 18:37:00 + */ +@FeignClient(value = "iailab-ntt-data", path = "/") +public interface IFeignDataApi { + @Parameter(name = "map", description = "查询InfluxDB", required = true) + @Operation(summary = "Feign接口-查询PointValue") + @PostMapping("/api/feign/influx-point-value") + List<ApiDataDTO> queryPointValues(@RequestBody FeignQueryPointDTO dto); + + @Parameter(name = "map", description = "查询InfluxDB", required = true) + @Operation(summary = "Feign接口-查询PointValue") + @PostMapping("/api/feign/sim-tag-value") + List<ApiDataDTO> querySimTagValues(@RequestBody FeignQueryPointDTO dto); + + @Parameter(name = "map", description = "查询InfluxDB", required = true) + @Operation(summary = "Feign接口-查询PointValue") + @PostMapping("/api/feign/currentValue") + Map<String, Object> getCurrentValue(@RequestParam("pointNos") List<String> pointNos); + + @Parameter(name = "map", description = "查询point", required = true) + @Operation(summary = "Feign接口-查询point") + @PostMapping("/api/feign/point/{pointNo}") + ApiDataPointDTO getPoint(@PathVariable("pointNo") String pointNo); + + @Parameter(name = "map", description = "查询HttpApi", required = true) + @Operation(summary = "Feign接口-查询HttpApi") + @GetMapping("/api/feign/http-api/{code}") + FeignHttpApiDTO getHttpApi(@PathVariable("code") String code); + + @Parameter(name = "map", description = "查询指标数据", required = true) + @Operation(summary = "Feign接口-查询指标数据") + @PostMapping("/api/feign/ind-item-values") + List<ApiDataDTO> queryIndItemValues(@RequestBody FeignQueryPointDTO dto); + + @Parameter(name = "map", description = "查询指标数据", required = true) + @Operation(summary = "Feign接口-查询指标数据") + @PostMapping("/api/feign/ind-item-values-range") + List<ApiIndValueDTO> queryIndItemValuesRange(@RequestBody FeignQueryPointDTO dto); + + @Parameter(name = "map", description = "设置测点值", required = true) + @Operation(summary = "Feign接口-设置测点值") + @PostMapping("/api/feign/set-point-value") + FeignResultDTO setPointValue(@RequestBody FeignWritePointValueDTO writePointValue); + + @Parameter(name = "map", description = "查询指标数据", required = true) + @Operation(summary = "Feign接口-查询指标数据") + @PostMapping("/api/feign/get-inditem-values") + List<ApiIndValueDTO> getIndItemValues(@RequestBody FeignQueryPointDTO dto); +} diff --git a/iailab-module-data/iailab-module-data-api/src/main/java/com/iailab/module/data/dto/AlarmTaskDto.java b/iailab-module-data/iailab-module-data-api/src/main/java/com/iailab/module/data/dto/AlarmTaskDto.java new file mode 100644 index 0000000..305eb15 --- /dev/null +++ b/iailab-module-data/iailab-module-data-api/src/main/java/com/iailab/module/data/dto/AlarmTaskDto.java @@ -0,0 +1,58 @@ +package com.iailab.module.data.dto; + +import lombok.Data; + +import java.util.Date; + +/** + * @author Lujiaxin + * @Description + * @createTime 2023年03月09日 10:05:00 + */ + +@Data +public class AlarmTaskDto { + + private String id; + + /** + * 设备编号 + */ + private String equipmentNumber; + + /** + * 设备名称 + */ + private String equipmentName; + + /** + * 报警场所 + */ + private String alarmPlace; + + /** + * 报警内容 + */ + private String alarmContent; + + /** + * 报警时间 + */ + private Date alarmTime; + + /** + * 推送对象 + */ + private String acceptBy; + + /** + * 工单创建方式(自动:auto 手动:manual) + */ + private String orderCreateType; + + /** + * 工单创建状态(未创建:0 已创建:1) + */ + private String orderCreateStatus; + +} diff --git a/iailab-module-data/iailab-module-data-api/src/main/java/com/iailab/module/data/dto/ApiDataDTO.java b/iailab-module-data/iailab-module-data-api/src/main/java/com/iailab/module/data/dto/ApiDataDTO.java new file mode 100644 index 0000000..fdcd93c --- /dev/null +++ b/iailab-module-data/iailab-module-data-api/src/main/java/com/iailab/module/data/dto/ApiDataDTO.java @@ -0,0 +1,18 @@ +package com.iailab.module.data.dto; + +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; + +@Data +public class ApiDataDTO implements Serializable { + private static final long serialVersionUID = 1L; + + private Date timeStamp; + + private String dataTime; + + private double dataValue; + +} diff --git a/iailab-module-data/iailab-module-data-api/src/main/java/com/iailab/module/data/dto/ApiDataPointDTO.java b/iailab-module-data/iailab-module-data-api/src/main/java/com/iailab/module/data/dto/ApiDataPointDTO.java new file mode 100644 index 0000000..4e075e7 --- /dev/null +++ b/iailab-module-data/iailab-module-data-api/src/main/java/com/iailab/module/data/dto/ApiDataPointDTO.java @@ -0,0 +1,26 @@ +package com.iailab.module.data.dto; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.io.Serializable; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年05月21日 + */ +@Data +@Schema(description = "测点") +public class ApiDataPointDTO implements Serializable { + private static final long serialVersionUID = 1L; + + @Schema(description = "测点编码", required = true) + private String pointNo; + + @Schema(description = "测点名称", required = true) + private String pointName; + + @Schema(description = "采集频率", required = true) + private String minfreqid; +} \ No newline at end of file diff --git a/iailab-module-data/iailab-module-data-api/src/main/java/com/iailab/module/data/dto/ApiIndValueDTO.java b/iailab-module-data/iailab-module-data-api/src/main/java/com/iailab/module/data/dto/ApiIndValueDTO.java new file mode 100644 index 0000000..f5ca841 --- /dev/null +++ b/iailab-module-data/iailab-module-data-api/src/main/java/com/iailab/module/data/dto/ApiIndValueDTO.java @@ -0,0 +1,23 @@ +package com.iailab.module.data.dto; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.io.Serializable; +import java.math.BigDecimal; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年06月17日 + */ +@Data +public class ApiIndValueDTO implements Serializable { + private static final long serialVersionUID = 1L; + + @Schema(description = "数据时间") + private String dataTime; + + @Schema(description = "数据值") + private BigDecimal dataValue; +} \ No newline at end of file diff --git a/iailab-module-data/iailab-module-data-api/src/main/java/com/iailab/module/data/dto/ApiPointValueQueryDTO.java b/iailab-module-data/iailab-module-data-api/src/main/java/com/iailab/module/data/dto/ApiPointValueQueryDTO.java new file mode 100644 index 0000000..afa9d29 --- /dev/null +++ b/iailab-module-data/iailab-module-data-api/src/main/java/com/iailab/module/data/dto/ApiPointValueQueryDTO.java @@ -0,0 +1,32 @@ +package com.iailab.module.data.dto; + +import com.fasterxml.jackson.annotation.JsonFormat; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import javax.validation.constraints.NotNull; +import java.util.Date; +import java.util.List; + +/** + * @author PanZhibao + * @Description + * @createTime 2023年05月05日 16:08:00 + */ +@Data +@Schema(name = "测点值查询") +public class ApiPointValueQueryDTO { + @Schema(name = "pointNos") + @NotNull(message="pointNos不能为空") + private List<String> pointNos; + + @Schema(name = "开始时间") + @NotNull(message="start不能为空") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + private Date start; + + @Schema(name = "结束时间") + @NotNull(message="end不能为空") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + private Date end; +} diff --git a/iailab-module-data/iailab-module-data-api/src/main/java/com/iailab/module/data/dto/FeignFileQueryDto.java b/iailab-module-data/iailab-module-data-api/src/main/java/com/iailab/module/data/dto/FeignFileQueryDto.java new file mode 100644 index 0000000..5298253 --- /dev/null +++ b/iailab-module-data/iailab-module-data-api/src/main/java/com/iailab/module/data/dto/FeignFileQueryDto.java @@ -0,0 +1,19 @@ +package com.iailab.module.data.dto; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * @author PanZhibao + * @Description + * @createTime 2023年08月21日 13:50:00 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@Schema(name = "文件") +public class FeignFileQueryDto { + private String businessId; + + private String type; +} diff --git a/iailab-module-data/iailab-module-data-api/src/main/java/com/iailab/module/data/dto/FeignFileSaveDto.java b/iailab-module-data/iailab-module-data-api/src/main/java/com/iailab/module/data/dto/FeignFileSaveDto.java new file mode 100644 index 0000000..41d2cfa --- /dev/null +++ b/iailab-module-data/iailab-module-data-api/src/main/java/com/iailab/module/data/dto/FeignFileSaveDto.java @@ -0,0 +1,24 @@ +package com.iailab.module.data.dto; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.util.List; + +/** + * @author PanZhibao + * @Description + * @createTime 2023年08月16日 13:26:00 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@Schema(name = "文件") +public class FeignFileSaveDto { + + private String businessId; + + private String type; + + private List<FileDto> fileList; +} diff --git a/iailab-module-data/iailab-module-data-api/src/main/java/com/iailab/module/data/dto/FeignFixDetDTO.java b/iailab-module-data/iailab-module-data-api/src/main/java/com/iailab/module/data/dto/FeignFixDetDTO.java new file mode 100644 index 0000000..abb59f7 --- /dev/null +++ b/iailab-module-data/iailab-module-data-api/src/main/java/com/iailab/module/data/dto/FeignFixDetDTO.java @@ -0,0 +1,9 @@ +package com.iailab.module.data.dto; + +/** + * @author PanZhibao + * @Description + * @createTime 2023年12月09日 09:49:00 + */ +public class FeignFixDetDTO { +} diff --git a/iailab-module-data/iailab-module-data-api/src/main/java/com/iailab/module/data/dto/FeignHttpApiDTO.java b/iailab-module-data/iailab-module-data-api/src/main/java/com/iailab/module/data/dto/FeignHttpApiDTO.java new file mode 100644 index 0000000..d90de7a --- /dev/null +++ b/iailab-module-data/iailab-module-data-api/src/main/java/com/iailab/module/data/dto/FeignHttpApiDTO.java @@ -0,0 +1,32 @@ +package com.iailab.module.data.dto; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.io.Serializable; +import java.util.Date; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年05月26日 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@Schema(description = "http接口") +public class FeignHttpApiDTO implements Serializable { + private static final long serialVersionUID = 1L; + + private String id; + private String name; + private String code; + private String url; + private String method; + private String collectType; + private String param; + private String descp; + private Integer status; + private Date createTime; + private Date updateTime; +} \ No newline at end of file diff --git a/iailab-module-data/iailab-module-data-api/src/main/java/com/iailab/module/data/dto/FeignOrderTaskDTO.java b/iailab-module-data/iailab-module-data-api/src/main/java/com/iailab/module/data/dto/FeignOrderTaskDTO.java new file mode 100644 index 0000000..27dbde4 --- /dev/null +++ b/iailab-module-data/iailab-module-data-api/src/main/java/com/iailab/module/data/dto/FeignOrderTaskDTO.java @@ -0,0 +1,140 @@ +package com.iailab.module.data.dto; + +import com.fasterxml.jackson.annotation.JsonFormat; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.util.Date; +import java.util.List; + +/** + * @author Lujiaxin + * @Description + * @createTime 2023年03月09日 10:05:00 + */ + +@Data +public class FeignOrderTaskDTO { + + @Schema(name = "工单编号") + private String orderNumber; + + @Schema(name = "工单类型") + private String orderType; + + @Schema(name = "工单类型名") + private String orderTypeName; + + @Schema(name = "工单来源") + private String orderSource; + + @Schema(name = "优先级") + private Integer priority; + + @Schema(name = "优先级") + private String priorityName; + + @Schema(name = "标题") + private String title; + + @Schema(name = "内容") + private String content; + + @Schema(name = "工单状态") + private String status; + + @Schema(name = "工单状态名称") + private String statusName; + + @Schema(name = "完成期限") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm", timezone = "GMT+8") + private Date deadline; + + @Schema(name = "发布人") + private String publisher; + + @Schema(name = "发布人姓名") + private String publisherName; + + @Schema(name = "发布人部门") + private String publisherDept; + + @Schema(name = "发布时间") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm", timezone = "GMT+8") + private Date publishTime; + + @Schema(name = "审核人") + private String reviewer; + + @Schema(name = "审核人姓名") + private String reviewerName; + + @Schema(name = "审核时间") + private Date reviewTime; + + @Schema(name = "审核结果") + private String reviewResult; + + @Schema(name = "办理人") + private String assigner; + + @Schema(name = "办理人姓名") + private String assignerName; + + @Schema(name = "办理人部门") + private String assignerDept; + + @Schema(name = "指派时间") + private Date assignTime; + + @Schema(name = "开始处理时间") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm", timezone = "GMT+8") + private Date processStartTime; + + @Schema(name = "处理完成时间") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + private Date processCompletedTime; + + @Schema(name = "已耗时(毫秒)") + private Long timeConsuming; + + @Schema(name = "已耗时(HH小时mm分钟)") + private String consuming; + + @Schema(name = "是否超时") + private Integer isTimeout; + + @Schema(name = "是否超时") + private String isTimeoutName; + + @Schema(name = "超时时长(毫秒)") + private Long timeoutLength; + + @Schema(name = "超时时长(HH小时mm分钟)") + private String timeoutHHmm; + + @Schema(name = "创建人") + private String createBy; + + @Schema(name = "创建人姓名") + private String createByName; + + @Schema(name = "抄送人") + private List<String> copyPerson; + + @Schema(name = "检修类型") + private String checkFixType; + + @Schema(name = "反馈内容") + private String backContent; + + @Schema(name = "创建时间") + private Date createDate; + + @Schema(name = "修改人") + private String updateBy; + + @Schema(name = "修改时间") + private Date updateDate; + +} diff --git a/iailab-module-data/iailab-module-data-api/src/main/java/com/iailab/module/data/dto/FeignQueryPointDTO.java b/iailab-module-data/iailab-module-data-api/src/main/java/com/iailab/module/data/dto/FeignQueryPointDTO.java new file mode 100644 index 0000000..7650785 --- /dev/null +++ b/iailab-module-data/iailab-module-data-api/src/main/java/com/iailab/module/data/dto/FeignQueryPointDTO.java @@ -0,0 +1,37 @@ +package com.iailab.module.data.dto; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.io.Serializable; +import java.util.Date; + +/** + * @author PanZhibao + * @Description + * @createTime 2023年06月28日 09:19:00 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@Schema(description = "运行时长") +public class FeignQueryPointDTO implements Serializable { + + @Schema(description = "测点编号") + private String pointCode; + + @Schema(description = "类型") + private String type; + + @Schema(description = "开始时间") + private Date startTime; + + @Schema(description = "结束时间") + private Date endTime; + + @Schema(description = "开始日期") + private String startDate; + + @Schema(description = "结束日期") + private String endDate; +} diff --git a/iailab-module-data/iailab-module-data-api/src/main/java/com/iailab/module/data/dto/FeignResultDTO.java b/iailab-module-data/iailab-module-data-api/src/main/java/com/iailab/module/data/dto/FeignResultDTO.java new file mode 100644 index 0000000..153dd5f --- /dev/null +++ b/iailab-module-data/iailab-module-data-api/src/main/java/com/iailab/module/data/dto/FeignResultDTO.java @@ -0,0 +1,22 @@ +package com.iailab.module.data.dto; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.io.Serializable; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年06月05日 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@Schema(description = "结果") +public class FeignResultDTO implements Serializable { + + private Integer code; + + private String msg; +} \ No newline at end of file diff --git a/iailab-module-data/iailab-module-data-api/src/main/java/com/iailab/module/data/dto/FeignWritePointValueDTO.java b/iailab-module-data/iailab-module-data-api/src/main/java/com/iailab/module/data/dto/FeignWritePointValueDTO.java new file mode 100644 index 0000000..b526828 --- /dev/null +++ b/iailab-module-data/iailab-module-data-api/src/main/java/com/iailab/module/data/dto/FeignWritePointValueDTO.java @@ -0,0 +1,24 @@ +package com.iailab.module.data.dto; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.io.Serializable; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年06月05日 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@Schema(description = "写入测点值") +public class FeignWritePointValueDTO implements Serializable { + + @Schema(description = "测点编号") + private String pointCode; + + @Schema(description = "测点值") + private Object pointValue; +} \ No newline at end of file diff --git a/iailab-module-data/iailab-module-data-api/src/main/java/com/iailab/module/data/dto/FileDto.java b/iailab-module-data/iailab-module-data-api/src/main/java/com/iailab/module/data/dto/FileDto.java new file mode 100644 index 0000000..4ed6b4d --- /dev/null +++ b/iailab-module-data/iailab-module-data-api/src/main/java/com/iailab/module/data/dto/FileDto.java @@ -0,0 +1,18 @@ +package com.iailab.module.data.dto; + +import lombok.Data; + +/** + * @author PanZhibao + * @Description + * @createTime 2023年03月05日 17:52:00 + */ +@Data +public class FileDto { + + private String uid; + + private String name; + + private String url; +} diff --git a/iailab-module-data/iailab-module-data-api/src/main/java/com/iailab/module/data/enums/ApiConstants.java b/iailab-module-data/iailab-module-data-api/src/main/java/com/iailab/module/data/enums/ApiConstants.java new file mode 100644 index 0000000..06382bf --- /dev/null +++ b/iailab-module-data/iailab-module-data-api/src/main/java/com/iailab/module/data/enums/ApiConstants.java @@ -0,0 +1,23 @@ +package com.iailab.module.data.enums; + +import com.iailab.framework.common.enums.RpcConstants; + +/** + * API 相关的枚举 + * + * @author iailab + */ +public class ApiConstants { + + /** + * 服务名 + * + * 注意,需要保证和 spring.application.name 保持一致 + */ + public static final String NAME = "data-server"; + + public static final String PREFIX = RpcConstants.RPC_API_PREFIX + "/data"; + + public static final String VERSION = "1.0.0"; + +} diff --git a/iailab-module-data/iailab-module-data-api/src/main/java/com/iailab/module/package-info.java b/iailab-module-data/iailab-module-data-api/src/main/java/com/iailab/module/package-info.java new file mode 100644 index 0000000..c343803 --- /dev/null +++ b/iailab-module-data/iailab-module-data-api/src/main/java/com/iailab/module/package-info.java @@ -0,0 +1 @@ +package com.iailab.module; \ No newline at end of file diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/DataWebApplication.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/DataWebApplication.java new file mode 100644 index 0000000..ec6152c --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/DataWebApplication.java @@ -0,0 +1,14 @@ +package com.iailab; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class DataWebApplication { + + + public static void main(String[] args) { + SpringApplication.run(DataWebApplication.class, args); + } + +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/api/controller/DataController.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/api/controller/DataController.java new file mode 100644 index 0000000..cd54c25 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/api/controller/DataController.java @@ -0,0 +1,282 @@ +package com.iailab.module.data.api.controller; + +import com.iailab.api.IFeignModelApi; +import com.iailab.framework.common.pojo.CommonResult; +import com.iailab.framework.common.util.date.DateUtils; +import com.iailab.module.data.common.dto.IndexQueryDTO; +import com.iailab.module.data.common.dto.echarts.BarLineDTO; +import com.iailab.module.data.common.dto.echarts.SeriesItem; +import com.iailab.module.data.common.utils.R; +import com.iailab.module.data.api.dto.ApiPointValueQueryDTO; +import com.iailab.module.data.point.collection.PointCollector; +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.point.service.DaPointValueService; +import com.iailab.module.data.ind.collection.IndItemCollector; +import com.iailab.module.data.influxdb.pojo.InfluxPointValuePOJO; +import com.iailab.module.data.influxdb.service.InfluxDBService; +import com.iailab.module.data.api.dto.DeviceValueDTO; +import com.iailab.module.data.api.utils.ApiSecurityUtils; +import com.iailab.module.data.ind.dto.IndItemValueDTO; +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.springframework.util.CollectionUtils; +import org.springframework.web.bind.annotation.*; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.math.BigDecimal; +import java.util.*; +import java.util.stream.Collectors; + +/** + * @author PanZhibao + * @Description + * @createTime 2023年05月02日 10:58:00 + */ +@Slf4j +@RestController +@RequestMapping("/api/data") +@Tag(name = "数据") +public class DataController { + + @Resource + private DaPointService daPointService; + + @Resource + private ApiSecurityUtils apiSecurityUtils; + + @Resource + private DaPointValueService daPointValueService; + + @Resource + private InfluxDBService influxDBService; + + @Resource + private PointCollector pointCollector; + + @Resource + private IndItemCollector indItemCollector; + + @Resource + private IFeignModelApi feignModelApi; + + @PostMapping("/point/history") + @Operation(summary = "point历史数据") + public R pointHistory(HttpServletResponse response, HttpServletRequest + request, @RequestBody ApiPointValueQueryDTO queryDto) { + try { + apiSecurityUtils.validate(request); + Map<String, List<Map<String, Object>>> data = new HashMap<>(); + if (CollectionUtils.isEmpty(queryDto.getPointNos())) { + return R.ok().put("data", data); + } + if (queryDto.getStart() == null) { + queryDto.setStart(new Date()); + } + if (queryDto.getEnd() == null) { + queryDto.setEnd(new Date()); + } + Map<String, Object> params = new HashMap<>(1); + params.put("pointNos", queryDto.getPointNos()); + List<DaPointDTO> pointList = daPointService.list(params); + if (CollectionUtils.isEmpty(pointList)) { + return R.ok().put("data", data); + } + List<InfluxPointValuePOJO> influxParams = pointList.stream().map(item -> { + InfluxPointValuePOJO pojo = new InfluxPointValuePOJO(); + pojo.setPoint(item.getPointNo()); + pojo.setType(item.getDataType()); + return pojo; + }).collect(Collectors.toList()); + data = influxDBService.queryPointsValues(influxParams, queryDto.getStart(), queryDto.getEnd()); + return R.ok().put("data", data); + + } catch (Exception ex) { + return R.error(ex.getMessage()); + } + } + + @PostMapping("/point/current") + @Operation(summary = "point当前实时数据") + public R pointCurrent(HttpServletResponse response, HttpServletRequest + request, @RequestBody List<String> pointNos) { + try { + // apiSecurityUtils.validate(request); + Map<String, Object> data = pointCollector.getCurrentValue(pointNos); + return R.ok().put("data", data); + } catch (Exception ex) { + return R.error(ex.getMessage()); + } + } + + @PostMapping("/point/chart") + public CommonResult<BarLineDTO> pointChart(@RequestBody IndexQueryDTO dto) { + BarLineDTO CommonResult = new BarLineDTO(); + try { + List<String> legend = new ArrayList<>(); + List<SeriesItem> series = new ArrayList<>(); + String endDateStr = dto.getEndDate() == null ? DateUtils.format(new Date(), "yyyy-MM-dd HH:mm:ss") : DateUtils.format(dto.getEndDate(), "yyyy-MM-dd HH:mm:ss"); + Date endDate = DateUtils.parse(endDateStr, "yyyy-MM-dd HH:mm"); + Date startDate = dto.getStartDate() == null ? DateUtils.addDateHours(endDate, -2) : dto.getStartDate(); + List<String> categories = DateUtils.getTimeScale(startDate, endDate, dto.getGranularity() == null ? 10 : dto.getGranularity()); + if (CollectionUtils.isEmpty(dto.getCodes())) { + return new CommonResult<BarLineDTO>().setData(CommonResult); + } + List<DaPointDTO> pointList = new ArrayList<>(); + dto.getCodes().forEach(item -> { + pointList.add(daPointService.getByNo(item)); + }); + pointList.forEach(item -> { + legend.add(item.getPointName()); + SeriesItem seriesItem = new SeriesItem(); + seriesItem.setName(item.getPointName()); + InfluxPointValuePOJO pojo = new InfluxPointValuePOJO(); + pojo.setPoint(item.getPointNo()); + pojo.setType(item.getDataType()); + List<Map<String, Object>> list = influxDBService.queryPointValues(pojo, startDate, endDate); + List<Object[]> sData = list.stream().map(dataItem -> { + Object[] valueArray = new Object[]{dataItem.get("time"), + getFormatValue(item.getDataType(), dataItem.get("value"))}; + 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); + } + + private Object getFormatValue(String dataType, Object value) { + if (!PointDataTypeEnum.BOOLEAN.getCode().equals(dataType)) { + BigDecimal decValue = new BigDecimal(value.toString()); + if (PointDataTypeEnum.FLOAT.getCode().equals(dataType)) { + return decValue.setScale(2, BigDecimal.ROUND_HALF_UP); + } else if (PointDataTypeEnum.INT.getCode().equals(dataType)) { + decValue = decValue.setScale(0, BigDecimal.ROUND_HALF_UP); + } + } + return value; + } + + + @PostMapping("/pointRelation/history") + @Operation(summary = "pointRelation历史数据") + public R pointRelationHistory(HttpServletResponse response, HttpServletRequest + request, @RequestBody ApiPointValueQueryDTO queryDto) { + try { + Map<String, List<Map<String, Object>>> data = new HashMap<>(); + if (CollectionUtils.isEmpty(queryDto.getPointNos())) { + return R.ok().put("data", data); + } + if (queryDto.getStart() == null) { + queryDto.setStart(new Date()); + } + if (queryDto.getEnd() == null) { + queryDto.setEnd(new Date()); + } + data = daPointValueService.getHistoryList(queryDto); + if (CollectionUtils.isEmpty(data)) { + return R.ok().put("data", data); + } + return R.ok().put("data", data); + } catch (Exception ex) { + return R.error(ex.getMessage()); + } + } + + @GetMapping("/device-value") + public List<DeviceValueDTO> getDeviceValue(@RequestParam Map<String, Object> params) { + List<DeviceValueDTO> CommonResult = new ArrayList<>(); + if (params.get("pointNos") == null) { + return CommonResult; + } + List<String> pointNos = Arrays.asList(params.get("pointNos").toString().split(",")); + Map<String, Object> data = pointCollector.getCurrentValue(pointNos); + if (!CollectionUtils.isEmpty(data)) { + data.forEach((k, v) -> { + DeviceValueDTO dto = new DeviceValueDTO(); + dto.setDataId(k); + dto.setValue(new BigDecimal(v.toString())); + CommonResult.add(dto); + }); + } + return CommonResult; + } + + @PostMapping("/ind-item/values") + @Operation(summary = "point当前实时数据") + public R indItemValues(HttpServletResponse response, HttpServletRequest + request, @RequestBody List<String> itemNos) { + try { + // apiSecurityUtils.validate(request); + Map<String, List<IndItemValueDTO>> data = indItemCollector.getValueList(itemNos); + return R.ok().put("data", data); + } catch (Exception ex) { + return R.error(ex.getMessage()); + } + } + + @PostMapping("/ind-item/current-value") + @Operation(summary = "point当前实时数据") + public R indItemCurrentValue(HttpServletResponse response, HttpServletRequest + request, @RequestBody List<String> itemNos) { + try { + Map<String, BigDecimal> data = new HashMap<>(); + // apiSecurityUtils.validate(request); + Map<String, List<IndItemValueDTO>> dataList = indItemCollector.getValueList(itemNos); + dataList.forEach((k, v) -> { + data.put(k, CollectionUtils.isEmpty(v) ? null : v.get(0).getDataValue()); + }); + return R.ok().put("data", data); + } catch (Exception ex) { + return R.error(ex.getMessage()); + } + } + + @PostMapping("/ind-item/values-trend") + @Operation(summary = "point当前实时数据") + public R indItemValuesTrend(HttpServletResponse response, HttpServletRequest + request, @RequestBody List<String> itemNos) { + try { + apiSecurityUtils.validate(request); + Map<String, Object> CommonResult = new HashMap<>(); + Map<String, List<IndItemValueDTO>> values = indItemCollector.getValueList(itemNos); + CommonResult.put("values", values); + + Map<String, Map<String, Object>> trend = new HashMap<>(); + Map<String, Object> params = new HashMap<>(1); + params.put("modelCode", "trend_analysis"); + values.forEach((k, v) -> { + try { + List<double[][]> sampleDataList = new ArrayList<>(); + List<IndItemValueDTO> nv = v.stream().filter(dto -> { + return dto.getDataValue() != null; + }).collect(Collectors.toList()); + double[][] mix = new double[nv.size()][1]; + for (int i = 0; i < nv.size(); i++) { + mix[i][0] = nv.get(i).getDataValue().doubleValue(); + } + sampleDataList.add(mix); + Map<String, Object> trendItem = feignModelApi.runModel(params, sampleDataList); + trend.put(k, trendItem); + } catch (Exception ex) { + ex.printStackTrace(); + } + }); + CommonResult.put("trend", trend); + return R.ok().put("data", CommonResult); + } catch (Exception ex) { + ex.printStackTrace(); + return R.error(ex.getMessage()); + } + } +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/api/controller/TokenController.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/api/controller/TokenController.java new file mode 100644 index 0000000..7bfee54 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/api/controller/TokenController.java @@ -0,0 +1,52 @@ +//package com.iailab.module.api.controller; +// +//import cn.hutool.jwt.JWTUtil; +//import com.iailab.common.utils.R; +//import com.iailab.module.gateway.entity.ApiAppEntity; +//import com.iailab.module.gateway.form.AppLoginForm; +//import com.iailab.module.gateway.service.ApiAppService; +//import io.swagger.v3.oas.annotations.tags.Tag; +//import javax.annotation.Resource; +//import org.springframework.web.bind.annotation.PostMapping; +//import org.springframework.web.bind.annotation.RequestBody; +//import org.springframework.web.bind.annotation.RequestMapping; +//import org.springframework.web.bind.annotation.RestController; +// +//import java.util.Date; +// +///** +// * @author PanZhibao +// * @Description +// * @createTime 2023年12月06日 15:42:00 +// */ +//@RestController +//@RequestMapping("/api/token") +//@Tag(name = "授权") +//public class TokenController { +// +// @Resource +// private ApiAppService apiAppService; +// +// @PostMapping("/authenticate") +// public R authenticate(@RequestBody AppLoginForm form) { +// String username = form.getAppKey(); +// String password = form.getAppSecret(); +// +// //1. 校验用户是否有效 +// ApiAppEntity apiAppEntity = apiAppService.getInfoByAppKey(username); +// if (apiAppEntity == null) { +// return R.error("无效的用户"); +// } +// +// //2. 校验用户名或密码是否正确 +// if (!apiAppEntity.getAppSecret().equals(password)) { +// return R.error("Secret错误"); +// } +// //3. 生成token +// String token = com.iailab.common.utils.JwtUtils.generateToken(username, password); +// Date now = new Date(); +// Date expireTime = new Date(now.getTime() + com.iailab.common.utils.JwtUtils.EXPIRE_TIME); +// R r = R.ok().put("token", token).put("expire", expireTime); +// return r; +// } +//} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/api/dto/ApiExportValueDTO.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/api/dto/ApiExportValueDTO.java new file mode 100644 index 0000000..c33beaa --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/api/dto/ApiExportValueDTO.java @@ -0,0 +1,24 @@ +package com.iailab.module.data.api.dto; + +import io.swagger.v3.oas.annotations.tags.Tag; +import lombok.Data; + +/** + * @author PanZhibao + * @Description + * @createTime 2023年08月28日 13:57:00 + */ +@Data +@Tag(name = "值导出") +public class ApiExportValueDTO { + + /** + * 值 + */ + private String dataValue; + + /** + * 时间 + */ + private String dataTime; +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/api/dto/ApiPointValueQueryDTO.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/api/dto/ApiPointValueQueryDTO.java new file mode 100644 index 0000000..d3878fd --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/api/dto/ApiPointValueQueryDTO.java @@ -0,0 +1,33 @@ +package com.iailab.module.data.api.dto; + +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.util.Date; +import java.util.List; + +/** + * @author PanZhibao + * @Description + * @createTime 2023年05月05日 16:08:00 + */ +@Data +@Tag(name = "测点值查询") +public class ApiPointValueQueryDTO { + @Schema(description = "pointNos") + @NotNull(message="pointNos不能为空") + private List<String> pointNos; + + @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; +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/api/dto/ApiTagValueQueryDTO.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/api/dto/ApiTagValueQueryDTO.java new file mode 100644 index 0000000..d085f93 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/api/dto/ApiTagValueQueryDTO.java @@ -0,0 +1,40 @@ +package com.iailab.module.data.api.dto; + +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.util.Date; +import java.util.List; + +/** + * @author PanZhibao + * @Description + * @createTime 2023年05月02日 12:24:00 + */ +@Data +@Tag(name = "实时值查询") +public class ApiTagValueQueryDTO { + + @Schema(description = "tags") + @NotNull(message="不能为空") + private List<String> tagIds; + + @Schema(description = "tagId") + private String tagId; + + @Schema(description = "dataType") + private String dataType; + + @Schema(description = "开始时间") + @NotNull(message="不能为空") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + private Date start; + + @Schema(description = "结束时间") + @NotNull(message="不能为空") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + private Date end; +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/api/dto/DeviceValueDTO.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/api/dto/DeviceValueDTO.java new file mode 100644 index 0000000..05e8ccc --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/api/dto/DeviceValueDTO.java @@ -0,0 +1,25 @@ +package com.iailab.module.data.api.dto; + +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.tags.Tag; +import lombok.Data; + +import java.io.Serializable; +import java.math.BigDecimal; + +/** + * @author PanZhibao + * @Description + * @createTime 2023年09月11日 08:50:00 + */ +@Data +@Tag(name = "设备值") +public class DeviceValueDTO implements Serializable { + private static final long serialVersionUID = 1L; + + @Schema(description = "设备ID") + private String dataId; + + @Schema(description = "值") + private BigDecimal value; +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/api/utils/ApiSecurityUtils.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/api/utils/ApiSecurityUtils.java new file mode 100644 index 0000000..72287f7 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/api/utils/ApiSecurityUtils.java @@ -0,0 +1,81 @@ +package com.iailab.module.data.api.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.module.data.gateway.entity.ApiAppEntity; +import com.iailab.module.data.gateway.service.ApiAppService; +import com.iailab.module.data.gateway.entity.ApiAppEntity; +import com.iailab.module.data.gateway.service.ApiAppService; +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; + +/** + * @author PanZhibao + * @Description + * @createTime 2023年12月06日 15:55:00 + */ +@Component +public class ApiSecurityUtils { + + @Resource + private ApiAppService apiAppService; + + @Resource + private AdminUserApi adminUserApi; + + private Pattern pattern = Pattern.compile("^[-\\+]?[\\d]*$"); + + private String getRequestToken(HttpServletRequest httpRequest) { + //从header中获取token + String token = httpRequest.getHeader(Constant.TOKEN_HEADER); + + //如果header中不存在token,则从参数中获取token + if (StringUtils.isBlank(token)) { + token = httpRequest.getParameter(Constant.TOKEN_HEADER); + } + + return token; + } + + + public void validate(HttpServletRequest httpRequest) throws Exception { + String token = getRequestToken(httpRequest); + if (StringUtils.isBlank(token)) { + throw new Exception("token 不能为空!"); + } + LoginUser loginUser = SecurityFrameworkUtils.getLoginUser(); + if (ObjectUtils.isEmpty(loginUser)) { + throw new RuntimeException("用户不能为空"); + } + CommonResult<AdminUserRespDTO> user = adminUserApi.getUser(loginUser.getId()); + if(ObjectUtils.isEmpty(user)) { + throw new RuntimeException("用户不存在"); + } + AdminUserRespDTO userData = user.getData(); + String username = userData.getUsername(); + ApiAppEntity appInfo = apiAppService.getInfoByAppKey(username); + if (appInfo == null) { + throw new RuntimeException("应用未授权"); + } + //TODO 验证签名 +// if(!com.iailab.common.utils.JwtUtils.verify(token, appInfo.getAppSecret())){ +// throw new RuntimeException("签名错误"); +// } + } + + private boolean isInteger(String str) { + return pattern.matcher(str).matches(); + } + + +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/kio/collector/KingIOClient.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/kio/collector/KingIOClient.java new file mode 100644 index 0000000..a291eea --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/kio/collector/KingIOClient.java @@ -0,0 +1,224 @@ +package com.iailab.module.data.channel.kio.collector; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.iailab.module.data.common.utils.HttpRequest; +import com.iailab.module.data.channel.kio.dto.*; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年06月04日 + */ +public class KingIOClient { + + private boolean bLogin = false; + + private boolean bConnect = false; + + private String ip; + + private int port; + + private String username; + + private String password; + + private String instanceName; + + private String authorization; + + private String url; + + private String chartset = "utf-8"; + + private final String R_CODE = "code"; + + private final String R_MSG = "message"; + + private final String R_DATA = "data"; + + private final int S_CODE = 0; + + private final String DATA_V = "V"; + + private long exp_login = 1000 * 60; + + private long logint_time = 0; + + private long heartbeat_last = 0; + + private int Q_192 = 192; + + private Logger logger = LoggerFactory.getLogger(getClass()); + + KingIOClient(String instanceName) { + this.instanceName = instanceName; + } + + /** + * 登录设备 + * + * @param ip + * @param port + * @param username + * @param password + */ + public boolean login(String ip, int port, String username, String password) { + if ((System.currentTimeMillis() - this.logint_time) < exp_login) { + return bLogin; + } + this.ip = ip; + this.port = port; + this.username = username; + this.password = password; + this.url = "http://" + ip + ":" + port + "/api/v1"; + Map<String, String> form = new HashMap<>(2); + form.put("username", username); + form.put("password", password); + this.logint_time = System.currentTimeMillis(); + String responseStr = HttpRequest.sendPost(this.url + "/login", JSON.toJSONString(form)); + JSONObject responseObj = JSON.parseObject(responseStr); + if (S_CODE != Integer.parseInt(responseObj.get(R_CODE).toString())) { + bLogin = false; + return false; + } + this.authorization = responseObj.getJSONObject(R_DATA).get("Authorization").toString(); + bLogin = true; + return bLogin; + } + + public boolean reLogin() { + return login(this.ip, this.port, this.username, this.password); + } + + public boolean isExpLogin() { + /*if ((System.currentTimeMillis() - logint_time) > exp_login) { + return true; + } else { + return false; + }*/ + if ((System.currentTimeMillis() - logint_time) > exp_login) { + this.bLogin = false; + return true; + }return false; + + } + + public boolean isConnect() { + try { + if ((System.currentTimeMillis() - heartbeat_last) < 10000) { + return bConnect; + } + Map<String, String> map = new HashMap<>(); + String responseStr = HttpRequest.sendPost(this.url + "/heartbeat", "", this.authorization); + JSONObject responseObj = JSON.parseObject(responseStr); + if (S_CODE != Integer.parseInt(responseObj.get(R_CODE).toString())) { + bConnect = false; + } else { + logger.info("KIO心跳正常。"); + bConnect = true; + } + heartbeat_last = System.currentTimeMillis(); + } catch (Exception ex) { + logger.info("KIO心跳异常!" + ex.getMessage()); + bConnect = false; + } + return bConnect; + } + + public String getTagValue(String tagName) { + Map<String, String> map = new HashMap<>(); + map.put("projectInstanceName", this.instanceName); + map.put("TagName", tagName); + String responseStr = HttpRequest.sendGet(this.url + "/realvalue", map, this.authorization); + JSONObject responseObj = JSON.parseObject(responseStr); + if (S_CODE != Integer.parseInt(responseObj.get(R_CODE).toString())) { + return null; + } + JSONObject data = responseObj.getJSONObject(R_DATA); + Object dataV = data.get(DATA_V); + return dataV.toString(); + } + + public Map<String, String> getTagsValue(List<String> tagNames) { + Map<String, String> result = new HashMap<>(); + KIOWriteObjDTO queryDto = new KIOWriteObjDTO(); + List<KIOWriteDTO> objs = new ArrayList<>(); + tagNames.forEach(item -> { + KIOWriteDTO dto = new KIOWriteDTO(); + dto.setN(item); + objs.add(dto); + }); + queryDto.setObjs(objs); + String responseStr = HttpRequest.sendPost(this.url + "/batchrealvalue", JSONObject.toJSONString(queryDto), this.authorization); + JSONObject responseObj = JSON.parseObject(responseStr); + if (S_CODE != Integer.parseInt(responseObj.get(R_CODE).toString())) { + return null; + } + JSONArray data = responseObj.getJSONArray(R_DATA); + for (int i = 0; i < data.size(); i++) { + JSONObject obj = data.getJSONObject(i); + if (obj.getInteger("Q") != Q_192) { + continue; + } + result.put(obj.getString("N"), obj.get(DATA_V).toString()); + } + return result; + } + + public void writeFloatValue(String tagName, Float newValue) throws Exception { + KIOWriteObjDTO writeObj = new KIOWriteObjDTO(); + List<KIOWriteDTO> objs = new ArrayList<>(); + KIOWriteFloatDTO writeDTO = new KIOWriteFloatDTO(); + writeDTO.setN(tagName); + writeDTO.setV(newValue); + objs.add(writeDTO); + writeObj.setObjs(objs); + String writeStr = JSONObject.toJSONString(writeObj); + String responseStr = HttpRequest.sendPost(this.url + "/realvariables", writeStr, this.authorization); + JSONObject responseObj = JSON.parseObject(responseStr); + if (S_CODE != Integer.parseInt(responseObj.get(R_CODE).toString())) { + throw new Exception(responseObj.getString(R_MSG)); + } + + } + + public void writeIntValue(String tagName, Integer newValue) throws Exception { + KIOWriteObjDTO writeObj = new KIOWriteObjDTO(); + List<KIOWriteDTO> objs = new ArrayList<>(); + KIOWriteIntDTO writeDTO = new KIOWriteIntDTO(); + writeDTO.setN(tagName); + writeDTO.setV(newValue); + objs.add(writeDTO); + writeObj.setObjs(objs); + String responseStr = HttpRequest.sendPost(this.url + "/realvariables", JSONObject.toJSONString(writeObj), this.authorization); + JSONObject responseObj = JSON.parseObject(responseStr); + if (S_CODE != Integer.parseInt(responseObj.get(R_CODE).toString())) { + throw new Exception(responseObj.getString(R_MSG)); + } + } + + public void writeBooleanValue(String tagName, Boolean newValue) throws Exception { + KIOWriteObjDTO writeObj = new KIOWriteObjDTO(); + List<KIOWriteDTO> objs = new ArrayList<>(); + KIOWriteBooleanDTO writeDTO = new KIOWriteBooleanDTO(); + writeDTO.setN(tagName); + writeDTO.setV(newValue); + objs.add(writeDTO); + writeObj.setObjs(objs); + String responseStr = HttpRequest.sendPost(this.url + "/realvariables", JSONObject.toJSONString(writeObj), this.authorization); + JSONObject responseObj = JSON.parseObject(responseStr); + if (S_CODE != Integer.parseInt(responseObj.get(R_CODE).toString())) { + throw new Exception(responseObj.getString(R_MSG)); + } + } +} \ No newline at end of file diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/kio/collector/KingIOCollector.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/kio/collector/KingIOCollector.java new file mode 100644 index 0000000..3dd07c6 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/kio/collector/KingIOCollector.java @@ -0,0 +1,129 @@ +package com.iailab.module.data.channel.kio.collector; + +import com.iailab.module.data.common.enums.DataSourceType; +import com.iailab.module.data.common.utils.TagUtils; +import com.iailab.module.data.channel.kio.dto.ChannelKioDeviceDTO; +import com.iailab.module.data.channel.kio.service.ChannelKioDeviceService; +import lombok.extern.slf4j.Slf4j; +import javax.annotation.Resource; +import org.springframework.stereotype.Component; +import org.springframework.util.CollectionUtils; + +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; +import java.util.stream.Collectors; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年06月04日 + */ +@Slf4j +@Component +public class KingIOCollector { + + @Resource + private ChannelKioDeviceService channelKioDeviceService; + + private Map<String, KingIOClient> clientMap = new ConcurrentHashMap<>(); + + private Map<String, ChannelKioDeviceDTO> deviceMap = new HashMap<>(); + + public synchronized KingIOClient getClient(String sourceId) throws Exception { + if (!clientMap.containsKey(sourceId)) { + ChannelKioDeviceDTO deviceDto = channelKioDeviceService.get(sourceId); + deviceMap.put(sourceId, deviceDto); + KingIOClient kingIOClient = new KingIOClient(deviceDto.getInstanceName()); + clientMap.put(sourceId, kingIOClient); + if (!kingIOClient.login(deviceDto.getAddress(), deviceDto.getPort(), deviceDto.getUsername(), deviceDto.getPassword())) { + throw new Exception("登录异常"); + } + } + KingIOClient kingIOClient = clientMap.get(sourceId); + if (!kingIOClient.isConnect()) { + kingIOClient.reLogin(); + } + return kingIOClient; + } + + public String getTagValue(String sourceId, String tagName) throws Exception { + KingIOClient client = this.getClient(sourceId); + String value = client.getTagValue(tagName); + return value; + } + + public void setTagValue(String sourceId, String tagName, String newValue, String dataType) throws Exception { + try { + KingIOClient client = this.getClient(sourceId); + switch (dataType) { + case "float": + log.debug("Float,tagName=" + tagName + ",Value=" + Float.parseFloat(newValue)); + client.writeFloatValue(tagName, Float.parseFloat(newValue)); + break; + case "int": + log.debug("Int,tagName=" + tagName + ",Value=" + new BigDecimal(newValue).intValue()); + client.writeIntValue(tagName, new BigDecimal(newValue).intValue()); + break; + case "boolean": + log.debug("Boolean,tagName=" + tagName + ",Value=" + newValue); + client.writeBooleanValue(tagName, Boolean.parseBoolean(newValue)); + break; + default: + log.warn("##################### No DataType ####################"); + break; + } + } catch (Exception ex) { + ex.printStackTrace(); + throw ex; + } + } + + public Map<String, Object> getTagValues(List<String[]> params) { + if (CollectionUtils.isEmpty(params)) { + return new HashMap<>(); + } + Map<String, Object> result = new HashMap<>(params.size()); + + /*params.forEach(item -> { + try { + KingIOClient client = this.getClient(item[0]); + String value = client.getTagValue(item[1]); + result.put(TagUtils.genTagId(DataSourceType.KIO.getCode(), deviceMap.get(item[0]).getInstanceName(), item[1]), value); + } catch (Exception ex) { + ex.printStackTrace(); + result.put(TagUtils.genTagId(DataSourceType.KIO.getCode(), deviceMap.get(item[0]).getInstanceName(), item[1]), CommonConstant.BAD_VALUE); + } + });*/ + + Map<String, List<String[]>> sourceGroup = new HashMap<>(); + params.forEach(item -> { + if (sourceGroup.containsKey(item[0])) { + sourceGroup.get(item[0]).add(item); + } else { + List<String[]> list = new ArrayList<>(); + list.add(item); + sourceGroup.put(item[0], list); + } + }); + sourceGroup.forEach((k, v) -> { + try { + KingIOClient client = this.getClient(k); + List<String> tagNames = v.stream().map(t -> { + return t[1]; + }).collect(Collectors.toList()); + Map<String, String> tagsValue = client.getTagsValue(tagNames); + for (Map.Entry<String, String> tagValue : tagsValue.entrySet()) { + result.put(TagUtils.genTagId(DataSourceType.KIO.getCode(), deviceMap.get(k).getInstanceName(), tagValue.getKey()), tagValue.getValue()); + } + } catch (Exception ex) { + ex.printStackTrace(); + } + + }); + return result; + } +} \ No newline at end of file diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/kio/controller/admin/ChannelKioDeviceController.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/kio/controller/admin/ChannelKioDeviceController.java new file mode 100644 index 0000000..90e50fb --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/kio/controller/admin/ChannelKioDeviceController.java @@ -0,0 +1,86 @@ +package com.iailab.module.data.channel.kio.controller.admin; + +import com.iailab.framework.common.constant.Constant; +import com.iailab.framework.common.page.PageData; +import com.iailab.framework.common.pojo.CommonResult; +import com.iailab.framework.common.util.validation.ValidationUtils; +import com.iailab.framework.common.validation.group.AddGroup; +import com.iailab.framework.common.validation.group.DefaultGroup; +import com.iailab.module.data.channel.kio.service.ChannelKioDeviceService; +import com.iailab.module.data.channel.kio.dto.ChannelKioDeviceDTO; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.Parameters; +import io.swagger.v3.oas.annotations.tags.Tag; +import javax.annotation.Resource; +import org.springframework.web.bind.annotation.*; + +import java.util.Map; +import java.util.UUID; + +import static com.iailab.framework.common.pojo.CommonResult.success; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年06月04日 + */ +@RestController +@RequestMapping("/data/channel/kio/device") +@Tag(name = "KIO") +public class ChannelKioDeviceController { + + @Resource + private ChannelKioDeviceService channelKioDeviceService; + + @GetMapping("page") + @Operation(summary = "分页") + @Parameters({ + @Parameter(name = Constant.PAGE, description = "当前页码,从1开始", required = true) , + @Parameter(name = Constant.LIMIT, description = "每页显示记录数", required = true) , + @Parameter(name = Constant.ORDER_FIELD, description = "排序字段") , + @Parameter(name = Constant.ORDER, description = "排序方式,可选值(asc、desc)") + }) + public CommonResult<PageData<ChannelKioDeviceDTO>> list(@RequestParam Map<String, Object> params) { + PageData<ChannelKioDeviceDTO> page = channelKioDeviceService.page(params); + return success(page); + } + + @GetMapping("{id}") + @Operation(summary = "信息") + public CommonResult<ChannelKioDeviceDTO> get(@PathVariable("id") String id) { + ChannelKioDeviceDTO data = channelKioDeviceService.get(id); + return success(data); + } + + @PostMapping + @Operation(summary = "保存") + public CommonResult save(@RequestBody ChannelKioDeviceDTO dto) { + //效验数据 + ValidationUtils.validate(dto, AddGroup.class, DefaultGroup.class); + String id = UUID.randomUUID().toString(); + dto.setId(id); + channelKioDeviceService.save(dto); + return new CommonResult(); + } + + /** + * 修改kio配置 + * + */ + @PutMapping + @Operation(summary = "修改") + public CommonResult update(@RequestBody ChannelKioDeviceDTO dto) { + //效验数据 + ValidationUtils.validate(dto, AddGroup.class, DefaultGroup.class); + channelKioDeviceService.update(dto); + return new CommonResult(); + } + + @DeleteMapping + @Operation(summary = "删除") + public CommonResult delete(@RequestBody String[] ids){ + channelKioDeviceService.delete(ids); + return new CommonResult(); + } +} \ No newline at end of file diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/kio/controller/admin/ChannelKioTagController.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/kio/controller/admin/ChannelKioTagController.java new file mode 100644 index 0000000..da0b4c9 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/kio/controller/admin/ChannelKioTagController.java @@ -0,0 +1,82 @@ +package com.iailab.module.data.channel.kio.controller.admin; + +import com.iailab.framework.common.constant.Constant; +import com.iailab.framework.common.page.PageData; +import com.iailab.framework.common.pojo.CommonResult; +import com.iailab.framework.common.util.validation.ValidationUtils; +import com.iailab.framework.common.validation.group.AddGroup; +import com.iailab.framework.common.validation.group.DefaultGroup; +import com.iailab.module.data.channel.kio.dto.ChannelKioTagDTO; +import com.iailab.module.data.channel.kio.service.ChannelKioTagService; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.Parameters; +import javax.annotation.Resource; +import org.springframework.web.bind.annotation.*; + +import java.util.Map; +import java.util.UUID; + +/** + * 操作opcua tag配置 + * + * @author DongYukun + * @createTime 2023年05月6日 17:44:00 + */ +@RestController +@RequestMapping("/data/channel/kio/tag") +public class ChannelKioTagController { + @Resource + private ChannelKioTagService channelKioTagService; + + /** + * 分页查询tag + * */ + @GetMapping("page") + @Operation(summary = "分页") + @Parameters({ + @Parameter(name = Constant.PAGE, description = "当前页码,从1开始", required = true) , + @Parameter(name = Constant.LIMIT, description = "每页显示记录数", required = true) , + @Parameter(name = Constant.ORDER_FIELD, description = "排序字段") , + @Parameter(name = Constant.ORDER, description = "排序方式,可选值(asc、desc)") + }) + public CommonResult<PageData<ChannelKioTagDTO>> page(@RequestParam Map<String, Object> params){ + PageData<ChannelKioTagDTO> page = channelKioTagService.page(params); + return new CommonResult<PageData<ChannelKioTagDTO>>().setData(page); + } + + @GetMapping("{id}") + @Operation(summary = "信息") + public CommonResult<ChannelKioTagDTO> get(@PathVariable("id") String id){ + ChannelKioTagDTO data= channelKioTagService.get(id); + return new CommonResult<ChannelKioTagDTO>().setData(data); + } + + @PostMapping + @Operation(summary = "保存") + public CommonResult save(@RequestBody ChannelKioTagDTO entity){ + entity.setId(UUID.randomUUID().toString()); + channelKioTagService.save(entity); + return new CommonResult(); + } + + /** + * 修改tag + */ + @PutMapping + @Operation(summary = "修改") + public CommonResult update(@RequestBody ChannelKioTagDTO dto) { + //效验数据 + ValidationUtils.validate(dto, AddGroup.class, DefaultGroup.class); + channelKioTagService.update(dto); + return new CommonResult(); + } + + @DeleteMapping + @Operation(summary = "删除") + public CommonResult tagDelete(@RequestBody String[] ids) { + channelKioTagService.delete(ids); + return new CommonResult(); + } + +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/kio/controller/package-info.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/kio/controller/package-info.java new file mode 100644 index 0000000..4e6bb36 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/kio/controller/package-info.java @@ -0,0 +1 @@ +package com.iailab.module.data.channel.kio.controller; \ No newline at end of file diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/kio/dao/ChannelKioDeviceDao.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/kio/dao/ChannelKioDeviceDao.java new file mode 100644 index 0000000..b3e00ed --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/kio/dao/ChannelKioDeviceDao.java @@ -0,0 +1,14 @@ +package com.iailab.module.data.channel.kio.dao; + +import com.iailab.framework.common.dao.BaseDao; +import com.iailab.module.data.channel.kio.entity.ChannelKioDeviceEntity; +import org.apache.ibatis.annotations.Mapper; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年06月04日 + */ +@Mapper +public interface ChannelKioDeviceDao extends BaseDao<ChannelKioDeviceEntity> { +} \ No newline at end of file diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/kio/dao/ChannelKioTagDao.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/kio/dao/ChannelKioTagDao.java new file mode 100644 index 0000000..d73ee58 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/kio/dao/ChannelKioTagDao.java @@ -0,0 +1,14 @@ +package com.iailab.module.data.channel.kio.dao; + +import com.iailab.framework.common.dao.BaseDao; +import com.iailab.module.data.channel.kio.entity.ChannelKioTagEntity; +import org.apache.ibatis.annotations.Mapper; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年06月05日 + */ +@Mapper +public interface ChannelKioTagDao extends BaseDao<ChannelKioTagEntity> { +} \ No newline at end of file diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/kio/dto/ChannelKioDeviceDTO.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/kio/dto/ChannelKioDeviceDTO.java new file mode 100644 index 0000000..6af24c2 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/kio/dto/ChannelKioDeviceDTO.java @@ -0,0 +1,45 @@ +package com.iailab.module.data.channel.kio.dto; + +import io.swagger.v3.oas.annotations.tags.Tag; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年06月04日 + */ +@Data +@Tag(name = "KIO实例") +public class ChannelKioDeviceDTO implements Serializable { + private static final long serialVersionUID = 1L; + + @Schema(description = "ID") + private String id; + + @Schema(description = "实例名称") + private String instanceName; + + @Schema(description = "IP地址") + private String address; + + @Schema(description = "端口") + private Integer port; + + @Schema(description = "用户名") + private String username; + + @Schema(description = "密码") + private String password; + + + @Schema(description = "创建时间") + private Date createTime; + + + @Schema(description = "修改时间") + private Date updateTime; +} \ No newline at end of file diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/kio/dto/ChannelKioTagDTO.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/kio/dto/ChannelKioTagDTO.java new file mode 100644 index 0000000..f2dac09 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/kio/dto/ChannelKioTagDTO.java @@ -0,0 +1,50 @@ +package com.iailab.module.data.channel.kio.dto; + +import io.swagger.v3.oas.annotations.tags.Tag; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年06月05日 + */ +@Data +@Tag(name = "KIO测点") +public class ChannelKioTagDTO implements Serializable { + private static final long serialVersionUID = 1L; + + + @Schema(description = "ID") + private String id; + + @Schema(description = "名称") + private String tagName; + + @Schema(description = "数据类型") + private String dataType; + + @Schema(description = "顺序号") + private Integer tagId; + + @Schema(description = "测点描述") + private String tagDesc; + + @Schema(description = "是否可以tag") + private Boolean enabled; + + @Schema(description = "关联设备") + private String device; + + @Schema(description = "采集频率") + private Integer samplingRate; + + @Schema(description = "创建时间") + private Date createTime; + + @Schema(description = "修改时间") + private Date updateTime; +} \ No newline at end of file diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/kio/dto/KIOWriteBooleanDTO.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/kio/dto/KIOWriteBooleanDTO.java new file mode 100644 index 0000000..6d3e07d --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/kio/dto/KIOWriteBooleanDTO.java @@ -0,0 +1,17 @@ +package com.iailab.module.data.channel.kio.dto; + +import com.alibaba.fastjson.annotation.JSONField; +import lombok.Data; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年06月05日 + */ +@Data +public class KIOWriteBooleanDTO extends KIOWriteDTO { + private static final long serialVersionUID = 1L; + + @JSONField(name="V") + private Boolean V; +} \ No newline at end of file diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/kio/dto/KIOWriteDTO.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/kio/dto/KIOWriteDTO.java new file mode 100644 index 0000000..ae506b9 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/kio/dto/KIOWriteDTO.java @@ -0,0 +1,19 @@ +package com.iailab.module.data.channel.kio.dto; + +import com.alibaba.fastjson.annotation.JSONField; +import lombok.Data; + +import java.io.Serializable; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年06月05日 + */ +@Data +public class KIOWriteDTO implements Serializable { + private static final long serialVersionUID = 1L; + + @JSONField(name="N") + private String N; +} \ No newline at end of file diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/kio/dto/KIOWriteFloatDTO.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/kio/dto/KIOWriteFloatDTO.java new file mode 100644 index 0000000..a745a33 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/kio/dto/KIOWriteFloatDTO.java @@ -0,0 +1,17 @@ +package com.iailab.module.data.channel.kio.dto; + +import com.alibaba.fastjson.annotation.JSONField; +import lombok.Data; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年06月05日 + */ +@Data +public class KIOWriteFloatDTO extends KIOWriteDTO { + private static final long serialVersionUID = 1L; + + @JSONField(name="V") + private Float V; +} \ No newline at end of file diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/kio/dto/KIOWriteIntDTO.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/kio/dto/KIOWriteIntDTO.java new file mode 100644 index 0000000..2fd32e5 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/kio/dto/KIOWriteIntDTO.java @@ -0,0 +1,17 @@ +package com.iailab.module.data.channel.kio.dto; + +import com.alibaba.fastjson.annotation.JSONField; +import lombok.Data; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年06月05日 + */ +@Data +public class KIOWriteIntDTO extends KIOWriteDTO { + private static final long serialVersionUID = 1L; + + @JSONField(name="V") + private Integer V; +} \ No newline at end of file diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/kio/dto/KIOWriteObjDTO.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/kio/dto/KIOWriteObjDTO.java new file mode 100644 index 0000000..8ad3894 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/kio/dto/KIOWriteObjDTO.java @@ -0,0 +1,20 @@ +package com.iailab.module.data.channel.kio.dto; + +import com.alibaba.fastjson.annotation.JSONField; +import lombok.Data; + +import java.io.Serializable; +import java.util.List; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年06月05日 + */ +@Data +public class KIOWriteObjDTO implements Serializable { + private static final long serialVersionUID = 1L; + + @JSONField(name="objs") + private List<KIOWriteDTO> objs; +} \ No newline at end of file diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/kio/entity/ChannelKioDeviceEntity.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/kio/entity/ChannelKioDeviceEntity.java new file mode 100644 index 0000000..acdd416 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/kio/entity/ChannelKioDeviceEntity.java @@ -0,0 +1,65 @@ +package com.iailab.module.data.channel.kio.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年06月04日 + */ +@Data +@TableName("t_channel_kio_device") +public class ChannelKioDeviceEntity implements Serializable { + private static final long serialVersionUID = 1L; + + /** + * 主键 + */ + @Schema(description = "主键") + @TableId(value = "id",type = IdType.INPUT) + private String id; + + /** + * 实例名称 + */ + private String instanceName; + + /** + * IP地址 + */ + private String address; + + /** + * 端口 + */ + private Integer port; + + /** + * 用户名 + */ + private String username; + + /** + * 密码 + */ + private String password; + + + /** + * 创建时间 + */ + private Date createTime; + + + /** + * 修改时间 + */ + private Date updateTime; +} \ No newline at end of file diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/kio/entity/ChannelKioTagEntity.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/kio/entity/ChannelKioTagEntity.java new file mode 100644 index 0000000..1a89990 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/kio/entity/ChannelKioTagEntity.java @@ -0,0 +1,74 @@ +package com.iailab.module.data.channel.kio.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年06月05日 + */ +@Data +@TableName("t_channel_kio_tag") +public class ChannelKioTagEntity implements Serializable { + private static final long serialVersionUID = 1L; + + /** + * 主键 + */ + @Schema(description = "主键") + @TableId(value = "id",type = IdType.INPUT) + private String id; + + /** + * 名称 + */ + private String tagName; + + + /** + * 数据类型 + */ + private String dataType; + + /** + * 顺序号 + */ + private Integer tagId; + + /** + * 测点描述 + */ + private String tagDesc; + + /** + * 是否可以tag + */ + private Boolean enabled; + + /** + * 关联设备 + */ + private String device; + + /** + * 采集频率 + */ + private Integer samplingRate; + + /** + * 创建时间 + */ + private Date createTime; + + /** + * 修改时间 + */ + private Date updateTime; +} \ No newline at end of file diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/kio/service/ChannelKioDeviceService.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/kio/service/ChannelKioDeviceService.java new file mode 100644 index 0000000..bbaf799 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/kio/service/ChannelKioDeviceService.java @@ -0,0 +1,29 @@ +package com.iailab.module.data.channel.kio.service; + +import com.iailab.framework.common.page.PageData; +import com.iailab.framework.common.service.BaseService; +import com.iailab.module.data.channel.kio.dto.ChannelKioDeviceDTO; +import com.iailab.module.data.channel.kio.entity.ChannelKioDeviceEntity; + +import java.util.List; +import java.util.Map; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年06月04日 + */ +public interface ChannelKioDeviceService extends BaseService<ChannelKioDeviceEntity> { + + PageData<ChannelKioDeviceDTO> page(Map<String, Object> params); + + List<ChannelKioDeviceDTO> list(Map<String, Object> params); + + ChannelKioDeviceDTO get(String id); + + void save(ChannelKioDeviceDTO dto); + + void update(ChannelKioDeviceDTO dto); + + void delete(String[] ids); +} \ No newline at end of file diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/kio/service/ChannelKioTagService.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/kio/service/ChannelKioTagService.java new file mode 100644 index 0000000..ba092e3 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/kio/service/ChannelKioTagService.java @@ -0,0 +1,33 @@ +package com.iailab.module.data.channel.kio.service; + +import com.iailab.framework.common.page.PageData; +import com.iailab.framework.common.service.BaseService; +import com.iailab.module.data.channel.kio.dto.ChannelKioTagDTO; +import com.iailab.module.data.channel.kio.entity.ChannelKioTagEntity; + +import java.util.List; +import java.util.Map; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年06月05日 + */ +public interface ChannelKioTagService extends BaseService<ChannelKioTagEntity> { + + PageData<ChannelKioTagDTO> page(Map<String, Object> params); + + ChannelKioTagDTO get(String id); + + void save(ChannelKioTagDTO dto); + + void update(ChannelKioTagDTO dto); + + void delete(String[] ids); + List<ChannelKioTagDTO> getByDevice(String instanceName); + + ChannelKioTagDTO getByTagName(String tagName); + + void deleteByDeviceName(String name); + +} \ No newline at end of file diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/kio/service/impl/ChannelKioDeviceServiceImpl.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/kio/service/impl/ChannelKioDeviceServiceImpl.java new file mode 100644 index 0000000..8a7cd0e --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/kio/service/impl/ChannelKioDeviceServiceImpl.java @@ -0,0 +1,83 @@ +package com.iailab.module.data.channel.kio.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.iailab.framework.common.constant.Constant; +import com.iailab.framework.common.page.PageData; +import com.iailab.framework.common.service.impl.BaseServiceImpl; +import com.iailab.framework.common.util.object.ConvertUtils; +import com.iailab.module.data.channel.kio.service.ChannelKioTagService; +import com.iailab.module.data.channel.kio.dao.ChannelKioDeviceDao; +import com.iailab.module.data.channel.kio.dto.ChannelKioDeviceDTO; +import com.iailab.module.data.channel.kio.entity.ChannelKioDeviceEntity; +import com.iailab.module.data.channel.kio.service.ChannelKioDeviceService; +import com.iailab.module.data.channel.kio.service.ChannelKioTagService; +import org.apache.commons.lang3.StringUtils; +import javax.annotation.Resource; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.Arrays; +import java.util.List; +import java.util.Map; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年06月04日 + */ +@Service +public class ChannelKioDeviceServiceImpl extends BaseServiceImpl<ChannelKioDeviceDao, ChannelKioDeviceEntity> implements ChannelKioDeviceService { + + @Resource + ChannelKioTagService channelKioTagService; + + @Override + public PageData<ChannelKioDeviceDTO> page(Map<String, Object> params) { + IPage<ChannelKioDeviceEntity> page = baseDao.selectPage( + getPage(params, Constant.CREATE_TIME, false), + getWrapper(params) + ); + return getPageData(page, ChannelKioDeviceDTO.class); + } + + @Override + public List<ChannelKioDeviceDTO> list(Map<String, Object> params) { + List<ChannelKioDeviceEntity> list = baseDao.selectList(getWrapper(params)); + return ConvertUtils.sourceToTarget(list, ChannelKioDeviceDTO.class); + } + + private QueryWrapper<ChannelKioDeviceEntity> getWrapper(Map<String, Object> params){ + String instanceName = (String)params.get("instanceName"); + QueryWrapper<ChannelKioDeviceEntity> wrapper = new QueryWrapper<>(); + wrapper.like(StringUtils.isNotBlank(instanceName), "instance_name", instanceName); + return wrapper; + } + + @Override + public ChannelKioDeviceDTO get(String id) { + ChannelKioDeviceEntity entity = baseDao.selectById(id); + return ConvertUtils.sourceToTarget(entity, ChannelKioDeviceDTO.class); + } + + @Override + public void save(ChannelKioDeviceDTO dto) { + ChannelKioDeviceEntity entity = ConvertUtils.sourceToTarget(dto, ChannelKioDeviceEntity.class); + insert(entity); + } + + @Override + public void update(ChannelKioDeviceDTO dto) { + ChannelKioDeviceEntity entity = ConvertUtils.sourceToTarget(dto, ChannelKioDeviceEntity.class); + updateById(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void delete(String[] ids) { + Arrays.asList(ids).forEach(id -> { + channelKioTagService.deleteByDeviceName(get(id).getInstanceName()); + }); + baseDao.deleteBatchIds(Arrays.asList(ids)); + } +} \ No newline at end of file diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/kio/service/impl/ChannelKioTagServiceImpl.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/kio/service/impl/ChannelKioTagServiceImpl.java new file mode 100644 index 0000000..1ded093 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/kio/service/impl/ChannelKioTagServiceImpl.java @@ -0,0 +1,106 @@ +package com.iailab.module.data.channel.kio.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.iailab.framework.common.constant.Constant; +import com.iailab.framework.common.page.PageData; +import com.iailab.framework.common.service.impl.BaseServiceImpl; +import com.iailab.framework.common.util.object.ConvertUtils; +import com.iailab.module.data.channel.kio.dao.ChannelKioTagDao; +import com.iailab.module.data.channel.kio.dto.ChannelKioTagDTO; +import com.iailab.module.data.channel.kio.entity.ChannelKioTagEntity; +import com.iailab.module.data.channel.kio.service.ChannelKioTagService; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.util.Arrays; +import java.util.Date; +import java.util.List; +import java.util.Map; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年06月05日 + */ +@Slf4j +@Service +public class ChannelKioTagServiceImpl extends BaseServiceImpl<ChannelKioTagDao, ChannelKioTagEntity> implements ChannelKioTagService { + @Resource + private ChannelKioTagDao channelKioTagDao; + + @Value("${iems.upload-dir}") + private String uploadDir; + + @Override + public PageData<ChannelKioTagDTO> page(Map<String, Object> params) { + IPage<ChannelKioTagEntity> page = baseDao.selectPage( + getPage(params, Constant.CREATE_TIME, false), + getWrapper(params) + ); + return getPageData(page, ChannelKioTagDTO.class); + } + + @Override + public ChannelKioTagDTO get(String id) { + ChannelKioTagEntity entity = baseDao.selectById(id); + return ConvertUtils.sourceToTarget(entity, ChannelKioTagDTO.class); + } + + @Override + public void save(ChannelKioTagDTO dto) { + ChannelKioTagEntity entity = ConvertUtils.sourceToTarget(dto, ChannelKioTagEntity.class); + entity.setCreateTime(new Date()); + entity.setUpdateTime(new Date()); + insert(entity); + } + + @Override + public void update(ChannelKioTagDTO dto) { + ChannelKioTagEntity entity = ConvertUtils.sourceToTarget(dto, ChannelKioTagEntity.class); + entity.setUpdateTime(new Date()); + updateById(entity); + } + + @Override + public void delete(String[] ids) { + baseDao.deleteBatchIds(Arrays.asList(ids)); + } + + @Override + public List<ChannelKioTagDTO> getByDevice(String device) { + QueryWrapper<ChannelKioTagEntity> wrapper = new QueryWrapper<>(); + wrapper.like(StringUtils.isNotBlank(device), "device", device) + .orderByAsc("tag_id"); + List<ChannelKioTagEntity> list = baseDao.selectList(wrapper); + return ConvertUtils.sourceToTarget(list, ChannelKioTagDTO.class); + } + + @Override + public ChannelKioTagDTO getByTagName(String tagName) { + QueryWrapper<ChannelKioTagEntity> wrapper = new QueryWrapper<>(); + wrapper.eq("tag_name", tagName); + ChannelKioTagEntity entity = baseDao.selectOne(wrapper); + return ConvertUtils.sourceToTarget(entity, ChannelKioTagDTO.class); + } + + @Override + public void deleteByDeviceName(String name) { + baseDao.delete(new QueryWrapper<ChannelKioTagEntity>().eq("device",name)); + } + + private QueryWrapper<ChannelKioTagEntity> getWrapper(Map<String, Object> params){ + String tagName = (String) params.get("tagName"); + String device = (String) params.get("device"); + QueryWrapper<ChannelKioTagEntity> wrapper = new QueryWrapper<>(); + wrapper.eq(StringUtils.isNotBlank(device), "device", device); + wrapper.like(StringUtils.isNotBlank(tagName), "tag_name", tagName); + wrapper.orderByDesc("create_time"); + return wrapper; + } + + +} \ No newline at end of file diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/modbus/collector/ModBusCollector.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/modbus/collector/ModBusCollector.java new file mode 100644 index 0000000..3b27b16 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/modbus/collector/ModBusCollector.java @@ -0,0 +1,135 @@ +package com.iailab.module.data.channel.modbus.collector; + +import com.iailab.module.data.common.enums.CommonConstant; +import com.iailab.module.data.common.enums.DataSourceType; +import com.iailab.framework.common.util.object.ConvertUtils; +import com.iailab.module.data.common.utils.TagUtils; +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.serotonin.modbus4j.ModbusMaster; +import com.serotonin.modbus4j.code.DataType; +import lombok.extern.slf4j.Slf4j; +import javax.annotation.Resource; +import org.springframework.stereotype.Component; +import org.springframework.util.CollectionUtils; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年05月12日 + */ +@Slf4j +@Component +public class ModBusCollector { + + @Resource + private ChannelModbusDeviceService channelModbusDeviceService; + + private Map<String, ModbusMaster> clientMap = new ConcurrentHashMap<>(); + + private Map<String, ChannelModBusDeviceEntity> deviceMap = new HashMap<>(); + + private synchronized ModbusMaster getMaster(String sourceId) throws Exception { + log.info("=========Modbus============"); + try { + if (!clientMap.containsKey(sourceId)) { + ChannelModBusDeviceEntity entity = channelModbusDeviceService.info(sourceId); + ChannelModBusDeviceDTO tModbusDTO = ConvertUtils.sourceToTarget(entity, ChannelModBusDeviceDTO.class); + ModbusMaster modbusMaster = ModbusUtils.getMaster(tModbusDTO); + if (modbusMaster != null) { + clientMap.put(sourceId, modbusMaster); + } + } + } catch (Exception ex) { + log.error("=========Modbus Exception============"); + log.error("ex.message+" + ex.getMessage()); + throw new Exception(ex.getMessage()); + } + return clientMap.get(sourceId); + } + + public Double getTagValue(String sourceId, String tagNo) { + Double result = CommonConstant.BAD_VALUE.doubleValue(); + try { + ModbusMaster modbusMaster = this.getMaster(sourceId); + // 获取寄存器类型 + String type = tagNo.substring(0, 1); + int slaveId = 1; + int offset = Integer.parseInt(tagNo.substring(1)) - 1; + switch (type) { + case "0": + // 读线圈寄存器 + result = ModbusUtils.readCoilStatus(modbusMaster, slaveId, offset) ? 1d : 0; + break; + case "1": + // 读离散输入寄存器 + result = ModbusUtils.inputStatus(modbusMaster, slaveId, offset) ? 1d : 0; + break; + case "3": + // 读输入寄存器 + result = ModbusUtils.inputRegister(modbusMaster, slaveId, offset, DataType.TWO_BYTE_INT_SIGNED) + .doubleValue(); + break; + case "4": + // 读输入寄存器数据 + result = ModbusUtils.holdingRegister(modbusMaster, slaveId, offset, DataType.TWO_BYTE_INT_SIGNED) + .doubleValue(); + break; + default: + break; + } + return result; + } catch (Exception ex) { + log.error("TagNo========" + tagNo); + ex.printStackTrace(); + } + return result; + } + + public void setTagValue(String sourceId, String tagNo, String newValue) { + try { + ModbusMaster modbusMaster = this.getMaster(sourceId); + // 获取寄存器类型 + String type = tagNo.substring(0, 1); + int slaveId = 1; + int offset = Integer.parseInt(tagNo.substring(1)) - 1; + switch (type) { + case "0": + // 写单个线圈寄存器 + ModbusUtils.writeCoilStatus(modbusMaster, slaveId, offset, Integer.parseInt(newValue) > 0 ); + break; + case "4": + // 写单个保持寄存器 + ModbusUtils.writeRegister(modbusMaster, slaveId, offset, Integer.parseInt(newValue)); + break; + default: + break; + } + } catch (Exception ex) { + ex.printStackTrace(); + } + } + + public Map<String, Object> getTagValues(List<String[]> params) { + if (CollectionUtils.isEmpty(params)) { + return new HashMap<>(); + } + Map<String, Object> result = new HashMap<>(params.size()); + params.forEach(item -> { + try { + Double value = this.getTagValue(item[0], item[1]); + result.put(TagUtils.genTagId(DataSourceType.ModBus.getCode(), deviceMap.get(item[0]).getName(), item[1]), value); + } catch (Exception ex) { + ex.printStackTrace(); + result.put(TagUtils.genTagId(DataSourceType.ModBus.getCode(), deviceMap.get(item[0]).getName(), item[1]), CommonConstant.BAD_VALUE); + } + }); + return result; + } +} \ No newline at end of file diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/modbus/collector/ModbusUtils.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/modbus/collector/ModbusUtils.java new file mode 100644 index 0000000..8f74059 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/modbus/collector/ModbusUtils.java @@ -0,0 +1,229 @@ +package com.iailab.module.data.channel.modbus.collector; + +import com.iailab.module.data.channel.modbus.dto.ChannelModBusDeviceDTO; +import com.serotonin.modbus4j.ModbusFactory; +import com.serotonin.modbus4j.ModbusMaster; +import com.serotonin.modbus4j.exception.ErrorResponseException; +import com.serotonin.modbus4j.exception.ModbusInitException; +import com.serotonin.modbus4j.exception.ModbusTransportException; +import com.serotonin.modbus4j.ip.IpParameters; +import com.serotonin.modbus4j.locator.BaseLocator; +import com.serotonin.modbus4j.msg.*; + +/** + * Modbus 工具类 + */ +public class ModbusUtils { + + /** + * 工厂 + */ + static ModbusFactory modbusFactory; + static ModbusMaster modbusMaster; + + static { + if (modbusFactory == null) { + modbusFactory = new ModbusFactory(); + } + } + + + /** + * 获取master + * + * @param tModbusDTO + * @return + */ + public static ModbusMaster getMaster(ChannelModBusDeviceDTO tModbusDTO) throws ModbusInitException { + if (modbusMaster == null) { + IpParameters ipParameters = new IpParameters(); + ipParameters.setHost(tModbusDTO.getAddress()); + ipParameters.setPort(tModbusDTO.getPort()); + modbusMaster = modbusFactory.createTcpMaster(ipParameters, true); + //设置超时时间 + modbusMaster.setTimeout(tModbusDTO.getReadTimeout()); + //设置重连次数 + modbusMaster.setRetries(tModbusDTO.getAttemptsBeforeTimeout()); + modbusMaster.init(); + return modbusMaster; + } + return modbusMaster; + } + + /** + * 测试用 + * + * @return + */ + public static ModbusMaster getMaster() throws ModbusInitException { + if (modbusMaster == null) { + IpParameters ipParameters = new IpParameters(); + ipParameters.setHost("127.0.0.1"); + ipParameters.setPort(502); + modbusMaster = modbusFactory.createTcpMaster(ipParameters, true); + modbusMaster.init(); + return modbusMaster; + } + return modbusMaster; + } + + + /** + * 读取线圈开关状态数据 0x01 + * + * @param slaveId + * @param offset + * @return + * @throws ModbusInitException + * @throws ModbusTransportException + * @throws ErrorResponseException + */ + public static Boolean readCoilStatus(ModbusMaster modbusMaster, int slaveId, int offset) throws ModbusInitException, ModbusTransportException, ErrorResponseException { + BaseLocator<Boolean> coilStatus = BaseLocator.coilStatus(slaveId, offset); + Boolean res = modbusMaster.getValue(coilStatus); + return res; + } + + /** + * 读离散输入寄存器状态数据 0x02 + * + * @param slaveId + * @param offset + * @return + * @throws ModbusInitException + * @throws ModbusTransportException + * @throws ErrorResponseException + */ + public static Boolean inputStatus(ModbusMaster modbusMaster, int slaveId, int offset) throws ModbusInitException, ModbusTransportException, ErrorResponseException { + BaseLocator<Boolean> inputStatus = BaseLocator.inputStatus(slaveId, offset); + Boolean res = modbusMaster.getValue(inputStatus); + return res; + } + + /** + * 读保持寄存器数据 0x03 + * + * @param modbusMaster + * @param slaveId + * @param offset + * @param dataType + * @return + * @throws ModbusInitException + * @throws ModbusTransportException + * @throws ErrorResponseException + */ + public static Number holdingRegister(ModbusMaster modbusMaster, int slaveId, int offset, int dataType) throws ModbusInitException, ModbusTransportException, ErrorResponseException { + BaseLocator<Number> holdingRegister = BaseLocator.holdingRegister(slaveId, offset, dataType); + Number value = modbusMaster.getValue(holdingRegister); + return value; + } + + /** + * 测试用 + * + * @return + */ + public static Number holdingRegister(int slaveId, int offset, int dataType) throws ModbusInitException, ModbusTransportException, ErrorResponseException { + BaseLocator<Number> holdingRegister = BaseLocator.holdingRegister(slaveId, offset, dataType); + Number value = getMaster().getValue(holdingRegister); + return value; + } + + /** + * 读输入寄存器数据 0x04 + * + * @param slaveId + * @param offset + * @param dataType + * @return + * @throws ModbusInitException + * @throws ModbusTransportException + * @throws ErrorResponseException + */ + public static Number inputRegister(ModbusMaster modbusMaster, int slaveId, int offset, int dataType) throws ModbusInitException, ModbusTransportException, ErrorResponseException { + BaseLocator<Number> inputRegister = BaseLocator.inputRegister(slaveId, offset, dataType); + Number value = modbusMaster.getValue(inputRegister); + return value; + } + + + /** + * 写线圈开关状态数据 0x05 + * + * @param slaveId + * @param offset + * @param status + * @return + * @throws ModbusTransportException + * @throws ModbusInitException + */ + public static Boolean writeCoilStatus(ModbusMaster modbusMaster, int slaveId, int offset, boolean status) throws ModbusTransportException, ModbusInitException { + boolean coilValue = status; + WriteCoilRequest coilRequest = new WriteCoilRequest(slaveId, offset, coilValue); + WriteCoilResponse coilResponse = (WriteCoilResponse) modbusMaster.send(coilRequest); + return !coilResponse.isException(); + } + + + /** + * 写单个保持寄存器数据 0x06 + * + * @param slaveId + * @param offset + * @param value + * @return + * @throws ModbusTransportException + * @throws ModbusInitException + */ + public static Boolean writeRegister(ModbusMaster modbusMaster, int slaveId, int offset, int value) throws ModbusTransportException, ModbusInitException { + WriteRegisterRequest registerRequest = new WriteRegisterRequest(slaveId, offset, value); + WriteRegisterResponse registerResponse = (WriteRegisterResponse) modbusMaster.send(registerRequest); + return !registerResponse.isException(); + + } + + /** + * 测试用 + * + * @return + */ + public static Boolean writeRegister(int slaveId, int offset, int value) throws ModbusTransportException, ModbusInitException { + WriteRegisterRequest registerRequest = new WriteRegisterRequest(slaveId, offset, value); + WriteRegisterResponse registerResponse = (WriteRegisterResponse) getMaster().send(registerRequest); + return !registerResponse.isException(); + + } + + /** + * 写线圈开关状态数据【多】 0x0f + * + * @param slaveId + * @param offset + * @param booleans + * @return + * @throws ModbusTransportException + * @throws ModbusInitException + */ + public static Boolean writeCoils(ModbusMaster modbusMaster, int slaveId, int offset, boolean[] booleans) throws ModbusTransportException, ModbusInitException { + WriteCoilsRequest writeCoils = new WriteCoilsRequest(slaveId, offset, booleans); + WriteCoilsResponse coilsResponse = (WriteCoilsResponse) modbusMaster.send(writeCoils); + return !coilsResponse.isException(); + } + + + /** + * 写保存寄存器数据【多】 0x10 + * + * @param slaveId + * @param offset + * @param nums + * @return + * @throws ModbusTransportException + * @throws ModbusInitException + */ + public static Boolean writeRegisters(ModbusMaster modbusMaster, int slaveId, int offset, short[] nums) throws ModbusTransportException, ModbusInitException { + WriteRegistersRequest writeRegisters = new WriteRegistersRequest(slaveId, offset, nums); + WriteRegistersResponse registersResponse = (WriteRegistersResponse) modbusMaster.send(writeRegisters); + return !registersResponse.isException(); + } +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/modbus/controller/admin/ChannelModbusDeviceController.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/modbus/controller/admin/ChannelModbusDeviceController.java new file mode 100644 index 0000000..d70b262 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/modbus/controller/admin/ChannelModbusDeviceController.java @@ -0,0 +1,84 @@ +package com.iailab.module.data.channel.modbus.controller.admin; + +import com.iailab.module.data.common.utils.PageUtils; +import com.iailab.module.data.common.utils.R; +import com.iailab.module.data.channel.modbus.entity.ChannelModBusDeviceEntity; +import com.iailab.module.data.channel.modbus.service.ChannelModbusDeviceService; +import javax.annotation.Resource; +import org.springframework.web.bind.annotation.*; + +import java.util.Map; +import java.util.UUID; + +/** + * 操作modbus配置 + * + * @author DongYukun + * @createTime 2023年04月24日 14:10:00 + */ +@RestController +@RequestMapping("/data/channel/modbus/device") +public class ChannelModbusDeviceController { + @Resource + private ChannelModbusDeviceService channelModbusDeviceService; + + /** + * 分页查询设备 + * + * @param params + */ + @GetMapping("/list") + public R list(@RequestParam Map<String, Object> params){ + PageUtils page = channelModbusDeviceService.queryPage(params); + + return R.ok().put("page", page); + } + /** + * 根据id查询设备详情 + * + * @param id + */ + @GetMapping("/info/{id}") + public R info(@PathVariable("id") String id){ + ChannelModBusDeviceEntity info= channelModbusDeviceService.info(id); + return R.ok().put("data", info); + } + /** + * 添加设备 + * + * @param channelModBusDeviceEntity + */ + @PostMapping("/add") + public R add(@RequestBody ChannelModBusDeviceEntity channelModBusDeviceEntity){ + String id = UUID.randomUUID().toString(); + channelModBusDeviceEntity.setId(id); + channelModbusDeviceService.add(channelModBusDeviceEntity); + return R.ok(); + } + + /** + * 修改设备 + * + * @param channelModBusDeviceEntity + */ + @PostMapping("/update") + public R update(@RequestBody ChannelModBusDeviceEntity channelModBusDeviceEntity) { + channelModbusDeviceService.update(channelModBusDeviceEntity); + return R.ok(); + } + + /** + * 删除设备 + * + * @param params + * + */ + @PostMapping("/delete") + public R delete(@RequestBody Map<String, Object> params) { + String id = (String)params.get("id"); + channelModbusDeviceService.delete(id); + return R.ok(); + } + + +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/modbus/controller/admin/ChannelModbusTagController.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/modbus/controller/admin/ChannelModbusTagController.java new file mode 100644 index 0000000..d855638 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/modbus/controller/admin/ChannelModbusTagController.java @@ -0,0 +1,100 @@ +package com.iailab.module.data.channel.modbus.controller.admin; + +import com.iailab.module.data.common.utils.PageUtils; +import com.iailab.module.data.common.utils.R; +import com.iailab.module.data.channel.modbus.entity.ChannelModBusTagEntity; +import com.iailab.module.data.channel.modbus.service.ChannelModbusTagService; +import com.sun.xml.internal.messaging.saaj.util.Base64; +import javax.annotation.Resource; +import org.springframework.web.bind.annotation.*; + +import java.util.Map; +import java.util.UUID; + +/** + * 操作modbus tag配置 + * + * @author DongYukun + * @createTime 2023年04月25日 10:31:00 + */ +@RestController +@RequestMapping("/data/channel/modbus/tag") +public class ChannelModbusTagController { + @Resource + private ChannelModbusTagService channelModbusTagService; + /** + * 分页查询tag + * + * @param params + */ + @GetMapping("/list") + public R tagList(@RequestParam Map<String, Object> params){ + PageUtils page = channelModbusTagService.queryPage(params); + + return R.ok().put("page", page); + } + /** + * 根据id查询tag详情 + * + * @param id + */ + @GetMapping("/info/{id}") + public R tagInfo(@PathVariable("id") String id){ + ChannelModBusTagEntity info= channelModbusTagService.info(Base64.base64Decode(id)); + return R.ok().put("data", info); + } + /** + * 添加tag + * + * @param entity + */ + @PostMapping("/add") + public R tagAdd(@RequestBody ChannelModBusTagEntity entity){ + entity.setId(UUID.randomUUID().toString()); + channelModbusTagService.add(entity); + return R.ok(); + } + + /** + * 修改tag + * + * @param channelModBusTagEntity + */ + @PostMapping("/update") + public R tagUpdate(@RequestBody ChannelModBusTagEntity channelModBusTagEntity) { + channelModbusTagService.update(channelModBusTagEntity); + return R.ok(); + } + + /** + * 删除tag + * @param params + * + */ + @PostMapping("/delete") + public R tagDelete(@RequestBody Map<String, Object> params) { + String id = (String)params.get("id"); + channelModbusTagService.delete(id); + return R.ok(); + } + +// /** +// * 导入 +// * +// * @param device +// * @param file +// * @return +// */ +// @PostMapping("/import/{device}") +// public R importTag(@PathVariable("device") String device, @RequestParam("file") MultipartFile file) { +// try { +// if (file.isEmpty()) { +// throw new RRException("上传文件不能为空"); +// } +// channelModbusTagService.importTag(device, file); +// } catch (Exception ex) { +// return R.error(ex.getMessage()); +// } +// return R.ok(); +// } +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/modbus/controller/package-info.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/modbus/controller/package-info.java new file mode 100644 index 0000000..f0132a0 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/modbus/controller/package-info.java @@ -0,0 +1 @@ +package com.iailab.module.data.channel.modbus.controller; \ No newline at end of file diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/modbus/dao/ChannelModBusDeviceDao.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/modbus/dao/ChannelModBusDeviceDao.java new file mode 100644 index 0000000..efc4510 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/modbus/dao/ChannelModBusDeviceDao.java @@ -0,0 +1,18 @@ +package com.iailab.module.data.channel.modbus.dao; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.iailab.module.data.channel.modbus.entity.ChannelModBusDeviceEntity; +import com.iailab.module.data.channel.modbus.entity.ChannelModBusDeviceEntity; +import com.iailab.module.data.channel.modbus.entity.ChannelModBusDeviceEntity; +import com.iailab.module.data.channel.modbus.entity.ChannelModBusDeviceEntity; +import org.apache.ibatis.annotations.Mapper; + +/** + * @author PanZhibao + * @Description + * @createTime 2023年04月24日 11:33:00 + */ +@Mapper +public interface ChannelModBusDeviceDao extends BaseMapper<ChannelModBusDeviceEntity> { + +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/modbus/dao/ChannelModBusTagDao.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/modbus/dao/ChannelModBusTagDao.java new file mode 100644 index 0000000..72297e7 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/modbus/dao/ChannelModBusTagDao.java @@ -0,0 +1,21 @@ +package com.iailab.module.data.channel.modbus.dao; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.iailab.module.data.channel.modbus.entity.ChannelModBusTagEntity; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * @author DongYukun + * @Description + * @createTime 2023年04月25日 15:12:00 + */ +@Mapper +public interface ChannelModBusTagDao extends BaseMapper<ChannelModBusTagEntity> { + + void insertList(List<ChannelModBusTagEntity> list); + + String selectIdByName(@Param("name") String name); +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/modbus/dto/ChannelModBusDeviceDTO.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/modbus/dto/ChannelModBusDeviceDTO.java new file mode 100644 index 0000000..34849b3 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/modbus/dto/ChannelModBusDeviceDTO.java @@ -0,0 +1,83 @@ +package com.iailab.module.data.channel.modbus.dto; + +import com.alibaba.fastjson.annotation.JSONField; +import lombok.Data; + +import java.io.Serializable; + +/** + * @author PanZhibao + * @Description + * @createTime 2023年04月23日 14:24:00 + */ +@Data +public class ChannelModBusDeviceDTO implements Serializable { + private static final long serialVersionUID = 1L; + + /** + * 用于标识该设备的名字 + */ + @JSONField(name="Name")//该注解防止属性名转化成json时变成小写 + private String Name; + + /** + * 要访问设备的 IP 地址 + */ + @JSONField(name="Address") + private String Address; + + /** + * 设备端口号 + */ + @JSONField(name="Port") + private Integer Port; + + /** + * 设备不活动超时时间 + */ + @JSONField(name="ConnectInactivityTimeout") + private Integer ConnectInactivityTimeout; + + /** + * 设备不在线或者连接异常时,系统进行重试连接的超时时间。默认值5000(5s) + */ + @JSONField(name="ReconnectInterval") + private Integer ReconnectInterval; + + /** + * 请求超时之前的重试次数,默认值为3 + */ + @JSONField(name="AttemptsBeforeTimeout") + private Integer AttemptsBeforeTimeout; + + /** + * 请求超时之前重试时间间隔,默认值250 (250ms) + */ + @JSONField(name="WaitToRetryMilliseconds") + private Integer WaitToRetryMilliseconds; + + /** + * 读请求超时时间,默认3000(3s) + */ + @JSONField(name="ReadTimeout") + private Integer ReadTimeout; + + /** + * 写请求超时时间,默认3000(3s) + */ + @JSONField(name="WriteTimeout") + private Integer WriteTimeout; + + /** + * 是否使用优化方式读取数据,默认true。使能后,多个读请求可能放在一个数据包中对设备进行一次请求 + */ + @JSONField(name="UseOptimizedBlockRead") + private Boolean UseOptimizedBlockRead; + + /** + * 系统内部用,默认空字符串 + */ + @JSONField(name="ProjectReference") + private String ProjectReference; + +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/modbus/dto/ChannelModbusTagDTO.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/modbus/dto/ChannelModbusTagDTO.java new file mode 100644 index 0000000..e2a7076 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/modbus/dto/ChannelModbusTagDTO.java @@ -0,0 +1,58 @@ +package com.iailab.module.data.channel.modbus.dto; + +import com.alibaba.fastjson.annotation.JSONField; +import lombok.Data; + +import java.io.Serializable; + +/** + * @author PanZhibao + * @Description + * @createTime 2023年04月23日 14:24:00 + */ +@Data +public class ChannelModbusTagDTO implements Serializable { + private static final long serialVersionUID = 1L; + + /** + * TagName + */ + @JSONField(name="TagName") + private String TagName; + + /** + * tag的数据类型 + */ + @JSONField(name="DataType") + private String DataType; + + /** + * 是否是能tag,如果为false,即使定义了但是runtime不会读取该数据 + */ + @JSONField(name="Enabled") + private Boolean Enabled; + + /** + * 定义大小端 + */ + @JSONField(name="Format") + private String Format; + + /** + * 关联的设备名字 + */ + @JSONField(name="Device") + private String Device; + + /** + * Modbus地址 00001 ~49999 + */ + @JSONField(name="Address") + private String Address; + + /** + * 系统采集频率,只对订阅模式有效 + */ + @JSONField(name="SamplingRate") + private Integer SamplingRate; +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/modbus/entity/ChannelModBusDeviceEntity.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/modbus/entity/ChannelModBusDeviceEntity.java new file mode 100644 index 0000000..6bc525e --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/modbus/entity/ChannelModBusDeviceEntity.java @@ -0,0 +1,85 @@ +package com.iailab.module.data.channel.modbus.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; + +/** + * ModBus设备表 + * + * @author PanZhibao + * @Description + * @createTime 2023年04月24日 10:31:00 + */ +@Data +@TableName("t_channel_modbus_device") +public class ChannelModBusDeviceEntity implements Serializable { + private static final long serialVersionUID = 1L; + + /** + * 主键 + */ + @Schema(description = "主键") + @TableId(value = "id",type = IdType.INPUT) + private String id; + + /** + * 设备名称 + */ + private String name; + + /** + * IP地址 + */ + private String address; + + /** + * 端口 + */ + private Integer port; + + /** + * 不活动超时(ms) + */ + private Integer connectInactivityTimeout; + + /** + * 重连超时(ms) + */ + private Integer reconnectInterval; + + /** + * 重试次数 + */ + private Integer attemptsBeforeTimeout; + + /** + * 重试间隔(ms) + */ + private Integer waitToRetryMilliseconds; + + /** + * 读超时(ms) + */ + private Integer readTimeout; + + /** + * 写超时(ms) + */ + private Integer writeTimeout; + + /** + * 是否使用优化 + */ + private Boolean useOptimizedBlockRead; + + /** + * 系统内部用,默认空字符串 + */ + private String projectReference; + +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/modbus/entity/ChannelModBusTagEntity.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/modbus/entity/ChannelModBusTagEntity.java new file mode 100644 index 0000000..4c24b18 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/modbus/entity/ChannelModBusTagEntity.java @@ -0,0 +1,78 @@ +package com.iailab.module.data.channel.modbus.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; + +/** + * mofbus点表 + * @author DongYuKun + * @Description + * @createTime 2023年04月25日 14:47:00 + */ +@Data +@TableName("t_channel_modbus_tag") +public class ChannelModBusTagEntity implements Serializable { + private static final long serialVersionUID = 1L; + + /** + * 主键 + */ + @Schema(description = "主键") + @TableId(value = "id",type = IdType.INPUT) + private String id; + /** + * TagName + */ + private String tagName; + + /** + * 数据类型 + */ + private String dataType; + + /** + * 是否可以tag,如果为false,即使定义了但是runtime不会读取该数据 + */ + private Boolean enabled; + + /** + * 大小端 + */ + private String format; + + /** + * 关联设备 + */ + private String device; + + /** + * Modbus地址 00001 ~49999 + */ + private String address; + + /** + * 采集频率 + */ + private Integer samplingRate; + + /** + * 描述 + */ + private String tagDesc; + + /** + * 创建时间 + */ + private Date createTime; + + /** + * 修改时间 + */ + private Date updateTime; +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/modbus/service/ChannelModbusDeviceService.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/modbus/service/ChannelModbusDeviceService.java new file mode 100644 index 0000000..85fe38e --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/modbus/service/ChannelModbusDeviceService.java @@ -0,0 +1,60 @@ +package com.iailab.module.data.channel.modbus.service; + +import com.iailab.module.data.common.utils.PageUtils; +import com.iailab.module.data.channel.modbus.dto.ChannelModBusDeviceDTO; +import com.iailab.module.data.channel.modbus.entity.ChannelModBusDeviceEntity; + +import java.util.List; +import java.util.Map; + +/** + * @author PanZhibao + * @Description + * @createTime 2023年04月23日 17:42:00 + */ +public interface ChannelModbusDeviceService { + /** + * 分页查询设备 + * + * @param params + */ + PageUtils queryPage(Map<String, Object> params); + /** + * 添加设备 + * + * @param channelModBusDeviceEntity + */ + void add(ChannelModBusDeviceEntity channelModBusDeviceEntity); + /** + * 修改设备 + * + * @param channelModBusDeviceEntity + */ + void update(ChannelModBusDeviceEntity channelModBusDeviceEntity); + /** + * 删除设备 + * @param id + * + */ + void delete(String id); + /** + * 查询设备详情 + * @param id + * + */ + ChannelModBusDeviceEntity info(String id); + + /** + * 查询设备详情 + * + */ + List<ChannelModBusDeviceDTO> selectAll(); + + /** + * 列表 + * + * @param params + * @return + */ + List<ChannelModBusDeviceEntity> list(Map<String, Object> params); +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/modbus/service/ChannelModbusTagService.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/modbus/service/ChannelModbusTagService.java new file mode 100644 index 0000000..e2abf72 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/modbus/service/ChannelModbusTagService.java @@ -0,0 +1,81 @@ +package com.iailab.module.data.channel.modbus.service; + +import com.iailab.module.data.common.utils.PageUtils; +import com.iailab.module.data.channel.modbus.dto.ChannelModbusTagDTO; +import com.iailab.module.data.channel.modbus.entity.ChannelModBusTagEntity; + +import java.util.List; +import java.util.Map; + +/** + * @author DongYukun + * @Description + * @createTime 2023年05月08日 15:04:00 + */ +public interface ChannelModbusTagService { + /** + * 分页查询tag + * + * @param params + */ + PageUtils queryPage(Map<String, Object> params); + + /** + * 查询tag详情 + * @param id + * + */ + ChannelModBusTagEntity info(String id); + + /** + * 添加tag + * + * @param channelModBusTagEntity + */ + void add(ChannelModBusTagEntity channelModBusTagEntity); + + /** + * 修改tag + * + * @param channelModBusTagEntity + */ + void update(ChannelModBusTagEntity channelModBusTagEntity); + + /** + * 删除tag + * @param id + * + */ + void delete(String id); + + /** + * 查询全部 + * + */ + List<ChannelModbusTagDTO> selectAll(); + + List<ChannelModBusTagEntity> getByDevice(String device); + + /** + * listByIds + * + * @param ids + * @return + */ + List<ChannelModBusTagEntity> listByIds(List<String> ids); + + /** + * 通过deviceName删除 + * + */ + void deleteByDeviceName(String name); + +// /** +// * 导入Tag +// * +// * @param device +// * @param file +// * @throws Exception +// */ +// void importTag(String device, MultipartFile file) throws Exception; +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/modbus/service/impl/ChannelModbusDeviceServiceImpl.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/modbus/service/impl/ChannelModbusDeviceServiceImpl.java new file mode 100644 index 0000000..aaeb70d --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/modbus/service/impl/ChannelModbusDeviceServiceImpl.java @@ -0,0 +1,121 @@ +package com.iailab.module.data.channel.modbus.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.core.toolkit.StringUtils; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.iailab.framework.common.util.object.ConvertUtils; +import com.iailab.module.data.common.utils.PageUtils; +import com.iailab.module.data.common.utils.Query; +import com.iailab.module.data.channel.modbus.dao.ChannelModBusDeviceDao; +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.modbus.service.ChannelModbusTagService; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.util.List; +import java.util.Map; + +/** + * @author PanZhibao + * @Description + * @createTime 2023年04月23日 17:45:00 + */ +@Service +public class ChannelModbusDeviceServiceImpl extends ServiceImpl<ChannelModBusDeviceDao, ChannelModBusDeviceEntity> implements ChannelModbusDeviceService { + @Resource + private ChannelModBusDeviceDao channelModBusDeviceDao; + @Resource + private ChannelModbusTagService channelModbusTagService; + + /** + * 分页查询设备 + * + * @param params + */ + @Override + public PageUtils queryPage(Map<String, Object> params) { + + String name = (String) params.get("name"); + + IPage<ChannelModBusDeviceEntity> page = this.page( + new Query<ChannelModBusDeviceEntity>().getPage(params), + new QueryWrapper<ChannelModBusDeviceEntity>() + .like(StringUtils.isNotBlank(name), "name", name) + .orderByDesc("create_time") + ); + return new PageUtils(page); + } + + /** + * 列表 + * + * @param params + * @return + */ + @Override + public List<ChannelModBusDeviceEntity> list(Map<String, Object> params) { + return channelModBusDeviceDao.selectList(new QueryWrapper<ChannelModBusDeviceEntity>().orderByAsc("name")); + } + + /** + * 添加设备 + * + * @param channelModBusDeviceEntity + */ + @Override + public void add(ChannelModBusDeviceEntity channelModBusDeviceEntity) { + + channelModBusDeviceDao.insert(channelModBusDeviceEntity); + + } + + /** + * 修改设备 + * + * @param channelModBusDeviceEntity + */ + @Override + public void update(ChannelModBusDeviceEntity channelModBusDeviceEntity) { + + channelModBusDeviceDao.updateById(channelModBusDeviceEntity); + } + + /** + * 删除设备 + * + * @param id + */ + @Override + public void delete(String id) { + //先删除device下的tag + channelModbusTagService.deleteByDeviceName(info(id).getName()); + + channelModBusDeviceDao.deleteById(id); + + + } + + /** + * 查询设备详情 + * + * @param id + */ + @Override + public ChannelModBusDeviceEntity info(String id) { + + return channelModBusDeviceDao.selectById(id); + } + + @Override + public List<ChannelModBusDeviceDTO> selectAll() { + + List<ChannelModBusDeviceEntity> entityList = baseMapper.selectList( + null); + + return ConvertUtils.sourceToTarget(entityList, ChannelModBusDeviceDTO.class); + + } +} \ No newline at end of file diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/modbus/service/impl/ChannelModbusTagServiceImpl.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/modbus/service/impl/ChannelModbusTagServiceImpl.java new file mode 100644 index 0000000..824196d --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/modbus/service/impl/ChannelModbusTagServiceImpl.java @@ -0,0 +1,206 @@ +package com.iailab.module.data.channel.modbus.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.core.toolkit.StringUtils; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.iailab.module.data.common.utils.PageUtils; +import com.iailab.module.data.common.utils.Query; +import com.iailab.framework.common.util.object.ConvertUtils; +import com.iailab.module.data.channel.modbus.dto.ChannelModbusTagDTO; +import com.iailab.module.data.channel.modbus.dao.ChannelModBusTagDao; +import com.iailab.module.data.channel.modbus.entity.ChannelModBusTagEntity; +import com.iailab.module.data.channel.modbus.service.ChannelModbusTagService; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.util.List; +import java.util.Map; + +/** + * @author DongYukun + * @Description + * @createTime 2023年05月08日 15:04:00 + */ +@Slf4j +@Service +public class ChannelModbusTagServiceImpl extends ServiceImpl<ChannelModBusTagDao, ChannelModBusTagEntity> implements ChannelModbusTagService { + @Resource + private ChannelModBusTagDao channelModBusTagDao; + + @Value("${iems.upload-dir}") + private String uploadDir; + + /** + * 分页查询tag + * + * @param params + */ + @Override + public PageUtils queryPage(Map<String, Object> params) { + String tagName = (String) params.get("tagName"); + String address = (String) params.get("address"); + String tagDesc = (String) params.get("tagDesc"); + String device = (String) params.get("device"); + + IPage<ChannelModBusTagEntity> page = this.page( + new Query<ChannelModBusTagEntity>().getPage(params), + new QueryWrapper<ChannelModBusTagEntity>() + .like(StringUtils.isNotBlank(tagName), "tag_name", tagName) + .like(StringUtils.isNotBlank(address), "address", address) + .like(StringUtils.isNotBlank(tagDesc), "tag_desc", tagDesc) + .eq(StringUtils.isNotBlank(device), "device", device) + .orderByDesc("create_time") + ); + return new PageUtils(page); + } + + /** + * 查询tag详情 + * + * @param id + */ + @Override + public ChannelModBusTagEntity info(String id) { + return channelModBusTagDao.selectById(id); + } + + /** + * 添加tag + * + * @param channelModBusTagEntity + */ + @Override + public void add(ChannelModBusTagEntity channelModBusTagEntity) { + channelModBusTagDao.insert(channelModBusTagEntity); + } + + /** + * 修改tag + * + * @param channelModBusTagEntity + */ + @Override + public void update(ChannelModBusTagEntity channelModBusTagEntity) { + channelModBusTagDao.updateById(channelModBusTagEntity); + } + + /** + * 删除tag + * + * @param id + */ + @Override + public void delete(String id) { + channelModBusTagDao.deleteById(id); + } + + @Override + public List<ChannelModBusTagEntity> getByDevice(String device) { + QueryWrapper<ChannelModBusTagEntity> queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("device", device); + queryWrapper.orderByDesc("create_time"); + return channelModBusTagDao.selectList(queryWrapper); + } + + /** + * 查询全部 + * + * @return + */ + @Override + public List<ChannelModbusTagDTO> selectAll() { + List<ChannelModBusTagEntity> entityList = baseMapper.selectList( + null + ); + return ConvertUtils.sourceToTarget(entityList, ChannelModbusTagDTO.class); + } + + /** + * listByIds + * + * @param ids + * @return + */ + @Override + public List<ChannelModBusTagEntity> listByIds(List<String> ids) { + return baseMapper.selectList(new QueryWrapper<ChannelModBusTagEntity>().in("id", ids)); + } + + /** + * deleteByDeviceName + * + * @param name + */ + @Override + public void deleteByDeviceName(String name) { + baseMapper.delete(new QueryWrapper<ChannelModBusTagEntity>().eq("device", name)); + } + + //TODO 使用easyExcel重写 +// /** +// * 导入Tag +// * +// * @param device +// * @param file +// * @throws Exception +// */ +// @Override +// @Transactional(rollbackFor = Exception.class) +// public void importTag(String device, MultipartFile file) throws Exception { +// try { +// String suffix = file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf(".")); +// String fileName = UUID.randomUUID().toString() + suffix; +// String path = uploadDir + fileName; +// file.transferTo(new File(path)); +// +// XSSFWorkbook hssfWorkbook = new XSSFWorkbook(new FileInputStream(path)); +// XSSFSheet sheet = hssfWorkbook.getSheetAt(0); +// int lastRowNum = sheet.getLastRowNum(); +// log.info("最后一行:" + lastRowNum); +// int lastCellNum = 6; +// List<ChannelModBusTagEntity> dangerList = new ArrayList<>(); +// for (int i = 1; i <= lastRowNum; i++) { +// XSSFRow row = sheet.getRow(i); +// for (int j = row.getFirstCellNum(); j < lastCellNum; j++) { +// row.getCell(j).setCellType(CellType.STRING); +// } +// ChannelModBusTagEntity tagEntity = new ChannelModBusTagEntity(); +// tagEntity.setId(UUID.randomUUID().toString()); +// tagEntity.setTagName(row.getCell(1).getStringCellValue()); +// tagEntity.setDataType(row.getCell(2).getStringCellValue()); +// tagEntity.setEnabled(true); +// tagEntity.setFormat(""); +// tagEntity.setDevice(device); +// tagEntity.setSamplingRate(0); +// row.getCell(4).setCellType(CellType.STRING); +// System.out.println(row.getCell(3).getStringCellValue()); +// if(row.getCell(3).getStringCellValue().equals("1")){ +// tagEntity.setAddress(String.format("1%04d",Integer.parseInt(row.getCell(4).getStringCellValue()))); +// }else if(row.getCell(3).getStringCellValue().equals("3")){ +// tagEntity.setAddress(String.format("4%04d",Integer.parseInt(row.getCell(4).getStringCellValue()))); +// } +// tagEntity.setTagDesc(row.getCell(5).getStringCellValue()); +// dangerList.add(tagEntity); +// } +// if (CollectionUtils.isEmpty(dangerList)) { +// return; +// } +// //getBaseMapper().insertList(dangerList); +// dangerList.forEach(item -> { +// try { +// getBaseMapper().insert(item); +// } catch (Exception ex) { +// log.warn("插入异常:" + item.getTagName()); +// } +// }); +// } catch (Exception ex) { +// ex.printStackTrace(); +// log.warn("导入失败!"); +// throw ex; +// } +// } + +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/opcua/collector/KeyStoreLoader.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/opcua/collector/KeyStoreLoader.java new file mode 100644 index 0000000..2305414 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/opcua/collector/KeyStoreLoader.java @@ -0,0 +1,58 @@ +package com.iailab.module.data.channel.opcua.collector; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.InputStream; +import java.nio.file.Files; +import java.nio.file.Path; +import java.security.*; +import java.security.cert.X509Certificate; +import java.util.regex.Pattern; + +/** + * @author PanZhibao + * @Description + * @createTime 2022年07月22日 14:44:00 + */ +public class KeyStoreLoader { + + private static final Pattern IP_ADDR_PATTERN = Pattern.compile( + "^(([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\.){3}([01]?\\d\\d?|2[0-4]\\d|25[0-5])$"); + + private static final String CLIENT_ALIAS = "mykey"; + private static final char[] PASSWORD = "keystore".toCharArray(); + + private final Logger logger = LoggerFactory.getLogger(getClass()); + + private X509Certificate clientCertificate; + private KeyPair clientKeyPair; + + KeyStoreLoader load(Path baseDir) throws Exception { + KeyStore keyStore = KeyStore.getInstance("PKCS12"); + + Path serverKeyStore = baseDir.resolve("mykey.pfx"); + + logger.info("Loading KeyStore at {}", serverKeyStore); + + if (Files.exists(serverKeyStore)) { + try (InputStream in = Files.newInputStream(serverKeyStore)) { + keyStore.load(in, PASSWORD); + } + } + + Key serverPrivateKey = keyStore.getKey(CLIENT_ALIAS, PASSWORD); + if (serverPrivateKey instanceof PrivateKey) { + clientCertificate = (X509Certificate) keyStore.getCertificate(CLIENT_ALIAS); + PublicKey serverPublicKey = clientCertificate.getPublicKey(); + clientKeyPair = new KeyPair(serverPublicKey, (PrivateKey) serverPrivateKey); + } + return this; + } + X509Certificate getClientCertificate() { + return clientCertificate; + } + KeyPair getClientKeyPair() { + return clientKeyPair; + } +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/opcua/collector/OpcUaCollector.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/opcua/collector/OpcUaCollector.java new file mode 100644 index 0000000..306e4b2 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/opcua/collector/OpcUaCollector.java @@ -0,0 +1,117 @@ +package com.iailab.module.data.channel.opcua.collector; + +import com.iailab.module.data.common.enums.CommonConstant; +import com.iailab.module.data.common.enums.DataSourceType; +import com.iailab.framework.common.util.object.ConvertUtils; +import com.iailab.module.data.common.utils.TagUtils; +import com.iailab.module.data.channel.opcua.entity.ChannelOPCUADeviceEntity; +import com.iailab.module.data.channel.opcua.service.ChannelOPCUADeviceService; +import com.iailab.module.data.channel.opcua.dto.ChannelOPCUADeviceDTO; +import lombok.extern.slf4j.Slf4j; +import org.eclipse.milo.opcua.sdk.client.OpcUaClient; +import javax.annotation.Resource; +import org.springframework.stereotype.Component; +import org.springframework.util.CollectionUtils; + +import java.math.BigDecimal; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年05月12日 + */ +@Slf4j +@Component +public class OpcUaCollector { + + @Resource + private OpcUaUtils opcUaUtils; + + @Resource + private ChannelOPCUADeviceService channelOPCUADeviceService; + + private Map<String, OpcUaClient> clientMap = new ConcurrentHashMap<>(); + + private Map<String, ChannelOPCUADeviceEntity> deviceMap = new HashMap<>(); + + + private OpcUaClient getClient(String sourceId) throws Exception { + try { + if (!clientMap.containsKey(sourceId)) { + log.info("根据数据源获取Client,sourceId=" + sourceId); + ChannelOPCUADeviceEntity opcuaDevice = channelOPCUADeviceService.info(sourceId); + deviceMap.put(sourceId, opcuaDevice); + ChannelOPCUADeviceDTO configDto = ConvertUtils.sourceToTarget(opcuaDevice, ChannelOPCUADeviceDTO.class); + OpcUaClient opcUaClient = opcUaUtils.createClient(configDto); + if (opcUaClient != null) { + clientMap.put(sourceId, opcUaClient); + } + } + } catch (Exception ex) { + log.info("=========getClient Exception============"); + log.info("ex.message+" + ex.getMessage()); + ex.printStackTrace(); + throw new Exception(ex.getMessage()); + } + OpcUaClient opcUaClient = clientMap.get(sourceId); + if (!opcUaClient.connect().isDone()) { + opcUaClient.connect().get(); + } + return opcUaClient; + } + + public String getTagValue(String sourceId, String tagNo) throws Exception { + OpcUaClient opcUaClient = this.getClient(sourceId); + String value = OpcUaUtils.readNode(opcUaClient, tagNo); + return value; + } + + public void setTagData(String sourceId, String tagNo, String newValue, String dataType) { + try { + OpcUaClient opcUaClient = this.getClient(sourceId); + switch (dataType) { + case "float": + log.debug("Float,TagNo=" + tagNo + ",Value=" + Float.parseFloat(newValue)); + OpcUaUtils.writeFloatValue(opcUaClient, tagNo, Float.parseFloat(newValue)); + break; + case "int": + log.debug("Int,TagNo=" + tagNo + ",Value=" + new BigDecimal(newValue).intValue()); + OpcUaUtils.writeIntValue(opcUaClient, tagNo, new BigDecimal(newValue).intValue()); + break; + case "boolean": + log.debug("Boolean,TagNo=" + tagNo + ",Value=" + newValue); + OpcUaUtils.writeBooleanValue(opcUaClient, tagNo, Boolean.parseBoolean(newValue)); + break; + default: + log.warn("##################### No DataType ####################"); + break; + } + + } catch (Exception ex) { + ex.printStackTrace(); + } + } + + public Map<String, Object> getTagValues(List<String[]> params) { + if (CollectionUtils.isEmpty(params)) { + return new HashMap<>(); + } + Map<String, Object> result = new HashMap<>(params.size()); + params.forEach(item -> { + + try { + OpcUaClient opcUaClient = this.getClient(item[0]); + String value = OpcUaUtils.readNode(opcUaClient, item[1]); + result.put(TagUtils.genTagId(DataSourceType.OPCUA.getCode(), deviceMap.get(item[0]).getServerName(), item[1]), value); + } catch (Exception ex) { + ex.printStackTrace(); + result.put(TagUtils.genTagId(DataSourceType.OPCUA.getCode(), deviceMap.get(item[0]).getServerName(), item[1]), CommonConstant.BAD_VALUE); + } + }); + return result; + } +} \ No newline at end of file diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/opcua/collector/OpcUaUtils.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/opcua/collector/OpcUaUtils.java new file mode 100644 index 0000000..9102add --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/opcua/collector/OpcUaUtils.java @@ -0,0 +1,262 @@ +package com.iailab.module.data.channel.opcua.collector; + +import com.alibaba.fastjson.JSONObject; +import com.iailab.module.data.channel.opcua.dto.ChannelOPCUADeviceDTO; +import lombok.extern.slf4j.Slf4j; +import org.eclipse.milo.opcua.sdk.client.OpcUaClient; +import org.eclipse.milo.opcua.sdk.client.api.config.OpcUaClientConfig; +import org.eclipse.milo.opcua.sdk.client.api.identity.AnonymousProvider; +import org.eclipse.milo.opcua.sdk.client.api.identity.IdentityProvider; +import org.eclipse.milo.opcua.sdk.client.api.identity.UsernameProvider; +import org.eclipse.milo.opcua.sdk.client.nodes.UaNode; +import org.eclipse.milo.opcua.stack.client.DiscoveryClient; +import org.eclipse.milo.opcua.stack.core.Identifiers; +import org.eclipse.milo.opcua.stack.core.security.SecurityPolicy; +import org.eclipse.milo.opcua.stack.core.types.builtin.*; +import org.eclipse.milo.opcua.stack.core.types.enumerated.TimestampsToReturn; +import org.eclipse.milo.opcua.stack.core.types.structured.EndpointDescription; +import org.springframework.stereotype.Component; + +import java.net.URI; +import java.net.URISyntaxException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.List; +import java.util.Objects; + +import static org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.Unsigned.uint; + +/** + * @author PanZhibao + * @Description + * @createTime 2023年05月12日 15:36:00 + */ +@Slf4j +@Component +public class OpcUaUtils { + + private final String CONNECTION_TYPE_USER = "1"; + + private final String SECURITY_POLICY_BASIC256 = "Basic256"; + + private final String SECURITY_POLICY_BASIC128RSA15 = "Basic128Rsa15"; + + private final String SECURITY_POLICY_BASIC256SHA256 = "Basic256Sha256"; + + public synchronized OpcUaClient createClient(ChannelOPCUADeviceDTO configDto) throws Exception { + OpcUaClient opcUaClient = null; + try { + log.info("OpcuaDTO" + JSONObject.toJSONString(configDto)); + + // 加载秘钥 + // Path securityTempDir = Paths.get(System.getProperty("java.io.tmpdir"), "security"); + log.info("加载秘钥"); + Path securityTempDir = Paths.get("D:\\DLUT\\pfx"); + Files.createDirectories(securityTempDir); + if (!Files.exists(securityTempDir)) { + throw new Exception("没有创建安全目录: " + securityTempDir); + } + KeyStoreLoader loader = new KeyStoreLoader().load(securityTempDir); + + // 安全策略 + log.info("安全策略"); + SecurityPolicy securityPolicy = getSecurityPolicy(configDto.getSecurityPolicy()); + + // 验证方式 + log.info("验证方式"); + IdentityProvider identityProvider = getIdentityProvider(configDto); + + // opc.tcp://DESKTOP-D7CDEIF:53530/OPCUA/SimulationServer + // String endpointUrl = "opc.tcp://127.0.0.1:53530"; + log.info("连接端点"); + List<EndpointDescription> endpoints = DiscoveryClient.getEndpoints(configDto.getEndpointUrl()).get(); + endpoints.forEach(item -> { + log.info("EndpointUrl=" + item.getEndpointUrl()); + }); + EndpointDescription endpoint = endpoints.stream() + .filter(e -> e.getSecurityPolicyUri().equals(securityPolicy.getUri())) + .findFirst() + .orElseThrow(() -> new Exception("没有连接上端点")); + + EndpointDescription newEndpoint = updateEndpointUrl(endpoint, getHostFromEndPointUrl(configDto.getEndpointUrl())); + log.info("NewEndpointUrl=" + newEndpoint.getEndpointUrl()); + + OpcUaClientConfig config = OpcUaClientConfig.builder() + .setApplicationName(LocalizedText.english("eclipse milo opc-ua client")) + .setApplicationUri("") + .setCertificate(loader.getClientCertificate()) + .setKeyPair(loader.getClientKeyPair()) + .setEndpoint(newEndpoint) + .setIdentityProvider(identityProvider) + .setRequestTimeout(uint(5000)) + .build(); + + opcUaClient = OpcUaClient.create(config); + log.info("创建客户端完成"); + } catch (Exception e) { + e.printStackTrace(); + log.error("创建客户端失败" + e.getMessage()); + throw new Exception(e.getMessage()); + } + return opcUaClient; + } + + private String getHostFromEndPointUrl (String endPointUrl) { + int indexStart = endPointUrl.lastIndexOf("//"); + int indexEnd = endPointUrl.lastIndexOf(":"); + String host = endPointUrl.substring(indexStart, indexEnd).replace("//",""); + log.info(host); + return host; + } + + private EndpointDescription updateEndpointUrl(EndpointDescription original, String hostname) throws URISyntaxException { + + URI uri = new URI(original.getEndpointUrl()).parseServerAuthority(); + + String endpointUrl = String.format( + "%s://%s:%s%s", + uri.getScheme(), + hostname, + uri.getPort(), + uri.getPath() + ); + + return new EndpointDescription( + endpointUrl, + original.getServer(), + original.getServerCertificate(), + original.getSecurityMode(), + original.getSecurityPolicyUri(), + original.getUserIdentityTokens(), + original.getTransportProfileUri(), + original.getSecurityLevel() + ); + } + + private IdentityProvider getIdentityProvider(ChannelOPCUADeviceDTO configDto) { + switch (configDto.getConnectionType()) { + case CONNECTION_TYPE_USER: + return new UsernameProvider(configDto.getUserName(), configDto.getPassword()); + default: + return new AnonymousProvider(); + } + } + + private SecurityPolicy getSecurityPolicy(String type) { + switch (type) { + case SECURITY_POLICY_BASIC256: + return SecurityPolicy.Basic256; + case SECURITY_POLICY_BASIC128RSA15: + return SecurityPolicy.Basic128Rsa15; + case SECURITY_POLICY_BASIC256SHA256: + return SecurityPolicy.Basic256Sha256; + default: + return SecurityPolicy.None; + } + } + + /** + * 遍历树形节点 + * + * @param client OPC UA客户端 + * @param uaNode 节点 + * @throws Exception + */ + private static void browseNode(OpcUaClient client, UaNode uaNode) throws Exception { + List<? extends UaNode> nodes; + if (uaNode == null) { + nodes = client.getAddressSpace().browseNodes(Identifiers.ObjectsFolder); + } else { + nodes = client.getAddressSpace().browseNodes(uaNode); + } + for (UaNode nd : nodes) { + //排除系统行性节点,这些系统性节点名称一般都是以"_"开头 + if (Objects.requireNonNull(nd.getBrowseName().getName()).contains("_")) { + continue; + } + System.out.println("Node= " + nd.getBrowseName().getName()); + browseNode(client, nd); + } + } + + /** + * 读取节点数据 + * namespaceIndex可以通过UaExpert客户端去查询,一般来说这个值是2。 + * identifier也可以通过UaExpert客户端去查询,这个值=通道名称.设备名称.标记名称 + * + * @param client OPC UA客户端 + * @param nodeIdStr 标识符 + * @throws Exception + */ + public static String readNode(OpcUaClient client, String nodeIdStr) throws Exception { + String[] nodeIdArr = nodeIdStr.split(";"); + + int namespaceIndex = Integer.parseInt(nodeIdArr[0].split("=")[1]); + String identifier = nodeIdArr[1].split("=")[1]; + //节点 + NodeId nodeId = new NodeId(namespaceIndex, identifier); + //读取节点数据 + DataValue value = client.readValue(0.0, TimestampsToReturn.Neither, nodeId).get(); + identifier = String.valueOf(nodeId.getIdentifier()); + System.out.println(identifier + ": " + String.valueOf(value.getValue().getValue())); + return value.getValue().getValue().toString(); + } + + /** + * 写入节点数据 + * + * @param client + * @param nodeIdStr + * @param nodeValue + */ + public static void writeIntValue(OpcUaClient client, String nodeIdStr, Integer nodeValue) { + String[] nodeIdArr = nodeIdStr.split(";"); + + int namespaceIndex = Integer.parseInt(nodeIdArr[0].split("=")[1]); + String identifier = nodeIdArr[1].split("=")[1]; + NodeId nodeId = new NodeId(namespaceIndex, identifier); + DataValue newValue = new DataValue(new Variant(nodeValue), null, null); + //写入节点数据 + StatusCode statusCode = client.writeValue(nodeId, newValue).join(); + System.out.println("结果:" + statusCode.isGood()); + } + + /** + * 写入节点数据 + * + * @param client + * @param nodeIdStr + * @param nodeValue + */ + public static void writeFloatValue(OpcUaClient client, String nodeIdStr, Float nodeValue) { + String[] nodeIdArr = nodeIdStr.split(";"); + + int namespaceIndex = Integer.parseInt(nodeIdArr[0].split("=")[1]); + String identifier = nodeIdArr[1].split("=")[1]; + NodeId nodeId = new NodeId(namespaceIndex, identifier); + DataValue newValue = new DataValue(new Variant(nodeValue), null, null); + //写入节点数据 + StatusCode statusCode = client.writeValue(nodeId, newValue).join(); + System.out.println("结果:" + statusCode.isGood()); + } + + /** + * 写入节点数据 + * + * @param client + * @param nodeIdStr + * @param nodeValue + */ + public static void writeBooleanValue(OpcUaClient client, String nodeIdStr, Boolean nodeValue) { + String[] nodeIdArr = nodeIdStr.split(";"); + + int namespaceIndex = Integer.parseInt(nodeIdArr[0].split("=")[1]); + String identifier = nodeIdArr[1].split("=")[1]; + NodeId nodeId = new NodeId(namespaceIndex, identifier); + DataValue newValue = new DataValue(new Variant(nodeValue), null, null); + //写入节点数据 + StatusCode statusCode = client.writeValue(nodeId, newValue).join(); + System.out.println("结果:" + statusCode.isGood()); + } +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/opcua/collector/RSACertHelper.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/opcua/collector/RSACertHelper.java new file mode 100644 index 0000000..fb094c9 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/opcua/collector/RSACertHelper.java @@ -0,0 +1,101 @@ +package com.iailab.module.data.channel.opcua.collector; + +import com.sun.org.apache.xerces.internal.impl.dv.util.Base64; + +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.security.Key; +import java.security.KeyStore; +import java.security.PublicKey; +import java.security.cert.Certificate; +import java.security.cert.CertificateException; +import java.security.cert.CertificateFactory; + +/** + * @Author: zhangsong + * @Date: 2019/5/28 20:21 + * @Version 1.0 + * 首先需要通过jdk的keytool生成秘钥库等,需确保机器中安装有jdk + * 0.在本代码环境下,执行1命令时,秘钥库的密码和证书的密码须一致,请自行修改路径 + * 请确保路径下无名为mykeystore.keystore的文件,否则可能会报密码错等 + * 1.keytool -genkey -alias mykey -keyalg RSA -keystore C:/Users/Lenovo/AppData/Local/Temp/security/mykeystore.keystore -keysize 1024 -validity 3650 + 2.keytool -export -alias mykey -keystore C:/Users/Lenovo/AppData/Local/Temp/security/mykeystore.keystore -file C:/Users/Lenovo/AppData/Local/Temp/security/mykey.cer + 3.代码中的秘钥库密码为keystore,请自行修改 + 4.查看信息 keytool -list -v -keystore C:/Users/Lenovo/AppData/Local/Temp/security/mykeystore.keystore -storepass "keystore" + * + */ +public class RSACertHelper { + + public static void main(String[] args) { + String path = "C:/Users/Lenovo/AppData/Local/Temp/security/"; + String keyStoreFile = "mykeystore.keystore"; + String passwd = "keystore"; + String keyAlias = "mykey"; + String pfxFile = "mykey.pfx"; + String cerFile = "mykey.cer"; + + System.out.println("请确保已执行完注释中的两条命令再执行本代码\n\n"); + System.out.println("1.开始生成PFX文件"); + coverToPfx(path + keyStoreFile, passwd, keyAlias, path + pfxFile); + System.out.println("==============================================================="); + System.out.println("2.开始提取.cer中的公钥字符串"); + String cerStr = getPubStr(path + cerFile); + System.out.println("从.cer文件中提取的公钥字符串如下:"); + System.out.println(cerStr); + } + + //1生成pfx文件 + public static void coverToPfx(String keyStoreFile, String passwd, String keyAlias, String pfxFile) { + try { + KeyStore inputKeyStore = KeyStore.getInstance("JKS"); + FileInputStream fis = new FileInputStream(keyStoreFile); + char[] nPassword = null; + if ((passwd == null) + || passwd.trim().equals("")) { + nPassword = null; + } else { + nPassword = passwd.toCharArray(); + } + inputKeyStore.load(fis, nPassword); + fis.close(); + KeyStore outputKeyStore = KeyStore.getInstance("PKCS12"); + outputKeyStore.load(null, passwd.toCharArray()); + + if (inputKeyStore.isKeyEntry(keyAlias)) { + Key key = inputKeyStore.getKey(keyAlias, passwd.toCharArray()); + Certificate[] certChain = inputKeyStore + .getCertificateChain(keyAlias); + outputKeyStore.setKeyEntry(keyAlias, key, passwd + .toCharArray(), certChain); + } + + FileOutputStream out = new FileOutputStream(pfxFile); + outputKeyStore.store(out, nPassword); + out.close(); + System.out.println("已生成PFX文件" + pfxFile); + } catch (Exception e) { + e.printStackTrace(); + } + } + + //2获取公钥字符串 + public static String getPubStr(String cerFile) { + String key = ""; + // 读取证书文件 + try { + CertificateFactory cf = CertificateFactory.getInstance("X.509"); + FileInputStream in = new FileInputStream(cerFile); + + //生成一个证书对象并使用从输入流 inStream 中读取的数据对它进行初始化。 + Certificate c = cf.generateCertificate(in); + PublicKey publicKey = c.getPublicKey(); + key = Base64.encode(publicKey.getEncoded()); + } catch (CertificateException e) { + e.printStackTrace(); + } catch (FileNotFoundException e) { + e.printStackTrace(); + } + return key; + } +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/opcua/controller/admin/ChannelOPCUADeviceController.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/opcua/controller/admin/ChannelOPCUADeviceController.java new file mode 100644 index 0000000..4324d41 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/opcua/controller/admin/ChannelOPCUADeviceController.java @@ -0,0 +1,108 @@ +package com.iailab.module.data.channel.opcua.controller.admin; + +import com.iailab.module.data.common.utils.PageUtils; +import com.iailab.module.data.common.utils.R; +import com.iailab.module.data.channel.opcua.entity.ChannelOPCUADeviceEntity; +import com.iailab.module.data.channel.opcua.service.ChannelOPCUADeviceService; +import javax.annotation.Resource; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; + +import java.io.File; +import java.io.IOException; +import java.util.Map; +import java.util.UUID; + +/** + * 操作opc ua配置 + * + * @author DongYukun + * @createTime 2023年04月26日 10:33:00 + */ +@RestController +@RequestMapping("/data/channel/opcua/device") +public class ChannelOPCUADeviceController { + @Resource + private ChannelOPCUADeviceService channelOPCUADeviceService; + + /** + * 分页查询opc ua 配置 + * + * @param params + */ + @GetMapping("/list") + public R list(@RequestParam Map<String, Object> params) { + PageUtils page = channelOPCUADeviceService.queryPage(params); + + return R.ok().put("page", page); + } + + /** + * 根据id查询opc ua配置详情 + * + * @param id + */ + @GetMapping("/info/{id}") + public R info(@PathVariable("id") String id) { + ChannelOPCUADeviceEntity info = channelOPCUADeviceService.info(id); + return R.ok().put("data", info); + } + + /** + * 添加opc ua配置 + * + * @param channelOPCUADeviceEntity + */ + @PostMapping("/add") + public R add(@RequestBody ChannelOPCUADeviceEntity channelOPCUADeviceEntity) { + String id = UUID.randomUUID().toString(); + channelOPCUADeviceEntity.setId(id); + channelOPCUADeviceService.add(channelOPCUADeviceEntity); + return R.ok(); + } + + /** + * 修改opc ua配置 + * + * @param channelOPCUADeviceEntity + */ + @PostMapping("/update") + public R update(@RequestBody ChannelOPCUADeviceEntity channelOPCUADeviceEntity) { + channelOPCUADeviceService.update(channelOPCUADeviceEntity); + return R.ok(); + } + + /** + * 删除opc ua配置 + * + * @param params + */ + @PostMapping("/delete") + public R delete(@RequestBody Map<String, Object> params) { + String id = (String) params.get("id"); + channelOPCUADeviceService.delete(id); + return R.ok(); + } + /** + * 上传安全证书 + * + * @param file + */ + @PostMapping("/upload") + public R uploadFile(@RequestParam("file") MultipartFile file) { + String fileName = file.getOriginalFilename(); + String filePath = ""; + try { + File dir = new File(filePath); + if (!dir.exists()) { + dir.mkdirs(); + } + File saveFile = new File(filePath + fileName); + file.transferTo(saveFile); + return R.ok().put("data",saveFile.getAbsolutePath()); + } catch (IOException e) { + e.printStackTrace(); + return R.error(); + } + } +} \ No newline at end of file diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/opcua/controller/admin/ChannelOPCUATagController.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/opcua/controller/admin/ChannelOPCUATagController.java new file mode 100644 index 0000000..ca2b965 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/opcua/controller/admin/ChannelOPCUATagController.java @@ -0,0 +1,102 @@ +package com.iailab.module.data.channel.opcua.controller.admin; + +import com.iailab.module.data.common.exception.RRException; +import com.iailab.module.data.common.utils.PageUtils; +import com.iailab.module.data.common.utils.R; +import com.iailab.module.data.channel.opcua.entity.ChannelOPCUATagEntity; +import com.iailab.module.data.channel.opcua.service.ChannelOPCUATagService; +import com.sun.xml.internal.messaging.saaj.util.Base64; +import javax.annotation.Resource; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; + +import java.util.Map; +import java.util.UUID; + +/** + * 操作opcua tag配置 + * + * @author DongYukun + * @createTime 2023年05月6日 17:44:00 + */ +@RestController +@RequestMapping("/data/channel/opcua/tag") +public class ChannelOPCUATagController { + @Resource + private ChannelOPCUATagService channelOpcuaTagService; + /** + * 分页查询tag + * + * @param params + */ + @GetMapping("/list") + public R tagList(@RequestParam Map<String, Object> params){ + PageUtils page = channelOpcuaTagService.queryPage(params); + + return R.ok().put("page", page); + } + /** + * 根据id查询tag详情 + * + * @param id + */ + @GetMapping("/info/{id}") + public R tagInfo(@PathVariable("id") String id){ + ChannelOPCUATagEntity info= channelOpcuaTagService.info(Base64.base64Decode(id)); + return R.ok().put("data", info); + } + /** + * 添加tag + * + * @param entity + */ + @PostMapping("/add") + public R tagAdd(@RequestBody ChannelOPCUATagEntity entity){ + entity.setId(UUID.randomUUID().toString()); + channelOpcuaTagService.add(entity); + return R.ok(); + } + + /** + * 修改tag + * + * @param channelOPCUATagEntity + */ + @PostMapping("/update") + public R tagUpdate(@RequestBody ChannelOPCUATagEntity channelOPCUATagEntity) { + channelOpcuaTagService.update(channelOPCUATagEntity); + return R.ok(); + } + + /** + * 删除tag + * @param params + * + */ + @PostMapping("/delete") + public R tagDelete(@RequestBody Map<String, Object> params) { + String id = (String)params.get("id"); + channelOpcuaTagService.delete(id); + return R.ok(); + } + + /** + * 导入 + * + * @param device + * @param file + * @return + */ + @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(); + } +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/opcua/controller/package-info.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/opcua/controller/package-info.java new file mode 100644 index 0000000..8a3bd64 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/opcua/controller/package-info.java @@ -0,0 +1 @@ +package com.iailab.module.data.channel.opcua.controller; \ No newline at end of file diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/opcua/dao/ChannelOPCUADeviceDao.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/opcua/dao/ChannelOPCUADeviceDao.java new file mode 100644 index 0000000..6964cb8 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/opcua/dao/ChannelOPCUADeviceDao.java @@ -0,0 +1,19 @@ +package com.iailab.module.data.channel.opcua.dao; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.iailab.module.data.channel.opcua.entity.ChannelOPCUADeviceEntity; +import com.iailab.module.data.channel.opcua.entity.ChannelOPCUADeviceEntity; +import com.iailab.module.data.channel.opcua.entity.ChannelOPCUADeviceEntity; +import com.iailab.module.data.channel.opcua.entity.ChannelOPCUADeviceEntity; +import org.apache.ibatis.annotations.Mapper; + + +/** + * @author PanZhibao + * @Description + * @createTime 2023年04月26日 11:31:00 + */ +@Mapper +public interface ChannelOPCUADeviceDao extends BaseMapper<ChannelOPCUADeviceEntity> { + +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/opcua/dao/ChannelOPCUATagDao.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/opcua/dao/ChannelOPCUATagDao.java new file mode 100644 index 0000000..52abf4a --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/opcua/dao/ChannelOPCUATagDao.java @@ -0,0 +1,17 @@ +package com.iailab.module.data.channel.opcua.dao; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.iailab.module.data.channel.opcua.entity.ChannelOPCUATagEntity; +import com.iailab.module.data.channel.opcua.entity.ChannelOPCUATagEntity; +import com.iailab.module.data.channel.opcua.entity.ChannelOPCUATagEntity; +import com.iailab.module.data.channel.opcua.entity.ChannelOPCUATagEntity; +import org.apache.ibatis.annotations.Mapper; + +/** + * @author DongYukun + * @Description + * @createTime 2023年05月8日 15:01:00 + */ +@Mapper +public interface ChannelOPCUATagDao extends BaseMapper<ChannelOPCUATagEntity> { +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/opcua/dto/ChannelOPCUADeviceDTO.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/opcua/dto/ChannelOPCUADeviceDTO.java new file mode 100644 index 0000000..2a29dbd --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/opcua/dto/ChannelOPCUADeviceDTO.java @@ -0,0 +1,76 @@ +package com.iailab.module.data.channel.opcua.dto; + +import com.alibaba.fastjson.annotation.JSONField; +import lombok.Data; + +import java.io.Serializable; + +/** + * @author PanZhibao + * @Description + * @createTime 2023年04月23日 14:25:00 + */ +@Data +public class ChannelOPCUADeviceDTO implements Serializable { + private static final long serialVersionUID = 1L; + + /** + * ServerName + */ + @JSONField(name="ServerName") + private String ServerName; + + + /** + * EndpointUrl + */ + @JSONField(name="EndpointUrl") + private String EndpointUrl; + + /** + * SecurityPolicy + */ + @JSONField(name="SecurityPolicy") + private String SecurityPolicy; + + /** + * SecurityMode + */ + @JSONField(name="SecurityMode") + private String SecurityMode; + + /** + * 连接方式(0,匿名;1,用户名密码; 2,安全证书) + */ + @JSONField(name="ConnectionType") + private String ConnectionType; + + /** + * 用户名 + */ + @JSONField(name="UserName") + private String UserName; + + /** + * 密码 + */ + @JSONField(name="Password") + private String Password; + + /** + * 安全证书路径 + */ + @JSONField(name="CertificatePath") + private String CertificatePath; + + /** + * 设备不活动超时时间 + */ + @JSONField(name="ConnectInactivityTimeout") + private Integer ConnectInactivityTimeout; + /** + * 重连超时 + */ + @JSONField(name="ConnectInactivityTimeout") + private Integer ReconnectInterval; +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/opcua/dto/ChannelOPCUATagDTO.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/opcua/dto/ChannelOPCUATagDTO.java new file mode 100644 index 0000000..43c022b --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/opcua/dto/ChannelOPCUATagDTO.java @@ -0,0 +1,52 @@ +package com.iailab.module.data.channel.opcua.dto; + +import com.alibaba.fastjson.annotation.JSONField; +import lombok.Data; + +import java.io.Serializable; + +/** + * @author DongYukun + * @Description + * @createTime 2023年05月8日 15:01:00 + */ +@Data +public class ChannelOPCUATagDTO implements Serializable { + private static final long serialVersionUID = 1L; + + /** + * TagName + */ + @JSONField(name="TagName") + private String TagName; + + /** + * tag的数据类型 + */ + @JSONField(name="DataType") + private String DataType; + + /** + * 是否是能tag,如果为false,即使定义了但是runtime不会读取该数据 + */ + @JSONField(name="Enabled") + private Boolean Enabled; + + /** + * 关联的设备名字 + */ + @JSONField(name="Device") + private String Device; + + /** + * Modbus地址 00001 ~49999 + */ + @JSONField(name="Address") + private String Address; + + /** + * 系统采集频率,只对订阅模式有效 + */ + @JSONField(name="SamplingRate") + private Integer SamplingRate; +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/opcua/entity/ChannelOPCUADeviceEntity.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/opcua/entity/ChannelOPCUADeviceEntity.java new file mode 100644 index 0000000..4f275ec --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/opcua/entity/ChannelOPCUADeviceEntity.java @@ -0,0 +1,77 @@ +package com.iailab.module.data.channel.opcua.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; + +/** + * @author DongYuKun + * @Description OPC UA + * @createTime 2023年04月26日 9:30:00 + */ +@Data +@TableName("t_channel_opcua_device") +public class ChannelOPCUADeviceEntity implements Serializable { + private static final long serialVersionUID = 1L; + + /** + * 主键 + */ + @Schema(description = "主键") + @TableId(value = "id",type = IdType.INPUT) + private String id; + /** + * ServerName 服务名 + */ + private String serverName; + + + /** + * EndpointUrl 端点URL + */ + private String endpointUrl; + + /** + * SecurityPolicy 安全策略 + */ + private String securityPolicy; + + /** + * SecurityMode 安全模式 + */ + private String securityMode; + + /** + * 连接方式(0,匿名;1,用户名密码; 2,安全证书) + */ + private String connectionType; + + /** + * 用户名 + */ + private String userName; + + /** + * 密码 + */ + private String password; + + /** + * 安全证书路径 + */ + private String certificatePath; + + /** + * 设备不活动超时时间 + */ + private Integer connectInactivityTimeout; + /** + * 重连超时 + */ + private Integer reconnectInterval; +} + diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/opcua/entity/ChannelOPCUATagEntity.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/opcua/entity/ChannelOPCUATagEntity.java new file mode 100644 index 0000000..fb489c5 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/opcua/entity/ChannelOPCUATagEntity.java @@ -0,0 +1,70 @@ +package com.iailab.module.data.channel.opcua.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; + +/** + * opc ua点表 + * + * @author DongYukun + * @Description + * @createTime 2023年05月8日 15:01:00 + */ +@Data +@TableName("t_channel_opcda_tag") +public class ChannelOPCUATagEntity implements Serializable { + private static final long serialVersionUID = 1L; + + /** + * 主键 + */ + @Schema(description = "主键") + @TableId(value = "id",type = IdType.INPUT) + private String id; + /** + * TagName + */ + private String tagName; + + /** + * 数据类型 + */ + private String dataType; + + /** + * 是否可以tag,如果为false,即使定义了但是runtime不会读取该数据 + */ + private Boolean enabled; + + /** + * 关联设备 + */ + private String device; + + /** + * Modbus地址 00001 ~49999 + */ + private String address; + + /** + * 采集频率 + */ + private Integer samplingRate; + + /** + * 创建时间 + */ + private Date createTime; + + /** + * 修改时间 + */ + private Date updateTime; + +} \ No newline at end of file diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/opcua/service/ChannelOPCUADeviceService.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/opcua/service/ChannelOPCUADeviceService.java new file mode 100644 index 0000000..cf66752 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/opcua/service/ChannelOPCUADeviceService.java @@ -0,0 +1,60 @@ +package com.iailab.module.data.channel.opcua.service; + +import com.iailab.module.data.common.utils.PageUtils; +import com.iailab.module.data.channel.opcua.entity.ChannelOPCUADeviceEntity; +import com.iailab.module.data.channel.opcua.dto.ChannelOPCUADeviceDTO; + +import java.util.List; +import java.util.Map; + +/** + * @author DongYukun + * @Description + * @createTime 2023年05月08日 15:04:00 + */ +public interface ChannelOPCUADeviceService { + /** + * 分页查询设备 + * + * @param params + */ + PageUtils queryPage(Map<String, Object> params); + /** + * 查询设备详情 + * + * @param id + */ + ChannelOPCUADeviceEntity info(String id); + + /** + * 列表 + * + * @param params + * @return + */ + List<ChannelOPCUADeviceEntity> list(Map<String, Object> params); + + /** + * 添加设备 + * + * @param channelOPCUADeviceEntity + */ + void add(ChannelOPCUADeviceEntity channelOPCUADeviceEntity); + /** + * 修改设备 + * + * @param channelOPCUADeviceEntity + */ + void update(ChannelOPCUADeviceEntity channelOPCUADeviceEntity); + /** + * 删除设备 + * + * @param id + */ + void delete(String id); + /** + * 查询全部设备 + * + */ + List<ChannelOPCUADeviceDTO> selectAll(); +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/opcua/service/ChannelOPCUATagService.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/opcua/service/ChannelOPCUATagService.java new file mode 100644 index 0000000..a470e2c --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/opcua/service/ChannelOPCUATagService.java @@ -0,0 +1,70 @@ +package com.iailab.module.data.channel.opcua.service; + +import com.iailab.module.data.common.utils.PageUtils; +import com.iailab.module.data.channel.opcua.dto.ChannelOPCUATagDTO; +import com.iailab.module.data.channel.opcua.entity.ChannelOPCUATagEntity; +import org.springframework.web.multipart.MultipartFile; + +import java.util.List; +import java.util.Map; + +/** + * @author DongYukun + * @Description + * @createTime 2023年05月08日 15:04:00 + */ +public interface ChannelOPCUATagService { + /** + * 分页查询tag + * + * @param params + */ + PageUtils queryPage(Map<String, Object> params); + + /** + * 查询tag详情 + * @param id + * + */ + ChannelOPCUATagEntity info(String id); + /** + * 添加tag + * + * @param channelOPCUATagEntity + */ + void add(ChannelOPCUATagEntity channelOPCUATagEntity); + /** + * 修改tag + * + * @param channelOPCUATagEntity + */ + void update(ChannelOPCUATagEntity channelOPCUATagEntity); + /** + * 删除tag + * @param id + * + */ + void delete(String id); + + List<ChannelOPCUATagEntity> getByDevice(String device); + + + List<ChannelOPCUATagDTO> selectAll(); + + List<ChannelOPCUATagEntity> listByIds(List<String> ids); + + /** + * 通过deviceName删除 + * + */ + void deleteByDeviceName(String name); + + /** + * 导入Tag + * + * @param device + * @param file + * @throws Exception + */ + void importTag(String device, MultipartFile file) throws Exception; +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/opcua/service/impl/ChannelOPCUADeviceServiceImpl.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/opcua/service/impl/ChannelOPCUADeviceServiceImpl.java new file mode 100644 index 0000000..52651bf --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/opcua/service/impl/ChannelOPCUADeviceServiceImpl.java @@ -0,0 +1,114 @@ +package com.iailab.module.data.channel.opcua.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.core.toolkit.StringUtils; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.iailab.framework.common.util.object.ConvertUtils; +import com.iailab.module.data.common.utils.PageUtils; +import com.iailab.module.data.common.utils.Query; +import com.iailab.module.data.channel.opcua.dao.ChannelOPCUADeviceDao; +import com.iailab.module.data.channel.opcua.entity.ChannelOPCUADeviceEntity; +import com.iailab.module.data.channel.opcua.service.ChannelOPCUADeviceService; +import com.iailab.module.data.channel.opcua.service.ChannelOPCUATagService; +import com.iailab.module.data.channel.opcua.dto.ChannelOPCUADeviceDTO; +import javax.annotation.Resource; +import org.springframework.stereotype.Service; + +import java.util.List; +import java.util.Map; + +/** + * @author DongYukun + * @Description + * @createTime 2023年05月08日 15:04:00 + */ +@Service +public class ChannelOPCUADeviceServiceImpl extends ServiceImpl<ChannelOPCUADeviceDao, ChannelOPCUADeviceEntity> implements ChannelOPCUADeviceService { + @Resource + private ChannelOPCUADeviceDao channelOPCUADeviceDao; + + @Resource + private ChannelOPCUATagService channelOPCUATagService; + /** + * 分页查询opc ua配置 + * + * @param params + */ + @Override + public PageUtils queryPage(Map<String, Object> params) { + String serverName = (String) params.get("serverName"); + + IPage<ChannelOPCUADeviceEntity> page = this.page( + new Query<ChannelOPCUADeviceEntity>().getPage(params), + new QueryWrapper<ChannelOPCUADeviceEntity>() + .like(StringUtils.isNotBlank(serverName), "server_name", serverName) + .orderByDesc("create_time") + ); + return new PageUtils(page); + } + + /** + * 查询opc ua配置详情 + * + * @param id + */ + @Override + public ChannelOPCUADeviceEntity info(String id) { + return channelOPCUADeviceDao.selectById(id); + } + + /** + * 列表 + * + * @param params + * @return + */ + @Override + public List<ChannelOPCUADeviceEntity> list(Map<String, Object> params) { + return channelOPCUADeviceDao.selectList(new QueryWrapper<ChannelOPCUADeviceEntity>().orderByAsc("server_name")); + } + + /** + * 添加opc ua配置 + * + * @param channelOPCUADeviceEntity + */ + @Override + public void add(ChannelOPCUADeviceEntity channelOPCUADeviceEntity) { + channelOPCUADeviceDao.insert(channelOPCUADeviceEntity); + } + + /** + * 修改opc ua配置 + * + * @param channelOPCUADeviceEntity + */ + @Override + public void update(ChannelOPCUADeviceEntity channelOPCUADeviceEntity) { + channelOPCUADeviceDao.updateById(channelOPCUADeviceEntity); + } + + /** + * 删除opc ua配置 + * + * @param id + */ + @Override + public void delete(String id) { + + //先删除device下的tag + channelOPCUATagService.deleteByDeviceName(info(id).getServerName()); + + channelOPCUADeviceDao.deleteById(id); + } + + @Override + public List<ChannelOPCUADeviceDTO> selectAll() { + + List<ChannelOPCUADeviceEntity> entityList = baseMapper.selectList( + null + ); + return ConvertUtils.sourceToTarget(entityList, ChannelOPCUADeviceDTO.class); + } +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/opcua/service/impl/ChannelOPCUATagServiceImpl.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/opcua/service/impl/ChannelOPCUATagServiceImpl.java new file mode 100644 index 0000000..f8ba635 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/opcua/service/impl/ChannelOPCUATagServiceImpl.java @@ -0,0 +1,193 @@ +package com.iailab.module.data.channel.opcua.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; +import com.baomidou.mybatisplus.core.toolkit.StringUtils; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.iailab.framework.common.util.object.ConvertUtils; +import com.iailab.module.data.common.utils.PageUtils; +import com.iailab.module.data.common.utils.Query; +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 lombok.extern.slf4j.Slf4j; +import org.apache.poi.ss.usermodel.CellType; +import org.apache.poi.xssf.usermodel.XSSFRow; +import org.apache.poi.xssf.usermodel.XSSFSheet; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.web.multipart.MultipartFile; + +import javax.annotation.Resource; +import java.io.File; +import java.io.FileInputStream; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.UUID; + +/** + * @author DongYukun + * @Description + * @createTime 2023年05月08日 15:04:00 + */ +@Slf4j +@Service +public class ChannelOPCUATagServiceImpl extends ServiceImpl<ChannelOPCUATagDao, ChannelOPCUATagEntity> implements ChannelOPCUATagService { + @Resource + private ChannelOPCUATagDao channelOPCUATagDao; + + @Value("${iems.upload-dir}") + private String uploadDir; + + /** + * 分页查询tag + * + * @param params + */ + @Override + public PageUtils queryPage(Map<String, Object> params) { + String tagName = (String) params.get("tagName"); + String device = (String) params.get("device"); + + IPage<ChannelOPCUATagEntity> page = this.page( + new Query<ChannelOPCUATagEntity>().getPage(params), + new QueryWrapper<ChannelOPCUATagEntity>() + .like(StringUtils.isNotBlank(tagName), "tag_name", tagName) + .eq(StringUtils.isNotBlank(device), "device", device) + .orderByDesc("create_time") + ); + return new PageUtils(page); + } + + /** + * 查询tag详情 + * + * @param id + */ + @Override + public ChannelOPCUATagEntity info(String id) { + return channelOPCUATagDao.selectById(id); + } + + @Override + public List<ChannelOPCUATagEntity> getByDevice(String device) { + QueryWrapper<ChannelOPCUATagEntity> queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("device", device).orderByDesc ("create_time"); + return channelOPCUATagDao.selectList(queryWrapper); + + } + + /** + * 添加tag + * + * @param channelOPCUATagEntity + */ + @Override + public void add(ChannelOPCUATagEntity channelOPCUATagEntity) { + channelOPCUATagDao.insert(channelOPCUATagEntity); + } + + /** + * 修改tag + * + * @param channelOPCUATagEntity + */ + @Override + public void update(ChannelOPCUATagEntity channelOPCUATagEntity) { + channelOPCUATagDao.updateById(channelOPCUATagEntity); + } + + /** + * 删除tag + * + * @param id + */ + @Override + public void delete(String id) { + channelOPCUATagDao.deleteById(id); + } + + @Override + public List<ChannelOPCUATagDTO> selectAll() { + + List<ChannelOPCUATagEntity> entityList = baseMapper.selectList( + null + ); + return ConvertUtils.sourceToTarget(entityList, ChannelOPCUATagDTO.class); + } + + @Override + public List<ChannelOPCUATagEntity> listByIds(List<String> ids) { + return baseMapper.selectList(new QueryWrapper<ChannelOPCUATagEntity>().in("id", ids)); + } + + @Override + public void deleteByDeviceName(String name) { + baseMapper.delete(new QueryWrapper<ChannelOPCUATagEntity>().eq("device",name)); + } + + /** + * 导入Tag + * + * @param device + * @param file + * @throws Exception + */ + @Override + @Transactional(rollbackFor = Exception.class) + public void importTag(String device, MultipartFile file) throws Exception { + try { + String suffix = file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf(".")); + String fileName = UUID.randomUUID().toString() + suffix; + String path = uploadDir + fileName; + file.transferTo(new File(path)); + + XSSFWorkbook hssfWorkbook = new XSSFWorkbook(new FileInputStream(path)); + XSSFSheet sheet = hssfWorkbook.getSheetAt(0); + int lastRowNum = sheet.getLastRowNum(); + log.info("最后一行:" + lastRowNum); + int lastCellNum = 4; + List<ChannelOPCUATagEntity> dangerList = new ArrayList<>(); + for (int i = 2; i <= lastRowNum; i++) { + XSSFRow row = sheet.getRow(i); + for (int j = row.getFirstCellNum(); j < lastCellNum; j++) { + row.getCell(j).setCellType(CellType.STRING); + } + ChannelOPCUATagEntity tagEntity = new ChannelOPCUATagEntity(); + tagEntity.setId(UUID.randomUUID().toString()); + tagEntity.setTagName(row.getCell(1).getStringCellValue()); + tagEntity.setDataType(row.getCell(2).getStringCellValue()); + row.getCell(4).setCellType(CellType.STRING); + if(row.getCell(3).getStringCellValue().equals("1")){ + tagEntity.setAddress(String.format("1%04d",Integer.parseInt(row.getCell(4).getStringCellValue()))); + }else if(row.getCell(3).getStringCellValue().equals("3")){ + tagEntity.setAddress(String.format("4%04d",Integer.parseInt(row.getCell(4).getStringCellValue()))); + } + tagEntity.setEnabled(true); + tagEntity.setDevice(device); + tagEntity.setSamplingRate(1); + dangerList.add(tagEntity); + } + if (CollectionUtils.isEmpty(dangerList)) { + return; + } + //getBaseMapper().insertList(dangerList); + dangerList.forEach(item -> { + try { + getBaseMapper().insert(item); + } catch (Exception ex) { + log.warn("插入异常:" + item.getTagName()); + } + }); + } catch (Exception ex) { + ex.printStackTrace(); + log.warn("导入失败!"); + throw ex; + } + } +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/tag/controller/TagController.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/tag/controller/TagController.java new file mode 100644 index 0000000..54cb417 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/tag/controller/TagController.java @@ -0,0 +1,173 @@ +package com.iailab.module.data.channel.tag.controller; + +import com.iailab.module.data.common.enums.DataSourceType; +import com.iailab.framework.common.pojo.CommonResult; +import com.iailab.module.data.channel.kio.dto.ChannelKioDeviceDTO; +import com.iailab.module.data.channel.kio.service.ChannelKioDeviceService; +import com.iailab.module.data.channel.kio.service.ChannelKioTagService; +import com.iailab.module.data.channel.modbus.entity.ChannelModBusDeviceEntity; +import com.iailab.module.data.channel.modbus.entity.ChannelModBusTagEntity; +import com.iailab.module.data.channel.modbus.service.ChannelModbusDeviceService; +import com.iailab.module.data.channel.modbus.service.ChannelModbusTagService; +import com.iailab.module.data.channel.opcua.entity.ChannelOPCUADeviceEntity; +import com.iailab.module.data.channel.opcua.service.ChannelOPCUADeviceService; +import com.iailab.module.data.channel.opcua.service.ChannelOPCUATagService; +import com.iailab.module.data.channel.tag.dto.TagOptionDTO; +import com.iailab.module.data.http.entity.HttpApiEntity; +import com.iailab.module.data.http.entity.HttpTagEntity; +import com.iailab.module.data.http.service.HttpApiService; +import com.iailab.module.data.channel.kio.dto.ChannelKioTagDTO; +import com.iailab.module.data.channel.opcua.entity.ChannelOPCUATagEntity; +import com.iailab.module.data.http.service.HttpTagService; +import javax.annotation.Resource; +import org.springframework.util.CollectionUtils; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年05月16日 + */ +@RestController +@RequestMapping("/channel/tag") +public class TagController { + + @Resource + private ChannelOPCUADeviceService channelOPCUADeviceService; + + @Resource + private ChannelOPCUATagService channelOPCUATagService; + + @Resource + private ChannelModbusDeviceService channelModbusDeviceService; + + @Resource + private ChannelModbusTagService channelModbusTagService; + + @Resource + private ChannelKioDeviceService channelKioDeviceService; + + @Resource + private ChannelKioTagService channelKioTagService; + + @Resource + private HttpApiService httpApiService; + + @Resource + private HttpTagService tagService; + + + @GetMapping("tree") + public CommonResult<List<TagOptionDTO>> tagTree() { + List<TagOptionDTO> result = new ArrayList<>(); + + TagOptionDTO opcuaData = new TagOptionDTO(); + opcuaData.setValue(DataSourceType.OPCUA.getCode()); + opcuaData.setLabel(DataSourceType.OPCUA.getDesc()); + List<ChannelOPCUADeviceEntity> opcuaDeviceList = channelOPCUADeviceService.list(new HashMap<>()); + List<TagOptionDTO> opcuaDeviceOp = new ArrayList<>(); + if (!CollectionUtils.isEmpty(opcuaDeviceList)) { + opcuaDeviceList.forEach(item -> { + TagOptionDTO op1 = new TagOptionDTO(); + op1.setValue(item.getId()); + op1.setLabel(item.getServerName()); + List<ChannelOPCUATagEntity> tags = channelOPCUATagService.getByDevice(item.getServerName()); + List<TagOptionDTO> op2 = new ArrayList<>(); + tags.forEach(item1 -> { + TagOptionDTO op3 = new TagOptionDTO(); + op3.setValue(item1.getTagName()); + op3.setLabel(item1.getTagName()); + op2.add(op3); + }); + op1.setChildren(op2); + opcuaDeviceOp.add(op1); + }); + } + opcuaData.setChildren(opcuaDeviceOp); + result.add(opcuaData); + + TagOptionDTO modbusData = new TagOptionDTO(); + modbusData.setValue(DataSourceType.ModBus.getCode()); + modbusData.setLabel(DataSourceType.ModBus.getDesc()); + List<ChannelModBusDeviceEntity> modbusList = channelModbusDeviceService.list(new HashMap<>()); + List<TagOptionDTO> modbusDeviceOp = new ArrayList<>(); + if (!CollectionUtils.isEmpty(modbusList)) { + modbusList.forEach(item -> { + TagOptionDTO op1 = new TagOptionDTO(); + op1.setValue(item.getId()); + op1.setLabel(item.getName()); + List<ChannelModBusTagEntity> tags = channelModbusTagService.getByDevice(item.getName()); + List<TagOptionDTO> op2 = new ArrayList<>(); + tags.forEach(item1 -> { + TagOptionDTO op3 = new TagOptionDTO(); + op3.setValue(item1.getTagName()); + op3.setLabel(item1.getTagName()); + op2.add(op3); + }); + op1.setChildren(op2); + modbusDeviceOp.add(op1); + }); + } + modbusData.setChildren(modbusDeviceOp); + result.add(modbusData); + + + TagOptionDTO kioData = new TagOptionDTO(); + kioData.setValue(DataSourceType.KIO.getCode()); + kioData.setLabel(DataSourceType.KIO.getDesc()); + List<ChannelKioDeviceDTO> kioList = channelKioDeviceService.list(new HashMap<>()); + List<TagOptionDTO> kioDeviceOp = new ArrayList<>(); + if (!CollectionUtils.isEmpty(kioList)) { + kioList.forEach(item -> { + TagOptionDTO op1 = new TagOptionDTO(); + op1.setValue(item.getId()); + op1.setLabel(item.getInstanceName()); + List<ChannelKioTagDTO> tags = channelKioTagService.getByDevice(item.getInstanceName()); + List<TagOptionDTO> op2 = new ArrayList<>(); + tags.forEach(item1 -> { + TagOptionDTO op3 = new TagOptionDTO(); + op3.setValue(item1.getTagName()); + op3.setLabel(item1.getTagName()); + op2.add(op3); + }); + op1.setChildren(op2); + kioDeviceOp.add(op1); + }); + } + kioData.setChildren(kioDeviceOp); + result.add(kioData); + + TagOptionDTO httpApiData = new TagOptionDTO(); + httpApiData.setValue(DataSourceType.HTTP.getCode()); + httpApiData.setLabel(DataSourceType.HTTP.getDesc()); + List<HttpApiEntity> httpApiList = httpApiService.list(); + List<TagOptionDTO> httpApiOp = new ArrayList<>(); + if (!CollectionUtils.isEmpty(httpApiList)) { + httpApiList.forEach(item -> { + TagOptionDTO op1 = new TagOptionDTO(); + op1.setValue(item.getId()); + op1.setLabel(item.getName()); + List<HttpTagEntity> tags = tagService.getByCode(item.getCode()); + List<TagOptionDTO> op2 = new ArrayList<>(); + tags.forEach(item1 -> { + TagOptionDTO op3 = new TagOptionDTO(); + op3.setValue(item1.getTagCode()); + op3.setLabel(item1.getTagCode()); + op2.add(op3); + }); + op1.setChildren(op2); + httpApiOp.add(op1); + }); + } + httpApiData.setChildren(httpApiOp); + result.add(httpApiData); + + return new CommonResult().setData(result); + } +} \ No newline at end of file diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/tag/dto/TagDTO.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/tag/dto/TagDTO.java new file mode 100644 index 0000000..60a643c --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/tag/dto/TagDTO.java @@ -0,0 +1,56 @@ +package com.iailab.module.data.channel.tag.dto; + +import lombok.Data; + +import java.io.Serializable; +import java.util.List; + +/** + * @author PanZhibao + * @Description + * @createTime 2023年04月23日 17:26:00 + */ +@Data +public class TagDTO implements Serializable { + private static final long serialVersionUID = 1L; + + /** + * 用于显示在用户界面 + */ + private String Name; + + /** + * 用于构造获取地址空间路径path + */ + private String BrowseName; + + /** + * Id + */ + private String Id; + + /** + * 数据类型 + */ + private String Type; + + /** + * AccessRight + */ + private Integer AccessRight; + + /** + * IsFolder + */ + private Boolean IsFolder; + + /** + * 维度 + */ + private List<Object> Dimensions; + + /** + * Children + */ + private List<Object> Children; +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/tag/dto/TagOptionDTO.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/tag/dto/TagOptionDTO.java new file mode 100644 index 0000000..6d8353c --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/tag/dto/TagOptionDTO.java @@ -0,0 +1,22 @@ +package com.iailab.module.data.channel.tag.dto; + +import lombok.Data; + +import java.io.Serializable; +import java.util.List; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年05月16日 + */ +@Data +public class TagOptionDTO implements Serializable { + private static final long serialVersionUID = 1L; + + private String value; + + private String label; + + private List<TagOptionDTO> children; +} \ No newline at end of file diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/tag/dto/TagValueDTO.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/tag/dto/TagValueDTO.java new file mode 100644 index 0000000..35db2b6 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/tag/dto/TagValueDTO.java @@ -0,0 +1,25 @@ +package com.iailab.module.data.channel.tag.dto; + +import lombok.Data; + +import java.io.Serializable; + +/** + * @author PanZhibao + * @Description + * @createTime 2023年04月23日 17:38:00 + */ +@Data +public class TagValueDTO implements Serializable { + private static final long serialVersionUID = 1L; + + private String Id; + + private String Quality; + + private String Timestamp; + + private String Type; + + private String Value; +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/tag/dto/TagValueQueryDTO.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/tag/dto/TagValueQueryDTO.java new file mode 100644 index 0000000..edae58b --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/tag/dto/TagValueQueryDTO.java @@ -0,0 +1,17 @@ +package com.iailab.module.data.channel.tag.dto; + +import lombok.Data; + +import java.io.Serializable; + +/** + * @author PanZhibao + * @Description + * @createTime 2023年04月25日 14:02:00 + */ +@Data +public class TagValueQueryDTO implements Serializable { + private static final long serialVersionUID = 1L; + + private String Id; +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/annotation/DataFilter.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/annotation/DataFilter.java new file mode 100644 index 0000000..1dda7d6 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/annotation/DataFilter.java @@ -0,0 +1,37 @@ +/** + * Copyright (c) 2018 人人开源 All rights reserved. + * + * https://www.renren.io + * + * 版权所有,侵权必究! + */ + +package com.iailab.module.data.common.annotation; + +import java.lang.annotation.*; + +/** + * 数据过滤注解 + * + * @author Mark sunlightcs@gmail.com + */ +@Target(ElementType.METHOD) +@Retention(RetentionPolicy.RUNTIME) +@Documented +public @interface DataFilter { + /** + * 表的别名 + */ + String tableAlias() default ""; + + /** + * 用户ID + */ + String userId() default "creator"; + + /** + * 部门ID + */ + String deptId() default "dept_id"; + +} \ No newline at end of file diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/annotation/LogOperation.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/annotation/LogOperation.java new file mode 100644 index 0000000..7b7678e --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/annotation/LogOperation.java @@ -0,0 +1,24 @@ +/** + * Copyright (c) 2018 人人开源 All rights reserved. + * + * https://www.renren.io + * + * 版权所有,侵权必究! + */ + +package com.iailab.module.data.common.annotation; + +import java.lang.annotation.*; + +/** + * 操作日志注解 + * + * @author Mark sunlightcs@gmail.com + */ +@Target(ElementType.METHOD) +@Retention(RetentionPolicy.RUNTIME) +@Documented +public @interface LogOperation { + + String value() default ""; +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/annotation/SysLog.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/annotation/SysLog.java new file mode 100644 index 0000000..9138499 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/annotation/SysLog.java @@ -0,0 +1,16 @@ +package com.iailab.module.data.common.annotation; + +import java.lang.annotation.*; + +/** + * 系统日志注解 + * + * @author Mark sunlightcs@gmail.com + */ +@Target(ElementType.METHOD) +@Retention(RetentionPolicy.RUNTIME) +@Documented +public @interface SysLog { + + String value() default ""; +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/aspect/DictAspect.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/aspect/DictAspect.java new file mode 100644 index 0000000..b83f418 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/aspect/DictAspect.java @@ -0,0 +1,166 @@ +//package com.iailab.common.aspect; +// +//import com.alibaba.fastjson.JSONObject; +//import com.alibaba.fastjson.parser.Feature; +//import com.iailab.common.annotation.Dict; +//import com.iailab.framework.common.page.PageData; +//import com.iailab.framework.common.util.object.ConvertUtils; +//import com.iailab.common.utils.PageUtils; +//import com.iailab.common.utils.R; +//import com.iailab.common.utils.CommonResult; +//import com.iailab.entity.SysDictItem; +//import com.iailab.feign.IFeignSystemController; +//import lombok.extern.slf4j.Slf4j; +//import org.aspectj.lang.ProceedingJoinPoint; +//import org.aspectj.lang.annotation.Around; +//import org.aspectj.lang.annotation.Aspect; +//import org.aspectj.lang.annotation.Pointcut; +//import javax.annotation.Resource; +//import org.springframework.stereotype.Component; +//import org.springframework.util.CollectionUtils; +// +//import java.beans.IntrospectionException; +//import java.beans.PropertyDescriptor; +//import java.lang.reflect.Field; +//import java.lang.reflect.InvocationTargetException; +//import java.lang.reflect.Method; +//import java.util.HashMap; +//import java.util.List; +//import java.util.Map; +// +///** +// * @author PanZhibao +// * @Description +// * @createTime 2022年05月21日 09:57:00 +// */ +//@Aspect +//@Component +//@Slf4j +//public class DictAspect { +// +// private final String PAGE_CODE = "page"; +// +// private final String DATA_CODE = "data"; +// +// @Resource +// private IFeignSystemController feignSystemController; +// +// /** +// * 定义切点Pointcut +// */ +// @Pointcut("@annotation(com.iailab.common.annotation.AutoDict)") +// public void excudeService() { +// } +// +// @Around("excudeService()") +// public Object doAround(ProceedingJoinPoint pjp) throws Throwable { +// Object result = pjp.proceed(); +// try { +// this.parseDictText(result); +// } catch (Exception ex) { +// log.info(ex.getMessage()); +// } +// return result; +// } +// +// /** +// * parseDictText +// * +// * @param result +// * @throws IntrospectionException +// * @throws InvocationTargetException +// * @throws IllegalAccessException +// */ +// private void parseDictText(Object result) throws IntrospectionException, InvocationTargetException, IllegalAccessException { +// Map<String, List<SysDictItem>> mapList = feignSystemController.queryAllDictItems(); +// Map<String,Map<String, String>> map = new HashMap<>(); +// if (!CollectionUtils.isEmpty(mapList)) { +// mapList.forEach((k , v) -> { +// Map<String, String> dictItems = new HashMap<>(); +// if (!CollectionUtils.isEmpty(v)) { +// v.forEach(item -> { +// dictItems.put(item.getItemValue(), item.getItemText()); +// }); +// } +// map.put(k, dictItems); +// }); +// } +// +// if (result instanceof R) { +// if (((R) result).get(PAGE_CODE) instanceof PageUtils) { +// PageUtils page =(PageUtils)((R) result).get(PAGE_CODE); +// for (Object record : page.getList()) { +// this.setDictText(record, map); +// } +// } else if(((R) result).get(DATA_CODE) instanceof PageUtils) { +// PageUtils page =(PageUtils)((R) result).get(DATA_CODE); +// for (Object record : page.getList()) { +// this.setDictText(record, map); +// } +// } +// } else if(result instanceof CommonResult) { +// if(((CommonResult) result).getData() != null) { +// Object data = ((CommonResult) result).getData(); +// if (data instanceof List) { +// for (Object record : (List)data) { +// this.setDictText(record, map); +// } +// } else if(data instanceof PageData) { +// Object list = ((PageData)data).getList(); +// for (Object record : (List)list) { +// this.setDictText(record, map); +// } +// } else { +// this.setDictText(data, map); +// } +// } +// } else if (result instanceof List){ +// for (Object record : (List)result) { +// this.setDictText(record, map); +// } +// } +// } +// +// /** +// * setDictText +// * +// * @param record +// * @param map +// * @throws IntrospectionException +// * @throws InvocationTargetException +// * @throws IllegalAccessException +// */ +// private void setDictText(Object record, Map<String,Map<String, String>> map) throws IntrospectionException, InvocationTargetException, IllegalAccessException { +// JSONObject item = JSONObject.parseObject(JSONObject.toJSONString(record), Feature.OrderedField); +// for (Field field : ConvertUtils.getAllFields(record)) { +// if (!field.isAnnotationPresent(Dict.class)) { +// continue; +// } +// String dictCode = field.getAnnotation(Dict.class).dicCode(); +// String itemValue = field.getAnnotation(Dict.class).itemValue(); +// String value = item.getString(itemValue); +// Method method = new PropertyDescriptor(field.getName(), record.getClass()).getWriteMethod(); +// method.invoke(record, this.getDictText(dictCode, value, map)); +// } +// } +// +// /** +// * getDictText +// * +// * @param dictCode +// * @param itemValue +// * @param map +// * @return +// */ +// private String getDictText(String dictCode, String itemValue, Map<String,Map<String, String>> map) { +// String dictText = ""; +// try{ +// if (map != null || map.containsKey(dictCode)) { +// dictText = map.get(dictCode).get(itemValue); +// } +// } catch (Exception ex) { +// log.info("字典异常:" + dictCode ); +// } +// return dictText; +// } +//} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/aspect/SysLogAspect.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/aspect/SysLogAspect.java new file mode 100644 index 0000000..6bb932f --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/aspect/SysLogAspect.java @@ -0,0 +1,37 @@ +package com.iailab.module.data.common.aspect; + +import org.aspectj.lang.ProceedingJoinPoint; +import org.aspectj.lang.annotation.Around; +import org.aspectj.lang.annotation.Aspect; +import org.aspectj.lang.annotation.Pointcut; +import org.springframework.stereotype.Component; + + +/** + * 系统日志,切面处理类 + * + * @author Mark sunlightcs@gmail.com + */ +@Aspect +@Component +public class SysLogAspect { + + @Pointcut("@annotation(com.iailab.module.data.common.annotation.SysLog)") + public void logPointCut() { + + } + + @Around("logPointCut()") + public Object around(ProceedingJoinPoint point) throws Throwable { + long beginTime = System.currentTimeMillis(); + //执行方法 + Object result = point.proceed(); + //执行时长(毫秒) + long time = System.currentTimeMillis() - beginTime; + + //保存日志 + //saveSysLog(point, time); + + return result; + } +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/config/MybatisPlusConfig.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/config/MybatisPlusConfig.java new file mode 100644 index 0000000..725757d --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/config/MybatisPlusConfig.java @@ -0,0 +1,42 @@ +///** +// * Copyright (c) 2016-2019 人人开源 All rights reserved. +// * +// * https://www.renren.io +// * +// * 版权所有,侵权必究! +// */ +// +//package com.iailab.module.common.config; +// +//import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor; +//import com.baomidou.mybatisplus.extension.plugins.inner.BlockAttackInnerInterceptor; +//import com.baomidou.mybatisplus.extension.plugins.inner.OptimisticLockerInnerInterceptor; +//import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor; +//import com.iailab.module.common.interceptor.DataFilterInterceptor; +//import org.springframework.context.annotation.Bean; +//import org.springframework.context.annotation.Configuration; +// +///** +// * mybatis-plus配置 +// * +// * @author Mark sunlightcs@gmail.com +// */ +//@Configuration +//public class MybatisPlusConfig { +// +// @Bean +// public MybatisPlusInterceptor mybatisPlusInterceptor() { +// MybatisPlusInterceptor mybatisPlusInterceptor = new MybatisPlusInterceptor(); +// // 数据权限 +// mybatisPlusInterceptor.addInnerInterceptor(new DataFilterInterceptor()); +// // 分页插件 +// mybatisPlusInterceptor.addInnerInterceptor(new PaginationInnerInterceptor()); +// // 乐观锁 +// mybatisPlusInterceptor.addInnerInterceptor(new OptimisticLockerInnerInterceptor()); +// // 防止全表更新与删除 +// mybatisPlusInterceptor.addInnerInterceptor(new BlockAttackInnerInterceptor()); +// +// return mybatisPlusInterceptor; +// } +// +//} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/config/SwaggerConfig.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/config/SwaggerConfig.java new file mode 100644 index 0000000..5f69f42 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/config/SwaggerConfig.java @@ -0,0 +1,69 @@ +///** +// * Copyright (c) 2018 人人开源 All rights reserved. +// * +// * https://www.renren.io +// * +// * 版权所有,侵权必究! +// */ +// +//package com.iailab.common.config; +// +//import com.github.xiaoymin.knife4j.spring.extension.OpenApiExtensionResolver; +//import com.iailab.framework.common.constant.Constant; +//import io.swagger.annotations.ApiOperation; +//import lombok.AllArgsConstructor; +//import org.springframework.context.annotation.Bean; +//import org.springframework.context.annotation.Configuration; +//import springfox.documentation.builders.ApiInfoBuilder; +//import springfox.documentation.builders.PathSelectors; +//import springfox.documentation.builders.RequestHandlerSelectors; +//import springfox.documentation.service.ApiInfo; +//import springfox.documentation.service.ApiKey; +//import springfox.documentation.spi.DocumentationType; +//import springfox.documentation.spring.web.plugins.Docket; +//import springfox.documentation.swagger2.annotations.EnableSwagger2WebMvc; +// +//import java.util.List; +// +///** +// * Swagger配置 +// * +// * @author Mark sunlightcs@gmail.com +// */ +//@Configuration +//@EnableSwagger2WebMvc +//@AllArgsConstructor +//public class SwaggerConfig { +// private final OpenApiExtensionResolver openApiExtensionResolver; +// +// @Bean +// public Docket createRestApi() { +// return new Docket(DocumentationType.SWAGGER_2) +// .apiInfo(apiInfo()) +// .select() +// //加了ApiOperation注解的类,生成接口文档 +// .apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class)) +// //包下的类,生成接口文档 +// //.apis(RequestHandlerSelectors.basePackage("io.renren.modules.job.controller")) +// .paths(PathSelectors.any()) +// .build() +// .extensions(openApiExtensionResolver.buildExtensions("Renren")) +// .directModelSubstitute(java.util.Date.class, String.class) +// .securitySchemes(security()); +// } +// +// private ApiInfo apiInfo() { +// return new ApiInfoBuilder() +// .title("人人开源") +// .description("renren-admin文档") +// .termsOfServiceUrl("https://www.renren.io") +// .version("5.x") +// .build(); +// } +// +// private List<ApiKey> security() { +// return newArrayList( +// new ApiKey(Constant.TOKEN_HEADER, Constant.TOKEN_HEADER, "header") +// ); +// } +//} \ No newline at end of file diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/dto/IndexQueryDTO.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/dto/IndexQueryDTO.java new file mode 100644 index 0000000..ac33c09 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/dto/IndexQueryDTO.java @@ -0,0 +1,20 @@ +package com.iailab.module.data.common.dto; + +import lombok.Data; + +import java.util.Date; +import java.util.List; + +@Data +public class IndexQueryDTO { + + private Date startDate; + + private Date endDate; + + private String code; + + private Integer granularity; + + private List<String> codes; +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/dto/IndexStatisticDTO.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/dto/IndexStatisticDTO.java new file mode 100644 index 0000000..c2a9a6f --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/dto/IndexStatisticDTO.java @@ -0,0 +1,16 @@ +package com.iailab.module.data.common.dto; + +import lombok.Data; + +import java.io.Serializable; +import java.math.BigDecimal; +import java.util.Date; + +@Data +public class IndexStatisticDTO implements Serializable { + private static final long serialVersionUID = 1L; + + public Date dateTime; + public BigDecimal data; + +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/dto/echarts/BarLineDTO.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/dto/echarts/BarLineDTO.java new file mode 100644 index 0000000..0055bd8 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/dto/echarts/BarLineDTO.java @@ -0,0 +1,27 @@ +package com.iailab.module.data.common.dto.echarts; + +import io.swagger.v3.oas.annotations.tags.Tag; +import lombok.Data; + +import java.io.Serializable; +import java.util.List; + +/** + * @author lirm + * @Description + * @createTime 2023.05.11 + */ +@Data +@Tag(name = "图表") +public class BarLineDTO implements Serializable { + private static final long serialVersionUID = 1L; + + private String valueName;//表名称 + + private List<String> legend;//线的名称 + + private List<String> categories;//X轴数据 + + private List<SeriesItem> series;//Y轴数据集合 + +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/dto/echarts/SeriesItem.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/dto/echarts/SeriesItem.java new file mode 100644 index 0000000..c4ebee7 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/dto/echarts/SeriesItem.java @@ -0,0 +1,18 @@ +package com.iailab.module.data.common.dto.echarts; + +import lombok.Data; + +import java.util.List; + +/** + * @author lirm + * @Description + * @createTime 2023.05.11 + */ +@Data +public class SeriesItem { + + private String name; + + private List<Object[]> data; +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/dto/vue/CascaderOptionDTO.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/dto/vue/CascaderOptionDTO.java new file mode 100644 index 0000000..cebe3d5 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/dto/vue/CascaderOptionDTO.java @@ -0,0 +1,22 @@ +package com.iailab.module.data.common.dto.vue; + +import lombok.Data; + +import java.io.Serializable; +import java.util.List; + +/** + * @author PanZhibao + * @Description + * @createTime 2023年05月15日 13:46:00 + */ +@Data +public class CascaderOptionDTO implements Serializable { + private static final long serialVersionUID = 1L; + + private String value; + + private String label; + + private List<CascaderOptionDTO> children; +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/enums/CommonConstant.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/enums/CommonConstant.java new file mode 100644 index 0000000..04d4c7a --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/enums/CommonConstant.java @@ -0,0 +1,561 @@ +package com.iailab.module.data.common.enums; + + +import java.math.BigDecimal; + +/** + * @Description: 通用常量 + */ +public interface CommonConstant { + + String CJS_SYS = "system"; + + String HTTP_CLIENT_ID_XST = "xsteam"; + + String HTTP_CLIENT_ID_SD = "sd"; + + String HTTP_CLIENT_ID_OADP = "oadp"; + + String HTTP_CLIENT_ID_FXJY = "fxjy"; + + String HTTP_CLIENT_ID_ELELOW = "elelow"; + + String HTTP_RESULT_TRUE = "true"; + //常量点 + String CONSTANT = "CONSTANT"; + //计量点 + String MEASURE = "MEASURE"; + //计算点 + String CALCULATE = "CALCULATE"; + + BigDecimal BAD_VALUE = new BigDecimal("-2"); + + BigDecimal ZERO_VALUE = new BigDecimal("0"); + + + //年生产计划执行数据 + String YEAR_PEI_HTTP_TAG = "yearPeiHttpTag"; + //当前产量 + String CURRENT_PERFORMANCE_HTTP_TAG = "currentPerformanceHttpTag"; + //生产时间分布 + String PRD_TIME_DIST_HTTP_TAG = "prdTimeDistHttpTag"; + //当前销量 + String CURRENT_SALE_HTTP_TAG = "currentSaleHttpTag"; + + String HTTP_API_ZXZK_IH = "ZXZK_IH"; + + String HTTP_API_SD_RUN_STATE = "SDRunState"; + + String HTTP_API_SD_HEALTH_STATE = "SDHealthState"; + + String HTTP_API_SD_DEVICE_LIST = "SDDeviceList"; + + String HTTP_API_SD_DEVICE_TEMPERATURE = "SDDeviceTemperature"; + + String HTTP_API_ZX_DEVICE_ELECTRIC = "ZXDeviceElectric"; + + String HTTP_API_PERSON_LIST = "PersonList"; + + String HTTP_API_JOB_LIST = "JobList"; + + //年 + String YEAR = "year"; + //月 + String MONTH = "month"; + + //下划线 + String UNDERLINE = "_"; + //$符 + String DOLLAR = "$"; + + /** + * 启用 + */ + public static final int IS_ENABLE = 1; + + /** + * 删除标志 + */ + public static final Integer BPM_FLAG_1 = 1; + + /** + * 正常状态 + */ + public static final Integer STATUS_NORMAL = 0; + + /** + * 禁用状态 + */ + public static final Integer STATUS_DISABLE = -1; + + /** + * 删除标志 + */ + public static final Integer DEL_FLAG_1 = 1; + + /** + * 未删除 + */ + public static final Integer DEL_FLAG_0 = 0; + + /** + * 未提交 + */ + public static final Integer SUBMINT_STATUS_0 = 0; + + /** + * 系统日志类型: 登录 + */ + public static final int LOG_TYPE_1 = 1; + + /** + * 系统日志类型: 操作 + */ + public static final int LOG_TYPE_2 = 2; + + /** + * 操作日志类型: 查询 + */ + public static final int OPERATE_TYPE_1 = 1; + + /** + * 操作日志类型: 添加 + */ + public static final int OPERATE_TYPE_2 = 2; + + /** + * 操作日志类型: 更新 + */ + public static final int OPERATE_TYPE_3 = 3; + + /** + * 操作日志类型: 删除 + */ + public static final int OPERATE_TYPE_4 = 4; + + /** + * 操作日志类型: 倒入 + */ + public static final int OPERATE_TYPE_5 = 5; + + /** + * 操作日志类型: 导出 + */ + public static final int OPERATE_TYPE_6 = 6; + + /** + * 提交 + */ + public static final int SUBMIT_FLAG_1 = 1; + + /** + * 通过 + */ + public static final int SUBMIT_FLAG_2 = 2; + + /** + * 驳回 + */ + public static final int SUBMIT_FLAG_3 = 3; + + /** + * 提交 + */ + public static final int SUBMIT_FLAG_0 = 0; + + public static final int SUBMIT_FLAG_4 = 4; + + public static final int SUBMIT_FLAG_5 = 5; + + public static final int SUBMIT_FLAG_6 = 6; + + public static final Integer DANGER_STATUS = 1; + + public static final Integer DANGER_STATUS_2 = 2; + + + /** + * {@code 500 Server Error} (HTTP/1.0 - RFC 1945) + */ + public static final Integer SC_INTERNAL_SERVER_ERROR_500 = 500; + /** + * {@code 200 OK} (HTTP/1.0 - RFC 1945) + */ + public static final Integer SC_OK_200 = 200; + + /** + * 访问权限认证未通过 510 + */ + public static final Integer SC_JEECG_NO_AUTHZ = 510; + + /** + * 登录用户Shiro权限缓存KEY前缀 + */ + public static String PREFIX_USER_SHIRO_CACHE = "shiro:cache:org.jeecg.config.shiro.ShiroRealm.authorizationCache:"; + /** + * 登录用户Token令牌缓存KEY前缀 + */ + public static final String PREFIX_USER_TOKEN = "prefix_user_token_"; +// /** Token缓存时间:3600秒即一小时 */ +// public static final int TOKEN_EXPIRE_TIME = 3600; + + /** + * 登录二维码 + */ + public static final String LOGIN_QRCODE_PRE = "QRCODELOGIN:"; + public static final String LOGIN_QRCODE = "LQ:"; + /** + * 登录二维码token + */ + public static final String LOGIN_QRCODE_TOKEN = "LQT:"; + + + /** + * 0:一级菜单 + */ + public static final Integer MENU_TYPE_0 = 0; + /** + * 1:子菜单 + */ + public static final Integer MENU_TYPE_1 = 1; + /** + * 2:按钮权限 + */ + public static final Integer MENU_TYPE_2 = 2; + + /** + * 通告对象类型(USER:指定用户,ALL:全体用户) + */ + public static final String MSG_TYPE_UESR = "USER"; + public static final String MSG_TYPE_ALL = "ALL"; + + /** + * 发布状态(0未发布,1已发布,2已撤销) + */ + public static final String NO_SEND = "0"; + public static final String HAS_SEND = "1"; + public static final String HAS_CANCLE = "2"; + + /** + * 阅读状态(0未读,1已读) + */ + public static final String HAS_READ_FLAG = "1"; + public static final String NO_READ_FLAG = "0"; + + /** + * 优先级(L低,M中,H高) + */ + public static final String PRIORITY_L = "L"; + public static final String PRIORITY_M = "M"; + public static final String PRIORITY_H = "H"; + + /** + * 短信模板方式 0 .登录模板、1.注册模板、2.忘记密码模板 + */ + public static final String SMS_TPL_TYPE_0 = "0"; + public static final String SMS_TPL_TYPE_1 = "1"; + public static final String SMS_TPL_TYPE_2 = "2"; + + /** + * 状态(0无效1有效) + */ + public static final String STATUS_0 = "0"; + public static final String STATUS_1 = "1"; + + /** + * 状态(0无效1有效) + */ + public static final Integer INT_STATUS_0 = 0; + public static final Integer INT_STATUS_1 = 1; + + /** + * 同步工作流引擎1同步0不同步 + */ + public static final Integer ACT_SYNC_1 = 1; + public static final Integer ACT_SYNC_0 = 0; + + /** + * 消息类型1:通知公告2:系统消息 + */ + public static final String MSG_CATEGORY_1 = "1"; + public static final String MSG_CATEGORY_2 = "2"; + + /** + * 是否配置菜单的数据权限 1是0否 + */ + public static final Integer RULE_FLAG_0 = 0; + public static final Integer RULE_FLAG_1 = 1; + + /** + * 是否用户已被冻结 1正常(解冻) 2冻结 + */ + public static final Integer USER_UNFREEZE = 1; + public static final Integer USER_FREEZE = 2; + + /** + * 字典翻译文本后缀 + */ + public static final String DICT_TEXT_SUFFIX = "_dictText"; + + /** + * 表单设计器主表类型 + */ + public static final Integer DESIGN_FORM_TYPE_MAIN = 1; + + /** + * 表单设计器子表表类型 + */ + public static final Integer DESIGN_FORM_TYPE_SUB = 2; + + /** + * 表单设计器URL授权通过 + */ + public static final Integer DESIGN_FORM_URL_STATUS_PASSED = 1; + + /** + * 表单设计器URL授权未通过 + */ + public static final Integer DESIGN_FORM_URL_STATUS_NOT_PASSED = 2; + + /** + * 表单设计器新增 Flag + */ + public static final String DESIGN_FORM_URL_TYPE_ADD = "add"; + /** + * 表单设计器修改 Flag + */ + public static final String DESIGN_FORM_URL_TYPE_EDIT = "edit"; + /** + * 表单设计器详情 Flag + */ + public static final String DESIGN_FORM_URL_TYPE_DETAIL = "detail"; + /** + * 表单设计器复用数据 Flag + */ + public static final String DESIGN_FORM_URL_TYPE_REUSE = "reuse"; + /** + * 表单设计器编辑 Flag (已弃用) + */ + public static final String DESIGN_FORM_URL_TYPE_VIEW = "view"; + + /** + * online参数值设置(是:Y, 否:N) + */ + public static final String ONLINE_PARAM_VAL_IS_TURE = "Y"; + public static final String ONLINE_PARAM_VAL_IS_FALSE = "N"; + + /** + * 文件上传类型(本地:local,Minio:minio,阿里云:alioss) + */ + public static final String UPLOAD_TYPE_LOCAL = "local"; + public static final String UPLOAD_TYPE_MINIO = "minio"; + public static final String UPLOAD_TYPE_OSS = "alioss"; + + /** + * 文档上传自定义桶名称 + */ + public static final String UPLOAD_CUSTOM_BUCKET = "eoafile"; + /** + * 文档上传自定义路径 + */ + public static final String UPLOAD_CUSTOM_PATH = "eoafile"; + /** + * 文件外链接有效天数 + */ + public static final Integer UPLOAD_EFFECTIVE_DAYS = 1; + + /** + * 员工身份 (1:普通员工 2:上级) + */ + public static final Integer USER_IDENTITY_1 = 1; + public static final Integer USER_IDENTITY_2 = 2; + + /** + * sys_user 表 username 唯一键索引 + */ + public static final String SQL_INDEX_UNIQ_SYS_USER_USERNAME = "uniq_sys_user_username"; + /** + * sys_user 表 work_no 唯一键索引 + */ + public static final String SQL_INDEX_UNIQ_SYS_USER_WORK_NO = "uniq_sys_user_work_no"; + /** + * sys_user 表 phone 唯一键索引 + */ + public static final String SQL_INDEX_UNIQ_SYS_USER_PHONE = "uniq_sys_user_phone"; + /** + * 达梦数据库升提示。违反表[SYS_USER]唯一性约束 + */ + public static final String SQL_INDEX_UNIQ_SYS_USER = "唯一性约束"; + + /** + * sys_user 表 email 唯一键索引 + */ + public static final String SQL_INDEX_UNIQ_SYS_USER_EMAIL = "uniq_sys_user_email"; + /** + * sys_quartz_job 表 job_class_name 唯一键索引 + */ + public static final String SQL_INDEX_UNIQ_JOB_CLASS_NAME = "uniq_job_class_name"; + /** + * sys_position 表 code 唯一键索引 + */ + public static final String SQL_INDEX_UNIQ_CODE = "uniq_code"; + /** + * sys_role 表 code 唯一键索引 + */ + public static final String SQL_INDEX_UNIQ_SYS_ROLE_CODE = "uniq_sys_role_role_code"; + /** + * sys_depart 表 code 唯一键索引 + */ + public static final String SQL_INDEX_UNIQ_DEPART_ORG_CODE = "uniq_depart_org_code"; + /** + * sys_category 表 code 唯一键索引 + */ + public static final String SQL_INDEX_UNIQ_CATEGORY_CODE = "idx_sc_code"; + /** + * 在线聊天 是否为默认分组 + */ + public static final String IM_DEFAULT_GROUP = "1"; + /** + * 在线聊天 图片文件保存路径 + */ + public static final String IM_UPLOAD_CUSTOM_PATH = "imfile"; + /** + * 在线聊天 用户状态 + */ + public static final String IM_STATUS_ONLINE = "online"; + + /** + * 在线聊天 SOCKET消息类型 + */ + public static final String IM_SOCKET_TYPE = "chatMessage"; + + /** + * 在线聊天 是否开启默认添加好友 1是 0否 + */ + public static final String IM_DEFAULT_ADD_FRIEND = "1"; + + /** + * 在线聊天 用户好友缓存前缀 + */ + public static final String IM_PREFIX_USER_FRIEND_CACHE = "sys:cache:im:im_prefix_user_friend_"; + + /** + * 考勤补卡业务状态 (1:同意 2:不同意) + */ + public static final String SIGN_PATCH_BIZ_STATUS_1 = "1"; + public static final String SIGN_PATCH_BIZ_STATUS_2 = "2"; + + /** + * 公文文档上传自定义路径 + */ + public static final String UPLOAD_CUSTOM_PATH_OFFICIAL = "officialdoc"; + /** + * 公文文档下载自定义路径 + */ + public static final String DOWNLOAD_CUSTOM_PATH_OFFICIAL = "officaldown"; + + /** + * WPS存储值类别(1 code文号 2 text(WPS模板还是公文发文模板)) + */ + public static final String WPS_TYPE_1 = "1"; + public static final String WPS_TYPE_2 = "2"; + + + public final static String X_ACCESS_TOKEN = "X-Access-Token"; + public final static String X_SIGN = "X-Sign"; + public final static String X_TIMESTAMP = "X-TIMESTAMP"; + public final static String TOKEN_IS_INVALID_MSG = "Token失效,请重新登录!"; + + /** + * 多租户 请求头 + */ + public final static String TENANT_ID = "tenant-id"; + + /** + * 微服务读取配置文件属性 服务地址 + */ + public final static String CLOUD_SERVER_KEY = "spring.cloud.nacos.discovery.server-addr"; + + /** + * 第三方登录 验证密码/创建用户 都需要设置一个操作码 防止被恶意调用 + */ + public final static String THIRD_LOGIN_CODE = "third_login_code"; + + /** + * 第三方APP同步方向:本地 --> 第三方APP + */ + String THIRD_SYNC_TO_APP = "SYNC_TO_APP"; + /** + * 第三方APP同步方向:第三方APP --> 本地 + */ + String THIRD_SYNC_TO_LOCAL = "SYNC_TO_LOCAL"; + + /** + * 系统通告消息状态:0=未发布 + */ + String ANNOUNCEMENT_SEND_STATUS_0 = "0"; + /** + * 系统通告消息状态:1=已发布 + */ + String ANNOUNCEMENT_SEND_STATUS_1 = "1"; + /** + * 系统通告消息状态:2=已撤销 + */ + String ANNOUNCEMENT_SEND_STATUS_2 = "2"; + + /** + * ONLINE 报表权限用 从request中获取地址栏后的参数 + */ + String ONL_REP_URL_PARAM_STR = "onlRepUrlParamStr"; + + /** + * POST请求 + */ + String HTTP_POST = "POST"; + + /** + * PUT请求 + */ + String HTTP_PUT = "PUT"; + + /** + * PATCH请求 + */ + String HTTP_PATCH = "PATCH"; + + /** + * 未知的 + */ + String UNKNOWN = "unknown"; + + /** + * 字符串http + */ + String STR_HTTP = "http"; + + /** + * String 类型的空值 + */ + String STRING_NULL = "null"; + + /** + * java.util.Date 包 + */ + String JAVA_UTIL_DATE = "java.util.Date"; + + /** + * .do + */ + String SPOT_DO = ".do"; + + + /** + * 前端vue版本标识 + */ + String VERSION = "X-Version"; + + /** + * 前端vue版本 + */ + String VERSION_VUE3 = "vue3"; +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/enums/CommonDict.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/enums/CommonDict.java new file mode 100644 index 0000000..815eccb --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/enums/CommonDict.java @@ -0,0 +1,13 @@ +package com.iailab.module.data.common.enums; + +/** + * @author PanZhibao + * @Description + * @createTime 2022年06月26日 12:12:00 + */ +public class CommonDict { + + public static final Integer ONE = 1; + + public static final Integer TOW = 2; +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/enums/DataSourceType.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/enums/DataSourceType.java new file mode 100644 index 0000000..12734ec --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/enums/DataSourceType.java @@ -0,0 +1,35 @@ +package com.iailab.module.data.common.enums; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年05月12日 + */ +@Getter +@AllArgsConstructor +public enum DataSourceType { + OPCUA("OPCUA", "OPC UA"), + OPCDA("OPCDA", "OPC DA"), + ModBus("ModBus", "ModBus"), + KIO("KIO", "KIO"), + HTTP("HTTP", "HTTP"); + + private String code; + private String desc; + + public static DataSourceType getEumByCode(String code) { + if (code == null) { + return null; + } + + for (DataSourceType statusEnum : DataSourceType.values()) { + if (statusEnum.getCode().equals(code)) { + return statusEnum; + } + } + return null; + } +} \ No newline at end of file diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/enums/DataTypeEnum.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/enums/DataTypeEnum.java new file mode 100644 index 0000000..19a46ff --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/enums/DataTypeEnum.java @@ -0,0 +1,22 @@ +package com.iailab.module.data.common.enums; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +/** + * @author PanZhibao + * @Description + * @createTime 2023年05月03日 19:10:00 + */ +@Getter +@AllArgsConstructor +public enum DataTypeEnum { + + INT("int"), + + FLOAT("float"), + + BOOLEAN("boolean"); + + private String code; +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/enums/DatabaseType.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/enums/DatabaseType.java new file mode 100644 index 0000000..79d176c --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/enums/DatabaseType.java @@ -0,0 +1,9 @@ +package com.iailab.module.data.common.enums; + +/** + * @author PanZhibao + * @date 2021年09月01日 15:06 + */ +public enum DatabaseType { + DB2, MY_SQL, SQL_SERVER +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/enums/IsEnableEnum.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/enums/IsEnableEnum.java new file mode 100644 index 0000000..7c31aa0 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/enums/IsEnableEnum.java @@ -0,0 +1,21 @@ +package com.iailab.module.data.common.enums; + +/** + * @author PanZhibao + * @Description + * @createTime 2023年07月17日 17:41:00 + */ +public enum IsEnableEnum { + DISABLE(0), // 手动 + ENABLE(1); //自动 + + private Integer value; + + IsEnableEnum(Integer value) { + this.value = value; + } + + public Integer value() { + return this.value; + } +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/enums/JsErrorCode.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/enums/JsErrorCode.java new file mode 100644 index 0000000..4563e89 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/enums/JsErrorCode.java @@ -0,0 +1,10 @@ +package com.iailab.module.data.common.enums; + +/** + * @author PanZhibao + * @Description + * @createTime 2022年03月28日 17:46:00 + */ +public enum JsErrorCode { + Infinity, NaN +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/enums/RequestMethodType.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/enums/RequestMethodType.java new file mode 100644 index 0000000..85b772e --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/enums/RequestMethodType.java @@ -0,0 +1,18 @@ +package com.iailab.module.data.common.enums; + +/** + * @author PanZhibao + * @date 2021年08月17日 11:28 + */ +public enum RequestMethodType { + + /** + * GET + */ + GET, + + /** + * POST + */ + POST +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/enums/RowAction.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/enums/RowAction.java new file mode 100644 index 0000000..0e3044c --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/enums/RowAction.java @@ -0,0 +1,15 @@ +package com.iailab.module.data.common.enums; + +/** + * @author PanZhibao + * @Description + * @createTime 2022年06月25日 10:48:00 + */ +public class RowAction { + + public static final String ADD = "add"; + + public static final String UPDATE = "update"; + + public static final String DELETE = "delete"; +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/enums/TagValueTypeConstant.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/enums/TagValueTypeConstant.java new file mode 100644 index 0000000..3a125d4 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/enums/TagValueTypeConstant.java @@ -0,0 +1,35 @@ +package com.iailab.module.data.common.enums; + +/** + * @author PanZhibao + * @Description + * @createTime 2023年04月25日 15:43:00 + */ +public class TagValueTypeConstant { + + public static final String QUALITY_GOOD = "Good"; + + public static final String BOOLEAN = "Boolean"; + + public static final String INT8 = "Int8"; + + public static final String INT16 = "Int16"; + + public static final String INT32 = "Int32"; + + public static final String INT64 = "Int64"; + + public static final String UINT8 = "UInt8"; + + public static final String UINT16 = "UInt16"; + + public static final String UINT32 = "UInt32"; + + public static final String UINT64 = "UInt64"; + + public static final String FLOAT = "Float"; + + public static final String DOUBLE = "Double"; + + public static final String STRING = "String"; +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/exception/RRException.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/exception/RRException.java new file mode 100644 index 0000000..ae0b2bf --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/exception/RRException.java @@ -0,0 +1,53 @@ +package com.iailab.module.data.common.exception; + +/** + * 自定义异常 + * + * @author Mark sunlightcs@gmail.com + */ +public class RRException extends RuntimeException { + private static final long serialVersionUID = 1L; + + private String msg; + private int code = 500; + + public RRException(String msg) { + super(msg); + this.msg = msg; + } + + public RRException(String msg, Throwable e) { + super(msg, e); + this.msg = msg; + } + + public RRException(String msg, int code) { + super(msg); + this.msg = msg; + this.code = code; + } + + public RRException(String msg, int code, Throwable e) { + super(msg, e); + this.msg = msg; + this.code = code; + } + + public String getMsg() { + return msg; + } + + public void setMsg(String msg) { + this.msg = msg; + } + + public int getCode() { + return code; + } + + public void setCode(int code) { + this.code = code; + } + + +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/exception/RRExceptionHandler.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/exception/RRExceptionHandler.java new file mode 100644 index 0000000..dce42ed --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/exception/RRExceptionHandler.java @@ -0,0 +1,56 @@ +//package com.iailab.common.exception; +// +//import com.iailab.common.utils.R; +//import org.apache.shiro.authz.AuthorizationException; +//import org.slf4j.Logger; +//import org.slf4j.LoggerFactory; +//import org.springframework.dao.DuplicateKeyException; +//import org.springframework.web.bind.annotation.ExceptionHandler; +//import org.springframework.web.bind.annotation.RestControllerAdvice; +//import org.springframework.web.servlet.NoHandlerFoundException; +// +///** +// * 异常处理器 +// * +// * @author Mark sunlightcs@gmail.com +// */ +//@RestControllerAdvice +//public class RRExceptionHandler { +// private Logger logger = LoggerFactory.getLogger(getClass()); +// +// /** +// * 处理自定义异常 +// */ +// @ExceptionHandler(RRException.class) +// public R handleRRException(RRException e){ +// R r = new R(); +// r.put("code", e.getCode()); +// r.put("msg", e.getMessage()); +// +// return r; +// } +// +// @ExceptionHandler(NoHandlerFoundException.class) +// public R handlerNoFoundException(Exception e) { +// logger.error(e.getMessage(), e); +// return R.error(404, "路径不存在,请检查路径是否正确"); +// } +// +// @ExceptionHandler(DuplicateKeyException.class) +// public R handleDuplicateKeyException(DuplicateKeyException e){ +// logger.error(e.getMessage(), e); +// return R.error("数据库中已存在该记录"); +// } +// +// @ExceptionHandler(AuthorizationException.class) +// public R handleAuthorizationException(AuthorizationException e){ +// logger.error(e.getMessage(), e); +// return R.error("没有权限,请联系管理员授权"); +// } +// +// @ExceptionHandler(Exception.class) +// public R handleException(Exception e){ +// logger.error(e.getMessage(), e); +// return R.error(); +// } +//} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/interceptor/DataFilterInterceptor.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/interceptor/DataFilterInterceptor.java new file mode 100644 index 0000000..4369aea --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/interceptor/DataFilterInterceptor.java @@ -0,0 +1,89 @@ +///** +// * Copyright (c) 2018 人人开源 All rights reserved. +// * +// * https://www.renren.io +// * +// * 版权所有,侵权必究! +// */ +// +//package com.iailab.module.common.interceptor; +// +//import cn.hutool.core.util.StrUtil; +//import com.baomidou.mybatisplus.core.toolkit.PluginUtils; +//import com.baomidou.mybatisplus.extension.plugins.inner.InnerInterceptor; +//import net.sf.jsqlparser.JSQLParserException; +//import net.sf.jsqlparser.expression.Expression; +//import net.sf.jsqlparser.expression.StringValue; +//import net.sf.jsqlparser.expression.operators.conditional.AndExpression; +//import net.sf.jsqlparser.parser.CCJSqlParserUtil; +//import net.sf.jsqlparser.statement.select.PlainSelect; +//import net.sf.jsqlparser.statement.select.Select; +//import org.apache.ibatis.executor.Executor; +//import org.apache.ibatis.mapping.BoundSql; +//import org.apache.ibatis.mapping.MappedStatement; +//import org.apache.ibatis.session.ResultHandler; +//import org.apache.ibatis.session.RowBounds; +// +//import java.util.Map; +// +///** +// * 数据过滤 +// * +// * @author Mark sunlightcs@gmail.com +// */ +//public class DataFilterInterceptor implements InnerInterceptor { +// +// @Override +// public void beforeQuery(Executor executor, MappedStatement ms, Object parameter, RowBounds rowBounds, ResultHandler resultHandler, BoundSql boundSql) { +// DataScope scope = getDataScope(parameter); +// // 不进行数据过滤 +// if(scope == null || StrUtil.isBlank(scope.getSqlFilter())){ +// return; +// } +// +// // 拼接新SQL +// String buildSql = getSelect(boundSql.getSql(), scope); +// +// // 重写SQL +// PluginUtils.mpBoundSql(boundSql).sql(buildSql); +// } +// +// private DataScope getDataScope(Object parameter){ +// if (parameter == null){ +// return null; +// } +// +// // 判断参数里是否有DataScope对象 +// if (parameter instanceof Map) { +// Map<?, ?> parameterMap = (Map<?, ?>) parameter; +// for (Map.Entry entry : parameterMap.entrySet()) { +// if (entry.getValue() != null && entry.getValue() instanceof DataScope) { +// return (DataScope) entry.getValue(); +// } +// } +// } else if (parameter instanceof DataScope) { +// return (DataScope) parameter; +// } +// +// return null; +// } +// +// private String getSelect(String buildSql, DataScope scope){ +// try { +// Select select = (Select) CCJSqlParserUtil.parse(buildSql); +// PlainSelect plainSelect = (PlainSelect) select.getSelectBody(); +// +// Expression expression = plainSelect.getWhere(); +// if(expression == null){ +// plainSelect.setWhere(new StringValue(scope.getSqlFilter())); +// }else{ +// AndExpression andExpression = new AndExpression(expression, new StringValue(scope.getSqlFilter())); +// plainSelect.setWhere(andExpression); +// } +// +// return select.toString().replaceAll("'", ""); +// }catch (JSQLParserException e){ +// return buildSql; +// } +// } +//} \ No newline at end of file diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/interceptor/DataScope.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/interceptor/DataScope.java new file mode 100644 index 0000000..bd08683 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/interceptor/DataScope.java @@ -0,0 +1,36 @@ +///** +// * Copyright (c) 2018 人人开源 All rights reserved. +// * +// * https://www.renren.io +// * +// * 版权所有,侵权必究! +// */ +// +//package com.iailab.module.common.interceptor; +// +///** +// * 数据范围 +// * +// * @author Mark sunlightcs@gmail.com +// * @since 1.0.0 +// */ +//public class DataScope { +// private String sqlFilter; +// +// public DataScope(String sqlFilter) { +// this.sqlFilter = sqlFilter; +// } +// +// public String getSqlFilter() { +// return sqlFilter; +// } +// +// public void setSqlFilter(String sqlFilter) { +// this.sqlFilter = sqlFilter; +// } +// +// @Override +// public String toString() { +// return this.sqlFilter; +// } +//} \ No newline at end of file diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/utils/Constant.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/utils/Constant.java new file mode 100644 index 0000000..ed2ba5c --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/utils/Constant.java @@ -0,0 +1,119 @@ +package com.iailab.module.data.common.utils; + +/** + * 常量 + * + * @author Mark sunlightcs@gmail.com + */ +public class Constant { + /** 超级管理员ID */ + public static final String SUPER_ADMIN = "1"; + /** + * 当前页码 + */ + public static final String PAGE = "page"; + /** + * 每页显示记录数 + */ + public static final String LIMIT = "limit"; + /** + * 排序字段 + */ + public static final String ORDER_FIELD = "sidx"; + /** + * 排序方式 + */ + public static final String ORDER = "order"; + /** + * 升序 + */ + public static final String ASC = "asc"; + /** + * 菜单类型 + * + * @author chenshun + * @email sunlightcs@gmail.com + * @date 2016年11月15日 下午1:24:29 + */ + public enum MenuType { + /** + * 目录 + */ + CATALOG(0), + /** + * 菜单 + */ + MENU(1), + /** + * 按钮 + */ + BUTTON(2); + + private int value; + + MenuType(int value) { + this.value = value; + } + + public int getValue() { + return value; + } + } + + /** + * 定时任务状态 + * + * @author chenshun + * @email sunlightcs@gmail.com + * @date 2016年12月3日 上午12:07:22 + */ + public enum ScheduleStatus { + /** + * 正常 + */ + NORMAL(0), + /** + * 暂停 + */ + PAUSE(1); + + private int value; + + ScheduleStatus(int value) { + this.value = value; + } + + public int getValue() { + return value; + } + } + + /** + * 云服务商 + */ + public enum CloudService { + /** + * 七牛云 + */ + QINIU(1), + /** + * 阿里云 + */ + ALIYUN(2), + /** + * 腾讯云 + */ + QCLOUD(3); + + private int value; + + CloudService(int value) { + this.value = value; + } + + public int getValue() { + return value; + } + } + +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/utils/Conversion.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/utils/Conversion.java new file mode 100644 index 0000000..7a7e62d --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/utils/Conversion.java @@ -0,0 +1,31 @@ +package com.iailab.module.data.common.utils; + +import org.springframework.stereotype.Component; + +import java.lang.reflect.Field; +@Component +public class Conversion { + public static void convert(Object entity, Object dto) { + Class<?> entityClass = entity.getClass(); + Class<?> dtoClass = dto.getClass(); + Field[] entityFields = entityClass.getDeclaredFields(); + Field[] dtoFields = dtoClass.getDeclaredFields(); + try { + for (Field entityField : entityFields) { + entityField.setAccessible(true); + Object value = entityField.get(entity); + String name = entityField.getName(); + String dtoFieldName = name.substring(0, 1).toUpperCase() + name.substring(1); + for (Field dtoField : dtoFields) { + dtoField.setAccessible(true); + if (dtoField.getName().equals(dtoFieldName)) { + dtoField.set(dto, value); + break; + } + } + } + }catch (Exception e){ + + } + } +} \ No newline at end of file diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/utils/ExcelUtil.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/utils/ExcelUtil.java new file mode 100644 index 0000000..2425c11 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/utils/ExcelUtil.java @@ -0,0 +1,140 @@ +package com.iailab.module.data.common.utils; + +import org.apache.poi.hssf.usermodel.*; +import org.apache.poi.ss.usermodel.HorizontalAlignment; +import org.apache.poi.ss.usermodel.VerticalAlignment; +import org.apache.poi.ss.util.CellRangeAddress; + +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.io.OutputStream; +import java.lang.reflect.Field; +import java.util.List; +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * Excel 导出通用工具类 + * + * @author PanZhibao + * @date 2021年06月29日 9:06 + */ +public class ExcelUtil { + + /** + * 导出PointValueExcel + * + * @param sheetTitle + * @param title + * @param list + * @param response + * @return + */ + public static byte[] exportPointValue(String sheetTitle, String[] title, List<Object> list, HttpServletResponse response) { + + HSSFWorkbook wb = new HSSFWorkbook();//创建excel表 + HSSFSheet sheet = wb.createSheet(sheetTitle); + sheet.setDefaultColumnWidth(20);//设置默认行宽 + + //表头样式(加粗,水平居中,垂直居中) + HSSFCellStyle cellStyle = wb.createCellStyle(); + cellStyle.setAlignment(HorizontalAlignment.CENTER);//水平居中 + cellStyle.setVerticalAlignment(VerticalAlignment.CENTER);//垂直居中 + + HSSFFont fontStyle = wb.createFont(); + + cellStyle.setFont(fontStyle); + + //标题样式(加粗,垂直居中) + HSSFCellStyle cellStyle2 = wb.createCellStyle(); + cellStyle2.setVerticalAlignment(VerticalAlignment.CENTER);//垂直居中 + cellStyle2.setFont(fontStyle); + + //字段样式(垂直居中) + HSSFCellStyle cellStyle3 = wb.createCellStyle(); + cellStyle3.setVerticalAlignment(VerticalAlignment.CENTER);//垂直居中 + + //数字样式 + HSSFCellStyle cellStyle4 = wb.createCellStyle(); + HSSFDataFormat df = wb.createDataFormat(); // 此处设置数据格式 + cellStyle4.setVerticalAlignment(VerticalAlignment.CENTER);//垂直居中 + cellStyle4.setDataFormat(df.getFormat("#,##0.000000"));//设置数值类型格式为保留两位小数 + + //创建表头 + HSSFRow row = sheet.createRow(0); + //row.setHeightInPoints(20);//行高 + + HSSFCell cell = row.createCell(0); + cell.setCellValue(sheetTitle); + cell.setCellStyle(cellStyle); + + sheet.addMergedRegion(new CellRangeAddress(0,0,0,(title.length-1))); + + //创建标题 + HSSFRow rowTitle = sheet.createRow(1); + //rowTitle.setHeightInPoints(20); + + HSSFCell hc; + for (int i = 0; i < title.length; i++) { + hc = rowTitle.createCell(i); + hc.setCellValue(title[i]); + hc.setCellStyle(cellStyle2); + } + + byte result[] = null; + + try { + //创建表格数据 + Field[] fields; + int i = 2; + for (Object obj : list) { + fields = obj.getClass().getDeclaredFields(); + + HSSFRow rowBody = sheet.createRow(i); + //rowBody.setHeightInPoints(20); + + int j = 0; + for (Field f : fields) { + + f.setAccessible(true); + + Object va = f.get(obj); + if (null == va) { + va = ""; + } + + hc = rowBody.createCell(j); + + if (j == 0) { + hc.setCellValue(Double.parseDouble(va.toString())); + hc.setCellStyle(cellStyle4); + } else { + hc.setCellValue(va.toString()); + hc.setCellStyle(cellStyle3); + } + + + j++; + } + + i++; + } + + //设置Http响应头告诉浏览器下载这个附件 + response.setHeader("Content-Disposition", "attachment;Filename=" + System.currentTimeMillis() + ".xls"); + OutputStream outputStream = response.getOutputStream(); + wb.write(outputStream); + outputStream.close(); + return wb.getBytes(); + } catch (Exception ex) { + Logger.getLogger(ExcelUtil.class.getName()).log(Level.SEVERE, null, ex); + return result; + } finally{ + try { + wb.close(); + } catch (IOException ex) { + Logger.getLogger(ExcelUtil.class.getName()).log(Level.SEVERE, null, ex); + } + } + } +} \ No newline at end of file diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/utils/HttpContextUtils.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/utils/HttpContextUtils.java new file mode 100644 index 0000000..8ef5373 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/utils/HttpContextUtils.java @@ -0,0 +1,24 @@ +package com.iailab.module.data.common.utils; + +import org.springframework.web.context.request.RequestContextHolder; +import org.springframework.web.context.request.ServletRequestAttributes; + +import javax.servlet.http.HttpServletRequest; + +public class HttpContextUtils { + + public static HttpServletRequest getHttpServletRequest() { + return ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); + } + + public static String getDomain(){ + HttpServletRequest request = getHttpServletRequest(); + StringBuffer url = request.getRequestURL(); + return url.delete(url.length() - request.getRequestURI().length(), url.length()).toString(); + } + + public static String getOrigin(){ + HttpServletRequest request = getHttpServletRequest(); + return request.getHeader("Origin"); + } +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/utils/HttpRequest.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/utils/HttpRequest.java new file mode 100644 index 0000000..e3816d5 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/utils/HttpRequest.java @@ -0,0 +1,235 @@ +package com.iailab.module.data.common.utils; + +import org.springframework.util.CollectionUtils; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.PrintWriter; +import java.net.URL; +import java.net.URLConnection; +import java.util.List; +import java.util.Map; + +/** + * @author PanZhibao + * @date 2021年06月03日 15:31 + */ +public class HttpRequest { + /** + * 向指定URL发送GET方法的请求 + * + * @param url 发送请求的URL + * @param param 请求参数,请求参数应该是 name1=value1&name2=value2 的形式。 + * @return URL 所代表远程资源的响应结果 + */ + public static String sendGet(String url, String param) { + String result = ""; + BufferedReader in = null; + try { + String urlNameString = url + "?" + param; + URL realUrl = new URL(urlNameString); + // 打开和URL之间的连接 + URLConnection connection = realUrl.openConnection(); + // 设置通用的请求属性 + connection.setRequestProperty("accept", "*/*"); + connection.setRequestProperty("connection", "Keep-Alive"); + connection.setRequestProperty("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)"); + + // 建立实际的连接 + connection.connect(); + // 获取所有响应头字段 + Map<String, List<String>> map = connection.getHeaderFields(); + // 遍历所有的响应头字段 + for (String key : map.keySet()) { + System.out.println(key + "--->" + map.get(key)); + } + // 定义 BufferedReader输入流来读取URL的响应 + in = new BufferedReader(new InputStreamReader(connection.getInputStream())); + String line; + while ((line = in.readLine()) != null) { + result += line; + } + } catch (Exception e) { + System.out.println("发送GET请求出现异常!" + e); + e.printStackTrace(); + } + // 使用finally块来关闭输入流 + finally { + try { + if (in != null) { + in.close(); + } + } catch (Exception e2) { + e2.printStackTrace(); + } + } + return result; + } + + public static String sendGet(String url, Map<String, String> params, String authorization) { + String result = ""; + BufferedReader in = null; + try { + StringBuilder sb = new StringBuilder(); + sb.append(url); + if (!CollectionUtils.isEmpty(params)) { + sb.append("?"); + params.forEach((k, v) -> { + sb.append(k + "=" + v + "&"); + }); + sb.append("t=" + System.currentTimeMillis()); + } + String urlNameString = sb.toString(); + URL realUrl = new URL(urlNameString); + // 打开和URL之间的连接 + URLConnection connection = realUrl.openConnection(); + // 设置通用的请求属性 + connection.setRequestProperty("Authorization", authorization); + connection.setRequestProperty("accept", "*/*"); + connection.setRequestProperty("connection", "Keep-Alive"); + connection.setRequestProperty("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)"); + + // 建立实际的连接 + connection.connect(); + // 获取所有响应头字段 + Map<String, List<String>> map = connection.getHeaderFields(); + // 遍历所有的响应头字段 + for (String key : map.keySet()) { + System.out.println(key + "--->" + map.get(key)); + } + // 定义 BufferedReader输入流来读取URL的响应 + in = new BufferedReader(new InputStreamReader(connection.getInputStream())); + String line; + while ((line = in.readLine()) != null) { + result += line; + } + } catch (Exception e) { + System.out.println("发送GET请求出现异常!" + e); + e.printStackTrace(); + } + // 使用finally块来关闭输入流 + finally { + try { + if (in != null) { + in.close(); + } + } catch (Exception e2) { + e2.printStackTrace(); + } + } + return result; + } + + /** + * 向指定 URL 发送POST方法的请求 + * + * @param url + * @param json + * @return + */ + public static String sendPost(String url, String json) { + PrintWriter out = null; + BufferedReader in = null; + String result = ""; + try { + URL realUrl = new URL(url); + // 打开和URL之间的连接 + URLConnection conn = realUrl.openConnection(); + // 设置通用的请求属性 + conn.setRequestProperty("accept", "*/*"); + conn.setRequestProperty("connection", "Keep-Alive"); + conn.setRequestProperty("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)"); + + // 发送POST请求必须设置如下两行 + conn.setDoOutput(true); + conn.setDoInput(true); + // 获取URLConnection对象对应的输出流 + out = new PrintWriter(conn.getOutputStream()); + // 发送请求参数 + out.print(json); + // flush输出流的缓冲 + out.flush(); + // 定义BufferedReader输入流来读取URL的响应 + in = new BufferedReader(new InputStreamReader(conn.getInputStream())); + String line; + while ((line = in.readLine()) != null) { + result += line; + } + } catch (Exception e) { + System.out.println("发送 POST 请求出现异常!" + e); + e.printStackTrace(); + } + //使用finally块来关闭输出流、输入流 + finally { + try { + if (out != null) { + out.close(); + } + if (in != null) { + in.close(); + } + } catch (IOException ex) { + ex.printStackTrace(); + } + } + return result; + } + + /** + * 向指定 URL 发送POST方法的请求 + * + * @param url + * @param json + * @param authorization + * @return + */ + public static String sendPost(String url, String json, String authorization) { + PrintWriter out = null; + BufferedReader in = null; + String result = ""; + try { + URL realUrl = new URL(url); + // 打开和URL之间的连接 + URLConnection conn = realUrl.openConnection(); + // 设置通用的请求属性 + conn.setRequestProperty("Authorization", authorization); + conn.setRequestProperty("accept", "*/*"); + conn.setRequestProperty("connection", "Keep-Alive"); + conn.setRequestProperty("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)"); + + // 发送POST请求必须设置如下两行 + conn.setDoOutput(true); + conn.setDoInput(true); + // 获取URLConnection对象对应的输出流 + out = new PrintWriter(conn.getOutputStream()); + // 发送请求参数 + out.print(json); + // flush输出流的缓冲 + out.flush(); + // 定义BufferedReader输入流来读取URL的响应 + in = new BufferedReader(new InputStreamReader(conn.getInputStream())); + String line; + while ((line = in.readLine()) != null) { + result += line; + } + } catch (Exception e) { + System.out.println("发送 POST 请求出现异常!" + e); + e.printStackTrace(); + } + //使用finally块来关闭输出流、输入流 + finally { + try { + if (out != null) { + out.close(); + } + if (in != null) { + in.close(); + } + } catch (IOException ex) { + ex.printStackTrace(); + } + } + return result; + } +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/utils/HttpsRequest.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/utils/HttpsRequest.java new file mode 100644 index 0000000..70901d9 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/utils/HttpsRequest.java @@ -0,0 +1,426 @@ +package com.iailab.module.data.common.utils; + +import lombok.extern.slf4j.Slf4j; +import org.apache.http.Header; +import org.apache.http.HttpEntity; +import org.apache.http.HttpResponse; +import org.apache.http.client.methods.HttpGet; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.entity.StringEntity; +import org.apache.http.util.EntityUtils; +import org.springframework.stereotype.Component; +import org.springframework.util.CollectionUtils; + +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; +import java.util.Map; +import java.util.Objects; + +/** + * @author PanZhibao + * @date 2021年06月03日 16:40 + */ +@Slf4j +@Component +public class HttpsRequest { + + /** + * doGet + * + * @param url + * @param map + * @param charset + * @param token + * @return + */ + public String doGet(String url, Map<String, String> map, String charset, String token) { + org.apache.http.client.HttpClient httpClient = null; + HttpGet httpGet = null; + String result = null; + try { + httpClient = new SSLClient(); + StringBuilder sb = new StringBuilder(); + sb.append(url); + if (!CollectionUtils.isEmpty(map)) { + sb.append("?"); + map.forEach((k, v) -> { + try { + sb.append(k + "=" + URLEncoder.encode(v, charset) + "&"); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + }); + sb.append("t=" + System.currentTimeMillis()); + } + log.info("doGet,url=" + sb.toString()); + httpGet = new HttpGet(sb.toString()); + //设置参数 + httpGet.addHeader("Accept", "application/json"); + httpGet.addHeader("Content-Type", "application/json;charset=UTF-8"); + httpGet.addHeader("Authorization", token); + HttpResponse response = httpClient.execute(httpGet); + if (response != null) { + HttpEntity resEntity = response.getEntity(); + if (resEntity != null) { + result = EntityUtils.toString(resEntity, charset); + } + } + } catch (Exception ex) { + ex.printStackTrace(); + } + return result; + } + + /** + * doGet + * + * @param url + * @param map + * @param charset + * @param authorization + * @return + */ + public String doGetKIO(String url, Map<String, String> map, String charset, String authorization) { + org.apache.http.client.HttpClient httpClient = null; + HttpGet httpGet = null; + String result = null; + try { + httpClient = new SSLClient(); + StringBuilder sb = new StringBuilder(); + sb.append(url); + if (!CollectionUtils.isEmpty(map)) { + sb.append("?"); + map.forEach((k, v) -> { + try { + sb.append(k + "=" + URLEncoder.encode(v, charset) + "&"); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + }); + sb.append("t=" + System.currentTimeMillis()); + } + log.info("doGet,url=" + sb.toString()); + httpGet = new HttpGet(sb.toString()); + //设置参数 + httpGet.addHeader("Accept", "application/json"); + httpGet.addHeader("Content-Type", "application/json;charset=UTF-8"); + httpGet.addHeader("Authorization", authorization); + HttpResponse response = httpClient.execute(httpGet); + if (response != null) { + HttpEntity resEntity = response.getEntity(); + if (resEntity != null) { + result = EntityUtils.toString(resEntity, charset); + } + } + } catch (Exception ex) { + ex.printStackTrace(); + } + return result; + } + + /** + * doPost + * + * @param url + * @param map + * @param json + * @param charset + * @param token + * @return + */ + public String doPost(String url, Map<String, String> map, String json, String charset, String token) { + org.apache.http.client.HttpClient httpClient = null; + HttpPost httpPost = null; + String result = null; + try { + httpClient = new SSLClient(); + StringBuilder sb = new StringBuilder(); + sb.append(url); + if (!CollectionUtils.isEmpty(map)) { + sb.append("?"); + map.forEach((k, v) -> { + try { + sb.append(k + "=" + URLEncoder.encode(v, charset) + "&"); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + }); + sb.append("t=" + System.currentTimeMillis()); + } + httpPost = new HttpPost(sb.toString()); + //设置参数 + httpPost.addHeader("Accept", "application/json"); + httpPost.addHeader("Content-Type", "application/json;charset=UTF-8"); + httpPost.addHeader("token", token); + StringEntity stringEntity = new StringEntity(json); + stringEntity.setContentEncoding("UTF-8"); + stringEntity.setContentType("application/json"); + httpPost.setEntity(stringEntity); + HttpResponse response = httpClient.execute(httpPost); + if (response != null) { + HttpEntity resEntity = response.getEntity(); + if (resEntity != null) { + result = EntityUtils.toString(resEntity, charset); + } + } + } catch (Exception ex) { + // ex.printStackTrace(); + log.info("doPost失败,url=" + url); + } + return result; + } + + + /** + * doPost + * + * @param url + * @param map + * @param json + * @param charset + * @param authorization + * @return + */ + public String doPostKIO(String url, Map<String, String> map, String json, String charset, String authorization) { + org.apache.http.client.HttpClient httpClient = null; + HttpPost httpPost = null; + String result = null; + try { + httpClient = new SSLClient(); + StringBuilder sb = new StringBuilder(); + sb.append(url); + if (!CollectionUtils.isEmpty(map)) { + sb.append("?"); + map.forEach((k, v) -> { + try { + sb.append(k + "=" + URLEncoder.encode(v, charset) + "&"); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + }); + sb.append("t=" + System.currentTimeMillis()); + } + httpPost = new HttpPost(sb.toString()); + //设置参数 + httpPost.addHeader("Accept", "application/json"); + httpPost.addHeader("Content-Type", "application/json;charset=UTF-8"); + httpPost.addHeader("Authorization", authorization); + StringEntity stringEntity = new StringEntity(json); + stringEntity.setContentEncoding("UTF-8"); + stringEntity.setContentType("application/json"); + httpPost.setEntity(stringEntity); + HttpResponse response = httpClient.execute(httpPost); + if (response != null) { + HttpEntity resEntity = response.getEntity(); + if (resEntity != null) { + result = EntityUtils.toString(resEntity, charset); + } + } + } catch (Exception ex) { + ex.printStackTrace(); + } + return result; + } + + /** + * doPost + * + * @param url + * @param map + * @param json + * @param charset + * @param token + * @return + */ + public String doPostAuthorization(String url, Map<String, String> map, String json, String charset, String token) { + org.apache.http.client.HttpClient httpClient = null; + HttpPost httpPost = null; + String result = null; + try { + httpClient = new SSLClient(); + StringBuilder sb = new StringBuilder(); + sb.append(url); + if (!CollectionUtils.isEmpty(map)) { + sb.append("?"); + map.forEach((k, v) -> { + try { + sb.append(k + "=" + URLEncoder.encode(v, charset) + "&"); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + }); + sb.append("t=" + System.currentTimeMillis()); + } + httpPost = new HttpPost(sb.toString()); + //设置参数 + httpPost.addHeader("Accept", "application/json"); + httpPost.addHeader("Content-Type", "application/json;charset=UTF-8"); + httpPost.addHeader("Authorization", "Bearer{" + token + "}"); + StringEntity stringEntity = new StringEntity(json); + stringEntity.setContentEncoding("UTF-8"); + stringEntity.setContentType("application/json"); + httpPost.setEntity(stringEntity); + HttpResponse response = httpClient.execute(httpPost); + if (response != null) { + HttpEntity resEntity = response.getEntity(); + if (resEntity != null) { + result = EntityUtils.toString(resEntity, charset); + } + } + } catch (Exception ex) { + ex.printStackTrace(); + } + return result; + } + + /** + * doPost + * + * @param url + * @param map + * @param json + * @param charset + * @return + */ + public String doPostToken(String url, Map<String, String> map, String json, String charset) { + org.apache.http.client.HttpClient httpClient = null; + HttpPost httpPost = null; + String result = null; + try { + httpClient = new SSLClient(); + StringBuilder sb = new StringBuilder(); + sb.append(url); + if (!CollectionUtils.isEmpty(map)) { + sb.append("?"); + map.forEach((k, v) -> { + try { + sb.append(k + "=" + URLEncoder.encode(v, charset) + "&"); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + }); + sb.append("t=" + System.currentTimeMillis()); + } + httpPost = new HttpPost(sb.toString()); + //设置参数 + httpPost.addHeader("Accept", "application/json"); + httpPost.addHeader("Content-Type", "application/json;charset=UTF-8"); + StringEntity stringEntity = new StringEntity(json); + stringEntity.setContentEncoding("UTF-8"); + stringEntity.setContentType("application/json"); + httpPost.setEntity(stringEntity); + HttpResponse response = httpClient.execute(httpPost); + if (response != null) { + Header[] resHeader = response.getHeaders("X-Auth-Tkn"); + if (resHeader != null) { + result = resHeader[0].getValue(); + } + } + } catch (Exception ex) { + ex.printStackTrace(); + } + return result; + } + + /** + * doGet + * + * @param url + * @param map + * @param charset + * @param token + * @param tMap + * @return + */ + public String doGetSDData(String url, Map<String, String> map, String charset, String token, Map<String, String> tMap) { + org.apache.http.client.HttpClient httpClient = null; + HttpGet httpGet = null; + String result = null; + try { + httpClient = new SSLClient(); + StringBuilder sb = new StringBuilder(); + sb.append(url); + if (!CollectionUtils.isEmpty(map)) { + sb.append("?"); + map.forEach((k, v) -> { + try { + sb.append(k + "=" + URLEncoder.encode(v, charset) + "&"); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + }); + sb.append("t=" + System.currentTimeMillis()); + } + log.info("doGet,url=" + sb.toString()); + httpGet = new HttpGet(sb.toString()); + //设置参数 + httpGet.addHeader("Content-Type", "application/json"); + httpGet.addHeader("X-Auth-Tkn", token); + if(!Objects.isNull(tMap.get("X-Forwarded-OrgSet"))){ + httpGet.addHeader("X-Forwarded-OrgSet", tMap.get("X-Forwarded-OrgSet")); + } + if(!Objects.isNull(tMap.get("X-Forwarded-PrId"))){ + httpGet.addHeader("X-Forwarded-PrId", tMap.get("X-Forwarded-PrId")); + } + if(!Objects.isNull(tMap.get("X-Request-Id"))){ + httpGet.addHeader("X-Request-Id", tMap.get("X-Request-Id")); + } + HttpResponse response = httpClient.execute(httpGet); + if (response != null) { + HttpEntity resEntity = response.getEntity(); + if (resEntity != null) { + result = EntityUtils.toString(resEntity, charset); + } + } + } catch (Exception ex) { + ex.printStackTrace(); + } + return result; + } + + /** + * doGet + * + * @param url + * @param map + * @param charset + * @param token + * @return + */ + public String doGetDeviceList(String url, Map<String, String> map, String charset, String token) { + org.apache.http.client.HttpClient httpClient = null; + HttpGet httpGet = null; + String result = null; + try { + httpClient = new SSLClient(); + StringBuilder sb = new StringBuilder(); + sb.append(url); + if (!CollectionUtils.isEmpty(map)) { + sb.append("?"); + map.forEach((k, v) -> { + try { + sb.append(k + "=" + URLEncoder.encode(v, charset) + "&"); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + }); + sb.append("t=" + System.currentTimeMillis()); + } + log.info("doGet,url=" + sb.toString()); + httpGet = new HttpGet(sb.toString()); + //设置参数 + httpGet.addHeader("Content-Type", "application/json"); + httpGet.addHeader("X-App-Secret", token); + HttpResponse response = httpClient.execute(httpGet); + if (response != null) { + HttpEntity resEntity = response.getEntity(); + if (resEntity != null) { + result = EntityUtils.toString(resEntity, charset); + } + } + } catch (Exception ex) { + ex.printStackTrace(); + } + return result; + } +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/utils/JavaScriptHandler.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/utils/JavaScriptHandler.java new file mode 100644 index 0000000..c47391b --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/utils/JavaScriptHandler.java @@ -0,0 +1,27 @@ +package com.iailab.module.data.common.utils; + +import javax.annotation.Resource; +import org.springframework.stereotype.Component; + +import javax.script.ScriptEngine; +import javax.script.ScriptException; + +/** + * @author PanZhibao + * @date 2021年06月04日 16:01 + */ +@Component +public class JavaScriptHandler { + + @Resource + ScriptEngine scriptEngine; + + public String eval (String script) { + try { + return scriptEngine.eval(script).toString(); + } catch (ScriptException e) { + e.printStackTrace(); + return null; + } + } +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/utils/MD5Util.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/utils/MD5Util.java new file mode 100644 index 0000000..a23ebc0 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/utils/MD5Util.java @@ -0,0 +1,29 @@ +package com.iailab.module.data.common.utils; + +import java.io.UnsupportedEncodingException; +import java.math.BigInteger; +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年06月05日 + */ +public class MD5Util { + + public static String getMD5Str(String str) { + byte[] digest = null; + try { + MessageDigest md5 = MessageDigest.getInstance("md5"); + digest = md5.digest(str.getBytes("utf-8")); + } catch (NoSuchAlgorithmException e) { + e.printStackTrace(); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + //16是表示转换为16进制数 + String md5Str = new BigInteger(1, digest).toString(16); + return md5Str; + } +} \ No newline at end of file diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/utils/MapUtils.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/utils/MapUtils.java new file mode 100644 index 0000000..2f27a60 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/utils/MapUtils.java @@ -0,0 +1,18 @@ +package com.iailab.module.data.common.utils; + +import java.util.HashMap; + + +/** + * Map工具类 + * + * @author Mark sunlightcs@gmail.com + */ +public class MapUtils extends HashMap<String, Object> { + + @Override + public MapUtils put(String key, Object value) { + super.put(key, value); + return this; + } +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/utils/PageUtils.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/utils/PageUtils.java new file mode 100644 index 0000000..d9225b8 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/utils/PageUtils.java @@ -0,0 +1,117 @@ +package com.iailab.module.data.common.utils; + +import com.baomidou.mybatisplus.core.metadata.IPage; + +import java.io.Serializable; +import java.util.List; + +/** + * 分页工具类 + * + * @author Mark sunlightcs@gmail.com + */ +public class PageUtils implements Serializable { + private static final long serialVersionUID = 1L; + + /** + * 总记录数 + */ + private int total; + + /** + * 总记录数 + */ + private int totalCount; + /** + * 每页记录数 + */ + private int pageSize; + /** + * 总页数 + */ + private int totalPage; + /** + * 当前页数 + */ + private int currPage; + /** + * 列表数据 + */ + private List<?> list; + + /** + * 分页 + * @param list 列表数据 + * @param totalCount 总记录数 + * @param pageSize 每页记录数 + * @param currPage 当前页数 + */ + public PageUtils(List<?> list, int totalCount, int pageSize, int currPage) { + this.list = list; + this.total = totalCount; + this.totalCount = totalCount; + this.pageSize = pageSize; + this.currPage = currPage; + this.totalPage = (int)Math.ceil((double)totalCount/pageSize); + } + + /** + * 分页 + */ + public PageUtils(IPage<?> page) { + this.list = page.getRecords(); + this.total = (int)page.getTotal(); + this.totalCount = (int)page.getTotal(); + this.pageSize = (int)page.getSize(); + this.currPage = (int)page.getCurrent(); + this.totalPage = (int)page.getPages(); + } + + public int getTotal() { + return total; + } + + public void setTotal(int total) { + this.total = total; + } + public int getTotalCount() { + return totalCount; + } + + public void setTotalCount(int totalCount) { + this.totalCount = totalCount; + } + + public int getPageSize() { + return pageSize; + } + + public void setPageSize(int pageSize) { + this.pageSize = pageSize; + } + + public int getTotalPage() { + return totalPage; + } + + public void setTotalPage(int totalPage) { + this.totalPage = totalPage; + } + + public int getCurrPage() { + return currPage; + } + + public void setCurrPage(int currPage) { + this.currPage = currPage; + } + + public List<?> getList() { + return list; + } + + public void setList(List<?> list) { + this.list = list; + } + +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/utils/Query.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/utils/Query.java new file mode 100644 index 0000000..b965fb9 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/utils/Query.java @@ -0,0 +1,69 @@ +package com.iailab.module.data.common.utils; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.core.metadata.OrderItem; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.iailab.module.data.common.xss.SQLFilter; +import org.apache.commons.lang3.StringUtils; + +import java.util.Map; + +/** + * 查询参数 + * + * @author Mark sunlightcs@gmail.com + */ +public class Query<T> { + + public IPage<T> getPage(Map<String, Object> params) { + return this.getPage(params, null, false); + } + + public IPage<T> getPage(Map<String, Object> params, String defaultOrderField, boolean isAsc) { + //分页参数 + long curPage = 1; + long limit = 10; + + if(params.get(Constant.PAGE) != null){ + curPage = Long.parseLong((String)params.get(Constant.PAGE)); + } + if(params.get(Constant.LIMIT) != null){ + limit = Long.parseLong((String)params.get(Constant.LIMIT)); + } + + //分页对象 + Page<T> page = new Page<>(curPage, limit); + + //分页参数 + params.put(Constant.PAGE, page); + + //排序字段 + //防止SQL注入(因为sidx、order是通过拼接SQL实现排序的,会有SQL注入风险) + String orderField = SQLFilter.sqlInject((String)params.get(Constant.ORDER_FIELD)); + String order = (String)params.get(Constant.ORDER); + + + //前端字段排序 + if(StringUtils.isNotEmpty(orderField) && StringUtils.isNotEmpty(order)){ + if(Constant.ASC.equalsIgnoreCase(order)) { + return page.addOrder(OrderItem.asc(orderField)); + }else { + return page.addOrder(OrderItem.desc(orderField)); + } + } + + //没有排序字段,则不排序 + if(StringUtils.isBlank(defaultOrderField)){ + return page; + } + + //默认排序 + if(isAsc) { + page.addOrder(OrderItem.asc(defaultOrderField)); + }else { + page.addOrder(OrderItem.desc(defaultOrderField)); + } + + return page; + } +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/utils/R.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/utils/R.java new file mode 100644 index 0000000..ddcc2a0 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/utils/R.java @@ -0,0 +1,64 @@ +/** + * Copyright (c) 2016-2019 人人开源 All rights reserved. + * + * https://www.renren.io + * + * 版权所有,侵权必究! + */ + +package com.iailab.module.data.common.utils; + +import org.apache.http.HttpStatus; + +import java.util.HashMap; +import java.util.Map; + +/** + * 返回数据 + * + * @author Mark sunlightcs@gmail.com + */ +public class R extends HashMap<String, Object> { + private static final long serialVersionUID = 1L; + + public R() { + put("code", 0); + put("msg", "success"); + } + + public static R error() { + return error(HttpStatus.SC_INTERNAL_SERVER_ERROR, "未知异常,请联系管理员"); + } + + public static R error(String msg) { + return error(HttpStatus.SC_INTERNAL_SERVER_ERROR, msg); + } + + public static R error(int code, String msg) { + R r = new R(); + r.put("code", code); + r.put("msg", msg); + return r; + } + + public static R ok(String msg) { + R r = new R(); + r.put("msg", msg); + return r; + } + + public static R ok(Map<String, Object> map) { + R r = new R(); + r.putAll(map); + return r; + } + + public static R ok() { + return new R(); + } + + public R put(String key, Object value) { + super.put(key, value); + return this; + } +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/utils/SSLClient.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/utils/SSLClient.java new file mode 100644 index 0000000..a3c4710 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/utils/SSLClient.java @@ -0,0 +1,45 @@ +package com.iailab.module.data.common.utils; + + +import org.apache.http.conn.ClientConnectionManager; +import org.apache.http.conn.scheme.Scheme; +import org.apache.http.conn.scheme.SchemeRegistry; +import org.apache.http.conn.ssl.SSLSocketFactory; +import org.apache.http.impl.client.DefaultHttpClient; + +import javax.net.ssl.SSLContext; +import javax.net.ssl.TrustManager; +import javax.net.ssl.X509TrustManager; +import java.security.cert.CertificateException; +import java.security.cert.X509Certificate; + +/** + * @author PanZhibao + * @date 2021年06月03日 15:35 + */ +public class SSLClient extends DefaultHttpClient { + public SSLClient() throws Exception { + super(); + //传输协议需要根据自己的判断 + SSLContext ctx = SSLContext.getInstance("TLS"); + X509TrustManager tm = new X509TrustManager() { + @Override + public void checkClientTrusted(X509Certificate[] chain, String authType) throws CertificateException { + } + + @Override + public void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException { + } + + @Override + public X509Certificate[] getAcceptedIssuers() { + return null; + } + }; + ctx.init(null, new TrustManager[]{tm}, null); + SSLSocketFactory ssf = new SSLSocketFactory(ctx, SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER); + ClientConnectionManager ccm = this.getConnectionManager(); + SchemeRegistry sr = ccm.getSchemeRegistry(); + sr.register(new Scheme("https", 443, ssf)); + } +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/utils/ScriptEngineConfiguration.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/utils/ScriptEngineConfiguration.java new file mode 100644 index 0000000..e0322be --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/utils/ScriptEngineConfiguration.java @@ -0,0 +1,20 @@ +package com.iailab.module.data.common.utils; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +import javax.script.ScriptEngine; +import javax.script.ScriptEngineManager; + +/** + * @author PanZhibao + * @date 2021年06月09日 16:38 + */ +@Configuration +public class ScriptEngineConfiguration { + + @Bean("scriptEngine") + public ScriptEngine scriptEngine() { + return new ScriptEngineManager().getEngineByName("javascript"); + } +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/utils/TagUtils.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/utils/TagUtils.java new file mode 100644 index 0000000..32e1687 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/utils/TagUtils.java @@ -0,0 +1,15 @@ +package com.iailab.module.data.common.utils; + +import java.text.MessageFormat; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年05月12日 + */ +public class TagUtils { + + public static String genTagId(String sourceType, String sourceName, String tagNo) { + return MessageFormat.format("source={0};id={1}.{2}", sourceType, sourceName, tagNo); + } +} \ No newline at end of file diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/xss/HTMLFilter.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/xss/HTMLFilter.java new file mode 100644 index 0000000..31dce39 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/xss/HTMLFilter.java @@ -0,0 +1,530 @@ +package com.iailab.module.data.common.xss; + +import java.util.*; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentMap; +import java.util.logging.Logger; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * + * HTML filtering utility for protecting against XSS (Cross Site Scripting). + * + * This code is licensed LGPLv3 + * + * This code is a Java port of the original work in PHP by Cal Hendersen. + * http://code.iamcal.com/php/lib_filter/ + * + * The trickiest part of the translation was handling the differences in regex handling + * between PHP and Java. These resources were helpful in the process: + * + * http://java.sun.com/j2se/1.4.2/docs/api/java/util/regex/Pattern.html + * http://us2.php.net/manual/en/reference.pcre.pattern.modifiers.php + * http://www.regular-expressions.info/modifiers.html + * + * A note on naming conventions: instance variables are prefixed with a "v"; global + * constants are in all caps. + * + * Sample use: + * String input = ... + * String clean = new HTMLFilter().filter( input ); + * + * The class is not thread safe. Create a new instance if in doubt. + * + * If you find bugs or have suggestions on improvement (especially regarding + * performance), please contact us. The latest version of this + * source, and our contact details, can be found at http://xss-html-filter.sf.net + * + * @author Joseph O'Connell + * @author Cal Hendersen + * @author Michael Semb Wever + */ +public final class HTMLFilter { + + /** regex flag union representing /si modifiers in php **/ + private static final int REGEX_FLAGS_SI = Pattern.CASE_INSENSITIVE | Pattern.DOTALL; + private static final Pattern P_COMMENTS = Pattern.compile("<!--(.*?)-->", Pattern.DOTALL); + private static final Pattern P_COMMENT = Pattern.compile("^!--(.*)--$", REGEX_FLAGS_SI); + private static final Pattern P_TAGS = Pattern.compile("<(.*?)>", Pattern.DOTALL); + private static final Pattern P_END_TAG = Pattern.compile("^/([a-z0-9]+)", REGEX_FLAGS_SI); + private static final Pattern P_START_TAG = Pattern.compile("^([a-z0-9]+)(.*?)(/?)$", REGEX_FLAGS_SI); + private static final Pattern P_QUOTED_ATTRIBUTES = Pattern.compile("([a-z0-9]+)=([\"'])(.*?)\\2", REGEX_FLAGS_SI); + private static final Pattern P_UNQUOTED_ATTRIBUTES = Pattern.compile("([a-z0-9]+)(=)([^\"\\s']+)", REGEX_FLAGS_SI); + private static final Pattern P_PROTOCOL = Pattern.compile("^([^:]+):", REGEX_FLAGS_SI); + private static final Pattern P_ENTITY = Pattern.compile("&#(\\d+);?"); + private static final Pattern P_ENTITY_UNICODE = Pattern.compile("&#x([0-9a-f]+);?"); + private static final Pattern P_ENCODE = Pattern.compile("%([0-9a-f]{2});?"); + private static final Pattern P_VALID_ENTITIES = Pattern.compile("&([^&;]*)(?=(;|&|$))"); + private static final Pattern P_VALID_QUOTES = Pattern.compile("(>|^)([^<]+?)(<|$)", Pattern.DOTALL); + private static final Pattern P_END_ARROW = Pattern.compile("^>"); + private static final Pattern P_BODY_TO_END = Pattern.compile("<([^>]*?)(?=<|$)"); + private static final Pattern P_XML_CONTENT = Pattern.compile("(^|>)([^<]*?)(?=>)"); + private static final Pattern P_STRAY_LEFT_ARROW = Pattern.compile("<([^>]*?)(?=<|$)"); + private static final Pattern P_STRAY_RIGHT_ARROW = Pattern.compile("(^|>)([^<]*?)(?=>)"); + private static final Pattern P_AMP = Pattern.compile("&"); + private static final Pattern P_QUOTE = Pattern.compile("<"); + private static final Pattern P_LEFT_ARROW = Pattern.compile("<"); + private static final Pattern P_RIGHT_ARROW = Pattern.compile(">"); + private static final Pattern P_BOTH_ARROWS = Pattern.compile("<>"); + + // @xxx could grow large... maybe use sesat's ReferenceMap + private static final ConcurrentMap<String,Pattern> P_REMOVE_PAIR_BLANKS = new ConcurrentHashMap<String, Pattern>(); + private static final ConcurrentMap<String,Pattern> P_REMOVE_SELF_BLANKS = new ConcurrentHashMap<String, Pattern>(); + + /** set of allowed html elements, along with allowed attributes for each element **/ + private final Map<String, List<String>> vAllowed; + /** counts of open tags for each (allowable) html element **/ + private final Map<String, Integer> vTagCounts = new HashMap<String, Integer>(); + + /** html elements which must always be self-closing (e.g. "<img />") **/ + private final String[] vSelfClosingTags; + /** html elements which must always have separate opening and closing tags (e.g. "<b></b>") **/ + private final String[] vNeedClosingTags; + /** set of disallowed html elements **/ + private final String[] vDisallowed; + /** attributes which should be checked for valid protocols **/ + private final String[] vProtocolAtts; + /** allowed protocols **/ + private final String[] vAllowedProtocols; + /** tags which should be removed if they contain no content (e.g. "<b></b>" or "<b />") **/ + private final String[] vRemoveBlanks; + /** entities allowed within html markup **/ + private final String[] vAllowedEntities; + /** flag determining whether comments are allowed in input String. */ + private final boolean stripComment; + private final boolean encodeQuotes; + private boolean vDebug = false; + /** + * flag determining whether to try to make tags when presented with "unbalanced" + * angle brackets (e.g. "<b text </b>" becomes "<b> text </b>"). If set to false, + * unbalanced angle brackets will be html escaped. + */ + private final boolean alwaysMakeTags; + + /** Default constructor. + * + */ + public HTMLFilter() { + vAllowed = new HashMap<>(); + + final ArrayList<String> a_atts = new ArrayList<String>(); + a_atts.add("href"); + a_atts.add("target"); + vAllowed.put("a", a_atts); + + final ArrayList<String> img_atts = new ArrayList<String>(); + img_atts.add("src"); + img_atts.add("width"); + img_atts.add("height"); + img_atts.add("alt"); + vAllowed.put("img", img_atts); + + final ArrayList<String> no_atts = new ArrayList<String>(); + vAllowed.put("b", no_atts); + vAllowed.put("strong", no_atts); + vAllowed.put("i", no_atts); + vAllowed.put("em", no_atts); + + vSelfClosingTags = new String[]{"img"}; + vNeedClosingTags = new String[]{"a", "b", "strong", "i", "em"}; + vDisallowed = new String[]{}; + vAllowedProtocols = new String[]{"http", "mailto", "https"}; // no ftp. + vProtocolAtts = new String[]{"src", "href"}; + vRemoveBlanks = new String[]{"a", "b", "strong", "i", "em"}; + vAllowedEntities = new String[]{"amp", "gt", "lt", "quot"}; + stripComment = true; + encodeQuotes = true; + alwaysMakeTags = true; + } + + /** Set debug flag to true. Otherwise use default settings. See the default constructor. + * + * @param debug turn debug on with a true argument + */ + public HTMLFilter(final boolean debug) { + this(); + vDebug = debug; + + } + + /** Map-parameter configurable constructor. + * + * @param conf map containing configuration. keys match field names. + */ + public HTMLFilter(final Map<String,Object> conf) { + + assert conf.containsKey("vAllowed") : "configuration requires vAllowed"; + assert conf.containsKey("vSelfClosingTags") : "configuration requires vSelfClosingTags"; + assert conf.containsKey("vNeedClosingTags") : "configuration requires vNeedClosingTags"; + assert conf.containsKey("vDisallowed") : "configuration requires vDisallowed"; + assert conf.containsKey("vAllowedProtocols") : "configuration requires vAllowedProtocols"; + assert conf.containsKey("vProtocolAtts") : "configuration requires vProtocolAtts"; + assert conf.containsKey("vRemoveBlanks") : "configuration requires vRemoveBlanks"; + assert conf.containsKey("vAllowedEntities") : "configuration requires vAllowedEntities"; + + vAllowed = Collections.unmodifiableMap((HashMap<String, List<String>>) conf.get("vAllowed")); + vSelfClosingTags = (String[]) conf.get("vSelfClosingTags"); + vNeedClosingTags = (String[]) conf.get("vNeedClosingTags"); + vDisallowed = (String[]) conf.get("vDisallowed"); + vAllowedProtocols = (String[]) conf.get("vAllowedProtocols"); + vProtocolAtts = (String[]) conf.get("vProtocolAtts"); + vRemoveBlanks = (String[]) conf.get("vRemoveBlanks"); + vAllowedEntities = (String[]) conf.get("vAllowedEntities"); + stripComment = conf.containsKey("stripComment") ? (Boolean) conf.get("stripComment") : true; + encodeQuotes = conf.containsKey("encodeQuotes") ? (Boolean) conf.get("encodeQuotes") : true; + alwaysMakeTags = conf.containsKey("alwaysMakeTags") ? (Boolean) conf.get("alwaysMakeTags") : true; + } + + private void reset() { + vTagCounts.clear(); + } + + private void debug(final String msg) { + if (vDebug) { + Logger.getAnonymousLogger().info(msg); + } + } + + //--------------------------------------------------------------- + // my versions of some PHP library functions + public static String chr(final int decimal) { + return String.valueOf((char) decimal); + } + + public static String htmlSpecialChars(final String s) { + String result = s; + result = regexReplace(P_AMP, "&", result); + result = regexReplace(P_QUOTE, """, result); + result = regexReplace(P_LEFT_ARROW, "<", result); + result = regexReplace(P_RIGHT_ARROW, ">", result); + return result; + } + + //--------------------------------------------------------------- + /** + * given a user submitted input String, filter out any invalid or restricted + * html. + * + * @param input text (i.e. submitted by a user) than may contain html + * @return "clean" version of input, with only valid, whitelisted html elements allowed + */ + public String filter(final String input) { + reset(); + String s = input; + + debug("************************************************"); + debug(" INPUT: " + input); + + s = escapeComments(s); + debug(" escapeComments: " + s); + + s = balanceHTML(s); + debug(" balanceHTML: " + s); + + s = checkTags(s); + debug(" checkTags: " + s); + + s = processRemoveBlanks(s); + debug("processRemoveBlanks: " + s); + + s = validateEntities(s); + debug(" validateEntites: " + s); + + debug("************************************************\n\n"); + return s; + } + + public boolean isAlwaysMakeTags(){ + return alwaysMakeTags; + } + + public boolean isStripComments(){ + return stripComment; + } + + private String escapeComments(final String s) { + final Matcher m = P_COMMENTS.matcher(s); + final StringBuffer buf = new StringBuffer(); + if (m.find()) { + final String match = m.group(1); //(.*?) + m.appendReplacement(buf, Matcher.quoteReplacement("<!--" + htmlSpecialChars(match) + "-->")); + } + m.appendTail(buf); + + return buf.toString(); + } + + private String balanceHTML(String s) { + if (alwaysMakeTags) { + // + // try and form html + // + s = regexReplace(P_END_ARROW, "", s); + s = regexReplace(P_BODY_TO_END, "<$1>", s); + s = regexReplace(P_XML_CONTENT, "$1<$2", s); + + } else { + // + // escape stray brackets + // + s = regexReplace(P_STRAY_LEFT_ARROW, "<$1", s); + s = regexReplace(P_STRAY_RIGHT_ARROW, "$1$2><", s); + + // + // the last regexp causes '<>' entities to appear + // (we need to do a lookahead assertion so that the last bracket can + // be used in the next pass of the regexp) + // + s = regexReplace(P_BOTH_ARROWS, "", s); + } + + return s; + } + + private String checkTags(String s) { + Matcher m = P_TAGS.matcher(s); + + final StringBuffer buf = new StringBuffer(); + while (m.find()) { + String replaceStr = m.group(1); + replaceStr = processTag(replaceStr); + m.appendReplacement(buf, Matcher.quoteReplacement(replaceStr)); + } + m.appendTail(buf); + + s = buf.toString(); + + // these get tallied in processTag + // (remember to reset before subsequent calls to filter method) + for (String key : vTagCounts.keySet()) { + for (int ii = 0; ii < vTagCounts.get(key); ii++) { + s += "</" + key + ">"; + } + } + + return s; + } + + private String processRemoveBlanks(final String s) { + String result = s; + for (String tag : vRemoveBlanks) { + if(!P_REMOVE_PAIR_BLANKS.containsKey(tag)){ + P_REMOVE_PAIR_BLANKS.putIfAbsent(tag, Pattern.compile("<" + tag + "(\\s[^>]*)?></" + tag + ">")); + } + result = regexReplace(P_REMOVE_PAIR_BLANKS.get(tag), "", result); + if(!P_REMOVE_SELF_BLANKS.containsKey(tag)){ + P_REMOVE_SELF_BLANKS.putIfAbsent(tag, Pattern.compile("<" + tag + "(\\s[^>]*)?/>")); + } + result = regexReplace(P_REMOVE_SELF_BLANKS.get(tag), "", result); + } + + return result; + } + + private static String regexReplace(final Pattern regex_pattern, final String replacement, final String s) { + Matcher m = regex_pattern.matcher(s); + return m.replaceAll(replacement); + } + + private String processTag(final String s) { + // ending tags + Matcher m = P_END_TAG.matcher(s); + if (m.find()) { + final String name = m.group(1).toLowerCase(); + if (allowed(name)) { + if (!inArray(name, vSelfClosingTags)) { + if (vTagCounts.containsKey(name)) { + vTagCounts.put(name, vTagCounts.get(name) - 1); + return "</" + name + ">"; + } + } + } + } + + // starting tags + m = P_START_TAG.matcher(s); + if (m.find()) { + final String name = m.group(1).toLowerCase(); + final String body = m.group(2); + String ending = m.group(3); + + //debug( "in a starting tag, name='" + name + "'; body='" + body + "'; ending='" + ending + "'" ); + if (allowed(name)) { + String params = ""; + + final Matcher m2 = P_QUOTED_ATTRIBUTES.matcher(body); + final Matcher m3 = P_UNQUOTED_ATTRIBUTES.matcher(body); + final List<String> paramNames = new ArrayList<String>(); + final List<String> paramValues = new ArrayList<String>(); + while (m2.find()) { + paramNames.add(m2.group(1)); //([a-z0-9]+) + paramValues.add(m2.group(3)); //(.*?) + } + while (m3.find()) { + paramNames.add(m3.group(1)); //([a-z0-9]+) + paramValues.add(m3.group(3)); //([^\"\\s']+) + } + + String paramName, paramValue; + for (int ii = 0; ii < paramNames.size(); ii++) { + paramName = paramNames.get(ii).toLowerCase(); + paramValue = paramValues.get(ii); + +// debug( "paramName='" + paramName + "'" ); +// debug( "paramValue='" + paramValue + "'" ); +// debug( "allowed? " + vAllowed.get( name ).contains( paramName ) ); + + if (allowedAttribute(name, paramName)) { + if (inArray(paramName, vProtocolAtts)) { + paramValue = processParamProtocol(paramValue); + } + params += " " + paramName + "=\"" + paramValue + "\""; + } + } + + if (inArray(name, vSelfClosingTags)) { + ending = " /"; + } + + if (inArray(name, vNeedClosingTags)) { + ending = ""; + } + + if (ending == null || ending.length() < 1) { + if (vTagCounts.containsKey(name)) { + vTagCounts.put(name, vTagCounts.get(name) + 1); + } else { + vTagCounts.put(name, 1); + } + } else { + ending = " /"; + } + return "<" + name + params + ending + ">"; + } else { + return ""; + } + } + + // comments + m = P_COMMENT.matcher(s); + if (!stripComment && m.find()) { + return "<" + m.group() + ">"; + } + + return ""; + } + + private String processParamProtocol(String s) { + s = decodeEntities(s); + final Matcher m = P_PROTOCOL.matcher(s); + if (m.find()) { + final String protocol = m.group(1); + if (!inArray(protocol, vAllowedProtocols)) { + // bad protocol, turn into local anchor link instead + s = "#" + s.substring(protocol.length() + 1, s.length()); + if (s.startsWith("#//")) { + s = "#" + s.substring(3, s.length()); + } + } + } + + return s; + } + + private String decodeEntities(String s) { + StringBuffer buf = new StringBuffer(); + + Matcher m = P_ENTITY.matcher(s); + while (m.find()) { + final String match = m.group(1); + final int decimal = Integer.decode(match).intValue(); + m.appendReplacement(buf, Matcher.quoteReplacement(chr(decimal))); + } + m.appendTail(buf); + s = buf.toString(); + + buf = new StringBuffer(); + m = P_ENTITY_UNICODE.matcher(s); + while (m.find()) { + final String match = m.group(1); + final int decimal = Integer.valueOf(match, 16).intValue(); + m.appendReplacement(buf, Matcher.quoteReplacement(chr(decimal))); + } + m.appendTail(buf); + s = buf.toString(); + + buf = new StringBuffer(); + m = P_ENCODE.matcher(s); + while (m.find()) { + final String match = m.group(1); + final int decimal = Integer.valueOf(match, 16).intValue(); + m.appendReplacement(buf, Matcher.quoteReplacement(chr(decimal))); + } + m.appendTail(buf); + s = buf.toString(); + + s = validateEntities(s); + return s; + } + + private String validateEntities(final String s) { + StringBuffer buf = new StringBuffer(); + + // validate entities throughout the string + Matcher m = P_VALID_ENTITIES.matcher(s); + while (m.find()) { + final String one = m.group(1); //([^&;]*) + final String two = m.group(2); //(?=(;|&|$)) + m.appendReplacement(buf, Matcher.quoteReplacement(checkEntity(one, two))); + } + m.appendTail(buf); + + return encodeQuotes(buf.toString()); + } + + private String encodeQuotes(final String s){ + if(encodeQuotes){ + StringBuffer buf = new StringBuffer(); + Matcher m = P_VALID_QUOTES.matcher(s); + while (m.find()) { + final String one = m.group(1); //(>|^) + final String two = m.group(2); //([^<]+?) + final String three = m.group(3); //(<|$) + m.appendReplacement(buf, Matcher.quoteReplacement(one + regexReplace(P_QUOTE, """, two) + three)); + } + m.appendTail(buf); + return buf.toString(); + }else{ + return s; + } + } + + private String checkEntity(final String preamble, final String term) { + + return ";".equals(term) && isValidEntity(preamble) + ? '&' + preamble + : "&" + preamble; + } + + private boolean isValidEntity(final String entity) { + return inArray(entity, vAllowedEntities); + } + + private static boolean inArray(final String s, final String[] array) { + for (String item : array) { + if (item != null && item.equals(s)) { + return true; + } + } + return false; + } + + private boolean allowed(final String name) { + return (vAllowed.isEmpty() || vAllowed.containsKey(name)) && !inArray(name, vDisallowed); + } + + private boolean allowedAttribute(final String name, final String paramName) { + return allowed(name) && (vAllowed.isEmpty() || vAllowed.get(name).contains(paramName)); + } +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/xss/SQLFilter.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/xss/SQLFilter.java new file mode 100644 index 0000000..57178fc --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/xss/SQLFilter.java @@ -0,0 +1,42 @@ +package com.iailab.module.data.common.xss; + +import com.iailab.module.data.common.exception.RRException; +import org.apache.commons.lang3.StringUtils; + +/** + * SQL过滤 + * + * @author Mark sunlightcs@gmail.com + */ +public class SQLFilter { + + /** + * SQL注入过滤 + * @param str 待验证的字符串 + */ + public static String sqlInject(String str){ + if(StringUtils.isBlank(str)){ + return null; + } + //去掉'|"|;|\字符 + str = StringUtils.replace(str, "'", ""); + str = StringUtils.replace(str, "\"", ""); + str = StringUtils.replace(str, ";", ""); + str = StringUtils.replace(str, "\\", ""); + + //转换成小写 + str = str.toLowerCase(); + + //非法字符 + String[] keywords = {"master", "truncate", "insert", "select", "delete", "update", "declare", "alter", "drop"}; + + //判断是否包含非法字符 + for(String keyword : keywords){ + if(str.indexOf(keyword) != -1){ + throw new RRException("包含非法字符"); + } + } + + return str; + } +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/xss/XssFilter.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/xss/XssFilter.java new file mode 100644 index 0000000..1b3c6b7 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/xss/XssFilter.java @@ -0,0 +1,29 @@ +package com.iailab.module.data.common.xss; + +import javax.servlet.*; +import javax.servlet.http.HttpServletRequest; +import java.io.IOException; + +/** + * XSS过滤 + * + * @author Mark sunlightcs@gmail.com + */ +public class XssFilter implements Filter { + + @Override + public void init(FilterConfig config) throws ServletException { + } + + public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) + throws IOException, ServletException { + XssHttpServletRequestWrapper xssRequest = new XssHttpServletRequestWrapper( + (HttpServletRequest) request); + chain.doFilter(xssRequest, response); + } + + @Override + public void destroy() { + } + +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/xss/XssHttpServletRequestWrapper.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/xss/XssHttpServletRequestWrapper.java new file mode 100644 index 0000000..1f48ebb --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/xss/XssHttpServletRequestWrapper.java @@ -0,0 +1,139 @@ +package com.iailab.module.data.common.xss; + +import org.apache.commons.io.IOUtils; +import org.apache.commons.lang3.StringUtils; +import org.springframework.http.HttpHeaders; +import org.springframework.http.MediaType; + +import javax.servlet.ReadListener; +import javax.servlet.ServletInputStream; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletRequestWrapper; +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.util.LinkedHashMap; +import java.util.Map; + +/** + * XSS过滤处理 + * + * @author Mark sunlightcs@gmail.com + */ +public class XssHttpServletRequestWrapper extends HttpServletRequestWrapper { + //没被包装过的HttpServletRequest(特殊场景,需要自己过滤) + HttpServletRequest orgRequest; + //html过滤 + private final static HTMLFilter htmlFilter = new HTMLFilter(); + + public XssHttpServletRequestWrapper(HttpServletRequest request) { + super(request); + orgRequest = request; + } + + @Override + public ServletInputStream getInputStream() throws IOException { + //非json类型,直接返回 + if(!MediaType.APPLICATION_JSON_VALUE.equalsIgnoreCase(super.getHeader(HttpHeaders.CONTENT_TYPE))){ + return super.getInputStream(); + } + + //为空,直接返回 + String json = IOUtils.toString(super.getInputStream(), "utf-8"); + if (StringUtils.isBlank(json)) { + return super.getInputStream(); + } + + //xss过滤 + json = xssEncode(json); + final ByteArrayInputStream bis = new ByteArrayInputStream(json.getBytes("utf-8")); + return new ServletInputStream() { + @Override + public boolean isFinished() { + return true; + } + + @Override + public boolean isReady() { + return true; + } + + @Override + public void setReadListener(ReadListener readListener) { + + } + + @Override + public int read() throws IOException { + return bis.read(); + } + }; + } + + @Override + public String getParameter(String name) { + String value = super.getParameter(xssEncode(name)); + if (StringUtils.isNotBlank(value)) { + value = xssEncode(value); + } + return value; + } + + @Override + public String[] getParameterValues(String name) { + String[] parameters = super.getParameterValues(name); + if (parameters == null || parameters.length == 0) { + return null; + } + + for (int i = 0; i < parameters.length; i++) { + parameters[i] = xssEncode(parameters[i]); + } + return parameters; + } + + @Override + public Map<String,String[]> getParameterMap() { + Map<String,String[]> map = new LinkedHashMap<>(); + Map<String,String[]> parameters = super.getParameterMap(); + for (String key : parameters.keySet()) { + String[] values = parameters.get(key); + for (int i = 0; i < values.length; i++) { + values[i] = xssEncode(values[i]); + } + map.put(key, values); + } + return map; + } + + @Override + public String getHeader(String name) { + String value = super.getHeader(xssEncode(name)); + if (StringUtils.isNotBlank(value)) { + value = xssEncode(value); + } + return value; + } + + private String xssEncode(String input) { + return htmlFilter.filter(input); + } + + /** + * 获取最原始的request + */ + public HttpServletRequest getOrgRequest() { + return orgRequest; + } + + /** + * 获取最原始的request + */ + public static HttpServletRequest getOrgRequest(HttpServletRequest request) { + if (request instanceof XssHttpServletRequestWrapper) { + return ((XssHttpServletRequestWrapper) request).getOrgRequest(); + } + + return request; + } + +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/feign/FeignDataImpl.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/feign/FeignDataImpl.java new file mode 100644 index 0000000..794d57f --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/feign/FeignDataImpl.java @@ -0,0 +1,192 @@ +package com.iailab.module.data.feign; + +import com.alibaba.cloud.commons.lang.StringUtils; +import com.iailab.module.data.api.IFeignDataApi; +import com.iailab.framework.common.util.date.DateUtils; +import com.iailab.framework.common.util.object.BeanUtils; +import com.iailab.module.data.common.enums.DataTypeEnum; +import com.iailab.module.data.dto.*; +import com.iailab.module.data.http.entity.HttpApiEntity; +import com.iailab.module.data.influxdb.pojo.InfluxPointValuePOJO; +import com.iailab.module.data.point.collection.PointCollector; +import com.iailab.module.data.point.dto.DaPointDTO; +import com.iailab.module.data.point.dto.DaPointWriteValueDTO; +import com.iailab.module.data.point.service.DaPointService; +import com.iailab.module.data.http.service.HttpApiService; +import com.iailab.module.data.ind.collection.IndItemCollector; +import com.iailab.module.data.ind.dto.IndItemValueDTO; +import com.iailab.module.data.influxdb.service.InfluxDBService; +import javax.annotation.Resource; +import org.springframework.util.CollectionUtils; +import org.springframework.web.bind.annotation.RestController; + +import java.math.BigDecimal; +import java.util.*; + +/** + * @author PanZhibao + * @Description + * @createTime 2023年06月28日 08:53:00 + */ +@RestController +public class FeignDataImpl implements IFeignDataApi { + @Resource + private InfluxDBService influxDBService; + + @Resource + DaPointService daPointService; + + @Resource + private HttpApiService httpApiService; + + @Resource + private IndItemCollector indItemCollector; + + @Resource + private PointCollector pointCollector; + + @Override + public List<ApiDataDTO> queryPointValues(FeignQueryPointDTO dto) { + DaPointDTO daPointDTO = daPointService.getByNo(dto.getPointCode()); + InfluxPointValuePOJO pojo = new InfluxPointValuePOJO(); + pojo.setPoint(dto.getPointCode()); + pojo.setType(daPointDTO.getDataType()); + Date startTime = dto.getStartTime(); + Date endTime = dto.getEndTime(); + List<Map<String, Object>> list = influxDBService.queryPointValues(pojo, startTime, endTime); + List<ApiDataDTO> dataEntityList = new ArrayList<>(); + for (int i = 0; list.size() - i >= 1; i++) { + ApiDataDTO dataEntity = new ApiDataDTO(); + dataEntity.setDataValue(Double.parseDouble(list.get(i).get("value").toString())); + dataEntity.setTimeStamp((Date)(list.get(i).get("time"))); + dataEntityList.add(dataEntity); + } + return dataEntityList; + } + + @Override + public List<ApiDataDTO> querySimTagValues(FeignQueryPointDTO dto) { + + InfluxPointValuePOJO pojo = new InfluxPointValuePOJO(); + pojo.setPoint(dto.getPointCode()); + pojo.setType(DataTypeEnum.FLOAT.getCode()); + Date startTime = dto.getStartTime(); + Date endTime = dto.getEndTime(); + List<Map<String, Object>> list = influxDBService.queryPointValues(pojo, startTime, endTime); + List<ApiDataDTO> dataEntityList = new ArrayList<>(); + for (int i = 0; list.size() - i >= 1; i++) { + ApiDataDTO dataEntity = new ApiDataDTO(); + dataEntity.setDataValue(Double.parseDouble(list.get(i).get("value").toString())); + dataEntity.setTimeStamp((Date)(list.get(i).get("time"))); + dataEntityList.add(dataEntity); + } + return dataEntityList; + } + + @Override + public Map<String, Object> getCurrentValue(List<String> pointNos) { + return pointCollector.getCurrentValue(pointNos); + } + + @Override + public ApiDataPointDTO getPoint(String pointNo) { + DaPointDTO daPointDTO = daPointService.getByNo(pointNo); + return BeanUtils.toBean(daPointDTO, ApiDataPointDTO.class); + + } + + @Override + public FeignHttpApiDTO getHttpApi(String code) { + HttpApiEntity entity = httpApiService.getByCode(code); + return BeanUtils.toBean(entity, FeignHttpApiDTO.class); + + } + + @Override + public List<ApiDataDTO> queryIndItemValues(FeignQueryPointDTO dto) { + List<ApiDataDTO> result = new ArrayList<>(); + List<String> itemNos = new ArrayList<>(); + itemNos.add(dto.getPointCode()); + Map<String, List<IndItemValueDTO>> data = indItemCollector.getValueList(itemNos); + List<IndItemValueDTO> list = data.get(dto.getPointCode()); + if (CollectionUtils.isEmpty(list)) { + return result; + } + list.forEach(item -> { + BigDecimal dv = null; + ApiDataDTO entity = new ApiDataDTO(); + entity.setDataTime(item.getDataTime()); + entity.setDataValue(item.getDataValue() == null ? 0 : item.getDataValue().doubleValue()); + result.add(entity); + }); + return result; + } + + @Override + public List<ApiIndValueDTO> getIndItemValues(FeignQueryPointDTO dto) { + List<ApiIndValueDTO> result = new ArrayList<>(); + List<String> itemNos = new ArrayList<>(); + itemNos.add(dto.getPointCode()); + Map<String, List<IndItemValueDTO>> data = indItemCollector.getValueList(itemNos); + List<IndItemValueDTO> list = data.get(dto.getPointCode()); + if (CollectionUtils.isEmpty(list)) { + return result; + } + list.forEach(item -> { + BigDecimal dv = null; + ApiIndValueDTO entity = new ApiIndValueDTO(); + entity.setDataTime(item.getDataTime()); + entity.setDataValue(item.getDataValue()); + result.add(entity); + }); + return result; + } + + @Override + public List<ApiIndValueDTO> queryIndItemValuesRange(FeignQueryPointDTO dto) { + List<ApiIndValueDTO> result = new ArrayList<>(); + List<String> itemNos = new ArrayList<>(); + itemNos.add(dto.getPointCode()); + Map<String, List<IndItemValueDTO>> data = new HashMap<>(); + if (StringUtils.isBlank(dto.getStartDate()) && StringUtils.isBlank(dto.getEndDate())) { + data = indItemCollector.getValueList(itemNos); + } else { + if (dto.getStartDate() == null) { + dto.setStartDate(DateUtils.format(new Date())); + } + if (dto.getEndDate() == null) { + dto.setEndDate(DateUtils.format(new Date())); + } + data = indItemCollector.getValueListRange(itemNos, dto.getStartDate(), dto.getEndDate()); + } + List<IndItemValueDTO> list = data.get(dto.getPointCode()); + if (CollectionUtils.isEmpty(list)) { + return result; + } + list.forEach(item -> { + BigDecimal dv = null; + ApiIndValueDTO entity = new ApiIndValueDTO(); + entity.setDataTime(item.getDataTime()); + entity.setDataValue(item.getDataValue()); + result.add(entity); + }); + return result; + } + + @Override + public FeignResultDTO setPointValue(FeignWritePointValueDTO writePointValue) { + FeignResultDTO result = new FeignResultDTO(); + try { + DaPointWriteValueDTO wr = new DaPointWriteValueDTO(); + wr.setPointNo(writePointValue.getPointCode()); + wr.setPointValue(writePointValue.getPointValue()); + pointCollector.setValue(wr); + result.setCode(0); + result.setMsg(""); + } catch (Exception ex) { + result.setCode(-1); + result.setMsg(ex.getMessage()); + } + return result; + } +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/framework/filter/MyFilter.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/framework/filter/MyFilter.java new file mode 100644 index 0000000..1fb6d26 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/framework/filter/MyFilter.java @@ -0,0 +1,31 @@ +//package com.iailab.module.data.framework.filter; +// +//import org.apache.logging.log4j.LogManager; +//import org.apache.logging.log4j.Logger; +//import org.springframework.stereotype.Component; +// +//import javax.servlet.*; +//import javax.servlet.http.HttpServletRequest; +//import java.io.IOException; +// +//public class MyFilter implements Filter { +// +// private static final Logger LOGGER = LogManager.getLogger(LogManager.ROOT_LOGGER_NAME); +// +// @Override +// public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { +// LOGGER.info("过滤器filter3开始 doFilter"); +// ServletRequest requestWrapper = null; +// if(request instanceof HttpServletRequest) { +// requestWrapper = new MyHttpServletRequestWrapper((HttpServletRequest) request); +// } +// //获取请求中的流如何,将取出来的字符串,再次转换成流,然后把它放入到新request对象中。 +// // 在chain.doFiler方法中传递新的request对象 +// if(requestWrapper == null) { +// +// chain.doFilter(request, response); +// } else { +// chain.doFilter(requestWrapper, response); +// } +// } +//} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/framework/filter/MyHttpServletRequestWrapper.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/framework/filter/MyHttpServletRequestWrapper.java new file mode 100644 index 0000000..ee33943 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/framework/filter/MyHttpServletRequestWrapper.java @@ -0,0 +1,74 @@ +package com.iailab.module.data.framework.filter; + +import groovy.util.logging.Slf4j; +import lombok.Getter; + +import javax.servlet.ReadListener; +import javax.servlet.ServletInputStream; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletRequestWrapper; +import java.io.BufferedReader; +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.io.InputStreamReader; + +@Slf4j +@Getter +public class MyHttpServletRequestWrapper extends HttpServletRequestWrapper { + /** 复制请求body */ + private final String body; + + public MyHttpServletRequestWrapper (HttpServletRequest request) { + super(request); + try { + //设置编码格式, 防止中文乱码 + request.setCharacterEncoding("UTF-8"); + //将请求中的流取出来放到body里,后面都只操作body就行 + this.body = RequestReadUtils.read(request); + } catch (Exception e) { + throw new RuntimeException("MyHttpServletRequestWrapper 拦截器异常"); + } + } + + @Override + public ServletInputStream getInputStream() { + //返回body的流信息即可 + try(final ByteArrayInputStream bais = new ByteArrayInputStream(body.getBytes())){ + return getServletInputStream(bais); + }catch(IOException e){ + throw new RuntimeException("MyHttpServletRequestWrapper 获取input流异常"); + } + } + + @Override + public BufferedReader getReader(){ + return new BufferedReader(new InputStreamReader(this.getInputStream())); + } + + /** + * 重写getInputStream流 + * @param bais + * @return + */ + private static ServletInputStream getServletInputStream(ByteArrayInputStream bais) { + return new ServletInputStream() { + @Override + public boolean isFinished() { + return false; + } + + @Override + public boolean isReady() { + return false; + } + + @Override + public void setReadListener(ReadListener readListener) { + } + @Override + public int read() { + return bais.read(); + } + }; + } +} \ No newline at end of file diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/framework/filter/RequestReadUtils.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/framework/filter/RequestReadUtils.java new file mode 100644 index 0000000..da35579 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/framework/filter/RequestReadUtils.java @@ -0,0 +1,27 @@ +package com.iailab.module.data.framework.filter; + +import groovy.util.logging.Slf4j; + +import javax.servlet.http.HttpServletRequest; +import java.io.BufferedReader; + +@Slf4j +public class RequestReadUtils { + /** + * 读取请求流 + * @param request + * @return + */ + public static String read(HttpServletRequest request){ + try(BufferedReader reader = request.getReader()){ + StringBuilder sb = new StringBuilder(); + String line; + while ((line = reader.readLine()) != null) { + sb.append(line); + } + return sb.toString(); + }catch (Exception e){ + throw new RuntimeException("MyHttpServletRequestWrapper.RequestReadUtils.read 获取请求流异常"); + } + } +} \ No newline at end of file diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/framework/filter/RewriteRequestFilter.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/framework/filter/RewriteRequestFilter.java new file mode 100644 index 0000000..c132da9 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/framework/filter/RewriteRequestFilter.java @@ -0,0 +1,30 @@ +package com.iailab.module.data.framework.filter; + +import org.apache.commons.lang3.StringUtils; +import org.springframework.core.annotation.Order; +import org.springframework.stereotype.Component; + +import javax.servlet.*; +import javax.servlet.annotation.WebFilter; +import javax.servlet.http.HttpServletRequest; +import java.io.IOException; +import java.util.Objects; +import java.util.Optional; + +@Component +@WebFilter(filterName = "RewriteRequestFilter", urlPatterns = "/*") +@Order(1) +public class RewriteRequestFilter implements Filter { + + @Override + public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { + //文件上传类型 不需要处理,否则会报java.nio.charset.MalformedInputException: Input length = 1异常 + if (Objects.isNull(request) || Optional.ofNullable(request.getContentType()).orElse(StringUtils.EMPTY).startsWith("multipart/")) { + chain.doFilter(request, response); + return; + } + //自定义wrapper 处理流,必须在过滤器中处理,然后通过FilterChain传下去, 否则重写后的getInputStream()方法不会被调用 + MyHttpServletRequestWrapper requestWrapper = new MyHttpServletRequestWrapper((HttpServletRequest)request); + chain.doFilter(requestWrapper,response); + } +} \ No newline at end of file diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/framework/interceptor/CommonData.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/framework/interceptor/CommonData.java new file mode 100644 index 0000000..eb2d934 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/framework/interceptor/CommonData.java @@ -0,0 +1,47 @@ +package com.iailab.module.data.framework.interceptor; + +import lombok.Getter; +import lombok.Setter; +import lombok.extern.slf4j.Slf4j; + +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +@Slf4j +@Getter +@Setter +public class CommonData { + private static ThreadLocal<Map<String, Object>> threadLocal = new ThreadLocal<>(); + + /** + * 添加数据 + * @param key + * @param value + */ + public static void set(String key, Object value) { + if (threadLocal.get() == null) { + Map<String, Object> map = new HashMap<>(); + threadLocal.set(map); + } + threadLocal.get().put(key, value); + } + + + /** + * 清除数据 + */ + public static void clearAll() { + threadLocal.set(null); + } + + + public static Map<String, Object> getSignParam() { + Object o = threadLocal.get().get("param"); + if (Objects.isNull(o)) { + log.info("CommonData.getSignParam is null"); + return null; + } + return (Map<String, Object>) o; + } +} \ No newline at end of file diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/framework/interceptor/WebMvcConfig.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/framework/interceptor/WebMvcConfig.java new file mode 100644 index 0000000..c423599 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/framework/interceptor/WebMvcConfig.java @@ -0,0 +1,22 @@ +//package com.iailab.module.data.framework.interceptor; +// +//import com.iailab.module.data.framework.filter.MyFilter; +//import org.springframework.boot.web.servlet.FilterRegistrationBean; +//import org.springframework.context.annotation.Bean; +//import org.springframework.context.annotation.Configuration; +//import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; +// +//@Configuration +//public class WebMvcConfig implements WebMvcConfigurer { +// +// @Bean +// public FilterRegistrationBean httpServletRequestReplacedFilter() { +// FilterRegistrationBean filterRegistrationBean = new FilterRegistrationBean(); +// filterRegistrationBean.setFilter(new MyFilter()); +// filterRegistrationBean.addUrlPatterns("/*"); +// filterRegistrationBean.setName("myFilter"); +// filterRegistrationBean.setOrder(1); +// return filterRegistrationBean; +// } +// +//} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/framework/package-info.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/framework/package-info.java new file mode 100644 index 0000000..843bf56 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/framework/package-info.java @@ -0,0 +1,6 @@ +/** + * 属于 infra 模块的 framework 封装 + * + * @author iailab + */ +package com.iailab.module.data.framework; diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/framework/rpc/config/RpcConfiguration.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/framework/rpc/config/RpcConfiguration.java new file mode 100644 index 0000000..8bee8c9 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/framework/rpc/config/RpcConfiguration.java @@ -0,0 +1,14 @@ +package com.iailab.module.data.framework.rpc.config; + +import com.iailab.api.IFeignModelApi; +import com.iailab.api.IFeignProddispApi; +import com.iailab.module.infra.api.config.ConfigApi; +import com.iailab.module.system.api.permission.RoleApi; +import com.iailab.module.system.api.user.AdminUserApi; +import org.springframework.cloud.openfeign.EnableFeignClients; +import org.springframework.context.annotation.Configuration; + +@Configuration(proxyBeanMethods = false) +@EnableFeignClients(clients = {IFeignModelApi.class, AdminUserApi.class, RoleApi.class, IFeignProddispApi.class, ConfigApi.class}) +public class RpcConfiguration { +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/framework/rpc/package-info.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/framework/rpc/package-info.java new file mode 100644 index 0000000..804e4d1 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/framework/rpc/package-info.java @@ -0,0 +1,4 @@ +/** + * 占位 + */ +package com.iailab.module.data.framework.rpc; diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/framework/security/config/SecurityConfiguration.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/framework/security/config/SecurityConfiguration.java new file mode 100644 index 0000000..a9883af --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/framework/security/config/SecurityConfiguration.java @@ -0,0 +1,48 @@ +package com.iailab.module.data.framework.security.config; + +import com.iailab.framework.security.config.AuthorizeRequestsCustomizer; +import com.iailab.module.data.enums.ApiConstants; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.security.config.annotation.web.builders.HttpSecurity; +import org.springframework.security.config.annotation.web.configurers.ExpressionUrlAuthorizationConfigurer; + +/** + * data 模块的 Security 配置 + */ +@Configuration(proxyBeanMethods = false, value = "dataSecurityConfiguration") +public class SecurityConfiguration { + + @Value("${spring.boot.admin.context-path:''}") + private String adminSeverContextPath; + + @Bean("infraAuthorizeRequestsCustomizer") + public AuthorizeRequestsCustomizer authorizeRequestsCustomizer() { + return new AuthorizeRequestsCustomizer() { + + @Override + public void customize(ExpressionUrlAuthorizationConfigurer<HttpSecurity>.ExpressionInterceptUrlRegistry registry) { + // Swagger 接口文档 + registry.antMatchers("/v3/api-docs/**").permitAll() // 元数据 + .antMatchers("/swagger-ui.html").permitAll(); // Swagger UI + // Spring Boot Actuator 的安全配置 + registry.antMatchers("/actuator").anonymous() + .antMatchers("/actuator/**").anonymous(); + // Druid 监控 + registry.antMatchers("/druid/**").anonymous(); + // Spring Boot Admin Server 的安全配置 + registry.antMatchers(adminSeverContextPath).anonymous() + .antMatchers(adminSeverContextPath + "/**").anonymous(); + // 文件读取 + registry.antMatchers(buildAdminApi("/data/point/**")).permitAll(); + + // TODO iailab:这个每个项目都需要重复配置,得捉摸有没通用的方案 + // RPC 服务的安全配置 + registry.antMatchers(ApiConstants.PREFIX + "/**").permitAll(); + } + + }; + } + +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/framework/security/core/package-info.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/framework/security/core/package-info.java new file mode 100644 index 0000000..a90b23c --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/framework/security/core/package-info.java @@ -0,0 +1,4 @@ +/** + * 占位 + */ +package com.iailab.module.data.framework.security.core; diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/gateway/controller/ApiAppController.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/gateway/controller/ApiAppController.java new file mode 100644 index 0000000..37870dc --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/gateway/controller/ApiAppController.java @@ -0,0 +1,118 @@ +package com.iailab.module.data.gateway.controller; + +import com.iailab.module.data.common.utils.PageUtils; +import com.iailab.module.data.common.utils.R; +import com.iailab.module.data.gateway.service.ApiAuthorizedService; +import com.iailab.module.data.gateway.entity.ApiAppEntity; +import com.iailab.module.data.gateway.service.ApiAppService; +import org.apache.commons.lang3.RandomStringUtils; +import javax.annotation.Resource; +import org.springframework.web.bind.annotation.*; + +import java.util.Date; +import java.util.HashMap; +import java.util.Map; + +/** + * @author PanZhibao + * @Description + * @createTime 2022年07月15日 14:13:00 + */ +@RestController +@RequestMapping("/api-gateway/app") +public class ApiAppController { + @Resource + private ApiAppService apiAppService; + + @Resource + private ApiAuthorizedService apiAuthorizedService; + + /** + * 合作方APP列表 + * + * @param params + * @return + */ + @GetMapping("/list") + public R list(@RequestParam Map<String, Object> params) { + PageUtils page = apiAppService.queryPage(params); + return R.ok().put("page", page); + } + + /** + * 新增合作方APP + * + * @param apiAppEntity + * @return + */ + @PostMapping("/add") + public R add(@RequestBody ApiAppEntity apiAppEntity) { + int count = apiAppService.cheack(apiAppEntity); + if (count > 0) { + return R.error("名称或数据值重复"); + } + apiAppEntity.setCreateTime(new Date()); + apiAppService.add(apiAppEntity); + return R.ok(); + } + + /** + * 更新合作方APP + * + * @param apiAppEntity + * @return + */ + @PostMapping("/update") + public R update(@RequestBody ApiAppEntity apiAppEntity) { + int count = apiAppService.cheack(apiAppEntity); + if (count > 0) { + return R.error("名称或数据值重复"); + } + apiAppEntity.setCreateTime(new Date()); + apiAppService.update(apiAppEntity); + return R.ok(); + } + + /** + * 重置Secret + * + * @param apiAppEntity + * @return + */ + @PostMapping("/restAppSecret") + public R restAppSecret(@RequestBody ApiAppEntity apiAppEntity) { + ApiAppEntity apiAppEntityUpdate = new ApiAppEntity(); + apiAppEntityUpdate.setId(apiAppEntity.getId()); + apiAppEntityUpdate.setAppSecret(RandomStringUtils.randomAlphanumeric(8)); + apiAppService.update(apiAppEntity); + return R.ok(); + } + + /** + * 删除合作方APP + * + * @param params + * @return + */ + @PostMapping("/delete") + public R delete(@RequestBody Map<String, Object> params) { + String id = (String)params.get("id"); + apiAppService.deleteById(id); + return R.ok(); + } + + /** + * 合作方APP详情 + * + * @param id + * @return + */ + @RequestMapping("/info/{id}") + public R info(@PathVariable("id") String id){ + ApiAppEntity apiAppEntity = apiAppService.getInfoById(id); + Map<String, Object> queryParams = new HashMap<>(); + queryParams.put("appId", id); + apiAppEntity.setApiAuthorizedList(apiAuthorizedService.queryList(queryParams)); + return R.ok().put("data", apiAppEntity); + } +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/gateway/controller/ApiAuthorizedController.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/gateway/controller/ApiAuthorizedController.java new file mode 100644 index 0000000..1191591 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/gateway/controller/ApiAuthorizedController.java @@ -0,0 +1,86 @@ +package com.iailab.module.data.gateway.controller; + +import com.iailab.module.data.common.utils.PageUtils; +import com.iailab.module.data.common.utils.R; +import com.iailab.module.data.gateway.service.ApiAuthorizedService; +import com.iailab.module.data.gateway.entity.ApiAuthorizedEntity; +import javax.annotation.Resource; +import org.springframework.web.bind.annotation.*; + +import java.util.List; +import java.util.Map; + +/** + * @author PanZhibao + * @Description + * @createTime 2022年07月15日 14:16:00 + */ +@RestController +@RequestMapping("/api-gateway/authorized") +public class ApiAuthorizedController { + @Resource + private ApiAuthorizedService apiAuthorizedService; + + /** + * 已授权API列表 + * + * @param params + * @return + */ + @GetMapping("/list") + public R list(@RequestParam Map<String, Object> params) { + PageUtils page = apiAuthorizedService.queryPage(params); + return R.ok().put("page", page); + } + + /** + * 已授权API更新 + * + * @param apiAuthorizedEntity + * @return + */ + @PostMapping("/update") + public R update(@RequestBody ApiAuthorizedEntity apiAuthorizedEntity) { + apiAuthorizedService.update(apiAuthorizedEntity); + return R.ok(); + } + + /** + * API授权 + * + * @param appId + * @param apiIdList + * @return + */ + @PostMapping("/grant-api/{appId}") + public R grantApi(@PathVariable("appId") String appId, @RequestBody List<String> apiIdList) { + apiAuthorizedService.grantApi(appId, apiIdList); + return R.ok(); + } + + /** + * 删除已授权API + * + * @param params + * @return + */ + @PostMapping("/delete") + public R delete(@RequestBody Map<String, Object> params) { + String id = (String)params.get("id"); + apiAuthorizedService.deleteById(id); + return R.ok(); + } + + /** + * 已授权API详情 + * + * @param id + * @return + */ + @RequestMapping("/info/{id}") + public R info(@PathVariable("id") String id){ + ApiAuthorizedEntity sysDictItemEntity = apiAuthorizedService.getInfoById(id); + + return R.ok().put("dictItem", sysDictItemEntity); + } +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/gateway/controller/ApiGroupController.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/gateway/controller/ApiGroupController.java new file mode 100644 index 0000000..4b2b7dc --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/gateway/controller/ApiGroupController.java @@ -0,0 +1,94 @@ +package com.iailab.module.data.gateway.controller; + +import com.iailab.module.data.common.utils.PageUtils; +import com.iailab.module.data.common.utils.R; +import com.iailab.module.data.gateway.entity.ApiGroupEntity; +import com.iailab.module.data.gateway.service.ApiGroupService; +import javax.annotation.Resource; +import org.springframework.web.bind.annotation.*; + +import java.util.Date; +import java.util.Map; + +/** + * @author PanZhibao + * @Description + * @createTime 2022年07月15日 14:16:00 + */ +@RestController +@RequestMapping("/api-gateway/group") +public class ApiGroupController { + @Resource + private ApiGroupService apiGroupService; + + /** + * API分组列表 + * + * @param params + * @return + */ + @GetMapping("/list") + public R list(@RequestParam Map<String, Object> params) { + PageUtils page = apiGroupService.queryPage(params); + return R.ok().put("page", page); + } + + /** + * 新增API分组 + * + * @param apiAppEntity + * @return + */ + @PostMapping("/add") + public R add(@RequestBody ApiGroupEntity apiAppEntity) { + int count = apiGroupService.cheack(apiAppEntity); + if (count > 0) { + return R.error("名称或数据值重复"); + } + apiAppEntity.setCreateTime(new Date()); + apiGroupService.add(apiAppEntity); + return R.ok(); + } + + /** + * 更新API分组 + * + * @param apiAppEntity + * @return + */ + @PostMapping("/update") + public R update(@RequestBody ApiGroupEntity apiAppEntity) { + int count = apiGroupService.cheack(apiAppEntity); + if (count > 0) { + return R.error("名称或数据值重复"); + } + apiGroupService.update(apiAppEntity); + return R.ok(); + } + + /** + * 删除API分组 + * + * @param params + * @return + */ + @PostMapping("/delete") + public R delete(@RequestBody Map<String, Object> params) { + String id = (String)params.get("id"); + apiGroupService.deleteById(id); + return R.ok(); + } + + /** + * API分组详情 + * + * @param id + * @return + */ + @RequestMapping("/info/{id}") + public R info(@PathVariable("id") String id){ + ApiGroupEntity sysDictItemEntity = apiGroupService.getInfoById(id); + + return R.ok().put("data", sysDictItemEntity); + } +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/gateway/controller/ApiInfoController.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/gateway/controller/ApiInfoController.java new file mode 100644 index 0000000..3586ab3 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/gateway/controller/ApiInfoController.java @@ -0,0 +1,98 @@ +package com.iailab.module.data.gateway.controller; + +import com.iailab.module.data.common.utils.PageUtils; +import com.iailab.module.data.common.utils.R; +import com.iailab.module.data.gateway.service.ApiInfoService; +import com.iailab.module.data.gateway.entity.ApiInfoEntity; +import com.iailab.module.data.gateway.service.ApiGroupService; +import javax.annotation.Resource; +import org.springframework.web.bind.annotation.*; + +import java.util.Date; +import java.util.Map; + +/** + * @author PanZhibao + * @Description + * @createTime 2022年07月15日 14:17:00 + */ +@RestController +@RequestMapping("/api-gateway/info") +public class ApiInfoController { + @Resource + private ApiInfoService apiInfoService; + + @Resource + private ApiGroupService apiGroupService; + + /** + * API信息列表 + * + * @param params + * @return + */ + @GetMapping("/list") + public R list(@RequestParam Map<String, Object> params) { + PageUtils page = apiInfoService.queryPage(params); + return R.ok().put("page", page); + } + + /** + * 新增API信息 + * + * @param apiAppEntity + * @return + */ + @PostMapping("/add") + public R add(@RequestBody ApiInfoEntity apiAppEntity) { + int count = apiInfoService.cheack(apiAppEntity); + if (count > 0) { + return R.error("名称或数据值重复"); + } + apiAppEntity.setCreateTime(new Date()); + apiInfoService.add(apiAppEntity); + return R.ok(); + } + + /** + * 更新API信息 + * + * @param apiAppEntity + * @return + */ + @PostMapping("/update") + public R update(@RequestBody ApiInfoEntity apiAppEntity) { + int count = apiInfoService.cheack(apiAppEntity); + if (count > 0) { + return R.error("名称或数据值重复"); + } + apiInfoService.update(apiAppEntity); + return R.ok(); + } + + /** + * 删除API信息 + * + * @param params + * @return + */ + @PostMapping("/delete") + public R delete(@RequestBody Map<String, Object> params) { + String id = (String)params.get("id"); + apiInfoService.deleteById(id); + return R.ok(); + } + + /** + * API信息详情 + * + * @param id + * @return + */ + @RequestMapping("/info/{id}") + public R info(@PathVariable("id") String id){ + ApiInfoEntity sysDictItemEntity = apiInfoService.getInfoById(id); + + return R.ok().put("data", sysDictItemEntity); + } +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/gateway/controller/ApiServerController.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/gateway/controller/ApiServerController.java new file mode 100644 index 0000000..6f8db83 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/gateway/controller/ApiServerController.java @@ -0,0 +1,94 @@ +package com.iailab.module.data.gateway.controller; + +import com.iailab.module.data.common.utils.PageUtils; +import com.iailab.module.data.common.utils.R; +import com.iailab.module.data.gateway.service.ApiServerService; +import com.iailab.module.data.gateway.entity.ApiServerEntity; +import javax.annotation.Resource; +import org.springframework.web.bind.annotation.*; + +import java.util.Date; +import java.util.Map; + +/** + * @author PanZhibao + * @Description + * @createTime 2022年07月15日 14:17:00 + */ +@RestController +@RequestMapping("/api-gateway/server") +public class ApiServerController { + @Resource + private ApiServerService apiServerService; + + /** + * API提供方列表 + * + * @param params + * @return + */ + @GetMapping("/list") + public R list(@RequestParam Map<String, Object> params) { + PageUtils page = apiServerService.queryPage(params); + return R.ok().put("page", page); + } + + /** + * 新增API提供方 + * + * @param apiAppEntity + * @return + */ + @PostMapping("/add") + public R add(@RequestBody ApiServerEntity apiAppEntity) { + int count = apiServerService.cheack(apiAppEntity); + if (count > 0) { + return R.error("名称或数据值重复"); + } + apiAppEntity.setCreateTime(new Date()); + apiServerService.add(apiAppEntity); + return R.ok(); + } + + /** + * 更新API提供方 + * + * @param apiAppEntity + * @return + */ + @PostMapping("/update") + public R update(@RequestBody ApiServerEntity apiAppEntity) { + int count = apiServerService.cheack(apiAppEntity); + if (count > 0) { + return R.error("名称或数据值重复"); + } + apiServerService.update(apiAppEntity); + return R.ok(); + } + + /** + * 删除API提供方 + * + * @param params + * @return + */ + @PostMapping("/delete") + public R delete(@RequestBody Map<String, Object> params) { + String id = (String)params.get("id"); + apiServerService.deleteById(id); + return R.ok(); + } + + /** + * API提供方详情 + * + * @param id + * @return + */ + @RequestMapping("/info/{id}") + public R info(@PathVariable("id") String id){ + ApiServerEntity sysDictItemEntity = apiServerService.getInfoById(id); + + return R.ok().put("data", sysDictItemEntity); + } +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/gateway/dao/ApiAppDao.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/gateway/dao/ApiAppDao.java new file mode 100644 index 0000000..c5a3a40 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/gateway/dao/ApiAppDao.java @@ -0,0 +1,17 @@ +package com.iailab.module.data.gateway.dao; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.iailab.module.data.gateway.entity.ApiAppEntity; +import com.iailab.module.data.gateway.entity.ApiAppEntity; +import com.iailab.module.data.gateway.entity.ApiAppEntity; +import com.iailab.module.data.gateway.entity.ApiAppEntity; +import org.apache.ibatis.annotations.Mapper; + +/** + * @author PanZhibao + * @Description + * @createTime 2022年07月15日 13:53:00 + */ +@Mapper +public interface ApiAppDao extends BaseMapper<ApiAppEntity> { +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/gateway/dao/ApiAuthorizedDao.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/gateway/dao/ApiAuthorizedDao.java new file mode 100644 index 0000000..e04e973 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/gateway/dao/ApiAuthorizedDao.java @@ -0,0 +1,27 @@ +package com.iailab.module.data.gateway.dao; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.iailab.module.data.gateway.entity.ApiAuthorizedEntity; +import com.iailab.module.data.gateway.entity.ApiAuthorizedEntity; +import com.iailab.module.data.gateway.entity.ApiAuthorizedEntity; +import com.iailab.module.data.gateway.vo.SysGatewayApi; +import com.iailab.module.data.gateway.entity.ApiAuthorizedEntity; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; +import java.util.Map; + +/** + * @author PanZhibao + * @Description + * @createTime 2022年07月15日 13:55:00 + */ +@Mapper +public interface ApiAuthorizedDao extends BaseMapper<ApiAuthorizedEntity> { + + IPage<ApiAuthorizedEntity> queryList(IPage<ApiAuthorizedEntity> page, @Param("params") Map<String, Object> params); + + List<SysGatewayApi> queryListGatewayApi(Map<String, Object> params); +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/gateway/dao/ApiGroupDao.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/gateway/dao/ApiGroupDao.java new file mode 100644 index 0000000..b00edce --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/gateway/dao/ApiGroupDao.java @@ -0,0 +1,14 @@ +package com.iailab.module.data.gateway.dao; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.iailab.module.data.gateway.entity.ApiGroupEntity; +import org.apache.ibatis.annotations.Mapper; + +/** + * @author PanZhibao + * @Description + * @createTime 2022年07月15日 13:56:00 + */ +@Mapper +public interface ApiGroupDao extends BaseMapper<ApiGroupEntity> { +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/gateway/dao/ApiInfoDao.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/gateway/dao/ApiInfoDao.java new file mode 100644 index 0000000..3eb34f9 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/gateway/dao/ApiInfoDao.java @@ -0,0 +1,23 @@ +package com.iailab.module.data.gateway.dao; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.iailab.module.data.gateway.entity.ApiInfoEntity; +import com.iailab.module.data.gateway.entity.ApiInfoEntity; +import com.iailab.module.data.gateway.entity.ApiInfoEntity; +import com.iailab.module.data.gateway.entity.ApiInfoEntity; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.Map; + +/** + * @author PanZhibao + * @Description + * @createTime 2022年07月15日 13:57:00 + */ +@Mapper +public interface ApiInfoDao extends BaseMapper<ApiInfoEntity> { + + IPage<ApiInfoEntity> queryList(IPage<ApiInfoEntity> page, @Param("params") Map<String, Object> params); +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/gateway/dao/ApiServerDao.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/gateway/dao/ApiServerDao.java new file mode 100644 index 0000000..3c48d22 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/gateway/dao/ApiServerDao.java @@ -0,0 +1,17 @@ +package com.iailab.module.data.gateway.dao; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.iailab.module.data.gateway.entity.ApiServerEntity; +import com.iailab.module.data.gateway.entity.ApiServerEntity; +import com.iailab.module.data.gateway.entity.ApiServerEntity; +import com.iailab.module.data.gateway.entity.ApiServerEntity; +import org.apache.ibatis.annotations.Mapper; + +/** + * @author PanZhibao + * @Description + * @createTime 2022年07月15日 13:58:00 + */ +@Mapper +public interface ApiServerDao extends BaseMapper<ApiServerEntity> { +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/gateway/entity/ApiAppEntity.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/gateway/entity/ApiAppEntity.java new file mode 100644 index 0000000..5a3295b --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/gateway/entity/ApiAppEntity.java @@ -0,0 +1,38 @@ +package com.iailab.module.data.gateway.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import com.iailab.framework.excel.core.annotations.DictFormat; +import lombok.Data; + +import java.util.List; + +@Data +@TableName("t_api_app") +public class ApiAppEntity { + + @TableId(type = IdType.ASSIGN_ID) + private String id; + + private String appName; + + private String appKey; + + private String appSecret; + + private String appDesc; + + private Integer status; + + @DictFormat("enable") + @TableField(exist = false) + private String statusName; + + private java.util.Date createTime; + + @TableField(exist = false) + private List<ApiAuthorizedEntity> apiAuthorizedList; + +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/gateway/entity/ApiAuthorizedEntity.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/gateway/entity/ApiAuthorizedEntity.java new file mode 100644 index 0000000..a2a42a8 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/gateway/entity/ApiAuthorizedEntity.java @@ -0,0 +1,39 @@ +package com.iailab.module.data.gateway.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; + +@Data +@TableName("t_api_authorized") +public class ApiAuthorizedEntity { + + @TableId(type = IdType.ASSIGN_ID) + private String id; + + private String appId; + + private String appKey; + + private String apiId; + + @TableField(exist = false) + private String serverName; + + @TableField(exist = false) + private String apiName; + + @TableField(exist = false) + private String apiAddress; + + private Integer limitMin; + + private Integer limitHour; + + private Integer limitDay; + + private java.util.Date createTime; + +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/gateway/entity/ApiGroupEntity.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/gateway/entity/ApiGroupEntity.java new file mode 100644 index 0000000..fd3674d --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/gateway/entity/ApiGroupEntity.java @@ -0,0 +1,23 @@ +package com.iailab.module.data.gateway.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import lombok.Data; +import com.baomidou.mybatisplus.annotation.TableName; + +@Data +@TableName("t_api_group") +public class ApiGroupEntity { + + @TableId(type = IdType.ASSIGN_ID) + private String id; + + private String groupName; + + private String groupDesc; + + private Integer status; + + private java.util.Date createTime; + +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/gateway/entity/ApiInfoEntity.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/gateway/entity/ApiInfoEntity.java new file mode 100644 index 0000000..d30d9dc --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/gateway/entity/ApiInfoEntity.java @@ -0,0 +1,36 @@ +package com.iailab.module.data.gateway.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; + +@Data +@TableName("t_api_info") +public class ApiInfoEntity { + + @TableId(type = IdType.ASSIGN_ID) + private String id; + + private String apiName; + + private String apiGroupId; + + @TableField(exist = false) + private String groupName; + + private String apiServerId; + + @TableField(exist = false) + private String serverName; + + private String apiDesc; + + private String apiAddress; + + private Integer status; + + private java.util.Date createTime; + +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/gateway/entity/ApiServerEntity.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/gateway/entity/ApiServerEntity.java new file mode 100644 index 0000000..ef65387 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/gateway/entity/ApiServerEntity.java @@ -0,0 +1,32 @@ +package com.iailab.module.data.gateway.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import com.iailab.framework.excel.core.annotations.DictFormat; +import lombok.Data; + +@Data +@TableName("t_api_server") +public class ApiServerEntity { + @TableId(type = IdType.ASSIGN_ID) + private String id; + + private String serverName; + + private String serverDesc; + + private String serverAddress; + + private Integer limitMin; + + private Integer status; + + @DictFormat("enable") + @TableField(exist = false) + private String statusName; + + private java.util.Date createTime; + +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/gateway/form/AppLoginForm.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/gateway/form/AppLoginForm.java new file mode 100644 index 0000000..b287f89 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/gateway/form/AppLoginForm.java @@ -0,0 +1,14 @@ +package com.iailab.module.data.gateway.form; + +import lombok.Data; + +/** + * @author PanZhibao + * @Description + * @createTime 2022年07月19日 17:18:00 + */ +@Data +public class AppLoginForm { + private String appKey; + private String appSecret; +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/gateway/service/ApiAppService.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/gateway/service/ApiAppService.java new file mode 100644 index 0000000..242983c --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/gateway/service/ApiAppService.java @@ -0,0 +1,29 @@ +package com.iailab.module.data.gateway.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.iailab.module.data.common.utils.PageUtils; +import com.iailab.module.data.gateway.entity.ApiAppEntity; + +import java.util.Map; + +/** + * @author PanZhibao + * @Description + * @createTime 2022年07月15日 14:00:00 + */ +public interface ApiAppService extends IService<ApiAppEntity> { + + PageUtils queryPage(Map<String, Object> params); + + void add(ApiAppEntity apiAppEntity); + + void update(ApiAppEntity apiAppEntity); + + void deleteById(String id); + + ApiAppEntity getInfoById(String id); + + ApiAppEntity getInfoByAppKey(String appKey); + + int cheack(ApiAppEntity apiAppEntity); +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/gateway/service/ApiAuthorizedService.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/gateway/service/ApiAuthorizedService.java new file mode 100644 index 0000000..2d1d158 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/gateway/service/ApiAuthorizedService.java @@ -0,0 +1,32 @@ +package com.iailab.module.data.gateway.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.iailab.module.data.common.utils.PageUtils; +import com.iailab.module.data.gateway.entity.ApiAuthorizedEntity; + +import java.util.List; +import java.util.Map; + +/** + * @author PanZhibao + * @Description + * @createTime 2022年07月15日 14:00:00 + */ +public interface ApiAuthorizedService extends IService<ApiAuthorizedEntity> { + + PageUtils queryPage(Map<String, Object> params); + + List<ApiAuthorizedEntity> queryList(Map<String, Object> params); + + void add(ApiAuthorizedEntity dictItemEntity); + + void update(ApiAuthorizedEntity dictItemEntity); + + void deleteById(String id); + + ApiAuthorizedEntity getInfoById(String id); + + void grantApi(String appId, List<String> apiIdList); + + void addApiRedis(); +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/gateway/service/ApiGroupService.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/gateway/service/ApiGroupService.java new file mode 100644 index 0000000..b4632c8 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/gateway/service/ApiGroupService.java @@ -0,0 +1,29 @@ +package com.iailab.module.data.gateway.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.iailab.module.data.common.utils.PageUtils; +import com.iailab.module.data.gateway.entity.ApiGroupEntity; + +import java.util.List; +import java.util.Map; + +/** + * @author PanZhibao + * @Description + * @createTime 2022年07月15日 14:00:00 + */ +public interface ApiGroupService extends IService<ApiGroupEntity> { + PageUtils queryPage(Map<String, Object> params); + + List<ApiGroupEntity> queryList(); + + void add(ApiGroupEntity apiGroupEntity); + + void update(ApiGroupEntity apiGroupEntity); + + void deleteById(String id); + + ApiGroupEntity getInfoById(String id); + + int cheack(ApiGroupEntity apiGroupEntity); +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/gateway/service/ApiInfoService.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/gateway/service/ApiInfoService.java new file mode 100644 index 0000000..4ce6cb6 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/gateway/service/ApiInfoService.java @@ -0,0 +1,30 @@ +package com.iailab.module.data.gateway.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.iailab.module.data.common.utils.PageUtils; +import com.iailab.module.data.gateway.entity.ApiInfoEntity; + +import java.util.List; +import java.util.Map; + +/** + * @author PanZhibao + * @Description + * @createTime 2022年07月15日 14:01:00 + */ +public interface ApiInfoService extends IService<ApiInfoEntity> { + + PageUtils queryPage(Map<String, Object> params); + + List<ApiInfoEntity> queryList(Map<String, Object> params); + + void add(ApiInfoEntity apiInfoEntity); + + void update(ApiInfoEntity apiInfoEntity); + + void deleteById(String id); + + ApiInfoEntity getInfoById(String id); + + int cheack(ApiInfoEntity apiInfoEntity); +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/gateway/service/ApiServerService.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/gateway/service/ApiServerService.java new file mode 100644 index 0000000..2432c39 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/gateway/service/ApiServerService.java @@ -0,0 +1,28 @@ +package com.iailab.module.data.gateway.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.iailab.module.data.common.utils.PageUtils; +import com.iailab.module.data.gateway.entity.ApiServerEntity; + +import java.util.Map; + +/** + * @author PanZhibao + * @Description + * @createTime 2022年07月15日 14:01:00 + */ +public interface ApiServerService extends IService<ApiServerEntity> { + PageUtils queryPage(Map<String, Object> params); + + void add(ApiServerEntity apiServerEntity); + + void update(ApiServerEntity apiServerEntity); + + void deleteById(String id); + + ApiServerEntity getInfoById(String id); + + int cheack(ApiServerEntity apiServerEntity); + + void addRouteRedis(); +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/gateway/service/impl/ApiAppServiceImpl.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/gateway/service/impl/ApiAppServiceImpl.java new file mode 100644 index 0000000..3f3e8ec --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/gateway/service/impl/ApiAppServiceImpl.java @@ -0,0 +1,81 @@ +package com.iailab.module.data.gateway.service.impl; + +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.iailab.framework.common.constant.Constant; +import com.iailab.module.data.common.utils.PageUtils; +import com.iailab.module.data.common.utils.Query; +import com.iailab.module.data.gateway.dao.ApiAppDao; +import com.iailab.module.data.gateway.entity.ApiAppEntity; +import com.iailab.module.data.gateway.service.ApiAppService; +import org.apache.commons.lang3.RandomStringUtils; +import org.apache.commons.lang3.StringUtils; +import org.springframework.stereotype.Service; + +import java.util.Map; +import java.util.UUID; + +/** + * @author PanZhibao + * @Description + * @createTime 2022年07月15日 14:02:00 + */ +@Service("apiAppService") +public class ApiAppServiceImpl extends ServiceImpl<ApiAppDao, ApiAppEntity> implements ApiAppService { + + @Override + public PageUtils queryPage(Map<String, Object> params) { + String appName = (String)params.get("appName"); + String appKey = (String)params.get("appKey"); + IPage<ApiAppEntity> page = this.page( + new Query<ApiAppEntity>().getPage(params), + new QueryWrapper<ApiAppEntity>() + .like(StringUtils.isNotBlank(appName),"app_name", appName) + .like(StringUtils.isNotBlank(appKey),"app_key", appKey) + .orderByDesc("create_time") + ); + return new PageUtils(page); + } + + @Override + public void add(ApiAppEntity entity) { + entity.setId(UUID.randomUUID().toString().replace("-", "")); + //apiAppEntity.setAppKey(UUID.randomUUID().toString().replace("-", "").substring(0, 16)); + entity.setAppSecret(StringUtils.isNotBlank(entity.getAppSecret()) ? entity.getAppSecret() : RandomStringUtils.randomAlphanumeric(8)); + entity.setStatus(Constant.EnableStatus.NORMAL.getValue()); + this.save(entity); + } + + @Override + public void update(ApiAppEntity apiAppEntity) { + this.updateById(apiAppEntity); + } + + @Override + public void deleteById(String id) { + this.getBaseMapper().delete(new QueryWrapper<ApiAppEntity>().eq("id", id)); + } + + @Override + public ApiAppEntity getInfoById(String id) { + return this.getById(id); + } + + @Override + public ApiAppEntity getInfoByAppKey(String appKey) { + return this.getOne(new QueryWrapper<ApiAppEntity>().eq("app_key", appKey)); + } + + @Override + public int cheack(ApiAppEntity apiAppEntity) { + String id = apiAppEntity.getId(); + String appName = apiAppEntity.getAppName(); + String appKey = apiAppEntity.getAppKey(); + QueryWrapper<ApiAppEntity> queryWrapper = new QueryWrapper<>(); + queryWrapper.ne(StringUtils.isNotBlank(id), "id", id); + queryWrapper.and(wrapper -> wrapper.eq("app_name", appName).or(). + eq(StringUtils.isNotBlank(appKey),"app_key", appKey)); + return (int)this.count(queryWrapper); + } +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/gateway/service/impl/ApiAuthorizedServiceImpl.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/gateway/service/impl/ApiAuthorizedServiceImpl.java new file mode 100644 index 0000000..b79ecfd --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/gateway/service/impl/ApiAuthorizedServiceImpl.java @@ -0,0 +1,131 @@ +package com.iailab.module.data.gateway.service.impl; + +import com.alibaba.fastjson.JSON; +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.iailab.module.data.common.utils.PageUtils; +import com.iailab.module.data.common.utils.Query; +import com.iailab.framework.common.constant.CacheConstant; +import com.iailab.module.data.gateway.dao.ApiAppDao; +import com.iailab.module.data.gateway.dao.ApiAuthorizedDao; +import com.iailab.module.data.gateway.dao.ApiInfoDao; +import com.iailab.module.data.gateway.entity.ApiAppEntity; +import com.iailab.module.data.gateway.entity.ApiAuthorizedEntity; +import com.iailab.module.data.gateway.entity.ApiInfoEntity; +import com.iailab.module.data.gateway.service.ApiAuthorizedService; +import com.iailab.module.data.gateway.vo.SysGatewayApi; +import org.apache.commons.lang3.StringUtils; +import javax.annotation.Resource; + +import org.springframework.data.redis.core.StringRedisTemplate; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.util.CollectionUtils; + +import java.util.*; +import java.util.stream.Collectors; + +/** + * @author PanZhibao + * @Description + * @createTime 2022年07月15日 14:02:00 + */ +@Service("apiAuthorizedService") +public class ApiAuthorizedServiceImpl extends ServiceImpl<ApiAuthorizedDao, ApiAuthorizedEntity> implements ApiAuthorizedService { + + @Resource + private ApiAppDao apiAppDao; + + @Resource + private ApiInfoDao apiInfoDao; + + @Resource + private StringRedisTemplate stringRedisTemplate; + + @Override + public PageUtils queryPage(Map<String, Object> params) { + String appId = (String)params.get("appId"); + Map<String, Object> queryParams = new HashMap<>(1); + queryParams.put("appId", appId); + IPage<ApiAuthorizedEntity> page = getBaseMapper().queryList( + new Query<ApiAuthorizedEntity>().getPage(params), + queryParams + ); + return new PageUtils(page); + } + + @Override + public List<ApiAuthorizedEntity> queryList(Map<String, Object> params) { + String appId = (String)params.get("appId"); + return getBaseMapper().selectList(new QueryWrapper<ApiAuthorizedEntity>() + .eq(StringUtils.isNotBlank(appId), "app_id", appId) + .orderByDesc("create_time")); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void grantApi(String appId, List<String> apiIdList) { + ApiAppEntity apiAppEntity = apiAppDao.selectById(appId); + if (apiAppEntity == null) { + return; + } + String appKey = apiAppEntity.getAppKey(); + getBaseMapper().delete(new QueryWrapper<ApiAuthorizedEntity>().eq("app_id", appId)); + if (!CollectionUtils.isEmpty(apiIdList)) { + apiIdList = apiIdList.stream().distinct().collect(Collectors.toList()); + apiIdList.forEach(item -> { + ApiInfoEntity apiInfoEntity = apiInfoDao.selectById(item); + if (apiInfoEntity != null) { + ApiAuthorizedEntity apiAuthorizedEntity = new ApiAuthorizedEntity(); + apiAuthorizedEntity.setId(UUID.randomUUID().toString().replace("-", "")); + apiAuthorizedEntity.setAppId(appId); + apiAuthorizedEntity.setAppKey(appKey); + apiAuthorizedEntity.setApiId(apiInfoEntity.getId()); + apiAuthorizedEntity.setCreateTime(new Date()); + this.save(apiAuthorizedEntity); + } + }); + } + addApiRedis(); + } + + @Override + public void add(ApiAuthorizedEntity apiAuthorizedEntity) { + this.save(apiAuthorizedEntity); + addApiRedis(); + } + + @Override + public void update(ApiAuthorizedEntity apiAuthorizedEntity) { + this.updateById(apiAuthorizedEntity); + addApiRedis(); + } + + @Override + public void deleteById(String id) { + this.getBaseMapper().delete(new QueryWrapper<ApiAuthorizedEntity>().eq("id", id)); + addApiRedis(); + } + + @Override + public ApiAuthorizedEntity getInfoById(String id) { + return this.getById(id); + } + + @Override + public void addApiRedis() { + Map<String, String> apis = new HashMap<>(); + Map<String, Object> params = new HashMap<>(1); + params.put("serverStatus", 1); + List<SysGatewayApi> gatewayApiList = getBaseMapper().queryListGatewayApi(params); + if (!CollectionUtils.isEmpty(gatewayApiList)) { + gatewayApiList.forEach(item -> { + String url = "/" + item.getServerName() + item.getApiAddress(); + apis.put(item.getAppKey() + "_" + url, item.getApiStatus().toString()); + }); + } + stringRedisTemplate.opsForValue().set(CacheConstant.GATEWAY_APIS, JSON.toJSONString(apis)); + } + +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/gateway/service/impl/ApiGroupServiceImpl.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/gateway/service/impl/ApiGroupServiceImpl.java new file mode 100644 index 0000000..d5c6910 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/gateway/service/impl/ApiGroupServiceImpl.java @@ -0,0 +1,77 @@ +package com.iailab.module.data.gateway.service.impl; + +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.iailab.module.data.common.utils.PageUtils; +import com.iailab.module.data.common.utils.Query; +import com.iailab.module.data.gateway.dao.ApiGroupDao; +import com.iailab.module.data.gateway.entity.ApiGroupEntity; +import com.iailab.module.data.gateway.service.ApiGroupService; +import org.apache.commons.lang3.StringUtils; +import org.springframework.stereotype.Service; + +import java.util.Date; +import java.util.List; +import java.util.Map; +import java.util.UUID; + +/** + * @author PanZhibao + * @Description + * @createTime 2022年07月15日 14:02:00 + */ +@Service("apiGroupService") +public class ApiGroupServiceImpl extends ServiceImpl<ApiGroupDao, ApiGroupEntity> implements ApiGroupService { + + @Override + public PageUtils queryPage(Map<String, Object> params) { + String groupName = (String)params.get("groupName"); + + IPage<ApiGroupEntity> page = this.page( + new Query<ApiGroupEntity>().getPage(params), + new QueryWrapper<ApiGroupEntity>() + .like(StringUtils.isNotBlank(groupName),"group_name", groupName) + .orderByDesc("create_time") + ); + return new PageUtils(page); + } + + @Override + public List<ApiGroupEntity> queryList() { + return getBaseMapper().selectList(new QueryWrapper<ApiGroupEntity>().orderByDesc("create_time")); + } + + @Override + public void add(ApiGroupEntity apiGroupEntity) { + apiGroupEntity.setId(UUID.randomUUID().toString().replace("-", "")); + apiGroupEntity.setCreateTime(new Date()); + this.save(apiGroupEntity); + } + + @Override + public void update(ApiGroupEntity apiGroupEntity) { + this.updateById(apiGroupEntity); + } + + @Override + public void deleteById(String id) { + this.getBaseMapper().delete(new QueryWrapper<ApiGroupEntity>().eq("id", id)); + } + + @Override + public ApiGroupEntity getInfoById(String id) { + return this.getById(id); + } + + @Override + public int cheack(ApiGroupEntity apiGroupEntity) { + String id = apiGroupEntity.getId(); + String groupName = apiGroupEntity.getGroupName(); + + QueryWrapper<ApiGroupEntity> queryWrapper = new QueryWrapper<>(); + queryWrapper.ne(StringUtils.isNotBlank(id), "id", id); + queryWrapper.and(wrapper -> wrapper.eq("group_name", groupName)); + return (int)this.count(queryWrapper); + } +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/gateway/service/impl/ApiInfoServiceImpl.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/gateway/service/impl/ApiInfoServiceImpl.java new file mode 100644 index 0000000..9bf6e31 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/gateway/service/impl/ApiInfoServiceImpl.java @@ -0,0 +1,83 @@ +package com.iailab.module.data.gateway.service.impl; + +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.iailab.module.data.common.utils.PageUtils; +import com.iailab.module.data.common.utils.Query; +import com.iailab.module.data.gateway.service.ApiInfoService; +import com.iailab.module.data.gateway.dao.ApiInfoDao; +import com.iailab.module.data.gateway.entity.ApiInfoEntity; +import org.apache.commons.lang3.StringUtils; +import org.springframework.stereotype.Service; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * @author PanZhibao + * @Description + * @createTime 2022年07月15日 14:03:00 + */ +@Service("apiInfoService") +public class ApiInfoServiceImpl extends ServiceImpl<ApiInfoDao, ApiInfoEntity> implements ApiInfoService { + + @Override + public PageUtils queryPage(Map<String, Object> params) { + String apiName = (String)params.get("apiName"); + String apiGroupId = (String)params.get("apiGroupId"); + String apiServerId = (String)params.get("apiServerId"); + + Map<String, Object> queryParams = new HashMap<>(3); + queryParams.put("apiName", apiName); + queryParams.put("apiGroupId", apiGroupId); + queryParams.put("apiServerId", apiServerId); + IPage<ApiInfoEntity> page = getBaseMapper().queryList( + new Query<ApiInfoEntity>().getPage(queryParams), + params + ); + return new PageUtils(page); + } + + @Override + public List<ApiInfoEntity> queryList(Map<String, Object> params) { + String apiGroupId = (String)params.get("apiGroupId"); + String apiServerId = (String)params.get("apiServerId"); + return getBaseMapper().selectList(new QueryWrapper<ApiInfoEntity>() + .eq(StringUtils.isNotBlank(apiGroupId), "api_group_id", apiGroupId) + .eq(StringUtils.isNotBlank(apiServerId), "api_server_id", apiServerId) + .orderByDesc("create_time")); + } + + @Override + public void add(ApiInfoEntity apiInfoEntity) { + this.save(apiInfoEntity); + } + + @Override + public void update(ApiInfoEntity apiInfoEntity) { + this.updateById(apiInfoEntity); + } + + @Override + public void deleteById(String id) { + this.getBaseMapper().delete(new QueryWrapper<ApiInfoEntity>().eq("id", id)); + } + + @Override + public ApiInfoEntity getInfoById(String id) { + return this.getById(id); + } + + @Override + public int cheack(ApiInfoEntity apiInfoEntity) { + String id = apiInfoEntity.getId(); + String apiName = apiInfoEntity.getApiName(); + + QueryWrapper<ApiInfoEntity> queryWrapper = new QueryWrapper<>(); + queryWrapper.ne(StringUtils.isNotBlank(id), "id", id); + queryWrapper.and(wrapper -> wrapper.eq("api_name", apiName)); + return (int)this.count(queryWrapper); + } +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/gateway/service/impl/ApiServerServiceImpl.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/gateway/service/impl/ApiServerServiceImpl.java new file mode 100644 index 0000000..ecfa272 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/gateway/service/impl/ApiServerServiceImpl.java @@ -0,0 +1,115 @@ +package com.iailab.module.data.gateway.service.impl; + +import com.alibaba.fastjson.JSON; +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.iailab.module.data.common.utils.PageUtils; +import com.iailab.module.data.common.utils.Query; +import com.iailab.framework.common.constant.CacheConstant; +import com.iailab.framework.common.constant.GlobalConstants; +import com.iailab.module.data.gateway.dao.ApiServerDao; +import com.iailab.module.data.gateway.entity.ApiServerEntity; +import com.iailab.module.data.gateway.service.ApiServerService; +import com.iailab.module.data.gateway.vo.SysGatewayRoute; +import org.apache.commons.lang3.StringUtils; +import javax.annotation.Resource; +import org.springframework.data.redis.core.RedisTemplate; +import org.springframework.stereotype.Service; +import org.springframework.util.CollectionUtils; + +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.UUID; +import java.util.stream.Collectors; + +/** + * @author PanZhibao + * @Description + * @createTime 2022年07月15日 14:03:00 + */ +@Service("apiServerService") +public class ApiServerServiceImpl extends ServiceImpl<ApiServerDao, ApiServerEntity> implements ApiServerService { + + @Resource + private RedisTemplate<String, Object> redisTemplate; + + private final int MINS = 60; + + private String filterJson = "[{\"args\":[{\"key\":\"parts\",\"value\":\"1\"}],\"name\":\"StripPrefix\"},{\"args\":[{\"key\":\"key-resolver\",\"value\":\"#{@authorizedApiKeyResolver}\"},{\"key\":\"redis-rate-limiter.replenishRate\",\"value\":1},{\"key\":\"redis-rate-limiter.burstCapacity\",\"value\":60},{\"key\":\"redis-rate-limiter.requestedTokens\",\"value\":requestedTokensValue}],\"name\":\"RequestRateLimiter\"}]"; + + @Override + public PageUtils queryPage(Map<String, Object> params) { + String serverName = (String)params.get("serverName"); + + IPage<ApiServerEntity> page = this.page( + new Query<ApiServerEntity>().getPage(params), + new QueryWrapper<ApiServerEntity>() + .like(StringUtils.isNotBlank(serverName),"server_name", serverName) + .orderByDesc("create_time") + ); + return new PageUtils(page); + } + + @Override + public void add(ApiServerEntity apiServerEntity) { + apiServerEntity.setId(UUID.randomUUID().toString().replace("-", "")); + this.save(apiServerEntity); +// this.addRouteRedis(); + } + + @Override + public void update(ApiServerEntity apiServerEntity) { + this.updateById(apiServerEntity); +// this.addRouteRedis(); + } + + @Override + public void deleteById(String id) { + this.getBaseMapper().delete(new QueryWrapper<ApiServerEntity>().eq("id", id)); + } + + @Override + public ApiServerEntity getInfoById(String id) { + return this.getById(id); + } + + @Override + public int cheack(ApiServerEntity apiServerEntity) { + String id = apiServerEntity.getId(); + String serverName = apiServerEntity.getServerName(); + + QueryWrapper<ApiServerEntity> queryWrapper = new QueryWrapper<>(); + queryWrapper.ne(StringUtils.isNotBlank(id), "id", id); + queryWrapper.and(wrapper -> wrapper.eq("server_name", serverName)); + return (int)this.count(queryWrapper); + } + + @Override + public void addRouteRedis() { + List<SysGatewayRoute> ls = new ArrayList<>(); + List<ApiServerEntity> list = getBaseMapper().selectList(new QueryWrapper<>()); + if (!CollectionUtils.isEmpty(list)) { + ls = list.stream().map(item -> { + SysGatewayRoute sysGatewayRoute = new SysGatewayRoute(); + sysGatewayRoute.setId(item.getId()); + sysGatewayRoute.setRouterId(item.getServerName()); + sysGatewayRoute.setName(item.getServerName()); + sysGatewayRoute.setUri(item.getServerAddress()); + sysGatewayRoute.setPredicates("[{\"args\":[\"/" + item.getServerName() +"/**\"],\"name\":\"Path\"}]"); + sysGatewayRoute.setFilters("[{\"args\":[{\"key\":\"parts\",\"value\":\"1\"}],\"name\":\"StripPrefix\"}]"); + if (item.getLimitMin() != null && item.getLimitMin().compareTo(MINS) <= 0) { + String requestedTokensValue = (new BigDecimal(MINS)).divide(new BigDecimal(item.getLimitMin()), 0, BigDecimal.ROUND_FLOOR).toString(); + sysGatewayRoute.setFilters(filterJson.replace("requestedTokensValue", requestedTokensValue)); + } + sysGatewayRoute.setStatus(item.getStatus()); + return sysGatewayRoute; + }).collect(Collectors.toList()); + } + redisTemplate.opsForValue().set(CacheConstant.GATEWAY_ROUTES, JSON.toJSONString(ls)); + //刷新网关 + redisTemplate.convertAndSend(GlobalConstants.REDIS_TOPIC_NAME, GlobalConstants.LODER_ROUDER_HANDLER); + } +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/gateway/vo/SysGatewayApi.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/gateway/vo/SysGatewayApi.java new file mode 100644 index 0000000..1ca7293 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/gateway/vo/SysGatewayApi.java @@ -0,0 +1,23 @@ +package com.iailab.module.data.gateway.vo; + +import lombok.Data; + +import java.io.Serializable; + +/** + * @author PanZhibao + * @Description + * @createTime 2022年07月20日 10:34:00 + */ +@Data +public class SysGatewayApi implements Serializable { + private static final long serialVersionUID = 1L; + + private String appKey; + + private Integer apiStatus; + + private String apiAddress; + + private String serverName; +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/gateway/vo/SysGatewayRoute.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/gateway/vo/SysGatewayRoute.java new file mode 100644 index 0000000..60fe5e0 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/gateway/vo/SysGatewayRoute.java @@ -0,0 +1,56 @@ +package com.iailab.module.data.gateway.vo; + +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; + +/** + * @author PanZhibao + * @Description + * @createTime 2022年07月19日 22:32:00 + */ +@Data +public class SysGatewayRoute implements Serializable { + private static final long serialVersionUID = 1L; + + /**主键*/ + private String id; + + /**routerKEy*/ + private String routerId; + + /**服务名*/ + private String name; + + /**服务地址*/ + private String uri; + + /** + * 断言配置 + */ + private String predicates; + + /** + * 过滤配置 + */ + private String filters; + + /**是否忽略前缀0-否 1-是*/ + private Integer stripPrefix; + + /**是否重试0-否 1-是*/ + private Integer retryable; + + /**是否为保留数据:0-否 1-是*/ + private Integer persistable; + + /**是否在接口文档中展示:0-否 1-是*/ + private Integer showApi; + + /**状态 1有效 0无效*/ + private Integer status; + + /**创建日期*/ + private Date createTime; +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/http/collector/HttpCollectorForSD.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/http/collector/HttpCollectorForSD.java new file mode 100644 index 0000000..9602de5 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/http/collector/HttpCollectorForSD.java @@ -0,0 +1,187 @@ +package com.iailab.module.data.http.collector; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.iailab.module.data.common.utils.HttpsRequest; +import com.iailab.api.IFeignModelApi; +import com.iailab.module.data.http.entity.HttpApiEntity; +import com.iailab.module.data.http.service.HttpTokenService; +import com.iailab.module.data.http.service.HttpApiService; +import com.iailab.module.data.http.service.HttpTagService; +import com.iailab.module.data.influxdb.service.InfluxDBService; +import lombok.extern.slf4j.Slf4j; +import javax.annotation.Resource; +import org.springframework.stereotype.Component; +import org.springframework.util.CollectionUtils; + +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * 山大设备数据采集 + * + * @author lirm + * @Description + * @createTime 2024年05月21日 + */ +@Slf4j +@Component +public class HttpCollectorForSD { + + @Resource + private HttpApiService httpApiService; + + @Resource + private HttpTagService httpTagService; + + @Resource + HttpTokenService httpTokenService; + @Resource + HttpsRequest httpsRequest; + + @Resource + private IFeignModelApi feignModelApi; + + @Resource + private InfluxDBService influxDBService; + + public void getRunStateValue(Map<String, String> tMap) { + Map<String, Integer> monitorCountMap = new HashMap<>(); + HttpApiEntity httpApi = httpApiService.getByCode(tMap.get("code")); + String token = httpTokenService.queryToken(tMap.get("client_id")); + Map<String, String> queryParams = new HashMap<>(); + queryParams.put("cu_ids", tMap.get("cu_ids")); + queryParams.put("t", tMap.get("t")); + String responseStr = httpsRequest.doGetSDData(httpApi.getUrl(), queryParams, "utf-8", token, tMap); + JSONObject responseObj = JSON.parseObject(responseStr); + if ("0".equals(responseObj.get("code").toString())) { + JSONObject dataObject = (JSONObject) responseObj.get("data"); + + JSONArray hasSensorArray = dataObject.getJSONArray("has_sensor"); + if (!CollectionUtils.isEmpty(hasSensorArray)) { + for (int i = 0; i < hasSensorArray.size(); i++) { + JSONObject item = hasSensorArray.getJSONObject(i); + String value = item.get("de_has_sensor").toString(); + if ("yes".equals(value)) { + monitorCountMap.put("total_count", Integer.parseInt(item.get("count").toString()));//在线监控设备数量 + } + } + } + JSONArray stateArray = dataObject.getJSONArray("state"); + if (!CollectionUtils.isEmpty(stateArray)) { + monitorCountMap.put("offline_count", 0); + monitorCountMap.put("halt_count", 0); + monitorCountMap.put("run_count", 0); + for (int i = 0; i < stateArray.size(); i++) { + JSONObject item = stateArray.getJSONObject(i); + String value = item.get("device_state").toString(); + if ("0".equals(value)) { + monitorCountMap.put("offline_count", Integer.parseInt(item.get("count").toString()));//离线设备数量 + } else if ("1".equals(value)) { + monitorCountMap.put("halt_count", Integer.parseInt(item.get("count").toString()));//停机设备数量 + } else if ("2".equals(value)) { + monitorCountMap.put("run_count", Integer.parseInt(item.get("count").toString()));//运行设备数量 + } + } + } + if (!monitorCountMap.isEmpty()) { + feignModelApi.insertRunState(monitorCountMap); + } + } + } + + public void getHealthStateValue(Map<String, String> tMap) { + Map<String, Object> monitorCountMap = new HashMap<>(); + HttpApiEntity httpApi = httpApiService.getByCode(tMap.get("code")); + String token = httpTokenService.queryToken(tMap.get("client_id")); + Map<String, String> queryParams = new HashMap<>(); + queryParams.put("cu_ids", tMap.get("cu_ids")); + queryParams.put("t", tMap.get("t")); + String responseStr = httpsRequest.doGetSDData(httpApi.getUrl(), queryParams, "utf-8", token, tMap); + JSONObject responseObj = JSON.parseObject(responseStr); + if ("0".equals(responseObj.get("code").toString())) { + JSONArray hasSensorArray = responseObj.getJSONArray("data"); + if (!CollectionUtils.isEmpty(hasSensorArray)) { + for (int i = 0; i < hasSensorArray.size(); i++) { + JSONObject item = hasSensorArray.getJSONObject(i); + String value = item.get("fault_level").toString(); + if ("0".equals(value)) { + monitorCountMap.put("normal", item.get("count"));//正常 + } else if ("1".equals(value)) { + monitorCountMap.put("common", item.get("count"));//一般 + } else if ("2".equals(value)) { + monitorCountMap.put("heavy", item.get("count"));//较重 + } else if ("3".equals(value)) { + monitorCountMap.put("serious", item.get("count"));//严重 + } else if ("4".equals(value)) { + monitorCountMap.put("espSerious", item.get("count"));//特别严重 + } + } + } + if (!monitorCountMap.isEmpty()) { + feignModelApi.insertHealthState(monitorCountMap); + } + } + } + + public void getDeviceList(Map<String, String> tMap) { + HttpApiEntity httpApi = httpApiService.getByCode(tMap.get("code")); + tMap.put("url", httpApi.getUrl()); + + feignModelApi.insertDeviceList(tMap); + } + + public void getTemperatureValue(Map<String, String> tMap, Date date) { + Map<String, Object> monitorCountMap = new HashMap<>(); + HttpApiEntity httpApi = httpApiService.getByCode(tMap.get("code")); + String token = httpTokenService.queryToken(tMap.get("client_id")); + List<String> deviceIdList = feignModelApi.getDeviceIdList(); + if (!CollectionUtils.isEmpty(deviceIdList)) { + for (String deviceId : deviceIdList) { + List<String> tagNoList = httpTagService.getByTagType(deviceId); + if (CollectionUtils.isEmpty(tagNoList)) { + continue; + } + StringBuffer sb = new StringBuffer(); + sb.append(httpApi.getUrl()); + sb.append("/"); + sb.append(deviceId); + Map<String, String> queryParams = new HashMap<>(); + String responseStr = httpsRequest.doGetSDData(sb.toString(), queryParams, "utf-8", token, tMap); + JSONObject responseObj = JSON.parseObject(responseStr); + if ("200".equals(responseObj.get("status").toString())) { + JSONObject dataObject = (JSONObject) responseObj.get("data"); + JSONArray jsonArray = dataObject.getJSONArray("realtime-params"); + if (!CollectionUtils.isEmpty(jsonArray)) { + for (int i = 0; i < jsonArray.size(); i++) { + JSONObject item = jsonArray.getJSONObject(i); + String order = item.get("cp_order").toString(); + String name = item.get("param_name").toString(); + if ("1".equals(order) && "温度".equals(name)) { + for (String tagCode : tagNoList) { + String value = item.get("last_value").toString(); + // Date date = DateUtils.parse(item.get("last_time").toString(),"yyyy-MM-dd HH:mm:ss"); + if (tagCode.contains("Temperature")) { + influxDBService.syncWriteFloatValue(tagCode, value, date.getTime()); + } + } + } + if ("1".equals(order) && "1倍频振幅".equals(name)) { + for (String tagCode : tagNoList) { + String value = item.get("last_value").toString(); + // Date date = DateUtils.parse(item.get("last_time").toString(),"yyyy-MM-dd HH:mm:ss"); + if (tagCode.contains("Flutter")) { + influxDBService.syncWriteFloatValue(tagCode, value, date.getTime()); + } + } + } + } + } + } + } + } + } +} \ No newline at end of file diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/http/collector/HttpCollectorForUser.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/http/collector/HttpCollectorForUser.java new file mode 100644 index 0000000..a12a0d4 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/http/collector/HttpCollectorForUser.java @@ -0,0 +1,85 @@ +package com.iailab.module.data.http.collector; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.iailab.module.data.common.utils.HttpsRequest; +import com.iailab.module.data.http.entity.HttpApiEntity; +import com.iailab.module.data.http.service.HttpApiService; +import com.iailab.module.system.api.permission.RoleApi; +import com.iailab.module.system.api.permission.dto.RoleDTO; +import com.iailab.module.system.api.user.AdminUserApi; +import com.iailab.module.system.api.user.dto.AdminUserRespDTO; +import lombok.extern.slf4j.Slf4j; +import javax.annotation.Resource; +import org.springframework.stereotype.Component; + +import java.util.*; + +/** + * 山大设备数据采集 + * + * @author lirm + * @Description + * @createTime 2024年05月21日 + */ +@Slf4j +@Component +public class HttpCollectorForUser { + + @Resource + private HttpApiService httpApiService; + + @Resource + HttpsRequest httpsRequest; + + @Resource + private AdminUserApi adminUserApi; + + @Resource + private RoleApi roleApi; + + public void saveJobInfo(Map<String, String> tMap) { + HttpApiEntity httpApi = httpApiService.getByCode(tMap.get("code")); + String responseStr = httpsRequest.doGet(httpApi.getUrl(), null, "utf-8", ""); + log.info("JobInfo responseStr:" + responseStr); + JSONObject responseObj = JSON.parseObject(responseStr); + if ("true".equals(responseObj.get("sta").toString())) { + JSONArray jsonArray = responseObj.getJSONArray("res"); + for (int i = 0; i < jsonArray.size(); i++) { + JSONObject jsonObject = jsonArray.getJSONObject(i); + RoleDTO role = new RoleDTO(); + role.setName(jsonObject.getString("name")); + role.setUpdateDate(new Date()); + log.info("同步保存的角色名称为:" + role.getName()); + roleApi.saveRoleInfo(role); + } + } + + } + public void saveUserInfo(Map<String, String> tMap) { + HttpApiEntity httpApi = httpApiService.getByCode(tMap.get("code")); + String responseStr = httpsRequest.doGet(httpApi.getUrl(), null, "utf-8", ""); + log.info("responseStr:" + responseStr); + JSONObject responseObj = JSON.parseObject(responseStr); + if ("true".equals(responseObj.get("sta").toString())) { + JSONArray jsonArray = responseObj.getJSONArray("res"); + for (int i = 0; i < jsonArray.size(); i++) { + JSONObject jsonObject = jsonArray.getJSONObject(i); + AdminUserRespDTO sysUser = new AdminUserRespDTO(); + sysUser.setUsername(jsonObject.getString("no")); + sysUser.setNickname(jsonObject.getString("name")); + sysUser.setMobile(jsonObject.getString("phone")); + sysUser.setStatus(1); + //添加用户角色 + RoleDTO role = roleApi.getRoleByName(jsonObject.getString("job")); + Set<Long> roleIdList = new HashSet<>(); + roleIdList.add(role.getId()); + //为用户添加默认角色 + roleIdList.add(2L); + sysUser.setRoleIdList(roleIdList); + adminUserApi.saveOrUpdateUserInfo(sysUser); + } + } + } +} \ No newline at end of file diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/http/collector/HttpCollectorForZxzk.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/http/collector/HttpCollectorForZxzk.java new file mode 100644 index 0000000..a0afa18 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/http/collector/HttpCollectorForZxzk.java @@ -0,0 +1,136 @@ +package com.iailab.module.data.http.collector; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.iailab.module.data.common.enums.CommonConstant; +import com.iailab.module.data.common.enums.DataSourceType; +import com.iailab.module.data.common.utils.HttpsRequest; +import com.iailab.module.data.common.utils.TagUtils; +import com.iailab.module.data.http.entity.HttpApiEntity; +import com.iailab.module.data.http.service.HttpApiService; +import lombok.extern.slf4j.Slf4j; +import javax.annotation.Resource; +import org.springframework.stereotype.Component; +import org.springframework.util.CollectionUtils; + +import java.math.BigDecimal; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * 中选时序数据采集 + * http://192.168.55.122/api/Data/CurrentData?domain=NttRslinxLogic&tagstr=[ZX1]D_113.State.KM,[ZX1]D_114.State.KM + * domain:限定数据域,可空,为空时不限定数据域。 + * tagstr:限定标签集合,可空,为空时不限定标签。格式为英文逗号分隔的一个或多个标签名,如tag1,tag2,由于标签中可能包含特殊字符,get参数需要对此参数进行encode处理。 + * { + * "sta": true, + * "msg": null, + * "res": [ + * { + * "Tag": "[ZX1]D_110.State.KM",//标签 + * "Value": 0//当前值 + * }, + * + * @author PanZhibao + * @Description + * @createTime 2024年05月16日 + */ +@Slf4j +@Component +public class HttpCollectorForZxzk { + + private Map<String, HttpApiEntity> apiMap = new HashMap<>(); + + @Resource + private HttpApiService httpApiService; + + @Resource + HttpsRequest httpsRequest; + + private final String STA_TRUE = "true"; + + private final int GROUP_MAX_COUNT = 50; + + private HttpApiEntity getHttpApi(String id) { + if (apiMap.containsKey(id)) { + return apiMap.get(id); + } + HttpApiEntity httpApi = httpApiService.get(id); + apiMap.put(id, httpApi); + return httpApi; + } + + public BigDecimal getTagValue(String sourceId, String tagNo) { + BigDecimal value = CommonConstant.BAD_VALUE; + HttpApiEntity httpApi = this.getHttpApi(sourceId); + Map<String, String> queryParams = new HashMap<>(); + queryParams.put("tagstr", tagNo); + String responseStr = httpsRequest.doGet(httpApi.getUrl(), queryParams, "utf-8", ""); + JSONObject responseObj = JSON.parseObject(responseStr); + if (STA_TRUE.equals(responseObj.get("sta").toString())) { + JSONArray tagValueList = responseObj.getJSONArray("res"); + if (!CollectionUtils.isEmpty(tagValueList)) { + for (int i = 0; i < tagValueList.size(); i++) { + JSONObject item = tagValueList.getJSONObject(i); + value = new BigDecimal(item.get("Value").toString()); + } + } + } + return value; + } + + + public Map<String, Object> getTagValues(List<String[]> params) { + if (CollectionUtils.isEmpty(params)) { + return new HashMap<>(); + } + + Map<Integer, List<String[]>> measurePointsCountGroup = new HashMap<>(); + int pointListSize = params.size(); + int groupCount = pointListSize / GROUP_MAX_COUNT + ((pointListSize % GROUP_MAX_COUNT) > 0 ? 1 : 0); + log.info("groupCount=" + groupCount); + for (int i = 0; i < groupCount; i++) { + int end = (i + 1) * GROUP_MAX_COUNT; + if (end > pointListSize) { + end = pointListSize; + } + measurePointsCountGroup.put(i, params.subList(i * GROUP_MAX_COUNT, end)); + } + Map<String, Object> result = new HashMap<>(params.size()); + for(Map.Entry<Integer, List<String[]>> measurePointsItem : measurePointsCountGroup.entrySet()) { + try { + getByHtp(result, measurePointsItem.getValue()); + } catch (Exception ex) { + ex.printStackTrace(); + } + } + return result; + } + + private void getByHtp(Map<String, Object> result, List<String[]> params) { + HttpApiEntity httpApi = this.getHttpApi(params.get(0)[0]); + Map<String, String> queryParams = new HashMap<>(); + StringBuilder tagSb = new StringBuilder(); + for (int i = 0; i < params.size(); i ++) { + tagSb.append(params.get(i)[1]); + if (i < params.size() - 1) { + tagSb.append(","); + } + } + queryParams.put("tagstr", tagSb.toString()); + String responseStr = httpsRequest.doGet(httpApi.getUrl(), queryParams, "utf-8", ""); + JSONObject responseObj = JSON.parseObject(responseStr); + if (STA_TRUE.equals(responseObj.get("sta").toString())) { + JSONArray tagValueList = responseObj.getJSONArray("res"); + if (!CollectionUtils.isEmpty(tagValueList)) { + for (int i = 0; i < tagValueList.size(); i++) { + JSONObject item = tagValueList.getJSONObject(i); + result.put(TagUtils.genTagId(DataSourceType.HTTP.getCode(), httpApi.getCode(), item.get("Tag").toString()), item.get("Value")); + } + } + } + + } +} \ No newline at end of file diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/http/controller/admin/HttpApiController.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/http/controller/admin/HttpApiController.java new file mode 100644 index 0000000..a620386 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/http/controller/admin/HttpApiController.java @@ -0,0 +1,82 @@ +package com.iailab.module.data.http.controller.admin; + +import com.iailab.framework.common.page.PageData; +import com.iailab.module.data.common.utils.R; +import com.iailab.framework.common.pojo.CommonResult; +import com.iailab.module.data.http.entity.HttpApiEntity; +import com.iailab.module.data.http.service.HttpApiService; +import javax.annotation.Resource; +import org.springframework.web.bind.annotation.*; + +import java.util.List; +import java.util.Map; +import java.util.UUID; + +import static com.iailab.framework.common.pojo.CommonResult.success; + +@RestController +@RequestMapping("/data/http/api") +public class HttpApiController { + + @Resource + private HttpApiService httpApiService; + + @GetMapping("page") + public CommonResult<PageData<HttpApiEntity>> page(@RequestParam Map<String, Object> params) { + PageData<HttpApiEntity> page = httpApiService.page(params); + return success(page); + } + + @GetMapping("list") + public CommonResult<List<HttpApiEntity>> list() { + List<HttpApiEntity> list = httpApiService.list(); + return new CommonResult<List<HttpApiEntity>>().setData(list); + } + + /** + * 根据id查询详情 + * + * @param id + */ + @GetMapping("/info/{id}") + public R info(@PathVariable("id") String id){ + HttpApiEntity info= httpApiService.selectById(id); + return R.ok().put("data", info); + } + /** + * 添加API + * + * @param httpApiEntity + */ + @PostMapping("/add") + public R add(@RequestBody HttpApiEntity httpApiEntity){ + String id = UUID.randomUUID().toString(); + httpApiEntity.setId(id); + httpApiService.insert(httpApiEntity); + return R.ok(); + } + + /** + * 修改API + * + * @param httpApiEntity + */ + @PostMapping("/update") + public R update(@RequestBody HttpApiEntity httpApiEntity) { + httpApiService.updateById(httpApiEntity); + return R.ok(); + } + + /** + * 删除API + * + * @param params + * + */ + @PostMapping("/delete") + public R delete(@RequestBody Map<String, Object> params) { + String id = (String)params.get("id"); + httpApiService.deleteById(id); + return R.ok(); + } +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/http/controller/admin/HttpTagController.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/http/controller/admin/HttpTagController.java new file mode 100644 index 0000000..1a7d48f --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/http/controller/admin/HttpTagController.java @@ -0,0 +1,103 @@ +package com.iailab.module.data.http.controller.admin; + +import com.iailab.module.data.common.utils.PageUtils; +import com.iailab.module.data.common.utils.R; +import com.iailab.framework.common.pojo.CommonResult; +import com.iailab.module.data.http.dto.HttpTagDTO; +import com.iailab.module.data.http.entity.HttpTagEntity; +import com.iailab.module.data.http.service.HttpTagService; +import javax.annotation.Resource; +import org.springframework.web.bind.annotation.*; + +import java.util.List; +import java.util.Map; +import java.util.UUID; + +/** + * @author Houzhongjian + * @Description + * @createTime 2024年04月10日 17:37:00 + */ +@RestController +@RequestMapping("/data/http/tag") +public class HttpTagController { + + @Resource + private HttpTagService tagService; + + /** + * 分页 + * + * @param params + */ + @GetMapping("/page") + public R tagPageList(@RequestParam Map<String, Object> params) { + PageUtils page = tagService.queryPage(params); + + return R.ok().put("page", page); + } + + /** + * 查询tagList + * + */ + @GetMapping("/list") + public R tagList(@RequestParam Map<String, Object> params){ + List<HttpTagEntity> data = tagService.selectList(params); + + return R.ok().put("data", data); + } + + /** + * 详情 + * + * @param id + */ + @GetMapping("/info/{id}") + public R tagInfo(@PathVariable("id") String id) { + HttpTagEntity info = tagService.selectById(id); + return R.ok().put("data", info); + } + + /** + * 添加 + * + * @param entity + */ + @PostMapping("/add") + public R tagAdd(@RequestBody HttpTagEntity entity) { + entity.setId(UUID.randomUUID().toString()); + tagService.insert(entity); + return R.ok(); + } + + /** + * 修改 + * + * @param entity + */ + @PostMapping("/update") + public R tagUpdate(@RequestBody HttpTagEntity entity) { + tagService.updateById(entity); + return R.ok(); + } + + /** + * 删除 + * + * @param params + */ + @PostMapping("/delete") + public R tagDelete(@RequestBody Map<String, Object> params) { + String id = (String) params.get("id"); + tagService.deleteById(id); + return R.ok(); + } + + + @GetMapping("tagNo") + public CommonResult<List<HttpTagDTO>> list(@RequestParam Map<String, Object> params){ + List<HttpTagDTO> list = tagService.list(params); + return new CommonResult<List<HttpTagDTO>>().setData(list); + } +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/http/controller/admin/HttpTokenController.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/http/controller/admin/HttpTokenController.java new file mode 100644 index 0000000..108a401 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/http/controller/admin/HttpTokenController.java @@ -0,0 +1,96 @@ +package com.iailab.module.data.http.controller.admin; + +import com.iailab.framework.common.page.PageData; +import com.iailab.module.data.common.utils.R; +import com.iailab.framework.common.pojo.CommonResult; +import com.iailab.module.data.http.entity.HttpTokenEntity; +import com.iailab.module.data.http.service.HttpTokenService; +import javax.annotation.Resource; +import org.springframework.web.bind.annotation.*; + +import java.util.Map; +import java.util.UUID; + +/** + * @author PanZhibao + * @Description + * @createTime 2023年12月22日 10:52:00 + */ +@RestController +@RequestMapping("/data/http/token") +public class HttpTokenController { + + @Resource + private HttpTokenService httpTokenService; + + /** + * 分页 + * + * @param params + * @return + */ + @GetMapping("page") + public CommonResult<PageData<HttpTokenEntity>> page(@RequestParam Map<String, Object> params) { + PageData<HttpTokenEntity> page = httpTokenService.page(params); + + return new CommonResult<PageData<HttpTokenEntity>>().setData(page); + } + + /** + * 详情 + * + * @param id + */ + @GetMapping("/info/{id}") + public R info(@PathVariable("id") String id) { + HttpTokenEntity info = httpTokenService.selectById(id); + return R.ok().put("data", info); + } + + /** + * 详情 + * + * @param apiId + */ + @GetMapping("/api-id/{apiId}") + public R apiId(@PathVariable("apiId") String apiId) { + HttpTokenEntity info = httpTokenService.getByApiId(apiId); + return R.ok().put("data", info); + } + + /** + * 添加 + * + * @param httpApiEntity + */ + @PostMapping("/add") + public R add(@RequestBody HttpTokenEntity httpApiEntity) { + String id = UUID.randomUUID().toString(); + httpApiEntity.setId(id); + httpTokenService.insert(httpApiEntity); + return R.ok(); + } + + /** + * 修改 + * + * @param httpApiEntity + */ + @PostMapping("/update") + public R update(@RequestBody HttpTokenEntity httpApiEntity) { + httpTokenService.updateById(httpApiEntity); + return R.ok(); + } + + /** + * 删除 + * + * @param params + */ + @PostMapping("/delete") + public R delete(@RequestBody Map<String, Object> params) { + String id = (String) params.get("id"); + httpTokenService.deleteById(id); + return R.ok(); + } +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/http/controller/package-info.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/http/controller/package-info.java new file mode 100644 index 0000000..49239c6 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/http/controller/package-info.java @@ -0,0 +1 @@ +package com.iailab.module.data.http.controller; \ No newline at end of file diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/http/dao/EleLowTagDao.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/http/dao/EleLowTagDao.java new file mode 100644 index 0000000..3fe1b57 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/http/dao/EleLowTagDao.java @@ -0,0 +1,14 @@ +package com.iailab.module.data.http.dao; + +import com.iailab.framework.common.dao.BaseDao; +import com.iailab.module.data.http.entity.EleLowTagEntity; +import org.apache.ibatis.annotations.Mapper; + +/** + * @author PanZhibao + * @Description + * @createTime 2023年12月19日 08:35:00 + */ +@Mapper +public interface EleLowTagDao extends BaseDao<EleLowTagEntity> { +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/http/dao/FxjyTagDao.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/http/dao/FxjyTagDao.java new file mode 100644 index 0000000..bcfabae --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/http/dao/FxjyTagDao.java @@ -0,0 +1,14 @@ +package com.iailab.module.data.http.dao; + +import com.iailab.framework.common.dao.BaseDao; +import com.iailab.module.data.http.entity.FxjyTagEntity; +import org.apache.ibatis.annotations.Mapper; + +/** + * @author DongYukun + * @Description + * @createTime 2024年01月17日 13:13:00 + */ +@Mapper +public interface FxjyTagDao extends BaseDao<FxjyTagEntity> { +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/http/dao/HttpApiDao.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/http/dao/HttpApiDao.java new file mode 100644 index 0000000..7db6b0f --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/http/dao/HttpApiDao.java @@ -0,0 +1,10 @@ +package com.iailab.module.data.http.dao; + +import com.iailab.framework.common.dao.BaseDao; +import com.iailab.module.data.http.entity.HttpApiEntity; +import com.iailab.module.data.http.entity.HttpApiEntity; +import org.apache.ibatis.annotations.Mapper; + +@Mapper +public interface HttpApiDao extends BaseDao<HttpApiEntity> { +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/http/dao/HttpTagDao.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/http/dao/HttpTagDao.java new file mode 100644 index 0000000..83a6674 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/http/dao/HttpTagDao.java @@ -0,0 +1,19 @@ +package com.iailab.module.data.http.dao; + +import com.iailab.framework.common.dao.BaseDao; +import com.iailab.module.data.http.dto.HttpTagDTO; +import com.iailab.module.data.http.entity.HttpTagEntity; +import org.apache.ibatis.annotations.Mapper; + +import java.util.List; +import java.util.Map; + +/** + * @author Houzhongjian + * @Description + * @createTime 2024年04月10日 17:35:00 + */ +@Mapper +public interface HttpTagDao extends BaseDao<HttpTagEntity> { + List<HttpTagDTO> getList(Map<String, Object> params); +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/http/dao/HttpTokenDao.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/http/dao/HttpTokenDao.java new file mode 100644 index 0000000..1741907 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/http/dao/HttpTokenDao.java @@ -0,0 +1,10 @@ +package com.iailab.module.data.http.dao; + +import com.iailab.framework.common.dao.BaseDao; +import com.iailab.module.data.http.entity.HttpTokenEntity; +import org.apache.ibatis.annotations.Mapper; + +@Mapper +public interface HttpTokenDao extends BaseDao<HttpTokenEntity> { + +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/http/dao/XSTTagDao.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/http/dao/XSTTagDao.java new file mode 100644 index 0000000..a0920e2 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/http/dao/XSTTagDao.java @@ -0,0 +1,11 @@ +package com.iailab.module.data.http.dao; + +import com.iailab.framework.common.dao.BaseDao; +import com.iailab.module.data.http.entity.XSTTagEntity; +import com.iailab.module.data.http.entity.XSTTagEntity; +import org.apache.ibatis.annotations.Mapper; + +@Mapper +public interface XSTTagDao extends BaseDao<XSTTagEntity> { + +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/http/dto/HttpTagDTO.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/http/dto/HttpTagDTO.java new file mode 100644 index 0000000..229e3c5 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/http/dto/HttpTagDTO.java @@ -0,0 +1,17 @@ +package com.iailab.module.data.http.dto; + +import lombok.Data; +import org.springframework.stereotype.Component; + +/** + * @author lirm + * @Description + * @createTime 2024年06月03日 + */ +@Component +@Data +public class HttpTagDTO { + private String tagType; + private String tagCode; + private String tagName; +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/http/dto/TagAffectDetailsJsonDto.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/http/dto/TagAffectDetailsJsonDto.java new file mode 100644 index 0000000..1c286c6 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/http/dto/TagAffectDetailsJsonDto.java @@ -0,0 +1,38 @@ +package com.iailab.module.data.http.dto; + +import lombok.Data; +import org.springframework.stereotype.Component; + +import java.io.Serializable; +import java.util.List; + +@Component +@Data +public class TagAffectDetailsJsonDto implements Serializable { + private String sta; + private String msg; + private DATA res; + + @Component + @Data + public static class DATA{ + + private List<AFFECTDETAILS> affectDetails; + + @Data + public static class AFFECTDETAILS { + //区域 + String area; + //时间 + String date; + //开始时间 + String starttime; + //结束时间 + String endtime; + //影响时间(时分秒格式) + String affecttime; + //停机原因 + String info; + } + } +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/http/dto/TagCommonCurrentDto.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/http/dto/TagCommonCurrentDto.java new file mode 100644 index 0000000..870eae4 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/http/dto/TagCommonCurrentDto.java @@ -0,0 +1,16 @@ +package com.iailab.module.data.http.dto; + +import lombok.Data; +import org.springframework.stereotype.Component; + +/** + * @author Houzhongjian + * @Description + * @createTime 2024年04月10日 17:35:00 + */ +@Component +@Data +public class TagCommonCurrentDto { + private String tagType; + private String tagCode; +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/http/dto/TagCurrentPerformanceJsonDto.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/http/dto/TagCurrentPerformanceJsonDto.java new file mode 100644 index 0000000..08f5b29 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/http/dto/TagCurrentPerformanceJsonDto.java @@ -0,0 +1,50 @@ +package com.iailab.module.data.http.dto; + +import lombok.Data; +import org.springframework.stereotype.Component; + +import java.io.Serializable; + +@Component +@Data +public class TagCurrentPerformanceJsonDto implements Serializable { + private String sta; + private String msg; + private DATA res; + + @Data + public static class DATA{ + TODAY today; + YESTERDAY yesterday; + CURRENTMONTH currentMonth; + CURRENTYEAR currentYear; + @Data + public static class TODAY{ + //筛选产量 + String xxPerformance; + //栈桥运输量 + String zqPerformance; + } + @Data + public static class YESTERDAY{ + //筛选产量 + String xxPerformance; + //栈桥运输量 + String zqPerformance; + } + @Data + public static class CURRENTMONTH{ + //筛选产量 + String xxPerformance; + //栈桥运输量 + String zqPerformance; + } + @Data + public static class CURRENTYEAR{ + //筛选产量 + String xxPerformance; + //栈桥运输量 + String zqPerformance; + } + } +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/http/dto/TagCurrentSaleJsonDto.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/http/dto/TagCurrentSaleJsonDto.java new file mode 100644 index 0000000..ababe23 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/http/dto/TagCurrentSaleJsonDto.java @@ -0,0 +1,92 @@ +package com.iailab.module.data.http.dto; + +import lombok.Data; +import org.springframework.stereotype.Component; + +import java.io.Serializable; + +@Component +@Data +public class TagCurrentSaleJsonDto implements Serializable { + private String sta; + private String msg; + private DATA res; + + @Component + @Data + public static class DATA{ + private TODAY today; + private YESTERDAY yesterday; + private CURRENTMONTH currentmonth; + private CURRENTYEAR currentyear; + + @Data + public static class TODAY { + //地销混煤 + String groundsales; + //洗中块 + String medblock; + //洗小块 + String nubmeasure; + //矸石 + String gangue; + //小块转载 + String reshipped; + //火车外运吨数 + String trainTon; + //火车外运列数 + String trainCount; + } + @Data + public static class YESTERDAY { + //地销混煤 + String groundsales; + //洗中块 + String medblock; + //洗小块 + String nubmeasure; + //矸石 + String gangue; + //小块转载 + String reshipped; + //火车外运吨数 + String trainTon; + //火车外运列数 + String trainCount; + } + @Data + public static class CURRENTMONTH { + //地销混煤 + String groundsales; + //洗中块 + String medblock; + //洗小块 + String nubmeasure; + //矸石 + String gangue; + //小块转载 + String reshipped; + //火车外运吨数 + String trainTon; + //火车外运列数 + String trainCount; + } + @Data + public static class CURRENTYEAR { + //地销混煤 + String groundsales; + //洗中块 + String medblock; + //洗小块 + String nubmeasure; + //矸石 + String gangue; + //小块转载 + String reshipped; + //火车外运吨数 + String trainTon; + //火车外运列数 + String trainCount; + } + } +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/http/dto/TagJsonDto.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/http/dto/TagJsonDto.java new file mode 100644 index 0000000..3da5686 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/http/dto/TagJsonDto.java @@ -0,0 +1,34 @@ +package com.iailab.module.data.http.dto; + +import lombok.Data; +import org.springframework.stereotype.Component; + +import java.io.Serializable; +import java.util.List; + +@Component +@Data +public class TagJsonDto implements Serializable { + + private List<RESULT> result; + private String targetUrl; + private String success; + private String error; + private String unAuthorizedRequest; + private String __abp; + + @Data + public static class RESULT{ + private String pointId; + private String pointCode; + private String pointName; + private String equipmentId; + private String equipmentName; + private String unit; + private String unitCode; + private String sampleTime; + private String measureValue; + private String pntDirect; + private String sensorAxis; + } +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/http/dto/TagPrdTimeDistJsonDto.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/http/dto/TagPrdTimeDistJsonDto.java new file mode 100644 index 0000000..489cf5e --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/http/dto/TagPrdTimeDistJsonDto.java @@ -0,0 +1,41 @@ +package com.iailab.module.data.http.dto; + +import lombok.Data; +import org.springframework.stereotype.Component; + +import java.io.Serializable; + +@Component +@Data +public class TagPrdTimeDistJsonDto implements Serializable { + private String sta; + private String msg; + private DATA res; + + @Component + @Data + public static class DATA{ + private XX xx; + private ZQ zq; + + @Data + public static class XX { + //runMinutes:生产时间(分钟) + String runMinutes; + //overhaulMinutes:检修时间(分钟) + String overhaulMinutes; + //affectMinutes:影响时间(分钟) + String affectMinutes; + } + @Data + public static class ZQ { + //runMinutes:生产时间(分钟) + String runMinutes; + //overhaulMinutes:检修时间(分钟) + String overhaulMinutes; + //affectMinutes:影响时间(分钟) + String affectMinutes; + } + + } +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/http/dto/TagYearPeiJsonDto.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/http/dto/TagYearPeiJsonDto.java new file mode 100644 index 0000000..9e33ccc --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/http/dto/TagYearPeiJsonDto.java @@ -0,0 +1,45 @@ +package com.iailab.module.data.http.dto; + +import lombok.Data; +import org.springframework.stereotype.Component; + +import java.io.Serializable; +import java.util.List; + +@Component +@Data +public class TagYearPeiJsonDto implements Serializable { + private String sta; + private String msg; + private DATA res; + @Data + public static class DATA{ + YEAR yearData; + List<MONTH> monthData; + @Data + public static class YEAR { + //洗选计划量 + String xxPlan; + //洗选产量 + String xxPerformance; + //栈桥计划量 + String zqPlan; + //栈桥产量 + String zqPerformance; + } + @Data + public static class MONTH { + //月份 + String month; + //洗选计划量 + String xxPlan; + //洗选产量 + String xxPerformance; + //栈桥计划量 + String zqPlan; + //栈桥产量 + String zqPerformance; + } + } + +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/http/dto/TokenJsonDto.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/http/dto/TokenJsonDto.java new file mode 100644 index 0000000..061885d --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/http/dto/TokenJsonDto.java @@ -0,0 +1,17 @@ +package com.iailab.module.data.http.dto; + +import lombok.Data; + +import java.io.Serializable; +import java.util.Map; + +@Data +public class TokenJsonDto implements Serializable { + + private Map<String,String> result; + private String targetUrl; + private String success; + private String error; + private String unAuthorizedRequest; + private String __abp; +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/http/entity/EleLowTagEntity.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/http/entity/EleLowTagEntity.java new file mode 100644 index 0000000..511411b --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/http/entity/EleLowTagEntity.java @@ -0,0 +1,58 @@ +package com.iailab.module.data.http.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 2023年12月18日 16:53:00 + */ +@Data +@TableName("t_ele_low_tag") +public class EleLowTagEntity implements Serializable { + private static final long serialVersionUID = 1L; + + /** + * ID + */ + @Schema(description = "ID") + @TableId(value = "id", type = IdType.INPUT) + private String id; + + /** + * 位置 + */ + private String location; + + /** + * 所在柜号 + */ + private String boxNum; + + /** + * 开关位置 + */ + private String switchLocation; + + /** + * 测点名称 + */ + private String tagName; + + /** + * 创建时间 + */ + private Date createTime; + + /** + * 更新时间 + */ + private Date updateTime; +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/http/entity/FxjyTagEntity.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/http/entity/FxjyTagEntity.java new file mode 100644 index 0000000..d3d637a --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/http/entity/FxjyTagEntity.java @@ -0,0 +1,53 @@ +package com.iailab.module.data.http.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 DongYukun + * @Description + * @createTime 2024年01月17日 13:19:00 + */ +@Data +@TableName("t_fxjy_tag") +public class FxjyTagEntity implements Serializable { + private static final long serialVersionUID = 1L; + + /** + * 主键 + */ + @Schema(description = "主键") + @TableId(value = "id", type = IdType.INPUT) + private String id; + + /** + * 测点类型 + */ + private String tagType; + + /** + * 测点编码 + */ + private String tagCode; + + /** + * 测点名称 + */ + private String tagName; + + /** + * 创建时间 + */ + private Date createTime; + + /** + * 更新时间 + */ + private Date updateTime; +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/http/entity/HttpApiEntity.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/http/entity/HttpApiEntity.java new file mode 100644 index 0000000..a01a9eb --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/http/entity/HttpApiEntity.java @@ -0,0 +1,33 @@ +package com.iailab.module.data.http.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; + +@Data +@TableName("T_HTTP_API") +public class HttpApiEntity implements Serializable { + private static final long serialVersionUID = 1L; + + /** + * 主键 + */ + @Schema(description = "主键") + @TableId(value = "id", type = IdType.INPUT) + private String id; + private String name; + private String code; + private String url; + private String method; + private String collectType; + private String param; + private String descp; + private Integer status; + private Date createTime; + private Date updateTime; +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/http/entity/HttpTagEntity.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/http/entity/HttpTagEntity.java new file mode 100644 index 0000000..c11f713 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/http/entity/HttpTagEntity.java @@ -0,0 +1,58 @@ +package com.iailab.module.data.http.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 Houzhongjian + * @Description + * @createTime 2024年04月10日 17:35:00 + */ +@Data +@TableName("t_http_tag") +public class HttpTagEntity implements Serializable { + private static final long serialVersionUID = 1L; + + /** + * 主键 + */ + @Schema(description = "主键") + @TableId(value = "id", type = IdType.INPUT) + private String id; + + /** + * HTTP api code + */ + private String httpApiCode; + + /** + * 测点类型 + */ + private String tagType; + + /** + * 测点编码 + */ + private String tagCode; + + /** + * 测点名称 + */ + private String tagName; + + /** + * 创建时间 + */ + private Date createTime; + + /** + * 更新时间 + */ + private Date updateTime; +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/http/entity/HttpTokenEntity.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/http/entity/HttpTokenEntity.java new file mode 100644 index 0000000..c9054c0 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/http/entity/HttpTokenEntity.java @@ -0,0 +1,35 @@ +package com.iailab.module.data.http.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; + +@Data +@TableName("T_HTTP_TOKEN") +public class HttpTokenEntity implements Serializable { + private static final long serialVersionUID = 1L; + + /** + * 主键 + */ + @Schema(description = "主键") + @TableId(value = "id", type = IdType.INPUT) + private String id; + private String apiId; + private String loginUrl; + private String clientId; + private String clientSecret; + private String username; + private String password; + private String token; + private String prvsetName; + private String projectName; + private String platform; + private Date expireTime; + private Date updateTime; +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/http/entity/XSTTagEntity.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/http/entity/XSTTagEntity.java new file mode 100644 index 0000000..358b85e --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/http/entity/XSTTagEntity.java @@ -0,0 +1,68 @@ +package com.iailab.module.data.http.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; + +@Data +@TableName("T_XST_TAG") +public class XSTTagEntity implements Serializable { + private static final long serialVersionUID = 1L; + + /** + * 主键 + */ + @Schema(description = "主键") + @TableId(value = "id", type = IdType.INPUT) + private String id; + + /** + * 设备编码 + */ + private String deviceCode; + + /** + * 设备名称 + */ + private String deviceName; + + /** + * 测点名称 + */ + private String pointName; + + /** + * 测点编码 + */ + private String pointCode; + + /** + * 单位 + */ + private String unit; + + /** + * 传感器标识符 + */ + private String identifier; + + /** + * Tag编号 + */ + private String tagno; + + /** + * 创建时间 + */ + private Date createTime; + + /** + * 更新时间 + */ + private Date updateTime; +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/http/service/HttpApiService.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/http/service/HttpApiService.java new file mode 100644 index 0000000..e0abeda --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/http/service/HttpApiService.java @@ -0,0 +1,21 @@ +package com.iailab.module.data.http.service; + +import com.iailab.framework.common.page.PageData; +import com.iailab.framework.common.service.BaseService; +import com.iailab.module.data.http.entity.HttpApiEntity; +import com.iailab.module.data.http.entity.HttpApiEntity; + +import java.util.List; +import java.util.Map; + +public interface HttpApiService extends BaseService<HttpApiEntity> { + HttpApiEntity selectXstHttpTagApi(); + + HttpApiEntity get(String id); + + HttpApiEntity getByCode(String code); + + PageData<HttpApiEntity> page(Map<String, Object> params); + + List<HttpApiEntity> list(); +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/http/service/HttpTagService.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/http/service/HttpTagService.java new file mode 100644 index 0000000..0769aff --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/http/service/HttpTagService.java @@ -0,0 +1,32 @@ +package com.iailab.module.data.http.service; + + +import com.iailab.module.data.common.utils.PageUtils; +import com.iailab.framework.common.service.BaseService; +import com.iailab.module.data.http.dto.HttpTagDTO; +import com.iailab.module.data.http.dto.TagCommonCurrentDto; +import com.iailab.module.data.http.entity.HttpTagEntity; + +import java.math.BigDecimal; +import java.util.List; +import java.util.Map; + +/** + * @author Houzhongjian + * @Description + * @createTime 2024年04月10日 17:35:00 + */ +public interface HttpTagService extends BaseService<HttpTagEntity> { + + PageUtils queryPage(Map<String, Object> params); + + List<HttpTagEntity> selectList(Map<String, Object> params); + + Map<String, BigDecimal> getTagsValues(String httpApiCode, List<TagCommonCurrentDto> tags); + + List<HttpTagEntity> getByCode(String code); + + List<String> getByTagType(String deviceId); + + List<HttpTagDTO> list(Map<String, Object> params); +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/http/service/HttpTokenService.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/http/service/HttpTokenService.java new file mode 100644 index 0000000..a238c88 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/http/service/HttpTokenService.java @@ -0,0 +1,21 @@ +package com.iailab.module.data.http.service; + + +import com.iailab.framework.common.page.PageData; +import com.iailab.framework.common.service.BaseService; +import com.iailab.module.data.http.entity.HttpTokenEntity; +import com.iailab.module.data.http.entity.HttpTokenEntity; + +import java.util.Map; + +public interface HttpTokenService extends BaseService<HttpTokenEntity> { + + PageData<HttpTokenEntity> page(Map<String, Object> params); + + HttpTokenEntity getByApiId(String apiId); + + void updateToken (String clientId); + + String queryToken (String clientId); + +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/http/service/impl/FxjyTagServiceImpl.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/http/service/impl/FxjyTagServiceImpl.java new file mode 100644 index 0000000..e11f6a7 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/http/service/impl/FxjyTagServiceImpl.java @@ -0,0 +1,238 @@ +//package com.iailab.module.http.service.impl; +// +//import com.alibaba.fastjson.JSONObject; +//import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +//import com.baomidou.mybatisplus.core.metadata.IPage; +//import com.baomidou.mybatisplus.core.toolkit.StringUtils; +//import com.iailab.framework.common.service.impl.BaseServiceImpl; +//import com.iailab.common.utils.HttpsRequest; +//import com.iailab.common.utils.PageUtils; +//import com.iailab.common.utils.Query; +//import com.iailab.module.http.dao.FxjyTagDao; +//import com.iailab.module.http.entity.FxjyTagEntity; +//import com.iailab.module.http.service.HttpApiService; +//import lombok.extern.slf4j.Slf4j; +//import javax.annotation.Resource; +//import org.springframework.stereotype.Service; +// +//import java.lang.reflect.Field; +//import java.math.BigDecimal; +//import java.util.HashMap; +//import java.util.List; +//import java.util.Map; +// +//@Slf4j +//@Service +//public class FxjyTagServiceImpl extends BaseServiceImpl<FxjyTagDao, FxjyTagEntity> implements FxjyTagService { +// +// @Resource +// private HttpsRequest httpsRequest; +// +// @Resource +// private HttpApiService httpApiService; +// +// private final String API_CODE = "fxjyHttpTag"; +// +// /** +// * 分页查询tag +// * +// * @param params +// */ +// @Override +// public PageUtils queryPage(Map<String, Object> params) { +// String tagType = (String) params.get("tagType"); +// String tagCode = (String) params.get("tagCode"); +// String tagName = (String) params.get("tagName"); +// +// IPage<FxjyTagEntity> page = baseDao.selectPage( +// new Query<FxjyTagEntity>().getPage(params), +// new QueryWrapper<FxjyTagEntity>() +// .like(StringUtils.isNotBlank(tagType), "tag_type", tagType) +// .like(StringUtils.isNotBlank(tagCode), "tag_code", tagCode) +// .like(StringUtils.isNotBlank(tagName), "tag_name", tagName) +// .orderByDesc("create_time") +// ); +// return new PageUtils(page); +// } +// +// @Override +// public Map<String, BigDecimal> getTagsValues(List<FxjyCurrentDto> tags){ +// Map<String, BigDecimal> result = new HashMap<>(tags.size()); +// Map<String, String> params = new HashMap<>(2); +// String url = httpApiService.getByCode(API_CODE).getUrl(); +//// String responseStr = httpsRequest.doGet(url, params,"utf-8", ""); +// String responseStr = "{\n" + +// "\"flag\":true,\n" + +// "\"data\":{\n" + +// "\"ST\":\"2024-01-1616:42:36\",\n" + +// "\"JYJ1\":{\n" + +// "\"CURRENT_SPEED\":199.17,\n" + +// "\"DL\":4.5,\n" + +// "\"CW\":false,\n" + +// "\"EN\":true,\n" + +// "\"FAULT\":false,\n" + +// "\"GL\":false,\n" + +// "\"GY\":false,\n" + +// "\"QY\":false,\n" + +// "\"RUNING\":true,\n" + +// "\"SPEED_SET\":200.0\n" + +// "},\n" + +// "\"JYJ2\":{\n" + +// "\"CURRENT_SPEED\":0.0,\n" + +// "\"DL\":1.8,\n" + +// "\"CW\":false,\n" + +// "\"EN\":true,\n" + +// "\"FAULT\":false,\n" + +// "\"GL\":false,\n" + +// "\"GY\":false,\n" + +// "\"QY\":false,\n" + +// "\"RUNING\":false,\n" + +// "\"SPEED_SET\":50.0\n" + +// "},\n" + +// "\"JYJ3\":{\n" + +// "\"CURRENT_SPEED\":199.17,\n" + +// "\"DL\":4.5,\n" + +// "\"CW\":false,\n" + +// "\"EN\":true,\n" + +// "\"FAULT\":false,\n" + +// "\"GL\":false,\n" + +// "\"GY\":false,\n" + +// "\"QY\":false,\n" + +// "\"RUNING\":true,\n" + +// "\"SPEED_SET\":200.0\n" + +// "},\n" + +// "\"JYJ4\":{\n" + +// "\"CURRENT_SPEED\":0.0,\n" + +// "\"DL\":1.8,\n" + +// "\"CW\":false,\n" + +// "\"EN\":true,\n" + +// "\"FAULT\":false,\n" + +// "\"GL\":false,\n" + +// "\"GY\":false,\n" + +// "\"QY\":false,\n" + +// "\"RUNING\":false,\n" + +// "\"SPEED_SET\":50.0\n" + +// "},\n" + +// "\"FXJY\":{\n" + +// "\"YW401\":5.49,\n" + +// "\"YW407\":66.83,\n" + +// "\"YW408\":19.92,\n" + +// "\"PumpRun_402A\":true,\n" + +// "\"PumpRun_402B\":true,\n" + +// "\"YCLQ_Run_403A\":true,\n" + +// "\"YCLQ_Run_403B\":true,\n" + +// "\"Valve1_GDW\":false,\n" + +// "\"Valve1_KDW\":true,\n" + +// "\"Valve1_ZZK\":false,\n" + +// "\"Valve1_ZZG\":false,\n" + +// "\"Valve2_GDW\":true,\n" + +// "\"Valve2_KDW\":false,\n" + +// "\"Valve2_ZZK\":false,\n" + +// "\"Valve2_ZZG\":false,\n" + +// "\"Valve3_GDW\":false,\n" + +// "\"Valve3_KDW\":true,\n" + +// "\"Valve3_ZZK\":false,\n" + +// "\"Valve3_ZZG\":false,\n" + +// "\"Valve4_GDW\":true,\n" + +// "\"Valve4_KDW\":false,\n" + +// " \"Valve4_ZZK\": false,\n" + +// "\"Valve4_ZZG\": false,\n" + +// "\"ZLLLJ1_403A\": 19.35,\n" + +// "\"ZLLLJ2_403A\": 2.73,\n" + +// "\"ZLLLJ1_403B\": 15.99,\n" + +// "\"ZLLLJ2_403B\": 5.19,\n" + +// "\"FXRL_LLJ_403A1\": 983.75,\n" + +// "\"FXRL_LLJ_403A2\": 583.91,\n" + +// "\"FXPMHDJC1\": 5.11,\n" + +// "\"FXPMHDJC2\": 1.95,\n" + +// "\"LD3_LD1\": 0.0,\n" + +// "\"LD3_LD2\": 0.0,\n" + +// "\"LD3_ND\": 0.0\n" + +// "},\n" + +// "\"YLXT\": {\n" + +// "\"YW405A\": 21.98,\n" + +// "\"YW405B\": 17.04,\n" + +// "\"YW601\": 33.79,\n" + +// "\"VF861_Run\": true,\n" + +// "\"VF862_Run\": true,\n" + +// "\"VF863_Run\": true,\n" + +// "\"KM414A_Run\": false,\n" + +// "\"KM414B_Run\": false,\n" + +// "\"KM418A_Run\": false,\n" + +// "\"KM418B_Run\": false,\n" + +// "\"KM602A_Run\": false,\n" + +// "\"KM602B_Run\": false,\n" + +// "\"KM602C_Run\": true,\n" + +// "\"KM416A_Run\": false,\n" + +// "\"KM416B_Run\": false,\n" + +// "\"KM420A_Run\": false,\n" + +// "\"KM420B_Run\": false,\n" + +// "\"KM606A_Run\": false,\n" + +// "\"KM606B_Run\": false,\n" + +// "\"KM606C_Run\": false\n" + +// "},\n" + +// "\"LJL\": {\n" + +// "\"Timestamp\": \"2024-01-16\",\n" + +// "\"JYJ1\": 120.53,\n" + +// "\"JYJ2\": 0.0,\n" + +// "\"JYJ3\": 117.66,\n" + +// "\"JYJ4\": 0.0\n" + +// "},\n" + +// "\"YCZ\": {\n" + +// "\"JYJ1\": 249.6,\n" + +// "\"JYJ2\": 0.0,\n" + +// "\"JYJ3\": 248.23,\n" + +// "\"JYJ4\": 0.0\n" + +// "},\n" + +// "\"YLCS\": {\n" + +// "\"YL415A_GLCSXS\": 7,\n" + +// "\"YL415B_GLCSXS\": 8,\n" + +// "\"YL419A_GLCSXS\": 7,\n" + +// "\"YL419B_GLCSXS\": 8,\n" + +// "\"YL603A_GLCSXS\": 1,\n" + +// "\"YL603B_GLCSXS\": 0,\n" + +// "\"YL603C_GLCSXS\": 3\n" + +// "},\n" + +// "\"TEMP\": {\n" + +// "\"FXRLNDJ403A\": 67.12\n" + +// "}\n" + +// "},\n" + +// "\"msg\": \"查询成功\"\n" + +// "}"; +// if (StringUtils.isNotBlank(responseStr)) { +// FxjyJsonDto fxjyJsonDto = parseDto(responseStr); +// fxjyJsonDto.getData().getLJL().getJYJ1(); +// tags.stream().forEach( +// item->{ +// Class<?> fxjyClass= fxjyJsonDto.getData().getClass(); +// try { +// Class<?> fxjyTypeClass = fxjyClass.getDeclaredField(item.getTagType()).getClass(); +// Field field = fxjyTypeClass.getDeclaredField(item.getTagCode()); +// field.setAccessible(true); +// BigDecimal value = new BigDecimal((String)field.get(fxjyJsonDto.getData())); +// result.put(item.getTagType()+"_"+item.getTagCode(), value); +// }catch (NoSuchFieldException e){ +// log.info("没有找到tag"+item.getTagType()+";"+item.getTagCode()); +// }catch(IllegalAccessException e){ +// log.info("没有反射权限"); +// } +// } +// ); +// } +// return result; +// } +// +// @Override +// public List<FxjyTagEntity> selectList() { +// return baseDao.selectList(new QueryWrapper<FxjyTagEntity>().orderByDesc("create_time")); +// } +// +// private FxjyJsonDto parseDto(String responseStr) { +// FxjyJsonDto result = new FxjyJsonDto(); +// if (!org.apache.commons.lang.StringUtils.isEmpty(responseStr)) { +// JSONObject items = JSONObject.parseObject(responseStr); +// result = items.toJavaObject(FxjyJsonDto.class); +// } +// return result; +// } +//} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/http/service/impl/HttpApiServiceImpl.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/http/service/impl/HttpApiServiceImpl.java new file mode 100644 index 0000000..5daf382 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/http/service/impl/HttpApiServiceImpl.java @@ -0,0 +1,57 @@ +package com.iailab.module.data.http.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.data.http.entity.HttpApiEntity; +import com.iailab.module.data.http.entity.HttpApiEntity; +import com.iailab.module.data.http.dao.HttpApiDao; +import com.iailab.module.data.http.service.HttpApiService; +import org.apache.commons.lang3.StringUtils; +import org.springframework.stereotype.Service; + +import java.util.List; +import java.util.Map; + +@Service +public class HttpApiServiceImpl extends BaseServiceImpl<HttpApiDao, HttpApiEntity> implements HttpApiService { + @Override + public HttpApiEntity selectXstHttpTagApi() { + return baseDao.selectOne(new QueryWrapper<HttpApiEntity>().eq("code","xstHttpTag")); + } + + @Override + public HttpApiEntity get(String id) { + return baseDao.selectById(id); + } + + + @Override + public HttpApiEntity getByCode(String code) { + return baseDao.selectOne(new QueryWrapper<HttpApiEntity>().eq("code", code)); + } + + @Override + public PageData<HttpApiEntity> page(Map<String, Object> params) { + IPage<HttpApiEntity> page = baseDao.selectPage( + getPage(params, "create_time", false), + getWrapper(params) + ); + + return getPageData(page, HttpApiEntity.class); + } + + @Override + public List<HttpApiEntity> list() { + List<HttpApiEntity> page = baseDao.selectList(new QueryWrapper<>()); + return page; + } + + private QueryWrapper<HttpApiEntity> getWrapper(Map<String, Object> params){ + String name = (String)params.get("name"); + QueryWrapper<HttpApiEntity> wrapper = new QueryWrapper<>(); + wrapper.eq(StringUtils.isNotBlank(name), "name", name); + return wrapper; + } +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/http/service/impl/HttpTagCollector.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/http/service/impl/HttpTagCollector.java new file mode 100644 index 0000000..1a22110 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/http/service/impl/HttpTagCollector.java @@ -0,0 +1,44 @@ +package com.iailab.module.data.http.service.impl; + +import com.iailab.module.data.http.dto.TagCommonCurrentDto; +import com.iailab.module.data.http.service.HttpTagService; +import javax.annotation.Resource; +import org.springframework.stereotype.Component; +import org.springframework.util.CollectionUtils; + +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +@Component +public class HttpTagCollector { + + @Resource + private HttpTagService httpTagService; + + + public Map<String, Object> collect(String httpApiCode, List<String> tagIds) { + Map<String, Object> result = new HashMap<>(); + if (CollectionUtils.isEmpty(tagIds)) { + return null; + } + List<TagCommonCurrentDto> tags = new ArrayList<>(); + for (String tagId : tagIds) { + String[] parts = tagId.split("_"); + TagCommonCurrentDto dto=new TagCommonCurrentDto(); + dto.setTagType(parts[0]); + dto.setTagCode(tagId); + tags.add(dto); + } + Map<String, BigDecimal> tagsValues = httpTagService.getTagsValues(httpApiCode, tags); + if (!CollectionUtils.isEmpty(tagsValues)) { + tagsValues.forEach((k, v) -> { + result.put(k, v); + }); + } + return result; + } + +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/http/service/impl/HttpTagServiceImpl.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/http/service/impl/HttpTagServiceImpl.java new file mode 100644 index 0000000..f984e1e --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/http/service/impl/HttpTagServiceImpl.java @@ -0,0 +1,304 @@ +package com.iailab.module.data.http.service.impl; + +import com.alibaba.fastjson.JSONObject; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.core.toolkit.StringUtils; +import com.iailab.module.data.common.enums.CommonConstant; +import com.iailab.framework.common.service.impl.BaseServiceImpl; +import com.iailab.module.data.common.utils.HttpsRequest; +import com.iailab.module.data.common.utils.PageUtils; +import com.iailab.module.data.common.utils.Query; +import com.iailab.module.data.http.dao.HttpTagDao; +import com.iailab.module.data.http.dto.*; +import com.iailab.module.data.http.entity.HttpApiEntity; +import com.iailab.module.data.http.entity.HttpTagEntity; +import com.iailab.module.data.http.service.HttpApiService; +import com.iailab.module.data.http.service.HttpTagService; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.ObjectUtils; +import javax.annotation.Resource; +import org.springframework.stereotype.Service; + +import java.lang.reflect.Field; +import java.math.BigDecimal; +import java.util.*; + +/** + * @author Houzhongjian + * @Description + * @createTime 2024年04月10日 17:35:00 + */ +@Slf4j +@Service +public class HttpTagServiceImpl extends BaseServiceImpl<HttpTagDao, HttpTagEntity> implements HttpTagService { + + @Resource + private HttpsRequest httpsRequest; + + @Resource + private HttpApiService httpApiService; + + + /** + * 分页查询tag + * + * @param params + */ + @Override + public PageUtils queryPage(Map<String, Object> params) { + String httpApiCode = (String) params.get("httpApiCode"); + String tagType = (String) params.get("tagType"); + String tagCode = (String) params.get("tagCode"); + String tagName = (String) params.get("tagName"); + + IPage<HttpTagEntity> page = baseDao.selectPage( + new Query<HttpTagEntity>().getPage(params), + new QueryWrapper<HttpTagEntity>() + .like(StringUtils.isNotBlank(httpApiCode), "http_api_code", httpApiCode) + .like(StringUtils.isNotBlank(tagType), "tag_type", tagType) + .like(StringUtils.isNotBlank(tagCode), "tag_code", tagCode) + .like(StringUtils.isNotBlank(tagName), "tag_name", tagName) + .orderByDesc("create_time") + ); + return new PageUtils(page); + } + + @Override + public List<HttpTagEntity> selectList(Map<String, Object> params) { + String httpId = (String) params.get("httpId"); + HttpApiEntity httpApiEntity = httpApiService.selectById(httpId); + return baseDao.selectList(new QueryWrapper<HttpTagEntity>() + .eq("http_api_code", httpApiEntity.getCode()) + .orderByDesc("create_time")); + } + + @Override + public List<HttpTagEntity> getByCode(String code) { + return baseDao.selectList(new QueryWrapper<HttpTagEntity>() + .eq("http_api_code", code) + .orderByDesc("create_time")); + } + + @Override + public List<String> getByTagType(String deviceId) { + QueryWrapper<HttpTagEntity> queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("tag_type", deviceId); + List<HttpTagEntity> entityList = baseDao.selectList(queryWrapper); + List<String> list = new ArrayList<>(); + if(ObjectUtils.isNotEmpty(entityList)) { + entityList.stream().forEach(entity -> { + String tagCode = entity.getTagCode(); + list.add(tagCode); + }); + } + return list; + } + + @Override + public List<HttpTagDTO> list(Map<String, Object> params) { + List<HttpTagDTO> list = baseDao.getList(params); + return list; + } + + @Override + public Map<String, BigDecimal> getTagsValues(String httpApiCode, List<TagCommonCurrentDto> tags) { + Map<String, BigDecimal> stringBigDecimalMap = new HashMap<>(); + if (CommonConstant.YEAR_PEI_HTTP_TAG.equals(httpApiCode)) { + stringBigDecimalMap = yearPeiTagsValues(tags); + } else if(CommonConstant.CURRENT_PERFORMANCE_HTTP_TAG.equals(httpApiCode)) { + stringBigDecimalMap = currentPerformanceTagsValues(tags); + } else if(CommonConstant.CURRENT_SALE_HTTP_TAG.equals(httpApiCode)) { + stringBigDecimalMap = currentSaleTagsValues(tags); + } else if(CommonConstant.PRD_TIME_DIST_HTTP_TAG.equals(httpApiCode)) { + stringBigDecimalMap = prdTimeDistTagsValues(tags); + } + return stringBigDecimalMap; + } + + private Map<String, BigDecimal> yearPeiTagsValues(List<TagCommonCurrentDto> tags) { + Map<String, BigDecimal> result = new HashMap<>(tags.size()); + Calendar calendar = Calendar.getInstance(); + int currentMonth = calendar.get(Calendar.MONTH) + 1; +// String url = httpApiService.getByCode(API_CODE).getUrl(); +// String responseStr = httpsRequest.doGet(url, params,"utf-8", ""); + String url = "http://192.168.55.121/Sunny/Action/BdApi/Invoke?code=Prd.YearPEI"; + String responseStr = "{\"sta\":true,\"msg\":null,\"res\":{\"yearData\":{\"year\":2024,\"xxPlan\":21850000.00,\"xxPerformance\":6794492.00,\"zqPlan\":12500000.00,\"zqPerformance\":3149110.41},\"monthData\":[{\"month\":1,\"xxPlan\":1400000.00,\"xxPerformance\":2022725.00,\"zqPlan\":800000.00,\"zqPerformance\":955066.76},{\"month\":2,\"xxPlan\":1400000.00,\"xxPerformance\":1829671.00,\"zqPlan\":800000.00,\"zqPerformance\":809494.02},{\"month\":3,\"xxPlan\":1700000.00,\"xxPerformance\":2225923.00,\"zqPlan\":1000000.00,\"zqPerformance\":971406.22},{\"month\":4,\"xxPlan\":1620000.00,\"xxPerformance\":716173.00,\"zqPlan\":1000000.00,\"zqPerformance\":345324.75},{\"month\":5,\"xxPlan\":0.0,\"xxPerformance\":0.00,\"zqPlan\":0.0,\"zqPerformance\":0.0},{\"month\":6,\"xxPlan\":0.0,\"xxPerformance\":0.0,\"zqPlan\":0.0,\"zqPerformance\":0.0},{\"month\":7,\"xxPlan\":0.0,\"xxPerformance\":0.0,\"zqPlan\":0.0,\"zqPerformance\":0.0},{\"month\":8,\"xxPlan\":0.0,\"xxPerformance\":0.0,\"zqPlan\":0.0,\"zqPerformance\":0.0},{\"month\":9,\"xxPlan\":0.0,\"xxPerformance\":0.0,\"zqPlan\":0.0,\"zqPerformance\":0.0},{\"month\":10,\"xxPlan\":0.0,\"xxPerformance\":0.0,\"zqPlan\":0.0,\"zqPerformance\":0.0},{\"month\":11,\"xxPlan\":0.0,\"xxPerformance\":0.0,\"zqPlan\":0.0,\"zqPerformance\":0.0},{\"month\":12,\"xxPlan\":0.0,\"xxPerformance\":0.0,\"zqPlan\":0.0,\"zqPerformance\":0.0}]}}"; + if (StringUtils.isNotBlank(responseStr)) { + TagYearPeiJsonDto yearPeiJsonDto = parseYearPeiDto(responseStr); + tags.stream().forEach( + item -> { + String tagType = item.getTagType(); + String tagCode = item.getTagCode().split(CommonConstant.UNDERLINE)[1]; + TagYearPeiJsonDto.DATA res = yearPeiJsonDto.getRes(); + TagYearPeiJsonDto.DATA.YEAR yearData = res.getYearData(); + List<TagYearPeiJsonDto.DATA.MONTH> monthDataList = res.getMonthData(); + TagYearPeiJsonDto.DATA.MONTH month = monthDataList.get(currentMonth - 1); + Class<?> yearPeiClass = res.getClass(); + String name = yearPeiClass.getName(); + try { + BigDecimal value; + Class<?> yearPeiTypeClass1 = Class.forName(name + CommonConstant.DOLLAR + tagType.toUpperCase()); + Field field = yearPeiTypeClass1.getDeclaredField(tagCode); + field.setAccessible(true); + if(CommonConstant.YEAR.equals(tagType)){ + value = new BigDecimal((String) field.get(yearData)); + result.put(item.getTagCode(), value); + } else if(CommonConstant.MONTH.equals(tagType)){ + value = new BigDecimal((String) field.get(month)); + result.put(item.getTagCode(), value); + } + } catch (NoSuchFieldException e) { + log.info("没有找到tag" + item.getTagType() + ";" + item.getTagCode()); + } catch (IllegalAccessException e) { + log.info("没有反射权限"); + } catch (ClassNotFoundException e) { + throw new RuntimeException(e); + } + } + ); + } + return result; + } + + private Map<String, BigDecimal> currentPerformanceTagsValues(List<TagCommonCurrentDto> tags) { + Map<String, BigDecimal> result = new HashMap<>(tags.size()); + Map<String, String> params = new HashMap<>(2); +// String url = httpApiService.getByCode(API_CODE).getUrl(); +// String responseStr = httpsRequest.doGet(url, params,"utf-8", ""); + String responseStr = "{\"sta\":true,\"msg\":null,\"res\":{\"today\":{\"xxPerformance\":30866.00,\"zqPerformance\":0.0},\"yesterday\":{\"xxPerformance\":65748.00,\"zqPerformance\":36263.20},\"currentMonth\":{\"xxPerformance\":716173.00,\"zqPerformance\":345324.75},\"currentYear\":{\"xxPerformance\":6794492.00,\"zqPerformance\":3149110.41}}}"; + if (StringUtils.isNotBlank(responseStr)) { + TagCurrentPerformanceJsonDto currentPerformanceJsonDto = parseCurrentPerformanceDto(responseStr); + tags.stream().forEach( + item -> { + String tagType = item.getTagType(); + String tagCode = item.getTagCode().split(CommonConstant.UNDERLINE)[1]; + Class<?> currentPerformanceClass = currentPerformanceJsonDto.getRes().getClass(); + String name = currentPerformanceClass.getName(); + try { + Field declaredField = currentPerformanceClass.getDeclaredField(tagType); + Class<?> typeClass = Class.forName(name + CommonConstant.DOLLAR + tagType.toUpperCase()); + Field field = typeClass.getDeclaredField(tagCode); + field.setAccessible(true); + declaredField.setAccessible(true); + BigDecimal value = new BigDecimal((String) field.get(declaredField.get(currentPerformanceJsonDto.getRes()))); + result.put(item.getTagCode(), value); + } catch (NoSuchFieldException e) { + log.info("没有找到tag" + item.getTagType() + ";" + item.getTagCode()); + } catch (IllegalAccessException e) { + log.info("没有反射权限"); + } catch (ClassNotFoundException e) { + throw new RuntimeException(e); + } + } + ); + } + return result; + } + + private Map<String, BigDecimal> currentSaleTagsValues(List<TagCommonCurrentDto> tags) { + Map<String, BigDecimal> result = new HashMap<>(tags.size()); + Map<String, String> params = new HashMap<>(2); +// String url = httpApiService.getByCode(API_CODE).getUrl(); +// String responseStr = httpsRequest.doGet(url, params,"utf-8", ""); + String responseStr = "{\"sta\":true,\"msg\":null,\"res\":{\"today\":{\"groundsales\":0.0,\"medblock\":0.0,\"nubmeasure\":0.0,\"gangue\":0.0,\"reshipped\":0.0,\"trainTon\":0.0,\"trainCount\":0},\"yesterday\":{\"groundsales\":15696.00,\"medblock\":14757.00,\"nubmeasure\":0.00,\"gangue\":4384.00,\"reshipped\":2447.00,\"trainTon\":36263.20,\"trainCount\":10},\"currentMonth\":{\"groundsales\":0.0,\"medblock\":0.0,\"nubmeasure\":0.0,\"gangue\":0.0,\"reshipped\":0.0,\"trainTon\":0.0,\"trainCount\":0},\"currentYear\":{\"groundsales\":521638.00,\"medblock\":266372.00,\"nubmeasure\":0.00,\"gangue\":143475.00,\"reshipped\":139695.00,\"trainTon\":0.0,\"trainCount\":0}}}"; + if (StringUtils.isNotBlank(responseStr)) { + TagCurrentSaleJsonDto currentPerformanceJsonDto = parseCurrentSaleDto(responseStr); + tags.stream().forEach( + item -> { + String tagType = item.getTagType(); + String tagCode = item.getTagCode().split(CommonConstant.UNDERLINE)[1]; + Class<?> currentSaleClass = currentPerformanceJsonDto.getRes().getClass(); + String name = currentSaleClass.getName(); + try { + Field declaredField = currentSaleClass.getDeclaredField(tagType); + Class<?> typeClass = Class.forName(name + CommonConstant.DOLLAR + tagType.toUpperCase()); + Field field = typeClass.getDeclaredField(tagCode); + field.setAccessible(true); + declaredField.setAccessible(true); + BigDecimal value = new BigDecimal((String) field.get(declaredField.get(currentPerformanceJsonDto.getRes()))); + result.put(item.getTagCode(), value); + } catch (NoSuchFieldException e) { + log.info("没有找到tag" + item.getTagType() + ";" + item.getTagCode()); + } catch (IllegalAccessException e) { + log.info("没有反射权限"); + } catch (ClassNotFoundException e) { + throw new RuntimeException(e); + } + } + ); + } + return result; + } + + private Map<String, BigDecimal> prdTimeDistTagsValues(List<TagCommonCurrentDto> tags) { + Map<String, BigDecimal> result = new HashMap<>(tags.size()); + Map<String, String> params = new HashMap<>(2); +// String url = httpApiService.getByCode(API_CODE).getUrl(); +// String responseStr = httpsRequest.doGet(url, params,"utf-8", ""); + String responseStr = "{\"sta\":true,\"msg\":null,\"res\":{\"xx\":{\"runMinutes\":1120.0,\"overhaulMinutes\":305.0,\"affectMinutes\":15.0},\"zq\":{\"runMinutes\":645.0,\"overhaulMinutes\":223.0,\"affectMinutes\":572.0}}}"; + if (StringUtils.isNotBlank(responseStr)) { + TagPrdTimeDistJsonDto prdTimeDistJsonDto = parsePrdTimeDistDto(responseStr); + tags.stream().forEach( + item -> { + String tagType = item.getTagType(); + String tagCode = item.getTagCode().split(CommonConstant.UNDERLINE)[1]; + Class<?> prdTimeDistClass = prdTimeDistJsonDto.getRes().getClass(); + String name = prdTimeDistClass.getName(); + try { + Field declaredField = prdTimeDistClass.getDeclaredField(tagType); + Class<?> typeClass = Class.forName(name + CommonConstant.DOLLAR + tagType.toUpperCase()); + Field field = typeClass.getDeclaredField(tagCode); + field.setAccessible(true); + declaredField.setAccessible(true); + BigDecimal value = new BigDecimal((String) field.get(declaredField.get(prdTimeDistJsonDto.getRes()))); + result.put(item.getTagCode(), value); + } catch (NoSuchFieldException e) { + log.info("没有找到tag" + item.getTagType() + ";" + item.getTagCode()); + } catch (IllegalAccessException e) { + log.info("没有反射权限"); + } catch (ClassNotFoundException e) { + throw new RuntimeException(e); + } + } + ); + } + return result; + } + + private TagYearPeiJsonDto parseYearPeiDto(String responseStr) { + TagYearPeiJsonDto result = new TagYearPeiJsonDto(); + if (!StringUtils.isEmpty(responseStr)) { + JSONObject items = JSONObject.parseObject(responseStr); + result = items.toJavaObject(TagYearPeiJsonDto.class); + } + return result; + } + + private TagCurrentPerformanceJsonDto parseCurrentPerformanceDto(String responseStr) { + TagCurrentPerformanceJsonDto result = new TagCurrentPerformanceJsonDto(); + if (!StringUtils.isEmpty(responseStr)) { + JSONObject items = JSONObject.parseObject(responseStr); + result = items.toJavaObject(TagCurrentPerformanceJsonDto.class); + } + return result; + } + + private TagCurrentSaleJsonDto parseCurrentSaleDto(String responseStr) { + TagCurrentSaleJsonDto result = new TagCurrentSaleJsonDto(); + if (!StringUtils.isEmpty(responseStr)) { + JSONObject items = JSONObject.parseObject(responseStr); + result = items.toJavaObject(TagCurrentSaleJsonDto.class); + } + return result; + } + + private TagPrdTimeDistJsonDto parsePrdTimeDistDto(String responseStr) { + TagPrdTimeDistJsonDto result = new TagPrdTimeDistJsonDto(); + if (!StringUtils.isEmpty(responseStr)) { + JSONObject items = JSONObject.parseObject(responseStr); + result = items.toJavaObject(TagPrdTimeDistJsonDto.class); + } + return result; + } +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/http/service/impl/HttpTokenServiceImpl.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/http/service/impl/HttpTokenServiceImpl.java new file mode 100644 index 0000000..497b49f --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/http/service/impl/HttpTokenServiceImpl.java @@ -0,0 +1,79 @@ +package com.iailab.module.data.http.service.impl; + +import com.alibaba.fastjson.JSONObject; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.iailab.module.data.common.utils.HttpsRequest; +import com.iailab.framework.common.page.PageData; +import com.iailab.framework.common.service.impl.BaseServiceImpl; +import com.iailab.module.data.http.dao.HttpTokenDao; +import com.iailab.module.data.http.entity.HttpTokenEntity; +import com.iailab.module.data.http.service.HttpTokenService; +import org.apache.commons.lang3.StringUtils; +import javax.annotation.Resource; +import org.springframework.stereotype.Service; + +import java.util.Date; +import java.util.HashMap; +import java.util.Map; + +@Service +public class HttpTokenServiceImpl extends BaseServiceImpl<HttpTokenDao, HttpTokenEntity> implements HttpTokenService { + + @Resource + private HttpsRequest httpsRequest; + + @Override + public PageData<HttpTokenEntity> page(Map<String, Object> params) { + IPage<HttpTokenEntity> page = baseDao.selectPage( + getPage(params, "client_id", false), + getWrapper(params) + ); + return getPageData(page, HttpTokenEntity.class); + } + + private QueryWrapper<HttpTokenEntity> getWrapper(Map<String, Object> params){ + String clientId = (String)params.get("clientId"); + QueryWrapper<HttpTokenEntity> wrapper = new QueryWrapper<>(); + wrapper.eq(StringUtils.isNotBlank(clientId), "client_id", clientId); + return wrapper; + } + + @Override + public HttpTokenEntity getByApiId(String apiId) { + QueryWrapper<HttpTokenEntity> wrapper = new QueryWrapper<>(); + wrapper.eq(StringUtils.isNotBlank(apiId), "api_id", apiId); + return baseDao.selectOne(wrapper); + } + + + @Override + public void updateToken(String clientId) { + Map<String, String> params = new HashMap<>(1); + params.put("timeout", "30000"); + HttpTokenEntity entity = baseDao.selectOne(new QueryWrapper<HttpTokenEntity>().eq("client_id", clientId)); + Map<String, String> dataJson = new HashMap<>(2); + String url = entity.getLoginUrl(); + String userName = entity.getUsername(); + String password = entity.getPassword(); + String prvsetName = entity.getPrvsetName(); + String projectName = entity.getProjectName(); + String platform = entity.getPlatform(); + dataJson.put("username", userName); + dataJson.put("password", password); + dataJson.put("prvset_name", prvsetName); + dataJson.put("project_name", projectName); + dataJson.put("platform", platform); + //查询token的请求 + String responseStr = httpsRequest.doPostToken(url, params, JSONObject.toJSONString(dataJson), "utf-8"); + //插入token和更新时间 + entity.setToken(responseStr); + entity.setUpdateTime(new Date()); + baseDao.update(entity, new QueryWrapper<HttpTokenEntity>().eq("client_id", clientId)); + } + + @Override + public String queryToken(String clientId) { + return baseDao.selectOne(new QueryWrapper<HttpTokenEntity>().eq("client_id", clientId)).getToken(); + } +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/collection/IndItemCollector.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/collection/IndItemCollector.java new file mode 100644 index 0000000..de80b07 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/collection/IndItemCollector.java @@ -0,0 +1,85 @@ +package com.iailab.module.data.ind.collection; + +import com.iailab.module.data.ind.collection.handler.AtomItemHandle; +import com.iailab.module.data.ind.service.IndItemService; +import com.iailab.module.data.ind.collection.handler.AtomItemHandle; +import com.iailab.module.data.ind.service.IndItemService; +import com.iailab.module.data.ind.collection.handler.AtomItemHandle; +import com.iailab.module.data.ind.collection.handler.CalItemHandle; +import com.iailab.module.data.ind.dto.IndItemDTO; +import com.iailab.module.data.ind.dto.IndItemValueDTO; +import com.iailab.module.data.ind.service.IndItemService; +import com.iailab.module.data.ind.collection.handler.AtomItemHandle; +import com.iailab.module.data.ind.service.IndItemService; +import lombok.extern.slf4j.Slf4j; +import javax.annotation.Resource; +import org.springframework.stereotype.Component; +import org.springframework.util.CollectionUtils; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年05月25日 + */ +@Slf4j +@Component +public class IndItemCollector { + + @Resource + private IndItemService indItemService; + + @Resource + private AtomItemHandle atomItemHandle; + + @Resource + private CalItemHandle calItemHandle; + + + public Map<String, List<IndItemValueDTO>> getValueList(List<String> itemNos) { + Map<String, List<IndItemValueDTO>> result = new HashMap<>(); + if (CollectionUtils.isEmpty(itemNos)) { + return result; + } + try { + List<IndItemDTO> atomList = indItemService.getItemAtom(itemNos); + atomList.forEach(item -> { + result.put(item.getItemNo(), atomItemHandle.getItemSourceValue(item.getItemNo())); + }); + + List<IndItemDTO> calList = indItemService.getItemCal(itemNos); + calList.forEach(item -> { + result.put(item.getItemNo(), calItemHandle.getItemCalValue(item.getItemNo())); + }); + + } catch (Exception ex) { + ex.printStackTrace(); + } + return result; + } + + public Map<String, List<IndItemValueDTO>> getValueListRange(List<String> itemNos, String start, String end) { + Map<String, List<IndItemValueDTO>> result = new HashMap<>(); + if (CollectionUtils.isEmpty(itemNos)) { + return result; + } + try { + List<IndItemDTO> atomList = indItemService.getItemAtom(itemNos); + atomList.forEach(item -> { + result.put(item.getItemNo(), atomItemHandle.getItemSourceValue(item.getItemNo(), start, end)); + }); + + List<IndItemDTO> calList = indItemService.getItemCal(itemNos); + calList.forEach(item -> { + result.put(item.getItemNo(), calItemHandle.getItemCalValue(item.getItemNo(), start, end)); + }); + + } catch (Exception ex) { + ex.printStackTrace(); + } + return result; + } +} \ No newline at end of file diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/collection/handler/AtomItemHandle.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/collection/handler/AtomItemHandle.java new file mode 100644 index 0000000..c875abd --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/collection/handler/AtomItemHandle.java @@ -0,0 +1,91 @@ +package com.iailab.module.data.ind.collection.handler; + +import com.iailab.module.data.ind.service.IndItemService; +import com.iailab.module.data.ind.service.IndItemService; +import com.iailab.module.data.ind.collection.utils.IndSqlUtils; +import com.iailab.module.data.ind.dao.IndItemValueDao; +import com.iailab.module.data.ind.dto.IndItemDTO; +import com.iailab.module.data.ind.dto.IndItemValueDTO; +import com.iailab.module.data.ind.service.IndItemService; +import com.iailab.module.data.ind.service.IndItemService; +import lombok.extern.slf4j.Slf4j; +import javax.annotation.Resource; +import org.springframework.stereotype.Component; + +import javax.annotation.Resource; +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.List; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年05月25日 + */ +@Slf4j +@Component +public class AtomItemHandle { + + @Resource + private IndItemService indItemService; + + @Resource + private IndItemValueDao indItemValueDao; + + + public List<IndItemValueDTO> getItemSourceValue(String itemNo) { + List<IndItemValueDTO> result = new ArrayList<>(); + IndItemDTO indItemDTO = indItemService.getItemAtom(itemNo); + if (indItemDTO == null) { + return result; + } + try { + StringBuilder sqlSelect = new StringBuilder(); + sqlSelect.append(" data_value, data_time "); + indItemDTO.setSqlSelect(sqlSelect.toString()); + indItemDTO.setSqlWhere(IndSqlUtils.getSqlWhere(indItemDTO.getTimeRange(), indItemDTO.getTimeGranularity())); + result = indItemValueDao.getSourceValue(indItemDTO); + } catch (Exception ex) { + ex.printStackTrace(); + } + + result.forEach(item -> { + if (indItemDTO.getCoefficient() != null) { + item.setDataValue(item.getDataValue().multiply(indItemDTO.getCoefficient())); + } + if (indItemDTO.getPrecision() != null) { + item.setDataValue(item.getDataValue().setScale(indItemDTO.getPrecision(), BigDecimal.ROUND_HALF_UP)); + } + item.setItemNo(itemNo); + }); + return result; + } + + public List<IndItemValueDTO> getItemSourceValue(String itemNo, String start, String end) { + List<IndItemValueDTO> result = new ArrayList<>(); + IndItemDTO indItemDTO = indItemService.getItemAtom(itemNo); + if (indItemDTO == null) { + return result; + } + try { + StringBuilder sqlSelect = new StringBuilder(); + sqlSelect.append(" data_value, data_time "); + indItemDTO.setSqlSelect(sqlSelect.toString()); + indItemDTO.setSqlWhere(IndSqlUtils.getSqlWhereByRange(start, end)); + result = indItemValueDao.getSourceValue(indItemDTO); + } catch (Exception ex) { + ex.printStackTrace(); + } + + result.forEach(item -> { + if (indItemDTO.getCoefficient() != null) { + item.setDataValue(item.getDataValue().multiply(indItemDTO.getCoefficient())); + } + if (indItemDTO.getPrecision() != null) { + item.setDataValue(item.getDataValue().setScale(indItemDTO.getPrecision(), BigDecimal.ROUND_HALF_UP)); + } + item.setItemNo(itemNo); + }); + return result; + } +} \ No newline at end of file diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/collection/handler/CalItemHandle.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/collection/handler/CalItemHandle.java new file mode 100644 index 0000000..d23ff0c --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/collection/handler/CalItemHandle.java @@ -0,0 +1,156 @@ +package com.iailab.module.data.ind.collection.handler; + +import com.iailab.module.data.common.enums.CommonConstant; +import com.iailab.module.data.common.enums.JsErrorCode; +import com.iailab.module.data.common.utils.JavaScriptHandler; +import com.iailab.module.data.ind.service.IndItemService; +import com.iailab.module.data.ind.dto.IndItemDTO; +import com.iailab.module.data.ind.dto.IndItemValueDTO; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import javax.annotation.Resource; +import org.springframework.stereotype.Component; + +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年05月25日 + */ +@Slf4j +@Component +public class CalItemHandle { + + @Resource + private JavaScriptHandler javaScriptHandler; + + public static final String regex = "[+\\-\\*\\/\\(\\)\\&\\|\\>\\<]"; + + @Resource + private IndItemService indItemService; + + @Resource + private AtomItemHandle atomItemHandle; + + + public List<IndItemValueDTO> getItemCalValue(String itemNo) { + List<IndItemValueDTO> result = new ArrayList<>(); + IndItemDTO indItemDTO = indItemService.getItemCal(itemNo); + if (indItemDTO == null) { + return result; + } + String expression = indItemDTO.getExpression(); + if (StringUtils.isBlank(expression)) { + return result; + } + String[] arr = expression.split(regex); + int dataLength = 0; + List<List<IndItemValueDTO>> valueMix = new ArrayList<>(); + + for (int i = 0; i < arr.length; i++) { + String s = arr[i]; + if (StringUtils.isBlank(s)) { + continue; + } + valueMix.add(atomItemHandle.getItemSourceValue(s)); + } + dataLength = valueMix.get(0).size(); + + for (int i = 0; i < dataLength; i++) { + Map<String, IndItemValueDTO> dataMap = new HashMap<>(); + for (int j = 0; j < valueMix.size(); j++) { + IndItemValueDTO valueDTO = valueMix.get(j).get(i); + dataMap.put(valueDTO.getItemNo(), valueDTO); + } + IndItemValueDTO itemValue = this.singleCompute(indItemDTO, dataMap); + result.add(itemValue); + } + return result; + } + + public List<IndItemValueDTO> getItemCalValue(String itemNo, String start, String end) { + List<IndItemValueDTO> result = new ArrayList<>(); + IndItemDTO indItemDTO = indItemService.getItemCal(itemNo); + if (indItemDTO == null) { + return result; + } + String expression = indItemDTO.getExpression(); + if (StringUtils.isBlank(expression)) { + return result; + } + String[] arr = expression.split(regex); + int dataLength = 0; + List<List<IndItemValueDTO>> valueMix = new ArrayList<>(); + + for (int i = 0; i < arr.length; i++) { + String s = arr[i]; + if (StringUtils.isBlank(s)) { + continue; + } + valueMix.add(atomItemHandle.getItemSourceValue(s, start, end)); + } + dataLength = valueMix.get(0).size(); + + for (int i = 0; i < dataLength; i++) { + Map<String, IndItemValueDTO> dataMap = new HashMap<>(); + for (int j = 0; j < valueMix.size(); j++) { + IndItemValueDTO valueDTO = valueMix.get(j).get(i); + dataMap.put(valueDTO.getItemNo(), valueDTO); + } + IndItemValueDTO itemValue = this.singleCompute(indItemDTO, dataMap); + result.add(itemValue); + } + return result; + } + + private IndItemValueDTO singleCompute(IndItemDTO dto, Map<String, IndItemValueDTO> dataMap) { + IndItemValueDTO resultDto = new IndItemValueDTO(); + String dataTime = ""; + BigDecimal dataValue = CommonConstant.ZERO_VALUE; + String expression = dto.getExpression(); + String[] arr = expression.split(regex); + + for (int i = 0; i < arr.length; i++) { + String s = arr[i]; + if (StringUtils.isNotBlank(s) && dataMap.containsKey(s)) { + dataTime = dataMap.get(s).getDataTime(); + if (dataMap.get(s) == null || dataMap.get(s).getDataValue() == null) { + resultDto.setDataTime(dataTime); + return resultDto; + } + expression = expression.replace(s, dataMap.get(s).getDataValue().toString()); + } + } + expression = expression.replace("&", "&&"); + expression = expression.replace("|", "||"); + expression = expression.replace("False", "false"); + expression = expression.replace("True", "true"); + log.info("ItemNo=" + dto.getItemNo() + ";expression=" + expression); + String result = javaScriptHandler.eval(expression); + log.info("result=" + result); + if (result == null) { + return null; + } else if (result.contains(JsErrorCode.Infinity.name()) || + result.contains(JsErrorCode.NaN.name())) { + log.info("计算异常,使用默认值"); + } else { + dataValue = new BigDecimal(result); + } + resultDto.setDataTime(dataTime); + + if (dto.getCoefficient() != null) { + dataValue = dataValue.multiply(dto.getCoefficient()); + } + if (dto.getPrecision() != null) { + dataValue = dataValue.setScale(dto.getPrecision(), BigDecimal.ROUND_HALF_UP); + } + resultDto.setDataValue(dataValue); + return resultDto; + } + +} \ No newline at end of file diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/collection/utils/IndSqlUtils.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/collection/utils/IndSqlUtils.java new file mode 100644 index 0000000..16e866e --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/collection/utils/IndSqlUtils.java @@ -0,0 +1,89 @@ +package com.iailab.module.data.ind.collection.utils; + +import com.iailab.framework.common.util.date.DateUtils; +import com.iailab.module.data.ind.common.IndTimeRangeConst; + +import java.util.Calendar; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年05月25日 + */ +public class IndSqlUtils { + + public final static String PATTERN_YEAR = "yyyy"; + + public final static String PATTERN_MON = "yyyy-MM"; + + public final static String PATTERN_DATE = "yyyy-MM-dd"; + + + public static String getSqlWhere(String timeRange, String timeGranularity) { + StringBuilder sqlWhere = new StringBuilder(); + Calendar calendar = Calendar.getInstance(); + calendar.set(Calendar.MILLISECOND, 0); + switch (timeRange) { + case IndTimeRangeConst.LAST_YEAR: + calendar.add(Calendar.YEAR, -1); + sqlWhere.append("ind_t.data_time = '"); + sqlWhere.append(DateUtils.format(calendar.getTime(), PATTERN_YEAR)); + sqlWhere.append("'"); + break; + case IndTimeRangeConst.THIS_YEAR: + sqlWhere.append("ind_t.data_time = '"); + sqlWhere.append(DateUtils.format(calendar.getTime(), PATTERN_YEAR)); + sqlWhere.append("'"); + break; + case IndTimeRangeConst.THIS_YEAR_MONTH: + sqlWhere.append("ind_t.data_time >= '"); + sqlWhere.append(DateUtils.format(calendar.getTime(), PATTERN_YEAR) + "-01' "); + sqlWhere.append("and ind_t.data_time <= '"); + sqlWhere.append(DateUtils.format(calendar.getTime(), PATTERN_YEAR) + "-12' "); + break; + case IndTimeRangeConst.THIS_MONTH: + sqlWhere.append("ind_t.data_time = '"); + sqlWhere.append(DateUtils.format(calendar.getTime(), PATTERN_MON)); + sqlWhere.append("'"); + break; + case IndTimeRangeConst.YESTERDAY: + calendar.add(Calendar.DAY_OF_YEAR, -1); + sqlWhere.append("ind_t.data_time = '"); + sqlWhere.append(DateUtils.format(calendar.getTime(), PATTERN_DATE)); + sqlWhere.append("'"); + break; + case IndTimeRangeConst.TODAY: + sqlWhere.append("ind_t.data_time = '"); + sqlWhere.append(DateUtils.format(calendar.getTime(), PATTERN_DATE)); + sqlWhere.append("'"); + break; + case IndTimeRangeConst.LAST_DAY_7: + calendar.add(Calendar.DAY_OF_YEAR, -7); + sqlWhere.append("ind_t.data_time >= '"); + sqlWhere.append(DateUtils.format(calendar.getTime(), PATTERN_DATE)); + sqlWhere.append("'"); + break; + case IndTimeRangeConst.LAST_DAY_30: + calendar.add(Calendar.DAY_OF_YEAR, -30); + sqlWhere.append("ind_t.data_time >= '"); + sqlWhere.append(DateUtils.format(calendar.getTime(), PATTERN_DATE)); + sqlWhere.append("'"); + break; + default: + break; + + } + return sqlWhere.toString(); + } + + public static String getSqlWhereByRange(String start, String end) { + StringBuilder sqlWhere = new StringBuilder(); + sqlWhere.append("ind_t.data_time >= '"); + sqlWhere.append(start); + sqlWhere.append("' "); + sqlWhere.append("and ind_t.data_time <= '"); + sqlWhere.append(end); + sqlWhere.append("' "); + return sqlWhere.toString(); + } +} \ No newline at end of file diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/common/IndItemTypeEnum.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/common/IndItemTypeEnum.java new file mode 100644 index 0000000..b85c6bb --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/common/IndItemTypeEnum.java @@ -0,0 +1,37 @@ +package com.iailab.module.data.ind.common; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年05月25日 + */ +public enum IndItemTypeEnum { + + ATOM_ITEM("ATOM", "ATOM"), + CAL_ITEM("CAL", "CAL"); + + private String code; + + private String name; + + IndItemTypeEnum(String code, String name){ + this.code = code; + this.name = name; + } + + 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; + } +} \ No newline at end of file diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/common/IndTimeRangeConst.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/common/IndTimeRangeConst.java new file mode 100644 index 0000000..913050b --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/common/IndTimeRangeConst.java @@ -0,0 +1,28 @@ +package com.iailab.module.data.ind.common; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年05月27日 + */ +public interface IndTimeRangeConst { + + String LAST_YEAR = "LAST_YEAR"; + + String THIS_YEAR = "THIS_YEAR"; + + String THIS_YEAR_MONTH = "THIS_YEAR_MONTH"; + + String LAST_MONTH_12 = "LAST_MONTH_12"; + + String THIS_MONTH = "THIS_MONTH"; + + String YESTERDAY = "YESTERDAY"; + + String TODAY = "TODAY"; + + String LAST_DAY_7 = "LAST_DAY_7"; + + String LAST_DAY_30 = "LAST_DAY_30"; + +} \ No newline at end of file diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/common/IndTimeRangeEnum.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/common/IndTimeRangeEnum.java new file mode 100644 index 0000000..f7ae67f --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/common/IndTimeRangeEnum.java @@ -0,0 +1,42 @@ +package com.iailab.module.data.ind.common; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年05月25日 + */ +public enum IndTimeRangeEnum { + + LAST_YEAR("LAST_YEAR", "LAST_YEAR"), + THIS_YEAR("THIS_YEAR", "THIS_YEAR"), + LAST_MONTH_12("LAST_MONTH_12", "LAST_MONTH_12"), + YESTERDAY("YESTERDAY", "YESTERDAY"), + TODAY("TODAY", "TODAY"), + LAST_DAY_7("LAST_DAY_7", "LAST_DAY_7"), + LAST_DAY_30("LAST_DAY_30", "LAST_DAY_30"); + + private String code; + + private String name; + + IndTimeRangeEnum(String code, String name){ + this.code = code; + this.name = name; + } + + 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; + } +} \ No newline at end of file diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/common/IndtimeGranularityEnum.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/common/IndtimeGranularityEnum.java new file mode 100644 index 0000000..f8158b1 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/common/IndtimeGranularityEnum.java @@ -0,0 +1,37 @@ +package com.iailab.module.data.ind.common; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年05月25日 + */ +public enum IndtimeGranularityEnum { + + DAY("DAY", "DAY"), + MONTH("MONTH", "MONTH"); + + private String code; + + private String name; + + IndtimeGranularityEnum(String code, String name){ + this.code = code; + this.name = name; + } + + 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; + } +} \ No newline at end of file diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/controller/admin/IndItemAtomController.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/controller/admin/IndItemAtomController.java new file mode 100644 index 0000000..77b68b8 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/controller/admin/IndItemAtomController.java @@ -0,0 +1,9 @@ +package com.iailab.module.data.ind.controller.admin; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年05月25日 + */ +public class IndItemAtomController { +} \ No newline at end of file diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/controller/admin/IndItemCalController.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/controller/admin/IndItemCalController.java new file mode 100644 index 0000000..2f7bee6 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/controller/admin/IndItemCalController.java @@ -0,0 +1,9 @@ +package com.iailab.module.data.ind.controller.admin; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年05月25日 + */ +public class IndItemCalController { +} \ No newline at end of file diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/controller/admin/IndItemController.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/controller/admin/IndItemController.java new file mode 100644 index 0000000..5cd8f64 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/controller/admin/IndItemController.java @@ -0,0 +1,112 @@ +package com.iailab.module.data.ind.controller.admin; + +import com.iailab.framework.common.annotation.AutoDict; +import com.iailab.framework.common.constant.Constant; +import com.iailab.framework.common.page.PageData; +import com.iailab.framework.common.pojo.CommonResult; +import com.iailab.framework.common.util.validation.ValidationUtils; +import com.iailab.framework.common.validation.group.AddGroup; +import com.iailab.framework.common.validation.group.DefaultGroup; +import com.iailab.module.data.ind.service.IndItemService; +import com.iailab.module.data.ind.dto.IndItemDTO; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.Parameters; +import javax.annotation.Resource; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.web.bind.annotation.*; + +import java.util.List; +import java.util.Map; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年05月25日 + */ +@RestController +@RequestMapping("/ind/item") +public class IndItemController { + + @Resource + private IndItemService indItemService; + + @GetMapping("page") + @Operation(summary = "分页") + @Parameters({ + @Parameter(name = Constant.PAGE, description = "当前页码,从1开始", required = true), + @Parameter(name = Constant.LIMIT, description = "每页显示记录数", required = true), + @Parameter(name = Constant.ORDER_FIELD, description = "排序字段"), + @Parameter(name = Constant.ORDER, description = "排序方式,可选值(asc、desc)") + }) + @AutoDict + public CommonResult<PageData<IndItemDTO>> page(@RequestParam Map<String, Object> params) { + PageData<IndItemDTO> page = indItemService.page(params); + + return new CommonResult<PageData<IndItemDTO>>().setData(page); + } + + @GetMapping("list") + @AutoDict + public CommonResult<List<IndItemDTO>> list(@RequestParam Map<String, Object> params) { + List<IndItemDTO> list = indItemService.getList(params); + return new CommonResult<List<IndItemDTO>>().setData(list); + } + + @GetMapping("{id}") + @Operation(summary = "信息") + public CommonResult<IndItemDTO> get(@PathVariable("id") String id) { + IndItemDTO data = indItemService.get(id); + + return new CommonResult<IndItemDTO>().setData(data); + } + + @PostMapping + @Operation(summary = "保存") + @PreAuthorize("@ss.hasPermission('ind:item:save')") + public CommonResult save(@RequestBody IndItemDTO dto){ + //效验数据 + ValidationUtils.validate(dto, AddGroup.class, DefaultGroup.class); + IndItemDTO data = indItemService.getItemByItemNo(dto.getItemNo()); + if(data != null){ + return new CommonResult().setMsg("指标编码已经存在,请重新定义指标编码!"); + } + indItemService.save(dto); + return new CommonResult(); + } + + @PutMapping + @Operation(summary = "修改") + @PreAuthorize("@ss.hasPermission('ind:item:update')") + public CommonResult update(@RequestBody IndItemDTO dto){ + //效验数据 + ValidationUtils.validate(dto, AddGroup.class, DefaultGroup.class); + indItemService.update(dto); + return new CommonResult(); + } + + @DeleteMapping + @Operation(summary = "删除") + @PreAuthorize("@ss.hasPermission('ind:item:delete')") + public CommonResult delete(@RequestBody String[] ids){ + indItemService.delete(ids); + return new CommonResult(); + } + + @PutMapping("/enable") + @Operation(summary = "启用") + @Transactional + public CommonResult enable(@RequestBody String[] ids) { + indItemService.enableByIds(ids); + return new CommonResult(); + } + + @PutMapping("/disable") + @Operation(summary = "禁用") + @Transactional + public CommonResult disable(@RequestBody String[] ids) { + indItemService.disableByIds(ids); + return new CommonResult(); + } +} \ No newline at end of file diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/controller/package-info.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/controller/package-info.java new file mode 100644 index 0000000..248a217 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/controller/package-info.java @@ -0,0 +1 @@ +package com.iailab.module.data.ind.controller; \ No newline at end of file diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/dao/IndItemAtomDao.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/dao/IndItemAtomDao.java new file mode 100644 index 0000000..5106626 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/dao/IndItemAtomDao.java @@ -0,0 +1,14 @@ +package com.iailab.module.data.ind.dao; + +import com.iailab.framework.common.dao.BaseDao; +import com.iailab.module.data.ind.entity.IndItemAtomEntity; +import org.apache.ibatis.annotations.Mapper; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年05月25日 + */ +@Mapper +public interface IndItemAtomDao extends BaseDao<IndItemAtomEntity> { +} \ No newline at end of file diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/dao/IndItemCalDao.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/dao/IndItemCalDao.java new file mode 100644 index 0000000..844827e --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/dao/IndItemCalDao.java @@ -0,0 +1,14 @@ +package com.iailab.module.data.ind.dao; + +import com.iailab.framework.common.dao.BaseDao; +import com.iailab.module.data.ind.entity.IndItemCalEntity; +import org.apache.ibatis.annotations.Mapper; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年05月25日 + */ +@Mapper +public interface IndItemCalDao extends BaseDao<IndItemCalEntity> { +} \ No newline at end of file diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/dao/IndItemDao.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/dao/IndItemDao.java new file mode 100644 index 0000000..6ea4c17 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/dao/IndItemDao.java @@ -0,0 +1,25 @@ +package com.iailab.module.data.ind.dao; + +import com.iailab.framework.common.dao.BaseDao; +import com.iailab.module.data.ind.entity.IndItemEntity; +import com.iailab.module.data.ind.entity.IndItemEntity; +import com.iailab.module.data.ind.dto.IndItemDTO; +import com.iailab.module.data.ind.entity.IndItemEntity; +import com.iailab.module.data.ind.entity.IndItemEntity; +import org.apache.ibatis.annotations.Mapper; + +import java.util.List; +import java.util.Map; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年05月25日 + */ +@Mapper +public interface IndItemDao extends BaseDao<IndItemEntity> { + + List<IndItemDTO> getItemAtom(Map<String, Object> params); + + List<IndItemDTO> getItemCal(Map<String, Object> params); +} \ No newline at end of file diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/dao/IndItemValueDao.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/dao/IndItemValueDao.java new file mode 100644 index 0000000..70de9bf --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/dao/IndItemValueDao.java @@ -0,0 +1,23 @@ +package com.iailab.module.data.ind.dao; + +import com.iailab.framework.common.dao.BaseDao; +import com.iailab.module.data.ind.entity.IndItemValueEntity; +import com.iailab.module.data.ind.entity.IndItemValueEntity; +import com.iailab.module.data.ind.dto.IndItemDTO; +import com.iailab.module.data.ind.dto.IndItemValueDTO; +import com.iailab.module.data.ind.entity.IndItemValueEntity; +import com.iailab.module.data.ind.entity.IndItemValueEntity; +import org.apache.ibatis.annotations.Mapper; + +import java.util.List; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年05月25日 + */ +@Mapper +public interface IndItemValueDao extends BaseDao<IndItemValueEntity> { + + List<IndItemValueDTO> getSourceValue(IndItemDTO queryDto); +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/dto/IndItemAtomDTO.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/dto/IndItemAtomDTO.java new file mode 100644 index 0000000..34528d9 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/dto/IndItemAtomDTO.java @@ -0,0 +1,26 @@ +package com.iailab.module.data.ind.dto; + +import io.swagger.v3.oas.annotations.tags.Tag; +import lombok.Data; + +import java.io.Serializable; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年05月25日 + */ +@Data +@Tag(name = "原子指标") +public class IndItemAtomDTO implements Serializable { + private static final long serialVersionUID = 1L; + + private String id; + + private String itemId; + + private String dataSource; + + private String querySql; + +} \ No newline at end of file diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/dto/IndItemCalDTO.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/dto/IndItemCalDTO.java new file mode 100644 index 0000000..8954b74 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/dto/IndItemCalDTO.java @@ -0,0 +1,23 @@ +package com.iailab.module.data.ind.dto; + +import io.swagger.v3.oas.annotations.tags.Tag; +import lombok.Data; + +import java.io.Serializable; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年05月25日 + */ +@Data +@Tag(name = "计算指标") +public class IndItemCalDTO implements Serializable { + private static final long serialVersionUID = 1L; + + private String id; + + private String itemId; + + private String expression; +} \ No newline at end of file diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/dto/IndItemDTO.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/dto/IndItemDTO.java new file mode 100644 index 0000000..7645712 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/dto/IndItemDTO.java @@ -0,0 +1,63 @@ +package com.iailab.module.data.ind.dto; + +import io.swagger.v3.oas.annotations.tags.Tag; +import lombok.Data; + +import java.io.Serializable; +import java.math.BigDecimal; +import java.util.Date; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年05月25日 + */ +@Data +@Tag(name = "指标项") +public class IndItemDTO implements Serializable { + private static final long serialVersionUID = 1L; + + private String id; + + private String itemNo; + + private String itemName; + + private String itemType; + + private BigDecimal coefficient; + + private Integer precision; + + private String businessType; + + private String timeRange; + + private String timeGranularity; + + private String remark; + + private Integer isEnable; + + private String creator; + + private Date createTime; + + private String updater; + + private Date updateTime; + + private String dataSource; + + private String querySql; + + private String expression; + + private String sqlSelect; + + private String sqlWhere; + + private IndItemAtomDTO indItemAtom; + + private IndItemCalDTO indItemCal; +} \ No newline at end of file diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/dto/IndItemValueDTO.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/dto/IndItemValueDTO.java new file mode 100644 index 0000000..2cbe1e6 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/dto/IndItemValueDTO.java @@ -0,0 +1,29 @@ +package com.iailab.module.data.ind.dto; + +import io.swagger.v3.oas.annotations.tags.Tag; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.io.Serializable; +import java.math.BigDecimal; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年05月25日 + */ +@Data +@Tag(name = "指标值") +public class IndItemValueDTO implements Serializable { + private static final long serialVersionUID = 1L; + + + @Schema(description = "指标编码") + private String itemNo; + + @Schema(description = "数据时间") + private String dataTime; + + @Schema(description = "数据值") + private BigDecimal dataValue; +} \ No newline at end of file diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/entity/IndItemAtomEntity.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/entity/IndItemAtomEntity.java new file mode 100644 index 0000000..0454616 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/entity/IndItemAtomEntity.java @@ -0,0 +1,26 @@ +package com.iailab.module.data.ind.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; + +@Data +@TableName("t_ind_item_atom") +public class IndItemAtomEntity implements Serializable { + private static final long serialVersionUID = 1L; + + @TableId(type = IdType.ASSIGN_UUID) + private String id; + + private String itemId; + + private String dataSource; + + private String querySql; + + +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/entity/IndItemCalEntity.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/entity/IndItemCalEntity.java new file mode 100644 index 0000000..75380f6 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/entity/IndItemCalEntity.java @@ -0,0 +1,23 @@ +package com.iailab.module.data.ind.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; + +@Data +@TableName("t_ind_item_cal") +public class IndItemCalEntity implements Serializable { + private static final long serialVersionUID = 1L; + + @TableId(type = IdType.ASSIGN_UUID) + private String id; + + private String itemId; + + private String expression; + + +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/entity/IndItemEntity.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/entity/IndItemEntity.java new file mode 100644 index 0000000..e9d2ad4 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/entity/IndItemEntity.java @@ -0,0 +1,96 @@ +package com.iailab.module.data.ind.entity; + + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; + +import java.io.Serializable; +import java.math.BigDecimal; +import java.util.Date; + +@Data +@TableName("t_ind_item") +public class IndItemEntity implements Serializable { + private static final long serialVersionUID = 1L; + + /** + * ID + */ + @TableId(type = IdType.ASSIGN_UUID) + private String id; + + /** + * 指标编码 + */ + private String itemNo; + + /** + * 指标名称 + */ + private String itemName; + + /** + * 指标类型 + */ + private String itemType; + + /** + * 系数 + */ + private BigDecimal coefficient; + + /** + * 指标精度 + */ + @TableField("`precision`") + private Integer precision; + + /** + * 业务类型 + */ + private String businessType; + + /** + * 时间范围 + */ + private String timeRange; + + /** + * 时间粒度 + */ + private String timeGranularity; + + /** + * 备注 + */ + private String remark; + + /** + * 是否启用 + */ + private Integer isEnable; + + /** + * 创建人 + */ + private String creator; + + /** + * 创建时间 + */ + private Date createTime; + + /** + * 修改人 + */ + private String updater; + + /** + * 修改人 + */ + private Date updateTime; + +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/entity/IndItemValueEntity.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/entity/IndItemValueEntity.java new file mode 100644 index 0000000..c57921c --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/entity/IndItemValueEntity.java @@ -0,0 +1,29 @@ +package com.iailab.module.data.ind.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.math.BigDecimal; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年05月25日 + */ +@Data +@TableName("t_ind_item_value") +public class IndItemValueEntity implements Serializable { + private static final long serialVersionUID = 1L; + + @TableId(type = IdType.ASSIGN_UUID) + private String id; + + private String itemNo; + + private BigDecimal dataValue; + + private String dataTime; +} \ No newline at end of file diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/service/IndItemAtomService.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/service/IndItemAtomService.java new file mode 100644 index 0000000..fda474d --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/service/IndItemAtomService.java @@ -0,0 +1,36 @@ +package com.iailab.module.data.ind.service; + +import com.iailab.framework.common.page.PageData; +import com.iailab.framework.common.service.BaseService; +import com.iailab.module.data.ind.dto.IndItemAtomDTO; +import com.iailab.module.data.ind.entity.IndItemAtomEntity; +import com.iailab.module.data.ind.dto.IndItemAtomDTO; +import com.iailab.module.data.ind.entity.IndItemAtomEntity; +import com.iailab.module.data.ind.dto.IndItemAtomDTO; +import com.iailab.module.data.ind.entity.IndItemAtomEntity; +import com.iailab.module.data.ind.dto.IndItemAtomDTO; +import com.iailab.module.data.ind.entity.IndItemAtomEntity; + +import java.util.Map; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年05月25日 + */ +public interface IndItemAtomService extends BaseService<IndItemAtomEntity> { + + PageData<IndItemAtomDTO> page(Map<String, Object> params); + + IndItemAtomDTO get(String id); + + IndItemAtomDTO getItemId(String itemId); + + void save(IndItemAtomDTO dto); + + void update(IndItemAtomDTO dto); + + void delete(String[] ids); + + void deleteByItemId(String[] ids); +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/service/IndItemCalService.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/service/IndItemCalService.java new file mode 100644 index 0000000..a93e6d0 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/service/IndItemCalService.java @@ -0,0 +1,31 @@ +package com.iailab.module.data.ind.service; + +import com.iailab.framework.common.page.PageData; +import com.iailab.framework.common.service.BaseService; +import com.iailab.module.data.ind.dto.IndItemCalDTO; +import com.iailab.module.data.ind.entity.IndItemCalEntity; + +import java.util.Map; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年05月25日 + */ +public interface IndItemCalService extends BaseService<IndItemCalEntity> { + + PageData<IndItemCalDTO> page(Map<String, Object> params); + + IndItemCalDTO get(String id); + + IndItemCalDTO getItemId(String itemId); + + void save(IndItemCalDTO dto); + + void update(IndItemCalDTO dto); + + void delete(String[] ids); + + void deleteByItemId(String[] ids); + +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/service/IndItemService.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/service/IndItemService.java new file mode 100644 index 0000000..f9c8168 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/service/IndItemService.java @@ -0,0 +1,43 @@ +package com.iailab.module.data.ind.service; + +import com.iailab.framework.common.page.PageData; +import com.iailab.framework.common.service.BaseService; +import com.iailab.module.data.ind.dto.IndItemDTO; +import com.iailab.module.data.ind.entity.IndItemEntity; + +import java.util.List; +import java.util.Map; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年05月25日 + */ +public interface IndItemService extends BaseService<IndItemEntity> { + + PageData<IndItemDTO> page(Map<String, Object> params); + + IndItemDTO get(String id); + + void save(IndItemDTO dto); + + void update(IndItemDTO dto); + + void delete(String[] ids); + + List<IndItemDTO> getItemAtom(List<String> itemNos); + + IndItemDTO getItemAtom(String itemNo); + + List<IndItemDTO> getItemCal(List<String> itemNos); + + IndItemDTO getItemCal(String itemNo); + + List<IndItemDTO> getList(Map<String, Object> params); + + void enableByIds(String[] ids); + + void disableByIds(String[] ids); + + IndItemDTO getItemByItemNo(String itemNo); +} \ No newline at end of file diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/service/IndItemValueService.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/service/IndItemValueService.java new file mode 100644 index 0000000..2645281 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/service/IndItemValueService.java @@ -0,0 +1,26 @@ +package com.iailab.module.data.ind.service; + +import com.iailab.framework.common.page.PageData; +import com.iailab.framework.common.service.BaseService; +import com.iailab.module.data.ind.dto.IndItemValueDTO; +import com.iailab.module.data.ind.entity.IndItemValueEntity; + +import java.util.Map; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年05月25日 + */ +public interface IndItemValueService extends BaseService<IndItemValueEntity> { + + PageData<IndItemValueDTO> page(Map<String, Object> params); + + IndItemValueDTO get(String id); + + void save(IndItemValueDTO dto); + + void update(IndItemValueDTO dto); + + void delete(String[] ids); +} \ No newline at end of file diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/service/impl/IndItemAtomServiceImpl.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/service/impl/IndItemAtomServiceImpl.java new file mode 100644 index 0000000..e33a236 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/service/impl/IndItemAtomServiceImpl.java @@ -0,0 +1,96 @@ +package com.iailab.module.data.ind.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.iailab.framework.common.constant.Constant; +import com.iailab.framework.common.page.PageData; +import com.iailab.framework.common.service.impl.BaseServiceImpl; +import com.iailab.framework.common.util.object.ConvertUtils; +import com.iailab.module.data.ind.dao.IndItemAtomDao; +import com.iailab.module.data.ind.dto.IndItemAtomDTO; +import com.iailab.module.data.ind.dao.IndItemAtomDao; +import com.iailab.module.data.ind.dto.IndItemAtomDTO; +import com.iailab.module.data.ind.dao.IndItemAtomDao; +import com.iailab.module.data.ind.dto.IndItemAtomDTO; +import com.iailab.module.data.ind.entity.IndItemAtomEntity; +import com.iailab.module.data.ind.service.IndItemAtomService; +import com.iailab.module.data.ind.dao.IndItemAtomDao; +import com.iailab.module.data.ind.dto.IndItemAtomDTO; +import org.apache.commons.lang3.StringUtils; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.Arrays; +import java.util.Map; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年05月25日 + */ +@Service +public class IndItemAtomServiceImpl extends BaseServiceImpl<IndItemAtomDao, IndItemAtomEntity> implements IndItemAtomService { + + @Override + public PageData<IndItemAtomDTO> page(Map<String, Object> params) { + IPage<IndItemAtomEntity> page = baseDao.selectPage( + getPage(params, Constant.CREATE_DATE, false), + getWrapper(params) + ); + return getPageData(page, IndItemAtomDTO.class); + } + + private QueryWrapper<IndItemAtomEntity> getWrapper(Map<String, Object> params){ + String itemId = (String)params.get("itemId"); + + QueryWrapper<IndItemAtomEntity> wrapper = new QueryWrapper<>(); + wrapper.like(StringUtils.isNotBlank(itemId), "item_id", itemId); + + return wrapper; + } + + @Override + public IndItemAtomDTO get(String id) { + IndItemAtomEntity entity = baseDao.selectById(id); + + return ConvertUtils.sourceToTarget(entity, IndItemAtomDTO.class); + } + + @Override + public IndItemAtomDTO getItemId(String itemId) { + QueryWrapper<IndItemAtomEntity> wrapper = new QueryWrapper<>(); + wrapper.like(StringUtils.isNotBlank(itemId), "item_id", itemId); + IndItemAtomEntity entity = baseDao.selectOne(wrapper); + + return ConvertUtils.sourceToTarget(entity, IndItemAtomDTO.class); + } + + + @Override + public void save(IndItemAtomDTO dto) { + IndItemAtomEntity entity = ConvertUtils.sourceToTarget(dto, IndItemAtomEntity.class); + + insert(entity); + } + + @Override + public void update(IndItemAtomDTO dto) { + IndItemAtomEntity entity = ConvertUtils.sourceToTarget(dto, IndItemAtomEntity.class); + + updateById(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void delete(String[] ids) { + baseDao.deleteBatchIds(Arrays.asList(ids)); + + } + + @Override + public void deleteByItemId(String[] ids) { + QueryWrapper<IndItemAtomEntity> wrapper = new QueryWrapper<>(); + wrapper.in("item_id", ids); + baseDao.delete(wrapper); + } +} \ No newline at end of file diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/service/impl/IndItemCalServiceImpl.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/service/impl/IndItemCalServiceImpl.java new file mode 100644 index 0000000..2809922 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/service/impl/IndItemCalServiceImpl.java @@ -0,0 +1,98 @@ +package com.iailab.module.data.ind.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.iailab.framework.common.constant.Constant; +import com.iailab.framework.common.page.PageData; +import com.iailab.framework.common.service.impl.BaseServiceImpl; +import com.iailab.framework.common.util.object.ConvertUtils; +import com.iailab.module.data.ind.dao.IndItemCalDao; +import com.iailab.module.data.ind.entity.IndItemCalEntity; +import com.iailab.module.data.ind.service.IndItemCalService; +import com.iailab.module.data.ind.dao.IndItemCalDao; +import com.iailab.module.data.ind.entity.IndItemCalEntity; +import com.iailab.module.data.ind.service.IndItemCalService; +import com.iailab.module.data.ind.dao.IndItemCalDao; +import com.iailab.module.data.ind.dto.IndItemCalDTO; +import com.iailab.module.data.ind.entity.IndItemCalEntity; +import com.iailab.module.data.ind.service.IndItemCalService; +import com.iailab.module.data.ind.dao.IndItemCalDao; +import com.iailab.module.data.ind.entity.IndItemCalEntity; +import com.iailab.module.data.ind.service.IndItemCalService; +import org.apache.commons.lang3.StringUtils; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.Arrays; +import java.util.Map; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年05月25日 + */ +@Service +public class IndItemCalServiceImpl extends BaseServiceImpl<IndItemCalDao, IndItemCalEntity> implements IndItemCalService { + + @Override + public PageData<IndItemCalDTO> page(Map<String, Object> params) { + IPage<IndItemCalEntity> page = baseDao.selectPage( + getPage(params, Constant.CREATE_DATE, false), + getWrapper(params) + ); + return getPageData(page, IndItemCalDTO.class); + } + + private QueryWrapper<IndItemCalEntity> getWrapper(Map<String, Object> params){ + String itemId = (String)params.get("itemId"); + + QueryWrapper<IndItemCalEntity> wrapper = new QueryWrapper<>(); + wrapper.like(StringUtils.isNotBlank(itemId), "item_id", itemId); + + return wrapper; + } + + @Override + public IndItemCalDTO get(String id) { + IndItemCalEntity entity = baseDao.selectById(id); + + return ConvertUtils.sourceToTarget(entity, IndItemCalDTO.class); + } + + @Override + public IndItemCalDTO getItemId(String itemId) { + QueryWrapper<IndItemCalEntity> wrapper = new QueryWrapper<>(); + wrapper.like(StringUtils.isNotBlank(itemId), "item_id", itemId); + IndItemCalEntity entity = baseDao.selectOne(wrapper); + + return ConvertUtils.sourceToTarget(entity, IndItemCalDTO.class); + } + + @Override + public void save(IndItemCalDTO dto) { + IndItemCalEntity entity = ConvertUtils.sourceToTarget(dto, IndItemCalEntity.class); + + insert(entity); + } + + @Override + public void update(IndItemCalDTO dto) { + IndItemCalEntity entity = ConvertUtils.sourceToTarget(dto, IndItemCalEntity.class); + + updateById(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void delete(String[] ids) { + baseDao.deleteBatchIds(Arrays.asList(ids)); + + } + + @Override + public void deleteByItemId(String[] ids) { + QueryWrapper<IndItemCalEntity> wrapper = new QueryWrapper<>(); + wrapper.in("item_id", ids); + baseDao.delete(wrapper); + } +} \ No newline at end of file diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/service/impl/IndItemServiceImpl.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/service/impl/IndItemServiceImpl.java new file mode 100644 index 0000000..53126dc --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/service/impl/IndItemServiceImpl.java @@ -0,0 +1,208 @@ +package com.iailab.module.data.ind.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.iailab.framework.common.constant.Constant; +import com.iailab.module.data.common.enums.CommonConstant; +import com.iailab.module.data.common.enums.IsEnableEnum; +import com.iailab.framework.common.page.PageData; +import com.iailab.framework.common.service.impl.BaseServiceImpl; +import com.iailab.framework.common.util.object.ConvertUtils; +import com.iailab.module.data.ind.dto.IndItemAtomDTO; +import com.iailab.module.data.ind.service.IndItemCalService; +import com.iailab.module.data.ind.service.IndItemService; +import com.iailab.module.data.ind.common.IndItemTypeEnum; +import com.iailab.module.data.ind.dao.IndItemDao; +import com.iailab.module.data.ind.dto.IndItemCalDTO; +import com.iailab.module.data.ind.dto.IndItemDTO; +import com.iailab.module.data.ind.entity.IndItemEntity; +import com.iailab.module.data.ind.service.IndItemAtomService; +import org.apache.commons.lang3.StringUtils; +import javax.annotation.Resource; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.util.CollectionUtils; + +import java.util.*; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年05月25日 + */ +@Service +public class IndItemServiceImpl extends BaseServiceImpl<IndItemDao, IndItemEntity> implements IndItemService { + + @Resource + private IndItemAtomService indItemAtomService; + + @Resource + private IndItemCalService indItemCalService; + + @Override + public PageData<IndItemDTO> page(Map<String, Object> params) { + IPage<IndItemEntity> page = baseDao.selectPage( + getPage(params, Constant.CREATE_TIME, false), + getWrapper(params) + ); + return getPageData(page, IndItemDTO.class); + } + + @Override + public List<IndItemDTO> getList(Map<String, Object> params) { + List<IndItemEntity> list = baseDao.selectList(getWrapper(params)); + return ConvertUtils.sourceToTarget(list, IndItemDTO.class); + } + + @Override + public void enableByIds(String[] ids) { + if (CollectionUtils.isEmpty(Arrays.asList(ids))) { + return; + } + Arrays.asList(ids).forEach(item -> { + IndItemEntity entity = new IndItemEntity(); + entity.setId(item); + entity.setIsEnable(IsEnableEnum.ENABLE.value()); + baseDao.updateById(entity); + }); + } + + @Override + public void disableByIds(String[] ids) { + if (CollectionUtils.isEmpty(Arrays.asList(ids))) { + return; + } + Arrays.asList(ids).forEach(item -> { + IndItemEntity entity = new IndItemEntity(); + entity.setId(item); + entity.setIsEnable(IsEnableEnum.DISABLE.value()); + baseDao.updateById(entity); + }); + } + + @Override + public IndItemDTO getItemByItemNo(String itemNo) { + QueryWrapper<IndItemEntity> wrapper = new QueryWrapper<>(); + wrapper.eq("item_no", itemNo); + return ConvertUtils.sourceToTarget(baseDao.selectOne(wrapper),IndItemDTO.class); + } + + private QueryWrapper<IndItemEntity> getWrapper(Map<String, Object> params){ + String itemNo = (String)params.get("itemNo"); + + QueryWrapper<IndItemEntity> wrapper = new QueryWrapper<>(); + wrapper.like(StringUtils.isNotBlank(itemNo), "item_no", itemNo); + + return wrapper; + } + + @Override + public IndItemDTO get(String id) { + IndItemEntity entity = baseDao.selectById(id); + if (entity == null) { + return null; + } + IndItemDTO result = ConvertUtils.sourceToTarget(entity, IndItemDTO.class); + if (IndItemTypeEnum.ATOM_ITEM.getCode().equals(result.getItemType())) { + IndItemAtomDTO dto = indItemAtomService.getItemId(id); + result.setIndItemAtom(dto); + } else if (IndItemTypeEnum.CAL_ITEM.getCode().equals(result.getItemType())) { + IndItemCalDTO dto = indItemCalService.getItemId(id); + result.setIndItemCal(dto); + } + return result; + } + + @Override + public void save(IndItemDTO dto) { + IndItemEntity entity = ConvertUtils.sourceToTarget(dto, IndItemEntity.class); + entity.setId(UUID.randomUUID().toString()); + if (IndItemTypeEnum.ATOM_ITEM.getName().equals(entity.getItemType())) { + IndItemAtomDTO indItemAtomDTO = new IndItemAtomDTO(); + indItemAtomDTO.setId(UUID.randomUUID().toString()); + indItemAtomDTO.setItemId(entity.getId()); + indItemAtomDTO.setDataSource(dto.getDataSource()); + indItemAtomDTO.setQuerySql(dto.getQuerySql()); + indItemAtomService.save(indItemAtomDTO); + }else if (IndItemTypeEnum.CAL_ITEM.getName().equals(entity.getItemType())){ + IndItemCalDTO indItemCalDTO = new IndItemCalDTO(); + indItemCalDTO.setId(UUID.randomUUID().toString()); + indItemCalDTO.setItemId(entity.getId()); + indItemCalDTO.setExpression(dto.getExpression()); + indItemCalService.save(indItemCalDTO); + } + entity.setIsEnable(CommonConstant.IS_ENABLE); + entity.setCreateTime(new Date()); + insert(entity); + } + + @Override + public void update(IndItemDTO dto) { + IndItemEntity entity = ConvertUtils.sourceToTarget(dto, IndItemEntity.class); + entity.setUpdateTime(new Date()); + updateById(entity); + System.out.println(IndItemTypeEnum.ATOM_ITEM.getName()+IndItemTypeEnum.CAL_ITEM.getName()); + if (IndItemTypeEnum.ATOM_ITEM.getName().equals(entity.getItemType())) { + dto.getIndItemAtom().setDataSource(dto.getDataSource()); + dto.getIndItemAtom().setQuerySql(dto.getQuerySql()); + indItemAtomService.update(dto.getIndItemAtom()); + }else if (IndItemTypeEnum.CAL_ITEM.getName().equals(entity.getItemType())){ + dto.getIndItemCal().setExpression(dto.getExpression()); + indItemCalService.update(dto.getIndItemCal()); + } + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void delete(String[] ids) { + baseDao.deleteBatchIds(Arrays.asList(ids)); + indItemAtomService.deleteByItemId(ids); + indItemCalService.deleteByItemId(ids); + } + + @Override + public List<IndItemDTO> getItemAtom(List<String> itemNos) { + Map<String, Object> params = new HashMap<>(); + params.put("itemType", IndItemTypeEnum.ATOM_ITEM.getCode()); + params.put("isEnable", CommonConstant.IS_ENABLE); + params.put("itemNos", itemNos); + return baseDao.getItemAtom(params); + } + + @Override + public IndItemDTO getItemAtom(String itemNo) { + IndItemDTO result = null; + Map<String, Object> params = new HashMap<>(); + params.put("itemType", IndItemTypeEnum.ATOM_ITEM.getCode()); + params.put("isEnable", CommonConstant.IS_ENABLE); + params.put("itemNo", itemNo); + List<IndItemDTO> list = baseDao.getItemAtom(params); + if (!CollectionUtils.isEmpty(list)) { + result = list.get(0); + } + return result; + } + + @Override + public List<IndItemDTO> getItemCal(List<String> itemNos) { + Map<String, Object> params = new HashMap<>(); + params.put("itemType", IndItemTypeEnum.CAL_ITEM.getCode()); + params.put("isEnable", CommonConstant.IS_ENABLE); + params.put("itemNos", itemNos); + return baseDao.getItemCal(params); + } + + @Override + public IndItemDTO getItemCal(String itemNo) { + IndItemDTO result = null; + Map<String, Object> params = new HashMap<>(); + params.put("itemType", IndItemTypeEnum.CAL_ITEM.getCode()); + params.put("isEnable", CommonConstant.IS_ENABLE); + params.put("itemNo", itemNo); + List<IndItemDTO> list = baseDao.getItemCal(params); + if (!CollectionUtils.isEmpty(list)) { + result = list.get(0); + } + return result; + } +} \ No newline at end of file diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/service/impl/IndItemValueServiceImpl.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/service/impl/IndItemValueServiceImpl.java new file mode 100644 index 0000000..abb2bcc --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/service/impl/IndItemValueServiceImpl.java @@ -0,0 +1,82 @@ +package com.iailab.module.data.ind.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.iailab.framework.common.constant.Constant; +import com.iailab.framework.common.page.PageData; +import com.iailab.framework.common.service.impl.BaseServiceImpl; +import com.iailab.framework.common.util.object.ConvertUtils; +import com.iailab.module.data.ind.dao.IndItemValueDao; +import com.iailab.module.data.ind.entity.IndItemValueEntity; +import com.iailab.module.data.ind.service.IndItemValueService; +import com.iailab.module.data.ind.dao.IndItemValueDao; +import com.iailab.module.data.ind.entity.IndItemValueEntity; +import com.iailab.module.data.ind.service.IndItemValueService; +import com.iailab.module.data.ind.dao.IndItemValueDao; +import com.iailab.module.data.ind.dto.IndItemValueDTO; +import com.iailab.module.data.ind.entity.IndItemValueEntity; +import com.iailab.module.data.ind.service.IndItemValueService; +import com.iailab.module.data.ind.dao.IndItemValueDao; +import com.iailab.module.data.ind.entity.IndItemValueEntity; +import com.iailab.module.data.ind.service.IndItemValueService; +import org.apache.commons.lang3.StringUtils; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.Arrays; +import java.util.Map; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年05月25日 + */ +@Service +public class IndItemValueServiceImpl extends BaseServiceImpl<IndItemValueDao, IndItemValueEntity> implements IndItemValueService { + + @Override + public PageData<IndItemValueDTO> page(Map<String, Object> params) { + IPage<IndItemValueEntity> page = baseDao.selectPage( + getPage(params, Constant.CREATE_DATE, false), + getWrapper(params) + ); + return getPageData(page, IndItemValueDTO.class); + } + + private QueryWrapper<IndItemValueEntity> getWrapper(Map<String, Object> params) { + String itemNo = (String) params.get("itemNo"); + + QueryWrapper<IndItemValueEntity> wrapper = new QueryWrapper<>(); + wrapper.like(StringUtils.isNotBlank(itemNo), "item_no", itemNo); + + return wrapper; + } + + @Override + public IndItemValueDTO get(String id) { + IndItemValueEntity entity = baseDao.selectById(id); + + return ConvertUtils.sourceToTarget(entity, IndItemValueDTO.class); + } + + @Override + public void save(IndItemValueDTO dto) { + IndItemValueEntity entity = ConvertUtils.sourceToTarget(dto, IndItemValueEntity.class); + + insert(entity); + } + + @Override + public void update(IndItemValueDTO dto) { + IndItemValueEntity entity = ConvertUtils.sourceToTarget(dto, IndItemValueEntity.class); + + updateById(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void delete(String[] ids) { + baseDao.deleteBatchIds(Arrays.asList(ids)); + + } +} \ No newline at end of file diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/indexdata/common/ClockSuffix.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/indexdata/common/ClockSuffix.java new file mode 100644 index 0000000..d3c3171 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/indexdata/common/ClockSuffix.java @@ -0,0 +1,10 @@ +package com.iailab.module.data.indexdata.common; + +/** + * @author PanZhibao + * @Description + * @createTime 2022年09月11日 09:52:00 + */ +public enum ClockSuffix { + BB,YB,RI +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/indexdata/common/IndexDataBc.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/indexdata/common/IndexDataBc.java new file mode 100644 index 0000000..60679b9 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/indexdata/common/IndexDataBc.java @@ -0,0 +1,10 @@ +package com.iailab.module.data.indexdata.common; + +/** + * @author PanZhibao + * @Description + * @createTime 2022年09月10日 23:29:00 + */ +public enum IndexDataBc { + BC_B_ST,BC_Y_ST,BC_TIME +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/indexdata/common/IndexDataConstant.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/indexdata/common/IndexDataConstant.java new file mode 100644 index 0000000..88ff93e --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/indexdata/common/IndexDataConstant.java @@ -0,0 +1,79 @@ +package com.iailab.module.data.indexdata.common; + +/** + * @author PanZhibao + * @Description + * @createTime 2022年09月12日 08:57:00 + */ +public interface IndexDataConstant { + + /** + * 数据项类别 原煤 + */ + String DATA_ITEM_TYPE_YM = "1"; + + /** + * 数据项类别 洗选 + */ + String DATA_ITEM_TYPE_XX = "2"; + + /** + * 数据项类别 装车 + */ + String DATA_ITEM_TYPE_ZC = "3"; + + /** + * 数据项类别 装车 + */ + String DATA_ITEM_TYPE_ZJ = "4"; + + /** + * 运行时长全部 + */ + String RUN_TIME = "run-time"; + + /** + * 运行时长正常 + */ + String RUN_TIME_ZC = "run-time-zc"; + + /** + * 运行时长空载 + */ + String RUN_TIME_KZ = "run-time-kz"; + + /** + * 消耗指标 + */ + String CONSUME_TARGET = "consume-target"; + + /** + * 电耗 + */ + String POWER_CONSUME = "power-consume"; + + /** + * 调入量 + */ + String WASH_TRANSFER_IN = "wash-transfer-in"; + + /** + * 入洗量 + */ + String WASH_TO_WASH = "wash-to-wash"; + + /** + * 生产量 + */ + String WASH_PROD_VOLUME = "wash-prod-volume"; + + /** + * 仓位 + */ + String WAREHOUSE_POSITION = "warehouse-position"; + + /** + * 小时量 + */ + String HOUR_VOLUME = "hour-volume"; +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/indexdata/common/IndexDataUtils.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/indexdata/common/IndexDataUtils.java new file mode 100644 index 0000000..fd26933 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/indexdata/common/IndexDataUtils.java @@ -0,0 +1,768 @@ +package com.iailab.module.data.indexdata.common; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.iailab.dto.*; +import com.iailab.module.data.common.enums.CommonConstant; +import com.iailab.api.IFeignProddispApi; +import com.iailab.framework.common.util.date.DateUtils; +import com.iailab.module.data.point.dto.DaPointDTO; +import com.iailab.module.data.point.service.DaPointService; +import com.iailab.module.data.indexdata.entity.IndexDataItemEntity; +import com.iailab.module.data.indexdata.entity.IndexDataValueEntity; +import com.iailab.module.data.indexdata.service.IndexDataItemService; +import com.iailab.module.data.indexdata.service.IndexDataValueService; +import com.iailab.module.data.influxdb.pojo.InfluxPointValuePOJO; +import com.iailab.module.data.influxdb.service.InfluxDBService; +import com.iailab.module.infra.api.config.ConfigApi; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import org.joda.time.LocalDate; +import javax.annotation.Resource; +import org.springframework.stereotype.Component; +import org.springframework.util.CollectionUtils; + +import java.math.BigDecimal; +import java.math.RoundingMode; +import java.text.SimpleDateFormat; +import java.util.*; +import java.util.stream.Collectors; + +/** + * @author PanZhibao + * @Description + * @createTime 2022年09月11日 14:11:00 + */ +@Slf4j +@Component +public class IndexDataUtils { + + private BigDecimal hourMins = new BigDecimal("60"); + + private String DATA_TYPE_BOOLEAN = "boolean"; + + private final int granularity = 5; + + @Resource + private InfluxDBService influxDBService; + + @Resource + private IndexDataValueService indexDataValueService; + + @Resource + private IFeignProddispApi feignProddispApi; + + @Resource + private ConfigApi configApi; + + @Resource + private DaPointService daPointService; + + @Resource + private IndexDataItemService indexDataItemService; + + public void doCal(Date startTime, Date endTime, String CLOCK_CODE, String DICT_DC) throws Exception { + log.info("startTime=" + DateUtils.format(startTime, DateUtils.FORMAT_YEAR_MONTH_DAY)); + log.info("endTime=" + DateUtils.format(endTime, DateUtils.FORMAT_YEAR_MONTH_DAY)); + // 获取数据项 + List<IndexDataItemEntity> indexDataItemList = indexDataItemService.getListByClockConfig(CLOCK_CODE); + if (CollectionUtils.isEmpty(indexDataItemList)) { + log.warn("indexDataItemEntityList为空, clockCode=" + CLOCK_CODE); + throw new Exception("indexDataItemEntityList为空, clockCode=" + CLOCK_CODE); + } + indexDataItemList.forEach(dataItem -> { + switch (dataItem.getItemType()) { + case IndexDataConstant.RUN_TIME: + // 运行时长 + this.createRunTime(CLOCK_CODE, dataItem, "all" ,startTime, endTime); + break; + case IndexDataConstant.RUN_TIME_ZC: + // 运行时长正常 + this.createRunTime(CLOCK_CODE, dataItem, "zc",startTime, endTime); + break; + case IndexDataConstant.RUN_TIME_KZ: + // 运行时长空载 + this.createRunTime(CLOCK_CODE, dataItem, "kz",startTime, endTime); + break; + case IndexDataConstant.POWER_CONSUME: + // 电耗 + this.createPowerConsume(CLOCK_CODE, dataItem, startTime, endTime); + break; + case IndexDataConstant.WASH_TRANSFER_IN: + // 调入量 + this.createWashTransferIn(CLOCK_CODE, dataItem, startTime, endTime); + break; + case IndexDataConstant.WASH_TO_WASH: + // 入洗量 + this.createWashToWash(CLOCK_CODE, dataItem, startTime, endTime); + break; + case IndexDataConstant.WASH_PROD_VOLUME: + // 生产量 + this.createWashProdVolume(CLOCK_CODE, dataItem, startTime, endTime); + break; + case IndexDataConstant.WAREHOUSE_POSITION: + // 仓位 + this.createWarehousePosition(CLOCK_CODE, dataItem, startTime, endTime); + break; + default: + break; + } + }); + + // 统计库存 + this.createWarehouseStock(DateUtils.format(startTime), DICT_DC); + + // 统计总电量 + FeignConsumeTargetDTO dto = new FeignConsumeTargetDTO(); + Map param = new HashMap(); + param.put("rq",new LocalDate()); + param.put("bc",DICT_DC); + BigDecimal hdl = feignProddispApi.sumData(param); + dto.setRq(DateUtils.format(startTime)); + dto.setBc(DICT_DC); + dto.setXhzb("hdl"); + dto.setDw("kw.h"); + dto.setNbdrl(hdl); + dto.setNbtzl(new BigDecimal(0)); + dto.setWbdrl(new BigDecimal(0)); + dto.setWbtzl(new BigDecimal(0)); + dto.setCjr(CommonConstant.CJS_SYS); + dto.setCjsj(new Date()); + dto.setXgsj(new Date()); + feignProddispApi.createConsumeTarget(dto); + + } + + public void doHourVolume(Date startTime, Date endTime, String CLOCK_CODE, String DICT_DC) throws Exception { + log.info("startTime=" + DateUtils.format(startTime, DateUtils.FORMAT_YEAR_MONTH_DAY)); + log.info("endTime=" + DateUtils.format(endTime, DateUtils.FORMAT_YEAR_MONTH_DAY)); + // 获取数据项 + List<IndexDataItemEntity> indexDataItemList = indexDataItemService.getListByClockConfig(CLOCK_CODE); + if (CollectionUtils.isEmpty(indexDataItemList)) { + log.warn("indexDataItemEntityList为空, clockCode=" + CLOCK_CODE); + throw new Exception("indexDataItemEntityList为空, clockCode=" + CLOCK_CODE); + } + indexDataItemList.forEach(dataItem -> {this.createHourVolume(CLOCK_CODE, dataItem, startTime, endTime);}); + + } + public void createRunTime(String clockCode, IndexDataItemEntity dataItem, String runTimeType,Date startTime, Date endTime) { + try{ + log.info("计算运行时长开始,itemCode=" + dataItem.getPointCode()); + InfluxPointValuePOJO pojo = new InfluxPointValuePOJO(); + pojo.setPoint(dataItem.getPointCode()); + pojo.setType(DATA_TYPE_BOOLEAN); + List<Map<String, Object>> pointData = influxDBService.queryPointValues(pojo, startTime, endTime); + if (CollectionUtils.isEmpty(pointData)) { + log.warn("历史值为空,PointCode=" + dataItem.getPointCode()); + return; + } + int mins = this.getRunMins(pointData); + int times = this.getStartUpTimes(pointData); + + Map<String, BigDecimal> valueMap = new HashMap<>(2); + valueMap.put("sumValue", new BigDecimal(mins)); + valueMap.put("startUpTimes", new BigDecimal(times)); + IndexDataValueEntity indexDataValue = this.buildIndexDataValueEntity(dataItem, clockCode, valueMap); + indexDataValueService.add(indexDataValue); + + FeignRunTimeDTO dto = new FeignRunTimeDTO(); + dto.setRq(DateUtils.format(startTime)); + dto.setBc(dataItem.getBc()); + dto.setScxm(dataItem.getXtCode()); + dto.setRunTimeType(runTimeType); + dto.setXss(Long.valueOf((mins / 60))); + dto.setFzs(Long.valueOf((mins % 60))); + dto.setZsc(Long.valueOf(mins)); + dto.setCjr(CommonConstant.CJS_SYS); + dto.setCjsj(new Date()); + dto.setXgsj(new Date()); + feignProddispApi.createRunTime(dto); + log.info("计算运行时长结束,itemCode=" + dataItem.getPointCode()); + } catch (Exception ex) { + log.info("计算运行时长异常,itemCode=" + dataItem.getPointCode()); + ex.printStackTrace(); + } + } + + public void createConsumeTarget(String clockCode, IndexDataItemEntity dataItem, Date startTime, Date endTime) { + try{ + log.info("计算消耗指标开始,itemCode=" + dataItem.getPointCode()); + + // 插入指标数据表 + Map<String, BigDecimal> valueMap = new HashMap<>(2); + valueMap.put("sumValue", new BigDecimal(0)); + IndexDataValueEntity indexDataValue = this.buildIndexDataValueEntity(dataItem, clockCode, valueMap); + indexDataValueService.add(indexDataValue); + + FeignConsumeTargetDTO dto = new FeignConsumeTargetDTO(); + dto.setRq(DateUtils.format(startTime)); + dto.setBc(dataItem.getBc()); + dto.setXhzb(dataItem.getExt1()); + dto.setDw(dataItem.getUnit()); + dto.setNbdrl(new BigDecimal(0)); + dto.setNbtzl(new BigDecimal(0)); + dto.setWbdrl(new BigDecimal(0)); + dto.setWbtzl(new BigDecimal(0)); + dto.setCjr(CommonConstant.CJS_SYS); + dto.setCjsj(new Date()); + dto.setXgsj(new Date()); + feignProddispApi.createConsumeTarget(dto); + log.info("计算消耗指标结束,itemCode=" + dataItem.getPointCode()); + } catch (Exception ex) { + log.info("计算消耗指标异常,itemCode=" + dataItem.getPointCode()); + ex.printStackTrace(); + } + } + + public void createPowerConsume(String clockCode, IndexDataItemEntity dataItem, Date startTime, Date endTime) { + try{ + DaPointDTO daPoint = daPointService.getByNo(dataItem.getPointCode()); + + if (daPoint == null) { + log.info("daPoint is null"); + return; + } + InfluxPointValuePOJO pojo = new InfluxPointValuePOJO(); + pojo.setPoint(daPoint.getPointNo()); + pojo.setType(daPoint.getPointType()); + // 取10min内最大值 + Object startPointValue = influxDBService.queryPointMaxValue(pojo, new Date(startTime.getTime() - 1000 * 60 * 10)); + Object endPointValue = influxDBService.queryPointMaxValue(pojo, new Date(endTime.getTime() - 1000 * 60 * 10)); + BigDecimal startValue = startPointValue == null ? BigDecimal.ZERO : new BigDecimal(startPointValue.toString()); + BigDecimal endValue = endPointValue == null ? BigDecimal.ZERO : new BigDecimal(endPointValue.toString()); + BigDecimal value = new BigDecimal(0); + if(endValue.compareTo(startValue) == 1){ + value = endValue.subtract(startValue); + } + // 插入指标数据表 + Map<String, BigDecimal> valueMap = new HashMap<>(1); + valueMap.put("sumValue", value); + IndexDataValueEntity indexDataValue = this.buildIndexDataValueEntity(dataItem, clockCode, valueMap); + indexDataValueService.add(indexDataValue); + + String xt = configApi.queryConfigByCode(dataItem.getExt1()); + // 插入统计表 + FeignPowerConsumeDTO dto = new FeignPowerConsumeDTO(); + dto.setRq(DateUtils.format(startTime)); + dto.setBc(dataItem.getBc()); + dto.setXt(xt); + dto.setNbdrl(value); + dto.setNbtzl(new BigDecimal(0)); + dto.setWbdrl(value); + dto.setWbtzl(new BigDecimal(0)); + dto.setCjr(CommonConstant.CJS_SYS); + dto.setCjsj(new Date()); + dto.setXgsj(new Date()); + feignProddispApi.createPowerConsume(dto); + log.info("计算电耗结束,itemCode=" + dataItem.getPointCode()); + } catch (Exception ex) { + log.info("计算电耗异常,itemCode=" + dataItem.getPointCode()); + ex.printStackTrace(); + } + } + public void createHourVolume(String clockCode, IndexDataItemEntity dataItem, Date startTime, Date endTime) { + try{ + /** + * 861 精煤 + * 862 混煤 + * 903 矸石 + * 603ABC 煤泥板数 + */ + log.info("计算小时量开始,itemCode=" + dataItem.getPointCode()); + List<String> pointNos = new ArrayList<>(); + pointNos.add(dataItem.getPointCode()); + if(StringUtils.isNotBlank(dataItem.getExt1())) { + pointNos.add(dataItem.getExt1()); + } + if(StringUtils.isNotBlank(dataItem.getExt2())) { + pointNos.add(dataItem.getExt2()); + } + if(StringUtils.isNotBlank(dataItem.getExt3())) { + pointNos.add(dataItem.getExt3()); + } + if(StringUtils.isNotBlank(dataItem.getExt4())) { + pointNos.add(dataItem.getExt4()); + } + if(StringUtils.isNotBlank(dataItem.getExt5())) { + pointNos.add(dataItem.getExt5()); + } + List<DaPointDTO> pointList = daPointService.getByNos(pointNos); + if (CollectionUtils.isEmpty(pointList)) { + log.warn("pointNos查询为空!"); + return; + } + List<InfluxPointValuePOJO> influxParams = pointList.stream().map(item -> { + InfluxPointValuePOJO pojo = new InfluxPointValuePOJO(); + pojo.setPoint(item.getPointNo()); + pojo.setType(item.getDataType()); + return pojo; + }).collect(Collectors.toList()); + Map<String, Object> data = influxDBService.queryPointsSpread(influxParams, startTime, endTime); + log.info("查询完成!"); + + log.info("插入统计表"); + FeignHourVolumeDTO dto = new FeignHourVolumeDTO(); + dto.setRq(DateUtils.format(startTime)); + dto.setBc(this.getBcByTime(endTime)); + dto.setSj(endTime); + if (StringUtils.isNotBlank(dataItem.getPointCode()) && data.get(dataItem.getPointCode()) != null) { + dto.setRxl(new BigDecimal(data.get(dataItem.getPointCode()).toString())); + log.info(" 插入指标数据表"); + Map<String, BigDecimal> valueMap = new HashMap<>(1); + valueMap.put("sumValue", new BigDecimal(data.get(dataItem.getPointCode()).toString())); + IndexDataValueEntity indexDataValue = this.buildIndexDataValueEntity(dataItem, clockCode, valueMap); + indexDataValueService.add(indexDataValue); + } + if (StringUtils.isNotBlank(dataItem.getExt1()) && data.get(dataItem.getExt1()) != null) { + dto.setJml(new BigDecimal(data.get(dataItem.getExt1()).toString())); + } + if (StringUtils.isNotBlank(dataItem.getExt2()) && data.get(dataItem.getExt2()) != null) { + dto.setHml(new BigDecimal(data.get(dataItem.getExt2()).toString())); + } + if (StringUtils.isNotBlank(dataItem.getExt3()) && data.get(dataItem.getExt3()) != null) { + dto.setGsl(new BigDecimal(data.get(dataItem.getExt3()).toString())); + } + if (StringUtils.isNotBlank(dataItem.getExt4()) && data.get(dataItem.getExt4()) != null) { + dto.setFjbs(new BigDecimal(data.get(dataItem.getExt4()).toString())); + } + if (StringUtils.isNotBlank(dataItem.getExt5()) && data.get(dataItem.getExt5()) != null) { + dto.setMnbs(new BigDecimal(data.get(dataItem.getExt5()).toString())); + } + dto.setCjr(CommonConstant.CJS_SYS); + dto.setCjsj(new Date()); + dto.setXgsj(new Date()); + feignProddispApi.createHourVolume(dto); + log.info("计算小时量结束,itemCode=" + dataItem.getPointCode()); + } catch (Exception ex) { + log.info("计算小时量异常,itemCode=" + dataItem.getPointCode()); + ex.printStackTrace(); + } + } + + + private String getBcByTime(Date dateTime) { + String bc = "bb"; + Calendar calendar = Calendar.getInstance(); + calendar.setTime(dateTime); + if (calendar.get(Calendar.HOUR_OF_DAY) >= 21 || calendar.get(Calendar.HOUR_OF_DAY) <= 8) { + bc = "yb"; + } + return bc; + } + + public void createWashTransferIn(String clockCode, IndexDataItemEntity dataItem, Date startTime, Date endTime) { + try{ + log.info("计算调入量开始,itemCode=" + dataItem.getPointCode()); + // 查询测点里的累计产量 + DaPointDTO daPoint = daPointService.getByNo(dataItem.getPointCode()); + + if (daPoint == null) { + log.info("daPoint is null"); + return; + } + InfluxPointValuePOJO pojo = new InfluxPointValuePOJO(); + pojo.setPoint(daPoint.getPointNo()); + pojo.setType(daPoint.getDataType()); + // 取10min内最大值 + Object pointValue = influxDBService.queryPointMaxValue(pojo, new Date(endTime.getTime() - 1000 * 60 * 10)); + BigDecimal sumValue = pointValue == null ? BigDecimal.ZERO : new BigDecimal(pointValue.toString()); + + // 插入指标数据表 + Map<String, BigDecimal> valueMap = new HashMap<>(1); + valueMap.put("sumValue", sumValue); + IndexDataValueEntity indexDataValue = this.buildIndexDataValueEntity(dataItem, clockCode, valueMap); + indexDataValueService.add(indexDataValue); + + String mz = configApi.queryConfigByCode(dataItem.getExt1()); + // 插入统计表 + FeignWashTransferInDTO dto = new FeignWashTransferInDTO(); + dto.setRq(DateUtils.format(startTime)); + dto.setBc(dataItem.getBc()); + dto.setDrly(mz); + dto.setNbdrl(sumValue); + dto.setNbtzl(new BigDecimal(0)); + dto.setWbdrl(sumValue); + dto.setWbtzl(new BigDecimal(0)); + dto.setCjr(CommonConstant.CJS_SYS); + dto.setCjsj(new Date()); + dto.setXgsj(new Date()); + feignProddispApi.createWashTransferIn(dto); + log.info("计算调入量结束,itemCode=" + dataItem.getPointCode()); + } catch (Exception ex) { + log.info("计算调入量异常,itemCode=" + dataItem.getPointCode()); + ex.printStackTrace(); + } + } + + public void createWashToWash(String clockCode, IndexDataItemEntity dataItem, Date startTime, Date endTime) { + try{ + log.info("计算入洗量开始,itemCode=" + dataItem.getPointCode()); + // 查询测点里的累计产量 + DaPointDTO daPoint = daPointService.getByNo(dataItem.getPointCode()); + if (daPoint == null) { + log.info("daPoint is null"); + return; + } + InfluxPointValuePOJO pojo = new InfluxPointValuePOJO(); + pojo.setPoint(daPoint.getPointNo()); + pojo.setType(daPoint.getDataType()); + // 取10min内最大值 + Object pointValue = influxDBService.queryPointMaxValue(pojo, new Date(endTime.getTime() - 1000 * 60 * 10)); + BigDecimal sumValue = pointValue == null ? BigDecimal.ZERO : new BigDecimal(pointValue.toString()); + log.info("插入指标数据表"); + Map<String, BigDecimal> valueMap = new HashMap<>(1); + log.info("sumValue"+sumValue); + valueMap.put("sumValue", sumValue); + IndexDataValueEntity indexDataValue = this.buildIndexDataValueEntity(dataItem, clockCode, valueMap); + indexDataValueService.add(indexDataValue); + List<FeignMcMzDTO> mzList = feignProddispApi.selectMcMzByMc(dataItem.getExt1()); + log.info("dataItem.getExt1()"+dataItem.getExt1()); + + //获取总入洗量 + pojo.setPoint(dataItem.getExt2()); + pojo.setType("float"); + Object rxlPointValue = influxDBService.queryPointMaxValue(pojo, new Date(endTime.getTime() - 1000 * 60 * 10)); + BigDecimal sumRXL = rxlPointValue == null ? BigDecimal.ZERO : new BigDecimal(rxlPointValue.toString()); + + mzList.stream().forEach( + mz->{ + log.info("插入统计表,mc:"+mz.getMc()+";mz:"+mz.getMz()); + FeignWashToWashDTO dto = new FeignWashToWashDTO(); + dto.setRq(DateUtils.format(startTime)); + dto.setBc(dataItem.getBc()); + dto.setXxjm(mz.getMz()); + dto.setNbdrl(sumValue.multiply(BigDecimal.valueOf(mz.getProportion())).divide(BigDecimal.valueOf(mz.getDen())) ); + dto.setRxbl(dto.getNbdrl().divide(sumRXL, 2, RoundingMode.HALF_UP)); + dto.setRxly(dataItem.getExt1()); + dto.setNbtzl(new BigDecimal(0)); + dto.setWbdrl(dto.getNbdrl()); + dto.setWbtzl(new BigDecimal(0)); + dto.setCjr(CommonConstant.CJS_SYS); + dto.setCjsj(new Date()); + dto.setXgsj(new Date()); + feignProddispApi.createWashToWash(dto); + } + ); + + + log.info("计算入洗量结束,itemCode=" + dataItem.getPointCode()); + } catch (Exception ex) { + log.info("计算入洗量异常,itemCode=" + dataItem.getPointCode()); + ex.printStackTrace(); + } + } + + public void createWashProdVolume(String clockCode, IndexDataItemEntity dataItem, Date startTime, Date endTime) { + try{ + log.info("计算生产量开始,itemCode=" + dataItem.getPointCode()); + // 查询测点里的累计产量 + DaPointDTO daPoint = daPointService.getByNo(dataItem.getPointCode()); + if (daPoint == null) { + log.info("daPoint is null"); + return; + } + InfluxPointValuePOJO pojo = new InfluxPointValuePOJO(); + pojo.setPoint(daPoint.getPointNo()); + pojo.setType(daPoint.getDataType()); + // 取10min内最大值 + Object pointValue = influxDBService.queryPointMaxValue(pojo, new Date(endTime.getTime() - 1000 * 60 * 10)); + BigDecimal sumValue = pointValue == null ? BigDecimal.ZERO : new BigDecimal(pointValue.toString()); + + log.info("插入指标数据表"); + Map<String, BigDecimal> valueMap = new HashMap<>(1); + valueMap.put("sumValue", sumValue); + IndexDataValueEntity indexDataValue = this.buildIndexDataValueEntity(dataItem, clockCode, valueMap); + indexDataValueService.add(indexDataValue); + + log.info("插入统计表"); + FeignWashProdVolumeDTO dto = new FeignWashProdVolumeDTO(); + dto.setRq(DateUtils.format(startTime)); + dto.setBc(dataItem.getBc()); + dto.setClmz(dataItem.getExt1()); + dto.setNbdrl(sumValue); + dto.setNbtzl(new BigDecimal(0)); + dto.setWbdrl(sumValue); + dto.setWbtzl(new BigDecimal(0)); + dto.setCjr(CommonConstant.CJS_SYS); + dto.setCjsj(new Date()); + dto.setXgsj(new Date()); + feignProddispApi.createWashProdVolume(dto); + log.info("计算生产量结束,itemCode=" + dataItem.getPointCode()); + } catch (Exception ex) { + log.info("计算生产量异常,itemCode=" + dataItem.getPointCode()); + ex.printStackTrace(); + } + } + + public void createWarehousePosition(String clockCode, IndexDataItemEntity dataItem, Date startTime, Date endTime) { + try{ + log.info("计算仓位开始,itemCode=" + dataItem.getPointCode()); + DaPointDTO daPoint = daPointService.getByNo(dataItem.getPointCode()); + if (daPoint == null) { + log.info("daPoint is null"); + return; + } + InfluxPointValuePOJO pojo = new InfluxPointValuePOJO(); + pojo.setPoint(daPoint.getPointNo()); + pojo.setType(daPoint.getDataType()); + List<Map<String, Object>> pointValues = influxDBService.queryPointValues(pojo, new Date(endTime.getTime() - 1000 * 30), endTime); + String point = JSON.toJSONString(pointValues); + log.info("pointValues :"+point); + if (CollectionUtils.isEmpty(pointValues)) { + log.info("pointValues is null"); + return; + } + + Map<String, Object> pointValue = pointValues.get(pointValues.size() - 1); + JSONObject json = new JSONObject(pointValue); + log.info("插入指标数据表:"+json); + Map<String, BigDecimal> valueMap = new HashMap<>(1); + BigDecimal sumValue = new BigDecimal(pointValue.get("value").toString()); + valueMap.put("sumValue",sumValue); + IndexDataValueEntity indexDataValue = this.buildIndexDataValueEntity(dataItem, clockCode, valueMap); + indexDataValueService.add(indexDataValue); + log.info("mc:"+dataItem.getExt1()); + FeignWarehouseItemDTO warehouseItem = feignProddispApi.selectWarehouseItemByMc(dataItem.getExt1()); + log.info("插入仓位统计表开始"); + FeignWarehousePositionDTO dto = new FeignWarehousePositionDTO(); + dto.setRq(DateUtils.format(startTime)); + dto.setBc(dataItem.getBc()); + dto.setMc(dataItem.getExt1()); + dto.setMclx(dataItem.getExt2()); + log.info(Integer.toString(warehouseItem.getCapacity())); + dto.setCrl(Integer.toString(warehouseItem.getCapacity())); + BigDecimal dqcc = sumValue.multiply(new BigDecimal(dto.getCrl())).divide(new BigDecimal(100), 1, BigDecimal.ROUND_HALF_UP); + dto.setNbgl(dqcc); + dto.setWbgl(dqcc); + dto.setCjr(CommonConstant.CJS_SYS); + dto.setCjsj(new Date()); + dto.setXgsj(new Date()); + feignProddispApi.createWarehousePosition(dto); + log.info("计算仓位结束,itemCode=" + dataItem.getPointCode()); + } catch (Exception ex) { + log.info("计算仓位异常,itemCode=" + dataItem.getPointCode()); + ex.printStackTrace(); + } + } + + public void createWarehouseStock(String rq, String bc) { + try{ + log.info("计算库存开始,rq=" + rq); + + Map<String, Object> params = new HashMap<>(); + params.put("rq", rq); + params.put("bc", bc); + List<FeignWarehousePositionDTO> list = feignProddispApi.selectWarehouseGroupByCp(params); + list.forEach(item -> { + log.info("遍历" + item.getMc()+"煤仓煤种"); + List<FeignMcMzDTO> mzList = feignProddispApi.selectMcMzByMc(item.getMc()); + mzList.stream().forEach( + mz->{ + log.info("插入" + mz.getMz()+"库存"); + FeignWarehouseStockDTO dto = new FeignWarehouseStockDTO(); + dto.setRq(rq); + dto.setBc(bc); + dto.setLsh(new SimpleDateFormat("yyyyMMddhhmmssSSS").format(new Date())); + dto.setBs(item.getMclx()); + dto.setKcmz(mz.getMz()); + dto.setNbzrkc(new BigDecimal(0)); + dto.setNbjrrk(new BigDecimal(0)); + log.info(mz.getProportion().toString()); + log.info(mz.getDen().toString()); + BigDecimal math = item.getNbgl().multiply(BigDecimal.valueOf(mz.getProportion()).divide(BigDecimal.valueOf(mz.getDen()))); + BigDecimal nbjrkc = math.setScale(2, RoundingMode.HALF_UP); + dto.setNbjrkc(nbjrkc); + dto.setNbtzl(new BigDecimal(0)); + dto.setWbzrkc(new BigDecimal(0)); + dto.setWbjrrk(new BigDecimal(0)); + dto.setWbjrkc(dto.getNbjrkc()); + dto.setWbtzl(new BigDecimal(0)); + dto.setCjr(CommonConstant.CJS_SYS); + dto.setCjsj(new Date()); + dto.setXgsj(new Date()); + feignProddispApi.createWarehouseStock(dto); + } + ); + }); + log.info("计算库存结束,rq=" + rq); + } catch (Exception ex) { + log.info("计算库存异常,rq=" + rq); + ex.printStackTrace(); + } + } + + public int getRunMins(List<Map<String, Object>> pointData) { + int seconds = 0; + for (Map<String, Object> item: + pointData) { + if (Boolean.parseBoolean(item.get("value").toString())) { + seconds = seconds + granularity; + } + } + return (seconds / 60); + } + + /** + * getAvgOutput + * + * @param indexDataItemEntity + * @param output + * @param hours + * @return + */ + public BigDecimal getAvgOutput(IndexDataItemEntity indexDataItemEntity, BigDecimal output, BigDecimal hours) { + BigDecimal result = BigDecimal.ZERO; + if (hours.compareTo(BigDecimal.ZERO) > 0) { + result = output.divide(hours, 0, BigDecimal.ROUND_HALF_UP); + } + return result; + } + + /** + * buildIndexDataValueEntity + * + * @param indexDataItemEntity + * @param clock + * @param valueMap + * @return + */ + public IndexDataValueEntity buildIndexDataValueEntity(IndexDataItemEntity indexDataItemEntity, String clock, + Map<String, BigDecimal> valueMap) { + IndexDataValueEntity entity = new IndexDataValueEntity(); + entity.setId(UUID.randomUUID().toString().replace("-","")); + entity.setConfigId(indexDataItemEntity.getId()); + entity.setUnit2(indexDataItemEntity.getUnit2()); + entity.setSsdw(indexDataItemEntity.getSsdw()); + entity.setItemCode(indexDataItemEntity.getItemCode()); + entity.setItemName(indexDataItemEntity.getItemName()); + entity.setUnit(indexDataItemEntity.getUnit()); + entity.setClock(clock); + entity.setSumValue(valueMap.get("sumValue")); + entity.setAvgValue(valueMap.get("avgValue")); + entity.setReportValue(valueMap.get("reportValue")); + entity.setReportHourValue(valueMap.get("reportHourValue")); + entity.setCollectValue(valueMap.get("collectValue")); + entity.setCollectHourValue(valueMap.get("collectHourValue")); + entity.setStartUpTimes(valueMap.get("startUpTimes")); + entity.setCreateTime(new Date()); + return entity; + } + + /** + * getAvgValue + * + * @param dataMap + * @return + */ + public BigDecimal getAvgValue (LinkedHashMap<String, BigDecimal> dataMap) { + BigDecimal avgValue = BigDecimal.ZERO; + double sumValue = 0d; + if (!CollectionUtils.isEmpty(dataMap)) { + int size = dataMap.size(); + for (Map.Entry<String, BigDecimal> item : dataMap.entrySet()) { + if (item.getValue() != null && item.getValue().compareTo(BigDecimal.ZERO) > 0) { + sumValue = sumValue + item.getValue().doubleValue(); + } + } + avgValue = new BigDecimal(sumValue).divide(new BigDecimal(size), 2, BigDecimal.ROUND_HALF_UP); + } + return avgValue; + } + + /** + * getRunHours + * + * @param dataMap + * @return + */ + public BigDecimal getRunHours (LinkedHashMap<String, BigDecimal> dataMap) { + BigDecimal result = BigDecimal.ZERO; + if (!CollectionUtils.isEmpty(dataMap)) { + int mins = 0; + for (Map.Entry<String, BigDecimal> item : dataMap.entrySet()) { + if (item.getValue() != null && item.getValue().compareTo(BigDecimal.ZERO) > 0) { + mins++; + } + } + result = new BigDecimal(mins).divide(hourMins, 2, BigDecimal.ROUND_HALF_UP); + } + return result; + } + + /** + * getStartUpTimes + * + * @param pointData + * @return + */ + public int getStartUpTimes (List<Map<String, Object>> pointData) { + int times = 0; + Boolean lastValue = Boolean.FALSE; + for (Map<String, Object> item: + pointData) { + Boolean itemValue = Boolean.parseBoolean(item.get("value").toString()); + if (itemValue.compareTo(lastValue) != 0) { + times++; + } + lastValue = itemValue; + } + return times; + } + + /** + * 完善数据 + * + * @param length + * @param sourceDataMap + * @param startTime + * @param endTime + * @return + */ + public LinkedHashMap<String, BigDecimal> completionData(int length, LinkedHashMap<String, BigDecimal> sourceDataMap, Date startTime, Date endTime) { + if (CollectionUtils.isEmpty(sourceDataMap) || length <= sourceDataMap.size()) { + return sourceDataMap; + } + log.info("补全数据, length =" + length + "; size = " + sourceDataMap.size() + "; startTime = " + startTime.getTime() + "; endTime = " + endTime.getTime()); + + //找出缺少项 + long oneMin = 1000 * 60; + long start = startTime.getTime(); + long end = endTime.getTime(); + long mins = ((end - start) / oneMin); + LinkedHashMap<String, BigDecimal> dataMap = new LinkedHashMap<>(); + for (int i = 0; i < mins; i ++) { + String key = DateUtils.format(new Date(start + oneMin * i), ""); + dataMap.put(key, sourceDataMap.get(key)); + } + + //补充缺少项 + int k = 0; + Map.Entry<String, BigDecimal> lastItem = null; + for (Map.Entry<String, BigDecimal> item : dataMap.entrySet()) { + if (k == 0 && item.getValue() == null) { + item.setValue(getFirstValue(dataMap)); + } else if (item.getValue() == null) { + item.setValue(lastItem.getValue()); + } + k ++; + lastItem = item; + } + log.info("补全完成"); + return dataMap; + } + + /** + * getFirstValue + * + * @param dataMap + * @return + */ + private BigDecimal getFirstValue(LinkedHashMap<String, BigDecimal> dataMap) { + for (Map.Entry<String, BigDecimal> item : dataMap.entrySet()) { + if (item.getValue() != null) { + return item.getValue(); + } + } + return null; + } +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/indexdata/controller/admin/IndexDataClockController.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/indexdata/controller/admin/IndexDataClockController.java new file mode 100644 index 0000000..dfab56b --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/indexdata/controller/admin/IndexDataClockController.java @@ -0,0 +1,109 @@ +package com.iailab.module.data.indexdata.controller.admin; + +import com.iailab.module.data.common.utils.PageUtils; +import com.iailab.module.data.common.utils.R; +import com.iailab.framework.security.core.util.SecurityFrameworkUtils; +import com.iailab.module.data.indexdata.entity.IndexDataClockEntity; +import com.iailab.module.data.indexdata.service.IndexDataClockService; +import javax.annotation.Resource; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; +import org.springframework.web.bind.annotation.*; + +import java.util.Date; +import java.util.List; +import java.util.Map; + +/** + * @author PanZhibao + * @Description + * @createTime 2022年09月08日 21:52:00 + */ +@RestController +@RequestMapping("/data/index-data/clock") +@Tag(name = "数据采集-index-data-clock") +public class IndexDataClockController { + + @Resource + private IndexDataClockService indexDataClockService; + + /** + * 所有时钟配置列表 + */ + @GetMapping("/list") + @Operation(summary = "查询列表") + public R list(@RequestParam Map<String, Object> params){ + PageUtils page = indexDataClockService.queryPage(params); + return R.ok().put("page", page); + } + + /** + * 采集点列表(全部) + */ + @GetMapping("/list/all") + public R queryAll(@RequestParam Map<String, Object> params){ + List<IndexDataClockEntity> data = indexDataClockService.queryList(params); + return R.ok().put("data", data); + } + + /** + * 新增时钟配置 + * + * @param indexDataClockEntity + * @return + */ + @PostMapping("/add") + public R add(@RequestBody IndexDataClockEntity indexDataClockEntity) { + int count = indexDataClockService.cheack(indexDataClockEntity); + if (count > 0) { + return R.error("名称或编号重复"); + } + indexDataClockEntity.setCreateBy(SecurityFrameworkUtils.getLoginUserId().toString()); + indexDataClockEntity.setCreateTime(new Date()); + indexDataClockService.add(indexDataClockEntity); + return R.ok(); + } + + /** + * 更新时钟配置 + * + * @param indexDataClockEntity + * @return + */ + @PostMapping("/update") + public R update(@RequestBody IndexDataClockEntity indexDataClockEntity) { + int count = indexDataClockService.cheack(indexDataClockEntity); + if (count > 0) { + return R.error("名称或编号重复"); + } + indexDataClockEntity.setUpdateBy(SecurityFrameworkUtils.getLoginUserId().toString()); + indexDataClockService.update(indexDataClockEntity); + return R.ok(); + } + + /** + * 删除时钟配置 + * + * @param params + * @return + */ + @PostMapping("/delete") + public R delete(@RequestParam Map<String, Object> params) { + String id = (String)params.get("id"); + indexDataClockService.deleteById(id); + return R.ok(); + } + + /** + * 时钟配置详情 + * + * @param id + * @return + */ + @RequestMapping("/info/{id}") + public R info(@PathVariable("id") String id){ + IndexDataClockEntity indexDataClockEntity = indexDataClockService.getInfoById(id); + return R.ok().put("data", indexDataClockEntity); + } +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/indexdata/controller/admin/IndexDataItemController.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/indexdata/controller/admin/IndexDataItemController.java new file mode 100644 index 0000000..0c80f84 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/indexdata/controller/admin/IndexDataItemController.java @@ -0,0 +1,93 @@ +package com.iailab.module.data.indexdata.controller.admin; + +import com.iailab.module.data.common.utils.PageUtils; +import com.iailab.module.data.common.utils.R; +import com.iailab.framework.security.core.util.SecurityFrameworkUtils; +import com.iailab.module.data.indexdata.service.IndexDataItemService; +import com.iailab.module.data.indexdata.entity.IndexDataItemEntity; +import javax.annotation.Resource; +import org.springframework.web.bind.annotation.*; + +import java.util.Date; +import java.util.Map; + +/** + * @author PanZhibao + * @Description + * @createTime 2022年09月08日 21:53:00 + */ +@RestController +@RequestMapping("/data/index-data/item") +public class IndexDataItemController { + @Resource + private IndexDataItemService indexDataItemService; + + /** + * 所有数据项目列表 + */ + @GetMapping("/list") + public R list(@RequestParam Map<String, Object> params){ + PageUtils page = indexDataItemService.queryPage(params); + return R.ok().put("page", page); + } + + /** + * 新增数据项目 + * + * @param enity + * @return + */ + @PostMapping("/add") + public R add(@RequestBody IndexDataItemEntity enity) { + enity.setId(null); + int count = indexDataItemService.cheack(enity); + if (count > 0) { + return R.error("名称或编号重复"); + } + enity.setCreateBy(SecurityFrameworkUtils.getLoginUserId().toString()); + enity.setCreateTime(new Date()); + indexDataItemService.add(enity); + return R.ok(); + } + + /** + * 更新数据项目 + * + * @param enity + * @return + */ + @PostMapping("/update") + public R update(@RequestBody IndexDataItemEntity enity) { + int count = indexDataItemService.cheack(enity); + if (count > 0) { + return R.error("名称或编号重复"); + } + enity.setUpdateBy(SecurityFrameworkUtils.getLoginUserId().toString()); + indexDataItemService.update(enity); + return R.ok(); + } + + /** + * 删除数据项目 + * + * @param ids + * @return + */ + @PostMapping("/delete") + public R delete(@RequestBody String[] ids) { + indexDataItemService.deleteBatch(ids); + return R.ok(); + } + + /** + * 数据项目详情 + * + * @param id + * @return + */ + @RequestMapping("/info/{id}") + public R info(@PathVariable("id") String id){ + IndexDataItemEntity enity = indexDataItemService.getInfoById(id); + return R.ok().put("data", enity); + } +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/indexdata/controller/admin/IndexDataValueController.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/indexdata/controller/admin/IndexDataValueController.java new file mode 100644 index 0000000..b7c284b --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/indexdata/controller/admin/IndexDataValueController.java @@ -0,0 +1,34 @@ +package com.iailab.module.data.indexdata.controller.admin; + +import com.iailab.module.data.common.utils.PageUtils; +import com.iailab.module.data.common.utils.R; +import com.iailab.module.data.indexdata.service.IndexDataValueService; +import javax.annotation.Resource; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +import java.util.Map; + +/** + * @author PanZhibao + * @Description + * @createTime 2022年09月08日 21:53:00 + */ +@RestController +@RequestMapping("/data/index-data/value") +public class IndexDataValueController { + + @Resource + private IndexDataValueService indexDataValueService; + + /** + * 所有数据值列表 + */ + @GetMapping("/list") + public R list(@RequestParam Map<String, Object> params){ + PageUtils page = indexDataValueService.queryPage(params); + return R.ok().put("page", page); + } +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/indexdata/controller/package-info.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/indexdata/controller/package-info.java new file mode 100644 index 0000000..6855a76 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/indexdata/controller/package-info.java @@ -0,0 +1 @@ +package com.iailab.module.data.indexdata.controller; \ No newline at end of file diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/indexdata/dao/IndexDataClockDao.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/indexdata/dao/IndexDataClockDao.java new file mode 100644 index 0000000..48bad3b --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/indexdata/dao/IndexDataClockDao.java @@ -0,0 +1,14 @@ +package com.iailab.module.data.indexdata.dao; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.iailab.module.data.indexdata.entity.IndexDataClockEntity; +import org.apache.ibatis.annotations.Mapper; + +/** + * @author PanZhibao + * @Description + * @createTime 2022年09月08日 21:36:00 + */ +@Mapper +public interface IndexDataClockDao extends BaseMapper<IndexDataClockEntity> { +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/indexdata/dao/IndexDataItemDao.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/indexdata/dao/IndexDataItemDao.java new file mode 100644 index 0000000..9761202 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/indexdata/dao/IndexDataItemDao.java @@ -0,0 +1,14 @@ +package com.iailab.module.data.indexdata.dao; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.iailab.module.data.indexdata.entity.IndexDataItemEntity; +import org.apache.ibatis.annotations.Mapper; + +/** + * @author PanZhibao + * @Description + * @createTime 2022年09月08日 21:45:00 + */ +@Mapper +public interface IndexDataItemDao extends BaseMapper<IndexDataItemEntity> { +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/indexdata/dao/IndexDataValueDao.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/indexdata/dao/IndexDataValueDao.java new file mode 100644 index 0000000..ced54b6 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/indexdata/dao/IndexDataValueDao.java @@ -0,0 +1,17 @@ +package com.iailab.module.data.indexdata.dao; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.iailab.module.data.indexdata.entity.IndexDataValueEntity; +import com.iailab.module.data.indexdata.entity.IndexDataValueEntity; +import com.iailab.module.data.indexdata.entity.IndexDataValueEntity; +import com.iailab.module.data.indexdata.entity.IndexDataValueEntity; +import org.apache.ibatis.annotations.Mapper; + +/** + * @author PanZhibao + * @Description + * @createTime 2022年09月08日 21:45:00 + */ +@Mapper +public interface IndexDataValueDao extends BaseMapper<IndexDataValueEntity> { +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/indexdata/entity/IndexDataClockEntity.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/indexdata/entity/IndexDataClockEntity.java new file mode 100644 index 0000000..86dc14e --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/indexdata/entity/IndexDataClockEntity.java @@ -0,0 +1,85 @@ +package com.iailab.module.data.indexdata.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import com.iailab.framework.excel.core.annotations.DictFormat; +import lombok.Data; + +import java.util.Date; + +/** + * @author PanZhibao + * @Description + * @createTime 2022年09月08日 18:26:00 + */ +@Data +@TableName("t_index_data_clock") +public class IndexDataClockEntity { + + /** + * ID + */ + @TableId(type = IdType.ASSIGN_ID) + private String id; + + /** + * 时钟代码 + */ + private String clockCode; + + /** + * 时钟名称 + */ + private String clockName; + + /** + * 类别 + */ + private String clockType; + + /** + * 类别 + */ + @DictFormat("clock-type") + @TableField(exist = false) + private String clockTypeName; + + /** + * 描述 + */ + private String description; + + /** + * 状态 + */ + private Integer status; + + /** + * 状态 + */ + @DictFormat("enable") + @TableField(exist = false) + private String statusName; + + /** + * 创建人 + */ + private String createBy; + + /** + * 创建时间 + */ + private Date createTime; + + /** + * 更新人 + */ + private String updateBy; + + /** + * 更新时间 + */ + private Date updateTime; +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/indexdata/entity/IndexDataItemEntity.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/indexdata/entity/IndexDataItemEntity.java new file mode 100644 index 0000000..7fe6d71 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/indexdata/entity/IndexDataItemEntity.java @@ -0,0 +1,184 @@ +package com.iailab.module.data.indexdata.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import com.iailab.framework.excel.core.annotations.DictFormat; +import lombok.Data; + +import java.math.BigDecimal; +import java.util.Date; + +/** + * @author PanZhibao + * @Description + * @createTime 2022年09月08日 18:28:00 + */ +@Data +@TableName("t_index_data_item") +public class IndexDataItemEntity { + + /** + * ID + */ + @TableId(type = IdType.ASSIGN_ID) + private String id; + + /** + * 所属公司 + */ + private String unit2; + + /** + * 所属公司 + */ + //@Dict(dicCode = "unit2", itemValue = "unit2") + @TableField(exist = false) + private String unit2Name; + + /** + * 所属单位 + */ + private String ssdw; + + /** + * 所属单位 + */ + //@Dict(dicCode = "ssdw", itemValue = "ssdw") + @TableField(exist = false) + private String ssdwName; + + /** + * 项目代码 + */ + private String itemCode; + + /** + * 项目名称 + */ + private String itemName; + + /** + * 点编码 + */ + private String pointCode; + + /** + * 点名称 + */ + private String pointName; + + /** + * 类别 + */ + private String itemType; + + /** + * 类别 + */ + @DictFormat("data-item-type") + @TableField(exist = false) + private String itemTypeName; + + /** + * 默认值 + */ + private BigDecimal defaultValue; + + /** + * 描述 + */ + private String description; + + /** + * 单位 + */ + private String unit; + + /** + * 配置时间 + */ + private String clockConfig; + + /** + * 班次 + */ + private String bc; + + /** + * 班次 + */ + @DictFormat("bc") + @TableField(exist = false) + private String bcName; + + /** + * 系统 + */ + private String xtCode; + + /** + * 系统 + */ + @DictFormat("scxt") + @TableField(exist = false) + private String xtName; + + /** + * 拓展字段1 + */ + private String ext1; + + /** + * 拓展字段2 + */ + private String ext2; + + /** + * 拓展字段3 + */ + private String ext3; + + /** + * 拓展字段4 + */ + private String ext4; + + /** + * 拓展字段5 + */ + private String ext5; + + /** + * 状态 + */ + private Integer status; + + /** + * 状态 + */ + @DictFormat("enable") + @TableField(exist = false) + private String statusName; + + /** + * 创建人 + */ + private String createBy; + + /** + * 创建时间 + */ + private Date createTime; + + /** + * 更新人 + */ + private String updateBy; + + /** + * 更新时间 + */ + private Date updateTime; +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/indexdata/entity/IndexDataValueEntity.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/indexdata/entity/IndexDataValueEntity.java new file mode 100644 index 0000000..332917d --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/indexdata/entity/IndexDataValueEntity.java @@ -0,0 +1,121 @@ +package com.iailab.module.data.indexdata.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import com.iailab.framework.excel.core.annotations.DictFormat; +import lombok.Data; + +import java.math.BigDecimal; +import java.util.Date; + +/** + * @author PanZhibao + * @Description + * @createTime 2022年09月08日 18:30:00 + */ +@Data +@TableName("t_index_data_value") +public class IndexDataValueEntity { + + /** + * ID + */ + @TableId(type = IdType.ASSIGN_ID) + private String id; + + /** + * 配置ID + */ + private String configId; + + /** + * 所属公司 + */ + private String unit2; + + /** + * 所属公司 + */ + @DictFormat("unit2") + @TableField(exist = false) + private String unit2Name; + + /** + * 所属单位 + */ + private String ssdw; + + /** + * 所属单位 + */ + @DictFormat("ssdw") + @TableField(exist = false) + private String ssdwName; + + /** + * 项目代码 + */ + private String itemCode; + + /** + * 项目名称 + */ + private String itemName; + + /** + * 单位 + */ + private String unit; + + /** + * 时间 + */ + private String clock; + + /** + * 累计值 + */ + private BigDecimal sumValue; + + /** + * 平均值 + */ + private BigDecimal avgValue; + + /** + * 上报值 + */ + private BigDecimal reportValue; + + /** + * 上报小时值 + */ + private BigDecimal reportHourValue; + + /** + * 采集值 + */ + private BigDecimal collectValue; + + /** + * 采集小时值 + */ + private BigDecimal collectHourValue; + + /** + * 启动次数 + */ + private BigDecimal startUpTimes; + + /** + * 创建时间 + */ + private Date createTime; + + /** + * 更新时间 + */ + private Date updateTime; +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/indexdata/service/IndexDataClockService.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/indexdata/service/IndexDataClockService.java new file mode 100644 index 0000000..1147bd5 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/indexdata/service/IndexDataClockService.java @@ -0,0 +1,31 @@ +package com.iailab.module.data.indexdata.service; + +import com.iailab.module.data.common.utils.PageUtils; +import com.iailab.module.data.indexdata.entity.IndexDataClockEntity; + +import java.util.List; +import java.util.Map; + +/** + * @author PanZhibao + * @Description + * @createTime 2022年09月08日 21:47:00 + */ +public interface IndexDataClockService { + + PageUtils queryPage(Map<String, Object> params); + + List<IndexDataClockEntity> queryList(Map<String, Object> params); + + void add(IndexDataClockEntity indexDataClockEntity); + + void update(IndexDataClockEntity indexDataClockEntity); + + void deleteById(String id); + + IndexDataClockEntity getInfoById(String id); + + IndexDataClockEntity getInfoByCode(String clockCode); + + int cheack(IndexDataClockEntity idexDataClockEntity); +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/indexdata/service/IndexDataItemService.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/indexdata/service/IndexDataItemService.java new file mode 100644 index 0000000..22d6369 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/indexdata/service/IndexDataItemService.java @@ -0,0 +1,31 @@ +package com.iailab.module.data.indexdata.service; + +import com.iailab.module.data.common.utils.PageUtils; +import com.iailab.module.data.indexdata.entity.IndexDataItemEntity; + +import java.util.List; +import java.util.Map; + +/** + * @author PanZhibao + * @Description + * @createTime 2022年09月08日 21:47:00 + */ +public interface IndexDataItemService { + + PageUtils queryPage(Map<String, Object> params); + + List<IndexDataItemEntity> getListByClockConfig(String clockConfig); + + void add(IndexDataItemEntity enity); + + void update(IndexDataItemEntity enity); + + void deleteById(String id); + + void deleteBatch(String[] ids); + + IndexDataItemEntity getInfoById(String id); + + int cheack(IndexDataItemEntity enity); +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/indexdata/service/IndexDataValueService.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/indexdata/service/IndexDataValueService.java new file mode 100644 index 0000000..cab2841 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/indexdata/service/IndexDataValueService.java @@ -0,0 +1,18 @@ +package com.iailab.module.data.indexdata.service; + +import com.iailab.module.data.common.utils.PageUtils; +import com.iailab.module.data.indexdata.entity.IndexDataValueEntity; + +import java.util.Map; + +/** + * @author PanZhibao + * @Description + * @createTime 2022年09月08日 21:48:00 + */ +public interface IndexDataValueService { + + PageUtils queryPage(Map<String, Object> params); + + void add(IndexDataValueEntity indexDataValueEntity); +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/indexdata/service/impl/IndexDataClockServiceImpl.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/indexdata/service/impl/IndexDataClockServiceImpl.java new file mode 100644 index 0000000..176952f --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/indexdata/service/impl/IndexDataClockServiceImpl.java @@ -0,0 +1,87 @@ +package com.iailab.module.data.indexdata.service.impl; + +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.iailab.module.data.common.enums.CommonConstant; +import com.iailab.module.data.common.utils.PageUtils; +import com.iailab.module.data.common.utils.Query; +import com.iailab.module.data.indexdata.dao.IndexDataClockDao; +import com.iailab.module.data.indexdata.entity.IndexDataClockEntity; +import com.iailab.module.data.indexdata.service.IndexDataClockService; +import org.apache.commons.lang3.StringUtils; +import org.springframework.stereotype.Service; + +import java.util.List; +import java.util.Map; + +/** + * @author PanZhibao + * @Description + * @createTime 2022年09月08日 21:49:00 + */ +@Service +public class IndexDataClockServiceImpl extends ServiceImpl<IndexDataClockDao, IndexDataClockEntity> implements IndexDataClockService { + + @Override + public PageUtils queryPage(Map<String, Object> params) { + String clockCode = (String)params.get("clockCode"); + String clockName = (String)params.get("clockName"); + + IPage<IndexDataClockEntity> page = this.page( + new Query<IndexDataClockEntity>().getPage(params), + new QueryWrapper<IndexDataClockEntity>() + .like(StringUtils.isNotBlank(clockCode),"clock_code", clockCode) + .like(StringUtils.isNotBlank(clockName),"clock_name", clockName) + .orderByDesc("create_time") + ); + return new PageUtils(page); + } + + @Override + public List<IndexDataClockEntity> queryList(Map<String, Object> params) { + return getBaseMapper().selectList( + new QueryWrapper<IndexDataClockEntity>().eq("status", CommonConstant.IS_ENABLE) + .orderByDesc("create_time") + ); + } + + @Override + public void add(IndexDataClockEntity indexDataClockEntity) { + this.save(indexDataClockEntity); + } + + @Override + public void update(IndexDataClockEntity indexDataClockEntity) { + this.updateById(indexDataClockEntity); + } + + @Override + public void deleteById(String id) { + this.removeById(id); + } + + @Override + public IndexDataClockEntity getInfoById(String id) { + return this.getById(id); + } + + @Override + public IndexDataClockEntity getInfoByCode(String clockCode) { + return getBaseMapper().selectOne(new QueryWrapper<IndexDataClockEntity>() + .eq("clock_code", clockCode) + .eq("status", CommonConstant.IS_ENABLE)); + } + + @Override + public int cheack(IndexDataClockEntity indexDataClockEntity) { + String id = indexDataClockEntity.getId(); + String clockCode = indexDataClockEntity.getClockCode(); + String clockName = indexDataClockEntity.getClockName(); + QueryWrapper<IndexDataClockEntity> queryWrapper = new QueryWrapper<>(); + queryWrapper.ne(StringUtils.isNotBlank(id), "id", id); + queryWrapper.and(wrapper -> wrapper.eq("clock_code", clockCode).or(). + eq(StringUtils.isNotBlank(clockName),"clock_name", clockName)); + return (int)this.count(queryWrapper); + } +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/indexdata/service/impl/IndexDataItemServiceImpl.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/indexdata/service/impl/IndexDataItemServiceImpl.java new file mode 100644 index 0000000..c0558a4 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/indexdata/service/impl/IndexDataItemServiceImpl.java @@ -0,0 +1,86 @@ +package com.iailab.module.data.indexdata.service.impl; + +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.iailab.module.data.common.enums.CommonConstant; +import com.iailab.module.data.common.utils.PageUtils; +import com.iailab.module.data.common.utils.Query; +import com.iailab.module.data.indexdata.dao.IndexDataItemDao; +import com.iailab.module.data.indexdata.service.IndexDataItemService; +import com.iailab.module.data.indexdata.entity.IndexDataItemEntity; +import org.apache.commons.lang3.StringUtils; +import org.springframework.stereotype.Service; + +import java.util.Arrays; +import java.util.List; +import java.util.Map; + +/** + * @author PanZhibao + * @Description + * @createTime 2022年09月08日 21:49:00 + */ +@Service +public class IndexDataItemServiceImpl extends ServiceImpl<IndexDataItemDao, IndexDataItemEntity> implements IndexDataItemService { + + @Override + public PageUtils queryPage(Map<String, Object> params) { + String itemCode = (String)params.get("itemCode"); + String itemName = (String)params.get("itemName"); + + IPage<IndexDataItemEntity> page = this.page( + new Query<IndexDataItemEntity>().getPage(params), + new QueryWrapper<IndexDataItemEntity>() + .like(StringUtils.isNotBlank(itemCode),"item_code", itemCode) + .like(StringUtils.isNotBlank(itemName),"item_name", itemName) + .orderByDesc("create_time") + ); + return new PageUtils(page); + } + + @Override + public List<IndexDataItemEntity> getListByClockConfig(String clockConfig) { + return getBaseMapper().selectList(new QueryWrapper<IndexDataItemEntity>() + .eq("clock_config", clockConfig) + .eq("status", CommonConstant.IS_ENABLE)); + + } + + @Override + public void add(IndexDataItemEntity enity) { + this.save(enity); + } + + @Override + public void update(IndexDataItemEntity enity) { + this.updateById(enity); + } + + @Override + public void deleteById(String id) { + this.removeById(id); + } + + @Override + public void deleteBatch(String[] ids) { + this.removeByIds(Arrays.asList(ids)); + } + + @Override + public IndexDataItemEntity getInfoById(String id) { + return this.getById(id); + } + + @Override + public int cheack(IndexDataItemEntity enity) { + String id = enity.getId(); + String itemCode = enity.getItemCode(); + String itemName = enity.getItemName(); + QueryWrapper<IndexDataItemEntity> queryWrapper = new QueryWrapper<>(); + queryWrapper.ne(StringUtils.isNotBlank(id), "id", id); + queryWrapper.and(wrapper -> wrapper.eq("item_code", itemCode).or(). + eq(StringUtils.isNotBlank(itemName),"item_name", itemName)); + return (int)this.count(queryWrapper); + } +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/indexdata/service/impl/IndexDataValueServiceImpl.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/indexdata/service/impl/IndexDataValueServiceImpl.java new file mode 100644 index 0000000..b49a921 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/indexdata/service/impl/IndexDataValueServiceImpl.java @@ -0,0 +1,55 @@ +package com.iailab.module.data.indexdata.service.impl; + +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.iailab.module.data.common.utils.PageUtils; +import com.iailab.module.data.common.utils.Query; +import com.iailab.module.data.indexdata.dao.IndexDataValueDao; +import com.iailab.module.data.indexdata.entity.IndexDataValueEntity; +import com.iailab.module.data.indexdata.service.IndexDataValueService; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.Map; + +/** + * @author PanZhibao + * @Description + * @createTime 2022年09月08日 21:49:00 + */ + +@Slf4j +@Service +public class IndexDataValueServiceImpl extends ServiceImpl<IndexDataValueDao, IndexDataValueEntity> implements IndexDataValueService { + + @Override + public PageUtils queryPage(Map<String, Object> params) { + String clock = (String)params.get("clock"); + String itemCode = (String)params.get("itemCode"); + + IPage<IndexDataValueEntity> page = this.page( + new Query<IndexDataValueEntity>().getPage(params), + new QueryWrapper<IndexDataValueEntity>() + .like(StringUtils.isNotBlank(clock),"clock", clock) + .like(StringUtils.isNotBlank(itemCode),"item_code", itemCode) + .orderByDesc("create_time") + ); + return new PageUtils(page); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void add(IndexDataValueEntity indexDataValueEntity) { + log.info("插入指标数据表2"); + getBaseMapper().delete(new QueryWrapper<IndexDataValueEntity>() + .eq("unit2", indexDataValueEntity.getUnit2()) + .eq("ssdw", indexDataValueEntity.getSsdw()) + .eq("item_code", indexDataValueEntity.getItemCode()) + .eq("clock", indexDataValueEntity.getClock())); + + this.save(indexDataValueEntity); + } +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/influxdb/common/config/InfluxDBInstance.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/influxdb/common/config/InfluxDBInstance.java new file mode 100644 index 0000000..7803bec --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/influxdb/common/config/InfluxDBInstance.java @@ -0,0 +1,46 @@ +package com.iailab.module.data.influxdb.common.config; + +import com.influxdb.client.InfluxDBClient; +import com.influxdb.client.InfluxDBClientFactory; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Component; + +/** + * @author PanZhibao + * @Description + * @createTime 2023年04月25日 17:13:00 + */ +@Component +public class InfluxDBInstance { + + @Value("${influx-db.org}") + public String org; + + @Value("${influx-db.bucket}") + public String bucket; + + @Value("${influx-db.token}") + public String token; + + @Value("${influx-db.url}") + public String url; + + private Logger logger = LoggerFactory.getLogger(getClass()); + + private InfluxDBClient client; + + public InfluxDBClient getClient() { + try { + if (client == null) { + client = InfluxDBClientFactory.create(url, token.toCharArray()); + } + } catch (Exception ex) { + ex.printStackTrace(); + logger.error("创建InfluxDBClient失败!"); + } + return client; + } + +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/influxdb/common/enums/DataMeasurement.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/influxdb/common/enums/DataMeasurement.java new file mode 100644 index 0000000..24ee1ff --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/influxdb/common/enums/DataMeasurement.java @@ -0,0 +1,19 @@ +package com.iailab.module.data.influxdb.common.enums; + +/** + * 数据表 + * + * @author PanZhibao + * @Description + * @createTime 2023年04月24日 15:13:00 + */ +public enum DataMeasurement { + t_da_sim_value, + t_da_dig_value, + t_da_bool_value, + t_da_str_value, + t_tag_int_value, + t_tag_float_value, + t_tag_bool_value, + t_tag_str_value; +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/influxdb/common/utils/PointValueUtils.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/influxdb/common/utils/PointValueUtils.java new file mode 100644 index 0000000..b7a47a9 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/influxdb/common/utils/PointValueUtils.java @@ -0,0 +1,37 @@ +package com.iailab.module.data.influxdb.common.utils; + +import com.iailab.module.data.common.enums.DataTypeEnum; +import com.iailab.module.data.influxdb.common.enums.DataMeasurement; +import com.influxdb.client.write.Point; + +/** + * @author PanZhibao + * @Description + * @createTime 2023年05月08日 10:25:00 + */ +public class PointValueUtils { + + public static void addFileByPointType(Point point, String type, String value) { + if (DataTypeEnum.FLOAT.getCode().equals(type)) { + point.addField("value", Double.parseDouble(value)); + } else if (DataTypeEnum.INT.getCode().equals(type)) { + point.addField("value", Integer.parseInt(value)); + } else if (DataTypeEnum.BOOLEAN.getCode().equals(type)) { + point.addField("value", Boolean.parseBoolean(value)); + } else { + point.addField("value", value); + } + } + + public static String getMeasurement(String type) { + if (DataTypeEnum.FLOAT.getCode().equals(type)) { + return DataMeasurement.t_da_sim_value.name(); + } else if (DataTypeEnum.INT.getCode().equals(type)) { + return DataMeasurement.t_da_dig_value.name(); + } else if (DataTypeEnum.BOOLEAN.getCode().equals(type)) { + return DataMeasurement.t_da_bool_value.name(); + } else { + return DataMeasurement.t_da_str_value.name(); + } + } +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/influxdb/common/utils/TagValueUtils.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/influxdb/common/utils/TagValueUtils.java new file mode 100644 index 0000000..94b6238 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/influxdb/common/utils/TagValueUtils.java @@ -0,0 +1,126 @@ +package com.iailab.module.data.influxdb.common.utils; + +import com.iailab.module.data.common.enums.TagValueTypeConstant; +import com.iailab.module.data.channel.tag.dto.TagValueDTO; +import com.iailab.module.data.influxdb.pojo.*; +import com.iailab.module.data.influxdb.common.enums.DataMeasurement; + +/** + * @author PanZhibao + * @Description + * @createTime 2023年05月03日 23:00:00 + */ +public class TagValueUtils { + + public static Object getByTagType(String type, String value) { + switch (type) { + case TagValueTypeConstant.BOOLEAN: + return Double.parseDouble(value); + case TagValueTypeConstant.INT8: + return Integer.parseInt(value); + case TagValueTypeConstant.INT16: + return Integer.parseInt(value); + case TagValueTypeConstant.INT32: + return Integer.parseInt(value); + case TagValueTypeConstant.INT64: + return Integer.parseInt(value); + case TagValueTypeConstant.UINT8: + return Integer.parseInt(value); + case TagValueTypeConstant.UINT16: + return Double.parseDouble(value); + case TagValueTypeConstant.UINT32: + return Integer.parseInt(value); + case TagValueTypeConstant.UINT64: + return Integer.parseInt(value); + case TagValueTypeConstant.FLOAT: + return Double.parseDouble(value); + case TagValueTypeConstant.DOUBLE: + return Double.parseDouble(value); + default: + break; + } + return value; + } + + public static String getMeasurement(String type) { + switch (type) { + case TagValueTypeConstant.BOOLEAN: + return DataMeasurement.t_tag_bool_value.name(); + case TagValueTypeConstant.INT8: + return DataMeasurement.t_tag_int_value.name(); + case TagValueTypeConstant.INT16: + return DataMeasurement.t_tag_int_value.name(); + case TagValueTypeConstant.INT32: + return DataMeasurement.t_tag_int_value.name(); + case TagValueTypeConstant.INT64: + return DataMeasurement.t_tag_int_value.name(); + case TagValueTypeConstant.UINT8: + return DataMeasurement.t_tag_int_value.name(); + case TagValueTypeConstant.UINT16: + return DataMeasurement.t_tag_int_value.name(); + case TagValueTypeConstant.UINT32: + return DataMeasurement.t_tag_int_value.name(); + case TagValueTypeConstant.UINT64: + return DataMeasurement.t_tag_int_value.name(); + case TagValueTypeConstant.FLOAT: + return DataMeasurement.t_tag_float_value.name(); + case TagValueTypeConstant.DOUBLE: + return DataMeasurement.t_tag_float_value.name(); + default: + return DataMeasurement.t_tag_str_value.name(); + } + } + + public static InfluxTagValuePOJO getByTag(TagValueDTO dto, String value) { + switch (dto.getType()) { + case TagValueTypeConstant.BOOLEAN: + InfluxTagValuePOJO boolPojo = new InfluxTagValueBoolPOJO(); + ((InfluxTagValueBoolPOJO) boolPojo).setValue(Boolean.parseBoolean(value.toString())); + return boolPojo; + case TagValueTypeConstant.INT8: + InfluxTagValuePOJO int8Pojo = new InfluxTagValueIntPOJO(); + ((InfluxTagValueIntPOJO) int8Pojo).setValue(Integer.parseInt(value.toString())); + return int8Pojo; + case TagValueTypeConstant.INT16: + InfluxTagValuePOJO int16Pojo = new InfluxTagValueIntPOJO(); + ((InfluxTagValueIntPOJO) int16Pojo).setValue(Integer.parseInt(value.toString())); + return int16Pojo; + case TagValueTypeConstant.INT32: + InfluxTagValuePOJO int32Pojo = new InfluxTagValueIntPOJO(); + ((InfluxTagValueIntPOJO) int32Pojo).setValue(Integer.parseInt(value.toString())); + return int32Pojo; + case TagValueTypeConstant.INT64: + InfluxTagValuePOJO int64Pojo = new InfluxTagValueIntPOJO(); + ((InfluxTagValueIntPOJO) int64Pojo).setValue(Integer.parseInt(value.toString())); + return int64Pojo; + case TagValueTypeConstant.UINT8: + InfluxTagValuePOJO uint8Pojo = new InfluxTagValueIntPOJO(); + ((InfluxTagValueIntPOJO) uint8Pojo).setValue(Integer.parseInt(value.toString())); + return uint8Pojo; + case TagValueTypeConstant.UINT16: + InfluxTagValuePOJO uint16Pojo = new InfluxTagValueIntPOJO(); + ((InfluxTagValueIntPOJO) uint16Pojo).setValue(Integer.parseInt(value.toString())); + return uint16Pojo; + case TagValueTypeConstant.UINT32: + InfluxTagValuePOJO uint32Pojo = new InfluxTagValueIntPOJO(); + ((InfluxTagValueIntPOJO) uint32Pojo).setValue(Integer.parseInt(value.toString())); + return uint32Pojo; + case TagValueTypeConstant.UINT64: + InfluxTagValuePOJO uint64Pojo = new InfluxTagValueIntPOJO(); + ((InfluxTagValueIntPOJO) uint64Pojo).setValue(Integer.parseInt(value.toString())); + return uint64Pojo; + case TagValueTypeConstant.FLOAT: + InfluxTagValuePOJO floatPojo = new InfluxTagValueFloatPOJO(); + ((InfluxTagValueFloatPOJO) floatPojo).setValue(Double.parseDouble(value.toString())); + return floatPojo; + case TagValueTypeConstant.DOUBLE: + InfluxTagValuePOJO doublePojo = new InfluxTagValueFloatPOJO(); + ((InfluxTagValueFloatPOJO) doublePojo).setValue(Double.parseDouble(value.toString())); + return doublePojo; + default: + InfluxTagValuePOJO strPojo = new InfluxTagValueStrPOJO(); + ((InfluxTagValueStrPOJO) strPojo).setValue(value.toString()); + return strPojo; + } + } +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/influxdb/pojo/InfluxPointValueBoolPOJO.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/influxdb/pojo/InfluxPointValueBoolPOJO.java new file mode 100644 index 0000000..f2b2246 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/influxdb/pojo/InfluxPointValueBoolPOJO.java @@ -0,0 +1,17 @@ +package com.iailab.module.data.influxdb.pojo; + +import com.influxdb.annotations.Column; +import com.influxdb.annotations.Measurement; +import lombok.Data; + +/** + * @author PanZhibao + * @Description + * @createTime 2023年05月08日 13:26:00 + */ +@Data +@Measurement(name = "t_da_bool_value") +public class InfluxPointValueBoolPOJO extends InfluxPointValuePOJO { + @Column + private Boolean value; +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/influxdb/pojo/InfluxPointValueDigPOJO.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/influxdb/pojo/InfluxPointValueDigPOJO.java new file mode 100644 index 0000000..975ee43 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/influxdb/pojo/InfluxPointValueDigPOJO.java @@ -0,0 +1,17 @@ +package com.iailab.module.data.influxdb.pojo; + +import com.influxdb.annotations.Column; +import com.influxdb.annotations.Measurement; +import lombok.Data; + +/** + * @author PanZhibao + * @Description + * @createTime 2023年05月08日 13:25:00 + */ +@Data +@Measurement(name = "t_da_dig_value") +public class InfluxPointValueDigPOJO extends InfluxPointValuePOJO { + @Column() + private Integer value; +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/influxdb/pojo/InfluxPointValuePOJO.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/influxdb/pojo/InfluxPointValuePOJO.java new file mode 100644 index 0000000..b972287 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/influxdb/pojo/InfluxPointValuePOJO.java @@ -0,0 +1,25 @@ +package com.iailab.module.data.influxdb.pojo; + +import com.influxdb.annotations.Column; +import lombok.Data; + +import java.io.Serializable; +import java.time.Instant; + +/** + * @author PanZhibao + * @Description + * @createTime 2023年04月24日 17:27:00 + */ +@Data +public class InfluxPointValuePOJO implements Serializable { + private static final long serialVersionUID = 1L; + + @Column(tag = true) + private String point; + + @Column(timestamp = true) + private Instant timestamp; + + private String type; +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/influxdb/pojo/InfluxPointValueSimPOJO.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/influxdb/pojo/InfluxPointValueSimPOJO.java new file mode 100644 index 0000000..fc021e8 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/influxdb/pojo/InfluxPointValueSimPOJO.java @@ -0,0 +1,18 @@ +package com.iailab.module.data.influxdb.pojo; + +import com.influxdb.annotations.Column; +import com.influxdb.annotations.Measurement; +import lombok.Data; + +/** + * @author PanZhibao + * @Description + * @createTime 2023年05月08日 13:25:00 + */ +@Data +@Measurement(name = "t_da_sim_value") +public class InfluxPointValueSimPOJO extends InfluxPointValuePOJO { + + @Column + private Double value; +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/influxdb/pojo/InfluxPointValueStrPOJO.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/influxdb/pojo/InfluxPointValueStrPOJO.java new file mode 100644 index 0000000..f0ff74d --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/influxdb/pojo/InfluxPointValueStrPOJO.java @@ -0,0 +1,18 @@ +package com.iailab.module.data.influxdb.pojo; + +import com.influxdb.annotations.Column; +import com.influxdb.annotations.Measurement; +import lombok.Data; + +/** + * @author PanZhibao + * @Description + * @createTime 2023年05月08日 13:41:00 + */ +@Data +@Measurement(name = "t_da_str_value") +public class InfluxPointValueStrPOJO extends InfluxPointValuePOJO { + + @Column + private String value; +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/influxdb/pojo/InfluxTagValueBoolPOJO.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/influxdb/pojo/InfluxTagValueBoolPOJO.java new file mode 100644 index 0000000..8c0216c --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/influxdb/pojo/InfluxTagValueBoolPOJO.java @@ -0,0 +1,17 @@ +package com.iailab.module.data.influxdb.pojo; + +import com.influxdb.annotations.Column; +import com.influxdb.annotations.Measurement; +import lombok.Data; + +/** + * @author PanZhibao + * @Description + * @createTime 2023年05月08日 14:22:00 + */ +@Data +@Measurement(name = "t_tag_bool_value") +public class InfluxTagValueBoolPOJO extends InfluxTagValuePOJO { + @Column + private Boolean value; +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/influxdb/pojo/InfluxTagValueFloatPOJO.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/influxdb/pojo/InfluxTagValueFloatPOJO.java new file mode 100644 index 0000000..22a24b5 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/influxdb/pojo/InfluxTagValueFloatPOJO.java @@ -0,0 +1,17 @@ +package com.iailab.module.data.influxdb.pojo; + +import com.influxdb.annotations.Column; +import com.influxdb.annotations.Measurement; +import lombok.Data; + +/** + * @author PanZhibao + * @Description + * @createTime 2023年05月08日 14:21:00 + */ +@Data +@Measurement(name = "t_tag_float_value") +public class InfluxTagValueFloatPOJO extends InfluxTagValuePOJO { + @Column + private Double value; +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/influxdb/pojo/InfluxTagValueIntPOJO.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/influxdb/pojo/InfluxTagValueIntPOJO.java new file mode 100644 index 0000000..be62c74 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/influxdb/pojo/InfluxTagValueIntPOJO.java @@ -0,0 +1,19 @@ +package com.iailab.module.data.influxdb.pojo; + +import com.influxdb.annotations.Column; +import com.influxdb.annotations.Measurement; +import lombok.Data; + +/** + * @author PanZhibao + * @Description + * @createTime 2023年05月08日 14:21:00 + */ +@Data +@Measurement(name = "t_tag_int_value") +public class InfluxTagValueIntPOJO extends InfluxTagValuePOJO { + @Column + private Integer value; + + +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/influxdb/pojo/InfluxTagValuePOJO.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/influxdb/pojo/InfluxTagValuePOJO.java new file mode 100644 index 0000000..4167c5d --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/influxdb/pojo/InfluxTagValuePOJO.java @@ -0,0 +1,26 @@ +package com.iailab.module.data.influxdb.pojo; + +import com.influxdb.annotations.Column; +import lombok.Data; + +import java.io.Serializable; +import java.time.Instant; + +/** + * @author PanZhibao + * @Description + * @createTime 2023年04月24日 16:08:00 + */ +@Data +public class InfluxTagValuePOJO implements Serializable { + private static final long serialVersionUID = 1L; + + @Column(tag = true) + private String id; + + @Column + private String type; + + @Column(timestamp = true) + private Instant timestamp; +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/influxdb/pojo/InfluxTagValueStrPOJO.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/influxdb/pojo/InfluxTagValueStrPOJO.java new file mode 100644 index 0000000..094d570 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/influxdb/pojo/InfluxTagValueStrPOJO.java @@ -0,0 +1,17 @@ +package com.iailab.module.data.influxdb.pojo; + +import com.influxdb.annotations.Column; +import com.influxdb.annotations.Measurement; +import lombok.Data; + +/** + * @author PanZhibao + * @Description + * @createTime 2023年05月08日 14:56:00 + */ +@Data +@Measurement(name = "t_tag_str_value") +public class InfluxTagValueStrPOJO extends InfluxTagValuePOJO { + @Column + private String value; +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/influxdb/service/InfluxDBService.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/influxdb/service/InfluxDBService.java new file mode 100644 index 0000000..bb9f207 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/influxdb/service/InfluxDBService.java @@ -0,0 +1,44 @@ +package com.iailab.module.data.influxdb.service; + +import com.iailab.module.data.influxdb.pojo.InfluxPointValuePOJO; +import com.iailab.module.data.influxdb.pojo.InfluxPointValuePOJO; +import com.iailab.module.data.api.dto.ApiTagValueQueryDTO; +import com.iailab.module.data.influxdb.pojo.InfluxPointValuePOJO; +import com.iailab.module.data.influxdb.pojo.InfluxTagValuePOJO; +import com.iailab.module.data.influxdb.pojo.InfluxPointValuePOJO; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.util.Date; +import java.util.List; +import java.util.Map; + +/** + * InfluxDB操作类 + */ +public interface InfluxDBService { + + void syncWriteFloatValue(String pointNo, String dataValue, long time); + + void syncWriteIntValue(String pointNo, String dataValue, long time); + + void syncWriteBooleanValue(String pointNo, String dataValue, long time); + + void asyncWritePointValues(List<InfluxPointValuePOJO> pointValues); + + void asyncWriteTagValues(List<InfluxTagValuePOJO> tagValues); + + Map<String, Object> queryPointsLastValue(List<InfluxPointValuePOJO> influxParams); + + Map<String, List<Object>> queryTagsValues(List<InfluxTagValuePOJO> influxParams, Date startTime, Date endTime); + + List<Map<String, Object>> queryPointValues(InfluxPointValuePOJO pojo, Date startTime, Date endTime); + + Map<String, List<Map<String, Object>>> queryPointsValues(List<InfluxPointValuePOJO> influxParams, Date startTime, Date endTime); + + Map<String, Object> queryPointsSpread(List<InfluxPointValuePOJO> influxParams, Date startTime, Date endTime); + + boolean exportTagValue(HttpServletResponse response, HttpServletRequest request, ApiTagValueQueryDTO params); + + Object queryPointMaxValue(InfluxPointValuePOJO point, Date startTime); +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/influxdb/service/impl/InfluxDBServiceImpl.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/influxdb/service/impl/InfluxDBServiceImpl.java new file mode 100644 index 0000000..f7c0075 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/influxdb/service/impl/InfluxDBServiceImpl.java @@ -0,0 +1,336 @@ +package com.iailab.module.data.influxdb.service.impl; + +import com.iailab.module.data.common.utils.ExcelUtil; +import com.iailab.framework.common.util.date.DateUtils; +import com.iailab.module.data.api.dto.ApiExportValueDTO; +import com.iailab.module.data.api.dto.ApiTagValueQueryDTO; +import com.iailab.module.data.influxdb.common.config.InfluxDBInstance; +import com.iailab.module.data.influxdb.common.enums.DataMeasurement; +import com.iailab.module.data.influxdb.common.utils.PointValueUtils; +import com.iailab.module.data.influxdb.common.utils.TagValueUtils; +import com.iailab.module.data.influxdb.pojo.InfluxPointValuePOJO; +import com.iailab.module.data.influxdb.pojo.InfluxTagValuePOJO; +import com.iailab.module.data.influxdb.service.InfluxDBService; +import com.influxdb.client.InfluxQLQueryApi; +import com.influxdb.client.QueryApi; +import com.influxdb.client.WriteApi; +import com.influxdb.client.WriteApiBlocking; +import com.influxdb.client.domain.InfluxQLQuery; +import com.influxdb.client.domain.WritePrecision; +import com.influxdb.client.write.Point; +import com.influxdb.query.FluxRecord; +import com.influxdb.query.FluxTable; +import com.influxdb.query.InfluxQLQueryResult; +import lombok.extern.slf4j.Slf4j; +import javax.annotation.Resource; +import org.springframework.stereotype.Service; +import org.springframework.util.CollectionUtils; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.math.BigDecimal; +import java.util.*; + +/** + * InfluxDB操作类 + */ +@Slf4j +@Service +public class InfluxDBServiceImpl implements InfluxDBService { + + @Resource + private InfluxDBInstance influxDBInstance; + + private WriteApi writeApi; + + private WriteApiBlocking writeApiBlocking; + + private QueryApi queryApi; + + private InfluxQLQueryApi influxQLQueryApi; + + private String VALUE = "value"; + + private String TIME = "time"; + + private int rawOffset = TimeZone.getDefault().getRawOffset(); + + private int pas_ms = 1000; + + @Override + public void syncWriteFloatValue(String pointNo, String dataValue, long time) { + if (writeApiBlocking == null) { + writeApiBlocking = influxDBInstance.getClient().getWriteApiBlocking(); + } + Point point = Point.measurement(DataMeasurement.t_da_sim_value.name()); + point.addTag("point", pointNo); + point.addField("value", Double.parseDouble(dataValue)); + point.time(time, WritePrecision.MS); + writeApiBlocking.writePoint(influxDBInstance.bucket, influxDBInstance.org, point); + } + + @Override + public void syncWriteIntValue(String pointNo, String dataValue, long time) { + if (writeApiBlocking == null) { + writeApiBlocking = influxDBInstance.getClient().getWriteApiBlocking(); + } + Point point = Point.measurement(DataMeasurement.t_da_dig_value.name()); + point.addTag("point", pointNo); + point.addField("value", Integer.parseInt(dataValue)); + point.time(time, WritePrecision.MS); + writeApiBlocking.writePoint(influxDBInstance.bucket, influxDBInstance.org, point); + } + + @Override + public void syncWriteBooleanValue(String pointNo, String dataValue, long time) { + if (writeApiBlocking == null) { + writeApiBlocking = influxDBInstance.getClient().getWriteApiBlocking(); + } + Point point = Point.measurement(DataMeasurement.t_da_bool_value.name()); + point.addTag("point", pointNo); + point.addField("value", Boolean.parseBoolean(dataValue)); + point.time(time, WritePrecision.MS); + writeApiBlocking.writePoint(influxDBInstance.bucket, influxDBInstance.org, point); + } + + @Override + public void asyncWritePointValues(List<InfluxPointValuePOJO> pointValues) { + if (writeApi == null) { + writeApi = influxDBInstance.getClient().makeWriteApi(); + } + if (!CollectionUtils.isEmpty(pointValues)) { + pointValues.forEach(item -> { + writeApi.writeMeasurement(influxDBInstance.bucket, influxDBInstance.org, WritePrecision.MS, item); + }); + } + writeApi.flush(); + } + + @Override + public void asyncWriteTagValues(List<InfluxTagValuePOJO> tagValues) { + if (writeApi == null) { + writeApi = influxDBInstance.getClient().makeWriteApi(); + } + if (!CollectionUtils.isEmpty(tagValues)) { + tagValues.forEach(item -> { + writeApi.writeMeasurement(influxDBInstance.bucket, influxDBInstance.org, WritePrecision.MS, item); + }); + } + writeApi.flush(); + } + + @Override + public Map<String, List<Object>> queryTagsValues(List<InfluxTagValuePOJO> influxParams, Date startTime, Date endTime) { + if (queryApi == null) { + queryApi = influxDBInstance.getClient().getQueryApi(); + } + if (CollectionUtils.isEmpty(influxParams)) { + return null; + } + Map<String, List<Object>> result = new HashMap<>(); + Calendar calendar = Calendar.getInstance(); + calendar.set(Calendar.MILLISECOND, 0); + // String start = startTime.getTime() - calendar.getTime().getTime() + "ms"; + String start = startTime.getTime() - calendar.getTime().getTime() - pas_ms + "ms"; + if (endTime==null){ + endTime= new Date(); + } + String stop = endTime.getTime() - calendar.getTime().getTime() + "ms"; + + for (int i = 0; i < influxParams.size(); i++) { + List<Object> dataList = new ArrayList<>(); + InfluxTagValuePOJO tag = influxParams.get(i); + String measurement = TagValueUtils.getMeasurement(tag.getType()); + StringBuilder sb = new StringBuilder(); + sb.append("from(bucket:\"" + influxDBInstance.bucket + "\") "); + sb.append("|> range(start: ").append(start).append(", stop: ").append(stop).append(") "); + sb.append("|> filter(fn: (r) => r[\"_measurement\"] == \"" + measurement + "\")"); + sb.append("|> filter(fn: (r) => r[\"_field\"] == \"value\")"); + sb.append("|> filter(fn: (r) => r[\"id\"] == \"" + tag.getId() + "\")"); + sb.append("|> sort(columns: [\"_time\"]) "); + sb.append("|> yield(name: \"mean\")"); + List<FluxTable> tables = queryApi.query(sb.toString(), influxDBInstance.org); + + for (FluxTable table : tables) { + List<FluxRecord> records = table.getRecords(); + for (FluxRecord record : records) { + Map<String, Object> dataIem = new HashMap<>(2); + dataIem.put(VALUE, record.getValueByKey("_value")); + dataIem.put(TIME, Date.from(record.getTime())); + dataList.add(dataIem); + } + } + result.put(tag.getId(), dataList); + } + return result; + } + + private List<ApiExportValueDTO> getExportValue(InfluxTagValuePOJO tag, Date startTime, Date endTime) { + List<ApiExportValueDTO> dataList = new ArrayList<>(); + if (queryApi == null) { + queryApi = influxDBInstance.getClient().getQueryApi(); + } + Map<String, List<Object>> result = new HashMap<>(); + Calendar calendar = Calendar.getInstance(); + calendar.set(Calendar.MILLISECOND, 0); + String start = startTime.getTime() - calendar.getTime().getTime() + "ms"; + String stop = endTime.getTime() - calendar.getTime().getTime() + "ms"; + + + String measurement = TagValueUtils.getMeasurement(tag.getType()); + StringBuilder sb = new StringBuilder(); + sb.append("from(bucket:\"" + influxDBInstance.bucket + "\") "); + sb.append("|> range(start: ").append(start).append(", stop: ").append(stop).append(") "); + sb.append("|> filter(fn: (r) => r[\"_measurement\"] == \"" + measurement + "\")"); + sb.append("|> filter(fn: (r) => r[\"_field\"] == \"value\")"); + sb.append("|> filter(fn: (r) => r[\"id\"] == \"" + tag.getId() + "\")"); + sb.append("|> sort(columns: [\"_time\"]) "); + sb.append("|> yield(name: \"mean\")"); + List<FluxTable> tables = queryApi.query(sb.toString(), influxDBInstance.org); + + for (FluxTable table : tables) { + List<FluxRecord> records = table.getRecords(); + for (FluxRecord record : records) { + ApiExportValueDTO dataIem = new ApiExportValueDTO(); + dataIem.setDataValue(record.getValueByKey("_value").toString()); + dataIem.setDataTime(DateUtils.format(Date.from(record.getTime()), DateUtils.FORMAT_YEAR_MONTH_DAY)); + dataList.add(dataIem); + } + } + return dataList; + } + + @Override + public boolean exportTagValue(HttpServletResponse response, HttpServletRequest request, ApiTagValueQueryDTO params) { + InfluxTagValuePOJO tag = new InfluxTagValuePOJO(); + tag.setId(params.getTagId()); + tag.setType(params.getDataType()); + List<ApiExportValueDTO> valueList = getExportValue(tag, params.getStart(), params.getEnd()); + try{ + String sheetTitle = "采集数据"; + String[] title = new String[]{"值", "时间"}; + ExcelUtil.exportPointValue(sheetTitle, title, new ArrayList<>(valueList), response); + } catch (Exception ex) { + return false; + } + return true; + } + + + @Override + public Map<String, Object> queryPointsLastValue(List<InfluxPointValuePOJO> influxParams) { + Map<String, Object> result = new HashMap<>(influxParams.size()); + if (influxQLQueryApi == null) { + influxQLQueryApi = influxDBInstance.getClient().getInfluxQLQueryApi(); + } + for (int i = 0; i < influxParams.size(); i++) { + InfluxPointValuePOJO point = influxParams.get(i); + String measurement = PointValueUtils.getMeasurement(point.getType()); + StringBuilder sql = new StringBuilder(); + sql.append("SELECT LAST(value) FROM "); + sql.append(measurement); + sql.append(" WHERE point = '"); + sql.append(point.getPoint()); + sql.append("'"); + InfluxQLQueryResult data = influxQLQueryApi.query(new InfluxQLQuery(sql.toString(), influxDBInstance.bucket)); + Object value = data.getResults().get(0).getSeries().get(0).getValues().get(0).getValueByKey("last"); + result.put(point.getPoint(), value); + } + return result; + } + + @Override + public Object queryPointMaxValue(InfluxPointValuePOJO point, Date startTime) { + if (influxQLQueryApi == null) { + influxQLQueryApi = influxDBInstance.getClient().getInfluxQLQueryApi(); + } + long utcMillis = startTime.getTime() -rawOffset; + String utsStart = DateUtils.format(new Date(utcMillis), DateUtils.FORMAT_YEAR_MONTH_DAY); + log.info("utsStart=" + utsStart); + String measurement = PointValueUtils.getMeasurement(point.getType()); + StringBuilder sql = new StringBuilder(); + sql.append("SELECT MAX(value) FROM "); + sql.append(measurement); + sql.append(" WHERE point = '"); + sql.append(point.getPoint()); + sql.append("' AND time >= '" + utsStart +"'"); + InfluxQLQueryResult data = influxQLQueryApi.query(new InfluxQLQuery(sql.toString(), influxDBInstance.bucket)); + if (data == null) { + return null; + } + return data.getResults().get(0).getSeries().get(0).getValues().get(0).getValues()[1]; + } + + @Override + public List<Map<String, Object>> queryPointValues(InfluxPointValuePOJO pojo, Date startTime, Date endTime) { + List<InfluxPointValuePOJO> influxParams = new ArrayList<>(); + influxParams.add(pojo); + Map<String, List<Map<String, Object>>> data = this.queryPointsValues(influxParams, startTime, endTime); + return data.get(pojo.getPoint()); + } + + @Override + public Map<String, List<Map<String, Object>>> queryPointsValues(List<InfluxPointValuePOJO> influxParams, Date startTime, Date endTime) { + if (queryApi == null) { + queryApi = influxDBInstance.getClient().getQueryApi(); + } + if (CollectionUtils.isEmpty(influxParams)) { + return null; + } + Map<String, List<Map<String, Object>>> result = new HashMap<>(); + Calendar calendar = Calendar.getInstance(); + calendar.set(Calendar.MILLISECOND, 0); + String start = startTime.getTime() - calendar.getTime().getTime() + "ms"; + if (endTime==null){ + endTime= new Date(); + } + String stop = endTime.getTime() - calendar.getTime().getTime() + "ms"; + + for (int i = 0; i < influxParams.size(); i++) { + List<Map<String, Object>> dataList = new ArrayList<>(); + InfluxPointValuePOJO point = influxParams.get(i); + String measurement = PointValueUtils.getMeasurement(point.getType()); + StringBuilder sb = new StringBuilder(); + sb.append("from(bucket:\"" + influxDBInstance.bucket + "\") "); + sb.append("|> range(start: ").append(start).append(", stop: ").append(stop).append(") "); + sb.append("|> filter(fn: (r) => r[\"_measurement\"] == \"" + measurement + "\")"); + sb.append("|> filter(fn: (r) => r[\"_field\"] == \"value\")"); + sb.append("|> filter(fn: (r) => r[\"point\"] == \"" + point.getPoint() + "\")"); + sb.append("|> sort(columns: [\"_time\"]) "); + sb.append("|> yield(name: \"mean\")"); + System.out.println("influxdbSql===============" + sb.toString()); + List<FluxTable> tables = queryApi.query(sb.toString(), influxDBInstance.org); + + for (FluxTable table : tables) { + List<FluxRecord> records = table.getRecords(); + for (FluxRecord record : records) { + Map<String, Object> dataIem = new HashMap<>(2); + dataIem.put(VALUE, record.getValueByKey("_value")); + dataIem.put(TIME, Date.from(record.getTime())); + dataList.add(dataIem); + } + } + result.put(point.getPoint(), dataList); + } + return result; + } + + @Override + public Map<String, Object> queryPointsSpread(List<InfluxPointValuePOJO> influxParams, Date startTime, Date endTime) { + Map<String, Object> result = new HashMap<>(); + Map<String, List<Map<String, Object>>> data = this.queryPointsValues(influxParams, startTime, endTime); + if (CollectionUtils.isEmpty(data)) { + return result; + } + data.forEach((k, v) -> { + if (!CollectionUtils.isEmpty(v)) { + BigDecimal lastValue = new BigDecimal(v.get(v.size() - 1).get(VALUE).toString()); + BigDecimal firstValue = new BigDecimal(v.get(0).get(VALUE).toString()); + BigDecimal spread = (lastValue.subtract(firstValue)); + result.put(k, spread.compareTo(BigDecimal.ZERO) < 0 ? lastValue : spread); + } + log.info(k + ",isEmpty"); + }); + return result; + } +} \ No newline at end of file diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/config/ScheduleConfig.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/config/ScheduleConfig.java new file mode 100644 index 0000000..2d0a3b5 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/config/ScheduleConfig.java @@ -0,0 +1,58 @@ +package com.iailab.module.data.job.config; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.scheduling.quartz.SchedulerFactoryBean; + +import javax.sql.DataSource; +import java.util.Properties; + +/** + * 定时任务配置 + * + * @author Mark sunlightcs@gmail.com + */ +@Configuration +public class ScheduleConfig { + + @Bean + public SchedulerFactoryBean schedulerFactoryBean(DataSource dataSource) { + SchedulerFactoryBean factory = new SchedulerFactoryBean(); + factory.setDataSource(dataSource); + + //quartz参数 + Properties prop = new Properties(); + prop.put("org.quartz.scheduler.instanceName", "IailabDataScheduler"); + prop.put("org.quartz.scheduler.instanceId", "AUTO"); + //线程池配置 + prop.put("org.quartz.threadPool.class", "org.quartz.simpl.SimpleThreadPool"); + prop.put("org.quartz.threadPool.threadCount", "20"); + prop.put("org.quartz.threadPool.threadPriority", "5"); + //JobStore配置 + prop.put("org.quartz.jobStore.class", "org.springframework.scheduling.quartz.LocalDataSourceJobStore"); + //集群配置 + prop.put("org.quartz.jobStore.isClustered", "true"); + prop.put("org.quartz.jobStore.clusterCheckinInterval", "15000"); + prop.put("org.quartz.jobStore.maxMisfiresToHandleAtATime", "1"); + + prop.put("org.quartz.jobStore.misfireThreshold", "12000"); + prop.put("org.quartz.jobStore.tablePrefix", "QRTZ_"); + prop.put("org.quartz.jobStore.selectWithLockSQL", "SELECT * FROM {0}LOCKS UPDLOCK WHERE LOCK_NAME = ?"); + + //PostgreSQL数据库,需要打开此注释 + //prop.put("org.quartz.jobStore.driverDelegateClass", "org.quartz.impl.jdbcjobstore.PostgreSQLDelegate"); + + factory.setQuartzProperties(prop); + + factory.setSchedulerName("IailabDataScheduler"); + //延时启动 + factory.setStartupDelay(30); + factory.setApplicationContextSchedulerContextKey("applicationContextKey"); + //可选,QuartzScheduler 启动时更新己存在的Job,这样就不用每次修改targetObject后删除qrtz_job_details表对应记录了 + factory.setOverwriteExistingJobs(true); + //设置自动启动,默认为true + factory.setAutoStartup(true); + + return factory; + } +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/controller/admin/ScheduleJobController.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/controller/admin/ScheduleJobController.java new file mode 100644 index 0000000..cb124e6 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/controller/admin/ScheduleJobController.java @@ -0,0 +1,117 @@ +package com.iailab.module.data.job.controller.admin; + +import com.iailab.framework.common.page.PageData; +import com.iailab.module.data.common.utils.Constant; +import com.iailab.framework.common.pojo.CommonResult; +import com.iailab.framework.common.util.validation.ValidationUtils; +import com.iailab.framework.common.validation.group.AddGroup; +import com.iailab.framework.common.validation.group.DefaultGroup; +import com.iailab.framework.common.validation.group.UpdateGroup; +import com.iailab.module.data.job.dto.ScheduleJobDTO; +import com.iailab.module.data.job.service.ScheduleJobService; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.Parameters; +import io.swagger.v3.oas.annotations.tags.Tag; +import javax.annotation.Resource; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.*; + +import java.util.Map; + +/** + * 定时任务 + * + * @author Mark sunlightcs@gmail.com + */ +@RestController +@RequestMapping("/sys/schedule") +@Tag(name = "定时任务") +public class ScheduleJobController { + @Resource + private ScheduleJobService scheduleJobService; + + @GetMapping("page") + @Operation(summary = "分页") + @Parameters({ + @Parameter(name = Constant.PAGE, description = "当前页码,从1开始", required = true) , + @Parameter(name = Constant.LIMIT, description = "每页显示记录数", required = true) , + @Parameter(name = Constant.ORDER_FIELD, description = "排序字段") , + @Parameter(name = Constant.ORDER, description = "排序方式,可选值(asc、desc)") , + @Parameter(name = "beanName", description = "beanName") + }) + @PreAuthorize("@ss.hasPermission('sys:schedule:page')") + public CommonResult<PageData<ScheduleJobDTO>> page(@RequestParam Map<String, Object> params){ + PageData<ScheduleJobDTO> page = scheduleJobService.page(params); + + return new CommonResult<PageData<ScheduleJobDTO>>().setData(page); + } + + @GetMapping("{id}") + @Operation(summary = "信息") + @PreAuthorize("@ss.hasPermission('sys:schedule:info')") + public CommonResult<ScheduleJobDTO> info(@PathVariable("id") Long id){ + ScheduleJobDTO schedule = scheduleJobService.get(id); + + return new CommonResult<ScheduleJobDTO>().setData(schedule); + } + + @PostMapping + @Operation(summary = "保存") + @PreAuthorize("@ss.hasPermission('sys:schedule:save')") + public CommonResult save(@RequestBody ScheduleJobDTO dto){ + ValidationUtils.validate(dto, AddGroup.class, DefaultGroup.class); + + scheduleJobService.save(dto); + + return new CommonResult(); + } + + @PutMapping + @Operation(summary = "修改") + @PreAuthorize("@ss.hasPermission('sys:schedule:update')") + public CommonResult update(@RequestBody ScheduleJobDTO dto){ + ValidationUtils.validate(dto, UpdateGroup.class, DefaultGroup.class); + + scheduleJobService.update(dto); + + return new CommonResult(); + } + + @DeleteMapping + @Operation(summary = "删除") + @PreAuthorize("@ss.hasPermission('sys:schedule:delete')") + public CommonResult delete(@RequestBody Long[] ids){ + scheduleJobService.deleteBatch(ids); + + return new CommonResult(); + } + + @PutMapping("/run") + @Operation(summary = "立即执行") + @PreAuthorize("@ss.hasPermission('sys:schedule:run')") + public CommonResult run(@RequestBody Long[] ids){ + scheduleJobService.run(ids); + + return new CommonResult(); + } + + @PutMapping("/pause") + @Operation(summary = "暂停") + @PreAuthorize("@ss.hasPermission('sys:schedule:pause')") + public CommonResult pause(@RequestBody Long[] ids){ + scheduleJobService.pause(ids); + + return new CommonResult(); + } + + @PutMapping("/resume") + @Operation(summary = "恢复") + @PreAuthorize("@ss.hasPermission('sys:schedule:resume')") + public CommonResult resume(@RequestBody Long[] ids){ + scheduleJobService.resume(ids); + + return new CommonResult(); + } + +} \ No newline at end of file diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/controller/admin/ScheduleJobLogController.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/controller/admin/ScheduleJobLogController.java new file mode 100644 index 0000000..bf22b7b --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/controller/admin/ScheduleJobLogController.java @@ -0,0 +1,62 @@ +/** + * Copyright (c) 2018 人人开源 All rights reserved. + * + * https://www.renren.io + * + * 版权所有,侵权必究! + */ + +package com.iailab.module.data.job.controller.admin; + +import com.iailab.framework.common.page.PageData; +import com.iailab.module.data.common.utils.Constant; +import com.iailab.framework.common.pojo.CommonResult; +import com.iailab.module.data.job.dto.ScheduleJobLogDTO; +import com.iailab.module.data.job.service.ScheduleJobLogService; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.Parameters; +import io.swagger.v3.oas.annotations.tags.Tag; +import javax.annotation.Resource; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.*; + +import java.util.Map; + +/** + * 定时任务日志 + * + * @author Mark sunlightcs@gmail.com + */ +@RestController +@RequestMapping("/sys/scheduleLog") +@Tag(name = "定时任务日志") +public class ScheduleJobLogController { + @Resource + private ScheduleJobLogService scheduleJobLogService; + + @GetMapping("page") + @Operation(summary = "分页") + @Parameters({ + @Parameter(name = Constant.PAGE, description = "当前页码,从1开始", required = true) , + @Parameter(name = Constant.LIMIT, description = "每页显示记录数", required = true) , + @Parameter(name = Constant.ORDER_FIELD, description = "排序字段") , + @Parameter(name = Constant.ORDER, description = "排序方式,可选值(asc、desc)") , + @Parameter(name = "jobId", description = "jobId") + }) + @PreAuthorize("@ss.hasPermission('sys:schedule:log')") + public CommonResult<PageData<ScheduleJobLogDTO>> page(@RequestParam Map<String, Object> params){ + PageData<ScheduleJobLogDTO> page = scheduleJobLogService.page(params); + + return new CommonResult<PageData<ScheduleJobLogDTO>>().setData(page); + } + + @GetMapping("{id}") + @Operation(summary = "信息") + @PreAuthorize("@ss.hasPermission('sys:schedule:log')") + public CommonResult<ScheduleJobLogDTO> info(@PathVariable("id") Long id){ + ScheduleJobLogDTO log = scheduleJobLogService.get(id); + + return new CommonResult<ScheduleJobLogDTO>().setData(log); + } +} \ No newline at end of file diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/controller/package-info.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/controller/package-info.java new file mode 100644 index 0000000..93a0c40 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/controller/package-info.java @@ -0,0 +1 @@ +package com.iailab.module.data.job.controller; \ No newline at end of file diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/dao/ScheduleJobDao.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/dao/ScheduleJobDao.java new file mode 100644 index 0000000..d472df5 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/dao/ScheduleJobDao.java @@ -0,0 +1,32 @@ +/** + * Copyright (c) 2018 人人开源 All rights reserved. + * + * https://www.renren.io + * + * 版权所有,侵权必究! + */ + +package com.iailab.module.data.job.dao; + +import com.iailab.framework.common.dao.BaseDao; +import com.iailab.module.data.job.entity.ScheduleJobEntity; +import com.iailab.module.data.job.entity.ScheduleJobEntity; +import com.iailab.module.data.job.entity.ScheduleJobEntity; +import com.iailab.module.data.job.entity.ScheduleJobEntity; +import org.apache.ibatis.annotations.Mapper; + +import java.util.Map; + +/** + * 定时任务 + * + * @author Mark sunlightcs@gmail.com + */ +@Mapper +public interface ScheduleJobDao extends BaseDao<ScheduleJobEntity> { + + /** + * 批量更新状态 + */ + int updateBatch(Map<String, Object> map); +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/dao/ScheduleJobLogDao.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/dao/ScheduleJobLogDao.java new file mode 100644 index 0000000..67615bb --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/dao/ScheduleJobLogDao.java @@ -0,0 +1,26 @@ +/** + * Copyright (c) 2018 人人开源 All rights reserved. + * + * https://www.renren.io + * + * 版权所有,侵权必究! + */ + +package com.iailab.module.data.job.dao; + +import com.iailab.framework.common.dao.BaseDao; +import com.iailab.module.data.job.entity.ScheduleJobLogEntity; +import com.iailab.module.data.job.entity.ScheduleJobLogEntity; +import com.iailab.module.data.job.entity.ScheduleJobLogEntity; +import com.iailab.module.data.job.entity.ScheduleJobLogEntity; +import org.apache.ibatis.annotations.Mapper; + +/** + * 定时任务日志 + * + * @author Mark sunlightcs@gmail.com + */ +@Mapper +public interface ScheduleJobLogDao extends BaseDao<ScheduleJobLogEntity> { + +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/dto/ScheduleJobDTO.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/dto/ScheduleJobDTO.java new file mode 100644 index 0000000..bc29b72 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/dto/ScheduleJobDTO.java @@ -0,0 +1,62 @@ +/** + * Copyright (c) 2018 人人开源 All rights reserved. + * + * https://www.renren.io + * + * 版权所有,侵权必究! + */ + +package com.iailab.module.data.job.dto; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.iailab.framework.common.validation.group.AddGroup; +import com.iailab.framework.common.validation.group.DefaultGroup; +import com.iailab.framework.common.validation.group.UpdateGroup; +import io.swagger.v3.oas.annotations.tags.Tag; +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.Null; +import java.io.Serializable; +import java.util.Date; + +/** + * 定时任务 + * + * @author Mark sunlightcs@gmail.com + * @since 1.0.0 + */ +@Data +@Tag(name = "定时任务") +public class ScheduleJobDTO implements Serializable { + private static final long serialVersionUID = 1L; + + @Schema(description = "id") + @Null(message="{id.null}", groups = AddGroup.class) + @NotNull(message="{id.require}", groups = UpdateGroup.class) + private Long id; + + @Schema(description = "spring bean名称") + @NotBlank(message = "{schedule.bean.require}", groups = DefaultGroup.class) + private String beanName; + + @Schema(description = "参数") + private String params; + + @Schema(description = "cron表达式") + @NotBlank(message = "{schedule.cron.require}", groups = DefaultGroup.class) + private String cronExpression; + + @Schema(description = "任务状态 0:暂停 1:正常") + private Integer status; + + @Schema(description = "备注") + private String remark; + + @Schema(description = "创建时间") + @JsonProperty(access = JsonProperty.Access.READ_ONLY) + private Date createDate; + +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/dto/ScheduleJobLogDTO.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/dto/ScheduleJobLogDTO.java new file mode 100644 index 0000000..542d94c --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/dto/ScheduleJobLogDTO.java @@ -0,0 +1,53 @@ +/** + * Copyright (c) 2018 人人开源 All rights reserved. + * + * https://www.renren.io + * + * 版权所有,侵权必究! + */ + +package com.iailab.module.data.job.dto; + +import io.swagger.v3.oas.annotations.tags.Tag; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; + +/** + * 定时任务日志 + * + * @author Mark sunlightcs@gmail.com + * @since 1.0.0 + */ +@Data +@Tag(name = "定时任务日志") +public class ScheduleJobLogDTO implements Serializable { + private static final long serialVersionUID = 1L; + + @Schema(description = "id") + private Long id; + + @Schema(description = "任务id") + private Long jobId; + + @Schema(description = "spring bean名称") + private String beanName; + + @Schema(description = "参数") + private String params; + + @Schema(description = "任务状态 0:失败 1:成功") + private Integer status; + + @Schema(description = "失败信息") + private String error; + + @Schema(description = "耗时(单位:毫秒)") + private Integer times; + + @Schema(description = "创建时间") + private Date createDate; + +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/entity/ScheduleJobEntity.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/entity/ScheduleJobEntity.java new file mode 100644 index 0000000..190efa1 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/entity/ScheduleJobEntity.java @@ -0,0 +1,61 @@ +/** + * Copyright (c) 2018 人人开源 All rights reserved. + * + * https://www.renren.io + * + * 版权所有,侵权必究! + */ + +package com.iailab.module.data.job.entity; + +import com.baomidou.mybatisplus.annotation.FieldFill; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; +import com.iailab.framework.common.entity.BaseEntity; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.util.Date; + +/** + * 定时任务 + * + * @author Mark sunlightcs@gmail.com + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("schedule_job") +public class ScheduleJobEntity extends BaseEntity { + private static final long serialVersionUID = 1L; + + /** + * spring bean名称 + */ + private String beanName; + /** + * 参数 + */ + private String params; + /** + * cron表达式 + */ + private String cronExpression; + /** + * 任务状态 0:暂停 1:正常 + */ + private Integer status; + /** + * 备注 + */ + private String remark; + /** + * 更新者 + */ + @TableField(fill = FieldFill.INSERT_UPDATE) + private Long updater; + /** + * 更新时间 + */ + @TableField(fill = FieldFill.INSERT_UPDATE) + private Date updateDate; +} \ No newline at end of file diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/entity/ScheduleJobLogEntity.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/entity/ScheduleJobLogEntity.java new file mode 100644 index 0000000..837f714 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/entity/ScheduleJobLogEntity.java @@ -0,0 +1,62 @@ +/** + * Copyright (c) 2018 人人开源 All rights reserved. + * + * https://www.renren.io + * + * 版权所有,侵权必究! + */ + +package com.iailab.module.data.job.entity; + +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; + +/** + * 定时任务日志 + * + * @author Mark sunlightcs@gmail.com + */ +@Data +@TableName("schedule_job_log") +public class ScheduleJobLogEntity implements Serializable { + private static final long serialVersionUID = 1L; + + /** + * id + */ + @TableId + private Long id; + /** + * 任务id + */ + private Long jobId; + /** + * spring bean名称 + */ + private String beanName; + /** + * 参数 + */ + private String params; + /** + * 任务状态 0:失败 1:成功 + */ + private Integer status; + /** + * 失败信息 + */ + private String error; + /** + * 耗时(单位:毫秒) + */ + private Integer times; + /** + * 创建时间 + */ + private Date createDate; + +} \ No newline at end of file diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/init/JobCommandLineRunner.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/init/JobCommandLineRunner.java new file mode 100644 index 0000000..cd15b19 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/init/JobCommandLineRunner.java @@ -0,0 +1,54 @@ +/** + * Copyright (c) 2018 人人开源 All rights reserved. + * + * https://www.renren.io + * + * 版权所有,侵权必究! + */ + +package com.iailab.module.data.job.init; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.iailab.module.data.job.entity.ScheduleJobEntity; +import com.iailab.module.data.job.utils.ScheduleUtils; +import com.iailab.module.data.job.entity.ScheduleJobEntity; +import com.iailab.module.data.job.utils.ScheduleUtils; +import com.iailab.module.data.job.dao.ScheduleJobDao; +import com.iailab.module.data.job.entity.ScheduleJobEntity; +import com.iailab.module.data.job.utils.ScheduleUtils; +import com.iailab.module.data.job.entity.ScheduleJobEntity; +import com.iailab.module.data.job.utils.ScheduleUtils; +import org.quartz.CronTrigger; +import org.quartz.Scheduler; +import javax.annotation.Resource; +import org.springframework.boot.CommandLineRunner; +import org.springframework.stereotype.Component; + +import java.util.List; + +/** + * 初始化定时任务数据 + * + * @author Mark sunlightcs@gmail.com + */ +@Component +public class JobCommandLineRunner implements CommandLineRunner { + @Resource + private Scheduler scheduler; + @Resource + private ScheduleJobDao scheduleJobDao; + + @Override + public void run(String... args) { + List<ScheduleJobEntity> scheduleJobList = scheduleJobDao.selectList(new QueryWrapper<>()); + for(ScheduleJobEntity scheduleJob : scheduleJobList){ + CronTrigger cronTrigger = ScheduleUtils.getCronTrigger(scheduler, scheduleJob.getId()); + //如果不存在,则创建 + if(cronTrigger == null) { + ScheduleUtils.createScheduleJob(scheduler, scheduleJob); + }else { + ScheduleUtils.updateScheduleJob(scheduler, scheduleJob); + } + } + } +} \ No newline at end of file diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/service/ScheduleJobLogService.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/service/ScheduleJobLogService.java new file mode 100644 index 0000000..4501827 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/service/ScheduleJobLogService.java @@ -0,0 +1,31 @@ +/** + * Copyright (c) 2018 人人开源 All rights reserved. + * + * https://www.renren.io + * + * 版权所有,侵权必究! + */ + +package com.iailab.module.data.job.service; + +import com.iailab.framework.common.page.PageData; +import com.iailab.framework.common.service.BaseService; +import com.iailab.module.data.job.entity.ScheduleJobLogEntity; +import com.iailab.module.data.job.entity.ScheduleJobLogEntity; +import com.iailab.module.data.job.dto.ScheduleJobLogDTO; +import com.iailab.module.data.job.entity.ScheduleJobLogEntity; +import com.iailab.module.data.job.entity.ScheduleJobLogEntity; + +import java.util.Map; + +/** + * 定时任务日志 + * + * @author Mark sunlightcs@gmail.com + */ +public interface ScheduleJobLogService extends BaseService<ScheduleJobLogEntity> { + + PageData<ScheduleJobLogDTO> page(Map<String, Object> params); + + ScheduleJobLogDTO get(Long id); +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/service/ScheduleJobService.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/service/ScheduleJobService.java new file mode 100644 index 0000000..99f5369 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/service/ScheduleJobService.java @@ -0,0 +1,64 @@ +/** + * Copyright (c) 2018 人人开源 All rights reserved. + * + * https://www.renren.io + * + * 版权所有,侵权必究! + */ + +package com.iailab.module.data.job.service; + +import com.iailab.framework.common.page.PageData; +import com.iailab.framework.common.service.BaseService; +import com.iailab.module.data.job.entity.ScheduleJobEntity; +import com.iailab.module.data.job.entity.ScheduleJobEntity; +import com.iailab.module.data.job.dto.ScheduleJobDTO; + +import java.util.Map; + +/** + * 定时任务 + * + * @author Mark sunlightcs@gmail.com + */ +public interface ScheduleJobService extends BaseService<ScheduleJobEntity> { + + PageData<ScheduleJobDTO> page(Map<String, Object> params); + + ScheduleJobDTO get(Long id); + + /** + * 保存定时任务 + */ + void save(ScheduleJobDTO dto); + + /** + * 更新定时任务 + */ + void update(ScheduleJobDTO dto); + + /** + * 批量删除定时任务 + */ + void deleteBatch(Long[] ids); + + /** + * 批量更新定时任务状态 + */ + int updateBatch(Long[] ids, int status); + + /** + * 立即执行 + */ + void run(Long[] ids); + + /** + * 暂停运行 + */ + void pause(Long[] ids); + + /** + * 恢复运行 + */ + void resume(Long[] ids); +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/service/impl/ScheduleJobLogServiceImpl.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/service/impl/ScheduleJobLogServiceImpl.java new file mode 100644 index 0000000..8d3e38d --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/service/impl/ScheduleJobLogServiceImpl.java @@ -0,0 +1,57 @@ +/** + * Copyright (c) 2018 人人开源 All rights reserved. + * + * https://www.renren.io + * + * 版权所有,侵权必究! + */ + +package com.iailab.module.data.job.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.iailab.framework.common.constant.Constant; +import com.iailab.framework.common.page.PageData; +import com.iailab.framework.common.service.impl.BaseServiceImpl; +import com.iailab.framework.common.util.object.ConvertUtils; +import com.iailab.module.data.job.entity.ScheduleJobLogEntity; +import com.iailab.module.data.job.entity.ScheduleJobLogEntity; +import com.iailab.module.data.job.dao.ScheduleJobLogDao; +import com.iailab.module.data.job.dto.ScheduleJobLogDTO; +import com.iailab.module.data.job.entity.ScheduleJobLogEntity; +import com.iailab.module.data.job.service.ScheduleJobLogService; +import com.iailab.module.data.job.entity.ScheduleJobLogEntity; +import org.apache.commons.lang3.StringUtils; +import org.springframework.stereotype.Service; + +import java.util.Map; + +@Service +public class ScheduleJobLogServiceImpl extends BaseServiceImpl<ScheduleJobLogDao, ScheduleJobLogEntity> implements ScheduleJobLogService { + + @Override + public PageData<ScheduleJobLogDTO> page(Map<String, Object> params) { + IPage<ScheduleJobLogEntity> page = baseDao.selectPage( + getPage(params, Constant.CREATE_DATE, false), + getWrapper(params) + ); + return getPageData(page, ScheduleJobLogDTO.class); + } + + private QueryWrapper<ScheduleJobLogEntity> getWrapper(Map<String, Object> params){ + String jobId = (String)params.get("jobId"); + + QueryWrapper<ScheduleJobLogEntity> wrapper = new QueryWrapper<>(); + wrapper.eq(StringUtils.isNotBlank(jobId), "job_id", jobId); + + return wrapper; + } + + @Override + public ScheduleJobLogDTO get(Long id) { + ScheduleJobLogEntity entity = baseDao.selectById(id); + + return ConvertUtils.sourceToTarget(entity, ScheduleJobLogDTO.class); + } + +} \ No newline at end of file diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/service/impl/ScheduleJobServiceImpl.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/service/impl/ScheduleJobServiceImpl.java new file mode 100644 index 0000000..917cdf2 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/service/impl/ScheduleJobServiceImpl.java @@ -0,0 +1,132 @@ +/** + * Copyright (c) 2018 人人开源 All rights reserved. + * + * https://www.renren.io + * + * 版权所有,侵权必究! + */ + +package com.iailab.module.data.job.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.iailab.framework.common.constant.Constant; +import com.iailab.framework.common.page.PageData; +import com.iailab.framework.common.service.impl.BaseServiceImpl; +import com.iailab.framework.common.util.object.ConvertUtils; +import com.iailab.module.data.job.entity.ScheduleJobEntity; +import com.iailab.module.data.job.entity.ScheduleJobEntity; +import com.iailab.module.data.job.dao.ScheduleJobDao; +import com.iailab.module.data.job.dto.ScheduleJobDTO; +import com.iailab.module.data.job.service.ScheduleJobService; +import com.iailab.module.data.job.utils.ScheduleUtils; +import org.apache.commons.lang3.StringUtils; +import org.quartz.Scheduler; +import javax.annotation.Resource; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.Arrays; +import java.util.Date; +import java.util.HashMap; +import java.util.Map; + +@Service +public class ScheduleJobServiceImpl extends BaseServiceImpl<ScheduleJobDao, ScheduleJobEntity> implements ScheduleJobService { + @Resource + private Scheduler scheduler; + + @Override + public PageData<ScheduleJobDTO> page(Map<String, Object> params) { + IPage<ScheduleJobEntity> page = baseDao.selectPage( + getPage(params, Constant.CREATE_DATE, false), + getWrapper(params) + ); + return getPageData(page, ScheduleJobDTO.class); + } + + @Override + public ScheduleJobDTO get(Long id) { + ScheduleJobEntity entity = baseDao.selectById(id); + + return ConvertUtils.sourceToTarget(entity, ScheduleJobDTO.class); + } + + private QueryWrapper<ScheduleJobEntity> getWrapper(Map<String, Object> params){ + String beanName = (String)params.get("beanName"); + + QueryWrapper<ScheduleJobEntity> wrapper = new QueryWrapper<>(); + wrapper.like(StringUtils.isNotBlank(beanName), "bean_name", beanName); + + return wrapper; + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void save(ScheduleJobDTO dto) { + ScheduleJobEntity entity = ConvertUtils.sourceToTarget(dto, ScheduleJobEntity.class); + entity.setCreateDate(new Date()); + entity.setStatus(Constant.ScheduleStatus.NORMAL.getValue()); + this.insert(entity); + + ScheduleUtils.createScheduleJob(scheduler, entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void update(ScheduleJobDTO dto) { + ScheduleJobEntity entity = ConvertUtils.sourceToTarget(dto, ScheduleJobEntity.class); + entity.setUpdateDate(new Date()); + ScheduleUtils.updateScheduleJob(scheduler, entity); + + this.updateById(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void deleteBatch(Long[] ids) { + for(Long id : ids){ + ScheduleUtils.deleteScheduleJob(scheduler, id); + } + + //删除数据 + this.deleteBatchIds(Arrays.asList(ids)); + } + + @Override + public int updateBatch(Long[] ids, int status){ + Map<String, Object> map = new HashMap<>(2); + map.put("ids", ids); + map.put("status", status); + return baseDao.updateBatch(map); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void run(Long[] ids) { + for(Long id : ids){ + ScheduleUtils.run(scheduler, this.selectById(id)); + } + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void pause(Long[] ids) { + for(Long id : ids){ + ScheduleUtils.pauseJob(scheduler, id); + } + + updateBatch(ids, Constant.ScheduleStatus.PAUSE.getValue()); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void resume(Long[] ids) { + for(Long id : ids){ + ScheduleUtils.resumeJob(scheduler, id); + } + + updateBatch(ids, Constant.ScheduleStatus.NORMAL.getValue()); + } + +} \ No newline at end of file diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/task/HttpCollectDeviceTask.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/task/HttpCollectDeviceTask.java new file mode 100644 index 0000000..3e93df7 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/task/HttpCollectDeviceTask.java @@ -0,0 +1,42 @@ +package com.iailab.module.data.job.task; + +import com.iailab.module.data.common.enums.CommonConstant; +import com.iailab.module.data.http.collector.HttpCollectorForSD; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import javax.annotation.Resource; +import org.springframework.stereotype.Component; + +import java.time.LocalDateTime; +import java.util.HashMap; +import java.util.Map; + +/** + *山大设备设备列表数据采集 + * + * @author lirm + * @Description + * @createTime 2024年05月21日 + */ +@Component("httpCollectDeviceTask") +public class HttpCollectDeviceTask implements ITask { + private Logger logger = LoggerFactory.getLogger(getClass()); + + @Resource + private HttpCollectorForSD httpCollectorForSD; + + @Override + public void run(String params) { + logger.info("HttpCollectDeviceTask定时任务正在执行,参数为:{}", params); + try { + Map<String,String> map = new HashMap<>(); + map.put("code", CommonConstant.HTTP_API_SD_DEVICE_LIST); + map.put("token", "914df3ebd91bc54b5b294f13477f497611d278aa4a8727249f8490cb274a0ed9"); + httpCollectorForSD.getDeviceList(map); + logger.info("HttpCollectDeviceTask定时任务完成时间:" + LocalDateTime.now()); + } catch (Exception ex) { + ex.printStackTrace(); + logger.info("HttpCollectDeviceTask定时任务失败时间:" + LocalDateTime.now()); + } + } +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/task/HttpCollectHealthStateTask.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/task/HttpCollectHealthStateTask.java new file mode 100644 index 0000000..4d3c0e3 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/task/HttpCollectHealthStateTask.java @@ -0,0 +1,47 @@ +package com.iailab.module.data.job.task; + +import com.iailab.module.data.common.enums.CommonConstant; +import com.iailab.module.data.http.collector.HttpCollectorForSD; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import javax.annotation.Resource; +import org.springframework.stereotype.Component; + +import java.time.LocalDateTime; +import java.util.HashMap; +import java.util.Map; + +/** + *山大设备健康状态数据采集 + * + * @author lirm + * @Description + * @createTime 2024年05月21日 + */ +@Component("httpCollectHealthStateTask") +public class HttpCollectHealthStateTask implements ITask { + private Logger logger = LoggerFactory.getLogger(getClass()); + + @Resource + private HttpCollectorForSD httpCollectorForSD; + + @Override + public void run(String params) { + logger.info("HttpCollectHealthStateTask定时任务正在执行,参数为:{}", params); + try { + Map<String,String> map = new HashMap<>(); + map.put("cu_ids", "3"); + map.put("t", "1716274632482"); + map.put("code", CommonConstant.HTTP_API_SD_HEALTH_STATE); + map.put("client_id", "sd"); + map.put("X-Forwarded-OrgSet", "1000000000000003"); + map.put("X-Forwarded-PrId", "300005001,300005002"); + map.put("X-Request-Id", "-c8048bc7-a206-4f71-a512-d6ade2272289"); + httpCollectorForSD.getHealthStateValue(map); + logger.info("HttpCollectHealthStateTask定时任务完成时间:" + LocalDateTime.now()); + } catch (Exception ex) { + ex.printStackTrace(); + logger.info("HttpCollectHealthStateTask定时任务失败时间:" + LocalDateTime.now()); + } + } +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/task/HttpCollectRunStateTask.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/task/HttpCollectRunStateTask.java new file mode 100644 index 0000000..8a5046f --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/task/HttpCollectRunStateTask.java @@ -0,0 +1,47 @@ +package com.iailab.module.data.job.task; + +import com.iailab.module.data.common.enums.CommonConstant; +import com.iailab.module.data.http.collector.HttpCollectorForSD; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import javax.annotation.Resource; +import org.springframework.stereotype.Component; + +import java.time.LocalDateTime; +import java.util.HashMap; +import java.util.Map; + +/** + *山大设备运行状态数据采集 + * + * @author lirm + * @Description + * @createTime 2024年05月21日 + */ +@Component("httpCollectRunStateTask") +public class HttpCollectRunStateTask implements ITask { + private Logger logger = LoggerFactory.getLogger(getClass()); + + @Resource + private HttpCollectorForSD httpCollectorForSD; + + @Override + public void run(String params) { + logger.info("HttpCollectRunStateTask定时任务正在执行,参数为:{}", params); + try { + Map<String,String> map = new HashMap<>(); + map.put("cu_ids", "3"); + map.put("t", "1716274632482"); + map.put("code", CommonConstant.HTTP_API_SD_RUN_STATE); + map.put("client_id", "sd"); + map.put("X-Forwarded-OrgSet", "1000000000000003"); + map.put("X-Forwarded-PrId", "300002001,300002002"); + map.put("X-Request-Id", "-3cfeef03-9f1f-48bb-98ec-5494012081d1"); + httpCollectorForSD.getRunStateValue(map); + logger.info("HttpCollectRunStateTask定时任务完成时间:" + LocalDateTime.now()); + } catch (Exception ex) { + ex.printStackTrace(); + logger.info("HttpCollectRunStateTask定时任务失败时间:" + LocalDateTime.now()); + } + } +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/task/HttpCollectTemperatureTask.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/task/HttpCollectTemperatureTask.java new file mode 100644 index 0000000..ada255d --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/task/HttpCollectTemperatureTask.java @@ -0,0 +1,47 @@ +package com.iailab.module.data.job.task; + +import com.iailab.module.data.common.enums.CommonConstant; +import com.iailab.module.data.http.collector.HttpCollectorForSD; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import javax.annotation.Resource; +import org.springframework.stereotype.Component; + +import java.time.LocalDateTime; +import java.util.Calendar; +import java.util.HashMap; +import java.util.Map; + +/** + *山大设备温度 振动数据采集 + * + * @author lirm + * @Description + * @createTime 2024年6月3日 + */ +@Component("httpCollectTemperatureTask") +public class HttpCollectTemperatureTask implements ITask { + private Logger logger = LoggerFactory.getLogger(getClass()); + + @Resource + private HttpCollectorForSD httpCollectorForSD; + + @Override + public void run(String params) { + logger.info("HttpCollectTemperatureTask定时任务正在执行,参数为:{}", params); + Calendar calendar = Calendar.getInstance(); + calendar.set(Calendar.MILLISECOND, 0); + calendar.set(Calendar.SECOND, 0); + try { + Map<String,String> map = new HashMap<>(); + map.put("code", CommonConstant.HTTP_API_SD_DEVICE_TEMPERATURE); + map.put("X-Forwarded-OrgSet", "1000000000000003"); + map.put("client_id", "sd"); + httpCollectorForSD.getTemperatureValue(map, calendar.getTime()); + logger.info("HttpCollectTemperatureTask定时任务完成时间:" + LocalDateTime.now()); + } catch (Exception ex) { + ex.printStackTrace(); + logger.info("HttpCollectTemperatureTask定时任务失败时间:" + LocalDateTime.now()); + } + } +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/task/HttpCollectUserTask.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/task/HttpCollectUserTask.java new file mode 100644 index 0000000..c5fc2a7 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/task/HttpCollectUserTask.java @@ -0,0 +1,46 @@ +package com.iailab.module.data.job.task; + +import com.iailab.module.data.common.enums.CommonConstant; +import com.iailab.module.data.http.collector.HttpCollectorForUser; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import javax.annotation.Resource; +import org.springframework.stereotype.Component; + +import java.time.LocalDateTime; +import java.util.HashMap; +import java.util.Map; + +/** + * 同步用户 + * 0 0 12 2 * ? + * + * + * @author lirm + * @Description + * @createTime 2024年05月21日 + */ +@Component("httpCollectUserTask") +public class HttpCollectUserTask implements ITask { + private Logger logger = LoggerFactory.getLogger(getClass()); + + @Resource + private HttpCollectorForUser httpCollectorForUser; + + @Override + public void run(String params) { + logger.info("HttpCollectUserTask定时任务正在执行,参数为:{}", params); + try { + Map<String,String> map1 = new HashMap<>(); + map1.put("code", CommonConstant.HTTP_API_JOB_LIST); + httpCollectorForUser.saveJobInfo(map1); + Map<String,String> map2 = new HashMap<>(); + map2.put("code", CommonConstant.HTTP_API_PERSON_LIST); + httpCollectorForUser.saveUserInfo(map2); + logger.info("HttpCollectUserTask定时任务完成时间:" + LocalDateTime.now()); + } catch (Exception ex) { + ex.printStackTrace(); + logger.info("HttpCollectUserTask定时任务失败时间:" + LocalDateTime.now()); + } + } +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/task/HttpTokenTask.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/task/HttpTokenTask.java new file mode 100644 index 0000000..92e120e --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/task/HttpTokenTask.java @@ -0,0 +1,40 @@ +package com.iailab.module.data.job.task; + +import com.iailab.module.data.common.enums.CommonConstant; +import com.iailab.module.data.http.service.HttpTokenService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import javax.annotation.Resource; +import org.springframework.stereotype.Component; + +import java.time.LocalDateTime; + +/** + * 更新httpToken + * 每天更新一次,token每两天过期 + * + * @author lirm + * @Description + * @createTime 2024年05月21日 + */ +@Component("httpTokenTask") +public class HttpTokenTask implements ITask { + private Logger logger = LoggerFactory.getLogger(getClass()); + + @Resource + HttpTokenService httpTokenService; + + @Override + public void run(String params) { + logger.info("httpTokenTask定时任务正在执行,参数为:{}", params); + + try { + logger.info("clientId=" + CommonConstant.HTTP_CLIENT_ID_SD); + httpTokenService.updateToken(CommonConstant.HTTP_CLIENT_ID_SD); + logger.info("httpTokenTask定时任务完成时间:" + LocalDateTime.now()); + } catch (Exception ex) { + ex.printStackTrace(); + logger.info("httpTokenTask定时任务失败时间:" + LocalDateTime.now()); + } + } +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/task/ITask.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/task/ITask.java new file mode 100644 index 0000000..8b38aa0 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/task/ITask.java @@ -0,0 +1,25 @@ +/** + * Copyright (c) 2018 人人开源 All rights reserved. + * + * https://www.renren.io + * + * 版权所有,侵权必究! + */ + +package com.iailab.module.data.job.task; + +/** + * 定时任务接口,所有定时任务都要实现该接口 + * + * @author Mark sunlightcs@gmail.com + * @since 1.0.0 + */ +public interface ITask { + + /** + * 执行定时任务接口 + * + * @param params 参数,多参数使用JSON数据 + */ + void run(String params); +} \ No newline at end of file diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/task/PointCollectTaskNet10.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/task/PointCollectTaskNet10.java new file mode 100644 index 0000000..df5fa11 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/task/PointCollectTaskNet10.java @@ -0,0 +1,44 @@ +package com.iailab.module.data.job.task; + +import com.iailab.module.data.point.collection.PointCollector; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import javax.annotation.Resource; +import org.springframework.stereotype.Component; + +import java.time.LocalDateTime; +import java.util.Calendar; + +/** + * Point采集器10s + * 0/10 * * * * ? + * + * @author PanZhibao + * @Description + * @createTime 2023年05月05日 11:49:00 + */ +@Component("pointCollectTaskNet10") +public class PointCollectTaskNet10 implements ITask { + private Logger logger = LoggerFactory.getLogger(getClass()); + + private final String NET = "NET10"; + + @Resource + private PointCollector pointCollector; + + @Override + public void run(String params){ + // 0/10 * * * * ? + logger.debug("PointCollectTaskNet10定时任务正在执行,参数为:{}", params); + try { + Calendar calendar = Calendar.getInstance(); + calendar.set(Calendar.MILLISECOND, 0); + pointCollector.collect(calendar.getTime(), NET); + logger.info("PointCollectTaskNet10定时任务完成时间:" + LocalDateTime.now()); + } catch (Exception ex) { + ex.printStackTrace(); + logger.error("PointCollectTaskNet10定时任务失败时间:" + LocalDateTime.now()); + } + + } +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/task/PointCollectTaskNet30.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/task/PointCollectTaskNet30.java new file mode 100644 index 0000000..d5a7c8f --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/task/PointCollectTaskNet30.java @@ -0,0 +1,43 @@ +package com.iailab.module.data.job.task; + +import com.iailab.module.data.point.collection.PointCollector; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import javax.annotation.Resource; +import org.springframework.stereotype.Component; + +import java.time.LocalDateTime; +import java.util.Calendar; + +/** + * Point采集器30s + * + * @author PanZhibao + * @Description + * @createTime 2023年05月05日 11:50:00 + */ +@Component("pointCollectTaskNet30") +public class PointCollectTaskNet30 implements ITask { + private Logger logger = LoggerFactory.getLogger(getClass()); + + private final String NET = "NET30"; + + @Resource + private PointCollector pointCollector; + + @Override + public void run(String params){ + // 0/30 * * * * ? + logger.debug("PointCollectTaskNet30定时任务正在执行,参数为:{}", params); + try { + Calendar calendar = Calendar.getInstance(); + calendar.set(Calendar.MILLISECOND, 0); + pointCollector.collect(calendar.getTime(), NET); + logger.info("PointCollectTaskNet30定时任务完成时间:" + LocalDateTime.now()); + } catch (Exception ex) { + ex.printStackTrace(); + logger.error("PointCollectTaskNet30定时任务失败时间:" + LocalDateTime.now()); + } + + } +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/task/PointCollectTaskNet60.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/task/PointCollectTaskNet60.java new file mode 100644 index 0000000..26eed3f --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/task/PointCollectTaskNet60.java @@ -0,0 +1,44 @@ +package com.iailab.module.data.job.task; + +import com.iailab.module.data.point.collection.PointCollector; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import javax.annotation.Resource; +import org.springframework.stereotype.Component; + +import java.time.LocalDateTime; +import java.util.Calendar; + +/** + * Point采集器1min + * 0 0/1 * * * ? + * + * @author PanZhibao + * @Description + * @createTime 2023年05月05日 11:50:00 + */ +@Component("pointCollectTaskNet60") +public class PointCollectTaskNet60 implements ITask { + private Logger logger = LoggerFactory.getLogger(getClass()); + + private final String NET = "NET60"; + + @Resource + private PointCollector pointCollector; + + @Override + public void run(String params){ + // 0 0/1 * * * ? + logger.debug("CollectTaskNet60定时任务正在执行,参数为:{}", params); + try { + Calendar calendar = Calendar.getInstance(); + calendar.set(Calendar.MILLISECOND, 0); + pointCollector.collect(calendar.getTime(), NET); + logger.info("PointCollectTaskNet60定时任务完成时间:" + LocalDateTime.now()); + } catch (Exception ex) { + ex.printStackTrace(); + logger.error("PointCollectTaskNet60定时任务失败时间:" + LocalDateTime.now()); + } + + } +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/task/PointCollectTaskNetKIO10.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/task/PointCollectTaskNetKIO10.java new file mode 100644 index 0000000..1cc31df --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/task/PointCollectTaskNetKIO10.java @@ -0,0 +1,44 @@ +package com.iailab.module.data.job.task; + +import com.iailab.module.data.point.collection.PointCollector; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import javax.annotation.Resource; +import org.springframework.stereotype.Component; + +import java.time.LocalDateTime; +import java.util.Calendar; + +/** + * Point采集器KIO 10s + * 0/10 * * * * ? + * + * @author PanZhibao + * @Description + * @createTime 2024年06月13日 + */ +@Component("pointCollectTaskNetKIO10") +public class PointCollectTaskNetKIO10 implements ITask { + private Logger logger = LoggerFactory.getLogger(getClass()); + + private final String NET = "NET_KIO10"; + + @Resource + private PointCollector pointCollector; + + @Override + public void run(String params){ + // 0/10 * * * * ? + logger.debug("PointCollectTaskNetKIO10定时任务正在执行,参数为:{}", params); + try { + Calendar calendar = Calendar.getInstance(); + calendar.set(Calendar.MILLISECOND, 0); + pointCollector.collect(calendar.getTime(), NET); + logger.info("PointCollectTaskNetKIO10定时任务完成时间:" + LocalDateTime.now()); + } catch (Exception ex) { + ex.printStackTrace(); + logger.error("PointCollectTaskNetKIO10定时任务失败时间:" + LocalDateTime.now()); + } + + } +} \ No newline at end of file diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/task/PointCollectTaskNetKIO60.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/task/PointCollectTaskNetKIO60.java new file mode 100644 index 0000000..a965154 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/task/PointCollectTaskNetKIO60.java @@ -0,0 +1,44 @@ +package com.iailab.module.data.job.task; + +import com.iailab.module.data.point.collection.PointCollector; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import javax.annotation.Resource; +import org.springframework.stereotype.Component; + +import java.time.LocalDateTime; +import java.util.Calendar; + +/** + * Point采集器KIO 1min + * 0 0/1 * * * ? + * + * @author PanZhibao + * @Description + * @createTime 2024年06月14日 + */ +@Component("pointCollectTaskNetKIO60") +public class PointCollectTaskNetKIO60 implements ITask { + private Logger logger = LoggerFactory.getLogger(getClass()); + + private final String NET = "NET_KIO60"; + + @Resource + private PointCollector pointCollector; + + @Override + public void run(String params){ + // 0/10 * * * * ? + logger.debug("PointCollectTaskNetKIO60定时任务正在执行,参数为:{}", params); + try { + Calendar calendar = Calendar.getInstance(); + calendar.set(Calendar.MILLISECOND, 0); + pointCollector.collect(calendar.getTime(), NET); + logger.info("PointCollectTaskNetKIO60定时任务完成时间:" + LocalDateTime.now()); + } catch (Exception ex) { + ex.printStackTrace(); + logger.error("PointCollectTaskNetKIO60定时任务失败时间:" + LocalDateTime.now()); + } + + } +} \ No newline at end of file diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/task/TestTask.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/task/TestTask.java new file mode 100644 index 0000000..8e00392 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/task/TestTask.java @@ -0,0 +1,22 @@ +package com.iailab.module.data.job.task; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Component; + +/** + * 测试定时任务(演示Demo,可删除) + * + * testTask为spring bean的名称 + * + * @author Mark sunlightcs@gmail.com + */ +@Component("testTask") +public class TestTask implements ITask{ + private Logger logger = LoggerFactory.getLogger(getClass()); + + @Override + public void run(String params){ + logger.debug("TestTask定时任务正在执行,参数为:{}", params); + } +} \ No newline at end of file diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/utils/ScheduleJob.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/utils/ScheduleJob.java new file mode 100644 index 0000000..489738f --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/utils/ScheduleJob.java @@ -0,0 +1,79 @@ +/** + * Copyright (c) 2018 人人开源 All rights reserved. + * + * https://www.renren.io + * + * 版权所有,侵权必究! + */ + +package com.iailab.module.data.job.utils; + +import com.iailab.framework.common.constant.Constant; +import com.iailab.framework.common.exception.ExceptionUtils; +import com.iailab.framework.common.util.spring.SpringContextUtils; +import com.iailab.module.data.job.entity.ScheduleJobEntity; +import com.iailab.module.data.job.entity.ScheduleJobEntity; +import com.iailab.module.data.job.entity.ScheduleJobLogEntity; +import org.quartz.JobExecutionContext; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.scheduling.quartz.QuartzJobBean; + +import java.lang.reflect.Method; +import java.util.Date; + + +/** + * 定时任务 + * + * @author Mark sunlightcs@gmail.com + */ +public class ScheduleJob extends QuartzJobBean { + private Logger logger = LoggerFactory.getLogger(getClass()); + + @Override + protected void executeInternal(JobExecutionContext context) { + ScheduleJobEntity scheduleJob = (ScheduleJobEntity) context.getMergedJobDataMap(). + get(ScheduleUtils.JOB_PARAM_KEY); + + //数据库保存执行记录 + ScheduleJobLogEntity log = new ScheduleJobLogEntity(); + log.setJobId(scheduleJob.getId()); + log.setBeanName(scheduleJob.getBeanName()); + log.setParams(scheduleJob.getParams()); + log.setCreateDate(new Date()); + + //任务开始时间 + long startTime = System.currentTimeMillis(); + + try { + //执行任务 + logger.info("任务准备执行,任务ID:{}", scheduleJob.getId()); + Object target = SpringContextUtils.getBean(scheduleJob.getBeanName()); + Method method = target.getClass().getDeclaredMethod("run", String.class); + method.invoke(target, scheduleJob.getParams()); + + //任务执行总时长 + long times = System.currentTimeMillis() - startTime; + log.setTimes((int)times); + //任务状态 + log.setStatus(Constant.SUCCESS); + + logger.info("任务执行完毕,任务ID:{} 总共耗时:{} 毫秒", scheduleJob.getId(), times); + } catch (Exception e) { + logger.error("任务执行失败,任务ID:{}", scheduleJob.getId(), e); + + //任务执行总时长 + long times = System.currentTimeMillis() - startTime; + log.setTimes((int)times); + + //任务状态 + log.setStatus(Constant.FAIL); + log.setError(ExceptionUtils.getErrorStackTrace(e)); + }finally { + //获取spring bean + /*ScheduleJobLogService scheduleJobLogService = SpringContextUtils.getBean(ScheduleJobLogService.class); + scheduleJobLogService.insert(log);*/ + } + } +} \ No newline at end of file diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/utils/ScheduleUtils.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/utils/ScheduleUtils.java new file mode 100644 index 0000000..e1f59a2 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/utils/ScheduleUtils.java @@ -0,0 +1,162 @@ +/** + * Copyright (c) 2018 人人开源 All rights reserved. + * + * https://www.renren.io + * + * 版权所有,侵权必究! + */ + +package com.iailab.module.data.job.utils; + +import com.iailab.framework.common.constant.Constant; +import com.iailab.framework.common.enums.ErrorCode; +import com.iailab.framework.common.exception.ServerException; +import com.iailab.module.data.job.entity.ScheduleJobEntity; +import com.iailab.module.data.job.entity.ScheduleJobEntity; +import org.quartz.*; + +/** + * 定时任务工具类 + * + * @author Mark sunlightcs@gmail.com + */ +public class ScheduleUtils { + private final static String JOB_NAME = "TASK_"; + /** + * 任务调度参数key + */ + public static final String JOB_PARAM_KEY = "JOB_PARAM_KEY"; + + /** + * 获取触发器key + */ + public static TriggerKey getTriggerKey(Long jobId) { + return TriggerKey.triggerKey(JOB_NAME + jobId); + } + + /** + * 获取jobKey + */ + public static JobKey getJobKey(Long jobId) { + return JobKey.jobKey(JOB_NAME + jobId); + } + + /** + * 获取表达式触发器 + */ + public static CronTrigger getCronTrigger(Scheduler scheduler, Long jobId) { + try { + return (CronTrigger) scheduler.getTrigger(getTriggerKey(jobId)); + } catch (SchedulerException e) { + throw new ServerException(ErrorCode.JOB_ERROR, e.getMessage()); + } + } + + /** + * 创建定时任务 + */ + public static void createScheduleJob(Scheduler scheduler, ScheduleJobEntity scheduleJob) { + try { + //构建job信息 + JobDetail jobDetail = JobBuilder.newJob(ScheduleJob.class).withIdentity(getJobKey(scheduleJob.getId())).build(); + + //表达式调度构建器 + CronScheduleBuilder scheduleBuilder = CronScheduleBuilder.cronSchedule(scheduleJob.getCronExpression()) + .withMisfireHandlingInstructionDoNothing(); + + //按新的cronExpression表达式构建一个新的trigger + CronTrigger trigger = TriggerBuilder.newTrigger().withIdentity(getTriggerKey(scheduleJob.getId())).withSchedule(scheduleBuilder).build(); + + //放入参数,运行时的方法可以获取 + jobDetail.getJobDataMap().put(JOB_PARAM_KEY, scheduleJob); + + scheduler.scheduleJob(jobDetail, trigger); + + //暂停任务 + if(scheduleJob.getStatus() == Constant.ScheduleStatus.PAUSE.getValue()){ + pauseJob(scheduler, scheduleJob.getId()); + } + } catch (SchedulerException e) { + throw new ServerException(ErrorCode.JOB_ERROR, e.getMessage()); + } + } + + /** + * 更新定时任务 + */ + public static void updateScheduleJob(Scheduler scheduler, ScheduleJobEntity scheduleJob) { + try { + TriggerKey triggerKey = getTriggerKey(scheduleJob.getId()); + + //表达式调度构建器 + CronScheduleBuilder scheduleBuilder = CronScheduleBuilder.cronSchedule(scheduleJob.getCronExpression()) + .withMisfireHandlingInstructionDoNothing(); + + CronTrigger trigger = getCronTrigger(scheduler, scheduleJob.getId()); + + //按新的cronExpression表达式重新构建trigger + trigger = trigger.getTriggerBuilder().withIdentity(triggerKey).withSchedule(scheduleBuilder).build(); + + //参数 + trigger.getJobDataMap().put(JOB_PARAM_KEY, scheduleJob); + + scheduler.rescheduleJob(triggerKey, trigger); + + //暂停任务 + if(scheduleJob.getStatus() == Constant.ScheduleStatus.PAUSE.getValue()){ + pauseJob(scheduler, scheduleJob.getId()); + } + + } catch (SchedulerException e) { + throw new ServerException(ErrorCode.JOB_ERROR, e.getMessage()); + } + } + + /** + * 立即执行任务 + */ + public static void run(Scheduler scheduler, ScheduleJobEntity scheduleJob) { + try { + //参数 + JobDataMap dataMap = new JobDataMap(); + dataMap.put(JOB_PARAM_KEY, scheduleJob); + + scheduler.triggerJob(getJobKey(scheduleJob.getId()), dataMap); + } catch (SchedulerException e) { + throw new ServerException(ErrorCode.JOB_ERROR, e.getMessage()); + } + } + + /** + * 暂停任务 + */ + public static void pauseJob(Scheduler scheduler, Long jobId) { + try { + scheduler.pauseJob(getJobKey(jobId)); + } catch (SchedulerException e) { + throw new ServerException(ErrorCode.JOB_ERROR, e.getMessage()); + } + } + + /** + * 恢复任务 + */ + public static void resumeJob(Scheduler scheduler, Long jobId) { + try { + scheduler.resumeJob(getJobKey(jobId)); + } catch (SchedulerException e) { + throw new ServerException(ErrorCode.JOB_ERROR, e.getMessage()); + } + } + + /** + * 删除定时任务 + */ + public static void deleteScheduleJob(Scheduler scheduler, Long jobId) { + try { + scheduler.deleteJob(getJobKey(jobId)); + } catch (SchedulerException e) { + throw new ServerException(ErrorCode.JOB_ERROR, e.getMessage()); + } + } +} \ No newline at end of file diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/collection/PointCollector.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/collection/PointCollector.java new file mode 100644 index 0000000..3723dd0 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/collection/PointCollector.java @@ -0,0 +1,137 @@ +package com.iailab.module.data.point.collection; + +import com.iailab.module.data.common.enums.DataSourceType; +import com.iailab.module.data.common.utils.R; +import com.iailab.module.data.channel.kio.collector.KingIOCollector; +import com.iailab.module.data.point.collection.handler.CalculateHandle; +import com.iailab.module.data.point.common.PointTypeEnum; +import com.iailab.module.data.point.dto.DaPointDTO; +import com.iailab.module.data.point.service.DaPointService; +import com.iailab.module.data.http.collector.HttpCollectorForZxzk; +import com.iailab.module.data.influxdb.pojo.InfluxPointValuePOJO; +import com.iailab.module.data.channel.modbus.collector.ModBusCollector; +import com.iailab.module.data.channel.opcua.collector.OpcUaCollector; +import com.iailab.module.data.point.collection.handler.ConstantHandle; +import com.iailab.module.data.point.collection.handler.MeasureHandle; +import com.iailab.module.data.point.dto.DaPointWriteValueDTO; +import com.iailab.module.data.influxdb.service.InfluxDBService; +import lombok.extern.slf4j.Slf4j; +import javax.annotation.Resource; +import org.springframework.stereotype.Component; +import org.springframework.util.CollectionUtils; + +import java.math.BigDecimal; +import java.util.*; + +/** + * @author PanZhibao + * @Description + * @createTime 2023年04月25日 16:16:00 + */ +@Slf4j +@Component +public class PointCollector { + + @Resource + private DaPointService daPointService; + + @Resource + private ConstantHandle constantHandle; + + @Resource + private MeasureHandle measureHandle; + + @Resource + private CalculateHandle calculateHandle; + + @Resource + private KingIOCollector kingIOCollector; + + @Resource + private InfluxDBService influxDBService; + + @Resource + private ModBusCollector modBusCollector; + + @Resource + private OpcUaCollector opcUaCollector; + + @Resource + private HttpCollectorForZxzk httpCollectorForZxzk; + + /** + * 采集 + * + * @param collectTime + * @param minfreq + */ + public void collect(Date collectTime, String minfreq) { + try { + Map<String, Object> dataMap = new HashMap<>(); + List<InfluxPointValuePOJO> pointValues = new ArrayList<>(); + + // 读取常量点 + log.info("读取常量点"); + List<DaPointDTO> pointConstantList = daPointService.getConstantPoint(minfreq); + pointValues.addAll(constantHandle.handle(collectTime, pointConstantList, dataMap)); + + // 读取测量点 + log.info("读取测量点"); + List<DaPointDTO> pointMeasureList = daPointService.getMeasurePoint(minfreq); + pointValues.addAll(measureHandle.handle(collectTime, pointMeasureList, dataMap)); + + // 读取计算点 + log.info("读取计算点"); + List<DaPointDTO> pointCalculateList = daPointService.getMathPoint(minfreq); + pointValues.addAll(calculateHandle.handle(collectTime, pointCalculateList, dataMap)); + + // 存入数据库 + log.info("存入数据库"); + influxDBService.asyncWritePointValues(pointValues); + + log.info("采集完成"); + } catch (Exception ex) { + log.info("采集异常!"); + ex.printStackTrace(); + } + } + + public Map<String, Object> getCurrentValue(List<String> pointNos) { + try { + Map<String, Object> data = new HashMap<>(); + if (CollectionUtils.isEmpty(pointNos)) { + return data; + } + data.putAll(constantHandle.getCurrent(pointNos)); + data.putAll(measureHandle.getCurrent(pointNos)); + data.putAll(calculateHandle.getCurrent(pointNos)); + return data; + } catch (Exception ex) { + return R.error(ex.getMessage()); + } + + } + + public void setValue(DaPointWriteValueDTO writeValue) throws Exception { + DaPointDTO daPointDTO = daPointService.getByNo(writeValue.getPointNo()); + if (daPointDTO == null) { + throw new Exception("点位不存在"); + } + if (PointTypeEnum.CONSTANT.getCode().equals(daPointDTO.getPointType())) { + daPointDTO.setDefaultValue(new BigDecimal(writeValue.getPointValue().toString())); + daPointService.updateDefaultValue(daPointDTO); + } else if (PointTypeEnum.MEASURE_POINT.getCode().equals(daPointDTO.getPointType())) { + DaPointDTO mPoint = daPointService.getMeasurePointByNo(daPointDTO.getPointNo()); + if (DataSourceType.OPCUA.getCode().equals(mPoint.getSourceType())) { + opcUaCollector.setTagData(mPoint.getSourceId(), mPoint.getTagNo(), writeValue.getPointValue().toString(), mPoint.getDataType()); + } else if (DataSourceType.ModBus.getCode().equals(mPoint.getSourceType())) { + modBusCollector.setTagValue(mPoint.getSourceId(), mPoint.getTagNo(), writeValue.getPointValue().toString()); + } else if (DataSourceType.KIO.getCode().equals(mPoint.getSourceType())) { + kingIOCollector.setTagValue(mPoint.getSourceId(), mPoint.getTagNo(), writeValue.getPointValue().toString(), mPoint.getDataType()); + } else { + log.info("没有匹配的TagNo=" + mPoint.getTagNo()); + } + } + + } +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/collection/handler/CalculateHandle.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/collection/handler/CalculateHandle.java new file mode 100644 index 0000000..5fe035d --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/collection/handler/CalculateHandle.java @@ -0,0 +1,157 @@ +package com.iailab.module.data.point.collection.handler; + +import com.iailab.module.data.common.enums.DataTypeEnum; +import com.iailab.module.data.common.enums.JsErrorCode; +import com.iailab.module.data.common.utils.JavaScriptHandler; +import com.iailab.module.data.point.collection.utils.GenInfluxPointValueUtils; +import com.iailab.module.data.point.dto.DaPointDTO; +import com.iailab.module.data.point.service.DaPointService; +import com.iailab.module.data.influxdb.pojo.InfluxPointValuePOJO; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import javax.annotation.Resource; +import org.springframework.stereotype.Component; +import org.springframework.util.CollectionUtils; + +import java.math.BigDecimal; +import java.util.*; + +/** + * 计算点处理 + * + * @author PanZhibao + * @Description + * @createTime 2023年05月03日 17:40:00 + */ +@Slf4j +@Component +public class CalculateHandle { + + @Resource + private DaPointService daPointService; + + @Resource + private MeasureHandle measureHandle; + + @Resource + private ConstantHandle constantHandle; + + @Resource + private JavaScriptHandler javaScriptHandler; + + public static final String regex = "[+\\-\\*\\/\\(\\)\\&\\|\\>\\<]"; + + public List<InfluxPointValuePOJO> handle(Date collectTime, List<DaPointDTO> dtos, Map<String, Object> dataMap) { + List<InfluxPointValuePOJO> result = new ArrayList<>(); + try { + log.info("计算点处理开始"); + if (CollectionUtils.isEmpty(dtos)) { + return result; + } + dtos.forEach(dto -> { + try { + Object value = singleCompute(dto, dataMap); + InfluxPointValuePOJO pojo = GenInfluxPointValueUtils.getByPoint(dto, value); + pojo.setTimestamp(collectTime.toInstant()); + result.add(pojo); + } catch (Exception ex) { + ex.printStackTrace(); + log.info("计算点异常!PointNo=" + dto.getPointNo()); + } + }); + log.info("计算点处理结束"); + + } catch (Exception ex) { + ex.printStackTrace(); + log.info("计算点处理异常!"); + } + return result; + } + + private Object singleCompute(DaPointDTO dto, Map<String, Object> dataMap) { + String expression = dto.getExpression(); + String[] arr = expression.split(regex); + + for (int i = 0; i < arr.length; i++) { + String s = arr[i]; + if (StringUtils.isNotBlank(s) && dataMap.containsKey(s)) { + expression = expression.replace(s, dataMap.get(s).toString()); + } + } + expression = expression.replace("&", "&&"); + expression = expression.replace("|", "||"); + expression = expression.replace("False", "false"); + expression = expression.replace("True", "true"); + log.info("PointNo=" + dto.getPointNo() + ";expression=" + expression); + String result = javaScriptHandler.eval(expression); + log.info("result=" + result); + if (result == null) { + return null; + } else if (result.contains(JsErrorCode.Infinity.name()) || + result.contains(JsErrorCode.NaN.name())) { + log.info("计算异常,使用默认值"); + return dto.getDefaultValue() == null ? BigDecimal.ZERO : dto.getDefaultValue(); + } else { + if (DataTypeEnum.INT.getCode().equals(dto.getDataType())) { + return new BigDecimal(result).intValue(); + } else if (DataTypeEnum.FLOAT.getCode().equals(dto.getDataType())) { + return new BigDecimal(result).setScale(10, BigDecimal.ROUND_UP).doubleValue(); + } else if (DataTypeEnum.BOOLEAN.getCode().equals(dto.getDataType())) { + return Boolean.parseBoolean(result); + } + } + return result; + } + + public Map<String, Object> getCurrent(List<String> pointNos) { + Map<String, Object> data = new HashMap<>(); + List<DaPointDTO> pointMathList = daPointService.getMathPoint(pointNos); + if (CollectionUtils.isEmpty(pointMathList)) { + return data; + } + pointMathList.forEach(item -> { + data.put(item.getPointNo(), singleCompute(item)); + }); + return data; + } + + private Object singleCompute(DaPointDTO dto) { + Map<String, Object> dataMap = new HashMap<>(); + String expression = dto.getExpression(); + String[] arr = expression.split(regex); + for (int i = 0; i < arr.length; i++) { + String s = arr[i]; + if (StringUtils.isBlank(s)) { + continue; + } + List<String> pointNos = new ArrayList<>(); + pointNos.add(s); + dataMap.putAll(measureHandle.getCurrent(pointNos)); + dataMap.putAll(constantHandle.getCurrent(pointNos)); + expression = expression.replace(s, dataMap.get(s).toString()); + } + expression = expression.replace("&", "&&"); + expression = expression.replace("|", "||"); + expression = expression.replace("False", "false"); + expression = expression.replace("True", "true"); + log.info("PointNo=" + dto.getPointNo() + ";expression=" + expression); + String result = javaScriptHandler.eval(expression); + log.info("result=" + result); + if (result == null) { + return null; + } else if (result.contains(JsErrorCode.Infinity.name()) || + result.contains(JsErrorCode.NaN.name())) { + log.info("计算异常,使用默认值"); + return dto.getDefaultValue() == null ? BigDecimal.ZERO : dto.getDefaultValue(); + } else { + if (DataTypeEnum.INT.getCode().equals(dto.getDataType())) { + return new BigDecimal(result).intValue(); + } else if (DataTypeEnum.FLOAT.getCode().equals(dto.getDataType())) { + return new BigDecimal(result).setScale(10, BigDecimal.ROUND_UP).doubleValue(); + } else if (DataTypeEnum.BOOLEAN.getCode().equals(dto.getDataType())) { + return Boolean.parseBoolean(result); + } + } + return result; + } +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/collection/handler/ConstantHandle.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/collection/handler/ConstantHandle.java new file mode 100644 index 0000000..96f7e8a --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/collection/handler/ConstantHandle.java @@ -0,0 +1,56 @@ +package com.iailab.module.data.point.collection.handler; + +import com.iailab.module.data.point.collection.utils.GenInfluxPointValueUtils; +import com.iailab.module.data.point.dto.DaPointDTO; +import com.iailab.module.data.point.service.DaPointService; +import com.iailab.module.data.influxdb.pojo.InfluxPointValuePOJO; +import lombok.extern.slf4j.Slf4j; +import javax.annotation.Resource; +import org.springframework.stereotype.Component; +import org.springframework.util.CollectionUtils; + +import java.util.*; + +/** + * 常量点处理 + * + * @author PanZhibao + * @Description + * @createTime 2023年05月03日 22:28:00 + */ +@Slf4j +@Component +public class ConstantHandle { + + @Resource + private DaPointService daPointService; + + public List<InfluxPointValuePOJO> handle(Date collectTime, List<DaPointDTO> dtos, Map<String, Object> dataMap) { + log.info("常量点处理开始"); + List<InfluxPointValuePOJO> result = new ArrayList<>(); + if (CollectionUtils.isEmpty(dtos)) { + return result; + } + dtos.forEach(dto -> { + InfluxPointValuePOJO pojo = GenInfluxPointValueUtils.getByPoint(dto); + pojo.setTimestamp(collectTime.toInstant()); + dataMap.put(dto.getPointNo(), dto.getDefaultValue()); + result.add(pojo); + }); + log.info("常量点处理结束"); + return result; + } + + public Map<String, Object> getCurrent(List<String> pointNos) { + Map<String, Object> data = new HashMap<>(); + + List<DaPointDTO> pointConstantList = daPointService.getConstantPoint(pointNos); + if (!CollectionUtils.isEmpty(pointConstantList)) { + pointConstantList.forEach(item -> { + data.put(item.getPointNo(), item.getDefaultValue()); + }); + } + return data; + } + +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/collection/handler/MeasureHandle.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/collection/handler/MeasureHandle.java new file mode 100644 index 0000000..44850d5 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/collection/handler/MeasureHandle.java @@ -0,0 +1,235 @@ +package com.iailab.module.data.point.collection.handler; + +import com.iailab.module.data.common.enums.CommonConstant; +import com.iailab.module.data.common.enums.DataSourceType; +import com.iailab.module.data.common.enums.DataTypeEnum; +import com.iailab.module.data.common.utils.TagUtils; +import com.iailab.module.data.channel.kio.collector.KingIOCollector; +import com.iailab.module.data.channel.modbus.collector.ModBusCollector; +import com.iailab.module.data.channel.opcua.collector.OpcUaCollector; +import com.iailab.module.data.point.collection.utils.GenInfluxPointValueUtils; +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.http.collector.HttpCollectorForZxzk; +import com.iailab.module.data.http.service.impl.HttpTagCollector; +import com.iailab.module.data.influxdb.pojo.InfluxPointValuePOJO; +import lombok.extern.slf4j.Slf4j; +import javax.annotation.Resource; +import org.springframework.stereotype.Component; +import org.springframework.util.CollectionUtils; + +import java.math.BigDecimal; +import java.util.*; + +/** + * 测量点处理 + * + * @author PanZhibao + * @Description + * @createTime 2023年05月03日 22:36:00 + */ +@Slf4j +@Component +public class MeasureHandle { + + private BigDecimal maxValue = new BigDecimal("1000000000"); + + private BigDecimal minValue = new BigDecimal("0"); + + @Resource + private ModBusCollector modBusCollector; + + @Resource + private KingIOCollector kingIOCollector; + + @Resource + private OpcUaCollector opcUaCollector; + + @Resource + private HttpTagCollector httpTagCollector; + + @Resource + private HttpCollectorForZxzk httpCollectorForZxzk; + + @Resource + private DaPointService daPointService; + + public List<InfluxPointValuePOJO> handle(Date collectTime, List<DaPointDTO> dtos, Map<String, Object> dataMap) { + log.info("测量点处理开始"); + List<InfluxPointValuePOJO> result = new ArrayList<>(); + if (CollectionUtils.isEmpty(dtos)) { + return result; + } + + List<String[]> opcuaTagIds = new ArrayList<>(); + List<String[]> opcDaTagIds = new ArrayList<>(); + List<String[]> modbusTagIds = new ArrayList<>(); + List<String[]> kioTagIds = new ArrayList<>(); + List<String[]> httpTagZxzk = new ArrayList<>(); + + + List<String> tagYearPeiIds = new ArrayList<>(); + List<String> tagCurrentPerformanceIds = new ArrayList<>(); + List<String> tagCurrentSaleIds = new ArrayList<>(); + List<String> tagPrdTimeDistIds = new ArrayList<>(); + + dtos.stream().forEach(item -> { + if (DataSourceType.OPCUA.getCode().equals(item.getSourceType())) { + opcuaTagIds.add(new String[]{item.getSourceId(), item.getTagNo()}); + } else if (DataSourceType.OPCDA.getCode().equals(item.getSourceType())) { + opcDaTagIds.add(new String[]{item.getSourceId(), item.getTagNo()}); + } else if (DataSourceType.ModBus.getCode().equals(item.getSourceType())) { + modbusTagIds.add(new String[]{item.getSourceId(), item.getTagNo()}); + } else if (DataSourceType.KIO.getCode().equals(item.getSourceType())) { + kioTagIds.add(new String[]{item.getSourceId(), item.getTagNo()}); + } else if (DataSourceType.HTTP.getCode().equals(item.getSourceType())) { + if (CommonConstant.YEAR_PEI_HTTP_TAG.equals(item.getSourceId())) { + tagYearPeiIds.add(item.getTagNo()); + } else if (CommonConstant.CURRENT_PERFORMANCE_HTTP_TAG.equals(item.getSourceId())) { + tagCurrentPerformanceIds.add(item.getTagNo()); + } else if (CommonConstant.CURRENT_SALE_HTTP_TAG.equals(item.getSourceId())) { + tagCurrentSaleIds.add(item.getTagNo()); + } else if (CommonConstant.PRD_TIME_DIST_HTTP_TAG.equals(item.getSourceId())) { + tagPrdTimeDistIds.add(item.getTagNo()); + } else if (CommonConstant.HTTP_API_ZXZK_IH.equals(item.getSourceName())) { + httpTagZxzk.add(new String[]{item.getSourceId(), item.getTagNo()}); + } + } + }); + + if (!CollectionUtils.isEmpty(opcuaTagIds)) { + Map<String, Object> tagValues = opcUaCollector.getTagValues(opcuaTagIds); + this.toCommonResult(collectTime, dtos, tagValues, dataMap, result); + } + if (!CollectionUtils.isEmpty(opcDaTagIds)) { + } + if (!CollectionUtils.isEmpty(modbusTagIds)) { + Map<String, Object> tagValues = modBusCollector.getTagValues(modbusTagIds); + this.toCommonResult(collectTime, dtos, tagValues, dataMap, result); + } + if (!CollectionUtils.isEmpty(kioTagIds)) { + Map<String, Object> tagValues = kingIOCollector.getTagValues(kioTagIds); + this.toCommonResult(collectTime, dtos, tagValues, dataMap, result); + } + if (!CollectionUtils.isEmpty(httpTagZxzk)) { + Map<String, Object> tagValues = httpCollectorForZxzk.getTagValues(httpTagZxzk); + this.toCommonResult(collectTime, dtos, tagValues, dataMap, result); + } + if (!CollectionUtils.isEmpty(tagYearPeiIds)) { + Map<String, Object> tagValues = httpTagCollector.collect(CommonConstant.YEAR_PEI_HTTP_TAG, tagYearPeiIds); + this.toCommonResult(collectTime, dtos, tagValues, dataMap, result); + } else if (!CollectionUtils.isEmpty(tagCurrentPerformanceIds)) { + Map<String, Object> tagValues = httpTagCollector.collect(CommonConstant.CURRENT_PERFORMANCE_HTTP_TAG, tagCurrentPerformanceIds); + this.toCommonResult(collectTime, dtos, tagValues, dataMap, result); + } else if (!CollectionUtils.isEmpty(tagCurrentSaleIds)) { + Map<String, Object> tagValues = httpTagCollector.collect(CommonConstant.CURRENT_SALE_HTTP_TAG, tagCurrentSaleIds); + this.toCommonResult(collectTime, dtos, tagValues, dataMap, result); + } else if (!CollectionUtils.isEmpty(tagPrdTimeDistIds)) { + Map<String, Object> tagValues = httpTagCollector.collect(CommonConstant.PRD_TIME_DIST_HTTP_TAG, tagPrdTimeDistIds); + this.toCommonResult(collectTime, dtos, tagValues, dataMap, result); + } + + log.info("测量点处理结束"); + return result; + } + + private void toCommonResult(Date collectTime, List<DaPointDTO> dtos, Map<String, Object> tagValues, + Map<String, Object> dataMap, List<InfluxPointValuePOJO> result) { + if (!CollectionUtils.isEmpty(tagValues)) { + tagValues.forEach((k, v) -> { + dataMap.put(k, v); + }); + dtos.forEach(dto -> { + String tagId = TagUtils.genTagId(dto.getSourceType(), dto.getSourceName(), dto.getTagNo()); + if (tagValues.get(tagId) != null) { + Object value = handleData(dto, tagValues.get(tagId)); + InfluxPointValuePOJO pojo = GenInfluxPointValueUtils.getByPoint(dto, value); + pojo.setTimestamp(collectTime.toInstant()); + dataMap.put(dto.getPointNo(), value); + result.add(pojo); + } else { + System.out.println("值异常!TagId=" + tagId); + } + }); + } + } + + private Object handleData(DaPointDTO dto, Object value) { + Object result = value; + try { + if (DataTypeEnum.FLOAT.getCode().equals(dto.getDataType()) || DataTypeEnum.INT.getCode().equals(dto.getDataType())) { + BigDecimal rawValue = new BigDecimal(value.toString()); + + // 异常值处理 + if (rawValue.compareTo(maxValue) > 0 || rawValue.compareTo(minValue) < 0) { + rawValue = CommonConstant.BAD_VALUE; + } + BigDecimal coefficient = dto.getUnittransfactor() == null ? BigDecimal.ONE : dto.getUnittransfactor(); + BigDecimal calValue = rawValue.multiply(coefficient); + if (dto.getMaxValue() != null && calValue.compareTo(dto.getMaxValue()) > 0) { + result = dto.getMaxValue(); + } else if (dto.getMinValue() != null && calValue.compareTo(dto.getMinValue()) < 0) { + result = dto.getMinValue(); + } else { + result = calValue; + } + if (DataTypeEnum.FLOAT.getCode().equals(dto.getDataType())) { + result = ((BigDecimal) result).doubleValue(); + } else { + result = ((BigDecimal) result).intValue(); + } + } else if (DataTypeEnum.BOOLEAN.getCode().equals(dto.getDataType())) { + result = Boolean.parseBoolean(value.toString()); + } + + } catch (Exception ex) { + log.warn("handleData异常,PointNo=" + dto.getPointNo()); + ex.printStackTrace(); + } + return result; + } + + public Map<String, Object> getCurrent(List<String> pointNos) { + Map<String, Object> data = new HashMap<>(); + List<DaPointDTO> pointMeasureList = daPointService.getMeasurePoint(pointNos); + pointMeasureList.forEach( + item -> { + try { + Object value = CommonConstant.BAD_VALUE; + if (DataSourceType.OPCUA.getCode().equals(item.getSourceType())) { + value = opcUaCollector.getTagValue(item.getSourceId(), item.getTagNo()); + } else if (DataSourceType.ModBus.getCode().equals(item.getSourceType())) { + value = modBusCollector.getTagValue(item.getSourceId(), item.getTagNo()); + } else if (DataSourceType.KIO.getCode().equals(item.getSourceType())) { + value = kingIOCollector.getTagValue(item.getSourceId(), item.getTagNo()); + } else if (DataSourceType.HTTP.getCode().equals(item.getSourceType())) { + if (CommonConstant.HTTP_API_ZXZK_IH.equals(item.getSourceName())) { + value = httpCollectorForZxzk.getTagValue(item.getSourceId(), item.getTagNo()); + } + } else { + log.info("没有匹配的TagNo=" + item.getTagNo()); + } + log.info("没有匹配的TagNo=" + item.getTagNo()); + log.info("valueStr=" + value.toString()); + log.info("DataType=" + item.getDataType()); + if (!PointDataTypeEnum.BOOLEAN.getCode().equals(item.getDataType())) { + BigDecimal decValue = new BigDecimal(value.toString()); + if (PointDataTypeEnum.FLOAT.getCode().equals(item.getDataType())) { + decValue = decValue.setScale(2, BigDecimal.ROUND_HALF_UP); + } else if (PointDataTypeEnum.INT.getCode().equals(item.getDataType())) { + decValue = decValue.setScale(0, BigDecimal.ROUND_HALF_UP); + } + data.put(item.getPointNo(), decValue); + } else { + data.put(item.getPointNo(), value); + } + } catch (Exception ex) { + ex.printStackTrace(); + } + + } + ); + return data; + } +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/collection/utils/GenInfluxPointValueUtils.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/collection/utils/GenInfluxPointValueUtils.java new file mode 100644 index 0000000..36d6dd1 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/collection/utils/GenInfluxPointValueUtils.java @@ -0,0 +1,72 @@ +package com.iailab.module.data.point.collection.utils; + +import com.iailab.module.data.common.enums.DataTypeEnum; +import com.iailab.module.data.point.dto.DaPointDTO; +import com.iailab.module.data.influxdb.pojo.*; + +/** + * @author PanZhibao + * @Description + * @createTime 2023年05月08日 13:34:00 + */ +public class GenInfluxPointValueUtils { + + public static InfluxPointValuePOJO getByPoint(DaPointDTO dto){ + if (DataTypeEnum.FLOAT.getCode().equals(dto.getDataType())) { + InfluxPointValuePOJO pojo = new InfluxPointValueSimPOJO(); + pojo.setPoint(dto.getPointNo()); + if (dto.getDefaultValue() != null) { + ((InfluxPointValueSimPOJO) pojo).setValue(dto.getDefaultValue().doubleValue()); + } + return pojo; + } else if (DataTypeEnum.INT.getCode().equals(dto.getDataType())) { + InfluxPointValuePOJO pojo = new InfluxPointValueDigPOJO(); + pojo.setPoint(dto.getPointNo()); + if (dto.getDefaultValue() != null) { + ((InfluxPointValueDigPOJO) pojo).setValue(dto.getDefaultValue().intValue()); + } + return pojo; + } else if (DataTypeEnum.BOOLEAN.getCode().equals(dto.getDataType())) { + return new InfluxPointValueDigPOJO(); + } else { + return new InfluxPointValueStrPOJO(); + } + } + + public static InfluxPointValuePOJO getByPoint(DaPointDTO dto, Object value){ + if (DataTypeEnum.FLOAT.getCode().equals(dto.getDataType())) { + InfluxPointValuePOJO pojo = new InfluxPointValueSimPOJO(); + pojo.setPoint(dto.getPointNo()); + if (dto.getDefaultValue() != null) { + ((InfluxPointValueSimPOJO) pojo).setValue(dto.getDefaultValue().doubleValue()); + } + if (value != null) { + ((InfluxPointValueSimPOJO) pojo).setValue(Double.parseDouble(value.toString())); + } + return pojo; + } else if (DataTypeEnum.INT.getCode().equals(dto.getDataType())) { + InfluxPointValuePOJO pojo = new InfluxPointValueDigPOJO(); + pojo.setPoint(dto.getPointNo()); + if (dto.getDefaultValue() != null) { + ((InfluxPointValueDigPOJO) pojo).setValue(dto.getDefaultValue().intValue()); + } + if (value != null) { + ((InfluxPointValueDigPOJO) pojo).setValue(Integer.parseInt(value.toString())); + } + return pojo; + } else if (DataTypeEnum.BOOLEAN.getCode().equals(dto.getDataType().trim())) { + InfluxPointValuePOJO pojo = new InfluxPointValueBoolPOJO(); + pojo.setPoint(dto.getPointNo()); + if (value != null) { + ((InfluxPointValueBoolPOJO) pojo).setValue(Boolean.parseBoolean(value.toString())); + } + return pojo; + } else { + InfluxPointValuePOJO pojo = new InfluxPointValueStrPOJO(); + if (value != null) { + ((InfluxPointValueStrPOJO) pojo).setValue(value.toString()); + } + return new InfluxPointValueStrPOJO(); + } + } +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/common/IncreaseCodeEnum.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/common/IncreaseCodeEnum.java new file mode 100644 index 0000000..1195a2f --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/common/IncreaseCodeEnum.java @@ -0,0 +1,11 @@ +package com.iailab.module.data.point.common; + +/** + * 编号自增主键 + * + * @author PanZhibao + * @date 2021年05月24日 9:41 + */ +public enum IncreaseCodeEnum { + POINT_M, POINT_C, POINT_F +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/common/ItemTypeEnum.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/common/ItemTypeEnum.java new file mode 100644 index 0000000..3e4528f --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/common/ItemTypeEnum.java @@ -0,0 +1,24 @@ +package com.iailab.module.data.point.common; + +/** + * @author PanZhibao + * @date 2021年04月26日 17:20 + */ +public enum ItemTypeEnum { + + NORMAL_ITEM("NormalItem"),MERGE_ITEM("MergeItem"),STEAMSP_ITEM("SteamSpItem"); + + private String name; + + ItemTypeEnum(String name){ + this.name = name; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/common/PointDataTypeEnum.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/common/PointDataTypeEnum.java new file mode 100644 index 0000000..18c5221 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/common/PointDataTypeEnum.java @@ -0,0 +1,34 @@ +package com.iailab.module.data.point.common; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +/** + * @author PanZhibao + * @Description + * @createTime 2023年12月06日 13:05:00 + */ +@Getter +@AllArgsConstructor +public enum PointDataTypeEnum { + + INT("int", "整型"), + FLOAT("float", "浮点型"), + BOOLEAN("boolean", "布尔型"); + + private String code; + private String desc; + + public static PointDataTypeEnum getEumByCode(String code) { + if (code == null) { + return null; + } + + for (PointDataTypeEnum statusEnum : PointDataTypeEnum.values()) { + if (statusEnum.getCode().equals(code)) { + return statusEnum; + } + } + return null; + } +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/common/PointDataTypeUtils.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/common/PointDataTypeUtils.java new file mode 100644 index 0000000..f32bf6c --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/common/PointDataTypeUtils.java @@ -0,0 +1,25 @@ +package com.iailab.module.data.point.common; + +import java.math.BigDecimal; + +/** + * @author PanZhibao + * @Description + * @createTime 2023年12月06日 13:12:00 + */ +public class PointDataTypeUtils { + + public static Object convert(Object value, String type) { + switch (type) { + case "int": + return Integer.parseInt(value.toString()); + case "float": + return new BigDecimal(value.toString()); + case "boolean": + return Boolean.parseBoolean(value.toString()); + default: + break; + } + return value; + } +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/common/PointTypeEnum.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/common/PointTypeEnum.java new file mode 100644 index 0000000..fd9cd3a --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/common/PointTypeEnum.java @@ -0,0 +1,37 @@ +package com.iailab.module.data.point.common; + +/** + * @author PanZhibao + * @date 2021年04月25日 11:41 + */ + +public enum PointTypeEnum { + MEASURE_POINT("MEASURE", "MEASURE"), + CALCULATE_POINT("CALCULATE", "CALCULATE"), + CONSTANT("CONSTANT", "CONSTANT"); + + private String code; + + private String name; + + PointTypeEnum(String code, String name){ + this.code = code; + this.name = name; + } + + 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; + } +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/common/StoreTypeEnum.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/common/StoreTypeEnum.java new file mode 100644 index 0000000..190253d --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/common/StoreTypeEnum.java @@ -0,0 +1,33 @@ +package com.iailab.module.data.point.common; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年05月12日 + */ +@Getter +@AllArgsConstructor +public enum StoreTypeEnum { + + RELATION("relation", "关系库"), + INFLUXDB("influxdb", "时序库"); + + private String code; + private String desc; + + public static PointDataTypeEnum getEumByCode(String code) { + if (code == null) { + return null; + } + + for (PointDataTypeEnum statusEnum : PointDataTypeEnum.values()) { + if (statusEnum.getCode().equals(code)) { + return statusEnum; + } + } + return null; + } +} \ No newline at end of file diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/controller/admin/DaPointController.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/controller/admin/DaPointController.java new file mode 100644 index 0000000..d29f255 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/controller/admin/DaPointController.java @@ -0,0 +1,131 @@ +package com.iailab.module.data.point.controller.admin; + +import com.iailab.framework.common.constant.Constant; +import com.iailab.framework.common.page.PageData; +import com.iailab.framework.common.pojo.CommonResult; +import com.iailab.framework.common.util.validation.ValidationUtils; +import com.iailab.framework.common.validation.group.AddGroup; +import com.iailab.framework.common.validation.group.UpdateGroup; +import com.iailab.framework.common.validation.group.DefaultGroup; +import com.iailab.module.data.point.dto.DaPointDTO; +import com.iailab.module.data.point.service.DaPointService; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.Parameters; +import javax.annotation.Resource; +import javax.annotation.security.PermitAll; +import javax.validation.Valid; + +import io.swagger.v3.oas.annotations.tags.Tag; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +import java.util.List; +import java.util.Map; + +import static com.iailab.framework.common.pojo.CommonResult.success; + + +/** + * @author PanZhibao + * @Description + * @createTime 2024年05月12日 + */ +@Tag(name = "数据采集,测点") +@RestController +@RequestMapping("/data/da/point") +@Validated +public class DaPointController { + + @Resource + private DaPointService daPointService; + + @GetMapping("page") + @Operation(summary = "分页") + @Parameters({ + @Parameter(name = Constant.PAGE, description = "当前页码,从1开始", required = true) , + @Parameter(name = Constant.LIMIT, description = "每页显示记录数", required = true) , + @Parameter(name = Constant.ORDER_FIELD, description = "排序字段") , + @Parameter(name = Constant.ORDER, description = "排序方式,可选值(asc、desc)") + }) + @PreAuthorize("@ss.hasPermission('data:point:query')") + public CommonResult<PageData<DaPointDTO>> page(@RequestParam Map<String, Object> params){ + PageData<DaPointDTO> page = daPointService.page(params); + + return success(page); + } + + @GetMapping("{id}") + @Operation(summary = "信息") + @PreAuthorize("@ss.hasPermission('data:point:query')") + public CommonResult<DaPointDTO> get(@PathVariable("id") String id){ + DaPointDTO data = daPointService.get(id); + + return new CommonResult<DaPointDTO>().setData(data); + } + + @GetMapping("/list") + @Operation(summary = "列表") + @PreAuthorize("@ss.hasPermission('data:point:query')") + public CommonResult<List<DaPointDTO>> list(@Valid @RequestParam Map<String, Object> params) { + List<DaPointDTO> list = daPointService.list(params); + return success(list); + } + + @PostMapping + @Operation(summary = "保存") + @PreAuthorize("@ss.hasPermission('data:point:save')") + public CommonResult save(@RequestBody DaPointDTO dto){ + //效验数据 + ValidationUtils.validate(dto, AddGroup.class, DefaultGroup.class); + daPointService.add(dto); + + return new CommonResult(); + } + + @PutMapping + @Operation(summary = "修改") + @PreAuthorize("@ss.hasPermission('data:point:update')") + public CommonResult update(@RequestBody DaPointDTO dto){ + //效验数据 + ValidationUtils.validate(dto, UpdateGroup.class, DefaultGroup.class); + + daPointService.update(dto); + + return new CommonResult(); + } + + @DeleteMapping + @Operation(summary = "删除") + @PreAuthorize("@ss.hasPermission('data:point:delete')") + public CommonResult delete(@RequestBody String[] ids){ + daPointService.delete(ids); + return new CommonResult(); + } + + @GetMapping("pointNo") + public CommonResult<List<DaPointDTO>> getpoint(@RequestParam Map<String, Object> params){ + List<DaPointDTO> list = daPointService.list(params); + + return new CommonResult<List<DaPointDTO>>().setData(list); + } + + @PutMapping("/enable") + @Operation(summary = "启用") + @Transactional + public CommonResult enable(@RequestBody String[] ids) { + daPointService.enableByIds(ids); + return new CommonResult(); + } + + @PutMapping("/disable") + @Operation(summary = "禁用") + @Transactional + public CommonResult disable(@RequestBody String[] ids) { + daPointService.disableByIds(ids); + return new CommonResult(); + } + +} \ No newline at end of file diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/dao/DaMathPointDao.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/dao/DaMathPointDao.java new file mode 100644 index 0000000..166cca8 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/dao/DaMathPointDao.java @@ -0,0 +1,14 @@ +package com.iailab.module.data.point.dao; + +import com.iailab.framework.common.dao.BaseDao; +import com.iailab.module.data.point.entity.DaMathPointEntity; +import org.apache.ibatis.annotations.Mapper; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年05月12日 + */ +@Mapper +public interface DaMathPointDao extends BaseDao<DaMathPointEntity> { +} \ No newline at end of file diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/dao/DaMeasurePointDao.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/dao/DaMeasurePointDao.java new file mode 100644 index 0000000..8cb1001 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/dao/DaMeasurePointDao.java @@ -0,0 +1,14 @@ +package com.iailab.module.data.point.dao; + +import com.iailab.framework.common.dao.BaseDao; +import com.iailab.module.data.point.entity.DaMeasurePointEntity; +import org.apache.ibatis.annotations.Mapper; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年05月12日 + */ +@Mapper +public interface DaMeasurePointDao extends BaseDao<DaMeasurePointEntity> { +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/dao/DaPointDao.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/dao/DaPointDao.java new file mode 100644 index 0000000..c0678b2 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/dao/DaPointDao.java @@ -0,0 +1,28 @@ +package com.iailab.module.data.point.dao; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.iailab.framework.common.dao.BaseDao; +import com.iailab.module.data.point.dto.DaPointDTO; +import com.iailab.module.data.point.entity.DaPointEntity; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; +import java.util.Map; + +/** + * @author PanZhibao + * @Description + * @createTime 2022年07月12日 13:47:00 + */ +@Mapper +public interface DaPointDao extends BaseDao<DaPointEntity> { + + IPage<DaPointDTO> getPageList(IPage<DaPointEntity> page, @Param("params") Map<String, Object> params); + + List<DaPointDTO> getConstantPoint(Map<String, Object> params); + + List<DaPointDTO> getMeasurePoint(Map<String, Object> params); + + List<DaPointDTO> getMathPoint(Map<String, Object> params); +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/dao/DaPointValueDao.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/dao/DaPointValueDao.java new file mode 100644 index 0000000..ea9fba4 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/dao/DaPointValueDao.java @@ -0,0 +1,14 @@ +package com.iailab.module.data.point.dao; + +import com.iailab.framework.common.dao.BaseDao; +import com.iailab.module.data.point.entity.DaPointValueEntity; +import org.apache.ibatis.annotations.Mapper; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年05月12日 + */ +@Mapper +public interface DaPointValueDao extends BaseDao<DaPointValueEntity> { +} \ No newline at end of file diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/dao/DaSequenceNumDao.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/dao/DaSequenceNumDao.java new file mode 100644 index 0000000..fc7fb56 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/dao/DaSequenceNumDao.java @@ -0,0 +1,14 @@ +package com.iailab.module.data.point.dao; + +import com.iailab.framework.common.dao.BaseDao; +import com.iailab.module.data.point.entity.DaSequenceNumEntity; +import org.apache.ibatis.annotations.Mapper; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年05月12日 + */ +@Mapper +public interface DaSequenceNumDao extends BaseDao<DaSequenceNumEntity> { +} \ No newline at end of file diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/dto/DaMathPointDTO.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/dto/DaMathPointDTO.java new file mode 100644 index 0000000..642b740 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/dto/DaMathPointDTO.java @@ -0,0 +1,34 @@ +package com.iailab.module.data.point.dto; + +import com.iailab.framework.common.validation.group.AddGroup; +import com.iailab.framework.common.validation.group.UpdateGroup; +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 javax.validation.constraints.Null; +import java.io.Serializable; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年05月11日 + */ +@Data +@Tag(name = "计算点表") +public class DaMathPointDTO implements Serializable { + private static final long serialVersionUID = 1L; + + @Schema(description = "id") + @Null(message="{id.null}", groups = AddGroup.class) + @NotNull(message="{id.require}", groups = UpdateGroup.class) + private String id; + + @Schema(description = "测点ID", required = true) + private String pointId; + + @Schema(description = "计算公式", required = true) + private String expression; + +} \ No newline at end of file diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/dto/DaMeasurePointDTO.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/dto/DaMeasurePointDTO.java new file mode 100644 index 0000000..908ba7a --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/dto/DaMeasurePointDTO.java @@ -0,0 +1,42 @@ +package com.iailab.module.data.point.dto; + +import com.iailab.framework.common.validation.group.AddGroup; +import com.iailab.framework.common.validation.group.UpdateGroup; +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 javax.validation.constraints.Null; +import java.io.Serializable; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年05月11日 + */ +@Data +@Tag(name = "测量点表") +public class DaMeasurePointDTO implements Serializable { + private static final long serialVersionUID = 1L; + + @Schema(description = "id") + @Null(message="{id.null}", groups = AddGroup.class) + @NotNull(message="{id.require}", groups = UpdateGroup.class) + private String id; + + @Schema(description = "测点ID", required = true) + private String pointId; + + @Schema(description = "数据源类型", required = true) + private String sourceType; + + @Schema(description = "数据源ID", required = true) + private String sourceId; + + @Schema(description = "测点Tag", required = true) + private String tagNo; + + @Schema(description = "平滑尺度") + private String dimension; +} \ No newline at end of file diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/dto/DaPointDTO.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/dto/DaPointDTO.java new file mode 100644 index 0000000..840fc0f --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/dto/DaPointDTO.java @@ -0,0 +1,115 @@ +package com.iailab.module.data.point.dto; + +import com.iailab.framework.common.validation.group.AddGroup; +import com.iailab.framework.common.validation.group.UpdateGroup; +import com.iailab.framework.excel.core.annotations.DictFormat; +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 javax.validation.constraints.Null; +import java.io.Serializable; +import java.math.BigDecimal; +import java.util.Date; +import java.util.List; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年05月11日 + */ +@Data +@Tag(name = "测点") +public class DaPointDTO implements Serializable { + private static final long serialVersionUID = 1L; + + @Schema(description = "id") + @Null(message="{id.null}", groups = AddGroup.class) + @NotNull(message="{id.require}", groups = UpdateGroup.class) + private String id; + + @Schema(description = "测点编码", required = true) + private String pointNo; + + @Schema(description = "测点名称", required = true) + private String pointName; + + @Schema(description = "测点类型", required = true) + private String pointType; + + @DictFormat("point_type") + private String pointTypeName; + + @Schema(description = "数据类型", required = true) + private String dataType; + + @DictFormat("data_type") + private String dataTypeName; + + @Schema(description = "值类型", required = true) + private String valueType; + + @Schema(description = "存储类型", required = true) + private String storeType; + + @Schema(description = "测量单位", required = true) + private String unit; + + @Schema(description = "单位转换", required = true) + private BigDecimal unittransfactor; + + @Schema(description = "默认值", required = true) + private BigDecimal defaultValue; + + @Schema(description = "最大值") + private BigDecimal maxValue; + + @Schema(description = "最小值") + private BigDecimal minValue; + + @Schema(description = "采集频率", required = true) + private String minfreqid; + + @Schema(description = "备注") + private String remark; + + @Schema(description = "是否启用", required = true) + private Integer isEnable; + + @Schema(description = "创建人") + private Long creator; + + @Schema(description = "创建时间") + private Date createTime; + + @Schema(description = "修改人") + private Long updater; + + @Schema(description = "修改时间") + private Date updateTime; + + @Schema(description = "数据源类型") + private String sourceType; + + @Schema(description = "数据源名称") + private String sourceName; + + @Schema(description = "数据源ID") + private String sourceId; + + @Schema(description = "测点Tag", required = true) + private String tagNo; + + @Schema(description = "计算公式", required = true) + private String expression; + + @Schema(description = "数据源选项") + private List<String> sourceOption; + + @Schema(description = "计算点") + private DaMathPointDTO mathPoint; + + @Schema(description = "测量点") + private DaMeasurePointDTO measurePoint; +} \ No newline at end of file diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/dto/DaPointMeasureDTO.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/dto/DaPointMeasureDTO.java new file mode 100644 index 0000000..a1949c2 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/dto/DaPointMeasureDTO.java @@ -0,0 +1,23 @@ +package com.iailab.module.data.point.dto; + +import io.swagger.v3.oas.annotations.tags.Tag; +import lombok.Data; + +import java.io.Serializable; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年05月12日 + */ +@Data +@Tag(name = "测量点") +public class DaPointMeasureDTO extends DaPointDTO implements Serializable { + private static final long serialVersionUID = 1L; + + private String tagId; + + private String sourceName; + + private String sourceAddress; +} \ No newline at end of file diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/dto/DaPointValueDTO.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/dto/DaPointValueDTO.java new file mode 100644 index 0000000..8f4673f --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/dto/DaPointValueDTO.java @@ -0,0 +1,32 @@ +package com.iailab.module.data.point.dto; + +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.tags.Tag; +import lombok.Data; + +import java.io.Serializable; +import java.math.BigDecimal; +import java.util.Date; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年05月11日 + */ +@Data +@Tag(name = "点值表") +public class DaPointValueDTO implements Serializable { + private static final long serialVersionUID = 1L; + + @Schema(description = "id") + private String id; + + @Schema(description = "测点编码") + private String pointNo; + + @Schema(description = "数据时间") + private Date dataTime; + + @Schema(description = "数据值") + private BigDecimal dataValue; +} \ No newline at end of file diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/dto/DaPointWriteValueDTO.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/dto/DaPointWriteValueDTO.java new file mode 100644 index 0000000..651b90c --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/dto/DaPointWriteValueDTO.java @@ -0,0 +1,19 @@ +package com.iailab.module.data.point.dto; + +import lombok.Data; + +import java.io.Serializable; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年06月05日 + */ +@Data +public class DaPointWriteValueDTO implements Serializable { + private static final long serialVersionUID = 1L; + + private String pointNo; + + private Object pointValue; +} \ No newline at end of file diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/entity/DaMathPointEntity.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/entity/DaMathPointEntity.java new file mode 100644 index 0000000..e7bf244 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/entity/DaMathPointEntity.java @@ -0,0 +1,37 @@ +package com.iailab.module.data.point.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; + +/** + * 计算点表 + * + * @author PanZhibao + * @Description + * @createTime 2024年05月11日 + */ +@Data +@TableName("t_da_math_point") +public class DaMathPointEntity implements Serializable { + private static final long serialVersionUID = 1L; + + /** + * id + */ + @TableId(type = IdType.ASSIGN_UUID) + private String id; + + /** + * 测点ID + */ + private String pointId; + + /** + * 计算公式 + */ + private String expression; +} \ No newline at end of file diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/entity/DaMeasurePointEntity.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/entity/DaMeasurePointEntity.java new file mode 100644 index 0000000..4a15643 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/entity/DaMeasurePointEntity.java @@ -0,0 +1,52 @@ +package com.iailab.module.data.point.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; + +/** + * 测量点表 + * + * @author PanZhibao + * @Description + * @createTime 2024年05月11日 + */ +@Data +@TableName("t_da_measure_point") +public class DaMeasurePointEntity implements Serializable { + private static final long serialVersionUID = 1L; + + /** + * id + */ + @TableId(type = IdType.ASSIGN_UUID) + private String id; + + /** + * 测点ID + */ + private String pointId; + + /** + * 数据源类型 + */ + private String sourceType; + + /** + * 数据源ID + */ + private String sourceId; + + /** + * 测点Tag + */ + private String tagNo; + + /** + * 平滑尺度 + */ + private Integer dimension; +} \ No newline at end of file diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/entity/DaPointEntity.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/entity/DaPointEntity.java new file mode 100644 index 0000000..6c85645 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/entity/DaPointEntity.java @@ -0,0 +1,113 @@ +package com.iailab.module.data.point.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.math.BigDecimal; +import java.util.Date; + +/** + * 测点表 + * + * @author lirm ${email} + * @since 1.0.0 2023-06-21 + */ +@Data +@TableName("t_da_point") +public class DaPointEntity implements Serializable { + private static final long serialVersionUID = 1L; + + /** + * id + */ + @TableId(type = IdType.ASSIGN_UUID) + private String id; + + /** + * 测点编码 + */ + private String pointNo; + + /** + * 测点名称 + */ + private String pointName; + + /** + * 测点类型 + */ + private String pointType; + + /** + * 数据类型 + */ + private String dataType; + + /** + * 值类型 + */ + private String valueType; + + /** + * 存储类型 + */ + private String storeType; + + /** + * 测量单位 + */ + private String unit; + + /** + * 单位转换 + */ + private BigDecimal unittransfactor; + + /** + * 默认值 + */ + private BigDecimal defaultValue; + + /** + * 最大值 + */ + private BigDecimal maxValue; + + /** + * 最小值 + */ + private BigDecimal minValue; + + /** + * 采集频率 + */ + private String minfreqid; + + /** + * 备注 + */ + private String remark; + /** + * 是否启用 + */ + private Integer isEnable; + /** + * 创建人 + */ + private Long creator; + /** + * 创建时间 + */ + private Date createTime; + /** + * 修改人 + */ + private Long updater; + /** + * 修改时间 + */ + private Date updateTime; +} \ No newline at end of file diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/entity/DaPointValueEntity.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/entity/DaPointValueEntity.java new file mode 100644 index 0000000..049e947 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/entity/DaPointValueEntity.java @@ -0,0 +1,44 @@ +package com.iailab.module.data.point.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.math.BigDecimal; +import java.util.Date; + +/** + * 点值表 + * + * @author PanZhibao + * @Description + * @createTime 2024年05月11日 + */ +@Data +@TableName("t_da_point_value") +public class DaPointValueEntity implements Serializable { + private static final long serialVersionUID = 1L; + + /** + * id + */ + @TableId(type = IdType.ASSIGN_UUID) + private String id; + + /** + * 测点编码 + */ + private String pointNo; + + /** + * 数据时间 + */ + private Date dataTime; + + /** + * 数据值 + */ + private BigDecimal dataValue; +} \ No newline at end of file diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/entity/DaSequenceNumEntity.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/entity/DaSequenceNumEntity.java new file mode 100644 index 0000000..24db753 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/entity/DaSequenceNumEntity.java @@ -0,0 +1,30 @@ +package com.iailab.module.data.point.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; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年05月12日 + */ +@Data +@TableName("t_da_sequence_num") +public class DaSequenceNumEntity implements Serializable { + private static final long serialVersionUID = 1L; + + @TableId(type = IdType.ASSIGN_UUID) + private String id; + + private String code; + + private String name; + + private Integer sequenceNum; + + private String prefix; +} \ No newline at end of file diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/service/DaMathPointService.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/service/DaMathPointService.java new file mode 100644 index 0000000..38f6fc5 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/service/DaMathPointService.java @@ -0,0 +1,23 @@ +package com.iailab.module.data.point.service; + +import com.iailab.framework.common.service.BaseService; +import com.iailab.module.data.point.entity.DaMathPointEntity; +import com.iailab.module.data.point.dto.DaMathPointDTO; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年05月12日 + */ +public interface DaMathPointService extends BaseService<DaMathPointEntity> { + + void add(DaMathPointDTO dto, String pointId); + + DaMathPointDTO getByPoint(String pointId); + + void update(DaMathPointDTO dto); + + void deleteBatch(String[] ids); + + void deleteByPoint(String[] ids); +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/service/DaMeasurePointService.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/service/DaMeasurePointService.java new file mode 100644 index 0000000..90e7361 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/service/DaMeasurePointService.java @@ -0,0 +1,23 @@ +package com.iailab.module.data.point.service; + +import com.iailab.framework.common.service.BaseService; +import com.iailab.module.data.point.dto.DaMeasurePointDTO; +import com.iailab.module.data.point.entity.DaMeasurePointEntity; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年05月12日 + */ +public interface DaMeasurePointService extends BaseService<DaMeasurePointEntity> { + + void add(DaMeasurePointDTO dto, String pointId); + + DaMeasurePointDTO getByPoint(String id); + + void update(DaMeasurePointDTO dto); + + void deleteBatch(String[] ids); + + void deleteByPoint(String[] ids); +} \ No newline at end of file diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/service/DaPointService.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/service/DaPointService.java new file mode 100644 index 0000000..0f16bf2 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/service/DaPointService.java @@ -0,0 +1,53 @@ +package com.iailab.module.data.point.service; + +import com.iailab.framework.common.page.PageData; +import com.iailab.framework.common.service.BaseService; +import com.iailab.module.data.point.dto.DaPointDTO; +import com.iailab.module.data.point.entity.DaPointEntity; + +import java.util.List; +import java.util.Map; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年05月12日 + */ +public interface DaPointService extends BaseService<DaPointEntity> { + + PageData<DaPointDTO> page(Map<String, Object> params); + + DaPointDTO get(String id); + + List<DaPointDTO> list(Map<String, Object> params); + + void add(DaPointDTO dataPoint); + + void update(DaPointDTO dataPoint); + + void delete(String[] ids); + + List<DaPointDTO> getConstantPoint(String freq); + + List<DaPointDTO> getConstantPoint(List<String> pointNos); + + List<DaPointDTO> getMeasurePoint(String freq); + + List<DaPointDTO> getMeasurePoint(List<String> pointNos); + + DaPointDTO getMeasurePointByNo(String pointNo); + + List<DaPointDTO> getMathPoint(String freq); + + List<DaPointDTO> getMathPoint(List<String> pointNos); + + DaPointDTO getByNo(String pointNo); + + List<DaPointDTO> getByNos(List<String> pointNos); + + void enableByIds(String[] ids); + + void disableByIds(String[] ids); + + void updateDefaultValue(DaPointDTO dto); +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/service/DaPointValueService.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/service/DaPointValueService.java new file mode 100644 index 0000000..c583be5 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/service/DaPointValueService.java @@ -0,0 +1,20 @@ +package com.iailab.module.data.point.service; + +import com.iailab.framework.common.service.BaseService; +import com.iailab.module.data.api.dto.ApiPointValueQueryDTO; +import com.iailab.module.data.point.entity.DaPointValueEntity; + +import java.util.List; +import java.util.Map; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年05月12日 + */ +public interface DaPointValueService extends BaseService<DaPointValueEntity> { + + void add(DaPointValueEntity entity); + + Map<String, List<Map<String, Object>>> getHistoryList(ApiPointValueQueryDTO queryDto); +} \ No newline at end of file diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/service/DaSequenceNumService.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/service/DaSequenceNumService.java new file mode 100644 index 0000000..04f42dd --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/service/DaSequenceNumService.java @@ -0,0 +1,14 @@ +package com.iailab.module.data.point.service; + +import com.iailab.framework.common.service.BaseService; +import com.iailab.module.data.point.entity.DaSequenceNumEntity; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年05月12日 + */ +public interface DaSequenceNumService extends BaseService<DaSequenceNumEntity> { + + String getAndIncreaseByCode (String code); +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/service/impl/DaMathPointServiceImpl.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/service/impl/DaMathPointServiceImpl.java new file mode 100644 index 0000000..6d17ce7 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/service/impl/DaMathPointServiceImpl.java @@ -0,0 +1,54 @@ +package com.iailab.module.data.point.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.iailab.framework.common.service.impl.BaseServiceImpl; +import com.iailab.framework.common.util.object.ConvertUtils; +import com.iailab.module.data.point.dao.DaMathPointDao; +import com.iailab.module.data.point.dto.DaMathPointDTO; +import com.iailab.module.data.point.entity.DaMathPointEntity; +import com.iailab.module.data.point.service.DaMathPointService; +import org.springframework.stereotype.Service; + +import java.util.Arrays; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年05月12日 + */ +@Service +public class DaMathPointServiceImpl extends BaseServiceImpl<DaMathPointDao, DaMathPointEntity> implements DaMathPointService { + + @Override + public void add(DaMathPointDTO dto, String pointId) { + DaMathPointEntity entity = ConvertUtils.sourceToTarget(dto, DaMathPointEntity.class); + entity.setPointId(pointId); + baseDao.insert(entity); + } + + @Override + public DaMathPointDTO getByPoint(String pointId) { + QueryWrapper<DaMathPointEntity> wrapper = new QueryWrapper<>(); + wrapper.eq("point_id", pointId); + DaMathPointEntity entity = baseDao.selectOne(wrapper); + return ConvertUtils.sourceToTarget(entity, DaMathPointDTO.class); + } + + @Override + public void update(DaMathPointDTO dto) { + DaMathPointEntity entity = ConvertUtils.sourceToTarget(dto, DaMathPointEntity.class); + this.updateById(entity); + } + + @Override + public void deleteBatch(String[] ids) { + baseDao.deleteBatchIds(Arrays.asList(ids)); + } + + @Override + public void deleteByPoint(String[] ids) { + QueryWrapper<DaMathPointEntity> wrapper = new QueryWrapper<>(); + wrapper.in("point_id", Arrays.asList(ids)); + baseDao.delete(wrapper); + } +} \ No newline at end of file diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/service/impl/DaMeasurePointServiceImpl.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/service/impl/DaMeasurePointServiceImpl.java new file mode 100644 index 0000000..fc3c349 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/service/impl/DaMeasurePointServiceImpl.java @@ -0,0 +1,56 @@ +package com.iailab.module.data.point.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.iailab.framework.common.service.impl.BaseServiceImpl; +import com.iailab.framework.common.util.object.ConvertUtils; +import com.iailab.module.data.point.dao.DaMeasurePointDao; +import com.iailab.module.data.point.entity.DaMeasurePointEntity; +import com.iailab.module.data.point.service.DaMeasurePointService; +import com.iailab.module.data.point.dto.DaMeasurePointDTO; +import org.springframework.stereotype.Service; + +import java.util.Arrays; +import java.util.UUID; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年05月12日 + */ +@Service +public class DaMeasurePointServiceImpl extends BaseServiceImpl<DaMeasurePointDao, DaMeasurePointEntity> implements DaMeasurePointService { + + @Override + public void add(DaMeasurePointDTO dto, String pointId) { + DaMeasurePointEntity entity = ConvertUtils.sourceToTarget(dto, DaMeasurePointEntity.class); + entity.setId(UUID.randomUUID().toString()); + entity.setPointId(pointId); + baseDao.insert(entity); + } + + @Override + public DaMeasurePointDTO getByPoint(String pointId) { + QueryWrapper<DaMeasurePointEntity> wrapper = new QueryWrapper<>(); + wrapper.eq("point_id", pointId); + DaMeasurePointEntity entity = baseDao.selectOne(wrapper); + return ConvertUtils.sourceToTarget(entity, DaMeasurePointDTO.class); + } + + @Override + public void update(DaMeasurePointDTO dto) { + DaMeasurePointEntity entity = ConvertUtils.sourceToTarget(dto, DaMeasurePointEntity.class); + this.updateById(entity); + } + + @Override + public void deleteBatch(String[] ids) { + baseDao.deleteBatchIds(Arrays.asList(ids)); + } + + @Override + public void deleteByPoint(String[] ids) { + QueryWrapper<DaMeasurePointEntity> wrapper = new QueryWrapper<>(); + wrapper.in("point_id", ids); + baseDao.delete(wrapper); + } +} \ No newline at end of file diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/service/impl/DaPointServiceImpl.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/service/impl/DaPointServiceImpl.java new file mode 100644 index 0000000..57ff47b --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/service/impl/DaPointServiceImpl.java @@ -0,0 +1,257 @@ +package com.iailab.module.data.point.service.impl; + +import com.alibaba.fastjson.JSONArray; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.iailab.framework.common.constant.Constant; +import com.iailab.module.data.common.enums.CommonConstant; +import com.iailab.module.data.common.enums.IsEnableEnum; +import com.iailab.framework.common.page.PageData; +import com.iailab.framework.common.service.impl.BaseServiceImpl; +import com.iailab.framework.common.util.object.ConvertUtils; +import com.iailab.module.data.point.common.IncreaseCodeEnum; +import com.iailab.module.data.point.dao.DaPointDao; +import com.iailab.module.data.point.service.DaMeasurePointService; +import com.iailab.module.data.point.common.PointTypeEnum; +import com.iailab.module.data.point.dto.DaMeasurePointDTO; +import com.iailab.module.data.point.dto.DaPointDTO; +import com.iailab.module.data.point.entity.DaPointEntity; +import com.iailab.module.data.point.service.DaMathPointService; +import com.iailab.module.data.point.service.DaPointService; +import com.iailab.module.data.point.service.DaSequenceNumService; +import org.apache.commons.lang3.StringUtils; +import javax.annotation.Resource; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.util.CollectionUtils; + +import java.util.*; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年05月12日 + */ +@Service +public class DaPointServiceImpl extends BaseServiceImpl<DaPointDao, DaPointEntity> implements DaPointService { + + @Resource + private DaMeasurePointService daMeasurePointService; + + @Resource + private DaMathPointService daMathPointService; + + @Resource + private DaSequenceNumService daSequenceNumService; + + @Override + public PageData<DaPointDTO> page(Map<String, Object> params) { + IPage<DaPointDTO> page = baseDao.getPageList( + getPage(params, Constant.CREATE_TIME, false), + params + ); + return getPageData(page, DaPointDTO.class); + } + + @Override + public DaPointDTO get(String id) { + DaPointEntity entity = baseDao.selectById(id); + DaPointDTO result = ConvertUtils.sourceToTarget(entity, DaPointDTO.class); + if (PointTypeEnum.MEASURE_POINT.getCode().equals(result.getPointType())) { + DaMeasurePointDTO measurePoint = daMeasurePointService.getByPoint(id); + result.setMeasurePoint(measurePoint); + List<String> sourceOption = new ArrayList<>(); + sourceOption.add(measurePoint.getSourceType()); + sourceOption.add(measurePoint.getSourceId()); + sourceOption.add(measurePoint.getTagNo()); + result.setSourceOption(sourceOption); + } else if (PointTypeEnum.CALCULATE_POINT.getCode().equals(result.getPointType())) { + result.setMathPoint(daMathPointService.getByPoint(id)); + } + return result; + } + + @Override + public List<DaPointDTO> list(Map<String, Object> params) { + String page = (String) params.get("page"); + String limit = (String) params.get("limit"); + String pointType = (String)params.get("pointType"); + List<String> pointNos = new ArrayList<>(); + if (params.get("pointNos") != null) { + pointNos = JSONArray.parseArray(JSONArray.toJSONString(params.get("pointNos")), String.class); + } + String pointNoLike = (String)params.get("pointNoLike"); + QueryWrapper<DaPointEntity> queryWrapper = new QueryWrapper(); + queryWrapper.eq(StringUtils.isNotBlank(pointType), "point_type", pointType) + .in(!CollectionUtils.isEmpty(pointNos),"point_no", pointNos) + .like(StringUtils.isNotBlank(pointNoLike), "point_no", pointNoLike) + .last("limit 1, 10"); + List<DaPointEntity> list = baseDao.selectList(queryWrapper); + return ConvertUtils.sourceToTarget(list, DaPointDTO.class); + } + + @Override + @Transactional(rollbackFor = Exception.class) + 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())); + } + daPointEntity.setIsEnable(CommonConstant.IS_ENABLE); + daPointEntity.setCreateTime(new Date()); + baseDao.insert(daPointEntity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void update(DaPointDTO dataPoint) { + DaPointEntity daPointEntity = ConvertUtils.sourceToTarget(dataPoint, DaPointEntity.class); + daPointEntity.setUpdateTime(new Date()); + baseDao.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.equals(dataPoint.getPointType())) { + daMathPointService.update(dataPoint.getMathPoint()); + } + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void delete(String[] ids) { + baseDao.deleteBatchIds(Arrays.asList(ids)); + daMeasurePointService.deleteByPoint(ids); + daMathPointService.deleteByPoint(ids); + } + + @Override + public List<DaPointDTO> getConstantPoint(String freq) { + Map<String, Object> params = new HashMap<>(); + params.put("pointType", PointTypeEnum.CONSTANT.getCode()); + params.put("isEnable", CommonConstant.IS_ENABLE); + params.put("minfreqid", freq); + return baseDao.getConstantPoint(params); + } + + @Override + public List<DaPointDTO> getConstantPoint(List<String> pointNos) { + Map<String, Object> params = new HashMap<>(); + params.put("pointType", PointTypeEnum.CONSTANT.getCode()); + params.put("isEnable", CommonConstant.IS_ENABLE); + params.put("pointNos", pointNos); + return baseDao.getConstantPoint(params); + } + + @Override + public List<DaPointDTO> getMeasurePoint(String freq) { + Map<String, Object> params = new HashMap<>(); + params.put("pointType", PointTypeEnum.MEASURE_POINT.getCode()); + params.put("isEnable", CommonConstant.IS_ENABLE); + params.put("minfreqid", freq); + return baseDao.getMeasurePoint(params); + } + + @Override + public List<DaPointDTO> getMeasurePoint(List<String> pointNos) { + Map<String, Object> params = new HashMap<>(); + params.put("pointType", PointTypeEnum.MEASURE_POINT.getCode()); + params.put("isEnable", CommonConstant.IS_ENABLE); + params.put("pointNos", pointNos); + return baseDao.getMeasurePoint(params); + } + + @Override + public DaPointDTO getMeasurePointByNo(String pointNo) { + Map<String, Object> params = new HashMap<>(); + params.put("pointType", PointTypeEnum.MEASURE_POINT.getCode()); + params.put("pointNo", pointNo); + List<DaPointDTO> list = baseDao.getMeasurePoint(params); + if (CollectionUtils.isEmpty(list)) { + return null; + } + return list.get(0); + } + + @Override + public List<DaPointDTO> getMathPoint(String freq) { + Map<String, Object> params = new HashMap<>(); + params.put("pointType", PointTypeEnum.CALCULATE_POINT.getCode()); + params.put("isEnable", CommonConstant.IS_ENABLE); + params.put("minfreqid", freq); + return baseDao.getMathPoint(params); + } + + @Override + public List<DaPointDTO> getMathPoint(List<String> pointNos) { + Map<String, Object> params = new HashMap<>(); + params.put("pointType", PointTypeEnum.CALCULATE_POINT.getCode()); + params.put("isEnable", CommonConstant.IS_ENABLE); + params.put("pointNos", pointNos); + return baseDao.getMathPoint(params); + } + + @Override + public DaPointDTO getByNo(String pointNo) { + QueryWrapper<DaPointEntity> wrapper = new QueryWrapper<>(); + wrapper.eq("point_no", pointNo); + DaPointEntity entity = baseDao.selectOne(wrapper); + return ConvertUtils.sourceToTarget(entity, DaPointDTO.class); + } + + @Override + public List<DaPointDTO> getByNos(List<String> pointNos) { + QueryWrapper<DaPointEntity> wrapper = new QueryWrapper<>(); + wrapper.in("point_no", pointNos); + List<DaPointEntity> list = baseDao.selectList(wrapper); + return ConvertUtils.sourceToTarget(list, DaPointDTO.class); + } + + @Override + public void updateDefaultValue(DaPointDTO dto) { + QueryWrapper<DaPointEntity> wrapper = new QueryWrapper<>(); + wrapper.eq("point_no", dto.getPointNo()); + DaPointEntity entity = new DaPointEntity(); + entity.setDefaultValue(dto.getDefaultValue()); + baseDao.update(entity, wrapper); + } + + @Override + public void enableByIds(String[] ids) { + if (CollectionUtils.isEmpty(Arrays.asList(ids))) { + return; + } + Arrays.asList(ids).forEach(item -> { + DaPointEntity entity = new DaPointEntity(); + entity.setId(item); + entity.setIsEnable(IsEnableEnum.ENABLE.value()); + baseDao.updateById(entity); + }); + } + + @Override + public void disableByIds(String[] ids) { + if (CollectionUtils.isEmpty(Arrays.asList(ids))) { + return; + } + Arrays.asList(ids).forEach(item -> { + DaPointEntity entity = new DaPointEntity(); + entity.setId(item); + entity.setIsEnable(IsEnableEnum.DISABLE.value()); + baseDao.updateById(entity); + }); + } +} \ No newline at end of file diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/service/impl/DaPointValueServiceImpl.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/service/impl/DaPointValueServiceImpl.java new file mode 100644 index 0000000..5b31865 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/service/impl/DaPointValueServiceImpl.java @@ -0,0 +1,59 @@ +package com.iailab.module.data.point.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.iailab.framework.common.service.impl.BaseServiceImpl; +import com.iailab.module.data.api.dto.ApiPointValueQueryDTO; +import com.iailab.module.data.point.dao.DaPointValueDao; +import com.iailab.module.data.point.entity.DaPointValueEntity; +import com.iailab.module.data.point.service.DaPointValueService; +import org.apache.commons.lang3.ObjectUtils; +import org.springframework.stereotype.Service; + +import java.math.BigDecimal; +import java.util.*; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年05月12日 + */ +@Service +public class DaPointValueServiceImpl extends BaseServiceImpl<DaPointValueDao, DaPointValueEntity> implements DaPointValueService { + + private String VALUE = "value"; + + private String TIME = "time"; + + @Override + public void add(DaPointValueEntity entity) { + entity.setId(UUID.randomUUID().toString()); + baseDao.insert(entity); + } + + @Override + public Map<String, List<Map<String, Object>>> getHistoryList(ApiPointValueQueryDTO queryDto) { + Map<String, List<Map<String, Object>>> map = new HashMap<>(); + List<DaPointValueEntity> daPointValueEntities; + for(int i=0;i<queryDto.getPointNos().size();i++){ + QueryWrapper<DaPointValueEntity> queryWrapper = new QueryWrapper<DaPointValueEntity>() + .eq("point_no", queryDto.getPointNos().get(i)) + .ge("data_time", queryDto.getStart()) + .le("data_time", queryDto.getEnd()) + .orderByAsc("data_time"); + daPointValueEntities = baseDao.selectList(queryWrapper); + List<Map<String, Object>> list = new ArrayList<>(); + if(ObjectUtils.isNotEmpty(daPointValueEntities)) { + daPointValueEntities.stream().forEach(daPointValueEntity -> { + Map<String, Object> dataMap = new HashMap<>(); + BigDecimal dataValue = daPointValueEntity.getDataValue(); + Date dataTime = daPointValueEntity.getDataTime(); + dataMap.put(VALUE, dataValue); + dataMap.put(TIME, dataTime); + list.add(dataMap); + }); + } + map.put(queryDto.getPointNos().get(i),list); + } + return map; + } +} \ No newline at end of file diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/service/impl/DaSequenceNumServiceImpl.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/service/impl/DaSequenceNumServiceImpl.java new file mode 100644 index 0000000..0333317 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/service/impl/DaSequenceNumServiceImpl.java @@ -0,0 +1,32 @@ +package com.iailab.module.data.point.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.iailab.framework.common.service.impl.BaseServiceImpl; +import com.iailab.module.data.point.dao.DaSequenceNumDao; +import com.iailab.module.data.point.entity.DaSequenceNumEntity; +import com.iailab.module.data.point.service.DaSequenceNumService; +import org.springframework.stereotype.Service; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年05月12日 + */ +@Service +public class DaSequenceNumServiceImpl extends BaseServiceImpl<DaSequenceNumDao, DaSequenceNumEntity> implements DaSequenceNumService { + + @Override + public synchronized String getAndIncreaseByCode (String code) { + QueryWrapper queryWrapper = new QueryWrapper<DaSequenceNumEntity>(); + queryWrapper.eq("code", code); + DaSequenceNumEntity sequenceNumEntity = baseDao.selectOne(queryWrapper); + + DaSequenceNumEntity sequenceNumUpdate = new DaSequenceNumEntity(); + sequenceNumUpdate.setId(sequenceNumEntity.getId()); + sequenceNumUpdate.setSequenceNum(sequenceNumEntity.getSequenceNum() + 1); + baseDao.updateById(sequenceNumUpdate); + + String str = String.format("%010d", sequenceNumEntity.getSequenceNum()); + return sequenceNumEntity.getPrefix() + str; + } +} \ No newline at end of file diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/package-info.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/package-info.java new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/package-info.java diff --git a/iailab-module-data/iailab-module-data-biz/src/main/resources/application-dev.yml b/iailab-module-data/iailab-module-data-biz/src/main/resources/application-dev.yml new file mode 100644 index 0000000..4e61e38 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/resources/application-dev.yml @@ -0,0 +1,82 @@ +spring: + # 数据源配置项 + autoconfigure: + exclude: + - com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure # 排除 Druid 的自动配置,使用 dynamic-datasource-spring-boot-starter 配置多数据源 + datasource: + druid: # Druid 【监控】相关的全局配置 + web-stat-filter: + enabled: true + stat-view-servlet: + enabled: true + allow: # 设置白名单,不填则允许所有访问 + url-pattern: /druid/* + login-username: # 控制台管理用户名和密码 + login-password: + filter: + stat: + enabled: true + log-slow-sql: true # 慢 SQL 记录 + slow-sql-millis: 100 + merge-sql: true + wall: + config: + multi-statement-allow: true + dynamic: # 多数据源配置 + druid: # Druid 【连接池】相关的全局配置 + initial-size: 1 # 初始连接数 + min-idle: 1 # 最小连接池数量 + max-active: 20 # 最大连接池数量 + max-wait: 600000 # 配置获取连接等待超时的时间,单位:毫秒 + time-between-eviction-runs-millis: 60000 # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位:毫秒 + min-evictable-idle-time-millis: 300000 # 配置一个连接在池中最小生存的时间,单位:毫秒 + max-evictable-idle-time-millis: 900000 # 配置一个连接在池中最大生存的时间,单位:毫秒 + validation-query: SELECT 1 FROM DUAL # 配置检测连接是否有效 + test-while-idle: true + test-on-borrow: false + test-on-return: false + primary: master + datasource: + master: + url: jdbc:mysql://127.0.0.1:3306/iailab_ntt_data?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例 + # url: jdbc:mysql://127.0.0.1:3306/iailab-platform?useSSL=true&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai # MySQL Connector/J 5.X 连接的示例 + # url: jdbc:postgresql://127.0.0.1:5432/ruoyi-vue-pro # PostgreSQL 连接的示例 + # url: jdbc:oracle:thin:@127.0.0.1:1521:xe # Oracle 连接的示例 + # url: jdbc:sqlserver://127.0.0.1:1433;DatabaseName=ruoyi-vue-pro # SQLServer 连接的示例 + # url: jdbc:dm://10.211.55.4:5236?schema=RUOYI_VUE_PRO # DM 连接的示例 + username: root + password: 123456 + # username: sa # SQL Server 连接的示例 + # password: JSm:g(*%lU4ZAkz06cd52KqT3)i1?H7W # SQL Server 连接的示例 + # username: SYSDBA # DM 连接的示例 + # password: SYSDBA # DM 连接的示例 + slave: # 模拟从库,可根据自己需要修改 + lazy: true # 开启懒加载,保证启动速度 + url: jdbc:mysql://127.0.0.1:3306/iailab_ntt_data?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true + username: root + password: 123456 + redis: + database: 0 + host: 127.0.0.1 + port: 6379 + password: '123456' # 密码(默认为空) + timeout: 6000ms # 连接超时时长(毫秒) + jedis: + pool: + max-active: 1000 # 连接池最大连接数(使用负值表示没有限制) + max-wait: -1ms # 连接池最大阻塞等待时间(使用负值表示没有限制) + max-idle: 10 # 连接池中的最大空闲连接 + min-idle: 5 # 连接池中的最小空闲连接 + +oadp: + domain: http://172.16.1.148:6010 + +influx-db: + org: IAILab + bucket: whs_data + token: gxhXM4H1VOBv07kYXKWyPag_zJ8_oChP4ooZ3u-BkSae9LS8R1wWzJYlmUjL3Qe9t1hDU3DtoYD5HTgjWoTGOg== + url: http://localhost:8086 + +iems: + upload-dir: D:/DLUT/upload/ + diff --git a/iailab-module-data/iailab-module-data-biz/src/main/resources/application-local.yml b/iailab-module-data/iailab-module-data-biz/src/main/resources/application-local.yml new file mode 100644 index 0000000..8829ec0 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/resources/application-local.yml @@ -0,0 +1,170 @@ +--- #################### 注册中心 + 配置中心相关配置 #################### + +spring: + cloud: + nacos: + server-addr: @nacos.server@ # Nacos 服务器地址 + username: @nacos.username@ + password: @nacos.password@ + discovery: # 【配置中心】配置项 + namespace: @nacos.namespace@ # 命名空间。这里使用 dev 开发环境 + group: DEFAULT_GROUP # 使用的 Nacos 配置分组,默认为 DEFAULT_GROUP + metadata: + version: @nacos.metadata.version@ # 服务实例的版本号,可用于灰度发布 + config: # 【注册中心】配置项 + namespace: @nacos.namespace@ # 命名空间。这里使用 dev 开发环境 + group: DEFAULT_GROUP # 使用的 Nacos 配置分组,默认为 DEFAULT_GROUP + +--- #################### 数据库相关配置 #################### +spring: + # 数据源配置项 + autoconfigure: + exclude: + - com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure # 排除 Druid 的自动配置,使用 dynamic-datasource-spring-boot-starter 配置多数据源 + - de.codecentric.boot.admin.client.config.SpringBootAdminClientAutoConfiguration # 禁用 Spring Boot Admin 的 Client 的自动配置 + datasource: + druid: # Druid 【监控】相关的全局配置 + web-stat-filter: + enabled: true + stat-view-servlet: + enabled: true + allow: # 设置白名单,不填则允许所有访问 + url-pattern: /druid/* + login-username: # 控制台管理用户名和密码 + login-password: + filter: + stat: + enabled: true + log-slow-sql: true # 慢 SQL 记录 + slow-sql-millis: 100 + merge-sql: true + wall: + config: + multi-statement-allow: true + dynamic: # 多数据源配置 + druid: # Druid 【连接池】相关的全局配置 + initial-size: 1 # 初始连接数 + min-idle: 1 # 最小连接池数量 + max-active: 20 # 最大连接池数量 + max-wait: 600000 # 配置获取连接等待超时的时间,单位:毫秒 + time-between-eviction-runs-millis: 60000 # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位:毫秒 + min-evictable-idle-time-millis: 300000 # 配置一个连接在池中最小生存的时间,单位:毫秒 + max-evictable-idle-time-millis: 900000 # 配置一个连接在池中最大生存的时间,单位:毫秒 + validation-query: SELECT 1 FROM DUAL # 配置检测连接是否有效 + test-while-idle: true + test-on-borrow: false + test-on-return: false + primary: master + datasource: + master: + url: jdbc:mysql://127.0.0.1:3306/iailab_ntt_data?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例 + # url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=true&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai # MySQL Connector/J 5.X 连接的示例 + # url: jdbc:postgresql://127.0.0.1:5432/ruoyi-vue-pro # PostgreSQL 连接的示例 + # url: jdbc:oracle:thin:@127.0.0.1:1521:xe # Oracle 连接的示例 + # url: jdbc:sqlserver://127.0.0.1:1433;DatabaseName=ruoyi-vue-pro # SQLServer 连接的示例 + # url: jdbc:dm://10.211.55.4:5236?schema=RUOYI_VUE_PRO # DM 连接的示例 + username: root + password: 123456 + # username: sa # SQL Server 连接的示例 + # password: JSm:g(*%lU4ZAkz06cd52KqT3)i1?H7W # SQL Server 连接的示例 + # username: SYSDBA # DM 连接的示例 + # password: SYSDBA # DM 连接的示例 + slave: # 模拟从库,可根据自己需要修改 + lazy: true # 开启懒加载,保证启动速度 + url: jdbc:mysql://127.0.0.1:3306/iailab_ntt_data?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true + username: root + password: 123456 + + # Redis 配置。Redisson 默认的配置足够使用,一般不需要进行调优 + redis: + host: 172.16.8.100 # 地址 + port: 6379 # 端口 + database: 0 # 数据库索引 + password: 123456 # 密码,建议生产环境开启 + +--- #################### MQ 消息队列相关配置 #################### + +# rocketmq 配置项,对应 RocketMQProperties 配置类 +rocketmq: + name-server: 127.0.0.1:9876 # RocketMQ Namesrv + +spring: + # RabbitMQ 配置项,对应 RabbitProperties 配置类 + rabbitmq: + host: 127.0.0.1 # RabbitMQ 服务的地址 + port: 5672 # RabbitMQ 服务的端口 + username: guest # RabbitMQ 服务的账号 + password: guest # RabbitMQ 服务的密码 + # Kafka 配置项,对应 KafkaProperties 配置类 + kafka: + bootstrap-servers: 127.0.0.1:9092 # 指定 Kafka Broker 地址,可以设置多个,以逗号分隔 + +--- #################### 定时任务相关配置 #################### + +xxl: + job: + enabled: true # 是否开启调度中心,默认为 true 开启 + admin: + addresses: http://127.0.0.1:9090/xxl-job-admin # 调度中心部署跟地址 + +--- #################### 服务保障相关配置 #################### + +# Lock4j 配置项 +lock4j: + acquire-timeout: 3000 # 获取分布式锁超时时间,默认为 3000 毫秒 + expire: 30000 # 分布式锁的超时时间,默认为 30 毫秒 + +--- #################### 监控相关配置 #################### + +# Actuator 监控端点的配置项 +management: + endpoints: + web: + base-path: /actuator # Actuator 提供的 API 接口的根目录。默认为 /actuator + exposure: + include: '*' # 需要开放的端点。默认值只打开 health 和 info 两个端点。通过设置 * ,可以开放所有端点。 + +# Spring Boot Admin 配置项 +spring: + boot: + admin: + # Spring Boot Admin Client 客户端的相关配置 + client: + instance: + service-host-type: IP # 注册实例时,优先使用 IP [IP, HOST_NAME, CANONICAL_HOST_NAME] + +# 日志文件配置 +logging: + level: + # 配置自己写的 MyBatis Mapper 打印日志 + com.iailab.module.system.dal.mysql: debug + com.iailab.module.system.dal.mysql.sensitiveword.SensitiveWordMapper: INFO # 配置 SensitiveWordMapper 的日志级别为 info + com.iailab.module.system.dal.mysql.sms.SmsChannelMapper: INFO # 配置 SmsChannelMapper 的日志级别为 info + +--- #################### 平台相关配置 #################### + +# 平台配置项,设置当前项目所有自定义的配置 +iailab: + env: # 多环境的配置项 + tag: ${HOSTNAME} + captcha: + enable: false # 本地环境,暂时关闭图片验证码,方便登录等接口的测试 + security: + mock-enable: true + xss: + enable: false + exclude-urls: # 如下两个 url,仅仅是为了演示,去掉配置也没关系 + - ${spring.boot.admin.context-path}/** # 不处理 Spring Boot Admin 的请求 + - ${management.endpoints.web.base-path}/** # 不处理 Actuator 的请求 + access-log: # 访问日志的配置项 + enable: false + demo: false # 关闭演示模式 + +influx-db: + org: IAILab + bucket: whs_data + token: gxhXM4H1VOBv07kYXKWyPag_zJ8_oChP4ooZ3u-BkSae9LS8R1wWzJYlmUjL3Qe9t1hDU3DtoYD5HTgjWoTGOg== + url: http://localhost:8086 + +iems: + upload-dir: D:/DLUT/upload/ diff --git a/iailab-module-data/iailab-module-data-biz/src/main/resources/application-prod.yml b/iailab-module-data/iailab-module-data-biz/src/main/resources/application-prod.yml new file mode 100644 index 0000000..5d3d877 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/resources/application-prod.yml @@ -0,0 +1,67 @@ +spring: + cloud: + nacos: + discovery: + server-addr: 192.168.55.179:8848 # 注册中心地址 nacos server + config: + server-addr: 192.168.55.179:8848 # 配置中心地址 nacos server + file-extension: yml # 配置中心的配置后缀 + datasource: + type: com.alibaba.druid.pool.DruidDataSource + druid: + driver-class-name: com.mysql.cj.jdbc.Driver + url: jdbc:mysql://localhost:3306/iailab_ntt_data?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai + username: root + password: 123456 + initial-size: 10 + max-active: 100 + min-idle: 10 + max-wait: 60000 + pool-prepared-statements: true + max-pool-prepared-statement-per-connection-size: 20 + time-between-eviction-runs-millis: 60000 + min-evictable-idle-time-millis: 300000 + #validationQuery是用来验证数据库连接的查询语句,这个查询语句必须是至少返回一条结果的SELECT语句。每种数据库都有各自的验证语句 + #validation-query: select 1 from sysibm.sysdummy1 + test-while-idle: true + test-on-borrow: false + test-on-return: false + stat-view-servlet: + enabled: true + url-pattern: /druid/* + #login-username: admin + #login-password: admin + filter: + stat: + log-slow-sql: true + slow-sql-millis: 1000 + merge-sql: false + wall: + config: + multi-statement-allow: true + redis: + database: 0 + host: 10.32.75.129 + port: 6379 + password: # 密码(默认为空) + timeout: 6000ms # 连接超时时长(毫秒) + jedis: + pool: + max-active: 1000 # 连接池最大连接数(使用负值表示没有限制) + max-wait: -1ms # 连接池最大阻塞等待时间(使用负值表示没有限制) + max-idle: 10 # 连接池中的最大空闲连接 + min-idle: 5 # 连接池中的最小空闲连接 + +oadp: + domain: http://192.168.55.180:6010 + +influx-db: + org: IAILab + bucket: ntt_data + token: FLkSbhpYgPrMJBNnOdmxuY3YcG8D_roPtdGPEhwXW9JSxJkEPe1sXUkrYgWcV-nOL9Zjm09RoTfMW44NoRYaXA== + url: http://192.168.55.180:8086 + username: root + password: ntt12345678 + +iems: + upload-dir: C:/DLUT/upload/ \ No newline at end of file diff --git a/iailab-module-data/iailab-module-data-biz/src/main/resources/application-test.yml b/iailab-module-data/iailab-module-data-biz/src/main/resources/application-test.yml new file mode 100644 index 0000000..a6bc3d9 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/resources/application-test.yml @@ -0,0 +1,65 @@ +spring: + cloud: + nacos: + discovery: + server-addr: 172.16.1.148:8848 # 注册中心地址 nacos server + config: + server-addr: 172.16.1.148:8848 # 配置中心地址 nacos server + file-extension: yml # 配置中心的配置后缀 + datasource: + type: com.alibaba.druid.pool.DruidDataSource + druid: + driver-class-name: com.mysql.cj.jdbc.Driver + url: jdbc:mysql://172.16.1.148:3306/iailab_ntt_data?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai + username: root + password: 123456 + initial-size: 10 + max-active: 100 + min-idle: 10 + max-wait: 60000 + pool-prepared-statements: true + max-pool-prepared-statement-per-connection-size: 20 + time-between-eviction-runs-millis: 60000 + min-evictable-idle-time-millis: 300000 + #validationQuery是用来验证数据库连接的查询语句,这个查询语句必须是至少返回一条结果的SELECT语句。每种数据库都有各自的验证语句 + #validation-query: select 1 from sysibm.sysdummy1 + test-while-idle: true + test-on-borrow: false + test-on-return: false + stat-view-servlet: + enabled: true + url-pattern: /druid/* + #login-username: admin + #login-password: admin + filter: + stat: + log-slow-sql: true + slow-sql-millis: 1000 + merge-sql: false + wall: + config: + multi-statement-allow: true + redis: + database: 0 + host: 172.16.1.148 + port: 6379 + password: # 密码(默认为空) + timeout: 6000ms # 连接超时时长(毫秒) + jedis: + pool: + max-active: 1000 # 连接池最大连接数(使用负值表示没有限制) + max-wait: -1ms # 连接池最大阻塞等待时间(使用负值表示没有限制) + max-idle: 10 # 连接池中的最大空闲连接 + min-idle: 5 # 连接池中的最小空闲连接 + +oadp: + domain: http://172.16.1.148:6010 + +influx-db: + org: IAILab + bucket: whs_data + token: dUoFsmlooCbyHsleY17w-_KpVf7vaFVRz0xBBuH4GZeOygMekoKpVi8kGIw49K_Qp_UDNf3RHpInoUIi4rTsow== + url: http://172.16.1.148:8086 + +iems: + upload-dir: D:/DLUT/znjt/safe/webapp/static/temp/ \ No newline at end of file diff --git a/iailab-module-data/iailab-module-data-biz/src/main/resources/application-uat.yml b/iailab-module-data/iailab-module-data-biz/src/main/resources/application-uat.yml new file mode 100644 index 0000000..0d9d757 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/resources/application-uat.yml @@ -0,0 +1,42 @@ +spring: + datasource: + type: com.alibaba.druid.pool.DruidDataSource + druid: + driver-class-name: com.ibm.db2.jcc.DB2Driver + url: jdbc:db2://192.168.122.240:50000/MgEms:currentSchema=EXPERT; + username: db2admin + password: Pwd123456 + initial-size: 10 + max-active: 100 + min-idle: 10 + max-wait: 60000 + pool-prepared-statements: true + max-pool-prepared-statement-per-connection-size: 20 + time-between-eviction-runs-millis: 60000 + min-evictable-idle-time-millis: 300000 + #validationQuery是用来验证数据库连接的查询语句,这个查询语句必须是至少返回一条结果的SELECT语句。每种数据库都有各自的验证语句 + validation-query: select 1 from sysibm.sysdummy1 + test-while-idle: true + test-on-borrow: false + test-on-return: false + stat-view-servlet: + enabled: true + url-pattern: /druid/* + #login-username: admin + #login-password: admin + filter: + stat: + log-slow-sql: true + slow-sql-millis: 1000 + merge-sql: false + wall: + config: + multi-statement-allow: true + +oadp: + domain: http://172.16.1.148:6010 + +influx-db: + org: IAILab + bucket: whs_data + token: vhNZN5bZ4c2aa9daQUsmYtaM5qExnLVZYGE0fscVV9mAQhzAnFfExVdPWKrfGVtKPVPUUmM_xfWAJZ1iqqh0qQ== diff --git a/iailab-module-data/iailab-module-data-biz/src/main/resources/application.yml b/iailab-module-data/iailab-module-data-biz/src/main/resources/application.yml new file mode 100644 index 0000000..072936a --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/resources/application.yml @@ -0,0 +1,166 @@ +spring: + application: + name: data-server + + profiles: + active: local + + main: + allow-circular-references: true # 允许循环依赖,因为项目是三层架构,无法避免这个情况。 + allow-bean-definition-overriding: true # 允许 Bean 覆盖,例如说 Feign 等会存在重复定义的服务 + + config: + import: + - optional:classpath:application-${spring.profiles.active}.yaml # 加载【本地】配置 + - optional:nacos:${spring.application.name}-${spring.profiles.active}.yaml # 加载【Nacos】的配置 + + # Servlet 配置 + servlet: + # 文件上传相关配置项 + multipart: + max-file-size: 16MB # 单个文件大小 + max-request-size: 32MB # 设置总上传的文件大小 + mvc: + pathmatch: + matching-strategy: ANT_PATH_MATCHER # 解决 SpringFox 与 SpringBoot 2.6.x 不兼容的问题,参见 SpringFoxHandlerProviderBeanPostProcessor 类 + + # Jackson 配置项 + jackson: + serialization: + write-dates-as-timestamps: true # 设置 LocalDateTime 的格式,使用时间戳 + write-date-timestamps-as-nanoseconds: false # 设置不使用 nanoseconds 的格式。例如说 1611460870.401,而是直接 1611460870401 + write-durations-as-timestamps: true # 设置 Duration 的格式,使用时间戳 + fail-on-empty-beans: false # 允许序列化无属性的 Bean + + # Cache 配置项 + cache: + type: REDIS + redis: + time-to-live: 1h # 设置过期时间为 1 小时 + +server: + port: 8982 + +logging: + file: + name: ${user.home}/logs/${spring.application.name}.log # 日志文件名,全路径 + +--- #################### 接口文档配置 #################### + +springdoc: + api-docs: + enabled: true # 1. 是否开启 Swagger 接文档的元数据 + path: /v3/api-docs + swagger-ui: + enabled: true # 2.1 是否开启 Swagger 文档的官方 UI 界面 + path: /swagger-ui.html + default-flat-param-object: true # 参见 https://doc.xiaominfo.com/docs/faq/v4/knife4j-parameterobject-flat-param 文档 + +knife4j: + enable: true + basic: + enable: false + username: admin + password: admin + setting: + enableFooter: false + +# MyBatis Plus 的配置项 +mybatis-plus: + configuration: + map-underscore-to-camel-case: true # 虽然默认为 true ,但是还是显示去指定下。 + global-config: + db-config: + id-type: AUTO # “智能”模式,基于 IdTypeEnvironmentPostProcessor + 数据源的类型,自动适配成 AUTO、INPUT 模式。 + # id-type: AUTO # 自增 ID,适合 MySQL 等直接自增的数据库 + # id-type: INPUT # 用户输入 ID,适合 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库 + # id-type: ASSIGN_ID # 分配 ID,默认使用雪花算法。注意,Oracle、PostgreSQL、Kingbase、DB2、H2 数据库时,需要去除实体类上的 @KeySequence 注解 + logic-delete-value: 1 # 逻辑已删除值(默认为 1) + logic-not-delete-value: 0 # 逻辑未删除值(默认为 0) + banner: false # 关闭控制台的 Banner 打印 + type-aliases-package: ${iailab.info.base-package}.*.entity + mapper-locations: classpath*:/mapper/**/*.xml + encryptor: + password: XDV71a+xqStEA3WH # 加解密的秘钥,可使用 https://www.imaegoo.com/2020/aes-key-generator/ 网站生成 + +mybatis-plus-join: + banner: false # 关闭控制台的 Banner 打印 + +# Spring Data Redis 配置 +spring: + data: + redis: + repositories: + enabled: false # 项目未使用到 Spring Data Redis 的 Repository,所以直接禁用,保证启动速度 + +# VO 转换(数据翻译)相关 +easy-trans: + is-enable-global: true # 启用全局翻译(拦截所有 SpringMVC ResponseBody 进行自动翻译 )。如果对于性能要求很高可关闭此配置,或通过 @IgnoreTrans 忽略某个接口 + is-enable-cloud: false # 禁用 TransType.RPC 微服务模式 + +--- #################### RPC 远程调用相关配置 #################### + +--- #################### 消息队列相关 #################### + +# rocketmq 配置项,对应 RocketMQProperties 配置类 +rocketmq: + # Producer 配置项 + producer: + group: ${spring.application.name}_PRODUCER # 生产者分组 + +spring: + # Kafka 配置项,对应 KafkaProperties 配置类 + kafka: + # Kafka Producer 配置项 + producer: + acks: 1 # 0-不应答。1-leader 应答。all-所有 leader 和 follower 应答。 + retries: 3 # 发送失败时,重试发送的次数 + value-serializer: org.springframework.kafka.support.serializer.JsonSerializer # 消息的 value 的序列化 + # Kafka Consumer 配置项 + consumer: + auto-offset-reset: earliest # 设置消费者分组最初的消费进度为 earliest 。可参考博客 https://blog.csdn.net/lishuangzhe7047/article/details/74530417 理解 + value-deserializer: org.springframework.kafka.support.serializer.JsonDeserializer + properties: + spring.json.trusted.packages: '*' + # Kafka Consumer Listener 监听器配置 + listener: + missing-topics-fatal: false # 消费监听接口监听的主题不存在时,默认会报错。所以通过设置为 false ,解决报错 + +--- #################### 定时任务相关配置 #################### + +xxl: + job: + executor: + appname: ${spring.application.name} # 执行器 AppName + logpath: ${user.home}/logs/xxl-job/${spring.application.name} # 执行器运行日志文件存储磁盘路径 + accessToken: default_token # 执行器通讯TOKEN + + +--- #################### 平台相关配置 #################### + +iailab: + info: + version: 1.0.0 + base-package: com.iailab.module.data + web: + admin-ui: + url: http://dashboard.iailab.iocoder.cn # Admin 管理后台 UI 的地址 + swagger: + title: 数据采集 + description: 数据采集 + version: ${iailab.info.version} + base-package: ${iailab.info.base-package} + tenant: # 多租户相关配置项 + enable: false +# ignore-urls: +# ignore-tables: + +# Open Automation Data Platform +oadp: + config-gui-data: + configinfo: /api/v1/configinfo + tags: + get-tags: /api/v1/tags + tags-values: /api/v1/tags/values + +debug: true diff --git a/iailab-module-data/iailab-module-data-biz/src/main/resources/banner.txt b/iailab-module-data/iailab-module-data-biz/src/main/resources/banner.txt new file mode 100644 index 0000000..10e933f --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/resources/banner.txt @@ -0,0 +1,8 @@ + + +,--. ,--.,--. ,--. ,--. ,--. ,--. ,--. +`--' ,--,--.`--'| | ,--,--.| |-. ,-----.,--,--, ,-' '-.,-' '-.,-----. ,-| | ,--,--.,-' '-. ,--,--. +,--.' ,-. |,--.| |' ,-. || .-. ''-----'| \'-. .-''-. .-''-----'' .-. |' ,-. |'-. .-'' ,-. | +| |\ '-' || || |\ '-' || `-' | | || | | | | | \ `-' |\ '-' | | | \ '-' | +`--' `--`--'`--'`--' `--`--' `---' `--''--' `--' `--' `---' `--`--' `--' `--`--' + diff --git a/iailab-module-data/iailab-module-data-biz/src/main/resources/logback-spring.xml b/iailab-module-data/iailab-module-data-biz/src/main/resources/logback-spring.xml new file mode 100644 index 0000000..db8f353 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/resources/logback-spring.xml @@ -0,0 +1,76 @@ +<configuration> + <!-- 引用 Spring Boot 的 logback 基础配置 --> + <include resource="org/springframework/boot/logging/logback/defaults.xml" /> + <!-- 变量 iailab.info.base-package,基础业务包 --> + <springProperty scope="context" name="iailab.info.base-package" source="iailab.info.base-package"/> + <!-- 格式化输出:%d 表示日期,%X{tid} SkWalking 链路追踪编号,%thread 表示线程名,%-5level:级别从左显示 5 个字符宽度,%msg:日志消息,%n是换行符 --> + <property name="PATTERN_DEFAULT" value="%d{${LOG_DATEFORMAT_PATTERN:-yyyy-MM-dd HH:mm:ss.SSS}} | %highlight(${LOG_LEVEL_PATTERN:-%5p} ${PID:- }) | %boldYellow(%thread [%tid]) %boldGreen(%-40.40logger{39}) | %m%n${LOG_EXCEPTION_CONVERSION_WORD:-%wEx}"/> + + <!-- 控制台 Appender --> + <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> + <encoder class="ch.qos.logback.core.encoder.LayoutWrappingEncoder"> + <layout class="org.apache.skywalking.apm.toolkit.log.logback.v1.x.TraceIdPatternLogbackLayout"> + <pattern>${PATTERN_DEFAULT}</pattern> + </layout> + </encoder> + </appender> + + <!-- 文件 Appender --> + <!-- 参考 Spring Boot 的 file-appender.xml 编写 --> + <appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"> + <encoder class="ch.qos.logback.core.encoder.LayoutWrappingEncoder"> + <layout class="org.apache.skywalking.apm.toolkit.log.logback.v1.x.TraceIdPatternLogbackLayout"> + <pattern>${PATTERN_DEFAULT}</pattern> + </layout> + </encoder> + <!-- 日志文件名 --> + <file>${LOG_FILE}</file> + <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy"> + <!-- 滚动后的日志文件名 --> + <fileNamePattern>${LOGBACK_ROLLINGPOLICY_FILE_NAME_PATTERN:-${LOG_FILE}.%d{yyyy-MM-dd}.%i.gz}</fileNamePattern> + <!-- 启动服务时,是否清理历史日志,一般不建议清理 --> + <cleanHistoryOnStart>${LOGBACK_ROLLINGPOLICY_CLEAN_HISTORY_ON_START:-false}</cleanHistoryOnStart> + <!-- 日志文件,到达多少容量,进行滚动 --> + <maxFileSize>${LOGBACK_ROLLINGPOLICY_MAX_FILE_SIZE:-10MB}</maxFileSize> + <!-- 日志文件的总大小,0 表示不限制 --> + <totalSizeCap>${LOGBACK_ROLLINGPOLICY_TOTAL_SIZE_CAP:-0}</totalSizeCap> + <!-- 日志文件的保留天数 --> + <maxHistory>${LOGBACK_ROLLINGPOLICY_MAX_HISTORY:-30}</maxHistory> + </rollingPolicy> + </appender> + <!-- 异步写入日志,提升性能 --> + <appender name="ASYNC" class="ch.qos.logback.classic.AsyncAppender"> + <!-- 不丢失日志。默认的,如果队列的 80% 已满,则会丢弃 TRACT、DEBUG、INFO 级别的日志 --> + <discardingThreshold>0</discardingThreshold> + <!-- 更改默认的队列的深度,该值会影响性能。默认值为 256 --> + <queueSize>256</queueSize> + <appender-ref ref="FILE"/> + </appender> + + <!-- SkyWalking GRPC 日志收集,实现日志中心。注意:SkyWalking 8.4.0 版本开始支持 --> + <appender name="GRPC" class="org.apache.skywalking.apm.toolkit.log.logback.v1.x.log.GRPCLogClientAppender"> + <encoder class="ch.qos.logback.core.encoder.LayoutWrappingEncoder"> + <layout class="org.apache.skywalking.apm.toolkit.log.logback.v1.x.TraceIdPatternLogbackLayout"> + <pattern>${PATTERN_DEFAULT}</pattern> + </layout> + </encoder> + </appender> + + <!-- 本地环境 --> + <springProfile name="local"> + <root level="INFO"> + <appender-ref ref="STDOUT"/> + <appender-ref ref="GRPC"/> <!-- 本地环境下,如果不想接入 SkyWalking 日志服务,可以注释掉本行 --> + <appender-ref ref="ASYNC"/> <!-- 本地环境下,如果不想打印日志,可以注释掉本行 --> + </root> + </springProfile> + <!-- 其它环境 --> + <springProfile name="dev,test,stage,prod,default"> + <root level="INFO"> + <appender-ref ref="STDOUT"/> + <appender-ref ref="ASYNC"/> + <appender-ref ref="GRPC"/> + </root> + </springProfile> + +</configuration> diff --git a/iailab-module-data/iailab-module-data-biz/src/main/resources/mapper/da/DaPointDao.xml b/iailab-module-data/iailab-module-data-biz/src/main/resources/mapper/da/DaPointDao.xml new file mode 100644 index 0000000..90b6481 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/resources/mapper/da/DaPointDao.xml @@ -0,0 +1,167 @@ +<?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.point.dao.DaPointDao"> + + <select id="getPageList" resultType="com.iailab.module.data.point.dto.DaPointDTO"> + select + t1.id, + t1.point_no, + t1.point_name, + t1.point_type , + t1.data_type, + t1.value_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 + 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="params.pointNo != null and params.pointNo != ''"> + and t1.point_no like concat('%', #{params.pointNo}, '%') + </if> + <if test="params.pointName != null and params.pointName != ''"> + and t1.point_name like concat('%', #{params.pointName}, '%') + </if> + <if test="params.pointType != null and params.pointType != ''"> + and t1.point_type = #{params.pointType} + </if> + <if test="params.dataType != null and params.dataType != ''"> + and t1.data_type = #{params.dataType} + </if> + <if test="params.sourceName != null and params.sourceName != ''"> + and t3.source_name like concat('%', #{params.sourceName}, '%') + </if> + <if test="params.tagNo != null and params.tagNo != ''"> + and t2.tag_no like concat('%', #{params.tagNo}, '%') + </if> + <if test="params.isEnable != null "> + and t1.is_enable = #{params.isEnable} + </if> + </where> + order by t1.point_no desc + </select> + + <select id="getConstantPoint" resultType="com.iailab.module.data.point.dto.DaPointDTO"> + SELECT + t1.point_no, + t1.point_name, + t1.default_value, + t1.point_type, + t1.store_type, + t1.data_type + FROM t_da_point t1 + <where> + t1.point_type = #{pointType} + <if test="isEnable != null"> + AND t1.is_enable = #{isEnable} + </if> + <if test="minfreqid != null and minfreqid != ''"> + AND t1.minfreqid = #{minfreqid} + </if> + <if test="pointNos != null"> + AND t1.point_no in + <foreach collection="pointNos" item="item" index="item" open="(" close=")" separator=","> + #{item} + </foreach> + </if> + </where> + </select> + + <select id="getMeasurePoint" resultType="com.iailab.module.data.point.dto.DaPointDTO"> + SELECT + t1.point_no, + t1.point_name, + t1.point_type, + t1.data_type, + t1.store_type, + t1.default_value, + t1.unittransfactor, + t1.max_value, + t1.min_value, + t2.source_type, + t2.source_id, + t3.source_name, + t2.tag_no + 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, instance_name source_name + from t_channel_kio_device + union + select id source_id, code source_name + from t_http_api + ) t3 on t3.source_id = t2.source_id + <where> + t1.point_type = #{pointType} + <if test="isEnable != null"> + AND t1.is_enable = #{isEnable} + </if> + <if test="minfreqid != null and minfreqid != ''"> + AND t1.minfreqid = #{minfreqid} + </if> + <if test="pointNo != null and pointNo != ''"> + AND t1.point_no = #{pointNo} + </if> + <if test="pointNos != null"> + AND t1.point_no in + <foreach collection="pointNos" item="item" index="item" open="(" close=")" separator=","> + #{item} + </foreach> + </if> + </where> + </select> + <select id="getMathPoint" resultType="com.iailab.module.data.point.dto.DaPointDTO"> + SELECT + t1.point_no, + t1.point_name, + t1.default_value, + t1.point_type, + t1.data_type, + t1.store_type, + t2.expression + FROM t_da_point t1 + LEFT JOIN t_da_math_point t2 ON t2.point_id = t1.id + <where> + t1.point_type = #{pointType} + <if test="isEnable != null"> + AND t1.is_enable = #{isEnable} + </if> + <if test="minfreqid != null and minfreqid != ''"> + AND t1.minfreqid = #{minfreqid} + </if> + </where> + </select> + +</mapper> \ No newline at end of file diff --git a/iailab-module-data/iailab-module-data-biz/src/main/resources/mapper/gateway/ApiAuthorizedDao.xml b/iailab-module-data/iailab-module-data-biz/src/main/resources/mapper/gateway/ApiAuthorizedDao.xml new file mode 100644 index 0000000..956d3ac --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/resources/mapper/gateway/ApiAuthorizedDao.xml @@ -0,0 +1,60 @@ +<?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.gateway.dao.ApiAuthorizedDao"> + <resultMap id="ApiAuthorizedEntity" type="com.iailab.module.data.gateway.entity.ApiAuthorizedEntity"> + <result property="id" column="id"/> + <result property="appId" column="app_id"/> + <result property="appKey" column="app_key"/> + <result property="serverName" column="server_name"/> + <result property="apiId" column="api_id"/> + <result property="apiName" column="api_name"/> + <result property="limitMin" column="limit_min"/> + <result property="limitHour" column="limit_hour"/> + <result property="limitDay" column="limit_day"/> + <result property="createTime" column="create_time"/> + </resultMap> + + <resultMap id="SysGatewayApi" type="com.iailab.module.data.gateway.vo.SysGatewayApi"> + <result property="appKey" column="app_key"/> + <result property="apiStatus" column="api_status"/> + <result property="apiAddress" column="api_address"/> + <result property="serverName" column="server_name"/> + </resultMap> + + <select id="queryList" parameterType="map" resultMap="ApiAuthorizedEntity"> + SELECT t1.*, + t2.api_name, + t2.api_address, + t3.server_name + FROM t_api_authorized t1 + LEFT JOIN t_api_info t2 ON t2.id = t1.api_id + LEFT JOIN t_api_server t3 ON t3.id = t2.api_server_id + <where> + <if test="params.appId != null and params.appId != ''"> + AND t1.app_id = #{params.appId} + </if> + </where> + ORDER BY t1.create_time DESC + </select> + + <select id="queryListGatewayApi" parameterType="map" resultMap="SysGatewayApi"> + SELECT + t1.app_key, + t2.api_address, + t3.server_name, + t2.status as api_status + FROM + t_api_authorized t1 + LEFT JOIN t_api_info t2 ON t2.id = t1.api_id + LEFT JOIN t_api_server t3 ON t3.id = t2.api_server_id + <where> + <if test="apiStatus != null and apiStatus != ''"> + AND t2.status = #{apiStatus} + </if> + <if test="serverStatus != null and serverStatus != ''"> + AND t3.status = #{serverStatus} + </if> + </where> + </select> + +</mapper> \ No newline at end of file diff --git a/iailab-module-data/iailab-module-data-biz/src/main/resources/mapper/gateway/ApiInfoDao.xml b/iailab-module-data/iailab-module-data-biz/src/main/resources/mapper/gateway/ApiInfoDao.xml new file mode 100644 index 0000000..2e46d01 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/resources/mapper/gateway/ApiInfoDao.xml @@ -0,0 +1,37 @@ +<?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.gateway.dao.ApiInfoDao"> + <resultMap id="ApiInfoEntity" type="com.iailab.module.data.gateway.entity.ApiInfoEntity"> + <result property="id" column="id"/> + <result property="apiName" column="api_name"/> + <result property="apiGroupId" column="api_group_id"/> + <result property="groupName" column="group_name"/> + <result property="apiServerId" column="api_server_id"/> + <result property="serverName" column="server_name"/> + <result property="apiDesc" column="api_desc"/> + <result property="apiAddress" column="api_address"/> + <result property="status" column="status"/> + <result property="createTime" column="create_time"/> + </resultMap> + <select id="queryList" parameterType="map" resultMap="ApiInfoEntity"> + SELECT t1.*, + t2.group_name, + t3.server_name + FROM t_api_info t1 + LEFT JOIN t_api_group t2 ON t2.id = t1.api_group_id + LEFT JOIN t_api_server t3 ON t3.id = t1.api_server_id + <where> + <if test="params.apiName != null and params.apiName != ''"> + AND t1.api_name LIKE CONCAT('%', #{params.apiName}, '%') + </if> + <if test="params.groupName != null and params.groupName != ''"> + AND t2.group_name LIKE CONCAT('%', #{params.groupName}, '%') + </if> + <if test="params.serverName != null and params.serverName != ''"> + AND t3.server_name LIKE CONCAT('%', #{params.serverName}, '%') + </if> + </where> + ORDER BY t1.create_time DESC + </select> + +</mapper> \ No newline at end of file diff --git a/iailab-module-data/iailab-module-data-biz/src/main/resources/mapper/http/HttpTagDao.xml b/iailab-module-data/iailab-module-data-biz/src/main/resources/mapper/http/HttpTagDao.xml new file mode 100644 index 0000000..fa227d7 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/resources/mapper/http/HttpTagDao.xml @@ -0,0 +1,15 @@ +<?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.http.dao.HttpTagDao"> + + <select id="getList" resultType="com.iailab.module.data.http.dto.HttpTagDTO"> + select * from t_http_tag + <where> + <if test="deviceId != null and deviceId != ''"> + tag_type = #{deviceId} + </if> + </where> + </select> + +</mapper> \ No newline at end of file diff --git a/iailab-module-data/iailab-module-data-biz/src/main/resources/mapper/ind/IndItemDao.xml b/iailab-module-data/iailab-module-data-biz/src/main/resources/mapper/ind/IndItemDao.xml new file mode 100644 index 0000000..b242970 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/resources/mapper/ind/IndItemDao.xml @@ -0,0 +1,74 @@ +<?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.ind.dao.IndItemDao"> + + + <select id="getItemAtom" resultType="com.iailab.module.data.ind.dto.IndItemDTO"> + SELECT + t1.item_no, + t1.item_name, + t1.item_type, + t1.coefficient, + t1.precision, + t1.time_range, + t1.time_granularity, + t2.data_source, + t2.query_sql + FROM t_ind_item t1 + LEFT JOIN t_ind_item_atom t2 ON t2.item_id = t1.id + <where> + t1.item_type = #{itemType} + <if test="isEnable != null"> + AND t1.is_enable = #{isEnable} + </if> + <if test="timeGranularity != null and timeGranularity != ''"> + AND t1.time_granularity = #{timeGranularity} + </if> + <if test="itemNo != null and itemNo != ''"> + AND t1.item_no = #{itemNo} + </if> + <if test="itemNos != null"> + AND t1.item_no in + <foreach collection="itemNos" item="item" index="item" open="(" close=")" separator=","> + #{item} + </foreach> + </if> + </where> + </select> + <select id="getItemCal" resultType="com.iailab.module.data.ind.dto.IndItemDTO"> + SELECT + t1.item_no, + t1.item_name, + t1.item_type, + t1.coefficient, + t1.precision, + t1.time_range, + t1.time_granularity, + t2.expression + FROM t_ind_item t1 + LEFT JOIN t_ind_item_cal t2 ON t2.item_id = t1.id + <where> + t1.item_type = #{itemType} + <if test="isEnable != null"> + AND t1.is_enable = #{isEnable} + </if> + <if test="timeGranularity != null and timeGranularity != ''"> + AND t1.time_granularity = #{timeGranularity} + </if> + <if test="itemNo != null and itemNo != ''"> + AND t1.item_no = #{itemNo} + </if> + <if test="itemNos != null"> + AND t1.item_no in + <foreach collection="itemNos" item="item" index="item" open="(" close=")" separator=","> + #{item} + </foreach> + </if> + </where> + + </select> + + + +</mapper> \ No newline at end of file diff --git a/iailab-module-data/iailab-module-data-biz/src/main/resources/mapper/ind/IndItemValueDao.xml b/iailab-module-data/iailab-module-data-biz/src/main/resources/mapper/ind/IndItemValueDao.xml new file mode 100644 index 0000000..2a07b6f --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/resources/mapper/ind/IndItemValueDao.xml @@ -0,0 +1,21 @@ +<?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.ind.dao.IndItemValueDao"> + + + <select id="getSourceValue" parameterType="com.iailab.module.data.ind.dto.IndItemDTO" resultType="com.iailab.module.data.ind.dto.IndItemValueDTO"> + select + ${sqlSelect} + from ( + ${querySql} + ) ind_t + <where> + <if test="sqlWhere != null and sqlWhere != ''"> + and ${sqlWhere} + </if> + </where> + order by ind_t.data_time + </select> + +</mapper> diff --git a/iailab-module-data/iailab-module-data-biz/src/main/resources/mapper/job/ScheduleJobDao.xml b/iailab-module-data/iailab-module-data-biz/src/main/resources/mapper/job/ScheduleJobDao.xml new file mode 100644 index 0000000..11858af --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/resources/mapper/job/ScheduleJobDao.xml @@ -0,0 +1,14 @@ +<?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.job.dao.ScheduleJobDao"> + + <!-- 批量更新状态 --> + <update id="updateBatch"> + update schedule_job set status = #{status} where id in + <foreach item="id" collection="ids" open="(" separator="," close=")"> + #{id} + </foreach> + </update> + +</mapper> \ No newline at end of file diff --git a/iailab-module-data/iailab-module-data-biz/src/main/resources/mapper/job/ScheduleJobLogDao.xml b/iailab-module-data/iailab-module-data-biz/src/main/resources/mapper/job/ScheduleJobLogDao.xml new file mode 100644 index 0000000..365798b --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/resources/mapper/job/ScheduleJobLogDao.xml @@ -0,0 +1,7 @@ +<?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.job.dao.ScheduleJobLogDao"> + + +</mapper> \ No newline at end of file diff --git "a/iailab-module-data/iailab-module-data-biz/src/main/resources/\345\257\274\345\205\245\346\250\241\346\235\277/ModBus.xlsx" "b/iailab-module-data/iailab-module-data-biz/src/main/resources/\345\257\274\345\205\245\346\250\241\346\235\277/ModBus.xlsx" new file mode 100644 index 0000000..0d669cd --- /dev/null +++ "b/iailab-module-data/iailab-module-data-biz/src/main/resources/\345\257\274\345\205\245\346\250\241\346\235\277/ModBus.xlsx" Binary files differ diff --git "a/iailab-module-data/iailab-module-data-biz/src/main/resources/\345\257\274\345\205\245\346\250\241\346\235\277/OpcUa.xlsx" "b/iailab-module-data/iailab-module-data-biz/src/main/resources/\345\257\274\345\205\245\346\250\241\346\235\277/OpcUa.xlsx" new file mode 100644 index 0000000..621b3fe --- /dev/null +++ "b/iailab-module-data/iailab-module-data-biz/src/main/resources/\345\257\274\345\205\245\346\250\241\346\235\277/OpcUa.xlsx" Binary files differ diff --git a/iailab-module-data/iailab-module-data-biz/src/test/java/com/iailab/InfluxDBTest.java b/iailab-module-data/iailab-module-data-biz/src/test/java/com/iailab/InfluxDBTest.java new file mode 100644 index 0000000..8dc472b --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/test/java/com/iailab/InfluxDBTest.java @@ -0,0 +1,68 @@ +package com.iailab; + +import com.iailab.module.data.influxdb.pojo.InfluxPointValuePOJO; +import com.iailab.module.data.influxdb.pojo.InfluxPointValueSimPOJO; +import com.iailab.module.data.influxdb.service.InfluxDBService; +import org.junit.Test; +import org.junit.runner.RunWith; +import javax.annotation.Resource; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit4.SpringRunner; + +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Date; +import java.util.List; + +/** + * @author PanZhibao + * @Description + * @createTime 2023年12月10日 12:19:00 + */ +@SpringBootTest +@RunWith(SpringRunner.class) +public class InfluxDBTest { + + @Resource + private InfluxDBService influxDBService; + + + @Test + public void testWrite() { + try { + List<InfluxPointValuePOJO> pointValues = new ArrayList<>(); + InfluxPointValuePOJO pojo = new InfluxPointValueSimPOJO(); + pojo.setPoint("88880102030001"); + pojo.setType("float"); + pojo.setTimestamp(new Date().toInstant()); + ((InfluxPointValueSimPOJO) pojo).setValue(123d); + pointValues.add(pojo); + + InfluxPointValuePOJO pojo1 = new InfluxPointValueSimPOJO(); + pojo1.setPoint("88880102030001"); + pojo1.setType("float"); + pojo1.setTimestamp(new Date().toInstant()); + ((InfluxPointValueSimPOJO) pojo1).setValue(456d); + pointValues.add(pojo1); + + influxDBService.asyncWritePointValues(pointValues); + } catch (Exception ex) { + ex.printStackTrace(); + } + + } + + @Test + public void testQueryPointMaxValue() { + InfluxPointValuePOJO point = new InfluxPointValuePOJO(); + point.setType("float"); + point.setPoint("88880102030001"); + Calendar calendar = Calendar.getInstance(); + calendar.add(Calendar.HOUR_OF_DAY, -1); + + Object value = influxDBService.queryPointMaxValue(point, calendar.getTime()); + + System.out.println("value=" + value); + + } +} diff --git a/iailab-module-data/iailab-module-data-biz/src/test/java/com/iailab/OadpTagCollectorTest.java b/iailab-module-data/iailab-module-data-biz/src/test/java/com/iailab/OadpTagCollectorTest.java new file mode 100644 index 0000000..d69fd61 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/test/java/com/iailab/OadpTagCollectorTest.java @@ -0,0 +1,43 @@ +package com.iailab; + +import com.iailab.module.collection.tag.impl.OadpTagCollector; +import org.junit.Test; +import org.junit.runner.RunWith; +import javax.annotation.Resource; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit4.SpringRunner; + +import java.util.ArrayList; +import java.util.Calendar; +import java.util.List; + +/** + * @author PanZhibao + * @Description + * @createTime 2023年04月25日 16:17:00 + */ +@SpringBootTest +@RunWith(SpringRunner.class) +public class OadpTagCollectorTest { + + @Resource + private OadpTagCollector tagCollector; + + @Test + public void test() { + Calendar calendar = Calendar.getInstance(); + calendar.set(Calendar.MILLISECOND, 0); + List<String> tags = new ArrayList<>(); + tags.add("source=producer-modbus;id=device0.change_random_int32"); + tags.add("source=producer-modbus;id=device0.change_random_float"); + tagCollector.collect(calendar.getTime(), tags); + } + + + @Test + public void testSp() { + String regex = "[+\\-\\*/()\\&&\\||]"; + String expression = "324123423&&34576||9999||66666+536345"; + String[] arr = expression.split(regex); + } +} diff --git a/iailab-module-infra/iailab-module-infra-api/src/main/java/com/iailab/module/infra/api/config/ConfigApi.java b/iailab-module-infra/iailab-module-infra-api/src/main/java/com/iailab/module/infra/api/config/ConfigApi.java new file mode 100644 index 0000000..2d41a26 --- /dev/null +++ b/iailab-module-infra/iailab-module-infra-api/src/main/java/com/iailab/module/infra/api/config/ConfigApi.java @@ -0,0 +1,17 @@ +package com.iailab.module.infra.api.config; + +import com.iailab.module.infra.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.*; + +@FeignClient(name = ApiConstants.NAME) +@Tag(name = "配置文件") +public interface ConfigApi { + + @Operation(summary = "Feign接口-查询配置参数") + @GetMapping("/api/feign/infra-config/{configCode}") + String queryConfigByCode(@PathVariable("configCode") String configCode); + +} diff --git a/iailab-module-infra/iailab-module-infra-biz/src/main/java/com/iailab/module/infra/api/config/ConfigApiImpl.java b/iailab-module-infra/iailab-module-infra-biz/src/main/java/com/iailab/module/infra/api/config/ConfigApiImpl.java new file mode 100644 index 0000000..521559f --- /dev/null +++ b/iailab-module-infra/iailab-module-infra-biz/src/main/java/com/iailab/module/infra/api/config/ConfigApiImpl.java @@ -0,0 +1,71 @@ +package com.iailab.module.infra.api.config; + +import com.iailab.framework.common.pojo.CommonResult; +import com.iailab.module.infra.api.file.FileApi; +import com.iailab.module.infra.api.file.dto.FileCreateReqDTO; +import com.iailab.module.infra.service.config.ConfigService; +import com.iailab.module.infra.service.file.FileService; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.RestController; + +import javax.annotation.Resource; + +import java.text.SimpleDateFormat; +import java.util.Calendar; +import java.util.Date; + +import static com.iailab.framework.common.pojo.CommonResult.success; + +@RestController // 提供 RESTful API 接口,给 Feign 调用 +@Validated +public class ConfigApiImpl implements ConfigApi { + + @Resource + private ConfigService configService; + +// /** +// * 查月初或者年初(根据code) +// * +// * @return +// */ +// @Override +// public String queryConfigByCode(String configCode, String type){ +// String result = ""; +// String value = configService.getValue(configCode); +// Calendar calendar = Calendar.getInstance(); +// calendar.setTime(new Date()); +// SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); +// if("month".equals(type)){ +// int nowDay = calendar.get(Calendar.DAY_OF_MONTH); +// if(nowDay < Integer.parseInt(value)){ +// calendar.add(Calendar.MONTH, -1); +// } +// calendar.set(Calendar.DAY_OF_MONTH, Integer.parseInt(value)); +// } else { +// int month = Integer.parseInt(value.substring(0,value.indexOf("-"))); +// int day = Integer.parseInt(value.substring(value.indexOf("-") + 1)); +// int nowMonth = calendar.get(Calendar.MONTH) + 1; +// int nowDay = calendar.get(Calendar.DAY_OF_MONTH); +// +// if(nowMonth == month) { +// if(nowDay < day){ +// calendar.add(Calendar.YEAR, -1); +// } +// } else if(nowMonth < month) { +// calendar.add(Calendar.YEAR, -1); +// } +// calendar.set(Calendar.MONTH, month - 1); +// calendar.set(Calendar.DAY_OF_MONTH, day); +// } +// +// result = sdf.format(calendar.getTime()); +// +// return result; +// } + + @Override + public String queryConfigByCode(String configCode) { + return configService.getValue(configCode); + } + +} diff --git a/iailab-module-model/iailab-module-model-api/pom.xml b/iailab-module-model/iailab-module-model-api/pom.xml new file mode 100644 index 0000000..7eb91aa --- /dev/null +++ b/iailab-module-model/iailab-module-model-api/pom.xml @@ -0,0 +1,48 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>com.iailab</groupId> + <artifactId>iailab-module-model</artifactId> + <version>${revision}</version> + </parent> + <version>${revision}</version> + + <artifactId>iailab-module-model-api</artifactId> + + <properties> + <maven.compiler.source>8</maven.compiler.source> + <maven.compiler.target>8</maven.compiler.target> + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> + </properties> + + <dependencies> + <dependency> + <groupId>com.iailab</groupId> + <artifactId>iailab-common</artifactId> + </dependency> + + <!-- Web 相关 --> + <dependency> + <groupId>org.springdoc</groupId> + <artifactId>springdoc-openapi-ui</artifactId> + </dependency> + + <!-- 参数校验 --> + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-validation</artifactId> + <optional>true</optional> + </dependency> + + <!-- RPC 远程调用相关 --> + <dependency> + <groupId>org.springframework.cloud</groupId> + <artifactId>spring-cloud-starter-openfeign</artifactId> + <optional>true</optional> + </dependency> + + </dependencies> +</project> \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-api/src/main/java/com/iailab/api/IFeignModelApi.java b/iailab-module-model/iailab-module-model-api/src/main/java/com/iailab/api/IFeignModelApi.java new file mode 100644 index 0000000..1ebb086 --- /dev/null +++ b/iailab-module-model/iailab-module-model-api/src/main/java/com/iailab/api/IFeignModelApi.java @@ -0,0 +1,44 @@ +package com.iailab.api; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestParam; + +import java.util.List; +import java.util.Map; + +/** + * @author lirm + * @Description + * @createTime 2024年05月22日 + */ +@FeignClient(value = "iailab-ntt-model", path = "/") +public interface IFeignModelApi { + @Parameter(name = "map", description = "插入运行状态数据", required = true) + @Operation(summary = "Feign接口-插入运行状态数据") + @PostMapping("/api/feign/run-state") + void insertRunState(@RequestParam Map<String, Integer> tMap); + + @Parameter(name = "map", description = "插入健康状态数据", required = true) + @Operation(summary = "Feign接口-插入健康状态数据") + @PostMapping("/api/feign/health-state") + void insertHealthState(@RequestParam Map<String, Object> tMap); + + @Parameter(name = "map", description = "插入设备列表数据", required = true) + @Operation(summary = "Feign接口-插入设备列表数据") + @PostMapping("/api/feign/device-list") + void insertDeviceList(@RequestParam Map<String, String> tMap); + + @Parameter(name = "map", description = "调用模型", required = true) + @Operation(summary = "Feign接口-调用模型") + @PostMapping("/api/feign/run-model") + Map<String, Object> runModel(@RequestParam Map<String, Object> params, @RequestBody List<double[][]> sampleDataList); + + @Parameter(name = "list", description = "查询设备ID", required = true) + @Operation(summary = "Feign接口-查询设备ID") + @PostMapping("/api/feign/deviceIdList") + List<String> getDeviceIdList(); +} diff --git a/iailab-module-model/iailab-module-model-api/src/main/java/com/iailab/api/IFeignProddispApi.java b/iailab-module-model/iailab-module-model-api/src/main/java/com/iailab/api/IFeignProddispApi.java new file mode 100644 index 0000000..cbe943f --- /dev/null +++ b/iailab-module-model/iailab-module-model-api/src/main/java/com/iailab/api/IFeignProddispApi.java @@ -0,0 +1,94 @@ +package com.iailab.api; + +import com.iailab.dto.*; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestParam; + +import java.math.BigDecimal; +import java.util.List; +import java.util.Map; + +/** + * 生产调度 + * + * @author PanZhibao + * @Description + * @createTime 2023年06月28日 08:54:00 + */ +@FeignClient(value = "iailab-ntt-coal-proddisp", path = "/") +public interface IFeignProddispApi { + + @Parameter(name = "FeignConsumeTargetDTO", description = "消耗指标", required = true) + @Operation(summary = "Feign接口-创建消耗指标") + @PostMapping("/api/feign/create/consume-target") + void createConsumeTarget(@RequestBody FeignConsumeTargetDTO dto); + + @Parameter(name = "FeignRunTimeDTO", description = "运行时长", required = true) + @Operation(summary = "Feign接口-创建运行时长") + @PostMapping("/api/feign/create/run-time") + void createRunTime(@RequestBody FeignRunTimeDTO dto); + + @Parameter(name = "FeignHourVolumeDTO", description = "小时量", required = true) + @Operation(summary = "Feign接口-创建小时量") + @PostMapping("/api/feign/create/hour-volume") + void createHourVolume(@RequestBody FeignHourVolumeDTO dto); + + @Parameter(name = "FeignWarehousePositionDTO", description = "仓位", required = true) + @Operation(summary = "Feign接口-创建仓位") + @PostMapping("/api/feign/create/warehouse-position") + void createWarehousePosition(@RequestBody FeignWarehousePositionDTO dto); + + @Parameter(name = "FeignWarehouseStockDTO", description = "库存", required = true) + @Operation(summary = "Feign接口-创建库存") + @PostMapping("/api/feign/create/warehouse-stock") + void createWarehouseStock(@RequestBody FeignWarehouseStockDTO dto); + + @Parameter(name = "FeignWashTransferInDTO", description = "调入量", required = true) + @Operation(summary = "Feign接口-创建调入量") + @PostMapping("/api/feign/create/wash-transfer-in") + void createWashTransferIn(@RequestBody FeignWashTransferInDTO dto); + + @Parameter(name = "FeignPowerConsumeDTO", description = "电耗", required = true) + @Operation(summary = "Feign接口-创建调入量") + @PostMapping("/api/feign/create/power-consume") + void createPowerConsume(@RequestBody FeignPowerConsumeDTO dto); + + @Parameter(name = "FeignRunTimeDTO", description = "入洗量", required = true) + @Operation(summary = "Feign接口-创建入洗量") + @PostMapping("/api/feign/create/wash-to-wash") + void createWashToWash(@RequestBody FeignWashToWashDTO dto); + + @Parameter(name = "FeignRunTimeDTO", description = "生产量", required = true) + @Operation(summary = "Feign接口-创建生产量") + @PostMapping("/api/feign/create/wash-prod-volume") + void createWashProdVolume(@RequestBody FeignWashProdVolumeDTO dto); + + @Parameter(name = "map", description = "查询库存", required = true) + @Operation(summary = "Feign接口-查询库存") + @PostMapping("/api/feign/select/warehouse-group") + List<FeignWarehousePositionDTO> selectWarehouseGroupByCp(@RequestParam("params") Map<String, Object> params); + + @Parameter(name = "map", description = "查询当班总电耗", required = true) + @Operation(summary = "Feign接口-查询当班总电耗") + @PostMapping("/api/feign/select/powerConsume") + BigDecimal sumData(@RequestParam("params") Map<String, Object> params); + + @Parameter(name = "String", description = "查询煤仓详情列表", required = true) + @Operation(summary = "Feign接口-查询煤仓详情列表") + @PostMapping("/api/feign/select/warehouse-item-list") + List<FeignWarehouseItemDTO> selectWarehouseItemListByMclx(@RequestParam("mclx") String mclx); + + @Parameter(name = "String", description = "查询煤仓详情", required = true) + @Operation(summary = "Feign接口-查询煤仓详情") + @PostMapping("/api/feign/select/warehouse-item") + FeignWarehouseItemDTO selectWarehouseItemByMc(@RequestParam("mc") String mc); + + @Parameter(name = "String", description = "查询煤仓煤种", required = true) + @Operation(summary = "Feign接口-查询煤仓详情") + @PostMapping("/api/feign/select/mc-mz") + List<FeignMcMzDTO> selectMcMzByMc(@RequestParam("mc") String mc); +} diff --git a/iailab-module-model/iailab-module-model-api/src/main/java/com/iailab/dto/FeignConsumeTargetDTO.java b/iailab-module-model/iailab-module-model-api/src/main/java/com/iailab/dto/FeignConsumeTargetDTO.java new file mode 100644 index 0000000..7641ee6 --- /dev/null +++ b/iailab-module-model/iailab-module-model-api/src/main/java/com/iailab/dto/FeignConsumeTargetDTO.java @@ -0,0 +1,58 @@ +package com.iailab.dto; + +import io.swagger.v3.oas.annotations.media.Schema; + +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.io.Serializable; +import java.math.BigDecimal; +import java.util.Date; + +/** + * @author PanZhibao + * @Description + * @createTime 2023年07月01日 10:00:00 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@Schema(name = "消耗指标") +public class FeignConsumeTargetDTO implements Serializable { + private static final long serialVersionUID = 1L; + + @Schema(name = "日期") + private String rq; + + @Schema(name = "班次") + private String bc; + + @Schema(name = "消耗指标") + private String xhzb; + + @Schema(name = "单位") + private String dw; + + @Schema(name = "内报当日量") + private BigDecimal nbdrl; + + @Schema(name = "内报调整量") + private BigDecimal nbtzl; + + @Schema(name = "外报当日量") + private BigDecimal wbdrl; + + @Schema(name = "外报调整量") + private BigDecimal wbtzl; + + @Schema(name = "创建人") + private String cjr; + + @Schema(name = "创建时间") + private Date cjsj; + + @Schema(name = "修改人") + private String xgr; + + @Schema(name = "修改时间") + private Date xgsj; +} diff --git a/iailab-module-model/iailab-module-model-api/src/main/java/com/iailab/dto/FeignHourVolumeDTO.java b/iailab-module-model/iailab-module-model-api/src/main/java/com/iailab/dto/FeignHourVolumeDTO.java new file mode 100644 index 0000000..4d57f5f --- /dev/null +++ b/iailab-module-model/iailab-module-model-api/src/main/java/com/iailab/dto/FeignHourVolumeDTO.java @@ -0,0 +1,64 @@ +package com.iailab.dto; + +import io.swagger.v3.oas.annotations.media.Schema; + +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.io.Serializable; +import java.math.BigDecimal; +import java.util.Date; + +/** + * @author PanZhibao + * @Description + * @createTime 2023年06月28日 10:02:00 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@Schema(name = "小时量") +public class FeignHourVolumeDTO implements Serializable { + private static final long serialVersionUID = 1L; + + @Schema(name = "日期") + private String rq; + + @Schema(name = "班次") + private String bc; + + @Schema(name = "时间") + private Date sj; + + @Schema(name = "入洗量") + private BigDecimal rxl; + + @Schema(name = "精煤量") + private BigDecimal jml; + + @Schema(name = "混煤量") + private BigDecimal hml; + + @Schema(name = "矸石量") + private BigDecimal gsl; + + @Schema(name = "浮精板数") + private BigDecimal fjbs; + + @Schema(name = "煤泥板数") + private BigDecimal mnbs; + + @Schema(name = "备注") + private String content; + + @Schema(name = "创建人") + private String cjr; + + @Schema(name = "创建时间") + private Date cjsj; + + @Schema(name = "修改人") + private String xgr; + + @Schema(name = "修改时间") + private Date xgsj; +} diff --git a/iailab-module-model/iailab-module-model-api/src/main/java/com/iailab/dto/FeignMcMzDTO.java b/iailab-module-model/iailab-module-model-api/src/main/java/com/iailab/dto/FeignMcMzDTO.java new file mode 100644 index 0000000..24dddd9 --- /dev/null +++ b/iailab-module-model/iailab-module-model-api/src/main/java/com/iailab/dto/FeignMcMzDTO.java @@ -0,0 +1,39 @@ +package com.iailab.dto; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import lombok.EqualsAndHashCode; + +@Data +@EqualsAndHashCode(callSuper = false) +@Schema(name = "煤仓详情") +public class FeignMcMzDTO { + /** + * id + */ + private String id; + /** + * 煤仓 + */ + private String mc; + /** + * 煤种 + */ + private String mz; + /** + * 比例分母 + */ + private Integer den; + /** + * 比例 + */ + private Integer proportion; + /** + * 创建人 + */ + private String createBy; + /** + * 更新人 + */ + private String updateBy; +} diff --git a/iailab-module-model/iailab-module-model-api/src/main/java/com/iailab/dto/FeignPowerConsumeDTO.java b/iailab-module-model/iailab-module-model-api/src/main/java/com/iailab/dto/FeignPowerConsumeDTO.java new file mode 100644 index 0000000..cd8319c --- /dev/null +++ b/iailab-module-model/iailab-module-model-api/src/main/java/com/iailab/dto/FeignPowerConsumeDTO.java @@ -0,0 +1,72 @@ +package com.iailab.dto; + +import com.fasterxml.jackson.annotation.JsonFormat; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.io.Serializable; +import java.math.BigDecimal; +import java.util.Date; + +/** + * @author DongYukun + * @Description + * @createTime 2024年02月02日 17:00:00 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@Schema(name = "电耗") +public class FeignPowerConsumeDTO implements Serializable { + private static final long serialVersionUID = 1L; + + @Schema(name = "日期") + private String rq; + + @Schema(name = "班次") + private String bc; + + @Schema(name = "电耗系统") + private String xt; + + /** + * 内报当日量 + */ + @JsonFormat(shape =JsonFormat.Shape.STRING) + private BigDecimal nbdrl; + + /** + * 内报调整量 + */ + @JsonFormat(shape =JsonFormat.Shape.STRING) + private BigDecimal nbtzl; + + /** + * 外报当日量 + */ + @JsonFormat(shape =JsonFormat.Shape.STRING) + private BigDecimal wbdrl; + + /** + * 外报调整量 + */ + @JsonFormat(shape =JsonFormat.Shape.STRING) + private BigDecimal wbtzl; + + /** + * 备注 + */ + private String bz; + + @Schema(name = "创建人") + private String cjr; + + @Schema(name = "创建时间") + private Date cjsj; + + @Schema(name = "修改人") + private String xgr; + + @Schema(name = "修改时间") + private Date xgsj; +} diff --git a/iailab-module-model/iailab-module-model-api/src/main/java/com/iailab/dto/FeignRunTimeDTO.java b/iailab-module-model/iailab-module-model-api/src/main/java/com/iailab/dto/FeignRunTimeDTO.java new file mode 100644 index 0000000..ce313af --- /dev/null +++ b/iailab-module-model/iailab-module-model-api/src/main/java/com/iailab/dto/FeignRunTimeDTO.java @@ -0,0 +1,57 @@ +package com.iailab.dto; + +import io.swagger.v3.oas.annotations.media.Schema; + +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.io.Serializable; +import java.util.Date; + +/** + * @author PanZhibao + * @Description + * @createTime 2023年06月28日 09:19:00 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@Schema(name = "运行时长") +public class FeignRunTimeDTO implements Serializable { + private static final long serialVersionUID = 1L; + + @Schema(name = "日期") + private String rq; + + @Schema(name = "班次") + private String bc; + + @Schema(name = "时长项目") + private String scxm; + + @Schema(name = "时长类型") + private String runTimeType; + + @Schema(name = "小时数") + private Long xss; + + @Schema(name = "分钟数") + private Long fzs; + + @Schema(name = "总时长(分钟)") + private Long zsc; + + @Schema(name = "备注") + private String content; + + @Schema(name = "创建人") + private String cjr; + + @Schema(name = "创建时间") + private Date cjsj; + + @Schema(name = "修改人") + private String xgr; + + @Schema(name = "修改时间") + private Date xgsj; +} diff --git a/iailab-module-model/iailab-module-model-api/src/main/java/com/iailab/dto/FeignWarehouseItemDTO.java b/iailab-module-model/iailab-module-model-api/src/main/java/com/iailab/dto/FeignWarehouseItemDTO.java new file mode 100644 index 0000000..3ddc138 --- /dev/null +++ b/iailab-module-model/iailab-module-model-api/src/main/java/com/iailab/dto/FeignWarehouseItemDTO.java @@ -0,0 +1,43 @@ +package com.iailab.dto; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import lombok.EqualsAndHashCode; + +@Data +@EqualsAndHashCode(callSuper = false) +@Schema(name = "煤仓详情") +public class FeignWarehouseItemDTO { + /** + * id + */ + private String id; + /** + * 煤仓类型 + */ + private String mclx; + /** + * 煤仓名 + */ + private String mcName; + /** + * 煤仓 + */ + private String mc; + /** + * 单位 + */ + private String unit; + /** + * 容量 + */ + private Integer capacity; + /** + * 创建人 + */ + private String createBy; + /** + * 更新人 + */ + private String updateBy; +} diff --git a/iailab-module-model/iailab-module-model-api/src/main/java/com/iailab/dto/FeignWarehousePositionDTO.java b/iailab-module-model/iailab-module-model-api/src/main/java/com/iailab/dto/FeignWarehousePositionDTO.java new file mode 100644 index 0000000..b57de28 --- /dev/null +++ b/iailab-module-model/iailab-module-model-api/src/main/java/com/iailab/dto/FeignWarehousePositionDTO.java @@ -0,0 +1,58 @@ +package com.iailab.dto; + +import io.swagger.v3.oas.annotations.media.Schema; + +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.io.Serializable; +import java.math.BigDecimal; +import java.util.Date; + +/** + * @author PanZhibao + * @Description + * @createTime 2023年07月01日 10:20:00 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@Schema(name = "仓位") +public class FeignWarehousePositionDTO implements Serializable { + private static final long serialVersionUID = 1L; + + @Schema(name = "日期") + private String rq; + + @Schema(name = "班次") + private String bc; + + @Schema(name = "煤仓") + private String mc; + + @Schema(name = "煤仓类型") + private String mclx; + + @Schema(name = "仓容量") + private String crl; + + @Schema(name = "产品") + private String cp; + + @Schema(name = "内报估量") + private BigDecimal nbgl; + + @Schema(name = "外报估量") + private BigDecimal wbgl; + + @Schema(name = "创建人") + private String cjr; + + @Schema(name = "创建时间") + private Date cjsj; + + @Schema(name = "修改人") + private String xgr; + + @Schema(name = "修改时间") + private Date xgsj; +} diff --git a/iailab-module-model/iailab-module-model-api/src/main/java/com/iailab/dto/FeignWarehouseStockDTO.java b/iailab-module-model/iailab-module-model-api/src/main/java/com/iailab/dto/FeignWarehouseStockDTO.java new file mode 100644 index 0000000..b14bb8d --- /dev/null +++ b/iailab-module-model/iailab-module-model-api/src/main/java/com/iailab/dto/FeignWarehouseStockDTO.java @@ -0,0 +1,83 @@ +package com.iailab.dto; + +import io.swagger.v3.oas.annotations.media.Schema; + +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.io.Serializable; +import java.math.BigDecimal; +import java.util.Date; + +/** + * @author PanZhibao + * @Description + * @createTime 2023年07月01日 10:42:00 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@Schema(name = "库存") +public class FeignWarehouseStockDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + @Schema(name = "日期") + private String rq; + + @Schema(name = "班次") + private String bc; + + @Schema(name = "流水号") + private String lsh; + + @Schema(name = "库存煤种") + private String kcmz; + + @Schema(name = "内报昨日库存") + private BigDecimal nbzrkc; + + @Schema(name = "内报今日入库") + private BigDecimal nbjrrk; + + @Schema(name = "内报今日出库") + private BigDecimal nbjrck; + + @Schema(name = "内报调整量") + private BigDecimal nbtzl; + + @Schema(name = "内报今日库存") + private BigDecimal nbjrkc; + + @Schema(name = "外报昨日库存") + private BigDecimal wbzrkc; + + @Schema(name = "外报今日入库") + private BigDecimal wbjrrk; + + @Schema(name = "外报今日出库") + private BigDecimal wbjrck; + + @Schema(name = "外报调整量") + private BigDecimal wbtzl; + + @Schema(name = "外报今日库存") + private BigDecimal wbjrkc; + + @Schema(name = "备注") + private String bz; + + @Schema(name = "创建人") + private String cjr; + + @Schema(name = "创建时间") + private Date cjsj; + + @Schema(name = "修改人") + private String xgr; + + @Schema(name = "修改时间") + private Date xgsj; + + @Schema(name = "标识(0原煤库存、1产品库存)") + private String bs; +} diff --git a/iailab-module-model/iailab-module-model-api/src/main/java/com/iailab/dto/FeignWashProdVolumeDTO.java b/iailab-module-model/iailab-module-model-api/src/main/java/com/iailab/dto/FeignWashProdVolumeDTO.java new file mode 100644 index 0000000..53486bd --- /dev/null +++ b/iailab-module-model/iailab-module-model-api/src/main/java/com/iailab/dto/FeignWashProdVolumeDTO.java @@ -0,0 +1,98 @@ +package com.iailab.dto; + +import io.swagger.v3.oas.annotations.media.Schema; + +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.io.Serializable; +import java.math.BigDecimal; +import java.util.Date; + +/** + * @author PanZhibao + * @Description + * @createTime 2023年07月01日 13:05:00 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@Schema(name = "生产量") +public class FeignWashProdVolumeDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + @Schema(name = "日期") + private String rq; + + @Schema(name = "班次") + private String bc; + + @Schema(name = "产量煤种") + private String clmz; + + @Schema(name = "内报当日量") + private BigDecimal nbdrl; + + @Schema(name = "内报调整量") + private BigDecimal nbtzl; + + @Schema(name = "外报当日量") + private BigDecimal wbdrl; + + @Schema(name = "外报调整量") + private BigDecimal wbtzl; + + @Schema(name = "采样点") + private String cyd; + + @Schema(name = "采样数量") + private BigDecimal cysl; + + @Schema(name = "化验时间") + private Date hysj; + + @Schema(name = "灰分Ad%") + private BigDecimal hf; + + @Schema(name = "水分Mt%") + private BigDecimal sf; + + @Schema(name = "硫份St,d%") + private BigDecimal lf; + + @Schema(name = "挥发分Vdaf%") + private BigDecimal hff; + + @Schema(name = "粘结GR.I") + private BigDecimal nj; + + @Schema(name = "胶质层Y(㎜)GR.I") + private BigDecimal jzc; + + @Schema(name = "发热量(cal/g)") + private BigDecimal frl; + + @Schema(name = "中损") + private BigDecimal zs; + + @Schema(name = "矸损") + private BigDecimal gs; + + @Schema(name = "压滤煤泥灰分Ad%") + private BigDecimal ylmnHf; + + @Schema(name = "备注") + private String bz; + + @Schema(name = "创建人") + private String cjr; + + @Schema(name = "创建时间") + private Date cjsj; + + @Schema(name = "修改人") + private String xgr; + + @Schema(name = "修改时间") + private Date xgsj; +} diff --git a/iailab-module-model/iailab-module-model-api/src/main/java/com/iailab/dto/FeignWashToWashDTO.java b/iailab-module-model/iailab-module-model-api/src/main/java/com/iailab/dto/FeignWashToWashDTO.java new file mode 100644 index 0000000..355d8ee --- /dev/null +++ b/iailab-module-model/iailab-module-model-api/src/main/java/com/iailab/dto/FeignWashToWashDTO.java @@ -0,0 +1,67 @@ +package com.iailab.dto; + +import io.swagger.v3.oas.annotations.media.Schema; + +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.io.Serializable; +import java.math.BigDecimal; +import java.util.Date; + +/** + * @author PanZhibao + * @Description + * @createTime 2023年07月01日 11:48:00 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@Schema(name = "入洗量") +public class FeignWashToWashDTO implements Serializable { + private static final long serialVersionUID = 1L; + + @Schema(name = "日期") + private String rq; + + @Schema(name = "班次") + private String bc; + + @Schema(name = "洗选精煤") + private String xxjm; + + @Schema(name = "入洗来源") + private String rxly; + + @Schema(name = "入洗配比(:)") + private BigDecimal rxpb; + + @Schema(name = "入洗比例(%)") + private BigDecimal rxbl; + + @Schema(name = "内报当日量") + private BigDecimal nbdrl; + + @Schema(name = "内报调整量") + private BigDecimal nbtzl; + + @Schema(name = "外报当日量") + private BigDecimal wbdrl; + + @Schema(name = "外报调整量") + private BigDecimal wbtzl; + + @Schema(name = "备注") + private String bz; + + @Schema(name = "创建人") + private String cjr; + + @Schema(name = "创建时间") + private Date cjsj; + + @Schema(name = "修改人") + private String xgr; + + @Schema(name = "修改时间") + private Date xgsj; +} diff --git a/iailab-module-model/iailab-module-model-api/src/main/java/com/iailab/dto/FeignWashTransferInDTO.java b/iailab-module-model/iailab-module-model-api/src/main/java/com/iailab/dto/FeignWashTransferInDTO.java new file mode 100644 index 0000000..421d814 --- /dev/null +++ b/iailab-module-model/iailab-module-model-api/src/main/java/com/iailab/dto/FeignWashTransferInDTO.java @@ -0,0 +1,97 @@ +package com.iailab.dto; + +import io.swagger.v3.oas.annotations.media.Schema; + +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.io.Serializable; +import java.math.BigDecimal; +import java.util.Date; + +/** + * @author PanZhibao + * @Description + * @createTime 2023年07月01日 10:57:00 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@Schema(name = "调入量") +public class FeignWashTransferInDTO implements Serializable { + private static final long serialVersionUID = 1L; + + @Schema(name = "日期") + private String rq; + + @Schema(name = "班次") + private String bc; + + @Schema(name = "调入来源") + private String drly; + + @Schema(name = "内报当日量") + private BigDecimal nbdrl; + + @Schema(name = "内报调整量") + private BigDecimal nbtzl; + + @Schema(name = "外报当日量") + private BigDecimal wbdrl; + + @Schema(name = "外报调整量") + private BigDecimal wbtzl; + + @Schema(name = "采样点") + private String cyd; + + @Schema(name = "采样数量") + private BigDecimal cysl; + + @Schema(name = "化验时间") + private Date hysj; + + @Schema(name = "灰分Ad%") + private BigDecimal hf; + + @Schema(name = "水分Mt%") + private BigDecimal sf; + + @Schema(name = "硫份St,d%") + private BigDecimal lf; + + @Schema(name = "挥发分Vdaf%") + private BigDecimal hff; + + @Schema(name = "粘结GR.I") + private BigDecimal nj; + + @Schema(name = "胶质层Y(㎜)GR.I") + private BigDecimal jzc; + + @Schema(name = "发热量(cal/g)") + private BigDecimal frl; + + @Schema(name = "中损") + private BigDecimal zs; + + @Schema(name = "矸损") + private BigDecimal gs; + + @Schema(name = "压滤煤泥灰分Ad%") + private BigDecimal ylmnHf; + + @Schema(name = "备注") + private String bz; + + @Schema(name = "创建人") + private String cjr; + + @Schema(name = "创建时间") + private Date cjsj; + + @Schema(name = "修改人") + private String xgr; + + @Schema(name = "修改时间") + private Date xgsj; +} diff --git a/iailab-module-model/iailab-module-model-biz/pom.xml b/iailab-module-model/iailab-module-model-biz/pom.xml new file mode 100644 index 0000000..a8e0e2e --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/pom.xml @@ -0,0 +1,192 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>com.iailab</groupId> + <artifactId>iailab-module-model</artifactId> + <version>${revision}</version> + </parent> + + <artifactId>iailab-module-model-biz</artifactId> + + <properties> + <maven.compiler.source>8</maven.compiler.source> + <maven.compiler.target>8</maven.compiler.target> + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> + </properties> + + <dependencies> + + <dependency> + <groupId>com.iailab</groupId> + <artifactId>iailab-common-env</artifactId> + </dependency> + + <dependency> + <groupId>com.iailab</groupId> + <artifactId>iailab-common</artifactId> + </dependency> + <dependency> + <groupId>com.iailab</groupId> + <artifactId>iailab-common-mybatis</artifactId> + </dependency> + <dependency> + <groupId>com.iailab</groupId> + <artifactId>iailab-common-redis</artifactId> + </dependency> + <dependency> + <groupId>com.iailab</groupId> + <artifactId>iailab-common-excel</artifactId> + </dependency> + <dependency> + <groupId>com.iailab</groupId> + <artifactId>iailab-common-security</artifactId> + </dependency> + <!-- RPC 远程调用相关 --> + <dependency> + <groupId>com.iailab</groupId> + <artifactId>iailab-common-rpc</artifactId> + </dependency> + <!-- 监控相关 --> + <dependency> + <groupId>com.iailab</groupId> + <artifactId>iailab-common-monitor</artifactId> + </dependency> + <!-- Job 定时任务相关 --> + <dependency> + <groupId>com.iailab</groupId> + <artifactId>iailab-common-job</artifactId> + </dependency> + <dependency> + <groupId>com.iailab</groupId> + <artifactId>iailab-common-biz-data-permission</artifactId> + </dependency> + <dependency> + <groupId>com.iailab</groupId> + <artifactId>iailab-module-model-api</artifactId> + <version>${revision}</version> + </dependency> + <dependency> + <groupId>com.iailab</groupId> + <artifactId>iailab-module-data-api</artifactId> + <version>${revision}</version> + </dependency> + <dependency> + <groupId>org.springframework.cloud</groupId> + <artifactId>spring-cloud-loadbalancer</artifactId> + </dependency> + + <!-- nacos 客户端 --> + <dependency> + <groupId>com.alibaba.cloud</groupId> + <artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId> + </dependency> + <!-- nacos 配置中心 --> + <dependency> + <groupId>com.alibaba.cloud</groupId> + <artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId> + </dependency> + <dependency> + <groupId>org.quartz-scheduler</groupId> + <artifactId>quartz</artifactId> + <version>2.3.2</version> + </dependency> + +<!-- <dependency>--> +<!-- <groupId>org.quartz-scheduler</groupId>--> +<!-- <artifactId>quartz</artifactId>--> +<!-- <version>${quartz.version}</version>--> +<!-- <exclusions>--> +<!-- <exclusion>--> +<!-- <groupId>com.mchange</groupId>--> +<!-- <artifactId>c3p0</artifactId>--> +<!-- </exclusion>--> +<!-- <exclusion>--> +<!-- <groupId>com.zaxxer</groupId>--> +<!-- <artifactId>HikariCP-java6</artifactId>--> +<!-- </exclusion>--> +<!-- </exclusions>--> +<!-- </dependency>--> +<!-- <dependency>--> +<!-- <groupId>cn.afterturn</groupId>--> +<!-- <artifactId>easypoi-base</artifactId>--> +<!-- <version>${easypoi.version}</version>--> +<!-- </dependency>--> +<!-- <dependency>--> +<!-- <groupId>cn.afterturn</groupId>--> +<!-- <artifactId>easypoi-web</artifactId>--> +<!-- <version>${easypoi.version}</version>--> +<!-- </dependency>--> +<!-- <dependency>--> +<!-- <groupId>cn.afterturn</groupId>--> +<!-- <artifactId>easypoi-annotation</artifactId>--> +<!-- <version>${easypoi.version}</version>--> +<!-- </dependency>--> + + <!-- 引用POI --> + <dependency> + <groupId>org.apache.poi</groupId> + <artifactId>poi</artifactId> + <version>4.1.1</version> + </dependency> + + <dependency> + <groupId>org.jetbrains</groupId> + <artifactId>annotations</artifactId> + <version>17.0.0</version> + <scope>compile</scope> + </dependency> + + <!-- ModBus TCP --> + <dependency> + <groupId>com.infiniteautomation</groupId> + <artifactId>modbus4j</artifactId> + <version>3.0.4</version> + </dependency> + + <!-- OPC UA --> + <dependency> + <groupId>org.eclipse.milo</groupId> + <artifactId>sdk-client</artifactId> + <version>0.6.9</version> + </dependency> + <dependency> + <groupId>org.eclipse.milo</groupId> + <artifactId>sdk-server</artifactId> + <version>0.6.9</version> + </dependency> + <dependency> + <groupId>com.google.guava</groupId> + <artifactId>guava</artifactId> + <version>31.0.1-jre</version> + </dependency> + <dependency> + <groupId>org.quartz-scheduler</groupId> + <artifactId>quartz</artifactId> + <version>2.3.2</version> + </dependency> + <!-- influxdb --> + <dependency> + <groupId>com.influxdb</groupId> + <artifactId>influxdb-client-java</artifactId> + <version>6.8.0</version> + </dependency> + + <!-- websocket --> + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-websocket</artifactId> + </dependency> +<!-- <dependency>--> +<!-- <groupId>io.swagger.core.v3</groupId>--> +<!-- <artifactId>swagger-annotations</artifactId>--> +<!-- <version>2.2.21</version>--> +<!-- <scope>compile</scope>--> +<!-- </dependency>--> + + </dependencies> + + +</project> \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/ModelServiceApplication.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/ModelServiceApplication.java new file mode 100644 index 0000000..e306c71 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/ModelServiceApplication.java @@ -0,0 +1,25 @@ +package com.iailab; + +import org.springframework.boot.CommandLineRunner; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.cloud.client.discovery.EnableDiscoveryClient; +import org.springframework.cloud.openfeign.EnableFeignClients; + +@SpringBootApplication +public class ModelServiceApplication implements CommandLineRunner { + + + public static void main(String[] args) { + SpringApplication.run(ModelServiceApplication.class, args); + } + + /** + * 容器初始化后加载路由 + * + * @param strings + */ + @Override + public void run(String... strings) { + } +} diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/annotation/DataFilter.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/annotation/DataFilter.java new file mode 100644 index 0000000..3634883 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/annotation/DataFilter.java @@ -0,0 +1,37 @@ +/** + * Copyright (c) 2018 人人开源 All rights reserved. + * + * https://www.renren.io + * + * 版权所有,侵权必究! + */ + +package com.iailab.common.annotation; + +import java.lang.annotation.*; + +/** + * 数据过滤注解 + * + * @author Mark sunlightcs@gmail.com + */ +@Target(ElementType.METHOD) +@Retention(RetentionPolicy.RUNTIME) +@Documented +public @interface DataFilter { + /** + * 表的别名 + */ + String tableAlias() default ""; + + /** + * 用户ID + */ + String userId() default "creator"; + + /** + * 部门ID + */ + String deptId() default "dept_id"; + +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/annotation/LogOperation.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/annotation/LogOperation.java new file mode 100644 index 0000000..13d06d8 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/annotation/LogOperation.java @@ -0,0 +1,24 @@ +/** + * Copyright (c) 2018 人人开源 All rights reserved. + * + * https://www.renren.io + * + * 版权所有,侵权必究! + */ + +package com.iailab.common.annotation; + +import java.lang.annotation.*; + +/** + * 操作日志注解 + * + * @author Mark sunlightcs@gmail.com + */ +@Target(ElementType.METHOD) +@Retention(RetentionPolicy.RUNTIME) +@Documented +public @interface LogOperation { + + String value() default ""; +} diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/aspect/DictAspect.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/aspect/DictAspect.java new file mode 100644 index 0000000..baa98e5 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/aspect/DictAspect.java @@ -0,0 +1,152 @@ +//package com.iailab.common.aspect; +// +//import com.alibaba.fastjson.JSONObject; +//import com.alibaba.fastjson.parser.Feature; +//import com.iailab.common.annotation.Dict; +//import com.iailab.framework.common.page.PageData; +//import com.iailab.framework.common.util.object.ConvertUtils; +//import com.iailab.framework.common.pojo.CommonResult; +//import com.iailab.entity.SysDictItem; +//import com.iailab.module.infra.api.config.ConfigApi; +//import lombok.extern.slf4j.Slf4j; +//import org.aspectj.lang.ProceedingJoinPoint; +//import org.aspectj.lang.annotation.Around; +//import org.aspectj.lang.annotation.Aspect; +//import org.aspectj.lang.annotation.Pointcut; +//import javax.annotation.Resource; +//import org.springframework.stereotype.Component; +//import org.springframework.util.CollectionUtils; +// +//import java.beans.IntrospectionException; +//import java.beans.PropertyDescriptor; +//import java.lang.reflect.Field; +//import java.lang.reflect.InvocationTargetException; +//import java.lang.reflect.Method; +//import java.util.HashMap; +//import java.util.List; +//import java.util.Map; +// +///** +// * @author PanZhibao +// * @Description +// * @createTime 2022年05月21日 09:57:00 +// */ +//@Aspect +//@Component +//@Slf4j +//public class DictAspect { +// +// private final String PAGE_CODE = "page"; +// +// private final String DATA_CODE = "data"; +// +// @Resource +// private ConfigApi configApi; +// +// /** +// * 定义切点Pointcut +// */ +// @Pointcut("@annotation(com.iailab.common.annotation.AutoDict)") +// public void excudeService() { +// } +// +// @Around("excudeService()") +// public Object doAround(ProceedingJoinPoint pjp) throws Throwable { +// Object result = pjp.proceed(); +// try { +// this.parseDictText(result); +// } catch (Exception ex) { +// log.info(ex.getMessage()); +// } +// return result; +// } +// +// /** +// * parseDictText +// * +// * @param result +// * @throws IntrospectionException +// * @throws InvocationTargetException +// * @throws IllegalAccessException +// */ +// private void parseDictText(Object result) throws IntrospectionException, InvocationTargetException, IllegalAccessException { +// Map<String, List<SysDictItem>> mapList = configApi.queryAllDictItems(); +// Map<String,Map<String, String>> map = new HashMap<>(); +// if (!CollectionUtils.isEmpty(mapList)) { +// mapList.forEach((k , v) -> { +// Map<String, String> dictItems = new HashMap<>(); +// if (!CollectionUtils.isEmpty(v)) { +// v.forEach(item -> { +// dictItems.put(item.getItemValue(), item.getItemText()); +// }); +// } +// map.put(k, dictItems); +// }); +// } +// +// if(result instanceof CommonResult) { +// if(((CommonResult) result).getData() != null) { +// Object data = ((CommonResult) result).getData(); +// if (data instanceof List) { +// for (Object record : (List)data) { +// this.setDictText(record, map); +// } +// } else if(data instanceof PageData) { +// Object list = ((PageData)data).getList(); +// for (Object record : (List)list) { +// this.setDictText(record, map); +// } +// } else { +// this.setDictText(data, map); +// } +// } +// } else if (result instanceof List){ +// for (Object record : (List)result) { +// this.setDictText(record, map); +// } +// } +// } +// +// /** +// * setDictText +// * +// * @param record +// * @param map +// * @throws IntrospectionException +// * @throws InvocationTargetException +// * @throws IllegalAccessException +// */ +// private void setDictText(Object record, Map<String,Map<String, String>> map) throws IntrospectionException, InvocationTargetException, IllegalAccessException { +// JSONObject item = JSONObject.parseObject(JSONObject.toJSONString(record), Feature.OrderedField); +// for (Field field : ConvertUtils.getAllFields(record)) { +// if (!field.isAnnotationPresent(Dict.class)) { +// continue; +// } +// String dictCode = field.getAnnotation(Dict.class).dicCode(); +// String itemValue = field.getAnnotation(Dict.class).itemValue(); +// String value = item.getString(itemValue); +// Method method = new PropertyDescriptor(field.getName(), record.getClass()).getWriteMethod(); +// method.invoke(record, this.getDictText(dictCode, value, map)); +// } +// } +// +// /** +// * getDictText +// * +// * @param dictCode +// * @param itemValue +// * @param map +// * @return +// */ +// private String getDictText(String dictCode, String itemValue, Map<String,Map<String, String>> map) { +// String dictText = ""; +// try{ +// if (map != null || map.containsKey(dictCode)) { +// dictText = map.get(dictCode).get(itemValue); +// } +// } catch (Exception ex) { +// log.info("字典异常:" + dictCode ); +// } +// return dictText; +// } +//} diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/config/MybatisPlusConfig.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/config/MybatisPlusConfig.java new file mode 100644 index 0000000..a9ef27e --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/config/MybatisPlusConfig.java @@ -0,0 +1,43 @@ +///** +// * Copyright (c) 2018 人人开源 All rights reserved. +// * +// * https://www.renren.io +// * +// * 版权所有,侵权必究! +// */ +// +//package com.iailab.common.config; +// +//import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor; +//import com.baomidou.mybatisplus.extension.plugins.inner.BlockAttackInnerInterceptor; +//import com.baomidou.mybatisplus.extension.plugins.inner.OptimisticLockerInnerInterceptor; +//import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor; +//import com.iailab.common.interceptor.DataFilterInterceptor; +//import org.springframework.context.annotation.Bean; +//import org.springframework.context.annotation.Configuration; +// +///** +// * mybatis-plus配置 +// * +// * @author Mark sunlightcs@gmail.com +// * @since 1.0.0 +// */ +//@Configuration +//public class MybatisPlusConfig { +// +// @Bean +// public MybatisPlusInterceptor mybatisPlusInterceptor() { +// MybatisPlusInterceptor mybatisPlusInterceptor = new MybatisPlusInterceptor(); +// // 数据权限 +// mybatisPlusInterceptor.addInnerInterceptor(new DataFilterInterceptor()); +// // 分页插件 +// mybatisPlusInterceptor.addInnerInterceptor(new PaginationInnerInterceptor()); +// // 乐观锁 +// mybatisPlusInterceptor.addInnerInterceptor(new OptimisticLockerInnerInterceptor()); +// // 防止全表更新与删除 +// mybatisPlusInterceptor.addInnerInterceptor(new BlockAttackInnerInterceptor()); +// +// return mybatisPlusInterceptor; +// } +// +//} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/constant/BusinessConstant.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/constant/BusinessConstant.java new file mode 100644 index 0000000..ee0c7e8 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/constant/BusinessConstant.java @@ -0,0 +1,171 @@ +package com.iailab.common.constant; + +/** + * 业务功能常量 + * + * @author PanZhibao + * @Description + * @createTime 2023年06月14日 11:58:00 + */ +public interface BusinessConstant { + + String DEV_Y = "y"; + + Integer granularity = 60; //时间粒度 + + + String MODEL_R_ERROR = "5"; // 模型结果错误 + + String MODEL_R_WARN = "4"; // 模型结果警告 + + + String In_ControlModel_PointNo = "1000"; //控制模式 + + + String FXModelCode = "separation_control";//分选控制模型 + + String JYModelCode = "dosing_control";//加药控制模型 + + Integer Granularity60 = 60; //时间粒度 + + Integer Granularity300 = 300; //时间粒度 + Integer Granularity10 = 10; //时间粒度 + + //设备健康评价模型 + String MODEL_Health_Status_Evaluate = "1b703117-7e6a-4bb8-82ad-b485d81a4fe5"; + + + String MODEL_Density_ParamID = "preDensity"; //分选预测 + + String MODEL_1315_ParamID = "V1315"; //1315/1分流阀开度给定值 + String MODEL_1308_ParamID= "V1308"; //1308/1分流阀开度给定值 + String MODEL_1355_ParamID = "V1355"; //1355/1分流阀开度给定值 + String MODEL_1309_ParamID = "V1309"; //1309/1分流阀开度给定值 + + String MODEL_YIN1_ParamID = "Vyin1"; //阴离子泵1频率给定值 + String MODEL_YIN2_ParamID = "Vyin2"; //阴离子泵2频率给定值 + String MODEL_YANG1_ParamID = "Vyang1"; //阳离子泵1频率给定值 + String MODEL_YANG2_ParamID = "Vyang2"; //阳离子泵1频率给定值 + + //OPCUA + String OPCUA_1315_PointNo = "1315_1_KD";//1315/1加水阀开关反馈值(8011改成1315_1_KD) + String OPCUA_1308_PointNo = "8002";//1308/1分流阀开度反馈值 + String OPCUA_1309_PointNo = "8004";//1309/1分流阀开度反馈值 + String OPCUA_1355_PointNo = "1355_1_KD";//1355/1加介阀开度反馈值(8033改成1355_1_KD) + String OPCUA_13151_RunState_PointNo = "13151_RunState";//阀13151运行状态 + String OPCUA_1355_1_KD_net10 = "1355_1_KD_net10";//1355/1阀门开度(10s采集频率) + String OPCUA_1315_1_KD_net10 = "1315_1_KD_net10"; + String OPCUA_1308_1_KD_net10 = "1308_1_KD_net10"; + String OPCUA_1309_1_KD_net10 = "1309_1_KD_net10"; + String OPCUA_1308_net10_PointNo = "8002_net10";//1308/1分流阀开度反馈值 + String OPCUA_1309_net10_PointNo = "8004_net10";//1309/1分流阀开度反馈值 + + + String OPCUA_1315_1_fh_PointNo = "1315_1_fh"; // 手动_稀介桶1315/1加水阀开度 + String OPCUA_1355_1_fh_PointNo = "1355_1_fh"; // 手动_1355/1分流阀开度 + + String OPCUA_8039_PointNo = "8039";//合介浓度反馈值 + String OPCUA_8041_PointNo = "8041";//稀介桶位高度 + String OPCUA_8043_PointNo = "8043";//合介桶位高度 + String OPCUA_8031_PointNo = "8031";//原煤入料 + String OPCUA_7001_PointNo = "7001";//原煤灰分 + String OPCUA_2001_PointNo = "2001";//精煤在线灰分 + + String OPCUA_1315_1_KD = "1315_1_KD"; + String OPCUA_1308_1_KD = "1308_1_KD"; + String OPCUA_1355_1_KD = "1355_1_KD"; + String OPCUA_1309_1_KD = "1309_1_KD"; + + //OPCUA + String OPCUA_8129_PointNo = "8129";//1610加药装置1#变频器频率返回 + String OPCUA_8130_PointNo = "8130";//1610加药装置2#变频器频率返回 + String OPCUA_8134_PointNo = "8134";//1611加药装置1#变频器频率返回 + String OPCUA_8135_PointNo = "8135";//1611加药装置2#变频器频率返回 + String OPCUA_3101_PointNo = "3101";//浓缩池入料浓度 + String OPCUA_3102_PointNo = "3102";//浓缩池入料流量1 + String OPCUA_3103_PointNo = "3103";//浓缩池入料流量2 + String OPCUA_8144_PointNo = "8144";//耙子1601靶位耙子NT + String OPCUA_8143_PointNo = "8143";//耙子1601扭矩耙子NT + String OPCUA_8149_PointNo = "8149";//耙子1602靶位耙子NT + String OPCUA_8150_PointNo = "8150";//耙子1602扭矩耙子NT + String OPCUA_8151_PointNo = "8151";//清水液位1 + String OPCUA_8161_PointNo = "8161";//清水液位2 + String OPCUA_3107_PointNo = "3107";//浓缩池出料浓度(底流浓度) + String OPCUA_3112_PointNo = "3112";//循环水池浊度(溢流浊度) + + String OPCUA_set_1610_1_f = "set_1610_1_f"; // 1610_1上位机频率设定(阴) + String OPCUA_set_1610_2_f = "set_1610_2_f"; // 1610_2上位机频率设定(阴) + + String OPCUA_i1610_1_f_set = "i1610_1_f_set"; + String OPCUA_i1610_2_f_set = "i1610_2_f_set"; + String OPCUA_i1611_1_f_set = "i1611_1_f_set"; + String OPCUA_i1611_2_f_set = "i1611_2_f_set"; + + String OPCUA_i_1610_LL = "i_1610_LL"; // 1610加药装置 流量计(阳) + String OPCUA_i_1611_LL = "i_1611_LL"; // 1611加药装置 流量计(阴) + String OPCUA_i1610_LL_Set = "i1610_LL_Set"; // 1610流量设定(阳) + String OPCUA_i1611_LL_Set = "i1611_LL_Set"; // 1611流量设定(阴) + + Integer SCHEDULEDCLEANDAYS = -10; //定时任务清理10天之前数据 + + String Code_Model = "model"; + + String Code_Model_Path = "path"; + + String Code_Model_Start= "start"; + + String MODELE_RESULT_STATUS = "status"; + + Integer MODELE_RESULT_STATUS_200 = 200; + + Integer MODELE_RESULT_STATUS_401 = 401; + + String MODELE_RESULT_TIPS = "tips"; + + /** + * 智能浓缩加药控制器启动状态 + */ + String SYS_PARAM_Controller_ICAD_ONSTS = "Controller_ICAD_ONSTS"; + + /** + * 智能分选控制器启动状态 + */ + String SYS_PARAM_Controller_IHMS_ONSTS = "Controller_IHMS_ONSTS"; + + String SYS_PARAM_Y = "y"; + + /** + * 分选启动,煤泥系统未启动 + */ + String ONSTS10 = "10"; + + /** + * 分选启动、煤泥系统启动 + */ + String ONSTS11 = "11"; + + /** + * 分选未启动、煤泥系统启动 + */ + String ONSTS01 = "01"; + + String ONSTS10_NAME = "分选启动,煤泥未启"; + + String ONSTS11_NAME = "分选启动,煤泥启动"; + + String ONSTS01_NAME = "分选未启,煤泥启动"; + + String RESULT = "CommonResult"; + + String RESULT_TRUE = "true"; + + String STATUS_TRUE = "true"; + + String STATUS_FALSE = "false"; + + String OPCUA_ZNJY_ALM = "ZNJY_ALM"; + + String OPCUA_ZNFX_ALM = "ZNFX_ALM"; + + long YEAR_MINUTE = 365 * 24 * 60; +} diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/dto/IndexQueryDTO.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/dto/IndexQueryDTO.java new file mode 100644 index 0000000..cc76369 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/dto/IndexQueryDTO.java @@ -0,0 +1,15 @@ +package com.iailab.common.dto; + +import lombok.Data; + +import java.util.Date; + +@Data +public class IndexQueryDTO { + + private Date startDate; + + private Date endDate; + + private String code; +} diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/dto/IndexStatisticDTO.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/dto/IndexStatisticDTO.java new file mode 100644 index 0000000..5572bc6 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/dto/IndexStatisticDTO.java @@ -0,0 +1,15 @@ +package com.iailab.common.dto; + +import lombok.Data; + +import java.io.Serializable; +import java.math.BigDecimal; +import java.util.Date; +@Data +public class IndexStatisticDTO implements Serializable { + private static final long serialVersionUID = 1L; + + public Date dateTime; + public BigDecimal data; + +} diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/dto/echarts/BarLineDTO.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/dto/echarts/BarLineDTO.java new file mode 100644 index 0000000..63c4c68 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/dto/echarts/BarLineDTO.java @@ -0,0 +1,27 @@ +package com.iailab.common.dto.echarts; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.io.Serializable; +import java.util.List; + +/** + * @author lirm + * @Description + * @createTime 2023.05.11 + */ +@Data +@Schema(name = "图表") +public class BarLineDTO implements Serializable { + private static final long serialVersionUID = 1L; + + private String valueName;//表名称 + + private List<String> legend;//线的名称 + + private List<String> categories;//X轴数据 + + private List<SeriesItem> series;//Y轴数据集合 + +} diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/dto/echarts/SeriesItem.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/dto/echarts/SeriesItem.java new file mode 100644 index 0000000..7ac0024 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/dto/echarts/SeriesItem.java @@ -0,0 +1,18 @@ +package com.iailab.common.dto.echarts; + +import lombok.Data; + +import java.util.List; + +/** + * @author lirm + * @Description + * @createTime 2023.05.11 + */ +@Data +public class SeriesItem { + + private String name; + + private List<Object[]> data; +} diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/dto/vue/CascaderOptionDTO.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/dto/vue/CascaderOptionDTO.java new file mode 100644 index 0000000..24c2c10 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/dto/vue/CascaderOptionDTO.java @@ -0,0 +1,22 @@ +package com.iailab.common.dto.vue; + +import lombok.Data; + +import java.io.Serializable; +import java.util.List; + +/** + * @author PanZhibao + * @Description + * @createTime 2023年05月15日 13:46:00 + */ +@Data +public class CascaderOptionDTO implements Serializable { + private static final long serialVersionUID = 1L; + + private String value; + + private String label; + + private List<CascaderOptionDTO> children; +} diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/enums/CdbmEnum.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/enums/CdbmEnum.java new file mode 100644 index 0000000..7cd3d1f --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/enums/CdbmEnum.java @@ -0,0 +1,79 @@ +package com.iailab.common.enums; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +/** + * @author DongYukun + * @Description + * @createTime 2024年05月12日 9:57:00 + */ +@Getter +@AllArgsConstructor +public enum CdbmEnum { + + //报表 + PLAN("plan", "计划","t"), + CL("cl", "产量","t"), + DBL("dbl", "达标率","%"), + HF("hf", "灰分","%"), + SF("sf", "水分","%"), + LF("lf", "硫分","%"), + RZ("rz", "热值","cal/g"), + + YIN("yin","阴离子消耗","kg"), + YANG("yang","阳离子消耗","kg"), + JH("jh","介耗","kg"), + + DXHM("groundsales","地销混煤","t"), + XZKWY("medblock","洗中块外运","t"), + XXKWY("nubmeasure","洗小块外运","t"), + GSWY("gangue","矸石外运","t"), + XKZZ("reshipped","小块转载","t"), + HCWYT("trainTon","火车外运吨数","t"), + HCWYC("trainCount","火车外运列数","列"), + + //测点 + AP1("M0000100373","1#低压风机出口压力","kpa"), + AP2("M0000100374","2#低压风机出口压力","kpa"), + HJMD3318("M0000100030","3318线路合介密度","kg/L"), + HJMD3319("M0000100031","3319线路合介密度","kg/L"), + HJMD315("M0000100084","307合介桶密度","kg/L"), + HJMD316("M0000100078","308合介桶密度","kg/L"), + BF401("M0000100108","401浓缩池出料浓度(底流浓度)","kg/L"), + BF402("M0000100114","402浓缩池出料浓度(底流浓度)","kg/L"), + BF501("M0000100120","501浓缩池出料浓度(底流浓度)","kg/L"), + BF504("M0000100120","504浓缩池出料浓度(底流浓度)","kg/L"), + + PDC721("721.DayTotal","721皮带秤累计","t"), + PDC722("722.DayTotal","722皮带秤累计","t"); + private String code; + private String desc; + private String unit;//单位 + + public static CdbmEnum getEumByCode(String code) { + if (code == null) { + return null; + } + + for (CdbmEnum cdbmEnum : CdbmEnum.values()) { + if (cdbmEnum.getCode().equals(code)) { + return cdbmEnum; + } + } + return null; + } + + public static CdbmEnum getEumByName(String name) { + if (name == null) { + return null; + } + + for (CdbmEnum cdbmEnum : CdbmEnum.values()) { + if (cdbmEnum.name().equals(name)) { + return cdbmEnum; + } + } + return null; + } +} diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/enums/CommonConstant.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/enums/CommonConstant.java new file mode 100644 index 0000000..d83138d --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/enums/CommonConstant.java @@ -0,0 +1,433 @@ +package com.iailab.common.enums; + + +/** + * @Description: 通用常量 + */ +public interface CommonConstant { + + String STA_TRUE = "true"; + + String ZX_RES = "res"; + + String CJS_SYS = "system"; + + /** + * 启用 + */ + public static final int IS_ENABLE = 1; + + /** + * 删除标志 + */ + public static final Integer BPM_FLAG_1 = 1; + + /** + * 正常状态 + */ + public static final Integer STATUS_NORMAL = 0; + + /** + * 禁用状态 + */ + public static final Integer STATUS_DISABLE = -1; + + /** + * 删除标志 + */ + public static final Integer DEL_FLAG_1 = 1; + + /** + * 未删除 + */ + public static final Integer DEL_FLAG_0 = 0; + + /** + * 未提交 + */ + public static final Integer SUBMINT_STATUS_0 = 0; + + /** + * 系统日志类型: 登录 + */ + public static final int LOG_TYPE_1 = 1; + + /** + * 系统日志类型: 操作 + */ + public static final int LOG_TYPE_2 = 2; + + /** + * 操作日志类型: 查询 + */ + public static final int OPERATE_TYPE_1 = 1; + + /** + * 操作日志类型: 添加 + */ + public static final int OPERATE_TYPE_2 = 2; + + /** + * 操作日志类型: 更新 + */ + public static final int OPERATE_TYPE_3 = 3; + + /** + * 操作日志类型: 删除 + */ + public static final int OPERATE_TYPE_4 = 4; + + /** + * 操作日志类型: 倒入 + */ + public static final int OPERATE_TYPE_5 = 5; + + /** + * 操作日志类型: 导出 + */ + public static final int OPERATE_TYPE_6 = 6; + + /** + * 提交 + */ + public static final int SUBMIT_FLAG_1 = 1; + + /** + * 通过 + */ + public static final int SUBMIT_FLAG_2 = 2; + + /** + * 驳回 + */ + public static final int SUBMIT_FLAG_3 = 3; + + /** + * 提交 + */ + public static final int SUBMIT_FLAG_0 = 0; + + public static final int SUBMIT_FLAG_4 = 4; + + public static final int SUBMIT_FLAG_5 = 5; + + public static final int SUBMIT_FLAG_6 = 6; + + public static final Integer DANGER_STATUS = 1; + + public static final Integer DANGER_STATUS_2 = 2; + + + /** {@code 500 Server Error} (HTTP/1.0 - RFC 1945) */ + public static final Integer SC_INTERNAL_SERVER_ERROR_500 = 500; + /** {@code 200 OK} (HTTP/1.0 - RFC 1945) */ + public static final Integer SC_OK_200 = 200; + + /**访问权限认证未通过 510*/ + public static final Integer SC_JEECG_NO_AUTHZ=510; + + /** 登录用户Shiro权限缓存KEY前缀 */ + public static String PREFIX_USER_SHIRO_CACHE = "shiro:cache:org.jeecg.config.shiro.ShiroRealm.authorizationCache:"; + /** 登录用户Token令牌缓存KEY前缀 */ + public static final String PREFIX_USER_TOKEN = "prefix_user_token_"; +// /** Token缓存时间:3600秒即一小时 */ +// public static final int TOKEN_EXPIRE_TIME = 3600; + + /** 登录二维码 */ + public static final String LOGIN_QRCODE_PRE = "QRCODELOGIN:"; + public static final String LOGIN_QRCODE = "LQ:"; + /** 登录二维码token */ + public static final String LOGIN_QRCODE_TOKEN = "LQT:"; + + + /** + * 0:一级菜单 + */ + public static final Integer MENU_TYPE_0 = 0; + /** + * 1:子菜单 + */ + public static final Integer MENU_TYPE_1 = 1; + /** + * 2:按钮权限 + */ + public static final Integer MENU_TYPE_2 = 2; + + /**通告对象类型(USER:指定用户,ALL:全体用户)*/ + public static final String MSG_TYPE_UESR = "USER"; + public static final String MSG_TYPE_ALL = "ALL"; + + /**发布状态(0未发布,1已发布,2已撤销)*/ + public static final String NO_SEND = "0"; + public static final String HAS_SEND = "1"; + public static final String HAS_CANCLE = "2"; + + /**阅读状态(0未读,1已读)*/ + public static final String HAS_READ_FLAG = "1"; + public static final String NO_READ_FLAG = "0"; + + /**优先级(L低,M中,H高)*/ + public static final String PRIORITY_L = "L"; + public static final String PRIORITY_M = "M"; + public static final String PRIORITY_H = "H"; + + /** + * 短信模板方式 0 .登录模板、1.注册模板、2.忘记密码模板 + */ + public static final String SMS_TPL_TYPE_0 = "0"; + public static final String SMS_TPL_TYPE_1 = "1"; + public static final String SMS_TPL_TYPE_2 = "2"; + + /** + * 状态(0无效1有效) + */ + public static final String STATUS_0 = "0"; + public static final String STATUS_1 = "1"; + + /** + * 状态(0无效1有效) + */ + public static final Integer INT_STATUS_0 = 0; + public static final Integer INT_STATUS_1 = 1; + + /** + * 同步工作流引擎1同步0不同步 + */ + public static final Integer ACT_SYNC_1 = 1; + public static final Integer ACT_SYNC_0 = 0; + + /** + * 消息类型1:通知公告2:系统消息 + */ + public static final String MSG_CATEGORY_1 = "1"; + public static final String MSG_CATEGORY_2 = "2"; + + /** + * 是否配置菜单的数据权限 1是0否 + */ + public static final Integer RULE_FLAG_0 = 0; + public static final Integer RULE_FLAG_1 = 1; + + /** + * 是否用户已被冻结 1正常(解冻) 2冻结 + */ + public static final Integer USER_UNFREEZE = 1; + public static final Integer USER_FREEZE = 2; + + /**字典翻译文本后缀*/ + public static final String DICT_TEXT_SUFFIX = "_dictText"; + + /** + * 表单设计器主表类型 + */ + public static final Integer DESIGN_FORM_TYPE_MAIN = 1; + + /** + * 表单设计器子表表类型 + */ + public static final Integer DESIGN_FORM_TYPE_SUB = 2; + + /** + * 表单设计器URL授权通过 + */ + public static final Integer DESIGN_FORM_URL_STATUS_PASSED = 1; + + /** + * 表单设计器URL授权未通过 + */ + public static final Integer DESIGN_FORM_URL_STATUS_NOT_PASSED = 2; + + /** + * 表单设计器新增 Flag + */ + public static final String DESIGN_FORM_URL_TYPE_ADD = "add"; + /** + * 表单设计器修改 Flag + */ + public static final String DESIGN_FORM_URL_TYPE_EDIT = "edit"; + /** + * 表单设计器详情 Flag + */ + public static final String DESIGN_FORM_URL_TYPE_DETAIL = "detail"; + /** + * 表单设计器复用数据 Flag + */ + public static final String DESIGN_FORM_URL_TYPE_REUSE = "reuse"; + /** + * 表单设计器编辑 Flag (已弃用) + */ + public static final String DESIGN_FORM_URL_TYPE_VIEW = "view"; + + /** + * online参数值设置(是:Y, 否:N) + */ + public static final String ONLINE_PARAM_VAL_IS_TURE = "Y"; + public static final String ONLINE_PARAM_VAL_IS_FALSE = "N"; + + /** + * 文件上传类型(本地:local,Minio:minio,阿里云:alioss) + */ + public static final String UPLOAD_TYPE_LOCAL = "local"; + public static final String UPLOAD_TYPE_MINIO = "minio"; + public static final String UPLOAD_TYPE_OSS = "alioss"; + + /** + * 文档上传自定义桶名称 + */ + public static final String UPLOAD_CUSTOM_BUCKET = "eoafile"; + /** + * 文档上传自定义路径 + */ + public static final String UPLOAD_CUSTOM_PATH = "eoafile"; + /** + * 文件外链接有效天数 + */ + public static final Integer UPLOAD_EFFECTIVE_DAYS = 1; + + /** + * 员工身份 (1:普通员工 2:上级) + */ + public static final Integer USER_IDENTITY_1 = 1; + public static final Integer USER_IDENTITY_2 = 2; + + /** sys_user 表 username 唯一键索引 */ + public static final String SQL_INDEX_UNIQ_SYS_USER_USERNAME = "uniq_sys_user_username"; + /** sys_user 表 work_no 唯一键索引 */ + public static final String SQL_INDEX_UNIQ_SYS_USER_WORK_NO = "uniq_sys_user_work_no"; + /** sys_user 表 phone 唯一键索引 */ + public static final String SQL_INDEX_UNIQ_SYS_USER_PHONE = "uniq_sys_user_phone"; + /** 达梦数据库升提示。违反表[SYS_USER]唯一性约束 */ + public static final String SQL_INDEX_UNIQ_SYS_USER = "唯一性约束"; + + /** sys_user 表 email 唯一键索引 */ + public static final String SQL_INDEX_UNIQ_SYS_USER_EMAIL = "uniq_sys_user_email"; + /** sys_quartz_job 表 job_class_name 唯一键索引 */ + public static final String SQL_INDEX_UNIQ_JOB_CLASS_NAME = "uniq_job_class_name"; + /** sys_position 表 code 唯一键索引 */ + public static final String SQL_INDEX_UNIQ_CODE = "uniq_code"; + /** sys_role 表 code 唯一键索引 */ + public static final String SQL_INDEX_UNIQ_SYS_ROLE_CODE = "uniq_sys_role_role_code"; + /** sys_depart 表 code 唯一键索引 */ + public static final String SQL_INDEX_UNIQ_DEPART_ORG_CODE = "uniq_depart_org_code"; + /** sys_category 表 code 唯一键索引 */ + public static final String SQL_INDEX_UNIQ_CATEGORY_CODE = "idx_sc_code"; + /** + * 在线聊天 是否为默认分组 + */ + public static final String IM_DEFAULT_GROUP = "1"; + /** + * 在线聊天 图片文件保存路径 + */ + public static final String IM_UPLOAD_CUSTOM_PATH = "imfile"; + /** + * 在线聊天 用户状态 + */ + public static final String IM_STATUS_ONLINE = "online"; + + /** + * 在线聊天 SOCKET消息类型 + */ + public static final String IM_SOCKET_TYPE = "chatMessage"; + + /** + * 在线聊天 是否开启默认添加好友 1是 0否 + */ + public static final String IM_DEFAULT_ADD_FRIEND = "1"; + + /** + * 在线聊天 用户好友缓存前缀 + */ + public static final String IM_PREFIX_USER_FRIEND_CACHE = "sys:cache:im:im_prefix_user_friend_"; + + /** + * 考勤补卡业务状态 (1:同意 2:不同意) + */ + public static final String SIGN_PATCH_BIZ_STATUS_1 = "1"; + public static final String SIGN_PATCH_BIZ_STATUS_2 = "2"; + + /** + * 公文文档上传自定义路径 + */ + public static final String UPLOAD_CUSTOM_PATH_OFFICIAL = "officialdoc"; + /** + * 公文文档下载自定义路径 + */ + public static final String DOWNLOAD_CUSTOM_PATH_OFFICIAL = "officaldown"; + + /** + * WPS存储值类别(1 code文号 2 text(WPS模板还是公文发文模板)) + */ + public static final String WPS_TYPE_1="1"; + public static final String WPS_TYPE_2="2"; + + + public final static String X_ACCESS_TOKEN = "X-Access-Token"; + public final static String X_SIGN = "X-Sign"; + public final static String X_TIMESTAMP = "X-TIMESTAMP"; + public final static String TOKEN_IS_INVALID_MSG = "Token失效,请重新登录!"; + + /** + * 多租户 请求头 + */ + public final static String TENANT_ID = "tenant-id"; + + /** + * 微服务读取配置文件属性 服务地址 + */ + public final static String CLOUD_SERVER_KEY = "spring.cloud.nacos.discovery.server-addr"; + + /** + * 第三方登录 验证密码/创建用户 都需要设置一个操作码 防止被恶意调用 + */ + public final static String THIRD_LOGIN_CODE = "third_login_code"; + + /** + * 第三方APP同步方向:本地 --> 第三方APP + */ + String THIRD_SYNC_TO_APP = "SYNC_TO_APP"; + /** + * 第三方APP同步方向:第三方APP --> 本地 + */ + String THIRD_SYNC_TO_LOCAL = "SYNC_TO_LOCAL"; + + /** 系统通告消息状态:0=未发布 */ + String ANNOUNCEMENT_SEND_STATUS_0 = "0"; + /** 系统通告消息状态:1=已发布 */ + String ANNOUNCEMENT_SEND_STATUS_1 = "1"; + /** 系统通告消息状态:2=已撤销 */ + String ANNOUNCEMENT_SEND_STATUS_2 = "2"; + + /**ONLINE 报表权限用 从request中获取地址栏后的参数*/ + String ONL_REP_URL_PARAM_STR="onlRepUrlParamStr"; + + /**POST请求*/ + String HTTP_POST = "POST"; + + /**PUT请求*/ + String HTTP_PUT = "PUT"; + + /**PATCH请求*/ + String HTTP_PATCH = "PATCH"; + + /**未知的*/ + String UNKNOWN = "unknown"; + + /**字符串http*/ + String STR_HTTP = "http"; + + /**String 类型的空值*/ + String STRING_NULL = "null"; + + /**java.util.Date 包*/ + String JAVA_UTIL_DATE = "java.util.Date"; + + /**.do*/ + String SPOT_DO = ".do"; + + + /**前端vue版本标识*/ + String VERSION="X-Version"; + + /**前端vue版本*/ + String VERSION_VUE3="vue3"; +} diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/enums/DataAshType.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/enums/DataAshType.java new file mode 100644 index 0000000..65f01e0 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/enums/DataAshType.java @@ -0,0 +1,30 @@ +package com.iailab.common.enums; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +/** + * @author PanZhibao + * @Description + * @createTime 2023年08月25日 18:03:00 + */ +@Getter +@AllArgsConstructor +public enum DataAshType { + YM(1, "7001"), JM(2, "2001"); + private Integer code; + private String desc; + + public static DataAshType getEumByCode(Integer code) { + if (code == null) { + return null; + } + + for (DataAshType statusEnum : DataAshType.values()) { + if (statusEnum.getCode().equals(code)) { + return statusEnum; + } + } + return null; + } +} diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/enums/DataTypeEnum.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/enums/DataTypeEnum.java new file mode 100644 index 0000000..335da30 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/enums/DataTypeEnum.java @@ -0,0 +1,24 @@ +package com.iailab.common.enums; + +/** + * @author PanZhibao + * @Description + * @createTime 2023年07月26日 15:06:00 + */ +public enum DataTypeEnum { + Float("Float"), + Int("Int"), + Short("Short"), + Boolean("Boolean"), + String("String"); + + private String value; + + DataTypeEnum(String value) { + this.value = value; + } + + public String value() { + return this.value; + } +} diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/enums/HttpMethodEnum.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/enums/HttpMethodEnum.java new file mode 100644 index 0000000..5191e0c --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/enums/HttpMethodEnum.java @@ -0,0 +1,21 @@ +package com.iailab.common.enums; + +/** + * @author PanZhibao + * @Description + * @createTime 2023年07月28日 11:28:00 + */ +public enum HttpMethodEnum { + GET("GET"), + POST("POST"); + + private String value; + + HttpMethodEnum(String value) { + this.value = value; + } + + public String value() { + return this.value; + } +} diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/enums/IsEnableEnum.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/enums/IsEnableEnum.java new file mode 100644 index 0000000..2a8f5fe --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/enums/IsEnableEnum.java @@ -0,0 +1,21 @@ +package com.iailab.common.enums; + +/** + * @author PanZhibao + * @Description + * @createTime 2023年07月17日 17:41:00 + */ +public enum IsEnableEnum { + DISABLE(0), // 手动 + ENABLE(1); //自动 + + private Integer value; + + IsEnableEnum(Integer value) { + this.value = value; + } + + public Integer value() { + return this.value; + } +} diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/enums/ModelTypeEnum.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/enums/ModelTypeEnum.java new file mode 100644 index 0000000..cb92880 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/enums/ModelTypeEnum.java @@ -0,0 +1,21 @@ +package com.iailab.common.enums; + +/** + * @author PanZhibao + * @Description + * @createTime 2023年07月20日 08:47:00 + */ +public enum ModelTypeEnum { + Python("Python"), + MATLAB("MATLAB"); + + private String value; + + ModelTypeEnum(String value) { + this.value = value; + } + + public String value() { + return this.value; + } +} diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/enums/PostalStatus.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/enums/PostalStatus.java new file mode 100644 index 0000000..8cb345a --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/enums/PostalStatus.java @@ -0,0 +1,23 @@ +package com.iailab.common.enums; + +/** + * 通讯状态 + * + * @author PanZhibao + * @Description + * @createTime 2023年05月22日 10:26:00 + */ +public enum PostalStatus { + ABNORMAL("0"), // 0 异常 + NORMAL("1"); //1 正常 + + private String value; + + PostalStatus(String value) { + this.value = value; + } + + public String value() { + return this.value; + } +} diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/enums/SourceTypeEnum.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/enums/SourceTypeEnum.java new file mode 100644 index 0000000..122ce50 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/enums/SourceTypeEnum.java @@ -0,0 +1,24 @@ +package com.iailab.common.enums; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +/** + * 数据源类型 + * + * @author PanZhibao + * @Description + * @createTime 2023年05月15日 14:01:00 + */ +@Getter +@AllArgsConstructor +public enum SourceTypeEnum { + + HTTP("HTTP"), + + OPCUA("OPCUA"), + + MODBUS("MODBUS"); + + private String code; +} diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/enums/SuperAdminEnum.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/enums/SuperAdminEnum.java new file mode 100644 index 0000000..4bb69ec --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/enums/SuperAdminEnum.java @@ -0,0 +1,30 @@ +/** + * Copyright (c) 2018 人人开源 All rights reserved. + * + * https://www.renren.io + * + * 版权所有,侵权必究! + */ + +package com.iailab.common.enums; + +/** + * 超级管理员枚举 + * + * @author Mark sunlightcs@gmail.com + * @since 1.0.0 + */ +public enum SuperAdminEnum { + YES(1), + NO(0); + + private int value; + + SuperAdminEnum(int value) { + this.value = value; + } + + public int value() { + return this.value; + } +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/enums/WatchDogStsEnum.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/enums/WatchDogStsEnum.java new file mode 100644 index 0000000..ace482d --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/enums/WatchDogStsEnum.java @@ -0,0 +1,21 @@ +package com.iailab.common.enums; + +/** + * @author PanZhibao + * @Description + * @createTime 2023年07月26日 16:33:00 + */ +public enum WatchDogStsEnum { + CONNECT_TRUE("1"), + CONNECT_FALSE("0"); + + private String value; + + WatchDogStsEnum(String value) { + this.value = value; + } + + public String value() { + return this.value; + } +} diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/exception/RRException.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/exception/RRException.java new file mode 100644 index 0000000..64788a7 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/exception/RRException.java @@ -0,0 +1,53 @@ +package com.iailab.common.exception; + +/** + * 自定义异常 + * + * @author Mark sunlightcs@gmail.com + */ +public class RRException extends RuntimeException { + private static final long serialVersionUID = 1L; + + private String msg; + private int code = 500; + + public RRException(String msg) { + super(msg); + this.msg = msg; + } + + public RRException(String msg, Throwable e) { + super(msg, e); + this.msg = msg; + } + + public RRException(String msg, int code) { + super(msg); + this.msg = msg; + this.code = code; + } + + public RRException(String msg, int code, Throwable e) { + super(msg, e); + this.msg = msg; + this.code = code; + } + + public String getMsg() { + return msg; + } + + public void setMsg(String msg) { + this.msg = msg; + } + + public int getCode() { + return code; + } + + public void setCode(int code) { + this.code = code; + } + + +} diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/interceptor/DataFilterInterceptor.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/interceptor/DataFilterInterceptor.java new file mode 100644 index 0000000..73fc509 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/interceptor/DataFilterInterceptor.java @@ -0,0 +1,89 @@ +///** +// * Copyright (c) 2018 人人开源 All rights reserved. +// * +// * https://www.renren.io +// * +// * 版权所有,侵权必究! +// */ +// +//package com.iailab.common.interceptor; +// +//import cn.hutool.core.util.StrUtil; +//import com.baomidou.mybatisplus.core.toolkit.PluginUtils; +//import com.baomidou.mybatisplus.extension.plugins.inner.InnerInterceptor; +//import net.sf.jsqlparser.JSQLParserException; +//import net.sf.jsqlparser.expression.Expression; +//import net.sf.jsqlparser.expression.StringValue; +//import net.sf.jsqlparser.expression.operators.conditional.AndExpression; +//import net.sf.jsqlparser.parser.CCJSqlParserUtil; +//import net.sf.jsqlparser.statement.select.PlainSelect; +//import net.sf.jsqlparser.statement.select.Select; +//import org.apache.ibatis.executor.Executor; +//import org.apache.ibatis.mapping.BoundSql; +//import org.apache.ibatis.mapping.MappedStatement; +//import org.apache.ibatis.session.ResultHandler; +//import org.apache.ibatis.session.RowBounds; +// +//import java.util.Map; +// +///** +// * 数据过滤 +// * +// * @author Mark sunlightcs@gmail.com +// */ +//public class DataFilterInterceptor implements InnerInterceptor { +// +// @Override +// public void beforeQuery(Executor executor, MappedStatement ms, Object parameter, RowBounds rowBounds, ResultHandler resultHandler, BoundSql boundSql) { +// DataScope scope = getDataScope(parameter); +// // 不进行数据过滤 +// if(scope == null || StrUtil.isBlank(scope.getSqlFilter())){ +// return; +// } +// +// // 拼接新SQL +// String buildSql = getSelect(boundSql.getSql(), scope); +// +// // 重写SQL +// PluginUtils.mpBoundSql(boundSql).sql(buildSql); +// } +// +// private DataScope getDataScope(Object parameter){ +// if (parameter == null){ +// return null; +// } +// +// // 判断参数里是否有DataScope对象 +// if (parameter instanceof Map) { +// Map<?, ?> parameterMap = (Map<?, ?>) parameter; +// for (Map.Entry entry : parameterMap.entrySet()) { +// if (entry.getValue() != null && entry.getValue() instanceof DataScope) { +// return (DataScope) entry.getValue(); +// } +// } +// } else if (parameter instanceof DataScope) { +// return (DataScope) parameter; +// } +// +// return null; +// } +// +// private String getSelect(String buildSql, DataScope scope){ +// try { +// Select select = (Select) CCJSqlParserUtil.parse(buildSql); +// PlainSelect plainSelect = (PlainSelect) select.getSelectBody(); +// +// Expression expression = plainSelect.getWhere(); +// if(expression == null){ +// plainSelect.setWhere(new StringValue(scope.getSqlFilter())); +// }else{ +// AndExpression andExpression = new AndExpression(expression, new StringValue(scope.getSqlFilter())); +// plainSelect.setWhere(andExpression); +// } +// +// return select.toString().replaceAll("'", ""); +// }catch (JSQLParserException e){ +// return buildSql; +// } +// } +//} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/interceptor/DataScope.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/interceptor/DataScope.java new file mode 100644 index 0000000..a2e5b49 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/interceptor/DataScope.java @@ -0,0 +1,36 @@ +///** +// * Copyright (c) 2018 人人开源 All rights reserved. +// * +// * https://www.renren.io +// * +// * 版权所有,侵权必究! +// */ +// +//package com.iailab.common.interceptor; +// +///** +// * 数据范围 +// * +// * @author Mark sunlightcs@gmail.com +// * @since 1.0.0 +// */ +//public class DataScope { +// private String sqlFilter; +// +// public DataScope(String sqlFilter) { +// this.sqlFilter = sqlFilter; +// } +// +// public String getSqlFilter() { +// return sqlFilter; +// } +// +// public void setSqlFilter(String sqlFilter) { +// this.sqlFilter = sqlFilter; +// } +// +// @Override +// public String toString() { +// return this.sqlFilter; +// } +//} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/utils/CommonUtils.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/utils/CommonUtils.java new file mode 100644 index 0000000..556f90e --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/utils/CommonUtils.java @@ -0,0 +1,61 @@ +package com.iailab.common.utils; + +import java.math.BigDecimal; +import java.text.SimpleDateFormat; +import java.util.Date; + +public class CommonUtils { + /** + *<p>获取当前日期<p> + *<p>格式yyyyMMdd<p> + */ + public static String getCurrDate(){ + Date date=new Date(); + SimpleDateFormat df1 = new SimpleDateFormat("yyyyMMdd"); + String tDate = df1.format(date); + return tDate; + } + + /** + *<p>获取当前时间<p> + *<p>格式yyyyMMddHHmmss<p> + */ + public static String getCurrDate2(){ + Date date=new Date(); + SimpleDateFormat df1 = new SimpleDateFormat("yyyyMMddHHmmss"); + String tDate = df1.format(date); + return tDate; + } + + /** + *<p>获取当前时间<p> + *<p>格式yyyy-MM-dd HH:mm:ss<p> + */ + public static String getCurrDate3(){ + Date date=new Date(); + SimpleDateFormat df1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + String tDate = df1.format(date); + return tDate; + } + + /** + * 由年月日时分秒+3位随机数 + * 生成流水号 + * @return + */ + public static Long Getnum(){ + String t = getCurrDate2(); + int x=(int)(Math.random()*900)+100; + String serial = t + x; + Long num = new Long(serial); + return num; + } + + public static BigDecimal getJSONValue(Object obj) { + if (obj == null) { + return null; + } + return new BigDecimal(obj.toString()); + } + +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/utils/Constant.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/utils/Constant.java new file mode 100644 index 0000000..03d628e --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/utils/Constant.java @@ -0,0 +1,119 @@ +package com.iailab.common.utils; + +/** + * 常量 + * + * @author Mark sunlightcs@gmail.com + */ +public class Constant { + /** 超级管理员ID */ + public static final String SUPER_ADMIN = "1"; + /** + * 当前页码 + */ + public static final String PAGE = "page"; + /** + * 每页显示记录数 + */ + public static final String LIMIT = "limit"; + /** + * 排序字段 + */ + public static final String ORDER_FIELD = "sidx"; + /** + * 排序方式 + */ + public static final String ORDER = "order"; + /** + * 升序 + */ + public static final String ASC = "asc"; + /** + * 菜单类型 + * + * @author chenshun + * @email sunlightcs@gmail.com + * @date 2016年11月15日 下午1:24:29 + */ + public enum MenuType { + /** + * 目录 + */ + CATALOG(0), + /** + * 菜单 + */ + MENU(1), + /** + * 按钮 + */ + BUTTON(2); + + private int value; + + MenuType(int value) { + this.value = value; + } + + public int getValue() { + return value; + } + } + + /** + * 定时任务状态 + * + * @author chenshun + * @email sunlightcs@gmail.com + * @date 2016年12月3日 上午12:07:22 + */ + public enum ScheduleStatus { + /** + * 正常 + */ + NORMAL(0), + /** + * 暂停 + */ + PAUSE(1); + + private int value; + + ScheduleStatus(int value) { + this.value = value; + } + + public int getValue() { + return value; + } + } + + /** + * 云服务商 + */ + public enum CloudService { + /** + * 七牛云 + */ + QINIU(1), + /** + * 阿里云 + */ + ALIYUN(2), + /** + * 腾讯云 + */ + QCLOUD(3); + + private int value; + + CloudService(int value) { + this.value = value; + } + + public int getValue() { + return value; + } + } + +} diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/utils/DateUtils.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/utils/DateUtils.java new file mode 100644 index 0000000..e7b265a --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/utils/DateUtils.java @@ -0,0 +1,302 @@ +/** + * Copyright (c) 2018 人人开源 All rights reserved. + * <p> + * https://www.renren.io + * <p> + * 版权所有,侵权必究! + */ + +package com.iailab.common.utils; + +import com.iailab.common.constant.BusinessConstant; +import org.apache.commons.lang3.StringUtils; +import org.joda.time.DateTime; +import org.joda.time.LocalDate; +import org.joda.time.format.DateTimeFormat; +import org.joda.time.format.DateTimeFormatter; + +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.*; + +/** + * 日期处理 + * + * @author Mark sunlightcs@gmail.com + */ +public class DateUtils { + /** 时间格式(yyyy-MM-dd) */ + 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"; + + public final static String DATE_TIME_PATTERN_MIN = "yyyy-MM-dd HH:mm"; + + public final static String TIME2_PATTERN = "mmss"; + + public final static String DATE_PATTERN_MON = "yyyy-MM"; + + public final static String DATE_PATTERN_YEAR = "yyyy-MM"; + + /** + * 日期格式化 日期格式为:yyyy-MM-dd + * @param date 日期 + * @return 返回yyyy-MM-dd格式日期 + */ + public static String format(Date date) { + return format(date, DATE_PATTERN); + } + + /** + * 日期格式化 日期格式为:yyyy-MM-dd + * @param date 日期 + * @param pattern 格式,如:DateUtils.DATE_TIME_PATTERN + * @return 返回yyyy-MM-dd格式日期 + */ + public static String format(Date date, String pattern) { + if (date != null) { + SimpleDateFormat df = new SimpleDateFormat(pattern); + return df.format(date); + } + return null; + } + + /** + * 日期解析 + * @param date 日期 + * @param pattern 格式,如:DateUtils.DATE_TIME_PATTERN + * @return 返回Date + */ + public static Date parse(String date, String pattern) { + try { + return new SimpleDateFormat(pattern).parse(date); + } catch (ParseException e) { + e.printStackTrace(); + } + return null; + } + + /** + * 字符串转换成日期 + * @param strDate 日期字符串 + * @param pattern 日期的格式,如:DateUtils.DATE_TIME_PATTERN + */ + public static Date stringToDate(String strDate, String pattern) { + if (StringUtils.isBlank(strDate)) { + return null; + } + + DateTimeFormatter fmt = DateTimeFormat.forPattern(pattern); + return fmt.parseLocalDateTime(strDate).toDate(); + } + + /** + * 根据周数,获取开始日期、结束日期 + * @param week 周期 0本周,-1上周,-2上上周,1下周,2下下周 + * @return 返回date[0]开始日期、date[1]结束日期 + */ + public static Date[] getWeekStartAndEnd(int week) { + DateTime dateTime = new DateTime(); + LocalDate date = new LocalDate(dateTime.plusWeeks(week)); + + date = date.dayOfWeek().withMinimumValue(); + Date beginDate = date.toDate(); + Date endDate = date.plusDays(6).toDate(); + return new Date[]{beginDate, endDate}; + } + + /** + * 对日期的【秒】进行加/减 + * + * @param date 日期 + * @param seconds 秒数,负数为减 + * @return 加/减几秒后的日期 + */ + public static Date addDateSeconds(Date date, int seconds) { + DateTime dateTime = new DateTime(date); + return dateTime.plusSeconds(seconds).toDate(); + } + + /** + * 对日期的【分钟】进行加/减 + * + * @param date 日期 + * @param minutes 分钟数,负数为减 + * @return 加/减几分钟后的日期 + */ + public static Date addDateMinutes(Date date, int minutes) { + DateTime dateTime = new DateTime(date); + return dateTime.plusMinutes(minutes).toDate(); + } + + /** + * 对日期的【小时】进行加/减 + * + * @param date 日期 + * @param hours 小时数,负数为减 + * @return 加/减几小时后的日期 + */ + public static Date addDateHours(Date date, int hours) { + DateTime dateTime = new DateTime(date); + return dateTime.plusHours(hours).toDate(); + } + + /** + * 对日期的【天】进行加/减 + * + * @param date 日期 + * @param days 天数,负数为减 + * @return 加/减几天后的日期 + */ + public static Date addDateDays(Date date, int days) { + DateTime dateTime = new DateTime(date); + return dateTime.plusDays(days).toDate(); + } + + /** + * 对日期的【周】进行加/减 + * + * @param date 日期 + * @param weeks 周数,负数为减 + * @return 加/减几周后的日期 + */ + public static Date addDateWeeks(Date date, int weeks) { + DateTime dateTime = new DateTime(date); + return dateTime.plusWeeks(weeks).toDate(); + } + + /** + * 对日期的【月】进行加/减 + * + * @param date 日期 + * @param months 月数,负数为减 + * @return 加/减几月后的日期 + */ + public static Date addDateMonths(Date date, int months) { + DateTime dateTime = new DateTime(date); + return dateTime.plusMonths(months).toDate(); + } + + /** + * 对日期的【年】进行加/减 + * + * @param date 日期 + * @param years 年数,负数为减 + * @return 加/减几年后的日期 + */ + public static Date addDateYears(Date date, int years) { + DateTime dateTime = new DateTime(date); + return dateTime.plusYears(years).toDate(); + } + + public static List<String> getDays(Date startDate, Date endDate) { + List<String> days = new ArrayList<String>(); + Calendar calendar = Calendar.getInstance(); + calendar.setTime(startDate); + + while (calendar.getTime().compareTo(endDate) < 0) { + days.add(DateUtils.format(calendar.getTime(), "yyyy-MM-dd")); + calendar.add(6, 1); + } + return days; + } + + public static Date getTime(Date date) { + Calendar calendar = Calendar.getInstance(); + calendar.setTime(date); + return calendar.getTime(); + } + + public static List<String> getYearTime(Date startDate, Date endDate) { + List<String> days = new ArrayList<String>(); + Calendar calendar = Calendar.getInstance(); + calendar.setTime(startDate); + + while (calendar.getTime().compareTo(endDate) <= 0) { + days.add(DateUtils.format(calendar.getTime(), DATE_PATTERN_YEAR)); + calendar.add(Calendar.YEAR, 1); + } + return days; + } + + public static List<String> getMonTime(Date startDate, Date endDate) { + List<String> days = new ArrayList<String>(); + Calendar calendar = Calendar.getInstance(); + calendar.setTime(startDate); + + while (calendar.getTime().compareTo(endDate) <= 0) { + days.add(DateUtils.format(calendar.getTime(), DATE_PATTERN_MON)); + calendar.add(Calendar.MONTH, 1); + } + return days; + } + + public static List<String> getDayTime(Date startDate, Date endDate) { + List<String> days = new ArrayList<String>(); + Calendar calendar = Calendar.getInstance(); + calendar.setTime(startDate); + + while (calendar.getTime().compareTo(endDate) <= 0) { + days.add(DateUtils.format(calendar.getTime(), DATE_PATTERN)); + calendar.add(Calendar.DAY_OF_YEAR, 1); + } + return days; + } + + public static List<String> getDayTime(Date startDate, Date endDate, int seconds) { + List<String> days = new ArrayList<String>(); + Calendar calendar = Calendar.getInstance(); + calendar.setTime(startDate); + while (calendar.getTime().compareTo(endDate) <= 0) { + days.add(DateUtils.format(calendar.getTime(), DATE_TIME_PATTERN)); + calendar.add(Calendar.SECOND, seconds); + } + return days; + } + + public static List<String> getClassTime(Date startDate, Date endDate) { + List<String> days = new ArrayList<String>(); + Calendar calendar = Calendar.getInstance(); + calendar.setTime(startDate); + while (calendar.getTime().compareTo(endDate) <= 0) { + days.add(DateUtils.format(calendar.getTime(), DATE_PATTERN) + " 0点班"); + days.add(DateUtils.format(calendar.getTime(), DATE_PATTERN) + " 8点班"); + days.add(DateUtils.format(calendar.getTime(), DATE_PATTERN) + " 16点班"); + calendar.add(Calendar.DAY_OF_YEAR, 1); + } + return days; + } + + public static Map<String, Date> getIntervalDate() { + Date tEndDate = getTime(addDateDays(new Date(), BusinessConstant.SCHEDULEDCLEANDAYS)); //当前时间前10天 + Date tStartDate = getTime(addDateHours(tEndDate, -1));//当前时间前10天前一个小时 + Map<String, Date> tMap = new HashMap<String, Date>(); + tMap.put("startdate", tStartDate); + tMap.put("enddate", tEndDate); + return tMap; + + } + + public static Map<String, Date> getIntervalDate(int days) { + Calendar calendar = Calendar.getInstance(); + calendar.add(Calendar.DAY_OF_YEAR, days); + calendar.set(Calendar.MILLISECOND, 0); + calendar.set(Calendar.SECOND, 0); + Date tEndDate = calendar.getTime(); + calendar.add(Calendar.HOUR_OF_DAY, -1); + Date tStartDate = calendar.getTime(); + Map<String, Date> tMap = new HashMap<String, Date>(2); + tMap.put("startdate", tStartDate); + tMap.put("enddate", tEndDate); + return tMap; + + } + + public static boolean isNotBlank(Date date) { + if (date == null) { + return false; + } + return true; + } + +} diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/utils/ExcelUtil.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/utils/ExcelUtil.java new file mode 100644 index 0000000..f3e73e7 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/utils/ExcelUtil.java @@ -0,0 +1,140 @@ +package com.iailab.common.utils; + +import org.apache.poi.hssf.usermodel.*; +import org.apache.poi.ss.usermodel.HorizontalAlignment; +import org.apache.poi.ss.usermodel.VerticalAlignment; +import org.apache.poi.ss.util.CellRangeAddress; + +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.io.OutputStream; +import java.lang.reflect.Field; +import java.util.List; +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * Excel 导出通用工具类 + * + * @author PanZhibao + * @date 2021年06月29日 9:06 + */ +public class ExcelUtil { + + /** + * 导出PointValueExcel + * + * @param sheetTitle + * @param title + * @param list + * @param response + * @return + */ + public static byte[] exportPointValue(String sheetTitle, String[] title, List<Object> list, HttpServletResponse response) { + + HSSFWorkbook wb = new HSSFWorkbook();//创建excel表 + HSSFSheet sheet = wb.createSheet(sheetTitle); + sheet.setDefaultColumnWidth(20);//设置默认行宽 + + //表头样式(加粗,水平居中,垂直居中) + HSSFCellStyle cellStyle = wb.createCellStyle(); + cellStyle.setAlignment(HorizontalAlignment.CENTER);//水平居中 + cellStyle.setVerticalAlignment(VerticalAlignment.CENTER);//垂直居中 + + HSSFFont fontStyle = wb.createFont(); + + cellStyle.setFont(fontStyle); + + //标题样式(加粗,垂直居中) + HSSFCellStyle cellStyle2 = wb.createCellStyle(); + cellStyle2.setVerticalAlignment(VerticalAlignment.CENTER);//垂直居中 + cellStyle2.setFont(fontStyle); + + //字段样式(垂直居中) + HSSFCellStyle cellStyle3 = wb.createCellStyle(); + cellStyle3.setVerticalAlignment(VerticalAlignment.CENTER);//垂直居中 + + //数字样式 + HSSFCellStyle cellStyle4 = wb.createCellStyle(); + HSSFDataFormat df = wb.createDataFormat(); // 此处设置数据格式 + cellStyle4.setVerticalAlignment(VerticalAlignment.CENTER);//垂直居中 + cellStyle4.setDataFormat(df.getFormat("#,##0.000000"));//设置数值类型格式为保留两位小数 + + //创建表头 + HSSFRow row = sheet.createRow(0); + //row.setHeightInPoints(20);//行高 + + HSSFCell cell = row.createCell(0); + cell.setCellValue(sheetTitle); + cell.setCellStyle(cellStyle); + + sheet.addMergedRegion(new CellRangeAddress(0,0,0,(title.length-1))); + + //创建标题 + HSSFRow rowTitle = sheet.createRow(1); + //rowTitle.setHeightInPoints(20); + + HSSFCell hc; + for (int i = 0; i < title.length; i++) { + hc = rowTitle.createCell(i); + hc.setCellValue(title[i]); + hc.setCellStyle(cellStyle2); + } + + byte result[] = null; + + try { + //创建表格数据 + Field[] fields; + int i = 2; + for (Object obj : list) { + fields = obj.getClass().getDeclaredFields(); + + HSSFRow rowBody = sheet.createRow(i); + //rowBody.setHeightInPoints(20); + + int j = 0; + for (Field f : fields) { + + f.setAccessible(true); + + Object va = f.get(obj); + if (null == va) { + va = ""; + } + + hc = rowBody.createCell(j); + + if (j == 0) { + hc.setCellValue(Double.parseDouble(va.toString())); + hc.setCellStyle(cellStyle4); + } else { + hc.setCellValue(va.toString()); + hc.setCellStyle(cellStyle3); + } + + + j++; + } + + i++; + } + + //设置Http响应头告诉浏览器下载这个附件 + response.setHeader("Content-Disposition", "attachment;Filename=" + System.currentTimeMillis() + ".xls"); + OutputStream outputStream = response.getOutputStream(); + wb.write(outputStream); + outputStream.close(); + return wb.getBytes(); + } catch (Exception ex) { + Logger.getLogger(ExcelUtil.class.getName()).log(Level.SEVERE, null, ex); + return result; + } finally{ + try { + wb.close(); + } catch (IOException ex) { + Logger.getLogger(ExcelUtil.class.getName()).log(Level.SEVERE, null, ex); + } + } + } +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/utils/ExcelUtils.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/utils/ExcelUtils.java new file mode 100644 index 0000000..e097b51 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/utils/ExcelUtils.java @@ -0,0 +1,77 @@ +///** +// * Copyright (c) 2018 人人开源 All rights reserved. +// * +// * https://www.renren.io +// * +// * 版权所有,侵权必究! +// */ +// +//package com.iailab.common.utils; +// +//import cn.afterturn.easypoi.excel.ExcelExportUtil; +//import cn.afterturn.easypoi.excel.entity.ExportParams; +//import org.apache.commons.lang3.StringUtils; +//import org.apache.poi.ss.usermodel.Workbook; +//import org.springframework.beans.BeanUtils; +// +//import javax.servlet.ServletOutputStream; +//import javax.servlet.http.HttpServletResponse; +//import java.io.IOException; +//import java.net.URLEncoder; +//import java.util.ArrayList; +//import java.util.Collection; +//import java.util.Date; +//import java.util.List; +// +///** +// * excel工具类 +// * +// * @author Mark sunlightcs@gmail.com +// */ +//public class ExcelUtils { +// +// /** +// * Excel导出 +// * +// * @param response response +// * @param fileName 文件名 +// * @param list 数据List +// * @param pojoClass 对象Class +// */ +// public static void exportExcel(HttpServletResponse response, String fileName, Collection<?> list, +// Class<?> pojoClass) throws IOException { +// if(StringUtils.isBlank(fileName)){ +// //当前日期 +// fileName = DateUtils.format(new Date()); +// } +// +// Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(), pojoClass, list); +// response.setCharacterEncoding("UTF-8"); +// response.setHeader("content-Type", "application/vnd.ms-excel"); +// response.setHeader("Content-Disposition", +// "attachment;filename=" + URLEncoder.encode(fileName, "UTF-8") + ".xls"); +// ServletOutputStream out = response.getOutputStream(); +// workbook.write(out); +// out.flush(); +// } +// +// /** +// * Excel导出,先sourceList转换成List<targetClass>,再导出 +// * +// * @param response response +// * @param fileName 文件名 +// * @param sourceList 原数据List +// * @param targetClass 目标对象Class +// */ +// public static void exportExcelToTarget(HttpServletResponse response, String fileName, Collection<?> sourceList, +// Class<?> targetClass) throws Exception { +// List targetList = new ArrayList<>(sourceList.size()); +// for(Object source : sourceList){ +// Object target = targetClass.newInstance(); +// BeanUtils.copyProperties(source, target); +// targetList.add(target); +// } +// +// exportExcel(response, fileName, targetList, targetClass); +// } +//} diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/utils/HttpRequest.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/utils/HttpRequest.java new file mode 100644 index 0000000..69f46bf --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/utils/HttpRequest.java @@ -0,0 +1,122 @@ +package com.iailab.common.utils; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.PrintWriter; +import java.net.URL; +import java.net.URLConnection; +import java.util.List; +import java.util.Map; + +/** + * @author PanZhibao + * @date 2021年06月03日 15:31 + */ +public class HttpRequest { + /** + * 向指定URL发送GET方法的请求 + * + * @param url 发送请求的URL + * @param param 请求参数,请求参数应该是 name1=value1&name2=value2 的形式。 + * @return URL 所代表远程资源的响应结果 + */ + public static String sendGet(String url, String param) { + String result = ""; + BufferedReader in = null; + try { + String urlNameString = url + "?" + param; + URL realUrl = new URL(urlNameString); + // 打开和URL之间的连接 + URLConnection connection = realUrl.openConnection(); + // 设置通用的请求属性 + connection.setRequestProperty("accept", "*/*"); + connection.setRequestProperty("connection", "Keep-Alive"); + connection.setRequestProperty("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)"); + + // 建立实际的连接 + connection.connect(); + // 获取所有响应头字段 + Map<String, List<String>> map = connection.getHeaderFields(); + // 遍历所有的响应头字段 + for (String key : map.keySet()) { + System.out.println(key + "--->" + map.get(key)); + } + // 定义 BufferedReader输入流来读取URL的响应 + in = new BufferedReader(new InputStreamReader(connection.getInputStream())); + String line; + while ((line = in.readLine()) != null) { + result += line; + } + } catch (Exception e) { + System.out.println("发送GET请求出现异常!" + e); + e.printStackTrace(); + } + // 使用finally块来关闭输入流 + finally { + try { + if (in != null) { + in.close(); + } + } catch (Exception e2) { + e2.printStackTrace(); + } + } + return result; + } + + /** + * 向指定 URL 发送POST方法的请求 + * + * @param url 发送请求的 URL + * @param param 请求参数,请求参数应该是 name1=value1&name2=value2 的形式。 + * @return 所代表远程资源的响应结果 + */ + public static String sendPost(String url, String param) { + PrintWriter out = null; + BufferedReader in = null; + String result = ""; + try { + URL realUrl = new URL(url); + // 打开和URL之间的连接 + URLConnection conn = realUrl.openConnection(); + // 设置通用的请求属性 + conn.setRequestProperty("accept", "*/*"); + conn.setRequestProperty("connection", "Keep-Alive"); + conn.setRequestProperty("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)"); + + // 发送POST请求必须设置如下两行 + conn.setDoOutput(true); + conn.setDoInput(true); + // 获取URLConnection对象对应的输出流 + out = new PrintWriter(conn.getOutputStream()); + // 发送请求参数 + out.print(param); + // flush输出流的缓冲 + out.flush(); + // 定义BufferedReader输入流来读取URL的响应 + in = new BufferedReader(new InputStreamReader(conn.getInputStream())); + String line; + while ((line = in.readLine()) != null) { + result += line; + } + } catch (Exception e) { + System.out.println("发送 POST 请求出现异常!" + e); + e.printStackTrace(); + } + //使用finally块来关闭输出流、输入流 + finally { + try { + if (out != null) { + out.close(); + } + if (in != null) { + in.close(); + } + } catch (IOException ex) { + ex.printStackTrace(); + } + } + return result; + } +} diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/utils/HttpsRequest.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/utils/HttpsRequest.java new file mode 100644 index 0000000..e442989 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/utils/HttpsRequest.java @@ -0,0 +1,322 @@ +package com.iailab.common.utils; + +import lombok.extern.slf4j.Slf4j; +import org.apache.http.Header; +import org.apache.http.HttpEntity; +import org.apache.http.HttpResponse; +import org.apache.http.client.methods.HttpGet; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.entity.StringEntity; +import org.apache.http.util.EntityUtils; +import org.springframework.stereotype.Component; +import org.springframework.util.CollectionUtils; + +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; +import java.util.Map; + +/** + * @author PanZhibao + * @date 2021年06月03日 16:40 + */ +@Slf4j +@Component +public class HttpsRequest { + + /** + * doGet + * + * @param url + * @param map + * @param charset + * @param token + * @return + */ + public String doGet(String url, Map<String, String> map, String charset, String token) { + org.apache.http.client.HttpClient httpClient = null; + HttpGet httpGet = null; + String result = null; + try { + httpClient = new SSLClient(); + StringBuilder sb = new StringBuilder(); + sb.append(url); + if (!CollectionUtils.isEmpty(map)) { + if ((url.indexOf("?") == -1)) { + sb.append("?"); + } else { + sb.append("&"); + } + map.forEach((k, v) -> { + try { + sb.append(k + "=" + URLEncoder.encode(v, charset) + "&"); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + }); + sb.append("t=" + System.currentTimeMillis()); + } + log.info("doGet,url=" + sb.toString()); + httpGet = new HttpGet(sb.toString()); + //设置参数 + httpGet.addHeader("Accept", "application/json"); + httpGet.addHeader("Content-Type", "application/json;charset=UTF-8"); + httpGet.addHeader("Authorization", token); + HttpResponse response = httpClient.execute(httpGet); + if (response != null) { + HttpEntity resEntity = response.getEntity(); + if (resEntity != null) { + result = EntityUtils.toString(resEntity, charset); + } + } + } catch (Exception ex) { + ex.printStackTrace(); + } + return result; + } + + /** + * doPost + * + * @param url + * @param map + * @param json + * @param charset + * @param token + * @return + */ + public String doPost(String url, Map<String, String> map, String json, String charset, String token) { + org.apache.http.client.HttpClient httpClient = null; + HttpPost httpPost = null; + String result = null; + try { + httpClient = new SSLClient(); + StringBuilder sb = new StringBuilder(); + sb.append(url); + if (!CollectionUtils.isEmpty(map)) { + sb.append("?"); + map.forEach((k, v) -> { + try { + sb.append(k + "=" + URLEncoder.encode(v, charset) + "&"); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + }); + sb.append("t=" + System.currentTimeMillis()); + } + httpPost = new HttpPost(sb.toString()); + //设置参数 + httpPost.addHeader("Accept", "application/json"); + httpPost.addHeader("Content-Type", "application/json;charset=UTF-8"); + httpPost.addHeader("token", token); + StringEntity stringEntity = new StringEntity(json); + stringEntity.setContentEncoding("UTF-8"); + stringEntity.setContentType("application/json"); + httpPost.setEntity(stringEntity); + HttpResponse response = httpClient.execute(httpPost); + if (response != null) { + HttpEntity resEntity = response.getEntity(); + if (resEntity != null) { + result = EntityUtils.toString(resEntity, charset); + } + } + } catch (Exception ex) { + ex.printStackTrace(); + } + return result; + } + /** + * doPost + * + * @param url + * @param map + * @param json + * @param charset + * @param token + * @return + */ + public String doPostAuthorization(String url, Map<String, String> map, String json, String charset, String token) { + org.apache.http.client.HttpClient httpClient = null; + HttpPost httpPost = null; + String result = null; + try { + httpClient = new SSLClient(); + StringBuilder sb = new StringBuilder(); + sb.append(url); + if (!CollectionUtils.isEmpty(map)) { + sb.append("?"); + map.forEach((k, v) -> { + try { + sb.append(k + "=" + URLEncoder.encode(v, charset) + "&"); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + }); + sb.append("t=" + System.currentTimeMillis()); + } + httpPost = new HttpPost(sb.toString()); + //设置参数 + httpPost.addHeader("Accept", "application/json"); + httpPost.addHeader("Content-Type", "application/json;charset=UTF-8"); + httpPost.addHeader("Authorization", "Bearer{" + token + "}"); + StringEntity stringEntity = new StringEntity(json); + stringEntity.setContentEncoding("UTF-8"); + stringEntity.setContentType("application/json"); + httpPost.setEntity(stringEntity); + HttpResponse response = httpClient.execute(httpPost); + if (response != null) { + HttpEntity resEntity = response.getEntity(); + if (resEntity != null) { + result = EntityUtils.toString(resEntity, charset); + } + } + } catch (Exception ex) { + ex.printStackTrace(); + } + return result; + } + + /** + * doPost + * + * @param url + * @param map + * @param json + * @param charset + * @return + */ + public String doPostToken(String url, Map<String, String> map, String json, String charset) { + org.apache.http.client.HttpClient httpClient = null; + HttpPost httpPost = null; + String result = null; + try { + httpClient = new SSLClient(); + StringBuilder sb = new StringBuilder(); + sb.append(url); + if (!CollectionUtils.isEmpty(map)) { + sb.append("?"); + map.forEach((k, v) -> { + try { + sb.append(k + "=" + URLEncoder.encode(v, charset) + "&"); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + }); + sb.append("t=" + System.currentTimeMillis()); + } + httpPost = new HttpPost(sb.toString()); + //设置参数 + httpPost.addHeader("Accept", "application/json"); + httpPost.addHeader("Content-Type", "application/json;charset=UTF-8"); + StringEntity stringEntity = new StringEntity(json); + stringEntity.setContentEncoding("UTF-8"); + stringEntity.setContentType("application/json"); + httpPost.setEntity(stringEntity); + HttpResponse response = httpClient.execute(httpPost); + if (response != null) { + Header[] resHeader = response.getHeaders("X-Auth-Tkn"); + if (resHeader != null) { + result = resHeader[0].getValue(); + } + } + } catch (Exception ex) { + ex.printStackTrace(); + } + return result; + } + + /** + * doGet + * + * @param url + * @param map + * @param charset + * @param token + * @param tMap + * @return + */ + public String doGetSDData(String url, Map<String, String> map, String charset, String token, Map<String, String> tMap) { + org.apache.http.client.HttpClient httpClient = null; + HttpGet httpGet = null; + String result = null; + try { + httpClient = new SSLClient(); + StringBuilder sb = new StringBuilder(); + sb.append(url); + if (!CollectionUtils.isEmpty(map)) { + sb.append("?"); + map.forEach((k, v) -> { + try { + sb.append(k + "=" + URLEncoder.encode(v, charset) + "&"); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + }); + sb.append("t=" + System.currentTimeMillis()); + } + log.info("doGet,url=" + sb.toString()); + httpGet = new HttpGet(sb.toString()); + //设置参数 + httpGet.addHeader("Content-Type", "application/json"); + httpGet.addHeader("X-Auth-Tkn", token); + httpGet.addHeader("X-Forwarded-OrgSet", tMap.get("X-Forwarded-OrgSet")); + httpGet.addHeader("X-Forwarded-PrId", tMap.get("X-Forwarded-PrId")); + httpGet.addHeader("X-Request-Id", tMap.get("X-Request-Id")); + HttpResponse response = httpClient.execute(httpGet); + if (response != null) { + HttpEntity resEntity = response.getEntity(); + if (resEntity != null) { + result = EntityUtils.toString(resEntity, charset); + } + } + } catch (Exception ex) { + ex.printStackTrace(); + } + return result; + } + + /** + * doGet + * + * @param url + * @param map + * @param charset + * @param token + * @return + */ + public String doGetDeviceList(String url, Map<String, String> map, String charset, String token) { + org.apache.http.client.HttpClient httpClient = null; + HttpGet httpGet = null; + String result = null; + try { + httpClient = new SSLClient(); + StringBuilder sb = new StringBuilder(); + sb.append(url); + if (!CollectionUtils.isEmpty(map)) { + sb.append("?"); + map.forEach((k, v) -> { + try { + sb.append(k + "=" + URLEncoder.encode(v, charset) + "&"); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + }); + sb.append("t=" + System.currentTimeMillis()); + } + log.info("doGet,url=" + sb.toString()); + httpGet = new HttpGet(sb.toString()); + //设置参数 + httpGet.addHeader("Content-Type", "application/json"); + httpGet.addHeader("X-App-Secret", token); + HttpResponse response = httpClient.execute(httpGet); + if (response != null) { + HttpEntity resEntity = response.getEntity(); + if (resEntity != null) { + result = EntityUtils.toString(resEntity, charset); + } + } + } catch (Exception ex) { + ex.printStackTrace(); + } + return result; + } +} diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/utils/MatlabUtil.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/utils/MatlabUtil.java new file mode 100644 index 0000000..6e3355a --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/utils/MatlabUtil.java @@ -0,0 +1,38 @@ +package com.iailab.common.utils; + +import cn.hutool.core.util.ReflectUtil; +import com.iailab.module.model.IAILModel; +import lombok.extern.slf4j.Slf4j; + +import java.lang.reflect.Method; +import java.util.HashMap; + +/** + * @author PanZhibao + * @Description + * @createTime 2023年01月11日 11:03:00 + */ +@Slf4j +public class MatlabUtil { + + public static HashMap<String, Object> execML(IAILModel model, Object[] paramValues) { + + //获取预测项的预测程序的类 + HashMap<String, Object> tMap = null; + try { +// double[][] realTimeData ={{12.1,5.1,1.45},{12.2,5.2,1.43},{12,3,5.3,1.425},{13.4,5.4,1.46},{14.5,5.5,1.48},{11.6,5.6,1.5},{12.7,5.7,1.47},{12.8,5.8,1.45},{12.9,5.9,1.43},{12.6,6,1.425},{12.1,5.1,1.46},{12.2,5.2,1.47} ,{12.3,5.3,1.5},{13.4,5.4,1.47},{14.5,5.5,1.45},{11.6,5.6,1.43},{12.7,5.7,1.425}, {12.8,5.8,1.46},{12.9,5.9,1.48},{12.6,6,1.5},{12.1,5.1,1.47},{12.2,5.2,1.45},{12.3,5.3,1.43},{13.4,5.4,1.425},{14.5,5.5,1.46},{11.6,5.6,1.47},{12.7,5.7,1.5},{12.8,5.8,1.47},{12.9,5.9,1.45},{12.6,6,1.45}}; + + Class<?> clazz = Class.forName(model.getClassName()); + + Method method = ReflectUtil.getPublicMethod(clazz, model.getMethodName(), model.getParamsArray()); + + //tMap = ReflectUtil.invoke(clazz.newInstance(), method, paramValues); + + tMap = (HashMap<String, Object>) method.invoke(clazz.newInstance(), paramValues); + } catch (Exception e) { + e.printStackTrace(); + log.error("exception message : {}", e.getMessage()); + } + return tMap; + } +} diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/utils/PythonUtil.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/utils/PythonUtil.java new file mode 100644 index 0000000..896d76b --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/utils/PythonUtil.java @@ -0,0 +1,49 @@ +package com.iailab.common.utils; + +import com.alibaba.fastjson.JSONObject; +import lombok.extern.slf4j.Slf4j; + +import java.io.BufferedReader; +import java.io.InputStreamReader; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +/** + * @author PanZhibao + * @Description + * @createTime 2023年01月11日 11:03:00 + */ +@Slf4j +public class PythonUtil { + + public static Map<String, Object> execPy(String[] command) throws Exception { + List<String> lines = new ArrayList<>(); + try { + Process proc = Runtime.getRuntime().exec(command); + BufferedReader in = new BufferedReader(new InputStreamReader(proc.getInputStream(), "GBK")); + String line = null; + + while ((line = in.readLine()) != null) { + log.info(line); + lines.add(line); + } + // 0表示成功,1表示远程调用失败,2表示python脚本出错 + int waitFor = proc.waitFor(); + log.info("waitFor=" + waitFor); + if (waitFor == 1) { + throw new Exception("远程调用失败"); + } else if (waitFor == 2) { + throw new Exception("python脚本出错"); + } else if (waitFor == 9009) { + throw new Exception("环境变量配置错误"); + } else if (waitFor != 0) { + throw new Exception("调用python失败"); + } + } catch (Exception ex) { + log.error("运行python异常!command=" + command.toString()); + throw ex; + } + return JSONObject.parseObject(lines.get(0)); + } +} diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/utils/SSLClient.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/utils/SSLClient.java new file mode 100644 index 0000000..a3c4051 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/utils/SSLClient.java @@ -0,0 +1,45 @@ +package com.iailab.common.utils; + + +import org.apache.http.conn.ClientConnectionManager; +import org.apache.http.conn.scheme.Scheme; +import org.apache.http.conn.scheme.SchemeRegistry; +import org.apache.http.conn.ssl.SSLSocketFactory; +import org.apache.http.impl.client.DefaultHttpClient; + +import javax.net.ssl.SSLContext; +import javax.net.ssl.TrustManager; +import javax.net.ssl.X509TrustManager; +import java.security.cert.CertificateException; +import java.security.cert.X509Certificate; + +/** + * @author PanZhibao + * @date 2021年06月03日 15:35 + */ +public class SSLClient extends DefaultHttpClient { + public SSLClient() throws Exception { + super(); + //传输协议需要根据自己的判断 + SSLContext ctx = SSLContext.getInstance("TLS"); + X509TrustManager tm = new X509TrustManager() { + @Override + public void checkClientTrusted(X509Certificate[] chain, String authType) throws CertificateException { + } + + @Override + public void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException { + } + + @Override + public X509Certificate[] getAcceptedIssuers() { + return null; + } + }; + ctx.init(null, new TrustManager[]{tm}, null); + SSLSocketFactory ssf = new SSLSocketFactory(ctx, SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER); + ClientConnectionManager ccm = this.getConnectionManager(); + SchemeRegistry sr = ccm.getSchemeRegistry(); + sr.register(new Scheme("https", 443, ssf)); + } +} diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/utils/UnzipUtils.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/utils/UnzipUtils.java new file mode 100644 index 0000000..2ed4454 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/utils/UnzipUtils.java @@ -0,0 +1,103 @@ +package com.iailab.common.utils; + +import java.io.*; +import java.nio.charset.Charset; +import java.util.Enumeration; +import java.util.zip.ZipEntry; +import java.util.zip.ZipFile; + +/** + * @author PanZhibao + * @Description + * @createTime 2023年05月25日 15:28:00 + */ +public class UnzipUtils { + /** + * 解压zip压缩文件到指定目录 + * + * @param zipPath zip压缩文件绝对路径 + * @param descDir 指定的解压目录 + */ + public static void unzipFile(String zipPath, String descDir) throws IOException { + try { + File zipFile = new File(zipPath); + if (!zipFile.exists()) { + throw new IOException("要解压的压缩文件不存在"); + } + File pathFile = new File(descDir); + if (!pathFile.exists()) { + pathFile.mkdirs(); + } + unzipWithStream(zipPath, descDir); + } catch (Exception e) { + throw new IOException(e); + } + } + + /** + * 解压 + * + * @param zipPath + * @param descDir + */ + public static void unzipWithStream(String zipPath, String descDir) { + try (ZipFile zipFile = new ZipFile(zipPath, Charset.forName("GBK"))) { + Enumeration e = zipFile.entries(); + while (e.hasMoreElements()) { + ZipEntry zipEntry = (ZipEntry)e.nextElement(); + String zipEntryNameStr = zipEntry.getName(); + String zipEntryName = zipEntryNameStr; + /*if (zipEntryNameStr.contains("/")) { + String str1 = zipEntryNameStr.substring(0, zipEntryNameStr.indexOf("/")); + zipEntryName = zipEntryNameStr.substring(str1.length() + 1); + }*/ + String outPath = (descDir + zipEntryName).replace("\\\\", "/"); + File outFile = new File(outPath.substring(0, outPath.lastIndexOf('/'))); + if (!outFile.exists()) { + outFile.mkdirs(); + } + if (new File(outPath).isDirectory()) { + continue; + } + writeFile(outPath, zipFile.getInputStream(zipEntry)); + } + System.out.println("======解压成功======="); + } catch (IOException e) { + System.out.println("压缩包处理异常,异常信息{}" + e); + } + } + + /** + * 将流写到文件中 + * + * @param filePath + * @param zipInputStream + */ + public static void writeFile(String filePath, InputStream zipInputStream) throws IOException { + try (OutputStream outputStream = new FileOutputStream(filePath)) { + byte[] bytes = new byte[4096]; + int len; + while ((len = zipInputStream.read(bytes)) != -1) { + outputStream.write(bytes, 0, len); + } + } catch (IOException ex) { + System.out.println("解压文件时,写出到文件出错"); + } finally { + zipInputStream.close(); + } + } + + /** + * 测试方法 + * + * @param args + * @throws IOException + */ + public static void test(String[] args) throws IOException { + + String zipPath = "D:/test/测试文件.zip"; + String descDir = "D:/test/解压/"; + + unzipFile(zipPath, descDir); + } +} diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/any/controller/AnyController.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/any/controller/AnyController.java new file mode 100644 index 0000000..9cf2bd6 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/any/controller/AnyController.java @@ -0,0 +1,195 @@ +package com.iailab.module.any.controller; + +import com.alibaba.fastjson.JSONObject; +import com.iailab.module.data.api.IFeignDataApi; +import com.iailab.module.data.dto.ApiIndValueDTO; +import com.iailab.module.data.dto.FeignQueryPointDTO; +import com.iailab.framework.common.page.PageData; +import com.iailab.common.utils.Constant; +import com.iailab.framework.common.pojo.CommonResult; +import com.iailab.module.any.dto.AnyAllEvaluationDTO; +import com.iailab.module.any.dto.AnyStoreReliabilityDTO; +import com.iailab.module.any.dto.AnySugLibDTO; +import com.iailab.module.any.dto.AnyTrendResultDTO; +import com.iailab.module.any.service.AnySugLibService; +import com.iailab.module.mcs.service.StModelResultService; +import com.iailab.module.model.handler.ModelHandler; +import com.iailab.module.param.service.PageParmService; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.Parameters; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import javax.annotation.Resource; +import org.springframework.util.CollectionUtils; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + + +import javax.annotation.Resource; +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年06月16日 + */ +@Slf4j +@RestController +@RequestMapping("any") +public class AnyController { + + @Resource + private PageParmService pageParmService; + + @Resource + private IFeignDataApi feignDataApi; + + @Resource + private ModelHandler modelHandler; + + @Resource + private AnySugLibService anySugLibService; + + @Resource + private StModelResultService stModelCommonResultService; + + private String MODEL_CODE_TREND = "trend_analysis"; + + /** + * 仓储可靠性分析结果(分页) + * + * @param params + * @return + */ + @GetMapping("store/page") + @Operation(summary = "分页") + @Parameters({ + @Parameter(name = Constant.PAGE, description = "当前页码,从1开始", required = true), + @Parameter(name = Constant.LIMIT, description = "每页显示记录数", required = true), + @Parameter(name = Constant.ORDER_FIELD, description = "排序字段"), + @Parameter(name = Constant.ORDER, description = "排序方式,可选值(asc、desc)") + }) + public CommonResult<PageData<AnyStoreReliabilityDTO>> storePage(@RequestParam Map<String, Object> params) { + PageData<AnyStoreReliabilityDTO> page = stModelCommonResultService.getStorePage(params); + + return new CommonResult<PageData<AnyStoreReliabilityDTO>>().setData(page); + } + + /** + * 综合评价分析结果(分页) + * + * @param params + * @return + */ + @GetMapping("evaluation/page") + @Operation(summary = "分页") + @Parameters({ + @Parameter(name = Constant.PAGE, description = "当前页码,从1开始", required = true), + @Parameter(name = Constant.LIMIT, description = "每页显示记录数", required = true), + @Parameter(name = Constant.ORDER_FIELD, description = "排序字段"), + @Parameter(name = Constant.ORDER, description = "排序方式,可选值(asc、desc)") + }) + public CommonResult<PageData<AnyAllEvaluationDTO>> evaluationPage(@RequestParam Map<String, Object> params) { + PageData<AnyAllEvaluationDTO> page = stModelCommonResultService.getAllEvaluationPage(params); + + return new CommonResult<PageData<AnyAllEvaluationDTO>>().setData(page); + } + + + /** + * 实时趋势分析 + * + * @param params + * @return + */ + @GetMapping("ind-item/trend") + public CommonResult<AnyTrendResultDTO> get(@RequestParam Map<String, Object> params) throws Exception { + AnyTrendResultDTO result = new AnyTrendResultDTO(); + String paramCode = params.get("paramCode").toString(); + String paramValue = pageParmService.selectValue(params.get("page").toString(), params.get("paramCode").toString()); + if (StringUtils.isBlank(paramValue)) { + return new CommonResult<AnyTrendResultDTO>(); + } + JSONObject paramObj = JSONObject.parseObject(paramValue); + result.setChartCode(paramObj.getString("chartCode")); + result.setLength(Integer.parseInt(paramObj.getString("length"))); + result.setUnit(paramObj.getString("unit")); + result.setMaxSlope(new BigDecimal(paramObj.getString("maxSlope"))); + result.setMinSlope(new BigDecimal(paramObj.getString("minSlope"))); + + FeignQueryPointDTO queryIndDto = new FeignQueryPointDTO(); + queryIndDto.setPointCode(result.getChartCode()); + queryIndDto.setStartDate(params.get("startDate") == null ? null : params.get("startDate").toString()); + queryIndDto.setEndDate(params.get("endDate") == null ? null : params.get("endDate").toString()); + List<ApiIndValueDTO> indValues = feignDataApi.queryIndItemValuesRange(queryIndDto); + result.setValueList(indValues); + result.setLength(indValues.size()); + List<ApiIndValueDTO> nv = indValues.stream().filter(dto -> {return dto.getDataValue() != null;}).collect(Collectors.toList()); + if (!CollectionUtils.isEmpty(nv)) { + result.setCurrentValue(nv.get(nv.size() - 1).getDataValue()); + } + Map<String, Object> mr = new HashMap<>(); + mr.put("mean_value", ""); + mr.put("max_value", ""); + mr.put("min_value", ""); + try { + List<double[][]> sampleDataList = new ArrayList<>(); + double[][] mix = new double[nv.size()][1]; + for (int i = 0; i < nv.size(); i++) { + mix[i][0] = nv.get(i).getDataValue().doubleValue(); + } + sampleDataList.add(mix); + mr = modelHandler.run(MODEL_CODE_TREND, sampleDataList); + String slopeFlag = mr.get("slope_flag").toString(); + switch (slopeFlag) { + case "1": + result.setTrend("上升"); + result.setIconClass("el-icon-top"); + result.setScopeValue("略有上升趋势"); + break; + case "2": + result.setTrend("上升"); + result.setIconClass("el-icon-top"); + result.setScopeValue("上升趋势过大"); + break; + case "-1": + result.setTrend("下降"); + result.setIconClass("el-icon-bottom"); + result.setScopeValue("略有下降趋势"); + break; + case "-2": + result.setTrend("下降"); + result.setIconClass("el-icon-bottom"); + result.setScopeValue("下降趋势过大"); + break; + default: + result.setTrend("平稳"); + result.setScopeValue("平稳"); + break; + + } + AnySugLibDTO sugDto = anySugLibService.get("trend", paramCode, slopeFlag); + if (sugDto != null) { + result.setDispatchSug(sugDto.getContent()); + } else { + result.setDispatchSug("生产正常,暂无建议"); + } + } catch (Exception ex) { + log.error("趋势模型运行异常"); + ex.printStackTrace(); + } + result.setTrendValue(mr); + return new CommonResult<AnyTrendResultDTO>().setData(result); + + } + + +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/any/controller/AnyProcCardController.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/any/controller/AnyProcCardController.java new file mode 100644 index 0000000..c9e4a00 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/any/controller/AnyProcCardController.java @@ -0,0 +1,34 @@ +package com.iailab.module.any.controller; + +import com.iailab.framework.common.pojo.CommonResult; +import com.iailab.module.any.dto.AnyProcCardDTO; +import com.iailab.module.any.service.AnyProcCardService; +import io.swagger.v3.oas.annotations.Operation; +import lombok.extern.slf4j.Slf4j; +import javax.annotation.Resource; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年06月25日 + */ +@Slf4j +@RestController +@RequestMapping("any/proc-card") +public class AnyProcCardController { + + @Resource + private AnyProcCardService anyProcCardService; + + @GetMapping("code/{code}") + @Operation(summary = "信息") + public CommonResult<AnyProcCardDTO> info(@PathVariable("code") String code) { + AnyProcCardDTO data = anyProcCardService.getByCode(code); + + return new CommonResult<AnyProcCardDTO>().setData(data); + } +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/any/controller/AnyProcReportController.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/any/controller/AnyProcReportController.java new file mode 100644 index 0000000..c1525c5 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/any/controller/AnyProcReportController.java @@ -0,0 +1,81 @@ +package com.iailab.module.any.controller; + +import com.iailab.common.annotation.LogOperation; +import com.iailab.framework.common.page.PageData; +import com.iailab.common.utils.Constant; +import com.iailab.framework.common.pojo.CommonResult; +import com.iailab.framework.common.util.validation.ValidationUtils; +import com.iailab.framework.common.validation.group.AddGroup; +import com.iailab.framework.common.validation.group.DefaultGroup; +import com.iailab.framework.common.validation.group.UpdateGroup; +import com.iailab.module.any.dto.AnyProcReportDTO; +import com.iailab.module.any.service.AnyProcReportService; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.Parameters; +import lombok.extern.slf4j.Slf4j; +import javax.annotation.Resource; +import org.springframework.web.bind.annotation.*; + + +import java.util.Map; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年06月25日 + */ +@Slf4j +@RestController +@RequestMapping("any/proc-report") +public class AnyProcReportController { + + @Resource + private AnyProcReportService anyProcReportService; + + @GetMapping("page") + @Operation(summary = "分页") + @Parameters({ + @Parameter(name = Constant.PAGE, description = "当前页码,从1开始", required = true), + @Parameter(name = Constant.LIMIT, description = "每页显示记录数", required = true), + @Parameter(name = Constant.ORDER_FIELD, description = "排序字段"), + @Parameter(name = Constant.ORDER, description = "排序方式,可选值(asc、desc)") + }) + public CommonResult<PageData<AnyProcReportDTO>> page(@RequestParam Map<String, Object> params) { + PageData<AnyProcReportDTO> page = anyProcReportService.page(params); + + return new CommonResult<PageData<AnyProcReportDTO>>().setData(page); + } + + @GetMapping("{id}") + @Operation(summary = "信息") + public CommonResult<AnyProcReportDTO> get(@PathVariable("id") String id) { + AnyProcReportDTO data = anyProcReportService.get(id); + + return new CommonResult<AnyProcReportDTO>().setData(data); + } + + @PostMapping + @Operation(summary = "保存") + @LogOperation("保存") + public CommonResult save(@RequestBody AnyProcReportDTO dto) { + //效验数据 + ValidationUtils.validate(dto, AddGroup.class, DefaultGroup.class); + + anyProcReportService.save(dto); + + return new CommonResult(); + } + + @PutMapping + @Operation(summary = "修改") + @LogOperation("修改") + public CommonResult update(@RequestBody AnyProcReportDTO dto) { + //效验数据 + ValidationUtils.validate(dto, UpdateGroup.class, DefaultGroup.class); + + anyProcReportService.update(dto); + + return new CommonResult(); + } +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/any/dao/AnyProcCardDao.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/any/dao/AnyProcCardDao.java new file mode 100644 index 0000000..6ce09b1 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/any/dao/AnyProcCardDao.java @@ -0,0 +1,14 @@ +package com.iailab.module.any.dao; + +import com.iailab.framework.common.dao.BaseDao; +import com.iailab.module.any.entity.AnyProcCardEntity; +import org.apache.ibatis.annotations.Mapper; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年06月25日 + */ +@Mapper +public interface AnyProcCardDao extends BaseDao<AnyProcCardEntity> { +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/any/dao/AnyProcParamDao.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/any/dao/AnyProcParamDao.java new file mode 100644 index 0000000..e9be450 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/any/dao/AnyProcParamDao.java @@ -0,0 +1,14 @@ +package com.iailab.module.any.dao; + +import com.iailab.framework.common.dao.BaseDao; +import com.iailab.module.any.entity.AnyProcParamEntity; +import org.apache.ibatis.annotations.Mapper; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年06月25日 + */ +@Mapper +public interface AnyProcParamDao extends BaseDao<AnyProcParamEntity> { +} diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/any/dao/AnyProcReportDao.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/any/dao/AnyProcReportDao.java new file mode 100644 index 0000000..a2303b0 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/any/dao/AnyProcReportDao.java @@ -0,0 +1,18 @@ +package com.iailab.module.any.dao; + +import com.iailab.framework.common.dao.BaseDao; +import com.iailab.module.any.entity.AnyProcReportEntity; +import org.apache.ibatis.annotations.Mapper; + +import java.util.List; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年06月25日 + */ +@Mapper +public interface AnyProcReportDao extends BaseDao<AnyProcReportEntity> { +// @DataSource("slave1") + void migrationProcReport(List<AnyProcReportEntity> list); +} diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/any/dao/AnyProcReportDetDao.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/any/dao/AnyProcReportDetDao.java new file mode 100644 index 0000000..6c93503 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/any/dao/AnyProcReportDetDao.java @@ -0,0 +1,18 @@ +package com.iailab.module.any.dao; + +import com.iailab.framework.common.dao.BaseDao; +import com.iailab.module.any.entity.AnyProcReportDetEntity; +import org.apache.ibatis.annotations.Mapper; + +import java.util.List; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年06月25日 + */ +@Mapper +public interface AnyProcReportDetDao extends BaseDao<AnyProcReportDetEntity> { +// @DataSource("slave1") + void migration(List<AnyProcReportDetEntity> list); +} diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/any/dao/AnySugLibDao.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/any/dao/AnySugLibDao.java new file mode 100644 index 0000000..96fa236 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/any/dao/AnySugLibDao.java @@ -0,0 +1,14 @@ +package com.iailab.module.any.dao; + +import com.iailab.framework.common.dao.BaseDao; +import com.iailab.module.any.entity.AnySugLibEntity; +import org.apache.ibatis.annotations.Mapper; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年06月16日 + */ +@Mapper +public interface AnySugLibDao extends BaseDao<AnySugLibEntity> { +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/any/dto/AnyAllEvaluationDTO.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/any/dto/AnyAllEvaluationDTO.java new file mode 100644 index 0000000..df6c366 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/any/dto/AnyAllEvaluationDTO.java @@ -0,0 +1,33 @@ +package com.iailab.module.any.dto; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.io.Serializable; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年06月18日 + */ +@Data +@Schema(name = "生产综合评价") +public class AnyAllEvaluationDTO implements Serializable { + private static final long serialVersionUID = 1L; + + private String dateTime; + + private String firstLevel; + + private String zongLevel; + + private String shuLiangFen; + + private String zhiLiangFen; + + private String shengChanFen; + + private String guoChengFen; + + private String guanLiFen; +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/any/dto/AnyProcCardDTO.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/any/dto/AnyProcCardDTO.java new file mode 100644 index 0000000..6473437 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/any/dto/AnyProcCardDTO.java @@ -0,0 +1,36 @@ +package com.iailab.module.any.dto; + +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年06月25日 + */ +@Data +@TableName("t_any_proc_card") +public class AnyProcCardDTO implements Serializable { + private static final long serialVersionUID = 1L; + + private String id; + + private String code; + + private String name; + + private String status; + + private String alarmInfo; + + private String suggest; + + private Date anyTime; + + private Integer sort; + + private Date createDate; +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/any/dto/AnyProcParamDTO.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/any/dto/AnyProcParamDTO.java new file mode 100644 index 0000000..a70259b --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/any/dto/AnyProcParamDTO.java @@ -0,0 +1,29 @@ +package com.iailab.module.any.dto; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.io.Serializable; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年06月25日 + */ +@Data +@Schema(name = "生产过程分析参数") +public class AnyProcParamDTO implements Serializable { + private static final long serialVersionUID = 1L; + + private String id; + + private String cardId; + + private String type; + + private String paramId; + + private Integer paramLength; + + private Integer sort; +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/any/dto/AnyProcReportDTO.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/any/dto/AnyProcReportDTO.java new file mode 100644 index 0000000..fa8731a --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/any/dto/AnyProcReportDTO.java @@ -0,0 +1,38 @@ +package com.iailab.module.any.dto; + +import com.iailab.common.dto.echarts.BarLineDTO; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; +import java.util.List; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年06月25日 + */ +@Data +@Schema(name = "分析报告") +public class AnyProcReportDTO implements Serializable { + private static final long serialVersionUID = 1L; + + private String id; + + private String procCode; + + private String procName; + + private String reportName; + + private Date reportDate; + + private String content; + + private Date createDate; + + private List<AnyProcReportDetDTO> detList; + + private List<BarLineDTO> chartList; +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/any/dto/AnyProcReportDetDTO.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/any/dto/AnyProcReportDetDTO.java new file mode 100644 index 0000000..d8d3bde --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/any/dto/AnyProcReportDetDTO.java @@ -0,0 +1,32 @@ +package com.iailab.module.any.dto; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年06月25日 + */ +@Data +@Schema(name = "分析报告详情") +public class AnyProcReportDetDTO implements Serializable { + private static final long serialVersionUID = 1L; + + private String id; + + private String reportId; + + private Integer sort; + + private String contentType; + + private String content; + + private String remark; + + private Date createDate; +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/any/dto/AnyStoreReliabilityDTO.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/any/dto/AnyStoreReliabilityDTO.java new file mode 100644 index 0000000..5e46ae1 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/any/dto/AnyStoreReliabilityDTO.java @@ -0,0 +1,23 @@ +package com.iailab.module.any.dto; + + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.io.Serializable; + +/** + * @author DongYukun + * @Description + * @createTime 2024年05月23日 + */ +@Data +@Schema(name = "仓储可靠性分析") +public class AnyStoreReliabilityDTO implements Serializable { + private static final long serialVersionUID = 1L; + + private String dateTime; + private String score; + private String analysis; + private String judgement; +} diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/any/dto/AnySugLibDTO.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/any/dto/AnySugLibDTO.java new file mode 100644 index 0000000..8000c35 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/any/dto/AnySugLibDTO.java @@ -0,0 +1,30 @@ +package com.iailab.module.any.dto; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年06月16日 + */ +@Data +@Schema(name = "分析建议库") +public class AnySugLibDTO implements Serializable { + private static final long serialVersionUID = 1L; + + private String id; + + private String type; + + private String code; + + private String cond; + + private String content; + + private Date createDate; +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/any/dto/AnyTrendResultDTO.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/any/dto/AnyTrendResultDTO.java new file mode 100644 index 0000000..ac8e958 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/any/dto/AnyTrendResultDTO.java @@ -0,0 +1,47 @@ +package com.iailab.module.any.dto; + +import com.iailab.module.data.dto.ApiIndValueDTO; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.io.Serializable; +import java.math.BigDecimal; +import java.util.List; +import java.util.Map; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年06月16日 + */ +@Data +@Schema(name = "趋势分析结果") +public class AnyTrendResultDTO implements Serializable { + private static final long serialVersionUID = 1L; + + private String chartCode; + + private String chartName; + + private Integer length; + + private String unit; + + private BigDecimal maxSlope; + + private BigDecimal minSlope; + + private BigDecimal currentValue; + + private String trend; + + private String iconClass; + + private String scopeValue; + + private Map<String, Object> trendValue; + + private String dispatchSug; + + private List<ApiIndValueDTO> valueList; +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/any/entity/AnyProcCardEntity.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/any/entity/AnyProcCardEntity.java new file mode 100644 index 0000000..e27b98d --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/any/entity/AnyProcCardEntity.java @@ -0,0 +1,39 @@ +package com.iailab.module.any.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年06月17日 + */ +@Data +@TableName("t_any_proc_card") +public class AnyProcCardEntity implements Serializable { + private static final long serialVersionUID = 1L; + + @TableId(type = IdType.ASSIGN_ID) + private String id; + + private String code; + + private String name; + + private String status; + + private String alarmInfo; + + private String suggest; + + private Date anyTime; + + private Integer sort; + + private Date createDate; +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/any/entity/AnyProcParamEntity.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/any/entity/AnyProcParamEntity.java new file mode 100644 index 0000000..a623e3c --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/any/entity/AnyProcParamEntity.java @@ -0,0 +1,34 @@ +package com.iailab.module.any.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; + +/** + * 生产过程分析参数 + * + * @author PanZhibao + * @Description + * @createTime 2024年06月17日 + */ +@Data +@TableName("t_any_proc_param") +public class AnyProcParamEntity implements Serializable { + private static final long serialVersionUID = 1L; + + @TableId(type = IdType.ASSIGN_ID) + private String id; + + private String cardId; + + private String type; + + private String paramId; + + private Integer paramLength; + + private Integer sort; +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/any/entity/AnyProcReportDetEntity.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/any/entity/AnyProcReportDetEntity.java new file mode 100644 index 0000000..a852860 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/any/entity/AnyProcReportDetEntity.java @@ -0,0 +1,35 @@ +package com.iailab.module.any.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年06月25日 + */ +@Data +@TableName("t_any_proc_report_det") +public class AnyProcReportDetEntity implements Serializable { + private static final long serialVersionUID = 1L; + + @TableId(type = IdType.ASSIGN_ID) + private String id; + + private String reportId; + + private Integer sort; + + private String contentType; + + private String content; + + private String remark; + + private Date createDate; +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/any/entity/AnyProcReportEntity.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/any/entity/AnyProcReportEntity.java new file mode 100644 index 0000000..4fce6cd --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/any/entity/AnyProcReportEntity.java @@ -0,0 +1,36 @@ +package com.iailab.module.any.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年06月17日 + */ +@Data +@TableName("t_any_proc_report") +public class AnyProcReportEntity implements Serializable { + private static final long serialVersionUID = 1L; + + @TableId(type = IdType.ASSIGN_ID) + private String id; + + private String procCode; + + private String procName; + + private String reportName; + + private Date reportDate; + + private String content; + + private Date createDate; + +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/any/entity/AnySugLibEntity.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/any/entity/AnySugLibEntity.java new file mode 100644 index 0000000..93d8d67 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/any/entity/AnySugLibEntity.java @@ -0,0 +1,33 @@ +package com.iailab.module.any.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年06月16日 + */ +@Data +@TableName("t_any_sug_lib") +public class AnySugLibEntity implements Serializable { + private static final long serialVersionUID = 1L; + + @TableId(type = IdType.ASSIGN_ID) + private String id; + + private String type; + + private String code; + + private String cond; + + private String content; + + private Date createDate; +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/any/service/AnyProcCardService.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/any/service/AnyProcCardService.java new file mode 100644 index 0000000..b922de4 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/any/service/AnyProcCardService.java @@ -0,0 +1,17 @@ +package com.iailab.module.any.service; + +import com.iailab.framework.common.service.BaseService; +import com.iailab.module.any.dto.AnyProcCardDTO; +import com.iailab.module.any.entity.AnyProcCardEntity; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年06月25日 + */ +public interface AnyProcCardService extends BaseService<AnyProcCardEntity> { + + AnyProcCardDTO getByCode(String code); + + void updateByCode(AnyProcCardDTO dto); +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/any/service/AnyProcParamService.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/any/service/AnyProcParamService.java new file mode 100644 index 0000000..8834f73 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/any/service/AnyProcParamService.java @@ -0,0 +1,17 @@ +package com.iailab.module.any.service; + +import com.iailab.framework.common.service.BaseService; +import com.iailab.module.any.dto.AnyProcParamDTO; +import com.iailab.module.any.entity.AnyProcParamEntity; + +import java.util.List; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年06月25日 + */ +public interface AnyProcParamService extends BaseService<AnyProcParamEntity> { + + List<AnyProcParamDTO> listByCardId(String cardId); +} diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/any/service/AnyProcReportDetService.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/any/service/AnyProcReportDetService.java new file mode 100644 index 0000000..01742dd --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/any/service/AnyProcReportDetService.java @@ -0,0 +1,24 @@ +package com.iailab.module.any.service; + +import com.iailab.framework.common.service.BaseService; +import com.iailab.module.any.dto.AnyProcReportDetDTO; +import com.iailab.module.any.entity.AnyProcReportDetEntity; + +import java.util.Date; +import java.util.List; +import java.util.Map; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年06月25日 + */ +public interface AnyProcReportDetService extends BaseService<AnyProcReportDetEntity> { + + + List<AnyProcReportDetDTO> listByReportId(String reportId); + + void save(AnyProcReportDetDTO dto); + + void migrationProcReportDet(Map<String, Date> tMap); +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/any/service/AnyProcReportService.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/any/service/AnyProcReportService.java new file mode 100644 index 0000000..ead78d8 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/any/service/AnyProcReportService.java @@ -0,0 +1,31 @@ +package com.iailab.module.any.service; + +import com.iailab.framework.common.page.PageData; +import com.iailab.framework.common.service.BaseService; +import com.iailab.module.any.dto.AnyProcReportDTO; +import com.iailab.module.any.entity.AnyProcReportEntity; + +import java.util.Date; +import java.util.Map; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年06月25日 + */ +public interface AnyProcReportService extends BaseService<AnyProcReportEntity> { + + PageData<AnyProcReportDTO> page(Map<String, Object> params); + + AnyProcReportDTO get(String id); + + void save(AnyProcReportDTO dto); + + void update(AnyProcReportDTO dto); + + void delete(Long[] ids); + + void saveReport(String cardCode, String reportName, String content, Date runTime); + + void migrationProcReport(Map<String, Date> tMap); +} diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/any/service/AnySugLibService.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/any/service/AnySugLibService.java new file mode 100644 index 0000000..4d519e9 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/any/service/AnySugLibService.java @@ -0,0 +1,15 @@ +package com.iailab.module.any.service; + +import com.iailab.framework.common.service.BaseService; +import com.iailab.module.any.dto.AnySugLibDTO; +import com.iailab.module.any.entity.AnySugLibEntity; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年06月16日 + */ +public interface AnySugLibService extends BaseService<AnySugLibEntity> { + + AnySugLibDTO get(String type, String code, String condition); +} diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/any/service/impl/AnyProcCardServiceImpl.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/any/service/impl/AnyProcCardServiceImpl.java new file mode 100644 index 0000000..0f41634 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/any/service/impl/AnyProcCardServiceImpl.java @@ -0,0 +1,38 @@ +package com.iailab.module.any.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.iailab.framework.common.service.impl.BaseServiceImpl; +import com.iailab.framework.common.util.object.ConvertUtils; +import com.iailab.module.any.dao.AnyProcCardDao; +import com.iailab.module.any.dto.AnyProcCardDTO; +import com.iailab.module.any.entity.AnyProcCardEntity; +import com.iailab.module.any.service.AnyProcCardService; +import org.springframework.stereotype.Service; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年06月25日 + */ +@Service +public class AnyProcCardServiceImpl extends BaseServiceImpl<AnyProcCardDao, AnyProcCardEntity> implements AnyProcCardService { + + @Override + public AnyProcCardDTO getByCode(String code) { + QueryWrapper<AnyProcCardEntity> wrapper = new QueryWrapper<>(); + wrapper.eq("code", code); + AnyProcCardEntity entity = baseDao.selectOne(wrapper); + return ConvertUtils.sourceToTarget(entity, AnyProcCardDTO.class); + + } + + @Override + public void updateByCode(AnyProcCardDTO dto) { + AnyProcCardEntity entity = new AnyProcCardEntity(); + entity.setAlarmInfo(dto.getAlarmInfo()); + entity.setAnyTime(dto.getAnyTime()); + QueryWrapper<AnyProcCardEntity> wrapper = new QueryWrapper<>(); + wrapper.eq("code", dto.getCode()); + baseDao.update(entity, wrapper); + } +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/any/service/impl/AnyProcParamServiceImpl.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/any/service/impl/AnyProcParamServiceImpl.java new file mode 100644 index 0000000..b280387 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/any/service/impl/AnyProcParamServiceImpl.java @@ -0,0 +1,31 @@ +package com.iailab.module.any.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.iailab.framework.common.service.impl.BaseServiceImpl; +import com.iailab.framework.common.util.object.ConvertUtils; +import com.iailab.module.any.dao.AnyProcParamDao; +import com.iailab.module.any.dto.AnyProcParamDTO; +import com.iailab.module.any.entity.AnyProcParamEntity; +import com.iailab.module.any.service.AnyProcParamService; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年06月25日 + */ +@Service +public class AnyProcParamServiceImpl extends BaseServiceImpl<AnyProcParamDao, AnyProcParamEntity> implements AnyProcParamService { + + @Override + public List<AnyProcParamDTO> listByCardId(String cardId) { + QueryWrapper<AnyProcParamEntity> wrapper = new QueryWrapper<>(); + wrapper.eq("card_id", cardId) + .orderByAsc("sort"); + List<AnyProcParamEntity> list = baseDao.selectList(wrapper); + return ConvertUtils.sourceToTarget(list, AnyProcParamDTO.class); + + } +} diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/any/service/impl/AnyProcReportDetServiceImpl.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/any/service/impl/AnyProcReportDetServiceImpl.java new file mode 100644 index 0000000..adbc06f --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/any/service/impl/AnyProcReportDetServiceImpl.java @@ -0,0 +1,64 @@ +package com.iailab.module.any.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.iailab.framework.common.service.impl.BaseServiceImpl; +import com.iailab.framework.common.util.object.ConvertUtils; +import com.iailab.common.utils.DateUtils; +import com.iailab.module.any.dao.AnyProcReportDetDao; +import com.iailab.module.any.dto.AnyProcReportDetDTO; +import com.iailab.module.any.entity.AnyProcReportDetEntity; +import com.iailab.module.any.service.AnyProcReportDetService; +import org.apache.commons.lang3.StringUtils; +import org.springframework.stereotype.Service; +import org.springframework.util.CollectionUtils; + +import java.util.Date; +import java.util.List; +import java.util.Map; +import java.util.UUID; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年06月25日 + */ +@Service +public class AnyProcReportDetServiceImpl extends BaseServiceImpl<AnyProcReportDetDao, AnyProcReportDetEntity> implements AnyProcReportDetService { + + @Override + public List<AnyProcReportDetDTO> listByReportId(String reportId) { + QueryWrapper<AnyProcReportDetEntity> wrapper = new QueryWrapper<>(); + wrapper.eq("report_id", reportId) + .orderByAsc("sort"); + List<AnyProcReportDetEntity> list = baseDao.selectList(wrapper); + return ConvertUtils.sourceToTarget(list, AnyProcReportDetDTO.class); + } + + @Override + public void save(AnyProcReportDetDTO dto) { + AnyProcReportDetEntity entity = ConvertUtils.sourceToTarget(dto, AnyProcReportDetEntity.class); + entity.setId(UUID.randomUUID().toString()); + entity.setCreateDate(new Date()); + insert(entity); + } + + @Override + public void migrationProcReportDet(Map<String, Date> tMap) { + List<AnyProcReportDetEntity> list = baseDao.selectList(getDateWrapper(tMap)); + if (CollectionUtils.isEmpty(list)){ + return; + } + baseDao.migration(list); + baseDao.delete(getDateWrapper(tMap)); + } + + public QueryWrapper<AnyProcReportDetEntity> getDateWrapper(Map<String, Date> params) { + String startDate = DateUtils.format(params.get("startdate"),DateUtils.DATE_TIME_PATTERN); + String endDate = DateUtils.format(params.get("enddate"),DateUtils.DATE_TIME_PATTERN); + + QueryWrapper<AnyProcReportDetEntity> wrapper = new QueryWrapper<>(); + wrapper.ge(StringUtils.isNotBlank(startDate), "create_date", startDate); + wrapper.le(StringUtils.isNotBlank(endDate), "create_date", endDate); + return wrapper; + } +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/any/service/impl/AnyProcReportServiceImpl.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/any/service/impl/AnyProcReportServiceImpl.java new file mode 100644 index 0000000..6450707 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/any/service/impl/AnyProcReportServiceImpl.java @@ -0,0 +1,216 @@ +package com.iailab.module.any.service.impl; + +import com.alibaba.fastjson.JSONArray; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.iailab.module.data.dto.ApiDataDTO; +import com.iailab.module.data.dto.FeignQueryPointDTO; +import com.iailab.framework.common.constant.Constant; +import com.iailab.common.dto.echarts.BarLineDTO; +import com.iailab.common.dto.echarts.SeriesItem; +import com.iailab.framework.common.page.PageData; +import com.iailab.framework.common.service.impl.BaseServiceImpl; +import com.iailab.framework.common.util.object.ConvertUtils; +import com.iailab.common.utils.DateUtils; +import com.iailab.module.data.dto.ApiDataPointDTO; +import com.iailab.module.data.api.IFeignDataApi; +import com.iailab.module.any.dao.AnyProcReportDao; +import com.iailab.module.any.dto.AnyProcCardDTO; +import com.iailab.module.any.dto.AnyProcParamDTO; +import com.iailab.module.any.dto.AnyProcReportDTO; +import com.iailab.module.any.dto.AnyProcReportDetDTO; +import com.iailab.module.any.entity.AnyProcReportEntity; +import com.iailab.module.any.service.AnyProcCardService; +import com.iailab.module.any.service.AnyProcParamService; +import com.iailab.module.any.service.AnyProcReportDetService; +import com.iailab.module.any.service.AnyProcReportService; +import org.apache.commons.lang3.StringUtils; +import javax.annotation.Resource; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.util.CollectionUtils; + +import java.math.BigDecimal; +import java.util.*; +import java.util.stream.Collectors; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年06月25日 + */ +@Service +public class AnyProcReportServiceImpl extends BaseServiceImpl<AnyProcReportDao, AnyProcReportEntity> implements AnyProcReportService { + @Resource + private AnyProcCardService anyProcCardService; + + @Resource + private AnyProcReportDetService anyProcReportDetService; + + @Resource + private AnyProcParamService anyProcParamService; + + @Resource + private IFeignDataApi feignDataApi; + + @Override + public PageData<AnyProcReportDTO> page(Map<String, Object> params) { + IPage<AnyProcReportEntity> page = baseDao.selectPage( + getPage(params, Constant.CREATE_DATE, false), + getWrapper(params) + ); + return getPageData(page, AnyProcReportDTO.class); + } + + private QueryWrapper<AnyProcReportEntity> getWrapper(Map<String, Object> params) { + String procCode = (String) params.get("procCode"); + String procName = (String) params.get("procName"); + String reportName = (String) params.get("reportName"); + String startTime = (String) params.get("startTime"); + String endTime = (String) params.get("endTime"); + QueryWrapper<AnyProcReportEntity> wrapper = new QueryWrapper<>(); + wrapper.eq(StringUtils.isNotBlank(procCode), "proc_code", procCode) + .like(StringUtils.isNotBlank(procName), "proc_name", procName) + .like(StringUtils.isNotBlank(reportName), "report_name", reportName) + .ge(StringUtils.isNotBlank(startTime), "start_time", startTime) + .le(StringUtils.isNotBlank(endTime), "end_time", endTime); + return wrapper; + } + + @Override + public AnyProcReportDTO get(String id) { + AnyProcReportEntity entity = baseDao.selectById(id); + AnyProcReportDTO result = ConvertUtils.sourceToTarget(entity, AnyProcReportDTO.class); + List<AnyProcReportDetDTO> detList = anyProcReportDetService.listByReportId(id); + + List<BarLineDTO> chartList = new ArrayList<>(); + if (CollectionUtils.isEmpty(detList)) { + result.setChartList(chartList); + return result; + } + List<String> ct = detList.stream().map(t -> { + return t.getContentType(); + }).distinct().collect(Collectors.toList()); + + Map<String, List<AnyProcReportDetDTO>> detGroup = detList.stream().collect(Collectors.groupingBy(AnyProcReportDetDTO::getContentType)); + + ct.forEach(k -> { + List<AnyProcReportDetDTO> v = detGroup.get(k); + BarLineDTO dto = new BarLineDTO(); + dto.setValueName(k); + List<String> legend = new ArrayList<>(); + List<SeriesItem> series = new ArrayList<>(); + List<String> categories = new ArrayList<>(); + v.forEach(item -> { + legend.add(item.getRemark()); + SeriesItem seriesItem = new SeriesItem(); + seriesItem.setName(item.getRemark()); + List<Object[]> sData = new ArrayList<>(); + if (StringUtils.isNotBlank(item.getContent())) { + sData = JSONArray.parseArray(item.getContent(), Object[].class); + } + seriesItem.setData(sData); + series.add(seriesItem); + }); + series.get(0).getData().forEach(item -> { + categories.add(item[0].toString()); + }); + dto.setLegend(legend); + dto.setSeries(series); + dto.setCategories(categories); + chartList.add(dto); + }); + + result.setChartList(chartList); + return result; + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void save(AnyProcReportDTO dto) { + AnyProcReportEntity entity = ConvertUtils.sourceToTarget(dto, AnyProcReportEntity.class); + entity.setId(UUID.randomUUID().toString()); + entity.setCreateDate(new Date()); + insert(entity); + + if (CollectionUtils.isEmpty(dto.getDetList())) { + return; + } + for (int i = 0; i < dto.getDetList().size(); i++) { + AnyProcReportDetDTO det = dto.getDetList().get(i); + det.setReportId(entity.getId()); + det.setSort(i); + anyProcReportDetService.save(det); + } + } + + @Override + public void update(AnyProcReportDTO dto) { + AnyProcReportEntity entity = ConvertUtils.sourceToTarget(dto, AnyProcReportEntity.class); + updateById(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void delete(Long[] ids) { + baseDao.deleteBatchIds(Arrays.asList(ids)); + } + + @Override + public void saveReport(String cardCode, String reportName, String content, Date runTime) { + AnyProcCardDTO card = anyProcCardService.getByCode(cardCode); + AnyProcReportDTO reportDTO = new AnyProcReportDTO(); + reportDTO.setProcCode(card.getCode()); + reportDTO.setProcName(card.getName()); + reportDTO.setReportName(reportName); + reportDTO.setReportDate(runTime); + reportDTO.setContent(content); + List<AnyProcReportDetDTO> detList = new ArrayList<>(); + List<AnyProcParamDTO> paramList = anyProcParamService.listByCardId(card.getId()); + for (int i = 0; i < paramList.size(); i++) { + AnyProcParamDTO paramItem = paramList.get(i); + FeignQueryPointDTO queryPointDTO = new FeignQueryPointDTO(); + Calendar calendar = Calendar.getInstance(); + calendar.setTime(runTime); + queryPointDTO.setEndTime(calendar.getTime()); + calendar.add(Calendar.MINUTE, paramItem.getParamLength() * -1); + queryPointDTO.setStartTime(calendar.getTime()); + queryPointDTO.setPointCode(paramItem.getParamId()); + List<ApiDataDTO> dataList = feignDataApi.queryPointValues(queryPointDTO); + ApiDataPointDTO pointDTO = feignDataApi.getPoint(paramItem.getParamId()); + if (CollectionUtils.isEmpty(dataList)) { + continue; + } + AnyProcReportDetDTO det = new AnyProcReportDetDTO(); + List<Object[]> dataCont = dataList.stream().map(t -> { + return new Object[]{DateUtils.format(t.getTimeStamp(), DateUtils.DATE_TIME_PATTERN_MIN), new BigDecimal(t.getDataValue()).setScale(4, BigDecimal.ROUND_HALF_UP)}; + }).collect(Collectors.toList()); + det.setContent(JSONArray.toJSONString(dataCont)); + det.setContentType(paramItem.getType()); + det.setRemark(pointDTO.getPointName()); + detList.add(det); + } + reportDTO.setDetList(detList); + this.save(reportDTO); + } + + @Override + public void migrationProcReport(Map<String, Date> tMap) { + List<AnyProcReportEntity> list = baseDao.selectList(getDateWrapper(tMap)); + if (CollectionUtils.isEmpty(list)){ + return; + } + baseDao.migrationProcReport(list); + baseDao.delete(getDateWrapper(tMap)); + } + + public QueryWrapper<AnyProcReportEntity> getDateWrapper(Map<String, Date> params) { + String startDate = DateUtils.format(params.get("startdate"),DateUtils.DATE_TIME_PATTERN); + String endDate = DateUtils.format(params.get("enddate"),DateUtils.DATE_TIME_PATTERN); + + QueryWrapper<AnyProcReportEntity> wrapper = new QueryWrapper<>(); + wrapper.ge(StringUtils.isNotBlank(startDate), "report_date", startDate); + wrapper.le(StringUtils.isNotBlank(endDate), "report_date", endDate); + return wrapper; + } +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/any/service/impl/AnySugLibServiceImpl.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/any/service/impl/AnySugLibServiceImpl.java new file mode 100644 index 0000000..29c2c86 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/any/service/impl/AnySugLibServiceImpl.java @@ -0,0 +1,30 @@ +package com.iailab.module.any.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.iailab.framework.common.service.impl.BaseServiceImpl; +import com.iailab.framework.common.util.object.ConvertUtils; +import com.iailab.module.any.dao.AnySugLibDao; +import com.iailab.module.any.dto.AnySugLibDTO; +import com.iailab.module.any.entity.AnySugLibEntity; +import com.iailab.module.any.service.AnySugLibService; +import org.springframework.stereotype.Service; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年06月16日 + */ +@Service +public class AnySugLibServiceImpl extends BaseServiceImpl<AnySugLibDao, AnySugLibEntity> implements AnySugLibService { + + @Override + public AnySugLibDTO get(String type, String code, String condition) { + QueryWrapper<AnySugLibEntity> wrapper = new QueryWrapper<>(); + wrapper.eq("type", type) + .eq("code", code) + .eq("cond", condition); + AnySugLibEntity entity = baseDao.selectOne(wrapper); + return ConvertUtils.sourceToTarget(entity, AnySugLibDTO.class); + + } +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/cons/dao/ConsDayDataDao.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/cons/dao/ConsDayDataDao.java new file mode 100644 index 0000000..5aaa558 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/cons/dao/ConsDayDataDao.java @@ -0,0 +1,14 @@ +package com.iailab.module.cons.dao; + +import com.iailab.framework.common.dao.BaseDao; +import com.iailab.module.cons.entity.ConsDayDataEntity; +import org.apache.ibatis.annotations.Mapper; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年05月27日 + */ +@Mapper +public interface ConsDayDataDao extends BaseDao<ConsDayDataEntity> { +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/cons/dto/ConsDayDataDTO.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/cons/dto/ConsDayDataDTO.java new file mode 100644 index 0000000..75dc073 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/cons/dto/ConsDayDataDTO.java @@ -0,0 +1,83 @@ +package com.iailab.module.cons.dto; + +import io.swagger.v3.oas.annotations.media.Schema; + +import lombok.Data; + +import java.io.Serializable; +import java.math.BigDecimal; +import java.util.Date; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年05月27日 + */ +@Data +@Schema(name = "日煤质趋势") +public class ConsDayDataDTO implements Serializable { + private static final long serialVersionUID = 1L; + + @Schema(name = "id") + private String id; + + @Schema(name = "月份") + private String monthstr; + + @Schema(name = "日期") + private String type; + + @Schema(name = "日期") + private String date; + + @Schema(name = "阴离子kg") + private BigDecimal anion; + + @Schema(name = "阴离子费用") + private BigDecimal anionFee; + + @Schema(name = "阴离子吨耗") + private BigDecimal anionPerCoal; + + @Schema(name = "阳离子kg") + private BigDecimal cation; + + @Schema(name = "阳离子费用") + private BigDecimal cationFee; + + @Schema(name = "阳离子吨耗") + private BigDecimal cationPerCoal; + + @Schema(name = "入洗原煤量吨") + private BigDecimal coalWeight; + + @Schema(name = "电耗kWh") + private BigDecimal elec; + + @Schema(name = "电耗费用") + private BigDecimal elecFee; + + @Schema(name = "电吨耗") + private BigDecimal elecPerCoal; + + @Schema(name = "介质kg") + private BigDecimal medium; + + @Schema(name = "介质费用") + private BigDecimal mediumFee; + + @Schema(name = "介质吨耗") + private BigDecimal mediumPerCoal; + + @Schema(name = "水耗m3") + private BigDecimal water; + + @Schema(name = "水费用") + private BigDecimal waterFee; + + @Schema(name = "水吨耗") + private BigDecimal waterPerCoal; + + @Schema(name = "创建日期") + private Date createDate; +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/cons/entity/ConsDayDataEntity.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/cons/entity/ConsDayDataEntity.java new file mode 100644 index 0000000..2b28222 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/cons/entity/ConsDayDataEntity.java @@ -0,0 +1,127 @@ +package com.iailab.module.cons.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.math.BigDecimal; +import java.util.Date; + +/** + * 日煤质趋势 + */ +@Data +@TableName("t_cons_day_data") +public class ConsDayDataEntity implements Serializable { + private static final long serialVersionUID = 1L; + + /** + * id + */ + @TableId(type = IdType.ASSIGN_UUID) + private String id; + + /** + * 月份 + */ + private String monthstr; + + /** + * 类型 + */ + private String type; + + /** + * 日期 + */ + private String date; + + /** + * 阴离子kg + */ + private BigDecimal anion; + + /** + * 阴离子费用 + */ + private BigDecimal anionFee; + + /** + * 阴离子吨耗 + */ + private BigDecimal anionPerCoal; + + /** + * 阳离子kg + */ + private BigDecimal cation; + + /** + * 阳离子费用 + */ + private BigDecimal cationFee; + + /** + * 阳离子吨耗 + */ + private BigDecimal cationPerCoal; + + /** + * 入洗原煤量吨 + */ + private BigDecimal coalWeight; + + /** + * 电耗kWh + */ + private BigDecimal elec; + + /** + * 电耗费用 + */ + private BigDecimal elecFee; + + /** + * 电吨耗 + */ + private BigDecimal elecPerCoal; + + /** + * 介质kg + */ + private BigDecimal medium; + + /** + * 介质费用 + */ + private BigDecimal mediumFee; + + /** + * 介质吨耗 + */ + private BigDecimal mediumPerCoal; + + /** + * 水耗m3 + */ + private BigDecimal water; + + /** + * 水费用 + */ + private BigDecimal waterFee; + + /** + * 水吨耗 + */ + private BigDecimal waterPerCoal; + + /** + * 创建日期 + */ + private Date createDate; + + +} diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/cons/service/ConsDayDataService.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/cons/service/ConsDayDataService.java new file mode 100644 index 0000000..d15b672 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/cons/service/ConsDayDataService.java @@ -0,0 +1,14 @@ +package com.iailab.module.cons.service; + +import com.iailab.framework.common.service.BaseService; +import com.iailab.module.cons.entity.ConsDayDataEntity; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年05月27日 + */ +public interface ConsDayDataService extends BaseService<ConsDayDataEntity> { + + void syncData(); +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/cons/service/impl/ConsDayDataServiceImpl.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/cons/service/impl/ConsDayDataServiceImpl.java new file mode 100644 index 0000000..da5cfee --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/cons/service/impl/ConsDayDataServiceImpl.java @@ -0,0 +1,80 @@ +package com.iailab.module.cons.service.impl; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.iailab.common.enums.CommonConstant; +import com.iailab.framework.common.service.impl.BaseServiceImpl; +import com.iailab.common.utils.DateUtils; +import com.iailab.common.utils.HttpsRequest; +import com.iailab.module.data.dto.FeignHttpApiDTO; +import com.iailab.module.data.api.IFeignDataApi; +import com.iailab.module.cons.dao.ConsDayDataDao; +import com.iailab.module.cons.entity.ConsDayDataEntity; +import com.iailab.module.cons.service.ConsDayDataService; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import javax.annotation.Resource; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.*; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年05月27日 + */ +@Slf4j +@Service +public class ConsDayDataServiceImpl extends BaseServiceImpl<ConsDayDataDao, ConsDayDataEntity> implements ConsDayDataService { + + private String HTTP_API_CODE = "Cons.MonthData"; + + @Resource + private IFeignDataApi feignDataApi; + + @Resource + private HttpsRequest httpsRequest; + + + @Override + @Transactional(rollbackFor = Exception.class) + public void syncData() { + Calendar calendar = Calendar.getInstance(); + calendar.add(Calendar.DAY_OF_YEAR, -1); + String monthstr = DateUtils.format(calendar.getTime(), DateUtils.DATE_PATTERN_MON); + String type = "主洗系统"; + FeignHttpApiDTO apiDTO = feignDataApi.getHttpApi(HTTP_API_CODE); + Map<String, String> params = new HashMap<>(); + params.put("monthstr", monthstr); + params.put("type", type); + String responseStr = httpsRequest.doGet(apiDTO.getUrl(), params, "utf-8", ""); + JSONObject responseObj = JSON.parseObject(responseStr); + if (!CommonConstant.STA_TRUE.equals(responseObj.get("sta").toString())) { + log.info("接口异常"); + } + JSONObject dataObject = responseObj.getJSONObject(CommonConstant.ZX_RES); + if (dataObject == null) { + return; + } + this.deleteByMonth(monthstr); + JSONArray rows = dataObject.getJSONArray("rows"); + List<ConsDayDataEntity> dataList = rows.toJavaList(ConsDayDataEntity.class); + + dataList.forEach(entity -> { + entity.setId(UUID.randomUUID().toString()); + entity.setMonthstr(monthstr); + entity.setType(type); + entity.setCreateDate(new Date()); + insert(entity); + }); + } + + private void deleteByMonth(String monthstr) { + QueryWrapper<ConsDayDataEntity> wrapper = new QueryWrapper<>(); + wrapper.eq(StringUtils.isNotBlank(monthstr), "monthstr", monthstr); + baseDao.delete(wrapper); + } +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/commons/HealthIndexTypeEnum.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/commons/HealthIndexTypeEnum.java new file mode 100644 index 0000000..aefa636 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/commons/HealthIndexTypeEnum.java @@ -0,0 +1,35 @@ +package com.iailab.module.device.commons; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +/** + * 设备健康评价指标类型 + * + * @author PanZhibao + * @Description + * @createTime 2024年06月30日 + */ +@Getter +@AllArgsConstructor +public enum HealthIndexTypeEnum { + runTime("runTime", "运行时长"), + elec("elec", "电流"), + temperature("temperature", "温度"), + flutter("flutter", "振动"); + private String code; + private String desc; + + public static HealthIndexTypeEnum getEumByCode(String code) { + if (code == null) { + return null; + } + + for (HealthIndexTypeEnum statusEnum : HealthIndexTypeEnum.values()) { + if (statusEnum.getCode().equals(code)) { + return statusEnum; + } + } + return null; + } +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/commons/HealthLevelEnum.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/commons/HealthLevelEnum.java new file mode 100644 index 0000000..2ee625c --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/commons/HealthLevelEnum.java @@ -0,0 +1,33 @@ +package com.iailab.module.device.commons; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年07月03日 + */ +@Getter +@AllArgsConstructor +public enum HealthLevelEnum { + + Level1("1", "健康"), + Level2("2", "良好"), + Level3("3", "不良"); + private String code; + private String desc; + + public static HealthLevelEnum getEumByCode(String code) { + if (code == null) { + return null; + } + + for (HealthLevelEnum statusEnum : HealthLevelEnum.values()) { + if (statusEnum.getCode().equals(code)) { + return statusEnum; + } + } + return null; + } +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/controller/DeviceAbnormalHistoryController.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/controller/DeviceAbnormalHistoryController.java new file mode 100644 index 0000000..c958afc --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/controller/DeviceAbnormalHistoryController.java @@ -0,0 +1,151 @@ +package com.iailab.module.device.controller; + +import com.iailab.common.annotation.LogOperation; +import com.iailab.common.constant.BusinessConstant; +import com.iailab.framework.common.constant.Constant; +import com.iailab.common.dto.IndexQueryDTO; +import com.iailab.common.dto.IndexStatisticDTO; +import com.iailab.common.dto.echarts.BarLineDTO; +import com.iailab.common.dto.echarts.SeriesItem; +import com.iailab.framework.common.page.PageData; +import com.iailab.common.utils.DateUtils; +import com.iailab.framework.common.pojo.CommonResult; + +import com.iailab.framework.common.util.validation.ValidationUtils; +import com.iailab.framework.common.validation.group.AddGroup; +import com.iailab.framework.common.validation.group.DefaultGroup; +import com.iailab.framework.common.validation.group.UpdateGroup; +import com.iailab.module.data.dto.ApiDataDTO; +import com.iailab.module.device.dto.DeviceAbnormalHistoryDTO; +import com.iailab.module.device.service.DeviceAbnormalHistoryService; +import io.swagger.v3.oas.annotations.tags.Tag; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.Parameters; +import javax.annotation.Resource; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.util.CollectionUtils; +import org.springframework.web.bind.annotation.*; + + +import java.util.*; +import java.util.stream.Collectors; + + +/** + * 异常设备历史表 + * + * @author lirm ${email} + * @since 1.0.0 2024-05-22 + */ +@RestController +@RequestMapping("device/device-abnormal-history") +@Tag(name = "异常设备历史表") +public class DeviceAbnormalHistoryController { + @Resource + private DeviceAbnormalHistoryService deviceAbnormalHistoryService; + + @GetMapping("page") + @Operation(summary = "分页") + @Parameters({ + @Parameter(name = Constant.PAGE, description = "当前页码,从1开始", required = true), + @Parameter(name = Constant.LIMIT, description = "每页显示记录数", required = true), + @Parameter(name = Constant.ORDER_FIELD, description = "排序字段"), + @Parameter(name = Constant.ORDER, description = "排序方式,可选值(asc、desc)") + }) + @PreAuthorize("@ss.hasPermission('device:deviceabnormalhistory:page')") + public CommonResult<PageData<DeviceAbnormalHistoryDTO>> page(@RequestParam Map<String, Object> params) { + PageData<DeviceAbnormalHistoryDTO> page = deviceAbnormalHistoryService.page(params); + + return new CommonResult<PageData<DeviceAbnormalHistoryDTO>>().setData(page); + } + + + @GetMapping("{id}") + @Operation(summary = "信息") + @PreAuthorize("@ss.hasPermission('device:deviceabnormalhistory:info')") + public CommonResult<DeviceAbnormalHistoryDTO> get(@PathVariable("id") Long id) { + DeviceAbnormalHistoryDTO data = deviceAbnormalHistoryService.get(id); + + return new CommonResult<DeviceAbnormalHistoryDTO>().setData(data); + } + + @PostMapping + @Operation(summary = "保存") + @LogOperation("保存") + @PreAuthorize("@ss.hasPermission('device:deviceabnormalhistory:save')") + public CommonResult save(@RequestBody DeviceAbnormalHistoryDTO dto) { + //效验数据 + ValidationUtils.validate(dto, AddGroup.class, DefaultGroup.class); + + deviceAbnormalHistoryService.save(dto); + + return new CommonResult(); + } + + @PutMapping + @Operation(summary = "修改") + @LogOperation("修改") + @PreAuthorize("@ss.hasPermission('device:deviceabnormalhistory:update')") + public CommonResult update(@RequestBody DeviceAbnormalHistoryDTO dto) { + //效验数据 + ValidationUtils.validate(dto, UpdateGroup.class, DefaultGroup.class); + + deviceAbnormalHistoryService.update(dto); + + return new CommonResult(); + } + + @DeleteMapping + @Operation(summary = "删除") + @LogOperation("删除") + @PreAuthorize("@ss.hasPermission('device:deviceabnormalhistory:delete')") + public CommonResult delete(@RequestBody Long[] ids) { + deviceAbnormalHistoryService.delete(ids); + + return new CommonResult(); + } + + @PostMapping("chart") + public CommonResult<BarLineDTO> chart(@RequestBody IndexQueryDTO dto) { + BarLineDTO data = new BarLineDTO(); + List<String> legend = new ArrayList<>(); + List<SeriesItem> series = new ArrayList<>(); + String endDateStr = dto.getEndDate() == null ? DateUtils.format(new Date(), "yyyy-MM-dd HH:mm:ss") : DateUtils.format(dto.getEndDate(), "yyyy-MM-dd HH:mm:ss"); + Date endDate = DateUtils.parse(endDateStr, "yyyy-MM-dd HH:mm"); + Date startDate = dto.getStartDate() == null ? DateUtils.getTime(DateUtils.addDateHours(endDate, -2)) : dto.getStartDate(); + List<String> categories = DateUtils.getDayTime(startDate, endDate, BusinessConstant.Granularity60); + List<DeviceAbnormalHistoryDTO> historyList = null; + List<ApiDataDTO> dataList = new ArrayList<>(); + List<IndexStatisticDTO> indexList; + + legend.add("设备异常总数"); + SeriesItem deviceItem = new SeriesItem(); + deviceItem.setName("设备异常总数"); + Map<String, Object> params = new HashMap<>(); + params.put("startDate", startDate); + params.put("endDate", endDate); + historyList = deviceAbnormalHistoryService.getlist(params); + if (!CollectionUtils.isEmpty(historyList)) { + historyList.forEach(item -> { + ApiDataDTO dataEntity = new ApiDataDTO(); + dataEntity.setTimeStamp(item.getCreateDate()); + dataEntity.setDataValue(item.getAbnormalCount()); + dataList.add(dataEntity); + }); + } + List<Object[]> deviceData = dataList.stream().map(item -> { + Object[] valueArray = new Object[]{item.getTimeStamp(), + item.getDataValue()}; + return valueArray; + }).collect(Collectors.toList()); + deviceItem.setData(deviceData); + + series.add(deviceItem); + data.setLegend(legend); + data.setCategories(categories); + data.setSeries(series); + return new CommonResult<BarLineDTO>().setData(data); + } + +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/controller/DeviceAccountController.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/controller/DeviceAccountController.java new file mode 100644 index 0000000..6e02bda --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/controller/DeviceAccountController.java @@ -0,0 +1,120 @@ +package com.iailab.module.device.controller; + +import com.iailab.common.annotation.LogOperation; +import com.iailab.framework.common.constant.Constant; +import com.iailab.framework.common.page.PageData; +import com.iailab.framework.common.pojo.CommonResult; + +import com.iailab.framework.common.util.validation.ValidationUtils; +import com.iailab.framework.common.validation.group.AddGroup; +import com.iailab.framework.common.validation.group.DefaultGroup; +import com.iailab.framework.common.validation.group.UpdateGroup; +import com.iailab.module.device.dto.DeviceAccountDTO; +import com.iailab.module.device.service.DeviceAccountService; +import io.swagger.v3.oas.annotations.tags.Tag; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.Parameters; +import javax.annotation.Resource; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.util.CollectionUtils; +import org.springframework.web.bind.annotation.*; + + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + + +/** + * 设备台账; + * + * @author lirm ${email} + * @since 1.0.0 2024-05-20 + */ +@RestController +@RequestMapping("device/device-account") +@Tag(name = "设备台账") +public class DeviceAccountController { + @Resource + private DeviceAccountService deviceAccountService; + + @GetMapping("page") + @Operation(summary = "分页") + @Parameters({ + @Parameter(name = Constant.PAGE, description = "当前页码,从1开始", required = true) , + @Parameter(name = Constant.LIMIT, description = "每页显示记录数", required = true) , + @Parameter(name = Constant.ORDER_FIELD, description = "排序字段") , + @Parameter(name = Constant.ORDER, description = "排序方式,可选值(asc、desc)") + }) + public CommonResult<PageData<DeviceAccountDTO>> page(@RequestParam Map<String, Object> params){ + PageData<DeviceAccountDTO> page = deviceAccountService.page(params); + + return new CommonResult<PageData<DeviceAccountDTO>>().setData(page); + } + + @GetMapping("list") + @Operation(summary = "设备健康评价") + public CommonResult<List<DeviceAccountDTO>> list(@RequestParam Map<String, Object> params) { + List<DeviceAccountDTO> list = deviceAccountService.list(params); + return new CommonResult<List<DeviceAccountDTO>>().setData(list); + } + + @GetMapping("log/abnormalList") + @Operation(summary = "设备健康评价") + public CommonResult<List<Object[]>> abnormalList(@RequestParam Map<String, Object> params) { + List<Object[]> data = new ArrayList<>(); + List<DeviceAccountDTO> list = deviceAccountService.list(params); + if (!CollectionUtils.isEmpty(list)) { + list.forEach(item -> { + if(item.getRunState().intValue() != 2){ + data.add(new Object[]{item.getDeviceName(), item.getUpdateDate(),item.getRemark()}); + } + }); + } + return new CommonResult<List<Object[]>>().setData(data); + } + + @GetMapping("{id}") + @Operation(summary = "信息") + @PreAuthorize("@ss.hasPermission('device:device-account:info')") + public CommonResult<DeviceAccountDTO> get(@PathVariable("id") Long id){ + DeviceAccountDTO data = deviceAccountService.get(id); + + return new CommonResult<DeviceAccountDTO>().setData(data); + } + + @PostMapping + @Operation(summary = "保存") + @LogOperation("保存") + @PreAuthorize("@ss.hasPermission('device:device-account:save')") + public CommonResult save(@RequestBody DeviceAccountDTO dto){ + //效验数据 + ValidationUtils.validate(dto, AddGroup.class, DefaultGroup.class); + + deviceAccountService.save(dto); + + return new CommonResult(); + } + + @PutMapping + @Operation(summary = "修改") + @LogOperation("修改") + @PreAuthorize("@ss.hasPermission('device:device-account:update')") + public CommonResult update(@RequestBody DeviceAccountDTO dto){ + //效验数据 + ValidationUtils.validate(dto, UpdateGroup.class, DefaultGroup.class); + deviceAccountService.update(dto); + return new CommonResult(); + } + + @DeleteMapping + @Operation(summary = "删除") + @LogOperation("删除") + @PreAuthorize("@ss.hasPermission('device:device-account:delete')") + public CommonResult delete(@RequestBody Long[] ids){ + deviceAccountService.delete(ids); + return new CommonResult(); + } + +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/controller/DeviceAccountHistoryController.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/controller/DeviceAccountHistoryController.java new file mode 100644 index 0000000..e52f189 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/controller/DeviceAccountHistoryController.java @@ -0,0 +1,97 @@ +package com.iailab.module.device.controller; + +import com.iailab.common.annotation.LogOperation; +import com.iailab.framework.common.constant.Constant; +import com.iailab.framework.common.page.PageData; +import com.iailab.framework.common.pojo.CommonResult; + +import com.iailab.framework.common.util.validation.ValidationUtils; +import com.iailab.framework.common.validation.group.AddGroup; +import com.iailab.framework.common.validation.group.DefaultGroup; +import com.iailab.framework.common.validation.group.UpdateGroup; +import com.iailab.module.device.dto.DeviceAccountHistoryDTO; +import com.iailab.module.device.service.DeviceAccountHistoryService; +import io.swagger.v3.oas.annotations.tags.Tag; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.Parameters; +import javax.annotation.Resource; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.*; + + +import java.util.Map; + + +/** + * 设备台账历史表 + * + * @author lirm ${email} + * @since 1.0.0 2024-05-27 + */ +@RestController +@RequestMapping("device/device-account-history") +@Tag(name = "设备台账历史表") +public class DeviceAccountHistoryController { + @Resource + private DeviceAccountHistoryService deviceAccountHistoryService; + + @GetMapping("page") + @Operation(summary = "分页") + @Parameters({ + @Parameter(name = Constant.PAGE, description = "当前页码,从1开始", required = true) , + @Parameter(name = Constant.LIMIT, description = "每页显示记录数", required = true) , + @Parameter(name = Constant.ORDER_FIELD, description = "排序字段") , + @Parameter(name = Constant.ORDER, description = "排序方式,可选值(asc、desc)") + }) + public CommonResult<PageData<DeviceAccountHistoryDTO>> page(@RequestParam Map<String, Object> params){ + PageData<DeviceAccountHistoryDTO> page = deviceAccountHistoryService.page(params); + + return new CommonResult<PageData<DeviceAccountHistoryDTO>>().setData(page); + } + + @GetMapping("{id}") + @Operation(summary = "信息") + @PreAuthorize("@ss.hasPermission('device:device-account-history:info')") + public CommonResult<DeviceAccountHistoryDTO> get(@PathVariable("id") Long id){ + DeviceAccountHistoryDTO data = deviceAccountHistoryService.get(id); + + return new CommonResult<DeviceAccountHistoryDTO>().setData(data); + } + + @PostMapping + @Operation(summary = "保存") + @LogOperation("保存") + @PreAuthorize("@ss.hasPermission('device:device-account-history:save')") + public CommonResult save(@RequestBody DeviceAccountHistoryDTO dto){ + //效验数据 + ValidationUtils.validate(dto, AddGroup.class, DefaultGroup.class); + + deviceAccountHistoryService.save(dto); + + return new CommonResult(); + } + + @PutMapping + @Operation(summary = "修改") + @LogOperation("修改") + @PreAuthorize("@ss.hasPermission('device:device-account-history:update')") + public CommonResult update(@RequestBody DeviceAccountHistoryDTO dto){ + //效验数据 + ValidationUtils.validate(dto, UpdateGroup.class, DefaultGroup.class); + + deviceAccountHistoryService.update(dto); + + return new CommonResult(); + } + + @DeleteMapping + @Operation(summary = "删除") + @LogOperation("删除") + @PreAuthorize("@ss.hasPermission('device:device-account-history:delete')") + public CommonResult delete(@RequestBody Long[] ids){ + deviceAccountHistoryService.delete(ids); + + return new CommonResult(); + } +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/controller/DeviceFaultController.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/controller/DeviceFaultController.java new file mode 100644 index 0000000..eb4a1a7 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/controller/DeviceFaultController.java @@ -0,0 +1,110 @@ +package com.iailab.module.device.controller; + +import com.iailab.common.annotation.LogOperation; +import com.iailab.framework.common.constant.Constant; +import com.iailab.framework.common.page.PageData; +import com.iailab.framework.common.pojo.CommonResult; + +import com.iailab.framework.common.util.validation.ValidationUtils; +import com.iailab.framework.common.validation.group.AddGroup; +import com.iailab.framework.common.validation.group.DefaultGroup; +import com.iailab.framework.common.validation.group.UpdateGroup; +import com.iailab.module.device.dto.DeviceFaultDTO; +import com.iailab.module.device.service.DeviceFaultService; +import io.swagger.v3.oas.annotations.tags.Tag; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.Parameters; +import javax.annotation.Resource; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.*; + + +import java.util.Map; + + +/** + * 设备故障库; + * + * @author lirm ${email} + * @since 1.0.0 2024-05-23 + */ +@RestController +@RequestMapping("device/device-fault") +@Tag(name = "设备故障库;") +public class DeviceFaultController { + @Resource + private DeviceFaultService deviceFaultService; + + @GetMapping("page") + @Operation(summary = "分页") + @Parameters({ + @Parameter(name = Constant.PAGE, description = "当前页码,从1开始", required = true) , + @Parameter(name = Constant.LIMIT, description = "每页显示记录数", required = true) , + @Parameter(name = Constant.ORDER_FIELD, description = "排序字段") , + @Parameter(name = Constant.ORDER, description = "排序方式,可选值(asc、desc)") + }) +// @AutoDict + @PreAuthorize("@ss.hasPermission('device:device-fault:page')") + public CommonResult<PageData<DeviceFaultDTO>> page(@RequestParam Map<String, Object> params){ + PageData<DeviceFaultDTO> page = deviceFaultService.page(params); + + return new CommonResult<PageData<DeviceFaultDTO>>().setData(page); + } + + @GetMapping("{id}") + @Operation(summary = "信息") + @PreAuthorize("@ss.hasPermission('device:device-fault:info')") + public CommonResult<DeviceFaultDTO> get(@PathVariable("id") Long id){ + DeviceFaultDTO data = deviceFaultService.get(id); + + return new CommonResult<DeviceFaultDTO>().setData(data); + } + + @PostMapping + @Operation(summary = "保存") + @LogOperation("保存") + @PreAuthorize("@ss.hasPermission('device:device-fault:save')") + public CommonResult save(@RequestBody DeviceFaultDTO dto){ + //效验数据 + ValidationUtils.validate(dto, AddGroup.class, DefaultGroup.class); + + deviceFaultService.save(dto); + + return new CommonResult(); + } + + @PutMapping + @Operation(summary = "修改") + @LogOperation("修改") + @PreAuthorize("@ss.hasPermission('device:device-fault:update')") + public CommonResult update(@RequestBody DeviceFaultDTO dto){ + //效验数据 + ValidationUtils.validate(dto, UpdateGroup.class, DefaultGroup.class); + + deviceFaultService.update(dto); + + return new CommonResult(); + } + + @DeleteMapping + @Operation(summary = "删除") + @LogOperation("删除") + @PreAuthorize("@ss.hasPermission('device:device-fault:delete')") + public CommonResult delete(@RequestBody Long[] ids){ + deviceFaultService.delete(ids); + + return new CommonResult(); + } + +// @GetMapping("export") +// @Operation(summary = "导出") +// @LogOperation("导出") +// @PreAuthorize("@ss.hasPermission('device:device-fault:export')") +// public void export(@RequestParam Map<String, Object> params, HttpServletResponse response) throws Exception { +// List<DeviceFaultDTO> list = deviceFaultService.list(params); +// +// ExcelUtils.exportExcelToTarget(response, null, list, DeviceFaultExcel.class); +// } + +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/controller/DeviceHealthAlarmController.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/controller/DeviceHealthAlarmController.java new file mode 100644 index 0000000..4fbe8bb --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/controller/DeviceHealthAlarmController.java @@ -0,0 +1,52 @@ +package com.iailab.module.device.controller; + +import com.iailab.framework.common.constant.Constant; +import com.iailab.framework.common.page.PageData; +import com.iailab.framework.common.pojo.CommonResult; +import com.iailab.module.device.dto.DeviceHealthAlarmDTO; +import com.iailab.module.device.service.DeviceHealthAlarmService; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.Parameters; +import io.swagger.v3.oas.annotations.tags.Tag; +import javax.annotation.Resource; +import org.springframework.web.bind.annotation.*; + +import java.util.Map; + +/** + * @description: 设备健康故障记录 + * @author: dzd + * @date: 2024/7/5 13:45 + **/ +@RestController +@RequestMapping("device/health-alarm") +@Tag(name = "设备健康故障记录") +public class DeviceHealthAlarmController { + + @Resource + private DeviceHealthAlarmService deviceHealthAlarmService; + + @GetMapping("page") + @Operation(summary = "分页") + @Parameters({ + @Parameter(name = Constant.PAGE, description = "当前页码,从1开始", required = true), + @Parameter(name = Constant.LIMIT, description = "每页显示记录数", required = true), + @Parameter(name = Constant.ORDER_FIELD, description = "排序字段"), + @Parameter(name = Constant.ORDER, description = "排序方式,可选值(asc、desc)") + }) + public CommonResult<PageData<DeviceHealthAlarmDTO>> page(@RequestParam Map<String, Object> params) { + PageData<DeviceHealthAlarmDTO> page = deviceHealthAlarmService.page(params); + + return new CommonResult<PageData<DeviceHealthAlarmDTO>>().setData(page); + } + + @GetMapping("{id}") + @Operation(summary = "信息") + public CommonResult<DeviceHealthAlarmDTO> get(@PathVariable("id") String id) { + DeviceHealthAlarmDTO data = deviceHealthAlarmService.get(id); + return new CommonResult<DeviceHealthAlarmDTO>().setData(data); + } + + +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/controller/DeviceHealthEvaluateController.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/controller/DeviceHealthEvaluateController.java new file mode 100644 index 0000000..95b02c8 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/controller/DeviceHealthEvaluateController.java @@ -0,0 +1,98 @@ +package com.iailab.module.device.controller; + +import com.iailab.framework.common.constant.Constant; +import com.iailab.framework.common.page.PageData; +import com.iailab.framework.common.pojo.CommonResult; +import com.iailab.framework.common.util.validation.ValidationUtils; +import com.iailab.framework.common.validation.group.AddGroup; +import com.iailab.framework.common.validation.group.DefaultGroup; +import com.iailab.framework.common.validation.group.UpdateGroup; +import com.iailab.module.device.dto.DeviceHealthEvaluateDTO; +import com.iailab.module.device.service.DeviceHealthEvaluateService; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.Parameters; +import io.swagger.v3.oas.annotations.tags.Tag; +import javax.annotation.Resource; +import org.springframework.web.bind.annotation.*; + +import java.util.Map; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年06月29日 + */ +@RestController +@RequestMapping("device/health-evaluate") +@Tag(name = "设备健康评价") +public class DeviceHealthEvaluateController { + + @Resource + private DeviceHealthEvaluateService deviceHealthEvaluateService; + + @GetMapping("page") + @Operation(summary = "分页") + @Parameters({ + @Parameter(name = Constant.PAGE, description = "当前页码,从1开始", required = true), + @Parameter(name = Constant.LIMIT, description = "每页显示记录数", required = true), + @Parameter(name = Constant.ORDER_FIELD, description = "排序字段"), + @Parameter(name = Constant.ORDER, description = "排序方式,可选值(asc、desc)") + }) + public CommonResult<PageData<DeviceHealthEvaluateDTO>> page(@RequestParam Map<String, Object> params) { + PageData<DeviceHealthEvaluateDTO> page = deviceHealthEvaluateService.page(params); + + return new CommonResult<PageData<DeviceHealthEvaluateDTO>>().setData(page); + } + + @GetMapping("{id}") + @Operation(summary = "信息") + public CommonResult<DeviceHealthEvaluateDTO> get(@PathVariable("id") String id) { + DeviceHealthEvaluateDTO data = deviceHealthEvaluateService.get(id); + + return new CommonResult<DeviceHealthEvaluateDTO>().setData(data); + } + + @PostMapping + @Operation(summary = "保存") + public CommonResult save(@RequestBody DeviceHealthEvaluateDTO dto) { + //效验数据 + ValidationUtils.validate(dto, AddGroup.class, DefaultGroup.class); + + deviceHealthEvaluateService.save(dto); + + return new CommonResult(); + } + + @PutMapping + @Operation(summary = "修改") + public CommonResult update(@RequestBody DeviceHealthEvaluateDTO dto) { + //效验数据 + ValidationUtils.validate(dto, UpdateGroup.class, DefaultGroup.class); + + deviceHealthEvaluateService.update(dto); + + return new CommonResult(); + } + + @DeleteMapping + @Operation(summary = "删除") + public CommonResult delete(@RequestBody String[] ids) { + deviceHealthEvaluateService.delete(ids); + return new CommonResult(); + } + + @PutMapping("/enable") + @Operation(summary = "启用") + public CommonResult enable(@RequestBody String[] ids) { + deviceHealthEvaluateService.enableByIds(ids); + return new CommonResult(); + } + + @PutMapping("/disable") + @Operation(summary = "禁用") + public CommonResult disable(@RequestBody String[] ids) { + deviceHealthEvaluateService.disableByIds(ids); + return new CommonResult(); + } +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/controller/DeviceHealthReportController.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/controller/DeviceHealthReportController.java new file mode 100644 index 0000000..be2409c --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/controller/DeviceHealthReportController.java @@ -0,0 +1,54 @@ +package com.iailab.module.device.controller; + +import com.iailab.framework.common.constant.Constant; +import com.iailab.framework.common.page.PageData; +import com.iailab.framework.common.pojo.CommonResult; +import com.iailab.module.device.dto.DeviceHealthReportDTO; +import com.iailab.module.device.service.DeviceHealthReportService; +import io.swagger.v3.oas.annotations.tags.Tag; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.Parameters; +import javax.annotation.Resource; +import org.springframework.web.bind.annotation.*; + + +import java.util.Map; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年06月28日 + */ +@RestController +@RequestMapping("device/health-report") +@Tag(name = "设备健康评价报告;") +public class DeviceHealthReportController { + + @Resource + private DeviceHealthReportService deviceHealthReportService; + + @GetMapping("page") + @Operation(summary = "分页") + @Parameters({ + @Parameter(name = Constant.PAGE, description = "当前页码,从1开始", required = true), + @Parameter(name = Constant.LIMIT, description = "每页显示记录数", required = true), + @Parameter(name = Constant.ORDER_FIELD, description = "排序字段"), + @Parameter(name = Constant.ORDER, description = "排序方式,可选值(asc、desc)") + }) + public CommonResult<PageData<DeviceHealthReportDTO>> page(@RequestParam Map<String, Object> params) { + PageData<DeviceHealthReportDTO> page = deviceHealthReportService.page(params); + + return new CommonResult<PageData<DeviceHealthReportDTO>>().setData(page); + } + + @GetMapping("{id}") + @Operation(summary = "信息") + public CommonResult<DeviceHealthReportDTO> get(@PathVariable("id") String id) { + DeviceHealthReportDTO data = deviceHealthReportService.get(id); + + return new CommonResult<DeviceHealthReportDTO>().setData(data); + } + + +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/controller/DeviceHealthStateController.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/controller/DeviceHealthStateController.java new file mode 100644 index 0000000..f3a2e8a --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/controller/DeviceHealthStateController.java @@ -0,0 +1,157 @@ +package com.iailab.module.device.controller; + +import com.iailab.common.annotation.LogOperation; +import com.iailab.framework.common.constant.Constant; +import com.iailab.framework.common.page.PageData; +import com.iailab.framework.common.pojo.CommonResult; + +import com.iailab.framework.common.util.validation.ValidationUtils; +import com.iailab.framework.common.validation.group.AddGroup; +import com.iailab.framework.common.validation.group.DefaultGroup; +import com.iailab.framework.common.validation.group.UpdateGroup; +import com.iailab.module.device.dto.DeviceCurrentRateDTO; +import com.iailab.module.device.dto.DeviceHealthStateDTO; +import com.iailab.module.device.dto.DeviceStatCountDTO; +import com.iailab.module.device.entity.DeviceStatUsageEntity; +import com.iailab.module.device.service.DeviceStatCountService; +import com.iailab.module.device.service.DeviceHealthStateService; +import com.iailab.module.device.service.DeviceStatUsageService; +import io.swagger.v3.oas.annotations.tags.Tag; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.Parameters; +import javax.annotation.Resource; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.*; + + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + + +/** + * 设备健康状态表 + * + * @author lirm ${email} + * @since 1.0.0 2024-05-22 + */ +@RestController +@RequestMapping("device/device-health-state") +@Tag(name = "设备健康状态表") +public class DeviceHealthStateController { + @Resource + private DeviceHealthStateService deviceHealthStateService; + @Resource + private DeviceStatCountService deviceStatCountService; + @Resource + private DeviceStatUsageService deviceStatUsageService; + + @GetMapping("page") + @Operation(summary = "分页") + @Parameters({ + @Parameter(name = Constant.PAGE, description = "当前页码,从1开始", required = true) , + @Parameter(name = Constant.LIMIT, description = "每页显示记录数", required = true) , + @Parameter(name = Constant.ORDER_FIELD, description = "排序字段") , + @Parameter(name = Constant.ORDER, description = "排序方式,可选值(asc、desc)") + }) + @PreAuthorize("@ss.hasPermission('device:device-health-state:page')") + public CommonResult<PageData<DeviceHealthStateDTO>> page(@RequestParam Map<String, Object> params){ + PageData<DeviceHealthStateDTO> page = deviceHealthStateService.page(params); + + return new CommonResult<PageData<DeviceHealthStateDTO>>().setData(page); + } + + + @GetMapping("list") + public CommonResult<DeviceHealthStateDTO> list(){ + List<DeviceHealthStateDTO> list = deviceHealthStateService.list(new HashMap<>()); + DeviceHealthStateDTO deviceHealthStateDTO = list.get(0); + return new CommonResult<DeviceHealthStateDTO>().setData(deviceHealthStateDTO); + } + + @GetMapping("{id}") + @Operation(summary = "信息") + @PreAuthorize("@ss.hasPermission('device:device-health-state:info')") + public CommonResult<DeviceHealthStateDTO> get(@PathVariable("id") Long id){ + DeviceHealthStateDTO data = deviceHealthStateService.get(id); + + return new CommonResult<DeviceHealthStateDTO>().setData(data); + } + + @PostMapping + @Operation(summary = "保存") + @LogOperation("保存") + @PreAuthorize("@ss.hasPermission('device:device-health-state:save')") + public CommonResult save(@RequestBody DeviceHealthStateDTO dto){ + //效验数据 + ValidationUtils.validate(dto, AddGroup.class, DefaultGroup.class); + + deviceHealthStateService.save(dto); + + return new CommonResult(); + } + + @PutMapping + @Operation(summary = "修改") + @LogOperation("修改") + @PreAuthorize("@ss.hasPermission('device:device-health-state:update')") + public CommonResult update(@RequestBody DeviceHealthStateDTO dto){ + //效验数据 + ValidationUtils.validate(dto, UpdateGroup.class, DefaultGroup.class); + + deviceHealthStateService.update(dto); + + return new CommonResult(); + } + + @DeleteMapping + @Operation(summary = "删除") + @LogOperation("删除") + @PreAuthorize("@ss.hasPermission('device:device-health-state:delete')") + public CommonResult delete(@RequestBody Long[] ids){ + deviceHealthStateService.delete(ids); + return new CommonResult(); + } + +// @GetMapping("export") +// @Operation(summary = "导出") +// @LogOperation("导出") +// @PreAuthorize("@ss.hasPermission('device:device-health-state:export')") +// public void export(@RequestParam Map<String, Object> params, HttpServletResponse response) throws Exception { +// List<DeviceHealthStateDTO> list = deviceHealthStateService.list(params); +// ExcelUtils.exportExcelToTarget(response, null, list, DeviceHealthStateExcel.class); +// } + + @GetMapping("getDeviceCurrentRate") + @Operation(summary = "实时获取设备率") + @LogOperation("实时获取设备率") + public CommonResult<DeviceCurrentRateDTO> getDeviceCurrentRate() { + DeviceCurrentRateDTO deviceCurrentRate = deviceStatUsageService.getDeviceCurrentRate(); + return new CommonResult<DeviceCurrentRateDTO>().setData(deviceCurrentRate); + } + + @GetMapping("getDeviceStatCount") + @Operation(summary = "实时获取设备数量统计") + @LogOperation("实时获取设备数量统计") + public CommonResult<DeviceStatCountDTO> getDeviceStatCount() { + DeviceStatCountDTO deviceStatistics = deviceStatCountService.getDeviceStatCount(); + return new CommonResult<DeviceStatCountDTO>().setData(deviceStatistics); + } + + @PostMapping("getDeviceStatCountHistory") + @Operation(summary = "获取设备数量统计历史") + @LogOperation("获取设备数量统计历史") + public CommonResult<List<DeviceStatCountDTO>> getDeviceStatCountHistory(@RequestBody Map<String, Object> params) { + List<DeviceStatCountDTO> list = deviceStatCountService.getHistory(params); + return new CommonResult<List<DeviceStatCountDTO>>().setData(list); + } + + @PostMapping("getDeviceRunTimeHistory") + @Operation(summary = "获取设备历史使用时间") + @LogOperation("获取设备历史使用时间") + public CommonResult<List<DeviceStatUsageEntity>> getDeviceRunTimeHistory(@RequestBody Map<String, Object> params) { + List<DeviceStatUsageEntity> list = deviceStatUsageService.list(params); + return new CommonResult<List<DeviceStatUsageEntity>>().setData(list); + } +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/controller/DeviceInfoController.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/controller/DeviceInfoController.java new file mode 100644 index 0000000..89ddc77 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/controller/DeviceInfoController.java @@ -0,0 +1,211 @@ +package com.iailab.module.device.controller; + +import com.iailab.common.annotation.LogOperation; +import com.iailab.common.constant.BusinessConstant; +import com.iailab.framework.common.constant.Constant; +import com.iailab.framework.common.page.PageData; +import com.iailab.framework.common.pojo.CommonResult; +import com.iailab.framework.common.util.validation.ValidationUtils; +import com.iailab.framework.common.validation.group.AddGroup; +import com.iailab.framework.common.validation.group.DefaultGroup; +import com.iailab.framework.common.validation.group.UpdateGroup; +import com.iailab.module.device.dto.DeviceIndexDTO; +import com.iailab.module.device.dto.DeviceInfoDTO; +import com.iailab.module.device.entity.DeviceIndexEntity; +import com.iailab.module.device.entity.DeviceInfoEntity; +import com.iailab.module.device.entity.DeviceStatNewnessEntity; +import com.iailab.module.device.entity.DeviceStatUsageEntity; +import com.iailab.module.device.service.DeviceIndexService; +import com.iailab.module.device.service.DeviceInfoService; +import com.iailab.module.device.service.DeviceStatNewnessService; +import com.iailab.module.device.service.DeviceStatUsageService; +import io.swagger.v3.oas.annotations.tags.Tag; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.Parameters; +import javax.annotation.Resource; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.util.CollectionUtils; +import org.springframework.web.bind.annotation.*; + + +import java.math.BigDecimal; +import java.math.RoundingMode; +import java.util.Date; +import java.util.List; +import java.util.Map; + + +/** + * 中选设备信息表 + * + * @author lirm ${email} + * @since 1.0.0 2024-05-28 + */ +@RestController +@RequestMapping("device/device-info") +@Tag(name = "中选设备信息表") +public class DeviceInfoController { + @Resource + private DeviceInfoService deviceInfoService; + @Resource + private DeviceIndexService deviceIndexService; + @Resource + private DeviceStatUsageService deviceStatUsageService; + @Resource + private DeviceStatNewnessService deviceStatNewnessService; + + @GetMapping("page") + @Operation(summary = "分页") + @Parameters({ + @Parameter(name = Constant.PAGE, description = "当前页码,从1开始", required = true) , + @Parameter(name = Constant.LIMIT, description = "每页显示记录数", required = true) , + @Parameter(name = Constant.ORDER_FIELD, description = "排序字段") , + @Parameter(name = Constant.ORDER, description = "排序方式,可选值(asc、desc)") + }) + public CommonResult<PageData<DeviceInfoDTO>> page(@RequestParam Map<String, Object> params){ + PageData<DeviceInfoDTO> page = deviceInfoService.page(params); + if (!CollectionUtils.isEmpty(page.getList())) { + page.getList().forEach(item -> { + item.setChildren(deviceInfoService.getchildrenList(item.getId())); + }); + } + + return new CommonResult<PageData<DeviceInfoDTO>>().setData(page); + } + + @GetMapping("{id}") + @Operation(summary = "信息") + public CommonResult<DeviceInfoDTO> get(@PathVariable("id") String id){ + DeviceInfoDTO data = deviceInfoService.get(id); + + List<DeviceIndexDTO> tIndexList= deviceIndexService.getByDeviceId(id); + data.setDeviceIndexList(tIndexList); + + return new CommonResult<DeviceInfoDTO>().setData(data); + } + + @GetMapping("list") + @Operation(summary = "列表") + public CommonResult<List<DeviceInfoDTO>> list(@RequestParam Map<String, Object> params){ + List<DeviceInfoDTO> data = deviceInfoService.list(params); + return new CommonResult<List<DeviceInfoDTO>>().setData(data); + } + + @PostMapping + @Operation(summary = "保存") + @LogOperation("保存") + @Transactional + public CommonResult save(@RequestBody DeviceInfoDTO dto) { + //效验数据 + ValidationUtils.validate(dto, AddGroup.class, DefaultGroup.class); + + List<DeviceIndexDTO> tIndexList = dto.getDeviceIndexList(); + if (tIndexList != null) { + for (int i = 0; i < tIndexList.size(); i++) { + DeviceIndexDTO tIndexDTO = tIndexList.get(i); + DeviceIndexEntity tIndexEntity = new DeviceIndexEntity(); + tIndexEntity.setModelId(BusinessConstant.MODEL_Health_Status_Evaluate); + tIndexEntity.setDeviceId(tIndexDTO.getDeviceId()); + tIndexEntity.setIndexNo(tIndexDTO.getIndexNo()); + tIndexEntity.setIndexUpperLimit(tIndexDTO.getIndexUpperLimit()); + tIndexEntity.setIndexLowerLimit(tIndexDTO.getIndexLowerLimit()); + tIndexEntity.setIndexOrder(tIndexDTO.getIndexOrder()); + tIndexEntity.setDataLength(tIndexDTO.getDataLength()); + tIndexEntity.setIndexType(tIndexDTO.getIndexType()); + deviceIndexService.insert(tIndexEntity); + } + } + return new CommonResult(); + } + + @PutMapping + @Operation(summary = "修改") + @LogOperation("修改") + @Transactional + public CommonResult update(@RequestBody DeviceInfoDTO dto) { + //效验数据 + ValidationUtils.validate(dto, UpdateGroup.class, DefaultGroup.class); + + List<DeviceIndexDTO> tIndexList = dto.getDeviceIndexList(); + if (tIndexList != null) { + deviceIndexService.deleteByDeviceId(dto.getId()); + for (int i = 0; i < tIndexList.size(); i++) { + DeviceIndexDTO tIndexDTO = tIndexList.get(i); + DeviceIndexEntity tIndexEntity = new DeviceIndexEntity(); + tIndexEntity.setModelId(BusinessConstant.MODEL_Health_Status_Evaluate); + tIndexEntity.setDeviceId(dto.getId()); + tIndexEntity.setIndexNo(tIndexDTO.getIndexNo()); + tIndexEntity.setIndexUpperLimit(tIndexDTO.getIndexUpperLimit()); + tIndexEntity.setIndexLowerLimit(tIndexDTO.getIndexLowerLimit()); + tIndexEntity.setIndexOrder(tIndexDTO.getIndexOrder()); + tIndexEntity.setDataLength(tIndexDTO.getDataLength()); + tIndexEntity.setIndexType(tIndexDTO.getIndexType()); + deviceIndexService.insert(tIndexEntity); + } + } + + return new CommonResult(); + } + + @PostMapping("/updatePlanTime") + @Operation(summary = "修改计划运行时间") + @LogOperation("修改计划运行时间") + @Transactional + public CommonResult updatePlanTime(@RequestBody DeviceInfoDTO dto) { + + Integer planTime = dto.getPlanTime(); + + // 重新计算使用率 + DeviceStatUsageEntity deviceStatUsage = deviceStatUsageService.getLastByNo(dto.getNo()); + BigDecimal usage = null; + if (deviceStatUsage != null){ + Integer runTime = deviceStatUsage.getRunTime(); + BigDecimal d1 = new BigDecimal(runTime); + BigDecimal d2 = new BigDecimal(planTime*60); + usage = d1.divide(d2, 4, RoundingMode.HALF_UP); + + DeviceStatUsageEntity insertUsageEntry = new DeviceStatUsageEntity(); + insertUsageEntry.setId(deviceStatUsage.getId()); + insertUsageEntry.setUsageRate(usage); + insertUsageEntry.setPlanTime(planTime*60); + deviceStatUsageService.updateById(insertUsageEntry); + } + + // 重新计算新度系数 + // 设备使用年限(分钟) + long durableMinutes = dto.getDurableYears() * BusinessConstant.YEAR_MINUTE; + // 设备剩余使用分钟 + long residueTime = dto.getResidueTime(); + BigDecimal d1 = new BigDecimal(residueTime); + BigDecimal d2 = new BigDecimal(durableMinutes); + BigDecimal newnessRate = d1.divide(d2, 4, RoundingMode.HALF_UP); + + //修改最新新度系数历史 + DeviceStatNewnessEntity deviceStatNewness = deviceStatNewnessService.getLastByNo(dto.getNo()); + if (deviceStatNewness != null){ + + DeviceStatNewnessEntity insertNewnessEntry = new DeviceStatNewnessEntity(); + insertNewnessEntry.setId(deviceStatNewness.getId()); + insertNewnessEntry.setNewnessRate(newnessRate); + insertNewnessEntry.setDurableTime(durableMinutes); + insertNewnessEntry.setResidueTime(residueTime); + deviceStatNewnessService.updateById(insertNewnessEntry); + } + + + DeviceInfoEntity deviceInfoEntity = new DeviceInfoEntity(); + deviceInfoEntity.setId(dto.getId()); + deviceInfoEntity.setPlanTime(planTime); + deviceInfoEntity.setUsageRate(usage); + deviceInfoEntity.setIsMain(dto.getIsMain()); + deviceInfoEntity.setDurableYears(dto.getDurableYears()); + deviceInfoEntity.setNewnessRate(newnessRate); + deviceInfoEntity.setResidueTime(dto.getResidueTime()); + deviceInfoEntity.setUseTime(dto.getUseTime()); + deviceInfoEntity.setUpdateDate(new Date()); + deviceInfoService.updateById(deviceInfoEntity); + + return new CommonResult(); + } +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/controller/DeviceRunStateController.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/controller/DeviceRunStateController.java new file mode 100644 index 0000000..285a101 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/controller/DeviceRunStateController.java @@ -0,0 +1,113 @@ +package com.iailab.module.device.controller; + +import com.iailab.common.annotation.LogOperation; +import com.iailab.framework.common.constant.Constant; +import com.iailab.framework.common.page.PageData; +import com.iailab.framework.common.pojo.CommonResult; + +import com.iailab.framework.common.util.validation.ValidationUtils; +import com.iailab.framework.common.validation.group.AddGroup; +import com.iailab.framework.common.validation.group.DefaultGroup; +import com.iailab.framework.common.validation.group.UpdateGroup; +import com.iailab.module.device.dto.DeviceRunStateDTO; +import com.iailab.module.device.service.DeviceRunStateService; +import io.swagger.v3.oas.annotations.tags.Tag; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.Parameters; +import javax.annotation.Resource; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.*; + + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + + +/** + * 设备运行状态表 + * + * @author lirm ${email} + * @since 1.0.0 2024-05-22 + */ +@RestController +@RequestMapping("device/device-run-state") +@Tag(name = "设备运行状态表") +public class DeviceRunStateController { + @Resource + private DeviceRunStateService deviceRunStateService; + + @GetMapping("page") + @Operation(summary = "分页") + @Parameters({ + @Parameter(name = Constant.PAGE, description = "当前页码,从1开始", required = true) , + @Parameter(name = Constant.LIMIT, description = "每页显示记录数", required = true) , + @Parameter(name = Constant.ORDER_FIELD, description = "排序字段") , + @Parameter(name = Constant.ORDER, description = "排序方式,可选值(asc、desc)") + }) + @PreAuthorize("@ss.hasPermission('device:device-run-state:page')") + public CommonResult<PageData<DeviceRunStateDTO>> page(@RequestParam Map<String, Object> params){ + PageData<DeviceRunStateDTO> page = deviceRunStateService.page(params); + + return new CommonResult<PageData<DeviceRunStateDTO>>().setData(page); + } + + @GetMapping("list") + public CommonResult<DeviceRunStateDTO> list(){ + List<DeviceRunStateDTO> list = deviceRunStateService.list(new HashMap<>()); + DeviceRunStateDTO deviceRunStateDTO = list.get(0); + return new CommonResult<DeviceRunStateDTO>().setData(deviceRunStateDTO); + } + + @GetMapping("{id}") + @Operation(summary = "信息") + @PreAuthorize("@ss.hasPermission('device:device-run-state:info')") + public CommonResult<DeviceRunStateDTO> get(@PathVariable("id") Long id){ + DeviceRunStateDTO data = deviceRunStateService.get(id); + + return new CommonResult<DeviceRunStateDTO>().setData(data); + } + + @PostMapping + @Operation(summary = "保存") + @LogOperation("保存") + @PreAuthorize("@ss.hasPermission('device:device-run-state:save')") + public CommonResult save(@RequestBody DeviceRunStateDTO dto){ + //效验数据 + ValidationUtils.validate(dto, AddGroup.class, DefaultGroup.class); + deviceRunStateService.save(dto); + return new CommonResult(); + } + + @PutMapping + @Operation(summary = "修改") + @LogOperation("修改") + @PreAuthorize("@ss.hasPermission('device:device-run-state:update')") + public CommonResult update(@RequestBody DeviceRunStateDTO dto){ + //效验数据 + ValidationUtils.validate(dto, UpdateGroup.class, DefaultGroup.class); + deviceRunStateService.update(dto); + return new CommonResult(); + } + + @DeleteMapping + @Operation(summary = "删除") + @LogOperation("删除") + @PreAuthorize("@ss.hasPermission('device:device-run-state:delete')") + public CommonResult delete(@RequestBody Long[] ids){ + deviceRunStateService.delete(ids); + return new CommonResult(); + } + +// @GetMapping("export") +// @Operation(summary = "导出") +// @LogOperation("导出") +// @PreAuthorize("@ss.hasPermission('device:device-run-state:export')") +// public void export(@RequestParam Map<String, Object> params, HttpServletResponse response) throws Exception { +// List<DeviceRunStateDTO> list = deviceRunStateService.list(params); +// +// ExcelUtils.exportExcelToTarget(response, null, list, DeviceRunStateExcel.class); +// } + +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/controller/DeviceStatNewnessController.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/controller/DeviceStatNewnessController.java new file mode 100644 index 0000000..2930241 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/controller/DeviceStatNewnessController.java @@ -0,0 +1,56 @@ +package com.iailab.module.device.controller; + +import com.iailab.framework.common.constant.Constant; +import com.iailab.framework.common.page.PageData; +import com.iailab.framework.common.pojo.CommonResult; +import com.iailab.module.device.dto.DeviceStatNewnessDTO; +import com.iailab.module.device.service.DeviceStatNewnessService; +import io.swagger.v3.oas.annotations.tags.Tag; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.Parameters; +import javax.annotation.Resource; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + + +import java.util.List; +import java.util.Map; + + +/** + * 设备新度系数统计表 + * + * @author lirm ${email} + * @since 1.0.0 2024-05-28 + */ +@RestController +@RequestMapping("device/newness") +@Tag(name = "设备新度系数统计表") +public class DeviceStatNewnessController { + @Resource + private DeviceStatNewnessService deviceStatNewnessService; + + @GetMapping("page") + @Operation(summary = "分页") + @Parameters({ + @Parameter(name = Constant.PAGE, description = "当前页码,从1开始", required = true) , + @Parameter(name = Constant.LIMIT, description = "每页显示记录数", required = true) , + @Parameter(name = Constant.ORDER_FIELD, description = "排序字段") , + @Parameter(name = Constant.ORDER, description = "排序方式,可选值(asc、desc)") + }) + public CommonResult<PageData<DeviceStatNewnessDTO>> page(@RequestParam Map<String, Object> params){ + PageData<DeviceStatNewnessDTO> page = deviceStatNewnessService.page(params); + + return new CommonResult<PageData<DeviceStatNewnessDTO>>().setData(page); + } + + @GetMapping("list") + @Operation(summary = "列表") + public CommonResult<List<DeviceStatNewnessDTO>> list(@RequestParam Map<String, Object> params){ + List<DeviceStatNewnessDTO> data = deviceStatNewnessService.list(params); + return new CommonResult<List<DeviceStatNewnessDTO>>().setData(data); + } +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dao/DeviceAbnormalHistoryDao.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dao/DeviceAbnormalHistoryDao.java new file mode 100644 index 0000000..ce0c2db --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dao/DeviceAbnormalHistoryDao.java @@ -0,0 +1,23 @@ +package com.iailab.module.device.dao; + +import com.iailab.framework.common.dao.BaseDao; +import com.iailab.module.device.dto.DeviceAbnormalHistoryDTO; +import com.iailab.module.device.entity.DeviceAbnormalHistoryEntity; +import org.apache.ibatis.annotations.Mapper; + +import java.util.List; +import java.util.Map; + +/** + * 异常设备历史表 + * + * @author lirm ${email} + * @since 1.0.0 2024-05-22 + */ +@Mapper +public interface DeviceAbnormalHistoryDao extends BaseDao<DeviceAbnormalHistoryEntity> { + + void insertHistory(Map<String, Integer> map); + + List<DeviceAbnormalHistoryDTO> getlist(Map<String, Object> params); +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dao/DeviceAccountDao.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dao/DeviceAccountDao.java new file mode 100644 index 0000000..3037e8c --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dao/DeviceAccountDao.java @@ -0,0 +1,27 @@ +package com.iailab.module.device.dao; + +import com.baomidou.mybatisplus.annotation.InterceptorIgnore; +import com.iailab.framework.common.dao.BaseDao; +import com.iailab.module.device.entity.DeviceAccountEntity; +import org.apache.ibatis.annotations.Mapper; + +import java.util.List; + +/** + * 设备台账; + * + * @author lirm ${email} + * @since 1.0.0 2024-05-20 + */ +@Mapper +public interface DeviceAccountDao extends BaseDao<DeviceAccountEntity> { + + @InterceptorIgnore(blockAttack = "true") + void delete(); + @InterceptorIgnore(blockAttack = "true") + void updateMonitorState(); + + DeviceAccountEntity getByDeviceId( int id); + @InterceptorIgnore(blockAttack = "true") + List<String> getDeviceIdList(); +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dao/DeviceAccountHistoryDao.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dao/DeviceAccountHistoryDao.java new file mode 100644 index 0000000..2c48ed3 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dao/DeviceAccountHistoryDao.java @@ -0,0 +1,16 @@ +package com.iailab.module.device.dao; + +import com.iailab.framework.common.dao.BaseDao; +import com.iailab.module.device.entity.DeviceAccountHistoryEntity; +import org.apache.ibatis.annotations.Mapper; + +/** + * 设备台账历史表 + * + * @author lirm ${email} + * @since 1.0.0 2024-05-27 + */ +@Mapper +public interface DeviceAccountHistoryDao extends BaseDao<DeviceAccountHistoryEntity> { + +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dao/DeviceEvaluateIndexDao.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dao/DeviceEvaluateIndexDao.java new file mode 100644 index 0000000..da91558 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dao/DeviceEvaluateIndexDao.java @@ -0,0 +1,14 @@ +package com.iailab.module.device.dao; + +import com.iailab.framework.common.dao.BaseDao; +import com.iailab.module.device.entity.DeviceEvaluateIndexEntity; +import org.apache.ibatis.annotations.Mapper; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年06月29日 + */ +@Mapper +public interface DeviceEvaluateIndexDao extends BaseDao<DeviceEvaluateIndexEntity> { +} diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dao/DeviceFaultDao.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dao/DeviceFaultDao.java new file mode 100644 index 0000000..5ef87f1 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dao/DeviceFaultDao.java @@ -0,0 +1,16 @@ +package com.iailab.module.device.dao; + +import com.iailab.framework.common.dao.BaseDao; +import com.iailab.module.device.entity.DeviceFaultEntity; +import org.apache.ibatis.annotations.Mapper; + +/** + * 设备故障库; + * + * @author lirm ${email} + * @since 1.0.0 2024-05-23 + */ +@Mapper +public interface DeviceFaultDao extends BaseDao<DeviceFaultEntity> { + +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dao/DeviceHealthAlarmDao.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dao/DeviceHealthAlarmDao.java new file mode 100644 index 0000000..88cd6a8 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dao/DeviceHealthAlarmDao.java @@ -0,0 +1,16 @@ +package com.iailab.module.device.dao; + +import com.iailab.framework.common.dao.BaseDao; +import com.iailab.module.device.dto.DeviceHealthAlarmDTO; +import com.iailab.module.device.entity.DeviceHealthAlarmEntity; +import org.apache.ibatis.annotations.Mapper; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年06月28日 + */ +@Mapper +public interface DeviceHealthAlarmDao extends BaseDao<DeviceHealthAlarmEntity> { + DeviceHealthAlarmDTO getInfo(String id); +} diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dao/DeviceHealthAlarmDetailDao.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dao/DeviceHealthAlarmDetailDao.java new file mode 100644 index 0000000..7869112 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dao/DeviceHealthAlarmDetailDao.java @@ -0,0 +1,14 @@ +package com.iailab.module.device.dao; + +import com.iailab.framework.common.dao.BaseDao; +import com.iailab.module.device.entity.DeviceHealthAlarmDetailEntity; +import org.apache.ibatis.annotations.Mapper; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年06月28日 + */ +@Mapper +public interface DeviceHealthAlarmDetailDao extends BaseDao<DeviceHealthAlarmDetailEntity> { +} diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dao/DeviceHealthEvaluateDao.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dao/DeviceHealthEvaluateDao.java new file mode 100644 index 0000000..b28821c --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dao/DeviceHealthEvaluateDao.java @@ -0,0 +1,14 @@ +package com.iailab.module.device.dao; + +import com.iailab.framework.common.dao.BaseDao; +import com.iailab.module.device.entity.DeviceHealthEvaluateEntity; +import org.apache.ibatis.annotations.Mapper; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年06月29日 + */ +@Mapper +public interface DeviceHealthEvaluateDao extends BaseDao<DeviceHealthEvaluateEntity> { +} diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dao/DeviceHealthReportDao.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dao/DeviceHealthReportDao.java new file mode 100644 index 0000000..e7b6b19 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dao/DeviceHealthReportDao.java @@ -0,0 +1,18 @@ +package com.iailab.module.device.dao; + +import com.iailab.framework.common.dao.BaseDao; +import com.iailab.module.device.entity.DeviceHealthReportEntity; +import org.apache.ibatis.annotations.Mapper; + +import java.util.List; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年06月28日 + */ +@Mapper +public interface DeviceHealthReportDao extends BaseDao<DeviceHealthReportEntity> { +// @DataSource("slave1") + void migration(List<DeviceHealthReportEntity> list); +} diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dao/DeviceHealthReportDataDao.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dao/DeviceHealthReportDataDao.java new file mode 100644 index 0000000..e3f439a --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dao/DeviceHealthReportDataDao.java @@ -0,0 +1,18 @@ +package com.iailab.module.device.dao; + +import com.iailab.framework.common.dao.BaseDao; +import com.iailab.module.device.entity.DeviceHealthReportDataEntity; +import org.apache.ibatis.annotations.Mapper; + +import java.util.List; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年06月28日 + */ +@Mapper +public interface DeviceHealthReportDataDao extends BaseDao<DeviceHealthReportDataEntity> { +// @DataSource("slave1") + void migration(List<DeviceHealthReportDataEntity> list); +} diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dao/DeviceHealthStateDao.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dao/DeviceHealthStateDao.java new file mode 100644 index 0000000..18af1ad --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dao/DeviceHealthStateDao.java @@ -0,0 +1,23 @@ +package com.iailab.module.device.dao; + +import com.iailab.framework.common.dao.BaseDao; +import com.iailab.module.device.entity.DeviceHealthStateEntity; +import org.apache.ibatis.annotations.Mapper; + +import java.util.Map; + +/** + * 设备健康状态表 + * + * @author lirm ${email} + * @since 1.0.0 2024-05-22 + */ +@Mapper +public interface DeviceHealthStateDao extends BaseDao<DeviceHealthStateEntity> { + + void insertHealthState(Map<String, Object> tMap); + + int getId(); + + void updateHealthState(Map<String, Object> tMap); +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dao/DeviceIndexDao.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dao/DeviceIndexDao.java new file mode 100644 index 0000000..99f302a --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dao/DeviceIndexDao.java @@ -0,0 +1,15 @@ +package com.iailab.module.device.dao; + +import com.iailab.framework.common.dao.BaseDao; +import com.iailab.module.device.entity.DeviceIndexEntity; +import org.apache.ibatis.annotations.Mapper; + +/** + * + * @author lirm ${email} + * @since 1.0.0 2024-05-29 + */ +@Mapper +public interface DeviceIndexDao extends BaseDao<DeviceIndexEntity> { + +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dao/DeviceInfoDao.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dao/DeviceInfoDao.java new file mode 100644 index 0000000..dd0c1d5 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dao/DeviceInfoDao.java @@ -0,0 +1,23 @@ +package com.iailab.module.device.dao; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.iailab.framework.common.dao.BaseDao; +import com.iailab.module.device.dto.DeviceInfoDTO; +import com.iailab.module.device.entity.DeviceInfoEntity; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; +import java.util.Map; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年05月27日 + */ +@Mapper +public interface DeviceInfoDao extends BaseDao<DeviceInfoEntity> { + List<DeviceInfoDTO> getchildrenList(String deviceId); + + IPage<DeviceInfoDTO> getPageList(IPage<DeviceInfoEntity> page, @Param("params") Map<String, Object> params); +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dao/DeviceMainDao.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dao/DeviceMainDao.java new file mode 100644 index 0000000..289701b --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dao/DeviceMainDao.java @@ -0,0 +1,14 @@ +package com.iailab.module.device.dao; + +import com.iailab.framework.common.dao.BaseDao; +import com.iailab.module.device.entity.DeviceMainEntity; +import org.apache.ibatis.annotations.Mapper; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年05月30日 + */ +@Mapper +public interface DeviceMainDao extends BaseDao<DeviceMainEntity> { +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dao/DeviceRunStateDao.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dao/DeviceRunStateDao.java new file mode 100644 index 0000000..14dead2 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dao/DeviceRunStateDao.java @@ -0,0 +1,23 @@ +package com.iailab.module.device.dao; + +import com.iailab.framework.common.dao.BaseDao; +import com.iailab.module.device.entity.DeviceRunStateEntity; +import org.apache.ibatis.annotations.Mapper; + +import java.util.Map; + +/** + * 设备运行状态表 + * + * @author lirm ${email} + * @since 1.0.0 2024-05-22 + */ +@Mapper +public interface DeviceRunStateDao extends BaseDao<DeviceRunStateEntity> { + + void insertRunState(Map<String, Integer> tMap); + + int getId(); + + void updateRunState(Map<String, Integer> tMap); +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dao/DeviceStatCountDao.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dao/DeviceStatCountDao.java new file mode 100644 index 0000000..f12c26e --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dao/DeviceStatCountDao.java @@ -0,0 +1,16 @@ +package com.iailab.module.device.dao; + +import com.iailab.framework.common.dao.BaseDao; +import com.iailab.module.device.entity.DeviceStatCountEntity; +import org.apache.ibatis.annotations.Mapper; + +/** + * 设备健康状态表 + * + * @author lirm ${email} + * @since 1.0.0 2024-05-22 + */ +@Mapper +public interface DeviceStatCountDao extends BaseDao<DeviceStatCountEntity> { + +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dao/DeviceStatNewnessDao.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dao/DeviceStatNewnessDao.java new file mode 100644 index 0000000..7acf25d --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dao/DeviceStatNewnessDao.java @@ -0,0 +1,20 @@ +package com.iailab.module.device.dao; + +import com.iailab.framework.common.dao.BaseDao; +import com.iailab.module.device.dto.DeviceStatNewnessDTO; +import com.iailab.module.device.entity.DeviceStatNewnessEntity; +import org.apache.ibatis.annotations.Mapper; + +import java.util.List; + +/** + * 设备运行状态表 + * + * @author lirm ${email} + * @since 1.0.0 2024-05-22 + */ +@Mapper +public interface DeviceStatNewnessDao extends BaseDao<DeviceStatNewnessEntity> { + + List<DeviceStatNewnessDTO> getLastDateList(); +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dao/DeviceStatUsageDao.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dao/DeviceStatUsageDao.java new file mode 100644 index 0000000..4bdde16 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dao/DeviceStatUsageDao.java @@ -0,0 +1,19 @@ +package com.iailab.module.device.dao; + +import com.iailab.framework.common.dao.BaseDao; +import com.iailab.module.device.entity.DeviceStatUsageEntity; +import org.apache.ibatis.annotations.Mapper; + +import java.util.List; + +/** + * 设备运行状态表 + * + * @author lirm ${email} + * @since 1.0.0 2024-05-22 + */ +@Mapper +public interface DeviceStatUsageDao extends BaseDao<DeviceStatUsageEntity> { + + void batchInsert(List<DeviceStatUsageEntity> list); +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dto/DeviceAbnormalHistoryDTO.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dto/DeviceAbnormalHistoryDTO.java new file mode 100644 index 0000000..dde134e --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dto/DeviceAbnormalHistoryDTO.java @@ -0,0 +1,35 @@ +package com.iailab.module.device.dto; + +import io.swagger.v3.oas.annotations.media.Schema; + +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; + + +/** + * 异常设备历史表 + * + * @author lirm ${email} + * @since 1.0.0 2024-05-22 + */ +@Data +@Schema(name = "异常设备历史表") +public class DeviceAbnormalHistoryDTO implements Serializable { + private static final long serialVersionUID = 1L; + + @Schema(name = "id") + private Integer id; + + @Schema(name = "总设备数") + private Integer totalCount; + + @Schema(name = "异常数量") + private Integer abnormalCount; + + @Schema(name = "创建时间") + private Date createDate; + + +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dto/DeviceAccountDTO.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dto/DeviceAccountDTO.java new file mode 100644 index 0000000..50f2020 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dto/DeviceAccountDTO.java @@ -0,0 +1,70 @@ +package com.iailab.module.device.dto; + +import io.swagger.v3.oas.annotations.media.Schema; + +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; + + +/** + * 设备台账 + * + * @author lirm ${email} + * @since 1.0.0 2024-05-27 + */ +@Data +@Schema(name = "设备台账") +public class DeviceAccountDTO implements Serializable { + private static final long serialVersionUID = 1L; + + @Schema(name = "ID") + private String id; + + @Schema(name = "设备ID") + private Integer deviceId; + + @Schema(name = "设备名称") + private String deviceName; + + @Schema(name = "设备编码") + private String deviceCode; + + @Schema(name = "设备类型") + private String deviceCategory; + + @Schema(name = "设备分类") + private String deviceClass; + + @Schema(name = "所属车间") + private String workShop; + + @Schema(name = "规格型号") + private String specification; + + @Schema(name = "是否推送工单") + private Integer isPush; + + @Schema(name = "运行状态") + private Integer runState; + + @Schema(name = "监测状态") + private Integer monitorState; + + @Schema(name = "备注") + private String remark; + @Schema(name = "创建人") + private String creator; + + @Schema(name = "创建时间") + private Date createDate; + + @Schema(name = "更新人") + private String updater; + + @Schema(name = "更新时间") + private Date updateDate; + + +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dto/DeviceAccountHistoryDTO.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dto/DeviceAccountHistoryDTO.java new file mode 100644 index 0000000..66e4287 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dto/DeviceAccountHistoryDTO.java @@ -0,0 +1,68 @@ +package com.iailab.module.device.dto; + +import io.swagger.v3.oas.annotations.media.Schema; + +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; + + +/** + * 设备台账 + * + * @author lirm ${email} + * @since 1.0.0 2024-05-27 + */ +@Data +@Schema(name = "设备台账") +public class DeviceAccountHistoryDTO implements Serializable { + private static final long serialVersionUID = 1L; + + @Schema(name = "ID") + private String id; + + @Schema(name = "设备ID") + private Integer deviceId; + + @Schema(name = "设备名称") + private String deviceName; + + @Schema(name = "设备编码") + private String deviceCode; + + @Schema(name = "设备类型") + private String deviceCategory; + + @Schema(name = "设备分类") + private String deviceClass; + + @Schema(name = "所属车间") + private String workShop; + + @Schema(name = "规格型号") + private String specification; + + @Schema(name = "是否推送工单") + private Integer isPush; + + @Schema(name = "运行状态") + private Integer runState; + + @Schema(name = "监测状态") + private Integer monitorState; + + @Schema(name = "创建人") + private String creator; + + @Schema(name = "创建时间") + private Date createDate; + + @Schema(name = "更新人") + private String updater; + + @Schema(name = "更新时间") + private Date updateDate; + + +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dto/DeviceCurrentRateDTO.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dto/DeviceCurrentRateDTO.java new file mode 100644 index 0000000..e30e127 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dto/DeviceCurrentRateDTO.java @@ -0,0 +1,26 @@ +package com.iailab.module.device.dto; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.math.BigDecimal; + +@Data +@Schema(name = "设备实时率") +public class DeviceCurrentRateDTO { + + /** + * 完好率 + */ + private BigDecimal healthyRate; + + /** + * 待修率 + */ + private BigDecimal repairRate; + + /** + * 事故率 + */ + private BigDecimal accidentRate; +} diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dto/DeviceEvaluateIndexDTO.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dto/DeviceEvaluateIndexDTO.java new file mode 100644 index 0000000..b8bd7aa --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dto/DeviceEvaluateIndexDTO.java @@ -0,0 +1,30 @@ +package com.iailab.module.device.dto; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.io.Serializable; +import java.math.BigDecimal; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年06月29日 + */ +@Data +@Schema(name = "设备健康评价指标") +public class DeviceEvaluateIndexDTO implements Serializable { + private static final long serialVersionUID = 1L; + + private String id; + private String evaluateId; + private String indexType; + private Integer paramOrder; + private String paramType; + private String paramId; + private String paramName; + private Integer dataLength; + private BigDecimal upperLimit; + private BigDecimal lowerLimit; + private BigDecimal nominalValue; +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dto/DeviceFaultDTO.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dto/DeviceFaultDTO.java new file mode 100644 index 0000000..62d9d24 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dto/DeviceFaultDTO.java @@ -0,0 +1,50 @@ +package com.iailab.module.device.dto; + +import com.iailab.framework.excel.core.annotations.DictFormat; +import io.swagger.v3.oas.annotations.media.Schema; + +import lombok.Data; + +import java.io.Serializable; + + +/** + * 设备故障库; + * + * @author lirm ${email} + * @since 1.0.0 2024-05-23 + */ +@Data +@Schema(name = "设备故障库") +public class DeviceFaultDTO implements Serializable { + private static final long serialVersionUID = 1L; + + @Schema(name = "id") + private Integer id; + + @Schema(name = "设备代码") + private String classNo; + + @Schema(name = "设备类型") + private String className; + + @Schema(name = "指标类型") + @DictFormat("health_index_type") + private String indexType; + + @Schema(name = "故障类型") + @DictFormat("health_fault_type") + private String faultType; + + @Schema(name = "故障码") + private String faultCode; + + @Schema(name = "处理对策") + private String solution; + + @Schema(name = "排序") + private Integer sort; + + @Schema(name = "故障名称") + private String faultName; +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dto/DeviceHealthAlarmDTO.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dto/DeviceHealthAlarmDTO.java new file mode 100644 index 0000000..d6e27eb --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dto/DeviceHealthAlarmDTO.java @@ -0,0 +1,34 @@ +package com.iailab.module.device.dto; + +import com.iailab.module.device.dao.DeviceFaultDao; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; +import java.util.List; + +/** + * @description: 设备健康故障记录 + * @author: dzd + * @date: 2024/7/9 17:28 + **/ +@Data +@Schema(name = "设备健康故障记录") +public class DeviceHealthAlarmDTO implements Serializable { + private static final long serialVersionUID = 1L; + + private String id; + private String reportId; + private String devNo; + private String devName; + private String alarmIndexTypes; + private String alarmSolutions; + private Integer isPushed; + private Integer pushType; + private Date pushTime; + private Date createDate; + private Date faultTime; + + private List<DeviceFaultDao> deviceFaults; +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dto/DeviceHealthAlarmDetailDTO.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dto/DeviceHealthAlarmDetailDTO.java new file mode 100644 index 0000000..0f1e640 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dto/DeviceHealthAlarmDetailDTO.java @@ -0,0 +1,23 @@ +package com.iailab.module.device.dto; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.io.Serializable; + +/** + * @description: 设备健康故障详情 + * @author: dzd + * @date: 2024/7/9 17:28 + **/ +@Data +@Schema(name = "设备健康故障详情") +public class DeviceHealthAlarmDetailDTO implements Serializable { + private static final long serialVersionUID = 1L; + + private String id; + private String alarmId; + private String faultCode; + private String faultName; + private String solution; +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dto/DeviceHealthEvaluateDTO.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dto/DeviceHealthEvaluateDTO.java new file mode 100644 index 0000000..c305580 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dto/DeviceHealthEvaluateDTO.java @@ -0,0 +1,41 @@ +package com.iailab.module.device.dto; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.io.Serializable; +import java.math.BigDecimal; +import java.util.Date; +import java.util.List; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年06月29日 + */ +@Data +@Schema(name = "设备健康评价") +public class DeviceHealthEvaluateDTO implements Serializable { + private static final long serialVersionUID = 1L; + + private String id; + private String devId; + private String devNo; + private String devName; + private String modelCode; + private String modelUrl; + private String healthLevel; + private BigDecimal healthScore; + private Integer abnormalCount; + private String reportId; + private Date reportDate; + private String reportContent; + private Integer isPushed; + private Integer isEnable; + private Long creator; + private Date createDate; + private Long updater; + private Date updateDate; + + private List<DeviceEvaluateIndexDTO> indexList; +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dto/DeviceHealthReportDTO.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dto/DeviceHealthReportDTO.java new file mode 100644 index 0000000..b4a6d3c --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dto/DeviceHealthReportDTO.java @@ -0,0 +1,46 @@ +package com.iailab.module.device.dto; + +import com.iailab.common.dto.echarts.BarLineDTO; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.io.Serializable; +import java.math.BigDecimal; +import java.util.Date; +import java.util.List; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年06月28日 + */ +@Data +@Schema(name = "设备健康评价报告") +public class DeviceHealthReportDTO implements Serializable { + private static final long serialVersionUID = 1L; + + private String id; + private String devNo; + private String devName; + private String classNo; + private String className; + private String workshop; + private String model; + private String reportNo; + private String reportName; + private Date reportDate; + private String healthLevel; + private BigDecimal healthScore; + private Integer abnormalCount; + private Integer dataLength; + private Integer runTime; + private String content; + private Date createDate; + private String modelCode; + + private List<DeviceHealthReportDataDTO> detList; + private DeviceHealthAlarmDTO deviceHealthAlarm; + private List<DeviceHealthAlarmDetailDTO> deviceHealthAlarmDetails; + + private List<BarLineDTO> chartList; +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dto/DeviceHealthReportDataDTO.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dto/DeviceHealthReportDataDTO.java new file mode 100644 index 0000000..0a3401f --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dto/DeviceHealthReportDataDTO.java @@ -0,0 +1,34 @@ +package com.iailab.module.device.dto; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.io.Serializable; +import java.math.BigDecimal; +import java.util.Date; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年06月28日 + */ +@Data +@Schema(name = "设备健康评价报告数据") +public class DeviceHealthReportDataDTO implements Serializable { + private static final long serialVersionUID = 1L; + + private String id; + private String reportId; + private Integer sort; + private String dataName; + private String dataValue; + private BigDecimal dataMax; + private BigDecimal dataMin; + private BigDecimal dataAvg; + private String gradeCode; + private String gradeName; + private String solution; + private String remark; + private Date createDate; + private String faultCode; +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dto/DeviceHealthStateDTO.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dto/DeviceHealthStateDTO.java new file mode 100644 index 0000000..5a12069 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dto/DeviceHealthStateDTO.java @@ -0,0 +1,47 @@ +package com.iailab.module.device.dto; + +import io.swagger.v3.oas.annotations.media.Schema; + +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; + + +/** + * 设备健康状态表 + * + * @author lirm ${email} + * @since 1.0.0 2024-05-22 + */ +@Data +@Schema(name = "设备健康状态表") +public class DeviceHealthStateDTO implements Serializable { + private static final long serialVersionUID = 1L; + + @Schema(name = "id") + private Integer id; + + @Schema(name = "总设备数") + private Integer totalCount; + + @Schema(name = "正常") + private Integer normal; + + @Schema(name = "一般") + private Integer common; + + @Schema(name = "较重") + private Integer heavy; + + @Schema(name = "严重") + private Integer serious; + + @Schema(name = "特别严重") + private Integer espserious; + + @Schema(name = "创建时间") + private Date creatorDate; + + +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dto/DeviceIndexDTO.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dto/DeviceIndexDTO.java new file mode 100644 index 0000000..3a0b9b9 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dto/DeviceIndexDTO.java @@ -0,0 +1,26 @@ +package com.iailab.module.device.dto; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.io.Serializable; + +/** + * @author lirm + * @Description + * @createTime 2024年05月29日 + */ +@Data +@Schema(name = "设备指标") +public class DeviceIndexDTO implements Serializable { + private static final long serialVersionUID = 1L; + private Integer id; + private String deviceId; + private String modelId; + private String indexNo; + private String indexUpperLimit; + private String indexLowerLimit; + private Integer indexOrder; + private Integer dataLength; + private String indexType; +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dto/DeviceInfoDTO.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dto/DeviceInfoDTO.java new file mode 100644 index 0000000..b8aa996 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dto/DeviceInfoDTO.java @@ -0,0 +1,54 @@ +package com.iailab.module.device.dto; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.io.Serializable; +import java.math.BigDecimal; +import java.util.Date; +import java.util.List; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年05月27日 + */ +@Data +@Schema(name = "中选设备信息表") +public class DeviceInfoDTO implements Serializable { + private static final long serialVersionUID = 1L; + + private String id; + private String no; + private String name; + private String classNo; + private String className; + private String workshop; + private String model; + private String sn; + private String position; + private String manufacturer; + private String installDate; + private String plcDevNo; + private String pid; + private Date createDate; + private Date updateDate; + + private List<DeviceInfoDTO> children; + + private String healthScore; + private String healthEvaluate; + private String isHealth; + private String evaluateDate; + + private String deviceId; + + private List<DeviceIndexDTO> deviceIndexList; + private BigDecimal usageRate; + private Integer planTime; + private Integer isMain; + private BigDecimal newnessRate; + private Integer durableYears; + private Long residueTime; + private Long useTime; +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dto/DeviceListJsonDto.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dto/DeviceListJsonDto.java new file mode 100644 index 0000000..a0b9dc2 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dto/DeviceListJsonDto.java @@ -0,0 +1,12 @@ +package com.iailab.module.device.dto; + +import lombok.Data; + +import java.io.Serializable; +import java.util.Map; + +@Data +public class DeviceListJsonDto implements Serializable { + private Map<String,String> items; + +} diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dto/DeviceMainDTO.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dto/DeviceMainDTO.java new file mode 100644 index 0000000..7c533bf --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dto/DeviceMainDTO.java @@ -0,0 +1,49 @@ +package com.iailab.module.device.dto; + +import io.swagger.v3.oas.annotations.media.Schema; + +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年05月30日 + */ +@Data +@Schema(name = "设备台账") +public class DeviceMainDTO implements Serializable { + private static final long serialVersionUID = 1L; + + @Schema(name = "ID") + private String id; + + @Schema(name = "设备编号") + private String devno; + + @Schema(name = "设备名称") + private String devname; + + @Schema(name = "common常规维保,timer定期维保") + private String source; + + @Schema(name = "维护类型") + private String type; + + @Schema(name = "维护日期") + private String date; + + @Schema(name = "维护部位") + private String part; + + @Schema(name = "维护内容") + private String info; + + @Schema(name = "登记时间") + private Date regTime; + + @Schema(name = "创建日期") + private Date createDate; +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dto/DeviceRunStateDTO.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dto/DeviceRunStateDTO.java new file mode 100644 index 0000000..442f8b1 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dto/DeviceRunStateDTO.java @@ -0,0 +1,41 @@ +package com.iailab.module.device.dto; + +import io.swagger.v3.oas.annotations.media.Schema; + +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; + + +/** + * 设备运行状态表 + * + * @author lirm ${email} + * @since 1.0.0 2024-05-22 + */ +@Data +@Schema(name = "设备运行状态表") +public class DeviceRunStateDTO implements Serializable { + private static final long serialVersionUID = 1L; + + @Schema(name = "id") + private Integer id; + + @Schema(name = "在线设备数量") + private Integer totalCount; + + @Schema(name = "运行设备") + private Integer runCount; + + @Schema(name = "停机设备") + private Integer haltCount; + + @Schema(name = "离线设备") + private Integer offlineCount; + + @Schema(name = "创建时间") + private Date creatorDate; + + +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dto/DeviceStatCountDTO.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dto/DeviceStatCountDTO.java new file mode 100644 index 0000000..1bfd981 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dto/DeviceStatCountDTO.java @@ -0,0 +1,43 @@ +package com.iailab.module.device.dto; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.util.Date; + +@Data +@Schema(name = "设备实时统计") +public class DeviceStatCountDTO { + /** + * id + */ + private String id; + /** + * 统计日期 + */ + private Date date; + + /** + * 所有设备 + */ + private Long totalCount; + + /** + * 健康设备 + */ + private Long healthCount; + + /** + * 良好设备 + */ + private Long goodCount; + + /** + * 故障设备 + */ + private Long accidentCount; + /** + * 创建时间 + */ + private Date createDate; +} diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dto/DeviceStatNewnessDTO.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dto/DeviceStatNewnessDTO.java new file mode 100644 index 0000000..a30c6ca --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dto/DeviceStatNewnessDTO.java @@ -0,0 +1,63 @@ +package com.iailab.module.device.dto; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.math.BigDecimal; +import java.util.Date; + +/** + * 设备新度系数统计表 + * + * @author lirm ${email} + * @since 1.0.0 2024-05-22 + */ +@Data +@Schema(name = "设备新度系数统计表") +public class DeviceStatNewnessDTO { + + /** + * id + */ + private String id; + /** + * 设备编号 + */ + private String devNo; + /** + * 设备名称 + */ + private String devName; + /** + * 统计日期 + */ + private Date date; + /** + * 设备计划使用时长(分) + */ + private Long durableTime; + /** + * 设备使用时长(分) + */ + private Integer runTime; + /** + * 设备剩余时长(分) + */ + private Long residueTime; + /** + * 新度系数 + */ + private BigDecimal newnessRate; + /** + * 创建时间 + */ + private Date createDate; + /** + * 设备损耗时长(分) + */ + private Integer lossTime; + /** + * 损耗系数 + */ + private BigDecimal lossRate; +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/entity/DeviceAbnormalHistoryEntity.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/entity/DeviceAbnormalHistoryEntity.java new file mode 100644 index 0000000..b2b1f63 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/entity/DeviceAbnormalHistoryEntity.java @@ -0,0 +1,36 @@ +package com.iailab.module.device.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; + +/** + * 异常设备历史表 + * + * @author lirm ${email} + * @since 1.0.0 2024-05-22 + */ +@Data +@TableName("t_device_abnormal_history") +public class DeviceAbnormalHistoryEntity implements Serializable { + private static final long serialVersionUID = 1L; + + /** + * id + */ + private Integer id; + /** + * 总设备数 + */ + private Integer totalCount; + /** + * 异常数量 + */ + private Integer abnormalCount; + /** + * 创建时间 + */ + private Date createDate; +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/entity/DeviceAccountEntity.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/entity/DeviceAccountEntity.java new file mode 100644 index 0000000..b0432bd --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/entity/DeviceAccountEntity.java @@ -0,0 +1,82 @@ +package com.iailab.module.device.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; + +/** + * 设备台账 + * + * @author lirm ${email} + * @since 1.0.0 2024-05-27 + */ +@Data +@TableName("t_device_account") +public class DeviceAccountEntity implements Serializable { + private static final long serialVersionUID = 1L; + + /** + * ID + */ + private String id; + /** + * 设备ID + */ + private Integer deviceId; + /** + * 设备名称 + */ + private String deviceName; + /** + * 设备编码 + */ + private String deviceCode; + /** + * 设备类型 + */ + private String deviceCategory; + /** + * 设备分类 + */ + private String deviceClass; + /** + * 所属车间 + */ + private String workShop; + /** + * 规格型号 + */ + private String specification; + /** + * 是否推送工单 + */ + private Integer isPush; + /** + * 运行状态 + */ + private Integer runState; + /** + * 监测状态 + */ + private Integer monitorState; + + private String remark; + /** + * 创建人 + */ + private String creator; + /** + * 创建时间 + */ + private Date createDate; + /** + * 更新人 + */ + private String updater; + /** + * 更新时间 + */ + private Date updateDate; +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/entity/DeviceAccountHistoryEntity.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/entity/DeviceAccountHistoryEntity.java new file mode 100644 index 0000000..009dd14 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/entity/DeviceAccountHistoryEntity.java @@ -0,0 +1,80 @@ +package com.iailab.module.device.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; + +/** + * 设备台账历史表 + * + * @author lirm ${email} + * @since 1.0.0 2024-05-27 + */ +@Data +@TableName("t_device_account_history") +public class DeviceAccountHistoryEntity implements Serializable { + private static final long serialVersionUID = 1L; + + /** + * ID + */ + private String id; + /** + * 设备ID + */ + private Integer deviceId; + /** + * 设备名称 + */ + private String deviceName; + /** + * 设备编码 + */ + private String deviceCode; + /** + * 设备类型 + */ + private String deviceCategory; + /** + * 设备分类 + */ + private String deviceClass; + /** + * 所属车间 + */ + private String workShop; + /** + * 规格型号 + */ + private String specification; + /** + * 是否推送工单 + */ + private Integer isPush; + /** + * 运行状态 + */ + private Integer runState; + /** + * 监测状态 + */ + private Integer monitorState; + /** + * 创建人 + */ + private String creator; + /** + * 创建时间 + */ + private Date createDate; + /** + * 更新人 + */ + private String updater; + /** + * 更新时间 + */ + private Date updateDate; +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/entity/DeviceEvaluateIndexEntity.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/entity/DeviceEvaluateIndexEntity.java new file mode 100644 index 0000000..c07b28f --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/entity/DeviceEvaluateIndexEntity.java @@ -0,0 +1,32 @@ +package com.iailab.module.device.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; + +import java.io.Serializable; +import java.math.BigDecimal; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年06月29日 + */ +@Data +@TableName("t_device_evaluate_index") +public class DeviceEvaluateIndexEntity implements Serializable { + + private static final long serialVersionUID = 1L; + + private String id; + private String evaluateId; + private String indexType; + private Integer paramOrder; + private String paramType; + private String paramId; + private String paramName; + private Integer dataLength; + private BigDecimal upperLimit; + private BigDecimal lowerLimit; + private BigDecimal nominalValue; + +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/entity/DeviceFaultEntity.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/entity/DeviceFaultEntity.java new file mode 100644 index 0000000..64d4f59 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/entity/DeviceFaultEntity.java @@ -0,0 +1,55 @@ +package com.iailab.module.device.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; + +import java.io.Serializable; + +/** + * 设备故障库; + * + * @author lirm ${email} + * @since 1.0.0 2024-05-23 + */ +@Data +@TableName("t_device_fault") +public class DeviceFaultEntity implements Serializable { + private static final long serialVersionUID = 1L; + + /** + * id + */ + private Integer id; + /** + * 设备代码 + */ + private String classNo; + /** + * 设备类型 + */ + private String className; + /** + * 指标类型 + */ + private String indexType; + + /** + * 故障类型 + */ + private String faultType; + + /** + * 故障码 + */ + private String faultCode; + + /** + * 处理对策 + */ + private String solution; + + /** + * 排序 + */ + private Integer sort; +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/entity/DeviceFaultHistoryEntity.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/entity/DeviceFaultHistoryEntity.java new file mode 100644 index 0000000..a7a77b6 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/entity/DeviceFaultHistoryEntity.java @@ -0,0 +1,56 @@ +package com.iailab.module.device.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; + +/** + * 设备故障历史表 + * + * @author lirm ${email} + * @since 1.0.0 2024-05-27 + */ +@Data +@TableName("t_fault_account_history") +public class DeviceFaultHistoryEntity implements Serializable { + private static final long serialVersionUID = 1L; + + /** + * id + */ + private Integer id; + /** + * 故障设备 + */ + private String faultDevice; + /** + * 故障部件 + */ + private String faultParts; + /** + * 故障类型 + */ + private String faultType; + /** + * 故障原因 + */ + private String faultCause; + /** + * 处理对策 + */ + private String solution; + /** + * 处理状态 + */ + private String state; + /** + * 影响时长 + */ + private Integer affectHour; + /** + * 发生时间 + */ + private Date creatorDate; +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/entity/DeviceHealthAlarmDetailEntity.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/entity/DeviceHealthAlarmDetailEntity.java new file mode 100644 index 0000000..7d30fa6 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/entity/DeviceHealthAlarmDetailEntity.java @@ -0,0 +1,24 @@ +package com.iailab.module.device.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; + +/** + * 设备健康故障详情 + */ +@Data +@TableName("t_device_health_alarm_detail") +public class DeviceHealthAlarmDetailEntity implements Serializable { + private static final long serialVersionUID = 1L; + + @TableId(type = IdType.ASSIGN_UUID) + private String id; + private String alarmId; + private String faultCode; + private String faultName; + private String solution; +} diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/entity/DeviceHealthAlarmEntity.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/entity/DeviceHealthAlarmEntity.java new file mode 100644 index 0000000..061e36c --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/entity/DeviceHealthAlarmEntity.java @@ -0,0 +1,31 @@ +package com.iailab.module.device.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; + +/** + * 设备健康故障记录 + */ +@Data +@TableName("t_device_health_alarm") +public class DeviceHealthAlarmEntity implements Serializable { + private static final long serialVersionUID = 1L; + + @TableId(type = IdType.ASSIGN_UUID) + private String id; + private String reportId; + private String devNo; + private String devName; + private String alarmIndexTypes; + private String alarmSolutions; + private Integer isPushed; + private Integer pushType; + private Date pushTime; + private Date createDate; + private Date faultTime; +} diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/entity/DeviceHealthEvaluateEntity.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/entity/DeviceHealthEvaluateEntity.java new file mode 100644 index 0000000..585d87f --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/entity/DeviceHealthEvaluateEntity.java @@ -0,0 +1,57 @@ +package com.iailab.module.device.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.math.BigDecimal; +import java.util.Date; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年06月29日 + */ +@Data +@TableName("t_device_health_evaluate") +public class DeviceHealthEvaluateEntity implements Serializable { + private static final long serialVersionUID = 1L; + + @TableId(type = IdType.ASSIGN_UUID) + private String id; + private String devId; + private String devNo; + private String devName; + private String modelCode; + private String modelUrl; + private String healthLevel; + private BigDecimal healthScore; + private Integer abnormalCount; + private String reportId; + private Date reportDate; + private String reportContent; + private Integer isPushed; + private Integer isEnable; + + /** + * 创建人 + */ + private Long creator; + + /** + * 创建时间 + */ + private Date createDate; + + /** + * 修改人 + */ + private Long updater; + + /** + * 修改时间 + */ + private Date updateDate; +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/entity/DeviceHealthReportDataEntity.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/entity/DeviceHealthReportDataEntity.java new file mode 100644 index 0000000..f049d89 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/entity/DeviceHealthReportDataEntity.java @@ -0,0 +1,33 @@ +package com.iailab.module.device.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; + +import java.io.Serializable; +import java.math.BigDecimal; +import java.util.Date; + +/** + * 设备健康评价报告数据 + */ +@Data +@TableName("t_device_health_report_data") +public class DeviceHealthReportDataEntity implements Serializable { + private static final long serialVersionUID = 1L; + + private String id; + private String reportId; + private Integer sort; + private String dataName; + private String dataValue; + private BigDecimal dataMax; + private BigDecimal dataMin; + private BigDecimal dataAvg; + private String gradeCode; + private String gradeName; + private String solution; + private String remark; + private Date createDate; + private String faultCode; + +} diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/entity/DeviceHealthReportEntity.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/entity/DeviceHealthReportEntity.java new file mode 100644 index 0000000..e38be5f --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/entity/DeviceHealthReportEntity.java @@ -0,0 +1,37 @@ +package com.iailab.module.device.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; + +import java.io.Serializable; +import java.math.BigDecimal; +import java.util.Date; + +/** + * 设备健康评价报告 + */ +@Data +@TableName("t_device_health_report") +public class DeviceHealthReportEntity implements Serializable { + private static final long serialVersionUID = 1L; + + private String id; + private String devNo; + private String devName; + private String classNo; + private String className; + private String workshop; + private String model; + private String reportNo; + private String reportName; + private Date reportDate; + private String healthLevel; + private BigDecimal healthScore; + private Integer abnormalCount; + private Integer dataLength; + private Integer runTime; + private String content; + private String modelCode; + private Date createDate; + +} diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/entity/DeviceHealthStateEntity.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/entity/DeviceHealthStateEntity.java new file mode 100644 index 0000000..1c97445 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/entity/DeviceHealthStateEntity.java @@ -0,0 +1,52 @@ +package com.iailab.module.device.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; + +/** + * 设备健康状态表 + * + * @author lirm ${email} + * @since 1.0.0 2024-05-22 + */ +@Data +@TableName("t_device_health_state") +public class DeviceHealthStateEntity implements Serializable { + private static final long serialVersionUID = 1L; + + /** + * id + */ + private Integer id; + /** + * 总设备数 + */ + private Integer totalCount; + /** + * 正常 + */ + private Integer normal; + /** + * 一般 + */ + private Integer common; + /** + * 较重 + */ + private Integer heavy; + /** + * 严重 + */ + private Integer serious; + /** + * 特别严重 + */ + private Integer espserious; + /** + * 创建时间 + */ + private Date creatorDate; +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/entity/DeviceIndexEntity.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/entity/DeviceIndexEntity.java new file mode 100644 index 0000000..bbd1d88 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/entity/DeviceIndexEntity.java @@ -0,0 +1,28 @@ +package com.iailab.module.device.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; + +import java.io.Serializable; + +/** + * 设备指标 + * + * @author lirm ${email} + * @since 1.0.0 2024-05-29 + */ +@Data +@TableName("t_device_index") +public class DeviceIndexEntity implements Serializable { + private static final long serialVersionUID = 1L; + + private Integer id; + private String deviceId; + private String modelId; + private String indexNo; + private String indexUpperLimit; + private String indexLowerLimit; + private Integer indexOrder; + private Integer dataLength; + private String indexType; +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/entity/DeviceInfoEntity.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/entity/DeviceInfoEntity.java new file mode 100644 index 0000000..3a2c11d --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/entity/DeviceInfoEntity.java @@ -0,0 +1,46 @@ +package com.iailab.module.device.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.io.Serializable; +import java.math.BigDecimal; +import java.util.Date; + +/** + * 中选设备信息表 + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("t_device_info") +public class DeviceInfoEntity implements Serializable { + private static final long serialVersionUID = 1L; + + /** + * id + */ + private String id; + private String no; + private String name; + private String classNo; + private String className; + private String workshop; + private String model; + private String sn; + private String position; + private String manufacturer; + private String installDate; + private String plcDevNo; + private String pid; + private Date createDate; + private Date updateDate; + private BigDecimal usageRate; + private Integer planTime; + private Integer isMain; + private BigDecimal newnessRate; + private Integer durableYears; + private Long residueTime; + private Long useTime; + +} diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/entity/DeviceMainEntity.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/entity/DeviceMainEntity.java new file mode 100644 index 0000000..26f0e21 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/entity/DeviceMainEntity.java @@ -0,0 +1,42 @@ +package com.iailab.module.device.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.io.Serializable; +import java.util.Date; + +/** + * 中选设备维护记录 + * + * @author PanZhibao + * @Description + * @createTime 2024年05月30日 + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("t_device_main") +public class DeviceMainEntity implements Serializable { + private static final long serialVersionUID = 1L; + + private String id; + + private String devno; + + private String devname; + + private String source; + + private String type; + + private String date; + + private String part; + + private String info; + + private Date regTime; + + private Date createDate; +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/entity/DeviceRunStateEntity.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/entity/DeviceRunStateEntity.java new file mode 100644 index 0000000..71a0f19 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/entity/DeviceRunStateEntity.java @@ -0,0 +1,44 @@ +package com.iailab.module.device.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; + +/** + * 设备运行状态表 + * + * @author lirm ${email} + * @since 1.0.0 2024-05-22 + */ +@Data +@TableName("t_device_run_state") +public class DeviceRunStateEntity implements Serializable { + private static final long serialVersionUID = 1L; + + /** + * id + */ + private Integer id; + /** + * 在线设备数量 + */ + private Integer totalCount; + /** + * 运行设备 + */ + private Integer runCount; + /** + * 停机设备 + */ + private Integer haltCount; + /** + * 离线设备 + */ + private Integer offlineCount; + /** + * 创建时间 + */ + private Date creatorDate; +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/entity/DeviceStatCountEntity.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/entity/DeviceStatCountEntity.java new file mode 100644 index 0000000..0dc80e8 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/entity/DeviceStatCountEntity.java @@ -0,0 +1,45 @@ +package com.iailab.module.device.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.util.Date; + +@Data +@Schema(name = "设备实时统计") +@TableName("t_device_stat_count") +public class DeviceStatCountEntity { + /** + * id + */ + private String id; + /** + * 统计日期 + */ + private Date date; + + /** + * 所有设备 + */ + private Long totalCount; + + /** + * 健康设备 + */ + private Long healthCount; + + /** + * 良好设备 + */ + private Long goodCount; + + /** + * 故障设备 + */ + private Long accidentCount; + /** + * 故障设备 + */ + private Date createDate; +} diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/entity/DeviceStatNewnessEntity.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/entity/DeviceStatNewnessEntity.java new file mode 100644 index 0000000..24c7303 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/entity/DeviceStatNewnessEntity.java @@ -0,0 +1,65 @@ +package com.iailab.module.device.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; + +import java.math.BigDecimal; +import java.util.Date; + +/** + * 设备新度系数统计表 + * + * @author lirm ${email} + * @since 1.0.0 2024-05-22 + */ +@Data +@TableName("t_device_stat_newness") +public class DeviceStatNewnessEntity { + + /** + * id + */ + private String id; + /** + * 设备编号 + */ + private String devNo; + /** + * 设备名称 + */ + private String devName; + /** + * 统计日期 + */ + private Date date; + /** + * 设备使用年限(分) + */ + private Long durableTime; + /** + * 设备使用时长(分) + */ + private Integer runTime; + /** + * 设备剩余时长(分) + */ + private Long residueTime; + /** + * 新度系数 + */ + private BigDecimal newnessRate; + /** + * 设备损耗时长(分) + */ + private Integer lossTime; + + /** + * 损耗系数 + */ + private BigDecimal lossRate; + + /** + * 创建时间 + */ + private Date createDate; +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/entity/DeviceStatUsageEntity.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/entity/DeviceStatUsageEntity.java new file mode 100644 index 0000000..5fa1a4d --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/entity/DeviceStatUsageEntity.java @@ -0,0 +1,51 @@ +package com.iailab.module.device.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; + +import java.math.BigDecimal; +import java.util.Date; + +/** + * 异常设备历史表 + * + * @author lirm ${email} + * @since 1.0.0 2024-05-22 + */ +@Data +@TableName("t_device_stat_usage") +public class DeviceStatUsageEntity { + + /** + * id + */ + private String id; + /** + * 设备编号 + */ + private String devNo; + /** + * 设备名称 + */ + private String devName; + /** + * 统计日期 + */ + private String date; + /** + * 计划运行时长 + */ + private Integer planTime; + /** + * 实绩运行时长 + */ + private Integer runTime; + /** + * 使用率 + */ + private BigDecimal usageRate; + /** + * 创建时间 + */ + private Date createDate; +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/excel/DeviceAbnormalHistoryExcel.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/excel/DeviceAbnormalHistoryExcel.java new file mode 100644 index 0000000..fd92172 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/excel/DeviceAbnormalHistoryExcel.java @@ -0,0 +1,25 @@ +//package com.iailab.module.device.excel; +// +//import cn.afterturn.easypoi.excel.annotation.Excel; +//import lombok.Data; +// +//import java.util.Date; +// +///** +// * 异常设备历史表 +// * +// * @author lirm ${email} +// * @since 1.0.0 2024-05-22 +// */ +//@Data +//public class DeviceAbnormalHistoryExcel { +// @Excel(name = "id") +// private String id; +// @Excel(name = "总设备数") +// private Integer totalCount; +// @Excel(name = "异常数量") +// private Integer abnormalCount; +// @Excel(name = "创建时间") +// private Date creatorDate; +// +//} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/excel/DeviceAccountExcel.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/excel/DeviceAccountExcel.java new file mode 100644 index 0000000..c6d8a3b --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/excel/DeviceAccountExcel.java @@ -0,0 +1,47 @@ +//package com.iailab.module.device.excel; +// +//import cn.afterturn.easypoi.excel.annotation.Excel; +//import lombok.Data; +// +//import java.util.Date; +// +///** +// * 设备台账 +// * +// * @author lirm ${email} +// * @since 1.0.0 2024-05-27 +// */ +//@Data +//public class DeviceAccountExcel { +// @Excel(name = "ID") +// private Integer id; +// @Excel(name = "设备ID") +// private Integer deviceId; +// @Excel(name = "设备名称") +// private String deviceName; +// @Excel(name = "设备编码") +// private String deviceCode; +// @Excel(name = "设备类型") +// private String deviceCategory; +// @Excel(name = "设备分类") +// private String deviceClass; +// @Excel(name = "所属车间") +// private String workShop; +// @Excel(name = "规格型号") +// private String specification; +// @Excel(name = "是否推送工单") +// private Integer isPush; +// @Excel(name = "运行状态") +// private Integer runState; +// @Excel(name = "监测状态") +// private Integer monitorState; +// @Excel(name = "创建人") +// private String creator; +// @Excel(name = "创建时间") +// private Date createDate; +// @Excel(name = "更新人") +// private String updater; +// @Excel(name = "更新时间") +// private Date updateDate; +// +//} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/excel/DeviceAccountHistoryExcel.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/excel/DeviceAccountHistoryExcel.java new file mode 100644 index 0000000..6ea00ab --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/excel/DeviceAccountHistoryExcel.java @@ -0,0 +1,35 @@ +//package com.iailab.module.device.excel; +// +//import cn.afterturn.easypoi.excel.annotation.Excel; +//import lombok.Data; +// +//import java.util.Date; +// +///** +// * 设备台账历史表 +// * +// * @author lirm ${email} +// * @since 1.0.0 2024-05-27 +// */ +//@Data +//public class DeviceAccountHistoryExcel { +// @Excel(name = "id") +// private Integer id; +// @Excel(name = "故障设备") +// private String faultDevice; +// @Excel(name = "故障部件") +// private String faultParts; +// @Excel(name = "故障类型") +// private String faultType; +// @Excel(name = "故障原因") +// private String faultCause; +// @Excel(name = "处理对策") +// private String solution; +// @Excel(name = "处理状态") +// private String state; +// @Excel(name = "影响时长") +// private Integer affectHour; +// @Excel(name = "发生时间") +// private Date creatorDate; +// +//} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/excel/DeviceFaultExcel.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/excel/DeviceFaultExcel.java new file mode 100644 index 0000000..bd5f1fe --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/excel/DeviceFaultExcel.java @@ -0,0 +1,43 @@ +//package com.iailab.module.device.excel; +// +//import cn.afterturn.easypoi.excel.annotation.Excel; +//import lombok.Data; +// +//import java.util.Date; +// +///** +// * 设备故障库; +// * +// * @author lirm ${email} +// * @since 1.0.0 2024-05-23 +// */ +//@Data +//public class DeviceFaultExcel { +// @Excel(name = "id") +// private String id; +// @Excel(name = "设备ID") +// private String deviceId; +// @Excel(name = "设备编号") +// private String deviceCode; +// @Excel(name = "设备名称") +// private String deviceName; +// @Excel(name = "设备信息") +// private String deviceInfo; +// @Excel(name = "故障码") +// private String faultCode; +// @Excel(name = "故障名称") +// private String faultName; +// @Excel(name = "解决方案") +// private String solution; +// @Excel(name = "备注") +// private String remark; +// @Excel(name = "创建人") +// private String creator; +// @Excel(name = "创建时间") +// private Date createDate; +// @Excel(name = "更新人") +// private String updater; +// @Excel(name = "更新时间") +// private Date updateDate; +// +//} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/excel/DeviceHealthStateExcel.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/excel/DeviceHealthStateExcel.java new file mode 100644 index 0000000..a7c4231 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/excel/DeviceHealthStateExcel.java @@ -0,0 +1,33 @@ +//package com.iailab.module.device.excel; +// +//import cn.afterturn.easypoi.excel.annotation.Excel; +//import lombok.Data; +// +//import java.util.Date; +// +///** +// * 设备健康状态表 +// * +// * @author lirm ${email} +// * @since 1.0.0 2024-05-22 +// */ +//@Data +//public class DeviceHealthStateExcel { +// @Excel(name = "id") +// private String id; +// @Excel(name = "总设备数") +// private Integer totalCount; +// @Excel(name = "正常") +// private Integer normal; +// @Excel(name = "一般") +// private Integer common; +// @Excel(name = "较重") +// private Integer heavy; +// @Excel(name = "严重") +// private Integer serious; +// @Excel(name = "特别严重") +// private Integer espserious; +// @Excel(name = "创建时间") +// private Date creatorDate; +// +//} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/excel/DeviceInfoExcel.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/excel/DeviceInfoExcel.java new file mode 100644 index 0000000..951c263 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/excel/DeviceInfoExcel.java @@ -0,0 +1,45 @@ +//package com.iailab.module.device.excel; +// +//import cn.afterturn.easypoi.excel.annotation.Excel; +//import lombok.Data; +// +//import java.util.Date; +// +///** +// * 中选设备信息表 +// * +// * @author lirm ${email} +// * @since 1.0.0 2024-05-28 +// */ +//@Data +//public class DeviceInfoExcel { +// @Excel(name = "id") +// private String id; +// @Excel(name = "设备编号") +// private String no; +// @Excel(name = "设备名称") +// private String name; +// @Excel(name = "分类编号") +// private String classNo; +// @Excel(name = "给料机") +// private String className; +// @Excel(name = "所属车间") +// private String workshop; +// @Excel(name = "规格型号") +// private String model; +// @Excel(name = "出厂序号") +// private String sn; +// @Excel(name = "安装位置") +// private String position; +// @Excel(name = "制造商") +// private String manufacturer; +// @Excel(name = "安装日期") +// private String installDate; +// @Excel(name = "控制系统编号") +// private String plcDevNo; +// @Excel(name = "父ID") +// private String pid; +// @Excel(name = "创建日期") +// private Date createDate; +// +//} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/excel/DeviceRunStateExcel.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/excel/DeviceRunStateExcel.java new file mode 100644 index 0000000..6aff92c --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/excel/DeviceRunStateExcel.java @@ -0,0 +1,29 @@ +//package com.iailab.module.device.excel; +// +//import cn.afterturn.easypoi.excel.annotation.Excel; +//import lombok.Data; +// +//import java.util.Date; +// +///** +// * 设备运行状态表 +// * +// * @author lirm ${email} +// * @since 1.0.0 2024-05-22 +// */ +//@Data +//public class DeviceRunStateExcel { +// @Excel(name = "id") +// private String id; +// @Excel(name = "在线设备数量") +// private Integer totalCount; +// @Excel(name = "运行设备") +// private Integer runCount; +// @Excel(name = "停机设备") +// private Integer haltCount; +// @Excel(name = "离线设备") +// private Integer offlineCount; +// @Excel(name = "创建时间") +// private Date creatorDate; +// +//} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/DeviceAbnormalHistoryService.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/DeviceAbnormalHistoryService.java new file mode 100644 index 0000000..57edd30 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/DeviceAbnormalHistoryService.java @@ -0,0 +1,21 @@ +package com.iailab.module.device.service; + +import com.iailab.framework.common.service.CrudService; +import com.iailab.module.device.dto.DeviceAbnormalHistoryDTO; +import com.iailab.module.device.entity.DeviceAbnormalHistoryEntity; + +import java.util.List; +import java.util.Map; + +/** + * 异常设备历史表 + * + * @author lirm ${email} + * @since 1.0.0 2024-05-22 + */ +public interface DeviceAbnormalHistoryService extends CrudService<DeviceAbnormalHistoryEntity, DeviceAbnormalHistoryDTO> { + + void insertHistory(Map<String, Object> tMap); + + List<DeviceAbnormalHistoryDTO> getlist(Map<String, Object> params); +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/DeviceAccountHistoryService.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/DeviceAccountHistoryService.java new file mode 100644 index 0000000..dd6dbb0 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/DeviceAccountHistoryService.java @@ -0,0 +1,15 @@ +package com.iailab.module.device.service; + +import com.iailab.framework.common.service.CrudService; +import com.iailab.module.device.dto.DeviceAccountHistoryDTO; +import com.iailab.module.device.entity.DeviceAccountHistoryEntity; + +/** + * 设备台账历史表 + * + * @author lirm ${email} + * @since 1.0.0 2024-05-27 + */ +public interface DeviceAccountHistoryService extends CrudService<DeviceAccountHistoryEntity, DeviceAccountHistoryDTO> { + +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/DeviceAccountService.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/DeviceAccountService.java new file mode 100644 index 0000000..d551cfa --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/DeviceAccountService.java @@ -0,0 +1,21 @@ +package com.iailab.module.device.service; + +import com.iailab.framework.common.service.CrudService; +import com.iailab.module.device.dto.DeviceAccountDTO; +import com.iailab.module.device.entity.DeviceAccountEntity; + +import java.util.List; +import java.util.Map; + +/** + * 设备台账; + * + * @author lirm ${email} + * @since 1.0.0 2024-05-20 + */ +public interface DeviceAccountService extends CrudService<DeviceAccountEntity, DeviceAccountDTO> { + + void insertDeviceList(Map<String, String> tMap); + + List<String> getDeviceIdList(); +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/DeviceEvaluateIndexService.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/DeviceEvaluateIndexService.java new file mode 100644 index 0000000..ada6369 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/DeviceEvaluateIndexService.java @@ -0,0 +1,19 @@ +package com.iailab.module.device.service; + +import com.iailab.framework.common.service.BaseService; +import com.iailab.module.device.dto.DeviceEvaluateIndexDTO; +import com.iailab.module.device.entity.DeviceEvaluateIndexEntity; + +import java.util.List; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年06月29日 + */ +public interface DeviceEvaluateIndexService extends BaseService<DeviceEvaluateIndexEntity> { + + List<DeviceEvaluateIndexDTO> listByEvaluateId(String evaluateId); + + void updateList(String evaluateId, List<DeviceEvaluateIndexDTO> dtos); +} diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/DeviceFaultService.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/DeviceFaultService.java new file mode 100644 index 0000000..f618822 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/DeviceFaultService.java @@ -0,0 +1,17 @@ +package com.iailab.module.device.service; + +import com.iailab.framework.common.service.CrudService; +import com.iailab.module.device.dto.DeviceFaultDTO; +import com.iailab.module.device.entity.DeviceFaultEntity; + +/** + * 设备故障库; + * + * @author lirm ${email} + * @since 1.0.0 2024-05-23 + */ +public interface DeviceFaultService extends CrudService<DeviceFaultEntity, DeviceFaultDTO> { + + DeviceFaultDTO getSolution(DeviceFaultDTO queryDto); + +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/DeviceHealthAlarmDetailService.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/DeviceHealthAlarmDetailService.java new file mode 100644 index 0000000..cc66432 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/DeviceHealthAlarmDetailService.java @@ -0,0 +1,13 @@ +package com.iailab.module.device.service; + +import com.iailab.framework.common.service.BaseService; +import com.iailab.module.device.entity.DeviceHealthAlarmDetailEntity; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年06月28日 + */ +public interface DeviceHealthAlarmDetailService extends BaseService<DeviceHealthAlarmDetailEntity> { + +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/DeviceHealthAlarmService.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/DeviceHealthAlarmService.java new file mode 100644 index 0000000..3025883 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/DeviceHealthAlarmService.java @@ -0,0 +1,19 @@ +package com.iailab.module.device.service; + +import com.iailab.framework.common.page.PageData; +import com.iailab.framework.common.service.BaseService; +import com.iailab.module.device.dto.DeviceHealthAlarmDTO; +import com.iailab.module.device.entity.DeviceHealthAlarmEntity; + +import java.util.Map; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年06月28日 + */ +public interface DeviceHealthAlarmService extends BaseService<DeviceHealthAlarmEntity> { + PageData<DeviceHealthAlarmDTO> page(Map<String, Object> params); + + DeviceHealthAlarmDTO get(String id); +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/DeviceHealthEvaluateService.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/DeviceHealthEvaluateService.java new file mode 100644 index 0000000..e68ba03 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/DeviceHealthEvaluateService.java @@ -0,0 +1,37 @@ +package com.iailab.module.device.service; + +import com.iailab.framework.common.page.PageData; +import com.iailab.framework.common.service.BaseService; +import com.iailab.module.device.dto.DeviceHealthEvaluateDTO; +import com.iailab.module.device.entity.DeviceHealthEvaluateEntity; + +import java.util.List; +import java.util.Map; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年06月29日 + */ +public interface DeviceHealthEvaluateService extends BaseService<DeviceHealthEvaluateEntity> { + + PageData<DeviceHealthEvaluateDTO> page(Map<String, Object> params); + + List<DeviceHealthEvaluateDTO> list(Map<String, Object> params); + + DeviceHealthEvaluateDTO get(String id); + + void save(DeviceHealthEvaluateDTO dto); + + void update(DeviceHealthEvaluateDTO dto); + + void updateReport(DeviceHealthEvaluateDTO dto); + + void delete(String[] ids); + + void enableByIds(String[] ids); + + void disableByIds(String[] ids); + + Long selectHealthLevalCount(String healthLeval); +} diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/DeviceHealthReportDataService.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/DeviceHealthReportDataService.java new file mode 100644 index 0000000..7ef6b4d --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/DeviceHealthReportDataService.java @@ -0,0 +1,23 @@ +package com.iailab.module.device.service; + +import com.iailab.framework.common.service.BaseService; +import com.iailab.module.device.dto.DeviceHealthReportDataDTO; +import com.iailab.module.device.entity.DeviceHealthReportDataEntity; + +import java.util.Date; +import java.util.List; +import java.util.Map; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年06月28日 + */ +public interface DeviceHealthReportDataService extends BaseService<DeviceHealthReportDataEntity> { + + List<DeviceHealthReportDataDTO> listByReportId(String reportId); + + void save(DeviceHealthReportDataDTO dto); + + void migrationDeviceHealthReportData(Map<String, Date> tMap); +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/DeviceHealthReportService.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/DeviceHealthReportService.java new file mode 100644 index 0000000..163cba0 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/DeviceHealthReportService.java @@ -0,0 +1,25 @@ +package com.iailab.module.device.service; + +import com.iailab.framework.common.page.PageData; +import com.iailab.framework.common.service.BaseService; +import com.iailab.module.device.dto.DeviceHealthReportDTO; +import com.iailab.module.device.entity.DeviceHealthReportEntity; + +import java.util.Date; +import java.util.Map; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年06月28日 + */ +public interface DeviceHealthReportService extends BaseService<DeviceHealthReportEntity> { + + PageData<DeviceHealthReportDTO> page(Map<String, Object> params); + + DeviceHealthReportDTO get(String id); + + void save(DeviceHealthReportDTO dto); + + void migrationDeviceHealthReport(Map<String, Date> tMap); +} diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/DeviceHealthStateService.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/DeviceHealthStateService.java new file mode 100644 index 0000000..67c09d1 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/DeviceHealthStateService.java @@ -0,0 +1,19 @@ +package com.iailab.module.device.service; + +import com.iailab.framework.common.service.CrudService; +import com.iailab.module.device.dto.DeviceHealthStateDTO; +import com.iailab.module.device.entity.DeviceHealthStateEntity; + +import java.util.Map; + +/** + * 设备健康状态表 + * + * @author lirm ${email} + * @since 1.0.0 2024-05-22 + */ +public interface DeviceHealthStateService extends CrudService<DeviceHealthStateEntity, DeviceHealthStateDTO> { + + void insertHealthState(Map<String, Object> tMap); + +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/DeviceIndexService.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/DeviceIndexService.java new file mode 100644 index 0000000..8ed790b --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/DeviceIndexService.java @@ -0,0 +1,20 @@ +package com.iailab.module.device.service; + +import com.iailab.framework.common.service.CrudService; +import com.iailab.module.device.dto.DeviceIndexDTO; +import com.iailab.module.device.entity.DeviceIndexEntity; + +import java.util.List; + +/** + * 设备故障库; + * + * @author lirm ${email} + * @since 1.0.0 2024-05-23 + */ +public interface DeviceIndexService extends CrudService<DeviceIndexEntity, DeviceIndexDTO> { + + void deleteByDeviceId(String id); + + List<DeviceIndexDTO> getByDeviceId(String id); +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/DeviceInfoService.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/DeviceInfoService.java new file mode 100644 index 0000000..3fde83c --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/DeviceInfoService.java @@ -0,0 +1,33 @@ +package com.iailab.module.device.service; + +import com.iailab.framework.common.page.PageData; +import com.iailab.framework.common.service.BaseService; +import com.iailab.module.device.dto.DeviceInfoDTO; +import com.iailab.module.device.entity.DeviceInfoEntity; + +import java.util.List; +import java.util.Map; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年05月27日 + */ +public interface DeviceInfoService extends BaseService<DeviceInfoEntity> { + + List<DeviceInfoDTO> list(Map<String, Object> params); + + void syncData(); + + PageData<DeviceInfoDTO> page(Map<String, Object> params); + + List<DeviceInfoDTO> getchildrenList(String deviceId); + + DeviceInfoDTO get(String id); + + void updateById(DeviceInfoDTO dto); + + DeviceInfoDTO getByDevNo(String devNo); + + Long getTotal(); +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/DeviceMainService.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/DeviceMainService.java new file mode 100644 index 0000000..8880d59 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/DeviceMainService.java @@ -0,0 +1,16 @@ +package com.iailab.module.device.service; + +import com.iailab.framework.common.service.BaseService; +import com.iailab.module.device.entity.DeviceMainEntity; + +import java.util.Date; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年05月30日 + */ +public interface DeviceMainService extends BaseService<DeviceMainEntity> { + + Integer getCount(String devno, Date startTime, Date endTime); +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/DeviceRunStateService.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/DeviceRunStateService.java new file mode 100644 index 0000000..edcc59c --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/DeviceRunStateService.java @@ -0,0 +1,19 @@ +package com.iailab.module.device.service; + + +import com.iailab.framework.common.service.CrudService; +import com.iailab.module.device.dto.DeviceRunStateDTO; +import com.iailab.module.device.entity.DeviceRunStateEntity; + +import java.util.Map; + +/** + * 设备运行状态表 + * + * @author lirm ${email} + * @since 1.0.0 2024-05-22 + */ +public interface DeviceRunStateService extends CrudService<DeviceRunStateEntity, DeviceRunStateDTO> { + + void insertRunState(Map<String, Integer> tMap); +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/DeviceStatCountService.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/DeviceStatCountService.java new file mode 100644 index 0000000..320ae9c --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/DeviceStatCountService.java @@ -0,0 +1,21 @@ +package com.iailab.module.device.service; + +import com.iailab.framework.common.service.CrudService; +import com.iailab.module.device.dto.DeviceStatCountDTO; +import com.iailab.module.device.entity.DeviceStatCountEntity; + +import java.util.List; +import java.util.Map; + +/** + * 设备健康状态表 + * + * @author lirm ${email} + * @since 1.0.0 2024-05-22 + */ +public interface DeviceStatCountService extends CrudService<DeviceStatCountEntity, DeviceStatCountDTO> { + + DeviceStatCountDTO getDeviceStatCount(); + + List<DeviceStatCountDTO> getHistory(Map<String, Object> params); +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/DeviceStatNewnessService.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/DeviceStatNewnessService.java new file mode 100644 index 0000000..cc9d7d7 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/DeviceStatNewnessService.java @@ -0,0 +1,21 @@ +package com.iailab.module.device.service; + +import com.iailab.framework.common.page.PageData; +import com.iailab.framework.common.service.BaseService; +import com.iailab.module.device.dto.DeviceStatNewnessDTO; +import com.iailab.module.device.entity.DeviceStatNewnessEntity; + +import java.util.Date; +import java.util.List; +import java.util.Map; + +public interface DeviceStatNewnessService extends BaseService<DeviceStatNewnessEntity> { + + void statNewness(List<DeviceStatNewnessEntity> list, Date statDate); + + DeviceStatNewnessEntity getLastByNo(String no); + + List<DeviceStatNewnessDTO> list(Map<String, Object> params); + + PageData<DeviceStatNewnessDTO> page(Map<String, Object> params); +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/DeviceStatUsageService.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/DeviceStatUsageService.java new file mode 100644 index 0000000..ca1bf79 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/DeviceStatUsageService.java @@ -0,0 +1,19 @@ +package com.iailab.module.device.service; + +import com.iailab.framework.common.service.BaseService; +import com.iailab.module.device.dto.DeviceCurrentRateDTO; +import com.iailab.module.device.entity.DeviceStatUsageEntity; + +import java.util.List; +import java.util.Map; + +public interface DeviceStatUsageService extends BaseService<DeviceStatUsageEntity> { + + void syncData(); + + DeviceStatUsageEntity getLastByNo(String no); + + DeviceCurrentRateDTO getDeviceCurrentRate(); + + List<DeviceStatUsageEntity> list(Map<String, Object> params); +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/impl/DeviceAbnormalHistoryServiceImpl.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/impl/DeviceAbnormalHistoryServiceImpl.java new file mode 100644 index 0000000..7b63f71 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/impl/DeviceAbnormalHistoryServiceImpl.java @@ -0,0 +1,57 @@ +package com.iailab.module.device.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.iailab.framework.common.service.impl.CrudServiceImpl; +import com.iailab.module.device.dao.DeviceAbnormalHistoryDao; +import com.iailab.module.device.dto.DeviceAbnormalHistoryDTO; +import com.iailab.module.device.entity.DeviceAbnormalHistoryEntity; +import com.iailab.module.device.service.DeviceAbnormalHistoryService; +import org.apache.commons.lang3.StringUtils; +import org.springframework.stereotype.Service; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * 异常设备历史表 + * + * @author lirm ${email} + * @since 1.0.0 2024-05-22 + */ +@Service +public class DeviceAbnormalHistoryServiceImpl extends CrudServiceImpl<DeviceAbnormalHistoryDao, DeviceAbnormalHistoryEntity, DeviceAbnormalHistoryDTO> implements DeviceAbnormalHistoryService { + + @Override + public QueryWrapper<DeviceAbnormalHistoryEntity> getWrapper(Map<String, Object> params){ + String id = (String)params.get("id"); + String endDate = (String)params.get("endDate"); + + QueryWrapper<DeviceAbnormalHistoryEntity> wrapper = new QueryWrapper<>(); + wrapper.eq(StringUtils.isNotBlank(id), "id", id); + + return wrapper; + } + + + @Override + public void insertHistory(Map<String, Object> tMap) { + Map<String, Integer> map = new HashMap<>(); + int normal = Integer.parseInt(tMap.get("normal").toString()); + int common = Integer.parseInt(tMap.get("common").toString()); + int heavy = Integer.parseInt(tMap.get("heavy").toString()); + int serious = Integer.parseInt(tMap.get("serious").toString()); + int espSerious = Integer.parseInt(tMap.get("espSerious").toString()); + int total_count = normal + common + heavy + serious + espSerious; + int abnormal_count = common + heavy + serious + espSerious; + map.put("total_count",total_count); + map.put("abnormal_count",abnormal_count); + baseDao.insertHistory(map); + } + + @Override + public List<DeviceAbnormalHistoryDTO> getlist(Map<String, Object> params) { + return baseDao.getlist(params); + } + +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/impl/DeviceAccountHistoryServiceImpl.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/impl/DeviceAccountHistoryServiceImpl.java new file mode 100644 index 0000000..497ed02 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/impl/DeviceAccountHistoryServiceImpl.java @@ -0,0 +1,32 @@ +package com.iailab.module.device.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.iailab.framework.common.service.impl.CrudServiceImpl; +import com.iailab.module.device.dao.DeviceAccountHistoryDao; +import com.iailab.module.device.dto.DeviceAccountHistoryDTO; +import com.iailab.module.device.entity.DeviceAccountHistoryEntity; +import com.iailab.module.device.service.DeviceAccountHistoryService; +import org.apache.commons.lang3.StringUtils; +import org.springframework.stereotype.Service; + +import java.util.Map; + +/** + * 设备台账历史表 + * + * @author lirm ${email} + * @since 1.0.0 2024-05-27 + */ +@Service +public class DeviceAccountHistoryServiceImpl extends CrudServiceImpl<DeviceAccountHistoryDao, DeviceAccountHistoryEntity, DeviceAccountHistoryDTO> implements DeviceAccountHistoryService { + + @Override + public QueryWrapper<DeviceAccountHistoryEntity> getWrapper(Map<String, Object> params){ + String deviceId = (String)params.get("deviceId"); + + QueryWrapper<DeviceAccountHistoryEntity> wrapper = new QueryWrapper<>(); + wrapper.eq(StringUtils.isNotBlank(deviceId), "device_id", deviceId) + .orderByDesc("create_date"); + return wrapper; + } +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/impl/DeviceAccountServiceImpl.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/impl/DeviceAccountServiceImpl.java new file mode 100644 index 0000000..8ee8952 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/impl/DeviceAccountServiceImpl.java @@ -0,0 +1,122 @@ +package com.iailab.module.device.service.impl; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.iailab.framework.common.service.impl.CrudServiceImpl; +import com.iailab.common.utils.HttpsRequest; +import com.iailab.module.device.dao.DeviceAccountDao; +import com.iailab.module.device.dto.DeviceAccountDTO; +import com.iailab.module.device.entity.DeviceAccountEntity; +import com.iailab.module.device.entity.DeviceAccountHistoryEntity; +import com.iailab.module.device.service.DeviceAccountHistoryService; +import com.iailab.module.device.service.DeviceAccountService; +import org.apache.commons.lang3.StringUtils; +import javax.annotation.Resource; +import org.springframework.stereotype.Service; +import org.springframework.util.CollectionUtils; + +import java.util.*; + +/** + * 设备台账; + * + * @author lirm ${email} + * @since 1.0.0 2024-05-20 + */ +@Service +public class DeviceAccountServiceImpl extends CrudServiceImpl<DeviceAccountDao, DeviceAccountEntity, DeviceAccountDTO> implements DeviceAccountService { + @Resource + DeviceAccountHistoryService deviceAccountHistoryService; + @Resource + HttpsRequest httpsRequest; + + @Override + public QueryWrapper<DeviceAccountEntity> getWrapper(Map<String, Object> params) { + String deviceCode = (String) params.get("deviceCode"); + String deviceName = (String) params.get("deviceName"); + + QueryWrapper<DeviceAccountEntity> wrapper = new QueryWrapper<>(); + wrapper.like(StringUtils.isNotBlank(deviceCode), "device_code", deviceCode); + wrapper.like(StringUtils.isNotBlank(deviceName), "device_name", deviceName); + wrapper.orderByAsc("device_id"); + return wrapper; + } + + + @Override + public void insertDeviceList(Map<String, String> tMap) { + Map<String, String> queryParams = new HashMap<>(); + queryParams.put("per_page", "100"); + String responseStr = httpsRequest.doGetDeviceList(tMap.get("url"), queryParams, "utf-8", tMap.get("token")); + JSONObject responseObj = JSON.parseObject(responseStr); + if ("200".equals(responseObj.get("code").toString())) { + JSONObject dataObject = (JSONObject) responseObj.get("data"); + JSONArray stateArray = dataObject.getJSONArray("items"); + if (!CollectionUtils.isEmpty(stateArray)) { + if (!CollectionUtils.isEmpty(stateArray)) { + baseDao.updateMonitorState();//先更新监测状态为0 + for (int i = 0; i < stateArray.size(); i++) { + JSONObject item = stateArray.getJSONObject(i); + if (!item.get("de_serial_no").toString().contains("ams")) { + DeviceAccountEntity entity = baseDao.getByDeviceId(Integer.parseInt(item.get("id").toString())); + if (entity != null) { + entity.setRunState(Integer.parseInt(item.get("status").toString())); + if(Integer.parseInt(item.get("status").toString()) == 0){ + entity.setRemark("设备离线"); + }else if(Integer.parseInt(item.get("status").toString()) == 1){ + entity.setRemark("设备空闲停机"); + }if(Integer.parseInt(item.get("status").toString()) == 2){ + entity.setRemark("设备运行正常"); + } + entity.setMonitorState(1); + entity.setUpdateDate(new Date()); + baseDao.updateById(entity); + } else { + //解析json + DeviceAccountEntity deviceAccountEntity = new DeviceAccountEntity(); + deviceAccountEntity.setId(UUID.randomUUID().toString()); + deviceAccountEntity.setDeviceId(Integer.parseInt(item.get("id").toString())); + deviceAccountEntity.setDeviceCode(item.get("de_serial_no").toString()); + deviceAccountEntity.setDeviceName(item.get("name").toString()); + deviceAccountEntity.setWorkShop(item.get("category").toString()); + deviceAccountEntity.setDeviceClass(item.get("class").toString()); + deviceAccountEntity.setRunState(Integer.parseInt(item.get("status").toString())); + deviceAccountEntity.setMonitorState(1); + deviceAccountEntity.setIsPush(0); + deviceAccountEntity.setCreateDate(new Date()); + if(Integer.parseInt(item.get("status").toString()) == 0){ + entity.setRemark("设备离线"); + }else if(Integer.parseInt(item.get("status").toString()) == 1){ + entity.setRemark("设备空闲停机"); + }if(Integer.parseInt(item.get("status").toString()) == 2){ + entity.setRemark("设备运行正常"); + } + baseDao.insert(deviceAccountEntity); + } + //解析json + DeviceAccountHistoryEntity deviceAccountHistoryEntity = new DeviceAccountHistoryEntity(); + deviceAccountHistoryEntity.setId(UUID.randomUUID().toString()); + deviceAccountHistoryEntity.setDeviceId(Integer.parseInt(item.get("id").toString())); + deviceAccountHistoryEntity.setDeviceCode(item.get("de_serial_no").toString()); + deviceAccountHistoryEntity.setDeviceName(item.get("name").toString()); + deviceAccountHistoryEntity.setWorkShop(item.get("category").toString()); + deviceAccountHistoryEntity.setDeviceClass(item.get("class").toString()); + deviceAccountHistoryEntity.setRunState(Integer.parseInt(item.get("status").toString())); + deviceAccountHistoryEntity.setMonitorState(1); + deviceAccountHistoryEntity.setIsPush(0); + deviceAccountHistoryEntity.setCreateDate(new Date()); + deviceAccountHistoryService.insert(deviceAccountHistoryEntity); + } + } + } + } + } + } + + @Override + public List<String> getDeviceIdList() { + return baseDao.getDeviceIdList(); + } +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/impl/DeviceEvaluateIndexServiceImpl.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/impl/DeviceEvaluateIndexServiceImpl.java new file mode 100644 index 0000000..62d733b --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/impl/DeviceEvaluateIndexServiceImpl.java @@ -0,0 +1,54 @@ +package com.iailab.module.device.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.iailab.framework.common.service.impl.BaseServiceImpl; +import com.iailab.framework.common.util.object.ConvertUtils; +import com.iailab.module.device.dao.DeviceEvaluateIndexDao; +import com.iailab.module.device.dto.DeviceEvaluateIndexDTO; +import com.iailab.module.device.entity.DeviceEvaluateIndexEntity; +import com.iailab.module.device.service.DeviceEvaluateIndexService; +import org.springframework.stereotype.Service; +import org.springframework.util.CollectionUtils; + +import java.util.List; +import java.util.UUID; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年06月29日 + */ +@Service +public class DeviceEvaluateIndexServiceImpl extends BaseServiceImpl<DeviceEvaluateIndexDao, DeviceEvaluateIndexEntity> + implements DeviceEvaluateIndexService { + + @Override + public List<DeviceEvaluateIndexDTO> listByEvaluateId(String evaluateId) { + QueryWrapper<DeviceEvaluateIndexEntity> wrapper = new QueryWrapper<>(); + wrapper.eq("evaluate_id", evaluateId).orderByAsc("param_order"); + List<DeviceEvaluateIndexEntity> list = baseDao.selectList(wrapper); + return ConvertUtils.sourceToTarget(list, DeviceEvaluateIndexDTO.class); + } + + @Override + public void updateList(String evaluateId, List<DeviceEvaluateIndexDTO> dtos) { + this.deleteByEvaluateId(evaluateId); + if(!CollectionUtils.isEmpty(dtos)) { + dtos.forEach(item -> { + DeviceEvaluateIndexEntity entity = ConvertUtils.sourceToTarget(item, DeviceEvaluateIndexEntity.class); + entity.setId(UUID.randomUUID().toString()); + entity.setEvaluateId(evaluateId); + baseDao.insert(entity); + }); + } + + } + + private void deleteByEvaluateId(String evaluateId) { + QueryWrapper<DeviceEvaluateIndexEntity> wrapper = new QueryWrapper<>(); + wrapper.eq("evaluate_id", evaluateId); + baseDao.delete(wrapper); + } + + +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/impl/DeviceFaultServiceImpl.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/impl/DeviceFaultServiceImpl.java new file mode 100644 index 0000000..b896470 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/impl/DeviceFaultServiceImpl.java @@ -0,0 +1,47 @@ +package com.iailab.module.device.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.iailab.framework.common.service.impl.CrudServiceImpl; +import com.iailab.framework.common.util.object.ConvertUtils; +import com.iailab.module.device.dao.DeviceFaultDao; +import com.iailab.module.device.dto.DeviceFaultDTO; +import com.iailab.module.device.entity.DeviceFaultEntity; +import com.iailab.module.device.service.DeviceFaultService; +import org.apache.commons.lang3.StringUtils; +import org.springframework.stereotype.Service; + +import java.util.Map; + +/** + * 设备故障库; + * + * @author lirm ${email} + * @since 1.0.0 2024-05-23 + */ +@Service +public class DeviceFaultServiceImpl extends CrudServiceImpl<DeviceFaultDao, DeviceFaultEntity, DeviceFaultDTO> implements DeviceFaultService { + + @Override + public QueryWrapper<DeviceFaultEntity> getWrapper(Map<String, Object> params) { + String className = (String) params.get("className"); + String faultType = (String) params.get("faultType"); + + QueryWrapper<DeviceFaultEntity> wrapper = new QueryWrapper<>(); + wrapper.like(StringUtils.isNotBlank(className), "class_name", className) + .like(StringUtils.isNotBlank(faultType), "fault_type", faultType); + + return wrapper; + } + + @Override + public DeviceFaultDTO getSolution(DeviceFaultDTO queryDto) { + QueryWrapper<DeviceFaultEntity> wrapper = new QueryWrapper<>(); + wrapper.eq("class_no", queryDto.getClassNo()) + .eq("index_type", queryDto.getIndexType()) + .eq("fault_type", queryDto.getFaultType()); + DeviceFaultEntity entity = baseDao.selectOne(wrapper); + return ConvertUtils.sourceToTarget(entity, DeviceFaultDTO.class); + } + + +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/impl/DeviceHealthAlarmDetailServiceImpl.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/impl/DeviceHealthAlarmDetailServiceImpl.java new file mode 100644 index 0000000..4f0cdbd --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/impl/DeviceHealthAlarmDetailServiceImpl.java @@ -0,0 +1,19 @@ +package com.iailab.module.device.service.impl; + +import com.iailab.framework.common.service.impl.BaseServiceImpl; +import com.iailab.module.device.dao.DeviceHealthAlarmDetailDao; +import com.iailab.module.device.entity.DeviceHealthAlarmDetailEntity; +import com.iailab.module.device.service.DeviceHealthAlarmDetailService; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年06月28日 + */ +@Slf4j +@Service +public class DeviceHealthAlarmDetailServiceImpl extends BaseServiceImpl<DeviceHealthAlarmDetailDao, DeviceHealthAlarmDetailEntity> + implements DeviceHealthAlarmDetailService { +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/impl/DeviceHealthAlarmServiceImpl.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/impl/DeviceHealthAlarmServiceImpl.java new file mode 100644 index 0000000..946d667 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/impl/DeviceHealthAlarmServiceImpl.java @@ -0,0 +1,55 @@ +package com.iailab.module.device.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.iailab.framework.common.constant.Constant; +import com.iailab.framework.common.page.PageData; +import com.iailab.framework.common.service.impl.BaseServiceImpl; +import com.iailab.module.device.dao.DeviceHealthAlarmDao; +import com.iailab.module.device.dto.DeviceHealthAlarmDTO; +import com.iailab.module.device.entity.DeviceHealthAlarmEntity; +import com.iailab.module.device.service.DeviceHealthAlarmService; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import org.springframework.stereotype.Service; + +import java.util.Map; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年06月28日 + */ +@Slf4j +@Service +public class DeviceHealthAlarmServiceImpl extends BaseServiceImpl<DeviceHealthAlarmDao, DeviceHealthAlarmEntity> + implements DeviceHealthAlarmService { + @Override + public PageData<DeviceHealthAlarmDTO> page(Map<String, Object> params) { + IPage<DeviceHealthAlarmEntity> page = baseDao.selectPage( + getPage(params, Constant.CREATE_DATE, false), + getWrapper(params) + ); + return getPageData(page, DeviceHealthAlarmDTO.class); + } + + @Override + public DeviceHealthAlarmDTO get(String id) { + return baseDao.getInfo(id); + } + + private QueryWrapper<DeviceHealthAlarmEntity> getWrapper(Map<String, Object> params) { + String devNo = (String) params.get("devNo"); + String devName = (String) params.get("devName"); + String faultName = (String) params.get("faultName"); + String startTime = (String) params.get("startTime"); + String endTime = (String) params.get("endTime"); + QueryWrapper<DeviceHealthAlarmEntity> wrapper = new QueryWrapper<>(); + wrapper.like(StringUtils.isNotBlank(devNo), "dev_no", devNo) + .like(StringUtils.isNotBlank(devName), "dev_name", devName) + .eq(StringUtils.isNotBlank(faultName), "fault_name", faultName) + .ge(StringUtils.isNotBlank(startTime), "fault_time", startTime) + .le(StringUtils.isNotBlank(endTime), "fault_time", endTime); + return wrapper; + } +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/impl/DeviceHealthEvaluateServiceImpl.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/impl/DeviceHealthEvaluateServiceImpl.java new file mode 100644 index 0000000..061d544 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/impl/DeviceHealthEvaluateServiceImpl.java @@ -0,0 +1,142 @@ +package com.iailab.module.device.service.impl; + +import com.alibaba.nacos.client.naming.utils.CollectionUtils; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.iailab.framework.common.constant.Constant; +import com.iailab.common.enums.IsEnableEnum; +import com.iailab.framework.common.page.PageData; +import com.iailab.framework.common.service.impl.BaseServiceImpl; +import com.iailab.framework.common.util.object.ConvertUtils; +import com.iailab.module.device.dao.DeviceHealthEvaluateDao; +import com.iailab.module.device.dto.DeviceHealthEvaluateDTO; +import com.iailab.module.device.entity.DeviceHealthEvaluateEntity; +import com.iailab.module.device.service.DeviceEvaluateIndexService; +import com.iailab.module.device.service.DeviceHealthEvaluateService; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import javax.annotation.Resource; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.*; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年06月29日 + */ +@Slf4j +@Service +public class DeviceHealthEvaluateServiceImpl extends BaseServiceImpl<DeviceHealthEvaluateDao, DeviceHealthEvaluateEntity> + implements DeviceHealthEvaluateService { + + @Resource + private DeviceEvaluateIndexService deviceEvaluateIndexService; + + @Override + public PageData<DeviceHealthEvaluateDTO> page(Map<String, Object> params) { + IPage<DeviceHealthEvaluateEntity> page = baseDao.selectPage( + getPage(params, Constant.CREATE_DATE, false), + getWrapper(params).orderByAsc("dev_name") + ); + return getPageData(page, DeviceHealthEvaluateDTO.class); + } + + @Override + public List<DeviceHealthEvaluateDTO> list(Map<String, Object> params) { + List<DeviceHealthEvaluateEntity> list = baseDao.selectList(getWrapper(params)); + + return ConvertUtils.sourceToTarget(list, DeviceHealthEvaluateDTO.class); + } + + private QueryWrapper<DeviceHealthEvaluateEntity> getWrapper(Map<String, Object> params) { + String devId = (String) params.get("devId"); + String devName = (String) params.get("devName"); + String healthLevel = (String) params.get("healthLevel"); + Integer isEnable = params.get("isEnable") == null ? null : Integer.parseInt(params.get("isEnable").toString()); + QueryWrapper<DeviceHealthEvaluateEntity> wrapper = new QueryWrapper<>(); + wrapper.eq(StringUtils.isNotBlank(devId), "dev_id", devId) + .eq(isEnable != null, "is_enable", isEnable) + .like(StringUtils.isNotBlank(devName), "dev_name", devName) + .eq(StringUtils.isNotBlank(healthLevel), "health_level", healthLevel); + return wrapper; + } + + @Override + public DeviceHealthEvaluateDTO get(String id) { + DeviceHealthEvaluateEntity entity = baseDao.selectById(id); + DeviceHealthEvaluateDTO result = ConvertUtils.sourceToTarget(entity, DeviceHealthEvaluateDTO.class); + result.setIndexList(deviceEvaluateIndexService.listByEvaluateId(id)); + return result; + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void save(DeviceHealthEvaluateDTO dto) { + DeviceHealthEvaluateEntity entity = ConvertUtils.sourceToTarget(dto, DeviceHealthEvaluateEntity.class); + entity.setId(UUID.randomUUID().toString()); + entity.setCreateDate(new Date()); + insert(entity); + deviceEvaluateIndexService.updateList(entity.getId(), dto.getIndexList()); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void update(DeviceHealthEvaluateDTO dto) { + DeviceHealthEvaluateEntity entity = ConvertUtils.sourceToTarget(dto, DeviceHealthEvaluateEntity.class); + entity.setUpdateDate(new Date()); + updateById(entity); + deviceEvaluateIndexService.updateList(entity.getId(), dto.getIndexList()); + } + + @Override + public void updateReport(DeviceHealthEvaluateDTO dto) { + DeviceHealthEvaluateEntity entity = ConvertUtils.sourceToTarget(dto, DeviceHealthEvaluateEntity.class); + entity.setUpdateDate(new Date()); + updateById(entity); + } + + + @Override + @Transactional(rollbackFor = Exception.class) + public void delete(String[] ids) { + baseDao.deleteBatchIds(Arrays.asList(ids)); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void enableByIds(String[] ids) { + if (CollectionUtils.isEmpty(Arrays.asList(ids))) { + return; + } + Arrays.asList(ids).forEach(item -> { + DeviceHealthEvaluateEntity entity = new DeviceHealthEvaluateEntity(); + entity.setId(item); + entity.setIsEnable(IsEnableEnum.ENABLE.value()); + baseDao.updateById(entity); + }); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void disableByIds(String[] ids) { + if (CollectionUtils.isEmpty(Arrays.asList(ids))) { + return; + } + Arrays.asList(ids).forEach(item -> { + DeviceHealthEvaluateEntity entity = new DeviceHealthEvaluateEntity(); + entity.setId(item); + entity.setIsEnable(IsEnableEnum.DISABLE.value()); + baseDao.updateById(entity); + }); + } + + @Override + public Long selectHealthLevalCount(String healthLeval) { + QueryWrapper<DeviceHealthEvaluateEntity> wrapper = new QueryWrapper<>(); + wrapper.eq(StringUtils.isNotBlank(healthLeval),"health_level",healthLeval); + wrapper.eq("is_enable",1); + return baseDao.selectCount(wrapper); + } +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/impl/DeviceHealthReportDataServiceImpl.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/impl/DeviceHealthReportDataServiceImpl.java new file mode 100644 index 0000000..3bea22a --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/impl/DeviceHealthReportDataServiceImpl.java @@ -0,0 +1,68 @@ +package com.iailab.module.device.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.iailab.framework.common.service.impl.BaseServiceImpl; +import com.iailab.framework.common.util.object.ConvertUtils; +import com.iailab.common.utils.DateUtils; +import com.iailab.module.device.dao.DeviceHealthReportDataDao; +import com.iailab.module.device.dto.DeviceHealthReportDataDTO; +import com.iailab.module.device.entity.DeviceHealthReportDataEntity; +import com.iailab.module.device.service.DeviceHealthReportDataService; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import org.springframework.stereotype.Service; +import org.springframework.util.CollectionUtils; + +import java.util.Date; +import java.util.List; +import java.util.Map; +import java.util.UUID; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年06月28日 + */ +@Slf4j +@Service +public class DeviceHealthReportDataServiceImpl extends BaseServiceImpl<DeviceHealthReportDataDao, DeviceHealthReportDataEntity> + implements DeviceHealthReportDataService { + + + @Override + public List<DeviceHealthReportDataDTO> listByReportId(String reportId) { + QueryWrapper<DeviceHealthReportDataEntity> wrapper = new QueryWrapper<>(); + wrapper.eq("report_id", reportId) + .orderByAsc("sort"); + List<DeviceHealthReportDataEntity> list = baseDao.selectList(wrapper); + return ConvertUtils.sourceToTarget(list, DeviceHealthReportDataDTO.class); + } + + @Override + public void save(DeviceHealthReportDataDTO dto) { + DeviceHealthReportDataEntity entity = ConvertUtils.sourceToTarget(dto, DeviceHealthReportDataEntity.class); + entity.setId(UUID.randomUUID().toString()); + entity.setCreateDate(new Date()); + insert(entity); + } + + @Override + public void migrationDeviceHealthReportData(Map<String, Date> tMap) { + List<DeviceHealthReportDataEntity> list = baseDao.selectList(getDateWrapper(tMap)); + if (CollectionUtils.isEmpty(list)){ + return; + } + baseDao.migration(list); + baseDao.delete(getDateWrapper(tMap)); + } + + public QueryWrapper<DeviceHealthReportDataEntity> getDateWrapper(Map<String, Date> params) { + String startDate = DateUtils.format(params.get("startdate"),DateUtils.DATE_TIME_PATTERN); + String endDate = DateUtils.format(params.get("enddate"),DateUtils.DATE_TIME_PATTERN); + + QueryWrapper<DeviceHealthReportDataEntity> wrapper = new QueryWrapper<>(); + wrapper.ge(StringUtils.isNotBlank(startDate), "create_date", startDate); + wrapper.le(StringUtils.isNotBlank(endDate), "create_date", endDate); + return wrapper; + } +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/impl/DeviceHealthReportServiceImpl.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/impl/DeviceHealthReportServiceImpl.java new file mode 100644 index 0000000..36754ae --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/impl/DeviceHealthReportServiceImpl.java @@ -0,0 +1,167 @@ +package com.iailab.module.device.service.impl; + +import com.alibaba.fastjson.JSONArray; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.iailab.framework.common.constant.Constant; +import com.iailab.common.dto.echarts.BarLineDTO; +import com.iailab.common.dto.echarts.SeriesItem; +import com.iailab.framework.common.page.PageData; +import com.iailab.framework.common.service.impl.BaseServiceImpl; +import com.iailab.framework.common.util.object.ConvertUtils; +import com.iailab.common.utils.DateUtils; +import com.iailab.module.device.dao.DeviceHealthReportDao; +import com.iailab.module.device.dto.DeviceHealthAlarmDTO; +import com.iailab.module.device.dto.DeviceHealthAlarmDetailDTO; +import com.iailab.module.device.dto.DeviceHealthReportDTO; +import com.iailab.module.device.dto.DeviceHealthReportDataDTO; +import com.iailab.module.device.entity.DeviceHealthAlarmDetailEntity; +import com.iailab.module.device.entity.DeviceHealthAlarmEntity; +import com.iailab.module.device.entity.DeviceHealthReportEntity; +import com.iailab.module.device.service.DeviceHealthAlarmService; +import com.iailab.module.device.service.DeviceHealthAlarmDetailService; +import com.iailab.module.device.service.DeviceHealthReportDataService; +import com.iailab.module.device.service.DeviceHealthReportService; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import javax.annotation.Resource; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.util.CollectionUtils; + +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.Map; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年06月28日 + */ +@Slf4j +@Service +public class DeviceHealthReportServiceImpl extends BaseServiceImpl<DeviceHealthReportDao, DeviceHealthReportEntity> + implements DeviceHealthReportService { + + @Resource + private DeviceHealthReportDataService deviceHealthReportDataService; + @Resource + private DeviceHealthAlarmService deviceHealthAlarmService; + @Resource + private DeviceHealthAlarmDetailService deviceHealthAlarmDetailService; + + @Override + public PageData<DeviceHealthReportDTO> page(Map<String, Object> params) { + IPage<DeviceHealthReportEntity> page = baseDao.selectPage( + getPage(params, Constant.CREATE_DATE, false), + getWrapper(params) + ); + return getPageData(page, DeviceHealthReportDTO.class); + } + + private QueryWrapper<DeviceHealthReportEntity> getWrapper(Map<String, Object> params) { + String devNo = (String) params.get("devNo"); + String devName = (String) params.get("devName"); + String reportName = (String) params.get("reportName"); + String startTime = (String) params.get("startTime"); + String endTime = (String) params.get("endTime"); + QueryWrapper<DeviceHealthReportEntity> wrapper = new QueryWrapper<>(); + wrapper.eq(StringUtils.isNotBlank(devNo), "dev_no", devNo) + .like(StringUtils.isNotBlank(devName), "dev_name", devName) + .like(StringUtils.isNotBlank(reportName), "report_name", reportName) + .ge(StringUtils.isNotBlank(startTime), "report_date", startTime) + .le(StringUtils.isNotBlank(endTime), "report_date", endTime); + return wrapper; + } + + @Override + public DeviceHealthReportDTO get(String id) { + DeviceHealthReportEntity entity = baseDao.selectById(id); + DeviceHealthReportDTO result = ConvertUtils.sourceToTarget(entity, DeviceHealthReportDTO.class); + List<DeviceHealthReportDataDTO> detList = deviceHealthReportDataService.listByReportId(id); + result.setDetList(detList); + + List<BarLineDTO> chartList = new ArrayList<>(); + if (CollectionUtils.isEmpty(detList)) { + result.setChartList(chartList); + return result; + } + detList.forEach(item -> { + BarLineDTO dto = new BarLineDTO(); + dto.setValueName(item.getDataName()); + List<String> legend = new ArrayList<>(); + List<SeriesItem> series = new ArrayList<>(); + List<String> categories = new ArrayList<>(); + + legend.add(item.getDataName()); + SeriesItem seriesItem = new SeriesItem(); + seriesItem.setName(item.getDataName()); + List<Object[]> sData = new ArrayList<>(); + if (StringUtils.isNotBlank(item.getDataValue())) { + sData = JSONArray.parseArray(item.getDataValue(), Object[].class); + } + seriesItem.setData(sData); + series.add(seriesItem); + series.get(0).getData().forEach(v -> { + categories.add(v[0].toString()); + }); + + dto.setLegend(legend); + dto.setSeries(series); + dto.setCategories(categories); + chartList.add(dto); + }); + result.setChartList(chartList); + return result; + } + + @Transactional(rollbackFor = Exception.class) + @Override + public void save(DeviceHealthReportDTO dto) { + DeviceHealthReportEntity entity = ConvertUtils.sourceToTarget(dto, DeviceHealthReportEntity.class); + entity.setCreateDate(new Date()); + insert(entity); + if (!CollectionUtils.isEmpty(dto.getDetList())) { + for (int i = 0; i < dto.getDetList().size(); i++) { + DeviceHealthReportDataDTO det = dto.getDetList().get(i); + det.setReportId(entity.getId()); + det.setSort(i); + deviceHealthReportDataService.save(det); + } + } + + // 设备健康故障记录 + DeviceHealthAlarmDTO deviceHealthAlarm = dto.getDeviceHealthAlarm(); + if ( null != deviceHealthAlarm ){ + DeviceHealthAlarmEntity deviceHealthAlarmEntitie = ConvertUtils.sourceToTarget(deviceHealthAlarm, DeviceHealthAlarmEntity.class); + deviceHealthAlarmService.insert(deviceHealthAlarmEntitie); + + // 设备健康故障详情记录 + List<DeviceHealthAlarmDetailDTO> deviceHealthAlarmDetails = dto.getDeviceHealthAlarmDetails(); + List<DeviceHealthAlarmDetailEntity> deviceHealthAlarmDetailEntities = ConvertUtils.sourceToTarget(deviceHealthAlarmDetails, DeviceHealthAlarmDetailEntity.class); + deviceHealthAlarmDetailService.insertBatch(deviceHealthAlarmDetailEntities); + } + + } + + @Override + public void migrationDeviceHealthReport(Map<String, Date> tMap) { + List<DeviceHealthReportEntity> list = baseDao.selectList(getDateWrapper(tMap)); + if (CollectionUtils.isEmpty(list)){ + return; + } + baseDao.migration(list); + baseDao.delete(getDateWrapper(tMap)); + } + + public QueryWrapper<DeviceHealthReportEntity> getDateWrapper(Map<String, Date> params) { + String startDate = DateUtils.format(params.get("startdate"),DateUtils.DATE_TIME_PATTERN); + String endDate = DateUtils.format(params.get("enddate"),DateUtils.DATE_TIME_PATTERN); + + QueryWrapper<DeviceHealthReportEntity> wrapper = new QueryWrapper<>(); + wrapper.ge(StringUtils.isNotBlank(startDate), "report_date", startDate); + wrapper.le(StringUtils.isNotBlank(endDate), "report_date", endDate); + return wrapper; + } +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/impl/DeviceHealthStateServiceImpl.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/impl/DeviceHealthStateServiceImpl.java new file mode 100644 index 0000000..b877446 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/impl/DeviceHealthStateServiceImpl.java @@ -0,0 +1,61 @@ +package com.iailab.module.device.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.iailab.framework.common.service.impl.CrudServiceImpl; +import com.iailab.module.device.dao.DeviceHealthStateDao; +import com.iailab.module.device.dto.DeviceHealthStateDTO; +import com.iailab.module.device.entity.DeviceHealthStateEntity; +import com.iailab.module.device.service.DeviceInfoService; +import com.iailab.module.device.service.DeviceHealthEvaluateService; +import com.iailab.module.device.service.DeviceHealthStateService; +import org.apache.commons.lang3.StringUtils; +import javax.annotation.Resource; +import org.springframework.stereotype.Service; + +import java.util.Map; + +/** + * 设备健康状态表 + * + * @author lirm ${email} + * @since 1.0.0 2024-05-22 + */ +@Service +public class DeviceHealthStateServiceImpl extends CrudServiceImpl<DeviceHealthStateDao, DeviceHealthStateEntity, DeviceHealthStateDTO> implements DeviceHealthStateService { + + @Resource + DeviceHealthEvaluateService deviceHealthEvaluateService; + + @Resource + DeviceInfoService deviceInfoService; + + @Override + public QueryWrapper<DeviceHealthStateEntity> getWrapper(Map<String, Object> params){ + String id = (String)params.get("id"); + + QueryWrapper<DeviceHealthStateEntity> wrapper = new QueryWrapper<>(); + wrapper.eq(StringUtils.isNotBlank(id), "id", id); + + return wrapper; + } + + + @Override + public void insertHealthState(Map<String, Object> tMap) { + int normal = Integer.parseInt(tMap.get("normal").toString()); + int common = Integer.parseInt(tMap.get("common").toString()); + int heavy = Integer.parseInt(tMap.get("heavy").toString()); + int serious = Integer.parseInt(tMap.get("serious").toString()); + int espSerious = Integer.parseInt(tMap.get("espSerious").toString()); + int total_count = normal + common + heavy + serious + espSerious; + tMap.put("total_count",total_count); + int id = baseDao.getId(); + if(id == 0){ + baseDao.insertHealthState(tMap); + }else{ + tMap.put("id",id); + baseDao.updateHealthState(tMap); + } + } + +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/impl/DeviceIndexServiceImpl.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/impl/DeviceIndexServiceImpl.java new file mode 100644 index 0000000..7bd92c3 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/impl/DeviceIndexServiceImpl.java @@ -0,0 +1,49 @@ +package com.iailab.module.device.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.iailab.framework.common.service.impl.CrudServiceImpl; +import com.iailab.framework.common.util.object.ConvertUtils; +import com.iailab.module.device.dao.DeviceIndexDao; +import com.iailab.module.device.dto.DeviceIndexDTO; +import com.iailab.module.device.entity.DeviceIndexEntity; +import com.iailab.module.device.service.DeviceIndexService; +import org.apache.commons.lang3.StringUtils; +import org.springframework.stereotype.Service; + +import java.util.List; +import java.util.Map; + +/** + * 设备故障库; + * + * @author lirm ${email} + * @since 1.0.0 2024-05-23 + */ +@Service +public class DeviceIndexServiceImpl extends CrudServiceImpl<DeviceIndexDao, DeviceIndexEntity, DeviceIndexDTO> implements DeviceIndexService { + + @Override + public QueryWrapper<DeviceIndexEntity> getWrapper(Map<String, Object> params){ + String faultType = (String)params.get("faultType"); + + QueryWrapper<DeviceIndexEntity> wrapper = new QueryWrapper<>(); + wrapper.like(StringUtils.isNotBlank(faultType), "fault_type", faultType); + + return wrapper; + } + + + @Override + public void deleteByDeviceId(String id) { + QueryWrapper<DeviceIndexEntity> wrapper = new QueryWrapper<>(); + wrapper.eq(StringUtils.isNotBlank(id), "device_id", id); + baseDao.delete(wrapper); + } + + @Override + public List<DeviceIndexDTO> getByDeviceId(String id) { + QueryWrapper<DeviceIndexEntity> wrapper = new QueryWrapper<>(); + wrapper.eq(StringUtils.isNotBlank(id), "device_id", id); + return ConvertUtils.sourceToTarget(baseDao.selectList(wrapper), DeviceIndexDTO.class); + } +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/impl/DeviceInfoServiceImpl.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/impl/DeviceInfoServiceImpl.java new file mode 100644 index 0000000..d4ec73e --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/impl/DeviceInfoServiceImpl.java @@ -0,0 +1,140 @@ +package com.iailab.module.device.service.impl; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.iailab.common.enums.CommonConstant; +import com.iailab.framework.common.page.PageData; +import com.iailab.framework.common.service.impl.BaseServiceImpl; +import com.iailab.framework.common.util.object.ConvertUtils; +import com.iailab.common.utils.HttpsRequest; +import com.iailab.module.data.dto.FeignHttpApiDTO; +import com.iailab.module.data.api.IFeignDataApi; +import com.iailab.module.device.dao.DeviceInfoDao; +import com.iailab.module.device.dto.DeviceInfoDTO; +import com.iailab.module.device.entity.DeviceInfoEntity; +import com.iailab.module.device.service.DeviceInfoService; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import javax.annotation.Resource; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.util.CollectionUtils; + +import java.util.*; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年05月27日 + */ +@Slf4j +@Service +public class DeviceInfoServiceImpl extends BaseServiceImpl<DeviceInfoDao, DeviceInfoEntity> implements DeviceInfoService { + + private String HTTP_API_CODE = "Dev.DeviceTree"; + + @Resource + private IFeignDataApi feignDataApi; + + @Resource + private HttpsRequest httpsRequest; + + + @Override + public List<DeviceInfoDTO> list(Map<String, Object> params) { + List<DeviceInfoEntity> list = baseDao.selectList(getWrapper(params)); + return ConvertUtils.sourceToTarget(list, DeviceInfoDTO.class); + } + + private QueryWrapper<DeviceInfoEntity> getWrapper(Map<String, Object> params) { + String pid = (String) params.get("pid"); + String no = (String) params.get("no"); + String name = (String) params.get("name"); + String isMain = (String) params.get("isMain"); + QueryWrapper<DeviceInfoEntity> wrapper = new QueryWrapper<>(); + wrapper.eq(StringUtils.isNotBlank(pid), "pid", pid) + .like(StringUtils.isNotBlank(no), "no", no) + .like(StringUtils.isNotBlank(name), "name", name) + .eq(StringUtils.isNotBlank(isMain), "is_main", isMain); + return wrapper; + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void syncData() { + FeignHttpApiDTO apiDTO = feignDataApi.getHttpApi(HTTP_API_CODE); + Map<String, String> params = new HashMap<>(); + String responseStr = httpsRequest.doGet(apiDTO.getUrl(), params, "utf-8", ""); + JSONObject responseObj = JSON.parseObject(responseStr); + if (!CommonConstant.STA_TRUE.equals(responseObj.get("sta").toString())) { + log.info("接口异常"); + } + JSONArray dataArray = responseObj.getJSONArray(CommonConstant.ZX_RES); + if (CollectionUtils.isEmpty(dataArray)) { + return; + } + List<DeviceInfoDTO> deviceInfoDTOS = dataArray.toJavaList(DeviceInfoDTO.class); + for (int i = 0; i < deviceInfoDTOS.size(); i++) { + DeviceInfoEntity entity0 = ConvertUtils.sourceToTarget(deviceInfoDTOS.get(i), DeviceInfoEntity.class); + entity0.setId(UUID.randomUUID().toString()); + entity0.setCreateDate(new Date()); + entity0.setPid("0"); + baseDao.insert(entity0); + List<DeviceInfoDTO> chd = deviceInfoDTOS.get(i).getChildren(); + if (CollectionUtils.isEmpty(chd)) { + continue; + } + for (int j = 0; j < chd.size(); j++) { + DeviceInfoEntity entity1 = ConvertUtils.sourceToTarget(chd.get(j), DeviceInfoEntity.class); + entity1.setId(UUID.randomUUID().toString()); + entity1.setCreateDate(new Date()); + entity1.setPid(entity0.getId()); + baseDao.insert(entity1); + } + } + } + + @Override + public PageData<DeviceInfoDTO> page(Map<String, Object> params) { + params.put("pid","0"); + IPage<DeviceInfoEntity> page = baseDao.selectPage(getPage(params, "no", true), getWrapper(params)); + return getPageData(page, DeviceInfoDTO.class); + } + + @Override + public List<DeviceInfoDTO> getchildrenList(String deviceId) { + return baseDao.getchildrenList(deviceId); + } + + @Override + public DeviceInfoDTO get(String id) { + + DeviceInfoEntity entity = baseDao.selectById(id); + + return ConvertUtils.sourceToTarget(entity, DeviceInfoDTO.class); + } + + @Override + public void updateById(DeviceInfoDTO dto) { + DeviceInfoEntity entity = ConvertUtils.sourceToTarget(dto, DeviceInfoEntity.class); + baseDao.updateById(entity); + } + + @Override + public DeviceInfoDTO getByDevNo(String devNo) { + QueryWrapper<DeviceInfoEntity> wrapper = new QueryWrapper<>(); + wrapper.eq("no", devNo); + DeviceInfoEntity entity = baseDao.selectOne(wrapper); + return ConvertUtils.sourceToTarget(entity, DeviceInfoDTO.class); + } + + @Override + public Long getTotal() { + QueryWrapper<DeviceInfoEntity> queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("pid","0"); + return baseDao.selectCount(queryWrapper); + } +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/impl/DeviceMainServiceImpl.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/impl/DeviceMainServiceImpl.java new file mode 100644 index 0000000..5395c0c --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/impl/DeviceMainServiceImpl.java @@ -0,0 +1,67 @@ +package com.iailab.module.device.service.impl; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.iailab.common.enums.CommonConstant; +import com.iailab.module.data.api.IFeignDataApi; +import com.iailab.module.data.dto.FeignHttpApiDTO; +import com.iailab.framework.common.service.impl.BaseServiceImpl; +import com.iailab.common.utils.DateUtils; +import com.iailab.common.utils.HttpsRequest; +import com.iailab.module.device.dao.DeviceMainDao; +import com.iailab.module.device.dto.DeviceMainDTO; +import com.iailab.module.device.entity.DeviceMainEntity; +import com.iailab.module.device.service.DeviceMainService; +import lombok.extern.slf4j.Slf4j; +import javax.annotation.Resource; +import org.springframework.stereotype.Service; +import org.springframework.util.CollectionUtils; + +import java.util.*; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年05月30日 + */ +@Slf4j +@Service +public class DeviceMainServiceImpl extends BaseServiceImpl<DeviceMainDao, DeviceMainEntity> implements DeviceMainService { + + private String HTTP_API_CODE = "Dev.DeviceMaintQuery"; + + @Resource + private IFeignDataApi feignDataApi; + + @Resource + private HttpsRequest httpsRequest; + + + @Override + public Integer getCount(String devno, Date startTime, Date endTime) { + Integer result = 0; + Map<String, String> params = new HashMap<>(3); + params.put("devno", devno); + params.put("startdate", DateUtils.format(startTime)); + params.put("enddate", DateUtils.format(endTime)); + + List<DeviceMainDTO> list = this.getList(params); + return list.size(); + } + + private List<DeviceMainDTO> getList(Map<String, String> params) { + List<DeviceMainDTO> result = new ArrayList<>(); + FeignHttpApiDTO apiDTO = feignDataApi.getHttpApi(HTTP_API_CODE); + String responseStr = httpsRequest.doGet(apiDTO.getUrl(), params, "utf-8", ""); + JSONObject responseObj = JSON.parseObject(responseStr); + if (!CommonConstant.STA_TRUE.equals(responseObj.get("sta").toString())) { + log.info("接口异常"); + } + JSONArray dataArray = responseObj.getJSONArray(CommonConstant.ZX_RES); + if (CollectionUtils.isEmpty(dataArray)) { + return result; + } + return dataArray.toJavaList(DeviceMainDTO.class); + } +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/impl/DeviceRunStateServiceImpl.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/impl/DeviceRunStateServiceImpl.java new file mode 100644 index 0000000..38bcb70 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/impl/DeviceRunStateServiceImpl.java @@ -0,0 +1,44 @@ +package com.iailab.module.device.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.iailab.framework.common.service.impl.CrudServiceImpl; +import com.iailab.module.device.dao.DeviceRunStateDao; +import com.iailab.module.device.dto.DeviceRunStateDTO; +import com.iailab.module.device.entity.DeviceRunStateEntity; +import com.iailab.module.device.service.DeviceRunStateService; +import org.apache.commons.lang3.StringUtils; +import org.springframework.stereotype.Service; + +import java.util.Map; + +/** + * 设备运行状态表 + * + * @author lirm ${email} + * @since 1.0.0 2024-05-22 + */ +@Service +public class DeviceRunStateServiceImpl extends CrudServiceImpl<DeviceRunStateDao, DeviceRunStateEntity, DeviceRunStateDTO> implements DeviceRunStateService { + + @Override + public QueryWrapper<DeviceRunStateEntity> getWrapper(Map<String, Object> params){ + String id = (String)params.get("id"); + + QueryWrapper<DeviceRunStateEntity> wrapper = new QueryWrapper<>(); + wrapper.eq(StringUtils.isNotBlank(id), "id", id); + + return wrapper; + } + + + @Override + public void insertRunState(Map<String, Integer> tMap) { + int id = baseDao.getId(); + if(id == 0){ + baseDao.insertRunState(tMap); + }else{ + tMap.put("id",id); + baseDao.updateRunState(tMap); + } + } +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/impl/DeviceStatCountServiceImpl.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/impl/DeviceStatCountServiceImpl.java new file mode 100644 index 0000000..bdd585d --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/impl/DeviceStatCountServiceImpl.java @@ -0,0 +1,66 @@ +package com.iailab.module.device.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.iailab.framework.common.service.impl.CrudServiceImpl; +import com.iailab.framework.common.util.object.ConvertUtils; +import com.iailab.module.device.commons.HealthLevelEnum; +import com.iailab.module.device.dao.DeviceStatCountDao; +import com.iailab.module.device.dto.DeviceStatCountDTO; +import com.iailab.module.device.entity.DeviceStatCountEntity; +import com.iailab.module.device.service.DeviceStatCountService; +import com.iailab.module.device.service.DeviceHealthEvaluateService; +import org.apache.commons.lang3.StringUtils; +import javax.annotation.Resource; +import org.springframework.stereotype.Service; + +import java.util.List; +import java.util.Map; + +/** + * 设备健康状态表 + * + * @author lirm ${email} + * @since 1.0.0 2024-05-22 + */ +@Service +public class DeviceStatCountServiceImpl extends CrudServiceImpl<DeviceStatCountDao, DeviceStatCountEntity, DeviceStatCountDTO> implements DeviceStatCountService { + + @Resource + DeviceHealthEvaluateService deviceHealthEvaluateService; + + public QueryWrapper<DeviceStatCountEntity> getWrapper(Map<String, Object> params){ + String startTime = (String)params.get("startTime"); + String endTime = (String)params.get("endTime"); + + QueryWrapper<DeviceStatCountEntity> wrapper = new QueryWrapper<>(); + wrapper.ge(StringUtils.isNotBlank(startTime), "date", startTime); + wrapper.le(StringUtils.isNotBlank(endTime), "date", endTime); + wrapper.orderByDesc("create_date"); + + return wrapper; + } + + @Override + public DeviceStatCountDTO getDeviceStatCount() { + DeviceStatCountDTO result = new DeviceStatCountDTO(); + //健康设备数量 + Long healthyNum = deviceHealthEvaluateService.selectHealthLevalCount(HealthLevelEnum.Level1.getCode()); + result.setHealthCount(healthyNum); + //良好设备数量 + Long goodNum = deviceHealthEvaluateService.selectHealthLevalCount(HealthLevelEnum.Level2.getCode()); + result.setGoodCount(goodNum); + //故障设备数量 + Long accidentNum = deviceHealthEvaluateService.selectHealthLevalCount(HealthLevelEnum.Level3.getCode()); + result.setAccidentCount(accidentNum); + //总设备数量 + Long totalNum = deviceHealthEvaluateService.selectHealthLevalCount(null); + result.setTotalCount(totalNum); + return result; + } + + @Override + public List<DeviceStatCountDTO> getHistory(Map<String, Object> params) { + List<DeviceStatCountEntity> list = baseDao.selectList(getWrapper(params)); + return ConvertUtils.sourceToTarget(list,DeviceStatCountDTO.class); + } +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/impl/DeviceStatNewnessServiceImpl.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/impl/DeviceStatNewnessServiceImpl.java new file mode 100644 index 0000000..6b1121f --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/impl/DeviceStatNewnessServiceImpl.java @@ -0,0 +1,119 @@ +package com.iailab.module.device.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.iailab.common.constant.BusinessConstant; +import com.iailab.framework.common.page.PageData; +import com.iailab.framework.common.service.impl.BaseServiceImpl; +import com.iailab.framework.common.util.object.ConvertUtils; +import com.iailab.module.device.dao.DeviceStatNewnessDao; +import com.iailab.module.device.dto.DeviceInfoDTO; +import com.iailab.module.device.dto.DeviceStatNewnessDTO; +import com.iailab.module.device.entity.DeviceStatNewnessEntity; +import com.iailab.module.device.service.DeviceInfoService; +import com.iailab.module.device.service.DeviceStatNewnessService; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import javax.annotation.Resource; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.math.BigDecimal; +import java.util.*; + +@Slf4j +@Service +public class DeviceStatNewnessServiceImpl extends BaseServiceImpl<DeviceStatNewnessDao, DeviceStatNewnessEntity> implements DeviceStatNewnessService { + + @Resource + private DeviceInfoService deviceInfoService; + + @Override + @Transactional(rollbackFor = Exception.class) + public void statNewness(List<DeviceStatNewnessEntity> list,Date statDate) { + // 计划运行时间 + Map<String, Object> ListParams = new HashMap<>(); + ListParams.put("pid", "0"); + List<DeviceInfoDTO> deviceInfoList = deviceInfoService.list(ListParams); + Map<String, DeviceInfoDTO> deviceInfoMap = new HashMap<>(); + deviceInfoList.forEach(item -> { + deviceInfoMap.put(item.getNo(), item); + }); + + List<DeviceStatNewnessEntity> deviceStatNewnessList = new ArrayList<>(); + for (DeviceStatNewnessEntity entity : list) { + DeviceInfoDTO devInfo = deviceInfoMap.get(entity.getDevNo()); + if (devInfo == null) { + continue; + } + DeviceInfoDTO devInfoUpdate = new DeviceInfoDTO(); + devInfoUpdate.setId(devInfo.getId()); + + entity.setId(UUID.randomUUID().toString()); + entity.setDate(statDate); + entity.setCreateDate(new Date()); + // 使用年限 + Integer durableYears = devInfo.getDurableYears() == null ? 0 : devInfo.getDurableYears(); + BigDecimal durMins = new BigDecimal(durableYears.longValue() * BusinessConstant.YEAR_MINUTE); + entity.setDurableTime(durMins.longValue()); + + // 已用时长 + BigDecimal useTime = devInfo.getUseTime() == null ? BigDecimal.ZERO : new BigDecimal(devInfo.getUseTime()); + BigDecimal useNew = useTime.add(new BigDecimal(entity.getLossTime())); + devInfoUpdate.setUseTime(useNew.longValue()); + + // 剩余时长 + BigDecimal residueNew = new BigDecimal(entity.getDurableTime() - useNew.longValue()); + devInfoUpdate.setResidueTime(residueNew.longValue()); + entity.setResidueTime(residueNew.longValue()); + + // 新度系数 + BigDecimal newnessRate = residueNew.divide(durMins, 4, BigDecimal.ROUND_FLOOR); + devInfoUpdate.setNewnessRate(newnessRate); + entity.setNewnessRate(newnessRate); + + deviceStatNewnessList.add(entity); + // 更新设备信息 + deviceInfoService.updateById(devInfoUpdate); + + + } + // 插入明细 + insertBatch(deviceStatNewnessList); + } + + @Override + public DeviceStatNewnessEntity getLastByNo(String no) { + QueryWrapper<DeviceStatNewnessEntity> wrapper = new QueryWrapper<>(); + wrapper.eq("dev_no",no); + wrapper.orderByDesc("create_date"); + wrapper.last("limit 1"); + return baseDao.selectOne(wrapper); + } + + @Override + public List<DeviceStatNewnessDTO> list(Map<String, Object> params) { + List<DeviceStatNewnessEntity> list = baseDao.selectList(getWrapper(params)); + return ConvertUtils.sourceToTarget(list,DeviceStatNewnessDTO.class); + } + + @Override + public PageData<DeviceStatNewnessDTO> page(Map<String, Object> params) { + params.put("pid","0"); + IPage<DeviceStatNewnessEntity> page = baseDao.selectPage(getPage(params, "create_date", false), getWrapper(params)); + return getPageData(page, DeviceStatNewnessDTO.class); + } + + public QueryWrapper<DeviceStatNewnessEntity> getWrapper(Map<String, Object> params) { + String no = (String) params.get("no"); + String startTime = (String) params.get("startTime"); + String endTime = (String) params.get("endTime"); + + QueryWrapper<DeviceStatNewnessEntity> wrapper = new QueryWrapper<>(); + wrapper.eq(StringUtils.isNotBlank(no), "dev_no", no); + wrapper.ge(StringUtils.isNotBlank(startTime), "date", startTime); + wrapper.le(StringUtils.isNotBlank(endTime), "date", endTime); + wrapper.orderByDesc("create_date"); + return wrapper; + } +} diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/impl/DeviceStatUsageServiceImpl.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/impl/DeviceStatUsageServiceImpl.java new file mode 100644 index 0000000..d9dcd71 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/impl/DeviceStatUsageServiceImpl.java @@ -0,0 +1,178 @@ +package com.iailab.module.device.service.impl; + +import cn.hutool.core.map.MapUtil; +import cn.hutool.core.util.ObjectUtil; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.iailab.common.enums.CommonConstant; +import com.iailab.framework.common.service.impl.BaseServiceImpl; +import com.iailab.common.utils.DateUtils; +import com.iailab.common.utils.HttpsRequest; +import com.iailab.module.data.dto.FeignHttpApiDTO; +import com.iailab.module.data.api.IFeignDataApi; +import com.iailab.module.device.commons.HealthLevelEnum; +import com.iailab.module.device.dao.DeviceStatUsageDao; +import com.iailab.module.device.dto.DeviceCurrentRateDTO; +import com.iailab.module.device.dto.DeviceInfoDTO; +import com.iailab.module.device.entity.DeviceInfoEntity; +import com.iailab.module.device.entity.DeviceStatUsageEntity; +import com.iailab.module.device.service.DeviceInfoService; +import com.iailab.module.device.service.DeviceHealthEvaluateService; +import com.iailab.module.device.service.DeviceStatUsageService; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import javax.annotation.Resource; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.util.CollectionUtils; + +import java.math.BigDecimal; +import java.math.RoundingMode; +import java.util.*; +import java.util.stream.Collectors; + +@Slf4j +@Service +public class DeviceStatUsageServiceImpl extends BaseServiceImpl<DeviceStatUsageDao, DeviceStatUsageEntity> implements DeviceStatUsageService { + + private String HTTP_API_CODE = "Dev.RunReportSumMonth"; + + @Resource + private IFeignDataApi feignDataApi; + + @Resource + private HttpsRequest httpsRequest; + + @Resource + private DeviceInfoService deviceInfoService; + + @Resource + private DeviceHealthEvaluateService deviceHealthEvaluateService; + + + @Override + @Transactional(rollbackFor = Exception.class) + public void syncData() { + Calendar calendar = Calendar.getInstance(); + calendar.add(Calendar.DAY_OF_YEAR,-1); + String ym = DateUtils.format(calendar.getTime(), DateUtils.DATE_PATTERN_MON); + FeignHttpApiDTO apiDTO = feignDataApi.getHttpApi(HTTP_API_CODE); + Map<String, String> params = new HashMap<>(); + params.put("ym", ym); + String responseStr = httpsRequest.doGet(apiDTO.getUrl(), params, "utf-8", ""); + JSONObject responseObj = JSON.parseObject(responseStr); + if (!CommonConstant.STA_TRUE.equals(responseObj.get("sta").toString())) { + log.info("接口异常"); + } + JSONArray datas = responseObj.getJSONArray(CommonConstant.ZX_RES); + if (CollectionUtils.isEmpty(datas)) { + return; + } + + // 计划运行时间 + Map<String,Object> ListParams = new HashMap<>(); + ListParams.put("pid","0"); + List<DeviceInfoDTO> deviceInfoList = deviceInfoService.list(ListParams); + Map<String, Integer> noPlanTimeMap = deviceInfoList.stream().filter(e -> ObjectUtil.isNotNull(e.getPlanTime())).collect(Collectors.toMap(DeviceInfoDTO::getNo, e -> e.getPlanTime() * 60)); + int planTime = 24; + String key = "z" + calendar.get(Calendar.DAY_OF_MONTH); + + List<DeviceStatUsageEntity> list = new ArrayList<>(datas.size()); + List<DeviceInfoEntity> deviceInfoEntities = new ArrayList<>(datas.size()); + for (Object data : datas) { + JSONObject jsonObject = JSONObject.parseObject(JSONObject.toJSONString(data)); + + DeviceStatUsageEntity deviceStatUsageEntity = new DeviceStatUsageEntity(); + DeviceInfoEntity deviceInfoEntity = new DeviceInfoEntity(); + + deviceStatUsageEntity.setId(UUID.randomUUID().toString()); + String deviceNo = jsonObject.get("no").toString(); + deviceStatUsageEntity.setDevNo(deviceNo); + deviceStatUsageEntity.setDevName(jsonObject.get("name").toString()); + deviceStatUsageEntity.setDate(DateUtils.format(calendar.getTime())); + int runTime = Integer.parseInt(jsonObject.get(key).toString()); + deviceStatUsageEntity.setRunTime(runTime); + + if (noPlanTimeMap.containsKey(deviceNo)){ + // 计划运行时间 + planTime = MapUtil.get(noPlanTimeMap,deviceNo,Integer.class); + // 计算使用率 + deviceStatUsageEntity.setPlanTime(planTime); + BigDecimal d1 = new BigDecimal(runTime); + BigDecimal d2 = new BigDecimal(planTime); + BigDecimal usage = d1.divide(d2, 4, RoundingMode.HALF_UP); + deviceStatUsageEntity.setUsageRate(usage); + deviceInfoEntity.setUsageRate(usage); + }else { + deviceStatUsageEntity.setPlanTime(null); + } + + deviceStatUsageEntity.setCreateDate(new Date()); + list.add(deviceStatUsageEntity); + + deviceInfoEntity.setNo(deviceNo); + deviceInfoEntity.setUpdateDate(calendar.getTime()); + deviceInfoEntities.add(deviceInfoEntity); + } + insertBatch(list); + // 修改deviceInfo + for (DeviceInfoEntity entity : deviceInfoEntities) { + QueryWrapper<DeviceInfoEntity> wrapper = new QueryWrapper<>(); + wrapper.eq("no",entity.getNo()); + wrapper.eq("pid","0"); + deviceInfoService.update(entity,wrapper); + } + + } + + @Override + public DeviceStatUsageEntity getLastByNo(String no) { + QueryWrapper<DeviceStatUsageEntity> wrapper = new QueryWrapper<>(); + wrapper.eq("dev_no",no); + wrapper.orderByDesc("create_date"); + wrapper.last("limit 1"); + return baseDao.selectOne(wrapper); + } + + @Override + public DeviceCurrentRateDTO getDeviceCurrentRate() { + DeviceCurrentRateDTO result = new DeviceCurrentRateDTO(); + //健康设备数量 + Long healthyNum = deviceHealthEvaluateService.selectHealthLevalCount(HealthLevelEnum.Level1.getCode()); + //待检修设备数量 + Long repairNum = deviceHealthEvaluateService.selectHealthLevalCount(HealthLevelEnum.Level3.getCode()); + //总设备数量 + Long totalNum = deviceHealthEvaluateService.selectHealthLevalCount(null); + + //完好率 + BigDecimal healthRate = BigDecimal.valueOf(healthyNum).divide(BigDecimal.valueOf(totalNum), 4, RoundingMode.HALF_UP); + result.setHealthyRate(healthRate); + //待修率 + BigDecimal repairRate = BigDecimal.valueOf(repairNum).divide(BigDecimal.valueOf(totalNum), 4, RoundingMode.HALF_UP); + result.setRepairRate(repairRate); + //todo 事故率 + result.setAccidentRate(BigDecimal.valueOf(0)); + + return result; + } + + @Override + public List<DeviceStatUsageEntity> list(Map<String, Object> params) { + return baseDao.selectList(getWrapper(params)); + } + + public QueryWrapper<DeviceStatUsageEntity> getWrapper(Map<String, Object> params) { + String no = (String) params.get("no"); + String startTime = (String) params.get("startTime"); + String endTime = (String) params.get("endTime"); + + QueryWrapper<DeviceStatUsageEntity> wrapper = new QueryWrapper<>(); + wrapper.eq(StringUtils.isNotBlank(no), "dev_no", no); + wrapper.ge(StringUtils.isNotBlank(startTime), "date", startTime); + wrapper.le(StringUtils.isNotBlank(endTime), "date", endTime); + wrapper.orderByDesc("create_date"); + return wrapper; + } +} diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/event/dao/EventInfoDao.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/event/dao/EventInfoDao.java new file mode 100644 index 0000000..b177def --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/event/dao/EventInfoDao.java @@ -0,0 +1,14 @@ +package com.iailab.module.event.dao; + +import com.iailab.framework.common.dao.BaseDao; +import com.iailab.module.event.entity.EventInfoEntity; +import org.apache.ibatis.annotations.Mapper; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年05月30日 + */ +@Mapper +public interface EventInfoDao extends BaseDao<EventInfoEntity> { +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/event/dto/EventInfoDTO.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/event/dto/EventInfoDTO.java new file mode 100644 index 0000000..aafe100 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/event/dto/EventInfoDTO.java @@ -0,0 +1,70 @@ +package com.iailab.module.event.dto; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年05月30日 + */ +@Data +@Schema(name = "中选事件信息表") +public class EventInfoDTO implements Serializable { + private static final long serialVersionUID = 1L; + + private String id; + + /** + * 记录时间 + */ + private String logTime; + + /** + * 事件发生时间 + */ + private String eventTime; + + /** + * 系统Key + */ + private String systemKey; + + /** + * 系统名称 + */ + private String systemName; + + /** + * 事件Key + */ + private String eventKey; + + /** + * 事件名称 + */ + private String eventName; + + /** + * 消息 + */ + private String message; + + /** + * 事件分类 + */ + private String eventCategory; + + /** + * 事件等级,1低,2中,3高 + */ + private Integer eventLevel; + + /** + * 数据创建时间 + */ + private Date createTime; +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/event/entity/EventInfoEntity.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/event/entity/EventInfoEntity.java new file mode 100644 index 0000000..d2733d0 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/event/entity/EventInfoEntity.java @@ -0,0 +1,72 @@ +package com.iailab.module.event.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; + +@Data +@TableName("t_event_info") +public class EventInfoEntity implements Serializable { + private static final long serialVersionUID = 1L; + + /** + * ID + */ + @TableId(type = IdType.INPUT) + private String id; + + /** + * 记录时间 + */ + private String logTime; + + /** + * 事件发生时间 + */ + private String eventTime; + + /** + * 系统Key + */ + private String systemKey; + + /** + * 系统名称 + */ + private String systemName; + + /** + * 事件Key + */ + private String eventKey; + + /** + * 事件名称 + */ + private String eventName; + + /** + * 消息 + */ + private String message; + + /** + * 事件分类 + */ + private String eventCategory; + + /** + * 事件等级,1低,2中,3高 + */ + private Integer eventLevel; + + /** + * 数据创建时间 + */ + private Date createTime; + +} diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/event/service/EventInfoService.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/event/service/EventInfoService.java new file mode 100644 index 0000000..c2685e9 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/event/service/EventInfoService.java @@ -0,0 +1,19 @@ +package com.iailab.module.event.service; + +import com.iailab.framework.common.service.BaseService; +import com.iailab.module.event.dto.EventInfoDTO; +import com.iailab.module.event.entity.EventInfoEntity; + +import java.util.Date; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年05月30日 + */ +public interface EventInfoService extends BaseService<EventInfoEntity> { + + void save(EventInfoDTO dto); + + Long getCount(String eventDevice, Date startTime, Date endTime); +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/event/service/impl/EventInfoServiceImpl.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/event/service/impl/EventInfoServiceImpl.java new file mode 100644 index 0000000..cd35790 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/event/service/impl/EventInfoServiceImpl.java @@ -0,0 +1,43 @@ +package com.iailab.module.event.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.iailab.framework.common.service.impl.BaseServiceImpl; +import com.iailab.framework.common.util.object.ConvertUtils; +import com.iailab.common.utils.DateUtils; +import com.iailab.module.event.dao.EventInfoDao; +import com.iailab.module.event.dto.EventInfoDTO; +import com.iailab.module.event.entity.EventInfoEntity; +import com.iailab.module.event.service.EventInfoService; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import org.springframework.stereotype.Service; + +import java.util.Date; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年05月30日 + */ +@Slf4j +@Service +public class EventInfoServiceImpl extends BaseServiceImpl<EventInfoDao, EventInfoEntity> implements EventInfoService { + + @Override + public void save(EventInfoDTO dto) { + EventInfoEntity entity = ConvertUtils.sourceToTarget(dto, EventInfoEntity.class); + insert(entity); + } + + @Override + public Long getCount(String eventName, Date startTime, Date endTime) { + Integer result = 0; + QueryWrapper<EventInfoEntity> wrapper = new QueryWrapper<>(); + wrapper.like(StringUtils.isNotBlank(eventName), "event_name", eventName) + .gt("event_time", DateUtils.format(startTime,DateUtils.DATE_TIME_PATTERN )) + .lt("event_time", DateUtils.format(startTime,DateUtils.DATE_TIME_PATTERN )); + + + return baseDao.selectCount(wrapper); + } +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/event/ws/EventWebSocketClient.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/event/ws/EventWebSocketClient.java new file mode 100644 index 0000000..cf43d1e --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/event/ws/EventWebSocketClient.java @@ -0,0 +1,82 @@ +//package com.iailab.module.event.ws; +// +//import com.alibaba.fastjson.JSONObject; +//import com.iailab.module.event.dto.EventInfoDTO; +//import com.iailab.module.event.service.EventInfoService; +//import lombok.extern.slf4j.Slf4j; +//import org.java_websocket.client.WebSocketClient; +//import org.java_websocket.handshake.ServerHandshake; +//import javax.annotation.Resource; +// +//import java.net.URI; +//import java.util.Date; +// +//@Slf4j +//public class EventWebSocketClient extends WebSocketClient { +// +// private static boolean WEBSTATUS = false; +// +// private String TYPE = "event"; +// +// private static String LISTEN_SystemName = "生产控制系统"; +// +// @Resource +// private EventInfoService eventInfoService; +// +// //连接 +// public EventWebSocketClient(URI serverUri) { +// super(serverUri); +// } +// +// //打开连接 +// @Override +// public void onOpen(ServerHandshake serverHandshake) { +// WEBSTATUS = true; +// } +// +// @Override +// public void onMessage(String mesg) { +// // log.info("event.mesg=" + mesg); +// JSONObject jo = JSONObject.parseObject(mesg); +// String type = jo.getString("type"); +// if (!TYPE.equals(jo.getString("type"))) { +// return; +// } +// String msg = jo.getString("msg"); +// JSONObject jomsg = JSONObject.parseObject(msg); +// log.info("msg=" + msg); +// if (!LISTEN_SystemName.equals(jo.getString("SystemName"))) { +// return; +// } +// +// EventInfoDTO entity = new EventInfoDTO(); +// entity.setId(jomsg.getString("Id")); +// entity.setLogTime(jomsg.getString("LogTime")); +// entity.setEventTime(jomsg.getString("EventTime")); +// entity.setSystemKey(jomsg.getString("SystemKey")); +// entity.setSystemName(jomsg.getString("SystemName")); +// entity.setEventTime(jomsg.getString("EventTime")); +// entity.setMessage(jomsg.getString("Message")); +// entity.setEventCategory(jomsg.getString("EventCategory")); +// entity.setEventLevel(jomsg.getInteger("EventLevel")); +// entity.setCreateTime(new Date()); +// try { +// eventInfoService.save(entity); +// } catch (Exception e) { +// e.printStackTrace(); +// } +// } +// +// @Override +// public void onClose(int i, String s, boolean b) { +// WEBSTATUS = false; +// //重连 +// ReconnectThreadEnum.getInstance().reconnectWs(this); +// } +// +// @Override +// public void onError(Exception e) { +// WEBSTATUS = false; +// } +// +//} diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/event/ws/EventWsBean.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/event/ws/EventWsBean.java new file mode 100644 index 0000000..55fed84 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/event/ws/EventWsBean.java @@ -0,0 +1,24 @@ +//package com.iailab.module.event.ws; +// +//import org.java_websocket.client.WebSocketClient; +//import org.springframework.context.annotation.Bean; +//import org.springframework.context.annotation.Configuration; +// +//import java.net.URI; +//import java.net.URISyntaxException; +// +//@Configuration +//public class EventWsBean { +// +// @Bean +// public WebSocketClient webServiceClient() { +// try { +// EventWebSocketClient mWebSocketClient = new EventWebSocketClient(new URI("ws://192.168.55.127/api/Ws/Event")); +// mWebSocketClient.connect(); +// return mWebSocketClient; +// } catch (URISyntaxException e) { +// e.printStackTrace(); +// } +// return null; +// } +//} diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/event/ws/ReconnectThreadEnum.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/event/ws/ReconnectThreadEnum.java new file mode 100644 index 0000000..7ad877d --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/event/ws/ReconnectThreadEnum.java @@ -0,0 +1,34 @@ +//package com.iailab.module.event.ws; +// +//import java.util.concurrent.ExecutorService; +//import java.util.concurrent.Executors; +// +//public enum ReconnectThreadEnum { +// +// WebSocketInstance(){ +// @Override +// public void reconnectWs(EventWebSocketClient demoWebSocketClient) { +// cachedThreadPool.execute(new Runnable() { +// @Override +// public void run() { +// try { +// //重连间隔一秒 +// Thread.sleep(10000000); +// System.out.println("重新连接"); +// } catch (InterruptedException e) { +// e.printStackTrace(); +// } +// demoWebSocketClient.reconnect(); +// } +// }); +// } +// }; +// +// private static final ExecutorService cachedThreadPool = Executors.newCachedThreadPool(); +// +// public abstract void reconnectWs(EventWebSocketClient demoWebSocketClient); +// +// public static ReconnectThreadEnum getInstance(){ +// return WebSocketInstance; +// } +//} diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/feign/FeignModelImpl.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/feign/FeignModelImpl.java new file mode 100644 index 0000000..85c0836 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/feign/FeignModelImpl.java @@ -0,0 +1,82 @@ +package com.iailab.module.feign; + +import com.iailab.api.IFeignModelApi; +import com.iailab.module.device.service.DeviceAbnormalHistoryService; +import com.iailab.module.device.service.DeviceAccountService; +import com.iailab.module.device.service.DeviceHealthStateService; +import com.iailab.module.device.service.DeviceRunStateService; +import com.iailab.module.model.handler.ModelHandler; +import org.apache.commons.lang3.StringUtils; +import javax.annotation.Resource; +import org.springframework.util.CollectionUtils; +import org.springframework.web.bind.annotation.RestController; + +import java.util.Calendar; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * @author lirm + * @Description + * @createTime 2024年05月22日 + */ +@RestController +public class FeignModelImpl implements IFeignModelApi { + + @Resource + private DeviceRunStateService deviceRunStateService; + + @Resource + private DeviceHealthStateService deviceHealthStateService; + + @Resource + private DeviceAbnormalHistoryService deviceAbnormalHistoryService; + + @Resource + private DeviceAccountService deviceAccountService; + + @Resource + private ModelHandler modelHandler; + + @Override + public void insertRunState(Map<String, Integer> tMap) { + deviceRunStateService.insertRunState(tMap); + } + + @Override + public void insertHealthState(Map<String, Object> tMap) { + deviceHealthStateService.insertHealthState(tMap); + deviceAbnormalHistoryService.insertHistory(tMap); + } + + @Override + public void insertDeviceList(Map<String, String> tMap) { + deviceAccountService.insertDeviceList(tMap); + } + + @Override + public Map<String, Object> runModel(Map<String, Object> params, List<double[][]> sampleDataList) { + Map<String, Object> result = new HashMap<>(); + try { + String modelCode = (String) params.get("modelCode"); + if (StringUtils.isBlank(modelCode)) { + return result; + } + if (CollectionUtils.isEmpty(sampleDataList)) { + return result; + } + Calendar calendar = Calendar.getInstance(); + calendar.set(Calendar.MILLISECOND, 0); + result = modelHandler.run(modelCode, sampleDataList); + } catch (Exception ex) { + ex.printStackTrace(); + } + return result; + } + + @Override + public List<String> getDeviceIdList() { + return deviceAccountService.getDeviceIdList(); + } +} diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/framework/package-info.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/framework/package-info.java new file mode 100644 index 0000000..e04f72a --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/framework/package-info.java @@ -0,0 +1,6 @@ +/** + * 属于 infra 模块的 framework 封装 + * + * @author iailab + */ +package com.iailab.module.framework; diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/framework/rpc/config/RpcConfiguration.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/framework/rpc/config/RpcConfiguration.java new file mode 100644 index 0000000..eb751ee --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/framework/rpc/config/RpcConfiguration.java @@ -0,0 +1,14 @@ +package com.iailab.module.framework.rpc.config; + +import com.iailab.api.IFeignProddispApi; +import com.iailab.module.data.api.IFeignDataApi; +import com.iailab.module.infra.api.config.ConfigApi; +import com.iailab.module.system.api.permission.RoleApi; +import com.iailab.module.system.api.user.AdminUserApi; +import org.springframework.cloud.openfeign.EnableFeignClients; +import org.springframework.context.annotation.Configuration; + +@Configuration(proxyBeanMethods = false) +@EnableFeignClients(clients = {IFeignDataApi.class, AdminUserApi.class, RoleApi.class, IFeignProddispApi.class, ConfigApi.class}) +public class RpcConfiguration { +} diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/framework/rpc/package-info.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/framework/rpc/package-info.java new file mode 100644 index 0000000..16e3ea0 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/framework/rpc/package-info.java @@ -0,0 +1,4 @@ +/** + * 占位 + */ +package com.iailab.module.framework.rpc; diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/framework/security/config/SecurityConfiguration.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/framework/security/config/SecurityConfiguration.java new file mode 100644 index 0000000..848671d --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/framework/security/config/SecurityConfiguration.java @@ -0,0 +1,48 @@ +package com.iailab.module.framework.security.config; + +import com.iailab.framework.security.config.AuthorizeRequestsCustomizer; +import com.iailab.module.infra.enums.ApiConstants; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.security.config.annotation.web.builders.HttpSecurity; +import org.springframework.security.config.annotation.web.configurers.ExpressionUrlAuthorizationConfigurer; + +/** + * data 模块的 Security 配置 + */ +@Configuration(proxyBeanMethods = false, value = "dataSecurityConfiguration") +public class SecurityConfiguration { + + @Value("${spring.boot.admin.context-path:''}") + private String adminSeverContextPath; + + @Bean("infraAuthorizeRequestsCustomizer") + public AuthorizeRequestsCustomizer authorizeRequestsCustomizer() { + return new AuthorizeRequestsCustomizer() { + + @Override + public void customize(ExpressionUrlAuthorizationConfigurer<HttpSecurity>.ExpressionInterceptUrlRegistry registry) { + // Swagger 接口文档 + registry.antMatchers("/v3/api-docs/**").permitAll() // 元数据 + .antMatchers("/swagger-ui.html").permitAll(); // Swagger UI + // Spring Boot Actuator 的安全配置 + registry.antMatchers("/actuator").anonymous() + .antMatchers("/actuator/**").anonymous(); + // Druid 监控 + registry.antMatchers("/druid/**").anonymous(); + // Spring Boot Admin Server 的安全配置 + registry.antMatchers(adminSeverContextPath).anonymous() + .antMatchers(adminSeverContextPath + "/**").anonymous(); + // 文件读取 + registry.antMatchers(buildAdminApi("/data/file/*/get/**")).permitAll(); + + // TODO iailab:这个每个项目都需要重复配置,得捉摸有没通用的方案 + // RPC 服务的安全配置 + registry.antMatchers(ApiConstants.PREFIX + "/**").permitAll(); + } + + }; + } + +} diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/framework/security/core/package-info.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/framework/security/core/package-info.java new file mode 100644 index 0000000..9f4a10b --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/framework/security/core/package-info.java @@ -0,0 +1,4 @@ +/** + * 占位 + */ +package com.iailab.module.framework.security.core; diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/config/ScheduleConfig.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/config/ScheduleConfig.java new file mode 100644 index 0000000..0a3101e --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/config/ScheduleConfig.java @@ -0,0 +1,58 @@ +package com.iailab.module.job.config; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.scheduling.quartz.SchedulerFactoryBean; + +import javax.sql.DataSource; +import java.util.Properties; + +/** + * 定时任务配置 + * + * @author Mark sunlightcs@gmail.com + */ +@Configuration +public class ScheduleConfig { + + @Bean + public SchedulerFactoryBean schedulerFactoryBean(DataSource dataSource) { + SchedulerFactoryBean factory = new SchedulerFactoryBean(); + factory.setDataSource(dataSource); + + //quartz参数 + Properties prop = new Properties(); + prop.put("org.quartz.scheduler.instanceName", "IailabModelScheduler"); + prop.put("org.quartz.scheduler.instanceId", "AUTO"); + //线程池配置 + prop.put("org.quartz.threadPool.class", "org.quartz.simpl.SimpleThreadPool"); + prop.put("org.quartz.threadPool.threadCount", "20"); + prop.put("org.quartz.threadPool.threadPriority", "5"); + //JobStore配置 + prop.put("org.quartz.jobStore.class", "org.springframework.scheduling.quartz.LocalDataSourceJobStore"); + //集群配置 + prop.put("org.quartz.jobStore.isClustered", "true"); + prop.put("org.quartz.jobStore.clusterCheckinInterval", "15000"); + prop.put("org.quartz.jobStore.maxMisfiresToHandleAtATime", "1"); + + prop.put("org.quartz.jobStore.misfireThreshold", "12000"); + prop.put("org.quartz.jobStore.tablePrefix", "QRTZ_"); + prop.put("org.quartz.jobStore.selectWithLockSQL", "SELECT * FROM {0}LOCKS UPDLOCK WHERE LOCK_NAME = ?"); + + //PostgreSQL数据库,需要打开此注释 + //prop.put("org.quartz.jobStore.driverDelegateClass", "org.quartz.impl.jdbcjobstore.PostgreSQLDelegate"); + + factory.setQuartzProperties(prop); + + factory.setSchedulerName("IailabModelScheduler"); + //延时启动 + factory.setStartupDelay(30); + factory.setApplicationContextSchedulerContextKey("applicationContextKey"); + //可选,QuartzScheduler 启动时更新己存在的Job,这样就不用每次修改targetObject后删除qrtz_job_details表对应记录了 + factory.setOverwriteExistingJobs(true); + //设置自动启动,默认为true + factory.setAutoStartup(true); + + return factory; + } +} diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/controller/ScheduleJobController.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/controller/ScheduleJobController.java new file mode 100644 index 0000000..5a7cb19 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/controller/ScheduleJobController.java @@ -0,0 +1,115 @@ +package com.iailab.module.job.controller; + +import com.iailab.framework.common.page.PageData; +import com.iailab.common.utils.Constant; +import com.iailab.framework.common.pojo.CommonResult; +import com.iailab.framework.common.util.validation.ValidationUtils; +import com.iailab.framework.common.validation.group.AddGroup; +import com.iailab.framework.common.validation.group.DefaultGroup; +import com.iailab.framework.common.validation.group.UpdateGroup; +import com.iailab.module.job.dto.ScheduleJobDTO; +import com.iailab.module.job.service.ScheduleJobService; +import io.swagger.v3.oas.annotations.tags.Tag; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.Parameters; +import javax.annotation.Resource; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.*; + + +import java.util.Map; + +/** + * 定时任务 + * + * @author Mark sunlightcs@gmail.com + */ +@RestController +@RequestMapping("mcs/schedule") +@Tag(name = "定时任务") +public class ScheduleJobController { + @Resource + private ScheduleJobService scheduleJobService; + + @GetMapping("page") + @Operation(summary = "分页") + @Parameters({ + @Parameter(name = Constant.PAGE, description = "当前页码,从1开始", required = true) , + @Parameter(name = Constant.LIMIT, description = "每页显示记录数", required = true) , + @Parameter(name = Constant.ORDER_FIELD, description = "排序字段") , + @Parameter(name = Constant.ORDER, description = "排序方式,可选值(asc、desc)") , + @Parameter(name = "beanName", description = "beanName") + }) + public CommonResult<PageData<ScheduleJobDTO>> page(@RequestParam Map<String, Object> params){ + PageData<ScheduleJobDTO> page = scheduleJobService.page(params); + + return new CommonResult<PageData<ScheduleJobDTO>>().setData(page); + } + + @GetMapping("{id}") + @Operation(summary = "信息") + public CommonResult<ScheduleJobDTO> info(@PathVariable("id") Long id){ + ScheduleJobDTO schedule = scheduleJobService.get(id); + + return new CommonResult<ScheduleJobDTO>().setData(schedule); + } + + @PostMapping + @Operation(summary = "保存") + @PreAuthorize("@ss.hasPermission('mcs:schedule:save')") + public CommonResult save(@RequestBody ScheduleJobDTO dto){ + ValidationUtils.validate(dto, AddGroup.class, DefaultGroup.class); + + scheduleJobService.save(dto); + + return new CommonResult(); + } + + @PutMapping + @Operation(summary = "修改") + @PreAuthorize("@ss.hasPermission('mcs:schedule:update')") + public CommonResult update(@RequestBody ScheduleJobDTO dto){ + ValidationUtils.validate(dto, UpdateGroup.class, DefaultGroup.class); + + scheduleJobService.update(dto); + + return new CommonResult(); + } + + @DeleteMapping + @Operation(summary = "删除") + @PreAuthorize("@ss.hasPermission('mcs:schedule:delete')") + public CommonResult delete(@RequestBody Long[] ids){ + scheduleJobService.deleteBatch(ids); + + return new CommonResult(); + } + + @PutMapping("/run") + @Operation(summary = "立即执行") + @PreAuthorize("@ss.hasPermission('mcs:schedule:run')") + public CommonResult run(@RequestBody Long[] ids){ + scheduleJobService.run(ids); + + return new CommonResult(); + } + + @PutMapping("/pause") + @Operation(summary = "暂停") + @PreAuthorize("@ss.hasPermission('mcs:schedule:pause')") + public CommonResult pause(@RequestBody Long[] ids){ + scheduleJobService.pause(ids); + + return new CommonResult(); + } + + @PutMapping("/resume") + @Operation(summary = "恢复") + @PreAuthorize("@ss.hasPermission('mcs:schedule:resume')") + public CommonResult resume(@RequestBody Long[] ids){ + scheduleJobService.resume(ids); + return new CommonResult(); + } + +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/controller/ScheduleJobLogController.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/controller/ScheduleJobLogController.java new file mode 100644 index 0000000..a50a26f --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/controller/ScheduleJobLogController.java @@ -0,0 +1,63 @@ +/** + * Copyright (c) 2018 人人开源 All rights reserved. + * + * https://www.renren.io + * + * 版权所有,侵权必究! + */ + +package com.iailab.module.job.controller; + +import com.iailab.framework.common.page.PageData; +import com.iailab.common.utils.Constant; +import com.iailab.framework.common.pojo.CommonResult; +import com.iailab.module.job.dto.ScheduleJobLogDTO; +import com.iailab.module.job.service.ScheduleJobLogService; +import io.swagger.v3.oas.annotations.tags.Tag; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.Parameters; +import javax.annotation.Resource; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.*; + + +import java.util.Map; + +/** + * 定时任务日志 + * + * @author Mark sunlightcs@gmail.com + */ +@RestController +@RequestMapping("/mcs/scheduleLog") +@Tag(name = "定时任务日志") +public class ScheduleJobLogController { + @Resource + private ScheduleJobLogService scheduleJobLogService; + + @GetMapping("page") + @Operation(summary = "分页") + @Parameters({ + @Parameter(name = Constant.PAGE, description = "当前页码,从1开始", required = true) , + @Parameter(name = Constant.LIMIT, description = "每页显示记录数", required = true) , + @Parameter(name = Constant.ORDER_FIELD, description = "排序字段") , + @Parameter(name = Constant.ORDER, description = "排序方式,可选值(asc、desc)") , + @Parameter(name = "jobId", description = "jobId") + }) + @PreAuthorize("@ss.hasPermission('mcs:schedule:log')") + public CommonResult<PageData<ScheduleJobLogDTO>> page(@RequestParam Map<String, Object> params){ + PageData<ScheduleJobLogDTO> page = scheduleJobLogService.page(params); + + return new CommonResult<PageData<ScheduleJobLogDTO>>().setData(page); + } + + @GetMapping("{id}") + @Operation(summary = "信息") + @PreAuthorize("@ss.hasPermission('mcs:schedule:log')") + public CommonResult<ScheduleJobLogDTO> info(@PathVariable("id") Long id){ + ScheduleJobLogDTO log = scheduleJobLogService.get(id); + + return new CommonResult<ScheduleJobLogDTO>().setData(log); + } +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/dao/ScheduleJobDao.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/dao/ScheduleJobDao.java new file mode 100644 index 0000000..045b81f --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/dao/ScheduleJobDao.java @@ -0,0 +1,29 @@ +/** + * Copyright (c) 2018 人人开源 All rights reserved. + * + * https://www.renren.io + * + * 版权所有,侵权必究! + */ + +package com.iailab.module.job.dao; + +import com.iailab.framework.common.dao.BaseDao; +import com.iailab.module.job.entity.ScheduleJobEntity; +import org.apache.ibatis.annotations.Mapper; + +import java.util.Map; + +/** + * 定时任务 + * + * @author Mark sunlightcs@gmail.com + */ +@Mapper +public interface ScheduleJobDao extends BaseDao<ScheduleJobEntity> { + + /** + * 批量更新状态 + */ + int updateBatch(Map<String, Object> map); +} diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/dao/ScheduleJobLogDao.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/dao/ScheduleJobLogDao.java new file mode 100644 index 0000000..3140cbd --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/dao/ScheduleJobLogDao.java @@ -0,0 +1,23 @@ +/** + * Copyright (c) 2018 人人开源 All rights reserved. + * + * https://www.renren.io + * + * 版权所有,侵权必究! + */ + +package com.iailab.module.job.dao; + +import com.iailab.framework.common.dao.BaseDao; +import com.iailab.module.job.entity.ScheduleJobLogEntity; +import org.apache.ibatis.annotations.Mapper; + +/** + * 定时任务日志 + * + * @author Mark sunlightcs@gmail.com + */ +@Mapper +public interface ScheduleJobLogDao extends BaseDao<ScheduleJobLogEntity> { + +} diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/dto/ScheduleJobDTO.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/dto/ScheduleJobDTO.java new file mode 100644 index 0000000..72c6ce5 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/dto/ScheduleJobDTO.java @@ -0,0 +1,63 @@ +/** + * Copyright (c) 2018 人人开源 All rights reserved. + * + * https://www.renren.io + * + * 版权所有,侵权必究! + */ + +package com.iailab.module.job.dto; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.iailab.framework.common.validation.group.AddGroup; +import com.iailab.framework.common.validation.group.DefaultGroup; +import com.iailab.framework.common.validation.group.UpdateGroup; +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.Null; +import java.io.Serializable; +import java.util.Date; + +/** + * 定时任务 + * + * @author Mark sunlightcs@gmail.com + * @since 1.0.0 + */ +@Data +@Schema(name = "定时任务") +public class ScheduleJobDTO implements Serializable { + private static final long serialVersionUID = 1L; + + @Schema(name = "id") + @Null(message="{id.null}", groups = AddGroup.class) + @NotNull(message="{id.require}", groups = UpdateGroup.class) + private Long id; + + @Schema(name = "spring bean名称") + @NotBlank(message = "{schedule.bean.require}", groups = DefaultGroup.class) + private String beanName; + + @Schema(name = "参数") + private String params; + + @Schema(name = "cron表达式") + @NotBlank(message = "{schedule.cron.require}", groups = DefaultGroup.class) + private String cronExpression; + + @Schema(name = "任务状态 0:暂停 1:正常") +// @Range(min=0, max=1, message = "{schedule.status.range}", groups = DefaultGroup.class) + private Integer status; + + @Schema(name = "备注") + private String remark; + + @Schema(name = "创建时间") + @JsonProperty(access = JsonProperty.Access.READ_ONLY) + private Date createDate; + +} diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/dto/ScheduleJobLogDTO.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/dto/ScheduleJobLogDTO.java new file mode 100644 index 0000000..765578f --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/dto/ScheduleJobLogDTO.java @@ -0,0 +1,53 @@ +/** + * Copyright (c) 2018 人人开源 All rights reserved. + * + * https://www.renren.io + * + * 版权所有,侵权必究! + */ + +package com.iailab.module.job.dto; + +import io.swagger.v3.oas.annotations.media.Schema; + +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; + +/** + * 定时任务日志 + * + * @author Mark sunlightcs@gmail.com + * @since 1.0.0 + */ +@Data +@Schema(name = "定时任务日志") +public class ScheduleJobLogDTO implements Serializable { + private static final long serialVersionUID = 1L; + + @Schema(name = "id") + private Long id; + + @Schema(name = "任务id") + private Long jobId; + + @Schema(name = "spring bean名称") + private String beanName; + + @Schema(name = "参数") + private String params; + + @Schema(name = "任务状态 0:失败 1:成功") + private Integer status; + + @Schema(name = "失败信息") + private String error; + + @Schema(name = "耗时(单位:毫秒)") + private Integer times; + + @Schema(name = "创建时间") + private Date createDate; + +} diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/entity/ScheduleJobEntity.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/entity/ScheduleJobEntity.java new file mode 100644 index 0000000..06c4ede --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/entity/ScheduleJobEntity.java @@ -0,0 +1,61 @@ +/** + * Copyright (c) 2018 人人开源 All rights reserved. + * + * https://www.renren.io + * + * 版权所有,侵权必究! + */ + +package com.iailab.module.job.entity; + +import com.baomidou.mybatisplus.annotation.FieldFill; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; +import com.iailab.framework.common.entity.BaseEntity; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.util.Date; + +/** + * 定时任务 + * + * @author Mark sunlightcs@gmail.com + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("schedule_job") +public class ScheduleJobEntity extends BaseEntity { + private static final long serialVersionUID = 1L; + + /** + * spring bean名称 + */ + private String beanName; + /** + * 参数 + */ + private String params; + /** + * cron表达式 + */ + private String cronExpression; + /** + * 任务状态 0:暂停 1:正常 + */ + private Integer status; + /** + * 备注 + */ + private String remark; + /** + * 更新者 + */ + @TableField(fill = FieldFill.INSERT_UPDATE) + private Long updater; + /** + * 更新时间 + */ + @TableField(fill = FieldFill.INSERT_UPDATE) + private Date updateDate; +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/entity/ScheduleJobLogEntity.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/entity/ScheduleJobLogEntity.java new file mode 100644 index 0000000..8fee21e --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/entity/ScheduleJobLogEntity.java @@ -0,0 +1,62 @@ +/** + * Copyright (c) 2018 人人开源 All rights reserved. + * + * https://www.renren.io + * + * 版权所有,侵权必究! + */ + +package com.iailab.module.job.entity; + +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; + +/** + * 定时任务日志 + * + * @author Mark sunlightcs@gmail.com + */ +@Data +@TableName("schedule_job_log") +public class ScheduleJobLogEntity implements Serializable { + private static final long serialVersionUID = 1L; + + /** + * id + */ + @TableId + private Long id; + /** + * 任务id + */ + private Long jobId; + /** + * spring bean名称 + */ + private String beanName; + /** + * 参数 + */ + private String params; + /** + * 任务状态 0:失败 1:成功 + */ + private Integer status; + /** + * 失败信息 + */ + private String error; + /** + * 耗时(单位:毫秒) + */ + private Integer times; + /** + * 创建时间 + */ + private Date createDate; + +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/init/JobCommandLineRunner.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/init/JobCommandLineRunner.java new file mode 100644 index 0000000..76dd2c0 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/init/JobCommandLineRunner.java @@ -0,0 +1,47 @@ +/** + * Copyright (c) 2018 人人开源 All rights reserved. + * + * https://www.renren.io + * + * 版权所有,侵权必究! + */ + +package com.iailab.module.job.init; + +import com.iailab.module.job.dao.ScheduleJobDao; +import com.iailab.module.job.entity.ScheduleJobEntity; +import com.iailab.module.job.utils.ScheduleUtils; +import org.quartz.CronTrigger; +import org.quartz.Scheduler; +import javax.annotation.Resource; +import org.springframework.boot.CommandLineRunner; +import org.springframework.stereotype.Component; + +import java.util.List; + +/** + * 初始化定时任务数据 + * + * @author Mark sunlightcs@gmail.com + */ +@Component +public class JobCommandLineRunner implements CommandLineRunner { + @Resource + private Scheduler scheduler; + @Resource + private ScheduleJobDao scheduleJobDao; + + @Override + public void run(String... args) { + List<ScheduleJobEntity> scheduleJobList = scheduleJobDao.selectList(null); + for(ScheduleJobEntity scheduleJob : scheduleJobList){ + CronTrigger cronTrigger = ScheduleUtils.getCronTrigger(scheduler, scheduleJob.getId()); + //如果不存在,则创建 + if(cronTrigger == null) { + ScheduleUtils.createScheduleJob(scheduler, scheduleJob); + }else { + ScheduleUtils.updateScheduleJob(scheduler, scheduleJob); + } + } + } +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/service/ScheduleJobLogService.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/service/ScheduleJobLogService.java new file mode 100644 index 0000000..85b899a --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/service/ScheduleJobLogService.java @@ -0,0 +1,28 @@ +/** + * Copyright (c) 2018 人人开源 All rights reserved. + * + * https://www.renren.io + * + * 版权所有,侵权必究! + */ + +package com.iailab.module.job.service; + +import com.iailab.framework.common.page.PageData; +import com.iailab.framework.common.service.BaseService; +import com.iailab.module.job.dto.ScheduleJobLogDTO; +import com.iailab.module.job.entity.ScheduleJobLogEntity; + +import java.util.Map; + +/** + * 定时任务日志 + * + * @author Mark sunlightcs@gmail.com + */ +public interface ScheduleJobLogService extends BaseService<ScheduleJobLogEntity> { + + PageData<ScheduleJobLogDTO> page(Map<String, Object> params); + + ScheduleJobLogDTO get(Long id); +} diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/service/ScheduleJobService.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/service/ScheduleJobService.java new file mode 100644 index 0000000..5d1242f --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/service/ScheduleJobService.java @@ -0,0 +1,63 @@ +/** + * Copyright (c) 2018 人人开源 All rights reserved. + * + * https://www.renren.io + * + * 版权所有,侵权必究! + */ + +package com.iailab.module.job.service; + +import com.iailab.framework.common.page.PageData; +import com.iailab.framework.common.service.BaseService; +import com.iailab.module.job.dto.ScheduleJobDTO; +import com.iailab.module.job.entity.ScheduleJobEntity; + +import java.util.Map; + +/** + * 定时任务 + * + * @author Mark sunlightcs@gmail.com + */ +public interface ScheduleJobService extends BaseService<ScheduleJobEntity> { + + PageData<ScheduleJobDTO> page(Map<String, Object> params); + + ScheduleJobDTO get(Long id); + + /** + * 保存定时任务 + */ + void save(ScheduleJobDTO dto); + + /** + * 更新定时任务 + */ + void update(ScheduleJobDTO dto); + + /** + * 批量删除定时任务 + */ + void deleteBatch(Long[] ids); + + /** + * 批量更新定时任务状态 + */ + int updateBatch(Long[] ids, int status); + + /** + * 立即执行 + */ + void run(Long[] ids); + + /** + * 暂停运行 + */ + void pause(Long[] ids); + + /** + * 恢复运行 + */ + void resume(Long[] ids); +} diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/service/impl/ScheduleJobLogServiceImpl.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/service/impl/ScheduleJobLogServiceImpl.java new file mode 100644 index 0000000..5f0d220 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/service/impl/ScheduleJobLogServiceImpl.java @@ -0,0 +1,54 @@ +/** + * Copyright (c) 2018 人人开源 All rights reserved. + * + * https://www.renren.io + * + * 版权所有,侵权必究! + */ + +package com.iailab.module.job.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.iailab.framework.common.constant.Constant; +import com.iailab.framework.common.page.PageData; +import com.iailab.framework.common.service.impl.BaseServiceImpl; +import com.iailab.framework.common.util.object.ConvertUtils; +import com.iailab.module.job.dao.ScheduleJobLogDao; +import com.iailab.module.job.dto.ScheduleJobLogDTO; +import com.iailab.module.job.entity.ScheduleJobLogEntity; +import com.iailab.module.job.service.ScheduleJobLogService; +import org.apache.commons.lang3.StringUtils; +import org.springframework.stereotype.Service; + +import java.util.Map; + +@Service +public class ScheduleJobLogServiceImpl extends BaseServiceImpl<ScheduleJobLogDao, ScheduleJobLogEntity> implements ScheduleJobLogService { + + @Override + public PageData<ScheduleJobLogDTO> page(Map<String, Object> params) { + IPage<ScheduleJobLogEntity> page = baseDao.selectPage( + getPage(params, Constant.CREATE_DATE, false), + getWrapper(params) + ); + return getPageData(page, ScheduleJobLogDTO.class); + } + + private QueryWrapper<ScheduleJobLogEntity> getWrapper(Map<String, Object> params){ + String jobId = (String)params.get("jobId"); + + QueryWrapper<ScheduleJobLogEntity> wrapper = new QueryWrapper<>(); + wrapper.eq(StringUtils.isNotBlank(jobId), "job_id", jobId); + + return wrapper; + } + + @Override + public ScheduleJobLogDTO get(Long id) { + ScheduleJobLogEntity entity = baseDao.selectById(id); + + return ConvertUtils.sourceToTarget(entity, ScheduleJobLogDTO.class); + } + +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/service/impl/ScheduleJobServiceImpl.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/service/impl/ScheduleJobServiceImpl.java new file mode 100644 index 0000000..2cd5602 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/service/impl/ScheduleJobServiceImpl.java @@ -0,0 +1,131 @@ +/** + * Copyright (c) 2018 人人开源 All rights reserved. + * + * https://www.renren.io + * + * 版权所有,侵权必究! + */ + +package com.iailab.module.job.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.iailab.framework.common.constant.Constant; +import com.iailab.framework.common.page.PageData; +import com.iailab.framework.common.service.impl.BaseServiceImpl; +import com.iailab.framework.common.util.object.ConvertUtils; +import com.iailab.module.job.dao.ScheduleJobDao; +import com.iailab.module.job.dto.ScheduleJobDTO; +import com.iailab.module.job.entity.ScheduleJobEntity; +import com.iailab.module.job.service.ScheduleJobService; +import com.iailab.module.job.utils.ScheduleUtils; +import org.apache.commons.lang3.StringUtils; +import org.quartz.Scheduler; +import javax.annotation.Resource; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.Arrays; +import java.util.Date; +import java.util.HashMap; +import java.util.Map; + +@Service +public class ScheduleJobServiceImpl extends BaseServiceImpl<ScheduleJobDao, ScheduleJobEntity> implements ScheduleJobService { + @Resource + private Scheduler scheduler; + + @Override + public PageData<ScheduleJobDTO> page(Map<String, Object> params) { + IPage<ScheduleJobEntity> page = baseDao.selectPage( + getPage(params, Constant.CREATE_DATE, false), + getWrapper(params) + ); + return getPageData(page, ScheduleJobDTO.class); + } + + @Override + public ScheduleJobDTO get(Long id) { + ScheduleJobEntity entity = baseDao.selectById(id); + + return ConvertUtils.sourceToTarget(entity, ScheduleJobDTO.class); + } + + private QueryWrapper<ScheduleJobEntity> getWrapper(Map<String, Object> params){ + String beanName = (String)params.get("beanName"); + + QueryWrapper<ScheduleJobEntity> wrapper = new QueryWrapper<>(); + wrapper.like(StringUtils.isNotBlank(beanName), "bean_name", beanName); + + return wrapper; + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void save(ScheduleJobDTO dto) { + ScheduleJobEntity entity = ConvertUtils.sourceToTarget(dto, ScheduleJobEntity.class); + entity.setCreateDate(new Date()); + entity.setStatus(Constant.ScheduleStatus.NORMAL.getValue()); + this.insert(entity); + + ScheduleUtils.createScheduleJob(scheduler, entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void update(ScheduleJobDTO dto) { + ScheduleJobEntity entity = ConvertUtils.sourceToTarget(dto, ScheduleJobEntity.class); + entity.setUpdateDate(new Date()); + ScheduleUtils.updateScheduleJob(scheduler, entity); + + this.updateById(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void deleteBatch(Long[] ids) { + for(Long id : ids){ + ScheduleUtils.deleteScheduleJob(scheduler, id); + } + + //删除数据 + this.deleteBatchIds(Arrays.asList(ids)); + } + + @Override + public int updateBatch(Long[] ids, int status){ + Map<String, Object> map = new HashMap<>(2); + map.put("ids", ids); + map.put("status", status); + return baseDao.updateBatch(map); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void run(Long[] ids) { + for(Long id : ids){ + ScheduleUtils.run(scheduler, this.selectById(id)); + } + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void pause(Long[] ids) { + for(Long id : ids){ + ScheduleUtils.pauseJob(scheduler, id); + } + + updateBatch(ids, Constant.ScheduleStatus.PAUSE.getValue()); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void resume(Long[] ids) { + for(Long id : ids){ + ScheduleUtils.resumeJob(scheduler, id); + } + + updateBatch(ids, Constant.ScheduleStatus.NORMAL.getValue()); + } + +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/AnyProc1Task.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/AnyProc1Task.java new file mode 100644 index 0000000..8b56e1f --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/AnyProc1Task.java @@ -0,0 +1,80 @@ +package com.iailab.module.job.task; + +import com.iailab.module.any.dto.AnyProcCardDTO; +import com.iailab.module.any.service.AnyProcCardService; +import com.iailab.module.any.service.AnyProcReportService; +import com.iailab.module.model.handler.ModelHandler; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import javax.annotation.Resource; +import org.springframework.stereotype.Component; + +import java.util.Calendar; +import java.util.Date; +import java.util.Map; + +/** + * 浅槽分选307控制诊断 + * 10 0 0/2 * * ? + * + * @author PanZhibao + * @Description + * @createTime 2024年06月25日 + */ +@Component("anyProc1Task") +public class AnyProc1Task implements ITask { + private Logger logger = LoggerFactory.getLogger(getClass()); + + private final String MODEL_CODE = "shallow_separation_diagnosis_307"; + + private final String CARD_CODE = "C01"; + + private final String REPORT_NAME = "浅槽分选307控制诊断"; + + @Resource + private ModelHandler modelHandler; + + @Resource + private AnyProcCardService anyProcCardService; + + @Resource + private AnyProcReportService anyProcReportService; + + + @Override + public void run(String params) { + Calendar calendar = Calendar.getInstance(); + calendar.set(Calendar.MILLISECOND, 0); + calendar.set(Calendar.SECOND, 0); + try { + Map<String, Object> modelCommonResult = modelHandler.run(MODEL_CODE, calendar.getTime()); + + StringBuilder sb = new StringBuilder(); + sb.append(modelCommonResult.get("hj_str_307") + ";"); + sb.append(modelCommonResult.get("xj_str_307") + ";"); + sb.append(modelCommonResult.get("mn_str_307") + ";"); + sb.append(modelCommonResult.get("cxw_str_307") + ";"); + sb.append(modelCommonResult.get("hj_md_str_307") + ";"); + sb.append(modelCommonResult.get("hf_str_307") + ";"); + + // 更新状态 + this.updateCard(sb.toString(), calendar.getTime()); + + // 生成报告 + anyProcReportService.saveReport(CARD_CODE, REPORT_NAME, sb.toString(), calendar.getTime()); + } catch (Exception ex) { + logger.error("AnyProc1Task运行异常"); + ex.printStackTrace(); + } + logger.info("AnyProc1Task运行完成"); + + } + + private void updateCard(String content, Date runTime) { + AnyProcCardDTO dto = new AnyProcCardDTO(); + dto.setCode(CARD_CODE); + dto.setAlarmInfo(content); + dto.setAnyTime(runTime); + anyProcCardService.updateByCode(dto); + } +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/AnyProc2Task.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/AnyProc2Task.java new file mode 100644 index 0000000..2182484 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/AnyProc2Task.java @@ -0,0 +1,80 @@ +package com.iailab.module.job.task; + +import com.iailab.module.any.dto.AnyProcCardDTO; +import com.iailab.module.any.service.AnyProcCardService; +import com.iailab.module.any.service.AnyProcReportService; +import com.iailab.module.model.handler.ModelHandler; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import javax.annotation.Resource; +import org.springframework.stereotype.Component; + +import java.util.Calendar; +import java.util.Date; +import java.util.Map; + +/** + * 浅槽分选308控制诊断 + * 10 0 0/2 * * ? + * + * @author PanZhibao + * @Description + * @createTime 2024年06月25日 + */ +@Component("anyProc2Task") +public class AnyProc2Task implements ITask { + private Logger logger = LoggerFactory.getLogger(getClass()); + + private final String MODEL_CODE = "shallow_separation_diagnosis_308"; + + private final String CARD_CODE = "C02"; + + private final String REPORT_NAME = "浅槽分选308控制诊断"; + + @Resource + private ModelHandler modelHandler; + + @Resource + private AnyProcCardService anyProcCardService; + + @Resource + private AnyProcReportService anyProcReportService; + + + @Override + public void run(String params) { + Calendar calendar = Calendar.getInstance(); + calendar.set(Calendar.MILLISECOND, 0); + calendar.set(Calendar.SECOND, 0); + try { + Map<String, Object> modelCommonResult = modelHandler.run(MODEL_CODE, calendar.getTime()); + + StringBuilder sb = new StringBuilder(); + sb.append(modelCommonResult.get("hj_str_308") + ";"); + sb.append(modelCommonResult.get("xj_str_308") + ";"); + sb.append(modelCommonResult.get("mn_str_308") + ";"); + sb.append(modelCommonResult.get("cxw_str_308") + ";"); + sb.append(modelCommonResult.get("hj_md_str_308") + ";"); + sb.append(modelCommonResult.get("hf_str_308") + ";"); + + // 更新状态 + this.updateCard(sb.toString(), calendar.getTime()); + + // 生成报告 + anyProcReportService.saveReport(CARD_CODE, REPORT_NAME, sb.toString(), calendar.getTime()); + } catch (Exception ex) { + logger.error("AnyProc2Task运行异常"); + ex.printStackTrace(); + } + logger.info("AnyProc2Task运行完成"); + + } + + private void updateCard(String content, Date runTime) { + AnyProcCardDTO dto = new AnyProcCardDTO(); + dto.setCode(CARD_CODE); + dto.setAlarmInfo(content); + dto.setAnyTime(runTime); + anyProcCardService.updateByCode(dto); + } +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/AnyProc3Task.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/AnyProc3Task.java new file mode 100644 index 0000000..92e977c --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/AnyProc3Task.java @@ -0,0 +1,83 @@ +package com.iailab.module.job.task; + +import com.iailab.module.any.dto.AnyProcCardDTO; +import com.iailab.module.any.service.AnyProcCardService; +import com.iailab.module.any.service.AnyProcReportService; +import com.iailab.module.model.handler.ModelHandler; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import javax.annotation.Resource; +import org.springframework.stereotype.Component; + +import java.util.Calendar; +import java.util.Date; +import java.util.Map; + +/** + * 旋流器分选3318控制诊断 + * 10 0 0/2 * * ? + * + * @author PanZhibao + * @Description + * @createTime 2024年06月26日 + */ +@Component("anyProc3Task") +public class AnyProc3Task implements ITask { + + private Logger logger = LoggerFactory.getLogger(getClass()); + + private final String MODEL_CODE = "separation_diagnosis_3318"; + + private final String CARD_CODE = "C03"; + + private final String REPORT_NAME = "旋流器分选3318控制诊断"; + + @Resource + private ModelHandler modelHandler; + + @Resource + private AnyProcCardService anyProcCardService; + + @Resource + private AnyProcReportService anyProcReportService; + + + @Override + public void run(String params) { + Calendar calendar = Calendar.getInstance(); + calendar.set(Calendar.MILLISECOND, 0); + calendar.set(Calendar.SECOND, 0); + try { + Map<String, Object> modelCommonResult = modelHandler.run(MODEL_CODE, calendar.getTime()); + + StringBuilder sb = new StringBuilder(); + sb.append(modelCommonResult.get("hl_str") + ";"); + sb.append(modelCommonResult.get("hj_str") + ";"); + sb.append(modelCommonResult.get("xj_str") + ";"); + sb.append(modelCommonResult.get("mn_str") + ";"); + sb.append(modelCommonResult.get("yl_str") + ";"); + sb.append(modelCommonResult.get("cxw_str") + ";"); + sb.append(modelCommonResult.get("hj_md_str") + ";"); + sb.append(modelCommonResult.get("hf_str") + ";"); + + // 更新状态 + this.updateCard(sb.toString(), calendar.getTime()); + + // 生成报告 + anyProcReportService.saveReport(CARD_CODE, REPORT_NAME, sb.toString(), calendar.getTime()); + } catch (Exception ex) { + logger.error("AnyProc1Task运行异常"); + ex.printStackTrace(); + } + logger.info("AnyProc1Task运行完成"); + + } + + private void updateCard(String content, Date runTime) { + AnyProcCardDTO dto = new AnyProcCardDTO(); + dto.setCode(CARD_CODE); + dto.setAlarmInfo(content); + dto.setAnyTime(runTime); + anyProcCardService.updateByCode(dto); + } +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/AnyProc4Task.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/AnyProc4Task.java new file mode 100644 index 0000000..39fc6b5 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/AnyProc4Task.java @@ -0,0 +1,83 @@ +package com.iailab.module.job.task; + +import com.iailab.module.any.dto.AnyProcCardDTO; +import com.iailab.module.any.service.AnyProcCardService; +import com.iailab.module.any.service.AnyProcReportService; +import com.iailab.module.model.handler.ModelHandler; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import javax.annotation.Resource; +import org.springframework.stereotype.Component; + +import java.util.Calendar; +import java.util.Date; +import java.util.Map; + +/** + * 旋流器分选3319控制诊断 + * 10 0 0/2 * * ? + * + * @author PanZhibao + * @Description + * @createTime 2024年06月26日 + */ +@Component("anyProc4Task") +public class AnyProc4Task implements ITask { + + private Logger logger = LoggerFactory.getLogger(getClass()); + + private final String MODEL_CODE = "separation_diagnosis_3319"; + + private final String CARD_CODE = "C04"; + + private final String REPORT_NAME = "旋流器分选3319控制诊断"; + + @Resource + private ModelHandler modelHandler; + + @Resource + private AnyProcCardService anyProcCardService; + + @Resource + private AnyProcReportService anyProcReportService; + + + @Override + public void run(String params) { + Calendar calendar = Calendar.getInstance(); + calendar.set(Calendar.MILLISECOND, 0); + calendar.set(Calendar.SECOND, 0); + try { + Map<String, Object> modelCommonResult = modelHandler.run(MODEL_CODE, calendar.getTime()); + + StringBuilder sb = new StringBuilder(); + sb.append(modelCommonResult.get("hl_str") + ";"); + sb.append(modelCommonResult.get("hj_str") + ";"); + sb.append(modelCommonResult.get("xj_str") + ";"); + sb.append(modelCommonResult.get("mn_str") + ";"); + sb.append(modelCommonResult.get("yl_str") + ";"); + sb.append(modelCommonResult.get("cxw_str") + ";"); + sb.append(modelCommonResult.get("hj_md_str") + ";"); + sb.append(modelCommonResult.get("hf_str") + ";"); + + // 更新状态 + this.updateCard(sb.toString(), calendar.getTime()); + + // 生成报告 + anyProcReportService.saveReport(CARD_CODE, REPORT_NAME, sb.toString(), calendar.getTime()); + } catch (Exception ex) { + logger.error("AnyProc1Task运行异常"); + ex.printStackTrace(); + } + logger.info("AnyProc1Task运行完成"); + + } + + private void updateCard(String content, Date runTime) { + AnyProcCardDTO dto = new AnyProcCardDTO(); + dto.setCode(CARD_CODE); + dto.setAlarmInfo(content); + dto.setAnyTime(runTime); + anyProcCardService.updateByCode(dto); + } +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/AnyProc5Task.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/AnyProc5Task.java new file mode 100644 index 0000000..318b300 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/AnyProc5Task.java @@ -0,0 +1,77 @@ +package com.iailab.module.job.task; + +import com.iailab.module.any.dto.AnyProcCardDTO; +import com.iailab.module.any.service.AnyProcCardService; +import com.iailab.module.any.service.AnyProcReportService; +import com.iailab.module.model.handler.ModelHandler; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import javax.annotation.Resource; +import org.springframework.stereotype.Component; + +import java.util.Calendar; +import java.util.Date; +import java.util.Map; + +/** + * 浅槽浓缩控制诊断 + * 10 0 0/2 * * ? + * + * @author PanZhibao + * @Description + * @createTime 2024年06月26日 + */ +@Component("anyProc5Task") +public class AnyProc5Task implements ITask { + + private Logger logger = LoggerFactory.getLogger(getClass()); + + private final String MODEL_CODE = "thickener_qc_analyis"; + + private final String CARD_CODE = "C05"; + + private final String REPORT_NAME = "浅槽浓缩控制诊断"; + + @Resource + private ModelHandler modelHandler; + + @Resource + private AnyProcCardService anyProcCardService; + + @Resource + private AnyProcReportService anyProcReportService; + + + @Override + public void run(String params) { + Calendar calendar = Calendar.getInstance(); + calendar.set(Calendar.MILLISECOND, 0); + calendar.set(Calendar.SECOND, 0); + try { + Map<String, Object> modelCommonResult = modelHandler.run(MODEL_CODE, calendar.getTime()); + + StringBuilder sb = new StringBuilder(); + sb.append(modelCommonResult.get("qs_str") + ";"); + sb.append(modelCommonResult.get("yl_str") + ";"); + sb.append(modelCommonResult.get("dl_str") + ";"); + // 更新状态 + this.updateCard(sb.toString(), calendar.getTime()); + + // 生成报告 + anyProcReportService.saveReport(CARD_CODE, REPORT_NAME, sb.toString(), calendar.getTime()); + } catch (Exception ex) { + logger.error("AnyProc1Task运行异常"); + ex.printStackTrace(); + } + logger.info("AnyProc1Task运行完成"); + + } + + private void updateCard(String content, Date runTime) { + AnyProcCardDTO dto = new AnyProcCardDTO(); + dto.setCode(CARD_CODE); + dto.setAlarmInfo(content); + dto.setAnyTime(runTime); + anyProcCardService.updateByCode(dto); + } +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/AnyProc6Task.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/AnyProc6Task.java new file mode 100644 index 0000000..91b12d9 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/AnyProc6Task.java @@ -0,0 +1,78 @@ +package com.iailab.module.job.task; + +import com.iailab.module.any.dto.AnyProcCardDTO; +import com.iailab.module.any.service.AnyProcCardService; +import com.iailab.module.any.service.AnyProcReportService; +import com.iailab.module.model.handler.ModelHandler; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import javax.annotation.Resource; +import org.springframework.stereotype.Component; + +import java.util.Calendar; +import java.util.Date; +import java.util.Map; + +/** + * 旋流浓缩控制诊断 + * 10 0 0/2 * * ? + * + * @author PanZhibao + * @Description + * @createTime 2024年06月26日 + */ +@Component("anyProc6Task") +public class AnyProc6Task implements ITask { + + private Logger logger = LoggerFactory.getLogger(getClass()); + + private final String MODEL_CODE = "thickener_xl_analyis"; + + private final String CARD_CODE = "C06"; + + private final String REPORT_NAME = "旋流浓缩控制诊断"; + + @Resource + private ModelHandler modelHandler; + + @Resource + private AnyProcCardService anyProcCardService; + + @Resource + private AnyProcReportService anyProcReportService; + + + @Override + public void run(String params) { + Calendar calendar = Calendar.getInstance(); + calendar.set(Calendar.MILLISECOND, 0); + calendar.set(Calendar.SECOND, 0); + try { + Map<String, Object> modelCommonResult = modelHandler.run(MODEL_CODE, calendar.getTime()); + + StringBuilder sb = new StringBuilder(); + sb.append(modelCommonResult.get("qs_str") + ";"); + sb.append(modelCommonResult.get("yl_str") + ";"); + sb.append(modelCommonResult.get("dl_str") + ";"); + + // 更新状态 + this.updateCard(sb.toString(), calendar.getTime()); + + // 生成报告 + anyProcReportService.saveReport(CARD_CODE, REPORT_NAME, sb.toString(), calendar.getTime()); + } catch (Exception ex) { + logger.error("AnyProc1Task运行异常"); + ex.printStackTrace(); + } + logger.info("AnyProc1Task运行完成"); + + } + + private void updateCard(String content, Date runTime) { + AnyProcCardDTO dto = new AnyProcCardDTO(); + dto.setCode(CARD_CODE); + dto.setAlarmInfo(content); + dto.setAnyTime(runTime); + anyProcCardService.updateByCode(dto); + } +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/AnyProc7Task.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/AnyProc7Task.java new file mode 100644 index 0000000..fbb2170 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/AnyProc7Task.java @@ -0,0 +1,83 @@ +package com.iailab.module.job.task; + +import com.iailab.module.any.dto.AnyProcCardDTO; +import com.iailab.module.any.service.AnyProcCardService; +import com.iailab.module.any.service.AnyProcReportService; +import com.iailab.module.model.handler.ModelHandler; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import javax.annotation.Resource; +import org.springframework.stereotype.Component; + +import java.util.Calendar; +import java.util.Date; +import java.util.Map; + +/** + * 旋流压滤控制诊断 + * 10 0 0/2 * * ? + * + * @author PanZhibao + * @Description + * @createTime 2024年06月26日 + */ +@Component("anyProc7Task") +public class AnyProc7Task implements ITask { + + private Logger logger = LoggerFactory.getLogger(getClass()); + + private final String MODEL_CODE = "filter_analyis"; + + private final String CARD_CODE = "C07"; + + private final String REPORT_NAME = "旋流压滤控制诊断"; + + @Resource + private ModelHandler modelHandler; + + @Resource + private AnyProcCardService anyProcCardService; + + @Resource + private AnyProcReportService anyProcReportService; + + + @Override + public void run(String params) { + Calendar calendar = Calendar.getInstance(); + calendar.set(Calendar.MILLISECOND, 0); + calendar.set(Calendar.SECOND, 0); + try { + Map<String, Object> modelCommonResult = modelHandler.run(MODEL_CODE, calendar.getTime()); + + StringBuilder sb = new StringBuilder(); + sb.append(modelCommonResult.get("rlc_str") + ";"); + sb.append(modelCommonResult.get("pd_str") + ";"); + sb.append(modelCommonResult.get("dl_str") + ";"); + sb.append(modelCommonResult.get("str_4423") + ";"); + sb.append(modelCommonResult.get("str_4424") + ";"); + sb.append(modelCommonResult.get("str_4425") + ";"); + sb.append(modelCommonResult.get("str_4426") + ";"); + sb.append(modelCommonResult.get("str_4427") + ";"); + + // 更新状态 + this.updateCard(sb.toString(), calendar.getTime()); + + // 生成报告 + anyProcReportService.saveReport(CARD_CODE, REPORT_NAME, sb.toString(), calendar.getTime()); + } catch (Exception ex) { + logger.error("AnyProc1Task运行异常"); + ex.printStackTrace(); + } + logger.info("AnyProc1Task运行完成"); + + } + + private void updateCard(String content, Date runTime) { + AnyProcCardDTO dto = new AnyProcCardDTO(); + dto.setCode(CARD_CODE); + dto.setAlarmInfo(content); + dto.setAnyTime(runTime); + anyProcCardService.updateByCode(dto); + } +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/DeviceHealthTask.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/DeviceHealthTask.java new file mode 100644 index 0000000..48d85ca --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/DeviceHealthTask.java @@ -0,0 +1,380 @@ +package com.iailab.module.job.task; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; +import com.iailab.framework.common.util.object.ConvertUtils; +import com.iailab.common.utils.DateUtils; +import com.iailab.module.device.commons.HealthIndexTypeEnum; +import com.iailab.module.device.commons.HealthLevelEnum; +import com.iailab.module.device.entity.DeviceStatCountEntity; +import com.iailab.module.device.entity.DeviceStatNewnessEntity; +import com.iailab.module.device.dto.*; +import com.iailab.module.device.service.*; +import com.iailab.module.model.handler.ModelHandler; +import com.iailab.module.model.sample.constructor.SampleDataConstructor; +import com.iailab.module.model.sample.constructor.SampleInfoConstructor; +import com.iailab.module.model.sample.dto.ColumnItem; +import com.iailab.module.model.sample.entity.DataEntity; +import org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import javax.annotation.Resource; +import org.springframework.stereotype.Component; +import org.springframework.util.CollectionUtils; + +import java.math.BigDecimal; +import java.util.*; +import java.util.stream.Collectors; + +/** + * 设备健康评价 + * 10 0 0/1 * * ? + * + * @author PanZhibao + * @Description + * @createTime 2024年06月29日 + */ +@Component("deviceHealthTask") +public class DeviceHealthTask implements ITask { + private Logger logger = LoggerFactory.getLogger(getClass()); + + + private BigDecimal DEFAULT_HEALTH_SCORE = new BigDecimal(100); + + private String DEFAULT_REPORT_CONTENT = "设备运行正常"; + + private int DEFAULT_DATA_LENGTH = 60; + + @Resource + private DeviceHealthEvaluateService deviceHealthEvaluateService; + + @Resource + private DeviceEvaluateIndexService deviceEvaluateIndexService; + + @Resource + private SampleInfoConstructor sampleInfoConstructor; + + @Resource + private SampleDataConstructor sampleDataConstructor; + + @Resource + private ModelHandler modelHandler; + + @Resource + private DeviceHealthReportService deviceHealthReportService; + + @Resource + private DeviceStatCountService deviceStatCountService; + + @Resource + private DeviceInfoService deviceInfoService; + + @Resource + private DeviceFaultService deviceFaultService; + + @Resource + private DeviceStatNewnessService deviceStatNewnessService; + + private final int GRANULARITY = 60; + + private Map<Integer, String> HEALTH_FAULT_TYPE = new HashMap<>(); + private Map<String, String> ALARM_INDEX_TYPE = new HashMap<>(); + + private String[] indexArr = new String[]{HealthIndexTypeEnum.elec.getCode(), HealthIndexTypeEnum.temperature.getCode(), + HealthIndexTypeEnum.flutter.getCode(), HealthIndexTypeEnum.runTime.getCode()}; + + + + DeviceHealthTask() { + HEALTH_FAULT_TYPE.put(1, "波动正常,趋势正常"); + HEALTH_FAULT_TYPE.put(2, "波动正常,趋势异常"); + HEALTH_FAULT_TYPE.put(3, "波动异常,趋势正常"); + HEALTH_FAULT_TYPE.put(4, "波动异常,趋势异常"); + + ALARM_INDEX_TYPE.put("temperature", "温度"); + ALARM_INDEX_TYPE.put("flutter", "震动"); + ALARM_INDEX_TYPE.put("elec", "电流"); + } + + @Override + public void run(String params) { + Calendar calendar = Calendar.getInstance(); + calendar.set(Calendar.MILLISECOND, 0); + calendar.set(Calendar.SECOND, 0); + try { + List<DeviceStatNewnessEntity> newnessList = new ArrayList<>(); + Map<String, Object> queryParams = new HashMap<>(); + queryParams.put("isEnable", 1); + List<DeviceHealthEvaluateDTO> evaList = deviceHealthEvaluateService.list(queryParams); + if (CollectionUtils.isEmpty(evaList)) { + return; + } + // 开始健康评价 + evaList.forEach(item -> { + this.runModel(item, calendar.getTime(), newnessList); + }); + + // 统计数量 + deviceStatCount(calendar); + + // 更新设备新度系数 + deviceStatNewnessService.statNewness(newnessList, calendar.getTime()); + + } catch (Exception ex) { + logger.error("DeviceHealthTask运行异常"); + ex.printStackTrace(); + } + logger.info("DeviceHealthTask运行完成"); + } + + public void runModel(DeviceHealthEvaluateDTO dto, Date runTime, List<DeviceStatNewnessEntity> newnessList) { + try { + List<DeviceEvaluateIndexDTO> indexList = deviceEvaluateIndexService.listByEvaluateId(dto.getId()); + if (CollectionUtils.isEmpty(indexList)) { + DeviceHealthEvaluateDTO updateDto = new DeviceHealthEvaluateDTO(); + updateDto.setId(dto.getId()); + updateDto.setReportContent(DEFAULT_REPORT_CONTENT); + updateDto.setReportDate(runTime); + updateDto.setReportId(""); + updateDto.setAbnormalCount(0); + updateDto.setHealthScore(DEFAULT_HEALTH_SCORE); + updateDto.setHealthLevel(HealthLevelEnum.Level1.getCode()); + deviceHealthEvaluateService.updateReport(updateDto); + return; + } + Map<String, DeviceEvaluateIndexDTO> indexMap = new HashMap<>(); + indexList.forEach(item -> { + indexMap.put(item.getIndexType(), item); + }); + + DEFAULT_DATA_LENGTH = indexList.get(0).getDataLength(); + + ColumnItem columnItem = new ColumnItem(); + columnItem.setEndTime(runTime); + columnItem.setStartTime(sampleInfoConstructor.calculateTime(runTime, true, DEFAULT_DATA_LENGTH - 1, GRANULARITY)); + List<double[][]> sampleDataList = new ArrayList<>(); + Map<String, List<DataEntity>> dataMap = new LinkedHashMap<>(); + + double[][] matrix1 = new double[DEFAULT_DATA_LENGTH][indexArr.length]; + double[][] matrix2 = new double[1][3]; + for (int i = 0; i < indexArr.length; i++) { + if (indexMap.get(indexArr[i]) == null) { + for (int k = 0; k < DEFAULT_DATA_LENGTH; k++) { + matrix1[k][i] = -2; + } + continue; + } + DeviceEvaluateIndexDTO indDTO = indexMap.get(indexArr[i]); + columnItem.setParamId(indDTO.getParamId()); + columnItem.setParamType(indDTO.getParamType()); + List<DataEntity> dataEntityList = sampleDataConstructor.getColumnData(columnItem); + logger.info("BEF:ParamType=" + indDTO.getParamType() + ";ParamId=" + indDTO.getParamId() + ";size=" + dataEntityList.size()); + //补全数据 + dataEntityList = sampleDataConstructor.completionData(matrix1.length, dataEntityList, columnItem.startTime, columnItem.endTime, GRANULARITY); + logger.info("AFT:ParamType=" + indDTO.getParamType() + ";ParamId=" + indDTO.getParamId() + ";size=" + dataEntityList.size()); + if (CollectionUtils.isEmpty(dataEntityList)) { + continue; + } + for (int k = 0; k < DEFAULT_DATA_LENGTH; k++) { + matrix1[k][i] = dataEntityList.get(k).getDataValue(); + } + dataMap.put(indexArr[i], dataEntityList); + + if (i < 3) { + matrix2[0][i] = indDTO.getNominalValue().doubleValue(); + } + } + sampleDataList.add(matrix1); + sampleDataList.add(matrix2); + + // 调用模型 + logger.info("调用模型,DevNo=" + dto.getDevNo()); + Map<String, Object> modelCommonResult = modelHandler.run(dto.getModelCode(), sampleDataList); + + // 生成评价报告 + this.saveReport(dto, runTime, modelCommonResult, dataMap, indexMap); + + // 更新新度系数 + if (modelCommonResult.get("run_time_adjust") != null) { + DeviceStatNewnessEntity deviceStatNewness = new DeviceStatNewnessEntity(); + deviceStatNewness.setDevNo(dto.getDevNo()); + deviceStatNewness.setDevName(dto.getDevName()); + deviceStatNewness.setRunTime(new BigDecimal(modelCommonResult.get("run_time_normal").toString()).intValue()); + deviceStatNewness.setLossTime(new BigDecimal(modelCommonResult.get("run_time_adjust").toString()).intValue()); + deviceStatNewness.setLossRate(new BigDecimal(deviceStatNewness.getLossTime()).divide(new BigDecimal(deviceStatNewness.getRunTime()),2,BigDecimal.ROUND_HALF_UP)); + newnessList.add(deviceStatNewness); + } + } catch (Exception ex) { + ex.printStackTrace(); + logger.error("设备健康评价计算异常,devNo=" + dto.getDevNo()); + } + } + + public void saveReport(DeviceHealthEvaluateDTO evaluateDTO, Date runTime, Map<String, Object> modelCommonResult, + Map<String, List<DataEntity>> dataMap, Map<String, DeviceEvaluateIndexDTO> indexMap) { + + DeviceInfoDTO deviceInfo = deviceInfoService.getByDevNo(evaluateDTO.getDevNo()); + + DeviceHealthReportDTO reportDTO = new DeviceHealthReportDTO(); + reportDTO.setId(UUID.randomUUID().toString()); + reportDTO.setReportNo("H" + DateUtils.format(runTime, "yyyyMMddHHmmss") + getRand(evaluateDTO.getDevNo())); + reportDTO.setReportName(evaluateDTO.getDevName() + "健康评价报告"); + reportDTO.setReportDate(runTime); + String deviceHealthLevel = modelCommonResult.get("isqualified").toString(); + reportDTO.setHealthLevel(deviceHealthLevel); + reportDTO.setAbnormalCount(getAbnormalCount(JSONArray.toJSONString(modelCommonResult.get("part_grade")))); + reportDTO.setContent(modelCommonResult.get("health_evaluate").toString()); + reportDTO.setHealthScore(new BigDecimal(modelCommonResult.get("health_score").toString())); + reportDTO.setDataLength(DEFAULT_DATA_LENGTH); + reportDTO.setRunTime(new BigDecimal(modelCommonResult.get("run_time_adjust").toString()).intValue()); + reportDTO.setDevNo(evaluateDTO.getDevNo()); + reportDTO.setDevName(evaluateDTO.getDevName()); + if (deviceInfo != null) { + reportDTO.setClassNo(deviceInfo.getClassNo()); + reportDTO.setClassName(deviceInfo.getClassName()); + reportDTO.setWorkshop(deviceInfo.getWorkshop()); + reportDTO.setModel(deviceInfo.getModel()); + } + List<Integer> partGrade = getIntValueArr(modelCommonResult.get("part_grade")); + List<BigDecimal> maxArr = getValueArr(modelCommonResult.get("max_arr")); + List<BigDecimal> minArr = getValueArr(modelCommonResult.get("min_arr")); + List<BigDecimal> meanArr = getValueArr(modelCommonResult.get("mean_arr")); + List<DeviceHealthReportDataDTO> detList = new ArrayList<>(); + List<DeviceHealthAlarmDetailDTO> deviceHealthAlarmDetailDTOList = new ArrayList<>(); + List<String> alarmIndexTypes = new ArrayList<>(); + List<String> alarmSolutions = new ArrayList<>(); + // 故障id + String alarmId = UUID.randomUUID().toString(); + for (int i = 0; i < indexArr.length; i++) { + List<DataEntity> dataList = dataMap.get(indexArr[i]); + if (CollectionUtils.isEmpty(dataList)) { + continue; + } + List<Object[]> dataCont = dataList.stream().map(t -> { + return new Object[]{DateUtils.format(t.getTimeStamp(), DateUtils.DATE_TIME_PATTERN_MIN), new BigDecimal(t.getDataValue()).setScale(4, BigDecimal.ROUND_HALF_UP)}; + }).collect(Collectors.toList()); + DeviceHealthReportDataDTO det = new DeviceHealthReportDataDTO(); + det.setSort(i); + det.setDataName(indexMap.get(indexArr[i]).getParamName()); + det.setDataValue(JSONArray.toJSONString(dataCont)); + if (!HealthIndexTypeEnum.runTime.getCode().equals(indexArr[i])) { + det.setDataMax(maxArr.get(i)); + det.setDataMin(minArr.get(i)); + det.setDataAvg(meanArr.get(i)); + det.setGradeCode(partGrade.get(i).toString()); + det.setGradeName(HEALTH_FAULT_TYPE.get(partGrade.get(i))); + + DeviceFaultDTO querySoluDto = new DeviceFaultDTO(); + querySoluDto.setClassNo(deviceInfo.getClassNo()); + querySoluDto.setIndexType(indexArr[i]); + querySoluDto.setFaultType(det.getGradeCode()); + DeviceFaultDTO faultDTO = deviceFaultService.getSolution(querySoluDto); + if (faultDTO != null) { + det.setSolution(faultDTO.getSolution()); + det.setFaultCode(faultDTO.getFaultCode()); + } + + // 设备健康故障详情记录 + if (HealthLevelEnum.Level3.getCode().equals(deviceHealthLevel) && faultDTO != null){ + DeviceHealthAlarmDetailDTO deviceHealthAlarmDetail = new DeviceHealthAlarmDetailDTO(); + deviceHealthAlarmDetail.setId(UUID.randomUUID().toString()); + deviceHealthAlarmDetail.setAlarmId(alarmId); + deviceHealthAlarmDetail.setFaultCode(faultDTO.getFaultCode()); + deviceHealthAlarmDetail.setFaultName(HEALTH_FAULT_TYPE.get(partGrade.get(i))); + deviceHealthAlarmDetail.setSolution(faultDTO.getSolution()); + + alarmIndexTypes.add(ALARM_INDEX_TYPE.get(faultDTO.getIndexType())); + alarmSolutions.add(faultDTO.getSolution()); + deviceHealthAlarmDetailDTOList.add(deviceHealthAlarmDetail); + } + } else { + StringBuilder rsb = new StringBuilder(); + rsb.append("运行时长:"); + rsb.append(modelCommonResult.get("run_time_normal").toString()); + det.setRemark(rsb.toString()); + } + detList.add(det); + } + + // 设备健康故障记录 + if (deviceHealthAlarmDetailDTOList.size() > 0) { + DeviceHealthAlarmDTO deviceHealthAlarm = new DeviceHealthAlarmDTO(); + deviceHealthAlarm.setId(alarmId); + deviceHealthAlarm.setReportId(reportDTO.getId()); + deviceHealthAlarm.setDevNo(evaluateDTO.getDevNo()); + deviceHealthAlarm.setDevName(evaluateDTO.getDevName()); + deviceHealthAlarm.setFaultTime(runTime); + deviceHealthAlarm.setIsPushed(0); + deviceHealthAlarm.setPushType(evaluateDTO.getIsPushed() == 0 ? 2 : 1); + deviceHealthAlarm.setCreateDate(new Date()); + deviceHealthAlarm.setAlarmIndexTypes(String.join(",", alarmIndexTypes)); + deviceHealthAlarm.setAlarmSolutions(String.join("\n", alarmSolutions)); + + reportDTO.setDeviceHealthAlarm(deviceHealthAlarm); + reportDTO.setDeviceHealthAlarmDetails(deviceHealthAlarmDetailDTOList); + } + reportDTO.setDetList(detList); + + deviceHealthReportService.save(reportDTO); + + DeviceHealthEvaluateDTO updateDto = new DeviceHealthEvaluateDTO(); + updateDto.setId(evaluateDTO.getId()); + updateDto.setReportContent(reportDTO.getContent()); + updateDto.setReportDate(runTime); + updateDto.setReportId(reportDTO.getId()); + updateDto.setAbnormalCount(reportDTO.getAbnormalCount()); + updateDto.setHealthScore(reportDTO.getHealthScore()); + updateDto.setHealthLevel(reportDTO.getHealthLevel()); + deviceHealthEvaluateService.updateReport(updateDto); + } + public void deviceStatCount(Calendar calendar) { + DeviceStatCountDTO deviceStatCountDTO = deviceStatCountService.getDeviceStatCount(); + DeviceStatCountEntity deviceStatCount = ConvertUtils.sourceToTarget(deviceStatCountDTO, DeviceStatCountEntity.class); + deviceStatCount.setId(UUID.randomUUID().toString()); + deviceStatCount.setDate(calendar.getTime()); + deviceStatCount.setCreateDate(new Date()); + deviceStatCountService.insert(deviceStatCount); + } + + private String getRand(String devNo) { + String t = Long.toString(System.currentTimeMillis()); + return devNo.substring(0, 1) + t.substring(t.length() - 4); + } + + private int getAbnormalCount(String partGrade) { + int result = 0; + if (StringUtils.isBlank(partGrade)) { + return result; + } + List<Integer> pgList = JSONArray.parseArray(partGrade, Integer.class); + if (CollectionUtils.isEmpty(pgList)) { + return result; + } + for (int i = 0; i < pgList.size(); i++) { + if (pgList.get(i) != 1) { + result = result + 1; + } + } + return result; + } + + private List<BigDecimal> getValueArr(Object value) { + List<BigDecimal> result = new ArrayList<>(); + if (value == null) { + return result; + } + result = JSONArray.parseArray(JSON.toJSONString(value), BigDecimal.class); + return result; + + } + + private List<Integer> getIntValueArr(Object value) { + List<Integer> result = new ArrayList<>(); + if (value == null) { + return result; + } + result = JSONArray.parseArray(JSON.toJSONString(value), Integer.class); + return result; + + } +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/FakeDataTask.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/FakeDataTask.java new file mode 100644 index 0000000..3e66030 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/FakeDataTask.java @@ -0,0 +1,103 @@ +package com.iailab.module.job.task; + +import com.alibaba.fastjson.JSON; +import com.iailab.common.utils.DateUtils; +import com.iailab.module.mcs.dto.StModelDTO; +import com.iailab.module.mcs.service.StModelService; +import com.iailab.module.mcs.service.StModelResultService; +import com.iailab.module.model.handler.ModelHandler; +import javax.annotation.Resource; +import org.springframework.stereotype.Component; + +import java.util.*; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年07月08日 + */ +@Component("fakeDataTask") +public class FakeDataTask implements ITask { + + @Resource + private StModelService stModelService; + + @Resource + private ModelHandler modelHandler; + + @Resource + private StModelResultService stModelCommonResultService; + + // private final String MODEL_CODE = "shallow_groove_separation_control307"; + + // private final String MODEL_CODE = "shallow_groove_separation_control308"; + + // private final String MODEL_CODE = "separation_control3318"; + + // private final String MODEL_CODE = "separation_control3319"; + + // private final String MODEL_CODE = "thickener_control_qc"; + + // private final String MODEL_CODE = "thickener_control_xl"; + + // private final String MODEL_CODE = "filter"; + + private final String MODEL_CODE = "warehouse_allocation"; + + private Date startDate = DateUtils.stringToDate("2024-05-15 12:00:00", DateUtils.DATE_TIME_PATTERN); + + private Date endDate = DateUtils.stringToDate("2024-07-01 12:00:00", DateUtils.DATE_TIME_PATTERN); + + private int sc = 60; + + private List<Integer> inHours = new ArrayList<>(); + + FakeDataTask() { + inHours.add(18); + } + + @Override + public void run(String params) { + Calendar calendar = Calendar.getInstance(); + calendar.setTime(startDate); + do { + calendar.add(Calendar.SECOND, sc); + int hour = calendar.get(Calendar.HOUR_OF_DAY); + System.out.println("hour=" + hour); + System.out.println(DateUtils.format(calendar.getTime(), DateUtils.DATE_TIME_PATTERN)); + if (!inHours.contains(hour) || calendar.get(Calendar.MINUTE) > 10) { + continue; + } + StModelDTO stModel = stModelService.getByCode(MODEL_CODE); + + // 307 + // String jsonString = "{\"mv_fl_kd_307\":14,\"mv_hj_water_valve_main_307\":0,\"mv_xj_water_valve_307\":51,\"mv_hj_water_valve_small_307\":0,\"mv_mn_water_valve_307\":0,\"status\":200,\"tips\":\"OK\"}"; + + // 308 + // String jsonString = "{\"mv_fl_kd_308\":14,\"mv_hj_water_valve_main_308\":0,\"mv_xj_water_valve_308\":51,\"mv_hj_water_valve_small_308\":0,\"mv_mn_water_valve_308\":0,\"status\":200,\"tips\":\"OK\"}"; + + // 3318 + //String jsonString = "{\"mv_pump_hl_3318\":9,\"mv_valve_fl_3318\":0,\"mv_pump_hj_3318\":11,\"mv_pump_xj_3318\":12,\"mv_value_hj_water_3318\":0,\"mv_value_xj_water_3318\":10,\"mv_valve_jj_3318\":0,\"mv_pump_mn_3318\":0,\"mv_valve_mn_water_3318\":30,\"target_md_3318\":15,\"status\":200,\"tips\":\"OK\"}"; + + // 3319 + // String jsonString = "{\"mv_pump_hl_3319\":9,\"mv_valve_fl_3319\":0,\"mv_pump_hj_3319\":11,\"mv_pump_xj_3319\":12,\"mv_value_hj_water_3319\":0,\"mv_value_xj_water_3319\":10,\"mv_valve_jj_3319\":0,\"mv_pump_mn_3319\":0,\"mv_valve_mn_water_3319\":30,\"target_md_3319\":15,\"status\":200,\"tips\":\"OK\"}"; + + // 浅槽浓缩 + // String jsonString = "{\"Dos_yang_det_QC\":35.5,\"Dos_yin_det_QC\":28.0,\"status\":200}"; + + // 旋流浓缩 + // String jsonString = "{\"Dos_yang_det1_XL\":38.0,\"Dos_yang_det2_XL\":0,\"Dos_yin_det1_XL\":31.0,\"Dos_yin_det2_XL\":0,\"status\":200}"; + + // 智能压滤 + // String jsonString = "{\"zt4429_res\":0,\"UF_pumb2\":0.0,\"zt4430_res\":-1,\"zt4422_res\":-1,\"zt4428_res\":1,\"zt4431_res\":1,\"zt4432_res\":-1,\"zt4419_res\":1,\"UF_pumb1\":1.0,\"zt4420_res\":-1,\"zt4418_res\":-1,\"zt4421_res\":-1,\"status\":200}"; + + // 智能配仓 + String jsonString = "{\"status\":200,\"tips\":\"OK\",\"unloader_state1\":0,\"unloader_state2\":0,\"unloader_state3\":0,\"unloader_state4\":0,\"unloader_state5\":0,\"unloader_state6\":0,\"unloader_state7\":0,\"unloader_state8\":0,\"unloader_state9\":0,\"unloader_state10\":1,\"bunker_ash\":7.74,\"bunker_water\":6.78,\"bunker_heat_val\":4617,\"bunker_number\":[4,12]}"; + + Map<String, Object> result = JSON.parseObject(jsonString); + stModelCommonResultService.addML(stModel.getId(), result, calendar.getTime()); + modelHandler.addLog(stModel.getId(), MODEL_CODE, calendar.getTime(), modelHandler.dealResult(result)); + } while (calendar.getTime().getTime() <= endDate.getTime()); + + } +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/ITask.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/ITask.java new file mode 100644 index 0000000..345badb --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/ITask.java @@ -0,0 +1,25 @@ +/** + * Copyright (c) 2018 人人开源 All rights reserved. + * + * https://www.renren.io + * + * 版权所有,侵权必究! + */ + +package com.iailab.module.job.task; + +/** + * 定时任务接口,所有定时任务都要实现该接口 + * + * @author Mark sunlightcs@gmail.com + * @since 1.0.0 + */ +public interface ITask { + + /** + * 执行定时任务接口 + * + * @param params 参数,多参数使用JSON数据 + */ + void run(String params); +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/MigrationTableDataTask.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/MigrationTableDataTask.java new file mode 100644 index 0000000..4b6eb4d --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/MigrationTableDataTask.java @@ -0,0 +1,67 @@ +package com.iailab.module.job.task; + +import com.iailab.common.utils.DateUtils; +import com.iailab.module.any.service.AnyProcReportDetService; +import com.iailab.module.any.service.AnyProcReportService; +import com.iailab.module.device.service.DeviceHealthReportDataService; +import com.iailab.module.device.service.DeviceHealthReportService; +import com.iailab.module.mcs.service.StModelResultService; +import com.iailab.module.mcs.service.StModelRunlogService; +import org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import javax.annotation.Resource; +import org.springframework.stereotype.Component; + +import java.util.Date; +import java.util.Map; + +/** + * 迁移表数据 + * + */ +@Component("migrationTableDataTask") +public class MigrationTableDataTask implements ITask { + private Logger logger = LoggerFactory.getLogger(getClass()); + + + @Resource + private DeviceHealthReportDataService deviceHealthReportDataService; + + @Resource + private DeviceHealthReportService deviceHealthReportService; + + @Resource + private StModelResultService stModelCommonResultService; + + @Resource + private StModelRunlogService stModelRunlogService; + + @Resource + private AnyProcReportDetService anyProcReportDetService; + + @Resource + private AnyProcReportService anyProcReportService; + + @Override + public void run(String params) { + logger.info("migrationTableDataTask定时任务正在执行,参数为:{}",params ); + try { + int days = -90; + if (StringUtils.isNotBlank(params)) { + days = Math.abs(Integer.parseInt(params)) * -1; + } + Map<String, Date> tMap = DateUtils.getIntervalDate(days); + deviceHealthReportDataService.migrationDeviceHealthReportData(tMap); + deviceHealthReportService.migrationDeviceHealthReport(tMap); + stModelCommonResultService.migrationModelResult(tMap); + stModelRunlogService.migrationModelRunlog(tMap); + anyProcReportService.migrationProcReport(tMap); + anyProcReportDetService.migrationProcReportDet(tMap); + } catch (Exception ex) { + logger.error("migrationTableDataTask运行异常"); + ex.printStackTrace(); + } + logger.info("migrationTableDataTask运行完成"); + } +} diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/ModelAllEvaluationTask.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/ModelAllEvaluationTask.java new file mode 100644 index 0000000..5875d42 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/ModelAllEvaluationTask.java @@ -0,0 +1,48 @@ +package com.iailab.module.job.task; + +import com.iailab.module.mcs.dto.StModelDTO; +import com.iailab.module.mcs.service.StModelService; +import com.iailab.module.model.handler.ModelHandler; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import javax.annotation.Resource; +import org.springframework.stereotype.Component; + +import java.util.Calendar; + +/** + * 生产综合评价 + * 每天08:00运行 + * 0 0 8 * * ? + * + * @author PanZhibao + * @Description + * @createTime 2024年06月04日 + */ +@Component("modelAllEvaluationTask") +public class ModelAllEvaluationTask implements ITask { + private Logger logger = LoggerFactory.getLogger(getClass()); + + private final String MODEL_CODE = "all_evaluation"; + + @Resource + private StModelService stModelService; + + @Resource + private ModelHandler modelHandler; + + @Override + public void run(String params) { + Calendar calendar = Calendar.getInstance(); + calendar.set(Calendar.MILLISECOND, 0); + calendar.set(Calendar.SECOND, 0); + try { + StModelDTO stModel = stModelService.getByCode(MODEL_CODE); + logger.info("运行模型:" + MODEL_CODE); + modelHandler.run(stModel.getModelCode(), calendar.getTime()); + } catch (Exception ex) { + logger.info("运行模型异常"); + ex.printStackTrace(); + } + } +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/ModelBlowerTask.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/ModelBlowerTask.java new file mode 100644 index 0000000..7353d00 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/ModelBlowerTask.java @@ -0,0 +1,202 @@ +package com.iailab.module.job.task; + +import com.alibaba.fastjson.JSONObject; +import com.iailab.common.constant.BusinessConstant; +import com.iailab.module.data.api.IFeignDataApi; +import com.iailab.module.data.dto.FeignWritePointValueDTO; +import com.iailab.module.infra.api.config.ConfigApi; +import com.iailab.module.mcs.dto.StModelDTO; +import com.iailab.module.mcs.dto.StModelOutDTO; +import com.iailab.module.mcs.service.StModelOutService; +import com.iailab.module.mcs.service.StModelService; +import com.iailab.module.model.handler.ModelHandler; +import com.iailab.module.watch.WatchConstant; +import com.iailab.module.watch.WatchDog; +import org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import javax.annotation.Resource; +import org.springframework.stereotype.Component; +import org.springframework.util.CollectionUtils; + +import java.math.BigDecimal; +import java.util.*; + +/** + * 智能压风 + * ZX1,ZX2 + * blower_control + * 5 0/1 * * * ? + */ +@Component("modelBlowerTask") +public class ModelBlowerTask implements ITask { + private Logger logger = LoggerFactory.getLogger(getClass()); + + private final String MODEL_CODE = "blower_control"; + + private final String mParamCode = "isDev"; + + private final List<String> MODEL_CODE_LIST = new ArrayList<>(); + + + private final String ALM_POINT = WatchConstant.CONTROLLER_ALM_6; + + private final String unWrite = "-1"; + + @Resource + private StModelService stModelService; + + @Resource + private ModelHandler modelHandler; + + @Resource + private IFeignDataApi feignDataApi; + + @Resource + private ConfigApi configApi; + + @Resource + private StModelOutService stModelOutService; + + @Resource + private WatchDog watchDog; + + ModelBlowerTask() { + MODEL_CODE_LIST.add(MODEL_CODE); + } + + @Override + public void run(String params) { + String isDev = configApi.queryConfigByCode(mParamCode); + Calendar calendar = Calendar.getInstance(); + calendar.set(Calendar.MILLISECOND, 0); + calendar.set(Calendar.SECOND, 0); + logger.info("ModelBlowerTask定时任务正在执行,参数为:{}", params); + if (BusinessConstant.DEV_Y.equals(isDev)) { + logger.info("模型采用开发模型"); + } else { + logger.info("模型采用生产模型"); + } + try { + if (!BusinessConstant.DEV_Y.equals(isDev)) { + // 1、判断通讯是否正常 + if (!watchDog.isConnect(WatchConstant.ZX1_STATUS)) { + logger.info("watchDog.isConnect=false"); + return; + } + if (!watchDog.isConnect(WatchConstant.ZX2_STATUS)) { + logger.info("watchDog.isConnect=false"); + return; + } + + // 2、判断控制器状态 + if (!watchDog.isUse(WatchConstant.CONTROLLER_ONSTS_6)) { + logger.info("将反馈值写入下发值,无扰动切换"); + MODEL_CODE_LIST.forEach(item -> { + this.writeBySetValue(item); + }); + return; + } + logger.info("控制器启动"); + } + + // 3、运行模型 + Map<String, Map<String, Object>> allCommonResult = new HashMap<>(); + for (int i = 0; i < MODEL_CODE_LIST.size(); i++) { + StModelDTO stModel = stModelService.getByCode(MODEL_CODE_LIST.get(i)); + if (stModel == null) { + logger.info("model为空!"); + return; + } + logger.info("运行模型:" + stModel.getModelCode()); + Map<String, Object> modelCommonResult = modelHandler.run(stModel.getModelCode(), calendar.getTime()); + allCommonResult.put(MODEL_CODE_LIST.get(i), modelCommonResult); + } + + // 4、下发数据 + if (!BusinessConstant.DEV_Y.equals(isDev)) { + for (int i = 0; i < MODEL_CODE_LIST.size(); i++) { + if (!writeToDcs(allCommonResult.get(MODEL_CODE_LIST.get(i)), MODEL_CODE_LIST.get(i))) { + throw new Exception(MODEL_CODE_LIST.get(i) + "下发数据异常"); + } + } + } + } catch (Exception ex) { + logger.error("ModelBlowerTask运行异常"); + ex.printStackTrace(); + } + logger.info("ModelBlowerTask运行完成"); + } + + /** + * 数据下发 + * + * @param data + * @param modelCode + */ + private boolean writeToDcs(Map<String, Object> data, String modelCode) { + String code = data.get(BusinessConstant.MODELE_RESULT_STATUS).toString(); + if (BusinessConstant.MODEL_R_ERROR.equals(code.substring(0,1))) { + logger.warn("code=" + code + ",结果异常,不下发数据!恢复手动"); + watchDog.stopControllerSts(WatchConstant.CONTROLLER_ONSTS_6); + return false; + } else if (BusinessConstant.MODEL_R_WARN.equals(code.substring(0,1))) { + logger.warn("code=" + code + ",结果警告"); + FeignWritePointValueDTO writeAlm = new FeignWritePointValueDTO(); + writeAlm.setPointCode(ALM_POINT); + writeAlm.setPointValue(BusinessConstant.STATUS_FALSE); + feignDataApi.setPointValue(writeAlm); + } + + logger.info("下发的数据=" + JSONObject.toJSONString(data)); + List<StModelOutDTO> outPoints = stModelOutService.getOutPoint(modelCode); + if (CollectionUtils.isEmpty(outPoints)) { + logger.info("outPoints 为空!"); + return true; + } + outPoints.forEach(pointItem -> { + FeignWritePointValueDTO writePointValue = new FeignWritePointValueDTO(); + if (!unWrite.equals(data.get(pointItem.getResultKey()).toString())) { + writePointValue.setPointCode(pointItem.getPointNo()); + writePointValue.setPointValue(new BigDecimal(data.get(pointItem.getResultKey()).toString())); + feignDataApi.setPointValue(writePointValue); + } + }); + return true; + } + + /** + * 无扰模式 + * 反馈写入下发点位 + */ + private void writeBySetValue(String modelCode) { + logger.info("=====writeBySetValue Start======="); + // 低压输出KEY要特殊处理 + String dy_key = "_control"; + List<StModelOutDTO> outPoints = stModelOutService.getOutPoint(modelCode); + if (CollectionUtils.isEmpty(outPoints)) { + return; + } + outPoints.forEach(item -> { + if (StringUtils.isNotBlank(item.getPointNo()) && StringUtils.isNotBlank(item.getDisturbancePointNo())) { + List<String> points = new ArrayList<>(); + points.add(item.getDisturbancePointNo()); + Map<String, Object> value = feignDataApi.getCurrentValue(points); + FeignWritePointValueDTO writePointValue = new FeignWritePointValueDTO(); + writePointValue.setPointCode(item.getPointNo()); + writePointValue.setPointValue(value.get(item.getDisturbancePointNo())); + if(item.getResultKey().contains(dy_key)) { + Object tempValue = value.get(item.getDisturbancePointNo()); + // 7或8:启动;10:停止 + if (tempValue.toString().equals("7") || tempValue.toString().equals("8")) { + writePointValue.setPointValue(new Integer(1)); + } else if (tempValue.toString().equals("10")) { + writePointValue.setPointValue(new Integer(0)); + } + } + feignDataApi.setPointValue(writePointValue); + } + }); + logger.info("=====智能压风无扰完成======="); + } +} diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/ModelControlReliabilityTask.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/ModelControlReliabilityTask.java new file mode 100644 index 0000000..1f43cac --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/ModelControlReliabilityTask.java @@ -0,0 +1,70 @@ +package com.iailab.module.job.task; + +import com.iailab.module.mcs.dto.StModelDTO; +import com.iailab.module.mcs.service.StModelService; +import com.iailab.module.model.handler.ModelHandler; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import javax.annotation.Resource; +import org.springframework.stereotype.Component; + +import java.util.ArrayList; +import java.util.Calendar; +import java.util.List; + +/** + * 控制系统可靠性评价 + * + * @author PanZhibao + * @Description + * @createTime 2024年06月15日 + */ +@Component("modelControlReliabilityTask") +public class ModelControlReliabilityTask implements ITask { + private Logger logger = LoggerFactory.getLogger(getClass()); + + @Resource + private StModelService stModelService; + + @Resource + private ModelHandler modelHandler; + + private final List<String> MODEL_CODE_LIST = new ArrayList<>(); + + ModelControlReliabilityTask() { + MODEL_CODE_LIST.add("control_reliability_mm"); + MODEL_CODE_LIST.add("control_reliability_km"); + MODEL_CODE_LIST.add("control_reliability_blow1"); + MODEL_CODE_LIST.add("control_reliability_blow2"); + + MODEL_CODE_LIST.add("control_reliability_dl401"); + MODEL_CODE_LIST.add("control_reliability_dl402"); + MODEL_CODE_LIST.add("control_reliability_dl501"); + MODEL_CODE_LIST.add("control_reliability_hm"); + } + + @Override + public void run(String params) { + Calendar calendar = Calendar.getInstance(); + calendar.set(Calendar.MILLISECOND, 0); + calendar.set(Calendar.SECOND, 0); + logger.info("ModelControlReliabilityTask定时任务正在执行,参数为:{}", params); + + try { + for (int i = 0; i < MODEL_CODE_LIST.size(); i++) { + StModelDTO stModel = stModelService.getByCode(MODEL_CODE_LIST.get(i)); + if (stModel == null) { + logger.info("model为空!"); + return; + } + logger.info("运行模型:" + stModel.getModelCode()); + modelHandler.run(stModel.getModelCode(), calendar.getTime()); + } + + } catch (Exception ex) { + logger.error("ModelControlReliabilityTask运行异常"); + ex.printStackTrace(); + } + logger.info("ModelControlReliabilityTask运行完成"); + } +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/ModelQCThickenerTask.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/ModelQCThickenerTask.java new file mode 100644 index 0000000..a8ff4d2 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/ModelQCThickenerTask.java @@ -0,0 +1,181 @@ +package com.iailab.module.job.task; + +import com.alibaba.fastjson.JSONObject; +import com.iailab.common.constant.BusinessConstant; +import com.iailab.module.data.dto.FeignWritePointValueDTO; +import com.iailab.module.data.api.IFeignDataApi; +import com.iailab.module.infra.api.config.ConfigApi; +import com.iailab.module.mcs.dto.StModelDTO; +import com.iailab.module.mcs.dto.StModelOutDTO; +import com.iailab.module.mcs.service.StModelOutService; +import com.iailab.module.mcs.service.StModelService; +import com.iailab.module.model.handler.ModelHandler; +import com.iailab.module.watch.WatchConstant; +import com.iailab.module.watch.WatchDog; +import org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import javax.annotation.Resource; +import org.springframework.stereotype.Component; +import org.springframework.util.CollectionUtils; + +import java.math.BigDecimal; +import java.util.*; + +/** + * 浅槽浓缩 + * ZX1 + * thickener_control_qc + * 5 0/1 * * * ? + */ +@Component("modelQCThickenerTask") +public class ModelQCThickenerTask implements ITask { + private Logger logger = LoggerFactory.getLogger(getClass()); + + private final String MODEL_CODE = "thickener_control_qc"; + + private final String mParamCode = "isDev"; + + private final List<String> MODEL_CODE_LIST = new ArrayList<>(); + + private final String ALM_POINT = WatchConstant.CONTROLLER_ALM_5; + + @Resource + private StModelService stModelService; + + @Resource + private ModelHandler modelHandler; + + @Resource + private IFeignDataApi feignDataApi; + + @Resource + private ConfigApi configApi; + + @Resource + private StModelOutService stModelOutService; + + @Resource + private WatchDog watchDog; + + ModelQCThickenerTask() { + MODEL_CODE_LIST.add(MODEL_CODE); + } + + @Override + public void run(String params) { + String isDev = configApi.queryConfigByCode(mParamCode); + Calendar calendar = Calendar.getInstance(); + calendar.set(Calendar.MILLISECOND, 0); + calendar.set(Calendar.SECOND, 0); + logger.info("ModelXLFilterTask定时任务正在执行,参数为:{}", params); + if (BusinessConstant.DEV_Y.equals(isDev)) { + logger.info("模型采用开发模型"); + } else { + logger.info("模型采用生产模型"); + } + try { + if (!BusinessConstant.DEV_Y.equals(isDev)) { + // 1、判断通讯是否正常 + if (!watchDog.isConnect(WatchConstant.ZX1_STATUS)) { + logger.info("watchDog.isConnect=false"); + return; + } + + // 2、判断控制器状态 + if (!watchDog.isUse(WatchConstant.CONTROLLER_ONSTS_5)) { + logger.info("将反馈值写入下发值,无扰动切换"); + MODEL_CODE_LIST.forEach(item -> { + this.writeBySetValue(item); + }); + return; + } + logger.info("控制器启动"); + } + + // 3、运行模型 + Map<String, Map<String, Object>> allCommonResult = new HashMap<>(); + for (int i = 0; i < MODEL_CODE_LIST.size(); i++) { + StModelDTO stModel = stModelService.getByCode(MODEL_CODE_LIST.get(i)); + if (stModel == null) { + logger.info("model为空!"); + return; + } + logger.info("运行模型:" + stModel.getModelCode()); + Map<String, Object> modelCommonResult = modelHandler.run(stModel.getModelCode(), calendar.getTime()); + allCommonResult.put(MODEL_CODE_LIST.get(i), modelCommonResult); + } + + // 4、下发数据 + if (!BusinessConstant.DEV_Y.equals(isDev)) { + for (int i = 0; i < MODEL_CODE_LIST.size(); i++) { + if (!writeToDcs(allCommonResult.get(MODEL_CODE_LIST.get(i)), MODEL_CODE_LIST.get(i))) { + throw new Exception(MODEL_CODE_LIST.get(i) + "下发数据异常"); + } + } + } + } catch (Exception ex) { + logger.error("ModelXLFilterTask运行异常"); + ex.printStackTrace(); + } + logger.info("ModelXLFilterTask运行完成"); + } + + /** + * 数据下发 + * + * @param data + * @param modelCode + */ + private boolean writeToDcs(Map<String, Object> data, String modelCode) { + String code = data.get(BusinessConstant.MODELE_RESULT_STATUS).toString(); + if (BusinessConstant.MODEL_R_ERROR.equals(code.substring(0,1))) { + logger.warn("code=" + code + ",结果异常,不下发数据!恢复手动"); + watchDog.stopControllerSts(WatchConstant.CONTROLLER_ONSTS_5); + return false; + } else if (BusinessConstant.MODEL_R_WARN.equals(code.substring(0,1))) { + logger.warn("code=" + code + ",结果警告"); + FeignWritePointValueDTO writeAlm = new FeignWritePointValueDTO(); + writeAlm.setPointCode(ALM_POINT); + writeAlm.setPointValue(BusinessConstant.STATUS_FALSE); + feignDataApi.setPointValue(writeAlm); + } + + logger.info("下发的数据=" + JSONObject.toJSONString(data)); + List<StModelOutDTO> outPoints = stModelOutService.getOutPoint(modelCode); + if (CollectionUtils.isEmpty(outPoints)) { + logger.info("outPoints 为空!"); + return true; + } + outPoints.forEach(pointItem -> { + FeignWritePointValueDTO writePointValue = new FeignWritePointValueDTO(); + writePointValue.setPointCode(pointItem.getPointNo()); + writePointValue.setPointValue(new BigDecimal(data.get(pointItem.getResultKey()).toString())); + feignDataApi.setPointValue(writePointValue); + }); + return true; + } + + /** + * 无扰模式 + * 反馈写入下发点位 + */ + private void writeBySetValue(String modelCode) { + logger.info("=====writeBySetValue Start======="); + List<StModelOutDTO> outPoints = stModelOutService.getOutPoint(modelCode); + if (CollectionUtils.isEmpty(outPoints)) { + return; + } + outPoints.forEach(item -> { + if (StringUtils.isNotBlank(item.getPointNo()) && StringUtils.isNotBlank(item.getDisturbancePointNo())) { + List<String> points = new ArrayList<>(); + points.add(item.getDisturbancePointNo()); + Map<String, Object> value = feignDataApi.getCurrentValue(points); + FeignWritePointValueDTO writePointValue = new FeignWritePointValueDTO(); + writePointValue.setPointCode(item.getPointNo()); + writePointValue.setPointValue(value.get(item.getDisturbancePointNo())); + feignDataApi.setPointValue(writePointValue); + } + }); + } +} diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/ModelSeparationTask.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/ModelSeparationTask.java new file mode 100644 index 0000000..6e61856 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/ModelSeparationTask.java @@ -0,0 +1,209 @@ +package com.iailab.module.job.task; + +import com.alibaba.fastjson.JSONObject; +import com.iailab.common.constant.BusinessConstant; +import com.iailab.module.data.api.IFeignDataApi; +import com.iailab.module.data.dto.FeignWritePointValueDTO; +import com.iailab.module.infra.api.config.ConfigApi; +import com.iailab.module.mcs.dto.StModelDTO; +import com.iailab.module.mcs.dto.StModelOutDTO; +import com.iailab.module.mcs.service.StModelOutService; +import com.iailab.module.mcs.service.StModelService; +import com.iailab.module.model.handler.ModelHandler; +import com.iailab.module.watch.WatchConstant; +import com.iailab.module.watch.WatchDog; +import org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import javax.annotation.Resource; +import org.springframework.stereotype.Component; +import org.springframework.util.CollectionUtils; + +import java.math.BigDecimal; +import java.util.*; +import java.util.concurrent.Executors; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.TimeUnit; + +/** + * 旋流器分选控制 + * ZX2 + * 5 0/1 * * * ? + */ +@Component("modelSeparationTask") +public class ModelSeparationTask implements ITask { + private Logger logger = LoggerFactory.getLogger(getClass()); + + private final String MODEL_CODE_3318 = "separation_control3318"; + + private final String MODEL_CODE_3319 = "separation_control3319"; + + private final String mParamCode = "isDev"; + + private final List<String> MODEL_CODE_LIST = new ArrayList<>(); + + private final String ALM_POINT = WatchConstant.CONTROLLER_ALM_2; + + @Resource + private StModelService stModelService; + + @Resource + private ModelHandler modelHandler; + + @Resource + private IFeignDataApi feignDataApi; + + @Resource + private ConfigApi configApi; + + @Resource + private StModelOutService stModelOutService; + + @Resource + private WatchDog watchDog; + + private final String MV_VALVE_JJ = "mv_valve_jj"; + + private int writeDelayTime = 20; + + private ScheduledExecutorService executor = Executors.newScheduledThreadPool(1); + + ModelSeparationTask() { + MODEL_CODE_LIST.add(MODEL_CODE_3318); + MODEL_CODE_LIST.add(MODEL_CODE_3319); + } + + @Override + public void run(String params) { + String isDev = configApi.queryConfigByCode(mParamCode); + Calendar calendar = Calendar.getInstance(); + calendar.set(Calendar.MILLISECOND, 0); + calendar.add(Calendar.SECOND, -5); // 滞后5s + logger.info("ModelSeparationTask定时任务正在执行,参数为:{}", params); + if (BusinessConstant.DEV_Y.equals(isDev)) { + logger.info("模型采用开发模型"); + } else { + logger.info("模型采用生产模型"); + } + try { + if (!BusinessConstant.DEV_Y.equals(isDev)) { + // 1、判断通讯是否正常 + if (!watchDog.isConnect(WatchConstant.ZX2_STATUS)) { + logger.info("watchDog.isConnect=false"); + return; + } + + // 2、判断控制器状态 + if (!watchDog.isUse(WatchConstant.CONTROLLER_ONSTS_2)) { + logger.info("将反馈值写入下发值,无扰动切换"); + MODEL_CODE_LIST.forEach(item -> { + this.writeBySetValue(item); + }); + return; + } + logger.info("控制器启动"); + } + + // 3、运行模型 + Map<String, Map<String, Object>> allCommonResult = new HashMap<>(); + for (int i = 0; i < MODEL_CODE_LIST.size(); i++) { + StModelDTO stModel = stModelService.getByCode(MODEL_CODE_LIST.get(i)); + if (stModel == null) { + logger.info("model为空!"); + return; + } + logger.info("运行模型:" + stModel.getModelCode()); + Map<String, Object> modelCommonResult = modelHandler.run(stModel.getModelCode(), calendar.getTime()); + allCommonResult.put(MODEL_CODE_LIST.get(i), modelCommonResult); + } + + // 4、下发数据 + if (!BusinessConstant.DEV_Y.equals(isDev)) { + for (int i = 0; i < MODEL_CODE_LIST.size(); i++) { + if (!writeToDcs(allCommonResult.get(MODEL_CODE_LIST.get(i)), MODEL_CODE_LIST.get(i))) { + throw new Exception(MODEL_CODE_LIST.get(i) + "下发数据异常"); + } + } + } + } catch (Exception ex) { + logger.error("ModelSeparationTask运行异常"); + ex.printStackTrace(); + } + logger.info("ModelSeparationTask运行完成"); + } + + /** + * 数据下发 + * + * @param data + * @param modelCode + */ + private boolean writeToDcs(Map<String, Object> data, String modelCode) { + String code = data.get(BusinessConstant.MODELE_RESULT_STATUS).toString(); + + if (BusinessConstant.MODEL_R_ERROR.equals(code.substring(0,1))) { + logger.warn("code=" + code + ",结果异常,不下发数据!恢复手动"); + watchDog.stopControllerSts(WatchConstant.CONTROLLER_ONSTS_2); + return false; + } else if (BusinessConstant.MODEL_R_WARN.equals(code.substring(0,1))) { + logger.warn("code=" + code + ",结果警告"); + FeignWritePointValueDTO writeAlm = new FeignWritePointValueDTO(); + writeAlm.setPointCode(ALM_POINT); + writeAlm.setPointValue(BusinessConstant.STATUS_FALSE); + feignDataApi.setPointValue(writeAlm); + } + + logger.info("下发的数据=" + JSONObject.toJSONString(data)); + List<StModelOutDTO> outPoints = stModelOutService.getOutPoint(modelCode); + if (CollectionUtils.isEmpty(outPoints)) { + logger.info("outPoints 为空!"); + return true; + } + outPoints.forEach(pointItem -> { + FeignWritePointValueDTO writePointValue = new FeignWritePointValueDTO(); + writePointValue.setPointCode(pointItem.getPointNo()); + writePointValue.setPointValue(new BigDecimal(data.get(pointItem.getResultKey()).toString())); + feignDataApi.setPointValue(writePointValue); + + if (pointItem.getResultKey().contains(MV_VALVE_JJ)) { + executor.schedule(() -> { + try { + logger.info("20秒后加介阀开度复位0!"); + FeignWritePointValueDTO fw = new FeignWritePointValueDTO(); + fw.setPointCode(pointItem.getPointNo()); + fw.setPointValue(BigDecimal.ZERO); + feignDataApi.setPointValue(fw); + logger.info("复位完成!"); + } catch (Exception ex) { + logger.info("复位失败!"); + ex.printStackTrace(); + } + }, writeDelayTime, TimeUnit.SECONDS); + } + }); + return true; + } + + /** + * 无扰模式 + * 反馈写入下发点位 + */ + private void writeBySetValue(String modelCode) { + logger.info("=====writeBySetValue Start======="); + List<StModelOutDTO> outPoints = stModelOutService.getOutPoint(modelCode); + if (CollectionUtils.isEmpty(outPoints)) { + return; + } + outPoints.forEach(item -> { + if (StringUtils.isNotBlank(item.getPointNo()) && StringUtils.isNotBlank(item.getDisturbancePointNo())) { + List<String> points = new ArrayList<>(); + points.add(item.getDisturbancePointNo()); + Map<String, Object> value = feignDataApi.getCurrentValue(points); + FeignWritePointValueDTO writePointValue = new FeignWritePointValueDTO(); + writePointValue.setPointCode(item.getPointNo()); + writePointValue.setPointValue(value.get(item.getDisturbancePointNo())); + feignDataApi.setPointValue(writePointValue); + } + }); + } +} diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/ModelShallowTask.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/ModelShallowTask.java new file mode 100644 index 0000000..4d5e1a7 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/ModelShallowTask.java @@ -0,0 +1,183 @@ +package com.iailab.module.job.task; + +import com.alibaba.fastjson.JSONObject; +import com.iailab.common.constant.BusinessConstant; +import com.iailab.module.data.api.IFeignDataApi; +import com.iailab.module.data.dto.FeignWritePointValueDTO; +import com.iailab.module.infra.api.config.ConfigApi; +import com.iailab.module.mcs.dto.StModelDTO; +import com.iailab.module.mcs.dto.StModelOutDTO; +import com.iailab.module.mcs.service.StModelOutService; +import com.iailab.module.mcs.service.StModelService; +import com.iailab.module.model.handler.ModelHandler; +import com.iailab.module.watch.WatchConstant; +import com.iailab.module.watch.WatchDog; +import org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import javax.annotation.Resource; +import org.springframework.stereotype.Component; +import org.springframework.util.CollectionUtils; + +import java.math.BigDecimal; +import java.util.*; + +/** + * 浅槽分选控制 + * ZX1 + * 5 0/1 * * * ? + */ +@Component("modelShallowTask") +public class ModelShallowTask implements ITask { + private Logger logger = LoggerFactory.getLogger(getClass()); + + private final String MODEL_CODE_307 = "shallow_groove_separation_control307"; + + private final String MODEL_CODE_308 = "shallow_groove_separation_control308"; + + private final String mParamCode = "isDev"; + + private final List<String> MODEL_CODE_LIST = new ArrayList<>(); + + // 浅槽分选故障需切换手动 + private final String ALM_POINT = WatchConstant.CONTROLLER_ALM_1; + + @Resource + private StModelService stModelService; + + @Resource + private ModelHandler modelHandler; + + @Resource + private IFeignDataApi feignDataApi; + @Resource + private ConfigApi configApi; + + @Resource + private StModelOutService stModelOutService; + + @Resource + private WatchDog watchDog; + + ModelShallowTask() { + MODEL_CODE_LIST.add(MODEL_CODE_307); + MODEL_CODE_LIST.add(MODEL_CODE_308); + } + + @Override + public void run(String params) { + String isDev = configApi.queryConfigByCode(mParamCode); + Calendar calendar = Calendar.getInstance(); + calendar.set(Calendar.MILLISECOND, 0); + calendar.add(Calendar.SECOND, -5); // 滞后5s + logger.info("ModelShallowTask定时任务正在执行,参数为:{}", params); + if (BusinessConstant.DEV_Y.equals(isDev)) { + logger.info("模型采用开发模型"); + } else { + logger.info("模型采用生产模型"); + } + try { + if (!BusinessConstant.DEV_Y.equals(isDev)) { + // 1、判断通讯是否正常 + if (!watchDog.isConnect(WatchConstant.ZX1_STATUS)) { + logger.info("watchDog.isConnect=false"); + return; + } + + // 2、判断控制器状态 + if (!watchDog.isUse(WatchConstant.CONTROLLER_ONSTS_1)) { + logger.info("将反馈值写入下发值,无扰动切换"); + MODEL_CODE_LIST.forEach(item -> { + this.writeBySetValue(item); + }); + return; + } + logger.info("控制器启动"); + } + + // 3、运行模型 + Map<String, Map<String, Object>> allCommonResult = new HashMap<>(); + for (int i = 0; i < MODEL_CODE_LIST.size(); i++) { + StModelDTO stModel = stModelService.getByCode(MODEL_CODE_LIST.get(i)); + if (stModel == null) { + logger.info("model为空!"); + return; + } + logger.info("运行模型:" + stModel.getModelCode()); + Map<String, Object> modelCommonResult = modelHandler.run(stModel.getModelCode(), calendar.getTime()); + allCommonResult.put(MODEL_CODE_LIST.get(i), modelCommonResult); + } + + // 4、下发数据 + if (!BusinessConstant.DEV_Y.equals(isDev)) { + for (int i = 0; i < MODEL_CODE_LIST.size(); i++) { + if (!writeToDcs(allCommonResult.get(MODEL_CODE_LIST.get(i)), MODEL_CODE_LIST.get(i))) { + throw new Exception(MODEL_CODE_LIST.get(i) + "下发数据异常"); + } + } + } + } catch (Exception ex) { + logger.error("ModelShallowTask运行异常"); + ex.printStackTrace(); + } + logger.info("ModelShallowTask运行完成"); + } + + /** + * 数据下发 + * + * @param data + * @param modelCode + */ + private boolean writeToDcs(Map<String, Object> data, String modelCode) { + String code = data.get(BusinessConstant.MODELE_RESULT_STATUS).toString(); + if (BusinessConstant.MODEL_R_ERROR.equals(code.substring(0,1))) { + logger.warn("code=" + code + ",结果异常,不下发数据!恢复手动"); + watchDog.stopControllerSts(WatchConstant.CONTROLLER_ONSTS_1); + return false; + } else if (BusinessConstant.MODEL_R_WARN.equals(code.substring(0,1))) { + logger.warn("code=" + code + ",结果警告"); + FeignWritePointValueDTO writeAlm = new FeignWritePointValueDTO(); + writeAlm.setPointCode(ALM_POINT); + writeAlm.setPointValue(BusinessConstant.STATUS_FALSE); + feignDataApi.setPointValue(writeAlm); + } + + logger.info("下发的数据=" + JSONObject.toJSONString(data)); + List<StModelOutDTO> outPoints = stModelOutService.getOutPoint(modelCode); + if (CollectionUtils.isEmpty(outPoints)) { + logger.info("outPoints 为空!"); + return true; + } + outPoints.forEach(pointItem -> { + FeignWritePointValueDTO writePointValue = new FeignWritePointValueDTO(); + writePointValue.setPointCode(pointItem.getPointNo()); + writePointValue.setPointValue(new BigDecimal(data.get(pointItem.getResultKey()).toString())); + feignDataApi.setPointValue(writePointValue); + }); + return true; + } + + /** + * 无扰模式 + * 反馈写入下发点位 + */ + private void writeBySetValue(String modelCode) { + logger.info("=====writeBySetValue Start======="); + List<StModelOutDTO> outPoints = stModelOutService.getOutPoint(modelCode); + if (CollectionUtils.isEmpty(outPoints)) { + return; + } + outPoints.forEach(item -> { + if (StringUtils.isNotBlank(item.getPointNo()) && StringUtils.isNotBlank(item.getDisturbancePointNo())) { + List<String> points = new ArrayList<>(); + points.add(item.getDisturbancePointNo()); + Map<String, Object> value = feignDataApi.getCurrentValue(points); + FeignWritePointValueDTO writePointValue = new FeignWritePointValueDTO(); + writePointValue.setPointCode(item.getPointNo()); + writePointValue.setPointValue(value.get(item.getDisturbancePointNo())); + feignDataApi.setPointValue(writePointValue); + } + }); + } +} diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/ModelStorageReliabilityTask.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/ModelStorageReliabilityTask.java new file mode 100644 index 0000000..2cd38ae --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/ModelStorageReliabilityTask.java @@ -0,0 +1,49 @@ +package com.iailab.module.job.task; + +import com.iailab.module.mcs.dto.StModelDTO; +import com.iailab.module.mcs.service.StModelService; +import com.iailab.module.model.handler.ModelHandler; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import javax.annotation.Resource; +import org.springframework.stereotype.Component; + +import java.util.Calendar; + +/** + * 仓储可靠性分析 + * 每天08:00运行 + * 0 0 8 * * ? + * + * @author PanZhibao + * @Description + * @createTime 2024年06月02日 + */ +@Component("modelStorageReliabilityTask") +public class ModelStorageReliabilityTask implements ITask { + + private Logger logger = LoggerFactory.getLogger(getClass()); + + private final String MODEL_CODE = "storage_reliability"; + + @Resource + private StModelService stModelService; + + @Resource + private ModelHandler modelHandler; + + @Override + public void run(String params) { + Calendar calendar = Calendar.getInstance(); + calendar.set(Calendar.MILLISECOND, 0); + calendar.set(Calendar.SECOND, 0); + try { + StModelDTO stModel = stModelService.getByCode(MODEL_CODE); + logger.info("运行模型:" + MODEL_CODE); + modelHandler.run(stModel.getModelCode(), calendar.getTime()); + } catch (Exception ex) { + logger.info("运行模型异常"); + ex.printStackTrace(); + } + } +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/ModelWarehouseTask.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/ModelWarehouseTask.java new file mode 100644 index 0000000..fb53b2a --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/ModelWarehouseTask.java @@ -0,0 +1,181 @@ +package com.iailab.module.job.task; + +import com.alibaba.fastjson.JSONObject; +import com.iailab.common.constant.BusinessConstant; +import com.iailab.module.data.dto.FeignWritePointValueDTO; +import com.iailab.module.data.api.IFeignDataApi; +import com.iailab.module.infra.api.config.ConfigApi; +import com.iailab.module.mcs.dto.StModelDTO; +import com.iailab.module.mcs.dto.StModelOutDTO; +import com.iailab.module.mcs.service.StModelOutService; +import com.iailab.module.mcs.service.StModelService; +import com.iailab.module.model.handler.ModelHandler; +import com.iailab.module.watch.WatchConstant; +import com.iailab.module.watch.WatchDog; +import org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import javax.annotation.Resource; +import org.springframework.stereotype.Component; +import org.springframework.util.CollectionUtils; + +import java.util.*; + +/** + * 智能配仓 + * ZX1 + * warehouse_allocation + * 5 0/1 * * * ? + * + */ +@Component("modelWarehouseTask") +public class ModelWarehouseTask implements ITask { + private Logger logger = LoggerFactory.getLogger(getClass()); + + private final String MODEL_CODE = "warehouse_allocation"; + + private final String mParamCode = "isDev"; + + private final List<String> MODEL_CODE_LIST = new ArrayList<>(); + + private final String ALM_POINT = WatchConstant.CONTROLLER_ALM_7; + + @Resource + private StModelService stModelService; + + @Resource + private ModelHandler modelHandler; + + @Resource + private IFeignDataApi feignDataApi; + + @Resource + private ConfigApi configApi; + + @Resource + private StModelOutService stModelOutService; + + @Resource + private WatchDog watchDog; + + ModelWarehouseTask() { + MODEL_CODE_LIST.add(MODEL_CODE); + } + + @Override + public void run(String params) { + String isDev = configApi.queryConfigByCode(mParamCode); + Calendar calendar = Calendar.getInstance(); + calendar.set(Calendar.MILLISECOND, 0); + calendar.set(Calendar.SECOND, 0); + logger.info("ModelWarehouseTask定时任务正在执行,参数为:{}", params); + if (BusinessConstant.DEV_Y.equals(isDev)) { + logger.info("模型采用开发模型"); + } else { + logger.info("模型采用生产模型"); + } + try { + if (!BusinessConstant.DEV_Y.equals(isDev)) { + // 1、判断通讯是否正常 + if (!watchDog.isConnect(WatchConstant.ZX1_STATUS)) { + logger.info("watchDog.isConnect=false"); + return; + } + + // 2、判断控制器状态 + if (!watchDog.isUse(WatchConstant.CONTROLLER_ONSTS_7)) { + logger.info("将反馈值写入下发值,无扰动切换"); + MODEL_CODE_LIST.forEach(item -> { + this.writeBySetValue(item); + }); + return; + } + logger.info("控制器启动"); + } + + // 3、运行模型 + Map<String, Map<String, Object>> allCommonResult = new HashMap<>(); + for (int i = 0; i < MODEL_CODE_LIST.size(); i++) { + StModelDTO stModel = stModelService.getByCode(MODEL_CODE_LIST.get(i)); + if (stModel == null) { + logger.info("model为空!"); + return; + } + logger.info("运行模型:" + stModel.getModelCode()); + Map<String, Object> modelCommonResult = modelHandler.run(stModel.getModelCode(), calendar.getTime()); + allCommonResult.put(MODEL_CODE_LIST.get(i), modelCommonResult); + } + + // 4、下发数据 + if (!BusinessConstant.DEV_Y.equals(isDev)) { + for (int i = 0; i < MODEL_CODE_LIST.size(); i++) { + if (!writeToDcs(allCommonResult.get(MODEL_CODE_LIST.get(i)), MODEL_CODE_LIST.get(i))) { + throw new Exception(MODEL_CODE_LIST.get(i) + "下发数据异常"); + } + } + } + } catch (Exception ex) { + logger.error("ModelWarehouseTask运行异常"); + ex.printStackTrace(); + } + logger.info("ModelWarehouseTask运行完成"); + } + + /** + * 数据下发 + * + * @param data + * @param modelCode + */ + private boolean writeToDcs(Map<String, Object> data, String modelCode) { + String code = data.get(BusinessConstant.MODELE_RESULT_STATUS).toString(); + if (BusinessConstant.MODEL_R_ERROR.equals(code.substring(0,1))) { + logger.warn("code=" + code + ",结果异常,不下发数据!恢复手动"); + watchDog.stopControllerSts(WatchConstant.CONTROLLER_ONSTS_7); + return false; + } else if (BusinessConstant.MODEL_R_WARN.equals(code.substring(0,1))) { + logger.warn("code=" + code + ",结果警告"); + FeignWritePointValueDTO writeAlm = new FeignWritePointValueDTO(); + writeAlm.setPointCode(ALM_POINT); + writeAlm.setPointValue(BusinessConstant.STATUS_FALSE); + feignDataApi.setPointValue(writeAlm); + } + + logger.info("下发的数据=" + JSONObject.toJSONString(data)); + List<StModelOutDTO> outPoints = stModelOutService.getOutPoint(modelCode); + if (CollectionUtils.isEmpty(outPoints)) { + logger.info("outPoints 为空!"); + return true; + } + outPoints.forEach(pointItem -> { + FeignWritePointValueDTO writePointValue = new FeignWritePointValueDTO(); + writePointValue.setPointCode(pointItem.getPointNo()); + writePointValue.setPointValue(data.get(pointItem.getResultKey())); + feignDataApi.setPointValue(writePointValue); + }); + return true; + } + + /** + * 无扰模式 + * 反馈写入下发点位 + */ + private void writeBySetValue(String modelCode) { + logger.info("=====writeBySetValue Start======="); + List<StModelOutDTO> outPoints = stModelOutService.getOutPoint(modelCode); + if (CollectionUtils.isEmpty(outPoints)) { + return; + } + outPoints.forEach(item -> { + if (StringUtils.isNotBlank(item.getPointNo()) && StringUtils.isNotBlank(item.getDisturbancePointNo())) { + List<String> points = new ArrayList<>(); + points.add(item.getDisturbancePointNo()); + Map<String, Object> value = feignDataApi.getCurrentValue(points); + FeignWritePointValueDTO writePointValue = new FeignWritePointValueDTO(); + writePointValue.setPointCode(item.getPointNo()); + writePointValue.setPointValue(value.get(item.getDisturbancePointNo())); + feignDataApi.setPointValue(writePointValue); + } + }); + } +} diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/ModelXLFilterTask.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/ModelXLFilterTask.java new file mode 100644 index 0000000..58a8c16 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/ModelXLFilterTask.java @@ -0,0 +1,184 @@ +package com.iailab.module.job.task; + +import com.alibaba.fastjson.JSONObject; +import com.iailab.common.constant.BusinessConstant; +import com.iailab.module.data.dto.FeignWritePointValueDTO; +import com.iailab.module.data.api.IFeignDataApi; +import com.iailab.module.infra.api.config.ConfigApi; +import com.iailab.module.mcs.dto.StModelDTO; +import com.iailab.module.mcs.dto.StModelOutDTO; +import com.iailab.module.mcs.service.StModelOutService; +import com.iailab.module.mcs.service.StModelService; +import com.iailab.module.model.handler.ModelHandler; +import com.iailab.module.watch.WatchConstant; +import com.iailab.module.watch.WatchDog; +import org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import javax.annotation.Resource; +import org.springframework.stereotype.Component; +import org.springframework.util.CollectionUtils; + +import java.math.BigDecimal; +import java.util.*; + +/** + * 智能压滤 + * ZX2 + * 5 0/1 * * * ? + */ +@Component("modelXLFilterTask") +public class ModelXLFilterTask implements ITask { + private Logger logger = LoggerFactory.getLogger(getClass()); + + private final String MODEL_CODE = "filter"; + + private final String mParamCode = "isDev"; + + private final List<String> MODEL_CODE_LIST = new ArrayList<>(); + + private final String ALM_POINT = WatchConstant.CONTROLLER_ALM_4; + + private final String unWrite = "-1"; + + @Resource + private StModelService stModelService; + + @Resource + private ModelHandler modelHandler; + + @Resource + private IFeignDataApi feignDataApi; + + @Resource + private ConfigApi configApi; + + @Resource + private StModelOutService stModelOutService; + + @Resource + private WatchDog watchDog; + + ModelXLFilterTask() { + MODEL_CODE_LIST.add(MODEL_CODE); + } + + @Override + public void run(String params) { + String isDev = configApi.queryConfigByCode(mParamCode); + Calendar calendar = Calendar.getInstance(); + calendar.set(Calendar.MILLISECOND, 0); + calendar.set(Calendar.SECOND, 0); + logger.info("ModelXLFilterTask定时任务正在执行,参数为:{}", params); + if (BusinessConstant.DEV_Y.equals(isDev)) { + logger.info("模型采用开发模型"); + } else { + logger.info("模型采用生产模型"); + } + try { + if (!BusinessConstant.DEV_Y.equals(isDev)) { + // 1、判断通讯是否正常 + if (!watchDog.isConnect(WatchConstant.ZX2_STATUS)) { + logger.info("watchDog.isConnect=false"); + return; + } + + // 2、判断控制器状态 + if (!watchDog.isUse(WatchConstant.CONTROLLER_ONSTS_4)) { + logger.info("将反馈值写入下发值,无扰动切换"); + MODEL_CODE_LIST.forEach(item -> { + this.writeBySetValue(item); + }); + return; + } + logger.info("控制器启动"); + } + + // 3、运行模型 + Map<String, Map<String, Object>> allCommonResult = new HashMap<>(); + for (int i = 0; i < MODEL_CODE_LIST.size(); i++) { + StModelDTO stModel = stModelService.getByCode(MODEL_CODE_LIST.get(i)); + if (stModel == null) { + logger.info("model为空!"); + return; + } + logger.info("运行模型:" + stModel.getModelCode()); + Map<String, Object> modelCommonResult = modelHandler.run(stModel.getModelCode(), calendar.getTime()); + allCommonResult.put(MODEL_CODE_LIST.get(i), modelCommonResult); + } + + // 4、下发数据 + if (!BusinessConstant.DEV_Y.equals(isDev)) { + for (int i = 0; i < MODEL_CODE_LIST.size(); i++) { + if (!writeToDcs(allCommonResult.get(MODEL_CODE_LIST.get(i)), MODEL_CODE_LIST.get(i))) { + throw new Exception(MODEL_CODE_LIST.get(i) + "下发数据异常"); + } + } + } + } catch (Exception ex) { + logger.error("ModelXLFilterTask运行异常"); + ex.printStackTrace(); + } + logger.info("ModelXLFilterTask运行完成"); + } + + /** + * 数据下发 + * + * @param data + * @param modelCode + */ + private boolean writeToDcs(Map<String, Object> data, String modelCode) { + String code = data.get(BusinessConstant.MODELE_RESULT_STATUS).toString(); + if (BusinessConstant.MODEL_R_ERROR.equals(code.substring(0,1))) { + logger.warn("code=" + code + ",结果异常,不下发数据!恢复手动"); + watchDog.stopControllerSts(WatchConstant.CONTROLLER_ONSTS_4); + return false; + } else if (BusinessConstant.MODEL_R_WARN.equals(code.substring(0,1))) { + logger.warn("code=" + code + ",结果警告"); + FeignWritePointValueDTO writeAlm = new FeignWritePointValueDTO(); + writeAlm.setPointCode(ALM_POINT); + writeAlm.setPointValue(BusinessConstant.STATUS_FALSE); + feignDataApi.setPointValue(writeAlm); + } + + logger.info("下发的数据=" + JSONObject.toJSONString(data)); + List<StModelOutDTO> outPoints = stModelOutService.getOutPoint(modelCode); + if (CollectionUtils.isEmpty(outPoints)) { + logger.info("outPoints 为空!"); + return true; + } + outPoints.forEach(pointItem -> { + if (!unWrite.equals(data.get(pointItem.getResultKey()).toString())) { + FeignWritePointValueDTO writePointValue = new FeignWritePointValueDTO(); + writePointValue.setPointCode(pointItem.getPointNo()); + writePointValue.setPointValue(new BigDecimal(data.get(pointItem.getResultKey()).toString())); + feignDataApi.setPointValue(writePointValue); + } + }); + return true; + } + + /** + * 无扰模式 + * 反馈写入下发点位 + */ + private void writeBySetValue(String modelCode) { + logger.info("=====writeBySetValue Start======="); + List<StModelOutDTO> outPoints = stModelOutService.getOutPoint(modelCode); + if (CollectionUtils.isEmpty(outPoints)) { + return; + } + outPoints.forEach(item -> { + if (StringUtils.isNotBlank(item.getPointNo()) && StringUtils.isNotBlank(item.getDisturbancePointNo())) { + List<String> points = new ArrayList<>(); + points.add(item.getDisturbancePointNo()); + Map<String, Object> value = feignDataApi.getCurrentValue(points); + FeignWritePointValueDTO writePointValue = new FeignWritePointValueDTO(); + writePointValue.setPointCode(item.getPointNo()); + writePointValue.setPointValue(value.get(item.getDisturbancePointNo())); + feignDataApi.setPointValue(writePointValue); + } + }); + } +} diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/ModelXLThickenerTask.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/ModelXLThickenerTask.java new file mode 100644 index 0000000..ccb0e89 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/ModelXLThickenerTask.java @@ -0,0 +1,180 @@ +package com.iailab.module.job.task; + +import com.alibaba.fastjson.JSONObject; +import com.iailab.common.constant.BusinessConstant; +import com.iailab.module.data.dto.FeignWritePointValueDTO; +import com.iailab.module.data.api.IFeignDataApi; +import com.iailab.module.infra.api.config.ConfigApi; +import com.iailab.module.mcs.dto.StModelDTO; +import com.iailab.module.mcs.dto.StModelOutDTO; +import com.iailab.module.mcs.service.StModelOutService; +import com.iailab.module.mcs.service.StModelService; +import com.iailab.module.model.handler.ModelHandler; +import com.iailab.module.watch.WatchConstant; +import com.iailab.module.watch.WatchDog; +import org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import javax.annotation.Resource; +import org.springframework.stereotype.Component; +import org.springframework.util.CollectionUtils; + +import java.math.BigDecimal; +import java.util.*; + +/** + * 旋流浓缩 + * ZX2 + * 5 0/1 * * * ? + */ +@Component("modelXLThickenerTask") +public class ModelXLThickenerTask implements ITask { + private Logger logger = LoggerFactory.getLogger(getClass()); + + private final String MODEL_CODE = "thickener_control_xl"; + + private final String mParamCode = "isDev"; + + private final List<String> MODEL_CODE_LIST = new ArrayList<>(); + + private final String ALM_POINT = WatchConstant.CONTROLLER_ALM_3; + + @Resource + private StModelService stModelService; + + @Resource + private ModelHandler modelHandler; + + @Resource + private IFeignDataApi feignDataApi; + + @Resource + private ConfigApi configApi; + + @Resource + private StModelOutService stModelOutService; + + @Resource + private WatchDog watchDog; + + ModelXLThickenerTask() { + MODEL_CODE_LIST.add(MODEL_CODE); + } + + @Override + public void run(String params) { + String isDev = configApi.queryConfigByCode(mParamCode); + Calendar calendar = Calendar.getInstance(); + calendar.set(Calendar.MILLISECOND, 0); + calendar.set(Calendar.SECOND, 0); + logger.info("ModelXLThickenerTask定时任务正在执行,参数为:{}", params); + if (BusinessConstant.DEV_Y.equals(isDev)) { + logger.info("模型采用开发模型"); + } else { + logger.info("模型采用生产模型"); + } + try { + if (!BusinessConstant.DEV_Y.equals(isDev)) { + // 1、判断通讯是否正常 + if (!watchDog.isConnect(WatchConstant.ZX2_STATUS)) { + logger.info("watchDog.isConnect=false"); + return; + } + + // 2、判断控制器状态 + if (!watchDog.isUse(WatchConstant.CONTROLLER_ONSTS_3)) { + logger.info("将反馈值写入下发值,无扰动切换"); + MODEL_CODE_LIST.forEach(item -> { + this.writeBySetValue(item); + }); + return; + } + logger.info("控制器启动"); + } + + // 3、运行模型 + Map<String, Map<String, Object>> allCommonResult = new HashMap<>(); + for (int i = 0; i < MODEL_CODE_LIST.size(); i++) { + StModelDTO stModel = stModelService.getByCode(MODEL_CODE_LIST.get(i)); + if (stModel == null) { + logger.info("model为空!"); + return; + } + logger.info("运行模型:" + stModel.getModelCode()); + Map<String, Object> modelCommonResult = modelHandler.run(stModel.getModelCode(), calendar.getTime()); + allCommonResult.put(MODEL_CODE_LIST.get(i), modelCommonResult); + } + + // 4、下发数据 + if (!BusinessConstant.DEV_Y.equals(isDev)) { + for (int i = 0; i < MODEL_CODE_LIST.size(); i++) { + if (!writeToDcs(allCommonResult.get(MODEL_CODE_LIST.get(i)), MODEL_CODE_LIST.get(i))) { + throw new Exception(MODEL_CODE_LIST.get(i) + "下发数据异常"); + } + } + } + } catch (Exception ex) { + logger.error("ModelXLThickenerTask运行异常"); + ex.printStackTrace(); + } + logger.info("ModelXLThickenerTask运行完成"); + } + + /** + * 数据下发 + * + * @param data + * @param modelCode + */ + private boolean writeToDcs(Map<String, Object> data, String modelCode) { + String code = data.get(BusinessConstant.MODELE_RESULT_STATUS).toString(); + if (BusinessConstant.MODEL_R_ERROR.equals(code.substring(0,1))) { + logger.warn("code=" + code + ",结果异常,不下发数据!恢复手动"); + watchDog.stopControllerSts(WatchConstant.CONTROLLER_ONSTS_3); + return false; + } else if (BusinessConstant.MODEL_R_WARN.equals(code.substring(0,1))) { + logger.warn("code=" + code + ",结果警告"); + FeignWritePointValueDTO writeAlm = new FeignWritePointValueDTO(); + writeAlm.setPointCode(ALM_POINT); + writeAlm.setPointValue(BusinessConstant.STATUS_FALSE); + feignDataApi.setPointValue(writeAlm); + } + + logger.info("下发的数据=" + JSONObject.toJSONString(data)); + List<StModelOutDTO> outPoints = stModelOutService.getOutPoint(modelCode); + if (CollectionUtils.isEmpty(outPoints)) { + logger.info("outPoints 为空!"); + return true; + } + outPoints.forEach(pointItem -> { + FeignWritePointValueDTO writePointValue = new FeignWritePointValueDTO(); + writePointValue.setPointCode(pointItem.getPointNo()); + writePointValue.setPointValue(new BigDecimal(data.get(pointItem.getResultKey()).toString())); + feignDataApi.setPointValue(writePointValue); + }); + return true; + } + + /** + * 无扰模式 + * 反馈写入下发点位 + */ + private void writeBySetValue(String modelCode) { + logger.info("=====writeBySetValue Start======="); + List<StModelOutDTO> outPoints = stModelOutService.getOutPoint(modelCode); + if (CollectionUtils.isEmpty(outPoints)) { + return; + } + outPoints.forEach(item -> { + if (StringUtils.isNotBlank(item.getPointNo()) && StringUtils.isNotBlank(item.getDisturbancePointNo())) { + List<String> points = new ArrayList<>(); + points.add(item.getDisturbancePointNo()); + Map<String, Object> value = feignDataApi.getCurrentValue(points); + FeignWritePointValueDTO writePointValue = new FeignWritePointValueDTO(); + writePointValue.setPointCode(item.getPointNo()); + writePointValue.setPointValue(value.get(item.getDisturbancePointNo())); + feignDataApi.setPointValue(writePointValue); + } + }); + } +} diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/SyncConsDayDataTask.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/SyncConsDayDataTask.java new file mode 100644 index 0000000..2a6946b --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/SyncConsDayDataTask.java @@ -0,0 +1,36 @@ +package com.iailab.module.job.task; + +import com.iailab.module.cons.service.ConsDayDataService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import javax.annotation.Resource; +import org.springframework.stereotype.Component; + +/** + * 同步消耗数据 + * + * @author PanZhibao + * @Description + * @createTime 2024年05月27日 + */ +@Component("syncConsDayDataTask") +public class SyncConsDayDataTask implements ITask { + private Logger logger = LoggerFactory.getLogger(getClass()); + + @Resource + private ConsDayDataService consDayDataService; + + + @Override + public void run(String params) { + try { + logger.info("SyncConsDayDataTask 开始"); + + consDayDataService.syncData(); + logger.info("SyncConsDayDataTask 完成"); + } catch (Exception ex) { + logger.info("SyncConsDayDataTask 异常"); + ex.printStackTrace(); + } + } +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/SyncDeviceInfoTask.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/SyncDeviceInfoTask.java new file mode 100644 index 0000000..83d6833 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/SyncDeviceInfoTask.java @@ -0,0 +1,36 @@ +package com.iailab.module.job.task; + +import com.iailab.module.device.service.DeviceInfoService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import javax.annotation.Resource; +import org.springframework.stereotype.Component; + +/** + * 同步中选设备 + * + * @author PanZhibao + * @Description + * @createTime 2024年05月27日 + */ +@Component("syncDeviceInfoTask") +public class SyncDeviceInfoTask implements ITask { + private Logger logger = LoggerFactory.getLogger(getClass()); + + @Resource + private DeviceInfoService deviceInfoService; + + + @Override + public void run(String params) { + try { + logger.info("SyncDeviceInfoTask 开始"); + + deviceInfoService.syncData(); + logger.info("SyncDeviceInfoTask 完成"); + } catch (Exception ex) { + logger.info("SyncDeviceInfoTask 异常"); + ex.printStackTrace(); + } + } +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/SyncDeviceStatUsageTask.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/SyncDeviceStatUsageTask.java new file mode 100644 index 0000000..fc1ed52 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/SyncDeviceStatUsageTask.java @@ -0,0 +1,35 @@ +package com.iailab.module.job.task; + +import com.iailab.module.device.service.DeviceStatUsageService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import javax.annotation.Resource; +import org.springframework.stereotype.Component; + +/** + * 同步中选设备运行时间 + * 计算设备使用率 + * 每天8:00执行 + * 0 0 8 * * ? + */ +@Component("syncDeviceStatUsageTask") +public class SyncDeviceStatUsageTask implements ITask { + private Logger logger = LoggerFactory.getLogger(getClass()); + + @Resource + private DeviceStatUsageService deviceStatUsageService; + + + @Override + public void run(String params) { + try { + logger.info("SyncDeviceStatUsageTask 开始"); + + deviceStatUsageService.syncData(); + logger.info("SyncDeviceStatUsageTask 完成"); + } catch (Exception ex) { + logger.info("SyncDeviceStatUsageTask 异常"); + ex.printStackTrace(); + } + } +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/SyncPrdCurrentSaleTask.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/SyncPrdCurrentSaleTask.java new file mode 100644 index 0000000..393d78f --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/SyncPrdCurrentSaleTask.java @@ -0,0 +1,36 @@ +package com.iailab.module.job.task; + +import com.iailab.module.prod.service.PrdCurrentSaleService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import javax.annotation.Resource; +import org.springframework.stereotype.Component; + +/** + * 同步当前销量 + * + * @author PanZhibao + * @Description + * @createTime 2024年05月26日 + */ +@Component("syncPrdCurrentSaleTask") +public class SyncPrdCurrentSaleTask implements ITask { + private Logger logger = LoggerFactory.getLogger(getClass()); + + @Resource + private PrdCurrentSaleService prdCurrentSaleService; + + + @Override + public void run(String params) { + try { + logger.info("SyncPrdCurrentSaleTask 开始"); + + prdCurrentSaleService.syncData(); + logger.info("SyncPrdCurrentSaleTask 完成"); + } catch (Exception ex) { + logger.info("SyncPrdCurrentSaleTask 异常"); + ex.printStackTrace(); + } + } +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/SyncPrdDayDutyTask.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/SyncPrdDayDutyTask.java new file mode 100644 index 0000000..0d60358 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/SyncPrdDayDutyTask.java @@ -0,0 +1,37 @@ +package com.iailab.module.job.task; + +import com.iailab.module.prod.service.PrdDayDutyService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import javax.annotation.Resource; +import org.springframework.stereotype.Component; + +/** + * 同步值班信息 + * 0 0 0/2 * * ? + * + * @author PanZhibao + * @Description + * @createTime 2024年05月26日 + */ +@Component("syncPrdDayDutyTask") +public class SyncPrdDayDutyTask implements ITask { + private Logger logger = LoggerFactory.getLogger(getClass()); + + @Resource + private PrdDayDutyService prdDayDutyService; + + + @Override + public void run(String params) { + try { + logger.info("syncPrdDayDutyTask 开始"); + + prdDayDutyService.syncData(); + logger.info("syncPrdDayDutyTask 完成"); + } catch (Exception ex) { + logger.info("syncPrdDayDutyTask 异常"); + ex.printStackTrace(); + } + } +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/SyncPrdDayProdTask.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/SyncPrdDayProdTask.java new file mode 100644 index 0000000..c1340fd --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/SyncPrdDayProdTask.java @@ -0,0 +1,36 @@ +package com.iailab.module.job.task; + +import com.iailab.module.prod.service.PrdDayProdService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import javax.annotation.Resource; +import org.springframework.stereotype.Component; + +/** + * 同步日产品产量 + * + * @author PanZhibao + * @Description + * @createTime 2024年05月26日 + */ +@Component("syncPrdDayProdTask") +public class SyncPrdDayProdTask implements ITask { + private Logger logger = LoggerFactory.getLogger(getClass()); + + @Resource + private PrdDayProdService prdDayProdService; + + + @Override + public void run(String params) { + try { + logger.info("SyncPrdDayProdTask 开始"); + + prdDayProdService.syncData(params); + logger.info("SyncPrdDayProdTask 完成"); + } catch (Exception ex) { + logger.info("SyncPrdDayProdTask 异常"); + ex.printStackTrace(); + } + } +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/SyncPrdPerformanceTask.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/SyncPrdPerformanceTask.java new file mode 100644 index 0000000..e42bb72 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/SyncPrdPerformanceTask.java @@ -0,0 +1,36 @@ +package com.iailab.module.job.task; + +import com.iailab.module.prod.service.PrdCurrentPerformanceService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import javax.annotation.Resource; +import org.springframework.stereotype.Component; + +/** + * 同步当前产量 + * + * @author PanZhibao + * @Description + * @createTime 2024年05月28日 + */ +@Component("syncPrdPerformanceTask") +public class SyncPrdPerformanceTask implements ITask { + private Logger logger = LoggerFactory.getLogger(getClass()); + + @Resource + private PrdCurrentPerformanceService prdCurrentPerformanceService; + + + @Override + public void run(String params) { + try { + logger.info("SyncPrdPerformanceTask 开始"); + + prdCurrentPerformanceService.syncData(); + logger.info("SyncPrdPerformanceTask 完成"); + } catch (Exception ex) { + logger.info("SyncPrdPerformanceTask 异常"); + ex.printStackTrace(); + } + } +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/SyncPrdPlanTask.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/SyncPrdPlanTask.java new file mode 100644 index 0000000..0d25098 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/SyncPrdPlanTask.java @@ -0,0 +1,38 @@ +package com.iailab.module.job.task; + +import com.iailab.module.prod.service.PrdPlanMonService; +import com.iailab.module.prod.service.PrdPlanYearService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import javax.annotation.Resource; +import org.springframework.stereotype.Component; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年05月26日 + */ +@Component("syncPrdPlanTask") +public class SyncPrdPlanTask implements ITask { + private Logger logger = LoggerFactory.getLogger(getClass()); + + @Resource + private PrdPlanYearService prdPlanYearService; + + @Resource + private PrdPlanMonService prdPlanMonService; + + @Override + public void run(String params) { + try { + logger.info("syncPrdDayDutyTask 开始"); + + prdPlanYearService.syncData(); + prdPlanMonService.syncData(); + logger.info("syncPrdDayDutyTask 完成"); + } catch (Exception ex) { + logger.info("syncPrdDayDutyTask 异常"); + ex.printStackTrace(); + } + } +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/SyncPrdStorageDayTask.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/SyncPrdStorageDayTask.java new file mode 100644 index 0000000..34d84ca --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/SyncPrdStorageDayTask.java @@ -0,0 +1,36 @@ +package com.iailab.module.job.task; + +import com.iailab.module.prod.service.StorageDayService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import javax.annotation.Resource; +import org.springframework.stereotype.Component; + +/** + * 同步日仓储趋势 + * + * @author PanZhibao + * @Description + * @createTime 2024年06月01日 + */ +@Component("syncPrdStorageDayTask") +public class SyncPrdStorageDayTask implements ITask { + private Logger logger = LoggerFactory.getLogger(getClass()); + + @Resource + private StorageDayService storageDayService; + + @Override + public void run(String params) { + try { + logger.info("SyncPrdStorageDayTask 开始"); + + storageDayService.syncData(); + logger.info("SyncPrdStorageDayTask 完成"); + } catch (Exception ex) { + logger.info("SyncPrdStorageDayTask 异常"); + ex.printStackTrace(); + } + + } +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/SyncPrdTimeDayTask.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/SyncPrdTimeDayTask.java new file mode 100644 index 0000000..9a866fc --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/SyncPrdTimeDayTask.java @@ -0,0 +1,38 @@ +package com.iailab.module.job.task; + +import com.iailab.module.prod.service.PrdTimeDayService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import javax.annotation.Resource; +import org.springframework.stereotype.Component; + +/** + * 同步生产时间分布 + * 0 0 0/1 * * ? + * + * @author PanZhibao + * @Description + * @createTime 2024年06月16日 + */ +@Component("syncPrdTimeDayTask") +public class SyncPrdTimeDayTask implements ITask { + + private Logger logger = LoggerFactory.getLogger(getClass()); + + @Resource + private PrdTimeDayService prdTimeDayService; + + @Override + public void run(String params) { + try { + logger.info("SyncPrdTimeDayTask 开始"); + + prdTimeDayService.syncData(params); + logger.info("SyncPrdTimeDayTask 完成"); + } catch (Exception ex) { + logger.info("SyncPrdTimeDayTask 异常"); + ex.printStackTrace(); + } + + } +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/SyncQualityTrendDayTask.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/SyncQualityTrendDayTask.java new file mode 100644 index 0000000..636af3c --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/SyncQualityTrendDayTask.java @@ -0,0 +1,36 @@ +package com.iailab.module.job.task; + +import com.iailab.module.quality.service.QualityQualityTrendDayService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import javax.annotation.Resource; +import org.springframework.stereotype.Component; + +/** + * 同步日煤质趋势 + * + * @author PanZhibao + * @Description + * @createTime 2024年05月26日 + */ +@Component("syncQualityTrendDayTask") +public class SyncQualityTrendDayTask implements ITask { + private Logger logger = LoggerFactory.getLogger(getClass()); + + @Resource + private QualityQualityTrendDayService qualityQualityTrendDayService; + + + @Override + public void run(String params) { + try { + logger.info("SyncQualityTrendDayTask 开始"); + + qualityQualityTrendDayService.syncData(); + logger.info("SyncQualityTrendDayTask 完成"); + } catch (Exception ex) { + logger.info("SyncQualityTrendDayTask 异常"); + ex.printStackTrace(); + } + } +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/WatchControllerOn1Task.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/WatchControllerOn1Task.java new file mode 100644 index 0000000..c391abb --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/WatchControllerOn1Task.java @@ -0,0 +1,47 @@ +package com.iailab.module.job.task; + +import com.iailab.module.watch.WatchConstant; +import com.iailab.module.watch.WatchDog; +import lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import javax.annotation.Resource; +import org.springframework.stereotype.Component; + +/** + * 监听浅槽分选控制器状态 + * ZX1 + * + * @author PanZhibao + * @Description + * @createTime 2024年06月06日 + */ +@Slf4j +@Component("watchControllerOn1Task") +public class WatchControllerOn1Task implements ITask { + private Logger logger = LoggerFactory.getLogger(getClass()); + + @Resource + private WatchDog watchDog; + + @Override + public void run(String params) { + // logger.info("WatchControllerOn1Task定时任务正在执行,参数为:{}", params); + try { + if (!watchDog.isConnect(WatchConstant.ZX1_STATUS)) { + log.info("通讯异常,投入智能化状态复位!"); + watchDog.stopControllerSts(WatchConstant.CONTROLLER_ONSTS_1); + return; + } + if (watchDog.isUse(WatchConstant.CONTROLLER_USE_1)) { + watchDog.startControllerSts(WatchConstant.CONTROLLER_ONSTS_1); + } else { + watchDog.stopControllerSts(WatchConstant.CONTROLLER_ONSTS_1); + } + } catch (Exception ex) { + logger.error("WatchControllerOn1Task运行异常"); + ex.printStackTrace(); + } + logger.info("WatchControllerOn1Task运行完成"); + } +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/WatchControllerOn2Task.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/WatchControllerOn2Task.java new file mode 100644 index 0000000..6f55152 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/WatchControllerOn2Task.java @@ -0,0 +1,49 @@ +package com.iailab.module.job.task; + +import com.iailab.module.watch.WatchConstant; +import com.iailab.module.watch.WatchDog; +import lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import javax.annotation.Resource; +import org.springframework.stereotype.Component; + +/** + * 监听旋流分选控制器状态 + * ZX2 + * + * @author PanZhibao + * @Description + * @createTime 2024年06月07日 + */ +@Slf4j +@Component("watchControllerOn2Task") +public class WatchControllerOn2Task implements ITask { + private Logger logger = LoggerFactory.getLogger(getClass()); + + @Resource + private WatchDog watchDog; + + @Override + public void run(String params) { + // logger.info("WatchControllerOn2Task定时任务正在执行,参数为:{}", params); + try { + if (!watchDog.isConnect(WatchConstant.ZX2_STATUS)) { + log.info("通讯异常,投入智能化状态复位!"); + watchDog.stopControllerSts(WatchConstant.CONTROLLER_ONSTS_2); + return; + } + if (watchDog.isUse(WatchConstant.CONTROLLER_USE_2)) { + watchDog.startControllerSts(WatchConstant.CONTROLLER_ONSTS_2); + } else { + watchDog.stopControllerSts(WatchConstant.CONTROLLER_ONSTS_2); + } + } catch (Exception ex) { + logger.error("WatchControllerOn2Task运行异常"); + ex.printStackTrace(); + } + logger.info("WatchControllerOn2Task运行完成"); + } + + +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/WatchControllerOn3Task.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/WatchControllerOn3Task.java new file mode 100644 index 0000000..508af2f --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/WatchControllerOn3Task.java @@ -0,0 +1,50 @@ +package com.iailab.module.job.task; + +import com.iailab.module.watch.WatchConstant; +import com.iailab.module.watch.WatchDog; +import lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import javax.annotation.Resource; +import org.springframework.stereotype.Component; + +/** + * 监听旋流器浓缩智能控制器状态 + * ZX2 + * + * 0/2 * * * * ? + * + * @author PanZhibao + * @Description + * @createTime 2024年06月05日 + */ +@Slf4j +@Component("watchControllerOn3Task") +public class WatchControllerOn3Task implements ITask { + private Logger logger = LoggerFactory.getLogger(getClass()); + + @Resource + private WatchDog watchDog; + + @Override + public void run(String params) { + // logger.info("WatchControllerOn3Task定时任务正在执行,参数为:{}", params); + try { + if (!watchDog.isConnect(WatchConstant.ZX2_STATUS)) { + log.info("通讯异常,投入智能化状态复位!"); + watchDog.stopControllerSts(WatchConstant.CONTROLLER_ONSTS_3); + return; + } + if (watchDog.isUse(WatchConstant.CONTROLLER_USE_3)) { + watchDog.startControllerSts(WatchConstant.CONTROLLER_ONSTS_3); + } else { + watchDog.stopControllerSts(WatchConstant.CONTROLLER_ONSTS_3); + } + } catch (Exception ex) { + logger.error("WatchControllerOn3Task运行异常"); + ex.printStackTrace(); + } + logger.info("WatchControllerOn3Task运行完成"); + + } +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/WatchControllerOn4Task.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/WatchControllerOn4Task.java new file mode 100644 index 0000000..2336aa0 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/WatchControllerOn4Task.java @@ -0,0 +1,49 @@ +package com.iailab.module.job.task; + +import com.iailab.module.watch.WatchConstant; +import com.iailab.module.watch.WatchDog; +import lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import javax.annotation.Resource; +import org.springframework.stereotype.Component; + +/** + * 监听旋流压滤智能控制器状态 + * ZX2 + * + * 0/2 * * * * ? + * + * @author PanZhibao + * @Description + * @createTime 2024年06月07日 + */ +@Slf4j +@Component("watchControllerOn4Task") +public class WatchControllerOn4Task implements ITask { + private Logger logger = LoggerFactory.getLogger(getClass()); + + @Resource + private WatchDog watchDog; + + @Override + public void run(String params) { + // logger.info("WatchControllerOn4Task定时任务正在执行,参数为:{}", params); + try { + if (!watchDog.isConnect(WatchConstant.ZX2_STATUS)) { + log.info("通讯异常,投入智能化状态复位!"); + watchDog.stopControllerSts(WatchConstant.CONTROLLER_ONSTS_4); + return; + } + if (watchDog.isUse(WatchConstant.CONTROLLER_USE_4)) { + watchDog.startControllerSts(WatchConstant.CONTROLLER_ONSTS_4); + } else { + watchDog.stopControllerSts(WatchConstant.CONTROLLER_ONSTS_4); + } + } catch (Exception ex) { + logger.error("WatchControllerOn4Task运行异常"); + ex.printStackTrace(); + } + logger.info("WatchControllerOn4Task运行完成"); + } +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/WatchControllerOn5Task.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/WatchControllerOn5Task.java new file mode 100644 index 0000000..5fa19f2 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/WatchControllerOn5Task.java @@ -0,0 +1,50 @@ +package com.iailab.module.job.task; + +import com.iailab.module.watch.WatchConstant; +import com.iailab.module.watch.WatchDog; +import lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import javax.annotation.Resource; +import org.springframework.stereotype.Component; + +/** + * 监听浅槽浓缩智能控制器状态 + * ZX1 + * + * 0/2 * * * * ? + * + * @author PanZhibao + * @Description + * @createTime 2024年06月07日 + */ +@Slf4j +@Component("watchControllerOn5Task") +public class WatchControllerOn5Task implements ITask { + private Logger logger = LoggerFactory.getLogger(getClass()); + + @Resource + private WatchDog watchDog; + + @Override + public void run(String params) { + // logger.info("WatchControllerOn5Task定时任务正在执行,参数为:{}", params); + try { + if (!watchDog.isConnect(WatchConstant.ZX1_STATUS)) { + log.info("通讯异常,投入智能化状态复位!"); + watchDog.stopControllerSts(WatchConstant.CONTROLLER_ONSTS_5); + return; + } + if (watchDog.isUse(WatchConstant.CONTROLLER_USE_5)) { + watchDog.startControllerSts(WatchConstant.CONTROLLER_ONSTS_5); + } else { + watchDog.stopControllerSts(WatchConstant.CONTROLLER_ONSTS_5); + } + } catch (Exception ex) { + logger.error("WatchControllerOn5Task运行异常"); + ex.printStackTrace(); + } + logger.info("WatchControllerOn5Task运行完成"); + + } +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/WatchControllerOn6Task.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/WatchControllerOn6Task.java new file mode 100644 index 0000000..68148e6 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/WatchControllerOn6Task.java @@ -0,0 +1,50 @@ +package com.iailab.module.job.task; + +import com.iailab.module.watch.WatchConstant; +import com.iailab.module.watch.WatchDog; +import lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import javax.annotation.Resource; +import org.springframework.stereotype.Component; + +/** + * 智能压风 + * ZX1 + * + * 0/2 * * * * ? + * + * @author PanZhibao + * @Description + * @createTime 2024年06月07日 + */ +@Slf4j +@Component("watchControllerOn6Task") +public class WatchControllerOn6Task implements ITask { + private Logger logger = LoggerFactory.getLogger(getClass()); + + @Resource + private WatchDog watchDog; + + @Override + public void run(String params) { + // logger.info("WatchControllerOn6Task定时任务正在执行,参数为:{}", params); + try { + if (!watchDog.isConnect(WatchConstant.ZX1_STATUS)) { + log.info("通讯异常,投入智能化状态复位!"); + watchDog.stopControllerSts(WatchConstant.CONTROLLER_ONSTS_6); + return; + } + if (watchDog.isUse(WatchConstant.CONTROLLER_USE_6)) { + watchDog.startControllerSts(WatchConstant.CONTROLLER_ONSTS_6); + } else { + watchDog.stopControllerSts(WatchConstant.CONTROLLER_ONSTS_6); + } + } catch (Exception ex) { + logger.error("WatchControllerOn6Task运行异常"); + ex.printStackTrace(); + } + logger.info("WatchControllerOn6Task运行完成"); + + } +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/WatchControllerOn7Task.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/WatchControllerOn7Task.java new file mode 100644 index 0000000..cf69833 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/WatchControllerOn7Task.java @@ -0,0 +1,50 @@ +package com.iailab.module.job.task; + +import com.iailab.module.watch.WatchConstant; +import com.iailab.module.watch.WatchDog; +import lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import javax.annotation.Resource; +import org.springframework.stereotype.Component; + +/** + * 配仓 + * ZX1 + * + * 0/2 * * * * ? + * + * @author PanZhibao + * @Description + * @createTime 2024年06月11日 + */ +@Slf4j +@Component("watchControllerOn7Task") +public class WatchControllerOn7Task implements ITask { + private Logger logger = LoggerFactory.getLogger(getClass()); + + @Resource + private WatchDog watchDog; + + @Override + public void run(String params) { + // logger.info("WatchControllerOn7Task定时任务正在执行,参数为:{}", params); + try { + if (!watchDog.isConnect(WatchConstant.ZX1_STATUS)) { + log.info("通讯异常,投入智能化状态复位!"); + watchDog.stopControllerSts(WatchConstant.CONTROLLER_ONSTS_7); + return; + } + if (watchDog.isUse(WatchConstant.CONTROLLER_USE_7)) { + watchDog.startControllerSts(WatchConstant.CONTROLLER_ONSTS_7); + } else { + watchDog.stopControllerSts(WatchConstant.CONTROLLER_ONSTS_7); + } + } catch (Exception ex) { + logger.error("WatchControllerOn7Task运行异常"); + ex.printStackTrace(); + } + logger.info("WatchControllerOn7Task运行完成"); + + } +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/WatchDogZX1Task.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/WatchDogZX1Task.java new file mode 100644 index 0000000..d9c7269 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/WatchDogZX1Task.java @@ -0,0 +1,41 @@ +package com.iailab.module.job.task; + +import com.iailab.module.watch.WatchConstant; +import com.iailab.module.watch.WatchDog; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import javax.annotation.Resource; +import org.springframework.stereotype.Component; + +/** + * ZX1心跳 + * 0/2 * * * * ? + * + * @author PanZhibao + * @Description + * @createTime 2024年06月04日 + */ +@Component("watchDogZX1Task") +public class WatchDogZX1Task implements ITask { + private Logger logger = LoggerFactory.getLogger(getClass()); + + @Resource + private WatchDog watchDog; + + private int lastHeat = 0; + + private final String mParamCode = "isWriteTime"; + + @Override + public void run(String params) { + // logger.info("WatchDogZX1Task定时任务正在执行,参数为:{}", params); + try { + lastHeat = watchDog.writeWatchDogTime(WatchConstant.ZX1_HEART_SET, WatchConstant.ZX1_HEART, + WatchConstant.ZX1_STATUS, lastHeat); + } catch (Exception ex) { + logger.error("WatchDogZX1Task运行异常"); + ex.printStackTrace(); + } + logger.info("WatchDogZX1Task运行完成"); + } +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/WatchDogZX2Task.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/WatchDogZX2Task.java new file mode 100644 index 0000000..080bf38 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/WatchDogZX2Task.java @@ -0,0 +1,41 @@ +package com.iailab.module.job.task; + +import com.iailab.module.watch.WatchConstant; +import com.iailab.module.watch.WatchDog; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import javax.annotation.Resource; +import org.springframework.stereotype.Component; + +/** + * ZX2心跳 + * 0/2 * * * * ? + * + * @author PanZhibao + * @Description + * @createTime 2024年06月05日 + */ +@Component("watchDogZX2Task") +public class WatchDogZX2Task implements ITask { + private Logger logger = LoggerFactory.getLogger(getClass()); + + @Resource + private WatchDog watchDog; + + private int lastHeat = 0; + + private final String mParamCode = "isWriteTime"; + + @Override + public void run(String params) { + // logger.info("WatchDogZX2Task定时任务正在执行,参数为:{}", params); + try { + lastHeat = watchDog.writeWatchDogTime(WatchConstant.ZX2_HEART_SET, WatchConstant.ZX2_HEART, + WatchConstant.ZX2_STATUS, lastHeat); + } catch (Exception ex) { + logger.error("WatchDogZX2Task运行异常"); + ex.printStackTrace(); + } + logger.info("WatchDogZX2Task运行完成"); + } +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/utils/ScheduleJob.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/utils/ScheduleJob.java new file mode 100644 index 0000000..91c497a --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/utils/ScheduleJob.java @@ -0,0 +1,78 @@ +/** + * Copyright (c) 2018 人人开源 All rights reserved. + * + * https://www.renren.io + * + * 版权所有,侵权必究! + */ + +package com.iailab.module.job.utils; + +import com.iailab.framework.common.constant.Constant; +import com.iailab.framework.common.exception.ExceptionUtils; +import com.iailab.framework.common.util.spring.SpringContextUtils; +import com.iailab.module.job.entity.ScheduleJobEntity; +import com.iailab.module.job.entity.ScheduleJobLogEntity; +import org.quartz.JobExecutionContext; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.scheduling.quartz.QuartzJobBean; + +import java.lang.reflect.Method; +import java.util.Date; + + +/** + * 定时任务 + * + * @author Mark sunlightcs@gmail.com + */ +public class ScheduleJob extends QuartzJobBean { + private Logger logger = LoggerFactory.getLogger(getClass()); + + @Override + protected void executeInternal(JobExecutionContext context) { + ScheduleJobEntity scheduleJob = (ScheduleJobEntity) context.getMergedJobDataMap(). + get(ScheduleUtils.JOB_PARAM_KEY); + + //数据库保存执行记录 + ScheduleJobLogEntity log = new ScheduleJobLogEntity(); + log.setJobId(scheduleJob.getId()); + log.setBeanName(scheduleJob.getBeanName()); + log.setParams(scheduleJob.getParams()); + log.setCreateDate(new Date()); + + //任务开始时间 + long startTime = System.currentTimeMillis(); + + try { + //执行任务 + logger.info("任务准备执行,任务ID:{}", scheduleJob.getId()); + Object target = SpringContextUtils.getBean(scheduleJob.getBeanName()); + Method method = target.getClass().getDeclaredMethod("run", String.class); + method.invoke(target, scheduleJob.getParams()); + + //任务执行总时长 + long times = System.currentTimeMillis() - startTime; + log.setTimes((int)times); + //任务状态 + log.setStatus(Constant.SUCCESS); + + logger.info("任务执行完毕,任务ID:{} 总共耗时:{} 毫秒", scheduleJob.getId(), times); + } catch (Exception e) { + logger.error("任务执行失败,任务ID:{}", scheduleJob.getId(), e); + + //任务执行总时长 + long times = System.currentTimeMillis() - startTime; + log.setTimes((int)times); + + //任务状态 + log.setStatus(Constant.FAIL); + log.setError(ExceptionUtils.getErrorStackTrace(e)); + }finally { + //获取spring bean + /*ScheduleJobLogService scheduleJobLogService = SpringContextUtils.getBean(ScheduleJobLogService.class); + scheduleJobLogService.insert(log);*/ + } + } +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/utils/ScheduleUtils.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/utils/ScheduleUtils.java new file mode 100644 index 0000000..49ac389 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/utils/ScheduleUtils.java @@ -0,0 +1,161 @@ +/** + * Copyright (c) 2018 人人开源 All rights reserved. + * + * https://www.renren.io + * + * 版权所有,侵权必究! + */ + +package com.iailab.module.job.utils; + +import com.iailab.framework.common.constant.Constant; +import com.iailab.framework.common.enums.ErrorCode; +import com.iailab.framework.common.exception.ServerException; +import com.iailab.module.job.entity.ScheduleJobEntity; +import org.quartz.*; + +/** + * 定时任务工具类 + * + * @author Mark sunlightcs@gmail.com + */ +public class ScheduleUtils { + private final static String JOB_NAME = "TASK_"; + /** + * 任务调度参数key + */ + public static final String JOB_PARAM_KEY = "JOB_PARAM_KEY"; + + /** + * 获取触发器key + */ + public static TriggerKey getTriggerKey(Long jobId) { + return TriggerKey.triggerKey(JOB_NAME + jobId); + } + + /** + * 获取jobKey + */ + public static JobKey getJobKey(Long jobId) { + return JobKey.jobKey(JOB_NAME + jobId); + } + + /** + * 获取表达式触发器 + */ + public static CronTrigger getCronTrigger(Scheduler scheduler, Long jobId) { + try { + return (CronTrigger) scheduler.getTrigger(getTriggerKey(jobId)); + } catch (SchedulerException e) { + throw new ServerException(ErrorCode.JOB_ERROR, e.getMessage()); + } + } + + /** + * 创建定时任务 + */ + public static void createScheduleJob(Scheduler scheduler, ScheduleJobEntity scheduleJob) { + try { + //构建job信息 + JobDetail jobDetail = JobBuilder.newJob(ScheduleJob.class).withIdentity(getJobKey(scheduleJob.getId())).build(); + + //表达式调度构建器 + CronScheduleBuilder scheduleBuilder = CronScheduleBuilder.cronSchedule(scheduleJob.getCronExpression()) + .withMisfireHandlingInstructionDoNothing(); + + //按新的cronExpression表达式构建一个新的trigger + CronTrigger trigger = TriggerBuilder.newTrigger().withIdentity(getTriggerKey(scheduleJob.getId())).withSchedule(scheduleBuilder).build(); + + //放入参数,运行时的方法可以获取 + jobDetail.getJobDataMap().put(JOB_PARAM_KEY, scheduleJob); + + scheduler.scheduleJob(jobDetail, trigger); + + //暂停任务 + if(scheduleJob.getStatus() == Constant.ScheduleStatus.PAUSE.getValue()){ + pauseJob(scheduler, scheduleJob.getId()); + } + } catch (SchedulerException e) { + throw new ServerException(ErrorCode.JOB_ERROR, e.getMessage()); + } + } + + /** + * 更新定时任务 + */ + public static void updateScheduleJob(Scheduler scheduler, ScheduleJobEntity scheduleJob) { + try { + TriggerKey triggerKey = getTriggerKey(scheduleJob.getId()); + + //表达式调度构建器 + CronScheduleBuilder scheduleBuilder = CronScheduleBuilder.cronSchedule(scheduleJob.getCronExpression()) + .withMisfireHandlingInstructionDoNothing(); + + CronTrigger trigger = getCronTrigger(scheduler, scheduleJob.getId()); + + //按新的cronExpression表达式重新构建trigger + trigger = trigger.getTriggerBuilder().withIdentity(triggerKey).withSchedule(scheduleBuilder).build(); + + //参数 + trigger.getJobDataMap().put(JOB_PARAM_KEY, scheduleJob); + + scheduler.rescheduleJob(triggerKey, trigger); + + //暂停任务 + if(scheduleJob.getStatus() == Constant.ScheduleStatus.PAUSE.getValue()){ + pauseJob(scheduler, scheduleJob.getId()); + } + + } catch (SchedulerException e) { + throw new ServerException(ErrorCode.JOB_ERROR, e.getMessage()); + } + } + + /** + * 立即执行任务 + */ + public static void run(Scheduler scheduler, ScheduleJobEntity scheduleJob) { + try { + //参数 + JobDataMap dataMap = new JobDataMap(); + dataMap.put(JOB_PARAM_KEY, scheduleJob); + + scheduler.triggerJob(getJobKey(scheduleJob.getId()), dataMap); + } catch (SchedulerException e) { + throw new ServerException(ErrorCode.JOB_ERROR, e.getMessage()); + } + } + + /** + * 暂停任务 + */ + public static void pauseJob(Scheduler scheduler, Long jobId) { + try { + scheduler.pauseJob(getJobKey(jobId)); + } catch (SchedulerException e) { + throw new ServerException(ErrorCode.JOB_ERROR, e.getMessage()); + } + } + + /** + * 恢复任务 + */ + public static void resumeJob(Scheduler scheduler, Long jobId) { + try { + scheduler.resumeJob(getJobKey(jobId)); + } catch (SchedulerException e) { + throw new ServerException(ErrorCode.JOB_ERROR, e.getMessage()); + } + } + + /** + * 删除定时任务 + */ + public static void deleteScheduleJob(Scheduler scheduler, Long jobId) { + try { + scheduler.deleteJob(getJobKey(jobId)); + } catch (SchedulerException e) { + throw new ServerException(ErrorCode.JOB_ERROR, e.getMessage()); + } + } +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/knowledge/controller/KnowledgeDetController.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/knowledge/controller/KnowledgeDetController.java new file mode 100644 index 0000000..d2f49d8 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/knowledge/controller/KnowledgeDetController.java @@ -0,0 +1,92 @@ +package com.iailab.module.knowledge.controller; + +import com.iailab.common.annotation.LogOperation; +import com.iailab.common.utils.Constant; +import com.iailab.framework.common.page.PageData; +import com.iailab.framework.common.pojo.CommonResult; +import com.iailab.framework.common.util.validation.ValidationUtils; +import com.iailab.framework.common.validation.group.AddGroup; +import com.iailab.framework.common.validation.group.DefaultGroup; +import com.iailab.framework.common.validation.group.UpdateGroup; +import com.iailab.module.knowledge.dto.KnowledgeDetDTO; +import com.iailab.module.knowledge.service.KnowledgeDetService; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.Parameters; +import io.swagger.v3.oas.annotations.tags.Tag; +import javax.annotation.Resource; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.*; + +import java.util.Map; + +/** + * @author PanZhibao + * @Description + * @createTime 2023年12月26日 09:12:00 + */ +@RestController +@RequestMapping("/knowledge/det") +@Tag(name = "知识详情") +public class KnowledgeDetController { + @Resource + private KnowledgeDetService knowledgeDetService; + + @GetMapping("page") + @Operation(summary = "分页") + @Parameters({ + @Parameter(name = Constant.PAGE, description = "当前页码,从1开始", required = true), + @Parameter(name = Constant.LIMIT, description = "每页显示记录数", required = true), + @Parameter(name = Constant.ORDER_FIELD, description = "排序字段"), + @Parameter(name = Constant.ORDER, description = "排序方式,可选值(asc、desc)") + }) + public CommonResult<PageData<KnowledgeDetDTO>> page(@RequestParam Map<String, Object> params) { + PageData<KnowledgeDetDTO> page = knowledgeDetService.page(params); + + return new CommonResult<PageData<KnowledgeDetDTO>>().setData(page); + } + + @GetMapping("{id}") + @Operation(summary = "信息") + public CommonResult<KnowledgeDetDTO> get(@PathVariable("id") String id) { + KnowledgeDetDTO data = knowledgeDetService.get(id); + + return new CommonResult<KnowledgeDetDTO>().setData(data); + } + + @PostMapping + @Operation(summary = "保存") + @LogOperation("保存") + @PreAuthorize("@ss.hasPermission('knowledge:det:save')") + public CommonResult save(@RequestBody KnowledgeDetDTO dto) { + //效验数据 + dto.setId(null); + ValidationUtils.validate(dto, AddGroup.class, DefaultGroup.class); + + knowledgeDetService.save(dto); + + return new CommonResult(); + } + + @PutMapping + @Operation(summary = "修改") + @LogOperation("修改") + @PreAuthorize("@ss.hasPermission('knowledge:det:update')") + public CommonResult update(@RequestBody KnowledgeDetDTO dto) { + //效验数据 + ValidationUtils.validate(dto, UpdateGroup.class, DefaultGroup.class); + + knowledgeDetService.update(dto); + + return new CommonResult(); + } + + @DeleteMapping + @Operation(summary = "删除") + @LogOperation("删除") + @PreAuthorize("@ss.hasPermission('knowledge:det:delete')") + public CommonResult delete(@RequestBody String[] ids) { + knowledgeDetService.delete(ids); + return new CommonResult(); + } +} diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/knowledge/controller/KnowledgePathController.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/knowledge/controller/KnowledgePathController.java new file mode 100644 index 0000000..18bbca3 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/knowledge/controller/KnowledgePathController.java @@ -0,0 +1,107 @@ +package com.iailab.module.knowledge.controller; + +import com.iailab.common.annotation.LogOperation; +import com.iailab.framework.common.page.PageData; +import com.iailab.common.utils.Constant; +import com.iailab.framework.common.pojo.CommonResult; +import com.iailab.framework.common.util.validation.ValidationUtils; +import com.iailab.framework.common.validation.group.AddGroup; +import com.iailab.framework.common.validation.group.DefaultGroup; +import com.iailab.framework.common.validation.group.UpdateGroup; +import com.iailab.module.knowledge.dto.KnowledgePathDTO; +import com.iailab.module.knowledge.service.KnowledgePathService; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.Parameters; +import io.swagger.v3.oas.annotations.tags.Tag; +import javax.annotation.Resource; +import org.springframework.web.bind.annotation.*; + +import java.util.List; +import java.util.Map; + +/** + * @author PanZhibao + * @Description + * @createTime 2023年12月26日 09:12:00 + */ +@RestController +@RequestMapping("/knowledge/path") +@Tag(name = "知识库目录") +public class +KnowledgePathController { + + @Resource + private KnowledgePathService knowledgePathService; + + @GetMapping("page") + @Operation(summary = "分页") + @Parameters({ + @Parameter(name = Constant.PAGE, description = "当前页码,从1开始", required = true), + @Parameter(name = Constant.LIMIT, description = "每页显示记录数", required = true), + @Parameter(name = Constant.ORDER_FIELD, description = "排序字段"), + @Parameter(name = Constant.ORDER, description = "排序方式,可选值(asc、desc)") + }) + public CommonResult<PageData<KnowledgePathDTO>> page(@RequestParam Map<String, Object> params) { + PageData<KnowledgePathDTO> page = knowledgePathService.page(params); + + return new CommonResult<PageData<KnowledgePathDTO>>().setData(page); + } + + @GetMapping("list") + @Operation(summary = "列表") + public CommonResult<List<KnowledgePathDTO>> list(@RequestParam Map<String, Object> params) { + List<KnowledgePathDTO> data = knowledgePathService.list(params); + + return new CommonResult<List<KnowledgePathDTO>>().setData(data); + } + + @GetMapping("tree") + @Operation(summary = "列表") + public CommonResult<List<KnowledgePathDTO>> tree() { + List<KnowledgePathDTO> data = knowledgePathService.tree(); + + return new CommonResult<List<KnowledgePathDTO>>().setData(data); + } + + @GetMapping("{id}") + @Operation(summary = "信息") + public CommonResult<KnowledgePathDTO> get(@PathVariable("id") String id) { + KnowledgePathDTO data = knowledgePathService.get(id); + + return new CommonResult<KnowledgePathDTO>().setData(data); + } + + @PostMapping + @Operation(summary = "保存") + @LogOperation("保存") + public CommonResult save(@RequestBody KnowledgePathDTO dto) { + //效验数据 + ValidationUtils.validate(dto, AddGroup.class, DefaultGroup.class); + + knowledgePathService.save(dto); + + return new CommonResult(); + } + + @PutMapping + @Operation(summary = "修改") + @LogOperation("修改") + public CommonResult update(@RequestBody KnowledgePathDTO dto) { + //效验数据 + ValidationUtils.validate(dto, UpdateGroup.class, DefaultGroup.class); + + knowledgePathService.update(dto); + + return new CommonResult(); + } + + @DeleteMapping("{id}") + @Operation(summary = "删除") + @LogOperation("删除") + public CommonResult delete(@PathVariable("id") String id) { + knowledgePathService.delete(id); + + return new CommonResult(); + } +} diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/knowledge/dao/KnowledgeDetDao.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/knowledge/dao/KnowledgeDetDao.java new file mode 100644 index 0000000..e95b366 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/knowledge/dao/KnowledgeDetDao.java @@ -0,0 +1,14 @@ +package com.iailab.module.knowledge.dao; + +import com.iailab.framework.common.dao.BaseDao; +import com.iailab.module.knowledge.entity.KnowledgeDetEntity; +import org.apache.ibatis.annotations.Mapper; + +/** + * @author PanZhibao + * @Description + * @createTime 2023年12月25日 17:20:00 + */ +@Mapper +public interface KnowledgeDetDao extends BaseDao<KnowledgeDetEntity> { +} diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/knowledge/dao/KnowledgePathDao.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/knowledge/dao/KnowledgePathDao.java new file mode 100644 index 0000000..6785503 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/knowledge/dao/KnowledgePathDao.java @@ -0,0 +1,19 @@ +package com.iailab.module.knowledge.dao; + +import com.iailab.framework.common.dao.BaseDao; +import com.iailab.module.knowledge.dto.KnowledgePathDTO; +import com.iailab.module.knowledge.entity.KnowledgePathEntity; +import org.apache.ibatis.annotations.Mapper; + +import java.util.List; + +/** + * @author PanZhibao + * @Description + * @createTime 2023年12月25日 17:19:00 + */ +@Mapper +public interface KnowledgePathDao extends BaseDao<KnowledgePathEntity> { + + List<KnowledgePathDTO> selectPathList(); +} diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/knowledge/dto/KnowledgeDetDTO.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/knowledge/dto/KnowledgeDetDTO.java new file mode 100644 index 0000000..d9fec7c --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/knowledge/dto/KnowledgeDetDTO.java @@ -0,0 +1,66 @@ +package com.iailab.module.knowledge.dto; + +import com.iailab.framework.common.validation.group.AddGroup; +import com.iailab.framework.common.validation.group.UpdateGroup; +import com.iailab.framework.excel.core.annotations.DictFormat; +import io.swagger.v3.oas.annotations.media.Schema; + +import lombok.Data; + +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Null; +import java.io.Serializable; +import java.util.Date; + +/** + * @author PanZhibao + * @Description + * @createTime 2023年12月26日 08:39:00 + */ +@Data +@Schema(name = "知识详情") +public class KnowledgeDetDTO implements Serializable { + private static final long serialVersionUID = 1L; + + @Schema(name = "id") + @Null(message="{id.null}", groups = AddGroup.class) + @NotNull(message="{id.require}", groups = UpdateGroup.class) + private String id; + + @Schema(name = "树形图节点id") + private String treeId; + + @Schema(name = "类型") + private String typeId; + + @DictFormat("knowledge-type") + @Schema(name = "类型") + private String typeName; + + @Schema(name = "标题") + private String title; + + @Schema(name = "关键词") + private String keyWords; + + @Schema(name = "技术分类") + private String skillTypeId; + + @Schema(name = "网址") + private String website; + + @Schema(name = "摘要") + private String content; + + @Schema(name = "文件名称") + private String fileName; + + @Schema(name = "文件后缀") + private String filePostfix; + + @Schema(name = "文件地址") + private String url; + + @Schema(name = "创建时间") + private Date createDate; +} diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/knowledge/dto/KnowledgePathDTO.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/knowledge/dto/KnowledgePathDTO.java new file mode 100644 index 0000000..24c59b3 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/knowledge/dto/KnowledgePathDTO.java @@ -0,0 +1,34 @@ +package com.iailab.module.knowledge.dto; + +import io.swagger.v3.oas.annotations.media.Schema; + +import lombok.Data; + +import java.io.Serializable; +import java.util.List; + +/** + * @author PanZhibao + * @Description + * @createTime 2023年12月26日 09:09:00 + */ +@Data +@Schema(name = "知识库目录") +public class KnowledgePathDTO implements Serializable { + private static final long serialVersionUID = 1L; + + @Schema(name = "id") + private String id; + + @Schema(name = "级联value") + private String value; + + @Schema(name = "标签") + private String label; + + @Schema(name = "父ID") + private String parentId; + + @Schema(name = "children") + private List<KnowledgePathDTO> children; +} diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/knowledge/entity/KnowledgeDetEntity.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/knowledge/entity/KnowledgeDetEntity.java new file mode 100644 index 0000000..883f4b9 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/knowledge/entity/KnowledgeDetEntity.java @@ -0,0 +1,82 @@ +package com.iailab.module.knowledge.entity; + +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.io.Serializable; +import java.util.Date; + +/** + * @author PanZhibao + * @Description + * @createTime 2023年12月25日 16:53:00 + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("t_knowledge_det") +public class KnowledgeDetEntity implements Serializable { + private static final long serialVersionUID = 1L; + + /** + * id + */ + @TableId + private String id; + + /** + * 树形图节点id + */ + private String treeId; + + /** + * 类型 + */ + private String typeId; + + /** + * 标题 + */ + private String title; + + /** + * 关键词 + */ + private String keyWords; + + /** + * 技术分类 + */ + private String skillTypeId; + + /** + * 网址 + */ + private String website; + + /** + * 摘要 + */ + private String content; + + /** + * 创建者 + */ + private Long creator; + + /** + * 创建时间 + */ + private Date createDate; + + /** + * 创建者 + */ + private Long updater; + + /** + * 创建时间 + */ + private Date updateDate; +} diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/knowledge/entity/KnowledgePathEntity.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/knowledge/entity/KnowledgePathEntity.java new file mode 100644 index 0000000..11d4197 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/knowledge/entity/KnowledgePathEntity.java @@ -0,0 +1,36 @@ +package com.iailab.module.knowledge.entity; + +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.io.Serializable; + +/** + * @author PanZhibao + * @Description + * @createTime 2023年12月24日 21:10:00 + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("t_knowledge_path") +public class KnowledgePathEntity implements Serializable { + private static final long serialVersionUID = 1L; + + /** + * id + */ + @TableId + private String id; + + /** + * 标签 + */ + private String label; + + /** + * 父ID + */ + private String parentId; +} diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/knowledge/service/KnowledgeDetService.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/knowledge/service/KnowledgeDetService.java new file mode 100644 index 0000000..e4a15aa --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/knowledge/service/KnowledgeDetService.java @@ -0,0 +1,26 @@ +package com.iailab.module.knowledge.service; + +import com.iailab.framework.common.page.PageData; +import com.iailab.framework.common.service.BaseService; +import com.iailab.module.knowledge.dto.KnowledgeDetDTO; +import com.iailab.module.knowledge.entity.KnowledgeDetEntity; + +import java.util.Map; + +/** + * @author PanZhibao + * @Description + * @createTime 2023年12月25日 17:20:00 + */ +public interface KnowledgeDetService extends BaseService<KnowledgeDetEntity> { + + PageData<KnowledgeDetDTO> page(Map<String, Object> params); + + KnowledgeDetDTO get(String id); + + void save(KnowledgeDetDTO dto); + + void update(KnowledgeDetDTO dto); + + void delete(String[] ids); +} diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/knowledge/service/KnowledgePathService.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/knowledge/service/KnowledgePathService.java new file mode 100644 index 0000000..94c7c12 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/knowledge/service/KnowledgePathService.java @@ -0,0 +1,31 @@ +package com.iailab.module.knowledge.service; + +import com.iailab.framework.common.page.PageData; +import com.iailab.framework.common.service.BaseService; +import com.iailab.module.knowledge.dto.KnowledgePathDTO; +import com.iailab.module.knowledge.entity.KnowledgePathEntity; + +import java.util.List; +import java.util.Map; + +/** + * @author PanZhibao + * @Description + * @createTime 2023年12月25日 17:21:00 + */ +public interface KnowledgePathService extends BaseService<KnowledgePathEntity> { + + PageData<KnowledgePathDTO> page(Map<String, Object> params); + + List<KnowledgePathDTO> list(Map<String, Object> params); + + List<KnowledgePathDTO> tree(); + + KnowledgePathDTO get(String id); + + void save(KnowledgePathDTO dto); + + void update(KnowledgePathDTO dto); + + void delete(String id); +} diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/knowledge/service/impl/KnowledgeDetServiceImpl.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/knowledge/service/impl/KnowledgeDetServiceImpl.java new file mode 100644 index 0000000..dff9918 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/knowledge/service/impl/KnowledgeDetServiceImpl.java @@ -0,0 +1,108 @@ +package com.iailab.module.knowledge.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.iailab.framework.common.constant.Constant; +import com.iailab.framework.common.page.PageData; +import com.iailab.framework.common.service.impl.BaseServiceImpl; +import com.iailab.framework.common.util.object.ConvertUtils; +import com.iailab.module.knowledge.dao.KnowledgeDetDao; +import com.iailab.module.knowledge.dto.KnowledgeDetDTO; +import com.iailab.module.knowledge.entity.KnowledgeDetEntity; +import com.iailab.module.knowledge.service.KnowledgeDetService; +import com.iailab.module.oss.dto.OssFileDTO; +import com.iailab.module.oss.service.OssFileService; +import org.apache.commons.lang3.StringUtils; +import javax.annotation.Resource; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.util.CollectionUtils; + +import java.util.*; + +/** + * @author PanZhibao + * @Description + * @createTime 2023年12月25日 17:33:00 + */ +@Service +public class KnowledgeDetServiceImpl extends BaseServiceImpl<KnowledgeDetDao, KnowledgeDetEntity> implements KnowledgeDetService { + + @Resource + private OssFileService ossAppService; + + private final String BUSINESS_TYPE = "knowledge"; + + @Override + public PageData<KnowledgeDetDTO> page(Map<String, Object> params) { + IPage<KnowledgeDetEntity> page = baseDao.selectPage( + getPage(params, Constant.CREATE_DATE, false), + getWrapper(params) + ); + PageData<KnowledgeDetDTO> result = getPageData(page, KnowledgeDetDTO.class); + result.getList().forEach(item -> { + List<OssFileDTO> fileDTOS = ossAppService.getByBusinessId(item.getId()); + if (!CollectionUtils.isEmpty(fileDTOS)) { + OssFileDTO fileDTO = fileDTOS.get(0); + item.setFileName(fileDTO.getFileName()); + item.setFilePostfix(fileDTO.getFilePostfix()); + item.setUrl(fileDTO.getUrl()); + } + }); + return result; + } + + private QueryWrapper<KnowledgeDetEntity> getWrapper(Map<String, Object> params) { + String treeId = (String) params.get("treeId"); + String title = (String) params.get("title"); + String keyWords = (String) params.get("keyWords"); + QueryWrapper<KnowledgeDetEntity> wrapper = new QueryWrapper<>(); + wrapper.eq(StringUtils.isNotBlank(treeId), "tree_id", treeId) + .like(StringUtils.isNotBlank(title), "title", title) + .like(StringUtils.isNotBlank(keyWords), "key_words", keyWords); + return wrapper; + } + + @Override + public KnowledgeDetDTO get(String id) { + KnowledgeDetEntity entity = baseDao.selectById(id); + KnowledgeDetDTO dto = ConvertUtils.sourceToTarget(entity, KnowledgeDetDTO.class); + List<OssFileDTO> fileDTOS = ossAppService.getByBusinessId(dto.getId()); + if (!CollectionUtils.isEmpty(fileDTOS)) { + OssFileDTO fileDTO = fileDTOS.get(0); + dto.setFileName(fileDTO.getFileName()); + dto.setFilePostfix(fileDTO.getFilePostfix()); + dto.setUrl(fileDTO.getUrl()); + } + return dto; + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void save(KnowledgeDetDTO dto) { + KnowledgeDetEntity entity = ConvertUtils.sourceToTarget(dto, KnowledgeDetEntity.class); + entity.setId(UUID.randomUUID().toString()); + entity.setCreateDate(new Date()); + insert(entity); + OssFileDTO fileDTO = new OssFileDTO(); + fileDTO.setBusinessId(entity.getId()); + fileDTO.setType(BUSINESS_TYPE); + fileDTO.setFileName(dto.getFileName()); + fileDTO.setFilePostfix(dto.getFilePostfix()); + fileDTO.setUrl(dto.getUrl()); + fileDTO.setSort(0); + ossAppService.save(fileDTO); + } + + @Override + public void update(KnowledgeDetDTO dto) { + KnowledgeDetEntity entity = ConvertUtils.sourceToTarget(dto, KnowledgeDetEntity.class); + updateById(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void delete(String[] ids) { + baseDao.deleteBatchIds(Arrays.asList(ids)); + } +} diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/knowledge/service/impl/KnowledgePathServiceImpl.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/knowledge/service/impl/KnowledgePathServiceImpl.java new file mode 100644 index 0000000..171bc87 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/knowledge/service/impl/KnowledgePathServiceImpl.java @@ -0,0 +1,136 @@ +package com.iailab.module.knowledge.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.iailab.framework.common.constant.Constant; +import com.iailab.framework.common.page.PageData; +import com.iailab.framework.common.service.impl.BaseServiceImpl; +import com.iailab.framework.common.util.object.ConvertUtils; +import com.iailab.module.knowledge.dao.KnowledgePathDao; +import com.iailab.module.knowledge.dto.KnowledgePathDTO; +import com.iailab.module.knowledge.entity.KnowledgePathEntity; +import com.iailab.module.knowledge.service.KnowledgePathService; +import org.apache.commons.lang3.StringUtils; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +/** + * @author PanZhibao + * @Description + * @createTime 2023年12月25日 17:33:00 + */ +@Service +public class KnowledgePathServiceImpl extends BaseServiceImpl<KnowledgePathDao, KnowledgePathEntity> implements KnowledgePathService { + @Resource + public KnowledgePathDao knowledgePathDao; + + final String ROOT = "0000000000"; + + @Override + public PageData<KnowledgePathDTO> page(Map<String, Object> params) { + IPage<KnowledgePathEntity> page = baseDao.selectPage( + getPage(params, Constant.CREATE_DATE, false), + getWrapper(params) + ); + return getPageData(page, KnowledgePathDTO.class); + } + + private QueryWrapper<KnowledgePathEntity> getWrapper(Map<String, Object> params) { + String treeId = (String) params.get("treeId"); + String title = (String) params.get("title"); + String keyWords = (String) params.get("keyWords"); + QueryWrapper<KnowledgePathEntity> wrapper = new QueryWrapper<>(); + wrapper.eq(StringUtils.isNotBlank(treeId), "tree_id", treeId) + .like(StringUtils.isNotBlank(title), "title", title) + .like(StringUtils.isNotBlank(keyWords), "key_words", keyWords); + return wrapper; + } + + @Override + public List<KnowledgePathDTO> list(Map<String, Object> params) { + return baseDao.selectPathList(); + } + + /** + * 查询树形图 + * + * @return 树形图 + */ + @Override + public List<KnowledgePathDTO> tree() { + List<KnowledgePathDTO> resultList = new ArrayList<>(); + // 所有树形图节点 + List<KnowledgePathDTO> dataList = knowledgePathDao.selectPathList(); + // 先取出根节点 + for (KnowledgePathDTO item : dataList) { + // 根节点的父id为0000000000 + if (ROOT.equals(item.getParentId())) { + resultList.add(item); + } + } + // 根据根节点id,查询对应子节点 + for (KnowledgePathDTO parent : resultList) { + List<KnowledgePathDTO> childList = getChild(parent.getId(), dataList); + parent.setChildren(childList); + } + + return resultList; + } + + /** + * 设置子节点 + * + * @param parentId 父节点id + * @param dataList 所有节点 + * @return 子节点列表 + */ + private List<KnowledgePathDTO> getChild(String parentId, List<KnowledgePathDTO> dataList) { + List<KnowledgePathDTO> childList = new ArrayList<>(); + // 把节点的子节点找出 + for (KnowledgePathDTO item : dataList) { + if (parentId.equals(item.getParentId())) { + childList.add(item); + } + } + // 递归 + for (KnowledgePathDTO parent : childList) { + parent.setChildren(getChild(parent.getId(), dataList)); + } + // 如果没有子节点了,设置一个空列表 + if (childList.size() == 0) { + return new ArrayList<>(); + } + return childList; + } + + @Override + public KnowledgePathDTO get(String id) { + KnowledgePathEntity entity = baseDao.selectById(id); + + return ConvertUtils.sourceToTarget(entity, KnowledgePathDTO.class); + } + + @Override + public void save(KnowledgePathDTO dto) { + KnowledgePathEntity entity = ConvertUtils.sourceToTarget(dto, KnowledgePathEntity.class); + insert(entity); + } + + @Override + public void update(KnowledgePathDTO dto) { + KnowledgePathEntity entity = ConvertUtils.sourceToTarget(dto, KnowledgePathEntity.class); + updateById(entity); + } + + @Override + public void delete(String id) { + baseDao.delete(new QueryWrapper<KnowledgePathEntity>() + .eq(StringUtils.isNotBlank(id), "id", id) + .or().eq(StringUtils.isNotBlank(id), "parent_id", id) + ); + } +} diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/controller/admin/StModelController.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/controller/admin/StModelController.java new file mode 100644 index 0000000..c51113e --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/controller/admin/StModelController.java @@ -0,0 +1,250 @@ +package com.iailab.module.mcs.controller.admin; + +import com.iailab.common.annotation.LogOperation; +import com.iailab.common.enums.IsEnableEnum; +import com.iailab.framework.common.page.PageData; +import com.iailab.common.utils.Constant; +import com.iailab.framework.common.util.object.ConvertUtils; +import com.iailab.framework.common.pojo.CommonResult; +import com.iailab.framework.common.util.validation.ValidationUtils; +import com.iailab.framework.common.validation.group.AddGroup; +import com.iailab.framework.common.validation.group.DefaultGroup; +import com.iailab.framework.common.validation.group.UpdateGroup; +import com.iailab.framework.security.core.util.SecurityFrameworkUtils; +import com.iailab.module.mcs.dto.StModelDTO; +import com.iailab.module.mcs.dto.StModelOutDTO; +import com.iailab.module.mcs.dto.StModelParamDTO; +import com.iailab.module.mcs.dto.StModelSettingDTO; +import com.iailab.module.mcs.entity.StModelOutEntity; +import com.iailab.module.mcs.entity.StModelParamEntity; +import com.iailab.module.mcs.entity.StModelSettingEntity; +import com.iailab.module.mcs.service.StModelOutService; +import com.iailab.module.mcs.service.StModelParamService; +import com.iailab.module.mcs.service.StModelService; +import com.iailab.module.mcs.service.StModelSettingService; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.Parameters; +import javax.annotation.Resource; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; + +import java.io.IOException; +import java.util.*; + +import static com.iailab.framework.common.pojo.CommonResult.success; + + +/** + * @author lirm 1343021927@qq.com + * @since 1.0.0 2023-05-10 + */ +@RestController +@RequestMapping("/model/mcs/st-model") +public class StModelController { + @Resource + private StModelService stModelService; + + @Resource + private StModelParamService stModelParamService; + + @Resource + private StModelSettingService stModelSettingService; + + @Resource + private StModelOutService stModelOutService; + + @GetMapping("page") + @Operation(summary = "分页") + @Parameters({ + @Parameter(name = Constant.PAGE, description = "当前页码,从1开始", required = true), + @Parameter(name = Constant.LIMIT, description = "每页显示记录数", required = true), + @Parameter(name = Constant.ORDER_FIELD, description = "排序字段"), + @Parameter(name = Constant.ORDER, description = "排序方式,可选值(asc、desc)") + }) + public CommonResult<PageData<StModelDTO>> page(@RequestParam Map<String, Object> params) { + PageData<StModelDTO> page = stModelService.page(params); + + return success(page); + } + + @GetMapping("{id}") + @Operation(summary = "信息") + public CommonResult<StModelDTO> get(@PathVariable("id") String id) { + StModelDTO data = stModelService.get(id); + + List<StModelParamDTO> tParamPage = stModelParamService.getByModelId(id); + data.setModelParamList(tParamPage); + + Map<String, Object> params = new HashMap<String, Object>(1); + params.put("modelId", data.getId()); + List<StModelSettingDTO> tSettingPage = stModelSettingService.getAll(params); + data.setModelSettingList(tSettingPage); + + Map<String, Object> out = new HashMap<String, Object>(1); + out.put("modelId", data.getId()); + List<StModelOutDTO> tOutPage = stModelOutService.getAll(out); + data.setModelOutList(tOutPage); + + return new CommonResult<StModelDTO>().setData(data); + } + + @PostMapping + @Operation(summary = "保存") + @LogOperation("保存") + @Transactional + public CommonResult save(@RequestBody StModelDTO dto) { + //效验数据 + ValidationUtils.validate(dto, AddGroup.class, DefaultGroup.class); + + dto.setId(UUID.randomUUID().toString()); + List<StModelParamDTO> tParamList = dto.getModelParamList(); + if (tParamList != null) { + for (int i = 0; i < tParamList.size(); i++) { + StModelParamDTO tParamDTO = new StModelParamDTO(); + tParamDTO = tParamList.get(i); + StModelParamEntity tParamEntity = new StModelParamEntity(); + tParamEntity.setModelId(dto.getId()); + tParamEntity.setParamName(tParamDTO.getParamName()); + tParamEntity.setParamId(tParamDTO.getParamId()); + tParamEntity.setParamOrder(tParamDTO.getParamOrder()); + tParamEntity.setParamPortOrder(tParamDTO.getParamPortOrder()); + tParamEntity.setDataLength(tParamDTO.getDataLength()); + tParamEntity.setParamType(tParamDTO.getParamType()); + stModelParamService.insert(tParamEntity); + } + } + List<StModelSettingDTO> tSettingList = dto.getModelSettingList(); + if (tSettingList != null) { + for (int i = 0; i < tSettingList.size(); i++) { + StModelSettingEntity tSettingEntity = ConvertUtils.sourceToTarget(tSettingList.get(i), StModelSettingEntity.class); + tSettingEntity.setModelId(dto.getId()); + stModelSettingService.insert(tSettingEntity); + } + } + + List<StModelOutDTO> tOutList = dto.getModelOutList(); + if (tOutList != null) { + for (int i = 0; i < tOutList.size(); i++) { + StModelOutEntity tOutEntity = ConvertUtils.sourceToTarget(tOutList.get(i), StModelOutEntity.class); + tOutEntity.setModelId(dto.getId()); + tOutEntity.setSort(i+1); + stModelOutService.insert(tOutEntity); + } + } + dto.setCreator(SecurityFrameworkUtils.getLoginUserId()); + dto.setCreateDate(new Date()); + dto.setUpdater(SecurityFrameworkUtils.getLoginUserId()); + dto.setUpdateDate(new Date()); + dto.setIsEnable(IsEnableEnum.ENABLE.value()); + stModelService.save(dto); + return new CommonResult(); + } + + @PutMapping + @Operation(summary = "修改") + @LogOperation("修改") + @Transactional + public CommonResult update(@RequestBody StModelDTO dto) { + //效验数据 + ValidationUtils.validate(dto, UpdateGroup.class, DefaultGroup.class); + + List<StModelParamDTO> tParamList = dto.getModelParamList(); + if (tParamList != null) { + stModelParamService.deleteByModelId(dto.getId()); + for (int i = 0; i < tParamList.size(); i++) { + StModelParamDTO tParamDTO = new StModelParamDTO(); + tParamDTO = tParamList.get(i); + StModelParamEntity tParamEntity = new StModelParamEntity(); + tParamEntity.setModelId(dto.getId()); + tParamEntity.setParamName(tParamDTO.getParamName()); + tParamEntity.setParamId(tParamDTO.getParamId()); + tParamEntity.setParamOrder(tParamDTO.getParamOrder()); + tParamEntity.setParamPortOrder(tParamDTO.getParamPortOrder()); + tParamEntity.setDataLength(tParamDTO.getDataLength()); + tParamEntity.setParamType(tParamDTO.getParamType()); + + stModelParamService.insert(tParamEntity); + } + } + List<StModelSettingDTO> tSettingList = dto.getModelSettingList(); + if (tSettingList != null) { + stModelSettingService.deleteByModelId(dto.getId()); + for (int i = 0; i < tSettingList.size(); i++) { + StModelSettingEntity tSettingEntity = ConvertUtils.sourceToTarget(tSettingList.get(i), StModelSettingEntity.class); + tSettingEntity.setModelId(dto.getId()); + stModelSettingService.insert(tSettingEntity); + } + } + List<StModelOutDTO> tOutList = dto.getModelOutList(); + if (tOutList != null) { + stModelOutService.deleteByModelId(dto.getId()); + for (int i = 0; i < tOutList.size(); i++) { + StModelOutEntity tOutEntity = ConvertUtils.sourceToTarget(tOutList.get(i), StModelOutEntity.class); + tOutEntity.setModelId(dto.getId()); + tOutEntity.setSort(i+1); + stModelOutService.insert(tOutEntity); + } + } + + Long id = SecurityFrameworkUtils.getLoginUserId(); + dto.setUpdater(id); + dto.setUpdateDate(new Date()); + stModelService.update(dto); + + return new CommonResult<Object>(); + } + + @DeleteMapping + @Operation(summary = "删除") + @LogOperation("删除") + @Transactional + public CommonResult delete(@RequestBody String[] ids) { + List<String> idsList = Arrays.asList(ids); + for (int i = 0; i < idsList.size(); i++) { + stModelParamService.deleteByModelId(idsList.get(i));//删除模型参数表数据 + stModelSettingService.deleteByModelId(idsList.get(i));//删除模型设置表数据 + } + + stModelService.deleteByIds(ids);//删除模型表数据 + + return new CommonResult(); + } + + @PutMapping("/enable") + @Operation(summary = "启用") + @LogOperation("启用") + @Transactional + public CommonResult enable(@RequestBody String[] ids) { + stModelService.enableByIds(ids); + return new CommonResult(); + } + + @PutMapping("/disable") + @Operation(summary = "禁用") + @LogOperation("禁用") + @Transactional + public CommonResult disable(@RequestBody String[] ids) { + stModelService.disableByIds(ids); + return new CommonResult(); + } + + + /** + * 上传模型 + */ + @Operation(summary = "上传模型") + @PostMapping("/upload") + public CommonResult<Map<String, Object>> upload(@RequestParam("file") MultipartFile file) throws IOException { + Map<String, Object> data = stModelService.upload(file); + return new CommonResult<Map<String, Object>>().setData(data); + } + + @Operation(summary = "上传模型") + @GetMapping("/relation") + public CommonResult getRelation() { + Map<String, Object> data = stModelService.getRelation(); + return new CommonResult().setData(data); + } +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/controller/admin/StModelDocController.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/controller/admin/StModelDocController.java new file mode 100644 index 0000000..fa93249 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/controller/admin/StModelDocController.java @@ -0,0 +1,51 @@ +package com.iailab.module.mcs.controller.admin; + +import com.iailab.common.annotation.LogOperation; +import com.iailab.framework.common.pojo.CommonResult; +import com.iailab.framework.common.util.validation.ValidationUtils; +import com.iailab.framework.common.validation.group.DefaultGroup; +import com.iailab.framework.common.validation.group.UpdateGroup; +import com.iailab.module.mcs.dto.StModelDocDTO; +import com.iailab.module.mcs.service.StModelDocService; +import io.swagger.v3.oas.annotations.Operation; +import javax.annotation.Resource; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.web.bind.annotation.*; + + +@RestController +@RequestMapping("/model/mcs/st-model-doc") +public class StModelDocController { + + @Resource + private StModelDocService stModelDocService; + + @GetMapping("{id}") + @Operation(summary = "信息") + public CommonResult<StModelDocDTO> get(@PathVariable("id") String id) { + StModelDocDTO data = stModelDocService.get(id); + + return new CommonResult<StModelDocDTO>().setData(data); + } + + @PutMapping + @Operation(summary = "修改") + @LogOperation("修改") + public CommonResult update(@RequestBody StModelDocDTO dto){ + //效验数据 + ValidationUtils.validate(dto, UpdateGroup.class, DefaultGroup.class); + stModelDocService.update(dto); + return new CommonResult(); + } + + @PostMapping + @Operation(summary = "保存") + @LogOperation("保存") + @Transactional + public CommonResult save(@RequestBody StModelDocDTO dto){ + //效验数据 + ValidationUtils.validate(dto, UpdateGroup.class, DefaultGroup.class); + stModelDocService.save(dto); + return new CommonResult(); + } +} diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/controller/admin/StModelRequestLogController.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/controller/admin/StModelRequestLogController.java new file mode 100644 index 0000000..d0c3bfe --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/controller/admin/StModelRequestLogController.java @@ -0,0 +1,46 @@ +package com.iailab.module.mcs.controller.admin; + +import com.iailab.framework.common.constant.Constant; +import com.iailab.framework.common.page.PageData; +import com.iailab.framework.common.pojo.CommonResult; +import com.iailab.module.mcs.dto.StModelRequestLogDTO; +import com.iailab.module.mcs.service.StModelRequestLogService; +import io.swagger.v3.oas.annotations.tags.Tag; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.Parameters; +import javax.annotation.Resource; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + + +import java.util.Map; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年05月22日 + */ +@RestController +@RequestMapping("/model/mcs/model-request-log") +@Tag(name = "模型调用日志表") +public class StModelRequestLogController { + + @Resource + private StModelRequestLogService stModelRequestLogService; + + @GetMapping("page") + @Operation(summary = "分页") + @Parameters({ + @Parameter(name = Constant.PAGE, description = "当前页码,从1开始", required = true) , + @Parameter(name = Constant.LIMIT, description = "每页显示记录数", required = true) , + @Parameter(name = Constant.ORDER_FIELD, description = "排序字段") , + @Parameter(name = Constant.ORDER, description = "排序方式,可选值(asc、desc)") + }) + public CommonResult<PageData<StModelRequestLogDTO>> page(@RequestParam Map<String, Object> params){ + PageData<StModelRequestLogDTO> page = stModelRequestLogService.page(params); + return new CommonResult<PageData<StModelRequestLogDTO>>().setData(page); + } +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/controller/admin/StModelRunlogController.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/controller/admin/StModelRunlogController.java new file mode 100644 index 0000000..c41299f --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/controller/admin/StModelRunlogController.java @@ -0,0 +1,116 @@ +package com.iailab.module.mcs.controller.admin; + +import com.iailab.common.annotation.LogOperation; +import com.iailab.framework.common.page.PageData; +import com.iailab.common.utils.Constant; +import com.iailab.framework.common.pojo.CommonResult; + +import com.iailab.framework.common.util.validation.ValidationUtils; +import com.iailab.framework.common.validation.group.AddGroup; +import com.iailab.framework.common.validation.group.DefaultGroup; +import com.iailab.framework.common.validation.group.UpdateGroup; +import com.iailab.module.mcs.dto.StModelRunlogDTO; +import com.iailab.module.mcs.service.StModelRunlogService; +import io.swagger.v3.oas.annotations.tags.Tag; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.Parameters; +import javax.annotation.Resource; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.*; + + +import java.util.Map; + + +/** + * 运行日志表 + * + * @author lirm ${email} + * @since 1.0.0 2023-07-04 + */ +@RestController +@RequestMapping("/model/mcs/runlog") +@Tag(name = "运行日志表") +public class StModelRunlogController { + @Resource + private StModelRunlogService runlogService; + + @GetMapping("page") + @Operation(summary = "分页") + @Parameters({ + @Parameter(name = Constant.PAGE, description = "当前页码,从1开始", required = true) , + @Parameter(name = Constant.LIMIT, description = "每页显示记录数", required = true) , + @Parameter(name = Constant.ORDER_FIELD, description = "排序字段") , + @Parameter(name = Constant.ORDER, description = "排序方式,可选值(asc、desc)") + }) + public CommonResult<PageData<StModelRunlogDTO>> page(@RequestParam Map<String, Object> params){ + PageData<StModelRunlogDTO> page = runlogService.queryPage(params); + + return new CommonResult<PageData<StModelRunlogDTO>>().setData(page); + } + + @GetMapping("{id}") + @Operation(summary = "信息") + @PreAuthorize("@ss.hasPermission('mcs:runlog:info')") + public CommonResult<StModelRunlogDTO> get(@PathVariable("id") Long id){ + StModelRunlogDTO data = runlogService.get(id); + + return new CommonResult<StModelRunlogDTO>().setData(data); + } + + @PostMapping + @Operation(summary = "保存") + @LogOperation("保存") + @PreAuthorize("@ss.hasPermission('mcs:runlog:save')") + public CommonResult save(@RequestBody StModelRunlogDTO dto){ + //效验数据 + ValidationUtils.validate(dto, AddGroup.class, DefaultGroup.class); + + runlogService.save(dto); + + return new CommonResult(); + } + + @PutMapping + @Operation(summary = "修改") + @LogOperation("修改") + @PreAuthorize("@ss.hasPermission('mcs:runlog:update')") + public CommonResult update(@RequestBody StModelRunlogDTO dto){ + //效验数据 + ValidationUtils.validate(dto, UpdateGroup.class, DefaultGroup.class); + + runlogService.update(dto); + + return new CommonResult(); + } + + @DeleteMapping + @Operation(summary = "删除") + @LogOperation("删除") + @PreAuthorize("@ss.hasPermission('mcs:runlog:delete')") + public CommonResult delete(@RequestBody Long[] ids){ + runlogService.delete(ids); + return new CommonResult(); + } + +// @GetMapping("export") +// @Operation(summary = "导出") +// @LogOperation("导出") +// @PreAuthorize("@ss.hasPermission('mcs:runlog:export')") +// public void export(@RequestParam Map<String, Object> params, HttpServletResponse response) throws Exception { +// List<StModelRunlogDTO> list = runlogService.listAll(params); +// +// ExcelUtils.exportExcelToTarget(response, null, list, StModelRunlogExcel.class); +// } + + @GetMapping("list") + @LogOperation("日志") + public CommonResult<PageData<StModelRunlogDTO>> runlog(@RequestParam Map<String, Object> params) { + params.put("limit", "8"); + PageData<StModelRunlogDTO> page = runlogService.queryPage(params); + + return new CommonResult<PageData<StModelRunlogDTO>>().setData(page); + } + +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/controller/package-info.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/controller/package-info.java new file mode 100644 index 0000000..3bebde8 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/controller/package-info.java @@ -0,0 +1 @@ +package com.iailab.module.mcs.controller; \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/dao/StModelDao.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/dao/StModelDao.java new file mode 100644 index 0000000..5817ace --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/dao/StModelDao.java @@ -0,0 +1,16 @@ +package com.iailab.module.mcs.dao; + +import com.iailab.framework.common.dao.BaseDao; +import com.iailab.module.mcs.entity.StModelEntity; +import org.apache.ibatis.annotations.Mapper; + +/** + * 模型信息表 + * + * @author lirm ${email} + * @since 1.0.0 2023-06-21 + */ +@Mapper +public interface StModelDao extends BaseDao<StModelEntity> { + +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/dao/StModelDocDao.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/dao/StModelDocDao.java new file mode 100644 index 0000000..942f61d --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/dao/StModelDocDao.java @@ -0,0 +1,16 @@ +package com.iailab.module.mcs.dao; + +import com.iailab.framework.common.dao.BaseDao; +import com.iailab.module.mcs.entity.StModelDocEntity; +import org.apache.ibatis.annotations.Mapper; + +/** + * 模型信息表 + * + * @author lirm ${email} + * @since 1.0.0 2023-06-21 + */ +@Mapper +public interface StModelDocDao extends BaseDao<StModelDocEntity> { + +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/dao/StModelOutDao.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/dao/StModelOutDao.java new file mode 100644 index 0000000..9164d35 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/dao/StModelOutDao.java @@ -0,0 +1,22 @@ +package com.iailab.module.mcs.dao; + +import com.iailab.framework.common.dao.BaseDao; +import com.iailab.module.mcs.dto.StModelOutDTO; +import com.iailab.module.mcs.entity.StModelOutEntity; +import org.apache.ibatis.annotations.Mapper; + +import java.util.List; +import java.util.Map; + +/** + * @author PanZhibao + * @Description + * @createTime 2023年08月02日 13:30:00 + */ +@Mapper +public interface StModelOutDao extends BaseDao<StModelOutEntity> { + + List<StModelOutDTO> getAll(Map<String, Object> out); + + List<StModelOutDTO> getOutPoint(Map<String, Object> params); +} diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/dao/StModelParamDao.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/dao/StModelParamDao.java new file mode 100644 index 0000000..eb25f4a --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/dao/StModelParamDao.java @@ -0,0 +1,24 @@ +package com.iailab.module.mcs.dao; + +import com.iailab.framework.common.dao.BaseDao; +import com.iailab.module.mcs.dto.StModelParamDTO; +import com.iailab.module.mcs.entity.StModelParamEntity; +import org.apache.ibatis.annotations.Mapper; + +import java.util.List; +import java.util.Map; + +/** + * + * + * @author lirm 1343021927@qq.com + * @since 1.0.0 2023-05-10 + */ +@Mapper +public interface StModelParamDao extends BaseDao<StModelParamEntity> { + + List<StModelParamDTO> getAll(Map<String, Object> params); + + void deleteByModelId(String modelId); + +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/dao/StModelRequestLogDao.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/dao/StModelRequestLogDao.java new file mode 100644 index 0000000..9d7288d --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/dao/StModelRequestLogDao.java @@ -0,0 +1,14 @@ +package com.iailab.module.mcs.dao; + +import com.iailab.framework.common.dao.BaseDao; +import com.iailab.module.mcs.entity.StModelRequestLogEntity; +import org.apache.ibatis.annotations.Mapper; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年05月22日 + */ +@Mapper +public interface StModelRequestLogDao extends BaseDao<StModelRequestLogEntity> { +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/dao/StModelResultDao.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/dao/StModelResultDao.java new file mode 100644 index 0000000..4b1c67e --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/dao/StModelResultDao.java @@ -0,0 +1,44 @@ +package com.iailab.module.mcs.dao; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.iailab.module.any.dto.AnyAllEvaluationDTO; +import com.iailab.module.any.dto.AnyStoreReliabilityDTO; +import com.iailab.module.data.dto.FeignQueryPointDTO; +import com.iailab.common.dto.IndexStatisticDTO; +import com.iailab.framework.common.dao.BaseDao; +import com.iailab.module.mcs.dto.StModelResultDTO; +import com.iailab.module.mcs.entity.StModelResultEntity; +import org.apache.ibatis.annotations.Mapper; + +import java.util.Date; +import java.util.List; +import java.util.Map; + +/** + * 模型返回信息表 + * + * @author lirm ${email} + * @since 1.0.0 2023-06-21 + */ +@Mapper +public interface StModelResultDao extends BaseDao<StModelResultEntity> { + + List<StModelResultEntity> getResultList(Map<String, Object> params); + + List<StModelResultDTO> getLastResultByCode(Map<String, Object> params); + + List<StModelResultDTO> getResultByCodeDate(Map<String, Object> params); + + void cleanModelResult(Map<String, Date> tMap); + + void insertList(List<StModelResultEntity> list); + + List<IndexStatisticDTO> getModelResultList(FeignQueryPointDTO feignQueryPointDTO); + + IPage<AnyStoreReliabilityDTO> getStorePageList(IPage<StModelResultEntity> page, Map<String, Object> params); + + IPage<AnyAllEvaluationDTO> getEvaluationPageList(IPage<StModelResultEntity> page, Map<String, Object> params); + +// @DataSource("slave1") + void migrationModelResult(List<StModelResultEntity> list); +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/dao/StModelRunlogDao.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/dao/StModelRunlogDao.java new file mode 100644 index 0000000..38a90a2 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/dao/StModelRunlogDao.java @@ -0,0 +1,37 @@ +package com.iailab.module.mcs.dao; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.iailab.framework.common.dao.BaseDao; +import com.iailab.module.mcs.dto.StModelRunlogDTO; +import com.iailab.module.mcs.entity.StModelRunlogEntity; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.Date; +import java.util.List; +import java.util.Map; + +/** + * 运行日志表 + * + * @author lirm ${email} + * @since 1.0.0 2023-06-21 + */ +@Mapper +public interface StModelRunlogDao extends BaseDao<StModelRunlogEntity> { + + List<StModelRunlogDTO> getLastFxLog(); + + List<StModelRunlogDTO> getLastJyLog(); + + List<StModelRunlogDTO> getLastLog(Map<String, Object> params); + + void cleanRunlogTask(Map<String, Date> tMap); + + IPage<StModelRunlogEntity> queryList(IPage<StModelRunlogEntity> page, @Param("params") Map<String, Object> params); + + List<StModelRunlogDTO> listAll(Map<String, Object> params); + +// @DataSource("slave1") + void migrationModelRunlog(List<StModelRunlogEntity> list); +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/dao/StModelSettingDao.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/dao/StModelSettingDao.java new file mode 100644 index 0000000..709518d --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/dao/StModelSettingDao.java @@ -0,0 +1,24 @@ +package com.iailab.module.mcs.dao; + +import com.iailab.framework.common.dao.BaseDao; +import com.iailab.module.mcs.dto.StModelSettingDTO; +import com.iailab.module.mcs.entity.StModelSettingEntity; +import org.apache.ibatis.annotations.Mapper; + +import java.util.List; +import java.util.Map; + +/** + * + * + * @author lirm 1343021927@qq.com + * @since 1.0.0 2023-05-10 + */ +@Mapper +public interface StModelSettingDao extends BaseDao<StModelSettingEntity> { + + List<StModelSettingDTO> getAll(Map<String, Object> params); + + void deleteByModelId(String modelId); + +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/dto/RelationLineDTO.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/dto/RelationLineDTO.java new file mode 100644 index 0000000..9625799 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/dto/RelationLineDTO.java @@ -0,0 +1,27 @@ +package com.iailab.module.mcs.dto; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.io.Serializable; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年05月23日 + */ +@Data +@Schema(name = "模型关系线") +public class RelationLineDTO implements Serializable { + private static final long serialVersionUID = 1L; + + private String from; + + private String to; + + private String text = ""; + + private Integer animation = 1; + + private Boolean isHideArrow = true; +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/dto/RelationNodeDTO.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/dto/RelationNodeDTO.java new file mode 100644 index 0000000..7492463 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/dto/RelationNodeDTO.java @@ -0,0 +1,23 @@ +package com.iailab.module.mcs.dto; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.io.Serializable; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年05月23日 + */ +@Data +@Schema(name = "模型关系点") +public class RelationNodeDTO implements Serializable { + private static final long serialVersionUID = 1L; + + private String id; + + private String text; + + private StModelDTO data; +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/dto/StModelDTO.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/dto/StModelDTO.java new file mode 100644 index 0000000..eb2aa10 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/dto/StModelDTO.java @@ -0,0 +1,94 @@ +package com.iailab.module.mcs.dto; + +import com.iailab.framework.excel.core.annotations.DictFormat; +import io.swagger.v3.oas.annotations.media.Schema; + +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; +import java.util.List; + + +/** + * 模型表 + * + * @author lirm 1343021927@qq.com + * @since 1.0.0 2023-05-10 + */ +@Data +@Schema(name = "模型表") +public class StModelDTO implements Serializable { + private static final long serialVersionUID = 1L; + + @Schema(name = "id") + private String id; + + @Schema(name = "模型编码") + private String modelCode; + + @Schema(name = "模型名称") + private String modelName; + + @Schema(name = "模型父级") + private String modelParent; + + @Schema(name = "模型类型") + private String modelType; + + @DictFormat("model_type") + @Schema(name = "模型类型名称") + private String modelTypeName; + + @Schema(name = "模型路径") + private String modelPath; + + @Schema(name = "类名") + private String className; + + @Schema(name = "方法名") + private String methodName; + + @Schema(name = "参数结构") + private String paramsStructure; + + @Schema(name = "备注") + private String remark; + + @Schema(name = "回路") + private String modelLoop; + + @Schema(name = "执行顺序") + private Integer runSort; + + @Schema(name = "运行时间") + private Date runTime; + + @Schema(name = "是否启用") + private Integer isEnable; + + @Schema(name = "创建人") + private Long creator; + + @Schema(name = "创建时间") + private Date createDate; + + @Schema(name = "修改人") + private Long updater; + + @Schema(name = "修改时间") + private Date updateDate; + + @Schema(name = "模型输入参数") + private List<StModelParamDTO> modelParamList; + + @Schema(name = "模型设置") + private List<StModelSettingDTO> modelSettingList; + + @Schema(name = "模型下发配置") + private List<StModelOutDTO> modelOutList; + + @Schema(name = "模型版本") + private String modelVersion; + +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/dto/StModelDocDTO.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/dto/StModelDocDTO.java new file mode 100644 index 0000000..2aee4a8 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/dto/StModelDocDTO.java @@ -0,0 +1,85 @@ +package com.iailab.module.mcs.dto; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; + + +/** + * 模型表 + * + * @author dongyukun + * @since 1.0.0 2023-05-10 + */ +@Data +@Schema(name = "模型接口文档表") +public class StModelDocDTO implements Serializable { + private static final long serialVersionUID = 1L; + + /** + * id + */ + @TableId(type = IdType.ASSIGN_UUID) + private String id; + + /** + * 模型ID + */ + private String modelId; + + /** + * URL + */ + private String url; + + /** + * 方法 + */ + private String method; + + /** + * 输入参数 + */ + private String params; + + /** + * 参数示例 + */ + private String paramsExample; + + /** + * 输出结果 + */ + private String result; + + /** + * 结果示例 + */ + private String resultExample; + + /** + * 创建人 + */ + private Long creator; + + /** + * 创建时间 + */ + private Date createDate; + + /** + * 修改人 + */ + private Long updater; + + /** + * 修改时间 + */ + private Date updateDate; + + +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/dto/StModelOutDTO.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/dto/StModelOutDTO.java new file mode 100644 index 0000000..3ee188b --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/dto/StModelOutDTO.java @@ -0,0 +1,40 @@ +package com.iailab.module.mcs.dto; + +import io.swagger.v3.oas.annotations.media.Schema; + +import lombok.Data; + +import java.io.Serializable; + +/** + * @author PanZhibao + * @Description + * @createTime 2023年08月02日 13:35:00 + */ +@Data +@Schema(name = "模型下发配置") +public class StModelOutDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + @Schema(name = "id") + private String id; + + @Schema(name = "模型ID") + private String modelId; + + @Schema(name = "输出key") + private String resultKey; + + @Schema(name = "是否下发") + private String isWrite; + + @Schema(name = "下发的点位") + private String pointNo; + + @Schema(name = "排序") + private Integer sort; + + @Schema(name = "无扰切换点位") + private String disturbancePointNo; +} diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/dto/StModelParamDTO.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/dto/StModelParamDTO.java new file mode 100644 index 0000000..27a6ebf --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/dto/StModelParamDTO.java @@ -0,0 +1,46 @@ +package com.iailab.module.mcs.dto; + +import io.swagger.v3.oas.annotations.media.Schema; + +import lombok.Data; + +import java.io.Serializable; + + +/** + * 模型参谋 + * + * @author lirm 1343021927@qq.com + * @since 1.0.0 2023-05-10 + */ +@Data +@Schema(name = "模型参谋") +public class StModelParamDTO implements Serializable { + private static final long serialVersionUID = 1L; + + @Schema(name = "id") + private String id; + + @Schema(name = "模型ID") + private String modelId; + + @Schema(name = "参数名称") + private String paramName; + + @Schema(name = "参数ID") + private String paramId; + + @Schema(name = "参数排序") + private Integer paramOrder; + + @Schema(name = "参数端口排序") + private Integer paramPortOrder; + + @Schema(name = "参数长度") + private Integer dataLength; + + @Schema(name = "参数类型") + private String paramType; + + +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/dto/StModelRequestLogDTO.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/dto/StModelRequestLogDTO.java new file mode 100644 index 0000000..43914ee --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/dto/StModelRequestLogDTO.java @@ -0,0 +1,37 @@ +package com.iailab.module.mcs.dto; + +import io.swagger.v3.oas.annotations.media.Schema; + +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年05月22日 + */ +@Data +@Schema(name = "模型调用日志表") +public class StModelRequestLogDTO implements Serializable { + private static final long serialVersionUID = 1L; + + @Schema(name = "id") + private String id; + + @Schema(name = "模型ID") + private String modelId; + + @Schema(name = "调用方账号") + private String appKey; + + @Schema(name = "调用时间") + private Date requestTime; + + @Schema(name = "请求参数") + private String requestParams; + + @Schema(name = "返回结果") + private String responseResult; +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/dto/StModelResultDTO.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/dto/StModelResultDTO.java new file mode 100644 index 0000000..6cec60b --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/dto/StModelResultDTO.java @@ -0,0 +1,56 @@ +package com.iailab.module.mcs.dto; + +import io.swagger.v3.oas.annotations.media.Schema; + +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; + + +/** + * 模型返回信息表 + * + * @author lirm ${email} + * @since 1.0.0 2023-06-21 + */ +@Data +@Schema(name = "模型返回信息表") +public class StModelResultDTO implements Serializable { + private static final long serialVersionUID = 1L; + + @Schema(name = "id") + private String id; + + @Schema(name = "模型ID") + private String modelId; + + @Schema(name = "行号") + private Integer lineIndex; + + @Schema(name = "输出key") + private String resultKey; + + @Schema(name = "输出值") + private String resultValue; + + @Schema(name = "输出时间") + private Date resultTime; + + @Schema(name = "合介密度AI给定值") + private String densityAI; + + @Schema(name = "精煤灰分设定值") + private String ashJm; + + @Schema(name = "凝聚剂流量") + private String flowNjj; + + @Schema(name = "絮凝剂流量") + private String flowXnj; + + @Schema(name = "底流流量") + private String flowBottom; + + +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/dto/StModelRunlogDTO.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/dto/StModelRunlogDTO.java new file mode 100644 index 0000000..e4e5204 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/dto/StModelRunlogDTO.java @@ -0,0 +1,46 @@ +package com.iailab.module.mcs.dto; + +import com.fasterxml.jackson.annotation.JsonFormat; +import io.swagger.v3.oas.annotations.media.Schema; + +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; + + +/** + * 运行日志表 + * + * @author lirm ${email} + * @since 1.0.0 2023-06-21 + */ +@Data +@Schema(name = "运行日志表") +public class StModelRunlogDTO implements Serializable { + private static final long serialVersionUID = 1L; + + @Schema(name = "id") + private String id; + + @Schema(name = "模型id") + private String modelid; + + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + @Schema(name = "运行时间") + private Date runTime; + + @Schema(name = "类别") + private String runType; + + @Schema(name = "运行结果") + private String runResult; + + @Schema(name = "模型代码") + private String modelCode; + + @Schema(name = "模型名称") + private String modelName; + + +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/dto/StModelSettingDTO.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/dto/StModelSettingDTO.java new file mode 100644 index 0000000..cf05019 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/dto/StModelSettingDTO.java @@ -0,0 +1,36 @@ +package com.iailab.module.mcs.dto; + +import io.swagger.v3.oas.annotations.media.Schema; + +import lombok.Data; + +import java.io.Serializable; + + +/** + * 模型参谋 + * + * @author lirm 1343021927@qq.com + * @since 1.0.0 2023-05-10 + */ +@Data +@Schema(name = "模型参谋") +public class StModelSettingDTO implements Serializable { + private static final long serialVersionUID = 1L; + + @Schema(name = "ID") + private String id; + + @Schema(name = "模型ID") + private String modelId; + + @Schema(name = "参数键") + private String settingKey; + + @Schema(name = "参数值") + private String settingValue; + + @Schema(name = "值类型") + private String valueType; + +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/entity/StModelDocEntity.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/entity/StModelDocEntity.java new file mode 100644 index 0000000..0902d4e --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/entity/StModelDocEntity.java @@ -0,0 +1,83 @@ +package com.iailab.module.mcs.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 lirm ${email} + * @since 1.0.0 2023-06-21 + */ +@Data +@TableName("t_st_model_doc") +public class StModelDocEntity implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * id + */ + @TableId(type = IdType.ASSIGN_UUID) + private String id; + + /** + * 模型ID + */ + private String modelId; + + /** + * URL + */ + private String url; + + /** + * 方法 + */ + private String method; + + /** + * 输入参数 + */ + private String params; + + /** + * 参数示例 + */ + private String paramsExample; + + /** + * 输出结果 + */ + private String result; + + /** + * 结果示例 + */ + private String resultExample; + + /** + * 创建人 + */ + private Long creator; + + /** + * 创建时间 + */ + private Date createDate; + + /** + * 修改人 + */ + private Long updater; + + /** + * 修改时间 + */ + private Date updateDate; +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/entity/StModelEntity.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/entity/StModelEntity.java new file mode 100644 index 0000000..3d076c7 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/entity/StModelEntity.java @@ -0,0 +1,118 @@ +package com.iailab.module.mcs.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 lirm ${email} + * @since 1.0.0 2023-06-21 + */ +@Data +@TableName("t_st_model") +public class StModelEntity implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * id + */ + @TableId(type = IdType.ASSIGN_UUID) + private String id; + + /** + * 模型编码 + */ + private String modelCode; + + /** + * 模型名称 + */ + private String modelName; + + /** + * 模型父级 + */ + private String modelParent; + + /** + * 模型类型 + */ + private String modelType; + + /** + * 模型路径 + */ + private String modelPath; + + /** + * 类名 + */ + private String className; + + /** + * 方法名 + */ + private String methodName; + + /** + * 参数结构 + */ + private String paramsStructure; + + /** + * 备注 + */ + private String remark; + + /** + * 回路 + */ + private String modelLoop; + + /** + * 执行顺序 + */ + private Integer runSort; + + /** + * 运行时间 + */ + private Date runTime; + + /** + * 是否启用 + */ + private Integer isEnable; + + /** + * 创建人 + */ + private Long creator; + + /** + * 创建时间 + */ + private Date createDate; + + /** + * 修改人 + */ + private Long updater; + + /** + * 修改时间 + */ + private Date updateDate; + + /** + * 模型版本 + */ + private String modelVersion; +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/entity/StModelOutEntity.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/entity/StModelOutEntity.java new file mode 100644 index 0000000..14e8f02 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/entity/StModelOutEntity.java @@ -0,0 +1,58 @@ +package com.iailab.module.mcs.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; + +/** + * 模型下发信息表 + * + * @author PanZhibao + * @Description + * @createTime 2023年08月02日 13:26:00 + */ +@Data +@TableName("t_st_model_out") +public class StModelOutEntity implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * id + */ + @TableId(type = IdType.ASSIGN_UUID) + private String id; + + /** + * 模型ID + */ + private String modelId; + + /** + * 输出key + */ + private String resultKey; + + /** + * 是否下发 + */ + private String isWrite; + + /** + * 下发的点位 + */ + private String pointNo; + + /** + * 排序 + */ + private Integer sort; + + /** + * 无扰切换点位 + */ + private String disturbancePointNo; +} diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/entity/StModelParamEntity.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/entity/StModelParamEntity.java new file mode 100644 index 0000000..2d36d32 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/entity/StModelParamEntity.java @@ -0,0 +1,55 @@ +package com.iailab.module.mcs.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; + +/** + * 模型参数信息表 + * + * @author lirm ${email} + * @since 1.0.0 2023-06-21 + */ +@Data +@TableName("t_st_model_param") +public class StModelParamEntity implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * id + */ + @TableId(type = IdType.ASSIGN_UUID) + private String id; + /** + * 模型ID + */ + private String modelId; + /** + * 参数名称 + */ + private String paramName; + /** + * 参数ID + */ + private String paramId; + /** + * 参数排序 + */ + private Integer paramOrder; + /** + * 输入排序 + */ + private Integer paramPortOrder; + /** + * 数据长度 + */ + private Integer dataLength; + /** + * 参数类型 + */ + private String paramType; +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/entity/StModelRequestLogEntity.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/entity/StModelRequestLogEntity.java new file mode 100644 index 0000000..f2471fe --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/entity/StModelRequestLogEntity.java @@ -0,0 +1,51 @@ +package com.iailab.module.mcs.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年05月22日 + */ +@Data +@TableName("t_st_model_request_log") +public class StModelRequestLogEntity implements Serializable { + private static final long serialVersionUID = 1L; + + /** + * id + */ + @TableId(type = IdType.ASSIGN_UUID) + private String id; + + /** + * 模型ID + */ + private String modelId; + + /** + * 调用方账号 + */ + private String appKey; + + /** + * 调用时间 + */ + private Date requestTime; + + /** + * 请求参数 + */ + private String requestParams; + + /** + * 返回结果 + */ + private String responseCommonResult; +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/entity/StModelRunlogEntity.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/entity/StModelRunlogEntity.java new file mode 100644 index 0000000..84544b4 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/entity/StModelRunlogEntity.java @@ -0,0 +1,44 @@ +package com.iailab.module.mcs.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 lirm ${email} + * @since 1.0.0 2023-06-21 + */ +@Data +@TableName("t_st_model_runlog") +public class StModelRunlogEntity implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * id + */ + @TableId(type = IdType.ASSIGN_UUID) + private String id; + /** + * 模型id + */ + private String modelid; + /** + * 运行时间 + */ + private Date runTime; + /** + * 类别 + */ + private String runType; + /** + * 运行结果 + */ + private String runCommonResult; +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/entity/StModelSettingEntity.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/entity/StModelSettingEntity.java new file mode 100644 index 0000000..d4f0721 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/entity/StModelSettingEntity.java @@ -0,0 +1,46 @@ +package com.iailab.module.mcs.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; + +/** + * 模型设置表 + * + * @author lirm ${email} + * @since 1.0.0 2023-06-21 + */ +@Data +@TableName("t_st_model_setting") +public class StModelSettingEntity implements Serializable { + private static final long serialVersionUID = 1L; + + /** + * id + */ + @TableId(type = IdType.ASSIGN_UUID) + private String id; + + /** + * 模型ID + */ + private String modelId; + + /** + * 参数键 + */ + private String settingKey; + + /** + * 参数值 + */ + private String settingValue; + + /** + * 值类型 + */ + private String valueType; +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/excel/StModelRunlogExcel.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/excel/StModelRunlogExcel.java new file mode 100644 index 0000000..ee30466 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/excel/StModelRunlogExcel.java @@ -0,0 +1,28 @@ +//package com.iailab.module.mcs.excel; +// +//import cn.afterturn.easypoi.excel.annotation.Excel; +//import lombok.Data; +// +//import java.util.Date; +// +///** +// * 运行日志表 +// * +// * @author lirm ${email} +// * @since 1.0.0 2023-06-21 +// */ +//@Data +//public class StModelRunlogExcel { +// @Excel(name = "id") +// private Integer id; +// @Excel(name = "模型代码") +// private String modelCode; +// @Excel(name = "模型名称") +// private String modelName; +// @Excel(name = "运行时间") +// private Date runTime; +// @Excel(name = "类别") +// private String runType; +// @Excel(name = "运行结果") +// private String runCommonResult; +//} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/service/StModelDocService.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/service/StModelDocService.java new file mode 100644 index 0000000..917546d --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/service/StModelDocService.java @@ -0,0 +1,20 @@ +package com.iailab.module.mcs.service; + +import com.iailab.framework.common.service.BaseService; +import com.iailab.module.mcs.dto.StModelDocDTO; +import com.iailab.module.mcs.entity.StModelDocEntity; + +/** + * 模型信息表 + * + * @author lirm ${email} + * @since 1.0.0 2023-06-21 + */ +public interface StModelDocService extends BaseService<StModelDocEntity> { + + StModelDocDTO get(String modelId); + + void update(StModelDocDTO stModelDocDTO); + + void save(StModelDocDTO stModelDocDTO); +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/service/StModelOutService.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/service/StModelOutService.java new file mode 100644 index 0000000..7dc494b --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/service/StModelOutService.java @@ -0,0 +1,25 @@ +package com.iailab.module.mcs.service; + +import com.iailab.framework.common.service.CrudService; +import com.iailab.module.mcs.dto.StModelOutDTO; +import com.iailab.module.mcs.entity.StModelOutEntity; + +import java.util.List; +import java.util.Map; + +/** + * @author PanZhibao + * @Description + * @createTime 2023年08月02日 13:33:00 + */ +public interface StModelOutService extends CrudService<StModelOutEntity, StModelOutDTO> { + + void deleteByModelId(String modelId); + + List<StModelOutDTO> getWriteByModelId(String modelId); + + List<StModelOutDTO> getOutPoint(String modelCode); + + List<StModelOutDTO> getAll(Map<String, Object> out); + +} diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/service/StModelParamService.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/service/StModelParamService.java new file mode 100644 index 0000000..cc56bc3 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/service/StModelParamService.java @@ -0,0 +1,24 @@ +package com.iailab.module.mcs.service; + +import com.iailab.framework.common.service.CrudService; +import com.iailab.module.mcs.dto.StModelParamDTO; +import com.iailab.module.mcs.entity.StModelParamEntity; + +import java.util.List; +import java.util.Map; + +/** + * + * + * @author lirm 1343021927@qq.com + * @since 1.0.0 2023-05-10 + */ +public interface StModelParamService extends CrudService<StModelParamEntity, StModelParamDTO> { + + List<StModelParamDTO> getAll(Map<String, Object> params); + + void deleteByModelId(String modelId); + + List<StModelParamDTO> getByModelId(String modelId); + +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/service/StModelRequestLogService.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/service/StModelRequestLogService.java new file mode 100644 index 0000000..714d72d --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/service/StModelRequestLogService.java @@ -0,0 +1,20 @@ +package com.iailab.module.mcs.service; + +import com.iailab.framework.common.page.PageData; +import com.iailab.framework.common.service.BaseService; +import com.iailab.module.mcs.dto.StModelRequestLogDTO; +import com.iailab.module.mcs.entity.StModelRequestLogEntity; + +import java.util.Map; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年05月22日 + */ +public interface StModelRequestLogService extends BaseService<StModelRequestLogEntity> { + + PageData<StModelRequestLogDTO> page(Map<String, Object> params); + + void save(StModelRequestLogDTO dto); +} diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/service/StModelResultService.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/service/StModelResultService.java new file mode 100644 index 0000000..b729f43 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/service/StModelResultService.java @@ -0,0 +1,48 @@ +package com.iailab.module.mcs.service; + +import com.iailab.common.dto.IndexStatisticDTO; +import com.iailab.module.any.dto.AnyAllEvaluationDTO; +import com.iailab.module.any.dto.AnyStoreReliabilityDTO; +import com.iailab.module.data.dto.FeignQueryPointDTO; +import com.iailab.framework.common.page.PageData; +import com.iailab.framework.common.service.CrudService; +import com.iailab.module.mcs.dto.StModelResultDTO; +import com.iailab.module.mcs.entity.StModelResultEntity; +import com.iailab.module.model.sample.entity.DataEntity; + +import java.util.Date; +import java.util.List; +import java.util.Map; + +/** + * 模型返回信息表 + * + * @author lirm ${email} + * @since 1.0.0 2023-06-21 + */ +public interface StModelResultService extends CrudService<StModelResultEntity, StModelResultDTO> { + + Map<String, List<IndexStatisticDTO>> getResultList(Map<String, Object> params); + + Map<String, Object> getLastResultMap(Map<String, Object> params); + + Map<String, Object> getResultByCodeDate(Map<String, Object> params); + + List<StModelResultDTO> getLastResultByCode(Map<String, Object> params); + + void migrationModelResult(Map<String, Date> params); + + void addPy(String modelId, List<String> lines, Date runTime); + + List<DataEntity> getValueList(String resultKey, Date startTime, Date endTime); + + void addML(String id, Map<String, Object> result, Date runTime); + + List<IndexStatisticDTO> getModelResultList(FeignQueryPointDTO feignQueryPointDTO); + + PageData<AnyStoreReliabilityDTO> getStorePage(Map<String, Object> params); + + PageData<AnyAllEvaluationDTO> getAllEvaluationPage(Map<String, Object> params); + + List<Map<String, Object>> getList(Map<String, Object> params); +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/service/StModelRunlogService.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/service/StModelRunlogService.java new file mode 100644 index 0000000..d15860c --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/service/StModelRunlogService.java @@ -0,0 +1,33 @@ +package com.iailab.module.mcs.service; + +import com.iailab.framework.common.page.PageData; +import com.iailab.framework.common.service.CrudService; +import com.iailab.module.mcs.dto.StModelRunlogDTO; +import com.iailab.module.mcs.entity.StModelRunlogEntity; + +import java.util.Date; +import java.util.List; +import java.util.Map; + +/** + * 运行日志表 + * + * @author lirm ${email} + * @since 1.0.0 2023-06-21 + */ +public interface StModelRunlogService extends CrudService<StModelRunlogEntity, StModelRunlogDTO> { + + List<StModelRunlogDTO> getLastFxLog(Integer limit); + + List<StModelRunlogDTO> getLastJyLog(Integer limit); + + void cleanRunlogTask(Map<String, Date> tMap); + + PageData<StModelRunlogDTO> queryPage(Map<String, Object> params); + + List<StModelRunlogDTO> listAll(Map<String, Object> params); + + void add(StModelRunlogDTO dto); + + void migrationModelRunlog(Map<String, Date> tMap); +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/service/StModelService.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/service/StModelService.java new file mode 100644 index 0000000..84c0127 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/service/StModelService.java @@ -0,0 +1,46 @@ +package com.iailab.module.mcs.service; + +import com.iailab.framework.common.page.PageData; +import com.iailab.framework.common.service.BaseService; +import com.iailab.module.mcs.dto.StModelDTO; +import com.iailab.module.mcs.entity.StModelEntity; +import org.springframework.web.multipart.MultipartFile; + +import java.io.IOException; +import java.util.Date; +import java.util.List; +import java.util.Map; + +/** + * 模型信息表 + * + * @author lirm ${email} + * @since 1.0.0 2023-06-21 + */ +public interface StModelService extends BaseService<StModelEntity> { + + PageData<StModelDTO> page(Map<String, Object> params); + + StModelDTO get(String id); + + List<StModelDTO> getListAll(Map<String, Object> params); + + void save(StModelDTO dto); + + void update(StModelDTO dto); + + StModelDTO getByCode(String code); + + void deleteByIds(String[] ids); + + void enableByIds(String[] ids); + + void disableByIds(String[] ids); + + void updateTime(String id, Date runTime); + + Map<String, Object> upload(MultipartFile file) throws IOException; + + Map<String, Object> getRelation(); + +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/service/StModelSettingService.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/service/StModelSettingService.java new file mode 100644 index 0000000..3a7e5a7 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/service/StModelSettingService.java @@ -0,0 +1,24 @@ +package com.iailab.module.mcs.service; + +import com.iailab.framework.common.service.CrudService; +import com.iailab.module.mcs.dto.StModelSettingDTO; +import com.iailab.module.mcs.entity.StModelSettingEntity; + +import java.util.List; +import java.util.Map; + +/** + * + * + * @author lirm 1343021927@qq.com + * @since 1.0.0 2023-05-10 + */ +public interface StModelSettingService extends CrudService<StModelSettingEntity, StModelSettingDTO>{ + + List<StModelSettingDTO> getAll(Map<String, Object> params); + + void deleteByModelId(String modelId); + + Map<String, Object> getByModelId(String modelId); + +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/service/impl/StModelDocServiceImpl.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/service/impl/StModelDocServiceImpl.java new file mode 100644 index 0000000..8862b7b --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/service/impl/StModelDocServiceImpl.java @@ -0,0 +1,40 @@ +package com.iailab.module.mcs.service.impl; + + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.iailab.framework.common.service.impl.BaseServiceImpl; +import com.iailab.framework.common.util.object.ConvertUtils; +import com.iailab.module.mcs.dao.StModelDocDao; +import com.iailab.module.mcs.dto.StModelDocDTO; +import com.iailab.module.mcs.entity.StModelDocEntity; +import com.iailab.module.mcs.service.StModelDocService; +import org.springframework.stereotype.Service; + +/** + * @author lirm 1343021927@qq.com + * @since 1.0.0 2023-05-10 + */ +@Service +public class StModelDocServiceImpl extends BaseServiceImpl<StModelDocDao, StModelDocEntity> implements StModelDocService { + + @Override + public StModelDocDTO get(String id) { + StModelDocEntity entity = baseDao.selectOne(new QueryWrapper<StModelDocEntity>().eq("model_id",id)); + + return ConvertUtils.sourceToTarget(entity, StModelDocDTO.class); + } + + @Override + public void update(StModelDocDTO stModelDocDTO) { + StModelDocEntity stModelDocEntity = ConvertUtils.sourceToTarget(stModelDocDTO,StModelDocEntity.class); + updateById(stModelDocEntity); + } + + @Override + public void save(StModelDocDTO stModelDocDTO) { + StModelDocEntity stModelDocEntity = ConvertUtils.sourceToTarget(stModelDocDTO, StModelDocEntity.class); + insert(stModelDocEntity); + } + + +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/service/impl/StModelOutServiceImpl.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/service/impl/StModelOutServiceImpl.java new file mode 100644 index 0000000..5524c30 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/service/impl/StModelOutServiceImpl.java @@ -0,0 +1,67 @@ +package com.iailab.module.mcs.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.iailab.framework.common.service.impl.CrudServiceImpl; +import com.iailab.framework.common.util.object.ConvertUtils; +import com.iailab.module.mcs.dao.StModelOutDao; +import com.iailab.module.mcs.dto.StModelOutDTO; +import com.iailab.module.mcs.entity.StModelOutEntity; +import com.iailab.module.mcs.service.StModelOutService; +import org.apache.commons.lang3.StringUtils; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * @author PanZhibao + * @Description + * @createTime 2023年08月02日 13:33:00 + */ +@Service +public class StModelOutServiceImpl extends CrudServiceImpl<StModelOutDao, StModelOutEntity, StModelOutDTO> implements StModelOutService { + + @Resource + private StModelOutDao stModelOutDao; + + @Override + public QueryWrapper<StModelOutEntity> getWrapper(Map<String, Object> params) { + String modelId = (String) params.get("model_id"); + + QueryWrapper<StModelOutEntity> wrapper = new QueryWrapper<>(); + wrapper.eq(StringUtils.isNotBlank(modelId), "model_id", modelId); + + return wrapper; + } + + @Override + public void deleteByModelId(String modelId) { + Map<String, Object> params = new HashMap<>(); + params.put("model_id", modelId); + baseDao.delete(this.getWrapper(params)); + } + + @Override + public List<StModelOutDTO> getWriteByModelId(String modelId) { + QueryWrapper queryWrapper = new QueryWrapper<StModelOutEntity>() + .eq("model_id", modelId) + .eq("is_write", "1") + .orderByAsc("sort"); + return ConvertUtils.sourceToTarget(baseDao.selectList(queryWrapper), StModelOutDTO.class); + } + + @Override + public List<StModelOutDTO> getOutPoint(String modelCode) { + Map<String, Object> params = new HashMap<>(1); + params.put("modelCode", modelCode); + return stModelOutDao.getOutPoint(params); + } + + @Override + public List<StModelOutDTO> getAll(Map<String, Object> out) { + return stModelOutDao.getAll(out); + } + +} diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/service/impl/StModelParamServiceImpl.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/service/impl/StModelParamServiceImpl.java new file mode 100644 index 0000000..a6928c6 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/service/impl/StModelParamServiceImpl.java @@ -0,0 +1,54 @@ +package com.iailab.module.mcs.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.iailab.framework.common.service.impl.CrudServiceImpl; +import com.iailab.framework.common.util.object.ConvertUtils; +import com.iailab.module.mcs.dao.StModelParamDao; +import com.iailab.module.mcs.dto.StModelParamDTO; +import com.iailab.module.mcs.entity.StModelParamEntity; +import com.iailab.module.mcs.service.StModelParamService; +import org.apache.commons.lang3.StringUtils; +import org.springframework.stereotype.Service; + +import java.util.List; +import java.util.Map; + +/** + * + * + * @author lirm 1343021927@qq.com + * @since 1.0.0 2023-05-10 + */ +@Service +public class StModelParamServiceImpl extends CrudServiceImpl<StModelParamDao, StModelParamEntity, StModelParamDTO> + implements StModelParamService { + + + @Override + public List<StModelParamDTO> getAll(Map<String, Object> params) { + return baseDao.getAll(params); + } + @Override + public QueryWrapper<StModelParamEntity> getWrapper(Map<String, Object> params) { + String id = (String)params.get("id"); + + QueryWrapper<StModelParamEntity> wrapper = new QueryWrapper<>(); + wrapper.eq(StringUtils.isNotBlank(id), "id", id); + + return wrapper; + } + @Override + public void deleteByModelId(String modelId) { + baseDao.deleteByModelId(modelId); + } + + @Override + public List<StModelParamDTO> getByModelId(String modelId) { + QueryWrapper queryWrapper = new QueryWrapper<StModelParamEntity>() + .eq("model_id", modelId) + .orderByAsc("param_port_order") + .orderByAsc("param_order"); + return ConvertUtils.sourceToTarget(baseDao.selectList(queryWrapper), StModelParamDTO.class); + } + +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/service/impl/StModelRequestLogServiceImpl.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/service/impl/StModelRequestLogServiceImpl.java new file mode 100644 index 0000000..e3edfa7 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/service/impl/StModelRequestLogServiceImpl.java @@ -0,0 +1,55 @@ +package com.iailab.module.mcs.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.framework.common.util.object.ConvertUtils; +import com.iailab.module.mcs.dao.StModelRequestLogDao; +import com.iailab.module.mcs.dto.StModelRequestLogDTO; +import com.iailab.module.mcs.entity.StModelRequestLogEntity; +import com.iailab.module.mcs.service.StModelRequestLogService; +import org.apache.commons.lang3.StringUtils; +import org.springframework.stereotype.Service; + +import java.util.Map; +import java.util.UUID; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年05月22日 + */ +@Service +public class StModelRequestLogServiceImpl extends BaseServiceImpl<StModelRequestLogDao, StModelRequestLogEntity> implements StModelRequestLogService { + + @Override + public PageData<StModelRequestLogDTO> page(Map<String, Object> params) { + IPage<StModelRequestLogEntity> page = baseDao.selectPage( + getPage(params, "request_time", false), + getWrapper(params) + ); + return getPageData(page, StModelRequestLogDTO.class); + } + + private QueryWrapper<StModelRequestLogEntity> getWrapper(Map<String, Object> params) { + String modelId = (String) params.get("modelId"); + String appKey = (String) params.get("appKey"); + String startTime = (String) params.get("startTime"); + String endTime = (String) params.get("endTime"); + + QueryWrapper<StModelRequestLogEntity> wrapper = new QueryWrapper<>(); + wrapper.eq(StringUtils.isNotBlank(modelId), "model_id", modelId) + .like(StringUtils.isNotBlank(appKey), "app_key", appKey) + .ge(StringUtils.isNotBlank(startTime), "request_time", startTime) + .le(StringUtils.isNotBlank(endTime), "request_time", endTime); + return wrapper; + } + + @Override + public void save(StModelRequestLogDTO dto) { + StModelRequestLogEntity entity = ConvertUtils.sourceToTarget(dto, StModelRequestLogEntity.class); + entity.setId(UUID.randomUUID().toString()); + insert(entity); + } +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/service/impl/StModelResultServiceImpl.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/service/impl/StModelResultServiceImpl.java new file mode 100644 index 0000000..4966719 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/service/impl/StModelResultServiceImpl.java @@ -0,0 +1,238 @@ +package com.iailab.module.mcs.service.impl; + +import com.alibaba.fastjson.JSONObject; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.iailab.common.dto.IndexStatisticDTO; +import com.iailab.module.any.dto.AnyAllEvaluationDTO; +import com.iailab.module.any.dto.AnyStoreReliabilityDTO; +import com.iailab.module.data.dto.FeignQueryPointDTO; +import com.iailab.framework.common.page.PageData; +import com.iailab.framework.common.service.impl.CrudServiceImpl; +import com.iailab.common.utils.DateUtils; +import com.iailab.module.mcs.dao.StModelResultDao; +import com.iailab.module.mcs.dto.StModelResultDTO; +import com.iailab.module.mcs.entity.StModelResultEntity; +import com.iailab.module.mcs.service.StModelResultService; +import com.iailab.module.model.sample.entity.DataEntity; +import org.apache.commons.lang3.StringUtils; +import org.springframework.stereotype.Service; +import org.springframework.util.CollectionUtils; + +import javax.annotation.Resource; +import java.math.BigDecimal; +import java.util.*; +import java.util.stream.Collectors; + +/** + * 模型返回信息表 + * + * @author lirm ${email} + * @since 1.0.0 2023-06-21 + */ +@Service +public class StModelResultServiceImpl extends CrudServiceImpl<StModelResultDao, StModelResultEntity, StModelResultDTO> implements StModelResultService { + + @Resource + private StModelResultDao stModelResultDao; + + @Override + public QueryWrapper<StModelResultEntity> getWrapper(Map<String, Object> params){ + String id = (String)params.get("id"); + + QueryWrapper<StModelResultEntity> wrapper = new QueryWrapper<>(); + wrapper.eq(StringUtils.isNotBlank(id), "id", id); + + return wrapper; + } + + @Override + public Map<String, List<IndexStatisticDTO>> getResultList(Map<String, Object> params) { + params.put("sortType", "asc"); + Map<String, List<IndexStatisticDTO>> result = new HashMap<>(5); + List<StModelResultEntity> list = stModelResultDao.getResultList(params); + if (CollectionUtils.isEmpty(list)) { + return result; + } + Map<String, List<StModelResultEntity>> groupList = list.stream().collect(Collectors.groupingBy(StModelResultEntity::getResultKey)); + groupList.forEach((k, v) -> { + try{ + List<IndexStatisticDTO> itemList = v.stream().map(item -> { + IndexStatisticDTO dto = new IndexStatisticDTO(); + dto.setData(new BigDecimal(item.getResultValue())); + dto.setDateTime(item.getResultTime()); + return dto; + }).collect(Collectors.toList()); + result.put(k, itemList); + } catch (Exception ex) { + ex.printStackTrace(); + } + }); + return result; + } + + @Override + public List<Map<String, Object>> getList(Map<String, Object> params) { + if (params.get("isAsc") != null && params.get("isAsc").toString().equals("false")) { + params.put("sortType", "desc"); + } else { + params.put("sortType", "asc"); + } + List<Map<String, Object>> result = new ArrayList<>(); + List<StModelResultEntity> list = stModelResultDao.getResultList(params); + List<Date> dateList = list.stream().map(t -> t.getResultTime()).distinct().collect(Collectors.toList()); + Map<Date, List<StModelResultEntity>> groupList = list.stream().collect(Collectors.groupingBy(StModelResultEntity::getResultTime)); + dateList.forEach(item -> { + Map<String, Object> vt = new HashMap<>(); + groupList.get(item).forEach(v -> { + vt.put(v.getResultKey(), v.getResultValue()); + }); + vt.put("resultTime", item); + result.add(vt); + }); + return result; + } + + @Override + public List<StModelResultDTO> getLastResultByCode(Map<String, Object> params) { + return baseDao.getLastResultByCode(params); + } + + @Override + public Map<String, Object> getLastResultMap(Map<String, Object> params) { + Map<String, Object> result = new HashMap<>(1); + List<StModelResultDTO> list = baseDao.getLastResultByCode(params); + if (CollectionUtils.isEmpty(list)) { + return result; + } + list.forEach(item -> { + result.put(item.getResultKey(), item.getResultValue()); + }); + result.put("result_time", list.get(0).getResultTime()); + return result; + } + + @Override + public Map<String, Object> getResultByCodeDate(Map<String, Object> params) { + Map<String, Object> result = new HashMap<>(1); + List<StModelResultDTO> list = baseDao.getResultByCodeDate(params); + if (CollectionUtils.isEmpty(list)) { + return result; + } + list.forEach(item -> { + result.put(item.getResultKey(), item.getResultValue()); + }); + result.put("result_time", list.get(0).getResultTime()); + return result; + } + + @Override + public void migrationModelResult(Map<String, Date> params) { + List<StModelResultEntity> list = stModelResultDao.selectList(getDateWrapper(params)); + if (CollectionUtils.isEmpty(list)){ + return; + } + stModelResultDao.migrationModelResult(list); + stModelResultDao.delete(getDateWrapper(params)); + } + + @Override + public void addPy(String modelId, List<String> lines, Date runTime) { + List<StModelResultEntity> list = new ArrayList<>(); + + if (CollectionUtils.isEmpty(lines)) { + return; + } + for (int i = 0; i < lines.size(); i ++) { + JSONObject josnObject = JSONObject.parseObject(lines.get(i)); + for (String key : josnObject.keySet()) { + StModelResultEntity entity = new StModelResultEntity(); + entity.setId(UUID.randomUUID().toString()); + entity.setModelId(modelId); + entity.setLineIndex(i); + entity.setResultKey(key); + entity.setResultValue(josnObject.getString(key)); + entity.setResultTime(runTime); + list.add(entity); + } + } + baseDao.insertList(list); + } + + @Override + public List<DataEntity> getValueList(String resultKey, Date startTime, Date endTime) { + List<DataEntity> result = new ArrayList<>(); + String[] params = resultKey.split(":"); + + QueryWrapper<StModelResultEntity> wrapper = new QueryWrapper<>(); + wrapper.eq("result_key", params[1]) + .ge("result_time", startTime) + .le("result_time", endTime) + .orderByAsc("result_time"); + List<StModelResultEntity> list = baseDao.selectList(wrapper); + if (CollectionUtils.isEmpty(list)) { + return result; + } + for (int i = 0; i < list.size(); i++) { + DataEntity dataEntity = new DataEntity(); + dataEntity.setTimeStamp(list.get(i).getResultTime()); + dataEntity.setDataValue(Double.parseDouble(list.get(i).getResultValue())); + result.add(dataEntity); + } + return result; + } + + @Override + public void addML(String modelId, Map<String,Object> tMap, Date runTime) { + if (tMap == null) { + return; + } + List<StModelResultEntity> list = new ArrayList<>(); + for(String key:tMap.keySet()){ + StModelResultEntity entity = new StModelResultEntity(); + entity.setId(UUID.randomUUID().toString()); + entity.setModelId(modelId); + entity.setLineIndex(0); + entity.setResultKey(key); + entity.setResultValue(tMap.get(key).toString()); + entity.setResultTime(runTime); + list.add(entity); + } + + baseDao.insertList(list); + } + + @Override + public List<IndexStatisticDTO> getModelResultList(FeignQueryPointDTO feignQueryPointDTO) { + return baseDao.getModelResultList(feignQueryPointDTO); + } + + @Override + public PageData<AnyStoreReliabilityDTO> getStorePage(Map<String, Object> params) { + IPage<AnyStoreReliabilityDTO> page = baseDao.getStorePageList( + getPage(params, "dateTime", false), + params + ); + return getPageData(page, AnyStoreReliabilityDTO.class); + } + + @Override + public PageData<AnyAllEvaluationDTO> getAllEvaluationPage(Map<String, Object> params) { + IPage<AnyAllEvaluationDTO> page = baseDao.getEvaluationPageList( + getPage(params, "dateTime", false), + params + ); + return getPageData(page, AnyAllEvaluationDTO.class); + + } + + public QueryWrapper<StModelResultEntity> getDateWrapper(Map<String, Date> params) { + String startDate = DateUtils.format(params.get("startdate"),DateUtils.DATE_TIME_PATTERN); + String endDate = DateUtils.format(params.get("enddate"),DateUtils.DATE_TIME_PATTERN); + + QueryWrapper<StModelResultEntity> wrapper = new QueryWrapper<>(); + wrapper.ge(StringUtils.isNotBlank(startDate), "result_time", startDate); + wrapper.le(StringUtils.isNotBlank(endDate), "result_time", endDate); + return wrapper; + } +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/service/impl/StModelRunlogServiceImpl.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/service/impl/StModelRunlogServiceImpl.java new file mode 100644 index 0000000..9e1305a --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/service/impl/StModelRunlogServiceImpl.java @@ -0,0 +1,118 @@ +package com.iailab.module.mcs.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.iailab.framework.common.page.PageData; +import com.iailab.framework.common.service.impl.CrudServiceImpl; +import com.iailab.common.utils.Constant; +import com.iailab.framework.common.util.object.ConvertUtils; +import com.iailab.common.utils.DateUtils; +import com.iailab.module.mcs.dao.StModelRunlogDao; +import com.iailab.module.mcs.dto.StModelRunlogDTO; +import com.iailab.module.mcs.entity.StModelRunlogEntity; +import com.iailab.module.mcs.service.StModelRunlogService; +import org.apache.commons.lang3.StringUtils; +import org.springframework.stereotype.Service; +import org.springframework.util.CollectionUtils; + +import javax.annotation.Resource; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + + +/** + * 运行日志表 + * + * @author lirm ${email} + * @since 1.0.0 2023-06-21 + */ +@Service +public class StModelRunlogServiceImpl extends CrudServiceImpl<StModelRunlogDao, StModelRunlogEntity, StModelRunlogDTO> implements StModelRunlogService { + + @Resource + private StModelRunlogDao runlogDao; + + @Override + public QueryWrapper<StModelRunlogEntity> getWrapper(Map<String, Object> params){ + String modelCode = (String)params.get("modelCode"); + String modelName = (String)params.get("modelName"); + + QueryWrapper<StModelRunlogEntity> wrapper = new QueryWrapper<>(); + wrapper.like(StringUtils.isNotBlank(modelCode), "model_code", modelCode); + wrapper.like(StringUtils.isNotBlank(modelName), "model_name", modelName); + + return wrapper; + } + + @Override + public List<StModelRunlogDTO> getLastFxLog(Integer limit) { + Map<String, Object> params = new HashMap<>(1); + params.put("runType", "separation_control"); + params.put("limit", limit == null ? 5 : limit); + return runlogDao.getLastLog(params); + } + + @Override + public List<StModelRunlogDTO> getLastJyLog(Integer limit) { + Map<String, Object> params = new HashMap<>(1); + params.put("runType", "dosing_control"); + params.put("limit", limit == null ? 5 : limit); + return runlogDao.getLastLog(params); + } + + @Override + public void cleanRunlogTask(Map<String, Date> tMap) { + runlogDao.cleanRunlogTask(tMap); + } + + @Override + public PageData<StModelRunlogDTO> queryPage(Map<String, Object> params) { + long curPage = 1; + long limit = 10; + + if(params.get(Constant.PAGE) != null){ + curPage = Long.parseLong((String)params.get(Constant.PAGE)); + } + if(params.get(Constant.LIMIT) != null){ + limit = Long.parseLong((String)params.get(Constant.LIMIT)); + } + + IPage<StModelRunlogEntity> page = baseDao.queryList(new Page<>(curPage, limit), params); + return getPageData(page, StModelRunlogDTO.class); + } + + @Override + public List<StModelRunlogDTO> listAll(Map<String, Object> params) { + return runlogDao.listAll(params); + } + + @Override + public void add(StModelRunlogDTO dto) { + StModelRunlogEntity entity = ConvertUtils.sourceToTarget(dto, StModelRunlogEntity.class); + baseDao.insert(entity); + } + + @Override + public void migrationModelRunlog(Map<String, Date> tMap) { + List<StModelRunlogEntity> list = runlogDao.selectList(getDateWrapper(tMap)); + if (CollectionUtils.isEmpty(list)){ + return; + } + runlogDao.migrationModelRunlog(list); + runlogDao.delete(getDateWrapper(tMap)); + } + + public QueryWrapper<StModelRunlogEntity> getDateWrapper(Map<String, Date> params) { + String startDate = DateUtils.format(params.get("startdate"),DateUtils.DATE_TIME_PATTERN); + String endDate = DateUtils.format(params.get("enddate"),DateUtils.DATE_TIME_PATTERN); + + QueryWrapper<StModelRunlogEntity> wrapper = new QueryWrapper<>(); + wrapper.ge(StringUtils.isNotBlank(startDate), "run_time", startDate); + wrapper.le(StringUtils.isNotBlank(endDate), "run_time", endDate); + return wrapper; + } + +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/service/impl/StModelServiceImpl.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/service/impl/StModelServiceImpl.java new file mode 100644 index 0000000..3ff5c27 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/service/impl/StModelServiceImpl.java @@ -0,0 +1,202 @@ +package com.iailab.module.mcs.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.iailab.common.enums.IsEnableEnum; +import com.iailab.framework.common.page.PageData; +import com.iailab.framework.common.service.impl.BaseServiceImpl; +import com.iailab.framework.common.util.object.ConvertUtils; +import com.iailab.common.utils.UnzipUtils; +import com.iailab.module.mcs.dao.StModelDao; +import com.iailab.module.mcs.dto.RelationLineDTO; +import com.iailab.module.mcs.dto.RelationNodeDTO; +import com.iailab.module.mcs.dto.StModelDTO; +import com.iailab.module.mcs.entity.StModelEntity; +import com.iailab.module.mcs.service.StModelService; +import org.apache.commons.lang3.StringUtils; +import org.springframework.stereotype.Service; +import org.springframework.util.CollectionUtils; +import org.springframework.web.multipart.MultipartFile; + +import java.io.File; +import java.io.IOException; +import java.util.*; +import java.util.stream.Collectors; + +/** + * @author lirm 1343021927@qq.com + * @since 1.0.0 2023-05-10 + */ +@Service +public class StModelServiceImpl extends BaseServiceImpl<StModelDao, StModelEntity> implements StModelService { + + private final String PATH_ZIP = "/zip/"; + + @Override + public PageData<StModelDTO> page(Map<String, Object> params) { + IPage<StModelEntity> page = baseDao.selectPage( + getPage(params, "create_date", false), + getWrapper(params) + ); + + return getPageData(page, StModelDTO.class); + } + + private QueryWrapper<StModelEntity> getWrapper(Map<String, Object> params) { + String modelCode = (String) params.get("modelCode"); + String modelName = (String) params.get("modelName"); + String modelType = (String) params.get("modelType"); + String isEnable = (String) params.get("isEnable"); + + QueryWrapper<StModelEntity> wrapper = new QueryWrapper<>(); + wrapper.like(StringUtils.isNotBlank(modelName), "model_name", modelName) + .like(StringUtils.isNotBlank(modelCode), "model_code", modelCode) + .eq(StringUtils.isNotBlank(modelType), "model_type", modelType) + .eq(StringUtils.isNotBlank(isEnable), "is_enable", isEnable); + return wrapper; + } + + @Override + public void save(StModelDTO dto) { + StModelEntity entity = ConvertUtils.sourceToTarget(dto, StModelEntity.class); + insert(entity); + } + + @Override + public void update(StModelDTO dto) { + StModelEntity entity = ConvertUtils.sourceToTarget(dto, StModelEntity.class); + updateById(entity); + } + + @Override + public StModelDTO get(String id) { + StModelEntity entity = baseDao.selectById(id); + + return ConvertUtils.sourceToTarget(entity, StModelDTO.class); + } + + @Override + public List<StModelDTO> getListAll(Map<String, Object> params) { + String modelLoop = (String)params.get("modelLoop"); + + QueryWrapper<StModelEntity> wrapper = new QueryWrapper<>(); + wrapper.eq("is_enable", IsEnableEnum.ENABLE.value()) + .eq(StringUtils.isNotBlank(modelLoop), "model_loop", modelLoop) + .orderByAsc("run_sort"); + + List<StModelEntity> list = baseDao.selectList(wrapper); + return ConvertUtils.sourceToTarget(list, StModelDTO.class); + } + + + @Override + public StModelDTO getByCode(String code) { + QueryWrapper<StModelEntity> wrapper = new QueryWrapper<>(); + wrapper.eq("model_code", code); + wrapper.eq("is_enable",1); + StModelEntity entity = baseDao.selectOne(wrapper); + return ConvertUtils.sourceToTarget(entity, StModelDTO.class); + } + + @Override + public void deleteByIds(String[] ids) { + baseDao.deleteBatchIds(Arrays.asList(ids)); + } + + @Override + public void enableByIds(String[] ids) { + if (CollectionUtils.isEmpty(Arrays.asList(ids))) { + return; + } + Arrays.asList(ids).forEach(item -> { + StModelEntity entity = new StModelEntity(); + entity.setId(item); + entity.setIsEnable(IsEnableEnum.ENABLE.value()); + baseDao.updateById(entity); + }); + } + + @Override + public void disableByIds(String[] ids) { + if (CollectionUtils.isEmpty(Arrays.asList(ids))) { + return; + } + Arrays.asList(ids).forEach(item -> { + StModelEntity entity = new StModelEntity(); + entity.setId(item); + entity.setIsEnable(IsEnableEnum.DISABLE.value()); + baseDao.updateById(entity); + }); + } + + @Override + public void updateTime(String id, Date runTime) { + StModelEntity entity = new StModelEntity(); + entity.setId(id); + entity.setRunTime(runTime); + baseDao.updateById(entity); + } + + @Override + public Map<String, Object> upload(MultipartFile file) throws IOException { + Map<String, Object> result = new HashMap<>(); + String modelPath = ""; + String modelStart = ""; + String uploadDir = modelPath + PATH_ZIP + file.getOriginalFilename(); + File uploadFile = new File(uploadDir); + if (!uploadFile.exists()) { + uploadFile.mkdirs(); + } + file.transferTo(new File(uploadDir)); + + // 解压 + UnzipUtils.unzipFile(uploadDir, modelPath + "/"); + result.put("path", modelPath + "/" + file.getOriginalFilename().substring(0, file.getOriginalFilename().indexOf(".")) + "/" + modelStart); + return result; + } + + @Override + public Map<String, Object> getRelation() { + Map<String, Object> result = new HashMap<>(); + List<RelationNodeDTO> nodes = new ArrayList<>(); + List<RelationLineDTO> lines = new ArrayList<>(); + List<StModelDTO> modelList = getListAll(new HashMap<>()); + if (CollectionUtils.isEmpty(modelList)) { + return result; + } + RelationNodeDTO rootNode = new RelationNodeDTO(); + rootNode.setId("root"); + rootNode.setText("模型库"); + nodes.add(rootNode); + List<String> parents = modelList.stream().map(t -> t.getModelParent()).distinct().collect(Collectors.toList()); + Map<String, List<StModelDTO>> modelGroup = modelList.stream().collect(Collectors.groupingBy(StModelDTO::getModelParent)); + for (int i = 0; i < parents.size(); i++) { + RelationNodeDTO pNode = new RelationNodeDTO(); + pNode.setId("p-" + i); + pNode.setText(parents.get(i)); + List<StModelDTO> groupList = modelGroup.get(parents.get(i)); + for (int j = 0; j < groupList.size(); j++) { + StModelDTO stModel = groupList.get(j); + RelationNodeDTO mNode = new RelationNodeDTO(); + mNode.setId(stModel.getId()); + mNode.setText(stModel.getModelName()); + mNode.setData(stModel); + nodes.add(mNode); + + RelationLineDTO mLine = new RelationLineDTO(); + mLine.setFrom(pNode.getId()); + mLine.setTo(mNode.getId()); + lines.add(mLine); + } + nodes.add(pNode); + + RelationLineDTO pLine = new RelationLineDTO(); + pLine.setFrom("root"); + pLine.setTo(pNode.getId()); + lines.add(pLine); + } + result.put("nodes", nodes); + result.put("lines", lines); + return result; + } +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/service/impl/StModelSettingServiceImpl.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/service/impl/StModelSettingServiceImpl.java new file mode 100644 index 0000000..564fdfe --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/service/impl/StModelSettingServiceImpl.java @@ -0,0 +1,79 @@ +package com.iailab.module.mcs.service.impl; + +import com.alibaba.fastjson.JSONArray; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.iailab.framework.common.service.impl.CrudServiceImpl; +import com.iailab.module.mcs.dao.StModelSettingDao; +import com.iailab.module.mcs.dto.StModelSettingDTO; +import com.iailab.module.mcs.entity.StModelSettingEntity; +import com.iailab.module.mcs.service.StModelSettingService; +import org.apache.commons.lang3.StringUtils; +import javax.annotation.Resource; +import org.springframework.stereotype.Service; +import org.springframework.util.CollectionUtils; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * @author lirm 1343021927@qq.com + * @since 1.0.0 2023-05-10 + */ +@Service +public class StModelSettingServiceImpl extends CrudServiceImpl<StModelSettingDao, StModelSettingEntity, StModelSettingDTO> + implements StModelSettingService { + + @Resource + private StModelSettingDao StModelSettingDao; + + @Override + public List<StModelSettingDTO> getAll(Map<String, Object> params) { + return StModelSettingDao.getAll(params); + } + + @Override + public QueryWrapper<StModelSettingEntity> getWrapper(Map<String, Object> params) { + String id = (String) params.get("id"); + + QueryWrapper<StModelSettingEntity> wrapper = new QueryWrapper<>(); + wrapper.eq(StringUtils.isNotBlank(id), "id", id); + + return wrapper; + } + + @Override + public void deleteByModelId(String modelId) { + StModelSettingDao.deleteByModelId(modelId); + } + + @Override + public Map<String, Object> getByModelId(String modelId) { + Map<String, Object> result = new HashMap<>(); + List<StModelSettingEntity> list = baseDao.selectList(new QueryWrapper<StModelSettingEntity>().eq("model_id", modelId)); + if (!CollectionUtils.isEmpty(list)) { + list.forEach(item -> { + if ("int".equals(item.getValueType())) { + int value = Integer.parseInt(item.getSettingValue()); + result.put(item.getSettingKey(), value); + } else if ("double".equals(item.getValueType())) { + double value = Double.parseDouble(item.getSettingValue()); + result.put(item.getSettingKey(), value); + } else if ("string".equals(item.getValueType())) { + String value = item.getSettingValue(); + result.put(item.getSettingKey(), value); + } else if ("decimalArray".equals(item.getValueType())) { + JSONArray valueArray = JSONArray.parseArray(item.getSettingValue()); + double[] value = new double[valueArray.size()]; + for(int i = 0; i < valueArray.size(); i ++) { + value[i] = Double.parseDouble(valueArray.get(i).toString()); + } + } else { + result.put(item.getSettingKey(), item.getSettingValue()); + } + }); + } + return result; + } + +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/IAILModel.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/IAILModel.java new file mode 100644 index 0000000..668dafd --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/IAILModel.java @@ -0,0 +1,147 @@ +package com.iailab.module.model; + +import java.io.Serializable; +import java.util.List; +import java.util.Map; + +public class IAILModel implements Serializable { + private static final long serialVersionUID = -4537530431274769332L; + private String className; + private String methodName; + private Class<?>[] paramsArray; + private String resultKey; + private String filePath; + private Map dataMap; + private Map settingConfigMap; + private Map loadSettingMap; + private List<String> paramNameList; + private List<String> paramPathList; + private List<String> fileBase64List; + private String version; + private String info1; + private String info2; + private String info3; + + public IAILModel() { + } + + public String getFilePath() { + return this.filePath; + } + + public void setFilePath(String filePath) { + this.filePath = filePath; + } + + public Map getDataMap() { + return this.dataMap; + } + + public void setDataMap(Map dataMap) { + this.dataMap = dataMap; + } + + public Map getSettingConfigMap() { + return this.settingConfigMap; + } + + public void setSettingConfigMap(Map settingConfigMap) { + this.settingConfigMap = settingConfigMap; + } + + public Map getLoadSettingMap() { + return this.loadSettingMap; + } + + public void setLoadSettingMap(Map loadSettingMap) { + this.loadSettingMap = loadSettingMap; + } + + public List<String> getParamNameList() { + return this.paramNameList; + } + + public void setParamNameList(List<String> paramNameList) { + this.paramNameList = paramNameList; + } + + public List<String> getParamPathList() { + return this.paramPathList; + } + + public void setParamPathList(List<String> paramPathList) { + this.paramPathList = paramPathList; + } + + public List<String> getFileBase64List() { + return this.fileBase64List; + } + + public void setFileBase64List(List<String> fileBase64List) { + this.fileBase64List = fileBase64List; + } + + public String getClassName() { + return this.className; + } + + public void setClassName(String className) { + this.className = className; + } + + public String getMethodName() { + return this.methodName; + } + + public void setMethodName(String methodName) { + this.methodName = methodName; + } + + public Class<?>[] getParamsArray() { + return this.paramsArray; + } + + public void setParamsArray(Class<?>[] paramsArray) { + this.paramsArray = paramsArray; + } + + public String getResultKey() { + return this.resultKey; + } + + public void setResultKey(String resultKey) { + this.resultKey = resultKey; + } + + public String getVersion() { + return this.version; + } + + public void setVersion(String version) { + this.version = version; + } + + public String getInfo1() { + return this.info1; + } + + public void setInfo1(String info1) { + this.info1 = info1; + } + + public String getInfo2() { + return this.info2; + } + + public void setInfo2(String info2) { + this.info2 = info2; + } + + public String getInfo3() { + return this.info3; + } + + public void setInfo3(String info3) { + this.info3 = info3; + } +} diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/api/ApiModelController.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/api/ApiModelController.java new file mode 100644 index 0000000..9c37943 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/api/ApiModelController.java @@ -0,0 +1,167 @@ +package com.iailab.module.model.api; + +import com.iailab.common.utils.DateUtils; + +import com.iailab.framework.common.pojo.CommonResult; +import com.iailab.module.data.api.IFeignDataApi; +import com.iailab.module.mcs.service.StModelResultService; +import com.iailab.module.model.dto.RunSetDTO; +import com.iailab.module.model.handler.ModelHandler; +import io.swagger.v3.oas.annotations.tags.Tag; +import org.apache.commons.lang3.StringUtils; +import javax.annotation.Resource; +import org.springframework.util.CollectionUtils; +import org.springframework.web.bind.annotation.*; + +import java.util.*; + +/** + * scada接口数据 + * + * @author lirm + * @date 2024/4/9 + * @since 1.0 + */ +@RestController +@RequestMapping("api/model") +@Tag(name = "数据接口") +public class ApiModelController { + + @Resource + private IFeignDataApi iFeignDataApi; + + @Resource + private StModelResultService stModelResultService; + + @Resource + private ModelHandler modelHandler; + + private static String mFx1315SwitchInName = "1315/1给定"; + private static String mFx1308SwitchInName = "1308/1给定"; + private static String mFx1301AshInName = "1308/1给定"; + + + @PostMapping("execute") + public CommonResult execute(@RequestParam Map<String, Object> params, @RequestBody List<double[][]> sampleDataList) { + Map<String, Object> result = new HashMap<>(); + try { + String appKey = "admin"; + String modelCode = (String)params.get("modelCode"); + if (StringUtils.isBlank(modelCode)) { + return new CommonResult().setMsg("modelCode不能为空!"); + } + if (CollectionUtils.isEmpty(sampleDataList)) { + return new CommonResult().setMsg("参数不能为空!"); + } + Calendar calendar = Calendar.getInstance(); + calendar.set(Calendar.MILLISECOND, 0); + result = modelHandler.run(modelCode, calendar.getTime(), sampleDataList, appKey); + return new CommonResult<Map<String, Object>>().setData(result); + } catch (Exception ex) { + return new CommonResult().setMsg(ex.getMessage()); + } + } + + @PostMapping("run") + public CommonResult run(@RequestParam Map<String, Object> params, @RequestBody List<double[][]> sampleDataList) { + Map<String, Object> result = new HashMap<>(); + try { + String modelCode = (String)params.get("modelCode"); + if (StringUtils.isBlank(modelCode)) { + return new CommonResult().setMsg("modelCode不能为空!"); + } + if (CollectionUtils.isEmpty(sampleDataList)) { + return new CommonResult().setMsg("参数不能为空!"); + } + Calendar calendar = Calendar.getInstance(); + calendar.set(Calendar.MILLISECOND, 0); + result = modelHandler.run(modelCode, sampleDataList); + return new CommonResult<Map<String, Object>>().setData(result); + } catch (Exception ex) { + return new CommonResult().setMsg(ex.getMessage()); + } + } + + @PostMapping("run-set") + public CommonResult runSet(@RequestParam Map<String, Object> params, @RequestBody RunSetDTO dto) { + Map<String, Object> result = new HashMap<>(); + try { + List<double[][]> sampleDataList = dto.getDataList(); + String modelCode = (String)params.get("modelCode"); + if (StringUtils.isBlank(modelCode)) { + return new CommonResult().setMsg("modelCode不能为空!"); + } + if (CollectionUtils.isEmpty(sampleDataList)) { + return new CommonResult().setMsg("参数不能为空!"); + } + Calendar calendar = Calendar.getInstance(); + calendar.set(Calendar.MILLISECOND, 0); + result = modelHandler.run(modelCode, sampleDataList, dto.getSettings()); + return new CommonResult<Map<String, Object>>().setData(result); + } catch (Exception ex) { + return new CommonResult().setMsg(ex.getMessage()); + } + } + + @GetMapping("model-result/{modelCode}") + public CommonResult<Map<String, Object>> getResultByModelCode(@PathVariable("modelCode") String modelCode) { + Map<String, Object> data = new HashMap<>(); + Map<String, Object> modelParams = new HashMap<>(1); + try { + modelParams.put("modelCode", modelCode); + data = stModelResultService.getLastResultMap(modelParams); + if (CollectionUtils.isEmpty(data)) { + return new CommonResult<>(); + } + } catch (Exception ex) { + ex.printStackTrace(); + } + return new CommonResult<Map<String, Object>>().setData(data); + } + + @GetMapping("model-date-result") + public CommonResult<Map<String, Object>> getTimeResult(@RequestParam Map<String, Object> params) { + Map<String, Object> data = new HashMap<>(); + try { + data = stModelResultService.getResultByCodeDate(params); + if (CollectionUtils.isEmpty(data)) { + return new CommonResult<>(); + } + } catch (Exception ex) { + ex.printStackTrace(); + } + return new CommonResult<Map<String, Object>>().setData(data); + } + + @GetMapping("model-result/list") + public CommonResult<List<Map<String, Object>>> geModelResultList(@RequestParam Map<String, Object> params) { + Calendar calendar = Calendar.getInstance(); + calendar.set(Calendar.MILLISECOND, 0); + calendar.set(Calendar.SECOND, 0); + if (params.get("lastHour") != null) { + calendar.add(Calendar.HOUR_OF_DAY, Integer.parseInt(params.get("lastHour").toString()) * -1); + } + Date startDate = calendar.getTime(); + Date endDate = new Date(); + + if ((params.get("startDate") != null && StringUtils.isNotBlank(params.get("startDate").toString()))) { + String ts = params.get("startDate").toString(); + if (ts.length() < 12) { + ts = ts + " 00:00:00"; + } + startDate = DateUtils.parse(ts, DateUtils.DATE_TIME_PATTERN); + } + if ((params.get("endDate") != null && StringUtils.isNotBlank(params.get("endDate").toString()))) { + String ts = params.get("endDate").toString(); + if (ts.length() < 12) { + ts = ts + " 23:59:59"; + } + endDate = DateUtils.parse(ts, DateUtils.DATE_TIME_PATTERN); + } + + params.put("startDate", startDate); + params.put("endDate", endDate); + List<Map<String, Object>> list = stModelResultService.getList(params); + return new CommonResult<List<Map<String, Object>>>().setData(list); + } +} diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/command/MLCommand.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/command/MLCommand.java new file mode 100644 index 0000000..2473047 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/command/MLCommand.java @@ -0,0 +1,41 @@ +package com.iailab.module.model.command; + +import com.iailab.module.mcs.dto.StModelDTO; +import com.iailab.module.model.sample.dto.SampleData; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +import java.util.List; +import java.util.Map; + +/** + * @author PanZhibao + * @Description + * @createTime 2023年05月17日 11:50:00 + */ +@Slf4j +@Component +public class MLCommand { + + public Object[] getCommand(StModelDTO stModel, List<Object> params, Map<String, Object> settings, List<SampleData> sampleDataList) { + + int portLength = sampleDataList.size(); + Object[] paramValues = new Object[portLength + 1]; + for (int i = 0; i < portLength; i++) { + paramValues[i] = sampleDataList.get(i).getMatrix(); + } + paramValues[portLength] = settings; + return paramValues; + } + + public Object[] getCommand1(StModelDTO stModel, List<Object> params, Map<String, Object> settings, List<double[][]> sampleDataList) { + + int portLength = sampleDataList.size(); + Object[] paramValues = new Object[portLength + 1]; + for (int i = 0; i < portLength; i++) { + paramValues[i] = sampleDataList.get(i); + } + paramValues[portLength] = settings; + return paramValues; + } +} diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/command/PyCommand.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/command/PyCommand.java new file mode 100644 index 0000000..9d65e7a --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/command/PyCommand.java @@ -0,0 +1,31 @@ +package com.iailab.module.model.command; + +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.iailab.module.mcs.dto.StModelDTO; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +import java.util.List; +import java.util.Map; + +/** + * @author PanZhibao + * @Description + * @createTime 2023年05月17日 11:50:00 + */ +@Slf4j +@Component +public class PyCommand { + + public String[] getCommand(StModelDTO stModel, List<Object> params, Map<String, Object> settings) { + String[] command = new String[2 + params.size() + 1]; + command[0] = "python"; + command[1] = stModel.getModelPath(); + for (int i = 0; i < params.size(); i++) { + command[2 + i] = JSONArray.toJSONString(params.get(i)); + } + command[command.length - 1] = JSONObject.toJSONString(settings).replace("\"", "'"); + return command; + } +} diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/dto/RunSetDTO.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/dto/RunSetDTO.java new file mode 100644 index 0000000..919caf0 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/dto/RunSetDTO.java @@ -0,0 +1,22 @@ +package com.iailab.module.model.dto; + +import lombok.Data; + +import java.io.Serializable; +import java.util.List; +import java.util.Map; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年06月15日 + */ +@Data +public class RunSetDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + List<double[][]> dataList; + + private Map<String, Object> settings; +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/entity/ModelEntity.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/entity/ModelEntity.java new file mode 100644 index 0000000..da4647e --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/entity/ModelEntity.java @@ -0,0 +1,122 @@ +package com.iailab.module.model.entity; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.math.BigDecimal; + +/** + * 模型实体 + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +@Builder +public class ModelEntity { + /** + * 模型ID + */ + private String id; + + /** + * 模型编号 + */ + private String modelNo; + + /** + * 模型名称 + */ + private String modelName; + + /** + * 预测项ID + */ + private String itemId; + + /** + * 算法ID + */ + private String arithId; + + /** + * 训练样本长度 + */ + private Integer trainSampleLength; + + /** + * 预测样本长度 + */ + private Integer predictSampleLength; + + /** + * 是否在线训练 + */ + private Integer isOnlineTrain; + + /** + * 模型路径 + */ + private String modelPath; + + /** + * 是否归一化 + */ + private Integer isNormal; + + /** + * 归一化后的最大值 + */ + private Double normalMax; + + /** + * 归一化后的最小值 + */ + private Double normalMin; + + /** + * 是否参与预测 + */ + private Integer status; + + /** + * 类名称 + */ + private String className; + + /** + * 方法名称 + */ + private String methodName; + + /** + * 模型构造器 + */ + private String modelParamStructure; + + /** + * 结果ID + */ + private String resultstrid; + + /** + * settingMap + */ + private String settingMap; + + /** + * 训练模型路径 + */ + private String trainModelPath; + + /** + * 模型路径状态(1:需要更换,0:不需要更换) + */ + private BigDecimal pathStatus; + + /** + * 预测阶段需要输入的数据长度 + */ + private Integer pdim; +} diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/enums/ModelResultEnum.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/enums/ModelResultEnum.java new file mode 100644 index 0000000..bc47ea4 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/enums/ModelResultEnum.java @@ -0,0 +1,39 @@ +package com.iailab.module.model.enums; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +/** + * @author PanZhibao + * @Description + * @createTime 2023年11月26日 10:17:00 + */ +@Getter +@AllArgsConstructor +public enum ModelResultEnum { + OK(200, "正常", ""), + BAD(401, "输入值非法", ""), + HJTW(402, "合介桶位异常,请切回手动控制", "Result402"), + XJTW(403, "稀介桶位异常,请切回手动控制", "Result403"), + HJMD(404, "合介密度异常,请切回手动控制", "Result404"), + JMHF(405, "精煤灰分异常,请切回手动控制", "Result405"), + YLND(406, "溢流浊度异常,请切回手动控制", "Result406"), + DLND(407, "底流浓度异常,请切回手动控制", "Result407"), + QSWG(408, "清水位高度异常,请切回手动控制", "Result408"); + private Integer code; + private String desc; + private String point; + + public static ModelResultEnum getEumByCode(Integer code) { + if (code == null) { + return null; + } + + for (ModelResultEnum statusEnum : ModelResultEnum.values()) { + if (statusEnum.getCode().equals(code)) { + return statusEnum; + } + } + return null; + } +} diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/handler/ModelHandler.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/handler/ModelHandler.java new file mode 100644 index 0000000..45d95df --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/handler/ModelHandler.java @@ -0,0 +1,360 @@ +package com.iailab.module.model.handler; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.iailab.common.utils.PythonUtil; +import com.iailab.module.mcs.dto.StModelDTO; +import com.iailab.module.mcs.dto.StModelRequestLogDTO; +import com.iailab.module.mcs.dto.StModelRunlogDTO; +import com.iailab.module.mcs.service.*; +import com.iailab.module.model.IAILModel; +import com.iailab.module.model.command.MLCommand; +import com.iailab.module.model.command.PyCommand; +import com.iailab.module.model.sample.constructor.SampleConstructor; +import com.iailab.module.model.sample.dto.SampleData; +import lombok.extern.slf4j.Slf4j; +import javax.annotation.Resource; +import org.springframework.stereotype.Component; +import org.springframework.util.CollectionUtils; + +import java.util.*; + +/** + * 浮选模型处理 + * + * @author PanZhibao + * @Description + * @createTime 2023年05月16日 13:33:00 + */ +@Slf4j +@Component +public class ModelHandler { + + @Resource + private PyCommand pyCommand; + + @Resource + private MLCommand mLCommand; + + @Resource + private StModelService stModelService; + + @Resource + private StModelSettingService stModelSettingService; + + @Resource + private StModelRunlogService runlogService; + + @Resource + private StModelResultService stModelResultService; + + @Resource + private SampleConstructor sampleConstructor; + + @Resource + private StModelRequestLogService stModelRequestLogService; + + /** + * 运行模型 + * + * @param modelCode + * @param runTime + * @return + * @throws Exception + */ + public Map<String, Object> run(String modelCode, Date runTime) throws Exception { + Map<String, Object> result = new HashMap<>(); + Calendar calendar = Calendar.getInstance(); + calendar.setTime(runTime); + calendar.set(Calendar.SECOND, 0); + Date dataTime = calendar.getTime(); + try { + // 1、查找模型 + StModelDTO stModel = stModelService.getByCode(modelCode); + if (stModel == null) { + throw new Exception("modelCode错误!"); + } + + // 2、构建输入参数 + List<SampleData> sampleDataList = sampleConstructor.constructSample(stModel.getId(), dataTime); + List<Object> params = new ArrayList<>(); + if (!CollectionUtils.isEmpty(sampleDataList)) { + sampleDataList.forEach(item -> { + params.add(item.getMatrix()); + }); + } + + // 3、构建配置参数 + Map<String, Object> settings = stModelSettingService.getByModelId(stModel.getId()); + + // 4、执行算法 + log.info("################ modelCode=" + modelCode + " ###################"); + String[] command = pyCommand.getCommand(stModel, params, settings); + log.info("command=" + JSONArray.toJSONString(command)); + result = PythonUtil.execPy(command); + log.info("result=" + JSON.toJSONString(result)); + stModelResultService.addML(stModel.getId(), result, runTime); + stModelService.updateTime(stModel.getId(), runTime); + + // 6、插入运行日志 + String jsonString = dealResult(result); + this.addLog(stModel.getId(), modelCode, runTime, jsonString); + } catch (Exception ex) { + ex.printStackTrace(); + throw ex; + } + return result; + } + + public String dealResult(Map<String, Object> result) { + ObjectMapper mapper = new ObjectMapper(); + String jsonString = ""; + try { + jsonString = mapper.writeValueAsString(result); + jsonString = jsonString.replace("mv_fl_kd_307", "307分流阀开度"); + jsonString = jsonString.replace("mv_hj_water_valve_main_307", "315合介桶加水阀开度"); + jsonString = jsonString.replace("mv_xj_water_valve_307", "333稀介桶加水阀开度"); + jsonString = jsonString.replace("mv_hj_water_valve_small_307", "315合介桶密度微调阀开度"); + jsonString = jsonString.replace("mv_mn_water_valve_307", "325煤泥桶加水阀开度"); + + jsonString = jsonString.replace("mv_fl_kd_308", "308分流阀开度"); + jsonString = jsonString.replace("mv_hj_water_valve_main_308", "316合介桶加水阀开度"); + jsonString = jsonString.replace("mv_xj_water_valve_308", "332稀介桶加水阀开度"); + jsonString = jsonString.replace("mv_hj_water_valve_small_308", "316合介桶密度微调阀开度"); + jsonString = jsonString.replace("mv_mn_water_valve_308", "325煤泥桶加水阀开度"); + + jsonString = jsonString.replace("mv_valve_fl_3318", "3318分流阀开度"); + jsonString = jsonString.replace("mv_pump_hl_3318", "3308混料桶排水泵频率"); + jsonString = jsonString.replace("mv_pump_hj_3318", "3344合介桶排水泵频率"); + jsonString = jsonString.replace("mv_valve_hj_water_3318", "3344合介桶加水阀开度"); + jsonString = jsonString.replace("mv_valve_jj_3318", "3344合介桶加介阀开度"); + jsonString = jsonString.replace("mv_valve_xj_water_3318", "3348稀介桶加水阀开度"); + jsonString = jsonString.replace("mv_pump_xj_3318", "3348稀介桶排水泵频率"); + jsonString = jsonString.replace("mv_pump_mn_3318", "4402煤泥桶排水泵频率"); + jsonString = jsonString.replace("mv_valve_mn_water_3318", "4402煤泥桶加水阀开度"); + jsonString = jsonString.replace("target_md_3318", "3318目标合介密度"); + + + jsonString = jsonString.replace("mv_valve_fl_3319", "3319分流阀开度"); + jsonString = jsonString.replace("mv_pump_hl_3319", "3317混料桶排水泵频率"); + jsonString = jsonString.replace("mv_pump_hj_3319", "3345合介桶排水泵频率"); + jsonString = jsonString.replace("mv_valve_hj_water_3319", "3345合介桶加水阀开度"); + jsonString = jsonString.replace("mv_valve_jj_3319", "3345合介桶加介阀开度"); + jsonString = jsonString.replace("mv_valve_xj_water_3319", "3349稀介桶加水阀开度"); + jsonString = jsonString.replace("mv_pump_xj_3319", "3349稀介桶排水泵频率"); + jsonString = jsonString.replace("mv_pump_mn_3319", "4403煤泥桶排水泵频率"); + jsonString = jsonString.replace("mv_valve_mn_water_3319", "4403煤泥桶加水阀开度"); + jsonString = jsonString.replace("target_md_3319", "3319目标合介密度"); + + jsonString = jsonString.replace("status_first_start", "第一组风机启动信号"); + jsonString = jsonString.replace("status_first_stop", "第一组风机停止信号"); + jsonString = jsonString.replace("status_second_start", "第二组风机启动信号"); + jsonString = jsonString.replace("status_second_stop", "第二组风机停止信号"); + jsonString = jsonString.replace("mv_1_346", "346高压风机频率设定"); + jsonString = jsonString.replace("mv_1_347", "347高压风机频率设定"); + jsonString = jsonString.replace("mv_2_4454", "4454高压风机频率设定"); + + jsonString = jsonString.replace("Thickener_OF_XL", "501 浓缩池循环水池浊度预测值"); + jsonString = jsonString.replace("Thickener_BF_XL", "501浓缩池出料浓度预测值"); + jsonString = jsonString.replace("Thickener_H_XL", "501浓缩池污泥厚度预测值"); + jsonString = jsonString.replace("Dos_yin_det1_XL", "507_1加药泵频率"); + jsonString = jsonString.replace("Dos_yang_det1_XL", "508_1加药泵频率"); + jsonString = jsonString.replace("Dos_yin_det2_XL", "507_2加药泵频率"); + jsonString = jsonString.replace("Dos_yang_det2_XL", "508_2加药泵频率"); + + jsonString = jsonString.replace("Thickener_OF_QC", "浓缩池循环水池浊度预测值"); + jsonString = jsonString.replace("Thickener_BF_QC", "浓缩池出料浓度预测值"); + jsonString = jsonString.replace("Thickener_H_QC", "浓缩池污泥厚度预测值"); + jsonString = jsonString.replace("Dos_yin_det_QC", "350加药系统频率"); + jsonString = jsonString.replace("Dos_yang_det_QC", "351加药系统频率"); + + jsonString = jsonString.replace("UF_pumb1", "503底流泵启停"); + jsonString = jsonString.replace("UF_pumb2", "502底流泵启停"); + jsonString = jsonString.replace("zt4418_res", "4418启停信号"); + jsonString = jsonString.replace("zt4419_res", "4419启停信号"); + jsonString = jsonString.replace("zt4420_res", "4420启停信号"); + jsonString = jsonString.replace("zt4421_res", "4421启停信号"); + jsonString = jsonString.replace("zt4422_res", "4422启停信号"); + jsonString = jsonString.replace("zt4428_res", "4428启停信号"); + jsonString = jsonString.replace("zt4429_res", "4429启停信号"); + jsonString = jsonString.replace("zt4430_res", "4430启停信号"); + jsonString = jsonString.replace("zt4431_res", "4431启停信号"); + jsonString = jsonString.replace("zt4432_res", "4432启停信号"); + + + } catch (JsonProcessingException e) { + e.printStackTrace(); + } + return jsonString; + } + + /** + * 调用模型 + * + * @param modelCode + * @param runTime + * @param sampleDataList + * @param appKey + * @return + * @throws Exception + */ + public Map<String, Object> run(String modelCode, Date runTime, List<double[][]> sampleDataList, String appKey) throws Exception { + Map<String, Object> result = new HashMap<>(); + try { + // 1、查找模型 + StModelDTO stModel = stModelService.getByCode(modelCode); + if (stModel == null) { + throw new Exception("modelCode错误!"); + } + + // 2、构建输入参数 + List<Object> params = new ArrayList<>(); + if (!CollectionUtils.isEmpty(sampleDataList)) { + sampleDataList.forEach(item -> { + params.add(item); + }); + } + + // 3、构建配置参数 + Map<String, Object> settings = stModelSettingService.getByModelId(stModel.getId()); + + // 4、执行算法 + log.info("################ modelCode=" + modelCode + " ###################"); + String[] command = pyCommand.getCommand(stModel, params, settings); + log.info("command=" + JSONArray.toJSONString(command)); + result = PythonUtil.execPy(command); + log.info("result=" + JSON.toJSONString(result)); + + // 5、插入调用日志 + StModelRequestLogDTO logDto = new StModelRequestLogDTO(); + logDto.setModelId(stModel.getId()); + logDto.setAppKey(appKey); + logDto.setRequestTime(runTime); + logDto.setRequestParams(JSONArray.toJSONString(sampleDataList)); + logDto.setResponseResult(JSONObject.toJSONString(result)); + stModelRequestLogService.save(logDto); + } catch (Exception ex) { + ex.printStackTrace(); + throw ex; + } + return result; + } + + /** + * 调用模型 + * + * @param modelCode + * @param sampleDataList + * @return + * @throws Exception + */ + public Map<String, Object> run(String modelCode, List<double[][]> sampleDataList) throws Exception { + Map<String, Object> result = new HashMap<>(); + try { + // 1、查找模型 + StModelDTO stModel = stModelService.getByCode(modelCode); + if (stModel == null) { + throw new Exception("modelCode错误!"); + } + + // 2、构建输入参数 + List<Object> params = new ArrayList<>(); + if (!CollectionUtils.isEmpty(sampleDataList)) { + sampleDataList.forEach(item -> { + params.add(item); + }); + } + + // 3、构建配置参数 + Map<String, Object> settings = stModelSettingService.getByModelId(stModel.getId()); + + // 4、执行算法 + log.info("################ modelCode=" + modelCode + " ###################"); + String[] command = pyCommand.getCommand(stModel, params, settings); + log.info("command=" + JSONArray.toJSONString(command)); + result = PythonUtil.execPy(command); + log.info("result=" + JSON.toJSONString(result)); + + } catch (Exception ex) { + ex.printStackTrace(); + throw ex; + } + return result; + } + + /** + * 调用模型 + * + * @param modelCode + * @param sampleDataList + * @param settings + * @return + * @throws Exception + */ + public Map<String, Object> run(String modelCode, List<double[][]> sampleDataList, Map<String, Object> settings) throws Exception { + Map<String, Object> result = new HashMap<>(); + try { + // 1、查找模型 + StModelDTO stModel = stModelService.getByCode(modelCode); + if (stModel == null) { + throw new Exception("modelCode错误!"); + } + + // 2、构建输入参数 + List<Object> params = new ArrayList<>(); + if (!CollectionUtils.isEmpty(sampleDataList)) { + sampleDataList.forEach(item -> { + params.add(item); + }); + } + + // 4、执行算法 + log.info("################ modelCode=" + modelCode + " ###################"); + String[] command = pyCommand.getCommand(stModel, params, settings); + log.info("command=" + JSONArray.toJSONString(command)); + result = PythonUtil.execPy(command); + log.info("result=" + JSON.toJSONString(result)); + + } catch (Exception ex) { + ex.printStackTrace(); + throw ex; + } + return result; + } + + /** + * 构造IAILMDK.run()方法的newModelBean参数 + * + * @param stModel + * @return + */ + private IAILModel composeNewModelBean(StModelDTO stModel) { + IAILModel newModelBean = new IAILModel(); + newModelBean.setClassName(stModel.getClassName().trim()); + newModelBean.setMethodName(stModel.getMethodName().trim()); + //构造参数类型 + String[] paArStr = stModel.getParamsStructure().trim().split(","); + Class<?>[] paramsArray = new Class[paArStr.length]; + for (int i = 0; i < paArStr.length; i++) { + if ("[[D".equals(paArStr[i])) { + paramsArray[i] = double[][].class; + } else if ("Map".equals(paArStr[i]) || "java.util.HashMap".equals(paArStr[i])) { + paramsArray[i] = HashMap.class; + } + } + newModelBean.setParamsArray(paramsArray); + return newModelBean; + } + + public void addLog(String modelId, String modelCode, Date runTime, String jsonString) { + StModelRunlogDTO logDto = new StModelRunlogDTO(); + logDto.setModelid(modelId); + logDto.setRunTime(runTime); + logDto.setRunType(modelCode); + logDto.setRunResult(jsonString); + runlogService.add(logDto); + } +} diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/sample/constructor/SampleConstructor.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/sample/constructor/SampleConstructor.java new file mode 100644 index 0000000..32f2e68 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/sample/constructor/SampleConstructor.java @@ -0,0 +1,42 @@ +package com.iailab.module.model.sample.constructor; + + +import com.iailab.module.model.sample.dto.SampleData; +import com.iailab.module.model.sample.dto.SampleInfo; +import lombok.extern.slf4j.Slf4j; +import javax.annotation.Resource; +import org.springframework.stereotype.Component; + +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +/** + * 样本构造 + * + * @author PanZhibao + * @Description + * @createTime 2023年05月16日 15:17:00 + */ +@Slf4j +@Component +public class SampleConstructor { + + @Resource + private SampleInfoConstructor sampleInfoConstructor; + + @Resource + private SampleDataConstructor sampleDataConstructor; + + public List<SampleData> constructSample(String modelId, Date runTime) { + List<SampleData> list = new ArrayList<>(); + try { + SampleInfo sampleInfo = sampleInfoConstructor.prepareSampleInfo(modelId, runTime); + list = sampleDataConstructor.prepareSampleData(sampleInfo); + } catch (Exception ex) { + ex.printStackTrace(); + log.error("constructSample:" + ex.getMessage()); + } + return list; + } +} diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/sample/constructor/SampleDataConstructor.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/sample/constructor/SampleDataConstructor.java new file mode 100644 index 0000000..4d64df2 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/sample/constructor/SampleDataConstructor.java @@ -0,0 +1,293 @@ +package com.iailab.module.model.sample.constructor; +import com.iailab.module.data.dto.ApiDataDTO; +import com.iailab.module.data.api.IFeignDataApi; +import com.iailab.module.data.dto.ApiDataPointDTO; +import com.iailab.module.data.dto.FeignQueryPointDTO; +import com.iailab.module.device.service.DeviceMainService; +import com.iailab.module.event.service.EventInfoService; +import com.iailab.module.mcs.service.StModelResultService; +import com.iailab.module.model.sample.dto.ColumnItem; +import com.iailab.module.model.sample.dto.ColumnItemPort; +import com.iailab.module.model.sample.dto.SampleData; +import com.iailab.module.model.sample.dto.SampleInfo; +import com.iailab.module.model.sample.entity.DataEntity; +import com.iailab.module.prod.service.IndexEvaluateSystemService; +import lombok.extern.slf4j.Slf4j; +import javax.annotation.Resource; +import org.springframework.stereotype.Component; +import org.springframework.util.CollectionUtils; + +import java.sql.Timestamp; +import java.util.*; +import java.util.stream.Collectors; + +/** + * @author PanZhibao + * @Description + * @createTime 2023年05月16日 16:24:00 + */ +@Slf4j +@Component +public class SampleDataConstructor { + + @Resource + private IFeignDataApi iFeignDataApi; + + @Resource + private StModelResultService modelResultService; + + @Resource + private EventInfoService eventInfoService; + + @Resource + private DeviceMainService deviceMainService; + + @Resource + private IndexEvaluateSystemService indexEvaluateSystemService; + + @Resource + private IFeignDataApi feignDataController; + + public List<SampleData> prepareSampleData(SampleInfo sampleInfo) { + List<SampleData> sampleDataList = new ArrayList<>(); + for (ColumnItemPort entry : sampleInfo.getColumnInfo()) { + double[][] matrix = new double[entry.getDataLength()][entry.getColumnItemList().size()]; + for (int i = 0; i < entry.getColumnItemList().size(); i++) { + ColumnItem columnItem = entry.getColumnItemList().get(i); + List<DataEntity> dataEntityList = getColumnData(columnItem); + + //补全数据 + dataEntityList = completionData(matrix.length, dataEntityList, columnItem.startTime, columnItem.endTime, columnItem.paramId); + + if (CollectionUtils.isEmpty(dataEntityList)) { + continue; + } + for (int k = 0; k < entry.getDataLength(); k++) { + matrix[k][i] = dataEntityList.get(k).getDataValue(); + } + } + SampleData sampleData = new SampleData(); + sampleData.setMatrix(matrix); + sampleDataList.add(sampleData); + } + return sampleDataList; + } + + public List<DataEntity> getColumnData(ColumnItem columnItem) { + List<DataEntity> dataEntityList = new ArrayList<>(); + switch (columnItem.getParamType()) { + case "predict": + // 预测值 + dataEntityList = modelResultService.getValueList(columnItem.getParamId(), columnItem.startTime, columnItem.endTime) + .stream().collect(Collectors.toList()); + break; + case "point": + // 测点值 + FeignQueryPointDTO dto = new FeignQueryPointDTO(); + dto.setEndTime(columnItem.endTime); + dto.setStartTime(columnItem.startTime); + dto.setPointCode(columnItem.getParamId()); + List<ApiDataDTO> pointValues = iFeignDataApi.queryPointValues(dto); + + List<DataEntity> tempList = new ArrayList<>(); + pointValues.forEach(item -> { + DataEntity dataEntity = new DataEntity(); + dataEntity.setDataValue(item.getDataValue()); + dataEntity.setTimeStamp(item.getTimeStamp()); + tempList.add(dataEntity); + }); + dataEntityList = tempList; + break; + case "wz": + FeignQueryPointDTO queryTag = new FeignQueryPointDTO(); + queryTag.setEndTime(columnItem.endTime); + queryTag.setStartTime(columnItem.startTime); + queryTag.setPointCode(columnItem.getParamId()); + List<ApiDataDTO> tagValues = iFeignDataApi.querySimTagValues(queryTag); + + List<DataEntity> tempListTag = new ArrayList<>(); + tagValues.forEach(item -> { + DataEntity dataEntity = new DataEntity(); + dataEntity.setDataValue(item.getDataValue()); + dataEntity.setTimeStamp(item.getTimeStamp()); + tempListTag.add(dataEntity); + }); + dataEntityList = tempListTag; + break; + case "real": + // 实时值 + List<String> pointNos = new ArrayList<>(); + pointNos.add(columnItem.getParamId()); + Map<String, Object> data = iFeignDataApi.getCurrentValue(pointNos); + DataEntity realData = new DataEntity(); + realData.setTimeStamp(new Date()); + realData.setDataValue(Double.parseDouble(data.get(columnItem.getParamId()).toString())); + dataEntityList.add(realData); + break; + case "ind": + // 指标数据 + FeignQueryPointDTO dto1 = new FeignQueryPointDTO(); + dto1.setEndTime(columnItem.endTime); + dto1.setStartTime(columnItem.startTime); + dto1.setPointCode(columnItem.getParamId()); + List<ApiDataDTO> indItemValues = iFeignDataApi.queryIndItemValues(dto1); + List<DataEntity> tempList1 = new ArrayList<>(); + indItemValues.forEach(item -> { + DataEntity dataEntity = new DataEntity(); + dataEntity.setDataValue(item.getDataValue()); + dataEntity.setTimeStamp(item.getTimeStamp()); + tempList1.add(dataEntity); + }); + dataEntityList = tempList1; + break; + case "device-main": + // 检修记录 + Integer mainTimes = deviceMainService.getCount(columnItem.getParamId(), columnItem.startTime, columnItem.endTime); + DataEntity mainData = new DataEntity(); + mainData.setTimeStamp(columnItem.endTime); + mainData.setDataValue(mainTimes.doubleValue()); + dataEntityList.add(mainData); + break; + case "event": + // 报警事件 + Long eventTimes = eventInfoService.getCount(columnItem.getParamId(), columnItem.startTime, columnItem.endTime); + DataEntity eventData = new DataEntity(); + eventData.setTimeStamp(columnItem.endTime); + eventData.setDataValue(eventTimes.doubleValue()); + dataEntityList.add(eventData); + break; + case "evaluate_weight": + // 指标权重 + List<Double> weightList = indexEvaluateSystemService.getWeight(); + List<DataEntity> weightDataList = new ArrayList<>(); + weightList.forEach(item -> { + DataEntity weightData = new DataEntity(); + weightData.setTimeStamp(columnItem.endTime); + weightData.setDataValue(item); + weightDataList.add(weightData); + }); + dataEntityList = weightDataList; + break; + default: + break; + } + return dataEntityList; + } + + /** + * 补全数据 + * + * @param length + * @param dataEntityList + * @param startTime + * @param endTime + * @return + */ + public List<DataEntity> completionData(int length, List<DataEntity> dataEntityList, Date startTime, Date endTime, String paramId) { + if (CollectionUtils.isEmpty(dataEntityList) || length <= dataEntityList.size()) { + return dataEntityList; + } + // log.info("补全数据, length =" + length + "; size = " + dataEntityList.size() + "; startTime = " + startTime + "; endTime = " + endTime); + // log.info("补全前:" + dataEntityList); + + ApiDataPointDTO dataPoint = feignDataController.getPoint(paramId); + + Map<Long, Double> sourceDataMap = new HashMap<>(dataEntityList.size()); + for (DataEntity dataEntity : dataEntityList) { + sourceDataMap.put(dataEntity.getTimeStamp().getTime(), dataEntity.getDataValue()); + } + + //找出缺少项 + long oneMin = 1000 * SampleInfoConstructor.minFreqMap.get(dataPoint.getMinfreqid()); + long start = startTime.getTime(); + long end = endTime.getTime(); + long mins = ((end - start) / oneMin) + 1; + Map<Long, Double> dataMap = new LinkedHashMap<>(); + for (int i = 0; i < mins; i ++) { + Long key = start + oneMin * i; + Double value = sourceDataMap.get(key); + dataMap.put(key, value); + } + + //补充缺少项 + int k = 0; + Map.Entry<Long, Double> lastItem = null; + List<DataEntity> completionDataEntityList = new ArrayList<>(); + for (Map.Entry<Long, Double> item : dataMap.entrySet()) { + if (k == 0 && item.getValue() == null) { + item.setValue(getFirstValue(dataMap)); + } else if (item.getValue() == null) { + item.setValue(lastItem.getValue()); + } + k ++; + lastItem = item; + + DataEntity dataEntity = new DataEntity(); + dataEntity.setTimeStamp(new Timestamp(item.getKey())); + dataEntity.setDataValue(item.getValue()); + completionDataEntityList.add(dataEntity); + } + + // log.info("补全后:" + completionDataEntityList); + return completionDataEntityList; + } + + public List<DataEntity> completionData(int length, List<DataEntity> dataEntityList, Date startTime, Date endTime, int s) { + if (CollectionUtils.isEmpty(dataEntityList) || length <= dataEntityList.size()) { + return dataEntityList; + } + Map<Long, Double> sourceDataMap = new HashMap<>(dataEntityList.size()); + for (DataEntity dataEntity : dataEntityList) { + sourceDataMap.put(dataEntity.getTimeStamp().getTime(), dataEntity.getDataValue()); + } + + //找出缺少项 + long oneMin = 1000 * s; + long start = startTime.getTime(); + long end = endTime.getTime(); + long mins = ((end - start) / oneMin) + 1; + Map<Long, Double> dataMap = new LinkedHashMap<>(); + for (int i = 0; i < mins; i ++) { + Long key = start + oneMin * i; + Double value = sourceDataMap.get(key); + dataMap.put(key, value); + } + + //补充缺少项 + int k = 0; + Map.Entry<Long, Double> lastItem = null; + List<DataEntity> completionDataEntityList = new ArrayList<>(); + for (Map.Entry<Long, Double> item : dataMap.entrySet()) { + if (k == 0 && item.getValue() == null) { + item.setValue(getFirstValue(dataMap)); + } else if (item.getValue() == null) { + item.setValue(lastItem.getValue()); + } + k ++; + lastItem = item; + + DataEntity dataEntity = new DataEntity(); + dataEntity.setTimeStamp(new Timestamp(item.getKey())); + dataEntity.setDataValue(item.getValue()); + completionDataEntityList.add(dataEntity); + } + + // log.info("补全后:" + completionDataEntityList); + return completionDataEntityList; + } + + /** + * getFirstValue + * + * @param dataMap + * @return + */ + private Double getFirstValue(Map<Long, Double> dataMap) { + for (Map.Entry<Long, Double> item : dataMap.entrySet()) { + if (item.getValue() != null) { + return item.getValue(); + } + } + return null; + } +} diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/sample/constructor/SampleInfoConstructor.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/sample/constructor/SampleInfoConstructor.java new file mode 100644 index 0000000..a8ade2c --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/sample/constructor/SampleInfoConstructor.java @@ -0,0 +1,172 @@ +package com.iailab.module.model.sample.constructor; + + +import com.iailab.module.data.api.IFeignDataApi; +import com.iailab.module.data.dto.ApiDataPointDTO; +import com.iailab.module.data.api.IFeignDataApi; +import com.iailab.module.mcs.dto.StModelParamDTO; +import com.iailab.module.mcs.service.StModelParamService; +import com.iailab.module.model.sample.dto.ColumnItem; +import com.iailab.module.model.sample.dto.ColumnItemPort; +import com.iailab.module.model.sample.dto.SampleInfo; +import javax.annotation.Resource; +import org.springframework.stereotype.Component; +import org.springframework.util.CollectionUtils; + +import java.util.*; + +/** + * @author PanZhibao + * @Description + * @createTime 2023年05月16日 16:25:00 + */ +@Component +public class SampleInfoConstructor { + + @Resource + private StModelParamService stModelParamService; + + @Resource + private IFeignDataApi feignDataApi; + + public static final Map<String, Integer> minFreqMap = new HashMap<>(); + + private int DAY_SECOND = 1000 * 60 * 60 * 24; + + SampleInfoConstructor() { + minFreqMap.put("NET10", 10); + minFreqMap.put("NET30", 30); + minFreqMap.put("NET60", 60); + minFreqMap.put("NET_KIO10", 10); + minFreqMap.put("NET_KIO60", 60); + } + + public SampleInfo prepareSampleInfo(String modelId, Date predictTime) throws Exception { + SampleInfo sampleInfo = new SampleInfo(); + sampleInfo.setSampleColumn(getSampleColumn(modelId)); + sampleInfo.setColumnInfo(getColumnInfo(modelId, predictTime)); + return sampleInfo; + } + + private Integer getSampleColumn(String modelId) { + return stModelParamService.getByModelId(modelId).size(); + } + + private List<ColumnItemPort> getColumnInfo(String modelId, Date dateTime) throws Exception { + List<ColumnItemPort> resultList = new ArrayList<>(); + List<ColumnItem> columnItemList = new ArrayList<>(); + ColumnItem columnInfo = new ColumnItem(); + ColumnItemPort curPort = new ColumnItemPort(); //当前端口 + List<StModelParamDTO> modelParamList = stModelParamService.getByModelId(modelId); + if (CollectionUtils.isEmpty(modelParamList)) { + return null; + } + int curPortOrder = modelParamList.get(0).getParamPortOrder(); + int curDataLength = modelParamList.get(0).getDataLength(); + for (StModelParamDTO entry : modelParamList) { + columnInfo.setParamType(entry.getParamType()); + columnInfo.setParamId(entry.getParamId()); + columnInfo.setDataLength(entry.getDataLength()); + columnInfo.setModelParamOrder(entry.getParamOrder()); + columnInfo.setModelParamPortOrder(entry.getParamPortOrder()); + columnInfo.setStartTime(this.getStartTime(columnInfo, dateTime)); + columnInfo.setEndTime(this.getEndTime(columnInfo, dateTime)); + if (curPortOrder != entry.getParamPortOrder()) { + //当数据项端口号不为当前端口号时,封装上一个端口类,操作下一个端口类 + curPort.setColumnItemList(columnItemList); + curPort.setDataLength(curDataLength); + curPort.setPortOrder(curPortOrder); + resultList.add(curPort); + curPort = new ColumnItemPort(); + //封装上一个端口类后更新当前的各个参数 + columnItemList = new ArrayList<>(); + curDataLength = entry.getDataLength(); + curPortOrder = entry.getParamPortOrder(); + } + columnItemList.add(columnInfo); + columnInfo = new ColumnItem(); + } + //当迭代到最后一个项的时候,封装最后一个端口的信息 + curPort.setColumnItemList(columnItemList); + curPort.setDataLength(curDataLength); + curPort.setPortOrder(curPortOrder); + resultList.add(curPort); + return resultList; + } + + protected Date getStartTime(ColumnItem columnItem, Date originalTime) throws Exception { + Date dateTime = new Date(); + Calendar calendar = Calendar.getInstance(); + calendar.setTime(originalTime); + switch (columnItem.getParamType()) { + case "point": + ApiDataPointDTO dataPoint = feignDataApi.getPoint(columnItem.paramId); + if (dataPoint == null) { + throw new Exception("apiDataPointDTO is null"); + } + dateTime = calculateTime(dateTime, true, columnItem.getDataLength(), minFreqMap.get(dataPoint.getMinfreqid())); + break; + case "predict": + dateTime = calendar.getTime(); + break; + case "ind": + dateTime = calculateTime(dateTime, true, columnItem.getDataLength(), DAY_SECOND); + break; + case "device-main": + dateTime = calculateTime(dateTime, true, columnItem.getDataLength(), DAY_SECOND); + break; + case "event": + dateTime = calculateTime(dateTime, true, columnItem.getDataLength(), DAY_SECOND); + break; + default: + break; + } + return dateTime; + } + + protected Date getEndTime(ColumnItem columnItem, Date originalTime) throws Exception { + Date dateTime = new Date(); + Calendar calendar = Calendar.getInstance(); + calendar.setTime(originalTime); + switch (columnItem.getParamType()) { + case "point": + ApiDataPointDTO dataPoint = feignDataApi.getPoint(columnItem.paramId); + if (dataPoint == null) { + throw new Exception("apiDataPointDTO is null"); + } + calendar.add(Calendar.SECOND, minFreqMap.get(dataPoint.getMinfreqid()) * -1); + break; + case "predict": + dateTime = calculateTime(dateTime, false, columnItem.getDataLength(), 60); + break; + case "ind": + dateTime = calendar.getTime(); + break; + case "device-main": + dateTime = calendar.getTime(); + break; + case "event": + dateTime = calendar.getTime(); + break; + default: + break; + } + return dateTime; + } + + public Date calculateTime(Date originalTime, Boolean backward, int dataLength, int granularity) { + int timeLength; + if (backward) { + timeLength = (-1) * dataLength; + } else { + timeLength = dataLength - 1; + } + Date desTime = originalTime; + Calendar calendar = Calendar.getInstance(); + calendar.setTime(desTime); + calendar.set(Calendar.MILLISECOND, 0); + // 数据长度 * 粒度 + calendar.add(Calendar.SECOND, timeLength * granularity); + return calendar.getTime(); + } +} diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/sample/dto/ColumnItem.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/sample/dto/ColumnItem.java new file mode 100644 index 0000000..1a45e32 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/sample/dto/ColumnItem.java @@ -0,0 +1,48 @@ +package com.iailab.module.model.sample.dto; + +import lombok.Data; + +import java.util.Date; + +/** + * @author PanZhibao + * @Description + * @createTime 2023年05月16日 15:15:00 + */ +@Data +public class ColumnItem { + /** + * 参数类型 + */ + public String paramType; + + /** + * 参数ID + */ + public String paramId; + + /** + * 数据长度 + */ + public int dataLength; + + /** + * 模型参数排序 + */ + public int modelParamOrder; + + /** + * 模型参数端口排序 + */ + public int modelParamPortOrder; + + /** + * 采样的开始时间 + */ + public Date startTime; + + /** + * 采样的结束时间 + */ + public Date endTime; +} diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/sample/dto/ColumnItemPort.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/sample/dto/ColumnItemPort.java new file mode 100644 index 0000000..de62bbf --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/sample/dto/ColumnItemPort.java @@ -0,0 +1,20 @@ +package com.iailab.module.model.sample.dto; + +import lombok.Data; + +import java.util.List; + +/** + * @author PanZhibao + * @Description + * @createTime 2023年05月16日 15:16:00 + */ +@Data +public class ColumnItemPort { + + private List<ColumnItem> columnItemList; + + private int portOrder; + + private int dataLength; +} diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/sample/dto/DataValue.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/sample/dto/DataValue.java new file mode 100644 index 0000000..a07e653 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/sample/dto/DataValue.java @@ -0,0 +1,18 @@ +package com.iailab.module.model.sample.dto; + +import lombok.Data; + +import java.util.Date; + +/** + * @author PanZhibao + * @Description + * @createTime 2023年05月16日 16:21:00 + */ +@Data +public class DataValue { + + private Date timeStamp; + + private Double dataValue; +} diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/sample/dto/SampleData.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/sample/dto/SampleData.java new file mode 100644 index 0000000..971fe16 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/sample/dto/SampleData.java @@ -0,0 +1,13 @@ +package com.iailab.module.model.sample.dto; + +import lombok.Data; + +/** + * @author PanZhibao + * @Description + * @createTime 2023年05月16日 15:14:00 + */ +@Data +public class SampleData { + private double[][] matrix; +} diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/sample/dto/SampleInfo.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/sample/dto/SampleInfo.java new file mode 100644 index 0000000..b3e7453 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/sample/dto/SampleInfo.java @@ -0,0 +1,19 @@ +package com.iailab.module.model.sample.dto; + +import lombok.Data; + +import java.util.List; + +/** + * @author PanZhibao + * @Description + * @createTime 2023年05月16日 15:13:00 + */ +@Data +public class SampleInfo { + private Integer portLength; + + private Integer sampleColumn; + + private List<ColumnItemPort> columnInfo; +} diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/sample/entity/DataEntity.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/sample/entity/DataEntity.java new file mode 100644 index 0000000..0ed6952 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/sample/entity/DataEntity.java @@ -0,0 +1,12 @@ +package com.iailab.module.model.sample.entity; + +import lombok.Data; + +import java.util.Date; +@Data +public class DataEntity { + + private Date timeStamp; + private double dataValue; + +} diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/utils/DcsUtils.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/utils/DcsUtils.java new file mode 100644 index 0000000..2844da4 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/utils/DcsUtils.java @@ -0,0 +1,52 @@ +package com.iailab.module.model.utils; + +import com.iailab.common.constant.BusinessConstant; +import com.iailab.module.infra.api.config.ConfigApi; +import com.iailab.module.model.enums.ModelResultEnum; +import com.iailab.module.websocket.server.WebSocketServer; +import lombok.extern.slf4j.Slf4j; +import javax.annotation.Resource; +import org.springframework.stereotype.Component; + +import java.util.Map; + +/** + * @author PanZhibao + * @Description + * @createTime 2023年11月26日 12:58:00 + */ +@Slf4j +@Component +public class DcsUtils { + + @Resource + private ConfigApi configApi; + + @Resource + private WebSocketServer webSocketServer; + + + private String IS_TIP = "isTip"; + + private String DEV_Y = "y"; + + public void sendTips(Map<String, Object> data, String modelName) { + if (!data.containsKey(BusinessConstant.MODELE_RESULT_STATUS)) { + return; + } + Integer code = Integer.parseInt(data.get(BusinessConstant.MODELE_RESULT_STATUS).toString()); + if (BusinessConstant.MODELE_RESULT_STATUS_200.equals(code)) { + return; + } + String isTip = configApi.queryConfigByCode(IS_TIP); + if (!DEV_Y.equals(isTip)) { + return; + } + StringBuilder sb = new StringBuilder(); + sb.append(modelName); + sb.append(":"); + sb.append(ModelResultEnum.getEumByCode(code).getDesc()); + webSocketServer.onMessage(sb.toString()); + + } +} diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/oss/controller/OssFileController.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/oss/controller/OssFileController.java new file mode 100644 index 0000000..80d114c --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/oss/controller/OssFileController.java @@ -0,0 +1,123 @@ +package com.iailab.module.oss.controller; + +import com.iailab.common.annotation.LogOperation; +import com.iailab.framework.common.page.PageData; +import com.iailab.common.utils.Constant; +import com.iailab.common.utils.DateUtils; +import com.iailab.framework.common.pojo.CommonResult; + +import com.iailab.framework.common.util.validation.ValidationUtils; +import com.iailab.framework.common.validation.group.AddGroup; +import com.iailab.framework.common.validation.group.DefaultGroup; +import com.iailab.framework.common.validation.group.UpdateGroup; +import com.iailab.module.oss.dto.OssFileDTO; +import com.iailab.module.oss.service.OssFileService; +import io.swagger.v3.oas.annotations.tags.Tag; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.Parameters; +import javax.annotation.Resource; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; + + +import java.io.File; +import java.text.MessageFormat; +import java.util.Date; +import java.util.HashMap; +import java.util.Map; + +/** + * @author PanZhibao + * @Description + * @createTime 2023年12月26日 11:14:00 + */ +@RestController +@RequestMapping("/oss/file") +@Tag(name = "应用程序表") +public class OssFileController { + @Resource + private OssFileService ossAppService; + @Value("${iems.upload}") + private String upload; + @GetMapping("page") + @Operation(summary = "分页") + @Parameters({ + @Parameter(name = Constant.PAGE, description = "当前页码,从1开始", required = true), + @Parameter(name = Constant.LIMIT, description = "每页显示记录数", required = true), + @Parameter(name = Constant.ORDER_FIELD, description = "排序字段"), + @Parameter(name = Constant.ORDER, description = "排序方式,可选值(asc、desc)") + }) + @PreAuthorize("@ss.hasPermission('oss:file:page')") + public CommonResult<PageData<OssFileDTO>> page(@RequestParam Map<String, Object> params) { + PageData<OssFileDTO> page = ossAppService.page(params); + + return new CommonResult<PageData<OssFileDTO>>().setData(page); + } + + @GetMapping("{id}") + @Operation(summary = "信息") + @PreAuthorize("@ss.hasPermission('oss:file:info')") + public CommonResult<OssFileDTO> get(@PathVariable("id") String id) { + OssFileDTO data = ossAppService.get(id); + + return new CommonResult<OssFileDTO>().setData(data); + } + + @PostMapping + @Operation(summary = "保存") + @LogOperation("保存") + @PreAuthorize("@ss.hasPermission('oss:file:save')") + public CommonResult save(@RequestBody OssFileDTO dto) { + //效验数据 + ValidationUtils.validate(dto, AddGroup.class, DefaultGroup.class); + + ossAppService.save(dto); + + return new CommonResult(); + } + + @PutMapping + @Operation(summary = "修改") + @LogOperation("修改") + @PreAuthorize("@ss.hasPermission('oss:file:update')") + public CommonResult update(@RequestBody OssFileDTO dto) { + //效验数据 + ValidationUtils.validate(dto, UpdateGroup.class, DefaultGroup.class); + + ossAppService.update(dto); + + return new CommonResult(); + } + + @DeleteMapping("{id}") + @Operation(summary = "删除") + @LogOperation("删除") + @PreAuthorize("@ss.hasPermission('oss:file:delete')") + public CommonResult delete(@PathVariable("id") Long[] ids) { + ossAppService.delete(ids); + return new CommonResult(); + } + + /** + * 上传文件 + * + * @param file + * @return + */ + @PostMapping("/upload") + public CommonResult<Map<String, String>> upload(@RequestParam("file") MultipartFile file) throws Exception { + String postfix = file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf(".") + 1); + String path = MessageFormat.format("{0}/{1}/{2}", upload, DateUtils.format(new Date()), postfix); + File dir = new File(path); + dir.mkdirs(); + String filePath = MessageFormat.format("{0}/{1}.{2}", path, file.getOriginalFilename(), postfix); + file.transferTo(new File(filePath)); + Map<String, String> data = new HashMap<>(2); + data.put("url", filePath.replace(upload, "")); + data.put("name", file.getOriginalFilename()); + return new CommonResult<Map<String, String>>().setData(data); + } +} diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/oss/dao/OssFileDao.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/oss/dao/OssFileDao.java new file mode 100644 index 0000000..af925a7 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/oss/dao/OssFileDao.java @@ -0,0 +1,14 @@ +package com.iailab.module.oss.dao; + +import com.iailab.framework.common.dao.BaseDao; +import com.iailab.module.oss.entity.OssFileEntity; +import org.apache.ibatis.annotations.Mapper; + +/** + * @author PanZhibao + * @Description + * @createTime 2023年12月26日 11:01:00 + */ +@Mapper +public interface OssFileDao extends BaseDao<OssFileEntity> { +} diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/oss/dto/OssFileDTO.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/oss/dto/OssFileDTO.java new file mode 100644 index 0000000..ddb1165 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/oss/dto/OssFileDTO.java @@ -0,0 +1,48 @@ +package com.iailab.module.oss.dto; + +import com.iailab.framework.common.validation.group.AddGroup; +import com.iailab.framework.common.validation.group.DefaultGroup; +import com.iailab.framework.common.validation.group.UpdateGroup; +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.Null; +import java.io.Serializable; + +/** + * @author PanZhibao + * @Description + * @createTime 2023年12月26日 10:44:00 + */ +@Data +@Schema(name = "业务文件") +public class OssFileDTO implements Serializable { + private static final long serialVersionUID = 1L; + + @Schema(name = "id") + @Null(message="{id.null}", groups = AddGroup.class) + @NotNull(message="{id.require}", groups = UpdateGroup.class) + private String id; + + @Schema(name = "业务ID", required = true) + @NotBlank(message="{sysapp.appcode.require}", groups = DefaultGroup.class) + private String businessId; + + @Schema(name = "类型") + private String type; + + @Schema(name = "文件名称") + private String fileName; + + @Schema(name = "文件后缀") + private String filePostfix; + + @Schema(name = "文件地址") + private String url; + + @Schema(name = "排序") + private Integer sort; +} diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/oss/entity/OssFileEntity.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/oss/entity/OssFileEntity.java new file mode 100644 index 0000000..3e54d2c --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/oss/entity/OssFileEntity.java @@ -0,0 +1,56 @@ +package com.iailab.module.oss.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; + +/** + * @author PanZhibao + * @Description + * @createTime 2023年12月26日 10:41:00 + */ +@Data +@TableName("t_oss_file") +public class OssFileEntity implements Serializable { + private static final long serialVersionUID = 1L; + + /** + * id + */ + @TableId(type = IdType.ASSIGN_ID) + private String id; + + /** + * 业务ID + */ + private String businessId; + + /** + * 类型(推荐格式:实体名_上传类型,例如,意见反馈图片:appComment_image) + */ + private String type; + + /** + * 文件名称 + */ + private String fileName; + + /** + * 文件后缀 + */ + private String filePostfix; + + /** + * 文件地址 + */ + private String url; + + /** + * 排序 + */ + private Integer sort; + +} diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/oss/service/OssFileService.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/oss/service/OssFileService.java new file mode 100644 index 0000000..60f4796 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/oss/service/OssFileService.java @@ -0,0 +1,33 @@ +package com.iailab.module.oss.service; + +import com.iailab.framework.common.page.PageData; +import com.iailab.framework.common.service.BaseService; +import com.iailab.module.oss.dto.OssFileDTO; +import com.iailab.module.oss.entity.OssFileEntity; + +import java.util.List; +import java.util.Map; + +/** + * @author PanZhibao + * @Description + * @createTime 2023年12月26日 11:07:00 + */ +public interface OssFileService extends BaseService<OssFileEntity> { + + PageData<OssFileDTO> page(Map<String, Object> params); + + OssFileDTO get(String id); + + List<OssFileEntity> list(Map<String, Object> params); + + void save(OssFileDTO dto); + + void saveList(String businessId, List<OssFileDTO> list); + + void update(OssFileDTO dto); + + void delete(Long[] ids); + + List<OssFileDTO> getByBusinessId(String businessId); +} diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/oss/service/impl/OssFileServiceImpl.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/oss/service/impl/OssFileServiceImpl.java new file mode 100644 index 0000000..46d827f --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/oss/service/impl/OssFileServiceImpl.java @@ -0,0 +1,108 @@ +package com.iailab.module.oss.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.iailab.framework.common.constant.Constant; +import com.iailab.framework.common.page.PageData; +import com.iailab.framework.common.service.impl.BaseServiceImpl; +import com.iailab.framework.common.util.object.ConvertUtils; +import com.iailab.module.oss.dao.OssFileDao; +import com.iailab.module.oss.dto.OssFileDTO; +import com.iailab.module.oss.entity.OssFileEntity; +import com.iailab.module.oss.service.OssFileService; +import org.apache.commons.lang3.StringUtils; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.util.CollectionUtils; + +import java.util.Arrays; +import java.util.List; +import java.util.Map; + +/** + * @author PanZhibao + * @Description + * @createTime 2023年12月26日 11:12:00 + */ +@Service +public class OssFileServiceImpl extends BaseServiceImpl<OssFileDao, OssFileEntity> implements OssFileService { + + @Override + public PageData<OssFileDTO> page(Map<String, Object> params) { + IPage<OssFileEntity> page = baseDao.selectPage( + getPage(params, Constant.CREATE_DATE, false), + getWrapper(params) + ); + return getPageData(page, OssFileDTO.class); + } + + private QueryWrapper<OssFileEntity> getWrapper(Map<String, Object> params) { + String businessId = (String) params.get("businessId"); + String type = (String) params.get("type"); + String fileName = (String) params.get("fileName"); + QueryWrapper<OssFileEntity> wrapper = new QueryWrapper<>(); + wrapper.eq(StringUtils.isNotBlank(businessId), "business_id", businessId) + .like(StringUtils.isNotBlank(type), "type", type) + .like(StringUtils.isNotBlank(fileName), "file_name", fileName); + return wrapper; + } + + @Override + public List<OssFileEntity> list(Map<String, Object> params) { + QueryWrapper<OssFileEntity> wrapper = getWrapper(params); + wrapper.orderByAsc("sort"); + return baseDao.selectList(wrapper); + } + + @Override + public OssFileDTO get(String id) { + OssFileEntity entity = baseDao.selectById(id); + + return ConvertUtils.sourceToTarget(entity, OssFileDTO.class); + } + + @Override + public List<OssFileDTO> getByBusinessId(String businessId) { + QueryWrapper<OssFileEntity> wrapper = new QueryWrapper<>(); + wrapper.eq(StringUtils.isNotBlank(businessId), "business_id", businessId); + List<OssFileEntity> list = baseDao.selectList(wrapper); + + return ConvertUtils.sourceToTarget(list, OssFileDTO.class); + } + + @Override + public void save(OssFileDTO dto) { + OssFileEntity entity = ConvertUtils.sourceToTarget(dto, OssFileEntity.class); + insert(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void saveList(String businessId, List<OssFileDTO> list) { + deleteByBusinessId(businessId); + if (CollectionUtils.isEmpty(list)) { + return; + } + list.forEach(item -> { + save(item); + }); + } + + @Override + public void update(OssFileDTO dto) { + OssFileEntity entity = ConvertUtils.sourceToTarget(dto, OssFileEntity.class); + updateById(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void delete(Long[] ids) { + baseDao.deleteBatchIds(Arrays.asList(ids)); + } + + private void deleteByBusinessId(String businessId) { + QueryWrapper<OssFileEntity> queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("business_id", businessId); + baseDao.delete(queryWrapper); + } +} diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/package-info.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/package-info.java new file mode 100644 index 0000000..c343803 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/package-info.java @@ -0,0 +1 @@ +package com.iailab.module; \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/param/controller/PageParamController.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/param/controller/PageParamController.java new file mode 100644 index 0000000..26e7397 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/param/controller/PageParamController.java @@ -0,0 +1,180 @@ +package com.iailab.module.param.controller; + +import com.alibaba.fastjson.JSONObject; +import com.iailab.common.enums.CdbmEnum; +import com.iailab.module.data.api.IFeignDataApi; +import com.iailab.module.data.dto.ApiDataDTO; +import com.iailab.module.data.dto.FeignQueryPointDTO; +import com.iailab.framework.common.pojo.CommonResult; +import com.iailab.module.model.handler.ModelHandler; +import com.iailab.module.param.dto.PageParamDTO; +import com.iailab.module.param.dto.PageParamResultValueDTO; +import com.iailab.module.param.dto.PointDataValueDTO; +import com.iailab.module.param.dto.ResultPointAndTrendDataDTO; +import com.iailab.module.param.service.PageParmService; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import javax.annotation.Resource; +import org.springframework.util.CollectionUtils; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.math.BigDecimal; +import java.text.SimpleDateFormat; +import java.util.*; +import java.util.stream.Collectors; + +/** + * @author DongYukun + * @Description + * @createTime 2024年5月10日 15:06:00 + */ +@RestController +@RequestMapping("/param/page") +@Tag(name = "原煤趋势分析") +@Slf4j +public class PageParamController { + + private final String[] rowCoalPageCode = {"ymrxl","ymhf","ymsf","ymlf","ymrz"}; + private final String[] washPageCode = {"hmcl","xxkcl","xzkcl","hmhf","hmlf","hmsf","hmrz"}; + + private final String[] wyPageCode = {"dxhm","xxkwy","xzkwy","gswy","xkzz","hcwyds","hcwyls"}; + + @Resource + PageParmService pageParmService; + + @Resource + private IFeignDataApi feignDataApi; + + @Resource + private ModelHandler modelHandler; + + @GetMapping("{page}") + @Operation(summary = "趋势分析数据") + public CommonResult<List<PageParamResultValueDTO>> get(@PathVariable("page") String page) { + List<PageParamDTO> dtoList = pageParmService.selectPageParamByPage(page); + List<PageParamResultValueDTO> resultData = new ArrayList<>(); + switch (page){ + case "rowCoal": + resultData = collateCommonResultValueDate(dtoList,rowCoalPageCode); + break; + case "wash": + resultData = collateCommonResultValueDate(dtoList,washPageCode); + break; + case "wy": + resultData = collateCommonResultValueDate(dtoList,wyPageCode); + break; + } + return new CommonResult<List<PageParamResultValueDTO>>().setData(resultData); + } + + @GetMapping("/point/{page}") + @Operation(summary = "获取point数据") + public CommonResult<List<ResultPointAndTrendDataDTO>> getPointData(@PathVariable("page") String page) { + List<ResultPointAndTrendDataDTO> result; + String pointLength = pageParmService.selectValue(page, "point_length"); + String point = pageParmService.selectValue(page, "point")==null?"":pageParmService.selectValue(page, "point"); + List<String> pointList = Arrays.asList(point.split(";")); + log.info("页面需要的point值:" + pointList); + result = getPoints(pointList,pointLength); + log.info("查询point返回的values" + result); + Map<String, Object> params = new HashMap<>(1); + params.put("modelCode", "trend_analysis"); + result.forEach(e -> { + try { + List<double[][]> sampleDataList = new ArrayList<>(); + List<PointDataValueDTO> nv = e.getDataValue().stream().filter(dto -> dto.getDataValue() != null).collect(Collectors.toList()); + double[][] mix = new double[nv.size()][1]; + for (int i = 0; i < nv.size(); i++) { + mix[i][0] = nv.get(i).getDataValue().doubleValue(); + } + sampleDataList.add(mix); + Map<String, Object> trendItem = runModel(params, sampleDataList); + log.info("根据point查询的values查询模型返回的trend" + trendItem); + e.setTrendValue(trendItem); + } catch (Exception ex) { + ex.printStackTrace(); + } + }); + return new CommonResult<List<ResultPointAndTrendDataDTO>>().setData(result); + } + + private List<PageParamResultValueDTO> collateCommonResultValueDate(List<PageParamDTO> dtoList, String[] pageCode){ + List<PageParamResultValueDTO> resultDataList = new ArrayList<>(); + dtoList.forEach(e->{ + if(Arrays.asList(pageCode).contains(e.getParamCode())){ + resultDataList.add(JSONObject.parseObject(e.getParamValue(), PageParamResultValueDTO.class)); + } + }); + return resultDataList; + } + + public List<ResultPointAndTrendDataDTO> getPoints(List<String> pointList,String length){ + List<ResultPointAndTrendDataDTO> result = new ArrayList<>(); + if (CollectionUtils.isEmpty(pointList)) { + return result; + } + try { + pointList.forEach(point->{ + ResultPointAndTrendDataDTO dto = new ResultPointAndTrendDataDTO(); + dto.setPointNo(point); + dto.setChartName(CdbmEnum.getEumByName(point).getDesc()); + dto.setUnit(CdbmEnum.getEumByName(point).getUnit()); + dto.setLength(length); + dto.setDataValue(getPointData(point,length)); + result.add(dto); + } + ); + } catch (Exception ex) { + ex.printStackTrace(); + } + return result; + } + + public List<PointDataValueDTO> getPointData(String param, String length){ + FeignQueryPointDTO dto = new FeignQueryPointDTO(); + dto.setEndTime(new Date()); + Calendar calendar = Calendar.getInstance(); + calendar.setTime(new Date()); + calendar.add(Calendar.DAY_OF_YEAR, -Integer.parseInt(length)); + dto.setStartTime(calendar.getTime()); + dto.setPointCode(CdbmEnum.getEumByName(param).getCode()); + dto.setType("float"); + log.info("开始获取point数据"); + List<ApiDataDTO> pointValues = feignDataApi.queryPointValues(dto); + log.info("获取的point数据pointValues:" + pointValues); + List<PointDataValueDTO> dots = new ArrayList<>(); + pointValues.forEach(e->{ + PointDataValueDTO pointDataValueDTO = new PointDataValueDTO(); + pointDataValueDTO.setItemNo(param); + pointDataValueDTO.setDataTime(new SimpleDateFormat("yyyy-MM-dd").format(e.getTimeStamp())); + pointDataValueDTO.setDataValue(BigDecimal.valueOf(e.getDataValue())); + dots.add(pointDataValueDTO); + } + ); + log.info("转换成的PointDataValueDTOS:" + dots); + return dots; + } + public Map<String, Object> runModel(Map<String, Object> params, List<double[][]> sampleDataList) { + Map<String, Object> result = new HashMap<>(); + try { + String modelCode = (String) params.get("modelCode"); + if (StringUtils.isBlank(modelCode)) { + return result; + } + if (CollectionUtils.isEmpty(sampleDataList)) { + return result; + } + Calendar calendar = Calendar.getInstance(); + calendar.set(Calendar.MILLISECOND, 0); + result = modelHandler.run(modelCode, sampleDataList); + } catch (Exception ex) { + ex.printStackTrace(); + } + return result; + } +} diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/param/dao/PageParamDao.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/param/dao/PageParamDao.java new file mode 100644 index 0000000..15e8dd2 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/param/dao/PageParamDao.java @@ -0,0 +1,9 @@ +package com.iailab.module.param.dao; + +import com.iailab.framework.common.dao.BaseDao; +import com.iailab.module.param.entity.PageParamEntity; +import org.apache.ibatis.annotations.Mapper; + +@Mapper +public interface PageParamDao extends BaseDao<PageParamEntity> { +} diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/param/dto/PageParamDTO.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/param/dto/PageParamDTO.java new file mode 100644 index 0000000..ebf7425 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/param/dto/PageParamDTO.java @@ -0,0 +1,20 @@ +package com.iailab.module.param.dto; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.io.Serializable; + +@Data +@Schema(name = "页面参数") +public class PageParamDTO implements Serializable { + private static final long serialVersionUID = 1L; + + private String id; + + private String page; + + private String paramCode = ""; + + private String paramValue = ""; +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/param/dto/PageParamResultValueDTO.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/param/dto/PageParamResultValueDTO.java new file mode 100644 index 0000000..5bc3ae0 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/param/dto/PageParamResultValueDTO.java @@ -0,0 +1,21 @@ +package com.iailab.module.param.dto; + +import lombok.Data; + +import java.io.Serializable; + +@Data +public class PageParamResultValueDTO implements Serializable { + private static final long serialVersionUID = 1L; + + private String chartCode; + + private String length; + + private String unit; + + private String maxSlope; + + private String minSlope; + +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/param/dto/PointDataValueDTO.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/param/dto/PointDataValueDTO.java new file mode 100644 index 0000000..e4d8e86 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/param/dto/PointDataValueDTO.java @@ -0,0 +1,28 @@ +package com.iailab.module.param.dto; + +import io.swagger.v3.oas.annotations.media.Schema; + +import lombok.Data; + +import java.io.Serializable; +import java.math.BigDecimal; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年05月25日 + */ +@Data +@Schema(name = "point值") +public class PointDataValueDTO implements Serializable { + private static final long serialVersionUID = 1L; + + @Schema(name = "point编码") + private String itemNo; + + @Schema(name = "数据时间") + private String dataTime; + + @Schema(name = "数据值") + private BigDecimal dataValue; +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/param/dto/ResultPointAndTrendDataDTO.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/param/dto/ResultPointAndTrendDataDTO.java new file mode 100644 index 0000000..4edfa38 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/param/dto/ResultPointAndTrendDataDTO.java @@ -0,0 +1,38 @@ +package com.iailab.module.param.dto; + +import io.swagger.v3.oas.annotations.media.Schema; + +import lombok.Data; + +import java.io.Serializable; +import java.util.List; +import java.util.Map; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年05月25日 + */ +@Data +@Schema(name = "point值") +public class ResultPointAndTrendDataDTO implements Serializable { + private static final long serialVersionUID = 1L; + + @Schema(name = "point编码") + private String pointNo; + + @Schema(name = "图形名称") + private String chartName; + + @Schema(name = "图形单位") + private String unit; + + @Schema(name = "时间长度") + private String length; + + @Schema(name = "趋势") + private Map<String, Object> trendValue; + + @Schema(name = "数据值") + private List<PointDataValueDTO> dataValue; +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/param/entity/PageParamEntity.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/param/entity/PageParamEntity.java new file mode 100644 index 0000000..262ecdd --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/param/entity/PageParamEntity.java @@ -0,0 +1,62 @@ +package com.iailab.module.param.entity; + +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.io.Serializable; +import java.util.Date; + +/** + * @author DongYukun + * @Description 页面 + * @createTime 2024年05月17日 09:55:00 + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("t_page_param") +public class PageParamEntity implements Serializable { + private static final long serialVersionUID = 1L; + + /** + * id + */ + @TableId + private String id; + + /** + * 页面编码 + */ + private String page; + + /** + * 参数编码 + */ + private String paramCode; + + /** + * 参数值 + */ + private String paramValue; + + /** + * 创建者 + */ + private Long creator; + + /** + * 创建时间 + */ + private Date createDate; + + /** + * 创建者 + */ + private Long updater; + + /** + * 创建时间 + */ + private Date updateDate; +} diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/param/service/PageParmService.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/param/service/PageParmService.java new file mode 100644 index 0000000..dcf0cba --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/param/service/PageParmService.java @@ -0,0 +1,15 @@ +package com.iailab.module.param.service; + +import com.iailab.framework.common.service.BaseService; +import com.iailab.module.param.dto.PageParamDTO; +import com.iailab.module.param.entity.PageParamEntity; + +import java.util.List; + +public interface PageParmService extends BaseService<PageParamEntity> { + + //根据页面和参数编码查询参数值 + String selectValue(String page , String paramCode); + + List<PageParamDTO> selectPageParamByPage(String page); +} diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/param/service/impl/PageParamServiceImpl.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/param/service/impl/PageParamServiceImpl.java new file mode 100644 index 0000000..cee429a --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/param/service/impl/PageParamServiceImpl.java @@ -0,0 +1,42 @@ +package com.iailab.module.param.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.iailab.framework.common.service.impl.BaseServiceImpl; +import com.iailab.framework.common.util.object.ConvertUtils; +import com.iailab.module.param.dao.PageParamDao; +import com.iailab.module.param.dto.PageParamDTO; +import com.iailab.module.param.entity.PageParamEntity; +import com.iailab.module.param.service.PageParmService; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * @author Jay + */ +@Service +public class PageParamServiceImpl extends BaseServiceImpl<PageParamDao, PageParamEntity> implements PageParmService { + @Override + public String selectValue(String page, String paramCode) { + + String value = baseDao.selectOne( + new QueryWrapper<PageParamEntity>() + .eq("page",page) + .eq("param_code",paramCode) + )==null?"":baseDao.selectOne( + new QueryWrapper<PageParamEntity>() + .eq("page",page) + .eq("param_code",paramCode) + ).getParamValue(); + + return value; + } + + @Override + public List<PageParamDTO> selectPageParamByPage(String page) { + QueryWrapper<PageParamEntity> queryWrapper = new QueryWrapper<PageParamEntity>() + .eq("page", page) + .orderByAsc("id"); + return ConvertUtils.sourceToTarget(baseDao.selectList(queryWrapper), PageParamDTO.class); + } +} diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/controller/IndexEvaluateSystemController.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/controller/IndexEvaluateSystemController.java new file mode 100644 index 0000000..fefd6fb --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/controller/IndexEvaluateSystemController.java @@ -0,0 +1,128 @@ +package com.iailab.module.prod.controller; + +import com.iailab.common.annotation.LogOperation; +import com.iailab.common.dto.echarts.BarLineDTO; +import com.iailab.framework.common.page.PageData; +import com.iailab.common.utils.Constant; +import com.iailab.framework.common.pojo.CommonResult; + +import com.iailab.framework.common.util.validation.ValidationUtils; +import com.iailab.framework.common.validation.group.AddGroup; +import com.iailab.framework.common.validation.group.DefaultGroup; +import com.iailab.framework.common.validation.group.UpdateGroup; +import com.iailab.module.prod.dto.IndexEvaluateSystemDTO; +import com.iailab.module.prod.entity.IndexEvaluateSystemEntity; +import com.iailab.module.prod.service.IndexEvaluateSystemService; +import io.swagger.v3.oas.annotations.tags.Tag; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.Parameters; +import javax.annotation.Resource; +import org.springframework.web.bind.annotation.*; + + +import java.util.List; +import java.util.Map; + +/** + * @author DongYukun + * @Description + * @createTime 2024年5月24日 21:58:00 + */ +@RestController +@RequestMapping("/index/evaluate") +@Tag(name = "指标评价体系") +public class IndexEvaluateSystemController { + + @Resource + private IndexEvaluateSystemService indexEvaluateSystemService; + + @GetMapping("page") + @Operation(summary = "分页") + @Parameters({ + @Parameter(name = Constant.PAGE, description = "当前页码,从1开始", required = true), + @Parameter(name = Constant.LIMIT, description = "每页显示记录数", required = true), + @Parameter(name = Constant.ORDER_FIELD, description = "排序字段"), + @Parameter(name = Constant.ORDER, description = "排序方式,可选值(asc、desc)") + }) + public CommonResult<PageData<IndexEvaluateSystemDTO>> page(@RequestParam Map<String, Object> params) { + PageData<IndexEvaluateSystemDTO> page = indexEvaluateSystemService.page(params); + + return new CommonResult<PageData<IndexEvaluateSystemDTO>>().setData(page); + } + + @GetMapping("systemWeightList") + @Operation(summary = "获取指标体系权重") + public CommonResult<Map<String,String>> systemWeightList() { + Map<String,String> data = indexEvaluateSystemService.systemWeightList(); + + return new CommonResult<Map<String,String>>().setData(data); + } + + @PostMapping("updataSystemWeight") + @Operation(summary = "修改指标体系权重") + public CommonResult updataSystemWeight(@RequestBody Map<String, String> params) { + + indexEvaluateSystemService.updataSystemWeight(params); + + return new CommonResult(); + } + + @PostMapping("updataWeight") + @Operation(summary = "修改指标权重") + public CommonResult updataWeight(@RequestBody List<IndexEvaluateSystemEntity> list) { + + indexEvaluateSystemService.updataWeight(list); + + return new CommonResult(); + } + + + @GetMapping("{id}") + @Operation(summary = "信息") + public CommonResult<IndexEvaluateSystemDTO> get(@PathVariable("id") String id) { + IndexEvaluateSystemDTO data = indexEvaluateSystemService.get(id); + + return new CommonResult<IndexEvaluateSystemDTO>().setData(data); + } + + @PostMapping + @Operation(summary = "保存") + @LogOperation("保存") + public CommonResult save(@RequestBody IndexEvaluateSystemDTO dto) { + //效验数据 + ValidationUtils.validate(dto, AddGroup.class, DefaultGroup.class); + + indexEvaluateSystemService.save(dto); + + return new CommonResult(); + } + + @PutMapping + @Operation(summary = "修改") + @LogOperation("修改") + public CommonResult update(@RequestBody IndexEvaluateSystemDTO dto) { + //效验数据 + ValidationUtils.validate(dto, UpdateGroup.class, DefaultGroup.class); + + indexEvaluateSystemService.update(dto); + + return new CommonResult(); + } + + @DeleteMapping + @Operation(summary = "删除") + @LogOperation("删除") + public CommonResult delete(@RequestBody String[] ids) { + indexEvaluateSystemService.delete(ids); + return new CommonResult(); + } + + @GetMapping("chart/{pid}") + @Operation(summary = "信息") + public CommonResult<BarLineDTO> getChart(@PathVariable("pid") String pid) { + BarLineDTO data = indexEvaluateSystemService.getChart(pid); + + return new CommonResult<BarLineDTO>().setData(data); + } +} diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/controller/PageCharsController.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/controller/PageCharsController.java new file mode 100644 index 0000000..81424a8 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/controller/PageCharsController.java @@ -0,0 +1,36 @@ +package com.iailab.module.prod.controller; + +import com.iailab.framework.common.pojo.CommonResult; +import com.iailab.module.prod.dto.PageCharsDTO; +import com.iailab.module.prod.service.PageCharsService; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; +import javax.annotation.Resource; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.util.List; + +/** + * @author DongYukun + * @Description + * @createTime 2024年5月10日 15:06:00 + */ +@RestController +@RequestMapping("/analysis/raw") +@Tag(name = "原煤趋势分析") +public class PageCharsController { + + @Resource + PageCharsService pageCharsService; + + @GetMapping("{page}") + @Operation(summary = "原煤趋势分析数据") + public CommonResult<List<PageCharsDTO>> get(@PathVariable("page") String page) { + List<PageCharsDTO> dtoList = pageCharsService.getData(page); + + return new CommonResult<List<PageCharsDTO>>().setData(dtoList); + } +} diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/controller/StoreDependableAnalysisController.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/controller/StoreDependableAnalysisController.java new file mode 100644 index 0000000..3bb5314 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/controller/StoreDependableAnalysisController.java @@ -0,0 +1,48 @@ +package com.iailab.module.prod.controller; + +import com.iailab.framework.common.page.PageData; +import com.iailab.common.utils.Constant; +import com.iailab.framework.common.pojo.CommonResult; +import com.iailab.module.any.dto.AnyStoreReliabilityDTO; +import com.iailab.module.mcs.service.StModelResultService; +import io.swagger.v3.oas.annotations.tags.Tag; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.Parameters; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + + +import javax.annotation.Resource; +import java.util.Map; + +/** + * @author DongYukun + * @Description + * @createTime 2024年5月23日 15:06:00 + */ +@RestController +@RequestMapping("/store") +@Tag(name = "仓储可靠性分析") +public class StoreDependableAnalysisController { + + @Resource + private StModelResultService stModelCommonResultService; + + @GetMapping("page") + @Operation(summary = "分页") + @Parameters({ + @Parameter(name = Constant.PAGE, description = "当前页码,从1开始", required = true), + @Parameter(name = Constant.LIMIT, description = "每页显示记录数", required = true), + @Parameter(name = Constant.ORDER_FIELD, description = "排序字段"), + @Parameter(name = Constant.ORDER, description = "排序方式,可选值(asc、desc)") + }) + public CommonResult<PageData<AnyStoreReliabilityDTO>> page(@RequestParam Map<String, Object> params) { + PageData<AnyStoreReliabilityDTO> page = stModelCommonResultService.getStorePage(params); + + return new CommonResult<PageData<AnyStoreReliabilityDTO>>().setData(page); + } + +} diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/dao/IndexEvaluateSystemDao.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/dao/IndexEvaluateSystemDao.java new file mode 100644 index 0000000..5d9d5cd --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/dao/IndexEvaluateSystemDao.java @@ -0,0 +1,14 @@ +package com.iailab.module.prod.dao; + +import com.iailab.framework.common.dao.BaseDao; +import com.iailab.module.prod.entity.IndexEvaluateSystemEntity; +import org.apache.ibatis.annotations.Mapper; + +/** + * @author DongYukun + * @Description + * @createTime 2024年05月25日 + */ +@Mapper +public interface IndexEvaluateSystemDao extends BaseDao<IndexEvaluateSystemEntity> { +} diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/dao/PrdCurrentPerformanceDao.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/dao/PrdCurrentPerformanceDao.java new file mode 100644 index 0000000..0ee778c --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/dao/PrdCurrentPerformanceDao.java @@ -0,0 +1,15 @@ + +package com.iailab.module.prod.dao; + +import com.iailab.framework.common.dao.BaseDao; +import com.iailab.module.prod.entity.PrdCurrentPerformanceEntity; +import org.apache.ibatis.annotations.Mapper; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年05月14日 + */ +@Mapper +public interface PrdCurrentPerformanceDao extends BaseDao<PrdCurrentPerformanceEntity> { +} diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/dao/PrdCurrentSaleDao.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/dao/PrdCurrentSaleDao.java new file mode 100644 index 0000000..7d15448 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/dao/PrdCurrentSaleDao.java @@ -0,0 +1,15 @@ + +package com.iailab.module.prod.dao; + +import com.iailab.framework.common.dao.BaseDao; +import com.iailab.module.prod.entity.PrdCurrentSaleEntity; +import org.apache.ibatis.annotations.Mapper; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年05月14日 + */ +@Mapper +public interface PrdCurrentSaleDao extends BaseDao<PrdCurrentSaleEntity> { +} diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/dao/PrdDayDutyDao.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/dao/PrdDayDutyDao.java new file mode 100644 index 0000000..00fac59 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/dao/PrdDayDutyDao.java @@ -0,0 +1,14 @@ +package com.iailab.module.prod.dao; + +import com.iailab.framework.common.dao.BaseDao; +import com.iailab.module.prod.entity.PrdDayDutyEntity; +import org.apache.ibatis.annotations.Mapper; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年05月26日 + */ +@Mapper +public interface PrdDayDutyDao extends BaseDao<PrdDayDutyEntity> { +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/dao/PrdDayProdDao.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/dao/PrdDayProdDao.java new file mode 100644 index 0000000..1e64e10 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/dao/PrdDayProdDao.java @@ -0,0 +1,16 @@ + +package com.iailab.module.prod.dao; + +import com.iailab.framework.common.dao.BaseDao; +import com.iailab.module.prod.entity.PrdDayProdEntity; +import org.apache.ibatis.annotations.Mapper; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年05月14日 + */ +@Mapper +public interface PrdDayProdDao extends BaseDao<PrdDayProdEntity> { +} + diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/dao/PrdPlanMonDao.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/dao/PrdPlanMonDao.java new file mode 100644 index 0000000..0530bae --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/dao/PrdPlanMonDao.java @@ -0,0 +1,16 @@ + +package com.iailab.module.prod.dao; + +import com.iailab.framework.common.dao.BaseDao; +import com.iailab.module.prod.entity.PrdPlanMonEntity; +import org.apache.ibatis.annotations.Mapper; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年05月14日 + */ +@Mapper +public interface PrdPlanMonDao extends BaseDao<PrdPlanMonEntity> { +} + diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/dao/PrdPlanYearDao.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/dao/PrdPlanYearDao.java new file mode 100644 index 0000000..ff81c36 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/dao/PrdPlanYearDao.java @@ -0,0 +1,15 @@ + +package com.iailab.module.prod.dao; + +import com.iailab.framework.common.dao.BaseDao; +import com.iailab.module.prod.entity.PrdPlanYearEntity; +import org.apache.ibatis.annotations.Mapper; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年05月14日 + */ +@Mapper +public interface PrdPlanYearDao extends BaseDao<PrdPlanYearEntity> { +} diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/dao/PrdTimeDayDao.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/dao/PrdTimeDayDao.java new file mode 100644 index 0000000..2371044 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/dao/PrdTimeDayDao.java @@ -0,0 +1,14 @@ +package com.iailab.module.prod.dao; + +import com.iailab.framework.common.dao.BaseDao; +import com.iailab.module.prod.entity.PrdTimeDayEntity; +import org.apache.ibatis.annotations.Mapper; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年06月16日 + */ +@Mapper +public interface PrdTimeDayDao extends BaseDao<PrdTimeDayEntity> { +} diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/dao/StorageDayDao.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/dao/StorageDayDao.java new file mode 100644 index 0000000..f534f6e --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/dao/StorageDayDao.java @@ -0,0 +1,14 @@ +package com.iailab.module.prod.dao; + +import com.iailab.framework.common.dao.BaseDao; +import com.iailab.module.prod.entity.StorageDayEntity; +import org.apache.ibatis.annotations.Mapper; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年06月01日 + */ +@Mapper +public interface StorageDayDao extends BaseDao<StorageDayEntity> { +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/dto/IndexEvaluateSystemDTO.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/dto/IndexEvaluateSystemDTO.java new file mode 100644 index 0000000..a5b69bb --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/dto/IndexEvaluateSystemDTO.java @@ -0,0 +1,59 @@ +package com.iailab.module.prod.dto; + +import com.iailab.framework.common.validation.group.AddGroup; +import com.iailab.framework.common.validation.group.UpdateGroup; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Null; +import java.io.Serializable; + +/** + * @author DongYukun + * @Description + * @createTime 2024年05月25日 + */ +@Data +@Schema(name = "指标权重") +public class IndexEvaluateSystemDTO implements Serializable { + private static final long serialVersionUID = 1L; + + @Schema(name = "id") + @Null(message="{id.null}", groups = AddGroup.class) + @NotNull(message="{id.require}", groups = UpdateGroup.class) + private String id; + /** + * 父ID + */ + private String pid; + /** + * 编码 + */ + private String code; + /** + * 评价指标 + */ + private String evaluateIndex; + /** + * 权重 + */ + private Integer weight; + /** + * 创建人 + */ + private String creator; + /** + * 创建时间 + */ + private String createDate; + /** + * 更新人 + */ + private String updater; + /** + * 更新时间 + */ + private String updateDate; +} + diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/dto/PageCharsDTO.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/dto/PageCharsDTO.java new file mode 100644 index 0000000..ca6f59c --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/dto/PageCharsDTO.java @@ -0,0 +1,43 @@ +package com.iailab.module.prod.dto; + +import com.iailab.common.dto.echarts.BarLineDTO; +import lombok.Data; + +import java.math.BigDecimal; +import java.util.Date; + +/** + * @author DongYukun + * @Description + * @createTime 2024年5月10日 15:06:00 + */ +@Data +public class PageCharsDTO { + + //图表 + private BarLineDTO barLineDTO; + + //图表 + private String length; + + //单位 + private String unit; + + //当前值 + private BigDecimal currentValue; + + //建议 + private String suggest; + + //建议时间 + private Date suggestTime; + + //平均值 + private String avg; + + //最大值 + private String max; + + //最小值 + private String min; +} diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/dto/PrdCurrentPerformanceDTO.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/dto/PrdCurrentPerformanceDTO.java new file mode 100644 index 0000000..fbe503b --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/dto/PrdCurrentPerformanceDTO.java @@ -0,0 +1,35 @@ +package com.iailab.module.prod.dto; + +import com.iailab.framework.common.validation.group.AddGroup; +import com.iailab.framework.common.validation.group.UpdateGroup; +import io.swagger.v3.oas.annotations.media.Schema; + +import lombok.Data; + +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Null; +import java.io.Serializable; +import java.math.BigDecimal; +import java.util.Date; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年05月14日 + */ +@Data +@Schema(name = "当前产量") +public class PrdCurrentPerformanceDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + @Schema(name = "id") + @Null(message="{id.null}", groups = AddGroup.class) + @NotNull(message="{id.require}", groups = UpdateGroup.class) + private String id; + private String rq; + private BigDecimal xxPerformance; + private BigDecimal zqPerformance; + private Date createDate; + private Date updateDate; +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/dto/PrdCurrentSaleDTO.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/dto/PrdCurrentSaleDTO.java new file mode 100644 index 0000000..1fe7c84 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/dto/PrdCurrentSaleDTO.java @@ -0,0 +1,40 @@ +package com.iailab.module.prod.dto; + +import com.iailab.framework.common.validation.group.AddGroup; +import com.iailab.framework.common.validation.group.UpdateGroup; +import io.swagger.v3.oas.annotations.media.Schema; + +import lombok.Data; + +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Null; +import java.io.Serializable; +import java.math.BigDecimal; +import java.util.Date; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年05月14日 + */ +@Data +@Schema(name = "当前销量") +public class PrdCurrentSaleDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + @Schema(name = "id") + @Null(message="{id.null}", groups = AddGroup.class) + @NotNull(message="{id.require}", groups = UpdateGroup.class) + private String id; + private String rq; + private BigDecimal groundsales; + private BigDecimal medblock; + private BigDecimal nubmeasure; + private BigDecimal gangue; + private BigDecimal reshipped; + private BigDecimal trainTon; + private BigDecimal trainCount; + private Date createDate; + private Date updateDate; +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/dto/PrdDayDutyDTO.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/dto/PrdDayDutyDTO.java new file mode 100644 index 0000000..d8f3871 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/dto/PrdDayDutyDTO.java @@ -0,0 +1,40 @@ +package com.iailab.module.prod.dto; + +import com.iailab.framework.common.validation.group.AddGroup; +import com.iailab.framework.common.validation.group.UpdateGroup; +import io.swagger.v3.oas.annotations.media.Schema; + +import lombok.Data; + +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Null; +import java.io.Serializable; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年05月26日 + */ +@Data +@Schema(name = "值班情况") +public class PrdDayDutyDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + @Schema(name = "id") + @Null(message="{id.null}", groups = AddGroup.class) + @NotNull(message="{id.require}", groups = UpdateGroup.class) + private String id; + + private String date; + + private String area; + + private String banci; + + private String banzu; + + private Integer number; + + private Integer arrive; +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/dto/PrdDayProdDTO.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/dto/PrdDayProdDTO.java new file mode 100644 index 0000000..e8063a2 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/dto/PrdDayProdDTO.java @@ -0,0 +1,37 @@ +package com.iailab.module.prod.dto; + +import com.iailab.framework.common.validation.group.AddGroup; +import com.iailab.framework.common.validation.group.UpdateGroup; +import io.swagger.v3.oas.annotations.media.Schema; + +import lombok.Data; + +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Null; +import java.io.Serializable; +import java.util.Date; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年05月14日 + */ +@Data +@Schema(name = "日产品产量") +public class PrdDayProdDTO implements Serializable { + private static final long serialVersionUID = 1L; + + @Schema(name = "id") + @Null(message="{id.null}", groups = AddGroup.class) + @NotNull(message="{id.require}", groups = UpdateGroup.class) + private String id; + + private String rq; + private double rawCoal; + private double mixedCoal; + private double mediumCoal; + private double smallCoal; + private double gangue; + private Date createDate; + private Date updateDate; +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/dto/PrdPlanMonDTO.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/dto/PrdPlanMonDTO.java new file mode 100644 index 0000000..dd9acfb --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/dto/PrdPlanMonDTO.java @@ -0,0 +1,37 @@ +package com.iailab.module.prod.dto; + +import com.iailab.framework.common.validation.group.AddGroup; +import com.iailab.framework.common.validation.group.UpdateGroup; +import io.swagger.v3.oas.annotations.media.Schema; + +import lombok.Data; + +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Null; +import java.io.Serializable; +import java.math.BigDecimal; +import java.util.Date; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年05月14日 + */ +@Data +@Schema(name = "月生产计划执行数据") +public class PrdPlanMonDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + @Schema(name = "id") + @Null(message="{id.null}", groups = AddGroup.class) + @NotNull(message="{id.require}", groups = UpdateGroup.class) + private String id; + private String rq; + private BigDecimal xxPlan; + private BigDecimal xxPerformance; + private BigDecimal zqPlan; + private BigDecimal zqPerformance; + private Date createDate; + private Date updateDate; +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/dto/PrdPlanYearDTO.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/dto/PrdPlanYearDTO.java new file mode 100644 index 0000000..36f8656 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/dto/PrdPlanYearDTO.java @@ -0,0 +1,37 @@ +package com.iailab.module.prod.dto; + +import com.iailab.framework.common.validation.group.AddGroup; +import com.iailab.framework.common.validation.group.UpdateGroup; +import io.swagger.v3.oas.annotations.media.Schema; + +import lombok.Data; + +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Null; +import java.io.Serializable; +import java.math.BigDecimal; +import java.util.Date; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年05月14日 + */ +@Data +@Schema(name = "年生产计划执行数据") +public class PrdPlanYearDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + @Schema(name = "id") + @Null(message="{id.null}", groups = AddGroup.class) + @NotNull(message="{id.require}", groups = UpdateGroup.class) + private String id; + private String rq; + private BigDecimal xxPlan; + private BigDecimal xxPerformance; + private BigDecimal zqPlan; + private BigDecimal zqPerformance; + private Date createDate; + private Date updateDate; +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/dto/StorageDayDTO.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/dto/StorageDayDTO.java new file mode 100644 index 0000000..c619fb1 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/dto/StorageDayDTO.java @@ -0,0 +1,31 @@ +package com.iailab.module.prod.dto; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.io.Serializable; +import java.math.BigDecimal; +import java.util.Date; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年06月01日 + */ +@Data +@Schema(name = "日仓储") +public class StorageDayDTO implements Serializable { + private static final long serialVersionUID = 1L; + + private String id; + + private String date; + + private BigDecimal caocang; + + private BigDecimal tower1; + + private BigDecimal tower2; + + private Date createDate; +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/entity/IndexEvaluateSystemEntity.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/entity/IndexEvaluateSystemEntity.java new file mode 100644 index 0000000..b808186 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/entity/IndexEvaluateSystemEntity.java @@ -0,0 +1,53 @@ +package com.iailab.module.prod.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.io.Serializable; +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("t_evaluate_index") +public class IndexEvaluateSystemEntity implements Serializable { + private static final long serialVersionUID = 1L; + + /** + * 应用id + */ + @TableId(type = IdType.ASSIGN_UUID) + private String id; + /** + * 父ID + */ + private String pid; + /** + * 编码 + */ + private String code; + /** + * 评价指标 + */ + private String evaluateIndex; + /** + * 权重 + */ + private Integer weight; + /** + * 创建人 + */ + private String creator; + /** + * 创建时间 + */ + private String createDate; + /** + * 更新人 + */ + private String updater; + /** + * 更新时间 + */ + private String updateDate; +} diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/entity/PrdCurrentPerformanceEntity.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/entity/PrdCurrentPerformanceEntity.java new file mode 100644 index 0000000..566dcbd --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/entity/PrdCurrentPerformanceEntity.java @@ -0,0 +1,29 @@ +package com.iailab.module.prod.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.io.Serializable; +import java.math.BigDecimal; +import java.util.Date; + +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("t_prd_current_performance") +public class PrdCurrentPerformanceEntity implements Serializable { + private static final long serialVersionUID = 1L; + + /** + * 应用id + */ + @TableId(type = IdType.ASSIGN_UUID) + private String id; + private String rq; + private BigDecimal xxPerformance; + private BigDecimal zqPerformance; + private Date createDate; + private Date updateDate; +} diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/entity/PrdCurrentSaleEntity.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/entity/PrdCurrentSaleEntity.java new file mode 100644 index 0000000..69eeaf8 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/entity/PrdCurrentSaleEntity.java @@ -0,0 +1,38 @@ +package com.iailab.module.prod.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.io.Serializable; +import java.math.BigDecimal; +import java.util.Date; + +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("t_prd_current_sale") +public class PrdCurrentSaleEntity implements Serializable { + private static final long serialVersionUID = 1L; + + /** + * 应用id + */ + @TableId(type = IdType.ASSIGN_UUID) + private String id; + private String rq; + @TableField(exist = false) + private String date; + private BigDecimal groundsales; + private BigDecimal medblock; + private BigDecimal nubmeasure; + private BigDecimal gangue; + private BigDecimal reshipped; + private BigDecimal trainTon; + private BigDecimal trainCount; + private Date createDate; + private Date updateDate; + +} diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/entity/PrdDayDutyEntity.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/entity/PrdDayDutyEntity.java new file mode 100644 index 0000000..18ae056 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/entity/PrdDayDutyEntity.java @@ -0,0 +1,39 @@ +package com.iailab.module.prod.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.io.Serializable; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年05月26日 + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("t_prd_day_duty") +public class PrdDayDutyEntity implements Serializable { + private static final long serialVersionUID = 1L; + + /** + * id + */ + @TableId(type = IdType.ASSIGN_UUID) + private String id; + + private String date; + + private String area; + + private String banci; + + private String banzu; + + private Integer number; + + private Integer arrive; +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/entity/PrdDayProdEntity.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/entity/PrdDayProdEntity.java new file mode 100644 index 0000000..8cc3483 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/entity/PrdDayProdEntity.java @@ -0,0 +1,33 @@ +package com.iailab.module.prod.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.io.Serializable; +import java.math.BigDecimal; +import java.util.Date; + +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("t_prd_day_prod") +public class PrdDayProdEntity implements Serializable { + private static final long serialVersionUID = 1L; + + /** + * 应用id + */ + @TableId(type = IdType.ASSIGN_UUID) + private String id; + private String rq; + private BigDecimal rawCoal; + private BigDecimal mixedCoal; + private BigDecimal mediumCoal; + private BigDecimal smallCoal; + private BigDecimal gangue; + private Date createDate; + private Date updateDate; +} + diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/entity/PrdPlanMonEntity.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/entity/PrdPlanMonEntity.java new file mode 100644 index 0000000..b8f23d0 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/entity/PrdPlanMonEntity.java @@ -0,0 +1,33 @@ + +package com.iailab.module.prod.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.io.Serializable; +import java.math.BigDecimal; +import java.util.Date; + +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("t_prd_plan_mon") +public class PrdPlanMonEntity implements Serializable { + private static final long serialVersionUID = 1L; + + /** + * 应用id + */ + @TableId(type = IdType.ASSIGN_UUID) + private String id; + private String rq; + private BigDecimal xxPlan; + private BigDecimal xxPerformance; + private BigDecimal zqPlan; + private BigDecimal zqPerformance; + private Date createDate; + private Date updateDate; + +} diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/entity/PrdPlanYearEntity.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/entity/PrdPlanYearEntity.java new file mode 100644 index 0000000..c72c027 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/entity/PrdPlanYearEntity.java @@ -0,0 +1,36 @@ + +package com.iailab.module.prod.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.io.Serializable; +import java.math.BigDecimal; +import java.util.Date; + +/** + * 年生产计划执行数据 + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("t_prd_plan_year") +public class PrdPlanYearEntity implements Serializable { + private static final long serialVersionUID = 1L; + + /** + * 应用id + */ + @TableId(type = IdType.ASSIGN_UUID) + private String id; + private String rq; + private BigDecimal xxPlan; + private BigDecimal xxPerformance; + private BigDecimal zqPlan; + private BigDecimal zqPerformance; + private Date createDate; + private Date updateDate; + +} diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/entity/PrdTimeDayEntity.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/entity/PrdTimeDayEntity.java new file mode 100644 index 0000000..d2d9fcc --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/entity/PrdTimeDayEntity.java @@ -0,0 +1,38 @@ +package com.iailab.module.prod.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.io.Serializable; +import java.math.BigDecimal; +import java.util.Date; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年06月16日 + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("t_prd_time_day") +public class PrdTimeDayEntity implements Serializable { + private static final long serialVersionUID = 1L; + + @TableId(type = IdType.ASSIGN_UUID) + private String id; + + private String date; + + private String type; + + private BigDecimal runMinutes; + + private BigDecimal overhaulMinutes; + + private BigDecimal affectMinutes; + + private Date createDate; +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/entity/StorageDayEntity.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/entity/StorageDayEntity.java new file mode 100644 index 0000000..4a2f4b1 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/entity/StorageDayEntity.java @@ -0,0 +1,36 @@ +package com.iailab.module.prod.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.io.Serializable; +import java.math.BigDecimal; +import java.util.Date; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年06月01日 + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("t_prd_storage_day") +public class StorageDayEntity implements Serializable { + private static final long serialVersionUID = 1L; + + @TableId(type = IdType.ASSIGN_UUID) + private String id; + + private String date; + + private BigDecimal caocang; + + private BigDecimal tower1; + + private BigDecimal tower2; + + private Date createDate; +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/service/IndexEvaluateSystemService.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/service/IndexEvaluateSystemService.java new file mode 100644 index 0000000..7e0e0ce --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/service/IndexEvaluateSystemService.java @@ -0,0 +1,35 @@ +package com.iailab.module.prod.service; + +import com.iailab.common.dto.echarts.BarLineDTO; +import com.iailab.framework.common.page.PageData; +import com.iailab.framework.common.service.BaseService; +import com.iailab.module.prod.dto.IndexEvaluateSystemDTO; +import com.iailab.module.prod.entity.IndexEvaluateSystemEntity; + +import java.util.List; +import java.util.Map; + +public interface IndexEvaluateSystemService extends BaseService<IndexEvaluateSystemEntity> { + + PageData<IndexEvaluateSystemDTO> page(Map<String, Object> params); + + IndexEvaluateSystemDTO get(String id); + + void save(IndexEvaluateSystemDTO dto); + + void update(IndexEvaluateSystemDTO dto); + + void delete(String[] ids); + + List<IndexEvaluateSystemEntity> list(String id); + + Map<String,String> systemWeightList(); + + void updataSystemWeight(Map<String, String> params); + + BarLineDTO getChart(String pid); + + void updataWeight(List<IndexEvaluateSystemEntity> list); + + List<Double> getWeight(); +} diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/service/PageCharsService.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/service/PageCharsService.java new file mode 100644 index 0000000..097c88f --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/service/PageCharsService.java @@ -0,0 +1,9 @@ +package com.iailab.module.prod.service; + +import com.iailab.module.prod.dto.PageCharsDTO; + +import java.util.List; + +public interface PageCharsService { + List<PageCharsDTO> getData(String page); +} diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/service/PrdCurrentPerformanceService.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/service/PrdCurrentPerformanceService.java new file mode 100644 index 0000000..66a0e3b --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/service/PrdCurrentPerformanceService.java @@ -0,0 +1,30 @@ +package com.iailab.module.prod.service; + + +import com.iailab.common.dto.echarts.BarLineDTO; +import com.iailab.framework.common.page.PageData; +import com.iailab.module.prod.dto.PrdCurrentPerformanceDTO; +import org.springframework.stereotype.Service; + +import java.math.BigDecimal; +import java.util.Map; + +@Service +public interface PrdCurrentPerformanceService { + + BarLineDTO barLine(String length); + + BigDecimal currentValue(); + + PageData<PrdCurrentPerformanceDTO> page(Map<String, Object> params); + + PrdCurrentPerformanceDTO get(String id); + + void save(PrdCurrentPerformanceDTO dto); + + void update(PrdCurrentPerformanceDTO dto); + + void delete(String[] ids); + + void syncData(); +} diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/service/PrdCurrentSaleService.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/service/PrdCurrentSaleService.java new file mode 100644 index 0000000..f744d57 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/service/PrdCurrentSaleService.java @@ -0,0 +1,34 @@ +package com.iailab.module.prod.service; + +import com.iailab.common.dto.echarts.BarLineDTO; +import com.iailab.framework.common.page.PageData; +import com.iailab.framework.common.service.BaseService; +import com.iailab.module.prod.dto.PrdCurrentSaleDTO; +import com.iailab.module.prod.entity.PrdCurrentSaleEntity; + +import java.math.BigDecimal; +import java.util.Map; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年05月14日 + */ +public interface PrdCurrentSaleService extends BaseService<PrdCurrentSaleEntity> { + + BarLineDTO barLine(String length,String Type); + + BigDecimal currentValue(String Type); + + PageData<PrdCurrentSaleDTO> page(Map<String, Object> params); + + PrdCurrentSaleDTO get(String id); + + void save(PrdCurrentSaleDTO dto); + + void update(PrdCurrentSaleDTO dto); + + void delete(String[] ids); + + void syncData(); +} diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/service/PrdDayDutyService.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/service/PrdDayDutyService.java new file mode 100644 index 0000000..f57cd04 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/service/PrdDayDutyService.java @@ -0,0 +1,14 @@ +package com.iailab.module.prod.service; + +import com.iailab.framework.common.service.BaseService; +import com.iailab.module.prod.entity.PrdDayDutyEntity; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年05月26日 + */ +public interface PrdDayDutyService extends BaseService<PrdDayDutyEntity> { + + void syncData(); +} diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/service/PrdDayProdService.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/service/PrdDayProdService.java new file mode 100644 index 0000000..4e5b94d --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/service/PrdDayProdService.java @@ -0,0 +1,35 @@ + +package com.iailab.module.prod.service; + +import com.iailab.common.dto.echarts.BarLineDTO; +import com.iailab.framework.common.page.PageData; +import com.iailab.framework.common.service.BaseService; +import com.iailab.module.prod.dto.PrdDayProdDTO; +import com.iailab.module.prod.entity.PrdDayProdEntity; + +import java.math.BigDecimal; +import java.util.Map; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年05月14日 + */ +public interface PrdDayProdService extends BaseService<PrdDayProdEntity> { + + BarLineDTO barLine(String length,String param); + + BigDecimal currentValue(String param); + + PageData<PrdDayProdDTO> page(Map<String, Object> params); + + PrdDayProdDTO get(String id); + + void save(PrdDayProdDTO dto); + + void update(PrdDayProdDTO dto); + + void delete(String[] ids); + + void syncData(String paramDate); +} diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/service/PrdPlanMonService.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/service/PrdPlanMonService.java new file mode 100644 index 0000000..c027da6 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/service/PrdPlanMonService.java @@ -0,0 +1,35 @@ + +package com.iailab.module.prod.service; + +import com.iailab.common.dto.echarts.BarLineDTO; +import com.iailab.framework.common.page.PageData; +import com.iailab.framework.common.service.BaseService; +import com.iailab.module.prod.dto.PrdPlanMonDTO; +import com.iailab.module.prod.entity.PrdPlanMonEntity; + +import java.math.BigDecimal; +import java.util.Map; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年05月14日 + */ +public interface PrdPlanMonService extends BaseService<PrdPlanMonEntity> { + + BarLineDTO barLine(String length); + + BigDecimal currentValue(); + + PageData<PrdPlanMonDTO> page(Map<String, Object> params); + + PrdPlanMonDTO get(String id); + + void save(PrdPlanMonDTO dto); + + void update(PrdPlanMonDTO dto); + + void delete(String[] ids); + + void syncData(); +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/service/PrdPlanYearService.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/service/PrdPlanYearService.java new file mode 100644 index 0000000..3cb542f --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/service/PrdPlanYearService.java @@ -0,0 +1,35 @@ + +package com.iailab.module.prod.service; + +import com.iailab.common.dto.echarts.BarLineDTO; +import com.iailab.framework.common.page.PageData; +import com.iailab.framework.common.service.BaseService; +import com.iailab.module.prod.dto.PrdPlanYearDTO; +import com.iailab.module.prod.entity.PrdPlanYearEntity; + +import java.math.BigDecimal; +import java.util.Map; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年05月14日 + */ +public interface PrdPlanYearService extends BaseService<PrdPlanYearEntity> { + + BarLineDTO barLine(String length); + + BigDecimal currentValue(); + + PageData<PrdPlanYearDTO> page(Map<String, Object> params); + + PrdPlanYearDTO get(String id); + + void save(PrdPlanYearDTO dto); + + void update(PrdPlanYearDTO dto); + + void delete(String[] ids); + + void syncData(); +} diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/service/PrdTimeDayService.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/service/PrdTimeDayService.java new file mode 100644 index 0000000..b7b3a07 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/service/PrdTimeDayService.java @@ -0,0 +1,14 @@ +package com.iailab.module.prod.service; + +import com.iailab.framework.common.service.BaseService; +import com.iailab.module.prod.entity.PrdTimeDayEntity; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年06月16日 + */ +public interface PrdTimeDayService extends BaseService<PrdTimeDayEntity> { + + void syncData(String iRq); +} diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/service/StorageDayService.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/service/StorageDayService.java new file mode 100644 index 0000000..891edf1 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/service/StorageDayService.java @@ -0,0 +1,14 @@ +package com.iailab.module.prod.service; + +import com.iailab.framework.common.service.BaseService; +import com.iailab.module.prod.entity.StorageDayEntity; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年06月01日 + */ +public interface StorageDayService extends BaseService<StorageDayEntity> { + + void syncData(); +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/service/impl/IndexEvaluateSystemServiceImpl.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/service/impl/IndexEvaluateSystemServiceImpl.java new file mode 100644 index 0000000..3d92d37 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/service/impl/IndexEvaluateSystemServiceImpl.java @@ -0,0 +1,169 @@ +package com.iailab.module.prod.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.iailab.framework.common.constant.Constant; +import com.iailab.common.dto.echarts.BarLineDTO; +import com.iailab.common.dto.echarts.SeriesItem; +import com.iailab.framework.common.page.PageData; +import com.iailab.framework.common.service.impl.BaseServiceImpl; +import com.iailab.framework.common.util.object.ConvertUtils; +import com.iailab.module.prod.dao.IndexEvaluateSystemDao; +import com.iailab.module.prod.dto.IndexEvaluateSystemDTO; +import com.iailab.module.prod.entity.IndexEvaluateSystemEntity; +import com.iailab.module.prod.service.IndexEvaluateSystemService; +import org.apache.commons.lang3.StringUtils; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.util.CollectionUtils; + +import java.math.BigDecimal; +import java.util.*; + +@Service +public class IndexEvaluateSystemServiceImpl extends BaseServiceImpl<IndexEvaluateSystemDao, IndexEvaluateSystemEntity> implements IndexEvaluateSystemService { + + @Override + public PageData<IndexEvaluateSystemDTO> page(Map<String, Object> params) { + IPage<IndexEvaluateSystemEntity> page = baseDao.selectPage( + getPage(params, Constant.CREATE_DATE, false), + getWrapper(params) + ); + return getPageData(page, IndexEvaluateSystemDTO.class); + } + + private QueryWrapper<IndexEvaluateSystemEntity> getWrapper(Map<String, Object> params) { + String pid = (String) params.get("pid"); + + QueryWrapper<IndexEvaluateSystemEntity> wrapper = new QueryWrapper<>(); + wrapper.eq(StringUtils.isNotBlank("pid"), "pid", pid); + + return wrapper; + } + + @Override + public IndexEvaluateSystemDTO get(String id) { + IndexEvaluateSystemEntity entity = baseDao.selectById(id); + + return ConvertUtils.sourceToTarget(entity, IndexEvaluateSystemDTO.class); + } + + @Override + public void save(IndexEvaluateSystemDTO dto) { + IndexEvaluateSystemEntity entity = ConvertUtils.sourceToTarget(dto, IndexEvaluateSystemEntity.class); + + insert(entity); + } + + @Override + public void update(IndexEvaluateSystemDTO dto) { + IndexEvaluateSystemEntity entity = ConvertUtils.sourceToTarget(dto, IndexEvaluateSystemEntity.class); + + updateById(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void delete(String[] ids) { + baseDao.deleteBatchIds(Arrays.asList(ids)); + } + + @Override + public List<IndexEvaluateSystemEntity> list(String pid) { + List<IndexEvaluateSystemEntity> list = baseDao.selectList(new QueryWrapper<IndexEvaluateSystemEntity>().eq("pid", pid)); + return list; + } + + @Override + public Map<String, String> systemWeightList() { + Map map = new HashMap(); + List<IndexEvaluateSystemEntity> list = baseDao.selectList(new QueryWrapper<IndexEvaluateSystemEntity>().eq("pid", 0)); + list.stream().forEach( + item -> { + map.put(item.getCode(), item.getWeight()); + } + ); + return map; + } + + @Override + public BarLineDTO getChart(String pid) { + BarLineDTO barLineDTO = new BarLineDTO(); + List<SeriesItem> series = new ArrayList<>(); + List<Object[]> data = new ArrayList<>(); + SeriesItem seriesItem = new SeriesItem(); + List<String> legend = new ArrayList<>(); + List<IndexEvaluateSystemEntity> list = baseDao.selectList(new QueryWrapper<IndexEvaluateSystemEntity>().eq("pid", pid)); + Object[] objects = new Object[list.size()]; + for (int i = 0; i < list.size(); i++) { + legend.add(list.get(i).getEvaluateIndex()); + Map<String, String> map = new HashMap<>(); + map.put("value", list.get(i).getWeight() == null ? "" : list.get(i).getWeight().toString()); + map.put("name", list.get(i).getEvaluateIndex()); + objects[i] = map; + } + data.add(objects); + seriesItem.setData(data); + series.add(seriesItem); + barLineDTO.setSeries(series); + barLineDTO.setLegend(legend); + return barLineDTO; + } + + @Override + public void updataWeight(List<IndexEvaluateSystemEntity> list) { + list.stream().forEach( + item -> { + baseDao.updateById(item); + } + ); + } + + @Override + public void updataSystemWeight(Map<String, String> params) { + String number = params.get("number"); + String quality = params.get("quality"); + String consume = params.get("consume"); + String process = params.get("process"); + String manage = params.get("manage"); + + IndexEvaluateSystemEntity numberEntity = baseDao.selectOne(new QueryWrapper<IndexEvaluateSystemEntity>().eq("code", "SYS0001")); + numberEntity.setWeight(Integer.parseInt(number)); + + IndexEvaluateSystemEntity qualityEntity = baseDao.selectOne(new QueryWrapper<IndexEvaluateSystemEntity>().eq("code", "SYS0002")); + qualityEntity.setWeight(Integer.parseInt(quality)); + + IndexEvaluateSystemEntity consumeEntity = baseDao.selectOne(new QueryWrapper<IndexEvaluateSystemEntity>().eq("code", "SYS0003")); + consumeEntity.setWeight(Integer.parseInt(consume)); + + IndexEvaluateSystemEntity processEntity = baseDao.selectOne(new QueryWrapper<IndexEvaluateSystemEntity>().eq("code", "SYS0004")); + processEntity.setWeight(Integer.parseInt(process)); + + IndexEvaluateSystemEntity manageEntity = baseDao.selectOne(new QueryWrapper<IndexEvaluateSystemEntity>().eq("code", "SYS0005")); + manageEntity.setWeight(Integer.parseInt(manage)); + + baseDao.updateById(numberEntity); + baseDao.updateById(qualityEntity); + baseDao.updateById(consumeEntity); + baseDao.updateById(processEntity); + baseDao.updateById(manageEntity); + } + + + @Override + public List<Double> getWeight() { + BigDecimal val100 = new BigDecimal("100"); + List<Double> result = new ArrayList<>(); + QueryWrapper<IndexEvaluateSystemEntity> wrapper = new QueryWrapper<>(); + wrapper.orderByAsc("sort"); + List<IndexEvaluateSystemEntity> list = baseDao.selectList(wrapper); + if (CollectionUtils.isEmpty(list)) { + return result; + } + list.forEach(item -> { + result.add(new BigDecimal(item.getWeight()).divide(val100, 3, BigDecimal.ROUND_HALF_UP).doubleValue()); + }); + return result; + } + +} diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/service/impl/PageCharsServiceImpl.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/service/impl/PageCharsServiceImpl.java new file mode 100644 index 0000000..eed4f42 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/service/impl/PageCharsServiceImpl.java @@ -0,0 +1,295 @@ +package com.iailab.module.prod.service.impl; + +import com.iailab.common.dto.echarts.BarLineDTO; +import com.iailab.common.dto.echarts.SeriesItem; +import com.iailab.common.enums.CdbmEnum; +import com.iailab.common.utils.HttpsRequest; +import com.iailab.module.data.dto.FeignQueryPointDTO; +import com.iailab.module.data.dto.ApiDataDTO; +import com.iailab.module.data.api.IFeignDataApi; +import com.iailab.module.param.service.PageParmService; +import com.iailab.module.prod.dto.PageCharsDTO; +import com.iailab.module.quality.service.QualityQualityTrendDayService; +import com.iailab.module.prod.service.*; +import javax.annotation.Resource; +import org.springframework.stereotype.Service; + +import java.math.BigDecimal; +import java.util.*; + +@Service +public class PageCharsServiceImpl implements PageCharsService { + + @Resource + private IFeignDataApi iFeignDataApi; + + @Resource + private HttpsRequest httpsRequest; + + @Resource + private PageParmService pageParmService; + + @Resource + private PrdCurrentPerformanceService prdCurrentPerformanceService; + + @Resource + private PrdCurrentSaleService prdCurrentSaleService; + + @Resource + private PrdDayProdService prdDayProdService; + + @Resource + private PrdPlanMonService prdPlanMonService; + + @Resource + private PrdPlanYearService prdPlanYearService; + + @Resource + private QualityQualityTrendDayService qualityQualityTrendDayService; + + @Override + public List<PageCharsDTO> getData(String page) { + + String chars = pageParmService.selectValue(page, "chars"); + String length = pageParmService.selectValue(page, "length"); + String pointLength = pageParmService.selectValue(page, "point_length"); + String coal = pageParmService.selectValue(page, "coal"); + String point = pageParmService.selectValue(page, "point")==null?"":pageParmService.selectValue(page, "point"); + List<String> coalList = Arrays.asList(coal.split(";")); + List<String> pointList = Arrays.asList(point.split(";")); + List<String> charsCodeList = Arrays.asList(chars.split(";")); + List<PageCharsDTO> list = new ArrayList<>(); + charsCodeList.stream().forEach( + item -> { + //如果数据源为报表,类型为煤质或产量,传一个煤种参数 + if(CdbmEnum.HF.getCode().equals(item)||CdbmEnum.LF.getCode().equals(item)||CdbmEnum.SF.getCode().equals(item)||CdbmEnum.RZ.getCode().equals(item)||CdbmEnum.CL.getCode().equals(item)) { + coalList.stream().forEach( + coalItem->{ + list.add(getPageChars(item, length,coalItem)); + } + ); + }else if(item.equals("point")){ + //如果数据源为point,传一个测点参数 + pointList.stream().forEach( + pointItem->{ + list.add(getPageChars(item,pointLength,pointItem)); + } + ); + }else { + list.add(getPageChars(item, length,"")); + } + } + ); + + return list; + } + + public PageCharsDTO getPageChars(String charsCode, String length,String param) { + PageCharsDTO dto = new PageCharsDTO(); + BarLineDTO barLine; + + try { + switch (charsCode) { + case "plan": + //计划 + barLine = prdPlanMonService.barLine(length); + dto.setCurrentValue(prdPlanMonService.currentValue()==null?new BigDecimal(0):prdPlanMonService.currentValue()); + dto.setBarLineDTO(barLine); + dto.setUnit(CdbmEnum.getEumByCode("plan").getUnit()); + dto.setLength(length); + //调用模型方法 + this.run(dto); + break; + case "cl": + //产量 + barLine = prdDayProdService.barLine(length,param); + dto.setCurrentValue(prdDayProdService.currentValue(param)==null?new BigDecimal(0):prdDayProdService.currentValue(param)); + dto.setBarLineDTO(barLine); + dto.setUnit(CdbmEnum.getEumByCode("cl").getUnit()); + dto.setLength(length); + //调用模型方法 + this.run(dto); + break; + case "groundsales": + //地销混煤 + barLine = prdCurrentSaleService.barLine(length,"groundsales"); + dto.setCurrentValue(prdCurrentSaleService.currentValue("groundsales")==null?new BigDecimal(0):prdCurrentSaleService.currentValue("groundsales")); + dto.setBarLineDTO(barLine); + dto.setUnit(CdbmEnum.getEumByCode("groundsales").getUnit()); + dto.setLength(length); + //调用模型方法 + this.run(dto); + break; + case "medblock": + //洗中块外运 + barLine = prdCurrentSaleService.barLine(length,"medblock"); + dto.setCurrentValue(prdCurrentSaleService.currentValue("medblock")==null?new BigDecimal(0):prdCurrentSaleService.currentValue("medblock")); + dto.setBarLineDTO(barLine); + dto.setUnit(CdbmEnum.getEumByCode("medblock").getUnit()); + dto.setLength(length); + //调用模型方法 + this.run(dto); + break; + case "nubmeasure": + //洗小块外运 + barLine = prdCurrentSaleService.barLine(length,"nubmeasure"); + dto.setCurrentValue(prdCurrentSaleService.currentValue("nubmeasure")==null?new BigDecimal(0):prdCurrentSaleService.currentValue("nubmeasure")); + dto.setBarLineDTO(barLine); + dto.setLength(length); + dto.setUnit(CdbmEnum.getEumByCode("nubmeasure").getUnit()); + //调用模型方法 + this.run(dto); + break; + case "gangue": + //矸石外运 + barLine = prdCurrentSaleService.barLine(length,"gangue"); + dto.setCurrentValue(prdCurrentSaleService.currentValue("gangue")==null?new BigDecimal(0):prdCurrentSaleService.currentValue("gangue")); + dto.setBarLineDTO(barLine); + dto.setUnit(CdbmEnum.getEumByCode("gangue").getUnit()); + dto.setLength(length); + //调用模型方法 + this.run(dto); + break; + case "reshipped": + //小块转载 + barLine = prdCurrentSaleService.barLine(length,"reshipped"); + dto.setCurrentValue(prdCurrentSaleService.currentValue("reshipped")==null?new BigDecimal(0):prdCurrentSaleService.currentValue("reshipped")); + dto.setBarLineDTO(barLine); + dto.setUnit(CdbmEnum.getEumByCode("reshipped").getUnit()); + dto.setLength(length); + //调用模型方法 + this.run(dto); + break; + case "trainTon": + //火车外运吨数 + barLine = prdCurrentSaleService.barLine(length,"trainTon"); + dto.setCurrentValue(prdCurrentSaleService.currentValue("trainTon")==null?new BigDecimal(0):prdCurrentSaleService.currentValue("trainTon")); + dto.setBarLineDTO(barLine); + dto.setUnit(CdbmEnum.getEumByCode("trainTon").getUnit()); + //调用模型方法 + this.run(dto); + break; + case "trainCount": + //火车外运列数 + barLine = prdCurrentSaleService.barLine(length,"trainCount"); + dto.setCurrentValue(prdCurrentSaleService.currentValue("trainCount")==null?new BigDecimal(0):prdCurrentSaleService.currentValue("trainCount")); + dto.setBarLineDTO(barLine); + dto.setUnit(CdbmEnum.getEumByCode("trainCount").getUnit()); + dto.setLength(length); + //调用模型方法 + this.run(dto); + break; + case "dbl": + //达标率 + dto.setUnit(CdbmEnum.getEumByCode("dbl").getUnit()); + barLine = prdDayProdService.barLine(length,"dbl"); + dto.setCurrentValue(prdDayProdService.currentValue("dbl")==null?new BigDecimal(0):prdDayProdService.currentValue("dbl")); + dto.setBarLineDTO(barLine); + dto.setLength(length); + //调用模型方法 + this.run(dto); + break; + case "hf": + //灰分 + barLine = qualityQualityTrendDayService.barLine(length,"hf",param); + dto.setCurrentValue(qualityQualityTrendDayService.currentValue(param,"hf")==null?new BigDecimal(0):qualityQualityTrendDayService.currentValue(param,"hf")); + dto.setBarLineDTO(barLine); + dto.setUnit(CdbmEnum.getEumByCode("hf").getUnit()); + dto.setLength(length); + //调用模型方法 + this.run(dto); + break; + case "lf": + //硫分 + barLine = qualityQualityTrendDayService.barLine(length,"lf",param); + dto.setCurrentValue(qualityQualityTrendDayService.currentValue(param,"lf")==null?new BigDecimal(0):qualityQualityTrendDayService.currentValue(param,"lf")); + dto.setBarLineDTO(barLine); + dto.setUnit(CdbmEnum.getEumByCode("lf").getUnit()); + dto.setLength(length); + //调用模型方法 + this.run(dto); + break; + case "sf": + //水分 + barLine = qualityQualityTrendDayService.barLine(length,"sf",param); + dto.setCurrentValue(qualityQualityTrendDayService.currentValue(param,"sf")==null?new BigDecimal(0):qualityQualityTrendDayService.currentValue(param,"sf")); + dto.setBarLineDTO(barLine); + dto.setUnit(CdbmEnum.getEumByCode("sf").getUnit()); + dto.setLength(length); + //调用模型方法 + this.run(dto); + break; + case "rz": + //热值 + barLine = qualityQualityTrendDayService.barLine(length,"rz",param); + dto.setCurrentValue(qualityQualityTrendDayService.currentValue(param,"rz")==null?new BigDecimal(0):qualityQualityTrendDayService.currentValue(param,"rz")); + dto.setBarLineDTO(barLine); + dto.setUnit(CdbmEnum.getEumByCode("rz").getUnit()); + dto.setLength(length); + //调用模型方法 + this.run(dto); + break; + case "point": + //测点 + barLine = this.pointBarline(param,length); + + dto.setBarLineDTO(barLine); + dto.setUnit(CdbmEnum.getEumByName(param).getUnit()); + dto.setLength(length); + //调用模型方法 + this.run(dto); + break; + default: + break; + } + }catch (Exception e){ + e.printStackTrace(); + System.out.println(charsCode+"查图表渲染异常" + e.getMessage()); + } + return dto; + } + + private BarLineDTO pointBarline(String param,String length) { + + FeignQueryPointDTO dto = new FeignQueryPointDTO(); + dto.setEndTime(new Date()); + Calendar calendar = Calendar.getInstance(); + calendar.setTime(new Date()); + calendar.add(Calendar.DAY_OF_YEAR, -Integer.parseInt(length)); + dto.setStartTime(calendar.getTime()); + dto.setPointCode(CdbmEnum.getEumByName(param).getCode()); + dto.setType("float"); + List<ApiDataDTO> list = iFeignDataApi.queryPointValues(dto); + + //封装echarsDto + BarLineDTO barLineDTO = new BarLineDTO(); + List<String> legend = new ArrayList<>(); + List<String> categories = new ArrayList<>(); + List<SeriesItem> series = new ArrayList<>(); + SeriesItem seriesItem = new SeriesItem(); + seriesItem.setName(CdbmEnum.getEumByName(param).getDesc()); + List<Object[]> seriesData = new ArrayList<>(); + for (ApiDataDTO entity : list) { + // 将数据作为图表数据 + seriesData.add(new Object[]{entity.getTimeStamp(), entity.getDataValue()}); + } + seriesItem.setData(seriesData); + series.add(seriesItem); + barLineDTO.setLegend(legend); + barLineDTO.setSeries(series); + barLineDTO.setValueName(CdbmEnum.getEumByName(param).getDesc()); + + return barLineDTO; + + } + + + private PageCharsDTO run(PageCharsDTO dto){ + dto.setSuggest("暂无建议"); + dto.setSuggestTime(new Date()); + dto.setAvg(""); + dto.setMax(""); + dto.setMin(""); + return dto; + } +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/service/impl/PrdCurrentPerformanceServiceImpl.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/service/impl/PrdCurrentPerformanceServiceImpl.java new file mode 100644 index 0000000..5e29730 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/service/impl/PrdCurrentPerformanceServiceImpl.java @@ -0,0 +1,152 @@ +package com.iailab.module.prod.service.impl; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.iailab.framework.common.constant.Constant; +import com.iailab.common.dto.echarts.BarLineDTO; +import com.iailab.common.enums.CommonConstant; +import com.iailab.framework.common.page.PageData; +import com.iailab.framework.common.service.impl.BaseServiceImpl; +import com.iailab.common.utils.CommonUtils; +import com.iailab.framework.common.util.object.ConvertUtils; +import com.iailab.common.utils.DateUtils; +import com.iailab.common.utils.HttpsRequest; +import com.iailab.module.data.dto.FeignHttpApiDTO; +import com.iailab.module.data.api.IFeignDataApi; +import com.iailab.module.prod.dao.PrdCurrentPerformanceDao; +import com.iailab.module.prod.dto.PrdCurrentPerformanceDTO; +import com.iailab.module.prod.entity.PrdCurrentPerformanceEntity; +import com.iailab.module.prod.service.PrdCurrentPerformanceService; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import javax.annotation.Resource; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.math.BigDecimal; +import java.time.LocalDate; +import java.time.format.DateTimeFormatter; +import java.util.*; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年05月14日 + */ +@Slf4j +@Service +public class PrdCurrentPerformanceServiceImpl extends BaseServiceImpl<PrdCurrentPerformanceDao, PrdCurrentPerformanceEntity> implements PrdCurrentPerformanceService { + + private String HTTP_API_CODE = "Prd.CurrentPerformance"; + + @Resource + private IFeignDataApi feignDataApi; + + @Resource + private HttpsRequest httpsRequest; + + @Override + public PageData<PrdCurrentPerformanceDTO> page(Map<String, Object> params) { + IPage<PrdCurrentPerformanceEntity> page = baseDao.selectPage( + getPage(params, Constant.CREATE_DATE, false), + getWrapper(params) + ); + return getPageData(page, PrdCurrentPerformanceDTO.class); + } + + private QueryWrapper<PrdCurrentPerformanceEntity> getWrapper(Map<String, Object> params){ + String rq = (String)params.get("rq"); + + QueryWrapper<PrdCurrentPerformanceEntity> wrapper = new QueryWrapper<>(); + wrapper.eq(StringUtils.isNotBlank(rq), "rq", rq) + .orderByAsc("rq"); + + return wrapper; + } + + @Override + public PrdCurrentPerformanceDTO get(String id) { + PrdCurrentPerformanceEntity entity = baseDao.selectById(id); + + return ConvertUtils.sourceToTarget(entity, PrdCurrentPerformanceDTO.class); + } + + @Override + public void save(PrdCurrentPerformanceDTO dto) { + PrdCurrentPerformanceEntity entity = ConvertUtils.sourceToTarget(dto, PrdCurrentPerformanceEntity.class); + + insert(entity); + } + + @Override + public void update(PrdCurrentPerformanceDTO dto) { + PrdCurrentPerformanceEntity entity = ConvertUtils.sourceToTarget(dto, PrdCurrentPerformanceEntity.class); + + updateById(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void delete(String[] ids) { + baseDao.deleteBatchIds(Arrays.asList(ids)); + } + + @Override + public BarLineDTO barLine(String length) { + return null; + } + + @Override + public BigDecimal currentValue() { + return null; + } + + public List<String> getLastMonthDates() { + List<String> dateList = new ArrayList<>(); + LocalDate currentDate = LocalDate.now(); + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + for (int i = 29; i >= 0; i--) { + dateList.add(currentDate.minusDays(i).format(formatter)); + } + + return dateList; + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void syncData() { + FeignHttpApiDTO apiDTO = feignDataApi.getHttpApi(HTTP_API_CODE); + Map<String, String> params = new HashMap<>(); + String responseStr = httpsRequest.doGet(apiDTO.getUrl(), params, "utf-8", ""); + JSONObject responseObj = JSON.parseObject(responseStr); + if (!CommonConstant.STA_TRUE.equals(responseObj.get("sta").toString())) { + log.info("接口异常"); + } + JSONObject res = responseObj.getJSONObject(CommonConstant.ZX_RES); + JSONObject yesterday = res.getJSONObject("yesterday"); + if (yesterday == null) { + return; + } + Calendar calendar = Calendar.getInstance(); + calendar.add(Calendar.DAY_OF_YEAR, -1); + String rq = DateUtils.format(calendar.getTime()); + this.deleteByRq(rq); + PrdCurrentPerformanceEntity entity = new PrdCurrentPerformanceEntity(); + entity.setId(UUID.randomUUID().toString()); + entity.setRq(rq); + entity.setXxPerformance(CommonUtils.getJSONValue(yesterday.get("xxPerformance"))); + entity.setZqPerformance(CommonUtils.getJSONValue(yesterday.get("zqPerformance"))); + entity.setCreateDate(new Date()); + entity.setUpdateDate(new Date()); + insert(entity); + + } + + private void deleteByRq(String rq) { + QueryWrapper<PrdCurrentPerformanceEntity> wrapper = new QueryWrapper<>(); + wrapper.eq(StringUtils.isNotBlank(rq), "rq", rq); + baseDao.delete(wrapper); + } +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/service/impl/PrdCurrentSaleServiceImpl.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/service/impl/PrdCurrentSaleServiceImpl.java new file mode 100644 index 0000000..1a9b66e --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/service/impl/PrdCurrentSaleServiceImpl.java @@ -0,0 +1,342 @@ + +package com.iailab.module.prod.service.impl; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.iailab.framework.common.constant.Constant; +import com.iailab.common.dto.echarts.BarLineDTO; +import com.iailab.common.dto.echarts.SeriesItem; +import com.iailab.common.enums.CommonConstant; +import com.iailab.framework.common.page.PageData; +import com.iailab.framework.common.service.impl.BaseServiceImpl; +import com.iailab.framework.common.util.object.ConvertUtils; +import com.iailab.common.utils.DateUtils; +import com.iailab.common.utils.HttpsRequest; +import com.iailab.module.data.dto.FeignHttpApiDTO; +import com.iailab.module.data.api.IFeignDataApi; +import com.iailab.module.prod.dao.PrdCurrentSaleDao; +import com.iailab.module.prod.dto.PrdCurrentSaleDTO; +import com.iailab.module.prod.entity.PrdCurrentSaleEntity; +import com.iailab.module.prod.service.PrdCurrentSaleService; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import javax.annotation.Resource; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.util.CollectionUtils; + +import javax.annotation.Resource; +import java.math.BigDecimal; +import java.text.SimpleDateFormat; +import java.time.LocalDate; +import java.time.format.DateTimeFormatter; +import java.util.*; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年05月14日 + */ +@Slf4j +@Service +public class PrdCurrentSaleServiceImpl extends BaseServiceImpl<PrdCurrentSaleDao, PrdCurrentSaleEntity> implements PrdCurrentSaleService { + + private String HTTP_API_CODE = "Prd.SaleTrendDay"; + + @Resource + private IFeignDataApi feignDataApi; + + @Resource + private HttpsRequest httpsRequest; + + @Resource + private PrdCurrentSaleDao prdCurrentSaleDao; + + @Override + public PageData<PrdCurrentSaleDTO> page(Map<String, Object> params) { + IPage<PrdCurrentSaleEntity> page = baseDao.selectPage( + getPage(params, Constant.CREATE_DATE, false), + getWrapper(params) + ); + return getPageData(page, PrdCurrentSaleDTO.class); + } + + private QueryWrapper<PrdCurrentSaleEntity> getWrapper(Map<String, Object> params){ + String rq = (String)params.get("rq"); + + QueryWrapper<PrdCurrentSaleEntity> wrapper = new QueryWrapper<>(); + wrapper.eq(StringUtils.isNotBlank(rq), "rq", rq) + .orderByAsc("rq"); + + return wrapper; + } + + @Override + public PrdCurrentSaleDTO get(String id) { + PrdCurrentSaleEntity entity = baseDao.selectById(id); + + return ConvertUtils.sourceToTarget(entity, PrdCurrentSaleDTO.class); + } + + @Override + public void save(PrdCurrentSaleDTO dto) { + PrdCurrentSaleEntity entity = ConvertUtils.sourceToTarget(dto, PrdCurrentSaleEntity.class); + + insert(entity); + } + + @Override + public void update(PrdCurrentSaleDTO dto) { + PrdCurrentSaleEntity entity = ConvertUtils.sourceToTarget(dto, PrdCurrentSaleEntity.class); + + updateById(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void delete(String[] ids) { + baseDao.deleteBatchIds(Arrays.asList(ids)); + } + + @Override + public BarLineDTO barLine(String length,String type) { + + BarLineDTO barLineDTO = new BarLineDTO(); + List<SeriesItem> seriesItemList = new ArrayList<>(); + List<Object[]> data = new ArrayList(); + + switch (type) { + case "groundsales": + this.list().stream().forEach( + item->{ + Object[] dataItem = new Object[2]; + dataItem[0] = item.getRq(); + dataItem[1] = item.getGroundsales(); + if(item.getGroundsales()!=null){ + data.add(dataItem); + } + barLineDTO.setValueName("地销混煤"); + } + ); + break; + case "medblock": + this.list().stream().forEach( + item->{ + Object[] dataItem = new Object[2]; + dataItem[0] = item.getRq(); + dataItem[1] = item.getMedblock(); + if(item.getMedblock()!=null){ + data.add(dataItem); + } + barLineDTO.setValueName("洗中块外运"); + } + ); + break; + case "nubmeasure": + this.list().stream().forEach( + item->{ + Object[] dataItem = new Object[2]; + dataItem[0] = item.getRq(); + dataItem[1] = item.getNubmeasure(); + if(item.getNubmeasure()!=null){ + data.add(dataItem); + } + barLineDTO.setValueName("洗小块外运"); + } + ); + break; + case "gangue": + this.list().stream().forEach( + item->{ + Object[] dataItem = new Object[2]; + dataItem[0] = item.getRq(); + dataItem[1] = item.getGangue(); + if(item.getGangue()!=null){ + data.add(dataItem); + } + barLineDTO.setValueName("矸石外运"); + } + ); + break; + case "reshipped": + this.list().stream().forEach( + item->{ + Object[] dataItem = new Object[2]; + dataItem[0] = item.getRq(); + dataItem[1] = item.getReshipped(); + if(item.getReshipped()!=null){ + data.add(dataItem); + } + barLineDTO.setValueName("小块转载"); + } + ); + break; + case "trainTon": + this.list().stream().forEach( + item->{ + Object[] dataItem = new Object[2]; + dataItem[0] = item.getRq(); + dataItem[1] = item.getTrainTon(); + if(item.getGangue()!=null){ + data.add(dataItem); + } + barLineDTO.setValueName("火车外运吨数"); + } + ); + break; + case "trainCount": + this.list().stream().forEach( + item->{ + Object[] dataItem = new Object[2]; + dataItem[0] = item.getRq(); + dataItem[1] = item.getTrainCount(); + if(item.getGangue()!=null){ + data.add(dataItem); + } + barLineDTO.setValueName("火车外运列数"); + } + ); + break; + default: + break; + } + + SeriesItem seriesItem = new SeriesItem(); + seriesItem.setData(data); + seriesItemList.add(seriesItem); + //barLineDTO.setLegend(this.getLastMonthDates(Integer.parseInt(length))); + barLineDTO.setSeries(seriesItemList); + return barLineDTO; + } + + @Override + public BigDecimal currentValue(String type) { + switch (type) { + case "groundsales": + //地销混煤 + return baseDao.selectOne( + new QueryWrapper<PrdCurrentSaleEntity>() + .eq("rq",new SimpleDateFormat("yyyy-MM-dd").format(new Date())))==null + ?new BigDecimal(0) + :baseDao.selectOne( + new QueryWrapper<PrdCurrentSaleEntity>() + .eq("rq",new SimpleDateFormat("yyyy-MM-dd").format(new Date()))).getGroundsales(); + case "medblock": + //洗中块外运 + return baseDao.selectOne( + new QueryWrapper<PrdCurrentSaleEntity>() + .eq("rq",new SimpleDateFormat("yyyy-MM-dd").format(new Date())))==null + ?new BigDecimal(0) + :baseDao.selectOne( + new QueryWrapper<PrdCurrentSaleEntity>() + .eq("rq",new SimpleDateFormat("yyyy-MM-dd").format(new Date()))).getMedblock(); + case "nubmeasure": + //洗小块外运 + return baseDao.selectOne( + new QueryWrapper<PrdCurrentSaleEntity>() + .eq("rq",new SimpleDateFormat("yyyy-MM-dd").format(new Date())))==null + ?new BigDecimal(0) + :baseDao.selectOne( + new QueryWrapper<PrdCurrentSaleEntity>() + .eq("rq",new SimpleDateFormat("yyyy-MM-dd").format(new Date()))).getNubmeasure(); + case "gangue": + //矸石外运 + return baseDao.selectOne( + new QueryWrapper<PrdCurrentSaleEntity>() + .eq("rq",new SimpleDateFormat("yyyy-MM-dd").format(new Date())))==null + ?new BigDecimal(0) + :baseDao.selectOne( + new QueryWrapper<PrdCurrentSaleEntity>() + .eq("rq",new SimpleDateFormat("yyyy-MM-dd").format(new Date()))).getGangue(); + case "reshipped": + //小块转载 + return baseDao.selectOne( + new QueryWrapper<PrdCurrentSaleEntity>() + .eq("rq",new SimpleDateFormat("yyyy-MM-dd").format(new Date())))==null + ?new BigDecimal(0) + :baseDao.selectOne( + new QueryWrapper<PrdCurrentSaleEntity>() + .eq("rq",new SimpleDateFormat("yyyy-MM-dd").format(new Date()))).getReshipped(); + case "trainTon": + //火车外运吨数 + return baseDao.selectOne( + new QueryWrapper<PrdCurrentSaleEntity>() + .eq("rq",new SimpleDateFormat("yyyy-MM-dd").format(new Date())))==null + ?new BigDecimal(0) + :baseDao.selectOne( + new QueryWrapper<PrdCurrentSaleEntity>() + .eq("rq",new SimpleDateFormat("yyyy-MM-dd").format(new Date()))).getTrainTon(); + case "trainCount": + //火车外运列数 + return baseDao.selectOne( + new QueryWrapper<PrdCurrentSaleEntity>() + .eq("rq",new SimpleDateFormat("yyyy-MM-dd").format(new Date())))==null + ?new BigDecimal(0) + :baseDao.selectOne( + new QueryWrapper<PrdCurrentSaleEntity>() + .eq("rq",new SimpleDateFormat("yyyy-MM-dd").format(new Date()))).getTrainCount(); + + default: + break; + } + return null; + } + public List<String> getLastMonthDates(int length) { + List<String> dateList = new ArrayList<>(); + LocalDate currentDate = LocalDate.now(); + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + for (int i = length-1; i >= 0; i--) { + dateList.add(currentDate.minusDays(i).format(formatter)); + } + + return dateList; + } + + public List<PrdCurrentSaleEntity> list(){ + List<PrdCurrentSaleEntity> prdCurrentSaleList = baseDao.selectList( + new QueryWrapper<PrdCurrentSaleEntity>() + .le("rq",new SimpleDateFormat("yyyy-MM-dd").format(new Date())) + .ge("rq",LocalDate.now().minusDays(29).format(DateTimeFormatter.ofPattern("yyyy-MM-dd"))) + .orderByAsc("rq") + ); + return prdCurrentSaleList; + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void syncData() { + Calendar calendar = Calendar.getInstance(); + calendar.add(Calendar.DAY_OF_YEAR, -30); + String startDate = DateUtils.format(calendar.getTime()); + FeignHttpApiDTO apiDTO = feignDataApi.getHttpApi(HTTP_API_CODE); + Map<String, String> params = new HashMap<>(); + String responseStr = httpsRequest.doGet(apiDTO.getUrl() + "&startDate=" + startDate, params, "utf-8", ""); + JSONObject responseObj = JSON.parseObject(responseStr); + if (!CommonConstant.STA_TRUE.equals(responseObj.get("sta").toString())) { + log.info("接口异常"); + } + JSONArray dataArray = responseObj.getJSONArray(CommonConstant.ZX_RES); + if (CollectionUtils.isEmpty(dataArray)) { + return; + } + List<PrdCurrentSaleEntity> entities = dataArray.toJavaList(PrdCurrentSaleEntity.class); + + entities.forEach(entity -> { + deleteByRq(entity.getDate()); + entity.setRq(entity.getDate()); + entity.setId(UUID.randomUUID().toString()); + entity.setCreateDate(new Date()); + entity.setUpdateDate(new Date()); + insert(entity); + }); + } + + private void deleteByRq(String rq) { + QueryWrapper<PrdCurrentSaleEntity> wrapper = new QueryWrapper<>(); + wrapper.eq(StringUtils.isNotBlank(rq), "rq", rq); + baseDao.delete(wrapper); + } +} diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/service/impl/PrdDayDutyServiceImpl.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/service/impl/PrdDayDutyServiceImpl.java new file mode 100644 index 0000000..811728a --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/service/impl/PrdDayDutyServiceImpl.java @@ -0,0 +1,84 @@ +package com.iailab.module.prod.service.impl; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.iailab.common.enums.CommonConstant; +import com.iailab.framework.common.service.impl.BaseServiceImpl; +import com.iailab.common.utils.DateUtils; +import com.iailab.common.utils.HttpsRequest; +import com.iailab.module.data.dto.FeignHttpApiDTO; +import com.iailab.module.data.api.IFeignDataApi; +import com.iailab.module.prod.dao.PrdDayDutyDao; +import com.iailab.module.prod.entity.PrdDayDutyEntity; +import com.iailab.module.prod.service.PrdDayDutyService; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import javax.annotation.Resource; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.util.CollectionUtils; + +import java.util.*; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年05月26日 + */ +@Slf4j +@Service +public class PrdDayDutyServiceImpl extends BaseServiceImpl<PrdDayDutyDao, PrdDayDutyEntity> implements PrdDayDutyService { + + private String HTTP_API_CODE = "Prd.DayDuty"; + + @Resource + private IFeignDataApi feignDataApi; + + @Resource + private HttpsRequest httpsRequest; + + + @Override + @Transactional(rollbackFor = Exception.class) + public void syncData() { + Calendar calendar = Calendar.getInstance(); + String endDate = DateUtils.format(calendar.getTime()); + calendar.add(Calendar.DAY_OF_YEAR, -5); + String startDate = DateUtils.format(calendar.getTime()); + + + FeignHttpApiDTO apiDTO = feignDataApi.getHttpApi(HTTP_API_CODE); + Map<String, String> params = new HashMap<>(); + String responseStr = httpsRequest.doGet(apiDTO.getUrl() + "&startDate=" + startDate + "&endDate=" + endDate, params, "utf-8", ""); + JSONObject responseObj = JSON.parseObject(responseStr); + if (!CommonConstant.STA_TRUE.equals(responseObj.get("sta").toString())) { + log.info("接口异常"); + } + JSONArray dataArray = responseObj.getJSONArray(CommonConstant.ZX_RES); + if (CollectionUtils.isEmpty(dataArray)) { + return; + } + this.deleteByDate(startDate, endDate); + List<PrdDayDutyEntity> dataList = dataArray.toJavaList(PrdDayDutyEntity.class); + dataList.forEach(entity -> { + if (StringUtils.isNotBlank(entity.getBanci())) { + entity.setId(UUID.randomUUID().toString()); + if (entity.getArrive() == null) { + entity.setArrive(entity.getNumber()); + } + insert(entity); + } + }); + } + + private void deleteByDate(String start, String end) { + QueryWrapper<PrdDayDutyEntity> wrapper = new QueryWrapper<>(); + wrapper.ge("date", start).le("date", end); + baseDao.delete(wrapper); + } + + + +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/service/impl/PrdDayProdServiceImpl.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/service/impl/PrdDayProdServiceImpl.java new file mode 100644 index 0000000..738f4b7 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/service/impl/PrdDayProdServiceImpl.java @@ -0,0 +1,299 @@ + +package com.iailab.module.prod.service.impl; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.iailab.framework.common.constant.Constant; +import com.iailab.common.dto.echarts.BarLineDTO; +import com.iailab.common.dto.echarts.SeriesItem; +import com.iailab.common.enums.CommonConstant; +import com.iailab.framework.common.page.PageData; +import com.iailab.framework.common.service.impl.BaseServiceImpl; +import com.iailab.framework.common.util.object.ConvertUtils; +import com.iailab.common.utils.DateUtils; +import com.iailab.common.utils.HttpsRequest; +import com.iailab.module.data.dto.FeignHttpApiDTO; +import com.iailab.module.data.api.IFeignDataApi; +import com.iailab.module.prod.dao.PrdDayProdDao; +import com.iailab.module.prod.dao.PrdPlanMonDao; +import com.iailab.module.prod.dto.PrdDayProdDTO; +import com.iailab.module.prod.entity.PrdDayProdEntity; +import com.iailab.module.prod.entity.PrdPlanMonEntity; +import com.iailab.module.prod.service.PrdDayProdService; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import javax.annotation.Resource; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import javax.annotation.Resource; +import java.math.BigDecimal; +import java.text.SimpleDateFormat; +import java.time.LocalDate; +import java.time.format.DateTimeFormatter; +import java.util.*; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年05月14日 + */ +@Slf4j +@Service +public class PrdDayProdServiceImpl extends BaseServiceImpl<PrdDayProdDao, PrdDayProdEntity> implements PrdDayProdService { + + @Resource + private PrdPlanMonDao prdPlanMonDao; + + private String HTTP_API_CODE = "Prd.DayProd"; + + @Resource + private IFeignDataApi feignDataApi; + + @Resource + private HttpsRequest httpsRequest; + + @Override + public PageData<PrdDayProdDTO> page(Map<String, Object> params) { + IPage<PrdDayProdEntity> page = baseDao.selectPage( + getPage(params, Constant.CREATE_DATE, false), + getWrapper(params) + ); + return getPageData(page, PrdDayProdDTO.class); + } + + private QueryWrapper<PrdDayProdEntity> getWrapper(Map<String, Object> params){ + String rq = (String)params.get("rq"); + + QueryWrapper<PrdDayProdEntity> wrapper = new QueryWrapper<>(); + wrapper.eq(StringUtils.isNotBlank(rq), "rq", rq) + .orderByAsc("rq"); + + return wrapper; + } + + @Override + public PrdDayProdDTO get(String id) { + PrdDayProdEntity entity = baseDao.selectById(id); + + return ConvertUtils.sourceToTarget(entity, PrdDayProdDTO.class); + } + + @Override + public void save(PrdDayProdDTO dto) { + PrdDayProdEntity entity = ConvertUtils.sourceToTarget(dto, PrdDayProdEntity.class); + + insert(entity); + } + + @Override + public void update(PrdDayProdDTO dto) { + PrdDayProdEntity entity = ConvertUtils.sourceToTarget(dto, PrdDayProdEntity.class); + + updateById(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void delete(String[] ids) { + baseDao.deleteBatchIds(Arrays.asList(ids)); + } + + @Override + public BarLineDTO barLine(String length,String type) { + + BarLineDTO barLineDTO = new BarLineDTO(); + List<SeriesItem> seriesItemList = new ArrayList<>(); + List<Object[]> data = new ArrayList(); + //获取当前月份天数 + int lengthOfMonth = LocalDate.now().lengthOfMonth(); + + //获取月计划 + PrdPlanMonEntity planMonEntity = prdPlanMonDao.selectOne(new QueryWrapper<PrdPlanMonEntity>() + .eq("rq", new SimpleDateFormat("MM").format(new Date())) + ); + BigDecimal planDay = planMonEntity==null?new BigDecimal(0):planMonEntity.getXxPlan().divide(new BigDecimal(lengthOfMonth),2,BigDecimal.ROUND_HALF_UP); + + switch (type) { + case "混煤": + this.list().stream().forEach( + item->{ + Object[] dataItem = new Object[2]; + dataItem[0] = item.getRq(); + dataItem[1] = item.getMixedCoal(); + if(item.getMixedCoal()!=null){ + data.add(dataItem); + } + barLineDTO.setValueName("混煤产量"); + } + ); + break; + case "原煤": + this.list().stream().forEach( + item->{ + Object[] dataItem = new Object[2]; + dataItem[0] = item.getRq(); + dataItem[1] = item.getRawCoal(); + if(item.getRawCoal()!=null){ + data.add(dataItem); + } + barLineDTO.setValueName("原煤入洗量"); + } + ); + break; + case "洗中块": + this.list().stream().forEach( + item->{ + Object[] dataItem = new Object[2]; + dataItem[0] = item.getRq(); + dataItem[1] = item.getMediumCoal(); + if(item.getMediumCoal()!=null){ + data.add(dataItem); + } + barLineDTO.setValueName("洗中块产量"); + } + ); + break; + case "洗小块": + this.list().stream().forEach( + item->{ + Object[] dataItem = new Object[2]; + dataItem[0] = item.getRq(); + dataItem[1] = item.getSmallCoal(); + if(item.getSmallCoal()!=null){ + data.add(dataItem); + } + barLineDTO.setValueName("洗小块产量"); + } + ); + break; + case "矸石": + this.list().stream().forEach( + item->{ + Object[] dataItem = new Object[2]; + dataItem[0] = item.getRq(); + dataItem[1] = item.getGangue(); + if(item.getGangue()!=null){ + data.add(dataItem); + } + barLineDTO.setValueName("矸石产量"); + } + ); + break; + default: + break; + } + + SeriesItem seriesItem = new SeriesItem(); + seriesItem.setData(data); + seriesItemList.add(seriesItem); + //barLineDTO.setLegend(this.getLastMonthDates(Integer.parseInt(length))); + barLineDTO.setSeries(seriesItemList); + return barLineDTO; + } + + @Override + public BigDecimal currentValue(String type) { + switch (type) { + case "混煤": + //混煤 + return baseDao.selectOne( + new QueryWrapper<PrdDayProdEntity>() + .eq("rq",new SimpleDateFormat("yyyy-MM-dd").format(new Date())))==null + ?new BigDecimal(0) + :baseDao.selectOne( + new QueryWrapper<PrdDayProdEntity>() + .eq("rq",new SimpleDateFormat("yyyy-MM-dd").format(new Date()))).getMixedCoal(); + case "原煤": + //入洗量 + return baseDao.selectOne( + new QueryWrapper<PrdDayProdEntity>() + .eq("rq",new SimpleDateFormat("yyyy-MM-dd").format(new Date())))==null + ?new BigDecimal(0) + :baseDao.selectOne( + new QueryWrapper<PrdDayProdEntity>() + .eq("rq",new SimpleDateFormat("yyyy-MM-dd").format(new Date()))).getRawCoal(); + case "洗中块": + return baseDao.selectOne( + new QueryWrapper<PrdDayProdEntity>() + .eq("rq",new SimpleDateFormat("yyyy-MM-dd").format(new Date())))==null + ?new BigDecimal(0) + :baseDao.selectOne( + new QueryWrapper<PrdDayProdEntity>() + .eq("rq",new SimpleDateFormat("yyyy-MM-dd").format(new Date()))).getMediumCoal(); + case "洗小块": + return baseDao.selectOne( + new QueryWrapper<PrdDayProdEntity>() + .eq("rq",new SimpleDateFormat("yyyy-MM-dd").format(new Date())))==null + ?new BigDecimal(0) + :baseDao.selectOne( + new QueryWrapper<PrdDayProdEntity>() + .eq("rq",new SimpleDateFormat("yyyy-MM-dd").format(new Date()))).getSmallCoal(); + case "矸石": + return baseDao.selectOne( + new QueryWrapper<PrdDayProdEntity>() + .eq("rq",new SimpleDateFormat("yyyy-MM-dd").format(new Date())))==null + ?new BigDecimal(0) + :baseDao.selectOne( + new QueryWrapper<PrdDayProdEntity>() + .eq("rq",new SimpleDateFormat("yyyy-MM-dd").format(new Date()))).getGangue(); + default: + break; + } + return null; + } + public List<String> getLastMonthDates(int length) { + List<String> dateList = new ArrayList<>(); + LocalDate currentDate = LocalDate.now(); + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + for (int i = length-1; i >= 0; i--) { + dateList.add(currentDate.minusDays(i).format(formatter)); + } + + return dateList; + } + + public List<PrdDayProdEntity> list(){ + List<PrdDayProdEntity> prdDayProdList = baseDao.selectList( + new QueryWrapper<PrdDayProdEntity>() + .le("rq",new SimpleDateFormat("yyyy-MM-dd").format(new Date())) + .ge("rq",LocalDate.now().minusDays(29).format(DateTimeFormatter.ofPattern("yyyy-MM-dd"))) + .orderByAsc("rq") + ); + return prdDayProdList; + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void syncData(String paramDate) { + Calendar calendar = Calendar.getInstance(); + calendar.add(Calendar.HOUR_OF_DAY, -12); + String rq = StringUtils.isNotBlank(paramDate) ? paramDate : DateUtils.format(calendar.getTime()); + FeignHttpApiDTO apiDTO = feignDataApi.getHttpApi(HTTP_API_CODE); + Map<String, String> params = new HashMap<>(); + String responseStr = httpsRequest.doGet(apiDTO.getUrl() + "&date=" + rq, params, "utf-8", ""); + JSONObject responseObj = JSON.parseObject(responseStr); + if (!CommonConstant.STA_TRUE.equals(responseObj.get("sta").toString())) { + log.info("接口异常"); + } + JSONObject dataObj = responseObj.getJSONObject(CommonConstant.ZX_RES); + if (dataObj == null) { + return; + } + this.deleteByDate(rq); + PrdDayProdEntity entity = dataObj.toJavaObject(PrdDayProdEntity.class); + entity.setId(UUID.randomUUID().toString()); + entity.setRq(rq); + entity.setCreateDate(new Date()); + entity.setUpdateDate(new Date()); + insert(entity); + } + + private void deleteByDate(String date) { + QueryWrapper<PrdDayProdEntity> wrapper = new QueryWrapper<>(); + wrapper.eq(StringUtils.isNotBlank(date), "rq", date); + baseDao.delete(wrapper); + } +} diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/service/impl/PrdPlanMonServiceImpl.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/service/impl/PrdPlanMonServiceImpl.java new file mode 100644 index 0000000..5bd026b --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/service/impl/PrdPlanMonServiceImpl.java @@ -0,0 +1,187 @@ + +package com.iailab.module.prod.service.impl; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.iailab.module.data.dto.FeignHttpApiDTO; +import com.iailab.framework.common.constant.Constant; +import com.iailab.common.dto.echarts.BarLineDTO; +import com.iailab.common.dto.echarts.SeriesItem; +import com.iailab.common.enums.CommonConstant; +import com.iailab.framework.common.page.PageData; +import com.iailab.framework.common.service.impl.BaseServiceImpl; +import com.iailab.common.utils.CommonUtils; +import com.iailab.framework.common.util.object.ConvertUtils; +import com.iailab.common.utils.HttpsRequest; +import com.iailab.module.data.api.IFeignDataApi; +import com.iailab.module.prod.dao.PrdPlanMonDao; +import com.iailab.module.prod.dto.PrdPlanMonDTO; +import com.iailab.module.prod.entity.PrdPlanMonEntity; +import com.iailab.module.prod.service.PrdPlanMonService; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import javax.annotation.Resource; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.math.BigDecimal; +import java.text.SimpleDateFormat; +import java.time.LocalDate; +import java.time.format.DateTimeFormatter; +import java.util.*; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年05月14日 + */ +@Slf4j +@Service +public class PrdPlanMonServiceImpl extends BaseServiceImpl<PrdPlanMonDao, PrdPlanMonEntity> implements PrdPlanMonService { + + private String HTTP_API_CODE = "Prd.YearPEI"; + + @Resource + private IFeignDataApi feignDataApi; + + @Resource + private HttpsRequest httpsRequest; + + @Override + public PageData<PrdPlanMonDTO> page(Map<String, Object> params) { + IPage<PrdPlanMonEntity> page = baseDao.selectPage( + getPage(params, Constant.CREATE_DATE, false), + getWrapper(params) + ); + return getPageData(page, PrdPlanMonDTO.class); + } + + private QueryWrapper<PrdPlanMonEntity> getWrapper(Map<String, Object> params){ + String rq = (String)params.get("rq"); + + QueryWrapper<PrdPlanMonEntity> wrapper = new QueryWrapper<>(); + wrapper.eq(StringUtils.isNotBlank(rq), "rq", rq) + .orderByAsc("rq"); + + return wrapper; + } + + @Override + public PrdPlanMonDTO get(String id) { + PrdPlanMonEntity entity = baseDao.selectById(id); + + return ConvertUtils.sourceToTarget(entity, PrdPlanMonDTO.class); + } + + @Override + public void save(PrdPlanMonDTO dto) { + PrdPlanMonEntity entity = ConvertUtils.sourceToTarget(dto, PrdPlanMonEntity.class); + + insert(entity); + } + + @Override + public void update(PrdPlanMonDTO dto) { + PrdPlanMonEntity entity = ConvertUtils.sourceToTarget(dto, PrdPlanMonEntity.class); + + updateById(entity); + } + + public List<PrdPlanMonEntity> list(){ + List<PrdPlanMonEntity> prdPlanMonList = baseDao.selectList( + new QueryWrapper<PrdPlanMonEntity>() + .ge("rq",new SimpleDateFormat("yyyy-MM-dd").format(new Date())) + .le("rq",new SimpleDateFormat("yyyy-MM-dd").format(LocalDate.now().minusDays(29))) + ); + return prdPlanMonList; + } + @Override + @Transactional(rollbackFor = Exception.class) + public void delete(String[] ids) { + baseDao.deleteBatchIds(Arrays.asList(ids)); + } + + @Override + public BarLineDTO barLine(String length) { + + BarLineDTO barLineDTO = new BarLineDTO(); + List<SeriesItem> seriesItemList = new ArrayList<>(); + List<Object[]> data = new ArrayList(); + this.list().stream().forEach( + item->{ + Object[] dataItem = new Object[2]; + dataItem[0] = item.getRq(); + dataItem[1] = item.getXxPlan(); + data.add(dataItem); + } + ); + + + SeriesItem seriesItem = new SeriesItem(); + seriesItem.setData(data); + barLineDTO.setValueName("月计划"); + List categoriesList = new ArrayList(); + categoriesList.add(""); + categoriesList.add(""); + barLineDTO.setCategories(categoriesList); + //barLineDTO.setLegend(this.getLastMonthDates()); + barLineDTO.setSeries(seriesItemList); + return barLineDTO; + } + + @Override + public BigDecimal currentValue() { + return new BigDecimal(1000); + } + public List<String> getLastMonthDates() { + List<String> dateList = new ArrayList<>(); + LocalDate currentDate = LocalDate.now(); + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + for (int i = 29; i >= 0; i--) { + dateList.add(currentDate.minusDays(i).format(formatter)); + } + + return dateList; + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void syncData() { + FeignHttpApiDTO apiDTO = feignDataApi.getHttpApi(HTTP_API_CODE); + Map<String, String> params = new HashMap<>(); + String responseStr = httpsRequest.doGet(apiDTO.getUrl(), params, "utf-8", ""); + + JSONObject responseObj = JSON.parseObject(responseStr); + if (!CommonConstant.STA_TRUE.equals(responseObj.get("sta").toString())) { + log.info("接口异常"); + } + JSONObject res = responseObj.getJSONObject(CommonConstant.ZX_RES); + JSONObject yearData = res.getJSONObject("yearData"); + String year = yearData.get("year").toString(); + JSONArray monthData = res.getJSONArray("monthData"); + for (int i = 0; i < monthData.size(); i++) { + JSONObject item = monthData.getJSONObject(i); + String rq = year + "-" + (Integer.parseInt(item.getString("month")) < 10 ? "0" + item.getString("month") : item.getString("month") ); + this.deleteByRq(rq); + PrdPlanMonEntity entity = new PrdPlanMonEntity(); + entity.setId(UUID.randomUUID().toString()); + entity.setRq(rq); + entity.setXxPlan(CommonUtils.getJSONValue(item.get("xxPlan"))); + entity.setXxPerformance(CommonUtils.getJSONValue(item.get("xxPerformance"))); + entity.setZqPlan(CommonUtils.getJSONValue(item.get("zqPlan"))); + entity.setZqPerformance(CommonUtils.getJSONValue(item.get("zqPerformance"))); + entity.setCreateDate(new Date()); + entity.setUpdateDate(new Date()); + insert(entity); + } + } + + private void deleteByRq(String rq) { + QueryWrapper<PrdPlanMonEntity> wrapper = new QueryWrapper<>(); + wrapper.eq(StringUtils.isNotBlank(rq), "rq", rq); + baseDao.delete(wrapper); + } +} diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/service/impl/PrdPlanYearServiceImpl.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/service/impl/PrdPlanYearServiceImpl.java new file mode 100644 index 0000000..9b46e3c --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/service/impl/PrdPlanYearServiceImpl.java @@ -0,0 +1,136 @@ + +package com.iailab.module.prod.service.impl; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.iailab.framework.common.constant.Constant; +import com.iailab.common.dto.echarts.BarLineDTO; +import com.iailab.common.enums.CommonConstant; +import com.iailab.framework.common.page.PageData; +import com.iailab.framework.common.service.impl.BaseServiceImpl; +import com.iailab.common.utils.CommonUtils; +import com.iailab.framework.common.util.object.ConvertUtils; +import com.iailab.common.utils.HttpsRequest; +import com.iailab.module.data.dto.FeignHttpApiDTO; +import com.iailab.module.data.api.IFeignDataApi; +import com.iailab.module.prod.dao.PrdPlanYearDao; +import com.iailab.module.prod.dto.PrdPlanYearDTO; +import com.iailab.module.prod.entity.PrdPlanYearEntity; +import com.iailab.module.prod.service.PrdPlanYearService; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import javax.annotation.Resource; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.math.BigDecimal; +import java.util.*; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年05月14日 + */ +@Slf4j +@Service +public class PrdPlanYearServiceImpl extends BaseServiceImpl<PrdPlanYearDao, PrdPlanYearEntity> implements PrdPlanYearService { + + private String HTTP_API_CODE = "Prd.YearPEI"; + + @Resource + private IFeignDataApi feignDataApi; + + @Resource + private HttpsRequest httpsRequest; + + @Override + public PageData<PrdPlanYearDTO> page(Map<String, Object> params) { + IPage<PrdPlanYearEntity> page = baseDao.selectPage( + getPage(params, Constant.CREATE_DATE, false), + getWrapper(params) + ); + return getPageData(page, PrdPlanYearDTO.class); + } + + private QueryWrapper<PrdPlanYearEntity> getWrapper(Map<String, Object> params){ + String rq = (String)params.get("rq"); + + QueryWrapper<PrdPlanYearEntity> wrapper = new QueryWrapper<>(); + wrapper.eq(StringUtils.isNotBlank(rq), "rq", rq) + .orderByAsc("rq"); + + return wrapper; + } + + @Override + public PrdPlanYearDTO get(String id) { + PrdPlanYearEntity entity = baseDao.selectById(id); + + return ConvertUtils.sourceToTarget(entity, PrdPlanYearDTO.class); + } + + @Override + public void save(PrdPlanYearDTO dto) { + PrdPlanYearEntity entity = ConvertUtils.sourceToTarget(dto, PrdPlanYearEntity.class); + + insert(entity); + } + + @Override + public void update(PrdPlanYearDTO dto) { + PrdPlanYearEntity entity = ConvertUtils.sourceToTarget(dto, PrdPlanYearEntity.class); + + updateById(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void delete(String[] ids) { + baseDao.deleteBatchIds(Arrays.asList(ids)); + } + + @Override + public BarLineDTO barLine(String length) { + return null; + } + + @Override + public BigDecimal currentValue() { + return null; + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void syncData() { + FeignHttpApiDTO apiDTO = feignDataApi.getHttpApi(HTTP_API_CODE); + Map<String, String> params = new HashMap<>(); + String responseStr = httpsRequest.doGet(apiDTO.getUrl(), params, "utf-8", ""); + + JSONObject responseObj = JSON.parseObject(responseStr); + if (!CommonConstant.STA_TRUE.equals(responseObj.get("sta").toString())) { + log.info("接口异常"); + } + JSONObject res = responseObj.getJSONObject(CommonConstant.ZX_RES); + JSONObject yearData = res.getJSONObject("yearData"); + this.deleteByYear(yearData.get("year").toString()); + PrdPlanYearEntity entity = new PrdPlanYearEntity(); + entity.setId(UUID.randomUUID().toString()); + entity.setRq(yearData.get("year").toString()); + entity.setXxPlan(CommonUtils.getJSONValue(yearData.get("xxPlan"))); + entity.setXxPerformance(CommonUtils.getJSONValue(yearData.get("xxPerformance"))); + entity.setZqPlan(CommonUtils.getJSONValue(yearData.get("zqPlan"))); + entity.setZqPerformance(CommonUtils.getJSONValue(yearData.get("zqPerformance"))); + entity.setCreateDate(new Date()); + entity.setUpdateDate(new Date()); + insert(entity); + + } + + private void deleteByYear(String rq) { + QueryWrapper<PrdPlanYearEntity> wrapper = new QueryWrapper<>(); + wrapper.eq(StringUtils.isNotBlank(rq), "rq", rq); + baseDao.delete(wrapper); + } +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/service/impl/PrdTimeDayServiceImpl.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/service/impl/PrdTimeDayServiceImpl.java new file mode 100644 index 0000000..ba58da4 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/service/impl/PrdTimeDayServiceImpl.java @@ -0,0 +1,76 @@ +package com.iailab.module.prod.service.impl; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.iailab.common.enums.CommonConstant; +import com.iailab.framework.common.service.impl.BaseServiceImpl; +import com.iailab.common.utils.CommonUtils; +import com.iailab.common.utils.DateUtils; +import com.iailab.common.utils.HttpsRequest; +import com.iailab.module.data.dto.FeignHttpApiDTO; +import com.iailab.module.data.api.IFeignDataApi; +import com.iailab.module.prod.dao.PrdTimeDayDao; +import com.iailab.module.prod.entity.PrdTimeDayEntity; +import com.iailab.module.prod.service.PrdTimeDayService; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import javax.annotation.Resource; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.*; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年06月16日 + */ +@Slf4j +@Service +public class PrdTimeDayServiceImpl extends BaseServiceImpl<PrdTimeDayDao, PrdTimeDayEntity> implements PrdTimeDayService { + + private String HTTP_API_CODE = "Prd.PrdTimeDistByDate"; + + @Resource + private IFeignDataApi feignDataApi; + + @Resource + private HttpsRequest httpsRequest; + + @Override + @Transactional(rollbackFor = Exception.class) + public void syncData(String iRq) { + Calendar calendar = Calendar.getInstance(); + calendar.add(Calendar.HOUR_OF_DAY, -12); + String rq = StringUtils.isNotBlank(iRq) ? iRq : DateUtils.format(calendar.getTime()); + FeignHttpApiDTO apiDTO = feignDataApi.getHttpApi(HTTP_API_CODE); + Map<String, String> params = new HashMap<>(); + String responseStr = httpsRequest.doGet(apiDTO.getUrl() + "&startDate=" + rq + "&endDate=" + rq, params, "utf-8", ""); + JSONObject responseObj = JSON.parseObject(responseStr); + if (!CommonConstant.STA_TRUE.equals(responseObj.get("sta").toString())) { + log.info("接口异常"); + } + JSONObject dataObj = responseObj.getJSONObject(CommonConstant.ZX_RES); + if (dataObj == null) { + return; + } + deleteByDate(rq); + JSONObject xxData = dataObj.getJSONObject("xx"); + PrdTimeDayEntity entity = new PrdTimeDayEntity(); + entity.setId(UUID.randomUUID().toString()); + entity.setCreateDate(new Date()); + entity.setDate(rq); + entity.setType("xx"); + entity.setRunMinutes(CommonUtils.getJSONValue(xxData.get("runMinutes"))); + entity.setOverhaulMinutes(CommonUtils.getJSONValue(xxData.get("overhaulMinutes"))); + entity.setAffectMinutes(CommonUtils.getJSONValue(xxData.get("affectMinutes"))); + insert(entity); + } + + private void deleteByDate(String date) { + QueryWrapper<PrdTimeDayEntity> wrapper = new QueryWrapper<>(); + wrapper.eq(StringUtils.isNotBlank(date), "date", date); + baseDao.delete(wrapper); + } +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/service/impl/StorageDayServiceImpl.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/service/impl/StorageDayServiceImpl.java new file mode 100644 index 0000000..2a8c1bf --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/service/impl/StorageDayServiceImpl.java @@ -0,0 +1,76 @@ +package com.iailab.module.prod.service.impl; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.iailab.common.enums.CommonConstant; +import com.iailab.framework.common.service.impl.BaseServiceImpl; +import com.iailab.common.utils.DateUtils; +import com.iailab.common.utils.HttpsRequest; +import com.iailab.module.data.dto.FeignHttpApiDTO; +import com.iailab.module.data.api.IFeignDataApi; +import com.iailab.module.prod.dao.StorageDayDao; +import com.iailab.module.prod.entity.StorageDayEntity; +import com.iailab.module.prod.service.StorageDayService; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import javax.annotation.Resource; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.util.CollectionUtils; + +import java.util.*; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年06月01日 + */ +@Slf4j +@Service +public class StorageDayServiceImpl extends BaseServiceImpl<StorageDayDao, StorageDayEntity> implements StorageDayService { + + private String HTTP_API_CODE = "Prd.StorageDay"; + + @Resource + private IFeignDataApi feignDataApi; + + @Resource + private HttpsRequest httpsRequest; + + @Override + @Transactional(rollbackFor = Exception.class) + public void syncData() { + Calendar calendar = Calendar.getInstance(); + calendar.add(Calendar.DAY_OF_YEAR, -1); + String endDate = DateUtils.format(calendar.getTime()); + calendar.add(Calendar.DAY_OF_YEAR, -5); + String startDate = DateUtils.format(calendar.getTime()); + + FeignHttpApiDTO apiDTO = feignDataApi.getHttpApi(HTTP_API_CODE); + Map<String, String> params = new HashMap<>(); + String responseStr = httpsRequest.doGet(apiDTO.getUrl() + "&startDate=" + startDate + "&endDate=" + endDate, params, "utf-8", ""); + JSONObject responseObj = JSON.parseObject(responseStr); + if (!CommonConstant.STA_TRUE.equals(responseObj.get("sta").toString())) { + log.info("接口异常"); + } + JSONArray dataArray = responseObj.getJSONArray(CommonConstant.ZX_RES); + if (CollectionUtils.isEmpty(dataArray)) { + return; + } + List<StorageDayEntity> entities = dataArray.toJavaList(StorageDayEntity.class); + entities.forEach(entity -> { + deleteByDate(entity.getDate()); + entity.setId(UUID.randomUUID().toString()); + entity.setCreateDate(new Date()); + insert(entity); + }); + } + + private void deleteByDate(String date) { + QueryWrapper<StorageDayEntity> wrapper = new QueryWrapper<>(); + wrapper.eq(StringUtils.isNotBlank(date), "date", date); + baseDao.delete(wrapper); + } +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/quality/dao/QualityQualityTrendDayDao.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/quality/dao/QualityQualityTrendDayDao.java new file mode 100644 index 0000000..6aa4eb4 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/quality/dao/QualityQualityTrendDayDao.java @@ -0,0 +1,16 @@ + +package com.iailab.module.quality.dao; + +import com.iailab.framework.common.dao.BaseDao; +import com.iailab.module.quality.entity.QualityQualityTrendDayEntity; +import org.apache.ibatis.annotations.Mapper; + +/** + * @author DongYukun + * @Description + * @createTime 2024年05月20日 + */ +@Mapper +public interface QualityQualityTrendDayDao extends BaseDao<QualityQualityTrendDayEntity> { +} + diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/quality/dto/QualityQualityTrendDayDTO.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/quality/dto/QualityQualityTrendDayDTO.java new file mode 100644 index 0000000..5852c66 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/quality/dto/QualityQualityTrendDayDTO.java @@ -0,0 +1,38 @@ +package com.iailab.module.quality.dto; + +import com.iailab.framework.common.validation.group.AddGroup; +import com.iailab.framework.common.validation.group.UpdateGroup; +import io.swagger.v3.oas.annotations.media.Schema; + +import lombok.Data; + +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Null; +import java.io.Serializable; +import java.math.BigDecimal; +import java.util.Date; + +/** + * @author DongYukun + * @Description + * @createTime 2024年05月20日 + */ +@Data +@Schema(name = "应用注册") +public class QualityQualityTrendDayDTO implements Serializable { + private static final long serialVersionUID = 1L; + + @Schema(name = "id") + @Null(message="{id.null}", groups = AddGroup.class) + @NotNull(message="{id.require}", groups = UpdateGroup.class) + private String id; + + private String rq; + private String coal; + private BigDecimal Mt; + private BigDecimal Ad; + private BigDecimal St; + private BigDecimal Qnet; + private Date createDate; + private Date updateDate; +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/quality/entity/QualityQualityTrendDayEntity.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/quality/entity/QualityQualityTrendDayEntity.java new file mode 100644 index 0000000..60f260f --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/quality/entity/QualityQualityTrendDayEntity.java @@ -0,0 +1,34 @@ +package com.iailab.module.quality.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.io.Serializable; +import java.math.BigDecimal; +import java.util.Date; +/** + * @author DongYukun + * @Description + * @createTime 2024年05月20日 + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("t_quality_quality_trend_day") +public class QualityQualityTrendDayEntity implements Serializable { + private static final long serialVersionUID = 1L; + + @TableId(type = IdType.ASSIGN_UUID) + private String id; + private String rq; + private String coal; + private BigDecimal Mt; + private BigDecimal Ad; + private BigDecimal St; + private BigDecimal Qnet; + private Date createDate; + private Date updateDate; +} + diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/quality/service/QualityQualityTrendDayService.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/quality/service/QualityQualityTrendDayService.java new file mode 100644 index 0000000..e08bc96 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/quality/service/QualityQualityTrendDayService.java @@ -0,0 +1,33 @@ +package com.iailab.module.quality.service; + +import com.iailab.common.dto.echarts.BarLineDTO; +import com.iailab.framework.common.page.PageData; +import com.iailab.framework.common.service.BaseService; +import com.iailab.module.quality.dto.QualityQualityTrendDayDTO; +import com.iailab.module.quality.entity.QualityQualityTrendDayEntity; + +import java.math.BigDecimal; +import java.util.Map; + +/** + * @author DongYukun + * @Description + * @createTime 2024年05月20日 + */ +public interface QualityQualityTrendDayService extends BaseService<QualityQualityTrendDayEntity> { + BarLineDTO barLine(String length, String type,String coal); + + BigDecimal currentValue(String coal,String type); + + PageData<QualityQualityTrendDayDTO> page(Map<String, Object> params); + + QualityQualityTrendDayDTO get(String id); + + void save(QualityQualityTrendDayDTO dto); + + void update(QualityQualityTrendDayDTO dto); + + void delete(String[] ids); + + void syncData(); +} diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/quality/service/impl/QualityQualityTrendDayServiceImpl.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/quality/service/impl/QualityQualityTrendDayServiceImpl.java new file mode 100644 index 0000000..865e087 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/quality/service/impl/QualityQualityTrendDayServiceImpl.java @@ -0,0 +1,291 @@ + +package com.iailab.module.quality.service.impl; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.iailab.framework.common.constant.Constant; +import com.iailab.common.dto.echarts.BarLineDTO; +import com.iailab.common.dto.echarts.SeriesItem; +import com.iailab.common.enums.CommonConstant; +import com.iailab.framework.common.page.PageData; +import com.iailab.framework.common.service.impl.BaseServiceImpl; +import com.iailab.framework.common.util.object.ConvertUtils; +import com.iailab.common.utils.DateUtils; +import com.iailab.common.utils.HttpsRequest; +import com.iailab.module.data.dto.FeignHttpApiDTO; +import com.iailab.module.data.api.IFeignDataApi; +import com.iailab.module.quality.dao.QualityQualityTrendDayDao; +import com.iailab.module.quality.dto.QualityQualityTrendDayDTO; +import com.iailab.module.quality.entity.QualityQualityTrendDayEntity; +import com.iailab.module.quality.service.QualityQualityTrendDayService; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import javax.annotation.Resource; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.util.CollectionUtils; + +import java.math.BigDecimal; +import java.text.SimpleDateFormat; +import java.time.LocalDate; +import java.time.format.DateTimeFormatter; +import java.util.*; + +/** + * @author DongYukun + * @Description + * @createTime 2024年05月20日 + */ +@Slf4j +@Service +public class QualityQualityTrendDayServiceImpl extends BaseServiceImpl<QualityQualityTrendDayDao, QualityQualityTrendDayEntity> implements QualityQualityTrendDayService { + + private String HTTP_API_CODE = "Quality.QualityTrendDay"; + + @Resource + private IFeignDataApi feignDataApi; + + @Resource + private HttpsRequest httpsRequest; + + @Override + public PageData<QualityQualityTrendDayDTO> page(Map<String, Object> params) { + IPage<QualityQualityTrendDayEntity> page = baseDao.selectPage( + getPage(params, Constant.CREATE_DATE, false), + getWrapper(params) + ); + return getPageData(page, QualityQualityTrendDayDTO.class); + } + + private QueryWrapper<QualityQualityTrendDayEntity> getWrapper(Map<String, Object> params){ + String rq = (String)params.get("rq"); + + QueryWrapper<QualityQualityTrendDayEntity> wrapper = new QueryWrapper<>(); + wrapper.eq(StringUtils.isNotBlank(rq), "rq", rq) + .orderByAsc("rq"); + + return wrapper; + } + + @Override + public QualityQualityTrendDayDTO get(String id) { + QualityQualityTrendDayEntity entity = baseDao.selectById(id); + + return ConvertUtils.sourceToTarget(entity, QualityQualityTrendDayDTO.class); + } + + @Override + public void save(QualityQualityTrendDayDTO dto) { + QualityQualityTrendDayEntity entity = ConvertUtils.sourceToTarget(dto, QualityQualityTrendDayEntity.class); + + insert(entity); + } + + @Override + public void update(QualityQualityTrendDayDTO dto) { + QualityQualityTrendDayEntity entity = ConvertUtils.sourceToTarget(dto, QualityQualityTrendDayEntity.class); + + updateById(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void delete(String[] ids) { + baseDao.deleteBatchIds(Arrays.asList(ids)); + } + + @Override + public BarLineDTO barLine(String length,String type,String coal) { + + BarLineDTO barLineDTO = new BarLineDTO(); + List<SeriesItem> seriesItemList = new ArrayList<>(); + List<Object[]> data = new ArrayList(); + switch (type) { + case "sf": + //水分 + this.list(coal).stream().forEach( + item->{ + Object[] dataItem = new Object[2]; + dataItem[0] = item.getRq(); + dataItem[1] = item.getMt(); + if(item.getMt()!=null){ + data.add(dataItem); + } + barLineDTO.setValueName(coal+"水分"); + } + ); + break; + case "hf": + //灰分 + this.list(coal).stream().forEach( + item->{ + Object[] dataItem = new Object[2]; + dataItem[0] = item.getRq(); + dataItem[1] = item.getAd(); + if(item.getAd()!=null){ + data.add(dataItem); + } + barLineDTO.setValueName(coal+"灰分"); + } + ); + break; + case "lf": + //硫分 + this.list(coal).stream().forEach( + item->{ + Object[] dataItem = new Object[2]; + dataItem[0] = item.getRq(); + dataItem[1] = item.getSt(); + if(item.getSt()!=null){ + data.add(dataItem); + } + barLineDTO.setValueName(coal+"硫分"); + } + ); + break; + case "rz": + //热值 + this.list(coal).stream().forEach( + item->{ + Object[] dataItem = new Object[2]; + dataItem[0] = item.getRq(); + dataItem[1] = item.getQnet(); + if(item.getQnet()!=null){ + data.add(dataItem); + } + barLineDTO.setValueName(coal+"热值"); + } + ); + break; + default: + break; + } + + SeriesItem seriesItem = new SeriesItem(); + seriesItem.setData(data); + seriesItemList.add(seriesItem); + barLineDTO.setCategories(this.getLastMonthDates(Integer.parseInt(length))); + barLineDTO.setSeries(seriesItemList); + return barLineDTO; + } + + @Override + public BigDecimal currentValue(String coal,String type) { + switch (type) { + case "sf": + //水分 + QualityQualityTrendDayEntity sf = baseDao.selectOne( + new QueryWrapper<QualityQualityTrendDayEntity>() + .eq("rq",new SimpleDateFormat("yyyy-MM-dd").format(new Date())) + .eq("coal",coal) + ); + if(sf != null){ + return sf.getMt(); + } + return null; + case "hf": + //灰分 + QualityQualityTrendDayEntity hf = baseDao.selectOne( + new QueryWrapper<QualityQualityTrendDayEntity>() + .eq("rq",new SimpleDateFormat("yyyy-MM-dd").format(new Date())) + .eq("coal",coal) + ); + if(hf != null){ + return hf.getAd(); + } + return null; + case "lf": + //硫分 + QualityQualityTrendDayEntity lf = baseDao.selectOne( + new QueryWrapper<QualityQualityTrendDayEntity>() + .eq("rq",new SimpleDateFormat("yyyy-MM-dd").format(new Date())) + .eq("coal",coal) + ); + if(lf != null){ + return lf.getSt(); + } + return null; + case "rz": + //热值 + QualityQualityTrendDayEntity rz = baseDao.selectOne( + new QueryWrapper<QualityQualityTrendDayEntity>() + .eq("rq",new SimpleDateFormat("yyyy-MM-dd").format(new Date())) + .eq("coal",coal) + ); + if(rz != null){ + return rz.getQnet(); + } + return null; + default: + break; + } + return null; + } + + public List<String> getLastMonthDates(int length) { + List<String> dateList = new ArrayList<>(); + LocalDate currentDate = LocalDate.now(); + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + for (int i = length-1; i >= 0; i--) { + dateList.add(currentDate.minusDays(i).format(formatter)); + } + + return dateList; + } + + public List<QualityQualityTrendDayEntity> list(String coal){ + List<QualityQualityTrendDayEntity> prdDayProdList = baseDao.selectList( + new QueryWrapper<QualityQualityTrendDayEntity>() + .le("rq",new SimpleDateFormat("yyyy-MM-dd").format(new Date())) + .ge("rq",LocalDate.now().minusDays(29).format(DateTimeFormatter.ofPattern("yyyy-MM-dd"))) + .eq("coal",coal) + .orderByAsc("rq") + ); + return prdDayProdList; + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void syncData() { + Calendar calendar = Calendar.getInstance(); + calendar.add(Calendar.DAY_OF_YEAR, -1); + String endDate = DateUtils.format(calendar.getTime()); + calendar.add(Calendar.DAY_OF_YEAR, -10); + String startDate = DateUtils.format(calendar.getTime()); + + FeignHttpApiDTO apiDTO = feignDataApi.getHttpApi(HTTP_API_CODE); + Map<String, String> params = new HashMap<>(); + String responseStr = httpsRequest.doGet(apiDTO.getUrl() + "&startDate=" + startDate + "&endDate=" + endDate, params, "utf-8", ""); + JSONObject responseObj = JSON.parseObject(responseStr); + if (!CommonConstant.STA_TRUE.equals(responseObj.get("sta").toString())) { + log.info("接口异常"); + } + JSONArray dataArray = responseObj.getJSONArray(CommonConstant.ZX_RES); + if (CollectionUtils.isEmpty(dataArray)) { + return; + } + for (int i = 0; i < dataArray.size(); i++) { + JSONObject dataItem = dataArray.getJSONObject(i); + String date = dataItem.getString("date"); + JSONArray coalList = dataItem.getJSONArray("coalList"); + this.deleteByDate(date); + List<QualityQualityTrendDayEntity> entities = coalList.toJavaList(QualityQualityTrendDayEntity.class); + entities.forEach(entity -> { + entity.setId(UUID.randomUUID().toString()); + entity.setRq(date); + entity.setCreateDate(new Date()); + entity.setUpdateDate(new Date()); + insert(entity); + }); + } + } + + private void deleteByDate(String date) { + QueryWrapper<QualityQualityTrendDayEntity> wrapper = new QueryWrapper<>(); + wrapper.eq(StringUtils.isNotBlank(date), "rq", date); + baseDao.delete(wrapper); + } +} diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/watch/WatchConstant.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/watch/WatchConstant.java new file mode 100644 index 0000000..f44f721 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/watch/WatchConstant.java @@ -0,0 +1,167 @@ +package com.iailab.module.watch; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年06月05日 + */ +public interface WatchConstant { + + /** + * 通信正常 + */ + Integer TX_STS_NORMAL = 1; + + /** + * 通信中断 + */ + Integer TX_STS_STOP = 0; + + /** + * 主洗1心跳读取 + */ + String ZX1_HEART = "M0000101001"; + + /** + * 主洗1心跳下发 + */ + String ZX1_HEART_SET = "M0000101003"; + + /** + * 主洗1通信状态 + */ + String ZX1_STATUS = "F0000100113"; + + + /** + * 主洗2心跳读取 + */ + String ZX2_HEART = "M0000101002"; + + /** + * 主洗2心跳下发 + */ + String ZX2_HEART_SET = "M0000101004"; + + /** + * 主洗2通信状态 + */ + String ZX2_STATUS = "F0000100121"; + + + /** + * 控制器停止(手动) + */ + String CONTROLLER_OFF = "false"; + + /** + * 控制器启动(自动) + */ + String CONTROLLER_ON = "true"; + + /** + * 浅槽分选投入智能化状态 + */ + String CONTROLLER_USE_1 = "M0000102003"; + + /** + * 浅槽分选智能化运行状态反馈 + */ + String CONTROLLER_ONSTS_1 = "M0000102004"; + + /** + * 浅槽分选智能化运行状态反馈 + */ + String CONTROLLER_ALM_1 = "M0000102005"; + + /** + * 旋流分选投入智能化状态 + */ + String CONTROLLER_USE_2 = "M0000102006"; + + /** + * 旋流分选智能化运行状态反馈 + */ + String CONTROLLER_ONSTS_2 = "M0000102007"; + + /** + * 旋流分选故障需切换手动 + */ + String CONTROLLER_ALM_2 = "M0000102008"; + + /** + * 旋流浓缩投入智能化状态 + */ + String CONTROLLER_USE_3 = "M0000102012"; + + /** + *旋流浓缩智能化运行状态反馈 + */ + String CONTROLLER_ONSTS_3 = "M0000102013"; + + /** + * 旋流浓缩故障需切换手动 + */ + String CONTROLLER_ALM_3 = "M0000102014"; + + /** + * 旋流压滤投入智能化状态 + */ + String CONTROLLER_USE_4 = "M0000102015"; + + /** + * 旋流压滤智能化运行状态反馈 + */ + String CONTROLLER_ONSTS_4 = "M0000102016"; + + /** + * 旋流压滤故障需切换手动 + */ + String CONTROLLER_ALM_4 = "M0000102017"; + + /** + * 浅槽浓缩投入智能化状态 + */ + String CONTROLLER_USE_5 = "M0000102009"; + + /** + * 浅槽浓缩智能化运行状态反馈 + */ + String CONTROLLER_ONSTS_5 = "M0000102010"; + + /** + * 浅槽浓缩故障需切换手动 + */ + String CONTROLLER_ALM_5 = "M0000102011"; + + /** + * 智能压风投入智能化状态 + */ + String CONTROLLER_USE_6 = "M0000102018"; + + /** + * 智能压风智能化运行状态反馈 + */ + String CONTROLLER_ONSTS_6 = "M0000102019"; + + /** + * 智能压风故障需切换手动 + */ + String CONTROLLER_ALM_6 = "M0000102020"; + + /** + * 智能配仓投入智能化状态 + */ + String CONTROLLER_USE_7 = "M0000102021"; + + /** + * 智能配仓智能化运行状态反馈 + */ + String CONTROLLER_ONSTS_7 = "M0000102022"; + + /** + * 智能配仓故障需切换手动 + */ + String CONTROLLER_ALM_7 = "M0000102023"; + +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/watch/WatchDog.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/watch/WatchDog.java new file mode 100644 index 0000000..1a75aea --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/watch/WatchDog.java @@ -0,0 +1,107 @@ +package com.iailab.module.watch; + +import com.iailab.common.utils.DateUtils; +import com.iailab.module.data.api.IFeignDataApi; +import com.iailab.module.data.dto.FeignResultDTO; +import com.iailab.module.data.dto.FeignWritePointValueDTO; +import lombok.extern.slf4j.Slf4j; +import javax.annotation.Resource; +import org.springframework.stereotype.Component; + +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.Map; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年06月05日 + */ +@Slf4j +@Component +public class WatchDog { + + private long failure_time = 1000 * 10; + + @Resource + private IFeignDataApi feignDataApi; + + public int writeWatchDogTime(String writePoint, String readPoint, String statusPoint, int lastHeat) { + try { + FeignWritePointValueDTO writeHeart = new FeignWritePointValueDTO(); + writeHeart.setPointCode(writePoint); + writeHeart.setPointValue(DateUtils.format(new Date(), DateUtils.TIME2_PATTERN)); + FeignResultDTO writeHeartResult = feignDataApi.setPointValue(writeHeart); + if (writeHeartResult.getCode() != 0) { + log.info("写入心跳值失败"); + setStsStop(statusPoint); + return lastHeat; + } + List<String> pointNos = new ArrayList<>(); + pointNos.add(readPoint); + Map<String, Object> readHeatValue = feignDataApi.getCurrentValue(pointNos); + Integer heartValue = new BigDecimal(readHeatValue.get(readPoint).toString()).intValue(); + log.info("heartValue=" + heartValue); + if (lastHeat == heartValue) { + log.info("心跳值无变化"); + setStsStop(statusPoint); + return lastHeat; + } + lastHeat = heartValue; + setStsNormal(statusPoint); + } catch (Exception ex) { + log.error("异常:控制器不能下发随机数;message:" + ex.getMessage()); + ex.printStackTrace(); + setStsStop(statusPoint); + + } + return lastHeat; + } + + public boolean isConnect(String pointNo) { + List<String> pointNos = new ArrayList<>(); + pointNos.add(pointNo); + Map<String, Object> pointValue = feignDataApi.getCurrentValue(pointNos); + Integer value = new BigDecimal(pointValue.get(pointNo).toString()).intValue(); + return WatchConstant.TX_STS_NORMAL.equals(value); + } + + public boolean isUse(String pointNo) { + List<String> pointNos = new ArrayList<>(); + pointNos.add(pointNo); + Map<String, Object> pointValue = feignDataApi.getCurrentValue(pointNos); + log.info("isUse=" + pointValue.get(pointNo).toString()); + return WatchConstant.CONTROLLER_ON.equals(pointValue.get(pointNo).toString()); + } + + public void stopControllerSts(String controllerCode) { + FeignWritePointValueDTO writeSts = new FeignWritePointValueDTO(); + writeSts.setPointCode(controllerCode); + writeSts.setPointValue(WatchConstant.CONTROLLER_OFF); + feignDataApi.setPointValue(writeSts); + } + + public void startControllerSts(String controllerCode) { + FeignWritePointValueDTO writeSts = new FeignWritePointValueDTO(); + writeSts.setPointCode(controllerCode); + writeSts.setPointValue(WatchConstant.CONTROLLER_ON); + feignDataApi.setPointValue(writeSts); + } + + private void setStsStop(String statusPoint) { + FeignWritePointValueDTO writeSts = new FeignWritePointValueDTO(); + writeSts.setPointCode(statusPoint); + writeSts.setPointValue(WatchConstant.TX_STS_STOP); + feignDataApi.setPointValue(writeSts); + } + + private void setStsNormal(String statusPoint) { + FeignWritePointValueDTO writeSts = new FeignWritePointValueDTO(); + writeSts.setPointCode(statusPoint); + writeSts.setPointValue(WatchConstant.TX_STS_NORMAL); + feignDataApi.setPointValue(writeSts); + } + +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/websocket/api/dto/ApiMsgDTO.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/websocket/api/dto/ApiMsgDTO.java new file mode 100644 index 0000000..78ef0ad --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/websocket/api/dto/ApiMsgDTO.java @@ -0,0 +1,48 @@ +package com.iailab.module.websocket.api.dto; + +import io.swagger.v3.oas.annotations.media.Schema; + +import lombok.Data; + +import javax.validation.constraints.NotNull; +import java.util.List; + +/** + * @author PanZhibao + * @Description + * @createTime 2023年03月28日 00:06:00 + */ +@Data +@Schema(name = "消息表") +public class ApiMsgDTO { + + @Schema(name = "id") + private String id = Long.toString(System.currentTimeMillis()); + + @Schema(name = "消息类型") + private String msgType; + + @Schema(name = "消息标题") + @NotNull(message="消息标题不能为空") + private String title; + + @Schema(name = "消息内容") + @NotNull(message="消息内容不能为空") + private String content; + + @Schema(name = "接收人") + @NotNull(message="接收人不能为空") + private List<String> receivers; + + @Schema(name = "发送人") + private String senderName; + + @Schema(name = "appKey") + @NotNull(message="appKey不能为空") + private String appKey; + + @Schema(name = "授权用户token") + @NotNull(message="授权用户token不能为空") + private String token; + +} diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/websocket/config/ServerEncoder.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/websocket/config/ServerEncoder.java new file mode 100644 index 0000000..27685b0 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/websocket/config/ServerEncoder.java @@ -0,0 +1,50 @@ +package com.iailab.module.websocket.config; + +import com.alibaba.fastjson.JSONObject; +import com.iailab.module.websocket.api.dto.ApiMsgDTO; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.websocket.EncodeException; +import javax.websocket.Encoder; +import javax.websocket.EndpointConfig; + +/** + * @desc: WebSocket编码器 + * @author: lirm + * @createTime 2023.11.23 + */ +public class ServerEncoder implements Encoder.Text<ApiMsgDTO> { + private static final Logger log = LoggerFactory.getLogger(ServerEncoder.class); + + /** + * 这里的参数 hashMap 要和 Encoder.Text<T>保持一致 + * @param hashMap + * @return + * @throws EncodeException + */ + @Override + public String encode(ApiMsgDTO hashMap) throws EncodeException { + /* + * 这里是重点,只需要返回Object序列化后的json字符串就行 + * 你也可以使用gosn,fastJson来序列化。 + * 这里我使用fastjson + */ + try { + return JSONObject.toJSONString(hashMap); + }catch (Exception e){ + log.error("",e); + } + return null; + } + + @Override + public void init(EndpointConfig endpointConfig) { + //可忽略 + } + + @Override + public void destroy() { + //可忽略 + } +} diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/websocket/config/WebSocketConfig.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/websocket/config/WebSocketConfig.java new file mode 100644 index 0000000..73b7370 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/websocket/config/WebSocketConfig.java @@ -0,0 +1,18 @@ +package com.iailab.module.websocket.config; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.socket.server.standard.ServerEndpointExporter; + +/** + * @author lirm + * @Description + * @createTime 2023.11.23 + */ +@Configuration +public class WebSocketConfig { + @Bean + public ServerEndpointExporter serverEndpointExporter(){ + return new ServerEndpointExporter(); + } +} diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/websocket/server/WebSocketServer.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/websocket/server/WebSocketServer.java new file mode 100644 index 0000000..b2c63fb --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/websocket/server/WebSocketServer.java @@ -0,0 +1,76 @@ +package com.iailab.module.websocket.server; + +import com.iailab.module.websocket.config.ServerEncoder; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +import javax.websocket.*; +import javax.websocket.server.PathParam; +import javax.websocket.server.ServerEndpoint; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.concurrent.ConcurrentHashMap; + +/** + * @author lirm + * @Description + * @createTime 2023.11.23 + */ +@Slf4j +@Component +@ServerEndpoint(encoders={ServerEncoder.class},value = "/socket/{username}") +public class WebSocketServer { + + /** + * 储存当前对象 + */ + private static Map<String, Session> sessionMap = new ConcurrentHashMap<>(); + + @OnOpen + public void onOpen(Session session, @PathParam("username") String username) { + sessionMap.put(username, session); + } + + @OnClose + public void onClose(@PathParam("username") String username) { + if (sessionMap.containsKey(username)) { + sessionMap.remove(username); + } + } + + @OnMessage + public void onMessage(String message) { + broadcastAllUser(message); + } + + @OnError + public void onError(Session session, Throwable error) { + error.printStackTrace(); + } + public void broadcastUsers(List<String> users, Object message) { + try { + Set<String> strings = sessionMap.keySet(); + for (String name : users) { + if (strings.contains(name)) { + sessionMap.get(name).getBasicRemote().sendObject(message); + } + } + } catch (Exception ex) { + log.error("广播消息出现异常"); + ex.printStackTrace(); + } + } + + public void broadcastAllUser(String message) { + try { + Set<String> strings = sessionMap.keySet(); + for (String name : strings) { + sessionMap.get(name).getBasicRemote().sendText(message); + } + } catch (Exception ex) { + log.error("广播消息出现异常"); + ex.printStackTrace(); + } + } +} diff --git a/iailab-module-model/iailab-module-model-biz/src/main/resources/application-dev.yml b/iailab-module-model/iailab-module-model-biz/src/main/resources/application-dev.yml new file mode 100644 index 0000000..34c4424 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/resources/application-dev.yml @@ -0,0 +1,91 @@ +--- #################### 注册中心 + 配置中心相关配置 #################### + +spring: + cloud: + nacos: + server-addr: @nacos.server@ # Nacos 服务器地址 + username: @nacos.username@ + password: @nacos.password@ + discovery: # 【配置中心】配置项 + namespace: @nacos.namespace@ # 命名空间。这里使用 dev 开发环境 + group: DEFAULT_GROUP # 使用的 Nacos 配置分组,默认为 DEFAULT_GROUP + metadata: + version: @nacos.metadata.version@ # 服务实例的版本号,可用于灰度发布 + config: # 【注册中心】配置项 + namespace: @nacos.namespace@ # 命名空间。这里使用 dev 开发环境 + group: DEFAULT_GROUP # 使用的 Nacos 配置分组,默认为 DEFAULT_GROUP + +--- #################### 数据库相关配置 #################### +spring: + datasource: + type: com.alibaba.druid.pool.DruidDataSource + druid: + driver-class-name: com.mysql.cj.jdbc.Driver + url: jdbc:mysql://127.0.0.1:3306/iailab_ntt_model?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai + username: root + password: 123456 + initial-size: 10 + max-active: 100 + min-idle: 10 + max-wait: 60000 + pool-prepared-statements: true + max-pool-prepared-statement-per-connection-size: 20 + time-between-eviction-runs-millis: 60000 + min-evictable-idle-time-millis: 300000 + #validationQuery是用来验证数据库连接的查询语句,这个查询语句必须是至少返回一条结果的SELECT语句。每种数据库都有各自的验证语句 + #validation-query: select 1 from sysibm.sysdummy1 + test-while-idle: true + test-on-borrow: false + test-on-return: false + stat-view-servlet: + enabled: true + url-pattern: /druid/* + #login-username: admin + #login-password: admin + filter: + stat: + log-slow-sql: true + slow-sql-millis: 1000 + merge-sql: false + wall: + config: + multi-statement-allow: true + redis: + database: 0 + host: 127.0.0.1 + port: 6379 + password: # 密码(默认为空) + timeout: 6000ms # 连接超时时长(毫秒) + jedis: + pool: + max-active: 1000 # 连接池最大连接数(使用负值表示没有限制) + max-wait: -1ms # 连接池最大阻塞等待时间(使用负值表示没有限制) + max-idle: 10 # 连接池中的最大空闲连接 + min-idle: 5 # 连接池中的最小空闲连接 + +##多数据源的配置 +dynamic: + datasource: + slave1: + driver-class-name: com.mysql.cj.jdbc.Driver + url: jdbc:mysql://127.0.0.1:3306/test?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai + username: root + password: 123456 +oadp: + domain: http://172.16.1.148:6010 + +influx-db: + org: IAILab + bucket: whs_data + token: 0p9sXgDxo4hyZ-hxhV7behQkto-8rD5GD0mTKb66_FHaDn_NoE1zusCP8fJznwfTdpttAjj7bEOeNrpt7cbRQw== + url: http://localhost:8086 + +iems: + upload: C:/DLUT/nginx/static/knowledge + +data: + domain: http://127.0.0.1:8980 + +iailab: + is-dev: y + diff --git a/iailab-module-model/iailab-module-model-biz/src/main/resources/application-local.yml b/iailab-module-model/iailab-module-model-biz/src/main/resources/application-local.yml new file mode 100644 index 0000000..9e75d86 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/resources/application-local.yml @@ -0,0 +1,164 @@ +--- #################### 注册中心 + 配置中心相关配置 #################### + +spring: + cloud: + nacos: + server-addr: @nacos.server@ # Nacos 服务器地址 + username: @nacos.username@ + password: @nacos.password@ + discovery: # 【配置中心】配置项 + namespace: @nacos.namespace@ # 命名空间。这里使用 dev 开发环境 + group: DEFAULT_GROUP # 使用的 Nacos 配置分组,默认为 DEFAULT_GROUP + metadata: + version: @nacos.metadata.version@ # 服务实例的版本号,可用于灰度发布 + config: # 【注册中心】配置项 + namespace: @nacos.namespace@ # 命名空间。这里使用 dev 开发环境 + group: DEFAULT_GROUP # 使用的 Nacos 配置分组,默认为 DEFAULT_GROUP + +--- #################### 数据库相关配置 #################### +spring: + # 数据源配置项 + autoconfigure: + exclude: + - com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure # 排除 Druid 的自动配置,使用 dynamic-datasource-spring-boot-starter 配置多数据源 + - de.codecentric.boot.admin.client.config.SpringBootAdminClientAutoConfiguration # 禁用 Spring Boot Admin 的 Client 的自动配置 + datasource: + druid: # Druid 【监控】相关的全局配置 + web-stat-filter: + enabled: true + stat-view-servlet: + enabled: true + allow: # 设置白名单,不填则允许所有访问 + url-pattern: /druid/* + login-username: # 控制台管理用户名和密码 + login-password: + filter: + stat: + enabled: true + log-slow-sql: true # 慢 SQL 记录 + slow-sql-millis: 100 + merge-sql: true + wall: + config: + multi-statement-allow: true + dynamic: # 多数据源配置 + druid: # Druid 【连接池】相关的全局配置 + initial-size: 1 # 初始连接数 + min-idle: 1 # 最小连接池数量 + max-active: 20 # 最大连接池数量 + max-wait: 600000 # 配置获取连接等待超时的时间,单位:毫秒 + time-between-eviction-runs-millis: 60000 # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位:毫秒 + min-evictable-idle-time-millis: 300000 # 配置一个连接在池中最小生存的时间,单位:毫秒 + max-evictable-idle-time-millis: 900000 # 配置一个连接在池中最大生存的时间,单位:毫秒 + validation-query: SELECT 1 FROM DUAL # 配置检测连接是否有效 + test-while-idle: true + test-on-borrow: false + test-on-return: false + primary: master + datasource: + master: + url: jdbc:mysql://127.0.0.1:3306/iailab_ntt_model?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例 + # url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=true&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai # MySQL Connector/J 5.X 连接的示例 + # url: jdbc:postgresql://127.0.0.1:5432/ruoyi-vue-pro # PostgreSQL 连接的示例 + # url: jdbc:oracle:thin:@127.0.0.1:1521:xe # Oracle 连接的示例 + # url: jdbc:sqlserver://127.0.0.1:1433;DatabaseName=ruoyi-vue-pro # SQLServer 连接的示例 + # url: jdbc:dm://10.211.55.4:5236?schema=RUOYI_VUE_PRO # DM 连接的示例 + username: root + password: 123456 + # username: sa # SQL Server 连接的示例 + # password: JSm:g(*%lU4ZAkz06cd52KqT3)i1?H7W # SQL Server 连接的示例 + # username: SYSDBA # DM 连接的示例 + # password: SYSDBA # DM 连接的示例 + slave: # 模拟从库,可根据自己需要修改 + lazy: true # 开启懒加载,保证启动速度 + url: jdbc:mysql://127.0.0.1:3306/iailab_ntt_model?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true + username: root + password: 123456 + + # Redis 配置。Redisson 默认的配置足够使用,一般不需要进行调优 + redis: + host: 172.16.8.100 # 地址 + port: 6379 # 端口 + database: 0 # 数据库索引 + password: 123456 # 密码,建议生产环境开启 + +--- #################### 定时任务相关配置 #################### + +xxl: + job: + enabled: true # 是否开启调度中心,默认为 true 开启 + admin: + addresses: http://127.0.0.1:9090/xxl-job-admin # 调度中心部署跟地址 + +--- #################### 服务保障相关配置 #################### + +# Lock4j 配置项 +lock4j: + acquire-timeout: 3000 # 获取分布式锁超时时间,默认为 3000 毫秒 + expire: 30000 # 分布式锁的超时时间,默认为 30 毫秒 + +--- #################### 监控相关配置 #################### + +# Actuator 监控端点的配置项 +management: + endpoints: + web: + base-path: /actuator # Actuator 提供的 API 接口的根目录。默认为 /actuator + exposure: + include: '*' # 需要开放的端点。默认值只打开 health 和 info 两个端点。通过设置 * ,可以开放所有端点。 + +# Spring Boot Admin 配置项 +spring: + boot: + admin: + # Spring Boot Admin Client 客户端的相关配置 + client: + instance: + service-host-type: IP # 注册实例时,优先使用 IP [IP, HOST_NAME, CANONICAL_HOST_NAME] + +# 日志文件配置 +logging: + level: + # 配置自己写的 MyBatis Mapper 打印日志 + com.iailab.module.system.dal.mysql: debug + com.iailab.module.system.dal.mysql.sensitiveword.SensitiveWordMapper: INFO # 配置 SensitiveWordMapper 的日志级别为 info + com.iailab.module.system.dal.mysql.sms.SmsChannelMapper: INFO # 配置 SmsChannelMapper 的日志级别为 info + +--- #################### 平台相关配置 #################### + +# 平台配置项,设置当前项目所有自定义的配置 +iailab: + is-dev: y + env: # 多环境的配置项 + tag: ${HOSTNAME} + captcha: + enable: false # 本地环境,暂时关闭图片验证码,方便登录等接口的测试 + security: + mock-enable: true + xss: + enable: false + exclude-urls: # 如下两个 url,仅仅是为了演示,去掉配置也没关系 + - ${spring.boot.admin.context-path}/** # 不处理 Spring Boot Admin 的请求 + - ${management.endpoints.web.base-path}/** # 不处理 Actuator 的请求 + access-log: # 访问日志的配置项 + enable: false + demo: false # 关闭演示模式 + + +oadp: + domain: http://172.16.1.148:6010 + +influx-db: + org: IAILab + bucket: whs_data + token: 0p9sXgDxo4hyZ-hxhV7behQkto-8rD5GD0mTKb66_FHaDn_NoE1zusCP8fJznwfTdpttAjj7bEOeNrpt7cbRQw== + url: http://localhost:8086 + +iems: + upload: C:/DLUT/nginx/static/knowledge + +data: + domain: http://127.0.0.1:8980 + + + diff --git a/iailab-module-model/iailab-module-model-biz/src/main/resources/application-prod.yml b/iailab-module-model/iailab-module-model-biz/src/main/resources/application-prod.yml new file mode 100644 index 0000000..3470519 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/resources/application-prod.yml @@ -0,0 +1,82 @@ +spring: + cloud: + nacos: + discovery: + server-addr: 192.168.55.179:8848 # 注册中心地址 nacos server + config: + server-addr: 192.168.55.179:8848 # 配置中心地址 nacos server + file-extension: yml # 配置中心的配置后缀 + datasource: + type: com.alibaba.druid.pool.DruidDataSource + druid: + driver-class-name: com.mysql.cj.jdbc.Driver + url: jdbc:mysql://192.168.55.180:3306/iailab_ntt_model?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai + username: root + password: 123456 + initial-size: 10 + max-active: 100 + min-idle: 10 + max-wait: 60000 + pool-prepared-statements: true + max-pool-prepared-statement-per-connection-size: 20 + time-between-eviction-runs-millis: 60000 + min-evictable-idle-time-millis: 300000 + #validationQuery是用来验证数据库连接的查询语句,这个查询语句必须是至少返回一条结果的SELECT语句。每种数据库都有各自的验证语句 + #validation-query: select 1 from sysibm.sysdummy1 + test-while-idle: true + test-on-borrow: false + test-on-return: false + stat-view-servlet: + enabled: true + url-pattern: /druid/* + #login-username: admin + #login-password: admin + filter: + stat: + log-slow-sql: true + slow-sql-millis: 1000 + merge-sql: false + wall: + config: + multi-statement-allow: true + redis: + database: 0 + host: 10.32.75.129 + port: 6379 + password: # 密码(默认为空) + timeout: 6000ms # 连接超时时长(毫秒) + jedis: + pool: + max-active: 1000 # 连接池最大连接数(使用负值表示没有限制) + max-wait: -1ms # 连接池最大阻塞等待时间(使用负值表示没有限制) + max-idle: 10 # 连接池中的最大空闲连接 + min-idle: 5 # 连接池中的最小空闲连接 + +##多数据源的配置 +dynamic: + datasource: + slave1: + driver-class-name: com.mysql.cj.jdbc.Driver + url: jdbc:mysql://192.168.55.181:3306/iailab_ntt_model_bak?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai + username: root + password: ntt@indus + +oadp: + domain: http://192.168.55.180:6010 + +influx-db: + org: IAILab + bucket: whs_data + token: 95A7quNeByW6MoUQj9cieA1JxCe-U95hOHdXXXJWMWXcXT8FFvdDCdymCav5W9S3n3LxCqHGOkzsVS6cWCKEtA== + url: http://localhost:8086 + username: root + password: 12345678 + +iems: + upload: C:/DLUT/nginx/static/knowledge + +data: + domain: http://192.168.55.180:8982 + +iailab: + is-dev: n \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/resources/application-test.yml b/iailab-module-model/iailab-module-model-biz/src/main/resources/application-test.yml new file mode 100644 index 0000000..4e4a249 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/resources/application-test.yml @@ -0,0 +1,65 @@ +spring: + cloud: + nacos: + discovery: + server-addr: 172.16.1.148:8848 # 注册中心地址 nacos server + config: + server-addr: 172.16.1.148:8848 # 配置中心地址 nacos server + file-extension: yml # 配置中心的配置后缀 + datasource: + type: com.alibaba.druid.pool.DruidDataSource + druid: + driver-class-name: com.mysql.cj.jdbc.Driver + url: jdbc:mysql://172.16.1.148:3306/iailab_ntt_model?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai + username: root + password: 123456 + initial-size: 10 + max-active: 100 + min-idle: 10 + max-wait: 60000 + pool-prepared-statements: true + max-pool-prepared-statement-per-connection-size: 20 + time-between-eviction-runs-millis: 60000 + min-evictable-idle-time-millis: 300000 + #validationQuery是用来验证数据库连接的查询语句,这个查询语句必须是至少返回一条结果的SELECT语句。每种数据库都有各自的验证语句 + #validation-query: select 1 from sysibm.sysdummy1 + test-while-idle: true + test-on-borrow: false + test-on-return: false + stat-view-servlet: + enabled: true + url-pattern: /druid/* + #login-username: admin + #login-password: admin + filter: + stat: + log-slow-sql: true + slow-sql-millis: 1000 + merge-sql: false + wall: + config: + multi-statement-allow: true + redis: + database: 0 + host: 172.16.1.148 + port: 6379 + password: # 密码(默认为空) + timeout: 6000ms # 连接超时时长(毫秒) + jedis: + pool: + max-active: 1000 # 连接池最大连接数(使用负值表示没有限制) + max-wait: -1ms # 连接池最大阻塞等待时间(使用负值表示没有限制) + max-idle: 10 # 连接池中的最大空闲连接 + min-idle: 5 # 连接池中的最小空闲连接 + +oadp: + domain: http://172.16.1.148:6010 + +influx-db: + org: IAILab + bucket: whs_data + token: dUoFsmlooCbyHsleY17w-_KpVf7vaFVRz0xBBuH4GZeOygMekoKpVi8kGIw49K_Qp_UDNf3RHpInoUIi4rTsow== + url: http://172.16.1.148:8086 + +iems: + upload-dir: D:/DLUT/znjt/safe/webapp/static/temp/ \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/resources/application-uat.yml b/iailab-module-model/iailab-module-model-biz/src/main/resources/application-uat.yml new file mode 100644 index 0000000..0d9d757 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/resources/application-uat.yml @@ -0,0 +1,42 @@ +spring: + datasource: + type: com.alibaba.druid.pool.DruidDataSource + druid: + driver-class-name: com.ibm.db2.jcc.DB2Driver + url: jdbc:db2://192.168.122.240:50000/MgEms:currentSchema=EXPERT; + username: db2admin + password: Pwd123456 + initial-size: 10 + max-active: 100 + min-idle: 10 + max-wait: 60000 + pool-prepared-statements: true + max-pool-prepared-statement-per-connection-size: 20 + time-between-eviction-runs-millis: 60000 + min-evictable-idle-time-millis: 300000 + #validationQuery是用来验证数据库连接的查询语句,这个查询语句必须是至少返回一条结果的SELECT语句。每种数据库都有各自的验证语句 + validation-query: select 1 from sysibm.sysdummy1 + test-while-idle: true + test-on-borrow: false + test-on-return: false + stat-view-servlet: + enabled: true + url-pattern: /druid/* + #login-username: admin + #login-password: admin + filter: + stat: + log-slow-sql: true + slow-sql-millis: 1000 + merge-sql: false + wall: + config: + multi-statement-allow: true + +oadp: + domain: http://172.16.1.148:6010 + +influx-db: + org: IAILab + bucket: whs_data + token: vhNZN5bZ4c2aa9daQUsmYtaM5qExnLVZYGE0fscVV9mAQhzAnFfExVdPWKrfGVtKPVPUUmM_xfWAJZ1iqqh0qQ== diff --git a/iailab-module-model/iailab-module-model-biz/src/main/resources/application.yml b/iailab-module-model/iailab-module-model-biz/src/main/resources/application.yml new file mode 100644 index 0000000..99fe1a8 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/resources/application.yml @@ -0,0 +1,156 @@ +spring: + application: + name: model-server + + profiles: + active: local + + main: + allow-circular-references: true # 允许循环依赖,因为项目是三层架构,无法避免这个情况。 + allow-bean-definition-overriding: true # 允许 Bean 覆盖,例如说 Feign 等会存在重复定义的服务 + + config: + import: + - optional:classpath:application-${spring.profiles.active}.yaml # 加载【本地】配置 + - optional:nacos:${spring.application.name}-${spring.profiles.active}.yaml # 加载【Nacos】的配置 + + # Servlet 配置 + servlet: + # 文件上传相关配置项 + multipart: + max-file-size: 16MB # 单个文件大小 + max-request-size: 32MB # 设置总上传的文件大小 + mvc: + pathmatch: + matching-strategy: ANT_PATH_MATCHER # 解决 SpringFox 与 SpringBoot 2.6.x 不兼容的问题,参见 SpringFoxHandlerProviderBeanPostProcessor 类 + + # Jackson 配置项 + jackson: + serialization: + write-dates-as-timestamps: true # 设置 LocalDateTime 的格式,使用时间戳 + write-date-timestamps-as-nanoseconds: false # 设置不使用 nanoseconds 的格式。例如说 1611460870.401,而是直接 1611460870401 + write-durations-as-timestamps: true # 设置 Duration 的格式,使用时间戳 + fail-on-empty-beans: false # 允许序列化无属性的 Bean + + # Cache 配置项 + cache: + type: REDIS + redis: + time-to-live: 1h # 设置过期时间为 1 小时 + +server: + port: 8983 + +logging: + file: + name: ${user.home}/logs/${spring.application.name}.log # 日志文件名,全路径 + +--- #################### 接口文档配置 #################### + +springdoc: + api-docs: + enabled: true # 1. 是否开启 Swagger 接文档的元数据 + path: /v3/api-docs + swagger-ui: + enabled: true # 2.1 是否开启 Swagger 文档的官方 UI 界面 + path: /swagger-ui.html + default-flat-param-object: true # 参见 https://doc.xiaominfo.com/docs/faq/v4/knife4j-parameterobject-flat-param 文档 + +knife4j: + enable: true + basic: + enable: false + username: admin + password: admin + setting: + enableFooter: false + +# MyBatis Plus 的配置项 +mybatis-plus: + configuration: + map-underscore-to-camel-case: true # 虽然默认为 true ,但是还是显示去指定下。 + global-config: + db-config: + id-type: AUTO # “智能”模式,基于 IdTypeEnvironmentPostProcessor + 数据源的类型,自动适配成 AUTO、INPUT 模式。 + # id-type: AUTO # 自增 ID,适合 MySQL 等直接自增的数据库 + # id-type: INPUT # 用户输入 ID,适合 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库 + # id-type: ASSIGN_ID # 分配 ID,默认使用雪花算法。注意,Oracle、PostgreSQL、Kingbase、DB2、H2 数据库时,需要去除实体类上的 @KeySequence 注解 + logic-delete-value: 1 # 逻辑已删除值(默认为 1) + logic-not-delete-value: 0 # 逻辑未删除值(默认为 0) + banner: false # 关闭控制台的 Banner 打印 + type-aliases-package: ${iailab.info.base-package}.*.entity + mapper-locations: classpath*:/mapper/**/*.xml + encryptor: + password: XDV71a+xqStEA3WH # 加解密的秘钥,可使用 https://www.imaegoo.com/2020/aes-key-generator/ 网站生成 + +mybatis-plus-join: + banner: false # 关闭控制台的 Banner 打印 + +# Spring Data Redis 配置 +spring: + data: + redis: + repositories: + enabled: false # 项目未使用到 Spring Data Redis 的 Repository,所以直接禁用,保证启动速度 + +# VO 转换(数据翻译)相关 +easy-trans: + is-enable-global: true # 启用全局翻译(拦截所有 SpringMVC ResponseBody 进行自动翻译 )。如果对于性能要求很高可关闭此配置,或通过 @IgnoreTrans 忽略某个接口 + is-enable-cloud: false # 禁用 TransType.RPC 微服务模式 + +--- #################### RPC 远程调用相关配置 #################### + +--- #################### 消息队列相关 #################### + +# rocketmq 配置项,对应 RocketMQProperties 配置类 +rocketmq: + # Producer 配置项 + producer: + group: ${spring.application.name}_PRODUCER # 生产者分组 + +spring: + # Kafka 配置项,对应 KafkaProperties 配置类 + kafka: + # Kafka Producer 配置项 + producer: + acks: 1 # 0-不应答。1-leader 应答。all-所有 leader 和 follower 应答。 + retries: 3 # 发送失败时,重试发送的次数 + value-serializer: org.springframework.kafka.support.serializer.JsonSerializer # 消息的 value 的序列化 + # Kafka Consumer 配置项 + consumer: + auto-offset-reset: earliest # 设置消费者分组最初的消费进度为 earliest 。可参考博客 https://blog.csdn.net/lishuangzhe7047/article/details/74530417 理解 + value-deserializer: org.springframework.kafka.support.serializer.JsonDeserializer + properties: + spring.json.trusted.packages: '*' + # Kafka Consumer Listener 监听器配置 + listener: + missing-topics-fatal: false # 消费监听接口监听的主题不存在时,默认会报错。所以通过设置为 false ,解决报错 + +--- #################### 定时任务相关配置 #################### + +xxl: + job: + executor: + appname: ${spring.application.name} # 执行器 AppName + logpath: ${user.home}/logs/xxl-job/${spring.application.name} # 执行器运行日志文件存储磁盘路径 + accessToken: default_token # 执行器通讯TOKEN + + +--- #################### 平台相关配置 #################### + +iailab: + info: + version: 1.0.0 + base-package: com.iailab.module + web: + admin-ui: + url: http://dashboard.iailab.iocoder.cn # Admin 管理后台 UI 的地址 + swagger: + title: 模型 + description: 模型 + version: ${iailab.info.version} + base-package: ${iailab.info.base-package} + tenant: # 多租户相关配置项 + enable: false + +debug: true \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/resources/banner.txt b/iailab-module-model/iailab-module-model-biz/src/main/resources/banner.txt new file mode 100644 index 0000000..f9d2f48 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/resources/banner.txt @@ -0,0 +1,8 @@ + + +,--. ,--.,--. ,--. ,--. ,--. ,--. ,--. +`--' ,--,--.`--'| | ,--,--.| |-. ,-----.,--,--, ,-' '-.,-' '-.,-----.,--,--,--. ,---. ,-| | ,---. | | +,--.' ,-. |,--.| |' ,-. || .-. ''-----'| \'-. .-''-. .-''-----'| || .-. |' .-. || .-. :| | +| |\ '-' || || |\ '-' || `-' | | || | | | | | | | | |' '-' '\ `-' |\ --.| | +`--' `--`--'`--'`--' `--`--' `---' `--''--' `--' `--' `--`--`--' `---' `---' `----'`--' + diff --git a/iailab-module-model/iailab-module-model-biz/src/main/resources/logback-spring.xml b/iailab-module-model/iailab-module-model-biz/src/main/resources/logback-spring.xml new file mode 100644 index 0000000..3ac202f --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/resources/logback-spring.xml @@ -0,0 +1,86 @@ +<?xml version="1.0" encoding="UTF-8"?> +<configuration scan="true"> + <property name="LOG_TEMP" value="./logs"/> + <include resource="org/springframework/boot/logging/logback/defaults.xml" /> + <!-- <include resource="org/springframework/boot/logging/logback/base.xml" /> --> + <logger name="org.springframework.web" level="INFO"/> + <logger name="org.springboot.sample" level="TRACE" /> + + <!-- 开发、测试环境 --> + <springProfile name="dev,test,prod"> + <logger name="org.springframework.web" level="INFO"/> + <logger name="org.springboot.sample" level="INFO" /> + <logger name="com.iailab" level="DEBUG" /> + </springProfile> + + <!-- 生产环境 --> + <!--<springProfile name="prod">--> + <!--<logger name="org.springframework.web" level="ERROR"/>--> + <!--<logger name="org.springboot.sample" level="ERROR" />--> + <!--<logger name="io.renren" level="ERROR" />--> + <!--</springProfile>--> + + <!-- 日志文件存放路径 --> + <property name="log_home" value="./logs" /> + <!-- 日志输出格式 --> + <!--生产用--> + <property name="log.pattern" value="[%d{yyyy-MM-dd HH:mm:ss.SSS}] | [%thread][%-5level] | [%logger{20}.%method,line : %line] %msg%n" /> + <!--本地测试使用--> + <!--<property name="log.pattern" value="[%boldGreen(%d{yyyy-MM-dd HH:mm:ss.SSS})] | [%highlight(%thread][%-5level)] | [%boldYellow(%logger{20}.%method,%line)] %msg%n" />--> + <!-- 日志输出格式【控制台】 --> + <!--<property name="log.pattern" value="%date{yyyy-MM-dd HH:mm:ss} | [ line: %line ] | %boldGreen(%thread) | %highlight(%-5level) | %boldYellow(%logger).%method | %msg%n"/>--> + + <!-- 控制台输出 --> + <appender name="console" class="ch.qos.logback.core.ConsoleAppender"> + <encoder> + <!--<pattern>${logPatternConsoleLog}</pattern>--> + <pattern>${log.pattern}</pattern> + </encoder> + </appender> + + <logger name="m-shop-mybatis-sql" level="debug"></logger> + + <!-- debug级别设置 --> + <appender name="file_debug" class="ch.qos.logback.core.rolling.RollingFileAppender"> + <prudent>true</prudent> + <filter class="ch.qos.logback.classic.filter.LevelFilter"> + <!--过滤 DEBUG--> + <level>DEBUG</level> + <!--匹配到就禁止--> + <!--<onMatch>ACCEPT</onMatch>--> + <!--没有匹配到就允许--> + <!--<onMismatch>DENY</onMismatch>--> + </filter> + <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> + <!--<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">--> + <!--日志文件输出的文件名--> + <!--<FileNamePattern>${log_home}/log-info.%d{yyyy-MM-dd}.%i.log</FileNamePattern>--> + <FileNamePattern>${log_home}/log-debug.%d{yyyy-MM-dd}.log</FileNamePattern> + <!--<maxFileSize>100MB</maxFileSize>--> + <!-- 日志最大的历史 7天 --> + <maxHistory>7</maxHistory> + <totalSizeCap>2GB</totalSizeCap> + <cleanHistoryOnStart>true</cleanHistoryOnStart> + </rollingPolicy> + <!--<triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">--> + <!--<!– 单文件最大50MB –>--> + <!--<maxFileSize>50MB</maxFileSize>--> + <!--</triggeringPolicy>--> + <encoder> + <pattern>${log.pattern}</pattern> + </encoder> + </appender> + + <!-- 系统模块日志级别控制 --> + <!--<logger name="com.btrh" level="info" />--> + + <!-- Spring日志级别控制 --> + <!--<logger name="org.springframework" level="info" />--> + + <!--系统操作日志--> + <root level="INFO"> + <appender-ref ref="console" /> + <appender-ref ref="file_debug" /> + </root> + +</configuration> diff --git a/iailab-module-model/iailab-module-model-biz/src/main/resources/mapper/device/DeviceAbnormalHistoryDao.xml b/iailab-module-model/iailab-module-model-biz/src/main/resources/mapper/device/DeviceAbnormalHistoryDao.xml new file mode 100644 index 0000000..e4d4946 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/resources/mapper/device/DeviceAbnormalHistoryDao.xml @@ -0,0 +1,12 @@ +<?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.device.dao.DeviceAbnormalHistoryDao"> + <insert id="insertHistory" parameterType="map"> + insert into `t_device_abnormal_history` (`total_count`, `abnormal_count`, `create_date`) + VALUES (#{total_count}, #{abnormal_count}, SYSDATE()) + </insert> + <select id="getlist" resultType="com.iailab.module.device.dto.DeviceAbnormalHistoryDTO"> + select * from t_device_abnormal_history where create_date between #{startDate} and #{endDate} + </select> +</mapper> \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/resources/mapper/device/DeviceAccountDao.xml b/iailab-module-model/iailab-module-model-biz/src/main/resources/mapper/device/DeviceAccountDao.xml new file mode 100644 index 0000000..c408928 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/resources/mapper/device/DeviceAccountDao.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.device.dao.DeviceAccountDao"> + <update id="updateMonitorState"> + update t_device_account set monitor_state = 0 + </update> + <delete id="delete"> + delete from t_device_account where 1=1 + </delete> + <select id="getByDeviceId" resultType="com.iailab.module.device.entity.DeviceAccountEntity"> + select * from t_device_account where device_id = #{id} + </select> + <select id="getDeviceIdList" resultType="java.lang.String"> + select device_id from t_device_account + </select> + + +</mapper> \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/resources/mapper/device/DeviceAccountHistoryDao.xml b/iailab-module-model/iailab-module-model-biz/src/main/resources/mapper/device/DeviceAccountHistoryDao.xml new file mode 100644 index 0000000..99243ab --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/resources/mapper/device/DeviceAccountHistoryDao.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.device.dao.DeviceAccountHistoryDao"> + + <resultMap type="com.iailab.module.device.entity.DeviceFaultHistoryEntity" id="deviceAccountHistoryMap"> + <result property="id" column="id"/> + <result property="faultDevice" column="fault_device"/> + <result property="faultParts" column="fault_parts"/> + <result property="faultType" column="fault_type"/> + <result property="faultCause" column="fault_cause"/> + <result property="solution" column="solution"/> + <result property="state" column="state"/> + <result property="affectHour" column="affect_hour"/> + <result property="creatorDate" column="creator_date"/> + </resultMap> + + +</mapper> \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/resources/mapper/device/DeviceFaultDao.xml b/iailab-module-model/iailab-module-model-biz/src/main/resources/mapper/device/DeviceFaultDao.xml new file mode 100644 index 0000000..50d6d0a --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/resources/mapper/device/DeviceFaultDao.xml @@ -0,0 +1,6 @@ +<?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.device.dao.DeviceFaultDao"> + +</mapper> \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/resources/mapper/device/DeviceHealthAlarmDao.xml b/iailab-module-model/iailab-module-model-biz/src/main/resources/mapper/device/DeviceHealthAlarmDao.xml new file mode 100644 index 0000000..b2eb258 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/resources/mapper/device/DeviceHealthAlarmDao.xml @@ -0,0 +1,36 @@ +<?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.device.dao.DeviceHealthAlarmDao"> + + <resultMap id="alarmCommonResult" type="com.iailab.module.device.dto.DeviceHealthAlarmDTO"> + <result column="dev_name" property="devName"/> + <result column="fault_time" property="faultTime"/> + <collection property="deviceFaults" ofType="com.iailab.module.device.dto.DeviceFaultDTO"> + <result column="index_type" property="indexType"/> + <result column="class_name" property="className"/> + <result column="fault_name" property="faultName"/> + <result column="solution" property="solution"/> + </collection> + + </resultMap> + + <select id="getInfo" resultMap="alarmCommonResult" + parameterType="java.lang.String"> + SELECT + t1.dev_name, + t1.fault_time, + t2.fault_name, + t3.class_name, + t3.index_type, + t3.solution + FROM + t_device_health_alarm t1, + t_device_health_alarm_detail t2, + t_device_fault t3 + WHERE + t1.id = t2.alarm_id + AND t2.fault_code = t3.fault_code + AND t1.id = #{id} + </select> +</mapper> \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/resources/mapper/device/DeviceHealthStateDao.xml b/iailab-module-model/iailab-module-model-biz/src/main/resources/mapper/device/DeviceHealthStateDao.xml new file mode 100644 index 0000000..eeb5aa1 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/resources/mapper/device/DeviceHealthStateDao.xml @@ -0,0 +1,34 @@ +<?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.device.dao.DeviceHealthStateDao"> + + <resultMap type="com.iailab.module.device.entity.DeviceHealthStateEntity" id="deviceHealthStateMap"> + <result property="id" column="id"/> + <result property="totalCount" column="total_count"/> + <result property="normal" column="normal"/> + <result property="common" column="common"/> + <result property="heavy" column="heavy"/> + <result property="serious" column="serious"/> + <result property="espserious" column="espSerious"/> + <result property="creatorDate" column="creator_date"/> + </resultMap> + <insert id="insertHealthState" parameterType="map"> + insert into `t_device_health_state` (`total_count`, `normal`, `common`, `heavy`, `serious`, `espserious`, `creator_date`) + VALUES (#{total_count}, #{normal}, #{common}, #{heavy}, #{serious}, #{espSerious}, SYSDATE()) + </insert> + <update id="updateHealthState" parameterType="map"> + update t_device_health_state + set total_count = #{total_count}, + normal = #{normal}, + common = #{common}, + heavy = #{heavy}, + serious = #{serious}, + espserious = #{espSerious}, + creator_date = SYSDATE() + where id = #{id} + </update> + <select id="getId" resultType="java.lang.Integer"> + select IF(count(1),id,0) from t_device_health_state group by id + </select> +</mapper> \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/resources/mapper/device/DeviceInfoDao.xml b/iailab-module-model/iailab-module-model-biz/src/main/resources/mapper/device/DeviceInfoDao.xml new file mode 100644 index 0000000..e64e354 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/resources/mapper/device/DeviceInfoDao.xml @@ -0,0 +1,34 @@ +<?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.device.dao.DeviceInfoDao"> + <select id="getchildrenList" resultType="com.iailab.module.device.dto.DeviceInfoDTO"> + select id, name, workshop + from t_device_info + where pid = #{id} + </select> + <select id="getPageList" resultType="com.iailab.module.device.dto.DeviceInfoDTO"> + select a.*,b.health_score healthScore,b.health_evaluate healthEvaluate,b.is_health isHealth,b.evaluate_date + evaluateDate, + IFNULL((select device_id from t_device_account where device_name = a.name),0) deviceId + from t_device_info a, + t_device_health_evaluate b + where a.id = b.device_id + <if test="params.no != null and params.no != ''"> + and a.no like concat('%',#{params.no},'%') + </if> + <if test="params.name != null and params.name != ''"> + and a.name like concat('%',#{params.name},'%') + </if> + <if test="params.isMain != null and params.isMain != ''"> + and a.is_main = #{params.isMain} + </if> + <if test="params.isMain != null and params.isMain != ''"> + and a.is_main = #{params.isMain} + </if> + + + </select> + + +</mapper> \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/resources/mapper/device/DeviceRunStateDao.xml b/iailab-module-model/iailab-module-model-biz/src/main/resources/mapper/device/DeviceRunStateDao.xml new file mode 100644 index 0000000..417414c --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/resources/mapper/device/DeviceRunStateDao.xml @@ -0,0 +1,33 @@ +<?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.device.dao.DeviceRunStateDao"> + + <resultMap type="com.iailab.module.device.entity.DeviceRunStateEntity" id="deviceRunStateMap"> + <result property="id" column="id"/> + <result property="totalCount" column="total_count"/> + <result property="runCount" column="run_count"/> + <result property="haltCount" column="halt_count"/> + <result property="offlineCount" column="offline_count"/> + <result property="creatorDate" column="creator_date"/> + </resultMap> + <insert id="insertRunState" parameterType="map"> + insert into `t_device_run_state` (`total_count`, `run_count`, `halt_count`, `offline_count`, `creator_date`) + VALUES (#{total_count}, #{run_count}, #{halt_count}, #{offline_count}, SYSDATE()) + </insert> + <update id="updateRunState" parameterType="map"> + update t_device_run_state + set total_count = #{total_count}, + run_count = #{run_count}, + halt_count = #{halt_count}, + offline_count = #{offline_count}, + creator_date = SYSDATE() + where id = #{id} + </update> + <select id="getId" resultType="java.lang.Integer"> + select IF(count(1), id, 0) + from t_device_run_state group by id + </select> + + +</mapper> \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/resources/mapper/device/DeviceStatCountDao.xml b/iailab-module-model/iailab-module-model-biz/src/main/resources/mapper/device/DeviceStatCountDao.xml new file mode 100644 index 0000000..ff67dc6 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/resources/mapper/device/DeviceStatCountDao.xml @@ -0,0 +1,6 @@ +<?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.device.dao.DeviceStatCountDao"> + +</mapper> \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/resources/mapper/device/DeviceStatNewnessDao.xml b/iailab-module-model/iailab-module-model-biz/src/main/resources/mapper/device/DeviceStatNewnessDao.xml new file mode 100644 index 0000000..7751fed --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/resources/mapper/device/DeviceStatNewnessDao.xml @@ -0,0 +1,24 @@ +<?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.device.dao.DeviceStatNewnessDao"> + + <select id="getLatDateList" resultType="com.iailab.module.device.dto.DeviceStatNewnessDTO"> + SELECT + t1.* + FROM + t_device_stat_newness AS t1, + ( + SELECT + dev_no, + max(date) as date + FROM + t_device_stat_newness + GROUP BY + dev_no + ) AS t2 + WHERE + t1.date = t2.date + AND t1.dev_no = t2.dev_no + </select> +</mapper> \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/resources/mapper/device/DeviceStatUsageDao.xml b/iailab-module-model/iailab-module-model-biz/src/main/resources/mapper/device/DeviceStatUsageDao.xml new file mode 100644 index 0000000..6eb8ba4 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/resources/mapper/device/DeviceStatUsageDao.xml @@ -0,0 +1,13 @@ +<?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.device.dao.DeviceStatUsageDao"> + + + <insert id="batchInsert"> + insert into t_device_stat_usage values + <foreach collection="list" item="item" open="(" close=")" separator=","> + #{item.id},#{item.devNo},#{item.devName},#{item.date},#{item.planTime},#{item.runTime},#{item.usageRate},#{item.createDate} + </foreach> + </insert> +</mapper> \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/resources/mapper/job/ScheduleJobDao.xml b/iailab-module-model/iailab-module-model-biz/src/main/resources/mapper/job/ScheduleJobDao.xml new file mode 100644 index 0000000..2bc8067 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/resources/mapper/job/ScheduleJobDao.xml @@ -0,0 +1,14 @@ +<?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.job.dao.ScheduleJobDao"> + + <!-- 批量更新状态 --> + <update id="updateBatch"> + update schedule_job set status = #{status} where id in + <foreach item="id" collection="ids" open="(" separator="," close=")"> + #{id} + </foreach> + </update> + +</mapper> \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/resources/mapper/job/ScheduleJobLogDao.xml b/iailab-module-model/iailab-module-model-biz/src/main/resources/mapper/job/ScheduleJobLogDao.xml new file mode 100644 index 0000000..0d20144 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/resources/mapper/job/ScheduleJobLogDao.xml @@ -0,0 +1,7 @@ +<?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.job.dao.ScheduleJobLogDao"> + + +</mapper> \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/resources/mapper/knowledge/KnowledgePathDao.xml b/iailab-module-model/iailab-module-model-biz/src/main/resources/mapper/knowledge/KnowledgePathDao.xml new file mode 100644 index 0000000..3d9bc10 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/resources/mapper/knowledge/KnowledgePathDao.xml @@ -0,0 +1,29 @@ +<?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.knowledge.dao.KnowledgePathDao"> + + <!-- 查询所有树形图节点 --> + <select id="selectPathList" resultType="com.iailab.module.knowledge.dto.KnowledgePathDTO"> + select * + from ( + select t1.id, + t1.id as value, + t1.label, + t1.parent_id + from t_knowledge_path t1 + inner join t_knowledge_path t2 on + t1.parent_id = t2.id + union + select id, + id as value, + label, + parent_id + from t_knowledge_path + where parent_id = '0000000000' + ) t + order by parent_id asc, + id asc + </select> + +</mapper> \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/resources/mapper/mcs/StModelDao.xml b/iailab-module-model/iailab-module-model-biz/src/main/resources/mapper/mcs/StModelDao.xml new file mode 100644 index 0000000..6e251d2 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/resources/mapper/mcs/StModelDao.xml @@ -0,0 +1,6 @@ +<?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.mcs.dao.StModelDao"> + +</mapper> \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/resources/mapper/mcs/StModelOutDao.xml b/iailab-module-model/iailab-module-model-biz/src/main/resources/mapper/mcs/StModelOutDao.xml new file mode 100644 index 0000000..6d6c33a --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/resources/mapper/mcs/StModelOutDao.xml @@ -0,0 +1,20 @@ +<?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.mcs.dao.StModelOutDao"> + <select id="getAll" resultType="com.iailab.module.mcs.dto.StModelOutDTO"> + select * from t_st_model_out where model_id = #{modelId} + order by sort + </select> + <delete id="deleteByModelId"> + delete from t_st_model_out where model_id = #{modelId} + </delete> + <select id="getOutPoint" parameterType="map" resultType="com.iailab.module.mcs.dto.StModelOutDTO"> + select t1.result_key,t1.is_write,t1.point_no,t1.disturbance_point_no + from t_st_model_out t1 + left join t_st_model t2 on t2.id = t1.model_id + where t2.model_code = #{modelCode} and t1.is_write = '1' + order by t1.sort + </select> + +</mapper> \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/resources/mapper/mcs/StModelParamDao.xml b/iailab-module-model/iailab-module-model-biz/src/main/resources/mapper/mcs/StModelParamDao.xml new file mode 100644 index 0000000..d35774d --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/resources/mapper/mcs/StModelParamDao.xml @@ -0,0 +1,14 @@ +<?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.mcs.dao.StModelParamDao"> + <select id="getAll" resultType="com.iailab.module.mcs.dto.StModelParamDTO"> + select * from t_st_model_param where model_id = #{modelId} order by param_order,param_port_order + </select> + + <delete id="deleteByModelId"> + delete from t_st_model_param where model_id = #{modelId} + </delete> + + +</mapper> \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/resources/mapper/mcs/StModelResultDao.xml b/iailab-module-model/iailab-module-model-biz/src/main/resources/mapper/mcs/StModelResultDao.xml new file mode 100644 index 0000000..692743b --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/resources/mapper/mcs/StModelResultDao.xml @@ -0,0 +1,142 @@ +<?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.mcs.dao.StModelResultDao"> + + <resultMap id="StModelResultEntity" type="com.iailab.module.mcs.entity.StModelResultEntity"> + <result property="modelId" column="model_id"/> + <result property="resultKey" column="result_key"/> + <result property="resultValue" column="result_value"/> + <result property="resultTime" column="result_time"/> + </resultMap> + + <resultMap id="StoreDependableAnalysisDTO" type="com.iailab.module.any.dto.AnyStoreReliabilityDTO"> + <result property="dateTime" column="dateTime"/> + <result property="grade" column="grade"/> + <result property="state" column="state"/> + <result property="analysis" column="analysis"/> + </resultMap> + + + <select id="getLastResultByCode" parameterType="map" resultType="com.iailab.module.mcs.dto.StModelResultDTO"> + select t2.result_key resultKey, t2.result_value resultValue, t2.result_time resultTime + from t_st_model t1 + inner join t_st_model_result t2 on t2.model_id = t1.id and t2.result_time = t1.run_time + where t1.model_code = #{modelCode} + </select> + <select id="getResultByCodeDate" parameterType="map" resultType="com.iailab.module.mcs.dto.StModelResultDTO"> + select t2.result_key resultKey, t2.result_value resultValue, t2.result_time resultTime + from t_st_model t1 + inner join t_st_model_result t2 on t2.model_id = t1.id + where t1.model_code = #{modelCode} and DATE_FORMAT(t2.result_time, '%Y-%m-%d') = #{resultTime} + </select> + + <select id="getResultList" parameterType="map" resultMap="StModelResultEntity"> + SELECT + b.model_id, + b.result_key, + b.result_value, + b.result_time + FROM + t_st_model_result b + left JOIN t_st_model a ON a.id = b.model_id + WHERE + b.result_key not in ('status', 'tips') + <if test="modelId != null and modelId != ''"> + AND b.model_id = #{modelId} + </if> + <if test="modelCode != null and modelCode != ''"> + AND a.model_code = #{modelCode} + </if> + AND result_time BETWEEN #{startDate} AND #{endDate} + ORDER BY + b.result_time ${sortType} + </select> + <select id="getModelResultList" resultType="com.iailab.common.dto.IndexStatisticDTO"> + SELECT + b.result_time dateTime,b.result_value data + FROM + t_st_model a, + t_st_model_result b + WHERE a.id = b.model_id + AND b.line_index = '0' + AND b.result_key = #{key} + AND result_time BETWEEN #{startDate} AND #{endDate} + ORDER BY + b.result_time + </select> + + <delete id="cleanModelResult" parameterType="map"> + delete from t_st_model_result + where result_time between #{startdate} and #{enddate} + </delete> + + <insert id="insertList" parameterType="list"> + INSERT INTO `t_st_model_result` (id, `model_id`, `line_index`, `result_key`, `result_value`, `result_time`) + VALUES + <foreach item="item" collection="list" separator=","> + (#{item.id},#{item.modelId},#{item.lineIndex},#{item.resultKey},#{item.resultValue},#{item.resultTime}) + </foreach> + </insert> + <insert id="migrationModelResult" + parameterType="java.util.List"> + INSERT INTO `t_st_model_result` (id, `model_id`, `line_index`, `result_key`, `result_value`, `result_time`) + VALUES + <foreach item="item" collection="list" separator=","> + (#{item.id},#{item.modelId},#{item.lineIndex},#{item.resultKey},#{item.resultValue},#{item.resultTime}) + </foreach> + </insert> + + <select id="getStorePageList" resultType="com.iailab.module.any.dto.AnyStoreReliabilityDTO"> + select t.* from ( + SELECT result_time as 'dateTime', + MAX(CASE WHEN result_key = 'score' THEN result_value END) AS 'score', + MAX(CASE WHEN result_key = 'analysis' THEN result_value END) AS 'analysis', + MAX(CASE WHEN result_key = 'judgement' THEN result_value END) AS 'judgement' + FROM `t_st_model_result` + <where> + model_id = #{params.modelId} + <if test="params.startTime != null and params.startTime != ''"> + and result_time >= #{params.startTime} + </if> + <if test="params.endTime != null and params.endTime != ''"> + and result_time <= #{params.endTime} + </if> + </where> + GROUP BY result_time + ) as t + <where> + <if test="params.judgement != null and params.judgement != ''"> + t.judgement like concat('%',#{params.judgement},'%') + </if> + </where> + </select> + <select id="getEvaluationPageList" resultType="com.iailab.module.any.dto.AnyAllEvaluationDTO"> + select * from ( + SELECT result_time as 'dateTime', + MAX(CASE WHEN result_key = 'first_level' THEN result_value END) AS 'first_level', + MAX(CASE WHEN result_key = 'zong_level' THEN result_value END) AS 'zong_level', + MAX(CASE WHEN result_key = 'shu_liang_fen' THEN result_value END) AS 'shu_liang_fen', + MAX(CASE WHEN result_key = 'zhi_liang_fen' THEN result_value END) AS 'zhi_liang_fen', + MAX(CASE WHEN result_key = 'sheng_chan_fen' THEN result_value END) AS 'sheng_chan_fen', + MAX(CASE WHEN result_key = 'guo_cheng_fen' THEN result_value END) AS 'guo_cheng_fen', + MAX(CASE WHEN result_key = 'guan_li_fen' THEN result_value END) AS 'guan_li_fen' + FROM `t_st_model_result` + <where> + model_id = #{params.modelId} + <if test="params.startDate != null and params.startDate != ''"> + and result_time >= #{params.startDate} + </if> + <if test="params.endDate != null and params.endDate != ''"> + and result_time <= #{params.endDate} + </if> + </where> + GROUP BY result_time + ) as t + <where> + <if test="params.state != null and params.state != ''"> + state like concat('%',#{params.state},'%') + </if> + </where> + </select> +</mapper> \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/resources/mapper/mcs/StModelRunlogDao.xml b/iailab-module-model/iailab-module-model-biz/src/main/resources/mapper/mcs/StModelRunlogDao.xml new file mode 100644 index 0000000..9669542 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/resources/mapper/mcs/StModelRunlogDao.xml @@ -0,0 +1,70 @@ +<?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.mcs.dao.StModelRunlogDao"> + <insert id="migrationModelRunlog" + parameterType="java.util.List"> + INSERT INTO `t_st_model_runlog` (id, `modelid`, `run_time`, `run_type`, `run_result`) + VALUES + <foreach item="item" collection="list" separator=","> + (#{item.id},#{item.modelid},#{item.runTime},#{item.runType},#{item.runCommonResult}) + </foreach> + </insert> + + <select id="getLastFxLog" resultType="com.iailab.module.mcs.dto.StModelRunlogDTO"> + select * + from t_st_model_runlog + where run_type in ('separation_control','DensityPredict') + order by run_time desc + limit 10 + </select> + <select id="getLastJyLog" resultType="com.iailab.module.mcs.dto.StModelRunlogDTO"> + select * + from t_st_model_runlog + where run_type in ('dosing_control','Dosingsystempre') + order by run_time desc + limit 10 + </select> + <select id="getLastLog" parameterType="map" resultType="com.iailab.module.mcs.dto.StModelRunlogDTO"> + select * + from t_st_model_runlog + where run_type = #{runType} + order by run_time desc + limit #{limit} + </select> + <delete id="cleanRunlogTask" parameterType="map"> + delete + from t_st_model_runlog + where run_time between #{startdate} and #{enddate} + </delete> + <select id="queryList" resultType="com.iailab.module.mcs.dto.StModelRunlogDTO" parameterType="map"> + SELECT a.model_code,a.model_name,b.* FROM t_st_model a,t_st_model_runlog b + where a.id = b.modelid + <if test="params.modelCode != null and params.modelCode != ''"> + and a.model_code LIKE concat(concat("%",#{params.modelCode}),"%") + </if> + <if test="params.modelName != null and params.modelName != ''"> + and a.model_name LIKE concat(concat("%",#{params.modelName}),"%") + </if> + <if test="params.startTime != null and params.startTime != ''"> + and b.run_time >= #{params.startTime} + </if> + <if test="params.endTime != null and params.endTime != ''"> + and b.run_time <= #{params.endTime} + </if> + order by b.run_time desc + </select> + <select id="listAll" resultType="com.iailab.module.mcs.dto.StModelRunlogDTO" parameterType="map"> + SELECT a.model_code,a.model_name,b.* FROM t_st_model a,t_st_model_runlog b + where a.id = b.modelid + <if test="modelCode != null and modelCode != ''"> + and a.model_code LIKE concat(concat("%",#{modelCode}),"%") + </if> + <if test="modelName != null and modelName != ''"> + and a.model_name LIKE concat(concat("%",#{modelName}),"%") + </if> + order by b.run_time desc + </select> + + +</mapper> \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/resources/mapper/mcs/StModelSettingDao.xml b/iailab-module-model/iailab-module-model-biz/src/main/resources/mapper/mcs/StModelSettingDao.xml new file mode 100644 index 0000000..a3c2a55 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/resources/mapper/mcs/StModelSettingDao.xml @@ -0,0 +1,14 @@ +<?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.mcs.dao.StModelSettingDao"> + <select id="getAll" resultType="com.iailab.module.mcs.dto.StModelSettingDTO"> + select * from t_st_model_setting where model_id = #{modelId} + order by setting_key + </select> + <delete id="deleteByModelId"> + delete from t_st_model_setting where model_id = #{modelId} + </delete> + + +</mapper> \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/resources/mapper/report/AnyProcReportDao.xml b/iailab-module-model/iailab-module-model-biz/src/main/resources/mapper/report/AnyProcReportDao.xml new file mode 100644 index 0000000..4371648 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/resources/mapper/report/AnyProcReportDao.xml @@ -0,0 +1,12 @@ +<?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.any.dao.AnyProcReportDao"> + <insert id="migrationProcReport" + parameterType="java.util.List"> + INSERT INTO `t_any_proc_report` (id, `proc_code`, `proc_name`, `report_name`, `report_date`, `content`, `create_date`) + VALUES + <foreach item="item" collection="list" separator=","> + (#{item.id},#{item.procCode},#{item.procName},#{item.reportName},#{item.reportDate},#{item.content},#{item.createDate}) + </foreach> + </insert> +</mapper> \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/resources/mapper/report/AnyProcReportDetDao.xml b/iailab-module-model/iailab-module-model-biz/src/main/resources/mapper/report/AnyProcReportDetDao.xml new file mode 100644 index 0000000..6af22c8 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/resources/mapper/report/AnyProcReportDetDao.xml @@ -0,0 +1,12 @@ +<?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.any.dao.AnyProcReportDetDao"> + <insert id="migration" + parameterType="java.util.List"> + INSERT INTO `t_any_proc_report_det` (id, `report_id`, `sort`, `content_type`, `content`, `remark`, `create_date`) + VALUES + <foreach item="item" collection="list" separator=","> + (#{item.id},#{item.reportId},#{item.sort},#{item.contentType},#{item.content},#{item.remark},#{item.createDate}) + </foreach> + </insert> +</mapper> \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/resources/mapper/report/DeviceHealthReportDao.xml b/iailab-module-model/iailab-module-model-biz/src/main/resources/mapper/report/DeviceHealthReportDao.xml new file mode 100644 index 0000000..1464e79 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/resources/mapper/report/DeviceHealthReportDao.xml @@ -0,0 +1,12 @@ +<?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.device.dao.DeviceHealthReportDao"> + <insert id="migration" + parameterType="java.util.List"> + INSERT INTO `t_device_health_report` (id, `dev_no`, `dev_name`, `class_no`, `class_name`, `workshop`, `model`, `report_no`, `report_name`, `report_date`, `health_level`, `health_score`, `abnormal_count`, `data_length`, `run_time`, `content`, `model_code`, `create_date`) + VALUES + <foreach item="item" collection="list" separator=","> + (#{item.id},#{item.devNo},#{item.devName},#{item.classNo},#{item.className},#{item.workshop},#{item.model},#{item.reportNo},#{item.reportName},#{item.reportDate},#{item.healthLevel},#{item.healthScore},#{item.abnormalCount},#{item.dataLength},#{item.runTime},#{item.content},#{item.modelCode},#{item.createDate}) + </foreach> + </insert> +</mapper> \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/resources/mapper/report/DeviceHealthReportDataDao.xml b/iailab-module-model/iailab-module-model-biz/src/main/resources/mapper/report/DeviceHealthReportDataDao.xml new file mode 100644 index 0000000..4b33a52 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/resources/mapper/report/DeviceHealthReportDataDao.xml @@ -0,0 +1,12 @@ +<?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.device.dao.DeviceHealthReportDataDao"> + <insert id="migration" + parameterType="java.util.List"> + INSERT INTO `t_device_health_report_data` (id, `report_id`, `sort`, `data_name`, `data_value`, `data_max`, `data_min`, `data_avg`, `grade_code`, `grade_name`, `solution`, `remark`, `create_date`, `fault_code`) + VALUES + <foreach item="item" collection="list" separator=","> + (#{item.id},#{item.reportId},#{item.sort},#{item.dataName},#{item.dataValue},#{item.dataMax},#{item.dataMin},#{item.dataAvg},#{item.gradeCode},#{item.gradeName},#{item.solution},#{item.remark},#{item.createDate},#{item.faultCode}) + </foreach> + </insert> +</mapper> \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/test/java/com/iailab/InfluxDBTest.java b/iailab-module-model/iailab-module-model-biz/src/test/java/com/iailab/InfluxDBTest.java new file mode 100644 index 0000000..0ca16f4 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/test/java/com/iailab/InfluxDBTest.java @@ -0,0 +1,68 @@ +package com.iailab; + +import com.iailab.module.model.influxdb.pojo.InfluxPointValuePOJO; +import com.iailab.module.model.influxdb.pojo.InfluxPointValueSimPOJO; +import com.iailab.module.model.influxdb.service.InfluxDBService; +import org.junit.Test; +import org.junit.runner.RunWith; +import javax.annotation.Resource; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit4.SpringRunner; + +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Date; +import java.util.List; + +/** + * @author PanZhibao + * @Description + * @createTime 2023年12月10日 12:19:00 + */ +@SpringBootTest +@RunWith(SpringRunner.class) +public class InfluxDBTest { + + @Resource + private InfluxDBService influxDBService; + + + @Test + public void testWrite() { + try { + List<InfluxPointValuePOJO> pointValues = new ArrayList<>(); + InfluxPointValuePOJO pojo = new InfluxPointValueSimPOJO(); + pojo.setPoint("88880102030001"); + pojo.setType("float"); + pojo.setTimestamp(new Date().toInstant()); + ((InfluxPointValueSimPOJO) pojo).setValue(123d); + pointValues.add(pojo); + + InfluxPointValuePOJO pojo1 = new InfluxPointValueSimPOJO(); + pojo1.setPoint("88880102030001"); + pojo1.setType("float"); + pojo1.setTimestamp(new Date().toInstant()); + ((InfluxPointValueSimPOJO) pojo1).setValue(456d); + pointValues.add(pojo1); + + influxDBService.asyncWritePointValues(pointValues); + } catch (Exception ex) { + ex.printStackTrace(); + } + + } + + @Test + public void testQueryPointMaxValue() { + InfluxPointValuePOJO point = new InfluxPointValuePOJO(); + point.setType("float"); + point.setPoint("88880102030001"); + Calendar calendar = Calendar.getInstance(); + calendar.add(Calendar.HOUR_OF_DAY, -1); + + Object value = influxDBService.queryPointMaxValue(point, calendar.getTime()); + + System.out.println("value=" + value); + + } +} diff --git a/iailab-module-model/iailab-module-model-biz/src/test/java/com/iailab/OadpTagCollectorTest.java b/iailab-module-model/iailab-module-model-biz/src/test/java/com/iailab/OadpTagCollectorTest.java new file mode 100644 index 0000000..d69fd61 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/test/java/com/iailab/OadpTagCollectorTest.java @@ -0,0 +1,43 @@ +package com.iailab; + +import com.iailab.module.collection.tag.impl.OadpTagCollector; +import org.junit.Test; +import org.junit.runner.RunWith; +import javax.annotation.Resource; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit4.SpringRunner; + +import java.util.ArrayList; +import java.util.Calendar; +import java.util.List; + +/** + * @author PanZhibao + * @Description + * @createTime 2023年04月25日 16:17:00 + */ +@SpringBootTest +@RunWith(SpringRunner.class) +public class OadpTagCollectorTest { + + @Resource + private OadpTagCollector tagCollector; + + @Test + public void test() { + Calendar calendar = Calendar.getInstance(); + calendar.set(Calendar.MILLISECOND, 0); + List<String> tags = new ArrayList<>(); + tags.add("source=producer-modbus;id=device0.change_random_int32"); + tags.add("source=producer-modbus;id=device0.change_random_float"); + tagCollector.collect(calendar.getTime(), tags); + } + + + @Test + public void testSp() { + String regex = "[+\\-\\*/()\\&&\\||]"; + String expression = "324123423&&34576||9999||66666+536345"; + String[] arr = expression.split(regex); + } +} diff --git a/iailab-module-model/pom.xml b/iailab-module-model/pom.xml new file mode 100644 index 0000000..478be0b --- /dev/null +++ b/iailab-module-model/pom.xml @@ -0,0 +1,25 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>com.iailab</groupId> + <artifactId>iailab-platform</artifactId> + <version>${revision}</version> + </parent> + + <artifactId>iailab-module-model</artifactId> + <packaging>pom</packaging> + <modules> + <module>iailab-module-model-biz</module> + <module>iailab-module-model-api</module> + </modules> + + <properties> + <maven.compiler.source>8</maven.compiler.source> + <maven.compiler.target>8</maven.compiler.target> + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> + </properties> + +</project> \ No newline at end of file diff --git a/iailab-module-system/iailab-module-system-api/src/main/java/com/iailab/module/system/api/params/ParamsApi.java b/iailab-module-system/iailab-module-system-api/src/main/java/com/iailab/module/system/api/params/ParamsApi.java new file mode 100644 index 0000000..5e0fa53 --- /dev/null +++ b/iailab-module-system/iailab-module-system-api/src/main/java/com/iailab/module/system/api/params/ParamsApi.java @@ -0,0 +1,21 @@ +package com.iailab.module.system.api.params; + +import com.iailab.module.system.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.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; + +@FeignClient(name = ApiConstants.NAME) +@Tag(name = "系统配置文件") +public interface ParamsApi { + + @Operation(summary = "Feign接口-查询月初或者年初") + @GetMapping("/api/feign/param/{paramCode}&&{type}") + String queryParamsByCode(@PathVariable("paramCode") String paramCode, @PathVariable("type") String type); + + @Operation(summary = "Feign接口-查询配置参数") + @GetMapping("/api/feign/sys-param/{paramCode}") + String queryParamByCode(@PathVariable("paramCode") String paramCode); +} diff --git a/iailab-module-system/iailab-module-system-api/src/main/java/com/iailab/module/system/api/permission/dto/RoleDTO.java b/iailab-module-system/iailab-module-system-api/src/main/java/com/iailab/module/system/api/permission/dto/RoleDTO.java new file mode 100644 index 0000000..c5c15af --- /dev/null +++ b/iailab-module-system/iailab-module-system-api/src/main/java/com/iailab/module/system/api/permission/dto/RoleDTO.java @@ -0,0 +1,64 @@ +package com.iailab.module.system.api.permission.dto; + +import com.iailab.framework.common.enums.CommonStatusEnum; +import com.iailab.module.system.enums.permission.DataScopeEnum; +import com.iailab.module.system.enums.permission.RoleTypeEnum; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.util.Date; + +/** + * 角色 DO + * + * @author houzhongjian + */ +@Schema(description = "角色") +@Data +public class RoleDTO{ + + /** + * 角色ID + */ + private Long id; + /** + * 角色名称 + */ + private String name; + /** + * 角色标识 + * + * 枚举 + */ + private String code; + /** + * 角色排序 + */ + private Integer sort; + /** + * 角色状态 + * + * 枚举 {@link CommonStatusEnum} + */ + private Integer status; + /** + * 角色类型 + * + * 枚举 {@link RoleTypeEnum} + */ + private Integer type; + /** + * 备注 + */ + private String remark; + + /** + * 数据范围 + * + * 枚举 {@link DataScopeEnum} + */ + private Integer dataScope; + + private Date updateDate; + +} diff --git a/iailab-module-system/iailab-module-system-biz/src/main/java/com/iailab/module/system/service/params/ParamsService.java b/iailab-module-system/iailab-module-system-biz/src/main/java/com/iailab/module/system/service/params/ParamsService.java new file mode 100644 index 0000000..dbfceb2 --- /dev/null +++ b/iailab-module-system/iailab-module-system-biz/src/main/java/com/iailab/module/system/service/params/ParamsService.java @@ -0,0 +1,50 @@ +///** +// * Copyright (c) 2018 人人开源 All rights reserved. +// * +// * https://www.renren.io +// * +// * 版权所有,侵权必究! +// */ +// +//package com.iailab.module.system.service.params; +// +// +//import com.iailab.common.page.PageData; +//import com.iailab.common.service.BaseService; +//import com.iailab.modules.sys.dto.SysParamsDTO; +//import com.iailab.modules.sys.entity.SysParamsEntity; +// +//import java.util.List; +//import java.util.Map; +// +///** +// * 参数管理 +// * +// * @author Mark sunlightcs@gmail.com +// * @since 1.0.0 +// */ +//public interface ParamsService extends BaseService<SysParamsEntity> { +// +// /** +// * 根据参数编码,获取参数的value值 +// * +// * @param paramCode 参数编码 +// */ +// String getValue(String paramCode); +// +// /** +// * 根据参数编码,获取value的Object对象 +// * @param paramCode 参数编码 +// * @param clazz Object对象 +// */ +// <T> T getValueObject(String paramCode, Class<T> clazz); +// +// /** +// * 根据参数编码,更新value +// * @param paramCode 参数编码 +// * @param paramValue 参数值 +// */ +// int updateValueByCode(String paramCode, String paramValue); +// +// String getValueByCode(String paramCode); +//} diff --git a/iailab-module-system/iailab-module-system-biz/src/main/java/com/iailab/module/system/service/params/ParamsServiceImpl.java b/iailab-module-system/iailab-module-system-biz/src/main/java/com/iailab/module/system/service/params/ParamsServiceImpl.java new file mode 100644 index 0000000..97877ad --- /dev/null +++ b/iailab-module-system/iailab-module-system-biz/src/main/java/com/iailab/module/system/service/params/ParamsServiceImpl.java @@ -0,0 +1,160 @@ +///** +// * Copyright (c) 2018 人人开源 All rights reserved. +// * +// * https://www.renren.io +// * +// * 版权所有,侵权必究! +// */ +// +//package com.iailab.module.system.service.params; +// +//import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +//import com.baomidou.mybatisplus.core.metadata.IPage; +//import com.iailab.common.constant.Constant; +//import com.iailab.common.exception.ErrorCode; +//import com.iailab.common.exception.RenException; +//import com.iailab.common.page.PageData; +//import com.iailab.common.service.impl.BaseServiceImpl; +//import com.iailab.common.utils.ConvertUtils; +//import com.iailab.common.utils.JsonUtils; +//import com.iailab.modules.sys.dao.SysParamsDao; +//import com.iailab.modules.sys.dto.SysParamsDTO; +//import com.iailab.modules.sys.entity.SysParamsEntity; +//import com.iailab.modules.sys.redis.SysParamsRedis; +//import com.iailab.modules.sys.service.SysParamsService; +//import org.apache.commons.lang3.StringUtils; +//import org.springframework.beans.factory.annotation.Autowired; +//import org.springframework.stereotype.Service; +//import org.springframework.transaction.annotation.Transactional; +// +//import java.util.ArrayList; +//import java.util.Arrays; +//import java.util.List; +//import java.util.Map; +// +///** +// * 参数管理 +// * +// * @author Mark sunlightcs@gmail.com +// * @since 1.0.0 +// */ +//@Service +//public class ParamsServiceImpl extends BaseServiceImpl<SysParamsDao, SysParamsEntity> implements SysParamsService { +// @Autowired +// private SysParamsRedis sysParamsRedis; +// +// @Override +// public PageData<SysParamsDTO> page(Map<String, Object> params) { +// IPage<SysParamsEntity> page = baseDao.selectPage( +// getPage(params, Constant.CREATE_DATE, false), +// getWrapper(params) +// ); +// +// return getPageData(page, SysParamsDTO.class); +// } +// +// @Override +// public List<SysParamsDTO> list(Map<String, Object> params) { +// List<SysParamsEntity> entityList = baseDao.selectList(getWrapper(params)); +// +// return ConvertUtils.sourceToTarget(entityList, SysParamsDTO.class); +// } +// +// private QueryWrapper<SysParamsEntity> getWrapper(Map<String, Object> params){ +// String paramCode = (String) params.get("paramCode"); +// String paramCodeList = (String) params.get("paramCodeList"); +// List<String> paramCodeArr = new ArrayList<>(); +// if (StringUtils.isNotBlank(paramCodeList)) { +// paramCodeArr = Arrays.asList(paramCodeList.split(",")); +// } +// +// QueryWrapper<SysParamsEntity> wrapper = new QueryWrapper<>(); +// wrapper.eq("param_type", 1); +// wrapper.like(StringUtils.isNotBlank(paramCode), "param_code", paramCode); +// wrapper.in(StringUtils.isNotBlank(paramCodeList), "param_code", paramCodeArr); +// +// return wrapper; +// } +// +// @Override +// public SysParamsDTO get(Long id) { +// SysParamsEntity entity = baseDao.selectById(id); +// +// return ConvertUtils.sourceToTarget(entity, SysParamsDTO.class); +// } +// +// @Override +// @Transactional(rollbackFor = Exception.class) +// public void save(SysParamsDTO dto) { +// SysParamsEntity entity = ConvertUtils.sourceToTarget(dto, SysParamsEntity.class); +// insert(entity); +// +// sysParamsRedis.set(entity.getParamCode(), entity.getParamValue()); +// } +// +// @Override +// @Transactional(rollbackFor = Exception.class) +// public void update(SysParamsDTO dto) { +// SysParamsEntity entity = ConvertUtils.sourceToTarget(dto, SysParamsEntity.class); +// updateById(entity); +// +// sysParamsRedis.set(entity.getParamCode(), entity.getParamValue()); +// } +// +// @Override +// @Transactional(rollbackFor = Exception.class) +// public void delete(Long[] ids) { +// //删除Redis数据 +// List<String> paramCodeList = baseDao.getParamCodeList(ids); +// String[] paramCodes = paramCodeList.toArray(new String[paramCodeList.size()]); +// sysParamsRedis.delete(paramCodes); +// +// //删除 +// deleteBatchIds(Arrays.asList(ids)); +// } +// +// @Override +// public String getValue(String paramCode) { +// String paramValue = sysParamsRedis.get(paramCode); +// if(paramValue == null){ +// paramValue = baseDao.getValueByCode(paramCode); +// +// sysParamsRedis.set(paramCode, paramValue); +// } +// return paramValue; +// } +// +// @Override +// public <T> T getValueObject(String paramCode, Class<T> clazz) { +// String paramValue = getValue(paramCode); +// if(StringUtils.isNotBlank(paramValue)){ +// return JsonUtils.parseObject(paramValue, clazz); +// } +// +// try { +// return clazz.newInstance(); +// } catch (Exception e) { +// throw new RenException(ErrorCode.PARAMS_GET_ERROR); +// } +// } +// +// @Override +// @Transactional(rollbackFor = Exception.class) +// public int updateValueByCode(String paramCode, String paramValue) { +// int count = baseDao.updateValueByCode(paramCode, paramValue); +// sysParamsRedis.set(paramCode, paramValue); +// return count; +// } +// +// @Override +// public String getValueByCode(String paramCode) { +// String paramValue = sysParamsRedis.get(paramCode); +// if(paramValue == null){ +// paramValue = baseDao.getValueByCode(paramCode); +// +// sysParamsRedis.set(paramCode, paramValue); +// } +// return paramValue; +// } +// +//} \ No newline at end of file -- Gitblit v1.9.3