├── release_note.txt ├── settings.gradle ├── src ├── main │ ├── scripts │ │ ├── bin │ │ │ ├── start.sh │ │ │ └── stop.sh │ │ └── init.sql │ ├── resources │ │ ├── application.properties │ │ ├── filetransfer.properties │ │ ├── datasource.properties │ │ └── reconcile.properties │ └── java │ │ └── com │ │ └── webank │ │ └── blockchain │ │ └── data │ │ └── reconcile │ │ ├── constants │ │ └── ResponseCode.java │ │ ├── message │ │ └── NoticeService.java │ │ ├── reconcile │ │ ├── ReconcileTransfer.java │ │ ├── ReconcileExecutor.java │ │ └── ReconcileExecutorImpl.java │ │ ├── exporter │ │ ├── bc │ │ │ ├── BCDataExportService.java │ │ │ ├── BCDataExportServiceTxtImpl.java │ │ │ └── BCDataExportServiceJsonImpl.java │ │ └── result │ │ │ ├── ResultDataExportService.java │ │ │ ├── ResultDataExportServiceTxtImpl.java │ │ │ └── ResultDataExportServiceJsonImpl.java │ │ ├── handler │ │ ├── Handler.java │ │ ├── InvocationHandler.java │ │ ├── ReconcileHandlerFactory.java │ │ ├── executor │ │ │ ├── ReconcileExecuteHandler.java │ │ │ └── DefaultReconcileExecuteHandler.java │ │ ├── finish │ │ │ ├── ReconcileResultHandler.java │ │ │ └── DefaultReconcileResultHandler.java │ │ ├── filesource │ │ │ ├── ReconcileFileObtainHandler.java │ │ │ └── DefaultReconcileFileObtainHandler.java │ │ └── task │ │ │ └── ReconcileTaskHandler.java │ │ ├── enums │ │ ├── TriggerType.java │ │ └── TaskStatus.java │ │ ├── filetransfer │ │ ├── FileTransferService.java │ │ ├── local │ │ │ └── LocalFileTransferService.java │ │ └── ftp │ │ │ ├── FtpPool.java │ │ │ ├── FtpClientFactory.java │ │ │ └── FtpFileTransferService.java │ │ ├── entity │ │ ├── ReconcileInfo.java │ │ ├── ReconcileResult.java │ │ ├── ReconcileExecuteData.java │ │ ├── Responses.java │ │ └── ReconcileContext.java │ │ ├── config │ │ ├── SystemEnvironmentConfig.java │ │ ├── BeanConfig.java │ │ ├── FTPConfig.java │ │ ├── DBConfig.java │ │ └── ReconcileConfig.java │ │ ├── exception │ │ └── ReconcileException.java │ │ ├── parser │ │ ├── FileParser.java │ │ ├── JsonFileDataParser.java │ │ └── TxtFileDataParser.java │ │ ├── db │ │ ├── entity │ │ │ ├── IdEntity.java │ │ │ └── TaskInfo.java │ │ ├── dao │ │ │ ├── TaskDao.java │ │ │ └── BCInfoDao.java │ │ └── repository │ │ │ └── TaskInfoRepository.java │ │ ├── utils │ │ ├── StringUtils.java │ │ ├── ThreadUtils.java │ │ ├── FileUtils.java │ │ └── BufferedRandomAccessFile.java │ │ ├── BcreconcileApplication.java │ │ ├── task │ │ ├── ReconcileTaskTimer.java │ │ ├── ReconcileTaskService.java │ │ └── TaskCompensateTimer.java │ │ └── controller │ │ └── ReconcileController.java └── test │ └── java │ └── com │ └── webank │ └── blockchain │ └── data │ └── reconcile │ ├── BaseTests.java │ ├── FileTransferTest.java │ ├── FileUtilsTest.java │ ├── ReconcileTaskTest.java │ └── ReconcileExecutorTest.java ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── ChangeLog.md ├── .gitignore ├── README.md ├── gradlew.bat ├── gradlew └── LICENSE /release_note.txt: -------------------------------------------------------------------------------- 1 | v1.0.0 2 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'Data-Reconcile' 2 | -------------------------------------------------------------------------------- /src/main/scripts/bin/start.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | java -jar Data-Reconcile*.jar -------------------------------------------------------------------------------- /src/main/scripts/bin/stop.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | ps -ef|grep Data-Reconcile |grep -v grep| awk '{print $2}'|xargs kill -9 -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WeBankBlockchain/Data-Reconcile/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | system.name=datareconcile 2 | 3 | server.port=8090 4 | #log config 5 | logging.file=logs/data-reconcile.log -------------------------------------------------------------------------------- /ChangeLog.md: -------------------------------------------------------------------------------- 1 | # 更新历史 2 | 3 | #### V1.0.0 4 | - 支持自定义对账数据结构 5 | - 支持自定义对账规则 6 | - 支持多种对账文件格式 7 | - 支持自定义对账任务和方式 8 | - 支持多种对账文件托管方式 9 | - 可定制化开发的对账处理流程 10 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Fri Aug 28 17:27:32 CST 2020 2 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip 3 | distributionBase=GRADLE_USER_HOME 4 | distributionPath=wrapper/dists 5 | zipStorePath=wrapper/dists 6 | zipStoreBase=GRADLE_USER_HOME 7 | -------------------------------------------------------------------------------- /src/main/resources/filetransfer.properties: -------------------------------------------------------------------------------- 1 | #localfile switch 2 | local.enabled=true 3 | 4 | #FTP switch 5 | ftp.enabled=false 6 | ftp.host=127.0.0.1 7 | ftp.port=21 8 | ftp.userName= 9 | ##ftp.userName=ftptest 10 | ftp.passWord= 11 | ftp.workDir=/home/upload 12 | ftp.encoding=UTF-8 13 | ftp.maxTotal=100 14 | ftp.minIdel=2 15 | ftp.maxIdle=5 16 | ftp.maxWaitMillis=3000 17 | -------------------------------------------------------------------------------- /src/main/scripts/init.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE `task_info` ( 2 | `pk_id` bigint(20) NOT NULL AUTO_INCREMENT, 3 | `node_id` varchar(255) NOT NULL DEFAULT '""', 4 | `task_id` varchar(255) NOT NULL DEFAULT '""', 5 | `status` tinyint(4) NOT NULL, 6 | `triggered` tinyint(4) NOT NULL, 7 | `business_file_name` varchar(255) DEFAULT NULL, 8 | `business_file_path` varchar(255) DEFAULT NULL, 9 | `bc_file_path` varchar(255) DEFAULT NULL, 10 | `result_file_path` varchar(255) DEFAULT NULL, 11 | `last_execute_starttime` timestamp NULL DEFAULT NULL, 12 | `last_execute_endtime` timestamp NULL DEFAULT NULL, 13 | `data_range_begintime` timestamp NULL DEFAULT NULL, 14 | `data_range_endtime` timestamp NULL DEFAULT NULL, 15 | `retry_count` int(11) DEFAULT 0, 16 | `createtime` timestamp NOT NULL DEFAULT '2019-05-21 00:00:00', 17 | `updatetime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, 18 | PRIMARY KEY (`pk_id`), 19 | UNIQUE KEY `task_id` (`task_id`) 20 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -------------------------------------------------------------------------------- /src/main/java/com/webank/blockchain/data/reconcile/constants/ResponseCode.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2020 Webank. 3 | * 4 | *
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file 5 | * except in compliance with the License. You may obtain a copy of the License at 6 | * 7 | *
http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | *
Unless required by applicable law or agreed to in writing, software distributed under the 10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 11 | * express or implied. See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | package com.webank.blockchain.data.reconcile.constants; 15 | 16 | /** 17 | * @author wesleywang 18 | * @Description: 19 | * @date 2020/7/3 20 | */ 21 | public class ResponseCode { 22 | 23 | public static final int HTTP_SUCCESS_CODE = 200; 24 | 25 | public static final int RECONCILE_FAILED_CODE = 3000; 26 | } 27 | -------------------------------------------------------------------------------- /src/test/java/com/webank/blockchain/data/reconcile/BaseTests.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2020 Webank. 3 | * 4 | *
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file 5 | * except in compliance with the License. You may obtain a copy of the License at 6 | * 7 | *
http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | *
Unless required by applicable law or agreed to in writing, software distributed under the 10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 11 | * express or implied. See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | package com.webank.blockchain.data.reconcile; 15 | 16 | 17 | import org.junit.runner.RunWith; 18 | import org.springframework.boot.test.context.SpringBootTest; 19 | import org.springframework.test.context.junit4.SpringRunner; 20 | 21 | @RunWith(SpringRunner.class) 22 | @SpringBootTest 23 | public abstract class BaseTests { 24 | 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/com/webank/blockchain/data/reconcile/message/NoticeService.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2020 Webank. 3 | * 4 | *
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file 5 | * except in compliance with the License. You may obtain a copy of the License at 6 | * 7 | *
http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | *
Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package com.webank.blockchain.data.reconcile.message;
15 |
16 | /**
17 | * An interface for message queues, used for extensions
18 | *
19 | * @author wesleywang
20 | * @Description:
21 | * @date 2020/6/17
22 | */
23 | public interface NoticeService Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
5 | * except in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package com.webank.blockchain.data.reconcile.reconcile;
15 |
16 | import com.webank.blockchain.data.reconcile.entity.ReconcileExecuteData;
17 |
18 | /**
19 | * @author wesleywang
20 | * @Description: ReconcileTransfer
21 | * @date 2020/6/24
22 | */
23 | public interface ReconcileTransfer {
24 |
25 | void transferToExecutor(ReconcileExecuteData executeData);
26 |
27 | }
28 |
--------------------------------------------------------------------------------
/src/main/java/com/webank/blockchain/data/reconcile/exporter/bc/BCDataExportService.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2020 Webank.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
5 | * except in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package com.webank.blockchain.data.reconcile.exporter.bc;
15 |
16 | import java.io.File;
17 | import java.util.Date;
18 |
19 | /**
20 | * @author wesleywang
21 | * @Description:
22 | * @date 2020/6/24
23 | */
24 | public interface BCDataExportService{
25 |
26 | File exportData(String filePath, Date dataRangeBeginTime, Date dataRangeEndTime) throws Exception;
27 |
28 | }
29 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | ### common ###
2 | log/
3 | src/main/resources
4 | src/test/resources
5 |
6 |
7 | ### mac ###
8 | .DS_Store
9 |
10 | ### gradle ###
11 | .gradle/
12 | build
13 | dist/
14 |
15 | ## eclipse ##
16 | .classpath
17 | .project
18 | .settings
19 | bin/
20 | out/
21 | conf/
22 |
23 | ## integration test files
24 | nodes/
25 | src/integration-test/resources/
26 | build_chain.sh
27 |
28 | ### STS ###
29 | .apt_generated
30 | .factorypath
31 | .springBeans
32 | .sts4-cache
33 |
34 | ### IntelliJ IDEA ###
35 | .idea
36 | *.iws
37 | *.iml
38 | *.ipr
39 |
40 | ### NetBeans ###
41 | /nbproject/private/
42 | /build/
43 | /nbbuild/
44 | /dist/
45 | /nbdist/
46 | /.nb-gradle/
47 |
48 | ### Compiled class file ###
49 | *.class
50 |
51 | ### Log file ###
52 | *.log
53 |
54 | ### BlueJ files ###
55 | *.ctxt
56 |
57 | ### Mobile Tools for Java (J2ME) ###
58 | .mtj.tmp/
59 |
60 | ### Package Files ###
61 | *.jar
62 | *.war
63 | *.nar
64 | *.ear
65 | *.zip
66 | *.tar.gz
67 | *.rar
68 |
69 | ### virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml ###
70 | hs_err_pid*
71 |
72 | ### repo ###
73 |
--------------------------------------------------------------------------------
/src/main/java/com/webank/blockchain/data/reconcile/handler/Handler.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2020 Webank.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
5 | * except in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package com.webank.blockchain.data.reconcile.handler;
15 |
16 | import com.webank.blockchain.data.reconcile.entity.ReconcileContext;
17 |
18 | /**
19 | * The interface of the chain of responsibility
20 | *
21 | * @author wesleywang
22 | * @Description: Handler
23 | * @date 2020/6/17
24 | */
25 | public interface Handler {
26 |
27 | void invoke(ReconcileContext context, InvocationHandler handler) throws Exception;
28 |
29 | }
30 |
--------------------------------------------------------------------------------
/src/main/java/com/webank/blockchain/data/reconcile/handler/InvocationHandler.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2020 Webank.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
5 | * except in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package com.webank.blockchain.data.reconcile.handler;
15 |
16 | import com.webank.blockchain.data.reconcile.entity.ReconcileContext;
17 |
18 | /**
19 | * The call interface for the chain of responsibility
20 | *
21 | * @author wesleywang
22 | * @Description: InvocationHandler
23 | * @date 2020/6/19
24 | */
25 | public interface InvocationHandler {
26 |
27 | void handle(ReconcileContext context) throws Exception;
28 | }
29 |
--------------------------------------------------------------------------------
/src/main/java/com/webank/blockchain/data/reconcile/reconcile/ReconcileExecutor.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2020 Webank.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
5 | * except in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package com.webank.blockchain.data.reconcile.reconcile;
15 |
16 | import com.webank.blockchain.data.reconcile.entity.ReconcileExecuteData;
17 | import com.webank.blockchain.data.reconcile.entity.ReconcileResult;
18 |
19 | /**
20 | * @author wesleywang
21 | * @Description: ReconcileExecutor
22 | * @date 2020/6/24
23 | */
24 | public interface ReconcileExecutor{
25 |
26 | ReconcileResult execute(ReconcileExecuteData executeData);
27 |
28 | }
29 |
--------------------------------------------------------------------------------
/src/main/java/com/webank/blockchain/data/reconcile/enums/TriggerType.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2020 Webank.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
5 | * except in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package com.webank.blockchain.data.reconcile.enums;
15 |
16 | import lombok.AllArgsConstructor;
17 | import lombok.Getter;
18 | import lombok.ToString;
19 |
20 | /**
21 | * @author wesleywang
22 | * @Description:
23 | * @date 2020/6/19
24 | */
25 | @Getter
26 | @ToString
27 | @AllArgsConstructor
28 | public enum TriggerType {
29 |
30 | SCHEDULED(1, "timing trigger"),
31 | MANUAL(2,"manual trigger");
32 |
33 |
34 | private int type;
35 | private String describe;
36 | }
37 |
--------------------------------------------------------------------------------
/src/main/java/com/webank/blockchain/data/reconcile/filetransfer/FileTransferService.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2020 Webank.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
5 | * except in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package com.webank.blockchain.data.reconcile.filetransfer;
15 |
16 | import java.io.File;
17 | import java.io.IOException;
18 |
19 | /**
20 | * File network transfer interface
21 | *
22 | * @Description: FileSender
23 | * @author graysonzhang
24 | * @date 2020-06-10 16:48:26
25 | *
26 | */
27 | public interface FileTransferService {
28 |
29 | String sendFile(File file) throws Exception;
30 |
31 | File obtainFile(String fileName, String localFilePath) throws IOException;
32 |
33 | }
34 |
--------------------------------------------------------------------------------
/src/main/java/com/webank/blockchain/data/reconcile/entity/ReconcileInfo.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2020 Webank.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
5 | * except in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package com.webank.blockchain.data.reconcile.entity;
15 |
16 | import lombok.Data;
17 |
18 | import java.util.Map;
19 |
20 | /**
21 | * @author wesleywang
22 | * @Description:
23 | * @date 2020-06-12
24 | */
25 | @Data
26 | public class ReconcileInfo {
27 |
28 | /**
29 | * Unique identification of each reconciliation data
30 | */
31 | private String id;
32 |
33 | /**
34 | * Field mapping for reconciliation data
35 | */
36 | private Map Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
5 | * except in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package com.webank.blockchain.data.reconcile.config;
15 |
16 | import org.springframework.boot.context.properties.ConfigurationProperties;
17 | import org.springframework.context.annotation.Configuration;
18 | import lombok.Data;
19 |
20 |
21 | /**
22 | * SystemEnvironmentConfig
23 | *
24 | * @Description: SystemEnvironmentConfig
25 | * @author graysonzhang
26 | * @date 2020-06-10 16:27:14
27 | *
28 | */
29 | @Configuration
30 | @ConfigurationProperties("system")
31 | @Data
32 | public class SystemEnvironmentConfig {
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/src/main/java/com/webank/blockchain/data/reconcile/exception/ReconcileException.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2020 Webank.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
5 | * except in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package com.webank.blockchain.data.reconcile.exception;
15 |
16 | /**
17 | * @author wesleywang
18 | * @Description:
19 | * @date 2020/6/16
20 | */
21 | public class ReconcileException extends Exception{
22 |
23 | private static final long serialVersionUID = 1L;
24 |
25 | public ReconcileException(){}
26 |
27 | public ReconcileException(String message, Throwable cause){
28 | super(message,cause);
29 | }
30 |
31 | public ReconcileException(String message){
32 | super(message);
33 | }
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/src/main/java/com/webank/blockchain/data/reconcile/parser/FileParser.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2020 Webank.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
5 | * except in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package com.webank.blockchain.data.reconcile.parser;
15 |
16 | import com.webank.blockchain.data.reconcile.exception.ReconcileException;
17 | import com.webank.blockchain.data.reconcile.reconcile.ReconcileTransfer;
18 |
19 | import java.io.File;
20 | import java.io.IOException;
21 |
22 | /**
23 | * @author wesleywang
24 | * @Description: FileParser
25 | * @date 2020/6/17
26 | */
27 | public interface FileParser {
28 |
29 | void parseAndTransfer(File businessReconFile, File bcReconFile, ReconcileTransfer transfer) throws ReconcileException, IOException;
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/src/main/java/com/webank/blockchain/data/reconcile/exporter/result/ResultDataExportService.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2020 Webank.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
5 | * except in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package com.webank.blockchain.data.reconcile.exporter.result;
15 |
16 | import com.webank.blockchain.data.reconcile.entity.ReconcileResult;
17 |
18 | import java.io.File;
19 | import java.util.List;
20 | import java.util.concurrent.Future;
21 |
22 | /**
23 | * Export interface of reconciliation result data
24 | *
25 | * @author wesleywang
26 | * @Description:
27 | * @date 2020/7/1
28 | */
29 | public interface ResultDataExportService {
30 |
31 | File exportResultData(String filePath, List Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
5 | * except in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package com.webank.blockchain.data.reconcile.entity;
15 |
16 | import lombok.Data;
17 |
18 | /**
19 | * @author wesleywang
20 | * @Description:
21 | * @date 2020/6/12
22 | */
23 | @Data
24 | public class ReconcileResult {
25 |
26 | /**
27 | * Unique identification of each reconciliation data
28 | */
29 | private String id;
30 |
31 | /**
32 | * Is the reconciliation data consistent
33 | */
34 | private boolean success;
35 |
36 | /**
37 | * note
38 | */
39 | private String note;
40 |
41 | /**
42 | * state
43 | */
44 | private String state;
45 |
46 | }
47 |
--------------------------------------------------------------------------------
/src/main/java/com/webank/blockchain/data/reconcile/filetransfer/local/LocalFileTransferService.java:
--------------------------------------------------------------------------------
1 | package com.webank.blockchain.data.reconcile.filetransfer.local;
2 |
3 | import cn.hutool.core.io.FileUtil;
4 | import com.webank.blockchain.data.reconcile.filetransfer.FileTransferService;
5 | import com.webank.blockchain.data.reconcile.utils.FileUtils;
6 | import lombok.extern.slf4j.Slf4j;
7 | import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
8 | import org.springframework.stereotype.Component;
9 |
10 | import java.io.File;
11 | import java.io.IOException;
12 | import java.nio.file.Paths;
13 | import java.nio.file.StandardCopyOption;
14 |
15 | /**
16 | * @author wesleywang
17 | * @Description:
18 | * @date 2020/12/15
19 | */
20 | @ConditionalOnProperty(value = "local.enabled", havingValue = "true")
21 | @Component
22 | @Slf4j
23 | public class LocalFileTransferService implements FileTransferService {
24 |
25 | @Override
26 | public String sendFile(File file) throws Exception {
27 | return null;
28 | }
29 |
30 | @Override
31 | public File obtainFile(String fileName, String localFilePath) throws IOException {
32 | File localFile = Paths.get("./", fileName).toFile();
33 | return FileUtil.copyFile(localFile, FileUtils.newFile(localFilePath), StandardCopyOption.REPLACE_EXISTING);
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/src/main/java/com/webank/blockchain/data/reconcile/db/entity/IdEntity.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2020 Webank.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
5 | * except in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | package com.webank.blockchain.data.reconcile.db.entity;
16 |
17 | import lombok.Data;
18 | import lombok.experimental.Accessors;
19 |
20 | import javax.persistence.*;
21 | import java.io.Serializable;
22 |
23 | /**
24 | * @author wesleywang
25 | * @Description:
26 | * @date 2020/6/17
27 | */
28 | @Data
29 | @MappedSuperclass
30 | @Accessors(chain = true)
31 | public abstract class IdEntity implements Serializable {
32 |
33 | private static final long serialVersionUID = 5903397383140175895L;
34 | /** @Fields pkId : primary key */
35 | @Id
36 | @GeneratedValue(strategy = GenerationType.IDENTITY)
37 | @Column(name = "pk_id")
38 | protected Long pkId;
39 | }
40 |
--------------------------------------------------------------------------------
/src/main/java/com/webank/blockchain/data/reconcile/config/BeanConfig.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2020 Webank.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
5 | * except in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package com.webank.blockchain.data.reconcile.config;
15 |
16 | import lombok.extern.slf4j.Slf4j;
17 | import org.springframework.context.annotation.Bean;
18 | import org.springframework.context.annotation.Configuration;
19 |
20 | import java.net.InetAddress;
21 | import java.net.UnknownHostException;
22 |
23 | /**
24 | * @author wesleywang
25 | * @Description:
26 | * @date 2020/6/19
27 | */
28 | @Configuration
29 | @Slf4j
30 | public class BeanConfig {
31 |
32 | @Bean
33 | public InetAddress getIpAddress() throws UnknownHostException {
34 | log.info("System confPath is {}", System.getProperty("confPath"));
35 | return InetAddress.getLocalHost();
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/src/main/resources/datasource.properties:
--------------------------------------------------------------------------------
1 | ## data export DB config
2 | spring.datasource.url=jdbc:mysql://[ip]:[port]/[database]?autoReconnect=true&characterEncoding=utf8&useSSL=false&serverTimezone=GMT%2b8
3 | spring.datasource.username=
4 | spring.datasource.password=
5 |
6 | #Specifies the minimum value at which the connection must be maintained.
7 | spring.datasource.min-idle=50
8 | #Specifies the maximum number of free connections to the connection pool.
9 | spring.datasource.max-idle=100
10 | #Specifies the maximum wait time, in milliseconds, for a connection pool to wait for a connection to return.
11 | spring.datasource.max-wait=1000
12 | #Verify the validity of the connection.
13 | spring.datasource.valdation-query=SELECT 1
14 | spring.datasource.test-while-idle=true
15 | #The interval between idle connections being reclaimed.
16 | spring.datasource.time-between-eviction-runs-millis=300000
17 | spring.datasource.encrypt=false
18 |
19 | #Configure database type
20 | spring.jpa.database=MYSQL
21 | #Configure whether to print SQL
22 | spring.jpa.show-sql=true
23 | #Configure the cascade level, which is configured by default to disable DDL
24 | spring.jpa.hibernate.ddl-auto=update
25 | #Naming policy, no modified naming by default
26 | spring.jpa.hibernate.naming-strategy=org.hibernate.cfg.ImprovedNamingStrategy
27 | spring.jpa.hibernate.database-platform=org.hibernate.dialect.MySQL5Dialect
28 |
29 |
30 |
--------------------------------------------------------------------------------
/src/main/java/com/webank/blockchain/data/reconcile/entity/ReconcileExecuteData.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2020 Webank.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
5 | * except in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package com.webank.blockchain.data.reconcile.entity;
15 |
16 | import lombok.Data;
17 |
18 | /**
19 | * @author wesleywang
20 | * @Description:
21 | * @date 2020/6/18
22 | */
23 | @Data
24 | public class ReconcileExecuteData {
25 |
26 | /**
27 | * Unique identification of each reconciliation data
28 | */
29 | private String id;
30 |
31 | /**
32 | * Reconciliation data of business parties
33 | */
34 | private ReconcileInfo busOrg;
35 |
36 | /**
37 | * Reconciliation data of BC parties
38 | */
39 | private ReconcileInfo bcOrg;
40 |
41 | /**
42 | * Whether or not id matching data was found
43 | */
44 | private boolean matchById;
45 |
46 | }
47 |
--------------------------------------------------------------------------------
/src/test/java/com/webank/blockchain/data/reconcile/FileTransferTest.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2020 Webank.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
5 | * except in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package com.webank.blockchain.data.reconcile;
15 |
16 | import com.webank.blockchain.data.reconcile.filetransfer.FileTransferService;
17 | import org.junit.Test;
18 | import org.springframework.beans.factory.annotation.Autowired;
19 |
20 | /**
21 | * @author wesleywang
22 | * @Description:
23 | * @date 2020/7/8
24 | */
25 | public class FileTransferTest extends BaseTests{
26 |
27 | @Autowired
28 | private FileTransferService transferService;
29 |
30 | @Test
31 | public void transferServiceTest() throws Exception {
32 | // transferService.obtainFile("xxxxx_2020-07-06.txt","out/business/xxxx_2020-07-06.txt");
33 | // transferService.sendFile(new File("out/result/result_xxxx_2020-07-06.txt"));
34 | }
35 |
36 | }
37 |
--------------------------------------------------------------------------------
/src/main/java/com/webank/blockchain/data/reconcile/utils/StringUtils.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2020 Webank.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
5 | * except in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package com.webank.blockchain.data.reconcile.utils;
15 |
16 | /**
17 | * @author wesleywang
18 | * @Description:
19 | * @date 2020/7/3
20 | */
21 | public class StringUtils {
22 |
23 | public static final String EMPTY = "";
24 |
25 | public static final int INDEX_NOT_FOUND = -1;
26 |
27 |
28 | public static String substringAfterOfIgnoreCase(String str, String separator) {
29 | if (isEmpty(str)) {
30 | return str;
31 | }
32 | if (isEmpty(separator)) {
33 | return EMPTY;
34 | }
35 | int pos = org.apache.commons.lang3.StringUtils.indexOfIgnoreCase(str,separator);
36 | if (pos == INDEX_NOT_FOUND || pos == str.length() - separator.length()) {
37 | return EMPTY;
38 | }
39 | return str.substring(pos + separator.length());
40 | }
41 |
42 | public static boolean isEmpty(CharSequence cs) {
43 | return cs == null || cs.length() == 0;
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/src/main/java/com/webank/blockchain/data/reconcile/config/FTPConfig.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2020 Webank.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
5 | * except in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package com.webank.blockchain.data.reconcile.config;
15 |
16 | import lombok.Data;
17 | import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
18 | import org.springframework.boot.context.properties.ConfigurationProperties;
19 | import org.springframework.context.annotation.Configuration;
20 | import org.springframework.context.annotation.PropertySource;
21 |
22 | /**
23 | * @author wesleywang
24 | * @Description:
25 | * @date 2020-06-11
26 | */
27 | @Configuration
28 | @ConditionalOnProperty(value = "ftp.enabled", havingValue = "true")
29 | @ConfigurationProperties(prefix="ftp")
30 | @Data
31 | public class FTPConfig {
32 |
33 | private String host;
34 | private int port;
35 | private String userName;
36 | private String passWord;
37 | private String workDir;
38 | private String encoding;
39 | private String root;
40 | private int maxTotal;
41 | private int minIdel;
42 | private int maxIdle;
43 | private int maxWaitMillis;
44 |
45 | }
46 |
--------------------------------------------------------------------------------
/src/main/java/com/webank/blockchain/data/reconcile/entity/Responses.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2020 Webank.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
5 | * except in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package com.webank.blockchain.data.reconcile.entity;
15 |
16 | import com.webank.blockchain.data.reconcile.constants.ResponseCode;
17 | import lombok.Data;
18 | import org.apache.commons.lang3.StringUtils;
19 |
20 | import java.io.Serializable;
21 |
22 | /**
23 | * @author wesleywang
24 | * @Description:
25 | * @date 2020/6/18
26 | */
27 | @Data
28 | public class Responses Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
5 | * except in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package com.webank.blockchain.data.reconcile.config;
15 |
16 | import com.zaxxer.hikari.HikariDataSource;
17 | import lombok.Data;
18 | import org.springframework.boot.context.properties.ConfigurationProperties;
19 | import org.springframework.context.annotation.Bean;
20 | import org.springframework.context.annotation.Configuration;
21 | import org.springframework.context.annotation.PropertySource;
22 | import org.springframework.core.env.Environment;
23 |
24 | import javax.sql.DataSource;
25 | import java.io.IOException;
26 |
27 | /**
28 | * @author wesleywang
29 | * @Description:
30 | * @date 2020/6/18
31 | */
32 | @Configuration
33 | @Data
34 | public class DBConfig {
35 |
36 | @Bean(name = "dataSource")
37 | public DataSource dataSource(Environment env) throws IOException {
38 | HikariDataSource ds = new HikariDataSource();
39 | ds.setJdbcUrl(env.getProperty("spring.datasource.url"));
40 | ds.setUsername(env.getProperty("spring.datasource.username"));
41 | ds.setPassword(env.getProperty("spring.datasource.password"));
42 | return ds;
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # 组件介绍
2 | 传统企业间的对账依赖于对账双⽅的中心化账本。中心化账本在对账期间如果出现账不平的情况,排查会⾮常耗时耗力。区块链作为信任的机器,具有不可篡改、分布式账本等特性,基于区块链的对账能够在对账不一致的情况下,找到⼀个可信的客观依据,从而减少因对账不平造成的排查成本。
3 | WeBankBlockchain-Data-Reconcile是一款基于区块链的对账组件,提供基于区块链智能合约账本的通用化数据对账解决方案,并提供了一套可动态扩展的对账框架,支持定制化开发。
4 |
5 | ## 关键特性
6 | - 支持自定义对账数据
7 | - 支持自定义对账规则
8 | - 支持多个对账任务, 提供对账任务配置
9 | - 支持多种对账文件格式,可扩展
10 | - 支持自定义对账任务和方式,手动或自动、任务频次、时间可配置
11 | - 支持多种对账文件托管方式,如文件管理系统或服务器,可扩展
12 |
13 | ## 环境要求
14 |
15 | 在使用本组件前,请确认系统环境已安装相关依赖软件,清单如下:
16 |
17 | | 依赖软件 | 说明 | 备注 |
18 | | ---------- | ------------------------------------------------------------ | ---- |
19 | | FISCO-BCOS | \>= 2.0, 1.x版本请参考V0.5版本 dev分支 | |
20 | | Bash | 需支持Bash(理论上来说支持所有ksh、zsh等其他unix shell,但未测试) | |
21 | | Java | \>= JDK[1.8] | |
22 | | Git | 下载的安装包使用Git | |
23 | | MySQL | \>= mysql-community-server[5.7] | |
24 | | FTP | 需要时安装 | |
25 |
26 |
27 | ## 文档
28 | - [**中文**](https://data-doc.readthedocs.io/zh_CN/dev/docs/WeBankBlockchain-Data-Reconcile/index.html)
29 | - [**快速安装**](https://data-doc.readthedocs.io/zh_CN/dev/docs/WeBankBlockchain-Data-Reconcile/install.html)
30 |
31 |
32 | ## 贡献代码
33 | 欢迎参与本项目的社区建设:
34 | - 如项目对您有帮助,欢迎点亮我们的小星星(点击项目右上方Star按钮)。
35 | - 欢迎提交代码(Pull requests)。
36 | - [提问和提交BUG](https://github.com/WeBankBlockchain/Data-Reconcile/issues)。
37 | - 如果发现代码存在安全漏洞,请在[这里](https://security.webank.com)上报。
38 |
39 |
40 | ## License
41 | 
42 |
43 | 开源协议为[Apache License 2.0](http://www.apache.org/licenses/). 详情参考[LICENSE](../LICENSE)。
44 |
45 |
--------------------------------------------------------------------------------
/src/test/java/com/webank/blockchain/data/reconcile/FileUtilsTest.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2020 Webank.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
5 | * except in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package com.webank.blockchain.data.reconcile;
15 |
16 | import com.webank.blockchain.data.reconcile.utils.FileUtils;
17 | import org.junit.Test;
18 |
19 | import java.util.ArrayList;
20 | import java.util.List;
21 |
22 | /**
23 | * @author wesleywang
24 | * @Description:
25 | * @date 2020/7/8
26 | */
27 | public class FileUtilsTest extends BaseTests {
28 |
29 | @Test
30 | public void exportDataUtilTest() throws Exception {
31 | List Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
5 | * except in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package com.webank.blockchain.data.reconcile;
15 |
16 | import org.springframework.boot.SpringApplication;
17 | import org.springframework.boot.autoconfigure.SpringBootApplication;
18 | import org.springframework.boot.context.properties.EnableConfigurationProperties;
19 | import org.springframework.context.annotation.PropertySource;
20 | import org.springframework.transaction.annotation.EnableTransactionManagement;
21 |
22 | @PropertySource(value = {
23 | "file:./config/application.properties",
24 | "file:./config/datasource.properties",
25 | "file:./config/reconcile.properties",
26 | "file:./config/filetransfer.properties",
27 | "classpath:application.properties",
28 | "classpath:datasource.properties",
29 | "classpath:reconcile.properties",
30 | "classpath:filetransfer.properties",
31 | }, encoding = "utf-8",ignoreResourceNotFound = true)
32 | @SpringBootApplication
33 | @EnableTransactionManagement
34 | @EnableConfigurationProperties
35 | public class BcreconcileApplication {
36 |
37 | public static void main(String[] args) {
38 | SpringApplication.run(BcreconcileApplication.class, args);
39 | }
40 |
41 | }
42 |
--------------------------------------------------------------------------------
/src/test/java/com/webank/blockchain/data/reconcile/ReconcileTaskTest.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2020 Webank.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
5 | * except in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package com.webank.blockchain.data.reconcile;
15 |
16 | import com.webank.blockchain.data.reconcile.entity.ReconcileContext;
17 | import com.webank.blockchain.data.reconcile.enums.TriggerType;
18 | import com.webank.blockchain.data.reconcile.handler.InvocationHandler;
19 | import com.webank.blockchain.data.reconcile.handler.ReconcileHandlerFactory;
20 | import org.junit.Test;
21 | import org.springframework.beans.factory.annotation.Autowired;
22 |
23 | /**
24 | * @author wesleywang
25 | * @Description:
26 | * @date 2020/6/28
27 | */
28 | public class ReconcileTaskTest extends BaseTests {
29 |
30 |
31 | @Autowired
32 | private ReconcileHandlerFactory handlerFactory;
33 |
34 | @Test
35 | public void test() throws Exception {
36 | InvocationHandler handler = handlerFactory.getInvocationHandler();
37 | ReconcileContext context = ReconcileContext.builder()
38 | .triggerType(TriggerType.SCHEDULED).build();
39 | try {
40 | handler.handle(context);
41 | } catch (Exception e) {
42 | // e.printStackTrace();
43 | }
44 |
45 | // Thread.sleep(1000000000);
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/src/main/java/com/webank/blockchain/data/reconcile/utils/ThreadUtils.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2020 Webank.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
5 | * except in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package com.webank.blockchain.data.reconcile.utils;
15 |
16 | import java.util.concurrent.Executors;
17 | import java.util.concurrent.LinkedBlockingQueue;
18 | import java.util.concurrent.ScheduledExecutorService;
19 | import java.util.concurrent.ThreadPoolExecutor;
20 | import java.util.concurrent.TimeUnit;
21 |
22 | /**
23 | * @author wesleywang
24 | * @Description:
25 | * @date 2020/6/17
26 | */
27 | public final class ThreadUtils {
28 |
29 | public static ThreadPoolExecutor executor;
30 |
31 | public static ScheduledExecutorService timer;
32 |
33 | public static ThreadPoolExecutor transfer;
34 |
35 | static {
36 | executor = new ThreadPoolExecutor(5,20,1000L,
37 | TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>(2048));
38 |
39 | timer = Executors.newScheduledThreadPool(4);
40 |
41 | transfer = new ThreadPoolExecutor(2,5,100L,
42 | TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>(256));
43 |
44 | Runtime.getRuntime().addShutdownHook(new Thread(){
45 | @Override
46 | public void run() {
47 | executor.shutdown();
48 | timer.shutdown();
49 | transfer.shutdown();
50 | }
51 | });
52 | }
53 |
54 | }
55 |
--------------------------------------------------------------------------------
/src/main/java/com/webank/blockchain/data/reconcile/handler/ReconcileHandlerFactory.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2020 Webank.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
5 | * except in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package com.webank.blockchain.data.reconcile.handler;
15 |
16 | import org.springframework.beans.factory.annotation.Autowired;
17 | import org.springframework.stereotype.Service;
18 |
19 | import javax.annotation.PostConstruct;
20 | import java.util.List;
21 |
22 | /**
23 | * The assembly and construction of the responsibility chain, and the management of the processor
24 | *
25 | * @author wesleywang
26 | * @Description: ReconcileHandlerFactory
27 | * @date 2020/6/19
28 | */
29 | @Service
30 | public class ReconcileHandlerFactory {
31 |
32 | @Autowired
33 | private List Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
5 | * except in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package com.webank.blockchain.data.reconcile.handler.executor;
15 |
16 | import com.webank.blockchain.data.reconcile.entity.ReconcileContext;
17 | import com.webank.blockchain.data.reconcile.entity.ReconcileResult;
18 | import com.webank.blockchain.data.reconcile.handler.Handler;
19 | import com.webank.blockchain.data.reconcile.handler.InvocationHandler;
20 |
21 | import java.io.File;
22 | import java.util.List;
23 | import java.util.concurrent.Future;
24 |
25 | /**
26 | * An abstract class that handles the reconciliation execution steps and is responsible for parsing and comparing
27 | * reconciliation files. It contains a core method for reconciliation execution and provides a default implementation
28 | *
29 | * @author wesleywang
30 | * @Description: ReconcileExecuteHandler
31 | * @date 2020/6/17
32 | */
33 | public abstract class ReconcileExecuteHandler implements Handler {
34 |
35 | @Override
36 | public void invoke(ReconcileContext context, InvocationHandler handler) throws Exception {
37 | List Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
5 | * except in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package com.webank.blockchain.data.reconcile.enums;
15 |
16 | import lombok.AllArgsConstructor;
17 | import lombok.Getter;
18 | import lombok.ToString;
19 | import lombok.extern.slf4j.Slf4j;
20 |
21 | /**
22 | * reconciliation task status flow:
23 | * 1.INIT -> EXECUTING -> SUCCESS
24 | * 2.INIT -> EXECUTING -> FAILURE -> SUCCESS
25 | * 3.INIT -> EXECUTING -> FAILURE -> TERMINATE
26 | *
27 | * @author wesleywang
28 | * @Description:TaskStatus
29 | * @date 2020/6/19
30 | */
31 | @Getter
32 | @ToString
33 | @AllArgsConstructor
34 | @Slf4j
35 | public enum TaskStatus {
36 |
37 | INIT(0, "waiting for executing"),
38 | EXECUTING(1, "executing"),
39 | SUCCESS(2, "execute successfully"),
40 | FAILURE(3,"execute failed"),
41 | TERMINATE(4,"execute terminated");
42 |
43 |
44 | private int status;
45 | private String describe;
46 |
47 | public static TaskStatus getByDescribe(String Describe){
48 | for(TaskStatus type : TaskStatus.values()){
49 | if(type.describe.equals(Describe)){
50 | return type;
51 | }
52 | }
53 | log.error("TaskStatus type {} can't be converted.", Describe);
54 | return null;
55 | }
56 |
57 | public static TaskStatus getByStatus(int status){
58 | for(TaskStatus type : TaskStatus.values()){
59 | if(type.status == status){
60 | return type;
61 | }
62 | }
63 | log.error("TaskStatus type {} error.", status);
64 | return null;
65 | }
66 |
67 |
68 | }
69 |
--------------------------------------------------------------------------------
/src/main/java/com/webank/blockchain/data/reconcile/db/dao/TaskDao.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2020 Webank.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
5 | * except in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package com.webank.blockchain.data.reconcile.db.dao;
15 |
16 | import com.webank.blockchain.data.reconcile.db.entity.TaskInfo;
17 | import com.webank.blockchain.data.reconcile.db.repository.TaskInfoRepository;
18 | import org.springframework.beans.factory.annotation.Autowired;
19 | import org.springframework.stereotype.Service;
20 |
21 | import java.util.Date;
22 | import java.util.List;
23 |
24 | /**
25 | * @author wesleywang
26 | * @Description:
27 | * @date 2020/6/19
28 | */
29 | @Service
30 | public class TaskDao {
31 |
32 | @Autowired
33 | private TaskInfoRepository repository;
34 |
35 | public void updateTaskStatus(long pkId, int from, int to){
36 | repository.updateStatus(pkId, from,to);
37 | }
38 |
39 | public void updateTaskStatus(long pkId, int from, int to, Date lastExecuteEndTime){
40 | repository.updateStatus(pkId, from,to,lastExecuteEndTime);
41 | }
42 |
43 | public TaskInfo save(TaskInfo taskInfo){
44 | return repository.save(taskInfo);
45 | }
46 |
47 | public List Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
5 | * except in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package com.webank.blockchain.data.reconcile.exporter.result;
15 |
16 | import com.webank.blockchain.data.reconcile.entity.ReconcileResult;
17 | import com.webank.blockchain.data.reconcile.utils.FileUtils;
18 | import lombok.extern.slf4j.Slf4j;
19 | import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
20 | import org.springframework.stereotype.Service;
21 |
22 | import java.io.File;
23 | import java.time.LocalTime;
24 | import java.util.ArrayList;
25 | import java.util.List;
26 | import java.util.concurrent.Future;
27 |
28 | /**
29 | * @author wesleywang
30 | * @Description:
31 | * @date 2020/6/28
32 | */
33 | @ConditionalOnProperty(value = "reconcile.file.type", havingValue = "txt")
34 | @Service
35 | @Slf4j
36 | public class ResultDataExportServiceTxtImpl implements ResultDataExportService{
37 |
38 |
39 | @Override
40 | public File exportResultData(String filePath, List Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
5 | * except in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package com.webank.blockchain.data.reconcile;
15 |
16 | import com.webank.blockchain.data.reconcile.entity.ReconcileExecuteData;
17 | import com.webank.blockchain.data.reconcile.entity.ReconcileInfo;
18 | import com.webank.blockchain.data.reconcile.reconcile.ReconcileExecutor;
19 | import org.junit.Test;
20 | import org.springframework.beans.factory.annotation.Autowired;
21 |
22 | import java.util.HashMap;
23 | import java.util.Map;
24 |
25 | /**
26 | * @author wesleywang
27 | * @Description:
28 | * @date 2020/7/8
29 | */
30 | public class ReconcileExecutorTest extends BaseTests{
31 |
32 |
33 | @Autowired
34 | private ReconcileExecutor reconcileExecutor;
35 |
36 | @Test
37 | public void reconcileExecutorTest() throws Exception {
38 | ReconcileExecuteData reconcileExecuteData = new ReconcileExecuteData();
39 | ReconcileInfo busOrg = new ReconcileInfo();
40 | Map Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
5 | * except in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package com.webank.blockchain.data.reconcile.db.repository;
15 |
16 | import com.webank.blockchain.data.reconcile.db.entity.TaskInfo;
17 | import org.springframework.data.jpa.repository.JpaRepository;
18 | import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
19 | import org.springframework.data.jpa.repository.Modifying;
20 | import org.springframework.data.jpa.repository.Query;
21 | import org.springframework.stereotype.Repository;
22 |
23 | import javax.transaction.Transactional;
24 | import java.util.Date;
25 | import java.util.List;
26 |
27 | /**
28 | * @author wesleywang
29 | * @Description:
30 | * @date 2020/6/19
31 | */
32 | @Repository
33 | public interface TaskInfoRepository extends JpaRepository Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
5 | * except in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package com.webank.blockchain.data.reconcile.entity;
15 |
16 | import com.webank.blockchain.data.reconcile.db.entity.TaskInfo;
17 | import com.webank.blockchain.data.reconcile.enums.TriggerType;
18 | import lombok.Builder;
19 | import lombok.Data;
20 |
21 | import java.io.File;
22 | import java.util.Date;
23 | import java.util.List;
24 | import java.util.concurrent.Future;
25 |
26 | /**
27 | * @author wesleywang
28 | * @Description:
29 | * @date 2020/6/17
30 | */
31 | @Data
32 | @Builder
33 | public class ReconcileContext {
34 |
35 | /**
36 | * Reconciliation task trigger mode
37 | */
38 | private TriggerType triggerType;
39 |
40 | /**
41 | * Whether the reconciliation task is enabled asynchronously
42 | */
43 | private boolean async;
44 |
45 | /**
46 | * Name of reconciliation document of business party
47 | */
48 | private String businessFileName;
49 |
50 | /**
51 | * The start time of the reconciliation data range
52 | */
53 | private Date dataRangeBeginTime;
54 |
55 | /**
56 | * The end time of the reconciliation data range
57 | */
58 | private Date dataRangeEndTime;
59 |
60 | /**
61 | * Reconciliation task detail object
62 | */
63 | private TaskInfo taskInfo;
64 |
65 | /**
66 | * Reconciliation business party documents
67 | */
68 | private File businessReconFile;
69 |
70 | /**
71 | * Reconciliation BC party documents
72 | */
73 | private File bcReconFile;
74 |
75 | /**
76 | * Reconciliation task results
77 | */
78 | private List Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
5 | * except in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package com.webank.blockchain.data.reconcile.task;
15 |
16 | import com.webank.blockchain.data.reconcile.entity.ReconcileContext;
17 | import com.webank.blockchain.data.reconcile.enums.TriggerType;
18 | import com.webank.blockchain.data.reconcile.handler.InvocationHandler;
19 | import com.webank.blockchain.data.reconcile.handler.ReconcileHandlerFactory;
20 | import lombok.extern.slf4j.Slf4j;
21 | import org.springframework.beans.factory.annotation.Autowired;
22 | import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
23 | import org.springframework.scheduling.annotation.EnableScheduling;
24 | import org.springframework.scheduling.annotation.Scheduled;
25 | import org.springframework.stereotype.Component;
26 |
27 | import java.time.LocalDate;
28 |
29 | /**
30 | * Timed trigger processing of reconciliation
31 | *
32 | * @author wesleywang
33 | * @Description:
34 | * @date 2020/6/17
35 | */
36 | @Component
37 | @Slf4j
38 | @EnableScheduling
39 | @ConditionalOnProperty(value = "reconcile.task.timer.enable", havingValue = "true")
40 | public class ReconcileTaskTimer {
41 |
42 | @Autowired
43 | private ReconcileHandlerFactory handlerFactory;
44 |
45 | @Scheduled(cron = "${reconcile.task.time.rule}")
46 | public void execute() {
47 | InvocationHandler handler = handlerFactory.getInvocationHandler();
48 | ReconcileContext context = ReconcileContext.builder()
49 | .triggerType(TriggerType.SCHEDULED).build();
50 | log.info("reconcile schedule task start , time :" + LocalDate.now().toString());
51 | try {
52 | handler.handle(context);
53 | } catch (Exception e) {
54 | log.error("reconcile schedule task failed, reason :", e);
55 | }
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/src/main/java/com/webank/blockchain/data/reconcile/handler/executor/DefaultReconcileExecuteHandler.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2020 Webank.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
5 | * except in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package com.webank.blockchain.data.reconcile.handler.executor;
15 |
16 | import com.webank.blockchain.data.reconcile.entity.ReconcileResult;
17 | import com.webank.blockchain.data.reconcile.parser.FileParser;
18 | import com.webank.blockchain.data.reconcile.reconcile.ReconcileExecutor;
19 | import com.webank.blockchain.data.reconcile.reconcile.ReconcileTransfer;
20 | import com.webank.blockchain.data.reconcile.utils.ThreadUtils;
21 | import org.springframework.beans.factory.annotation.Autowired;
22 | import org.springframework.core.annotation.Order;
23 | import org.springframework.stereotype.Service;
24 |
25 | import java.io.File;
26 | import java.util.ArrayList;
27 | import java.util.List;
28 | import java.util.concurrent.Future;
29 |
30 | /**
31 | * The default implementation for the reconciliation processing step consists of two modules, parsing
32 | * {@link FileParser} and executing {@link ReconcileExecutor}, with a decoupling between the modules through
33 | * the {@link ReconcileTransfer} interface
34 | *
35 | * @author wesleywang
36 | * @Description: DefaultReconcileExecuteHandler
37 | * @date 2020/6/23
38 | */
39 | @Service
40 | @Order(3)
41 | public class DefaultReconcileExecuteHandler extends ReconcileExecuteHandler{
42 |
43 | @Autowired
44 | private FileParser fileParser;
45 | @Autowired
46 | private ReconcileExecutor reconcileExecutor;
47 |
48 | @Override
49 | List Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
5 | * except in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package com.webank.blockchain.data.reconcile.exporter.bc;
15 |
16 | import com.webank.blockchain.data.reconcile.db.dao.BCInfoDao;
17 | import com.webank.blockchain.data.reconcile.utils.BufferedRandomAccessFile;
18 | import com.webank.blockchain.data.reconcile.utils.FileUtils;
19 | import org.apache.tomcat.util.http.fileupload.IOUtils;
20 | import org.springframework.beans.factory.annotation.Autowired;
21 | import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
22 | import org.springframework.data.domain.Page;
23 | import org.springframework.stereotype.Service;
24 |
25 | import java.io.File;
26 | import java.util.Date;
27 | import java.util.List;
28 | import java.util.Map;
29 |
30 | /**
31 | * @author wesleywang
32 | * @Description:
33 | * @date 2020/6/24
34 | */
35 | @Service
36 | @ConditionalOnProperty(value = "reconcile.file.type", havingValue = "txt")
37 | public class BCDataExportServiceTxtImpl implements BCDataExportService{
38 |
39 | @Autowired
40 | private BCInfoDao bcInfoDao;
41 |
42 | @Override
43 | public File exportData(String filePath, Date dataRangeBeginTime, Date dataRangeEndTime) throws Exception {
44 | File file = FileUtils.newFile(filePath);
45 | Page