Jelajahi Sumber

修改防疫检测bug

523096025 2 tahun lalu
induk
melakukan
15707fed4a

+ 3 - 1
huimv-cattle/src/main/java/com/huimv/cattle/mapper/PreventDetectionMapper.java

@@ -1,5 +1,7 @@
 package com.huimv.cattle.mapper;
 
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.toolkit.Constants;
 import com.huimv.cattle.pojo.PreventDetection;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import org.apache.ibatis.annotations.Param;
@@ -16,6 +18,6 @@ import java.util.List;
  */
 public interface PreventDetectionMapper extends BaseMapper<PreventDetection> {
 
-    List<PreventDetection> getPreventDetectionScreen(@Param("farmCode")String farmCode);
+    List<PreventDetection> getPreventDetectionScreen(@Param(Constants.WRAPPER) QueryWrapper<PreventDetection> queryWrapper);
 
 }

+ 1 - 1
huimv-cattle/src/main/java/com/huimv/cattle/mapper/xml/PreventDetectionMapper.xml

@@ -18,7 +18,7 @@
     </sql>
     <select id="getPreventDetectionScreen" resultType="com.huimv.cattle.pojo.PreventDetection">
         SELECT SUM(detection_num) detectionNum ,SUM(acceptance_num) acceptanceNum,`year`,month_name ,`month` , farm_code FROM `prevent_detection`
-        WHERE farm_code = #{farmCode} GROUP BY `year` ,`month` order  by `year` DESC,`month` DESC
+         ${ew.customSqlSegment}  GROUP BY `year` ,`month` order  by `year` DESC,`month` DESC
     </select>
 
 </mapper>

+ 15 - 2
huimv-cattle/src/main/java/com/huimv/cattle/service/impl/PreventDetectionServiceImpl.java

@@ -1,14 +1,20 @@
 package com.huimv.cattle.service.impl;
 
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.toolkit.StringUtils;
+import com.huimv.cattle.mapper.SysFarmMapper;
 import com.huimv.cattle.pojo.PreventDetection;
 import com.huimv.cattle.mapper.PreventDetectionMapper;
+import com.huimv.cattle.pojo.SysFarm;
 import com.huimv.cattle.service.PreventDetectionService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.List;
+import java.util.stream.Collectors;
 
 /**
  * <p>
@@ -23,12 +29,19 @@ public class PreventDetectionServiceImpl extends ServiceImpl<PreventDetectionMap
 
     @Autowired
     private PreventDetectionMapper preventDetectionMapper;
+    @Autowired
+    private SysFarmMapper sysFarmMapper;
 
     @Override
     public List<PreventDetection> getPreventDetectionScreen(String farmCode) {
+        List<String> farmCodes = Arrays.asList();
+        //没传farmId
         if (StringUtils.isBlank(farmCode)){
-            farmCode = "0";
+            List<SysFarm> sysFarms = sysFarmMapper.selectList(null);
+            farmCodes = sysFarms.stream().map(SysFarm::getFarmCode).collect(Collectors.toList());
         }
-        return preventDetectionMapper.getPreventDetectionScreen(farmCode);
+        QueryWrapper<PreventDetection> wrapper = new QueryWrapper<>();
+        wrapper.in("farm_code",farmCodes);
+        return preventDetectionMapper.getPreventDetectionScreen(wrapper);
     }
 }