From f1162ee7b12a1e4fd45301f4d3fecb3bf155d006 Mon Sep 17 00:00:00 2001 From: 潘志宝 <979469083@qq.com> Date: 星期二, 10 九月 2024 16:10:42 +0800 Subject: [PATCH] 指标分类 --- iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/category/service/impl/IndItemCategoryServiceImpl.java | 84 +++++++++ iailab-module-data/iailab-module-data-biz/db/mysql/tenant.sql | 107 +++++++---- iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/category/entity/IndItemCategoryEntity.java | 67 +++++++ iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/package-info.java | 1 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/category/controller/package-info.java | 1 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/data/package-info.java | 1 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/category/vo/IndItemCategoryRespVO.java | 9 + iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/category/package-info.java | 1 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/item/package-info.java | 1 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/category/controller/admin/IndItemCategoryController.java | 79 ++++++++ iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/category/vo/IndItemCategoryReqVO.java | 18 ++ /dev/null | 21 -- iailab-module-data/iailab-module-data-biz/src/main/resources/application.yml | 3 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/category/vo/IndItemCategorySaveReqVO.java | 34 +++ iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/category/service/IndItemCategoryService.java | 26 ++ iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/category/dao/IndItemCategoryDao.java | 26 ++ iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/api/controller/DataController.java | 39 ---- 17 files changed, 421 insertions(+), 97 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 7cce151..c716368 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 @@ -238,43 +238,85 @@ PRIMARY KEY (`id`) USING BTREE ) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='接口Tag表'; -CREATE TABLE t_ind_item_atom( - `id` VARCHAR(36) NOT NULL COMMENT 'ID' , - `item_id` VARCHAR(36) COMMENT '指标ID' , - `data_source` VARCHAR(20) COMMENT '数据源', - `query_sql` VARCHAR(500) COMMENT '查询语句', - PRIMARY KEY (id) USING BTREE, - UNIQUE KEY `uk_point_id` (`item_id`) USING BTREE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT = '原子指标'; +-- 指标管理------------ +CREATE TABLE t_ind_data_set( + `id` VARCHAR(36) NOT NULL COMMENT 'ID' , + `name` VARCHAR(30) NOT NULL COMMENT '名称' , + `data_source` VARCHAR(64) NOT NULL COMMENT '数据源ID', + `query_sql` VARCHAR(200) NOT NULL COMMENT '查询语句', + `remark` VARCHAR(100) COMMENT '备注', + `sort` int COMMENT '排序', + `creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '创建者', + `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + `updater` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '更新者', + `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', + PRIMARY KEY (id) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT = '指标数据集'; + +CREATE TABLE t_ind_data_set_field( + `id` VARCHAR(36) NOT NULL COMMENT 'ID' , + `data_set_id` VARCHAR(36) NOT NULL COMMENT '数据集ID' , + `field_code` VARCHAR(30) COMMENT '英文名' , + `field_name` VARCHAR(30) COMMENT '中文名' , + `field_type` VARCHAR(30) COMMENT '数据类型' , + `sort` int COMMENT '排序', + PRIMARY KEY (id) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT = '指标数据集字段'; + +CREATE TABLE t_ind_item_category( + `id` VARCHAR(36) NOT NULL COMMENT 'ID' , + `label` VARCHAR(20) COMMENT '标签' , + `pid` VARCHAR(36) COMMENT '父ID', + `sort` int COMMENT '排序', + `creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '创建者', + `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + `updater` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '更新者', + `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', + PRIMARY KEY (id) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT = '指标分类'; CREATE TABLE t_ind_item( - `id` VARCHAR(36) NOT NULL COMMENT 'ID' , - `item_no` VARCHAR(36) COMMENT '指标编码' , - `item_name` VARCHAR(36) COMMENT '指标名称' , - `item_type` VARCHAR(10) COMMENT '指标类型' , - `coefficient` decimal(10, 4) COMMENT '系数', - `precision` int COMMENT '指标精度', - `business_type` VARCHAR(10) COMMENT '业务类型', - `time_range` VARCHAR(20) COMMENT '时间范围' , - `time_granularity` VARCHAR(10) COMMENT '时间粒度' , - `remark` VARCHAR(255) COMMENT '备注' , - `is_enable` tinyint(1) COMMENT '是否启用' , - `creator` VARCHAR(36) COMMENT '创建人' , - `create_time` DATETIME COMMENT '创建时间' , - `updater` VARCHAR(36) COMMENT '修改人' , - `update_time` DATETIME COMMENT '修改时间' , - PRIMARY KEY (id) USING BTREE, - UNIQUE KEY `uk_item_no` (`item_no`) USING BTREE + `id` VARCHAR(36) NOT NULL COMMENT 'ID' , + `item_no` VARCHAR(36) COMMENT '指标编码' , + `item_name` VARCHAR(36) COMMENT '指标名称' , + `item_type` VARCHAR(20) COMMENT '指标类型' , + `item_category` VARCHAR(20) COMMENT '指标分类' , + `coefficient` decimal(10, 4) COMMENT '系数', + `precision` int COMMENT '指标精度', + `time_granularity` VARCHAR(10) COMMENT '时间粒度' , + `remark` VARCHAR(255) COMMENT '备注' , + `status` tinyint NOT NULL DEFAULT 0 COMMENT '状态(0正常 1停用)', + `creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '创建者', + `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + `updater` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '更新者', + `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', + PRIMARY KEY (id) USING BTREE, + UNIQUE KEY `uk_item_no` (`item_no`) USING BTREE ) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT = '指标项表'; CREATE TABLE t_ind_item_atom( `id` VARCHAR(36) NOT NULL COMMENT 'ID' , `item_id` VARCHAR(36) COMMENT '指标ID' , - `data_source` VARCHAR(20) COMMENT '数据源', - `query_sql` VARCHAR(500) COMMENT '查询语句', + `data_source` VARCHAR(64) COMMENT '数据源', + `data_set` VARCHAR(64) COMMENT '数据集', + `using_field` VARCHAR(64) COMMENT '使用字段', + `stat_func` VARCHAR(64) COMMENT '统计方式', PRIMARY KEY (id) USING BTREE, - UNIQUE KEY `uk_point_id` (`item_id`) USING BTREE + UNIQUE KEY `uk_item_id` (`item_id`) USING BTREE ) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT = '原子指标'; + +CREATE TABLE t_ind_item_der( + `id` VARCHAR(36) NOT NULL COMMENT 'ID' , + `item_id` VARCHAR(36) COMMENT '指标ID' , + `atom_item_id` VARCHAR(36) COMMENT '原子指标ID' , + `time_label` VARCHAR(20) COMMENT '时间标识', + `time_limit` VARCHAR(20) COMMENT '时间限定', + `time_start` DATETIME COMMENT '开始时间', + `time_end` DATETIME COMMENT '结束时间', + `dimension` VARCHAR(200) COMMENT '分析维度', + PRIMARY KEY (id) USING BTREE, + UNIQUE KEY `uk_item_id` (`item_id`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT = '派生指标'; CREATE TABLE t_ind_item_cal( `id` VARCHAR(36) NOT NULL COMMENT 'ID' , @@ -283,15 +325,6 @@ PRIMARY KEY (id) USING BTREE, UNIQUE KEY `uk_item_id` (`item_id`) USING BTREE ) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT = '计算指标'; - -CREATE TABLE t_ind_item_derive( - `id` VARCHAR(36) NOT NULL COMMENT 'ID' , - `item_id` VARCHAR(36) COMMENT '指标ID' , - `limit_time` varchar(100) DEFAULT NULL COMMENT '时间限定', - `limit_business` varchar(100) DEFAULT NULL COMMENT '业务限定', - PRIMARY KEY (id) USING BTREE, - UNIQUE KEY `uk_item_id` (`item_id`) USING BTREE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT = '派生指标'; CREATE TABLE `t_ind_item_value` ( `id` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT 'id', diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/api/controller/DataController.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/api/controller/DataController.java index b2da9e3..bc0bdf7 100644 --- a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/api/controller/DataController.java +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/api/controller/DataController.java @@ -5,21 +5,16 @@ import com.iailab.module.data.api.dto.IndexQueryDTO; import com.iailab.module.data.api.dto.echarts.BarLineDTO; import com.iailab.module.data.api.dto.echarts.SeriesItem; -import com.iailab.module.data.channel.kio.entity.ChannelKioDeviceEntity; -import com.iailab.module.data.common.utils.Constant; -import com.iailab.module.data.common.utils.R; import com.iailab.module.data.api.dto.ApiPointValueQueryDTO; import com.iailab.module.data.point.collection.PointCollector; import com.iailab.module.data.point.common.PointDataTypeEnum; import com.iailab.module.data.point.dto.DaPointDTO; import com.iailab.module.data.point.service.DaPointService; import com.iailab.module.data.point.service.DaPointValueService; -import com.iailab.module.data.ind.collection.IndItemCollector; import com.iailab.module.data.influxdb.pojo.InfluxPointValuePOJO; import com.iailab.module.data.influxdb.service.InfluxDBService; import com.iailab.module.data.api.dto.DeviceValueDTO; import com.iailab.module.data.api.utils.ApiSecurityUtils; -import com.iailab.module.data.ind.dto.IndItemValueDTO; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; import lombok.extern.slf4j.Slf4j; @@ -34,7 +29,6 @@ import java.util.stream.Collectors; import static com.iailab.framework.common.pojo.CommonResult.success; -import static com.iailab.framework.common.pojo.CommonResult.error; /** * @author PanZhibao @@ -61,9 +55,6 @@ @Resource private PointCollector pointCollector; - - @Resource - private IndItemCollector indItemCollector; @PostMapping("/point/history") @Operation(summary = "point历史数据") @@ -211,35 +202,5 @@ }); } return CommonResult; - } - - @PostMapping("/ind-item/values") - @Operation(summary = "point当前实时数据") - public CommonResult<Map<String, List<IndItemValueDTO>>> indItemValues(HttpServletResponse response, HttpServletRequest - request, @RequestBody List<String> itemNos) { - try { - // apiSecurityUtils.validate(request); - Map<String, List<IndItemValueDTO>> data = indItemCollector.getValueList(itemNos); - return success(data); - } catch (Exception ex) { - return new CommonResult<Map<String, List<IndItemValueDTO>>>().setMsg(ex.getMessage()); - } - } - - @PostMapping("/ind-item/current-value") - @Operation(summary = "point当前实时数据") - public CommonResult<Map<String, BigDecimal>> indItemCurrentValue(HttpServletResponse response, HttpServletRequest - request, @RequestBody List<String> itemNos) { - try { - Map<String, BigDecimal> data = new HashMap<>(); - // apiSecurityUtils.validate(request); - Map<String, List<IndItemValueDTO>> dataList = indItemCollector.getValueList(itemNos); - dataList.forEach((k, v) -> { - data.put(k, CollectionUtils.isEmpty(v) ? null : v.get(0).getDataValue()); - }); - return success(data); - } catch (Exception ex) { - return new CommonResult<Map<String, BigDecimal>>().setMsg(ex.getMessage()); - } } } diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/category/controller/admin/IndItemCategoryController.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/category/controller/admin/IndItemCategoryController.java new file mode 100644 index 0000000..6db3666 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/category/controller/admin/IndItemCategoryController.java @@ -0,0 +1,79 @@ +package com.iailab.module.data.ind.category.controller.admin; + +import com.iailab.framework.common.pojo.CommonResult; +import com.iailab.framework.common.util.object.BeanUtils; +import com.iailab.module.data.ind.category.entity.IndItemCategoryEntity; +import com.iailab.module.data.ind.category.service.IndItemCategoryService; +import com.iailab.module.data.ind.category.vo.IndItemCategoryReqVO; +import com.iailab.module.data.ind.category.vo.IndItemCategoryRespVO; +import com.iailab.module.data.ind.category.vo.IndItemCategorySaveReqVO; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.tags.Tag; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +import javax.validation.Valid; +import java.util.Comparator; +import java.util.List; + +import static com.iailab.framework.common.pojo.CommonResult.success; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年09月10日 + */ +@Tag(name = "数据平台 - 指标分类") +@RestController +@RequestMapping("/data/ind-item-category") +@Validated +public class IndItemCategoryController { + + @Autowired + private IndItemCategoryService indItemCategoryService; + + @GetMapping("/list") + @Operation(summary = "获取指标分类列表", description = "用于【指标分类】界面") + @PreAuthorize("@ss.hasPermission('data:ind-item-category:query')") + public CommonResult<List<IndItemCategoryRespVO>> getList(IndItemCategoryReqVO reqVO) { + List<IndItemCategoryEntity> list = indItemCategoryService.getList(reqVO); + list.sort(Comparator.comparing(IndItemCategoryEntity::getSort)); + return success(BeanUtils.toBean(list, IndItemCategoryRespVO.class)); + } + + @PostMapping("/create") + @Operation(summary = "创建指标分类") + @PreAuthorize("@ss.hasPermission('data:ind-item-category:create')") + public CommonResult<Boolean> createMenu(@Valid @RequestBody IndItemCategorySaveReqVO createReqVO) { + indItemCategoryService.create(createReqVO); + return success(true); + } + + @PutMapping("/update") + @Operation(summary = "修改指标分类") + @PreAuthorize("@ss.hasPermission('data:ind-item-category:update')") + public CommonResult<Boolean> updateMenu(@Valid @RequestBody IndItemCategorySaveReqVO updateReqVO) { + indItemCategoryService.update(updateReqVO); + return success(true); + } + + @DeleteMapping("/delete") + @Operation(summary = "删除指标分类") + @Parameter(name = "id", description = "指标分类编号", required= true, example = "1024") + @PreAuthorize("@ss.hasPermission('data:ind-item-category:delete')") + public CommonResult<Boolean> deleteMenu(@RequestParam("id") String id) { + indItemCategoryService.delete(id); + return success(true); + } + + @GetMapping("/get") + @Operation(summary = "获取指标分类信息") + @PreAuthorize("@ss.hasPermission('system:ind-item-category:query')") + public CommonResult<IndItemCategoryRespVO> getMenu(String id) { + IndItemCategoryEntity entity = indItemCategoryService.get(id); + return success(BeanUtils.toBean(entity, IndItemCategoryRespVO.class)); + } +} \ No newline at end of file diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/category/controller/package-info.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/category/controller/package-info.java new file mode 100644 index 0000000..f66e64a --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/category/controller/package-info.java @@ -0,0 +1 @@ +package com.iailab.module.data.ind.category.controller; \ No newline at end of file diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/category/dao/IndItemCategoryDao.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/category/dao/IndItemCategoryDao.java new file mode 100644 index 0000000..d868e6f --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/category/dao/IndItemCategoryDao.java @@ -0,0 +1,26 @@ +package com.iailab.module.data.ind.category.dao; + +import com.iailab.framework.mybatis.core.mapper.BaseMapperX; +import com.iailab.framework.mybatis.core.query.LambdaQueryWrapperX; +import com.iailab.framework.tenant.core.db.dynamic.TenantDS; +import com.iailab.module.data.ind.category.entity.IndItemCategoryEntity; +import com.iailab.module.data.ind.category.vo.IndItemCategoryReqVO; +import org.apache.ibatis.annotations.Mapper; + +import java.util.List; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年09月10日 + */ +@TenantDS +@Mapper +public interface IndItemCategoryDao extends BaseMapperX<IndItemCategoryEntity> { + + default List<IndItemCategoryEntity> selectList(IndItemCategoryReqVO reqVO) { + return selectList(new LambdaQueryWrapperX<IndItemCategoryEntity>() + .likeIfPresent(IndItemCategoryEntity::getLabel, reqVO.getLabel())); + } + +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/category/entity/IndItemCategoryEntity.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/category/entity/IndItemCategoryEntity.java new file mode 100644 index 0000000..16505c3 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/category/entity/IndItemCategoryEntity.java @@ -0,0 +1,67 @@ +package com.iailab.module.data.ind.category.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; + +/** + * 指标分类 + * + * @author PanZhibao + * @Description + * @createTime 2024年09月10日 + */ +@Data +@TableName("t_ind_item_category") +public class IndItemCategoryEntity implements Serializable { + private static final long serialVersionUID = 1L; + + public static final String ID_ROOT = "0"; + + /** + * 主键 + */ + @Schema(description = "主键") + @TableId(value = "id",type = IdType.INPUT) + private String id; + + /** + * 标签 + */ + private String label; + + /** + * 父ID + */ + private String pid; + + /** + * 排序 + */ + private Integer sort; + + /** + * 创建者 + */ + private String creator; + + /** + * 创建时间 + */ + private Date createTime; + + /** + * 更新者 + */ + private String updater; + + /** + * 更新时间 + */ + private Date updateTime; +} \ No newline at end of file diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/category/package-info.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/category/package-info.java new file mode 100644 index 0000000..5eebf1c --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/category/package-info.java @@ -0,0 +1 @@ +package com.iailab.module.data.ind.category; \ No newline at end of file diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/category/service/IndItemCategoryService.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/category/service/IndItemCategoryService.java new file mode 100644 index 0000000..3681c93 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/category/service/IndItemCategoryService.java @@ -0,0 +1,26 @@ +package com.iailab.module.data.ind.category.service; + + +import com.iailab.module.data.ind.category.entity.IndItemCategoryEntity; +import com.iailab.module.data.ind.category.vo.IndItemCategoryReqVO; +import com.iailab.module.data.ind.category.vo.IndItemCategorySaveReqVO; + +import java.util.List; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年09月10日 + */ +public interface IndItemCategoryService { + + List<IndItemCategoryEntity> getList(IndItemCategoryReqVO reqVO); + + void create(IndItemCategorySaveReqVO createReqVO); + + void update(IndItemCategorySaveReqVO updateReqVO); + + IndItemCategoryEntity get(String id); + + void delete(String id); +} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/category/service/impl/IndItemCategoryServiceImpl.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/category/service/impl/IndItemCategoryServiceImpl.java new file mode 100644 index 0000000..5fd1947 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/category/service/impl/IndItemCategoryServiceImpl.java @@ -0,0 +1,84 @@ +package com.iailab.module.data.ind.category.service.impl; + +import com.iailab.framework.common.util.object.BeanUtils; +import com.iailab.module.data.ind.category.entity.IndItemCategoryEntity; +import com.iailab.module.data.ind.category.service.IndItemCategoryService; +import com.iailab.module.data.ind.category.vo.IndItemCategoryReqVO; +import com.iailab.module.data.ind.category.dao.IndItemCategoryDao; +import com.iailab.module.data.ind.category.vo.IndItemCategorySaveReqVO; +import com.iailab.module.system.enums.permission.MenuTypeEnum; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.util.Date; +import java.util.List; +import java.util.UUID; + +import static com.iailab.framework.common.exception.util.ServiceExceptionUtil.exception; +import static com.iailab.module.system.enums.ErrorCodeConstants.*; +import static com.iailab.module.data.ind.category.entity.IndItemCategoryEntity.ID_ROOT; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年09月10日 + */ +@Service +@Slf4j +public class IndItemCategoryServiceImpl implements IndItemCategoryService { + + @Resource + private IndItemCategoryDao indItemCategoryDao; + + @Override + public List<IndItemCategoryEntity> getList(IndItemCategoryReqVO reqVO) { + return indItemCategoryDao.selectList(reqVO); + } + + @Override + public void create(IndItemCategorySaveReqVO createReqVO) { + // 校验父菜单存在 + validateParentMenu(createReqVO.getPid(), null); + + // 插入数据库 + IndItemCategoryEntity entity = BeanUtils.toBean(createReqVO, IndItemCategoryEntity.class); + entity.setId(UUID.randomUUID().toString()); + entity.setCreateTime(new Date()); + indItemCategoryDao.insert(entity); + } + + @Override + public void update(IndItemCategorySaveReqVO updateReqVO) { + // 校验父菜单存在 + validateParentMenu(updateReqVO.getPid(), null); + IndItemCategoryEntity entity = BeanUtils.toBean(updateReqVO, IndItemCategoryEntity.class); + entity.setUpdateTime(new Date()); + indItemCategoryDao.updateById(entity); + } + + @Override + public IndItemCategoryEntity get(String id) { + return indItemCategoryDao.selectById(id); + } + + @Override + public void delete(String id) { + indItemCategoryDao.deleteById(id); + } + + private void validateParentMenu(String parentId, String childId) { + if (parentId == null || ID_ROOT.equals(parentId)) { + return; + } + // 不能设置自己为父菜单 + if (parentId.equals(childId)) { + throw exception(MENU_PARENT_ERROR); + } + IndItemCategoryEntity category = indItemCategoryDao.selectById(parentId); + // 父菜单不存在 + if (category == null) { + throw exception(MENU_PARENT_NOT_EXISTS); + } + } +} \ No newline at end of file diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/category/vo/IndItemCategoryReqVO.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/category/vo/IndItemCategoryReqVO.java new file mode 100644 index 0000000..00aadd3 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/category/vo/IndItemCategoryReqVO.java @@ -0,0 +1,18 @@ +package com.iailab.module.data.ind.category.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import lombok.ToString; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年09月10日 + */ +@Schema(description = "数据服务 - 指标分类分页 Request VO") +@Data +@ToString(callSuper = true) +public class IndItemCategoryReqVO { + + private String label; +} \ No newline at end of file diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/category/vo/IndItemCategoryRespVO.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/category/vo/IndItemCategoryRespVO.java new file mode 100644 index 0000000..efc8bb9 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/category/vo/IndItemCategoryRespVO.java @@ -0,0 +1,9 @@ +package com.iailab.module.data.ind.category.vo; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年09月10日 + */ +public class IndItemCategoryRespVO { +} \ No newline at end of file diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/category/vo/IndItemCategorySaveReqVO.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/category/vo/IndItemCategorySaveReqVO.java new file mode 100644 index 0000000..35c824b --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/category/vo/IndItemCategorySaveReqVO.java @@ -0,0 +1,34 @@ +package com.iailab.module.data.ind.category.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Size; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年09月10日 + */ +@Schema(description = "数据平台 - 指标分类创建/修改 Request VO") +@Data +public class IndItemCategorySaveReqVO { + + @Schema(description = "ID", example = "1024") + private String id; + + @Schema(description = "标签", requiredMode = Schema.RequiredMode.REQUIRED, example = "平台") + @NotBlank(message = "标签") + @Size(max = 50, message = "标签长度不能超过20个字符") + private String label; + + @Schema(description = "父菜单 ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") + @NotNull(message = "父菜单 ID 不能为空") + private String pid; + + @Schema(description = "显示顺序", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") + @NotNull(message = "显示顺序不能为空") + private Integer sort; +} \ No newline at end of file diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/collection/IndItemCollector.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/collection/IndItemCollector.java deleted file mode 100644 index de80b07..0000000 --- a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/collection/IndItemCollector.java +++ /dev/null @@ -1,85 +0,0 @@ -package com.iailab.module.data.ind.collection; - -import com.iailab.module.data.ind.collection.handler.AtomItemHandle; -import com.iailab.module.data.ind.service.IndItemService; -import com.iailab.module.data.ind.collection.handler.AtomItemHandle; -import com.iailab.module.data.ind.service.IndItemService; -import com.iailab.module.data.ind.collection.handler.AtomItemHandle; -import com.iailab.module.data.ind.collection.handler.CalItemHandle; -import com.iailab.module.data.ind.dto.IndItemDTO; -import com.iailab.module.data.ind.dto.IndItemValueDTO; -import com.iailab.module.data.ind.service.IndItemService; -import com.iailab.module.data.ind.collection.handler.AtomItemHandle; -import com.iailab.module.data.ind.service.IndItemService; -import lombok.extern.slf4j.Slf4j; -import javax.annotation.Resource; -import org.springframework.stereotype.Component; -import org.springframework.util.CollectionUtils; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -/** - * @author PanZhibao - * @Description - * @createTime 2024年05月25日 - */ -@Slf4j -@Component -public class IndItemCollector { - - @Resource - private IndItemService indItemService; - - @Resource - private AtomItemHandle atomItemHandle; - - @Resource - private CalItemHandle calItemHandle; - - - public Map<String, List<IndItemValueDTO>> getValueList(List<String> itemNos) { - Map<String, List<IndItemValueDTO>> result = new HashMap<>(); - if (CollectionUtils.isEmpty(itemNos)) { - return result; - } - try { - List<IndItemDTO> atomList = indItemService.getItemAtom(itemNos); - atomList.forEach(item -> { - result.put(item.getItemNo(), atomItemHandle.getItemSourceValue(item.getItemNo())); - }); - - List<IndItemDTO> calList = indItemService.getItemCal(itemNos); - calList.forEach(item -> { - result.put(item.getItemNo(), calItemHandle.getItemCalValue(item.getItemNo())); - }); - - } catch (Exception ex) { - ex.printStackTrace(); - } - return result; - } - - public Map<String, List<IndItemValueDTO>> getValueListRange(List<String> itemNos, String start, String end) { - Map<String, List<IndItemValueDTO>> result = new HashMap<>(); - if (CollectionUtils.isEmpty(itemNos)) { - return result; - } - try { - List<IndItemDTO> atomList = indItemService.getItemAtom(itemNos); - atomList.forEach(item -> { - result.put(item.getItemNo(), atomItemHandle.getItemSourceValue(item.getItemNo(), start, end)); - }); - - List<IndItemDTO> calList = indItemService.getItemCal(itemNos); - calList.forEach(item -> { - result.put(item.getItemNo(), calItemHandle.getItemCalValue(item.getItemNo(), start, end)); - }); - - } catch (Exception ex) { - ex.printStackTrace(); - } - return result; - } -} \ No newline at end of file diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/collection/handler/AtomItemHandle.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/collection/handler/AtomItemHandle.java deleted file mode 100644 index c875abd..0000000 --- a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/collection/handler/AtomItemHandle.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.iailab.module.data.ind.collection.handler; - -import com.iailab.module.data.ind.service.IndItemService; -import com.iailab.module.data.ind.service.IndItemService; -import com.iailab.module.data.ind.collection.utils.IndSqlUtils; -import com.iailab.module.data.ind.dao.IndItemValueDao; -import com.iailab.module.data.ind.dto.IndItemDTO; -import com.iailab.module.data.ind.dto.IndItemValueDTO; -import com.iailab.module.data.ind.service.IndItemService; -import com.iailab.module.data.ind.service.IndItemService; -import lombok.extern.slf4j.Slf4j; -import javax.annotation.Resource; -import org.springframework.stereotype.Component; - -import javax.annotation.Resource; -import java.math.BigDecimal; -import java.util.ArrayList; -import java.util.List; - -/** - * @author PanZhibao - * @Description - * @createTime 2024年05月25日 - */ -@Slf4j -@Component -public class AtomItemHandle { - - @Resource - private IndItemService indItemService; - - @Resource - private IndItemValueDao indItemValueDao; - - - public List<IndItemValueDTO> getItemSourceValue(String itemNo) { - List<IndItemValueDTO> result = new ArrayList<>(); - IndItemDTO indItemDTO = indItemService.getItemAtom(itemNo); - if (indItemDTO == null) { - return result; - } - try { - StringBuilder sqlSelect = new StringBuilder(); - sqlSelect.append(" data_value, data_time "); - indItemDTO.setSqlSelect(sqlSelect.toString()); - indItemDTO.setSqlWhere(IndSqlUtils.getSqlWhere(indItemDTO.getTimeRange(), indItemDTO.getTimeGranularity())); - result = indItemValueDao.getSourceValue(indItemDTO); - } catch (Exception ex) { - ex.printStackTrace(); - } - - result.forEach(item -> { - if (indItemDTO.getCoefficient() != null) { - item.setDataValue(item.getDataValue().multiply(indItemDTO.getCoefficient())); - } - if (indItemDTO.getPrecision() != null) { - item.setDataValue(item.getDataValue().setScale(indItemDTO.getPrecision(), BigDecimal.ROUND_HALF_UP)); - } - item.setItemNo(itemNo); - }); - return result; - } - - public List<IndItemValueDTO> getItemSourceValue(String itemNo, String start, String end) { - List<IndItemValueDTO> result = new ArrayList<>(); - IndItemDTO indItemDTO = indItemService.getItemAtom(itemNo); - if (indItemDTO == null) { - return result; - } - try { - StringBuilder sqlSelect = new StringBuilder(); - sqlSelect.append(" data_value, data_time "); - indItemDTO.setSqlSelect(sqlSelect.toString()); - indItemDTO.setSqlWhere(IndSqlUtils.getSqlWhereByRange(start, end)); - result = indItemValueDao.getSourceValue(indItemDTO); - } catch (Exception ex) { - ex.printStackTrace(); - } - - result.forEach(item -> { - if (indItemDTO.getCoefficient() != null) { - item.setDataValue(item.getDataValue().multiply(indItemDTO.getCoefficient())); - } - if (indItemDTO.getPrecision() != null) { - item.setDataValue(item.getDataValue().setScale(indItemDTO.getPrecision(), BigDecimal.ROUND_HALF_UP)); - } - item.setItemNo(itemNo); - }); - return result; - } -} \ No newline at end of file diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/collection/handler/CalItemHandle.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/collection/handler/CalItemHandle.java deleted file mode 100644 index d23ff0c..0000000 --- a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/collection/handler/CalItemHandle.java +++ /dev/null @@ -1,156 +0,0 @@ -package com.iailab.module.data.ind.collection.handler; - -import com.iailab.module.data.common.enums.CommonConstant; -import com.iailab.module.data.common.enums.JsErrorCode; -import com.iailab.module.data.common.utils.JavaScriptHandler; -import com.iailab.module.data.ind.service.IndItemService; -import com.iailab.module.data.ind.dto.IndItemDTO; -import com.iailab.module.data.ind.dto.IndItemValueDTO; -import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang3.StringUtils; -import javax.annotation.Resource; -import org.springframework.stereotype.Component; - -import java.math.BigDecimal; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -/** - * @author PanZhibao - * @Description - * @createTime 2024年05月25日 - */ -@Slf4j -@Component -public class CalItemHandle { - - @Resource - private JavaScriptHandler javaScriptHandler; - - public static final String regex = "[+\\-\\*\\/\\(\\)\\&\\|\\>\\<]"; - - @Resource - private IndItemService indItemService; - - @Resource - private AtomItemHandle atomItemHandle; - - - public List<IndItemValueDTO> getItemCalValue(String itemNo) { - List<IndItemValueDTO> result = new ArrayList<>(); - IndItemDTO indItemDTO = indItemService.getItemCal(itemNo); - if (indItemDTO == null) { - return result; - } - String expression = indItemDTO.getExpression(); - if (StringUtils.isBlank(expression)) { - return result; - } - String[] arr = expression.split(regex); - int dataLength = 0; - List<List<IndItemValueDTO>> valueMix = new ArrayList<>(); - - for (int i = 0; i < arr.length; i++) { - String s = arr[i]; - if (StringUtils.isBlank(s)) { - continue; - } - valueMix.add(atomItemHandle.getItemSourceValue(s)); - } - dataLength = valueMix.get(0).size(); - - for (int i = 0; i < dataLength; i++) { - Map<String, IndItemValueDTO> dataMap = new HashMap<>(); - for (int j = 0; j < valueMix.size(); j++) { - IndItemValueDTO valueDTO = valueMix.get(j).get(i); - dataMap.put(valueDTO.getItemNo(), valueDTO); - } - IndItemValueDTO itemValue = this.singleCompute(indItemDTO, dataMap); - result.add(itemValue); - } - return result; - } - - public List<IndItemValueDTO> getItemCalValue(String itemNo, String start, String end) { - List<IndItemValueDTO> result = new ArrayList<>(); - IndItemDTO indItemDTO = indItemService.getItemCal(itemNo); - if (indItemDTO == null) { - return result; - } - String expression = indItemDTO.getExpression(); - if (StringUtils.isBlank(expression)) { - return result; - } - String[] arr = expression.split(regex); - int dataLength = 0; - List<List<IndItemValueDTO>> valueMix = new ArrayList<>(); - - for (int i = 0; i < arr.length; i++) { - String s = arr[i]; - if (StringUtils.isBlank(s)) { - continue; - } - valueMix.add(atomItemHandle.getItemSourceValue(s, start, end)); - } - dataLength = valueMix.get(0).size(); - - for (int i = 0; i < dataLength; i++) { - Map<String, IndItemValueDTO> dataMap = new HashMap<>(); - for (int j = 0; j < valueMix.size(); j++) { - IndItemValueDTO valueDTO = valueMix.get(j).get(i); - dataMap.put(valueDTO.getItemNo(), valueDTO); - } - IndItemValueDTO itemValue = this.singleCompute(indItemDTO, dataMap); - result.add(itemValue); - } - return result; - } - - private IndItemValueDTO singleCompute(IndItemDTO dto, Map<String, IndItemValueDTO> dataMap) { - IndItemValueDTO resultDto = new IndItemValueDTO(); - String dataTime = ""; - BigDecimal dataValue = CommonConstant.ZERO_VALUE; - String expression = dto.getExpression(); - String[] arr = expression.split(regex); - - for (int i = 0; i < arr.length; i++) { - String s = arr[i]; - if (StringUtils.isNotBlank(s) && dataMap.containsKey(s)) { - dataTime = dataMap.get(s).getDataTime(); - if (dataMap.get(s) == null || dataMap.get(s).getDataValue() == null) { - resultDto.setDataTime(dataTime); - return resultDto; - } - expression = expression.replace(s, dataMap.get(s).getDataValue().toString()); - } - } - expression = expression.replace("&", "&&"); - expression = expression.replace("|", "||"); - expression = expression.replace("False", "false"); - expression = expression.replace("True", "true"); - log.info("ItemNo=" + dto.getItemNo() + ";expression=" + expression); - String result = javaScriptHandler.eval(expression); - log.info("result=" + result); - if (result == null) { - return null; - } else if (result.contains(JsErrorCode.Infinity.name()) || - result.contains(JsErrorCode.NaN.name())) { - log.info("计算异常,使用默认值"); - } else { - dataValue = new BigDecimal(result); - } - resultDto.setDataTime(dataTime); - - if (dto.getCoefficient() != null) { - dataValue = dataValue.multiply(dto.getCoefficient()); - } - if (dto.getPrecision() != null) { - dataValue = dataValue.setScale(dto.getPrecision(), BigDecimal.ROUND_HALF_UP); - } - resultDto.setDataValue(dataValue); - return resultDto; - } - -} \ No newline at end of file diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/collection/utils/IndSqlUtils.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/collection/utils/IndSqlUtils.java deleted file mode 100644 index 16e866e..0000000 --- a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/collection/utils/IndSqlUtils.java +++ /dev/null @@ -1,89 +0,0 @@ -package com.iailab.module.data.ind.collection.utils; - -import com.iailab.framework.common.util.date.DateUtils; -import com.iailab.module.data.ind.common.IndTimeRangeConst; - -import java.util.Calendar; - -/** - * @author PanZhibao - * @Description - * @createTime 2024年05月25日 - */ -public class IndSqlUtils { - - public final static String PATTERN_YEAR = "yyyy"; - - public final static String PATTERN_MON = "yyyy-MM"; - - public final static String PATTERN_DATE = "yyyy-MM-dd"; - - - public static String getSqlWhere(String timeRange, String timeGranularity) { - StringBuilder sqlWhere = new StringBuilder(); - Calendar calendar = Calendar.getInstance(); - calendar.set(Calendar.MILLISECOND, 0); - switch (timeRange) { - case IndTimeRangeConst.LAST_YEAR: - calendar.add(Calendar.YEAR, -1); - sqlWhere.append("ind_t.data_time = '"); - sqlWhere.append(DateUtils.format(calendar.getTime(), PATTERN_YEAR)); - sqlWhere.append("'"); - break; - case IndTimeRangeConst.THIS_YEAR: - sqlWhere.append("ind_t.data_time = '"); - sqlWhere.append(DateUtils.format(calendar.getTime(), PATTERN_YEAR)); - sqlWhere.append("'"); - break; - case IndTimeRangeConst.THIS_YEAR_MONTH: - sqlWhere.append("ind_t.data_time >= '"); - sqlWhere.append(DateUtils.format(calendar.getTime(), PATTERN_YEAR) + "-01' "); - sqlWhere.append("and ind_t.data_time <= '"); - sqlWhere.append(DateUtils.format(calendar.getTime(), PATTERN_YEAR) + "-12' "); - break; - case IndTimeRangeConst.THIS_MONTH: - sqlWhere.append("ind_t.data_time = '"); - sqlWhere.append(DateUtils.format(calendar.getTime(), PATTERN_MON)); - sqlWhere.append("'"); - break; - case IndTimeRangeConst.YESTERDAY: - calendar.add(Calendar.DAY_OF_YEAR, -1); - sqlWhere.append("ind_t.data_time = '"); - sqlWhere.append(DateUtils.format(calendar.getTime(), PATTERN_DATE)); - sqlWhere.append("'"); - break; - case IndTimeRangeConst.TODAY: - sqlWhere.append("ind_t.data_time = '"); - sqlWhere.append(DateUtils.format(calendar.getTime(), PATTERN_DATE)); - sqlWhere.append("'"); - break; - case IndTimeRangeConst.LAST_DAY_7: - calendar.add(Calendar.DAY_OF_YEAR, -7); - sqlWhere.append("ind_t.data_time >= '"); - sqlWhere.append(DateUtils.format(calendar.getTime(), PATTERN_DATE)); - sqlWhere.append("'"); - break; - case IndTimeRangeConst.LAST_DAY_30: - calendar.add(Calendar.DAY_OF_YEAR, -30); - sqlWhere.append("ind_t.data_time >= '"); - sqlWhere.append(DateUtils.format(calendar.getTime(), PATTERN_DATE)); - sqlWhere.append("'"); - break; - default: - break; - - } - return sqlWhere.toString(); - } - - public static String getSqlWhereByRange(String start, String end) { - StringBuilder sqlWhere = new StringBuilder(); - sqlWhere.append("ind_t.data_time >= '"); - sqlWhere.append(start); - sqlWhere.append("' "); - sqlWhere.append("and ind_t.data_time <= '"); - sqlWhere.append(end); - sqlWhere.append("' "); - return sqlWhere.toString(); - } -} \ No newline at end of file diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/common/IndItemTypeEnum.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/common/IndItemTypeEnum.java deleted file mode 100644 index b85c6bb..0000000 --- a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/common/IndItemTypeEnum.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.iailab.module.data.ind.common; - -/** - * @author PanZhibao - * @Description - * @createTime 2024年05月25日 - */ -public enum IndItemTypeEnum { - - ATOM_ITEM("ATOM", "ATOM"), - CAL_ITEM("CAL", "CAL"); - - private String code; - - private String name; - - IndItemTypeEnum(String code, String name){ - this.code = code; - this.name = name; - } - - public String getCode() { - return code; - } - - public void setCode(String code) { - this.code = code; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } -} \ No newline at end of file diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/common/IndTimeRangeConst.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/common/IndTimeRangeConst.java deleted file mode 100644 index 913050b..0000000 --- a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/common/IndTimeRangeConst.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.iailab.module.data.ind.common; - -/** - * @author PanZhibao - * @Description - * @createTime 2024年05月27日 - */ -public interface IndTimeRangeConst { - - String LAST_YEAR = "LAST_YEAR"; - - String THIS_YEAR = "THIS_YEAR"; - - String THIS_YEAR_MONTH = "THIS_YEAR_MONTH"; - - String LAST_MONTH_12 = "LAST_MONTH_12"; - - String THIS_MONTH = "THIS_MONTH"; - - String YESTERDAY = "YESTERDAY"; - - String TODAY = "TODAY"; - - String LAST_DAY_7 = "LAST_DAY_7"; - - String LAST_DAY_30 = "LAST_DAY_30"; - -} \ No newline at end of file diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/common/IndTimeRangeEnum.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/common/IndTimeRangeEnum.java deleted file mode 100644 index f7ae67f..0000000 --- a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/common/IndTimeRangeEnum.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.iailab.module.data.ind.common; - -/** - * @author PanZhibao - * @Description - * @createTime 2024年05月25日 - */ -public enum IndTimeRangeEnum { - - LAST_YEAR("LAST_YEAR", "LAST_YEAR"), - THIS_YEAR("THIS_YEAR", "THIS_YEAR"), - LAST_MONTH_12("LAST_MONTH_12", "LAST_MONTH_12"), - YESTERDAY("YESTERDAY", "YESTERDAY"), - TODAY("TODAY", "TODAY"), - LAST_DAY_7("LAST_DAY_7", "LAST_DAY_7"), - LAST_DAY_30("LAST_DAY_30", "LAST_DAY_30"); - - private String code; - - private String name; - - IndTimeRangeEnum(String code, String name){ - this.code = code; - this.name = name; - } - - public String getCode() { - return code; - } - - public void setCode(String code) { - this.code = code; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } -} \ No newline at end of file diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/common/IndtimeGranularityEnum.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/common/IndtimeGranularityEnum.java deleted file mode 100644 index f8158b1..0000000 --- a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/common/IndtimeGranularityEnum.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.iailab.module.data.ind.common; - -/** - * @author PanZhibao - * @Description - * @createTime 2024年05月25日 - */ -public enum IndtimeGranularityEnum { - - DAY("DAY", "DAY"), - MONTH("MONTH", "MONTH"); - - private String code; - - private String name; - - IndtimeGranularityEnum(String code, String name){ - this.code = code; - this.name = name; - } - - public String getCode() { - return code; - } - - public void setCode(String code) { - this.code = code; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } -} \ No newline at end of file diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/controller/admin/IndItemAtomController.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/controller/admin/IndItemAtomController.java deleted file mode 100644 index 77b68b8..0000000 --- a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/controller/admin/IndItemAtomController.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.iailab.module.data.ind.controller.admin; - -/** - * @author PanZhibao - * @Description - * @createTime 2024年05月25日 - */ -public class IndItemAtomController { -} \ No newline at end of file diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/controller/admin/IndItemCalController.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/controller/admin/IndItemCalController.java deleted file mode 100644 index 2f7bee6..0000000 --- a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/controller/admin/IndItemCalController.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.iailab.module.data.ind.controller.admin; - -/** - * @author PanZhibao - * @Description - * @createTime 2024年05月25日 - */ -public class IndItemCalController { -} \ No newline at end of file diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/controller/admin/IndItemController.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/controller/admin/IndItemController.java deleted file mode 100644 index 5cd8f64..0000000 --- a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/controller/admin/IndItemController.java +++ /dev/null @@ -1,112 +0,0 @@ -package com.iailab.module.data.ind.controller.admin; - -import com.iailab.framework.common.annotation.AutoDict; -import com.iailab.framework.common.constant.Constant; -import com.iailab.framework.common.page.PageData; -import com.iailab.framework.common.pojo.CommonResult; -import com.iailab.framework.common.util.validation.ValidationUtils; -import com.iailab.framework.common.validation.group.AddGroup; -import com.iailab.framework.common.validation.group.DefaultGroup; -import com.iailab.module.data.ind.service.IndItemService; -import com.iailab.module.data.ind.dto.IndItemDTO; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.Parameters; -import javax.annotation.Resource; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.web.bind.annotation.*; - -import java.util.List; -import java.util.Map; - -/** - * @author PanZhibao - * @Description - * @createTime 2024年05月25日 - */ -@RestController -@RequestMapping("/ind/item") -public class IndItemController { - - @Resource - private IndItemService indItemService; - - @GetMapping("page") - @Operation(summary = "分页") - @Parameters({ - @Parameter(name = Constant.PAGE, description = "当前页码,从1开始", required = true), - @Parameter(name = Constant.LIMIT, description = "每页显示记录数", required = true), - @Parameter(name = Constant.ORDER_FIELD, description = "排序字段"), - @Parameter(name = Constant.ORDER, description = "排序方式,可选值(asc、desc)") - }) - @AutoDict - public CommonResult<PageData<IndItemDTO>> page(@RequestParam Map<String, Object> params) { - PageData<IndItemDTO> page = indItemService.page(params); - - return new CommonResult<PageData<IndItemDTO>>().setData(page); - } - - @GetMapping("list") - @AutoDict - public CommonResult<List<IndItemDTO>> list(@RequestParam Map<String, Object> params) { - List<IndItemDTO> list = indItemService.getList(params); - return new CommonResult<List<IndItemDTO>>().setData(list); - } - - @GetMapping("{id}") - @Operation(summary = "信息") - public CommonResult<IndItemDTO> get(@PathVariable("id") String id) { - IndItemDTO data = indItemService.get(id); - - return new CommonResult<IndItemDTO>().setData(data); - } - - @PostMapping - @Operation(summary = "保存") - @PreAuthorize("@ss.hasPermission('ind:item:save')") - public CommonResult save(@RequestBody IndItemDTO dto){ - //效验数据 - ValidationUtils.validate(dto, AddGroup.class, DefaultGroup.class); - IndItemDTO data = indItemService.getItemByItemNo(dto.getItemNo()); - if(data != null){ - return new CommonResult().setMsg("指标编码已经存在,请重新定义指标编码!"); - } - indItemService.save(dto); - return new CommonResult(); - } - - @PutMapping - @Operation(summary = "修改") - @PreAuthorize("@ss.hasPermission('ind:item:update')") - public CommonResult update(@RequestBody IndItemDTO dto){ - //效验数据 - ValidationUtils.validate(dto, AddGroup.class, DefaultGroup.class); - indItemService.update(dto); - return new CommonResult(); - } - - @DeleteMapping - @Operation(summary = "删除") - @PreAuthorize("@ss.hasPermission('ind:item:delete')") - public CommonResult delete(@RequestBody String[] ids){ - indItemService.delete(ids); - return new CommonResult(); - } - - @PutMapping("/enable") - @Operation(summary = "启用") - @Transactional - public CommonResult enable(@RequestBody String[] ids) { - indItemService.enableByIds(ids); - return new CommonResult(); - } - - @PutMapping("/disable") - @Operation(summary = "禁用") - @Transactional - public CommonResult disable(@RequestBody String[] ids) { - indItemService.disableByIds(ids); - return new CommonResult(); - } -} \ No newline at end of file diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/controller/package-info.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/controller/package-info.java deleted file mode 100644 index 248a217..0000000 --- a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/controller/package-info.java +++ /dev/null @@ -1 +0,0 @@ -package com.iailab.module.data.ind.controller; \ No newline at end of file diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/dao/IndItemAtomDao.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/dao/IndItemAtomDao.java deleted file mode 100644 index 3661577..0000000 --- a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/dao/IndItemAtomDao.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.iailab.module.data.ind.dao; - -import com.iailab.framework.common.dao.BaseDao; -import com.iailab.framework.tenant.core.db.dynamic.TenantDS; -import com.iailab.module.data.ind.entity.IndItemAtomEntity; -import org.apache.ibatis.annotations.Mapper; - -/** - * @author PanZhibao - * @Description - * @createTime 2024年05月25日 - */ -@TenantDS -@Mapper -public interface IndItemAtomDao extends BaseDao<IndItemAtomEntity> { -} \ No newline at end of file diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/dao/IndItemCalDao.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/dao/IndItemCalDao.java deleted file mode 100644 index 962b37d..0000000 --- a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/dao/IndItemCalDao.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.iailab.module.data.ind.dao; - -import com.iailab.framework.common.dao.BaseDao; -import com.iailab.framework.tenant.core.db.dynamic.TenantDS; -import com.iailab.module.data.ind.entity.IndItemCalEntity; -import org.apache.ibatis.annotations.Mapper; - -/** - * @author PanZhibao - * @Description - * @createTime 2024年05月25日 - */ -@TenantDS -@Mapper -public interface IndItemCalDao extends BaseDao<IndItemCalEntity> { -} \ No newline at end of file diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/dao/IndItemDao.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/dao/IndItemDao.java deleted file mode 100644 index 7476a5b..0000000 --- a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/dao/IndItemDao.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.iailab.module.data.ind.dao; - -import com.iailab.framework.common.dao.BaseDao; -import com.iailab.framework.tenant.core.db.dynamic.TenantDS; -import com.iailab.module.data.ind.entity.IndItemEntity; -import com.iailab.module.data.ind.entity.IndItemEntity; -import com.iailab.module.data.ind.dto.IndItemDTO; -import com.iailab.module.data.ind.entity.IndItemEntity; -import com.iailab.module.data.ind.entity.IndItemEntity; -import org.apache.ibatis.annotations.Mapper; - -import java.util.List; -import java.util.Map; - -/** - * @author PanZhibao - * @Description - * @createTime 2024年05月25日 - */ -@TenantDS -@Mapper -public interface IndItemDao extends BaseDao<IndItemEntity> { - - List<IndItemDTO> getItemAtom(Map<String, Object> params); - - List<IndItemDTO> getItemCal(Map<String, Object> params); -} \ No newline at end of file diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/dao/IndItemValueDao.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/dao/IndItemValueDao.java deleted file mode 100644 index 1d109a6..0000000 --- a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/dao/IndItemValueDao.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.iailab.module.data.ind.dao; - -import com.iailab.framework.common.dao.BaseDao; -import com.iailab.framework.tenant.core.db.dynamic.TenantDS; -import com.iailab.module.data.ind.entity.IndItemValueEntity; -import com.iailab.module.data.ind.entity.IndItemValueEntity; -import com.iailab.module.data.ind.dto.IndItemDTO; -import com.iailab.module.data.ind.dto.IndItemValueDTO; -import com.iailab.module.data.ind.entity.IndItemValueEntity; -import com.iailab.module.data.ind.entity.IndItemValueEntity; -import org.apache.ibatis.annotations.Mapper; - -import java.util.List; - -/** - * @author PanZhibao - * @Description - * @createTime 2024年05月25日 - */ -@TenantDS -@Mapper -public interface IndItemValueDao extends BaseDao<IndItemValueEntity> { - - List<IndItemValueDTO> getSourceValue(IndItemDTO queryDto); -} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/data/package-info.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/data/package-info.java new file mode 100644 index 0000000..30fa3e8 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/data/package-info.java @@ -0,0 +1 @@ +package com.iailab.module.data.ind.data; \ No newline at end of file diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/dto/IndItemAtomDTO.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/dto/IndItemAtomDTO.java deleted file mode 100644 index 34528d9..0000000 --- a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/dto/IndItemAtomDTO.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.iailab.module.data.ind.dto; - -import io.swagger.v3.oas.annotations.tags.Tag; -import lombok.Data; - -import java.io.Serializable; - -/** - * @author PanZhibao - * @Description - * @createTime 2024年05月25日 - */ -@Data -@Tag(name = "原子指标") -public class IndItemAtomDTO implements Serializable { - private static final long serialVersionUID = 1L; - - private String id; - - private String itemId; - - private String dataSource; - - private String querySql; - -} \ No newline at end of file diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/dto/IndItemCalDTO.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/dto/IndItemCalDTO.java deleted file mode 100644 index 8954b74..0000000 --- a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/dto/IndItemCalDTO.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.iailab.module.data.ind.dto; - -import io.swagger.v3.oas.annotations.tags.Tag; -import lombok.Data; - -import java.io.Serializable; - -/** - * @author PanZhibao - * @Description - * @createTime 2024年05月25日 - */ -@Data -@Tag(name = "计算指标") -public class IndItemCalDTO implements Serializable { - private static final long serialVersionUID = 1L; - - private String id; - - private String itemId; - - private String expression; -} \ No newline at end of file diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/dto/IndItemDTO.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/dto/IndItemDTO.java deleted file mode 100644 index 7645712..0000000 --- a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/dto/IndItemDTO.java +++ /dev/null @@ -1,63 +0,0 @@ -package com.iailab.module.data.ind.dto; - -import io.swagger.v3.oas.annotations.tags.Tag; -import lombok.Data; - -import java.io.Serializable; -import java.math.BigDecimal; -import java.util.Date; - -/** - * @author PanZhibao - * @Description - * @createTime 2024年05月25日 - */ -@Data -@Tag(name = "指标项") -public class IndItemDTO implements Serializable { - private static final long serialVersionUID = 1L; - - private String id; - - private String itemNo; - - private String itemName; - - private String itemType; - - private BigDecimal coefficient; - - private Integer precision; - - private String businessType; - - private String timeRange; - - private String timeGranularity; - - private String remark; - - private Integer isEnable; - - private String creator; - - private Date createTime; - - private String updater; - - private Date updateTime; - - private String dataSource; - - private String querySql; - - private String expression; - - private String sqlSelect; - - private String sqlWhere; - - private IndItemAtomDTO indItemAtom; - - private IndItemCalDTO indItemCal; -} \ No newline at end of file diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/dto/IndItemValueDTO.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/dto/IndItemValueDTO.java deleted file mode 100644 index 2cbe1e6..0000000 --- a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/dto/IndItemValueDTO.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.iailab.module.data.ind.dto; - -import io.swagger.v3.oas.annotations.tags.Tag; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.io.Serializable; -import java.math.BigDecimal; - -/** - * @author PanZhibao - * @Description - * @createTime 2024年05月25日 - */ -@Data -@Tag(name = "指标值") -public class IndItemValueDTO implements Serializable { - private static final long serialVersionUID = 1L; - - - @Schema(description = "指标编码") - private String itemNo; - - @Schema(description = "数据时间") - private String dataTime; - - @Schema(description = "数据值") - private BigDecimal dataValue; -} \ No newline at end of file diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/entity/IndItemAtomEntity.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/entity/IndItemAtomEntity.java deleted file mode 100644 index 0454616..0000000 --- a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/entity/IndItemAtomEntity.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.iailab.module.data.ind.entity; - - -import com.baomidou.mybatisplus.annotation.IdType; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.Data; - -import java.io.Serializable; - -@Data -@TableName("t_ind_item_atom") -public class IndItemAtomEntity implements Serializable { - private static final long serialVersionUID = 1L; - - @TableId(type = IdType.ASSIGN_UUID) - private String id; - - private String itemId; - - private String dataSource; - - private String querySql; - - -} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/entity/IndItemCalEntity.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/entity/IndItemCalEntity.java deleted file mode 100644 index 75380f6..0000000 --- a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/entity/IndItemCalEntity.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.iailab.module.data.ind.entity; - -import com.baomidou.mybatisplus.annotation.IdType; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.Data; - -import java.io.Serializable; - -@Data -@TableName("t_ind_item_cal") -public class IndItemCalEntity implements Serializable { - private static final long serialVersionUID = 1L; - - @TableId(type = IdType.ASSIGN_UUID) - private String id; - - private String itemId; - - private String expression; - - -} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/entity/IndItemEntity.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/entity/IndItemEntity.java deleted file mode 100644 index e9d2ad4..0000000 --- a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/entity/IndItemEntity.java +++ /dev/null @@ -1,96 +0,0 @@ -package com.iailab.module.data.ind.entity; - - -import com.baomidou.mybatisplus.annotation.IdType; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.Data; - -import java.io.Serializable; -import java.math.BigDecimal; -import java.util.Date; - -@Data -@TableName("t_ind_item") -public class IndItemEntity implements Serializable { - private static final long serialVersionUID = 1L; - - /** - * ID - */ - @TableId(type = IdType.ASSIGN_UUID) - private String id; - - /** - * 指标编码 - */ - private String itemNo; - - /** - * 指标名称 - */ - private String itemName; - - /** - * 指标类型 - */ - private String itemType; - - /** - * 系数 - */ - private BigDecimal coefficient; - - /** - * 指标精度 - */ - @TableField("`precision`") - private Integer precision; - - /** - * 业务类型 - */ - private String businessType; - - /** - * 时间范围 - */ - private String timeRange; - - /** - * 时间粒度 - */ - private String timeGranularity; - - /** - * 备注 - */ - private String remark; - - /** - * 是否启用 - */ - private Integer isEnable; - - /** - * 创建人 - */ - private String creator; - - /** - * 创建时间 - */ - private Date createTime; - - /** - * 修改人 - */ - private String updater; - - /** - * 修改人 - */ - private Date updateTime; - -} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/entity/IndItemValueEntity.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/entity/IndItemValueEntity.java deleted file mode 100644 index c57921c..0000000 --- a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/entity/IndItemValueEntity.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.iailab.module.data.ind.entity; - -import com.baomidou.mybatisplus.annotation.IdType; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.Data; - -import java.io.Serializable; -import java.math.BigDecimal; - -/** - * @author PanZhibao - * @Description - * @createTime 2024年05月25日 - */ -@Data -@TableName("t_ind_item_value") -public class IndItemValueEntity implements Serializable { - private static final long serialVersionUID = 1L; - - @TableId(type = IdType.ASSIGN_UUID) - private String id; - - private String itemNo; - - private BigDecimal dataValue; - - private String dataTime; -} \ No newline at end of file diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/item/package-info.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/item/package-info.java new file mode 100644 index 0000000..f31f0f7 --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/item/package-info.java @@ -0,0 +1 @@ +package com.iailab.module.data.ind.item; \ No newline at end of file diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/package-info.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/package-info.java new file mode 100644 index 0000000..60f67db --- /dev/null +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/package-info.java @@ -0,0 +1 @@ +package com.iailab.module.data.ind; \ No newline at end of file diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/service/IndItemAtomService.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/service/IndItemAtomService.java deleted file mode 100644 index fda474d..0000000 --- a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/service/IndItemAtomService.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.iailab.module.data.ind.service; - -import com.iailab.framework.common.page.PageData; -import com.iailab.framework.common.service.BaseService; -import com.iailab.module.data.ind.dto.IndItemAtomDTO; -import com.iailab.module.data.ind.entity.IndItemAtomEntity; -import com.iailab.module.data.ind.dto.IndItemAtomDTO; -import com.iailab.module.data.ind.entity.IndItemAtomEntity; -import com.iailab.module.data.ind.dto.IndItemAtomDTO; -import com.iailab.module.data.ind.entity.IndItemAtomEntity; -import com.iailab.module.data.ind.dto.IndItemAtomDTO; -import com.iailab.module.data.ind.entity.IndItemAtomEntity; - -import java.util.Map; - -/** - * @author PanZhibao - * @Description - * @createTime 2024年05月25日 - */ -public interface IndItemAtomService extends BaseService<IndItemAtomEntity> { - - PageData<IndItemAtomDTO> page(Map<String, Object> params); - - IndItemAtomDTO get(String id); - - IndItemAtomDTO getItemId(String itemId); - - void save(IndItemAtomDTO dto); - - void update(IndItemAtomDTO dto); - - void delete(String[] ids); - - void deleteByItemId(String[] ids); -} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/service/IndItemCalService.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/service/IndItemCalService.java deleted file mode 100644 index a93e6d0..0000000 --- a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/service/IndItemCalService.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.iailab.module.data.ind.service; - -import com.iailab.framework.common.page.PageData; -import com.iailab.framework.common.service.BaseService; -import com.iailab.module.data.ind.dto.IndItemCalDTO; -import com.iailab.module.data.ind.entity.IndItemCalEntity; - -import java.util.Map; - -/** - * @author PanZhibao - * @Description - * @createTime 2024年05月25日 - */ -public interface IndItemCalService extends BaseService<IndItemCalEntity> { - - PageData<IndItemCalDTO> page(Map<String, Object> params); - - IndItemCalDTO get(String id); - - IndItemCalDTO getItemId(String itemId); - - void save(IndItemCalDTO dto); - - void update(IndItemCalDTO dto); - - void delete(String[] ids); - - void deleteByItemId(String[] ids); - -} diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/service/IndItemService.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/service/IndItemService.java deleted file mode 100644 index f9c8168..0000000 --- a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/service/IndItemService.java +++ /dev/null @@ -1,43 +0,0 @@ -package com.iailab.module.data.ind.service; - -import com.iailab.framework.common.page.PageData; -import com.iailab.framework.common.service.BaseService; -import com.iailab.module.data.ind.dto.IndItemDTO; -import com.iailab.module.data.ind.entity.IndItemEntity; - -import java.util.List; -import java.util.Map; - -/** - * @author PanZhibao - * @Description - * @createTime 2024年05月25日 - */ -public interface IndItemService extends BaseService<IndItemEntity> { - - PageData<IndItemDTO> page(Map<String, Object> params); - - IndItemDTO get(String id); - - void save(IndItemDTO dto); - - void update(IndItemDTO dto); - - void delete(String[] ids); - - List<IndItemDTO> getItemAtom(List<String> itemNos); - - IndItemDTO getItemAtom(String itemNo); - - List<IndItemDTO> getItemCal(List<String> itemNos); - - IndItemDTO getItemCal(String itemNo); - - List<IndItemDTO> getList(Map<String, Object> params); - - void enableByIds(String[] ids); - - void disableByIds(String[] ids); - - IndItemDTO getItemByItemNo(String itemNo); -} \ No newline at end of file diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/service/IndItemValueService.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/service/IndItemValueService.java deleted file mode 100644 index 2645281..0000000 --- a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/service/IndItemValueService.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.iailab.module.data.ind.service; - -import com.iailab.framework.common.page.PageData; -import com.iailab.framework.common.service.BaseService; -import com.iailab.module.data.ind.dto.IndItemValueDTO; -import com.iailab.module.data.ind.entity.IndItemValueEntity; - -import java.util.Map; - -/** - * @author PanZhibao - * @Description - * @createTime 2024年05月25日 - */ -public interface IndItemValueService extends BaseService<IndItemValueEntity> { - - PageData<IndItemValueDTO> page(Map<String, Object> params); - - IndItemValueDTO get(String id); - - void save(IndItemValueDTO dto); - - void update(IndItemValueDTO dto); - - void delete(String[] ids); -} \ No newline at end of file diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/service/impl/IndItemAtomServiceImpl.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/service/impl/IndItemAtomServiceImpl.java deleted file mode 100644 index e33a236..0000000 --- a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/service/impl/IndItemAtomServiceImpl.java +++ /dev/null @@ -1,96 +0,0 @@ -package com.iailab.module.data.ind.service.impl; - -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import com.baomidou.mybatisplus.core.metadata.IPage; -import com.iailab.framework.common.constant.Constant; -import com.iailab.framework.common.page.PageData; -import com.iailab.framework.common.service.impl.BaseServiceImpl; -import com.iailab.framework.common.util.object.ConvertUtils; -import com.iailab.module.data.ind.dao.IndItemAtomDao; -import com.iailab.module.data.ind.dto.IndItemAtomDTO; -import com.iailab.module.data.ind.dao.IndItemAtomDao; -import com.iailab.module.data.ind.dto.IndItemAtomDTO; -import com.iailab.module.data.ind.dao.IndItemAtomDao; -import com.iailab.module.data.ind.dto.IndItemAtomDTO; -import com.iailab.module.data.ind.entity.IndItemAtomEntity; -import com.iailab.module.data.ind.service.IndItemAtomService; -import com.iailab.module.data.ind.dao.IndItemAtomDao; -import com.iailab.module.data.ind.dto.IndItemAtomDTO; -import org.apache.commons.lang3.StringUtils; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - -import java.util.Arrays; -import java.util.Map; - -/** - * @author PanZhibao - * @Description - * @createTime 2024年05月25日 - */ -@Service -public class IndItemAtomServiceImpl extends BaseServiceImpl<IndItemAtomDao, IndItemAtomEntity> implements IndItemAtomService { - - @Override - public PageData<IndItemAtomDTO> page(Map<String, Object> params) { - IPage<IndItemAtomEntity> page = baseDao.selectPage( - getPage(params, Constant.CREATE_DATE, false), - getWrapper(params) - ); - return getPageData(page, IndItemAtomDTO.class); - } - - private QueryWrapper<IndItemAtomEntity> getWrapper(Map<String, Object> params){ - String itemId = (String)params.get("itemId"); - - QueryWrapper<IndItemAtomEntity> wrapper = new QueryWrapper<>(); - wrapper.like(StringUtils.isNotBlank(itemId), "item_id", itemId); - - return wrapper; - } - - @Override - public IndItemAtomDTO get(String id) { - IndItemAtomEntity entity = baseDao.selectById(id); - - return ConvertUtils.sourceToTarget(entity, IndItemAtomDTO.class); - } - - @Override - public IndItemAtomDTO getItemId(String itemId) { - QueryWrapper<IndItemAtomEntity> wrapper = new QueryWrapper<>(); - wrapper.like(StringUtils.isNotBlank(itemId), "item_id", itemId); - IndItemAtomEntity entity = baseDao.selectOne(wrapper); - - return ConvertUtils.sourceToTarget(entity, IndItemAtomDTO.class); - } - - - @Override - public void save(IndItemAtomDTO dto) { - IndItemAtomEntity entity = ConvertUtils.sourceToTarget(dto, IndItemAtomEntity.class); - - insert(entity); - } - - @Override - public void update(IndItemAtomDTO dto) { - IndItemAtomEntity entity = ConvertUtils.sourceToTarget(dto, IndItemAtomEntity.class); - - updateById(entity); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void delete(String[] ids) { - baseDao.deleteBatchIds(Arrays.asList(ids)); - - } - - @Override - public void deleteByItemId(String[] ids) { - QueryWrapper<IndItemAtomEntity> wrapper = new QueryWrapper<>(); - wrapper.in("item_id", ids); - baseDao.delete(wrapper); - } -} \ No newline at end of file diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/service/impl/IndItemCalServiceImpl.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/service/impl/IndItemCalServiceImpl.java deleted file mode 100644 index 2809922..0000000 --- a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/service/impl/IndItemCalServiceImpl.java +++ /dev/null @@ -1,98 +0,0 @@ -package com.iailab.module.data.ind.service.impl; - -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import com.baomidou.mybatisplus.core.metadata.IPage; -import com.iailab.framework.common.constant.Constant; -import com.iailab.framework.common.page.PageData; -import com.iailab.framework.common.service.impl.BaseServiceImpl; -import com.iailab.framework.common.util.object.ConvertUtils; -import com.iailab.module.data.ind.dao.IndItemCalDao; -import com.iailab.module.data.ind.entity.IndItemCalEntity; -import com.iailab.module.data.ind.service.IndItemCalService; -import com.iailab.module.data.ind.dao.IndItemCalDao; -import com.iailab.module.data.ind.entity.IndItemCalEntity; -import com.iailab.module.data.ind.service.IndItemCalService; -import com.iailab.module.data.ind.dao.IndItemCalDao; -import com.iailab.module.data.ind.dto.IndItemCalDTO; -import com.iailab.module.data.ind.entity.IndItemCalEntity; -import com.iailab.module.data.ind.service.IndItemCalService; -import com.iailab.module.data.ind.dao.IndItemCalDao; -import com.iailab.module.data.ind.entity.IndItemCalEntity; -import com.iailab.module.data.ind.service.IndItemCalService; -import org.apache.commons.lang3.StringUtils; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - -import java.util.Arrays; -import java.util.Map; - -/** - * @author PanZhibao - * @Description - * @createTime 2024年05月25日 - */ -@Service -public class IndItemCalServiceImpl extends BaseServiceImpl<IndItemCalDao, IndItemCalEntity> implements IndItemCalService { - - @Override - public PageData<IndItemCalDTO> page(Map<String, Object> params) { - IPage<IndItemCalEntity> page = baseDao.selectPage( - getPage(params, Constant.CREATE_DATE, false), - getWrapper(params) - ); - return getPageData(page, IndItemCalDTO.class); - } - - private QueryWrapper<IndItemCalEntity> getWrapper(Map<String, Object> params){ - String itemId = (String)params.get("itemId"); - - QueryWrapper<IndItemCalEntity> wrapper = new QueryWrapper<>(); - wrapper.like(StringUtils.isNotBlank(itemId), "item_id", itemId); - - return wrapper; - } - - @Override - public IndItemCalDTO get(String id) { - IndItemCalEntity entity = baseDao.selectById(id); - - return ConvertUtils.sourceToTarget(entity, IndItemCalDTO.class); - } - - @Override - public IndItemCalDTO getItemId(String itemId) { - QueryWrapper<IndItemCalEntity> wrapper = new QueryWrapper<>(); - wrapper.like(StringUtils.isNotBlank(itemId), "item_id", itemId); - IndItemCalEntity entity = baseDao.selectOne(wrapper); - - return ConvertUtils.sourceToTarget(entity, IndItemCalDTO.class); - } - - @Override - public void save(IndItemCalDTO dto) { - IndItemCalEntity entity = ConvertUtils.sourceToTarget(dto, IndItemCalEntity.class); - - insert(entity); - } - - @Override - public void update(IndItemCalDTO dto) { - IndItemCalEntity entity = ConvertUtils.sourceToTarget(dto, IndItemCalEntity.class); - - updateById(entity); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void delete(String[] ids) { - baseDao.deleteBatchIds(Arrays.asList(ids)); - - } - - @Override - public void deleteByItemId(String[] ids) { - QueryWrapper<IndItemCalEntity> wrapper = new QueryWrapper<>(); - wrapper.in("item_id", ids); - baseDao.delete(wrapper); - } -} \ No newline at end of file diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/service/impl/IndItemServiceImpl.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/service/impl/IndItemServiceImpl.java deleted file mode 100644 index 53126dc..0000000 --- a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/service/impl/IndItemServiceImpl.java +++ /dev/null @@ -1,208 +0,0 @@ -package com.iailab.module.data.ind.service.impl; - -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import com.baomidou.mybatisplus.core.metadata.IPage; -import com.iailab.framework.common.constant.Constant; -import com.iailab.module.data.common.enums.CommonConstant; -import com.iailab.module.data.common.enums.IsEnableEnum; -import com.iailab.framework.common.page.PageData; -import com.iailab.framework.common.service.impl.BaseServiceImpl; -import com.iailab.framework.common.util.object.ConvertUtils; -import com.iailab.module.data.ind.dto.IndItemAtomDTO; -import com.iailab.module.data.ind.service.IndItemCalService; -import com.iailab.module.data.ind.service.IndItemService; -import com.iailab.module.data.ind.common.IndItemTypeEnum; -import com.iailab.module.data.ind.dao.IndItemDao; -import com.iailab.module.data.ind.dto.IndItemCalDTO; -import com.iailab.module.data.ind.dto.IndItemDTO; -import com.iailab.module.data.ind.entity.IndItemEntity; -import com.iailab.module.data.ind.service.IndItemAtomService; -import org.apache.commons.lang3.StringUtils; -import javax.annotation.Resource; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.util.CollectionUtils; - -import java.util.*; - -/** - * @author PanZhibao - * @Description - * @createTime 2024年05月25日 - */ -@Service -public class IndItemServiceImpl extends BaseServiceImpl<IndItemDao, IndItemEntity> implements IndItemService { - - @Resource - private IndItemAtomService indItemAtomService; - - @Resource - private IndItemCalService indItemCalService; - - @Override - public PageData<IndItemDTO> page(Map<String, Object> params) { - IPage<IndItemEntity> page = baseDao.selectPage( - getPage(params, Constant.CREATE_TIME, false), - getWrapper(params) - ); - return getPageData(page, IndItemDTO.class); - } - - @Override - public List<IndItemDTO> getList(Map<String, Object> params) { - List<IndItemEntity> list = baseDao.selectList(getWrapper(params)); - return ConvertUtils.sourceToTarget(list, IndItemDTO.class); - } - - @Override - public void enableByIds(String[] ids) { - if (CollectionUtils.isEmpty(Arrays.asList(ids))) { - return; - } - Arrays.asList(ids).forEach(item -> { - IndItemEntity entity = new IndItemEntity(); - entity.setId(item); - entity.setIsEnable(IsEnableEnum.ENABLE.value()); - baseDao.updateById(entity); - }); - } - - @Override - public void disableByIds(String[] ids) { - if (CollectionUtils.isEmpty(Arrays.asList(ids))) { - return; - } - Arrays.asList(ids).forEach(item -> { - IndItemEntity entity = new IndItemEntity(); - entity.setId(item); - entity.setIsEnable(IsEnableEnum.DISABLE.value()); - baseDao.updateById(entity); - }); - } - - @Override - public IndItemDTO getItemByItemNo(String itemNo) { - QueryWrapper<IndItemEntity> wrapper = new QueryWrapper<>(); - wrapper.eq("item_no", itemNo); - return ConvertUtils.sourceToTarget(baseDao.selectOne(wrapper),IndItemDTO.class); - } - - private QueryWrapper<IndItemEntity> getWrapper(Map<String, Object> params){ - String itemNo = (String)params.get("itemNo"); - - QueryWrapper<IndItemEntity> wrapper = new QueryWrapper<>(); - wrapper.like(StringUtils.isNotBlank(itemNo), "item_no", itemNo); - - return wrapper; - } - - @Override - public IndItemDTO get(String id) { - IndItemEntity entity = baseDao.selectById(id); - if (entity == null) { - return null; - } - IndItemDTO result = ConvertUtils.sourceToTarget(entity, IndItemDTO.class); - if (IndItemTypeEnum.ATOM_ITEM.getCode().equals(result.getItemType())) { - IndItemAtomDTO dto = indItemAtomService.getItemId(id); - result.setIndItemAtom(dto); - } else if (IndItemTypeEnum.CAL_ITEM.getCode().equals(result.getItemType())) { - IndItemCalDTO dto = indItemCalService.getItemId(id); - result.setIndItemCal(dto); - } - return result; - } - - @Override - public void save(IndItemDTO dto) { - IndItemEntity entity = ConvertUtils.sourceToTarget(dto, IndItemEntity.class); - entity.setId(UUID.randomUUID().toString()); - if (IndItemTypeEnum.ATOM_ITEM.getName().equals(entity.getItemType())) { - IndItemAtomDTO indItemAtomDTO = new IndItemAtomDTO(); - indItemAtomDTO.setId(UUID.randomUUID().toString()); - indItemAtomDTO.setItemId(entity.getId()); - indItemAtomDTO.setDataSource(dto.getDataSource()); - indItemAtomDTO.setQuerySql(dto.getQuerySql()); - indItemAtomService.save(indItemAtomDTO); - }else if (IndItemTypeEnum.CAL_ITEM.getName().equals(entity.getItemType())){ - IndItemCalDTO indItemCalDTO = new IndItemCalDTO(); - indItemCalDTO.setId(UUID.randomUUID().toString()); - indItemCalDTO.setItemId(entity.getId()); - indItemCalDTO.setExpression(dto.getExpression()); - indItemCalService.save(indItemCalDTO); - } - entity.setIsEnable(CommonConstant.IS_ENABLE); - entity.setCreateTime(new Date()); - insert(entity); - } - - @Override - public void update(IndItemDTO dto) { - IndItemEntity entity = ConvertUtils.sourceToTarget(dto, IndItemEntity.class); - entity.setUpdateTime(new Date()); - updateById(entity); - System.out.println(IndItemTypeEnum.ATOM_ITEM.getName()+IndItemTypeEnum.CAL_ITEM.getName()); - if (IndItemTypeEnum.ATOM_ITEM.getName().equals(entity.getItemType())) { - dto.getIndItemAtom().setDataSource(dto.getDataSource()); - dto.getIndItemAtom().setQuerySql(dto.getQuerySql()); - indItemAtomService.update(dto.getIndItemAtom()); - }else if (IndItemTypeEnum.CAL_ITEM.getName().equals(entity.getItemType())){ - dto.getIndItemCal().setExpression(dto.getExpression()); - indItemCalService.update(dto.getIndItemCal()); - } - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void delete(String[] ids) { - baseDao.deleteBatchIds(Arrays.asList(ids)); - indItemAtomService.deleteByItemId(ids); - indItemCalService.deleteByItemId(ids); - } - - @Override - public List<IndItemDTO> getItemAtom(List<String> itemNos) { - Map<String, Object> params = new HashMap<>(); - params.put("itemType", IndItemTypeEnum.ATOM_ITEM.getCode()); - params.put("isEnable", CommonConstant.IS_ENABLE); - params.put("itemNos", itemNos); - return baseDao.getItemAtom(params); - } - - @Override - public IndItemDTO getItemAtom(String itemNo) { - IndItemDTO result = null; - Map<String, Object> params = new HashMap<>(); - params.put("itemType", IndItemTypeEnum.ATOM_ITEM.getCode()); - params.put("isEnable", CommonConstant.IS_ENABLE); - params.put("itemNo", itemNo); - List<IndItemDTO> list = baseDao.getItemAtom(params); - if (!CollectionUtils.isEmpty(list)) { - result = list.get(0); - } - return result; - } - - @Override - public List<IndItemDTO> getItemCal(List<String> itemNos) { - Map<String, Object> params = new HashMap<>(); - params.put("itemType", IndItemTypeEnum.CAL_ITEM.getCode()); - params.put("isEnable", CommonConstant.IS_ENABLE); - params.put("itemNos", itemNos); - return baseDao.getItemCal(params); - } - - @Override - public IndItemDTO getItemCal(String itemNo) { - IndItemDTO result = null; - Map<String, Object> params = new HashMap<>(); - params.put("itemType", IndItemTypeEnum.CAL_ITEM.getCode()); - params.put("isEnable", CommonConstant.IS_ENABLE); - params.put("itemNo", itemNo); - List<IndItemDTO> list = baseDao.getItemCal(params); - if (!CollectionUtils.isEmpty(list)) { - result = list.get(0); - } - return result; - } -} \ No newline at end of file diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/service/impl/IndItemValueServiceImpl.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/service/impl/IndItemValueServiceImpl.java deleted file mode 100644 index abb2bcc..0000000 --- a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/service/impl/IndItemValueServiceImpl.java +++ /dev/null @@ -1,82 +0,0 @@ -package com.iailab.module.data.ind.service.impl; - -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import com.baomidou.mybatisplus.core.metadata.IPage; -import com.iailab.framework.common.constant.Constant; -import com.iailab.framework.common.page.PageData; -import com.iailab.framework.common.service.impl.BaseServiceImpl; -import com.iailab.framework.common.util.object.ConvertUtils; -import com.iailab.module.data.ind.dao.IndItemValueDao; -import com.iailab.module.data.ind.entity.IndItemValueEntity; -import com.iailab.module.data.ind.service.IndItemValueService; -import com.iailab.module.data.ind.dao.IndItemValueDao; -import com.iailab.module.data.ind.entity.IndItemValueEntity; -import com.iailab.module.data.ind.service.IndItemValueService; -import com.iailab.module.data.ind.dao.IndItemValueDao; -import com.iailab.module.data.ind.dto.IndItemValueDTO; -import com.iailab.module.data.ind.entity.IndItemValueEntity; -import com.iailab.module.data.ind.service.IndItemValueService; -import com.iailab.module.data.ind.dao.IndItemValueDao; -import com.iailab.module.data.ind.entity.IndItemValueEntity; -import com.iailab.module.data.ind.service.IndItemValueService; -import org.apache.commons.lang3.StringUtils; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - -import java.util.Arrays; -import java.util.Map; - -/** - * @author PanZhibao - * @Description - * @createTime 2024年05月25日 - */ -@Service -public class IndItemValueServiceImpl extends BaseServiceImpl<IndItemValueDao, IndItemValueEntity> implements IndItemValueService { - - @Override - public PageData<IndItemValueDTO> page(Map<String, Object> params) { - IPage<IndItemValueEntity> page = baseDao.selectPage( - getPage(params, Constant.CREATE_DATE, false), - getWrapper(params) - ); - return getPageData(page, IndItemValueDTO.class); - } - - private QueryWrapper<IndItemValueEntity> getWrapper(Map<String, Object> params) { - String itemNo = (String) params.get("itemNo"); - - QueryWrapper<IndItemValueEntity> wrapper = new QueryWrapper<>(); - wrapper.like(StringUtils.isNotBlank(itemNo), "item_no", itemNo); - - return wrapper; - } - - @Override - public IndItemValueDTO get(String id) { - IndItemValueEntity entity = baseDao.selectById(id); - - return ConvertUtils.sourceToTarget(entity, IndItemValueDTO.class); - } - - @Override - public void save(IndItemValueDTO dto) { - IndItemValueEntity entity = ConvertUtils.sourceToTarget(dto, IndItemValueEntity.class); - - insert(entity); - } - - @Override - public void update(IndItemValueDTO dto) { - IndItemValueEntity entity = ConvertUtils.sourceToTarget(dto, IndItemValueEntity.class); - - updateById(entity); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void delete(String[] ids) { - baseDao.deleteBatchIds(Arrays.asList(ids)); - - } -} \ No newline at end of file diff --git a/iailab-module-data/iailab-module-data-biz/src/main/resources/application.yml b/iailab-module-data/iailab-module-data-biz/src/main/resources/application.yml index b0e8d5e..5cc98b8 100644 --- a/iailab-module-data/iailab-module-data-biz/src/main/resources/application.yml +++ b/iailab-module-data/iailab-module-data-biz/src/main/resources/application.yml @@ -193,6 +193,9 @@ - t_http_api - t_http_tag - t_http_token + - t_ind_data_set + - t_ind_data_set_field + - t_ind_item_category - t_ind_item - t_ind_item_atom app: diff --git a/iailab-module-data/iailab-module-data-biz/src/main/resources/mapper/ind/IndItemDao.xml b/iailab-module-data/iailab-module-data-biz/src/main/resources/mapper/ind/IndItemDao.xml deleted file mode 100644 index b242970..0000000 --- a/iailab-module-data/iailab-module-data-biz/src/main/resources/mapper/ind/IndItemDao.xml +++ /dev/null @@ -1,74 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> - -<mapper namespace="com.iailab.module.data.ind.dao.IndItemDao"> - - - <select id="getItemAtom" resultType="com.iailab.module.data.ind.dto.IndItemDTO"> - SELECT - t1.item_no, - t1.item_name, - t1.item_type, - t1.coefficient, - t1.precision, - t1.time_range, - t1.time_granularity, - t2.data_source, - t2.query_sql - FROM t_ind_item t1 - LEFT JOIN t_ind_item_atom t2 ON t2.item_id = t1.id - <where> - t1.item_type = #{itemType} - <if test="isEnable != null"> - AND t1.is_enable = #{isEnable} - </if> - <if test="timeGranularity != null and timeGranularity != ''"> - AND t1.time_granularity = #{timeGranularity} - </if> - <if test="itemNo != null and itemNo != ''"> - AND t1.item_no = #{itemNo} - </if> - <if test="itemNos != null"> - AND t1.item_no in - <foreach collection="itemNos" item="item" index="item" open="(" close=")" separator=","> - #{item} - </foreach> - </if> - </where> - </select> - <select id="getItemCal" resultType="com.iailab.module.data.ind.dto.IndItemDTO"> - SELECT - t1.item_no, - t1.item_name, - t1.item_type, - t1.coefficient, - t1.precision, - t1.time_range, - t1.time_granularity, - t2.expression - FROM t_ind_item t1 - LEFT JOIN t_ind_item_cal t2 ON t2.item_id = t1.id - <where> - t1.item_type = #{itemType} - <if test="isEnable != null"> - AND t1.is_enable = #{isEnable} - </if> - <if test="timeGranularity != null and timeGranularity != ''"> - AND t1.time_granularity = #{timeGranularity} - </if> - <if test="itemNo != null and itemNo != ''"> - AND t1.item_no = #{itemNo} - </if> - <if test="itemNos != null"> - AND t1.item_no in - <foreach collection="itemNos" item="item" index="item" open="(" close=")" separator=","> - #{item} - </foreach> - </if> - </where> - - </select> - - - -</mapper> \ No newline at end of file diff --git a/iailab-module-data/iailab-module-data-biz/src/main/resources/mapper/ind/IndItemValueDao.xml b/iailab-module-data/iailab-module-data-biz/src/main/resources/mapper/ind/IndItemValueDao.xml deleted file mode 100644 index 2a07b6f..0000000 --- a/iailab-module-data/iailab-module-data-biz/src/main/resources/mapper/ind/IndItemValueDao.xml +++ /dev/null @@ -1,21 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> - -<mapper namespace="com.iailab.module.data.ind.dao.IndItemValueDao"> - - - <select id="getSourceValue" parameterType="com.iailab.module.data.ind.dto.IndItemDTO" resultType="com.iailab.module.data.ind.dto.IndItemValueDTO"> - select - ${sqlSelect} - from ( - ${querySql} - ) ind_t - <where> - <if test="sqlWhere != null and sqlWhere != ''"> - and ${sqlWhere} - </if> - </where> - order by ind_t.data_time - </select> - -</mapper> -- Gitblit v1.9.3