Procházet zdrojové kódy

增加种类、参数查询接口

zhuoning před 4 roky
rodič
revize
eaebbb94c6

+ 13 - 1
huimv-ql-farm/huimv-ql-production/src/main/java/com/huimv/production/controller/IndexProductionGroup2Controller.java

@@ -2,6 +2,7 @@ package com.huimv.production.controller;
 
 import com.huimv.production.domain.IndexProductionGroup2;
 import com.huimv.production.result.Result;
+import com.huimv.production.service.IndexParameterService;
 import com.huimv.production.service.IndexProductionGroup2Service;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.CrossOrigin;
@@ -14,6 +15,8 @@ public class IndexProductionGroup2Controller {
 
 	@Autowired
 	private IndexProductionGroup2Service service;
+	@Autowired
+	private IndexParameterService parameterService;
 
 	@RequestMapping("/add")
 	public Result add(IndexProductionGroup2 entity){ return service.add(entity); }
@@ -30,7 +33,16 @@ public class IndexProductionGroup2Controller {
 
 	@RequestMapping("/findAll")
 	public Result findAll(){
-		return service.findAll();
+		Result parameterResult = parameterService.getDatasourceType();
+		String datasourceType = parameterResult.getData().toString();
+		if(datasourceType.trim().equalsIgnoreCase("true")){
+			// 从本地填报表获取数据
+			return service.findAll();
+		}else {
+			System.out.println("remote");
+			// 从远程落地表获取数据
+			return service.findAllFrom();
+		}
 	}
 
 }

+ 12 - 1
huimv-ql-farm/huimv-ql-production/src/main/java/com/huimv/production/controller/IndexVarietyController.java

@@ -2,6 +2,7 @@ package com.huimv.production.controller;
 
 import com.huimv.production.domain.IndexVariety;
 import com.huimv.production.result.Result;
+import com.huimv.production.service.IndexParameterService;
 import com.huimv.production.service.IndexVarietyService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.CrossOrigin;
@@ -14,6 +15,8 @@ public class IndexVarietyController {
 
 	@Autowired
 	private IndexVarietyService service;
+	@Autowired
+	private IndexParameterService parameterService;
 
 	@RequestMapping("/add")
 	public Result add(IndexVariety entity){ return service.add(entity); }
@@ -30,7 +33,15 @@ public class IndexVarietyController {
 
 	@RequestMapping("/findAll")
 	public Result findAll(){
-		return service.findAll();
+		Result parameterResult = parameterService.getDatasourceType();
+		String datasourceType = parameterResult.getData().toString();
+		if(datasourceType.trim().equalsIgnoreCase("true")){
+			// 从本地填报表获取数据
+			return service.findAllFrom2();
+		}else {
+			// 从远程落地表获取数据
+			return service.findAll();
+		}
 	}
 
 }

+ 12 - 0
huimv-ql-farm/huimv-ql-production/src/main/java/com/huimv/production/repo/IndexProductionGroupEntityRepository.java

@@ -0,0 +1,12 @@
+package com.huimv.production.repo;
+
+import com.huimv.production.domain.IndexProductionGroupEntity;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
+
+import java.util.List;
+
+public interface IndexProductionGroupEntityRepository extends JpaRepository<IndexProductionGroupEntity, Integer>, JpaSpecificationExecutor<IndexProductionGroupEntity> {
+
+    List<IndexProductionGroupEntity> findAllByVariety(String variety);
+}

+ 2 - 1
huimv-ql-farm/huimv-ql-production/src/main/java/com/huimv/production/service/IndexProductionGroup2Service.java

@@ -21,6 +21,7 @@ public interface IndexProductionGroup2Service {
    //根据id查找
    Result findAllById(Integer id);
 
-    //查询
+   //查询
+   Result findAllFrom();
 //   Result findAllFrom(String name, Integer pageNum, Integer pageSize);
 }

+ 2 - 0
huimv-ql-farm/huimv-ql-production/src/main/java/com/huimv/production/service/IndexVarietyService.java

@@ -20,4 +20,6 @@ public interface IndexVarietyService {
 
    //根据id查找
    Result findAllById(Integer id);
+
+    Result findAllFrom2();
 }

+ 36 - 3
huimv-ql-farm/huimv-ql-production/src/main/java/com/huimv/production/service/impl/IndexProductionGroup2ServiceImpl.java

@@ -1,13 +1,16 @@
 package com.huimv.production.service.impl;
 
 import com.huimv.production.domain.IndexProductionGroup2;
+import com.huimv.production.domain.IndexProductionGroupEntity;
 import com.huimv.production.repo.IndexProductionGroup2Repository;
+import com.huimv.production.repo.IndexProductionGroupEntityRepository;
 import com.huimv.production.result.Result;
 import com.huimv.production.result.ResultStatus;
 import com.huimv.production.service.IndexProductionGroup2Service;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -18,6 +21,9 @@ public class IndexProductionGroup2ServiceImpl implements IndexProductionGroup2Se
 	@Autowired
 	private IndexProductionGroup2Repository rep;
 
+	@Autowired
+	private IndexProductionGroupEntityRepository indexProductionGroupRepo;
+
 	@Override
 	public Result add(IndexProductionGroup2 entity){
 		if (entity == null){
@@ -61,9 +67,7 @@ public class IndexProductionGroup2ServiceImpl implements IndexProductionGroup2Se
 
 	@Override
 	public Result findAll() {
-
-			return new Result(10000,ResultStatus.findSuccess,rep.findAll());
-
+		return new Result(10000,ResultStatus.findSuccess,rep.findAll());
 	}
 
 	@Override
@@ -75,4 +79,33 @@ public class IndexProductionGroup2ServiceImpl implements IndexProductionGroup2Se
 			return new Result(10001,ResultStatus.findFailed,null);
 		}
 	}
+
+	@Override
+	public Result findAllFrom() {
+		List<IndexProductionGroupEntity> delivery = indexProductionGroupRepo.findAllByVariety("巴嘉");
+		List<IndexProductionGroupEntity> reservice = indexProductionGroupRepo.findAllByVariety("杜巴嘉");
+		List<IndexProductionGroupEntity> breeding = indexProductionGroupRepo.findAllByVariety("金华两头乌");
+		Map map1 = new HashMap();
+		Map map2 = new HashMap();
+		Map map3 = new HashMap();
+		map1.put("veriety","巴嘉");
+		map2.put("veriety","杜巴嘉");
+		map3.put("veriety","金华两头乌");
+		for (IndexProductionGroupEntity productionGroup : delivery) {
+			map1.put(productionGroup.getProductionType(),productionGroup.getFrequency());
+		}
+		for (IndexProductionGroupEntity productionGroup : reservice) {
+			map2.put(productionGroup.getProductionType(),productionGroup.getFrequency());
+		}
+		for (IndexProductionGroupEntity productionGroup : breeding) {
+			map3.put(productionGroup.getProductionType(),productionGroup.getFrequency());
+		}
+
+		List list = new ArrayList();
+		list.add(map1);
+		list.add(map2);
+		list.add(map3);
+
+		return new Result(10000,ResultStatus.findSuccess,list);
+	}
 }

+ 8 - 0
huimv-ql-farm/huimv-ql-production/src/main/java/com/huimv/production/service/impl/IndexVarietyServiceImpl.java

@@ -1,6 +1,7 @@
 package com.huimv.production.service.impl;
 
 import com.huimv.production.domain.IndexVariety;
+import com.huimv.production.repo.IndexVariety2Repository;
 import com.huimv.production.repo.IndexVarietyRepository;
 import com.huimv.production.result.Result;
 import com.huimv.production.result.ResultStatus;
@@ -17,6 +18,8 @@ public class IndexVarietyServiceImpl implements IndexVarietyService {
 
 	@Autowired
 	private IndexVarietyRepository rep;
+	@Autowired
+	private IndexVariety2Repository rep2;
 
 	@Override
 	public Result add(IndexVariety entity){
@@ -73,4 +76,9 @@ public class IndexVarietyServiceImpl implements IndexVarietyService {
 			return new Result(10001,ResultStatus.findFailed,null);
 		}
 	}
+
+	@Override
+	public Result findAllFrom2() {
+		return new Result(10000,ResultStatus.findSuccess,rep2.findAll());
+	}
 }

+ 2 - 2
huimv-ql-farm/huimv-ql-production/src/main/resources/application.properties

@@ -1,6 +1,6 @@
-#spring.profiles.active=ycg
+spring.profiles.active=ycg
 #spring.profiles.active=wuyi
-spring.profiles.active=haiyan
+#spring.profiles.active=haiyan
 #spring.profiles.active=wjj
 
 # 生产数据源配置(本地填报数据true/远程数据false)