Procházet zdrojové kódy

添加切换数据库

523096025 před 4 roky
rodič
revize
ffe6dbb81a
16 změnil soubory, kde provedl 368 přidání a 71 odebrání
  1. 3 4
      huimv-ql-farm/huimv-ql-production/src/main/java/com/huimv/production/controller/IndexParameter2Controller.java
  2. 5 16
      huimv-ql-farm/huimv-ql-production/src/main/java/com/huimv/production/controller/IndexProductionGroup2Controller.java
  3. 37 0
      huimv-ql-farm/huimv-ql-production/src/main/java/com/huimv/production/controller/IndexVariety2Controller.java
  4. 37 0
      huimv-ql-farm/huimv-ql-production/src/main/java/com/huimv/production/controller/IndexVarietyController.java
  5. 24 0
      huimv-ql-farm/huimv-ql-production/src/main/java/com/huimv/production/domain/IndexVariety.java
  6. 24 0
      huimv-ql-farm/huimv-ql-production/src/main/java/com/huimv/production/domain/IndexVariety2.java
  7. 14 0
      huimv-ql-farm/huimv-ql-production/src/main/java/com/huimv/production/repo/IndexVariety2Repository.java
  8. 14 0
      huimv-ql-farm/huimv-ql-production/src/main/java/com/huimv/production/repo/IndexVarietyRepository.java
  9. 1 1
      huimv-ql-farm/huimv-ql-production/src/main/java/com/huimv/production/service/IndexParameter2Service.java
  10. 2 2
      huimv-ql-farm/huimv-ql-production/src/main/java/com/huimv/production/service/IndexProductionGroup2Service.java
  11. 23 0
      huimv-ql-farm/huimv-ql-production/src/main/java/com/huimv/production/service/IndexVariety2Service.java
  12. 23 0
      huimv-ql-farm/huimv-ql-production/src/main/java/com/huimv/production/service/IndexVarietyService.java
  13. 4 14
      huimv-ql-farm/huimv-ql-production/src/main/java/com/huimv/production/service/impl/IndexParameter2ServiceImpl.java
  14. 3 34
      huimv-ql-farm/huimv-ql-production/src/main/java/com/huimv/production/service/impl/IndexProductionGroup2ServiceImpl.java
  15. 78 0
      huimv-ql-farm/huimv-ql-production/src/main/java/com/huimv/production/service/impl/IndexVariety2ServiceImpl.java
  16. 76 0
      huimv-ql-farm/huimv-ql-production/src/main/java/com/huimv/production/service/impl/IndexVarietyServiceImpl.java

+ 3 - 4
huimv-ql-farm/huimv-ql-production/src/main/java/com/huimv/production/controller/IndexParameter2Controller.java

@@ -10,8 +10,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
 @RestController
-@CrossOrigin
-@RequestMapping("/IndexParameter2")
+@RequestMapping("/indexParameter2")
 public class IndexParameter2Controller {
 
 	@Autowired
@@ -31,8 +30,8 @@ public class IndexParameter2Controller {
 
 
 	@RequestMapping("/findAll")
-	public Result findAll(String name , Integer pageNum , Integer pageSize){
-		return service.findAll(name,pageNum,pageSize);
+	public Result findAll(){
+		return service.findAll();
 	}
 
 }

+ 5 - 16
huimv-ql-farm/huimv-ql-production/src/main/java/com/huimv/production/controller/IndexProductionGroup2Controller.java

@@ -1,9 +1,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,8 +12,10 @@ 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); }
 
@@ -27,22 +27,11 @@ 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){
-		// 获取数据源类型
-		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);
-		}
+	public Result findAll(){
+		return service.findAll();
 	}
 
 }

+ 37 - 0
huimv-ql-farm/huimv-ql-production/src/main/java/com/huimv/production/controller/IndexVariety2Controller.java

@@ -0,0 +1,37 @@
+package com.huimv.production.controller;
+
+import com.huimv.production.domain.IndexVariety2;
+import com.huimv.production.result.Result;
+import com.huimv.production.service.IndexVariety2Service;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.CrossOrigin;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+@RestController
+@CrossOrigin
+@RequestMapping("/IndexVariety2")
+public class IndexVariety2Controller {
+
+	@Autowired
+	private IndexVariety2Service service;
+
+	@RequestMapping("/add")
+	public Result add(IndexVariety2 entity){ return service.add(entity); }
+
+	@RequestMapping("/remove")
+	public Result remove(Integer[] ids){ return service.remove(ids); }
+
+	@RequestMapping("/update")
+	public Result update(IndexVariety2 entity){ return service.update(entity); }
+
+	@RequestMapping("/findAllById")
+	public Result findAllById(Integer id){ return service.findAllById(id); }
+
+
+	@RequestMapping("/findAll")
+	public Result findAll(){
+		return service.findAll();
+	}
+
+}

+ 37 - 0
huimv-ql-farm/huimv-ql-production/src/main/java/com/huimv/production/controller/IndexVarietyController.java

@@ -0,0 +1,37 @@
+package com.huimv.production.controller;
+
+import com.huimv.production.domain.IndexVariety;
+import com.huimv.production.result.Result;
+import com.huimv.production.service.IndexVarietyService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.CrossOrigin;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+@RestController
+@CrossOrigin
+@RequestMapping("/indexVariety")
+public class IndexVarietyController {
+
+	@Autowired
+	private IndexVarietyService service;
+
+	@RequestMapping("/add")
+	public Result add(IndexVariety entity){ return service.add(entity); }
+
+	@RequestMapping("/remove")
+	public Result remove(Integer[] ids){ return service.remove(ids); }
+
+	@RequestMapping("/update")
+	public Result update(IndexVariety entity){ return service.update(entity); }
+
+	@RequestMapping("/findAllById")
+	public Result findAllById(Integer id){ return service.findAllById(id); }
+
+
+	@RequestMapping("/findAll")
+	public Result findAll(){
+		return service.findAll();
+	}
+
+}

+ 24 - 0
huimv-ql-farm/huimv-ql-production/src/main/java/com/huimv/production/domain/IndexVariety.java

@@ -0,0 +1,24 @@
+package com.huimv.production.domain;
+
+import lombok.Data;
+
+import javax.persistence.*;
+import java.io.Serializable;
+
+@Data
+@Entity
+@Table(name = "index_variety")
+public class IndexVariety implements Serializable {
+
+	@Id
+	@GeneratedValue(strategy = GenerationType.IDENTITY)
+	@Column(name = "id")
+	private Integer id;
+
+	@Column(name = "variety")
+	private String variety;
+
+	@Column(name = "amount")
+	private Integer amount;
+
+}

+ 24 - 0
huimv-ql-farm/huimv-ql-production/src/main/java/com/huimv/production/domain/IndexVariety2.java

@@ -0,0 +1,24 @@
+package com.huimv.production.domain;
+
+import lombok.Data;
+
+import javax.persistence.*;
+import java.io.Serializable;
+
+@Data
+@Entity
+@Table(name = "index_variety2")
+public class IndexVariety2 implements Serializable {
+
+	@Id
+	@GeneratedValue(strategy = GenerationType.IDENTITY)
+	@Column(name = "id")
+	private Integer id;
+
+	@Column(name = "variety")
+	private String variety;
+
+	@Column(name = "amount")
+	private Integer amount;
+
+}

+ 14 - 0
huimv-ql-farm/huimv-ql-production/src/main/java/com/huimv/production/repo/IndexVariety2Repository.java

@@ -0,0 +1,14 @@
+package com.huimv.production.repo;
+
+import com.huimv.production.domain.IndexVariety2;
+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 IndexVariety2Repository extends JpaRepository<IndexVariety2, Integer>,JpaSpecificationExecutor<IndexVariety2>{
+	
+	@Query(nativeQuery = true ,value = "select * from index_variety2 where variety like %?1% limit ?2 , ?3")
+    List<IndexVariety2> findAll(String name, Integer startPage, Integer pageSize);
+}

+ 14 - 0
huimv-ql-farm/huimv-ql-production/src/main/java/com/huimv/production/repo/IndexVarietyRepository.java

@@ -0,0 +1,14 @@
+package com.huimv.production.repo;
+
+import com.huimv.production.domain.IndexVariety;
+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 IndexVarietyRepository extends JpaRepository<IndexVariety, Integer>,JpaSpecificationExecutor<IndexVariety>{
+	
+	@Query(nativeQuery = true ,value = "select * from index_variety where variety like %?1% limit ?2 , ?3")
+    List<IndexVariety> findAll(String name, Integer startPage, Integer pageSize);
+}

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

@@ -16,7 +16,7 @@ public interface IndexParameter2Service  {
    Result update(IndexParameter2 entity);
 
    //查询
-  Result findAll(String name, Integer pageNum, Integer pageSize);
+  Result findAll();
 
    //根据id查找
    Result findAllById(Integer id);

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

@@ -4,7 +4,7 @@ package com.huimv.production.service;
 import com.huimv.production.domain.IndexProductionGroup2;
 import com.huimv.production.result.Result;
 
-public interface IndexProductionGroup2Service  {
+public interface IndexProductionGroup2Service {
 
    //添加
    Result add(IndexProductionGroup2 entity);
@@ -16,7 +16,7 @@ public interface IndexProductionGroup2Service  {
    Result update(IndexProductionGroup2 entity);
 
    //查询
-  Result findAll(String name, Integer pageNum, Integer pageSize);
+  Result findAll();
 
    //根据id查找
    Result findAllById(Integer id);

+ 23 - 0
huimv-ql-farm/huimv-ql-production/src/main/java/com/huimv/production/service/IndexVariety2Service.java

@@ -0,0 +1,23 @@
+package com.huimv.production.service;
+
+
+import com.huimv.production.domain.IndexVariety2;
+import com.huimv.production.result.Result;
+
+public interface IndexVariety2Service {
+
+   //添加
+   Result add(IndexVariety2 entity);
+
+   //添加
+   Result remove(Integer[] ids);
+
+   //添加
+   Result update(IndexVariety2 entity);
+
+   //查询
+  Result findAll();
+
+   //根据id查找
+   Result findAllById(Integer id);
+}

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

@@ -0,0 +1,23 @@
+package com.huimv.production.service;
+
+
+import com.huimv.production.domain.IndexVariety;
+import com.huimv.production.result.Result;
+
+public interface IndexVarietyService {
+
+   //添加
+   Result add(IndexVariety entity);
+
+   //添加
+   Result remove(Integer[] ids);
+
+   //添加
+   Result update(IndexVariety entity);
+
+   //查询
+  Result findAll();
+
+   //根据id查找
+   Result findAllById(Integer id);
+}

+ 4 - 14
huimv-ql-farm/huimv-ql-production/src/main/java/com/huimv/production/service/impl/IndexParameter2ServiceImpl.java

@@ -61,20 +61,10 @@ public class IndexParameter2ServiceImpl implements IndexParameter2Service {
 	}
 
 	@Override
-	public Result findAll(String name , Integer pageNum , Integer pageSize) {
-		try {
-			Map map = new HashMap();
-			int size = rep.findAll().size() ;
-			Integer startPage = (pageNum-1) * pageSize;
-			List<IndexParameter2> all = rep.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);
-		}
+	public Result findAll() {
+
+			return new Result(10000,ResultStatus.findSuccess,rep.findAll());
+
 	}
 
 	@Override

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

@@ -1,10 +1,7 @@
 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;
@@ -20,8 +17,6 @@ public class IndexProductionGroup2ServiceImpl implements IndexProductionGroup2Se
 
 	@Autowired
 	private IndexProductionGroup2Repository rep;
-	@Autowired
-	private IndexProductionGroupRepository indexProductionGroupRepo;
 
 	@Override
 	public Result add(IndexProductionGroup2 entity){
@@ -65,20 +60,10 @@ public class IndexProductionGroup2ServiceImpl implements IndexProductionGroup2Se
 	}
 
 	@Override
-	public Result findAll(String name , Integer pageNum , Integer pageSize) {
-		try {
-			Map map = new HashMap();
-			int size = rep.findAll().size() ;
-			Integer startPage = (pageNum-1) * pageSize;
-			List<IndexProductionGroup2> all = rep.findAll(name,startPage,pageSize);
-			map.put("total",size);
-			map.put("totalPageNum",(size  +  pageSize  - 1) / pageSize);
-			map.put("data",all);
+	public Result findAll() {
+
+			return new Result(10000,ResultStatus.findSuccess,rep.findAll());
 
-			return new Result(10000,ResultStatus.findSuccess,map);
-		}catch (Exception e){
-			return new Result(10001,ResultStatus.findFailed,null);
-		}
 	}
 
 	@Override
@@ -90,20 +75,4 @@ 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);
-		}
-	}
 }

+ 78 - 0
huimv-ql-farm/huimv-ql-production/src/main/java/com/huimv/production/service/impl/IndexVariety2ServiceImpl.java

@@ -0,0 +1,78 @@
+package com.huimv.production.service.impl;
+
+import com.huimv.production.domain.IndexVariety2;
+import com.huimv.production.repo.IndexVariety2Repository;
+import com.huimv.production.result.Result;
+import com.huimv.production.result.ResultStatus;
+import com.huimv.production.service.IndexVariety2Service;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+@Service
+public class IndexVariety2ServiceImpl implements IndexVariety2Service {
+
+	@Autowired
+	private IndexVariety2Repository rep;
+
+	@Override
+	public Result add(IndexVariety2 entity){
+		if (entity == null){
+			return new Result(10002, ResultStatus.addNull);
+		}
+		try {
+			rep.save(entity);
+			return new Result(10000,ResultStatus.addSuccess);
+		}catch (Exception e){
+			return new Result(10001,ResultStatus.addFailed);
+		}
+	}
+
+	@Override
+	public Result remove(Integer[] ids) {
+		if (ids == null || ids.length==0){
+			return new Result(10002,ResultStatus.deleteNull);
+		}
+		try {
+			for (Integer id : ids) {
+				rep.deleteById(id);
+			}
+			return new Result(10000,ResultStatus.deleteSuccess);
+		}catch (Exception e){
+			return new Result(10001,ResultStatus.deleteFailed);
+		}
+	}
+
+	@Override
+	public Result update(IndexVariety2 entity) {
+		if (entity == null){
+			return new Result(10002,ResultStatus.updateNull);
+		}
+		try {
+			rep.save(entity);
+			return new Result(10000,ResultStatus.updateSuccess);
+		}catch (Exception e){
+			return new Result(10001,ResultStatus.updateFailed);
+		}
+	}
+
+	@Override
+	public Result findAll() {
+
+			return new Result(10000,ResultStatus.findSuccess,rep.findAll());
+
+	}
+
+	@Override
+	public Result findAllById(Integer id) {
+		try {
+			IndexVariety2 entity = rep.findById(id).get();
+			return new Result(10000,ResultStatus.findSuccess,entity);
+		}catch (Exception e){
+			return new Result(10001,ResultStatus.findFailed,null);
+		}
+	}
+}

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

@@ -0,0 +1,76 @@
+package com.huimv.production.service.impl;
+
+import com.huimv.production.domain.IndexVariety;
+import com.huimv.production.repo.IndexVarietyRepository;
+import com.huimv.production.result.Result;
+import com.huimv.production.result.ResultStatus;
+import com.huimv.production.service.IndexVarietyService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+@Service
+public class IndexVarietyServiceImpl implements IndexVarietyService {
+
+	@Autowired
+	private IndexVarietyRepository rep;
+
+	@Override
+	public Result add(IndexVariety entity){
+		if (entity == null){
+			return new Result(10002, ResultStatus.addNull);
+		}
+		try {
+			rep.save(entity);
+			return new Result(10000,ResultStatus.addSuccess);
+		}catch (Exception e){
+			return new Result(10001,ResultStatus.addFailed);
+		}
+	}
+
+	@Override
+	public Result remove(Integer[] ids) {
+		if (ids == null || ids.length==0){
+			return new Result(10002,ResultStatus.deleteNull);
+		}
+		try {
+			for (Integer id : ids) {
+				rep.deleteById(id);
+			}
+			return new Result(10000,ResultStatus.deleteSuccess);
+		}catch (Exception e){
+			return new Result(10001,ResultStatus.deleteFailed);
+		}
+	}
+
+	@Override
+	public Result update(IndexVariety entity) {
+		if (entity == null){
+			return new Result(10002,ResultStatus.updateNull);
+		}
+		try {
+			rep.save(entity);
+			return new Result(10000,ResultStatus.updateSuccess);
+		}catch (Exception e){
+			return new Result(10001,ResultStatus.updateFailed);
+		}
+	}
+
+	@Override
+	public Result findAll() {
+		return new Result(10000,ResultStatus.findSuccess,rep.findAll());
+	}
+
+	@Override
+	public Result findAllById(Integer id) {
+		try {
+			IndexVariety entity = rep.findById(id).get();
+			return new Result(10000,ResultStatus.findSuccess,entity);
+		}catch (Exception e){
+			return new Result(10001,ResultStatus.findFailed,null);
+		}
+	}
+}