15928045575 2 жил өмнө
parent
commit
bee3fbd80d

+ 21 - 0
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/controller/DeviceController.java

@@ -1,8 +1,20 @@
 package com.sckw.slope.detection.controller;
 
+import com.alibaba.fastjson2.JSONObject;
+import com.sckw.core.annotation.Log;
+import com.sckw.core.annotation.RepeatSubmit;
+import com.sckw.core.web.response.HttpResult;
+import com.sckw.slope.detection.model.param.DeviceQueryDto;
+import com.sckw.slope.detection.service.ProjectService;
+import jakarta.validation.Valid;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.http.HttpResponse;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
 import org.springframework.web.bind.annotation.RestController;
+import com.sckw.slope.detection.service.DeviceService;
 
 /**
  * @author lfdc
@@ -13,5 +25,14 @@ import org.springframework.web.bind.annotation.RestController;
 @RestController
 @RequestMapping("/device")
 public class DeviceController {
+    @Autowired
+    DeviceService deviceService;
 
+    @Log(description = "设备查询-分页")
+    @RepeatSubmit(interval = 3000, message = "两次请求间隔未超过3秒")
+    @RequestMapping(name = "设备查询-分页", value = "/select", method = RequestMethod.POST)
+    public HttpResult select(@Valid @RequestBody DeviceQueryDto deviceQueryDto, HttpResponse response) {
+        log.info("设备查询 select param:{}", JSONObject.toJSONString(deviceQueryDto));
+        return HttpResult.ok(deviceService.select(deviceQueryDto, response));
+    }
 }

+ 10 - 6
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/dao/mysql/KwsDeviceMapper.java

@@ -3,20 +3,24 @@ package com.sckw.slope.detection.dao.mysql;
 import com.baomidou.dynamic.datasource.annotation.DS;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.sckw.slope.detection.model.dos.mysql.KwsDevice;
+import com.sckw.slope.detection.model.param.DeviceQueryDto;
+import com.sckw.slope.detection.model.param.ProjectQueryDto;
+import com.sckw.slope.detection.model.vo.DeviceVo;
+import com.sckw.slope.detection.model.vo.ProjectVo;
 import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
 
 @Mapper
 @DS("mysql")
 public interface KwsDeviceMapper extends BaseMapper<KwsDevice> {
-    int deleteByPrimaryKey(Long id);
 
-    int insert(KwsDevice record);
+    List<DeviceVo> selectByDeviceParam(@Param("deviceQueryDto") DeviceQueryDto deviceQueryDto);
+
+
 
-    int insertSelective(KwsDevice record);
 
-    KwsDevice selectByPrimaryKey(Long id);
 
-    int updateByPrimaryKeySelective(KwsDevice record);
 
-    int updateByPrimaryKey(KwsDevice record);
 }

+ 34 - 0
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/model/param/DeviceQueryDto.java

@@ -0,0 +1,34 @@
+package com.sckw.slope.detection.model.param;
+
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * @author lfdc
+ * @description 分页查询项目dto
+ * @date 2023-10-30 13:10:38
+ */
+@Data
+public class DeviceQueryDto implements Serializable {
+
+
+    //设备名称
+    private String deviceName;
+
+    //监测项目
+    private String projectName;
+
+    //产品类型
+    private String deviceType;
+
+    //视频设备、监测设备
+    private String attribute;
+
+    //设备类型
+    private String status;
+
+    private int page;
+
+    private int pageSize;
+}

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

@@ -0,0 +1,111 @@
+package com.sckw.slope.detection.model.vo;
+
+import com.baomidou.mybatisplus.annotation.TableLogic;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.time.LocalDateTime;
+import java.util.Date;
+
+/**
+ * @author lfdc
+ * @description vo
+ * @date 2023-10-30 13:10:38
+ */
+@Data
+public class DeviceVo implements Serializable {
+    private Long id;
+
+    /**
+     * 视频设备、监测设备等
+     */
+    private Integer attribute;
+
+    /**
+     * 设备名
+     */
+    private String name;
+
+    /**
+     * 别名(单元名称)
+     */
+    private String alias;
+
+    /**
+     * sn码
+     */
+    private String snCode;
+
+    /**
+     * 设备型号id
+     */
+    private Long modelId;
+
+    /**
+     * 质保日期
+     */
+    private Date validTime;
+
+    /**
+     * 秘钥
+     */
+    private String secretKey;
+
+    /**
+     * 接口地址
+     */
+    private String interFace;
+
+    /**
+     * 备注
+     */
+    private String remark;
+
+    /**
+     * 状态
+     */
+    private Byte status;
+
+    /**
+     * 创建人
+     */
+    private Long createBy;
+
+    /**
+     * 创建时间
+     */
+    private LocalDateTime createTime;
+
+    /**
+     * 修改人
+     */
+    private Long updateBy;
+
+    /**
+     * 修改时间
+     */
+    private LocalDateTime updateTime;
+
+    /**
+     * 删除标识
+     */
+    @TableLogic(value = "0")
+    private int delFlag;
+
+    /**
+     * 逻辑经度(测点布设的值)
+     */
+    private String logicLng;
+
+    /**
+     * 逻辑纬度(测点布设的值)
+     */
+    private String logicLat;
+
+    /**
+     * 逻辑海拔(测点布设的值)
+     */
+    private String logicAlt;
+
+    private static final long serialVersionUID = 1L;
+}

+ 79 - 0
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/service/DeviceService.java

@@ -0,0 +1,79 @@
+package com.sckw.slope.detection.service;
+
+import com.alibaba.fastjson2.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
+import com.github.pagehelper.PageHelper;
+import com.github.pagehelper.PageInfo;
+import com.sckw.core.common.enums.NumberConstant;
+import com.sckw.core.exception.BusinessException;
+import com.sckw.core.model.page.PageRes;
+import com.sckw.core.utils.IdWorker;
+import com.sckw.core.utils.StringUtils;
+import com.sckw.core.web.response.HttpResult;
+import com.sckw.slope.detection.dao.mysql.KwsProjectDeviceMapper;
+import com.sckw.slope.detection.dao.mysql.KwsDeviceMapper;
+import com.sckw.slope.detection.model.dos.mysql.KwsProject;
+import com.sckw.slope.detection.model.dos.mysql.KwsProjectDevice;
+import com.sckw.slope.detection.model.dto.BaseItemDTO;
+import com.sckw.slope.detection.model.dto.IntegrationItemDTO;
+import com.sckw.slope.detection.model.dto.ProjectAddDTO;
+import com.sckw.slope.detection.model.dto.ProjectUpdateDTO;
+import com.sckw.slope.detection.model.param.DeviceQueryDto;
+import com.sckw.slope.detection.model.param.ProjectQueryDto;
+import com.sckw.slope.detection.model.vo.DeviceVo;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.http.HttpResponse;
+import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.util.CollectionUtils;
+
+import java.time.LocalDateTime;
+import java.util.List;
+
+/**
+ * @author sky
+ * @description 项目service
+ * @date 2023-10-30 13:10:50
+ */
+@Slf4j
+@Service
+public class DeviceService {
+
+    @Autowired
+    KwsDeviceMapper deviceMapper;
+
+    @Autowired
+    KwsProjectDeviceMapper projectDeviceMapper;
+
+    /**
+     * 新增项目
+     *
+     * @param projectAddDto 请求参数
+     * @param response      http流
+     * @return 返回值
+     */
+
+
+    /**
+     * 项目管理分页查询
+     *
+     * @param deviceQueryDto 请求分页
+     * @param response        http流
+     * @return 返回值
+     */
+    public PageRes select(DeviceQueryDto deviceQueryDto, HttpResponse response) {
+        PageHelper.startPage(deviceQueryDto.getPage(), deviceQueryDto.getPageSize());
+        List<DeviceVo> list = deviceMapper.selectByDeviceParam(deviceQueryDto);
+        PageInfo<DeviceVo> pageInfo = new PageInfo<>(list);
+        if (CollectionUtils.isEmpty(list)) {
+            return PageRes.build(pageInfo, list);
+        }
+        for (DeviceVo vo : list) {
+            //vo.setDeviceTotal(projectDeviceMapper.selectCount(new LambdaQueryWrapper<KwsProjectDevice>().eq(KwsProjectDevice::getProjectId, vo.getId())));
+        }
+        return PageRes.build(pageInfo, list);
+    }
+}

+ 51 - 0
slope-modules/slope-detection/src/main/resources/bootstrap-sky.yml

@@ -0,0 +1,51 @@
+spring:
+  application:
+    name: slope-detection
+  cloud:
+    nacos:
+      discovery:
+        # 服务注册地址
+        server-addr: 10.10.10.230:8848
+        # 命名空间
+        namespace: slope-manage-service-sky
+        # 共享配置
+        group: slope-manage-service
+      config:
+        # 配置中心地址
+        server-addr: 10.10.10.230:8848
+        # 配置文件格式
+        file-extension: yaml
+        # 命名空间
+        namespace: slope-manage-service-sky
+        # 共享配置
+        group: slope-manage-service
+        #可以读多个配置文件  需要在同一个命名空间下面可以是不同的组
+        extension-configs:
+          - dataId: slope-common.yml
+            group: slope-manage-service
+            refresh: true
+## MQTT##
+mqtt:
+  send:
+    #完成超时时间
+    completionTimeout: 3000
+    #通过mqtt发送消息验证所需用户名
+    username: test
+    #通过mqtt发送消息验证所需密码
+    password: test
+    #连接的mqtt地址
+    url: tcp://10.10.10.225:1883
+    #客户端id
+    clientId: mqttx_12411c5cec
+    #推送主题  后面跟着#是监控下面所有的话题
+    topic: slope
+    #topic: my-test
+    # 会话心跳时间
+    keepAliveInterval: 20
+    # 设置连接超时时间
+    connectionTimeout: 3000
+    timeout: 10
+    keepalive: 20
+  # 要消费的topic配置
+  receive:
+    topic: slopePush/slopePull/test/out,test,slope,sharjeck/ai/test/out

+ 15 - 2
slope-modules/slope-detection/src/main/resources/mapper/mysql/KwsDeviceMapper.xml

@@ -23,9 +23,22 @@
   </resultMap>
   <sql id="Base_Column_List">
     <!--@mbg.generated-->
-    id, `attribute`, `name`, `alias`, sn_code, model_id, valid_time, secret_key, inter_face,
-    remark, `status`, create_by, create_time, update_by, update_time, del_flag
+    d.id, d.name,manufacturer,device_type,m.name as m_name,d.remark,d.status,d.update_by,d.update_time
   </sql>
+
+  <select id="selectByDeviceParam" resultType="com.sckw.slope.detection.model.vo.DeviceVo">
+    select
+    <include refid="Base_Column_List">
+    </include>
+    from kws_device as d inner join kws_device_model as m on d.model_id=m.id
+    WHERE d.del_flag = 0 and m.del_flag = 0
+    <where>
+      <if test="deviceQueryDto.deviceName != null and deviceQueryDto.deviceName != ''">
+        and name like concat('%', #{deviceQueryDto.deviceName}, '%')
+      </if>
+    </where>
+  </select>
+
   <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
     <!--@mbg.generated-->
     select