Browse Source

“相关值日统计增加耗能、吨水耗能、千吨水耗能;scada数据存储间隔;新增用户删除超级管理员创建限制;相关值日月季年统计增加耗能、吨水耗能、千吨水耗能;厂站数据查询区分实时历史值”

yangjunfeng 1 year ago
parent
commit
3882490dde

+ 3 - 3
snws-admin/snws-base-service/src/main/java/com/tofly/base/service/impl/UserServiceImpl.java

@@ -551,9 +551,9 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
             return ResultRespone.failed("该用户名【" + user.getUsername() + "】已经存在,不能新增");
         }
 
-        if (CommonConstants.SUPER_ADMIN_ULEVEL.equals(user.getUserLevel())) {
-            return ResultRespone.failed("不能创建超级管理员级别的用户");
-        }
+//        if (CommonConstants.SUPER_ADMIN_ULEVEL.equals(user.getUserLevel())) {
+//            return ResultRespone.failed("不能创建超级管理员级别的用户");
+//        }
 
         if (null != file) {
             StringBuilder fileId = iFileInfoService.saveFile(file, "/base/user/avatar/", "tf_smpn_user_x");

+ 1 - 1
snws-monitor/snws-monitor-boot/src/main/java/com/tofly/monitor/mqtt/ScadaTopicHandler.java

@@ -71,7 +71,7 @@ public class ScadaTopicHandler implements TopicHandler {
                     calendar1.add(Calendar.MINUTE, -Integer.parseInt(IndexTypeTimeWaveEnum.getCodeForValue(String.valueOf(stationIndexVo.getIndexType()))));
                 } else {
                     calendar1.setTime(new Date());
-                    calendar1.add(Calendar.MINUTE, -120);
+                    calendar1.add(Calendar.MINUTE, -60);
                 }
                 if (stationIndexVo.getScadaTime().compareTo(sdf.format(calendar1.getTime())) > 0) {
                     continue;

+ 17 - 0
snws-monitor/snws-monitor-boot/src/main/java/com/tofly/monitor/screenDisplay/entity/TfDayStatistics.java

@@ -111,5 +111,22 @@ public class TfDayStatistics extends Model<TfDayStatistics> {
      */
             @ApiModelProperty(value = "创建人")
                 private Long createUser;
+    /**
+     * 耗能(kw·h)
+     */
+    @ApiModelProperty(value = "耗能(kw·h)")
+    private Double energy;
+
+    /**
+     * 吨水耗电量(kw·h/m³)
+     */
+    @ApiModelProperty(value = "吨水耗电量(kw·h/m³)")
+    private Double energyWater;
+
+    /**
+     * 千吨水耗电量(kw·h/km³)
+     */
+    @ApiModelProperty(value = "千吨水耗电量(kw·h/km³)")
+    private Double energyWaterThousand;
             
 }

+ 24 - 9
snws-monitor/snws-monitor-boot/src/main/java/com/tofly/monitor/screenDisplay/service/impl/CustomDisplayServiceImpl.java

@@ -109,7 +109,7 @@ public class CustomDisplayServiceImpl implements CustomDisplayService {
 
         List<StationInfoVo> stationList = null;
         List<StationIndexVo> stationIndexList = new ArrayList<>();
-        if ( wis.getStartEndTimes() != null && wis.getStartEndTimes().size() != 0) {
+        if (CollUtil.isNotEmpty(wis.getStartEndTimes())) {
             List<StartEndTimeDto> startEndTimes = wis.getStartEndTimes();
             List<StationIndexVo> stationIndexListFinal;
             for (StartEndTimeDto startEndTime : startEndTimes) {
@@ -119,7 +119,11 @@ public class CustomDisplayServiceImpl implements CustomDisplayService {
                 }
                 wis.setStartDate(startEndTime.getStartTime());
                 wis.setEndDate(startEndTime.getEndTime());
-                stationIndexListFinal = customDisplayMapper.viewStatisticsScada(wis);
+                if (wis.getIsHistory().equals("0")) {
+                    stationIndexListFinal = customDisplayMapper.viewStationIndex(wis);
+                } else {
+                    stationIndexListFinal = customDisplayMapper.viewStatisticsScada(wis);
+                }
                 if (CollUtil.isNotEmpty(stationIndexListFinal)) {
                     for (StationIndexVo stationIndexVo : stationIndexListFinal) {
                         stationIndexVo.setStartTime(startEndTime.getStartTime());
@@ -131,7 +135,11 @@ public class CustomDisplayServiceImpl implements CustomDisplayService {
             wis.setStartDate(null);
             wis.setEndDate(null);
         }else {
-            stationIndexList = customDisplayMapper.viewStatisticsScada(wis);
+            if (wis.getIsHistory().equals("0")) {
+                stationIndexList = customDisplayMapper.viewStationIndex(wis);
+            } else {
+                stationIndexList = customDisplayMapper.viewStatisticsScada(wis);
+            }
         }
         switch (queryStationType) {
             case "1":// 污水厂
@@ -213,7 +221,6 @@ public class CustomDisplayServiceImpl implements CustomDisplayService {
             wis.setIsHistory("0");
         }
         if (statisticsType == null) {
-            statisticsType = 0;
             wis.setStatisticsType(0);
         }
         if (StringUtils.isBlank(wis.getIsStatisticsReport())) {
@@ -252,7 +259,7 @@ public class CustomDisplayServiceImpl implements CustomDisplayService {
 
         Page<StationInfoVo> stationPage = new Page<>();
         List<StationIndexVo> stationIndexList = new ArrayList<>();
-        if ( wis.getStartEndTimes() != null && wis.getStartEndTimes().size() != 0) {
+        if (CollUtil.isNotEmpty(wis.getStartEndTimes())) {
             List<StartEndTimeDto> startEndTimes = wis.getStartEndTimes();
             List<StationIndexVo> stationIndexListFinal;
             for (StartEndTimeDto startEndTime : startEndTimes) {
@@ -262,7 +269,11 @@ public class CustomDisplayServiceImpl implements CustomDisplayService {
                 }
                 wis.setStartDate(startEndTime.getStartTime());
                 wis.setEndDate(startEndTime.getEndTime());
-                stationIndexListFinal = customDisplayMapper.viewStatisticsScada(wis);
+                if (wis.getIsHistory().equals("0")) {
+                    stationIndexListFinal = customDisplayMapper.viewStationIndex(wis);
+                } else {
+                    stationIndexListFinal = customDisplayMapper.viewStatisticsScada(wis);
+                }
                 if (CollUtil.isNotEmpty(stationIndexListFinal)) {
                     for (StationIndexVo stationIndexVo : stationIndexListFinal) {
                         stationIndexVo.setStartTime(startEndTime.getStartTime());
@@ -274,7 +285,11 @@ public class CustomDisplayServiceImpl implements CustomDisplayService {
             wis.setStartDate(null);
             wis.setEndDate(null);
         }else {
-            stationIndexList = customDisplayMapper.viewStatisticsScada(wis);
+            if (wis.getIsHistory().equals("0")) {
+                stationIndexList = customDisplayMapper.viewStationIndex(wis);
+            } else {
+                stationIndexList = customDisplayMapper.viewStatisticsScada(wis);
+            }
         }
         switch (queryStationType) {
             case "1":// 污水厂
@@ -294,7 +309,7 @@ public class CustomDisplayServiceImpl implements CustomDisplayService {
     @Override
     public Page<Device> viewDeviceIndexNewPage(Page page, WisdomDisplayDto wis) {
         String queryStationType = wis.getQueryStationType();
-        Long category = 50701L;
+        long category = 50701L;
         if (StringUtils.isBlank(queryStationType)) {
             queryStationType = "1";
             wis.setQueryStationType("1");
@@ -332,7 +347,7 @@ public class CustomDisplayServiceImpl implements CustomDisplayService {
         wis.setDeptStationIds(stationIds);
 
         List<StationIndexVo> stationIndexList = new ArrayList<>();
-        if ( wis.getStartEndTimes() != null && wis.getStartEndTimes().size() != 0) {
+        if (CollUtil.isNotEmpty(wis.getStartEndTimes())) {
             List<StartEndTimeDto> startEndTimes = wis.getStartEndTimes();
             List<StationIndexVo> stationIndexListFinal;
             for (StartEndTimeDto startEndTime : startEndTimes) {

+ 17 - 6
snws-monitor/snws-monitor-boot/src/main/java/com/tofly/monitor/screenDisplay/service/impl/TfDayStatisticsServiceImpl.java

@@ -21,6 +21,7 @@ import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
 import java.math.BigDecimal;
+import java.math.RoundingMode;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.time.LocalDateTime;
@@ -70,15 +71,17 @@ public class TfDayStatisticsServiceImpl extends ServiceImpl<TfDayStatisticsMappe
             dayStatistics.setCreateTime(new Date());
             indexTypeVos.forEach((k1, v1) -> {
                 Double indexSumVal = v1.stream().mapToDouble(s -> Double.parseDouble(s.getItVal())).average().getAsDouble();
+                BigDecimal startVal =  new BigDecimal(v1.get(v1.size() - 1).getItVal());
+                BigDecimal endVal =  new BigDecimal(v1.get(0).getItVal());
                 if (k1 == 28) {
-                    BigDecimal startVal =  new BigDecimal(v1.get(v1.size() - 1).getItVal());
-                    BigDecimal endVal =  new BigDecimal(v1.get(0).getItVal());
-                    if (endVal.compareTo(startVal) < 0) {
-                        dayStatistics.setCumulativeFlow(0.0);
-                    } else {
+                    if (endVal.compareTo(startVal) > 0) {
                         dayStatistics.setCumulativeFlow(endVal.subtract(startVal).doubleValue());
                     }
-                } else if (k1 == 10) {
+                } else if (k1 == 26) {
+                    if (endVal.compareTo(startVal) > 0) {
+                        dayStatistics.setEnergy(endVal.subtract(startVal).doubleValue());
+                    }
+                }else if (k1 == 10) {
                     dayStatistics.setCod(indexSumVal);
                 } else if (k1 == 34) {
                     dayStatistics.setSs(indexSumVal);
@@ -92,6 +95,14 @@ public class TfDayStatisticsServiceImpl extends ServiceImpl<TfDayStatisticsMappe
                     dayStatistics.setTn(indexSumVal);
                 }
             });
+            if (dayStatistics.getEnergy() != null
+                    && dayStatistics.getCumulativeFlow() != null
+                    && dayStatistics.getCumulativeFlow() != 0) {
+                BigDecimal energy = BigDecimal.valueOf(dayStatistics.getEnergy());
+                BigDecimal cumulativeFlow = BigDecimal.valueOf(dayStatistics.getCumulativeFlow());
+                dayStatistics.setEnergyWater(energy.divide(cumulativeFlow,4, RoundingMode.HALF_UP).doubleValue());
+                dayStatistics.setEnergyWaterThousand(energy.divide(cumulativeFlow,7, RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(1000)).doubleValue());
+            }
             dayStatisticsList.add(dayStatistics);
         });
         this.remove(new QueryWrapper<TfDayStatistics>().lambda().between(TfDayStatistics::getCensusTime,startDate,endDate));

+ 20 - 5
snws-monitor/snws-monitor-boot/src/main/resources/mapper/screenDisplay/CustomDisplayMapper.xml

@@ -609,7 +609,10 @@
                 case WHEN(ISNULL(COUNT(*), 0)) != 0 THEN round(SUM( PH ) / COUNT(*),2) ELSE 0 END PH,
                 case WHEN(ISNULL(COUNT(*), 0)) != 0 THEN round(SUM( NH3N ) / COUNT(*),2) ELSE 0 END NH3N,
                 case WHEN(ISNULL(COUNT(*), 0)) != 0 THEN round(SUM( TP ) / COUNT(*),2) ELSE 0 END TP,
-                case WHEN(ISNULL(COUNT(*), 0)) != 0 THEN round(SUM( TN ) / COUNT(*),2) ELSE 0 END TN
+                case WHEN(ISNULL(COUNT(*), 0)) != 0 THEN round(SUM( TN ) / COUNT(*),2) ELSE 0 END TN,
+                ISNULL(SUM ( energy ), 0) energy,
+                ISNULL(SUM ( energy_water ), 0) energy_water,
+                ISNULL(SUM ( energy_water_thousand ), 0) energy_water_thousand
         from tf_day_statistics
         WHERE
         1=1
@@ -631,7 +634,10 @@
                ISNULL(nh3n, 0) nh3n,
                ISNULL(tp, 0) tp,
                ISNULL(tn, 0) tn,
-               ISNULL(report_num, 0) report_num
+               ISNULL(report_num, 0) report_num,
+               ISNULL(energy, 0) energy,
+               ISNULL(energy_water, 0) energy_water,
+               ISNULL(energy_water_thousand, 0) energy_water_thousand
         from tf_day_statistics
         WHERE
         1=1
@@ -658,7 +664,10 @@
         case WHEN(ISNULL(COUNT(*), 0)) != 0 THEN round(SUM( PH ) / COUNT(*),2) ELSE 0 END PH,
         case WHEN(ISNULL(COUNT(*), 0)) != 0 THEN round(SUM( NH3N ) / COUNT(*),2) ELSE 0 END NH3N,
         case WHEN(ISNULL(COUNT(*), 0)) != 0 THEN round(SUM( TP ) / COUNT(*),2) ELSE 0 END TP,
-        case WHEN(ISNULL(COUNT(*), 0)) != 0 THEN round(SUM( TN ) / COUNT(*),2) ELSE 0 END TN
+        case WHEN(ISNULL(COUNT(*), 0)) != 0 THEN round(SUM( TN ) / COUNT(*),2) ELSE 0 END TN,
+        ISNULL(SUM ( energy ), 0) energy,
+        ISNULL(SUM ( energy_water ), 0) energy_water,
+        ISNULL(SUM ( energy_water_thousand ), 0) energy_water_thousand
         from tf_day_statistics
         WHERE
         1=1
@@ -686,7 +695,10 @@
                 case WHEN(ISNULL(COUNT(*), 0)) != 0 THEN round(SUM( PH ) / COUNT(*),2) ELSE 0 END PH,
                 case WHEN(ISNULL(COUNT(*), 0)) != 0 THEN round(SUM( NH3N ) / COUNT(*),2) ELSE 0 END NH3N,
                 case WHEN(ISNULL(COUNT(*), 0)) != 0 THEN round(SUM( TP ) / COUNT(*),2) ELSE 0 END TP,
-                case WHEN(ISNULL(COUNT(*), 0)) != 0 THEN round(SUM( TN ) / COUNT(*),2) ELSE 0 END TN
+                case WHEN(ISNULL(COUNT(*), 0)) != 0 THEN round(SUM( TN ) / COUNT(*),2) ELSE 0 END TN,
+                ISNULL(SUM ( energy ), 0) energy,
+                ISNULL(SUM ( energy_water ), 0) energy_water,
+                ISNULL(SUM ( energy_water_thousand ), 0) energy_water_thousand
         from tf_day_statistics
         WHERE
             1=1
@@ -714,7 +726,10 @@
                 case WHEN(ISNULL(COUNT(*), 0)) != 0 THEN round(SUM( PH ) / COUNT(*),2) ELSE 0 END PH,
                 case WHEN(ISNULL(COUNT(*), 0)) != 0 THEN round(SUM( NH3N ) / COUNT(*),2) ELSE 0 END NH3N,
                 case WHEN(ISNULL(COUNT(*), 0)) != 0 THEN round(SUM( TP ) / COUNT(*),2) ELSE 0 END TP,
-                case WHEN(ISNULL(COUNT(*), 0)) != 0 THEN round(SUM( TN ) / COUNT(*),2) ELSE 0 END TN
+                case WHEN(ISNULL(COUNT(*), 0)) != 0 THEN round(SUM( TN ) / COUNT(*),2) ELSE 0 END TN,
+                ISNULL(SUM ( energy ), 0) energy,
+                ISNULL(SUM ( energy_water ), 0) energy_water,
+                ISNULL(SUM ( energy_water_thousand ), 0) energy_water_thousand
         from tf_day_statistics
         WHERE
         1=1

+ 3 - 0
snws-monitor/snws-monitor-boot/src/main/resources/mapper/screenDisplay/TfDayStatisticsMapper.xml

@@ -17,6 +17,9 @@
                       <result property="nh3n" column="NH3N"/>
                       <result property="tp" column="TP"/>
                       <result property="tn" column="TN"/>
+                      <result property="energy" column="energy"/>
+                      <result property="energyWater" column="energy_water"/>
+                      <result property="energyWaterThousand" column="energy_water_thousand"/>
                       <result property="reportNum" column="report_num"/>
                       <result property="createTime" column="create_time"/>
                       <result property="createUser" column="create_user"/>