修改发布渠道传参方式和计分规则

main
whb 1 year ago
parent de00c6c52a
commit 163884a70c

@ -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();
//数据标准化结果 校验
//错误次数 //2.
int monthlyDataErrorCount =compareListsUtil.compareErrorCount(stuExposureData, exposureData).getErrorCount(); List<FbqdDTO> radioInfoList = fbqdStuAnswerDTO.getRadioInfoList();
count = count + monthlyDataErrorCount; 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);
//2.渠道中的比重
String stuAnswerClickData = stuAnswer.getClickData();
String clickData = answer.getClickData();
//错误次数
int cheapSumCount =compareListsUtil.compareErrorCount(stuAnswerClickData, clickData).getErrorCount();
count = count + cheapSumCount;
//3.信息滴
String stuAnswerAdCost = stuAnswer.getAdCost();
String adCost = answer.getAdCost();
//错误次数
int cheapPercentageCount =compareListsUtil.compareErrorCount(stuAnswerAdCost, adCost).getErrorCount();
count = count + cheapPercentageCount;
//3.
List<FbqdDTO> messageInfoList = fbqdStuAnswerDTO.getMessageInfoList();
String threeAnswer = "0.6305,0.5342,0.4066,0.5243";
int count3 =calculte(messageInfoList,3,threeAnswer);
//每个指标的权重 //4.
String stuAnswerOrderAmount = stuAnswer.getOrderAmount(); List<FbqdDTO> eventInfoList = fbqdStuAnswerDTO.getEventInfoList();
String fourAnswer = "0.1940,0.2446,0.3116,0.2498";
String orderAmount = answer.getOrderAmount(); int count4 = calculte(eventInfoList,4,fourAnswer);
//错误次数
int costEffectiveSumCount =compareListsUtil.compareErrorCount(stuAnswerOrderAmount, orderAmount).getErrorCount();
count = count + costEffectiveSumCount;
//5.综合评分
String fiveAnswer = "1,0.1503,0.2751";
int fiveCount = compareListsUtil.compareErrorCount(fbqdStuAnswerDTO.getKeywords(), fiveAnswer).getErrorCount();
//综合评分
String stuAnswerKeywords = stuAnswer.getKeywords();
String keywords = answer.getKeywords(); //主观题
//错误次数 int i = compareListsUtil.calculateLengthPenaltyEnhanced(fbqdStuAnswerDTO.getScenePromotion());
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;
}
}
} }

@ -1,6 +1,9 @@
package com.sztzjy.linkCommerce.entity; package com.sztzjy.linkCommerce.entity;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import java.util.List;
/** /**
* *
* *
@ -17,16 +20,16 @@ public class FbqdStuAnswer {
@ApiModelProperty(notes = "用户ID关联userinfo表") @ApiModelProperty(notes = "用户ID关联userinfo表")
private String userId; private String userId;
@ApiModelProperty(notes = "1.数据标准化结果(以逗号隔开,没做就为空)") @ApiModelProperty(notes = "曝光量")
private String exposureData; private String exposureData;
@ApiModelProperty(notes = "2.每个渠道中的比重(以逗号隔开,没做就为空)") @ApiModelProperty(notes = "点击量")
private String clickData; private String clickData;
@ApiModelProperty(notes = "3.每个指标的信息熵(以逗号隔开,没做就为空)") @ApiModelProperty(notes = "花费")
private String adCost; private String adCost;
@ApiModelProperty(notes = "4.计算每个指标的权重(以逗号隔开,没做就为空)") @ApiModelProperty(notes = "订单金额")
private String orderAmount; private String orderAmount;
@ApiModelProperty(notes = "5.综合评分(以逗号隔开,没做就为空)") @ApiModelProperty(notes = "5.综合评分(以逗号隔开,没做就为空)")

@ -0,0 +1,25 @@
package com.sztzjy.linkCommerce.entity.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @author 17803
* @date 2025-05-01 15:57
*/
@Data
public class FbqdDTO {
@ApiModelProperty(notes = "曝光量")
private String exposureData;
@ApiModelProperty(notes = "点击量")
private String clickData;
@ApiModelProperty(notes = "花费")
private String adCost;
@ApiModelProperty(notes = "订单金额")
private String orderAmount;
}

@ -0,0 +1,42 @@
package com.sztzjy.linkCommerce.entity.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
/**
* @author 17803
* @date 2025-05-01 15:56
*/
@Data
public class FbqdStuAnswerDTO {
@ApiModelProperty(notes = "1.数据标准化结果")
private List<FbqdDTO> dataInfoList;
@ApiModelProperty(notes = "2.每个渠道中的比重")
private List<FbqdDTO> radioInfoList;
@ApiModelProperty(notes = "3.计算每个指标的信息熵")
private List<FbqdDTO> messageInfoList;
@ApiModelProperty(notes = "4.计算每个指标的权重")
private List<FbqdDTO> eventInfoList;
@ApiModelProperty(notes = "5.综合评分(以逗号隔开,没做就为空)")
private String keywords;
@ApiModelProperty(notes = "6.主观题")
private String scenePromotion;
@ApiModelProperty(notes = "用户ID关联userinfo表")
private String userId;
}
Loading…
Cancel
Save