|
|
@ -1,6 +1,7 @@
|
|
|
|
package com.sztzjy.marketing.service.impl;
|
|
|
|
package com.sztzjy.marketing.service.impl;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
|
import com.google.gson.Gson;
|
|
|
|
import com.google.gson.Gson;
|
|
|
|
import com.google.gson.reflect.TypeToken;
|
|
|
|
import com.google.gson.reflect.TypeToken;
|
|
|
|
import com.hankcs.hanlp.HanLP;
|
|
|
|
import com.hankcs.hanlp.HanLP;
|
|
|
@ -30,6 +31,7 @@ import java.util.*;
|
|
|
|
import java.util.regex.Matcher;
|
|
|
|
import java.util.regex.Matcher;
|
|
|
|
import java.util.regex.Pattern;
|
|
|
|
import java.util.regex.Pattern;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import static com.sztzjy.marketing.util.StringUtils.convertCamelCaseToUnderscore;
|
|
|
|
import static com.sztzjy.marketing.util.algorithm.BaiDuZhiNengYun.getAccessToken;
|
|
|
|
import static com.sztzjy.marketing.util.algorithm.BaiDuZhiNengYun.getAccessToken;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
@ -45,6 +47,9 @@ public class StuDigitalMarketingModelServiceImpl implements StuDigitalMarketingM
|
|
|
|
@Resource
|
|
|
|
@Resource
|
|
|
|
StuTableNameMapper stuTableNameMapper;
|
|
|
|
StuTableNameMapper stuTableNameMapper;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
|
|
|
StuUploadExcelUserMapper uploadExcelUserMapper;
|
|
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
@Resource
|
|
|
|
StuSelectIndicatorsMapper indicatorsMapper;
|
|
|
|
StuSelectIndicatorsMapper indicatorsMapper;
|
|
|
|
@Resource
|
|
|
|
@Resource
|
|
|
@ -346,6 +351,31 @@ public class StuDigitalMarketingModelServiceImpl implements StuDigitalMarketingM
|
|
|
|
list.add("id");
|
|
|
|
list.add("id");
|
|
|
|
list.add("user_behavior_type");
|
|
|
|
list.add("user_behavior_type");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}else {
|
|
|
|
|
|
|
|
//查询导入的表数据
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<String> stringList=uploadExcelUserMapper.selectByString(userId,tableName);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (String s : stringList) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<String> rightList = JSON.parseArray(s, String.class);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<String> strings=new ArrayList<>();
|
|
|
|
|
|
|
|
for (int i = 0; i < rightList.size(); i++) { //转为驼峰命名
|
|
|
|
|
|
|
|
String string = convertCamelCaseToUnderscore(rightList.get(i));
|
|
|
|
|
|
|
|
strings.add(string);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!list.isEmpty()){
|
|
|
|
|
|
|
|
if(list.size()<strings.size()){
|
|
|
|
|
|
|
|
list=strings;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}else {
|
|
|
|
|
|
|
|
list=strings;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -353,6 +383,9 @@ public class StuDigitalMarketingModelServiceImpl implements StuDigitalMarketingM
|
|
|
|
return list;
|
|
|
|
return list;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public ResultEntity viewAnalyzeData(AnalyzeDataDTO analyzeDataDTO) {
|
|
|
|
public ResultEntity viewAnalyzeData(AnalyzeDataDTO analyzeDataDTO) {
|
|
|
|
|
|
|
|
|
|
|
@ -363,22 +396,47 @@ public class StuDigitalMarketingModelServiceImpl implements StuDigitalMarketingM
|
|
|
|
table="stu_user_attribute";
|
|
|
|
table="stu_user_attribute";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if(analyzeDataDTO.getTableName().equals(Constant.YHDLHYB)){ //查询用户登录活跃表
|
|
|
|
else if(analyzeDataDTO.getTableName().equals(Constant.YHDLHYB)){ //查询用户登录活跃表
|
|
|
|
table="stu_user_login_active";
|
|
|
|
table="stu_user_login_active";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if(analyzeDataDTO.getTableName().equals(Constant.YHXFNLB)){ //查询用户消费能力表
|
|
|
|
else if(analyzeDataDTO.getTableName().equals(Constant.YHXFNLB)){ //查询用户消费能力表
|
|
|
|
table="stu_user_consumption_ability";
|
|
|
|
table="stu_user_consumption_ability";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if(analyzeDataDTO.getTableName().equals(Constant.YHPLB) || analyzeDataDTO.getTableName().equals(Constant.YHXWB)){ //查询用户评论或行为表
|
|
|
|
else if(analyzeDataDTO.getTableName().equals(Constant.YHPLB) || analyzeDataDTO.getTableName().equals(Constant.YHXWB)){ //查询用户评论或行为表
|
|
|
|
table="stu_user_behavior";
|
|
|
|
table="stu_user_behavior";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}else {
|
|
|
|
|
|
|
|
table="stu_upload_excel_user"; //查询用户自建表
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<String> fieldList = analyzeDataDTO.getFieldList();
|
|
|
|
|
|
|
|
String userId = analyzeDataDTO.getUserId();
|
|
|
|
|
|
|
|
String tableName = analyzeDataDTO.getTableName();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<Map<String,Object>> attributes = stuTableNameMapper.selectBuildTable(fieldList,table,userId,tableName);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < attributes.size(); i++) {
|
|
|
|
|
|
|
|
if(attributes.get(i).size()<fieldList.size()){
|
|
|
|
|
|
|
|
Collections.rotate(attributes,-1);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return new ResultEntity(HttpStatus.OK,attributes);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
List<String> fieldList = analyzeDataDTO.getFieldList();
|
|
|
|
List<String> fieldList = analyzeDataDTO.getFieldList();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<Map<String,Object>> attributes = stuTableNameMapper.selectByFields(fieldList,table);
|
|
|
|
List<Map<String,Object>> attributes = stuTableNameMapper.selectByFields(fieldList,table);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < attributes.size(); i++) {
|
|
|
|
|
|
|
|
if(attributes.get(i).size()<fieldList.size()){
|
|
|
|
|
|
|
|
Collections.rotate(attributes,-1);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// //将日期类型转为时间戳返回
|
|
|
|
// //将日期类型转为时间戳返回
|
|
|
@ -425,6 +483,7 @@ public class StuDigitalMarketingModelServiceImpl implements StuDigitalMarketingM
|
|
|
|
if(method.equals("缺失值处理--剔除数据")){
|
|
|
|
if(method.equals("缺失值处理--剔除数据")){
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
deduplicatedDataList.removeIf(record -> record.containsValue(null));
|
|
|
|
deduplicatedDataList.removeIf(record -> record.containsValue(null));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -493,5 +552,20 @@ public class StuDigitalMarketingModelServiceImpl implements StuDigitalMarketingM
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return mode != null ? mode : ""; // 如果存在众数则返回,否则返回空字符串
|
|
|
|
return mode != null ? mode : ""; // 如果存在众数则返回,否则返回空字符串
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public static List<Map<String, Object>> filterEmptyValues(List<Map<String, Object>> dataList) {
|
|
|
|
|
|
|
|
List<Map<String, Object>> filteredList = new ArrayList<>();
|
|
|
|
|
|
|
|
for (Map<String, Object> map : dataList) {
|
|
|
|
|
|
|
|
boolean allValuesEmpty = true;
|
|
|
|
|
|
|
|
for (Object value : map.values()) {
|
|
|
|
|
|
|
|
if (value != null) {
|
|
|
|
|
|
|
|
allValuesEmpty = false;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!allValuesEmpty) {
|
|
|
|
|
|
|
|
filteredList.add(map);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return filteredList;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|