提交 dc8b7f10 authored 作者: 133's avatar 133

修改了多数据源

上级 84545b06
......@@ -17,6 +17,7 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
import javax.persistence.EntityManager;
import javax.sql.DataSource;
import java.util.HashMap;
import java.util.Map;
/**
......@@ -49,7 +50,7 @@ public class BackupConfig {
public LocalContainerEntityManagerFactoryBean entityManagerFactoryStms(EntityManagerFactoryBuilder builder) {
return builder
.dataSource(remoteDataSource)
.properties(properties.determineHibernateProperties(jpaProperties.getProperties(),new HibernateSettings()))
.properties(getVendorProperties())
.packages("com.example.removetolocal.newentity.entity")
.persistenceUnit("backupPersistenceUnit")
.build();
......@@ -58,8 +59,13 @@ public class BackupConfig {
@Autowired
private JpaProperties jpaProperties;
private Map<String, String> getVendorProperties(DataSource remoteDataSource) {
return jpaProperties.getProperties();
private Map<String, Object> getVendorProperties() {
Map<String,String> map = new HashMap<>();
map.put("hibernate.dialect","org.hibernate.dialect.MySQL5Dialect");// 设置对应的数据库方言
jpaProperties.setProperties(map);
return properties.determineHibernateProperties(
jpaProperties.getProperties(), new HibernateSettings());
}
......
......@@ -19,6 +19,7 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
import javax.persistence.EntityManager;
import javax.sql.DataSource;
import java.util.HashMap;
import java.util.Map;
@SuppressWarnings({"SpringAutowiredFieldsWarningInspection", "SpringComponentScan"})
......@@ -57,7 +58,7 @@ public class LocationConfig {
log.info("本地数据源:" + locationDataSource);
return builder
.dataSource(locationDataSource)
.properties(properties.determineHibernateProperties(jpaProperties.getProperties(),new HibernateSettings()))
.properties(getVendorProperties())
.packages("com.example.removetolocal.newdevice.domin",
"com.example.removetolocal.newtrain.entity",
"com.example.removetolocal.newuser.domin",
......@@ -72,8 +73,12 @@ public class LocationConfig {
@Autowired
private JpaProperties jpaProperties;
private Map<String, String> getVendorProperties() {
return jpaProperties.getProperties();
private Map<String, Object> getVendorProperties() {
Map<String,String> map = new HashMap<>();
map.put("hibernate.dialect","org.hibernate.dialect.MySQL5Dialect");// 设置对应的数据库方言
jpaProperties.setProperties(map);
return properties.determineHibernateProperties(
jpaProperties.getProperties(), new HibernateSettings());
}
@Primary
......
......@@ -12,7 +12,6 @@ import java.util.List;
/**
* @author dengdiyi
*/
@SuppressWarnings("SqlResolve")
public interface DeviceLibraryDao extends JpaRepository<DeviceLibrary, Integer>, JpaSpecificationExecutor<DeviceLibrary> {
DeviceLibrary findByOldId(Integer oldId);
......
package com.example.removetolocal.newdevice.domin;
import com.example.removetolocal.config.BeanHelper;
import lombok.Data;
import org.hibernate.annotations.SQLDelete;
import org.hibernate.annotations.Where;
import org.modelmapper.ModelMapper;
import org.springframework.data.annotation.CreatedBy;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedBy;
......
package com.example.removetolocal.newentity.dao;
import com.example.removetolocal.newentity.entity.AccessControlName;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
......@@ -7,5 +8,4 @@ import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
* @author dengdiyi
*/
public interface AccessControlNameDao extends JpaRepository<AccessControlName,Integer>, JpaSpecificationExecutor<AccessControlName> {
AccessControlName findByDeviceNo(String deviceNo);
}
package com.example.removetolocal.newentity.dao;
import com.example.removetolocal.newentity.entity.AllotBackBill;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
......
package com.example.removetolocal.newentity.dao;
import com.example.removetolocal.newentity.entity.AllotBill;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
......
package com.example.removetolocal.newentity.dao;
import com.example.removetolocal.newentity.entity.DeviceApplyBill;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
......
package com.example.removetolocal.newentity.dao;
import com.example.removetolocal.newentity.entity.DeviceCheckBill;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
......
package com.example.removetolocal.newentity.dao;
import com.example.removetolocal.newentity.entity.DeviceCheckDetail;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
......
package com.example.removetolocal.newentity.dao;
import com.example.removetolocal.newentity.entity.DeviceCheckPeriod;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
......
package com.example.removetolocal.newentity.dao;
import com.example.removetolocal.newentity.entity.DeviceCheckStat;
import org.springframework.data.jpa.repository.JpaRepository;
/**
......
package com.example.removetolocal.newentity.dao;
import com.example.removetolocal.newentity.entity.DeviceDestroyBill;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
......
......@@ -12,7 +12,6 @@ import java.util.List;
/**
* @author dengdiyi
*/
@SuppressWarnings("SqlResolve")
public interface DeviceLibraryDao extends JpaRepository<DeviceLibrary, Integer>, JpaSpecificationExecutor<DeviceLibrary> {
DeviceLibrary findByOldId(Integer oldId);
......
package com.example.removetolocal.newentity.dao;
import com.example.removetolocal.newentity.entity.DeviceRetiredBill;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
......
package com.example.removetolocal.newentity.dao;
import com.example.removetolocal.newentity.entity.DeviceUseReport;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
......
package com.example.removetolocal.newentity.dao;
import com.example.removetolocal.newentity.entity.FinalDetail;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
......@@ -14,11 +15,4 @@ import java.util.Optional;
*/
public interface FinalDetailDao extends JpaRepository<FinalDetail, Integer>, JpaSpecificationExecutor<FinalDetail> {
/**
* 根据reportId获得报告详情列表
*
* @param reportId 报告概览id
* @return 报告详情列表
*/
Optional<List<FinalDetail>> findByReportId(Integer reportId);
}
package com.example.removetolocal.newentity.dao;
import com.example.removetolocal.newentity.entity.FinalReport;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
......
package com.example.removetolocal.newentity.dao;
import com.example.removetolocal.newentity.entity.MatchingDeviceBill;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
......
package com.example.removetolocal.newentity.dao;
import com.example.removetolocal.newentity.entity.MatchingDeviceLibrary;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
......
package com.example.removetolocal.newentity.dao;
import com.example.removetolocal.newentity.entity.MatchingRepairBill;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
......
package com.example.removetolocal.newentity.dao;
import com.example.removetolocal.newentity.entity.RepairBackBill;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
......
package com.example.removetolocal.newentity.dao;
import com.example.removetolocal.newentity.entity.RepairBill;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
......
package com.example.removetolocal.newentity.dao;
import com.example.removetolocal.newentity.entity.RepairDetail;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
......
package com.example.removetolocal.newentity.dao;
import com.example.removetolocal.newentity.entity.RepairSendBill;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
......
package com.example.removetolocal.newentity.dao;
import com.example.removetolocal.newentity.entity.RfidChangeBill;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
/**
* @author HuangXiahao
* @version V1.0
......
package com.example.removetolocal.newentity.dao;
import com.example.removetolocal.newentity.entity.RfidChangeLog;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
......
package com.example.removetolocal.newentity.dao;
import com.example.removetolocal.newentity.entity.ScrapBill;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
......
package com.example.removetolocal.newentity.dao;
import com.example.removetolocal.newentity.entity.SelfCheckBill;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
......
package com.example.removetolocal.newentity.dao;
import com.example.removetolocal.newentity.entity.SendBackBill;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
......
package com.example.removetolocal.newentity.dao;
import com.example.removetolocal.newentity.entity.SendBackBillDetail;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
......
package com.example.removetolocal.newentity.dao;
import com.example.removetolocal.newentity.entity.Task;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
......@@ -12,56 +13,4 @@ import java.util.Optional;
*/
public interface TaskDao extends JpaRepository<Task, Integer>, JpaSpecificationExecutor<Task> {
/**
* @param billId 账单id
* @param businessType 业务类型
* 根据账单Id和业务类型查询task
*/
Optional<Task> findByBillIdAndBusinessType(Integer billId, Integer businessType);
/**
* 根据账单id、业务类型、任务状态查询task
*
* @param billId 账单id
* @param businessType 业务类型
* @param billStatus 任务状态
*/
List<Task> findAllByBillIdAndBusinessTypeAndBillStatus(Integer billId, Integer businessType, Integer billStatus);
/**
* 根据账单id、业务类型、任务状态查询task
*
* @param billId 账单id
* @param businessType 业务类型
*/
List<Task> findAllByBillIdAndBusinessType(Integer billId, Integer businessType);
/**
* 根据账单id、业务类型、以及父id为null
*
* @param billId 账单ID
* @param businessType 业务类型
*/
Task findAllByParentTaskIdIsNullAndBillIdAndBusinessType(Integer billId, Integer businessType);
List<Task> findAllByParentTaskId(Integer parentTaskId);
@Query("select o.billId from Task o where o.id=?1")
Integer findBillIdByTaskId(int taskId);
@Query("select o.billId from Task o where o.id=?1 and o.businessType=?2")
Integer findBillId(int id, int businessType);
@Query("select o.billId from Task o where o.parentTaskId = ?1 and o. businessType = ?2")
Integer findBillIdByParentId(int parentTaskId, int businessType);
List<Task> findTaskEntitiesByParentTaskId(Integer parentTaskId);
Task findByBusinessTypeAndOwnUnitAndBillStatus(Integer type, Integer ownUnit, Integer billStatus);
Task findByParentTaskIdAndAndTitle(Integer parentId, String title);
List<Task> findAllByBusinessType(Integer businessType);
}
package com.example.removetolocal.newentity.dao;
import com.example.removetolocal.newentity.entity.TaskLog;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
......
package com.example.removetolocal.newentity.dao;
import com.example.removetolocal.newentity.entity.WorkHandover;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
......
package com.example.removetolocal.newtrain.dao;
import com.example.removetolocal.newtrain.entity.WorkHandover;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
......
package com.example.removetolocal.newtrain.entity;
import com.example.removetolocal.config.BeanHelper;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.modelmapper.ModelMapper;
import javax.persistence.*;
import java.util.Date;
......
spring.datasource.local.url=jdbc:mysql://localhost:3306/old2?serverTimezone=Asia/Shanghai&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&useSSL=false
spring.datasource.local.url=jdbc:mysql://localhost:3306/t2?serverTimezone=Asia/Shanghai&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&useSSL=false
spring.datasource.local.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.local.username=root
spring.datasource.local.password=root
#神通
spring.datasource.backup.url=jdbc:mysql://localhost:3306/old2?serverTimezone=Asia/Shanghai&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&useSSL=false
spring.datasource.backup.url=jdbc:mysql://localhost:3306/t1?serverTimezone=Asia/Shanghai&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&useSSL=false
spring.datasource.backup.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.backup.username=root
spring.datasource.backup.password=root
spring.datasource.url=jdbc:mysql://localhost:3306/old2?serverTimezone=Asia/Shanghai&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&useSSL=false
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.username=root
spring.datasource.password=root
spring.jpa.hibernate.ddl-auto=update
spring.jpa.show-sql=false
spring.jpa.open-in-view=true
spring.jpa.hibernate.naming.physical-strategy=org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl
spring.main.allow-bean-definition-overriding=true
\ No newline at end of file
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论