|
|
|
@ -1,9 +1,12 @@
|
|
|
|
package com.sztzjy.linkCommerce.controller.stu;
|
|
|
|
package com.sztzjy.linkCommerce.controller.stu;
|
|
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.util.IdUtil;
|
|
|
|
import cn.hutool.core.util.IdUtil;
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
|
import com.sztzjy.linkCommerce.annotation.AnonymousAccess;
|
|
|
|
import com.sztzjy.linkCommerce.annotation.AnonymousAccess;
|
|
|
|
import com.sztzjy.linkCommerce.config.Constant;
|
|
|
|
import com.sztzjy.linkCommerce.config.Constant;
|
|
|
|
import com.sztzjy.linkCommerce.entity.*;
|
|
|
|
import com.sztzjy.linkCommerce.entity.*;
|
|
|
|
|
|
|
|
import com.sztzjy.linkCommerce.entity.dto.FbqdDTO;
|
|
|
|
|
|
|
|
import com.sztzjy.linkCommerce.entity.dto.FbqdStuAnswerDTO;
|
|
|
|
import com.sztzjy.linkCommerce.mapper.*;
|
|
|
|
import com.sztzjy.linkCommerce.mapper.*;
|
|
|
|
import com.sztzjy.linkCommerce.service.ScoreService;
|
|
|
|
import com.sztzjy.linkCommerce.service.ScoreService;
|
|
|
|
import com.sztzjy.linkCommerce.util.CompareListsUtil;
|
|
|
|
import com.sztzjy.linkCommerce.util.CompareListsUtil;
|
|
|
|
@ -22,9 +25,11 @@ import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
import java.math.BigDecimal;
|
|
|
|
import java.math.BigDecimal;
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.Date;
|
|
|
|
import java.util.Date;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.UUID;
|
|
|
|
import java.util.UUID;
|
|
|
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* @author 17803
|
|
|
|
* @author 17803
|
|
|
|
@ -59,73 +64,58 @@ public class CptfController {
|
|
|
|
@PostMapping("/commitCpdjAnswer")
|
|
|
|
@PostMapping("/commitCpdjAnswer")
|
|
|
|
@ApiOperation("发布渠道-提交")
|
|
|
|
@ApiOperation("发布渠道-提交")
|
|
|
|
@AnonymousAccess
|
|
|
|
@AnonymousAccess
|
|
|
|
public ResultEntity commitFbqdAnswer(@RequestBody FbqdStuAnswer stuAnswer) {
|
|
|
|
// public ResultEntity commitFbqdAnswer(@RequestBody FbqdStuAnswer stuAnswer,FbqdStuAnswerDTO fbqdStuAnswerDTO) {
|
|
|
|
|
|
|
|
public ResultEntity commitCpdjAnswer(@RequestBody FbqdStuAnswerDTO fbqdStuAnswerDTO) {
|
|
|
|
//先查询是否提交过
|
|
|
|
//先查询是否提交过
|
|
|
|
StuGradeExample stuGradeExample = new StuGradeExample();
|
|
|
|
StuGradeExample stuGradeExample = new StuGradeExample();
|
|
|
|
stuGradeExample.createCriteria().andUserIdEqualTo(stuAnswer.getUserId()).andProjectEqualTo(Constant.PRO_CPTFCS).andModuleEqualTo(Constant.MODULE_CPDJ);
|
|
|
|
stuGradeExample.createCriteria().andUserIdEqualTo(fbqdStuAnswerDTO.getUserId()).andProjectEqualTo(Constant.PRO_CPTFCS).andModuleEqualTo(Constant.MODULE_CPDJ);
|
|
|
|
List<StuGrade> stuGradeList = stuGradeMapper.selectByExampleWithBLOBs(stuGradeExample);
|
|
|
|
List<StuGrade> stuGradeList = stuGradeMapper.selectByExampleWithBLOBs(stuGradeExample);
|
|
|
|
if(CollectionUtils.isEmpty(stuGradeList)){
|
|
|
|
if(CollectionUtils.isEmpty(stuGradeList)){
|
|
|
|
FbqdAnswer answer = fbqdAnswerMapper.selectByExampleWithBLOBs(new FbqdAnswerExample()).get(0);
|
|
|
|
// FbqdAnswer answer = fbqdAnswerMapper.selectByExampleWithBLOBs(new FbqdAnswerExample()).get(0);
|
|
|
|
int count = 0;
|
|
|
|
int count = 0;
|
|
|
|
|
|
|
|
|
|
|
|
//1.数据标准化结果
|
|
|
|
//1.
|
|
|
|
String stuExposureData = stuAnswer.getExposureData();
|
|
|
|
List<FbqdDTO> dataInfoList = fbqdStuAnswerDTO.getDataInfoList();
|
|
|
|
|
|
|
|
String oneAnswer = "1,1,1,1,0,0,0.1965,0.3565,0.3767,0.9430,0,0";
|
|
|
|
|
|
|
|
int count1 = calculte(dataInfoList,1,oneAnswer);
|
|
|
|
|
|
|
|
|
|
|
|
String exposureData = answer.getExposureData();
|
|
|
|
|
|
|
|
//数据标准化结果 校验
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//错误次数
|
|
|
|
|
|
|
|
int monthlyDataErrorCount =compareListsUtil.compareErrorCount(stuExposureData, exposureData).getErrorCount();
|
|
|
|
|
|
|
|
count = count + monthlyDataErrorCount;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//2.渠道中的比重
|
|
|
|
|
|
|
|
String stuAnswerClickData = stuAnswer.getClickData();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String clickData = answer.getClickData();
|
|
|
|
|
|
|
|
//错误次数
|
|
|
|
|
|
|
|
int cheapSumCount =compareListsUtil.compareErrorCount(stuAnswerClickData, clickData).getErrorCount();
|
|
|
|
|
|
|
|
count = count + cheapSumCount;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//2.
|
|
|
|
|
|
|
|
List<FbqdDTO> radioInfoList = fbqdStuAnswerDTO.getRadioInfoList();
|
|
|
|
|
|
|
|
String twoAnswer = "0.7264,0.5147,0.8358,0.7372,0,0,0.1642,0.2628,0.2736,0.4853,0,0";
|
|
|
|
|
|
|
|
int count2 = calculte(radioInfoList,2,twoAnswer);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//3.信息滴
|
|
|
|
//3.
|
|
|
|
String stuAnswerAdCost = stuAnswer.getAdCost();
|
|
|
|
List<FbqdDTO> messageInfoList = fbqdStuAnswerDTO.getMessageInfoList();
|
|
|
|
|
|
|
|
String threeAnswer = "0.6305,0.5342,0.4066,0.5243";
|
|
|
|
|
|
|
|
int count3 =calculte(messageInfoList,3,threeAnswer);
|
|
|
|
|
|
|
|
|
|
|
|
String adCost = answer.getAdCost();
|
|
|
|
//4.
|
|
|
|
//错误次数
|
|
|
|
List<FbqdDTO> eventInfoList = fbqdStuAnswerDTO.getEventInfoList();
|
|
|
|
int cheapPercentageCount =compareListsUtil.compareErrorCount(stuAnswerAdCost, adCost).getErrorCount();
|
|
|
|
String fourAnswer = "0.1940,0.2446,0.3116,0.2498";
|
|
|
|
count = count + cheapPercentageCount;
|
|
|
|
int count4 = calculte(eventInfoList,4,fourAnswer);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//5.综合评分
|
|
|
|
|
|
|
|
String fiveAnswer = "1,0.1503,0.2751";
|
|
|
|
|
|
|
|
|
|
|
|
//每个指标的权重
|
|
|
|
int fiveCount = compareListsUtil.compareErrorCount(fbqdStuAnswerDTO.getKeywords(), fiveAnswer).getErrorCount();
|
|
|
|
String stuAnswerOrderAmount = stuAnswer.getOrderAmount();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String orderAmount = answer.getOrderAmount();
|
|
|
|
|
|
|
|
//错误次数
|
|
|
|
|
|
|
|
int costEffectiveSumCount =compareListsUtil.compareErrorCount(stuAnswerOrderAmount, orderAmount).getErrorCount();
|
|
|
|
|
|
|
|
count = count + costEffectiveSumCount;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//主观题
|
|
|
|
//综合评分
|
|
|
|
int i = compareListsUtil.calculateLengthPenaltyEnhanced(fbqdStuAnswerDTO.getScenePromotion());
|
|
|
|
String stuAnswerKeywords = stuAnswer.getKeywords();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String keywords = answer.getKeywords();
|
|
|
|
|
|
|
|
//错误次数
|
|
|
|
|
|
|
|
int costEffectivePercentageCount =compareListsUtil.compareErrorCount(stuAnswerKeywords, keywords).getErrorCount();
|
|
|
|
|
|
|
|
count = count + costEffectivePercentageCount;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
count= count1 + count2+count3+count4+i + fiveCount;
|
|
|
|
|
|
|
|
|
|
|
|
//主观题
|
|
|
|
FbqdStuAnswer fbqdStuAnswer = new FbqdStuAnswer();
|
|
|
|
int i = compareListsUtil.calculateLengthPenaltyEnhanced(stuAnswer.getScenePromotion());
|
|
|
|
fbqdStuAnswer.setId(IdUtil.simpleUUID());
|
|
|
|
count = count + i;
|
|
|
|
fbqdStuAnswer.setUserId(fbqdStuAnswerDTO.getUserId());
|
|
|
|
stuAnswer.setId(IdUtil.simpleUUID());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fbqdStuAnswerMapper.insertSelective(stuAnswer);
|
|
|
|
fbqdStuAnswer.setCrowdPromotion( JSON.toJSONString(fbqdStuAnswerDTO));
|
|
|
|
|
|
|
|
fbqdStuAnswerMapper.insertSelective(fbqdStuAnswer);
|
|
|
|
|
|
|
|
|
|
|
|
Boolean aBoolean = scoreService.insertScore(stuAnswer.getUserId(), Constant.PRO_CPTFCS, Constant.MODULE_FBQDPG, BigDecimal.valueOf(100 - count), stuAnswer.getScenePromotion());
|
|
|
|
Boolean aBoolean = scoreService.insertScore(fbqdStuAnswerDTO.getUserId(), Constant.PRO_CPTFCS, Constant.MODULE_FBQDPG, BigDecimal.valueOf(100 - count), fbqdStuAnswerDTO.getScenePromotion());
|
|
|
|
if(aBoolean){
|
|
|
|
if(aBoolean){
|
|
|
|
return new ResultEntity<>(HttpStatus.OK, "提交成功");
|
|
|
|
return new ResultEntity<>(HttpStatus.OK, "提交成功");
|
|
|
|
}else {
|
|
|
|
}else {
|
|
|
|
@ -151,7 +141,10 @@ public class CptfController {
|
|
|
|
if (CollectionUtils.isEmpty(stuAnswerList)) {
|
|
|
|
if (CollectionUtils.isEmpty(stuAnswerList)) {
|
|
|
|
return new ResultEntity<>(HttpStatus.OK);
|
|
|
|
return new ResultEntity<>(HttpStatus.OK);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
return new ResultEntity<>(HttpStatus.OK, stuAnswerList.get(0));
|
|
|
|
String crowdPromotion = stuAnswerList.get(0).getCrowdPromotion();
|
|
|
|
|
|
|
|
// 从字符串解析回对象
|
|
|
|
|
|
|
|
FbqdStuAnswerDTO parsedDTO = JSON.parseObject(crowdPromotion, FbqdStuAnswerDTO.class);
|
|
|
|
|
|
|
|
return new ResultEntity<>(HttpStatus.OK, parsedDTO);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -411,5 +404,41 @@ public class CptfController {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public Integer calculte( List<FbqdDTO> dataInfoList,Integer ser,String answer ) {
|
|
|
|
|
|
|
|
int count = 0;
|
|
|
|
|
|
|
|
if (CollectionUtils.isEmpty(dataInfoList)) {
|
|
|
|
|
|
|
|
if (ser==1)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return 12;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ser==2)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return 12;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ser==3)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return 4;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ser==4)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return 4;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
List<String> array = new ArrayList<>(); // 确保使用 List 并初始化
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (FbqdDTO fbqdDTO : dataInfoList) {
|
|
|
|
|
|
|
|
array.add(fbqdDTO.getExposureData());
|
|
|
|
|
|
|
|
array.add(fbqdDTO.getClickData());
|
|
|
|
|
|
|
|
array.add(fbqdDTO.getAdCost());
|
|
|
|
|
|
|
|
array.add(fbqdDTO.getOrderAmount());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String[] array1 = array.toArray(new String[0]); // 正确转换为 String[]
|
|
|
|
|
|
|
|
String result = String.join(",", array1);
|
|
|
|
|
|
|
|
int monthlyDataErrorCount = compareListsUtil.compareErrorCount(result, answer).getErrorCount();
|
|
|
|
|
|
|
|
count = count + monthlyDataErrorCount;
|
|
|
|
|
|
|
|
return count;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|