From 3763675057ef86741b65faad91da994454b97c9f Mon Sep 17 00:00:00 2001 From: lishuai Date: Mon, 6 Jan 2025 16:51:06 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=85=A4=E6=8A=98=E6=A0=87?= =?UTF-8?q?=E7=85=A4=202025=E5=B9=B41=E6=9C=886=E6=97=A516:51:03?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/resources/application.yml | 4 +- .../IotPowerCoalRatioController.java | 98 +++++++++++++++++ .../thing/ratio/dto/IotPowerCoalRatioDTO.java | 59 +++++++++++ .../ratio/entity/IotPowerCoalRatioEntity.java | 100 ++++++++++++++++++ .../ratio/mapper/IotPowerCoalRatioMapper.java | 16 +++ .../service/IotPowerCoalRatioService.java | 14 +++ .../impl/IotPowerCoalRatioServiceImpl.java | 28 +++++ 7 files changed, 317 insertions(+), 2 deletions(-) create mode 100644 modules/thing/src/main/java/com/thing/ratio/controller/IotPowerCoalRatioController.java create mode 100644 modules/thing/src/main/java/com/thing/ratio/dto/IotPowerCoalRatioDTO.java create mode 100644 modules/thing/src/main/java/com/thing/ratio/entity/IotPowerCoalRatioEntity.java create mode 100644 modules/thing/src/main/java/com/thing/ratio/mapper/IotPowerCoalRatioMapper.java create mode 100644 modules/thing/src/main/java/com/thing/ratio/service/IotPowerCoalRatioService.java create mode 100644 modules/thing/src/main/java/com/thing/ratio/service/impl/IotPowerCoalRatioServiceImpl.java diff --git a/application/src/main/resources/application.yml b/application/src/main/resources/application.yml index d9351f7..54b2ee9 100644 --- a/application/src/main/resources/application.yml +++ b/application/src/main/resources/application.yml @@ -62,7 +62,7 @@ database: # 数据源及mybatis、mybatis-flex配置 mybatis-flex: #是否开启审计日志打印 - auditEnable: false + auditEnable: true #mapper 包扫描路径 typeAliasesPackage: com.thing.**.mapper #mapper 扫描路径 @@ -113,7 +113,7 @@ calculate: am_total: offset: 24 #当数据出现断点时,向后偏移查询多少小时 interval: 15 # 分区间统计,间隔时长(分)1/3/5/10/15/20/30/60 - keys: A29,B2,C2,C6,D2,D4,E3,E4,F4,G2,G4,H2,I2,I4,K2,N2,N4,P4,Q2,R2,R4,S2,S4,F2,T2,T4,U2,U4,J2,J4,L2,A30,P2,Q4,V2,V4,A29_rush,A29_peak,A29_valley,A29_normal,A29_generate,A30_rush,A30_peak,A30_valley,A30_normal,tce_C6,tce_A29,tce_E3,CO2_A29,CO2_C6,CO2_E3,CO2_run,tce_run,tce_E3,A201,A202,A204,tce_J2 + keys: A29,B2,C2,C6,D2,D4,E3,E4,F4,G2,G4,H2,I2,I4,K2,N2,N4,P4,Q2,R2,R4,S2,S4,F2,T2,T4,U2,U4,J2,J4,L2,A30,P2,Q4,V2,V4,A29_rush,A29_peak,A29_valley,A29_normal,A29_generate,A30_rush,A30_peak,A30_valley,A30_normal,tce_C6,tce_A29,tce_E3,CO2_A29,CO2_C6,CO2_E3,CO2_run,tce_run,tce_E3,A201,A202,A204,tce_J2,gdp,tce,tce_vol,tce_B2,tce_H2,firms ddmmyy: #例如:每月1号0时0分 开始统计年/月/日用量 start_hh: 0 #小时/天/月/年 用量统计开始的分钟数(0-59) start_dd: 0 #天/月/年 用量统计开始的小时(0-23) diff --git a/modules/thing/src/main/java/com/thing/ratio/controller/IotPowerCoalRatioController.java b/modules/thing/src/main/java/com/thing/ratio/controller/IotPowerCoalRatioController.java new file mode 100644 index 0000000..9f51c1d --- /dev/null +++ b/modules/thing/src/main/java/com/thing/ratio/controller/IotPowerCoalRatioController.java @@ -0,0 +1,98 @@ +package com.thing.ratio.controller; + +import com.thing.common.core.annotation.LogOperation; +import com.thing.common.core.constants.Constant; +import com.thing.common.core.validator.AssertUtils; +import com.thing.common.core.validator.ValidatorUtils; +import com.thing.common.core.validator.group.AddGroup; +import com.thing.common.core.validator.group.DefaultGroup; +import com.thing.common.core.validator.group.UpdateGroup; +import com.thing.common.core.web.response.PageData; +import com.thing.common.core.web.response.Result; + +import com.thing.ratio.dto.IotPowerCoalRatioDTO; +import com.thing.ratio.service.IotPowerCoalRatioService; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.Parameters; +import io.swagger.v3.oas.annotations.tags.Tag; +import lombok.RequiredArgsConstructor; +import org.springframework.web.bind.annotation.*; + +import java.util.Map; + +/** +* 折标煤系数 +* +* @author ls +* @since 3.0 2025-01-02 +*/ +@RestController +@RequestMapping("v2/power/ratio") +@Tag(name="折标煤系数") +@RequiredArgsConstructor +public class IotPowerCoalRatioController { + + private final IotPowerCoalRatioService iotPowerCoalRatioService; + + @GetMapping("page") + @Operation(summary="分页") + @Parameters({ + @Parameter(name = Constant.PAGE, description = "当前页码,从1开始", required = true) , + @Parameter(name = Constant.LIMIT, description = "每页显示记录数", required = true) , + @Parameter(name = Constant.ORDER_FIELD, description = "排序字段") , + @Parameter(name = Constant.ORDER, description = "排序方式,可选值(asc、desc)") + }) + public Result> page(@Parameter(hidden = true) @RequestParam Map params){ + PageData page = iotPowerCoalRatioService.getPageData(params, IotPowerCoalRatioDTO.class); + return new Result>().ok(page); + } + + @GetMapping("{id}") + @Operation(summary="信息") + public Result get(@PathVariable("id") Long id){ + IotPowerCoalRatioDTO data = iotPowerCoalRatioService.getByIdAs(id, IotPowerCoalRatioDTO.class); + return new Result().ok(data); + } + + @PostMapping + @Operation(summary="保存") + @LogOperation("保存") + public Result save(@RequestBody IotPowerCoalRatioDTO dto){ + //效验数据 + ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); + iotPowerCoalRatioService.saveDto(dto); + return new Result<>(); + } + + @PutMapping + @Operation(summary="修改") + @LogOperation("修改") + public Result update(@RequestBody IotPowerCoalRatioDTO dto){ + //效验数据 + ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); + iotPowerCoalRatioService.updateDto(dto); + return new Result<>(); + } + + @DeleteMapping + @Operation(summary="删除") + @LogOperation("删除") + public Result delete(@RequestBody Long[] ids){ + //效验数据 + AssertUtils.isArrayEmpty(ids, "id"); + iotPowerCoalRatioService.batchDelete(ids); + return new Result<>(); + } + + /** + *@GetMapping("export") + *@Operation(summary="导出") + *@LogOperation("导出") + *public void export(@Parameter(hidden = true) @RequestParam Map params, HttpServletResponse response) throws Exception { + * List list = iotPowerCoalRatioService.listAs(params, IotPowerCoalRatioDTO.class); + * //ExcelUtils.exportExcelToTarget(response, null, "折标煤系数", list, IotPowerCoalRatioExcel.class); + *} + */ + +} \ No newline at end of file diff --git a/modules/thing/src/main/java/com/thing/ratio/dto/IotPowerCoalRatioDTO.java b/modules/thing/src/main/java/com/thing/ratio/dto/IotPowerCoalRatioDTO.java new file mode 100644 index 0000000..fd34928 --- /dev/null +++ b/modules/thing/src/main/java/com/thing/ratio/dto/IotPowerCoalRatioDTO.java @@ -0,0 +1,59 @@ +package com.thing.ratio.dto; + +import io.swagger.v3.oas.annotations.media.Schema; + +import lombok.Data; + +import java.io.Serial; +import java.io.Serializable; +import java.math.BigDecimal; +import java.util.Date; + +/** +* 折标煤系数 +* +* @author ls +* @since 3.0 2025-01-02 +*/ +@Data +@Schema(description = "折标煤系数") +public class IotPowerCoalRatioDTO implements Serializable { + @Serial + private static final long serialVersionUID = 1L; + + @Schema(description = "折标煤系数设置id") + private Long id; + @Schema(description = "能源品种") + private String powerTypeCode; + @Schema(description = "单位") + private String unit; + @Schema(description = "当量/等量 calorific/equivalent(业务字典-sa)") + private String energyValue; + @Schema(description = "折标煤单位") + private String coalUnit; + @Schema(description = "折标煤系数") + private BigDecimal coalRatio; + @Schema(description = "企业id") + private Long deptId; + @Schema(description = "租户code") + private Long tenantCode; + @Schema(description = "创建者") + private Long creator; + @Schema(description = "创建时间") + private Date createDate; + @Schema(description = "修改者") + private Long updater; + @Schema(description = "修改时间") + private Date updateDate; + @Schema(description = "类型") + private String type; + @Schema(description = "系数") + private BigDecimal ratio; + @Schema(description = "折标煤类型") + private String coalType; + @Schema(description = "实际折标系数小数位") + private String coalRatioDecimal; + @Schema(description = "参考折标系数小数位") + private String ratioDecimal; + +} \ No newline at end of file diff --git a/modules/thing/src/main/java/com/thing/ratio/entity/IotPowerCoalRatioEntity.java b/modules/thing/src/main/java/com/thing/ratio/entity/IotPowerCoalRatioEntity.java new file mode 100644 index 0000000..7941a7e --- /dev/null +++ b/modules/thing/src/main/java/com/thing/ratio/entity/IotPowerCoalRatioEntity.java @@ -0,0 +1,100 @@ +package com.thing.ratio.entity; + +import com.mybatisflex.annotation.Id; +import com.mybatisflex.annotation.KeyType; +import com.mybatisflex.annotation.Table; + +import com.mybatisflex.core.keygen.KeyGenerators; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +import java.io.Serial; +import java.io.Serializable; +import java.math.BigDecimal; +import java.util.Date; + +/** + * 折标煤系数 + * + * @author ls + * @since 3.0 2025-01-02 + */ +@Data +@Accessors(chain = true) +@EqualsAndHashCode(callSuper=false) +@Table("iot_power_coal_ratio") +public class IotPowerCoalRatioEntity implements Serializable { + @Serial + private static final long serialVersionUID = 1L; + + /** + * 折标煤系数设置id + */ + @Id(keyType = KeyType.Generator,value = KeyGenerators.snowFlakeId) + private Long id; + /** + * 能源品种 + */ + private String powerTypeCode; + /** + * 单位 + */ + private String unit; + /** + * 当量/等量 calorific/equivalent(业务字典-sa) + */ + private String energyValue; + /** + * 折标煤单位 + */ + private String coalUnit; + /** + * 折标煤系数 + */ + private BigDecimal coalRatio; + /** + * 企业id + */ + private Long deptId; + /** + * 租户code + */ + private Long tenantCode; + /** + * 创建者 + */ + private Long creator; + /** + * 创建时间 + */ + private Date createDate; + /** + * 修改者 + */ + private Long updater; + /** + * 修改时间 + */ + private Date updateDate; + /** + * 类型 + */ + private String type; + /** + * 系数 + */ + private BigDecimal ratio; + /** + * 折标煤类型 + */ + private String coalType; + /** + * 实际折标系数小数位 + */ + private String coalRatioDecimal; + /** + * 参考折标系数小数位 + */ + private String ratioDecimal; +} \ No newline at end of file diff --git a/modules/thing/src/main/java/com/thing/ratio/mapper/IotPowerCoalRatioMapper.java b/modules/thing/src/main/java/com/thing/ratio/mapper/IotPowerCoalRatioMapper.java new file mode 100644 index 0000000..9b1282e --- /dev/null +++ b/modules/thing/src/main/java/com/thing/ratio/mapper/IotPowerCoalRatioMapper.java @@ -0,0 +1,16 @@ +package com.thing.ratio.mapper; + +import com.thing.common.orm.mapper.PowerBaseMapper; +import com.thing.ratio.entity.IotPowerCoalRatioEntity; +import org.apache.ibatis.annotations.Mapper; + +/** +* 折标煤系数 +* +* @author ls +* @since 3.0 2025-01-02 +*/ +@Mapper +public interface IotPowerCoalRatioMapper extends PowerBaseMapper { + +} \ No newline at end of file diff --git a/modules/thing/src/main/java/com/thing/ratio/service/IotPowerCoalRatioService.java b/modules/thing/src/main/java/com/thing/ratio/service/IotPowerCoalRatioService.java new file mode 100644 index 0000000..89e9ad0 --- /dev/null +++ b/modules/thing/src/main/java/com/thing/ratio/service/IotPowerCoalRatioService.java @@ -0,0 +1,14 @@ +package com.thing.ratio.service; + +import com.thing.common.orm.service.IBaseService; +import com.thing.ratio.entity.IotPowerCoalRatioEntity; + +/** + * 折标煤系数 + * + * @author ls + * @since 3.0 2025-01-02 + */ +public interface IotPowerCoalRatioService extends IBaseService { + +} \ No newline at end of file diff --git a/modules/thing/src/main/java/com/thing/ratio/service/impl/IotPowerCoalRatioServiceImpl.java b/modules/thing/src/main/java/com/thing/ratio/service/impl/IotPowerCoalRatioServiceImpl.java new file mode 100644 index 0000000..608bfe4 --- /dev/null +++ b/modules/thing/src/main/java/com/thing/ratio/service/impl/IotPowerCoalRatioServiceImpl.java @@ -0,0 +1,28 @@ +package com.thing.ratio.service.impl; + +import com.mybatisflex.core.query.QueryWrapper; +import com.thing.common.orm.service.impl.BaseServiceImpl; +import com.thing.ratio.entity.IotPowerCoalRatioEntity; +import com.thing.ratio.mapper.IotPowerCoalRatioMapper; +import com.thing.ratio.service.IotPowerCoalRatioService; +import org.springframework.stereotype.Service; + +import java.util.Map; + +/** + * 折标煤系数 + * + * @author ls + * @since 3.0 2025-01-02 + */ +@Service +public class IotPowerCoalRatioServiceImpl extends BaseServiceImpl implements IotPowerCoalRatioService { + + @Override + public QueryWrapper getWrapper(Map params){ + QueryWrapper wrapper = new QueryWrapper(); + return wrapper; + } + + +} \ No newline at end of file