Browse Source

#新区域值班统计

zhongwei
yang_shj 1 year ago
parent
commit
18c5378d9a
  1. 24
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/census/vo/AreaAssetDeviceVo.java
  2. 24
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/census/vo/AreaAssetVo.java
  3. 13
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/census/vo/AreaTimelyVo.java
  4. 2
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/home/impl/ShowServiceImpl.java
  5. 57
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/controller/AreaDutyController.java
  6. 20
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/service/AreaDutyService.java
  7. 114
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/service/impl/AreaDutyServiceImpl.java

24
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/census/vo/AreaAssetDeviceVo.java

@ -0,0 +1,24 @@
package com.hnac.hzims.operational.census.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
/**
* @author ysj
* @date 2023/8/29 11:22:22
* @version 4.0.0
*/
@Data
public class AreaAssetDeviceVo {
@ApiModelProperty(value = "机构Id")
private Long deptId;
@ApiModelProperty(value = "机构名称")
private String deptName;
@ApiModelProperty(value = "状态")
private String status;
}

24
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/census/vo/AreaAssetVo.java

@ -0,0 +1,24 @@
package com.hnac.hzims.operational.census.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
/**
* @author ysj
* @date 2023/8/29 11:22:22
* @version 4.0.0
*/
@Data
public class AreaAssetVo {
@ApiModelProperty(value = "机构Id")
private Long deptId;
@ApiModelProperty(value = "机构名称")
private String deptName;
@ApiModelProperty(value = "设备集合")
private List<AreaAssetDeviceVo> devices;
}

13
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/census/vo/AreaTimelyVo.java

@ -0,0 +1,13 @@
package com.hnac.hzims.operational.census.vo;
import lombok.Data;
/**
* @author ysj
* @date 2023/8/29 11:22:22
* @version 4.0.0
*/
@Data
public class AreaTimelyVo {
}

2
hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/home/impl/ShowServiceImpl.java

@ -105,7 +105,7 @@ public class ShowServiceImpl implements ShowService {
@Value("${hzims.equipment.emInfo.emInfoList}")
public String device_cache_cofig_final;
@Value("${hzims.operation.region.areaDutyInfoKey}")
@Value("${hzims.operation.region.areaDutyInfoKey}")
private String area_duty_cache_final;
@Value("${hzims.operation.region.deviceClassifyKey}")

57
hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/controller/AreaDutyController.java

@ -0,0 +1,57 @@
package com.hnac.hzims.operational.census.controller;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.hnac.hzims.operational.census.service.AreaDutyService;
import com.hnac.hzims.operational.census.vo.AreaAssetVo;
import com.hnac.hzims.operational.census.vo.AreaTimelyVo;
import com.hnac.hzims.operational.main.vo.AreaDutyVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.AllArgsConstructor;
import org.springblade.core.log.annotation.ApiLog;
import org.springblade.core.tool.api.R;
import org.springframework.web.bind.annotation.PostMapping;
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
*/
@RestController
@AllArgsConstructor
@RequestMapping("/area_duty")
@Api(value = "区域值班统计", tags = "区域值班统计")
public class AreaDutyController {
private final AreaDutyService service;
@ApiLog
@ApiOperation("值班数据")
@PostMapping("/duty")
@ApiOperationSupport(order = 1)
public R<AreaDutyVo> duty(@ApiParam(value = "机构Id", required = true) @RequestParam Long deptId) {
return R.data(service.duty(deptId));
}
@ApiLog
@ApiOperation("资产信息")
@PostMapping("/asset")
@ApiOperationSupport(order = 1)
public R<List<AreaAssetVo>> asset(@ApiParam(value = "机构Id", required = true) @RequestParam Long deptId) {
return R.data(service.asset(deptId));
}
@ApiLog
@ApiOperation("及时提醒消息")
@PostMapping("/timely")
@ApiOperationSupport(order = 1)
public R<AreaTimelyVo> timely(@ApiParam(value = "机构Id", required = true) @RequestParam Long deptId) {
return R.data(service.timely(deptId));
}
}

20
hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/service/AreaDutyService.java

@ -0,0 +1,20 @@
package com.hnac.hzims.operational.census.service;
import com.hnac.hzims.operational.census.vo.AreaAssetVo;
import com.hnac.hzims.operational.census.vo.AreaTimelyVo;
import com.hnac.hzims.operational.main.vo.AreaDutyVo;
import java.util.List;
/**
* @author ysj
*/
public interface AreaDutyService {
AreaDutyVo duty(Long deptId);
AreaTimelyVo timely(Long deptId);
List<AreaAssetVo> asset(Long deptId);
}

114
hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/service/impl/AreaDutyServiceImpl.java

@ -0,0 +1,114 @@
package com.hnac.hzims.operational.census.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.hnac.hzims.equipment.vo.EminfoAndEmParamVo;
import com.hnac.hzims.operational.census.service.AreaDutyService;
import com.hnac.hzims.operational.census.vo.AreaAssetVo;
import com.hnac.hzims.operational.census.vo.AreaTimelyVo;
import com.hnac.hzims.operational.main.vo.AreaDutyVo;
import com.hnac.hzims.operational.main.vo.HydropowerUnitRealVo;
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.tool.api.R;
import org.springblade.core.tool.utils.CollectionUtil;
import org.springblade.system.entity.Dept;
import org.springblade.system.feign.ISysClient;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;
/**
* @author ysj
* @date 2023/02/23 13:37:22
* @version 4.0.0
*/
@Service
@Slf4j
@RequiredArgsConstructor
public class AreaDutyServiceImpl implements AreaDutyService {
@Value("${hzims.equipment.emInfo.emInfoList}")
public String device_cache_cofig_final;
@Value("${hzims.operation.region.areaDutyInfoKey}")
private String area_duty_cache_final;
private final static String load_hydropower_unit_real_key = "hzims:operation:loadhydropowerunit:real:key";
private final IStationService stationService;
private final ISysClient sysClient;
private final RedisTemplate redisTemplate;
/**
* 区域值班数据
* @param deptId
* @return
*/
@Override
public AreaDutyVo duty(Long deptId) {
List<AreaDutyVo> dutys = (List<AreaDutyVo>) redisTemplate.opsForValue().get(area_duty_cache_final);;
if(CollectionUtil.isEmpty(dutys)){
return new AreaDutyVo();
}
return dutys.stream().filter(o->o.getDepartId().equals(deptId)).min(Comparator.comparing(AreaDutyVo::getDepartId)).get();
}
/**
* 区域及时提醒消息
* @param deptId
* @return
*/
@Override
public AreaTimelyVo timely(Long deptId) {
return null;
}
/**
* 资产信息
* @param deptId
* @return
*/
@Override
public List<AreaAssetVo> asset(Long deptId) {
// 查询子部门
R<List<Dept>> result = sysClient.getDeptChild(deptId);
if(!result.isSuccess() && CollectionUtil.isEmpty(result.getData())){
return new ArrayList<>();
}
List<Long> depts = result.getData().stream().map(Dept::getId).collect(Collectors.toList());
// 查询站点
List<StationEntity> stations = stationService.list(Wrappers.<StationEntity>lambdaQuery()
.in(StationEntity::getRefDept,depts));
if(CollectionUtil.isEmpty(stations)){
return new ArrayList<>();
}
try{
// 查询设备
List<EminfoAndEmParamVo> devices = JSONObject.parseObject(redisTemplate.opsForValue().get(device_cache_cofig_final).toString(),new TypeReference<List<EminfoAndEmParamVo>>() {});
// 水电站设备实时数据
List<HydropowerUnitRealVo> reals = (List<HydropowerUnitRealVo>) redisTemplate.opsForValue().get(load_hydropower_unit_real_key);
return devices.stream().filter(device -> depts.contains(device.getCreateDept())).collect(Collectors.groupingBy(EminfoAndEmParamVo::getCreateDept)).entrySet().stream().map(entry->{
AreaAssetVo asset = new AreaAssetVo();
return asset;
}).collect(Collectors.toList());
}catch (Exception ex){
log.error("duty_asset_error: {}",ex);
return new ArrayList<>();
}
}
}
Loading…
Cancel
Save