Browse Source

#字典sql修改

zhongwei
yang_shj 9 months ago
parent
commit
43f3580d63
  1. 8
      hzims-service/hzims-alarm/src/main/resources/dict/dict.sql
  2. 54
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/controller/AppHomeController.java
  3. 137
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/controller/HomePageController.java
  4. 34
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/IAppHomeService.java
  5. 50
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/IHomePageService.java
  6. 755
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/AppHomeServiceImpl.java
  7. 2200
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/HomePageServiceImpl.java
  8. 72
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/SideHustleServiceImpl.java

8
hzims-service/hzims-alarm/src/main/resources/dict/dict.sql

@ -48,3 +48,11 @@ INSERT INTO `BLADEX`.`BLADE_DICT`(`ID`, `PARENT_ID`, `CODE`, `DICT_KEY`, `DICT_V
INSERT INTO `BLADEX`.`BLADE_DICT`(`ID`, `PARENT_ID`, `CODE`, `DICT_KEY`, `DICT_VALUE`, `SORT`, `REMARK`, `IS_SEALED`, `IS_DELETED`, `DICT_TYPE`, `APP_ID`, `APP_CODE`) VALUES (1331515358493851649, 1331514879315591270, 'FAULTDEALTYPE', '1', '误报', 1, '', 0, 0, 1, 1347090334530641921, 'HZIMS-ALARM'); INSERT INTO `BLADEX`.`BLADE_DICT`(`ID`, `PARENT_ID`, `CODE`, `DICT_KEY`, `DICT_VALUE`, `SORT`, `REMARK`, `IS_SEALED`, `IS_DELETED`, `DICT_TYPE`, `APP_ID`, `APP_CODE`) VALUES (1331515358493851649, 1331514879315591270, 'FAULTDEALTYPE', '1', '误报', 1, '', 0, 0, 1, 1347090334530641921, 'HZIMS-ALARM');
INSERT INTO `BLADEX`.`BLADE_DICT` (`ID`, `PARENT_ID`, `CODE`, `DICT_KEY`, `DICT_VALUE`, `SORT`, `REMARK`, `IS_SEALED`, `IS_DELETED`, `DICT_TYPE`, `APP_ID`, `APP_CODE`) VALUES (1651149948657455106, 0, 'ALARM_HANDLE_TYPE', '-1', '告警处理类型', 100, '', 0, 0, 0, -1, 'HZIMS-ALARM');
INSERT INTO `BLADEX`.`BLADE_DICT` (`ID`, `PARENT_ID`, `CODE`, `DICT_KEY`, `DICT_VALUE`, `SORT`, `REMARK`, `IS_SEALED`, `IS_DELETED`, `DICT_TYPE`, `APP_ID`, `APP_CODE`) VALUES (1651150040252665858, 1651149948657455106, 'ALARM_HANDLE_TYPE', '1', '延后', 1, '', 0, 0, 0, -1, 'HZIMS-ALARM');
INSERT INTO `BLADEX`.`BLADE_DICT` (`ID`, `PARENT_ID`, `CODE`, `DICT_KEY`, `DICT_VALUE`, `SORT`, `REMARK`, `IS_SEALED`, `IS_DELETED`, `DICT_TYPE`, `APP_ID`, `APP_CODE`) VALUES (1651150074092310530, 1651149948657455106, 'ALARM_HANDLE_TYPE', '2', '误报', 2, '', 0, 0, 0, -1, 'HZIMS-ALARM');
INSERT INTO `BLADEX`.`BLADE_DICT` (`ID`, `PARENT_ID`, `CODE`, `DICT_KEY`, `DICT_VALUE`, `SORT`, `REMARK`, `IS_SEALED`, `IS_DELETED`, `DICT_TYPE`, `APP_ID`, `APP_CODE`) VALUES (1651150112910594050, 1651149948657455106, 'ALARM_HANDLE_TYPE', '3', '缺陷', 3, '', 0, 0, 0, -1, 'HZIMS-ALARM');
INSERT INTO `BLADEX`.`BLADE_DICT` (`ID`, `PARENT_ID`, `CODE`, `DICT_KEY`, `DICT_VALUE`, `SORT`, `REMARK`, `IS_SEALED`, `IS_DELETED`, `DICT_TYPE`, `APP_ID`, `APP_CODE`) VALUES (1651150146049789954, 1651149948657455106, 'ALARM_HANDLE_TYPE', '4', '检修', 4, '', 0, 0, 0, -1, 'HZIMS-ALARM');
INSERT INTO `BLADEX`.`BLADE_DICT` (`ID`, `PARENT_ID`, `CODE`, `DICT_KEY`, `DICT_VALUE`, `SORT`, `REMARK`, `IS_SEALED`, `IS_DELETED`, `DICT_TYPE`, `APP_ID`, `APP_CODE`) VALUES (1651150182032723969, 1651149948657455106, 'ALARM_HANDLE_TYPE', '5', '处理', 5, '', 0, 0, 0, -1, 'HZIMS-ALARM');
INSERT INTO `BLADEX`.`BLADE_DICT` (`ID`, `PARENT_ID`, `CODE`, `DICT_KEY`, `DICT_VALUE`, `SORT`, `REMARK`, `IS_SEALED`, `IS_DELETED`, `DICT_TYPE`, `APP_ID`, `APP_CODE`) VALUES (1651150182032756242, 1651149948657455106, 'ALARM_HANDLE_TYPE', '6', '处理完成', 5, '', 0, 0, 0, -1, 'HZIMS-ALARM');

54
hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/controller/AppHomeController.java

@ -1,54 +0,0 @@
package com.hnac.hzims.operational.main.controller;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.hnac.hzims.operational.main.service.IAppHomeService;
import com.hnac.hzims.operational.main.vo.AppStationAreaVo;
import com.hnac.hzims.operational.main.vo.AppAreaDutyVo;
import com.hnac.hzims.operational.main.vo.AppStationVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.AllArgsConstructor;
import org.springblade.core.boot.ctrl.BladeController;
import org.springblade.core.log.annotation.ApiLog;
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.RestController;
import java.util.List;
@RestController
@RequestMapping("/appHome")
@Api(value = "app首页", tags = "app-首页")
@AllArgsConstructor
public class AppHomeController extends BladeController {
private final IAppHomeService appService;
@ApiLog
@ApiOperation("app首页-站点")
@GetMapping("/appStation")
@ApiOperationSupport(order = 1)
public R<List<AppStationVo>> appStation(@ApiParam(value = "区域机构ID") Long deptId) {
return R.data(appService.appStation(deptId));
}
@ApiLog
@ApiOperation("app首页-站点列表数据")
@GetMapping("/appStationList")
@ApiOperationSupport(order = 2)
public R<List<AppStationAreaVo>> appStationList(@ApiParam(value = "机构ID") Long deptId) {
return R.data(appService.appStationList(deptId));
}
@ApiLog
@ApiOperation("app首页-当班数据")
@GetMapping("/getDutyData")
@ApiOperationSupport(order = 3)
public R<List<AppAreaDutyVo>> getDutyData(@ApiParam(value = "区域机构ID") Long deptId) {
return R.data(appService.getDutyData(deptId));
}
}

137
hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/controller/HomePageController.java

@ -1,137 +0,0 @@
package com.hnac.hzims.operational.main.controller;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.hnac.hzims.common.logs.annotation.OperationAnnotation;
import com.hnac.hzims.common.logs.enums.BusinessType;
import com.hnac.hzims.common.logs.enums.OperatorType;
import com.hnac.hzims.operational.main.service.IHomePageService;
import com.hnac.hzims.operational.main.vo.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.AllArgsConstructor;
import org.springblade.core.boot.ctrl.BladeController;
import org.springblade.core.log.annotation.ApiLog;
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.RestController;
import javax.validation.constraints.NotNull;
import java.util.List;
import java.util.Map;
/**
* @author ysj
*/
@RestController
@RequestMapping("/homePage")
@Api(value = "水电站-首页", tags = "水电站-首页")
@AllArgsConstructor
public class HomePageController extends BladeController {
@NotNull
private final IHomePageService homePageService;
@ApiLog
@ApiOperation("服务厂站统计")
@GetMapping("/stationCensus")
@ApiOperationSupport(order = 1)
public R<List<OldStationCountVo>> stationCount(@ApiParam(value = "站点服务类型:1、云服务站点; 2、代运维服务站点", required = true) Integer serveType, Long deptId) {
List<OldStationCountVo> stationList = homePageService.getStationCount(deptId,serveType);
return R.data(stationList);
}
@ApiLog
@ApiOperation("关键指标:水电站、风电站、光伏站")
@GetMapping("/powerStation")
@ApiOperationSupport(order = 2)
public R<List<PowerTargetVo>> powerStation(@ApiParam(value = "站点服务类型:1、云服务站点; 2、代运维服务站点", required = true)Integer serveType,Long deptId) {
List<PowerTargetVo> powerTargetVoList = homePageService.powerTarget(serveType,deptId);
return R.data(powerTargetVoList);
}
@ApiLog
@ApiOperation("关键指标:储能站、水利")
@GetMapping("/storageConservancy")
@ApiOperationSupport(order = 3)
public R<List<StorageConservancyVo>> storageConservancy(@ApiParam(value = "站点服务类型:1、云服务站点; 2、代运维服务站点", required = true) Integer serveType,Long deptId) {
List<StorageConservancyVo> crucialTargetVoList = homePageService.storageConservancy(serveType,deptId);
return R.data(crucialTargetVoList);
}
@ApiLog
@ApiOperation("关键指标:暂定其他站")
@GetMapping("/waterAffairs")
@ApiOperationSupport(order = 4)
public R<OtherStationVo> waterAffairs(@ApiParam(value = "站点服务类型:1、云服务站点; 2、代运维服务站点", required = true) Integer serveType,Long deptId) {
OtherStationVo waterAffairsVoList = homePageService.otherStation(serveType,deptId);
return R.data(waterAffairsVoList);
}
@ApiLog
@ApiOperation("水电站数据获取")
@GetMapping("/getHydropowerData")
@ApiOperationSupport(order = 5)
public R<List<OldHydropowerScoreVo>> getHydropowerData(@ApiParam(value = "区域id", required = true) Long deptId) {
List<OldHydropowerScoreVo> hydropowerScoreVoList = homePageService.getHydropowerData(deptId);
return R.data(hydropowerScoreVoList);
}
@ApiLog
@ApiOperation("年计划发电完成趋势")
@GetMapping("/planAactualTrend")
// @OperationAnnotation(moduleName = "演示大屏",title = "演示大屏", operatorType = OperatorType.MOBILE,
// businessType = BusinessType.GENCODE,action = "年计划发电完成趋势")
@ApiOperationSupport(order = 6)
public R<List<PowerMonthVo>> planActualTrend(@ApiParam(value = "区域机构ID") Long deptId) {
return R.data(homePageService.planActualTrend(deptId));
}
@ApiLog
@ApiOperation("计划发电趋势")
@GetMapping("/planGenerationTrend")
@ApiOperationSupport(order = 7)
public R<Map<Long, List<PlanGenerationTrendVo>>> planGenerationTrend(@ApiParam(value = "区域机构ID") Long deptId) {
return homePageService.planGenerationTrend(deptId, 0, 2);
}
@ApiLog
@ApiOperation("区域发电占比")
@GetMapping("/areaGenerationMakeUp")
@ApiOperationSupport(order = 9)
public R<Map<Long, List<AreaGenerationMakeUpVo>>> areaGenerationMakeUp(@ApiParam(value = "区域机构ID") Long deptId) {
return homePageService.areaGenerationMakeUp(deptId, 0, 2);
}
@ApiLog
@ApiOperation("统计")
@GetMapping("/getCount")
@ApiOperationSupport(order = 10)
public R<Map<Long, List<HomePageCountVo>>> getCount(@ApiParam(value = "区域机构ID") Long deptId) {
return homePageService.getCount(deptId, 0, 2);
}
@ApiLog
@ApiOperation("获取区域")
@GetMapping("/getArea")
@ApiOperationSupport(order = 11)
public R<List<AreaVo>> getArea(@ApiParam(value = "区域机构ID") Long deptId) {
return homePageService.getArea(deptId);
}
@ApiLog
@ApiOperation("站点首页")
@GetMapping("/stationHome")
@ApiOperationSupport(order = 11)
public R<List<AreaVo>> homeStation(@ApiParam(value = "区域机构ID") Long deptId) {
return R.data(homePageService.homeStation(deptId));
}
}

34
hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/IAppHomeService.java

@ -1,34 +0,0 @@
package com.hnac.hzims.operational.main.service;
import com.hnac.hzims.operational.main.vo.AppStationAreaVo;
import com.hnac.hzims.operational.main.vo.AppAreaDutyVo;
import com.hnac.hzims.operational.main.vo.AppStationVo;
import java.util.List;
/**
* APP首页接口
* @author ysj
*/
public interface IAppHomeService {
/**
* 获取App首页站点列表
* @param deptId
* @return
*/
List<AppStationVo> appStation(Long deptId);
/**
* 获取app首页-站点列表数据
* @param deptId
* @return
*/
List<AppStationAreaVo> appStationList(Long deptId);
/**
* app首页-当班数据
* @return
*/
List<AppAreaDutyVo> getDutyData(Long deptId);
}

50
hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/IHomePageService.java

@ -1,50 +0,0 @@
package com.hnac.hzims.operational.main.service;
import com.hnac.hzims.operational.main.vo.*;
import org.springblade.core.tool.api.R;
import org.springblade.system.entity.Dept;
import java.util.List;
import java.util.Map;
public interface IHomePageService {
// 水电站加载数据
void loadHydropower(String param, Integer serveType);
// 近年发电量数据
void loadPowerData(String param,List<Integer> types, Integer serveType, int yearCount);
List<String> getMonthList(int year, int endMoth,boolean nextMon);
List<OldStationCountVo> getStationCount(Long deptId, Integer serveType);
List<PowerTargetVo> powerTarget(Integer serveType,Long deptId);
List<StorageConservancyVo> storageConservancy(Integer serveType,Long deptId);
OtherStationVo otherStation(Integer serveType,Long deptId);
R<Map<Long,List<PlanGenerationTrendVo>>> planGenerationTrend(Long deptId,Integer stationType,Integer serveType);
R<Map<Long,List<AreaGenerationMakeUpVo>>> areaGenerationMakeUp(Long deptId,Integer stationType,Integer serveType);
List<OldHydropowerScoreVo> getHydropowerData(Long deptId);
R<Map<Long,List<HomePageCountVo>>> getCount(Long deptId,Integer stationType,Integer serveType);
Map<Long, List<Long>> getDepartMap(Long deptId);
R<List<AreaVo>> getArea(Long depeId);
List<Long> getChildDept(List<Dept> departList, Long deptId,List<Long> list);
List<Dept> getChildArea(List<Dept> departList, Long deptId,List<Dept> list);
List<PowerMonthVo> planActualTrend(Long deptId);
List<AreaVo> homeStation(Long deptId);
boolean compareDate(String date);
}

755
hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/AppHomeServiceImpl.java

@ -1,755 +0,0 @@
package com.hnac.hzims.operational.main.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.google.common.util.concurrent.ThreadFactoryBuilder;
import com.hnac.hzims.equipment.entity.PlanGenerationEntity;
import com.hnac.hzims.equipment.vo.EminfoAndEmParamVo;
import com.hnac.hzims.hzimsweather.response.weather.Daily;
import com.hnac.hzims.hzimsweather.response.weather.HeWeatherWeatherDailyResponse;
import com.hnac.hzims.operational.access.constants.AccessConstants;
import com.hnac.hzims.operational.access.entity.OperAccessTaskEntity;
import com.hnac.hzims.operational.access.service.IOperAccessTaskService;
import com.hnac.hzims.operational.defect.constants.TreatMethodConstant;
import com.hnac.hzims.operational.defect.entity.OperPhenomenonEntity;
import com.hnac.hzims.operational.defect.service.IOperPhenomenonService;
import com.hnac.hzims.operational.duty.service.IImsDutyMainService;
import com.hnac.hzims.operational.duty.vo.DutyMainInfoVo;
import com.hnac.hzims.operational.main.constant.HomePageConstant;
import com.hnac.hzims.operational.main.service.AreaService;
import com.hnac.hzims.operational.main.service.IAppHomeService;
import com.hnac.hzims.operational.main.service.IMainSystemMonitoringService;
import com.hnac.hzims.operational.main.service.IWeatherService;
import com.hnac.hzims.operational.main.vo.*;
import com.hnac.hzims.operational.maintenance.constants.MaintenanceConstant;
import com.hnac.hzims.operational.maintenance.entity.OperMaintenanceTaskEntity;
import com.hnac.hzims.operational.maintenance.service.IOperMaintenanceTaskService;
import com.hnac.hzims.operational.station.entity.StationEntity;
import com.hnac.hzims.operational.station.service.IStationAttributeService;
import com.hnac.hzims.operational.station.service.IStationService;
import com.hnac.hzinfo.datasearch.soe.domian.SoeData;
import com.hnac.hzinfo.inspect.task.feign.IInspectTaskReportClient;
import com.hnac.hzinfo.inspect.task.vo.DutyInspectTaskVO;
import lombok.RequiredArgsConstructor;
import org.apache.commons.collections4.MapUtils;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.CollectionUtil;
import org.springblade.core.tool.utils.DateUtil;
import org.springblade.core.tool.utils.ObjectUtil;
import org.springblade.core.tool.utils.StringUtil;
import org.springblade.system.entity.Dept;
import org.springblade.system.feign.ISysClient;
import org.springblade.system.user.cache.UserCache;
import org.springblade.system.user.entity.User;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.time.Duration;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.concurrent.*;
import java.util.stream.Collectors;
/**
* APP首页实现类
* @author ysj
*/
@Service
@RequiredArgsConstructor
public class AppHomeServiceImpl implements IAppHomeService {
private final AreaService areaService;
private final IStationService stationService;
private final IImsDutyMainService dutyMainService;
private final IOperPhenomenonService phenomenonService;
private final IOperAccessTaskService accessTaskService;
private final IMainSystemMonitoringService mainService;
private final IStationAttributeService attributeService;
private final IOperMaintenanceTaskService maintenanceTaskService;
private final IInspectTaskReportClient inspectTaskReportClient;
private final ISysClient sysClient;
private final IWeatherService weatherService;
private final RedisTemplate redisTemplate;
// 线程数量
private final static int POOL_QUANTITY = 5;
@Value("${hzims.operation.realIdKey}")
public String real_id_key;
private final static String LOAD_HYDROPOWER_UNIT_REAL_KEY = "hzims:operation:loadhydropowerunit:real:key";
private final static String LOAD_HYDROPOWER_UNIT_TARGET_KEY = "hzims:operation:loadhydropowerunit:target:key";
private final static String KEY_INDICATORS_INFO = "hzims:operation:key:indicators:info";
/**
* app首页-站点
* @param deptId
* @return
*/
@Override
public List<AppStationVo> appStation(Long deptId) {
// 用户权限机构
R<List<Dept>> R = sysClient.getDeptByCurrentUser();
if(!R.isSuccess() && CollectionUtil.isEmpty(R.getData())){
return null;
}
// 设备信息
List<EminfoAndEmParamVo> emList = mainService.getEmInfoList();
if(CollectionUtil.isEmpty(emList)){
return null;
}
// 站点列表
List<StationEntity> list = stationService.getStationList(R.getData(),deptId,Collections.singletonList(HomePageConstant.HYDROPOWER),null,true);
if(CollectionUtil.isEmpty(list)){
return null;
}
// 站点缓存列表
KeyIndicatorsVo keyIndicatorsVo = (KeyIndicatorsVo) redisTemplate.opsForValue().get(KEY_INDICATORS_INFO);
// 监测点单位
Map<String,String> unitMap = this.attributeService.getPointUnit();
// 站点遍历
List<AppStationVo> result = new ArrayList<>();
list.forEach(station -> {
if(null == station.getRefDept()){
return;
}
AppStationVo vo = new AppStationVo();
vo.setDeptId(station.getRefDept());
vo.setDeptName(station.getName());
vo.setDay(0L);
// 投运时间计算安全运行天数
if (ObjectUtil.isNotEmpty(station.getCommissionTime())) {
Duration dur = Duration.between(station.getCommissionTime(), LocalDateTime.now());
vo.setDay(dur.toDays());
}
// 天气温度
this.getWeather(station,vo);
// 站点告警列表
List<SoeData> alertList = this.getStationAlert(station.getId(),keyIndicatorsVo);
if(CollectionUtil.isNotEmpty(alertList)){
vo.setAlertList(alertList);
}
// 遍历监测点数据
List<EmShowVo> stationEmList = getEmShowList(emList.stream().filter(o->station.getCreateDept().equals(o.getCreateDept())).collect(Collectors.toList()),unitMap);
if(CollectionUtil.isEmpty(stationEmList)){
vo.setInstalledCapacity(0.0);
vo.setActivePower(0.0);
vo.setUsrRate(0.0);
result.add(vo);
return;
}
// 设备
vo.setList(stationEmList);
// 总装机容量
double installedCapacity = stationEmList.stream().filter(o-> null != o.getInstalledCapacity()).mapToDouble(EmShowVo::getInstalledCapacity).sum();
vo.setInstalledCapacity(installedCapacity);
// 总有功功率
double activePower = stationEmList.stream().filter(o->StringUtil.isNotBlank(o.getActivePower())).mapToDouble(o->Float.parseFloat(o.getActivePower())).sum();
vo.setActivePower(activePower);
// 总有功率单位
List<String> unit = stationEmList.stream().filter(o->StringUtil.isNotBlank(o.getPowerUnit())).map(EmShowVo::getPowerUnit).collect(Collectors.toList());
if(CollectionUtil.isNotEmpty(unit)){
vo.setPowerUnit(unit.get(0));
} else {
vo.setPowerUnit("kW");
}
if(installedCapacity <= 0){
vo.setUsrRate(0.0);
}else{
double usrRate = BigDecimal.valueOf(activePower / installedCapacity * 100).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
vo.setUsrRate(usrRate);
}
result.add(vo);
});
return result;
}
/**
* 获取展示设备列表
* @param valid
* @return
*/
private List<EmShowVo> getEmShowList(List<EminfoAndEmParamVo> valid,Map<String,String> unitMap) {
if(CollectionUtil.isEmpty(valid)){
return null;
}
// readId,value
String json = (String) redisTemplate.opsForValue().get(real_id_key);
Map<String, String> map = null;
if (StringUtil.isNotBlank(json)) {
map = JSONObject.parseObject(json, new TypeReference<Map<String, String>>() {});
}
// 展示设备(有功功率)
List<EmShowVo> list = getActiveList(map,valid,unitMap);
// 设备监测点集合
List<String> onOffList = valid.stream().filter(o->MapUtils.isNotEmpty(o.getPoint()) && StringUtil.isNotBlank(o.getPoint().get(HomePageConstant.ACTIVE_POWER))).
map(o->o.getPoint().get(HomePageConstant.JOINT_RELAY)).collect(Collectors.toList());
if(CollectionUtil.isEmpty(onOffList) || MapUtils.isEmpty(map)){
return list;
}
// 展示设备(开关机状态)
for(EmShowVo em : list){
em.setOnOff(false);
if (MapUtils.isEmpty(em.getPoint()) || StringUtil.isEmpty(em.getPoint().get(HomePageConstant.JOINT_RELAY))) {
continue;
}
String realId = em.getPoint().get(HomePageConstant.JOINT_RELAY);
String value = map.get(realId);
if(StringUtil.isBlank(value)){
continue;
}
if (value.contains("1") || "1.0".equals(value)) {
em.setOnOff(true);
}
}
return list;
}
/**
* 获取有功功率展示设备
* @param valid
* @return
*/
private List<EmShowVo> getActiveList(Map<String, String> map,List<EminfoAndEmParamVo> valid,Map<String,String> unitMap) {
List<String> realIds = valid.stream().filter(o->MapUtils.isNotEmpty(o.getPoint()) && StringUtil.isNotBlank(o.getPoint().get(HomePageConstant.ACTIVE_POWER))).
map(o->o.getPoint().get(HomePageConstant.ACTIVE_POWER)).collect(Collectors.toList());
if (CollectionUtil.isEmpty(realIds) || MapUtils.isEmpty(map)) {
return getEmShowVos(valid);
}
// 遍历设备
List<EmShowVo> emShowVoList = new ArrayList<>();
valid.forEach(em -> {
EmShowVo emShowVo = new EmShowVo();
emShowVo.setDeptId(em.getCreateDept());
emShowVo.setCode(em.getEmCode());
emShowVo.setName(em.getName());
emShowVo.setPoint(em.getPoint());
emShowVo.setOnOff(false);
emShowVo.setOrd(em.getOrd());
emShowVo.setInstalledCapacity(em.getInstalledCapacity());
// 有功功率
if (MapUtils.isEmpty(em.getPoint())) {
emShowVo.setActivePower("0");
emShowVoList.add(emShowVo);
return;
}
String realId = em.getPoint().get(HomePageConstant.ACTIVE_POWER);
if(StringUtil.isEmpty(realId)){
emShowVo.setActivePower("0");
emShowVoList.add(emShowVo);
return;
}
// websocket 中取realId的value值
String value = map.get(realId);
if(StringUtil.isEmpty(value)){
emShowVo.setActivePower("0");
emShowVoList.add(emShowVo);
return;
}
emShowVo.setActivePower(value);
// 单位设置
if(MapUtils.isNotEmpty(unitMap)){
String unit = unitMap.get(em.getId()+HomePageConstant.CONCAT_P);
if(StringUtil.isNotBlank(unit)) {
emShowVo.setPowerUnit(unit);
} else {
emShowVo.setPowerUnit("kW");
}
} else {
emShowVo.setPowerUnit("kW");
}
emShowVoList.add(emShowVo);
});
return emShowVoList.stream().sorted(Comparator.comparing(EmShowVo::getOrd)).collect(Collectors.toList());
}
/**
* 默认设备展示信息
* @param valid
* @return
*/
private List<EmShowVo> getEmShowVos(List<EminfoAndEmParamVo> valid) {
return valid.stream().map(o -> {
EmShowVo emShowVo = new EmShowVo();
emShowVo.setDeptId(o.getCreateDept());
emShowVo.setCode(o.getEmCode());
emShowVo.setName(o.getName());
emShowVo.setInstalledCapacity(o.getInstalledCapacity());
emShowVo.setActivePower("0");
emShowVo.setPoint(o.getPoint());
emShowVo.setOnOff(false);
return emShowVo;
}).collect(Collectors.toList());
}
/**
* 获取温度
* @param station
* @return
*/
private void getWeather(StationEntity station,AppStationVo vo) {
Map<String, HeWeatherWeatherDailyResponse> weekWeather = this.weatherService.getWeekWeather(Collections.singletonList(station.getCode()));
if(MapUtils.isEmpty(weekWeather)) {
return;
}
List<Daily> list = weekWeather.get(station.getCode()).getDaily();
if (CollectionUtil.isEmpty(list)) {
return;
}
vo.setTempMin(list.get(0).getTempMin());
vo.setTempMax(list.get(0).getTempMax());
}
/**
* 获取站点告警列表
* @param stationId
* @return
*/
public List<SoeData> getStationAlert(Long stationId,KeyIndicatorsVo keyIndicatorsVo) {
if(ObjectUtil.isEmpty(keyIndicatorsVo) || null == stationId){
return null;
}
List<PowerStationTotalVo> powerStationTotalVoList = keyIndicatorsVo.getPowerStationTotalVoList();
if(CollectionUtil.isEmpty(powerStationTotalVoList)){
return null;
}
List<PowerStationTotalVo> stationAlertList = powerStationTotalVoList.stream().filter(o->stationId.equals(o.getStationId())).collect(Collectors.toList());
if(CollectionUtil.isEmpty(stationAlertList)){
return null;
}
return stationAlertList.get(0).getAlertList();
}
/**
* app首页-站点列表数据
* @param deptId
* @return
*/
@Override
public List<AppStationAreaVo> appStationList(Long deptId) {
// 获取区域或者站点map结构
Map<Dept,List<StationEntity>> map = areaService.areaOrStaion(deptId,Collections.singletonList(HomePageConstant.HYDROPOWER),true);
if(MapUtils.isEmpty(map)){
return null;
}
// 获取站点计划发电量集合
//List<PlanGenerationEntity> planPowerList = sideHustleService.getStaionPlanPower(map);
// 获取设备指标数据列表
List<HydropowerUnitTargetVo> targetList = (List<HydropowerUnitTargetVo>) redisTemplate.opsForValue().get(LOAD_HYDROPOWER_UNIT_TARGET_KEY);
// 获取设备实时数据
List<HydropowerUnitRealVo> realList = (List<HydropowerUnitRealVo>) redisTemplate.opsForValue().get(LOAD_HYDROPOWER_UNIT_REAL_KEY);
// 响应结果
List<AppStationAreaVo> result = new ArrayList<>();
map.forEach((key,value)->{
AppStationAreaVo vo = new AppStationAreaVo();
List<AppStationTargetVo> children = new ArrayList<>();
value.forEach(item->{
AppStationTargetVo response = new AppStationTargetVo();
response.setDeptId(item.getRefDept());
response.setDeptName(item.getName());
// 站点年计划发电量
//float planPowerYear = this.getPlanPowerYear(planPowerList,item.getCode());
response.setPlanPowerYear(0f);
// 站点发电完成率
double powerRate = this.getPowerRate(targetList,item.getCreateDept(),0f);
response.setPowerRate(powerRate);
// 设备总数
int deviceSum = this.getDeviceSum(realList,item.getCreateDept(),false);
response.setDeviceSum(deviceSum);
// 设备开机数
int deviceRunSum = this.getDeviceSum(realList,item.getCreateDept(),true);
response.setDeviceRunSum(deviceRunSum);
// 实时负荷
float realPowerSum = this.getRealPowerSum(realList,item.getCreateDept());
response.setRealPowerSum(realPowerSum);
// 负荷单位
String unit = this.getPowerUnit(realList,item.getCreateDept());
response.setRealPowerUnit(unit);
children.add(response);
});
vo.setList(children);
vo.setDeptId(key.getId());
vo.setDeptName(key.getDeptName());
result.add(vo);
});
return result;
}
/**
* 获取站点年计划发电量
* @param list
* @param code
* @return
*/
private float getPlanPowerYear(List<PlanGenerationEntity> list, String code) {
if(CollectionUtil.isEmpty(list)){
return 0f;
}
return (float) list.stream().filter(o->code.equals(o.getStationId())).mapToDouble(PlanGenerationEntity::getPlanGeneration).sum();
}
/**
* 站点发电完成率
* @param list
* @param createDept
* @return
*/
private double getPowerRate(List<HydropowerUnitTargetVo> list, Long createDept ,float planPowerYear) {
if(CollectionUtil.isEmpty(list) || ObjectUtil.isEmpty(createDept)){
return 0.0;
}
if(Math.abs(planPowerYear) <= 0){
return 0.0;
}
double power = list.stream().filter(o->createDept.equals(o.getDeptId())).mapToDouble(HydropowerUnitTargetVo::getPowerYear).sum();
if(Math.abs(power) <= 0){
return 0.0;
}
return BigDecimal.valueOf((float) power / planPowerYear * 100).setScale(2, RoundingMode.HALF_UP).doubleValue();
}
/**
* 设备总数
* @param list
* @param createDept
* @return
*/
private int getDeviceSum(List<HydropowerUnitRealVo> list, Long createDept,boolean isRun) {
if(CollectionUtil.isEmpty(list)){
return 0;
}
if(isRun){
return (int) list.stream().filter(o->createDept.equals(o.getDeptId()) && HomePageConstant.OFF.equals(o.getState())).count();
}
return (int) list.stream().filter(o->createDept.equals(o.getDeptId())).count();
}
/**
* 实时负荷
* @param list
* @param createDept
* @return
*/
private float getRealPowerSum(List<HydropowerUnitRealVo> list, Long createDept) {
if(CollectionUtil.isEmpty(list)){
return 0;
}
return (float) list.stream().filter(o->createDept.equals(o.getDeptId())).mapToDouble(o->Double.valueOf(o.getActivePower())).sum();
}
/**
* 负荷单位
* @param list
* @param createDept
* @return
*/
private String getPowerUnit(List<HydropowerUnitRealVo> list, Long createDept) {
if(CollectionUtil.isEmpty(list)){
return "kW";
}
List<String> units = list.stream().filter(o->createDept.equals(o.getDeptId())).map(HydropowerUnitRealVo::getPowerUnit).collect(Collectors.toList());
if(CollectionUtil.isEmpty(units)){
return "kW";
}
return units.get(0);
}
/**
* app首页-当班数据
* @return
*/
@Override
public List<AppAreaDutyVo> getDutyData(Long deptId) {
// 获取当班列表数据
List<DutyMainInfoVo> list = this.dutyMainService.getDutyDataV2(deptId);
if(CollectionUtil.isEmpty(list)){
return null;
}
// 响应数据
return list.stream().map(duty->{
AppAreaDutyVo item = new AppAreaDutyVo();
// 班组基础数据设置
this.settingBase(duty,item);
// 开始时间、结束时间
LocalDateTime localDateTime = LocalDateTime.ofInstant(duty.getDutyDate().toInstant(), ZoneId.systemDefault());
LocalDateTime startDate = localDateTime.withHour(duty.getStartTime().getHours()).withMinute(duty.getStartTime().getMinutes()).withSecond(00);
//LocalDateTime endDate = localDateTime.withHour(duty.getEndTime().getHours()).withMinute(duty.getEndTime().getMinutes()).withSecond(00);
DateTimeFormatter dtf = DateTimeFormatter.ofPattern(DateUtil.PATTERN_DATETIME);
String start = dtf.format(startDate);
String end = dtf.format(LocalDateTime.now());
List<Long> deptList = Collections.singletonList(duty.getCreateDept());
// 使用多线程处理数据
ThreadFactory namedThreadFactory = new ThreadFactoryBuilder().setNameFormat("duty_data-pool-%d").build();
ExecutorService pool = new ThreadPoolExecutor(5, 5, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<Runnable>(1024), namedThreadFactory, new ThreadPoolExecutor.AbortPolicy());
CountDownLatch countDownLatch = new CountDownLatch(POOL_QUANTITY);
// 下一班组
pool.execute(()-> {
this.getNextDuty(item,duty.getId());
countDownLatch.countDown();
});
// 缺陷
pool.execute(()-> {
this.getDutyDefect(item,startDate,null);
countDownLatch.countDown();
});
// 巡检
pool.execute(()-> {
this.getInspectionTask(item,start,end,deptList);
countDownLatch.countDown();
});
// 维护
pool.execute(()-> {
this.getMaintenanceTask(item,start,end,deptList);
countDownLatch.countDown();
});
// 检修
pool.execute(()-> {
this.getOverhaulTask(item,start,end,deptList);
countDownLatch.countDown();
});
// 等待所有线程执行完成
try {
countDownLatch.await();
} catch (InterruptedException e) {
e.printStackTrace();
Thread.currentThread().interrupt();
}
pool.shutdown();
// 任务完成率
int taskSum = item.getDefectSum() + item.getInspectionTaskCount() + item.getMaintenanceTaskCount() + item.getOverhaulTaskCount();
int finishSum = item.getSolvedCount() + item.getInspectionTaskFinishCount() + item.getMaintenanceTaskFinishCount() + item.getOverhaulTaskFinishCount();
if(Math.abs(taskSum) <= 0){
item.setTaskRate(0.0);
}else{
double taskRate = BigDecimal.valueOf((double)finishSum / (double)taskSum * 100).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
item.setTaskRate(taskRate);
}
return item;
}).collect(Collectors.toList());
}
/**
* 班组基础数据设置
* @param duty
* @param item
*/
private void settingBase(DutyMainInfoVo duty, AppAreaDutyVo item) {
item.setShift(duty.getClassName());
item.setTeam(duty.getGroupName());
// 班组负责人
String managerName = this.getManagerName(duty.getManagerId());
item.setTeamLeader(managerName);
// 班组成员
String classMember = this.getClassMemberName(duty.getDutyPersonIds(),duty.getManagerId());
item.setClassMember(classMember);
}
/**
* 获取下一班组数据
* @param item
*
* @param id
*/
private void getNextDuty(AppAreaDutyVo item, Long id) {
DutyMainInfoVo nextDuty = this.dutyMainService.getNextDutyDataV2(id);
if(ObjectUtil.isEmpty(nextDuty) || ObjectUtil.isEmpty(nextDuty.getId())){
return;
}
item.setNextShift(nextDuty.getClassName());
item.setNextTeam(nextDuty.getGroupName());
// 下一班组负责人
String managerName = this.getManagerName(nextDuty.getManagerId());
item.setNextTeamLeader(managerName);
// 下一班组成员
String classMember = this.getClassMemberName(nextDuty.getDutyPersonIds(),nextDuty.getManagerId());
item.setNextClassMember(classMember);
}
/**
* 获取巡检任务数量
* @param item
* @param startDate
* @param endDate
*/
private void getInspectionTask(AppAreaDutyVo item, String startDate, String endDate, List<Long> deptList) {
item.setInspectionTaskCount(0);
item.setInspectionTaskFinishCount(0);
item.setNotInspectionTaskCount(0);
// 查询当班巡检任务
Map<String, Object> params = new HashMap<>();
params.put("startDate",startDate);
params.put("endDate",endDate);
params.put("deptList",deptList);
R<DutyInspectTaskVO> response = inspectTaskReportClient.getDutyInspectTask(params);
if(!response.isSuccess() || ObjectUtil.isEmpty(response.getData())){
return;
}
// 赋值
item.setInspectionTaskCount(response.getData().getInspectTaskSum());
item.setInspectionTaskFinishCount(response.getData().getInspectTaskFinish());
item.setNotInspectionTaskCount(response.getData().getNotExecuteTaskCount());
}
/**
* 获取当班日常维护数据
* @param item
* @param start
* @param end
* @param deptList
*/
private void getMaintenanceTask(AppAreaDutyVo item, String start, String end, List<Long> deptList) {
item.setMaintenanceTaskCount(0);
item.setMaintenanceTaskFinishCount(0);
item.setNotMaintenanceTaskCount(0);
// 查询当班日常维护任务
List<OperMaintenanceTaskEntity> list = maintenanceTaskService.getMaintenanceTask(start, end, deptList);
if(CollectionUtil.isEmpty(list)){
return;
}
// 总数
item.setMaintenanceTaskCount(list.size());
// 完成数
int maintenanceTaskFinishCount = (int) list.stream().filter(o-> MaintenanceConstant.TASK_STATUS_5 == o.getStatus()).count();
item.setMaintenanceTaskFinishCount(maintenanceTaskFinishCount);
// 未完成数
int notMaintenanceTaskCount = list.size() - maintenanceTaskFinishCount;
item.setNotMaintenanceTaskCount(notMaintenanceTaskCount);
}
/**
* 获取检修任务数量
* @param item
* @param start
* @param end
* @param deptList
*/
private void getOverhaulTask(AppAreaDutyVo item, String start, String end, List<Long> deptList) {
item.setOverhaulTaskCount(0);
item.setNotOverhaulTaskCount(0);
item.setOverhaulTaskFinishCount(0);
// 查询当班检修任务
List<OperAccessTaskEntity> list = accessTaskService.getAccessTask(start, end, deptList);
if(CollectionUtil.isEmpty(list)){
return;
}
// 总数
item.setOverhaulTaskCount(list.size());
// 完成数
int overhaulTaskFinishCount = (int) list.stream().filter(o-> AccessConstants.ACCESS_TASK_STATUS_4 == o.getStatus()).count();
item.setOverhaulTaskFinishCount(overhaulTaskFinishCount);
// 未开始数
int notOverhaulTaskCount = (int) list.stream().filter(o-> AccessConstants.ACCESS_TASK_STATUS_0 == o.getStatus()).count();
item.setNotOverhaulTaskCount(notOverhaulTaskCount);
}
/**
* 获取当班缺陷数据
* @param item
* @param startTime
* @param endTime
*/
private void getDutyDefect(AppAreaDutyVo item, LocalDateTime startTime, LocalDateTime endTime) {
LambdaQueryWrapper<OperPhenomenonEntity> wrapper = Wrappers.lambdaQuery();
wrapper.ge(OperPhenomenonEntity::getCreateTime,startTime);
//wrapper.le(OperPhenomenonEntity::getCreateTime,endTime);
wrapper.eq(OperPhenomenonEntity::getIsDefect, TreatMethodConstant.IS_DEFECT);
wrapper.eq(OperPhenomenonEntity::getDiscriminateStatus,TreatMethodConstant.AUTO_SCREENED);
// 查询现象
List<OperPhenomenonEntity> list = phenomenonService.list(wrapper);
if(CollectionUtil.isEmpty(list)){
item.setUnsolvedCount(0);
item.setSolvedCount(0);
item.setDefectSum(0);
item.setSeriousCount(0);
item.setDefectRate(0.0);
return;
}
// 缺陷总数
int defectSum = list.size();
item.setDefectSum(defectSum);
// 缺陷已解决数量
int solvedCount = (int) list.stream().filter(o->TreatMethodConstant.CONCLUSION_COMPLETED.equals(o.getConclusionStatus())).count();
item.setSolvedCount(solvedCount);
// 缺陷未解决数量
int unsolvedCount = list.size() - solvedCount;
item.setUnsolvedCount(unsolvedCount);
// 缺陷严重数量
int seriousCount = (int) list.stream().filter(o-> TreatMethodConstant.CLASS_I_DEFECT.toString().equals(o.getDefectLevel())).count();
item.setSeriousCount(seriousCount);
// 消缺率
double defectRate = BigDecimal.valueOf((double) solvedCount / (double)list.size() * 100).setScale(2, RoundingMode.HALF_UP).doubleValue();
item.setDefectRate(defectRate);
}
/**
* 获取班组负责人
* @param managerId
* @return
*/
private String getManagerName(String managerId) {
if(StringUtil.isBlank(managerId)){
return "";
}
User user = UserCache.getUser(Long.valueOf(managerId));
if (ObjectUtil.isEmpty(user)) {
return "";
}
return user.getName();
}
/**
* 获取班组成员
* @param personIds
* @param managerId
* @return
*/
private String getClassMemberName(String personIds,String managerId) {
if(StringUtil.isBlank(personIds)){
return "";
}
StringBuilder builder = new StringBuilder();
// 遍历成员
for (String item : personIds.split("\\^")) {
if (item.equals(managerId)) {
continue;
}
User user = UserCache.getUser(Long.valueOf(item));
if (ObjectUtil.isEmpty(user)) {
continue;
}
builder.append(user.getName()).append(",");
}
if(builder.length() <= 0){
return "";
}
return builder.substring(0,builder.toString().length() - 1);
}
}

2200
hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/HomePageServiceImpl.java

File diff suppressed because it is too large Load Diff

72
hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/SideHustleServiceImpl.java

@ -31,7 +31,6 @@ import com.hnac.hzims.operational.main.vo.*;
import com.hnac.hzims.operational.maintenance.constants.MaintenanceConstant; import com.hnac.hzims.operational.maintenance.constants.MaintenanceConstant;
import com.hnac.hzims.operational.maintenance.entity.OperMaintenanceTaskEntity; import com.hnac.hzims.operational.maintenance.entity.OperMaintenanceTaskEntity;
import com.hnac.hzims.operational.maintenance.service.IOperMaintenanceTaskService; import com.hnac.hzims.operational.maintenance.service.IOperMaintenanceTaskService;
import com.hnac.hzims.operational.main.vo.RegularWorkVO;
import com.hnac.hzims.operational.report.vo.DutyDefectVO; import com.hnac.hzims.operational.report.vo.DutyDefectVO;
import com.hnac.hzims.operational.station.entity.StationEntity; import com.hnac.hzims.operational.station.entity.StationEntity;
import com.hnac.hzims.operational.station.service.IStationService; import com.hnac.hzims.operational.station.service.IStationService;
@ -70,8 +69,6 @@ import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors; import java.util.concurrent.Executors;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import static org.springblade.system.user.UserConstants.UserDataScopeTypeEnum.dept;
/** /**
* @author ysj * @author ysj
*/ */
@ -83,8 +80,6 @@ public class SideHustleServiceImpl implements ISideHustleService {
@NotNull @NotNull
private final IAnalyseDataService analyseDataService; private final IAnalyseDataService analyseDataService;
@NotNull @NotNull
private final IHomePageService homePageService;
@NotNull
private final IStationService stationService; private final IStationService stationService;
@NotNull @NotNull
private final UserDeptService userDeptService; private final UserDeptService userDeptService;
@ -851,7 +846,7 @@ public class SideHustleServiceImpl implements ISideHustleService {
return null; return null;
} }
Map<Long, Map<String, Float>> powerMap = (Map<Long, Map<String, Float>>) redisTemplate.opsForValue().get(RECENT_YEAR_POWER_DATA); Map<Long, Map<String, Float>> powerMap = (Map<Long, Map<String, Float>>) redisTemplate.opsForValue().get(RECENT_YEAR_POWER_DATA);
List<String> monList = homePageService.getMonthList(0,12,false); List<String> monList = this.getMonthList(0,12,false);
// 获取总发电量 // 获取总发电量
float sumPower = this.getSumPower(map.values(),powerMap,monList); float sumPower = this.getSumPower(map.values(),powerMap,monList);
List<AreaPowerScaleVo> list = new ArrayList<>(); List<AreaPowerScaleVo> list = new ArrayList<>();
@ -901,7 +896,7 @@ public class SideHustleServiceImpl implements ISideHustleService {
// 设备开关机状态 // 设备开关机状态
Map<Long, JointRelayVo> deviceStateMap = (Map<Long, JointRelayVo>) redisTemplate.opsForValue().get(joint_relay_key); Map<Long, JointRelayVo> deviceStateMap = (Map<Long, JointRelayVo>) redisTemplate.opsForValue().get(joint_relay_key);
// 获取总发电量 // 获取总发电量
List<String> monList = homePageService.getMonthList(0,12,false); List<String> monList = this.getMonthList(0,12,false);
float sumPower = this.getSumPower(map.values(),powerMap,monList); float sumPower = this.getSumPower(map.values(),powerMap,monList);
List<OldAreaScaleVo> list = new ArrayList<>(); List<OldAreaScaleVo> list = new ArrayList<>();
map.forEach((key,value)->{ map.forEach((key,value)->{
@ -1554,7 +1549,7 @@ public class SideHustleServiceImpl implements ISideHustleService {
}}); }});
} }
// 获取区域下站点级机构集合 // 获取区域下站点级机构集合
List<Long> stationDeprList = homePageService.getChildDept(depts, area.getId(), new ArrayList<>()); List<Long> stationDeprList = this.getChildDept(depts, area.getId(), new ArrayList<>());
if (CollectionUtil.isEmpty(stationDeprList)) { if (CollectionUtil.isEmpty(stationDeprList)) {
return null; return null;
} }
@ -1673,4 +1668,65 @@ public class SideHustleServiceImpl implements ISideHustleService {
private List<StationEntity> getStation(List<Integer> singletonList, List<Long> childDeptIdList) { private List<StationEntity> getStation(List<Integer> singletonList, List<Long> childDeptIdList) {
return stationService.getStationType(HomePageConstant.HYDROPOWER_SERVETYPE,singletonList,childDeptIdList,true); return stationService.getStationType(HomePageConstant.HYDROPOWER_SERVETYPE,singletonList,childDeptIdList,true);
} }
/**
* 递归取子机构
*
* @param departList
* @param deptId
* @return
*/
private List<Long> getChildDept(List<Dept> departList, Long deptId, List<Long> list) {
if (null == deptId || CollectionUtil.isEmpty(departList)) {
return null;
}
departList.forEach(dept -> {
if (dept.getParentId().equals(deptId)) {
// FIXME 是否只需要添加站点
if (dept.getDeptCategory().equals(4)) {
list.add(dept.getId());
}
getChildDept(departList, dept.getId(), list);
}
});
List<StationEntity> stationList = stationService.getStationType(HomePageConstant.HYDROPOWER_SERVETYPE, Collections.singletonList(HomePageConstant.HYDROPOWER), list,true);
if (CollectionUtil.isEmpty(stationList)) {
return null;
}
List<Long> refDeptList = stationList.stream().map(StationEntity::getRefDept).collect(Collectors.toList());
return list.stream().filter(refDeptList::contains).collect(Collectors.toList());
}
/**
* 获取近年月份集合
*
* @param year
* @return
*/
private List<String> getMonthList(int year, int endMoth, boolean nextMon) {
SimpleDateFormat sdf = new SimpleDateFormat(DateUtil.PATTERN_DATE);
List<String> 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(sdf.format(startCal.getTime()));
startCal.add(Calendar.MONTH, 1);
}
if(nextMon){
list.add(sdf.format(endCal.getTime()));
}
return list;
}
} }

Loading…
Cancel
Save