15928045575 2 лет назад
Родитель
Сommit
3cd19869d3

+ 7 - 1
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/model/param/DeviceQuery.java

@@ -23,7 +23,7 @@ public class DeviceQuery {
     /**
     /**
      * 项目id
      * 项目id
      */
      */
-    @NotBlank(message = "项目id不能为空")
+
     private String projectId;
     private String projectId;
 
 
     /**
     /**
@@ -54,4 +54,10 @@ public class DeviceQuery {
     private int page;
     private int page;
 
 
     private int pageSize;
     private int pageSize;
+
+    /**
+     * 设备状态
+     */
+
+    private String status;
 }
 }

+ 5 - 0
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/model/vo/DeviceVo.java

@@ -161,6 +161,11 @@ public class DeviceVo implements Serializable {
      */
      */
     private List<KwsDeviceIntegration> integration;
     private List<KwsDeviceIntegration> integration;
 
 
+    /**
+     * 检测时间
+     */
+    private LocalDateTime check_time;
+
 
 
 
 
     private static final long serialVersionUID = 1L;
     private static final long serialVersionUID = 1L;

+ 44 - 4
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/service/DeviceService.java

@@ -172,7 +172,7 @@ public class DeviceService {
         device.setUpdateTime(now);
         device.setUpdateTime(now);
         device.setMountainId(headerData.getCompanyId());
         device.setMountainId(headerData.getCompanyId());
         deviceMapper.insert(device);
         deviceMapper.insert(device);
-        //新增到数据表kws_device_relation
+        //新增到数据表kws_device_Integration
         KwsDeviceIntegration deIntergration = new KwsDeviceIntegration();
         KwsDeviceIntegration deIntergration = new KwsDeviceIntegration();
         String[] temp;//接收分割后的数组
         String[] temp;//接收分割后的数组
         temp = deviceAdd.getIntegrationId().split(Global.COMMA);
         temp = deviceAdd.getIntegrationId().split(Global.COMMA);
@@ -259,14 +259,54 @@ public class DeviceService {
 
 
     @Transactional
     @Transactional
     public HttpResult update(DeviceAdd deviceAdd, HttpServletRequest response) {
     public HttpResult update(DeviceAdd deviceAdd, HttpServletRequest response) {
+
+        KwsDevice deviceHas = deviceMapper.selectOne(new LambdaQueryWrapper<KwsDevice>()
+                .eq(KwsDevice::getId, deviceAdd.getId()));
+        if (Objects.isNull(deviceHas)) {
+            throw new SystemException(HttpStatus.QUERY_FAIL_CODE, HttpStatus.DEVICE_SN_EXISTS);
+        }
+
         KwsDevice device = new KwsDevice();
         KwsDevice device = new KwsDevice();
         BeanUtils.copyProperties(deviceAdd, device);
         BeanUtils.copyProperties(deviceAdd, device);
         device.setId(Long.parseLong(deviceAdd.getId()));
         device.setId(Long.parseLong(deviceAdd.getId()));
         LocalDateTime now = LocalDateTime.now();
         LocalDateTime now = LocalDateTime.now();
-        device.setUpdateBy(Long.parseLong(commonService.getHeaderData(response).getUpdateBy()));
+        HeaderData headerData = commonService.getHeaderData(response);
+        device.setUpdateBy(Long.parseLong(headerData.getUpdateBy()));
         device.setUpdateTime(now);
         device.setUpdateTime(now);
-        deviceMapper.updateById(device);
-        return HttpResult.ok();
+        Integer updateStatus = deviceMapper.updateById(device);
+        if(updateStatus == 1){
+            int update = deviceIntegrationMapper.update(null, new LambdaUpdateWrapper<KwsDeviceIntegration>()
+                    .eq(KwsDeviceIntegration::getDeviceId, deviceAdd.getId())
+                    .set(KwsDeviceIntegration::getDelFlag, NumberConstant.ONE)
+                    .set(KwsDeviceIntegration::getUpdateBy,Long.parseLong(headerData.getUpdateBy()) )
+                    .set(KwsDeviceIntegration::getUpdateTime, now));
+            if (update < 1) {
+                throw new BusinessException("删除设备集成要素异常");
+            }
+
+            //新增到数据表kws_device_Integration
+            KwsDeviceIntegration deIntergration = new KwsDeviceIntegration();
+            String[] temp;//接收分割后的数组
+            temp = deviceAdd.getIntegrationId().split(Global.COMMA);
+
+            for (int i = 0; i < temp.length; i++) {
+                long interId = new IdWorker(NumberConstant.ONE).nextId();
+                deIntergration.setId(interId);
+                deIntergration.setDeviceId(Long.parseLong(deviceAdd.getId()));
+                deIntergration.setMountainId(headerData.getCompanyId());
+                deIntergration.setIntegrationId(Long.parseLong(temp[i]));
+                deIntergration.setCreateBy(Long.parseLong(headerData.getCreateBy()));
+                deIntergration.setCreateTime(now);
+                deIntergration.setStatus(NumberConstant.ZERO);
+                deIntergration.setUpdateBy(Long.parseLong(headerData.getUpdateBy()));
+                deIntergration.setUpdateTime(now);
+                deviceIntegrationMapper.insert(deIntergration);
+            }
+            return HttpResult.ok();
+        }
+
+        throw new BusinessException("更新异常");
+
     }
     }
 
 
     /**
     /**

+ 13 - 7
slope-modules/slope-detection/src/main/resources/mapper/mysql/KwsDeviceMapper.xml

@@ -27,7 +27,7 @@
   <sql id="Base_Column_List">
   <sql id="Base_Column_List">
     <!--@mbg.generated-->
     <!--@mbg.generated-->
     id, `attribute`, `name`, `alias`, sn_code, model_id, valid_time, secret_key, inter_face,relevance_level,
     id, `attribute`, `name`, `alias`, sn_code, model_id, valid_time, secret_key, inter_face,relevance_level,
-    remark, `status`, create_by, create_time, update_by, update_time, del_flag,mountain_id,related
+    remark, `status`, create_by, create_time, update_by, update_time, del_flag,mountain_id,related,check_time
   </sql>
   </sql>
   <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
   <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
       <!--@mbg.generated-->
       <!--@mbg.generated-->
@@ -55,13 +55,22 @@
                left join kws_project as p on pd.project_id = p.id
                left join kws_project as p on pd.project_id = p.id
       WHERE d.del_flag = 0
       WHERE d.del_flag = 0
         and m.del_flag = 0
         and m.del_flag = 0
-          <if test="deviceQuery.name != null and deviceQuery.name != ''">
-              and name like concat('%', #{deviceQuery.name}
+          <if test="deviceQuery.deviceName != null and deviceQuery.deviceName != ''">
+              and deviceName like concat('%', #{deviceQuery.deviceName}
                    , '%')
                    , '%')
           </if>
           </if>
           <if test="deviceQuery.id != null and deviceQuery.id != ''">
           <if test="deviceQuery.id != null and deviceQuery.id != ''">
               and id = #{deviceQuery.id,jdbcType=BIGINT}
               and id = #{deviceQuery.id,jdbcType=BIGINT}
           </if>
           </if>
+          <if test="deviceQuery.deviceType != null and deviceQuery.deviceType != ''">
+              and d.deviceType = #{deviceQuery.deviceType,jdbcType=BIGINT}
+          </if>
+          <if test="deviceQuery.status != null and deviceQuery.status != ''">
+              and d.status = #{deviceQuery.status,jdbcType=TINYINT}
+          </if>
+          <if test="deviceQuery.projectId != null and deviceQuery.projectId != ''">
+              and  p.id= #{deviceQuery.projectId,jdbcType=TINYINT}
+          </if>
           <if test="deviceQuery.attribute != null and deviceQuery.attribute != ''">
           <if test="deviceQuery.attribute != null and deviceQuery.attribute != ''">
               and attribute = #{deviceQuery.attribute,jdbcType=TINYINT}
               and attribute = #{deviceQuery.attribute,jdbcType=TINYINT}
           </if>
           </if>
@@ -299,10 +308,7 @@
         FROM kws_device a
         FROM kws_device a
                  LEFT JOIN kws_project_device b ON a.id = b.device_id
                  LEFT JOIN kws_project_device b ON a.id = b.device_id
                  LEFT JOIN kws_project c ON b.project_id = c.id
                  LEFT JOIN kws_project c ON b.project_id = c.id
-        WHERE a.del_flag = 0
-          and b.del_flag = 0
-          and c.del_flag = 0
-          and c.id = #{projectId}
+        WHERE c.id = #{projectId}
     </select>
     </select>
 
 
     <select id="selectDeviceAllByProjectAndMountainId" resultType="com.sckw.slope.detection.model.dto.ThresholdSelectDTO">
     <select id="selectDeviceAllByProjectAndMountainId" resultType="com.sckw.slope.detection.model.dto.ThresholdSelectDTO">