Browse Source

添加切换数据库

523096025 4 years ago
parent
commit
5d12382574
14 changed files with 398 additions and 105 deletions
  1. 10 0
      huimv-ql-farm/huimv-ql-production/pom.xml
  2. 38 0
      huimv-ql-farm/huimv-ql-production/src/main/java/com/huimv/production/controller/IndexParameter2Controller.java
  3. 38 0
      huimv-ql-farm/huimv-ql-production/src/main/java/com/huimv/production/controller/IndexProductionGroup2Controller.java
  4. 33 0
      huimv-ql-farm/huimv-ql-production/src/main/java/com/huimv/production/domain/IndexParameter2.java
  5. 0 92
      huimv-ql-farm/huimv-ql-production/src/main/java/com/huimv/production/domain/IndexParameter2Entity.java
  6. 27 0
      huimv-ql-farm/huimv-ql-production/src/main/java/com/huimv/production/domain/IndexProductionGroup2.java
  7. 0 9
      huimv-ql-farm/huimv-ql-production/src/main/java/com/huimv/production/repo/IndexParameter2Repo.java
  8. 14 0
      huimv-ql-farm/huimv-ql-production/src/main/java/com/huimv/production/repo/IndexParameter2Repository.java
  9. 14 0
      huimv-ql-farm/huimv-ql-production/src/main/java/com/huimv/production/repo/IndexProductionGroup2Repository.java
  10. 23 0
      huimv-ql-farm/huimv-ql-production/src/main/java/com/huimv/production/service/IndexParameter2Service.java
  11. 23 0
      huimv-ql-farm/huimv-ql-production/src/main/java/com/huimv/production/service/IndexProductionGroup2Service.java
  12. 89 0
      huimv-ql-farm/huimv-ql-production/src/main/java/com/huimv/production/service/impl/IndexParameter2ServiceImpl.java
  13. 89 0
      huimv-ql-farm/huimv-ql-production/src/main/java/com/huimv/production/service/impl/IndexProductionGroup2ServiceImpl.java
  14. 0 4
      huimv-ql-farm/huimv-ql-production/src/main/java/com/huimv/production/service/impl/MOperationAnalysisServiceImpl.java

+ 10 - 0
huimv-ql-farm/huimv-ql-production/pom.xml

@@ -53,4 +53,14 @@
         <artifactId>lombok</artifactId>
     </dependency>
 </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-resources-plugin</artifactId>
+                <version>2.6</version>
+            </plugin>
+        </plugins>
+    </build>
 </project>

+ 38 - 0
huimv-ql-farm/huimv-ql-production/src/main/java/com/huimv/production/controller/IndexParameter2Controller.java

@@ -0,0 +1,38 @@
+package com.huimv.production.controller;
+
+
+import com.huimv.production.domain.IndexParameter2;
+import com.huimv.production.result.Result;
+import com.huimv.production.service.IndexParameter2Service;
+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("/IndexParameter2")
+public class IndexParameter2Controller {
+
+	@Autowired
+	private IndexParameter2Service service;
+
+	@RequestMapping("/add")
+	public Result add(IndexParameter2 entity){ return service.add(entity); }
+
+	@RequestMapping("/remove")
+	public Result remove(Integer[] ids){ return service.remove(ids); }
+
+	@RequestMapping("/update")
+	public Result update(IndexParameter2 entity){ return service.update(entity); }
+
+	@RequestMapping("/findAllById")
+	public Result findAllById(Integer id){ return service.findAllById(id); }
+
+
+	@RequestMapping("/findAll")
+	public Result findAll(String name , Integer pageNum , Integer pageSize){
+		return service.findAll(name,pageNum,pageSize);
+	}
+
+}

+ 38 - 0
huimv-ql-farm/huimv-ql-production/src/main/java/com/huimv/production/controller/IndexProductionGroup2Controller.java

@@ -0,0 +1,38 @@
+package com.huimv.production.controller;
+
+
+import com.huimv.production.domain.IndexProductionGroup2;
+import com.huimv.production.result.Result;
+import com.huimv.production.service.IndexProductionGroup2Service;
+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("/IndexProductionGroup2")
+public class IndexProductionGroup2Controller {
+
+	@Autowired
+	private IndexProductionGroup2Service service;
+
+	@RequestMapping("/add")
+	public Result add(IndexProductionGroup2 entity){ return service.add(entity); }
+
+	@RequestMapping("/remove")
+	public Result remove(Integer[] ids){ return service.remove(ids); }
+
+	@RequestMapping("/update")
+	public Result update(IndexProductionGroup2 entity){ return service.update(entity); }
+
+	@RequestMapping("/findAllById")
+	public Result findAllById(Integer id){ return service.findAllById(id); }
+
+
+	@RequestMapping("/findAll")
+	public Result findAll(String name , Integer pageNum , Integer pageSize){
+		return service.findAll(name,pageNum,pageSize);
+	}
+
+}

+ 33 - 0
huimv-ql-farm/huimv-ql-production/src/main/java/com/huimv/production/domain/IndexParameter2.java

@@ -0,0 +1,33 @@
+package com.huimv.production.domain;
+
+import lombok.Data;
+
+import javax.persistence.*;
+import java.io.Serializable;
+
+@Data
+@Entity
+@Table(name = "index_parameter2")
+public class IndexParameter2 implements Serializable {
+
+	@Id
+	@GeneratedValue(strategy = GenerationType.IDENTITY)
+	@Column(name = "id")
+	private Integer id;
+
+	@Column(name = "name")
+	private String name;
+
+	@Column(name = "data")
+	private String data;
+
+	@Column(name = "create_time")
+	private java.util.Date createTime;
+
+	@Column(name = "update_time")
+	private java.util.Date updateTime;
+
+	@Column(name = "check_parameter")
+	private Boolean checkParameter;
+
+}

+ 0 - 92
huimv-ql-farm/huimv-ql-production/src/main/java/com/huimv/production/domain/IndexParameter2Entity.java

@@ -1,92 +0,0 @@
-package com.huimv.production.domain;
-
-import javax.persistence.*;
-import java.io.Serializable;
-import java.sql.Timestamp;
-
-@Entity
-@Table(name = "index_parameter2")
-public class IndexParameter2Entity implements Serializable {
-
-    private static final long serialVersionUID = 1L;
-
-    @Id
-    @GeneratedValue(strategy = GenerationType.IDENTITY)
-    @Column(name = "id", nullable = false)
-    private Integer id;
-
-    @Column(name = "name")
-    private String name;
-
-    @Column(name = "data")
-    private String data;
-
-    @Column(name = "create_time", nullable = false)
-    private Timestamp createTime;
-
-    @Column(name = "update_time")
-    private Timestamp updateTime;
-
-    @Column(name = "check_parameter")
-    private Integer checkParameter;
-
-    public void setId(Integer id) {
-        this.id = id;
-    }
-
-    public Integer getId() {
-        return id;
-    }
-
-    public void setName(String name) {
-        this.name = name;
-    }
-
-    public String getName() {
-        return name;
-    }
-
-    public void setData(String data) {
-        this.data = data;
-    }
-
-    public String getData() {
-        return data;
-    }
-
-    public void setCreateTime(Timestamp createTime) {
-        this.createTime = createTime;
-    }
-
-    public Timestamp getCreateTime() {
-        return createTime;
-    }
-
-    public void setUpdateTime(Timestamp updateTime) {
-        this.updateTime = updateTime;
-    }
-
-    public Timestamp getUpdateTime() {
-        return updateTime;
-    }
-
-    public void setCheckParameter(Integer checkParameter) {
-        this.checkParameter = checkParameter;
-    }
-
-    public Integer getCheckParameter() {
-        return checkParameter;
-    }
-
-    @Override
-    public String toString() {
-        return "IndexParameter2Entity{" +
-                "id=" + id + '\'' +
-                "name=" + name + '\'' +
-                "data=" + data + '\'' +
-                "createTime=" + createTime + '\'' +
-                "updateTime=" + updateTime + '\'' +
-                "checkParameter=" + checkParameter + '\'' +
-                '}';
-    }
-}

+ 27 - 0
huimv-ql-farm/huimv-ql-production/src/main/java/com/huimv/production/domain/IndexProductionGroup2.java

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

+ 0 - 9
huimv-ql-farm/huimv-ql-production/src/main/java/com/huimv/production/repo/IndexParameter2Repo.java

@@ -1,9 +0,0 @@
-package com.huimv.production.repo;
-
-import com.huimv.production.domain.IndexParameter2Entity;
-import org.springframework.data.jpa.repository.JpaRepository;
-import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
-
-public interface IndexParameter2Repo extends JpaRepository<IndexParameter2Entity, Integer>, JpaSpecificationExecutor<IndexParameter2Entity> {
-
-}

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

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

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

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

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

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

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

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

+ 89 - 0
huimv-ql-farm/huimv-ql-production/src/main/java/com/huimv/production/service/impl/IndexParameter2ServiceImpl.java

@@ -0,0 +1,89 @@
+package com.huimv.production.service.impl;
+
+
+import com.huimv.production.domain.IndexParameter2;
+import com.huimv.production.repo.IndexParameter2Repository;
+import com.huimv.production.result.Result;
+import com.huimv.production.result.ResultStatus;
+import com.huimv.production.service.IndexParameter2Service;
+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 IndexParameter2ServiceImpl implements IndexParameter2Service {
+
+	@Autowired
+	private IndexParameter2Repository rep;
+
+	@Override
+	public Result add(IndexParameter2 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(IndexParameter2 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(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);
+		}
+	}
+
+	@Override
+	public Result findAllById(Integer id) {
+		try {
+			IndexParameter2 entity = rep.findById(id).get();
+			return new Result(10000,ResultStatus.findSuccess,entity);
+		}catch (Exception e){
+			return new Result(10001,ResultStatus.findFailed,null);
+		}
+	}
+}

+ 89 - 0
huimv-ql-farm/huimv-ql-production/src/main/java/com/huimv/production/service/impl/IndexProductionGroup2ServiceImpl.java

@@ -0,0 +1,89 @@
+package com.huimv.production.service.impl;
+
+
+import com.huimv.production.domain.IndexProductionGroup2;
+import com.huimv.production.repo.IndexProductionGroup2Repository;
+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.HashMap;
+import java.util.List;
+import java.util.Map;
+
+@Service
+public class IndexProductionGroup2ServiceImpl implements IndexProductionGroup2Service {
+
+	@Autowired
+	private IndexProductionGroup2Repository rep;
+
+	@Override
+	public Result add(IndexProductionGroup2 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(IndexProductionGroup2 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(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);
+			
+			return new Result(10000,ResultStatus.findSuccess,map);
+		}catch (Exception e){
+			return new Result(10001,ResultStatus.findFailed,null);
+		}
+	}
+
+	@Override
+	public Result findAllById(Integer id) {
+		try {
+			IndexProductionGroup2 entity = rep.findById(id).get();
+			return new Result(10000,ResultStatus.findSuccess,entity);
+		}catch (Exception e){
+			return new Result(10001,ResultStatus.findFailed,null);
+		}
+	}
+}

+ 0 - 4
huimv-ql-farm/huimv-ql-production/src/main/java/com/huimv/production/service/impl/MOperationAnalysisServiceImpl.java

@@ -9,12 +9,8 @@ import com.huimv.production.service.MOperationAnalysisService;
 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
-@DS("thired")
 public class MOperationAnalysisServiceImpl implements MOperationAnalysisService {
 
 	@Autowired