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 3713c48..83ffbcd 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 @@ -28,6 +28,9 @@ public class WorkTaskEntity extends TenantEntity { private static final long serialVersionUID = -3122149146340663132L; + @ApiModelProperty(value = "序号") + private String number; + @ApiModelProperty(value = "工作任务单编号") private String code; @@ -58,9 +61,6 @@ public class WorkTaskEntity extends TenantEntity { @ApiModelProperty(value = "工作计划结束时间") private Date planEndTime; - @ApiModelProperty(value = "工作票据ID") - private Long workTicketId; - @ApiModelProperty(value = "工作任务") private String workTask; diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/alarm/impl/AlarmServiceImpl.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/alarm/impl/AlarmServiceImpl.java index c78f300..69c643c 100644 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/alarm/impl/AlarmServiceImpl.java +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/alarm/impl/AlarmServiceImpl.java @@ -274,7 +274,7 @@ public class AlarmServiceImpl implements AlarmService { alarm.setType(Integer.parseInt(entity.getType())); alarm.setStation(entity.getStationId()); alarm.setRealId(entity.getRealId()); - alarm.setContext(entity.getSoeExplain()); + alarm.setContext(entity.getStationName() + "." + entity.getSoeExplain()); alarm.setState(entity.getStatus()); log.error("send_interruption_msg : {}",JsonUtil.toJson(alarm)); mqttSender.sendToMqtt(InterruptionConstants.HZ3000_TOPIC_PREFIX + entity.getStationId(), JsonUtil.toJson(alarm)); diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/monitor/impl/MonitorServiceImpl.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/monitor/impl/MonitorServiceImpl.java index 00e220b..da76d0d 100644 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/monitor/impl/MonitorServiceImpl.java +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/monitor/impl/MonitorServiceImpl.java @@ -78,6 +78,9 @@ public class MonitorServiceImpl implements MonitorService { private final IAnalyseDataSearchClient analyseDataSearchClient; + private static final ExecutorService pool = new ThreadPoolExecutor(5, 5, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>(1024), new ThreadFactoryBuilder().setNameFormat("load-monitoring-pool-%d").build(), new ThreadPoolExecutor.CallerRunsPolicy()); + + @Value("${hzims.equipment.emInfo.emInfoList}") public String device_cache_final; @@ -312,16 +315,14 @@ public class MonitorServiceImpl implements MonitorService { // 分割,每个map限制10个长度 List>> handleList = this.mapChunk(stationAttbtMap); // 创建线程池 - ThreadFactory namedThreadFactory = new ThreadFactoryBuilder().setNameFormat("load-monitoring-pool-%d").build(); - ExecutorService pool = new ThreadPoolExecutor(5, 5, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>(1024), namedThreadFactory, new ThreadPoolExecutor.AbortPolicy()); - CountDownLatch countDownLatch = new CountDownLatch(handleList.size()); + CountDownLatch countDownLatch = new CountDownLatch(handleList.size()); // 所有机构 R> deptAll = sysClient.getDeptList(); // 存储数据节点 List stationList = new CopyOnWriteArrayList<>(); - pool.execute(()->{ - // 线程处理数据 - for(Map> item : handleList){ + // 线程处理数据 + for(Map> item : handleList){ + pool.submit(()->{ item.forEach((key,value)->{ RealStationVo station = new RealStationVo(); // 站点编码 @@ -353,8 +354,8 @@ public class MonitorServiceImpl implements MonitorService { stationList.add(station); }); countDownLatch.countDown(); - } - }); + }); + } // 等待所有线程执行完成 try { countDownLatch.await(); @@ -362,7 +363,6 @@ public class MonitorServiceImpl implements MonitorService { e.printStackTrace(); Thread.currentThread().interrupt(); } - pool.shutdown(); redisTemplate.opsForValue().set(moniter_station_cache_final, stationList); } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/HydropowerServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/HydropowerServiceImpl.java index 31facd0..cba31a3 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/HydropowerServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/HydropowerServiceImpl.java @@ -167,8 +167,10 @@ public class HydropowerServiceImpl implements HydropowerService { response.setPlanPowerMon(this.getPlanPowerrMon(station.getCode())); // 年计划发电量 response.setPlanPowerYear(this.getPlanPowerYear(station.getCode())); - // 月发电量、年发电量、年发电完成率 + // 年发电量、年发电完成率 this.handleStationInfo(station.getRefDept(),response); + // 月发电量 + this.stationMonthPower(station.getId(),map,response); // 水位、水位曲线 this.handleWaterLeve(station.getCode(),response); // 年发电量完成百分比 @@ -178,7 +180,6 @@ public class HydropowerServiceImpl implements HydropowerService { return response; } - /** * 水电站-机组列表 * @param deptId @@ -396,16 +397,12 @@ public class HydropowerServiceImpl implements HydropowerService { * @param response */ private void handleStationInfo(Long deptId, HydropowerStationVo response) { - response.setPowerMon(0f); response.setPowerYear(0f); response.setPowerRateYear(0.0); List targetList = (List) redisTemplate.opsForValue().get(load_hydropower_unit_target_key); if(CollectionUtil.isEmpty(targetList)){ return; } - // 月发电量 - float powerMont = (float) targetList.stream().filter(o-> deptId.equals(o.getDeptId())).mapToDouble(HydropowerUnitTargetVo::getPowerMon).sum(); - response.setPowerMon(powerMont); // 年发电量 float powerYear = (float) targetList.stream().filter(o-> deptId.equals(o.getDeptId())).mapToDouble(HydropowerUnitTargetVo::getPowerYear).sum(); response.setPowerYear(powerYear); @@ -420,6 +417,22 @@ public class HydropowerServiceImpl implements HydropowerService { } /** + * 月发电量 + * @param id + * @param map + * @param response + */ + private void stationMonthPower(Long id, Map> map, HydropowerStationVo response) { + if(MapUtils.isEmpty(map) || !map.containsKey(id)){ + response.setPowerMon(0f); + return; + } + String month = DateUtil.format(new Date(),"yyyy-MM") + "-01"; + response.setPowerMon(map.get(id).getOrDefault(month, 0f)); + } + + + /** * 站点水位数据处理 * @param code * @param response @@ -637,6 +650,14 @@ public class HydropowerServiceImpl implements HydropowerService { if (MapUtils.isEmpty(map)) { return kpi; } + String month = DateUtil.format(new Date(),"yyyy-MM") + "-01"; + // 当月发电量 + kpi.setGenerateMon(map.entrySet().stream().filter(o->stations.stream().map(StationEntity::getId).collect(Collectors.toList()).contains(o.getKey())).mapToDouble(entry->{ + if(entry.getValue().containsKey(month)){ + return Double.valueOf(entry.getValue().get(month)); + } + return 0.0; + }).sum()); // 今年发电趋势 kpi.setPowerMonthVoList(this.handlePowerFinish(stations,map)); // 近3年发电量 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 a4b6ff4..32b028c 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 @@ -6,6 +6,7 @@ import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.TypeReference; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.hnac.hzims.common.constant.CommonConstant; import com.hnac.hzims.message.MessageConstants; import com.hnac.hzims.message.dto.BusinessMessageDTO; @@ -123,7 +124,28 @@ public class WorkTaskServiceImpl extends BaseServiceImpllambdaQuery() + .like(WorkTaskEntity::getCreateTime,DateUtil.format(new Date(),"yyyy-MM")) + .orderByDesc(WorkTaskEntity::getNumber) + .last("LIMIT 1") + ); + if(ObjectUtil.isEmpty(max)){ + workTask.setNumber("001"); + workTask.setCode("GZRWD" + DateUtil.format(new Date(),"yyyyMM") + "001"); + }else{ + int number = Integer.parseInt(max.getNumber()) + 1; + String code = ""; + if(number > 100){ + code += number; + }else if(number > 10){ + code = code + "0" + number; + }else{ + code = code + "00" + number; + } + workTask.setNumber(code); + workTask.setCode("GZRWD" + DateUtil.format(new Date(),"yyyyMM") + code); + } R result = sysClient.getDept(Long.valueOf(AuthUtil.getDeptId())); if(result.isSuccess() && ObjectUtil.isNotEmpty(result.getData())){ workTask.setDeptName(result.getData().getDeptName()); @@ -149,9 +171,7 @@ public class WorkTaskServiceImpl extends BaseServiceImpl