소스 검색

新增分页获取设备及统计接口

王苗苗 6 달 전
부모
커밋
8a09e0e33e

+ 1 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/controller/business/BusinessController.java

@@ -1,6 +1,7 @@
 package com.ruoyi.web.controller.business;
 
 import com.alibaba.fastjson2.JSON;
+import com.github.pagehelper.PageHelper;
 import com.ruoyi.business.domain.*;
 import com.ruoyi.business.mapper.*;
 import com.ruoyi.business.req.DeviceReq;

+ 8 - 1
ruoyi-admin/src/main/resources/application.yml

@@ -107,10 +107,17 @@ mybatis:
   configLocation: classpath:mybatis/mybatis-config.xml
 
 # PageHelper分页插件
+#pagehelper:
+#  helperDialect: mysql
+#  supportMethodsArguments: true
+#  params: count=countSql
+#PageHelper分页插件 需要支持多数据源
 pagehelper:
-  helperDialect: mysql
+  reasonable: true
   supportMethodsArguments: true
   params: count=countSql
+  autoRuntimeDialect: true
+
 
 # Swagger配置
 swagger:

+ 10 - 0
ruoyi-system/src/main/java/com/ruoyi/business/mapper/BizDeviceMapper.java

@@ -2,6 +2,8 @@ package com.ruoyi.business.mapper;
 
 import java.util.List;
 import com.ruoyi.business.domain.BizDevice;
+import com.ruoyi.business.req.DeviceReq;
+import com.ruoyi.business.res.DeviceRes;
 
 /**
  * 设备Mapper接口
@@ -58,4 +60,12 @@ public interface BizDeviceMapper
      * @return 结果
      */
     public int deleteBizDeviceByDeviceIds(Long[] deviceIds);
+
+    /**
+     *
+     * 获取在线的设备的部分信息
+     * @param deviceReq
+     * @return 结果
+     */
+    List<DeviceRes> devicePageList(DeviceReq deviceReq);
 }

+ 2 - 2
ruoyi-system/src/main/java/com/ruoyi/business/req/DeviceReq.java

@@ -12,10 +12,10 @@ import lombok.NoArgsConstructor;
 @NoArgsConstructor
 public class DeviceReq {
 
-    private String assayStatus;//化验状态(0:在线;1:离线;2:化验中
+    private String assayStatus;//化验状态(0:在线;1:离线;2:化验中)
 
     private String assayTime;//化验日期
 
-    private String deviceName;//设备名称,也是水厂的名称
+    private String worksId;//水厂ID
 
 }

+ 42 - 2
ruoyi-system/src/main/java/com/ruoyi/business/res/DeviceRes.java

@@ -1,18 +1,58 @@
 package com.ruoyi.business.res;
 
-
+import com.fasterxml.jackson.annotation.JsonIgnore;
 import lombok.AllArgsConstructor;
 import lombok.Builder;
 import lombok.Data;
 import lombok.NoArgsConstructor;
 
+import java.util.Date;
+
 @Builder
 @Data
 @AllArgsConstructor
 @NoArgsConstructor
 public class DeviceRes {
 
-    private String deviceId;
+    //---------设备相关 可以直接bean的copy---------
+    private Long deviceId;//设备ID
+
+    private String deviceName;//设备名称
+
+    private String deviceNo;//设备编号
+
+//    @JsonIgnore
+//    private Long deviceWorks;//水厂ID
+
+    //---------单独查一下水厂---------
+    private String worksName;//水厂名称
+
+    private String assayStatus;//化验状态(0:在线;1:离线;2:化验中)
+
+//    private String deviceStatus;//设备状态(0:使用;1:停用)
+
+
+    //---------查询化验记录---------
+//    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private String lastAssayTime;//最近一次化验时间
+
+    private String beginAssayTime;//化验开始时间
+
+    private double assayProgress;//化验进度  计算
+
+    private double currentTemperature;//当前温度
+
+    private double currentHumidity;//当前湿度
+
+    private int assayCounts;//检验轮次 聚合
+
+    private int assayTotals;//检验总次数  聚合
+
+    private double passCheckRates;//合格率(质控样) 计算
+
+    private double wasteLiquidAmounts;//废液产生总量  todo 待提供数据
+
+
 
 
 }

+ 20 - 6
ruoyi-system/src/main/java/com/ruoyi/business/service/impl/BusinessServiceImpl.java

@@ -1,9 +1,6 @@
 package com.ruoyi.business.service.impl;
 
-import com.ruoyi.business.domain.BizDevice;
-import com.ruoyi.business.domain.ZAssay;
-import com.ruoyi.business.domain.ZAssayResult;
-import com.ruoyi.business.domain.ZQualityValue;
+import com.ruoyi.business.domain.*;
 import com.ruoyi.business.mapper.*;
 import com.ruoyi.business.req.DeviceReq;
 import com.ruoyi.business.res.DeviceRes;
@@ -73,7 +70,24 @@ public class BusinessServiceImpl implements IBusinessService {
 
     @Override
     public List<DeviceRes> devicePageList(DeviceReq deviceReq) {
-        return Collections.emptyList();
+        //先获取设备列表 直接写SQL了,不使用copy
+        List<DeviceRes> list =this.bizDeviceMapper.devicePageList(deviceReq);
+        //额外处理其他数据
+        if(!CollectionUtils.isEmpty(list)){
+            for (DeviceRes deviceRes : list) {
+                this.addExtra(deviceRes);
+            }
+        }
+        return list;
+    }
+
+    /**
+     * 额外处理其他的字段 聚合,查询其他表,计算等
+     * @param deviceRes
+     */
+    private void addExtra(DeviceRes deviceRes) {
+        //查询最近的一条化验记录明细
+
     }
 
     //判断每个质控样的数是否各个,然后获取汇总的数量
@@ -108,7 +122,7 @@ public class BusinessServiceImpl implements IBusinessService {
         List<ZQualityValue> list = this.zQualityValueMapper.selectZQualityValueList(ZQualityValue.builder().beginTime(nowDate).endTime(nowDate).deviceWorks(bizDevices.get(0).getDeviceWorks()).assayItem(zAssayResult.getAssayItem()).build());
         //理论上是只有一个的
         if(!CollectionUtils.isEmpty(list)){
-            ZQualityValue zQualityValue = list.get(list.size() - 1);//获取最新的一条,防止有多条数据的情况
+            ZQualityValue zQualityValue = list.get(0);//获取最新的一条,防止有多条数据的情况
             Long lowValue = zQualityValue.getLowValue();
             Long highValue = zQualityValue.getHighValue();
             if(!Objects.isNull(resultConcentration) && !Objects.isNull(lowValue) && !Objects.isNull(highValue)){

+ 16 - 0
ruoyi-system/src/main/resources/mapper/business/BizDeviceMapper.xml

@@ -190,4 +190,20 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             #{deviceId}
         </foreach>
     </delete>
+
+    <!-- 2024年09月27日10:21:37 下面是新增的SQL,不允许覆盖 -->
+    <select id="devicePageList" parameterType="com.ruoyi.business.req.DeviceReq" resultType="com.ruoyi.business.res.DeviceRes">
+        SELECT
+            bd.device_id deviceId,
+            bd.device_name deviceName,
+            bd.device_no deviceNo,
+            bzw.works_name worksName
+        FROM
+            biz_device bd
+        INNER JOIN biz_water_work bzw
+        on bd.device_works = bzw.works_id
+        WHERE bd.device_status = '0' AND bzw.del_flag = 0
+        <if test="assayStatus != null  and assayStatus != ''"> and bd.assay_status = #{assayStatus}</if>
+        <if test="worksId != null  and worksId != ''"> and bzw.works_id = #{worksId}</if>
+    </select>
 </mapper>