Sfoglia il codice sorgente

化验记录接口新增

王苗苗 6 mesi fa
parent
commit
bda406ebc6

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

@@ -4,7 +4,9 @@ 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.AssayReq;
 import com.ruoyi.business.req.DeviceReq;
+import com.ruoyi.business.res.AssayDetailRes;
 import com.ruoyi.business.res.DeviceRes;
 import com.ruoyi.business.res.HomeCountsRes;
 import com.ruoyi.business.service.IBusinessService;
@@ -107,7 +109,7 @@ public class BusinessController extends BaseController {
      */
     @GetMapping("/devicePageList")
     public TableDataInfo devicePageList(DeviceReq deviceReq){
-        log.info("进入了 分页获取设备列表(通过类型区分是实验室的还是连续检测的) 接口,类型是{}", JSON.toJSONString(deviceReq));
+        log.info("进入了 分页获取设备列表(通过类型区分是实验室的还是连续检测的) 接口,请求参数是{}", JSON.toJSONString(deviceReq));
         String type = deviceReq.getType();
         if(StringUtils.isBlank(type))
             throw new RuntimeException("设备类型为必填参数");
@@ -119,4 +121,19 @@ public class BusinessController extends BaseController {
         DynamicDataSourceContextHolder.clearDataSourceType();
         return getDataTable(list);
     }
+
+
+    /**
+     *
+     * 接口4:通过设备编号和日期获取质控样的化验记录的明细和各个指标的偏差度等(通过类型区分是实验室的还是连续检测的)
+     */
+    @GetMapping("/assayPageListByDeviceNoAndDate")
+    public TableDataInfo assayPageListByDeviceNoAndDate(AssayReq assayReq){
+        log.info("进入了 通过设备编号和日期获取质控样的化验记录的明细和各个指标的偏差度等 接口,请求参数是{}", JSON.toJSONString(assayReq));
+        DynamicDataSourceContextHolder.setDataSourceType(DataSourceType.SLAVE.name());
+        startPage();
+        List<AssayDetailRes> list = this.businessService.assayPageListByDeviceNoAndDate(assayReq);
+        DynamicDataSourceContextHolder.clearDataSourceType();
+        return getDataTable(list);
+    }
 }

+ 1 - 1
ruoyi-system/src/main/java/com/ruoyi/business/domain/ZAssayResult.java

@@ -50,7 +50,7 @@ public class ZAssayResult
 
     /** 化验浓度值 */
     @Excel(name = "化验浓度值")
-    private Long resultConcentration;
+    private Double resultConcentration;
 
     /** 化验ABS值(吸光度) */
     @Excel(name = "化验ABS值", readConverterExp = "吸=光度")

+ 2 - 2
ruoyi-system/src/main/java/com/ruoyi/business/domain/ZQualityValue.java

@@ -45,11 +45,11 @@ public class ZQualityValue extends BaseEntity
 
     /** 下限值 */
     @Excel(name = "下限值")
-    private Long lowValue;
+    private Double lowValue;
 
     /** 上限值 */
     @Excel(name = "上限值")
-    private Long highValue;
+    private Double highValue;
 
     /** 有效开始时间 */
     @JsonFormat(pattern = "yyyy-MM-dd")

+ 3 - 0
ruoyi-system/src/main/java/com/ruoyi/business/mapper/ZAssayMapper.java

@@ -2,6 +2,8 @@ package com.ruoyi.business.mapper;
 
 import java.util.List;
 import com.ruoyi.business.domain.ZAssay;
+import com.ruoyi.business.req.AssayReq;
+import com.ruoyi.business.res.AssayDetailRes;
 import org.apache.ibatis.annotations.Param;
 
 /**
@@ -64,4 +66,5 @@ public interface ZAssayMapper
 
     int getDistinctCountsByDeviceNoAndDate(@Param("assayDate") String assayDate, @Param("deviceNo") String deviceNo);
 
+    List<AssayDetailRes> assayPageListByDeviceNoAndDate(AssayReq assayReq);
 }

+ 20 - 0
ruoyi-system/src/main/java/com/ruoyi/business/req/AssayReq.java

@@ -0,0 +1,20 @@
+package com.ruoyi.business.req;
+
+
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+@Builder
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+public class AssayReq {
+
+    private String assayDateBegin;//化验日期-开始
+
+    private String assayDateEnd;//化验日期-截止
+
+    private String deviceNo;//设备编号
+}

+ 83 - 0
ruoyi-system/src/main/java/com/ruoyi/business/res/AssayDetailRes.java

@@ -0,0 +1,83 @@
+package com.ruoyi.business.res;
+
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.ruoyi.common.annotation.Excel;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+@Builder
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+public class AssayDetailRes {
+
+    private String assayTime;//化验时间
+
+    private String deviceName;//设备名称
+
+    private String deviceNo;//设备编号
+
+    @JsonIgnore
+    private Long deviceWorks;//水厂ID 通过设备关联
+
+    private String worksName;//所属水厂
+
+    private String assayNo;//化验编号
+
+    private String assayTypeName = "质控样";//样品名称  全部都是质控样
+
+    private Double highCodResultConcentration;//高COD化验值
+
+    private Double highCodStandardVal = 200.0D;//高COD标称值
+
+    private Double highCodDeviationRate;//高COD偏差度
+
+    private Double lowCodResultConcentration;//低COD化验值
+
+    private Double lowCodStandardVal = 50.0D;//低COD标称值
+
+    private Double lowCodDeviationRate;//低COD偏差度
+
+    private Double anDanResultConcentration;//氨氮化验值
+
+    private Double anDanStandardVal = 20.0D;//氨氮标称值
+
+    private Double anDanDeviationRate;//氨氮偏差度
+
+    private Double tnResultConcentration;//总氮化验值
+
+    private Double tnStandardVal = 20.0D;//总氮标称值
+
+    private Double tnDeviationRate;//总氮偏差度
+
+    private Double tpResultConcentration;//总磷化验值
+
+    private Double tpStandardVal = 2.0D;//总磷标称值
+
+    private Double tpDeviationRate;//总磷偏差度
+
+    private Double xsydResultConcentration;//硝酸盐氮化验值
+
+    private Double xsydStandardVal = 20.0D;//硝酸盐氮标称值
+
+    private Double xsydDeviationRate;//硝酸盐氮偏差度
+
+    private Double yxsyResultConcentration;//亚硝酸盐化验值
+
+    private Double yxsyStandardVal = 1.0D;//亚硝酸盐标称值
+
+    private Double yxsyDeviationRate;//亚硝酸盐偏差度
+
+    private Double zlsyResultConcentration;//正磷酸盐化验值
+
+    private Double zlsyStandardVal = 2.0D;//正磷酸标称值
+
+    private Double zlsyDeviationRate;//正磷酸偏差度
+
+
+
+
+
+}

+ 4 - 0
ruoyi-system/src/main/java/com/ruoyi/business/service/IBusinessService.java

@@ -1,6 +1,8 @@
 package com.ruoyi.business.service;
 
+import com.ruoyi.business.req.AssayReq;
 import com.ruoyi.business.req.DeviceReq;
+import com.ruoyi.business.res.AssayDetailRes;
 import com.ruoyi.business.res.DeviceRes;
 import com.ruoyi.business.res.HomeCountsRes;
 
@@ -11,4 +13,6 @@ public interface IBusinessService {
     HomeCountsRes homeCountsInfo(int type);
 
     List<DeviceRes> devicePageList(DeviceReq deviceReq);
+
+    List<AssayDetailRes> assayPageListByDeviceNoAndDate(AssayReq assayReq);
 }

+ 40 - 5
ruoyi-system/src/main/java/com/ruoyi/business/service/impl/BusinessServiceImpl.java

@@ -2,7 +2,9 @@ package com.ruoyi.business.service.impl;
 
 import com.ruoyi.business.domain.*;
 import com.ruoyi.business.mapper.*;
+import com.ruoyi.business.req.AssayReq;
 import com.ruoyi.business.req.DeviceReq;
+import com.ruoyi.business.res.AssayDetailRes;
 import com.ruoyi.business.res.DeviceRes;
 import com.ruoyi.business.res.HomeCountsRes;
 import com.ruoyi.business.service.IBusinessService;
@@ -81,12 +83,45 @@ public class BusinessServiceImpl implements IBusinessService {
         //额外处理其他数据
         if(!CollectionUtils.isEmpty(list)){
             for (DeviceRes deviceRes : list) {
-                this.addExtra(deviceRes, assayDate, deviceRes.getDeviceNo());
+                this.addDeviceExtra(deviceRes, assayDate, deviceRes.getDeviceNo());
             }
         }
         return list;
     }
 
+    @Override
+    public List<AssayDetailRes> assayPageListByDeviceNoAndDate(AssayReq assayReq) {
+        //通过设备编号和日期获取质控样的化验记录的明细化验时间和化验编号
+        List<AssayDetailRes> list = this.zAssayMapper.assayPageListByDeviceNoAndDate(assayReq);
+        if(!CollectionUtils.isEmpty(list)){
+            for (AssayDetailRes assayDetailRes : list) {
+                String assayNo = assayDetailRes.getAssayNo();
+                if(StringUtils.isNotBlank(assayNo)){
+                    this.addAssayExtra(assayNo, assayDetailRes);
+                }
+            }
+        }
+        return list;
+    }
+
+    private void addAssayExtra(String assayNo, AssayDetailRes assayDetailRes) {
+        //分别处理化验设备的名称、水厂的名字字段
+        List<BizDevice> bizDevices = this.bizDeviceMapper.selectBizDeviceList(BizDevice.builder().deviceNo(assayDetailRes.getDeviceNo()).build());
+        if(!CollectionUtils.isEmpty(bizDevices)){
+            assayDetailRes.setDeviceName(bizDevices.get(0).getDeviceName());
+            assayDetailRes.setDeviceWorks(bizDevices.get(0).getDeviceWorks());
+        }
+        List<BizWaterWork> bizWaterWorks = this.bizWaterWorkMapper.selectBizWaterWorkList(BizWaterWork.builder().worksId(assayDetailRes.getDeviceWorks()).build());
+        if(!CollectionUtils.isEmpty(bizWaterWorks)){
+            assayDetailRes.setWorksName(bizWaterWorks.get(0).getWorksName());
+        }
+        //通过化验编号查询所有的化验明细,然后根据类型计算对应的
+        List<ZAssayResult> zAssayResults = this.zAssayResultMapper.selectZAssayResultList(ZAssayResult.builder().assayNo(assayNo).assayType("3").build());
+        if(!CollectionUtils.isEmpty(zAssayResults)){
+            //todo 处理八种类型化验的计算
+        }
+    }
+
     /**
      * 额外处理其他的字段 聚合,查询其他表,计算等
      *
@@ -94,7 +129,7 @@ public class BusinessServiceImpl implements IBusinessService {
      * @param assayDate
      * @param deviceNo
      */
-    private void addExtra(DeviceRes deviceRes, String assayDate, String deviceNo) {
+    private void addDeviceExtra(DeviceRes deviceRes, String assayDate, String deviceNo) {
         //查询最近的一条化验记录明细 及 化验统计(结果)
         List<ZAssayResult> zAssayResults = this.zAssayResultMapper.selectZAssayResultList(ZAssayResult.builder().resultDate(assayDate).assayType("3").deviceNo(deviceNo).build());
         if(!CollectionUtils.isEmpty(zAssayResults)){
@@ -162,14 +197,14 @@ public class BusinessServiceImpl implements IBusinessService {
         //todo 日期临时写死,因为数据不会同步,都是历史数据  正式以后,需要改成真实日期
 //        Date nowDate = DateUtils.getNowDate();
         Date nowDate = DateUtils.parseDate("2024-08-13");
-        Long resultConcentration = zAssayResult.getResultConcentration();//化验的真实值
+        Double resultConcentration = zAssayResult.getResultConcentration();//化验的真实值
         //去查询配置的标准值的范围(数据不确认,有可能是多个,获取最后一条数据):
         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(0);//获取最新的一条,防止有多条数据的情况
-            Long lowValue = zQualityValue.getLowValue();
-            Long highValue = zQualityValue.getHighValue();
+            Double lowValue = zQualityValue.getLowValue();
+            Double highValue = zQualityValue.getHighValue();
             if(!Objects.isNull(resultConcentration) && !Objects.isNull(lowValue) && !Objects.isNull(highValue)){
                 isPassed = resultConcentration >= lowValue && resultConcentration <= highValue;
             }

+ 12 - 0
ruoyi-system/src/main/resources/mapper/business/ZAssayMapper.xml

@@ -169,4 +169,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     <select id="getDistinctCountsByDeviceNoAndDate" resultType="int">
         SELECT COUNT(DISTINCT assay_no) FROM z_assay WHERE assay_date = #{assayDate} AND device_no = #{deviceNo}
     </select>
+
+    <select id="assayPageListByDeviceNoAndDate" parameterType="com.ruoyi.business.req.AssayReq" resultType="com.ruoyi.business.res.AssayDetailRes">
+        SELECT DISTINCT
+            update_time assayTime,
+            device_no deviceNo,
+            assay_no assayNo
+        FROM
+            z_assay
+        WHERE
+            device_no = #{deviceNo}
+          AND assay_date between #{assayDateBegin} and #{assayDateEnd}
+    </select>
 </mapper>