diff --git a/hzims-service-api/target/classes/META-INF/build-info.properties b/hzims-service-api/target/classes/META-INF/build-info.properties new file mode 100644 index 0000000..8fd2af4 --- /dev/null +++ b/hzims-service-api/target/classes/META-INF/build-info.properties @@ -0,0 +1,5 @@ +build.artifact=hzims-service-api +build.group=com.hnac.hzims +build.name=hzims-service-api +build.time=2024-07-22T06\:45\:56.469Z +build.version=4.0.0-SNAPSHOT diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/mqtt/MqttConfigHzims.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/mqtt/MqttConfigHzims.java index 4952543..993f4b1 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/mqtt/MqttConfigHzims.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/mqtt/MqttConfigHzims.java @@ -60,11 +60,11 @@ public class MqttConfigHzims { log.info(fdpClient.toString()+fdpClient.getClientId()); //drools DroolsSoeSubscribe droolsSoeSubscribe = new DroolsSoeSubscribe(); - MqttAsyncClient droolsClient = droolsSoeSubscribe.subscribe(mqttConfig, "#",Collections.singletonList("#"), droolsMqttConsumer); + MqttAsyncClient droolsClient = droolsSoeSubscribe.subscribe(mqttConfig, Collections.singletonList("#"), droolsMqttConsumer); log.info(droolsClient.toString()+droolsClient.getClientId()); //Soe SoeSubscribe soeSubscribe = new SoeSubscribe(); - MqttAsyncClient soeClient = soeSubscribe.subscribe(mqttConfig, "#",Collections.singletonList("#"), soeMqttConsumer); + MqttAsyncClient soeClient = soeSubscribe.subscribe(mqttConfig, Collections.singletonList("#"), soeMqttConsumer); log.info(soeClient.toString()+soeClient.getClientId()); //hz3000 HZ3000SoeSubscribe hz3000SoeSubscribe = new HZ3000SoeSubscribe(); @@ -72,7 +72,7 @@ public class MqttConfigHzims { log.info(hz3000Client.toString()+hz3000Client.getClientId()); //视频 SoeSubscribe subscribe = new SoeSubscribe(); - MqttAsyncClient videoClient = subscribe.subscribe(mqttConfig, "#",Collections.singletonList("#"), videoMqttConsumer); + MqttAsyncClient videoClient = subscribe.subscribe(mqttConfig, Collections.singletonList("#"), videoMqttConsumer); log.info(videoClient.toString()+videoClient.getClientId()); }catch (Exception e){ log.error(e.toString()) ; diff --git a/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/processflow/mapper/ProcessDictMapper.java b/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/processflow/mapper/ProcessDictMapper.java index c4e1a77..c81b9cb 100644 --- a/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/processflow/mapper/ProcessDictMapper.java +++ b/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/processflow/mapper/ProcessDictMapper.java @@ -1,5 +1,6 @@ package com.hnac.hzims.middle.processflow.mapper; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.hnac.hzims.middle.processflow.entity.ProcessDict; import org.springblade.core.datascope.mapper.UserDataScopeBaseMapper; @@ -9,6 +10,6 @@ import org.springblade.core.datascope.mapper.UserDataScopeBaseMapper; * @Serial 1.0 * @Date 2023/6/5 8:49 */ -public interface ProcessDictMapper extends UserDataScopeBaseMapper { +public interface ProcessDictMapper extends BaseMapper { } diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/home/impl/RealTargetServiceImpl.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/home/impl/RealTargetServiceImpl.java index e58bb87..24efa10 100644 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/home/impl/RealTargetServiceImpl.java +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/home/impl/RealTargetServiceImpl.java @@ -37,9 +37,6 @@ import com.hnac.hzinfo.sdk.analyse.po.MultiAnalyzeCodePO; import com.hnac.hzinfo.sdk.core.response.HzPage; import com.hnac.hzinfo.sdk.core.response.Result; import com.hnac.hzinfo.sdk.v5.device.DeviceDataClient; -import com.hnac.hzinfo.sdk.v5.device.dto.ReductionDataDTO; -import com.hnac.hzinfo.sdk.v5.device.vo.ReductionDataVO; -import io.undertow.util.CopyOnWriteMap; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections4.MapUtils; @@ -56,7 +53,6 @@ import org.springframework.stereotype.Service; import java.math.BigDecimal; import java.math.RoundingMode; import java.time.LocalDate; -import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; import java.util.*; import java.util.concurrent.*; @@ -1274,7 +1270,7 @@ public class RealTargetServiceImpl implements RealTargetService { calendar.add(Calendar.MONTH, -calendar.get(Calendar.MONTH)); String start = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATE) + " 00:00:00"; // 存储数据map :<站点id,<月份,发电量>> - Map> powerMap = new ConcurrentHashMap <>(); + Map> powerMap = new ConcurrentHashMap <>(); // 将站点切割 int limit = countStep(stations.size()); List> limits = Stream.iterate(0, n -> n + 1).limit(limit).parallel().map(a -> stations.stream().skip((long) a * 3).limit(3).parallel().collect(Collectors.toList())).collect(Collectors.toList()); @@ -1289,7 +1285,7 @@ public class RealTargetServiceImpl implements RealTargetService { if(MapUtils.isEmpty(generateMap)){ return; } - powerMap.put(station.getId(),generateMap); + powerMap.put(station.getCode(),generateMap); }); countDownLatch.countDown(); log.error("pool_item_execute_complete: {}" ,item.stream().map(StationEntity::getName).collect(Collectors.toList())); @@ -1359,9 +1355,6 @@ public class RealTargetServiceImpl implements RealTargetService { in(StationEntity::getType, types); } }}); - // 设备信息 -// List devices = JSONObject.parseObject(redisTemplate.opsForValue().get(device_cache_cofig_final).toString(), new TypeReference>() { -// }); // 开始时间 Calendar calendar = Calendar.getInstance(); calendar.add(Calendar.MONTH, -calendar.get(Calendar.MONTH) + 12); @@ -1372,16 +1365,14 @@ public class RealTargetServiceImpl implements RealTargetService { calendar.add(Calendar.MONTH, -calendar.get(Calendar.MONTH)); String start = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATE) + " 00:00:00"; // 存储数据map :<站点id,<月份,发电量>> - Map> powerMap = new HashMap<>(); + Map> powerMap = new HashMap<>(); stationList.forEach(station -> { // 站点设备集合 -// List stationDevices = devices.stream().filter(device -> device.getCreateDept().equals(station.getRefDept())).collect(Collectors.toList()); -// log.error("load_power_data station :" + station.getCode() + "==== device :" + stationDevices ); Map generateMap = this.getGenerateYearByWindEnergy(station,start,end); if(MapUtils.isEmpty(generateMap)){ return; } - powerMap.put(station.getId(),generateMap); + powerMap.put(station.getCode(),generateMap); }); redisTemplate.opsForValue().set(key, powerMap); } diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/report/impl/ReportServiceImpl.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/report/impl/ReportServiceImpl.java index b7fc18e..15dee24 100644 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/report/impl/ReportServiceImpl.java +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/report/impl/ReportServiceImpl.java @@ -69,7 +69,6 @@ import java.math.BigDecimal; import java.math.RoundingMode; import java.text.SimpleDateFormat; import java.time.LocalDateTime; -import java.time.ZoneId; import java.util.*; import java.util.concurrent.*; import java.util.stream.Collectors; @@ -149,7 +148,7 @@ public class ReportServiceImpl implements ReportService { return; } // 站点近年发电数据 - Map> powerMap = (Map>) redisTemplate.opsForValue().get(recent_year_cache_final); + Map> powerMap = (Map>) redisTemplate.opsForValue().get(recent_year_cache_final); // 存储数据节点 key - 月份 value - 区域数据集合 Map> map = new HashMap<>(); // 月份集合 @@ -187,7 +186,7 @@ public class ReportServiceImpl implements ReportService { return; } // 站点近年发电数据 - Map> powerMap = (Map>) redisTemplate.opsForValue().get(key); + Map> powerMap = (Map>) redisTemplate.opsForValue().get(key); // 存储数据节点 key - 月份 value - 区域数据集合 Map> map = new HashMap<>(); // 月份集合 @@ -242,15 +241,15 @@ public class ReportServiceImpl implements ReportService { * @param mon * @return */ - private List getAreaReportByMon(List deptList, Map> powerMap, List stationList, String mon) { + private List getAreaReportByMon(List deptList, Map> powerMap, List stationList, String mon) { // 查询所有站点的计划发电量 List planList = this.planPower(stationList, mon); // 站点实际发电量 - Map actualMap = this.actualPower(powerMap, stationList, mon + "-01"); + Map actualMap = this.actualPower(powerMap, stationList, mon + "-01"); // 站点去年发电量 - Map oldActualMap = this.actualPower(powerMap, stationList, lastyear(1,mon)); + Map oldActualMap = this.actualPower(powerMap, stationList, lastyear(1,mon)); // 站点前发电量 - Map oldOldActualMap = this.actualPower(powerMap, stationList, lastyear(2,mon)); + Map oldOldActualMap = this.actualPower(powerMap, stationList, lastyear(2,mon)); // 取机构中区域部分 List areaList = deptList.stream().filter(o -> o.getDeptCategory().equals(3)).collect(Collectors.toList()); if (CollectionUtil.isEmpty(areaList)) { @@ -295,14 +294,14 @@ public class ReportServiceImpl implements ReportService { /** * 获取站点月份实际发电量 */ - private Map actualPower(Map> powerMap, List stationList, String month) { + private Map actualPower(Map> powerMap, List stationList, String month) { if (MapUtils.isEmpty(powerMap)) { return null; } // 站点Id集合 - List stationIdList = stationList.stream().map(StationEntity::getId).collect(Collectors.toList()); + List stationIdList = stationList.stream().map(StationEntity::getCode).collect(Collectors.toList()); // 存储站点实际发电量 - Map actualPowerMap = new HashMap<>(); + Map actualPowerMap = new HashMap<>(); stationIdList.forEach(key -> { Map monthMap = powerMap.get(key); if (MapUtils.isEmpty(monthMap)) { @@ -349,7 +348,7 @@ public class ReportServiceImpl implements ReportService { * @param areaStationList * @param areaMonthReport */ - private void powerMonth(List planList, Map actualMap, Map oldActualMap, List areaStationList, AreaMonthReportVo areaMonthReport) { + private void powerMonth(List planList, Map actualMap, Map oldActualMap, List areaStationList, AreaMonthReportVo areaMonthReport) { // 计划发电量 List codeList = areaStationList.stream().map(StationEntity::getCode).collect(Collectors.toList()); double planPower = planList.stream().filter(o -> codeList.contains(o.getStationId())).mapToDouble(PlanGenerationEntity::getPlanGeneration).sum(); @@ -360,8 +359,8 @@ public class ReportServiceImpl implements ReportService { return; } // 实际发电量 - List ids = areaStationList.stream().map(StationEntity::getId).collect(Collectors.toList()); - double actualPower = actualMap.entrySet().stream().filter(e -> ids.contains(e.getKey())).mapToDouble(Map.Entry::getValue).sum(); + List codes = areaStationList.stream().map(StationEntity::getCode).collect(Collectors.toList()); + double actualPower = actualMap.entrySet().stream().filter(e -> codes.contains(e.getKey())).mapToDouble(Map.Entry::getValue).sum(); areaMonthReport.setActualPower(Float.parseFloat(String.valueOf(actualPower))); if (Math.abs(planPower) <= 0) { areaMonthReport.setPowerFinishRate(0.0); @@ -371,7 +370,7 @@ public class ReportServiceImpl implements ReportService { areaMonthReport.setPowerFinishRate(powerFinishRate); } // 同比 - double oldActualPower = oldActualMap.entrySet().stream().filter(e -> ids.contains(e.getKey())).mapToDouble(Map.Entry::getValue).sum(); + double oldActualPower = oldActualMap.entrySet().stream().filter(e -> codes.contains(e.getKey())).mapToDouble(Map.Entry::getValue).sum(); if (Math.abs(actualPower) <= 0 || Math.abs(oldActualPower) <= 0) { areaMonthReport.setComparePowerRate(0.0); return; @@ -490,15 +489,15 @@ public class ReportServiceImpl implements ReportService { * @param areaStationList * @param areaMonthReport */ - private void predictPlanPower(Map oldActualMap, Map oldOldActualMap, List areaStationList, AreaMonthReportVo areaMonthReport) { + private void predictPlanPower(Map oldActualMap, Map oldOldActualMap, List areaStationList, AreaMonthReportVo areaMonthReport) { areaMonthReport.setPredictPlanPower(0.0); // 实际发电量 - List ids = areaStationList.stream().map(StationEntity::getId).collect(Collectors.toList()); - if(CollectionUtil.isEmpty(ids)){ + List codes = areaStationList.stream().map(StationEntity::getCode).collect(Collectors.toList()); + if(CollectionUtil.isEmpty(codes)){ return; } - double oldActualPower = oldActualMap.entrySet().stream().filter(e -> ids.contains(e.getKey())).mapToDouble(Map.Entry::getValue).sum(); - double oldOldActualPower = oldOldActualMap.entrySet().stream().filter(e -> ids.contains(e.getKey())).mapToDouble(Map.Entry::getValue).sum(); + double oldActualPower = oldActualMap.entrySet().stream().filter(e -> codes.contains(e.getKey())).mapToDouble(Map.Entry::getValue).sum(); + double oldOldActualPower = oldOldActualMap.entrySet().stream().filter(e -> codes.contains(e.getKey())).mapToDouble(Map.Entry::getValue).sum(); if(Math.abs(oldActualPower) <= 0 && Math.abs(oldOldActualPower) <= 0 ){ return; } @@ -1009,7 +1008,7 @@ public class ReportServiceImpl implements ReportService { EchartValueVo echartValue = new EchartValueVo(); echartValue.setAttribute(value.getSignage()); echartValue.setAttributeName(attributes.stream().filter(o->o.getSignage().equals(value.getSignage())).collect(Collectors.toList()).get(0).getSignageName()); - if(StringUtil.isEmpty(value.getVal())){ + if(StringUtil.isBlank(value.getVal())){ echartValue.setValue(0.0); }else{ echartValue.setValue(Double.parseDouble(value.getVal())); diff --git a/hzims-service/hzims-simulate/pom.xml b/hzims-service/hzims-simulate/pom.xml deleted file mode 100644 index 72cbbb0..0000000 --- a/hzims-service/hzims-simulate/pom.xml +++ /dev/null @@ -1,129 +0,0 @@ - - - - com.hnac.hzims - hzims-service - 4.0.0-SNAPSHOT - - - 4.0.0 - hzims-simulate - jar - - - 8 - 8 - UTF-8 - - - - - - com.xuxueli - xxl-job-core - - - com.google.guava - failureaccess - 1.0.1 - - - org.springblade - blade-common - - - org.springblade - blade-core-boot - - - org.springblade - blade-core-cloud - - - - - org.springblade - blade-starter-http - - - org.springblade - blade-core-cloud - compile - - - - org.springblade - blade-starter-datascope - compile - - - org.projectlombok - lombok - - - - com.hnac.hzims - equipment-api - 4.0.0-SNAPSHOT - - - - com.hnac.hzims - weather-api - 4.0.0-SNAPSHOT - - - - com.hzinfo.framework - hnac-framework-mqtt-starters - - - - dom4j - dom4j - 1.6.1 - compile - - - org.springblade - blade-core-cloud - 5.1.1.RELEASE.fix.1 - compile - - - - - - - ${project.name}-${project.version} - - - src/main/java - - **/*.xml - - false - - - - - org.springframework.boot - spring-boot-maven-plugin - 2.6.6 - - - - repackage - - - exec - - - - - - - - \ No newline at end of file diff --git a/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/SimulateApplication.java b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/SimulateApplication.java deleted file mode 100644 index 59981d0..0000000 --- a/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/SimulateApplication.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.hnac.hzims.simulate; - -import org.mybatis.spring.annotation.MapperScan; -import org.springblade.core.cloud.feign.EnableBladeFeign; -import org.springblade.core.launch.BladeApplication; -import org.springframework.boot.builder.SpringApplicationBuilder; -import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; -import org.springframework.cloud.client.SpringCloudApplication; - - -/** - * @author admin - */ -@EnableBladeFeign -@SpringCloudApplication -@MapperScan(basePackages={"com.hnac.hzims.**.mapper"}) -//@ComponentScan(basePackages = {"com.hnac.hzinfo.simulate"}) -public class SimulateApplication extends SpringBootServletInitializer { - static String APPLICATION_NAME="hzims-simulate"; - public static void main(String[] args) { - BladeApplication.run(APPLICATION_NAME, SimulateApplication.class, args); - } - - @Override - protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) { - return BladeApplication.createSpringApplicationBuilder(builder, APPLICATION_NAME, SimulateApplication.class); - } -} diff --git a/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/constants/WriteRealDataConstant.java b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/constants/WriteRealDataConstant.java deleted file mode 100644 index bd48066..0000000 --- a/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/constants/WriteRealDataConstant.java +++ /dev/null @@ -1,43 +0,0 @@ -package com.hnac.hzims.simulate.constants; - -/** - * @author ysj - * @describe 实时数据写入常量 - */ -public interface WriteRealDataConstant { - - String REAL_DATA_V3 = "3"; - - String REAL_DATA_V4 = "4"; - - String GATE_FLOW = "过闸流量(m³/s)"; - - String OPENING_DEGREE = "开度(m)"; - - String GATE_STATUS = "闸门状态"; - - String WRITE_REAL_GATE_DATA = "writeRealGateData"; - - String WRITE_REAL_RAIN_DATA = "writeRealRainData"; - - Long OPEN = 0L; - - Long CLOSE = 1L; - - String WRITE_GATE = "1"; - - String WRITE_RAIN = "2"; - - // 降雨站属性标识 - String ATTR_RAIN = "attr_rain"; - String ATTR_WIND360 = "wind360"; - String ATTR_WIND_SCALE = "wind_scale"; - String ATTR_WIND_SPEED = "wind_speed "; - String ATTR_HUMIDITY = "humidity"; - String ATTR_PRESSURE = "pressure"; - String ATTR_VIS = "vis"; - String ATTR_CLOUD = "cloud"; - String ATTR_DEW = "dew"; - String ATTR_FEELS_LIKE = "feels_like"; - String ATTR_TEMP = "temp"; -} \ No newline at end of file diff --git a/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/controller/GageController.java b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/controller/GageController.java deleted file mode 100644 index 08ec0a8..0000000 --- a/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/controller/GageController.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.hnac.hzims.simulate.controller; - -import com.hnac.hzims.simulate.service.WriteRealDataService; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import lombok.AllArgsConstructor; -import lombok.extern.slf4j.Slf4j; -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; - -/** - * @author ysj - */ -@RestController -@AllArgsConstructor -@RequestMapping("/gate") -@Api(value = "闸门开关机模拟服务", tags = "闸门开关机模拟服务") -public class GageController { - - private final WriteRealDataService writeRealDataService; - - @GetMapping("/isOpen") - @ApiOperation(value = "枢纽天气情况") - public R weather(@RequestParam("deviceCode") String deviceCode, - @RequestParam("isOpen") Long isOpen){ - return R.data(writeRealDataService.isOpen(deviceCode,isOpen)); - } -} \ No newline at end of file diff --git a/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/controller/SimulationDataController.java b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/controller/SimulationDataController.java deleted file mode 100644 index 8d6d85c..0000000 --- a/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/controller/SimulationDataController.java +++ /dev/null @@ -1,195 +0,0 @@ -package com.hnac.hzims.simulate.controller; - -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.baomidou.mybatisplus.core.metadata.IPage; -import com.google.common.collect.Maps; -import com.hnac.hzims.common.enums.ExceptionEnum; -import com.hnac.hzims.simulate.entity.DataModel; -import com.hnac.hzims.simulate.entity.Device; -import com.hnac.hzims.simulate.entity.DeviceField; -import com.hnac.hzims.simulate.entity.DeviceFieldGap; -import com.hnac.hzims.simulate.service.DeviceFieldGapService; -import com.hnac.hzims.simulate.service.DeviceFieldService; -import com.hnac.hzims.simulate.service.SimulationService; -import com.hnac.hzims.simulate.util.ParseFacUtils; -import com.hnac.hzims.simulate.util.TopicConstant; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import lombok.extern.slf4j.Slf4j; -import org.springblade.core.log.exception.ServiceException; -import org.springblade.core.mp.support.Condition; -import org.springblade.core.mp.support.Query; -import org.springblade.core.tool.api.R; -import org.springblade.core.tool.jackson.JsonUtil; -import org.springblade.core.tool.utils.Func; -import org.springblade.mqtt.producer.IMqttSender; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.web.bind.annotation.*; - -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.math.BigDecimal; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; - -@RestController -@RequestMapping("/simulationData") -@Api(value = "数据模拟服务", tags = "数据模拟服务") -@Slf4j -public class SimulationDataController { - - @Autowired - private SimulationService simulationService; - - @Autowired - private DeviceFieldService deviceFieldService; - - @Autowired - private DeviceFieldGapService deviceFieldGapService; - - @Autowired - private IMqttSender mqttSender; - - @Value("fac.path") - private String facPath; - - public static Map cacheMap = Maps.newHashMap(); - - @ApiOperation(value = "解析v3.0场信息文件", notes = "解析场信息文件") - @GetMapping("/readFac") - public R readFac() { - InputStream inputStream = null; - try { - inputStream = new FileInputStream(new File(facPath+File.separator+"factory.fac")); - List list = ParseFacUtils.parsePoint(inputStream); - list.forEach(entity -> { - mqttSender.sendToMqtt(TopicConstant.TOPIC_DEVICE_MODEL, JsonUtil.toJson(entity)); - }); - return R.success("解析场信息文件成功"); - } catch (Exception e) { - log.error(e.getMessage(), e); - return R.fail("解析场信息文件失败"); - } finally { - if (inputStream != null) { - try { - inputStream.close(); - } catch (IOException e) { - e.printStackTrace(); - } - } - } - } - - @ApiOperation(value = "分页范围配置", notes = "分页范围配置") - @GetMapping("/pageGap") - public R> pageGap(String stationId, Query query) { - List list=simulationService.getDeviceListByStationId(stationId); - List ids=list.stream().map(Device::getId).collect(Collectors.toList()); - LambdaQueryWrapper lambdaQueryWrapper=new LambdaQueryWrapper(); - lambdaQueryWrapper.in(DeviceFieldGap::getFacDeviceId,ids); - IPage pageList=deviceFieldGapService.page(Condition.getPage(query),lambdaQueryWrapper); - return R.data(pageList); - } - - @ApiOperation(value = "更新设备属性范围配置", notes = "更新设备属性范围配置") - @PostMapping("/updateGap") - public R updateGap(@RequestBody DeviceFieldGap deviceFieldGap) { - deviceFieldGapService.updateById(deviceFieldGap); - return R.status(true); - } - - @ApiOperation(value = "第一次同步设备属性", notes = "第一次同步设备属性") - @GetMapping("/syncOneGap") - public R syncGap() { - //存在表 - int count=deviceFieldService.existGapTable(); - if(count<=0){//建表 - deviceFieldService.createGapTable(); - } - //同步 - List list=deviceFieldService.list(); - List gaps=list.stream().map(result -> new DeviceFieldGap(result.getId(), result.getFacDeviceId(), - result.getSignage(),result.getName(), BigDecimal.ZERO,BigDecimal.ZERO)) - .collect(Collectors.toList()); - deviceFieldGapService.saveOrUpdateBatch(gaps); - - return R.status(true); - } - - @ApiOperation(value = "第二次同步设备属性", notes = "第二次同步设备属性") - @GetMapping("/syncTwoGap") - public R syncTwoGap() { - //同步 - List list=deviceFieldService.queryNewInsert(); - if(list!=null && !list.isEmpty()) { - List gaps = list.stream().map(result -> new DeviceFieldGap(result.getId(), result.getFacDeviceId(), - result.getSignage(), result.getName(), BigDecimal.ZERO, BigDecimal.ZERO)) - .collect(Collectors.toList()); - deviceFieldGapService.saveBatch(gaps); - } - return R.status(true); - } - - - @ApiOperation(value = "模拟单站的数据(循环,每隔sleepTime时长发送一次整站数据)", notes = "模拟单站的数据") - @GetMapping("/simulationMultiple") - public R simulationMultipleV3(String stationId, Long sleepTime) { - String key = "simulation:" + stationId; - String hasExc = cacheMap.get(key); - if (Func.isNotBlank(hasExc)) { - return R.fail("该站已经在模拟数据了"); - } - try { - simulationService.simulationMultiple(stationId, sleepTime); - }catch (Exception e) { - throw new ServiceException(ExceptionEnum.SIMULATE_ERROR); - } - cacheMap.put(key, "true"); - return R.status(true); - - } - - @ApiOperation(value = "模拟单站的数据(循环,每隔sleepTime时长发送一次整站数据)", notes = "模拟单站的数据") - @GetMapping("/simulationMultipleV4") - public R simulationMultipleV4(String stationId, Long sleepTime) { - String key = "simulation:" + stationId; - String hasExc = cacheMap.get(key); - if (Func.isNotBlank(hasExc)) { - return R.fail("该站已经在模拟数据了"); - } - try { - simulationService.simulationMultipleV4(stationId, sleepTime); - }catch (Exception e) { - throw new ServiceException(ExceptionEnum.SIMULATE_ERROR); - } - cacheMap.put(key, "true"); - return R.status(true); - } - -// @ApiOperation(value = "模拟单站的数据(循环,每隔sleepTime时长发送一次整站数据)", notes = "模拟单站的数据") -// @GetMapping("/simulationMultipleFlow") -// public R simulationMultipleInFlow() { -// String key = "simulationMultipleInFlow"; -// String hasExc = cacheMap.get(key); -// if (Func.isNotBlank(hasExc)) { -// return R.fail("该站已经在模拟数据了"); -// } -// simulationService.simulationMultipleInFlow(); -// cacheMap.put(key, "true"); -// return R.status(true); -// } - - - @ApiOperation(value = "停止模拟", notes = "停止模拟") - @GetMapping("/stopStart") - public R stopStart() { - simulationService.stopStart(); - return R.status(true); - - } - -} diff --git a/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/entity/DataItem.java b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/entity/DataItem.java deleted file mode 100644 index 633cbb8..0000000 --- a/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/entity/DataItem.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.hnac.hzims.simulate.entity; - -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; - -@Data -@AllArgsConstructor -@NoArgsConstructor -@Builder -public class DataItem { - - private String id; - private String signage;//hz3000定义的id - private String name; - private String type; - private String soeType; - private String eventType; -} diff --git a/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/entity/DataModel.java b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/entity/DataModel.java deleted file mode 100644 index 7771e95..0000000 --- a/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/entity/DataModel.java +++ /dev/null @@ -1,46 +0,0 @@ -package com.hnac.hzims.simulate.entity; - -import lombok.Data; - -import java.util.List; - -/** - * { - * "station": "4543", - * "structType": "dataGroup", - * "id": "5016387599_0", - * "pid": "5016387585", - * "name": "温度传感器", - * "children": [{ - * "id": "5016387607", - * "name": "温度", - * "type": "YC" - * },{ - * "id": "5016387617", - * "name": "高度", - * "type": "YC" - * },{ - * "id": "5016387608", - * "name": "工作状态", - * "type": "YX" - * },{ - * "id": "5016387609", - * "name": "工作状态", - * "type": "SOE", - * "eventType": "" - * }] - * } - * 数据组 - * @author ninglong - */ -@Data -public class DataModel { - private String station; - private String structType; - private String id; - private String signage;//hz3000定义的id - private String pid; - private String name; - private List children; -} - diff --git a/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/entity/Device.java b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/entity/Device.java deleted file mode 100644 index b3ed590..0000000 --- a/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/entity/Device.java +++ /dev/null @@ -1,66 +0,0 @@ -package com.hnac.hzims.simulate.entity; - -import com.baomidou.mybatisplus.annotation.IdType; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import com.fasterxml.jackson.annotation.JsonFormat; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; -import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; -import io.swagger.annotations.ApiModelProperty; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; -import org.springframework.format.annotation.DateTimeFormat; - -import java.io.Serializable; -import java.util.Date; - -/** - * 数据组 - * - * @author ninglong - */ -@TableName(value = "hzinfo_fac_device") -@Data -@AllArgsConstructor -@NoArgsConstructor -@Builder -public class Device implements Serializable { - - @ApiModelProperty(value = "id") - @TableId(type = IdType.INPUT) - private String id; - - @ApiModelProperty(value = "名称") - private String name; - - @ApiModelProperty(value = "0-云端cms,1-站端直传") - private Integer source; - - @ApiModelProperty("hz3000定义的id,如果定义的是大id则值与id字段值相同") - private String sid; - - @ApiModelProperty("version=v3,version=v4") - private String modelKind; - - @DateTimeFormat( - pattern = "yyyy-MM-dd HH:mm:ss" - ) - @JsonFormat( - pattern = "yyyy-MM-dd HH:mm:ss" - ) - @ApiModelProperty("创建时间") - private Date createTime; - - @JsonSerialize( - using = ToStringSerializer.class - ) - - @ApiModelProperty("项目id") - private String projectId; - - - @ApiModelProperty("写入方式") - private String isWrite; -} \ No newline at end of file diff --git a/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/entity/DeviceData.java b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/entity/DeviceData.java deleted file mode 100644 index 411609c..0000000 --- a/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/entity/DeviceData.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.hnac.hzims.simulate.entity; - -import com.google.common.collect.Lists; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; - -import java.util.List; - -/** - * 设备数据 - */ -@Data -@AllArgsConstructor -@NoArgsConstructor -@Builder -public class DeviceData { - private String station; - private String time; - private List children = Lists.newArrayList(); -} diff --git a/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/entity/DeviceDataV4.java b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/entity/DeviceDataV4.java deleted file mode 100644 index 6b6023d..0000000 --- a/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/entity/DeviceDataV4.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.hnac.hzims.simulate.entity; - -import com.google.common.collect.Lists; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; - -import java.util.List; - -@Data -@AllArgsConstructor -@NoArgsConstructor -@Builder -public class DeviceDataV4 { - private String stationId; - private String time; - private List children = Lists.newArrayList(); -} diff --git a/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/entity/DeviceFacConfig.java b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/entity/DeviceFacConfig.java deleted file mode 100644 index 80c449e..0000000 --- a/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/entity/DeviceFacConfig.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.hnac.hzims.simulate.entity; - -import com.baomidou.mybatisplus.annotation.IdType; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; - -import java.io.Serializable; - -/** - * @author ysj - */ -@TableName("hzinfo_fac_device_config") -@Data -public class DeviceFacConfig implements Serializable { - @ApiModelProperty("id") - @TableId(type = IdType.INPUT) - private String id; - - @ApiModelProperty("设备id") - private String deviceCode; - - @ApiModelProperty("字段标识") - private String facDeviceId; - - @ApiModelProperty("站点Id") - private String stationId; - - @ApiModelProperty("站点类型") - private String modelKind; - - @ApiModelProperty("sid") - private String sid; - - @ApiModelProperty("数据写入方式: 1-闸门,2-天气") - private String writeMethod; -} \ No newline at end of file diff --git a/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/entity/DeviceField.java b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/entity/DeviceField.java deleted file mode 100644 index c9660e2..0000000 --- a/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/entity/DeviceField.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.hnac.hzims.simulate.entity; - -import com.baomidou.mybatisplus.annotation.IdType; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import com.fasterxml.jackson.annotation.JsonFormat; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; -import org.springframework.format.annotation.DateTimeFormat; - -import java.io.Serializable; -import java.util.Date; - -@TableName("hzinfo_fac_device_attr") -@Data -public class DeviceField implements Serializable { - @ApiModelProperty("id") - @TableId(type = IdType.INPUT) - private String id; - @ApiModelProperty("设备id") - private String facDeviceId; - @ApiModelProperty("字段标识") - private String signage; - @ApiModelProperty("字段名称") - private String name; - @ApiModelProperty("最大值") - private String projectId; - - @DateTimeFormat( - pattern = "yyyy-MM-dd HH:mm:ss" - ) - @JsonFormat( - pattern = "yyyy-MM-dd HH:mm:ss" - ) - @ApiModelProperty("创建时间") - private Date createTime; - - private Long modelClassifyId; - private String alarmType; - - -} diff --git a/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/entity/DeviceFieldGap.java b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/entity/DeviceFieldGap.java deleted file mode 100644 index d3efad5..0000000 --- a/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/entity/DeviceFieldGap.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.hnac.hzims.simulate.entity; - -import com.baomidou.mybatisplus.annotation.IdType; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import io.swagger.annotations.ApiModelProperty; -import lombok.AllArgsConstructor; -import lombok.Data; - -import java.io.Serializable; -import java.math.BigDecimal; - -@TableName("hzinfo_fac_device_attr_gap") -@Data -@AllArgsConstructor -public class DeviceFieldGap implements Serializable { - @ApiModelProperty("id") - @TableId(type = IdType.INPUT) - private String id; - @ApiModelProperty("设备id") - private String facDeviceId; - @ApiModelProperty("字段标识") - private String signage; - @ApiModelProperty("字段名称") - private String name; - @ApiModelProperty("最大值") - private BigDecimal maxVal; - @ApiModelProperty("最小值") - private BigDecimal minVal; -} diff --git a/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/entity/DeviceRainGap.java b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/entity/DeviceRainGap.java deleted file mode 100644 index 5363edd..0000000 --- a/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/entity/DeviceRainGap.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.hnac.hzims.simulate.entity; - -import com.baomidou.mybatisplus.annotation.IdType; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; - -import java.io.Serializable; - -/** - * @author ysj - */ -@TableName("hzinfo_fac_device_rain_gap") -@Data -public class DeviceRainGap implements Serializable { - - @ApiModelProperty("id") - @TableId(type = IdType.INPUT) - private String id; - - @ApiModelProperty("设备id") - private String facDeviceId; - - @ApiModelProperty("属性标识名称") - private String name; - - @ApiModelProperty("属性标识") - private String attribute; - - @ApiModelProperty("字段标识") - private String signage; -} \ No newline at end of file diff --git a/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/entity/Kvtq.java b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/entity/Kvtq.java deleted file mode 100644 index 4a6c839..0000000 --- a/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/entity/Kvtq.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.hnac.hzims.simulate.entity; - -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; - -@Data -@AllArgsConstructor -@NoArgsConstructor -@Builder -public class Kvtq { - - private String k; - private String v; - private String t; - private Integer q; -} diff --git a/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/entity/KvtqV4.java b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/entity/KvtqV4.java deleted file mode 100644 index a5a8b0e..0000000 --- a/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/entity/KvtqV4.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.hnac.hzims.simulate.entity; - -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; - -@Data -@AllArgsConstructor -@NoArgsConstructor -@Builder -public class KvtqV4 { - private String sid; - private String k; - private String v; - private String t; - private Integer q; -} diff --git a/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/mapper/DeviceFacConfigMapper.java b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/mapper/DeviceFacConfigMapper.java deleted file mode 100644 index ad70ac9..0000000 --- a/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/mapper/DeviceFacConfigMapper.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.hnac.hzims.simulate.mapper; - -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.hnac.hzims.simulate.entity.DeviceFacConfig; -import org.apache.ibatis.annotations.Mapper; -import org.apache.ibatis.annotations.Param; - -import java.util.List; - -/** - * @author ysj - */ -@Mapper -public interface DeviceFacConfigMapper extends BaseMapper { - - List queryConfigDevice(@Param("method") String method); - - DeviceFacConfig configByDeviceCode(@Param("deviceCode") String deviceCode); -} \ No newline at end of file diff --git a/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/mapper/DeviceFacConfigMapper.xml b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/mapper/DeviceFacConfigMapper.xml deleted file mode 100644 index 1dda78c..0000000 --- a/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/mapper/DeviceFacConfigMapper.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - diff --git a/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/mapper/DeviceFieldGapMapper.java b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/mapper/DeviceFieldGapMapper.java deleted file mode 100644 index d3e85d4..0000000 --- a/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/mapper/DeviceFieldGapMapper.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.hnac.hzims.simulate.mapper; - -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.hnac.hzims.simulate.entity.DeviceFieldGap; -import org.apache.ibatis.annotations.Mapper; -import org.apache.ibatis.annotations.Param; - -import java.math.BigDecimal; -import java.util.List; - -@Mapper -public interface DeviceFieldGapMapper extends BaseMapper { - List queryDeviceLimits(@Param("signages") List signages); - - void updateLimitById(@Param("maxValue") BigDecimal maxValue, @Param("minValue") BigDecimal minValue,@Param("id") String id); -} diff --git a/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/mapper/DeviceFieldMapper.java b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/mapper/DeviceFieldMapper.java deleted file mode 100644 index e44fc5d..0000000 --- a/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/mapper/DeviceFieldMapper.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.hnac.hzims.simulate.mapper; - -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.hnac.hzims.simulate.entity.DeviceField; -import org.apache.ibatis.annotations.Mapper; -import org.apache.ibatis.annotations.Param; - -import java.util.List; - -@Mapper -public interface DeviceFieldMapper extends BaseMapper { - int existGapTable(); - int createGapTable(); - List queryNewInsert(); - - List queryDeviceFields(@Param("devices") List devices); - - List querySignages(@Param("facDeviceId") String facDeviceId); -} diff --git a/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/mapper/DeviceFieldMapper.xml b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/mapper/DeviceFieldMapper.xml deleted file mode 100644 index 477ff69..0000000 --- a/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/mapper/DeviceFieldMapper.xml +++ /dev/null @@ -1,34 +0,0 @@ - - - - - - CREATE TABLE hzinfo_device_field_gap ( - id varchar(64) COLLATE utf8mb4_bin NOT NULL COMMENT '字段类型', - fac_device_id varchar(50) COLLATE utf8mb4_bin NOT NULL COMMENT '设备实例id', - signage varchar(25) COLLATE utf8mb4_bin DEFAULT NULL COMMENT '字段标识', - name varchar(100) COLLATE utf8mb4_bin NOT NULL COMMENT '字段名称', - max_val decimal(9,3) DEFAULT NULL, - min_val decimal(9,3) DEFAULT NULL, - PRIMARY KEY (id) - ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT='设备字段' - - - - - - - diff --git a/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/mapper/DeviceMapper.java b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/mapper/DeviceMapper.java deleted file mode 100644 index 4edccd1..0000000 --- a/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/mapper/DeviceMapper.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.hnac.hzims.simulate.mapper; - -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.hnac.hzims.simulate.entity.Device; -import org.apache.ibatis.annotations.Mapper; -import org.apache.ibatis.annotations.Param; - -@Mapper -public interface DeviceMapper extends BaseMapper { - String getSid(@Param("stationId") String stationId); - -// List selectStcd(); -// -// int insertData(@Param("param") Map param); -} diff --git a/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/mapper/DeviceMapper.xml b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/mapper/DeviceMapper.xml deleted file mode 100644 index 19587cf..0000000 --- a/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/mapper/DeviceMapper.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - - - - diff --git a/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/mapper/DeviceRainGapMapper.java b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/mapper/DeviceRainGapMapper.java deleted file mode 100644 index 5438aca..0000000 --- a/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/mapper/DeviceRainGapMapper.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.hnac.hzims.simulate.mapper; - -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.hnac.hzims.simulate.entity.DeviceRainGap; -import org.apache.ibatis.annotations.Mapper; -import org.apache.ibatis.annotations.Param; - -import java.util.List; - -/** - * @author ysj - */ -@Mapper -public interface DeviceRainGapMapper extends BaseMapper { - - List RainGapByFacDeviceId(@Param("facDeviceId") String facDeviceId); -} \ No newline at end of file diff --git a/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/mapper/DeviceRainGapMapper.xml b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/mapper/DeviceRainGapMapper.xml deleted file mode 100644 index 95d531a..0000000 --- a/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/mapper/DeviceRainGapMapper.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - diff --git a/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/mapper/IHzllmInteractiveService.xml b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/mapper/IHzllmInteractiveService.xml deleted file mode 100644 index 7a4fff8..0000000 --- a/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/mapper/IHzllmInteractiveService.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - UPDATE HZINFO_FAC_DEVICE_ATTR_GAP - SET max_val = #{maxValue}, - min_val = #{minValue} - WHERE id = #{id} - - diff --git a/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/scheduled/WriteRealDataTask.java b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/scheduled/WriteRealDataTask.java deleted file mode 100644 index 3032379..0000000 --- a/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/scheduled/WriteRealDataTask.java +++ /dev/null @@ -1,53 +0,0 @@ -package com.hnac.hzims.simulate.scheduled; - -import com.hnac.hzims.simulate.constants.WriteRealDataConstant; -import com.hnac.hzims.simulate.service.WriteRealDataService; -import com.xxl.job.core.biz.model.ReturnT; -import com.xxl.job.core.handler.annotation.XxlJob; -import lombok.extern.slf4j.Slf4j; -import org.springblade.core.tool.utils.DateUtil; -import org.springblade.core.tool.utils.Func; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.scheduling.annotation.Scheduled; -import org.springframework.stereotype.Component; - -import java.util.Date; - - -/** - * @author ysj - * @describe 实时数据写入定时任务 - */ -@Slf4j -@Component -public class WriteRealDataTask { - - @Autowired - private WriteRealDataService writeRealDataService; - - /** - * 设备模型信息 - */ - @XxlJob(WriteRealDataConstant.WRITE_REAL_GATE_DATA) - //@Scheduled(cron = "0/40 * * * * ? ") - public ReturnT writeRealGateData(String param) { - if (Func.isBlank(param)) { - param = DateUtil.format(new Date(), "yyyy-MM"); - } - writeRealDataService.writeRealGateData(param); - return new ReturnT<>("SUCCESS"); - } - - /** - * 设备模型信息 - */ - @XxlJob(WriteRealDataConstant.WRITE_REAL_RAIN_DATA) - //@Scheduled(cron = "0/40 * * * * ? ") - public ReturnT writeRealRainData(String param) { - if (Func.isBlank(param)) { - param = DateUtil.format(new Date(), "yyyy-MM"); - } - writeRealDataService.writeRealRainData(param); - return new ReturnT<>("SUCCESS"); - } -} \ No newline at end of file diff --git a/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/service/DeviceFieldGapService.java b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/service/DeviceFieldGapService.java deleted file mode 100644 index 99868bb..0000000 --- a/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/service/DeviceFieldGapService.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.hnac.hzims.simulate.service; - -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.hnac.hzims.simulate.entity.DeviceFieldGap; -import com.hnac.hzims.simulate.mapper.DeviceFieldGapMapper; -import org.springframework.stereotype.Service; - -@Service -public class DeviceFieldGapService extends ServiceImpl { - -} diff --git a/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/service/DeviceFieldService.java b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/service/DeviceFieldService.java deleted file mode 100644 index c97b7e9..0000000 --- a/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/service/DeviceFieldService.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.hnac.hzims.simulate.service; - -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.hnac.hzims.simulate.entity.DeviceField; -import com.hnac.hzims.simulate.mapper.DeviceFieldMapper; -import org.springframework.stereotype.Service; - -import java.util.List; - -@Service -public class DeviceFieldService extends ServiceImpl { - - public int existGapTable(){ - return this.baseMapper.existGapTable(); - } - - public int createGapTable(){ - return this.baseMapper.createGapTable(); - } - - public List queryNewInsert(){ - return this.baseMapper.queryNewInsert(); - } -} diff --git a/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/service/DeviceService.java b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/service/DeviceService.java deleted file mode 100644 index 494b1e5..0000000 --- a/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/service/DeviceService.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.hnac.hzims.simulate.service; - -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.hnac.hzims.simulate.entity.Device; -import com.hnac.hzims.simulate.mapper.DeviceMapper; -import org.springframework.stereotype.Service; - -@Service -public class DeviceService extends ServiceImpl { - public String getSid(String stationId){ - return this.baseMapper.getSid(stationId); - } - -// public List selectStcd(){ -// return this.baseMapper.selectStcd(); -// } -// -// public int insertData(Map param){ -// return this.baseMapper.insertData(param); -// } -} diff --git a/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/service/SimulationService.java b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/service/SimulationService.java deleted file mode 100644 index 31903f9..0000000 --- a/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/service/SimulationService.java +++ /dev/null @@ -1,280 +0,0 @@ -package com.hnac.hzims.simulate.service; - -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.baomidou.mybatisplus.core.toolkit.Wrappers; -import com.google.common.collect.Lists; -import com.google.common.collect.Maps; -import com.hnac.hzims.simulate.entity.*; -import com.hnac.hzims.simulate.util.DataConstants; -import lombok.extern.slf4j.Slf4j; -import org.springblade.core.tool.jackson.JsonUtil; -import org.springblade.core.tool.utils.DateTimeUtil; -import org.springblade.core.tool.utils.ThreadUtil; -import org.springblade.mqtt.producer.IMqttSender; -import com.hnac.hzims.simulate.util.TopicConstant; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.scheduling.annotation.Async; -import org.springframework.stereotype.Service; - -import java.math.BigDecimal; -import java.text.SimpleDateFormat; -import java.time.LocalDateTime; -import java.util.*; -import java.util.stream.Collectors; - -@Service -@Slf4j -public class SimulationService { - @Autowired - IMqttSender mqttSender; - - @Autowired - DeviceService deviceService; - - @Autowired - DeviceFieldService deviceFieldService; - - @Autowired - DeviceFieldGapService deviceFieldGapService; - - public List getDeviceListByStationId(String projectId){ - LambdaQueryWrapper lambdaQueryWrapper=new LambdaQueryWrapper(); - lambdaQueryWrapper.eq(Device::getProjectId,projectId); - lambdaQueryWrapper.eq(Device::getIsWrite,"0"); - List list = deviceService.list(lambdaQueryWrapper); - return list; - } - - String getSid(String stationId){ - return deviceService.getSid(stationId); - } - - //模拟启停标识 - private volatile boolean flag=true; - - public void stopStart(){ - flag = !flag; - } - - @Async - public void simulationMultiple(String stationId, Long sleepTime) { - - List list = getDeviceListByStationId(stationId); - //查询所有属性 - List fieldList = deviceFieldService.list(); - List gapList = deviceFieldGapService.list(); - - log.info("本站{}有{}个设备实例,每{}毫秒发送{}条数据", stationId, list.size(), sleepTime, list.size()); - while (true) { - if (flag) {//启动或关闭模拟 - for (Device device : list) { - Map map = simulation(stationId, device,fieldList,gapList); -// log.info("map data: "+ JsonUtil.toJson(map)); - if (map.get("yc") != null && map.get("yc").getChildren().size() > 0) { - log.info("模拟推送遥测,主题:topic_hzinfo_props:{}", JsonUtil.toJson(map.get("yc"))); - mqttSender.sendToMqtt(TopicConstant.TOPIC_HZINFO_PROPS, JsonUtil.toJson(map.get("yc"))); - } -// if (map.get("dd") != null && map.get("dd").getChildren().size() > 0) { -// mqttSender.sendToMqtt(TopicConstant.TOPIC_HZINFO_DD, JsonUtil.toJson(map.get("dd"))); -// } - if (map.get("yx") != null && map.get("yx").getChildren().size() > 0) { - mqttSender.sendToMqtt(TopicConstant.TOPIC_HZINFO_YX, JsonUtil.toJson(map.get("yx"))); - } - } - //最小10毫秒 - if (sleepTime == null || sleepTime == 0) { - sleepTime = 10L; - } - ThreadUtil.sleep(sleepTime); - } - } - } - - -// @Async -// public void simulationMultipleInFlow(){ -// List list=deviceService.selectStcd(); -// while (true) { -// List> datas = simulationFlow(list); -// for(Map param:datas){ -// deviceService.insertData(param); -// } -// ThreadUtil.sleep(3600000); -// } -// } - - private List> simulationFlow(List list){ - List> datas =new ArrayList<>(); - SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); - String dt=sdf.format(new Date()); - for(String stcd:list){ - Map data=new HashMap<>(); - String value = getRandomRedPacketBetweenMinAndMax(new BigDecimal("0"), new BigDecimal("20")).toString(); - data.put("stcd",stcd); - data.put("dt",dt); - data.put("inflow",value); - datas.add(data); - } - return datas; - } - - - @Async - public void simulationMultipleV4(String stationId, Long sleepTime){ - String sid=getSid(stationId); - List list = getDeviceListByStationId(stationId); - //查询所有属性 - List fieldList = deviceFieldService.list(); - List gapList = deviceFieldGapService.list(); - - log.info("本站{}有{}个设备实例,每{}毫秒发送{}条数据", stationId, list.size(), sleepTime, list.size()); - while (true) { - if (flag) {//启动或关闭模拟 - for (Device device : list) { - Map map = simulationV4(stationId,sid, device,fieldList,gapList); - //log.info("map data: "+ JsonUtil.toJson(map)); - if (map.get("yc") != null && map.get("yc").getChildren().size() > 0) { - mqttSender.sendToMqtt("hzinfo_v4_yc", JsonUtil.toJson(map.get("yc"))); - } -// if (map.get("dd") != null && map.get("dd").getChildren().size() > 0) { -// mqttSender.sendToMqtt(TopicConstant.TOPIC_HZINFO_DD, JsonUtil.toJson(map.get("dd"))); -// } - if (map.get("yx") != null && map.get("yx").getChildren().size() > 0) { - mqttSender.sendToMqtt("hzinfo_v4_yx", JsonUtil.toJson(map.get("yx"))); - } - } - //最小10毫秒 - if (sleepTime == null || sleepTime == 0) { - sleepTime = 10L; - } - ThreadUtil.sleep(sleepTime); - } - } - } - - public static BigDecimal getRandomRedPacketBetweenMinAndMax(BigDecimal min, BigDecimal max){ - float minF = min.floatValue(); - float maxF = max.floatValue(); - //生成随机数 - BigDecimal db = new BigDecimal(Math.random() * (maxF - minF) + minF); - //返回保留两位小数的随机数。不进行四舍五入 - return db.setScale(3,BigDecimal.ROUND_DOWN); - } - - public static int getIntBetweenMinAndMax(int min, int max){ - //生成随机数 - int randomNum = min + (int)(Math.random() * ((max - min) + 1)); - //返回保留两位小数的随机数。不进行四舍五入 - return randomNum; - } - - /** - * 模拟一条数据 - */ - private Map simulation(String stationId, Device device,List fieldListAll,List gapListAll) { -// List fieldList = getListByDeviceId(device.getId()); -// List gapList = getListByDeviceGapId(device.getId()); - List fieldList =fieldListAll.stream().filter(e->e.getFacDeviceId().equals(device.getId())).collect(Collectors.toList()); - List gapList =gapListAll.stream().filter(e->e.getFacDeviceId().equals(device.getId())).collect(Collectors.toList()); -// log.info("fieldList data: "+ JsonUtil.toJson(fieldList)); -// log.info("gapList data: "+ JsonUtil.toJson(gapList)); - List ycList = Lists.newArrayList(); - List yxList = Lists.newArrayList(); - //List ddList = Lists.newArrayList(); - for (DeviceField field : fieldList) { - Optional gapOpt=gapList.stream().filter(e->e.getSignage().equals(field.getSignage())).findFirst(); - - if (DataConstants.DeviceDataType.YC.ordinal()== field.getModelClassifyId().intValue()) { - if(gapOpt!=null) { - DeviceFieldGap gap=gapOpt.get(); - String value = getRandomRedPacketBetweenMinAndMax(gap.getMinVal(), gap.getMaxVal()).toString(); - Kvtq kvtq = Kvtq.builder().k(field.getSignage()).v(value).t(DateTimeUtil.format(LocalDateTime.now(), "yyyy-MM-dd HH:mm:ss.SSS")).q(0).build(); - ycList.add(kvtq); - } - } -// if (DataConstants.DeviceDataType.DD.name().equals(field.getType())) { -// String value = Func.random(1, RandomType.INT) + "." + Func.random(1, RandomType.INT); -// Kvtq kvtq = Kvtq.builder().k(field.getId()).v(value).t(DateTimeUtil.format(LocalDateTime.now(), "yyyy-MM-dd HH:mm:ss.SSS")).q(0).build(); -// ddList.add(kvtq); -// } - if (DataConstants.DeviceDataType.YX.ordinal()== field.getModelClassifyId().intValue()) { - if(gapOpt!=null) { - DeviceFieldGap gap=gapOpt.get(); - int value = getIntBetweenMinAndMax(gap.getMinVal().intValue(), gap.getMaxVal().intValue()); - Kvtq kvtq = Kvtq.builder().k(field.getSignage()).v(String.valueOf(value)).t(DateTimeUtil.format(LocalDateTime.now(), "yyyy-MM-dd HH:mm:ss.SSS")).q(0).build(); - yxList.add(kvtq); - } - } - } - Map map = Maps.newHashMap(); - if (ycList.size() > 0) { - map.put("yc", DeviceData.builder().station(stationId).time(DateTimeUtil.format(LocalDateTime.now(), "yyyy-MM-dd HH:mm:ss.SSS")).children(ycList).build()); - } -// if (ddList.size() > 0) { -// map.put("dd", DeviceData.builder().station(stationId).time(DateTimeUtil.format(LocalDateTime.now(), "yyyy-MM-dd HH:mm:ss.SSS")).children(ddList).build()); -// } - if (yxList.size() > 0) { - map.put("yx", DeviceData.builder().station(stationId).time(DateTimeUtil.format(LocalDateTime.now(), "yyyy-MM-dd HH:mm:ss.SSS")).children(yxList).build()); - } - return map; - } - - - private Map simulationV4(String stationId,String sid, Device device,List fieldListAll,List gapListAll) { - -// List fieldList = getListByDeviceId(device.getId()); -// List gapList = getListByDeviceGapId(device.getId()); - List fieldList =fieldListAll.stream().filter(e->e.getFacDeviceId().equals(device.getId())).collect(Collectors.toList()); - List gapList =gapListAll.stream().filter(e->e.getFacDeviceId().equals(device.getId())).collect(Collectors.toList()); -// log.info("fieldList data: "+ JsonUtil.toJson(fieldList)); -// log.info("gapList data: "+ JsonUtil.toJson(gapList)); - List ycList = Lists.newArrayList(); - List yxList = Lists.newArrayList(); - //List ddList = Lists.newArrayList(); - for (DeviceField field : fieldList) { - Optional gapOpt=gapList.stream().filter(e->e.getSignage().equals(field.getSignage())).findFirst(); - - if (DataConstants.DeviceDataType.YC.ordinal()== field.getModelClassifyId().intValue()) { - if(gapOpt!=null) { - DeviceFieldGap gap=gapOpt.get(); - String value = getRandomRedPacketBetweenMinAndMax(gap.getMinVal(), gap.getMaxVal()).toString(); - KvtqV4 kvtq = KvtqV4.builder().sid(sid).k(field.getSignage()).v(value).t(DateTimeUtil.format(LocalDateTime.now(), "yyyy-MM-dd HH:mm:ss.SSS")).q(0).build(); - ycList.add(kvtq); - } - } -// if (DataConstants.DeviceDataType.DD.name().equals(field.getType())) { -// String value = Func.random(1, RandomType.INT) + "." + Func.random(1, RandomType.INT); -// Kvtq kvtq = Kvtq.builder().k(field.getId()).v(value).t(DateTimeUtil.format(LocalDateTime.now(), "yyyy-MM-dd HH:mm:ss.SSS")).q(0).build(); -// ddList.add(kvtq); -// } - if (DataConstants.DeviceDataType.YX.ordinal()== field.getModelClassifyId().intValue()) { - if(gapOpt!=null) { - DeviceFieldGap gap=gapOpt.get(); - int value = getIntBetweenMinAndMax(gap.getMinVal().intValue(), gap.getMaxVal().intValue()); - KvtqV4 kvtq = KvtqV4.builder().sid(sid).k(field.getSignage()).v(String.valueOf(value)).t(DateTimeUtil.format(LocalDateTime.now(), "yyyy-MM-dd HH:mm:ss.SSS")).q(0).build(); - yxList.add(kvtq); - } - } - } - Map map = Maps.newHashMap(); - if (ycList.size() > 0) { - map.put("yc", DeviceDataV4.builder().stationId(stationId).time(DateTimeUtil.format(LocalDateTime.now(), "yyyy-MM-dd HH:mm:ss.SSS")).children(ycList).build()); - } -// if (ddList.size() > 0) { -// map.put("dd", DeviceData.builder().station(stationId).time(DateTimeUtil.format(LocalDateTime.now(), "yyyy-MM-dd HH:mm:ss.SSS")).children(ddList).build()); -// } - if (yxList.size() > 0) { - map.put("yx", DeviceDataV4.builder().stationId(stationId).time(DateTimeUtil.format(LocalDateTime.now(), "yyyy-MM-dd HH:mm:ss.SSS")).children(yxList).build()); - } - return map; - } - - private List getListByDeviceId(String deviceId) { - return deviceFieldService.list(Wrappers.lambdaQuery().ne(DeviceField::getModelClassifyId, DataConstants.DeviceDataType.SOE.name()).eq(DeviceField::getFacDeviceId, deviceId)); - } - - private List getListByDeviceGapId(String deviceId){ - return deviceFieldGapService.list(Wrappers.lambdaQuery().eq(DeviceFieldGap::getFacDeviceId, deviceId)); - } - -} diff --git a/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/service/WriteRealDataService.java b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/service/WriteRealDataService.java deleted file mode 100644 index ed500f3..0000000 --- a/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/service/WriteRealDataService.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.hnac.hzims.simulate.service; - -/** - * @author ysj - */ -public interface WriteRealDataService { - - void writeRealGateData(String param); - - void writeRealRainData(String param); - - Boolean isOpen(String deviceCode, Long isOpen); -} diff --git a/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/service/impl/WriteRealDataServiceImpl.java b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/service/impl/WriteRealDataServiceImpl.java deleted file mode 100644 index 4a49938..0000000 --- a/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/service/impl/WriteRealDataServiceImpl.java +++ /dev/null @@ -1,304 +0,0 @@ -package com.hnac.hzims.simulate.service.impl; - -import com.hnac.hzims.equipment.entity.EmInfoEntity; -import com.hnac.hzims.equipment.feign.IEmInfoClient; -import com.hnac.hzims.hzimsweather.feign.IHeWeatherWeatherClient; -import com.hnac.hzims.hzimsweather.response.weather.HeWeatherWeatherNowResponse; -import com.hnac.hzims.simulate.constants.WriteRealDataConstant; -import com.hnac.hzims.simulate.entity.*; -import com.hnac.hzims.simulate.mapper.DeviceFacConfigMapper; -import com.hnac.hzims.simulate.mapper.DeviceFieldGapMapper; -import com.hnac.hzims.simulate.mapper.DeviceFieldMapper; -import com.hnac.hzims.simulate.mapper.DeviceRainGapMapper; -import com.hnac.hzims.simulate.service.WriteRealDataService; -import com.hnac.hzims.simulate.util.DataConstants; -import com.hnac.hzims.simulate.util.TopicConstant; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springblade.core.tool.api.R; -import org.springblade.core.tool.jackson.JsonUtil; -import org.springblade.core.tool.utils.*; -import org.springblade.mqtt.producer.IMqttSender; -import org.springframework.stereotype.Service; - -import java.math.BigDecimal; -import java.text.DecimalFormat; -import java.time.LocalDateTime; -import java.util.Date; -import java.util.List; -import java.util.Optional; -import java.util.stream.Collectors; - -import static com.hnac.hzims.simulate.constants.WriteRealDataConstant.REAL_DATA_V3; -import static com.hnac.hzims.simulate.constants.WriteRealDataConstant.REAL_DATA_V4; - -/** - * @author ysj - */ -@Service -@Slf4j -@RequiredArgsConstructor -public class WriteRealDataServiceImpl implements WriteRealDataService { - - private final IEmInfoClient deviceClient; - - private final IHeWeatherWeatherClient weatherClient; - - private final IMqttSender mqttSender; - - private final DeviceFieldMapper fieldMapper; - - private final DeviceFieldGapMapper limitMapper; - - private final DeviceFacConfigMapper configMapper; - - private final DeviceRainGapMapper deviceRainGapMapper; - - /** - * 实时数据写入 - * @param param - */ - @Override - public void writeRealGateData(String param) { - // 查询设备配置 - List configs = configMapper.queryConfigDevice(WriteRealDataConstant.WRITE_GATE); - if(CollectionUtil.isEmpty(configs)){ - return; - } - //#.000 表示三位小数 - DecimalFormat df = new DecimalFormat("#0.000"); - // 遍历发送mqtt实时数据 - configs.stream().collect(Collectors.groupingBy(DeviceFacConfig::getModelKind)).forEach((modeKind,groups)->{ - // 查询设备属性 - List fields = fieldMapper.queryDeviceFields(groups.stream().map(DeviceFacConfig::getFacDeviceId).collect(Collectors.toList())); - if(CollectionUtil.isEmpty(fields)){ - return; - } - // 查询设备限制 - List limits = limitMapper.queryDeviceLimits(fields.stream().map(DeviceField::getSignage).collect(Collectors.toList())); - if(CollectionUtil.isEmpty(limits)){ - return; - } - // v3 - if(REAL_DATA_V3.equals(modeKind)){ - fields.stream().collect(Collectors.groupingBy(DeviceField::getModelClassifyId)).forEach((key, models) -> models.stream().collect(Collectors.groupingBy(DeviceField::getProjectId)).forEach((projectId, value)-> { - // 遥测实时数据对象 - List ycs = value.stream().filter(o -> DataConstants.DeviceDataType.YC.ordinal() == o.getModelClassifyId()).map(field -> { - List limit = limits.stream().filter(e -> e.getSignage().equals(field.getSignage())).collect(Collectors.toList()); - if (CollectionUtil.isEmpty(limit)) { - return new Kvtq(); - } - Kvtq real = new Kvtq(); - double random = Math.random() * limit.get(0).getMaxVal().subtract(limit.get(0).getMinVal()).doubleValue() + limit.get(0).getMinVal().doubleValue(); - real.setK(field.getSignage()); - real.setV(df.format(random)); - real.setT(DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss.SSS")); - real.setQ(0); - return real; - }).filter(ObjectUtil::isNotEmpty).collect(Collectors.toList()); - if (CollectionUtil.isNotEmpty(ycs)) { - log.error("yc_real_data_v3 : {}", JsonUtil.toJson(DeviceData.builder().station(projectId).time(DateTimeUtil.format(LocalDateTime.now(), "yyyy-MM-dd HH:mm:ss.SSS")).children(ycs).build())); - mqttSender.sendToMqtt(TopicConstant.TOPIC_HZINFO_PROPS, JsonUtil.toJson(DeviceData.builder().station(projectId).time(DateTimeUtil.format(LocalDateTime.now(), "yyyy-MM-dd HH:mm:ss.SSS")).children(ycs).build())); - } - // 遥信实时数据对象 - List yxs = value.stream().filter(o -> DataConstants.DeviceDataType.YX.ordinal() == o.getModelClassifyId()).map(field -> { - List limit = limits.stream().filter(e -> e.getSignage().equals(field.getSignage())).collect(Collectors.toList()); - if (CollectionUtil.isEmpty(limit)) { - return new Kvtq(); - } - Kvtq real = new Kvtq(); - double random = limit.get(0).getMaxVal().subtract(limit.get(0).getMinVal()).doubleValue() + limit.get(0).getMinVal().doubleValue(); - real.setK(field.getSignage()); - real.setV(df.format(random)); - real.setT(DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss.SSS")); - real.setQ(0); - return real; - }).collect(Collectors.toList()); - if (CollectionUtil.isNotEmpty(yxs)) { - log.error("yx_real_data_v3 : {}", JsonUtil.toJson(DeviceData.builder().station(projectId).time(DateTimeUtil.format(LocalDateTime.now(), "yyyy-MM-dd HH:mm:ss.SSS")).children(yxs).build())); - mqttSender.sendToMqtt(TopicConstant.TOPIC_HZINFO_YX, JsonUtil.toJson(DeviceData.builder().station(projectId).time(DateTimeUtil.format(LocalDateTime.now(), "yyyy-MM-dd HH:mm:ss.SSS")).children(yxs).build())); - } - })); - } - // v4 - if(REAL_DATA_V4.equals(modeKind)){ - fields.stream().collect(Collectors.groupingBy(DeviceField::getModelClassifyId)).forEach((key, models) -> models.stream().collect(Collectors.groupingBy(DeviceField::getProjectId)).forEach((projectId, value)->{ - // 遥测实时数据对象 - List ycs = value.stream().filter(o -> DataConstants.DeviceDataType.YC.ordinal() == o.getModelClassifyId()).map(field -> { - List limit = limits.stream().filter(e -> e.getSignage().equals(field.getSignage())).collect(Collectors.toList()); - if (CollectionUtil.isEmpty(limit)) { - return new KvtqV4(); - } - // 查找sid - Optional sid = groups.stream().filter(group->field.getFacDeviceId().equals(group.getFacDeviceId())).findFirst(); - if(!sid.isPresent()){ - return new KvtqV4(); - } - KvtqV4 real = new KvtqV4(); - double random = Math.random() * limit.get(0).getMaxVal().subtract(limit.get(0).getMinVal()).doubleValue() + limit.get(0).getMinVal().doubleValue(); - real.setSid(sid.get().getSid()); - real.setK(field.getSignage()); - real.setV(df.format(random)); - real.setT(DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss.SSS")); - real.setQ(0); - return real; - }).filter(ObjectUtil::isNotEmpty).collect(Collectors.toList()); - if (CollectionUtil.isNotEmpty(ycs)) { - log.error("yc_real_data_v4 : {}",JsonUtil.toJson(DeviceDataV4.builder().stationId(projectId).time(DateTimeUtil.format(LocalDateTime.now(), "yyyy-MM-dd HH:mm:ss.SSS")).children(ycs).build())); - mqttSender.sendToMqtt(TopicConstant.TOPIC_HZINFO_V4_YC,JsonUtil.toJson(DeviceDataV4.builder().stationId(projectId).time(DateTimeUtil.format(LocalDateTime.now(), "yyyy-MM-dd HH:mm:ss.SSS")).children(ycs).build())); - } - // 遥信实时数据对象 - List yxs = value.stream().filter(o -> DataConstants.DeviceDataType.YX.ordinal() == o.getModelClassifyId()).map(field -> { - List limit = limits.stream().filter(e -> e.getSignage().equals(field.getSignage())).collect(Collectors.toList()); - if (CollectionUtil.isEmpty(limit)) { - return new KvtqV4(); - } - // 查找sid - Optional sid = groups.stream().filter(group->field.getFacDeviceId().equals(group.getFacDeviceId())).findFirst(); - if(!sid.isPresent()){ - return new KvtqV4(); - } - KvtqV4 real = new KvtqV4(); - double random = limit.get(0).getMaxVal().subtract(limit.get(0).getMinVal()).doubleValue() + limit.get(0).getMinVal().doubleValue(); - real.setSid(sid.get().getSid()); - real.setK(field.getSignage()); - real.setV(df.format(random)); - real.setT(DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss.SSS")); - real.setQ(0); - return real; - }).collect(Collectors.toList()); - if (CollectionUtil.isNotEmpty(yxs)) { - log.error("yx_real_data_v4 : {}",JsonUtil.toJson(DeviceDataV4.builder().stationId(projectId).time(DateTimeUtil.format(LocalDateTime.now(), "yyyy-MM-dd HH:mm:ss.SSS")).children(yxs).build())); - mqttSender.sendToMqtt(TopicConstant.TOPIC_HZINFO_V4_YX,JsonUtil.toJson(DeviceDataV4.builder().stationId(projectId).time(DateTimeUtil.format(LocalDateTime.now(), "yyyy-MM-dd HH:mm:ss.SSS")).children(yxs).build())); - } - })); - } - }); - } - - /** - * 雨量站实时数据写入 - * @param param - */ - @Override - public void writeRealRainData(String param) { - // 查询设备配置 - List configs = configMapper.queryConfigDevice(WriteRealDataConstant.WRITE_RAIN); - if(CollectionUtil.isEmpty(configs)){ - return; - } - R> devices = deviceClient.getEmInfoByEmCodes(configs.stream().map(DeviceFacConfig::getDeviceCode).collect(Collectors.toList())); - if(!devices.isSuccess() || CollectionUtil.isEmpty(devices.getData())){ - return; - } - devices.getData().forEach(device->{ - if(ObjectUtil.isEmpty(device.getLgtd()) || ObjectUtil.isEmpty(device.getLttd())){ - return; - } - // 查询设备经纬度 - String location = device.getLgtd() + "," + device.getLttd(); - R weather = weatherClient.getWeatherNowWithCache(location); - if(!weather.isSuccess() || ObjectUtil.isEmpty(weather.getData()) || ObjectUtil.isEmpty(weather.getData().getNow())){ - return; - } - Optional optional = configs.stream().filter(o->o.getDeviceCode().equals(device.getNumber())).findFirst(); - if(!optional.isPresent()){ - return; - } - List deviceRainGap = deviceRainGapMapper.RainGapByFacDeviceId(optional.get().getFacDeviceId()); - if(CollectionUtil.isEmpty(deviceRainGap)){ - return; - } - List yxs = deviceRainGap.stream().map(o->{ - KvtqV4 real = new KvtqV4(); - real.setSid(optional.get().getSid()); - real.setK(o.getSignage()); - real.setT(DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss.SSS")); - real.setQ(0); - if(WriteRealDataConstant.ATTR_RAIN.equals(o.getAttribute())){ - real.setV(weather.getData().getNow().getPrecip()); - }else if(WriteRealDataConstant.ATTR_WIND360.equals(o.getAttribute())){ - real.setV(weather.getData().getNow().getWind360()); - }else if(WriteRealDataConstant.ATTR_WIND_SCALE.equals(o.getAttribute())){ - real.setV(weather.getData().getNow().getWindScale()); - }else if(WriteRealDataConstant.ATTR_WIND_SPEED.equals(o.getAttribute())){ - real.setV(weather.getData().getNow().getWindSpeed()); - }else if(WriteRealDataConstant.ATTR_HUMIDITY.equals(o.getAttribute())){ - real.setV(weather.getData().getNow().getHumidity()); - }else if(WriteRealDataConstant.ATTR_PRESSURE.equals(o.getAttribute())){ - real.setV(weather.getData().getNow().getPressure()); - }else if(WriteRealDataConstant.ATTR_VIS.equals(o.getAttribute())){ - real.setV(weather.getData().getNow().getVis()); - }else if(WriteRealDataConstant.ATTR_CLOUD.equals(o.getAttribute())){ - real.setV(weather.getData().getNow().getCloud()); - }else if(WriteRealDataConstant.ATTR_DEW.equals(o.getAttribute())){ - real.setV(weather.getData().getNow().getDew()); - }else if(WriteRealDataConstant.ATTR_FEELS_LIKE.equals(o.getAttribute())){ - real.setV(weather.getData().getNow().getFeelsLike()); - }else if(WriteRealDataConstant.ATTR_TEMP.equals(o.getAttribute())){ - real.setV(weather.getData().getNow().getTemp()); - } - if(StringUtil.isEmpty(real.getV())){ - real.setV("0.0"); - } - return real; - }).collect(Collectors.toList()); - if (CollectionUtil.isNotEmpty(yxs)) { - log.error("yx_real_data_v4 : {}",JsonUtil.toJson(DeviceDataV4.builder().stationId(optional.get().getStationId()).time(DateTimeUtil.format(LocalDateTime.now(), "yyyy-MM-dd HH:mm:ss.SSS")).children(yxs).build())); - mqttSender.sendToMqtt(TopicConstant.TOPIC_HZINFO_V4_YX,JsonUtil.toJson(DeviceDataV4.builder().stationId(optional.get().getStationId()).time(DateTimeUtil.format(LocalDateTime.now(), "yyyy-MM-dd HH:mm:ss.SSS")).children(yxs).build())); - } - }); - } - - /** - * 开启/关闭闸门数据 - * @param deviceCode - * @param isOpen - * @return - */ - @Override - public Boolean isOpen(String deviceCode, Long isOpen) { - // 查询写入设备配置 - DeviceFacConfig config = configMapper.configByDeviceCode(deviceCode); - if(ObjectUtil.isEmpty(config)){ - return false; - } - // 查询设备属性 - List fields = fieldMapper.querySignages(config.getFacDeviceId()); - if(CollectionUtil.isEmpty(fields)){ - return false; - } - // 查询属性限制 - List limits = limitMapper.queryDeviceLimits(fields.stream().map(DeviceField::getSignage).collect(Collectors.toList())); - if(CollectionUtil.isEmpty(limits)){ - return false; - } - limits.forEach(limit->{ - Optional optional = fields.stream().filter(o->o.getSignage().equals(limit.getSignage())).findFirst(); - if(!optional.isPresent()){ - return; - } - String signage = optional.get().getName(); - if(WriteRealDataConstant.GATE_STATUS.equals(signage)){ - if(WriteRealDataConstant.OPEN.equals(isOpen)){ - limitMapper.updateLimitById(BigDecimal.ONE,BigDecimal.ZERO,limit.getId()); - }else{ - limitMapper.updateLimitById(BigDecimal.ZERO,BigDecimal.ZERO,limit.getId()); - } - }else if(WriteRealDataConstant.GATE_FLOW.equals(signage)){ - if(WriteRealDataConstant.OPEN.equals(isOpen)){ - limitMapper.updateLimitById(BigDecimal.valueOf(3560.000),BigDecimal.valueOf(0.000),limit.getId()); - }else{ - limitMapper.updateLimitById(BigDecimal.ZERO,BigDecimal.ZERO,limit.getId()); - } - }else if(WriteRealDataConstant.OPENING_DEGREE.equals(signage)){ - if(WriteRealDataConstant.OPEN.equals(isOpen)){ - limitMapper.updateLimitById(BigDecimal.valueOf(10),BigDecimal.valueOf(0.000),limit.getId()); - }else{ - limitMapper.updateLimitById(BigDecimal.ZERO,BigDecimal.ZERO,limit.getId()); - } - } - }); - return true; - } -} \ No newline at end of file diff --git a/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/util/DataConstants.java b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/util/DataConstants.java deleted file mode 100644 index a4873df..0000000 --- a/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/util/DataConstants.java +++ /dev/null @@ -1,357 +0,0 @@ -package com.hnac.hzims.simulate.util; - -public interface DataConstants { - String REDIS_MESSAGE_TOPIC = "hzinfo_config_message_topic"; - String TIME_COLUMN = "ts"; - String VALUE_COLUMN = "val"; - String Q_COLUMN = "q"; - String REAL_ID_COLUMN = "realid"; - String TBNAME = "tbname"; - String YC_TABLE_PREFIX = "yc_"; - String YX_TABLE_PREFIX = "yx_"; - String SOE_TABLE_PREFIX = "soe_"; - String SOE_ALARM_TABLE_PREFIX = "soe_alarm_"; - String YC = "YC"; - String YX = "YX"; - String SOE = "SOE"; - String YK_RETURN_PREFIX = "ykfj:"; - String REALID_CALCULATE = "16777215"; - String DEVICE_SUPER_TABLE_PREFIX = "hz_"; - String DEVICE_TABLE_PREFIX = "d_"; - - public static enum DataStructTypeEnum { - struct, - dataGroup; - - private DataStructTypeEnum() { - } - } - - public static enum EYkRetStatus { - yrsSuccess, - yrsServerErr, - yrsChannelErr, - yrsModuleErr, - yrsDeviceTimeOut, - yrsDeviceFail, - yrsExpired; - - private EYkRetStatus() { - } - } - - public static enum SoeType { - skNone(0, "0", "默认"), - skSys(1, "1", "系统"), - skAlarm(2, "2", "报警"), - skAct(3, "3", "事故"), - skOperate(4, "4", "用户操作"), - skYcOut(5, "5,11,12", "遥测越限"), - skYxChange(6, "6,10", "遥信变位"), - skReg(7, "7", "注册信息"), - skHint(8, "8", "信息提示"), - skInspect(9, "9", "设备巡检"), - skMonitorOperate(10, "13,14", "遥控操作"), - skRDSYcOutOfLimitResume(11, "15", "遥测越限恢复"), - skUndefine(12, "16,17,18", "未定义"), - skNetworkAnomaly(13, "-1", "通讯异常"), - skCommunicateAnomaly(14, "-2", "数据异常"); - - private Integer index; - private String soeKind; - private String name; - - private SoeType(Integer index, String soeKind, String name) { - this.index = index; - this.soeKind = soeKind; - this.name = name; - } - - public static String getName(Integer id) { - SoeType[] values = values(); - - for (int i = 0; i < values.length; ++i) { - if (values[i].index.equals(id)) { - return values[i].getName(); - } - } - - return null; - } - - public static Integer getIndexBySoeKind(String soeType) { - SoeType[] values = values(); - SoeType[] var2 = values; - int var3 = values.length; - - for (int var4 = 0; var4 < var3; ++var4) { - SoeType type = var2[var4]; - if (type.getSoeKind().contains(soeType)) { - return type.getIndex(); - } - } - - return skUndefine.getIndex(); - } - - public static String getSoeKindByIndex(Integer index) { - SoeType[] values = values(); - SoeType[] var2 = values; - int var3 = values.length; - - for (int var4 = 0; var4 < var3; ++var4) { - SoeType type = var2[var4]; - if (type.getIndex().equals(index)) { - return type.getSoeKind(); - } - } - - return ""; - } - - public Integer getIndex() { - return this.index; - } - - public String getSoeKind() { - return this.soeKind; - } - - public String getName() { - return this.name; - } - } - - public static enum SoeKind { - skNone(0, "默认"), - skSys(1, "系统"), - skAlarm(2, "报警"), - skAct(3, "事故"), - skOperate(4, "操作"), - skYcOut(5, "遥测越限(告警)"), - skYxChange(6, "遥信变位(告警)"), - skReg(7, "注册信息"), - skHint(8, "信息提示"), - skInspect(9, "设备巡检"), - skRDSYxChange(10, "遥信变位(数据)"), - skRDSYcOutOfLimit(11, "遥测越上/下限(数据)"), - skRDSYcOutOfLimit2(12, "遥测越上上/下下限(数据)"), - skMonitorOperate(13, "操作记录(遥控)"), - skMonitorOperateII(14, "操作记录(写定值)"), - skRDSYcOutOfLimitResume(15, "越限恢复"), - bak_7(16, "备用7"), - bak_8(17, "备用8"), - skUndefine(18, "未定义"); - - private Integer index; - private String name; - - private SoeKind(Integer index, String name) { - this.index = index; - this.name = name; - } - - public static String getName(Integer id) { - SoeKind[] values = values(); - - for (int i = 0; i < values.length; ++i) { - if (values[i].index.equals(id)) { - return values[i].getName(); - } - } - - return null; - } - - public Integer getIndex() { - return this.index; - } - - public String getName() { - return this.name; - } - } - - public static enum DeviceDataType { - YC("遥测"), - YX("遥信"), - DD("电渡"), - YK("遥控"), - YT("遥调"), - SOE("事件"), - STR("字符串"), - OTHER("其它"); - - private String displayName; - - private DeviceDataType(String displayName) { - this.displayName = displayName; - } - - public static String getDisplayName(String name) { - DeviceDataType type = valueOf(name); - return type.getDisplayName(); - } - - public String getDisplayName() { - return this.displayName; - } - } - - public static enum YkDelayType { - none_store, - store, - delay_store; - - private YkDelayType() { - } - } - - public static enum RedisGroupMessageTypeEnum { - NOTICE_CLEAN_LOCAL_CACHE_DEVICE("clean.local.cache.device"), - NOTICE_CLEAN_LOCAL_CACHE_DEVICE_GROUP("clean.local.cache.group"), - NOTICE_CLEAN_LOCAL_CACHE_ALARM("clean.local.cache.alarm"), - NOTICE_CLEAN_LOCAL_CACHE_YK("clean.local.cache.yk"); - - private String value; - - private RedisGroupMessageTypeEnum(String value) { - this.value = value; - } - - public String getValue() { - return this.value; - } - } - - public static enum DataStatusEnum { - offline, - online; - - private DataStatusEnum() { - } - } - - public static enum StatisticsType { - avg("AVG"), - max("MAX"), - min("MIN"); - - private String computeStrategy; - - private StatisticsType(String fun) { - this.computeStrategy = fun; - } - - public static StatisticsType getStatisticsType(int index) { - StatisticsType[] values = values(); - StatisticsType[] var2 = values; - int var3 = values.length; - - for (int var4 = 0; var4 < var3; ++var4) { - StatisticsType value = var2[var4]; - if (index == value.ordinal()) { - return value; - } - } - - return null; - } - - public String getComputeStrategy() { - return this.computeStrategy; - } - - public void setComputeStrategy(final String computeStrategy) { - this.computeStrategy = computeStrategy; - } - } - - public static enum AnalyzeInstanceAlarmConfType { - changeAlarm("变化告警"), - supassAlarm("越限告警"); - - private String name; - - private AnalyzeInstanceAlarmConfType(String name) { - this.name = name; - } - - public String getName() { - return this.name; - } - } - - public static enum StatisticsAnalyEnum { - Hour("h"), - Day("d"), - Month("n"), - Year("h"); - - private String type; - - private StatisticsAnalyEnum(String fun) { - this.type = fun; - } - - public static StatisticsAnalyEnum getStatisticsAnalyEnum(int index) { - StatisticsAnalyEnum[] values = values(); - StatisticsAnalyEnum[] var2 = values; - int var3 = values.length; - - for (int var4 = 0; var4 < var3; ++var4) { - StatisticsAnalyEnum value = var2[var4]; - if (value.ordinal() == index) { - return value; - } - } - - return null; - } - - public String getType() { - return this.type; - } - } - - public static enum StationFromSouceEnum { - cloud, - station; - - private StationFromSouceEnum() { - } - } - - public static enum AnalyzeInstanceDataResoureEnum { - deviceUp("设备上报"), - hz3000Up("华自网关上报"); - - private String name; - - private AnalyzeInstanceDataResoureEnum(String name) { - this.name = name; - } - - public String getName() { - return this.name; - } - } - - public static enum ThresholdLevelEnum { - one, - two, - three; - - private ThresholdLevelEnum() { - } - } - - public static enum Hz3000VersionEnum { - v3, - v4; - - private Hz3000VersionEnum() { - } - } - -} diff --git a/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/util/ParseFacUtils.java b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/util/ParseFacUtils.java deleted file mode 100644 index 34d7437..0000000 --- a/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/util/ParseFacUtils.java +++ /dev/null @@ -1,105 +0,0 @@ -package com.hnac.hzims.simulate.util; - -import com.fasterxml.jackson.core.JsonProcessingException; -import com.google.common.collect.Lists; -import com.hnac.hzims.simulate.entity.DataItem; -import com.hnac.hzims.simulate.entity.DataModel; -import org.dom4j.Document; -import org.dom4j.DocumentException; -import org.dom4j.Element; -import org.dom4j.io.SAXReader; -import org.xml.sax.SAXException; - -import java.io.InputStream; -import java.math.BigInteger; -import java.util.List; - -/** - * 解析厂信息工具类 - * @author ninglong - */ -public class ParseFacUtils { - - public static List parsePoint(InputStream inputStream) throws SAXException, DocumentException, JsonProcessingException { - SAXReader saxReader = new SAXReader(); - Document document = saxReader.read(inputStream); - List groupElements = document.selectNodes("/Factorys/Factory/Group"); - List list = parseDataGroup(groupElements); - List ycElements = document.selectNodes("/Factorys/Factory/Group/AIS/AI"); - list = pastePointElement(ycElements, DataConstants.DeviceDataType.YC.name(),list); - - List yxElements = document.selectNodes("/Factorys/Factory/Group/DIS/DI"); - list = pastePointElement(yxElements, DataConstants.DeviceDataType.YX.name(),list); - - List ddElements = document.selectNodes("/Factorys/Factory/Group/DDS/DD"); - list = pastePointElement(ddElements, DataConstants.DeviceDataType.DD.name(),list); - - List soeElements = document.selectNodes("/Factorys/Factory/Group/SOES/SOE"); - list = pastePointElement(soeElements, DataConstants.DeviceDataType.SOE.name(),list); - - List ykElements = document.selectNodes("/Factorys/Factory/Group/DOS/DO"); - list = pastePointElement(ykElements, DataConstants.DeviceDataType.YK.name(),list); - return list; - } - - /** - * 解析数据组 - */ - private static List parseDataGroup(List elements){ - List list = Lists.newArrayList(); - for (Element element : (List) elements) { - DataModel model = new DataModel(); - model.setStructType(DataConstants.DataStructTypeEnum.dataGroup.name()); - model.setId(element.attribute("ID").getValue()); - model.setSignage(bigId2SmallId(element.attribute("ID").getValue())); - model.setName(element.attribute("Name").getValue()); - String stationNumStr = element.getParent().attribute("StationNum").getValue(); - model.setStation(stationNumStr); - list.add(model); - } - return list; - } - - /** - * 将大id转换成小id - */ - public static String bigId2SmallId(String realId){ - BigInteger bigRealId = new BigInteger(realId); - return bigRealId.and(new BigInteger(DataConstants.REALID_CALCULATE)).toString(); - } - /** - * 解析数据点 - */ - private static List pastePointElement(List elements, String type, List list) throws JsonProcessingException { - for (Element element : (List) elements) { - String groupId = element.getParent().getParent().attribute("ID").getValue(); - for(DataModel dm:list){ - if(!groupId.equals(dm.getId())){ - continue; - } - DataItem dataItem = DataItem.builder() - .id(element.attribute("ID").getValue()) - .signage(bigId2SmallId(element.attribute("ID").getValue())) - .name(element.attribute("Name").getValue()) - .type(type) - .build(); - if(DataConstants.DeviceDataType.SOE.name().equals(type)){ - dataItem.setEventType(element.attribute("SOEAlarmType").getValue()); - dataItem.setSoeType(element.attribute("SOEType").getValue()); - } - if(DataConstants.DeviceDataType.YX.name().equals(type)){ - dataItem.setEventType(element.attribute("YXAlarmType").getValue()); - dataItem.setSoeType(element.attribute("SOEType").getValue()); - } - List childrens = dm.getChildren(); - if(childrens==null){ - childrens = Lists.newArrayList(); - } - childrens.add(dataItem); - dm.setChildren(childrens); - } - } - return list; - } -} - diff --git a/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/util/RealIdConvertUtils.java b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/util/RealIdConvertUtils.java deleted file mode 100644 index f5d3282..0000000 --- a/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/util/RealIdConvertUtils.java +++ /dev/null @@ -1,52 +0,0 @@ -package com.hnac.hzims.simulate.util; - - -import java.math.BigInteger; - -public class RealIdConvertUtils { - - private void demo() { - BigInteger ss = new BigInteger("16777215"); - BigInteger s = new BigInteger("15122982502953650999"); - BigInteger stationId = s.shiftRight(24); - System.out.println(stationId.toString()); - BigInteger realId = s.and(ss); - System.out.println(realId.toString()); - - BigInteger xxx = stationId.shiftLeft(24); - BigInteger yyy = xxx.or(realId); - System.out.println(s.toString()); - System.out.println(yyy.toString()); - } - - /** - * 将大id转换成小id - */ - public static String bigId2SmallId(String realId) { - BigInteger bigRealId = new BigInteger(realId); - return bigRealId.and(new BigInteger(DataConstants.REALID_CALCULATE)).toString(); - } - - /** - * 将小id转换成大id - */ - public static String smallId2BigId(String station, String realId) { - BigInteger stationId = new BigInteger(station); - BigInteger BigRealId = stationId.shiftLeft(24).or(new BigInteger(realId)); - return BigRealId.toString(); - } - -// public static void main(String[] args) { -// System.out.println(RealIdConvertUtils.getStationId("262952509021093892")); -// System.out.println(RealIdConvertUtils.bigId2SmallId("262952509021093892")); -// System.out.println(smallId2BigId("15673190893", "32")); -// } - - /** - * 获取站点id - */ - public static String getStationId(String realId) { - BigInteger bigRealId = new BigInteger(realId); - return bigRealId.shiftRight(24).toString(); - } -} diff --git a/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/util/TopicConstant.java b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/util/TopicConstant.java deleted file mode 100644 index 1d4a8ca..0000000 --- a/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/util/TopicConstant.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.hnac.hzims.simulate.util; - -public interface TopicConstant { - String TOPIC_DEVICE_MODEL = "topic_device_model"; - String TOPIC_HZINFO_PROPS = "topic_hzinfo_props"; - String TOPIC_HZINFO_V4_YC = "hzinfo_v4_yc"; - - String TOPIC_HZINFO_V4_YX = "hzinfo_v4_yx"; - - String TOPIC_HZINFO_YX = "topic_hzinfo_yx"; - String TOPIC_HZINFO_DD = "topic_hzinfo_dd"; - String TOPIC_HZINFO_EVENTS = "topic_hzinfo_events"; - String TOPIC_HZINFO_EVENTS_ALARM = "topic_hzinfo_events_alarm"; - String TOPIC_HZINFO_CONTROL_RETURN = "topic_hzinfo_control_return"; - String TOPIC_HZINFO_HEART_BEAT = "topic_hzinfo_heart_beat"; - String TOPIC_HZINFO_BROADCAST = "topic_hzinfo_broadcast"; - String TOPIC_HZINFO_DATA = "topic_hzinfo_data"; -} diff --git a/hzims-service/hzims-simulate/src/main/resources/application-dev.yml b/hzims-service/hzims-simulate/src/main/resources/application-dev.yml deleted file mode 100644 index 0abb9d3..0000000 --- a/hzims-service/hzims-simulate/src/main/resources/application-dev.yml +++ /dev/null @@ -1,13 +0,0 @@ -#服务器端口 -server: - port: 8211 - -#数据源配置 -spring: - datasource: - url: ${blade.datasource.dev.url} - username: ${blade.datasource.dev.username} - password: ${blade.datasource.dev.password} - cloud: - inetutils: - preferred-networks: 192.168.65 diff --git a/hzims-service/hzims-simulate/src/main/resources/application-prod.yml b/hzims-service/hzims-simulate/src/main/resources/application-prod.yml deleted file mode 100644 index a96da50..0000000 --- a/hzims-service/hzims-simulate/src/main/resources/application-prod.yml +++ /dev/null @@ -1,6 +0,0 @@ -#数据源配置 -spring: - datasource: - url: ${blade.datasource.prod.url} - username: ${blade.datasource.prod.username} - password: ${blade.datasource.prod.password} \ No newline at end of file diff --git a/hzims-service/hzims-simulate/src/main/resources/application.yml b/hzims-service/hzims-simulate/src/main/resources/application.yml deleted file mode 100644 index 61e8ff7..0000000 --- a/hzims-service/hzims-simulate/src/main/resources/application.yml +++ /dev/null @@ -1,15 +0,0 @@ -spring: - application: - name: lewa-simulate - -#mybatis-plus配置 -mybatis-plus: - mapper-locations: classpath:org/springbalde/**/mapper/*Mapper.xml,classpath:com/hnac/hzinfo/**/mapper/*Mapper.xml - #实体扫描,多个package用逗号或者分号分隔 - typeAliasesPackage: org.springbalde.**.entity,com.hnac.hzinfo.**.entity - -#swagger扫描路径配置 -swagger: - base-packages: - - org.springbalde - - com.hnac.hzinfo \ No newline at end of file diff --git a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/obj/mapper/ProjectMapper.java b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/obj/mapper/ProjectMapper.java index 0577c22..7c23c44 100644 --- a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/obj/mapper/ProjectMapper.java +++ b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/obj/mapper/ProjectMapper.java @@ -4,6 +4,8 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.hnac.hzinfo.inspect.obj.entity.ProjectEntity; import com.hnac.hzinfo.inspect.obj.vo.ProjectOfflineVO; import org.apache.ibatis.annotations.Mapper; +import org.springblade.core.datascope.annotation.UserDataAuth; +import org.springblade.core.datascope.mapper.UserDataScopeBaseMapper; import java.util.List; @@ -11,7 +13,8 @@ import java.util.List; * 巡检项目 */ @Mapper -public interface ProjectMapper extends BaseMapper { +public interface ProjectMapper extends UserDataScopeBaseMapper { + @UserDataAuth List getProjectData(String tenantId); } diff --git a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/obj/web/ProjectController.java b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/obj/web/ProjectController.java index 1db0920..929d432 100644 --- a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/obj/web/ProjectController.java +++ b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/obj/web/ProjectController.java @@ -20,10 +20,10 @@ import com.hnac.hzinfo.inspect.obj.services.impl.ProjectContentServiceImpl; import com.hnac.hzinfo.inspect.obj.utils.CodeUtils; import com.hnac.hzinfo.inspect.obj.vo.ProjectListQueryVO; import com.hnac.hzinfo.inspect.obj.vo.ProjectVO; -import com.hnac.hzinfo.inspect.utils.Condition; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; +import org.springblade.core.mp.support.Condition; import org.springblade.core.mp.support.Query; import org.springblade.core.secure.utils.AuthUtil; import org.springblade.core.tool.api.R; @@ -192,7 +192,7 @@ public class ProjectController { @ApiOperation(value = "获取巡检项目下的机构") @ApiOperationSupport(order = 9) public R getProjectDept() { - QueryWrapper queryWrapper = Wrappers.query().select("distinct create_dept deptId"); + QueryWrapper queryWrapper = Wrappers.query().select("distinct create_dept"); List deptIdList = projectService.listObjs(queryWrapper, Func::toLong); List result = deptIdList.stream().map(deptId -> new HashMap() {{ put("deptId", deptId); diff --git a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/offline/service/impl/InspectOfflineServiceImpl.java b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/offline/service/impl/InspectOfflineServiceImpl.java index a5f042b..e33d189 100644 --- a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/offline/service/impl/InspectOfflineServiceImpl.java +++ b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/offline/service/impl/InspectOfflineServiceImpl.java @@ -965,8 +965,7 @@ public class InspectOfflineServiceImpl implements IOfflineDataService { private MultipartFile getMultipartFile(File file) { FileItem fileItem = this.createFileItem(file); - MultipartFile mfile = new CommonsMultipartFile(fileItem); - return mfile; + return new CommonsMultipartFile(fileItem); } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/service/impl/TargetServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/service/impl/TargetServiceImpl.java index 8bae428..0d34e55 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/service/impl/TargetServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/service/impl/TargetServiceImpl.java @@ -53,7 +53,6 @@ import org.springframework.beans.factory.annotation.Value; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.stereotype.Service; import org.springframework.util.CollectionUtils; -import org.springframework.util.StringUtils; import java.math.BigDecimal; import java.math.RoundingMode; @@ -142,7 +141,7 @@ public class TargetServiceImpl implements TargetService { LambdaQueryWrapper wappers = Wrappers.lambdaQuery(); wappers.eq(StationEntity::getType, type); //wappers.eq(StationEntity::getServeType,2); - if(!StringUtils.isEmpty(stationName)){ + if(!StringUtil.isBlank(stationName)){ wappers.like(StationEntity::getName,stationName); } List stations = stationService.list(wappers); @@ -183,7 +182,7 @@ public class TargetServiceImpl implements TargetService { LambdaQueryWrapper wappers = Wrappers.lambdaQuery(); wappers.eq(StationEntity::getType, type); //wappers.eq(StationEntity::getServeType,2); - if(!StringUtils.isEmpty(stationName)){ + if(!StringUtil.isBlank(stationName)){ wappers.like(StationEntity::getName,stationName); } List stations = stationService.list(wappers); @@ -217,7 +216,7 @@ public class TargetServiceImpl implements TargetService { }).filter(generate->Math.abs(generate.getElectricGeneration()) > 0).collect(Collectors.toList()); }else if(HomePageConstant.PHOTOVOLTAIC.equals(type)) { List targets = (List) redisTemplate.opsForValue().get(load_photovoltaic_target_key); - if (CollectionUtil.isEmpty(targets)) { + if (CollectionUtils.isEmpty(targets)) { return page; } electrics = stations.stream().map(station -> { @@ -273,7 +272,7 @@ public class TargetServiceImpl implements TargetService { LambdaQueryWrapper wappers = Wrappers.lambdaQuery(); wappers.eq(StationEntity::getType, type); //wappers.eq(StationEntity::getServeType,2); - if(!StringUtils.isEmpty(stationName)){ + if(!StringUtil.isBlank(stationName)){ wappers.like(StationEntity::getName,stationName); } List stations = stationService.list(wappers); @@ -374,7 +373,7 @@ public class TargetServiceImpl implements TargetService { generations = stations.stream().map(station -> { CompleteGenerationVo item = new CompleteGenerationVo(); item.setStationName(station.getName()); - if(CollectionUtil.isEmpty(plans)){ + if(CollectionUtils.isEmpty(plans)){ item.setPlanGeneration(0.0); }else{ item.setPlanGeneration(plans.stream().filter(plan->plan.getStationId().equals(station.getCode())).mapToDouble(PlanGenerationEntity::getPlanGeneration).sum()); @@ -425,7 +424,7 @@ public class TargetServiceImpl implements TargetService { CountDownLatch countDownLatch = new CountDownLatch(areas.size()); List completes = new ArrayList<>(); exe.execute(()-> { - if(!StringUtil.isEmpty(areaName)){ + if(!StringUtil.isBlank(areaName)){ for (Dept dept: areas.stream().filter(area->area.getDeptName().equals(areaName)).collect(Collectors.toList())) { // 双票 TicketStatisticDTO ticketStatisticDTO=new TicketStatisticDTO(); @@ -496,16 +495,16 @@ public class TargetServiceImpl implements TargetService { .eq(StationEntity::getServeType,HomePageConstant.HYDROPOWER_SERVETYPE) .in(StationEntity::getType,types) ); - if(CollectionUtil.isEmpty(stations)){ + if(CollectionUtils.isEmpty(stations)){ return new ArrayList<>(); } R> result = sysClient.getDeptByCurrentUser(); - if(!result.isSuccess() || CollectionUtil.isEmpty(result.getData())){ + if(!result.isSuccess() || CollectionUtils.isEmpty(result.getData())){ return new ArrayList<>(); } // 站点父级区域 List parents = result.getData().stream().filter(dept->stations.stream().map(StationEntity::getRefDept).collect(Collectors.toList()).contains(dept.getId())).map(Dept::getParentId).distinct().collect(Collectors.toList()); - if(CollectionUtil.isEmpty(parents)){ + if(CollectionUtils.isEmpty(parents)){ return new ArrayList<>(); } return result.getData().stream().filter(dept->parents.contains(dept.getId()) && HomePageConstant.AREA.equals(dept.getDeptCategory())).collect(Collectors.toList()); @@ -537,7 +536,7 @@ public class TargetServiceImpl implements TargetService { item.setTicketCount("*"); item.setCompleteCount("*"); List stationPower = powers.stream().filter(power->power.getCreateDept().equals(station.getRefDept())).collect(Collectors.toList()); - if(CollectionUtil.isEmpty(stationPower)){ + if(CollectionUtils.isEmpty(stationPower)){ item.setCompleteRate("0.0"); }else{ double rate = stationPower.stream().mapToDouble(o->Double.parseDouble(o.getDoubleQualifyRate())).sum(); @@ -565,7 +564,7 @@ public class TargetServiceImpl implements TargetService { if(MapUtils.isEmpty(areas)){ return page; } - List depts = areas.keySet().stream().filter(dept -> StringUtils.isEmpty(areaName) || dept.getDeptName().contains(areaName)).collect(Collectors.toList()); + List depts = areas.keySet().stream().filter(dept -> StringUtil.isBlank(areaName) || dept.getDeptName().contains(areaName)).collect(Collectors.toList()); if(CollectionUtils.isEmpty(depts)){ return page; } @@ -619,7 +618,7 @@ public class TargetServiceImpl implements TargetService { LambdaQueryWrapper wappers = Wrappers.lambdaQuery(); wappers.eq(StationEntity::getType, type); wappers.eq(StationEntity::getServeType,2); - if(!StringUtils.isEmpty(stationName)){ + if(!StringUtil.isBlank(stationName)){ wappers.like(StationEntity::getName,stationName); } List stations = stationService.list(wappers); @@ -666,7 +665,7 @@ public class TargetServiceImpl implements TargetService { LambdaQueryWrapper wappers = Wrappers.lambdaQuery(); wappers.eq(StationEntity::getType, type); wappers.eq(StationEntity::getServeType,HomePageConstant.HYDROPOWER_SERVETYPE); - if(!StringUtils.isEmpty(stationName)){ + if(!StringUtil.isBlank(stationName)){ wappers.like(StationEntity::getName,stationName); } List stations = stationService.list(wappers); @@ -710,7 +709,7 @@ public class TargetServiceImpl implements TargetService { LambdaQueryWrapper wappers = Wrappers.lambdaQuery(); wappers.eq(StationEntity::getType, type); wappers.eq(StationEntity::getServeType,HomePageConstant.HYDROPOWER_SERVETYPE); - if(!StringUtils.isEmpty(areaName)){ + if(!StringUtil.isBlank(areaName)){ wappers.like(StationEntity::getName,areaName); } List stations = stationService.list(wappers); @@ -775,7 +774,7 @@ public class TargetServiceImpl implements TargetService { public R> examineRepair(OperAccessTaskDTO params, Query query, Integer type) { // 获取区域机构 Map> areas = areaService.getAuthArea(null,null,Collections.singletonList(type),HomePageConstant.HYDROPOWER_SERVETYPE,true); - if(MapUtils.isEmpty(areas)){ + if(ObjectUtil.isEmpty(areas)){ return null; } // 查询检修任务 @@ -806,7 +805,7 @@ public class TargetServiceImpl implements TargetService { if(CollectionUtils.isEmpty(stations)){ return page; } - List detpIds = stations.stream().filter(o-> StringUtils.isEmpty(stationName) || o.getName().contains(stationName)).map(StationEntity::getRefDept).collect(Collectors.toList()); + List detpIds = stations.stream().filter(o-> StringUtil.isBlank(stationName) || o.getName().contains(stationName)).map(StationEntity::getRefDept).collect(Collectors.toList()); if(CollectionUtils.isEmpty(detpIds)){ return page; } @@ -830,7 +829,7 @@ public class TargetServiceImpl implements TargetService { deviceClassify.setDeviceStatus(2); } return deviceClassify; - }).filter(deviceClass -> StringUtils.isEmpty(stationName) || deviceClass.getStationName().contains(stationName)).collect(Collectors.toList()); + }).filter(deviceClass -> StringUtil.isBlank(stationName) || deviceClass.getStationName().contains(stationName)).collect(Collectors.toList()); List records; // 状态过滤 if(ObjectUtil.isEmpty(status)){ @@ -855,7 +854,7 @@ public class TargetServiceImpl implements TargetService { LambdaQueryWrapper wappers = Wrappers.lambdaQuery(); wappers.eq(StationEntity::getType, HomePageConstant.HYDROPOWER); wappers.eq(StationEntity::getServeType,HomePageConstant.HYDROPOWER_SERVETYPE); - if(!StringUtil.isEmpty(stationName)){ + if(!StringUtil.isBlank(stationName)){ wappers.like(StationEntity::getName,stationName); } if(ObjectUtil.isNotEmpty(deptId)){ @@ -872,7 +871,7 @@ public class TargetServiceImpl implements TargetService { List records = stations.stream().map(station->{ HydropowerTargetVo hydropower = new HydropowerTargetVo(); hydropower.setStationName(station.getName()); - if(CollectionUtil.isEmpty(reals)){ + if(CollectionUtils.isEmpty(reals)){ hydropower.setPower(0.0); }else{ hydropower.setPower(reals.stream().filter(real->real.getDeptId().equals(station.getRefDept())).mapToDouble(real->{ @@ -930,7 +929,7 @@ public class TargetServiceImpl implements TargetService { LambdaQueryWrapper wappers = Wrappers.lambdaQuery(); wappers.in(StationEntity::getType, HomePageConstant.waterList); wappers.eq(StationEntity::getServeType,2); - if(!StringUtils.isEmpty(stationName)){ + if(!StringUtil.isBlank(stationName)){ wappers.like(StationEntity::getName,stationName); } if(!ObjectUtil.isEmpty(deptId)){ @@ -947,7 +946,7 @@ public class TargetServiceImpl implements TargetService { List records = stations.stream().map(station->{ WaterTargetVo water = new WaterTargetVo(); water.setStationName(station.getName()); - if(CollectionUtil.isEmpty(pumps)){ + if(CollectionUtils.isEmpty(pumps)){ water.setLoad(0.0); return water; } @@ -964,7 +963,7 @@ public class TargetServiceImpl implements TargetService { List records = stations.stream().map(station->{ WaterTargetVo water = new WaterTargetVo(); water.setStationName(station.getName()); - if(CollectionUtil.isEmpty(targets)){ + if(CollectionUtils.isEmpty(targets)){ water.setUse(0.0); return water; } @@ -994,7 +993,7 @@ public class TargetServiceImpl implements TargetService { LambdaQueryWrapper wappers = Wrappers.lambdaQuery(); wappers.eq(StationEntity::getType, HomePageConstant.PHOTOVOLTAIC); wappers.eq(StationEntity::getServeType,2); - if(!StringUtils.isEmpty(stationName)){ + if(!StringUtil.isBlank(stationName)){ wappers.like(StationEntity::getName,stationName); } if(!ObjectUtil.isEmpty(deptId)){ @@ -1012,7 +1011,7 @@ public class TargetServiceImpl implements TargetService { List records = stations.stream().map(station->{ PhotovoTargetVo photovo = new PhotovoTargetVo(); photovo.setStationName(station.getName()); - if(CollectionUtil.isEmpty(reals)){ + if(CollectionUtils.isEmpty(reals)){ photovo.setLoad(0.0); }else{ photovo.setLoad(reals.stream().filter(o->o.getDeptId().equals(station.getRefDept())).mapToDouble(PhotovoltaicRealVo::getLoad).sum()); @@ -1028,7 +1027,7 @@ public class TargetServiceImpl implements TargetService { List records = stations.stream().map(station->{ PhotovoTargetVo photovo = new PhotovoTargetVo(); photovo.setStationName(station.getName()); - if(CollectionUtil.isEmpty(targets)){ + if(CollectionUtils.isEmpty(targets)){ photovo.setGenerate(0.0); }else{ switch (target){ @@ -1067,12 +1066,12 @@ public class TargetServiceImpl implements TargetService { } // redis中取区域数据 List areaDutyVoList = (List) redisTemplate.opsForValue().get(areaDutyInfoKey); - List records = areas.keySet().stream().filter(stationEntities -> StringUtil.isEmpty(areaName) || stationEntities.getDeptName().contains(areaName)).map(stationEntities -> { + List records = areas.keySet().stream().filter(stationEntities -> StringUtil.isBlank(areaName) || stationEntities.getDeptName().contains(areaName)).map(stationEntities -> { DutyGroupVo duty = new DutyGroupVo(); duty.setDeptId(stationEntities.getId()); duty.setAreaName(stationEntities.getDeptName()); List dutys = areaDutyVoList.stream().filter(area -> area.getDepartId().equals(stationEntities.getId())).collect(Collectors.toList()); - if (CollectionUtil.isEmpty(dutys)) { + if (CollectionUtils.isEmpty(dutys)) { return duty; } // 操作票 @@ -1122,25 +1121,25 @@ public class TargetServiceImpl implements TargetService { public IPage maintenance(IPage page, MaintenanceAssociationVo business) { Wrapper queryWrapper = new LambdaQueryWrapper() {{ orderByDesc(OperMaintenanceTaskEntity::getDisposeTime); - if (!StringUtil.isEmpty(business.getTitle())) { + if (!StringUtil.isBlank(business.getTitle())) { like(OperMaintenanceTaskEntity::getTitle, business.getTitle()); } - if (!StringUtil.isEmpty(business.getTaskType())) { + if (!StringUtil.isBlank(business.getTaskType())) { eq(OperMaintenanceTaskEntity::getTaskType, business.getTaskType()); } - if (!StringUtil.isEmpty(business.getContent())) { + if (!StringUtil.isBlank(business.getContent())) { like(OperMaintenanceTaskEntity::getContent, business.getContent()); } - if (!StringUtil.isEmpty(business.getStartTime())) { + if (!StringUtil.isBlank(business.getStartTime())) { ge(OperMaintenanceTaskEntity::getDisposeTime,business.getStartTime()); } - if (!StringUtil.isEmpty(business.getEndTime())) { + if (!StringUtil.isBlank(business.getEndTime())) { le(OperMaintenanceTaskEntity::getDisposeTime,business.getEndTime()); } - if(!StringUtil.isEmpty(business.getType()) && "1".equals(business.getType())){ + if(!StringUtil.isBlank(business.getType()) && "1".equals(business.getType())){ eq(OperMaintenanceTaskEntity::getFlowTaskName,"结束"); } - if(!StringUtil.isEmpty(business.getDeptIds())){ + if(!StringUtil.isBlank(business.getDeptIds())){ in(OperMaintenanceTaskEntity::getCreateDept, Func.toLongList(",",business.getDeptIds())); } }}; @@ -1159,29 +1158,29 @@ public class TargetServiceImpl implements TargetService { public IPage phenomenon(IPage page, MaintenancePhenomenonVo business) { Wrapper queryWrapper = new LambdaQueryWrapper() {{ orderByDesc(OperPhenomenonEntity::getCreateTime); - if (!StringUtil.isEmpty(business.getFaultName())) { + if (!StringUtil.isBlank(business.getFaultName())) { like(OperPhenomenonEntity::getFaultName,business.getFaultName()); } if (!ObjectUtil.isEmpty(business.getIsDefect())) { eq(OperPhenomenonEntity::getIsDefect,business.getIsDefect()); } - if (!StringUtil.isEmpty(business.getFindStartTime())) { + if (!StringUtil.isBlank(business.getFindStartTime())) { ge(OperPhenomenonEntity::getFindTime,business.getFindStartTime()); } - if (!StringUtil.isEmpty(business.getFindEndTime())) { + if (!StringUtil.isBlank(business.getFindEndTime())) { le(OperPhenomenonEntity::getFindTime,business.getFindEndTime()); } - if (!StringUtil.isEmpty(business.getStartTime())) { + if (!StringUtil.isBlank(business.getStartTime())) { ge(OperPhenomenonEntity::getCreateTime,business.getStartTime()); } - if (!StringUtil.isEmpty(business.getEndTime())) { + if (!StringUtil.isBlank(business.getEndTime())) { le(OperPhenomenonEntity::getCreateTime,business.getEndTime()); } - if(!StringUtil.isEmpty(business.getType()) && "1".equals(business.getType())){ + if(!StringUtil.isBlank(business.getType()) && "1".equals(business.getType())){ isNotNull(OperPhenomenonEntity::getHandleTaskId); } - if(!StringUtil.isEmpty(business.getDeptIds())){ + if(!StringUtil.isBlank(business.getDeptIds())){ in(OperPhenomenonEntity::getCreateDept, Func.toLongList(",",business.getDeptIds())); } }}; @@ -1200,19 +1199,19 @@ public class TargetServiceImpl implements TargetService { public IPage access(IPage page, AccessAssociationVo business) { Wrapper queryWrapper = new LambdaQueryWrapper() {{ orderByDesc(OperAccessTaskEntity::getPlanStartTime); - if (!StringUtil.isEmpty(business.getName())) { + if (!StringUtil.isBlank(business.getName())) { like(OperAccessTaskEntity::getName,business.getName()); } - if (!StringUtil.isEmpty(business.getStartTime())) { + if (!StringUtil.isBlank(business.getStartTime())) { ge(OperAccessTaskEntity::getPlanStartTime,business.getStartTime()); } - if (!StringUtil.isEmpty(business.getEndTime())) { + if (!StringUtil.isBlank(business.getEndTime())) { le(OperAccessTaskEntity::getPlanStartTime,business.getEndTime()); } - if(!StringUtil.isEmpty(business.getType()) && "1".equals(business.getType())){ + if(!StringUtil.isBlank(business.getType()) && "1".equals(business.getType())){ eq(OperAccessTaskEntity::getStatus,4); } - if(!StringUtil.isEmpty(business.getDeptIds())){ + if(!StringUtil.isBlank(business.getDeptIds())){ in(OperAccessTaskEntity::getCreateDept, Func.toLongList(",",business.getDeptIds())); } }}; @@ -1237,7 +1236,7 @@ public class TargetServiceImpl implements TargetService { } if(HomePageConstant.YEAR.equals(type)){ // 站点近年发电数据 - Map> powerMap = (Map>) redisTemplate.opsForValue().get(recent_year_power_data); + Map> powerMap = (Map>) redisTemplate.opsForValue().get(recent_year_power_data); // 填报发电量 List mons = this.mons(0,12,false); return mons.stream().map(mon->{ @@ -1249,7 +1248,7 @@ public class TargetServiceImpl implements TargetService { return detail; } // 发电量 - Map monMap = powerMap.get(station.getId()); + Map monMap = powerMap.get(station.getCode()); if(MapUtils.isEmpty(monMap)){ detail.setElectric(0.0); return detail; @@ -1266,12 +1265,12 @@ public class TargetServiceImpl implements TargetService { HydropowerTargetDetailVo detail = new HydropowerTargetDetailVo(); detail.setTime(day.getDate()); detail.setElectric(Double.valueOf(day.getGenerate())); - if(CollectionUtil.isEmpty(targets)){ + if(CollectionUtils.isEmpty(targets)){ return detail; } // 设备指标数据 List generations = targets.stream().filter(o-> CollectionUtil.isNotEmpty(o.getGenerationPowerVoList()) && o.getDeptId().equals(station.getRefDept())).flatMap(v -> v.getGenerationPowerVoList().stream()).collect(Collectors.toList()); - if(CollectionUtil.isEmpty(generations)){ + if(CollectionUtils.isEmpty(generations)){ return detail; } detail.setElectric(generations.stream().filter(o->o.getDate().equals(day.getDate())).mapToDouble(GenerationPowerVo::getGenerate).sum()); diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/data/service/impl/HzimsDataServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/data/service/impl/HzimsDataServiceImpl.java index 59b40ab..4db2b8e 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/data/service/impl/HzimsDataServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/data/service/impl/HzimsDataServiceImpl.java @@ -22,7 +22,6 @@ import com.hnac.hzims.operational.station.entity.StationEntity; import com.hnac.hzims.operational.station.service.IHzimsAnalyzeModelStationService; import com.hnac.hzims.operational.station.service.IStationService; import com.hnac.hzinfo.datasearch.analyse.vo.AnalyseDataTaosVO; -import com.hnac.hzinfo.datasearch.analyse.vo.AnalyzeDataConditionVO; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections4.MapUtils; @@ -232,7 +231,7 @@ public class HzimsDataServiceImpl implements HzimsDataService { List deviceList = maintenanceTaskService.getEmInfoList(); HydropowerStationVo response = new HydropowerStationVo(); // 近年发电量数据 - Map> map = (Map>) redisTemplate.opsForValue().get(recent_year_power_data); + Map> map = (Map>) redisTemplate.opsForValue().get(recent_year_power_data); response.setDeptId(station.getRefDept()); response.setDeptName(station.getName()); response.setStationCode(station.getCode()); @@ -734,7 +733,7 @@ public class HzimsDataServiceImpl implements HzimsDataService { * 年发电量完成百分比 * @param stations */ - private List handlePowerFinish(List stations, Map> map) { + private List handlePowerFinish(List stations, Map> map) { if (CollectionUtil.isEmpty(stations)) { return null; } @@ -755,7 +754,7 @@ public class HzimsDataServiceImpl implements HzimsDataService { vo.setPower(0f); } else { float generate = (float) map.entrySet().stream(). - filter(entry -> stations.stream().map(StationEntity::getId).collect(Collectors.toList()).contains(entry.getKey())). + filter(entry -> stations.stream().map(StationEntity::getCode).collect(Collectors.toList()).contains(entry.getKey())). mapToDouble(valueMap -> valueMap.getValue().entrySet().stream().filter(entry -> entry.getKey().equals(o)) .mapToDouble(Map.Entry::getValue).sum()).sum(); vo.setPower(generate); diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/impl/ImsDutyGroupServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/impl/ImsDutyGroupServiceImpl.java index c5cd17b..7ee5f6a 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/impl/ImsDutyGroupServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/impl/ImsDutyGroupServiceImpl.java @@ -408,7 +408,11 @@ public class ImsDutyGroupServiceImpl extends ServiceImpl members = group.getMember().stream().peek(member->{ User person = UserCache.getUser(member.getPersonId()); if (ObjectUtil.isNotEmpty(person)) { - member.setPersonName(person.getName()); + if(StringUtil.isBlank(person.getRealName())){ + member.setPersonName(person.getName()); + }else{ + member.setPersonName(person.getRealName()); + } } }).collect(Collectors.toList()); group.setMember(members.stream().filter(o->StringUtil.isNotBlank(o.getPersonName())).collect(Collectors.toList())); diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/history/controller/HistoryController.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/history/controller/HistoryController.java index 93c10b9..c804f8b 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/history/controller/HistoryController.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/history/controller/HistoryController.java @@ -1,14 +1,10 @@ package com.hnac.hzims.operational.history.controller; -import com.baomidou.mybatisplus.core.metadata.IPage; import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; import com.hnac.hzims.operational.history.service.AlarmService; import com.hnac.hzims.operational.history.service.PointService; import com.hnac.hzims.operational.history.vo.HistoricalCurveVo; import com.hnac.hzims.operational.history.vo.HistoryProjectAlarmVo; -import com.hnac.hzinfo.dataconfig.entity.Device; -import com.hnac.hzinfo.datasearch.soe.domian.SoeData; -import com.hnac.hzinfo.datasearch.soe.domian.SoeQueryCondition; import com.hnac.hzinfo.sdk.v5.device.vo.DeviceInstanceAttrVO; import com.hnac.hzinfo.sdk.v5.device.vo.DeviceInstanceVO; import com.hnac.hzinfo.sdk.v5.hzfac.vo.FacDeviceAttrVO; @@ -19,8 +15,8 @@ import lombok.AllArgsConstructor; import org.springblade.core.boot.ctrl.BladeController; import org.springblade.core.tool.api.R; import org.springframework.web.bind.annotation.*; +import org.springblade.core.mp.support.Query; -import javax.management.Query; import java.util.List; import java.util.Map; diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/history/service/AlarmService.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/history/service/AlarmService.java index 712fefd..d21efbc 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/history/service/AlarmService.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/history/service/AlarmService.java @@ -1,13 +1,8 @@ package com.hnac.hzims.operational.history.service; -import com.baomidou.mybatisplus.core.metadata.IPage; import com.hnac.hzims.operational.history.vo.HistoryProjectAlarmVo; -import com.hnac.hzinfo.datasearch.soe.domian.SoeData; -import com.hnac.hzinfo.datasearch.soe.domian.SoeQueryCondition; -import com.hnac.hzinfo.sdk.v5.device.vo.DeviceInstanceAttrVO; +import org.springblade.core.mp.support.Query; -import javax.management.Query; -import java.util.List; import java.util.Map; /** diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/history/service/impl/AlarmServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/history/service/impl/AlarmServiceImpl.java index daeca61..296e515 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/history/service/impl/AlarmServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/history/service/impl/AlarmServiceImpl.java @@ -3,13 +3,13 @@ package com.hnac.hzims.operational.history.service.impl; import com.hnac.hzims.operational.history.service.AlarmService; import com.hnac.hzims.operational.history.vo.HistoryProjectAlarmVo; import com.hnac.hzinfo.sdk.core.response.Result; +import org.springblade.core.mp.support.Query; import com.hnac.hzinfo.sdk.v5.soe.SoeDataClient; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springblade.core.tool.utils.CollectionUtil; import org.springframework.stereotype.Service; -import javax.management.Query; import java.util.HashMap; import java.util.Map; @@ -39,7 +39,8 @@ public class AlarmServiceImpl implements AlarmService { alarm.getSoeType(), alarm.getStartTime(), alarm.getEndTime(), - query + query.getCurrent(), + query.getSize() ); if(!result.isSuccess() || CollectionUtil.isEmpty(result.getData())){ return new HashMap<>(); diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/AreaMonthReportServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/AreaMonthReportServiceImpl.java index 02da94f..2a716fe 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/AreaMonthReportServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/AreaMonthReportServiceImpl.java @@ -288,8 +288,8 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService { }else { map.put("commissionTime", 0); } - List stationIds = Optional.ofNullable(stationEntityList) - .orElse(new ArrayList<>()).stream().map(BaseEntity::getId).collect(Collectors.toList()); + List stationIds = Optional.ofNullable(stationEntityList) + .orElse(new ArrayList<>()).stream().map(StationEntity::getCode).collect(Collectors.toList()); //其它普通数据 map.put("year", year); Integer yearBefore = year - 1; @@ -706,13 +706,13 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService { return R.success("成功"); } - private List getMonPowerPercentageVos(Integer year, Integer month, List deptList, List deptIds, List stationEntityList, List stationIds, Integer yearBefore, Integer monthBefore) { + private List getMonPowerPercentageVos(Integer year, Integer month, List deptList, List deptIds, List stationEntityList, List stationIds, Integer yearBefore, Integer monthBefore) { List deptIdsString = deptIds.stream().map(String::valueOf).collect(Collectors.toList()); //年计划发电量 List planYearData = planGenertionClient.getPlanGenerationByParam(null, deptIdsString, year.toString()); List powerPercentageVoList = new ArrayList<>(); //水电站,光伏站和带代运维数据近三年数据 - Map> powerMapThree = (Map>) redisTemplate.opsForValue().get(RECENT_YEAR_POWER_DATA); + Map> powerMapThree = (Map>) redisTemplate.opsForValue().get(RECENT_YEAR_POWER_DATA); List listByYear = TimeUtils.getListByYear(year); List listByYearBefore = TimeUtils.getListByYear(yearBefore); String monStart = TimeUtils.getMon(year, month); @@ -720,12 +720,12 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService { String monStartMonBefore = TimeUtils.getEarlyTime(yearBefore, month); // String monStartMonBefore = TimeUtils.getMon(year, monthBefore); // 格式:站点-日期-发电量 - for (Map.Entry> deviceMap : powerMapThree.entrySet()) { + for (Map.Entry> deviceMap : powerMapThree.entrySet()) { String deptNameByKey; if (stationIds.contains(deviceMap.getKey())) { MonPowerPercentageVo powerVo = new MonPowerPercentageVo(); - powerVo.setDeptId(deviceMap.getKey()); - List collect = stationEntityList.stream().filter(s -> deviceMap.getKey().equals(s.getId())).collect(Collectors.toList()); + //powerVo.setDeptId(deviceMap.getKey()); + List collect = stationEntityList.stream().filter(s -> deviceMap.getKey().equals(s.getCode())).collect(Collectors.toList()); Long dept = collect.get(0).getRefDept(); List dep = deptList.stream().filter(s -> dept.equals(s.getId())).collect(Collectors.toList()); deptNameByKey=dep.get(0).getDeptName(); @@ -738,7 +738,7 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService { Double planGeneration = 0d; List planGenerationById = planYearData.stream().filter(s -> collect.get(0).getRefDept().equals(s.getStationDeptId())).collect(Collectors.toList()); if (CollectionUtils.isNotEmpty(planGenerationById)) { - planGeneration = Double.valueOf(planGenerationById.stream().mapToDouble(PlanGenerationEntity::getPlanGeneration).sum()); + planGeneration = planGenerationById.stream().mapToDouble(PlanGenerationEntity::getPlanGeneration).sum(); } //当前机构近三年的数据 Map value = deviceMap.getValue(); @@ -760,11 +760,9 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService { BigDecimal planPercentage = new BigDecimal(0); if (powerYearBefore.compareTo(BigDecimal.ZERO) != 0) { yearPercentage = (powerYear.subtract(powerYearBefore)).divide(powerYearBefore, 2, RoundingMode.UP); - yearPercentage.setScale(2, RoundingMode.UP); } if (BigDecimal.valueOf(planGeneration).compareTo(BigDecimal.ZERO) != 0) { planPercentage = powerYear.divide(BigDecimal.valueOf(planGeneration), 2, RoundingMode.UP); - planPercentage.setScale(2, RoundingMode.UP); } powerVo.setPlanPercentage(planPercentage.doubleValue()); powerVo.setPowerYearPercentage(yearPercentage.doubleValue()); @@ -774,7 +772,6 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService { BigDecimal monPercentage = new BigDecimal(0); if (powerMonthYearBefore.compareTo(BigDecimal.ZERO) != 0) { monPercentage = (powerMonth.subtract(powerMonthYearBefore)).divide(powerMonthYearBefore, 2, RoundingMode.UP); - monPercentage.setScale(2, RoundingMode.UP); } powerVo.setPowerMonPercentage(monPercentage.doubleValue()); powerPercentageVoList.add(powerVo); @@ -1246,7 +1243,7 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService { return; } // 站点近年发电数据 - Map> powerMap = (Map>) redisTemplate.opsForValue().get(RECENT_YEAR_POWER_DATA); + Map> powerMap = (Map>) redisTemplate.opsForValue().get(RECENT_YEAR_POWER_DATA); // 存储数据节点 key - 月份 value - 区域数据集合 Map> map = new HashMap<>(); // 月份集合 @@ -1290,7 +1287,7 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService { return; } // 站点近年发电数据 - Map> powerMap = (Map>) redisTemplate.opsForValue().get(RECENT_YEAR_POWER_DATA); + Map> powerMap = (Map>) redisTemplate.opsForValue().get(RECENT_YEAR_POWER_DATA); // 存储数据节点 key - 月份 value - 区域数据集合 Map> map = new HashMap<>(); // 月份集合 @@ -1345,17 +1342,17 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService { * @param mon * @return */ - private List getAreaReportByMon(List deptList, Map> powerMap, List stationList, String mon) { + private List getAreaReportByMon(List deptList, Map> powerMap, List stationList, String mon) { LocalDateTime startTime = LocalDateTime.parse(mon + "-01 00:00:00", dtf); LocalDateTime endTime = getEndTime(mon); // 查询所有站点的计划发电量 List planList = getPlanPower(stationList, mon); // 站点实际发电量 - Map actualMap = getActualPower(powerMap, stationList, mon + "-01"); + Map actualMap = getActualPower(powerMap, stationList, mon + "-01"); // 站点去年发电量 - Map oldActualMap = getActualPower(powerMap, stationList, getLastyear(1, mon)); + Map oldActualMap = getActualPower(powerMap, stationList, getLastyear(1, mon)); // 站点前发电量 - Map oldOldActualMap = getActualPower(powerMap, stationList, getLastyear(2, mon)); + Map oldOldActualMap = getActualPower(powerMap, stationList, getLastyear(2, mon)); // 取机构中区域部分 List areaList = deptList.stream().filter(o -> o.getDeptCategory().equals(3)).collect(Collectors.toList()); if (CollectionUtil.isEmpty(areaList)) { @@ -1397,15 +1394,15 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService { * @param areaStationList * @param areaMonthReport */ - private void getPredictPlanPower(Map oldActualMap, Map oldOldActualMap, List areaStationList, AreaMonthReportVo areaMonthReport) { + private void getPredictPlanPower(Map oldActualMap, Map oldOldActualMap, List areaStationList, AreaMonthReportVo areaMonthReport) { areaMonthReport.setPredictPlanPower(0.0); // 实际发电量 - List ids = areaStationList.stream().map(StationEntity::getId).collect(Collectors.toList()); - if (CollectionUtil.isEmpty(ids)) { + List codes = areaStationList.stream().map(StationEntity::getCode).collect(Collectors.toList()); + if (CollectionUtil.isEmpty(codes)) { return; } - double oldActualPower = oldActualMap.entrySet().stream().filter(e -> ids.contains(e.getKey())).mapToDouble(Map.Entry::getValue).sum(); - double oldOldActualPower = oldOldActualMap.entrySet().stream().filter(e -> ids.contains(e.getKey())).mapToDouble(Map.Entry::getValue).sum(); + double oldActualPower = oldActualMap.entrySet().stream().filter(e -> codes.contains(e.getKey())).mapToDouble(Map.Entry::getValue).sum(); + double oldOldActualPower = oldOldActualMap.entrySet().stream().filter(e -> codes.contains(e.getKey())).mapToDouble(Map.Entry::getValue).sum(); if (Math.abs(oldActualPower) <= 0 && Math.abs(oldOldActualPower) <= 0) { return; } @@ -1523,14 +1520,14 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService { * @param stationList * @return */ - private Map getActualPower(Map> powerMap, List stationList, String month) { + private Map getActualPower(Map> powerMap, List stationList, String month) { if (MapUtils.isEmpty(powerMap)) { return null; } // 站点Id集合 - List stationIdList = stationList.stream().map(StationEntity::getId).collect(Collectors.toList()); + List stationIdList = stationList.stream().map(StationEntity::getCode).collect(Collectors.toList()); // 存储站点实际发电量 - Map actualPowerMap = new HashMap<>(); + Map actualPowerMap = new HashMap<>(); stationIdList.forEach(key -> { Map monthMap = powerMap.get(key); if (MapUtils.isEmpty(monthMap)) { @@ -1554,7 +1551,7 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService { * @param areaStationList * @param areaMonthReport */ - private void powerMonth(List planList, Map actualMap, Map oldActualMap, List areaStationList, AreaMonthReportVo areaMonthReport) { + private void powerMonth(List planList, Map actualMap, Map oldActualMap, List areaStationList, AreaMonthReportVo areaMonthReport) { // 计划发电量 List codeList = areaStationList.stream().map(StationEntity::getCode).collect(Collectors.toList()); double planPower = planList.stream().filter(o -> codeList.contains(o.getStationId())).mapToDouble(PlanGenerationEntity::getPlanGeneration).sum(); @@ -1566,8 +1563,8 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService { return; } // 实际发电量 - List ids = areaStationList.stream().map(StationEntity::getId).collect(Collectors.toList()); - double actualPower = actualMap.entrySet().stream().filter(e -> ids.contains(e.getKey())).mapToDouble(Map.Entry::getValue).sum(); + List codes = areaStationList.stream().map(StationEntity::getCode).collect(Collectors.toList()); + double actualPower = actualMap.entrySet().stream().filter(e -> codes.contains(e.getKey())).mapToDouble(Map.Entry::getValue).sum(); areaMonthReport.setActualPower(Float.parseFloat(String.valueOf(actualPower))); if (Math.abs(planPower) <= 0) { areaMonthReport.setPowerFinishRate(0.0); @@ -1577,7 +1574,7 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService { areaMonthReport.setPowerFinishRate(powerFinishRate); } // 同比 - double oldActualPower = oldActualMap.entrySet().stream().filter(e -> ids.contains(e.getKey())).mapToDouble(Map.Entry::getValue).sum(); + double oldActualPower = oldActualMap.entrySet().stream().filter(e -> codes.contains(e.getKey())).mapToDouble(Map.Entry::getValue).sum(); if (Math.abs(actualPower) <= 0 || Math.abs(oldActualPower) <= 0) { areaMonthReport.setComparePowerRate(0.0); return; 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 7c7d3b2..60de174 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 @@ -28,10 +28,8 @@ import com.hnac.hzims.operational.station.service.IStationService; import com.hnac.hzims.ticket.workTicket.feign.ITicketInfoClient; import com.hnac.hzims.ticket.workTicket.vo.TicketMonthVO; import com.hnac.hzinfo.datasearch.soe.ISoeClient; -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 com.hnac.hzinfo.sdk.core.response.Result; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections4.MapUtils; @@ -142,7 +140,7 @@ public class HydropowerServiceImpl implements HydropowerService { Map weekWeather = this.getWeekWeather(Collections.singletonList(station.getCode())); HydropowerStationVo response = new HydropowerStationVo(); // 近年发电量数据 - Map> map = (Map>) redisTemplate.opsForValue().get(recent_year_power_data); + Map> map = (Map>) redisTemplate.opsForValue().get(recent_year_power_data); response.setDeptId(station.getRefDept()); response.setDeptName(station.getName()); response.setStationCode(station.getCode()); @@ -167,7 +165,7 @@ public class HydropowerServiceImpl implements HydropowerService { // 年计划发电量 response.setPlanPowerYear(this.getPlanPowerYear(station.getCode())); // 年发电量、月发电量 - this.stationMonthPower(station.getId(),map,response); + this.stationMonthPower(station.getCode(),map,response); // 水位、水位曲线 this.handleWaterLeve(station.getCode(),response); // 年发电量完成百分比 @@ -391,24 +389,24 @@ public class HydropowerServiceImpl implements HydropowerService { /** * 月发电量 - * @param id + * @param code * @param map * @param response */ - private void stationMonthPower(Long id, Map> map, HydropowerStationVo response) { - if(MapUtils.isEmpty(map) || !map.containsKey(id)){ + private void stationMonthPower(String code, Map> map, HydropowerStationVo response) { + if(MapUtils.isEmpty(map) || !map.containsKey(code)){ response.setPowerMon(0f); return; } // 月发电量 String month = DateUtil.format(new Date(),"yyyy-MM") + "-01"; - float powerMon = map.get(id).getOrDefault(month, 0f); + float powerMon = map.get(code).getOrDefault(month, 0f); if(powerMon > 0){ response.setPowerMon(powerMon); } String year = DateUtil.format(new Date(),"yyyy"); // 年发电量 - float powerYear = (float) map.get(id).entrySet().stream().filter(o->o.getKey().contains(year)).mapToDouble(Map.Entry::getValue).sum(); + float powerYear = (float) map.get(code).entrySet().stream().filter(o->o.getKey().contains(year)).mapToDouble(Map.Entry::getValue).sum(); response.setPowerYear(powerYear); // 年发电完成率 float planPowerYear = response.getPlanPowerYear(); @@ -446,7 +444,7 @@ public class HydropowerServiceImpl implements HydropowerService { * 年发电量完成百分比 * @param stations */ - private List handlePowerFinish(List stations,Map> map) { + private List handlePowerFinish(List stations,Map> map) { if(CollectionUtil.isEmpty(stations)){ return null; } @@ -467,7 +465,7 @@ public class HydropowerServiceImpl implements HydropowerService { vo.setPower(0f); }else{ float generate = (float) map.entrySet().stream(). - filter(entry->stations.stream().map(StationEntity::getId).collect(Collectors.toList()).contains(entry.getKey())). + filter(entry->stations.stream().map(StationEntity::getCode).collect(Collectors.toList()).contains(entry.getKey())). mapToDouble(valueMap-> valueMap.getValue().entrySet().stream().filter(entry->entry.getKey().equals(o)) .mapToDouble(Map.Entry::getValue).sum()).sum(); vo.setPower(generate); @@ -535,7 +533,7 @@ public class HydropowerServiceImpl implements HydropowerService { // 七天天气 Map weekWeather = this.getWeekWeather(stations.stream().map(StationEntity::getCode).collect(Collectors.toList())); // 站点近年发电数据 key - id value - 月份,发电量 - Map> map = (Map>) redisTemplate.opsForValue().get(recent_year_power_data); + Map> map = (Map>) redisTemplate.opsForValue().get(recent_year_power_data); return stations.stream().map(station->{ HydropowerStationVo hydropower = new HydropowerStationVo(); hydropower.setDeptId(station.getRefDept()); @@ -562,7 +560,7 @@ public class HydropowerServiceImpl implements HydropowerService { // 年计划发电量 hydropower.setPlanPowerYear(this.getPlanPowerYear(station.getCode())); // 月发电量、年发电量、年发电完成率 - this.stationMonthPower(station.getId(),map,hydropower); + this.stationMonthPower(station.getCode(),map,hydropower); // 水位、水位曲线 this.handleWaterLeve(station.getCode(),hydropower); // 年发电量完成百分比 @@ -619,8 +617,6 @@ public class HydropowerServiceImpl implements HydropowerService { // 年发电量 kpi.setGenerateYear(targets.stream().mapToDouble(HydropowerUnitTargetVo::getPowerYear).sum()); // 月发电量 - - kpi.setGenerateMon(targets.stream().mapToDouble(HydropowerUnitTargetVo::getPowerMon).sum()); // 日发电量 kpi.setGenerateDay(targets.stream().mapToDouble(HydropowerUnitTargetVo::getPowerDay).sum()); @@ -636,13 +632,13 @@ public class HydropowerServiceImpl implements HydropowerService { } } // 站点近年发电数据 key - id value - 月份,发电量 - Map> map = (Map>) redisTemplate.opsForValue().get(recent_year_power_data); + Map> map = (Map>) redisTemplate.opsForValue().get(recent_year_power_data); if (MapUtils.isEmpty(map)) { return kpi; } // 当月发电量 String month = DateUtil.format(new Date(),"yyyy-MM") + "-01"; - double generateMon = map.entrySet().stream().filter(o->stations.stream().map(StationEntity::getId).collect(Collectors.toList()).contains(o.getKey())).mapToDouble(entry->{ + double generateMon = map.entrySet().stream().filter(o->stations.stream().map(StationEntity::getCode).collect(Collectors.toList()).contains(o.getKey())).mapToDouble(entry->{ if(entry.getValue().containsKey(month)){ return Double.valueOf(entry.getValue().get(month)); } @@ -654,7 +650,7 @@ public class HydropowerServiceImpl implements HydropowerService { // 今年发电趋势 kpi.setPowerMonthVoList(this.handlePowerFinish(stations,map)); // 近3年发电量 - kpi.setPowerYearVoList(this.generateThreeYear(stations.stream().map(StationEntity::getId).collect(Collectors.toList()),map)); + kpi.setPowerYearVoList(this.generateThreeYear(stations.stream().map(StationEntity::getCode).collect(Collectors.toList()),map)); return kpi; } @@ -801,8 +797,8 @@ public class HydropowerServiceImpl implements HydropowerService { * @param stations * @return */ - private List generateThreeYear(List stations,Map> map) { - List> filter = map.entrySet().stream().filter(e -> stations.contains(e.getKey())).map(Map.Entry::getValue).collect(Collectors.toList()); + private List generateThreeYear(List stations,Map> map) { + List> filter = map.entrySet().stream().filter(entry -> stations.contains(entry.getKey())).map(Map.Entry::getValue).collect(Collectors.toList()); if (CollectionUtil.isEmpty(filter)) { return new ArrayList<>(); } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/MainSystemMonitoringServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/MainSystemMonitoringServiceImpl.java index 4b6d779..44673c8 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/MainSystemMonitoringServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/MainSystemMonitoringServiceImpl.java @@ -35,13 +35,11 @@ import com.hnac.hzinfo.datasearch.analyse.po.AnalyzeDataConditionPO; import com.hnac.hzinfo.datasearch.analyse.vo.AnalyseDataTaosVO; import com.hnac.hzinfo.datasearch.analyse.vo.AnalyzeCodeBySignagesVO; import com.hnac.hzinfo.datasearch.analyse.vo.AnalyzeDataConditionVO; -import com.hnac.hzinfo.datasearch.real.IRealDataSearchClient; import com.hnac.hzinfo.datasearch.soe.ISoeClient; import com.hnac.hzinfo.datasearch.soe.domian.SoeData; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections4.MapUtils; - import org.springblade.core.secure.BladeUser; import org.springblade.core.secure.utils.AuthUtil; import org.springblade.core.tool.api.R; @@ -105,23 +103,35 @@ public class MainSystemMonitoringServiceImpl implements IMainSystemMonitoringSer @Value("${hzims.operation.realIdKey}") public String realIdKeyPath; - - private final static String GENERATE_SIGNAGE = "generation_capacity";//发电标识 - private final static String POWER_SIGNAGE = "active_power";//有功功率标识 - private final static String JOINT_RELAY_SIGNAGE = "joint_relay";//开关机状态 - private final static String WATER_LEVEL = "water_level";//前池水位 - private final static String LIMIT_WATER_LEVEL = "limit_water_level";//限制水位 - - - private final static String UNIT_REV = "index_jzzs";//机组转速 - private final static String GUIDE_VANE_OPENING = "index_dykd";//导叶开度 - private final static String REACTIV_POWER = "reactive_power";//无功功率Q - private final static String POWER_FACTOR = "index_jz_cos";//机组Cos - private final static String HZVE_ADJUST_THE_GIVEN = "index_ygtzgd";//有功调整给定 - private final static String FEEDBACK = "index_jz_f";//频率 - private final static String IDLE_ADJUST_THE_GIVEN = "index_wgtzgd";//无功调整给定 - private final static String STATOR_CURRENT = "stator_current";//定子电流 - private final static String STATOR_VOLTAGE = "stator_voltage";//定子电压 + //发电标识 + private final static String GENERATE_SIGNAGE = "generation_capacity"; + //有功功率标识 + private final static String POWER_SIGNAGE = "active_power"; + //开关机状态 + private final static String JOINT_RELAY_SIGNAGE = "joint_relay"; + //前池水位 + private final static String WATER_LEVEL = "water_level"; + //限制水位 + private final static String LIMIT_WATER_LEVEL = "limit_water_level"; + + //机组转速 + private final static String UNIT_REV = "index_jzzs"; + //导叶开度 + private final static String GUIDE_VANE_OPENING = "index_dykd"; + //无功功率Q + private final static String REACTIV_POWER = "reactive_power"; + //机组Cos + private final static String POWER_FACTOR = "index_jz_cos"; + //有功调整给定 + private final static String HZVE_ADJUST_THE_GIVEN = "index_ygtzgd"; + //频率 + private final static String FEEDBACK = "index_jz_f"; + //无功调整给定 + private final static String IDLE_ADJUST_THE_GIVEN = "index_wgtzgd"; + //定子电流 + private final static String STATOR_CURRENT = "stator_current"; + //定子电压 + private final static String STATOR_VOLTAGE = "stator_voltage"; /** * 从Redis获取设备信息 @@ -244,11 +254,12 @@ public class MainSystemMonitoringServiceImpl implements IMainSystemMonitoringSer Map> yearGenerationMap = new HashMap<>(); Object yearGenerationDataObject = redisTemplate.opsForValue().get(yearGenerationData); if (ObjectUtil.isNotEmpty(yearGenerationDataObject)) { - yearGenerationMap = JSONObject.parseObject(yearGenerationDataObject.toString(), new TypeReference>>() {{ - }}); + yearGenerationMap = JSONObject.parseObject(yearGenerationDataObject.toString(), new TypeReference>>() { + }); } Float powerSumCount = 0f; - Float waterStageCount = 0f;//池水位统计 + //池水位统计 + Float waterStageCount; Map stringStationBodyVoMap = new HashMap<>(); Object json = redisTemplate.opsForValue().get(hisDataNew); if (ObjectUtil.isNotEmpty(json)) { @@ -281,14 +292,6 @@ public class MainSystemMonitoringServiceImpl implements IMainSystemMonitoringSer } // 限制水位 stationBodyVo.setLimitWaterLevel(dept.getLimitWaterLevel()); - /*String realIdLimitWaterLevel = realMap.get(dept.getCode() + LIMIT_WATER_LEVEL); - if (StringUtil.isNotBlank(realIdLimitWaterLevel)) { - if (null != realIdKeyMap.get(realIdLimitWaterLevel)) { - Float aFloat = realIdKeyMap.get(realIdLimitWaterLevel); - stationBodyVo.setLimitWaterLevel(aFloat); - } - }*/ - stationBodyVo.setPowerSumCount(powerSumCount); log.info("powerSumCount:{};installedCapacityCount:{}", powerSumCount, stationBodyVo.getInstalledCapacityCount()); //logger.info("getRedisHisDataByDeptNewArgs", "powerSumCount:" + powerSumCount + ";installedCapacityCount:" + stationBodyVo.getInstalledCapacityCount()); @@ -333,11 +336,7 @@ public class MainSystemMonitoringServiceImpl implements IMainSystemMonitoringSer } List ids = new ArrayList<>(); Map> rideCountGroupEmIdByDepts = emParamClient.getRideCountGroupEmIdByDepts(ids); - /*List analyzeModelStationEntityList = analyzeModelStationService.list(new LambdaQueryWrapper() {{ - eq(HzimsAnalyzeModelStationEntity::getIsDeleted, 0); - }});*/ for (StationEntity dept : stations) { - //前池水位数据 List waterLevelList = this.getWaterLevelTheDay(dept.getCode(), beginTime, endTime); @@ -396,7 +395,7 @@ public class MainSystemMonitoringServiceImpl implements IMainSystemMonitoringSer } } } catch (Exception e) { - log.error("-----getTheDayHydrographRedis-error{}-----", e); + log.error("-----getTheDayHydrographRedis-error{}-----", e.getMessage()); } } @@ -417,7 +416,7 @@ public class MainSystemMonitoringServiceImpl implements IMainSystemMonitoringSer List eminfoAndEmParamVos = this.getEmInfoList(); //获取计划发电量 - List planGenerationByDateAndStationList = planGenertionClient.getPlanGenerationByParam(stations.stream().map(s -> s.getCode()).collect(Collectors.toList()), null, DateUtil.format(new Date(), "yyyy-")); + List planGenerationByDateAndStationList = planGenertionClient.getPlanGenerationByParam(stations.stream().map(StationEntity::getCode).collect(Collectors.toList()), null, DateUtil.format(new Date(), "yyyy-")); LocalDateTime yearBeginTime = LocalDateTime.parse(DateUtil.format(new Date(), "yyyy-01-01 00:00:00"), df); @@ -485,7 +484,7 @@ public class MainSystemMonitoringServiceImpl implements IMainSystemMonitoringSer } } } catch (Exception e) { - log.error("-----getTheDayHydrographRedis-error{}-----", e); + log.error("-----getTheDayHydrographRedis-error{}-----", e.getMessage()); } } @@ -605,7 +604,7 @@ public class MainSystemMonitoringServiceImpl implements IMainSystemMonitoringSer map.put("rideCount", rideCount); map.put("installedCapacityCount", installedCapacityCount); - int installedCapacity = 0; + int installedCapacity; if (MapUtils.isNotEmpty(paramCountGroupEmIds)) { Map stringIntegerMap = paramCountGroupEmIds.get(emInfoExtendVo.getId()); if (MapUtils.isNotEmpty(stringIntegerMap)) { @@ -660,7 +659,7 @@ public class MainSystemMonitoringServiceImpl implements IMainSystemMonitoringSer R> listAnalyseCode = analyseInstanceClient.getListAnalyseCode(emInfoList.stream().map(EmInfoExtendVo::getEmCode).collect(Collectors.toList())); if (listAnalyseCode.isSuccess() && CollectionUtil.isNotEmpty(listAnalyseCode.getData())) { List emCodeList = listAnalyseCode.getData(); - List emInfoEntityList = emInfoList.stream().filter(o -> emCodeList.stream().collect(Collectors.toList()).contains(o.getEmCode())).collect(Collectors.toList()); + List emInfoEntityList = emInfoList.stream().filter(o -> new ArrayList<>(emCodeList).contains(o.getEmCode())).collect(Collectors.toList()); UnitVo unitVo = new UnitVo(); if (CollectionUtil.isNotEmpty(emInfoEntityList)) { for (EminfoAndEmParamVo emInfoEntity : emInfoEntityList) { @@ -716,7 +715,7 @@ public class MainSystemMonitoringServiceImpl implements IMainSystemMonitoringSer if (ObjectUtil.isNotEmpty(dept.getCommissionTime())) { Duration dur = Duration.between(dept.getCommissionTime(), LocalDateTime.now()); //天数 - day = Integer.valueOf(dur.toDays() + ""); + day = Integer.parseInt(dur.toDays() + ""); } stationVo.setSafetyOperationNumber(day); stationVo.setLatitude(dept.getLttd()); @@ -745,7 +744,7 @@ public class MainSystemMonitoringServiceImpl implements IMainSystemMonitoringSer LocalDateTime beginTime = LocalDateTime.parse(DateUtil.format(new Date(), "yyyy-MM-dd 00:00:00"), df); LocalDateTime endTime = LocalDateTime.now(); //给站点年发电量中的月份以及计划发电量赋值 - List yearGenerationVos = this.setYearGenerationData(12, dept.getCode(), planGenerationByDateAndStationList); + List yearGenerationVos = this.setYearGenerationData(dept.getCode(), planGenerationByDateAndStationList); //前池水位数据 List waterLevelList = this.getWaterLevelTheDay(dept.getCode(),beginTime,endTime); @@ -760,7 +759,7 @@ public class MainSystemMonitoringServiceImpl implements IMainSystemMonitoringSer R> listAnalyseCode = analyseInstanceClient.getListAnalyseCode(emInfoList.stream().map(EmInfoExtendVo::getEmCode).collect(Collectors.toList())); if (listAnalyseCode.isSuccess() && CollectionUtil.isNotEmpty(listAnalyseCode.getData())) { List emCodeList = listAnalyseCode.getData(); - List emInfoEntityList = emInfoList.stream().filter(o -> emCodeList.stream().collect(Collectors.toList()).contains(o.getEmCode())).collect(Collectors.toList()); + List emInfoEntityList = emInfoList.stream().filter(o -> new ArrayList<>(emCodeList).contains(o.getEmCode())).collect(Collectors.toList()); UnitVo unitVo = new UnitVo(); if (CollectionUtil.isNotEmpty(emInfoEntityList)) { for (EminfoAndEmParamVo emInfoEntity : emInfoEntityList) { @@ -865,7 +864,7 @@ public class MainSystemMonitoringServiceImpl implements IMainSystemMonitoringSer if (ObjectUtil.isNotEmpty(dept.getCommissionTime())) { Duration dur = Duration.between(dept.getCommissionTime(), LocalDateTime.now()); //天数 - day = Integer.valueOf(dur.toDays() + ""); + day = Integer.parseInt(dur.toDays() + ""); } if (null != stationVo.getYearPlanGenerateSumCount()) { stationVo.setYearSentGenerationCount(stationVo.getYearGenerateSumCount() / stationVo.getYearPlanGenerateSumCount() * 100); @@ -897,11 +896,11 @@ public class MainSystemMonitoringServiceImpl implements IMainSystemMonitoringSer if (CollectionUtil.isNotEmpty(analyzeDataConditionVO.getList())) { List list = analyzeDataConditionVO.getList(); for (AnalyseDataTaosVO analyseDataTaosVO : list) { - float count = 0; + float count; if (StringUtil.isBlank(analyseDataTaosVO.getVal())) { analyseDataTaosVO.setVal("0"); } else { - count = Float.valueOf(analyseDataTaosVO.getVal()) * (float) rideCount; + count = Float.parseFloat(analyseDataTaosVO.getVal()) * (float) rideCount; analyseDataTaosVO.setVal(count + ""); } } @@ -915,17 +914,16 @@ public class MainSystemMonitoringServiceImpl implements IMainSystemMonitoringSer /** * 给站点年发电量中的月份以及计划发电量赋值 * - * @param month * @return */ - private List setYearGenerationData(int month, String stationId, List planGenerationByDateAndStationList) { + private List setYearGenerationData(String stationId, List planGenerationByDateAndStationList) { List collect = new ArrayList<>(); if (CollectionUtil.isNotEmpty(planGenerationByDateAndStationList)) { collect = planGenerationByDateAndStationList.stream().filter(s -> s.getStationId().equals(stationId)).collect(Collectors.toList()); } List yearGenerationVoList = new ArrayList<>(); String format = DateUtil.format(new Date(), "yyyy-"); - for (int i = 1; i <= month; i++) { + for (int i = 1; i <= 12; i++) { YearGenerationVo vo = new YearGenerationVo(); if (i < 10) { vo.setYearMonth(format + "0" + i); @@ -959,7 +957,7 @@ public class MainSystemMonitoringServiceImpl implements IMainSystemMonitoringSer for (int i = 0; i < list.size(); i++) { AnalyseDataTaosVO analyseDataTaosVO = list.get(i); YearGenerationVo yearGenerationVo = yearGenerationVoList.get(i); - float count = 0; + float count; if (StringUtil.isNotBlank(analyseDataTaosVO.getVal())) { count = Float.parseFloat(String.valueOf(Double.parseDouble(analyseDataTaosVO.getVal()) * rideCount)); analyseDataTaosVO.setVal(count + ""); @@ -1328,9 +1326,10 @@ public class MainSystemMonitoringServiceImpl implements IMainSystemMonitoringSer if (CollectionUtil.isNotEmpty(record.getList())) { AnalyseDataTaosVO analyseDataTaosVO1 = record.getList().get(0); if (ObjectUtil.isNotEmpty(analyseDataTaosVO1) && StringUtil.isNotBlank(analyseDataTaosVO1.getVal())) { - Float aFloat = Float.valueOf(analyseDataTaosVO1.getVal()); + float aFloat = Float.parseFloat(analyseDataTaosVO1.getVal()); if (0 != rideCount) { - aFloat = Float.parseFloat(String.valueOf(Double.parseDouble(analyseDataTaosVO1.getVal()) * rideCount));; //获取发电量的值 且 * rideCount + //获取发电量的值 且 * rideCount + aFloat = Float.parseFloat(String.valueOf(Double.parseDouble(analyseDataTaosVO1.getVal()) * rideCount)); } if (typeCycle == EquipmentConstants.CycleTypeEnum.DAY_CYCLE.getType()) { vo.setDayGenerateCount(aFloat); @@ -1358,11 +1357,11 @@ public class MainSystemMonitoringServiceImpl implements IMainSystemMonitoringSer List listByYear = TimeUtils.getListByYearMon(year, mon); String currentMon = TimeUtils.getMon(year, mon); Integer count=0; - Map> powerMapThree = (Map>) redisTemplate.opsForValue().get(RECENT_YEAR_POWER_DATA); + Map> powerMapThree = (Map>) redisTemplate.opsForValue().get(RECENT_YEAR_POWER_DATA); log.info("Redis近三年发电量数据查询:"+powerMapThree); - for (Map.Entry> deviceMap : powerMapThree.entrySet()) { + for (Map.Entry> deviceMap : powerMapThree.entrySet()) { for (StationEntity stationEntity : stationEntityList) { - if (stationEntity.getId().equals(deviceMap.getKey())) { + if (stationEntity.getCode().equals(deviceMap.getKey())) { StationRunReportVO stationReportVO = new StationRunReportVO(); count++; stationReportVO.setIndex(count); @@ -1392,7 +1391,7 @@ public class MainSystemMonitoringServiceImpl implements IMainSystemMonitoringSer .divide(BigDecimal.valueOf(stationReportVO.getPowerMonPlan()), 2, RoundingMode.UP); stationReportVO.setPowerMonRate(String.valueOf(monRate.doubleValue())); }else { - stationReportVO.setPowerMonRate(new Double(0).toString()); + stationReportVO.setPowerMonRate(Double.toString(0)); } if (ObjectUtil.isNotEmpty(stationReportVO.getFinishPowerYear()) &&ObjectUtil.isNotEmpty(stationReportVO.getPowerYearPlan()) @@ -1401,7 +1400,7 @@ public class MainSystemMonitoringServiceImpl implements IMainSystemMonitoringSer .divide(BigDecimal.valueOf(stationReportVO.getPowerYearPlan()), 2, RoundingMode.UP); stationReportVO.setPowerYearRate(String.valueOf(yearRate.doubleValue())); }else { - stationReportVO.setPowerYearRate(new Double(0).toString()); + stationReportVO.setPowerYearRate(Double.toString(0)); } reportVOS.add(stationReportVO); } @@ -1493,7 +1492,7 @@ public class MainSystemMonitoringServiceImpl implements IMainSystemMonitoringSer .divide(BigDecimal.valueOf(stationReportVO.getPowerMonPlan()), 2, RoundingMode.UP); stationReportVO.setPowerMonRate(String.valueOf(monRate.doubleValue())); }else { - stationReportVO.setPowerMonRate(new Double(0).toString()); + stationReportVO.setPowerMonRate(Double.toString(0)); } if (ObjectUtil.isNotEmpty(stationReportVO.getFinishPowerYear()) &&ObjectUtil.isNotEmpty(stationReportVO.getPowerYearPlan()) @@ -1502,7 +1501,7 @@ public class MainSystemMonitoringServiceImpl implements IMainSystemMonitoringSer .divide(BigDecimal.valueOf(stationReportVO.getPowerYearPlan()), 2, RoundingMode.UP); stationReportVO.setPowerYearRate(String.valueOf(yearRate.doubleValue())); }else { - stationReportVO.setPowerYearRate(new Double(0).toString()); + stationReportVO.setPowerYearRate(Double.toString(0)); } stationReportVOList.add(stationReportVO); return stationReportVOList; @@ -1589,7 +1588,7 @@ public class MainSystemMonitoringServiceImpl implements IMainSystemMonitoringSer R planGenerationMonthCount = planGenertionClient.planGenerationMonthCount(stationEntity.getCode(), month);//获取计划月发电量 stationReportVO.setEnergy(powerCount.get()); if (planGenerationMonthCount.isSuccess() && ObjectUtil.isNotEmpty(planGenerationMonthCount.getData()) && planGenerationMonthCount.getData() != 0) { - Float rate = powerCount.get() / planGenerationMonthCount.getData() * 100; + float rate = powerCount.get() / planGenerationMonthCount.getData() * 100; stationReportVO.setYearPlanCompleteRate((float) (Math.round(rate * 100) / 100)); } stationReportVOList.add(stationReportVO); @@ -1710,8 +1709,8 @@ public class MainSystemMonitoringServiceImpl implements IMainSystemMonitoringSer //全部 //List stationTypesAll = stationAll.stream().map(s -> s.getType()).distinct().collect(Collectors.toList()); //用户权限 - List refDomainTypesUserAuth = stationUserAuth.stream().map(s -> s.getRefDomain()).distinct().collect(Collectors.toList()); - List stationTypesUserAuth = stationUserAuth.stream().map(s -> s.getType()).distinct().collect(Collectors.toList()); + List refDomainTypesUserAuth = stationUserAuth.stream().map(StationEntity::getRefDomain).distinct().collect(Collectors.toList()); + List stationTypesUserAuth = stationUserAuth.stream().map(StationEntity::getType).distinct().collect(Collectors.toList()); if (refDomainTypesUserAuth.size() > 1) {//多个行业 系统数据总览 @@ -1742,10 +1741,10 @@ public class MainSystemMonitoringServiceImpl implements IMainSystemMonitoringSer List stationUserAuth = stationService.getStationByUserAuth(user); List stationAll = stationService.getAll(); //全部 - List stationTypesAll = stationAll.stream().map(s -> s.getType()).distinct().collect(Collectors.toList()); + List stationTypesAll = stationAll.stream().map(StationEntity::getType).distinct().collect(Collectors.toList()); //用户权限 - Integer refDomainTypesUserAuthByRefDomain = stationUserAuth.stream().filter(o -> o.getRefDomain().toString().equals(refDomain)).map(s -> s.getRefDomain()).distinct().collect(Collectors.toList()).get(0); - List stationTypesUserAuth = stationUserAuth.stream().filter(o -> o.getRefDomain().toString().equals(refDomain)).map(s -> s.getType()).distinct().collect(Collectors.toList()); + Integer refDomainTypesUserAuthByRefDomain = stationUserAuth.stream().map(StationEntity::getRefDomain).filter(domain -> domain.toString().equals(refDomain)).distinct().collect(Collectors.toList()).get(0); + List stationTypesUserAuth = stationUserAuth.stream().filter(o -> o.getRefDomain().toString().equals(refDomain)).map(StationEntity::getType).distinct().collect(Collectors.toList()); InDustryVo inDustryVo = new InDustryVo(); inDustryVo.setType(OperationalConstants.InDustryEnum.INDUSTRY.getVal()); inDustryVo.setMainWorkBenchExtendVo(this.getRouteByRefDomain(null, inDustryVo, refTerminal, stationTypesAll, refDomainTypesUserAuthByRefDomain, stationTypesUserAuth, stationUserAuth)); @@ -1764,7 +1763,7 @@ public class MainSystemMonitoringServiceImpl implements IMainSystemMonitoringSer stationTypes.add(Integer.valueOf(stationType)); InDustryVo inDustryVo = new InDustryVo(); MainWorkBenchExtendVo mainWorkBenchExtendVo = new MainWorkBenchExtendVo(); - int userStaionCount = this.staionTypeSingle(user, type, stationType, null); + int userStaionCount = this.staionTypeSingle(user, type, stationType); mainWorkBenchExtendVo.setMainWorkBenchEntityList(this.getResult(userStaionCount, Integer.valueOf(type), refTerminal, stationTypes)); inDustryVo.setType(OperationalConstants.InDustryEnum.INDUSTRY.getVal()); inDustryVo.setMainWorkBenchExtendVo(mainWorkBenchExtendVo); @@ -1786,10 +1785,10 @@ public class MainSystemMonitoringServiceImpl implements IMainSystemMonitoringSer List stationUserAuth = stationService.getStationByUserAuth(user); List stationAll = stationService.getAll(); //全部 - List stationTypesAll = stationAll.stream().map(s -> s.getType()).distinct().collect(Collectors.toList()); + List stationTypesAll = stationAll.stream().map(StationEntity::getType).distinct().collect(Collectors.toList()); //用户权限 - Integer refDomainTypesUserAuthByRefDomain = stationUserAuth.stream().filter(o -> o.getRefDomain().toString().equals(refDomain)).map(s -> s.getRefDomain()).distinct().collect(Collectors.toList()).get(0); - List stationTypesUserAuth = stationUserAuth.stream().filter(o -> o.getRefDomain().toString().equals(refDomain)).map(s -> s.getType()).distinct().collect(Collectors.toList()); + Integer refDomainTypesUserAuthByRefDomain = stationUserAuth.stream().map(StationEntity::getRefDomain).filter(domain -> domain.toString().equals(refDomain)).distinct().collect(Collectors.toList()).get(0); + List stationTypesUserAuth = stationUserAuth.stream().filter(o -> o.getRefDomain().toString().equals(refDomain)).map(StationEntity::getType).distinct().collect(Collectors.toList()); InDustryVo inDustryVo = new InDustryVo(); inDustryVo.setType(OperationalConstants.InDustryEnum.INDUSTRY.getVal()); @@ -1859,31 +1858,31 @@ public class MainSystemMonitoringServiceImpl implements IMainSystemMonitoringSer List stationTypes = new ArrayList<>(); if (bool) { for (Long deptId : deptIds) { - stationTypesUserAuthDeptIds.addAll(stationUserAuth.stream().filter(o -> o.getRefDept().toString().equals(deptId.toString())).map(s -> s.getType()).collect(Collectors.toList())); + stationTypesUserAuthDeptIds.addAll(stationUserAuth.stream().filter(o -> o.getRefDept().toString().equals(deptId.toString())).map(StationEntity::getType).collect(Collectors.toList())); station.addAll(stationUserAuth.stream().filter(o -> o.getRefDept().toString().equals(deptId.toString())).collect(Collectors.toList())); } } else { stationTypesUserAuthDeptIds.addAll(stationTypesUserAuth); station.addAll(stationUserAuth); } - if (0 == stationTypesUserAuthDeptIds.size()) { + if (stationTypesUserAuthDeptIds.isEmpty()) { return null; } if (stationTypesAllByRefDomain.size() == stationTypesUserAuthDeptIds.size()) {//行业数据总览 List mainWorkBenchByType = mainWorkBenchService.getMainWorkBenchByType(OperationalConstants.FirstPageTypeEnum.INDUSTRY.getVal(), refDomainTypesUserAuth, refTerminal, stationTypesUserAuthDeptIds); mainWorkBenchEntityList.addAll(mainWorkBenchByType); - } else if (stationTypesAllByRefDomain.size() != stationTypesUserAuthDeptIds.size() && stationTypesUserAuthDeptIds.size() > 1) {//多个站点类型 + } else if (stationTypesUserAuthDeptIds.size() > 1) {//多个站点类型 inDustryVo.setType(OperationalConstants.InDustryEnum.MORE_STATION_TYPE.getVal()); List userStation = stationUserAuth.stream().filter(o -> o.getRefDomain().toString().equals(refDomainTypesUserAuth.toString())).collect(Collectors.toList()); for (StationEntity vo : userStation) { - int refDomainStationCount = userStation.stream().filter(o -> o.getType().toString().equals(vo.getType().toString())).collect(Collectors.toList()).size(); + int refDomainStationCount = (int) userStation.stream().filter(o -> o.getType().toString().equals(vo.getType().toString())).count(); stationTypes.add(vo.getType()); List result = this.getResult(refDomainStationCount, vo.getRefDomain(), refTerminal, stationTypes); mainWorkBenchEntityList.addAll(result); } - } else if (stationTypesAllByRefDomain.size() != stationTypesUserAuthDeptIds.size() && stationTypesUserAuthDeptIds.size() == 1) {//单个站点类型 + } else {//单个站点类型 inDustryVo.setType(OperationalConstants.InDustryEnum.SINGLE_STATION_TYPE.getVal()); - int refDomainStationCount = station.stream().filter(o -> o.getType().toString().equals(stationTypesUserAuthDeptIds.get(0).toString())).collect(Collectors.toList()).size(); + int refDomainStationCount = (int) station.stream().filter(o -> o.getType().toString().equals(stationTypesUserAuthDeptIds.get(0).toString())).count(); stationTypes.add(stationTypesUserAuthDeptIds.get(0)); List result = this.getResult(refDomainStationCount, refDomainTypesUserAuth, refTerminal, stationTypes); mainWorkBenchEntityList.addAll(result); @@ -1917,19 +1916,18 @@ public class MainSystemMonitoringServiceImpl implements IMainSystemMonitoringSer * @param user * @param refDomain * @param type - * @param deptIds * @return */ - private int staionTypeSingle(BladeUser user, String refDomain, String type, List deptIds) { + private int staionTypeSingle(BladeUser user, String refDomain, String type) { int userStaionCount = 0; if (user.getDataScopeType().equals(OperationalConstants.UserDataScopeTypeEnum.EMPLOYER_VISIBLE.getVal()) && ObjectUtil.isNotEmpty(user.getDeptId())) {//所属机构 - userStaionCount = stationService.getEqualToRefDeptStationCount(Long.valueOf(user.getDeptId()), refDomain, type, deptIds); + userStaionCount = stationService.getEqualToRefDeptStationCount(Long.valueOf(user.getDeptId()), refDomain, type, null); } else if ((user.getDataScopeType().equals(OperationalConstants.UserDataScopeTypeEnum.EMPLOYER_SUBORDINATE_BODY.getVal()) || user.getDataScopeType().equals(OperationalConstants.UserDataScopeTypeEnum.SELT_SUBORDINATE_BODY.getVal())) && ObjectUtil.isNotEmpty(user.getDeptId())) {//所属机构及下属机构 - userStaionCount = stationService.getLikeRefDeptStationCount(Long.valueOf(user.getDeptId()), refDomain, type, deptIds); + userStaionCount = stationService.getLikeRefDeptStationCount(Long.valueOf(user.getDeptId()), refDomain, type, null); } else if (user.getDataScopeType().equals(OperationalConstants.UserDataScopeTypeEnum.AFFILIATE.getVal()) && ObjectUtil.isNotEmpty(user.getDeptIds())) {//附属机构 - userStaionCount = stationService.getInRefDeptStationCount(Func.toLongList(user.getDeptIds()), refDomain, type, deptIds); + userStaionCount = stationService.getInRefDeptStationCount(Func.toLongList(user.getDeptIds()), refDomain, type, null); } else if (user.getDataScopeType().equals(OperationalConstants.UserDataScopeTypeEnum.AFFILIATE_SUBORDINATE_BODY.getVal()) && ObjectUtil.isNotEmpty(user.getDeptIds())) {//附属机构及下属 - userStaionCount = stationService.getForEachRefDeptStationCount(Func.toLongList(user.getDeptIds()), refDomain, type, deptIds); + userStaionCount = stationService.getForEachRefDeptStationCount(Func.toLongList(user.getDeptIds()), refDomain, type, null); } return userStaionCount; } @@ -1941,70 +1939,9 @@ public class MainSystemMonitoringServiceImpl implements IMainSystemMonitoringSer if ("admin".equals(user.getAccount())) { return stationService.getAll(); } - return getStationList(true); + return getStationList(); } - /*@Override - public List doListByAuthDept() { - List stationDeptVos = new ArrayList<>(); - BladeUser user = AuthUtil.getUser(); - if (user.getAccount().equals("admin")) { - R> deptByType = sysClient.getDeptByType("200000", null, null); - if (deptByType.isSuccess() && CollectionUtil.isNotEmpty(deptByType.getData())) { - deptByType.getData().forEach(o -> { - StationDeptVo vo = new StationDeptVo(); - vo.setRefDept(o.getId().toString()); - vo.setStationId(o.getStationId()); - vo.setName(o.getDeptName()); - stationDeptVos.add(vo); - }); - } - List stationEntityList = stationService.getAll(); - stationEntityList.forEach(o -> { - StationDeptVo vo = new StationDeptVo(); - vo.setRefDept(o.getRefDept().toString()); - vo.setStationId(o.getCode()); - vo.setName(o.getName()); - stationDeptVos.add(vo); - }); - if (CollectionUtil.isNotEmpty(stationDeptVos) && user.getAccount().equals("admin")) { - Set collect = stationDeptVos.stream().collect(Collectors.toSet()); - List collect1 = collect.stream().collect(Collectors.toList()); - return collect1; - } - return stationDeptVos; - } - - List list = getStationList(true); - String userDepts = this.classifyUserDataStringDepts(); - if (CollectionUtil.isNotEmpty(list) && StringUtil.isNotBlank(userDepts)) { - for (String deptId : userDepts.split(",")) { - List collect = list.stream().filter(iter -> iter.getRefDept().toString().equals(deptId)).collect(Collectors.toList()); - if (CollectionUtil.isEmpty(collect)) { - R dept = sysClient.getDept(Long.valueOf(deptId)); - if (dept.isSuccess() && ObjectUtil.isNotEmpty(dept.getData())) { - StationDeptVo vo = new StationDeptVo(); - Dept data = dept.getData(); - vo.setName(data.getDeptName()); - vo.setStationId(data.getStationId()); - vo.setRefDept(data.getId().toString()); - stationDeptVos.add(vo); - } - } - } - for (StationEntity stationEntity : list) { - StationDeptVo vo = new StationDeptVo(); - vo.setName(stationEntity.getName()); - vo.setStationId(stationEntity.getCode()); - vo.setRefDept(stationEntity.getRefDept().toString()); - stationDeptVos.add(vo); - } - - } - return stationDeptVos; - } -*/ - @Override public List doListByAuthDept() { List stationDeptVos = new ArrayList<>(); @@ -2024,13 +1961,12 @@ public class MainSystemMonitoringServiceImpl implements IMainSystemMonitoringSer @Override public R deptByAuthUser() { - R> deptByCurrentUser = sysClient.getDeptByCurrentUser(); - return deptByCurrentUser; + return sysClient.getDeptByCurrentUser(); } - private List getStationList(boolean bool) { - return this.classifyUserDataScopeType(null, null, null, bool); + private List getStationList() { + return this.classifyUserDataScopeType(null, null, null, true); } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/PhotovoltaicServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/PhotovoltaicServiceImpl.java index e0aab67..7c3d32b 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/PhotovoltaicServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/PhotovoltaicServiceImpl.java @@ -151,7 +151,7 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService { // 减少森林砍伐 kpi.setDeforest(targets.stream().mapToDouble(PhotovoltaicTargetVo::getDeforest).sum()); // 近3年发电量 - kpi.setPowerYearVoList(this.getPowerList(stations.stream().map(StationEntity::getId).collect(Collectors.toList()))); + kpi.setPowerYearVoList(this.getPowerList(stations.stream().map(StationEntity::getCode).collect(Collectors.toList()))); return kpi; } @@ -160,9 +160,9 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService { * * @return */ - private List getPowerList(List stations) { + private List getPowerList(List stations) { // 站点近年发电数据 key - stationCode value - 月份,发电量 - Map> map = (Map>) redisTemplate.opsForValue().get(recent_year_power_data); + Map> map = (Map>) redisTemplate.opsForValue().get(recent_year_power_data); if (MapUtils.isEmpty(map)) { return new ArrayList<>(); } @@ -227,7 +227,7 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService { return this.getGeneration(stations.stream().map(StationEntity::getRefDept).distinct().collect(Collectors.toList()), false); // 年 case "2": - return this.getGenerationYear(stations.stream().map(StationEntity::getId).distinct().collect(Collectors.toList())); + return this.getGenerationYear(stations.stream().map(StationEntity::getCode).distinct().collect(Collectors.toList())); default: throw new ServiceException("无效查询类型!"); } @@ -285,9 +285,9 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService { * * @return */ - private List getGenerationYear(List stations) { + private List getGenerationYear(List stations) { // 站点近年发电数据 key - stationCode value - 月份,发电量 - Map> map = (Map>) redisTemplate.opsForValue().get(recent_year_power_data); + Map> map = (Map>) redisTemplate.opsForValue().get(recent_year_power_data); if (MapUtils.isEmpty(map)) { return new ArrayList<>(); } @@ -745,7 +745,7 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService { return this.periodLoadGenerate(stations.stream().map(StationEntity::getRefDept).collect(Collectors.toList()), type, false); // 年 case "3": - return this.periodLoadGenerateYear(stations.stream().map(StationEntity::getId).collect(Collectors.toList())); + return this.periodLoadGenerateYear(stations.stream().map(StationEntity::getCode).collect(Collectors.toList())); default: throw new ServiceException("无效查询类型!"); @@ -850,9 +850,9 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService { * @param stations * @return */ - private List periodLoadGenerateYear(List stations) { + private List periodLoadGenerateYear(List stations) { // 站点近年发电数据 key - stationCode value - 月份,发电量 - Map> map = (Map>) redisTemplate.opsForValue().get(recent_year_power_data); + Map> map = (Map>) redisTemplate.opsForValue().get(recent_year_power_data); if (MapUtils.isEmpty(map)) { return new ArrayList<>(); } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/SideHustleServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/SideHustleServiceImpl.java index b5ee524..aeb43c5 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/SideHustleServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/SideHustleServiceImpl.java @@ -1,16 +1,13 @@ package com.hnac.hzims.operational.main.service.impl; -import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.TypeReference; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import com.hnac.hzims.EquipmentConstants; import com.hnac.hzims.equipment.entity.EmInfoEntity; import com.hnac.hzims.equipment.entity.PlanGenerationEntity; import com.hnac.hzims.equipment.feign.IEmInfoClient; import com.hnac.hzims.equipment.feign.IPlanGenertionClient; -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.hzimsweather.response.weather.HeWeatherWeatherNowResponse; @@ -21,9 +18,6 @@ import com.hnac.hzims.operational.defect.constants.DefectConstant; 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.DutyInfoVo; -import com.hnac.hzims.operational.duty.vo.DutyTaskVo; -import com.hnac.hzims.operational.duty.vo.NextDutyInfoVo; import com.hnac.hzims.operational.main.constant.HomePageConstant; import com.hnac.hzims.operational.main.entity.UserDeptEntity; import com.hnac.hzims.operational.main.service.*; @@ -31,24 +25,20 @@ 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.report.vo.DutyDefectVO; import com.hnac.hzims.operational.station.entity.StationEntity; import com.hnac.hzims.operational.station.service.IStationService; import com.hnac.hzims.ticket.workTicket.feign.ITicketInfoClient; -import com.hnac.hzims.ticket.workTicket.vo.TicketMonthVO; -import com.hnac.hzims.ticket.workTicket.vo.WorkTicketStatisticVO; import com.hnac.hzinfo.datasearch.analyse.IAnalyseInstanceClient; import com.hnac.hzinfo.inspect.task.feign.IInspectTaskReportClient; -import com.hnac.hzinfo.inspect.task.vo.DutyInspectTaskVO; -import com.xxl.job.core.log.XxlJobLogger; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections4.MapUtils; import org.springblade.core.secure.utils.AuthUtil; import org.springblade.core.tool.api.R; -import org.springblade.core.tool.utils.*; +import org.springblade.core.tool.utils.CollectionUtil; +import org.springblade.core.tool.utils.DateUtil; +import org.springblade.core.tool.utils.ObjectUtil; import org.springblade.system.entity.Dept; -import org.springblade.system.entity.Region; import org.springblade.system.feign.ISysClient; import org.springframework.beans.factory.annotation.Value; import org.springframework.data.redis.core.RedisTemplate; @@ -57,16 +47,10 @@ import org.springframework.stereotype.Service; import javax.validation.constraints.NotNull; import java.math.BigDecimal; import java.math.RoundingMode; -import java.sql.Time; import java.text.SimpleDateFormat; -import java.time.LocalDate; import java.time.LocalDateTime; -import java.time.LocalTime; import java.time.format.DateTimeFormatter; import java.util.*; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; import java.util.stream.Collectors; /** @@ -185,7 +169,7 @@ public class SideHustleServiceImpl implements ISideHustleService { if(MapUtils.isEmpty(map)){ return null; } - Map> powerMap = (Map>) redisTemplate.opsForValue().get(RECENT_YEAR_POWER_DATA); + Map> powerMap = (Map>) redisTemplate.opsForValue().get(RECENT_YEAR_POWER_DATA); List monList = this.getMonthList(0,12,false); // 获取总发电量 float sumPower = this.getSumPower(map.values(),powerMap,monList); @@ -226,7 +210,7 @@ public class SideHustleServiceImpl implements ISideHustleService { // 获取站点7日天气 Map weekWeather = this.weatherService.getWeekWeather( codes); // 近年发电量 - Map> powerMap = (Map>) redisTemplate.opsForValue().get(RECENT_YEAR_POWER_DATA); + Map> powerMap = (Map>) redisTemplate.opsForValue().get(RECENT_YEAR_POWER_DATA); // 计划发电量 List planGenerationList = this.getStaionPlanPower(map); // 站点容量、设备运行情况 @@ -311,7 +295,7 @@ public class SideHustleServiceImpl implements ISideHustleService { * @param powerMap * @return */ - private float getSumPower(Collection> values, Map> powerMap,List monList) { + private float getSumPower(Collection> values, Map> powerMap,List monList) { if(CollectionUtil.isEmpty(values) || MapUtils.isEmpty(powerMap) || CollectionUtil.isEmpty(monList)){ return 0f; } @@ -330,11 +314,11 @@ public class SideHustleServiceImpl implements ISideHustleService { * @param powerMap * @return */ - private float getPower(List list,Map> powerMap,List monList) { + private float getPower(List list,Map> powerMap,List monList) { if(CollectionUtil.isEmpty(list) || MapUtils.isEmpty(powerMap) || CollectionUtil.isEmpty(monList)){ return 0f; } - List stationIdList = list.stream().map(StationEntity::getId).collect(Collectors.toList()); + List stationIdList = list.stream().map(StationEntity::getCode).collect(Collectors.toList()); if(CollectionUtil.isEmpty(stationIdList)){ return 0f; } @@ -344,7 +328,7 @@ public class SideHustleServiceImpl implements ISideHustleService { } float sumPower = 0f; for(Map item : floatList){ - sumPower += item.entrySet().stream().filter(o->monList.contains(o.getKey())).mapToDouble(Map.Entry::getValue).sum(); + sumPower += (float) item.entrySet().stream().filter(o->monList.contains(o.getKey())).mapToDouble(Map.Entry::getValue).sum(); } return sumPower; } @@ -719,7 +703,7 @@ public class SideHustleServiceImpl implements ISideHustleService { @Override public List areaPowerMonth(Long deptId) { // 实际发电量 - Map> powerMap = (Map>) redisTemplate.opsForValue().get(RECENT_YEAR_POWER_DATA); + Map> powerMap = (Map>) redisTemplate.opsForValue().get(RECENT_YEAR_POWER_DATA); // 确定获取数据区域 Map> map = areaService.getAuthArea(null,deptId,Collections.singletonList(HomePageConstant.HYDROPOWER),HomePageConstant.HYDROPOWER_SERVETYPE,true); if (MapUtils.isEmpty(map)) { @@ -756,11 +740,11 @@ public class SideHustleServiceImpl implements ISideHustleService { * @param powerMap * @return */ - private float getStationActualPower(List value, Map> powerMap,String mon) { + private float getStationActualPower(List value, Map> powerMap,String mon) { if(CollectionUtil.isEmpty(value) || MapUtils.isEmpty(powerMap)){ return 0f; } - List stationIdList = value.stream().map(StationEntity::getId).collect(Collectors.toList()); + List stationIdList = value.stream().map(StationEntity::getCode).collect(Collectors.toList()); if(CollectionUtil.isEmpty(stationIdList)){ return 0f; } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/HikVideoServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/HikVideoServiceImpl.java index f3fd0ea..da7ed81 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/HikVideoServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/HikVideoServiceImpl.java @@ -53,6 +53,9 @@ public class HikVideoServiceImpl implements IHikVideoService { String contentType = "application/json"; String resultStr = ArtemisHttpUtil.doPostStringArtemis(path, body, null, null, contentType, null); JSONObject resultObj = JSONObject.parseObject(resultStr); + if(ObjectUtil.isEmpty(resultObj)){ + throw new ServiceException("该平台信息录入有误,无法找到对应点位!"); + } Assert.isTrue("0".equals(resultObj.getString("code")),()-> { throw new ServiceException(resultObj.getString("msg")); }); diff --git a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/standardTicket/service/impl/OperationTicketServiceImpl.java b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/standardTicket/service/impl/OperationTicketServiceImpl.java index 4af840c..34c9db7 100644 --- a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/standardTicket/service/impl/OperationTicketServiceImpl.java +++ b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/standardTicket/service/impl/OperationTicketServiceImpl.java @@ -107,7 +107,7 @@ public class OperationTicketServiceImpl implements OperationTicketService , Star String standardTicketInfoVoBySave = this.saveEntity(JSONObject.toJSONString(standardTicketInfoVo)); //查询流程对应value String dictValue = processDictFeignService.selectDictValueByKey(OPERATION_TICKET_KEY); - if (true){ + if (isOffice){ dictValue = processDictFeignService.selectDictValueByKey(OFFLINE_OPERATION_TICKET); } log.info("查询第操作票值: {}", dictValue); diff --git a/pom.xml b/pom.xml index fdec67f..d36661b 100644 --- a/pom.xml +++ b/pom.xml @@ -15,7 +15,7 @@ 5.1.3.RELEASE.fix2 - 5.2.0.0-SNAPSHOT + 5.1.3.RELEASE.fix3 UTF-8 1.8 UTF-8 @@ -112,11 +112,6 @@ com.hnac.hzims - message-api - ${hzims.project.version} - - - com.hnac.hzims middle-api ${hzims.project.version} @@ -140,11 +135,6 @@ safeproduct-api ${hzims.project.version} - - com.hnac.hzims - topvision-api - ${hzims.project.version} - com.hikvision.ga diff --git a/target/classes/META-INF/build-info.properties b/target/classes/META-INF/build-info.properties new file mode 100644 index 0000000..92baf95 --- /dev/null +++ b/target/classes/META-INF/build-info.properties @@ -0,0 +1,5 @@ +build.artifact=hzims-back +build.group=com.hnac.hzims +build.name=hzims-back +build.time=2024-07-22T06\:45\:56.469Z +build.version=4.0.0-SNAPSHOT