Browse Source

#bug修改

zhongwei
yang_shj 2 years ago
parent
commit
c0428a031f
  1. 45
      hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/impl/EmInfoServiceImpl.java
  2. 18
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/service/impl/AbnormalAlarmServiceImpl.java
  3. 2
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/service/impl/HistoryAbnormalAlarmServiceImpl.java
  4. 3
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/impl/ImsDutyMainServiceImpl.java
  5. 4
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/HydropowerServiceImpl.java
  6. 2
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/PhotovoltaicServiceImpl.java
  7. 2
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/WaterServiceImpl.java

45
hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/impl/EmInfoServiceImpl.java

@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.IdWorker; import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.google.api.client.util.Sleeper;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.hnac.hzims.equipment.EquipmentContants; import com.hnac.hzims.equipment.EquipmentContants;
import com.hnac.hzims.equipment.entity.*; import com.hnac.hzims.equipment.entity.*;
@ -21,6 +22,7 @@ import com.hnac.hzinfo.datasearch.analyse.IAnalyseDataSearchClient;
import com.hnac.hzinfo.datasearch.analyse.vo.AnalyzeCodeBySignagesVO; import com.hnac.hzinfo.datasearch.analyse.vo.AnalyzeCodeBySignagesVO;
import com.hnac.hzinfo.sdk.analyse.po.MultiAnalyzeCodePO; import com.hnac.hzinfo.sdk.analyse.po.MultiAnalyzeCodePO;
import com.hnac.hzinfo.sdk.v5.device.client.DeviceClient; import com.hnac.hzinfo.sdk.v5.device.client.DeviceClient;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.MapUtils; import org.apache.commons.collections4.MapUtils;
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;
@ -38,6 +40,7 @@ import org.springframework.util.Assert;
import javax.validation.Valid; import javax.validation.Valid;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.Stream;
/** /**
* 服务实现类 * 服务实现类
@ -45,6 +48,7 @@ import java.util.stream.Collectors;
* @author Chill * @author Chill
*/ */
@Service @Service
@Slf4j
public class EmInfoServiceImpl extends BaseServiceImpl<EmInfoMapper, EmInfoEntity> implements IEmInfoService { public class EmInfoServiceImpl extends BaseServiceImpl<EmInfoMapper, EmInfoEntity> implements IEmInfoService {
@Autowired @Autowired
private IEmParamService paramService; private IEmParamService paramService;
@ -77,6 +81,11 @@ public class EmInfoServiceImpl extends BaseServiceImpl<EmInfoMapper, EmInfoEntit
@Value("${hzims.equipment.emInfo.code-prefix}") @Value("${hzims.equipment.emInfo.code-prefix}")
public String emInfoCodePrefix; public String emInfoCodePrefix;
/**
* 10站点为一组数据
*/
private static final Integer MAX_SEND = 3;
@Override @Override
public R<EmInfoEntity> getEmInfoByCode(String emCode) { public R<EmInfoEntity> getEmInfoByCode(String emCode) {
EmInfoNoScopeMapper mapper = SpringUtil.getBean("emInfoNoScopeMapper"); EmInfoNoScopeMapper mapper = SpringUtil.getBean("emInfoNoScopeMapper");
@ -417,29 +426,38 @@ public class EmInfoServiceImpl extends BaseServiceImpl<EmInfoMapper, EmInfoEntit
@Override @Override
public void loadEmInfo() { public void loadEmInfo() {
// 查询所有首页展示/状态非删除设备 // 查询所有首页展示/状态非删除设备
List<EminfoAndEmParamVo> list = this.baseMapper.selectEminfoAndEmParamVoList(); List<EminfoAndEmParamVo> devices = this.baseMapper.selectEminfoAndEmParamVoList();
// 查询所有设备(ct、pt、installedCapacity)配置参数 // 查询所有设备(ct、pt、installedCapacity)配置参数
List<EmParamEntity> paramList = this.paramService.getParamByParamNameGenerate(); List<EmParamEntity> paramList = this.paramService.getParamByParamNameGenerate();
// 获取设备监测点
// 获取设备监测点位:未配置监测点位不进行统计设备 // 获取设备监测点位:未配置监测点位不进行统计设备
List<MultiAnalyzeCodePO> multiAnalyzeCodePOList = list.stream().map(o->{ List<MultiAnalyzeCodePO> multiAnalyzeCodePOList = devices.stream().map(o->{
MultiAnalyzeCodePO multiAnalyzeCodePO = new MultiAnalyzeCodePO(); MultiAnalyzeCodePO multiAnalyzeCodePO = new MultiAnalyzeCodePO();
multiAnalyzeCodePO.setDeviceCode(o.getEmCode()); multiAnalyzeCodePO.setDeviceCode(o.getEmCode());
multiAnalyzeCodePO.setSignages(HomePageConstant.SIGNAGES); multiAnalyzeCodePO.setSignages(HomePageConstant.SIGNAGES);
return multiAnalyzeCodePO; return multiAnalyzeCodePO;
}).collect(Collectors.toList()); }).collect(Collectors.toList());
R<List<AnalyzeCodeBySignagesVO>> result = searchClient.getAnalyzeCodeBySignages(multiAnalyzeCodePOList); // 切割
int limit = countStep(multiAnalyzeCodePOList.size());
List<List<MultiAnalyzeCodePO>> lists = Stream.iterate(0, n -> n + 1).limit(limit).parallel().map(a -> multiAnalyzeCodePOList.stream().skip((long) a * MAX_SEND).limit(MAX_SEND).parallel().collect(Collectors.toList())).collect(Collectors.toList());
// 接收数据
List<AnalyzeCodeBySignagesVO> analys = new ArrayList<>();
lists.forEach(list->{
R<List<AnalyzeCodeBySignagesVO>> result = searchClient.getAnalyzeCodeBySignages(list);
if(!result.isSuccess() || CollectionUtil.isEmpty(result.getData())){ if(!result.isSuccess() || CollectionUtil.isEmpty(result.getData())){
return; return;
} }
analys.addAll(result.getData());
});
// 设备遍历 // 设备遍历
list.forEach(item->{ devices.forEach(item->{
item.setRideCount(1); item.setRideCount(1);
item.setInstalledCapacity(0.0); item.setInstalledCapacity(0.0);
List<AnalyzeCodeBySignagesVO> signages = analys.stream().filter(o-> item.getEmCode().equals(o.getDeviceCode()) && !StringUtil.isEmpty(o.getSignage()) && !StringUtil.isEmpty(o.getRealId())).collect(Collectors.toList());
if(CollectionUtil.isEmpty(signages)){
return;
}
// list -> map // list -> map
item.setPoint(result.getData().stream().filter(o-> item.getEmCode().equals(o.getDeviceCode()) && StringUtil.isNotBlank(o.getSignage()) && StringUtil.isNotBlank(o.getRealId())). item.setPoint(signages.stream().collect(Collectors.toMap(AnalyzeCodeBySignagesVO::getSignage,AnalyzeCodeBySignagesVO::getRealId)));
collect(Collectors.toMap(AnalyzeCodeBySignagesVO::getSignage,AnalyzeCodeBySignagesVO::getRealId)));
// 寻找设备配置参数 // 寻找设备配置参数
List<EmParamEntity> itemParamList = paramList.stream().filter(o->item.getId().equals(o.getInfoId())).collect(Collectors.toList()); List<EmParamEntity> itemParamList = paramList.stream().filter(o->item.getId().equals(o.getInfoId())).collect(Collectors.toList());
if(CollectionUtil.isNotEmpty(itemParamList)){ if(CollectionUtil.isNotEmpty(itemParamList)){
@ -456,6 +474,8 @@ public class EmInfoServiceImpl extends BaseServiceImpl<EmInfoMapper, EmInfoEntit
case "installedCapacity": case "installedCapacity":
item.setInstalledCapacity(Double.valueOf(param.getParamValue())); item.setInstalledCapacity(Double.valueOf(param.getParamValue()));
break; break;
default:
break;
} }
} }
// 设置ct * pt // 设置ct * pt
@ -465,7 +485,14 @@ public class EmInfoServiceImpl extends BaseServiceImpl<EmInfoMapper, EmInfoEntit
} }
}); });
// 设置缓存 // 设置缓存
redisTemplate.opsForValue().set(em_info_list_path, JSONObject.toJSONString(list.stream().filter(o-> Math.abs(o.getInstalledCapacity()) > 0 || MapUtils.isNotEmpty(o.getPoint())).collect(Collectors.toList()))); redisTemplate.opsForValue().set(em_info_list_path, JSONObject.toJSONString(devices.stream().filter(o-> Math.abs(o.getInstalledCapacity()) > 0 || MapUtils.isNotEmpty(o.getPoint())).collect(Collectors.toList())));
}
/**
* 计算切分次数
*/
private static Integer countStep(Integer size) {
return (size + MAX_SEND - 1) / MAX_SEND;
} }
private void validEmInfo(EmInfoAddVo em_info) { private void validEmInfo(EmInfoAddVo em_info) {

18
hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/service/impl/AbnormalAlarmServiceImpl.java

@ -71,14 +71,13 @@ public class AbnormalAlarmServiceImpl extends BaseServiceImpl<AbnormalAlarmMappe
if(CollectionUtil.isEmpty(stations)){ if(CollectionUtil.isEmpty(stations)){
return; return;
} }
DateTimeFormatter df = DateTimeFormatter.ofPattern(DateUtil.PATTERN_DATETIME);
SoeQueryConditionByStation query = new SoeQueryConditionByStation(); SoeQueryConditionByStation query = new SoeQueryConditionByStation();
query.setTypes(AbnormalAlarmConstant.TYPE_LIST); query.setTypes(AbnormalAlarmConstant.SEND_MESSSAGE_TYPE_LIST);
query.setStationIds(stations.stream().map(StationEntity::getCode).collect(Collectors.toList())); query.setStationIds(stations.stream().map(StationEntity::getCode).collect(Collectors.toList()));
Calendar calendar = Calendar.getInstance(); Calendar calendar = Calendar.getInstance();
query.setEndTime(LocalDateTime.parse(/*DateUtil.format(calendar.getTime(), DateUtil.PATTERN_DATETIME)*/"2023-02-27 00:00:00", df)); query.setEndTime(LocalDateTime.parse(DateUtil.format(calendar.getTime(), DateUtil.PATTERN_DATETIME),DateUtil.DATETIME_FORMATTER));
calendar.add(Calendar.MINUTE,-2); calendar.add(Calendar.MINUTE,-2);
query.setBeginTime(LocalDateTime.parse(/*DateUtil.format(calendar.getTime() , DateUtil.PATTERN_DATETIME)*/"2023-02-01 00:00:00", df)); query.setBeginTime(LocalDateTime.parse(DateUtil.format(calendar.getTime() , DateUtil.PATTERN_DATETIME),DateUtil.DATETIME_FORMATTER));
query.setNeedPage(false); query.setNeedPage(false);
log.error("alarm_data_handle_param : {}",query); log.error("alarm_data_handle_param : {}",query);
Result<HzPage<SoeData>> result = soeClient.getByStationsAndTime(query); Result<HzPage<SoeData>> result = soeClient.getByStationsAndTime(query);
@ -88,8 +87,8 @@ public class AbnormalAlarmServiceImpl extends BaseServiceImpl<AbnormalAlarmMappe
} }
log.error("alarm_data_handle_begin_result : {}",result.getData().getRecords()); log.error("alarm_data_handle_begin_result : {}",result.getData().getRecords());
// 遍历告警信息 // 遍历告警信息
List<SoeData> list = result.getData().getRecords().stream().sorted(Comparator.comparing(SoeData::getTs).reversed()) List<SoeData> list = new ArrayList<>(result.getData().getRecords().stream().sorted(Comparator.comparing(SoeData::getTs).reversed())
.collect(Collectors.toMap(o->o.getStation()+o.getSoeType(),Function.identity(),(o1, o2) -> o1)).entrySet().stream().map(Map.Entry::getValue).collect(Collectors.toList()); .collect(Collectors.toMap(o -> o.getStation() + o.getSoeType(), Function.identity(), (o1, o2) -> o1)).values());
log.error("alarm_data_handle_end_result : {}",list); log.error("alarm_data_handle_end_result : {}",list);
list.forEach(item -> { list.forEach(item -> {
AbnormalAlarmEntity queryEntity = this.baseMapper.getAbnormalAlarm(item.getStation(),item.getSoeType()); AbnormalAlarmEntity queryEntity = this.baseMapper.getAbnormalAlarm(item.getStation(),item.getSoeType());
@ -160,6 +159,7 @@ public class AbnormalAlarmServiceImpl extends BaseServiceImpl<AbnormalAlarmMappe
String stationName = Optional.ofNullable(stations.stream().filter(o-> o.getCode().equals(item.getStation())).collect(Collectors.toList())).map(o->o.get(0).getName()).orElse(null); String stationName = Optional.ofNullable(stations.stream().filter(o-> o.getCode().equals(item.getStation())).collect(Collectors.toList())).map(o->o.get(0).getName()).orElse(null);
if(ObjectUtil.isEmpty(queryEntity) || !flag){ if(ObjectUtil.isEmpty(queryEntity) || !flag){
HistoryAbnormalAlarmEntity entity = new HistoryAbnormalAlarmEntity(); HistoryAbnormalAlarmEntity entity = new HistoryAbnormalAlarmEntity();
entity.setAlarmId(item.getId());
entity.setStationId(item.getStation()); entity.setStationId(item.getStation());
entity.setStationName(stationName); entity.setStationName(stationName);
entity.setRealId(item.getRealId()); entity.setRealId(item.getRealId());
@ -172,13 +172,9 @@ public class AbnormalAlarmServiceImpl extends BaseServiceImpl<AbnormalAlarmMappe
this.sendAlarmMessage(Collections.singletonList(entity),stations); this.sendAlarmMessage(Collections.singletonList(entity),stations);
return; return;
} }
Random random = new Random();
Calendar calendar = Calendar.getInstance();
calendar.setTime(item.getTs());
calendar.add(Calendar.MINUTE,random.nextInt(1000) + 50);
queryEntity.setSoeExplain(item.getSoeExplain()); queryEntity.setSoeExplain(item.getSoeExplain());
queryEntity.setUpdateTime(new Date()); queryEntity.setUpdateTime(new Date());
queryEntity.setEndTime(calendar.getTime()); queryEntity.setEndTime(ts);
queryEntity.setStatus(1); queryEntity.setStatus(1);
this.historyAbnormalAlarmService.updateById(queryEntity); this.historyAbnormalAlarmService.updateById(queryEntity);
}); });

2
hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/service/impl/HistoryAbnormalAlarmServiceImpl.java

@ -208,6 +208,7 @@ public class HistoryAbnormalAlarmServiceImpl extends BaseServiceImpl<HistoryAbno
public AlarmReustVo alarms(AlarmParamVo param) { public AlarmReustVo alarms(AlarmParamVo param) {
// 查询站点 // 查询站点
LambdaQueryWrapper<StationEntity> wrapper = Wrappers.lambdaQuery(); LambdaQueryWrapper<StationEntity> wrapper = Wrappers.lambdaQuery();
wrapper.eq(StationEntity::getServeType,HomePageConstant.HYDROPOWER_SERVETYPE);
if(StringUtils.isNotEmpty(param.getCode())){ if(StringUtils.isNotEmpty(param.getCode())){
wrapper.eq(StationEntity::getCode,param.getCode()); wrapper.eq(StationEntity::getCode,param.getCode());
} }
@ -215,7 +216,6 @@ public class HistoryAbnormalAlarmServiceImpl extends BaseServiceImpl<HistoryAbno
if(CollectionUtil.isEmpty(stations)){ if(CollectionUtil.isEmpty(stations)){
return new AlarmReustVo(); return new AlarmReustVo();
} }
// 查询告警数据 // 查询告警数据
SoeQueryConditionByStation condition = new SoeQueryConditionByStation(); SoeQueryConditionByStation condition = new SoeQueryConditionByStation();
condition.setBeginTime(LocalDateTime.parse(DateUtil.format(new Date(),DateUtil.PATTERN_DATE) + " 00:00:00", DateUtil.DATETIME_FORMATTER)); condition.setBeginTime(LocalDateTime.parse(DateUtil.format(new Date(),DateUtil.PATTERN_DATE) + " 00:00:00", DateUtil.DATETIME_FORMATTER));

3
hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/impl/ImsDutyMainServiceImpl.java

@ -1669,6 +1669,9 @@ public class ImsDutyMainServiceImpl extends BaseServiceImpl<ImsDutyMainMapper, I
@Override @Override
public DutyMainInfoVo getNextDutyDataV2(Long parentId) { public DutyMainInfoVo getNextDutyDataV2(Long parentId) {
DutyMainInfoVo dutyMainInfoVo = this.baseMapper.selectDutyMainInfoSignV2(parentId); DutyMainInfoVo dutyMainInfoVo = this.baseMapper.selectDutyMainInfoSignV2(parentId);
if(ObjectUtil.isEmpty(dutyMainInfoVo)){
return new DutyMainInfoVo();
}
if (null == dutyMainInfoVo.getDutyGroupId()) { if (null == dutyMainInfoVo.getDutyGroupId()) {
ImsDutyMainPersonEntity imsDutyMainPersonEntity = imsDutyMainPersonMapper.selectOne(new LambdaQueryWrapper<ImsDutyMainPersonEntity>() {{ ImsDutyMainPersonEntity imsDutyMainPersonEntity = imsDutyMainPersonMapper.selectOne(new LambdaQueryWrapper<ImsDutyMainPersonEntity>() {{
eq(ImsDutyMainPersonEntity::getDutyMainId, dutyMainInfoVo.getId()); eq(ImsDutyMainPersonEntity::getDutyMainId, dutyMainInfoVo.getId());

4
hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/HydropowerServiceImpl.java

@ -285,7 +285,7 @@ public class HydropowerServiceImpl implements HydropowerService {
private List<ActivePowerVo> getLoadsByDay(EminfoAndEmParamVo device) { private List<ActivePowerVo> getLoadsByDay(EminfoAndEmParamVo device) {
String start = DateUtil.format(new Date(), DateUtil.PATTERN_DATE) + " 00:00:00"; String start = DateUtil.format(new Date(), DateUtil.PATTERN_DATE) + " 00:00:00";
String end = DateUtil.format(new Date(), DateUtil.PATTERN_DATETIME); String end = DateUtil.format(new Date(), DateUtil.PATTERN_DATETIME);
List<AnalyseDataTaosVO> records = analyseDataService.periodTargetData(start, end, 1, 2, device.getEmCode(), HomePageConstant.PV_LOAD); List<AnalyseDataTaosVO> records = analyseDataService.periodTargetData(start, end, 3, 2, device.getEmCode(), HomePageConstant.PV_LOAD);
if (CollectionUtil.isEmpty(records)) { if (CollectionUtil.isEmpty(records)) {
return new ArrayList<>(); return new ArrayList<>();
} }
@ -526,7 +526,7 @@ public class HydropowerServiceImpl implements HydropowerService {
GenerationPowerVo generate = new GenerationPowerVo(); GenerationPowerVo generate = new GenerationPowerVo();
Date time = DateUtil.parse(record.getTs(), "yyyy-MM-dd HH:mm:ss.s"); Date time = DateUtil.parse(record.getTs(), "yyyy-MM-dd HH:mm:ss.s");
generate.setDate(DateUtil.format(time,DateUtil.PATTERN_DATE)); generate.setDate(DateUtil.format(time,DateUtil.PATTERN_DATE));
generate.setGenerate(Float.valueOf(Optional.ofNullable(record.getVal()).orElse("0"))); generate.setGenerate(Float.parseFloat(Optional.ofNullable(record.getVal()).orElse("0")) * device.getRideCount());
return generate; return generate;
}).collect(Collectors.toList()); }).collect(Collectors.toList());
} }

2
hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/PhotovoltaicServiceImpl.java

@ -487,7 +487,7 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService {
return "0"; return "0";
} }
String value = map.get(realId); String value = map.get(realId);
if (StringUtil.isEmpty(realId)) { if (StringUtil.isEmpty(value)) {
return "0"; return "0";
} }
// 获取value // 获取value

2
hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/WaterServiceImpl.java

@ -521,7 +521,7 @@ public class WaterServiceImpl implements IWaterService {
return "0"; return "0";
} }
String value = map.get(realId); String value = map.get(realId);
if(StringUtil.isBlank(realId)){ if(StringUtil.isBlank(value)){
return "0"; return "0";
} }
// 获取value // 获取value

Loading…
Cancel
Save