diff --git a/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/electric/entity/ThirtyEntity.java b/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/electric/entity/ThirtyEntity.java new file mode 100644 index 0000000..db4fcb9 --- /dev/null +++ b/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/electric/entity/ThirtyEntity.java @@ -0,0 +1,46 @@ +package com.hnac.hzims.electric.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import org.springblade.core.tenant.mp.TenantEntity; + +import java.math.BigDecimal; + +/** + * 实体类 + * + * @author Chill + */ +@Data +@TableName("hzims_em_thirty_generate") +@EqualsAndHashCode(callSuper = true) +@ApiModel(value = "设备30天发电量对象", description = "") +public class ThirtyEntity extends TenantEntity { + + @ApiModelProperty(value = "站点编码") + private String stationId; + + @ApiModelProperty(value = "站点名称") + private String stationName; + + @ApiModelProperty(value = "设备编号") + private String deviceCode; + + @ApiModelProperty(value = "设备名称") + private String deviceName; + + @ApiModelProperty(value = "月份 : String") + private String strDay; + + @ApiModelProperty(value = "月份 : Int") + private Integer day; + + @ApiModelProperty(value = "发电量") + private BigDecimal generate; + + @ApiModelProperty(value = "无功发电量") + private BigDecimal reactiveGenerate; +} diff --git a/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/electric/entity/ThreeEntity.java b/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/electric/entity/ThreeEntity.java new file mode 100644 index 0000000..7f5b9c0 --- /dev/null +++ b/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/electric/entity/ThreeEntity.java @@ -0,0 +1,46 @@ +package com.hnac.hzims.electric.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import org.springblade.core.tenant.mp.TenantEntity; + +import java.math.BigDecimal; + +/** + * 实体类 + * + * @author Chill + */ +@Data +@TableName("hzims_em_three_generate") +@EqualsAndHashCode(callSuper = true) +@ApiModel(value = "设备3年发电量对象", description = "") +public class ThreeEntity extends TenantEntity { + + @ApiModelProperty(value = "站点编码") + private String stationId; + + @ApiModelProperty(value = "站点名称") + private String stationName; + + @ApiModelProperty(value = "设备编号") + private String deviceCode; + + @ApiModelProperty(value = "设备名称") + private String deviceName; + + @ApiModelProperty(value = "月份 : String") + private String strMonth; + + @ApiModelProperty(value = "月份 : Int") + private Integer month; + + @ApiModelProperty(value = "发电量") + private BigDecimal generate; + + @ApiModelProperty(value = "无功电量") + private BigDecimal reactiveGenerate; +} \ No newline at end of file diff --git a/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/electric/vo/TableHeadVo.java b/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/electric/vo/TableHeadVo.java new file mode 100644 index 0000000..2cfcb83 --- /dev/null +++ b/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/electric/vo/TableHeadVo.java @@ -0,0 +1,23 @@ +package com.hnac.hzims.electric.vo; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.List; + + +/** + * @author 表头 + */ +@Data +public class TableHeadVo { + + @ApiModelProperty(value = "表头名字") + private String tableName; + + @ApiModelProperty(value = "是否存在子表头") + private Boolean isChildren; + + @ApiModelProperty(value = "子表头列表") + private List children; +} \ No newline at end of file diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/feign/IStationClient.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/feign/IStationClient.java index da6326c..53cc157 100644 --- a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/feign/IStationClient.java +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/feign/IStationClient.java @@ -33,6 +33,8 @@ public interface IStationClient { String GET_STATIONS_BY_TYPE_AND_DURATION = API_PREFIX + "/getStationByTypeAndDuration"; String QUERY_STATION_BY_CODES = API_PREFIX + "/querySatationByCodes"; + String GET_STATIONS_BY_REF_DEPTS = API_PREFIX + "/getStationsByRefDepts"; + @GetMapping(GET_LIST_ALL) R> getListAll(); @@ -86,4 +88,7 @@ public interface IStationClient { R> getStationByTypeAndDuration(@RequestParam(value = "startTime",required = false) String startTime, @RequestParam(value = "endTime",required = false) String endTime, @RequestParam(value = "type",required = false) String type); + + @GetMapping(GET_STATIONS_BY_REF_DEPTS) + R> getStationsByRefDepts(@RequestParam(value = "deptIds",required = false) List deptIds); } diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/feign/IStationClientFallBack.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/feign/IStationClientFallBack.java index 0607d79..171b0a4 100644 --- a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/feign/IStationClientFallBack.java +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/feign/IStationClientFallBack.java @@ -82,4 +82,9 @@ public class IStationClientFallBack implements IStationClient { public R> getStationByTypeAndDuration(String startTime, String endTime, String type) { return R.fail("远程调用失败!"); } + + @Override + public R> getStationsByRefDepts(List deptIds) { + return R.fail("远程调用失败!"); + } } diff --git a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/train/entity/InstitutionalEntity.java b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/train/entity/InstitutionalEntity.java index aefa8e8..081a63f 100644 --- a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/train/entity/InstitutionalEntity.java +++ b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/train/entity/InstitutionalEntity.java @@ -41,4 +41,10 @@ public class InstitutionalEntity extends TenantEntity { @ApiModelProperty(value = "附件名称") private String dataAttachmentName; + + @ApiModelProperty(value = "添加人ID") + private String createUserId; + + @ApiModelProperty(value = "添加人名称") + private String createUserName; } \ No newline at end of file diff --git a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/train/entity/RectificationEntity.java b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/train/entity/RectificationEntity.java index bc97440..06c412b 100644 --- a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/train/entity/RectificationEntity.java +++ b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/train/entity/RectificationEntity.java @@ -1,11 +1,14 @@ package com.hnac.hzims.safeproduct.train.entity; import com.baomidou.mybatisplus.annotation.TableName; +import com.fasterxml.jackson.annotation.JsonFormat; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import lombok.EqualsAndHashCode; import org.springblade.core.tenant.mp.TenantEntity; +import org.springblade.core.tool.utils.DateUtil; +import org.springframework.format.annotation.DateTimeFormat; import java.util.Date; @@ -34,12 +37,18 @@ public class RectificationEntity extends TenantEntity { private Integer rectificationType; @ApiModelProperty(value = "限时日期") + @DateTimeFormat(pattern = DateUtil.PATTERN_DATETIME) + @JsonFormat(pattern = DateUtil.PATTERN_DATETIME) private Date limitTime; @ApiModelProperty(value = "提醒日期") + @DateTimeFormat(pattern = DateUtil.PATTERN_DATETIME) + @JsonFormat(pattern = DateUtil.PATTERN_DATETIME) private Date remindTime; @ApiModelProperty(value = "完成日期") + @DateTimeFormat(pattern = DateUtil.PATTERN_DATETIME) + @JsonFormat(pattern = DateUtil.PATTERN_DATETIME) private Date completeTime; @ApiModelProperty(value = "问题事项") @@ -53,4 +62,10 @@ public class RectificationEntity extends TenantEntity { @ApiModelProperty(value = "问题附件名称") private String problemAttachmentName; + + @ApiModelProperty(value = "添加人ID") + private String createUserId; + + @ApiModelProperty(value = "添加人名称") + private String createUserName; } diff --git a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/train/entity/TrainEntity.java b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/train/entity/TrainEntity.java index 62cfb70..7223e9c 100644 --- a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/train/entity/TrainEntity.java +++ b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/train/entity/TrainEntity.java @@ -62,4 +62,10 @@ public class TrainEntity extends TenantEntity { @ApiModelProperty(value = "培训附件名称") private String trainAttachmentName; + + @ApiModelProperty(value = "添加人ID") + private String createUserId; + + @ApiModelProperty(value = "添加人名称") + private String createUserName; } \ No newline at end of file diff --git a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/train/entity/ViolationEntity.java b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/train/entity/ViolationEntity.java index 0512f76..884f92d 100644 --- a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/train/entity/ViolationEntity.java +++ b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/train/entity/ViolationEntity.java @@ -59,4 +59,10 @@ public class ViolationEntity extends TenantEntity { @ApiModelProperty(value = "通知单附件名称") private String noticeAttachmentName; + + @ApiModelProperty(value = "添加人ID") + private String createUserId; + + @ApiModelProperty(value = "添加人名称") + private String createUserName; } diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/electric/controller/ElectricReportController.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/electric/controller/ElectricReportController.java new file mode 100644 index 0000000..361658b --- /dev/null +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/electric/controller/ElectricReportController.java @@ -0,0 +1,38 @@ +package com.hnac.hzims.electric.controller; + +import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; +import com.hnac.hzims.electric.service.IElectricReportService; +import com.hnac.hzims.equipment.entity.EmAssociationEntity; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.AllArgsConstructor; +import org.springblade.core.boot.ctrl.BladeController; +import org.springblade.core.mp.support.Condition; +import org.springblade.core.tool.api.R; +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.Map; + +/** + * @author ysj + */ +@RestController +@AllArgsConstructor +@RequestMapping("/electric") +@Api(tags = "电量报表") +public class ElectricReportController extends BladeController { + + private final IElectricReportService service; + + @GetMapping("/basics") + @ApiOperationSupport(order = 1) + @ApiOperation(value = "基础报表", notes = "传入 type : 0-日报 1-月报 2-年报") + public R> basics(@RequestParam(value = "deptId",required = false) Long deptId, + @RequestParam(value = "type") Long type, + @RequestParam(value = "time") String time) { + return R.data(service.basics(deptId,type,time)); + } +} \ No newline at end of file diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/electric/mapper/ThirtyMapper.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/electric/mapper/ThirtyMapper.java new file mode 100644 index 0000000..f5f2775 --- /dev/null +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/electric/mapper/ThirtyMapper.java @@ -0,0 +1,12 @@ +package com.hnac.hzims.electric.mapper; + + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.hnac.hzims.electric.entity.ThirtyEntity; + +/** + * @author ysj + */ +public interface ThirtyMapper extends BaseMapper { + +} \ No newline at end of file diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/electric/mapper/ThirtyMapper.xml b/hzims-service/equipment/src/main/java/com/hnac/hzims/electric/mapper/ThirtyMapper.xml new file mode 100644 index 0000000..8a36f81 --- /dev/null +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/electric/mapper/ThirtyMapper.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/electric/mapper/ThreeMapper.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/electric/mapper/ThreeMapper.java new file mode 100644 index 0000000..9f1918d --- /dev/null +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/electric/mapper/ThreeMapper.java @@ -0,0 +1,13 @@ +package com.hnac.hzims.electric.mapper; + + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.hnac.hzims.electric.entity.ThreeEntity; + +/** + * @author ysj + */ +public interface ThreeMapper extends BaseMapper { + + +} \ No newline at end of file diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/electric/mapper/ThreeMapper.xml b/hzims-service/equipment/src/main/java/com/hnac/hzims/electric/mapper/ThreeMapper.xml new file mode 100644 index 0000000..b09575a --- /dev/null +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/electric/mapper/ThreeMapper.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/electric/service/IElectricReportService.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/electric/service/IElectricReportService.java new file mode 100644 index 0000000..a579675 --- /dev/null +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/electric/service/IElectricReportService.java @@ -0,0 +1,12 @@ +package com.hnac.hzims.electric.service; + +import java.util.Map; + +/** + * @author ysj + */ +public interface IElectricReportService { + + + Map basics(Long deptId, Long type,String time); +} diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/electric/service/ThirtyService.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/electric/service/ThirtyService.java new file mode 100644 index 0000000..8afa40a --- /dev/null +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/electric/service/ThirtyService.java @@ -0,0 +1,11 @@ +package com.hnac.hzims.electric.service; + +import com.hnac.hzims.electric.entity.ThirtyEntity; +import org.springblade.core.mp.base.BaseService; + +/** + * @author ysj + */ +public interface ThirtyService extends BaseService { + +} \ No newline at end of file diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/electric/service/ThreeService.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/electric/service/ThreeService.java new file mode 100644 index 0000000..77e6ab2 --- /dev/null +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/electric/service/ThreeService.java @@ -0,0 +1,11 @@ +package com.hnac.hzims.electric.service; + +import com.hnac.hzims.electric.entity.ThreeEntity; +import org.springblade.core.mp.base.BaseService; + +/** + * @author ysj + */ +public interface ThreeService extends BaseService { + +} \ No newline at end of file diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/electric/service/impl/ElectricReportServiceImpl.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/electric/service/impl/ElectricReportServiceImpl.java new file mode 100644 index 0000000..bd70dda --- /dev/null +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/electric/service/impl/ElectricReportServiceImpl.java @@ -0,0 +1,385 @@ +package com.hnac.hzims.electric.service.impl; + + +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.hnac.hzims.electric.entity.ThirtyEntity; +import com.hnac.hzims.electric.entity.ThreeEntity; +import com.hnac.hzims.electric.service.IElectricReportService; +import com.hnac.hzims.electric.service.ThirtyService; +import com.hnac.hzims.electric.service.ThreeService; +import com.hnac.hzims.electric.vo.TableHeadVo; +import com.hnac.hzims.operational.station.entity.StationEntity; +import com.hnac.hzims.operational.station.feign.IStationClient; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springblade.core.tool.api.R; +import org.springblade.core.tool.utils.CollectionUtil; +import org.springblade.core.tool.utils.DateUtil; +import org.springblade.core.tool.utils.ObjectUtil; +import org.springblade.system.entity.Dept; +import org.springblade.system.feign.ISysClient; +import org.springframework.stereotype.Service; + +import java.util.*; +import java.util.stream.Collectors; + +/** + * @author ysj + */ +@Slf4j +@Service +@RequiredArgsConstructor +public class ElectricReportServiceImpl implements IElectricReportService { + + private final ThreeService threeService; + + private final ThirtyService thirtyService; + + private final ISysClient sysClient; + + private final IStationClient stationClient; + + /** + * 基础报表 + * @param deptId + * @param type + * @return + */ + @Override + public Map basics(Long deptId, Long type,String time) { + Map result = new HashMap<>(); + + // 步骤1.查询当前用户权限机构 + R> depts = sysClient.getDeptByCurrentUser(); + + // 步骤2.确认机构级别 + Integer category = this.category(depts.getData(),deptId); + if(category < 0){ + return result; + } + + // 步骤3.根据级别进行查询发电数据 + switch (category){ + case 4: + return this.station(deptId,type,time); + case 3: + List deptIds = depts.getData().stream().filter(dept->dept.getParentId().equals(deptId)).map(Dept::getId).collect(Collectors.toList()); + return this.area(deptIds,type,time); + case 2: + case 1: + //return this.group(); + default: + return result; + + } + } + + /** + * 确认机构级别 + * @param deptId + * @return + */ + private Integer category(List depts,Long deptId) { + if(ObjectUtil.isEmpty(deptId)){ + if(CollectionUtil.isEmpty(depts)){ + return -1; + } + Optional optional = depts.stream().min(Comparator.comparing(Dept::getDeptCategory)); + return optional.get().getDeptCategory(); + } + R dept = sysClient.getDept(deptId); + if(!dept.isSuccess() || ObjectUtil.isEmpty(dept)){ + return -1; + } + return dept.getData().getDeptCategory(); + } + + /** + * 区域级别数据 + * @param deptIds + * @param type + * @param time + * @return + */ + private Map area(List deptIds, Long type, String time) { + // 查询站点 + R> stations = stationClient.getStationsByRefDepts(deptIds); + if(!stations.isSuccess() || ObjectUtil.isEmpty(stations.getData())){ + return new HashMap<>(); + } + + Map result = new HashMap<>(); + // 月 + if (type == 1) { + // 查询月数据 + List thirtys = thirtyService.list(Wrappers.lambdaQuery() + //.isNotNull(ThirtyEntity::getDeviceCode) + .in(ThirtyEntity::getStationId,stations.getData().stream().map(StationEntity::getCode).collect(Collectors.toList())) + .like(ThirtyEntity::getStrDay,time) + ); + if(CollectionUtil.isEmpty(thirtys)){ + return new HashMap<>(); + } + // 表头 + List tableHeads = new ArrayList<>(); + TableHeadVo firstHead = new TableHeadVo(); + firstHead.setTableName("日期"); + firstHead.setIsChildren(false); + tableHeads.add(firstHead); + TableHeadVo secondHead = new TableHeadVo(); + secondHead.setTableName("日总计发电量"); + secondHead.setIsChildren(true); + secondHead.setChildren(Arrays.asList("日总有功","日总无功")); + tableHeads.add(secondHead); + + // 根据设备分组 + Map> group = thirtys.stream().collect(Collectors.groupingBy(ThirtyEntity::getStationName)); + group.keySet().stream().sorted().forEach(key->{ + TableHeadVo tableHead = new TableHeadVo(); + tableHead.setTableName(key + "发电量(kWh)"); + tableHead.setIsChildren(true); + tableHead.setChildren(Arrays.asList("日有功","日无功")); + tableHeads.add(tableHead); + }); + + result.put("tableHead",tableHeads); + // 组装数据 + Calendar calendar = Calendar.getInstance(); + calendar.setTime(DateUtil.parse(time + "-01 00:00:00",DateUtil.PATTERN_DATETIME)); + calendar.add(Calendar.MONTH,1); + Date end = calendar.getTime(); + calendar.add(Calendar.MONTH,-1); + Date start = calendar.getTime(); + List> tableDate = new ArrayList<>(); + while (start.compareTo(end) < 0){ + List item = new ArrayList<>(); + String day = DateUtil.format(start,DateUtil.PATTERN_DATE); + item.add(start.getDate() + "日"); + // 总计:有功、无功 + item.add(thirtys.stream().filter(thirty -> thirty.getStrDay().contains(day)).mapToDouble(o->o.getGenerate().doubleValue()).sum()); + item.add(thirtys.stream().filter(thirty -> thirty.getStrDay().contains(day)).mapToDouble(o->o.getReactiveGenerate().doubleValue()).sum()); + + // 遍历站点 + group.entrySet().stream().sorted(Map.Entry. + comparingByKey()).forEach(entry->{ + item.add(entry.getValue().stream().filter(thirty -> thirty.getStrDay().contains(day)).mapToDouble(o->o.getGenerate().doubleValue()).sum()); + item.add(entry.getValue().stream().filter(thirty -> thirty.getStrDay().contains(day)).mapToDouble(o->o.getReactiveGenerate().doubleValue()).sum()); + }); + calendar.add(Calendar.DAY_OF_MONTH,1); + start = calendar.getTime(); + tableDate.add(item); + } + result.put("tableDate",tableDate); + } + // 年 + else if (type == 2) { + // 查询月数据 + List threes = threeService.list(Wrappers.lambdaQuery() + .isNotNull(ThreeEntity::getDeviceCode) + .in(ThreeEntity::getStationId,stations.getData().stream().map(StationEntity::getCode).collect(Collectors.toList())) + .like(ThreeEntity::getStrMonth,time) + ); + if(CollectionUtil.isEmpty(threes)){ + return new HashMap<>(); + } + // 表头 + List tableHeads = new ArrayList<>(); + TableHeadVo firstHead = new TableHeadVo(); + firstHead.setTableName("月份"); + firstHead.setIsChildren(false); + tableHeads.add(firstHead); + TableHeadVo secondHead = new TableHeadVo(); + secondHead.setTableName("月总计发电量"); + secondHead.setIsChildren(true); + secondHead.setChildren(Arrays.asList("月总有功","月总无功")); + tableHeads.add(secondHead); + + // 根据站点分组 + Map> group = threes.stream().collect(Collectors.groupingBy(ThreeEntity::getStationName)); + group.keySet().stream().sorted().forEach(key->{ + TableHeadVo tableHead = new TableHeadVo(); + tableHead.setTableName(key + "发电量(kWh)"); + tableHead.setIsChildren(true); + tableHead.setChildren(Arrays.asList("月有功","月无功")); + tableHeads.add(tableHead); + }); + + result.put("tableHead",tableHeads); + // 组装数据 + Calendar calendar = Calendar.getInstance(); + calendar.setTime(DateUtil.parse(time + "-01-01 00:00:00",DateUtil.PATTERN_DATETIME)); + calendar.add(Calendar.YEAR,1); + Date end = calendar.getTime(); + calendar.add(Calendar.YEAR,-1); + Date start = calendar.getTime(); + List> tableDate = new ArrayList<>(); + while (start.compareTo(end) < 0){ + List item = new ArrayList<>(); + String mon = DateUtil.format(start,"yyyy-MM"); + item.add(start.getMonth() + 1 + "月"); + // 总计:有功、无功 + item.add(threes.stream().filter(three -> three.getStrMonth().contains(mon)).mapToDouble(o->o.getGenerate().doubleValue()).sum()); + item.add(threes.stream().filter(three -> three.getStrMonth().contains(mon)).mapToDouble(o->o.getReactiveGenerate().doubleValue()).sum()); + + // 遍历站点 + group.entrySet().stream().sorted(Map.Entry. + comparingByKey()).forEach(entry->{ + item.add(entry.getValue().stream().filter(three -> three.getStrMonth().contains(mon)).mapToDouble(o->o.getGenerate().doubleValue()).sum()); + item.add(entry.getValue().stream().filter(three -> three.getStrMonth().contains(mon)).mapToDouble(o->o.getReactiveGenerate().doubleValue()).sum()); + }); + calendar.add(Calendar.MONTH,1); + start = calendar.getTime(); + tableDate.add(item); + } + result.put("tableDate",tableDate); + } + return result; + } + + /** + * 站点级别数据 + * @param deptId + * @param type + * @return + */ + private Map station(Long deptId, Long type,String time) { + // 查询站点 + StationEntity param = new StationEntity(); + param.setRefDept(deptId); + R station = stationClient.getStationByCodeOrRedDept(param); + if(!station.isSuccess() || ObjectUtil.isEmpty(station.getData())){ + return new HashMap<>(); + } + + Map result = new HashMap<>(); + // 日 + if (type == 0) { + + } + // 月 + else if (type == 1) { + // 查询月数据 + List thirtys = thirtyService.list(Wrappers.lambdaQuery() + .isNotNull(ThirtyEntity::getDeviceCode) + .eq(ThirtyEntity::getStationId,station.getData().getCode()) + .like(ThirtyEntity::getStrDay,time) + ); + if(CollectionUtil.isEmpty(thirtys)){ + return new HashMap<>(); + } + // 表头 + List tableHeads = new ArrayList<>(); + TableHeadVo firstHead = new TableHeadVo(); + firstHead.setTableName("日期"); + firstHead.setIsChildren(false); + tableHeads.add(firstHead); + TableHeadVo secondHead = new TableHeadVo(); + secondHead.setTableName("日总计发电量"); + secondHead.setIsChildren(true); + secondHead.setChildren(Arrays.asList("日总有功","日总无功")); + tableHeads.add(secondHead); + + // 根据设备分组 + Map> group = thirtys.stream().collect(Collectors.groupingBy(ThirtyEntity::getDeviceName)); + group.keySet().stream().sorted().forEach(key->{ + TableHeadVo tableHead = new TableHeadVo(); + tableHead.setTableName(key + "发电量(kWh)"); + tableHead.setIsChildren(true); + tableHead.setChildren(Arrays.asList("日有功","日无功")); + tableHeads.add(tableHead); + }); + + result.put("tableHead",tableHeads); + // 组装数据 + Calendar calendar = Calendar.getInstance(); + calendar.setTime(DateUtil.parse(time + "-01 00:00:00",DateUtil.PATTERN_DATETIME)); + calendar.add(Calendar.MONTH,1); + Date end = calendar.getTime(); + calendar.add(Calendar.MONTH,-1); + Date start = calendar.getTime(); + List> tableDate = new ArrayList<>(); + while (start.compareTo(end) < 0){ + List item = new ArrayList<>(); + String day = DateUtil.format(start,DateUtil.PATTERN_DATE); + item.add(start.getDate() + "日"); + // 总计:有功、无功 + item.add(thirtys.stream().filter(thirty -> thirty.getStrDay().contains(day)).mapToDouble(o->o.getGenerate().doubleValue()).sum()); + item.add(thirtys.stream().filter(thirty -> thirty.getStrDay().contains(day)).mapToDouble(o->o.getReactiveGenerate().doubleValue()).sum()); + + // 遍历机组 + group.entrySet().stream().sorted(Map.Entry. + comparingByKey()).forEach(entry->{ + item.add(entry.getValue().stream().filter(thirty -> thirty.getStrDay().contains(day)).mapToDouble(o->o.getGenerate().doubleValue()).sum()); + item.add(entry.getValue().stream().filter(thirty -> thirty.getStrDay().contains(day)).mapToDouble(o->o.getReactiveGenerate().doubleValue()).sum()); + }); + calendar.add(Calendar.DAY_OF_MONTH,1); + start = calendar.getTime(); + tableDate.add(item); + } + result.put("tableDate",tableDate); + } + // 年 + else if (type == 2) { + // 查询月数据 + List threes = threeService.list(Wrappers.lambdaQuery() + .isNotNull(ThreeEntity::getDeviceCode) + .eq(ThreeEntity::getStationId,station.getData().getCode()) + .like(ThreeEntity::getStrMonth,time) + ); + if(CollectionUtil.isEmpty(threes)){ + return new HashMap<>(); + } + // 表头 + List tableHeads = new ArrayList<>(); + TableHeadVo firstHead = new TableHeadVo(); + firstHead.setTableName("月份"); + firstHead.setIsChildren(false); + tableHeads.add(firstHead); + TableHeadVo secondHead = new TableHeadVo(); + secondHead.setTableName("月总计发电量"); + secondHead.setIsChildren(true); + secondHead.setChildren(Arrays.asList("月总有功","月总无功")); + tableHeads.add(secondHead); + + // 根据设备分组 + Map> group = threes.stream().collect(Collectors.groupingBy(ThreeEntity::getDeviceName)); + group.keySet().stream().sorted().forEach(key->{ + TableHeadVo tableHead = new TableHeadVo(); + tableHead.setTableName(key + "发电量(kWh)"); + tableHead.setIsChildren(true); + tableHead.setChildren(Arrays.asList("月有功","月无功")); + tableHeads.add(tableHead); + }); + + result.put("tableHead",tableHeads); + // 组装数据 + Calendar calendar = Calendar.getInstance(); + calendar.setTime(DateUtil.parse(time + "-01-01 00:00:00",DateUtil.PATTERN_DATETIME)); + calendar.add(Calendar.YEAR,1); + Date end = calendar.getTime(); + calendar.add(Calendar.YEAR,-1); + Date start = calendar.getTime(); + List> tableDate = new ArrayList<>(); + while (start.compareTo(end) < 0){ + List item = new ArrayList<>(); + String mon = DateUtil.format(start,"yyyy-MM"); + item.add(start.getMonth() + 1 + "月"); + // 总计:有功、无功 + item.add(threes.stream().filter(three -> three.getStrMonth().contains(mon)).mapToDouble(o->o.getGenerate().doubleValue()).sum()); + item.add(threes.stream().filter(three -> three.getStrMonth().contains(mon)).mapToDouble(o->o.getReactiveGenerate().doubleValue()).sum()); + + // 遍历机组 + group.entrySet().stream().sorted(Map.Entry. + comparingByKey()).forEach(entry->{ + item.add(entry.getValue().stream().filter(three -> three.getStrMonth().contains(mon)).mapToDouble(o->o.getGenerate().doubleValue()).sum()); + item.add(entry.getValue().stream().filter(three -> three.getStrMonth().contains(mon)).mapToDouble(o->o.getReactiveGenerate().doubleValue()).sum()); + }); + calendar.add(Calendar.MONTH,1); + start = calendar.getTime(); + tableDate.add(item); + } + result.put("tableDate",tableDate); + } + return result; + } +} \ No newline at end of file diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/electric/service/impl/ThirtyServiceImpl.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/electric/service/impl/ThirtyServiceImpl.java new file mode 100644 index 0000000..a900fd5 --- /dev/null +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/electric/service/impl/ThirtyServiceImpl.java @@ -0,0 +1,20 @@ +package com.hnac.hzims.electric.service.impl; + +import com.hnac.hzims.electric.entity.ThirtyEntity; +import com.hnac.hzims.electric.mapper.ThirtyMapper; +import com.hnac.hzims.electric.service.ThirtyService; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springblade.core.mp.base.BaseServiceImpl; +import org.springframework.stereotype.Service; + +/** + * @author ysj + */ +@Slf4j +@Service +@RequiredArgsConstructor +public class ThirtyServiceImpl extends BaseServiceImpl implements ThirtyService { + + +} \ No newline at end of file diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/electric/service/impl/ThreeServiceImpl.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/electric/service/impl/ThreeServiceImpl.java new file mode 100644 index 0000000..9f3be12 --- /dev/null +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/electric/service/impl/ThreeServiceImpl.java @@ -0,0 +1,20 @@ +package com.hnac.hzims.electric.service.impl; + +import com.hnac.hzims.electric.entity.ThreeEntity; +import com.hnac.hzims.electric.mapper.ThreeMapper; +import com.hnac.hzims.electric.service.ThreeService; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springblade.core.mp.base.BaseServiceImpl; +import org.springframework.stereotype.Service; + +/** + * @author ysj + */ +@Slf4j +@Service +@RequiredArgsConstructor +public class ThreeServiceImpl extends BaseServiceImpl implements ThreeService { + + +} diff --git a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/offline/service/impl/InspectOfflineServiceImpl.java b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/offline/service/impl/InspectOfflineServiceImpl.java index 62d76e2..dc7cec6 100644 --- a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/offline/service/impl/InspectOfflineServiceImpl.java +++ b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/offline/service/impl/InspectOfflineServiceImpl.java @@ -967,7 +967,8 @@ public class InspectOfflineServiceImpl implements IOfflineDataService { public R putFile(File file) throws IOException { FileItem fileItem = new DiskFileItem("file", Files.probeContentType(file.toPath()),false,file.getName(),(int)file.length(),file.getParentFile()); - try (InputStream inputStream = new FileInputStream(file); OutputStream os = fileItem.getOutputStream()){ + try (InputStream inputStream = new FileInputStream(file); + OutputStream os = fileItem.getOutputStream()){ IOUtils.copy(inputStream,os); /* diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/impl/AccessPlanV4ServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/impl/AccessPlanV4ServiceImpl.java index 029d156..cc715ff 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/impl/AccessPlanV4ServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/impl/AccessPlanV4ServiceImpl.java @@ -256,14 +256,14 @@ public class AccessPlanV4ServiceImpl implements AccessPlanV4Service, StartProces detail.setId(null); contentService.save(detail); if(CollectionUtil.isNotEmpty(detail.getAccessContentDetails())){ + List contentDetails = contentDetailService.list(new LambdaQueryWrapper() {{ + eq(OperAccessContentDetailEntity::getContentId, detail.getId()); + }}); + // 先删除 + if(CollectionUtil.isNotEmpty(contentDetails)){ + contentDetailService.removeByIds(contentDetails.stream().map(OperAccessContentDetailEntity::getId).collect(Collectors.toList())); + } for (OperAccessContentDetailDTO contentDetail : detail.getAccessContentDetails()){ - List contentDetails = contentDetailService.list(new LambdaQueryWrapper() {{ - eq(OperAccessContentDetailEntity::getContentId, detail.getId()); - }}); - // 先删除 - if(CollectionUtil.isNotEmpty(contentDetails)){ - contentDetailService.removeByIds(contentDetails.stream().map(OperAccessContentDetailEntity::getId).collect(Collectors.toList())); - } // 再保存 contentDetail.setId(null); contentDetail.setContentId(detail.getId()); diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/feign/StationClient.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/feign/StationClient.java index 619a196..8746669 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/feign/StationClient.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/feign/StationClient.java @@ -12,6 +12,7 @@ import lombok.AllArgsConstructor; import lombok.RequiredArgsConstructor; import org.springblade.core.mp.support.Condition; import org.springblade.core.tool.api.R; +import org.springblade.core.tool.utils.CollectionUtil; import org.springblade.core.tool.utils.Func; import org.springblade.core.tool.utils.ObjectUtil; import org.springblade.core.tool.utils.StringUtil; @@ -150,6 +151,16 @@ public class StationClient implements IStationClient { return R.data(stationService.list(wrapper)); } + @Override + @GetMapping("/getStationsByRefDepts") + public R> getStationsByRefDepts(@RequestParam(value = "deptIds" , required = false) List deptIds) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + if(CollectionUtil.isNotEmpty(deptIds)) { + wrapper.in(StationEntity::getRefDept,deptIds); + } + return R.data(stationService.list(wrapper)); + } + @Override @PostMapping("/getStationByCodeOrRedDept") diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/train/service/impl/ViolationServiceImpl.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/train/service/impl/ViolationServiceImpl.java index da585f3..733debf 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/train/service/impl/ViolationServiceImpl.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/train/service/impl/ViolationServiceImpl.java @@ -30,13 +30,13 @@ public class ViolationServiceImpl extends ServiceImpl wrapper = new LambdaQueryWrapper(); wrapper.orderByDesc(ViolationEntity::getCreateTime); if(StringUtil.isNotBlank(params.getStationId())){ - wrapper.eq(ViolationEntity::getStationId,params.getStartTime()); + wrapper.eq(ViolationEntity::getStationId,params.getStationId()); } if(StringUtil.isNotBlank(params.getStartTime())){ wrapper.ge(ViolationEntity::getDiscoverTime,params.getStartTime()); } if(StringUtil.isNotBlank(params.getEndTime())){ - wrapper.eq(ViolationEntity::getDiscoverTime,params.getEndTime()); + wrapper.le(ViolationEntity::getDiscoverTime,params.getEndTime()); } if(ObjectUtil.isNotEmpty(params.getViolationLevel())){ wrapper.eq(ViolationEntity::getViolationLevel,params.getViolationLevel()); diff --git a/hzims-service/safeproduct/src/main/resources/dict/dict.sql b/hzims-service/safeproduct/src/main/resources/dict/dict.sql index 4904dfa..2830937 100644 --- a/hzims-service/safeproduct/src/main/resources/dict/dict.sql +++ b/hzims-service/safeproduct/src/main/resources/dict/dict.sql @@ -40,3 +40,18 @@ insert into `bladex`.`blade_dict`(`id`, `parent_id`, `code`, `dict_key`, `dict_v insert into `bladex`.`blade_dict`(`id`, `parent_id`, `code`, `dict_key`, `dict_value`, `sort`, `remark`, `is_sealed`, `is_deleted`, `dict_type`, `app_id`, `app_code`) values (1811421133117767768, 1810401848933404699, 'inner_danger_type', '3', '物的不安全行为', 5, '', 0, 0, 1, -1, 'hzims_safeproduct'); insert into `bladex`.`blade_dict`(`id`, `parent_id`, `code`, `dict_key`, `dict_value`, `sort`, `remark`, `is_sealed`, `is_deleted`, `dict_type`, `app_id`, `app_code`) values (1811421133117767769, 1810401848933404699, 'inner_danger_type', '4', '管理因素', 5, '', 0, 0, 1, -1, 'hzims_safeproduct'); insert into `bladex`.`blade_dict`(`id`, `parent_id`, `code`, `dict_key`, `dict_value`, `sort`, `remark`, `is_sealed`, `is_deleted`, `dict_type`, `app_id`, `app_code`) values (1811421133117767770, 1810401848933404699, 'inner_danger_type', '5', '其他', 5, '', 0, 0, 1, -1, 'hzims_safeproduct'); + +#违章级别 +INSERT INTO `bladex`.`blade_dict` (`id`, `parent_id`, `code`, `dict_key`, `dict_value`, `sort`, `remark`, `is_sealed`, `is_deleted`, `dict_type`, `app_id`, `app_code`) VALUES (1397731100361748001, 0, 'violation_level', '-1', '违章级别', 1, '', 0, 0, 0, -1, 'hzims_safeproduct'); +INSERT INTO `bladex`.`blade_dict` (`id`, `parent_id`, `code`, `dict_key`, `dict_value`, `sort`, `remark`, `is_sealed`, `is_deleted`, `dict_type`, `app_id`, `app_code`) VALUES (1397731100361748002, 1397731100361748001, 'violation_level', '0', '严重', 1, '', 0, 0, 0, -1, 'hzims_safeproduct'); +INSERT INTO `bladex`.`blade_dict` (`id`, `parent_id`, `code`, `dict_key`, `dict_value`, `sort`, `remark`, `is_sealed`, `is_deleted`, `dict_type`, `app_id`, `app_code`) VALUES (1397731100361748003, 1397731100361748001, 'violation_level', '1', '一般', 2, '', 0, 0, 0, -1, 'hzims_safeproduct'); + +#整改类型 +INSERT INTO `bladex`.`blade_dict` (`id`, `parent_id`, `code`, `dict_key`, `dict_value`, `sort`, `remark`, `is_sealed`, `is_deleted`, `dict_type`, `app_id`, `app_code`) VALUES (1397731100361748101, 0, 'rectification_type', '-1', '整改类型', 1, '', 0, 0, 0, -1, 'hzims_safeproduct'); +INSERT INTO `bladex`.`blade_dict` (`id`, `parent_id`, `code`, `dict_key`, `dict_value`, `sort`, `remark`, `is_sealed`, `is_deleted`, `dict_type`, `app_id`, `app_code`) VALUES (1397731100361748102, 1397731100361748101, 'rectification_type', '0', '整改闭环', 1, '', 0, 0, 0, -1, 'hzims_safeproduct'); +INSERT INTO `bladex`.`blade_dict` (`id`, `parent_id`, `code`, `dict_key`, `dict_value`, `sort`, `remark`, `is_sealed`, `is_deleted`, `dict_type`, `app_id`, `app_code`) VALUES (1397731100361748103, 1397731100361748101, 'rectification_type', '1', '会议督办', 2, '', 0, 0, 0, -1, 'hzims_safeproduct'); + +#整改状态 +INSERT INTO `bladex`.`blade_dict` (`id`, `parent_id`, `code`, `dict_key`, `dict_value`, `sort`, `remark`, `is_sealed`, `is_deleted`, `dict_type`, `app_id`, `app_code`) VALUES (1397731100361748201, 0, 'rectification_status', '-1', '整改状态', 1, '', 0, 0, 0, -1, 'hzims_safeproduct'); +INSERT INTO `bladex`.`blade_dict` (`id`, `parent_id`, `code`, `dict_key`, `dict_value`, `sort`, `remark`, `is_sealed`, `is_deleted`, `dict_type`, `app_id`, `app_code`) VALUES (1397731100361748202, 1397731100361748201, 'rectification_status', '0', '未整改', 1, '', 0, 0, 0, -1, 'hzims_safeproduct'); +INSERT INTO `bladex`.`blade_dict` (`id`, `parent_id`, `code`, `dict_key`, `dict_value`, `sort`, `remark`, `is_sealed`, `is_deleted`, `dict_type`, `app_id`, `app_code`) VALUES (1397731100361748203, 1397731100361748201, 'rectification_status', '1', '已整改', 2, '', 0, 0, 0, -1, 'hzims_safeproduct'); \ No newline at end of file