|
@@ -0,0 +1,73 @@
|
|
|
|
+package ieven.server.webapp.service.datastatic;
|
|
|
|
+
|
|
|
|
+import cn.hutool.core.util.NumberUtil;
|
|
|
|
+import com.mongodb.client.MongoCursor;
|
|
|
|
+import ieven.server.webapp.domain.alipay.HeaderProperties;
|
|
|
|
+import ieven.server.webapp.domain.data.DataMap;
|
|
|
|
+import ieven.server.webapp.domain.file.FileService;
|
|
|
|
+import ieven.server.webapp.service.Ops;
|
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
|
+import org.apache.commons.collections4.CollectionUtils;
|
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
|
+import org.bson.Document;
|
|
|
|
+import org.springframework.data.mongodb.core.MongoTemplate;
|
|
|
|
+
|
|
|
|
+import java.math.BigDecimal;
|
|
|
|
+import java.util.*;
|
|
|
|
+import java.util.concurrent.CountDownLatch;
|
|
|
|
+
|
|
|
|
+@Slf4j
|
|
|
|
+public class DataStaticAnalysis extends Ops implements Runnable {
|
|
|
|
+ private HeaderProperties headerProperties;
|
|
|
|
+ String modelId;
|
|
|
|
+ MongoTemplate mongoTemplate;
|
|
|
|
+ FileService fileService;
|
|
|
|
+ CountDownLatch latch;
|
|
|
|
+
|
|
|
|
+ public DataStaticAnalysis(
|
|
|
|
+ HeaderProperties headerProperties,
|
|
|
|
+ String modelId,
|
|
|
|
+ MongoTemplate mongoTemplate,
|
|
|
|
+ FileService fileService,
|
|
|
|
+ CountDownLatch latch) {
|
|
|
|
+ this.headerProperties = headerProperties;
|
|
|
|
+ this.modelId = modelId;
|
|
|
|
+ this.mongoTemplate = mongoTemplate;
|
|
|
|
+ this.fileService = fileService;
|
|
|
|
+ this.latch = latch;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void run() {
|
|
|
|
+ log.info("数据统计-主体信息开始");
|
|
|
|
+ // 直接删除并创建表
|
|
|
|
+ String newFileId = "";
|
|
|
|
+ String dateFileIdcft = getFileId("财付通-交易明细", modelId, mongoTemplate);
|
|
|
|
+ String dateFileIdfzza = getFileId("反诈治安-交易明细", modelId, mongoTemplate);
|
|
|
|
+
|
|
|
|
+ if(StringUtils.isNotBlank(dateFileIdcft)||StringUtils.isNotBlank(dateFileIdfzza)){
|
|
|
|
+ newFileId =createLogicAndDeleteOld( "数据分析-主体信息汇总", modelId, headerProperties.getAntiSecurityTradeScaleAnalysisOutput(), mongoTemplate, fileService);
|
|
|
|
+ }
|
|
|
|
+ // 插入记录用户后续查询明细
|
|
|
|
+ if (StringUtils.isNotBlank(dateFileIdcft)) {
|
|
|
|
+ MongoCursor<Document> cursor = getCursor(dateFileIdcft, mongoTemplate);
|
|
|
|
+ Document origin;
|
|
|
|
+ List<DataMap> needToSave = new ArrayList<>(1000);
|
|
|
|
+ while (cursor.hasNext()) {
|
|
|
|
+ origin = cursor.next();
|
|
|
|
+ DataMap dataMap = new DataMap();
|
|
|
|
+ dataMap.put("fileId", newFileId);
|
|
|
|
+ needToSave.add(dataMap);
|
|
|
|
+ if (needToSave.size() >= 1000) {
|
|
|
|
+ saveLines(new ArrayList<>(needToSave), mongoTemplate);
|
|
|
|
+ needToSave.clear();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (CollectionUtils.isNotEmpty(needToSave)) {
|
|
|
|
+ saveLines(needToSave, mongoTemplate);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ latch.countDown();
|
|
|
|
+ log.info("数据统计-主体信息结束");
|
|
|
|
+ }
|
|
|
|
+}
|