diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/census/vo/HydropowerTargetDetailVo.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/census/vo/HydropowerTargetDetailVo.java new file mode 100644 index 0000000..e96ce10 --- /dev/null +++ b/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; +} diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/constant/HomePageConstant.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/constant/HomePageConstant.java index 3203ab8..e02e30a 100644 --- a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/constant/HomePageConstant.java +++ b/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; + + /** + * 年 + */ + Long YEAR = 0L; + + /** + * 月 + */ + Long MON = 1L; + /*==========================================================================================*/ // 水利集团、区域指标关联 /** diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/GenerationPowerVo.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/GenerationPowerVo.java index 854a5d5..57d4d32 100644 --- a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/GenerationPowerVo.java +++ b/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) private Float generate; - @ApiModelProperty(value = "功率·") + @ApiModelProperty(value = "功率") @JsonSerialize(nullsUsing = NullSerializer.class) private Float load; } diff --git a/hzims-service-api/ticket-api/src/main/java/com/hnac/hzims/ticket/repair/entity/WorkTaskEntity.java b/hzims-service-api/ticket-api/src/main/java/com/hnac/hzims/ticket/repair/entity/WorkTaskEntity.java index 1afffae..c9dadf1 100644 --- a/hzims-service-api/ticket-api/src/main/java/com/hnac/hzims/ticket/repair/entity/WorkTaskEntity.java +++ b/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 = "工作计划结束时间") private Date planEndTime; + @ApiModelProperty(value = "工作票据ID") + private Long workTicketId; + @ApiModelProperty(value = "工作任务") private String workTask; @@ -89,4 +92,7 @@ public class WorkTaskEntity extends TenantEntity { @ApiModelProperty(value = "流程环节处理人") private String nextStepOperator; + + @ApiModelProperty(value = "创建机构名称") + private String deptName; } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/controller/TargetController.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/controller/TargetController.java index e35dc15..7ff523b 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/controller/TargetController.java +++ b/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.springframework.web.bind.annotation.*; +import java.util.List; + /** * @author ysj * @date 2023/03/01 16:12:22 @@ -152,6 +154,15 @@ public class TargetController { } @ApiLog + @ApiOperation("水电关联-发电详情") + @GetMapping("/hydropower-target-detail") + @ApiOperationSupport(order = 11) + public R> hydropowerTargetDetail(@RequestParam(value = "stationName") String stationName, + @RequestParam(value = "type") Long type) { + return R.data(service.hydropowerTargetDetail(stationName,type)); + } + + @ApiLog @ApiOperation("水利集团、区域指标关联") @GetMapping("/water-target") @ApiOperationSupport(order = 12) @@ -203,5 +214,4 @@ public class TargetController { public R> access(AccessAssociationVo business,Query query) { return R.data(service.access(Condition.getPage(query),business)); } - } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/service/TargetService.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/service/TargetService.java index ffe50ba..5fe2324 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/service/TargetService.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/service/TargetService.java @@ -71,4 +71,6 @@ public interface TargetService { IPage phenomenon(IPage page, MaintenancePhenomenonVo business); IPage access(IPage page, AccessAssociationVo business); + + List hydropowerTargetDetail(String stationName, Long type); } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/service/impl/TargetServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/service/impl/TargetServiceImpl.java index 3213b3c..169fe70 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/service/impl/TargetServiceImpl.java +++ b/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 lombok.RequiredArgsConstructor; import org.apache.commons.collections4.MapUtils; +import org.springblade.core.log.exception.ServiceException; import org.springblade.core.mp.support.Query; import org.springblade.core.tool.api.R; import org.springblade.core.tool.utils.*; @@ -83,6 +84,8 @@ public class TargetServiceImpl implements TargetService { private final IStationService stationService; + private final GenerateService generateService; + private final OverDetailsService overDetailsService; 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 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_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())); return pages; } + + /** + * 水电关联-发电详情 + * @param stationName + * @param type + * @return + */ + @Override + public List hydropowerTargetDetail(String stationName, Long type) { + StationEntity station = stationService.getOne(Wrappers.lambdaQuery() + .eq(StationEntity::getName,stationName)); + if(ObjectUtil.isEmpty(station)){ + throw new ServiceException("站点信息不存在!"); + } + if(HomePageConstant.YEAR.equals(type)){ + // 站点近年发电数据 + Map> powerMap = (Map>) redisTemplate.opsForValue().get(recent_year_power_data); + // 填报发电量 + List 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 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 targets = (List) redisTemplate.opsForValue().get(load_hydropower_unit_target_key); + // 填报发电量 + List 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 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 generations = stationTargets.get(0).getGenerationPowerVoList(); + if(CollectionUtil.isEmpty(generations)){ + detail.setElectric(Double.valueOf(day.getGenerate())); + return detail; + } + List 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 mons(int year, int endMoth, boolean nextMon) { + List 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; + } } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/service/GenerateService.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/service/GenerateService.java index dc7e967..699bd03 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/service/GenerateService.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/service/GenerateService.java @@ -31,6 +31,10 @@ public interface GenerateService extends BaseService { // 查询30天填报用电量 List generate30Day(String day, String station); + List fillPowerDay(String station); + // 获取站点填报发电量 List generateThreeYear(String start, String end, String station); + + List fillPowerMon(String code); } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/service/impl/GenerateServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/service/impl/GenerateServiceImpl.java index 80db3af..8ed3a73 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/service/impl/GenerateServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/service/impl/GenerateServiceImpl.java @@ -164,6 +164,25 @@ public class GenerateServiceImpl extends BaseServiceImpl fillPowerDay(String station) { + List records = this.list(Wrappers.lambdaQuery() + .eq(GenerateEntity::getStationCode,station) + .like(GenerateEntity::getFillDate,DateUtil.format(new Date(),"yyyy-MM")) + ); + List 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 @@ -191,6 +210,32 @@ public class GenerateServiceImpl extends BaseServiceImpl fillPowerMon(String code) { + List records = this.list(Wrappers.lambdaQuery() + .eq(GenerateEntity::getStationCode,code) + .like(GenerateEntity::getFillDate,DateUtil.format(new Date(),"yyyy")) + ); + List mons = this.mons(0,12,false); + List 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 days(Date date) { + List 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; + } } diff --git a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/repair/service/impl/WorkTaskServiceImpl.java b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/repair/service/impl/WorkTaskServiceImpl.java index 88869be..f75f160 100644 --- a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/repair/service/impl/WorkTaskServiceImpl.java +++ b/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.mp.base.BaseServiceImpl; 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.utils.DateUtil; 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.utils.FlowUtil; 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 java.util.Date; @@ -37,6 +40,7 @@ public class WorkTaskServiceImpl extends BaseServiceImpl result = sysClient.getDept(Long.valueOf(AuthUtil.getDeptId())); + if(result.isSuccess() && ObjectUtil.isNotEmpty(result.getData())){ + workTask.setDeptName(result.getData().getDeptName()); + } this.save(workTask); }