|
@@ -0,0 +1,164 @@
|
|
|
+package ieven.server.webapp.service.datastatic;
|
|
|
+
|
|
|
+import com.mongodb.client.MongoCursor;
|
|
|
+import ieven.server.webapp.domain.alipay.AlipayHeaders;
|
|
|
+import ieven.server.webapp.domain.alipay.HeaderProperties;
|
|
|
+import ieven.server.webapp.domain.data.AccountVO;
|
|
|
+import ieven.server.webapp.domain.data.DataMap;
|
|
|
+import ieven.server.webapp.domain.file.FileService;
|
|
|
+import ieven.server.webapp.domain.tenpay.TenpayHeaders;
|
|
|
+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 org.springframework.data.mongodb.core.query.Criteria;
|
|
|
+import org.springframework.data.mongodb.core.query.Query;
|
|
|
+
|
|
|
+import java.math.BigDecimal;
|
|
|
+import java.util.*;
|
|
|
+import java.util.concurrent.CountDownLatch;
|
|
|
+
|
|
|
+@Slf4j
|
|
|
+public class DataStaticAnalysisTotal extends Ops implements Runnable {
|
|
|
+ private HeaderProperties headerProperties;
|
|
|
+ String modelId;
|
|
|
+ MongoTemplate mongoTemplate;
|
|
|
+ FileService fileService;
|
|
|
+ CountDownLatch latch;
|
|
|
+
|
|
|
+ public DataStaticAnalysisTotal(
|
|
|
+ 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 dateFileId = getFileId("数据分析-主体信息汇总明细", modelId, mongoTemplate);
|
|
|
+ // 插入记录用户后续查询明细
|
|
|
+ if (StringUtils.isNotBlank(dateFileId)) {
|
|
|
+ MongoCursor<Document> cursor = getCursor(dateFileId, mongoTemplate);
|
|
|
+ if (cursor.hasNext()) {
|
|
|
+ newFileId =createLogicAndDeleteOld("数据分析-主体信息汇总", modelId,headerProperties.getAntiSecurityTradeScaleAnalysisOutput(),mongoTemplate, fileService);
|
|
|
+ insertFromTo(dateFileId, newFileId, modelId, mongoTemplate);
|
|
|
+ }
|
|
|
+ Set<String> alipayIds = new HashSet<>();
|
|
|
+ Map<String, DataMap> idToData = new HashMap<>();
|
|
|
+ Map<String, Set<String>> idToNames = new HashMap<>();
|
|
|
+ Document origin;
|
|
|
+ while (cursor.hasNext()) {
|
|
|
+ try {
|
|
|
+ origin = cursor.next();
|
|
|
+ String alipayId = origin.getString("交易主体账号");
|
|
|
+ DataMap dataMap;
|
|
|
+ if (!alipayIds.contains(alipayId)) {
|
|
|
+ alipayIds.add(alipayId);
|
|
|
+ dataMap = new DataMap();
|
|
|
+ dataMap.put("fileId", newFileId);
|
|
|
+ dataMap.put("交易主体账号", alipayId);
|
|
|
+ dataMap.put("交易主体户名", "");
|
|
|
+ idToData.put(alipayId, dataMap);
|
|
|
+ }
|
|
|
+ String alipayUsername = origin.getString("交易主体户名");
|
|
|
+ if (StringUtils.isNotBlank(alipayUsername)) {
|
|
|
+ Set<String> namesSet;
|
|
|
+ if (idToNames.containsKey(alipayId)) {
|
|
|
+ namesSet = idToNames.get(alipayId);
|
|
|
+ } else {
|
|
|
+ namesSet = new HashSet<>();
|
|
|
+ idToNames.put(alipayId, namesSet);
|
|
|
+ }
|
|
|
+ namesSet.add(alipayUsername);
|
|
|
+ }
|
|
|
+
|
|
|
+ } catch (Exception exception) {
|
|
|
+ log.error(exception.getMessage(), exception);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (CollectionUtils.isNotEmpty(idToData.values())) {
|
|
|
+ for (Map.Entry<String, DataMap> entry : idToData.entrySet()) {
|
|
|
+ DataMap dataMap = entry.getValue();
|
|
|
+ String id = (String) dataMap.get("交易主体账号");
|
|
|
+ Set<String> namesSet = idToNames.get(id);
|
|
|
+ if (CollectionUtils.isNotEmpty(namesSet)) {
|
|
|
+ dataMap.put("交易主体户名", StringUtils.join(namesSet, ";"));
|
|
|
+ }
|
|
|
+
|
|
|
+ //查询其他的基本信息
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ latch.countDown();
|
|
|
+ log.info("数据分析-主体信息汇总开始");
|
|
|
+ }
|
|
|
+
|
|
|
+ public void getData(DataMap dataMap,Document origin){
|
|
|
+ String type = origin.getString("类型");
|
|
|
+ String account = origin.getString("交易主体账号");
|
|
|
+ String zjha="";
|
|
|
+ String bdyhkh="";
|
|
|
+ String khyhmc="";
|
|
|
+ String bdsjh="";
|
|
|
+ String zcsj="";
|
|
|
+ if("财付通".equals(type)){
|
|
|
+ //账户状态", "账号", "注册姓名", "注册时间", "注册身份证号", "绑定手机", "绑定状态", "开户行信息", "银行账号"
|
|
|
+ String dateFileId2 = getFileId(TenpayHeaders.getGeneratedName(3), modelId, mongoTemplate);
|
|
|
+ List<DataMap> dataMaps = this.mongoTemplate.find((new Query(
|
|
|
+ Criteria.where("modelId")
|
|
|
+ .is(modelId)
|
|
|
+ .and("fileId")
|
|
|
+ .is(dateFileId2)
|
|
|
+ .and("账号")
|
|
|
+ .is(account)
|
|
|
+ .and("generated")
|
|
|
+ .is(Boolean.TRUE))), DataMap.class);
|
|
|
+ if(CollectionUtils.isNotEmpty(dataMaps)){
|
|
|
+ zjha=String.valueOf(dataMaps.get(0).get("注册身份证号"));
|
|
|
+ bdyhkh=String.valueOf(dataMaps.get(0).get("银行账号"));
|
|
|
+ khyhmc=String.valueOf(dataMaps.get(0).get("开户行信息"));
|
|
|
+ bdsjh=String.valueOf(dataMaps.get(0).get("绑定手机"));
|
|
|
+ zcsj=String.valueOf(dataMaps.get(0).get("注册时间"));
|
|
|
+ }
|
|
|
+ }else if("反诈".equals(type)){
|
|
|
+ // "交易号", "商户订单号", "交易创建时间", "付款时间", "最近修改时间", "交易来源地", "类型", "用户信息", "交易对方信息", "消费名称", "金额(元)", "收/支", "交易状态", "备注", "对应的协查数据"));
|
|
|
+
|
|
|
+
|
|
|
+ }else if("五联单".equals(type)){
|
|
|
+// "用户ID", "登录邮箱", "登录手机", "账户名称", "证件类型", "证件号", "可用余额", "注册时间", "绑定手机", "绑定银行卡", "对应的协查数据"));
|
|
|
+ String dateFileId2 = getFileId(AlipayHeaders.getGeneratedName(2), modelId, mongoTemplate);
|
|
|
+ List<DataMap> dataMaps = this.mongoTemplate.find((new Query(
|
|
|
+ Criteria.where("modelId")
|
|
|
+ .is(modelId)
|
|
|
+ .and("fileId")
|
|
|
+ .is(dateFileId2)
|
|
|
+ .and("用户ID")
|
|
|
+ .is(account)
|
|
|
+ .and("generated")
|
|
|
+ .is(Boolean.TRUE))), DataMap.class);
|
|
|
+ if(CollectionUtils.isNotEmpty(dataMaps)){
|
|
|
+ zjha=String.valueOf(dataMaps.get(0).get("证件号"));
|
|
|
+ bdyhkh=String.valueOf(dataMaps.get(0).get("绑定银行卡"));
|
|
|
+ khyhmc=String.valueOf(dataMaps.get(0).get("账户名称"));
|
|
|
+ bdsjh=String.valueOf(dataMaps.get(0).get("登录手机"));
|
|
|
+ zcsj=String.valueOf(dataMaps.get(0).get("注册时间"));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ dataMap.put("证件号码", zjha);
|
|
|
+ dataMap.put("绑定银行卡号", bdyhkh);
|
|
|
+ dataMap.put("开户银行名称", khyhmc);
|
|
|
+ dataMap.put("绑定手机号", bdsjh);
|
|
|
+ dataMap.put("注册时间", zcsj);
|
|
|
+ }
|
|
|
+}
|