15928045575 2 лет назад
Родитель
Сommit
46c7b356eb

+ 2 - 1
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/dao/mysql/KwsDeviceIntegrationMapper.java

@@ -4,6 +4,7 @@ import com.baomidou.dynamic.datasource.annotation.DS;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.sckw.slope.detection.model.dos.mysql.KwsDeviceIntegration;
 import com.sckw.slope.detection.model.dto.DeviceElementDTO;
+import com.sckw.slope.detection.model.vo.DeviceIntegrationVo;
 import com.sckw.slope.detection.model.vo.DeviceVo;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
@@ -33,5 +34,5 @@ public interface KwsDeviceIntegrationMapper extends BaseMapper<KwsDeviceIntegrat
 
     List<KwsDeviceIntegration> selectListByParms(@Param("vo") DeviceVo vo);
 
-    List<KwsDeviceIntegration> selectListByParmsAndInterName(@Param("vo") DeviceVo vo);
+    List<DeviceIntegrationVo> selectListByParmsAndInterName(@Param("vo") DeviceVo vo);
 }

+ 9 - 0
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/dao/mysql/KwsDeviceReferenceMapper.java

@@ -2,8 +2,15 @@ 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.KwsDeviceModel;
 import com.sckw.slope.detection.model.dos.mysql.KwsDeviceReference;
+import com.sckw.slope.detection.model.vo.DevicePartModelVo;
+import com.sckw.slope.detection.model.vo.DeviceReferenceVo;
+import com.sckw.slope.detection.model.vo.DeviceVo;
 import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
 
 @Mapper
 @DS("mysql")
@@ -19,4 +26,6 @@ public interface KwsDeviceReferenceMapper extends BaseMapper<KwsDeviceReference>
     int updateByPrimaryKeySelective(KwsDeviceReference record);
 
     int updateByPrimaryKey(KwsDeviceReference record);
+
+    List<DeviceReferenceVo>  selectByDeviceId(@Param("vo") DeviceVo vo);
 }

+ 1 - 0
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/dao/tdengine/SlopeDataMapper.java

@@ -35,4 +35,5 @@ public interface SlopeDataMapper extends BaseMapper<SlopeData> {
     List<SlopeData> selectListByLineOrderByCreateTime(@Param("snCode") String snCode, @Param("item") String item);
 
     List<SlopeDataVo> selectListByMaster(@Param("page") Integer page, @Param("pageSize") Integer pageSize);
+
 }

+ 1 - 4
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/model/dos/mysql/KwsDeviceIntegration.java

@@ -62,10 +62,7 @@ public class KwsDeviceIntegration implements Serializable {
     @TableLogic(value = "0")
     private int delFlag;
 
-    /**
-     *
-     */
-    private String integrationName;
+
 
     private static final long serialVersionUID = 1L;
 

+ 79 - 0
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/model/vo/DeviceIntegrationVo.java

@@ -0,0 +1,79 @@
+package com.sckw.slope.detection.model.vo;
+
+import com.baomidou.mybatisplus.annotation.TableLogic;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.sckw.slope.detection.model.dos.mysql.KwsDeviceIntegration;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.time.LocalDateTime;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * @author lfdc
+ * @description vo
+ * @date 2023-10-30 13:10:38
+ */
+@Data
+public class DeviceIntegrationVo implements Serializable {
+    private Long id;
+
+    /**
+     * 设备id
+     */
+    private Long deviceId;
+
+    /**
+     * 企业id
+     */
+    private String mountainId;
+
+    /**
+     * 集成要素id
+     */
+    private Long integrationId;
+
+    /**
+     * 状态
+     */
+    private Integer status;
+
+    /**
+     * 创建人
+     */
+    private Long createBy;
+
+    /**
+     * 创建时间
+     */
+    private LocalDateTime createTime;
+
+    /**
+     * 修改人
+     */
+    private Long updateBy;
+
+    /**
+     * 修改时间
+     */
+    private LocalDateTime updateTime;
+
+    /**
+     * 删除标识
+     */
+    @TableLogic(value = "0")
+    private int delFlag;
+
+    /**
+     *
+     */
+    private String integrationName;
+
+    /**
+     *
+     */
+    private String integrationBaseData;
+
+    private static final long serialVersionUID = 1L;
+}

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

@@ -34,6 +34,11 @@ public class DevicePartModelVo implements Serializable {
      */
     private String partNameDesc;
 
+    /**
+     * 要素基准
+     */
+    private String partBaseData;
+
     /**
      * 状态
      */

+ 89 - 0
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/model/vo/DeviceReferenceVo.java

@@ -0,0 +1,89 @@
+package com.sckw.slope.detection.model.vo;
+
+import com.baomidou.mybatisplus.annotation.TableLogic;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.sckw.slope.detection.model.dos.mysql.KwsDeviceIntegration;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.time.LocalDateTime;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * @author sky
+ * @description vo
+ * @date 2023-10-30 13:10:38
+ */
+@Data
+public class DeviceReferenceVo implements Serializable {
+    private Long id;
+
+    /**
+     * 设备id
+     */
+    private Long deviceId;
+
+    /**
+     * 基准项
+     */
+    private String item;
+
+    private String mountainId;
+
+    /**
+     * 原始基准值
+     */
+    private BigDecimal originalValue;
+
+    /**
+     * 当前基准值
+     */
+    private BigDecimal currentValue;
+
+    /**
+     * 偏移量
+     */
+    private BigDecimal offset;
+
+    /**
+     * 状态
+     */
+    private int status;
+
+    /**
+     * 创建人
+     */
+    private Long createBy;
+
+    /**
+     * 创建时间
+     */
+    private LocalDateTime createTime;
+
+    /**
+     * 修改人
+     */
+    private Long updateBy;
+
+    /**
+     * 修改时间
+     */
+    private LocalDateTime updateTime;
+
+    /**
+     * 要素类型 1 基本要素 2 集成要素
+     */
+    private int  type;
+
+    /**
+     * 删除标识
+     */
+    @TableLogic(value = "0")
+    private int delFlag;
+
+
+
+    private static final long serialVersionUID = 1L;
+}

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

@@ -3,12 +3,14 @@ package com.sckw.slope.detection.model.vo;
 import com.baomidou.mybatisplus.annotation.TableLogic;
 import com.fasterxml.jackson.annotation.JsonFormat;
 import com.sckw.slope.detection.model.dos.mysql.KwsDeviceIntegration;
+import com.sckw.slope.detection.model.dos.mysql.KwsDeviceReference;
 import lombok.Data;
 
 import java.io.Serializable;
 import java.time.LocalDateTime;
 import java.util.Date;
 import java.util.List;
+import java.util.Map;
 
 /**
  * @author lfdc
@@ -159,7 +161,7 @@ public class DeviceVo implements Serializable {
     /**
      * 产品类型
      */
-    private List<KwsDeviceIntegration> integration;
+    private List<DeviceIntegrationVo> integration;
 
     /**
      * 检测时间
@@ -173,5 +175,7 @@ public class DeviceVo implements Serializable {
 
 
 
+
+
     private static final long serialVersionUID = 1L;
 }

+ 74 - 13
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/service/DeviceService.java

@@ -17,6 +17,7 @@ import com.sckw.core.utils.IdWorker;
 import com.sckw.core.utils.StringUtils;
 import com.sckw.core.web.constant.HttpStatus;
 import com.sckw.core.web.response.HttpResult;
+import com.sckw.excel.utils.DateUtil;
 import com.sckw.slope.detection.dao.mysql.*;
 import com.sckw.slope.detection.dao.tdengine.InsTablesMapper;
 import com.sckw.slope.detection.dao.tdengine.SlopeDataMapper;
@@ -26,10 +27,7 @@ import com.sckw.slope.detection.model.dos.tdengine.SlopeData;
 import com.sckw.slope.detection.model.dto.*;
 import com.sckw.slope.detection.model.param.DeviceAdd;
 import com.sckw.slope.detection.model.param.DeviceQuery;
-import com.sckw.slope.detection.model.vo.DeviceOutputValueVO;
-import com.sckw.slope.detection.model.vo.DevicePartModelVo;
-import com.sckw.slope.detection.model.vo.DeviceVo;
-import com.sckw.slope.detection.model.vo.ProjectDeviceVO;
+import com.sckw.slope.detection.model.vo.*;
 import jakarta.servlet.http.HttpServletRequest;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.http.HttpResponse;
@@ -93,6 +91,8 @@ public class DeviceService {
     KwsDeviceReferenceMapper deviceReferenceMapper;
 
 
+
+
     @Transactional
     public HttpResult dels(String ids) {
         List<Long> list = StringUtils.splitStrToList(ids, Long.class);
@@ -210,30 +210,91 @@ public class DeviceService {
             put("code", DictEnum.MODEL_PART.getCodeType());
             put("type", "1");
         }});
-        //获取集成要素
-        List<KwsDeviceIntegration> intergData = new ArrayList<>();
-        intergData = deviceIntegrationMapper.selectListByParmsAndInterName(vo);
-        if(!Objects.isNull(intergData)){
-            vo.setIntegration(intergData);
-        }
+        //获取设备基准信息
+        HeaderData headerData = commonService.getHeaderData(response);
+        List<KwsDeviceReference> references = deviceReferenceMapper.selectList(new LambdaQueryWrapper<KwsDeviceReference>()
+                .eq(KwsDeviceReference::getDeviceId, id)
+                .eq(KwsDeviceReference::getMountainId, headerData.getMountainId())
+                .eq(KwsDeviceReference::getDelFlag, NumberConstant.ZERO)
+        );
         //获取基础要数
         List<DevicePartModelVo> partData = new ArrayList<>();
         partData = deviceModelPartMapper.selectByModelId(deviceModel.getId());
         if(!Objects.isNull(partData)){//首先在kws_device_model_part获取数据,然后到字典中查询
-
             for (DevicePartModelVo part : partData) {
                 for (SystemDict value : dictList.values()) {
                     if (part.getPartName().equals(value.getValue())) {
                         part.setPartNameDesc(value.getLabel());
                     }
                 }
+                references.forEach(re -> {
+                        if (part.getPartName().equals(re.getItem())) {
+                            part.setPartBaseData(re.getOriginalValue().toString());
+                        }
+                });
             }
             vo.setPart(partData);
-            //vo.setIntegration(intergData);
         }
-        //获取设备基准信息
 
+        //获取集成要素
+        List<DeviceIntegrationVo> intergData = new ArrayList<>();
+        intergData = deviceIntegrationMapper.selectListByParmsAndInterName(vo);
+        if(!Objects.isNull(intergData)){
+            for (DeviceIntegrationVo inter : intergData) {
+                references.forEach(re -> {
+                    if (inter.getIntegrationName().equals(re.getItem())) {
+                        inter.setIntegrationBaseData(re.getOriginalValue().toString());
+                    }
+                });
+            }
+            vo.setIntegration(intergData);
+        }
+
+
+
+        //vo.setReference(references);
+        //获取td里面的要数数据
+        /*List<Map<String, DeviceOutputValueVO>> mapList = new ArrayList<>();
+        if (!CollectionUtils.isEmpty(references)) {
+            vo.setReference(references);
+            references.forEach(re -> {
+                String snCode = device.getSnCode();
+                String item = re.getItem();
+                Date date = new Date();
+                BigDecimal decimal = new BigDecimal("0.00");
+                String dateStart = DateUtil.getLastWeekDateEndToString(6);
+                String dateEnd = LocalDateTime.now().toString();
+                List<SlopeData> selected = slopeDataMapper.selectLineList(snCode, item, dateStart,dateEnd);
+                List<Map<String, Object>> mapListXy = new ArrayList<>();
+                if (!CollectionUtils.isEmpty(selected)) {
+                    for (int i = 0; i < selected.size(); i++) {
+                        Map<String, Object> map = new HashMap<>();
+                        SlopeData currSlopeData = selected.get(i);
+                        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("MM-dd HH:mm:ss");
+                        String key = simpleDateFormat.format(currSlopeData.getTs());
+                        SlopeData lastSlopeData = selected.get(i + 1);
+                        Date localDateTime = currSlopeData.getTs();
+                        long epochMilli1 = 0L;
+                        String val2 = "0";
+                        Date localDateTime1 = lastSlopeData.getTs();
+                        if (lastSlopeData != null) {
+                            epochMilli1 = localDateTime1.getTime();
+                            val2 = lastSlopeData.getVal();
+                        }
+                        long epochMilli = localDateTime.getTime();
+                        epochMilli1 = localDateTime1.getTime();
+                        String val1 = currSlopeData.getVal();
+                        long t = (epochMilli - epochMilli1) / (60 * 60 * 1000);
+                        long val = Long.parseLong(val1) - Long.parseLong(val2);
+                        decimal = BigDecimal.valueOf(val).divide((new BigDecimal(t).multiply(new BigDecimal(t))), 9, BigDecimal.ROUND_HALF_UP);
+                        map.put(key, decimal);
+                        mapListXy.add(map);
+                    }
+                }
+                vo.setMonitor(mapListXy);
+            });
 
+        }*/
         return HttpResult.ok(vo);
     }
 

+ 1 - 1
slope-modules/slope-detection/src/main/resources/mapper/mysql/KwsDeviceIntegrationMapper.xml

@@ -200,7 +200,7 @@
         </if>
     </select>
 
-    <select id="selectListByParmsAndInterName" resultType="com.sckw.slope.detection.model.dos.mysql.KwsDeviceIntegration">
+    <select id="selectListByParmsAndInterName" resultType="com.sckw.slope.detection.model.vo.DeviceIntegrationVo">
         <!--@mbg.generated-->
         select
         d.id,d.integration_id,integration_name,part_names

+ 12 - 0
slope-modules/slope-detection/src/main/resources/mapper/mysql/KwsDeviceReferenceMapper.xml

@@ -43,6 +43,18 @@
         from kws_device_reference
         where id = #{id,jdbcType=BIGINT}
     </select>
+
+    <select id="selectByDeviceId" resultType="com.sckw.slope.detection.model.vo.DeviceReferenceVo">
+        <!--@mbg.generated-->
+        select
+        <include refid="Base_Column_List"/>
+        from kws_device_reference
+        where del_flag = 0
+        <if test="vo.id != null and vo.id != ''">
+            and device_id = #{vo.id,jdbcType=BIGINT}
+        </if>
+
+    </select>
     <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
         <!--@mbg.generated-->
         delete