Browse Source

修改数据源字段

523096025 2 years ago
parent
commit
3ef5cc9284

+ 23 - 0
huimv-cattle/src/main/java/com/huimv/cattle/controller/PreventDetectionController.java

@@ -4,8 +4,10 @@ package com.huimv.cattle.controller;
 import cn.hutool.core.util.ObjectUtil;
 import com.alibaba.druid.wall.violation.ErrorCode;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.huimv.cattle.pojo.DataSource;
 import com.huimv.cattle.pojo.PreventDetection;
 import com.huimv.cattle.pojo.vo.PreventDetectionVo;
+import com.huimv.cattle.service.DataSourceService;
 import com.huimv.cattle.service.PreventDetectionService;
 import com.huimv.cattle.token.TokenSign;
 import com.huimv.cattle.utils.FarmCodeUtils;
@@ -15,6 +17,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.web.bind.annotation.*;
 
+import javax.annotation.Resource;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import java.util.ArrayList;
@@ -35,6 +38,8 @@ import java.util.Map;
 public class PreventDetectionController {
     @Autowired
     private PreventDetectionService preventDetectionService;
+    @Resource
+    private DataSourceService dataSourceService;
 
     @Transactional
     @PostMapping("/savePreventDetection")
@@ -72,6 +77,24 @@ public class PreventDetectionController {
         }
         return new Result(ResultCode.SUCCESS,list);
     }
+    @PostMapping("/getPreventDetectionScreen")
+    public  Result getPreventDetectionScreen(@RequestBody PreventDetection preventDetection,HttpServletRequest request){
+        String farmCode = FarmCodeUtils.getFarmCode(preventDetection.getFarmCode(), request);
+        DataSource dataSource = dataSourceService.getDataSourceStatus();
+        //镇汇总
+        List<PreventDetection> list = new ArrayList<>();
+        if (dataSource.getDsStatus() == 1 && dataSource.getViewType() ==2) {
+            list = preventDetectionService.getPreventDetectionScreen();
+        }else {
+            list = preventDetectionService.list(new QueryWrapper<PreventDetection>().eq("farm_code",farmCode).orderByDesc("year").orderByDesc("month"));
+            if (ObjectUtil.isEmpty(list)){
+                return new Result(ResultCode.SUCCESS,new ArrayList<>());
+            }
+        }
+        //县填写
+        return new Result(ResultCode.SUCCESS,list);
+    }
+
 
 
 }

+ 4 - 0
huimv-cattle/src/main/java/com/huimv/cattle/mapper/PreventDetectionMapper.java

@@ -3,6 +3,8 @@ package com.huimv.cattle.mapper;
 import com.huimv.cattle.pojo.PreventDetection;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 
+import java.util.List;
+
 /**
  * <p>
  *  Mapper 接口
@@ -13,4 +15,6 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
  */
 public interface PreventDetectionMapper extends BaseMapper<PreventDetection> {
 
+    List<PreventDetection> getPreventDetectionScreen();
+
 }

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

@@ -16,5 +16,9 @@
     <sql id="Base_Column_List">
         id, month_name, month, detection_num, acceptance_num
     </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 != 0 GROUP BY `year` ,`month` order  by `year` ,`month` DESC
+    </select>
 
 </mapper>

+ 3 - 0
huimv-cattle/src/main/java/com/huimv/cattle/service/PreventDetectionService.java

@@ -3,6 +3,8 @@ package com.huimv.cattle.service;
 import com.huimv.cattle.pojo.PreventDetection;
 import com.baomidou.mybatisplus.extension.service.IService;
 
+import java.util.List;
+
 /**
  * <p>
  *  服务类
@@ -13,4 +15,5 @@ import com.baomidou.mybatisplus.extension.service.IService;
  */
 public interface PreventDetectionService extends IService<PreventDetection> {
 
+    List<PreventDetection> getPreventDetectionScreen();
 }

+ 10 - 0
huimv-cattle/src/main/java/com/huimv/cattle/service/impl/PreventDetectionServiceImpl.java

@@ -4,8 +4,11 @@ import com.huimv.cattle.pojo.PreventDetection;
 import com.huimv.cattle.mapper.PreventDetectionMapper;
 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.List;
+
 /**
  * <p>
  *  服务实现类
@@ -17,4 +20,11 @@ import org.springframework.stereotype.Service;
 @Service
 public class PreventDetectionServiceImpl extends ServiceImpl<PreventDetectionMapper, PreventDetection> implements PreventDetectionService {
 
+    @Autowired
+    private PreventDetectionMapper preventDetectionMapper;
+
+    @Override
+    public List<PreventDetection> getPreventDetectionScreen() {
+        return preventDetectionMapper.getPreventDetectionScreen();
+    }
 }