lihui001 3 роки тому
батько
коміт
1390eb8f19

+ 9 - 3
zoniot-water/zoniot-water-api/src/main/java/com/bz/zoneiot/water/api/vo/AlarmTypeVo.java

@@ -23,7 +23,7 @@ public class AlarmTypeVo {
     @ApiModelProperty(value="产品名字")
     private String productName;
 
-    @ApiModelProperty(value="产品名字")
+    @ApiModelProperty(value="设备名字")
     private String deviceName;
 
     @ApiModelProperty(value="产品Id")
@@ -32,8 +32,8 @@ public class AlarmTypeVo {
     @ApiModelProperty(value="名称")
     private String alarmName;
 
-    @ApiModelProperty(value="code")
-    private String code;
+    @ApiModelProperty(value="属性Id")
+    private Long attributeId;
 
     @ApiModelProperty(value="描述")
     private String desc;
@@ -47,6 +47,12 @@ public class AlarmTypeVo {
     @ApiModelProperty(value="告警规则数量")
     private Integer alarmRuleNum;
 
+    @ApiModelProperty(value="天")
+    private String days;
+
+    @ApiModelProperty(value="时段")
+    private String times;
+
     @ApiModelProperty(value="告警规则")
     private List<AlarmRuleVo> rules;
 }

+ 9 - 0
zoniot-water/zoniot-water-core/src/main/java/com/bz/zoneiot/water/core/dao/AlarmTypeMapper.java

@@ -44,6 +44,15 @@ public interface AlarmTypeMapper {
     **/
     AlarmType findById(@Param("id") Integer id);
 
+    /**
+     * 根据ID查找
+     * @author Andy
+     * @date 18:44 2021/8/3
+     * @param id:
+     * @return com.bz.zoniot.system.entity.AlarmType
+     **/
+    AlarmTypeVo findAlarmProductInfoById(@Param("id") Integer id);
+
     /**
     * 查找设备ID
     * @author Andy

+ 234 - 222
zoniot-water/zoniot-water-core/src/main/java/com/bz/zoneiot/water/core/mapper/AlarmTypeMapper.xml

@@ -33,242 +33,254 @@
     </if>
   </sql>
 
-    <sql id="Base_Column_List">
-      <!--@mbg.generated-->
-      id, tenant_id, company_org_id, dept_org_id, product_id, `name`, attribute_id, `desc`, alarm_category, enabled,
-      alarm_rule_num, days, times,`status`, create_date, create_by, update_date, update_by, iot_alarm_id
-    </sql>
-    <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.bz.zoneiot.water.core.entity.AlarmType" useGeneratedKeys="true">
-      <!--@mbg.generated-->
-      insert into sms_alarm_type
-      <trim prefix="(" suffix=")" suffixOverrides=",">
-        <if test="tenantId != null">
-          tenant_id,
-        </if>
-        <if test="attributeId != null">
-          attribute_id,
-        </if>
-        <if test="customerId != null">
-          customer_id,
-        </if>
-        <if test="sceneType != null">
-          scene_type,
-        </if>
-        <if test="deviceId != null">
-          device_id,
-        </if>
-        <if test="iotAlarmId != null">
-          iot_alarm_id,
-        </if>
-        <if test="companyOrgId != null">
-          company_org_id,
-        </if>
-        <if test="deptOrgId != null">
-          dept_org_id,
-        </if>
-        <if test="productId != null">
-          product_id,
-        </if>
-        <if test="name != null">
-          `name`,
-        </if>
-        <if test="code != null">
-          code,
-        </if>
-        <if test="desc != null">
-          `desc`,
-        </if>
-        <if test="days != null">
-          `days`,
-        </if>
-        <if test="times != null">
-          `times`,
-        </if>
-        <if test="alarmCategory != null">
-          alarm_category,
-        </if>
-        <if test="enabled != null">
-          enabled,
-        </if>
-        <if test="alarmRuleNum != null">
-          alarm_rule_num,
-        </if>
-        <if test="status != null">
-          `status`,
-        </if>
-        <if test="createDate != null">
-          create_date,
-        </if>
-        <if test="createBy != null">
-          create_by,
-        </if>
-        <if test="updateDate != null">
-          update_date,
-        </if>
-        <if test="updateBy != null">
-          update_by,
-        </if>
-      </trim>
-      <trim prefix="values (" suffix=")" suffixOverrides=",">
-        <if test="tenantId != null">
-          #{tenantId},
-        </if>
-        <if test="attributeId != null">
-          #{attributeId},
-        </if>
-        <if test="customerId != null">
-          #{customerId},
-        </if>
-        <if test="sceneType != null">
-          #{sceneType},
-        </if>
-        <if test="deviceId != null">
-          #{deviceId},
-        </if>
-        <if test="iotAlarmId != null">
-          #{iotAlarmId},
-        </if>
-        <if test="companyOrgId != null">
-          #{companyOrgId},
-        </if>
+  <sql id="Base_Column_List">
+    <!--@mbg.generated-->
+    id, tenant_id, company_org_id, dept_org_id, product_id, `name`, attribute_id, `desc`, alarm_category, enabled,
+    alarm_rule_num, days, times,`status`, create_date, create_by, update_date, update_by, iot_alarm_id
+  </sql>
+  <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.bz.zoneiot.water.core.entity.AlarmType" useGeneratedKeys="true">
+    <!--@mbg.generated-->
+    insert into sms_alarm_type
+    <trim prefix="(" suffix=")" suffixOverrides=",">
+      <if test="tenantId != null">
+        tenant_id,
+      </if>
+      <if test="attributeId != null">
+        attribute_id,
+      </if>
+      <if test="customerId != null">
+        customer_id,
+      </if>
+      <if test="sceneType != null">
+        scene_type,
+      </if>
+      <if test="deviceId != null">
+        device_id,
+      </if>
+      <if test="iotAlarmId != null">
+        iot_alarm_id,
+      </if>
+      <if test="companyOrgId != null">
+        company_org_id,
+      </if>
+      <if test="deptOrgId != null">
+        dept_org_id,
+      </if>
+      <if test="productId != null">
+        product_id,
+      </if>
+      <if test="name != null">
+        `name`,
+      </if>
+      <if test="code != null">
+        code,
+      </if>
+      <if test="desc != null">
+        `desc`,
+      </if>
+      <if test="days != null">
+        `days`,
+      </if>
+      <if test="times != null">
+        `times`,
+      </if>
+      <if test="alarmCategory != null">
+        alarm_category,
+      </if>
+      <if test="enabled != null">
+        enabled,
+      </if>
+      <if test="alarmRuleNum != null">
+        alarm_rule_num,
+      </if>
+      <if test="status != null">
+        `status`,
+      </if>
+      <if test="createDate != null">
+        create_date,
+      </if>
+      <if test="createBy != null">
+        create_by,
+      </if>
+      <if test="updateDate != null">
+        update_date,
+      </if>
+      <if test="updateBy != null">
+        update_by,
+      </if>
+    </trim>
+    <trim prefix="values (" suffix=")" suffixOverrides=",">
+      <if test="tenantId != null">
+        #{tenantId},
+      </if>
+      <if test="attributeId != null">
+        #{attributeId},
+      </if>
+      <if test="customerId != null">
+        #{customerId},
+      </if>
+      <if test="sceneType != null">
+        #{sceneType},
+      </if>
+      <if test="deviceId != null">
+        #{deviceId},
+      </if>
+      <if test="iotAlarmId != null">
+        #{iotAlarmId},
+      </if>
+      <if test="companyOrgId != null">
+        #{companyOrgId},
+      </if>
 
-        <if test="deptOrgId != null">
-          #{deptOrgId},
-        </if>
-        <if test="productId != null">
-          #{productId},
-        </if>
-        <if test="name != null">
-          #{name},
-        </if>
-        <if test="code != null">
-          #{code},
-        </if>
-        <if test="desc != null">
-          #{desc},
-        </if>
-        <if test="days != null">
-          #{days},
-        </if>
-        <if test="times != null">
-          #{times},
-        </if>
-        <if test="alarmCategory != null">
-          #{alarmCategory},
-        </if>
-        <if test="enabled != null">
-          #{enabled},
-        </if>
-        <if test="alarmRuleNum != null">
-          #{alarmRuleNum},
-        </if>
-        <if test="status != null">
-          #{status},
-        </if>
-        <if test="createDate != null">
-          #{createDate},
-        </if>
-        <if test="createBy != null">
-          #{createBy},
-        </if>
-        <if test="updateDate != null">
-          #{updateDate},
-        </if>
-        <if test="updateBy != null">
-          #{updateBy},
-        </if>
-      </trim>
-    </insert>
+      <if test="deptOrgId != null">
+        #{deptOrgId},
+      </if>
+      <if test="productId != null">
+        #{productId},
+      </if>
+      <if test="name != null">
+        #{name},
+      </if>
+      <if test="code != null">
+        #{code},
+      </if>
+      <if test="desc != null">
+        #{desc},
+      </if>
+      <if test="days != null">
+        #{days},
+      </if>
+      <if test="times != null">
+        #{times},
+      </if>
+      <if test="alarmCategory != null">
+        #{alarmCategory},
+      </if>
+      <if test="enabled != null">
+        #{enabled},
+      </if>
+      <if test="alarmRuleNum != null">
+        #{alarmRuleNum},
+      </if>
+      <if test="status != null">
+        #{status},
+      </if>
+      <if test="createDate != null">
+        #{createDate},
+      </if>
+      <if test="createBy != null">
+        #{createBy},
+      </if>
+      <if test="updateDate != null">
+        #{updateDate},
+      </if>
+      <if test="updateBy != null">
+        #{updateBy},
+      </if>
+    </trim>
+  </insert>
 
-    <update id="updateByPrimaryKeySelective" parameterType="com.bz.zoneiot.water.core.entity.AlarmType">
-      update sms_alarm_type
-      <set>
-        <if test="deviceId != null">
-          device_id = #{deviceId},
-        </if>
-        <if test="attributeId != null">
-          attribute_id = #{attributeId}
-        </if>
-        <if test="productId != null">
-          product_id = #{productId},
-        </if>
-        <if test="name != null">
-          `name` = #{name},
-        </if>
-        <if test="code != null">
-          code = #{code},
-        </if>
-        <if test="desc != null">
-          `desc` = #{desc},
-        </if>
-        <if test="days != null">
-          `days` = #{days},
-        </if>
-        <if test="times != null">
-          `times` = #{times},
-        </if>
-        <if test="alarmCategory != null">
-          alarm_category = #{alarmCategory},
-        </if>
-        <if test="enabled != null">
-          enabled = #{enabled},
-        </if>
-        <if test="alarmRuleNum != null">
-          alarm_rule_num = #{alarmRuleNum},
-        </if>
-        <if test="status != null">
-          `status` = #{status},
-        </if>
-        <if test="updateDate != null">
-          update_date = #{updateDate},
-        </if>
-        <if test="updateBy != null">
-          update_by = #{updateBy},
-        </if>
-      </set>
-      where id = #{id}
-    </update>
+  <update id="updateByPrimaryKeySelective" parameterType="com.bz.zoneiot.water.core.entity.AlarmType">
+    update sms_alarm_type
+    <set>
+      <if test="deviceId != null">
+        device_id = #{deviceId},
+      </if>
+      <if test="attributeId != null">
+        attribute_id = #{attributeId},
+      </if>
+      <if test="productId != null">
+        product_id = #{productId},
+      </if>
+      <if test="name != null">
+        `name` = #{name},
+      </if>
+      <if test="code != null">
+        code = #{code},
+      </if>
+      <if test="desc != null">
+        `desc` = #{desc},
+      </if>
+      <if test="days != null">
+        `days` = #{days},
+      </if>
+      <if test="times != null">
+        `times` = #{times},
+      </if>
+      <if test="alarmCategory != null">
+        alarm_category = #{alarmCategory},
+      </if>
+      <if test="enabled != null">
+        enabled = #{enabled},
+      </if>
+      <if test="alarmRuleNum != null">
+        alarm_rule_num = #{alarmRuleNum},
+      </if>
+      <if test="status != null">
+        `status` = #{status},
+      </if>
+      <if test="updateDate != null">
+        update_date = #{updateDate},
+      </if>
+      <if test="updateBy != null">
+        update_by = #{updateBy},
+      </if>
+    </set>
+    where id = #{id}
+  </update>
 
-    <select id="findById" resultType="com.bz.zoneiot.water.core.entity.AlarmType">
+  <select id="findById" resultType="com.bz.zoneiot.water.core.entity.AlarmType">
       select
-          <include refid="Base_Column_List" />
+           <include refid="Base_Column_List"></include>
       from sms_alarm_type
       where  id = #{id} and status = 1
     </select>
 
+  <select id="findAlarmProductInfoById" resultType="com.bz.zoneiot.water.api.vo.AlarmTypeVo">
+    select
+    sat.id,sat.iot_alarm_id,sat.device_id,sat.product_id,sat.name as alarmName,sat.attribute_id,sat.`desc`,sat.days,sat.times,
+    CONCAT(sp.MANUFACTURER_NAME,"/",sp.DEVICE_TYPE,"/",sp.DEVICE_MODE) as productName,
+    sd.device_name,sat.alarm_rule_num
+    from sms_alarm_type sat
+    left join sms_device_type sp on sp.id = sat.product_id
+    left join sms_device sd on (sd.id = sat.device_id)
+    where
+         sat.id = #{id} and sat.status = 1
+  </select>
+
   <select id="findDeviceIdByIotAlarmId" resultType="java.lang.Long">
     select device_id  from sms_alarm_type where  iot_alarm_id = #{id} and status = 1
   </select>
 
 
 
-    <select id="getAlarmTypeList" resultType="com.bz.zoneiot.water.api.vo.AlarmTypeVo">
-      select
-      sat.id,
-      CONCAT(sp.MANUFACTURER_NAME,"/",sp.DEVICE_TYPE,"/",sp.DEVICE_MODE) as productName,
-      sd.device_name,
-      sat.name as alarmName,
-      sat.desc,
-      sat.alarm_rule_num,
-      sat.enabled
-      from sms_alarm_type sat
-      left join sms_device_type sp on (sp.id = sat.product_id)
-      left join sms_device sd on (sd.id = sat.device_id)
-      where
-      1=1
-      <if test="dto.alarmName !=null and dto.alarmName != ''" >
-        and sat.`name` like concat('%', #{dto.alarmName}, '%')
-      </if>
-      <if test="dto.alarmCategory !=null and dto.alarmCategory!=''" >
-        and sat.alarm_category  = #{dto.alarmCategory}
-      </if>
-      <if test="dto.sceneType !=null and dto.sceneType!=''" >
-        and sat.scene_type  = #{dto.sceneType}
-      </if>
-      and sat.status = 1
-      <include refid="permissionCondition"></include>
-      order by sat.create_date desc
-    </select>
+  <select id="getAlarmTypeList" resultType="com.bz.zoneiot.water.api.vo.AlarmTypeVo">
+    select
+    sat.id,
+    CONCAT(sp.MANUFACTURER_NAME,"/",sp.DEVICE_TYPE,"/",sp.DEVICE_MODE) as productName,
+    sd.device_name,
+    sat.name as alarmName,
+    sat.desc,
+    sat.alarm_rule_num,
+    sat.enabled
+    from sms_alarm_type sat
+    left join sms_device_type sp on (sp.id = sat.product_id)
+    left join sms_device sd on (sd.id = sat.device_id)
+    where
+    1=1
+    <if test="dto.alarmName !=null and dto.alarmName != ''" >
+      and sat.`name` like concat('%', #{dto.alarmName}, '%')
+    </if>
+    <if test="dto.alarmCategory !=null and dto.alarmCategory!=''" >
+      and sat.alarm_category  = #{dto.alarmCategory}
+    </if>
+    <if test="dto.sceneType !=null and dto.sceneType!=''" >
+      and sat.scene_type  = #{dto.sceneType}
+    </if>
+    and sat.status = 1
+    <include refid="permissionCondition"></include>
+    order by sat.create_date desc
+  </select>
 
   <select id="findByNameUnique" resultType="int">
     select count(1) from sms_alarm_type where `name` = #{name} and tenant_id = #{tenantId} and status = 1

+ 7 - 8
zoniot-water/zoniot-water-web/src/main/java/com/bz/zoneiot/water/web/service/impl/AlarmTypeServiceImpl.java

@@ -63,11 +63,9 @@ public class AlarmTypeServiceImpl implements AlarmTypeService {
 
     @Override
     public AlarmTypeVo findById(Integer id) {
-        AlarmTypeVo vo = null;
-        AlarmType alarmType = alarmTypeMapper.findById(id);
-        if (alarmType != null) {
-            vo = BeanCopyUtils.copy(alarmType, AlarmTypeVo.class);
-            vo.setRules(alarmRuleMapper.findByAlarmTypeId(alarmType.getId()));
+        AlarmTypeVo vo = alarmTypeMapper.findAlarmProductInfoById(id);
+        if (vo != null) {
+            vo.setRules(alarmRuleMapper.findByAlarmTypeId(vo.getId()));
         }
         return vo;
     }
@@ -174,8 +172,6 @@ public class AlarmTypeServiceImpl implements AlarmTypeService {
         if (alarmType == null) {
             throw BusinessException.builder(WaterErrorEnum.NOT_FOUND);
         }
-        alarmType.setId(id);
-        alarmType.setStatus(false);
         Long iotAlarmId = null;
         if (AlarmCategoryEnum.DATA_ALARM.getType() == alarmType.getAlarmCategory()) {
             iotAlarmId = syncAlarmService.deleteDataWaringConfig(alarmType.getIotAlarmId());
@@ -185,7 +181,10 @@ public class AlarmTypeServiceImpl implements AlarmTypeService {
         if (iotAlarmId == null || iotAlarmId == 0) {
             throw BusinessException.builder(WaterErrorEnum.IOT_SYNC_DELETE_ALARM_ERROR);
         }
-        int result = this.updateByPrimaryKeySelective(alarmType);
+        AlarmType deleteAlarmType = new AlarmType();
+        deleteAlarmType.setId(id);
+        deleteAlarmType.setStatus(false);
+        int result = this.updateByPrimaryKeySelective(deleteAlarmType);
         AlarmType dto = new AlarmType();
         dto.setId(id);
         dto.setProductId(alarmType.getProductId());