Преглед изворни кода

Merge remote-tracking branch 'origin/master'

wangbo пре 4 година
родитељ
комит
e6612efe4e
23 измењених фајлова са 106 додато и 59 уклоњено
  1. 29 0
      sms_water/src/main/java/com/huaxu/common/converter/Double1Serializer.java
  2. 3 2
      sms_water/src/main/java/com/huaxu/dto/DispatchSummaryDto.java
  3. 4 0
      sms_water/src/main/java/com/huaxu/dto/ReportDto.java
  4. 8 8
      sms_water/src/main/java/com/huaxu/dto/generalView/DeviceWaterAmount.java
  5. 1 1
      sms_water/src/main/java/com/huaxu/dto/generalView/DeviceWaterDetail.java
  6. 1 1
      sms_water/src/main/java/com/huaxu/dto/generalView/DeviceWaterSupply.java
  7. 1 1
      sms_water/src/main/java/com/huaxu/dto/generalView/SceneWaterAmount.java
  8. 8 15
      sms_water/src/main/java/com/huaxu/dto/generalView/SceneWaterPressure.java
  9. 3 3
      sms_water/src/main/java/com/huaxu/dto/generalView/WaterSupplyChart.java
  10. 10 5
      sms_water/src/main/java/com/huaxu/rabbitmq/ReceiveData.java
  11. 1 0
      sms_water/src/main/java/com/huaxu/service/DayReportService.java
  12. 1 0
      sms_water/src/main/java/com/huaxu/service/MonthReportService.java
  13. 1 0
      sms_water/src/main/java/com/huaxu/service/YearReportService.java
  14. 12 5
      sms_water/src/main/java/com/huaxu/service/impl/AlarmDetailsServiceImpl.java
  15. 6 10
      sms_water/src/main/java/com/huaxu/service/impl/OnlineMonitorImpl.java
  16. 1 1
      sms_water/src/main/resources/mapper/DayReportMapper.xml
  17. 5 1
      sms_water/src/main/resources/mapper/DeviceParmMapper.xml
  18. 1 1
      sms_water/src/main/resources/mapper/MonthReportMapper.xml
  19. 1 1
      sms_water/src/main/resources/mapper/YearReportMapper.xml
  20. 1 3
      user_auth/src/main/java/com/huaxu/controller/UserController.java
  21. 1 0
      user_auth/src/main/java/com/huaxu/entity/User.java
  22. 5 0
      user_auth/src/main/java/com/huaxu/service/impl/UserServiceImpl.java
  23. 2 1
      user_auth/src/main/resources/mapper/UserMapper.xml

+ 29 - 0
sms_water/src/main/java/com/huaxu/common/converter/Double1Serializer.java

@@ -0,0 +1,29 @@
+package com.huaxu.common.converter;
+
+import com.fasterxml.jackson.core.JsonGenerator;
+import com.fasterxml.jackson.databind.JsonSerializer;
+import com.fasterxml.jackson.databind.SerializerProvider;
+
+import java.io.IOException;
+import java.text.DecimalFormat;
+
+public class Double1Serializer extends JsonSerializer<Double> {
+
+    private DecimalFormat df = new DecimalFormat("0.#");
+
+    /**
+     * 小数保留1位返回给前端序列化器
+     * @param data
+     * @param jsonGenerator
+     * @param serializerProvider
+     * @throws IOException
+     */
+    @Override
+    public void serialize(Double data, JsonGenerator jsonGenerator, SerializerProvider serializerProvider)
+            throws IOException {
+        if (data != null) {
+            jsonGenerator.writeNumber(df.format(data));
+        }
+    }
+
+}

+ 3 - 2
sms_water/src/main/java/com/huaxu/dto/DispatchSummaryDto.java

@@ -3,6 +3,7 @@ package com.huaxu.dto;
 import com.fasterxml.jackson.annotation.JsonFormat;
 import com.fasterxml.jackson.annotation.JsonIgnore;
 import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.huaxu.common.converter.Double1Serializer;
 import com.huaxu.common.converter.Double3Serializer;
 import com.huaxu.model.ProgramItem;
 import io.swagger.annotations.ApiModel;
@@ -34,11 +35,11 @@ public class DispatchSummaryDto {
     @ApiModelProperty("总能耗")
     private Double powerUsage;
 
-    @JsonSerialize(using = Double3Serializer.class)
+    @JsonSerialize(using = Double1Serializer.class)
     @ApiModelProperty("压力合格率")
     private Double presQualifiedRate;
 
-   @JsonSerialize(using = Double3Serializer.class)
+   @JsonSerialize(using = Double1Serializer.class)
     @ApiModelProperty("水质合格率")
     private Double waterQualifiedRate;
 

+ 4 - 0
sms_water/src/main/java/com/huaxu/dto/ReportDto.java

@@ -27,6 +27,10 @@ public class ReportDto implements Serializable {
     private Integer hour;
     @ApiModelProperty("一级场景信息")
     private Integer parentSceneId;
+    /** 一级场景s */
+    @JsonIgnore
+    @ApiModelProperty(value = "一级场景IDS")
+    private Long[] parentSceneIds;
     @ApiModelProperty("一级场景名称")
     private String parentSceneName;
     @ApiModelProperty("今日供水量or今日出水量")

+ 8 - 8
sms_water/src/main/java/com/huaxu/dto/generalView/DeviceWaterAmount.java

@@ -22,29 +22,29 @@ public class DeviceWaterAmount implements Serializable {
 
     @ApiModelProperty("供水瞬时流量")
     @JsonSerialize(using = BigDecimalJsonSerializer.class)
-    private BigDecimal waterSupplyAmountForNow;
+    private BigDecimal waterSupplyAmountForNow = BigDecimal.ZERO;
     @ApiModelProperty("本日供水量")
     @JsonSerialize(using = BigDecimalJsonSerializer.class)
-    private BigDecimal waterSupplyAmountForDay;
+    private BigDecimal waterSupplyAmountForDay = BigDecimal.ZERO;
     @ApiModelProperty("本月供水量")
     @JsonSerialize(using = BigDecimalJsonSerializer.class)
-    private BigDecimal waterSupplyAmountForMonth;
+    private BigDecimal waterSupplyAmountForMonth = BigDecimal.ZERO;
     @ApiModelProperty("本年供水量")
     @JsonSerialize(using = BigDecimalJsonSerializer.class)
-    private BigDecimal waterSupplyAmountForYear;
+    private BigDecimal waterSupplyAmountForYear = BigDecimal.ZERO;
 
     @ApiModelProperty("原水瞬时流量")
     @JsonSerialize(using = BigDecimalJsonSerializer.class)
-    private BigDecimal waterIntakeAmountForNow;
+    private BigDecimal waterIntakeAmountForNow = BigDecimal.ZERO;
     @ApiModelProperty("本日原水量")
     @JsonSerialize(using = BigDecimalJsonSerializer.class)
-    private BigDecimal waterIntakeAmountForDay;
+    private BigDecimal waterIntakeAmountForDay = BigDecimal.ZERO;
     @ApiModelProperty("本月原水量")
     @JsonSerialize(using = BigDecimalJsonSerializer.class)
-    private BigDecimal waterIntakeAmountForMonth;
+    private BigDecimal waterIntakeAmountForMonth = BigDecimal.ZERO;
     @ApiModelProperty("本年原水量")
     @JsonSerialize(using = BigDecimalJsonSerializer.class)
-    private BigDecimal waterIntakeAmountForYear;
+    private BigDecimal waterIntakeAmountForYear = BigDecimal.ZERO;
 
     //3供水
     public void addWaterSupplyAmountForNow(BigDecimal amount){

+ 1 - 1
sms_water/src/main/java/com/huaxu/dto/generalView/DeviceWaterDetail.java

@@ -30,7 +30,7 @@ public class DeviceWaterDetail implements Serializable {
     private Integer parmType;
     @ApiModelProperty("值")
     @JsonSerialize(using = BigDecimalJsonSerializer.class)
-    private BigDecimal amount;
+    private BigDecimal amount = BigDecimal.ZERO;
     @ApiModelProperty("最后抄表数据")
     private BigDecimal latestValue;
 }

+ 1 - 1
sms_water/src/main/java/com/huaxu/dto/generalView/DeviceWaterSupply.java

@@ -30,7 +30,7 @@ public class DeviceWaterSupply implements Serializable {
     private Integer day;
     @ApiModelProperty("量")
     @JsonSerialize(using = BigDecimalJsonSerializer.class)
-    private BigDecimal amount;
+    private BigDecimal amount = BigDecimal.ZERO;
     @ApiModelProperty("日期")
     private LocalDate date;
 

+ 1 - 1
sms_water/src/main/java/com/huaxu/dto/generalView/SceneWaterAmount.java

@@ -23,5 +23,5 @@ public class SceneWaterAmount implements Serializable {
     private String sceneName;
     @ApiModelProperty("水量")
     @JsonSerialize(using = BigDecimalJsonSerializer.class)
-    private BigDecimal waterAmount;
+    private BigDecimal waterAmount = BigDecimal.ZERO;
 }

+ 8 - 15
sms_water/src/main/java/com/huaxu/dto/generalView/SceneWaterPressure.java

@@ -22,15 +22,15 @@ public class SceneWaterPressure implements Serializable {
     private static final long serialVersionUID = -2156183545580875355L;
 
     @ApiModelProperty("一级压力数量,<0.15")
-    private Integer pressureLevel1;
+    private Integer pressureLevel1 = 0;
     @ApiModelProperty("一级压力数量,0.15<=0.30")
-    private Integer pressureLevel2;
+    private Integer pressureLevel2 = 0;
     @ApiModelProperty("一级压力数量,0.30<=0.40")
-    private Integer pressureLevel3;
+    private Integer pressureLevel3 = 0;
     @ApiModelProperty("一级压力数量,0.40<=0.50")
-    private Integer pressureLevel4;
+    private Integer pressureLevel4 = 0;
     @ApiModelProperty("一级压力数量,>0.50")
-    private Integer pressureLevel5;
+    private Integer pressureLevel5 = 0;
 
     @ApiModelProperty("各级压力数量")
     private List<Integer> pressureLevels;
@@ -38,21 +38,14 @@ public class SceneWaterPressure implements Serializable {
     private String minPressureSceneName;
     @ApiModelProperty("最小压力值")
     @JsonSerialize(using = BigDecimalJsonSerializer.class)
-    private BigDecimal minPressureValue;
+    private BigDecimal minPressureValue = BigDecimal.ZERO;
     @ApiModelProperty("最大压力场景名称")
     private String maxPressureSceneName;
     @ApiModelProperty("最大压力值")
     @JsonSerialize(using = BigDecimalJsonSerializer.class)
-    private BigDecimal maxPressureValue;
+    private BigDecimal maxPressureValue = BigDecimal.ZERO;
     @ApiModelProperty("平均压力值")
     @JsonSerialize(using = BigDecimalJsonSerializer.class)
-    private BigDecimal avgPressureValue;
+    private BigDecimal avgPressureValue = BigDecimal.ZERO;
 
-    public SceneWaterPressure(){
-        this.pressureLevel1=0;
-        this.pressureLevel2=0;
-        this.pressureLevel3=0;
-        this.pressureLevel4=0;
-        this.pressureLevel5=0;
-    }
 }

+ 3 - 3
sms_water/src/main/java/com/huaxu/dto/generalView/WaterSupplyChart.java

@@ -31,13 +31,13 @@ public class WaterSupplyChart implements Serializable {
     private String date;
     @ApiModelProperty("制水量")
     @JsonSerialize(using = BigDecimalJsonSerializer.class)
-    private BigDecimal waterData;
+    private BigDecimal waterData = BigDecimal.ZERO;
     @ApiModelProperty("电耗")
     @JsonSerialize(using = BigDecimalJsonSerializer.class)
-    private BigDecimal powerData;
+    private BigDecimal powerData = BigDecimal.ZERO;
     @ApiModelProperty("药耗")
     @JsonSerialize(using = BigDecimalJsonSerializer.class)
-    private BigDecimal drugData;
+    private BigDecimal drugData = BigDecimal.ZERO;
 
 
     public WaterSupplyChart (){ }

+ 10 - 5
sms_water/src/main/java/com/huaxu/rabbitmq/ReceiveData.java

@@ -206,11 +206,16 @@ public class ReceiveData {
                            Integer companyOrgId = deviceCheckAlarmDto.getCompanyOrgId();
                            Integer departmentOrgId = deviceCheckAlarmDto.getDeptOrgId();
                            List<Integer> taskUsers = userCenterClient.findUserIdsByPermissonOrg(deviceCheckAlarmDto.getTenantId(),companyOrgId,departmentOrgId);
-                           if(taskUsers!=null){
-                               taskUsers.forEach(id->{
-                                   message.setUserId(id);
-                                   messageSendUtil.send(message);
-                               });
+                           try{
+                               if(taskUsers!=null){
+                                   taskUsers.forEach(id->{
+                                       message.setUserId(id);
+                                       messageSendUtil.send(message);
+                                   });
+                               }
+                           }catch(Exception e){
+                               e.printStackTrace();
+                               log.info("推送报警消息失败:{}",e.getMessage());
                            }
 
                            insert.add(alarmDetailsEntity);

+ 1 - 0
sms_water/src/main/java/com/huaxu/service/DayReportService.java

@@ -94,6 +94,7 @@ public class DayReportService extends ServiceImpl<DayReportMapper, DayReportEnti
             reportDto.setMonth(month);
             reportDto.setDay(day);
             reportDto.setDeviceIds(devices);
+            reportDto.setParentSceneIds(ids);
             List<ReportAttributeDto> reportAttributeDtos2 = deviceParmService.findAttributeNameList(reportDto);
             List<String> dataTitle = new ArrayList<>();
             Map<String, Integer> mapsTitle = new LinkedHashMap<>();

+ 1 - 0
sms_water/src/main/java/com/huaxu/service/MonthReportService.java

@@ -87,6 +87,7 @@ public class MonthReportService extends ServiceImpl<MonthReportMapper, MonthRepo
             reportDto.setYear(year);
             reportDto.setMonth(month);
             reportDto.setDeviceIds(devices);
+            reportDto.setParentSceneIds(ids);
             List<ReportAttributeDto> reportAttributeDtos2 = deviceParmService.findAttributeNameList(reportDto);
             List<String> dataTitle = new ArrayList<>();
             Map<String, Integer> mapsTitle = new LinkedHashMap<>();

+ 1 - 0
sms_water/src/main/java/com/huaxu/service/YearReportService.java

@@ -87,6 +87,7 @@ public class YearReportService extends ServiceImpl<YearReportMapper, YearReportE
             ReportDto reportDto = new ReportDto();
             reportDto.setYear(year);
             reportDto.setDeviceIds(devices);
+            reportDto.setParentSceneIds(ids);
             List<ReportAttributeDto> reportAttributeDtos2 = deviceParmService.findAttributeNameList(reportDto);
             List<String> dataTitle = new ArrayList<>();
             Map<String, Integer> mapsTitle = new LinkedHashMap<>();

+ 12 - 5
sms_water/src/main/java/com/huaxu/service/impl/AlarmDetailsServiceImpl.java

@@ -13,6 +13,7 @@ import com.huaxu.service.AlarmDetailsService;
 import com.huaxu.util.DatesUtil;
 import com.huaxu.util.MessageSendUtil;
 import com.huaxu.util.UserUtil;
+import lombok.extern.log4j.Log4j2;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -27,6 +28,7 @@ import java.util.stream.Collectors;
  * @data 2020-11-17 15:48
  */
 @Service
+@Log4j2
 public class AlarmDetailsServiceImpl implements AlarmDetailsService {
 
     @Resource
@@ -208,11 +210,16 @@ public class AlarmDetailsServiceImpl implements AlarmDetailsService {
                     Integer companyOrgId = d.getCompanyOrgId();
                     Integer departmentOrgId = d.getDeptOrgId();
                     List<Integer> taskUsers = userCenterClient.findUserIdsByPermissonOrg(d.getTenantId(),companyOrgId,departmentOrgId);
-                    if(taskUsers!=null){
-                        taskUsers.forEach(id->{
-                            message.setUserId(id);
-                            messageSendUtil.send(message);
-                        });
+                    try{
+                        if(taskUsers!=null){
+                            taskUsers.forEach(id->{
+                                message.setUserId(id);
+                                messageSendUtil.send(message);
+                            });
+                        }
+                    }catch(Exception e){
+                        e.printStackTrace();
+                        log.info("推送报警消息失败:{}"+e.getMessage());
                     }
                     return alarmDetailsEntity;
                 })

+ 6 - 10
sms_water/src/main/java/com/huaxu/service/impl/OnlineMonitorImpl.java

@@ -267,10 +267,7 @@ public class OnlineMonitorImpl implements OnlineMonitorService {
         //1是公司,2是公司及以下,3部门,4部门及以下,5自定义
         onlineDataDto.setPermissonType(loginUser.getPermissonType());
 
-        int[] deviceCount=new int[6];
-        if(onlineDataDto.getSceneTypeName().equals("压力")){
-            deviceCount=new int[5];
-        }
+        int[] deviceCount=new int[5];
         int count=0;
         Double sumValue=null,maxValue=null,minValue=null;
         String maxDeviceName=null,minDeviceName=null;
@@ -324,18 +321,16 @@ public class OnlineMonitorImpl implements OnlineMonitorService {
                                    deviceCount[4]++;
                                }
                            }else if(onlineDataDto.getSceneTypeName().equals("流量")){
-                               if(dataValue>=0&&dataValue<=100){
+                               if(dataValue<=0){
                                    deviceCount[0]++;
                                }else if(dataValue<=200) {
                                    deviceCount[1]++;
-                               }else if(dataValue<=300) {
-                                   deviceCount[2]++;
                                }else if(dataValue<=400) {
+                                   deviceCount[2]++;
+                               }else if(dataValue<=600) {
                                    deviceCount[3]++;
-                               }else if(dataValue<=500) {
+                               }else if(dataValue>600) {
                                    deviceCount[4]++;
-                               }else if(dataValue>500) {
-                                   deviceCount[5]++;
                                }
                            }
                        }
@@ -343,6 +338,7 @@ public class OnlineMonitorImpl implements OnlineMonitorService {
                 }
             }
         }
+        deviceCount[0]=result.size()-deviceCount[1]-deviceCount[2]-deviceCount[3]-deviceCount[4];
         DistributeIntervalDto distributeIntervalDto=new DistributeIntervalDto();
         distributeIntervalDto.setDistributeValue(deviceCount);
         distributeIntervalDto.setAvgValue(count==0?null:sumValue/count);

+ 1 - 1
sms_water/src/main/resources/mapper/DayReportMapper.xml

@@ -244,7 +244,7 @@
         FROM sms_day_report a
         inner join sms_device d on d.id = a.DEVICE_ID
         inner join sms_device_parm b on a.DEVICE_ID = b.DEVICE_ID and a.ATTRIBUTE_ID=b.ATTRIBUTE_ID and b.`STATUS`=1
-            and (b.PARM_TYPE = 7 or b.PARM_TYPE = 10  or b.PARM_TYPE = 11)
+            and (b.PARM_TYPE = 7 or b.PARM_TYPE = 9  or b.PARM_TYPE = 11)
         <where>
             <if test="dayReport.tenantId != null  and dayReport.tenantId != ''">and a.tenant_id =
                 #{dayReport.tenantId}

+ 5 - 1
sms_water/src/main/resources/mapper/DeviceParmMapper.xml

@@ -205,13 +205,17 @@
         FROM sms_device_parm a
         INNER JOIN sms_device_attribute b on a.ATTRIBUTE_ID=b.ID
         where
-        a.IS_REPORT=1
+        a.IS_REPORT=1 and a.status=1
         <if test="report.deviceIds != null and report.deviceIds.size() > 0">
             and a.DEVICE_ID in
             <foreach collection="report.deviceIds" item="dramaId" open="(" close=")" separator=",">
                 #{dramaId.id}
             </foreach>
         </if>
+        and a.PARENT_SCENE_ID in
+        <foreach collection="report.parentSceneIds" item="dramaId" open="(" close=")" separator=",">
+            #{dramaId}
+        </foreach>
         ORDER BY a.SEQ
         ) as tab
     </select>

+ 1 - 1
sms_water/src/main/resources/mapper/MonthReportMapper.xml

@@ -239,7 +239,7 @@
         FROM sms_month_report a
         inner join sms_device d on d.id = a.DEVICE_ID
         inner join sms_device_parm b on a.DEVICE_ID = b.DEVICE_ID and a.ATTRIBUTE_ID=b.ATTRIBUTE_ID and b.`STATUS`=1
-        and (b.PARM_TYPE = 7 or b.PARM_TYPE = 10  or b.PARM_TYPE = 11)
+        and (b.PARM_TYPE = 7 or b.PARM_TYPE = 9  or b.PARM_TYPE = 11)
         <where>
             <if test="monthReport.tenantId != null  and monthReport.tenantId != ''">and a.tenant_id =
                 #{monthReport.tenantId}

+ 1 - 1
sms_water/src/main/resources/mapper/YearReportMapper.xml

@@ -236,7 +236,7 @@
         FROM sms_year_report a
         inner join sms_device d on d.id = a.DEVICE_ID
         inner join sms_device_parm b on a.DEVICE_ID = b.DEVICE_ID and a.ATTRIBUTE_ID=b.ATTRIBUTE_ID and b.`STATUS`=1
-        and (b.PARM_TYPE = 7 or b.PARM_TYPE = 10  or b.PARM_TYPE = 11)
+        and (b.PARM_TYPE = 7 or b.PARM_TYPE = 9  or b.PARM_TYPE = 11)
         <where>
             <if test="yearReport.tenantId != null  and yearReport.tenantId != ''">and a.tenant_id =
                 #{yearReport.tenantId}

+ 1 - 3
user_auth/src/main/java/com/huaxu/controller/UserController.java

@@ -139,9 +139,7 @@ public class UserController {
         ||bytes4!=null){
             return null;
         }
-       /* String authorization = request.getHeader("Authorization");
-        String token =authorization.substring(authorization.indexOf("Bearer")+6).trim();
-        redisUtil.setExpire("auth:"+token,60000);
+        /*redisUtil.setExpire("auth:"+token,60000);
         redisUtil.setExpire("access:"+token,60000);*/
         return principal;
     }

+ 1 - 0
user_auth/src/main/java/com/huaxu/entity/User.java

@@ -100,5 +100,6 @@ public class User implements Serializable {
     private Integer companyOrgState;
     private String token;
     private Integer roleState;
+    private Integer tenantState;
 
 }

+ 5 - 0
user_auth/src/main/java/com/huaxu/service/impl/UserServiceImpl.java

@@ -197,6 +197,7 @@ public class UserServiceImpl implements UserService {
         UserDto userDto=new UserDto();
         userDto.setPhone(user.getPhone());
 
+
        List<ProgramItem>programItems=new ArrayList<>();
 
         Permission permission= findPermission(user);
@@ -207,6 +208,10 @@ public class UserServiceImpl implements UserService {
             returnFlag=true;
 
         }
+        if((user.getTenantState()!=null&&user.getTenantState()==0)){
+            user.setEnableState("0");
+            returnFlag=true;
+        }
         if((user.getCompanyOrgState()!=null&&user.getCompanyOrgState()==0)){
             user.setEnableState("0");
             returnFlag=true;

+ 2 - 1
user_auth/src/main/resources/mapper/UserMapper.xml

@@ -23,6 +23,7 @@
         <result property="webUrl" column="WEB_URL" jdbcType="VARCHAR"/>
         <result property="companyOrgState" column="companyOrgState" jdbcType="INTEGER"/>
         <result property="departmentOrgState" column="departmentOrgState" jdbcType="INTEGER"/>
+        <result property="tenantState" column="TENANT_STATE" jdbcType="INTEGER"/>
     </resultMap>
 
 
@@ -49,7 +50,7 @@
     <!--通过实体作为筛选条件查询-->
     <select id="selectList" resultMap="UserMap">
         select
-        a.*, b.LOGO,b.WEB_URL ,c.ORG_STATE companyOrgState,d.ORG_STATE departmentOrgState
+       b.TENANT_STATE, a.*, b.LOGO,b.WEB_URL ,c.ORG_STATE companyOrgState,d.ORG_STATE departmentOrgState
         from uims_user a join uims_tenant b on a.TENANT_ID=b.CODE
         join uims_org c on a.COMPANY_ORG_ID=c.id left join
         uims_org d on a.DEPT_ORG_ID=d.ID