소스 검색

Merge branch 'dev' into sky_v2

15928045575 2 년 전
부모
커밋
9adbd0f469
18개의 변경된 파일216개의 추가작업 그리고 26개의 파일을 삭제
  1. 2 0
      slope-common/slope-common-core/src/main/java/com/sckw/core/model/enums/DictEnum.java
  2. 9 0
      slope-common/slope-common-core/src/main/java/com/sckw/core/model/enums/ReportTypeEnum.java
  3. 8 3
      slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/controller/DeviceController.java
  4. 5 0
      slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/dao/mysql/KwsProjectDeviceMapper.java
  5. 3 0
      slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/dao/tdengine/DevicesMapper.java
  6. 3 2
      slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/model/dto/ProjectAddDTO.java
  7. 2 1
      slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/model/dto/ProjectUpdateDTO.java
  8. 5 0
      slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/model/param/ProjectAndDeviceParam.java
  9. 9 0
      slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/model/param/StatementQuery.java
  10. 28 0
      slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/model/vo/ProjectAndDeviceVo.java
  11. 15 0
      slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/service/CommonService.java
  12. 10 0
      slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/service/DeviceService.java
  13. 16 5
      slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/service/ProjectService.java
  14. 2 2
      slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/service/ReportTemplateService.java
  15. 46 11
      slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/service/ThresholdService.java
  16. 33 2
      slope-modules/slope-detection/src/main/resources/mapper/mysql/KwsProjectDeviceMapper.xml
  17. 7 0
      slope-modules/slope-detection/src/main/resources/mapper/mysql/KwsReportTemplateMapper.xml
  18. 13 0
      slope-modules/slope-detection/src/main/resources/mapper/tdengine/DevicesMapper.xml

+ 2 - 0
slope-common/slope-common-core/src/main/java/com/sckw/core/model/enums/DictEnum.java

@@ -14,6 +14,8 @@ public enum DictEnum {
     THRESHOLD_LEVEL("threshold_level", "告警等级"),
     ALARM_TYPE("alarm_type", "告警类型"),
     ALARM_DETAIL_TYPE("alarm_detail_type", "告警明细类型"),
+    REPORT_TEMPLATE_TYPE("report_template_type", "报表模板"),
+    COMPANY("company", "厂商"),
     ;
     private final String codeType;
     private final String name;

+ 9 - 0
slope-common/slope-common-core/src/main/java/com/sckw/core/model/enums/ReportTypeEnum.java

@@ -65,4 +65,13 @@ public enum ReportTypeEnum {
         }
         return null;
     }
+
+    public static String getValue(String status) {
+        for (ReportTypeEnum value : ReportTypeEnum.values()) {
+            if (value.status.equals(status)) {
+                return value.getValue();
+            }
+        }
+        return null;
+    }
 }

+ 8 - 3
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/controller/DeviceController.java

@@ -5,16 +5,14 @@ import com.sckw.core.annotation.Log;
 import com.sckw.core.web.response.HttpResult;
 import com.sckw.slope.detection.model.dto.LocationDTO;
 import com.sckw.slope.detection.model.param.DeviceAdd;
-import com.sckw.slope.detection.model.param.DeviceReferenceAdd;
 import com.sckw.slope.detection.model.param.DeviceQuery;
-import com.sckw.slope.detection.model.vo.DeviceReferenceVo;
+import com.sckw.slope.detection.model.param.DeviceReferenceAdd;
 import com.sckw.slope.detection.service.DeviceService;
 import jakarta.servlet.http.HttpServletRequest;
 import jakarta.validation.Valid;
 import jakarta.validation.constraints.NotBlank;
 import jakarta.validation.constraints.NotNull;
 import lombok.extern.slf4j.Slf4j;
-import org.apache.http.HttpResponse;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
@@ -109,5 +107,12 @@ public class DeviceController {
         return deviceService.referenceEdit(deviceReference, request);
     }
 
+    @Log(description = "设备监测要素项")
+    //@RepeatSubmit(interval = 3000, message = "两次请求间隔未超过3秒")
+    @RequestMapping(name = "设备监测要素项", value = "/monitorItem", method = RequestMethod.GET)
+    public HttpResult monitorItem(@RequestParam("id") @NotBlank(message = "数据id不能为空") String id, HttpServletRequest request) {
+        log.info("设备监测要素项 select param:{}", id);
+        return deviceService.monitorItem(id, request);
+    }
 
 }

+ 5 - 0
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/dao/mysql/KwsProjectDeviceMapper.java

@@ -25,5 +25,10 @@ public interface KwsProjectDeviceMapper extends BaseMapper<KwsProjectDevice> {
 
     List<BaseItemDTO> selectDataByProjectId(@Param("id") long id);
 
+    List<BaseItemDTO> selectDataByDeviceId(@Param("id") long id);
+
+
     List<IntegrationItemVO> selectIntegrationItemByProjectId(@Param("id") long id);
+
+    List<IntegrationItemVO> selectIntegrationItemByDeviceId(@Param("id") long id);
 }

+ 3 - 0
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/dao/tdengine/DevicesMapper.java

@@ -14,4 +14,7 @@ public interface DevicesMapper extends BaseMapper<Devices> {
     @DS("td")
     Devices selectLastData(@Param("deviceCode") String deviceCode);
 
+    @DS("td")
+    Devices selectLastDataByCodeAndItemName(@Param("deviceCode") String deviceCode,@Param("itemName") String itemName);
+
 }

+ 3 - 2
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/model/dto/ProjectAddDTO.java

@@ -1,7 +1,7 @@
 package com.sckw.slope.detection.model.dto;
 
-import jakarta.validation.constraints.Max;
 import jakarta.validation.constraints.NotBlank;
+import jakarta.validation.constraints.Size;
 import lombok.Data;
 
 import java.io.Serializable;
@@ -90,6 +90,7 @@ public class ProjectAddDTO implements Serializable {
     /**
      * 备注
      */
-    @Max(value = 200, message = "请输入不超过{value}个字符")
+//    @Max(value = 200, message = "请输入不超过{value}个字符")
+    @Size(max = 200,message = "请输入不超过{value}个字符")
     private String remark;
 }

+ 2 - 1
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/model/dto/ProjectUpdateDTO.java

@@ -96,6 +96,7 @@ public class ProjectUpdateDTO implements Serializable {
     /**
      * 备注
      */
-    @Max(value = 200, message = "请输入不超过{value}个字符")
+//    @Max(value = 200, message = "请输入不超过{value}个字符")
+    @Size(max = 200,message = "请输入不超过{value}个字符")
     private String remark;
 }

+ 5 - 0
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/model/param/ProjectAndDeviceParam.java

@@ -18,4 +18,9 @@ public class ProjectAndDeviceParam implements Serializable {
 
     @NotBlank(message = "设备id")
     private String deviceId;
+
+    /**
+     * 检测要素
+     */
+    private String itemName;
 }

+ 9 - 0
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/model/param/StatementQuery.java

@@ -15,6 +15,10 @@ public class StatementQuery {
      * 报表名称
      */
     private String reportName;
+    /**
+     * 报表名称
+     */
+    private String name;
     /**
      * 项目id
      */
@@ -31,6 +35,11 @@ public class StatementQuery {
      */
     private String reportType;
 
+    /**
+     * 报表类型
+     */
+    private String type;
+
     private int page;
 
     private int pageSize;

+ 28 - 0
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/model/vo/ProjectAndDeviceVo.java

@@ -22,15 +22,43 @@ public class ProjectAndDeviceVo implements Serializable {
      */
     private String logicLat;
 
+    /**
+     * 逻辑纬度(测点布设的值)
+     */
+    private String fence;
+
     /**
      * 逻辑海拔(测点布设的值)
      */
     private String logicAlt;
 
+    /**
+     * 设备id
+     */
     private String deviceId;
 
+    /**
+     * 设备名称
+     */
     private String deviceName;
 
+    /**
+     * 项目id
+     */
     private String projectId;
+
+    /**
+     * 项目名称
+     */
     private String projectName;
+
+    /**
+     * 当前测量值(计算之后的)
+     */
+    private String offset;
+
+    /**
+     * 当前基准值
+     */
+    private String currentValue;
 }

+ 15 - 0
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/service/CommonService.java

@@ -1,6 +1,7 @@
 package com.sckw.slope.detection.service;
 
 import com.alibaba.fastjson2.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
 import com.sckw.core.exception.BusinessException;
@@ -11,6 +12,7 @@ import com.sckw.core.model.enums.MessageLogEnum;
 import com.sckw.core.model.page.PageRes;
 import com.sckw.core.utils.IdWorker;
 import com.sckw.core.web.response.PhpResult;
+import com.sckw.slope.detection.dao.mysql.KwsDeviceReferenceMapper;
 import com.sckw.slope.detection.dao.mysql.KwsDictMapper;
 import com.sckw.slope.detection.dao.mysql.KwsLogMapper;
 import com.sckw.slope.detection.model.dos.mysql.KwsDeviceReference;
@@ -107,8 +109,12 @@ public class CommonService {
 
     private static final Long equatorial_circumference = 40075020000L;
 
+    @Autowired
+    KwsDeviceReferenceMapper deviceReferenceMapper;
+
     /**
      * 计算xyz值的偏移量  当前只用于计算偏移数据的offset
+     *
      * @param value
      * @param itemName
      * @param deviceRelation
@@ -125,6 +131,15 @@ public class CommonService {
         }
         double angleInRadians = 0;
         if (DictItemEnum.LONGITUDE_X.getValue().equals(itemName)) {
+            KwsDeviceReference deviceReference = deviceReferenceMapper.selectOne(new LambdaQueryWrapper<KwsDeviceReference>()
+                    .eq(KwsDeviceReference::getDeviceId, deviceRelation.getDeviceId())
+                    .eq(KwsDeviceReference::getType, NumberConstant.ONE)
+                    .eq(KwsDeviceReference::getDelFlag, NumberConstant.ZERO)
+                    .eq(KwsDeviceReference::getItem, DictItemEnum.LATITUDE_Y.getValue())
+            );
+            if (deviceReference != null) {
+                angleInRadians = deviceReference.getCurrentValue().doubleValue();
+            }
             double cosValue = Math.cos(angleInRadians);
             double doubleValue = subtract.divide(new BigDecimal("360"), 9, BigDecimal.ROUND_HALF_UP).doubleValue();
             offsetValue = new BigDecimal(equatorial_circumference).multiply(new BigDecimal(cosValue)).multiply(new BigDecimal(doubleValue));

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

@@ -656,4 +656,14 @@ public class DeviceService {
     }
 
 
+    public HttpResult monitorItem(String id, HttpServletRequest request) {
+        String companyId = commonService.getHeaderData(request).getCompanyId();
+        //查询基本要素
+        List<BaseItemDTO> baseItem = projectDeviceMapper.selectDataByDeviceId(Long.parseLong(id));
+        List<IntegrationItemVO> integrationItem = projectDeviceMapper.selectIntegrationItemByDeviceId(Long.parseLong(id));
+        com.alibaba.fastjson2.JSONObject jsonObject = new com.alibaba.fastjson2.JSONObject();
+        jsonObject.put("baseItem", baseItem);
+        jsonObject.put("integrationItem", integrationItem);
+        return HttpResult.ok(jsonObject);
+    }
 }

+ 16 - 5
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/service/ProjectService.java

@@ -257,7 +257,8 @@ public class ProjectService {
         if (CollectionUtils.isEmpty(list)) {
             return PageRes.build(info, list);
         }
-//        后期要数据翻译产品类型
+        Map<String, SystemDict> deviceType = commonService.getDictByDictCode(DictEnum.DEVICE_TYPE);
+        Map<String, SystemDict> company = commonService.getDictByDictCode(DictEnum.COMPANY);
         for (ProjectDeviceVO projectDeviceDTO : list) {
             Long id = projectDeviceDTO.getDeviceRelationId();
             KwsDeviceRelation deviceRelation = deviceRelationMapper.selectOne(new LambdaQueryWrapper<KwsDeviceRelation>()
@@ -265,6 +266,13 @@ public class ProjectService {
                     .eq(KwsDeviceRelation::getMountainId, headerData.getMountainId())
                     .eq(KwsDeviceRelation::getDelFlag, 0)
             );
+            projectDeviceDTO.setDeviceModelName(projectDeviceDTO.getDeviceModelName() == null ? null :
+                    (deviceType == null ? projectDeviceDTO.getDeviceModelName() : (
+                            deviceType.get(projectDeviceDTO.getDeviceType()) == null ? projectDeviceDTO.getDeviceModelName() : deviceType.get(projectDeviceDTO.getDeviceType()).getLabel()
+                    )));
+            projectDeviceDTO.setManufacturer(projectDeviceDTO.getManufacturer() == null ? null :
+                    (company == null ? projectDeviceDTO.getManufacturer() :
+                            (company.get(projectDeviceDTO.getManufacturer()) == null ? projectDeviceDTO.getManufacturer() : company.get(projectDeviceDTO.getManufacturer()).getLabel())));
             if (deviceRelation != null) {
                 projectDeviceDTO.setParentId(deviceRelation.getDeviceId().toString());
                 KwsDevice kwsDevice = deviceMapper.selectByPrimaryKey(deviceRelation.getDeviceId());
@@ -382,10 +390,13 @@ public class ProjectService {
         if (CollectionUtils.isEmpty(list)) {
             return PageRes.build(info, list);
         }
-//        后期要数据翻译产品类型
-//        for (ProjectDeviceDTO projectDeviceDTO : list) {
-//
-//        }
+        Map<String, SystemDict> dictByDictCode = commonService.getDictByDictCode(DictEnum.DEVICE_TYPE);
+        for (ProjectDeviceVO projectDeviceVO : list) {
+            projectDeviceVO.setDeviceType(projectDeviceVO.getDeviceType() == null ? null :
+                    (dictByDictCode == null ? projectDeviceVO.getDeviceType() :
+                            (dictByDictCode.get(projectDeviceVO.getDeviceType()) == null ? projectDeviceVO.getDeviceType() :
+                                    dictByDictCode.get(projectDeviceVO.getDeviceType()).getLabel())));
+        }
         return PageRes.build(info, list);
     }
 

+ 2 - 2
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/service/ReportTemplateService.java

@@ -205,12 +205,12 @@ public class ReportTemplateService {
             map = kwsProjects.stream().collect(Collectors.toMap(KwsProject::getId, KwsProject::getName));
         }
         Map<String, SystemDict> dictByDictCode = commonService.getDictByDictCode(DictEnum.THRESHOLD_TYPE);
+        Map<String, SystemDict> alarmDetailType = commonService.getDictByDictCode(DictEnum.ALARM_DETAIL_TYPE);
         for (ReportStatementVO reportStatementVO : list) {
             reportStatementVO.setStatusLabel(ReportEnum.getDescription(reportStatementVO.getStatus()));
             reportStatementVO.setReportType(ReportTypeEnum.getDescription(reportStatementVO.getReportType()));
             reportStatementVO.setProjectName(map.get(Long.parseLong(reportStatementVO.getProjectId())));
-            reportStatementVO.setTabulationTime(dictByDictCode == null ? reportStatementVO.getTabulationTime() :
-                    (dictByDictCode.get(reportStatementVO.getTabulationTime()) == null ? reportStatementVO.getTabulationTime() : dictByDictCode.get(reportStatementVO.getTabulationTime()).getLabel()));
+            reportStatementVO.setTabulationTime(ReportTypeEnum.getValue(reportStatementVO.getTabulationTime()));
         }
         return PageRes.build(info, list);
     }

+ 46 - 11
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/service/ThresholdService.java

@@ -6,10 +6,7 @@ import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
 import com.sckw.core.exception.BusinessException;
 import com.sckw.core.model.constant.NumberConstant;
-import com.sckw.core.model.enums.DeviceEnum;
-import com.sckw.core.model.enums.DictEnum;
-import com.sckw.core.model.enums.MessageLogEnum;
-import com.sckw.core.model.enums.ThresholdEnum;
+import com.sckw.core.model.enums.*;
 import com.sckw.core.model.page.PageRes;
 import com.sckw.core.utils.IdWorker;
 import com.sckw.core.utils.RegularUtils;
@@ -17,7 +14,9 @@ import com.sckw.core.utils.StringUtils;
 import com.sckw.core.web.constant.HttpStatus;
 import com.sckw.core.web.response.HttpResult;
 import com.sckw.slope.detection.dao.mysql.*;
+import com.sckw.slope.detection.dao.tdengine.DevicesMapper;
 import com.sckw.slope.detection.model.dos.mysql.*;
+import com.sckw.slope.detection.model.dos.tdengine.Devices;
 import com.sckw.slope.detection.model.dto.*;
 import com.sckw.slope.detection.model.param.ProjectAndDeviceParam;
 import com.sckw.slope.detection.model.param.ThresholdDetailQuery;
@@ -34,10 +33,7 @@ import org.springframework.util.CollectionUtils;
 
 import java.math.BigDecimal;
 import java.time.LocalDateTime;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 import java.util.function.Function;
 import java.util.stream.Collectors;
 
@@ -62,6 +58,9 @@ public class ThresholdService {
     @Autowired
     KwsProjectMapper projectMapper;
 
+    @Autowired
+    DevicesMapper devicesMapper;
+
     @Autowired
     KwsDeviceIntegrationMapper deviceIntegrationMapper;
 
@@ -657,10 +656,8 @@ public class ThresholdService {
         KwsProjectArea area = projectAreaMapper.selectOne(new LambdaQueryWrapper<KwsProjectArea>()
                 .eq(KwsProjectArea::getProjectId, Long.parseLong(projectId))
                 .eq(KwsProjectArea::getDelFlag, 0));
-        if (area != null) {
-
-        }
         ProjectAndDeviceVo vo = new ProjectAndDeviceVo();
+        vo.setFence(area == null ? null : area.getFence());
         KwsDevice kwsDevice = deviceMapper.selectById(Long.parseLong(deviceId));
         if (kwsDevice != null) {
             vo.setLogicLng(kwsDevice.getLogicLng());
@@ -671,6 +668,44 @@ public class ThresholdService {
         vo.setDeviceName(kwsDevice == null ? null : kwsDevice.getName());
         vo.setProjectId(projectId);
         vo.setProjectName(project == null ? null : project.getName());
+        Devices devices = null;
+        String itemName = param.getItemName();
+        List<String> list = new ArrayList<>();
+        list.add(DictItemEnum.LONGITUDE_X.getValue());
+        list.add(DictItemEnum.LATITUDE_Y.getValue());
+        list.add(DictItemEnum.ALTITUDE_Z.getValue());
+        Map<String, SystemDict> dictByDictCode = commonService.getDictByDictCode(DictEnum.MODEL_PART);
+        if (Objects.nonNull(itemName)) {
+            if (list.contains(itemName)) {
+                try {
+                    devices = devicesMapper.selectLastDataByCodeAndItemName(kwsDevice.getSnCode(), itemName);
+                } catch (Exception e) {
+                    log.error("设备查询td异常:{}", e.getMessage(), e);
+                }
+                BigDecimal offset = null;
+                KwsDeviceReference deviceRelation = null;
+                if (Objects.nonNull(itemName)) {
+                    if (devices != null) {
+                        deviceRelation = deviceReferenceMapper.selectOne(new LambdaQueryWrapper<KwsDeviceReference>()
+                                .eq(KwsDeviceReference::getDeviceId, deviceId)
+                                .eq(KwsDeviceReference::getDelFlag, NumberConstant.ZERO)
+                                .eq(KwsDeviceReference::getType, "1")
+                                .eq(KwsDeviceReference::getItem, itemName)
+                        );
+                        offset = commonService.computeOffset(devices.getVal(), itemName, deviceRelation);
+                        vo.setCurrentValue(devices.getVal());
+                    }
+                }
+                vo.setOffset(offset == null ? null : offset.toString());
+            } else if (dictByDictCode != null && (dictByDictCode.get(itemName) != null)) {
+                try {
+                    devices = devicesMapper.selectLastDataByCodeAndItemName(kwsDevice.getSnCode(), itemName);
+                } catch (Exception e) {
+                    log.error("设备查询td异常:{}", e.getMessage(), e);
+                }
+                vo.setCurrentValue(devices == null ? null : devices.getVal());
+            }
+        }
         return HttpResult.ok(vo);
     }
 }

+ 33 - 2
slope-modules/slope-detection/src/main/resources/mapper/mysql/KwsProjectDeviceMapper.xml

@@ -181,7 +181,7 @@ WHERE
         and a.project_id = #{id}
     </select>
 
-  <select id="selectIntegrationItemByProjectId" resultType="com.sckw.slope.detection.model.vo.IntegrationItemVO">
+  <select id="selectIntegrationItemByDeviceId" resultType="com.sckw.slope.detection.model.vo.IntegrationItemVO">
       SELECT c.integration_id   AS integrationId,
              d.integration_name AS integrationName
       FROM kws_project_device a
@@ -192,6 +192,37 @@ WHERE
         AND b.del_flag = 0
         and c.del_flag = 0
         and d.del_flag
-        and a.project_id = #{id}
+        and b.id = #{id}
   </select>
+
+    <select id="selectIntegrationItemByProjectId" resultType="com.sckw.slope.detection.model.vo.IntegrationItemVO">
+        SELECT c.integration_id   AS integrationId,
+        d.integration_name AS integrationName
+        FROM kws_project_device a
+        LEFT JOIN kws_device b ON a.device_id = b.id
+        LEFT JOIN kws_device_integration c ON b.id = c.integration_id
+        LEFT JOIN kws_integration d ON c.integration_id = d.id
+        WHERE a.del_flag = 0
+        AND b.del_flag = 0
+        and c.del_flag = 0
+        and d.del_flag
+        and b.id = #{id}
+    </select>
+
+  <select id="selectDataByDeviceId" resultType="com.sckw.slope.detection.model.dto.BaseItemDTO">
+      SELECT
+      c.`name` AS NAME,
+      d.part_name AS partName
+      FROM
+      kws_project_device a
+      LEFT JOIN kws_device b ON a.device_id = b.id
+      LEFT JOIN kws_device_model c ON b.model_id = c.id
+      LEFT JOIN kws_device_model_part d ON c.id = d.device_model_id
+      WHERE
+      a.del_flag = 0
+      AND b.del_flag = 0
+      AND c.del_flag = 0
+      AND d.del_flag =0
+      and b.id = #{id}
+    </select>
 </mapper>

+ 7 - 0
slope-modules/slope-detection/src/main/resources/mapper/mysql/KwsReportTemplateMapper.xml

@@ -195,6 +195,13 @@
         <if test="companyId != null and companyId != ''">
             and mountain_id = #{companyId,jdbcType=VARCHAR}
         </if>
+        <if test="query.name != null and query.name != ''">
+            and name like concat('%', #{query.name}
+            , '%')
+        </if>
+        <if test="query.type != null and query.type != ''">
+            and type =#{query.type}
+        </if>
     </select>
 
     <select id="selectListByReportNameAndProjectId" resultType="com.sckw.slope.detection.model.vo.ReportStatementVO">

+ 13 - 0
slope-modules/slope-detection/src/main/resources/mapper/tdengine/DevicesMapper.xml

@@ -36,4 +36,17 @@
         FROM devicesv2.device_${deviceCode}
         order by ts desc limit 1
     </select>
+
+    <select id="selectLastDataByCodeAndItemName" resultMap="BaseResultMap">
+        SELECT
+        <include refid="Base_List">
+        </include>
+        FROM devicesv2.device_${deviceCode}
+        <where>
+            <if test="itemName != null and itemName != ''">
+                and line = #{itemName}
+            </if>
+        </where>
+        order by ts desc limit 1
+    </select>
 </mapper>