From 8c41fe94af2f3b94a913289c8f8c3d687037a00b Mon Sep 17 00:00:00 2001 From: dengzedong <dengzedong@email> Date: 星期五, 20 九月 2024 09:39:57 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/master' --- iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/http/entity/HttpTagEntity.java | 31 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/common/enums/JsErrorCode.java | 10 iailab-module-system/iailab-module-system-biz/db/增量SQL/202409.sql | 6 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/opcua/controller/admin/ChannelOPCUADeviceController.java | 10 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/common/enums/IsEnableEnum.java | 21 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mpk/service/impl/MpkFileServiceImpl.java | 6 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/http/service/HttpTokenService.java | 2 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/common/enums/TagValueTypeConstant.java | 35 + iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/collection/PointCollector.java | 4 iailab-module-data/iailab-module-data-biz/src/main/resources/application-test.yaml | 13 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/kio/controller/admin/ChannelKioTagController.java | 10 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/common/xss/HTMLFilter.java | 530 +++++++++++++++++ iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/common/enums/DatabaseType.java | 9 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/http/vo/HttpApiRespVO.java | 36 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/opcua/controller/admin/ChannelOPCUATagController.java | 10 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/common/enums/DataSourceType.java | 35 + iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/common/xss/XssFilter.java | 29 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/http/service/impl/HttpTokenServiceImpl.java | 26 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/common/enums/CommonDict.java | 13 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/framework/rpc/config/RpcConfiguration.java | 3 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/http/entity/HttpApiEntity.java | 49 + iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/modbus/entity/ChannelModBusTagEntity.java | 2 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/http/controller/admin/HttpApiController.java | 39 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/common/exception/RRExceptionHandler.java | 56 + iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/sche/service/StScheduleModelService.java | 2 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/common/xss/XssHttpServletRequestWrapper.java | 139 ++++ iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/http/vo/HttpTagRespVO.java | 30 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/common/xss/SQLFilter.java | 42 + iailab-module-model/iailab-module-model-biz/src/main/resources/application.yml | 4 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/http/controller/admin/HttpTokenController.java | 23 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/opcda/controller/admin/ChannelOPCDATagController.java | 13 iailab-module-data/iailab-module-data-biz/db/mysql/tenant.sql | 36 iailab-module-model/iailab-module-model-biz/src/main/resources/banner.txt | 10 iailab-module-data/iailab-module-data-biz/pom.xml | 13 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/modbus/controller/admin/ChannelModbusTagController.java | 4 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/common/enums/ItemPredictStatus.java | 14 iailab-module-model/iailab-module-model-biz/src/main/resources/application-dev_rec.yaml | 4 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/modbus/controller/admin/ChannelModbusDeviceController.java | 10 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mpk/controller/package-info.java | 1 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/vo/DmModuleRespVO.java | 2 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/opcda/controller/package-info.java | 1 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/http/dao/HttpTagDao.java | 4 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/collection/handler/MeasureHandle.java | 12 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/opcda/controller/admin/ChannelOPCDADeviceController.java | 10 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mpk/controller/admin/ProjectController.java | 19 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/common/enums/RequestMethodType.java | 18 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/common/exception/RRException.java | 53 + iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/common/enums/CommonConstant.java | 18 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/sche/service/impl/StScheduleModelServiceImpl.java | 30 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/common/enums/RowAction.java | 15 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/common/enums/DataTypeEnum.java | 22 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/sche/entity/StScheduleModelEntity.java | 2 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/schedule/impl/ScheduleModelHandlerImpl.java | 2 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/tag/controller/TagController.java | 4 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/kio/controller/admin/ChannelKioDeviceController.java | 8 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mpk/controller/admin/MpkFileController.java | 19 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/opcua/entity/ChannelOPCUATagEntity.java | 4 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/common/interceptor/DataScope.java | 28 /dev/null | 42 - iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/common/interceptor/DataFilterInterceptor.java | 81 ++ iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/http/controller/admin/HttpTagController.java | 17 iailab-module-model/iailab-module-model-biz/pom.xml | 55 + iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/http/entity/HttpTokenEntity.java | 41 + 63 files changed, 1,547 insertions(+), 290 deletions(-) diff --git a/iailab-module-data/iailab-module-data-biz/db/mysql/tenant.sql b/iailab-module-data/iailab-module-data-biz/db/mysql/tenant.sql index 1df8e81..9ef32c6 100644 --- a/iailab-module-data/iailab-module-data-biz/db/mysql/tenant.sql +++ b/iailab-module-data/iailab-module-data-biz/db/mysql/tenant.sql @@ -116,7 +116,7 @@ `id` varchar(36) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, `tag_name` varchar(36) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '测点名称', `data_type` varchar(16) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '数据类型', - `tag_id` int NOT NULL COMMENT '顺序号', + `tag_id` int default NULL COMMENT '顺序号', `tag_desc` varchar(36) CHARACTER SET utf8 COLLATE utf8_general_ci default NULL COMMENT '测点描述', `enabled` tinyint(1) DEFAULT NULL COMMENT '是否启用', `device` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '关联设备', @@ -200,13 +200,13 @@ `code` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '编码', `name` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '名称', `url` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT 'URL', - `method` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '方法', + `method` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '请求方法', `param` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '参数', `descp` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '描述', `status` int NULL DEFAULT NULL COMMENT '状态', - `creator` VARCHAR(255) COMMENT '创建人' , + `creator` VARCHAR(64) COMMENT '创建人' , `create_time` DATETIME COMMENT '创建时间' , - `updater` VARCHAR(255) COMMENT '修改人' , + `updater` VARCHAR(64) COMMENT '修改人' , `update_time` DATETIME COMMENT '修改时间' , PRIMARY KEY (`ID`) USING BTREE, UNIQUE KEY `uk_code` (`code`) USING BTREE @@ -214,14 +214,14 @@ CREATE TABLE `t_http_token` ( - `id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL, - `api_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL, - `login_url` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL, - `client_id` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL, - `client_secret` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL, - `username` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL, - `password` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL, - `token` varchar(2000) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT 'token', + `id` varchar(36) NOT NULL COMMENT 'ID', + `api_id` varchar(36) NOT NULL COMMENT '接口ID', + `login_url` varchar(200) DEFAULT NULL COMMENT '登录地址', + `client_id` varchar(100) DEFAULT NULL COMMENT 'ClientId', + `client_secret` varchar(100) DEFAULT NULL COMMENT 'ClientSecret', + `username` varchar(50) DEFAULT NULL COMMENT '用户名', + `password` varchar(50) DEFAULT NULL COMMENT '密码', + `token` varchar(2000) DEFAULT NULL COMMENT 'token', `expire_time` datetime DEFAULT NULL COMMENT '过期时间', `update_time` datetime DEFAULT NULL COMMENT '更新时间', PRIMARY KEY (`id`) USING BTREE, @@ -229,14 +229,16 @@ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=DYNAMIC COMMENT='接口Token'; CREATE TABLE `t_http_tag` ( - `id` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '查询号', - `http_api_code` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT 'HTTP 接口代码', - `tag_code` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '测点编码', - `tag_name` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '测点名称', + `id` varchar(36) NOT NULL COMMENT 'ID', + `api_id` varchar(36) NOT NULL COMMENT '接口ID', + `tag_name` varchar(64) NOT NULL COMMENT '标签名称', + `data_type` varchar(16) NOT NULL COMMENT '数据类型', + `enabled` tinyint(1) DEFAULT NULL COMMENT '是否启用', + `tag_desc` varchar(64) DEFAULT NULL COMMENT '描述', `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', PRIMARY KEY (`id`) USING BTREE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='接口Tag表'; +) ENGINE=InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT='接口Tag表'; -- 指标管理------------ CREATE TABLE t_ind_data_set( diff --git a/iailab-module-data/iailab-module-data-biz/pom.xml b/iailab-module-data/iailab-module-data-biz/pom.xml index a55d2ee..1589b01 100644 --- a/iailab-module-data/iailab-module-data-biz/pom.xml +++ b/iailab-module-data/iailab-module-data-biz/pom.xml @@ -202,9 +202,16 @@ <plugins> <!-- 打包 --> <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-compiler-plugin</artifactId> - <version>3.1</version> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-maven-plugin</artifactId> + <version>${spring.boot.version}</version> + <executions> + <execution> + <goals> + <goal>repackage</goal> <!-- 将引入的 jar 打入其中 --> + </goals> + </execution> + </executions> </plugin> </plugins> </build> diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/http/collector/HttpCollectorForZxzk.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/http/collector/HttpCollectorForZxzk.java deleted file mode 100644 index 1828401..0000000 --- a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/http/collector/HttpCollectorForZxzk.java +++ /dev/null @@ -1,136 +0,0 @@ -package com.iailab.module.data.channel.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.channel.http.entity.HttpApiEntity; -import com.iailab.module.data.channel.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.info(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/channel/http/controller/admin/HttpApiController.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/http/controller/admin/HttpApiController.java index 222a362..2cbf40a 100644 --- a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/http/controller/admin/HttpApiController.java +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/http/controller/admin/HttpApiController.java @@ -7,10 +7,12 @@ import com.iailab.module.data.channel.http.service.HttpApiService; import com.iailab.module.data.channel.http.vo.HttpApiPageReqVO; import com.iailab.module.data.channel.http.vo.HttpApiRespVO; +import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import javax.validation.Valid; +import java.util.Date; import java.util.List; import java.util.UUID; @@ -28,58 +30,45 @@ @Resource private HttpApiService httpApiService; + @PreAuthorize("@ss.hasPermission('data:channel-http:query')") @GetMapping("page") public CommonResult<PageResult<HttpApiRespVO>> page(@Valid HttpApiPageReqVO reqVO) { PageResult<HttpApiEntity> page = httpApiService.queryPage(reqVO); return success(BeanUtils.toBean(page, HttpApiRespVO.class)); } + @PreAuthorize("@ss.hasPermission('data:channel-http:query')") @GetMapping("list") public CommonResult<List<HttpApiEntity>> list() { List<HttpApiEntity> list = httpApiService.list(); return success(list); } - /** - * 根据id查询详情 - * - * @param id - */ + @PreAuthorize("@ss.hasPermission('data:channel-http:query')") @GetMapping("/info/{id}") public CommonResult<HttpApiEntity> info(@PathVariable("id") String id){ HttpApiEntity info= httpApiService.info(id); return success(info); } - /** - * 添加API - * - * @param httpApiEntity - */ - @PostMapping("/add") - public CommonResult<Boolean> add(@RequestBody HttpApiEntity httpApiEntity){ - String id = UUID.randomUUID().toString(); - httpApiEntity.setId(id); + + @PreAuthorize("@ss.hasPermission('data:channel-http:create')") + @PostMapping("/create") + public CommonResult<Boolean> create(@RequestBody HttpApiEntity httpApiEntity){ + httpApiEntity.setId(UUID.randomUUID().toString()); + httpApiEntity.setCreateTime(new Date()); httpApiService.add(httpApiEntity); return success(true); } - /** - * 修改API - * - * @param httpApiEntity - */ + @PreAuthorize("@ss.hasPermission('data:channel-http:update')") @PutMapping("/update") public CommonResult<Boolean> update(@RequestBody HttpApiEntity httpApiEntity) { httpApiService.update(httpApiEntity); + httpApiEntity.setUpdateTime(new Date()); return success(true); } - /** - * 删除API - * - * @param id - * - */ + @PreAuthorize("@ss.hasPermission('data:channel-http:delete')") @DeleteMapping("/delete") public CommonResult<Boolean> delete(@RequestParam("id") String id) { httpApiService.delete(id); diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/http/controller/admin/HttpTagController.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/http/controller/admin/HttpTagController.java index 66a8a54..07b08cc 100644 --- a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/http/controller/admin/HttpTagController.java +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/http/controller/admin/HttpTagController.java @@ -7,10 +7,12 @@ import com.iailab.module.data.channel.http.service.HttpTagService; import com.iailab.module.data.channel.http.vo.HttpTagPageReqVO; import com.iailab.module.data.channel.http.vo.HttpTagRespVO; +import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import javax.validation.Valid; +import java.util.Date; import java.util.List; import java.util.UUID; @@ -23,44 +25,51 @@ * @createTime 2024年08月27日 */ @RestController -@RequestMapping("/data/http/tag") +@RequestMapping("/data/channel/http/tag") public class HttpTagController { @Resource private HttpTagService tagService; + @PreAuthorize("@ss.hasPermission('data:channel-http:query')") @GetMapping("page") public CommonResult<PageResult<HttpTagRespVO>> page(@Valid HttpTagPageReqVO reqVO) { PageResult<HttpTagEntity> page = tagService.queryPage(reqVO); return success(BeanUtils.toBean(page, HttpTagRespVO.class)); } + @PreAuthorize("@ss.hasPermission('data:channel-http:query')") @GetMapping("list") public CommonResult<List<HttpTagEntity>> list(){ List<HttpTagEntity> list = tagService.list(); return new CommonResult<List<HttpTagEntity>>().setData(list); } + @PreAuthorize("@ss.hasPermission('data:channel-http:query')") @GetMapping("/info/{id}") public CommonResult<HttpTagEntity> info(@PathVariable("id") String id){ HttpTagEntity info= tagService.info(id); return success(info); } - @PostMapping("/add") + @PreAuthorize("@ss.hasPermission('data:channel-http:create')") + @PostMapping("/create") public CommonResult<Boolean> add(@RequestBody HttpTagEntity httpTagEntity){ - String id = UUID.randomUUID().toString(); - httpTagEntity.setId(id); + httpTagEntity.setId(UUID.randomUUID().toString()); + httpTagEntity.setCreateTime(new Date()); tagService.add(httpTagEntity); return success(true); } + @PreAuthorize("@ss.hasPermission('data:channel-http:update')") @PutMapping("/update") public CommonResult<Boolean> update(@RequestBody HttpTagEntity httpTagEntity) { + httpTagEntity.setUpdateTime(new Date()); tagService.update(httpTagEntity); return success(true); } + @PreAuthorize("@ss.hasPermission('data:channel-http:delete')") @DeleteMapping("/delete") public CommonResult<Boolean> delete(@RequestParam("id") String id) { tagService.delete(id); diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/http/controller/admin/HttpTokenController.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/http/controller/admin/HttpTokenController.java index 31bd57c..2ca79c7 100644 --- a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/http/controller/admin/HttpTokenController.java +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/http/controller/admin/HttpTokenController.java @@ -7,10 +7,12 @@ import com.iailab.module.data.channel.http.service.HttpTokenService; import com.iailab.module.data.channel.http.vo.HttpTokenPageReqVO; import com.iailab.module.data.channel.http.vo.HttpTokenRespVO; +import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import javax.validation.Valid; +import java.util.Date; import java.util.List; import java.util.UUID; @@ -22,52 +24,59 @@ * @createTime 2024年08月27日 */ @RestController -@RequestMapping("/data/http/token") +@RequestMapping("/data/channel/http/token") public class HttpTokenController { @Resource private HttpTokenService httpTokenService; + @PreAuthorize("@ss.hasPermission('data:channel-http:query')") @GetMapping("page") public CommonResult<PageResult<HttpTokenRespVO>> page(@Valid HttpTokenPageReqVO reqVO) { PageResult<HttpTokenEntity> page = httpTokenService.queryPage(reqVO); return success(BeanUtils.toBean(page, HttpTokenRespVO.class)); } + @PreAuthorize("@ss.hasPermission('data:channel-http:query')") @GetMapping("list") public CommonResult<List<HttpTokenEntity>> list(){ List<HttpTokenEntity> list = httpTokenService.list(); return new CommonResult<List<HttpTokenEntity>>().setData(list); } + @PreAuthorize("@ss.hasPermission('data:channel-http:query')") @GetMapping("/info/{id}") public CommonResult<HttpTokenEntity> info(@PathVariable("id") String id){ HttpTokenEntity info= httpTokenService.info(id); return success(info); } - @PostMapping("/add") - public CommonResult<Boolean> add(@RequestBody HttpTokenEntity HttpTokenEntity){ - String id = UUID.randomUUID().toString(); - HttpTokenEntity.setId(id); + @PreAuthorize("@ss.hasPermission('data:channel-http:create')") + @PostMapping("/create") + public CommonResult<Boolean> create(@RequestBody HttpTokenEntity HttpTokenEntity){ + HttpTokenEntity.setId(UUID.randomUUID().toString()); + HttpTokenEntity.setUpdateTime(new Date()); httpTokenService.add(HttpTokenEntity); return success(true); } + @PreAuthorize("@ss.hasPermission('data:channel-http:update')") @PutMapping("/update") public CommonResult<Boolean> update(@RequestBody HttpTokenEntity HttpTokenEntity) { httpTokenService.update(HttpTokenEntity); return success(true); } + @PreAuthorize("@ss.hasPermission('data:channel-http:delete')") @DeleteMapping("/delete") public CommonResult<Boolean> delete(@RequestParam("id") String id) { httpTokenService.delete(id); return success(true); } - @GetMapping("/api-id/{apiId}") - public CommonResult<HttpTokenEntity> apiId(@PathVariable("apiId") String apiId) { + @PreAuthorize("@ss.hasPermission('data:channel-http:query')") + @GetMapping("/api-id") + public CommonResult<HttpTokenEntity> apiId(@RequestParam("apiId") String apiId) { HttpTokenEntity info = httpTokenService.getByApiId(apiId); return success(info); } diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/http/dao/HttpTagDao.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/http/dao/HttpTagDao.java index d693d62..aee37f1 100644 --- a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/http/dao/HttpTagDao.java +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/http/dao/HttpTagDao.java @@ -13,8 +13,8 @@ public interface HttpTagDao extends BaseMapperX<HttpTagEntity> { default PageResult<HttpTagEntity> selectPage(HttpTagPageReqVO reqVO) { return selectPage(reqVO, new LambdaQueryWrapperX<HttpTagEntity>() - .likeIfPresent(HttpTagEntity::getTagType, reqVO.getTagType()) - .likeIfPresent(HttpTagEntity::getTagCode, reqVO.getTagCode()) + .likeIfPresent(HttpTagEntity::getTagName, reqVO.getTagType()) + .likeIfPresent(HttpTagEntity::getTagName, reqVO.getTagCode()) .likeIfPresent(HttpTagEntity::getTagName, reqVO.getTagName()) .orderByDesc(HttpTagEntity::getCreateTime)); } diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/http/entity/EleLowTagEntity.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/http/entity/EleLowTagEntity.java deleted file mode 100644 index b3016e0..0000000 --- a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/http/entity/EleLowTagEntity.java +++ /dev/null @@ -1,58 +0,0 @@ -package com.iailab.module.data.channel.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/channel/http/entity/FxjyTagEntity.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/http/entity/FxjyTagEntity.java deleted file mode 100644 index 456e9cb..0000000 --- a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/http/entity/FxjyTagEntity.java +++ /dev/null @@ -1,53 +0,0 @@ -package com.iailab.module.data.channel.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/channel/http/entity/HttpApiEntity.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/http/entity/HttpApiEntity.java index de52968..d31bcc3 100644 --- a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/http/entity/HttpApiEntity.java +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/http/entity/HttpApiEntity.java @@ -20,14 +20,59 @@ @Schema(description = "主键") @TableId(value = "id", type = IdType.INPUT) private String id; - private String name; + + /** + * 编码 + */ private String code; + + /** + * 名称 + */ + private String name; + + /** + * URL + */ private String url; + + /** + * 请求方法 + */ private String method; - private String collectType; + + /** + * 参数 + */ private String param; + + /** + * 描述 + */ private String descp; + + /** + * 状态 + */ private Integer status; + + /** + * 创建人 + */ + 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/channel/http/entity/HttpTagEntity.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/http/entity/HttpTagEntity.java index fba20f9..4ab81e1 100644 --- a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/http/entity/HttpTagEntity.java +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/http/entity/HttpTagEntity.java @@ -27,26 +27,31 @@ private String id; /** - * HTTP api code + * 接口ID */ - private String httpApiCode; + private String apiId; /** - * 测点类型 - */ - private String tagType; - - /** - * 测点编码 - */ - private String tagCode; - - /** - * 测点名称 + * 标签名称 */ private String tagName; /** + * 数据类型 + */ + private String dataType; + + /** + * 标签描述 + */ + private String tagDesc; + + /** + * 是否启用 + */ + private Boolean enabled; + + /** * 创建时间 */ private Date createTime; diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/http/entity/HttpTokenEntity.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/http/entity/HttpTokenEntity.java index d6cdf22..d3f4b69 100644 --- a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/http/entity/HttpTokenEntity.java +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/http/entity/HttpTokenEntity.java @@ -10,7 +10,7 @@ import java.util.Date; @Data -@TableName("T_HTTP_TOKEN") +@TableName("t_http_token") public class HttpTokenEntity implements Serializable { private static final long serialVersionUID = 1L; @@ -20,16 +20,49 @@ @Schema(description = "主键") @TableId(value = "id", type = IdType.INPUT) private String id; + + /** + * 接口ID + */ private String apiId; + + /** + * 登录地址 + */ private String loginUrl; + + /** + * ClientId + */ private String clientId; + + /** + * ClientSecret + */ private String clientSecret; + + /** + * 用户名 + */ private String username; + + /** + * 密码 + */ private String password; + + /** + * token + */ 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/channel/http/entity/XSTTagEntity.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/http/entity/XSTTagEntity.java deleted file mode 100644 index 009e565..0000000 --- a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/http/entity/XSTTagEntity.java +++ /dev/null @@ -1,68 +0,0 @@ -package com.iailab.module.data.channel.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/channel/http/service/HttpTokenService.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/http/service/HttpTokenService.java index 07c2e0e..d8e1478 100644 --- a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/http/service/HttpTokenService.java +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/http/service/HttpTokenService.java @@ -21,7 +21,5 @@ 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/channel/http/service/impl/HttpTokenServiceImpl.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/http/service/impl/HttpTokenServiceImpl.java index 48f459c..bd6c61d 100644 --- a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/http/service/impl/HttpTokenServiceImpl.java +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/http/service/impl/HttpTokenServiceImpl.java @@ -65,32 +65,6 @@ return httpTokenDao.selectOne(wrapper); } - - @Override - public void updateToken(String clientId) { - Map<String, String> params = new HashMap<>(1); - params.put("timeout", "30000"); - HttpTokenEntity entity = httpTokenDao.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()); - httpTokenDao.update(entity, new QueryWrapper<HttpTokenEntity>().eq("client_id", clientId)); - } - @Override public String queryToken(String clientId) { return httpTokenDao.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/channel/http/vo/HttpApiRespVO.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/http/vo/HttpApiRespVO.java index ac6570f..9c73475 100644 --- a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/http/vo/HttpApiRespVO.java +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/http/vo/HttpApiRespVO.java @@ -21,36 +21,32 @@ @ExcelProperty("ID") private String id; - @Schema(description = "", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @ExcelProperty("") - private String name; - - @Schema(description = "", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @ExcelProperty("") + @Schema(description = "编码", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") + @ExcelProperty("编码") private String code; - @Schema(description = "", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @ExcelProperty("") + @Schema(description = "名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") + @ExcelProperty("名称") + private String name; + + @Schema(description = "URL", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") + @ExcelProperty("URL") private String url; - @Schema(description = "", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @ExcelProperty("") + @Schema(description = "请求方法", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") + @ExcelProperty("请求方法") private String method; - @Schema(description = "", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @ExcelProperty("") - private String collectType; - - @Schema(description = "", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @ExcelProperty("") + @Schema(description = "参数", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") + @ExcelProperty("参数") private String param; - @Schema(description = "", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @ExcelProperty("") + @Schema(description = "描述", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") + @ExcelProperty("描述") private String descp; - @Schema(description = "", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @ExcelProperty("") + @Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") + @ExcelProperty("状态") private Integer status; @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/http/vo/HttpTagRespVO.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/http/vo/HttpTagRespVO.java index f196604..c8a3d5a 100644 --- a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/http/vo/HttpTagRespVO.java +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/http/vo/HttpTagRespVO.java @@ -21,22 +21,26 @@ @ExcelProperty("ID") private String id; - @Schema(description = "api编码", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @ExcelProperty("api编码") - private String httpApiCode; + @Schema(description = "接口ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") + @ExcelProperty("接口ID") + private String apiId; - @Schema(description = "测点类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @ExcelProperty("测点类型") - private String tagType; - - @Schema(description = "测点编码", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @ExcelProperty("测点编码") - private String tagCode; - - @Schema(description = "测点名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @ExcelProperty("测点名称") + @Schema(description = "标签名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") + @ExcelProperty("标签名称") private String tagName; + @Schema(description = "数据类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") + @ExcelProperty("数据类型") + private String dataType; + + @Schema(description = "标签描述", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") + @ExcelProperty("标签描述") + private String tagDesc; + + @Schema(description = "是否启用", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") + @ExcelProperty("是否启用") + private Boolean enabled; + @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") @ExcelProperty("创建时间") private Date createTime; 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 index 8b50bee..67b5070 100644 --- 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 @@ -10,6 +10,7 @@ import com.iailab.module.data.channel.kio.vo.KioDeviceRespVO; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; +import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; @@ -32,12 +33,14 @@ @Resource private ChannelKioDeviceService channelKioDeviceService; + @PreAuthorize("@ss.hasPermission('data:channel-kio:query')") @GetMapping("page") public CommonResult<PageResult<KioDeviceRespVO>> list(@Valid KioDevicePageReqVO reqVO) { PageResult<ChannelKioDeviceEntity> page = channelKioDeviceService.queryPage(reqVO); return success(BeanUtils.toBean(page, KioDeviceRespVO.class)); } + @PreAuthorize("@ss.hasPermission('data:channel-kio:query')") @GetMapping("/info/{id}") @Operation(summary = "信息") public CommonResult<ChannelKioDeviceEntity> info(@PathVariable("id") String id) { @@ -45,8 +48,9 @@ return success(info); } + @PreAuthorize("@ss.hasPermission('data:channel-kio:create')") @PostMapping("/add") - public CommonResult<Boolean> add(@RequestBody ChannelKioDeviceEntity channelKioDeviceEntity) { + public CommonResult<Boolean> create(@RequestBody ChannelKioDeviceEntity channelKioDeviceEntity) { String id = UUID.randomUUID().toString(); channelKioDeviceEntity.setId(id); channelKioDeviceEntity.setCreateTime(new Date()); @@ -54,6 +58,7 @@ return success(true); } + @PreAuthorize("@ss.hasPermission('data:channel-kio:update')") @PutMapping("/update") public CommonResult<Boolean> update(@RequestBody ChannelKioDeviceEntity channelKioDeviceEntity) { channelKioDeviceEntity.setUpdateTime(new Date()); @@ -61,6 +66,7 @@ return success(true); } + @PreAuthorize("@ss.hasPermission('data:channel-kio:delete')") @DeleteMapping("/delete") public CommonResult<Boolean> delete(@RequestParam("id") String id) { channelKioDeviceService.delete(id); 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 index df61b27..6122d90 100644 --- 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 @@ -8,6 +8,7 @@ import com.iailab.module.data.channel.kio.vo.KioTagPageReqVO; import com.iailab.module.data.channel.kio.vo.KioTagRespVO; import io.swagger.v3.oas.annotations.Operation; +import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; @@ -29,12 +30,14 @@ /** * 分页查询tag * */ + @PreAuthorize("@ss.hasPermission('data:channel-kio:query')") @GetMapping("page") public CommonResult<PageResult<KioTagRespVO>> page(@Valid KioTagPageReqVO reqVO){ PageResult<ChannelKioTagEntity> page = channelKioTagService.queryPage(reqVO); return success(BeanUtils.toBean(page, KioTagRespVO.class)); } + @PreAuthorize("@ss.hasPermission('data:channel-kio:query')") @GetMapping("/info/{id}") @Operation(summary = "信息") public CommonResult<ChannelKioTagEntity> info(@PathVariable("id") String id) { @@ -42,8 +45,9 @@ return success(info); } - @PostMapping("/add") - public CommonResult<Boolean> add(@RequestBody ChannelKioTagEntity channelKioTagEntity) { + @PreAuthorize("@ss.hasPermission('data:channel-kio:create')") + @PostMapping("/create") + public CommonResult<Boolean> create(@RequestBody ChannelKioTagEntity channelKioTagEntity) { String id = UUID.randomUUID().toString(); channelKioTagEntity.setId(id); channelKioTagEntity.setCreateTime(new Date()); @@ -51,6 +55,7 @@ return success(true); } + @PreAuthorize("@ss.hasPermission('data:channel-kio:update')") @PutMapping("/update") public CommonResult<Boolean> update(@RequestBody ChannelKioTagEntity channelKioTagEntity) { channelKioTagEntity.setUpdateTime(new Date()); @@ -58,6 +63,7 @@ return success(true); } + @PreAuthorize("@ss.hasPermission('data:channel-kio:delete')") @DeleteMapping("/delete") public CommonResult<Boolean> delete(@RequestParam("id") String id) { channelKioTagService.delete(id); 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 index bfc5fce..f11d797 100644 --- 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 @@ -10,6 +10,7 @@ import javax.annotation.Resource; import com.iailab.module.data.channel.modbus.vo.ModBusDeviceRespVO; +import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; @@ -34,6 +35,7 @@ * * @param reqVO */ + @PreAuthorize("@ss.hasPermission('data:channel-modbus:query')") @GetMapping("/page") public CommonResult<PageResult<ModBusDeviceRespVO>> list(@Validated ModBusDevicePageReqVO reqVO) { PageResult<ChannelModBusDeviceEntity> page = channelModbusDeviceService.queryPage(reqVO); @@ -46,6 +48,7 @@ * * @param id */ + @PreAuthorize("@ss.hasPermission('data:channel-modbus:query')") @GetMapping("/info/{id}") public CommonResult<ChannelModBusDeviceEntity> info(@PathVariable("id") String id) { ChannelModBusDeviceEntity info = channelModbusDeviceService.info(id); @@ -57,8 +60,9 @@ * * @param channelModBusDeviceEntity */ - @PostMapping("/add") - public CommonResult<Boolean> add(@RequestBody ChannelModBusDeviceEntity channelModBusDeviceEntity) { + @PreAuthorize("@ss.hasPermission('data:channel-modbus:create')") + @PostMapping("/create") + public CommonResult<Boolean> create(@RequestBody ChannelModBusDeviceEntity channelModBusDeviceEntity) { String id = UUID.randomUUID().toString(); channelModBusDeviceEntity.setId(id); channelModbusDeviceService.add(channelModBusDeviceEntity); @@ -70,6 +74,7 @@ * * @param channelModBusDeviceEntity */ + @PreAuthorize("@ss.hasPermission('data:channel-modbus:update')") @PutMapping("/update") public CommonResult<Boolean> update(@RequestBody ChannelModBusDeviceEntity channelModBusDeviceEntity) { channelModbusDeviceService.update(channelModBusDeviceEntity); @@ -81,6 +86,7 @@ * * @param id */ + @PreAuthorize("@ss.hasPermission('data:channel-modbus:delete')") @DeleteMapping("/delete") public CommonResult<Boolean> delete(@RequestParam("id") String id) { channelModbusDeviceService.delete(id); 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 index cf82388..38b5a98 100644 --- 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 @@ -51,8 +51,8 @@ * * @param channelModBusTagEntity */ - @PostMapping("/add") - public CommonResult<Boolean> add(@RequestBody ChannelModBusTagEntity channelModBusTagEntity) { + @PostMapping("/create") + public CommonResult<Boolean> create(@RequestBody ChannelModBusTagEntity channelModBusTagEntity) { String id = UUID.randomUUID().toString(); channelModBusTagEntity.setId(id); channelModBusTagEntity.setCreateTime(new Date()); 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 index 4c24b18..b2a1bca 100644 --- 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 @@ -37,7 +37,7 @@ private String dataType; /** - * 是否可以tag,如果为false,即使定义了但是runtime不会读取该数据 + * 是否启用 */ private Boolean enabled; diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/opcda/controller/admin/ChannelOPCDADeviceController.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/opcda/controller/admin/ChannelOPCDADeviceController.java index 87693ea..c3331de 100644 --- a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/opcda/controller/admin/ChannelOPCDADeviceController.java +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/opcda/controller/admin/ChannelOPCDADeviceController.java @@ -8,6 +8,7 @@ import com.iailab.module.data.channel.opcda.vo.OpcDaDevicePageReqVO; import com.iailab.module.data.channel.opcda.vo.OpcDaDeviceRespVO; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.web.bind.annotation.*; import javax.validation.Valid; @@ -28,20 +29,23 @@ @Autowired private ChannelOPCDADeviceService channelOPCDADeviceService; + @PreAuthorize("@ss.hasPermission('data:channel-opcda:query')") @GetMapping("page") public CommonResult<PageResult<OpcDaDeviceRespVO>> list(@Valid OpcDaDevicePageReqVO reqVO) { PageResult<ChannelOPCDADeviceEntity> page = channelOPCDADeviceService.queryPage(reqVO); return success(BeanUtils.toBean(page, OpcDaDeviceRespVO.class)); } + @PreAuthorize("@ss.hasPermission('data:channel-opcda:query')") @GetMapping("/info/{id}") public CommonResult<ChannelOPCDADeviceEntity> info(@PathVariable("id") String id) { ChannelOPCDADeviceEntity info = channelOPCDADeviceService.info(id); return success(info); } - @PostMapping("/add") - public CommonResult<Boolean> add(@RequestBody ChannelOPCDADeviceEntity channelOPCDADeviceEntity) { + @PreAuthorize("@ss.hasPermission('data:channel-opcda:create')") + @PostMapping("/create") + public CommonResult<Boolean> create(@RequestBody ChannelOPCDADeviceEntity channelOPCDADeviceEntity) { String id = UUID.randomUUID().toString(); channelOPCDADeviceEntity.setId(id); channelOPCDADeviceEntity.setCreateTime(new Date()); @@ -49,6 +53,7 @@ return success(true); } + @PreAuthorize("@ss.hasPermission('data:channel-opcda:update')") @PutMapping("/update") public CommonResult<Boolean> update(@RequestBody ChannelOPCDADeviceEntity channelOPCDADeviceEntity) { channelOPCDADeviceEntity.setUpdateTime(new Date()); @@ -56,6 +61,7 @@ return success(true); } + @PreAuthorize("@ss.hasPermission('data:channel-opcda:delete')") @DeleteMapping("/delete") public CommonResult<Boolean> delete(@RequestParam("id") String id) { channelOPCDADeviceService.delete(id); diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/opcda/controller/admin/ChannelOPCDATagController.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/opcda/controller/admin/ChannelOPCDATagController.java index 77f35e7..2a6fb45 100644 --- a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/opcda/controller/admin/ChannelOPCDATagController.java +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/opcda/controller/admin/ChannelOPCDATagController.java @@ -9,6 +9,7 @@ import com.iailab.module.data.channel.opcda.vo.OpcDaTagRespVO; import com.iailab.module.data.common.exception.RRException; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; @@ -29,21 +30,24 @@ public class ChannelOPCDATagController { @Autowired private ChannelOPCDATagService channelOPCDATagService; - + + @PreAuthorize("@ss.hasPermission('data:channel-opcua:query')") @GetMapping("page") public CommonResult<PageResult<OpcDaTagRespVO>> list(@Valid OpcDaTagPageReqVO reqVO) { PageResult<ChannelOPCDATagEntity> page = channelOPCDATagService.queryPage(reqVO); return success(BeanUtils.toBean(page, OpcDaTagRespVO.class)); } + @PreAuthorize("@ss.hasPermission('data:channel-opcua:query')") @GetMapping("/info/{id}") public CommonResult<ChannelOPCDATagEntity> info(@PathVariable("id") String id) { ChannelOPCDATagEntity info = channelOPCDATagService.info(id); return success(info); } - @PostMapping("/add") - public CommonResult<Boolean> add(@RequestBody ChannelOPCDATagEntity channelOPCDATagEntity) { + @PreAuthorize("@ss.hasPermission('data:channel-opcua:create')") + @PostMapping("/create") + public CommonResult<Boolean> create(@RequestBody ChannelOPCDATagEntity channelOPCDATagEntity) { String id = UUID.randomUUID().toString(); channelOPCDATagEntity.setId(id); channelOPCDATagEntity.setCreateTime(new Date()); @@ -51,6 +55,7 @@ return success(true); } + @PreAuthorize("@ss.hasPermission('data:channel-opcua:update')") @PutMapping("/update") public CommonResult<Boolean> update(@RequestBody ChannelOPCDATagEntity channelOPCDATagEntity) { channelOPCDATagEntity.setUpdateTime(new Date()); @@ -58,11 +63,13 @@ return success(true); } + @PreAuthorize("@ss.hasPermission('data:channel-opcua:delete')") @DeleteMapping("/delete") public CommonResult<Boolean> delete(@RequestParam("id") String id) { channelOPCDATagService.delete(id); return success(true); } + @PostMapping("/import/{serverId}") public CommonResult<String> importTag(@PathVariable("serverId") String serverId, @RequestParam("file") MultipartFile file) { try { diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/opcda/controller/package-info.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/opcda/controller/package-info.java new file mode 100644 index 0000000..fe10629 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/opcda/controller/package-info.java @@ -0,0 +1 @@ +package com.iailab.module.data.channel.opcda.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/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 index fe43eee..6495268 100644 --- 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 @@ -7,6 +7,7 @@ import com.iailab.module.data.channel.opcua.service.ChannelOPCUADeviceService; import com.iailab.module.data.channel.opcua.vo.OpcUaDevicePageReqVO; import com.iailab.module.data.channel.opcua.vo.OpcUaDeviceRespVO; +import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; @@ -27,32 +28,37 @@ @Resource private ChannelOPCUADeviceService channelOPCUADeviceService; + @PreAuthorize("@ss.hasPermission('data:channel-opcua:query')") @GetMapping("page") public CommonResult<PageResult<OpcUaDeviceRespVO>> list(@Valid OpcUaDevicePageReqVO reqVO) { PageResult<ChannelOPCUADeviceEntity> page = channelOPCUADeviceService.queryPage(reqVO); return success(BeanUtils.toBean(page, OpcUaDeviceRespVO.class)); } + @PreAuthorize("@ss.hasPermission('data:channel-opcua:query')") @GetMapping("/info/{id}") public CommonResult<ChannelOPCUADeviceEntity> info(@PathVariable("id") String id) { ChannelOPCUADeviceEntity info = channelOPCUADeviceService.info(id); return success(info); } - @PostMapping("/add") - public CommonResult<Boolean> add(@RequestBody ChannelOPCUADeviceEntity channelOPCUADeviceEntity) { + @PreAuthorize("@ss.hasPermission('data:channel-opcua:create')") + @PostMapping("/create") + public CommonResult<Boolean> create(@RequestBody ChannelOPCUADeviceEntity channelOPCUADeviceEntity) { String id = UUID.randomUUID().toString(); channelOPCUADeviceEntity.setId(id); channelOPCUADeviceService.add(channelOPCUADeviceEntity); return success(true); } + @PreAuthorize("@ss.hasPermission('data:channel-opcua:update')") @PutMapping("/update") public CommonResult<Boolean> update(@RequestBody ChannelOPCUADeviceEntity channelOPCUADeviceEntity) { channelOPCUADeviceService.update(channelOPCUADeviceEntity); return success(true); } + @PreAuthorize("@ss.hasPermission('data:channel-opcua:delete')") @DeleteMapping("/delete") public CommonResult<Boolean> delete(@RequestParam("id") String id) { channelOPCUADeviceService.delete(id); 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 index 1a2f688..981ef30 100644 --- 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 @@ -7,6 +7,7 @@ import com.iailab.module.data.channel.opcua.service.ChannelOPCUATagService; import com.iailab.module.data.channel.opcua.vo.OpcUaTagPageReqVO; import com.iailab.module.data.channel.opcua.vo.OpcUaTagRespVO; +import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; @@ -28,20 +29,23 @@ @Resource private ChannelOPCUATagService channelOpcuaTagService; + @PreAuthorize("@ss.hasPermission('data:channel-opcua:query')") @GetMapping("page") public CommonResult<PageResult<OpcUaTagRespVO>> list(@Valid OpcUaTagPageReqVO reqVO) { PageResult<ChannelOPCUATagEntity> page = channelOpcuaTagService.queryPage(reqVO); return success(BeanUtils.toBean(page, OpcUaTagRespVO.class)); } + @PreAuthorize("@ss.hasPermission('data:channel-opcua:query')") @GetMapping("/info/{id}") public CommonResult<ChannelOPCUATagEntity> info(@PathVariable("id") String id) { ChannelOPCUATagEntity info = channelOpcuaTagService.info(id); return success(info); } - @PostMapping("/add") - public CommonResult<Boolean> add(@RequestBody ChannelOPCUATagEntity channelOPCUATagEntity) { + @PreAuthorize("@ss.hasPermission('data:channel-opcua:create')") + @PostMapping("/create") + public CommonResult<Boolean> create(@RequestBody ChannelOPCUATagEntity channelOPCUATagEntity) { String id = UUID.randomUUID().toString(); channelOPCUATagEntity.setId(id); channelOPCUATagEntity.setCreateTime(new Date()); @@ -49,6 +53,7 @@ return success(true); } + @PreAuthorize("@ss.hasPermission('data:channel-opcua:update')") @PutMapping("/update") public CommonResult<Boolean> update(@RequestBody ChannelOPCUATagEntity channelOPCUATagEntity) { channelOPCUATagEntity.setUpdateTime(new Date()); @@ -56,6 +61,7 @@ return success(true); } + @PreAuthorize("@ss.hasPermission('data:channel-opcua:delete')") @DeleteMapping("/delete") public CommonResult<Boolean> delete(@RequestParam("id") String id) { channelOpcuaTagService.delete(id); 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 index e487db4..857c0b4 100644 --- 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 @@ -16,7 +16,7 @@ * @createTime 2023年05月8日 15:01:00 */ @Data -@TableName("t_channel_opcda_tag") +@TableName("t_channel_opcua_tag") public class ChannelOPCUATagEntity implements Serializable { private static final long serialVersionUID = 1L; @@ -46,7 +46,7 @@ private String device; /** - * Modbus地址 00001 ~49999 + * 地址 */ private String address; 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 index 7813746..a946b31 100644 --- 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 @@ -157,8 +157,8 @@ List<TagOptionDTO> op2 = new ArrayList<>(); tags.forEach(item1 -> { TagOptionDTO op3 = new TagOptionDTO(); - op3.setValue(item1.getTagCode()); - op3.setLabel(item1.getTagCode()); + op3.setValue(item1.getTagName()); + op3.setLabel(item1.getTagName()); op2.add(op3); }); op1.setChildren(op2); 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 index 7bd34be..dc4c0be 100644 --- 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 @@ -7,7 +7,6 @@ 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.channel.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; @@ -55,9 +54,6 @@ @Resource private OpcUaCollector opcUaCollector; - - @Resource - private HttpCollectorForZxzk httpCollectorForZxzk; /** * 采集 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 index a5d084e..455b836 100644 --- 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 @@ -12,7 +12,6 @@ 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.channel.http.collector.HttpCollectorForZxzk; import com.iailab.module.data.influxdb.pojo.InfluxPointValuePOJO; import lombok.extern.slf4j.Slf4j; import javax.annotation.Resource; @@ -50,9 +49,6 @@ @Autowired private OpcDACollector opcDACollector; - - @Resource - private HttpCollectorForZxzk httpCollectorForZxzk; @Resource private DaPointService daPointService; @@ -95,10 +91,6 @@ } if (!CollectionUtils.isEmpty(kioTagIds)) { tagValues.putAll(kingIOCollector.getTagValues(kioTagIds)); - } - if (!CollectionUtils.isEmpty(httpTagZxzk)) { - tagValues.putAll(httpCollectorForZxzk.getTagValues(httpTagZxzk)); - } this.toCommonResult(collectTime, dtos, tagValues, dataMap, result); log.info("测量点处理结束"); @@ -175,9 +167,7 @@ } 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()); } diff --git a/iailab-module-model/iailab-module-model-biz/src/main/resources/application-dev.yaml b/iailab-module-data/iailab-module-data-biz/src/main/resources/application-test.yaml similarity index 81% copy from iailab-module-model/iailab-module-model-biz/src/main/resources/application-dev.yaml copy to iailab-module-data/iailab-module-data-biz/src/main/resources/application-test.yaml index ab357c4..52382fa 100644 --- a/iailab-module-model/iailab-module-model-biz/src/main/resources/application-dev.yaml +++ b/iailab-module-data/iailab-module-data-biz/src/main/resources/application-test.yaml @@ -38,7 +38,7 @@ primary: master datasource: master: - url: jdbc:mysql://127.0.0.1:3306/iailab_expert_master?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true + url: jdbc:mysql://172.16.8.100:3306/iailab_expert_master?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true username: root password: 123456 @@ -47,5 +47,14 @@ host: 127.0.0.1 # 地址 port: 6379 # 端口 database: 0 # 数据库索引 - # password: 123456 # 密码,建议生产环境开启 + password: 123456 # 密码,建议生产环境开启 + +influx-db: + org: IAILab + bucket: whs_data + token: gxhXM4H1VOBv07kYXKWyPag_zJ8_oChP4ooZ3u-BkSae9LS8R1wWzJYlmUjL3Qe9t1hDU3DtoYD5HTgjWoTGOg== + url: http://172.16.8.100:8086 + +iems: + upload-dir: D:/DLUT/upload/ diff --git a/iailab-module-model/iailab-module-model-biz/pom.xml b/iailab-module-model/iailab-module-model-biz/pom.xml index d04cd7a..6395271 100644 --- a/iailab-module-model/iailab-module-model-biz/pom.xml +++ b/iailab-module-model/iailab-module-model-biz/pom.xml @@ -58,11 +58,6 @@ <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> @@ -188,23 +183,43 @@ <plugins> <!-- 打包 --> <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-compiler-plugin</artifactId> - <version>3.1</version> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-maven-plugin</artifactId> + <version>${spring.boot.version}</version> + <executions> + <execution> + <goals> + <goal>repackage</goal> <!-- 将引入的 jar 打入其中 --> + </goals> + </execution> + </executions> </plugin> - <!-- <plugin>--> - <!-- <groupId>org.springframework.boot</groupId>--> - <!-- <artifactId>spring-boot-maven-plugin</artifactId>--> - <!-- <version>${spring.boot.version}</version>--> - <!-- <executions>--> - <!-- <execution>--> - <!-- <goals>--> - <!-- <goal>repackage</goal> <!– 将引入的 jar 打入其中 –>--> - <!-- </goals>--> - <!-- </execution>--> - <!-- </executions>--> - <!-- </plugin>--> + <plugin> + <groupId>org.codehaus.mojo</groupId> + <artifactId>flatten-maven-plugin</artifactId> + <version>1.1.0</version> + <configuration> + <updatePomFile>true</updatePomFile> + <flattenMode>resolveCiFriendliesOnly</flattenMode> + </configuration> + <executions> + <execution> + <id>flatten</id> + <phase>process-resources</phase> + <goals> + <goal>flatten</goal> + </goals> + </execution> + <execution> + <id>flatten.clean</id> + <phase>clean</phase> + <goals> + <goal>clean</goal> + </goals> + </execution> + </executions> + </plugin> </plugins> </build> diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/common/enums/CommonConstant.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/common/enums/CommonConstant.java new file mode 100644 index 0000000..1229790 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/common/enums/CommonConstant.java @@ -0,0 +1,18 @@ +package com.iailab.module.model.common.enums; + + +import java.math.BigDecimal; + +/** + * @Description: 通用常量 + */ +public interface CommonConstant { + + int IS_ENABLE = 1; + + BigDecimal BAD_VALUE = new BigDecimal("-2"); + + BigDecimal ZERO_VALUE = new BigDecimal("0"); + + String HTTP_API_ZXZK_IH = "ZXZK_IH"; +} diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/common/enums/CommonDict.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/common/enums/CommonDict.java new file mode 100644 index 0000000..a97c749 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/common/enums/CommonDict.java @@ -0,0 +1,13 @@ +package com.iailab.module.model.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-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/common/enums/DataSourceType.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/common/enums/DataSourceType.java new file mode 100644 index 0000000..eed3909 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/common/enums/DataSourceType.java @@ -0,0 +1,35 @@ +package com.iailab.module.model.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-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/common/enums/DataTypeEnum.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/common/enums/DataTypeEnum.java new file mode 100644 index 0000000..adc3f8e --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/common/enums/DataTypeEnum.java @@ -0,0 +1,22 @@ +package com.iailab.module.model.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-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/common/enums/DatabaseType.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/common/enums/DatabaseType.java new file mode 100644 index 0000000..3d2ffbd --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/common/enums/DatabaseType.java @@ -0,0 +1,9 @@ +package com.iailab.module.model.common.enums; + +/** + * @author PanZhibao + * @date 2021年09月01日 15:06 + */ +public enum DatabaseType { + DB2, MY_SQL, SQL_SERVER +} diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/common/enums/IsEnableEnum.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/common/enums/IsEnableEnum.java new file mode 100644 index 0000000..e02b21a --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/common/enums/IsEnableEnum.java @@ -0,0 +1,21 @@ +package com.iailab.module.model.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/module/model/common/enums/JsErrorCode.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/common/enums/JsErrorCode.java new file mode 100644 index 0000000..98f0f55 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/common/enums/JsErrorCode.java @@ -0,0 +1,10 @@ +package com.iailab.module.model.common.enums; + +/** + * @author PanZhibao + * @Description + * @createTime 2022年03月28日 17:46:00 + */ +public enum JsErrorCode { + Infinity, NaN +} diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/common/enums/RequestMethodType.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/common/enums/RequestMethodType.java new file mode 100644 index 0000000..d691bbc --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/common/enums/RequestMethodType.java @@ -0,0 +1,18 @@ +package com.iailab.module.model.common.enums; + +/** + * @author PanZhibao + * @date 2021年08月17日 11:28 + */ +public enum RequestMethodType { + + /** + * GET + */ + GET, + + /** + * POST + */ + POST +} diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/common/enums/RowAction.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/common/enums/RowAction.java new file mode 100644 index 0000000..0933368 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/common/enums/RowAction.java @@ -0,0 +1,15 @@ +package com.iailab.module.model.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-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/common/enums/TagValueTypeConstant.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/common/enums/TagValueTypeConstant.java new file mode 100644 index 0000000..ca6ff20 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/common/enums/TagValueTypeConstant.java @@ -0,0 +1,35 @@ +package com.iailab.module.model.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-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/common/exception/RRException.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/common/exception/RRException.java new file mode 100644 index 0000000..f058597 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/common/exception/RRException.java @@ -0,0 +1,53 @@ +package com.iailab.module.model.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/module/model/common/exception/RRExceptionHandler.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/common/exception/RRExceptionHandler.java new file mode 100644 index 0000000..9f5c309 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/common/exception/RRExceptionHandler.java @@ -0,0 +1,56 @@ +package com.iailab.module.model.common.exception;//package com.iailab.module.data.common.exception; +// +//import com.iailab.module.data.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-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/common/interceptor/DataFilterInterceptor.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/common/interceptor/DataFilterInterceptor.java new file mode 100644 index 0000000..c95779e --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/common/interceptor/DataFilterInterceptor.java @@ -0,0 +1,81 @@ +package com.iailab.module.model.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/module/model/common/interceptor/DataScope.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/common/interceptor/DataScope.java new file mode 100644 index 0000000..02eba79 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/common/interceptor/DataScope.java @@ -0,0 +1,28 @@ +package com.iailab.module.model.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/module/model/common/xss/HTMLFilter.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/common/xss/HTMLFilter.java new file mode 100644 index 0000000..d535e73 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/common/xss/HTMLFilter.java @@ -0,0 +1,530 @@ +package com.iailab.module.model.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-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/common/xss/SQLFilter.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/common/xss/SQLFilter.java new file mode 100644 index 0000000..74a012e --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/common/xss/SQLFilter.java @@ -0,0 +1,42 @@ +package com.iailab.module.model.common.xss; + +import com.iailab.module.model.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-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/common/xss/XssFilter.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/common/xss/XssFilter.java new file mode 100644 index 0000000..49476a5 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/common/xss/XssFilter.java @@ -0,0 +1,29 @@ +package com.iailab.module.model.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-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/common/xss/XssHttpServletRequestWrapper.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/common/xss/XssHttpServletRequestWrapper.java new file mode 100644 index 0000000..3267789 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/common/xss/XssHttpServletRequestWrapper.java @@ -0,0 +1,139 @@ +package com.iailab.module.model.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-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/framework/rpc/config/RpcConfiguration.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/framework/rpc/config/RpcConfiguration.java index 34ffc5d..6616b2c 100644 --- a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/framework/rpc/config/RpcConfiguration.java +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/framework/rpc/config/RpcConfiguration.java @@ -2,10 +2,11 @@ import com.iailab.module.data.api.point.DataPointApi; import com.iailab.module.infra.api.config.ConfigApi; +import com.iailab.module.system.api.tenant.TenantApi; import org.springframework.cloud.openfeign.EnableFeignClients; import org.springframework.context.annotation.Configuration; @Configuration(proxyBeanMethods = false) -@EnableFeignClients(clients = {DataPointApi.class,ConfigApi.class}) +@EnableFeignClients(clients = {DataPointApi.class, ConfigApi.class, TenantApi.class}) public class RpcConfiguration { } diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/vo/DmModuleRespVO.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/vo/DmModuleRespVO.java index 1dba4b7..c029686 100644 --- a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/vo/DmModuleRespVO.java +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/vo/DmModuleRespVO.java @@ -14,7 +14,7 @@ * @Description * @createTime 2024年08月29日 */ -@Schema(description = "模型平台 - ModBusDevice Response VO") +@Schema(description = "模型平台 - DmModule Response VO") @Data @ExcelIgnoreUnannotated public class DmModuleRespVO { diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/sche/entity/StScheduleModelEntity.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/sche/entity/StScheduleModelEntity.java index 8cff28a..3c20295 100644 --- a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/sche/entity/StScheduleModelEntity.java +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/sche/entity/StScheduleModelEntity.java @@ -14,7 +14,7 @@ * @date 2021年07月19日 15:03 */ @Data -@TableName("T_ST_SCHEDULE_MODEL") +@TableName("t_st_schedule_model") public class StScheduleModelEntity extends BaseDO { private static final long serialVersionUID = 1L; diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/sche/service/StScheduleModelService.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/sche/service/StScheduleModelService.java index 688f976..76aeb7b 100644 --- a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/sche/service/StScheduleModelService.java +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/sche/service/StScheduleModelService.java @@ -12,7 +12,7 @@ * @author PanZhibao * @date 2021年07月20日 14:13 */ -public interface StScheduleModelService extends BaseService<StScheduleModelEntity> { +public interface StScheduleModelService { PageResult<StScheduleModelEntity> page(StScheduleModelPageReqVO reqVO); diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/sche/service/impl/StScheduleModelServiceImpl.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/sche/service/impl/StScheduleModelServiceImpl.java index 35abed9..a3cf4d3 100644 --- a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/sche/service/impl/StScheduleModelServiceImpl.java +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/sche/service/impl/StScheduleModelServiceImpl.java @@ -1,8 +1,8 @@ package com.iailab.module.model.mcs.sche.service.impl; +import com.baomidou.dynamic.datasource.annotation.DSTransactional; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.iailab.framework.common.pojo.PageResult; -import com.iailab.framework.common.service.impl.BaseServiceImpl; import com.iailab.framework.common.util.object.BeanUtils; import com.iailab.module.model.mcs.sche.dao.StScheduleModelDao; import com.iailab.module.model.mcs.sche.entity.StScheduleModelEntity; @@ -16,6 +16,7 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import javax.annotation.Resource; import java.util.List; import java.util.UUID; @@ -24,7 +25,10 @@ * @date 2021年07月20日 14:23 */ @Service -public class StScheduleModelServiceImpl extends BaseServiceImpl<StScheduleModelDao, StScheduleModelEntity> implements StScheduleModelService { +public class StScheduleModelServiceImpl implements StScheduleModelService { + + @Resource + private StScheduleModelDao stScheduleModelDao; @Autowired private StScheduleModelParamService stScheduleModelParamService; @@ -34,43 +38,43 @@ @Override public PageResult<StScheduleModelEntity> page(StScheduleModelPageReqVO reqVO) { - return baseDao.selectPage(reqVO); + return stScheduleModelDao.selectPage(reqVO); } @Override public List<StScheduleModelEntity> list() { - return baseDao.selectList(null); + return stScheduleModelDao.selectList(null); } @Override - @Transactional(rollbackFor = Exception.class) + @DSTransactional(rollbackFor = Exception.class) public void create(StScheduleModelSaveReqVO reqVO) { StScheduleModelEntity entity = BeanUtils.toBean(reqVO, StScheduleModelEntity.class); entity.setId(UUID.randomUUID().toString()); - baseDao.insert(entity); + stScheduleModelDao.insert(entity); stScheduleModelParamService.saveList(entity.getId(), reqVO.getParamList()); stScheduleModelSettingService.saveList(entity.getId(), reqVO.getSettingList()); } @Override - @Transactional(rollbackFor = Exception.class) + @DSTransactional(rollbackFor = Exception.class) public void update(StScheduleModelSaveReqVO reqVO) { StScheduleModelEntity entity = BeanUtils.toBean(reqVO, StScheduleModelEntity.class); - baseDao.updateById(entity); + stScheduleModelDao.updateById(entity); stScheduleModelParamService.saveList(entity.getId(), reqVO.getParamList()); stScheduleModelSettingService.saveList(entity.getId(), reqVO.getSettingList()); } @Override public StScheduleModelEntity get(String id) { - return baseDao.selectById(id); + return stScheduleModelDao.selectById(id); } @Override - @Transactional(rollbackFor = Exception.class) + @DSTransactional(rollbackFor = Exception.class) public void delete(String id) { - baseDao.deleteById(id); + stScheduleModelDao.deleteById(id); stScheduleModelParamService.deleteByModelId(id); stScheduleModelSettingService.deleteByModelId(id); } @@ -82,12 +86,12 @@ QueryWrapper<StScheduleModelEntity> scheduleModelWrapper = new QueryWrapper<>(); scheduleModelWrapper.ne(StringUtils.isNotBlank(id), "id", id); scheduleModelWrapper.and(wrapper -> wrapper.eq("model_name", modelname)); - return baseDao.selectCount(scheduleModelWrapper); + return stScheduleModelDao.selectCount(scheduleModelWrapper); } @Override public Long count() { QueryWrapper<StScheduleModelEntity> wrapper = new QueryWrapper<>(); - return baseDao.selectCount(wrapper); + return stScheduleModelDao.selectCount(wrapper); } } diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/common/dto/MdkDataDTO.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/common/dto/MdkDataDTO.java deleted file mode 100644 index 2ca9412..0000000 --- a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/common/dto/MdkDataDTO.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.iailab.module.model.mdk.common.dto; - -/** - * @author PanZhibao - * @Description - * @createTime 2024年09月02日 - */ -public class MdkDataDTO { -} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/common/enums/ItemPredictStatus.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/common/enums/ItemPredictStatus.java index 7fae71b..b6da20e 100644 --- a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/common/enums/ItemPredictStatus.java +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/common/enums/ItemPredictStatus.java @@ -1,10 +1,13 @@ package com.iailab.module.model.mdk.common.enums; -import org.jetbrains.annotations.Contract; +import lombok.AllArgsConstructor; +import lombok.Getter; /** * 预测项的预测状态 */ +@Getter +@AllArgsConstructor public enum ItemPredictStatus { PREDICTING(1), @@ -15,13 +18,4 @@ private Integer value; - @Contract(pure = true) - ItemPredictStatus(Integer value) { - this.value = value; - } - - @Contract(pure = true) - public Integer getValue() { - return value; - } } diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/schedule/impl/ScheduleModelHandlerImpl.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/schedule/impl/ScheduleModelHandlerImpl.java index 34ecd54..ed4d4c8 100644 --- a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/schedule/impl/ScheduleModelHandlerImpl.java +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/schedule/impl/ScheduleModelHandlerImpl.java @@ -49,7 +49,7 @@ public ScheduleResultVO doSchedule(String schemeCode, Date scheduleTime) throws ModelInvokeException { ScheduleResultVO scheduleResult = new ScheduleResultVO(); StScheduleSchemeEntity scheduleScheme = stScheduleSchemeService.getByCode(schemeCode); - StScheduleModelEntity scheduleModel = stScheduleModelService.selectById(scheduleScheme.getModelId()); + StScheduleModelEntity scheduleModel = stScheduleModelService.get(scheduleScheme.getModelId()); if (scheduleModel == null) { throw new ModelInvokeException(MessageFormat.format("{0},modelId={1}", ModelInvokeException.errorGetModelEntity, scheduleModel.getId())); diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mpk/controller/admin/MpkFileController.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mpk/controller/admin/MpkFileController.java index ad7352f..f6fcaea 100644 --- a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mpk/controller/admin/MpkFileController.java +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mpk/controller/admin/MpkFileController.java @@ -7,6 +7,7 @@ import io.swagger.v3.oas.annotations.Operation; import org.apache.commons.io.IOUtils; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; @@ -30,12 +31,14 @@ @GetMapping("page") @Operation(summary = "分页") + @PreAuthorize("@ss.hasPermission('mpk:file:query')") public CommonResult<PageData<MpkFileDTO>> page(@RequestParam Map<String, Object> params) { PageData<MpkFileDTO> page = mpkFileService.page(params); return success(page); } + @PreAuthorize("@ss.hasPermission('mpk:file:query')") @GetMapping("{id}") public CommonResult<MpkFileDTO> info(@PathVariable("id") String id) { MpkFileDTO schedule = mpkFileService.get(id); @@ -43,6 +46,7 @@ return success(schedule); } + @PreAuthorize("@ss.hasPermission('mpk:file:query')") @GetMapping("list") public CommonResult<List<MpkFileDTO>> list() { List<MpkFileDTO> list = mpkFileService.list(new HashMap<>()); @@ -50,22 +54,25 @@ return success(list); } + @PreAuthorize("@ss.hasPermission('mpk:file:create')") @PostMapping - public CommonResult save(@RequestBody MpkFileDTO dto) { + public CommonResult<Boolean> save(@RequestBody MpkFileDTO dto) { mpkFileService.save(dto); - return CommonResult.success(); + return CommonResult.success(true); } + @PreAuthorize("@ss.hasPermission('mpk:file:delete')") @DeleteMapping - public CommonResult delete(String id) { + public CommonResult<Boolean> delete(String id) { mpkFileService.delete(id); - return CommonResult.success(); + return CommonResult.success(true); } + @PreAuthorize("@ss.hasPermission('mpk:file:update')") @PutMapping - public CommonResult update(@RequestBody MpkFileDTO dto) { + public CommonResult<Boolean> update(@RequestBody MpkFileDTO dto) { mpkFileService.update(dto); - return CommonResult.success(); + return CommonResult.success(true); } @GetMapping("generat") diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mpk/controller/admin/ProjectController.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mpk/controller/admin/ProjectController.java index 7110831..a7d841e 100644 --- a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mpk/controller/admin/ProjectController.java +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mpk/controller/admin/ProjectController.java @@ -7,6 +7,7 @@ import com.iailab.module.model.mpk.dto.ProjectPackageHistoryModelDTO; import com.iailab.module.model.mpk.service.ProjectService; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.web.bind.annotation.*; import java.util.Date; @@ -28,6 +29,7 @@ @Autowired private ProjectService projectService; + @PreAuthorize("@ss.hasPermission('mpk:project:query')") @GetMapping("page") public CommonResult<PageData<ProjectDTO>> page(@RequestParam Map<String, Object> params){ PageData<ProjectDTO> page = projectService.page(params); @@ -35,6 +37,7 @@ return success(page); } + @PreAuthorize("@ss.hasPermission('mpk:project:query')") @GetMapping("list") public CommonResult<List<ProjectDTO>> list() { List<ProjectDTO> list = projectService.list(new HashMap<>()); @@ -42,6 +45,7 @@ return success(list); } + @PreAuthorize("@ss.hasPermission('mpk:project:query')") @GetMapping("{id}") public CommonResult<ProjectDTO> get(@PathVariable("id") String id){ ProjectDTO data = projectService.get(id); @@ -49,27 +53,30 @@ return success(data); } + @PreAuthorize("@ss.hasPermission('mpk:project:create')") @PostMapping - public CommonResult save(@RequestBody ProjectDTO dto){ + public CommonResult<Boolean> save(@RequestBody ProjectDTO dto){ projectService.save(dto); - return CommonResult.success(); + return CommonResult.success(true); } + @PreAuthorize("@ss.hasPermission('mpk:project:update')") @PutMapping - public CommonResult update(@RequestBody ProjectDTO dto){ + public CommonResult<Boolean> update(@RequestBody ProjectDTO dto){ dto.setUpdateTime(new Date()); projectService.update(dto); - return CommonResult.success(); + return CommonResult.success(true); } + @PreAuthorize("@ss.hasPermission('mpk:project:delete')") @DeleteMapping - public CommonResult delete(String id){ + public CommonResult<Boolean> delete(String id){ projectService.delete(id); - return CommonResult.success(); + return CommonResult.success(true); } @GetMapping("getProjectModel") diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mpk/controller/package-info.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mpk/controller/package-info.java new file mode 100644 index 0000000..1a5b9c5 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mpk/controller/package-info.java @@ -0,0 +1 @@ +package com.iailab.module.model.mpk.controller; \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mpk/service/impl/MpkFileServiceImpl.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mpk/service/impl/MpkFileServiceImpl.java index a8aa81a..d0bb2f8 100644 --- a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mpk/service/impl/MpkFileServiceImpl.java +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mpk/service/impl/MpkFileServiceImpl.java @@ -67,12 +67,12 @@ @Autowired private ConfigApi configApi; - private String mpkBakFilePath; + private String mpkBakFilePath = ""; - @PostConstruct + /*@PostConstruct public void init() { mpkBakFilePath = configApi.getConfigValueByKey("mpkBakFilePath").getCheckedData(); - } + }*/ @Override public PageData<MpkFileDTO> page(Map<String, Object> params) { 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 deleted file mode 100644 index 3314b19..0000000 --- a/iailab-module-model/iailab-module-model-biz/src/main/resources/application-dev.yml +++ /dev/null @@ -1,91 +0,0 @@ ---- #################### 注册中心 + 配置中心相关配置 #################### - -spring: - cloud: - nacos: - server-addr: @nacos.server@ # Nacos 服务器地址 - username: @nacos.username@ - password: @nacos.password@ - discovery: # 【配置中心】配置项 - namespace: @profiles.active@ # 命名空间。这里使用 dev 开发环境 - group: DEFAULT_GROUP # 使用的 Nacos 配置分组,默认为 DEFAULT_GROUP - metadata: - version: @nacos.metadata.version@ # 服务实例的版本号,可用于灰度发布 - config: # 【注册中心】配置项 - namespace: @profiles.active@ # 命名空间。这里使用 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_expert_tenant_zjgt?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-dev.yaml b/iailab-module-model/iailab-module-model-biz/src/main/resources/application-dev_rec.yaml similarity index 95% rename from iailab-module-model/iailab-module-model-biz/src/main/resources/application-dev.yaml rename to iailab-module-model/iailab-module-model-biz/src/main/resources/application-dev_rec.yaml index ab357c4..dfd9856 100644 --- a/iailab-module-model/iailab-module-model-biz/src/main/resources/application-dev.yaml +++ b/iailab-module-model/iailab-module-model-biz/src/main/resources/application-dev_rec.yaml @@ -44,8 +44,8 @@ # Redis 配置。Redisson 默认的配置足够使用,一般不需要进行调优 redis: - host: 127.0.0.1 # 地址 + host: 172.16.8.100 # 地址 port: 6379 # 端口 database: 0 # 数据库索引 - # password: 123456 # 密码,建议生产环境开启 + password: 123456 # 密码,建议生产环境开启 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 deleted file mode 100644 index c253d89..0000000 --- a/iailab-module-model/iailab-module-model-biz/src/main/resources/application-local.yml +++ /dev/null @@ -1,147 +0,0 @@ ---- #################### 数据库相关配置 #################### -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 deleted file mode 100644 index 3470519..0000000 --- a/iailab-module-model/iailab-module-model-biz/src/main/resources/application-prod.yml +++ /dev/null @@ -1,82 +0,0 @@ -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 deleted file mode 100644 index 4e4a249..0000000 --- a/iailab-module-model/iailab-module-model-biz/src/main/resources/application-test.yml +++ /dev/null @@ -1,65 +0,0 @@ -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 deleted file mode 100644 index 0d9d757..0000000 --- a/iailab-module-model/iailab-module-model-biz/src/main/resources/application-uat.yml +++ /dev/null @@ -1,42 +0,0 @@ -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 index 1161edd..983a693 100644 --- 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 @@ -11,12 +11,12 @@ username: @nacos.username@ password: @nacos.password@ discovery: # 【配置中心】配置项 - namespace: ${spring.profiles.active} + namespace: test group: DEFAULT_GROUP # 使用的 Nacos 配置分组,默认为 DEFAULT_GROUP metadata: version: @nacos.metadata.version@ # 服务实例的版本号,可用于灰度发布 config: # 【注册中心】配置项 - namespace: ${spring.profiles.active} + namespace: test group: DEFAULT_GROUP # 使用的 Nacos 配置分组,默认为 DEFAULT_GROUP main: 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 index f9d2f48..a092e7e 100644 --- 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 @@ -1,8 +1,8 @@ -,--. ,--.,--. ,--. ,--. ,--. ,--. ,--. -`--' ,--,--.`--'| | ,--,--.| |-. ,-----.,--,--, ,-' '-.,-' '-.,-----.,--,--,--. ,---. ,-| | ,---. | | -,--.' ,-. |,--.| |' ,-. || .-. ''-----'| \'-. .-''-. .-''-----'| || .-. |' .-. || .-. :| | -| |\ '-' || || |\ '-' || `-' | | || | | | | | | | | |' '-' '\ `-' |\ --.| | -`--' `--`--'`--'`--' `--`--' `---' `--''--' `--' `--' `--`--`--' `---' `---' `----'`--' +,--. ,--.,--. ,--. ,--. ,--. +`--' ,--,--.`--'| | ,--,--.| |-. ,-----.,--,--,--. ,---. ,-| | ,---. | | +,--.' ,-. |,--.| |' ,-. || .-. ''-----'| || .-. |' .-. || .-. :| | +| |\ '-' || || |\ '-' || `-' | | | | |' '-' '\ `-' |\ --.| | +`--' `--`--'`--'`--' `--`--' `---' `--`--`--' `---' `---' `----'`--' diff --git "a/iailab-module-system/iailab-module-system-biz/db/\345\242\236\351\207\217SQL/202409.sql" "b/iailab-module-system/iailab-module-system-biz/db/\345\242\236\351\207\217SQL/202409.sql" new file mode 100644 index 0000000..334ffc0 --- /dev/null +++ "b/iailab-module-system/iailab-module-system-biz/db/\345\242\236\351\207\217SQL/202409.sql" @@ -0,0 +1,6 @@ +alter table system_menu add column `app_id` int DEFAULT NULL; +alter table system_menu add column `tenant_id` int DEFAULT NULL; + +alter table system_app add column `type` int DEFAULT NULL; +alter table system_app add column `tenant_id` int DEFAULT NULL; +alter table system_app add column `group_id` int DEFAULT NULL; \ No newline at end of file -- Gitblit v1.9.3