From edae4149a9a4e8ca81dff939a6e936d7868ad8c9 Mon Sep 17 00:00:00 2001 From: lishuai Date: Tue, 7 Jan 2025 15:29:31 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=89=E4=BC=8F=E7=94=B5=E7=AB=99=E4=BF=A1?= =?UTF-8?q?=E6=81=AF=202025=E5=B9=B41=E6=9C=887=E6=97=A515:29:28?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/PlantController.java | 2 +- .../qingyuan/manageboard/dto/PlantDTO.java | 18 +++++ .../manageboard/service/PlantService.java | 2 + .../service/impl/PlantServiceImpl.java | 69 ++++++++++++++++--- 4 files changed, 82 insertions(+), 9 deletions(-) diff --git a/modules/qingyuan/src/main/java/com/thing/qingyuan/manageboard/controller/PlantController.java b/modules/qingyuan/src/main/java/com/thing/qingyuan/manageboard/controller/PlantController.java index d50fba4..ab38756 100644 --- a/modules/qingyuan/src/main/java/com/thing/qingyuan/manageboard/controller/PlantController.java +++ b/modules/qingyuan/src/main/java/com/thing/qingyuan/manageboard/controller/PlantController.java @@ -56,7 +56,7 @@ public class PlantController { @GetMapping("list") @Operation(summary="电站列表信息") public Result> list(@RequestParam Map params){ - List plantDTOS = plantService.listAs(params, PlantDTO.class); + List plantDTOS = plantService.list(params); return new Result>().ok(plantDTOS); } diff --git a/modules/qingyuan/src/main/java/com/thing/qingyuan/manageboard/dto/PlantDTO.java b/modules/qingyuan/src/main/java/com/thing/qingyuan/manageboard/dto/PlantDTO.java index 87879d5..9557486 100644 --- a/modules/qingyuan/src/main/java/com/thing/qingyuan/manageboard/dto/PlantDTO.java +++ b/modules/qingyuan/src/main/java/com/thing/qingyuan/manageboard/dto/PlantDTO.java @@ -51,5 +51,23 @@ public class PlantDTO implements Serializable { private BigDecimal attenuation; @Schema(description = "日照时常") private BigDecimal sunshine; + @Schema(description = "电站收益, 每千瓦时发电量减排二氧化碳, 标准化单位") + private String profitco; + @Schema(description = "当年每千瓦时发电量减排二氧化碳量") + private String reduction; + @Schema(description = "当年发电A29") + private String attrKey29; + @Schema(description = "当年发电量") + private String val29; + @Schema(description = "发电功率A16") + private String attrKey16; + @Schema(description = "发电功率") + private String val16; + @Schema(description = "今日发电量") + private String attrKeyToday29; + @Schema(description = "今日发电量") + private String valToday29; + @Schema(description = "今日每千瓦时发电量减排二氧化碳量") + private String todayReduction; } \ No newline at end of file diff --git a/modules/qingyuan/src/main/java/com/thing/qingyuan/manageboard/service/PlantService.java b/modules/qingyuan/src/main/java/com/thing/qingyuan/manageboard/service/PlantService.java index cdebed7..f18266e 100644 --- a/modules/qingyuan/src/main/java/com/thing/qingyuan/manageboard/service/PlantService.java +++ b/modules/qingyuan/src/main/java/com/thing/qingyuan/manageboard/service/PlantService.java @@ -18,6 +18,8 @@ import java.util.Map; */ public interface PlantService extends IBaseService { + List list(Map params); + Map> findByParam(MapParam mapParam); List findByName(String plantName,String area); diff --git a/modules/qingyuan/src/main/java/com/thing/qingyuan/manageboard/service/impl/PlantServiceImpl.java b/modules/qingyuan/src/main/java/com/thing/qingyuan/manageboard/service/impl/PlantServiceImpl.java index 13604d9..884d633 100644 --- a/modules/qingyuan/src/main/java/com/thing/qingyuan/manageboard/service/impl/PlantServiceImpl.java +++ b/modules/qingyuan/src/main/java/com/thing/qingyuan/manageboard/service/impl/PlantServiceImpl.java @@ -1,27 +1,32 @@ package com.thing.qingyuan.manageboard.service.impl; import cn.hutool.core.map.MapUtil; -import cn.hutool.core.util.ObjectUtil; +import com.google.common.collect.Lists; import com.mybatisflex.core.query.QueryColumn; import com.mybatisflex.core.query.QueryWrapper; +import com.thing.common.core.utils.ConvertUtils; +import com.thing.common.data.tskv.TsKvDTO; +import com.thing.common.orm.service.impl.BaseServiceImpl; +import com.thing.common.tskv.service.TsKvService; import com.thing.qingyuan.manageboard.dto.MapParam; import com.thing.qingyuan.manageboard.dto.PlantDTO; import com.thing.qingyuan.manageboard.dto.PlantInfoReq; import com.thing.qingyuan.manageboard.entity.PlantEntity; import com.thing.qingyuan.manageboard.mapper.PlantMapper; import com.thing.qingyuan.manageboard.service.PlantService; -import com.thing.common.core.utils.ConvertUtils; -import com.thing.common.orm.service.impl.BaseServiceImpl; import com.thing.sys.security.context.UserContext; import com.thing.thing.entity.dto.IotThingEntityDTO; import com.thing.thing.entity.service.IotThingEntityService; -import lombok.RequiredArgsConstructor; +import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import javax.annotation.Resource; +import java.math.BigDecimal; +import java.math.RoundingMode; import java.util.List; import java.util.Map; +import java.util.Objects; import java.util.Optional; import java.util.stream.Collectors; @@ -34,12 +39,12 @@ import static com.mybatisflex.core.query.QueryMethods.column; * @since 3.0 2024-01-29 */ @Service -@RequiredArgsConstructor public class PlantServiceImpl extends BaseServiceImpl implements PlantService { - @Autowired + @Resource IotThingEntityService iotThingEntityService; - + @Resource + private TsKvService tsKvService; @Override public QueryWrapper getWrapper(Map params){ @@ -63,6 +68,54 @@ public class PlantServiceImpl extends BaseServiceImpl } + @Override + public List list(Map params) { + List plantDTOS = listAs(params, PlantDTO.class); + if(CollectionUtils.isEmpty(plantDTOS)){ + return Lists.newArrayList(); + } + for (PlantDTO plantDTO : plantDTOS) { + Long plantId = plantDTO.getPlantId(); + //年发电量 + TsKvDTO tsKvDTO29 = tsKvService.findLatestByCodeAndAttr(String.valueOf(plantId), "A29yy"); + if(!Objects.isNull(tsKvDTO29)){ + plantDTO.setAttrKey29(tsKvDTO29.getAttrKey()); + plantDTO.setVal29(tsKvDTO29.getVal()); + //减排量 + if(!Objects.isNull(plantDTO.getProfitco())){ + plantDTO.setReduction( + new BigDecimal(tsKvDTO29.getVal()) + .subtract(new BigDecimal(plantDTO.getProfitco())) + .setScale(4, RoundingMode.HALF_UP) // 保留四位小数,四舍五入 + .toPlainString() + ); + } + } + //当前功率 + TsKvDTO tsKvDTO16 = tsKvService.findLatestByCodeAndAttr(String.valueOf(plantId), "A16"); + if(!Objects.isNull(tsKvDTO16)){ + plantDTO.setAttrKey16(tsKvDTO16.getAttrKey()); + plantDTO.setVal16(tsKvDTO16.getVal()); + } + //今日发电量 + TsKvDTO tsKvDToday29 = tsKvService.findLatestByCodeAndAttr(String.valueOf(plantId), "A29dd"); + if(!Objects.isNull(tsKvDToday29)){ + plantDTO.setAttrKeyToday29(tsKvDToday29.getAttrKey()); + plantDTO.setValToday29(tsKvDToday29.getVal()); + //今日减排量 + if(!Objects.isNull(plantDTO.getProfitco())){ + plantDTO.setTodayReduction( + new BigDecimal(tsKvDToday29.getVal()) + .subtract(new BigDecimal(plantDTO.getProfitco())) + .setScale(4, RoundingMode.HALF_UP) // 保留四位小数,四舍五入 + .toPlainString() + ); + } + } + } + return plantDTOS; + } + @Override public Map> findByParam(MapParam mapParam) { QueryWrapper wrapper = new QueryWrapper();