Commit fed7a97e935020698399dcbafad8dd3162b17f33
0 parents
初始化
Showing
40 changed files
with
2239 additions
and
0 deletions
.gitignore
0 → 100644
| 1 | +++ a/.gitignore | |
| 1 | +HELP.md | |
| 2 | +target/ | |
| 3 | +!.mvn/wrapper/maven-wrapper.jar | |
| 4 | +!**/src/main/** | |
| 5 | +!**/src/test/** | |
| 6 | + | |
| 7 | +### STS ### | |
| 8 | +.apt_generated | |
| 9 | +.classpath | |
| 10 | +.factorypath | |
| 11 | +.project | |
| 12 | +.settings | |
| 13 | +.springBeans | |
| 14 | +.sts4-cache | |
| 15 | + | |
| 16 | +### IntelliJ IDEA ### | |
| 17 | +.idea | |
| 18 | +*.iws | |
| 19 | +*.iml | |
| 20 | +*.ipr | |
| 21 | + | |
| 22 | +### NetBeans ### | |
| 23 | +/nbproject/private/ | |
| 24 | +/nbbuild/ | |
| 25 | +/dist/ | |
| 26 | +/nbdist/ | |
| 27 | +/.nb-gradle/ | |
| 28 | +build/ | |
| 29 | + | |
| 30 | +### VS Code ### | |
| 31 | +.vscode/ | |
| 32 | + | |
| 33 | +### mvn2 ### | |
| 34 | +mvnw | |
| 35 | +mvnw.cmd | |
| 36 | +.mvn | ... | ... |
pom.xml
0 → 100644
| 1 | +++ a/pom.xml | |
| 1 | +<?xml version="1.0" encoding="UTF-8"?> | |
| 2 | +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
| 3 | + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> | |
| 4 | + <modelVersion>4.0.0</modelVersion> | |
| 5 | + <parent> | |
| 6 | + <groupId>org.springframework.boot</groupId> | |
| 7 | + <artifactId>spring-boot-starter-parent</artifactId> | |
| 8 | + <version>2.3.0.RELEASE</version> | |
| 9 | + <relativePath/> <!-- lookup parent from repository --> | |
| 10 | + </parent> | |
| 11 | + <groupId>com.bsth.control_v3</groupId> | |
| 12 | + <artifactId>plan_module-service-data_sync</artifactId> | |
| 13 | + <version>0.0.1-SNAPSHOT</version> | |
| 14 | + <name>plan_module-service-data_sync</name> | |
| 15 | + <description>浦东计划调度数据同步模块</description> | |
| 16 | + | |
| 17 | + <properties> | |
| 18 | + <java.version>1.8</java.version> | |
| 19 | + </properties> | |
| 20 | + | |
| 21 | + <dependencies> | |
| 22 | + <dependency> | |
| 23 | + <groupId>org.springframework.boot</groupId> | |
| 24 | + <artifactId>spring-boot-starter-batch</artifactId> | |
| 25 | + </dependency> | |
| 26 | + <dependency> | |
| 27 | + <groupId>org.springframework.boot</groupId> | |
| 28 | + <artifactId>spring-boot-starter-data-jdbc</artifactId> | |
| 29 | + </dependency> | |
| 30 | + <dependency> | |
| 31 | + <groupId>org.springframework.boot</groupId> | |
| 32 | + <artifactId>spring-boot-starter-data-jpa</artifactId> | |
| 33 | + </dependency> | |
| 34 | + <dependency> | |
| 35 | + <groupId>org.springframework.boot</groupId> | |
| 36 | + <artifactId>spring-boot-starter-jdbc</artifactId> | |
| 37 | + </dependency> | |
| 38 | + | |
| 39 | + <dependency> | |
| 40 | + <groupId>com.h2database</groupId> | |
| 41 | + <artifactId>h2</artifactId> | |
| 42 | + <scope>test</scope> | |
| 43 | + </dependency> | |
| 44 | + <dependency> | |
| 45 | + <groupId>mysql</groupId> | |
| 46 | + <artifactId>mysql-connector-java</artifactId> | |
| 47 | + <scope>runtime</scope> | |
| 48 | + </dependency> | |
| 49 | + <dependency> | |
| 50 | + <groupId>org.springframework.boot</groupId> | |
| 51 | + <artifactId>spring-boot-starter-test</artifactId> | |
| 52 | + <scope>test</scope> | |
| 53 | + <exclusions> | |
| 54 | + <exclusion> | |
| 55 | + <groupId>org.junit.vintage</groupId> | |
| 56 | + <artifactId>junit-vintage-engine</artifactId> | |
| 57 | + </exclusion> | |
| 58 | + </exclusions> | |
| 59 | + </dependency> | |
| 60 | + <dependency> | |
| 61 | + <groupId>org.springframework.batch</groupId> | |
| 62 | + <artifactId>spring-batch-test</artifactId> | |
| 63 | + <scope>test</scope> | |
| 64 | + </dependency> | |
| 65 | + <dependency> | |
| 66 | + <groupId>org.dbunit</groupId> | |
| 67 | + <artifactId>dbunit</artifactId> | |
| 68 | + <version>2.4.9</version> | |
| 69 | + <scope>test</scope> | |
| 70 | + </dependency> | |
| 71 | + </dependencies> | |
| 72 | + | |
| 73 | + <build> | |
| 74 | + <plugins> | |
| 75 | + <plugin> | |
| 76 | + <groupId>org.springframework.boot</groupId> | |
| 77 | + <artifactId>spring-boot-maven-plugin</artifactId> | |
| 78 | + </plugin> | |
| 79 | + </plugins> | |
| 80 | + </build> | |
| 81 | + | |
| 82 | +</project> | ... | ... |
src/main/java/com/bsth/control_v3/plan_module/service/data_sync/PlanModuleServiceDataSyncApplication.java
0 → 100644
| 1 | +++ a/src/main/java/com/bsth/control_v3/plan_module/service/data_sync/PlanModuleServiceDataSyncApplication.java | |
| 1 | +package com.bsth.control_v3.plan_module.service.data_sync; | |
| 2 | + | |
| 3 | +import org.springframework.boot.CommandLineRunner; | |
| 4 | +import org.springframework.boot.SpringApplication; | |
| 5 | +import org.springframework.boot.autoconfigure.SpringBootApplication; | |
| 6 | +import org.springframework.transaction.annotation.EnableTransactionManagement; | |
| 7 | + | |
| 8 | +@EnableTransactionManagement | |
| 9 | +@SpringBootApplication | |
| 10 | +public class PlanModuleServiceDataSyncApplication implements CommandLineRunner { | |
| 11 | + | |
| 12 | + @Override | |
| 13 | + public void run(String... args) throws Exception { | |
| 14 | + // TODO:其他初始化代码 | |
| 15 | + | |
| 16 | + } | |
| 17 | + | |
| 18 | + public static void main(String[] args) { | |
| 19 | + | |
| 20 | + SpringApplication.run(PlanModuleServiceDataSyncApplication.class, args); | |
| 21 | + | |
| 22 | + } | |
| 23 | + | |
| 24 | +} | ... | ... |
src/main/java/com/bsth/control_v3/plan_module/service/data_sync/vehicle/batch/MySQL5InnoDBDialectExt.java
0 → 100644
| 1 | +++ a/src/main/java/com/bsth/control_v3/plan_module/service/data_sync/vehicle/batch/MySQL5InnoDBDialectExt.java | |
| 1 | +package com.bsth.control_v3.plan_module.service.data_sync.vehicle.batch; | |
| 2 | + | |
| 3 | +import org.hibernate.dialect.InnoDBStorageEngine; | |
| 4 | +import org.hibernate.dialect.MySQL5Dialect; | |
| 5 | +import org.hibernate.dialect.MySQLStorageEngine; | |
| 6 | + | |
| 7 | +/** | |
| 8 | + * springBoot 2使用了新的mysql驱动类 com.mysql.cj.jdbc.Driver,和原来的比较会有一些问题 | |
| 9 | + * 1、日期,默认保存日期会差12个小时,是时区问题,需要在数据库连接字符串上加 serverTimezone=GMT%2B8 | |
| 10 | + * 2、默认创建表示使用的引擎是 MyIsam,默认的字符集为 latin1,需要在配置文件中设定 MySQL5Dialect,如下: | |
| 11 | + * spring.jpa.database-platform=com.bsth.control_v3.plan_module.service.data_sync.vehicle.batch.MySQL5InnoDBDialectExt | |
| 12 | + */ | |
| 13 | +public class MySQL5InnoDBDialectExt extends MySQL5Dialect { | |
| 14 | + | |
| 15 | + @Override | |
| 16 | + protected MySQLStorageEngine getDefaultMySQLStorageEngine() { | |
| 17 | + return InnoDBStorageEngine.INSTANCE; | |
| 18 | + } | |
| 19 | + | |
| 20 | + @Override | |
| 21 | + public String getTableTypeString() { | |
| 22 | + return "ENGINE=InnoDB DEFAULT CHARSET=utf8"; | |
| 23 | + } | |
| 24 | +} | ... | ... |
src/main/java/com/bsth/control_v3/plan_module/service/data_sync/vehicle/batch/VehicleDataSyncBatchConfig.java
0 → 100644
| 1 | +++ a/src/main/java/com/bsth/control_v3/plan_module/service/data_sync/vehicle/batch/VehicleDataSyncBatchConfig.java | |
| 1 | +package com.bsth.control_v3.plan_module.service.data_sync.vehicle.batch; | |
| 2 | + | |
| 3 | +import com.bsth.control_v3.plan_module.service.data_sync.vehicle.batch.domain.VehicleData; | |
| 4 | +import com.bsth.control_v3.plan_module.service.data_sync.vehicle.batch.domain.VehicleDataSync; | |
| 5 | +import com.bsth.control_v3.plan_module.service.data_sync.vehicle.batch.domain.VehicleDataSyncStatusEnum; | |
| 6 | +import com.bsth.control_v3.plan_module.service.data_sync.vehicle.batch.repo.VehicleDataRepo; | |
| 7 | +import com.bsth.control_v3.plan_module.service.data_sync.vehicle.batch.repo.VehicleDataSyncRepo; | |
| 8 | +import com.bsth.control_v3.plan_module.service.data_sync.vehicle.batch.service.listener.*; | |
| 9 | +import com.bsth.control_v3.plan_module.service.data_sync.vehicle.batch.service.process.PrepareStepDataProcessor; | |
| 10 | +import com.bsth.control_v3.plan_module.service.data_sync.vehicle.batch.service.process.SyncStepDataProcessor; | |
| 11 | +import org.springframework.batch.core.Job; | |
| 12 | +import org.springframework.batch.core.Step; | |
| 13 | +import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing; | |
| 14 | +import org.springframework.batch.core.configuration.annotation.JobBuilderFactory; | |
| 15 | +import org.springframework.batch.core.configuration.annotation.StepBuilderFactory; | |
| 16 | +import org.springframework.batch.core.launch.support.RunIdIncrementer; | |
| 17 | +import org.springframework.batch.item.data.RepositoryItemReader; | |
| 18 | +import org.springframework.batch.item.data.RepositoryItemWriter; | |
| 19 | +import org.springframework.batch.item.data.builder.RepositoryItemReaderBuilder; | |
| 20 | +import org.springframework.batch.item.data.builder.RepositoryItemWriterBuilder; | |
| 21 | +import org.springframework.beans.factory.annotation.Autowired; | |
| 22 | +import org.springframework.context.annotation.Bean; | |
| 23 | +import org.springframework.context.annotation.Configuration; | |
| 24 | +import org.springframework.data.domain.Sort; | |
| 25 | + | |
| 26 | +import java.util.Collections; | |
| 27 | + | |
| 28 | +/** | |
| 29 | + * 车辆数据同步批处理相关配置config。 | |
| 30 | + */ | |
| 31 | +@Configuration | |
| 32 | +@EnableBatchProcessing | |
| 33 | +public class VehicleDataSyncBatchConfig { | |
| 34 | + @Autowired | |
| 35 | + private JobBuilderFactory jobBuilderFactory; | |
| 36 | + @Autowired | |
| 37 | + private StepBuilderFactory stepBuilderFactory; | |
| 38 | + @Autowired | |
| 39 | + private VehicleDataSyncRepo vehicleDataSyncDomainRepo; | |
| 40 | + @Autowired | |
| 41 | + private VehicleDataRepo vehicleDataRepo; | |
| 42 | + | |
| 43 | + //------------------ process service ------------------// | |
| 44 | + @Autowired | |
| 45 | + private PrepareStepDataProcessor prepareStepDataProcessor; | |
| 46 | + @Autowired | |
| 47 | + private SyncStepDataProcessor syncStepDataProcessor; | |
| 48 | + | |
| 49 | + //------------------ 监听器service ----------------// | |
| 50 | + @Autowired | |
| 51 | + private JobStatListener jobStatListener; | |
| 52 | + @Autowired | |
| 53 | + private PrepareStepReadStatListener prepareStepReadStatListener; | |
| 54 | + @Autowired | |
| 55 | + private PrepareStepProcessStatListener prepareStepProcessStatListener; | |
| 56 | + @Autowired | |
| 57 | + private PrepareStepWriteStatListener prepareStepWriteStatListener; | |
| 58 | + @Autowired | |
| 59 | + private SyncStepReadStatListener syncStepReadStatListener; | |
| 60 | + @Autowired | |
| 61 | + private SyncStepProcessStatListener syncStepProcessStatListener; | |
| 62 | + @Autowired | |
| 63 | + private SyncStepWriteStatListener syncStepWriteStatListener; | |
| 64 | + | |
| 65 | + @Bean | |
| 66 | + public Job vehicleDataSyncJob() { | |
| 67 | + return this.jobBuilderFactory | |
| 68 | + .get("vehicleDataSyncJob") | |
| 69 | + .start(vehicleDataSyncPrepareStep()) | |
| 70 | + .next(vehicleDataSyncSyncStep()) | |
| 71 | + .listener(jobStatListener) | |
| 72 | + .incrementer(new RunIdIncrementer()) | |
| 73 | + .build(); | |
| 74 | + } | |
| 75 | + | |
| 76 | + //--------------- prepare step 配置 -----------------// | |
| 77 | + @Bean | |
| 78 | + public Step vehicleDataSyncPrepareStep() { | |
| 79 | + return this.stepBuilderFactory | |
| 80 | + .get("vehicleDataSyncPrepareStep") | |
| 81 | + .<VehicleDataSync, VehicleDataSync>chunk(10) | |
| 82 | + .reader(vehicleDataSyncPrepareStepDataReader()) | |
| 83 | + .processor(prepareStepDataProcessor) | |
| 84 | + .writer(vehicleDataSyncPrepareStepDataWriter()) | |
| 85 | + .listener(prepareStepReadStatListener) | |
| 86 | + .listener(prepareStepProcessStatListener) | |
| 87 | + .listener(prepareStepWriteStatListener) | |
| 88 | + .build(); | |
| 89 | + } | |
| 90 | + @Bean | |
| 91 | + public RepositoryItemReader<VehicleDataSync> vehicleDataSyncPrepareStepDataReader() { | |
| 92 | + return new RepositoryItemReaderBuilder<VehicleDataSync>() | |
| 93 | + .saveState(false) // 不保存step状态 | |
| 94 | + .repository(this.vehicleDataSyncDomainRepo) | |
| 95 | + .methodName("findByStatus") | |
| 96 | + .arguments(Collections.singletonList(VehicleDataSyncStatusEnum.PREPARE)) | |
| 97 | + .sorts(Collections.singletonMap("createDate", Sort.Direction.ASC)) | |
| 98 | + .build(); | |
| 99 | + } | |
| 100 | + @Bean | |
| 101 | + public RepositoryItemWriter<VehicleDataSync> vehicleDataSyncPrepareStepDataWriter() { | |
| 102 | + return new RepositoryItemWriterBuilder<VehicleDataSync>() | |
| 103 | + .repository(this.vehicleDataSyncDomainRepo) | |
| 104 | + .methodName("save") | |
| 105 | + .build(); | |
| 106 | + } | |
| 107 | + | |
| 108 | + | |
| 109 | + //--------------- sync step 配置 -----------------// | |
| 110 | + @Bean | |
| 111 | + public Step vehicleDataSyncSyncStep() { | |
| 112 | + return this.stepBuilderFactory | |
| 113 | + .get("vehicleDataSyncSyncStep") | |
| 114 | + .<VehicleDataSync, VehicleData>chunk(10) | |
| 115 | + .reader(vehicleDataSyncSyncStepDataReader()) | |
| 116 | + .processor(syncStepDataProcessor) | |
| 117 | + .writer(vehicleDataSyncSyncStepDataWriter()) | |
| 118 | + .listener(syncStepReadStatListener) | |
| 119 | + .listener(syncStepProcessStatListener) | |
| 120 | + .listener(syncStepWriteStatListener) | |
| 121 | + .build(); | |
| 122 | + } | |
| 123 | + @Bean | |
| 124 | + public RepositoryItemReader<VehicleDataSync> vehicleDataSyncSyncStepDataReader() { | |
| 125 | + return new RepositoryItemReaderBuilder<VehicleDataSync>() | |
| 126 | + .saveState(false) // 不保存step状态 | |
| 127 | + .repository(this.vehicleDataSyncDomainRepo) | |
| 128 | + .methodName("findByStatus") | |
| 129 | + .arguments(Collections.singletonList(VehicleDataSyncStatusEnum.SYNCING)) | |
| 130 | + .sorts(Collections.singletonMap("createDate", Sort.Direction.ASC)) | |
| 131 | + .build(); | |
| 132 | + } | |
| 133 | + @Bean | |
| 134 | + public RepositoryItemWriter<VehicleData> vehicleDataSyncSyncStepDataWriter() { | |
| 135 | + return new RepositoryItemWriterBuilder<VehicleData>() | |
| 136 | + .repository(this.vehicleDataRepo) | |
| 137 | + .methodName("save") | |
| 138 | + .build(); | |
| 139 | + } | |
| 140 | +} | ... | ... |
src/main/java/com/bsth/control_v3/plan_module/service/data_sync/vehicle/batch/VehicleDataSyncBatchThread.java
0 → 100644
| 1 | +++ a/src/main/java/com/bsth/control_v3/plan_module/service/data_sync/vehicle/batch/VehicleDataSyncBatchThread.java | |
| 1 | +package com.bsth.control_v3.plan_module.service.data_sync.vehicle.batch; | |
| 2 | + | |
| 3 | +import com.bsth.control_v3.plan_module.service.data_sync.vehicle.batch.domain.VehicleDataSyncStatusEnum; | |
| 4 | +import com.bsth.control_v3.plan_module.service.data_sync.vehicle.batch.repo.VehicleDataSyncRepo; | |
| 5 | +import org.slf4j.Logger; | |
| 6 | +import org.slf4j.LoggerFactory; | |
| 7 | +import org.springframework.batch.core.Job; | |
| 8 | +import org.springframework.batch.core.JobParameters; | |
| 9 | +import org.springframework.batch.core.launch.JobLauncher; | |
| 10 | +import org.springframework.beans.factory.DisposableBean; | |
| 11 | +import org.springframework.beans.factory.annotation.Autowired; | |
| 12 | +import org.springframework.beans.factory.annotation.Qualifier; | |
| 13 | +import org.springframework.stereotype.Component; | |
| 14 | + | |
| 15 | +import javax.annotation.PostConstruct; | |
| 16 | +import java.util.Date; | |
| 17 | + | |
| 18 | +@Component | |
| 19 | +public class VehicleDataSyncBatchThread implements Runnable, DisposableBean { | |
| 20 | + /** 日志记录器 */ | |
| 21 | + private final static Logger LOG = LoggerFactory.getLogger(VehicleDataSyncBatchThread.class); | |
| 22 | + | |
| 23 | + /** bean是否销毁(用于优雅退出) */ | |
| 24 | + private volatile boolean beanDestroy = false; | |
| 25 | + /** service是否完成 */ | |
| 26 | + private volatile boolean serviceComplete = false; | |
| 27 | + | |
| 28 | + /** 最近service完成时间 */ | |
| 29 | + private Date lastServiceCompleteDate = new Date(); | |
| 30 | + /** 数据同步间隔(秒) */ | |
| 31 | + private Integer serviceIdleSecond = 1; | |
| 32 | + | |
| 33 | + @PostConstruct | |
| 34 | + public void init() { | |
| 35 | + LOG.info("车辆数据同步服务启动!"); | |
| 36 | + // 启动线程实例 | |
| 37 | + new Thread(this).start(); | |
| 38 | + } | |
| 39 | + | |
| 40 | + @Override | |
| 41 | + public void destroy() throws Exception { | |
| 42 | + beanDestroy = true; | |
| 43 | + while (!serviceComplete) { | |
| 44 | + // 等待service完成 | |
| 45 | + try { | |
| 46 | + // 等待1秒后继续判定 | |
| 47 | + Thread.sleep(1000); | |
| 48 | + } catch (Exception exp) { | |
| 49 | + exp.printStackTrace(); | |
| 50 | + } | |
| 51 | + } | |
| 52 | + LOG.info("车辆数据同步服务销毁!"); | |
| 53 | + } | |
| 54 | + | |
| 55 | + @Override | |
| 56 | + public void run() { | |
| 57 | + while (!beanDestroy) { | |
| 58 | + Date current = new Date(); | |
| 59 | + long testIdleTime = current.getTime() - lastServiceCompleteDate.getTime(); | |
| 60 | + if (testIdleTime > serviceIdleSecond * 1000) { | |
| 61 | + service(); | |
| 62 | + } | |
| 63 | + | |
| 64 | + // 等待100毫秒后继续判定 | |
| 65 | + try { | |
| 66 | + Thread.sleep(100); | |
| 67 | + } catch (Exception exp) { | |
| 68 | + exp.printStackTrace(); | |
| 69 | + } | |
| 70 | + } | |
| 71 | + } | |
| 72 | + | |
| 73 | + @Autowired | |
| 74 | + private VehicleDataSyncRepo vehicleDataSyncRepo; | |
| 75 | + protected void service() { | |
| 76 | + serviceComplete = false; | |
| 77 | + try { | |
| 78 | + long prepareCount = this.vehicleDataSyncRepo.countByStatus(VehicleDataSyncStatusEnum.PREPARE); | |
| 79 | + if (prepareCount > 0) { | |
| 80 | + doService(); | |
| 81 | + } | |
| 82 | + } catch (Exception exp) { | |
| 83 | + exp.printStackTrace(); | |
| 84 | + } finally { | |
| 85 | + lastServiceCompleteDate = new Date(); | |
| 86 | + serviceComplete = true; | |
| 87 | + } | |
| 88 | + } | |
| 89 | + | |
| 90 | + @Autowired | |
| 91 | + private JobLauncher jobLauncher; | |
| 92 | + @Autowired | |
| 93 | + @Qualifier("vehicleDataSyncJob") | |
| 94 | + private Job vehicleDataSyncJob; | |
| 95 | + protected void doService() throws Exception { | |
| 96 | + LOG.info("车辆数据同步开始..."); | |
| 97 | + // 启动job | |
| 98 | + this.jobLauncher.run(vehicleDataSyncJob, new JobParameters()); | |
| 99 | + LOG.info("车辆数据同步结束..."); | |
| 100 | + } | |
| 101 | +} | |
| 102 | + | ... | ... |
src/main/java/com/bsth/control_v3/plan_module/service/data_sync/vehicle/batch/domain/VehicleData.java
0 → 100644
| 1 | +++ a/src/main/java/com/bsth/control_v3/plan_module/service/data_sync/vehicle/batch/domain/VehicleData.java | |
| 1 | +package com.bsth.control_v3.plan_module.service.data_sync.vehicle.batch.domain; | |
| 2 | + | |
| 3 | +import javax.persistence.*; | |
| 4 | +import java.io.Serializable; | |
| 5 | +import java.util.Date; | |
| 6 | + | |
| 7 | +/** | |
| 8 | + * 车辆数据用Domain。 | |
| 9 | + */ | |
| 10 | +@Entity | |
| 11 | +@Table(name = "bsth_c_cars") | |
| 12 | +public class VehicleData implements Serializable { | |
| 13 | + /** 主健Id */ | |
| 14 | + @Id | |
| 15 | + @GeneratedValue | |
| 16 | + private Integer id; | |
| 17 | + | |
| 18 | + /** 自编号/内部编号 */ | |
| 19 | + @Column(nullable = false, length = 20, unique = true) | |
| 20 | + private String insideCode; | |
| 21 | + | |
| 22 | + /** 公司代码 */ | |
| 23 | + @Column(nullable = false) | |
| 24 | + private String businessCode; | |
| 25 | + /** 公司名称 */ | |
| 26 | + @Column(nullable = false) | |
| 27 | + private String company; | |
| 28 | + /** 分公司编码 */ | |
| 29 | + private String brancheCompanyCode; | |
| 30 | + /** 分公司 */ | |
| 31 | + private String brancheCompany; | |
| 32 | + | |
| 33 | + /** 车辆编码(TODO:在原系统里没有,这里暂时留着) */ | |
| 34 | + @Column(nullable = false) | |
| 35 | + private String carCode; | |
| 36 | + /** 车牌号 */ | |
| 37 | + @Column(nullable = false) | |
| 38 | + private String carPlate; | |
| 39 | + /** 供应商名称 */ | |
| 40 | + @Column(nullable = false) | |
| 41 | + private String supplierName; | |
| 42 | + /** 设备终端号 */ | |
| 43 | + @Column(nullable = false) | |
| 44 | + private String equipmentCode; | |
| 45 | + | |
| 46 | + // 以下信息来自总公司的业务系统,可能需要调用相关接口 | |
| 47 | + /** 车型类别 */ | |
| 48 | + private String carClass ; | |
| 49 | + /** 技术速度 */ | |
| 50 | + private Double speed; | |
| 51 | + /** 座位数 */ | |
| 52 | + private Integer carSeatnNumber; | |
| 53 | + /** 载客标准 */ | |
| 54 | + private String carStandard; | |
| 55 | + /** 标准油耗(开空调) */ | |
| 56 | + private Double kburnStandard; | |
| 57 | + /** 标准油耗(关空调) */ | |
| 58 | + private Double gburnStandard; | |
| 59 | + /** 报废号 */ | |
| 60 | + private String scrapCode; | |
| 61 | + /** 报废日期 */ | |
| 62 | + private Date scrapDate; | |
| 63 | + /** 厂牌型号1 */ | |
| 64 | + private String makeCodeOne; | |
| 65 | + /** 厂牌型号2 */ | |
| 66 | + private String makeCodeTwo; | |
| 67 | + /** 车辆等级标准 */ | |
| 68 | + private String carGride; | |
| 69 | + /** 出厂排放标准 */ | |
| 70 | + private String emissionsStandard; | |
| 71 | + /** 发动机号码1 */ | |
| 72 | + private String engineCodeOne; | |
| 73 | + /** 发动机号码2 */ | |
| 74 | + private String engineCodeTwo; | |
| 75 | + /** 车架号码1 */ | |
| 76 | + private String carNumberOne; | |
| 77 | + /** 车架号码2 */ | |
| 78 | + private String carNumberTwo; | |
| 79 | + /** 启用日期(2008-10-10)*/ | |
| 80 | + private Date openDate; | |
| 81 | + /** 取消日期 */ | |
| 82 | + private Date closeDate; | |
| 83 | + | |
| 84 | + /** 是否空调车 */ | |
| 85 | + @Column(nullable = true) | |
| 86 | + private Boolean hvacCar; | |
| 87 | + /** 有无人售票 */ | |
| 88 | + @Column(nullable = true) | |
| 89 | + private Boolean ticketType; | |
| 90 | + /** 是否有LED服务屏 */ | |
| 91 | + @Column(nullable = true) | |
| 92 | + private Boolean ledScreen; | |
| 93 | + /** 是否有TV视频 */ | |
| 94 | + @Column(nullable = true) | |
| 95 | + private Boolean tvVideoType; | |
| 96 | + | |
| 97 | + /** 车辆类型 */ | |
| 98 | + private String carType; | |
| 99 | + /** 是否机动车(机动车类型选择)*/ | |
| 100 | + private String vehicleStats; | |
| 101 | + /** 营运状态 */ | |
| 102 | + private String operatorsState; | |
| 103 | + /** 营运证编码 */ | |
| 104 | + private String serviceNo; | |
| 105 | + /** 是否电车(TODO:在原系统里没有,这里暂时留着) */ | |
| 106 | + private Boolean sfdc; | |
| 107 | + /** 是否混合动力(TODO:在原系统里没有,这里暂时留着) */ | |
| 108 | + private Boolean sfmix; | |
| 109 | + /** 备注/描述 */ | |
| 110 | + private String descriptions; | |
| 111 | + | |
| 112 | + /** 车辆序号(TODO:在原系统里没有,这里暂时留着) */ | |
| 113 | + private String carOrdinal; | |
| 114 | + /** 视频编号 */ | |
| 115 | + private String videoCode; | |
| 116 | + /** 是否报废 */ | |
| 117 | + @Column(nullable = true) | |
| 118 | + private Boolean scrapState; | |
| 119 | + /** 是否切换(TODO:在原系统里没有,这里暂时留着)*/ | |
| 120 | + private Integer isSwitch; | |
| 121 | + /** 线路名称(TODO:在原系统里没有,这里暂时留着,并且不做线路关联,只保留个名字) */ | |
| 122 | + private String xlmc; | |
| 123 | + | |
| 124 | + /** 创建日期 */ | |
| 125 | + @Column(updatable = false, name = "create_date") | |
| 126 | + private Date createDate; | |
| 127 | + /** 修改日期 */ | |
| 128 | + @Column(name = "update_date") | |
| 129 | + private Date updateDate; | |
| 130 | + | |
| 131 | + public Integer getId() { | |
| 132 | + return id; | |
| 133 | + } | |
| 134 | + | |
| 135 | + public void setId(Integer id) { | |
| 136 | + this.id = id; | |
| 137 | + } | |
| 138 | + | |
| 139 | + public String getInsideCode() { | |
| 140 | + return insideCode; | |
| 141 | + } | |
| 142 | + | |
| 143 | + public void setInsideCode(String insideCode) { | |
| 144 | + this.insideCode = insideCode; | |
| 145 | + } | |
| 146 | + | |
| 147 | + public String getBusinessCode() { | |
| 148 | + return businessCode; | |
| 149 | + } | |
| 150 | + | |
| 151 | + public void setBusinessCode(String businessCode) { | |
| 152 | + this.businessCode = businessCode; | |
| 153 | + } | |
| 154 | + | |
| 155 | + public String getCompany() { | |
| 156 | + return company; | |
| 157 | + } | |
| 158 | + | |
| 159 | + public void setCompany(String company) { | |
| 160 | + this.company = company; | |
| 161 | + } | |
| 162 | + | |
| 163 | + public String getBrancheCompanyCode() { | |
| 164 | + return brancheCompanyCode; | |
| 165 | + } | |
| 166 | + | |
| 167 | + public void setBrancheCompanyCode(String brancheCompanyCode) { | |
| 168 | + this.brancheCompanyCode = brancheCompanyCode; | |
| 169 | + } | |
| 170 | + | |
| 171 | + public String getBrancheCompany() { | |
| 172 | + return brancheCompany; | |
| 173 | + } | |
| 174 | + | |
| 175 | + public void setBrancheCompany(String brancheCompany) { | |
| 176 | + this.brancheCompany = brancheCompany; | |
| 177 | + } | |
| 178 | + | |
| 179 | + public String getCarCode() { | |
| 180 | + return carCode; | |
| 181 | + } | |
| 182 | + | |
| 183 | + public void setCarCode(String carCode) { | |
| 184 | + this.carCode = carCode; | |
| 185 | + } | |
| 186 | + | |
| 187 | + public String getCarPlate() { | |
| 188 | + return carPlate; | |
| 189 | + } | |
| 190 | + | |
| 191 | + public void setCarPlate(String carPlate) { | |
| 192 | + this.carPlate = carPlate; | |
| 193 | + } | |
| 194 | + | |
| 195 | + public String getSupplierName() { | |
| 196 | + return supplierName; | |
| 197 | + } | |
| 198 | + | |
| 199 | + public void setSupplierName(String supplierName) { | |
| 200 | + this.supplierName = supplierName; | |
| 201 | + } | |
| 202 | + | |
| 203 | + public String getEquipmentCode() { | |
| 204 | + return equipmentCode; | |
| 205 | + } | |
| 206 | + | |
| 207 | + public void setEquipmentCode(String equipmentCode) { | |
| 208 | + this.equipmentCode = equipmentCode; | |
| 209 | + } | |
| 210 | + | |
| 211 | + public String getCarClass() { | |
| 212 | + return carClass; | |
| 213 | + } | |
| 214 | + | |
| 215 | + public void setCarClass(String carClass) { | |
| 216 | + this.carClass = carClass; | |
| 217 | + } | |
| 218 | + | |
| 219 | + public Double getSpeed() { | |
| 220 | + return speed; | |
| 221 | + } | |
| 222 | + | |
| 223 | + public void setSpeed(Double speed) { | |
| 224 | + this.speed = speed; | |
| 225 | + } | |
| 226 | + | |
| 227 | + public Integer getCarSeatnNumber() { | |
| 228 | + return carSeatnNumber; | |
| 229 | + } | |
| 230 | + | |
| 231 | + public void setCarSeatnNumber(Integer carSeatnNumber) { | |
| 232 | + this.carSeatnNumber = carSeatnNumber; | |
| 233 | + } | |
| 234 | + | |
| 235 | + public String getCarStandard() { | |
| 236 | + return carStandard; | |
| 237 | + } | |
| 238 | + | |
| 239 | + public void setCarStandard(String carStandard) { | |
| 240 | + this.carStandard = carStandard; | |
| 241 | + } | |
| 242 | + | |
| 243 | + public Double getKburnStandard() { | |
| 244 | + return kburnStandard; | |
| 245 | + } | |
| 246 | + | |
| 247 | + public void setKburnStandard(Double kburnStandard) { | |
| 248 | + this.kburnStandard = kburnStandard; | |
| 249 | + } | |
| 250 | + | |
| 251 | + public Double getGburnStandard() { | |
| 252 | + return gburnStandard; | |
| 253 | + } | |
| 254 | + | |
| 255 | + public void setGburnStandard(Double gburnStandard) { | |
| 256 | + this.gburnStandard = gburnStandard; | |
| 257 | + } | |
| 258 | + | |
| 259 | + public String getScrapCode() { | |
| 260 | + return scrapCode; | |
| 261 | + } | |
| 262 | + | |
| 263 | + public void setScrapCode(String scrapCode) { | |
| 264 | + this.scrapCode = scrapCode; | |
| 265 | + } | |
| 266 | + | |
| 267 | + public Date getScrapDate() { | |
| 268 | + return scrapDate; | |
| 269 | + } | |
| 270 | + | |
| 271 | + public void setScrapDate(Date scrapDate) { | |
| 272 | + this.scrapDate = scrapDate; | |
| 273 | + } | |
| 274 | + | |
| 275 | + public String getMakeCodeOne() { | |
| 276 | + return makeCodeOne; | |
| 277 | + } | |
| 278 | + | |
| 279 | + public void setMakeCodeOne(String makeCodeOne) { | |
| 280 | + this.makeCodeOne = makeCodeOne; | |
| 281 | + } | |
| 282 | + | |
| 283 | + public String getMakeCodeTwo() { | |
| 284 | + return makeCodeTwo; | |
| 285 | + } | |
| 286 | + | |
| 287 | + public void setMakeCodeTwo(String makeCodeTwo) { | |
| 288 | + this.makeCodeTwo = makeCodeTwo; | |
| 289 | + } | |
| 290 | + | |
| 291 | + public String getCarGride() { | |
| 292 | + return carGride; | |
| 293 | + } | |
| 294 | + | |
| 295 | + public void setCarGride(String carGride) { | |
| 296 | + this.carGride = carGride; | |
| 297 | + } | |
| 298 | + | |
| 299 | + public String getEmissionsStandard() { | |
| 300 | + return emissionsStandard; | |
| 301 | + } | |
| 302 | + | |
| 303 | + public void setEmissionsStandard(String emissionsStandard) { | |
| 304 | + this.emissionsStandard = emissionsStandard; | |
| 305 | + } | |
| 306 | + | |
| 307 | + public String getEngineCodeOne() { | |
| 308 | + return engineCodeOne; | |
| 309 | + } | |
| 310 | + | |
| 311 | + public void setEngineCodeOne(String engineCodeOne) { | |
| 312 | + this.engineCodeOne = engineCodeOne; | |
| 313 | + } | |
| 314 | + | |
| 315 | + public String getEngineCodeTwo() { | |
| 316 | + return engineCodeTwo; | |
| 317 | + } | |
| 318 | + | |
| 319 | + public void setEngineCodeTwo(String engineCodeTwo) { | |
| 320 | + this.engineCodeTwo = engineCodeTwo; | |
| 321 | + } | |
| 322 | + | |
| 323 | + public String getCarNumberOne() { | |
| 324 | + return carNumberOne; | |
| 325 | + } | |
| 326 | + | |
| 327 | + public void setCarNumberOne(String carNumberOne) { | |
| 328 | + this.carNumberOne = carNumberOne; | |
| 329 | + } | |
| 330 | + | |
| 331 | + public String getCarNumberTwo() { | |
| 332 | + return carNumberTwo; | |
| 333 | + } | |
| 334 | + | |
| 335 | + public void setCarNumberTwo(String carNumberTwo) { | |
| 336 | + this.carNumberTwo = carNumberTwo; | |
| 337 | + } | |
| 338 | + | |
| 339 | + public Date getOpenDate() { | |
| 340 | + return openDate; | |
| 341 | + } | |
| 342 | + | |
| 343 | + public void setOpenDate(Date openDate) { | |
| 344 | + this.openDate = openDate; | |
| 345 | + } | |
| 346 | + | |
| 347 | + public Date getCloseDate() { | |
| 348 | + return closeDate; | |
| 349 | + } | |
| 350 | + | |
| 351 | + public void setCloseDate(Date closeDate) { | |
| 352 | + this.closeDate = closeDate; | |
| 353 | + } | |
| 354 | + | |
| 355 | + public Boolean getHvacCar() { | |
| 356 | + return hvacCar; | |
| 357 | + } | |
| 358 | + | |
| 359 | + public void setHvacCar(Boolean hvacCar) { | |
| 360 | + this.hvacCar = hvacCar; | |
| 361 | + } | |
| 362 | + | |
| 363 | + public Boolean getTicketType() { | |
| 364 | + return ticketType; | |
| 365 | + } | |
| 366 | + | |
| 367 | + public void setTicketType(Boolean ticketType) { | |
| 368 | + this.ticketType = ticketType; | |
| 369 | + } | |
| 370 | + | |
| 371 | + public Boolean getLedScreen() { | |
| 372 | + return ledScreen; | |
| 373 | + } | |
| 374 | + | |
| 375 | + public void setLedScreen(Boolean ledScreen) { | |
| 376 | + this.ledScreen = ledScreen; | |
| 377 | + } | |
| 378 | + | |
| 379 | + public Boolean getTvVideoType() { | |
| 380 | + return tvVideoType; | |
| 381 | + } | |
| 382 | + | |
| 383 | + public void setTvVideoType(Boolean tvVideoType) { | |
| 384 | + this.tvVideoType = tvVideoType; | |
| 385 | + } | |
| 386 | + | |
| 387 | + public String getCarType() { | |
| 388 | + return carType; | |
| 389 | + } | |
| 390 | + | |
| 391 | + public void setCarType(String carType) { | |
| 392 | + this.carType = carType; | |
| 393 | + } | |
| 394 | + | |
| 395 | + public String getVehicleStats() { | |
| 396 | + return vehicleStats; | |
| 397 | + } | |
| 398 | + | |
| 399 | + public void setVehicleStats(String vehicleStats) { | |
| 400 | + this.vehicleStats = vehicleStats; | |
| 401 | + } | |
| 402 | + | |
| 403 | + public String getOperatorsState() { | |
| 404 | + return operatorsState; | |
| 405 | + } | |
| 406 | + | |
| 407 | + public void setOperatorsState(String operatorsState) { | |
| 408 | + this.operatorsState = operatorsState; | |
| 409 | + } | |
| 410 | + | |
| 411 | + public String getServiceNo() { | |
| 412 | + return serviceNo; | |
| 413 | + } | |
| 414 | + | |
| 415 | + public void setServiceNo(String serviceNo) { | |
| 416 | + this.serviceNo = serviceNo; | |
| 417 | + } | |
| 418 | + | |
| 419 | + public Boolean getSfdc() { | |
| 420 | + return sfdc; | |
| 421 | + } | |
| 422 | + | |
| 423 | + public void setSfdc(Boolean sfdc) { | |
| 424 | + this.sfdc = sfdc; | |
| 425 | + } | |
| 426 | + | |
| 427 | + public Boolean getSfmix() { | |
| 428 | + return sfmix; | |
| 429 | + } | |
| 430 | + | |
| 431 | + public void setSfmix(Boolean sfmix) { | |
| 432 | + this.sfmix = sfmix; | |
| 433 | + } | |
| 434 | + | |
| 435 | + public String getDescriptions() { | |
| 436 | + return descriptions; | |
| 437 | + } | |
| 438 | + | |
| 439 | + public void setDescriptions(String descriptions) { | |
| 440 | + this.descriptions = descriptions; | |
| 441 | + } | |
| 442 | + | |
| 443 | + public String getCarOrdinal() { | |
| 444 | + return carOrdinal; | |
| 445 | + } | |
| 446 | + | |
| 447 | + public void setCarOrdinal(String carOrdinal) { | |
| 448 | + this.carOrdinal = carOrdinal; | |
| 449 | + } | |
| 450 | + | |
| 451 | + public String getVideoCode() { | |
| 452 | + return videoCode; | |
| 453 | + } | |
| 454 | + | |
| 455 | + public void setVideoCode(String videoCode) { | |
| 456 | + this.videoCode = videoCode; | |
| 457 | + } | |
| 458 | + | |
| 459 | + public Boolean getScrapState() { | |
| 460 | + return scrapState; | |
| 461 | + } | |
| 462 | + | |
| 463 | + public void setScrapState(Boolean scrapState) { | |
| 464 | + this.scrapState = scrapState; | |
| 465 | + } | |
| 466 | + | |
| 467 | + public Integer getIsSwitch() { | |
| 468 | + return isSwitch; | |
| 469 | + } | |
| 470 | + | |
| 471 | + public void setIsSwitch(Integer isSwitch) { | |
| 472 | + this.isSwitch = isSwitch; | |
| 473 | + } | |
| 474 | + | |
| 475 | + public String getXlmc() { | |
| 476 | + return xlmc; | |
| 477 | + } | |
| 478 | + | |
| 479 | + public void setXlmc(String xlmc) { | |
| 480 | + this.xlmc = xlmc; | |
| 481 | + } | |
| 482 | + | |
| 483 | + public Date getCreateDate() { | |
| 484 | + return createDate; | |
| 485 | + } | |
| 486 | + | |
| 487 | + public void setCreateDate(Date createDate) { | |
| 488 | + this.createDate = createDate; | |
| 489 | + } | |
| 490 | + | |
| 491 | + public Date getUpdateDate() { | |
| 492 | + return updateDate; | |
| 493 | + } | |
| 494 | + | |
| 495 | + public void setUpdateDate(Date updateDate) { | |
| 496 | + this.updateDate = updateDate; | |
| 497 | + } | |
| 498 | +} | ... | ... |
src/main/java/com/bsth/control_v3/plan_module/service/data_sync/vehicle/batch/domain/VehicleDataSync.java
0 → 100644
| 1 | +++ a/src/main/java/com/bsth/control_v3/plan_module/service/data_sync/vehicle/batch/domain/VehicleDataSync.java | |
| 1 | +package com.bsth.control_v3.plan_module.service.data_sync.vehicle.batch.domain; | |
| 2 | + | |
| 3 | +import javax.persistence.*; | |
| 4 | +import java.util.Date; | |
| 5 | + | |
| 6 | +/** | |
| 7 | + * 车辆数据同步数据。 | |
| 8 | + */ | |
| 9 | +@Entity | |
| 10 | +@Table(name = "bsth_c_cars_sync") | |
| 11 | +public class VehicleDataSync { | |
| 12 | + /** 主健Id */ | |
| 13 | + @Id | |
| 14 | + @GeneratedValue | |
| 15 | + private Long id; | |
| 16 | + | |
| 17 | + //--------------- 标识车辆的数据(自编号和车牌号) ---------------// | |
| 18 | + /** 自编号/内部编号 */ | |
| 19 | + @Column(nullable = false, length = 20, unique = true) | |
| 20 | + private String idenZbh; | |
| 21 | + /** 车牌号 */ | |
| 22 | + @Column(nullable = false) | |
| 23 | + private String idenCph; | |
| 24 | + | |
| 25 | + //--------------- 更新的数据 ------------// | |
| 26 | + /** 更新 公司代码 */ | |
| 27 | + private String updateGsdm; | |
| 28 | + /** 更新 公司名称 */ | |
| 29 | + private String updateGsmc; | |
| 30 | + | |
| 31 | + // TODO:后续再添加 | |
| 32 | + | |
| 33 | + //--------------- 时间,状态数据 ------------// | |
| 34 | + /** 创建时间 */ | |
| 35 | + @Column(nullable = false) | |
| 36 | + private Date createDate; | |
| 37 | + /** 更新时间 */ | |
| 38 | + @Column(nullable = false) | |
| 39 | + private Date updateDate; | |
| 40 | + /** 同步状态 */ | |
| 41 | + @Column(nullable = false) | |
| 42 | + @Convert(converter = VehicleDataSyncStatusEnumConverter.class) | |
| 43 | + private VehicleDataSyncStatusEnum status; | |
| 44 | + | |
| 45 | + public Long getId() { | |
| 46 | + return id; | |
| 47 | + } | |
| 48 | + | |
| 49 | + public void setId(Long id) { | |
| 50 | + this.id = id; | |
| 51 | + } | |
| 52 | + | |
| 53 | + public String getIdenZbh() { | |
| 54 | + return idenZbh; | |
| 55 | + } | |
| 56 | + | |
| 57 | + public void setIdenZbh(String idenZbh) { | |
| 58 | + this.idenZbh = idenZbh; | |
| 59 | + } | |
| 60 | + | |
| 61 | + public String getIdenCph() { | |
| 62 | + return idenCph; | |
| 63 | + } | |
| 64 | + | |
| 65 | + public void setIdenCph(String idenCph) { | |
| 66 | + this.idenCph = idenCph; | |
| 67 | + } | |
| 68 | + | |
| 69 | + public String getUpdateGsdm() { | |
| 70 | + return updateGsdm; | |
| 71 | + } | |
| 72 | + | |
| 73 | + public void setUpdateGsdm(String updateGsdm) { | |
| 74 | + this.updateGsdm = updateGsdm; | |
| 75 | + } | |
| 76 | + | |
| 77 | + public String getUpdateGsmc() { | |
| 78 | + return updateGsmc; | |
| 79 | + } | |
| 80 | + | |
| 81 | + public void setUpdateGsmc(String updateGsmc) { | |
| 82 | + this.updateGsmc = updateGsmc; | |
| 83 | + } | |
| 84 | + | |
| 85 | + public Date getCreateDate() { | |
| 86 | + return createDate; | |
| 87 | + } | |
| 88 | + | |
| 89 | + public void setCreateDate(Date createDate) { | |
| 90 | + this.createDate = createDate; | |
| 91 | + } | |
| 92 | + | |
| 93 | + public Date getUpdateDate() { | |
| 94 | + return updateDate; | |
| 95 | + } | |
| 96 | + | |
| 97 | + public void setUpdateDate(Date updateDate) { | |
| 98 | + this.updateDate = updateDate; | |
| 99 | + } | |
| 100 | + | |
| 101 | + public VehicleDataSyncStatusEnum getStatus() { | |
| 102 | + return status; | |
| 103 | + } | |
| 104 | + | |
| 105 | + public void setStatus(VehicleDataSyncStatusEnum status) { | |
| 106 | + this.status = status; | |
| 107 | + } | |
| 108 | +} | |
| 0 | 109 | \ No newline at end of file | ... | ... |
src/main/java/com/bsth/control_v3/plan_module/service/data_sync/vehicle/batch/domain/VehicleDataSyncStat.java
0 → 100644
| 1 | +++ a/src/main/java/com/bsth/control_v3/plan_module/service/data_sync/vehicle/batch/domain/VehicleDataSyncStat.java | |
| 1 | +package com.bsth.control_v3.plan_module.service.data_sync.vehicle.batch.domain; | |
| 2 | + | |
| 3 | +import javax.persistence.*; | |
| 4 | +import java.util.Date; | |
| 5 | + | |
| 6 | +/** | |
| 7 | + * 车辆数据同步数据统计。 | |
| 8 | + */ | |
| 9 | +@Entity | |
| 10 | +@Table(name = "bsth_c_cars_sync_stat") | |
| 11 | +public class VehicleDataSyncStat { | |
| 12 | + /** 主健Id */ | |
| 13 | + @Id | |
| 14 | + @GeneratedValue | |
| 15 | + private Long id; | |
| 16 | + | |
| 17 | + /** job实例Id */ | |
| 18 | + @Column(nullable = false) | |
| 19 | + private Long jobId; | |
| 20 | + /** job名字 */ | |
| 21 | + @Column(nullable = false) | |
| 22 | + private String jobName; | |
| 23 | + /** job执行Id */ | |
| 24 | + @Column(nullable = false, unique = true) | |
| 25 | + private Long jobExecutionId; | |
| 26 | + | |
| 27 | + /** 待同步的车辆数据ids(同步状态=SYNCING) */ | |
| 28 | + @Column(length = 2000) | |
| 29 | + private String syncDataPrepareIds; | |
| 30 | + /** 待同步的车辆数据自编号s(同步状态=SYNCING) */ | |
| 31 | + @Column(length = 2000) | |
| 32 | + private String syncDataPrepareZbhs; | |
| 33 | + | |
| 34 | + /** 待同步的车辆count */ | |
| 35 | + private Integer syncDataPrepareCount; | |
| 36 | + /** 同步成功的车辆count */ | |
| 37 | + private Integer syncDataSuccessCount; | |
| 38 | + | |
| 39 | + /** 退出step执行Id */ | |
| 40 | + private Long exitStepExecutionId; | |
| 41 | + /** 退出异常stack信息 */ | |
| 42 | + @Column(length = 2500) | |
| 43 | + private String exitStackTrace; | |
| 44 | + | |
| 45 | + /** 同步状态 */ | |
| 46 | + @Column(nullable = false) | |
| 47 | + @Convert(converter = VehicleDataSyncStatusEnumConverter.class) | |
| 48 | + private VehicleDataSyncStatusEnum status; | |
| 49 | + | |
| 50 | + /** job执行开始时间 */ | |
| 51 | + @Column(nullable = false) | |
| 52 | + private Date startDate; | |
| 53 | + /** job执行结束时间 */ | |
| 54 | + private Date endDate; | |
| 55 | + | |
| 56 | + public Long getId() { | |
| 57 | + return id; | |
| 58 | + } | |
| 59 | + | |
| 60 | + public void setId(Long id) { | |
| 61 | + this.id = id; | |
| 62 | + } | |
| 63 | + | |
| 64 | + public Long getJobId() { | |
| 65 | + return jobId; | |
| 66 | + } | |
| 67 | + | |
| 68 | + public void setJobId(Long jobId) { | |
| 69 | + this.jobId = jobId; | |
| 70 | + } | |
| 71 | + | |
| 72 | + public String getJobName() { | |
| 73 | + return jobName; | |
| 74 | + } | |
| 75 | + | |
| 76 | + public void setJobName(String jobName) { | |
| 77 | + this.jobName = jobName; | |
| 78 | + } | |
| 79 | + | |
| 80 | + public Long getJobExecutionId() { | |
| 81 | + return jobExecutionId; | |
| 82 | + } | |
| 83 | + | |
| 84 | + public void setJobExecutionId(Long jobExecutionId) { | |
| 85 | + this.jobExecutionId = jobExecutionId; | |
| 86 | + } | |
| 87 | + | |
| 88 | + public String getSyncDataPrepareIds() { | |
| 89 | + return syncDataPrepareIds; | |
| 90 | + } | |
| 91 | + | |
| 92 | + public void setSyncDataPrepareIds(String syncDataPrepareIds) { | |
| 93 | + this.syncDataPrepareIds = syncDataPrepareIds; | |
| 94 | + } | |
| 95 | + | |
| 96 | + public String getSyncDataPrepareZbhs() { | |
| 97 | + return syncDataPrepareZbhs; | |
| 98 | + } | |
| 99 | + | |
| 100 | + public void setSyncDataPrepareZbhs(String syncDataPrepareZbhs) { | |
| 101 | + this.syncDataPrepareZbhs = syncDataPrepareZbhs; | |
| 102 | + } | |
| 103 | + | |
| 104 | + public Integer getSyncDataPrepareCount() { | |
| 105 | + return syncDataPrepareCount; | |
| 106 | + } | |
| 107 | + | |
| 108 | + public void setSyncDataPrepareCount(Integer syncDataPrepareCount) { | |
| 109 | + this.syncDataPrepareCount = syncDataPrepareCount; | |
| 110 | + } | |
| 111 | + | |
| 112 | + public Integer getSyncDataSuccessCount() { | |
| 113 | + return syncDataSuccessCount; | |
| 114 | + } | |
| 115 | + | |
| 116 | + public void setSyncDataSuccessCount(Integer syncDataSuccessCount) { | |
| 117 | + this.syncDataSuccessCount = syncDataSuccessCount; | |
| 118 | + } | |
| 119 | + | |
| 120 | + public Long getExitStepExecutionId() { | |
| 121 | + return exitStepExecutionId; | |
| 122 | + } | |
| 123 | + | |
| 124 | + public void setExitStepExecutionId(Long exitStepExecutionId) { | |
| 125 | + this.exitStepExecutionId = exitStepExecutionId; | |
| 126 | + } | |
| 127 | + | |
| 128 | + public String getExitStackTrace() { | |
| 129 | + return exitStackTrace; | |
| 130 | + } | |
| 131 | + | |
| 132 | + public void setExitStackTrace(String exitStackTrace) { | |
| 133 | + this.exitStackTrace = exitStackTrace; | |
| 134 | + } | |
| 135 | + | |
| 136 | + public VehicleDataSyncStatusEnum getStatus() { | |
| 137 | + return status; | |
| 138 | + } | |
| 139 | + | |
| 140 | + public void setStatus(VehicleDataSyncStatusEnum status) { | |
| 141 | + this.status = status; | |
| 142 | + } | |
| 143 | + | |
| 144 | + public Date getStartDate() { | |
| 145 | + return startDate; | |
| 146 | + } | |
| 147 | + | |
| 148 | + public void setStartDate(Date startDate) { | |
| 149 | + this.startDate = startDate; | |
| 150 | + } | |
| 151 | + | |
| 152 | + public Date getEndDate() { | |
| 153 | + return endDate; | |
| 154 | + } | |
| 155 | + | |
| 156 | + public void setEndDate(Date endDate) { | |
| 157 | + this.endDate = endDate; | |
| 158 | + } | |
| 159 | +} | ... | ... |
src/main/java/com/bsth/control_v3/plan_module/service/data_sync/vehicle/batch/domain/VehicleDataSyncStatusEnum.java
0 → 100644
| 1 | +++ a/src/main/java/com/bsth/control_v3/plan_module/service/data_sync/vehicle/batch/domain/VehicleDataSyncStatusEnum.java | |
| 1 | +package com.bsth.control_v3.plan_module.service.data_sync.vehicle.batch.domain; | |
| 2 | + | |
| 3 | +import com.fasterxml.jackson.annotation.JsonCreator; | |
| 4 | +import com.fasterxml.jackson.annotation.JsonValue; | |
| 5 | +import org.springframework.util.StringUtils; | |
| 6 | + | |
| 7 | +import java.util.HashMap; | |
| 8 | +import java.util.Map; | |
| 9 | + | |
| 10 | +/** | |
| 11 | + * 车辆数据同步状态enum。 | |
| 12 | + */ | |
| 13 | +public enum VehicleDataSyncStatusEnum { | |
| 14 | + PREPARE("准备"), | |
| 15 | + SYNCING("同步中"), | |
| 16 | + SUCCESS("成功"), | |
| 17 | + FAILURE("失败"); | |
| 18 | + | |
| 19 | + public static Map<String, VehicleDataSyncStatusEnum> enumMap = | |
| 20 | + new HashMap<String, VehicleDataSyncStatusEnum>() {{ | |
| 21 | + put("准备", PREPARE); | |
| 22 | + put("同步中", SYNCING); | |
| 23 | + put("成功", SUCCESS); | |
| 24 | + put("失败", FAILURE); | |
| 25 | + }}; | |
| 26 | + | |
| 27 | + /** 字典描述(对应数据库的字典) */ | |
| 28 | + private String dicDesc; | |
| 29 | + | |
| 30 | + @JsonCreator | |
| 31 | + VehicleDataSyncStatusEnum(String dicDesc) { | |
| 32 | + this.dicDesc = dicDesc; | |
| 33 | + } | |
| 34 | + | |
| 35 | + public static VehicleDataSyncStatusEnum fromDicDesc(String dicDesc) { | |
| 36 | + if (StringUtils.isEmpty(dicDesc)) { | |
| 37 | + throw new RuntimeException("车辆数据同步状态描述不能为空!"); | |
| 38 | + } else if (enumMap.get(dicDesc) == null) { | |
| 39 | + throw new RuntimeException("车辆数据同步状态未定义:" + dicDesc); | |
| 40 | + } | |
| 41 | + return enumMap.get(dicDesc); | |
| 42 | + } | |
| 43 | + | |
| 44 | + @JsonValue | |
| 45 | + public String getDicDesc() { | |
| 46 | + return dicDesc; | |
| 47 | + } | |
| 48 | + | |
| 49 | + public void setDicDesc(String dicDesc) { | |
| 50 | + this.dicDesc = dicDesc; | |
| 51 | + } | |
| 52 | + | |
| 53 | + @Override | |
| 54 | + public String toString() { | |
| 55 | + return dicDesc; | |
| 56 | + } | |
| 57 | +} | ... | ... |
src/main/java/com/bsth/control_v3/plan_module/service/data_sync/vehicle/batch/domain/VehicleDataSyncStatusEnumConverter.java
0 → 100644
| 1 | +++ a/src/main/java/com/bsth/control_v3/plan_module/service/data_sync/vehicle/batch/domain/VehicleDataSyncStatusEnumConverter.java | |
| 1 | +package com.bsth.control_v3.plan_module.service.data_sync.vehicle.batch.domain; | |
| 2 | + | |
| 3 | +import javax.persistence.AttributeConverter; | |
| 4 | +import javax.persistence.Convert; | |
| 5 | + | |
| 6 | +@Convert | |
| 7 | +public class VehicleDataSyncStatusEnumConverter implements AttributeConverter<VehicleDataSyncStatusEnum, String> { | |
| 8 | + @Override | |
| 9 | + public String convertToDatabaseColumn(VehicleDataSyncStatusEnum vehicleDataSyncStatusEnum) { | |
| 10 | + return vehicleDataSyncStatusEnum.getDicDesc(); | |
| 11 | + } | |
| 12 | + | |
| 13 | + @Override | |
| 14 | + public VehicleDataSyncStatusEnum convertToEntityAttribute(String s) { | |
| 15 | + return VehicleDataSyncStatusEnum.fromDicDesc(s); | |
| 16 | + } | |
| 17 | +} | ... | ... |
src/main/java/com/bsth/control_v3/plan_module/service/data_sync/vehicle/batch/repo/VehicleDataRepo.java
0 → 100644
| 1 | +++ a/src/main/java/com/bsth/control_v3/plan_module/service/data_sync/vehicle/batch/repo/VehicleDataRepo.java | |
| 1 | +package com.bsth.control_v3.plan_module.service.data_sync.vehicle.batch.repo; | |
| 2 | + | |
| 3 | +import com.bsth.control_v3.plan_module.service.data_sync.vehicle.batch.domain.VehicleData; | |
| 4 | +import org.springframework.data.jpa.repository.JpaRepository; | |
| 5 | +import org.springframework.stereotype.Repository; | |
| 6 | + | |
| 7 | +@Repository | |
| 8 | +public interface VehicleDataRepo extends JpaRepository<VehicleData, Integer> { | |
| 9 | + VehicleData findByInsideCodeAndCarPlate(String insideCode, String carPlate); | |
| 10 | +} | ... | ... |
src/main/java/com/bsth/control_v3/plan_module/service/data_sync/vehicle/batch/repo/VehicleDataSyncRepo.java
0 → 100644
| 1 | +++ a/src/main/java/com/bsth/control_v3/plan_module/service/data_sync/vehicle/batch/repo/VehicleDataSyncRepo.java | |
| 1 | +package com.bsth.control_v3.plan_module.service.data_sync.vehicle.batch.repo; | |
| 2 | + | |
| 3 | +import com.bsth.control_v3.plan_module.service.data_sync.vehicle.batch.domain.VehicleDataSync; | |
| 4 | +import com.bsth.control_v3.plan_module.service.data_sync.vehicle.batch.domain.VehicleDataSyncStatusEnum; | |
| 5 | +import org.springframework.data.domain.Page; | |
| 6 | +import org.springframework.data.domain.Pageable; | |
| 7 | +import org.springframework.data.jpa.repository.JpaRepository; | |
| 8 | +import org.springframework.stereotype.Repository; | |
| 9 | + | |
| 10 | +@Repository | |
| 11 | +public interface VehicleDataSyncRepo extends JpaRepository<VehicleDataSync, Long> { | |
| 12 | + Page<VehicleDataSync> findByStatus(VehicleDataSyncStatusEnum status, Pageable pageRequest); | |
| 13 | + long countByStatus(VehicleDataSyncStatusEnum status); | |
| 14 | +} | ... | ... |
src/main/java/com/bsth/control_v3/plan_module/service/data_sync/vehicle/batch/repo/VehicleDataSyncStatRepo.java
0 → 100644
| 1 | +++ a/src/main/java/com/bsth/control_v3/plan_module/service/data_sync/vehicle/batch/repo/VehicleDataSyncStatRepo.java | |
| 1 | +package com.bsth.control_v3.plan_module.service.data_sync.vehicle.batch.repo; | |
| 2 | + | |
| 3 | +import com.bsth.control_v3.plan_module.service.data_sync.vehicle.batch.domain.VehicleDataSyncStat; | |
| 4 | +import org.springframework.data.jpa.repository.JpaRepository; | |
| 5 | +import org.springframework.stereotype.Repository; | |
| 6 | + | |
| 7 | +@Repository | |
| 8 | +public interface VehicleDataSyncStatRepo extends JpaRepository<VehicleDataSyncStat, Long> { | |
| 9 | + VehicleDataSyncStat findByJobExecutionId(Long id); | |
| 10 | +} | ... | ... |
src/main/java/com/bsth/control_v3/plan_module/service/data_sync/vehicle/batch/service/listener/JobStatListener.java
0 → 100644
| 1 | +++ a/src/main/java/com/bsth/control_v3/plan_module/service/data_sync/vehicle/batch/service/listener/JobStatListener.java | |
| 1 | +package com.bsth.control_v3.plan_module.service.data_sync.vehicle.batch.service.listener; | |
| 2 | + | |
| 3 | +import com.bsth.control_v3.plan_module.service.data_sync.vehicle.batch.domain.VehicleDataSyncStat; | |
| 4 | +import com.bsth.control_v3.plan_module.service.data_sync.vehicle.batch.domain.VehicleDataSyncStatusEnum; | |
| 5 | +import com.bsth.control_v3.plan_module.service.data_sync.vehicle.batch.repo.VehicleDataSyncStatRepo; | |
| 6 | +import org.springframework.batch.core.JobExecution; | |
| 7 | +import org.springframework.batch.core.JobExecutionListener; | |
| 8 | +import org.springframework.beans.factory.annotation.Autowired; | |
| 9 | +import org.springframework.stereotype.Service; | |
| 10 | +import org.springframework.transaction.annotation.Isolation; | |
| 11 | +import org.springframework.transaction.annotation.Propagation; | |
| 12 | +import org.springframework.transaction.annotation.Transactional; | |
| 13 | + | |
| 14 | +import java.util.Date; | |
| 15 | + | |
| 16 | +@Service | |
| 17 | +@Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.READ_COMMITTED) | |
| 18 | +public class JobStatListener implements JobExecutionListener { | |
| 19 | + @Autowired | |
| 20 | + private VehicleDataSyncStatRepo vehicleDataSyncStatRepo; | |
| 21 | + | |
| 22 | + @Override | |
| 23 | + public void beforeJob(JobExecution jobExecution) { | |
| 24 | + VehicleDataSyncStat vehicleDataSyncStat = new VehicleDataSyncStat(); | |
| 25 | + vehicleDataSyncStat.setJobId(jobExecution.getJobId()); | |
| 26 | + vehicleDataSyncStat.setJobName(jobExecution.getJobInstance().getJobName()); | |
| 27 | + vehicleDataSyncStat.setJobExecutionId(jobExecution.getId()); | |
| 28 | + | |
| 29 | + vehicleDataSyncStat.setStatus(VehicleDataSyncStatusEnum.SYNCING); | |
| 30 | + vehicleDataSyncStat.setStartDate(new Date()); | |
| 31 | + | |
| 32 | + vehicleDataSyncStatRepo.save(vehicleDataSyncStat); | |
| 33 | + } | |
| 34 | + | |
| 35 | + @Override | |
| 36 | + public void afterJob(JobExecution jobExecution) { | |
| 37 | + VehicleDataSyncStat vehicleDataSyncStat = | |
| 38 | + this.vehicleDataSyncStatRepo.findByJobExecutionId(jobExecution.getId()); | |
| 39 | + if (jobExecution.getStatus().isUnsuccessful()) { | |
| 40 | + vehicleDataSyncStat.setStatus(VehicleDataSyncStatusEnum.FAILURE); | |
| 41 | + } else { | |
| 42 | + vehicleDataSyncStat.setStatus(VehicleDataSyncStatusEnum.SUCCESS); | |
| 43 | + } | |
| 44 | + vehicleDataSyncStat.setEndDate(new Date()); | |
| 45 | + } | |
| 46 | +} | ... | ... |
src/main/java/com/bsth/control_v3/plan_module/service/data_sync/vehicle/batch/service/listener/PrepareStepProcessStatListener.java
0 → 100644
| 1 | +++ a/src/main/java/com/bsth/control_v3/plan_module/service/data_sync/vehicle/batch/service/listener/PrepareStepProcessStatListener.java | |
| 1 | +package com.bsth.control_v3.plan_module.service.data_sync.vehicle.batch.service.listener; | |
| 2 | + | |
| 3 | +import com.bsth.control_v3.plan_module.service.data_sync.vehicle.batch.domain.VehicleDataSync; | |
| 4 | +import com.bsth.control_v3.plan_module.service.data_sync.vehicle.batch.domain.VehicleDataSyncStat; | |
| 5 | +import com.bsth.control_v3.plan_module.service.data_sync.vehicle.batch.repo.VehicleDataSyncStatRepo; | |
| 6 | +import org.springframework.batch.core.ItemProcessListener; | |
| 7 | +import org.springframework.batch.core.StepExecution; | |
| 8 | +import org.springframework.batch.core.configuration.annotation.StepScope; | |
| 9 | +import org.springframework.beans.factory.annotation.Autowired; | |
| 10 | +import org.springframework.beans.factory.annotation.Value; | |
| 11 | +import org.springframework.stereotype.Service; | |
| 12 | +import org.springframework.transaction.annotation.Isolation; | |
| 13 | +import org.springframework.transaction.annotation.Propagation; | |
| 14 | +import org.springframework.transaction.annotation.Transactional; | |
| 15 | + | |
| 16 | +import java.util.Arrays; | |
| 17 | + | |
| 18 | +@StepScope | |
| 19 | +@Service | |
| 20 | +@Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.READ_COMMITTED) | |
| 21 | +public class PrepareStepProcessStatListener implements ItemProcessListener<VehicleDataSync, VehicleDataSync> { | |
| 22 | + @Value("#{stepExecution}") | |
| 23 | + private StepExecution stepExecution; | |
| 24 | + @Autowired | |
| 25 | + private VehicleDataSyncStatRepo vehicleDataSyncStatRepo; | |
| 26 | + | |
| 27 | + @Override | |
| 28 | + public void beforeProcess(VehicleDataSync item) { | |
| 29 | + | |
| 30 | + } | |
| 31 | + | |
| 32 | + @Override | |
| 33 | + public void afterProcess(VehicleDataSync item, VehicleDataSync result) { | |
| 34 | + | |
| 35 | + } | |
| 36 | + | |
| 37 | + @Override | |
| 38 | + public void onProcessError(VehicleDataSync item, Exception ex) { | |
| 39 | + VehicleDataSyncStat vehicleDataSyncStat = this.vehicleDataSyncStatRepo.findByJobExecutionId( | |
| 40 | + stepExecution.getJobExecutionId() | |
| 41 | + ); | |
| 42 | + vehicleDataSyncStat.setExitStepExecutionId(stepExecution.getId()); | |
| 43 | + vehicleDataSyncStat.setExitStackTrace(Arrays.asList(ex.getStackTrace()).toString()); | |
| 44 | + } | |
| 45 | +} | ... | ... |
src/main/java/com/bsth/control_v3/plan_module/service/data_sync/vehicle/batch/service/listener/PrepareStepReadStatListener.java
0 → 100644
| 1 | +++ a/src/main/java/com/bsth/control_v3/plan_module/service/data_sync/vehicle/batch/service/listener/PrepareStepReadStatListener.java | |
| 1 | +package com.bsth.control_v3.plan_module.service.data_sync.vehicle.batch.service.listener; | |
| 2 | + | |
| 3 | +import com.bsth.control_v3.plan_module.service.data_sync.vehicle.batch.domain.VehicleDataSync; | |
| 4 | +import com.bsth.control_v3.plan_module.service.data_sync.vehicle.batch.domain.VehicleDataSyncStat; | |
| 5 | +import com.bsth.control_v3.plan_module.service.data_sync.vehicle.batch.repo.VehicleDataSyncStatRepo; | |
| 6 | +import org.springframework.batch.core.ItemReadListener; | |
| 7 | +import org.springframework.batch.core.StepExecution; | |
| 8 | +import org.springframework.batch.core.configuration.annotation.StepScope; | |
| 9 | +import org.springframework.beans.factory.annotation.Autowired; | |
| 10 | +import org.springframework.beans.factory.annotation.Value; | |
| 11 | +import org.springframework.stereotype.Service; | |
| 12 | +import org.springframework.transaction.annotation.Isolation; | |
| 13 | +import org.springframework.transaction.annotation.Propagation; | |
| 14 | +import org.springframework.transaction.annotation.Transactional; | |
| 15 | + | |
| 16 | +import java.util.Arrays; | |
| 17 | + | |
| 18 | +@StepScope | |
| 19 | +@Service | |
| 20 | +@Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.READ_COMMITTED) | |
| 21 | +public class PrepareStepReadStatListener implements ItemReadListener<VehicleDataSync> { | |
| 22 | + @Value("#{stepExecution}") | |
| 23 | + private StepExecution stepExecution; | |
| 24 | + @Autowired | |
| 25 | + private VehicleDataSyncStatRepo vehicleDataSyncStatRepo; | |
| 26 | + | |
| 27 | + @Override | |
| 28 | + public void beforeRead() { | |
| 29 | + | |
| 30 | + } | |
| 31 | + | |
| 32 | + @Override | |
| 33 | + public void afterRead(VehicleDataSync item) { | |
| 34 | + | |
| 35 | + } | |
| 36 | + | |
| 37 | + @Override | |
| 38 | + public void onReadError(Exception ex) { | |
| 39 | + VehicleDataSyncStat vehicleDataSyncStat = this.vehicleDataSyncStatRepo.findByJobExecutionId( | |
| 40 | + stepExecution.getJobExecutionId() | |
| 41 | + ); | |
| 42 | + vehicleDataSyncStat.setExitStepExecutionId(stepExecution.getId()); | |
| 43 | + vehicleDataSyncStat.setExitStackTrace(Arrays.asList(ex.getStackTrace()).toString()); | |
| 44 | + } | |
| 45 | +} | ... | ... |
src/main/java/com/bsth/control_v3/plan_module/service/data_sync/vehicle/batch/service/listener/PrepareStepWriteStatListener.java
0 → 100644
| 1 | +++ a/src/main/java/com/bsth/control_v3/plan_module/service/data_sync/vehicle/batch/service/listener/PrepareStepWriteStatListener.java | |
| 1 | +package com.bsth.control_v3.plan_module.service.data_sync.vehicle.batch.service.listener; | |
| 2 | + | |
| 3 | +import com.bsth.control_v3.plan_module.service.data_sync.vehicle.batch.domain.VehicleDataSync; | |
| 4 | +import com.bsth.control_v3.plan_module.service.data_sync.vehicle.batch.domain.VehicleDataSyncStat; | |
| 5 | +import com.bsth.control_v3.plan_module.service.data_sync.vehicle.batch.repo.VehicleDataSyncStatRepo; | |
| 6 | +import org.springframework.batch.core.ItemWriteListener; | |
| 7 | +import org.springframework.batch.core.StepExecution; | |
| 8 | +import org.springframework.batch.core.configuration.annotation.StepScope; | |
| 9 | +import org.springframework.beans.factory.annotation.Autowired; | |
| 10 | +import org.springframework.beans.factory.annotation.Value; | |
| 11 | +import org.springframework.stereotype.Service; | |
| 12 | +import org.springframework.transaction.annotation.Isolation; | |
| 13 | +import org.springframework.transaction.annotation.Propagation; | |
| 14 | +import org.springframework.transaction.annotation.Transactional; | |
| 15 | +import org.springframework.util.CollectionUtils; | |
| 16 | +import org.springframework.util.StringUtils; | |
| 17 | + | |
| 18 | +import java.util.ArrayList; | |
| 19 | +import java.util.Arrays; | |
| 20 | +import java.util.List; | |
| 21 | + | |
| 22 | +@StepScope | |
| 23 | +@Service | |
| 24 | +@Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.READ_COMMITTED) | |
| 25 | +public class PrepareStepWriteStatListener implements ItemWriteListener<VehicleDataSync> { | |
| 26 | + @Value("#{stepExecution}") | |
| 27 | + private StepExecution stepExecution; | |
| 28 | + @Autowired | |
| 29 | + private VehicleDataSyncStatRepo vehicleDataSyncStatRepo; | |
| 30 | + | |
| 31 | + @Override | |
| 32 | + public void beforeWrite(List<? extends VehicleDataSync> items) { | |
| 33 | + | |
| 34 | + } | |
| 35 | + | |
| 36 | + @Override | |
| 37 | + public void afterWrite(List<? extends VehicleDataSync> items) { | |
| 38 | + if (!CollectionUtils.isEmpty(items)) { | |
| 39 | + List<String> ids = new ArrayList<>(); | |
| 40 | + List<String> zbhs = new ArrayList<>(); | |
| 41 | + VehicleDataSyncStat vehicleDataSyncStat = this.vehicleDataSyncStatRepo.findByJobExecutionId( | |
| 42 | + stepExecution.getJobExecutionId() | |
| 43 | + ); | |
| 44 | + | |
| 45 | + if (!StringUtils.isEmpty(vehicleDataSyncStat.getSyncDataPrepareIds())) { | |
| 46 | + ids.addAll(Arrays.asList(vehicleDataSyncStat.getSyncDataPrepareIds().split(","))); | |
| 47 | + } | |
| 48 | + if (!StringUtils.isEmpty(vehicleDataSyncStat.getSyncDataPrepareZbhs())) { | |
| 49 | + zbhs.addAll(Arrays.asList(vehicleDataSyncStat.getSyncDataPrepareZbhs().split(","))); | |
| 50 | + } | |
| 51 | + | |
| 52 | + for (VehicleDataSync item : items) { | |
| 53 | + ids.add(item.getId().toString()); | |
| 54 | + zbhs.add(item.getIdenZbh()); | |
| 55 | + } | |
| 56 | + | |
| 57 | + vehicleDataSyncStat.setSyncDataPrepareIds(String.join(",", ids)); | |
| 58 | + vehicleDataSyncStat.setSyncDataPrepareZbhs(String.join(",", zbhs)); | |
| 59 | + | |
| 60 | + // 更新数量 | |
| 61 | + if (vehicleDataSyncStat.getSyncDataPrepareCount() == null) { | |
| 62 | + vehicleDataSyncStat.setSyncDataPrepareCount(items.size()); | |
| 63 | + } else { | |
| 64 | + vehicleDataSyncStat.setSyncDataPrepareCount( | |
| 65 | + vehicleDataSyncStat.getSyncDataPrepareCount() + items.size()); | |
| 66 | + } | |
| 67 | + } | |
| 68 | + } | |
| 69 | + | |
| 70 | + @Override | |
| 71 | + public void onWriteError(Exception ex, List<? extends VehicleDataSync> items) { | |
| 72 | + VehicleDataSyncStat vehicleDataSyncStat = this.vehicleDataSyncStatRepo.findByJobExecutionId( | |
| 73 | + stepExecution.getJobExecutionId() | |
| 74 | + ); | |
| 75 | + vehicleDataSyncStat.setExitStepExecutionId(stepExecution.getId()); | |
| 76 | + vehicleDataSyncStat.setExitStackTrace(Arrays.asList(ex.getStackTrace()).toString()); | |
| 77 | + } | |
| 78 | +} | ... | ... |
src/main/java/com/bsth/control_v3/plan_module/service/data_sync/vehicle/batch/service/listener/SyncStepProcessStatListener.java
0 → 100644
| 1 | +++ a/src/main/java/com/bsth/control_v3/plan_module/service/data_sync/vehicle/batch/service/listener/SyncStepProcessStatListener.java | |
| 1 | +package com.bsth.control_v3.plan_module.service.data_sync.vehicle.batch.service.listener; | |
| 2 | + | |
| 3 | +import com.bsth.control_v3.plan_module.service.data_sync.vehicle.batch.domain.VehicleData; | |
| 4 | +import com.bsth.control_v3.plan_module.service.data_sync.vehicle.batch.domain.VehicleDataSync; | |
| 5 | +import com.bsth.control_v3.plan_module.service.data_sync.vehicle.batch.domain.VehicleDataSyncStat; | |
| 6 | +import com.bsth.control_v3.plan_module.service.data_sync.vehicle.batch.repo.VehicleDataSyncStatRepo; | |
| 7 | +import org.springframework.batch.core.ItemProcessListener; | |
| 8 | +import org.springframework.batch.core.StepExecution; | |
| 9 | +import org.springframework.batch.core.configuration.annotation.StepScope; | |
| 10 | +import org.springframework.beans.factory.annotation.Autowired; | |
| 11 | +import org.springframework.beans.factory.annotation.Value; | |
| 12 | +import org.springframework.stereotype.Service; | |
| 13 | +import org.springframework.transaction.annotation.Isolation; | |
| 14 | +import org.springframework.transaction.annotation.Propagation; | |
| 15 | +import org.springframework.transaction.annotation.Transactional; | |
| 16 | + | |
| 17 | +import java.util.Arrays; | |
| 18 | + | |
| 19 | +@StepScope | |
| 20 | +@Service | |
| 21 | +@Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.READ_COMMITTED) | |
| 22 | +public class SyncStepProcessStatListener implements ItemProcessListener<VehicleDataSync, VehicleData> { | |
| 23 | + @Value("#{stepExecution}") | |
| 24 | + private StepExecution stepExecution; | |
| 25 | + @Autowired | |
| 26 | + private VehicleDataSyncStatRepo vehicleDataSyncStatRepo; | |
| 27 | + | |
| 28 | + @Override | |
| 29 | + public void beforeProcess(VehicleDataSync item) { | |
| 30 | + | |
| 31 | + } | |
| 32 | + | |
| 33 | + @Override | |
| 34 | + public void afterProcess(VehicleDataSync item, VehicleData result) { | |
| 35 | + | |
| 36 | + } | |
| 37 | + | |
| 38 | + @Override | |
| 39 | + public void onProcessError(VehicleDataSync item, Exception ex) { | |
| 40 | + VehicleDataSyncStat vehicleDataSyncStat = this.vehicleDataSyncStatRepo.findByJobExecutionId( | |
| 41 | + stepExecution.getJobExecutionId() | |
| 42 | + ); | |
| 43 | + vehicleDataSyncStat.setExitStepExecutionId(stepExecution.getId()); | |
| 44 | + vehicleDataSyncStat.setExitStackTrace(Arrays.asList(ex.getStackTrace()).toString()); | |
| 45 | + } | |
| 46 | +} | ... | ... |
src/main/java/com/bsth/control_v3/plan_module/service/data_sync/vehicle/batch/service/listener/SyncStepReadStatListener.java
0 → 100644
| 1 | +++ a/src/main/java/com/bsth/control_v3/plan_module/service/data_sync/vehicle/batch/service/listener/SyncStepReadStatListener.java | |
| 1 | +package com.bsth.control_v3.plan_module.service.data_sync.vehicle.batch.service.listener; | |
| 2 | + | |
| 3 | +import com.bsth.control_v3.plan_module.service.data_sync.vehicle.batch.domain.VehicleDataSync; | |
| 4 | +import com.bsth.control_v3.plan_module.service.data_sync.vehicle.batch.domain.VehicleDataSyncStat; | |
| 5 | +import com.bsth.control_v3.plan_module.service.data_sync.vehicle.batch.repo.VehicleDataSyncStatRepo; | |
| 6 | +import org.springframework.batch.core.ItemReadListener; | |
| 7 | +import org.springframework.batch.core.StepExecution; | |
| 8 | +import org.springframework.batch.core.configuration.annotation.StepScope; | |
| 9 | +import org.springframework.beans.factory.annotation.Autowired; | |
| 10 | +import org.springframework.beans.factory.annotation.Value; | |
| 11 | +import org.springframework.stereotype.Service; | |
| 12 | +import org.springframework.transaction.annotation.Isolation; | |
| 13 | +import org.springframework.transaction.annotation.Propagation; | |
| 14 | +import org.springframework.transaction.annotation.Transactional; | |
| 15 | + | |
| 16 | +import java.util.Arrays; | |
| 17 | + | |
| 18 | +@StepScope | |
| 19 | +@Service | |
| 20 | +@Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.READ_COMMITTED) | |
| 21 | +public class SyncStepReadStatListener implements ItemReadListener<VehicleDataSync> { | |
| 22 | + @Value("#{stepExecution}") | |
| 23 | + private StepExecution stepExecution; | |
| 24 | + @Autowired | |
| 25 | + private VehicleDataSyncStatRepo vehicleDataSyncStatRepo; | |
| 26 | + | |
| 27 | + @Override | |
| 28 | + public void beforeRead() { | |
| 29 | + | |
| 30 | + } | |
| 31 | + | |
| 32 | + @Override | |
| 33 | + public void afterRead(VehicleDataSync item) { | |
| 34 | + | |
| 35 | + } | |
| 36 | + | |
| 37 | + @Override | |
| 38 | + public void onReadError(Exception ex) { | |
| 39 | + VehicleDataSyncStat vehicleDataSyncStat = this.vehicleDataSyncStatRepo.findByJobExecutionId( | |
| 40 | + stepExecution.getJobExecutionId() | |
| 41 | + ); | |
| 42 | + vehicleDataSyncStat.setExitStepExecutionId(stepExecution.getId()); | |
| 43 | + vehicleDataSyncStat.setExitStackTrace(Arrays.asList(ex.getStackTrace()).toString()); | |
| 44 | + } | |
| 45 | +} | ... | ... |
src/main/java/com/bsth/control_v3/plan_module/service/data_sync/vehicle/batch/service/listener/SyncStepWriteStatListener.java
0 → 100644
| 1 | +++ a/src/main/java/com/bsth/control_v3/plan_module/service/data_sync/vehicle/batch/service/listener/SyncStepWriteStatListener.java | |
| 1 | +package com.bsth.control_v3.plan_module.service.data_sync.vehicle.batch.service.listener; | |
| 2 | + | |
| 3 | +import com.bsth.control_v3.plan_module.service.data_sync.vehicle.batch.domain.VehicleData; | |
| 4 | +import com.bsth.control_v3.plan_module.service.data_sync.vehicle.batch.domain.VehicleDataSyncStat; | |
| 5 | +import com.bsth.control_v3.plan_module.service.data_sync.vehicle.batch.repo.VehicleDataSyncStatRepo; | |
| 6 | +import org.springframework.batch.core.ItemWriteListener; | |
| 7 | +import org.springframework.batch.core.StepExecution; | |
| 8 | +import org.springframework.batch.core.configuration.annotation.StepScope; | |
| 9 | +import org.springframework.beans.factory.annotation.Autowired; | |
| 10 | +import org.springframework.beans.factory.annotation.Value; | |
| 11 | +import org.springframework.stereotype.Service; | |
| 12 | +import org.springframework.transaction.annotation.Isolation; | |
| 13 | +import org.springframework.transaction.annotation.Propagation; | |
| 14 | +import org.springframework.transaction.annotation.Transactional; | |
| 15 | +import org.springframework.util.CollectionUtils; | |
| 16 | + | |
| 17 | +import java.util.Arrays; | |
| 18 | +import java.util.List; | |
| 19 | + | |
| 20 | +@StepScope | |
| 21 | +@Service | |
| 22 | +@Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.READ_COMMITTED) | |
| 23 | +public class SyncStepWriteStatListener implements ItemWriteListener<VehicleData> { | |
| 24 | + @Value("#{stepExecution}") | |
| 25 | + private StepExecution stepExecution; | |
| 26 | + @Autowired | |
| 27 | + private VehicleDataSyncStatRepo vehicleDataSyncStatRepo; | |
| 28 | + | |
| 29 | + @Override | |
| 30 | + public void beforeWrite(List<? extends VehicleData> items) { | |
| 31 | + | |
| 32 | + } | |
| 33 | + | |
| 34 | + @Override | |
| 35 | + public void afterWrite(List<? extends VehicleData> items) { | |
| 36 | + if (!CollectionUtils.isEmpty(items)) { | |
| 37 | + VehicleDataSyncStat vehicleDataSyncStat = this.vehicleDataSyncStatRepo.findByJobExecutionId( | |
| 38 | + stepExecution.getJobExecutionId() | |
| 39 | + ); | |
| 40 | + // 更新数量 | |
| 41 | + if (vehicleDataSyncStat.getSyncDataSuccessCount() == null) { | |
| 42 | + vehicleDataSyncStat.setSyncDataSuccessCount(items.size()); | |
| 43 | + } else { | |
| 44 | + vehicleDataSyncStat.setSyncDataSuccessCount( | |
| 45 | + vehicleDataSyncStat.getSyncDataSuccessCount() + items.size() | |
| 46 | + ); | |
| 47 | + } | |
| 48 | + } | |
| 49 | + } | |
| 50 | + | |
| 51 | + @Override | |
| 52 | + public void onWriteError(Exception ex, List<? extends VehicleData> items) { | |
| 53 | + VehicleDataSyncStat vehicleDataSyncStat = this.vehicleDataSyncStatRepo.findByJobExecutionId( | |
| 54 | + stepExecution.getJobExecutionId() | |
| 55 | + ); | |
| 56 | + vehicleDataSyncStat.setExitStepExecutionId(stepExecution.getId()); | |
| 57 | + vehicleDataSyncStat.setExitStackTrace(Arrays.asList(ex.getStackTrace()).toString()); | |
| 58 | + } | |
| 59 | +} | ... | ... |
src/main/java/com/bsth/control_v3/plan_module/service/data_sync/vehicle/batch/service/process/PrepareStepDataProcessor.java
0 → 100644
| 1 | +++ a/src/main/java/com/bsth/control_v3/plan_module/service/data_sync/vehicle/batch/service/process/PrepareStepDataProcessor.java | |
| 1 | +package com.bsth.control_v3.plan_module.service.data_sync.vehicle.batch.service.process; | |
| 2 | + | |
| 3 | +import com.bsth.control_v3.plan_module.service.data_sync.vehicle.batch.domain.VehicleDataSync; | |
| 4 | +import com.bsth.control_v3.plan_module.service.data_sync.vehicle.batch.domain.VehicleDataSyncStatusEnum; | |
| 5 | +import org.springframework.batch.core.configuration.annotation.StepScope; | |
| 6 | +import org.springframework.batch.item.ItemProcessor; | |
| 7 | +import org.springframework.stereotype.Service; | |
| 8 | +import org.springframework.transaction.annotation.Isolation; | |
| 9 | +import org.springframework.transaction.annotation.Propagation; | |
| 10 | +import org.springframework.transaction.annotation.Transactional; | |
| 11 | + | |
| 12 | +import java.util.Date; | |
| 13 | + | |
| 14 | +@StepScope | |
| 15 | +@Service | |
| 16 | +@Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.READ_COMMITTED) | |
| 17 | +public class PrepareStepDataProcessor implements ItemProcessor<VehicleDataSync, VehicleDataSync> { | |
| 18 | + @Override | |
| 19 | + public VehicleDataSync process(VehicleDataSync item) throws Exception { | |
| 20 | + if (item.getStatus() == VehicleDataSyncStatusEnum.PREPARE) { | |
| 21 | + item.setStatus(VehicleDataSyncStatusEnum.SYNCING); | |
| 22 | + item.setUpdateDate(new Date()); | |
| 23 | + return item; | |
| 24 | + } else { | |
| 25 | + // 过滤状态不为 PREPARE 的记录 | |
| 26 | + return null; | |
| 27 | + } | |
| 28 | + } | |
| 29 | +} | ... | ... |
src/main/java/com/bsth/control_v3/plan_module/service/data_sync/vehicle/batch/service/process/SyncStepDataProcessor.java
0 → 100644
| 1 | +++ a/src/main/java/com/bsth/control_v3/plan_module/service/data_sync/vehicle/batch/service/process/SyncStepDataProcessor.java | |
| 1 | +package com.bsth.control_v3.plan_module.service.data_sync.vehicle.batch.service.process; | |
| 2 | + | |
| 3 | +import com.bsth.control_v3.plan_module.service.data_sync.vehicle.batch.domain.VehicleData; | |
| 4 | +import com.bsth.control_v3.plan_module.service.data_sync.vehicle.batch.domain.VehicleDataSync; | |
| 5 | +import com.bsth.control_v3.plan_module.service.data_sync.vehicle.batch.domain.VehicleDataSyncStatusEnum; | |
| 6 | +import com.bsth.control_v3.plan_module.service.data_sync.vehicle.batch.repo.VehicleDataRepo; | |
| 7 | +import org.springframework.batch.core.configuration.annotation.StepScope; | |
| 8 | +import org.springframework.batch.item.ItemProcessor; | |
| 9 | +import org.springframework.beans.factory.annotation.Autowired; | |
| 10 | +import org.springframework.stereotype.Service; | |
| 11 | +import org.springframework.transaction.annotation.Isolation; | |
| 12 | +import org.springframework.transaction.annotation.Propagation; | |
| 13 | +import org.springframework.transaction.annotation.Transactional; | |
| 14 | + | |
| 15 | +import java.util.Date; | |
| 16 | + | |
| 17 | +@StepScope | |
| 18 | +@Service | |
| 19 | +@Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.READ_COMMITTED) | |
| 20 | +public class SyncStepDataProcessor implements ItemProcessor<VehicleDataSync, VehicleData> { | |
| 21 | + @Autowired | |
| 22 | + private VehicleDataRepo vehicleDataRepo; | |
| 23 | + | |
| 24 | + @Override | |
| 25 | + public VehicleData process(VehicleDataSync item) throws Exception { | |
| 26 | + if (item.getStatus() == VehicleDataSyncStatusEnum.SYNCING) { | |
| 27 | + // 1、查找车辆信息 | |
| 28 | + VehicleData vehicleData = this.vehicleDataRepo.findByInsideCodeAndCarPlate( | |
| 29 | + item.getIdenZbh(), item.getIdenCph() | |
| 30 | + ); | |
| 31 | + | |
| 32 | + // 2、判断是否找到,没有重新创建,有更新update相关字段 | |
| 33 | + if (vehicleData == null) { | |
| 34 | + vehicleData = new VehicleData(); | |
| 35 | + // 标识用字段 | |
| 36 | + vehicleData.setInsideCode(item.getIdenZbh()); // 自编号 | |
| 37 | + vehicleData.setCarPlate(item.getIdenCph()); // 车牌号 | |
| 38 | + | |
| 39 | + // TODO:后面添加其他的非空字段 | |
| 40 | + vehicleData.setBusinessCode(item.getUpdateGsdm()); // 公司代码 | |
| 41 | + vehicleData.setCompany(item.getUpdateGsmc()); // 公司名称 | |
| 42 | + vehicleData.setCarCode(item.getIdenZbh()); // 车辆编码(初始使用自编号代替) | |
| 43 | + vehicleData.setSupplierName("1"); // 供应商名称(字典:1=巴士拓华) | |
| 44 | + vehicleData.setEquipmentCode(item.getIdenZbh()); // 设备编号(初始使用自编号代替) | |
| 45 | + vehicleData.setCreateDate(new Date()); // 创建时间 | |
| 46 | + | |
| 47 | + } else { | |
| 48 | + // TODO:后面添加其他更新字段 | |
| 49 | + vehicleData.setBusinessCode(item.getUpdateGsdm()); | |
| 50 | + vehicleData.setCompany(item.getUpdateGsmc()); | |
| 51 | + } | |
| 52 | + | |
| 53 | + // 3、更新车辆同步数据字段 | |
| 54 | + item.setStatus(VehicleDataSyncStatusEnum.SUCCESS); | |
| 55 | + item.setUpdateDate(new Date()); | |
| 56 | + | |
| 57 | + return vehicleData; | |
| 58 | + } else { | |
| 59 | + // 过滤状态不为 SYNCING 的记录 | |
| 60 | + return null; | |
| 61 | + } | |
| 62 | + } | |
| 63 | +} | ... | ... |
src/main/java/com/bsth/control_v3/plan_module/service/data_sync/vehicle/facade/VehicleDataSyncFacadeConfig.java
0 → 100644
| 1 | +++ a/src/main/java/com/bsth/control_v3/plan_module/service/data_sync/vehicle/facade/VehicleDataSyncFacadeConfig.java | |
| 1 | +package com.bsth.control_v3.plan_module.service.data_sync.vehicle.facade; | |
| 2 | + | |
| 3 | +/** | |
| 4 | + * TODO:车辆数据同步facade相关配置。 | |
| 5 | + */ | |
| 6 | +public class VehicleDataSyncFacadeConfig { | |
| 7 | + // TODO: | |
| 8 | +} | ... | ... |
src/main/resources/application-active_dev.properties
0 → 100644
src/main/resources/application-active_prod.properties
0 → 100644
src/main/resources/application-include_batch.properties
0 → 100644
| 1 | +++ a/src/main/resources/application-include_batch.properties | |
| 1 | +#----------------- spring batch profile 配置 ----------------# | |
| 2 | +# BatchAutoConfiguration中的配置,false,关闭自动启动所有job,手动启动,默认为true | |
| 3 | +spring.batch.job.enabled=false | |
| 4 | +# 创建batch相关schema | |
| 5 | +spring.batch.initialize-schema=always | |
| 0 | 6 | \ No newline at end of file | ... | ... |
src/main/resources/application-include_db.properties
0 → 100644
| 1 | +++ a/src/main/resources/application-include_db.properties | |
| 1 | +#----------------- database profile 配置 ----------------# | |
| 2 | +# 数据源配置 | |
| 3 | +spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver | |
| 4 | +# serverTimezone参数解决数据库时区不一致的问题 | |
| 5 | +spring.datasource.url=jdbc:mysql://127.0.0.1/spring_batch_test?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=GMT%2B8 | |
| 6 | +spring.datasource.username=root | |
| 7 | +spring.datasource.password= | |
| 8 | + | |
| 9 | + | ... | ... |
src/main/resources/application-include_ds.properties
0 → 100644
src/main/resources/application-include_jpa.properties
0 → 100644
| 1 | +++ a/src/main/resources/application-include_jpa.properties | |
| 1 | +#------------- jpa profile ---------------# | |
| 2 | +# core数据源jpa配置 | |
| 3 | +# dialect | |
| 4 | +spring.jpa.database= MYSQL | |
| 5 | +# 是否显示sql,格式化sql | |
| 6 | +#spring.jpa.core.show-sql= false | |
| 7 | +spring.jpa.properties.hibernate.show_sql= false | |
| 8 | +spring.jpa.properties.hibernate.format_sql= false | |
| 9 | +# ddl schema是否更新 | |
| 10 | +#spring.jpa.core.hibernate.ddl-auto= none (自定义多数据源,这种写法没作用,使用下面的属性) | |
| 11 | +spring.jpa.properties.hibernate.hbm2ddl.auto= none | |
| 12 | +# hibernate5的命名策略 | |
| 13 | +spring.jpa.properties.hibernate.implicit_naming_strategy= org.springframework.boot.orm.jpa.hibernate.SpringImplicitNamingStrategy | |
| 14 | +spring.jpa.properties.hibernate.physical_naming_strategy= org.springframework.boot.orm.jpa.hibernate.SpringPhysicalNamingStrategy | |
| 15 | + | |
| 16 | + | |
| 17 | +spring.jpa.database-platform=com.bsth.control_v3.plan_module.service.data_sync.vehicle.batch.MySQL5InnoDBDialectExt | |
| 18 | + | ... | ... |
src/main/resources/application.properties
0 → 100644
| 1 | +++ a/src/main/resources/application.properties | |
| 1 | +#------------------ main profile 主配置 ----------------# | |
| 2 | +# 启动的profile | |
| 3 | +spring.profiles.active=active_dev | |
| 4 | +# 包含的profile | |
| 5 | +spring.profiles.include=include_jpa,include_db,include_ds,include_batch | |
| 6 | + | |
| 7 | +# application名字 | |
| 8 | +spring.application.name=plan_module-service-data_sync | |
| 9 | + | ... | ... |
src/main/resources/logback.xml
0 → 100644
| 1 | +++ a/src/main/resources/logback.xml | |
| 1 | +<?xml version="1.0" encoding="UTF-8" ?> | |
| 2 | +<!-- scan="true" 当此属性设置为true时,配置文件如果发生改变,将会被重新加载,默认值为true。 --> | |
| 3 | +<!-- scanPeriod="30 seconds" 设置每30秒自动扫描,若没有指定具体单位则以milliseconds为标准(单位:milliseconds, seconds, minutes or hours) --> | |
| 4 | +<!-- debug="false"当此属性设置为true时,将打印出logback内部日志信息,实时查看logback运行状态。默认值为false。--> | |
| 5 | +<configuration scan="true" scanPeriod="30 seconds"> | |
| 6 | + <!-- 控制台输出 --> | |
| 7 | + <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> | |
| 8 | + <encoder> | |
| 9 | + <!--格式化输出:%d表示日期,%thread表示线程名,%-5level:级别从左显示5个字符宽度%msg:日志消息,%n是换行符 --> | |
| 10 | + <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] [%file:%line] %-5level-%msg%n</pattern> | |
| 11 | + </encoder> | |
| 12 | + </appender> | |
| 13 | + | |
| 14 | + <!-- 日志输出级别 --> | |
| 15 | + <root level="INFO"> | |
| 16 | + <appender-ref ref="STDOUT" /> | |
| 17 | + </root> | |
| 18 | + | |
| 19 | + <logger name="com.bsth.control_mini.service.dvr.service.process.handler.impl" | |
| 20 | + level="DEBUG" additivity="false"> | |
| 21 | + <appender-ref ref="STDOUT" /> | |
| 22 | + </logger> | |
| 23 | + | |
| 24 | +</configuration> | |
| 0 | 25 | \ No newline at end of file | ... | ... |
src/test/java/com/bsth/control_v3/plan_module/service/data_sync/PlanModuleServiceDataSyncTestApplication.java
0 → 100644
| 1 | +++ a/src/test/java/com/bsth/control_v3/plan_module/service/data_sync/PlanModuleServiceDataSyncTestApplication.java | |
| 1 | +package com.bsth.control_v3.plan_module.service.data_sync; | |
| 2 | + | |
| 3 | +import org.springframework.boot.CommandLineRunner; | |
| 4 | +import org.springframework.boot.SpringApplication; | |
| 5 | +import org.springframework.boot.autoconfigure.SpringBootApplication; | |
| 6 | +import org.springframework.context.annotation.ComponentScan; | |
| 7 | +import org.springframework.context.annotation.FilterType; | |
| 8 | +import org.springframework.transaction.annotation.EnableTransactionManagement; | |
| 9 | + | |
| 10 | +@EnableTransactionManagement | |
| 11 | +@SpringBootApplication | |
| 12 | +@ComponentScan(excludeFilters = { | |
| 13 | + @ComponentScan.Filter( | |
| 14 | + type = FilterType.ASSIGNABLE_TYPE, | |
| 15 | + value = { | |
| 16 | + PlanModuleServiceDataSyncApplication.class | |
| 17 | + } | |
| 18 | + ) | |
| 19 | +}) | |
| 20 | +public class PlanModuleServiceDataSyncTestApplication implements CommandLineRunner { | |
| 21 | + @Override | |
| 22 | + public void run(String... args) throws Exception { | |
| 23 | + // TODO:其他初始化代码 | |
| 24 | + | |
| 25 | + } | |
| 26 | + | |
| 27 | + public static void main(String[] args) throws Exception { | |
| 28 | + SpringApplication.run(PlanModuleServiceDataSyncTestApplication.class, args); | |
| 29 | + } | |
| 30 | +} | ... | ... |
src/test/java/com/bsth/control_v3/plan_module/service/data_sync/base/BaseTest.java
0 → 100644
| 1 | +++ a/src/test/java/com/bsth/control_v3/plan_module/service/data_sync/base/BaseTest.java | |
| 1 | +package com.bsth.control_v3.plan_module.service.data_sync.base; | |
| 2 | + | |
| 3 | +import ch.qos.logback.classic.LoggerContext; | |
| 4 | +import ch.qos.logback.classic.joran.JoranConfigurator; | |
| 5 | +import ch.qos.logback.core.util.StatusPrinter; | |
| 6 | +import org.dbunit.database.DatabaseConfig; | |
| 7 | +import org.dbunit.database.DatabaseConnection; | |
| 8 | +import org.dbunit.database.DatabaseSequenceFilter; | |
| 9 | +import org.dbunit.database.IDatabaseConnection; | |
| 10 | +import org.dbunit.dataset.FilteredDataSet; | |
| 11 | +import org.dbunit.dataset.IDataSet; | |
| 12 | +import org.dbunit.dataset.xml.FlatXmlDataSetBuilder; | |
| 13 | +import org.dbunit.ext.h2.H2DataTypeFactory; | |
| 14 | +import org.dbunit.operation.DatabaseOperation; | |
| 15 | +import org.junit.After; | |
| 16 | +import org.junit.Before; | |
| 17 | +import org.junit.BeforeClass; | |
| 18 | +import org.junit.Rule; | |
| 19 | +import org.junit.rules.TestName; | |
| 20 | +import org.slf4j.Logger; | |
| 21 | +import org.slf4j.LoggerFactory; | |
| 22 | +import org.springframework.core.io.ClassPathResource; | |
| 23 | +import org.springframework.core.io.Resource; | |
| 24 | +import org.springframework.util.StringUtils; | |
| 25 | + | |
| 26 | +import javax.sql.DataSource; | |
| 27 | +import java.io.File; | |
| 28 | +import java.util.Map; | |
| 29 | + | |
| 30 | +/** | |
| 31 | + * 基础测试类。 | |
| 32 | + */ | |
| 33 | +public abstract class BaseTest { | |
| 34 | + /** 日志记录器 */ | |
| 35 | + public static final Logger LOG = LoggerFactory.getLogger(BaseTest.class); | |
| 36 | + | |
| 37 | + @Rule | |
| 38 | + public TestName name = new TestName(); | |
| 39 | + | |
| 40 | + @BeforeClass | |
| 41 | + public static void initLogConfig() throws Exception { | |
| 42 | + File logFile = new File(BaseTest.class.getResource("/logback.xml").toURI()); | |
| 43 | + LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory(); | |
| 44 | + JoranConfigurator configurator = new JoranConfigurator(); | |
| 45 | + configurator.setContext(lc); | |
| 46 | + lc.reset(); | |
| 47 | + configurator.doConfigure(logFile); | |
| 48 | + StatusPrinter.printInCaseOfErrorsOrWarnings(lc); | |
| 49 | + } | |
| 50 | + | |
| 51 | + /** | |
| 52 | + * 获取DBUnit数据源。 | |
| 53 | + * @return | |
| 54 | + */ | |
| 55 | + private IDataSet getDataSet() throws Exception { | |
| 56 | + Map<String, String> dbFileMap = getDbunitTestDbFileClassPathMap(); | |
| 57 | + String dbunitClassPath = dbFileMap.get(name.getMethodName()); | |
| 58 | + if (StringUtils.isEmpty(dbunitClassPath)) { | |
| 59 | + LOG.info("dbunit测试xml为空,key={}", name.getMethodName()); | |
| 60 | + } | |
| 61 | + Resource res = new ClassPathResource(dbunitClassPath); | |
| 62 | + FlatXmlDataSetBuilder builder = new FlatXmlDataSetBuilder(); | |
| 63 | + builder.setColumnSensing(true); | |
| 64 | + return builder.build(res.getInputStream()); | |
| 65 | + } | |
| 66 | + | |
| 67 | + /** | |
| 68 | + * 获取数据库连接。 | |
| 69 | + * @return | |
| 70 | + */ | |
| 71 | + private IDatabaseConnection getConnection() throws Exception { | |
| 72 | + DatabaseConnection conn = new DatabaseConnection(getDataSource().getConnection()); | |
| 73 | + DatabaseConfig config = conn.getConfig(); | |
| 74 | + config.setProperty(DatabaseConfig.PROPERTY_DATATYPE_FACTORY, new H2DataTypeFactory()); | |
| 75 | + return conn; | |
| 76 | + } | |
| 77 | + | |
| 78 | + /** | |
| 79 | + * 初始化数据。 | |
| 80 | + * @throws Exception | |
| 81 | + */ | |
| 82 | + @Before | |
| 83 | + public void initDbunitDataSet() throws Exception { | |
| 84 | + LOG.info(name.getMethodName()); | |
| 85 | + LOG.info("junit setup:dbunit-载入测试数据!===>"); | |
| 86 | + IDatabaseConnection connection = getConnection(); | |
| 87 | + DatabaseOperation.CLEAN_INSERT.execute(connection, getDataSet()); | |
| 88 | + connection.close(); | |
| 89 | + } | |
| 90 | + | |
| 91 | + /** | |
| 92 | + * 销毁测试数据。 | |
| 93 | + * @throws Exception | |
| 94 | + */ | |
| 95 | + @After | |
| 96 | + public void afterDbunitDataSet() throws Exception { | |
| 97 | + LOG.info("===>junit teardown:dbunit-销毁测试数据!"); | |
| 98 | + IDatabaseConnection connection = getConnection(); | |
| 99 | + // 使用FilteredDataSet重新定义数据库,否则删除的时候会发生外健依赖错误 | |
| 100 | + // 因为默认删除是按照表名字母顺序删除的,如果外健关联的表先删除,则发生外健约束错误 | |
| 101 | + IDataSet fullDataSet = new FilteredDataSet(new DatabaseSequenceFilter(connection), connection.createDataSet()); | |
| 102 | + DatabaseOperation.DELETE_ALL.execute(getConnection(), fullDataSet); | |
| 103 | + connection.close(); | |
| 104 | + } | |
| 105 | + | |
| 106 | + /** | |
| 107 | + * 获取Dbunit测试数据文件xml映射,key=测试方法名,value=dbunit测试文件classpath | |
| 108 | + * key:子类testCase方法名 | |
| 109 | + * value:dbunit数据文件classpath(如:db/testdata/dbunit_testdata1.xml) | |
| 110 | + * @return | |
| 111 | + */ | |
| 112 | + public abstract Map<String, String> getDbunitTestDbFileClassPathMap(); | |
| 113 | + | |
| 114 | + /** | |
| 115 | + * 获取数据源。 | |
| 116 | + * @return | |
| 117 | + */ | |
| 118 | + public abstract DataSource getDataSource(); | |
| 119 | +} | ... | ... |
src/test/java/com/bsth/control_v3/plan_module/service/data_sync/batch/TestJob.java
0 → 100644
| 1 | +++ a/src/test/java/com/bsth/control_v3/plan_module/service/data_sync/batch/TestJob.java | |
| 1 | +package com.bsth.control_v3.plan_module.service.data_sync.batch; | |
| 2 | + | |
| 3 | +import com.bsth.control_v3.plan_module.service.data_sync.PlanModuleServiceDataSyncTestApplication; | |
| 4 | +import com.bsth.control_v3.plan_module.service.data_sync.base.BaseTest; | |
| 5 | +import com.bsth.control_v3.plan_module.service.data_sync.vehicle.batch.domain.VehicleData; | |
| 6 | +import com.bsth.control_v3.plan_module.service.data_sync.vehicle.batch.domain.VehicleDataSync; | |
| 7 | +import com.bsth.control_v3.plan_module.service.data_sync.vehicle.batch.domain.VehicleDataSyncStat; | |
| 8 | +import com.bsth.control_v3.plan_module.service.data_sync.vehicle.batch.domain.VehicleDataSyncStatusEnum; | |
| 9 | +import com.bsth.control_v3.plan_module.service.data_sync.vehicle.batch.repo.VehicleDataRepo; | |
| 10 | +import com.bsth.control_v3.plan_module.service.data_sync.vehicle.batch.repo.VehicleDataSyncRepo; | |
| 11 | +import com.bsth.control_v3.plan_module.service.data_sync.vehicle.batch.repo.VehicleDataSyncStatRepo; | |
| 12 | +import org.junit.Assert; | |
| 13 | +import org.junit.Test; | |
| 14 | +import org.junit.runner.RunWith; | |
| 15 | +import org.springframework.batch.core.Job; | |
| 16 | +import org.springframework.batch.core.JobParameters; | |
| 17 | +import org.springframework.batch.core.launch.JobLauncher; | |
| 18 | +import org.springframework.batch.test.context.SpringBatchTest; | |
| 19 | +import org.springframework.beans.factory.annotation.Autowired; | |
| 20 | +import org.springframework.beans.factory.annotation.Qualifier; | |
| 21 | +import org.springframework.boot.test.context.SpringBootTest; | |
| 22 | +import org.springframework.test.context.junit4.SpringRunner; | |
| 23 | + | |
| 24 | +import javax.sql.DataSource; | |
| 25 | +import java.util.HashMap; | |
| 26 | +import java.util.Map; | |
| 27 | + | |
| 28 | +@RunWith(SpringRunner.class) | |
| 29 | +@SpringBatchTest | |
| 30 | +@SpringBootTest(classes = {PlanModuleServiceDataSyncTestApplication.class}) | |
| 31 | +public class TestJob extends BaseTest { | |
| 32 | + @Autowired | |
| 33 | + private DataSource dataSource; | |
| 34 | + | |
| 35 | + @Override | |
| 36 | + public DataSource getDataSource() { | |
| 37 | + return dataSource; | |
| 38 | + } | |
| 39 | + | |
| 40 | + @Override | |
| 41 | + public Map<String, String> getDbunitTestDbFileClassPathMap() { | |
| 42 | + Map<String, String> dbFileMap = new HashMap<>(); | |
| 43 | + dbFileMap.put("case1", "testdata/dbunit_vehicle_case1.xml"); | |
| 44 | + return dbFileMap; | |
| 45 | + } | |
| 46 | + | |
| 47 | + | |
| 48 | + /** | |
| 49 | + * JobLauncherTestUtils在当前spring context下如果有多个Job,会报错因为内部是@Autowired注入 | |
| 50 | + * 所以,如果要正常使用JobLauncherTestUtils,请在上下文中只有一个Job配置,这需要@SpringBootTest配合 | |
| 51 | + * 因为这里是每个Test都是系统全部启动注入的,上下文会存在多个Job配置,以后考虑部分注入配合@SpringBootTest | |
| 52 | + */ | |
| 53 | +// @Autowired | |
| 54 | +// private JobLauncherTestUtils jobLauncherTestUtils; | |
| 55 | + | |
| 56 | + @Autowired | |
| 57 | + private JobLauncher jobLauncher; | |
| 58 | + @Autowired | |
| 59 | + @Qualifier("vehicleDataSyncJob") | |
| 60 | + private Job vehicleDataSyncJob; | |
| 61 | + | |
| 62 | + @Autowired | |
| 63 | + private VehicleDataRepo vehicleDataRepo; | |
| 64 | + @Autowired | |
| 65 | + private VehicleDataSyncRepo vehicleDataSyncDomainRepo; | |
| 66 | + @Autowired | |
| 67 | + private VehicleDataSyncStatRepo vehicleDataSyncStatRepo; | |
| 68 | + | |
| 69 | + @Test | |
| 70 | + public void case1() throws Exception { | |
| 71 | + LOG.info("TestJob case1测试"); | |
| 72 | + | |
| 73 | + // 验证车辆数据 | |
| 74 | + VehicleData vehicleData = this.vehicleDataRepo.findById(1).get(); | |
| 75 | + Assert.assertNotNull("车辆数据id=1为空!", vehicleData); | |
| 76 | + | |
| 77 | + // 验证车辆同步数据 | |
| 78 | + VehicleDataSync vehicleDataSyncDomain = this.vehicleDataSyncDomainRepo.findById(1L).get(); | |
| 79 | + Assert.assertNotNull("车辆同步数据id=1为空!", vehicleDataSyncDomain); | |
| 80 | + Assert.assertArrayEquals( | |
| 81 | + "车辆同步数据id=1字段值不一致!", | |
| 82 | + new Object[] {VehicleDataSyncStatusEnum.PREPARE}, | |
| 83 | + new Object[] {vehicleDataSyncDomain.getStatus()}); | |
| 84 | + | |
| 85 | + // 启动job | |
| 86 | + this.jobLauncher.run(vehicleDataSyncJob, new JobParameters()); | |
| 87 | + | |
| 88 | + // 验证同步后,车辆数据 | |
| 89 | + vehicleData = this.vehicleDataRepo.findById(1).get(); | |
| 90 | + Assert.assertNotNull("车辆数据id=1为空!", vehicleData); | |
| 91 | + Assert.assertArrayEquals( | |
| 92 | + "同步后,车辆id=1数据字段值不一致", | |
| 93 | + new Object[] {"05", "杨高公司"}, | |
| 94 | + new Object[] {vehicleData.getBusinessCode(), vehicleData.getCompany()}); | |
| 95 | + | |
| 96 | + // 验证同步后,车辆同步数据 | |
| 97 | + vehicleDataSyncDomain = this.vehicleDataSyncDomainRepo.findById(1L).get(); | |
| 98 | + Assert.assertNotNull("车辆同步数据id=1为空!", vehicleDataSyncDomain); | |
| 99 | + Assert.assertArrayEquals( | |
| 100 | + "同步后,车辆同步数据id=1字段值不一致!", | |
| 101 | + new Object[] {VehicleDataSyncStatusEnum.SUCCESS}, | |
| 102 | + new Object[] {vehicleDataSyncDomain.getStatus()}); | |
| 103 | + | |
| 104 | + // 验证同步后,车辆同步数据stat | |
| 105 | + VehicleDataSyncStat vehicleDataSyncStat = this.vehicleDataSyncStatRepo.findById(1L).get(); | |
| 106 | + Assert.assertNotNull("车辆同步数据stat id=1为空!", vehicleDataSyncStat); | |
| 107 | + Assert.assertArrayEquals( | |
| 108 | + "同步后,车辆同步数据stat id=1字段值不一致!", | |
| 109 | + new Object[] { | |
| 110 | + "1", | |
| 111 | + "SSS-01", | |
| 112 | + 1, | |
| 113 | + 1, | |
| 114 | + true, | |
| 115 | + true, | |
| 116 | + VehicleDataSyncStatusEnum.SUCCESS, | |
| 117 | + true | |
| 118 | + }, | |
| 119 | + new Object[] { | |
| 120 | + vehicleDataSyncStat.getSyncDataPrepareIds(), | |
| 121 | + vehicleDataSyncStat.getSyncDataPrepareZbhs(), | |
| 122 | + vehicleDataSyncStat.getSyncDataPrepareCount(), | |
| 123 | + vehicleDataSyncStat.getSyncDataSuccessCount(), | |
| 124 | + vehicleDataSyncStat.getExitStepExecutionId() == null, | |
| 125 | + vehicleDataSyncStat.getExitStackTrace() == null, | |
| 126 | + vehicleDataSyncStat.getStatus(), | |
| 127 | + vehicleDataSyncStat.getEndDate() != null | |
| 128 | + }); | |
| 129 | + | |
| 130 | + } | |
| 131 | + | |
| 132 | + | |
| 133 | +} | ... | ... |
src/test/resources/application-test.properties
0 → 100644
| 1 | +++ a/src/test/resources/application-test.properties | |
| 1 | +# jpa配置 | |
| 2 | +spring.jpa.database= H2 | |
| 3 | +spring.jpa.properties.hibernate.show_sql= true | |
| 4 | +spring.jpa.properties.hibernate.hbm2ddl.auto = update | |
| 5 | +spring.jpa.properties.hibernate.format_sql= true | |
| 6 | + | |
| 7 | +# db配置 | |
| 8 | +spring.datasource.driver-class-name=org.h2.Driver | |
| 9 | +# h2 v1.4.200 不支持 mvcc了去除 | |
| 10 | +# spring.datasource.url=jdbc:h2:mem:core;DB_CLOSE_DELAY=1000;MVCC=TRUE;LOCK_TIMEOUT=10000 | |
| 11 | +spring.datasource.url=jdbc:h2:mem:core;DB_CLOSE_DELAY=1000;LOCK_TIMEOUT=10000 | |
| 12 | +spring.datasource.username=sa | |
| 13 | +spring.datasource.password= | |
| 14 | + | |
| 15 | +# ds配置 | ... | ... |
src/test/resources/application.properties
0 → 100644
| 1 | +++ a/src/test/resources/application.properties | |
| 1 | +#------------------ main profile 主配置 ----------------# | |
| 2 | +# 启动的profile | |
| 3 | +spring.profiles.active=test | |
| 4 | +# 包含的profile | |
| 5 | +spring.profiles.include=include_jpa,include_db,include_ds,include_batch | |
| 6 | + | |
| 7 | +# application名字 | |
| 8 | +spring.application.name=dvr | |
| 9 | + | ... | ... |
src/test/resources/logback.xml
0 → 100644
| 1 | +++ a/src/test/resources/logback.xml | |
| 1 | +<?xml version="1.0" encoding="UTF-8" ?> | |
| 2 | +<!-- scan="true" 当此属性设置为true时,配置文件如果发生改变,将会被重新加载,默认值为true。 --> | |
| 3 | +<!-- scanPeriod="30 seconds" 设置每30秒自动扫描,若没有指定具体单位则以milliseconds为标准(单位:milliseconds, seconds, minutes or hours) --> | |
| 4 | +<!-- debug="false"当此属性设置为true时,将打印出logback内部日志信息,实时查看logback运行状态。默认值为false。--> | |
| 5 | +<configuration scan="true" scanPeriod="30 seconds"> | |
| 6 | + <!-- 控制台输出 --> | |
| 7 | + <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> | |
| 8 | + <encoder> | |
| 9 | + <!--格式化输出:%d表示日期,%thread表示线程名,%-5level:级别从左显示5个字符宽度%msg:日志消息,%n是换行符 --> | |
| 10 | + <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] [%file:%line] %-5level-%msg%n</pattern> | |
| 11 | + </encoder> | |
| 12 | + </appender> | |
| 13 | + | |
| 14 | + <!-- 日志输出级别 --> | |
| 15 | + <root level="INFO"> | |
| 16 | + <appender-ref ref="STDOUT" /> | |
| 17 | + </root> | |
| 18 | + | |
| 19 | + <logger name="com.bsth.control_mini.service.dvr.service.process.handler.impl" | |
| 20 | + level="DEBUG" additivity="false"> | |
| 21 | + <appender-ref ref="STDOUT" /> | |
| 22 | + </logger> | |
| 23 | + | |
| 24 | +</configuration> | |
| 0 | 25 | \ No newline at end of file | ... | ... |
src/test/resources/testdata/dbunit_vehicle_case1.xml
0 → 100644
| 1 | +++ a/src/test/resources/testdata/dbunit_vehicle_case1.xml | |
| 1 | +<?xml version='1.0' encoding='UTF-8'?> | |
| 2 | +<dataset> | |
| 3 | + <!-- 车辆基础信息 --> | |
| 4 | + <bsth_c_cars id="1" inside_code="SSS-01" | |
| 5 | + business_code="22" company="金高公司" branche_company_code="01" branche_company="一分公司" | |
| 6 | + car_code="11111" car_plate="沪88888" supplier_name="bsth" equipment_code="123456" | |
| 7 | + hvac_car="1" ticket_type="1" led_screen="1" tv_video_type="1" scrap_state="0" | |
| 8 | + create_date="2020-02-01" | |
| 9 | + /> | |
| 10 | + | |
| 11 | + <!-- 车辆同步数据 --> | |
| 12 | + <bsth_c_cars_sync id="1" iden_zbh="SSS-01" iden_cph="沪88888" | |
| 13 | + update_gsdm="05" update_gsmc="杨高公司" | |
| 14 | + create_date="2020-03-01" update_date="2020-03-01" status="准备" | |
| 15 | + /> | |
| 16 | + | |
| 17 | + | |
| 18 | +</dataset> | |
| 0 | 19 | \ No newline at end of file | ... | ... |
src/test/resources/testdata/dbunit_vehicle_data.xml
0 → 100644
| 1 | +++ a/src/test/resources/testdata/dbunit_vehicle_data.xml | |
| 1 | +<?xml version='1.0' encoding='UTF-8'?> | |
| 2 | +<dataset> | |
| 3 | + <!-- 车辆基础信息 --> | |
| 4 | + <bsth_c_cars id="1" inside_code="SSS-01" | |
| 5 | + business_code="22" company="金高公司" branche_company_code="01" branche_company="一分公司" | |
| 6 | + car_code="11111" car_plate="沪88888" supplier_name="bsth" equipment_code="123456" | |
| 7 | + hvac_car="1" ticket_type="1" led_screen="1" tv_video_type="1" scrap_state="0" /> | |
| 8 | + <bsth_c_cars id="2" inside_code="SSS-02" | |
| 9 | + business_code="22" company="金高公司" branche_company_code="01" branche_company="一分公司" | |
| 10 | + car_code="11111" car_plate="沪88888" supplier_name="bsth" equipment_code="123456" | |
| 11 | + hvac_car="1" ticket_type="1" led_screen="1" tv_video_type="1" scrap_state="0" /> | |
| 12 | + <bsth_c_cars id="3" inside_code="SSS-03" | |
| 13 | + business_code="55" company="南汇公司" branche_company_code="01" branche_company="一分公司" | |
| 14 | + car_code="11111" car_plate="沪88888" supplier_name="bsth" equipment_code="123456" | |
| 15 | + hvac_car="1" ticket_type="1" led_screen="1" tv_video_type="1" scrap_state="0" /> | |
| 16 | + <bsth_c_cars id="4" inside_code="SSS-04" | |
| 17 | + business_code="22" company="金高公司" branche_company_code="02" branche_company="二分公司" | |
| 18 | + car_code="11111" car_plate="沪88888" supplier_name="bsth" equipment_code="123456" | |
| 19 | + hvac_car="1" ticket_type="1" led_screen="1" tv_video_type="1" scrap_state="0" /> | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | +</dataset> | |
| 0 | 26 | \ No newline at end of file | ... | ... |