|
@@ -7,10 +7,12 @@ import ieven.server.webapp.domain.data.Fields;
|
|
import ieven.server.webapp.domain.file.FileService;
|
|
import ieven.server.webapp.domain.file.FileService;
|
|
import ieven.server.webapp.domain.file.LogicalFile;
|
|
import ieven.server.webapp.domain.file.LogicalFile;
|
|
import ieven.server.webapp.infrastructure.wrapper.Mapped;
|
|
import ieven.server.webapp.infrastructure.wrapper.Mapped;
|
|
|
|
+import ieven.server.webapp.service.FieldsService;
|
|
import ieven.server.webapp.service.tenpay.*;
|
|
import ieven.server.webapp.service.tenpay.*;
|
|
import ieven.server.webapp.util.DataUtils;
|
|
import ieven.server.webapp.util.DataUtils;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import org.apache.commons.collections4.CollectionUtils;
|
|
import org.apache.commons.collections4.CollectionUtils;
|
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.data.mongodb.core.MongoTemplate;
|
|
import org.springframework.data.mongodb.core.MongoTemplate;
|
|
import org.springframework.data.mongodb.core.query.Criteria;
|
|
import org.springframework.data.mongodb.core.query.Criteria;
|
|
@@ -34,11 +36,26 @@ public class AlipayService {
|
|
@Autowired private HeaderProperties headerProperties;
|
|
@Autowired private HeaderProperties headerProperties;
|
|
@Autowired private FileService fileService;
|
|
@Autowired private FileService fileService;
|
|
|
|
|
|
|
|
+ @Autowired FieldsService fieldsService;
|
|
|
|
+
|
|
public Mapped extractAll(String modelId) throws InterruptedException {
|
|
public Mapped extractAll(String modelId) throws InterruptedException {
|
|
|
|
+ final List<Fields> originFields = queryAllFields(modelId);
|
|
|
|
+ // 先校验文件结构如果有不符合结构的文件 则暂停执行 给于提示
|
|
|
|
+ fieldsService.checkAllFields(originFields);
|
|
|
|
+ List<LogicalFile> logicalFiles = this.queryAllLogicalFiles(modelId);
|
|
|
|
+ List<String> checkResultStrings = new ArrayList<>();
|
|
|
|
+ for (LogicalFile logicalFile : logicalFiles) {
|
|
|
|
+ if (StringUtils.isBlank(logicalFile.getMatchType())) {
|
|
|
|
+ checkResultStrings.add(logicalFile.getFilename() + "未匹配到文件校验规则,请检查!");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (checkResultStrings.size() > 0) {
|
|
|
|
+ return Mapped.ERROR(String.join(" ", checkResultStrings));
|
|
|
|
+ }
|
|
// 先删除所有原来生成的表
|
|
// 先删除所有原来生成的表
|
|
clearAllGenerated(modelId);
|
|
clearAllGenerated(modelId);
|
|
// 查询出modelId的所有原始表头
|
|
// 查询出modelId的所有原始表头
|
|
- final List<Fields> originFields = checkFields(modelId);
|
|
|
|
|
|
+
|
|
if (CollectionUtils.isEmpty(originFields)) {
|
|
if (CollectionUtils.isEmpty(originFields)) {
|
|
return Mapped.ERROR("文件为空");
|
|
return Mapped.ERROR("文件为空");
|
|
}
|
|
}
|
|
@@ -125,6 +142,7 @@ public class AlipayService {
|
|
log.info("latch4");
|
|
log.info("latch4");
|
|
log.info("latch5");
|
|
log.info("latch5");
|
|
CountDownLatch latch5 = new CountDownLatch(1);
|
|
CountDownLatch latch5 = new CountDownLatch(1);
|
|
|
|
+ // 财付通 开户信息
|
|
exec.execute(
|
|
exec.execute(
|
|
new TenpayAccount(
|
|
new TenpayAccount(
|
|
originFields, modelId, mongoTemplate, fileService, accountToName, latch5));
|
|
originFields, modelId, mongoTemplate, fileService, accountToName, latch5));
|
|
@@ -132,17 +150,22 @@ public class AlipayService {
|
|
log.info("latch5");
|
|
log.info("latch5");
|
|
log.info("latch6");
|
|
log.info("latch6");
|
|
CountDownLatch latch6 = new CountDownLatch(1);
|
|
CountDownLatch latch6 = new CountDownLatch(1);
|
|
|
|
+ // 财付通-订单明细
|
|
exec.execute(new TenpayOrders(originFields, modelId, mongoTemplate, fileService, latch6));
|
|
exec.execute(new TenpayOrders(originFields, modelId, mongoTemplate, fileService, latch6));
|
|
latch6.await();
|
|
latch6.await();
|
|
log.info("latch6");
|
|
log.info("latch6");
|
|
log.info("latch7");
|
|
log.info("latch7");
|
|
CountDownLatch latch9 = new CountDownLatch(1);
|
|
CountDownLatch latch9 = new CountDownLatch(1);
|
|
|
|
+ // 财付通-交易明细
|
|
exec.execute(new TenpayTrades(modelId, mongoTemplate, accountToName, fileService, latch9));
|
|
exec.execute(new TenpayTrades(modelId, mongoTemplate, accountToName, fileService, latch9));
|
|
latch9.await();
|
|
latch9.await();
|
|
CountDownLatch latch7 = new CountDownLatch(3);
|
|
CountDownLatch latch7 = new CountDownLatch(3);
|
|
|
|
+ // 财付通-手机明细
|
|
exec.execute(new TenpayMobile(originFields, modelId, mongoTemplate, fileService, latch7));
|
|
exec.execute(new TenpayMobile(originFields, modelId, mongoTemplate, fileService, latch7));
|
|
|
|
+ // 财付通-对手透视
|
|
exec.execute(
|
|
exec.execute(
|
|
new TenpayTradesEndAnalysis(headerProperties, modelId, mongoTemplate, fileService, latch7));
|
|
new TenpayTradesEndAnalysis(headerProperties, modelId, mongoTemplate, fileService, latch7));
|
|
|
|
+ // 财付通-账户透视
|
|
exec.execute(
|
|
exec.execute(
|
|
new TenpayTradesScaleAnalysis(
|
|
new TenpayTradesScaleAnalysis(
|
|
headerProperties, modelId, mongoTemplate, fileService, latch7));
|
|
headerProperties, modelId, mongoTemplate, fileService, latch7));
|
|
@@ -177,11 +200,15 @@ public class AlipayService {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- private void clearAllGenerated(String modelId) {
|
|
|
|
|
|
+ public List<LogicalFile> queryAllLogicalFiles(String modelId) {
|
|
Query query =
|
|
Query query =
|
|
new Query(Criteria.where("modelId").is(modelId).and("generated").is(Boolean.TRUE));
|
|
new Query(Criteria.where("modelId").is(modelId).and("generated").is(Boolean.TRUE));
|
|
- List<LogicalFile> oldFiles = mongoTemplate.find(query, LogicalFile.class);
|
|
|
|
- for (LogicalFile old : oldFiles) {
|
|
|
|
|
|
+ return mongoTemplate.find(query, LogicalFile.class);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private void clearAllGenerated(String modelId) {
|
|
|
|
+ List<LogicalFile> logicalFiles = queryAllLogicalFiles(modelId);
|
|
|
|
+ for (LogicalFile old : logicalFiles) {
|
|
IdInput idInput = new IdInput();
|
|
IdInput idInput = new IdInput();
|
|
idInput.setId(old.getId());
|
|
idInput.setId(old.getId());
|
|
fileService.deleteById(idInput);
|
|
fileService.deleteById(idInput);
|
|
@@ -189,7 +216,7 @@ public class AlipayService {
|
|
mongoTemplate.remove(new Query(Criteria.where("modelId").is(modelId)), TFromToFileIds.class);
|
|
mongoTemplate.remove(new Query(Criteria.where("modelId").is(modelId)), TFromToFileIds.class);
|
|
}
|
|
}
|
|
|
|
|
|
- private List<Fields> checkFields(String modelId) {
|
|
|
|
|
|
+ private List<Fields> queryAllFields(String modelId) {
|
|
Query query =
|
|
Query query =
|
|
new Query(Criteria.where("modelId").is(modelId).and("generated").is(Boolean.FALSE));
|
|
new Query(Criteria.where("modelId").is(modelId).and("generated").is(Boolean.FALSE));
|
|
List<LogicalFile> fileList = mongoTemplate.find(query, LogicalFile.class);
|
|
List<LogicalFile> fileList = mongoTemplate.find(query, LogicalFile.class);
|