haungxing
5 months ago
15 changed files with 301 additions and 15 deletions
@ -0,0 +1,32 @@ |
|||||||
|
package com.hnac.hzims.alarm.show.vo; |
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModelProperty; |
||||||
|
import lombok.Data; |
||||||
|
import org.springblade.core.mp.support.QueryField; |
||||||
|
import org.springblade.core.mp.support.SqlCondition; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author ysj |
||||||
|
* @date 2023/03/17 10:02:33 |
||||||
|
* @version 4.0.0 |
||||||
|
*/ |
||||||
|
@Data |
||||||
|
public class AlarmVideoVo { |
||||||
|
|
||||||
|
@ApiModelProperty("视频设备编码") |
||||||
|
private String pointCode; |
||||||
|
|
||||||
|
@ApiModelProperty("视频名称") |
||||||
|
@QueryField(condition = SqlCondition.LIKE) |
||||||
|
private String videoName; |
||||||
|
|
||||||
|
@ApiModelProperty("视频服务器host") |
||||||
|
private String videoHost; |
||||||
|
|
||||||
|
@ApiModelProperty("运管中心appSecret") |
||||||
|
private String videoAppSecret; |
||||||
|
|
||||||
|
@ApiModelProperty("运管中心appKey") |
||||||
|
private String videoAppKey; |
||||||
|
} |
||||||
|
|
@ -0,0 +1,24 @@ |
|||||||
|
package com.hnac.hzims.operational.report.vo; |
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModel; |
||||||
|
import io.swagger.annotations.ApiModelProperty; |
||||||
|
import lombok.Data; |
||||||
|
|
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author ysj |
||||||
|
*/ |
||||||
|
@Data |
||||||
|
@ApiModel("发电量报表") |
||||||
|
public class GenerationDeviceVo { |
||||||
|
|
||||||
|
@ApiModelProperty("设备编号") |
||||||
|
private String deviceCode; |
||||||
|
|
||||||
|
@ApiModelProperty("设备名称") |
||||||
|
private String deviceName; |
||||||
|
|
||||||
|
@ApiModelProperty("属性时间范围统计数据") |
||||||
|
private List<GenerationReportVo> attributes; |
||||||
|
} |
@ -0,0 +1,19 @@ |
|||||||
|
package com.hnac.hzims.operational.report.vo; |
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModel; |
||||||
|
import io.swagger.annotations.ApiModelProperty; |
||||||
|
import lombok.Data; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author ysj |
||||||
|
*/ |
||||||
|
@Data |
||||||
|
@ApiModel("发电量报表") |
||||||
|
public class GenerationReportTimeVo { |
||||||
|
|
||||||
|
@ApiModelProperty("时间") |
||||||
|
private String time; |
||||||
|
|
||||||
|
@ApiModelProperty("值") |
||||||
|
private Double value; |
||||||
|
} |
@ -0,0 +1,24 @@ |
|||||||
|
package com.hnac.hzims.operational.report.vo; |
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModel; |
||||||
|
import io.swagger.annotations.ApiModelProperty; |
||||||
|
import lombok.Data; |
||||||
|
|
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author ysj |
||||||
|
*/ |
||||||
|
@Data |
||||||
|
@ApiModel("发电量报表") |
||||||
|
public class GenerationReportVo { |
||||||
|
|
||||||
|
@ApiModelProperty("属性") |
||||||
|
private String attribute; |
||||||
|
|
||||||
|
@ApiModelProperty("属性名称") |
||||||
|
private String attributeName; |
||||||
|
|
||||||
|
@ApiModelProperty("属性时间范围统计数据") |
||||||
|
private List<GenerationReportTimeVo> times; |
||||||
|
} |
@ -0,0 +1,34 @@ |
|||||||
|
package com.hnac.hzims.operational.report.controller; |
||||||
|
|
||||||
|
import com.hnac.hzims.operational.report.service.IGenerationReportService; |
||||||
|
import com.hnac.hzims.operational.report.vo.GenerationDeviceVo; |
||||||
|
import com.hnac.hzims.operational.report.vo.GenerationReportTimeVo; |
||||||
|
import com.hnac.hzims.operational.report.vo.GenerationReportVo; |
||||||
|
import lombok.AllArgsConstructor; |
||||||
|
import lombok.extern.slf4j.Slf4j; |
||||||
|
import org.springblade.core.boot.ctrl.BladeController; |
||||||
|
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.List; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author ysj |
||||||
|
*/ |
||||||
|
@Slf4j |
||||||
|
@AllArgsConstructor |
||||||
|
@RestController |
||||||
|
@RequestMapping("/generation/report") |
||||||
|
public class GenerationReportController extends BladeController { |
||||||
|
|
||||||
|
private final IGenerationReportService service; |
||||||
|
|
||||||
|
@GetMapping("/sameDayReport") |
||||||
|
public R<List<GenerationDeviceVo>> sameDayReport(@RequestParam("stationId") String stationId){ |
||||||
|
return R.data(service.sameDayReport(stationId)); |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,14 @@ |
|||||||
|
package com.hnac.hzims.operational.report.service; |
||||||
|
|
||||||
|
import com.hnac.hzims.operational.report.vo.GenerationDeviceVo; |
||||||
|
import com.hnac.hzims.operational.report.vo.GenerationReportVo; |
||||||
|
|
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author ysj |
||||||
|
*/ |
||||||
|
public interface IGenerationReportService { |
||||||
|
|
||||||
|
List<GenerationDeviceVo> sameDayReport(String stationId); |
||||||
|
} |
@ -0,0 +1,100 @@ |
|||||||
|
package com.hnac.hzims.operational.report.service.impl; |
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
||||||
|
import com.hnac.hzims.equipment.entity.EmInfoEntity; |
||||||
|
import com.hnac.hzims.equipment.feign.IEmInfoClient; |
||||||
|
import com.hnac.hzims.operational.report.service.IGenerationReportService; |
||||||
|
import com.hnac.hzims.operational.report.vo.GenerationDeviceVo; |
||||||
|
import com.hnac.hzims.operational.report.vo.GenerationReportTimeVo; |
||||||
|
import com.hnac.hzims.operational.report.vo.GenerationReportVo; |
||||||
|
import com.hnac.hzims.operational.station.entity.StationEntity; |
||||||
|
import com.hnac.hzims.operational.station.service.IStationService; |
||||||
|
import lombok.RequiredArgsConstructor; |
||||||
|
import lombok.extern.slf4j.Slf4j; |
||||||
|
import org.springblade.core.log.exception.ServiceException; |
||||||
|
import org.springblade.core.tool.utils.CollectionUtil; |
||||||
|
import org.springblade.core.tool.utils.ObjectUtil; |
||||||
|
import org.springframework.stereotype.Service; |
||||||
|
|
||||||
|
import java.util.*; |
||||||
|
import java.util.stream.Collectors; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author ysj |
||||||
|
*/ |
||||||
|
@Service |
||||||
|
@Slf4j |
||||||
|
@RequiredArgsConstructor |
||||||
|
public class GenerationReportServiceImpl implements IGenerationReportService { |
||||||
|
|
||||||
|
private final IStationService stationService; |
||||||
|
|
||||||
|
private final IEmInfoClient deviceClient; |
||||||
|
|
||||||
|
/** |
||||||
|
* 当天报表 |
||||||
|
* @param stationId |
||||||
|
* @return |
||||||
|
*/ |
||||||
|
@Override |
||||||
|
public List<GenerationDeviceVo> sameDayReport(String stationId) { |
||||||
|
// 查询站点
|
||||||
|
StationEntity station = stationService.getOne(Wrappers.<StationEntity>lambdaQuery().eq(StationEntity::getCode,stationId)); |
||||||
|
if(ObjectUtil.isEmpty(station)){ |
||||||
|
throw new ServiceException("未查询到站点信息!"); |
||||||
|
} |
||||||
|
// 查询站点机组设备
|
||||||
|
List<EmInfoEntity> devices = deviceClient.crewsDevices(station.getRefDept()); |
||||||
|
if(CollectionUtil.isEmpty(devices)){ |
||||||
|
throw new ServiceException("未查询到站点机组类型设备!"); |
||||||
|
} |
||||||
|
// FIXME 属性标识
|
||||||
|
Map<String,String> signages = new HashMap<>(); |
||||||
|
signages.put("active_power","有功功率"); |
||||||
|
signages.put("reactive_power","无功功率"); |
||||||
|
signages.put("generation_capacity","正向有功电量"); |
||||||
|
signages.put("reactive_generation_capacity","正向无功电量"); |
||||||
|
List<String> times = this.sameDayValues(); |
||||||
|
Random random = new Random(); |
||||||
|
return devices.stream().map(device->{ |
||||||
|
GenerationDeviceVo item = new GenerationDeviceVo(); |
||||||
|
item.setDeviceCode(device.getNumber()); |
||||||
|
item.setDeviceName(device.getName()); |
||||||
|
item.setAttributes(signages.entrySet().stream().map(entry->{ |
||||||
|
GenerationReportVo attribute = new GenerationReportVo(); |
||||||
|
attribute.setAttribute(entry.getKey()); |
||||||
|
attribute.setAttributeName(entry.getValue()); |
||||||
|
// FIXME : 使用随机数
|
||||||
|
attribute.setTimes(times.stream().map(time->{ |
||||||
|
GenerationReportTimeVo generation = new GenerationReportTimeVo(); |
||||||
|
generation.setTime(time); |
||||||
|
generation.setValue(random.nextDouble() * 1000); |
||||||
|
return generation; |
||||||
|
}).collect(Collectors.toList())); |
||||||
|
return attribute; |
||||||
|
}).collect(Collectors.toList())); |
||||||
|
return item; |
||||||
|
}).collect(Collectors.toList()); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 当天数据值 |
||||||
|
* @return |
||||||
|
*/ |
||||||
|
private List<String> sameDayValues() { |
||||||
|
Calendar calendar = Calendar.getInstance(); |
||||||
|
Date end = calendar.getTime(); |
||||||
|
calendar.add(Calendar.HOUR_OF_DAY,-calendar.get(Calendar.HOUR_OF_DAY)); |
||||||
|
calendar.add(Calendar.MINUTE, -calendar.get(Calendar.MINUTE)); |
||||||
|
calendar.add(Calendar.SECOND, -calendar.get(Calendar.SECOND)); |
||||||
|
calendar.add(Calendar.MILLISECOND,-calendar.get(Calendar.MILLISECOND)); |
||||||
|
Date start = calendar.getTime(); |
||||||
|
List<String> times = new ArrayList<>(); |
||||||
|
while (start.compareTo(end) <= 0){ |
||||||
|
calendar.add(Calendar.HOUR_OF_DAY,1); |
||||||
|
times.add(start.getHours() + "时"); |
||||||
|
start = calendar.getTime(); |
||||||
|
} |
||||||
|
return times; |
||||||
|
} |
||||||
|
} |
Loading…
Reference in new issue