Bladeren bron

修改查询年份

Newspaper 2 jaren geleden
bovenliggende
commit
da5d8c733f

+ 2 - 2
huimv-cattle/src/main/java/com/huimv/cattle/controller/IndustryOutputController.java

@@ -28,8 +28,8 @@ public class IndustryOutputController {
     private IndustryOutputService industryOutputService;
 
     @PostMapping("/getIndustryOutput")
-    public Result getIndustryOutput(){
-        return industryOutputService.getIndustryOutput();
+    public Result getIndustryOutput(@RequestBody Map<String,String> paramsMap){
+        return industryOutputService.getIndustryOutput(paramsMap);
     }
 
     @PostMapping("/saveIndustryOutput")

+ 1 - 1
huimv-cattle/src/main/java/com/huimv/cattle/service/IndustryOutputService.java

@@ -16,7 +16,7 @@ import java.util.Map;
  */
 public interface IndustryOutputService extends IService<IndustryOutput> {
 
-    Result getIndustryOutput();
+    Result getIndustryOutput(Map<String, String> paramsMap);
 
     Result saveIndustryOutput(Map<String, String> paramsMap);
 }

+ 5 - 4
huimv-cattle/src/main/java/com/huimv/cattle/service/impl/IndustryOutputServiceImpl.java

@@ -34,10 +34,11 @@ public class IndustryOutputServiceImpl extends ServiceImpl<IndustryOutputMapper,
     private DateUtil dateUtil;
 
     @Override
-    public Result getIndustryOutput() {
-        QueryWrapper<IndustryOutput> queryWrapper = new QueryWrapper<>();
-        queryWrapper.orderByAsc("year");
-        List<IndustryOutput> industryOutputs = industryOutputMapper.selectList(queryWrapper);
+    public Result getIndustryOutput(Map<String, String> paramsMap) {
+        String yearNum = paramsMap.get("yearNum");
+        List<IndustryOutput> industryOutputs = industryOutputMapper.selectList(new QueryWrapper<IndustryOutput>()
+                .between("year", Integer.valueOf(dateUtil.getThisYear()) - Integer.valueOf(yearNum), Integer.valueOf(dateUtil.getThisYear()))
+                .orderByDesc("year"));
         if (industryOutputs.isEmpty()) {
             IndustryOutput industryOutput = new IndustryOutput();
             industryOutput.setYear(Integer.valueOf(dateUtil.getThisYear()));

+ 6 - 4
huimv-cattle/src/main/java/com/huimv/cattle/service/impl/ProductionCapacityServiceImpl.java

@@ -38,14 +38,16 @@ public class ProductionCapacityServiceImpl extends ServiceImpl<ProductionCapacit
     @Override
     public Result getProductionCapacity(Map<String, String> paramsMap) {
         String yearNum = paramsMap.get("yearNum");
-        List<ProductionCapacity> productionCapacity = productionCapacityMapper.getProductionCapacity(yearNum);
-        if (ObjectUtil.isEmpty(productionCapacity)){
+        List<ProductionCapacity> productionCapacities = productionCapacityMapper.selectList(new QueryWrapper<ProductionCapacity>()
+                .between("year", Integer.valueOf(dateUtil.getThisYear()) - Integer.valueOf(yearNum), Integer.valueOf(dateUtil.getThisYear()))
+                .orderByDesc("year"));
+        if (ObjectUtil.isEmpty(productionCapacities)){
             ProductionCapacity productionCapacity1 = new ProductionCapacity();
             productionCapacity1.setYear(Integer.valueOf(dateUtil.getThisYear()));
-            productionCapacity.add(productionCapacity1);
+            productionCapacities.add(productionCapacity1);
             productionCapacityMapper.insert(productionCapacity1);
         }
-        return new Result(ResultCode.SUCCESS,productionCapacity);
+        return new Result(ResultCode.SUCCESS,productionCapacities);
     }
 
     @Override

+ 6 - 4
huimv-cattle/src/main/java/com/huimv/cattle/service/impl/SubsidyCountServiceImpl.java

@@ -38,14 +38,16 @@ public class SubsidyCountServiceImpl extends ServiceImpl<SubsidyCountMapper, Sub
     @Override
     public Result getSubsidyCount(Map<String, String> paramsMap) {
         String yearNum = paramsMap.get("yearNum");
-        List<SubsidyCount> subsidyCount = subsidyCountMapper.getSubsidyCount(yearNum);
-        if (ObjectUtil.isEmpty(subsidyCount)){
+        List<SubsidyCount> subsidyCounts = subsidyCountMapper.selectList(new QueryWrapper<SubsidyCount>()
+                .between("year", Integer.valueOf(dateUtil.getThisYear()) - Integer.valueOf(yearNum), Integer.valueOf(dateUtil.getThisYear()))
+                .orderByDesc("year"));
+        if (ObjectUtil.isEmpty(subsidyCounts)){
             SubsidyCount subsidyCount1 = new SubsidyCount();
             subsidyCount1.setYear(Integer.valueOf(dateUtil.getThisYear()));
-            subsidyCount.add(subsidyCount1);
+            subsidyCounts.add(subsidyCount1);
             subsidyCountMapper.insert(subsidyCount1);
         }
-        return new Result(ResultCode.SUCCESS,subsidyCount);
+        return new Result(ResultCode.SUCCESS,subsidyCounts);
     }
 
     @Override