Преглед на файлове

判断补贴统计、生产规模、产业产值重复日期 养殖分布重复类型

Newspaper преди 2 години
родител
ревизия
e690c3c361

+ 17 - 2
huimv-cattle/src/main/java/com/huimv/cattle/service/impl/FarmKindCountServiceImpl.java

@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.huimv.cattle.pojo.FarmKindCount;
 import com.huimv.cattle.mapper.FarmKindCountMapper;
 import com.huimv.cattle.pojo.IndustryOutput;
+import com.huimv.cattle.pojo.ProductionCapacity;
 import com.huimv.cattle.service.FarmKindCountService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.huimv.cattle.token.TokenSign;
@@ -16,8 +17,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import javax.servlet.http.HttpServletRequest;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 
 /**
  * <p>
@@ -51,6 +51,12 @@ public class FarmKindCountServiceImpl extends ServiceImpl<FarmKindCountMapper, F
         farmKindCountMapper.deleteAll(farmCode);
         String list = paramsMap.get("list");
         JSONArray listJa = JSONArray.parseArray(list);
+        List<FarmKindCount> farmKindCountList = listJa.toJavaList(FarmKindCount.class);
+        if (checkRepeat(farmKindCountList)) {
+            return new Result(10001,"有重复类型",false);
+        }else {
+            farmKindCountMapper.deleteAll(farmCode);
+        }
         for (int a = listJa.size()-1; a >= 0 ; a--){
             JSONObject jsonObject = listJa.getJSONObject(a);
             FarmKindCount farmKindCount = new FarmKindCount();
@@ -61,4 +67,13 @@ public class FarmKindCountServiceImpl extends ServiceImpl<FarmKindCountMapper, F
         }
         return new Result(ResultCode.SUCCESS);
     }
+
+    private Boolean checkRepeat(List<FarmKindCount> list){
+        List<String> collectionOptionList = new ArrayList<>();
+        for (FarmKindCount a : list){
+            collectionOptionList.add(a.getFarmKind());
+        }
+        Set<String> set = new HashSet<>(collectionOptionList);
+        return collectionOptionList.size()!= set.size();
+    }
 }

+ 17 - 2
huimv-cattle/src/main/java/com/huimv/cattle/service/impl/IndustryOutputServiceImpl.java

@@ -6,6 +6,7 @@ import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.huimv.cattle.pojo.IndustryOutput;
 import com.huimv.cattle.mapper.IndustryOutputMapper;
+import com.huimv.cattle.pojo.SubsidyCount;
 import com.huimv.cattle.service.IndustryOutputService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.huimv.cattle.token.TokenSign;
@@ -17,8 +18,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import javax.servlet.http.HttpServletRequest;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 
 /**
  * <p>
@@ -69,6 +69,12 @@ public class IndustryOutputServiceImpl extends ServiceImpl<IndustryOutputMapper,
         industryOutputMapper.deleteAll(farmCode);
         String list = paramsMap.get("list");
         JSONArray listJa = JSONArray.parseArray(list);
+        List<IndustryOutput> industryOutputList = listJa.toJavaList(IndustryOutput.class);
+        if (checkRepeat(industryOutputList)) {
+            return new Result(10001,"有重复年份",false);
+        }else {
+            industryOutputMapper.deleteAll(farmCode);
+        }
         for (int a = listJa.size()-1; a >= 0 ; a--){
             JSONObject jsonObject = listJa.getJSONObject(a);
             IndustryOutput industryOutput = new IndustryOutput();
@@ -79,4 +85,13 @@ public class IndustryOutputServiceImpl extends ServiceImpl<IndustryOutputMapper,
         }
         return new Result(ResultCode.SUCCESS);
     }
+
+    private Boolean checkRepeat(List<IndustryOutput> list){
+        List<Integer> collectionOptionList = new ArrayList<>();
+        for (IndustryOutput a : list){
+            collectionOptionList.add(a.getYear());
+        }
+        Set<Integer> set = new HashSet<>(collectionOptionList);
+        return collectionOptionList.size()!= set.size();
+    }
 }

+ 16 - 2
huimv-cattle/src/main/java/com/huimv/cattle/service/impl/ProductionCapacityServiceImpl.java

@@ -19,8 +19,7 @@ import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
 import javax.servlet.http.HttpServletRequest;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 
 /**
  * <p>
@@ -72,6 +71,12 @@ public class ProductionCapacityServiceImpl extends ServiceImpl<ProductionCapacit
         productionCapacityMapper.deleteAll(farmCode);
         String list = paramsMap.get("list");
         JSONArray listJa = JSONArray.parseArray(list);
+        List<ProductionCapacity> productionCapacityList = listJa.toJavaList(ProductionCapacity.class);
+        if (checkRepeat(productionCapacityList)) {
+            return new Result(10001,"有重复年份",false);
+        }else {
+            productionCapacityMapper.deleteAll(farmCode);
+        }
         for (int a = listJa.size()-1; a >= 0 ; a--){
             JSONObject jsonObject = listJa.getJSONObject(a);
             Integer year = jsonObject.getInteger("year");
@@ -86,4 +91,13 @@ public class ProductionCapacityServiceImpl extends ServiceImpl<ProductionCapacit
         }
         return new Result(ResultCode.SUCCESS);
     }
+
+    private Boolean checkRepeat(List<ProductionCapacity> list){
+        List<Integer> collectionOptionList = new ArrayList<>();
+        for (ProductionCapacity a : list){
+            collectionOptionList.add(a.getYear());
+        }
+        Set<Integer> set = new HashSet<>(collectionOptionList);
+        return collectionOptionList.size()!= set.size();
+    }
 }

+ 16 - 3
huimv-cattle/src/main/java/com/huimv/cattle/service/impl/SubsidyCountServiceImpl.java

@@ -19,8 +19,7 @@ import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
 import javax.servlet.http.HttpServletRequest;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 
 /**
  * <p>
@@ -69,9 +68,14 @@ public class SubsidyCountServiceImpl extends ServiceImpl<SubsidyCountMapper, Sub
         if (StringUtils.isBlank(farmCode)){
             farmCode = TokenSign.getFarmCode(request);
         }
-        subsidyCountMapper.deleteAll(farmCode);
         String list = paramsMap.get("list");
         JSONArray listJa = JSONArray.parseArray(list);
+        List<SubsidyCount> SubsidyCountList = listJa.toJavaList(SubsidyCount.class);
+        if (checkRepeat(SubsidyCountList)) {
+            return new Result(10001,"有重复年份",false);
+        }else {
+            subsidyCountMapper.deleteAll(farmCode);
+        }
         for (int a = listJa.size()-1; a >= 0 ; a--){
             JSONObject jsonObject = listJa.getJSONObject(a);
             Integer year = jsonObject.getInteger("year");
@@ -86,4 +90,13 @@ public class SubsidyCountServiceImpl extends ServiceImpl<SubsidyCountMapper, Sub
         }
         return new Result(ResultCode.SUCCESS);
     }
+
+    private Boolean checkRepeat(List<SubsidyCount> list){
+        List<Integer> collectionOptionList = new ArrayList<>();
+        for (SubsidyCount a : list){
+            collectionOptionList.add(a.getYear());
+        }
+        Set<Integer> set = new HashSet<>(collectionOptionList);
+        return collectionOptionList.size()!= set.size();
+    }
 }