Newspaper 2 роки тому
батько
коміт
31ebd31386

+ 38 - 1
huimv-cattle/src/main/java/com/huimv/cattle/controller/VaccineDeliveryController.java

@@ -4,9 +4,13 @@ package com.huimv.cattle.controller;
 import cn.hutool.core.date.DateUtil;
 import cn.hutool.core.util.ObjectUtil;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.huimv.cattle.mapper.SysRegionCounTownVillMapper;
+import com.huimv.cattle.mapper.VaccineDeliveryMapper;
+import com.huimv.cattle.pojo.DataSource;
 import com.huimv.cattle.pojo.FarmStockRank;
 import com.huimv.cattle.pojo.VaccineDelivery;
 import com.huimv.cattle.pojo.vo.VaccineDeliveryVo;
+import com.huimv.cattle.service.DataSourceService;
 import com.huimv.cattle.service.VaccineDeliveryService;
 import com.huimv.cattle.utils.FarmCodeUtils;
 import com.huimv.common.utils.Result;
@@ -36,6 +40,12 @@ import java.util.Map;
 public class VaccineDeliveryController {
     @Autowired
     private VaccineDeliveryService vaccineDeliveryService;
+    @Autowired
+    private DataSourceService dataSourceService;
+    @Autowired
+    private SysRegionCounTownVillMapper sysRegionCounTownVillMapper;
+    @Autowired
+    private VaccineDeliveryMapper vaccineDeliveryMapper;
 
     @PostMapping("/saveVaccineDelivery")
     @Transactional
@@ -81,8 +91,35 @@ public class VaccineDeliveryController {
             yearNum ="0";
         }
         int year = DateUtil.year(new Date());
-        List<VaccineDelivery> list = vaccineDeliveryService.list(new QueryWrapper<VaccineDelivery>().eq("farm_code",farmCode).ge("year", (year - Integer.parseInt(yearNum))));
+        List<VaccineDelivery> list = vaccineDeliveryService.list(new QueryWrapper<VaccineDelivery>()
+                .eq("farm_code",farmCode)
+                .ge("year", (year - Integer.parseInt(yearNum))));
         return new Result(ResultCode.SUCCESS,list);
     }
+
+    @PostMapping("/getVaccineDeliveryScreen")
+    public  Result getVaccineDeliveryScreen(@RequestBody Map<String,String> paramMap, HttpServletRequest request){
+        String yearNum = paramMap.get("yearNum");
+        String farmCode = FarmCodeUtils.getFarmCode(paramMap.get("farmCode"), request);
+        if (StringUtils.isBlank(yearNum)){
+            yearNum ="0";
+        }
+        int year = DateUtil.year(new Date());
+        DataSource dataSource = dataSourceService.getDataSourceStatus();
+
+        if (dataSource.getDsStatus() == 1 && dataSource.getViewType() == 3){
+            String[] city = sysRegionCounTownVillMapper.listSub(farmCode).split(",");
+            QueryWrapper<VaccineDelivery> queryWrapper = new QueryWrapper<>();
+            queryWrapper.ge("year", (year - Integer.parseInt(yearNum))).orderByDesc("year").in("farm_code",city).groupBy("year");
+            List<VaccineDelivery> list = vaccineDeliveryMapper.getVaccineDeliveryScreen(queryWrapper);
+            return new Result(ResultCode.SUCCESS,list);
+        }else {
+            List<VaccineDelivery> list = vaccineDeliveryService.list(new QueryWrapper<VaccineDelivery>()
+                    .eq("farm_code",farmCode)
+                    .ge("year", (year - Integer.parseInt(yearNum))));
+            return new Result(ResultCode.SUCCESS,list);
+        }
+
+    }
 }
 

+ 8 - 0
huimv-cattle/src/main/java/com/huimv/cattle/mapper/VaccineDeliveryMapper.java

@@ -1,7 +1,13 @@
 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.VaccineDelivery;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Param;
+import org.springframework.stereotype.Repository;
+
+import java.util.List;
 
 /**
  * <p>
@@ -11,6 +17,8 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
  * @author zn
  * @since 2022-12-15
  */
+@Repository
 public interface VaccineDeliveryMapper extends BaseMapper<VaccineDelivery> {
 
+    List<VaccineDelivery> getVaccineDeliveryScreen(@Param(Constants.WRAPPER) QueryWrapper<VaccineDelivery> queryWrapper);
 }

+ 5 - 0
huimv-cattle/src/main/java/com/huimv/cattle/mapper/xml/VaccineDeliveryMapper.xml

@@ -15,4 +15,9 @@
         id, year, delivery_count
     </sql>
 
+    <select id="getVaccineDeliveryScreen" resultType="com.huimv.cattle.pojo.VaccineDelivery">
+        SELECT YEAR,SUM(delivery_count) deliveryCount,farm_code farmCode FROM `vaccine_delivery`
+        ${ew.customSqlSegment}
+    </select>
+
 </mapper>

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

@@ -1,8 +1,11 @@
 package com.huimv.cattle.service;
 
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.huimv.cattle.pojo.VaccineDelivery;
 import com.baomidou.mybatisplus.extension.service.IService;
 
+import java.util.List;
+
 /**
  * <p>
  *  服务类