200 changed files with 12 additions and 15638 deletions
-
13application/src/main/resources/application.yml
-
108modules/qingyuan/src/main/java/com/thing/qingyuan/basedevice/controller/DeviceController.java
-
61modules/qingyuan/src/main/java/com/thing/qingyuan/basedevice/dto/DeviceDTO.java
-
88modules/qingyuan/src/main/java/com/thing/qingyuan/basedevice/entity/DeviceEntity.java
-
46modules/qingyuan/src/main/java/com/thing/qingyuan/basedevice/excel/DeviceExcel.java
-
18modules/qingyuan/src/main/java/com/thing/qingyuan/basedevice/mapper/DeviceMapper.java
-
18modules/qingyuan/src/main/java/com/thing/qingyuan/basedevice/service/IotDeviceService.java
-
36modules/qingyuan/src/main/java/com/thing/qingyuan/basedevice/service/impl/IotDeviceServiceImpl.java
-
20modules/qingyuan/src/main/java/com/thing/qingyuan/board/service/impl/BoardNewServiceImpl.java
-
72modules/qingyuan/src/main/java/com/thing/qingyuan/carbon/controller/QyCarbonAssetController.java
-
107modules/qingyuan/src/main/java/com/thing/qingyuan/carbon/controller/QyCarbonQuotaInfoController.java
-
111modules/qingyuan/src/main/java/com/thing/qingyuan/carbon/controller/QyCcerInfoController.java
-
105modules/qingyuan/src/main/java/com/thing/qingyuan/carbon/controller/QyGreenCertificateInfoController.java
-
87modules/qingyuan/src/main/java/com/thing/qingyuan/carbon/controller/QyRegionController.java
-
53modules/qingyuan/src/main/java/com/thing/qingyuan/carbon/dto/QyCarbonAssetDTO.java
-
67modules/qingyuan/src/main/java/com/thing/qingyuan/carbon/dto/QyCarbonQuotaInfoDTO.java
-
28modules/qingyuan/src/main/java/com/thing/qingyuan/carbon/dto/QyCarbonSumQuotaInfoDTO.java
-
63modules/qingyuan/src/main/java/com/thing/qingyuan/carbon/dto/QyCcerInfoDTO.java
-
63modules/qingyuan/src/main/java/com/thing/qingyuan/carbon/dto/QyGreenCertificateInfoDTO.java
-
38modules/qingyuan/src/main/java/com/thing/qingyuan/carbon/dto/QyRegionDTO.java
-
76modules/qingyuan/src/main/java/com/thing/qingyuan/carbon/entity/QyCarbonQuotaInfoEntity.java
-
75modules/qingyuan/src/main/java/com/thing/qingyuan/carbon/entity/QyCcerInfoEntity.java
-
68modules/qingyuan/src/main/java/com/thing/qingyuan/carbon/entity/QyGreenCertificateInfoEntity.java
-
34modules/qingyuan/src/main/java/com/thing/qingyuan/carbon/entity/QyRegionEntity.java
-
43modules/qingyuan/src/main/java/com/thing/qingyuan/carbon/exception/BusinessException.java
-
71modules/qingyuan/src/main/java/com/thing/qingyuan/carbon/mapper/QyCarbonQuotaInfoMapper.java
-
16modules/qingyuan/src/main/java/com/thing/qingyuan/carbon/mapper/QyCcerInfoMapper.java
-
9modules/qingyuan/src/main/java/com/thing/qingyuan/carbon/mapper/QyGreenCertificateInfoMapper.java
-
44modules/qingyuan/src/main/java/com/thing/qingyuan/carbon/mapper/QyRegionMapper.java
-
31modules/qingyuan/src/main/java/com/thing/qingyuan/carbon/service/QyCarbonAssetService.java
-
35modules/qingyuan/src/main/java/com/thing/qingyuan/carbon/service/QyCarbonQuotaInfoService.java
-
25modules/qingyuan/src/main/java/com/thing/qingyuan/carbon/service/QyCcerInfoService.java
-
21modules/qingyuan/src/main/java/com/thing/qingyuan/carbon/service/QyGreenCertificateInfoService.java
-
22modules/qingyuan/src/main/java/com/thing/qingyuan/carbon/service/QyRegionService.java
-
363modules/qingyuan/src/main/java/com/thing/qingyuan/carbon/service/impl/QyCarbonAssetServiceImpl.java
-
140modules/qingyuan/src/main/java/com/thing/qingyuan/carbon/service/impl/QyCarbonQuotaInfoServiceImpl.java
-
183modules/qingyuan/src/main/java/com/thing/qingyuan/carbon/service/impl/QyCcerInfoServiceImpl.java
-
153modules/qingyuan/src/main/java/com/thing/qingyuan/carbon/service/impl/QyGreenCertificateInfoServiceImpl.java
-
55modules/qingyuan/src/main/java/com/thing/qingyuan/carbon/service/impl/QyRegionServiceImpl.java
-
17modules/qingyuan/src/main/java/com/thing/qingyuan/carbon/util/Constant.java
-
41modules/qingyuan/src/main/java/com/thing/qingyuan/chargeStation/config/StationProperties.java
-
65modules/qingyuan/src/main/java/com/thing/qingyuan/chargeStation/controller/ChargeOrderHeadController.java
-
44modules/qingyuan/src/main/java/com/thing/qingyuan/chargeStation/controller/ChargeStatisticController.java
-
91modules/qingyuan/src/main/java/com/thing/qingyuan/chargeStation/controller/StationInfoController.java
-
84modules/qingyuan/src/main/java/com/thing/qingyuan/chargeStation/dto/ChargeOrderDetailsDTO.java
-
83modules/qingyuan/src/main/java/com/thing/qingyuan/chargeStation/dto/ChargeOrderHeadDTO.java
-
84modules/qingyuan/src/main/java/com/thing/qingyuan/chargeStation/dto/ChargeStatisticReportResp.java
-
94modules/qingyuan/src/main/java/com/thing/qingyuan/chargeStation/dto/ChargeStatisticRequest.java
-
64modules/qingyuan/src/main/java/com/thing/qingyuan/chargeStation/dto/ConnectorInfoDTO.java
-
18modules/qingyuan/src/main/java/com/thing/qingyuan/chargeStation/dto/ConnectorStatusInfo.java
-
64modules/qingyuan/src/main/java/com/thing/qingyuan/chargeStation/dto/EquipmentInfoDTO.java
-
11modules/qingyuan/src/main/java/com/thing/qingyuan/chargeStation/dto/IdNameDTO.java
-
17modules/qingyuan/src/main/java/com/thing/qingyuan/chargeStation/dto/SimpleThingRelationDTO.java
-
26modules/qingyuan/src/main/java/com/thing/qingyuan/chargeStation/dto/StationDeviceDetail.java
-
86modules/qingyuan/src/main/java/com/thing/qingyuan/chargeStation/dto/StationInfoDTO.java
-
81modules/qingyuan/src/main/java/com/thing/qingyuan/chargeStation/dto/StationOrderAgg.java
-
43modules/qingyuan/src/main/java/com/thing/qingyuan/chargeStation/dto/StationSimpleDTO.java
-
28modules/qingyuan/src/main/java/com/thing/qingyuan/chargeStation/dto/StationSimpleInfo.java
-
81modules/qingyuan/src/main/java/com/thing/qingyuan/chargeStation/entity/ChargeOrderDetailsEntity.java
-
70modules/qingyuan/src/main/java/com/thing/qingyuan/chargeStation/entity/ChargeOrderHeadEntity.java
-
66modules/qingyuan/src/main/java/com/thing/qingyuan/chargeStation/entity/ConnectorInfoEntity.java
-
80modules/qingyuan/src/main/java/com/thing/qingyuan/chargeStation/entity/EquipmentInfoEntity.java
-
105modules/qingyuan/src/main/java/com/thing/qingyuan/chargeStation/entity/StationInfoEntity.java
-
106modules/qingyuan/src/main/java/com/thing/qingyuan/chargeStation/excel/ChargeStatisticExcel.java
-
23modules/qingyuan/src/main/java/com/thing/qingyuan/chargeStation/mapper/ChargeOrderDetailsMapper.java
-
18modules/qingyuan/src/main/java/com/thing/qingyuan/chargeStation/mapper/ChargeOrderHeadMapper.java
-
32modules/qingyuan/src/main/java/com/thing/qingyuan/chargeStation/mapper/ConnectorInfoMapper.java
-
24modules/qingyuan/src/main/java/com/thing/qingyuan/chargeStation/mapper/EquipmentInfoMapper.java
-
22modules/qingyuan/src/main/java/com/thing/qingyuan/chargeStation/mapper/StationInfoMapper.java
-
20modules/qingyuan/src/main/java/com/thing/qingyuan/chargeStation/service/ChargeOrderDetailsService.java
-
21modules/qingyuan/src/main/java/com/thing/qingyuan/chargeStation/service/ChargeOrderHeadService.java
-
18modules/qingyuan/src/main/java/com/thing/qingyuan/chargeStation/service/ChargeStatisticService.java
-
23modules/qingyuan/src/main/java/com/thing/qingyuan/chargeStation/service/ConnectorInfoService.java
-
22modules/qingyuan/src/main/java/com/thing/qingyuan/chargeStation/service/EquipmentInfoService.java
-
55modules/qingyuan/src/main/java/com/thing/qingyuan/chargeStation/service/StationInfoService.java
-
57modules/qingyuan/src/main/java/com/thing/qingyuan/chargeStation/service/impl/ChargeOrderDetailsServiceImpl.java
-
108modules/qingyuan/src/main/java/com/thing/qingyuan/chargeStation/service/impl/ChargeOrderHeadServiceImpl.java
-
135modules/qingyuan/src/main/java/com/thing/qingyuan/chargeStation/service/impl/ChargeStatisticServiceImpl.java
-
51modules/qingyuan/src/main/java/com/thing/qingyuan/chargeStation/service/impl/ConnectorInfoServiceImpl.java
-
53modules/qingyuan/src/main/java/com/thing/qingyuan/chargeStation/service/impl/EquipmentInfoServiceImpl.java
-
389modules/qingyuan/src/main/java/com/thing/qingyuan/chargeStation/service/impl/StationInfoServiceImpl.java
-
275modules/qingyuan/src/main/java/com/thing/qingyuan/chargeStation/task/StationTask.java
-
99modules/qingyuan/src/main/java/com/thing/qingyuan/manageboard/controller/ManageBoardController.java
-
80modules/qingyuan/src/main/java/com/thing/qingyuan/manageboard/controller/ManageChargeController.java
-
121modules/qingyuan/src/main/java/com/thing/qingyuan/manageboard/controller/PlantController.java
-
20modules/qingyuan/src/main/java/com/thing/qingyuan/manageboard/dto/ChargeTotalInfo.java
-
22modules/qingyuan/src/main/java/com/thing/qingyuan/manageboard/dto/ChargingGunState.java
-
22modules/qingyuan/src/main/java/com/thing/qingyuan/manageboard/dto/DataParam.java
-
28modules/qingyuan/src/main/java/com/thing/qingyuan/manageboard/dto/DataReq.java
-
15modules/qingyuan/src/main/java/com/thing/qingyuan/manageboard/dto/FindParam.java
-
20modules/qingyuan/src/main/java/com/thing/qingyuan/manageboard/dto/GunDataParam.java
-
17modules/qingyuan/src/main/java/com/thing/qingyuan/manageboard/dto/GunReportParam.java
-
16modules/qingyuan/src/main/java/com/thing/qingyuan/manageboard/dto/MapParam.java
-
20modules/qingyuan/src/main/java/com/thing/qingyuan/manageboard/dto/PVParam.java
-
68modules/qingyuan/src/main/java/com/thing/qingyuan/manageboard/dto/PVReport.java
-
45modules/qingyuan/src/main/java/com/thing/qingyuan/manageboard/dto/PhotovoltaicDTO.java
-
38modules/qingyuan/src/main/java/com/thing/qingyuan/manageboard/dto/PhotovoltaicOverviewDTO.java
-
91modules/qingyuan/src/main/java/com/thing/qingyuan/manageboard/dto/PlantDTO.java
-
57modules/qingyuan/src/main/java/com/thing/qingyuan/manageboard/dto/PlantInfoReq.java
-
32modules/qingyuan/src/main/java/com/thing/qingyuan/manageboard/dto/PlantReq.java
@ -1,108 +0,0 @@ |
|||
//package com.thing.qingyuan.basedevice.controller; |
|||
// |
|||
//import com.thing.qingyuan.basedevice.dto.DeviceDTO; |
|||
//import com.thing.qingyuan.basedevice.service.IotDeviceService; |
|||
//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 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 jakarta.servlet.http.HttpServletResponse; |
|||
//import lombok.RequiredArgsConstructor; |
|||
//import org.springframework.web.bind.annotation.*; |
|||
// |
|||
//import java.util.List; |
|||
//import java.util.Map; |
|||
// |
|||
///** |
|||
// * 设备信息表 |
|||
// * |
|||
// * @author xc |
|||
// * @since 3.0 2024-01-30 |
|||
// */ |
|||
//@RestController |
|||
//@RequestMapping("v1/device/info") |
|||
//@Tag(name = "设备信息表") |
|||
//@RequiredArgsConstructor |
|||
//public class DeviceController { |
|||
// |
|||
// private final IotDeviceService iotDeviceService; |
|||
// |
|||
// @GetMapping("page") |
|||
// @Operation(summary = "分页") |
|||
// @Parameters({ |
|||
// @Parameter(name = Constant.PAGE, description = "当前页码,从1开始"), |
|||
// @Parameter(name = Constant.LIMIT, description = "每页显示记录数"), |
|||
// @Parameter(name = Constant.ORDER_FIELD, description = "排序字段"), |
|||
// @Parameter(name = Constant.ORDER, description = "排序方式,可选值(asc、desc)") |
|||
// }) |
|||
// public Result<PageData<DeviceDTO>> page(@RequestParam Map<String, Object> params) { |
|||
// PageData<DeviceDTO> page = iotDeviceService.getPageData(params, DeviceDTO.class); |
|||
// return new Result<PageData<DeviceDTO>>().ok(page); |
|||
// } |
|||
// |
|||
// @GetMapping("{id}") |
|||
// @Operation(summary = "信息") |
|||
// public Result<DeviceDTO> get(@PathVariable("id") Long id) { |
|||
// DeviceDTO data = iotDeviceService.getByIdAs(id, DeviceDTO.class); |
|||
// return new Result<DeviceDTO>().ok(data); |
|||
// } |
|||
// |
|||
// @PostMapping |
|||
// @Operation(summary = "保存") |
|||
// @LogOperation("保存") |
|||
// public Result<Void> save(@RequestBody DeviceDTO dto) { |
|||
// //效验数据 |
|||
// ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); |
|||
// iotDeviceService.saveDto(dto); |
|||
// return new Result<>(); |
|||
// } |
|||
// |
|||
// @PutMapping |
|||
// @Operation(summary = "修改") |
|||
// @LogOperation("修改") |
|||
// public Result<Void> update(@RequestBody DeviceDTO dto) { |
|||
// //效验数据 |
|||
// ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); |
|||
// iotDeviceService.updateDto(dto); |
|||
// return new Result<>(); |
|||
// } |
|||
// |
|||
// @DeleteMapping |
|||
// @Operation(summary = "删除") |
|||
// @LogOperation("删除") |
|||
// public Result<Void> delete(@RequestBody Long[] ids) { |
|||
// //效验数据 |
|||
// AssertUtils.isArrayEmpty(ids, "id"); |
|||
// iotDeviceService.batchDelete(ids); |
|||
// return new Result<>(); |
|||
// } |
|||
// |
|||
// @GetMapping("export") |
|||
// @Operation(summary = "导出") |
|||
// @LogOperation("导出") |
|||
// public void export(@RequestParam Map<String, Object> params, HttpServletResponse response) throws Exception { |
|||
// List<DeviceDTO> list = iotDeviceService.listAs(params, DeviceDTO.class); |
|||
// //ExcelUtils.exportExcelToTarget(response, null, "设备信息表", list, DeviceExcel.class); |
|||
// } |
|||
// |
|||
// @GetMapping("{plantId}/{type}") |
|||
// @Operation(summary = "根据电站id和类型查询 1.采集器\n" + |
|||
// "2.逆变器\n" + |
|||
// "3.电表\n" + |
|||
// "4.EPM\n" + |
|||
// "5.气象仪") |
|||
// public Result<List<DeviceDTO>> getDeviceByType(@PathVariable("plantId") Long plantId,@PathVariable("type") Integer type) { |
|||
// List<DeviceDTO> deviceDTOS = iotDeviceService.findByPlantId(plantId, type); |
|||
// return new Result<List<DeviceDTO>>().ok(deviceDTOS); |
|||
// } |
|||
// |
|||
//} |
|||
@ -1,61 +0,0 @@ |
|||
package com.thing.qingyuan.basedevice.dto; |
|||
|
|||
import io.swagger.v3.oas.annotations.media.Schema; |
|||
import lombok.Data; |
|||
|
|||
import java.io.Serial; |
|||
import java.io.Serializable; |
|||
|
|||
/** |
|||
* 设备信息表 |
|||
* |
|||
* @author xc |
|||
* @since 3.0 2024-01-30 |
|||
*/ |
|||
@Data |
|||
@Schema(name = "设备信息表") |
|||
public class DeviceDTO implements Serializable { |
|||
@Serial |
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
@Schema(description = "设备ID") |
|||
private String deviceId; |
|||
@Schema(description = "设备类型: 1.采集器 2.逆变器 3.电表 4.EPM 5.气象仪") |
|||
private Integer deviceType; |
|||
@Schema(description = "设备类型2: 与 productKey及deviceType2 关联") |
|||
private Integer deviceType2; |
|||
@Schema(description = "设备SN 逆变器sn") |
|||
private String deviceSn; |
|||
@Schema(description = "设备首次上电日期") |
|||
private String firstReportTime; |
|||
@Schema(description = "设备状态: 01.正常 02.离线 3.报警 4.故障 5.自定义报警 逆变器状态") |
|||
private Integer status; |
|||
@Schema(description = "产品代码 ") |
|||
private String productKey; |
|||
@Schema(description = "设备当前实时关联的电站ID") |
|||
private Long plantId; |
|||
@Schema(description = "设备最后上电日期") |
|||
private String lastReportTime; |
|||
@Schema(description = "设备上级连接父设备") |
|||
private Long upDeviceId; |
|||
@Schema(description = "记录创建时间") |
|||
private String createTime; |
|||
@Schema(description = "父设备sn 采集器sn") |
|||
private String upDeviceSn; |
|||
@Schema(description = "01.正常 02.离线 3.报警 4.故障 5.自定义报警 采集器状态 ") |
|||
private Integer upStatus; |
|||
@Schema(description = "01.正常 02.离线 3.报警 4.故障 5.自定义报警 采集器状态 ") |
|||
private String upAlias; |
|||
@Schema(description = "设备别名") |
|||
private String alias; |
|||
@Schema(description = "网络状态") |
|||
private String netWorkType="4G"; |
|||
/** |
|||
* 设备别名 |
|||
*/ |
|||
private Integer devcode; |
|||
/** |
|||
* 设备别名 |
|||
*/ |
|||
private Integer devaddr; |
|||
} |
|||
@ -1,88 +0,0 @@ |
|||
package com.thing.qingyuan.basedevice.entity; |
|||
|
|||
import com.mybatisflex.annotation.Table; |
|||
import lombok.Data; |
|||
import lombok.EqualsAndHashCode; |
|||
|
|||
import java.io.Serial; |
|||
import java.io.Serializable; |
|||
|
|||
/** |
|||
* 设备信息表 |
|||
* |
|||
* @author xc |
|||
* @since 3.0 2024-01-30 |
|||
*/ |
|||
@Data |
|||
@EqualsAndHashCode(callSuper = false) |
|||
@Table(value = "device",dataSource = "systemCollect") |
|||
public class DeviceEntity implements Serializable { |
|||
@Serial |
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
/** |
|||
* 设备ID |
|||
*/ |
|||
private String deviceId; |
|||
/** |
|||
* 设备类型: |
|||
* 1.采集器 |
|||
* 2.逆变器 |
|||
* 3.电表 |
|||
* 4.EPM |
|||
* 5.气象仪 |
|||
*/ |
|||
private Integer deviceType; |
|||
/** |
|||
* 设备类型2: 与 productKey及deviceType2 关联 |
|||
*/ |
|||
private Integer deviceType2; |
|||
/** |
|||
* 设备pn |
|||
*/ |
|||
private String devicePn; |
|||
/** |
|||
* 设备首次上电日期 |
|||
*/ |
|||
private String firstReportTime; |
|||
/** |
|||
* 设备状态: 01.正常 02.离线 3.报警 4.故障 5.自定义报警 |
|||
*/ |
|||
private Integer status; |
|||
/** |
|||
* 产品代码 |
|||
*/ |
|||
private String productKey; |
|||
/** |
|||
* 设备当前实时关联的电站ID |
|||
*/ |
|||
private Long plantId; |
|||
/** |
|||
* 设备最后上电日期 |
|||
*/ |
|||
private String lastReportTime; |
|||
/** |
|||
* 设备上级连接父设备 |
|||
*/ |
|||
private Long upDeviceId; |
|||
/** |
|||
* 记录创建时间 |
|||
*/ |
|||
private String createTime; |
|||
/** |
|||
* 父设备sn |
|||
*/ |
|||
private String upDeviceSn; |
|||
/** |
|||
* 设备别名 |
|||
*/ |
|||
private String alias; |
|||
/** |
|||
* 设备别名 |
|||
*/ |
|||
private Integer devcode; |
|||
/** |
|||
* 设备别名 |
|||
*/ |
|||
private Integer devaddr; |
|||
} |
|||
@ -1,46 +0,0 @@ |
|||
package com.thing.qingyuan.basedevice.excel; |
|||
|
|||
import com.alibaba.excel.annotation.ExcelProperty; |
|||
import com.alibaba.excel.annotation.write.style.ColumnWidth; |
|||
import com.alibaba.excel.annotation.write.style.ContentRowHeight; |
|||
import com.alibaba.excel.annotation.write.style.HeadRowHeight; |
|||
import lombok.Data; |
|||
|
|||
/** |
|||
* 设备信息表 |
|||
* |
|||
* @author xc |
|||
* @since 3.0 2024-01-30 |
|||
*/ |
|||
@Data |
|||
@ContentRowHeight(20) |
|||
@HeadRowHeight(20) |
|||
@ColumnWidth(25) |
|||
public class DeviceExcel { |
|||
@ExcelProperty(value = "设备ID", index = 0) |
|||
private Long deviceId; |
|||
@ExcelProperty(value = "设备类型:1.采集器2.逆变器3.电表4.EPM5.气象仪", index = 1) |
|||
private Integer deviceType; |
|||
@ExcelProperty(value = "设备类型2: 与 productKey及deviceType2 关联", index = 2) |
|||
private Integer deviceType2; |
|||
@ExcelProperty(value = "设备SN", index = 3) |
|||
private String deviceSn; |
|||
@ExcelProperty(value = "设备首次上电日期", index = 4) |
|||
private String firstReportTime; |
|||
@ExcelProperty(value = "设备状态: 01.正常 02.离线 3.报警 4.故障 5.自定义报警", index = 5) |
|||
private Integer status; |
|||
@ExcelProperty(value = "产品代码 ", index = 6) |
|||
private String productKey; |
|||
@ExcelProperty(value = "设备当前实时关联的电站ID", index = 7) |
|||
private Long plantId; |
|||
@ExcelProperty(value = "设备最后上电日期", index = 8) |
|||
private String lastReportTime; |
|||
@ExcelProperty(value = "设备上级连接父设备", index = 9) |
|||
private Long upDeviceId; |
|||
@ExcelProperty(value = "记录创建时间", index = 10) |
|||
private String createTime; |
|||
@ExcelProperty(value = "父设备sn", index = 11) |
|||
private String upDeviceSn; |
|||
@ExcelProperty(value = "设备别名", index = 12) |
|||
private String alias; |
|||
} |
|||
@ -1,18 +0,0 @@ |
|||
package com.thing.qingyuan.basedevice.mapper; |
|||
|
|||
import com.mybatisflex.annotation.UseDataSource; |
|||
import com.thing.qingyuan.basedevice.entity.DeviceEntity; |
|||
import com.thing.common.orm.mapper.PowerBaseMapper; |
|||
import org.apache.ibatis.annotations.Mapper; |
|||
|
|||
/** |
|||
* 设备信息表 |
|||
* |
|||
* @author xc |
|||
* @since 3.0 2024-01-30 |
|||
*/ |
|||
@Mapper |
|||
@UseDataSource("systemCollect") |
|||
public interface DeviceMapper extends PowerBaseMapper<DeviceEntity> { |
|||
|
|||
} |
|||
@ -1,18 +0,0 @@ |
|||
package com.thing.qingyuan.basedevice.service; |
|||
|
|||
import com.thing.qingyuan.basedevice.dto.DeviceDTO; |
|||
import com.thing.qingyuan.basedevice.entity.DeviceEntity; |
|||
import com.thing.common.orm.service.IBaseService; |
|||
|
|||
import java.util.List; |
|||
|
|||
/** |
|||
* 设备信息表 |
|||
* |
|||
* @author xc |
|||
* @since 3.0 2024-01-30 |
|||
*/ |
|||
public interface IotDeviceService extends IBaseService<DeviceEntity> { |
|||
List<DeviceDTO> findByPlantId(Long plantId,Integer type); |
|||
|
|||
} |
|||
@ -1,36 +0,0 @@ |
|||
package com.thing.qingyuan.basedevice.service.impl; |
|||
|
|||
import cn.hutool.core.util.ObjectUtil; |
|||
import com.mybatisflex.core.query.QueryWrapper; |
|||
import com.thing.qingyuan.basedevice.dto.DeviceDTO; |
|||
import com.thing.qingyuan.basedevice.entity.DeviceEntity; |
|||
import com.thing.qingyuan.basedevice.mapper.DeviceMapper; |
|||
import com.thing.qingyuan.basedevice.service.IotDeviceService; |
|||
import com.thing.common.orm.service.impl.BaseServiceImpl; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
/** |
|||
* 设备信息表 |
|||
* |
|||
* @author xc |
|||
* @since 3.0 2024-01-30 |
|||
*/ |
|||
@Service("IotDeviceServiceImpl") |
|||
public class IotDeviceServiceImpl extends BaseServiceImpl<DeviceMapper, DeviceEntity> implements IotDeviceService { |
|||
|
|||
@Override |
|||
public QueryWrapper getWrapper(Map<String, Object> params) { |
|||
QueryWrapper wrapper = new QueryWrapper(); |
|||
return wrapper; |
|||
} |
|||
|
|||
|
|||
@Override |
|||
public List<DeviceDTO> findByPlantId(Long plantId,Integer type) { |
|||
QueryWrapper queryWrapper = QueryWrapper.create().eq(DeviceEntity::getPlantId, plantId).eq(DeviceEntity::getDeviceType,type, ObjectUtil::isNotNull); |
|||
return mapper.selectListByQueryAs(queryWrapper,DeviceDTO.class); |
|||
} |
|||
} |
|||
@ -1,72 +0,0 @@ |
|||
package com.thing.qingyuan.carbon.controller; |
|||
|
|||
|
|||
import com.thing.common.core.constants.Constant; |
|||
import com.thing.common.core.web.response.PageData; |
|||
import com.thing.common.core.web.response.Result; |
|||
import com.thing.qingyuan.carbon.dto.QyCarbonAssetDTO; |
|||
import com.thing.qingyuan.carbon.service.QyCarbonAssetService; |
|||
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.GetMapping; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RequestParam; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
|
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
@RestController |
|||
@RequestMapping("v2/carbon/asset") |
|||
@Tag(name = "碳资产") |
|||
@RequiredArgsConstructor |
|||
public class QyCarbonAssetController { |
|||
|
|||
private final QyCarbonAssetService qyCarbonAssetService; |
|||
|
|||
/** |
|||
* 计算当前碳资产,包括碳配额,CCER,绿证 |
|||
* @return 返回一个Map |
|||
*/ |
|||
@GetMapping("percent") |
|||
@Operation(summary = "统计当前碳资产占比") |
|||
public Result<Map<String, String>> getCarbonAssetPercentages() { |
|||
Map<String, String> resultMap = qyCarbonAssetService.countCarbonAsset(); |
|||
return new Result<Map<String, String>>().ok(resultMap); |
|||
} |
|||
|
|||
/** |
|||
* 统计近几个月的碳资产 |
|||
* @return 返回一个map |
|||
*/ |
|||
@GetMapping("trend") |
|||
@Operation(summary = "统计进几个月的碳资产") |
|||
public Result<List<QyCarbonAssetDTO>> recentMonths(@RequestParam("startTime") Long startTime, |
|||
@RequestParam("endTime") Long endTime) { |
|||
List<QyCarbonAssetDTO> assetList = qyCarbonAssetService.countRecentCarbonAsset(startTime,endTime); |
|||
return new Result<List<QyCarbonAssetDTO>>().ok(assetList); |
|||
} |
|||
|
|||
/** |
|||
* 获取碳资产对应标签的单价,数量,余额,账户总余额 |
|||
* @return 返回一个Map |
|||
*/ |
|||
@GetMapping("page") |
|||
@Parameters({ |
|||
@Parameter(name = Constant.PAGE, description = "当前页码,从1开始", required = true) , |
|||
@Parameter(name = Constant.LIMIT, description = "每页显示记录数", required = true) , |
|||
@Parameter(name = "state", description = "状态", required = true) , |
|||
@Parameter(name = Constant.ORDER_FIELD, description = "排序字段") , |
|||
@Parameter(name = Constant.ORDER, description = "排序方式,可选值(asc、desc)") |
|||
}) |
|||
@Operation(summary = "分页获取碳资产对应标签的单价,数量,余额,账户总余额") |
|||
public Result<PageData<QyCarbonAssetDTO>> calculateAsset(@Parameter(hidden = true) @RequestParam Map<String, Object> params) { |
|||
PageData<QyCarbonAssetDTO> unitPrice = qyCarbonAssetService.calculateAsset(params); |
|||
return new Result<PageData<QyCarbonAssetDTO>>().ok(unitPrice); |
|||
} |
|||
|
|||
|
|||
} |
|||
@ -1,107 +0,0 @@ |
|||
package com.thing.qingyuan.carbon.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.qingyuan.carbon.dto.QyCarbonQuotaInfoDTO; |
|||
import com.thing.qingyuan.carbon.service.QyCarbonQuotaInfoService; |
|||
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.List; |
|||
import java.util.Map; |
|||
|
|||
@RestController |
|||
@RequestMapping("v2/quota") |
|||
@Tag(name="碳配额信息总览") |
|||
@RequiredArgsConstructor |
|||
public class QyCarbonQuotaInfoController { |
|||
|
|||
private final QyCarbonQuotaInfoService qyCarbonQuotaInfoService; |
|||
|
|||
@GetMapping("page") |
|||
@Operation(summary="分页") |
|||
@Parameters({ |
|||
@Parameter(name = Constant.PAGE, description = "当前页码,从1开始", required = true) , |
|||
@Parameter(name = Constant.LIMIT, description = "每页显示记录数", required = true) , |
|||
@Parameter(name = "state", description = "状态", required = true) , |
|||
@Parameter(name = Constant.ORDER_FIELD, description = "排序字段") , |
|||
@Parameter(name = Constant.ORDER, description = "排序方式,可选值(asc、desc)") |
|||
}) |
|||
public Result<PageData<QyCarbonQuotaInfoDTO>> page(@Parameter(hidden = true) @RequestParam Map<String, Object> params){ |
|||
PageData<QyCarbonQuotaInfoDTO> pageData = qyCarbonQuotaInfoService.getPageData(params, QyCarbonQuotaInfoDTO.class); |
|||
return new Result<PageData<QyCarbonQuotaInfoDTO>>().ok(pageData); |
|||
} |
|||
|
|||
@GetMapping("{id}") |
|||
@Operation(summary="信息") |
|||
public Result<QyCarbonQuotaInfoDTO> get(@PathVariable("id") Long id){ |
|||
QyCarbonQuotaInfoDTO data = qyCarbonQuotaInfoService.getByIdAs(id, QyCarbonQuotaInfoDTO.class); |
|||
return new Result<QyCarbonQuotaInfoDTO>().ok(data); |
|||
} |
|||
|
|||
@PostMapping |
|||
@Operation(summary="保存") |
|||
@LogOperation("保存") |
|||
public Result<Void> save(@RequestBody QyCarbonQuotaInfoDTO dto){ |
|||
//效验数据 |
|||
ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); |
|||
qyCarbonQuotaInfoService.saveDto(dto); |
|||
return new Result<>(); |
|||
} |
|||
|
|||
@PutMapping |
|||
@Operation(summary="修改") |
|||
@LogOperation("修改") |
|||
public Result<Void> update(@RequestBody QyCarbonQuotaInfoDTO dto){ |
|||
//效验数据 |
|||
ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); |
|||
qyCarbonQuotaInfoService.updateDto(dto); |
|||
return new Result<>(); |
|||
} |
|||
|
|||
@DeleteMapping |
|||
@Operation(summary="删除") |
|||
@LogOperation("删除") |
|||
public Result<Void> delete(@RequestBody Long[] ids){ |
|||
//效验数据 |
|||
AssertUtils.isArrayEmpty(ids, "id"); |
|||
qyCarbonQuotaInfoService.batchDelete(ids); |
|||
return new Result<>(); |
|||
} |
|||
|
|||
|
|||
/** |
|||
* 统计当前碳配额总和和三种状态所占百分比 |
|||
* @return 返回一个map |
|||
*/ |
|||
@GetMapping("state") |
|||
@Operation(summary = "获取碳配额状态统计和百分比") |
|||
public Result<Map<String, String>> getCarbonQuotaStatisticsWithStatePercentage() { |
|||
Map<String, String> statisticsWithPercentage = qyCarbonQuotaInfoService.getCarbonQuotaStatisticsWithStatePercentage(); |
|||
return new Result<Map<String, String>>().ok(statisticsWithPercentage); |
|||
} |
|||
|
|||
/** |
|||
* 获取区域减排量占比 |
|||
* @return 返回一个Map,键为区域名称,值为该区域减排量占总碳配额的百分比 |
|||
*/ |
|||
@GetMapping("region") |
|||
@Operation(summary = "获取区域减排量占比") |
|||
public Result<List<Map<String, String>>>getEmissionReductionPercentages() { |
|||
List<Map<String, String>> percentage = qyCarbonQuotaInfoService.getEmissionReductionPercentagesByState(); |
|||
return new Result<List<Map<String, String>>>().ok(percentage); |
|||
} |
|||
|
|||
|
|||
} |
|||
@ -1,111 +0,0 @@ |
|||
package com.thing.qingyuan.carbon.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.qingyuan.carbon.dto.QyCcerInfoDTO; |
|||
import com.thing.qingyuan.carbon.service.QyCcerInfoService; |
|||
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.List; |
|||
import java.util.Map; |
|||
|
|||
/** |
|||
* CCER信息总览 |
|||
* |
|||
* @author xc |
|||
* @since 3.0 2025-02-17 |
|||
*/ |
|||
@RestController |
|||
@RequestMapping("v2/ccer") |
|||
@Tag(name="CCER信息总览") |
|||
@RequiredArgsConstructor |
|||
public class QyCcerInfoController { |
|||
|
|||
private final QyCcerInfoService qyCcerInfoService; |
|||
|
|||
@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<PageData<QyCcerInfoDTO>> page(@Parameter(hidden = true) @RequestParam Map<String, Object> params){ |
|||
PageData<QyCcerInfoDTO> page = qyCcerInfoService.getPageData(params, QyCcerInfoDTO.class); |
|||
return new Result<PageData<QyCcerInfoDTO>>().ok(page); |
|||
} |
|||
|
|||
@GetMapping("{id}") |
|||
@Operation(summary="信息") |
|||
public Result<QyCcerInfoDTO> get(@PathVariable("id") Long id){ |
|||
QyCcerInfoDTO data = qyCcerInfoService.getByIdAs(id, QyCcerInfoDTO.class); |
|||
return new Result<QyCcerInfoDTO>().ok(data); |
|||
} |
|||
|
|||
@PostMapping |
|||
@Operation(summary="保存") |
|||
@LogOperation("保存") |
|||
public Result<Void> save(@RequestBody QyCcerInfoDTO dto){ |
|||
//效验数据 |
|||
ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); |
|||
qyCcerInfoService.saveDto(dto); |
|||
return new Result<>(); |
|||
} |
|||
|
|||
@PutMapping |
|||
@Operation(summary="修改") |
|||
@LogOperation("修改") |
|||
public Result<Void> update(@RequestBody QyCcerInfoDTO dto){ |
|||
//效验数据 |
|||
ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); |
|||
qyCcerInfoService.updateDto(dto); |
|||
return new Result<>(); |
|||
} |
|||
|
|||
@DeleteMapping |
|||
@Operation(summary="删除") |
|||
@LogOperation("删除") |
|||
public Result<Void> delete(@RequestBody Long[] ids){ |
|||
//效验数据 |
|||
AssertUtils.isArrayEmpty(ids, "id"); |
|||
qyCcerInfoService.batchDelete(ids); |
|||
return new Result<>(); |
|||
} |
|||
|
|||
/** |
|||
* 获取根据状态统计的CCER数量 |
|||
* @return 各状态的CCER数量 |
|||
*/ |
|||
@GetMapping("state") |
|||
@Operation(summary = "根据状态统计CCER数量", description = "待申请、已申请状态的CCER数量") |
|||
public Result<Map<String, String>> countCcerByState() { |
|||
Map<String, String> countResult = qyCcerInfoService.countCcerByState(); |
|||
return new Result<Map<String, String>>().ok(countResult); |
|||
} |
|||
|
|||
/** |
|||
* 根据区域与小区统计成交量,并计算每个小镇在所属区域内的成交量占比 |
|||
* @return 返回一个List,包含每个区域下每个小镇的成交量占比 |
|||
*/ |
|||
@GetMapping("region") |
|||
@Operation(summary = "获取区域减排量占比") |
|||
@Parameter(name = "region", description = "区域名称") |
|||
public Result<List<Map<String, String>>>getEmissionReductionPercentages() { |
|||
List<Map<String, String>> percentage = qyCcerInfoService.getByRegion(); |
|||
return new Result<List<Map<String, String>>>().ok(percentage); |
|||
} |
|||
|
|||
} |
|||
@ -1,105 +0,0 @@ |
|||
package com.thing.qingyuan.carbon.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.UpdateGroup; |
|||
import com.thing.common.core.web.response.PageData; |
|||
import com.thing.common.core.web.response.Result; |
|||
import com.thing.qingyuan.carbon.dto.QyGreenCertificateInfoDTO; |
|||
import com.thing.qingyuan.carbon.service.QyGreenCertificateInfoService; |
|||
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 jakarta.validation.groups.Default; |
|||
import lombok.RequiredArgsConstructor; |
|||
import org.springframework.web.bind.annotation.*; |
|||
|
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
@RestController |
|||
@RequestMapping("v2/green") |
|||
@Tag(name = "绿证信息总览") |
|||
@RequiredArgsConstructor |
|||
public class QyGreenCertificateInfoController { |
|||
|
|||
private final QyGreenCertificateInfoService qyGreenCertificateInfoService; |
|||
|
|||
@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<PageData<QyGreenCertificateInfoDTO>> page(@Parameter(hidden = true) @RequestParam Map<String, Object> params) { |
|||
PageData<QyGreenCertificateInfoDTO> page = qyGreenCertificateInfoService.getPageData(params, QyGreenCertificateInfoDTO.class); |
|||
return new Result<PageData<QyGreenCertificateInfoDTO>>().ok(page); |
|||
} |
|||
|
|||
@GetMapping("{id}") |
|||
@Operation(summary = "信息") |
|||
public Result<QyGreenCertificateInfoDTO> info(@PathVariable("id") Long id) { |
|||
QyGreenCertificateInfoDTO data = qyGreenCertificateInfoService.getByIdAs(id, QyGreenCertificateInfoDTO.class); |
|||
return new Result<QyGreenCertificateInfoDTO>().ok(data); |
|||
} |
|||
|
|||
@PostMapping() |
|||
@Operation(summary = "保存") |
|||
@LogOperation("保存") |
|||
public Result<Void> save(@RequestBody QyGreenCertificateInfoDTO dto) { |
|||
//校验数据 |
|||
ValidatorUtils.validateEntity(dto, AddGroup.class, Default.class); |
|||
qyGreenCertificateInfoService.saveDto(dto); |
|||
return new Result<>(); |
|||
} |
|||
|
|||
@PutMapping() |
|||
@Operation(summary = "修改") |
|||
@LogOperation("修改") |
|||
public Result<Void> update(@RequestBody QyGreenCertificateInfoDTO dto) { |
|||
//校验数据 |
|||
ValidatorUtils.validateEntity(dto, UpdateGroup.class, Default.class); |
|||
qyGreenCertificateInfoService.updateDto(dto); |
|||
return new Result<>(); |
|||
} |
|||
|
|||
@DeleteMapping() |
|||
@Operation(summary = "删除") |
|||
@LogOperation("删除") |
|||
public Result<Void> delete(@RequestBody Long[] ids) { |
|||
//校验数据 |
|||
AssertUtils.isArrayEmpty(ids, "id"); |
|||
qyGreenCertificateInfoService.batchDelete(ids); |
|||
return new Result<>(); |
|||
} |
|||
|
|||
|
|||
/** |
|||
* 获取根据状态统计的绿证数量 |
|||
* @return 各状态的绿证数量 |
|||
*/ |
|||
@GetMapping("state") |
|||
@Operation(summary = "根据状态统计绿证数量", description = "待发放、已申请状态的CCER数量") |
|||
public Result<Map<String, String>> countGreenByState() { |
|||
Map<String, String> countResult = qyGreenCertificateInfoService.countGreenByState(); |
|||
return new Result<Map<String, String>>().ok(countResult); |
|||
} |
|||
|
|||
/** |
|||
* 根据区域与绿证能源总量,并计算每个小镇在所属区域内的绿证占比 |
|||
* @return 返回一个List,包含每个区域下每个小镇的绿证占比 |
|||
*/ |
|||
@GetMapping("region") |
|||
@Operation(summary = "获取区域绿证占比") |
|||
public Result<List<Map<String, String>>> getRegionGreenCertificatePercentage() { |
|||
List<Map<String, String>> percentage = qyGreenCertificateInfoService.getRegionGreenCertificatePercentage(); |
|||
return new Result<List<Map<String, String>>>().ok(percentage); |
|||
} |
|||
|
|||
} |
|||
@ -1,87 +0,0 @@ |
|||
package com.thing.qingyuan.carbon.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.qingyuan.carbon.dto.QyRegionDTO; |
|||
import com.thing.qingyuan.carbon.service.QyRegionService; |
|||
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 xc |
|||
* @since 3.0 2025-02-12 |
|||
*/ |
|||
@RestController |
|||
@RequestMapping("v2/qyregion") |
|||
@Tag(name="区域列表") |
|||
@RequiredArgsConstructor |
|||
public class QyRegionController { |
|||
|
|||
private final QyRegionService qyRegionService; |
|||
|
|||
@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<PageData<QyRegionDTO>> page(@Parameter(hidden = true) @RequestParam Map<String, Object> params){ |
|||
PageData<QyRegionDTO> page = qyRegionService.getPageData(params, QyRegionDTO.class); |
|||
return new Result<PageData<QyRegionDTO>>().ok(page); |
|||
} |
|||
|
|||
@GetMapping("{id}") |
|||
@Operation(summary="信息") |
|||
public Result<QyRegionDTO> get(@PathVariable("id") Long id){ |
|||
QyRegionDTO data = qyRegionService.getByIdAs(id, QyRegionDTO.class); |
|||
return new Result<QyRegionDTO>().ok(data); |
|||
} |
|||
|
|||
@PostMapping |
|||
@Operation(summary="保存") |
|||
@LogOperation("保存") |
|||
public Result<Void> save(@RequestBody QyRegionDTO dto){ |
|||
//效验数据 |
|||
ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); |
|||
qyRegionService.saveDto(dto); |
|||
return new Result<>(); |
|||
} |
|||
|
|||
@PutMapping |
|||
@Operation(summary="修改") |
|||
@LogOperation("修改") |
|||
public Result<Void> update(@RequestBody QyRegionDTO dto){ |
|||
//效验数据 |
|||
ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); |
|||
qyRegionService.updateDto(dto); |
|||
return new Result<>(); |
|||
} |
|||
|
|||
@DeleteMapping |
|||
@Operation(summary="删除") |
|||
@LogOperation("删除") |
|||
public Result<Void> delete(@RequestBody Long[] ids){ |
|||
//效验数据 |
|||
AssertUtils.isArrayEmpty(ids, "id"); |
|||
qyRegionService.batchDelete(ids); |
|||
return new Result<>(); |
|||
} |
|||
|
|||
} |
|||
@ -1,53 +0,0 @@ |
|||
package com.thing.qingyuan.carbon.dto; |
|||
|
|||
import io.swagger.v3.oas.annotations.media.Schema; |
|||
import lombok.Data; |
|||
|
|||
import java.io.Serial; |
|||
import java.io.Serializable; |
|||
import java.math.BigDecimal; |
|||
|
|||
@Data |
|||
@Schema(description = "碳资产") |
|||
public class QyCarbonAssetDTO implements Serializable { |
|||
|
|||
@Serial |
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
@Schema(description = "交易时间") |
|||
private Long issueDate; |
|||
@Schema(description = "碳资产标签") |
|||
private String tag; |
|||
@Schema(description = "单价") |
|||
private BigDecimal unitPrice= BigDecimal.ZERO; |
|||
@Schema(description = "数量") |
|||
private BigDecimal total= BigDecimal.ZERO; |
|||
@Schema(description = "价格") |
|||
private BigDecimal price= BigDecimal.ZERO; |
|||
@Schema(description = "账户余额") |
|||
private BigDecimal balance= BigDecimal.ZERO; |
|||
@Schema(description = "交易性质(碳资产状态:1.待发 2.已发 3.买入 4.核销 5.卖出) ") |
|||
private String state; |
|||
@Schema(description = "买入") |
|||
private BigDecimal buy= BigDecimal.ZERO; |
|||
@Schema(description = "卖出") |
|||
private BigDecimal sell= BigDecimal.ZERO; |
|||
@Schema(description = "卖出") |
|||
private BigDecimal off= BigDecimal.ZERO; |
|||
|
|||
public QyCarbonAssetDTO() { |
|||
} |
|||
|
|||
public QyCarbonAssetDTO(Long issueDate, BigDecimal total, String state) { |
|||
this.issueDate = issueDate; |
|||
this.total = total; |
|||
this.state = state; |
|||
} |
|||
|
|||
public QyCarbonAssetDTO(Long issueDate, BigDecimal total, String state, BigDecimal balance) { |
|||
this.issueDate = issueDate; |
|||
this.total = total; |
|||
this.state = state; |
|||
this.balance = balance; |
|||
} |
|||
} |
|||
@ -1,67 +0,0 @@ |
|||
package com.thing.qingyuan.carbon.dto; |
|||
|
|||
import io.swagger.v3.oas.annotations.media.Schema; |
|||
import lombok.Data; |
|||
|
|||
import java.io.Serial; |
|||
import java.io.Serializable; |
|||
import java.math.BigDecimal; |
|||
|
|||
/** |
|||
* 碳配额信息总览 |
|||
* |
|||
* @author xc |
|||
* @since 3.0 2025-02-14 |
|||
*/ |
|||
@Data |
|||
@Schema(description = "碳配额信息总览") |
|||
public class QyCarbonQuotaInfoDTO implements Serializable { |
|||
@Serial |
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
@Schema(description = "主键") |
|||
private Long id; |
|||
@Schema(description = "碳配额状态:1.待发放碳配额(tCO2) 2.已发放碳配额(tCO2)3.买入 4.核销 5.卖出") |
|||
private String state; |
|||
@Schema(description = "项目名称") |
|||
private String name; |
|||
@Schema(description = "项目编号") |
|||
private String code; |
|||
@Schema(description = "认证周期") |
|||
private String certificationCycle; |
|||
@Schema(description = "认证时间段") |
|||
private String certificationTime; |
|||
@Schema(description = "认证完成日期") |
|||
private Long certificationFinishDate; |
|||
@Schema(description = "区域") |
|||
private String region; |
|||
@Schema(description = "所属企业") |
|||
private String company; |
|||
@Schema(description = "发放日期/核销日期") |
|||
private Long issueDate; |
|||
@Schema(description = "碳配额/tCO2") |
|||
private BigDecimal total; |
|||
@Schema(description = "创建者") |
|||
private Long creator; |
|||
@Schema(description = "创建时间") |
|||
private Long createDate; |
|||
@Schema(description = "更新者") |
|||
private Long updater; |
|||
@Schema(description = "更新时间") |
|||
private Long updateDate; |
|||
@Schema(description = "租户编码") |
|||
private Long tenantCode; |
|||
@Schema(description = "公司id") |
|||
private Long companyId; |
|||
@Schema(description = "部门id") |
|||
private Long deptId; |
|||
@Schema(description = "价格") |
|||
private BigDecimal price; |
|||
@Schema(description = "所属标签") |
|||
private String tag="碳配额"; |
|||
public String getTag() { |
|||
// 确保tag永远有默认值,如果为null或 "",则返回 "碳配额" |
|||
return tag == null || tag.isEmpty() ? "碳配额" : tag; |
|||
} |
|||
|
|||
} |
|||
@ -1,28 +0,0 @@ |
|||
package com.thing.qingyuan.carbon.dto; |
|||
|
|||
import io.swagger.v3.oas.annotations.media.Schema; |
|||
import lombok.Data; |
|||
|
|||
import java.io.Serial; |
|||
import java.io.Serializable; |
|||
import java.math.BigDecimal; |
|||
|
|||
/** |
|||
* 区域碳配额统计信息 |
|||
* |
|||
* @author xc |
|||
* @since 3.0 2025-02-14 |
|||
*/ |
|||
@Data |
|||
@Schema(description = "区域碳配额统计信息") |
|||
public class QyCarbonSumQuotaInfoDTO implements Serializable { |
|||
@Serial |
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
@Schema(description = "区域") |
|||
private String region; |
|||
@Schema(description = "统计") |
|||
private BigDecimal total; |
|||
@Schema(description = "状态") |
|||
private String state; |
|||
} |
|||
@ -1,63 +0,0 @@ |
|||
package com.thing.qingyuan.carbon.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.time.LocalDate; |
|||
|
|||
/** |
|||
* CCER信息总览 |
|||
* |
|||
* @author xc |
|||
* @since 3.0 2025-02-17 |
|||
*/ |
|||
@Data |
|||
@Schema(description = "CCER信息总览") |
|||
public class QyCcerInfoDTO implements Serializable { |
|||
@Serial |
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
@Schema(description = "主键") |
|||
private Long id; |
|||
@Schema(description = "CCER状态:1.待申请CCER(tCO2) 2.已申请CCER(tCO2)3.买入 4.核销 5.卖出") |
|||
private String state; |
|||
@Schema(description = "项目名称") |
|||
private String name; |
|||
@Schema(description = "所属企业") |
|||
private String company; |
|||
@Schema(description = "所属区域") |
|||
private String region; |
|||
@Schema(description = "第一次减排量备案") |
|||
private String firstEmission; |
|||
@Schema(description = "备案减排量") |
|||
private BigDecimal total; |
|||
@Schema(description = "减排量时间/核销日期") |
|||
private Long issueDate; |
|||
@Schema(description = "核证机构") |
|||
private String certificationAuthority; |
|||
@Schema(description = "价格") |
|||
private BigDecimal price; |
|||
@Schema(description = "创建者") |
|||
private Long creator; |
|||
@Schema(description = "创建时间") |
|||
private Long createDate; |
|||
@Schema(description = "更新者") |
|||
private Long updater; |
|||
@Schema(description = "更新时间") |
|||
private Long updateDate; |
|||
@Schema(description = "租户编码") |
|||
private Long tenantCode; |
|||
@Schema(description = "公司id") |
|||
private Long companyId; |
|||
@Schema(description = "部门id") |
|||
private Long deptId; |
|||
@Schema(description = "所属标签") |
|||
private String tag="CCER"; |
|||
public String getTag() { |
|||
// 确保tag永远有默认值,如果为null或 "",则返回 "CCER" |
|||
return tag == null || tag.isEmpty() ? "CCER" : tag; |
|||
} |
|||
} |
|||
@ -1,63 +0,0 @@ |
|||
package com.thing.qingyuan.carbon.dto; |
|||
|
|||
import io.swagger.v3.oas.annotations.media.Schema; |
|||
import lombok.Data; |
|||
|
|||
import java.io.Serial; |
|||
import java.io.Serializable; |
|||
import java.math.BigDecimal; |
|||
|
|||
/** |
|||
* 绿证信息总览 |
|||
* |
|||
* @author xc |
|||
* @since 3.0 2025-02-17 |
|||
*/ |
|||
@Data |
|||
@Schema(description = "绿证信息总览") |
|||
public class QyGreenCertificateInfoDTO implements Serializable { |
|||
@Serial |
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
@Schema(description = "主键") |
|||
private Long id; |
|||
@Schema(description = "绿证状态:1.待发放绿证(MWH) 2.已申请绿证(MWH)3.买入 4.核销 5.卖出") |
|||
private String state; |
|||
@Schema(description = "发电类型") |
|||
private String powerType; |
|||
@Schema(description = "申请日期") |
|||
private Long applicationDate; |
|||
@Schema(description = "核发日期/核销日期") |
|||
private Long issueDate; |
|||
@Schema(description = "绿证能源总量") |
|||
private BigDecimal total; |
|||
@Schema(description = "绿证证书代码") |
|||
private String code; |
|||
@Schema(description = "创建者") |
|||
private Long creator; |
|||
@Schema(description = "创建时间") |
|||
private Long createDate; |
|||
@Schema(description = "更新者") |
|||
private Long updater; |
|||
@Schema(description = "更新时间") |
|||
private Long updateDate; |
|||
@Schema(description = "租户编码") |
|||
private String tenantCode; |
|||
@Schema(description = "公司id") |
|||
private Long companyId; |
|||
@Schema(description = "部门id") |
|||
private Long deptId; |
|||
@Schema(description = "区域") |
|||
private String region; |
|||
@Schema(description = "所属企业") |
|||
private String company; |
|||
@Schema(description = "绿证价格") |
|||
private BigDecimal price; |
|||
@Schema(description = "所属标签") |
|||
private String tag="绿证"; |
|||
public String getTag() { |
|||
// 确保tag永远有默认值,如果为null或 "",则返回 "绿证" |
|||
return tag == null || tag.isEmpty() ? "绿证" : tag; |
|||
} |
|||
|
|||
} |
|||
@ -1,38 +0,0 @@ |
|||
package com.thing.qingyuan.carbon.dto; |
|||
|
|||
import io.swagger.v3.oas.annotations.media.Schema; |
|||
import lombok.Data; |
|||
|
|||
import java.io.Serial; |
|||
import java.io.Serializable; |
|||
|
|||
/** |
|||
* 区域列表 |
|||
* |
|||
* @author xc |
|||
* @since 3.0 2025-02-12 |
|||
*/ |
|||
@Data |
|||
@Schema(description = "区域列表") |
|||
public class QyRegionDTO implements Serializable { |
|||
@Serial |
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
@Schema(description = "主键") |
|||
private Long id; |
|||
@Schema(description = "区域名称") |
|||
private String name; |
|||
@Schema(description = "创建者") |
|||
private Long creator; |
|||
@Schema(description = "创建时间") |
|||
private Long createDate; |
|||
@Schema(description = "更新者") |
|||
private Long updater; |
|||
@Schema(description = "更新时间") |
|||
private Long updateDate; |
|||
|
|||
public QyRegionDTO(Long id, String name) { |
|||
this.id = id; |
|||
this.name = name; |
|||
} |
|||
} |
|||
@ -1,76 +0,0 @@ |
|||
package com.thing.qingyuan.carbon.entity; |
|||
|
|||
import com.mybatisflex.annotation.Table; |
|||
import com.thing.common.orm.entity.BaseInfoEntity; |
|||
import lombok.Data; |
|||
import lombok.EqualsAndHashCode; |
|||
import lombok.experimental.Accessors; |
|||
|
|||
import java.io.Serial; |
|||
import java.io.Serializable; |
|||
import java.math.BigDecimal; |
|||
|
|||
/** |
|||
* 碳配额信息总览 |
|||
* |
|||
* @author xc |
|||
* @since 3.0 2025-02-14 |
|||
*/ |
|||
@Data |
|||
@Accessors(chain = true) |
|||
@EqualsAndHashCode(callSuper=false) |
|||
@Table("qy_carbon_quota_info") |
|||
public class QyCarbonQuotaInfoEntity extends BaseInfoEntity implements Serializable { |
|||
@Serial |
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
/** |
|||
* 碳配额状态:1.待发放碳配额(tCO2) 2.已发放碳配额(tCO2)3.买入 4.核销 5.卖出 |
|||
*/ |
|||
private String state; |
|||
/** |
|||
* 项目名称 |
|||
*/ |
|||
private String name; |
|||
/** |
|||
* 项目编号 |
|||
*/ |
|||
private String code; |
|||
/** |
|||
* 认证周期 |
|||
*/ |
|||
private String certificationCycle; |
|||
/** |
|||
* 认证时间段 |
|||
*/ |
|||
private String certificationTime; |
|||
/** |
|||
* 认证完成日期 |
|||
*/ |
|||
private Long certificationFinishDate; |
|||
/** |
|||
* 区域 |
|||
*/ |
|||
private String region; |
|||
/** |
|||
* 所属企业 |
|||
*/ |
|||
private String company; |
|||
/** |
|||
* 发放日期 |
|||
*/ |
|||
private Long issueDate; |
|||
/** |
|||
* 碳配额/tCO2 |
|||
*/ |
|||
private BigDecimal total; |
|||
|
|||
/** |
|||
* 价格 |
|||
*/ |
|||
private BigDecimal price; |
|||
|
|||
private String tag; |
|||
|
|||
|
|||
} |
|||
@ -1,75 +0,0 @@ |
|||
package com.thing.qingyuan.carbon.entity; |
|||
|
|||
import com.mybatisflex.annotation.Table; |
|||
import com.thing.common.orm.entity.BaseInfoEntity; |
|||
import lombok.Data; |
|||
import lombok.EqualsAndHashCode; |
|||
import lombok.experimental.Accessors; |
|||
|
|||
import java.io.Serial; |
|||
import java.io.Serializable; |
|||
import java.math.BigDecimal; |
|||
|
|||
/** |
|||
* CCER信息总览 |
|||
* |
|||
* @author xc |
|||
* @since 3.0 2025-02-17 |
|||
*/ |
|||
@Data |
|||
@Accessors(chain = true) |
|||
@EqualsAndHashCode(callSuper=false) |
|||
@Table("qy_ccer_info") |
|||
public class QyCcerInfoEntity extends BaseInfoEntity implements Serializable { |
|||
@Serial |
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
|
|||
/** |
|||
* CCER状态:1.待申请CCER(tCO2) 2.已申请CCER(tCO2)3.买入 4.核销 5.卖出 |
|||
*/ |
|||
private String state; |
|||
|
|||
/** |
|||
* 项目名称 |
|||
*/ |
|||
private String name; |
|||
|
|||
/** |
|||
* 所属企业 |
|||
*/ |
|||
private String company; |
|||
|
|||
/** |
|||
* 所属区域 |
|||
*/ |
|||
private String region; |
|||
|
|||
/** |
|||
* 第一次减排量备案 |
|||
*/ |
|||
private String firstEmission; |
|||
|
|||
/** |
|||
* 备案减排量 |
|||
*/ |
|||
private BigDecimal total; |
|||
|
|||
/** |
|||
* 减排量时间 |
|||
*/ |
|||
private Long issueDate; |
|||
|
|||
/** |
|||
* 核证机构 |
|||
*/ |
|||
private String certificationAuthority; |
|||
|
|||
/** |
|||
* 价格 |
|||
*/ |
|||
private BigDecimal price; |
|||
private String tag; |
|||
|
|||
|
|||
} |
|||
@ -1,68 +0,0 @@ |
|||
package com.thing.qingyuan.carbon.entity; |
|||
|
|||
import com.mybatisflex.annotation.Table; |
|||
import com.thing.common.orm.entity.BaseInfoEntity; |
|||
import lombok.Data; |
|||
import lombok.EqualsAndHashCode; |
|||
import lombok.experimental.Accessors; |
|||
|
|||
import java.io.Serial; |
|||
import java.io.Serializable; |
|||
import java.math.BigDecimal; |
|||
|
|||
/** |
|||
* 绿证信息总览 |
|||
* |
|||
* @author xc |
|||
* @since 3.0 2025-02-17 |
|||
*/ |
|||
@Data |
|||
@Accessors(chain = true) |
|||
@EqualsAndHashCode(callSuper=false) |
|||
@Table("qy_green_certificate_info") |
|||
public class QyGreenCertificateInfoEntity extends BaseInfoEntity implements Serializable { |
|||
|
|||
@Serial |
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
|
|||
/** |
|||
* 绿证状态:1.待发放绿证(MWH) 2.已申请绿证(MWH)3.买入 4.核销 5.卖出 |
|||
*/ |
|||
private String state; |
|||
/** |
|||
* 发电类型 |
|||
*/ |
|||
private String powerType; |
|||
/** |
|||
* 申请日期 |
|||
*/ |
|||
private Long applicationDate; |
|||
/** |
|||
* 核发日期 |
|||
*/ |
|||
private Long issueDate; |
|||
/** |
|||
* 绿证能源总量 |
|||
*/ |
|||
private BigDecimal total; |
|||
/** |
|||
* 绿证证书代码 |
|||
*/ |
|||
private String code; |
|||
/** |
|||
* 区域 |
|||
*/ |
|||
private String region; |
|||
/** |
|||
* 所属企业 |
|||
*/ |
|||
private String company; |
|||
/** |
|||
* 绿证价格 |
|||
*/ |
|||
private BigDecimal price; |
|||
private String tag; |
|||
|
|||
|
|||
} |
|||
@ -1,34 +0,0 @@ |
|||
package com.thing.qingyuan.carbon.entity; |
|||
|
|||
import com.mybatisflex.annotation.Id; |
|||
import com.mybatisflex.annotation.KeyType; |
|||
import com.mybatisflex.annotation.Table; |
|||
import com.mybatisflex.core.keygen.KeyGenerators; |
|||
import com.thing.common.orm.entity.BaseInfoEntity; |
|||
import lombok.Data; |
|||
import lombok.EqualsAndHashCode; |
|||
import lombok.experimental.Accessors; |
|||
|
|||
import java.io.Serial; |
|||
import java.io.Serializable; |
|||
|
|||
/** |
|||
* 区域列表 |
|||
* |
|||
* @author xc |
|||
* @since 3.0 2025-02-12 |
|||
*/ |
|||
@Data |
|||
@Accessors(chain = true) |
|||
@EqualsAndHashCode(callSuper=false) |
|||
@Table("qy_region") |
|||
public class QyRegionEntity extends BaseInfoEntity implements Serializable { |
|||
@Serial |
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
/** |
|||
* 区域名称 |
|||
*/ |
|||
private String name; |
|||
|
|||
} |
|||
@ -1,43 +0,0 @@ |
|||
package com.thing.qingyuan.carbon.exception; |
|||
|
|||
|
|||
import lombok.Data; |
|||
import lombok.EqualsAndHashCode; |
|||
|
|||
@EqualsAndHashCode(callSuper = true) |
|||
@Data |
|||
public class BusinessException extends RuntimeException { |
|||
// 获取错误码 |
|||
// 错误码 |
|||
private final String code; |
|||
// 错误信息 |
|||
private final String message; |
|||
|
|||
// 无参构造函数 |
|||
public BusinessException() { |
|||
super(); |
|||
this.code = "500"; // 默认为500 |
|||
this.message = "业务异常"; |
|||
} |
|||
|
|||
// 传入错误信息的构造函数 |
|||
public BusinessException(String message) { |
|||
super(message); |
|||
this.code = "500"; // 默认为500 |
|||
this.message = message; |
|||
} |
|||
|
|||
// 传入错误码和错误信息的构造函数 |
|||
public BusinessException(String code, String message) { |
|||
super(message); |
|||
this.code = code; |
|||
this.message = message; |
|||
} |
|||
|
|||
// 获取错误信息 |
|||
@Override |
|||
public String getMessage() { |
|||
return message; |
|||
} |
|||
} |
|||
|
|||
@ -1,71 +0,0 @@ |
|||
package com.thing.qingyuan.carbon.mapper; |
|||
|
|||
import com.thing.common.orm.mapper.PowerBaseMapper; |
|||
import com.thing.qingyuan.carbon.entity.QyCarbonQuotaInfoEntity; |
|||
import org.apache.ibatis.annotations.Mapper; |
|||
import org.apache.ibatis.annotations.Param; |
|||
import org.apache.ibatis.annotations.Select; |
|||
|
|||
import java.math.BigDecimal; |
|||
import java.util.List; |
|||
|
|||
@Mapper |
|||
public interface QyCarbonQuotaInfoMapper extends PowerBaseMapper<QyCarbonQuotaInfoEntity> { |
|||
|
|||
/** |
|||
* 查询指定状态下的碳配额总和 |
|||
* @param state 状态值 |
|||
* @return 返回碳配额的总和 |
|||
*/ |
|||
@Select("SELECT SUM(carbonQuota) " + |
|||
"FROM qy_carbon_quota_info " + |
|||
"WHERE state = #{state}") |
|||
BigDecimal getTotalCarbonQuotaByState(String state); |
|||
|
|||
|
|||
/** |
|||
* 查询指定小镇和区域的碳配额总和 |
|||
* @param town 小镇名称 |
|||
* @param region 区域名称 |
|||
* @return 返回小镇在指定区域的碳配额总和 |
|||
*/ |
|||
@Select("SELECT SUM(carbonQuota) " + |
|||
"FROM qy_carbon_quota_info " + |
|||
"WHERE town = #{town} AND region = #{region}") |
|||
BigDecimal getTotalCarbonQuotaByTown(@Param("town") String town, @Param("region") String region); |
|||
|
|||
/** |
|||
* 查询指定区域的所有小镇名称 |
|||
* @param region 区域名称 |
|||
* @return 返回该区域下所有小镇的列表 |
|||
*/ |
|||
@Select("SELECT DISTINCT town " + |
|||
"FROM qy_carbon_quota_info " + |
|||
"WHERE region = #{region}") |
|||
List<String> getDistinctTownsByRegion(@Param("region") String region); |
|||
|
|||
/** |
|||
* 查询所有碳配额的总和 |
|||
* @return 返回所有碳配额的总和 |
|||
*/ |
|||
@Select("SELECT SUM(carbonQuota) " + |
|||
"FROM qy_carbon_quota_info") |
|||
BigDecimal selectSumCarbonQuota(); |
|||
|
|||
/** |
|||
* 根据状态查询碳配额 |
|||
* @param number 状态值 |
|||
* @return 返回该状态下的碳配额总和 |
|||
*/ |
|||
@Select("SELECT SUM(carbonQuota) " + |
|||
"FROM qy_carbon_quota_info " + |
|||
"WHERE state = #{number}") |
|||
BigDecimal selectCarbonQuotaByState(String number); |
|||
|
|||
/** |
|||
* 获取指定小镇的减排量占比 |
|||
* @param regions 小镇名称 |
|||
* @return 小镇的减排量占比 |
|||
*/ |
|||
List<QyCarbonQuotaInfoEntity> findByTownIn(List<String> regions); |
|||
} |
|||
@ -1,16 +0,0 @@ |
|||
package com.thing.qingyuan.carbon.mapper; |
|||
|
|||
import com.thing.common.orm.mapper.PowerBaseMapper; |
|||
import com.thing.qingyuan.carbon.dto.QyCcerInfoDTO; |
|||
import com.thing.qingyuan.carbon.entity.QyCcerInfoEntity; |
|||
import org.apache.ibatis.annotations.Mapper; |
|||
import org.apache.ibatis.annotations.Param; |
|||
import org.apache.ibatis.annotations.Select; |
|||
import org.springframework.dao.DataAccessException; |
|||
|
|||
import java.util.List; |
|||
|
|||
@Mapper |
|||
public interface QyCcerInfoMapper extends PowerBaseMapper<QyCcerInfoEntity> { |
|||
|
|||
} |
|||
@ -1,9 +0,0 @@ |
|||
package com.thing.qingyuan.carbon.mapper; |
|||
|
|||
import com.thing.common.orm.mapper.PowerBaseMapper; |
|||
import com.thing.qingyuan.carbon.entity.QyGreenCertificateInfoEntity; |
|||
import org.apache.ibatis.annotations.Mapper; |
|||
|
|||
@Mapper |
|||
public interface QyGreenCertificateInfoMapper extends PowerBaseMapper<QyGreenCertificateInfoEntity> { |
|||
} |
|||
@ -1,44 +0,0 @@ |
|||
package com.thing.qingyuan.carbon.mapper; |
|||
|
|||
import com.thing.common.orm.mapper.PowerBaseMapper; |
|||
import com.thing.qingyuan.carbon.dto.QyRegionDTO; |
|||
import com.thing.qingyuan.carbon.entity.QyRegionEntity; |
|||
import org.apache.ibatis.annotations.Mapper; |
|||
import org.apache.ibatis.annotations.Param; |
|||
import org.apache.ibatis.annotations.Select; |
|||
|
|||
import java.util.List; |
|||
|
|||
@Mapper |
|||
public interface QyRegionMapper extends PowerBaseMapper<QyRegionEntity> { |
|||
|
|||
/** |
|||
* 获取所有区域的列表,包括每个区域的基本信息。 |
|||
* @return 区域列表,包含区域基本信息的 DTO |
|||
*/ |
|||
@Select("SELECT * FROM qy_region") |
|||
List<QyRegionDTO> findAll(); |
|||
|
|||
/** |
|||
* 查询所有区域实体数据 |
|||
* @param o 过滤条件或查询参数,可以传入null查询所有区域 |
|||
* @return 区域列表,包含区域的实体信息 |
|||
*/ |
|||
@Select("<script>" + |
|||
"SELECT * FROM qy_region" + |
|||
"<where>" + |
|||
"<if test='o != null'> AND region_name = #{o.regionName} </if>" + |
|||
"</where>" + |
|||
"</script>") |
|||
List<QyRegionEntity> selectList(@Param("o") Object o); |
|||
|
|||
/** |
|||
* 根据区域 ID 查询指定区域 |
|||
* @param id 区域的唯一标识 |
|||
* @return 返回对应区域的实体对象 |
|||
*/ |
|||
@Select("SELECT * FROM qy_region WHERE id = #{id}") |
|||
QyRegionEntity selectById(Long id); |
|||
|
|||
|
|||
} |
|||
@ -1,31 +0,0 @@ |
|||
package com.thing.qingyuan.carbon.service; |
|||
|
|||
|
|||
import com.thing.common.core.web.response.PageData; |
|||
import com.thing.qingyuan.carbon.dto.QyCarbonAssetDTO; |
|||
|
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
public interface QyCarbonAssetService { |
|||
|
|||
/** |
|||
* 计算当前碳资产,包括碳配额,CCER,绿证 |
|||
* @return 返回一个Map |
|||
*/ |
|||
Map<String,String> countCarbonAsset(); |
|||
|
|||
|
|||
/** |
|||
* 统计近几个月的资产 |
|||
* @return 返回一个map |
|||
*/ |
|||
List<QyCarbonAssetDTO> countRecentCarbonAsset(Long startTime, Long endTime); |
|||
|
|||
/** |
|||
* 获取碳资产对应标签的单价,数量,余额,账户总余额 |
|||
* @return 返回一个Map |
|||
*/ |
|||
PageData<QyCarbonAssetDTO> calculateAsset(Map<String, Object> params); |
|||
|
|||
} |
|||
@ -1,35 +0,0 @@ |
|||
package com.thing.qingyuan.carbon.service; |
|||
|
|||
|
|||
import com.thing.common.orm.service.IBaseService; |
|||
import com.thing.qingyuan.carbon.dto.QyRegionDTO; |
|||
import com.thing.qingyuan.carbon.entity.QyCarbonQuotaInfoEntity; |
|||
import com.thing.qingyuan.carbon.entity.QyRegionEntity; |
|||
|
|||
import java.math.BigDecimal; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
|
|||
public interface QyCarbonQuotaInfoService extends IBaseService<QyCarbonQuotaInfoEntity> { |
|||
|
|||
/** |
|||
* 获取区域减排量占比 |
|||
* |
|||
* @return 返回一个Map,键为区域名称,值为该区域减排量占总碳配额的百分比 |
|||
*/ |
|||
List<Map<String, String>> getEmissionReductionPercentagesByState(); |
|||
|
|||
|
|||
/** |
|||
* 统计当前碳配额总和和三种状态所占百分比 |
|||
* |
|||
* @return 返回一个Map,其中包含: |
|||
* 1. "pendingPercent" - 待发放碳配额状态的百分比 |
|||
* 2. "issuedPercent" - 已发放碳配额状态的百分比 |
|||
*/ |
|||
Map<String, String> getCarbonQuotaStatisticsWithStatePercentage(); |
|||
|
|||
} |
|||
|
|||
|
|||
@ -1,25 +0,0 @@ |
|||
package com.thing.qingyuan.carbon.service; |
|||
|
|||
|
|||
import com.thing.common.orm.service.IBaseService; |
|||
import com.thing.qingyuan.carbon.entity.QyCcerInfoEntity; |
|||
|
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
public interface QyCcerInfoService extends IBaseService<QyCcerInfoEntity> { |
|||
|
|||
/** |
|||
* 根据状态统计CCER数量 |
|||
* @return 各状态的CCER数量 |
|||
*/ |
|||
Map<String, String> countCcerByState(); |
|||
|
|||
/** |
|||
* 根据区域与小镇统计成交量,并计算每个小镇在所属区域内的成交量占比 |
|||
* @return 返回一个Map,包含每个区域下每个小镇的成交量占比 |
|||
*/ |
|||
List<Map<String, String>> getByRegion(); |
|||
|
|||
|
|||
} |
|||
@ -1,21 +0,0 @@ |
|||
package com.thing.qingyuan.carbon.service; |
|||
|
|||
import com.thing.common.orm.service.IBaseService; |
|||
import com.thing.qingyuan.carbon.entity.QyGreenCertificateInfoEntity; |
|||
|
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
public interface QyGreenCertificateInfoService extends IBaseService<QyGreenCertificateInfoEntity> { |
|||
/** |
|||
* 根据区域与小镇统计绿证,并计算每个小镇在所属区域内的绿证占比 |
|||
* @return 返回一个Map,包含每个区域下每个小镇的绿证占比 |
|||
*/ |
|||
List<Map<String, String>> getRegionGreenCertificatePercentage(); |
|||
|
|||
/** |
|||
* 获取根据状态统计的绿证数量 |
|||
* @return 各状态的绿证数量 |
|||
*/ |
|||
Map<String, String> countGreenByState(); |
|||
} |
|||
@ -1,22 +0,0 @@ |
|||
package com.thing.qingyuan.carbon.service; |
|||
|
|||
import com.thing.common.orm.service.IBaseService; |
|||
import com.thing.qingyuan.carbon.dto.QyRegionDTO; |
|||
import com.thing.qingyuan.carbon.entity.QyRegionEntity; |
|||
|
|||
import java.util.List; |
|||
|
|||
/** |
|||
* 区域列表 |
|||
* |
|||
* @author xc |
|||
* @since 3.0 2025-02-12 |
|||
*/ |
|||
public interface QyRegionService extends IBaseService<QyRegionEntity> { |
|||
|
|||
/** |
|||
* 获取所有区域列表 |
|||
* @return 所有区域的DTO列表 |
|||
*/ |
|||
List<QyRegionDTO> getAllRegions(); |
|||
} |
|||
@ -1,363 +0,0 @@ |
|||
package com.thing.qingyuan.carbon.service.impl; |
|||
|
|||
import cn.hutool.core.map.MapUtil; |
|||
import com.google.common.collect.Lists; |
|||
import com.mybatisflex.core.query.QueryWrapper; |
|||
import com.thing.common.core.utils.PageUtils; |
|||
import com.thing.common.core.web.response.PageData; |
|||
import com.thing.qingyuan.carbon.dto.QyCarbonAssetDTO; |
|||
import com.thing.qingyuan.carbon.dto.QyCarbonSumQuotaInfoDTO; |
|||
import com.thing.qingyuan.carbon.entity.QyCarbonQuotaInfoEntity; |
|||
import com.thing.qingyuan.carbon.entity.QyCcerInfoEntity; |
|||
import com.thing.qingyuan.carbon.entity.QyGreenCertificateInfoEntity; |
|||
import com.thing.qingyuan.carbon.service.QyCarbonAssetService; |
|||
import com.thing.qingyuan.carbon.service.QyCarbonQuotaInfoService; |
|||
import com.thing.qingyuan.carbon.service.QyCcerInfoService; |
|||
import com.thing.qingyuan.carbon.service.QyGreenCertificateInfoService; |
|||
import lombok.RequiredArgsConstructor; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.apache.commons.collections4.CollectionUtils; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
import java.math.BigDecimal; |
|||
import java.math.RoundingMode; |
|||
import java.time.Instant; |
|||
import java.time.LocalDate; |
|||
import java.time.ZoneId; |
|||
import java.time.temporal.ChronoUnit; |
|||
import java.util.*; |
|||
import java.util.stream.Collectors; |
|||
|
|||
import static com.mybatisflex.core.query.QueryMethods.sum; |
|||
import static com.thing.qingyuan.carbon.entity.table.QyCarbonQuotaInfoEntityTableDef.QY_CARBON_QUOTA_INFO_ENTITY; |
|||
import static com.thing.qingyuan.carbon.entity.table.QyCcerInfoEntityTableDef.QY_CCER_INFO_ENTITY; |
|||
import static com.thing.qingyuan.carbon.entity.table.QyGreenCertificateInfoEntityTableDef.QY_GREEN_CERTIFICATE_INFO_ENTITY; |
|||
|
|||
@Slf4j |
|||
@Service |
|||
@RequiredArgsConstructor |
|||
public class QyCarbonAssetServiceImpl implements QyCarbonAssetService { |
|||
|
|||
private final QyCarbonQuotaInfoService qyCarbonQuotaInfoService; |
|||
private final QyCcerInfoService qyCcerInfoService; |
|||
private final QyGreenCertificateInfoService qyGreenCertificateInfoService; |
|||
|
|||
/** |
|||
* 计算当前碳资产,包括碳配额,CCER,绿证 |
|||
* @return 返回一个Map |
|||
*/ |
|||
@Override |
|||
public Map<String, String> countCarbonAsset() { |
|||
|
|||
BigDecimal carbonTotal = BigDecimal.ZERO; |
|||
BigDecimal ccerTotal = BigDecimal.ZERO; |
|||
BigDecimal greenTotal = BigDecimal.ZERO; |
|||
BigDecimal carbon = BigDecimal.ZERO; |
|||
BigDecimal ccer = BigDecimal.ZERO; |
|||
BigDecimal green = BigDecimal.ZERO; |
|||
//买入 |
|||
BigDecimal carbonBuy = BigDecimal.ZERO; |
|||
BigDecimal ccerBuy = BigDecimal.ZERO; |
|||
BigDecimal greenBuy = BigDecimal.ZERO; |
|||
//卖出 |
|||
BigDecimal carbonSell = BigDecimal.ZERO; |
|||
BigDecimal ccerSell = BigDecimal.ZERO; |
|||
BigDecimal greenSell = BigDecimal.ZERO; |
|||
//核销 |
|||
BigDecimal carbonOff = BigDecimal.ZERO; |
|||
BigDecimal ccerOff = BigDecimal.ZERO; |
|||
BigDecimal greenOff = BigDecimal.ZERO; |
|||
//查询碳配额 |
|||
QueryWrapper queryWrapper = QueryWrapper.create() |
|||
.select(sum(QY_CARBON_QUOTA_INFO_ENTITY.TOTAL).as("total"), QY_CARBON_QUOTA_INFO_ENTITY.STATE) |
|||
.from(QY_CARBON_QUOTA_INFO_ENTITY) |
|||
.in(QyCarbonQuotaInfoEntity::getState,"2", "3", "4", "5") |
|||
.ne(QyCarbonQuotaInfoEntity::getState,"0") |
|||
.groupBy(QY_CARBON_QUOTA_INFO_ENTITY.STATE); |
|||
// sum1 为待 发放碳配额 |
|||
List<QyCarbonSumQuotaInfoDTO> carbonList = qyCarbonQuotaInfoService.getMapper().selectListByQueryAs(queryWrapper, QyCarbonSumQuotaInfoDTO.class); |
|||
if(CollectionUtils.isNotEmpty(carbonList)){ |
|||
carbonTotal = carbonList.stream().filter(e -> "2".equals(e.getState()) || "3".equals(e.getState())) |
|||
.map(QyCarbonSumQuotaInfoDTO::getTotal) |
|||
.reduce(BigDecimal.ZERO, BigDecimal::add); |
|||
carbon = carbonList.stream().filter(e -> "4".equals(e.getState()) || "5".equals(e.getState())) |
|||
.map(QyCarbonSumQuotaInfoDTO::getTotal) |
|||
.reduce(BigDecimal.ZERO, BigDecimal::add); |
|||
carbonBuy = carbonList.stream().filter(e -> "3".equals(e.getState())) |
|||
.map(QyCarbonSumQuotaInfoDTO::getTotal) |
|||
.reduce(BigDecimal.ZERO, BigDecimal::add); |
|||
carbonSell = carbonList.stream().filter(e -> "4".equals(e.getState())).map(QyCarbonSumQuotaInfoDTO::getTotal) |
|||
.reduce(BigDecimal.ZERO, BigDecimal::add); |
|||
carbonOff = carbonList.stream().filter(e -> "5".equals(e.getState())).map(QyCarbonSumQuotaInfoDTO::getTotal) |
|||
.reduce(BigDecimal.ZERO, BigDecimal::add); |
|||
} |
|||
|
|||
//查询待申请CCER |
|||
QueryWrapper queryWrapper1 = QueryWrapper.create() |
|||
.select(sum(QY_CCER_INFO_ENTITY.TOTAL).as("total")) |
|||
.from(QY_CCER_INFO_ENTITY) |
|||
.in(QyCcerInfoEntity::getState,"2", "3", "4", "5") |
|||
.ne(QyCcerInfoEntity::getState,"0") |
|||
.groupBy(QY_CCER_INFO_ENTITY.STATE); |
|||
// sum2 为待申请CCER |
|||
List<QyCarbonSumQuotaInfoDTO> ccerList = qyCarbonQuotaInfoService.getMapper().selectListByQueryAs(queryWrapper1, QyCarbonSumQuotaInfoDTO.class); |
|||
if(CollectionUtils.isNotEmpty(ccerList)){ |
|||
ccerTotal = ccerList.stream().filter(e -> "2".equals(e.getState()) || "3".equals(e.getState())) |
|||
.map(QyCarbonSumQuotaInfoDTO::getTotal) |
|||
.reduce(BigDecimal.ZERO, BigDecimal::add); |
|||
ccer = ccerList.stream().filter(e -> "4".equals(e.getState()) || "5".equals(e.getState())) |
|||
.map(QyCarbonSumQuotaInfoDTO::getTotal) |
|||
.reduce(BigDecimal.ZERO, BigDecimal::add); |
|||
ccerBuy = ccerList.stream().filter(e -> "3".equals(e.getState())) |
|||
.map(QyCarbonSumQuotaInfoDTO::getTotal) |
|||
.reduce(BigDecimal.ZERO, BigDecimal::add); |
|||
ccerSell = ccerList.stream().filter(e -> "4".equals(e.getState())).map(QyCarbonSumQuotaInfoDTO::getTotal) |
|||
.reduce(BigDecimal.ZERO, BigDecimal::add); |
|||
ccerOff = ccerList.stream().filter(e -> "5".equals(e.getState())).map(QyCarbonSumQuotaInfoDTO::getTotal) |
|||
.reduce(BigDecimal.ZERO, BigDecimal::add); |
|||
} |
|||
//查询待发放绿证 |
|||
QueryWrapper queryWrapper2 = QueryWrapper.create() |
|||
.select(sum(QY_GREEN_CERTIFICATE_INFO_ENTITY.TOTAL).as("total")) |
|||
.from(QY_GREEN_CERTIFICATE_INFO_ENTITY) |
|||
.in(QyGreenCertificateInfoEntity::getState,"2", "3", "4", "5") |
|||
.ne(QyGreenCertificateInfoEntity::getState,"0") |
|||
.groupBy(QY_GREEN_CERTIFICATE_INFO_ENTITY.STATE); |
|||
// sum3 为待发放绿证 |
|||
List<QyCarbonSumQuotaInfoDTO> greenList = qyCarbonQuotaInfoService.getMapper().selectListByQueryAs(queryWrapper2, QyCarbonSumQuotaInfoDTO.class); |
|||
if(CollectionUtils.isNotEmpty(greenList)){ |
|||
greenTotal = greenList.stream().filter(e -> "2".equals(e.getState()) || "3".equals(e.getState())) |
|||
.map(QyCarbonSumQuotaInfoDTO::getTotal) |
|||
.reduce(BigDecimal.ZERO, BigDecimal::add); |
|||
green = greenList.stream().filter(e -> "4".equals(e.getState()) || "5".equals(e.getState())) |
|||
.map(QyCarbonSumQuotaInfoDTO::getTotal) |
|||
.reduce(BigDecimal.ZERO, BigDecimal::add); |
|||
greenBuy = greenList.stream().filter(e -> "3".equals(e.getState())) |
|||
.map(QyCarbonSumQuotaInfoDTO::getTotal) |
|||
.reduce(BigDecimal.ZERO, BigDecimal::add); |
|||
greenSell = greenList.stream().filter(e -> "4".equals(e.getState())).map(QyCarbonSumQuotaInfoDTO::getTotal) |
|||
.reduce(BigDecimal.ZERO, BigDecimal::add); |
|||
greenOff = greenList.stream().filter(e -> "5".equals(e.getState())).map(QyCarbonSumQuotaInfoDTO::getTotal) |
|||
.reduce(BigDecimal.ZERO, BigDecimal::add); |
|||
} |
|||
|
|||
//统计当前状态下 碳配额,ccer,绿证总和 |
|||
BigDecimal total = carbonTotal.add(ccerTotal).add(greenTotal).subtract(carbon).subtract(ccer).subtract(green); |
|||
|
|||
BigDecimal carbonSum = carbonTotal.subtract(carbon); |
|||
BigDecimal ccerSum = ccerTotal.subtract(ccer); |
|||
BigDecimal greenSum = greenTotal.subtract(green); |
|||
|
|||
//返回结果 |
|||
Map<String, String> resMap = new HashMap<>(); |
|||
//占比 |
|||
resMap.put("carbonPercent",carbonSum.divide(total,2, RoundingMode.HALF_UP).toPlainString()); |
|||
resMap.put("ccerPercent",ccerSum.divide(total,2, RoundingMode.HALF_UP).toPlainString()); |
|||
resMap.put("greenPercent",greenSum.divide(total,2, RoundingMode.HALF_UP).toPlainString()); |
|||
resMap.put("total",total.toPlainString()); |
|||
//累计资产状态 |
|||
resMap.put("carbonSum",carbonSum.toPlainString()); |
|||
resMap.put("ccerSum",ccerSum.toPlainString()); |
|||
resMap.put("greenSum",greenSum.toPlainString()); |
|||
//碳资产状态 |
|||
resMap.put("buy",carbonBuy.add(ccerBuy).add(greenBuy).toPlainString()); |
|||
resMap.put("sell",carbonSell.add(ccerSell).add(greenSell).toPlainString()); |
|||
resMap.put("off",carbonOff.add(ccerOff).add(greenOff).toPlainString()); |
|||
return resMap; |
|||
|
|||
} |
|||
|
|||
/** |
|||
* 统计近几个月的碳资产 |
|||
* @return 返回一个map |
|||
*/ |
|||
@Override |
|||
public List<QyCarbonAssetDTO> countRecentCarbonAsset(Long startTime, Long endTime) { |
|||
List<QyCarbonAssetDTO> tempList = Lists.newArrayList(); |
|||
Boolean sixMonth = isSixMonth(startTime, endTime); |
|||
//查询碳配额这段时间的账户总额度 |
|||
List<QyCarbonAssetDTO> carbonList = qyCarbonQuotaInfoService.getMapper().selectListByQueryAs( |
|||
QueryWrapper.create().select(QY_CARBON_QUOTA_INFO_ENTITY.TOTAL |
|||
, QY_CARBON_QUOTA_INFO_ENTITY.STATE, QY_CARBON_QUOTA_INFO_ENTITY.ISSUE_DATE) |
|||
.ge(QyCarbonQuotaInfoEntity::getIssueDate, startTime) |
|||
.lt(QyCarbonQuotaInfoEntity::getIssueDate, endTime) |
|||
.in(QyCarbonQuotaInfoEntity::getState, "2", "3", "4", "5") |
|||
.orderBy(QY_CARBON_QUOTA_INFO_ENTITY.ISSUE_DATE, true) |
|||
, QyCarbonAssetDTO.class); |
|||
if(CollectionUtils.isNotEmpty(carbonList)){ |
|||
tempList.addAll(carbonList); |
|||
} |
|||
//查询CCER这段时间的账户总额度 |
|||
List<QyCarbonAssetDTO> ccerInfoList = qyCcerInfoService.getMapper().selectListByQueryAs( |
|||
QueryWrapper.create().select(QY_CCER_INFO_ENTITY.TOTAL |
|||
, QY_CCER_INFO_ENTITY.STATE, QY_CCER_INFO_ENTITY.ISSUE_DATE) |
|||
.ge(QyCcerInfoEntity::getIssueDate, startTime) |
|||
.lt(QyCcerInfoEntity::getIssueDate, endTime) |
|||
.in(QyCcerInfoEntity::getState, "2", "3", "4", "5") |
|||
.orderBy(QY_CCER_INFO_ENTITY.ISSUE_DATE, true) |
|||
, QyCarbonAssetDTO.class); |
|||
if(CollectionUtils.isNotEmpty(ccerInfoList)){ |
|||
tempList.addAll(ccerInfoList); |
|||
} |
|||
//查询绿证这段时间的账户总额度 |
|||
List<QyCarbonAssetDTO> greenList = qyGreenCertificateInfoService.getMapper().selectListByQueryAs( |
|||
QueryWrapper.create().select(QY_GREEN_CERTIFICATE_INFO_ENTITY.TOTAL |
|||
, QY_GREEN_CERTIFICATE_INFO_ENTITY.STATE, QY_GREEN_CERTIFICATE_INFO_ENTITY.ISSUE_DATE) |
|||
.ge(QyGreenCertificateInfoEntity::getIssueDate, startTime) |
|||
.lt(QyGreenCertificateInfoEntity::getIssueDate, endTime) |
|||
.in(QyGreenCertificateInfoEntity::getState, "2", "3", "4", "5") |
|||
.orderBy(QY_GREEN_CERTIFICATE_INFO_ENTITY.ISSUE_DATE, true) |
|||
, QyCarbonAssetDTO.class); |
|||
if(CollectionUtils.isNotEmpty(greenList)){ |
|||
tempList.addAll(greenList); |
|||
} |
|||
if(CollectionUtils.isEmpty(tempList)){ |
|||
return new ArrayList<>(); |
|||
} |
|||
List<QyCarbonAssetDTO> resList = Lists.newArrayList(); |
|||
Map<Long, List<QyCarbonAssetDTO>> collect ; |
|||
//不超过6个月的查询每天的,超过的查询每个月的 |
|||
if(!sixMonth){ |
|||
collect = tempList.stream().collect(Collectors.groupingBy(QyCarbonAssetDTO::getIssueDate)); |
|||
}else { |
|||
// 分组,按年月进行分组,时间戳转换为年月(13位) |
|||
collect = tempList.stream().collect(Collectors.groupingBy(dto -> { |
|||
// 获取13位时间戳 |
|||
long timestamp = dto.getIssueDate(); |
|||
// 转换为 LocalDate 对象 |
|||
LocalDate localDate = Instant.ofEpochMilli(timestamp).atZone(ZoneId.systemDefault()).toLocalDate(); |
|||
// 获取年月的13位时间戳(年和月) |
|||
LocalDate firstDayOfMonth = localDate.withDayOfMonth(1); // 获取当前月份的第一天 |
|||
// 返回年月对应的13位时间戳 |
|||
return firstDayOfMonth.atStartOfDay(ZoneId.systemDefault()).toInstant().toEpochMilli(); |
|||
})); |
|||
} |
|||
collect.forEach((k,v)->{ |
|||
QyCarbonAssetDTO temp = new QyCarbonAssetDTO(); |
|||
//1.待发 2.已发 3.买入 4.核销 5.卖出 |
|||
BigDecimal total = v.stream().filter(e -> "2".equals(e.getState())).map(QyCarbonAssetDTO::getTotal).reduce(BigDecimal.ZERO, BigDecimal::add); |
|||
BigDecimal buy = v.stream().filter(e -> "3".equals(e.getState())).map(QyCarbonAssetDTO::getTotal).reduce(BigDecimal.ZERO, BigDecimal::add); |
|||
BigDecimal off = v.stream().filter(e -> "4".equals(e.getState())).map(QyCarbonAssetDTO::getTotal).reduce(BigDecimal.ZERO, BigDecimal::add); |
|||
BigDecimal sell = v.stream().filter(e -> "5".equals(e.getState())).map(QyCarbonAssetDTO::getTotal).reduce(BigDecimal.ZERO, BigDecimal::add); |
|||
BigDecimal balance = total.add(buy).subtract(sell).subtract(off); |
|||
temp.setIssueDate(k); |
|||
temp.setBuy(buy); |
|||
temp.setOff(off); |
|||
temp.setSell(sell); |
|||
temp.setBalance(balance); |
|||
temp.setTotal(total); |
|||
resList.add(temp); |
|||
}); |
|||
// 按 issueDate 升序排序 |
|||
resList.sort(Comparator.comparingLong(QyCarbonAssetDTO::getIssueDate)); |
|||
return resList; |
|||
} |
|||
|
|||
private Boolean isSixMonth(Long startTime, Long endTime) { |
|||
|
|||
// 将时间戳转换为 LocalDate(假设我们关心日期而不是时间) |
|||
LocalDate startDate = Instant.ofEpochMilli(startTime) |
|||
.atZone(ZoneId.systemDefault()) |
|||
.toLocalDate(); |
|||
LocalDate endDate = Instant.ofEpochMilli(endTime) |
|||
.atZone(ZoneId.systemDefault()) |
|||
.toLocalDate(); |
|||
|
|||
// 计算两个日期之间的月份差 |
|||
long monthsBetween = ChronoUnit.MONTHS.between(startDate, endDate); |
|||
|
|||
// 判断是否超过半年(6个月) |
|||
if (monthsBetween >= 6) { |
|||
return true; |
|||
} else { |
|||
return false; |
|||
} |
|||
} |
|||
|
|||
|
|||
/** |
|||
* 获取碳资产对应标签的单价,数量,余额,账户总余额 |
|||
* @return 返回一个Map |
|||
*/ |
|||
@Override |
|||
public PageData<QyCarbonAssetDTO> calculateAsset(Map<String, Object> params) { |
|||
Integer page = MapUtil.getInt(params, "page"); |
|||
Integer limit = MapUtil.getInt(params, "limit"); |
|||
Long startTime = MapUtil.getLong(params, "startTime"); |
|||
Long endTime = MapUtil.getLong(params, "endTime"); |
|||
List<QyCarbonAssetDTO> resList = Lists.newArrayList(); |
|||
List<QyCarbonAssetDTO> carbonList = qyCarbonQuotaInfoService.getMapper().selectListByQueryAs( |
|||
QueryWrapper.create().select(QY_CARBON_QUOTA_INFO_ENTITY.TOTAL, |
|||
QY_CARBON_QUOTA_INFO_ENTITY.STATE, |
|||
QY_CARBON_QUOTA_INFO_ENTITY.ISSUE_DATE, |
|||
QY_CARBON_QUOTA_INFO_ENTITY.TAG, |
|||
QY_CARBON_QUOTA_INFO_ENTITY.TOTAL, |
|||
QY_CARBON_QUOTA_INFO_ENTITY.PRICE |
|||
) |
|||
.ge(QyCarbonQuotaInfoEntity::getIssueDate, startTime,!Objects.isNull(startTime)) |
|||
.lt(QyCarbonQuotaInfoEntity::getIssueDate, endTime,!Objects.isNull(endTime)) |
|||
, QyCarbonAssetDTO.class); |
|||
|
|||
if(CollectionUtils.isNotEmpty(carbonList)){ |
|||
calBalanceAndUnitPrice(carbonList); |
|||
} |
|||
|
|||
//查询CCER这段时间的账户总额度 |
|||
List<QyCarbonAssetDTO> ccerInfoList = qyCcerInfoService.getMapper().selectListByQueryAs( |
|||
QueryWrapper.create().select( |
|||
QY_CCER_INFO_ENTITY.TOTAL, |
|||
QY_CCER_INFO_ENTITY.STATE, |
|||
QY_CCER_INFO_ENTITY.ISSUE_DATE, |
|||
QY_CCER_INFO_ENTITY.TAG, |
|||
QY_CCER_INFO_ENTITY.TOTAL, |
|||
QY_CCER_INFO_ENTITY.PRICE) |
|||
.ge(QyCcerInfoEntity::getIssueDate, startTime,!Objects.isNull(startTime)) |
|||
.lt(QyCcerInfoEntity::getIssueDate, endTime,!Objects.isNull(endTime)) |
|||
, QyCarbonAssetDTO.class); |
|||
|
|||
if(CollectionUtils.isNotEmpty(ccerInfoList)){ |
|||
calBalanceAndUnitPrice(ccerInfoList); |
|||
} |
|||
|
|||
//查询绿证这段时间的账户总额度 |
|||
List<QyCarbonAssetDTO> greenList = qyGreenCertificateInfoService.getMapper().selectListByQueryAs( |
|||
QueryWrapper.create().select( |
|||
QY_GREEN_CERTIFICATE_INFO_ENTITY.TOTAL, |
|||
QY_GREEN_CERTIFICATE_INFO_ENTITY.STATE, |
|||
QY_GREEN_CERTIFICATE_INFO_ENTITY.ISSUE_DATE, |
|||
QY_GREEN_CERTIFICATE_INFO_ENTITY.TAG, |
|||
QY_GREEN_CERTIFICATE_INFO_ENTITY.TOTAL, |
|||
QY_GREEN_CERTIFICATE_INFO_ENTITY.PRICE) |
|||
.ge(QyGreenCertificateInfoEntity::getIssueDate, startTime,!Objects.isNull(startTime)) |
|||
.lt(QyGreenCertificateInfoEntity::getIssueDate, endTime,!Objects.isNull(endTime)) |
|||
, QyCarbonAssetDTO.class); |
|||
|
|||
if(CollectionUtils.isNotEmpty(greenList)){ |
|||
calBalanceAndUnitPrice(greenList); |
|||
} |
|||
resList.addAll(carbonList); |
|||
resList.addAll(ccerInfoList); |
|||
resList.addAll(greenList); |
|||
List<QyCarbonAssetDTO> list = resList.stream().sorted(Comparator.comparing(QyCarbonAssetDTO::getIssueDate).reversed()).toList(); |
|||
List<QyCarbonAssetDTO> qyCarbonAssetDTOS = PageUtils.startPage(list, page, limit); |
|||
return new PageData<>(qyCarbonAssetDTOS, CollectionUtils.size(list)); |
|||
} |
|||
|
|||
private static void calBalanceAndUnitPrice(List<QyCarbonAssetDTO> carbonList) { |
|||
//总数 |
|||
BigDecimal sum = carbonList.stream().filter(s -> "2".equals(s.getState())||"3".equals(s.getState())) |
|||
.map(QyCarbonAssetDTO::getTotal) |
|||
.reduce(BigDecimal.ZERO, BigDecimal::add); |
|||
//核销和卖出 |
|||
BigDecimal sellNum = carbonList.stream().filter(s -> "4".equals(s.getState()) || "5".equals(s.getState())) |
|||
.map(QyCarbonAssetDTO::getTotal) |
|||
.reduce(BigDecimal.ZERO, BigDecimal::add); |
|||
|
|||
BigDecimal balance = sum.subtract(sellNum); |
|||
for (QyCarbonAssetDTO qyCarbonAssetDTO : carbonList) { |
|||
qyCarbonAssetDTO.setBalance(balance); |
|||
qyCarbonAssetDTO.setUnitPrice(qyCarbonAssetDTO.getTotal().divide(qyCarbonAssetDTO.getPrice(), 2, RoundingMode.HALF_UP)); |
|||
} |
|||
} |
|||
|
|||
} |
|||
@ -1,140 +0,0 @@ |
|||
package com.thing.qingyuan.carbon.service.impl; |
|||
|
|||
import cn.hutool.core.collection.CollectionUtil; |
|||
import com.google.common.collect.Lists; |
|||
import com.mybatisflex.core.query.QueryWrapper; |
|||
import com.thing.common.orm.service.impl.BaseServiceImpl; |
|||
import com.thing.qingyuan.carbon.dto.QyCarbonSumQuotaInfoDTO; |
|||
import com.thing.qingyuan.carbon.entity.QyCarbonQuotaInfoEntity; |
|||
import com.thing.qingyuan.carbon.mapper.QyCarbonQuotaInfoMapper; |
|||
import com.thing.qingyuan.carbon.service.QyCarbonQuotaInfoService; |
|||
import com.thing.qingyuan.carbon.util.Constant; |
|||
import org.apache.commons.collections4.MapUtils; |
|||
import org.apache.commons.lang3.StringUtils; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
import java.math.BigDecimal; |
|||
import java.math.RoundingMode; |
|||
import java.util.*; |
|||
|
|||
import static com.mybatisflex.core.query.QueryMethods.sum; |
|||
import static com.thing.qingyuan.carbon.entity.table.QyCarbonQuotaInfoEntityTableDef.QY_CARBON_QUOTA_INFO_ENTITY; |
|||
|
|||
@Service |
|||
public class QyCarbonQuotaInfoServiceImpl extends BaseServiceImpl<QyCarbonQuotaInfoMapper, QyCarbonQuotaInfoEntity> implements QyCarbonQuotaInfoService { |
|||
|
|||
@Override |
|||
public QueryWrapper getWrapper(Map<String, Object> params) { |
|||
QueryWrapper queryWrapper = new QueryWrapper(); |
|||
if(MapUtils.isEmpty(params)){ |
|||
return queryWrapper; |
|||
} |
|||
if (params.containsKey("state")) { |
|||
queryWrapper.eq("state", params.get("state")); |
|||
} |
|||
if (params.containsKey("region")) { |
|||
queryWrapper.eq("region", params.get("region")); |
|||
} |
|||
if (params.containsKey("name")) { |
|||
queryWrapper.like("name", params.get("name")); |
|||
} |
|||
if (params.containsKey("projectCode")) { |
|||
queryWrapper.eq("projectCode", params.get("projectCode")); |
|||
} |
|||
if (params.containsKey("startDate") && params.containsKey("endDate")) { |
|||
queryWrapper.between("issueDate", params.get("startDate"), params.get("endDate")); |
|||
} |
|||
if (params.containsKey("createDateStart") && params.containsKey("createDateEnd")) { |
|||
queryWrapper.between("createDate", params.get("createDateStart"), params.get("createDateEnd")); |
|||
} |
|||
return queryWrapper; |
|||
} |
|||
|
|||
/** |
|||
* 统计当前碳配额总和和三种状态所占百分比 |
|||
* @return 返回一个Map,其中包含: |
|||
*/ |
|||
@Override |
|||
public Map<String, String> getCarbonQuotaStatisticsWithStatePercentage() { |
|||
//查询待发放碳配额 |
|||
QueryWrapper queryWrapper1 = QueryWrapper.create() |
|||
.select(sum(QY_CARBON_QUOTA_INFO_ENTITY.TOTAL)) |
|||
.from(QY_CARBON_QUOTA_INFO_ENTITY) |
|||
.eq(QyCarbonQuotaInfoEntity::getState, "1"); |
|||
//sum1 待发放碳配额总量 |
|||
String sum1 = mapper.selectOneByQueryAs(queryWrapper1, String.class); |
|||
|
|||
//查询已发放碳配额 |
|||
QueryWrapper queryWrapper2 = QueryWrapper.create() |
|||
.select(sum(QY_CARBON_QUOTA_INFO_ENTITY.TOTAL)) |
|||
.from(QY_CARBON_QUOTA_INFO_ENTITY) |
|||
.eq(QyCarbonQuotaInfoEntity::getState, "2"); |
|||
//sum2 已发放碳配额总量 |
|||
String sum2 = mapper.selectOneByQueryAs(queryWrapper2, String.class); |
|||
//sum 为总碳配额量 即累计(sum=sum1+sum2) |
|||
QueryWrapper queryWrapper3 = QueryWrapper.create() |
|||
.select(sum(QY_CARBON_QUOTA_INFO_ENTITY.TOTAL)) |
|||
.from(QY_CARBON_QUOTA_INFO_ENTITY); |
|||
String sum = mapper.selectOneByQueryAs(queryWrapper3, String.class); |
|||
|
|||
QueryWrapper queryWrapperBalance = QueryWrapper.create() |
|||
.select(sum(QY_CARBON_QUOTA_INFO_ENTITY.TOTAL)) |
|||
.from(QY_CARBON_QUOTA_INFO_ENTITY) |
|||
.in(QyCarbonQuotaInfoEntity::getState, "4","5"); |
|||
//sum1 待发放碳配额总量 |
|||
String sumBalance = mapper.selectOneByQueryAs(queryWrapperBalance, String.class); |
|||
|
|||
|
|||
Map<String, String> tempMap = new HashMap<>(); |
|||
//待发放碳配额 |
|||
tempMap.put("pendingPercent", new BigDecimal(sum1).divide(new BigDecimal(sum), 2, RoundingMode.HALF_UP).toPlainString()); |
|||
//已发放碳配额 |
|||
tempMap.put("issuedPercent", new BigDecimal(sum2).divide(new BigDecimal(sum), 2, RoundingMode.HALF_UP).toPlainString()); |
|||
tempMap.put("pending",sum1); |
|||
tempMap.put("issued",sum2); |
|||
tempMap.put("total",sum); |
|||
tempMap.put("balance",new BigDecimal(sum).subtract(new BigDecimal(StringUtils.isBlank(sumBalance)? "0" : sumBalance)).toPlainString()); |
|||
return tempMap; |
|||
} |
|||
/** |
|||
* 获取指定小镇的减排量占比 |
|||
* @return 返回所有指定小镇的减排量占比 |
|||
*/ |
|||
@Override |
|||
public List<Map<String, String>> getEmissionReductionPercentagesByState() { |
|||
// 示例区域列表,可根据实际情况查询数据库中的区域列表 |
|||
// 查询区域和碳配额总和 |
|||
QueryWrapper queryWrapper4 = QueryWrapper.create() |
|||
.select(QY_CARBON_QUOTA_INFO_ENTITY.REGION,sum(QY_CARBON_QUOTA_INFO_ENTITY.TOTAL).as("total") ) |
|||
.from(QY_CARBON_QUOTA_INFO_ENTITY) |
|||
.groupBy(QY_CARBON_QUOTA_INFO_ENTITY.REGION); |
|||
// 查询符合条件的小镇碳配额数据 |
|||
List<QyCarbonSumQuotaInfoDTO> quotaList1 = mapper.selectListByQueryAs(queryWrapper4,QyCarbonSumQuotaInfoDTO.class); |
|||
//查询总量 |
|||
QueryWrapper queryWrapper5 = QueryWrapper.create() |
|||
.select(sum(QY_CARBON_QUOTA_INFO_ENTITY.TOTAL).as("total") ) |
|||
.from(QY_CARBON_QUOTA_INFO_ENTITY); |
|||
String sumtotal = mapper.selectOneByQueryAs(queryWrapper5, String.class); |
|||
// 存储最终结果 |
|||
List<Map<String, String>> resultList = new ArrayList<>(); |
|||
List<String> tempRegions = Lists.newArrayList(); |
|||
for (QyCarbonSumQuotaInfoDTO quotaInfoDTO : quotaList1) { |
|||
Map<String, String> tempMap = new HashMap<>(); |
|||
//占比 |
|||
tempMap.put("percent", quotaInfoDTO.getTotal().divide(new BigDecimal(sumtotal), 2, RoundingMode.HALF_UP).toString()); |
|||
tempMap.put("region", quotaInfoDTO.getRegion()); |
|||
resultList.add(tempMap); |
|||
tempRegions.add(quotaInfoDTO.getRegion()); |
|||
} |
|||
//差集 |
|||
Collection<String> disjunction = CollectionUtil.disjunction(Constant.REGIONS, tempRegions); |
|||
for (String s : disjunction) { |
|||
Map<String, String> tempMap = new HashMap<>(); |
|||
tempMap.put("percent", "0"); |
|||
tempMap.put("region", s); |
|||
resultList.add(tempMap); |
|||
} |
|||
return resultList; |
|||
} |
|||
|
|||
} |
|||
@ -1,183 +0,0 @@ |
|||
package com.thing.qingyuan.carbon.service.impl; |
|||
|
|||
import cn.hutool.core.collection.CollectionUtil; |
|||
import com.google.common.collect.Lists; |
|||
import com.mybatisflex.core.query.QueryWrapper; |
|||
import com.thing.common.orm.service.impl.BaseServiceImpl; |
|||
import com.thing.qingyuan.carbon.dto.QyCcerInfoDTO; |
|||
import com.thing.qingyuan.carbon.entity.QyCcerInfoEntity; |
|||
import com.thing.qingyuan.carbon.mapper.QyCcerInfoMapper; |
|||
import com.thing.qingyuan.carbon.service.QyCcerInfoService; |
|||
import com.thing.qingyuan.carbon.util.Constant; |
|||
import org.apache.commons.lang3.StringUtils; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
import java.math.BigDecimal; |
|||
import java.math.RoundingMode; |
|||
import java.time.LocalDate; |
|||
import java.time.ZoneId; |
|||
import java.util.*; |
|||
|
|||
import static com.mybatisflex.core.query.QueryMethods.sum; |
|||
import static com.thing.qingyuan.carbon.entity.table.QyCcerInfoEntityTableDef.QY_CCER_INFO_ENTITY; |
|||
|
|||
|
|||
@Service |
|||
public class QyCcerInfoServiceImpl extends BaseServiceImpl<QyCcerInfoMapper, QyCcerInfoEntity> implements QyCcerInfoService { |
|||
|
|||
|
|||
@Override |
|||
public QueryWrapper getWrapper(Map<String, Object> params) { |
|||
QueryWrapper qw = new QueryWrapper(); |
|||
|
|||
// 判断并处理查询参数 |
|||
if (params != null) { |
|||
// 根据项目名称查询 |
|||
if (params.containsKey("name") && params.get("name") != null) { |
|||
qw.like("name", params.get("name")); |
|||
} |
|||
// 根据CCER状态查询 |
|||
if (params.containsKey("state") && params.get("state") != null) { |
|||
qw.eq("state", params.get("state")); |
|||
} |
|||
// 根据所属企业查询 |
|||
if (params.containsKey("belongCompany") && params.get("belongCompany") != null) { |
|||
qw.like("belongCompany", params.get("belongCompany")); |
|||
} |
|||
// 根据所属区域查询 |
|||
if (params.containsKey("belongRegion") && params.get("belongRegion") != null) { |
|||
qw.like("belongRegion", params.get("belongRegion")); |
|||
} |
|||
// 根据所属小镇查询 |
|||
if (params.containsKey("belongTown") && params.get("belongTown") != null) { |
|||
qw.like("belongTown", params.get("belongTown")); |
|||
} |
|||
// 根据创建时间范围查询 |
|||
if (params.containsKey("createDateStart") && params.get("createDateStart") != null) { |
|||
qw.ge("createDate", params.get("createDateStart")); // >= |
|||
} |
|||
if (params.containsKey("createDateEnd") && params.get("createDateEnd") != null) { |
|||
qw.le("createDate", params.get("createDateEnd")); // <= |
|||
} |
|||
// 根据更新者查询 |
|||
if (params.containsKey("updater") && params.get("updater") != null) { |
|||
qw.eq("updater", params.get("updater")); |
|||
} |
|||
// 根据租户编码查询 |
|||
if (params.containsKey("tenantCode") && params.get("tenantCode") != null) { |
|||
qw.eq("tenantCode", params.get("tenantCode")); |
|||
} |
|||
// 根据成交量查询 |
|||
if (params.containsKey("transactionVolume") && params.get("transactionVolume") != null) { |
|||
qw.like("transactionVolume", params.get("transactionVolume")); |
|||
} |
|||
} |
|||
|
|||
return qw; |
|||
} |
|||
|
|||
/** |
|||
* 根据状态统计ccer数量 |
|||
* |
|||
* @return 个状态的ccer数量 |
|||
*/ |
|||
@Override |
|||
public Map<String, String> countCcerByState() { |
|||
QueryWrapper queryWrapper1 = QueryWrapper.create() |
|||
.select(sum(QY_CCER_INFO_ENTITY.TOTAL)) |
|||
.from(QY_CCER_INFO_ENTITY) |
|||
.eq(QyCcerInfoEntity::getState, "1"); |
|||
//sum1 待申请CCER |
|||
String sum1 = mapper.selectOneByQueryAs(queryWrapper1, String.class); |
|||
QueryWrapper queryWrapper2 = QueryWrapper.create() |
|||
.select(sum(QY_CCER_INFO_ENTITY.TOTAL)) |
|||
.from(QY_CCER_INFO_ENTITY) |
|||
.eq(QyCcerInfoEntity::getState, "2"); |
|||
//sum2 已申请CCER |
|||
String sum2 = mapper.selectOneByQueryAs(queryWrapper2, String.class); |
|||
QueryWrapper queryWrapper3 = QueryWrapper.create() |
|||
.select(sum(QY_CCER_INFO_ENTITY.TOTAL)) |
|||
.from(QY_CCER_INFO_ENTITY); |
|||
//sum3 累计CCER(sum=sum1+sum2) |
|||
String sum3 = mapper.selectOneByQueryAs(queryWrapper3, String.class); |
|||
|
|||
HashMap<String, String> temMap = new HashMap<>(); |
|||
//待申请CCER |
|||
temMap.put("pending", StringUtils.isBlank(sum1) ? "0" : sum1); |
|||
//已申请CCER |
|||
temMap.put("applied", StringUtils.isBlank(sum2) ? "0" : sum2); |
|||
//累计CCER |
|||
temMap.put("total", StringUtils.isBlank(sum3) ? "0" : sum3); |
|||
|
|||
// 获取今天的日期 |
|||
LocalDate today = LocalDate.now(); |
|||
// 将今天的日期转换为 Date 类型 |
|||
Long startOfDay = today.atStartOfDay(ZoneId.systemDefault()).toInstant().toEpochMilli(); |
|||
Long endOfDay = today.atTime(23, 59, 59, 999999999) |
|||
.atZone(ZoneId.systemDefault()) |
|||
.toInstant() |
|||
.toEpochMilli(); |
|||
|
|||
QueryWrapper queryWrapperDay = QueryWrapper.create() |
|||
.select(sum(QY_CCER_INFO_ENTITY.TOTAL)) |
|||
.from(QY_CCER_INFO_ENTITY) |
|||
.ge(QyCcerInfoEntity::getIssueDate, startOfDay) |
|||
.le(QyCcerInfoEntity::getIssueDate, endOfDay) |
|||
; |
|||
String todayTotal = mapper.selectOneByQueryAs(queryWrapperDay, String.class); |
|||
temMap.put("todayTotal", StringUtils.isBlank(todayTotal) ? "0" : todayTotal); |
|||
QueryWrapper queryWrapperDay1 = QueryWrapper.create() |
|||
.select(sum(QY_CCER_INFO_ENTITY.PRICE)) |
|||
.from(QY_CCER_INFO_ENTITY) |
|||
.ge(QyCcerInfoEntity::getIssueDate, startOfDay) |
|||
.le(QyCcerInfoEntity::getIssueDate, endOfDay) |
|||
; |
|||
String todayPriceTotal = mapper.selectOneByQueryAs(queryWrapperDay1, String.class); |
|||
temMap.put("todayPriceTotal", StringUtils.isBlank(todayPriceTotal) ? "0" : todayPriceTotal); |
|||
return temMap; |
|||
} |
|||
|
|||
/** |
|||
* 获取指定小镇的减排量占比 |
|||
* |
|||
* @return 返回所有指定小镇的减排量占比 |
|||
*/ |
|||
@Override |
|||
public List<Map<String, String>> getByRegion() { |
|||
// 根据区域查询成交量总和 |
|||
QueryWrapper queryWrapper = QueryWrapper.create() |
|||
.select(QY_CCER_INFO_ENTITY.REGION, sum(QY_CCER_INFO_ENTITY.TOTAL).as("total")) |
|||
.from(QY_CCER_INFO_ENTITY) |
|||
.groupBy(QY_CCER_INFO_ENTITY.REGION); |
|||
// 查询符合条件的小镇成交量数据 |
|||
List<QyCcerInfoDTO> quotaList1 = mapper.selectListByQueryAs(queryWrapper, QyCcerInfoDTO.class); |
|||
//查询总量 |
|||
QueryWrapper queryWrapper2 = QueryWrapper.create() |
|||
.select(sum(QY_CCER_INFO_ENTITY.TOTAL)) |
|||
.from(QY_CCER_INFO_ENTITY); |
|||
String sumTotal = mapper.selectOneByQueryAs(queryWrapper2, String.class); |
|||
// 存储最终结果 |
|||
List<Map<String, String>> resultList = new ArrayList<>(); |
|||
List<String> tempRegions = Lists.newArrayList(); |
|||
for (QyCcerInfoDTO quotaInfoDTO : quotaList1) { |
|||
Map<String, String> tempMap = new HashMap<>(); |
|||
//占比 |
|||
tempMap.put("percent", quotaInfoDTO.getTotal().divide(new BigDecimal(sumTotal), 2, RoundingMode.HALF_UP).toString()); |
|||
tempMap.put("region", quotaInfoDTO.getRegion()); |
|||
resultList.add(tempMap); |
|||
tempRegions.add(quotaInfoDTO.getRegion()); |
|||
} |
|||
//差集 |
|||
Collection<String> disjunction = CollectionUtil.disjunction(Constant.REGIONS, tempRegions); |
|||
for (String s : disjunction) { |
|||
Map<String, String> tempMap = new HashMap<>(); |
|||
tempMap.put("percent", "0"); |
|||
tempMap.put("region", s); |
|||
resultList.add(tempMap); |
|||
} |
|||
return resultList; |
|||
} |
|||
|
|||
|
|||
} |
|||
|
|||
@ -1,153 +0,0 @@ |
|||
package com.thing.qingyuan.carbon.service.impl; |
|||
|
|||
|
|||
import cn.hutool.core.collection.CollectionUtil; |
|||
import com.google.common.collect.Lists; |
|||
import com.mybatisflex.core.query.QueryWrapper; |
|||
import com.thing.common.orm.service.impl.BaseServiceImpl; |
|||
import com.thing.qingyuan.carbon.dto.QyGreenCertificateInfoDTO; |
|||
import com.thing.qingyuan.carbon.entity.QyGreenCertificateInfoEntity; |
|||
import com.thing.qingyuan.carbon.mapper.QyGreenCertificateInfoMapper; |
|||
import com.thing.qingyuan.carbon.service.QyGreenCertificateInfoService; |
|||
import com.thing.qingyuan.carbon.util.Constant; |
|||
import org.apache.commons.lang3.StringUtils; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
import java.math.BigDecimal; |
|||
import java.math.RoundingMode; |
|||
import java.time.LocalDate; |
|||
import java.time.ZoneId; |
|||
import java.util.*; |
|||
|
|||
import static com.mybatisflex.core.query.QueryMethods.sum; |
|||
import static com.thing.qingyuan.carbon.entity.table.QyGreenCertificateInfoEntityTableDef.QY_GREEN_CERTIFICATE_INFO_ENTITY; |
|||
|
|||
|
|||
@Service |
|||
public class QyGreenCertificateInfoServiceImpl extends BaseServiceImpl<QyGreenCertificateInfoMapper, QyGreenCertificateInfoEntity> implements QyGreenCertificateInfoService { |
|||
@Override |
|||
public QueryWrapper getWrapper(Map<String, Object> params) { |
|||
QueryWrapper qw = new QueryWrapper(); |
|||
// 根据 params 添加条件 |
|||
if (params.containsKey("state")) { |
|||
qw.eq("state", params.get("state")); |
|||
} |
|||
if (params.containsKey("powerType")) { |
|||
qw.eq("powerType", params.get("powerType")); |
|||
} |
|||
if (params.containsKey("region")) { |
|||
qw.eq("region", params.get("region")); |
|||
} |
|||
if (params.containsKey("applicationDate")) { |
|||
qw.ge("applicationDate", params.get("applicationDate")); |
|||
} |
|||
if (params.containsKey("dateIssue")) { |
|||
qw.ge("dateIssue", params.get("dateIssue")); |
|||
} |
|||
|
|||
return qw; |
|||
} |
|||
|
|||
/** |
|||
* 获取根据状态统计的绿证数量 |
|||
* |
|||
* @return 各状态的绿证数量 |
|||
*/ |
|||
@Override |
|||
public Map<String, String> countGreenByState() { |
|||
QueryWrapper queryWrapper1 = QueryWrapper.create() |
|||
.select(sum(QY_GREEN_CERTIFICATE_INFO_ENTITY.TOTAL)) |
|||
.from(QY_GREEN_CERTIFICATE_INFO_ENTITY) |
|||
.eq(QyGreenCertificateInfoEntity::getState, "1"); |
|||
//sum1 为待发放绿证 |
|||
String sum1 = mapper.selectOneByQueryAs(queryWrapper1, String.class); |
|||
|
|||
QueryWrapper queryWrapper2 = QueryWrapper.create() |
|||
.select(sum(QY_GREEN_CERTIFICATE_INFO_ENTITY.TOTAL)) |
|||
.from(QY_GREEN_CERTIFICATE_INFO_ENTITY) |
|||
.eq(QyGreenCertificateInfoEntity::getState, "2"); |
|||
//sum1 为已申请绿证 |
|||
String sum2 = mapper.selectOneByQueryAs(queryWrapper2, String.class); |
|||
|
|||
QueryWrapper queryWrapper3 = QueryWrapper.create() |
|||
.select(sum(QY_GREEN_CERTIFICATE_INFO_ENTITY.TOTAL).as("total")) |
|||
.from(QY_GREEN_CERTIFICATE_INFO_ENTITY); |
|||
//sum1 为累计绿证 (sum=sum1+sum2) |
|||
String sum = mapper.selectOneByQueryAs(queryWrapper3, String.class); |
|||
// 获取今天的日期 |
|||
LocalDate today = LocalDate.now(); |
|||
Long startOfDay = today.atStartOfDay(ZoneId.systemDefault()).toInstant().toEpochMilli(); |
|||
Long endOfDay = today.atTime(23, 59, 59, 999999999) |
|||
.atZone(ZoneId.systemDefault()) |
|||
.toInstant() |
|||
.toEpochMilli(); |
|||
|
|||
QueryWrapper queryWrapperPrice = QueryWrapper.create() |
|||
.select(sum(QY_GREEN_CERTIFICATE_INFO_ENTITY.PRICE)) |
|||
.from(QY_GREEN_CERTIFICATE_INFO_ENTITY) |
|||
.ge(QyGreenCertificateInfoEntity::getIssueDate, startOfDay) |
|||
.le(QyGreenCertificateInfoEntity::getIssueDate, endOfDay); |
|||
String sum2Price = mapper.selectOneByQueryAs(queryWrapperPrice, String.class); |
|||
|
|||
QueryWrapper queryWrapperTotal = QueryWrapper.create() |
|||
.select(sum(QY_GREEN_CERTIFICATE_INFO_ENTITY.TOTAL)) |
|||
.from(QY_GREEN_CERTIFICATE_INFO_ENTITY) |
|||
.ge(QyGreenCertificateInfoEntity::getIssueDate, startOfDay) |
|||
.le(QyGreenCertificateInfoEntity::getIssueDate, endOfDay); |
|||
String sum2Total = mapper.selectOneByQueryAs(queryWrapperTotal, String.class); |
|||
|
|||
Map<String, String> temMap = new HashMap<>(); |
|||
//待发放绿证 |
|||
temMap.put("pending", StringUtils.isBlank(sum1) ? "0" : sum1); |
|||
//已申请绿证 |
|||
temMap.put("applied", StringUtils.isBlank(sum2) ? "0" : sum2); |
|||
//累计绿证 |
|||
temMap.put("total", StringUtils.isBlank(sum) ? "0" : sum); |
|||
temMap.put("todayPrice", StringUtils.isBlank(sum2Price) ? "0" : sum2Price); |
|||
temMap.put("todayTotal", StringUtils.isBlank(sum2Total) ? "0" : sum2Total); |
|||
return temMap; |
|||
} |
|||
|
|||
/** |
|||
* 根据区域与小镇统计绿证,并计算每个小镇在所属区域内的绿证占比 |
|||
* |
|||
* @return 返回一个Map, 包含每个区域下每个小镇的绿证占比 |
|||
*/ |
|||
@Override |
|||
public List<Map<String, String>> getRegionGreenCertificatePercentage() { |
|||
// 根据区域查询成绿证总和 |
|||
QueryWrapper queryWrapper = QueryWrapper.create() |
|||
.select(QY_GREEN_CERTIFICATE_INFO_ENTITY.REGION, sum(QY_GREEN_CERTIFICATE_INFO_ENTITY.TOTAL).as("total")) |
|||
.from(QY_GREEN_CERTIFICATE_INFO_ENTITY) |
|||
.groupBy(QY_GREEN_CERTIFICATE_INFO_ENTITY.REGION); |
|||
// 查询符合条件的小镇绿证数据 |
|||
List<QyGreenCertificateInfoDTO> qyGreenSumInfoDTOList = mapper.selectListByQueryAs(queryWrapper, QyGreenCertificateInfoDTO.class); |
|||
//查询绿证总能源量 |
|||
QueryWrapper queryWrapper6 = QueryWrapper.create() |
|||
.select(sum(QY_GREEN_CERTIFICATE_INFO_ENTITY.TOTAL).as("total")) |
|||
.from(QY_GREEN_CERTIFICATE_INFO_ENTITY); |
|||
String sumTotal = mapper.selectOneByQueryAs(queryWrapper6, String.class); |
|||
//存储最终结果 |
|||
List<Map<String, String>> resultList = new ArrayList<>(); |
|||
List<String> tempRegions = Lists.newArrayList(); |
|||
for (QyGreenCertificateInfoDTO qyGreenSumInfoDTO : qyGreenSumInfoDTOList) { |
|||
Map<String, String> tempMap = new HashMap<>(); |
|||
//占比 |
|||
tempMap.put("percent", qyGreenSumInfoDTO.getTotal().divide(new BigDecimal(sumTotal), 2, RoundingMode.HALF_UP).toString()); |
|||
tempMap.put("region", qyGreenSumInfoDTO.getRegion()); |
|||
resultList.add(tempMap); |
|||
tempRegions.add(qyGreenSumInfoDTO.getRegion()); |
|||
} |
|||
//差集 |
|||
Collection<String> disjunction = CollectionUtil.disjunction(Constant.REGIONS, tempRegions); |
|||
for (String s : disjunction) { |
|||
Map<String, String> tempMap = new HashMap<>(); |
|||
tempMap.put("percent", "0"); |
|||
tempMap.put("region", s); |
|||
resultList.add(tempMap); |
|||
} |
|||
return resultList; |
|||
} |
|||
|
|||
} |
|||
|
|||
@ -1,55 +0,0 @@ |
|||
package com.thing.qingyuan.carbon.service.impl; |
|||
|
|||
|
|||
import com.mybatisflex.core.query.QueryWrapper; |
|||
import com.thing.common.orm.service.impl.BaseServiceImpl; |
|||
import com.thing.qingyuan.carbon.dto.QyRegionDTO; |
|||
import com.thing.qingyuan.carbon.entity.QyRegionEntity; |
|||
import com.thing.qingyuan.carbon.mapper.QyRegionMapper; |
|||
import com.thing.qingyuan.carbon.service.QyRegionService; |
|||
import jakarta.annotation.Resource; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
import java.util.List; |
|||
import java.util.Map; |
|||
import java.util.stream.Collectors; |
|||
|
|||
@Service |
|||
public class QyRegionServiceImpl extends BaseServiceImpl<QyRegionMapper, QyRegionEntity> implements QyRegionService { |
|||
|
|||
@Resource |
|||
private QyRegionMapper qyRegionMapper; |
|||
|
|||
@Override |
|||
public QueryWrapper getWrapper(Map<String, Object> params) { |
|||
QueryWrapper qw = new QueryWrapper(); |
|||
// 判断传入的参数是否为空,如果不为空则构建查询条件 |
|||
if (params.containsKey("name")) { |
|||
qw.like("name", params.get("name")); |
|||
} |
|||
|
|||
if (params.containsKey("type")) { |
|||
qw.eq("type", params.get("type")); |
|||
} |
|||
|
|||
return qw; |
|||
} |
|||
|
|||
/** |
|||
* 获取所有区域列表 |
|||
* @return 所以区域的DTO列表 |
|||
*/ |
|||
@Override |
|||
public List<QyRegionDTO> getAllRegions() { |
|||
try { |
|||
//获取所有区域 |
|||
List<QyRegionDTO> regions = qyRegionMapper.findAll(); |
|||
return regions.stream() |
|||
.map(region -> new QyRegionDTO(region.getId(), region.getName())) |
|||
.collect(Collectors.toList()); |
|||
}catch (Exception e){ |
|||
throw new RuntimeException("获取区域列表失败",e); |
|||
} |
|||
} |
|||
|
|||
} |
|||
@ -1,17 +0,0 @@ |
|||
package com.thing.qingyuan.carbon.util; |
|||
|
|||
import java.util.Collections; |
|||
import java.util.List; |
|||
|
|||
public interface Constant { |
|||
|
|||
// 使用不可修改的List,保证常量不可变 |
|||
List<String> REGIONS = Collections.unmodifiableList( |
|||
List.of("天玉镇", "河东街道", "富滩镇", "值夏镇", "文陂镇", "富田镇", "东固畲族乡", "新圩镇") |
|||
); |
|||
|
|||
List<String> STATES = Collections.unmodifiableList( |
|||
List.of("1", "2", "3", "4", "5") |
|||
); |
|||
|
|||
} |
|||
@ -1,41 +0,0 @@ |
|||
package com.thing.qingyuan.chargeStation.config; |
|||
|
|||
import lombok.Data; |
|||
import org.springframework.boot.context.properties.ConfigurationProperties; |
|||
import org.springframework.stereotype.Component; |
|||
|
|||
import java.util.List; |
|||
import java.util.Objects; |
|||
|
|||
/** |
|||
* @author SiYang |
|||
* @date 2024/01/29 14:17 |
|||
* @description 充电站配置属性 |
|||
*/ |
|||
@Data |
|||
@Component |
|||
@ConfigurationProperties(prefix = "qingyuan.charge-station") |
|||
public class StationProperties { |
|||
|
|||
private Long relationId; |
|||
|
|||
private List<Operator> operators; |
|||
|
|||
@Data |
|||
public static class Operator { |
|||
private String id; |
|||
private String name; |
|||
} |
|||
|
|||
public String getOperatorNameById(String id) { |
|||
Operator operator = getOperatorById(id); |
|||
return Objects.isNull(operator) ? null : operator.getName(); |
|||
} |
|||
|
|||
private Operator getOperatorById(String id) { |
|||
return operators.stream() |
|||
.filter(e -> Objects.equals(id, e.getId())) |
|||
.findFirst() |
|||
.orElse(null); |
|||
} |
|||
} |
|||
@ -1,65 +0,0 @@ |
|||
package com.thing.qingyuan.chargeStation.controller; |
|||
|
|||
import com.thing.common.core.constants.Constant; |
|||
import com.thing.common.core.web.response.PageData; |
|||
import com.thing.common.core.web.response.Result; |
|||
import com.thing.qingyuan.chargeStation.dto.ChargeOrderHeadDTO; |
|||
import com.thing.qingyuan.chargeStation.service.ChargeOrderHeadService; |
|||
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.apache.commons.lang3.StringUtils; |
|||
import org.springframework.web.bind.annotation.*; |
|||
|
|||
import java.util.Map; |
|||
|
|||
/** |
|||
* 充电桩订单头 |
|||
* |
|||
* @author system system@lrd.com |
|||
* @since 5.1 2024-01-23 |
|||
*/ |
|||
@RestController |
|||
@RequestMapping("chargeStation/order/head") |
|||
@Tag(name="充电桩订单头") |
|||
@RequiredArgsConstructor |
|||
public class ChargeOrderHeadController { |
|||
|
|||
private final ChargeOrderHeadService chargeOrderHeadService; |
|||
|
|||
@GetMapping("page") |
|||
@Operation(summary="分页") |
|||
@Parameters({ |
|||
@Parameter(name = Constant.PAGE, description = "当前页码,从1开始", required = true) , |
|||
@Parameter(name = Constant.LIMIT, description = "每页显示记录数", required = true) , |
|||
@Parameter(name = Constant.ORDER_FIELD, description = "排序字段") , |
|||
@Parameter(name = Constant.ORDER, description = "排序方式,可选值(asc、desc)"), |
|||
@Parameter(name = Constant.BEGIN_TIME, description = "开始时间"), |
|||
@Parameter(name = Constant.END_TIME, description = "结束时间"), |
|||
@Parameter(name = "startChargeSeq", description = "订单号"), |
|||
@Parameter(name = "stationId", description = "充电站编码"), |
|||
@Parameter(name = "equipmentId", description = "充电桩编码"), |
|||
@Parameter(name = "connectorId", description = "充电枪编码"), |
|||
}) |
|||
public Result<PageData<ChargeOrderHeadDTO>> page(@Parameter(hidden = true) @RequestParam Map<String, Object> params){ |
|||
String order = StringUtils.isBlank((String) params.get(Constant.ORDER)) ? "desc" : (String) params.get(Constant.ORDER); |
|||
String orderField = StringUtils.isBlank((String) params.get(Constant.ORDER_FIELD)) ? "start_time" : (String) params.get(Constant.ORDER_FIELD); |
|||
params.put(Constant.ORDER, order); |
|||
params.put(Constant.ORDER_FIELD, orderField); |
|||
PageData<ChargeOrderHeadDTO> page = chargeOrderHeadService.handlePage(params); |
|||
return new Result<PageData<ChargeOrderHeadDTO>>().ok(page); |
|||
} |
|||
|
|||
@GetMapping("{startChargeSeq}") |
|||
@Operation(summary="充电详情") |
|||
@Parameters({ |
|||
@Parameter(name = "startChargeSeq", description = "订单号"), |
|||
}) |
|||
public Result<ChargeOrderHeadDTO> get(@PathVariable("startChargeSeq") String startChargeSeq){ |
|||
ChargeOrderHeadDTO data = chargeOrderHeadService.getDetails(startChargeSeq); |
|||
return new Result<ChargeOrderHeadDTO>().ok(data); |
|||
} |
|||
|
|||
} |
|||
@ -1,44 +0,0 @@ |
|||
package com.thing.qingyuan.chargeStation.controller; |
|||
|
|||
import com.thing.qingyuan.chargeStation.dto.ChargeStatisticReportResp; |
|||
import com.thing.qingyuan.chargeStation.dto.ChargeStatisticRequest; |
|||
import com.thing.qingyuan.chargeStation.service.ChargeStatisticService; |
|||
import com.thing.common.core.web.response.Result; |
|||
import io.swagger.v3.oas.annotations.Operation; |
|||
import io.swagger.v3.oas.annotations.tags.Tag; |
|||
import jakarta.servlet.http.HttpServletResponse; |
|||
import lombok.RequiredArgsConstructor; |
|||
import org.springframework.web.bind.annotation.PostMapping; |
|||
import org.springframework.web.bind.annotation.RequestBody; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
|
|||
import java.util.List; |
|||
|
|||
/** |
|||
* 充电统计 |
|||
* |
|||
* @author system system@lrd.com |
|||
* @since 5.1 2024-01-23 |
|||
*/ |
|||
@RestController |
|||
@RequestMapping("chargeStation/statistic") |
|||
@Tag(name = "充电统计") |
|||
@RequiredArgsConstructor |
|||
public class ChargeStatisticController { |
|||
|
|||
private final ChargeStatisticService service; |
|||
|
|||
@PostMapping("report") |
|||
@Operation(summary = "充电统计报表") |
|||
public Result<List<ChargeStatisticReportResp>> page(@RequestBody ChargeStatisticRequest request) { |
|||
List<ChargeStatisticReportResp> data = service.getReport(request); |
|||
return new Result<List<ChargeStatisticReportResp>>().ok(data); |
|||
} |
|||
|
|||
@PostMapping("report/export") |
|||
@Operation(summary="充电统计报表导出") |
|||
public void export(@RequestBody ChargeStatisticRequest request, HttpServletResponse response) { |
|||
service.export(request, response); |
|||
} |
|||
} |
|||
@ -1,91 +0,0 @@ |
|||
package com.thing.qingyuan.chargeStation.controller; |
|||
|
|||
import cn.hutool.core.map.MapUtil; |
|||
import com.thing.qingyuan.chargeStation.dto.IdNameDTO; |
|||
import com.thing.qingyuan.chargeStation.dto.StationDeviceDetail; |
|||
import com.thing.qingyuan.chargeStation.dto.StationInfoDTO; |
|||
import com.thing.qingyuan.chargeStation.dto.StationSimpleInfo; |
|||
import com.thing.qingyuan.chargeStation.service.StationInfoService; |
|||
import com.thing.common.core.constants.Constant; |
|||
import com.thing.common.core.web.response.PageData; |
|||
import com.thing.common.core.web.response.Result; |
|||
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.GetMapping; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RequestParam; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
|
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
/** |
|||
* 充电站信息 |
|||
* |
|||
* @author ssy 2337720667@qq.com |
|||
* @since 3.0 2024-01-23 |
|||
*/ |
|||
@RestController |
|||
@RequestMapping("chargeStation/station") |
|||
@Tag(name = "充电站信息") |
|||
@RequiredArgsConstructor |
|||
public class StationInfoController { |
|||
|
|||
private final StationInfoService stationInfoService; |
|||
|
|||
@GetMapping("page") |
|||
@Operation(summary = "分页") |
|||
@Parameters({ |
|||
@Parameter(name = Constant.PAGE, description = "当前页码,从1开始", required = true), |
|||
@Parameter(name = Constant.LIMIT, description = "每页显示记录数", required = true), |
|||
@Parameter(name = Constant.ORDER_FIELD, description = "排序字段"), |
|||
@Parameter(name = Constant.ORDER, description = "排序方式,可选值(asc、desc)"), |
|||
@Parameter(name = "areaCode", description = "区域编码"), |
|||
@Parameter(name = "operatorId", description = "运营商id"), |
|||
@Parameter(name = "keyword", description = "充电站名称关键字"), |
|||
}) |
|||
public Result<PageData<StationInfoDTO>> page(@Parameter(hidden = true) @RequestParam Map<String, Object> params) { |
|||
params.putIfAbsent(Constant.ORDER_FIELD, "station_id"); |
|||
PageData<StationInfoDTO> page = stationInfoService.handlePage(params); |
|||
return new Result<PageData<StationInfoDTO>>().ok(page); |
|||
} |
|||
|
|||
@GetMapping("simple/list") |
|||
@Operation(summary="简要信息列表") |
|||
public Result<List<StationSimpleInfo>> simpleList(){ |
|||
List<StationSimpleInfo> list = stationInfoService.simpleList(); |
|||
return new Result<List<StationSimpleInfo>>().ok(list); |
|||
} |
|||
|
|||
@GetMapping("pile/or/gun/idName") |
|||
@Operation(summary="充电桩或充电枪的id-name列表") |
|||
@Parameters({ |
|||
@Parameter(name = "type", description = "pile:充电桩, gun:充电枪"), |
|||
@Parameter(name = "pid", description = "上级id"), |
|||
}) |
|||
public Result<List<IdNameDTO>> getIdNameList(@Parameter(hidden = true) @RequestParam Map<String, Object> params) { |
|||
List<IdNameDTO> list = stationInfoService.getIdNameList(params); |
|||
return new Result<List<IdNameDTO>>().ok(list); |
|||
} |
|||
|
|||
@GetMapping("details") |
|||
@Operation(summary = "信息") |
|||
@Parameters({ |
|||
@Parameter(name = "stationId", description = "充电站编码(id)"), |
|||
}) |
|||
public Result<StationDeviceDetail> getDetails(@Parameter(hidden = true) @RequestParam Map<String, Object> params) { |
|||
String stationId = MapUtil.getStr(params, "stationId"); |
|||
StationDeviceDetail data = stationInfoService.getDetails(stationId); |
|||
return new Result<StationDeviceDetail>().ok(data); |
|||
} |
|||
|
|||
@GetMapping("generate/thing/config") |
|||
@Operation(summary = "一键生成物模型、物实体、物指标、物关系、数据源配置") |
|||
public Result<Void> get() { |
|||
stationInfoService.generateThingConfig(); |
|||
return new Result<>(); |
|||
} |
|||
} |
|||
@ -1,84 +0,0 @@ |
|||
package com.thing.qingyuan.chargeStation.dto; |
|||
|
|||
import com.thing.common.core.utils.DateTimeUtils; |
|||
import com.thing.common.data.proto.QueueProto; |
|||
import com.thing.common.data.proto.QueueProto.DataProto; |
|||
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.ArrayList; |
|||
import java.util.List; |
|||
import java.util.Objects; |
|||
import java.util.stream.Collectors; |
|||
|
|||
/** |
|||
* 充电桩订单明细 |
|||
* |
|||
* @author system system@lrd.com |
|||
* @since 5.1 2024-01-23 |
|||
*/ |
|||
@Data |
|||
@Schema(description = "充电桩订单明细") |
|||
public class ChargeOrderDetailsDTO implements Serializable { |
|||
@Serial |
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
private Long id; |
|||
@Schema(description = "充电订单号;运营商ID+唯一编号") |
|||
private String startChargeSeq; |
|||
@Schema(description = "充电设备接口编码") |
|||
private String connectorId; |
|||
@Schema(description = "结束时间;格式,yyyy-MM-dd HH: mm: ss") |
|||
private String endTime; |
|||
@Schema(description = "开始时间") |
|||
private String startTime; |
|||
@Schema(description = "A相电流") |
|||
private BigDecimal currentA; |
|||
@Schema(description = "B相电流") |
|||
private BigDecimal currentB; |
|||
@Schema(description = "C相电流") |
|||
private BigDecimal currentC; |
|||
@Schema(description = "A相电压") |
|||
private BigDecimal voltageA; |
|||
@Schema(description = "B相电压") |
|||
private BigDecimal voltageB; |
|||
@Schema(description = "C相电压") |
|||
private BigDecimal voltageC; |
|||
@Schema(description = "电池剩余电量,单位:%") |
|||
private BigDecimal soc; |
|||
@Schema(description = "时段充电量,单位:度(kwh)") |
|||
private BigDecimal totalPower; |
|||
|
|||
public List<DataProto> toProtoDataList() { |
|||
List<DataProto> dataProtoList = new ArrayList<>(); |
|||
Long ts = DateTimeUtils.convertTimeToLong(endTime); |
|||
dataProtoList.add(toProtoData(connectorId, "A8", currentA, ts)); |
|||
dataProtoList.add(toProtoData(connectorId, "A9", currentB, ts)); |
|||
dataProtoList.add(toProtoData(connectorId, "A10", currentC, ts)); |
|||
dataProtoList.add(toProtoData(connectorId, "A1", voltageA, ts)); |
|||
dataProtoList.add(toProtoData(connectorId, "A2", voltageB, ts)); |
|||
dataProtoList.add(toProtoData(connectorId, "A3", voltageC, ts)); |
|||
dataProtoList.add(toProtoData(connectorId, "A203", soc, ts)); |
|||
dataProtoList.add(toProtoData(connectorId, "A229", totalPower, ts)); |
|||
return dataProtoList.stream().filter(Objects::nonNull).collect(Collectors.toList()); |
|||
} |
|||
|
|||
private DataProto toProtoData(String thingCode, String key, BigDecimal val, Long ts) { |
|||
if(Objects.isNull(val)){ |
|||
return null; |
|||
} |
|||
return DataProto.newBuilder() |
|||
.setTskvProto( |
|||
QueueProto.TsKvProto.newBuilder() |
|||
.setThingCode(thingCode) |
|||
.setKey(key) |
|||
.setVal(val.toPlainString()) |
|||
.setTs(ts) |
|||
.build()) |
|||
.build(); |
|||
} |
|||
|
|||
} |
|||
@ -1,83 +0,0 @@ |
|||
package com.thing.qingyuan.chargeStation.dto; |
|||
|
|||
import com.thing.qingyuan.chargeStation.entity.ChargeOrderDetailsEntity; |
|||
import com.thing.common.core.utils.DateTimeUtils; |
|||
import io.swagger.v3.oas.annotations.media.Schema; |
|||
import lombok.Data; |
|||
import lombok.experimental.Accessors; |
|||
|
|||
import java.io.Serial; |
|||
import java.io.Serializable; |
|||
import java.math.BigDecimal; |
|||
import java.util.List; |
|||
import java.util.Objects; |
|||
|
|||
/** |
|||
* 充电桩订单头 |
|||
* |
|||
* @author system system@lrd.com |
|||
* @since 5.1 2024-01-23 |
|||
*/ |
|||
@Data |
|||
@Accessors(chain = true) |
|||
@Schema(description = "充电桩订单头") |
|||
public class ChargeOrderHeadDTO implements Serializable { |
|||
@Serial |
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
@Schema(description = "充电订单号;运营商ID+唯一编号") |
|||
private String startChargeSeq; |
|||
|
|||
@Schema(description = "充电站id") |
|||
private String stationId; |
|||
@Schema(description = "充电站名称") |
|||
private String stationName; |
|||
@Schema(description = "充电桩id") |
|||
private String equipmentId; |
|||
@Schema(description = "充电桩名称") |
|||
private String equipmentName; |
|||
@Schema(description = "充电枪id") |
|||
private String connectorId; |
|||
@Schema(description = "充电枪名称") |
|||
private String connectorName; |
|||
|
|||
@Schema(description = "开始充电时间;格式,yyyy-MM-dd HH: mm: ss") |
|||
private String startTime; |
|||
@Schema(description = "结束充电时间;格式,yyyy-MM-dd HH: mm: ss") |
|||
private String endTime; |
|||
|
|||
@Schema(description = "累计充电量;单位:度, 小数点后2位") |
|||
private BigDecimal totalPower; |
|||
@Schema(description = "总电费;单位:元, 小数点后2位") |
|||
private BigDecimal elecMoney; |
|||
@Schema(description = "总服务费;单位:元, 小数点后2位") |
|||
private BigDecimal seviceMoney; |
|||
@Schema(description = "累计总金额;单位:元, 小数点后2位") |
|||
private BigDecimal totalMoney; |
|||
|
|||
@Schema(description = "充电结束原因;0: 用户手动停止充电; 1:客户归属地运营商平台停止充电; 2: BMS停止充电; 3: 充电机设备故障; 4:连接器断开; 5~99: 自定义") |
|||
private Integer stopReason; |
|||
@Schema(description = "时段数N;范围:0~32") |
|||
private Integer sumPeriod; |
|||
|
|||
@Schema(description = "充电订单状态;1:启动中; 2:充电中; 3:停止中; 4:已结束; 5:未知") |
|||
private Integer startChargeSeqStat; |
|||
|
|||
|
|||
@Schema(description = "订单详情: 电池电量(%)、A相电流、B相电流、C相电流 ...") |
|||
private List<ChargeOrderDetailsEntity> details; |
|||
|
|||
public Long getDuration(){ |
|||
return Objects.isNull(endTime) |
|||
? System.currentTimeMillis() - getStartTs() |
|||
: getEndTs() - getStartTs(); |
|||
} |
|||
|
|||
public Long getStartTs(){ |
|||
return DateTimeUtils.convertTimeToLong(startTime); |
|||
} |
|||
|
|||
public Long getEndTs(){ |
|||
return DateTimeUtils.convertTimeToLong(endTime); |
|||
} |
|||
} |
|||
@ -1,84 +0,0 @@ |
|||
package com.thing.qingyuan.chargeStation.dto; |
|||
|
|||
import com.thing.common.core.utils.DateTimeUtils; |
|||
import com.thing.common.data.tskv.TsKvDTO; |
|||
import io.swagger.v3.oas.annotations.media.Schema; |
|||
import lombok.Data; |
|||
import lombok.experimental.Accessors; |
|||
import org.springframework.util.CollectionUtils; |
|||
|
|||
import java.math.BigDecimal; |
|||
import java.math.RoundingMode; |
|||
import java.time.LocalDateTime; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
import java.util.Objects; |
|||
import java.util.TreeMap; |
|||
|
|||
/** |
|||
* @author SiYang |
|||
* @date 2024/01/31 17:31 |
|||
* @description 充电统计报表数据 |
|||
*/ |
|||
@Data |
|||
@Accessors(chain = true) |
|||
public class ChargeStatisticReportResp { |
|||
@Schema(description = "物id") |
|||
private Long thingId; |
|||
|
|||
@Schema(description = "物名称") |
|||
private String thingName; |
|||
|
|||
@Schema(description = "物编码") |
|||
private String thingCode; |
|||
|
|||
@Schema(description = "属性名称") |
|||
private String attrName; |
|||
|
|||
@Schema(description = "属性编码") |
|||
private String attrCode; |
|||
|
|||
@Schema(description = "属性单位") |
|||
private String unit; |
|||
|
|||
@Schema(description = "时间类型") |
|||
private String timeType; |
|||
|
|||
@Schema(description = "合计数据") |
|||
private BigDecimal total; |
|||
|
|||
@Schema(description = "数据") |
|||
private Map<Long, String> data; |
|||
|
|||
public ChargeStatisticReportResp initData(List<LocalDateTime> timeList) { |
|||
if (Objects.isNull(data)) { |
|||
data = new TreeMap<>(); |
|||
} |
|||
timeList.forEach(t -> data.put(DateTimeUtils.parse(t), null)); |
|||
return this; |
|||
} |
|||
|
|||
public ChargeStatisticReportResp fillData(List<TsKvDTO> tskvList) { |
|||
if(CollectionUtils.isEmpty(tskvList)){ |
|||
return this; |
|||
} |
|||
if (Objects.isNull(data)) { |
|||
data = new TreeMap<>(); |
|||
} |
|||
tskvList.forEach(tskv -> data.put(tskv.getTs(), tskv.getVal())); |
|||
return this; |
|||
} |
|||
|
|||
public ChargeStatisticReportResp calculateTotal() { |
|||
BigDecimal total = |
|||
data.values().stream() |
|||
.filter(Objects::nonNull) |
|||
.map( |
|||
dataStr -> |
|||
BigDecimal.valueOf(Double.parseDouble(dataStr)) |
|||
.setScale(2, RoundingMode.HALF_UP)) |
|||
.reduce(BigDecimal::add) |
|||
.orElse(BigDecimal.ZERO); |
|||
return this.setTotal(total); |
|||
} |
|||
} |
|||
@ -1,94 +0,0 @@ |
|||
package com.thing.qingyuan.chargeStation.dto; |
|||
|
|||
import com.thing.common.core.exception.SysException; |
|||
import com.thing.common.core.utils.DateTimeUtils; |
|||
import io.swagger.v3.oas.annotations.media.Schema; |
|||
import lombok.Data; |
|||
|
|||
import java.time.LocalDateTime; |
|||
import java.util.ArrayList; |
|||
import java.util.List; |
|||
|
|||
/** |
|||
* @author SiYang |
|||
* @date 2024/01/31 17:16 |
|||
* @description 充电统计请求 |
|||
*/ |
|||
@Data |
|||
@Schema(description = "充电统计请求参数") |
|||
public class ChargeStatisticRequest { |
|||
@Schema(description = "关系id") |
|||
private Long rootId; |
|||
|
|||
@Schema(description = "顶级物id列表") |
|||
private List<String> rootThingIds; |
|||
|
|||
@Schema(description = "物id列表") |
|||
private List<Long> thingIds; |
|||
|
|||
@Schema(description = "报表类型=> 充电量: 1; 充电时长: 2; 充电次数: 3") |
|||
private Integer reportType; |
|||
|
|||
@Schema(description = "时间类型:day ,month, year, any") |
|||
private String timeType; |
|||
|
|||
@Schema(description = "开始时间") |
|||
private String beginTime; |
|||
|
|||
@Schema(description = "结束时间") |
|||
private String endTime; |
|||
|
|||
public String getAttrType() { |
|||
return switch (timeType) { |
|||
case "day" -> "hh"; |
|||
case "month", "any" -> "dd"; |
|||
case "year" -> "mm"; |
|||
default -> throw new SysException( |
|||
"unSupport timeType, pls choose from [month, year, any]"); |
|||
}; |
|||
} |
|||
|
|||
/** 充电量: A29; 充电时长: A201; 充电次数: A202 */ |
|||
public String getBaseAttrCode(){ |
|||
return switch (reportType) { |
|||
case 1 -> "A29"; |
|||
case 2 -> "A201"; |
|||
case 3 -> "A202"; |
|||
default -> throw new SysException( |
|||
"unSupport reportType, pls choose from [1, 2, 3]"); |
|||
}; |
|||
} |
|||
|
|||
public String getAttrCode() { |
|||
return getBaseAttrCode() + getAttrType(); |
|||
} |
|||
|
|||
public Long getStartTs() { |
|||
return DateTimeUtils.convertTimeToLong(beginTime); |
|||
} |
|||
|
|||
public Long getEndTs() { |
|||
return DateTimeUtils.convertTimeToLong(endTime); |
|||
} |
|||
|
|||
public List<LocalDateTime> generateAllDateTime() { |
|||
List<LocalDateTime> dateTimeList = new ArrayList<>(); |
|||
LocalDateTime begin = getBeginDateTime().withHour(0).withMinute(0).withSecond(0).withNano(0); |
|||
LocalDateTime end = getEndDateTime(); |
|||
while (begin.isBefore(end) || begin.isEqual(end)) { |
|||
dateTimeList.add(begin); |
|||
begin = "year".equals(timeType) ? begin.plusMonths(1) : begin.plusDays(1); |
|||
} |
|||
return dateTimeList; |
|||
} |
|||
|
|||
private LocalDateTime getBeginDateTime() { |
|||
return DateTimeUtils.parseDateTime(beginTime); |
|||
} |
|||
|
|||
private LocalDateTime getEndDateTime() { |
|||
LocalDateTime dateTime = DateTimeUtils.parseDateTime(endTime); |
|||
LocalDateTime currentDateTime = LocalDateTime.now(); |
|||
return dateTime.isBefore(currentDateTime) ? dateTime : currentDateTime; |
|||
} |
|||
} |
|||
@ -1,64 +0,0 @@ |
|||
package com.thing.qingyuan.chargeStation.dto; |
|||
|
|||
import io.swagger.v3.oas.annotations.media.Schema; |
|||
import lombok.Data; |
|||
|
|||
import java.io.Serial; |
|||
import java.io.Serializable; |
|||
import java.math.BigDecimal; |
|||
|
|||
/** |
|||
* 充电枪 |
|||
* |
|||
* @author system system@lrd.com |
|||
* @since 5.1 2024-01-29 |
|||
*/ |
|||
@Data |
|||
@Schema(description = "充电枪") |
|||
public class ConnectorInfoDTO implements Serializable { |
|||
@Serial private static final long serialVersionUID = 1L; |
|||
|
|||
@Schema(description = "充电设备接口编码") |
|||
private String connectorId; |
|||
|
|||
private String couplerType; |
|||
|
|||
@Schema(description = "额定电压下限") |
|||
private Integer voltageLowerLimits; |
|||
|
|||
private String qrCode; |
|||
|
|||
@Schema( |
|||
description = |
|||
"充电设备接口类型内唯 1:家用插座(模式2);2: 交流接口插座(模式3, 连接方式B);3:交流接口插头(带枪线,模式3,连接方式C);4:直流5: 无线充电座; 6:其他") |
|||
private Integer connectorType; |
|||
|
|||
@Schema(description = "额定电压上限") |
|||
private Integer voltageUpperLimits; |
|||
|
|||
@Schema(description = "家标准1: 2011: 2: 2015") |
|||
private Integer nationalStandard; |
|||
|
|||
@Schema(description = "充电设备接口名称") |
|||
private String connectorName; |
|||
|
|||
private Integer ratedCurrent; |
|||
|
|||
@Schema(description = "额定电流") |
|||
private BigDecimal current; |
|||
|
|||
@Schema(description = "额定功率") |
|||
private BigDecimal power; |
|||
|
|||
@Schema(description = "充电桩Id") |
|||
private String equipmentId; |
|||
|
|||
@Schema(description = "充电设备接口状态 0:离网;1:空闲;2:占用(未充电);3:占用(充电中); 4:占用(预约锁定); 255:故障") |
|||
private Integer status; |
|||
|
|||
@Schema(description = "地锁状态 0: 未知;10: 已解锁;50: 已上锁") |
|||
private Integer lockStatus; |
|||
|
|||
@Schema(description = "车位状态 0:未知;10:空闲;50:占用") |
|||
private Integer parkStatus; |
|||
} |
|||
@ -1,18 +0,0 @@ |
|||
package com.thing.qingyuan.chargeStation.dto; |
|||
|
|||
|
|||
import io.swagger.v3.oas.annotations.media.Schema; |
|||
import lombok.Data; |
|||
|
|||
|
|||
@Data |
|||
@Schema(description = "充电枪统计信息") |
|||
public class ConnectorStatusInfo { |
|||
|
|||
@Schema(description = "状态") |
|||
private String status; |
|||
@Schema(description = "数量") |
|||
private Integer num; |
|||
|
|||
|
|||
} |
|||
@ -1,64 +0,0 @@ |
|||
package com.thing.qingyuan.chargeStation.dto; |
|||
|
|||
import io.swagger.v3.oas.annotations.media.Schema; |
|||
import lombok.Data; |
|||
import lombok.experimental.Accessors; |
|||
|
|||
import java.io.Serial; |
|||
import java.io.Serializable; |
|||
import java.math.BigDecimal; |
|||
import java.util.Objects; |
|||
|
|||
/** |
|||
* 充电桩 |
|||
* |
|||
* @author system system@lrd.com |
|||
* @since 5.1 2024-01-29 |
|||
*/ |
|||
@Data |
|||
@Accessors(chain = true) |
|||
@Schema(description = "充电桩") |
|||
public class EquipmentInfoDTO implements Serializable { |
|||
@Serial |
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
private String equipmentApplication; |
|||
private Integer equipmentStatus; |
|||
@Schema(description = "设备生产商名称") |
|||
private String manufacturerName; |
|||
private String openDate; |
|||
private BigDecimal equipmentPower; |
|||
@Schema(description = "设备编码") |
|||
private String equipmentId; |
|||
@Schema(description = "设备生产商组织机 构代码") |
|||
private String manufacturerId; |
|||
private Integer nationalStandard; |
|||
@Schema(description = "充电设备经度") |
|||
private BigDecimal equipmentLng; |
|||
private String openForBusinessDate; |
|||
@Schema(description = "充电枪数量") |
|||
private Integer gunNum=0; |
|||
@Schema(description = "设备类型1:直流设备; 2:交流设备;3:交直流一体设备;4:无线设备;5:其他") |
|||
private Integer equipmentType; |
|||
@Schema(description = "充电设备纬度") |
|||
private BigDecimal equipmentLat; |
|||
private BigDecimal voltage; |
|||
private Integer newNationalStandard; |
|||
@Schema(description = "充电设备名称") |
|||
private String equipmentName; |
|||
@Schema(description = "设备生产日期") |
|||
private String productionDate; |
|||
@Schema(description = "设备型号") |
|||
private String equipmentModel; |
|||
private BigDecimal current; |
|||
@Schema(description = "充电设备总功率单位:kW") |
|||
private BigDecimal power= BigDecimal.ZERO; |
|||
private String stationId; |
|||
|
|||
public EquipmentInfoDTO add(EquipmentInfoDTO another) { |
|||
if (Objects.isNull(another)) return this; |
|||
return setGunNum(gunNum + another.getGunNum()) |
|||
.setEquipmentPower(equipmentPower.add(another.getEquipmentPower())) |
|||
.setPower(power.add(another.getPower())); |
|||
} |
|||
} |
|||
@ -1,11 +0,0 @@ |
|||
package com.thing.qingyuan.chargeStation.dto; |
|||
|
|||
import lombok.AllArgsConstructor; |
|||
import lombok.Data; |
|||
|
|||
@Data |
|||
@AllArgsConstructor |
|||
public class IdNameDTO { |
|||
private String id; |
|||
private String name; |
|||
} |
|||
@ -1,17 +0,0 @@ |
|||
package com.thing.qingyuan.chargeStation.dto; |
|||
|
|||
import lombok.AllArgsConstructor; |
|||
import lombok.Data; |
|||
|
|||
/** |
|||
* @author SiYang |
|||
* @date 2024/01/30 16:14 |
|||
* @description 极简物关系 |
|||
*/ |
|||
@Data |
|||
@AllArgsConstructor |
|||
public class SimpleThingRelationDTO { |
|||
private String fromCode; |
|||
private String toCode; |
|||
private String toName; |
|||
} |
|||
@ -1,26 +0,0 @@ |
|||
package com.thing.qingyuan.chargeStation.dto; |
|||
|
|||
import lombok.AllArgsConstructor; |
|||
import lombok.Data; |
|||
import lombok.NoArgsConstructor; |
|||
|
|||
import java.util.List; |
|||
|
|||
/** |
|||
* @author SiYang |
|||
* @date 2024/01/29 13:29 |
|||
* @description 充电站的设备详情,包含充电桩、充电枪 |
|||
*/ |
|||
@Data |
|||
@NoArgsConstructor |
|||
@AllArgsConstructor |
|||
public class StationDeviceDetail { |
|||
/** 充电站id */ |
|||
private String stationId; |
|||
|
|||
/** 充电桩列表 */ |
|||
private List<EquipmentInfoDTO> pileList; |
|||
|
|||
/** 充电枪列表 */ |
|||
private List<ConnectorInfoDTO> gunList; |
|||
} |
|||
@ -1,86 +0,0 @@ |
|||
package com.thing.qingyuan.chargeStation.dto; |
|||
|
|||
import io.swagger.v3.oas.annotations.media.Schema; |
|||
import lombok.Data; |
|||
|
|||
import java.io.Serial; |
|||
import java.io.Serializable; |
|||
import java.math.BigDecimal; |
|||
|
|||
/** |
|||
* 充电站信息 |
|||
* |
|||
* @author ssy 2337720667@qq.com |
|||
* @since 3.0 2024-01-23 |
|||
*/ |
|||
@Data |
|||
@Schema(description = "充电站信息") |
|||
public class StationInfoDTO implements Serializable { |
|||
@Serial |
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
@Schema(description = "填写内容为参照GB/T2260 2007 ") |
|||
private String areaCode; |
|||
@Schema(description = "详细地址 ") |
|||
private String address; |
|||
@Schema(description = "能够联系场站工作人员进行协助的联系电话") |
|||
private String stationTel; |
|||
@Schema(description = "平台服务电话, 例如400的电话") |
|||
private String serviceTel; |
|||
@Schema(description = "1:公共; 50:个人;100:公交(专用);101:环卫(专用);102:物流(专用);103:出租车(专用);255:其他") |
|||
private Integer stationType; |
|||
@Schema(description = ":未知; 1:建设中:5:关闭下线;6:维护中;50:正常使用") |
|||
private Integer stationStatus; |
|||
@Schema(description = "可停放进行充电的车位总数,默认: 0未知") |
|||
private Integer parkNums; |
|||
@Schema(description = "GCJ-02坐标系") |
|||
private BigDecimal stationLng; |
|||
@Schema(description = "GCJ-02坐标系") |
|||
private BigDecimal stationLat; |
|||
@Schema(description = "描述性文字, 用千引导车主找到充电车位") |
|||
private String siteGuide; |
|||
@Schema(description = "1:居民区; 2:公共机构;3:企事业单位;4:写字楼;5:工业园区;6:交通枢纽;7:大型文体设施;8:城市绿地;9:大型建筑配建停车场;10:路边停车位;11:城际高速服务区;255:其他") |
|||
private Integer construction; |
|||
@Schema(description = "描述该站点接受的车大小以及类型, 如大巳、 物流车、 私家乘用车、 出租车等") |
|||
private String matchCars; |
|||
@Schema(description = "车位楼层以及数擢信息") |
|||
private String parkInfo; |
|||
@Schema(description = "营业时间描述") |
|||
private String busineHours; |
|||
@Schema(description = "充电费描述") |
|||
private String electricityFee; |
|||
@Schema(description = "服务费率描述") |
|||
private String serviceFee; |
|||
@Schema(description = "停车费率描述") |
|||
private String parkFee; |
|||
@Schema(description = "支付方式:刷卡、线上、现金。其中电子钱包类卡为刷卡,身份鉴权卡、微信/支付宝、APP为线上 ") |
|||
private String payment; |
|||
@Schema(description = "充电设备是否需要提前预约后才能使用。0为不支持预约; 1 为支持预约。不填默认为0") |
|||
private Integer supportOrder; |
|||
@Schema(description = "其他备注信息") |
|||
private String remark; |
|||
@Schema(description = "充电站Id 接口文档没有但是接口有") |
|||
private String stationId; |
|||
@Schema(description = "运营商id") |
|||
private String operatorId; |
|||
@Schema(description = "运营商名称") |
|||
private String operatorName; |
|||
@Schema(description = "设备所有者id") |
|||
private String equipmentOwnerId; |
|||
@Schema(description = "充电站名称") |
|||
private String stationName; |
|||
@Schema(description = "国家") |
|||
private String countryCode; |
|||
@Schema(description = "省") |
|||
private String province; |
|||
@Schema(description = "市") |
|||
private String city; |
|||
@Schema(description = "区") |
|||
private String area; |
|||
|
|||
@Schema(description = "装机功率: sum(充电桩功率)") |
|||
private Double totalPilePower; |
|||
@Schema(description = "调节功率") |
|||
private Double regulatingPower; |
|||
|
|||
} |
|||
@ -1,81 +0,0 @@ |
|||
package com.thing.qingyuan.chargeStation.dto; |
|||
|
|||
import com.thing.common.data.proto.QueueProto; |
|||
import lombok.Data; |
|||
import lombok.NoArgsConstructor; |
|||
import lombok.experimental.Accessors; |
|||
|
|||
import java.math.BigDecimal; |
|||
import java.util.ArrayList; |
|||
import java.util.List; |
|||
import java.util.Objects; |
|||
|
|||
/** |
|||
* @author SiYang |
|||
* @date 2024/01/23 15:54 |
|||
* @description 充电站订单汇总数据 |
|||
* 充电量: A29 totalPower |
|||
* 充电时长: A201 endTime - startTime |
|||
* 充电次数: A202 count(order) |
|||
* 充电金额: A204 totalMoney |
|||
*/ |
|||
@Data |
|||
@Accessors(chain = true) |
|||
@NoArgsConstructor |
|||
public class StationOrderAgg { |
|||
/** 设备编号: 站(stationId), 桩(equipmentId), 枪(connectorId) */ |
|||
private String deviceCode; |
|||
|
|||
/** 汇总充电金额:A204xx */ |
|||
private BigDecimal fee = BigDecimal.ZERO; |
|||
|
|||
/** 汇总充电电量:A29xx */ |
|||
private BigDecimal energy = BigDecimal.ZERO; |
|||
|
|||
/** 汇总充电次数:A202xx */ |
|||
private Integer count = 0; |
|||
|
|||
/** 汇总充电时长:A201xx */ |
|||
private Long duration = 0L; |
|||
|
|||
public StationOrderAgg(String deviceCode) { |
|||
this.deviceCode = deviceCode; |
|||
} |
|||
|
|||
public StationOrderAgg add(ChargeOrderHeadDTO order) { |
|||
if (Objects.isNull(order)) return this; |
|||
return setFee(fee.add(order.getTotalMoney())) |
|||
.setEnergy(energy.add(order.getTotalPower())) |
|||
.setCount(count + 1) |
|||
.setDuration(duration + order.getDuration()); |
|||
} |
|||
|
|||
public StationOrderAgg add(StationOrderAgg another) { |
|||
if (Objects.isNull(another)) return this; |
|||
return setFee(fee.add(another.getFee())) |
|||
.setEnergy(energy.add(another.getEnergy())) |
|||
.setCount(count + another.getCount()) |
|||
.setDuration(duration + another.getDuration()); |
|||
} |
|||
|
|||
public List<QueueProto.DataProto> toProtoData(Long ts, String suffix) { |
|||
List<QueueProto.DataProto> list = new ArrayList<>(); |
|||
list.add(toProtoData("A204" + suffix, fee.toPlainString(), ts)); |
|||
list.add(toProtoData("A29" + suffix, energy.toPlainString(), ts)); |
|||
list.add(toProtoData("A202" + suffix, count.toString(), ts)); |
|||
list.add(toProtoData("A201" + suffix, duration.toString(), ts)); |
|||
return list; |
|||
} |
|||
|
|||
private QueueProto.DataProto toProtoData(String key, String val, Long ts) { |
|||
return QueueProto.DataProto.newBuilder() |
|||
.setTskvProto( |
|||
QueueProto.TsKvProto.newBuilder() |
|||
.setThingCode(deviceCode) |
|||
.setKey(key) |
|||
.setVal(val) |
|||
.setTs(ts) |
|||
.build()) |
|||
.build(); |
|||
} |
|||
} |
|||
@ -1,43 +0,0 @@ |
|||
package com.thing.qingyuan.chargeStation.dto; |
|||
|
|||
import io.swagger.v3.oas.annotations.media.Schema; |
|||
import lombok.Data; |
|||
|
|||
import java.math.BigDecimal; |
|||
|
|||
/** |
|||
* 充电站信息 |
|||
* |
|||
* @author ssy 2337720667@qq.com |
|||
* @since 3.0 2024-01-23 |
|||
*/ |
|||
@Data |
|||
@Schema(description = "充电站简要信息") |
|||
public class StationSimpleDTO { |
|||
@Schema(description = "充电站id") |
|||
private String stationId; |
|||
|
|||
@Schema(description = "充电站名称") |
|||
private String stationName; |
|||
|
|||
@Schema(description = "经度") |
|||
private BigDecimal stationLng; |
|||
|
|||
@Schema(description = "纬度") |
|||
private BigDecimal stationLat; |
|||
|
|||
@Schema(description = "充电枪总数") |
|||
private Integer totalGunCount; |
|||
|
|||
@Schema(description = "离线枪数量") |
|||
private Integer offLineCount; |
|||
|
|||
@Schema(description = "空闲枪数量") |
|||
private Integer freeCount; |
|||
|
|||
@Schema(description = "正在充电的枪数量") |
|||
private Integer inChargingCount; |
|||
|
|||
@Schema(description = "故障枪数量") |
|||
private Integer errorCount; |
|||
} |
|||
@ -1,28 +0,0 @@ |
|||
package com.thing.qingyuan.chargeStation.dto; |
|||
|
|||
import io.swagger.v3.oas.annotations.media.Schema; |
|||
import lombok.Data; |
|||
import lombok.experimental.Accessors; |
|||
|
|||
/** |
|||
* @author SiYang |
|||
* @date 2024/01/29 13:54 |
|||
* @description 充电站简化信息:用于下拉查询 |
|||
*/ |
|||
@Data |
|||
@Accessors(chain = true) |
|||
@Schema(description = "充电站简化信息") |
|||
public class StationSimpleInfo { |
|||
@Schema(description = "充电站id ") |
|||
private String stationId; |
|||
@Schema(description = "充电站名称 ") |
|||
private String stationName; |
|||
@Schema(description = "地区编码 ") |
|||
private String areaCode; |
|||
@Schema(description = "地区名称 ") |
|||
private String areaName; |
|||
@Schema(description = "运营商id ") |
|||
private String operatorId; |
|||
@Schema(description = "运营商名称 ") |
|||
private String operatorName; |
|||
} |
|||
@ -1,81 +0,0 @@ |
|||
package com.thing.qingyuan.chargeStation.entity; |
|||
|
|||
import com.mybatisflex.annotation.Id; |
|||
import com.mybatisflex.annotation.Table; |
|||
import lombok.Data; |
|||
import lombok.EqualsAndHashCode; |
|||
|
|||
import java.io.Serial; |
|||
import java.io.Serializable; |
|||
import java.math.BigDecimal; |
|||
|
|||
/** |
|||
* 充电桩订单明细 |
|||
* |
|||
* @author system system@lrd.com |
|||
* @since 5.1 2024-01-23 |
|||
*/ |
|||
@Data |
|||
@EqualsAndHashCode(callSuper=false) |
|||
@Table("charge_details") |
|||
public class ChargeOrderDetailsEntity implements Serializable { |
|||
@Serial |
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
/** |
|||
* 主键 |
|||
*/ |
|||
@Id |
|||
private Long id; |
|||
|
|||
/** |
|||
* 充电订单号;运营商ID+唯一编号 |
|||
* @see ChargeOrderHeadEntity#startChargeSeq |
|||
*/ |
|||
private String startChargeSeq; |
|||
/** |
|||
* 充电设备接口编码 |
|||
*/ |
|||
private String connectorId; |
|||
/** |
|||
* 结束时间;格式,yyyy-MM-dd HH: mm: ss |
|||
*/ |
|||
private String endTime; |
|||
/** |
|||
* 开始时间 |
|||
*/ |
|||
private String startTime; |
|||
/** |
|||
* A相电流 |
|||
*/ |
|||
private BigDecimal currentA; |
|||
/** |
|||
* B相电流 |
|||
*/ |
|||
private BigDecimal currentB; |
|||
/** |
|||
* C相电流 |
|||
*/ |
|||
private BigDecimal currentC; |
|||
/** |
|||
* A相电压 |
|||
*/ |
|||
private BigDecimal voltageA; |
|||
/** |
|||
* B相电压 |
|||
*/ |
|||
private BigDecimal voltageB; |
|||
/** |
|||
* C相电压 |
|||
*/ |
|||
private BigDecimal voltageC; |
|||
/** |
|||
* 电池剩余电量,单位:% |
|||
*/ |
|||
private BigDecimal soc; |
|||
/** |
|||
* 时段充电量,单位:度(kwh) |
|||
*/ |
|||
private BigDecimal totalPower; |
|||
|
|||
} |
|||
@ -1,70 +0,0 @@ |
|||
package com.thing.qingyuan.chargeStation.entity; |
|||
|
|||
import com.mybatisflex.annotation.Id; |
|||
import com.mybatisflex.annotation.Table; |
|||
import lombok.Data; |
|||
import lombok.EqualsAndHashCode; |
|||
|
|||
import java.io.Serial; |
|||
import java.io.Serializable; |
|||
import java.math.BigDecimal; |
|||
|
|||
/** |
|||
* 充电桩订单头 |
|||
* |
|||
* @author system system@lrd.com |
|||
* @since 5.1 2024-01-23 |
|||
*/ |
|||
@Data |
|||
@EqualsAndHashCode(callSuper=false) |
|||
@Table("notification_charge_order_info") |
|||
public class ChargeOrderHeadEntity implements Serializable { |
|||
@Serial |
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
/** |
|||
* 充电订单号;运营商ID+唯一编号 |
|||
*/ |
|||
@Id |
|||
private String startChargeSeq; |
|||
/** |
|||
* 充电设备接口编码 |
|||
*/ |
|||
private String connectorId; |
|||
/** |
|||
* 开始充电时间;格式,yyyy-MM-dd HH: mm: ss |
|||
*/ |
|||
private String startTime; |
|||
/** |
|||
* 结束充电时间;格式,yyyy-MM-dd HH: mm: ss |
|||
*/ |
|||
private String endTime; |
|||
/** |
|||
* 累计充电量;单位:度, 小数点后2位 |
|||
*/ |
|||
private BigDecimal totalPower; |
|||
/** |
|||
* 总电费;单位:元, 小数点后2位 |
|||
*/ |
|||
private BigDecimal elecMoney; |
|||
/** |
|||
* 总服务费;单位:元, 小数点后2位 |
|||
*/ |
|||
private BigDecimal seviceMoney; |
|||
/** |
|||
* 累计总金额;单位:元, 小数点后2位 |
|||
*/ |
|||
private BigDecimal totalMoney; |
|||
/** |
|||
* 充电结束原因;0: 用户手动停止充电; 1:客户归属地运营商平台停止充电; 2: BMS停止充电; 3: 充电机设备故障; 4:连接器断开; 5~99: 自定义 |
|||
*/ |
|||
private Integer stopReason; |
|||
/** |
|||
* 时段数N;范围:0~32 |
|||
*/ |
|||
private Integer sumPeriod; |
|||
/** |
|||
* 充电订单状态;1:启动中; 2:充电中; 3:停止中; 4:已结束; 5:未知 |
|||
*/ |
|||
private Integer startChargeSeqStat; |
|||
} |
|||
@ -1,66 +0,0 @@ |
|||
package com.thing.qingyuan.chargeStation.entity; |
|||
|
|||
import com.mybatisflex.annotation.Id; |
|||
import com.mybatisflex.annotation.Table; |
|||
import lombok.Data; |
|||
import lombok.EqualsAndHashCode; |
|||
import lombok.experimental.Accessors; |
|||
|
|||
import java.io.Serial; |
|||
import java.io.Serializable; |
|||
import java.math.BigDecimal; |
|||
|
|||
/** |
|||
* 充电枪 |
|||
* |
|||
* @author system system@lrd.com |
|||
* @since 5.1 2024-01-29 |
|||
*/ |
|||
@Data |
|||
@Accessors(chain = true) |
|||
@EqualsAndHashCode(callSuper = false) |
|||
@Table("connector_info") |
|||
public class ConnectorInfoEntity implements Serializable { |
|||
@Serial private static final long serialVersionUID = 1L; |
|||
|
|||
/** 充电设备接口编码 */ |
|||
@Id private String connectorId; |
|||
|
|||
private String couplerType; |
|||
|
|||
/** 额定电压下限 */ |
|||
private Integer voltageLowerLimits; |
|||
|
|||
private String qrCode; |
|||
|
|||
/** 充电设备接口类型内唯 1:家用插座(模式2);2: 交流接口插座(模式3, 连接方式B);3:交流接口插头(带枪线,模式3,连接方式C);4:直流5: 无线充电座; 6:其他 */ |
|||
private Integer connectorType; |
|||
|
|||
/** 额定电压上限 */ |
|||
private Integer voltageUpperLimits; |
|||
|
|||
/** 家标准1: 2011: 2: 2015 */ |
|||
private Integer nationalStandard; |
|||
|
|||
/** 充电设备接口名称 */ |
|||
private String connectorName; |
|||
|
|||
private Integer ratedCurrent; |
|||
|
|||
/** 额定电流 */ |
|||
private BigDecimal current; |
|||
|
|||
/** 额定功率 */ |
|||
private BigDecimal power; |
|||
|
|||
private String equipmentId; |
|||
|
|||
/** 充电设备接口状态 0:离网;1:空闲;2:占用(未充电);3:占用(充电中); 4:占用(预约锁定); 255:故障 */ |
|||
private Integer status; |
|||
|
|||
/** 地锁状态 0: 未知;10: 已解锁;50: 已上锁 */ |
|||
private Integer lockStatus; |
|||
|
|||
/** 车位状态 0:未知;10:空闲;50:占用 */ |
|||
private Integer parkStatus; |
|||
} |
|||
@ -1,80 +0,0 @@ |
|||
package com.thing.qingyuan.chargeStation.entity; |
|||
|
|||
import com.mybatisflex.annotation.Id; |
|||
import com.mybatisflex.annotation.Table; |
|||
import lombok.Data; |
|||
import lombok.EqualsAndHashCode; |
|||
|
|||
import java.io.Serial; |
|||
import java.io.Serializable; |
|||
import java.math.BigDecimal; |
|||
|
|||
/** |
|||
* 充电桩 |
|||
* |
|||
* @author system system@lrd.com |
|||
* @since 5.1 2024-01-29 |
|||
*/ |
|||
@Data |
|||
@EqualsAndHashCode(callSuper=false) |
|||
@Table("equipment_info") |
|||
public class EquipmentInfoEntity implements Serializable { |
|||
@Serial |
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
/** |
|||
* 设备编码 |
|||
*/ |
|||
@Id |
|||
private String equipmentId; |
|||
private String equipmentApplication; |
|||
private Integer equipmentStatus; |
|||
/** |
|||
* 设备生产商名称 |
|||
*/ |
|||
private String manufacturerName; |
|||
private String openDate; |
|||
private BigDecimal equipmentPower; |
|||
/** |
|||
* 设备生产商组织机 构代码 |
|||
*/ |
|||
private String manufacturerId; |
|||
private Integer nationalStandard; |
|||
/** |
|||
* 充电设备经度 |
|||
*/ |
|||
private BigDecimal equipmentLng; |
|||
private String openForBusinessDate; |
|||
/** |
|||
* 充电枪数量 |
|||
*/ |
|||
private Integer gunNum; |
|||
/** |
|||
* 设备类型1:直流设备;2:交流设备;3:交直流一体设备;4:无线设备;5:其他 |
|||
*/ |
|||
private Integer equipmentType; |
|||
/** |
|||
* 充电设备纬度 |
|||
*/ |
|||
private BigDecimal equipmentLat; |
|||
private BigDecimal voltage; |
|||
private Integer newNationalStandard; |
|||
/** |
|||
* 充电设备名称 |
|||
*/ |
|||
private String equipmentName; |
|||
/** |
|||
* 设备生产日期 |
|||
*/ |
|||
private String productionDate; |
|||
/** |
|||
* 设备型号 |
|||
*/ |
|||
private String equipmentModel; |
|||
private BigDecimal current; |
|||
/** |
|||
* 充电设备总功率单位:kW |
|||
*/ |
|||
private BigDecimal power; |
|||
private String stationId; |
|||
} |
|||
@ -1,105 +0,0 @@ |
|||
package com.thing.qingyuan.chargeStation.entity; |
|||
|
|||
import com.mybatisflex.annotation.Id; |
|||
import com.mybatisflex.annotation.Table; |
|||
import lombok.Data; |
|||
import lombok.EqualsAndHashCode; |
|||
|
|||
import java.io.Serial; |
|||
import java.io.Serializable; |
|||
import java.math.BigDecimal; |
|||
|
|||
/** |
|||
* 充电站信息 |
|||
* |
|||
* @author ssy 2337720667@qq.com |
|||
* @since 3.0 2024-01-23 |
|||
*/ |
|||
@Data |
|||
@EqualsAndHashCode(callSuper = false) |
|||
@Table("station_info") |
|||
public class StationInfoEntity implements Serializable { |
|||
@Serial private static final long serialVersionUID = 1L; |
|||
|
|||
/** 填写内容为参照GB/T2260 2007 */ |
|||
private String areaCode; |
|||
|
|||
/** 详细地址 */ |
|||
private String address; |
|||
|
|||
/** 能够联系场站工作人员进行协助的联系电话 */ |
|||
private String stationTel; |
|||
|
|||
/** 平台服务电话, 例如400的电话 */ |
|||
private String serviceTel; |
|||
|
|||
/** 1:公共;50:个人;100:公交(专用);101:环卫(专用);102:物流(专用);103:出租车(专用);255:其他 */ |
|||
private Integer stationType; |
|||
|
|||
/** :未知;1:建设中:5:关闭下线;6:维护中;50:正常使用 */ |
|||
private Integer stationStatus; |
|||
|
|||
/** 可停放进行充电的车位总数,默认: 0未知 */ |
|||
private Integer parkNums; |
|||
|
|||
/** GCJ-02坐标系 */ |
|||
private BigDecimal stationLng; |
|||
|
|||
/** GCJ-02坐标系 */ |
|||
private BigDecimal stationLat; |
|||
|
|||
/** 描述性文字, 用千引导车主找到充电车位 */ |
|||
private String siteGuide; |
|||
|
|||
/** |
|||
* 1:居民区;2:公共机构;3:企事业单位;4:写字楼;5:工业园区;6:交通枢纽;7:大型文体设施;8:城市绿地;9:大型建筑配建停车场;10:路边停车位;11:城际高速服务区;255:其他 |
|||
*/ |
|||
private Integer construction; |
|||
|
|||
/** 描述该站点接受的车大小以及类型, 如大巳、 物流车、 私家乘用车、 出租车等 */ |
|||
private String matchCars; |
|||
|
|||
/** 车位楼层以及数擢信息 */ |
|||
private String parkInfo; |
|||
|
|||
/** 营业时间描述 */ |
|||
private String busineHours; |
|||
|
|||
/** 充电费描述 */ |
|||
private String electricityFee; |
|||
|
|||
/** 服务费率描述 */ |
|||
private String serviceFee; |
|||
|
|||
/** 停车费率描述 */ |
|||
private String parkFee; |
|||
|
|||
/** 支付方式:刷卡、线上、现金。其中电子钱包类卡为刷卡,身份鉴权卡、微信/支付宝、APP为线上 */ |
|||
private String payment; |
|||
|
|||
/** 充电设备是否需要提前预约后才能使用。0为不支持预约; 1 为支持预约。不填默认为0 */ |
|||
private Integer supportOrder; |
|||
|
|||
/** 其他备注信息 */ |
|||
private String remark; |
|||
|
|||
/** 充电站Id 接口文档没有但是接口有 */ |
|||
@Id |
|||
private String stationId; |
|||
|
|||
/** 运营商id */ |
|||
private String operatorId; |
|||
|
|||
/** 设备所属方id */ |
|||
private String equipmentOwnerId; |
|||
/** 充电站名称 */ |
|||
private String stationName; |
|||
/** 充电站国家代码 */ |
|||
private String countryCode; |
|||
/** 省 */ |
|||
private String province; |
|||
/** 市 */ |
|||
private String city; |
|||
/** 区 */ |
|||
private String area; |
|||
} |
|||
@ -1,106 +0,0 @@ |
|||
package com.thing.qingyuan.chargeStation.excel; |
|||
|
|||
import com.thing.qingyuan.chargeStation.dto.ChargeStatisticReportResp; |
|||
import com.thing.common.core.annotation.CustomExcel; |
|||
import com.thing.common.core.annotation.CustomExcelCollection; |
|||
import com.thing.common.core.utils.DateTimeUtils; |
|||
import lombok.AllArgsConstructor; |
|||
import lombok.Data; |
|||
import lombok.NoArgsConstructor; |
|||
import lombok.experimental.Accessors; |
|||
import org.springframework.util.CollectionUtils; |
|||
|
|||
import java.time.LocalDateTime; |
|||
import java.util.*; |
|||
import java.util.stream.Collectors; |
|||
|
|||
/** |
|||
* @author SiYang |
|||
* @date 2024/02/01 14:17 |
|||
* @description 充电统计 |
|||
*/ |
|||
@Data |
|||
@Accessors(chain = true) |
|||
@NoArgsConstructor |
|||
@AllArgsConstructor |
|||
public class ChargeStatisticExcel { |
|||
|
|||
@CustomExcel(name = "结构", width = 25) |
|||
private String thingName; |
|||
|
|||
private String attrName; |
|||
|
|||
private String attrUnit; |
|||
|
|||
@CustomExcel(columnNameGenerator = "dataColNameGenerator", width = 15, orderNum = 1) |
|||
private String total; |
|||
|
|||
@CustomExcelCollection |
|||
private List<TsVal> data; |
|||
|
|||
@SuppressWarnings("unused") |
|||
private String dataColNameGenerator() { |
|||
return attrName + "(" + attrUnit + ")"; |
|||
} |
|||
|
|||
public static List<ChargeStatisticExcel> convert(List<ChargeStatisticReportResp> sources) { |
|||
if (CollectionUtils.isEmpty(sources)) { |
|||
return Collections.emptyList(); |
|||
} |
|||
return sources.stream() |
|||
.map( |
|||
source -> { |
|||
Map<Long, String> dataMap = source.getData(); |
|||
List<TsVal> dataList = new ArrayList<>(); |
|||
dataMap.forEach( |
|||
(k, v) -> |
|||
dataList.add( |
|||
new TsVal() |
|||
.setTs(DateTimeUtils.parseDateTime(k)) |
|||
.setTimeType(source.getTimeType()) |
|||
.setVal(Optional.ofNullable(v).orElse("--")))); |
|||
return new ChargeStatisticExcel() |
|||
.setThingName(source.getThingName() + source.getAttrCode()) |
|||
.setAttrName(source.getAttrName()) |
|||
.setAttrUnit(source.getUnit()) |
|||
.setTotal(source.getTotal().toString()) |
|||
.setData(dataList); |
|||
}) |
|||
.collect(Collectors.toList()); |
|||
} |
|||
|
|||
@Data |
|||
@Accessors(chain = true) |
|||
@NoArgsConstructor |
|||
@AllArgsConstructor |
|||
public static class TsVal { |
|||
private String timeType; |
|||
|
|||
private LocalDateTime ts; |
|||
|
|||
@CustomExcel(columnNameGenerator = "dataColNameGenerator", width = 12, orderGenerator = "colOrderGenerator") |
|||
private String val; |
|||
|
|||
@SuppressWarnings("unused") |
|||
private String dataColNameGenerator() { |
|||
return switch (timeType) { |
|||
case "month" -> ts.getDayOfMonth() + "日"; |
|||
case "year" -> ts.getMonthValue() + "月"; |
|||
default -> null; |
|||
}; |
|||
} |
|||
|
|||
@SuppressWarnings("unused") |
|||
private int colOrderGenerator(){ |
|||
int orderNum = 2; |
|||
switch (timeType) { |
|||
case "month" -> orderNum += (31 - ts.getDayOfMonth()); |
|||
case "year" -> orderNum += (12 - ts.getMonthValue()); |
|||
default -> { |
|||
} |
|||
} |
|||
return orderNum; |
|||
} |
|||
|
|||
} |
|||
} |
|||
@ -1,23 +0,0 @@ |
|||
package com.thing.qingyuan.chargeStation.mapper; |
|||
|
|||
import com.mybatisflex.annotation.UseDataSource; |
|||
import com.thing.qingyuan.chargeStation.dto.ChargeOrderDetailsDTO; |
|||
import com.thing.qingyuan.chargeStation.entity.ChargeOrderDetailsEntity; |
|||
import com.thing.common.orm.mapper.PowerBaseMapper; |
|||
import org.apache.ibatis.annotations.Mapper; |
|||
import org.apache.ibatis.annotations.Param; |
|||
|
|||
import java.util.List; |
|||
|
|||
/** |
|||
* 充电桩订单明细 |
|||
* |
|||
* @author system system@lrd.com |
|||
* @since 5.1 2024-01-23 |
|||
*/ |
|||
@Mapper |
|||
@UseDataSource("systemCollect") |
|||
public interface ChargeOrderDetailsMapper extends PowerBaseMapper<ChargeOrderDetailsEntity> { |
|||
|
|||
List<ChargeOrderDetailsDTO> getLatestDetails(@Param("start") String start, @Param("end") String end); |
|||
} |
|||
@ -1,18 +0,0 @@ |
|||
package com.thing.qingyuan.chargeStation.mapper; |
|||
|
|||
import com.mybatisflex.annotation.UseDataSource; |
|||
import com.thing.qingyuan.chargeStation.entity.ChargeOrderHeadEntity; |
|||
import com.thing.common.orm.mapper.PowerBaseMapper; |
|||
import org.apache.ibatis.annotations.Mapper; |
|||
|
|||
/** |
|||
* 充电桩订单头 |
|||
* |
|||
* @author system system@lrd.com |
|||
* @since 5.1 2024-01-23 |
|||
*/ |
|||
@Mapper |
|||
@UseDataSource("systemCollect") |
|||
public interface ChargeOrderHeadMapper extends PowerBaseMapper<ChargeOrderHeadEntity> { |
|||
|
|||
} |
|||
@ -1,32 +0,0 @@ |
|||
package com.thing.qingyuan.chargeStation.mapper; |
|||
|
|||
import com.mybatisflex.annotation.UseDataSource; |
|||
import com.thing.qingyuan.chargeStation.dto.ConnectorStatusInfo; |
|||
import com.thing.qingyuan.chargeStation.entity.ConnectorInfoEntity; |
|||
import com.thing.common.orm.mapper.PowerBaseMapper; |
|||
import org.apache.ibatis.annotations.Mapper; |
|||
import org.apache.ibatis.annotations.Param; |
|||
|
|||
import java.util.List; |
|||
|
|||
/** |
|||
* 充电枪 |
|||
* |
|||
* @author system system@lrd.com |
|||
* @since 5.1 2024-01-29 |
|||
*/ |
|||
@Mapper |
|||
@UseDataSource("systemCollect") |
|||
public interface ConnectorInfoMapper extends PowerBaseMapper<ConnectorInfoEntity> { |
|||
|
|||
|
|||
|
|||
List<ConnectorStatusInfo> getStatusByStationId(String stationId); |
|||
|
|||
|
|||
Integer getCountByStationIds(List<String> stationIds); |
|||
|
|||
List<ConnectorStatusInfo> getStatusByStationIds(List<String> stationIds); |
|||
|
|||
List<ConnectorInfoEntity> simpleList(@Param("stationId") String stationId); |
|||
} |
|||
@ -1,24 +0,0 @@ |
|||
package com.thing.qingyuan.chargeStation.mapper; |
|||
|
|||
import com.mybatisflex.annotation.UseDataSource; |
|||
import com.thing.qingyuan.chargeStation.entity.EquipmentInfoEntity; |
|||
import com.thing.common.orm.mapper.PowerBaseMapper; |
|||
import org.apache.ibatis.annotations.Mapper; |
|||
import org.apache.ibatis.annotations.Param; |
|||
|
|||
import java.util.Collection; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
/** |
|||
* 充电桩 |
|||
* |
|||
* @author system system@lrd.com |
|||
* @since 5.1 2024-01-29 |
|||
*/ |
|||
@Mapper |
|||
@UseDataSource("systemCollect") |
|||
public interface EquipmentInfoMapper extends PowerBaseMapper<EquipmentInfoEntity> { |
|||
|
|||
List<Map<String, Object>> sumPower(@Param("stationIds") Collection<String> stationIds); |
|||
} |
|||
@ -1,22 +0,0 @@ |
|||
package com.thing.qingyuan.chargeStation.mapper; |
|||
|
|||
import com.mybatisflex.annotation.UseDataSource; |
|||
import com.thing.qingyuan.chargeStation.dto.StationSimpleDTO; |
|||
import com.thing.qingyuan.chargeStation.entity.StationInfoEntity; |
|||
import com.thing.common.orm.mapper.PowerBaseMapper; |
|||
import org.apache.ibatis.annotations.Mapper; |
|||
|
|||
import java.util.List; |
|||
|
|||
/** |
|||
* 充电站信息 |
|||
* |
|||
* @author ssy 2337720667@qq.com |
|||
* @since 3.0 2024-01-23 |
|||
*/ |
|||
@Mapper |
|||
@UseDataSource("systemCollect") |
|||
public interface StationInfoMapper extends PowerBaseMapper<StationInfoEntity> { |
|||
|
|||
List<StationSimpleDTO> getSimpleListWithGunStatus(); |
|||
} |
|||
@ -1,20 +0,0 @@ |
|||
package com.thing.qingyuan.chargeStation.service; |
|||
|
|||
import com.thing.qingyuan.chargeStation.dto.ChargeOrderDetailsDTO; |
|||
import com.thing.qingyuan.chargeStation.entity.ChargeOrderDetailsEntity; |
|||
import com.thing.common.orm.service.IBaseService; |
|||
|
|||
import java.util.List; |
|||
|
|||
/** |
|||
* 充电桩订单明细 |
|||
* |
|||
* @author system system@lrd.com |
|||
* @since 5.1 2024-01-23 |
|||
*/ |
|||
public interface ChargeOrderDetailsService extends IBaseService<ChargeOrderDetailsEntity> { |
|||
|
|||
List<ChargeOrderDetailsEntity> findByHeadId(String startChargeSeq); |
|||
|
|||
List<ChargeOrderDetailsDTO> getLatestDetails(String start, String end); |
|||
} |
|||
@ -1,21 +0,0 @@ |
|||
package com.thing.qingyuan.chargeStation.service; |
|||
|
|||
import com.thing.qingyuan.chargeStation.dto.ChargeOrderHeadDTO; |
|||
import com.thing.qingyuan.chargeStation.entity.ChargeOrderHeadEntity; |
|||
import com.thing.common.core.web.response.PageData; |
|||
import com.thing.common.orm.service.IBaseService; |
|||
|
|||
import java.util.Map; |
|||
|
|||
/** |
|||
* 充电桩订单头 |
|||
* |
|||
* @author system system@lrd.com |
|||
* @since 5.1 2024-01-23 |
|||
*/ |
|||
public interface ChargeOrderHeadService extends IBaseService<ChargeOrderHeadEntity> { |
|||
|
|||
PageData<ChargeOrderHeadDTO> handlePage(Map<String, Object> params); |
|||
|
|||
ChargeOrderHeadDTO getDetails(String startChargeSeq); |
|||
} |
|||
@ -1,18 +0,0 @@ |
|||
package com.thing.qingyuan.chargeStation.service; |
|||
|
|||
import com.thing.qingyuan.chargeStation.dto.ChargeStatisticReportResp; |
|||
import com.thing.qingyuan.chargeStation.dto.ChargeStatisticRequest; |
|||
import jakarta.servlet.http.HttpServletResponse; |
|||
|
|||
import java.util.List; |
|||
|
|||
/** |
|||
* @author SiYang |
|||
* @date 2024/01/31 17:33 |
|||
* @description 充电统计服务 |
|||
*/ |
|||
public interface ChargeStatisticService { |
|||
List<ChargeStatisticReportResp> getReport(ChargeStatisticRequest request); |
|||
|
|||
void export(ChargeStatisticRequest request, HttpServletResponse response); |
|||
} |
|||
@ -1,23 +0,0 @@ |
|||
package com.thing.qingyuan.chargeStation.service; |
|||
|
|||
import com.thing.qingyuan.chargeStation.dto.ConnectorInfoDTO; |
|||
import com.thing.qingyuan.chargeStation.entity.ConnectorInfoEntity; |
|||
import com.thing.common.orm.service.IBaseService; |
|||
|
|||
import java.util.Collection; |
|||
import java.util.List; |
|||
|
|||
/** |
|||
* 充电枪 |
|||
* |
|||
* @author system system@lrd.com |
|||
* @since 5.1 2024-01-29 |
|||
*/ |
|||
public interface ConnectorInfoService extends IBaseService<ConnectorInfoEntity> { |
|||
|
|||
List<ConnectorInfoDTO> getByEquipmentIds(Collection<String> equipmentIds); |
|||
|
|||
List<ConnectorInfoEntity> simpleList(String stationId); |
|||
|
|||
Integer getCountByStationIds(List<String> stationIds); |
|||
} |
|||
@ -1,22 +0,0 @@ |
|||
package com.thing.qingyuan.chargeStation.service; |
|||
|
|||
import com.thing.qingyuan.chargeStation.dto.EquipmentInfoDTO; |
|||
import com.thing.qingyuan.chargeStation.entity.EquipmentInfoEntity; |
|||
import com.thing.common.orm.service.IBaseService; |
|||
|
|||
import java.util.Collection; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
/** |
|||
* 充电桩 |
|||
* |
|||
* @author system system@lrd.com |
|||
* @since 5.1 2024-01-29 |
|||
*/ |
|||
public interface EquipmentInfoService extends IBaseService<EquipmentInfoEntity> { |
|||
|
|||
List<EquipmentInfoDTO> getByStationId(String stationId); |
|||
|
|||
Map<String, Double> sumPower(Collection<String> stationIds); |
|||
} |
|||
@ -1,55 +0,0 @@ |
|||
package com.thing.qingyuan.chargeStation.service; |
|||
|
|||
import com.thing.qingyuan.chargeStation.dto.*; |
|||
import com.thing.qingyuan.chargeStation.entity.StationInfoEntity; |
|||
import com.thing.common.core.web.response.PageData; |
|||
import com.thing.common.orm.service.IBaseService; |
|||
import com.thing.qingyuan.manageboard.dto.MapParam; |
|||
|
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
/** |
|||
* 充电站信息 |
|||
* |
|||
* @author ssy 2337720667@qq.com |
|||
* @since 3.0 2024-01-23 |
|||
*/ |
|||
public interface StationInfoService extends IBaseService<StationInfoEntity> { |
|||
|
|||
|
|||
PageData<StationInfoDTO> handlePage(Map<String, Object> params); |
|||
|
|||
/** |
|||
* 查询充电站的简要信息列表 |
|||
*/ |
|||
List<StationSimpleInfo> simpleList(); |
|||
|
|||
/** |
|||
* 获取充电站下的充电桩列表和充电枪列表 |
|||
* |
|||
* @param stationId 充电站id |
|||
* @return 充电站设备详情 |
|||
*/ |
|||
StationDeviceDetail getDetails(String stationId); |
|||
|
|||
/** |
|||
* 在当前租户下生成充电站配置: |
|||
* 1. 物模型 |
|||
* 2. 物实体 |
|||
* 3. 物指标 |
|||
* 4. 物关系 |
|||
* 5. 数据源配置 |
|||
*/ |
|||
void generateThingConfig(); |
|||
|
|||
Map<String, List<StationInfoDTO>> findByParam(MapParam mapParam); |
|||
|
|||
List<StationInfoDTO> findByName(String plantName, String area); |
|||
|
|||
List<StationInfoEntity> getSimpleList(); |
|||
|
|||
List<StationSimpleDTO> getSimpleListWithGunStatus(); |
|||
|
|||
List<IdNameDTO> getIdNameList(Map<String, Object> params); |
|||
} |
|||
@ -1,57 +0,0 @@ |
|||
package com.thing.qingyuan.chargeStation.service.impl; |
|||
|
|||
import cn.hutool.core.map.MapUtil; |
|||
import com.mybatisflex.core.query.QueryWrapper; |
|||
import com.thing.qingyuan.chargeStation.dto.ChargeOrderDetailsDTO; |
|||
import com.thing.qingyuan.chargeStation.entity.ChargeOrderDetailsEntity; |
|||
import com.thing.qingyuan.chargeStation.entity.ChargeOrderHeadEntity; |
|||
import com.thing.qingyuan.chargeStation.mapper.ChargeOrderDetailsMapper; |
|||
import com.thing.qingyuan.chargeStation.service.ChargeOrderDetailsService; |
|||
import com.thing.common.orm.service.impl.BaseServiceImpl; |
|||
import lombok.RequiredArgsConstructor; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
import java.util.List; |
|||
import java.util.Map; |
|||
import java.util.Objects; |
|||
|
|||
/** |
|||
* 充电桩订单明细 |
|||
* |
|||
* @author system system@lrd.com |
|||
* @since 5.1 2024-01-23 |
|||
*/ |
|||
@Service |
|||
@RequiredArgsConstructor |
|||
public class ChargeOrderDetailsServiceImpl extends BaseServiceImpl<ChargeOrderDetailsMapper, ChargeOrderDetailsEntity> implements ChargeOrderDetailsService { |
|||
|
|||
@Override |
|||
public QueryWrapper getWrapper(Map<String, Object> params) { |
|||
QueryWrapper wrapper = new QueryWrapper(); |
|||
String orderNo = MapUtil.getStr(params, "orderNo"); |
|||
String beginTime = MapUtil.getStr(params, "beginTime"); |
|||
String endTime = MapUtil.getStr(params, "endTime"); |
|||
|
|||
wrapper.eq(ChargeOrderHeadEntity::getStartChargeSeq, orderNo); |
|||
if (Objects.nonNull(beginTime) && Objects.nonNull(endTime)) { |
|||
wrapper.between(ChargeOrderHeadEntity::getStartTime, beginTime, endTime) |
|||
.between(ChargeOrderHeadEntity::getEndTime, beginTime, endTime); |
|||
} |
|||
|
|||
return wrapper; |
|||
} |
|||
|
|||
@Override |
|||
public List<ChargeOrderDetailsEntity> findByHeadId(String startChargeSeq) { |
|||
return list( |
|||
QueryWrapper.create() |
|||
.eq(ChargeOrderDetailsEntity::getStartChargeSeq, startChargeSeq) |
|||
.orderBy(ChargeOrderDetailsEntity::getEndTime) |
|||
.asc()); |
|||
} |
|||
|
|||
@Override |
|||
public List<ChargeOrderDetailsDTO> getLatestDetails(String start, String end) { |
|||
return mapper.getLatestDetails(start, end); |
|||
} |
|||
} |
|||
@ -1,108 +0,0 @@ |
|||
package com.thing.qingyuan.chargeStation.service.impl; |
|||
|
|||
import cn.hutool.core.map.MapUtil; |
|||
import com.mybatisflex.core.paginate.Page; |
|||
import com.mybatisflex.core.query.QueryWrapper; |
|||
import com.thing.qingyuan.chargeStation.dto.ChargeOrderHeadDTO; |
|||
import com.thing.qingyuan.chargeStation.entity.ChargeOrderDetailsEntity; |
|||
import com.thing.qingyuan.chargeStation.entity.ChargeOrderHeadEntity; |
|||
import com.thing.qingyuan.chargeStation.entity.EquipmentInfoEntity; |
|||
import com.thing.qingyuan.chargeStation.entity.StationInfoEntity; |
|||
import com.thing.qingyuan.chargeStation.mapper.ChargeOrderHeadMapper; |
|||
import com.thing.qingyuan.chargeStation.service.*; |
|||
import com.thing.common.core.constants.Constant; |
|||
import com.thing.common.core.web.response.PageData; |
|||
import com.thing.common.orm.service.impl.BaseServiceImpl; |
|||
import lombok.RequiredArgsConstructor; |
|||
import org.apache.commons.lang3.StringUtils; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
import static com.thing.qingyuan.chargeStation.entity.table.ChargeOrderHeadEntityTableDef.CHARGE_ORDER_HEAD_ENTITY; |
|||
import static com.thing.qingyuan.chargeStation.entity.table.ConnectorInfoEntityTableDef.CONNECTOR_INFO_ENTITY; |
|||
import static com.thing.qingyuan.chargeStation.entity.table.EquipmentInfoEntityTableDef.EQUIPMENT_INFO_ENTITY; |
|||
import static com.thing.qingyuan.chargeStation.entity.table.StationInfoEntityTableDef.STATION_INFO_ENTITY; |
|||
|
|||
/** |
|||
* 充电桩订单头 |
|||
* |
|||
* @author system system@lrd.com |
|||
* @since 5.1 2024-01-23 |
|||
*/ |
|||
@Service |
|||
@RequiredArgsConstructor |
|||
public class ChargeOrderHeadServiceImpl extends BaseServiceImpl<ChargeOrderHeadMapper, ChargeOrderHeadEntity> implements ChargeOrderHeadService { |
|||
|
|||
private final ChargeOrderDetailsService chargeOrderDetailsService; |
|||
|
|||
@Override |
|||
public QueryWrapper getWrapper(Map<String, Object> params){ |
|||
return new QueryWrapper(); |
|||
} |
|||
|
|||
@Override |
|||
public PageData<ChargeOrderHeadDTO> handlePage(Map<String, Object> params) { |
|||
Page<ChargeOrderHeadDTO> page = getPage(params, ChargeOrderHeadDTO.class); |
|||
return selectPage(page, params); |
|||
} |
|||
|
|||
@Override |
|||
public ChargeOrderHeadDTO getDetails(String startChargeSeq) { |
|||
ChargeOrderHeadDTO orderHead = getByIdAs(startChargeSeq, ChargeOrderHeadDTO.class); |
|||
fillDetail(orderHead); |
|||
return orderHead; |
|||
} |
|||
|
|||
private PageData<ChargeOrderHeadDTO> selectPage(Page<ChargeOrderHeadDTO> page, Map<String, Object> params) { |
|||
String startChargeSeq = MapUtil.getStr(params, "startChargeSeq"); |
|||
String stationId = MapUtil.getStr(params, "stationId"); |
|||
String equipmentId = MapUtil.getStr(params, "equipmentId"); |
|||
String connectorId = MapUtil.getStr(params, "connectorId"); |
|||
String beginTime = MapUtil.getStr(params, "beginTime"); |
|||
String endTime = MapUtil.getStr(params, "endTime"); |
|||
String order = MapUtil.getStr(params, Constant.ORDER); |
|||
String orderField = MapUtil.getStr(params, Constant.ORDER_FIELD); |
|||
|
|||
QueryWrapper queryWrapper = |
|||
QueryWrapper.create() |
|||
.select( |
|||
CHARGE_ORDER_HEAD_ENTITY.ALL_COLUMNS, |
|||
CONNECTOR_INFO_ENTITY.CONNECTOR_NAME, |
|||
EQUIPMENT_INFO_ENTITY.EQUIPMENT_ID, |
|||
EQUIPMENT_INFO_ENTITY.EQUIPMENT_NAME, |
|||
STATION_INFO_ENTITY.STATION_ID, |
|||
STATION_INFO_ENTITY.STATION_NAME) |
|||
.from(CHARGE_ORDER_HEAD_ENTITY) |
|||
.innerJoin(CONNECTOR_INFO_ENTITY).on(CHARGE_ORDER_HEAD_ENTITY.CONNECTOR_ID.eq(CONNECTOR_INFO_ENTITY.CONNECTOR_ID)) |
|||
.innerJoin(EQUIPMENT_INFO_ENTITY).on(CONNECTOR_INFO_ENTITY.EQUIPMENT_ID.eq(EQUIPMENT_INFO_ENTITY.EQUIPMENT_ID)) |
|||
.innerJoin(STATION_INFO_ENTITY).on(EQUIPMENT_INFO_ENTITY.STATION_ID.eq(STATION_INFO_ENTITY.STATION_ID)) |
|||
.eq(ChargeOrderHeadEntity::getStartChargeSeq, startChargeSeq, StringUtils.isNotBlank(startChargeSeq)) |
|||
.eq(ChargeOrderHeadEntity::getConnectorId, connectorId, StringUtils.isNotBlank(connectorId)) |
|||
.eq(StationInfoEntity::getStationId, stationId, StringUtils.isNotBlank(stationId)) |
|||
.eq(EquipmentInfoEntity::getEquipmentId, equipmentId, StringUtils.isNotBlank(equipmentId)); |
|||
|
|||
if (StringUtils.isNotBlank(beginTime) && StringUtils.isNotBlank(endTime)) { |
|||
queryWrapper.and(CHARGE_ORDER_HEAD_ENTITY.START_TIME.between(beginTime, endTime) |
|||
.or(CHARGE_ORDER_HEAD_ENTITY.END_TIME.between(beginTime, endTime))); |
|||
} |
|||
|
|||
queryWrapper.orderBy(orderField, "asc".equals(order)); |
|||
|
|||
Page<ChargeOrderHeadDTO> paginate = |
|||
mapper.paginateAs(page, queryWrapper, ChargeOrderHeadDTO.class); |
|||
return new PageData<>(paginate.getRecords(), paginate.getTotalRow()); |
|||
} |
|||
|
|||
/** |
|||
* 补充属性和值, 属性说明:CurrentA~C: 电流(A); VoltageA~C: 电压(V) |
|||
* |
|||
* @param orderHead 充电枪订单头 |
|||
*/ |
|||
private void fillDetail(ChargeOrderHeadDTO orderHead) { |
|||
List<ChargeOrderDetailsEntity> details = |
|||
chargeOrderDetailsService.findByHeadId(orderHead.getStartChargeSeq()); |
|||
orderHead.setDetails(details); |
|||
} |
|||
} |
|||
@ -1,135 +0,0 @@ |
|||
package com.thing.qingyuan.chargeStation.service.impl; |
|||
|
|||
import cn.afterturn.easypoi.excel.ExcelExportUtil; |
|||
import cn.afterturn.easypoi.excel.entity.ExportParams; |
|||
import cn.afterturn.easypoi.excel.entity.params.ExcelExportEntity; |
|||
import com.thing.qingyuan.chargeStation.dto.ChargeStatisticReportResp; |
|||
import com.thing.qingyuan.chargeStation.dto.ChargeStatisticRequest; |
|||
import com.thing.qingyuan.chargeStation.excel.ChargeStatisticExcel; |
|||
import com.thing.qingyuan.chargeStation.service.ChargeStatisticService; |
|||
import com.thing.common.core.utils.excel.ExcelUtils; |
|||
import com.thing.common.core.utils.export.ExcelEntityGenerator; |
|||
import com.thing.common.data.tskv.TsKvDTO; |
|||
import com.thing.common.tskv.service.TsKvService; |
|||
import com.thing.thing.dict.dto.IotThingDictDTO; |
|||
import com.thing.thing.dict.entity.IotThingDictEntity; |
|||
import com.thing.thing.dict.service.IotThingDictService; |
|||
|
|||
import com.thing.thing.dictRelation.service.IotThingDictRelationService; |
|||
import com.thing.thing.entity.dto.IotThingViewDTO; |
|||
import com.thing.thing.entity.entity.IotThingEntity; |
|||
import com.thing.thing.entity.service.IotThingEntityService; |
|||
import com.thing.thing.relation.root.service.IotThingRelationRootService; |
|||
import jakarta.servlet.http.HttpServletResponse; |
|||
import lombok.RequiredArgsConstructor; |
|||
import org.apache.commons.collections4.CollectionUtils; |
|||
import org.apache.commons.lang3.StringUtils; |
|||
import org.apache.poi.ss.usermodel.Workbook; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
import java.math.BigDecimal; |
|||
import java.math.RoundingMode; |
|||
import java.util.*; |
|||
import java.util.stream.Collectors; |
|||
|
|||
/** |
|||
* @author SiYang |
|||
* @date 2024/01/31 17:34 |
|||
* @description 充电统计服务实现 |
|||
*/ |
|||
@Service |
|||
@RequiredArgsConstructor |
|||
public class ChargeStatisticServiceImpl implements ChargeStatisticService { |
|||
|
|||
private final TsKvService tsKvService; |
|||
private final IotThingDictService thingDictService; |
|||
private final IotThingDictRelationService thingDictRelationService; |
|||
private final IotThingEntityService thingEntityService; |
|||
private final IotThingRelationRootService relationRootService; |
|||
|
|||
@Override |
|||
public List<ChargeStatisticReportResp> getReport(ChargeStatisticRequest request) { |
|||
// 物信息 |
|||
List<Long> thingIds = request.getThingIds(); |
|||
List<IotThingViewDTO> things = thingEntityService.findByIds(thingIds); |
|||
Set<String> thingCodes = things.stream().map(IotThingViewDTO::getEntityCode).collect(Collectors.toSet()); |
|||
|
|||
// 属性信息 |
|||
IotThingDictDTO dict = thingDictService.findDictByCode(request.getBaseAttrCode()); |
|||
|
|||
// 查询tskv |
|||
List<TsKvDTO> tskvList = |
|||
tsKvService.findTsKvByCodesAndAttrs( |
|||
thingCodes, |
|||
Collections.singletonList(request.getAttrCode()), |
|||
request.getStartTs(), |
|||
request.getEndTs(), |
|||
false); |
|||
Map<String, List<TsKvDTO>> thingTskvListMap = |
|||
tskvList.stream().collect(Collectors.groupingBy(TsKvDTO::getThingCode)); |
|||
|
|||
// 数据组装 |
|||
List<ChargeStatisticReportResp> unsortedResult = assemble(things, dict, request, thingTskvListMap); |
|||
|
|||
// 按深度优先排序 |
|||
return relationRootService.sortInDiffRootThingIds( |
|||
request.getRootId(), |
|||
request.getRootThingIds(), |
|||
new HashSet<>(thingIds), |
|||
unsortedResult, |
|||
res -> res.stream().collect(Collectors.groupingBy(ChargeStatisticReportResp::getThingId))); |
|||
} |
|||
|
|||
@Override |
|||
public void export(ChargeStatisticRequest request, HttpServletResponse response) { |
|||
// 报表原始数据 |
|||
List<ChargeStatisticReportResp> report = getReport(request); |
|||
|
|||
// 数据类型转换 |
|||
List<ChargeStatisticExcel> excelDataList = ChargeStatisticExcel.convert(report); |
|||
|
|||
// 生成表头 & 生成数据集合 |
|||
List<ExcelExportEntity> excelExportEntities = ExcelEntityGenerator.generateExportEntity(new ArrayList<>(excelDataList)); |
|||
List<Map<String, Object>> dataCollection = ExcelEntityGenerator.generateDataCollection(new ArrayList<>(excelDataList)); |
|||
|
|||
// 导出 |
|||
Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(null, "充电统计报表"), excelExportEntities, dataCollection); |
|||
ExcelUtils.downLoadExcel("充电统计报表.xls", response, workbook); |
|||
} |
|||
|
|||
private List<ChargeStatisticReportResp> assemble( |
|||
List<IotThingViewDTO> things, |
|||
IotThingDictDTO dict, |
|||
ChargeStatisticRequest request, |
|||
Map<String, List<TsKvDTO>> thingTskvListMap) { |
|||
return things.stream() |
|||
.map( |
|||
t -> { |
|||
List<TsKvDTO> tskvList = thingTskvListMap.get(t.getEntityCode()); |
|||
if (CollectionUtils.isNotEmpty(tskvList) && request.getReportType().equals(2)) { |
|||
tskvList.forEach( |
|||
e -> { |
|||
String msVal = e.getVal(); |
|||
if (StringUtils.isNotBlank(msVal)) { |
|||
BigDecimal hourVal = |
|||
new BigDecimal(msVal) |
|||
.divide(BigDecimal.valueOf(60 * 60 * 1000), 2, RoundingMode.HALF_UP); |
|||
e.setVal(hourVal.toPlainString()); |
|||
} |
|||
}); |
|||
} |
|||
return new ChargeStatisticReportResp() |
|||
.setThingId(t.getEntityId()) |
|||
.setThingName(t.getEntityName()) |
|||
.setThingCode(t.getEntityCode()) |
|||
.setAttrName(dict.getName()) |
|||
.setAttrCode(dict.getCode()) |
|||
.setUnit(dict.getUnit()) |
|||
.setTimeType(request.getTimeType()) |
|||
.initData(request.generateAllDateTime()) |
|||
.fillData(tskvList) |
|||
.calculateTotal(); |
|||
}) |
|||
.toList(); |
|||
} |
|||
} |
|||
@ -1,51 +0,0 @@ |
|||
package com.thing.qingyuan.chargeStation.service.impl; |
|||
|
|||
import com.mybatisflex.core.query.QueryWrapper; |
|||
import com.thing.qingyuan.chargeStation.dto.ConnectorInfoDTO; |
|||
import com.thing.qingyuan.chargeStation.entity.ConnectorInfoEntity; |
|||
import com.thing.qingyuan.chargeStation.mapper.ConnectorInfoMapper; |
|||
import com.thing.qingyuan.chargeStation.service.ConnectorInfoService; |
|||
import com.thing.common.orm.service.impl.BaseServiceImpl; |
|||
import lombok.RequiredArgsConstructor; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
import java.util.Collection; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
/** |
|||
* 充电枪 |
|||
* |
|||
* @author system system@lrd.com |
|||
* @since 5.1 2024-01-29 |
|||
*/ |
|||
@Service |
|||
@RequiredArgsConstructor |
|||
public class ConnectorInfoServiceImpl extends BaseServiceImpl<ConnectorInfoMapper, ConnectorInfoEntity> implements ConnectorInfoService { |
|||
|
|||
@Override |
|||
public QueryWrapper getWrapper(Map<String, Object> params){ |
|||
QueryWrapper wrapper = new QueryWrapper(); |
|||
return wrapper; |
|||
} |
|||
|
|||
@Override |
|||
public List<ConnectorInfoDTO> getByEquipmentIds(Collection<String> equipmentIds) { |
|||
return mapper.selectListByQueryAs( |
|||
QueryWrapper.create() |
|||
.in(ConnectorInfoEntity::getEquipmentId, equipmentIds) |
|||
.orderBy(ConnectorInfoEntity::getEquipmentId) |
|||
.asc(), |
|||
ConnectorInfoDTO.class); |
|||
} |
|||
|
|||
@Override |
|||
public List<ConnectorInfoEntity> simpleList(String stationId) { |
|||
return mapper.simpleList(stationId); |
|||
} |
|||
|
|||
@Override |
|||
public Integer getCountByStationIds(List<String> stationIds) { |
|||
return mapper.getCountByStationIds(stationIds); |
|||
} |
|||
} |
|||
@ -1,53 +0,0 @@ |
|||
package com.thing.qingyuan.chargeStation.service.impl; |
|||
|
|||
import cn.hutool.core.map.MapUtil; |
|||
import com.mybatisflex.core.query.QueryWrapper; |
|||
import com.thing.qingyuan.chargeStation.dto.EquipmentInfoDTO; |
|||
import com.thing.qingyuan.chargeStation.entity.EquipmentInfoEntity; |
|||
import com.thing.qingyuan.chargeStation.mapper.EquipmentInfoMapper; |
|||
import com.thing.qingyuan.chargeStation.service.EquipmentInfoService; |
|||
import com.thing.common.orm.service.impl.BaseServiceImpl; |
|||
import org.apache.commons.lang3.StringUtils; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
import java.util.Collection; |
|||
import java.util.HashMap; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
/** |
|||
* 充电桩 |
|||
* |
|||
* @author system system@lrd.com |
|||
* @since 5.1 2024-01-29 |
|||
*/ |
|||
@Service |
|||
public class EquipmentInfoServiceImpl extends BaseServiceImpl<EquipmentInfoMapper, EquipmentInfoEntity> implements EquipmentInfoService { |
|||
|
|||
@Override |
|||
public QueryWrapper getWrapper(Map<String, Object> params) { |
|||
QueryWrapper wrapper = new QueryWrapper(); |
|||
String stationId = MapUtil.getStr(params, "stationId"); |
|||
wrapper.eq(EquipmentInfoEntity::getStationId, stationId, StringUtils.isNotBlank(stationId)); |
|||
return wrapper; |
|||
} |
|||
|
|||
@Override |
|||
public List<EquipmentInfoDTO> getByStationId(String stationId) { |
|||
return mapper.selectListByQueryAs( |
|||
QueryWrapper.create().eq(EquipmentInfoEntity::getStationId, stationId), |
|||
EquipmentInfoDTO.class); |
|||
} |
|||
|
|||
@Override |
|||
public Map<String, Double> sumPower(Collection<String> stationIds) { |
|||
List<Map<String, Object>> stationPowerMapList = mapper.sumPower(stationIds); |
|||
Map<String, Double> res = new HashMap<>(); |
|||
for (Map<String, Object> map : stationPowerMapList) { |
|||
String stationId = (String) map.get("stationId"); |
|||
Double totalPower = Double.valueOf("" + map.get("totalPower")); |
|||
res.put(stationId, totalPower); |
|||
} |
|||
return res; |
|||
} |
|||
} |
|||
@ -1,389 +0,0 @@ |
|||
package com.thing.qingyuan.chargeStation.service.impl; |
|||
|
|||
import cn.hutool.core.collection.CollectionUtil; |
|||
import cn.hutool.core.map.MapUtil; |
|||
import com.mybatisflex.core.query.QueryWrapper; |
|||
import com.thing.qingyuan.chargeStation.config.StationProperties; |
|||
import com.thing.qingyuan.chargeStation.dto.*; |
|||
import com.thing.qingyuan.chargeStation.entity.ConnectorInfoEntity; |
|||
import com.thing.qingyuan.chargeStation.entity.EquipmentInfoEntity; |
|||
import com.thing.qingyuan.chargeStation.entity.StationInfoEntity; |
|||
import com.thing.qingyuan.chargeStation.mapper.StationInfoMapper; |
|||
import com.thing.qingyuan.chargeStation.service.ConnectorInfoService; |
|||
import com.thing.qingyuan.chargeStation.service.EquipmentInfoService; |
|||
import com.thing.qingyuan.chargeStation.service.StationInfoService; |
|||
import com.thing.common.core.enumeration.TemplateMark; |
|||
import com.thing.common.core.utils.ConvertUtils; |
|||
import com.thing.common.core.validator.AssertUtils; |
|||
import com.thing.common.core.web.response.PageData; |
|||
import com.thing.common.orm.service.impl.BaseServiceImpl; |
|||
import com.thing.event.ThingRelationDetailSaveEvent; |
|||
import com.thing.qingyuan.manageboard.dto.MapParam; |
|||
import com.thing.sys.security.context.UserContext; |
|||
import com.thing.thing.dictRelation.service.IotThingDictRelationService; |
|||
import com.thing.thing.entity.entity.IotThingEntity; |
|||
import com.thing.thing.entity.service.IotThingEntityService; |
|||
import com.thing.thing.model.service.IotThingModelService; |
|||
import com.thing.thing.model.thread.ThingModelExecutor; |
|||
import com.thing.thing.relation.detail.service.IotThingRelationDetailService; |
|||
import lombok.RequiredArgsConstructor; |
|||
import org.apache.commons.lang3.StringUtils; |
|||
import org.springframework.beans.BeanUtils; |
|||
import org.springframework.context.ApplicationEventPublisher; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
import java.util.*; |
|||
import java.util.stream.Collectors; |
|||
|
|||
import static com.thing.qingyuan.chargeStation.entity.table.StationInfoEntityTableDef.STATION_INFO_ENTITY; |
|||
|
|||
/** |
|||
* 充电站信息 |
|||
* |
|||
* @author ssy 2337720667@qq.com |
|||
* @since 3.0 2024-01-23 |
|||
*/ |
|||
@Service |
|||
@RequiredArgsConstructor |
|||
public class StationInfoServiceImpl extends BaseServiceImpl<StationInfoMapper, StationInfoEntity> implements StationInfoService { |
|||
private final StationProperties stationProperties; |
|||
private final ThingModelExecutor thingModelExecutor; |
|||
private final EquipmentInfoService equipmentInfoService; |
|||
private final ConnectorInfoService connectorInfoService; |
|||
private final IotThingModelService iotThingModelService; |
|||
private final IotThingEntityService iotThingEntityService; |
|||
private final ApplicationEventPublisher applicationEventPublisher; |
|||
private final IotThingDictRelationService iotThingDictRelationService; |
|||
private final IotThingRelationDetailService iotThingRelationDetailService; |
|||
|
|||
private static final String STATION_TEMPLATE_TYPE = "Station"; |
|||
private static final String PILE_TEMPLATE_TYPE = "Pile"; |
|||
private static final String GUN_TEMPLATE_TYPE = "Gun"; |
|||
|
|||
@Override |
|||
public QueryWrapper getWrapper(Map<String, Object> params) { |
|||
QueryWrapper wrapper = new QueryWrapper(); |
|||
String areaCode = MapUtil.getStr(params, "areaCode"); |
|||
String operatorId = MapUtil.getStr(params, "operatorId"); |
|||
String keyword = MapUtil.getStr(params, "keyword"); |
|||
|
|||
wrapper.eq(StationInfoEntity::getAreaCode, areaCode, StringUtils.isNotBlank(areaCode)) |
|||
.eq(StationInfoEntity::getOperatorId, operatorId, StringUtils.isNotBlank(operatorId)) |
|||
.like(StationInfoEntity::getStationName, keyword, StringUtils.isNotBlank(keyword)); |
|||
return wrapper; |
|||
} |
|||
|
|||
@Override |
|||
public PageData<StationInfoDTO> handlePage(Map<String, Object> params) { |
|||
PageData<StationInfoDTO> page = getPageData(params, StationInfoDTO.class); |
|||
List<StationInfoDTO> list = page.getList(); |
|||
fillExtendData(list); |
|||
return page; |
|||
} |
|||
|
|||
private void fillExtendData(List<StationInfoDTO> list) { |
|||
Set<String> stationIds = list.stream().map(StationInfoDTO::getStationId).collect(Collectors.toSet()); |
|||
Map<String, Double> stationPowerMap = equipmentInfoService.sumPower(stationIds); |
|||
list.forEach( |
|||
e -> { |
|||
e.setOperatorName(stationProperties.getOperatorNameById(e.getOperatorId())); |
|||
e.setTotalPilePower(stationPowerMap.get(e.getStationId())); |
|||
}); |
|||
} |
|||
|
|||
@Override |
|||
public List<StationSimpleInfo> simpleList() { |
|||
List<StationInfoEntity> list = list(); |
|||
return list.stream() |
|||
.map( |
|||
e -> |
|||
new StationSimpleInfo() |
|||
.setStationId(e.getStationId()) |
|||
.setStationName(e.getStationName()) |
|||
.setAreaCode(e.getAreaCode()) |
|||
.setAreaName(e.getArea()) |
|||
.setOperatorId(e.getOperatorId()) |
|||
.setOperatorName( |
|||
stationProperties.getOperatorNameById(e.getOperatorId()))) |
|||
.collect(Collectors.toList()); |
|||
} |
|||
|
|||
@Override |
|||
public StationDeviceDetail getDetails(String stationId) { |
|||
List<EquipmentInfoDTO> pileList = equipmentInfoService.getByStationId(stationId); |
|||
Set<String> equipmentIds = pileList.stream().map(EquipmentInfoDTO::getEquipmentId).collect(Collectors.toSet()); |
|||
List<ConnectorInfoDTO> gunList = connectorInfoService.getByEquipmentIds(equipmentIds); |
|||
return new StationDeviceDetail(stationId, pileList, gunList); |
|||
} |
|||
|
|||
/** |
|||
* 在当前租户下生成充电站配置: |
|||
* 1. 物模型 |
|||
* 2. 物实体 |
|||
* 3. 物指标 |
|||
* 4. 物关系 |
|||
* 5. 数据源配置 |
|||
*/ |
|||
@Override |
|||
public void generateThingConfig() { |
|||
Long tenantCode = UserContext.getTenantCode(); |
|||
|
|||
// 站 |
|||
List<StationInfoEntity> stationList = list(); |
|||
List<SimpleThingRelationDTO> stationSimpleRelations = stationConvert2SimpleRelation(stationList); |
|||
doGenerate(stationSimpleRelations, STATION_TEMPLATE_TYPE, tenantCode); |
|||
|
|||
// 桩 |
|||
List<EquipmentInfoEntity> pileList = equipmentInfoService.list(); |
|||
List<SimpleThingRelationDTO> pileSimpleRelations = pileConvert2SimpleRelation(pileList); |
|||
doGenerate(pileSimpleRelations, PILE_TEMPLATE_TYPE, tenantCode); |
|||
|
|||
// 枪 |
|||
List<ConnectorInfoEntity> gunList = connectorInfoService.list(); |
|||
List<SimpleThingRelationDTO> gunSimpleRelations = gunConvert2SimpleRelation(gunList); |
|||
doGenerate(gunSimpleRelations, GUN_TEMPLATE_TYPE, tenantCode); |
|||
} |
|||
|
|||
@Override |
|||
public Map<String, List<StationInfoDTO>> findByParam(MapParam mapParam) { |
|||
QueryWrapper wrapper = new QueryWrapper(); |
|||
if(mapParam.getType().equals("2")){ |
|||
wrapper.eq(StationInfoEntity::getProvince,mapParam.getCityName()); |
|||
List<StationInfoDTO> dtos = ConvertUtils.sourceToTarget(this.list(wrapper),StationInfoDTO.class); |
|||
return dtos.stream() |
|||
.collect(Collectors.groupingBy(StationInfoDTO::getCity)); |
|||
}else if(mapParam.getType().equals("3")){ |
|||
wrapper.eq(StationInfoEntity::getCity,mapParam.getCityName()); |
|||
List<StationInfoDTO> dtos = ConvertUtils.sourceToTarget(this.list(wrapper),StationInfoDTO.class); |
|||
return dtos.stream() |
|||
.collect(Collectors.groupingBy(StationInfoDTO::getCity)); |
|||
}else if(mapParam.getType().equals("4")){ |
|||
wrapper.eq(StationInfoEntity::getArea,mapParam.getCityName()); |
|||
List<StationInfoDTO> dtos = ConvertUtils.sourceToTarget(this.list(wrapper),StationInfoDTO.class); |
|||
return dtos.stream() |
|||
.collect(Collectors.groupingBy(StationInfoDTO::getCity)); |
|||
}else { |
|||
List<StationInfoDTO> dtos = ConvertUtils.sourceToTarget(this.list(wrapper),StationInfoDTO.class); |
|||
return dtos.stream() |
|||
.collect(Collectors.groupingBy(StationInfoDTO::getProvince)); |
|||
} |
|||
} |
|||
|
|||
@Override |
|||
public List<StationInfoDTO> findByName(String plantName, String area) { |
|||
QueryWrapper wrapper = new QueryWrapper(); |
|||
wrapper.like(StationInfoEntity::getStationName,plantName,StringUtils.isNotEmpty(plantName)); |
|||
wrapper.like(StationInfoEntity::getArea,area,StringUtils.isNotEmpty(area)); |
|||
return ConvertUtils.sourceToTarget(this.list(wrapper),StationInfoDTO.class); |
|||
} |
|||
|
|||
@Override |
|||
public List<StationInfoEntity> getSimpleList() { |
|||
QueryWrapper queryWrapper = |
|||
QueryWrapper.create() |
|||
.select(STATION_INFO_ENTITY.STATION_ID, STATION_INFO_ENTITY.STATION_NAME) |
|||
.from(STATION_INFO_ENTITY); |
|||
return list(queryWrapper); |
|||
} |
|||
|
|||
@Override |
|||
public List<StationSimpleDTO> getSimpleListWithGunStatus() { |
|||
return mapper.getSimpleListWithGunStatus(); |
|||
} |
|||
|
|||
@Override |
|||
public List<IdNameDTO> getIdNameList(Map<String, Object> params) { |
|||
String type = MapUtil.getStr(params, "type"); |
|||
String pid = MapUtil.getStr(params, "pid"); |
|||
boolean pidValid = StringUtils.isNotBlank(pid); |
|||
if ("pile".equals(type)) { |
|||
List<EquipmentInfoEntity> piles = |
|||
equipmentInfoService.list( |
|||
QueryWrapper.create() |
|||
.eq(EquipmentInfoEntity::getStationId, pid, pidValid)); |
|||
return piles.stream() |
|||
.map(p -> new IdNameDTO(p.getEquipmentId(), p.getEquipmentName())) |
|||
.toList(); |
|||
} else { |
|||
List<ConnectorInfoEntity> guns = |
|||
connectorInfoService.list( |
|||
QueryWrapper.create() |
|||
.eq(ConnectorInfoEntity::getEquipmentId, pid, pidValid)); |
|||
return guns.stream() |
|||
.map(g -> new IdNameDTO(g.getConnectorId(), g.getConnectorName())) |
|||
.toList(); |
|||
} |
|||
} |
|||
|
|||
private void doGenerate(List<SimpleThingRelationDTO> simpleRelations, String templateType, Long tenantCode){ |
|||
Map<String, String> thingMap = |
|||
simpleRelations.stream().collect(Collectors.toMap(SimpleThingRelationDTO::getToCode, SimpleThingRelationDTO::getToName)); |
|||
Set<String> thingCodes = thingMap.keySet(); |
|||
// 新增物模型【异步】 |
|||
// thingModelExecutor.execute(() -> iotThingModelService.batchSaveWithCodes(thingCodes)); |
|||
|
|||
// 新增物实体【同步】 |
|||
// iotThingEntityService.batchSaveWithThingMap(thingMap, templateType, tenantCode); |
|||
|
|||
AssertUtils.isBlank(templateType, "物模板不存在,请配置物模板"); |
|||
|
|||
// 同步物指标【异步】 |
|||
// thingModelExecutor.execute(() -> syncDict(templateType, tenantCode)); |
|||
|
|||
// 生成物关系【同步】 |
|||
// 查询出当前租户下,类型为${templateType}且不在任何物关系中的物实体 |
|||
// List<IotThingEntity> nonRelationThings = iotThingEntityService.selectNonRelationThings(tenantCode, templateType); |
|||
/*if (!CollectionUtil.isEmpty(nonRelationThings)) { |
|||
// 需要新增的物关系 |
|||
if (STATION_TEMPLATE_TYPE.equals(templateType)) { |
|||
createTopRelationDetails(nonRelationThings, tenantCode); |
|||
} else { |
|||
createSubRelationDetails(nonRelationThings, simpleRelations, tenantCode); |
|||
} |
|||
}*/ |
|||
|
|||
// 生成数据源【异步】 |
|||
List<IotThingEntity> things = |
|||
iotThingEntityService.list( |
|||
QueryWrapper.create().eq(IotThingEntity::getTenantCode, tenantCode)); |
|||
generateThingSource(things, tenantCode); |
|||
} |
|||
|
|||
/* private void createTopRelationDetails(List<IotThingEntity> things, Long tenantCode){ |
|||
Long maxSort = iotThingRelationDetailService.getMaxSort(stationProperties.getRelationId()); |
|||
List<IotThingRelationDetailEntity> details = new ArrayList<>(); |
|||
for (IotThingEntity thing : things) { |
|||
IotThingRelationDetailEntity detail = |
|||
new IotThingRelationDetailEntity() |
|||
.setSort(++maxSort) |
|||
.setFromId(stationProperties.getRelationId()) |
|||
.setToId(thing.getId()) |
|||
.setToCode(thing.getCode()) |
|||
.setToName(thing.getName()) |
|||
.setRootId(stationProperties.getRelationId()) |
|||
.setRootThingId(thing.getId()); |
|||
details.add(detail); |
|||
} |
|||
iotThingRelationDetailService.saveBatch(details); |
|||
}*/ |
|||
|
|||
/** |
|||
* 创建物关系详情 |
|||
* |
|||
* @param things 本次新创建的物模板 |
|||
* @param simpleRelations 携带所有物的父级id |
|||
* @param tenantCode 租户编码 |
|||
*/ |
|||
/* private void createSubRelationDetails(List<IotThingEntity> things, List<SimpleThingRelationDTO> simpleRelations, Long tenantCode) { |
|||
Set<String> toCodes = things.stream().map(IotThingEntity::getCode).collect(Collectors.toSet()); |
|||
List<SimpleThingRelationDTO> validSimpleRelations = |
|||
simpleRelations.stream().filter(e -> toCodes.contains(e.getToCode())).toList(); |
|||
Map<String, String> codeMap = |
|||
validSimpleRelations.stream() |
|||
.collect( |
|||
Collectors.toMap( |
|||
SimpleThingRelationDTO::getToCode, |
|||
SimpleThingRelationDTO::getFromCode)); |
|||
Set<String> fromCodes = |
|||
validSimpleRelations.stream() |
|||
.map(SimpleThingRelationDTO::getFromCode) |
|||
.collect(Collectors.toSet()); |
|||
List<IotThingEntity> fromThings = findUnTemplateThings(fromCodes, tenantCode); |
|||
Map<String, Long> fromtCodeIdMap = |
|||
fromThings.stream() |
|||
.collect( |
|||
Collectors.toMap( |
|||
IotThingEntity::getCode, |
|||
IotThingEntity::getId, |
|||
(v1, v2) -> v1)); |
|||
Map<Long, Long> fromIdMaxSortMap = iotThingRelationDetailService.getMaxSortMap(fromtCodeIdMap.values()); |
|||
Map<Long, Long> fromIdRootThingIdMap = iotThingRelationDetailService.getRootThingIds(fromtCodeIdMap.values()); |
|||
|
|||
List<IotThingRelationDetailEntity> details = new ArrayList<>(); |
|||
for (IotThingEntity thing : things) { |
|||
String fromCode = codeMap.get(thing.getCode()); |
|||
Long fromId = fromtCodeIdMap.get(fromCode); |
|||
Long maxSort = Optional.ofNullable(fromIdMaxSortMap.get(fromId)).orElse(0L); |
|||
long newMaxSort = maxSort + 1; |
|||
fromIdMaxSortMap.put(fromId, newMaxSort); |
|||
IotThingRelationDetailEntity detail = |
|||
new IotThingRelationDetailEntity() |
|||
.setSort(newMaxSort) |
|||
.setFromId(fromId) |
|||
.setToId(thing.getId()) |
|||
.setToCode(thing.getCode()) |
|||
.setToName(thing.getName()) |
|||
.setRootId(stationProperties.getRelationId()) |
|||
.setRootThingId(fromIdRootThingIdMap.get(fromId)); |
|||
details.add(detail); |
|||
} |
|||
iotThingRelationDetailService.saveBatch(details); |
|||
}*/ |
|||
|
|||
/** |
|||
* 基于物模板同步物实体的属性,只有新创建的物才会进行属性同步 |
|||
* @param templateType 物模板类型 |
|||
* @param tenantCode 租户编码 |
|||
*/ |
|||
/* private void syncDict(String templateType, Long tenantCode){ |
|||
// 查询当前租户下,类型为${templateType}且没有任何属性的物实体 |
|||
List<IotThingEntity> things = iotThingEntityService.selectNonAttrThings(tenantCode, templateType); |
|||
if (CollectionUtil.isEmpty(things)) return; |
|||
List<IotThingDictRelationEntity> templateDictRelations = iotThingDictRelationService.findByTemplate(templateType); |
|||
List<IotThingDictRelationEntity> targetDictList = |
|||
things.stream() |
|||
.map(t -> templateDictRelations.stream() |
|||
.map(d -> { |
|||
IotThingDictRelationEntity targetDict = new IotThingDictRelationEntity(); |
|||
BeanUtils.copyProperties(d, targetDict); |
|||
targetDict.setId(null); |
|||
targetDict.setFromId(t.getId()); |
|||
return targetDict; |
|||
}) |
|||
.collect(Collectors.toList())) |
|||
.flatMap(Collection::stream) |
|||
.toList(); |
|||
iotThingDictRelationService.saveBatch(targetDictList); |
|||
}*/ |
|||
|
|||
private List<SimpleThingRelationDTO> stationConvert2SimpleRelation(List<StationInfoEntity> stationList) { |
|||
return stationList.stream() |
|||
.map(e -> new SimpleThingRelationDTO(null, e.getStationId(), e.getStationName())) |
|||
.toList(); |
|||
} |
|||
|
|||
private List<SimpleThingRelationDTO> pileConvert2SimpleRelation(List<EquipmentInfoEntity> pileList) { |
|||
return pileList.stream() |
|||
.map(e -> new SimpleThingRelationDTO(e.getStationId(), e.getEquipmentId(), e.getEquipmentName())) |
|||
.toList(); |
|||
} |
|||
|
|||
private List<SimpleThingRelationDTO> gunConvert2SimpleRelation(List<ConnectorInfoEntity> gunList) { |
|||
return gunList.stream() |
|||
.map(e -> new SimpleThingRelationDTO(e.getEquipmentId(), e.getConnectorId(), e.getConnectorName())) |
|||
.toList(); |
|||
} |
|||
|
|||
private void generateThingSource(List<IotThingEntity> things, Long tenantCode){ |
|||
List<Long> thingIds = |
|||
things.stream().map(IotThingEntity::getId).collect(Collectors.toList()); |
|||
applicationEventPublisher.publishEvent( |
|||
new ThingRelationDetailSaveEvent( |
|||
this, |
|||
stationProperties.getRelationId(), |
|||
thingIds, |
|||
tenantCode)); |
|||
} |
|||
|
|||
private List<IotThingEntity> findUnTemplateThings(Collection<String> codes, Long tenantCode) { |
|||
return iotThingEntityService |
|||
.getMapper() |
|||
.selectListByQuery( |
|||
QueryWrapper.create() |
|||
.in(IotThingEntity::getCode, codes) |
|||
.eq(IotThingEntity::getTenantCode, tenantCode) |
|||
.eq(IotThingEntity::getTemplateMark, TemplateMark.NO.getValue())); |
|||
} |
|||
|
|||
|
|||
} |
|||
@ -1,275 +0,0 @@ |
|||
package com.thing.qingyuan.chargeStation.task; |
|||
|
|||
import com.alibaba.fastjson.JSONObject; |
|||
import com.mybatisflex.core.query.QueryWrapper; |
|||
import com.thing.qingyuan.chargeStation.dto.ChargeOrderDetailsDTO; |
|||
import com.thing.qingyuan.chargeStation.dto.ChargeOrderHeadDTO; |
|||
import com.thing.qingyuan.chargeStation.dto.StationOrderAgg; |
|||
import com.thing.qingyuan.chargeStation.entity.ChargeOrderHeadEntity; |
|||
import com.thing.qingyuan.chargeStation.entity.ConnectorInfoEntity; |
|||
import com.thing.qingyuan.chargeStation.entity.EquipmentInfoEntity; |
|||
import com.thing.qingyuan.chargeStation.service.ChargeOrderDetailsService; |
|||
import com.thing.qingyuan.chargeStation.service.ChargeOrderHeadService; |
|||
import com.thing.qingyuan.chargeStation.service.ConnectorInfoService; |
|||
import com.thing.qingyuan.chargeStation.service.EquipmentInfoService; |
|||
import com.thing.common.core.utils.DateTimeUtils; |
|||
import com.thing.common.data.event.QueueConsumerEvent; |
|||
import com.thing.common.data.proto.QueueProto.DataProto; |
|||
import com.thing.quartz.timetask.task.ITask; |
|||
import com.thing.queue.util.Topics; |
|||
import lombok.RequiredArgsConstructor; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.apache.commons.lang3.StringUtils; |
|||
import org.apache.commons.lang3.tuple.Pair; |
|||
import org.springframework.context.ApplicationEventPublisher; |
|||
import org.springframework.stereotype.Component; |
|||
import org.springframework.util.CollectionUtils; |
|||
|
|||
import java.time.LocalDate; |
|||
import java.time.LocalDateTime; |
|||
import java.time.LocalTime; |
|||
import java.util.*; |
|||
import java.util.stream.Collectors; |
|||
|
|||
/** |
|||
* @author SiYang |
|||
* @date 2024/02/01 16:59 |
|||
* @description 每日订单数据汇总 |
|||
*/ |
|||
@Slf4j |
|||
@RequiredArgsConstructor |
|||
@Component("StationTask") |
|||
public class StationTask implements ITask { |
|||
private final ConnectorInfoService gunService; |
|||
private final EquipmentInfoService pileService; |
|||
private final ChargeOrderHeadService orderHeadService; |
|||
private final ApplicationEventPublisher eventPublisher; |
|||
private final ChargeOrderDetailsService orderDetailsService; |
|||
|
|||
/** |
|||
* 1. 查询完成时间在昨日的订单数据 |
|||
* 2. 按枪的维度汇总数据 |
|||
* 3. 按桩的维度再次汇总 |
|||
* 4. 按站的维度再次汇总 |
|||
* 5. 推送数据 |
|||
* @param params json格式,支持字段如下: |
|||
* - startTime: 订单结束时间的起始时间窗口 (yyyy-MM-dd HH:mm:ss) |
|||
* - endTime: 订单结束时间的结束时间窗口 (yyyy-MM-dd HH:mm:ss) |
|||
*/ |
|||
@Override |
|||
public void run(String params) { |
|||
log.info("StationTask run params: {}", params); |
|||
List<Pair<String, String>> dayList = getDayList(params); |
|||
for (Pair<String, String> timePair : dayList) { |
|||
handleSequence(timePair); |
|||
handleAgg(timePair); |
|||
} |
|||
log.info("StationTask run end"); |
|||
} |
|||
|
|||
/** |
|||
* 时序数据推送,电流、电压、剩余电量、充电量 |
|||
* @param timePair 某天的开始时间和结束时间 |
|||
*/ |
|||
private void handleSequence(Pair<String, String> timePair) { |
|||
Pair<String, String> latestTimePair = convert2LatestTime(timePair.getLeft()); |
|||
List<ChargeOrderDetailsDTO> orderDetails = getOrderDetails(latestTimePair); |
|||
List<DataProto> dataProtoList = |
|||
orderDetails.stream() |
|||
.map(ChargeOrderDetailsDTO::toProtoDataList) |
|||
.flatMap(List::stream) |
|||
.toList(); |
|||
if (!dataProtoList.isEmpty()) { |
|||
eventPublisher.publishEvent( |
|||
new QueueConsumerEvent(Topics.V1_TSKV_HISTORY.getValue(), dataProtoList)); |
|||
} |
|||
} |
|||
|
|||
|
|||
|
|||
/** |
|||
* 按指定时间聚合数据 |
|||
* @param timePair 某天的开始时间和结束时间 |
|||
*/ |
|||
private void handleAgg(Pair<String, String> timePair){ |
|||
// 计算本次汇总数据所在的时间戳 |
|||
Long ts = DateTimeUtils.convertTimeToLong(timePair.getLeft()); |
|||
|
|||
// 查询本次汇总数据所需使用的订单列表 |
|||
List<ChargeOrderHeadDTO> orders = getOrders(timePair); |
|||
|
|||
// 汇总枪 |
|||
Map<String, List<ChargeOrderHeadDTO>> gunOrderMap = |
|||
orders.stream().collect(Collectors.groupingBy(ChargeOrderHeadDTO::getConnectorId)); |
|||
Map<String, StationOrderAgg> gunDailyAggMap = aggGunOrders(gunOrderMap, ts); |
|||
|
|||
// 汇总桩 |
|||
Map<String, List<String>> pileGunIdMap = getPileGunIdMap(gunOrderMap.keySet()); |
|||
Map<String, StationOrderAgg> pileDailyAggMap = aggSubDeviceData(pileGunIdMap, gunDailyAggMap, ts); |
|||
|
|||
// 汇总站 |
|||
Map<String, List<String>> stationPileIdMap = getStationPileIdMap(pileGunIdMap.keySet()); |
|||
aggSubDeviceData(stationPileIdMap, pileDailyAggMap, ts); |
|||
} |
|||
|
|||
/** |
|||
* 跨天任务支持 |
|||
* |
|||
* @param params 任务参数 |
|||
* @return 每天的起始和结束时间列表 |
|||
*/ |
|||
private List<Pair<String, String>> getDayList(String params) { |
|||
List<Pair<String, String>> dayList = new ArrayList<>(); |
|||
// 默认计算: 当前时间在00:05分前,那么计算昨日数据, 否则计算今日数据。目的:防止遗漏临界情况下的订单 |
|||
if (StringUtils.isBlank(params)) { |
|||
LocalDateTime currentTime = LocalDateTime.now(); |
|||
LocalDate today = currentTime.toLocalDate(); |
|||
boolean calculateYesterday = currentTime.getHour() == 0 && currentTime.getMinute() <= 5; |
|||
String start = getDayStart(calculateYesterday ? today.minusDays(1) : today); |
|||
String end = getDayStart(calculateYesterday ? today : today.plusDays(1)); |
|||
dayList.add(Pair.of(start, end)); |
|||
return dayList; |
|||
} |
|||
|
|||
// 按参数解析出多天的起始和结束时间 |
|||
JSONObject jsonObject = JSONObject.parseObject(params); |
|||
LocalDateTime startTime = getDayStart(jsonObject.getString("startTime")); |
|||
LocalDateTime endTime = DateTimeUtils.parseDateTime(jsonObject.getString("endTime")); |
|||
while (!startTime.isAfter(endTime)) { |
|||
String start = startTime.format(DateTimeUtils.DATE_TIME_PATTERN); |
|||
String end = getDayStart(startTime.toLocalDate().plusDays(1)); |
|||
dayList.add(Pair.of(start, end)); |
|||
startTime = startTime.plusDays(1); |
|||
} |
|||
return dayList; |
|||
} |
|||
|
|||
private Pair<String, String> convert2LatestTime(String dateTime) { |
|||
LocalDateTime localDateTime = DateTimeUtils.parseDateTime(dateTime); |
|||
LocalDateTime now = LocalDateTime.now(); |
|||
LocalDateTime formatTime = |
|||
localDateTime |
|||
.withHour(now.getHour()) |
|||
.withMinute(now.getMinute()) |
|||
.withSecond(now.getSecond()); |
|||
String start; |
|||
if (formatTime.getHour() == 0 && formatTime.getMinute() <= 10) { |
|||
start = getDayStart(formatTime.toLocalDate()); |
|||
} else { |
|||
start = formatTime.minusMinutes(10).format(DateTimeUtils.DATE_TIME_PATTERN); |
|||
} |
|||
String end = formatTime.format(DateTimeUtils.DATE_TIME_PATTERN); |
|||
return Pair.of(start, end); |
|||
} |
|||
|
|||
private List<ChargeOrderHeadDTO> getOrders(Pair<String, String> timePair) { |
|||
return orderHeadService.listAs( |
|||
QueryWrapper.create() |
|||
.between( |
|||
ChargeOrderHeadEntity::getEndTime, |
|||
timePair.getLeft(), |
|||
timePair.getRight()), |
|||
ChargeOrderHeadDTO.class); |
|||
} |
|||
|
|||
private List<ChargeOrderDetailsDTO> getOrderDetails(Pair<String, String> timePair) { |
|||
return orderDetailsService.getLatestDetails(timePair.getLeft(), timePair.getRight()); |
|||
} |
|||
|
|||
private Map<String, List<String>> getPileGunIdMap(Collection<String> gunIds) { |
|||
if (gunIds.isEmpty()) return new HashMap<>(1); |
|||
List<ConnectorInfoEntity> gunList = gunService.listByIds(gunIds); |
|||
return gunList.stream() |
|||
.collect( |
|||
Collectors.groupingBy( |
|||
ConnectorInfoEntity::getEquipmentId, |
|||
Collectors.mapping( |
|||
ConnectorInfoEntity::getConnectorId, Collectors.toList()))); |
|||
} |
|||
|
|||
private Map<String, List<String>> getStationPileIdMap(Collection<String> pileIds) { |
|||
if(pileIds.isEmpty()) return new HashMap<>(1); |
|||
List<EquipmentInfoEntity> pileList = pileService.listByIds(pileIds); |
|||
return pileList.stream() |
|||
.collect( |
|||
Collectors.groupingBy( |
|||
EquipmentInfoEntity::getStationId, |
|||
Collectors.mapping( |
|||
EquipmentInfoEntity::getEquipmentId, Collectors.toList()))); |
|||
} |
|||
|
|||
/** |
|||
* 仅针对充电枪的聚合 |
|||
* |
|||
* @param orderMap 订单按充电枪id分组后的map |
|||
* @param ts 汇总数据所在时间戳 |
|||
* @return 充电枪的汇总数据 |
|||
*/ |
|||
private Map<String, StationOrderAgg> aggGunOrders( |
|||
Map<String, List<ChargeOrderHeadDTO>> orderMap, Long ts) { |
|||
Map<String, StationOrderAgg> orderAggMap = new HashMap<>(); |
|||
orderMap.forEach( |
|||
(gunId, orderList) -> { |
|||
StationOrderAgg orderAgg = |
|||
orderList.stream() |
|||
.reduce( |
|||
new StationOrderAgg(gunId), |
|||
StationOrderAgg::add, |
|||
(x, y) -> null); |
|||
orderAggMap.put(gunId, orderAgg); |
|||
}); |
|||
List<StationOrderAgg> orderAggList = new ArrayList<>(orderAggMap.values()); |
|||
publish(orderAggList, ts); |
|||
return orderAggMap; |
|||
} |
|||
|
|||
/** |
|||
* 将子设备的聚合数据进一步聚合,成为父设备的聚合数据 |
|||
* |
|||
* @param deviceCodeMap 父设备id, 子设备id列表组成的map |
|||
* @param subDeviceAggMap 子设备的聚合数据map |
|||
* @param ts 数据所在时间戳 |
|||
* @return 父设备的聚合数据 |
|||
*/ |
|||
private Map<String, StationOrderAgg> aggSubDeviceData( |
|||
Map<String, List<String>> deviceCodeMap, |
|||
Map<String, StationOrderAgg> subDeviceAggMap, |
|||
Long ts) { |
|||
Map<String, StationOrderAgg> parentDeviceAggMap = new HashMap<>(); |
|||
deviceCodeMap.forEach( |
|||
(parentDeviceId, subDeviceIdList) -> { |
|||
List<StationOrderAgg> subDeviceAggList = |
|||
subDeviceIdList.stream().map(subDeviceAggMap::get).toList(); |
|||
StationOrderAgg parentDeviceAgg = |
|||
subDeviceAggList.stream() |
|||
.reduce(StationOrderAgg::add) |
|||
.orElse(new StationOrderAgg()); |
|||
parentDeviceAgg.setDeviceCode(parentDeviceId); |
|||
parentDeviceAggMap.put(parentDeviceId, parentDeviceAgg); |
|||
}); |
|||
List<StationOrderAgg> orderAggList = new ArrayList<>(parentDeviceAggMap.values()); |
|||
publish(orderAggList, ts); |
|||
return parentDeviceAggMap; |
|||
} |
|||
|
|||
private void publish(List<StationOrderAgg> orderAggList, Long ts) { |
|||
if (CollectionUtils.isEmpty(orderAggList)) return; |
|||
List<DataProto> protoList = |
|||
orderAggList.stream() |
|||
.map(orderAgg -> orderAgg.toProtoData(ts, "am")) |
|||
.flatMap(Collection::stream) |
|||
.toList(); |
|||
if (!protoList.isEmpty()) { |
|||
eventPublisher.publishEvent( |
|||
new QueueConsumerEvent(Topics.V1_TSKV_HISTORY.getValue(), protoList)); |
|||
} |
|||
} |
|||
|
|||
private String getDayStart(LocalDate date) { |
|||
return LocalDateTime.of(date, LocalTime.MIN).format(DateTimeUtils.DATE_TIME_PATTERN); |
|||
} |
|||
|
|||
private LocalDateTime getDayStart(String date) { |
|||
return DateTimeUtils.parseDateTime(date).toLocalDate().atStartOfDay(); |
|||
} |
|||
} |
|||
@ -1,99 +0,0 @@ |
|||
package com.thing.qingyuan.manageboard.controller; |
|||
|
|||
import com.mybatisflex.core.query.QueryWrapper; |
|||
import com.thing.qingyuan.basedevice.dto.DeviceDTO; |
|||
import com.thing.qingyuan.basedevice.entity.DeviceEntity; |
|||
import com.thing.qingyuan.basedevice.mapper.DeviceMapper; |
|||
import com.thing.qingyuan.manageboard.dto.*; |
|||
import com.thing.qingyuan.manageboard.service.ManageBoardService; |
|||
import com.thing.qingyuan.screen.ScreenData; |
|||
import com.thing.common.core.utils.excel.ExcelUtils; |
|||
import com.thing.common.core.web.response.Result; |
|||
import io.swagger.v3.oas.annotations.Operation; |
|||
import io.swagger.v3.oas.annotations.tags.Tag; |
|||
import jakarta.servlet.http.HttpServletResponse; |
|||
import lombok.RequiredArgsConstructor; |
|||
import org.springframework.web.bind.annotation.*; |
|||
|
|||
import java.util.List; |
|||
|
|||
|
|||
/** |
|||
* 管理端主平台 |
|||
*/ |
|||
@RestController |
|||
@RequestMapping("manage/board") |
|||
@Tag(name="管理端主平台") |
|||
@RequiredArgsConstructor |
|||
public class ManageBoardController { |
|||
|
|||
private final ManageBoardService boardService; |
|||
|
|||
private final DeviceMapper deviceMapper; |
|||
|
|||
@PostMapping ("map") |
|||
@Operation(summary="管理端主平台-光伏地图") |
|||
private Result<List<ScreenData>> mapInfoByNameAndType(@RequestBody MapParam mapParam){ |
|||
return boardService.mapInfoByNameAndType(mapParam); |
|||
} |
|||
|
|||
@GetMapping ("plantList") |
|||
@Operation(summary="管理端主平台-光伏项目下拉列表") |
|||
private Result<List<PlantReq>> plantList(){ |
|||
return boardService.plantList(); |
|||
} |
|||
|
|||
@PostMapping ("plantInfoList") |
|||
@Operation(summary="管理端主平台,光伏子平台-光伏项目发电量,上网量,减排量等信息,可按名称模糊过滤") |
|||
private Result<List<PlantInfoReq>> plantInfoList(@RequestBody FindParam param){ |
|||
return boardService.plantInfoList(param); |
|||
} |
|||
|
|||
@GetMapping ("totalInfo") |
|||
@Operation(summary="管理端主平台-光伏项目数量,总装机容量,发电量,收益等统计信息") |
|||
private Result<TotalInfo> totalInfo(){ |
|||
return boardService.totalInfo(); |
|||
} |
|||
|
|||
@PostMapping ("findListByAttrCodeAndType") |
|||
@Operation(summary="管理端主平台,月/年得电量用量查询") |
|||
private Result<DataReq> findListByAttrCodeAndType(@RequestBody DataParam dataParam){ |
|||
return boardService.findListByAttrCodeAndType(dataParam); |
|||
} |
|||
|
|||
@PostMapping ("findYOYList") |
|||
@Operation(summary="管理端主平台,年发电量同比分析") |
|||
private Result<List<YOYDataReq>> findYOYList(@RequestBody DataParam dataParam){ |
|||
return boardService.findYOYList(dataParam); |
|||
} |
|||
|
|||
@PostMapping ("pVReport") |
|||
@Operation(summary="管理端主平台,光伏数据报表") |
|||
private Result<List<PVReport>> pVReport(@RequestBody PVParam param){ |
|||
return boardService.pVReport(param); |
|||
} |
|||
|
|||
@PostMapping ("pVReportExport") |
|||
@Operation(summary="管理端主平台,光伏数据报表导出") |
|||
private void pVReportExport(@RequestBody PVParam param, HttpServletResponse response) { |
|||
ExcelUtils.exportExcel(boardService.pVReport(param).getData(), "光伏数据报表", null, PVReport.class, "光伏报表.xls", response); |
|||
} |
|||
|
|||
@GetMapping("deviceInfoByPlantId/{id}") |
|||
@Operation(summary="逆变器列表查询") |
|||
private Result<List<DeviceDTO>> deviceInfoByPlantId(@PathVariable("id") Long id){ |
|||
QueryWrapper queryWrapper = QueryWrapper.create().eq(DeviceEntity::getPlantId, id).eq(DeviceEntity::getDeviceType,2); |
|||
List<DeviceDTO> result = deviceMapper.selectListByQueryAs(queryWrapper,DeviceDTO.class); |
|||
result.forEach(temp->{ |
|||
DeviceDTO dto = deviceMapper.selectOneByQueryAs(QueryWrapper.create().eq(DeviceEntity::getDeviceId, temp.getUpDeviceId()),DeviceDTO.class); |
|||
try { |
|||
temp.setUpStatus(dto.getStatus()); |
|||
temp.setUpAlias(dto.getAlias()); |
|||
} catch (Exception e) { |
|||
temp.setUpStatus(1); |
|||
} |
|||
}); |
|||
|
|||
return new Result<List<DeviceDTO>>().ok(result); |
|||
} |
|||
} |
|||
@ -1,80 +0,0 @@ |
|||
package com.thing.qingyuan.manageboard.controller; |
|||
|
|||
|
|||
import com.thing.qingyuan.manageboard.dto.*; |
|||
import com.thing.qingyuan.manageboard.service.ManageChargeService; |
|||
import com.thing.qingyuan.screen.ScreenData; |
|||
import com.thing.common.core.utils.excel.ExcelUtils; |
|||
import com.thing.common.core.web.response.Result; |
|||
import io.swagger.v3.oas.annotations.Operation; |
|||
import io.swagger.v3.oas.annotations.tags.Tag; |
|||
import jakarta.servlet.http.HttpServletResponse; |
|||
import lombok.RequiredArgsConstructor; |
|||
import org.springframework.web.bind.annotation.*; |
|||
|
|||
import java.util.List; |
|||
|
|||
@RestController |
|||
@RequestMapping("charge/board") |
|||
@Tag(name="管理端主平台,充电站") |
|||
@RequiredArgsConstructor |
|||
public class ManageChargeController { |
|||
|
|||
|
|||
private final ManageChargeService manageChargeService; |
|||
|
|||
|
|||
@PostMapping("map") |
|||
@Operation(summary="管理端主平台-充电站地图") |
|||
private Result<List<ScreenData>> mapInfoByNameAndType(@RequestBody MapParam mapParam){ |
|||
return manageChargeService.mapInfoByNameAndType(mapParam); |
|||
} |
|||
|
|||
@GetMapping("totalInfo") |
|||
@Operation(summary="管理端主平台-充电站数量,充电枪数量,年度充电量,年度充电金额等信息") |
|||
private Result<ChargeTotalInfo> totalInfo(){ |
|||
return manageChargeService.totalInfo(); |
|||
} |
|||
|
|||
@GetMapping("siteTypeInfo") |
|||
@Operation(summary="管理端主平台-年度站点类型分析") |
|||
private Result<List<SiteTypeInfo>> siteTypeInfo(){ |
|||
return manageChargeService.siteTypeInfo(); |
|||
} |
|||
|
|||
@GetMapping("chargingGunState") |
|||
@Operation(summary="管理端主平台-充电枪实时状态") |
|||
private Result<List<ChargingGunState>> chargingGunState(){ |
|||
return manageChargeService.chargingGunState(); |
|||
} |
|||
|
|||
@PostMapping("stationInfo") |
|||
@Operation(summary="管理端主平台-充电站详情") |
|||
private Result<List<StationInfoReq>> stationInfo(@RequestBody FindParam param){ |
|||
return manageChargeService.stationInfo(param); |
|||
} |
|||
|
|||
@PostMapping ("findListByAttrCodeAndType") |
|||
@Operation(summary="管理端主平台,月充电分析/年度充电时常趋势") |
|||
private Result<DataReq> findListByAttrCode(@RequestBody GunDataParam dataParam){ |
|||
return manageChargeService.findListByAttrCode(dataParam); |
|||
} |
|||
|
|||
@PostMapping ("findYOYList") |
|||
@Operation(summary="管理端主平台,年发电量同比分析") |
|||
private Result<List<YOYDataReq>> findYOYList(@RequestBody GunDataParam dataParam){ |
|||
return manageChargeService.findYOYList(dataParam); |
|||
} |
|||
|
|||
@PostMapping ("gunReport") |
|||
@Operation(summary="管理端主平台,光伏数据报表") |
|||
private Result<List<StationInfoReq>> gunReport(@RequestBody PVParam param){ |
|||
return manageChargeService.gunReport(param); |
|||
} |
|||
|
|||
@PostMapping ("gunReportExport") |
|||
@Operation(summary="管理端主平台,充电站数据报表导出") |
|||
private void gunReportExport(@RequestBody PVParam param, HttpServletResponse response) { |
|||
ExcelUtils.exportExcel(manageChargeService.gunReport(param).getData(), "充电站数据报表", null, StationInfoReq.class, "充电站报表.xls", response); |
|||
} |
|||
} |
|||
@ -1,121 +0,0 @@ |
|||
package com.thing.qingyuan.manageboard.controller; |
|||
|
|||
import com.thing.common.core.annotation.LogOperation; |
|||
import com.thing.common.core.constants.Constant; |
|||
import com.thing.common.core.web.response.PageData; |
|||
import com.thing.common.core.web.response.Result; |
|||
import com.thing.qingyuan.manageboard.dto.PhotovoltaicDTO; |
|||
import com.thing.qingyuan.manageboard.dto.PhotovoltaicOverviewDTO; |
|||
import com.thing.qingyuan.manageboard.dto.PlantDTO; |
|||
import com.thing.qingyuan.manageboard.dto.ReductionStatistics; |
|||
import com.thing.qingyuan.manageboard.service.PlantService; |
|||
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 jakarta.servlet.http.HttpServletResponse; |
|||
import lombok.RequiredArgsConstructor; |
|||
import org.springframework.web.bind.annotation.*; |
|||
|
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
/** |
|||
* 光伏项目点位信息 |
|||
* |
|||
* @author xc |
|||
* @since 3.0 2024-01-29 |
|||
*/ |
|||
@RestController |
|||
@RequestMapping("plant") |
|||
@Tag(name="光伏项目基础信息") |
|||
@RequiredArgsConstructor |
|||
public class PlantController { |
|||
private final PlantService plantService; |
|||
|
|||
@GetMapping("page") |
|||
@Operation(summary="分页") |
|||
@Parameters({ |
|||
@Parameter(name = Constant.PAGE, description = "当前页码,从1开始") , |
|||
@Parameter(name = Constant.LIMIT, description = "每页显示记录数") , |
|||
@Parameter(name = Constant.ORDER_FIELD, description = "排序字段") , |
|||
@Parameter(name = Constant.ORDER, description = "排序方式,可选值(asc、desc)"), |
|||
@Parameter(name = "buildDate", description = "建站日期"), |
|||
@Parameter(name = "area", description = "区域"), |
|||
@Parameter(name = "key", description = "站点idor名称") |
|||
}) |
|||
public Result<PageData<PlantDTO>> page(@RequestParam Map<String, Object> params){ |
|||
PageData<PlantDTO> page = plantService.getPageData(params, PlantDTO.class); |
|||
return new Result<PageData<PlantDTO>>().ok(page); |
|||
} |
|||
|
|||
@GetMapping("{id}") |
|||
@Operation(summary="信息") |
|||
public Result<PlantDTO> get(@PathVariable("id") Long id){ |
|||
PlantDTO data = plantService.getByIdAs(id, PlantDTO.class); |
|||
return new Result<PlantDTO>().ok(data); |
|||
} |
|||
|
|||
@GetMapping("getById") |
|||
@Operation(summary="信息") |
|||
public Result<PhotovoltaicDTO> getById(Long id){ |
|||
PhotovoltaicDTO data = plantService.findById(id); |
|||
return new Result<PhotovoltaicDTO>().ok(data); |
|||
} |
|||
|
|||
@GetMapping("overview") |
|||
@Operation(summary="获取光伏概览数据信息") |
|||
public Result<PhotovoltaicOverviewDTO> getOverview(){ |
|||
PhotovoltaicOverviewDTO data = plantService.getOverview(); |
|||
return new Result<PhotovoltaicOverviewDTO>().ok(data); |
|||
} |
|||
|
|||
@GetMapping ("reduction") |
|||
@Operation(summary="管理端主平台-光伏节能减排信息") |
|||
public Result<ReductionStatistics.ReductionInfo> reduction(){ |
|||
ReductionStatistics.ReductionInfo reduction = plantService.reduction(); |
|||
return new Result<ReductionStatistics.ReductionInfo>().ok(reduction); |
|||
} |
|||
|
|||
|
|||
@GetMapping("list") |
|||
@Operation(summary="电站列表信息") |
|||
public Result<List<PlantDTO>> list(@RequestParam Map<String, Object> params){ |
|||
List<PlantDTO> plantDTOS = plantService.list(params); |
|||
return new Result<List<PlantDTO>>().ok(plantDTOS); |
|||
} |
|||
|
|||
@PostMapping |
|||
@Operation(summary="保存") |
|||
@LogOperation("保存") |
|||
public Result<Void> save(@RequestBody PlantDTO dto){ |
|||
plantService.saveDto(dto); |
|||
return new Result<>(); |
|||
} |
|||
|
|||
@PutMapping |
|||
@Operation(summary="修改") |
|||
@LogOperation("修改") |
|||
public Result<Void> update(@RequestBody PlantDTO dto){ |
|||
plantService.updateDto(dto); |
|||
return new Result<>(); |
|||
} |
|||
|
|||
@DeleteMapping |
|||
@Operation(summary="删除") |
|||
@LogOperation("删除") |
|||
public Result<Void> delete(@RequestBody Long[] ids){ |
|||
plantService.batchDelete(ids); |
|||
return new Result<>(); |
|||
} |
|||
|
|||
|
|||
@GetMapping("export") |
|||
@Operation(summary="导出") |
|||
@LogOperation("导出") |
|||
public void export( @RequestParam Map<String, Object> params, HttpServletResponse response) throws Exception { |
|||
List<PlantDTO> list = plantService.listAs(params, PlantDTO.class); |
|||
//ExcelUtils.exportExcelToTarget(response, null, "光伏项目点位信息", list, PlantExcel.class); |
|||
} |
|||
|
|||
} |
|||
@ -1,20 +0,0 @@ |
|||
package com.thing.qingyuan.manageboard.dto; |
|||
|
|||
import io.swagger.v3.oas.annotations.media.Schema; |
|||
import lombok.Data; |
|||
|
|||
import java.math.BigDecimal; |
|||
|
|||
@Data |
|||
@Schema( description= "充电站统计信息") |
|||
public class ChargeTotalInfo { |
|||
@Schema( description= "充电站数量") |
|||
private Integer stationCount; |
|||
@Schema( description= "充电枪数量") |
|||
private Integer connectorCount; |
|||
@Schema( description= "年度充电量") |
|||
private BigDecimal yearCharge; |
|||
@Schema( description= "年充电金额") |
|||
private BigDecimal yearMoney; |
|||
|
|||
} |
|||
@ -1,22 +0,0 @@ |
|||
package com.thing.qingyuan.manageboard.dto; |
|||
|
|||
|
|||
import io.swagger.v3.oas.annotations.media.Schema; |
|||
import lombok.AllArgsConstructor; |
|||
import lombok.Data; |
|||
import lombok.NoArgsConstructor; |
|||
|
|||
@Data |
|||
@Schema(description = "充电枪实时状态") |
|||
@AllArgsConstructor |
|||
@NoArgsConstructor |
|||
public class ChargingGunState { |
|||
|
|||
@Schema(description = "充电枪状态名称") |
|||
private String stateName; |
|||
@Schema(description = "充电桩状态编码") |
|||
private String stateCode; |
|||
@Schema(description = "数量") |
|||
private Integer num; |
|||
|
|||
} |
|||
@ -1,22 +0,0 @@ |
|||
package com.thing.qingyuan.manageboard.dto; |
|||
|
|||
|
|||
import io.swagger.v3.oas.annotations.media.Schema; |
|||
import lombok.Data; |
|||
|
|||
@Data |
|||
@Schema(description = "查询入参") |
|||
public class DataParam { |
|||
|
|||
@Schema(description = "物编码") |
|||
private String thingCode; |
|||
@Schema(description = "属性编码 月 传A29dd,年传A29mm") |
|||
private String attrCode; |
|||
@Schema(description = "属性类型,dd 月,mm年") |
|||
private String attrType; |
|||
|
|||
private Long startTime; |
|||
|
|||
private Long endTime; |
|||
|
|||
} |
|||
@ -1,28 +0,0 @@ |
|||
package com.thing.qingyuan.manageboard.dto; |
|||
|
|||
import com.thing.common.data.tskv.TsKvDTO; |
|||
import io.swagger.v3.oas.annotations.media.Schema; |
|||
import lombok.Data; |
|||
|
|||
import java.util.List; |
|||
|
|||
@Data |
|||
@Schema(description = "用量查询,响应结果") |
|||
public class DataReq { |
|||
@Schema(description = "用量结果集合") |
|||
private List<TsKvDTO> tskvs; |
|||
@Schema(description = "属性信息") |
|||
private AttrInfo attrInfo; |
|||
|
|||
@Schema(description = "属性信息") |
|||
@Data |
|||
public static class AttrInfo{ |
|||
@Schema(description = "属性编码") |
|||
private String attrCode; |
|||
@Schema(description = "属性名称") |
|||
private String attrName; |
|||
@Schema(description = "属性单位") |
|||
private String attrUint; |
|||
} |
|||
|
|||
} |
|||
@ -1,15 +0,0 @@ |
|||
package com.thing.qingyuan.manageboard.dto; |
|||
|
|||
|
|||
import io.swagger.v3.oas.annotations.media.Schema; |
|||
import lombok.Data; |
|||
|
|||
@Data |
|||
@Schema(description = "模糊查找入参") |
|||
public class FindParam { |
|||
|
|||
@Schema(description = "项目名称/站点名称") |
|||
private String plantName; |
|||
|
|||
|
|||
} |
|||
@ -1,20 +0,0 @@ |
|||
package com.thing.qingyuan.manageboard.dto; |
|||
|
|||
|
|||
import io.swagger.v3.oas.annotations.media.Schema; |
|||
import lombok.Data; |
|||
|
|||
@Data |
|||
@Schema(description = "查询入参") |
|||
public class GunDataParam { |
|||
|
|||
@Schema(description = "属性编码 充电电量: 月A29dd,年A29mm,充电时长月A201dd,年A201mm,充电次数 A202dd") |
|||
private String attrCode; |
|||
@Schema(description = "属性类型,dd 月,mm年") |
|||
private String attrType; |
|||
|
|||
private Long startTime; |
|||
|
|||
private Long endTime; |
|||
|
|||
} |
|||
@ -1,17 +0,0 @@ |
|||
package com.thing.qingyuan.manageboard.dto; |
|||
|
|||
import io.swagger.v3.oas.annotations.media.Schema; |
|||
import lombok.Data; |
|||
|
|||
@Data |
|||
@Schema(description = "充电站报表查询入参") |
|||
public class GunReportParam { |
|||
@Schema(description = "区域") |
|||
private String area; |
|||
@Schema(description = "站点名称") |
|||
private String stationName; |
|||
@Schema(description = "时间 月 入参 yyyy-MM 年入参 yyyy") |
|||
private String date; |
|||
@Schema(description = "时间类型 dd月,mm年") |
|||
private String dateType; |
|||
} |
|||
@ -1,16 +0,0 @@ |
|||
package com.thing.qingyuan.manageboard.dto; |
|||
|
|||
|
|||
import io.swagger.v3.oas.annotations.media.Schema; |
|||
import lombok.Data; |
|||
|
|||
@Data |
|||
@Schema(description = "地图统计信息请求入参") |
|||
public class MapParam { |
|||
|
|||
@Schema(description = "城市名称,全国的时候不传") |
|||
private String cityName; |
|||
@Schema(description = "类型,1全国,2全省,3全市") |
|||
private String type; |
|||
|
|||
} |
|||
@ -1,20 +0,0 @@ |
|||
package com.thing.qingyuan.manageboard.dto; |
|||
|
|||
import io.swagger.v3.oas.annotations.media.Schema; |
|||
import lombok.Data; |
|||
|
|||
@Data |
|||
@Schema(description = "光伏报表查询入参") |
|||
public class PVParam { |
|||
|
|||
@Schema(description = "区域") |
|||
private String area; |
|||
@Schema(description = "项目名称") |
|||
private String plantName; |
|||
@Schema(description = "时间 月 入参 yyyy-MM 年入参 yyyy") |
|||
private String date; |
|||
@Schema(description = "时间类型 dd月,mm年") |
|||
private String dateType; |
|||
|
|||
|
|||
} |
|||
@ -1,68 +0,0 @@ |
|||
package com.thing.qingyuan.manageboard.dto; |
|||
|
|||
|
|||
import cn.afterturn.easypoi.excel.annotation.Excel; |
|||
import io.swagger.v3.oas.annotations.media.Schema; |
|||
import lombok.Data; |
|||
|
|||
import java.math.BigDecimal; |
|||
|
|||
@Data |
|||
@Schema(description = "光伏项目报表") |
|||
public class PVReport { |
|||
@Schema(description = "电站Id") |
|||
private Long plantId; |
|||
@Excel(name = "序号") |
|||
private String sortStr; |
|||
@Schema(description = "电站名称") |
|||
@Excel(name = "项目名称") |
|||
private String plantName; |
|||
@Schema(description = "所属区县") |
|||
@Excel(name = "区域") |
|||
private String area; |
|||
@Schema(description = "电站装机容量 (单位:MWp)") |
|||
@Excel(name = "装机容量(MWp)") |
|||
private BigDecimal capacity = BigDecimal.ZERO; |
|||
@Schema(description = "理论发电量") |
|||
@Excel(name = "理论发电量(kWh)") |
|||
private BigDecimal theoryEnergyPhotovoltaic = BigDecimal.ZERO; |
|||
@Schema(description = "发电量") |
|||
@Excel(name = "发电量(kWh)") |
|||
private BigDecimal energyPhotovoltaic = BigDecimal.ZERO; |
|||
@Schema(description = "综合效率") |
|||
@Excel(name = "综合效率(%)") |
|||
private BigDecimal oee = BigDecimal.ZERO; |
|||
@Schema(description = "消纳量") |
|||
@Excel(name = "消纳量(kWh)") |
|||
private BigDecimal consumption = BigDecimal.ZERO; |
|||
@Schema(description = "上网电量") |
|||
@Excel(name = "上网电量(kWh)") |
|||
private BigDecimal internetUsage= BigDecimal.ZERO; |
|||
@Schema(description = "减排量") |
|||
@Excel(name = "减排量(kgCO₂)") |
|||
private BigDecimal co2 = BigDecimal.ZERO; |
|||
@Schema(description = "建站日期") |
|||
private String buildDate; |
|||
@Schema(description = "所属国家") |
|||
private String country; |
|||
@Schema(description = "所属省份") |
|||
private String province; |
|||
@Schema(description = "所属城市") |
|||
private String city; |
|||
@Schema(description = "电站所在具体地址") |
|||
private String address; |
|||
@Schema(description = "电站状态(1 正常 2 离线 3报警)") |
|||
private Integer status; |
|||
@Schema(description = "衰减率") |
|||
private BigDecimal attenuation = BigDecimal.ZERO; |
|||
@Schema(description = "日照时常") |
|||
private BigDecimal sunshine = BigDecimal.ZERO; |
|||
private Integer sort; |
|||
|
|||
public String getSortStr() { |
|||
if(sort==-1){ |
|||
return "--"; |
|||
} |
|||
return sort.toString(); |
|||
} |
|||
} |
|||
@ -1,45 +0,0 @@ |
|||
package com.thing.qingyuan.manageboard.dto; |
|||
|
|||
import io.swagger.v3.oas.annotations.media.Schema; |
|||
import lombok.Data; |
|||
|
|||
import java.io.Serial; |
|||
import java.io.Serializable; |
|||
import java.math.BigDecimal; |
|||
|
|||
/** |
|||
* 光伏项目点位信息 |
|||
* |
|||
* @author xc |
|||
* @since 3.0 2024-01-29 |
|||
*/ |
|||
@Data |
|||
@Schema( description= "光伏项目点位信息") |
|||
public class PhotovoltaicDTO implements Serializable { |
|||
@Serial |
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
@Schema(description = "电站Id") |
|||
private Long plantId; |
|||
@Schema(description = "电站名称") |
|||
private String plantName; |
|||
@Schema(description = "电站装机容量 (单位:kWp)") |
|||
private BigDecimal capacity; |
|||
@Schema(description = "经度") |
|||
private Object longitude; |
|||
@Schema(description = "纬度") |
|||
private Object latitude; |
|||
@Schema(description = "逆变器数量") |
|||
private Integer inverterNum = 0; |
|||
@Schema(description = "今日发电量") |
|||
private BigDecimal electricityUsage = BigDecimal.ZERO; |
|||
@Schema(description = "今日上网量") |
|||
private BigDecimal internetUsage = BigDecimal.ZERO; |
|||
@Schema(description = "今日减碳量") |
|||
private BigDecimal carbonUsage = BigDecimal.ZERO; |
|||
@Schema(description = "检测点运行正常") |
|||
private BigDecimal pointNormal = BigDecimal.ZERO; |
|||
@Schema(description = "检测点运行总量") |
|||
private BigDecimal pointTotal = BigDecimal.ZERO; |
|||
|
|||
} |
|||
@ -1,38 +0,0 @@ |
|||
package com.thing.qingyuan.manageboard.dto; |
|||
|
|||
import io.swagger.v3.oas.annotations.media.Schema; |
|||
import lombok.Data; |
|||
|
|||
import java.io.Serial; |
|||
import java.io.Serializable; |
|||
import java.math.BigDecimal; |
|||
|
|||
/** |
|||
* 光伏项目概览数据信息 |
|||
* |
|||
* @author xc |
|||
* @since 3.0 2024-01-29 |
|||
*/ |
|||
@Data |
|||
@Schema( description= "光伏项目概览数据信息") |
|||
public class PhotovoltaicOverviewDTO implements Serializable { |
|||
|
|||
@Serial |
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
@Schema(description = "光伏电站数量") |
|||
private BigDecimal num = BigDecimal.ZERO; |
|||
@Schema(description = "电站装机容量 (单位:kWp)") |
|||
private BigDecimal capacity = BigDecimal.ZERO; |
|||
@Schema(description = "年发电量(单位:kWp)") |
|||
private BigDecimal electricityUsage = BigDecimal.ZERO; |
|||
@Schema(description = "年上网量(单位:kWp)") |
|||
private BigDecimal internetUsage = BigDecimal.ZERO; |
|||
@Schema(description = "年节能量(单位:tce)") |
|||
private BigDecimal energySaveUsage = BigDecimal.ZERO; |
|||
@Schema(description = "年减排量(单位:tCO2)") |
|||
private BigDecimal reductionUsage = BigDecimal.ZERO; |
|||
@Schema(description = "年收益") |
|||
private BigDecimal profit = BigDecimal.ZERO; |
|||
|
|||
} |
|||
@ -1,91 +0,0 @@ |
|||
package com.thing.qingyuan.manageboard.dto; |
|||
|
|||
import io.swagger.v3.oas.annotations.media.Schema; |
|||
import lombok.Data; |
|||
|
|||
import java.io.Serial; |
|||
import java.io.Serializable; |
|||
import java.math.BigDecimal; |
|||
|
|||
/** |
|||
* 光伏项目点位信息 |
|||
* |
|||
* @author xc |
|||
* @since 3.0 2024-01-29 |
|||
*/ |
|||
@Data |
|||
@Schema( description= "光伏项目点位信息") |
|||
public class PlantDTO implements Serializable { |
|||
@Serial |
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
@Schema(description = "电站Id") |
|||
private Long plantId; |
|||
@Schema(description = "电站名称") |
|||
private String plantName; |
|||
@Schema(description = "建站日期(yyyy-MM-dd)") |
|||
private String buildDate; |
|||
@Schema(description = "所属国家") |
|||
private String country; |
|||
@Schema(description = "所属省份") |
|||
private String province; |
|||
@Schema(description = "所属城市") |
|||
private String city; |
|||
@Schema(description = "所属区县") |
|||
private String area; |
|||
@Schema(description = "电站所在具体地址") |
|||
private String address; |
|||
@Schema(description = "电站状态(1 正常 2 离线 3报警)") |
|||
private Integer status; |
|||
@Schema(description = "电站装机容量 (单位:kWp)") |
|||
private BigDecimal capacity; |
|||
@Schema(description = "电站最后同步数据时间") |
|||
private String lastReportTime; |
|||
@Schema(description = "经度") |
|||
private BigDecimal longitude; |
|||
@Schema(description = "纬度") |
|||
private BigDecimal latitude; |
|||
@Schema(description = "图片") |
|||
private String url; |
|||
@Schema(description = "并网日期(yyyy-MM-dd)") |
|||
private String gridDate; |
|||
@Schema(description = "衰减率") |
|||
private BigDecimal attenuation; |
|||
@Schema(description = "日照时常") |
|||
private BigDecimal sunshine; |
|||
@Schema(description = "电站收益, 每千瓦时发电量减排二氧化碳, 标准化单位") |
|||
private String profitco2; |
|||
@Schema(description = "电站收益, 每千瓦时发电量节省标准煤, 标准化单位") |
|||
private BigDecimal profitcoal; |
|||
@Schema(description = "电站收益, 每千瓦时发电量减排二氧化硫, 标准化单位") |
|||
private BigDecimal profitso2; |
|||
@Schema(description = "电站收益, 每千瓦时发电量收益") |
|||
private BigDecimal unitProfit; |
|||
@Schema(description = "当年每千瓦时发电量减排二氧化碳量") |
|||
private String reductionyy; |
|||
@Schema(description = "当年发电A29") |
|||
private String attrKey29yy; |
|||
@Schema(description = "当月发电A29") |
|||
private String attrKey29mm; |
|||
@Schema(description = "当年发电量") |
|||
private String val29yy; |
|||
@Schema(description = "当月发电量") |
|||
private String val29mm; |
|||
@Schema(description = "发电功率A16") |
|||
private String attrKey16; |
|||
@Schema(description = "发电功率") |
|||
private String val16; |
|||
@Schema(description = "今日发电量") |
|||
private String attrKey29dd; |
|||
@Schema(description = "今日发电量") |
|||
private String val29dd; |
|||
@Schema(description = "今日每千瓦时发电量减排二氧化碳量") |
|||
private String reductiondd; |
|||
@Schema(description = "逆变器数量") |
|||
private Integer inverterNum = 0; |
|||
@Schema(description = "检测点运行正常") |
|||
private BigDecimal pointNormal = BigDecimal.ZERO; |
|||
@Schema(description = "检测点运行总量") |
|||
private BigDecimal pointTotal = BigDecimal.ZERO; |
|||
|
|||
} |
|||
@ -1,57 +0,0 @@ |
|||
package com.thing.qingyuan.manageboard.dto; |
|||
|
|||
import io.swagger.v3.oas.annotations.media.Schema; |
|||
import lombok.AllArgsConstructor; |
|||
import lombok.Data; |
|||
import lombok.NoArgsConstructor; |
|||
|
|||
import java.io.Serial; |
|||
import java.io.Serializable; |
|||
import java.math.BigDecimal; |
|||
|
|||
/** |
|||
* 光伏项目点位信息 |
|||
* |
|||
* @author xc |
|||
* @since 3.0 2024-01-29 |
|||
*/ |
|||
@Data |
|||
@Schema( description= "光伏项目发电量,上网量,减排量等信息") |
|||
@AllArgsConstructor |
|||
@NoArgsConstructor |
|||
public class PlantInfoReq implements Serializable { |
|||
@Serial |
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
@Schema(description = "电站Id") |
|||
private Long plantId; |
|||
@Schema(description = "电站名称") |
|||
private String plantName; |
|||
@Schema(description = "建站日期") |
|||
private String buildDate; |
|||
@Schema(description = "装机容量 (单位:kWp)") |
|||
private BigDecimal capacity; |
|||
@Schema(description = "年发电量(单位:万kWh)") |
|||
private BigDecimal powerGeneration; |
|||
@Schema(description = "年上网量 (单位:万kWh)") |
|||
private BigDecimal internetUsage; |
|||
@Schema(description = "年减排量 (单位:tCO₂)") |
|||
private BigDecimal minusTCO2; |
|||
@Schema(description = "所属国家") |
|||
private String country; |
|||
@Schema(description = "所属省份") |
|||
private String province; |
|||
@Schema(description = "所属城市") |
|||
private String city; |
|||
@Schema(description = "所属区县") |
|||
private String area; |
|||
@Schema(description = "电站所在具体地址") |
|||
private String address; |
|||
@Schema(description = "电站状态(1 正常 2 离线 3报警)") |
|||
private Integer status; |
|||
@Schema(description = "衰减率") |
|||
private BigDecimal attenuation; |
|||
@Schema(description = "日照时常") |
|||
private BigDecimal sunshine; |
|||
|
|||
} |
|||
@ -1,32 +0,0 @@ |
|||
package com.thing.qingyuan.manageboard.dto; |
|||
|
|||
import io.swagger.v3.oas.annotations.media.Schema; |
|||
import lombok.AllArgsConstructor; |
|||
import lombok.Data; |
|||
import lombok.NoArgsConstructor; |
|||
|
|||
import java.io.Serial; |
|||
import java.io.Serializable; |
|||
|
|||
/** |
|||
* 光伏项目点位信息 |
|||
* |
|||
* @author xc |
|||
* @since 3.0 2024-01-29 |
|||
*/ |
|||
@Data |
|||
@Schema( description= "光伏项目点位信息") |
|||
@AllArgsConstructor |
|||
@NoArgsConstructor |
|||
public class PlantReq implements Serializable { |
|||
@Serial |
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
@Schema(description = "电站Id") |
|||
private Long plantId; |
|||
@Schema(description = "电站名称") |
|||
private String plantName; |
|||
@Schema(description = "序号") |
|||
private Integer sort = 0; |
|||
|
|||
} |
|||
Some files were not shown because too many files changed in this diff
Write
Preview
Loading…
Cancel
Save
Reference in new issue