Browse Source

#水电站点发电量数据关联详情

zhongwei
yang_shj 1 year ago
parent
commit
b8b30c9ca4
  1. 22
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/census/vo/HydropowerTargetDetailVo.java
  2. 11
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/constant/HomePageConstant.java
  3. 2
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/GenerationPowerVo.java
  4. 6
      hzims-service-api/ticket-api/src/main/java/com/hnac/hzims/ticket/repair/entity/WorkTaskEntity.java
  5. 12
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/controller/TargetController.java
  6. 2
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/service/TargetService.java
  7. 104
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/service/impl/TargetServiceImpl.java
  8. 4
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/service/GenerateService.java
  9. 70
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/service/impl/GenerateServiceImpl.java
  10. 8
      hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/repair/service/impl/WorkTaskServiceImpl.java

22
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/census/vo/HydropowerTargetDetailVo.java

@ -0,0 +1,22 @@
package com.hnac.hzims.operational.census.vo;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.NullSerializer;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @author ysj
* @date 2023/03/14 15:01:17
* @version 4.0.0
*/
@Data
public class HydropowerTargetDetailVo {
@ApiModelProperty("日期")
private String time;
@ApiModelProperty("发电量")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Double electric;
}

11
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/constant/HomePageConstant.java

@ -314,6 +314,17 @@ public interface HomePageConstant {
* 功率 * 功率
**/ **/
Integer POWER = 0; Integer POWER = 0;
/**
*
*/
Long YEAR = 0L;
/**
*
*/
Long MON = 1L;
/*==========================================================================================*/ /*==========================================================================================*/
// 水利集团、区域指标关联 // 水利集团、区域指标关联
/** /**

2
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/GenerationPowerVo.java

@ -17,7 +17,7 @@ public class GenerationPowerVo {
@JsonSerialize(nullsUsing = NullSerializer.class) @JsonSerialize(nullsUsing = NullSerializer.class)
private Float generate; private Float generate;
@ApiModelProperty(value = "功率·") @ApiModelProperty(value = "功率")
@JsonSerialize(nullsUsing = NullSerializer.class) @JsonSerialize(nullsUsing = NullSerializer.class)
private Float load; private Float load;
} }

6
hzims-service-api/ticket-api/src/main/java/com/hnac/hzims/ticket/repair/entity/WorkTaskEntity.java

@ -57,6 +57,9 @@ public class WorkTaskEntity extends TenantEntity {
@ApiModelProperty(value = "工作计划结束时间") @ApiModelProperty(value = "工作计划结束时间")
private Date planEndTime; private Date planEndTime;
@ApiModelProperty(value = "工作票据ID")
private Long workTicketId;
@ApiModelProperty(value = "工作任务") @ApiModelProperty(value = "工作任务")
private String workTask; private String workTask;
@ -89,4 +92,7 @@ public class WorkTaskEntity extends TenantEntity {
@ApiModelProperty(value = "流程环节处理人") @ApiModelProperty(value = "流程环节处理人")
private String nextStepOperator; private String nextStepOperator;
@ApiModelProperty(value = "创建机构名称")
private String deptName;
} }

12
hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/controller/TargetController.java

@ -21,6 +21,8 @@ import org.springblade.core.mp.support.Query;
import org.springblade.core.tool.api.R; import org.springblade.core.tool.api.R;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.List;
/** /**
* @author ysj * @author ysj
* @date 2023/03/01 16:12:22 * @date 2023/03/01 16:12:22
@ -152,6 +154,15 @@ public class TargetController {
} }
@ApiLog @ApiLog
@ApiOperation("水电关联-发电详情")
@GetMapping("/hydropower-target-detail")
@ApiOperationSupport(order = 11)
public R<List<HydropowerTargetDetailVo>> hydropowerTargetDetail(@RequestParam(value = "stationName") String stationName,
@RequestParam(value = "type") Long type) {
return R.data(service.hydropowerTargetDetail(stationName,type));
}
@ApiLog
@ApiOperation("水利集团、区域指标关联") @ApiOperation("水利集团、区域指标关联")
@GetMapping("/water-target") @GetMapping("/water-target")
@ApiOperationSupport(order = 12) @ApiOperationSupport(order = 12)
@ -203,5 +214,4 @@ public class TargetController {
public R<IPage<OperAccessTaskVO>> access(AccessAssociationVo business,Query query) { public R<IPage<OperAccessTaskVO>> access(AccessAssociationVo business,Query query) {
return R.data(service.access(Condition.getPage(query),business)); return R.data(service.access(Condition.getPage(query),business));
} }
} }

2
hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/service/TargetService.java

@ -71,4 +71,6 @@ public interface TargetService {
IPage<OperPhenomenonVO> phenomenon(IPage<OperPhenomenonEntity> page, MaintenancePhenomenonVo business); IPage<OperPhenomenonVO> phenomenon(IPage<OperPhenomenonEntity> page, MaintenancePhenomenonVo business);
IPage<OperAccessTaskVO> access(IPage<OperAccessTaskEntity> page, AccessAssociationVo business); IPage<OperAccessTaskVO> access(IPage<OperAccessTaskEntity> page, AccessAssociationVo business);
List<HydropowerTargetDetailVo> hydropowerTargetDetail(String stationName, Long type);
} }

104
hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/service/impl/TargetServiceImpl.java

@ -43,6 +43,7 @@ import com.hnac.hzims.ticket.allTicket.vo.DoublePassRateVO;
import com.hnac.hzims.ticket.areamonthly.vo.MaintenanceTaskVo; import com.hnac.hzims.ticket.areamonthly.vo.MaintenanceTaskVo;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.apache.commons.collections4.MapUtils; import org.apache.commons.collections4.MapUtils;
import org.springblade.core.log.exception.ServiceException;
import org.springblade.core.mp.support.Query; import org.springblade.core.mp.support.Query;
import org.springblade.core.tool.api.R; import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.*; import org.springblade.core.tool.utils.*;
@ -83,6 +84,8 @@ public class TargetServiceImpl implements TargetService {
private final IStationService stationService; private final IStationService stationService;
private final GenerateService generateService;
private final OverDetailsService overDetailsService; private final OverDetailsService overDetailsService;
private final IOperAccessTaskService accessTaskService; private final IOperAccessTaskService accessTaskService;
@ -114,6 +117,8 @@ public class TargetServiceImpl implements TargetService {
private final static String load_waterpump_real_key = "hzims:operation:loadwaterpump:real:key"; private final static String load_waterpump_real_key = "hzims:operation:loadwaterpump:real:key";
private final static String recent_year_power_data = "hzims:operation:key:power:data";
private final static String load_photovoltaic_real_key = "hzims:operation:photovoltaic:real:key"; private final static String load_photovoltaic_real_key = "hzims:operation:photovoltaic:real:key";
private final static String load_hydropower_unit_real_key = "hzims:operation:loadhydropowerunit:real:key"; private final static String load_hydropower_unit_real_key = "hzims:operation:loadhydropowerunit:real:key";
@ -1205,4 +1210,103 @@ public class TargetServiceImpl implements TargetService {
pages.setRecords(OperAccessTaskWrapper.build().listVOExtras(pages.getRecords())); pages.setRecords(OperAccessTaskWrapper.build().listVOExtras(pages.getRecords()));
return pages; return pages;
} }
/**
* 水电关联-发电详情
* @param stationName
* @param type
* @return
*/
@Override
public List<HydropowerTargetDetailVo> hydropowerTargetDetail(String stationName, Long type) {
StationEntity station = stationService.getOne(Wrappers.<StationEntity>lambdaQuery()
.eq(StationEntity::getName,stationName));
if(ObjectUtil.isEmpty(station)){
throw new ServiceException("站点信息不存在!");
}
if(HomePageConstant.YEAR.equals(type)){
// 站点近年发电数据
Map<Long, Map<String, Float>> powerMap = (Map<Long, Map<String, Float>>) redisTemplate.opsForValue().get(recent_year_power_data);
// 填报发电量
List<PowerMonthVo> powerMonths = generateService.fillPowerMon(station.getCode());
return powerMonths.stream().map(mon->{
HydropowerTargetDetailVo detail = new HydropowerTargetDetailVo();
detail.setTime(mon.getStrMonth());
if(MapUtils.isEmpty(powerMap)){
detail.setElectric(Double.valueOf(mon.getPower()));
return detail;
}
// 发电量
Map<String,Float> monMap = powerMap.get(station.getId());
if(MapUtils.isEmpty(monMap)){
detail.setElectric(Double.valueOf(mon.getPower()));
return detail;
}
detail.setElectric((double) (monMap.get(mon.getStrMonth()) + mon.getPower()));
return detail;
}).collect(Collectors.toList());
}else if(HomePageConstant.MON.equals(type)){
// 指标数据
List<HydropowerUnitTargetVo> targets = (List<HydropowerUnitTargetVo>) redisTemplate.opsForValue().get(load_hydropower_unit_target_key);
// 填报发电量
List<GenerationPowerVo> powerDays = generateService.fillPowerDay(station.getCode());
return powerDays.stream().map(day->{
HydropowerTargetDetailVo detail = new HydropowerTargetDetailVo();
detail.setTime(day.getDate());
if(CollectionUtil.isEmpty(targets)){
detail.setElectric(Double.valueOf(day.getGenerate()));
return detail;
}
List<HydropowerUnitTargetVo> stationTargets = targets.stream().filter(o->o.getDeptId().equals(station.getRefDept())).collect(Collectors.toList());
if(CollectionUtil.isEmpty(stationTargets)){
detail.setElectric(Double.valueOf(day.getGenerate()));
return detail;
}
List<GenerationPowerVo> generations = stationTargets.get(0).getGenerationPowerVoList();
if(CollectionUtil.isEmpty(generations)){
detail.setElectric(Double.valueOf(day.getGenerate()));
return detail;
}
List<GenerationPowerVo> dayGenerations = generations.stream().filter(generation -> generation.getDate().equals(day.getDate())).collect(Collectors.toList());
if(CollectionUtil.isEmpty(dayGenerations)){
detail.setElectric(Double.valueOf(day.getGenerate()));
return detail;
}
detail.setElectric((double) (day.getGenerate() + dayGenerations.get(0).getGenerate()));
return detail;
}).collect(Collectors.toList());
}else{
throw new ServiceException("查询数据类型不支持!");
}
}
/**
* 获取近年月份集合
* @param year
* @return
*/
public List<String> mons(int year, int endMoth, boolean nextMon) {
List<String> list = new ArrayList<>();
// 开始日期
Calendar endCal = Calendar.getInstance();
endCal.setTime(new Date());
endCal.add(Calendar.MONTH, -endCal.get(Calendar.MONTH) + endMoth);
endCal.add(Calendar.DATE, -endCal.get(Calendar.DATE) + 1);
// 结束日期
Calendar startCal = Calendar.getInstance();
startCal.setTime(new Date());
startCal.set(Calendar.YEAR, startCal.get(Calendar.YEAR) - year);
startCal.add(Calendar.MONTH, -startCal.get(Calendar.MONTH));
startCal.add(Calendar.DATE, -startCal.get(Calendar.DATE) + 1);
// 获取日期之间的月份
while (endCal.after(startCal)) {
list.add(DateUtil.format(startCal.getTime(),DateUtil.PATTERN_DATE));
startCal.add(Calendar.MONTH, 1);
}
if(nextMon){
list.add(DateUtil.format(endCal.getTime(),DateUtil.PATTERN_DATE));
}
return list;
}
} }

4
hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/service/GenerateService.java

@ -31,6 +31,10 @@ public interface GenerateService extends BaseService<GenerateEntity> {
// 查询30天填报用电量 // 查询30天填报用电量
List<GenerationPowerVo> generate30Day(String day, String station); List<GenerationPowerVo> generate30Day(String day, String station);
List<GenerationPowerVo> fillPowerDay(String station);
// 获取站点填报发电量 // 获取站点填报发电量
List<PowerMonthVo> generateThreeYear(String start, String end, String station); List<PowerMonthVo> generateThreeYear(String start, String end, String station);
List<PowerMonthVo> fillPowerMon(String code);
} }

70
hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/service/impl/GenerateServiceImpl.java

@ -164,6 +164,25 @@ public class GenerateServiceImpl extends BaseServiceImpl<GenerateMapper, Generat
}).collect(Collectors.toList()); }).collect(Collectors.toList());
} }
@Override
public List<GenerationPowerVo> fillPowerDay(String station) {
List<GenerateEntity> records = this.list(Wrappers.<GenerateEntity>lambdaQuery()
.eq(GenerateEntity::getStationCode,station)
.like(GenerateEntity::getFillDate,DateUtil.format(new Date(),"yyyy-MM"))
);
List<String> days = this.days(new Date());
return days.stream().map(day->{
GenerationPowerVo powerDay = new GenerationPowerVo();
powerDay.setDate(day);
if(CollectionUtil.isEmpty(records)){
powerDay.setGenerate(0f);
return powerDay;
}
powerDay.setGenerate((float) records.stream().filter(record->record.getFillDate().equals(day)).mapToDouble(GenerateEntity::getGenerate).sum());
return powerDay;
}).collect(Collectors.toList());
}
/** /**
* *
* @param start 时间: - yyyy/ yyyy-mm/ yyyy-mm-dd * @param start 时间: - yyyy/ yyyy-mm/ yyyy-mm-dd
@ -191,6 +210,32 @@ public class GenerateServiceImpl extends BaseServiceImpl<GenerateMapper, Generat
}).collect(Collectors.toList()); }).collect(Collectors.toList());
} }
/**
* 获取当年度月份填报发电量
* @param code
* @return
*/
@Override
public List<PowerMonthVo> fillPowerMon(String code) {
List<GenerateEntity> records = this.list(Wrappers.<GenerateEntity>lambdaQuery()
.eq(GenerateEntity::getStationCode,code)
.like(GenerateEntity::getFillDate,DateUtil.format(new Date(),"yyyy"))
);
List<String> mons = this.mons(0,12,false);
List<GenerateEntity> format = records.stream().peek(record-> record.setFillDate(DateUtil.format(DateUtil.parse(record.getFillDate(),"yyyy-MM"),"yyyy-MM") + "-01")).collect(Collectors.toList());
// 返回结果
return mons.stream().map(mon->{
PowerMonthVo powerMonth = new PowerMonthVo();
powerMonth.setStrMonth(mon);
if(CollectionUtil.isEmpty(format)){
powerMonth.setPower(0f);
return powerMonth;
}
powerMonth.setPower((float) format.stream().filter(o->o.getFillDate().equals(mon)).mapToDouble(GenerateEntity::getGenerate).sum());
return powerMonth;
}).collect(Collectors.toList());
}
/** /**
* 获取近年月份集合 * 获取近年月份集合
@ -221,4 +266,29 @@ public class GenerateServiceImpl extends BaseServiceImpl<GenerateMapper, Generat
} }
return list; return list;
} }
/**
* 获取近月日期集合
* @param date
* @return
*/
private List<String> days(Date date) {
List<String> list = new ArrayList<>();
// 结束日期
Calendar endCal = Calendar.getInstance();
endCal.setTime(new Date());
endCal.add(Calendar.MONTH, -endCal.get(Calendar.MONTH) + 1);
endCal.add(Calendar.DATE, -endCal.get(Calendar.DATE) + 1);
// 开始日期
Calendar startCal = Calendar.getInstance();
startCal.setTime(new Date());
startCal.add(Calendar.DATE, -startCal.get(Calendar.DATE) + 1);
// 获取日期之间的月份
while (endCal.after(startCal)) {
list.add(DateUtil.format(startCal.getTime(),DateUtil.PATTERN_DATE));
startCal.add(Calendar.DAY_OF_MONTH, 1);
}
return list;
}
} }

8
hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/repair/service/impl/WorkTaskServiceImpl.java

@ -14,6 +14,7 @@ import lombok.extern.slf4j.Slf4j;
import org.springblade.core.log.exception.ServiceException; import org.springblade.core.log.exception.ServiceException;
import org.springblade.core.mp.base.BaseServiceImpl; import org.springblade.core.mp.base.BaseServiceImpl;
import org.springblade.core.mp.support.Condition; import org.springblade.core.mp.support.Condition;
import org.springblade.core.secure.utils.AuthUtil;
import org.springblade.core.tool.api.R; import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.DateUtil; import org.springblade.core.tool.utils.DateUtil;
import org.springblade.core.tool.utils.ObjectUtil; import org.springblade.core.tool.utils.ObjectUtil;
@ -22,6 +23,8 @@ import org.springblade.flow.core.entity.BladeFlow;
import org.springblade.flow.core.feign.IFlowClient; import org.springblade.flow.core.feign.IFlowClient;
import org.springblade.flow.core.utils.FlowUtil; import org.springblade.flow.core.utils.FlowUtil;
import org.springblade.flow.core.utils.TaskUtil; import org.springblade.flow.core.utils.TaskUtil;
import org.springblade.system.entity.Dept;
import org.springblade.system.feign.ISysClient;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.Date; import java.util.Date;
@ -37,6 +40,7 @@ public class WorkTaskServiceImpl extends BaseServiceImpl<WorkTaskMapper, WorkTas
private final IFlowClient flowClient; private final IFlowClient flowClient;
private final ISysClient sysClient;
/** /**
* 工作任务单-分页查询 * 工作任务单-分页查询
@ -103,6 +107,10 @@ public class WorkTaskServiceImpl extends BaseServiceImpl<WorkTaskMapper, WorkTas
*/ */
private void saveWorkTask(WorkTaskVO workTask) { private void saveWorkTask(WorkTaskVO workTask) {
workTask.setCode("GZRWD" + DateUtil.format(new Date(),DateUtil.PATTERN_DATETIME_MINI)); workTask.setCode("GZRWD" + DateUtil.format(new Date(),DateUtil.PATTERN_DATETIME_MINI));
R<Dept> result = sysClient.getDept(Long.valueOf(AuthUtil.getDeptId()));
if(result.isSuccess() && ObjectUtil.isNotEmpty(result.getData())){
workTask.setDeptName(result.getData().getDeptName());
}
this.save(workTask); this.save(workTask);
} }

Loading…
Cancel
Save