Pārlūkot izejas kodu

修复品种,返情率等参数

zhuoning 4 gadi atpakaļ
vecāks
revīzija
fe0d2aeea6

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

@@ -43,9 +43,9 @@ public class IndexParameterController {
      }*/
     @RequestMapping("/findAll")
     public Result findAll() {
+        // 获取数据源类型
         Result parameterResult = parameterService.getDatasourceType();
         String datasourceType = parameterResult.getData().toString();
-        System.out.println("datasourceType>>"+datasourceType);
         if(datasourceType.trim().equalsIgnoreCase("true")){
             // 从本地填报表获取数据
             return parameterService.findAllFrom2();

+ 14 - 4
huimv-ql-farm/huimv-ql-production/src/main/java/com/huimv/production/controller/IndexProductionGroup2Controller.java

@@ -3,6 +3,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;
@@ -13,10 +14,8 @@ import org.springframework.web.bind.annotation.RestController;
 @CrossOrigin
 @RequestMapping("/IndexProductionGroup2")
 public class IndexProductionGroup2Controller {
-
 	@Autowired
 	private IndexProductionGroup2Service service;
-
 	@RequestMapping("/add")
 	public Result add(IndexProductionGroup2 entity){ return service.add(entity); }
 
@@ -28,11 +27,22 @@ public class IndexProductionGroup2Controller {
 
 	@RequestMapping("/findAllById")
 	public Result findAllById(Integer id){ return service.findAllById(id); }
-
+	@Autowired
+	private IndexParameterService parameterService;
 
 	@RequestMapping("/findAll")
 	public Result findAll(String name , Integer pageNum , Integer pageSize){
-		return service.findAll(name,pageNum,pageSize);
+		// 获取数据源类型
+		Result parameterResult = parameterService.getDatasourceType();
+		String datasourceType = parameterResult.getData().toString();
+		System.out.println("datasourceType>>"+datasourceType);
+		if(datasourceType.trim().equalsIgnoreCase("true")){
+			// 从本地填报表获取数据
+			return service.findAll(name, pageNum, pageSize);
+		}else {
+			// 从远程落地表获取数据
+			return service.findAllFrom(name, pageNum, pageSize);
+		}
 	}
 
 }

+ 67 - 0
huimv-ql-farm/huimv-ql-production/src/main/java/com/huimv/production/domain/IndexProductionGroupEntity.java

@@ -0,0 +1,67 @@
+package com.huimv.production.domain;
+
+import javax.persistence.*;
+import java.io.Serializable;
+
+@Entity
+@Table(name = "index_production_group")
+public class IndexProductionGroupEntity implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    @Id
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
+    @Column(name = "id", nullable = false)
+    private Integer id;
+
+    @Column(name = "variety")
+    private String variety;
+
+    @Column(name = "frequency")
+    private String frequency;
+
+    @Column(name = "production_type")
+    private String productionType;
+
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+    public Integer getId() {
+        return id;
+    }
+
+    public void setVariety(String variety) {
+        this.variety = variety;
+    }
+
+    public String getVariety() {
+        return variety;
+    }
+
+    public void setFrequency(String frequency) {
+        this.frequency = frequency;
+    }
+
+    public String getFrequency() {
+        return frequency;
+    }
+
+    public void setProductionType(String productionType) {
+        this.productionType = productionType;
+    }
+
+    public String getProductionType() {
+        return productionType;
+    }
+
+    @Override
+    public String toString() {
+        return "IndexProductionGroupEntity{" +
+                "id=" + id + '\'' +
+                "variety=" + variety + '\'' +
+                "frequency=" + frequency + '\'' +
+                "productionType=" + productionType + '\'' +
+                '}';
+    }
+}

+ 16 - 0
huimv-ql-farm/huimv-ql-production/src/main/java/com/huimv/production/repo/IndexProductionGroupRepository.java

@@ -0,0 +1,16 @@
+package com.huimv.production.repo;
+
+import com.huimv.production.domain.IndexProductionGroup2;
+import com.huimv.production.domain.IndexProductionGroupEntity;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
+import org.springframework.data.jpa.repository.Query;
+
+import java.util.List;
+
+public interface IndexProductionGroupRepository extends JpaRepository<IndexProductionGroupEntity, Integer>, JpaSpecificationExecutor<IndexProductionGroupEntity> {
+
+    @Query(nativeQuery = true ,value = "select * from index_production_group where variety like %?1% limit ?2 , ?3")
+    List<IndexProductionGroupEntity> findAll(String name, Integer startPage, Integer pageSize);
+
+}

+ 3 - 0
huimv-ql-farm/huimv-ql-production/src/main/java/com/huimv/production/service/IndexProductionGroup2Service.java

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

+ 1 - 1
huimv-ql-farm/huimv-ql-production/src/main/java/com/huimv/production/service/impl/IndexParameterServiceImpl.java

@@ -104,7 +104,7 @@ public class IndexParameterServiceImpl implements IndexParameterService {
      * 
      * @Author      : ZhuoNing
      * @Date        : 2021/5/22       
-     * @Time        : 16:58
+     * @Time        : 17:32
      */
     @Override
     public Result findAllFrom2() {

+ 21 - 1
huimv-ql-farm/huimv-ql-production/src/main/java/com/huimv/production/service/impl/IndexProductionGroup2ServiceImpl.java

@@ -2,7 +2,9 @@ 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.IndexProductionGroupRepository;
 import com.huimv.production.result.Result;
 import com.huimv.production.result.ResultStatus;
 import com.huimv.production.service.IndexProductionGroup2Service;
@@ -18,6 +20,8 @@ public class IndexProductionGroup2ServiceImpl implements IndexProductionGroup2Se
 
 	@Autowired
 	private IndexProductionGroup2Repository rep;
+	@Autowired
+	private IndexProductionGroupRepository indexProductionGroupRepo;
 
 	@Override
 	public Result add(IndexProductionGroup2 entity){
@@ -70,7 +74,7 @@ public class IndexProductionGroup2ServiceImpl implements IndexProductionGroup2Se
 			map.put("total",size);
 			map.put("totalPageNum",(size  +  pageSize  - 1) / pageSize);
 			map.put("data",all);
-			
+
 			return new Result(10000,ResultStatus.findSuccess,map);
 		}catch (Exception e){
 			return new Result(10001,ResultStatus.findFailed,null);
@@ -86,4 +90,20 @@ public class IndexProductionGroup2ServiceImpl implements IndexProductionGroup2Se
 			return new Result(10001,ResultStatus.findFailed,null);
 		}
 	}
+
+	@Override
+	public Result findAllFrom(String name , Integer pageNum , Integer pageSize) {
+		try {
+			Map map = new HashMap();
+			int size = indexProductionGroupRepo.findAll().size() ;
+			Integer startPage = (pageNum-1) * pageSize;
+			List<IndexProductionGroupEntity> all = indexProductionGroupRepo.findAll(name,startPage,pageSize);
+			map.put("total",size);
+			map.put("totalPageNum",(size  +  pageSize  - 1) / pageSize);
+			map.put("data",all);
+			return new Result(10000,ResultStatus.findSuccess,map);
+		}catch (Exception e){
+			return new Result(10001,ResultStatus.findFailed,null);
+		}
+	}
 }