Просмотр исходного кода

设备相关的3个接口支持不传类型 获取所有数据

王苗苗 5 месяцев назад
Родитель
Сommit
e397970528

+ 5 - 4
ruoyi-admin/src/main/java/com/ruoyi/web/controller/business/BusinessController.java

@@ -110,8 +110,8 @@ public class BusinessController extends BaseController {
      * 接口1:获取首页的统计信息(通过类型区分是实验室的还是连续检测的)
      * @param type 1:化验室,2:连续检测
      */
-    @GetMapping("/homeCountsInfo/{type}")
-    public R<HomeCountsRes> homeCountsInfo(@PathVariable Integer type){
+    @GetMapping("/homeCountsInfo")
+    public R<HomeCountsRes> homeCountsInfo(@RequestParam(value = "type" ,required = false) String type){
         log.info("进入了 获取首页的统计信息(通过类型区分是实验室的还是连续检测的) 接口,类型是{}", type);
         DynamicDataSourceContextHolder.setDataSourceType(DataSourceType.SLAVE.name());
         HomeCountsRes homeCountsRes = this.businessService.homeCountsInfo(type);
@@ -141,11 +141,12 @@ public class BusinessController extends BaseController {
     @GetMapping("/devicePageList")
     public TableDataInfo devicePageList(DeviceReq deviceReq){
         log.info("进入了 分页获取设备列表(通过类型区分是实验室的还是连续检测的) 接口,请求参数是{}", JSON.toJSONString(deviceReq));
-        String type = deviceReq.getType();
+        //2024年10月25日09:53:18 类型可以不传,获取所有
+        /*String type = deviceReq.getType();
         if(StringUtils.isBlank(type))
             throw new RuntimeException("设备类型为必填参数");
         if(!"1".equals(type) && !"2".equals(type))
-            throw new RuntimeException("请输入正确的设备类型");
+            throw new RuntimeException("请输入正确的设备类型");*/
         DynamicDataSourceContextHolder.setDataSourceType(DataSourceType.SLAVE.name());
         startPage();
         List<DeviceRes> list = this.businessService.devicePageList(deviceReq);

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

@@ -10,7 +10,7 @@ import java.util.Map;
 
 public interface IBusinessService {
 
-    HomeCountsRes homeCountsInfo(int type);
+    HomeCountsRes homeCountsInfo(String type);
 
     List<DeviceRes> devicePageList(DeviceReq deviceReq);
 

+ 9 - 3
ruoyi-system/src/main/java/com/ruoyi/business/service/impl/BusinessServiceImpl.java

@@ -42,14 +42,20 @@ public class BusinessServiceImpl implements IBusinessService {
     private ZQualityValueMapper zQualityValueMapper;
 
 
+    /**
+     * 2024年10月25日09:46:36  新增逻辑:type可以不传。
+     * @param type
+     * @return
+     */
     @Override
-    public HomeCountsRes homeCountsInfo(int type) {//type 1:化验室,2:连续检测
+    public HomeCountsRes homeCountsInfo(String type) {//type 1:化验室,2:连续检测
         HomeCountsRes build = HomeCountsRes.builder().build();
         //处理各个维度的统计信息
         //获取所有的正在使用的设备列表 大概几十个,所以直接取所有数据,下面再过滤
-        List<BizDevice> bizDevices = this.bizDeviceMapper.selectBizDeviceList(BizDevice.builder().deviceStatus("0").build());
+        //2024年10月25日09:51:12 type可以不传,直接查询对应的数据
+        List<BizDevice> totalList = this.bizDeviceMapper.selectBizDeviceList(BizDevice.builder().deviceStatus("0").type(type).build());
         //一定有设备 并且mybatis返回的默认是空集合new出来的而不是null,所以这里不用判断
-        List<BizDevice> totalList = bizDevices.stream().filter(bizDevice -> String.valueOf(type).equals(bizDevice.getType())).collect(Collectors.toList());
+//        List<BizDevice> totalList = bizDevices.stream().filter(bizDevice -> String.valueOf(type).equals(bizDevice.getType())).collect(Collectors.toList());
         if (!CollectionUtils.isEmpty(totalList)) {
             build.setDeviceTotals((long) totalList.size());
             //化验中

+ 2 - 1
ruoyi-system/src/main/resources/mapper/business/BizDeviceMapper.xml

@@ -203,10 +203,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             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 AND bd.type = #{type}
+        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>
         <if test="deviceNo != null  and deviceNo != ''"> and bd.device_no = #{deviceNo}</if>
+        <if test="type != null  and type != ''"> and bd.type = #{type}</if>
         order by bd.device_id desc
     </select>
 </mapper>